/** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ (function (Drupal, debounce, CKEDITOR, $, displace, AjaxCommands) { Drupal.editors.ckeditor = { attach: function attach(element, format) { this._loadExternalPlugins(format); format.editorSettings.drupal = { format: format.format }; var label = $('label[for=' + element.getAttribute('id') + ']').html(); format.editorSettings.title = Drupal.t('Rich Text Editor, !label field', { '!label': label }); return !!CKEDITOR.replace(element, format.editorSettings); }, detach: function detach(element, format, trigger) { var editor = CKEDITOR.dom.element.get(element).getEditor(); if (editor) { if (trigger === 'serialize') { editor.updateElement(); } else { editor.destroy(); element.removeAttribute('contentEditable'); } } return !!editor; }, onChange: function onChange(element, callback) { var editor = CKEDITOR.dom.element.get(element).getEditor(); if (editor) { editor.on('change', debounce(function () { callback(editor.getData()); }, 400)); editor.on('mode', function () { var editable = editor.editable(); if (!editable.isInline()) { editor.on('autoGrow', function (evt) { var doc = evt.editor.document; var scrollable = CKEDITOR.env.quirks ? doc.getBody() : doc.getDocumentElement(); if (scrollable.$.scrollHeight < scrollable.$.clientHeight) { scrollable.setStyle('overflow-y', 'hidden'); } else { scrollable.removeStyle('overflow-y'); } }, null, null, 10000); } }); } return !!editor; }, attachInlineEditor: function attachInlineEditor(element, format, mainToolbarId, floatedToolbarId) { this._loadExternalPlugins(format); format.editorSettings.drupal = { format: format.format }; var settings = $.extend(true, {}, format.editorSettings); if (mainToolbarId) { var settingsOverride = { extraPlugins: 'sharedspace', removePlugins: 'floatingspace,elementspath', sharedSpaces: { top: mainToolbarId } }; var sourceButtonFound = false; for (var i = 0; !sourceButtonFound && i < settings.toolbar.length; i++) { if (settings.toolbar[i] !== '/') { for (var j = 0; !sourceButtonFound && j < settings.toolbar[i].items.length; j++) { if (settings.toolbar[i].items[j] === 'Source') { sourceButtonFound = true; settings.toolbar[i].items[j] = 'Sourcedialog'; settingsOverride.extraPlugins += ',sourcedialog'; settingsOverride.removePlugins += ',sourcearea'; } } } } settings.extraPlugins += ',' + settingsOverride.extraPlugins; settings.removePlugins += ',' + settingsOverride.removePlugins; settings.sharedSpaces = settingsOverride.sharedSpaces; } element.setAttribute('contentEditable', 'true'); return !!CKEDITOR.inline(element, settings); }, _loadExternalPlugins: function _loadExternalPlugins(format) { var externalPlugins = format.editorSettings.drupalExternalPlugins; if (externalPlugins) { Object.keys(externalPlugins || {}).forEach(function (pluginName) { CKEDITOR.plugins.addExternal(pluginName, externalPlugins[pluginName], ''); }); delete format.editorSettings.drupalExternalPlugins; } } }; Drupal.ckeditor = { saveCallback: null, openDialog: function openDialog(editor, url, existingValues, saveCallback, dialogSettings) { var $target = $(editor.container.$); if (editor.elementMode === CKEDITOR.ELEMENT_MODE_REPLACE) { $target = $target.find('.cke_contents'); } $target.css('position', 'relative').find('.ckeditor-dialog-loading').remove(); var classes = dialogSettings.dialogClass ? dialogSettings.dialogClass.split(' ') : []; classes.push('ui-dialog--narrow'); dialogSettings.dialogClass = classes.join(' '); dialogSettings.autoResize = window.matchMedia('(min-width: 600px)').matches; dialogSettings.width = 'auto'; var $content = $('