@zipify/wysiwyg 3.3.0-0 → 3.3.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.
- package/dist/cli.js +1 -1
- package/dist/wysiwyg.mjs +7 -9
- package/lib/components/toolbar/controls/AlignmentControl.vue +1 -1
- package/lib/enums/TextSettings.js +2 -2
- package/lib/extensions/Alignment.js +1 -4
- package/lib/extensions/StylePreset.js +4 -4
- package/lib/extensions/__tests__/StylePreset.test.js +5 -27
- package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +8 -26
- package/package.json +1 -1
package/dist/wysiwyg.mjs
CHANGED
|
@@ -16352,8 +16352,8 @@ const TextSettings = Object.freeze({
|
|
|
16352
16352
|
get attributes() {
|
|
16353
16353
|
return [this.ALIGNMENT, this.LINE_HEIGHT, this.MARGIN];
|
|
16354
16354
|
},
|
|
16355
|
-
get
|
|
16356
|
-
return [this.LINE_HEIGHT
|
|
16355
|
+
get presetAttributes() {
|
|
16356
|
+
return [this.LINE_HEIGHT];
|
|
16357
16357
|
},
|
|
16358
16358
|
get inlineMarks() {
|
|
16359
16359
|
return [this.TEXT_DECORATION, this.LINK, this.SUPERSCRIPT, this.BACKGROUND_COLOR];
|
|
@@ -18785,7 +18785,7 @@ const StylePreset = Extension.create({
|
|
|
18785
18785
|
}),
|
|
18786
18786
|
isSettingCustomized: createCommand(({ commands: commands2 }, name) => {
|
|
18787
18787
|
const customization = commands2.getPresetCustomization();
|
|
18788
|
-
const group = TextSettings.
|
|
18788
|
+
const group = TextSettings.presetAttributes.includes(name) ? "attributes" : "marks";
|
|
18789
18789
|
return computed(() => {
|
|
18790
18790
|
var _a;
|
|
18791
18791
|
return ((_a = unref(customization)[group]) == null ? void 0 : _a.includes(name)) ?? false;
|
|
@@ -18803,7 +18803,7 @@ const StylePreset = Extension.create({
|
|
|
18803
18803
|
const attributes = /* @__PURE__ */ new Set();
|
|
18804
18804
|
doc2.nodesBetween(from2, to, (node) => {
|
|
18805
18805
|
for (const [name, value] of Object.entries(node.attrs)) {
|
|
18806
|
-
const isSetting = TextSettings.
|
|
18806
|
+
const isSetting = TextSettings.presetAttributes.includes(name);
|
|
18807
18807
|
if (isSetting && value)
|
|
18808
18808
|
attributes.add(name);
|
|
18809
18809
|
}
|
|
@@ -18819,7 +18819,7 @@ const StylePreset = Extension.create({
|
|
|
18819
18819
|
};
|
|
18820
18820
|
}),
|
|
18821
18821
|
removePresetCustomization: createCommand(({ chain }) => {
|
|
18822
|
-
chain().storeSelection().expandSelectionToBlock().removeMarks(TextSettings.marks).resetAttributes(NodeTypes.PARAGRAPH, TextSettings.
|
|
18822
|
+
chain().storeSelection().expandSelectionToBlock().removeMarks(TextSettings.marks).resetAttributes(NodeTypes.PARAGRAPH, TextSettings.presetAttributes).resetAttributes(NodeTypes.HEADING, TextSettings.presetAttributes).restoreSelection().run();
|
|
18823
18823
|
}),
|
|
18824
18824
|
removeFormat: createCommand(({ chain }) => {
|
|
18825
18825
|
chain().storeSelection().expandSelectionToBlock().removeAllMarks().applyDefaultPreset().restoreSelection().run();
|
|
@@ -19329,9 +19329,7 @@ const Alignment = Extension.create({
|
|
|
19329
19329
|
addCommands() {
|
|
19330
19330
|
return {
|
|
19331
19331
|
toggleAlignment: createCommand(({ commands: commands2 }, value) => {
|
|
19332
|
-
|
|
19333
|
-
const isCurrentValue = unref(currentValue) === value;
|
|
19334
|
-
!isCurrentValue ? commands2.applyAlignment(value) : commands2.removeAlignment();
|
|
19332
|
+
commands2.applyAlignment(value);
|
|
19335
19333
|
}),
|
|
19336
19334
|
applyAlignment: createCommand(({ commands: commands2 }, value) => {
|
|
19337
19335
|
const device = unref(commands2.getDevice());
|
|
@@ -25363,7 +25361,7 @@ const __vue2_script$d = {
|
|
|
25363
25361
|
setup(_, { emit }) {
|
|
25364
25362
|
const editor = inject(InjectionTokens$1.EDITOR);
|
|
25365
25363
|
const alignment = editor.commands.getAlignment();
|
|
25366
|
-
const currentValue = computed(() => unref(alignment) ?? "
|
|
25364
|
+
const currentValue = computed(() => unref(alignment) ?? "left");
|
|
25367
25365
|
function toggle(value) {
|
|
25368
25366
|
editor.chain().focus().toggleAlignment(value).run();
|
|
25369
25367
|
emit("applied");
|
|
@@ -57,7 +57,7 @@ export default {
|
|
|
57
57
|
setup(_, { emit }) {
|
|
58
58
|
const editor = inject(InjectionTokens.EDITOR);
|
|
59
59
|
const alignment = editor.commands.getAlignment();
|
|
60
|
-
const currentValue = computed(() => unref(alignment) ?? '
|
|
60
|
+
const currentValue = computed(() => unref(alignment) ?? 'left');
|
|
61
61
|
|
|
62
62
|
function toggle(value) {
|
|
63
63
|
editor.chain().focus().toggleAlignment(value).run();
|
|
@@ -17,8 +17,8 @@ export const TextSettings = Object.freeze({
|
|
|
17
17
|
return [this.ALIGNMENT, this.LINE_HEIGHT, this.MARGIN];
|
|
18
18
|
},
|
|
19
19
|
|
|
20
|
-
get
|
|
21
|
-
return [this.LINE_HEIGHT
|
|
20
|
+
get presetAttributes() {
|
|
21
|
+
return [this.LINE_HEIGHT];
|
|
22
22
|
},
|
|
23
23
|
|
|
24
24
|
get inlineMarks() {
|
|
@@ -52,10 +52,7 @@ export const Alignment = Extension.create({
|
|
|
52
52
|
addCommands() {
|
|
53
53
|
return {
|
|
54
54
|
toggleAlignment: createCommand(({ commands }, value) => {
|
|
55
|
-
|
|
56
|
-
const isCurrentValue = unref(currentValue) === value;
|
|
57
|
-
|
|
58
|
-
!isCurrentValue ? commands.applyAlignment(value) : commands.removeAlignment();
|
|
55
|
+
commands.applyAlignment(value);
|
|
59
56
|
}),
|
|
60
57
|
|
|
61
58
|
applyAlignment: createCommand(({ commands }, value) => {
|
|
@@ -135,7 +135,7 @@ export const StylePreset = Extension.create({
|
|
|
135
135
|
|
|
136
136
|
isSettingCustomized: createCommand(({ commands }, name) => {
|
|
137
137
|
const customization = commands.getPresetCustomization();
|
|
138
|
-
const group = TextSettings.
|
|
138
|
+
const group = TextSettings.presetAttributes.includes(name) ? 'attributes' : 'marks';
|
|
139
139
|
|
|
140
140
|
return computed(() => unref(customization)[group]?.includes(name) ?? false);
|
|
141
141
|
}),
|
|
@@ -156,7 +156,7 @@ export const StylePreset = Extension.create({
|
|
|
156
156
|
|
|
157
157
|
doc.nodesBetween(from, to, (node) => {
|
|
158
158
|
for (const [name, value] of Object.entries(node.attrs)) {
|
|
159
|
-
const isSetting = TextSettings.
|
|
159
|
+
const isSetting = TextSettings.presetAttributes.includes(name);
|
|
160
160
|
|
|
161
161
|
if (isSetting && value) attributes.add(name);
|
|
162
162
|
}
|
|
@@ -179,8 +179,8 @@ export const StylePreset = Extension.create({
|
|
|
179
179
|
.storeSelection()
|
|
180
180
|
.expandSelectionToBlock()
|
|
181
181
|
.removeMarks(TextSettings.marks)
|
|
182
|
-
.resetAttributes(NodeTypes.PARAGRAPH, TextSettings.
|
|
183
|
-
.resetAttributes(NodeTypes.HEADING, TextSettings.
|
|
182
|
+
.resetAttributes(NodeTypes.PARAGRAPH, TextSettings.presetAttributes)
|
|
183
|
+
.resetAttributes(NodeTypes.HEADING, TextSettings.presetAttributes)
|
|
184
184
|
.restoreSelection()
|
|
185
185
|
.run();
|
|
186
186
|
}),
|
|
@@ -26,22 +26,6 @@ const MockFontWeight = Mark.create({
|
|
|
26
26
|
renderHTML: () => ['span', {}, 0]
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
const MockAlignment = Extension.create({
|
|
30
|
-
name: TextSettings.ALIGNMENT,
|
|
31
|
-
|
|
32
|
-
addGlobalAttributes: () => [
|
|
33
|
-
{
|
|
34
|
-
types: [NodeTypes.PARAGRAPH, NodeTypes.HEADING],
|
|
35
|
-
attributes: {
|
|
36
|
-
[TextSettings.ALIGNMENT]: {
|
|
37
|
-
default: null,
|
|
38
|
-
renderHTML: () => ({})
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
});
|
|
44
|
-
|
|
45
29
|
const MockBackgroundColor = Mark.create({
|
|
46
30
|
name: TextSettings.BACKGROUND_COLOR,
|
|
47
31
|
|
|
@@ -128,9 +112,6 @@ const MockLineHeight = Extension.create({
|
|
|
128
112
|
line_height: {
|
|
129
113
|
isRequired: false,
|
|
130
114
|
renderHTML: (attrs) => ({ style: `line-height: ${attrs.line_height}` })
|
|
131
|
-
},
|
|
132
|
-
alignment: {
|
|
133
|
-
isRequired: false
|
|
134
115
|
}
|
|
135
116
|
}
|
|
136
117
|
}
|
|
@@ -158,7 +139,6 @@ function createEditor({ content, presets, defaultId, link }) {
|
|
|
158
139
|
}),
|
|
159
140
|
MockFontSize,
|
|
160
141
|
MockFontWeight,
|
|
161
|
-
MockAlignment,
|
|
162
142
|
MockBackgroundColor,
|
|
163
143
|
MockFontColor,
|
|
164
144
|
MockFontFamily,
|
|
@@ -367,7 +347,7 @@ describe('apply preset', () => {
|
|
|
367
347
|
content: NodeFactory.doc([
|
|
368
348
|
NodeFactory.paragraph({
|
|
369
349
|
preset: { id: 'regular-1' },
|
|
370
|
-
|
|
350
|
+
line_height: { value: '1.1' }
|
|
371
351
|
}, 'test')
|
|
372
352
|
]),
|
|
373
353
|
presets: [
|
|
@@ -405,10 +385,8 @@ describe('get preset customization', () => {
|
|
|
405
385
|
});
|
|
406
386
|
|
|
407
387
|
const isFontSizeCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_SIZE);
|
|
408
|
-
const isAlignmentCustomized = editor.commands.isSettingCustomized(TextSettings.ALIGNMENT);
|
|
409
388
|
|
|
410
389
|
expect(isFontSizeCustomized.value).toBe(false);
|
|
411
|
-
expect(isAlignmentCustomized.value).toBe(false);
|
|
412
390
|
});
|
|
413
391
|
|
|
414
392
|
test('should find marks', () => {
|
|
@@ -455,7 +433,7 @@ describe('get preset customization', () => {
|
|
|
455
433
|
content: NodeFactory.doc([
|
|
456
434
|
NodeFactory.paragraph({
|
|
457
435
|
preset: { id: 'regular-1' },
|
|
458
|
-
|
|
436
|
+
line_height: { value: '1.1' }
|
|
459
437
|
}, 'test')
|
|
460
438
|
]),
|
|
461
439
|
presets: [createPreset({ id: 'regular-1' })]
|
|
@@ -522,7 +500,7 @@ describe('get content customization', () => {
|
|
|
522
500
|
content: NodeFactory.doc([
|
|
523
501
|
NodeFactory.paragraph({
|
|
524
502
|
preset: { id: 'regular-2' },
|
|
525
|
-
|
|
503
|
+
line_height: { value: '1.1' }
|
|
526
504
|
}, 'test')
|
|
527
505
|
]),
|
|
528
506
|
presets: [createPreset({ id: 'regular-2' })]
|
|
@@ -562,12 +540,12 @@ describe('remove preset customization', () => {
|
|
|
562
540
|
content: NodeFactory.doc([
|
|
563
541
|
NodeFactory.heading(1, {
|
|
564
542
|
preset: { id: 'regular-1' },
|
|
565
|
-
|
|
543
|
+
line_height: { value: '1.1' }
|
|
566
544
|
}, 'heading'),
|
|
567
545
|
|
|
568
546
|
NodeFactory.paragraph({
|
|
569
547
|
preset: { id: 'regular-1' },
|
|
570
|
-
|
|
548
|
+
line_height: { value: '1.1' }
|
|
571
549
|
}, 'paragraph')
|
|
572
550
|
]),
|
|
573
551
|
|
|
@@ -5,7 +5,6 @@ Object {
|
|
|
5
5
|
"content": Array [
|
|
6
6
|
Object {
|
|
7
7
|
"attrs": Object {
|
|
8
|
-
"alignment": null,
|
|
9
8
|
"line_height": null,
|
|
10
9
|
"preset": Object {
|
|
11
10
|
"id": "regular-1",
|
|
@@ -29,7 +28,6 @@ Object {
|
|
|
29
28
|
"content": Array [
|
|
30
29
|
Object {
|
|
31
30
|
"attrs": Object {
|
|
32
|
-
"alignment": null,
|
|
33
31
|
"level": 1,
|
|
34
32
|
"preset": Object {
|
|
35
33
|
"id": "h1",
|
|
@@ -45,7 +43,6 @@ Object {
|
|
|
45
43
|
},
|
|
46
44
|
Object {
|
|
47
45
|
"attrs": Object {
|
|
48
|
-
"alignment": null,
|
|
49
46
|
"level": 1,
|
|
50
47
|
"preset": Object {
|
|
51
48
|
"id": "h1",
|
|
@@ -69,7 +66,6 @@ Object {
|
|
|
69
66
|
"content": Array [
|
|
70
67
|
Object {
|
|
71
68
|
"attrs": Object {
|
|
72
|
-
"alignment": null,
|
|
73
69
|
"level": 1,
|
|
74
70
|
"preset": Object {
|
|
75
71
|
"id": "h1",
|
|
@@ -93,7 +89,6 @@ Object {
|
|
|
93
89
|
"content": Array [
|
|
94
90
|
Object {
|
|
95
91
|
"attrs": Object {
|
|
96
|
-
"alignment": null,
|
|
97
92
|
"line_height": null,
|
|
98
93
|
"preset": Object {
|
|
99
94
|
"id": "regular-1",
|
|
@@ -117,7 +112,6 @@ Object {
|
|
|
117
112
|
"content": Array [
|
|
118
113
|
Object {
|
|
119
114
|
"attrs": Object {
|
|
120
|
-
"alignment": null,
|
|
121
115
|
"line_height": null,
|
|
122
116
|
"preset": Object {
|
|
123
117
|
"id": "regular-1",
|
|
@@ -133,7 +127,6 @@ Object {
|
|
|
133
127
|
},
|
|
134
128
|
Object {
|
|
135
129
|
"attrs": Object {
|
|
136
|
-
"alignment": null,
|
|
137
130
|
"line_height": null,
|
|
138
131
|
"preset": Object {
|
|
139
132
|
"id": "regular-1",
|
|
@@ -157,7 +150,6 @@ Object {
|
|
|
157
150
|
"content": Array [
|
|
158
151
|
Object {
|
|
159
152
|
"attrs": Object {
|
|
160
|
-
"alignment": null,
|
|
161
153
|
"level": 1,
|
|
162
154
|
"preset": Object {
|
|
163
155
|
"id": "h1",
|
|
@@ -181,10 +173,9 @@ Object {
|
|
|
181
173
|
"content": Array [
|
|
182
174
|
Object {
|
|
183
175
|
"attrs": Object {
|
|
184
|
-
"
|
|
185
|
-
"value": "
|
|
176
|
+
"line_height": Object {
|
|
177
|
+
"value": "1.1",
|
|
186
178
|
},
|
|
187
|
-
"line_height": null,
|
|
188
179
|
"preset": Object {
|
|
189
180
|
"id": "regular-2",
|
|
190
181
|
},
|
|
@@ -204,7 +195,9 @@ Object {
|
|
|
204
195
|
|
|
205
196
|
exports[`get content customization should find attributes 1`] = `
|
|
206
197
|
Object {
|
|
207
|
-
"attributes": Array [
|
|
198
|
+
"attributes": Array [
|
|
199
|
+
"line_height",
|
|
200
|
+
],
|
|
208
201
|
"marks": Array [],
|
|
209
202
|
}
|
|
210
203
|
`;
|
|
@@ -228,7 +221,9 @@ Object {
|
|
|
228
221
|
|
|
229
222
|
exports[`get preset customization should find attributes 1`] = `
|
|
230
223
|
Object {
|
|
231
|
-
"attributes": Array [
|
|
224
|
+
"attributes": Array [
|
|
225
|
+
"line_height",
|
|
226
|
+
],
|
|
232
227
|
"marks": Array [],
|
|
233
228
|
}
|
|
234
229
|
`;
|
|
@@ -293,7 +288,6 @@ Object {
|
|
|
293
288
|
"content": Array [
|
|
294
289
|
Object {
|
|
295
290
|
"attrs": Object {
|
|
296
|
-
"alignment": null,
|
|
297
291
|
"line_height": null,
|
|
298
292
|
"preset": Object {
|
|
299
293
|
"id": "regular-2",
|
|
@@ -317,7 +311,6 @@ Object {
|
|
|
317
311
|
"content": Array [
|
|
318
312
|
Object {
|
|
319
313
|
"attrs": Object {
|
|
320
|
-
"alignment": null,
|
|
321
314
|
"level": 3,
|
|
322
315
|
"preset": Object {
|
|
323
316
|
"id": "h3",
|
|
@@ -341,7 +334,6 @@ Object {
|
|
|
341
334
|
"content": Array [
|
|
342
335
|
Object {
|
|
343
336
|
"attrs": Object {
|
|
344
|
-
"alignment": null,
|
|
345
337
|
"line_height": null,
|
|
346
338
|
"preset": Object {
|
|
347
339
|
"id": "regular-2",
|
|
@@ -365,7 +357,6 @@ Object {
|
|
|
365
357
|
"content": Array [
|
|
366
358
|
Object {
|
|
367
359
|
"attrs": Object {
|
|
368
|
-
"alignment": null,
|
|
369
360
|
"line_height": null,
|
|
370
361
|
"preset": Object {
|
|
371
362
|
"id": "regular-1",
|
|
@@ -398,7 +389,6 @@ Object {
|
|
|
398
389
|
"content": Array [
|
|
399
390
|
Object {
|
|
400
391
|
"attrs": Object {
|
|
401
|
-
"alignment": null,
|
|
402
392
|
"line_height": null,
|
|
403
393
|
"preset": Object {
|
|
404
394
|
"id": "regular-1",
|
|
@@ -437,7 +427,6 @@ Object {
|
|
|
437
427
|
"content": Array [
|
|
438
428
|
Object {
|
|
439
429
|
"attrs": Object {
|
|
440
|
-
"alignment": null,
|
|
441
430
|
"line_height": null,
|
|
442
431
|
"preset": Object {
|
|
443
432
|
"id": "regular-1",
|
|
@@ -467,9 +456,6 @@ Object {
|
|
|
467
456
|
"content": Array [
|
|
468
457
|
Object {
|
|
469
458
|
"attrs": Object {
|
|
470
|
-
"alignment": Object {
|
|
471
|
-
"value": "center",
|
|
472
|
-
},
|
|
473
459
|
"level": 1,
|
|
474
460
|
"preset": Object {
|
|
475
461
|
"id": "regular-1",
|
|
@@ -485,9 +471,6 @@ Object {
|
|
|
485
471
|
},
|
|
486
472
|
Object {
|
|
487
473
|
"attrs": Object {
|
|
488
|
-
"alignment": Object {
|
|
489
|
-
"value": "center",
|
|
490
|
-
},
|
|
491
474
|
"line_height": null,
|
|
492
475
|
"preset": Object {
|
|
493
476
|
"id": "regular-1",
|
|
@@ -511,7 +494,6 @@ Object {
|
|
|
511
494
|
"content": Array [
|
|
512
495
|
Object {
|
|
513
496
|
"attrs": Object {
|
|
514
|
-
"alignment": null,
|
|
515
497
|
"line_height": null,
|
|
516
498
|
"preset": Object {
|
|
517
499
|
"id": "regular-1",
|