CKEDITOR.plugins.add('apply', { requires: ['button', 'toolbar', 'maximize'], lang: 'en,ru,uk', // %REMOVE_LINE_CORE% icons: 'apply,cancel', // %REMOVE_LINE_CORE% hidpi: true, // %REMOVE_LINE_CORE% init: function (editor) { if (typeof(window.applyCKEditorChanges) != "function") return; function close(discard_changes) { if (editor.commands.maximize.state == 1) { editor.commands.maximize.exec(); } editor.destroy(discard_changes); if (typeof(window.applyCloseCKEditor) == "function") { window.applyCloseCKEditor(Object.keys(CKEDITOR.instances).length); } } var lang = editor.lang; var applyFunction = { exec: function (editor) { close(false); window.applyCKEditorChanges(editor.getData()); } }; var cancelFunction = { exec: function (editor) { close(true); } }; var applyCommand = editor.addCommand('apply', applyFunction); applyCommand.modes = {wysiwyg: 1, source: 1}; applyCommand.canUndo = false; applyCommand.readOnly = 1; editor.ui.addButton && editor.ui.addButton('Apply', { label: lang.apply.apply, command: 'apply', toolbar: 'document,0' }); var cancelCommand = editor.addCommand('cancel', cancelFunction); cancelCommand.modes = {wysiwyg: 1, source: 1}; cancelCommand.canUndo = false; cancelCommand.readOnly = 1; editor.ui.addButton && editor.ui.addButton('Cancel', { label: lang.apply.cancel, command: 'cancel', toolbar: 'document,1' }); } });