From 64052bdec2c35ea64fe0e6bfd4489587e3347b59 Mon Sep 17 00:00:00 2001 From: Konrad Oboza Date: Wed, 28 Apr 2021 14:42:19 +0200 Subject: [PATCH] EZP-32400: Fixed displaying anchors for tables (#1745) * EZP-32400: Fixed displaying anchors for tables * additional check whether previous sibling is not null --- .../js/scripts/fieldType/base/base-rich-text.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/bundle/Resources/public/js/scripts/fieldType/base/base-rich-text.js b/src/bundle/Resources/public/js/scripts/fieldType/base/base-rich-text.js index 7a96095311..6f7aef7f57 100644 --- a/src/bundle/Resources/public/js/scripts/fieldType/base/base-rich-text.js +++ b/src/bundle/Resources/public/js/scripts/fieldType/base/base-rich-text.js @@ -1,5 +1,7 @@ (function(global) { const eZ = (global.eZ = global.eZ || {}); + const TABLE_TAG_NAME = 'table'; + const SVG_TAG_NAME = 'svg'; const HTML_NODE = 1; const TEXT_NODE = 3; const notInitializeElements = ['strong', 'em', 'u', 'sup', 'sub', 's']; @@ -170,8 +172,15 @@ clearAnchor(element) { const icon = element.querySelector('.ez-icon--anchor'); - - if (icon) { + const elementPreviousSibling = element.previousSibling; + const isTableWithAnchor = + element.tagName.toLowerCase() === TABLE_TAG_NAME && + elementPreviousSibling && + elementPreviousSibling.tagName.toLowerCase() === SVG_TAG_NAME; + + if (isTableWithAnchor) { + elementPreviousSibling.remove(); + } else if (icon) { icon.remove(); } else { element.classList.remove('ez-has-anchor');