Created
October 24, 2017 22:38
-
-
Save robbieaverill/090f2f0bf8d977c4489a96c0ad3cecd5 to your computer and use it in GitHub Desktop.
Reacting to change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/client/src/legacy/TinyMCE_sslink-internal.js b/client/src/legacy/TinyMCE_sslink-internal.js | |
index c20a6c0d..ba5312f5 100644 | |
--- a/client/src/legacy/TinyMCE_sslink-internal.js | |
+++ b/client/src/legacy/TinyMCE_sslink-internal.js | |
@@ -61,10 +61,7 @@ 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 tagName = selection.getNode().tagName; | |
- const requireLinkText = tagName !== 'A' && selectionContent.trim() === ''; | |
+ const requireLinkText = this.getRequireLinkText(); | |
// create/update the react component | |
ReactDOM.render( | |
@@ -86,6 +83,20 @@ jQuery.entwine('ss', ($) => { | |
}, | |
/** | |
+ * Determine whether to show the link text field | |
+ * | |
+ * @return {Boolean} | |
+ */ | |
+ getRequireLinkText() { | |
+ const selection = tinymce.activeEditor.selection; | |
+ const selectionContent = selection.getContent() || ''; | |
+ const tagName = selection.getNode().tagName; | |
+ const requireLinkText = tagName !== 'A' && selectionContent.trim() === ''; | |
+ | |
+ return requireLinkText; | |
+ }, | |
+ | |
+ /** | |
* @param {Object} data - Posted data | |
* @return {Object} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment