From 9fe48f32d212f5a7ed1ebe58921ad52ef86a834c Mon Sep 17 00:00:00 2001 From: Jacob Rief Date: Wed, 20 Sep 2023 15:01:30 +0200 Subject: [PATCH 1/4] fix #648: unable to unlink --- djangocms_text_ckeditor/cms_plugins.py | 7 +++---- .../ckeditor_plugins/cmsplugins/plugin.js | 12 ++++++++---- ....min.js => bundle-9f0bbac8ec.cms.ckeditor.min.js} | 4 ++-- djangocms_text_ckeditor/widgets.py | 3 +-- 4 files changed, 14 insertions(+), 12 deletions(-) rename djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/dist/{bundle-13948e6025.cms.ckeditor.min.js => bundle-9f0bbac8ec.cms.ckeditor.min.js} (98%) diff --git a/djangocms_text_ckeditor/cms_plugins.py b/djangocms_text_ckeditor/cms_plugins.py index 11d7e73b4..2d0bc5cbc 100644 --- a/djangocms_text_ckeditor/cms_plugins.py +++ b/djangocms_text_ckeditor/cms_plugins.py @@ -417,13 +417,13 @@ def _get_text_plugin_from_request(self, request, data): raise PermissionDenied form = ActionTokenValidationForm(data) - if form.is_valid(): session_key = request.session.session_key text_plugin_id = form.get_id_from_token(session_key) if text_plugin_id: return self._get_plugin_or_404(text_plugin_id) + message = gettext("Unable to process your request. Invalid token.") raise ValidationError(message=force_str(message)) @@ -436,10 +436,9 @@ def render_plugin(self, request): return HttpResponseBadRequest(error.message) form = RenderPluginForm(request.GET, text_plugin=text_plugin) - if not form.is_valid(): - message = gettext("Unable to process your request.") - return HttpResponseBadRequest(message) + # plugin not found, inform CKEDITOR.plugins.insertPlugin to remove it + return HttpResponse(status=204) plugin_class = text_plugin.get_plugin_class_instance() # The following is needed for permission checking diff --git a/djangocms_text_ckeditor/static/djangocms_text_ckeditor/ckeditor_plugins/cmsplugins/plugin.js b/djangocms_text_ckeditor/static/djangocms_text_ckeditor/ckeditor_plugins/cmsplugins/plugin.js index d6366dd0b..83d617f1b 100644 --- a/djangocms_text_ckeditor/static/djangocms_text_ckeditor/ckeditor_plugins/cmsplugins/plugin.js +++ b/djangocms_text_ckeditor/static/djangocms_text_ckeditor/ckeditor_plugins/cmsplugins/plugin.js @@ -383,10 +383,14 @@ token: settings.action_token, plugin: data.plugin_id } - }).done(function (res) { - CMS.CKEditor.editors[editor.id].changed = true; - CMS.CKEditor.editors[editor.id].child_changed = true; - editor.insertHtml(res, 'unfiltered_html'); + }).done(function (res, textStatus, jqXHR) { + CMS.CKEditor.editors[editor.id].changed = true; + CMS.CKEditor.editors[editor.id].child_changed = true; + if (jqXHR.status === 200) { + editor.insertHtml(res, 'unfiltered_html'); + } else if (jqXHR.status === 204) { + editor.insertHtml(editor.getSelectedHtml().$.textContent); + } editor.fire('updateSnapshot'); }); }, diff --git a/djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/dist/bundle-13948e6025.cms.ckeditor.min.js b/djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/dist/bundle-9f0bbac8ec.cms.ckeditor.min.js similarity index 98% rename from djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/dist/bundle-13948e6025.cms.ckeditor.min.js rename to djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/dist/bundle-9f0bbac8ec.cms.ckeditor.min.js index bf42231de..26ea7a08c 100644 --- a/djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/dist/bundle-13948e6025.cms.ckeditor.min.js +++ b/djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/dist/bundle-9f0bbac8ec.cms.ckeditor.min.js @@ -1,7 +1,7 @@ (function ($) { $(function () { -!function(t,i){"use strict";window.CKEDITOR_BASEPATH=t("[data-ckeditor-basepath]").attr("data-ckeditor-basepath"),i.CKEditor={options:{language:"en",skin:"moono-lisa",toolbar_CMS:[["Undo","Redo"],["cmsplugins","cmswidget","-","ShowBlocks"],["Format","Styles"],["TextColor","BGColor","-","PasteText","PasteFromWord"],["Scayt"],["Maximize",""],"/",["Bold","Italic","Underline","Strike","-","Subscript","Superscript","-","RemoveFormat"],["JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock"],["HorizontalRule"],["NumberedList","BulletedList"],["Outdent","Indent","-","Blockquote","-","Link","Unlink","-","Table"],["Source"]],toolbar_HTMLField:[["Undo","Redo"],["ShowBlocks"],["Format","Styles"],["TextColor","BGColor","-","PasteText","PasteFromWord"],["Scayt"],["Maximize",""],"/",["Bold","Italic","Underline","Strike","-","Subscript","Superscript","-","RemoveFormat"],["JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock"],["HorizontalRule"],["Link","Unlink"],["NumberedList","BulletedList"],["Outdent","Indent","-","Blockqote","-","Link","Unlink","-","Table"],["Source"]],allowedContent:!0,toolbarCanCollapse:!1,removePlugins:"resize",extraPlugins:""},static_url:"/static/djangocms-text-ckeditor",CSS:[],editors:{},init:function(e,o,n,r,s){var d=t(e);d.data("ckeditor-initialized",!0),d.attr("contenteditable",!0),this.options.toolbar=r.toolbar,this.options=t.extend(!1,{settings:r},this.options,n),this.options.extraPlugins=this.options.extraPlugins+=",cmsplugins,cmswidget,cmsdialog,cmsresize,widget",document.createElement("cms-plugin"),CKEDITOR.dtd["cms-plugin"]=CKEDITOR.dtd.div,CKEDITOR.dtd.$inline["cms-plugin"]=1,CKEDITOR.dtd.$nonEditable["cms-plugin"]=1,CKEDITOR.dtd.$transparent["cms-plugin"]=1,CKEDITOR.dtd.body["cms-plugin"]=1,CKEDITOR.skin.addIcon("cmsplugins",r.static_url+"/ckeditor_plugins/cmsplugins/icons/cmsplugins.svg");var a;a="admin"===o?CKEDITOR.replace(d[0],this.options):CKEDITOR.inline(d[0],this.options),i.CKEditor.editors[a.id]={editor:a,options:n,settings:r,container:d,changed:!1,child_changed:!1},a.on("instanceReady",s)},initInlineEditors:function(){void 0!==i._plugins&&(i.CKEditor.observer=i.CKEditor.observer||new IntersectionObserver(function(e,o){e.forEach(function(e){if(e.isIntersecting){var o=t(e.target),n=o.data("cms_plugin_id"),r=o.data("cms_edit_url");i.CKEditor.startInlineEditor(n,r)}})},{root:null,threshold:.05}),i._plugins.forEach(function(e){if("TextPlugin"===e[1].plugin_type){var o,n=e[1].urls.edit_plugin,r=e[1].plugin_id,s=t(".cms-plugin.cms-plugin-"+r);s.length>0&&(1===s.length&&"DIV"===s.prop("tagName")?o=s.addClass("cms-ckeditor-inline-wrapper"):(o=s.wrapAll('
').parent(),s.removeClass("cms-plugin").removeClass("cms-plugin-"+r),o.addClass("cms-plugin").addClass("cms-plugin-"+r)),o.data("cms_edit_url",n),o.data("cms_plugin_id",r),o.on("dblclick.cms-ckeditor",function(t){t.stopPropagation()}),o.on("pointerover.cms-ckeditor",function(t){setTimeout(function(){i.API.Tooltip.displayToggle(!1,t.target,"",r)},0)}),i.CKEditor.observer.observe(o[0]))}}),t(window).on("beforeunload.cms-ckeditor",function(){for(var t in i.CKEditor.editors)if(i.CKEditor.editors.hasOwnProperty(t)&&i.CKEditor.editors[t].changed)return"Do you really want to leave this page?"}))},startInlineEditor:function(e,o){var n,r=JSON.parse(document.getElementById("ck-cfg-"+e).textContent),s=t(".cms-plugin.cms-plugin-"+e);s.data("ckeditor-initialized")||(r.plugin_id=e,r.url=o,n=r.options,delete r.options,i.CKEditor.init(s[0],"inline",n,r,function(t){t.editor.element.removeAttribute("title"),t.editor.on("change",function(){i.CKEditor.editors[t.editor.id].changed=!0}),s.on("blur.cms-ckeditor",function(){setTimeout(function(){document.activeElement.classList.contains("cke_panel_frame")||document.activeElement.classList.contains("cke_dialog_ui_button")||i.CKEditor.save_data(t.editor.id)},0)}),s.on("click.cms-ckeditor",function(){i.CKEditor._highlight_Textplugin(e)}),i.CKEditor.storeCSSlinks()}))},save_data:function(e,o){var n=i.CKEditor.editors[e];if(n&&n.changed){i.CKEditor.storeCSSlinks();var r=n.editor.getData();i.API.Toolbar.showLoader(),t.post(i.API.Helpers.updateUrlWithPath(n.settings.url),{csrfmiddlewaretoken:i.config.csrf,body:r,_save:"Save"},function(e){if(n.changed=!1,i.API.Toolbar.hideLoader(),void 0!==o&&o(n,e),n.child_changed){var r=t(e).find("script:not([src])").addClass("cms-ckeditor-result");i.CKEditor._destroyAll(),r.each(function(i,e){t("body").append(e)})}else i.CKEditor.loadToolbar()}).fail(function(t){n.changed=!0,i.API.Messages.open({message:t.message,error:!0})})}},loadToolbar:function(){i.settings&&i.settings.version&&this._toolbar_bug_version(i.settings.version)?i.API.Helpers.reloadBrowser():i.API.StructureBoard._loadToolbar().done(function(e){i.API.Toolbar._refreshMarkup(t(e).find(".cms-toolbar"))}).fail(i.API.Helpers.reloadBrowser)},_toolbar_bug_version:function(t){var i=t.split(".");return"3"===i[0]&&i[1].length<2},storeCSSlinks:function(){t("link[rel='stylesheet'][type='text/css'][href*='ckeditor']").each(function(t,e){i.CKEditor.CSS.includes(e.href)||i.CKEditor.CSS.push(e.href)})},setupAdmin:function(e){var o=this,n=window.parent||window;this._isAloneInModal(i.CKEditor.editors[e.id].container)&&(e.resize("100%",n.CMS.$(".cms-modal-frame").height()-70),e.execCommand("maximize"),t(window).on("resize.ckeditor",function(){o._repositionDialog(CKEDITOR.dialog.getCurrent(),n)}).trigger("resize.ckeditor"),n.CMS.API.Helpers.addEventListener("modal-maximized modal-restored",function(){try{t(".cke_maximized").length||(e.resize("100%",n.CMS.$(".cms-modal-frame").height()-70),setTimeout(function(){o._repositionDialog(CKEDITOR.dialog.getCurrent(),n)},0))}catch(t){}})),this.styles(),this._resizing()},styles:function(){t(".cke_button__maximize, .cke_button__source").parent().css("margin-right",0).parent().css("float","right")},_resizing:function(){t(document).on("pointerdown",".cms-ckeditor-resizer",function(e){e.preventDefault();var o=new i.$.Event("mousedown");t.extend(o,{screenX:e.originalEvent.screenX,screenY:e.originalEvent.screenY}),t(this).trigger(o)})},_isAloneInModal:function(t){return t.closest("body").is(".app-djangocms_text_ckeditor.model-text")},_repositionDialog:function(t){if(t){var i=t.getSize(),e=t.getPosition(),o=CKEDITOR.document.getWindow(),n=o.getViewPaneSize(),r=n.width,s=n.height;e.x<0&&(t.move(0,e.y),e.x=0),e.y<0&&(t.move(e.x,0),e.y=0),e.y+i.height>s&&t.resize(i.width,s-e.y-80),e.x+i.width>r&&t.resize(r-e.x,i.height)}},initAdminEditors:function(){window._cmsCKEditors=window._cmsCKEditors||[];var e,o,n=[];window._cmsCKEditors.forEach(function(t){var r="ck-cfg-"+(t[1]?t[1]:t[0]);e=JSON.parse(document.getElementById(r).textContent),o=e.options,delete e.options,t[0].match(/__prefix__/)?n.push(t):i.CKEditor.init(document.getElementById(t[0]),"admin",o,e,function(t){return i.CKEditor.setupAdmin(t.editor)})}),t(".add-row a").on("click",function(){t(".CMS_CKEditor").each(function(r,s){var d=t(s);if(!d.data("ckeditor-initialized")){var a=d.attr("id");n.forEach(function(t){var n=t[0].id,r=new RegExp(n.replace("__prefix__","\\d+"));a.match(r)&&i.CKEditor.init(document.getElementById(a),o,e)})}})})},_highlight_Textplugin:function(e){var o=t(".cms-draggable-"+e),n=t(document),r=n.data("expandmode");n.data("expandmode",!1),o.parents(".cms-draggable").find('> .cms-dragitem-collapsable:not(".cms-dragitem-expanded") > .cms-dragitem-text').each(function(e,o){t(o).triggerHandler(i.Plugin.click)}),o.length>0&&(setTimeout(function(){n.data("expandmode",r)}),setTimeout(function(){i.Plugin._highlightPluginStructure(o.find(".cms-dragitem:first"),{successTimeout:200,delay:2e3,seeThrough:!0})},10))},_initAll:function(){i.CKEditor.touchdevice="ontouchstart"in window||navigator.msMaxTouchPoints,i.CKEditor.touchdevice?t("div.cms a.cms-btn.cms-edit-toggle").hide():(i.CKEditor.initInlineEditors(),t("div.cms a.cms-btn.cms-edit-toggle").show()),i.CKEditor.initAdminEditors()},_destroyAll:function(){for(var e in i.CKEditor.editors)i.CKEditor.editors.hasOwnProperty(e)&&(i.CKEditor.editors[e].editor.destroy(),t(i.CKEditor.editors[e].container).off(".cms-ckeditor"),delete i.CKEditor.editors[e]);t(window).off(".cms-ckeditor")},_resetInlineEditors:function(){i.CKEditor.CSS.forEach(function(i){0===t("link[href='"+i+"']").length&&t("head").append(t(""))}),i.CKEditor._destroyAll(),i.CKEditor._initAll()}},setTimeout(function(){i.CKEditor._initAll()},0),t(window).on("cms-content-refresh",i.CKEditor._resetInlineEditors)}(window.CMS.$,window.CMS); +!function(t,i){"use strict";window.CKEDITOR_BASEPATH=t("[data-ckeditor-basepath]").attr("data-ckeditor-basepath"),i.CKEditor={options:{language:"en",skin:"moono-lisa",toolbar_CMS:[["Undo","Redo"],["cmsplugins","cmswidget","-","ShowBlocks"],["Format","Styles"],["TextColor","BGColor","-","PasteText","PasteFromWord"],["Scayt"],["Maximize",""],"/",["Bold","Italic","Underline","Strike","-","Subscript","Superscript","-","RemoveFormat"],["JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock"],["HorizontalRule"],["NumberedList","BulletedList"],["Outdent","Indent","-","Blockquote","-","Link","Unlink","-","Table"],["Source"]],toolbar_HTMLField:[["Undo","Redo"],["ShowBlocks"],["Format","Styles"],["TextColor","BGColor","-","PasteText","PasteFromWord"],["Scayt"],["Maximize",""],"/",["Bold","Italic","Underline","Strike","-","Subscript","Superscript","-","RemoveFormat"],["JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock"],["HorizontalRule"],["Link","Unlink"],["NumberedList","BulletedList"],["Outdent","Indent","-","Blockquote","-","Link","Unlink","-","Table"],["Source"]],allowedContent:!0,toolbarCanCollapse:!1,removePlugins:"resize",extraPlugins:""},static_url:"/static/djangocms-text-ckeditor",CSS:[],editors:{},init:function(e,o,n,r,s){var d=t(e);d.data("ckeditor-initialized",!0),d.attr("contenteditable",!0),this.options.toolbar=r.toolbar,this.options=t.extend(!1,{settings:r},this.options,n),this.options.extraPlugins=this.options.extraPlugins+=",cmsplugins,cmswidget,cmsdialog,cmsresize,widget",document.createElement("cms-plugin"),CKEDITOR.dtd["cms-plugin"]=CKEDITOR.dtd.div,CKEDITOR.dtd.$inline["cms-plugin"]=1,CKEDITOR.dtd.$nonEditable["cms-plugin"]=1,CKEDITOR.dtd.$transparent["cms-plugin"]=1,CKEDITOR.dtd.body["cms-plugin"]=1,CKEDITOR.skin.addIcon("cmsplugins",r.static_url+"/ckeditor_plugins/cmsplugins/icons/cmsplugins.svg");var a;a="admin"===o?CKEDITOR.replace(d[0],this.options):CKEDITOR.inline(d[0],this.options),i.CKEditor.editors[a.id]={editor:a,options:n,settings:r,container:d,changed:!1,child_changed:!1},a.on("instanceReady",s)},initInlineEditors:function(){void 0!==i._plugins&&(i.CKEditor.observer=i.CKEditor.observer||new IntersectionObserver(function(e,o){e.forEach(function(e){if(e.isIntersecting){var o=t(e.target),n=o.data("cms_plugin_id"),r=o.data("cms_edit_url");i.CKEditor.startInlineEditor(n,r)}})},{root:null,threshold:.05}),i._plugins.forEach(function(e){if("TextPlugin"===e[1].plugin_type){var o,n=e[1].urls.edit_plugin,r=e[1].plugin_id,s=t(".cms-plugin.cms-plugin-"+r);s.length>0&&(1===s.length&&"DIV"===s.prop("tagName")?o=s.addClass("cms-ckeditor-inline-wrapper"):(o=s.wrapAll('
').parent(),s.removeClass("cms-plugin").removeClass("cms-plugin-"+r),o.addClass("cms-plugin").addClass("cms-plugin-"+r)),o.data("cms_edit_url",n),o.data("cms_plugin_id",r),o.on("dblclick.cms-ckeditor",function(t){t.stopPropagation()}),o.on("pointerover.cms-ckeditor",function(t){setTimeout(function(){i.API.Tooltip.displayToggle(!1,t.target,"",r)},0)}),i.CKEditor.observer.observe(o[0]))}}),t(window).on("beforeunload.cms-ckeditor",function(){for(var t in i.CKEditor.editors)if(i.CKEditor.editors.hasOwnProperty(t)&&i.CKEditor.editors[t].changed)return"Do you really want to leave this page?"}))},startInlineEditor:function(e,o){var n,r=JSON.parse(document.getElementById("ck-cfg-"+e).textContent),s=t(".cms-plugin.cms-plugin-"+e);s.data("ckeditor-initialized")||(r.plugin_id=e,r.url=o,n=r.options,delete r.options,i.CKEditor.init(s[0],"inline",n,r,function(t){t.editor.element.removeAttribute("title"),t.editor.on("change",function(){i.CKEditor.editors[t.editor.id].changed=!0}),s.on("blur.cms-ckeditor",function(){setTimeout(function(){document.activeElement.classList.contains("cke_panel_frame")||document.activeElement.classList.contains("cke_dialog_ui_button")||i.CKEditor.save_data(t.editor.id)},0)}),s.on("click.cms-ckeditor",function(){i.CKEditor._highlight_Textplugin(e)}),i.CKEditor.storeCSSlinks()}))},save_data:function(e,o){var n=i.CKEditor.editors[e];if(n&&n.changed){i.CKEditor.storeCSSlinks();var r=n.editor.getData();i.API.Toolbar.showLoader(),t.post(i.API.Helpers.updateUrlWithPath(n.settings.url),{csrfmiddlewaretoken:i.config.csrf,body:r,_save:"Save"},function(e){if(n.changed=!1,i.API.Toolbar.hideLoader(),void 0!==o&&o(n,e),n.child_changed){var r=t(e).find("script:not([src])").addClass("cms-ckeditor-result");i.CKEditor._destroyAll(),r.each(function(i,e){t("body").append(e)})}else i.CKEditor.loadToolbar()}).fail(function(t){n.changed=!0,i.API.Messages.open({message:t.message,error:!0})})}},loadToolbar:function(){i.settings&&i.settings.version&&this._toolbar_bug_version(i.settings.version)?i.API.Helpers.reloadBrowser():i.API.StructureBoard._loadToolbar().done(function(e){i.API.Toolbar._refreshMarkup(t(e).find(".cms-toolbar"))}).fail(i.API.Helpers.reloadBrowser)},_toolbar_bug_version:function(t){var i=t.split(".");return"3"===i[0]&&i[1].length<2},storeCSSlinks:function(){t("link[rel='stylesheet'][type='text/css'][href*='ckeditor']").each(function(t,e){i.CKEditor.CSS.includes(e.href)||i.CKEditor.CSS.push(e.href)})},setupAdmin:function(e){var o=this,n=window.parent||window;this._isAloneInModal(i.CKEditor.editors[e.id].container)&&(e.resize("100%",n.CMS.$(".cms-modal-frame").height()-70),e.execCommand("maximize"),t(window).on("resize.ckeditor",function(){o._repositionDialog(CKEDITOR.dialog.getCurrent(),n)}).trigger("resize.ckeditor"),n.CMS.API.Helpers.addEventListener("modal-maximized modal-restored",function(){try{t(".cke_maximized").length||(e.resize("100%",n.CMS.$(".cms-modal-frame").height()-70),setTimeout(function(){o._repositionDialog(CKEDITOR.dialog.getCurrent(),n)},0))}catch(t){}})),this.styles(),this._resizing()},styles:function(){t(".cke_button__maximize, .cke_button__source").parent().css("margin-right",0).parent().css("float","right")},_resizing:function(){t(document).on("pointerdown",".cms-ckeditor-resizer",function(e){e.preventDefault();var o=new i.$.Event("mousedown");t.extend(o,{screenX:e.originalEvent.screenX,screenY:e.originalEvent.screenY}),t(this).trigger(o)})},_isAloneInModal:function(t){return t.closest("body").is(".app-djangocms_text_ckeditor.model-text")},_repositionDialog:function(t){if(t){var i=t.getSize(),e=t.getPosition(),o=CKEDITOR.document.getWindow(),n=o.getViewPaneSize(),r=n.width,s=n.height;e.x<0&&(t.move(0,e.y),e.x=0),e.y<0&&(t.move(e.x,0),e.y=0),e.y+i.height>s&&t.resize(i.width,s-e.y-80),e.x+i.width>r&&t.resize(r-e.x,i.height)}},initAdminEditors:function(){window._cmsCKEditors=window._cmsCKEditors||[];var e,o,n=[];window._cmsCKEditors.forEach(function(t){var r="ck-cfg-"+(t[1]?t[1]:t[0]);e=JSON.parse(document.getElementById(r).textContent),o=e.options,delete e.options,t[0].match(/__prefix__/)?n.push(t):i.CKEditor.init(document.getElementById(t[0]),"admin",o,e,function(t){return i.CKEditor.setupAdmin(t.editor)})}),t(".add-row a").on("click",function(){t(".CMS_CKEditor").each(function(r,s){var d=t(s);if(!d.data("ckeditor-initialized")){var a=d.attr("id");n.forEach(function(t){var n=t[0].id,r=new RegExp(n.replace("__prefix__","\\d+"));a.match(r)&&i.CKEditor.init(document.getElementById(a),o,e)})}})})},_highlight_Textplugin:function(e){var o=t(".cms-draggable-"+e),n=t(document),r=n.data("expandmode");n.data("expandmode",!1),o.parents(".cms-draggable").find('> .cms-dragitem-collapsable:not(".cms-dragitem-expanded") > .cms-dragitem-text').each(function(e,o){t(o).triggerHandler(i.Plugin.click)}),o.length>0&&(setTimeout(function(){n.data("expandmode",r)}),setTimeout(function(){i.Plugin._highlightPluginStructure(o.find(".cms-dragitem:first"),{successTimeout:200,delay:2e3,seeThrough:!0})},10))},_initAll:function(){i.CKEditor.touchdevice="ontouchstart"in window||navigator.msMaxTouchPoints,i.CKEditor.touchdevice?t("div.cms a.cms-btn.cms-edit-toggle").hide():(i.CKEditor.initInlineEditors(),t("div.cms a.cms-btn.cms-edit-toggle").show()),i.CKEditor.initAdminEditors()},_destroyAll:function(){for(var e in i.CKEditor.editors)i.CKEditor.editors.hasOwnProperty(e)&&(i.CKEditor.editors[e].editor.destroy(),t(i.CKEditor.editors[e].container).off(".cms-ckeditor"),delete i.CKEditor.editors[e]);t(window).off(".cms-ckeditor")},_resetInlineEditors:function(){i.CKEditor.CSS.forEach(function(i){0===t("link[href='"+i+"']").length&&t("head").append(t(""))}),i.CKEditor._destroyAll(),i.CKEditor._initAll()}},setTimeout(function(){i.CKEditor._initAll()},0),t(window).on("cms-content-refresh",i.CKEditor._resetInlineEditors)}(window.CMS.$,window.CMS); /* Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license/ @@ -1404,6 +1404,6 @@ CKEDITOR.env.webkit&&e.push("float:none;"),e.push('"'),e.push('align="',CKEDITOR * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ CKEDITOR.plugins.add("cmsresize",{init:function(e){function i(i){var t=i.originalEvent.screenX-s.x,r=i.originalEvent.screenY-s.y,a=d.width,c=d.height,l=a+t*("rtl"==o?-1:1),z=c+r;m&&(a=Math.max(n.resize_minWidth,Math.min(l,n.resize_maxWidth))),h&&(c=Math.max(n.resize_minHeight,Math.min(z,n.resize_maxHeight))),e.resize(m?a:null,c)}function t(){CMS.$(CKEDITOR.document.$).off("pointermove",i),CMS.$(CKEDITOR.document.$).off("pointerup",t),e.document&&(CMS.$(e.document.$).off("pointermove",i),CMS.$(e.document.$).off("pointerup",t))}var n=e.config,r=e.ui.spaceId("resizer"),o=e.element?e.element.getDirection(1):"ltr";if(!n.resize_dir&&(n.resize_dir="vertical"),void 0===n.resize_maxWidth&&(n.resize_maxWidth=3e3),void 0===n.resize_maxHeight&&(n.resize_maxHeight=3e3),void 0===n.resize_minWidth&&(n.resize_minWidth=750),void 0===n.resize_minHeight&&(n.resize_minHeight=250),!1!==n.resize_enabled){var s,d,a=null,m=("both"==n.resize_dir||"horizontal"==n.resize_dir)&&n.resize_minWidth!=n.resize_maxWidth,h=("both"==n.resize_dir||"vertical"==n.resize_dir)&&n.resize_minHeight!=n.resize_maxHeight,c=CKEDITOR.tools.addFunction(function(r){a||(a=e.getResizable()),d={width:a.$.offsetWidth||0,height:a.$.offsetHeight||0},s={x:r.screenX,y:r.screenY},n.resize_minWidth>d.width&&(n.resize_minWidth=d.width),n.resize_minHeight>d.height&&(n.resize_minHeight=d.height),CMS.$(CKEDITOR.document.$).on("pointermove",i),CMS.$(CKEDITOR.document.$).on("pointerup",t),e.document&&(CMS.$(e.document.$).on("pointermove",i),CMS.$(e.document.$).on("pointerup",t)),r.preventDefault&&r.preventDefault()});CMS.$(CKEDITOR.document.$).find("html").attr("data-touch-action","none"),e.on("destroy",function(){CKEDITOR.tools.removeFunction(c)}),e.on("uiSpace",function(i){if("bottom"==i.data.space){var t="";m&&!h&&(t=" cke_resizer_horizontal"),!m&&h&&(t=" cke_resizer_vertical");var n=''+("ltr"==o?"◢":"◣")+"";"ltr"==o&&"ltr"==t?i.data.html+=n:i.data.html=n+i.data.html}},e,null,100),e.on("maximize",function(i){e.ui.space("resizer")[i.data==CKEDITOR.TRISTATE_ON?"hide":"show"]()})}}})}(CMS.$); -!function(e){function t(e){var t=(e.match(/<\s*([^>\s]+)[\s\S]*?>/)||[0,!1]).splice(1),n=t.some(function(e){return e&&CKEDITOR.dtd.$block[e]}),i="span";return n&&(i="div"),i}function n(t,n){t.each(function(t,i){var l,a=e(i);l=e("<"+n+">"),e.each(i.attributes,function(e,t){l.attr(t.nodeName,t.nodeValue)}),l.html(a.html()),a.replaceWith(l)})}CKEDITOR&&CKEDITOR.plugins&&CKEDITOR.plugins.registered&&CKEDITOR.plugins.registered.cmsplugins||CKEDITOR.plugins.add("cmsplugins",{icons:"cmsplugins",init:function(t){var n=this;CKEDITOR.on("instanceReady",function(){var e=[];for(var i in t.widgets.instances)t.widgets.instances.hasOwnProperty(i)&&e.push(t.widgets.instances[i]);n.numberOfChildren=CKEDITOR.tools.array.filter(e,function(e){return"cms-widget"===e.name}).length}),this.unsaved_child_plugins=[];var i=CMS.CKEditor.editors[t.id].settings;if(this.setupCancelCleanupCallback(i),void 0===i||void 0===i.plugins)return!1;this.setupDialog(t),t.ui.add("cmsplugins",CKEDITOR.UI_PANELBUTTON,{toolbar:"cms,0",label:i.lang.toolbar,title:i.lang.toolbar,className:"cke_panelbutton__cmsplugins",modes:{wysiwyg:1},editorFocus:0,panel:{css:[CKEDITOR.skin.getPath("editor")].concat(t.config.contentsCss),attributes:{role:"cmsplugins","aria-label":i.lang.aria}},onBlock:function(i,l){l.element.setHtml(t.plugins.cmsplugins.setupDropdown(t)),e(l.element.$).find(".cke_panel_listItem a").bind("click",function(l){l.preventDefault(),n.addPlugin(e(this),i,t)})}}),t.contextMenu&&this.setupContextMenu(t),t.addCommand("cmspluginsEdit",{exec:function(){var e=n.getElementFromSelection(t),i=n.getPluginWidget(e);i&&n.editPlugin(i,t)}});var l=function(n){if(n.stop(),"touchend"===n.type||"click"===n.type){var i,l=e(n.currentTarget).closest("cms-plugin")[0];i=new CKEDITOR.dom.element(l).getParent(),n.data=n.data||{},t.getSelection().fake(i)}t.execCommand("cmspluginsEdit")};t.on("doubleclick",l),t.on("instanceReady",function(){}),this.setupDataProcessor(t)},getElementFromSelection:function(e){var t=e.getSelection();return t.getSelectedElement()||t.getCommonAncestor().getAscendant("cms-plugin",!0)},getPluginWidget:function(e){return e?e.getAscendant("cms-plugin",!0)||e.findOne("cms-plugin"):null},setupDialog:function(t){var n=this,i=function(){return{title:"",minWidth:200,minHeight:200,contents:[{elements:[{type:"html",html:'