@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.
Files changed (103) hide show
  1. package/.eslintrc.js +1 -1
  2. package/config/build/lib.config.js +4 -2
  3. package/dist/cli.js +10 -2
  4. package/dist/wysiwyg.css +43 -48
  5. package/dist/wysiwyg.mjs +1928 -787
  6. package/example/ExampleApp.vue +3 -1
  7. package/lib/__tests__/utils/buildTestExtensions.js +14 -0
  8. package/lib/__tests__/utils/index.js +1 -0
  9. package/lib/components/base/Button.vue +0 -7
  10. package/lib/components/base/dropdown/Dropdown.vue +1 -7
  11. package/lib/components/base/dropdown/DropdownActivator.vue +4 -19
  12. package/lib/components/base/dropdown/__tests__/DropdownActivator.test.js +1 -23
  13. package/lib/components/toolbar/controls/AlignmentControl.vue +1 -11
  14. package/lib/components/toolbar/controls/FontColorControl.vue +0 -13
  15. package/lib/components/toolbar/controls/FontFamilyControl.vue +0 -4
  16. package/lib/components/toolbar/controls/FontSizeControl.vue +1 -6
  17. package/lib/components/toolbar/controls/FontWeightControl.vue +0 -12
  18. package/lib/components/toolbar/controls/ItalicControl.vue +0 -13
  19. package/lib/components/toolbar/controls/LineHeightControl.vue +0 -14
  20. package/lib/components/toolbar/controls/StylePresetControl.vue +1 -1
  21. package/lib/components/toolbar/controls/SuperscriptControl.vue +2 -2
  22. package/lib/components/toolbar/controls/UnderlineControl.vue +0 -12
  23. package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +5 -72
  24. package/lib/components/toolbar/controls/__tests__/FontColorControl.test.js +1 -22
  25. package/lib/components/toolbar/controls/__tests__/FontFamilyControl.test.js +0 -1
  26. package/lib/components/toolbar/controls/__tests__/FontSizeControl.test.js +0 -1
  27. package/lib/components/toolbar/controls/__tests__/FontWeightControl.test.js +0 -1
  28. package/lib/components/toolbar/controls/__tests__/ItalicControl.test.js +1 -23
  29. package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +1 -23
  30. package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +2 -2
  31. package/lib/components/toolbar/controls/__tests__/SuperscriptControl.test.js +2 -2
  32. package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +1 -25
  33. package/lib/composables/__tests__/useEditor.test.js +2 -2
  34. package/lib/enums/TextSettings.js +5 -5
  35. package/lib/extensions/BackgroundColor.js +4 -4
  36. package/lib/extensions/FontColor.js +4 -5
  37. package/lib/extensions/FontFamily.js +4 -5
  38. package/lib/extensions/FontSize.js +5 -7
  39. package/lib/extensions/FontStyle.js +13 -11
  40. package/lib/extensions/FontWeight.js +6 -9
  41. package/lib/extensions/Link.js +1 -1
  42. package/lib/extensions/StylePreset.js +1 -15
  43. package/lib/extensions/Superscript.js +23 -1
  44. package/lib/extensions/TextDecoration.js +16 -20
  45. package/lib/extensions/__tests__/Alignment.test.js +10 -7
  46. package/lib/extensions/__tests__/BackgroundColor.test.js +6 -3
  47. package/lib/extensions/__tests__/CaseStyle.test.js +11 -7
  48. package/lib/extensions/__tests__/FontColor.test.js +6 -3
  49. package/lib/extensions/__tests__/FontFamily.test.js +29 -22
  50. package/lib/extensions/__tests__/FontSize.test.js +24 -17
  51. package/lib/extensions/__tests__/FontStyle.test.js +22 -16
  52. package/lib/extensions/__tests__/FontWeight.test.js +28 -21
  53. package/lib/extensions/__tests__/LineHeight.test.js +14 -11
  54. package/lib/extensions/__tests__/Link.test.js +14 -10
  55. package/lib/extensions/__tests__/Margin.test.js +2 -2
  56. package/lib/extensions/__tests__/StylePreset.test.js +49 -100
  57. package/lib/extensions/__tests__/TextDecoration.test.js +59 -37
  58. package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +25 -25
  59. package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +25 -25
  60. package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +105 -105
  61. package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +72 -72
  62. package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +54 -46
  63. package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +77 -77
  64. package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +68 -3
  65. package/lib/extensions/core/Document.js +5 -0
  66. package/lib/extensions/core/Heading.js +10 -0
  67. package/lib/extensions/core/NodeProcessor.js +112 -10
  68. package/lib/extensions/core/Paragraph.js +9 -0
  69. package/lib/extensions/core/TextProcessor.js +9 -16
  70. package/lib/extensions/core/__tests__/NodeProcessor.test.js +137 -10
  71. package/lib/extensions/core/__tests__/SelectionProcessor.test.js +2 -2
  72. package/lib/extensions/core/__tests__/TextProcessor.test.js +18 -41
  73. package/lib/extensions/core/__tests__/__snapshots__/NodeProcessor.test.js.snap +192 -0
  74. package/lib/extensions/core/__tests__/__snapshots__/TextProcessor.test.js.snap +7 -27
  75. package/lib/extensions/core/index.js +5 -5
  76. package/lib/extensions/core/steps/AddNodeMarkStep.js +60 -0
  77. package/lib/extensions/core/steps/AttrStep.js +54 -0
  78. package/lib/extensions/core/steps/RemoveNodeMarkStep.js +50 -0
  79. package/lib/extensions/core/steps/index.js +3 -0
  80. package/lib/extensions/list/List.js +1 -0
  81. package/lib/extensions/list/ListItem.js +5 -0
  82. package/lib/extensions/list/__tests__/List.test.js +30 -25
  83. package/lib/services/NodeFactory.js +25 -21
  84. package/lib/services/index.js +1 -1
  85. package/lib/services/normalizer/BaseNormalizer.js +11 -0
  86. package/lib/services/{BrowserDomParser.js → normalizer/BrowserDomParser.js} +0 -0
  87. package/lib/services/normalizer/ContentNormalizer.js +24 -0
  88. package/lib/services/normalizer/HtmlNormalizer.js +245 -0
  89. package/lib/services/normalizer/JsonNormalizer.js +81 -0
  90. package/lib/services/{__tests__/ContentNormalizer.test.js → normalizer/__tests__/HtmlNormalizer.test.js} +27 -67
  91. package/lib/services/normalizer/__tests__/JsonNormalizer.test.js +70 -0
  92. package/lib/services/normalizer/__tests__/__snapshots__/JsonNormalizer.test.js.snap +159 -0
  93. package/lib/services/normalizer/index.js +1 -0
  94. package/lib/styles/content.css +8 -0
  95. package/lib/utils/findMarkByType.js +5 -0
  96. package/lib/utils/index.js +5 -0
  97. package/lib/utils/isMarkAppliedToParent.js +10 -0
  98. package/lib/utils/isNodeFullySelected.js +10 -0
  99. package/lib/utils/resolveNodePosition.js +6 -0
  100. package/lib/utils/resolveTextPosition.js +6 -0
  101. package/package.json +3 -1
  102. package/lib/assets/icons/indicator.svg +0 -5
  103. package/lib/services/ContentNormalizer.js +0 -293
