-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX Add tinymce link menuitems per editor instance #1653
FIX Add tinymce link menuitems per editor instance #1653
Conversation
aa2e7c3
to
88ddba9
Compare
893894c
to
294c4f3
Compare
294c4f3
to
33889ac
Compare
33889ac
to
aeb4844
Compare
// Add "Link to email address" to link menu for this editor | ||
TinyMCEActionRegistrar.addAction( | ||
'sslink', | ||
{ | ||
text: i18n._t('Admin.LINKLABEL_EMAIL', 'Link to email address'), | ||
onclick: (editorInst) => editorInst.execCommand(commandName), | ||
priority: 51, | ||
}, | ||
editor.settings.editorIdentifier, | ||
).addCommandWithUrlTest(commandName, /^mailto:/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this into here means we have access to the actual editor instance, so we can find its unique editor identifier.
Note the change from editorIdentifier
to editor.settings.editorIdentifier
.
If multiple editors use the same config (and therefore have the same identifier), the action is not duplicated - there's deduping logic in TinyMCEActionRegistrar
to handle that.
const actions = TinyMCEActionRegistrar.getSortedActions('sslink', editor.settings.editorIdentifier, true) | ||
.map(action => Object.assign( | ||
{}, | ||
action, | ||
{ onclick: () => action.onclick(editor) } | ||
)); | ||
|
||
editor.addButton('sslink', { | ||
icon: 'link', | ||
title: titleWithShortcut, | ||
type: 'menubutton', | ||
menu: actions, | ||
}); | ||
|
||
editor.addMenuItem('sslink', { | ||
icon: 'link', | ||
text: title, | ||
menu: actions, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The additional link type plugins' init
function hasn't been called yet, so we have to defer this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally using replication steps on issue and reconfirmed on vanilla install that replication steps are valid. PR works correctly.
Description
Fixes an issue where multiple tinymce instances with different configs don't correctly register the link menus.
There is (or will be) associated PRs for asset-admin and cms as well, to update their tinymce link plugins.
Note that this change is backwards compatible with older versions of cms or asset-admin, but the PRs for those modules are not backwards compatible with older versions of this module.
Manual testing steps
See issue for reproduction steps
Issues
Pull request checklist