@zipify/wysiwyg 1.2.4 → 1.2.5-1
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
|
@@ -19559,6 +19559,7 @@ const _ContentNormalizer = class {
|
|
|
19559
19559
|
const fragment = this.dom.createDocumentFragment();
|
|
19560
19560
|
const children = Array.from(itemEl.childNodes);
|
|
19561
19561
|
let capturingParagraph;
|
|
19562
|
+
let previousNode;
|
|
19562
19563
|
const append2 = (node) => {
|
|
19563
19564
|
this._assignElementProperties(node, itemEl, _ContentNormalizer.BLOCK_STYLES);
|
|
19564
19565
|
fragment.append(node);
|
|
@@ -19568,6 +19569,20 @@ const _ContentNormalizer = class {
|
|
|
19568
19569
|
if (this._isBlockNode(node)) {
|
|
19569
19570
|
append2(node);
|
|
19570
19571
|
capturingParagraph = null;
|
|
19572
|
+
previousNode = node;
|
|
19573
|
+
continue;
|
|
19574
|
+
}
|
|
19575
|
+
if (node.tagName === "BR" && previousNode && (previousNode == null ? void 0 : previousNode.tagName) !== "BR") {
|
|
19576
|
+
node.remove();
|
|
19577
|
+
previousNode = node;
|
|
19578
|
+
continue;
|
|
19579
|
+
}
|
|
19580
|
+
if (node.tagName === "BR") {
|
|
19581
|
+
const emptyLineEl = this.dom.createElement("p");
|
|
19582
|
+
emptyLineEl.append(node);
|
|
19583
|
+
append2(emptyLineEl);
|
|
19584
|
+
capturingParagraph = null;
|
|
19585
|
+
previousNode = node;
|
|
19571
19586
|
continue;
|
|
19572
19587
|
}
|
|
19573
19588
|
if (!capturingParagraph) {
|
|
@@ -19575,6 +19590,7 @@ const _ContentNormalizer = class {
|
|
|
19575
19590
|
append2(capturingParagraph);
|
|
19576
19591
|
}
|
|
19577
19592
|
capturingParagraph.append(node);
|
|
19593
|
+
previousNode = node;
|
|
19578
19594
|
}
|
|
19579
19595
|
itemEl.append(fragment);
|
|
19580
19596
|
this._removeStyleProperties(itemEl, _ContentNormalizer.BLOCK_STYLES);
|
|
@@ -113,6 +113,7 @@ export class ContentNormalizer {
|
|
|
113
113
|
const fragment = this.dom.createDocumentFragment();
|
|
114
114
|
const children = Array.from(itemEl.childNodes);
|
|
115
115
|
let capturingParagraph;
|
|
116
|
+
let previousNode;
|
|
116
117
|
|
|
117
118
|
const append = (node) => {
|
|
118
119
|
this._assignElementProperties(node, itemEl, ContentNormalizer.BLOCK_STYLES);
|
|
@@ -125,6 +126,23 @@ export class ContentNormalizer {
|
|
|
125
126
|
if (this._isBlockNode(node)) {
|
|
126
127
|
append(node);
|
|
127
128
|
capturingParagraph = null;
|
|
129
|
+
previousNode = node;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (node.tagName === 'BR' && previousNode && previousNode?.tagName !== 'BR') {
|
|
134
|
+
node.remove();
|
|
135
|
+
previousNode = node;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (node.tagName === 'BR') {
|
|
140
|
+
const emptyLineEl = this.dom.createElement('p');
|
|
141
|
+
|
|
142
|
+
emptyLineEl.append(node);
|
|
143
|
+
append(emptyLineEl);
|
|
144
|
+
capturingParagraph = null;
|
|
145
|
+
previousNode = node;
|
|
128
146
|
continue;
|
|
129
147
|
}
|
|
130
148
|
|
|
@@ -134,6 +152,7 @@ export class ContentNormalizer {
|
|
|
134
152
|
}
|
|
135
153
|
|
|
136
154
|
capturingParagraph.append(node);
|
|
155
|
+
previousNode = node;
|
|
137
156
|
}
|
|
138
157
|
|
|
139
158
|
itemEl.append(fragment);
|
|
@@ -155,6 +155,16 @@ describe('normalize text content', () => {
|
|
|
155
155
|
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
+
test('should normalize br in list items', () => {
|
|
159
|
+
const input = '<ul><li>lorem ipsum 1<br><br></li><li>lorem ipsum 2</li></ul>';
|
|
160
|
+
const output = '<ul>' +
|
|
161
|
+
'<li><p>lorem ipsum 1</p><p><br></p></li>' +
|
|
162
|
+
'<li><p>lorem ipsum 2</p></li>' +
|
|
163
|
+
'</ul>';
|
|
164
|
+
|
|
165
|
+
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
166
|
+
});
|
|
167
|
+
|
|
158
168
|
test('should remove comments', () => {
|
|
159
169
|
const input = '<p>lorem ipsum</p><p style="color: red;">Hello <!-- world --></p>';
|
|
160
170
|
const output = '<p>lorem ipsum</p><p><span style="color: red;">Hello </span></p>';
|