@zipify/wysiwyg 1.0.0-dev.78 → 1.0.0-dev.80
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
|
@@ -631,15 +631,16 @@
|
|
|
631
631
|
width: 234px;
|
|
632
632
|
}
|
|
633
633
|
|
|
634
|
-
.zw-toolbar[data-v-
|
|
634
|
+
.zw-toolbar[data-v-7afee166] {
|
|
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: fixed;
|
|
640
641
|
}
|
|
641
|
-
.zw-toolbar[data-v-
|
|
642
|
-
.zw-toolbar[data-v-
|
|
642
|
+
.zw-toolbar[data-v-7afee166]::before,
|
|
643
|
+
.zw-toolbar[data-v-7afee166]::after {
|
|
643
644
|
content: "";
|
|
644
645
|
display: block;
|
|
645
646
|
width: 100%;
|
|
@@ -647,21 +648,21 @@
|
|
|
647
648
|
position: absolute;
|
|
648
649
|
--zw-toolbar-safe-zone: calc(-1 * var(--zw-toolbar-offset-y));
|
|
649
650
|
}
|
|
650
|
-
.zw-toolbar[data-v-
|
|
651
|
+
.zw-toolbar[data-v-7afee166]::before {
|
|
651
652
|
top: var(--zw-toolbar-safe-zone);
|
|
652
653
|
}
|
|
653
|
-
.zw-toolbar[data-v-
|
|
654
|
+
.zw-toolbar[data-v-7afee166]::after {
|
|
654
655
|
bottom: var(--zw-toolbar-safe-zone);
|
|
655
656
|
}
|
|
656
|
-
.zw-toolbar--enter-active[data-v-
|
|
657
|
-
.zw-toolbar--leave-active[data-v-
|
|
657
|
+
.zw-toolbar--enter-active[data-v-7afee166],
|
|
658
|
+
.zw-toolbar--leave-active[data-v-7afee166] {
|
|
658
659
|
transition: opacity 150ms ease-out;
|
|
659
660
|
}
|
|
660
|
-
.zw-toolbar--leave-active[data-v-
|
|
661
|
+
.zw-toolbar--leave-active[data-v-7afee166] {
|
|
661
662
|
transition: opacity 0s ease-in;
|
|
662
663
|
}
|
|
663
|
-
.zw-toolbar--enter[data-v-
|
|
664
|
-
.zw-toolbar--leave-to[data-v-
|
|
664
|
+
.zw-toolbar--enter[data-v-7afee166],
|
|
665
|
+
.zw-toolbar--leave-to[data-v-7afee166] {
|
|
665
666
|
opacity: 0;
|
|
666
667
|
}
|
|
667
668
|
.zw-wysiwyg {
|
package/dist/wysiwyg.mjs
CHANGED
|
@@ -19433,24 +19433,6 @@ class FavoriteColors {
|
|
|
19433
19433
|
this.triggerUpdate = triggerUpdate;
|
|
19434
19434
|
}
|
|
19435
19435
|
}
|
|
19436
|
-
class ContextWindow {
|
|
19437
|
-
static use(window2) {
|
|
19438
|
-
this.window = window2;
|
|
19439
|
-
}
|
|
19440
|
-
static get document() {
|
|
19441
|
-
return this.window.document;
|
|
19442
|
-
}
|
|
19443
|
-
static get body() {
|
|
19444
|
-
return this.document.body;
|
|
19445
|
-
}
|
|
19446
|
-
static get head() {
|
|
19447
|
-
return this.document.head;
|
|
19448
|
-
}
|
|
19449
|
-
static getComputedStyle(element) {
|
|
19450
|
-
return this.window.getComputedStyle(element);
|
|
19451
|
-
}
|
|
19452
|
-
}
|
|
19453
|
-
__publicField(ContextWindow, "window", window);
|
|
19454
19436
|
const _ContentNormalizer = class {
|
|
19455
19437
|
static normalize(content) {
|
|
19456
19438
|
const options = {
|
|
@@ -19472,6 +19454,7 @@ const _ContentNormalizer = class {
|
|
|
19472
19454
|
}
|
|
19473
19455
|
_normalizeTextContent() {
|
|
19474
19456
|
this._dom = this._parser.parseFromString(this._content, "text/html");
|
|
19457
|
+
this._iterateNodes(this._normalizeBreakLines, (node) => node.tagName === "BR");
|
|
19475
19458
|
this._iterateNodes(this._removeEmptyNodes, this._isBlockNode);
|
|
19476
19459
|
this._iterateNodes(this._normalizeListItems, (node) => node.tagName === "LI");
|
|
19477
19460
|
this._iterateNodes(this._normalizeSettingsStructure, (node) => node.tagName === "SPAN");
|
|
@@ -19567,7 +19550,7 @@ const _ContentNormalizer = class {
|
|
|
19567
19550
|
_wrapTextNode(parent, node) {
|
|
19568
19551
|
if (node.nodeType !== Node.TEXT_NODE)
|
|
19569
19552
|
return node;
|
|
19570
|
-
const span =
|
|
19553
|
+
const span = document.createElement("span");
|
|
19571
19554
|
span.append(node.cloneNode());
|
|
19572
19555
|
parent.replaceChild(span, node);
|
|
19573
19556
|
return span;
|
|
@@ -19597,6 +19580,29 @@ const _ContentNormalizer = class {
|
|
|
19597
19580
|
element.removeAttribute("style");
|
|
19598
19581
|
}
|
|
19599
19582
|
}
|
|
19583
|
+
_normalizeBreakLines({ parentElement }) {
|
|
19584
|
+
if (!this._isBlockNode(parentElement))
|
|
19585
|
+
return;
|
|
19586
|
+
if (!parentElement.textContent)
|
|
19587
|
+
return;
|
|
19588
|
+
const fragment = new DocumentFragment();
|
|
19589
|
+
const children = Array.from(parentElement.childNodes);
|
|
19590
|
+
let capturingParagraph = document.createElement("p");
|
|
19591
|
+
const append2 = (node) => {
|
|
19592
|
+
this._assignElementProperties(node, parentElement, _ContentNormalizer.BLOCK_STYLES);
|
|
19593
|
+
fragment.append(node);
|
|
19594
|
+
};
|
|
19595
|
+
for (const child of children) {
|
|
19596
|
+
if (child.tagName === "BR") {
|
|
19597
|
+
append2(capturingParagraph);
|
|
19598
|
+
capturingParagraph = document.createElement("p");
|
|
19599
|
+
continue;
|
|
19600
|
+
}
|
|
19601
|
+
capturingParagraph.append(child);
|
|
19602
|
+
}
|
|
19603
|
+
fragment.append(capturingParagraph);
|
|
19604
|
+
parentElement.replaceWith(fragment);
|
|
19605
|
+
}
|
|
19600
19606
|
};
|
|
19601
19607
|
let ContentNormalizer = _ContentNormalizer;
|
|
19602
19608
|
__publicField(ContentNormalizer, "PARSER", new DOMParser());
|
|
@@ -19616,6 +19622,24 @@ __publicField(ContentNormalizer, "ASSIGN_STYLE_RULES", [
|
|
|
19616
19622
|
ignore: /text-decoration(.+)?/
|
|
19617
19623
|
}
|
|
19618
19624
|
]);
|
|
19625
|
+
class ContextWindow {
|
|
19626
|
+
static use(window2) {
|
|
19627
|
+
this.window = window2;
|
|
19628
|
+
}
|
|
19629
|
+
static get document() {
|
|
19630
|
+
return this.window.document;
|
|
19631
|
+
}
|
|
19632
|
+
static get body() {
|
|
19633
|
+
return this.document.body;
|
|
19634
|
+
}
|
|
19635
|
+
static get head() {
|
|
19636
|
+
return this.document.head;
|
|
19637
|
+
}
|
|
19638
|
+
static getComputedStyle(element) {
|
|
19639
|
+
return this.window.getComputedStyle(element);
|
|
19640
|
+
}
|
|
19641
|
+
}
|
|
19642
|
+
__publicField(ContextWindow, "window", window);
|
|
19619
19643
|
class NodeFactory {
|
|
19620
19644
|
static doc(content) {
|
|
19621
19645
|
return {
|
|
@@ -22772,7 +22796,7 @@ var __component__$1 = /* @__PURE__ */ normalizeComponent(
|
|
|
22772
22796
|
staticRenderFns$1,
|
|
22773
22797
|
false,
|
|
22774
22798
|
__vue2_injectStyles$1,
|
|
22775
|
-
"
|
|
22799
|
+
"7afee166",
|
|
22776
22800
|
null,
|
|
22777
22801
|
null
|
|
22778
22802
|
);
|
|
@@ -25550,60 +25574,6 @@ const History = Extension.create({
|
|
|
25550
25574
|
};
|
|
25551
25575
|
}
|
|
25552
25576
|
});
|
|
25553
|
-
const HardBreak = Node$1.create({
|
|
25554
|
-
name: "hardBreak",
|
|
25555
|
-
addOptions() {
|
|
25556
|
-
return {
|
|
25557
|
-
keepMarks: true,
|
|
25558
|
-
HTMLAttributes: {}
|
|
25559
|
-
};
|
|
25560
|
-
},
|
|
25561
|
-
inline: true,
|
|
25562
|
-
group: "inline",
|
|
25563
|
-
selectable: false,
|
|
25564
|
-
parseHTML() {
|
|
25565
|
-
return [
|
|
25566
|
-
{ tag: "br" }
|
|
25567
|
-
];
|
|
25568
|
-
},
|
|
25569
|
-
renderHTML({ HTMLAttributes }) {
|
|
25570
|
-
return ["br", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
|
|
25571
|
-
},
|
|
25572
|
-
renderText() {
|
|
25573
|
-
return "\n";
|
|
25574
|
-
},
|
|
25575
|
-
addCommands() {
|
|
25576
|
-
return {
|
|
25577
|
-
setHardBreak: () => ({ commands: commands2, chain, state, editor }) => {
|
|
25578
|
-
return commands2.first([
|
|
25579
|
-
() => commands2.exitCode(),
|
|
25580
|
-
() => commands2.command(() => {
|
|
25581
|
-
const { selection, storedMarks } = state;
|
|
25582
|
-
if (selection.$from.parent.type.spec.isolating) {
|
|
25583
|
-
return false;
|
|
25584
|
-
}
|
|
25585
|
-
const { keepMarks } = this.options;
|
|
25586
|
-
const { splittableMarks } = editor.extensionManager;
|
|
25587
|
-
const marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();
|
|
25588
|
-
return chain().insertContent({ type: this.name }).command(({ tr, dispatch }) => {
|
|
25589
|
-
if (dispatch && marks && keepMarks) {
|
|
25590
|
-
const filteredMarks = marks.filter((mark) => splittableMarks.includes(mark.type.name));
|
|
25591
|
-
tr.ensureMarks(filteredMarks);
|
|
25592
|
-
}
|
|
25593
|
-
return true;
|
|
25594
|
-
}).run();
|
|
25595
|
-
})
|
|
25596
|
-
]);
|
|
25597
|
-
}
|
|
25598
|
-
};
|
|
25599
|
-
},
|
|
25600
|
-
addKeyboardShortcuts() {
|
|
25601
|
-
return {
|
|
25602
|
-
"Mod-Enter": () => this.editor.commands.setHardBreak(),
|
|
25603
|
-
"Shift-Enter": () => this.editor.commands.setHardBreak()
|
|
25604
|
-
};
|
|
25605
|
-
}
|
|
25606
|
-
});
|
|
25607
25577
|
const NodeProcessor = Extension.create({
|
|
25608
25578
|
name: "node_processor",
|
|
25609
25579
|
addCommands() {
|
|
@@ -25759,9 +25729,6 @@ const buildCoreExtensions = () => [
|
|
|
25759
25729
|
}),
|
|
25760
25730
|
Text,
|
|
25761
25731
|
History,
|
|
25762
|
-
HardBreak.configure({
|
|
25763
|
-
keepMarks: false
|
|
25764
|
-
}),
|
|
25765
25732
|
NodeProcessor,
|
|
25766
25733
|
TextProcessor,
|
|
25767
25734
|
SelectionProcessor,
|
|
@@ -3,7 +3,6 @@ import Paragraph from '@tiptap/extension-paragraph';
|
|
|
3
3
|
import Text from '@tiptap/extension-text';
|
|
4
4
|
import Placeholder from '@tiptap/extension-placeholder';
|
|
5
5
|
import History from '@tiptap/extension-history';
|
|
6
|
-
import HardBreak from '@tiptap/extension-hard-break';
|
|
7
6
|
import { NodeProcessor } from './NodeProcessor';
|
|
8
7
|
import { TextProcessor } from './TextProcessor';
|
|
9
8
|
import { SelectionProcessor } from './SelectionProcessor';
|
|
@@ -20,9 +19,6 @@ export const buildCoreExtensions = () => [
|
|
|
20
19
|
}),
|
|
21
20
|
Text,
|
|
22
21
|
History,
|
|
23
|
-
HardBreak.configure({
|
|
24
|
-
keepMarks: false
|
|
25
|
-
}),
|
|
26
22
|
NodeProcessor,
|
|
27
23
|
TextProcessor,
|
|
28
24
|
SelectionProcessor,
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ContextWindow } from './ContextWidnow';
|
|
2
|
-
|
|
3
1
|
export class ContentNormalizer {
|
|
4
2
|
static PARSER = new DOMParser();
|
|
5
3
|
static BLOCK_STYLES = ['text-align', 'line-height'];
|
|
@@ -45,6 +43,7 @@ export class ContentNormalizer {
|
|
|
45
43
|
_normalizeTextContent() {
|
|
46
44
|
this._dom = this._parser.parseFromString(this._content, 'text/html');
|
|
47
45
|
|
|
46
|
+
this._iterateNodes(this._normalizeBreakLines, (node) => node.tagName === 'BR');
|
|
48
47
|
this._iterateNodes(this._removeEmptyNodes, this._isBlockNode);
|
|
49
48
|
this._iterateNodes(this._normalizeListItems, (node) => node.tagName === 'LI');
|
|
50
49
|
this._iterateNodes(this._normalizeSettingsStructure, (node) => node.tagName === 'SPAN');
|
|
@@ -166,7 +165,7 @@ export class ContentNormalizer {
|
|
|
166
165
|
_wrapTextNode(parent, node) {
|
|
167
166
|
if (node.nodeType !== Node.TEXT_NODE) return node;
|
|
168
167
|
|
|
169
|
-
const span =
|
|
168
|
+
const span = document.createElement('span');
|
|
170
169
|
|
|
171
170
|
span.append(node.cloneNode());
|
|
172
171
|
parent.replaceChild(span, node);
|
|
@@ -203,4 +202,31 @@ export class ContentNormalizer {
|
|
|
203
202
|
element.removeAttribute('style');
|
|
204
203
|
}
|
|
205
204
|
}
|
|
205
|
+
|
|
206
|
+
_normalizeBreakLines({ parentElement }) {
|
|
207
|
+
if (!this._isBlockNode(parentElement)) return;
|
|
208
|
+
if (!parentElement.textContent) return;
|
|
209
|
+
|
|
210
|
+
const fragment = new DocumentFragment();
|
|
211
|
+
const children = Array.from(parentElement.childNodes);
|
|
212
|
+
let capturingParagraph = document.createElement('p');
|
|
213
|
+
|
|
214
|
+
const append = (node) => {
|
|
215
|
+
this._assignElementProperties(node, parentElement, ContentNormalizer.BLOCK_STYLES);
|
|
216
|
+
fragment.append(node);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
for (const child of children) {
|
|
220
|
+
if (child.tagName === 'BR') {
|
|
221
|
+
append(capturingParagraph);
|
|
222
|
+
capturingParagraph = document.createElement('p');
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
capturingParagraph.append(child);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
fragment.append(capturingParagraph);
|
|
230
|
+
parentElement.replaceWith(fragment);
|
|
231
|
+
}
|
|
206
232
|
}
|
|
@@ -127,4 +127,18 @@ describe('normalize text content', () => {
|
|
|
127
127
|
|
|
128
128
|
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
129
129
|
});
|
|
130
|
+
|
|
131
|
+
test('should migrate br to paragraphs', () => {
|
|
132
|
+
const input = '<p><b>lorem</b><br>ipsum</p>';
|
|
133
|
+
const output = '<p><b>lorem</b></p><p>ipsum</p>';
|
|
134
|
+
|
|
135
|
+
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('should not migrate single br to paragraph', () => {
|
|
139
|
+
const input = '<p><br></p>';
|
|
140
|
+
const output = '<p><br></p>';
|
|
141
|
+
|
|
142
|
+
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
143
|
+
});
|
|
130
144
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zipify/wysiwyg",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.80",
|
|
4
4
|
"description": "Zipify modification of TipTap text editor",
|
|
5
5
|
"main": "dist/wysiwyg.mjs",
|
|
6
6
|
"repository": {
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"@popperjs/core": "^2.11.5",
|
|
31
31
|
"@tiptap/core": "^2.0.0-beta.182",
|
|
32
32
|
"@tiptap/extension-document": "^2.0.0-beta.17",
|
|
33
|
-
"@tiptap/extension-hard-break": "^2.0.0-beta.33",
|
|
34
33
|
"@tiptap/extension-heading": "^2.0.0-beta.29",
|
|
35
34
|
"@tiptap/extension-history": "^2.0.0-beta.26",
|
|
36
35
|
"@tiptap/extension-link": "^2.0.0-beta.43",
|