- md5
- 90b583de2eee5e3be44ebbb6a5bf564f
- sha1
- cf714336c65be5bc40ce4d13fd6b05e0fc852196
- sha256
- 0af0c7af9acf73d4a69b443d3c1b66996523d347ece8c61ba2190a6495782568
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
/**
* plugin.js
*
* Original code by Arjan Haverkamp
* Copyright 2013-2015 Arjan Haverkamp ([email protected])
*/
window.tinymce.PluginManager.add('highlightPlus', (editor, url) => {
const showSourceEditor = () => {
editor.focus();
editor.selection.collapse(true);
editor.options.register('codemirror', {
processor: 'object',
default: {
codemirrorWidth: 800,
codemirrorHeight: 550,
fullscreen: false,
indentOnInit: true,
config: {
mode: 'htmlmixed',
theme: 'default',
lineNumbers: true,
lineWrapping: true,
indentUnit: 2,
tabSize: 2,
indentWithTabs: true,
matchBrackets: true,
saveCursorPosition: false,
styleActiveLine: true
}
}
});
const cmSettings = editor.options.get('codemirror');
// Insert caret marker
if (cmSettings.config.saveCursorPosition) {
editor.selection.setContent('<span style="display: none;" class="CmCaReT">�</span>');
}
const buttonsConfig = [{
type: 'custom',
text: 'Ok',
name: 'codemirrorOk',
primary: true
}, {
type: 'cancel',
text: 'Cancel',
name: 'codemirrorCancel'
}];
const config = {
title: 'Source code',
url: `${url}/source.html`,
width: cmSettings.width,
height: cmSettings.height,
resizable: true,
maximizable: true,
fullScreen: cmSettings.fullscreen,
saveCursorPosition: false,
buttons: buttonsConfig
};
config.onAction = (dialogApi, actionData) => {
if (actionData.name === 'codemirrorOk') {
const doc = document.querySelectorAll('.tox-dialog__body-iframe iframe')[0];
doc.contentWindow.tinymceHighlighterSubmit();
editor.undoManager.add();
// eslint-disable-next-line no-use-before-define
win.close();
}
};
const win = editor.windowManager.openUrl(config);
if (cmSettings.fullscreen) {
win.fullscreen(true);
}
};
editor.ui.registry.addButton('code', {
icon: 'sourcecode',
title: 'Source code+',
tooltip: 'Source code+',
onAction: showSourceEditor
});
editor.ui.registry.addMenuItem('code', {
icon: 'sourcecode',
text: 'Source code+',
onAction: showSourceEditor,
context: 'tools'
});
editor.addShortcut('Alt+U', 'Opens the code editor', showSourceEditor);
});
The same content is in 2 releases, Joomla 5.0.0-alpha2 to 5.0.0-alpha3. See them all, or every version of this file.