Skip to content

Commit 0ca7c7f

Browse files
authored
PRO-7811: Rich text modified state not detected correctly by the backend (#4982)
1 parent f4e524f commit 0ca7c7f

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
### Fixes
1313

1414
* Add missing Pages manager shortcuts list helper.
15+
* Improve the `isEmpty` method of the rich text widget to take into account the HTML blocks (`<figure>` and `<table>`) that are not empty but do not contain any plain text.
1516

1617
## 4.18.0 (2025-06-11)
1718

modules/@apostrophecms/rich-text-widget/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,11 @@ module.exports = {
837837
},
838838

839839
isEmpty(widget) {
840-
const text = self.apos.util.htmlToPlaintext(widget.content || '');
841-
return !text.trim().length;
840+
const content = (widget.content || '').trim();
841+
const text = self.apos.util.htmlToPlaintext(content).trim();
842+
return text.length === 0 &&
843+
content.includes('<table') === false &&
844+
content.includes('<figure') === false;
842845
},
843846

844847
sanitizeHtml(html, options) {

0 commit comments

Comments
 (0)