@@ -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 { BackgroundColor } from '../BackgroundColor';
5
6
  import { ContentNormalizer, NodeFactory } from '../../services';
6
- import { buildCoreExtensions } from '../core';
7
7
 
8
8
  const MockStylePreset = Extension.create({
9
9
  name: 'style_preset',
@@ -20,7 +20,9 @@ const MockStylePreset = Extension.create({
20
20
  function createEditor({ content }) {
21
21
  return new Editor({
22
22
  content: ContentNormalizer.normalize(content),
23
- extensions: buildCoreExtensions().concat(MockStylePreset, BackgroundColor)
23
+ extensions: buildTestExtensions({
24
+ include: [MockStylePreset, BackgroundColor]
25
+ })
24
26
  });
25
27
  }
26
28
 
@@ -56,7 +58,8 @@ describe('apply background color', () => {
56
58
  content: createContent(NodeFactory.text('hello world'))
57
59
  });
58
60
 
59
- editor.chain().selectAll().applyBackgroundColor('green').run();
61
+ editor.commands.selectAll();
62
+ editor.commands.applyBackgroundColor('green');
60
63
 
61
64
  expect(editor.getJSON()).toMatchSnapshot();
62
65
  });
@@ -1,13 +1,13 @@
1
1
  import { Editor } from '@tiptap/vue-2';
2
+ import { buildTestExtensions } from '../../__tests__/utils';
3
+ import { ContentNormalizer, NodeFactory } from '../../services';
2
4
  import { CaseStyles } from '../../enums';
3
5
  import { CaseStyle } from '../CaseStyle';
4
- import { ContentNormalizer, NodeFactory } from '../../services';
5
- import { buildCoreExtensions } from '../core';
6
6
 
7
7
  function createEditor({ content }) {
8
8
  return new Editor({
9
9
  content: ContentNormalizer.normalize(content),
10
- extensions: buildCoreExtensions().concat(CaseStyle)
10
+ extensions: buildTestExtensions({ include: [CaseStyle] })
11
11
  });
12
12
  }
13
13
 
@@ -21,7 +21,8 @@ describe('apply case style', () => {
21
21
  content: createContent(NodeFactory.text('hello world'))
22
22
  });
23
23
 
24
- editor.chain().selectAll().applyCapitalize().run();
24
+ editor.commands.selectAll();
25
+ editor.commands.applyCapitalize();
25
26
 
26
27
  expect(editor.getJSON()).toMatchSnapshot();
27
28
  });
