Skip to content

Commit

Permalink
Merge branch '5' into fix-5-remove-trailing-slash-from-sitetree-links
Browse files Browse the repository at this point in the history
  • Loading branch information
xini committed Oct 10, 2022
2 parents 95dc73b + ea9ce63 commit 3ffdfbc
Show file tree
Hide file tree
Showing 25 changed files with 39 additions and 1,034 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_sslink-anchor.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-internal.js

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

11 changes: 6 additions & 5 deletions client/src/legacy/TinyMCE_sslink-anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TinyMCEActionRegistrar
'sslink',
{
text: i18n._t('CMS.LINKLABEL_ANCHOR', 'Anchor on a page'),
onclick: (activeEditor) => activeEditor.execCommand(commandName),
onAction: (activeEditor) => activeEditor.execCommand(commandName),
priority: 60,
},
editorIdentifier,
Expand All @@ -32,8 +32,8 @@ const plugin = {
const field = jQuery(`#${editor.id}`).entwine('ss');
// Get the anchors in the current field and save them as props for AnchorSelectorField
const currentPageID = Number(jQuery('#Form_EditForm_ID').val() || 0);
const validTargets = editor
.$('[id],[name]', editor.getBody())
const validTargets = jQuery(editor.getBody())
.find('[id],[name]')
.toArray()
.map((element) => element.id || element.name);
ss.store.dispatch(updatedCurrentField(currentPageID, validTargets, editor.id));
Expand Down Expand Up @@ -74,8 +74,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() === '';
const currentPageID = Number($('#Form_EditForm_ID').val() || 0);
Expand Down
8 changes: 5 additions & 3 deletions client/src/legacy/TinyMCE_sslink-internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TinyMCEActionRegistrar
'sslink',
{
text: i18n._t('CMS.LINKLABEL_PAGE', 'Page on this site'),
onclick: (activeEditor) => activeEditor.execCommand(commandName),
onAction: (activeEditor) => activeEditor.execCommand(commandName),
priority: 90,
},
editorIdentifier,
Expand Down Expand Up @@ -95,8 +95,10 @@ jQuery.entwine('ss', ($) => {
* @return {Boolean}
*/
getRequireLinkText() {
const selection = this.getElement().getEditor().getInstance().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
Loading

0 comments on commit 3ffdfbc

Please sign in to comment.