From e1867375e645a9c4b43396420a26bc8a335c551f Mon Sep 17 00:00:00 2001 From: i-just Date: Mon, 20 Jul 2026 15:48:54 +0200 Subject: [PATCH] download attr shouldn't have a value --- CHANGELOG.md | 4 ++++ src/web/assets/ckeditor/dist/ckeditor5-craftcms.js | 4 +++- src/web/assets/ckeditor/src/link/linkediting.js | 8 +++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fa661e2..b426fb53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for CKEditor for Craft CMS +## Unreleased + +- Fixed a bug where downloadable links’ `download` attributes were sometimes getting set to the value `"true"`. ([#606](https://github.com/craftcms/ckeditor/issues/606)) + ## 5.6.1 - 2026-05-13 - Fixed errors that could occur if the `ckeditor_references` table didn’t exist yet. ([#584](https://github.com/craftcms/ckeditor/issues/584)) diff --git a/src/web/assets/ckeditor/dist/ckeditor5-craftcms.js b/src/web/assets/ckeditor/dist/ckeditor5-craftcms.js index 6f7cbbcf..3026ff77 100644 --- a/src/web/assets/ckeditor/dist/ckeditor5-craftcms.js +++ b/src/web/assets/ckeditor/dist/ckeditor5-craftcms.js @@ -1245,7 +1245,9 @@ class ju extends $n { for (const h of C) i[p.model] ? f.setAttribute( p.model, - i[p.model], + // for bool type options, if the value is set to true, set the attribute with empty value + // see https://github.com/craftcms/ckeditor/issues/606 for more info + p.type == "bool" && p.value == !0 ? "" : i[p.model], h ) : f.removeAttribute(p.model, h); } diff --git a/src/web/assets/ckeditor/src/link/linkediting.js b/src/web/assets/ckeditor/src/link/linkediting.js index 71b4ccd0..d18d0a10 100644 --- a/src/web/assets/ckeditor/src/link/linkediting.js +++ b/src/web/assets/ckeditor/src/link/linkediting.js @@ -124,6 +124,8 @@ export default class CraftLinkEditing extends Plugin { writer.removeAttribute(item.model, writer.createRangeOn(node)); } } else { + // one case where selection is considered not collapsed is when you highlight a text, add a link to it, + // and then click on the "edit link" icon without closing the balloon that you see after adding a link const ranges = editor.model.schema.getValidRanges( selection.getRanges(), item.model, @@ -133,7 +135,11 @@ export default class CraftLinkEditing extends Plugin { if (extraAttributeValues[item.model]) { writer.setAttribute( item.model, - extraAttributeValues[item.model], + // for bool type options, if the value is set to true, set the attribute with empty value + // see https://github.com/craftcms/ckeditor/issues/606 for more info + item.type == 'bool' && item.value == true + ? '' + : extraAttributeValues[item.model], range, ); } else {