Skip to content

Commit

Permalink
Fix TinyMCE edit link when link contains html
Browse files Browse the repository at this point in the history
  • Loading branch information
satrun77 committed Aug 25, 2024
1 parent 88a3d8e commit de95ff6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion client/src/legacy/TinyMCE_sslink.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ const plugin = {

// Callback for opening the edit link dialog form
function openLinkDialog() {
// Find "a" node (we might have clicked on a child element e.g. "span")
const linkNode = jQuery(tinymce.activeEditor.selection.getNode()).closest('a');
tinymce.activeEditor.selection.select(linkNode[0]);
const node = tinymce.activeEditor.selection.getNode();
const href = node.getAttribute('href');

Expand Down Expand Up @@ -192,7 +195,11 @@ jQuery.entwine('ss', ($) => {
*/
getRequireLinkText() {
const editor = this.getElement().getEditor();
const selection = editor.getInstance().selection;
let selection = editor.getInstance().selection;
const node = $(selection.getNode()).closest('a');
editor.getInstance().selection.select(node[0]);

selection = editor.getInstance().selection;
const isValidSelection = this.linkCanWrapSelection(editor, selection);
const tagName = selection.getNode().tagName;
const requireLinkText = tagName !== 'A' && !isValidSelection;
Expand Down

0 comments on commit de95ff6

Please sign in to comment.