@zipify/wysiwyg 1.3.0-0 → 2.0.0-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +1 -1
- package/config/build/lib.config.js +4 -2
- package/dist/cli.js +10 -2
- package/dist/wysiwyg.css +43 -48
- package/dist/wysiwyg.mjs +1928 -787
- package/example/ExampleApp.vue +3 -1
- package/lib/__tests__/utils/buildTestExtensions.js +14 -0
- package/lib/__tests__/utils/index.js +1 -0
- package/lib/components/base/Button.vue +0 -7
- package/lib/components/base/dropdown/Dropdown.vue +1 -7
- package/lib/components/base/dropdown/DropdownActivator.vue +4 -19
- package/lib/components/base/dropdown/__tests__/DropdownActivator.test.js +1 -23
- package/lib/components/toolbar/controls/AlignmentControl.vue +1 -11
- package/lib/components/toolbar/controls/FontColorControl.vue +0 -13
- package/lib/components/toolbar/controls/FontFamilyControl.vue +0 -4
- package/lib/components/toolbar/controls/FontSizeControl.vue +1 -6
- package/lib/components/toolbar/controls/FontWeightControl.vue +0 -12
- package/lib/components/toolbar/controls/ItalicControl.vue +0 -13
- package/lib/components/toolbar/controls/LineHeightControl.vue +0 -14
- package/lib/components/toolbar/controls/StylePresetControl.vue +1 -1
- package/lib/components/toolbar/controls/SuperscriptControl.vue +2 -2
- package/lib/components/toolbar/controls/UnderlineControl.vue +0 -12
- package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +5 -72
- package/lib/components/toolbar/controls/__tests__/FontColorControl.test.js +1 -22
- package/lib/components/toolbar/controls/__tests__/FontFamilyControl.test.js +0 -1
- package/lib/components/toolbar/controls/__tests__/FontSizeControl.test.js +0 -1
- package/lib/components/toolbar/controls/__tests__/FontWeightControl.test.js +0 -1
- package/lib/components/toolbar/controls/__tests__/ItalicControl.test.js +1 -23
- package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +1 -23
- package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +2 -2
- package/lib/components/toolbar/controls/__tests__/SuperscriptControl.test.js +2 -2
- package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +1 -25
- package/lib/composables/__tests__/useEditor.test.js +2 -2
- package/lib/enums/TextSettings.js +5 -5
- package/lib/extensions/BackgroundColor.js +4 -4
- package/lib/extensions/FontColor.js +4 -5
- package/lib/extensions/FontFamily.js +4 -5
- package/lib/extensions/FontSize.js +5 -7
- package/lib/extensions/FontStyle.js +13 -11
- package/lib/extensions/FontWeight.js +6 -9
- package/lib/extensions/Link.js +1 -1
- package/lib/extensions/StylePreset.js +1 -15
- package/lib/extensions/Superscript.js +23 -1
- package/lib/extensions/TextDecoration.js +16 -20
- package/lib/extensions/__tests__/Alignment.test.js +10 -7
- package/lib/extensions/__tests__/BackgroundColor.test.js +6 -3
- package/lib/extensions/__tests__/CaseStyle.test.js +11 -7
- package/lib/extensions/__tests__/FontColor.test.js +6 -3
- package/lib/extensions/__tests__/FontFamily.test.js +29 -22
- package/lib/extensions/__tests__/FontSize.test.js +24 -17
- package/lib/extensions/__tests__/FontStyle.test.js +22 -16
- package/lib/extensions/__tests__/FontWeight.test.js +28 -21
- package/lib/extensions/__tests__/LineHeight.test.js +14 -11
- package/lib/extensions/__tests__/Link.test.js +14 -10
- package/lib/extensions/__tests__/Margin.test.js +2 -2
- package/lib/extensions/__tests__/StylePreset.test.js +49 -100
- package/lib/extensions/__tests__/TextDecoration.test.js +59 -37
- package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +25 -25
- package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +25 -25
- package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +105 -105
- package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +72 -72
- package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +54 -46
- package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +77 -77
- package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +68 -3
- package/lib/extensions/core/Document.js +5 -0
- package/lib/extensions/core/Heading.js +10 -0
- package/lib/extensions/core/NodeProcessor.js +112 -10
- package/lib/extensions/core/Paragraph.js +9 -0
- package/lib/extensions/core/TextProcessor.js +9 -16
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +137 -10
- package/lib/extensions/core/__tests__/SelectionProcessor.test.js +2 -2
- package/lib/extensions/core/__tests__/TextProcessor.test.js +18 -41
- package/lib/extensions/core/__tests__/__snapshots__/NodeProcessor.test.js.snap +192 -0
- package/lib/extensions/core/__tests__/__snapshots__/TextProcessor.test.js.snap +7 -27
- package/lib/extensions/core/index.js +5 -5
- package/lib/extensions/core/steps/AddNodeMarkStep.js +60 -0
- package/lib/extensions/core/steps/AttrStep.js +54 -0
- package/lib/extensions/core/steps/RemoveNodeMarkStep.js +50 -0
- package/lib/extensions/core/steps/index.js +3 -0
- package/lib/extensions/list/List.js +1 -0
- package/lib/extensions/list/ListItem.js +5 -0
- package/lib/extensions/list/__tests__/List.test.js +30 -25
- package/lib/services/NodeFactory.js +25 -21
- package/lib/services/index.js +1 -1
- package/lib/services/normalizer/BaseNormalizer.js +11 -0
- package/lib/services/{BrowserDomParser.js → normalizer/BrowserDomParser.js} +0 -0
- package/lib/services/normalizer/ContentNormalizer.js +24 -0
- package/lib/services/normalizer/HtmlNormalizer.js +245 -0
- package/lib/services/normalizer/JsonNormalizer.js +81 -0
- package/lib/services/{__tests__/ContentNormalizer.test.js → normalizer/__tests__/HtmlNormalizer.test.js} +27 -67
- package/lib/services/normalizer/__tests__/JsonNormalizer.test.js +70 -0
- package/lib/services/normalizer/__tests__/__snapshots__/JsonNormalizer.test.js.snap +159 -0
- package/lib/services/normalizer/index.js +1 -0
- package/lib/styles/content.css +8 -0
- package/lib/utils/findMarkByType.js +5 -0
- package/lib/utils/index.js +5 -0
- package/lib/utils/isMarkAppliedToParent.js +10 -0
- package/lib/utils/isNodeFullySelected.js +10 -0
- package/lib/utils/resolveNodePosition.js +6 -0
- package/lib/utils/resolveTextPosition.js +6 -0
- package/package.json +3 -1
- package/lib/assets/icons/indicator.svg +0 -5
- package/lib/services/ContentNormalizer.js +0 -293
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Editor, Extension } 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:
|
|
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.
|
|
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:
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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:
|
|
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.
|
|
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:
|
|
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
|
});
|
|
@@ -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(
|
|
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.
|
|
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
|
});
|
|
@@ -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(
|
|
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.
|
|
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
|
|