@zipify/wysiwyg 2.0.0-1 → 2.0.0-11

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.
Files changed (97) hide show
  1. package/config/build/cli.config.js +8 -2
  2. package/dist/cli.js +3 -3
  3. package/dist/wysiwyg.css +41 -31
  4. package/dist/wysiwyg.mjs +2015 -1359
  5. package/example/ExampleApp.vue +10 -1
  6. package/lib/Wysiwyg.vue +3 -2
  7. package/lib/__tests__/utils/buildTestExtensions.js +2 -1
  8. package/lib/assets/icons/indicator.svg +4 -0
  9. package/lib/cli/commands/Command.js +39 -0
  10. package/lib/cli/commands/ToJsonCommand.js +55 -0
  11. package/lib/cli/commands/VersionCommand.js +11 -0
  12. package/lib/cli/commands/index.js +2 -0
  13. package/lib/cli/index.js +1 -0
  14. package/lib/components/base/Button.vue +6 -0
  15. package/lib/components/base/dropdown/Dropdown.vue +7 -1
  16. package/lib/components/base/dropdown/DropdownActivator.vue +25 -4
  17. package/lib/components/base/dropdown/__tests__/DropdownActivator.test.js +23 -1
  18. package/lib/components/toolbar/controls/AlignmentControl.vue +12 -1
  19. package/lib/components/toolbar/controls/FontColorControl.vue +14 -0
  20. package/lib/components/toolbar/controls/FontFamilyControl.vue +4 -0
  21. package/lib/components/toolbar/controls/FontSizeControl.vue +6 -1
  22. package/lib/components/toolbar/controls/FontWeightControl.vue +12 -0
  23. package/lib/components/toolbar/controls/ItalicControl.vue +14 -0
  24. package/lib/components/toolbar/controls/LineHeightControl.vue +15 -0
  25. package/lib/components/toolbar/controls/UnderlineControl.vue +13 -0
  26. package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +72 -5
  27. package/lib/components/toolbar/controls/__tests__/FontColorControl.test.js +22 -1
  28. package/lib/components/toolbar/controls/__tests__/FontFamilyControl.test.js +1 -0
  29. package/lib/components/toolbar/controls/__tests__/FontSizeControl.test.js +1 -0
  30. package/lib/components/toolbar/controls/__tests__/FontWeightControl.test.js +1 -0
  31. package/lib/components/toolbar/controls/__tests__/ItalicControl.test.js +23 -1
  32. package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +23 -1
  33. package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +4 -4
  34. package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +25 -1
  35. package/lib/composables/__tests__/useEditor.test.js +1 -1
  36. package/lib/composables/useEditor.js +9 -8
  37. package/lib/directives/__tests__/tooltip.test.js +22 -4
  38. package/lib/directives/tooltip.js +4 -1
  39. package/lib/entry-cli.js +7 -20
  40. package/lib/entry-lib.js +1 -1
  41. package/lib/enums/MarkGroups.js +4 -0
  42. package/lib/enums/TextSettings.js +1 -1
  43. package/lib/enums/index.js +1 -0
  44. package/lib/extensions/BackgroundColor.js +0 -1
  45. package/lib/extensions/FontColor.js +2 -2
  46. package/lib/extensions/FontFamily.js +3 -3
  47. package/lib/extensions/FontSize.js +2 -2
  48. package/lib/extensions/FontStyle.js +2 -2
  49. package/lib/extensions/FontWeight.js +2 -2
  50. package/lib/extensions/StylePreset.js +9 -2
  51. package/lib/extensions/Superscript.js +5 -2
  52. package/lib/extensions/TextDecoration.js +7 -0
  53. package/lib/extensions/__tests__/Alignment.test.js +2 -2
  54. package/lib/extensions/__tests__/BackgroundColor.test.js +4 -3
  55. package/lib/extensions/__tests__/FontColor.test.js +4 -3
  56. package/lib/extensions/__tests__/FontFamily.test.js +6 -6
  57. package/lib/extensions/__tests__/FontSize.test.js +9 -8
  58. package/lib/extensions/__tests__/FontStyle.test.js +6 -5
  59. package/lib/extensions/__tests__/LineHeight.test.js +2 -1
  60. package/lib/extensions/__tests__/StylePreset.test.js +51 -0
  61. package/lib/extensions/__tests__/Superscript.test.js +102 -0
  62. package/lib/extensions/__tests__/TextDecoration.test.js +20 -0
  63. package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +25 -25
  64. package/lib/extensions/__tests__/__snapshots__/Superscript.test.js.snap +107 -0
  65. package/lib/extensions/core/Document.js +2 -1
  66. package/lib/extensions/core/Heading.js +2 -1
  67. package/lib/extensions/core/NodeProcessor.js +42 -21
  68. package/lib/extensions/core/Paragraph.js +2 -1
  69. package/lib/extensions/core/__tests__/NodeProcessor.test.js +309 -11
  70. package/lib/extensions/core/__tests__/TextProcessor.test.js +1 -1
  71. package/lib/extensions/core/__tests__/__snapshots__/NodeProcessor.test.js.snap +249 -0
  72. package/lib/extensions/core/steps/AddNodeMarkStep.js +6 -0
  73. package/lib/extensions/core/steps/AttrStep.js +6 -0
  74. package/lib/extensions/core/steps/RemoveNodeMarkStep.js +6 -0
  75. package/lib/extensions/list/List.js +70 -9
  76. package/lib/extensions/list/ListItem.js +27 -5
  77. package/lib/extensions/list/__tests__/List.test.js +26 -17
  78. package/lib/extensions/list/__tests__/__snapshots__/List.test.js.snap +36 -36
  79. package/lib/services/NodeFactory.js +69 -3
  80. package/lib/services/__tests__/NodeFactory.test.js +124 -0
  81. package/lib/services/__tests__/__snapshots__/NodeFactory.test.js.snap +326 -0
  82. package/lib/services/normalizer/HtmlNormalizer.js +54 -2
  83. package/lib/services/normalizer/JsonNormalizer.js +6 -5
  84. package/lib/services/normalizer/__tests__/HtmlNormalizer.test.js +14 -0
  85. package/lib/services/normalizer/__tests__/JsonNormalizer.test.js +20 -3
  86. package/lib/services/normalizer/__tests__/__snapshots__/JsonNormalizer.test.js.snap +37 -0
  87. package/lib/utils/__tests__/findMarkByType.test.js +17 -0
  88. package/lib/utils/__tests__/isMarkAppliedToParent.test.js +53 -0
  89. package/lib/utils/__tests__/isNodeFullySelected.test.js +44 -0
  90. package/lib/utils/__tests__/resolveTextPosition.test.js +39 -0
  91. package/lib/utils/copyMark.js +5 -0
  92. package/lib/utils/index.js +1 -1
  93. package/lib/utils/isMarkAppliedToParent.js +1 -1
  94. package/lib/utils/isNodeFullySelected.js +4 -7
  95. package/lib/utils/resolveTextPosition.js +4 -6
  96. package/package.json +37 -27
  97. package/lib/utils/resolveNodePosition.js +0 -6
