@zipify/wysiwyg 4.0.1 → 4.0.3

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 (27) hide show
  1. package/README.md +5 -0
  2. package/dist/cli.js +2 -2
  3. package/dist/wysiwyg.mjs +44 -4
  4. package/example/ai-component/AiComponent.vue +14 -0
  5. package/lib/components/toolbar/controls/ItalicControl.vue +2 -4
  6. package/lib/composables/__tests__/__snapshots__/useEditor.test.js.snap +3 -0
  7. package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +15 -0
  8. package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +15 -0
  9. package/lib/extensions/__tests__/__snapshots__/CaseStyle.test.js.snap +12 -0
  10. package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +15 -0
  11. package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +33 -0
  12. package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +27 -0
  13. package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +27 -0
  14. package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +39 -0
  15. package/lib/extensions/__tests__/__snapshots__/LineHeight.test.js.snap +18 -0
  16. package/lib/extensions/__tests__/__snapshots__/Link.test.js.snap +30 -0
  17. package/lib/extensions/__tests__/__snapshots__/Margin.test.js.snap +9 -0
  18. package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +45 -0
  19. package/lib/extensions/__tests__/__snapshots__/Superscript.test.js.snap +15 -0
  20. package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +63 -0
  21. package/lib/extensions/core/Document.js +14 -0
  22. package/lib/extensions/core/__tests__/__snapshots__/NodeProcessor.test.js.snap +57 -0
  23. package/lib/extensions/core/__tests__/__snapshots__/TextProcessor.test.js.snap +6 -0
  24. package/lib/extensions/list/__tests__/__snapshots__/List.test.js.snap +54 -0
  25. package/lib/extensions/steps/SetDocAttr.js +42 -0
  26. package/lib/extensions/steps/index.js +1 -0
  27. package/package.json +1 -1
package/dist/wysiwyg.mjs CHANGED
@@ -21305,13 +21305,55 @@ const Document$1 = Node2.create({
21305
21305
  topNode: true,
21306
21306
  content: "block+"
21307
21307
  });
21308
+ class SetDocAttr extends Step {
21309
+ constructor(key, value, schema, stepType = "SetDocAttr") {
21310
+ super();
21311
+ this.key = key;
21312
+ this.value = value;
21313
+ this.schema = schema;
21314
+ this.stepType = stepType;
21315
+ }
21316
+ apply(doc2) {
21317
+ this.prevValue = doc2.attrs.meta[this.key];
21318
+ const newDoc = Node$1.fromJSON(this.schema, doc2.toJSON());
21319
+ newDoc.attrs.meta[this.key] = this.value;
21320
+ return StepResult.ok(newDoc);
21321
+ }
21322
+ invert() {
21323
+ return new SetDocAttr(this.key, this.prevValue, this.schema, "revertSetDocAttr");
21324
+ }
21325
+ map() {
21326
+ return null;
21327
+ }
21328
+ toJSON() {
21329
+ return {
21330
+ stepType: this.stepType,
21331
+ key: this.key,
21332
+ value: this.value
21333
+ };
21334
+ }
21335
+ static fromJSON(json) {
21336
+ return new SetDocAttr(json.key, json.value, json.stepType);
21337
+ }
21338
+ }
21339
+ Step.jsonID("setDocAttr", SetDocAttr);
21308
21340
  const Document = Document$1.extend({
21309
21341
  marks: MarkGroups.SETTINGS,
21342
+ addAttributes: () => ({
21343
+ meta: { default: {} }
21344
+ }),
21310
21345
  onCreate() {
21311
21346
  this.editor.view.dom.addEventListener("click", (event) => {
21312
21347
  if (event.target.closest("a"))
21313
21348
  event.preventDefault();
21314
21349
  });
21350
+ },
21351
+ addCommands() {
21352
+ return {
21353
+ setDocMetaAttributes: createCommand(({ state }, key, value) => {
21354
+ state.tr.step(new SetDocAttr(key, value, state.schema));
21355
+ })
21356
+ };
21315
21357
  }
21316
21358
  });
