@zipify/wysiwyg 1.0.0-dev.3 → 1.0.0-dev.32
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/.eslintignore +1 -0
- package/.github/dependabot.yaml +1 -0
- package/.release-it.json +3 -1
- package/.stylelintignore +1 -0
- package/README.md +3 -1
- package/config/jest/setupTests.js +7 -1
- package/config/webpack/example.config.js +2 -0
- package/config/webpack/lib.config.js +46 -0
- package/config/webpack/loaders/style-loader.js +3 -1
- package/config/webpack/loaders/svg-loader.js +1 -1
- package/dist/wysiwyg.css +1118 -0
- package/dist/wysiwyg.js +2 -0
- package/dist/wysiwyg.js.LICENSE.txt +1 -0
- package/example/ExampleApp.vue +51 -32
- package/example/example.js +26 -0
- package/example/pageBlocks.js +31 -0
- package/example/presets.js +4 -2
- package/lib/Wysiwyg.vue +41 -21
- package/lib/assets/icons/alignment-center.svg +3 -0
- package/lib/assets/icons/alignment-justify.svg +3 -0
- package/lib/assets/icons/alignment-left.svg +3 -0
- package/lib/assets/icons/alignment-right.svg +3 -0
- package/lib/assets/icons/arrow.svg +3 -0
- package/lib/assets/icons/background-color.svg +3 -0
- package/lib/assets/icons/case-style.svg +3 -0
- package/lib/assets/icons/font-color.svg +5 -0
- package/lib/assets/icons/italic.svg +3 -0
- package/lib/assets/icons/line-height.svg +3 -0
- package/lib/assets/icons/link.svg +3 -0
- package/lib/assets/icons/list-circle.svg +3 -0
- package/lib/assets/icons/list-decimal.svg +3 -0
- package/lib/assets/icons/list-disc.svg +3 -0
- package/lib/assets/icons/list-latin.svg +3 -0
- package/lib/assets/icons/list-roman.svg +3 -0
- package/lib/assets/icons/list-square.svg +3 -0
- package/lib/assets/icons/remove-format.svg +3 -0
- package/lib/assets/icons/reset-styles.svg +3 -0
- package/lib/assets/icons/strike-through.svg +3 -0
- package/lib/assets/icons/superscript.svg +3 -0
- package/lib/assets/icons/underline.svg +3 -0
- package/lib/assets/icons/unlink.svg +3 -0
- package/lib/components/base/Button.vue +21 -1
- package/lib/components/base/Checkbox.vue +89 -0
- package/lib/components/base/FieldLabel.vue +2 -1
- package/lib/components/base/Icon.vue +18 -10
- package/lib/components/base/Modal.vue +0 -1
- package/lib/components/base/TextField.vue +106 -0
- package/lib/components/base/__tests__/Icon.test.js +6 -13
- package/lib/components/base/__tests__/TextField.test.js +57 -0
- package/lib/components/base/__tests__/__snapshots__/TextField.test.js.snap +9 -0
- package/lib/components/base/colorPicker/composables/usePickerHotkeys.js +2 -1
- package/lib/components/base/composables/index.js +1 -0
- package/lib/components/base/composables/useValidator.js +19 -0
- package/lib/components/base/dropdown/Dropdown.vue +15 -3
- package/lib/components/base/dropdown/DropdownActivator.vue +19 -3
- package/lib/components/base/index.js +3 -1
- package/lib/components/toolbar/Toolbar.vue +49 -9
- package/lib/components/toolbar/ToolbarFull.vue +10 -2
- package/lib/components/toolbar/__tests__/Toolbar.test.js +6 -0
- package/lib/components/toolbar/controls/FontSizeControl.vue +7 -0
- package/lib/components/toolbar/controls/ListControl.vue +1 -5
- package/lib/components/toolbar/controls/UnderlineControl.vue +2 -2
- package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +4 -0
- package/lib/components/toolbar/controls/index.js +1 -0
- package/lib/components/toolbar/controls/link/LinkControl.vue +152 -0
- package/lib/components/toolbar/controls/link/LinkControlApply.vue +35 -0
- package/lib/components/toolbar/controls/link/LinkControlHeader.vue +67 -0
- package/lib/components/toolbar/controls/link/composables/index.js +1 -0
- package/lib/components/toolbar/controls/link/composables/useLink.js +61 -0
- package/lib/components/toolbar/controls/link/destination/LinkControlDestination.vue +103 -0
- package/lib/components/toolbar/controls/link/destination/LinkControlPageBlock.vue +54 -0
- package/lib/components/toolbar/controls/link/destination/LinkControlUrl.vue +52 -0
- package/lib/components/toolbar/controls/link/destination/index.js +1 -0
- package/lib/components/toolbar/controls/link/index.js +1 -0
- package/lib/composables/__tests__/useEditor.test.js +14 -5
- package/lib/composables/useEditor.js +13 -8
- package/lib/composables/useToolbar.js +14 -29
- package/lib/directives/outClick.js +20 -4
- package/lib/enums/LinkDestinations.js +4 -0
- package/lib/enums/LinkTargets.js +4 -0
- package/lib/enums/TextSettings.js +3 -1
- package/lib/enums/index.js +2 -0
- package/lib/extensions/Alignment.js +21 -3
- package/lib/extensions/BackgroundColor.js +16 -1
- package/lib/extensions/FontColor.js +16 -1
- package/lib/extensions/FontFamily.js +26 -2
- package/lib/extensions/FontSize.js +28 -3
- package/lib/extensions/FontStyle.js +23 -2
- package/lib/extensions/FontWeight.js +33 -1
- package/lib/extensions/LineHeight.js +29 -3
- package/lib/extensions/Link.js +101 -0
- package/lib/extensions/StylePreset.js +36 -6
- package/lib/extensions/TextDecoration.js +29 -3
- package/lib/extensions/__tests__/Alignment.test.js +30 -3
- package/lib/extensions/__tests__/BackgroundColor.test.js +38 -3
- package/lib/extensions/__tests__/CaseStyle.test.js +4 -3
- package/lib/extensions/__tests__/FontColor.test.js +38 -3
- package/lib/extensions/__tests__/FontFamily.test.js +59 -5
- package/lib/extensions/__tests__/FontSize.test.js +38 -3
- package/lib/extensions/__tests__/FontStyle.test.js +46 -3
- package/lib/extensions/__tests__/FontWeight.test.js +66 -3
- package/lib/extensions/__tests__/LineHeight.test.js +49 -3
- package/lib/extensions/__tests__/StylePreset.test.js +143 -4
- package/lib/extensions/__tests__/TextDecoration.test.js +87 -3
- package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +70 -2
- package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +121 -1
- package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +109 -1
- package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +179 -1
- package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +132 -2
- package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +142 -1
- package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +179 -1
- package/lib/extensions/__tests__/__snapshots__/LineHeight.test.js.snap +118 -2
- package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +171 -2
- package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +300 -3
- package/lib/extensions/core/CopyPasteProcessor.js +10 -0
- package/lib/extensions/core/TextProcessor.js +10 -0
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +4 -3
- package/lib/extensions/core/__tests__/SelectionProcessor.test.js +9 -6
- package/lib/extensions/core/__tests__/TextProcessor.test.js +139 -10
- package/lib/extensions/core/__tests__/__snapshots__/TextProcessor.test.js.snap +26 -0
- package/lib/extensions/core/index.js +11 -2
- package/lib/extensions/core/plugins/PastePlugin.js +48 -0
- package/lib/extensions/core/plugins/ProseMirrorPlugin.js +20 -0
- package/lib/extensions/core/plugins/index.js +1 -0
- package/lib/extensions/index.js +41 -33
- package/lib/extensions/list/List.js +34 -0
- package/lib/extensions/list/__tests__/List.test.js +115 -5
- package/lib/extensions/list/__tests__/__snapshots__/List.test.js.snap +481 -0
- package/lib/index.js +4 -1
- package/lib/injectionTokens.js +2 -1
- package/lib/services/ContentNormalizer.js +157 -0
- package/lib/services/ContextWidnow.js +23 -0
- package/lib/services/Storage.js +1 -13
- package/lib/services/__tests__/ContentNormalizer.test.js +74 -0
- package/lib/services/__tests__/FavoriteColors.test.js +20 -0
- package/lib/services/__tests__/JsonSerializer.test.js +23 -0
- package/lib/services/__tests__/Storage.test.js +79 -0
- package/lib/services/index.js +2 -0
- package/lib/styles/content.css +96 -9
- package/lib/styles/helpers/offsets.css +16 -0
- package/lib/styles/variables.css +6 -0
- package/lib/utils/__tests__/__snapshots__/renderInlineSetting.test.js.snap +4 -4
- package/lib/utils/__tests__/convertColor.test.js +19 -0
- package/lib/utils/__tests__/createKeyboardShortcut.test.js +25 -0
- package/lib/utils/__tests__/renderInlineSetting.test.js +26 -0
- package/lib/utils/convertColor.js +7 -0
- package/lib/utils/importIcon.js +12 -0
- package/lib/utils/index.js +2 -0
- package/lib/utils/renderInlineSetting.js +2 -2
- package/package.json +18 -14
- package/lib/assets/icons.svg +0 -69
- package/lib/composables/__tests__/useToolbar.test.js +0 -56
|
@@ -24,6 +24,122 @@ Object {
|
|
|
24
24
|
}
|
|
25
25
|
`;
|
|
26
26
|
|
|
27
|
-
exports[`
|
|
27
|
+
exports[`parsing html should get value from rendered view 1`] = `
|
|
28
|
+
Object {
|
|
29
|
+
"content": Array [
|
|
30
|
+
Object {
|
|
31
|
+
"attrs": Object {
|
|
32
|
+
"line_height": Object {
|
|
33
|
+
"desktop": "1.4",
|
|
34
|
+
"mobile": "1.2",
|
|
35
|
+
"tablet": null,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
"content": Array [
|
|
39
|
+
Object {
|
|
40
|
+
"text": "test",
|
|
41
|
+
"type": "text",
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
"type": "paragraph",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
"type": "doc",
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
exports[`parsing html should get value from text in px units with font size 1`] = `
|
|
52
|
+
Object {
|
|
53
|
+
"content": Array [
|
|
54
|
+
Object {
|
|
55
|
+
"attrs": Object {
|
|
56
|
+
"line_height": Object {
|
|
57
|
+
"desktop": "1.20",
|
|
58
|
+
"mobile": "1.20",
|
|
59
|
+
"tablet": "1.20",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
"content": Array [
|
|
63
|
+
Object {
|
|
64
|
+
"text": "test",
|
|
65
|
+
"type": "text",
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
"type": "paragraph",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
"type": "doc",
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
|
|
75
|
+
exports[`parsing html should get value from text in px units with no font size 1`] = `
|
|
76
|
+
Object {
|
|
77
|
+
"content": Array [
|
|
78
|
+
Object {
|
|
79
|
+
"attrs": Object {
|
|
80
|
+
"line_height": Object {
|
|
81
|
+
"desktop": "1.20",
|
|
82
|
+
"mobile": "1.20",
|
|
83
|
+
"tablet": "1.20",
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
"content": Array [
|
|
87
|
+
Object {
|
|
88
|
+
"text": "test",
|
|
89
|
+
"type": "text",
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
"type": "paragraph",
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
"type": "doc",
|
|
96
|
+
}
|
|
97
|
+
`;
|
|
98
|
+
|
|
99
|
+
exports[`parsing html should get value from text in relative units 1`] = `
|
|
100
|
+
Object {
|
|
101
|
+
"content": Array [
|
|
102
|
+
Object {
|
|
103
|
+
"attrs": Object {
|
|
104
|
+
"line_height": Object {
|
|
105
|
+
"desktop": "1.2",
|
|
106
|
+
"mobile": "1.2",
|
|
107
|
+
"tablet": "1.2",
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
"content": Array [
|
|
111
|
+
Object {
|
|
112
|
+
"text": "test",
|
|
113
|
+
"type": "text",
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
"type": "paragraph",
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
"type": "doc",
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
|
|
123
|
+
exports[`parsing html should set null if no alignment 1`] = `
|
|
124
|
+
Object {
|
|
125
|
+
"content": Array [
|
|
126
|
+
Object {
|
|
127
|
+
"attrs": Object {
|
|
128
|
+
"line_height": null,
|
|
129
|
+
},
|
|
130
|
+
"content": Array [
|
|
131
|
+
Object {
|
|
132
|
+
"text": "test",
|
|
133
|
+
"type": "text",
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
"type": "paragraph",
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
"type": "doc",
|
|
140
|
+
}
|
|
141
|
+
`;
|
|
142
|
+
|
|
143
|
+
exports[`rendering should render all devices 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-line-height-mobile:1.21;--zw-line-height-tablet:1.4;--zw-line-height-desktop:1.6;\\">hello world</p>"`;
|
|
28
144
|
|
|
29
|
-
exports[`rendering should render only desktop 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-
|
|
145
|
+
exports[`rendering should render only desktop 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-line-height-desktop:1.3;\\">hello world</p>"`;
|
|
@@ -241,6 +241,175 @@ Object {
|
|
|
241
241
|
}
|
|
242
242
|
`;
|
|
243
243
|
|
|
244
|
+
exports[`parsing html should get by fallback class 1`] = `
|
|
245
|
+
Object {
|
|
246
|
+
"content": Array [
|
|
247
|
+
Object {
|
|
248
|
+
"attrs": Object {
|
|
249
|
+
"alignment": null,
|
|
250
|
+
"preset": Object {
|
|
251
|
+
"id": "regular-2",
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
"content": Array [
|
|
255
|
+
Object {
|
|
256
|
+
"text": "lorem ipsum",
|
|
257
|
+
"type": "text",
|
|
258
|
+
},
|
|
259
|
+
],
|
|
260
|
+
"type": "paragraph",
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
"type": "doc",
|
|
264
|
+
}
|
|
265
|
+
`;
|
|
266
|
+
|
|
267
|
+
exports[`parsing html should get by heading tag 1`] = `
|
|
268
|
+
Object {
|
|
269
|
+
"content": Array [
|
|
270
|
+
Object {
|
|
271
|
+
"attrs": Object {
|
|
272
|
+
"alignment": null,
|
|
273
|
+
"level": 3,
|
|
274
|
+
"preset": Object {
|
|
275
|
+
"id": "h3",
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
"content": Array [
|
|
279
|
+
Object {
|
|
280
|
+
"text": "lorem ipsum",
|
|
281
|
+
"type": "text",
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
"type": "heading",
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
"type": "doc",
|
|
288
|
+
}
|
|
289
|
+
`;
|
|
290
|
+
|
|
291
|
+
exports[`parsing html should get by preset class 1`] = `
|
|
292
|
+
Object {
|
|
293
|
+
"content": Array [
|
|
294
|
+
Object {
|
|
295
|
+
"attrs": Object {
|
|
296
|
+
"alignment": null,
|
|
297
|
+
"preset": Object {
|
|
298
|
+
"id": "regular-2",
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
"content": Array [
|
|
302
|
+
Object {
|
|
303
|
+
"text": "lorem ipsum",
|
|
304
|
+
"type": "text",
|
|
305
|
+
},
|
|
306
|
+
],
|
|
307
|
+
"type": "paragraph",
|
|
308
|
+
},
|
|
309
|
+
],
|
|
310
|
+
"type": "doc",
|
|
311
|
+
}
|
|
312
|
+
`;
|
|
313
|
+
|
|
314
|
+
exports[`parsing html should set default preset to unstyled paragraph 1`] = `
|
|
315
|
+
Object {
|
|
316
|
+
"content": Array [
|
|
317
|
+
Object {
|
|
318
|
+
"attrs": Object {
|
|
319
|
+
"alignment": null,
|
|
320
|
+
"preset": Object {
|
|
321
|
+
"id": "regular-1",
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
"content": Array [
|
|
325
|
+
Object {
|
|
326
|
+
"text": "lorem ipsum",
|
|
327
|
+
"type": "text",
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
"type": "paragraph",
|
|
331
|
+
},
|
|
332
|
+
],
|
|
333
|
+
"type": "doc",
|
|
334
|
+
}
|
|
335
|
+
`;
|
|
336
|
+
|
|
337
|
+
exports[`parsing html should set null to list item 1`] = `
|
|
338
|
+
Object {
|
|
339
|
+
"content": Array [
|
|
340
|
+
Object {
|
|
341
|
+
"attrs": Object {
|
|
342
|
+
"bullet": Object {
|
|
343
|
+
"type": "disc",
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
"content": Array [
|
|
347
|
+
Object {
|
|
348
|
+
"content": Array [
|
|
349
|
+
Object {
|
|
350
|
+
"attrs": Object {
|
|
351
|
+
"alignment": null,
|
|
352
|
+
"preset": Object {
|
|
353
|
+
"id": "regular-1",
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
"content": Array [
|
|
357
|
+
Object {
|
|
358
|
+
"text": "lorem ipsum",
|
|
359
|
+
"type": "text",
|
|
360
|
+
},
|
|
361
|
+
],
|
|
362
|
+
"type": "paragraph",
|
|
363
|
+
},
|
|
364
|
+
],
|
|
365
|
+
"type": "listItem",
|
|
366
|
+
},
|
|
367
|
+
],
|
|
368
|
+
"type": "list",
|
|
369
|
+
},
|
|
370
|
+
],
|
|
371
|
+
"type": "doc",
|
|
372
|
+
}
|
|
373
|
+
`;
|
|
374
|
+
|
|
375
|
+
exports[`parsing html should set null to list item with preset 1`] = `
|
|
376
|
+
Object {
|
|
377
|
+
"content": Array [
|
|
378
|
+
Object {
|
|
379
|
+
"attrs": Object {
|
|
380
|
+
"bullet": Object {
|
|
381
|
+
"type": "disc",
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
"content": Array [
|
|
385
|
+
Object {
|
|
386
|
+
"content": Array [
|
|
387
|
+
Object {
|
|
388
|
+
"attrs": Object {
|
|
389
|
+
"alignment": null,
|
|
390
|
+
"preset": Object {
|
|
391
|
+
"id": "regular-1",
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
"content": Array [
|
|
395
|
+
Object {
|
|
396
|
+
"text": "lorem ipsum",
|
|
397
|
+
"type": "text",
|
|
398
|
+
},
|
|
399
|
+
],
|
|
400
|
+
"type": "paragraph",
|
|
401
|
+
},
|
|
402
|
+
],
|
|
403
|
+
"type": "listItem",
|
|
404
|
+
},
|
|
405
|
+
],
|
|
406
|
+
"type": "list",
|
|
407
|
+
},
|
|
408
|
+
],
|
|
409
|
+
"type": "doc",
|
|
410
|
+
}
|
|
411
|
+
`;
|
|
412
|
+
|
|
244
413
|
exports[`remove preset customization should remove all attributes 1`] = `
|
|
245
414
|
Object {
|
|
246
415
|
"content": Array [
|
|
@@ -305,6 +474,6 @@ Object {
|
|
|
305
474
|
|
|
306
475
|
exports[`render preset styles should render node without preset 1`] = `"<p class=\\"zw-style\\">test</p>"`;
|
|
307
476
|
|
|
308
|
-
exports[`render preset styles should render preset class 1`] = `"<p class=\\"zw-style zw-
|
|
477
|
+
exports[`render preset styles should render preset class 1`] = `"<p class=\\"zw-style zw ts-regular-1\\">test</p>"`;
|
|
309
478
|
|
|
310
|
-
exports[`render preset styles should render styles 1`] = `" .zw-
|
|
479
|
+
exports[`render preset styles should render styles 1`] = `" .zw.ts-regular-1 { --zw-preset-font-weight: var(--common-regular-1-font-weight, inherit); --zw-preset-mobile-font-size: var(--mobile-regular-1-font-size, inherit); --zw-preset-tablet-font-size: var(--tablet-regular-1-font-size, inherit); --zw-preset-desktop-font-size: var(--desktop-regular-1-font-size, inherit); }"`;
|
|
@@ -199,8 +199,305 @@ Object {
|
|
|
199
199
|
}
|
|
200
200
|
`;
|
|
201
201
|
|
|
202
|
-
exports[`
|
|
202
|
+
exports[`parsing html should get both from paragraph 1`] = `
|
|
203
|
+
Object {
|
|
204
|
+
"content": Array [
|
|
205
|
+
Object {
|
|
206
|
+
"content": Array [
|
|
207
|
+
Object {
|
|
208
|
+
"marks": Array [
|
|
209
|
+
Object {
|
|
210
|
+
"attrs": Object {
|
|
211
|
+
"strike_through": true,
|
|
212
|
+
"underline": true,
|
|
213
|
+
},
|
|
214
|
+
"type": "text_decoration",
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
"text": "test",
|
|
218
|
+
"type": "text",
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
"type": "paragraph",
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
"type": "doc",
|
|
225
|
+
}
|
|
226
|
+
`;
|
|
227
|
+
|
|
228
|
+
exports[`parsing html should get both from rendered view 1`] = `
|
|
229
|
+
Object {
|
|
230
|
+
"content": Array [
|
|
231
|
+
Object {
|
|
232
|
+
"content": Array [
|
|
233
|
+
Object {
|
|
234
|
+
"marks": Array [
|
|
235
|
+
Object {
|
|
236
|
+
"attrs": Object {
|
|
237
|
+
"strike_through": true,
|
|
238
|
+
"underline": true,
|
|
239
|
+
},
|
|
240
|
+
"type": "text_decoration",
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
"text": "lorem",
|
|
244
|
+
"type": "text",
|
|
245
|
+
},
|
|
246
|
+
Object {
|
|
247
|
+
"text": " ipsum",
|
|
248
|
+
"type": "text",
|
|
249
|
+
},
|
|
250
|
+
],
|
|
251
|
+
"type": "paragraph",
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
"type": "doc",
|
|
255
|
+
}
|
|
256
|
+
`;
|
|
257
|
+
|
|
258
|
+
exports[`parsing html should get both from text 1`] = `
|
|
259
|
+
Object {
|
|
260
|
+
"content": Array [
|
|
261
|
+
Object {
|
|
262
|
+
"content": Array [
|
|
263
|
+
Object {
|
|
264
|
+
"marks": Array [
|
|
265
|
+
Object {
|
|
266
|
+
"attrs": Object {
|
|
267
|
+
"strike_through": true,
|
|
268
|
+
"underline": true,
|
|
269
|
+
},
|
|
270
|
+
"type": "text_decoration",
|
|
271
|
+
},
|
|
272
|
+
],
|
|
273
|
+
"text": "lorem",
|
|
274
|
+
"type": "text",
|
|
275
|
+
},
|
|
276
|
+
Object {
|
|
277
|
+
"text": " ipsum",
|
|
278
|
+
"type": "text",
|
|
279
|
+
},
|
|
280
|
+
],
|
|
281
|
+
"type": "paragraph",
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
"type": "doc",
|
|
285
|
+
}
|
|
286
|
+
`;
|
|
287
|
+
|
|
288
|
+
exports[`parsing html should get strike through from paragraph 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": false,
|
|
299
|
+
},
|
|
300
|
+
"type": "text_decoration",
|
|
301
|
+
},
|
|
302
|
+
],
|
|
303
|
+
"text": "test",
|
|
304
|
+
"type": "text",
|
|
305
|
+
},
|
|
306
|
+
],
|
|
307
|
+
"type": "paragraph",
|
|
308
|
+
},
|
|
309
|
+
],
|
|
310
|
+
"type": "doc",
|
|
311
|
+
}
|
|
312
|
+
`;
|
|
313
|
+
|
|
314
|
+
exports[`parsing html should get strike through from rendered view 1`] = `
|
|
315
|
+
Object {
|
|
316
|
+
"content": Array [
|
|
317
|
+
Object {
|
|
318
|
+
"content": Array [
|
|
319
|
+
Object {
|
|
320
|
+
"marks": Array [
|
|
321
|
+
Object {
|
|
322
|
+
"attrs": Object {
|
|
323
|
+
"strike_through": true,
|
|
324
|
+
"underline": false,
|
|
325
|
+
},
|
|
326
|
+
"type": "text_decoration",
|
|
327
|
+
},
|
|
328
|
+
],
|
|
329
|
+
"text": "lorem",
|
|
330
|
+
"type": "text",
|
|
331
|
+
},
|
|
332
|
+
Object {
|
|
333
|
+
"text": " ipsum",
|
|
334
|
+
"type": "text",
|
|
335
|
+
},
|
|
336
|
+
],
|
|
337
|
+
"type": "paragraph",
|
|
338
|
+
},
|
|
339
|
+
],
|
|
340
|
+
"type": "doc",
|
|
341
|
+
}
|
|
342
|
+
`;
|
|
343
|
+
|
|
344
|
+
exports[`parsing html should get strike through from text 1`] = `
|
|
345
|
+
Object {
|
|
346
|
+
"content": Array [
|
|
347
|
+
Object {
|
|
348
|
+
"content": Array [
|
|
349
|
+
Object {
|
|
350
|
+
"marks": Array [
|
|
351
|
+
Object {
|
|
352
|
+
"attrs": Object {
|
|
353
|
+
"strike_through": true,
|
|
354
|
+
"underline": false,
|
|
355
|
+
},
|
|
356
|
+
"type": "text_decoration",
|
|
357
|
+
},
|
|
358
|
+
],
|
|
359
|
+
"text": "lorem",
|
|
360
|
+
"type": "text",
|
|
361
|
+
},
|
|
362
|
+
Object {
|
|
363
|
+
"text": " ipsum",
|
|
364
|
+
"type": "text",
|
|
365
|
+
},
|
|
366
|
+
],
|
|
367
|
+
"type": "paragraph",
|
|
368
|
+
},
|
|
369
|
+
],
|
|
370
|
+
"type": "doc",
|
|
371
|
+
}
|
|
372
|
+
`;
|
|
373
|
+
|
|
374
|
+
exports[`parsing html should get underline from paragraph 1`] = `
|
|
375
|
+
Object {
|
|
376
|
+
"content": Array [
|
|
377
|
+
Object {
|
|
378
|
+
"content": Array [
|
|
379
|
+
Object {
|
|
380
|
+
"marks": Array [
|
|
381
|
+
Object {
|
|
382
|
+
"attrs": Object {
|
|
383
|
+
"strike_through": false,
|
|
384
|
+
"underline": true,
|
|
385
|
+
},
|
|
386
|
+
"type": "text_decoration",
|
|
387
|
+
},
|
|
388
|
+
],
|
|
389
|
+
"text": "test",
|
|
390
|
+
"type": "text",
|
|
391
|
+
},
|
|
392
|
+
],
|
|
393
|
+
"type": "paragraph",
|
|
394
|
+
},
|
|
395
|
+
],
|
|
396
|
+
"type": "doc",
|
|
397
|
+
}
|
|
398
|
+
`;
|
|
399
|
+
|
|
400
|
+
exports[`parsing html should get underline from rendered view 1`] = `
|
|
401
|
+
Object {
|
|
402
|
+
"content": Array [
|
|
403
|
+
Object {
|
|
404
|
+
"content": Array [
|
|
405
|
+
Object {
|
|
406
|
+
"marks": Array [
|
|
407
|
+
Object {
|
|
408
|
+
"attrs": Object {
|
|
409
|
+
"strike_through": false,
|
|
410
|
+
"underline": true,
|
|
411
|
+
},
|
|
412
|
+
"type": "text_decoration",
|
|
413
|
+
},
|
|
414
|
+
],
|
|
415
|
+
"text": "lorem",
|
|
416
|
+
"type": "text",
|
|
417
|
+
},
|
|
418
|
+
Object {
|
|
419
|
+
"text": " ipsum",
|
|
420
|
+
"type": "text",
|
|
421
|
+
},
|
|
422
|
+
],
|
|
423
|
+
"type": "paragraph",
|
|
424
|
+
},
|
|
425
|
+
],
|
|
426
|
+
"type": "doc",
|
|
427
|
+
}
|
|
428
|
+
`;
|
|
429
|
+
|
|
430
|
+
exports[`parsing html should get underline from text 1`] = `
|
|
431
|
+
Object {
|
|
432
|
+
"content": Array [
|
|
433
|
+
Object {
|
|
434
|
+
"content": Array [
|
|
435
|
+
Object {
|
|
436
|
+
"marks": Array [
|
|
437
|
+
Object {
|
|
438
|
+
"attrs": Object {
|
|
439
|
+
"strike_through": false,
|
|
440
|
+
"underline": true,
|
|
441
|
+
},
|
|
442
|
+
"type": "text_decoration",
|
|
443
|
+
},
|
|
444
|
+
],
|
|
445
|
+
"text": "lorem",
|
|
446
|
+
"type": "text",
|
|
447
|
+
},
|
|
448
|
+
Object {
|
|
449
|
+
"text": " ipsum",
|
|
450
|
+
"type": "text",
|
|
451
|
+
},
|
|
452
|
+
],
|
|
453
|
+
"type": "paragraph",
|
|
454
|
+
},
|
|
455
|
+
],
|
|
456
|
+
"type": "doc",
|
|
457
|
+
}
|
|
458
|
+
`;
|
|
459
|
+
|
|
460
|
+
exports[`parsing html should merge paragraph and text settings 1`] = `
|
|
461
|
+
Object {
|
|
462
|
+
"content": Array [
|
|
463
|
+
Object {
|
|
464
|
+
"content": Array [
|
|
465
|
+
Object {
|
|
466
|
+
"marks": Array [
|
|
467
|
+
Object {
|
|
468
|
+
"attrs": Object {
|
|
469
|
+
"strike_through": true,
|
|
470
|
+
"underline": false,
|
|
471
|
+
},
|
|
472
|
+
"type": "text_decoration",
|
|
473
|
+
},
|
|
474
|
+
],
|
|
475
|
+
"text": "lorem",
|
|
476
|
+
"type": "text",
|
|
477
|
+
},
|
|
478
|
+
Object {
|
|
479
|
+
"marks": Array [
|
|
480
|
+
Object {
|
|
481
|
+
"attrs": Object {
|
|
482
|
+
"strike_through": false,
|
|
483
|
+
"underline": true,
|
|
484
|
+
},
|
|
485
|
+
"type": "text_decoration",
|
|
486
|
+
},
|
|
487
|
+
],
|
|
488
|
+
"text": " ipsum",
|
|
489
|
+
"type": "text",
|
|
490
|
+
},
|
|
491
|
+
],
|
|
492
|
+
"type": "paragraph",
|
|
493
|
+
},
|
|
494
|
+
],
|
|
495
|
+
"type": "doc",
|
|
496
|
+
}
|
|
497
|
+
`;
|
|
498
|
+
|
|
499
|
+
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>"`;
|
|
203
500
|
|
|
204
|
-
exports[`rendering should render strike through only 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-text-decoration:
|
|
501
|
+
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>"`;
|
|
205
502
|
|
|
206
|
-
exports[`rendering should render underline only 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-text-decoration:
|
|
503
|
+
exports[`rendering should render underline only 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-text-decoration:underline;\\" class=\\"zw-style\\">hello world</span></p>"`;
|
|
@@ -17,6 +17,16 @@ export const TextProcessor = Extension.create({
|
|
|
17
17
|
|
|
18
18
|
addCommands() {
|
|
19
19
|
return {
|
|
20
|
+
getSelectedText: createCommand(({ state }) => {
|
|
21
|
+
const { from, to } = state.selection;
|
|
22
|
+
|
|
23
|
+
return state.doc.textBetween(from, to, ' ');
|
|
24
|
+
}),
|
|
25
|
+
|
|
26
|
+
unsetMarks: createCommand(({ commands }, marks) => {
|
|
27
|
+
marks.forEach((mark) => commands.unsetMark(mark));
|
|
28
|
+
}),
|
|
29
|
+
|
|
20
30
|
transformText: createCommand(({ state }, transform) => {
|
|
21
31
|
const { selection } = state.tr;
|
|
22
32
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Editor, Extension } from '@tiptap/vue-2';
|
|
2
2
|
import { NodeFactory } from '../../../__tests__/utils';
|
|
3
|
-
import { CORE_EXTENSIONS } from '../index';
|
|
4
3
|
import { NodeTypes } from '../../../enums';
|
|
4
|
+
import { ContentNormalizer } from '../../../services';
|
|
5
|
+
import { buildCoreExtensions } from '../index';
|
|
5
6
|
|
|
6
7
|
const LineHeight = Extension.create({
|
|
7
8
|
name: 'line_height',
|
|
@@ -21,8 +22,8 @@ const LineHeight = Extension.create({
|
|
|
21
22
|
|
|
22
23
|
function createEditor({ content }) {
|
|
23
24
|
return new Editor({
|
|
24
|
-
content,
|
|
25
|
-
extensions:
|
|
25
|
+
content: ContentNormalizer.normalize(content),
|
|
26
|
+
extensions: buildCoreExtensions().concat(LineHeight) // Included to core extensions
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Editor } from '@tiptap/vue-2';
|
|
2
|
-
import { CORE_EXTENSIONS } from '../index';
|
|
3
2
|
import { NodeFactory } from '../../../__tests__/utils';
|
|
3
|
+
import { ContentNormalizer } from '../../../services';
|
|
4
|
+
import { buildCoreExtensions } from '../index';
|
|
4
5
|
|
|
5
6
|
function createEditor() {
|
|
7
|
+
const content = NodeFactory.doc([
|
|
8
|
+
NodeFactory.paragraph('Lorem ipsum dolor sit amet'),
|
|
9
|
+
NodeFactory.paragraph('consectetur adipisicing elit')
|
|
10
|
+
]);
|
|
11
|
+
|
|
6
12
|
return new Editor({
|
|
7
|
-
content:
|
|
8
|
-
|
|
9
|
-
NodeFactory.paragraph('consectetur adipisicing elit')
|
|
10
|
-
]),
|
|
11
|
-
extensions: CORE_EXTENSIONS // included to core
|
|
13
|
+
content: ContentNormalizer.normalize(content),
|
|
14
|
+
extensions: buildCoreExtensions() // included to core
|
|
12
15
|
});
|
|
13
16
|
}
|
|
14
17
|
|