@zipify/wysiwyg 1.2.5 → 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.
Files changed (62) hide show
  1. package/dist/cli.js +2 -2
  2. package/dist/wysiwyg.mjs +421 -274
  3. package/lib/__tests__/utils/buildTestExtensions.js +14 -0
  4. package/lib/__tests__/utils/index.js +1 -0
  5. package/lib/components/toolbar/controls/SuperscriptControl.vue +2 -2
  6. package/lib/components/toolbar/controls/__tests__/SuperscriptControl.test.js +2 -2
  7. package/lib/composables/__tests__/useEditor.test.js +2 -2
  8. package/lib/extensions/BackgroundColor.js +4 -4
  9. package/lib/extensions/FontColor.js +4 -5
  10. package/lib/extensions/FontFamily.js +4 -5
  11. package/lib/extensions/FontSize.js +5 -7
  12. package/lib/extensions/FontStyle.js +13 -11
  13. package/lib/extensions/FontWeight.js +6 -9
  14. package/lib/extensions/StylePreset.js +0 -8
  15. package/lib/extensions/Superscript.js +23 -1
  16. package/lib/extensions/TextDecoration.js +33 -13
  17. package/lib/extensions/__tests__/Alignment.test.js +10 -7
  18. package/lib/extensions/__tests__/BackgroundColor.test.js +6 -3
  19. package/lib/extensions/__tests__/CaseStyle.test.js +11 -7
  20. package/lib/extensions/__tests__/FontColor.test.js +6 -3
  21. package/lib/extensions/__tests__/FontFamily.test.js +29 -22
  22. package/lib/extensions/__tests__/FontSize.test.js +24 -17
  23. package/lib/extensions/__tests__/FontStyle.test.js +22 -16
  24. package/lib/extensions/__tests__/FontWeight.test.js +26 -19
  25. package/lib/extensions/__tests__/LineHeight.test.js +14 -11
  26. package/lib/extensions/__tests__/Link.test.js +14 -10
  27. package/lib/extensions/__tests__/Margin.test.js +2 -2
  28. package/lib/extensions/__tests__/StylePreset.test.js +49 -49
  29. package/lib/extensions/__tests__/TextDecoration.test.js +72 -26
  30. package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +24 -24
  31. package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +24 -24
  32. package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +86 -82
  33. package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +70 -70
  34. package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +53 -45
  35. package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +64 -60
  36. package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +148 -83
  37. package/lib/extensions/core/Document.js +5 -0
  38. package/lib/extensions/core/Heading.js +10 -0
  39. package/lib/extensions/core/NodeProcessor.js +84 -4
  40. package/lib/extensions/core/Paragraph.js +9 -0
  41. package/lib/extensions/core/TextProcessor.js +10 -12
  42. package/lib/extensions/core/__tests__/NodeProcessor.test.js +82 -10
  43. package/lib/extensions/core/__tests__/SelectionProcessor.test.js +2 -2
  44. package/lib/extensions/core/__tests__/TextProcessor.test.js +18 -20
  45. package/lib/extensions/core/__tests__/__snapshots__/NodeProcessor.test.js.snap +132 -0
  46. package/lib/extensions/core/index.js +5 -5
  47. package/lib/extensions/core/steps/AddNodeMarkStep.js +60 -0
  48. package/lib/extensions/core/steps/RemoveNodeMarkStep.js +50 -0
  49. package/lib/extensions/core/steps/index.js +2 -0
  50. package/lib/extensions/list/List.js +1 -0
  51. package/lib/extensions/list/ListItem.js +5 -0
  52. package/lib/extensions/list/__tests__/List.test.js +30 -25
  53. package/lib/services/ContentNormalizer.js +1 -100
  54. package/lib/services/NodeFactory.js +16 -6
  55. package/lib/services/__tests__/ContentNormalizer.test.js +0 -64
  56. package/lib/utils/findMarkByType.js +5 -0
  57. package/lib/utils/index.js +5 -0
  58. package/lib/utils/isMarkAppliedToParent.js +15 -0
  59. package/lib/utils/isNodeFullySelected.js +10 -0
  60. package/lib/utils/resolveNodePosition.js +6 -0
  61. package/lib/utils/resolveTextPosition.js +6 -0
  62. package/package.json +1 -1
@@ -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
  });
@@ -120,7 +124,8 @@ describe('apply font weight', () => {
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
  });
@@ -145,7 +151,8 @@ describe('apply font weight', () => {
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
 
@@ -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: buildCoreExtensions().concat(
128
- StylePreset.configure({
129
- presets: presets,
130
- baseClass: 'zw ts-',
131
- defaultId,
132
-
133
- makeVariable({ device, preset, property }) {
134
- const formattedProperty = property.replace(/_/i, '-');
135
-
136
- return `--${device}-${preset.id}-${formattedProperty}`;
137
- }
138
- }),
139
- List.configure({
140
- baseClass: 'zw-list--'
141
- }),
142
- MockFontSize,
143
- MockFontWeight,
144
- MockAlignment,
145
- MockBackgroundColor,
146
- MockFontColor,
147
- MockFontFamily,
148
- MockFontStyle,
149
- MockTextDecoration,
150
- MockSuperscript,
151
- MockLink.configure(link)
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.chain().selectAll().applyPreset('regular-1').run();
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.chain().selectAll().applyPreset('h1').run();
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.chain().selectAll().applyPreset('h1').run();
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.chain().selectAll().applyPreset('regular-1').run();
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.chain().selectAll().applyPreset('h1').run();
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.chain().selectAll().applyDefaultPreset().run();
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.chain().selectAll().applyPreset('regular-2').run();
388
+ editor.commands.selectAll();
389
+ editor.commands.applyPreset('regular-2');
381
390
 
382
391
  expect(editor.getJSON()).toMatchSnapshot();
383
392
  });
@@ -452,11 +461,8 @@ describe('remove preset customization', () => {
452
461
  presets: [createPreset({ id: 'regular-1' })]
453
462
  });
454
463
 
455
- editor
456
- .chain()
457
- .setTextSelection({ from: 1, to: 2 })
458
- .removePresetCustomization()
459
- .run();
464
+ editor.commands.setTextSelection({ from: 1, to: 2 });
465
+ editor.commands.removePresetCustomization();
460
466
 
461
467
  expect(editor.getJSON()).toMatchSnapshot();
462
468
  });
@@ -478,11 +484,8 @@ describe('remove preset customization', () => {
478
484
  presets: [createPreset({ id: 'regular-1' })]
479
485
  });
480
486
 
481
- editor
482
- .chain()
483
- .setTextSelection({ from: 1, to: 10 })
484
- .removePresetCustomization()
485
- .run();
487
+ editor.commands.setTextSelection({ from: 1, to: 10 });
488
+ editor.commands.removePresetCustomization();
486
489
 
487
490
  expect(editor.getJSON()).toMatchSnapshot();
488
491
  });
@@ -503,11 +506,8 @@ describe('remove preset customization', () => {
503
506
  presets: [createPreset({ id: 'regular-1' })]
504
507
  });
505
508
 
506
- editor
507
- .chain()
508
- .setTextSelection({ from: 1, to: 2 })
509
- .removePresetCustomization()
510
- .run();
509
+ editor.commands.setTextSelection({ from: 1, to: 2 });
510
+ editor.commands.removePresetCustomization();
511
511
 
512
512
  expect(editor.state.selection).toEqual(
513
513
  expect.objectContaining({ from: 1, to: 2 })