Skip to content
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 #2916

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

29 changes: 15 additions & 14 deletions client/src/legacy/TinyMCE_sslink-anchor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global tinymce, editorIdentifier, ss */
/* global tinymce, ss */
import i18n from 'i18n';
import TinyMCEActionRegistrar from 'lib/TinyMCEActionRegistrar';
import React from 'react';
Expand All @@ -13,21 +13,22 @@ import { updatedCurrentField } from '../state/anchorSelector/AnchorSelectorActio

const commandName = 'sslinkanchor';

// Link to external url
TinyMCEActionRegistrar
.addAction(
'sslink',
{
text: i18n._t('CMS.LINKLABEL_ANCHOR', 'Anchor on a page'),
onclick: (activeEditor) => activeEditor.execCommand(commandName),
priority: 60,
},
editorIdentifier,
)
.addCommandWithUrlTest(commandName, /^\[sitetree_link.+]#[^#\]]+$/);

const plugin = {
init(editor) {
// Add "Anchor on a page" to link menu for this editor
TinyMCEActionRegistrar
.addAction(
'sslink',
{
text: i18n._t('CMS.LINKLABEL_ANCHOR', 'Anchor on a page'),
onclick: (activeEditor) => activeEditor.execCommand(commandName),
priority: 60,
},
editor.settings.editorIdentifier,
)
.addCommandWithUrlTest(commandName, /^\[sitetree_link.+]#[^#\]]+$/);

// Add a command that corresponds with the above menu item
editor.addCommand(commandName, () => {
const field = jQuery(`#${editor.id}`).entwine('ss');
// Get the anchors in the current field and save them as props for AnchorSelectorField
Expand Down
29 changes: 15 additions & 14 deletions client/src/legacy/TinyMCE_sslink-internal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global tinymce, editorIdentifier, ss */
/* global tinymce, ss */
import i18n from 'i18n';
import TinyMCEActionRegistrar from 'lib/TinyMCEActionRegistrar';
import React from 'react';
Expand All @@ -12,21 +12,22 @@ import { provideInjector } from 'lib/Injector';

const commandName = 'sslinkinternal';

// Link to external url
TinyMCEActionRegistrar
.addAction(
'sslink',
{
text: i18n._t('CMS.LINKLABEL_PAGE', 'Page on this site'),
onclick: (activeEditor) => activeEditor.execCommand(commandName),
priority: 90,
},
editorIdentifier,
)
.addCommandWithUrlTest(commandName, /^\[sitetree_link.+]$/);

const plugin = {
init(editor) {
// Add "Page on this site" to link menu for this editor
TinyMCEActionRegistrar
.addAction(
'sslink',
{
text: i18n._t('CMS.LINKLABEL_PAGE', 'Page on this site'),
onclick: (activeEditor) => activeEditor.execCommand(commandName),
priority: 90,
},
editor.settings.editorIdentifier,
)
.addCommandWithUrlTest(commandName, /^\[sitetree_link.+]$/);

// Add a command that corresponds with the above menu item
editor.addCommand(commandName, () => {
const field = jQuery(`#${editor.id}`).entwine('ss');

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
],
"require": {
"silverstripe/admin": "^1.13@dev",
"silverstripe/admin": "^1.13.20",
"silverstripe/campaign-admin": "^1.7@dev",
"silverstripe/framework": "^4.11",
"silverstripe/reports": "^4.7@dev",
Expand Down