@zipify/wysiwyg 1.3.0-0 → 2.0.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/.eslintrc.js +1 -1
- package/config/build/lib.config.js +4 -2
- package/dist/cli.js +10 -2
- package/dist/wysiwyg.css +43 -48
- package/dist/wysiwyg.mjs +1928 -787
- package/example/ExampleApp.vue +3 -1
- 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/StylePresetControl.vue +1 -1
- 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__/StylePresetControl.test.js +2 -2
- 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/enums/TextSettings.js +5 -5
- 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/Link.js +1 -1
- package/lib/extensions/StylePreset.js +1 -15
- package/lib/extensions/Superscript.js +23 -1
- package/lib/extensions/TextDecoration.js +16 -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 +28 -21
- 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 +59 -37
- package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +25 -25
- package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +25 -25
- package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +105 -105
- package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +72 -72
- package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +54 -46
- package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +77 -77
- package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +68 -3
- package/lib/extensions/core/Document.js +5 -0
- package/lib/extensions/core/Heading.js +10 -0
- package/lib/extensions/core/NodeProcessor.js +112 -10
- package/lib/extensions/core/Paragraph.js +9 -0
- package/lib/extensions/core/TextProcessor.js +9 -16
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +137 -10
- package/lib/extensions/core/__tests__/SelectionProcessor.test.js +2 -2
- package/lib/extensions/core/__tests__/TextProcessor.test.js +18 -41
- package/lib/extensions/core/__tests__/__snapshots__/NodeProcessor.test.js.snap +192 -0
- package/lib/extensions/core/__tests__/__snapshots__/TextProcessor.test.js.snap +7 -27
- package/lib/extensions/core/index.js +5 -5
- package/lib/extensions/core/steps/AddNodeMarkStep.js +60 -0
- package/lib/extensions/core/steps/AttrStep.js +54 -0
- package/lib/extensions/core/steps/RemoveNodeMarkStep.js +50 -0
- package/lib/extensions/core/steps/index.js +3 -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/NodeFactory.js +25 -21
- package/lib/services/index.js +1 -1
- package/lib/services/normalizer/BaseNormalizer.js +11 -0
- package/lib/services/{BrowserDomParser.js → normalizer/BrowserDomParser.js} +0 -0
- package/lib/services/normalizer/ContentNormalizer.js +24 -0
- package/lib/services/normalizer/HtmlNormalizer.js +245 -0
- package/lib/services/normalizer/JsonNormalizer.js +81 -0
- package/lib/services/{__tests__/ContentNormalizer.test.js → normalizer/__tests__/HtmlNormalizer.test.js} +27 -67
- package/lib/services/normalizer/__tests__/JsonNormalizer.test.js +70 -0
- package/lib/services/normalizer/__tests__/__snapshots__/JsonNormalizer.test.js.snap +159 -0
- package/lib/services/normalizer/index.js +1 -0
- package/lib/styles/content.css +8 -0
- package/lib/utils/findMarkByType.js +5 -0
- package/lib/utils/index.js +5 -0
- package/lib/utils/isMarkAppliedToParent.js +10 -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 +3 -1
- package/lib/assets/icons/indicator.svg +0 -5
- package/lib/services/ContentNormalizer.js +0 -293
|
@@ -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,7 +116,8 @@ 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
|
});
|
|
@@ -141,13 +126,52 @@ describe('apply decoration', () => {
|
|
|
141
126
|
const editor = createEditor({
|
|
142
127
|
content: createContent(NodeFactory.text('hello world', [
|
|
143
128
|
NodeFactory.mark(TextSettings.TEXT_DECORATION, {
|
|
144
|
-
strike_through:
|
|
129
|
+
strike_through: true,
|
|
145
130
|
underline: true
|
|
146
131
|
})
|
|
147
132
|
]))
|
|
148
133
|
});
|
|
149
134
|
|
|
150
|
-
editor.
|
|
135
|
+
editor.commands.selectAll();
|
|
136
|
+
editor.commands.applyTextDecoration('strike_through');
|
|
137
|
+
|
|
138
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test('should not apply decoration with decorated parent', () => {
|
|
142
|
+
const editor = createEditor({
|
|
143
|
+
content: NodeFactory.doc([
|
|
144
|
+
NodeFactory.paragraph([
|
|
145
|
+
NodeFactory.text('hello world', [
|
|
146
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, {
|
|
147
|
+
underline: true,
|
|
148
|
+
strike_through: false
|
|
149
|
+
})
|
|
150
|
+
])
|
|
151
|
+
])
|
|
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
|
});
|
|
@@ -156,14 +180,12 @@ describe('apply decoration', () => {
|
|
|
156
180
|
test('should toggle to removed', () => {
|
|
157
181
|
const editor = createEditor({
|
|
158
182
|
content: createContent(NodeFactory.text('hello world', [
|
|
159
|
-
NodeFactory.mark(TextSettings.TEXT_DECORATION, {
|
|
160
|
-
strike_through: true,
|
|
161
|
-
underline: true
|
|
162
|
-
})
|
|
183
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, { underline: true })
|
|
163
184
|
]))
|
|
164
185
|
});
|
|
165
186
|
|
|
166
|
-
editor.
|
|
187
|
+
editor.commands.selectAll();
|
|
188
|
+
editor.commands.toggleUnderline();
|
|
167
189
|
|
|
168
190
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
169
191
|
});
|
|
@@ -173,7 +195,8 @@ describe('apply decoration', () => {
|
|
|
173
195
|
content: createContent(NodeFactory.text('hello world'))
|
|
174
196
|
});
|
|
175
197
|
|
|
176
|
-
editor.
|
|
198
|
+
editor.commands.selectAll();
|
|
199
|
+
editor.commands.toggleUnderline();
|
|
177
200
|
|
|
178
201
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
179
202
|
});
|
|
@@ -183,14 +206,12 @@ describe('apply decoration', () => {
|
|
|
183
206
|
test('should toggle to removed', () => {
|
|
184
207
|
const editor = createEditor({
|
|
185
208
|
content: createContent(NodeFactory.text('hello world', [
|
|
186
|
-
NodeFactory.mark(TextSettings.TEXT_DECORATION, {
|
|
187
|
-
strike_through: true,
|
|
188
|
-
underline: true
|
|
189
|
-
})
|
|
209
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, { strike_through: true })
|
|
190
210
|
]))
|
|
191
211
|
});
|
|
192
212
|
|
|
193
|
-
editor.
|
|
213
|
+
editor.commands.selectAll();
|
|
214
|
+
editor.commands.toggleStrikeThrough();
|
|
194
215
|
|
|
195
216
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
196
217
|
});
|
|
@@ -200,7 +221,8 @@ describe('apply decoration', () => {
|
|
|
200
221
|
content: createContent(NodeFactory.text('hello world'))
|
|
201
222
|
});
|
|
202
223
|
|
|
203
|
-
editor.
|
|
224
|
+
editor.commands.selectAll();
|
|
225
|
+
editor.commands.toggleStrikeThrough();
|
|
204
226
|
|
|
205
227
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
206
228
|
});
|
|
@@ -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
|
],
|
|
@@ -145,4 +145,4 @@ Object {
|
|
|
145
145
|
}
|
|
146
146
|
`;
|
|
147
147
|
|
|
148
|
-
exports[`rendering should render html 1`] = `"<
|
|
148
|
+
exports[`rendering should render html 1`] = `"<span style="--zw-background-color:green;" class="zw-style"><p class="zw-style">hello world</p></span>"`;
|
|
@@ -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
|
],
|
|
@@ -133,4 +133,4 @@ Object {
|
|
|
133
133
|
}
|
|
134
134
|
`;
|
|
135
135
|
|
|
136
|
-
exports[`rendering should render html 1`] = `"<
|
|
136
|
+
exports[`rendering should render html 1`] = `"<span style="--zw-font-color:green;" class="zw-style"><p class="zw-style">hello world</p></span>"`;
|