@zipify/wysiwyg 1.0.0-dev.80 → 1.0.0-dev.81
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.css
CHANGED
|
@@ -740,7 +740,6 @@ $font-height--md: 1.72;
|
|
|
740
740
|
}
|
|
741
741
|
.zw-superscript {
|
|
742
742
|
font-size: 75%;
|
|
743
|
-
line-height: 0;
|
|
744
743
|
position: relative;
|
|
745
744
|
vertical-align: initial;
|
|
746
745
|
top: -0.5em;
|
|
@@ -781,7 +780,6 @@ $font-height--md: 1.72;
|
|
|
781
780
|
}
|
|
782
781
|
.ProseMirror {
|
|
783
782
|
word-wrap: break-word;
|
|
784
|
-
white-space: pre-wrap;
|
|
785
783
|
white-space: break-spaces;
|
|
786
784
|
-webkit-font-variant-ligatures: none;
|
|
787
785
|
font-variant-ligatures: none;
|
package/dist/wysiwyg.mjs
CHANGED
|
@@ -19435,10 +19435,7 @@ class FavoriteColors {
|
|
|
19435
19435
|
}
|
|
19436
19436
|
const _ContentNormalizer = class {
|
|
19437
19437
|
static normalize(content) {
|
|
19438
|
-
const options = {
|
|
19439
|
-
content,
|
|
19440
|
-
parser: _ContentNormalizer.PARSER
|
|
19441
|
-
};
|
|
19438
|
+
const options = { content, parser: _ContentNormalizer.PARSER };
|
|
19442
19439
|
return new _ContentNormalizer(options).normalize();
|
|
19443
19440
|
}
|
|
19444
19441
|
constructor({ content, parser }) {
|
|
@@ -19453,7 +19450,7 @@ const _ContentNormalizer = class {
|
|
|
19453
19450
|
return this._normalizeTextContent();
|
|
19454
19451
|
}
|
|
19455
19452
|
_normalizeTextContent() {
|
|
19456
|
-
this._dom = this._parser.parseFromString(this._content, "text/html");
|
|
19453
|
+
this._dom = this._parser.parseFromString(this._content.replace(/(\r)?\n/g, ""), "text/html");
|
|
19457
19454
|
this._iterateNodes(this._normalizeBreakLines, (node) => node.tagName === "BR");
|
|
19458
19455
|
this._iterateNodes(this._removeEmptyNodes, this._isBlockNode);
|
|
19459
19456
|
this._iterateNodes(this._normalizeListItems, (node) => node.tagName === "LI");
|
|
@@ -19472,9 +19469,9 @@ const _ContentNormalizer = class {
|
|
|
19472
19469
|
}
|
|
19473
19470
|
}
|
|
19474
19471
|
_removeEmptyNodes(node) {
|
|
19475
|
-
|
|
19472
|
+
const html2 = node.innerHTML.replace(/ /g, "").trim();
|
|
19473
|
+
if (!html2)
|
|
19476
19474
|
node.remove();
|
|
19477
|
-
}
|
|
19478
19475
|
}
|
|
19479
19476
|
_normalizeListItems(itemEl) {
|
|
19480
19477
|
const fragment = new DocumentFragment();
|
|
@@ -19486,7 +19483,7 @@ const _ContentNormalizer = class {
|
|
|
19486
19483
|
};
|
|
19487
19484
|
this._assignElementProperties(itemEl, itemEl.parentElement, _ContentNormalizer.BLOCK_STYLES);
|
|
19488
19485
|
for (const node of children) {
|
|
19489
|
-
if (node
|
|
19486
|
+
if (this._isBlockNode(node)) {
|
|
19490
19487
|
append2(node);
|
|
19491
19488
|
capturingParagraph = null;
|
|
19492
19489
|
continue;
|
|
@@ -19,10 +19,7 @@ export class ContentNormalizer {
|
|
|
19
19
|
];
|
|
20
20
|
|
|
21
21
|
static normalize(content) {
|
|
22
|
-
const options = {
|
|
23
|
-
content,
|
|
24
|
-
parser: ContentNormalizer.PARSER
|
|
25
|
-
};
|
|
22
|
+
const options = { content, parser: ContentNormalizer.PARSER };
|
|
26
23
|
|
|
27
24
|
return new ContentNormalizer(options).normalize();
|
|
28
25
|
}
|
|
@@ -41,7 +38,7 @@ export class ContentNormalizer {
|
|
|
41
38
|
}
|
|
42
39
|
|
|
43
40
|
_normalizeTextContent() {
|
|
44
|
-
this._dom = this._parser.parseFromString(this._content, 'text/html');
|
|
41
|
+
this._dom = this._parser.parseFromString(this._content.replace(/(\r)?\n/g, ''), 'text/html');
|
|
45
42
|
|
|
46
43
|
this._iterateNodes(this._normalizeBreakLines, (node) => node.tagName === 'BR');
|
|
47
44
|
this._iterateNodes(this._removeEmptyNodes, this._isBlockNode);
|
|
@@ -65,9 +62,9 @@ export class ContentNormalizer {
|
|
|
65
62
|
}
|
|
66
63
|
|
|
67
64
|
_removeEmptyNodes(node) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
const html = node.innerHTML.replace(/ /g, '').trim();
|
|
66
|
+
|
|
67
|
+
if (!html) node.remove();
|
|
71
68
|
}
|
|
72
69
|
|
|
73
70
|
_normalizeListItems(itemEl) {
|
|
@@ -83,7 +80,7 @@ export class ContentNormalizer {
|
|
|
83
80
|
this._assignElementProperties(itemEl, itemEl.parentElement, ContentNormalizer.BLOCK_STYLES);
|
|
84
81
|
|
|
85
82
|
for (const node of children) {
|
|
86
|
-
if (node
|
|
83
|
+
if (this._isBlockNode(node)) {
|
|
87
84
|
append(node);
|
|
88
85
|
capturingParagraph = null;
|
|
89
86
|
continue;
|
|
@@ -72,6 +72,12 @@ describe('normalize text content', () => {
|
|
|
72
72
|
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
+
test('should allow using heading in list', () => {
|
|
76
|
+
const input = '<ul><li><h2>lorem ipsum</h2></li></ul>';
|
|
77
|
+
|
|
78
|
+
expect(ContentNormalizer.normalize(input)).toBe(input);
|
|
79
|
+
});
|
|
80
|
+
|
|
75
81
|
test('should ignore empty nodes', () => {
|
|
76
82
|
const input = '<p>lorem ipsum 1</p><p></p><p>lorem ipsum 2</p>';
|
|
77
83
|
const output = '<p>lorem ipsum 1</p><p>lorem ipsum 2</p>';
|
|
@@ -86,6 +92,13 @@ describe('normalize text content', () => {
|
|
|
86
92
|
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
87
93
|
});
|
|
88
94
|
|
|
95
|
+
test('should ignore non-breaking space only nodes', () => {
|
|
96
|
+
const input = '<p>lorem ipsum 1</p><p> </p><p>lorem ipsum 2</p>';
|
|
97
|
+
const output = '<p>lorem ipsum 1</p><p>lorem ipsum 2</p>';
|
|
98
|
+
|
|
99
|
+
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
100
|
+
});
|
|
101
|
+
|
|
89
102
|
test('should ignore newline chapters only nodes', () => {
|
|
90
103
|
const input = '<p>lorem ipsum 1</p><p>\n</p><p>lorem ipsum 2</p>';
|
|
91
104
|
const output = '<p>lorem ipsum 1</p><p>lorem ipsum 2</p>';
|
package/lib/styles/content.css
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
|
|
13
13
|
.zw-superscript {
|
|
14
14
|
font-size: 75%;
|
|
15
|
-
line-height: 0;
|
|
16
15
|
position: relative;
|
|
17
16
|
vertical-align: initial;
|
|
18
17
|
top: -0.5em;
|
|
@@ -64,7 +63,6 @@
|
|
|
64
63
|
|
|
65
64
|
.ProseMirror {
|
|
66
65
|
word-wrap: break-word;
|
|
67
|
-
white-space: pre-wrap;
|
|
68
66
|
white-space: break-spaces;
|
|
69
67
|
-webkit-font-variant-ligatures: none;
|
|
70
68
|
font-variant-ligatures: none;
|