21317
21359
  const Paragraph$1 = Node2.create({
@@ -26354,9 +26396,7 @@ const _sfc_main$k = {
26354
26396
  const editor = inject(InjectionTokens$1.EDITOR);
26355
26397
  const currentValue = editor.commands.isItalic();
26356
26398
  const isAvailable = editor.commands.isItalicAvailable();
26357
- const isCustomized = computed(() => {
26358
- return editor.commands.isSettingCustomized(TextSettings.FONT_STYLE).value;
26359
- });
26399
+ const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_STYLE);
26360
26400
  const apply2 = () => editor.chain().focus().toggleItalic().run();
26361
26401
  return (_ctx, _cache) => {
26362
26402
  return withDirectives((openBlock(), createBlock(unref(Button), {
@@ -26373,7 +26413,7 @@ const _sfc_main$k = {
26373
26413
  size: "28px",
26374
26414
  "auto-color": ""
26375
26415
  }),
26376
- isCustomized.value ? withDirectives((openBlock(), createElementBlock("span", _hoisted_1$7, null, 512)), [
26416
+ unref(isCustomized) ? withDirectives((openBlock(), createElementBlock("span", _hoisted_1$7, null, 512)), [
26377
26417
  [
26378
26418
  unref(tooltip),
26379
26419
  "Style differs from Page Styles",
@@ -7,6 +7,10 @@
7
7
 
8
8
  <Modal ref="modalRef" class="zw-ai-component__modal" :toggler="toggler" focus-first-control>
9
9
  <p>Modal content</p>
10
+
11
+ <Button skin="primary" @click="onInsert">
12
+ Insert Content
13
+ </Button>
10
14
  </Modal>
11
15
  </div>
12
16
  </template>
@@ -43,6 +47,15 @@ export default {
43
47
  modalRef
44
48
  });
45
49
 
50
+ const onInsert = () => {
51
+ editor.chain()
52
+ .focus()
53
+ .insertContent('Hello from AI component')
54
+ .setDocMeta('ai_generated', true)
55
+ .run();
56
+ toggler.close();
57
+ };
58
+
46
59
  const isActive = computed(() => unref(toggler.isOpened));
47
60
 
48
61
  return {
@@ -50,6 +63,7 @@ export default {
50
63
  wrapperRef,
51
64
  modalRef,
52
65
  toggler,
66
+ onInsert,
53
67
  isActive
54
68
  };
55
69
  }
@@ -20,7 +20,7 @@
20
20
  </template>
21
21
 
22
22
  <script setup>
23
- import { inject, computed } from 'vue';
23
+ import { inject } from 'vue';
24
24
  import { Button, Icon } from '../../base';
25
25
  import { InjectionTokens } from '../../../injectionTokens';
26
26
  import { tooltip as vTooltip } from '../../../directives';
@@ -30,9 +30,7 @@ const editor = inject(InjectionTokens.EDITOR);
30
30
 
31
31
  const currentValue = editor.commands.isItalic();
32
32
  const isAvailable = editor.commands.isItalicAvailable();
33
- const isCustomized = computed(() => {
34
- return editor.commands.isSettingCustomized(TextSettings.FONT_STYLE).value;
35
- });
33
+ const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_STYLE);
36
34
  const apply = () => editor.chain().focus().toggleItalic().run();
37
35
  </script>
38
36
 
@@ -5,6 +5,9 @@ Array [
5
5
  Array [
6
6
  Object {
7
7
  "__wswg__": true,
8
+ "attrs": Object {
9
+ "meta": Object {},
10
+ },
8
11
  "content": Array [
9
12
  Object {
10
13
  "content": Array [
@@ -2,6 +2,9 @@
2
2
 
3
3
  exports[`change value should apply 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[`change value should remove value 1`] = `
28
31
  Object {
32
+ "attrs": Object {
33
+ "meta": Object {},
34
+ },
29
35
  "content": Array [
30
36
  Object {
31
37
  "attrs": Object {
@@ -46,6 +52,9 @@ Object {
46
52
 
47
53
  exports[`parsing html should get alignment from rendered view 1`] = `
48
54
  Object {
55
+ "attrs": Object {
56
+ "meta": Object {},
57
+ },
49
58
  "content": Array [
50
59
  Object {
51
60
  "attrs": Object {
@@ -70,6 +79,9 @@ Object {
70
79
 
71
80
  exports[`parsing html should get alignment from text 1`] = `
72
81
  Object {
82
+ "attrs": Object {
83
+ "meta": Object {},
84
+ },
73
85
  "content": Array [
74
86
  Object {
75
87
  "attrs": Object {
@@ -94,6 +106,9 @@ Object {
94
106
 
95
107
  exports[`parsing html should set null if no alignment 1`] = `
96
108
  Object {
109
+ "attrs": Object {
110
+ "meta": Object {},
111
+ },
97
112
  "content": Array [
98
113
  Object {
99
114
  "attrs": Object {
@@ -2,6 +2,9 @@
2
2
 
3
3
  exports[`apply background color should change background color 1`] = `
4
4
  Object {
5
+ "attrs": Object {
6
+ "meta": Object {},
7
+ },
5
8
  "content": Array [
6
9
  Object {
7
10
  "content": Array [
@@ -27,6 +30,9 @@ Object {
27
30
 
28
31
  exports[`parsing html should get value from paragraph 1`] = `
29
32
  Object {
33
+ "attrs": Object {
34
+ "meta": Object {},
35
+ },
30
36
  "content": Array [
31
37
  Object {
32
38
  "content": Array [
@@ -52,6 +58,9 @@ Object {
52
58
 
53
59
  exports[`parsing html should get value from rendered view 1`] = `
54
60
  Object {
61
+ "attrs": Object {
62
+ "meta": Object {},
63
+ },
55
64
  "content": Array [
56
65
  Object {
57
66
  "content": Array [
@@ -81,6 +90,9 @@ Object {
81
90
 
82
91
  exports[`parsing html should get value from text 1`] = `
83
92
  Object {
93
+ "attrs": Object {
94
+ "meta": Object {},
95
+ },
84
96
  "content": Array [
85
97
  Object {
86
98
  "content": Array [
@@ -110,6 +122,9 @@ Object {
110
122
 
111
123
  exports[`parsing html should merge paragraph and text settings 1`] = `
112
124
  Object {
125
+ "attrs": Object {
126
+ "meta": Object {},
127
+ },
113
128
  "content": Array [
114
129
  Object {
115
130
  "content": Array [
@@ -2,6 +2,9 @@
2
2
 
3
3
  exports[`apply case style should apply capitalize 1`] = `
4
4
  Object {
5
+ "attrs": Object {
6
+ "meta": Object {},
7
+ },
5
8
  "content": Array [
6
9
  Object {
7
10
  "content": Array [
@@ -19,6 +22,9 @@ Object {
19
22
 
20
23
  exports[`apply case style should apply case by type 1`] = `
21
24
  Object {
25
+ "attrs": Object {
26
+ "meta": Object {},
27
+ },
22
28
  "content": Array [
23
29
  Object {
24
30
  "content": Array [
@@ -36,6 +42,9 @@ Object {
36
42
 
37
43
  exports[`apply case style should apply lowercase 1`] = `
38
44
  Object {
45
+ "attrs": Object {
46
+ "meta": Object {},
47
+ },
39
48
  "content": Array [
40
49
  Object {
41
50
  "content": Array [
@@ -53,6 +62,9 @@ Object {
53
62
 
54
63
  exports[`apply case style should apply uppercase 1`] = `
55
64
  Object {
65
+ "attrs": Object {
66
+ "meta": Object {},
67
+ },
56
68
  "content": Array [
57
69
  Object {
58
70
  "content": Array [
@@ -2,6 +2,9 @@
2
2
 
3
3
  exports[`apply font color should change font color 1`] = `
4
4
  Object {
5
+ "attrs": Object {
6
+ "meta": Object {},
7
+ },
5
8
  "content": Array [
6
9
  Object {
7
10
  "content": Array [
@@ -27,6 +30,9 @@ Object {
27
30
 
28
31
  exports[`parsing html should get value from paragraph 1`] = `
29
32
  Object {
33
+ "attrs": Object {
34
+ "meta": Object {},
35
+ },
30
36
  "content": Array [
31
37
  Object {
32
38
  "content": Array [
@@ -52,6 +58,9 @@ Object {
52
58
 
53
59
  exports[`parsing html should get value from parsed view 1`] = `
54
60
  Object {
61
+ "attrs": Object {
62
+ "meta": Object {},
63
+ },
55
64
  "content": Array [
56
65
  Object {
57
66
  "content": Array [
@@ -69,6 +78,9 @@ Object {
69
78
 
70
79
  exports[`parsing html should get value from text 1`] = `
71
80
  Object {
81
+ "attrs": Object {
82
+ "meta": Object {},
83
+ },
72
84
  "content": Array [
73
85
  Object {
74
86
  "content": Array [
@@ -98,6 +110,9 @@ Object {
98
110
 
99
111
  exports[`parsing html should merge paragraph and text settings 1`] = `
100
112
  Object {
113
+ "attrs": Object {
114
+ "meta": Object {},
115
+ },
101
116
  "content": Array [
102
117
  Object {
103
118
  "content": Array [
@@ -2,6 +2,9 @@
2
2
 
3
3
  exports[`apply font family should apply closest font weight if current is unavailable 1`] = `
4
4
  Object {
5
+ "attrs": Object {
6
+ "meta": Object {},
7
+ },
5
8
  "content": Array [
6
9
  Object {
7
10
  "content": Array [
@@ -39,6 +42,9 @@ Object {
39
42
 
40
43
  exports[`apply font family should change font family 1`] = `
41
44
  Object {
45
+ "attrs": Object {
46
+ "meta": Object {},
47
+ },
42
48
  "content": Array [
43
49
  Object {
44
50
  "content": Array [
@@ -70,6 +76,9 @@ Object {
70
76
 
71
77
  exports[`apply font family should not change current font weight if available 1`] = `
72
78
  Object {
79
+ "attrs": Object {
80
+ "meta": Object {},
81
+ },
73
82
  "content": Array [
74
83
  Object {
75
84
  "content": Array [
@@ -101,6 +110,9 @@ Object {
101
110
 
102
111
  exports[`apply font family should not change italic if available 1`] = `
103
112
  Object {
113
+ "attrs": Object {
114
+ "meta": Object {},
115
+ },
104
116
  "content": Array [
105
117
  Object {
106
118
  "content": Array [
@@ -138,6 +150,9 @@ Object {
138
150
 
139
151
  exports[`apply font family should remove italic if unavailable 1`] = `
140
152
  Object {
153
+ "attrs": Object {
154
+ "meta": Object {},
155
+ },
141
156
  "content": Array [
142
157
  Object {
143
158
  "content": Array [
@@ -175,6 +190,9 @@ Object {
175
190
 
176
191
  exports[`parsing html should get parse font name with quotes 1`] = `
177
192
  Object {
193
+ "attrs": Object {
194
+ "meta": Object {},
195
+ },
178
196
  "content": Array [
179
197
  Object {
180
198
  "content": Array [
@@ -204,6 +222,9 @@ Object {
204
222
 
205
223
  exports[`parsing html should get set default if undefined font 1`] = `
206
224
  Object {
225
+ "attrs": Object {
226
+ "meta": Object {},
227
+ },
207
228
  "content": Array [
208
229
  Object {
209
230
  "content": Array [
@@ -233,6 +254,9 @@ Object {
233
254
 
234
255
  exports[`parsing html should get value from paragraph 1`] = `
235
256
  Object {
257
+ "attrs": Object {
258
+ "meta": Object {},
259
+ },
236
260
  "content": Array [
237
261
  Object {
238
262
  "content": Array [
@@ -258,6 +282,9 @@ Object {
258
282
 
259
283
  exports[`parsing html should get value from rendered view 1`] = `
260
284
  Object {
285
+ "attrs": Object {
286
+ "meta": Object {},
287
+ },
261
288
  "content": Array [
262
289
  Object {
263
290
  "content": Array [
@@ -287,6 +314,9 @@ Object {
287
314
 
288
315
  exports[`parsing html should get value from text 1`] = `
289
316
  Object {
317
+ "attrs": Object {
318
+ "meta": Object {},
319
+ },
290
320
  "content": Array [
291
321
  Object {
292
322
  "content": Array [
@@ -316,6 +346,9 @@ Object {
316
346
 
317
347
  exports[`parsing html should merge paragraph and text settings 1`] = `
318
348
  Object {
349
+ "attrs": Object {
350
+ "meta": Object {},
351
+ },
319
352
  "content": Array [
320
353
  Object {
321
354
  "content": Array [
@@ -2,6 +2,9 @@
2
2
 
3
3
  exports[`apply font size should change font size 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 font size should decrease font size 1`] = `
31
34
  Object {
35
+ "attrs": Object {
36
+ "meta": Object {},
37
+ },
32
38
  "content": Array [
33
39
  Object {
34
40
  "content": Array [
@@ -56,6 +62,9 @@ Object {
56
62
 
57
63
  exports[`apply font size should increase font size 1`] = `
58
64
  Object {
65
+ "attrs": Object {
66
+ "meta": Object {},
67
+ },
59
68
  "content": Array [
60
69
  Object {
61
70
  "content": Array [
@@ -83,6 +92,9 @@ Object {
83
92
 
84
93
  exports[`apply font size should not decrease font size if reached limit 1`] = `
85
94
  Object {
95
+ "attrs": Object {
96
+ "meta": Object {},
97
+ },
86
98
  "content": Array [
87
99
  Object {
88
100
  "content": Array [
@@ -110,6 +122,9 @@ Object {
110
122
 
111
123
  exports[`apply font size should not increase font size if reached limit 1`] = `
112
124
  Object {
125
+ "attrs": Object {
126
+ "meta": Object {},
127
+ },
113
128
  "content": Array [
114
129
  Object {
115
130
  "content": Array [
@@ -137,6 +152,9 @@ Object {
137
152
 
138
153
  exports[`parsing html should get value from paragraph 1`] = `
139
154
  Object {
155
+ "attrs": Object {
156
+ "meta": Object {},
157
+ },
140
158
  "content": Array [
141
159
  Object {
142
160
  "content": Array [
@@ -164,6 +182,9 @@ Object {
164
182
 
165
183
  exports[`parsing html should get value from rendered view 1`] = `
166
184
  Object {
185
+ "attrs": Object {
186
+ "meta": Object {},
187
+ },
167
188
  "content": Array [
168
189
  Object {
169
190
  "content": Array [
@@ -195,6 +216,9 @@ Object {
195
216
 
196
217
  exports[`parsing html should get value from text 1`] = `
197
218
  Object {
219
+ "attrs": Object {
220
+ "meta": Object {},
221
+ },
198
222
  "content": Array [
199
223
  Object {
200
224
  "content": Array [
@@ -226,6 +250,9 @@ Object {
226
250
 
227
251
  exports[`parsing html should merge paragraph and text settings 1`] = `
228
252
  Object {
253
+ "attrs": Object {
254
+ "meta": Object {},
255
+ },
229
256
  "content": Array [
230
257
  Object {
231
258
  "content": Array [
@@ -2,6 +2,9 @@
2
2
 
3
3
  exports[`apply font style should make italic 1`] = `
4
4
  Object {
5
+ "attrs": Object {
6
+ "meta": Object {},
7
+ },
5
8
  "content": Array [
6
9
  Object {
7
10
  "content": Array [
@@ -27,6 +30,9 @@ Object {
27
30
 
28
31
  exports[`apply font style should remove italic 1`] = `
29
32
  Object {
33
+ "attrs": Object {
34
+ "meta": Object {},
35
+ },
30
36
  "content": Array [
31
37
  Object {
32
38
  "content": Array [
@@ -52,6 +58,9 @@ Object {
52
58
 
53
59
  exports[`apply font style should toggle italic to removed 1`] = `
54
60
  Object {
61
+ "attrs": Object {
62
+ "meta": Object {},
63
+ },
55
64
  "content": Array [
56
65
  Object {
57
66
  "content": Array [
@@ -77,6 +86,9 @@ Object {
77
86
 
78
87
  exports[`apply font style should toggle italic to used 1`] = `
79
88
  Object {
89
+ "attrs": Object {
90
+ "meta": Object {},
91
+ },
80
92
  "content": Array [
81
93
  Object {
82
94
  "content": Array [
@@ -102,6 +114,9 @@ Object {
102
114
 
103
115
  exports[`parsing html should get value from i tag 1`] = `
104
116
  Object {
117
+ "attrs": Object {
118
+ "meta": Object {},
119
+ },
105
120
  "content": Array [
106
121
  Object {
107
122
  "content": Array [
@@ -131,6 +146,9 @@ Object {
131
146
 
132
147
  exports[`parsing html should get value from paragraph 1`] = `
133
148
  Object {
149
+ "attrs": Object {
150
+ "meta": Object {},
151
+ },
134
152
  "content": Array [
135
153
  Object {
136
154
  "content": Array [
@@ -156,6 +174,9 @@ Object {
156
174
 
157
175
  exports[`parsing html should get value from rendered view 1`] = `
158
176
  Object {
177
+ "attrs": Object {
178
+ "meta": Object {},
179
+ },
159
180
  "content": Array [
160
181
  Object {
161
182
  "content": Array [
@@ -185,6 +206,9 @@ Object {
185
206
 
186
207
  exports[`parsing html should get value from text 1`] = `
187
208
  Object {
209
+ "attrs": Object {
210
+ "meta": Object {},
211
+ },
188
212
  "content": Array [
189
213
  Object {
190
214
  "content": Array [
@@ -214,6 +238,9 @@ Object {
214
238
 
215
239
  exports[`parsing html should merge paragraph and text settings 1`] = `
216
240
  Object {
241
+ "attrs": Object {
242
+ "meta": Object {},
243
+ },
217
244
  "content": Array [
218
245
  Object {
219
246
  "content": Array [