@@ -31,7 +32,8 @@ describe('apply case style', () => {
31
32
  content: createContent(NodeFactory.text('HeLlO wOrLd'))
32
33
  });
33
34
 
34
- editor.chain().selectAll().applyLowerCase().run();
35
+ editor.commands.selectAll();
36
+ editor.commands.applyLowerCase();
35
37
 
36
38
  expect(editor.getJSON()).toMatchSnapshot();
37
39
  });
@@ -41,7 +43,8 @@ describe('apply case style', () => {
41
43
  content: createContent(NodeFactory.text('hello world'))
42
44
  });
43
45
 
44
- editor.chain().selectAll().applyUpperCase().run();
46
+ editor.commands.selectAll();
47
+ editor.commands.applyUpperCase();
45
48
 
46
49
  expect(editor.getJSON()).toMatchSnapshot();
47
50
  });
@@ -51,7 +54,8 @@ describe('apply case style', () => {
51
54
  content: createContent(NodeFactory.text('hello world'))
52
55
  });
53
56
 
54
- editor.chain().selectAll().applyCaseStyle(CaseStyles.CAPITALIZE).run();
57
+ editor.commands.selectAll();
58
+ editor.commands.applyCaseStyle(CaseStyles.CAPITALIZE);
55
59
 
56
60
  expect(editor.getJSON()).toMatchSnapshot();
57
61
  });
@@ -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 { FontColor } from '../FontColor';
5
6
  import { ContentNormalizer, NodeFactory } from '../../services';
6
- import { buildCoreExtensions } from '../core';
7
7
 
