From d594b1763173fba96cbdb0fac9ca7645a6ffe643 Mon Sep 17 00:00:00 2001 From: konradoboza Date: Tue, 27 Apr 2021 09:03:37 +0200 Subject: [PATCH 1/2] EZP-32400: Fixed displaying anchors for tables --- .../js/scripts/fieldType/base/base-rich-text.js | 12 ++++++++++-- 1 file changed, 10 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..034757ed78 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,14 @@ clearAnchor(element) { const icon = element.querySelector('.ez-icon--anchor'); - - if (icon) { + const elementPreviousSibling = element.previousSibling; + const isTableWithAnchor = + element.tagName.toLowerCase() === TABLE_TAG_NAME && + elementPreviousSibling.tagName.toLowerCase() === SVG_TAG_NAME; + + if (isTableWithAnchor) { + elementPreviousSibling.remove(); + } else if (icon) { icon.remove(); } else { element.classList.remove('ez-has-anchor'); From 7c070308602ab6cdb23fce86236995e7654f2d4b Mon Sep 17 00:00:00 2001 From: konradoboza Date: Tue, 27 Apr 2021 12:11:59 +0200 Subject: [PATCH 2/2] additional check whether previous sibling is not null --- .../Resources/public/js/scripts/fieldType/base/base-rich-text.js | 1 + 1 file changed, 1 insertion(+) 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 034757ed78..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 @@ -175,6 +175,7 @@ const elementPreviousSibling = element.previousSibling; const isTableWithAnchor = element.tagName.toLowerCase() === TABLE_TAG_NAME && + elementPreviousSibling && elementPreviousSibling.tagName.toLowerCase() === SVG_TAG_NAME; if (isTableWithAnchor) {