@zipify/wysiwyg 2.0.0-1 → 2.0.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 +2 -2
- package/dist/wysiwyg.mjs +72 -57
- package/lib/__tests__/utils/buildTestExtensions.js +2 -1
- package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +4 -4
- package/lib/enums/MarkGroups.js +4 -0
- package/lib/enums/TextSettings.js +1 -1
- package/lib/enums/index.js +1 -0
- package/lib/extensions/BackgroundColor.js +2 -2
- package/lib/extensions/FontColor.js +2 -2
- package/lib/extensions/FontFamily.js +3 -3
- package/lib/extensions/FontSize.js +2 -2
- package/lib/extensions/FontStyle.js +2 -2
- package/lib/extensions/FontWeight.js +2 -2
- package/lib/extensions/StylePreset.js +1 -1
- package/lib/extensions/Superscript.js +5 -2
- package/lib/extensions/__tests__/Alignment.test.js +2 -2
- package/lib/extensions/__tests__/BackgroundColor.test.js +4 -3
- package/lib/extensions/__tests__/FontColor.test.js +4 -3
- package/lib/extensions/__tests__/FontFamily.test.js +6 -6
- package/lib/extensions/__tests__/FontSize.test.js +9 -8
- package/lib/extensions/__tests__/FontStyle.test.js +6 -5
- package/lib/extensions/__tests__/LineHeight.test.js +2 -1
- package/lib/extensions/__tests__/Superscript.test.js +102 -0
- package/lib/extensions/__tests__/__snapshots__/Superscript.test.js.snap +107 -0
- package/lib/extensions/core/Document.js +2 -1
- package/lib/extensions/core/Heading.js +2 -1
- package/lib/extensions/core/NodeProcessor.js +31 -21
- package/lib/extensions/core/Paragraph.js +2 -1
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +309 -11
- package/lib/extensions/core/__tests__/TextProcessor.test.js +1 -1
- package/lib/extensions/core/__tests__/__snapshots__/NodeProcessor.test.js.snap +249 -0
- package/lib/extensions/core/steps/AddNodeMarkStep.js +6 -0
- package/lib/extensions/core/steps/AttrStep.js +6 -0
- package/lib/extensions/core/steps/RemoveNodeMarkStep.js +6 -0
- package/lib/extensions/list/List.js +2 -2
- package/lib/extensions/list/ListItem.js +2 -2
- package/lib/services/NodeFactory.js +69 -3
- package/lib/services/__tests__/NodeFactory.test.js +124 -0
- package/lib/services/__tests__/__snapshots__/NodeFactory.test.js.snap +326 -0
- package/lib/services/normalizer/JsonNormalizer.js +3 -3
- package/lib/utils/__tests__/findMarkByType.test.js +17 -0
- package/lib/utils/__tests__/isMarkAppliedToParent.test.js +53 -0
- package/lib/utils/__tests__/isNodeFullySelected.test.js +53 -0
- package/lib/utils/__tests__/resolveTextPosition.test.js +39 -0
- package/lib/utils/index.js +0 -1
- package/lib/utils/isMarkAppliedToParent.js +1 -1
- package/lib/utils/isNodeFullySelected.js +9 -5
- package/lib/utils/resolveTextPosition.js +4 -6
- package/package.json +26 -26
- package/lib/utils/resolveNodePosition.js +0 -6
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
1
2
|
import { Editor, Extension, Mark } from '@tiptap/vue-2';
|
|
2
3
|
import { buildTestExtensions } from '../../../__tests__/utils';
|
|
3
|
-
import { NodeTypes, TextSettings } from '../../../enums';
|
|
4
|
+
import { Devices, ListTypes, MarkGroups, NodeTypes, TextSettings } from '../../../enums';
|
|
4
5
|
import { ContentNormalizer, NodeFactory } from '../../../services';
|
|
6
|
+
import { createCommand } from '../../../utils';
|
|
7
|
+
import { List } from '../../list';
|
|
5
8
|
|
|
6
9
|
const MockLineHeight = Extension.create({
|
|
7
10
|
name: TextSettings.LINE_HEIGHT,
|
|
@@ -19,18 +22,59 @@ const MockLineHeight = Extension.create({
|
|
|
19
22
|
]
|
|
20
23
|
});
|
|
21
24
|
|
|
25
|
+
const MockTextDecoration = Mark.create({
|
|
26
|
+
name: TextSettings.TEXT_DECORATION,
|
|
27
|
+
renderHTML: () => ['span', {}, 0],
|
|
28
|
+
|
|
29
|
+
addAttributes: () => ({
|
|
30
|
+
underline: { default: false },
|
|
31
|
+
strike_through: { default: false }
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
|
|
22
35
|
const MockFontWeight = Mark.create({
|
|
23
36
|
name: TextSettings.FONT_WEIGHT,
|
|
24
|
-
group:
|
|
37
|
+
group: MarkGroups.SETTINGS,
|
|
25
38
|
renderHTML: () => ['span', {}, 0],
|
|
26
39
|
addAttributes: () => ({ value: { required: true } })
|
|
27
40
|
});
|
|
28
41
|
|
|
29
|
-
|
|
42
|
+
const MockFontSize = Mark.create({
|
|
43
|
+
name: TextSettings.FONT_SIZE,
|
|
44
|
+
group: MarkGroups.SETTINGS,
|
|
45
|
+
renderHTML: () => ['span', {}, 0],
|
|
46
|
+
|
|
47
|
+
addAttributes: () => ({
|
|
48
|
+
mobile: { default: null },
|
|
49
|
+
tablet: { default: null },
|
|
50
|
+
desktop: { default: null }
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const DeviceManager = Extension.create({
|
|
55
|
+
name: 'device_manager',
|
|
56
|
+
|
|
57
|
+
addOptions: () => ({
|
|
58
|
+
device: { required: true }
|
|
59
|
+
}),
|
|
60
|
+
|
|
61
|
+
addCommands() {
|
|
62
|
+
return { getDevice: createCommand(() => ref(this.options.device)) };
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
function createEditor({ content, device }) {
|
|
30
67
|
return new Editor({
|
|
31
68
|
content: ContentNormalizer.normalize(content),
|
|
32
69
|
extensions: buildTestExtensions({
|
|
33
|
-
include: [
|
|
70
|
+
include: [
|
|
71
|
+
MockLineHeight,
|
|
72
|
+
MockFontWeight,
|
|
73
|
+
MockFontSize,
|
|
74
|
+
MockTextDecoration,
|
|
75
|
+
List.configure({ baseClass: 'zw-list--' }),
|
|
76
|
+
DeviceManager.configure({ device: device ?? Devices.DESKTOP })
|
|
77
|
+
]
|
|
34
78
|
})
|
|
35
79
|
});
|
|
36
80
|
}
|
|
@@ -54,7 +98,7 @@ describe('block attributes', () => {
|
|
|
54
98
|
line_height: { mobile: '1.2' }
|
|
55
99
|
})
|
|
56
100
|
});
|
|
57
|
-
const attrs = editor.commands.getBlockAttributes(
|
|
101
|
+
const attrs = editor.commands.getBlockAttributes(TextSettings.LINE_HEIGHT);
|
|
58
102
|
|
|
59
103
|
expect(attrs.value).toEqual({ mobile: '1.2' });
|
|
60
104
|
});
|
|
@@ -65,7 +109,7 @@ describe('block attributes', () => {
|
|
|
65
109
|
line_height: { mobile: '1.2' }
|
|
66
110
|
})
|
|
67
111
|
});
|
|
68
|
-
const attrs = editor.commands.getBlockAttributes(
|
|
112
|
+
const attrs = editor.commands.getBlockAttributes(TextSettings.LINE_HEIGHT, DEFAULTS);
|
|
69
113
|
|
|
70
114
|
expect(attrs.value).toEqual({
|
|
71
115
|
mobile: '1.2',
|
|
@@ -78,7 +122,7 @@ describe('block attributes', () => {
|
|
|
78
122
|
const editor = createEditor({
|
|
79
123
|
content: createContent({ line_height: null })
|
|
80
124
|
});
|
|
81
|
-
const attrs = editor.commands.getBlockAttributes(
|
|
125
|
+
const attrs = editor.commands.getBlockAttributes(TextSettings.LINE_HEIGHT);
|
|
82
126
|
|
|
83
127
|
expect(attrs.value).toEqual(null);
|
|
84
128
|
});
|
|
@@ -89,7 +133,7 @@ describe('block attributes', () => {
|
|
|
89
133
|
});
|
|
90
134
|
|
|
91
135
|
editor.commands.selectAll();
|
|
92
|
-
editor.commands.setBlockAttributes(
|
|
136
|
+
editor.commands.setBlockAttributes(TextSettings.LINE_HEIGHT, { mobile: '1.3' });
|
|
93
137
|
|
|
94
138
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
95
139
|
});
|
|
@@ -100,7 +144,7 @@ describe('block attributes', () => {
|
|
|
100
144
|
});
|
|
101
145
|
|
|
102
146
|
editor.commands.selectAll();
|
|
103
|
-
editor.commands.setBlockAttributes(
|
|
147
|
+
editor.commands.setBlockAttributes(TextSettings.LINE_HEIGHT, { mobile: '1.3' }, DEFAULTS);
|
|
104
148
|
|
|
105
149
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
106
150
|
});
|
|
@@ -113,7 +157,7 @@ describe('block attributes', () => {
|
|
|
113
157
|
});
|
|
114
158
|
|
|
115
159
|
editor.commands.selectAll();
|
|
116
|
-
editor.commands.setBlockAttributes(
|
|
160
|
+
editor.commands.setBlockAttributes(TextSettings.LINE_HEIGHT, { mobile: '1.3' });
|
|
117
161
|
|
|
118
162
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
119
163
|
});
|
|
@@ -126,7 +170,7 @@ describe('block attributes', () => {
|
|
|
126
170
|
});
|
|
127
171
|
|
|
128
172
|
editor.commands.selectAll();
|
|
129
|
-
editor.commands.setBlockAttributes(
|
|
173
|
+
editor.commands.setBlockAttributes(TextSettings.LINE_HEIGHT, { mobile: '1.3' }, DEFAULTS);
|
|
130
174
|
|
|
131
175
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
132
176
|
});
|
|
@@ -191,6 +235,260 @@ describe('apply mark', () => {
|
|
|
191
235
|
});
|
|
192
236
|
});
|
|
193
237
|
|
|
238
|
+
describe('apply mark', () => {
|
|
239
|
+
test('should apply inline mark', () => {
|
|
240
|
+
const editor = createEditor({
|
|
241
|
+
content: NodeFactory.doc([
|
|
242
|
+
NodeFactory.paragraph('lorem ipsum')
|
|
243
|
+
])
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
editor.commands.selectAll();
|
|
247
|
+
editor.commands.applyMark(TextSettings.TEXT_DECORATION, { underline: true });
|
|
248
|
+
|
|
249
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
test('should apply mark to part of text', () => {
|
|
253
|
+
const editor = createEditor({
|
|
254
|
+
content: NodeFactory.doc([
|
|
255
|
+
NodeFactory.paragraph('lorem ipsum')
|
|
256
|
+
])
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
editor.commands.setTextSelection({ from: 1, to: 6 });
|
|
260
|
+
editor.commands.applyMark(TextSettings.FONT_WEIGHT, { value: '700' });
|
|
261
|
+
|
|
262
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
test('should apply mark to paragraph', () => {
|
|
266
|
+
const editor = createEditor({
|
|
267
|
+
content: NodeFactory.doc([
|
|
268
|
+
NodeFactory.paragraph('lorem ipsum')
|
|
269
|
+
])
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
editor.commands.selectAll();
|
|
273
|
+
editor.commands.applyMark(TextSettings.FONT_WEIGHT, { value: '700' });
|
|
274
|
+
|
|
275
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
test('should remove text mark on applying to paragraph', () => {
|
|
279
|
+
const editor = createEditor({
|
|
280
|
+
content: NodeFactory.doc([
|
|
281
|
+
NodeFactory.paragraph([
|
|
282
|
+
NodeFactory.text('lorem', [
|
|
283
|
+
NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '400' })
|
|
284
|
+
]),
|
|
285
|
+
NodeFactory.text(' ipsum')
|
|
286
|
+
])
|
|
287
|
+
])
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
editor.commands.selectAll();
|
|
291
|
+
editor.commands.applyMark(TextSettings.FONT_WEIGHT, { value: '700' });
|
|
292
|
+
|
|
293
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
test('should apply mark to list item', () => {
|
|
297
|
+
const editor = createEditor({
|
|
298
|
+
content: NodeFactory.doc([
|
|
299
|
+
NodeFactory.list(ListTypes.DISC, [
|
|
300
|
+
'lorem ipsum 1',
|
|
301
|
+
'lorem ipsum 2'
|
|
302
|
+
])
|
|
303
|
+
])
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
editor.commands.setTextSelection({ from: 1, to: 16 });
|
|
307
|
+
editor.commands.applyMark(TextSettings.FONT_WEIGHT, { value: '700' });
|
|
308
|
+
|
|
309
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
test('should remove paragraph mark on applying to list item', () => {
|
|
313
|
+
const editor = createEditor({
|
|
314
|
+
content: NodeFactory.doc([
|
|
315
|
+
NodeFactory.list(ListTypes.DISC, [
|
|
316
|
+
NodeFactory.listItem([
|
|
317
|
+
NodeFactory.paragraph(null, [
|
|
318
|
+
NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '400' })
|
|
319
|
+
], 'lorem ipsum 1'),
|
|
320
|
+
|
|
321
|
+
'lorem ipsum 2' // prevent move mark to list item on init
|
|
322
|
+
]),
|
|
323
|
+
|
|
324
|
+
'lorem ipsum 3'
|
|
325
|
+
])
|
|
326
|
+
])
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
editor.commands.setTextSelection({ from: 1, to: 31 });
|
|
330
|
+
editor.commands.applyMark(TextSettings.FONT_WEIGHT, { value: '700' });
|
|
331
|
+
|
|
332
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
describe('get marks', () => {
|
|
337
|
+
test('should get marks', () => {
|
|
338
|
+
const editor = createEditor({
|
|
339
|
+
content: NodeFactory.doc([
|
|
340
|
+
NodeFactory.paragraph(null, [
|
|
341
|
+
NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '400' })
|
|
342
|
+
], [
|
|
343
|
+
NodeFactory.text('lorem', [
|
|
344
|
+
NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '700' })
|
|
345
|
+
]),
|
|
346
|
+
NodeFactory.text(' ipsum')
|
|
347
|
+
])
|
|
348
|
+
])
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
editor.commands.selectAll();
|
|
352
|
+
const selectionRef = editor.commands.getMarks(TextSettings.FONT_WEIGHT);
|
|
353
|
+
|
|
354
|
+
expect(selectionRef.value).toEqual([
|
|
355
|
+
{ value: '700' },
|
|
356
|
+
{ value: '400' }
|
|
357
|
+
]);
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
test('should get empty marks', () => {
|
|
361
|
+
const editor = createEditor({
|
|
362
|
+
content: NodeFactory.doc([
|
|
363
|
+
NodeFactory.paragraph('lorem ipsum')
|
|
364
|
+
])
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
editor.commands.selectAll();
|
|
368
|
+
const selectionRef = editor.commands.getMarks(TextSettings.FONT_WEIGHT);
|
|
369
|
+
|
|
370
|
+
expect(selectionRef.value).toEqual([]);
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
describe('get mark', () => {
|
|
375
|
+
test('should get text mark', () => {
|
|
376
|
+
const editor = createEditor({
|
|
377
|
+
content: NodeFactory.doc([
|
|
378
|
+
NodeFactory.paragraph(null, [
|
|
379
|
+
NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '400' })
|
|
380
|
+
], [
|
|
381
|
+
NodeFactory.text('lorem', [
|
|
382
|
+
NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '700' })
|
|
383
|
+
]),
|
|
384
|
+
NodeFactory.text(' ipsum')
|
|
385
|
+
])
|
|
386
|
+
])
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
editor.commands.selectAll();
|
|
390
|
+
const selectionRef = editor.commands.getMark(TextSettings.FONT_WEIGHT);
|
|
391
|
+
|
|
392
|
+
expect(selectionRef.value).toEqual({ value: '700' });
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
test('should get block mark', () => {
|
|
396
|
+
const editor = createEditor({
|
|
397
|
+
content: NodeFactory.doc([
|
|
398
|
+
NodeFactory.paragraph(null, [
|
|
399
|
+
NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '400' })
|
|
400
|
+
], 'lorem ipsum')
|
|
401
|
+
])
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
editor.commands.selectAll();
|
|
405
|
+
const selectionRef = editor.commands.getMark(TextSettings.FONT_WEIGHT);
|
|
406
|
+
|
|
407
|
+
expect(selectionRef.value).toEqual({ value: '400' });
|
|
408
|
+
});
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
describe('get setting mark', () => {
|
|
412
|
+
test('should get common setting mark', () => {
|
|
413
|
+
const editor = createEditor({
|
|
414
|
+
content: NodeFactory.doc([
|
|
415
|
+
NodeFactory.paragraph(null, [
|
|
416
|
+
NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '400' })
|
|
417
|
+
], 'lorem ipsum')
|
|
418
|
+
])
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
editor.commands.selectAll();
|
|
422
|
+
const selectionRef = editor.commands.getCommonSettingMark(TextSettings.FONT_WEIGHT);
|
|
423
|
+
|
|
424
|
+
expect(selectionRef.value).toEqual('400');
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
test('should get default of common setting mark', () => {
|
|
428
|
+
const editor = createEditor({
|
|
429
|
+
content: NodeFactory.doc([
|
|
430
|
+
NodeFactory.paragraph('lorem ipsum')
|
|
431
|
+
])
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
editor.commands.selectAll();
|
|
435
|
+
const selectionRef = editor.commands.getCommonSettingMark(TextSettings.FONT_WEIGHT, ref('400'));
|
|
436
|
+
|
|
437
|
+
expect(selectionRef.value).toEqual('400');
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
test('should get device setting mark', () => {
|
|
441
|
+
const editor = createEditor({
|
|
442
|
+
content: NodeFactory.doc([
|
|
443
|
+
NodeFactory.paragraph(null, [
|
|
444
|
+
NodeFactory.mark(TextSettings.FONT_SIZE, { mobile: '23' })
|
|
445
|
+
], 'lorem ipsum')
|
|
446
|
+
]),
|
|
447
|
+
device: Devices.MOBILE
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
editor.commands.selectAll();
|
|
451
|
+
const selectionRef = editor.commands.getDeviceSettingMark(TextSettings.FONT_SIZE);
|
|
452
|
+
|
|
453
|
+
expect(selectionRef.value).toEqual('23');
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
test('should get default of device setting mark', () => {
|
|
457
|
+
const editor = createEditor({
|
|
458
|
+
content: NodeFactory.doc([
|
|
459
|
+
NodeFactory.paragraph('lorem ipsum')
|
|
460
|
+
]),
|
|
461
|
+
device: Devices.MOBILE
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
editor.commands.selectAll();
|
|
465
|
+
const selectionRef = editor.commands.getDeviceSettingMark(TextSettings.FONT_SIZE, ref('23'));
|
|
466
|
+
|
|
467
|
+
expect(selectionRef.value).toEqual('23');
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
test('should inherit device setting mark', () => {
|
|
471
|
+
const editor = createEditor({
|
|
472
|
+
content: NodeFactory.doc([
|
|
473
|
+
NodeFactory.paragraph(null, [
|
|
474
|
+
NodeFactory.mark(TextSettings.FONT_SIZE, { mobile: '23' })
|
|
475
|
+
], [
|
|
476
|
+
NodeFactory.text('lorem', [
|
|
477
|
+
NodeFactory.mark(TextSettings.FONT_SIZE, { tablet: '25' })
|
|
478
|
+
]),
|
|
479
|
+
NodeFactory.text(' ipsum')
|
|
480
|
+
])
|
|
481
|
+
]),
|
|
482
|
+
device: Devices.MOBILE
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
editor.commands.selectAll();
|
|
486
|
+
const selectionRef = editor.commands.getDeviceSettingMark(TextSettings.FONT_SIZE);
|
|
487
|
+
|
|
488
|
+
expect(selectionRef.value).toEqual('23');
|
|
489
|
+
});
|
|
490
|
+
});
|
|
491
|
+
|
|
194
492
|
describe('remove marks', () => {
|
|
195
493
|
test('should remove text marks', () => {
|
|
196
494
|
const editor = createEditor({
|
|
@@ -138,7 +138,7 @@ describe('transform text', () => {
|
|
|
138
138
|
content: NodeFactory.doc([
|
|
139
139
|
NodeFactory.paragraph([
|
|
140
140
|
NodeFactory.text('hello world', [
|
|
141
|
-
NodeFactory.mark(
|
|
141
|
+
NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '700' })
|
|
142
142
|
])
|
|
143
143
|
])
|
|
144
144
|
])
|
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
+
exports[`apply mark should apply inline mark 1`] = `
|
|
4
|
+
Object {
|
|
5
|
+
"content": Array [
|
|
6
|
+
Object {
|
|
7
|
+
"attrs": Object {
|
|
8
|
+
"line_height": null,
|
|
9
|
+
},
|
|
10
|
+
"content": Array [
|
|
11
|
+
Object {
|
|
12
|
+
"marks": Array [
|
|
13
|
+
Object {
|
|
14
|
+
"attrs": Object {
|
|
15
|
+
"strike_through": false,
|
|
16
|
+
"underline": true,
|
|
17
|
+
},
|
|
18
|
+
"type": "text_decoration",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
"text": "lorem ipsum",
|
|
22
|
+
"type": "text",
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
"type": "paragraph",
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
"type": "doc",
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
|
|
3
32
|
exports[`apply mark should apply mark to block 1`] = `
|
|
4
33
|
Object {
|
|
5
34
|
"content": Array [
|
|
@@ -28,6 +57,126 @@ Object {
|
|
|
28
57
|
}
|
|
29
58
|
`;
|
|
30
59
|
|
|
60
|
+
exports[`apply mark should apply mark to list item 1`] = `
|
|
61
|
+
Object {
|
|
62
|
+
"content": Array [
|
|
63
|
+
Object {
|
|
64
|
+
"attrs": Object {
|
|
65
|
+
"bullet": Object {
|
|
66
|
+
"type": "disc",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
"content": Array [
|
|
70
|
+
Object {
|
|
71
|
+
"content": Array [
|
|
72
|
+
Object {
|
|
73
|
+
"attrs": Object {
|
|
74
|
+
"line_height": null,
|
|
75
|
+
},
|
|
76
|
+
"content": Array [
|
|
77
|
+
Object {
|
|
78
|
+
"text": "lorem ipsum 1",
|
|
79
|
+
"type": "text",
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
"type": "paragraph",
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
"marks": Array [
|
|
86
|
+
Object {
|
|
87
|
+
"attrs": Object {
|
|
88
|
+
"value": "700",
|
|
89
|
+
},
|
|
90
|
+
"type": "font_weight",
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
"type": "listItem",
|
|
94
|
+
},
|
|
95
|
+
Object {
|
|
96
|
+
"content": Array [
|
|
97
|
+
Object {
|
|
98
|
+
"attrs": Object {
|
|
99
|
+
"line_height": null,
|
|
100
|
+
},
|
|
101
|
+
"content": Array [
|
|
102
|
+
Object {
|
|
103
|
+
"text": "lorem ipsum 2",
|
|
104
|
+
"type": "text",
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
"type": "paragraph",
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
"type": "listItem",
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
"type": "list",
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
"type": "doc",
|
|
117
|
+
}
|
|
118
|
+
`;
|
|
119
|
+
|
|
120
|
+
exports[`apply mark should apply mark to paragraph 1`] = `
|
|
121
|
+
Object {
|
|
122
|
+
"content": Array [
|
|
123
|
+
Object {
|
|
124
|
+
"attrs": Object {
|
|
125
|
+
"line_height": null,
|
|
126
|
+
},
|
|
127
|
+
"content": Array [
|
|
128
|
+
Object {
|
|
129
|
+
"text": "lorem ipsum",
|
|
130
|
+
"type": "text",
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
"marks": Array [
|
|
134
|
+
Object {
|
|
135
|
+
"attrs": Object {
|
|
136
|
+
"value": "700",
|
|
137
|
+
},
|
|
138
|
+
"type": "font_weight",
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
"type": "paragraph",
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
"type": "doc",
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
147
|
+
|
|
148
|
+
exports[`apply mark should apply mark to part of text 1`] = `
|
|
149
|
+
Object {
|
|
150
|
+
"content": Array [
|
|
151
|
+
Object {
|
|
152
|
+
"attrs": Object {
|
|
153
|
+
"line_height": null,
|
|
154
|
+
},
|
|
155
|
+
"content": Array [
|
|
156
|
+
Object {
|
|
157
|
+
"marks": Array [
|
|
158
|
+
Object {
|
|
159
|
+
"attrs": Object {
|
|
160
|
+
"value": "700",
|
|
161
|
+
},
|
|
162
|
+
"type": "font_weight",
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
"text": "lorem",
|
|
166
|
+
"type": "text",
|
|
167
|
+
},
|
|
168
|
+
Object {
|
|
169
|
+
"text": " ipsum",
|
|
170
|
+
"type": "text",
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
"type": "paragraph",
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
"type": "doc",
|
|
177
|
+
}
|
|
178
|
+
`;
|
|
179
|
+
|
|
31
180
|
exports[`apply mark should apply mark to word 1`] = `
|
|
32
181
|
Object {
|
|
33
182
|
"content": Array [
|
|
@@ -132,6 +281,106 @@ Object {
|
|
|
132
281
|
}
|
|
133
282
|
`;
|
|
134
283
|
|
|
284
|
+
exports[`apply mark should remove paragraph mark on applying to list item 1`] = `
|
|
285
|
+
Object {
|
|
286
|
+
"content": Array [
|
|
287
|
+
Object {
|
|
288
|
+
"attrs": Object {
|
|
289
|
+
"bullet": Object {
|
|
290
|
+
"type": "disc",
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
"content": Array [
|
|
294
|
+
Object {
|
|
295
|
+
"content": Array [
|
|
296
|
+
Object {
|
|
297
|
+
"attrs": Object {
|
|
298
|
+
"line_height": null,
|
|
299
|
+
},
|
|
300
|
+
"content": Array [
|
|
301
|
+
Object {
|
|
302
|
+
"text": "lorem ipsum 1",
|
|
303
|
+
"type": "text",
|
|
304
|
+
},
|
|
305
|
+
],
|
|
306
|
+
"type": "paragraph",
|
|
307
|
+
},
|
|
308
|
+
Object {
|
|
309
|
+
"attrs": Object {
|
|
310
|
+
"line_height": null,
|
|
311
|
+
},
|
|
312
|
+
"content": Array [
|
|
313
|
+
Object {
|
|
314
|
+
"text": "lorem ipsum 2",
|
|
315
|
+
"type": "text",
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
"type": "paragraph",
|
|
319
|
+
},
|
|
320
|
+
],
|
|
321
|
+
"marks": Array [
|
|
322
|
+
Object {
|
|
323
|
+
"attrs": Object {
|
|
324
|
+
"value": "700",
|
|
325
|
+
},
|
|
326
|
+
"type": "font_weight",
|
|
327
|
+
},
|
|
328
|
+
],
|
|
329
|
+
"type": "listItem",
|
|
330
|
+
},
|
|
331
|
+
Object {
|
|
332
|
+
"content": Array [
|
|
333
|
+
Object {
|
|
334
|
+
"attrs": Object {
|
|
335
|
+
"line_height": null,
|
|
336
|
+
},
|
|
337
|
+
"content": Array [
|
|
338
|
+
Object {
|
|
339
|
+
"text": "lorem ipsum 3",
|
|
340
|
+
"type": "text",
|
|
341
|
+
},
|
|
342
|
+
],
|
|
343
|
+
"type": "paragraph",
|
|
344
|
+
},
|
|
345
|
+
],
|
|
346
|
+
"type": "listItem",
|
|
347
|
+
},
|
|
348
|
+
],
|
|
349
|
+
"type": "list",
|
|
350
|
+
},
|
|
351
|
+
],
|
|
352
|
+
"type": "doc",
|
|
353
|
+
}
|
|
354
|
+
`;
|
|
355
|
+
|
|
356
|
+
exports[`apply mark should remove text mark on applying to paragraph 1`] = `
|
|
357
|
+
Object {
|
|
358
|
+
"content": Array [
|
|
359
|
+
Object {
|
|
360
|
+
"attrs": Object {
|
|
361
|
+
"line_height": null,
|
|
362
|
+
},
|
|
363
|
+
"content": Array [
|
|
364
|
+
Object {
|
|
365
|
+
"text": "lorem ipsum",
|
|
366
|
+
"type": "text",
|
|
367
|
+
},
|
|
368
|
+
],
|
|
369
|
+
"marks": Array [
|
|
370
|
+
Object {
|
|
371
|
+
"attrs": Object {
|
|
372
|
+
"value": "700",
|
|
373
|
+
},
|
|
374
|
+
"type": "font_weight",
|
|
375
|
+
},
|
|
376
|
+
],
|
|
377
|
+
"type": "paragraph",
|
|
378
|
+
},
|
|
379
|
+
],
|
|
380
|
+
"type": "doc",
|
|
381
|
+
}
|
|
382
|
+
`;
|
|
383
|
+
|
|
135
384
|
exports[`block attributes should set attributes 1`] = `
|
|
136
385
|
Object {
|
|
137
386
|
"content": Array [
|
|
@@ -2,6 +2,12 @@ import { Step, StepResult } from 'prosemirror-transform';
|
|
|
2
2
|
import { Slice, Fragment } from 'prosemirror-model';
|
|
3
3
|
import { RemoveNodeMarkStep } from './RemoveNodeMarkStep';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Copy&Paste from the latest version prosemirror-transform
|
|
7
|
+
* Can be replaced to built-in commands when tiptap update dependencies
|
|
8
|
+
*
|
|
9
|
+
* Original file: https://github.com/ProseMirror/prosemirror-transform/blob/e659a51eacb6eab66be992ea86b9bf70881d7c5d/src/mark_step.ts#L131
|
|
10
|
+
*/
|
|
5
11
|
export class AddNodeMarkStep extends Step {
|
|
6
12
|
static fromJSON(schema, json) {
|
|
7
13
|
if (typeof json.pos != 'number') {
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Step, StepResult, StepMap } from 'prosemirror-transform';
|
|
2
2
|
import { Fragment, Slice } from 'prosemirror-model';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Copy&Paste from the latest version prosemirror-transform
|
|
6
|
+
* Can be replaced to built-in commands when tiptap update dependencies
|
|
7
|
+
*
|
|
8
|
+
* Original file: https://github.com/ProseMirror/prosemirror-transform/blob/9ee7c0806f38180bae0e60d7d84af4fd9ee44f26/src/attr_step.ts#L6
|
|
9
|
+
*/
|
|
4
10
|
export class AttrStep extends Step {
|
|
5
11
|
static fromJSON(schema, json) {
|
|
6
12
|
if (typeof json.pos != 'number' || typeof json.attr != 'string') {
|