8
8
  const MockStylePreset = Extension.create({
9
9
  name: 'style_preset',
@@ -20,7 +20,9 @@ const MockStylePreset = Extension.create({
20
20
  function createEditor({ content }) {
21
21
  return new Editor({
22
22
  content: ContentNormalizer.normalize(content),
23
- extensions: buildCoreExtensions().concat(MockStylePreset, FontColor)
23
+ extensions: buildTestExtensions({
24
+ include: [MockStylePreset, FontColor]
25
+ })
24
26
  });
25
27
  }
26
28
 
@@ -66,7 +68,8 @@ describe('apply font color', () => {
66
68
  content: createContent(NodeFactory.text('hello world'))
67
69
  });
68
70
 
69
- editor.chain().selectAll().applyFontColor('green').run();
71
+ editor.commands.selectAll();
72
+ editor.commands.applyFontColor('green');
70
73
 
71
74
  expect(editor.getJSON()).toMatchSnapshot();
72
75
  });
@@ -1,13 +1,13 @@
1
1
  import { Editor, Extension } from '@tiptap/vue-2';
2
2
  import { ref } from 'vue';
3
3
  import { createCommand } from '../../utils';
4
+ import { buildTestExtensions } from '../../__tests__/utils';
4
5
  import { Font } from '../../models';
5
6
  import { FontFamily } from '../FontFamily';
6
7
  import { FontWeight } from '../FontWeight';
7
8
  import { FontStyle } from '../FontStyle';
8
9
  import { ContentNormalizer, NodeFactory } from '../../services';
9
10
  import { TextSettings } from '../../enums';
10
- import { buildCoreExtensions } from '../core';
11
11
 
12
12
  const MockStylePreset = Extension.create({
13
13
  name: TextSettings.STYLE_PRESET,
@@ -27,22 +27,24 @@ const MockStylePreset = Extension.create({
27
27
  function createEditor({ content }) {
28
28
  return new Editor({
29
29
  content: ContentNormalizer.normalize(content),
30
- extensions: buildCoreExtensions().concat(
31
- MockStylePreset,
32
- FontFamily.configure({
33
- fonts: [
34
- new Font({ name: 'Lato', styles: ['400', '400i', '700', '700i'] }),
35
- new Font({ name: 'Bungee', styles: ['400'] }),
36
- new Font({ name: 'Roboto', styles: ['400', '400i'] }),
37
- new Font({ name: 'Josefin Slab', styles: ['400', '400i'] })
38
- ],
39
- defaultPreset: ref({
40
- common: { font_family: 'Lato' }
41
- })
42
- }),
43
- FontWeight,
44
- FontStyle
45
- )
30
+ extensions: buildTestExtensions({
31
+ include: [
32
+ MockStylePreset,
33
+ FontFamily.configure({
34
+ fonts: [
35
+ new Font({ name: 'Lato', styles: ['400', '400i', '700', '700i'] }),
36
+ new Font({ name: 'Bungee', styles: ['400'] }),
37
+ new Font({ name: 'Roboto', styles: ['400', '400i'] }),
38
+ new Font({ name: 'Josefin Slab', styles: ['400', '400i'] })
39
+ ],
40
+ defaultPreset: ref({
41
+ common: { font_family: 'Lato' }
42
+ })
43
+ }),
44
+ FontWeight,
45
+ FontStyle
46
+ ]
47
+ })
46
48
  });
47
49
  }
48
50
 
@@ -108,7 +110,8 @@ describe('apply font family', () => {
108
110
  content: createContent(NodeFactory.text('hello world'))
109
111
  });
110
112
 
111
- editor.chain().selectAll().applyFontFamily('Bungee').run();
113
+ editor.commands.selectAll();
114
+ editor.commands.applyFontFamily('Bungee');
112
115
 
113
116
  expect(editor.getJSON()).toMatchSnapshot();
114
117
  });
@@ -120,7 +123,8 @@ describe('apply font family', () => {
120
123
  ]))
121
124
  });
122
125
 
123
- editor.chain().selectAll().applyFontFamily('Lato').run();
126
+ editor.commands.selectAll();
127
+ editor.commands.applyFontFamily('Lato');
124
128
 
125
129
  expect(editor.getJSON()).toMatchSnapshot();
126
130
  });
@@ -132,7 +136,8 @@ describe('apply font family', () => {
132
136
  ]))
133
137
  });
134
138
 
135
- editor.chain().selectAll().applyFontFamily('Bungee').run();
139
+ editor.commands.selectAll();
140
+ editor.commands.applyFontFamily('Bungee');
136
141
 
137
142
  expect(editor.getJSON()).toMatchSnapshot();
138
143
  });
@@ -145,7 +150,8 @@ describe('apply font family', () => {
145
150
  ]))
