@hmcts/ccd-case-ui-toolkit 7.4.1-exui-5233-rc1 → 7.4.1-exui-5233-rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -27438,14 +27438,12 @@ class WriteRichTextAreaFieldComponent extends AbstractFieldWriteComponent {
|
|
|
27438
27438
|
? this.normalisePlainTextValue(sanitisedValue)
|
|
27439
27439
|
: '';
|
|
27440
27440
|
}
|
|
27441
|
+
/**
|
|
27442
|
+
* Gives intentionally blank paragraphs content so Docmosis preserves them as blank lines.
|
|
27443
|
+
* This runs only when the document has meaningful content, so a completely empty field remains empty.
|
|
27444
|
+
*/
|
|
27441
27445
|
preserveDocmosisBlankParagraphs(documentElement) {
|
|
27442
|
-
|
|
27443
|
-
paragraphs.forEach((paragraph) => {
|
|
27444
|
-
const visibleText = (paragraph.textContent || '').replace(/[\s\u00a0\u200b-\u200d\ufeff]/g, '');
|
|
27445
|
-
if (!visibleText && !paragraph.querySelector('hr')) {
|
|
27446
|
-
paragraph.textContent = '\u00a0';
|
|
27447
|
-
}
|
|
27448
|
-
});
|
|
27446
|
+
this.replaceBlankParagraphContent(documentElement, '\u00a0');
|
|
27449
27447
|
}
|
|
27450
27448
|
hasMeaningfulRichTextContent(documentElement) {
|
|
27451
27449
|
const visibleText = (documentElement.body.textContent || '')
|
|
@@ -27586,12 +27584,21 @@ class WriteRichTextAreaFieldComponent extends AbstractFieldWriteComponent {
|
|
|
27586
27584
|
this.clearBlankParagraphs(normalisedDocument);
|
|
27587
27585
|
return originalDocument.body.innerHTML === normalisedDocument.body.innerHTML;
|
|
27588
27586
|
}
|
|
27587
|
+
/**
|
|
27588
|
+
* Canonicalises visually blank paragraphs to <p></p> before comparing two HTML values.
|
|
27589
|
+
* This lets the editor avoid reloading when only the Docmosis blank-line representation changed.
|
|
27590
|
+
*/
|
|
27589
27591
|
clearBlankParagraphs(documentElement) {
|
|
27592
|
+
this.replaceBlankParagraphContent(documentElement, '');
|
|
27593
|
+
}
|
|
27594
|
+
replaceBlankParagraphContent(documentElement, replacement) {
|
|
27590
27595
|
const paragraphs = Array.prototype.slice.call(documentElement.body.querySelectorAll('p'));
|
|
27591
27596
|
paragraphs.forEach((paragraph) => {
|
|
27597
|
+
// Ignore standard whitespace (\s), non-breaking spaces (U+00A0), zero-width characters
|
|
27598
|
+
// (U+200B–U+200D), and the byte-order mark (U+FEFF) when checking for visible text.
|
|
27592
27599
|
const visibleText = (paragraph.textContent || '').replace(/[\s\u00a0\u200b-\u200d\ufeff]/g, '');
|
|
27593
|
-
if (!visibleText) {
|
|
27594
|
-
paragraph.textContent =
|
|
27600
|
+
if (!visibleText && !paragraph.querySelector('hr')) {
|
|
27601
|
+
paragraph.textContent = replacement;
|
|
27595
27602
|
}
|
|
27596
27603
|
});
|
|
27597
27604
|
}
|