Compare commits

...

1 commit

Author SHA1 Message Date
Pranav Raj S
2d5d7866f8 Revert "fix: Updates logic to insert canned response into editor (#5880)"
This reverts commit c94ba16565.
2022-11-30 09:16:37 -08:00

View file

@ -233,9 +233,7 @@ export default {
node node
); );
this.state = this.editorView.state.apply(tr); this.state = this.editorView.state.apply(tr);
this.emitOnChange(); return this.emitOnChange();
return false;
}, },
insertCannedResponse(cannedItem) { insertCannedResponse(cannedItem) {
@ -243,26 +241,22 @@ export default {
return null; return null;
} }
let from = this.range.from - 1; const tr = this.editorView.state.tr.insertText(
let node = addMentionsToMarkdownParser(defaultMarkdownParser).parse( cannedItem,
cannedItem this.range.from,
this.range.to
); );
if (node.childCount === 1) {
node = this.editorView.state.schema.text(cannedItem);
from = this.range.from;
}
const tr = this.editorView.state.tr.replaceWith(
from,
this.range.to,
node
);
this.state = this.editorView.state.apply(tr); this.state = this.editorView.state.apply(tr);
this.emitOnChange(); this.emitOnChange();
tr.scrollIntoView(); // Hacky fix for #5501
this.state = createState(
this.contentFromEditor,
this.placeholder,
this.plugins
);
this.editorView.updateState(this.state);
this.focusEditorInputField();
return false; return false;
}, },