146
151
  });
147
152
 
148
- editor.chain().selectAll().applyFontFamily('Lato').run();
153
+ editor.commands.selectAll();
154
+ editor.commands.applyFontFamily('Lato');
149
155
 
150
156
  expect(editor.getJSON()).toMatchSnapshot();
151
157
  });
@@ -158,7 +164,8 @@ describe('apply font family', () => {
158
164
  ]))
159
165
  });
160
166
 
161
- editor.chain().selectAll().applyFontFamily('Bungee').run();
167
+ editor.commands.selectAll();
168
+ editor.commands.applyFontFamily('Bungee');
162
169
 
163
170
  expect(editor.getJSON()).toMatchSnapshot();
164
171
  });
@@ -1,10 +1,10 @@
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 { FontSize } from '../FontSize';
5
6
  import { DeviceManager } from '../DeviceManager';
6
7
  import { ContentNormalizer, NodeFactory } from '../../services';
7
- import { buildCoreExtensions } from '../core';
8
8
 
9
9
  const MockStylePreset = Extension.create({
10
10
  name: 'style_preset',
@@ -23,17 +23,19 @@ const MockStylePreset = Extension.create({
23
23
  function createEditor({ content }) {
24
24
  return new Editor({
25
25
  content: ContentNormalizer.normalize(content),
26
- extensions: buildCoreExtensions().concat(
27
- MockStylePreset,
28
- DeviceManager.configure({
29
- device: ref('desktop')
30
- }),
31
- FontSize.configure({
32
- minSize: 5,
33
- maxSize: 20,
34
- wrapperRef: ref(document.createElement('div'))
35
- })
36
- )
26
+ extensions: buildTestExtensions({
27
+ include: [
28
+ MockStylePreset,
29
+ DeviceManager.configure({
30
+ device: ref('desktop')
31
+ }),
32
+ FontSize.configure({
33
+ minSize: 5,
34
+ maxSize: 20,
35
+ wrapperRef: ref(document.createElement('div'))
36
+ })
37
+ ]
38
+ })
37
39
  });
38
40
  }
39
41
 
@@ -83,7 +85,8 @@ describe('apply font size', () => {
83
85
  content: createContent(NodeFactory.text('hello world'))
84
86
  });
85
87
 
86
- editor.chain().selectAll().applyFontSize('16').run();
88
+ editor.commands.selectAll();
89
+ editor.commands.applyFontSize('16');
87
90
 
88
91
  expect(editor.getJSON()).toMatchSnapshot();
89
92
  });
@@ -99,7 +102,8 @@ describe('apply font size', () => {
99
102
  ]))
100
103
  });
101
104
 
102
- editor.chain().selectAll().increaseFontSize().run();
105
+ editor.commands.selectAll();
106
+ editor.commands.increaseFontSize();
103
107
 
104
108
  expect(editor.getJSON()).toMatchSnapshot();
105
109
  });
@@ -115,7 +119,8 @@ describe('apply font size', () => {
115
119
  ]))
116
120
  });
117
121
 
118
- editor.chain().selectAll().increaseFontSize().run();
122
+ editor.commands.selectAll();
123
+ editor.commands.increaseFontSize();
119
124
 
120
125
  expect(editor.getJSON()).toMatchSnapshot();
121
126
  });
@@ -131,7 +136,8 @@ describe('apply font size', () => {
131
136
  ]))
132
137
  });
133
138
 
134
- editor.chain().selectAll().decreaseFontSize().run();
139
+ editor.commands.selectAll();
140
+ editor.commands.decreaseFontSize();
135
141
 
136
142
  expect(editor.getJSON()).toMatchSnapshot();
137
143
  });
@@ -147,7 +153,8 @@ describe('apply font size', () => {
147
153
  ]))
148
154
  });
149
155
 
150
- editor.chain().selectAll().decreaseFontSize().run();
156
+ editor.commands.selectAll();
157
+ editor.commands.decreaseFontSize();
151
158
 
152
159
  expect(editor.getJSON()).toMatchSnapshot();
