-import React from 'react';
+import React, { useRef } from 'react';
import PropTypes from 'prop-types';
import './Message.scss';
import Text from '../../atoms/text/Text';
import RawIcon from '../../atoms/system-icons/RawIcon';
+import Button from '../../atoms/button/Button';
import Tooltip from '../../atoms/tooltip/Tooltip';
+import Input from '../../atoms/input/Input';
import ReplyArrowIC from '../../../../public/res/ic/outlined/reply-arrow.svg';
isEdited: PropTypes.bool,
};
+function MessageEdit({ content, onSave, onCancel }) {
+ const editInputRef = useRef(null);
+ return (
+ <form className="message__edit" onSubmit={(e) => { e.preventDefault(); onSave(editInputRef.current.value); }}>
+ <Input
+ forwardRef={editInputRef}
+ value={content}
+ placeholder="Edit message"
+ required
+ resizable
+ />
+ <div className="message__edit-btns">
+ <Button type="submit" variant="primary">Save</Button>
+ <Button onClick={onCancel}>Cancel</Button>
+ </div>
+ </form>
+ );
+}
+MessageEdit.propTypes = {
+ content: PropTypes.string.isRequired,
+ onSave: PropTypes.func.isRequired,
+ onCancel: PropTypes.func.isRequired,
+};
+
function MessageReactionGroup({ children }) {
return (
<div className="message__reactions text text-b3 noselect">
};
function Message({
- avatar, header, reply, content, reactions, options,
+ avatar, header, reply, content, editContent, reactions, options,
}) {
const msgClass = header === null ? ' message--content-only' : ' message--full';
return (
<div className="message__main-container">
{header !== null && header}
{reply !== null && reply}
- {content}
+ {content !== null && content}
+ {editContent !== null && editContent}
{reactions !== null && reactions}
{options !== null && options}
</div>
avatar: null,
header: null,
reply: null,
+ content: null,
+ editContent: null,
reactions: null,
options: null,
};
avatar: PropTypes.node,
header: PropTypes.node,
reply: PropTypes.node,
- content: PropTypes.node.isRequired,
+ content: PropTypes.node,
+ editContent: PropTypes.node,
reactions: PropTypes.node,
options: PropTypes.node,
};
MessageHeader,
MessageReply,
MessageContent,
+ MessageEdit,
MessageReactionGroup,
MessageReaction,
MessageOptions,