You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are two problems when using quill.format("mention", ...):
It doesn't replace the selected text, but instead inserts the mention after the selection
I get the console error TypeError: wrapper.appendChild is not a function
Other than that, it actually seems to work fine. The first problem can be be worked around by manually deleting text and changing cursor position, and I'm not sure what is breaking due to the error (other than the function not returning anything). But it seems this use case wasn't considered.
In case it helps, this is what I've had to do to workaround the issues:
newCharacterFromSelection(){constselection=this.editor.quillEditor.getSelection();constselectedText=this.editor.quillEditor.getText(selection.index,selection.length,);// This could be any function that returns an observablethis.charService.newCharacter(selectedText).subscribe((character)=>{// Must focus manually, probably due to focus changing due to modalthis.editor.quillEditor.focus();// Delete selection, because format("mention") doesn'tthis.editor.quillEditor.deleteText(selection.index,selection.length);this._insertMention({type: "character",id: character.id,value: character.name,denotationChar: DENOTATIONS.CHARACTER,});// Set cursor to after the mention (should be index + 1, but only + 2 worked)this.editor.quillEditor.setSelection(selection.index+2,0);});}_insertMention(data: {type: string;
id: number;
value: string;
denotationChar: string;}){try{this.editor.quillEditor.format("mention",{index: 0,
...data,});}catch(e){// Have to wrap in try/catch otherwise error can prevent focus/selection/delete working properly}}
There are two problems when using
quill.format("mention", ...)
:TypeError: wrapper.appendChild is not a function
Other than that, it actually seems to work fine. The first problem can be be worked around by manually deleting text and changing cursor position, and I'm not sure what is breaking due to the error (other than the function not returning anything). But it seems this use case wasn't considered.
Tested with:
Versions (using in Angular 9)
The text was updated successfully, but these errors were encountered: