@zipify/wysiwyg 3.2.0 → 3.3.0-1
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/README.md +2 -2
- package/dist/cli.js +1 -1
- package/dist/wysiwyg.mjs +8 -7
- package/lib/enums/TextSettings.js +4 -0
- package/lib/extensions/Alignment.js +1 -4
- package/lib/extensions/StylePreset.js +4 -4
- package/lib/extensions/__tests__/StylePreset.test.js +25 -27
- package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +17 -23
- package/package.json +3 -3
package/dist/wysiwyg.mjs
CHANGED
|
@@ -16352,6 +16352,9 @@ const TextSettings = Object.freeze({
|
|
|
16352
16352
|
get attributes() {
|
|
16353
16353
|
return [this.ALIGNMENT, this.LINE_HEIGHT, this.MARGIN];
|
|
16354
16354
|
},
|
|
16355
|
+
get presetAttributes() {
|
|
16356
|
+
return [this.LINE_HEIGHT];
|
|
16357
|
+
},
|
|
16355
16358
|
get inlineMarks() {
|
|
16356
16359
|
return [this.TEXT_DECORATION, this.LINK, this.SUPERSCRIPT, this.BACKGROUND_COLOR];
|
|
16357
16360
|
},
|
|
@@ -18782,7 +18785,7 @@ const StylePreset = Extension.create({
|
|
|
18782
18785
|
}),
|
|
18783
18786
|
isSettingCustomized: createCommand(({ commands: commands2 }, name) => {
|
|
18784
18787
|
const customization = commands2.getPresetCustomization();
|
|
18785
|
-
const group = TextSettings.
|
|
18788
|
+
const group = TextSettings.presetAttributes.includes(name) ? "attributes" : "marks";
|
|
18786
18789
|
return computed(() => {
|
|
18787
18790
|
var _a;
|
|
18788
18791
|
return ((_a = unref(customization)[group]) == null ? void 0 : _a.includes(name)) ?? false;
|
|
@@ -18800,7 +18803,7 @@ const StylePreset = Extension.create({
|
|
|
18800
18803
|
const attributes = /* @__PURE__ */ new Set();
|
|
18801
18804
|
doc2.nodesBetween(from2, to, (node) => {
|
|
18802
18805
|
for (const [name, value] of Object.entries(node.attrs)) {
|
|
18803
|
-
const isSetting = TextSettings.
|
|
18806
|
+
const isSetting = TextSettings.presetAttributes.includes(name);
|
|
18804
18807
|
if (isSetting && value)
|
|
18805
18808
|
attributes.add(name);
|
|
18806
18809
|
}
|
|
@@ -18816,7 +18819,7 @@ const StylePreset = Extension.create({
|
|
|
18816
18819
|
};
|
|
18817
18820
|
}),
|
|
18818
18821
|
removePresetCustomization: createCommand(({ chain }) => {
|
|
18819
|
-
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();
|
|
18820
18823
|
}),
|
|
18821
18824
|
removeFormat: createCommand(({ chain }) => {
|
|
18822
18825
|
chain().storeSelection().expandSelectionToBlock().removeAllMarks().applyDefaultPreset().restoreSelection().run();
|
|
@@ -19326,9 +19329,7 @@ const Alignment = Extension.create({
|
|
|
19326
19329
|
addCommands() {
|
|
19327
19330
|
return {
|
|
19328
19331
|
toggleAlignment: createCommand(({ commands: commands2 }, value) => {
|
|
19329
|
-
|
|
19330
|
-
const isCurrentValue = unref(currentValue) === value;
|
|
19331
|
-
!isCurrentValue ? commands2.applyAlignment(value) : commands2.removeAlignment();
|
|
19332
|
+
commands2.applyAlignment(value);
|
|
19332
19333
|
}),
|
|
19333
19334
|
applyAlignment: createCommand(({ commands: commands2 }, value) => {
|
|
19334
19335
|
const device = unref(commands2.getDevice());
|
|
@@ -26732,7 +26733,7 @@ var render = function __render__45() {
|
|
|
26732
26733
|
})], 1);
|
|
26733
26734
|
};
|
|
26734
26735
|
var staticRenderFns = [];
|
|
26735
|
-
const
|
|
26736
|
+
const main_css_vue_type_style_index_0_from__2FUsers_2Fmaster_2Fwork_2FZipifyWysiwyg_2Flib_2FWysiwyg_vue_src_lang = "";
|
|
26736
26737
|
const MIN_FONT_SIZE = 5;
|
|
26737
26738
|
const MAX_FONT_SIZE = 112;
|
|
26738
26739
|
const __vue2_script = {
|
|
@@ -17,6 +17,10 @@ export const TextSettings = Object.freeze({
|
|
|
17
17
|
return [this.ALIGNMENT, this.LINE_HEIGHT, this.MARGIN];
|
|
18
18
|
},
|
|
19
19
|
|
|
20
|
+
get presetAttributes() {
|
|
21
|
+
return [this.LINE_HEIGHT];
|
|
22
|
+
},
|
|
23
|
+
|
|
20
24
|
get inlineMarks() {
|
|
21
25
|
return [this.TEXT_DECORATION, this.LINK, this.SUPERSCRIPT, this.BACKGROUND_COLOR];
|
|
22
26
|
},
|
|
@@ -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
|
|
|
@@ -118,6 +102,22 @@ const MockLink = Extension.create({
|
|
|
118
102
|
}
|
|
119
103
|
});
|
|
120
104
|
|
|
105
|
+
const MockLineHeight = Extension.create({
|
|
106
|
+
name: TextSettings.LINE_HEIGHT,
|
|
107
|
+
|
|
108
|
+
addGlobalAttributes: () => [
|
|
109
|
+
{
|
|
110
|
+
types: [NodeTypes.PARAGRAPH],
|
|
111
|
+
attributes: {
|
|
112
|
+
line_height: {
|
|
113
|
+
isRequired: false,
|
|
114
|
+
renderHTML: (attrs) => ({ style: `line-height: ${attrs.line_height}` })
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
|
|
121
121
|
function createEditor({ content, presets, defaultId, link }) {
|
|
122
122
|
return new Editor({
|
|
123
123
|
content: ContentNormalizer.normalize(content),
|
|
@@ -139,11 +139,11 @@ function createEditor({ content, presets, defaultId, link }) {
|
|
|
139
139
|
}),
|
|
140
140
|
MockFontSize,
|
|
141
141
|
MockFontWeight,
|
|
142
|
-
MockAlignment,
|
|
143
142
|
MockBackgroundColor,
|
|
144
143
|
MockFontColor,
|
|
145
144
|
MockFontFamily,
|
|
146
145
|
MockFontStyle,
|
|
146
|
+
MockLineHeight,
|
|
147
147
|
MockTextDecoration,
|
|
148
148
|
MockSuperscript,
|
|
149
149
|
MockLink.configure(link)
|
|
@@ -347,7 +347,7 @@ describe('apply preset', () => {
|
|
|
347
347
|
content: NodeFactory.doc([
|
|
348
348
|
NodeFactory.paragraph({
|
|
349
349
|
preset: { id: 'regular-1' },
|
|
350
|
-
|
|
350
|
+
line_height: { value: '1.1' }
|
|
351
351
|
}, 'test')
|
|
352
352
|
]),
|
|
353
353
|
presets: [
|
|
@@ -385,10 +385,8 @@ describe('get preset customization', () => {
|
|
|
385
385
|
});
|
|
386
386
|
|
|
387
387
|
const isFontSizeCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_SIZE);
|
|
388
|
-
const isAlignmentCustomized = editor.commands.isSettingCustomized(TextSettings.ALIGNMENT);
|
|
389
388
|
|
|
390
389
|
expect(isFontSizeCustomized.value).toBe(false);
|
|
391
|
-
expect(isAlignmentCustomized.value).toBe(false);
|
|
392
390
|
});
|
|
393
391
|
|
|
394
392
|
test('should find marks', () => {
|
|
@@ -435,7 +433,7 @@ describe('get preset customization', () => {
|
|
|
435
433
|
content: NodeFactory.doc([
|
|
436
434
|
NodeFactory.paragraph({
|
|
437
435
|
preset: { id: 'regular-1' },
|
|
438
|
-
|
|
436
|
+
line_height: { value: '1.1' }
|
|
439
437
|
}, 'test')
|
|
440
438
|
]),
|
|
441
439
|
presets: [createPreset({ id: 'regular-1' })]
|
|
@@ -453,16 +451,16 @@ describe('get preset customization', () => {
|
|
|
453
451
|
content: NodeFactory.doc([
|
|
454
452
|
NodeFactory.paragraph({
|
|
455
453
|
preset: { id: 'regular-1' },
|
|
456
|
-
|
|
454
|
+
line_height: { value: '1.1' }
|
|
457
455
|
}, 'test')
|
|
458
456
|
]),
|
|
459
457
|
presets: [createPreset({ id: 'regular-1' })]
|
|
460
458
|
});
|
|
461
459
|
|
|
462
460
|
editor.commands.selectAll();
|
|
463
|
-
const
|
|
461
|
+
const isLineHeightCustomized = editor.commands.isSettingCustomized(TextSettings.LINE_HEIGHT);
|
|
464
462
|
|
|
465
|
-
expect(
|
|
463
|
+
expect(isLineHeightCustomized.value).toBe(true);
|
|
466
464
|
});
|
|
467
465
|
});
|
|
468
466
|
|
|
@@ -502,7 +500,7 @@ describe('get content customization', () => {
|
|
|
502
500
|
content: NodeFactory.doc([
|
|
503
501
|
NodeFactory.paragraph({
|
|
504
502
|
preset: { id: 'regular-2' },
|
|
505
|
-
|
|
503
|
+
line_height: { value: '1.1' }
|
|
506
504
|
}, 'test')
|
|
507
505
|
]),
|
|
508
506
|
presets: [createPreset({ id: 'regular-2' })]
|
|
@@ -542,12 +540,12 @@ describe('remove preset customization', () => {
|
|
|
542
540
|
content: NodeFactory.doc([
|
|
543
541
|
NodeFactory.heading(1, {
|
|
544
542
|
preset: { id: 'regular-1' },
|
|
545
|
-
|
|
543
|
+
line_height: { value: '1.1' }
|
|
546
544
|
}, 'heading'),
|
|
547
545
|
|
|
548
546
|
NodeFactory.paragraph({
|
|
549
547
|
preset: { id: 'regular-1' },
|
|
550
|
-
|
|
548
|
+
line_height: { value: '1.1' }
|
|
551
549
|
}, 'paragraph')
|
|
552
550
|
]),
|
|
553
551
|
|
|
@@ -5,7 +5,7 @@ Object {
|
|
|
5
5
|
"content": Array [
|
|
6
6
|
Object {
|
|
7
7
|
"attrs": Object {
|
|
8
|
-
"
|
|
8
|
+
"line_height": null,
|
|
9
9
|
"preset": Object {
|
|
10
10
|
"id": "regular-1",
|
|
11
11
|
},
|
|
@@ -28,7 +28,6 @@ Object {
|
|
|
28
28
|
"content": Array [
|
|
29
29
|
Object {
|
|
30
30
|
"attrs": Object {
|
|
31
|
-
"alignment": null,
|
|
32
31
|
"level": 1,
|
|
33
32
|
"preset": Object {
|
|
34
33
|
"id": "h1",
|
|
@@ -44,7 +43,6 @@ Object {
|
|
|
44
43
|
},
|
|
45
44
|
Object {
|
|
46
45
|
"attrs": Object {
|
|
47
|
-
"alignment": null,
|
|
48
46
|
"level": 1,
|
|
49
47
|
"preset": Object {
|
|
50
48
|
"id": "h1",
|
|
@@ -68,7 +66,6 @@ Object {
|
|
|
68
66
|
"content": Array [
|
|
69
67
|
Object {
|
|
70
68
|
"attrs": Object {
|
|
71
|
-
"alignment": null,
|
|
72
69
|
"level": 1,
|
|
73
70
|
"preset": Object {
|
|
74
71
|
"id": "h1",
|
|
@@ -92,7 +89,7 @@ Object {
|
|
|
92
89
|
"content": Array [
|
|
93
90
|
Object {
|
|
94
91
|
"attrs": Object {
|
|
95
|
-
"
|
|
92
|
+
"line_height": null,
|
|
96
93
|
"preset": Object {
|
|
97
94
|
"id": "regular-1",
|
|
98
95
|
},
|
|
@@ -115,7 +112,7 @@ Object {
|
|
|
115
112
|
"content": Array [
|
|
116
113
|
Object {
|
|
117
114
|
"attrs": Object {
|
|
118
|
-
"
|
|
115
|
+
"line_height": null,
|
|
119
116
|
"preset": Object {
|
|
120
117
|
"id": "regular-1",
|
|
121
118
|
},
|
|
@@ -130,7 +127,7 @@ Object {
|
|
|
130
127
|
},
|
|
131
128
|
Object {
|
|
132
129
|
"attrs": Object {
|
|
133
|
-
"
|
|
130
|
+
"line_height": null,
|
|
134
131
|
"preset": Object {
|
|
135
132
|
"id": "regular-1",
|
|
136
133
|
},
|
|
@@ -153,7 +150,6 @@ Object {
|
|
|
153
150
|
"content": Array [
|
|
154
151
|
Object {
|
|
155
152
|
"attrs": Object {
|
|
156
|
-
"alignment": null,
|
|
157
153
|
"level": 1,
|
|
158
154
|
"preset": Object {
|
|
159
155
|
"id": "h1",
|
|
@@ -177,8 +173,8 @@ Object {
|
|
|
177
173
|
"content": Array [
|
|
178
174
|
Object {
|
|
179
175
|
"attrs": Object {
|
|
180
|
-
"
|
|
181
|
-
"value": "
|
|
176
|
+
"line_height": Object {
|
|
177
|
+
"value": "1.1",
|
|
182
178
|
},
|
|
183
179
|
"preset": Object {
|
|
184
180
|
"id": "regular-2",
|
|
@@ -200,7 +196,7 @@ Object {
|
|
|
200
196
|
exports[`get content customization should find attributes 1`] = `
|
|
201
197
|
Object {
|
|
202
198
|
"attributes": Array [
|
|
203
|
-
"
|
|
199
|
+
"line_height",
|
|
204
200
|
],
|
|
205
201
|
"marks": Array [],
|
|
206
202
|
}
|
|
@@ -226,7 +222,7 @@ Object {
|
|
|
226
222
|
exports[`get preset customization should find attributes 1`] = `
|
|
227
223
|
Object {
|
|
228
224
|
"attributes": Array [
|
|
229
|
-
"
|
|
225
|
+
"line_height",
|
|
230
226
|
],
|
|
231
227
|
"marks": Array [],
|
|
232
228
|
}
|
|
@@ -292,7 +288,7 @@ Object {
|
|
|
292
288
|
"content": Array [
|
|
293
289
|
Object {
|
|
294
290
|
"attrs": Object {
|
|
295
|
-
"
|
|
291
|
+
"line_height": null,
|
|
296
292
|
"preset": Object {
|
|
297
293
|
"id": "regular-2",
|
|
298
294
|
},
|
|
@@ -315,7 +311,6 @@ Object {
|
|
|
315
311
|
"content": Array [
|
|
316
312
|
Object {
|
|
317
313
|
"attrs": Object {
|
|
318
|
-
"alignment": null,
|
|
319
314
|
"level": 3,
|
|
320
315
|
"preset": Object {
|
|
321
316
|
"id": "h3",
|
|
@@ -339,7 +334,7 @@ Object {
|
|
|
339
334
|
"content": Array [
|
|
340
335
|
Object {
|
|
341
336
|
"attrs": Object {
|
|
342
|
-
"
|
|
337
|
+
"line_height": null,
|
|
343
338
|
"preset": Object {
|
|
344
339
|
"id": "regular-2",
|
|
345
340
|
},
|
|
@@ -362,7 +357,7 @@ Object {
|
|
|
362
357
|
"content": Array [
|
|
363
358
|
Object {
|
|
364
359
|
"attrs": Object {
|
|
365
|
-
"
|
|
360
|
+
"line_height": null,
|
|
366
361
|
"preset": Object {
|
|
367
362
|
"id": "regular-1",
|
|
368
363
|
},
|
|
@@ -394,7 +389,7 @@ Object {
|
|
|
394
389
|
"content": Array [
|
|
395
390
|
Object {
|
|
396
391
|
"attrs": Object {
|
|
397
|
-
"
|
|
392
|
+
"line_height": null,
|
|
398
393
|
"preset": Object {
|
|
399
394
|
"id": "regular-1",
|
|
400
395
|
},
|
|
@@ -432,7 +427,7 @@ Object {
|
|
|
432
427
|
"content": Array [
|
|
433
428
|
Object {
|
|
434
429
|
"attrs": Object {
|
|
435
|
-
"
|
|
430
|
+
"line_height": null,
|
|
436
431
|
"preset": Object {
|
|
437
432
|
"id": "regular-1",
|
|
438
433
|
},
|
|
@@ -461,7 +456,6 @@ Object {
|
|
|
461
456
|
"content": Array [
|
|
462
457
|
Object {
|
|
463
458
|
"attrs": Object {
|
|
464
|
-
"alignment": null,
|
|
465
459
|
"level": 1,
|
|
466
460
|
"preset": Object {
|
|
467
461
|
"id": "regular-1",
|
|
@@ -477,7 +471,7 @@ Object {
|
|
|
477
471
|
},
|
|
478
472
|
Object {
|
|
479
473
|
"attrs": Object {
|
|
480
|
-
"
|
|
474
|
+
"line_height": null,
|
|
481
475
|
"preset": Object {
|
|
482
476
|
"id": "regular-1",
|
|
483
477
|
},
|
|
@@ -500,7 +494,7 @@ Object {
|
|
|
500
494
|
"content": Array [
|
|
501
495
|
Object {
|
|
502
496
|
"attrs": Object {
|
|
503
|
-
"
|
|
497
|
+
"line_height": null,
|
|
504
498
|
"preset": Object {
|
|
505
499
|
"id": "regular-1",
|
|
506
500
|
},
|
|
@@ -518,6 +512,6 @@ Object {
|
|
|
518
512
|
}
|
|
519
513
|
`;
|
|
520
514
|
|
|
521
|
-
exports[`render preset styles should render node without preset 1`] = `"<p class="zw-style">test</p>"`;
|
|
515
|
+
exports[`render preset styles should render node without preset 1`] = `"<p class="zw-style" style="line-height: null">test</p>"`;
|
|
522
516
|
|
|
523
|
-
exports[`render preset styles should render preset class 1`] = `"<p class="zw-style zw ts-regular-1">test</p>"`;
|
|
517
|
+
exports[`render preset styles should render preset class 1`] = `"<p class="zw-style zw ts-regular-1" style="line-height: null">test</p>"`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zipify/wysiwyg",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0-1",
|
|
4
4
|
"description": "Zipify modification of TipTap text editor",
|
|
5
5
|
"main": "dist/wysiwyg.mjs",
|
|
6
6
|
"bin": {
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
73
73
|
"@rollup/plugin-replace": "^5.0.2",
|
|
74
74
|
"@rollup/plugin-terser": "^0.4.0",
|
|
75
|
-
"@vue/test-utils": "^1.3.
|
|
75
|
+
"@vue/test-utils": "^1.3.4",
|
|
76
76
|
"@vue/vue2-jest": "^29.2.2",
|
|
77
|
-
"@zipify/colorpicker": "^2.2.
|
|
77
|
+
"@zipify/colorpicker": "^2.2.2",
|
|
78
78
|
"@zipify/eslint-config": "^1.1.2",
|
|
79
79
|
"babel-jest": "^29.4.2",
|
|
80
80
|
"eslint": "8.33.0",
|