Skip to content

Commit 56cebbb

Browse files
author
Amedeo
committed
Add support for asyc mentionning
1 parent 51fecc1 commit 56cebbb

3 files changed

Lines changed: 187 additions & 196 deletions

File tree

src/Editor/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class WysiwygEditor extends Component {
7777
const newState = {};
7878
const { editorState, contentState } = this.props;
7979
if (!this.state.toolbar) {
80-
const toolbar = mergeRecursive(defaultToolbar, toolbar);
80+
const toolbar = mergeRecursive(defaultToolbar, this.state.toolbar);
8181
newState.toolbar = toolbar;
8282
}
8383
if (
@@ -216,9 +216,14 @@ class WysiwygEditor extends Component {
216216
decorators.push(
217217
...getMentionDecorators({
218218
...this.props.mention,
219-
onChange: this.onChange,
219+
onChange: this.props?.mention?.onChange ? (editorState, selectedSuggestion) => {
220+
this.props.mention.onChange(selectedSuggestion, editorState);
221+
this.onChange(editorState);
222+
} : this.onChange,
220223
getEditorState: this.getEditorState,
221-
getSuggestions: this.getSuggestions,
224+
getSuggestions: this.props?.mention?.getSuggestions ? (mentionText) => {
225+
return this.props.mention.getSuggestions(mentionText)
226+
} : this.getSuggestions,
222227
getWrapperRef: this.getWrapperRef,
223228
modalHandler: this.modalHandler,
224229
})

0 commit comments

Comments
 (0)