Description
I'm using a custom plugin with active of:
onClick: function (evt) {
const languageMenu = this.context.languageMenu;
const newNode = this.util.createElement('lang');
newNode.classList.add("language");
newNode.setAttribute("lang", languageMenu.selectedLanguage)
this.nodeChange(newNode, null, ["lang"], null);
this.submenuOff();
}
This creates a <lang lang="fi">the text that was selected</lang>
in the editor. Works nicely, and changes the selected text between chosen languages.
I have another action which uses nodeChange(null, null ["lang"], null);
to reset the formatting.
Case 1 (Works): Reset exact selection back to plaintext by using nodeChange with first parameter null
Case 2 (Nothing happens): Reset overlapping selection back to plaintext by using nodeChange with first parameter null
Case 3 (Multiple tags): Change language with overlapping selection creates two new nodes, and leaves the old node in the middle.
Now I found a way to work around case 3 using mergeSameTags, so that's fine, but I might be going at it the wrong way, any input is welcome.
What I'm really struggling with is Case 2, and the only way I managed to get it to work was to manually look for lang tags and just unwrap them, losing the active selection in the process.
What would be the correct way to clear the custom formatting?
Activity