@zipify/wysiwyg 4.0.0 → 4.0.2

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.
Files changed (26) hide show
  1. package/README.md +5 -0
  2. package/dist/cli.js +2 -2
  3. package/dist/wysiwyg.mjs +42 -0
  4. package/example/ai-component/AiComponent.vue +14 -0
  5. package/lib/composables/__tests__/__snapshots__/useEditor.test.js.snap +3 -0
  6. package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +15 -0
  7. package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +15 -0
  8. package/lib/extensions/__tests__/__snapshots__/CaseStyle.test.js.snap +12 -0
  9. package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +15 -0
  10. package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +33 -0
  11. package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +27 -0
  12. package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +27 -0
  13. package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +39 -0
  14. package/lib/extensions/__tests__/__snapshots__/LineHeight.test.js.snap +18 -0
  15. package/lib/extensions/__tests__/__snapshots__/Link.test.js.snap +30 -0
  16. package/lib/extensions/__tests__/__snapshots__/Margin.test.js.snap +9 -0
  17. package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +45 -0
  18. package/lib/extensions/__tests__/__snapshots__/Superscript.test.js.snap +15 -0
  19. package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +63 -0
  20. package/lib/extensions/core/Document.js +14 -0
  21. package/lib/extensions/core/__tests__/__snapshots__/NodeProcessor.test.js.snap +57 -0
  22. package/lib/extensions/core/__tests__/__snapshots__/TextProcessor.test.js.snap +6 -0
  23. package/lib/extensions/list/__tests__/__snapshots__/List.test.js.snap +54 -0
  24. package/lib/extensions/steps/SetDocAttr.js +42 -0
  25. package/lib/extensions/steps/index.js +1 -0
  26. package/package.json +2 -2
@@ -2,6 +2,9 @@
2
2
 
3
3
  exports[`apply value should change value 1`] = `
4
4
  Object {
5
+ "attrs": Object {
6
+ "meta": Object {},
7
+ },
5
8
  "content": Array [
6
9
  Object {
7
10
  "attrs": Object {
@@ -26,6 +29,9 @@ Object {
26
29
 
27
30
  exports[`parsing html should get value from rendered view 1`] = `
