@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.
- package/dist/cli.js +2 -2
- package/dist/wysiwyg.mjs +421 -274
- package/lib/__tests__/utils/buildTestExtensions.js +14 -0
- package/lib/__tests__/utils/index.js +1 -0
- package/lib/components/toolbar/controls/SuperscriptControl.vue +2 -2
- package/lib/components/toolbar/controls/__tests__/SuperscriptControl.test.js +2 -2
- package/lib/composables/__tests__/useEditor.test.js +2 -2
- package/lib/extensions/BackgroundColor.js +4 -4
- package/lib/extensions/FontColor.js +4 -5
- package/lib/extensions/FontFamily.js +4 -5
- package/lib/extensions/FontSize.js +5 -7
- package/lib/extensions/FontStyle.js +13 -11
- package/lib/extensions/FontWeight.js +6 -9
- package/lib/extensions/StylePreset.js +0 -8
- package/lib/extensions/Superscript.js +23 -1
- package/lib/extensions/TextDecoration.js +33 -13
- package/lib/extensions/__tests__/Alignment.test.js +10 -7
- package/lib/extensions/__tests__/BackgroundColor.test.js +6 -3
- package/lib/extensions/__tests__/CaseStyle.test.js +11 -7
- package/lib/extensions/__tests__/FontColor.test.js +6 -3
- package/lib/extensions/__tests__/FontFamily.test.js +29 -22
- package/lib/extensions/__tests__/FontSize.test.js +24 -17
- package/lib/extensions/__tests__/FontStyle.test.js +22 -16
- package/lib/extensions/__tests__/FontWeight.test.js +26 -19
- package/lib/extensions/__tests__/LineHeight.test.js +14 -11
- package/lib/extensions/__tests__/Link.test.js +14 -10
- package/lib/extensions/__tests__/Margin.test.js +2 -2
- package/lib/extensions/__tests__/StylePreset.test.js +49 -49
- package/lib/extensions/__tests__/TextDecoration.test.js +72 -26
- package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +24 -24
- package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +24 -24
- package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +86 -82
- package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +70 -70
- package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +53 -45
- package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +64 -60
- package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +148 -83
- package/lib/extensions/core/Document.js +5 -0
- package/lib/extensions/core/Heading.js +10 -0
- package/lib/extensions/core/NodeProcessor.js +84 -4
- package/lib/extensions/core/Paragraph.js +9 -0
- package/lib/extensions/core/TextProcessor.js +10 -12
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +82 -10
- package/lib/extensions/core/__tests__/SelectionProcessor.test.js +2 -2
- package/lib/extensions/core/__tests__/TextProcessor.test.js +18 -20
- package/lib/extensions/core/__tests__/__snapshots__/NodeProcessor.test.js.snap +132 -0
- package/lib/extensions/core/index.js +5 -5
- package/lib/extensions/core/steps/AddNodeMarkStep.js +60 -0
- package/lib/extensions/core/steps/RemoveNodeMarkStep.js +50 -0
- package/lib/extensions/core/steps/index.js +2 -0
- package/lib/extensions/list/List.js +1 -0
- package/lib/extensions/list/ListItem.js +5 -0
- package/lib/extensions/list/__tests__/List.test.js +30 -25
- package/lib/services/ContentNormalizer.js +1 -100
- package/lib/services/NodeFactory.js +16 -6
- package/lib/services/__tests__/ContentNormalizer.test.js +0 -64
- package/lib/utils/findMarkByType.js +5 -0
- package/lib/utils/index.js +5 -0
- package/lib/utils/isMarkAppliedToParent.js +15 -0
- package/lib/utils/isNodeFullySelected.js +10 -0
- package/lib/utils/resolveNodePosition.js +6 -0
- package/lib/utils/resolveTextPosition.js +6 -0
- package/package.json +1 -1
|
@@ -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:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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.
|
|
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:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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.
|
|
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.
|
|
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:
|
|
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:
|
|
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
|
});
|
|
@@ -452,11 +461,8 @@ describe('remove preset customization', () => {
|
|
|
452
461
|
presets: [createPreset({ id: 'regular-1' })]
|
|
453
462
|
});
|
|
454
463
|
|
|
455
|
-
editor
|
|
456
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 })
|