@zipify/wysiwyg 1.1.0 → 1.1.1-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.css +11 -11
- package/dist/wysiwyg.mjs +36 -36
- package/lib/components/toolbar/controls/link/LinkControl.vue +5 -4
- package/lib/components/toolbar/controls/link/LinkControlHeader.vue +2 -2
- package/lib/components/toolbar/controls/link/__tests__/LinkControl.test.js +1 -1
- package/lib/components/toolbar/controls/link/__tests__/LinkControlHeader.test.js +1 -1
- package/lib/components/toolbar/controls/link/composables/useLink.js +7 -5
- package/lib/enums/TextSettings.js +2 -0
- package/lib/extensions/FontStyle.js +2 -2
- package/lib/extensions/Link.js +13 -15
- package/lib/extensions/TextDecoration.js +12 -13
- package/lib/extensions/__tests__/FontFamily.test.js +7 -6
- package/lib/extensions/__tests__/FontWeight.test.js +11 -10
- package/lib/extensions/__tests__/TextDecoration.test.js +73 -42
- package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +18 -0
- package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +16 -0
- package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +0 -43
- package/package.json +1 -1
|
@@ -4,9 +4,10 @@ import { createCommand } from '../../utils';
|
|
|
4
4
|
import { TextDecoration } from '../TextDecoration';
|
|
5
5
|
import { ContentNormalizer, NodeFactory } from '../../services';
|
|
6
6
|
import { buildCoreExtensions } from '../core';
|
|
7
|
+
import { TextSettings } from '../../enums';
|
|
7
8
|
|
|
8
9
|
const MockStylePreset = Extension.create({
|
|
9
|
-
name:
|
|
10
|
+
name: TextSettings.TEXT_DECORATION,
|
|
10
11
|
|
|
11
12
|
addCommands() {
|
|
12
13
|
return {
|
|
@@ -17,10 +18,26 @@ const MockStylePreset = Extension.create({
|
|
|
17
18
|
}
|
|
18
19
|
});
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
const MockLink = Extension.create({
|
|
22
|
+
name: TextSettings.LINK,
|
|
23
|
+
|
|
24
|
+
addOptions: () => ({
|
|
25
|
+
isLink: false,
|
|
26
|
+
preset: {}
|
|
27
|
+
}),
|
|
28
|
+
|
|
29
|
+
addCommands() {
|
|
30
|
+
return {
|
|
31
|
+
isLink: createCommand(() => this.options.isLink),
|
|
32
|
+
getLinkPreset: createCommand(() => this.options.preset)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
function createEditor({ content, link }) {
|
|
21
38
|
return new Editor({
|
|
22
39
|
content: ContentNormalizer.normalize(content),
|
|
23
|
-
extensions: buildCoreExtensions().concat(MockStylePreset, TextDecoration)
|
|
40
|
+
extensions: buildCoreExtensions().concat(MockStylePreset, TextDecoration, MockLink.configure(link))
|
|
24
41
|
});
|
|
25
42
|
}
|
|
26
43
|
|
|
@@ -32,7 +49,7 @@ describe('get decoration', () => {
|
|
|
32
49
|
test('should get from selection', () => {
|
|
33
50
|
const editor = createEditor({
|
|
34
51
|
content: createContent(NodeFactory.text('hello world', [
|
|
35
|
-
NodeFactory.mark(
|
|
52
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, {
|
|
36
53
|
underline: true,
|
|
37
54
|
strike_through: true
|
|
38
55
|
})
|
|
@@ -60,7 +77,7 @@ describe('get decoration', () => {
|
|
|
60
77
|
test('should get from selection', () => {
|
|
61
78
|
const editor = createEditor({
|
|
62
79
|
content: createContent(NodeFactory.text('hello world', [
|
|
63
|
-
NodeFactory.mark(
|
|
80
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, { underline: true })
|
|
64
81
|
]))
|
|
65
82
|
});
|
|
66
83
|
|
|
@@ -78,13 +95,57 @@ describe('get decoration', () => {
|
|
|
78
95
|
|
|
79
96
|
expect(editor.commands.isUnderline().value).toBe(false);
|
|
80
97
|
});
|
|
98
|
+
|
|
99
|
+
test('should get true from link preset', () => {
|
|
100
|
+
const editor = createEditor({
|
|
101
|
+
content: createContent(NodeFactory.text('hello world')),
|
|
102
|
+
link: {
|
|
103
|
+
isLink: true,
|
|
104
|
+
preset: { common: { text_decoration: 'underline' } }
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
editor.commands.selectAll();
|
|
109
|
+
|
|
110
|
+
expect(editor.commands.isUnderline().value).toBe(true);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('should get false from link preset', () => {
|
|
114
|
+
const editor = createEditor({
|
|
115
|
+
content: createContent(NodeFactory.text('hello world')),
|
|
116
|
+
link: {
|
|
117
|
+
isLink: true,
|
|
118
|
+
preset: { common: { text_decoration: 'none' } }
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
editor.commands.selectAll();
|
|
123
|
+
|
|
124
|
+
expect(editor.commands.isUnderline().value).toBe(false);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test('should override link by local', () => {
|
|
128
|
+
const editor = createEditor({
|
|
129
|
+
content: createContent(NodeFactory.text('hello world', [
|
|
130
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, { underline: false })
|
|
131
|
+
])),
|
|
132
|
+
link: {
|
|
133
|
+
isLink: true,
|
|
134
|
+
preset: { common: { text_decoration: 'underline' } }
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
editor.commands.selectAll();
|
|
139
|
+
|
|
140
|
+
expect(editor.commands.isUnderline().value).toBe(false);
|
|
141
|
+
});
|
|
81
142
|
});
|
|
82
143
|
|
|
83
144
|
describe('strike through', () => {
|
|
84
145
|
test('should get from selection', () => {
|
|
85
146
|
const editor = createEditor({
|
|
86
147
|
content: createContent(NodeFactory.text('hello world', [
|
|
87
|
-
NodeFactory.mark(
|
|
148
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, { strike_through: true })
|
|
88
149
|
]))
|
|
89
150
|
});
|
|
90
151
|
|
|
@@ -119,7 +180,7 @@ describe('apply decoration', () => {
|
|
|
119
180
|
test('should second decoration', () => {
|
|
120
181
|
const editor = createEditor({
|
|
121
182
|
content: createContent(NodeFactory.text('hello world', [
|
|
122
|
-
NodeFactory.mark(
|
|
183
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, {
|
|
123
184
|
strike_through: false,
|
|
124
185
|
underline: true
|
|
125
186
|
})
|
|
@@ -131,41 +192,11 @@ describe('apply decoration', () => {
|
|
|
131
192
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
132
193
|
});
|
|
133
194
|
|
|
134
|
-
test('should remove decoration', () => {
|
|
135
|
-
const editor = createEditor({
|
|
136
|
-
content: createContent(NodeFactory.text('hello world', [
|
|
137
|
-
NodeFactory.mark('text_decoration', {
|
|
138
|
-
strike_through: true,
|
|
139
|
-
underline: true
|
|
140
|
-
})
|
|
141
|
-
]))
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
editor.chain().selectAll().removeTextDecoration('strike_through').run();
|
|
145
|
-
|
|
146
|
-
expect(editor.getJSON()).toMatchSnapshot();
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
test('should remove mark if no decoration', () => {
|
|
150
|
-
const editor = createEditor({
|
|
151
|
-
content: createContent(NodeFactory.text('hello world', [
|
|
152
|
-
NodeFactory.mark('text_decoration', {
|
|
153
|
-
strike_through: false,
|
|
154
|
-
underline: true
|
|
155
|
-
})
|
|
156
|
-
]))
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
editor.chain().selectAll().removeTextDecoration('underline').run();
|
|
160
|
-
|
|
161
|
-
expect(editor.getJSON()).toMatchSnapshot();
|
|
162
|
-
});
|
|
163
|
-
|
|
164
195
|
describe('underline', () => {
|
|
165
196
|
test('should toggle to removed', () => {
|
|
166
197
|
const editor = createEditor({
|
|
167
198
|
content: createContent(NodeFactory.text('hello world', [
|
|
168
|
-
NodeFactory.mark(
|
|
199
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, {
|
|
169
200
|
strike_through: true,
|
|
170
201
|
underline: true
|
|
171
202
|
})
|
|
@@ -192,7 +223,7 @@ describe('apply decoration', () => {
|
|
|
192
223
|
test('should toggle to removed', () => {
|
|
193
224
|
const editor = createEditor({
|
|
194
225
|
content: createContent(NodeFactory.text('hello world', [
|
|
195
|
-
NodeFactory.mark(
|
|
226
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, {
|
|
196
227
|
strike_through: true,
|
|
197
228
|
underline: true
|
|
198
229
|
})
|
|
@@ -220,7 +251,7 @@ describe('rendering', () => {
|
|
|
220
251
|
test('should render underline only', () => {
|
|
221
252
|
const editor = createEditor({
|
|
222
253
|
content: createContent(NodeFactory.text('hello world', [
|
|
223
|
-
NodeFactory.mark(
|
|
254
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, {
|
|
224
255
|
strike_through: false,
|
|
225
256
|
underline: true
|
|
226
257
|
})
|
|
@@ -233,7 +264,7 @@ describe('rendering', () => {
|
|
|
233
264
|
test('should render strike through only', () => {
|
|
234
265
|
const editor = createEditor({
|
|
235
266
|
content: createContent(NodeFactory.text('hello world', [
|
|
236
|
-
NodeFactory.mark(
|
|
267
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, {
|
|
237
268
|
strike_through: true,
|
|
238
269
|
underline: false
|
|
239
270
|
})
|
|
@@ -246,7 +277,7 @@ describe('rendering', () => {
|
|
|
246
277
|
test('should render both', () => {
|
|
247
278
|
const editor = createEditor({
|
|
248
279
|
content: createContent(NodeFactory.text('hello world', [
|
|
249
|
-
NodeFactory.mark(
|
|
280
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, {
|
|
250
281
|
strike_through: true,
|
|
251
282
|
underline: true
|
|
252
283
|
})
|
|
@@ -19,6 +19,12 @@ Object {
|
|
|
19
19
|
},
|
|
20
20
|
"type": "font_weight",
|
|
21
21
|
},
|
|
22
|
+
Object {
|
|
23
|
+
"attrs": Object {
|
|
24
|
+
"italic": false,
|
|
25
|
+
},
|
|
26
|
+
"type": "font_style",
|
|
27
|
+
},
|
|
22
28
|
],
|
|
23
29
|
"text": "hello world",
|
|
24
30
|
"type": "text",
|
|
@@ -44,6 +50,12 @@ Object {
|
|
|
44
50
|
},
|
|
45
51
|
"type": "font_family",
|
|
46
52
|
},
|
|
53
|
+
Object {
|
|
54
|
+
"attrs": Object {
|
|
55
|
+
"italic": false,
|
|
56
|
+
},
|
|
57
|
+
"type": "font_style",
|
|
58
|
+
},
|
|
47
59
|
],
|
|
48
60
|
"text": "hello world",
|
|
49
61
|
"type": "text",
|
|
@@ -143,6 +155,12 @@ Object {
|
|
|
143
155
|
},
|
|
144
156
|
"type": "font_weight",
|
|
145
157
|
},
|
|
158
|
+
Object {
|
|
159
|
+
"attrs": Object {
|
|
160
|
+
"italic": false,
|
|
161
|
+
},
|
|
162
|
+
"type": "font_style",
|
|
163
|
+
},
|
|
146
164
|
],
|
|
147
165
|
"text": "hello world",
|
|
148
166
|
"type": "text",
|
|
@@ -31,6 +31,14 @@ Object {
|
|
|
31
31
|
Object {
|
|
32
32
|
"content": Array [
|
|
33
33
|
Object {
|
|
34
|
+
"marks": Array [
|
|
35
|
+
Object {
|
|
36
|
+
"attrs": Object {
|
|
37
|
+
"italic": false,
|
|
38
|
+
},
|
|
39
|
+
"type": "font_style",
|
|
40
|
+
},
|
|
41
|
+
],
|
|
34
42
|
"text": "hello world",
|
|
35
43
|
"type": "text",
|
|
36
44
|
},
|
|
@@ -48,6 +56,14 @@ Object {
|
|
|
48
56
|
Object {
|
|
49
57
|
"content": Array [
|
|
50
58
|
Object {
|
|
59
|
+
"marks": Array [
|
|
60
|
+
Object {
|
|
61
|
+
"attrs": Object {
|
|
62
|
+
"italic": false,
|
|
63
|
+
},
|
|
64
|
+
"type": "font_style",
|
|
65
|
+
},
|
|
66
|
+
],
|
|
51
67
|
"text": "hello world",
|
|
52
68
|
"type": "text",
|
|
53
69
|
},
|
|
@@ -26,49 +26,6 @@ Object {
|
|
|
26
26
|
}
|
|
27
27
|
`;
|
|
28
28
|
|
|
29
|
-
exports[`apply decoration should remove decoration 1`] = `
|
|
30
|
-
Object {
|
|
31
|
-
"content": Array [
|
|
32
|
-
Object {
|
|
33
|
-
"content": Array [
|
|
34
|
-
Object {
|
|
35
|
-
"marks": Array [
|
|
36
|
-
Object {
|
|
37
|
-
"attrs": Object {
|
|
38
|
-
"strike_through": false,
|
|
39
|
-
"underline": true,
|
|
40
|
-
},
|
|
41
|
-
"type": "text_decoration",
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
"text": "hello world",
|
|
45
|
-
"type": "text",
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
"type": "paragraph",
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
"type": "doc",
|
|
52
|
-
}
|
|
53
|
-
`;
|
|
54
|
-
|
|
55
|
-
exports[`apply decoration should remove mark if no decoration 1`] = `
|
|
56
|
-
Object {
|
|
57
|
-
"content": Array [
|
|
58
|
-
Object {
|
|
59
|
-
"content": Array [
|
|
60
|
-
Object {
|
|
61
|
-
"text": "hello world",
|
|
62
|
-
"type": "text",
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
"type": "paragraph",
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
"type": "doc",
|
|
69
|
-
}
|
|
70
|
-
`;
|
|
71
|
-
|
|
72
29
|
exports[`apply decoration should second decoration 1`] = `
|
|
73
30
|
Object {
|
|
74
31
|
"content": Array [
|