153
160
  });
@@ -1,12 +1,12 @@
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 { FontStyle } from '../FontStyle';
5
6
  import { FontFamily } from '../FontFamily';
6
7
  import { Font } from '../../models';
7
8
  import { FontWeight } from '../FontWeight';
8
9
  import { ContentNormalizer, NodeFactory } from '../../services';
9
- import { buildCoreExtensions } from '../core';
10
10
 
11
11
  const MockStylePreset = Extension.create({
12
12
  name: 'style_preset',
@@ -27,17 +27,19 @@ const MockStylePreset = Extension.create({
27
27
  function createEditor({ content }) {
28
28
  return new Editor({
29
29
  content: ContentNormalizer.normalize(content),
30
- extensions: buildCoreExtensions().concat(
31
- MockStylePreset,
32
- FontStyle,
33
- FontWeight,
34
- FontFamily.configure({
35
- fonts: [
36
- new Font({ name: 'Lato', styles: ['400', '400i'] }),
37
- new Font({ name: 'Bungee', styles: ['400'] })
38
- ]
39
- })
40
- )
30
+ extensions: buildTestExtensions({
31
+ include: [
32
+ MockStylePreset,
33
+ FontStyle,
34
+ FontWeight,
35
+ FontFamily.configure({
36
+ fonts: [
37
+ new Font({ name: 'Lato', styles: ['400', '400i'] }),
38
+ new Font({ name: 'Bungee', styles: ['400'] })
39
+ ]
40
+ })
41
+ ]
42
+ })
41
43
  });
42
44
  }
43
45
 
@@ -83,7 +85,8 @@ describe('apply font style', () => {
83
85
  content: createContent(NodeFactory.text('hello world'))
84
86
  });
85
87
 
86
- editor.chain().selectAll().applyItalic().run();
88
+ editor.commands.selectAll();
89
+ editor.commands.applyItalic();
87
90
 
88
91
  expect(editor.getJSON()).toMatchSnapshot();
89
92
  });
@@ -95,7 +98,8 @@ describe('apply font style', () => {
95
98
  ]))
96
99
  });
97
100
 
98
- editor.chain().selectAll().removeItalic().run();
101
+ editor.commands.selectAll();
102
+ editor.commands.removeItalic();
99
103
 
100
104
  expect(editor.getJSON()).toMatchSnapshot();
101
105
  });
@@ -107,7 +111,8 @@ describe('apply font style', () => {
107
111
  ]))
108
112
  });
109
113
 
110
- editor.chain().selectAll().toggleItalic().run();
114
+ editor.commands.selectAll();
115
+ editor.commands.toggleItalic();
111
116
 
112
117
  expect(editor.getJSON()).toMatchSnapshot();
113
118
  });
@@ -117,7 +122,8 @@ describe('apply font style', () => {
117
122
  content: createContent(NodeFactory.text('hello world'))
118
123
  });
119
124
 
120
- editor.chain().selectAll().toggleItalic().run();
125
+ editor.commands.selectAll();
126
+ editor.commands.toggleItalic();
121
127
 
122
128
  expect(editor.getJSON()).toMatchSnapshot();
123
129
  });
@@ -1,13 +1,13 @@
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';
5
+ import { ContentNormalizer, NodeFactory } from '../../services';
4
6
  import { Font } from '../../models';
7
+ import { TextSettings } from '../../enums';
5
8
  import { FontWeight } from '../FontWeight';
6
9
  import { FontFamily } from '../FontFamily';
7
10
  import { FontStyle } from '../FontStyle';
8
- import { ContentNormalizer, NodeFactory } from '../../services';
9
- import { TextSettings } from '../../enums';
10
- import { buildCoreExtensions } from '../core';
11
11
 
