Skip to content

Commit

Permalink
Fix TinyMCE edit link when link contains html (#1814)
Browse files Browse the repository at this point in the history
  • Loading branch information
satrun77 authored Aug 25, 2024
1 parent 88a3d8e commit 27a2da7
Show file tree
Hide file tree
Showing 2 changed files with 9 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.

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 27a2da7

Please sign in to comment.