@zipify/wysiwyg 1.0.0-dev.92 → 1.0.0-dev.93
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.
package/dist/wysiwyg.mjs
CHANGED
|
@@ -19588,7 +19588,9 @@ const _ContentNormalizer = class {
|
|
|
19588
19588
|
return;
|
|
19589
19589
|
const fragment = new DocumentFragment();
|
|
19590
19590
|
const children = Array.from(parentElement.childNodes);
|
|
19591
|
-
|
|
19591
|
+
const parentTemplate = parentElement.cloneNode(true);
|
|
19592
|
+
parentTemplate.innerHTML = "";
|
|
19593
|
+
let capturingParagraph = parentTemplate.cloneNode();
|
|
19592
19594
|
const append2 = (node) => {
|
|
19593
19595
|
this._assignElementProperties(node, parentElement, _ContentNormalizer.BLOCK_STYLES);
|
|
19594
19596
|
fragment.append(node);
|
|
@@ -19596,7 +19598,7 @@ const _ContentNormalizer = class {
|
|
|
19596
19598
|
for (const child of children) {
|
|
19597
19599
|
if (child.tagName === "BR") {
|
|
19598
19600
|
append2(capturingParagraph);
|
|
19599
|
-
capturingParagraph =
|
|
19601
|
+
capturingParagraph = parentTemplate.cloneNode();
|
|
19600
19602
|
continue;
|
|
19601
19603
|
}
|
|
19602
19604
|
capturingParagraph.append(child);
|
|
@@ -206,7 +206,10 @@ export class ContentNormalizer {
|
|
|
206
206
|
|
|
207
207
|
const fragment = new DocumentFragment();
|
|
208
208
|
const children = Array.from(parentElement.childNodes);
|
|
209
|
-
|
|
209
|
+
const parentTemplate = parentElement.cloneNode(true);
|
|
210
|
+
|
|
211
|
+
parentTemplate.innerHTML = '';
|
|
212
|
+
let capturingParagraph = parentTemplate.cloneNode();
|
|
210
213
|
|
|
211
214
|
const append = (node) => {
|
|
212
215
|
this._assignElementProperties(node, parentElement, ContentNormalizer.BLOCK_STYLES);
|
|
@@ -216,7 +219,7 @@ export class ContentNormalizer {
|
|
|
216
219
|
for (const child of children) {
|
|
217
220
|
if (child.tagName === 'BR') {
|
|
218
221
|
append(capturingParagraph);
|
|
219
|
-
capturingParagraph =
|
|
222
|
+
capturingParagraph = parentTemplate.cloneNode();
|
|
220
223
|
continue;
|
|
221
224
|
}
|
|
222
225
|
|
|
@@ -154,4 +154,11 @@ describe('normalize text content', () => {
|
|
|
154
154
|
|
|
155
155
|
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
156
156
|
});
|
|
157
|
+
|
|
158
|
+
test('should duplicate parent tag on normalize br', () => {
|
|
159
|
+
const input = '<h1><br></h1>';
|
|
160
|
+
const output = '<h1><br></h1>';
|
|
161
|
+
|
|
162
|
+
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
163
|
+
});
|
|
157
164
|
});
|