28
31
  Object {
32
+ "attrs": Object {
33
+ "meta": Object {},
34
+ },
29
35
  "content": Array [
30
36
  Object {
31
37
  "attrs": Object {
@@ -50,6 +56,9 @@ Object {
50
56
 
51
57
  exports[`parsing html should get value from text in px units with font size 1`] = `
52
58
  Object {
59
+ "attrs": Object {
60
+ "meta": Object {},
61
+ },
53
62
  "content": Array [
54
63
  Object {
55
64
  "attrs": Object {
@@ -74,6 +83,9 @@ Object {
74
83
 
75
84
  exports[`parsing html should get value from text in px units with no font size 1`] = `
76
85
  Object {
86
+ "attrs": Object {
87
+ "meta": Object {},
88
+ },
77
89
  "content": Array [
78
90
  Object {
79
91
  "attrs": Object {
@@ -98,6 +110,9 @@ Object {
98
110
 
99
111
  exports[`parsing html should get value from text in relative units 1`] = `
100
112
  Object {
113
+ "attrs": Object {
114
+ "meta": Object {},
115
+ },
101
116
  "content": Array [
102
117
  Object {
103
118
  "attrs": Object {
@@ -122,6 +137,9 @@ Object {
122
137
 
123
138
  exports[`parsing html should set null if no alignment 1`] = `
124
139
  Object {
140
+ "attrs": Object {
141
+ "meta": Object {},
142
+ },
125
143
  "content": Array [
126
144
  Object {
127
145
  "attrs": Object {
@@ -2,6 +2,9 @@
2
2
 
3
3
  exports[`apply link should apply link 1`] = `
4
4
  Object {
5
+ "attrs": Object {
6
+ "meta": Object {},
7
+ },
5
8
  "content": Array [
6
9
  Object {
7
10
  "content": Array [
@@ -29,6 +32,9 @@ Object {
29
32
 
30
33
  exports[`apply link should apply link to multiple selected nodes 1`] = `
31
34
  Object {
35
+ "attrs": Object {
36
+ "meta": Object {},
37
+ },
32
38
  "content": Array [
33
39
  Object {
34
40
  "content": Array [
@@ -62,6 +68,9 @@ Object {
62
68
 
63
69
  exports[`apply link should apply link to text with link 1`] = `
64
70
  Object {
71
+ "attrs": Object {
72
+ "meta": Object {},
73
+ },
65
74
  "content": Array [
66
75
  Object {
67
76
  "content": Array [
@@ -89,6 +98,9 @@ Object {
89
98
 
90
99
  exports[`apply link should apply link when no selected text 1`] = `
91
100
  Object {
101
+ "attrs": Object {
102
+ "meta": Object {},
103
+ },
92
104
  "content": Array [
93
105
  Object {
94
106
  "content": Array [
@@ -124,6 +136,9 @@ Object {
124
136
 
125
137
  exports[`parse html should add default self target for links from html without target 1`] = `
126
138
  Object {
139
+ "attrs": Object {
140
+ "meta": Object {},
141
+ },
127
142
  "content": Array [
128
143
  Object {
129
144
  "content": Array [
@@ -151,6 +166,9 @@ Object {
151
166
 
152
167
  exports[`parse html should parse block links from html 1`] = `
153
168
  Object {
169
+ "attrs": Object {
170
+ "meta": Object {},
171
+ },
154
172
  "content": Array [
155
173
  Object {
156
174
  "content": Array [
@@ -178,6 +196,9 @@ Object {
178
196
 
179
197
  exports[`parse html should parse link target 1`] = `
180
198
  Object {
199
+ "attrs": Object {
200
+ "meta": Object {},
201
+ },
181
202
  "content": Array [
182
203
  Object {
183
204
  "content": Array [
@@ -205,6 +226,9 @@ Object {
205
226
 
206
227
  exports[`parse html should parse not valid value 1`] = `
207
228
  Object {
229
+ "attrs": Object {
230
+ "meta": Object {},
231
+ },
208
232
  "content": Array [
209
233
  Object {
210
234
  "content": Array [
@@ -232,6 +256,9 @@ Object {
232
256
 
233
257
  exports[`parse html should parse url links from html 1`] = `
234
258
  Object {
259
+ "attrs": Object {
260
+ "meta": Object {},
261
+ },
235
262
  "content": Array [
236
263
  Object {
237
264
  "content": Array [
@@ -259,6 +286,9 @@ Object {
259
286
 
260
287
  exports[`parse html should parse value for relative url 1`] = `
261
288
  Object {
289
+ "attrs": Object {
290
+ "meta": Object {},
291
+ },
262
292
  "content": Array [
263
293
  Object {
264
294
  "content": Array [
@@ -2,6 +2,9 @@
2
2
 
3
3
  exports[`parse html should parse shorthand 1`] = `
4
4
  Object {
5
+ "attrs": Object {
6
+ "meta": Object {},
7
+ },
5
8
  "content": Array [
6
9
  Object {
7
10
  "attrs": Object {
@@ -24,6 +27,9 @@ Object {
24
27
 
25
28
  exports[`parse html should parse values 1`] = `
26
29
  Object {
30
+ "attrs": Object {
31
+ "meta": Object {},
32
+ },
27
33
  "content": Array [
28
34
  Object {
29
35
  "attrs": Object {
@@ -46,6 +52,9 @@ Object {
46
52
 
47
53
  exports[`parse html should set null if no margin 1`] = `
48
54
  Object {
55
+ "attrs": Object {
56
+ "meta": Object {},
57
+ },
49
58
  "content": Array [
50
59
  Object {
51
60
  "attrs": Object {
@@ -2,6 +2,9 @@
2
2
 
3
3
  exports[`apply preset should apply default preset 1`] = `
4
4
  Object {
5
+ "attrs": Object {
6
+ "meta": Object {},
7
+ },
5
8
  "content": Array [
6
9
  Object {
7
10
  "attrs": Object {
@@ -25,6 +28,9 @@ Object {
25
28
 
26
29
  exports[`apply preset should apply heading to list 1`] = `
27
30
  Object {
31
+ "attrs": Object {
32
+ "meta": Object {},
33
+ },
28
34
  "content": Array [
29
35
  Object {
30
36
  "attrs": Object {
@@ -63,6 +69,9 @@ Object {
63
69
 
64
70
  exports[`apply preset should apply heading to text 1`] = `
65
71
  Object {
72
+ "attrs": Object {
73
+ "meta": Object {},
74
+ },
66
75
  "content": Array [
67
76
  Object {
68
77
  "attrs": Object {
@@ -86,6 +95,9 @@ Object {
86
95
 
87
96
  exports[`apply preset should apply preset to text 1`] = `
88
97
  Object {
98
+ "attrs": Object {
99
+ "meta": Object {},
100
+ },
89
101
  "content": Array [
90
102
  Object {
91
103
  "attrs": Object {
@@ -109,6 +121,9 @@ Object {
109
121
 
110
122
  exports[`apply preset should apply regular to list 1`] = `
111
123
  Object {
124
+ "attrs": Object {
125
+ "meta": Object {},
126
+ },
112
127
  "content": Array [
113
128
  Object {
114
129
  "attrs": Object {
@@ -147,6 +162,9 @@ Object {
147
162
 
148
163
  exports[`apply preset should change paragraph to heading 1`] = `
149
164
  Object {
165
+ "attrs": Object {
166
+ "meta": Object {},
167
+ },
150
168
  "content": Array [
151
169
  Object {
152
170
  "attrs": Object {
@@ -170,6 +188,9 @@ Object {
170
188
 
171
189
  exports[`apply preset should keep text attributes on apply 1`] = `
172
190
  Object {
191
+ "attrs": Object {
192
+ "meta": Object {},
193
+ },
173
194
  "content": Array [
174
195
  Object {
175
196
  "attrs": Object {
@@ -285,6 +306,9 @@ Object {
285
306
 
286
307
  exports[`parsing html should get by fallback class 1`] = `
287
308
  Object {
309
+ "attrs": Object {
310
+ "meta": Object {},
311
+ },
288
312
  "content": Array [
289
313
  Object {
290
314
  "attrs": Object {
@@ -308,6 +332,9 @@ Object {
308
332
 
309
333
  exports[`parsing html should get by heading tag 1`] = `
310
334
  Object {
335
+ "attrs": Object {
336
+ "meta": Object {},
337
+ },
311
338
  "content": Array [
312
339
  Object {
313
340
  "attrs": Object {
@@ -331,6 +358,9 @@ Object {
331
358
 
332
359
  exports[`parsing html should get by preset class 1`] = `
333
360
  Object {
361
+ "attrs": Object {
362
+ "meta": Object {},
363
+ },
334
364
  "content": Array [
335
365
  Object {
336
366
  "attrs": Object {
@@ -354,6 +384,9 @@ Object {
354
384
 
355
385
  exports[`parsing html should set default preset to unstyled paragraph 1`] = `
356
386
  Object {
387
+ "attrs": Object {
388
+ "meta": Object {},
389
+ },
357
390
  "content": Array [
358
391
  Object {
359
392
  "attrs": Object {
@@ -377,6 +410,9 @@ Object {
377
410
 
378
411
  exports[`parsing html should set null to list item 1`] = `
379
412
  Object {
413
+ "attrs": Object {
414
+ "meta": Object {},
415
+ },
380
416
  "content": Array [
381
417
  Object {
382
418
  "attrs": Object {
@@ -415,6 +451,9 @@ Object {
415
451
 
416
452
  exports[`parsing html should set null to list item with preset 1`] = `
417
453
  Object {
454
+ "attrs": Object {
455
+ "meta": Object {},
456
+ },
418
457
  "content": Array [
419
458
  Object {
420
459
  "attrs": Object {
@@ -453,6 +492,9 @@ Object {
453
492
 
454
493
  exports[`remove preset customization should remove all attributes 1`] = `
455
494
  Object {
495
+ "attrs": Object {
496
+ "meta": Object {},
497
+ },
456
498
  "content": Array [
457
499
  Object {
458
500
  "attrs": Object {
@@ -491,6 +533,9 @@ Object {
491
533
 
492
534
  exports[`remove preset customization should remove all marks in block 1`] = `
493
535
  Object {
536
+ "attrs": Object {
537
+ "meta": Object {},
538
+ },
494
539
  "content": Array [
495
540
  Object {
496
541
  "attrs": Object {
@@ -2,6 +2,9 @@
2
2
 
3
3
  exports[`apply value should apply superscript 1`] = `
4
4
  Object {
5
+ "attrs": Object {
6
+ "meta": Object {},
7
+ },
5
8
  "content": Array [
6
9
  Object {
7
10
  "content": Array [
@@ -24,6 +27,9 @@ Object {
24
27
 
25
28
  exports[`apply value should remove superscript 1`] = `
26
29
  Object {
30
+ "attrs": Object {
31
+ "meta": Object {},
32
+ },
27
33
  "content": Array [
28
34
  Object {
29
35
  "content": Array [
@@ -41,6 +47,9 @@ Object {
41
47
 
42
48
  exports[`apply value should toggle superscript to enabled 1`] = `
43
49
  Object {
50
+ "attrs": Object {
51
+ "meta": Object {},
52
+ },
44
53
  "content": Array [
45
54
  Object {
46
55
  "content": Array [
@@ -63,6 +72,9 @@ Object {
63
72
 
64
73
  exports[`apply value should toggle superscript to removed 1`] = `
65
74
  Object {
75
+ "attrs": Object {
76
+ "meta": Object {},
77
+ },
66
78
  "content": Array [
67
79
  Object {
68
80
  "content": Array [
@@ -80,6 +92,9 @@ Object {
80
92
 
81
93
  exports[`parsing html should get value from text 1`] = `
82
94
  Object {
95
+ "attrs": Object {
96
+ "meta": Object {},
97
+ },
83
98
  "content": Array [
84
99
  Object {
85
100
  "content": Array [
@@ -2,6 +2,9 @@
2
2
 
3
3
  exports[`apply decoration should apply decoration 1`] = `
4
4
  Object {
5
+ "attrs": Object {
6
+ "meta": Object {},
7
+ },
5
8
  "content": Array [
6
9
  Object {
7
10
  "content": Array [
@@ -28,6 +31,9 @@ Object {
28
31
 
29
32
  exports[`apply decoration should apply decoration with decorated parent false value 1`] = `
30
33
  Object {
34
+ "attrs": Object {
35
+ "meta": Object {},
36
+ },
31
37
  "content": Array [
32
38
  Object {
33
39
  "content": Array [
@@ -67,6 +73,9 @@ Object {
67
73
 
68
74
  exports[`apply decoration should not apply decoration with decorated parent 1`] = `
69
75
  Object {
76
+ "attrs": Object {
77
+ "meta": Object {},
78
+ },
70
79
  "content": Array [
71
80
  Object {
72
81
  "content": Array [
@@ -93,6 +102,9 @@ Object {
93
102
 
94
103
  exports[`apply decoration should second decoration 1`] = `
95
104
  Object {
105
+ "attrs": Object {
106
+ "meta": Object {},
107
+ },
96
108
  "content": Array [
97
109
  Object {
98
110
  "content": Array [
@@ -119,6 +131,9 @@ Object {
119
131
 
120
132
  exports[`apply decoration strike through should toggle to removed 1`] = `
121
133
  Object {
134
+ "attrs": Object {
135
+ "meta": Object {},
136
+ },
122
137
  "content": Array [
123
138
  Object {
124
139
  "content": Array [
@@ -145,6 +160,9 @@ Object {
145
160
 
146
161
  exports[`apply decoration strike through should toggle to used 1`] = `
147
162
  Object {
163
+ "attrs": Object {
164
+ "meta": Object {},
165
+ },
148
166
  "content": Array [
149
167
  Object {
150
168
  "content": Array [
@@ -171,6 +189,9 @@ Object {
171
189
 
172
190
  exports[`apply decoration underline should toggle to removed 1`] = `
173
191
  Object {
192
+ "attrs": Object {
193
+ "meta": Object {},
194
+ },
174
195
  "content": Array [
175
196
  Object {
176
197
  "content": Array [
@@ -197,6 +218,9 @@ Object {
197
218
 
198
219
  exports[`apply decoration underline should toggle to used 1`] = `
199
220
  Object {
221
+ "attrs": Object {
222
+ "meta": Object {},
223
+ },
200
224
  "content": Array [
201
225
  Object {
202
226
  "content": Array [
@@ -223,6 +247,9 @@ Object {
223
247
 
224
248
  exports[`parsing html should get both from paragraph 1`] = `
225
249
  Object {
250
+ "attrs": Object {
251
+ "meta": Object {},
252
+ },
226
253
  "content": Array [
227
254
  Object {
228
255
  "content": Array [
@@ -249,6 +276,9 @@ Object {
249
276
 
250
277
  exports[`parsing html should get both from rendered view 1`] = `
251
278
  Object {
279
+ "attrs": Object {
280
+ "meta": Object {},
281
+ },
252
282
  "content": Array [
253
283
  Object {
254
284
  "content": Array [
@@ -279,6 +309,9 @@ Object {
279
309
 
280
310
  exports[`parsing html should get both from text 1`] = `
281
311
  Object {
312
+ "attrs": Object {
313
+ "meta": Object {},
314
+ },
282
315
  "content": Array [
283
316
  Object {
284
317
  "content": Array [
@@ -309,6 +342,9 @@ Object {
309
342
 
310
343
  exports[`parsing html should get both from text with property shorthand 1`] = `
311
344
  Object {
345
+ "attrs": Object {
346
+ "meta": Object {},
347
+ },
312
348
  "content": Array [
313
349
  Object {
314
350
  "content": Array [
@@ -339,6 +375,9 @@ Object {
339
375
 
340
376
  exports[`parsing html should get strike through from paragraph 1`] = `
341
377
  Object {
378
+ "attrs": Object {
379
+ "meta": Object {},
380
+ },
342
381
  "content": Array [
343
382
  Object {
344
383
  "content": Array [
@@ -365,6 +404,9 @@ Object {
365
404
 
366
405
  exports[`parsing html should get strike through from rendered view 1`] = `
367
406
  Object {
407
+ "attrs": Object {
408
+ "meta": Object {},
409
+ },
368
410
  "content": Array [
369
411
  Object {
370
412
  "content": Array [
@@ -395,6 +437,9 @@ Object {
395
437
 
396
438
  exports[`parsing html should get strike through from text 1`] = `
397
439
  Object {
440
+ "attrs": Object {
441
+ "meta": Object {},
442
+ },
398
443
  "content": Array [
399
444
  Object {
400
445
  "content": Array [
@@ -425,6 +470,9 @@ Object {
425
470
 
426
471
  exports[`parsing html should get underline from paragraph 1`] = `
427
472
  Object {
473
+ "attrs": Object {
474
+ "meta": Object {},
475
+ },
428
476
  "content": Array [
429
477
  Object {
430
478
  "content": Array [
@@ -451,6 +499,9 @@ Object {
451
499
 
452
500
  exports[`parsing html should get underline from rendered view 1`] = `
453
501
  Object {
502
+ "attrs": Object {
503
+ "meta": Object {},
504
+ },
454
505
  "content": Array [
455
506
  Object {
456
507
  "content": Array [
@@ -481,6 +532,9 @@ Object {
481
532
 
482
533
  exports[`parsing html should get underline from text 1`] = `
483
534
  Object {
535
+ "attrs": Object {
536
+ "meta": Object {},
537
+ },
484
538
  "content": Array [
485
539
  Object {
486
540
  "content": Array [
@@ -511,6 +565,9 @@ Object {
511
565
 
512
566
  exports[`parsing html should merge paragraph and text settings 1`] = `
513
567
  Object {
568
+ "attrs": Object {
569
+ "meta": Object {},
570
+ },
514
571
  "content": Array [
515
572
  Object {
516
573
  "content": Array [
@@ -550,6 +607,9 @@ Object {
550
607
 
551
608
  exports[`parsing html should parse strike through from tag 1`] = `
552
609
  Object {
610
+ "attrs": Object {
611
+ "meta": Object {},
612
+ },
553
613
  "content": Array [
554
614
  Object {
555
615
  "content": Array [
@@ -580,6 +640,9 @@ Object {
580
640
 
581
641
  exports[`parsing html should parse underline from tag 1`] = `
582
642
  Object {
643
+ "attrs": Object {
644
+ "meta": Object {},
645
+ },
583
646
  "content": Array [
584
647
  Object {
585
648
  "content": Array [
@@ -1,13 +1,27 @@
1
1
  import { Document as Base } from '@tiptap/extension-document';
2
2
  import { MarkGroups } from '../../enums';
3
+ import { createCommand } from '../../utils';
4
+ import { SetDocAttr } from '../steps';
3
5
 
4
6
  export const Document = Base.extend({
5
7
  marks: MarkGroups.SETTINGS,
6
8
 
9
+ addAttributes: () => ({
10
+ meta: { default: {} }
11
+ }),
12
+
7
13
  onCreate() {
8
14
  // Prevent open links in new tab when editor is readonly
9
15
  this.editor.view.dom.addEventListener('click', (event) => {
10
16
  if (event.target.closest('a')) event.preventDefault();
11
17
  });
18
+ },
19
+
20
+ addCommands() {
21
+ return {
22
+ setDocMetaAttributes: createCommand(({ state }, key, value) => {
23
+ state.tr.step(new SetDocAttr(key, value, state.schema));
24
+ })
25
+ };
12
26
  }
13
27
  });