Skip to content

Commit

Permalink
FIX Use correct tinymce selection logic
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Sep 30, 2022
1 parent 7f81b8f commit 7b3ac23
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_sslink-email.js

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

2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_sslink-external.js

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

2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions client/src/legacy/HtmlEditorField.js
Expand Up @@ -185,6 +185,15 @@ ss.editorWrappers.tinyMCE = (function() {
return this.getInstance().getContent();
},

getSelection: function() {
const instance = this.getInstance();
let selection = instance.selection.getContent({ format: 'text' });
if (!selection) {
selection = instance.selection.getSel().toString();
}
return selection || '';
},

/**
* DOM tree of the edited content
*
Expand Down
5 changes: 3 additions & 2 deletions client/src/legacy/TinyMCE_sslink-email.js
Expand Up @@ -59,8 +59,9 @@ jQuery.entwine('ss', ($) => {
const handleHide = () => this.close();
const handleInsert = (...args) => this.handleInsert(...args);
const attrs = this.getOriginalAttributes();
const selection = tinymce.activeEditor.selection;
const selectionContent = selection.getContent() || '';
const editor = this.getElement().getEditor();
const selection = editor.getInstance().selection;
const selectionContent = editor.getSelection();
const tagName = selection.getNode().tagName;
const requireLinkText = tagName !== 'A' && selectionContent.trim() === '';

Expand Down
5 changes: 3 additions & 2 deletions client/src/legacy/TinyMCE_sslink-external.js
Expand Up @@ -54,8 +54,9 @@ jQuery.entwine('ss', ($) => {
const handleHide = () => this.close();
const handleInsert = (...args) => this.handleInsert(...args);
const attrs = this.getOriginalAttributes();
const selection = tinymce.activeEditor.selection;
const selectionContent = selection.getContent() || '';
const editor = this.getElement().getEditor();
const selection = editor.getInstance().selection;
const selectionContent = editor.getSelection();
const tagName = selection.getNode().tagName;
const requireLinkText = tagName !== 'A' && selectionContent.trim() === '';

Expand Down

0 comments on commit 7b3ac23

Please sign in to comment.