@@ -41,6 +41,13 @@ export const TextDecoration = Mark.create({
41
41
  });
42
42
  }),
43
43
 
44
+ isUnderlineCustomized: createCommand(({ commands }) => {
45
+ const currentValue = commands.isUnderline();
46
+ const defaultValue = commands.getDefaultTextDecoration();
47
+
48
+ return computed(() => unref(currentValue) !== unref(defaultValue).underline);
49
+ }),
50
+
44
51
  getDefaultTextDecoration: createCommand(({ commands }) => {
45
52
  const preset = commands.getPreset();
46
53
 
@@ -4,11 +4,11 @@ import { buildTestExtensions } from '../../__tests__/utils';
4
4
  import { createCommand } from '../../utils';
5
5
  import { Alignment } from '../Alignment';
6
6
  import { DeviceManager } from '../DeviceManager';
7
- import { Alignments } from '../../enums';
7
+ import { Alignments, TextSettings } from '../../enums';
8
8
  import { ContentNormalizer, NodeFactory } from '../../services';
9
9
 
10
10
  const MockStylePreset = Extension.create({
11
- name: 'style_preset',
11
+ name: TextSettings.STYLE_PRESET,
12
12
 
13
13
  addCommands() {
14
14
  return {
@@ -4,9 +4,10 @@ import { buildTestExtensions } from '../../__tests__/utils';
4
4
  import { createCommand } from '../../utils';
5
5
  import { BackgroundColor } from '../BackgroundColor';
6
6
  import { ContentNormalizer, NodeFactory } from '../../services';
7
+ import { TextSettings } from '../../enums';
7
8
 
8
9
  const MockStylePreset = Extension.create({
9
- name: 'style_preset',
10
+ name: TextSettings.STYLE_PRESET,
10
11
 
11
12
  addCommands() {
12
13
  return {
@@ -34,7 +35,7 @@ describe('get background color', () => {
34
35
  test('should get from selection', () => {
35
36
  const editor = createEditor({
36
37
  content: createContent(NodeFactory.text('hello world', [
37
- NodeFactory.mark('background_color', { value: 'green' })
38
+ NodeFactory.mark(TextSettings.BACKGROUND_COLOR, { value: 'green' })
38
39
  ]))
39
40
  });
40
41
 
@@ -69,7 +70,7 @@ describe('rendering', () => {
69
70
  test('should render html', () => {
70
71
  const editor = createEditor({
71
72
  content: createContent(NodeFactory.text('hello world', [
72
- NodeFactory.mark('background_color', { value: 'green' })
73
+ NodeFactory.mark(TextSettings.BACKGROUND_COLOR, { value: 'green' })
73
74
  ]))
74
75
  });
75
76
 
@@ -4,9 +4,10 @@ import { buildTestExtensions } from '../../__tests__/utils';
4
4
  import { createCommand } from '../../utils';
5
5
  import { FontColor } from '../FontColor';
6
6
  import { ContentNormalizer, NodeFactory } from '../../services';
7
+ import { TextSettings } from '../../enums';
7
8
 
8
9
  const MockStylePreset = Extension.create({
9
- name: 'style_preset',
10
+ name: TextSettings.STYLE_PRESET,
10
11
 
11
12
  addCommands() {
12
13
  return {
@@ -34,7 +35,7 @@ describe('get font color', () => {
34
35
  test('should get from selection', () => {
35
36
  const editor = createEditor({
36
37
  content: createContent(NodeFactory.text('hello world', [
37
- NodeFactory.mark('font_color', { value: 'green' })
38
+ NodeFactory.mark(TextSettings.FONT_COLOR, { value: 'green' })
38
39
  ]))
39
40
  });
40
41
 
@@ -79,7 +80,7 @@ describe('rendering', () => {
79
80
  test('should render html', () => {
80
81
  const editor = createEditor({
81
82
  content: createContent(NodeFactory.text('hello world', [
82
- NodeFactory.mark('font_color', { value: 'green' })
83
+ NodeFactory.mark(TextSettings.FONT_COLOR, { value: 'green' })
83
84
  ]))
84
85
  });
85
86
 
@@ -119,7 +119,7 @@ describe('apply font family', () => {
119
119
  test('should not change current font weight if available', () => {
120
120
  const editor = createEditor({
121
121
  content: createContent(NodeFactory.text('hello world', [
122
- NodeFactory.mark('font_weight', { value: '700' })
122
+ NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '700' })
123
123
  ]))
124
124
  });
125
125
 
@@ -132,7 +132,7 @@ describe('apply font family', () => {
132
132
  test('should apply closest font weight if current is unavailable', () => {
133
133
  const editor = createEditor({
134
134
  content: createContent(NodeFactory.text('hello world', [
135
- NodeFactory.mark('font_weight', { value: '700' })
135
+ NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '700' })
136
136
  ]))
137
137
  });
138
138
 
@@ -145,8 +145,8 @@ describe('apply font family', () => {
145
145
  test('should not change italic if available', () => {
146
146
  const editor = createEditor({
147
147
  content: createContent(NodeFactory.text('hello world', [
148
- NodeFactory.mark('font_weight', { value: '700' }),
149
- NodeFactory.mark('font_style', { italic: true })
148
+ NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '700' }),
149
+ NodeFactory.mark(TextSettings.FONT_STYLE, { italic: true })
150
150
  ]))
151
151
  });
152
152
 
@@ -159,8 +159,8 @@ describe('apply font family', () => {
159
159
  test('should remove italic if unavailable', () => {
160
160
  const editor = createEditor({
161
161
  content: createContent(NodeFactory.text('hello world', [
162
- NodeFactory.mark('font_weight', { value: '700' }),
163
- NodeFactory.mark('font_style', { italic: true })
162
+ NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '700' }),
163
+ NodeFactory.mark(TextSettings.FONT_STYLE, { italic: true })
164
164
  ]))
165
165
  });
166
166
 
@@ -5,9 +5,10 @@ import { createCommand } from '../../utils';
5
5
  import { FontSize } from '../FontSize';
6
6
  import { DeviceManager } from '../DeviceManager';
7
7
  import { ContentNormalizer, NodeFactory } from '../../services';
8
+ import { TextSettings } from '../../enums';
8
9
 
9
10
  const MockStylePreset = Extension.create({
10
- name: 'style_preset',
11
+ name: TextSettings.STYLE_PRESET,
11
12
 
12
13
  addCommands() {
13
14
  return {
@@ -47,7 +48,7 @@ describe('get font size', () => {
47
48
  test('should get from selection', () => {
48
49
  const editor = createEditor({
49
50
  content: createContent(NodeFactory.text('hello world'[
50
- NodeFactory.mark('font_size', {
51
+ NodeFactory.mark(TextSettings.FONT_SIZE, {
51
52
  mobile: null,
52
53
  tablet: null,
53
54
  desktop: '14'
@@ -94,7 +95,7 @@ describe('apply font size', () => {
94
95
  test('should increase font size', () => {
95
96
  const editor = createEditor({
96
97
  content: createContent(NodeFactory.text('hello world', [
97
- NodeFactory.mark('font_size', {
98
+ NodeFactory.mark(TextSettings.FONT_SIZE, {
98
99
  mobile: null,
99
100
  tablet: null,
100
101
  desktop: '14'
@@ -111,7 +112,7 @@ describe('apply font size', () => {
111
112
  test('should not increase font size if reached limit', () => {
112
113
  const editor = createEditor({
113
114
  content: createContent(NodeFactory.text('hello world', [
114
- NodeFactory.mark('font_size', {
115
+ NodeFactory.mark(TextSettings.FONT_SIZE, {
115
116
  mobile: null,
116
117
  tablet: null,
117
118
  desktop: '20'
@@ -128,7 +129,7 @@ describe('apply font size', () => {
128
129
  test('should decrease font size', () => {
129
130
  const editor = createEditor({
130
131
  content: createContent(NodeFactory.text('hello world', [
131
- NodeFactory.mark('font_size', {
132
+ NodeFactory.mark(TextSettings.FONT_SIZE, {
132
133
  mobile: null,
133
134
  tablet: null,
134
135
  desktop: '14'
@@ -145,7 +146,7 @@ describe('apply font size', () => {
145
146
  test('should not decrease font size if reached limit', () => {
146
147
  const editor = createEditor({
147
148
  content: createContent(NodeFactory.text('hello world', [
148
- NodeFactory.mark('font_size', {
149
+ NodeFactory.mark(TextSettings.FONT_SIZE, {
149
150
  mobile: null,
150
151
  tablet: null,
151
152
  desktop: '5'
@@ -164,7 +165,7 @@ describe('rendering', () => {
164
165
  test('should render only desktop', () => {
165
166
  const editor = createEditor({
166
167
  content: createContent(NodeFactory.text('hello world', [
167
- NodeFactory.mark('font_size', {
168
+ NodeFactory.mark(TextSettings.FONT_SIZE, {
168
169
  mobile: null,
169
170
  tablet: null,
170
171
  desktop: '14'
@@ -178,7 +179,7 @@ describe('rendering', () => {
178
179
  test('should render all devices', () => {
179
180
  const editor = createEditor({
180
181
  content: createContent(NodeFactory.text('hello world', [
181
- NodeFactory.mark('font_size', {
182
+ NodeFactory.mark(TextSettings.FONT_SIZE, {
182
183
  mobile: '12',
183
184
  tablet: '14',
184
185
  desktop: '16'
@@ -7,9 +7,10 @@ import { FontFamily } from '../FontFamily';
7
7
  import { Font } from '../../models';
8
8
  import { FontWeight } from '../FontWeight';
9
9
  import { ContentNormalizer, NodeFactory } from '../../services';
10
+ import { TextSettings } from '../../enums';
10
11
 
11
12
  const MockStylePreset = Extension.create({
12
- name: 'style_preset',
13
+ name: TextSettings.STYLE_PRESET,
13
14
 
14
15
  addCommands() {
15
16
  return {
@@ -51,7 +52,7 @@ describe('get font style', () => {
51
52
  test('should get italic from selection', () => {
52
53
  const editor = createEditor({
53
54
  content: createContent(NodeFactory.text('hello world', [
54
- NodeFactory.mark('font_style', { italic: true })
55
+ NodeFactory.mark(TextSettings.FONT_STYLE, { italic: true })
55
56
  ]))
56
57
  });
57
58
 
@@ -94,7 +95,7 @@ describe('apply font style', () => {
94
95
  test('should remove italic', () => {
95
96
  const editor = createEditor({
96
97
  content: createContent(NodeFactory.text('hello world', [
97
- NodeFactory.mark('font_style', { italic: true })
98
+ NodeFactory.mark(TextSettings.FONT_STYLE, { italic: true })
98
99
  ]))
99
100
  });
100
101
 
@@ -107,7 +108,7 @@ describe('apply font style', () => {
107
108
  test('should toggle italic to removed', () => {
108
109
  const editor = createEditor({
109
110
  content: createContent(NodeFactory.text('hello world', [
110
- NodeFactory.mark('font_style', { italic: true })
111
+ NodeFactory.mark(TextSettings.FONT_STYLE, { italic: true })
111
112
  ]))
112
113
  });
113
114
 
@@ -133,7 +134,7 @@ describe('rendering', () => {
133
134
  test('should render html', () => {
134
135
  const editor = createEditor({
135
136
  content: createContent(NodeFactory.text('hello world', [
136
- NodeFactory.mark('font_style', { italic: true })
137
+ NodeFactory.mark(TextSettings.FONT_STYLE, { italic: true })
137
138
  ]))
138
139
  });
139
140
 
@@ -5,9 +5,10 @@ import { createCommand } from '../../utils';
5
5
  import { DeviceManager } from '../DeviceManager';
6
6
  import { LineHeight } from '../LineHeight';
7
7
  import { ContentNormalizer, NodeFactory } from '../../services';
8
+ import { TextSettings } from '../../enums';
8
9
 
9
10
  const MockStylePreset = Extension.create({
10
- name: 'style_preset',
11
+ name: TextSettings.STYLE_PRESET,
11
12
 
12
13
  addCommands() {
13
14
  return {
@@ -405,6 +405,21 @@ describe('get preset customization', () => {
405
405
  expect(customization.value).toMatchSnapshot();
406
406
  });
407
407
 
408
+ test('should not is setting customized', async () => {
409
+ const editor = await createEditor({
410
+ content: NodeFactory.doc([
411
+ NodeFactory.paragraph({ preset: { id: 'regular-1' } }, 'test')
412
+ ]),
413
+ presets: [createPreset({ id: 'regular-1' })]
414
+ });
415
+
416
+ const isFontSizeCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_SIZE);
417
+ const isAlignmentCustomized = editor.commands.isSettingCustomized(TextSettings.ALIGNMENT);
418
+
419
+ expect(isFontSizeCustomized.value).toBe(false);
420
+ expect(isAlignmentCustomized.value).toBe(false);
421
+ });
422
+
408
423
  test('should find marks', async () => {
409
424
  const editor = await createEditor({
410
425
  content: NodeFactory.doc([
@@ -425,6 +440,25 @@ describe('get preset customization', () => {
425
440
  expect(customization.value).toMatchSnapshot();
426
441
  });
427
442
 
443
+ test('should is marks setting customized', async () => {
444
+ const editor = await createEditor({
445
+ content: NodeFactory.doc([
446
+ NodeFactory.paragraph({ preset: { id: 'regular-1' } }, [
447
+ NodeFactory.text('test', [
448
+ NodeFactory.mark(TextSettings.FONT_SIZE, { value: '12' }),
449
+ NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '400' })
450
+ ])
451
+ ])
452
+ ]),
453
+ presets: [createPreset({ id: 'regular-1' })]
454
+ });
455
+
456
+ editor.commands.selectAll();
457
+ const isFontSizeCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_SIZE);
458
+
459
+ expect(isFontSizeCustomized.value).toBe(true);
460
+ });
461
+
428
462
  test('should find attributes', async () => {
429
463
  const editor = await createEditor({
430
464
  content: NodeFactory.doc([
@@ -442,6 +476,23 @@ describe('get preset customization', () => {
442
476
 
443
477
  expect(customization.value).toMatchSnapshot();
444
478
  });
479
+
480
+ test('should is attributes setting customized', async () => {
481
+ const editor = await createEditor({
482
+ content: NodeFactory.doc([
483
+ NodeFactory.paragraph({
484
+ preset: { id: 'regular-1' },
485
+ alignment: { value: 'center' }
486
+ }, 'test')
487
+ ]),
488
+ presets: [createPreset({ id: 'regular-1' })]
489
+ });
490
+
491
+ editor.commands.selectAll();
492
+ const isAlignmentCustomized = editor.commands.isSettingCustomized(TextSettings.ALIGNMENT);
493
+
494
+ expect(isAlignmentCustomized.value).toBe(true);
495
+ });
445
496
  });
446
497
 
447
498
  describe('remove preset customization', () => {
@@ -0,0 +1,102 @@
1
+ import { Editor } from '@tiptap/vue-2';
2
+ import { buildTestExtensions } from '../../__tests__/utils';
3
+ import { ContentNormalizer, NodeFactory } from '../../services';
4
+ import { Superscript } from '../Superscript';
5
+ import { TextSettings } from '../../enums';
6
+
7
+ function createEditor({ content }) {
8
+ return new Editor({
9
+ content: ContentNormalizer.normalize(content),
10
+ extensions: buildTestExtensions({ include: [Superscript] })
11
+ });
12
+ }
13
+
14
+ const createContent = (text) => NodeFactory.doc([
15
+ NodeFactory.paragraph([text])
16
+ ]);
17
+
18
+ describe('get value', () => {
19
+ test('should get from selection', () => {
20
+ const editor = createEditor({
21
+ content: createContent(NodeFactory.text('hello world', [
22
+ NodeFactory.mark(TextSettings.SUPERSCRIPT)
23
+ ]))
24
+ });
25
+
26
+ editor.commands.selectAll();
27
+
28
+ expect(editor.commands.isSuperscript().value).toBe(true);
29
+ });
30
+ });
31
+
32
+ describe('apply value', () => {
33
+ test('should apply superscript', () => {
34
+ const editor = createEditor({
35
+ content: createContent(NodeFactory.text('hello world'))
36
+ });
37
+
38
+ editor.commands.selectAll();
39
+ editor.commands.applySuperscript();
40
+
41
+ expect(editor.getJSON()).toMatchSnapshot();
42
+ });
43
+
44
+ test('should remove superscript', () => {
45
+ const editor = createEditor({
46
+ content: createContent(NodeFactory.text('hello world', [
47
+ NodeFactory.mark(TextSettings.SUPERSCRIPT)
48
+ ]))
49
+ });
50
+
51
+ editor.commands.selectAll();
52
+ editor.commands.removeSuperscript();
53
+
54
+ expect(editor.getJSON()).toMatchSnapshot();
55
+ });
56
+
57
+ test('should toggle superscript to enabled', () => {
58
+ const editor = createEditor({
59
+ content: createContent(NodeFactory.text('hello world'))
60
+ });
61
+
62
+ editor.commands.selectAll();
63
+ editor.commands.toggleSuperscript();
64
+
65
+ expect(editor.getJSON()).toMatchSnapshot();
66
+ });
67
+
68
+ test('should toggle superscript to removed', () => {
69
+ const editor = createEditor({
70
+ content: createContent(NodeFactory.text('hello world', [
71
+ NodeFactory.mark(TextSettings.SUPERSCRIPT)
72
+ ]))
73
+ });
74
+
75
+ editor.commands.selectAll();
76
+ editor.commands.toggleSuperscript();
77
+
78
+ expect(editor.getJSON()).toMatchSnapshot();
79
+ });
80
+ });
81
+
82
+ describe('rendering', () => {
83
+ test('should render html', () => {
84
+ const editor = createEditor({
85
+ content: createContent(NodeFactory.text('hello world', [
86
+ NodeFactory.mark(TextSettings.SUPERSCRIPT)
87
+ ]))
88
+ });
89
+
90
+ expect(editor.getHTML()).toMatchSnapshot();
91
+ });
92
+ });
93
+
94
+ describe('parsing html', () => {
95
+ test('should get value from text', () => {
96
+ const editor = createEditor({
97
+ content: '<p><sup>lorem</sup> ipsum</p>'
98
+ });
99
+
100
+ expect(editor.getJSON()).toMatchSnapshot();
101
+ });
102
+ });
@@ -74,6 +74,17 @@ describe('get decoration', () => {
74
74
  expect(editor.commands.isUnderline().value).toBe(true);
75
75
  });
76
76
 
77
+ test('should is customized settings', () => {
78
+ const editor = createEditor({
79
+ content: createContent(NodeFactory.text('hello world', [
80
+ NodeFactory.mark(TextSettings.TEXT_DECORATION, { underline: true })
81
+ ]))
82
+ });
83
+
84
+ editor.commands.selectAll();
85
+ expect(editor.commands.isUnderlineCustomized().value).toBe(true);
86
+ });
87
+
77
88
  test('should get from preset', () => {
78
89
  const editor = createEditor({
79
90
  content: createContent(NodeFactory.text('hello world'))
@@ -83,6 +94,15 @@ describe('get decoration', () => {
83
94
 
84
95
  expect(editor.commands.isUnderline().value).toBe(false);
85
96
  });
97
+
98
+ test('should not is customized settings', () => {
99
+ const editor = createEditor({
100
+ content: createContent(NodeFactory.text('hello world'))
101
+ });
102
+
103
+ editor.commands.selectAll();
104
+ expect(editor.commands.isUnderlineCustomized().value).toBe(false);
105
+ });
86
106
  });
87
107
 
88
108
  describe('strike through', () => {
@@ -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
+ ],
9
17
  "text": "hello world",
10
18
  "type": "text",
11
19
  },
12
20
  ],
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
+ ],
34
42
  "text": "test",
35
43
  "type": "text",
36
44
  },
37
45
  ],
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
+ ],
129
137
  "text": " ipsum",
130
138
  "type": "text",
131
139
  },
132
140
  ],
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`] = `"<span style="--zw-background-color:green;" class="zw-style"><p class="zw-style">hello world</p></span>"`;
148
+ exports[`rendering should render html 1`] = `"<p class="zw-style"><span style="--zw-background-color:green;" class="zw-style">hello world</span></p>"`;
@@ -0,0 +1,107 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`apply value should apply superscript 1`] = `
4
+ Object {
5
+ "content": Array [
6
+ Object {
7
+ "content": Array [
8
+ Object {
9
+ "marks": Array [
10
+ Object {
11
+ "type": "superscript",
12
+ },
13
+ ],
14
+ "text": "hello world",
15
+ "type": "text",
16
+ },
17
+ ],
18
+ "type": "paragraph",
19
+ },
20
+ ],
21
+ "type": "doc",
22
+ }
23
+ `;
24
+
25
+ exports[`apply value should remove superscript 1`] = `
26
+ Object {
27
+ "content": Array [
28
+ Object {
29
+ "content": Array [
30
+ Object {
31
+ "text": "hello world",
32
+ "type": "text",
33
+ },
34
+ ],
35
+ "type": "paragraph",
36
+ },
37
+ ],
38
+ "type": "doc",
39
+ }
40
+ `;
41
+
42
+ exports[`apply value should toggle superscript to enabled 1`] = `
43
+ Object {
44
+ "content": Array [
45
+ Object {
46
+ "content": Array [
47
+ Object {
48
+ "text": "hello world",
49
+ "type": "text",
50
+ },
51
+ ],
52
+ "type": "paragraph",
53
+ },
54
+ ],
55
+ "type": "doc",
56
+ }
57
+ `;
58
+
59
+ exports[`apply value should toggle superscript to removed 1`] = `
60
+ Object {
61
+ "content": Array [
62
+ Object {
63
+ "content": Array [
64
+ Object {
65
+ "marks": Array [
66
+ Object {
67
+ "type": "superscript",
68
+ },
69
+ ],
70
+ "text": "hello world",
71
+ "type": "text",
72
+ },
73
+ ],
74
+ "type": "paragraph",
75
+ },
76
+ ],
77
+ "type": "doc",
78
+ }
79
+ `;
80
+
81
+ exports[`parsing html should get value from text 1`] = `
82
+ Object {
83
+ "content": Array [
84
+ Object {
85
+ "content": Array [
86
+ Object {
87
+ "marks": Array [
88
+ Object {
89
+ "type": "superscript",
90
+ },
91
+ ],
92
+ "text": "lorem",
93
+ "type": "text",
94
+ },
95
+ Object {
96
+ "text": " ipsum",
97
+ "type": "text",
98
+ },
99
+ ],
100
+ "type": "paragraph",
101
+ },
102
+ ],
103
+ "type": "doc",
104
+ }
105
+ `;
106
+
107
+ exports[`rendering should render html 1`] = `"<p class="zw-style"><sup class="zw-superscript">hello world</sup></p>"`;
@@ -1,5 +1,6 @@
1
1
  import { Document as Base } from '@tiptap/extension-document';
2
+ import { MarkGroups } from '../../enums';
2
3
 
3
4
  export const Document = Base.extend({
4
- marks: 'settings'
5
+ marks: MarkGroups.SETTINGS
5
6
  });