12
12
  const MockStylePreset = Extension.create({
13
13
  name: TextSettings.STYLE_PRESET,
@@ -27,17 +27,19 @@ const MockStylePreset = Extension.create({
27
27
  function createEditor({ content }) {
28
28
  return new Editor({
29
29
  content: ContentNormalizer.normalize(content),
30
- extensions: buildCoreExtensions().concat(
31
- MockStylePreset,
32
- FontFamily.configure({
33
- fonts: [
34
- new Font({ name: 'Lato', styles: ['400', '400i', '700', '700i'] }),
35
- new Font({ name: 'Bungee', styles: ['300', '300i', '800', '800i'] })
36
- ]
37
- }),
38
- FontWeight,
39
- FontStyle
40
- )
30
+ extensions: buildTestExtensions({
31
+ include: [
32
+ MockStylePreset,
33
+ FontFamily.configure({
34
+ fonts: [
35
+ new Font({ name: 'Lato', styles: ['400', '400i', '700', '700i'] }),
36
+ new Font({ name: 'Bungee', styles: ['300', '300i', '800', '800i'] })
37
+ ]
38
+ }),
39
+ FontWeight,
40
+ FontStyle
41
+ ]
42
+ })
41
43
  });
42
44
  }
43
45
 
@@ -95,7 +97,8 @@ describe('apply font weight', () => {
95
97
  content: createContent(NodeFactory.text('hello world'))
96
98
  });
97
99
 
98
- editor.chain().selectAll().applyFontWeight('700').run();
100
+ editor.commands.selectAll();
101
+ editor.commands.applyFontWeight('700');
99
102
 
100
103
  expect(editor.getJSON()).toMatchSnapshot();
101
104
  });
@@ -107,7 +110,8 @@ describe('apply font weight', () => {
107
110
  ]))
108
111
  });
109
112
 
110
- editor.chain().selectAll().toggleBold().run();
113
+ editor.commands.selectAll();
114
+ editor.commands.toggleBold();
111
115
 
112
116
  expect(editor.getJSON()).toMatchSnapshot();
113
117
  });
@@ -115,12 +119,13 @@ describe('apply font weight', () => {
115
119
  test('should toggle weight to closest bold', () => {
116
120
  const editor = createEditor({
117
121
  content: createContent(NodeFactory.text('hello world', [
118
- NodeFactory.mark('font_family', { value: 'Bungee' }),
122
+ NodeFactory.mark(TextSettings.FONT_FAMILY, { value: 'Bungee' }),
119
123
  NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '400' })
120
124
  ]))
121
125
  });
122
126
 
123
- editor.chain().selectAll().toggleBold().run();
127
+ editor.commands.selectAll();
128
+ editor.commands.toggleBold();
124
129
 
125
130
  expect(editor.getJSON()).toMatchSnapshot();
126
131
  });
@@ -132,7 +137,8 @@ describe('apply font weight', () => {
132
137
  ]))
133
138
  });
134
139
 
135
- editor.chain().selectAll().toggleBold().run();
140
+ editor.commands.selectAll();
141
+ editor.commands.toggleBold();
136
142
 
137
143
  expect(editor.getJSON()).toMatchSnapshot();
138
144
  });
@@ -140,12 +146,13 @@ describe('apply font weight', () => {
140
146
  test('should toggle weight to closest medium', () => {
141
147
  const editor = createEditor({
142
148
  content: createContent(NodeFactory.text('hello world', [
143
- NodeFactory.mark('font_family', { value: 'Bungee' }),
149
+ NodeFactory.mark(TextSettings.FONT_FAMILY, { value: 'Bungee' }),
144
150
  NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '800' })
145
151
  ]))
146
152
  });
147
153
 
148
- editor.chain().selectAll().toggleBold().run();
154
+ editor.commands.selectAll();
155
+ editor.commands.toggleBold();
149
156
 
150
157
  expect(editor.getJSON()).toMatchSnapshot();
151
158
  });
@@ -1,10 +1,10 @@
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 { DeviceManager } from '../DeviceManager';
5
6
  import { LineHeight } from '../LineHeight';
6
7
  import { ContentNormalizer, NodeFactory } from '../../services';
7
- import { buildCoreExtensions } from '../core';
8
8
 
