@zipify/wysiwyg 1.0.0-dev.80 → 1.0.0-dev.83
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 +11 -13
- package/dist/wysiwyg.mjs +9 -12
- package/lib/components/toolbar/Toolbar.vue +1 -1
- package/lib/composables/useToolbar.js +4 -3
- package/lib/services/ContentNormalizer.js +6 -9
- package/lib/services/__tests__/ContentNormalizer.test.js +13 -0
- package/lib/styles/content.css +0 -2
- package/package.json +1 -1
package/dist/wysiwyg.css
CHANGED
|
@@ -631,16 +631,16 @@
|
|
|
631
631
|
width: 234px;
|
|
632
632
|
}
|
|
633
633
|
|
|
634
|
-
.zw-toolbar[data-v-
|
|
634
|
+
.zw-toolbar[data-v-a84e0da4] {
|
|
635
635
|
border-radius: 2px;
|
|
636
636
|
background-color: rgb(var(--zw-color-n15));
|
|
637
637
|
color: rgb(var(--zw-color-n70));
|
|
638
638
|
z-index: 999999;
|
|
639
639
|
text-align: left;
|
|
640
|
-
position:
|
|
640
|
+
position: absolute;
|
|
641
641
|
}
|
|
642
|
-
.zw-toolbar[data-v-
|
|
643
|
-
.zw-toolbar[data-v-
|
|
642
|
+
.zw-toolbar[data-v-a84e0da4]::before,
|
|
643
|
+
.zw-toolbar[data-v-a84e0da4]::after {
|
|
644
644
|
content: "";
|
|
645
645
|
display: block;
|
|
646
646
|
width: 100%;
|
|
@@ -648,21 +648,21 @@
|
|
|
648
648
|
position: absolute;
|
|
649
649
|
--zw-toolbar-safe-zone: calc(-1 * var(--zw-toolbar-offset-y));
|
|
650
650
|
}
|
|
651
|
-
.zw-toolbar[data-v-
|
|
651
|
+
.zw-toolbar[data-v-a84e0da4]::before {
|
|
652
652
|
top: var(--zw-toolbar-safe-zone);
|
|
653
653
|
}
|
|
654
|
-
.zw-toolbar[data-v-
|
|
654
|
+
.zw-toolbar[data-v-a84e0da4]::after {
|
|
655
655
|
bottom: var(--zw-toolbar-safe-zone);
|
|
656
656
|
}
|
|
657
|
-
.zw-toolbar--enter-active[data-v-
|
|
658
|
-
.zw-toolbar--leave-active[data-v-
|
|
657
|
+
.zw-toolbar--enter-active[data-v-a84e0da4],
|
|
658
|
+
.zw-toolbar--leave-active[data-v-a84e0da4] {
|
|
659
659
|
transition: opacity 150ms ease-out;
|
|
660
660
|
}
|
|
661
|
-
.zw-toolbar--leave-active[data-v-
|
|
661
|
+
.zw-toolbar--leave-active[data-v-a84e0da4] {
|
|
662
662
|
transition: opacity 0s ease-in;
|
|
663
663
|
}
|
|
664
|
-
.zw-toolbar--enter[data-v-
|
|
665
|
-
.zw-toolbar--leave-to[data-v-
|
|
664
|
+
.zw-toolbar--enter[data-v-a84e0da4],
|
|
665
|
+
.zw-toolbar--leave-to[data-v-a84e0da4] {
|
|
666
666
|
opacity: 0;
|
|
667
667
|
}
|
|
668
668
|
.zw-wysiwyg {
|
|
@@ -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;
|
|
@@ -22796,7 +22793,7 @@ var __component__$1 = /* @__PURE__ */ normalizeComponent(
|
|
|
22796
22793
|
staticRenderFns$1,
|
|
22797
22794
|
false,
|
|
22798
22795
|
__vue2_injectStyles$1,
|
|
22799
|
-
"
|
|
22796
|
+
"a84e0da4",
|
|
22800
22797
|
null,
|
|
22801
22798
|
null
|
|
22802
22799
|
);
|
|
@@ -22833,7 +22830,6 @@ function useToolbar({ wrapperRef, offsets, isActiveRef }) {
|
|
|
22833
22830
|
function mount(element) {
|
|
22834
22831
|
popper2 = createPopper(wrapperEl.value, element, {
|
|
22835
22832
|
placement: "top-start",
|
|
22836
|
-
strategy: "fixed",
|
|
22837
22833
|
modifiers: [
|
|
22838
22834
|
{
|
|
22839
22835
|
name: "offset",
|
|
@@ -22843,12 +22839,13 @@ function useToolbar({ wrapperRef, offsets, isActiveRef }) {
|
|
|
22843
22839
|
name: "preventOverflow",
|
|
22844
22840
|
options: {
|
|
22845
22841
|
altAxis: true,
|
|
22846
|
-
padding: 2
|
|
22842
|
+
padding: 2,
|
|
22843
|
+
boundary: ContextWindow.window
|
|
22847
22844
|
}
|
|
22848
22845
|
},
|
|
22849
22846
|
{
|
|
22850
22847
|
name: "flip",
|
|
22851
|
-
options: {
|
|
22848
|
+
options: { boundary: ContextWindow.document }
|
|
22852
22849
|
}
|
|
22853
22850
|
]
|
|
22854
22851
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createPopper } from '@popperjs/core';
|
|
2
2
|
import { useElementRef } from '../components/base';
|
|
3
|
+
import { ContextWindow } from '../services';
|
|
3
4
|
|
|
4
5
|
export function useToolbar({ wrapperRef, offsets, isActiveRef }) {
|
|
5
6
|
const wrapperEl = useElementRef(wrapperRef);
|
|
@@ -8,7 +9,6 @@ export function useToolbar({ wrapperRef, offsets, isActiveRef }) {
|
|
|
8
9
|
function mount(element) {
|
|
9
10
|
popper = createPopper(wrapperEl.value, element, {
|
|
10
11
|
placement: 'top-start',
|
|
11
|
-
strategy: 'fixed',
|
|
12
12
|
modifiers: [
|
|
13
13
|
{
|
|
14
14
|
name: 'offset',
|
|
@@ -18,12 +18,13 @@ export function useToolbar({ wrapperRef, offsets, isActiveRef }) {
|
|
|
18
18
|
name: 'preventOverflow',
|
|
19
19
|
options: {
|
|
20
20
|
altAxis: true,
|
|
21
|
-
padding: 2
|
|
21
|
+
padding: 2,
|
|
22
|
+
boundary: ContextWindow.window
|
|
22
23
|
}
|
|
23
24
|
},
|
|
24
25
|
{
|
|
25
26
|
name: 'flip',
|
|
26
|
-
options: {
|
|
27
|
+
options: { boundary: ContextWindow.document }
|
|
27
28
|
}
|
|
28
29
|
]
|
|
29
30
|
});
|
|
@@ -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;
|