Skip to content

Commit

Permalink
fix: dont wrap empty cells
Browse files Browse the repository at this point in the history
  • Loading branch information
buuhuu committed Feb 13, 2024
1 parent c8f9169 commit 7386a5c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/aem.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,8 @@ function decorateBlock(block) {
// wrap plain text and inline elements in a <p>
block.querySelectorAll(':scope > div > div').forEach((cell) => {
const firstChild = cell.firstElementChild;
if (!firstChild || ['STRONG', 'EM', 'A', 'PICTURE'].includes(firstChild.tagName)) {
if ((!firstChild && cell.textContent.trim())
|| (firstChild && ['STRONG', 'EM', 'A', 'PICTURE'].includes(firstChild.tagName))) {
const p = document.createElement('p');
p.append(...cell.childNodes);
cell.replaceChildren(p);
Expand Down

0 comments on commit 7386a5c

Please sign in to comment.