fix: Updates logic to insert canned response into editor (#5880)
* fix: Updates logic to insert canned response into editor * Removes commented code * Parse incoming canned text as markdown
This commit is contained in:
parent
0cad3bed71
commit
c94ba16565
1 changed files with 19 additions and 13 deletions
|
@ -233,7 +233,9 @@ export default {
|
||||||
node
|
node
|
||||||
);
|
);
|
||||||
this.state = this.editorView.state.apply(tr);
|
this.state = this.editorView.state.apply(tr);
|
||||||
return this.emitOnChange();
|
this.emitOnChange();
|
||||||
|
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
insertCannedResponse(cannedItem) {
|
insertCannedResponse(cannedItem) {
|
||||||
|
@ -241,22 +243,26 @@ export default {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tr = this.editorView.state.tr.insertText(
|
let from = this.range.from - 1;
|
||||||
cannedItem,
|
let node = addMentionsToMarkdownParser(defaultMarkdownParser).parse(
|
||||||
this.range.from,
|
cannedItem
|
||||||
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();
|
||||||
|
|
||||||
// Hacky fix for #5501
|
tr.scrollIntoView();
|
||||||
this.state = createState(
|
|
||||||
this.contentFromEditor,
|
|
||||||
this.placeholder,
|
|
||||||
this.plugins
|
|
||||||
);
|
|
||||||
this.editorView.updateState(this.state);
|
|
||||||
this.focusEditorInputField();
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue