@zipify/wysiwyg 4.11.0 → 4.11.2
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/.release-it.json +2 -1
- package/dist/cli.js +28 -28
- package/dist/node.js +26 -26
- package/dist/types/Wysiwyg.vue.d.ts +7 -8
- package/dist/types/components/base/Button.vue.d.ts +5 -10
- package/dist/types/components/base/ButtonToggle.vue.d.ts +9 -14
- package/dist/types/components/base/Checkbox.vue.d.ts +1 -1
- package/dist/types/components/base/FieldLabel.vue.d.ts +5 -10
- package/dist/types/components/base/Icon.vue.d.ts +1 -1
- package/dist/types/components/base/Modal.vue.d.ts +5 -14
- package/dist/types/components/base/ModalFloating.vue.d.ts +5 -14
- package/dist/types/components/base/NumberField.vue.d.ts +1 -1
- package/dist/types/components/base/Range.vue.d.ts +1 -1
- package/dist/types/components/base/ScrollView.vue.d.ts +5 -14
- package/dist/types/components/base/TextField.vue.d.ts +1 -1
- package/dist/types/components/base/colorPicker/ColorPicker.vue.d.ts +10 -517
- package/dist/types/components/base/dropdown/Dropdown.vue.d.ts +6 -15
- package/dist/types/components/base/dropdown/DropdownActivator.vue.d.ts +7 -12
- package/dist/types/components/base/dropdown/DropdownDivider.vue.d.ts +1 -1
- package/dist/types/components/base/dropdown/DropdownGroup.vue.d.ts +7 -12
- package/dist/types/components/base/dropdown/DropdownMenu.vue.d.ts +6 -12
- package/dist/types/components/base/dropdown/DropdownOption.vue.d.ts +5 -14
- package/dist/types/components/toolbar/ToolbarFloating.vue.d.ts +5 -14
- package/dist/types/components/toolbar/controls/AlignmentControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/CaseStyleControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/FontFamilyControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/FontSizeControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/FontWeightControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/ItalicControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/LineHeightControl.vue.d.ts +1 -3
- package/dist/types/components/toolbar/controls/ListControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/RemoveFormatControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/StrikeThroughControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/SuperscriptControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/UnderlineControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/link/LinkControl.vue.d.ts +1 -3
- package/dist/types/components/toolbar/controls/link/LinkControlHeader.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/link/composables/useLink.d.ts +11 -9
- package/dist/types/components/toolbar/controls/link/destination/LinkControlDestination.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/link/destination/LinkControlPageBlock.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/link/destination/LinkControlUrl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/stylePreset/StylePresetControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/stylePreset/StylePresetOption.vue.d.ts +2 -4
- package/dist/types/enums/Alignment.d.ts +7 -0
- package/dist/types/enums/CaseStyle.d.ts +5 -0
- package/dist/types/enums/Device.d.ts +7 -0
- package/dist/types/enums/LinkDestination.d.ts +4 -0
- package/dist/types/enums/LinkTarget.d.ts +4 -0
- package/dist/types/enums/ListType.d.ts +10 -0
- package/dist/types/enums/MarkGroup.d.ts +4 -0
- package/dist/types/enums/NodeType.d.ts +9 -0
- package/dist/types/enums/TextSetting.d.ts +19 -0
- package/dist/types/enums/index.d.ts +9 -9
- package/dist/types/extensions/Alignment.d.ts +2 -1
- package/dist/types/extensions/CaseStyle.d.ts +2 -1
- package/dist/types/models/Font.d.ts +1 -0
- package/dist/wysiwyg.css +27 -27
- package/dist/wysiwyg.mjs +135 -165
- package/example/fonts.js +111 -111
- package/lib/Wysiwyg.vue +3 -3
- package/lib/__tests__/utils/buildTestExtensions.js +6 -6
- package/lib/components/toolbar/Toolbar.vue +2 -2
- package/lib/components/toolbar/__tests__/Toolbar.test.js +5 -5
- package/lib/components/toolbar/controls/AlignmentControl.vue +7 -7
- package/lib/components/toolbar/controls/CaseStyleControl.vue +5 -5
- package/lib/components/toolbar/controls/FontColorControl.vue +2 -2
- package/lib/components/toolbar/controls/FontFamilyControl.vue +2 -2
- package/lib/components/toolbar/controls/FontSizeControl.vue +2 -2
- package/lib/components/toolbar/controls/FontWeightControl.vue +2 -2
- package/lib/components/toolbar/controls/ItalicControl.vue +2 -2
- package/lib/components/toolbar/controls/LineHeightControl.vue +2 -2
- package/lib/components/toolbar/controls/ListControl.vue +5 -5
- package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +13 -13
- package/lib/components/toolbar/controls/__tests__/CaseStyleControl.test.js +4 -4
- package/lib/components/toolbar/controls/__tests__/ListControl.test.js +10 -10
- package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +6 -6
- package/lib/components/toolbar/controls/link/LinkControl.vue +5 -5
- package/lib/components/toolbar/controls/link/composables/__tests__/useLink.test.js +20 -20
- package/lib/components/toolbar/controls/link/composables/useLink.js +10 -10
- package/lib/components/toolbar/controls/link/destination/LinkControlDestination.vue +10 -7
- package/lib/components/toolbar/controls/link/destination/LinkControlPageBlock.vue +1 -1
- package/lib/enums/{Alignments.ts → Alignment.ts} +0 -8
- package/lib/enums/{CaseStyles.ts → CaseStyle.ts} +0 -6
- package/lib/enums/{Devices.ts → Device.ts} +0 -8
- package/lib/enums/LinkDestination.ts +4 -0
- package/lib/enums/LinkTarget.ts +4 -0
- package/lib/enums/{ListTypes.ts → ListType.ts} +0 -9
- package/lib/enums/MarkGroup.ts +4 -0
- package/lib/enums/{NodeTypes.ts → NodeType.ts} +0 -8
- package/lib/enums/{TextSettings.ts → TextSetting.ts} +0 -11
- package/lib/enums/index.ts +9 -9
- package/lib/extensions/Alignment.js +13 -11
- package/lib/extensions/BackgroundColor.js +2 -2
- package/lib/extensions/CaseStyle.js +8 -6
- package/lib/extensions/FontColor.js +4 -4
- package/lib/extensions/FontFamily.js +8 -6
- package/lib/extensions/FontSize.js +3 -3
- package/lib/extensions/FontStyle.js +3 -3
- package/lib/extensions/FontWeight.js +3 -3
- package/lib/extensions/LineHeight.js +4 -4
- package/lib/extensions/Link.js +11 -11
- package/lib/extensions/Margin.js +4 -4
- package/lib/extensions/StylePreset.js +18 -12
- package/lib/extensions/Superscript.js +2 -2
- package/lib/extensions/TextDecoration.js +2 -2
- package/lib/extensions/__tests__/Alignment.test.js +21 -21
- package/lib/extensions/__tests__/BackgroundColor.test.js +4 -4
- package/lib/extensions/__tests__/CaseStyle.test.js +6 -6
- package/lib/extensions/__tests__/FontColor.test.js +4 -4
- package/lib/extensions/__tests__/FontFamily.test.js +10 -10
- package/lib/extensions/__tests__/FontSize.test.js +9 -9
- package/lib/extensions/__tests__/FontStyle.test.js +6 -6
- package/lib/extensions/__tests__/FontWeight.test.js +11 -11
- package/lib/extensions/__tests__/LineHeight.test.js +2 -2
- package/lib/extensions/__tests__/Link.test.js +13 -13
- package/lib/extensions/__tests__/StylePreset.test.js +29 -29
- package/lib/extensions/__tests__/Superscript.test.js +5 -5
- package/lib/extensions/__tests__/TextDecoration.test.js +14 -14
- package/lib/extensions/core/Document.js +3 -3
- package/lib/extensions/core/Heading.js +2 -2
- package/lib/extensions/core/NodeProcessor.js +8 -8
- package/lib/extensions/core/Paragraph.js +2 -2
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +68 -68
- package/lib/extensions/core/__tests__/TextProcessor.test.js +13 -13
- package/lib/extensions/list/ListItem.js +5 -5
- package/lib/extensions/list/__tests__/List.test.js +11 -11
- package/lib/extensions/proseMirror/PasteLinkPlugin.js +4 -4
- package/lib/extensions/proseMirror/PastePlugin.js +2 -2
- package/lib/models/Font.ts +4 -0
- package/lib/services/ContentSerializer.js +3 -3
- package/lib/services/StylePresetRenderer.js +4 -4
- package/lib/services/__tests__/NodeFactory.test.js +11 -11
- package/lib/services/__tests__/NodeSelector.test.js +18 -18
- package/lib/services/normalizer/JsonNormalizer.js +5 -5
- package/lib/services/normalizer/__tests__/JsonNormalizer.test.js +15 -15
- package/lib/utils/__tests__/convertAlignment.test.js +3 -3
- package/lib/utils/convertAlignment.js +4 -4
- package/package.json +17 -17
- package/lib/enums/LinkDestinations.ts +0 -9
- package/lib/enums/LinkTargets.ts +0 -9
- package/lib/enums/MarkGroups.ts +0 -9
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { ref } from 'vue';
|
|
2
2
|
import { Editor, Extension, Mark } from '@tiptap/vue-3';
|
|
3
|
-
import { buildTestExtensions } from '
|
|
4
|
-
import {
|
|
5
|
-
import { ContentNormalizer, NodeFactory } from '
|
|
6
|
-
import { createCommand } from '
|
|
3
|
+
import { buildTestExtensions } from '@/__tests__/utils';
|
|
4
|
+
import { Device, ListType, MarkGroup, NodeType, TextSetting } from '@/enums';
|
|
5
|
+
import { ContentNormalizer, NodeFactory } from '@/services';
|
|
6
|
+
import { createCommand } from '@/utils';
|
|
7
7
|
import { List } from '../../list';
|
|
8
8
|
|
|
9
9
|
const MockLineHeight = Extension.create({
|
|
10
|
-
name:
|
|
10
|
+
name: TextSetting.LINE_HEIGHT,
|
|
11
11
|
|
|
12
12
|
addGlobalAttributes: () => [
|
|
13
13
|
{
|
|
14
|
-
types: [
|
|
14
|
+
types: [NodeType.PARAGRAPH],
|
|
15
15
|
attributes: {
|
|
16
16
|
line_height: {
|
|
17
17
|
isRequired: false,
|
|
@@ -26,7 +26,7 @@ const MockLineHeight = Extension.create({
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
const MockTextDecoration = Mark.create({
|
|
29
|
-
name:
|
|
29
|
+
name: TextSetting.TEXT_DECORATION,
|
|
30
30
|
renderHTML: () => ['span', {}, 0],
|
|
31
31
|
|
|
32
32
|
addAttributes: () => ({
|
|
@@ -36,15 +36,15 @@ const MockTextDecoration = Mark.create({
|
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
const MockFontWeight = Mark.create({
|
|
39
|
-
name:
|
|
40
|
-
group:
|
|
39
|
+
name: TextSetting.FONT_WEIGHT,
|
|
40
|
+
group: MarkGroup.SETTINGS,
|
|
41
41
|
renderHTML: () => ['span', {}, 0],
|
|
42
42
|
addAttributes: () => ({ value: { required: true } })
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
const MockFontSize = Mark.create({
|
|
46
|
-
name:
|
|
47
|
-
group:
|
|
46
|
+
name: TextSetting.FONT_SIZE,
|
|
47
|
+
group: MarkGroup.SETTINGS,
|
|
48
48
|
renderHTML: () => ['span', {}, 0],
|
|
49
49
|
|
|
50
50
|
addAttributes: () => ({
|
|
@@ -76,7 +76,7 @@ function createEditor({ content, device }) {
|
|
|
76
76
|
MockFontSize,
|
|
77
77
|
MockTextDecoration,
|
|
78
78
|
List.configure({ baseClass: 'zw-list--' }),
|
|
79
|
-
DeviceManager.configure({ device: device ??
|
|
79
|
+
DeviceManager.configure({ device: device ?? Device.DESKTOP })
|
|
80
80
|
]
|
|
81
81
|
})
|
|
82
82
|
});
|
|
@@ -101,7 +101,7 @@ describe('block attributes', () => {
|
|
|
101
101
|
line_height: { mobile: '1.2' }
|
|
102
102
|
})
|
|
103
103
|
});
|
|
104
|
-
const attrs = editor.commands.getBlockAttributes(
|
|
104
|
+
const attrs = editor.commands.getBlockAttributes(TextSetting.LINE_HEIGHT);
|
|
105
105
|
|
|
106
106
|
expect(attrs.value).toEqual({ mobile: '1.2' });
|
|
107
107
|
});
|
|
@@ -112,7 +112,7 @@ describe('block attributes', () => {
|
|
|
112
112
|
line_height: { mobile: '1.2' }
|
|
113
113
|
})
|
|
114
114
|
});
|
|
115
|
-
const attrs = editor.commands.getBlockAttributes(
|
|
115
|
+
const attrs = editor.commands.getBlockAttributes(TextSetting.LINE_HEIGHT, DEFAULTS);
|
|
116
116
|
|
|
117
117
|
expect(attrs.value).toEqual({
|
|
118
118
|
mobile: '1.2',
|
|
@@ -125,7 +125,7 @@ describe('block attributes', () => {
|
|
|
125
125
|
const editor = createEditor({
|
|
126
126
|
content: createContent({ line_height: null })
|
|
127
127
|
});
|
|
128
|
-
const attrs = editor.commands.getBlockAttributes(
|
|
128
|
+
const attrs = editor.commands.getBlockAttributes(TextSetting.LINE_HEIGHT);
|
|
129
129
|
|
|
130
130
|
expect(attrs.value).toBeNull();
|
|
131
131
|
});
|
|
@@ -136,7 +136,7 @@ describe('block attributes', () => {
|
|
|
136
136
|
});
|
|
137
137
|
|
|
138
138
|
editor.commands.selectAll();
|
|
139
|
-
editor.commands.setBlockAttributes(
|
|
139
|
+
editor.commands.setBlockAttributes(TextSetting.LINE_HEIGHT, { mobile: '1.3' });
|
|
140
140
|
|
|
141
141
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
142
142
|
});
|
|
@@ -149,7 +149,7 @@ describe('block attributes', () => {
|
|
|
149
149
|
});
|
|
150
150
|
|
|
151
151
|
editor.commands.selectAll();
|
|
152
|
-
editor.commands.removeBlockAttributes(
|
|
152
|
+
editor.commands.removeBlockAttributes(TextSetting.LINE_HEIGHT);
|
|
153
153
|
|
|
154
154
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
155
155
|
});
|
|
@@ -167,7 +167,7 @@ describe('block attributes', () => {
|
|
|
167
167
|
});
|
|
168
168
|
|
|
169
169
|
editor.commands.selectAll();
|
|
170
|
-
editor.commands.removeBlockAttributes([
|
|
170
|
+
editor.commands.removeBlockAttributes([TextSetting.LINE_HEIGHT, TextSetting.ALIGNMENT]);
|
|
171
171
|
|
|
172
172
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
173
173
|
});
|
|
@@ -178,7 +178,7 @@ describe('block attributes', () => {
|
|
|
178
178
|
});
|
|
179
179
|
|
|
180
180
|
editor.commands.selectAll();
|
|
181
|
-
editor.commands.setBlockAttributes(
|
|
181
|
+
editor.commands.setBlockAttributes(TextSetting.LINE_HEIGHT, { mobile: '1.3' }, DEFAULTS);
|
|
182
182
|
|
|
183
183
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
184
184
|
});
|
|
@@ -191,7 +191,7 @@ describe('block attributes', () => {
|
|
|
191
191
|
});
|
|
192
192
|
|
|
193
193
|
editor.commands.selectAll();
|
|
194
|
-
editor.commands.setBlockAttributes(
|
|
194
|
+
editor.commands.setBlockAttributes(TextSetting.LINE_HEIGHT, { mobile: '1.3' });
|
|
195
195
|
|
|
196
196
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
197
197
|
});
|
|
@@ -204,7 +204,7 @@ describe('block attributes', () => {
|
|
|
204
204
|
});
|
|
205
205
|
|
|
206
206
|
editor.commands.selectAll();
|
|
207
|
-
editor.commands.setBlockAttributes(
|
|
207
|
+
editor.commands.setBlockAttributes(TextSetting.LINE_HEIGHT, { mobile: '1.3' }, DEFAULTS);
|
|
208
208
|
|
|
209
209
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
210
210
|
});
|
|
@@ -217,7 +217,7 @@ describe('apply mark', () => {
|
|
|
217
217
|
});
|
|
218
218
|
|
|
219
219
|
editor.commands.setTextSelection({ from: 1, to: 6 });
|
|
220
|
-
editor.commands.applyMark(
|
|
220
|
+
editor.commands.applyMark(TextSetting.FONT_WEIGHT, { value: '700' });
|
|
221
221
|
|
|
222
222
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
223
223
|
});
|
|
@@ -227,7 +227,7 @@ describe('apply mark', () => {
|
|
|
227
227
|
content: NodeFactory.doc([
|
|
228
228
|
NodeFactory.paragraph([
|
|
229
229
|
NodeFactory.text('lorem', [
|
|
230
|
-
NodeFactory.mark(
|
|
230
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '900' })
|
|
231
231
|
]),
|
|
232
232
|
NodeFactory.text(' ipsum')
|
|
233
233
|
])
|
|
@@ -235,7 +235,7 @@ describe('apply mark', () => {
|
|
|
235
235
|
});
|
|
236
236
|
|
|
237
237
|
editor.commands.setTextSelection({ from: 1, to: 10 });
|
|
238
|
-
editor.commands.applyMark(
|
|
238
|
+
editor.commands.applyMark(TextSetting.FONT_WEIGHT, { value: '700' });
|
|
239
239
|
|
|
240
240
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
241
241
|
});
|
|
@@ -248,7 +248,7 @@ describe('apply mark', () => {
|
|
|
248
248
|
editor
|
|
249
249
|
.chain()
|
|
250
250
|
.selectAll()
|
|
251
|
-
.applyMark(
|
|
251
|
+
.applyMark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
252
252
|
.run();
|
|
253
253
|
|
|
254
254
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
@@ -257,13 +257,13 @@ describe('apply mark', () => {
|
|
|
257
257
|
test('should apply text mark to paragraph with mark', () => {
|
|
258
258
|
const editor = createEditor({
|
|
259
259
|
content: NodeFactory.doc([
|
|
260
|
-
NodeFactory.paragraph(null, [NodeFactory.mark(
|
|
260
|
+
NodeFactory.paragraph(null, [NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })], 'lorem impum')
|
|
261
261
|
])
|
|
262
262
|
});
|
|
263
263
|
|
|
264
264
|
|
|
265
265
|
editor.commands.setTextSelection({ from: 1, to: 6 });
|
|
266
|
-
editor.commands.applyMark(
|
|
266
|
+
editor.commands.applyMark(TextSetting.FONT_WEIGHT, { value: '400' });
|
|
267
267
|
|
|
268
268
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
269
269
|
});
|
|
@@ -276,7 +276,7 @@ describe('apply mark', () => {
|
|
|
276
276
|
});
|
|
277
277
|
|
|
278
278
|
editor.commands.selectAll();
|
|
279
|
-
editor.commands.applyMark(
|
|
279
|
+
editor.commands.applyMark(TextSetting.TEXT_DECORATION, { underline: true });
|
|
280
280
|
|
|
281
281
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
282
282
|
});
|
|
@@ -289,7 +289,7 @@ describe('apply mark', () => {
|
|
|
289
289
|
});
|
|
290
290
|
|
|
291
291
|
editor.commands.setTextSelection({ from: 1, to: 6 });
|
|
292
|
-
editor.commands.applyMark(
|
|
292
|
+
editor.commands.applyMark(TextSetting.FONT_WEIGHT, { value: '700' });
|
|
293
293
|
|
|
294
294
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
295
295
|
});
|
|
@@ -302,7 +302,7 @@ describe('apply mark', () => {
|
|
|
302
302
|
});
|
|
303
303
|
|
|
304
304
|
editor.commands.selectAll();
|
|
305
|
-
editor.commands.applyMark(
|
|
305
|
+
editor.commands.applyMark(TextSetting.FONT_WEIGHT, { value: '700' });
|
|
306
306
|
|
|
307
307
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
308
308
|
});
|
|
@@ -312,7 +312,7 @@ describe('apply mark', () => {
|
|
|
312
312
|
content: NodeFactory.doc([
|
|
313
313
|
NodeFactory.paragraph([
|
|
314
314
|
NodeFactory.text('lorem', [
|
|
315
|
-
NodeFactory.mark(
|
|
315
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '400' })
|
|
316
316
|
]),
|
|
317
317
|
NodeFactory.text(' ipsum')
|
|
318
318
|
])
|
|
@@ -320,7 +320,7 @@ describe('apply mark', () => {
|
|
|
320
320
|
});
|
|
321
321
|
|
|
322
322
|
editor.commands.selectAll();
|
|
323
|
-
editor.commands.applyMark(
|
|
323
|
+
editor.commands.applyMark(TextSetting.FONT_WEIGHT, { value: '700' });
|
|
324
324
|
|
|
325
325
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
326
326
|
});
|
|
@@ -328,7 +328,7 @@ describe('apply mark', () => {
|
|
|
328
328
|
test('should apply mark to list item', () => {
|
|
329
329
|
const editor = createEditor({
|
|
330
330
|
content: NodeFactory.doc([
|
|
331
|
-
NodeFactory.list(
|
|
331
|
+
NodeFactory.list(ListType.DISC, [
|
|
332
332
|
'lorem ipsum 1',
|
|
333
333
|
'lorem ipsum 2'
|
|
334
334
|
])
|
|
@@ -336,7 +336,7 @@ describe('apply mark', () => {
|
|
|
336
336
|
});
|
|
337
337
|
|
|
338
338
|
editor.commands.setTextSelection({ from: 1, to: 16 });
|
|
339
|
-
editor.commands.applyMark(
|
|
339
|
+
editor.commands.applyMark(TextSetting.FONT_WEIGHT, { value: '700' });
|
|
340
340
|
|
|
341
341
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
342
342
|
});
|
|
@@ -344,10 +344,10 @@ describe('apply mark', () => {
|
|
|
344
344
|
test('should remove paragraph mark on applying to list item', () => {
|
|
345
345
|
const editor = createEditor({
|
|
346
346
|
content: NodeFactory.doc([
|
|
347
|
-
NodeFactory.list(
|
|
347
|
+
NodeFactory.list(ListType.DISC, [
|
|
348
348
|
NodeFactory.listItem([
|
|
349
349
|
NodeFactory.paragraph(null, [
|
|
350
|
-
NodeFactory.mark(
|
|
350
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '400' })
|
|
351
351
|
], 'lorem ipsum 1'),
|
|
352
352
|
|
|
353
353
|
'lorem ipsum 2' // prevent move mark to list item on init
|
|
@@ -359,7 +359,7 @@ describe('apply mark', () => {
|
|
|
359
359
|
});
|
|
360
360
|
|
|
361
361
|
editor.commands.setTextSelection({ from: 1, to: 31 });
|
|
362
|
-
editor.commands.applyMark(
|
|
362
|
+
editor.commands.applyMark(TextSetting.FONT_WEIGHT, { value: '700' });
|
|
363
363
|
|
|
364
364
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
365
365
|
});
|
|
@@ -370,10 +370,10 @@ describe('get marks', () => {
|
|
|
370
370
|
const editor = createEditor({
|
|
371
371
|
content: NodeFactory.doc([
|
|
372
372
|
NodeFactory.paragraph(null, [
|
|
373
|
-
NodeFactory.mark(
|
|
373
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '400' })
|
|
374
374
|
], [
|
|
375
375
|
NodeFactory.text('lorem', [
|
|
376
|
-
NodeFactory.mark(
|
|
376
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
377
377
|
]),
|
|
378
378
|
NodeFactory.text(' ipsum')
|
|
379
379
|
])
|
|
@@ -381,7 +381,7 @@ describe('get marks', () => {
|
|
|
381
381
|
});
|
|
382
382
|
|
|
383
383
|
editor.commands.selectAll();
|
|
384
|
-
const selectionRef = editor.commands.getMarks(
|
|
384
|
+
const selectionRef = editor.commands.getMarks(TextSetting.FONT_WEIGHT);
|
|
385
385
|
|
|
386
386
|
expect(selectionRef.value).toEqual([
|
|
387
387
|
{ value: '700' },
|
|
@@ -397,7 +397,7 @@ describe('get marks', () => {
|
|
|
397
397
|
});
|
|
398
398
|
|
|
399
399
|
editor.commands.selectAll();
|
|
400
|
-
const selectionRef = editor.commands.getMarks(
|
|
400
|
+
const selectionRef = editor.commands.getMarks(TextSetting.FONT_WEIGHT);
|
|
401
401
|
|
|
402
402
|
expect(selectionRef.value).toEqual([]);
|
|
403
403
|
});
|
|
@@ -408,10 +408,10 @@ describe('get mark', () => {
|
|
|
408
408
|
const editor = createEditor({
|
|
409
409
|
content: NodeFactory.doc([
|
|
410
410
|
NodeFactory.paragraph(null, [
|
|
411
|
-
NodeFactory.mark(
|
|
411
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '400' })
|
|
412
412
|
], [
|
|
413
413
|
NodeFactory.text('lorem', [
|
|
414
|
-
NodeFactory.mark(
|
|
414
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
415
415
|
]),
|
|
416
416
|
NodeFactory.text(' ipsum')
|
|
417
417
|
])
|
|
@@ -419,7 +419,7 @@ describe('get mark', () => {
|
|
|
419
419
|
});
|
|
420
420
|
|
|
421
421
|
editor.commands.selectAll();
|
|
422
|
-
const selectionRef = editor.commands.getMark(
|
|
422
|
+
const selectionRef = editor.commands.getMark(TextSetting.FONT_WEIGHT);
|
|
423
423
|
|
|
424
424
|
expect(selectionRef.value).toEqual({ value: '700' });
|
|
425
425
|
});
|
|
@@ -428,13 +428,13 @@ describe('get mark', () => {
|
|
|
428
428
|
const editor = createEditor({
|
|
429
429
|
content: NodeFactory.doc([
|
|
430
430
|
NodeFactory.paragraph(null, [
|
|
431
|
-
NodeFactory.mark(
|
|
431
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '400' })
|
|
432
432
|
], 'lorem ipsum')
|
|
433
433
|
])
|
|
434
434
|
});
|
|
435
435
|
|
|
436
436
|
editor.commands.selectAll();
|
|
437
|
-
const selectionRef = editor.commands.getMark(
|
|
437
|
+
const selectionRef = editor.commands.getMark(TextSetting.FONT_WEIGHT);
|
|
438
438
|
|
|
439
439
|
expect(selectionRef.value).toEqual({ value: '400' });
|
|
440
440
|
});
|
|
@@ -446,13 +446,13 @@ describe('has mark', () => {
|
|
|
446
446
|
content: NodeFactory.doc([
|
|
447
447
|
NodeFactory.paragraph([
|
|
448
448
|
NodeFactory.text('lorem ipsum', [
|
|
449
|
-
NodeFactory.mark(
|
|
449
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
450
450
|
])
|
|
451
451
|
])
|
|
452
452
|
])
|
|
453
453
|
});
|
|
454
454
|
|
|
455
|
-
expect(editor.commands.hasMark(
|
|
455
|
+
expect(editor.commands.hasMark(TextSetting.FONT_WEIGHT).value).toBe(true);
|
|
456
456
|
});
|
|
457
457
|
|
|
458
458
|
test('should not detect mark', () => {
|
|
@@ -462,7 +462,7 @@ describe('has mark', () => {
|
|
|
462
462
|
])
|
|
463
463
|
});
|
|
464
464
|
|
|
465
|
-
expect(editor.commands.hasMark(
|
|
465
|
+
expect(editor.commands.hasMark(TextSetting.FONT_WEIGHT).value).toBe(false);
|
|
466
466
|
});
|
|
467
467
|
});
|
|
468
468
|
|
|
@@ -471,13 +471,13 @@ describe('get setting mark', () => {
|
|
|
471
471
|
const editor = createEditor({
|
|
472
472
|
content: NodeFactory.doc([
|
|
473
473
|
NodeFactory.paragraph(null, [
|
|
474
|
-
NodeFactory.mark(
|
|
474
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '400' })
|
|
475
475
|
], 'lorem ipsum')
|
|
476
476
|
])
|
|
477
477
|
});
|
|
478
478
|
|
|
479
479
|
editor.commands.selectAll();
|
|
480
|
-
const selectionRef = editor.commands.getCommonSettingMark(
|
|
480
|
+
const selectionRef = editor.commands.getCommonSettingMark(TextSetting.FONT_WEIGHT);
|
|
481
481
|
|
|
482
482
|
expect(selectionRef.value).toBe('400');
|
|
483
483
|
});
|
|
@@ -490,7 +490,7 @@ describe('get setting mark', () => {
|
|
|
490
490
|
});
|
|
491
491
|
|
|
492
492
|
editor.commands.selectAll();
|
|
493
|
-
const selectionRef = editor.commands.getCommonSettingMark(
|
|
493
|
+
const selectionRef = editor.commands.getCommonSettingMark(TextSetting.FONT_WEIGHT, ref('400'));
|
|
494
494
|
|
|
495
495
|
expect(selectionRef.value).toBe('400');
|
|
496
496
|
});
|
|
@@ -499,14 +499,14 @@ describe('get setting mark', () => {
|
|
|
499
499
|
const editor = createEditor({
|
|
500
500
|
content: NodeFactory.doc([
|
|
501
501
|
NodeFactory.paragraph(null, [
|
|
502
|
-
NodeFactory.mark(
|
|
502
|
+
NodeFactory.mark(TextSetting.FONT_SIZE, { mobile: '23' })
|
|
503
503
|
], 'lorem ipsum')
|
|
504
504
|
]),
|
|
505
|
-
device:
|
|
505
|
+
device: Device.MOBILE
|
|
506
506
|
});
|
|
507
507
|
|
|
508
508
|
editor.commands.selectAll();
|
|
509
|
-
const selectionRef = editor.commands.getDeviceSettingMark(
|
|
509
|
+
const selectionRef = editor.commands.getDeviceSettingMark(TextSetting.FONT_SIZE);
|
|
510
510
|
|
|
511
511
|
expect(selectionRef.value).toBe('23');
|
|
512
512
|
});
|
|
@@ -516,11 +516,11 @@ describe('get setting mark', () => {
|
|
|
516
516
|
content: NodeFactory.doc([
|
|
517
517
|
NodeFactory.paragraph('lorem ipsum')
|
|
518
518
|
]),
|
|
519
|
-
device:
|
|
519
|
+
device: Device.MOBILE
|
|
520
520
|
});
|
|
521
521
|
|
|
522
522
|
editor.commands.selectAll();
|
|
523
|
-
const selectionRef = editor.commands.getDeviceSettingMark(
|
|
523
|
+
const selectionRef = editor.commands.getDeviceSettingMark(TextSetting.FONT_SIZE, ref('23'));
|
|
524
524
|
|
|
525
525
|
expect(selectionRef.value).toBe('23');
|
|
526
526
|
});
|
|
@@ -529,19 +529,19 @@ describe('get setting mark', () => {
|
|
|
529
529
|
const editor = createEditor({
|
|
530
530
|
content: NodeFactory.doc([
|
|
531
531
|
NodeFactory.paragraph(null, [
|
|
532
|
-
NodeFactory.mark(
|
|
532
|
+
NodeFactory.mark(TextSetting.FONT_SIZE, { mobile: '23' })
|
|
533
533
|
], [
|
|
534
534
|
NodeFactory.text('lorem', [
|
|
535
|
-
NodeFactory.mark(
|
|
535
|
+
NodeFactory.mark(TextSetting.FONT_SIZE, { tablet: '25' })
|
|
536
536
|
]),
|
|
537
537
|
NodeFactory.text(' ipsum')
|
|
538
538
|
])
|
|
539
539
|
]),
|
|
540
|
-
device:
|
|
540
|
+
device: Device.MOBILE
|
|
541
541
|
});
|
|
542
542
|
|
|
543
543
|
editor.commands.selectAll();
|
|
544
|
-
const selectionRef = editor.commands.getDeviceSettingMark(
|
|
544
|
+
const selectionRef = editor.commands.getDeviceSettingMark(TextSetting.FONT_SIZE);
|
|
545
545
|
|
|
546
546
|
expect(selectionRef.value).toBe('23');
|
|
547
547
|
});
|
|
@@ -553,7 +553,7 @@ describe('remove marks', () => {
|
|
|
553
553
|
content: NodeFactory.doc([
|
|
554
554
|
NodeFactory.paragraph([
|
|
555
555
|
NodeFactory.text('lorem', [
|
|
556
|
-
NodeFactory.mark(
|
|
556
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
557
557
|
]),
|
|
558
558
|
NodeFactory.text(' ipsum')
|
|
559
559
|
])
|
|
@@ -561,7 +561,7 @@ describe('remove marks', () => {
|
|
|
561
561
|
});
|
|
562
562
|
|
|
563
563
|
editor.commands.selectAll();
|
|
564
|
-
editor.commands.removeMarks([
|
|
564
|
+
editor.commands.removeMarks([TextSetting.FONT_WEIGHT]);
|
|
565
565
|
|
|
566
566
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
567
567
|
});
|
|
@@ -570,13 +570,13 @@ describe('remove marks', () => {
|
|
|
570
570
|
const editor = createEditor({
|
|
571
571
|
content: NodeFactory.doc([
|
|
572
572
|
NodeFactory.paragraph(null, [
|
|
573
|
-
NodeFactory.mark(
|
|
573
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
574
574
|
], 'lorem ipsum')
|
|
575
575
|
])
|
|
576
576
|
});
|
|
577
577
|
|
|
578
578
|
editor.commands.selectAll();
|
|
579
|
-
editor.commands.removeMarks([
|
|
579
|
+
editor.commands.removeMarks([TextSetting.FONT_WEIGHT]);
|
|
580
580
|
|
|
581
581
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
582
582
|
});
|
|
@@ -585,18 +585,18 @@ describe('remove marks', () => {
|
|
|
585
585
|
const editor = createEditor({
|
|
586
586
|
content: NodeFactory.doc([
|
|
587
587
|
NodeFactory.paragraph(null, [
|
|
588
|
-
NodeFactory.mark(
|
|
588
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
589
589
|
], [
|
|
590
590
|
NodeFactory.text('lorem'),
|
|
591
591
|
NodeFactory.text(' ipsum', [
|
|
592
|
-
NodeFactory.mark(
|
|
592
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '400' })
|
|
593
593
|
])
|
|
594
594
|
])
|
|
595
595
|
])
|
|
596
596
|
});
|
|
597
597
|
|
|
598
598
|
editor.commands.selectAll();
|
|
599
|
-
editor.commands.removeMarks([
|
|
599
|
+
editor.commands.removeMarks([TextSetting.FONT_WEIGHT]);
|
|
600
600
|
|
|
601
601
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
602
602
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Editor, Mark, Extension } from '@tiptap/vue-3';
|
|
2
2
|
import { buildTestExtensions } from '../../../__tests__/utils';
|
|
3
3
|
import { ContentNormalizer, NodeFactory } from '../../../services';
|
|
4
|
-
import {
|
|
4
|
+
import { NodeType, TextSetting } from '../../../enums';
|
|
5
5
|
|
|
6
6
|
const MockFontSize = Mark.create({
|
|
7
|
-
name:
|
|
7
|
+
name: TextSetting.FONT_SIZE,
|
|
8
8
|
|
|
9
9
|
addAttributes: () => ({
|
|
10
10
|
value: { default: null }
|
|
@@ -14,7 +14,7 @@ const MockFontSize = Mark.create({
|
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
const MockFontWeight = Mark.create({
|
|
17
|
-
name:
|
|
17
|
+
name: TextSetting.FONT_WEIGHT,
|
|
18
18
|
|
|
19
19
|
addAttributes: () => ({
|
|
20
20
|
value: { default: null }
|
|
@@ -24,13 +24,13 @@ const MockFontWeight = Mark.create({
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
const MockAlignment = Extension.create({
|
|
27
|
-
name:
|
|
27
|
+
name: TextSetting.ALIGNMENT,
|
|
28
28
|
|
|
29
29
|
addGlobalAttributes: () => [
|
|
30
30
|
{
|
|
31
|
-
types: [
|
|
31
|
+
types: [NodeType.PARAGRAPH, NodeType.HEADING],
|
|
32
32
|
attributes: {
|
|
33
|
-
[
|
|
33
|
+
[TextSetting.ALIGNMENT]: {
|
|
34
34
|
default: null,
|
|
35
35
|
renderHTML: () => ({})
|
|
36
36
|
}
|
|
@@ -40,7 +40,7 @@ const MockAlignment = Extension.create({
|
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
const MockBackgroundColor = Mark.create({
|
|
43
|
-
name:
|
|
43
|
+
name: TextSetting.BACKGROUND_COLOR,
|
|
44
44
|
|
|
45
45
|
addAttributes: () => ({
|
|
46
46
|
value: { default: null }
|
|
@@ -50,7 +50,7 @@ const MockBackgroundColor = Mark.create({
|
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
const MockFontColor = Mark.create({
|
|
53
|
-
name:
|
|
53
|
+
name: TextSetting.FONT_COLOR,
|
|
54
54
|
|
|
55
55
|
addAttributes: () => ({
|
|
56
56
|
value: { default: null }
|
|
@@ -60,7 +60,7 @@ const MockFontColor = Mark.create({
|
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
const MockFontFamily = Mark.create({
|
|
63
|
-
name:
|
|
63
|
+
name: TextSetting.FONT_FAMILY,
|
|
64
64
|
|
|
65
65
|
addAttributes: () => ({
|
|
66
66
|
value: { default: null }
|
|
@@ -70,7 +70,7 @@ const MockFontFamily = Mark.create({
|
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
const MockFontStyle = Mark.create({
|
|
73
|
-
name:
|
|
73
|
+
name: TextSetting.FONT_STYLE,
|
|
74
74
|
|
|
75
75
|
addAttributes: () => ({
|
|
76
76
|
value: { default: null }
|
|
@@ -80,7 +80,7 @@ const MockFontStyle = Mark.create({
|
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
const MockTextDecoration = Mark.create({
|
|
83
|
-
name:
|
|
83
|
+
name: TextSetting.TEXT_DECORATION,
|
|
84
84
|
|
|
85
85
|
addAttributes: () => ({
|
|
86
86
|
value: { default: null }
|
|
@@ -90,7 +90,7 @@ const MockTextDecoration = Mark.create({
|
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
const MockSuperscript = Mark.create({
|
|
93
|
-
name:
|
|
93
|
+
name: TextSetting.SUPERSCRIPT,
|
|
94
94
|
|
|
95
95
|
addAttributes: () => ({
|
|
96
96
|
value: { default: null }
|
|
@@ -138,7 +138,7 @@ describe('transform text', () => {
|
|
|
138
138
|
content: NodeFactory.doc([
|
|
139
139
|
NodeFactory.paragraph([
|
|
140
140
|
NodeFactory.text('hello world', [
|
|
141
|
-
NodeFactory.mark(
|
|
141
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
142
142
|
])
|
|
143
143
|
])
|
|
144
144
|
])
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Base from '@tiptap/extension-list-item';
|
|
2
|
-
import {
|
|
3
|
-
import { copyMark, createCommand } from '
|
|
2
|
+
import { MarkGroup, NodeType } from '@/enums';
|
|
3
|
+
import { copyMark, createCommand } from '@/utils';
|
|
4
4
|
|
|
5
5
|
export const ListItem = Base.extend({
|
|
6
|
-
name:
|
|
7
|
-
marks:
|
|
6
|
+
name: NodeType.LIST_ITEM,
|
|
7
|
+
marks: MarkGroup.SETTINGS,
|
|
8
8
|
|
|
9
9
|
addCommands() {
|
|
10
10
|
const getItemPosition = ({ selection }) => selection.$cursor.before(selection.$cursor.depth - 1);
|
|
@@ -38,7 +38,7 @@ export const ListItem = Base.extend({
|
|
|
38
38
|
const { state, commands } = context.editor;
|
|
39
39
|
|
|
40
40
|
const isListSelected = state.selection.$cursor?.path.some((node) => {
|
|
41
|
-
return node.type?.name ===
|
|
41
|
+
return node.type?.name === NodeType.LIST;
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
if (isListSelected) return commands.listItemNewline();
|