@zipify/wysiwyg 1.3.0-0 → 2.0.0-0
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.css +31 -42
- package/dist/wysiwyg.mjs +454 -399
- package/lib/__tests__/utils/buildTestExtensions.js +14 -0
- package/lib/__tests__/utils/index.js +1 -0
- package/lib/components/base/Button.vue +0 -7
- package/lib/components/base/dropdown/Dropdown.vue +1 -7
- package/lib/components/base/dropdown/DropdownActivator.vue +4 -19
- package/lib/components/base/dropdown/__tests__/DropdownActivator.test.js +1 -23
- package/lib/components/toolbar/controls/AlignmentControl.vue +1 -11
- package/lib/components/toolbar/controls/FontColorControl.vue +0 -13
- package/lib/components/toolbar/controls/FontFamilyControl.vue +0 -4
- package/lib/components/toolbar/controls/FontSizeControl.vue +1 -6
- package/lib/components/toolbar/controls/FontWeightControl.vue +0 -12
- package/lib/components/toolbar/controls/ItalicControl.vue +0 -13
- package/lib/components/toolbar/controls/LineHeightControl.vue +0 -14
- package/lib/components/toolbar/controls/SuperscriptControl.vue +2 -2
- package/lib/components/toolbar/controls/UnderlineControl.vue +0 -12
- package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +5 -72
- package/lib/components/toolbar/controls/__tests__/FontColorControl.test.js +1 -22
- package/lib/components/toolbar/controls/__tests__/FontFamilyControl.test.js +0 -1
- package/lib/components/toolbar/controls/__tests__/FontSizeControl.test.js +0 -1
- package/lib/components/toolbar/controls/__tests__/FontWeightControl.test.js +0 -1
- package/lib/components/toolbar/controls/__tests__/ItalicControl.test.js +1 -23
- package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +1 -23
- package/lib/components/toolbar/controls/__tests__/SuperscriptControl.test.js +2 -2
- package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +1 -25
- package/lib/composables/__tests__/useEditor.test.js +2 -2
- package/lib/extensions/BackgroundColor.js +4 -4
- package/lib/extensions/FontColor.js +4 -5
- package/lib/extensions/FontFamily.js +4 -5
- package/lib/extensions/FontSize.js +5 -7
- package/lib/extensions/FontStyle.js +13 -11
- package/lib/extensions/FontWeight.js +6 -9
- package/lib/extensions/StylePreset.js +0 -14
- package/lib/extensions/Superscript.js +23 -1
- package/lib/extensions/TextDecoration.js +33 -20
- package/lib/extensions/__tests__/Alignment.test.js +10 -7
- package/lib/extensions/__tests__/BackgroundColor.test.js +6 -3
- package/lib/extensions/__tests__/CaseStyle.test.js +11 -7
- package/lib/extensions/__tests__/FontColor.test.js +6 -3
- package/lib/extensions/__tests__/FontFamily.test.js +29 -22
- package/lib/extensions/__tests__/FontSize.test.js +24 -17
- package/lib/extensions/__tests__/FontStyle.test.js +22 -16
- package/lib/extensions/__tests__/FontWeight.test.js +26 -19
- package/lib/extensions/__tests__/LineHeight.test.js +14 -11
- package/lib/extensions/__tests__/Link.test.js +14 -10
- package/lib/extensions/__tests__/Margin.test.js +2 -2
- package/lib/extensions/__tests__/StylePreset.test.js +49 -100
- package/lib/extensions/__tests__/TextDecoration.test.js +72 -46
- package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +24 -24
- package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +24 -24
- package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +86 -82
- package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +70 -70
- package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +53 -45
- package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +64 -60
- package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +148 -83
- package/lib/extensions/core/Document.js +5 -0
- package/lib/extensions/core/Heading.js +10 -0
- package/lib/extensions/core/NodeProcessor.js +84 -4
- package/lib/extensions/core/Paragraph.js +9 -0
- package/lib/extensions/core/TextProcessor.js +10 -12
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +82 -10
- package/lib/extensions/core/__tests__/SelectionProcessor.test.js +2 -2
- package/lib/extensions/core/__tests__/TextProcessor.test.js +18 -20
- package/lib/extensions/core/__tests__/__snapshots__/NodeProcessor.test.js.snap +132 -0
- package/lib/extensions/core/index.js +5 -5
- package/lib/extensions/core/steps/AddNodeMarkStep.js +60 -0
- package/lib/extensions/core/steps/RemoveNodeMarkStep.js +50 -0
- package/lib/extensions/core/steps/index.js +2 -0
- package/lib/extensions/list/List.js +1 -0
- package/lib/extensions/list/ListItem.js +5 -0
- package/lib/extensions/list/__tests__/List.test.js +30 -25
- package/lib/services/ContentNormalizer.js +1 -100
- package/lib/services/NodeFactory.js +16 -6
- package/lib/services/__tests__/ContentNormalizer.test.js +0 -64
- package/lib/utils/findMarkByType.js +5 -0
- package/lib/utils/index.js +5 -0
- package/lib/utils/isMarkAppliedToParent.js +15 -0
- package/lib/utils/isNodeFullySelected.js +10 -0
- package/lib/utils/resolveNodePosition.js +6 -0
- package/lib/utils/resolveTextPosition.js +6 -0
- package/package.json +1 -1
- package/lib/assets/icons/indicator.svg +0 -5
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Editor, Extension, Mark } from '@tiptap/vue-2';
|
|
2
|
+
import { buildTestExtensions } from '../../__tests__/utils';
|
|
2
3
|
import { StylePreset } from '../StylePreset';
|
|
3
4
|
import { List } from '../list';
|
|
4
5
|
import { ListTypes, NodeTypes, TextSettings } from '../../enums';
|
|
5
6
|
import { ContentNormalizer, NodeFactory } from '../../services';
|
|
6
|
-
import { buildCoreExtensions } from '../core';
|
|
7
7
|
import { createCommand } from '../../utils';
|
|
8
8
|
|
|
9
9
|
const MockFontSize = Mark.create({
|
|
@@ -124,32 +124,34 @@ function createEditor({ content, presets, defaultId, link }) {
|
|
|
124
124
|
content: ContentNormalizer.normalize(content),
|
|
125
125
|
onCreate: () => resolve(editor),
|
|
126
126
|
|
|
127
|
-
extensions:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
127
|
+
extensions: buildTestExtensions({
|
|
128
|
+
include: [
|
|
129
|
+
StylePreset.configure({
|
|
130
|
+
presets: presets,
|
|
131
|
+
baseClass: 'zw ts-',
|
|
132
|
+
defaultId,
|
|
133
|
+
|
|
134
|
+
makeVariable({ device, preset, property }) {
|
|
135
|
+
const formattedProperty = property.replace(/_/i, '-');
|
|
136
|
+
|
|
137
|
+
return `--${device}-${preset.id}-${formattedProperty}`;
|
|
138
|
+
}
|
|
139
|
+
}),
|
|
140
|
+
List.configure({
|
|
141
|
+
baseClass: 'zw-list--'
|
|
142
|
+
}),
|
|
143
|
+
MockFontSize,
|
|
144
|
+
MockFontWeight,
|
|
145
|
+
MockAlignment,
|
|
146
|
+
MockBackgroundColor,
|
|
147
|
+
MockFontColor,
|
|
148
|
+
MockFontFamily,
|
|
149
|
+
MockFontStyle,
|
|
150
|
+
MockTextDecoration,
|
|
151
|
+
MockSuperscript,
|
|
152
|
+
MockLink.configure(link)
|
|
153
|
+
]
|
|
154
|
+
})
|
|
153
155
|
});
|
|
154
156
|
});
|
|
155
157
|
}
|
|
@@ -279,7 +281,8 @@ describe('apply preset', () => {
|
|
|
279
281
|
presets: [createPreset({ id: 'regular-1' })]
|
|
280
282
|
});
|
|
281
283
|
|
|
282
|
-
editor.
|
|
284
|
+
editor.commands.selectAll();
|
|
285
|
+
editor.commands.applyPreset('regular-1');
|
|
283
286
|
|
|
284
287
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
285
288
|
});
|
|
@@ -294,7 +297,8 @@ describe('apply preset', () => {
|
|
|
294
297
|
]
|
|
295
298
|
});
|
|
296
299
|
|
|
297
|
-
editor.
|
|
300
|
+
editor.commands.selectAll();
|
|
301
|
+
editor.commands.applyPreset('h1');
|
|
298
302
|
|
|
299
303
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
300
304
|
});
|
|
@@ -310,7 +314,8 @@ describe('apply preset', () => {
|
|
|
310
314
|
]
|
|
311
315
|
});
|
|
312
316
|
|
|
313
|
-
editor.
|
|
317
|
+
editor.commands.selectAll();
|
|
318
|
+
editor.commands.applyPreset('h1');
|
|
314
319
|
|
|
315
320
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
316
321
|
});
|
|
@@ -326,7 +331,8 @@ describe('apply preset', () => {
|
|
|
326
331
|
presets: [createPreset({ id: 'regular-1' })]
|
|
327
332
|
});
|
|
328
333
|
|
|
329
|
-
editor.
|
|
334
|
+
editor.commands.selectAll();
|
|
335
|
+
editor.commands.applyPreset('regular-1');
|
|
330
336
|
|
|
331
337
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
332
338
|
});
|
|
@@ -344,7 +350,8 @@ describe('apply preset', () => {
|
|
|
344
350
|
]
|
|
345
351
|
});
|
|
346
352
|
|
|
347
|
-
editor.
|
|
353
|
+
editor.commands.selectAll();
|
|
354
|
+
editor.commands.applyPreset('h1');
|
|
348
355
|
|
|
349
356
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
350
357
|
});
|
|
@@ -358,7 +365,8 @@ describe('apply preset', () => {
|
|
|
358
365
|
defaultId: 'regular-1'
|
|
359
366
|
});
|
|
360
367
|
|
|
361
|
-
editor.
|
|
368
|
+
editor.commands.selectAll();
|
|
369
|
+
editor.commands.applyDefaultPreset();
|
|
362
370
|
|
|
363
371
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
364
372
|
});
|
|
@@ -377,7 +385,8 @@ describe('apply preset', () => {
|
|
|
377
385
|
]
|
|
378
386
|
});
|
|
379
387
|
|
|
380
|
-
editor.
|
|
388
|
+
editor.commands.selectAll();
|
|
389
|
+
editor.commands.applyPreset('regular-2');
|
|
381
390
|
|
|
382
391
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
383
392
|
});
|
|
@@ -396,21 +405,6 @@ describe('get preset customization', () => {
|
|
|
396
405
|
expect(customization.value).toMatchSnapshot();
|
|
397
406
|
});
|
|
398
407
|
|
|
399
|
-
test('should not is setting customized', async () => {
|
|
400
|
-
const editor = await createEditor({
|
|
401
|
-
content: NodeFactory.doc([
|
|
402
|
-
NodeFactory.paragraph({ preset: { id: 'regular-1' } }, 'test')
|
|
403
|
-
]),
|
|
404
|
-
presets: [createPreset({ id: 'regular-1' })]
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
const isFontSizeCustomized = editor.commands.isSettingCustomized('marks', TextSettings.FONT_SIZE);
|
|
408
|
-
const isAlignmentCustomized = editor.commands.isSettingCustomized('attributes', TextSettings.ALIGNMENT);
|
|
409
|
-
|
|
410
|
-
expect(isFontSizeCustomized.value).toBe(false);
|
|
411
|
-
expect(isAlignmentCustomized.value).toBe(false);
|
|
412
|
-
});
|
|
413
|
-
|
|
414
408
|
test('should find marks', async () => {
|
|
415
409
|
const editor = await createEditor({
|
|
416
410
|
content: NodeFactory.doc([
|
|
@@ -431,25 +425,6 @@ describe('get preset customization', () => {
|
|
|
431
425
|
expect(customization.value).toMatchSnapshot();
|
|
432
426
|
});
|
|
433
427
|
|
|
434
|
-
test('should is marks setting customized', async () => {
|
|
435
|
-
const editor = await createEditor({
|
|
436
|
-
content: NodeFactory.doc([
|
|
437
|
-
NodeFactory.paragraph({ preset: { id: 'regular-1' } }, [
|
|
438
|
-
NodeFactory.text('test', [
|
|
439
|
-
NodeFactory.mark(TextSettings.FONT_SIZE, { value: '12' }),
|
|
440
|
-
NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '400' })
|
|
441
|
-
])
|
|
442
|
-
])
|
|
443
|
-
]),
|
|
444
|
-
presets: [createPreset({ id: 'regular-1' })]
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
editor.commands.selectAll();
|
|
448
|
-
const isFontSizeCustomized = editor.commands.isSettingCustomized('marks', TextSettings.FONT_SIZE);
|
|
449
|
-
|
|
450
|
-
expect(isFontSizeCustomized.value).toBe(true);
|
|
451
|
-
});
|
|
452
|
-
|
|
453
428
|
test('should find attributes', async () => {
|
|
454
429
|
const editor = await createEditor({
|
|
455
430
|
content: NodeFactory.doc([
|
|
@@ -467,23 +442,6 @@ describe('get preset customization', () => {
|
|
|
467
442
|
|
|
468
443
|
expect(customization.value).toMatchSnapshot();
|
|
469
444
|
});
|
|
470
|
-
|
|
471
|
-
test('should is attributes setting customized', async () => {
|
|
472
|
-
const editor = await createEditor({
|
|
473
|
-
content: NodeFactory.doc([
|
|
474
|
-
NodeFactory.paragraph({
|
|
475
|
-
preset: { id: 'regular-1' },
|
|
476
|
-
alignment: { value: 'center' }
|
|
477
|
-
}, 'test')
|
|
478
|
-
]),
|
|
479
|
-
presets: [createPreset({ id: 'regular-1' })]
|
|
480
|
-
});
|
|
481
|
-
|
|
482
|
-
editor.commands.selectAll();
|
|
483
|
-
const isAlignmentCustomized = editor.commands.isSettingCustomized('attributes', TextSettings.ALIGNMENT);
|
|
484
|
-
|
|
485
|
-
expect(isAlignmentCustomized.value).toBe(true);
|
|
486
|
-
});
|
|
487
445
|
});
|
|
488
446
|
|
|
489
447
|
describe('remove preset customization', () => {
|
|
@@ -503,11 +461,8 @@ describe('remove preset customization', () => {
|
|
|
503
461
|
presets: [createPreset({ id: 'regular-1' })]
|
|
504
462
|
});
|
|
505
463
|
|
|
506
|
-
editor
|
|
507
|
-
|
|
508
|
-
.setTextSelection({ from: 1, to: 2 })
|
|
509
|
-
.removePresetCustomization()
|
|
510
|
-
.run();
|
|
464
|
+
editor.commands.setTextSelection({ from: 1, to: 2 });
|
|
465
|
+
editor.commands.removePresetCustomization();
|
|
511
466
|
|
|
512
467
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
513
468
|
});
|
|
@@ -529,11 +484,8 @@ describe('remove preset customization', () => {
|
|
|
529
484
|
presets: [createPreset({ id: 'regular-1' })]
|
|
530
485
|
});
|
|
531
486
|
|
|
532
|
-
editor
|
|
533
|
-
|
|
534
|
-
.setTextSelection({ from: 1, to: 10 })
|
|
535
|
-
.removePresetCustomization()
|
|
536
|
-
.run();
|
|
487
|
+
editor.commands.setTextSelection({ from: 1, to: 10 });
|
|
488
|
+
editor.commands.removePresetCustomization();
|
|
537
489
|
|
|
538
490
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
539
491
|
});
|
|
@@ -554,11 +506,8 @@ describe('remove preset customization', () => {
|
|
|
554
506
|
presets: [createPreset({ id: 'regular-1' })]
|
|
555
507
|
});
|
|
556
508
|
|
|
557
|
-
editor
|
|
558
|
-
|
|
559
|
-
.setTextSelection({ from: 1, to: 2 })
|
|
560
|
-
.removePresetCustomization()
|
|
561
|
-
.run();
|
|
509
|
+
editor.commands.setTextSelection({ from: 1, to: 2 });
|
|
510
|
+
editor.commands.removePresetCustomization();
|
|
562
511
|
|
|
563
512
|
expect(editor.state.selection).toEqual(
|
|
564
513
|
expect.objectContaining({ from: 1, to: 2 })
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Editor, Extension } from '@tiptap/vue-2';
|
|
2
2
|
import { ref } from 'vue';
|
|
3
|
+
import { buildTestExtensions } from '../../__tests__/utils';
|
|
3
4
|
import { createCommand } from '../../utils';
|
|
4
5
|
import { TextDecoration } from '../TextDecoration';
|
|
5
6
|
import { ContentNormalizer, NodeFactory } from '../../services';
|
|
6
|
-
import { buildCoreExtensions } from '../core';
|
|
7
7
|
import { TextSettings } from '../../enums';
|
|
8
8
|
|
|
9
9
|
const MockStylePreset = Extension.create({
|
|
@@ -21,7 +21,9 @@ const MockStylePreset = Extension.create({
|
|
|
21
21
|
function createEditor({ content }) {
|
|
22
22
|
return new Editor({
|
|
23
23
|
content: ContentNormalizer.normalize(content),
|
|
24
|
-
extensions:
|
|
24
|
+
extensions: buildTestExtensions({
|
|
25
|
+
include: [MockStylePreset, TextDecoration]
|
|
26
|
+
})
|
|
25
27
|
});
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -40,6 +42,8 @@ describe('get decoration', () => {
|
|
|
40
42
|
]))
|
|
41
43
|
});
|
|
42
44
|
|
|
45
|
+
editor.commands.selectAll();
|
|
46
|
+
|
|
43
47
|
expect(editor.commands.getTextDecoration().value).toEqual({
|
|
44
48
|
underline: true,
|
|
45
49
|
strike_through: true
|
|
@@ -70,17 +74,6 @@ describe('get decoration', () => {
|
|
|
70
74
|
expect(editor.commands.isUnderline().value).toBe(true);
|
|
71
75
|
});
|
|
72
76
|
|
|
73
|
-
test('should is customized settings', () => {
|
|
74
|
-
const editor = createEditor({
|
|
75
|
-
content: createContent(NodeFactory.text('hello world', [
|
|
76
|
-
NodeFactory.mark(TextSettings.TEXT_DECORATION, { underline: true })
|
|
77
|
-
]))
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
editor.commands.selectAll();
|
|
81
|
-
expect(editor.commands.isUnderlineCustomized().value).toBe(true);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
77
|
test('should get from preset', () => {
|
|
85
78
|
const editor = createEditor({
|
|
86
79
|
content: createContent(NodeFactory.text('hello world'))
|
|
@@ -90,15 +83,6 @@ describe('get decoration', () => {
|
|
|
90
83
|
|
|
91
84
|
expect(editor.commands.isUnderline().value).toBe(false);
|
|
92
85
|
});
|
|
93
|
-
|
|
94
|
-
test('should not is customized settings', () => {
|
|
95
|
-
const editor = createEditor({
|
|
96
|
-
content: createContent(NodeFactory.text('hello world'))
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
editor.commands.selectAll();
|
|
100
|
-
expect(editor.commands.isUnderlineCustomized().value).toBe(false);
|
|
101
|
-
});
|
|
102
86
|
});
|
|
103
87
|
|
|
104
88
|
describe('strike through', () => {
|
|
@@ -132,22 +116,62 @@ describe('apply decoration', () => {
|
|
|
132
116
|
content: createContent(NodeFactory.text('hello world'))
|
|
133
117
|
});
|
|
134
118
|
|
|
135
|
-
editor.
|
|
119
|
+
editor.commands.selectAll();
|
|
120
|
+
editor.commands.applyTextDecoration('underline');
|
|
136
121
|
|
|
137
122
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
138
123
|
});
|
|
139
124
|
|
|
140
125
|
test('should second decoration', () => {
|
|
141
126
|
const editor = createEditor({
|
|
142
|
-
content:
|
|
143
|
-
NodeFactory.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
127
|
+
content: NodeFactory.doc([
|
|
128
|
+
NodeFactory.paragraph(null, [
|
|
129
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, {
|
|
130
|
+
underline: true,
|
|
131
|
+
strike_through: false
|
|
132
|
+
})
|
|
133
|
+
], 'hello world')
|
|
134
|
+
])
|
|
148
135
|
});
|
|
149
136
|
|
|
150
|
-
editor.
|
|
137
|
+
editor.commands.selectAll();
|
|
138
|
+
editor.commands.applyTextDecoration('strike_through');
|
|
139
|
+
|
|
140
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('should not apply decoration with decorated parent', () => {
|
|
144
|
+
const editor = createEditor({
|
|
145
|
+
content: NodeFactory.doc([
|
|
146
|
+
NodeFactory.paragraph(null, [
|
|
147
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, {
|
|
148
|
+
underline: true,
|
|
149
|
+
strike_through: false
|
|
150
|
+
})
|
|
151
|
+
], 'hello world')
|
|
152
|
+
])
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
editor.commands.setTextSelection({ from: 1, to: 6 });
|
|
156
|
+
editor.commands.applyTextDecoration('underline');
|
|
157
|
+
|
|
158
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test('should apply decoration with decorated parent false value', () => {
|
|
162
|
+
const editor = createEditor({
|
|
163
|
+
content: NodeFactory.doc([
|
|
164
|
+
NodeFactory.paragraph(null, [
|
|
165
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, {
|
|
166
|
+
underline: false,
|
|
167
|
+
strike_through: false
|
|
168
|
+
})
|
|
169
|
+
], 'hello world')
|
|
170
|
+
])
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
editor.commands.setTextSelection({ from: 1, to: 6 });
|
|
174
|
+
editor.commands.applyTextDecoration('underline');
|
|
151
175
|
|
|
152
176
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
153
177
|
});
|
|
@@ -155,15 +179,15 @@ describe('apply decoration', () => {
|
|
|
155
179
|
describe('underline', () => {
|
|
156
180
|
test('should toggle to removed', () => {
|
|
157
181
|
const editor = createEditor({
|
|
158
|
-
content:
|
|
159
|
-
NodeFactory.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
]))
|
|
182
|
+
content: NodeFactory.doc([
|
|
183
|
+
NodeFactory.paragraph(null, [
|
|
184
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, { underline: true })
|
|
185
|
+
], 'lorem ipsum')
|
|
186
|
+
])
|
|
164
187
|
});
|
|
165
188
|
|
|
166
|
-
editor.
|
|
189
|
+
editor.commands.selectAll();
|
|
190
|
+
editor.commands.toggleUnderline();
|
|
167
191
|
|
|
168
192
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
169
193
|
});
|
|
@@ -173,7 +197,8 @@ describe('apply decoration', () => {
|
|
|
173
197
|
content: createContent(NodeFactory.text('hello world'))
|
|
174
198
|
});
|
|
175
199
|
|
|
176
|
-
editor.
|
|
200
|
+
editor.commands.selectAll();
|
|
201
|
+
editor.commands.toggleUnderline();
|
|
177
202
|
|
|
178
203
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
179
204
|
});
|
|
@@ -182,15 +207,15 @@ describe('apply decoration', () => {
|
|
|
182
207
|
describe('strike through', () => {
|
|
183
208
|
test('should toggle to removed', () => {
|
|
184
209
|
const editor = createEditor({
|
|
185
|
-
content:
|
|
186
|
-
NodeFactory.
|
|
187
|
-
strike_through: true
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
]))
|
|
210
|
+
content: NodeFactory.doc([
|
|
211
|
+
NodeFactory.paragraph(null, [
|
|
212
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, { strike_through: true })
|
|
213
|
+
], 'lorem ipsum')
|
|
214
|
+
])
|
|
191
215
|
});
|
|
192
216
|
|
|
193
|
-
editor.
|
|
217
|
+
editor.commands.selectAll();
|
|
218
|
+
editor.commands.toggleStrikeThrough();
|
|
194
219
|
|
|
195
220
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
196
221
|
});
|
|
@@ -200,7 +225,8 @@ describe('apply decoration', () => {
|
|
|
200
225
|
content: createContent(NodeFactory.text('hello world'))
|
|
201
226
|
});
|
|
202
227
|
|
|
203
|
-
editor.
|
|
228
|
+
editor.commands.selectAll();
|
|
229
|
+
editor.commands.toggleStrikeThrough();
|
|
204
230
|
|
|
205
231
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
206
232
|
});
|
|
@@ -6,18 +6,18 @@ Object {
|
|
|
6
6
|
Object {
|
|
7
7
|
"content": Array [
|
|
8
8
|
Object {
|
|
9
|
-
"marks": Array [
|
|
10
|
-
Object {
|
|
11
|
-
"attrs": Object {
|
|
12
|
-
"value": "green",
|
|
13
|
-
},
|
|
14
|
-
"type": "background_color",
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
9
|
"text": "hello world",
|
|
18
10
|
"type": "text",
|
|
19
11
|
},
|
|
20
12
|
],
|
|
13
|
+
"marks": Array [
|
|
14
|
+
Object {
|
|
15
|
+
"attrs": Object {
|
|
16
|
+
"value": "green",
|
|
17
|
+
},
|
|
18
|
+
"type": "background_color",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
21
|
"type": "paragraph",
|
|
22
22
|
},
|
|
23
23
|
],
|
|
@@ -31,18 +31,18 @@ Object {
|
|
|
31
31
|
Object {
|
|
32
32
|
"content": Array [
|
|
33
33
|
Object {
|
|
34
|
-
"marks": Array [
|
|
35
|
-
Object {
|
|
36
|
-
"attrs": Object {
|
|
37
|
-
"value": "#FF0000",
|
|
38
|
-
},
|
|
39
|
-
"type": "background_color",
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
34
|
"text": "test",
|
|
43
35
|
"type": "text",
|
|
44
36
|
},
|
|
45
37
|
],
|
|
38
|
+
"marks": Array [
|
|
39
|
+
Object {
|
|
40
|
+
"attrs": Object {
|
|
41
|
+
"value": "#FF0000",
|
|
42
|
+
},
|
|
43
|
+
"type": "background_color",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
46
|
"type": "paragraph",
|
|
47
47
|
},
|
|
48
48
|
],
|
|
@@ -126,18 +126,18 @@ Object {
|
|
|
126
126
|
"type": "text",
|
|
127
127
|
},
|
|
128
128
|
Object {
|
|
129
|
-
"marks": Array [
|
|
130
|
-
Object {
|
|
131
|
-
"attrs": Object {
|
|
132
|
-
"value": "#FF0000",
|
|
133
|
-
},
|
|
134
|
-
"type": "background_color",
|
|
135
|
-
},
|
|
136
|
-
],
|
|
137
129
|
"text": " ipsum",
|
|
138
130
|
"type": "text",
|
|
139
131
|
},
|
|
140
132
|
],
|
|
133
|
+
"marks": Array [
|
|
134
|
+
Object {
|
|
135
|
+
"attrs": Object {
|
|
136
|
+
"value": "#FF0000",
|
|
137
|
+
},
|
|
138
|
+
"type": "background_color",
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
141
|
"type": "paragraph",
|
|
142
142
|
},
|
|
143
143
|
],
|
|
@@ -6,18 +6,18 @@ Object {
|
|
|
6
6
|
Object {
|
|
7
7
|
"content": Array [
|
|
8
8
|
Object {
|
|
9
|
-
"marks": Array [
|
|
10
|
-
Object {
|
|
11
|
-
"attrs": Object {
|
|
12
|
-
"value": "green",
|
|
13
|
-
},
|
|
14
|
-
"type": "font_color",
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
9
|
"text": "hello world",
|
|
18
10
|
"type": "text",
|
|
19
11
|
},
|
|
20
12
|
],
|
|
13
|
+
"marks": Array [
|
|
14
|
+
Object {
|
|
15
|
+
"attrs": Object {
|
|
16
|
+
"value": "green",
|
|
17
|
+
},
|
|
18
|
+
"type": "font_color",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
21
|
"type": "paragraph",
|
|
22
22
|
},
|
|
23
23
|
],
|
|
@@ -31,18 +31,18 @@ Object {
|
|
|
31
31
|
Object {
|
|
32
32
|
"content": Array [
|
|
33
33
|
Object {
|
|
34
|
-
"marks": Array [
|
|
35
|
-
Object {
|
|
36
|
-
"attrs": Object {
|
|
37
|
-
"value": "#FF0000",
|
|
38
|
-
},
|
|
39
|
-
"type": "font_color",
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
34
|
"text": "test",
|
|
43
35
|
"type": "text",
|
|
44
36
|
},
|
|
45
37
|
],
|
|
38
|
+
"marks": Array [
|
|
39
|
+
Object {
|
|
40
|
+
"attrs": Object {
|
|
41
|
+
"value": "#FF0000",
|
|
42
|
+
},
|
|
43
|
+
"type": "font_color",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
46
|
"type": "paragraph",
|
|
47
47
|
},
|
|
48
48
|
],
|
|
@@ -114,18 +114,18 @@ Object {
|
|
|
114
114
|
"type": "text",
|
|
115
115
|
},
|
|
116
116
|
Object {
|
|
117
|
-
"marks": Array [
|
|
118
|
-
Object {
|
|
119
|
-
"attrs": Object {
|
|
120
|
-
"value": "#FF0000",
|
|
121
|
-
},
|
|
122
|
-
"type": "font_color",
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
117
|
"text": " ipsum",
|
|
126
118
|
"type": "text",
|
|
127
119
|
},
|
|
128
120
|
],
|
|
121
|
+
"marks": Array [
|
|
122
|
+
Object {
|
|
123
|
+
"attrs": Object {
|
|
124
|
+
"value": "#FF0000",
|
|
125
|
+
},
|
|
126
|
+
"type": "font_color",
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
129
|
"type": "paragraph",
|
|
130
130
|
},
|
|
131
131
|
],
|