Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/components/ComposerQuill/composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ class Composer extends React.Component {
placeholder,
});

this.quillMention = this.quill.getModule('mention');
const originalHighlightItem = this.quillMention.highlightItem;

const {onMentionFocus} = this.props;

this.quillMention.highlightItem = function(...args) {
onMentionFocus(this.itemIndex);
originalHighlightItem.apply(this, args);
};

// inserts the initial text to the composer
// may contain formats as html tags, so convert those to markdowns
if (typeof draft?.value === 'string') {
Expand Down Expand Up @@ -482,6 +492,7 @@ Composer.propTypes = {
}),
notifyKeyDown: PropTypes.func,
onMentionClose: PropTypes.func,
onMentionFocus: PropTypes.func,
onMentionOpen: PropTypes.func,
onError: PropTypes.func,
placeholder: PropTypes.string,
Expand All @@ -495,6 +506,7 @@ Composer.defaultProps = {
mentions: undefined,
notifyKeyDown: undefined,
onMentionClose: undefined,
onMentionFocus: undefined,
onMentionOpen: undefined,
onError: undefined,
placeholder: 'Compose something awesome...',
Expand Down
6 changes: 5 additions & 1 deletion src/components/MessageComposer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ const MessageComposer = ({
notifyKeyDown,
onMentionOpen,
onMentionClose,
onMentionFocus,
placeholder,
onError,
keyBindings,
sendButton
sendButton,
}) => {
const emitter = useRef(new TinyEmitter());
const [active, setActive] = useState({});
Expand Down Expand Up @@ -54,6 +55,7 @@ const MessageComposer = ({
notifyKeyDown={notifyKeyDown}
onMentionOpen={onMentionOpen}
onMentionClose={onMentionClose}
onMentionFocus={onMentionFocus}
placeholder={placeholder}
onError={onError}
keyBindings={keyBindings}
Expand Down Expand Up @@ -84,6 +86,7 @@ MessageComposer.propTypes = {
}),
notifyKeyDown: PropTypes.func,
onMentionClose: PropTypes.func,
onMentionFocus: PropTypes.func,
onMentionOpen: PropTypes.func,
onError: PropTypes.func,
placeholder: PropTypes.string,
Expand All @@ -102,6 +105,7 @@ MessageComposer.defaultProps = {
mentions: undefined,
notifyKeyDown: null,
onMentionClose: undefined,
onMentionFocus: undefined,
onMentionOpen: undefined,
onError: undefined,
placeholder: '',
Expand Down