diff --git a/libs/utils/decorate.js b/libs/utils/decorate.js index ab3363489f..78593c43eb 100644 --- a/libs/utils/decorate.js +++ b/libs/utils/decorate.js @@ -5,17 +5,27 @@ export function decorateButtons(el, size) { if (buttons.length === 0) return; const buttonTypeMap = { STRONG: 'blue', EM: 'outline', A: 'blue' }; buttons.forEach((button) => { + let target = button; const parent = button.parentElement; const buttonType = buttonTypeMap[parent.nodeName] || 'outline'; if (button.nodeName === 'STRONG') { - parent.classList.add('con-button', buttonType); - if (size) parent.classList.add(size); /* button-l, button-xl */ + target = parent; } else { - button.classList.add('con-button', buttonType); - if (size) button.classList.add(size); /* button-l, button-xl */ parent.insertAdjacentElement('afterend', button); parent.remove(); } + target.classList.add('con-button', buttonType); + if (size) target.classList.add(size); /* button-l, button-xl */ + const customClasses = target.href && [...target.href.matchAll(/#_button-([a-zA-Z-]+)/g)]; + if (customClasses) { + customClasses.forEach((match) => { + target.href = target.href.replace(match[0], ''); + if (target.dataset.modalHash) { + target.setAttribute('data-modal-hash', target.dataset.modalHash.replace(match[0], '')); + } + target.classList.add(match[1]); + }); + } const actionArea = button.closest('p, div'); if (actionArea) { actionArea.classList.add('action-area'); diff --git a/test/blocks/text/mocks/body.html b/test/blocks/text/mocks/body.html index 3c10028ad6..2db780be10 100644 --- a/test/blocks/text/mocks/body.html +++ b/test/blocks/text/mocks/body.html @@ -220,3 +220,18 @@
Featuring over 600,000 hand-picked stock photos and graphics, curated from the world’s leading photographers, illustrators, and agencies. Our Premium collection is perfect for organizations looking for authentic, high-quality commercial content, and easy licensing plans.
+ +