9
9
  const MockStylePreset = Extension.create({
10
10
  name: 'style_preset',
@@ -23,15 +23,17 @@ const MockStylePreset = Extension.create({
23
23
  function createEditor({ content, wrapperEl }) {
24
24
  return new Editor({
25
25
  content: ContentNormalizer.normalize(content),
26
- extensions: buildCoreExtensions().concat(
27
- MockStylePreset,
28
- DeviceManager.configure({
29
- device: ref('desktop')
30
- }),
31
- LineHeight.configure({
32
- wrapperRef: ref(wrapperEl ?? document.createElement('div'))
33
- })
34
- )
26
+ extensions: buildTestExtensions({
27
+ include: [
28
+ MockStylePreset,
29
+ DeviceManager.configure({
30
+ device: ref('desktop')
31
+ }),
32
+ LineHeight.configure({
33
+ wrapperRef: ref(wrapperEl ?? document.createElement('div'))
34
+ })
35
+ ]
36
+ })
35
37
  });
36
38
  }
37
39
 
@@ -77,7 +79,8 @@ describe('apply value', () => {
77
79
  content: createContent({ line_height: null })
78
80
  });
79
81
 
80
- editor.chain().selectAll().applyLineHeight('1.41').run();
82
+ editor.commands.selectAll();
83
+ editor.commands.applyLineHeight('1.41');
81
84
 
82
85
  expect(editor.getJSON()).toMatchSnapshot();
83
86
  });
@@ -1,19 +1,21 @@
1
1
  import { ref } from 'vue';
2
2
  import { Editor } from '@tiptap/vue-2';
3
+ import { buildTestExtensions } from '../../__tests__/utils';
3
4
  import { ContentNormalizer, NodeFactory } from '../../services';
4
5
  import { Link } from '../Link';
5
- import { buildCoreExtensions } from '../core';
6
6
 
7
7
  function createEditor({ content }) {
8
8
  return new Editor({
9
9
  content: ContentNormalizer.normalize(content),
10
- extensions: buildCoreExtensions().concat(
11
- Link.configure({
12
- preset: 'link',
13
- baseClass: 'zw ts-',
14
- pageBlocks: ref([{ id: 987654 }])
15
- })
16
- )
10
+ extensions: buildTestExtensions({
11
+ include: [
12
+ Link.configure({
13
+ preset: 'link',
14
+ baseClass: 'zw ts-',
15
+ pageBlocks: ref([{ id: 987654 }])
16
+ })
17
+ ]
18
+ })
17
19
  });
18
20
  }
19
21
 
@@ -34,7 +36,8 @@ describe('apply link', () => {
34
36
  content: createContent(NodeFactory.text('hello world'))
35
37
  });
36
38
 
37
- editor.chain().selectAll().applyLink(linkAttributes()).run();
39
+ editor.commands.selectAll();
40
+ editor.commands.applyLink(linkAttributes());
38
41
 
39
42
  expect(editor.getJSON()).toMatchSnapshot();
40
43
  });
@@ -44,7 +47,8 @@ describe('apply link', () => {
44
47
  content: createContent(NodeFactory.text('Some text'))
45
48
  });
46
49
 
47
- editor.chain().setTextSelection(6).applyLink(linkAttributes()).run();
50
+ editor.commands.setTextSelection(6);
51
+ editor.commands.applyLink(linkAttributes());
48
52
 
49
53
  expect(editor.getJSON()).toMatchSnapshot();
50
54
  });
@@ -1,12 +1,12 @@
1
1
  import { Editor } from '@tiptap/core';
2
+ import { buildTestExtensions } from '../../__tests__/utils';
2
3
  import { ContentNormalizer, NodeFactory } from '../../services';
3
- import { buildCoreExtensions } from '../core';
4
4
  import { Margin } from '../Margin';
5
5
 
6
6
  function createEditor({ content }) {
7
7
  return new Editor({
8
8
  content: ContentNormalizer.normalize(content),
9
- extensions: buildCoreExtensions().concat(Margin)
9
+ extensions: buildTestExtensions({ include: [Margin] })
10
10
  });
11
11
  }
12
12