@zipify/wysiwyg 1.0.0-dev.42 → 1.0.0-dev.43
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/config/vite/example.config.js +25 -0
- package/dist/wysiwyg.css +1 -1
- package/dist/wysiwyg.mjs +3272 -3219
- package/example/ExampleApp.vue +5 -0
- package/example/{example.html → index.html} +1 -0
- package/lib/Wysiwyg.vue +1 -4
- package/lib/__tests__/utils/NodeFactory.js +13 -0
- package/lib/components/base/__tests__/Modal.test.js +2 -3
- package/lib/components/base/composables/__tests__/useValidator.test.js +44 -0
- package/lib/components/base/composables/useValidator.js +7 -3
- package/lib/components/toolbar/__tests__/Toolbar.test.js +2 -3
- package/lib/components/toolbar/controls/StylePresetControl.vue +14 -1
- package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +16 -0
- package/lib/components/toolbar/controls/link/LinkControl.vue +28 -25
- package/lib/components/toolbar/controls/link/__tests__/LinkControl.test.js +79 -0
- package/lib/components/toolbar/controls/link/__tests__/LinkControlHeader.test.js +42 -0
- package/lib/components/toolbar/controls/link/composables/__tests__/__snapshots__/useLink.test.js.snap +8 -0
- package/lib/components/toolbar/controls/link/composables/__tests__/useLink.test.js +114 -0
- package/lib/components/toolbar/controls/link/destination/LinkControlDestination.vue +2 -2
- package/lib/components/toolbar/controls/link/destination/LinkControlUrl.vue +2 -2
- package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlPageBlock.test.js +36 -0
- package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlUrl.test.js +46 -0
- package/lib/components/toolbar/controls/link/destination/__tests__/__snapshots__/LinkControlPageBlock.test.js.snap +9 -0
- package/lib/components/toolbar/controls/link/destination/__tests__/__snapshots__/LinkControlUrl.test.js.snap +17 -0
- package/lib/composables/useToolbar.js +12 -0
- package/lib/directives/__tests__/outClick.test.js +6 -0
- package/lib/directives/outClick.js +12 -15
- package/lib/extensions/FontWeight.js +3 -1
- package/lib/extensions/LineHeight.js +3 -2
- package/lib/extensions/Link.js +3 -15
- package/lib/extensions/TextDecoration.js +18 -0
- package/lib/extensions/__tests__/FontWeight.test.js +8 -0
- package/lib/extensions/__tests__/Link.test.js +102 -0
- package/lib/extensions/__tests__/TextDecoration.test.js +24 -0
- package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +17 -0
- package/lib/extensions/__tests__/__snapshots__/Link.test.js.snap +225 -0
- package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +90 -0
- package/lib/extensions/core/plugins/PastePlugin.js +23 -14
- package/lib/extensions/index.js +5 -3
- package/lib/services/ContentNormalizer.js +55 -15
- package/lib/services/__tests__/ContentNormalizer.test.js +39 -4
- package/package.json +3 -13
- package/config/webpack/example.config.js +0 -88
- package/config/webpack/lib.config.js +0 -43
- package/config/webpack/loaders/index.js +0 -6
- package/config/webpack/loaders/js-loader.js +0 -5
- package/config/webpack/loaders/style-loader.js +0 -9
- package/config/webpack/loaders/svg-loader.js +0 -4
- package/config/webpack/loaders/vue-loader.js +0 -4
- package/config/webpack/settings.js +0 -9
|
@@ -285,6 +285,36 @@ Object {
|
|
|
285
285
|
}
|
|
286
286
|
`;
|
|
287
287
|
|
|
288
|
+
exports[`parsing html should get both from text with property shorthand 1`] = `
|
|
289
|
+
Object {
|
|
290
|
+
"content": Array [
|
|
291
|
+
Object {
|
|
292
|
+
"content": Array [
|
|
293
|
+
Object {
|
|
294
|
+
"marks": Array [
|
|
295
|
+
Object {
|
|
296
|
+
"attrs": Object {
|
|
297
|
+
"strike_through": true,
|
|
298
|
+
"underline": true,
|
|
299
|
+
},
|
|
300
|
+
"type": "text_decoration",
|
|
301
|
+
},
|
|
302
|
+
],
|
|
303
|
+
"text": "lorem",
|
|
304
|
+
"type": "text",
|
|
305
|
+
},
|
|
306
|
+
Object {
|
|
307
|
+
"text": " ipsum",
|
|
308
|
+
"type": "text",
|
|
309
|
+
},
|
|
310
|
+
],
|
|
311
|
+
"type": "paragraph",
|
|
312
|
+
},
|
|
313
|
+
],
|
|
314
|
+
"type": "doc",
|
|
315
|
+
}
|
|
316
|
+
`;
|
|
317
|
+
|
|
288
318
|
exports[`parsing html should get strike through from paragraph 1`] = `
|
|
289
319
|
Object {
|
|
290
320
|
"content": Array [
|
|
@@ -496,6 +526,66 @@ Object {
|
|
|
496
526
|
}
|
|
497
527
|
`;
|
|
498
528
|
|
|
529
|
+
exports[`parsing html should parse strike through from tag 1`] = `
|
|
530
|
+
Object {
|
|
531
|
+
"content": Array [
|
|
532
|
+
Object {
|
|
533
|
+
"content": Array [
|
|
534
|
+
Object {
|
|
535
|
+
"marks": Array [
|
|
536
|
+
Object {
|
|
537
|
+
"attrs": Object {
|
|
538
|
+
"strike_through": true,
|
|
539
|
+
"underline": false,
|
|
540
|
+
},
|
|
541
|
+
"type": "text_decoration",
|
|
542
|
+
},
|
|
543
|
+
],
|
|
544
|
+
"text": "lorem",
|
|
545
|
+
"type": "text",
|
|
546
|
+
},
|
|
547
|
+
Object {
|
|
548
|
+
"text": " ipsum",
|
|
549
|
+
"type": "text",
|
|
550
|
+
},
|
|
551
|
+
],
|
|
552
|
+
"type": "paragraph",
|
|
553
|
+
},
|
|
554
|
+
],
|
|
555
|
+
"type": "doc",
|
|
556
|
+
}
|
|
557
|
+
`;
|
|
558
|
+
|
|
559
|
+
exports[`parsing html should parse underline from tag 1`] = `
|
|
560
|
+
Object {
|
|
561
|
+
"content": Array [
|
|
562
|
+
Object {
|
|
563
|
+
"content": Array [
|
|
564
|
+
Object {
|
|
565
|
+
"marks": Array [
|
|
566
|
+
Object {
|
|
567
|
+
"attrs": Object {
|
|
568
|
+
"strike_through": false,
|
|
569
|
+
"underline": true,
|
|
570
|
+
},
|
|
571
|
+
"type": "text_decoration",
|
|
572
|
+
},
|
|
573
|
+
],
|
|
574
|
+
"text": "lorem",
|
|
575
|
+
"type": "text",
|
|
576
|
+
},
|
|
577
|
+
Object {
|
|
578
|
+
"text": " ipsum",
|
|
579
|
+
"type": "text",
|
|
580
|
+
},
|
|
581
|
+
],
|
|
582
|
+
"type": "paragraph",
|
|
583
|
+
},
|
|
584
|
+
],
|
|
585
|
+
"type": "doc",
|
|
586
|
+
}
|
|
587
|
+
`;
|
|
588
|
+
|
|
499
589
|
exports[`rendering should render both 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-text-decoration:underline line-through;\\" class=\\"zw-style\\">hello world</span></p>"`;
|
|
500
590
|
|
|
501
591
|
exports[`rendering should render strike through only 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-text-decoration:line-through;\\" class=\\"zw-style\\">hello world</span></p>"`;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ContentNormalizer } from '../../../services';
|
|
2
|
+
import { NodeTypes } from '../../../enums';
|
|
2
3
|
import { ProseMirrorPlugin } from './ProseMirrorPlugin';
|
|
3
4
|
|
|
4
5
|
export class PastePlugin extends ProseMirrorPlugin {
|
|
@@ -21,28 +22,36 @@ export class PastePlugin extends ProseMirrorPlugin {
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
_insertPastedContent({ state, input }, slice) {
|
|
24
|
-
if (!this.
|
|
25
|
+
if (!this._isFullBlockSelected(state)) {
|
|
25
26
|
return state.tr.replaceSelection(slice);
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
return state.tr.replaceSelectionWith(slice.content, input.shiftKey);
|
|
30
|
+
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
_isFullBlockSelected(state) {
|
|
33
|
+
const blocksSelection = this._expandSelectionToBlocks(state);
|
|
34
|
+
const isFromMatch = this._isMatchPosition(blocksSelection.from, state.selection.from);
|
|
35
|
+
const isToMatch = this._isMatchPosition(blocksSelection.to, state.selection.to);
|
|
36
|
+
|
|
37
|
+
return isFromMatch && isToMatch;
|
|
38
|
+
}
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
_expandSelectionToBlocks({ selection, doc }) {
|
|
41
|
+
let from = selection.from;
|
|
42
|
+
let to = selection.to;
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
doc.nodesBetween(from, to, (node, position, parent) => {
|
|
45
|
+
if (parent.type.name !== NodeTypes.DOCUMENT) return;
|
|
46
|
+
|
|
47
|
+
from = Math.min(from, position + 1);
|
|
48
|
+
to = Math.max(to, position + node.nodeSize - 1);
|
|
49
|
+
});
|
|
41
50
|
|
|
42
|
-
return
|
|
51
|
+
return { from, to };
|
|
43
52
|
}
|
|
44
53
|
|
|
45
|
-
|
|
46
|
-
return
|
|
54
|
+
_isMatchPosition(position1, position2) {
|
|
55
|
+
return Math.abs(position1 - position2) < 5;
|
|
47
56
|
}
|
|
48
57
|
}
|
package/lib/extensions/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import { buildCoreExtensions } from './core';
|
|
|
18
18
|
export function buildExtensions(options) {
|
|
19
19
|
const getPresetById = (id) => options.presetsRef.value.find((preset) => preset.id === id);
|
|
20
20
|
const defaultPreset = getPresetById(options.defaultPresetId);
|
|
21
|
+
const linkPreset = getPresetById('link');
|
|
21
22
|
|
|
22
23
|
return buildCoreExtensions(options).concat([
|
|
23
24
|
StylePreset.configure({
|
|
@@ -50,8 +51,9 @@ export function buildExtensions(options) {
|
|
|
50
51
|
Alignment,
|
|
51
52
|
LineHeight,
|
|
52
53
|
Link.configure({
|
|
53
|
-
preset:
|
|
54
|
+
preset: linkPreset,
|
|
54
55
|
basePresetClass: options.basePresetClass,
|
|
55
|
-
pageBlocks: options.
|
|
56
|
-
})
|
|
56
|
+
pageBlocks: options.pageBlocksRef
|
|
57
|
+
})
|
|
58
|
+
]);
|
|
57
59
|
}
|
|
@@ -2,6 +2,22 @@ import { ContextWindow } from './ContextWidnow';
|
|
|
2
2
|
|
|
3
3
|
export class ContentNormalizer {
|
|
4
4
|
static BLOCK_STYLES = ['text-align', 'line-height'];
|
|
5
|
+
static BLOCK_NODE_NAMES = ['P', 'H1', 'H2', 'H3', 'H4'];
|
|
6
|
+
|
|
7
|
+
static ASSIGN_STYLE_RULES = [
|
|
8
|
+
{
|
|
9
|
+
tag: /^(b|strong)$/,
|
|
10
|
+
ignore: /font-weight/
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
tag: /^i$/,
|
|
14
|
+
ignore: /font-style/
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
tag: /^s$/,
|
|
18
|
+
ignore: /text-decoration(.+)?/
|
|
19
|
+
}
|
|
20
|
+
];
|
|
5
21
|
|
|
6
22
|
static normalize(content) {
|
|
7
23
|
return new ContentNormalizer(content).normalize();
|
|
@@ -22,25 +38,32 @@ export class ContentNormalizer {
|
|
|
22
38
|
_normalizeTextContent() {
|
|
23
39
|
this._dom = new DOMParser().parseFromString(this._content, 'text/html');
|
|
24
40
|
|
|
25
|
-
this._iterateNodes(this.
|
|
26
|
-
this._iterateNodes(this.
|
|
27
|
-
this._iterateNodes(this.
|
|
41
|
+
this._iterateNodes(this._removeEmptyNodes, this._isBlockNode);
|
|
42
|
+
this._iterateNodes(this._normalizeListItems, (node) => node.tagName === 'LI');
|
|
43
|
+
this._iterateNodes(this._normalizeSettingsStructure, (node) => node.tagName === 'SPAN');
|
|
44
|
+
this._iterateNodes(this._normalizeStyles, (node) => node.tagName !== 'SPAN');
|
|
28
45
|
|
|
29
46
|
return this._dom.body.innerHTML;
|
|
30
47
|
}
|
|
31
48
|
|
|
32
|
-
_iterateNodes(handler, condition) {
|
|
49
|
+
_iterateNodes(handler, condition = () => true) {
|
|
33
50
|
const iterator = this._dom.createNodeIterator(this._dom.body, NodeFilter.SHOW_ELEMENT, {
|
|
34
|
-
acceptNode: (node) => condition(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT
|
|
51
|
+
acceptNode: (node) => condition.call(this, node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT
|
|
35
52
|
});
|
|
36
53
|
let currentNode = iterator.nextNode();
|
|
37
54
|
|
|
38
55
|
while (currentNode) {
|
|
39
|
-
handler(currentNode);
|
|
56
|
+
handler.call(this, currentNode);
|
|
40
57
|
currentNode = iterator.nextNode();
|
|
41
58
|
}
|
|
42
59
|
}
|
|
43
60
|
|
|
61
|
+
_removeEmptyNodes(node) {
|
|
62
|
+
if (node.childNodes.length === 0) {
|
|
63
|
+
node.remove();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
44
67
|
_normalizeListItems(itemEl) {
|
|
45
68
|
const fragment = new DocumentFragment();
|
|
46
69
|
const children = Array.from(itemEl.childNodes);
|
|
@@ -71,10 +94,7 @@ export class ContentNormalizer {
|
|
|
71
94
|
}
|
|
72
95
|
|
|
73
96
|
_normalizeSettingsStructure(element) {
|
|
74
|
-
|
|
75
|
-
.every((node) => node.nodeType === Node.TEXT_NODE);
|
|
76
|
-
|
|
77
|
-
if (isTextChildren) return;
|
|
97
|
+
if (this._isOnlyTextContent(element)) return;
|
|
78
98
|
|
|
79
99
|
const cloned = element.cloneNode(true);
|
|
80
100
|
const migratingStyles = this._getMigratingStyles(element, { customProperties: true });
|
|
@@ -95,8 +115,12 @@ export class ContentNormalizer {
|
|
|
95
115
|
}
|
|
96
116
|
|
|
97
117
|
_normalizeStyles(element) {
|
|
118
|
+
if (!this._isBlockNode(element) && this._isOnlyTextContent(element)) return;
|
|
119
|
+
|
|
98
120
|
const properties = this._getMigratingStyles(element);
|
|
99
121
|
|
|
122
|
+
if (!properties.length) return;
|
|
123
|
+
|
|
100
124
|
for (const node of element.childNodes) {
|
|
101
125
|
const child = this._wrapTextNode(element, node);
|
|
102
126
|
|
|
@@ -106,6 +130,14 @@ export class ContentNormalizer {
|
|
|
106
130
|
this._removeStyleProperties(element, properties);
|
|
107
131
|
}
|
|
108
132
|
|
|
133
|
+
_isOnlyTextContent(node) {
|
|
134
|
+
return Array.from(node.childNodes).every((node) => node.nodeType === Node.TEXT_NODE);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
_isBlockNode(node) {
|
|
138
|
+
return ContentNormalizer.BLOCK_NODE_NAMES.includes(node.tagName);
|
|
139
|
+
}
|
|
140
|
+
|
|
109
141
|
_getMigratingStyles(element, { customProperties } = {}) {
|
|
110
142
|
const blacklist = ContentNormalizer.BLOCK_STYLES;
|
|
111
143
|
const properties = [];
|
|
@@ -135,16 +167,24 @@ export class ContentNormalizer {
|
|
|
135
167
|
|
|
136
168
|
_assignElementProperties(target, source, properties) {
|
|
137
169
|
for (const property of properties) {
|
|
138
|
-
if (target.style.getPropertyValue(property)) {
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
170
|
const value = source.style.getPropertyValue(property);
|
|
143
171
|
|
|
144
|
-
if (value
|
|
172
|
+
if (value && this._canAssignElementProperty(target, source, property)) {
|
|
173
|
+
target.style.setProperty(property, value);
|
|
174
|
+
}
|
|
145
175
|
}
|
|
146
176
|
}
|
|
147
177
|
|
|
178
|
+
_canAssignElementProperty(target, source, property) {
|
|
179
|
+
if (target.style.getPropertyValue(property)) return false;
|
|
180
|
+
|
|
181
|
+
return ContentNormalizer.ASSIGN_STYLE_RULES.every((rule) => {
|
|
182
|
+
if (!rule.tag.test(target.tagName.toLowerCase())) return true;
|
|
183
|
+
|
|
184
|
+
return !rule.ignore.test(property);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
148
188
|
_removeStyleProperties(element, properties) {
|
|
149
189
|
for (const property of properties) {
|
|
150
190
|
element.style.removeProperty(property);
|
|
@@ -39,7 +39,7 @@ describe('normalize text content', () => {
|
|
|
39
39
|
|
|
40
40
|
test('should wrap list content in paragraph', () => {
|
|
41
41
|
const input = '<ul><li style="line-height: 2;">lorem impsum</li></ul>';
|
|
42
|
-
const output = '<ul><li><p style="line-height: 2;"
|
|
42
|
+
const output = '<ul><li><p style="line-height: 2;">lorem impsum</p></li></ul>';
|
|
43
43
|
|
|
44
44
|
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
45
45
|
});
|
|
@@ -48,7 +48,7 @@ describe('normalize text content', () => {
|
|
|
48
48
|
const input = '<ul><li style="line-height: 2;"><span style="font-weight: 700">lorem</span> impsum</li></ul>';
|
|
49
49
|
const output = '<ul>' +
|
|
50
50
|
'<li>' +
|
|
51
|
-
'<p style="line-height: 2;"><span style="font-weight: 700">lorem</span
|
|
51
|
+
'<p style="line-height: 2;"><span style="font-weight: 700">lorem</span> impsum</p>' +
|
|
52
52
|
'</li>' +
|
|
53
53
|
'</ul>';
|
|
54
54
|
|
|
@@ -64,11 +64,46 @@ describe('normalize text content', () => {
|
|
|
64
64
|
'</ul>';
|
|
65
65
|
const output = '<ul>' +
|
|
66
66
|
'<li>' +
|
|
67
|
-
'<p style="line-height: 2;"><span style="font-weight: 700">lorem</span
|
|
68
|
-
'<p style="line-height: 2;"
|
|
67
|
+
'<p style="line-height: 2;"><span style="font-weight: 700">lorem</span> impsum</p>' +
|
|
68
|
+
'<p style="line-height: 2;">paragraph text</p>' +
|
|
69
69
|
'</li>' +
|
|
70
70
|
'</ul>';
|
|
71
71
|
|
|
72
72
|
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
73
73
|
});
|
|
74
|
+
|
|
75
|
+
test('should ignore empty nodes', () => {
|
|
76
|
+
const input = '<p>lorem ipsum 1</p><p></p><p>lorem ipsum 2</p>';
|
|
77
|
+
const output = '<p>lorem ipsum 1</p><p>lorem ipsum 2</p>';
|
|
78
|
+
|
|
79
|
+
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('should not ignore setting', () => {
|
|
83
|
+
const input = '<p style="text-decoration-line: underline;">lorem ipsum</p>';
|
|
84
|
+
const output = '<p><span style="text-decoration-line: underline;">lorem ipsum</span></p>';
|
|
85
|
+
|
|
86
|
+
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('should not assign font-weight to b tag', () => {
|
|
90
|
+
const input = '<p style="font-weight: 400;"><b>lorem ipsum</b></p>';
|
|
91
|
+
const output = '<p><b>lorem ipsum</b></p>';
|
|
92
|
+
|
|
93
|
+
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('should not assign font-style to i tag', () => {
|
|
97
|
+
const input = '<p style="font-style: normal;"><i>lorem ipsum</i></p>';
|
|
98
|
+
const output = '<p><i>lorem ipsum</i></p>';
|
|
99
|
+
|
|
100
|
+
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('should not assign text-decoration to s tag', () => {
|
|
104
|
+
const input = '<p style="text-decoration-line: initial;"><s>lorem ipsum</s></p>';
|
|
105
|
+
const output = '<p><s>lorem ipsum</s></p>';
|
|
106
|
+
|
|
107
|
+
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
108
|
+
});
|
|
74
109
|
});
|
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.43",
|
|
4
4
|
"description": "Zipify modification of TipTap text editor",
|
|
5
5
|
"main": "dist/wysiwyg.mjs",
|
|
6
6
|
"repository": {
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"lib:build": "vite build --config ./config/vite/lib.config.js",
|
|
18
|
-
"example:start": "NODE_ENV=development
|
|
19
|
-
"example:build": "NODE_ENV=production
|
|
18
|
+
"example:start": "NODE_ENV=development vite serve --config ./config/vite/example.config.js",
|
|
19
|
+
"example:build": "NODE_ENV=production vite build --config ./config/vite/example.config.js",
|
|
20
20
|
"test:unit": "jest .",
|
|
21
21
|
"optimize-svg": "svgo --config ./config/svgo.js",
|
|
22
22
|
"gzip": "gzipper compress",
|
|
@@ -51,32 +51,22 @@
|
|
|
51
51
|
"@vue/test-utils": "^1.3.0",
|
|
52
52
|
"@vue/vue2-jest": "^28.0.1",
|
|
53
53
|
"babel-jest": "^28.1.3",
|
|
54
|
-
"babel-loader": "^8.2.5",
|
|
55
|
-
"css-loader": "^6.7.1",
|
|
56
54
|
"eslint": "^8.20.0",
|
|
57
55
|
"eslint-plugin-import": "^2.26.0",
|
|
58
56
|
"eslint-plugin-vue": "^9.3.0",
|
|
59
57
|
"gzipper": "^7.1.0",
|
|
60
|
-
"html-webpack-plugin": "^5.5.0",
|
|
61
58
|
"husky": "^8.0.1",
|
|
62
59
|
"jest": "^28.1.3",
|
|
63
60
|
"jest-environment-jsdom": "^28.1.3",
|
|
64
61
|
"lint-staged": "^13.0.3",
|
|
65
|
-
"mini-css-extract-plugin": "^2.6.1",
|
|
66
62
|
"postcss-html": "^1.5.0",
|
|
67
63
|
"release-it": "^15.1.2",
|
|
68
|
-
"style-loader": "^3.3.1",
|
|
69
64
|
"stylelint": "^14.9.1",
|
|
70
65
|
"svgo": "^2.8.0",
|
|
71
66
|
"vite": "^3.0.4",
|
|
72
67
|
"vite-plugin-vue2": "^2.0.2",
|
|
73
68
|
"vue": "^2.7.8",
|
|
74
|
-
"vue-loader": "^15.10.0",
|
|
75
69
|
"vue-template-compiler": "^2.7.8",
|
|
76
|
-
"webpack": "^5.74.0",
|
|
77
|
-
"webpack-bundle-analyzer": "^4.5.0",
|
|
78
|
-
"webpack-cli": "^4.10.0",
|
|
79
|
-
"webpack-dev-server": "^4.9.3",
|
|
80
70
|
"zipify-colorpicker": "^1.0.28"
|
|
81
71
|
}
|
|
82
72
|
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const { DefinePlugin } = require('webpack');
|
|
3
|
-
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
4
|
-
const { VueLoaderPlugin } = require('vue-loader');
|
|
5
|
-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
6
|
-
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
|
7
|
-
const { resolvePath, isDevelopment } = require('./settings');
|
|
8
|
-
const loaders = require('./loaders');
|
|
9
|
-
|
|
10
|
-
const isAnalyzerEnabled = !!process.env.ANALYZE_BUILD;
|
|
11
|
-
const filename = isDevelopment ? '[name].js' : '[name].[contenthash].js';
|
|
12
|
-
|
|
13
|
-
module.exports = {
|
|
14
|
-
mode: isDevelopment ? 'development' : 'production',
|
|
15
|
-
entry: resolvePath('./example/example.js'),
|
|
16
|
-
devtool: isDevelopment ? 'eval-source-map' : false,
|
|
17
|
-
|
|
18
|
-
output: {
|
|
19
|
-
clean: true,
|
|
20
|
-
path: resolvePath('./example/dist'),
|
|
21
|
-
filename,
|
|
22
|
-
chunkFilename: filename,
|
|
23
|
-
devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]',
|
|
24
|
-
devtoolModuleFilenameTemplate: (info) => {
|
|
25
|
-
let resPath = path.normalize(info.resourcePath);
|
|
26
|
-
let isVue = resPath.match(/\.vue$/);
|
|
27
|
-
let isGenerated = info.allLoaders;
|
|
28
|
-
|
|
29
|
-
let generated = `webpack-generated:///${resPath}?${info.hash}`;
|
|
30
|
-
let vuesource = `parsed:///${resPath}`;
|
|
31
|
-
|
|
32
|
-
return isVue && isGenerated ? generated : vuesource;
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
cache: {
|
|
37
|
-
type: 'filesystem',
|
|
38
|
-
cacheDirectory: resolvePath('./example/.cache')
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
devServer: {
|
|
42
|
-
host: 'localhost',
|
|
43
|
-
port: 7777,
|
|
44
|
-
devMiddleware: { publicPath: '/' }
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
resolve: {
|
|
48
|
-
extensions: ['*', '.js', '.vue', '.json']
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
optimization: {
|
|
52
|
-
splitChunks: {
|
|
53
|
-
chunks: 'all',
|
|
54
|
-
cacheGroups: {
|
|
55
|
-
vue: {
|
|
56
|
-
name: 'vue',
|
|
57
|
-
test: /[\\/]node_modules[\\/]@?vue/
|
|
58
|
-
},
|
|
59
|
-
tiptap: {
|
|
60
|
-
name: 'tiptap',
|
|
61
|
-
test: /[\\/]node_modules[\\/](@?tiptap|prosemirror)/
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
module: {
|
|
68
|
-
rules: [
|
|
69
|
-
loaders.style,
|
|
70
|
-
loaders.js,
|
|
71
|
-
loaders.svg,
|
|
72
|
-
loaders.vue
|
|
73
|
-
]
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
plugins: [
|
|
77
|
-
new VueLoaderPlugin(),
|
|
78
|
-
new MiniCssExtractPlugin(),
|
|
79
|
-
new HtmlWebpackPlugin({
|
|
80
|
-
title: 'ZipifyWysiwyg',
|
|
81
|
-
template: resolvePath('./example/example.html')
|
|
82
|
-
}),
|
|
83
|
-
new DefinePlugin({
|
|
84
|
-
ZW_UPDATED_AT: JSON.stringify(Date.now())
|
|
85
|
-
}),
|
|
86
|
-
...(isAnalyzerEnabled ? [new BundleAnalyzerPlugin()] : [])
|
|
87
|
-
]
|
|
88
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const { VueLoaderPlugin } = require('vue-loader');
|
|
2
|
-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
3
|
-
const { resolvePath } = require('./settings');
|
|
4
|
-
const loaders = require('./loaders');
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
mode: 'production',
|
|
8
|
-
entry: resolvePath('./lib/index.js'),
|
|
9
|
-
|
|
10
|
-
output: {
|
|
11
|
-
clean: true,
|
|
12
|
-
path: resolvePath('./dist'),
|
|
13
|
-
filename: 'wysiwyg.js',
|
|
14
|
-
library: { type: 'commonjs2' }
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
resolve: {
|
|
18
|
-
extensions: ['*', '.js', '.vue', '.json']
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
module: {
|
|
22
|
-
rules: [
|
|
23
|
-
loaders.style,
|
|
24
|
-
loaders.js,
|
|
25
|
-
loaders.svg,
|
|
26
|
-
loaders.vue
|
|
27
|
-
]
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
externals: {
|
|
31
|
-
'vue': 'commonjs2 vue',
|
|
32
|
-
'zipify-colorpicker': 'commonjs2 zipify-colorpicker'
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
experiments: {
|
|
36
|
-
outputModule: true
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
plugins: [
|
|
40
|
-
new VueLoaderPlugin(),
|
|
41
|
-
new MiniCssExtractPlugin({ filename: 'wysiwyg.css' })
|
|
42
|
-
]
|
|
43
|
-
};
|