From 35915cd75f4e6912194a064824ca64d1fe42c769 Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Wed, 11 Sep 2024 07:53:54 +0200 Subject: [PATCH] Fix: Allow double clicks to propagate. (#676) * Fix: Allow double clicks to propagate. * Update tests * More extensive test suite * Remove django 2.2 test for django CMS 4.0 * Update test-matrix * Update test.yaml * test with released version of django CMS 4.1 * fix: Add missing typo for test actions * Remove PYthon 3.12 from tests, correct django CMS 4.0 dependency --- .github/workflows/test.yml | 20 +- CHANGELOG.rst | 9 +- djangocms_text_ckeditor/__init__.py | 2 +- .../ckeditor_plugins/cmsplugins/plugin.js | 1 - ... => bundle-a9032984d4.cms.ckeditor.min.js} | 2 +- djangocms_text_ckeditor/widgets.py | 2 +- package-lock.json | 359 +++--------------- tests/requirements/base.txt | 2 +- tests/requirements/dj22_cms40.txt | 6 - tests/requirements/dj32_cms41.txt | 2 +- tests/requirements/dj41_cms41.txt | 2 +- tests/requirements/dj42_cms40.txt | 4 + tests/requirements/dj42_cms41.txt | 2 +- tests/requirements/dj50_cms41.txt | 2 +- tox.ini | 15 +- 15 files changed, 102 insertions(+), 328 deletions(-) rename djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/dist/{bundle-9f0bbac8ec.cms.ckeditor.min.js => bundle-a9032984d4.cms.ckeditor.min.js} (99%) delete mode 100644 tests/requirements/dj22_cms40.txt create mode 100644 tests/requirements/dj42_cms40.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index de9366d56..babd13f10 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,6 @@ jobs: requirements-file: [ dj22_cms37.txt, dj22_cms38.txt, - dj22_cms40.txt, dj31_cms38.txt, dj32_cms39.txt, dj32_cms310.txt, @@ -23,8 +22,9 @@ jobs: dj41_cms311.txt, dj41_cms41.txt, dj42_cms311.txt, + dj42_cms40.txt, dj42_cms41.txt, - dj50_cms41.txt + dj50_cms41.txt, ] os: [ ubuntu-20.04, @@ -42,6 +42,8 @@ jobs: requirements-file: dj41_cms41.txt - python-version: 3.7 requirements-file: dj42_cms311.txt + - python-version: 3.7 + requirements-file: dj42_cms40.txt - python-version: 3.7 requirements-file: dj42_cms41.txt - python-version: 3.7 @@ -49,19 +51,21 @@ jobs: - python-version: 3.8 requirements-file: dj50_cms41.txt - python-version: 3.8 - requirements-file: dj41_cms41.txt + requirements-file: dj32_cms41.txt - python-version: 3.8 requirements-file: dj40_cms41.txt - python-version: 3.8 - requirements-file: dj32_cms41.txt + requirements-file: dj41_cms41.txt + - python-version: 3.8 + requirements-file: dj42_cms41.txt - python-version: 3.8 requirements-file: dj42_cms41.txt - python-version: 3.9 requirements-file: dj50_cms41.txt - - python-version: "3.10" - requirements-file: dj22_cms40.txt - - python-version: "3.11" - requirements-file: dj22_cms40.txt + - python-version: 3.11 + requirements-file: dj42_cms40.txt + - python-version: 3.12 + requirements-file: dj40_cms40.txt steps: - uses: actions/checkout@v1 - name: Set up Python ${{ matrix.python-version }} diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5718a632b..b8979f568 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,11 +2,18 @@ Changelog ========= +5.1.6 (2024-07-18) +================== + +* fix: Allow double-clicks to propagate to CKEditor, e.g., to open the link dialog by @fsbraun in https://github.com/django-cms/djangocms-text-ckeditor/pull/676 +* fix: Let CKEditor decide on size of its panels by @fsbraun in https://github.com/django-cms/djangocms-text-ckeditor/pull/674 + + 5.1.5 (2023-11-30) ================== * fix(settings): Extend ALLOW_TOKEN_PARSERS if custom one is provided by @DmytroLitvinov in `#654 `_ -* fix: Support djangocms-picture 2.0.0 and higher in create_picture_plugin by @leture in `#660 `_ +* fix: Support djangocms-picture 2.0.0 and higher in create_picture_plugin by @leture in `#660 `_ * Remove Flash plugin in the default settings by @MacLake in `#656 `_ * fix: Allow for request-free context objects for testing purposes by @fsbraun in `#659 `_ * Update test matrix to include Django 5 by @protoroto in `#662 `_ diff --git a/djangocms_text_ckeditor/__init__.py b/djangocms_text_ckeditor/__init__.py index 9154022f5..2b27aae03 100644 --- a/djangocms_text_ckeditor/__init__.py +++ b/djangocms_text_ckeditor/__init__.py @@ -16,6 +16,6 @@ 10. Publish the release when ready 11. Github actions will publish the new package to pypi """ -__version__ = '5.1.5' +__version__ = '5.1.6' default_app_config = 'djangocms_text_ckeditor.apps.TextCkeditorConfig' 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 83d617f1b..afaf25668 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 @@ -137,7 +137,6 @@ // if event is a jQuery event (touchend), than we mutate // event a bit so we make the payload similar to what ckeditor.event produces var handleEdit = function (event) { - event.stop(); if (event.type === 'touchend' || event.type === 'click') { var cmsPluginNode = $(event.currentTarget).closest('cms-plugin')[0]; diff --git a/djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/dist/bundle-9f0bbac8ec.cms.ckeditor.min.js b/djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/dist/bundle-a9032984d4.cms.ckeditor.min.js similarity index 99% rename from djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/dist/bundle-9f0bbac8ec.cms.ckeditor.min.js rename to djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/dist/bundle-a9032984d4.cms.ckeditor.min.js index 26ea7a08c..99d5f63dd 100644 --- a/djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/dist/bundle-9f0bbac8ec.cms.ckeditor.min.js +++ b/djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/dist/bundle-a9032984d4.cms.ckeditor.min.js @@ -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:'