From 108212e00ed0cf9a557498e34c0d283bbe3847e3 Mon Sep 17 00:00:00 2001 From: Dariusz Szut Date: Tue, 20 Jun 2023 11:18:44 +0200 Subject: [PATCH] IBX-5950: Fixed last value from one custom class appears in another --- .../custom-attributes/custom-attributes-command.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bundle/Resources/public/js/CKEditor/custom-attributes/custom-attributes-command.js b/src/bundle/Resources/public/js/CKEditor/custom-attributes/custom-attributes-command.js index 4f9fc1f4..b0a5fd68 100644 --- a/src/bundle/Resources/public/js/CKEditor/custom-attributes/custom-attributes-command.js +++ b/src/bundle/Resources/public/js/CKEditor/custom-attributes/custom-attributes-command.js @@ -23,7 +23,15 @@ class IbexaCustomAttributesCommand extends Command { cleanClasses(modelElement, classes) { Object.keys(classes).forEach((elementName) => { - if (elementName === modelElement.name || classes[modelElement.name]) { + const selectedCustomClasses = modelElement.getAttribute('custom-classes') ?? ''; + const elementCustomClassesConfig = classes[modelElement.name]; + const hasOwnCustomClasses = + elementCustomClassesConfig && + selectedCustomClasses + .split() + .every((selectedCustomClass) => elementCustomClassesConfig.choices.includes(selectedCustomClass)); + + if (elementName === modelElement.name || hasOwnCustomClasses) { return; }