Skip to content

Commit

Permalink
FIX TinyMCE bug adding a link after removing a link
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Aug 2, 2020
1 parent 055cf6d commit 6c876f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_sslink.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion client/src/legacy/TinyMCE_sslink.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,25 @@ const plugin = {
editor.on('preinit', () => {
setupTinyMceInlineToolbar(editor, [
{ type: 'button', onClick: openLinkDialog, text: 'Edit link' },
{ type: 'button', onClick: () => editor.execCommand('unlink'), text: 'Remove link' },
{ type: 'button', onClick: () => this.handleRemoveLinkClick(editor), text: 'Remove link' },
], ['a[href]']);
});
},

/**
* @param {Object} editor
*/
handleRemoveLinkClick(editor) {
const result = editor.execCommand('unlink');
// Merge adjacent textNodes after removing <a> nodes so that tinymce.js can properly
// calculate a value for 'isCollapsed'
const node = editor.selection.getNode();
// IE11 normalize() compatibility is unknown
if (node && (typeof node.normalize !== 'undefined')) {
node.normalize();
}
return result;
}
};

jQuery.entwine('ss', ($) => {
Expand Down

0 comments on commit 6c876f2

Please sign in to comment.