@zipify/wysiwyg 4.11.0-4 → 4.11.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/.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/wysiwyg.css +27 -27
- package/dist/wysiwyg.mjs +129 -164
- 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 +5 -5
- 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/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,16 +1,22 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/vue-3';
|
|
2
2
|
import { computed, toRef, unref } from 'vue';
|
|
3
3
|
import { createCommand } from '@/utils';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
NodeType,
|
|
6
|
+
TextAttributeSettingList,
|
|
7
|
+
TextBlockMarkList,
|
|
8
|
+
TextPresetAttributeSettingList,
|
|
9
|
+
TextSetting
|
|
10
|
+
} from '@/enums';
|
|
5
11
|
import { ContextWindow } from '@/services';
|
|
6
12
|
|
|
7
13
|
export const StylePreset = Extension.create({
|
|
8
|
-
name:
|
|
14
|
+
name: TextSetting.STYLE_PRESET,
|
|
9
15
|
|
|
10
16
|
addGlobalAttributes() {
|
|
11
17
|
return [
|
|
12
18
|
{
|
|
13
|
-
types: [
|
|
19
|
+
types: [NodeType.PARAGRAPH, NodeType.HEADING],
|
|
14
20
|
attributes: {
|
|
15
21
|
preset: {
|
|
16
22
|
isRequired: false,
|
|
@@ -97,7 +103,7 @@ export const StylePreset = Extension.create({
|
|
|
97
103
|
applyPreset: createCommand(({ commands, chain }, presetId) => {
|
|
98
104
|
const presets = unref(commands.getPresetList());
|
|
99
105
|
const preset = findPresetById(presets, presetId);
|
|
100
|
-
const nodeType = preset.node?.type ??
|
|
106
|
+
const nodeType = preset.node?.type ?? NodeType.PARAGRAPH;
|
|
101
107
|
|
|
102
108
|
const attrs = {
|
|
103
109
|
preset: { id: presetId }
|
|
@@ -107,7 +113,7 @@ export const StylePreset = Extension.create({
|
|
|
107
113
|
attrs.level = preset.node.level;
|
|
108
114
|
}
|
|
109
115
|
|
|
110
|
-
for (const textAttribute of
|
|
116
|
+
for (const textAttribute of TextAttributeSettingList) {
|
|
111
117
|
attrs[textAttribute] = unref(commands.getBlockAttributes(textAttribute));
|
|
112
118
|
}
|
|
113
119
|
|
|
@@ -119,7 +125,7 @@ export const StylePreset = Extension.create({
|
|
|
119
125
|
}),
|
|
120
126
|
|
|
121
127
|
removePreset: createCommand(({ commands }) => {
|
|
122
|
-
commands.setNode(
|
|
128
|
+
commands.setNode(NodeType.PARAGRAPH, { preset: null });
|
|
123
129
|
}),
|
|
124
130
|
|
|
125
131
|
getPresetCustomization: createCommand(({ editor, commands }) => {
|
|
@@ -135,7 +141,7 @@ export const StylePreset = Extension.create({
|
|
|
135
141
|
|
|
136
142
|
isSettingCustomized: createCommand(({ commands }, name) => {
|
|
137
143
|
const customization = commands.getPresetCustomization();
|
|
138
|
-
const group =
|
|
144
|
+
const group = TextPresetAttributeSettingList.includes(name) ? 'attributes' : 'marks';
|
|
139
145
|
|
|
140
146
|
return computed(() => unref(customization)[group]?.includes(name) ?? false);
|
|
141
147
|
}),
|
|
@@ -156,13 +162,13 @@ export const StylePreset = Extension.create({
|
|
|
156
162
|
|
|
157
163
|
doc.nodesBetween(from, to, (node) => {
|
|
158
164
|
for (const [name, value] of Object.entries(node.attrs)) {
|
|
159
|
-
const isSetting =
|
|
165
|
+
const isSetting = TextPresetAttributeSettingList.includes(name);
|
|
160
166
|
|
|
161
167
|
if (isSetting && value) attributes.add(name);
|
|
162
168
|
}
|
|
163
169
|
|
|
164
170
|
for (const { type } of node.marks) {
|
|
165
|
-
if (
|
|
171
|
+
if (TextBlockMarkList.includes(type.name)) {
|
|
166
172
|
marks.add(type.name);
|
|
167
173
|
}
|
|
168
174
|
}
|
|
@@ -178,9 +184,9 @@ export const StylePreset = Extension.create({
|
|
|
178
184
|
chain()
|
|
179
185
|
.storeSelection()
|
|
180
186
|
.expandSelectionToBlock()
|
|
181
|
-
.removeMarks(
|
|
182
|
-
.resetAttributes(
|
|
183
|
-
.resetAttributes(
|
|
187
|
+
.removeMarks(TextBlockMarkList)
|
|
188
|
+
.resetAttributes(NodeType.PARAGRAPH, TextPresetAttributeSettingList)
|
|
189
|
+
.resetAttributes(NodeType.HEADING, TextPresetAttributeSettingList)
|
|
184
190
|
.restoreSelection()
|
|
185
191
|
.run();
|
|
186
192
|
}),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-3';
|
|
2
2
|
import { computed, unref } from 'vue';
|
|
3
3
|
import { createCommand } from '../utils';
|
|
4
|
-
import {
|
|
4
|
+
import { TextSetting } from '../enums';
|
|
5
5
|
|
|
6
6
|
export const Superscript = Mark.create({
|
|
7
|
-
name:
|
|
7
|
+
name: TextSetting.SUPERSCRIPT,
|
|
8
8
|
|
|
9
9
|
addCommands() {
|
|
10
10
|
return {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-3';
|
|
2
2
|
import { computed, unref } from 'vue';
|
|
3
3
|
import { createCommand, createKeyboardShortcut, renderMark } from '../utils';
|
|
4
|
-
import {
|
|
4
|
+
import { TextSetting } from '../enums';
|
|
5
5
|
|
|
6
6
|
export const TextDecoration = Mark.create({
|
|
7
|
-
name:
|
|
7
|
+
name: TextSetting.TEXT_DECORATION,
|
|
8
8
|
priority: 1000,
|
|
9
9
|
|
|
10
10
|
addAttributes: () => ({
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { Editor, Extension } from '@tiptap/vue-3';
|
|
2
2
|
import { ref } from 'vue';
|
|
3
|
-
import { buildTestExtensions } from '
|
|
4
|
-
import { createCommand } from '
|
|
5
|
-
import { Alignment } from '
|
|
3
|
+
import { buildTestExtensions } from '@/__tests__/utils';
|
|
4
|
+
import { createCommand } from '@/utils';
|
|
5
|
+
import { Alignment, TextSetting } from '@/enums';
|
|
6
|
+
import { ContentNormalizer, NodeFactory } from '@/services';
|
|
7
|
+
import { AlignmentExtension } from '../Alignment';
|
|
6
8
|
import { DeviceManager } from '../DeviceManager';
|
|
7
|
-
import { Alignments, TextSettings } from '../../enums';
|
|
8
|
-
import { ContentNormalizer, NodeFactory } from '../../services';
|
|
9
9
|
|
|
10
10
|
const MockStylePreset = Extension.create({
|
|
11
|
-
name:
|
|
11
|
+
name: TextSetting.STYLE_PRESET,
|
|
12
12
|
|
|
13
13
|
addCommands() {
|
|
14
14
|
return {
|
|
15
15
|
getPreset: createCommand(() => ref({
|
|
16
|
-
mobile: { alignment:
|
|
17
|
-
tablet: { alignment:
|
|
18
|
-
desktop: { alignment:
|
|
16
|
+
mobile: { alignment: Alignment.JUSTIFY },
|
|
17
|
+
tablet: { alignment: Alignment.JUSTIFY },
|
|
18
|
+
desktop: { alignment: Alignment.JUSTIFY }
|
|
19
19
|
}))
|
|
20
20
|
};
|
|
21
21
|
}
|
|
@@ -28,7 +28,7 @@ function createEditor({ content }) {
|
|
|
28
28
|
include: [
|
|
29
29
|
MockStylePreset,
|
|
30
30
|
DeviceManager.configure({ device: ref('desktop') }),
|
|
31
|
-
|
|
31
|
+
AlignmentExtension
|
|
32
32
|
]
|
|
33
33
|
})
|
|
34
34
|
});
|
|
@@ -44,13 +44,13 @@ describe('get value', () => {
|
|
|
44
44
|
test('should get from selection', () => {
|
|
45
45
|
const editor = createEditor({
|
|
46
46
|
content: createContent({
|
|
47
|
-
alignment: { desktop:
|
|
47
|
+
alignment: { desktop: Alignment.CENTER }
|
|
48
48
|
})
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
editor.commands.selectAll();
|
|
52
52
|
|
|
53
|
-
expect(editor.commands.getAlignment().value).toEqual(
|
|
53
|
+
expect(editor.commands.getAlignment().value).toEqual(Alignment.CENTER);
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
test('should get default value', () => {
|
|
@@ -58,7 +58,7 @@ describe('get value', () => {
|
|
|
58
58
|
content: createContent({ alignment: null })
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
expect(editor.commands.getDefaultAlignment().value).toEqual(
|
|
61
|
+
expect(editor.commands.getDefaultAlignment().value).toEqual(Alignment.JUSTIFY);
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
test('should get from preset', () => {
|
|
@@ -66,7 +66,7 @@ describe('get value', () => {
|
|
|
66
66
|
content: createContent({ alignment: null })
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
expect(editor.commands.getAlignment().value).toEqual(
|
|
69
|
+
expect(editor.commands.getAlignment().value).toEqual(Alignment.JUSTIFY);
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
|
|
@@ -77,7 +77,7 @@ describe('change value', () => {
|
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
editor.commands.selectAll();
|
|
80
|
-
editor.commands.applyAlignment(
|
|
80
|
+
editor.commands.applyAlignment(Alignment.RIGHT);
|
|
81
81
|
|
|
82
82
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
83
83
|
});
|
|
@@ -85,12 +85,12 @@ describe('change value', () => {
|
|
|
85
85
|
test('should remove value', () => {
|
|
86
86
|
const editor = createEditor({
|
|
87
87
|
content: createContent({
|
|
88
|
-
alignment: { desktop:
|
|
88
|
+
alignment: { desktop: Alignment.CENTER }
|
|
89
89
|
})
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
editor.commands.selectAll();
|
|
93
|
-
editor.commands.removeAlignment(
|
|
93
|
+
editor.commands.removeAlignment(TextSetting.ALIGNMENT);
|
|
94
94
|
|
|
95
95
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
96
96
|
});
|
|
@@ -100,7 +100,7 @@ describe('rendering', () => {
|
|
|
100
100
|
test('should render only desktop', () => {
|
|
101
101
|
const editor = createEditor({
|
|
102
102
|
content: createContent({
|
|
103
|
-
alignment: { desktop:
|
|
103
|
+
alignment: { desktop: Alignment.CENTER }
|
|
104
104
|
})
|
|
105
105
|
});
|
|
106
106
|
|
|
@@ -111,9 +111,9 @@ describe('rendering', () => {
|
|
|
111
111
|
const editor = createEditor({
|
|
112
112
|
content: createContent({
|
|
113
113
|
alignment: {
|
|
114
|
-
desktop:
|
|
115
|
-
tablet:
|
|
116
|
-
mobile:
|
|
114
|
+
desktop: Alignment.CENTER,
|
|
115
|
+
tablet: Alignment.RIGHT,
|
|
116
|
+
mobile: Alignment.LEFT
|
|
117
117
|
}
|
|
118
118
|
})
|
|
119
119
|
});
|
|
@@ -4,10 +4,10 @@ import { buildTestExtensions } from '../../__tests__/utils';
|
|
|
4
4
|
import { createCommand } from '../../utils';
|
|
5
5
|
import { BackgroundColor } from '../BackgroundColor';
|
|
6
6
|
import { ContentNormalizer, NodeFactory } from '../../services';
|
|
7
|
-
import {
|
|
7
|
+
import { TextSetting } from '../../enums';
|
|
8
8
|
|
|
9
9
|
const MockStylePreset = Extension.create({
|
|
10
|
-
name:
|
|
10
|
+
name: TextSetting.STYLE_PRESET,
|
|
11
11
|
|
|
12
12
|
addCommands() {
|
|
13
13
|
return {
|
|
@@ -35,7 +35,7 @@ describe('get background color', () => {
|
|
|
35
35
|
test('should get from selection', () => {
|
|
36
36
|
const editor = createEditor({
|
|
37
37
|
content: createContent(NodeFactory.text('hello world', [
|
|
38
|
-
NodeFactory.mark(
|
|
38
|
+
NodeFactory.mark(TextSetting.BACKGROUND_COLOR, { value: 'green' })
|
|
39
39
|
]))
|
|
40
40
|
});
|
|
41
41
|
|
|
@@ -70,7 +70,7 @@ describe('rendering', () => {
|
|
|
70
70
|
test('should render html', () => {
|
|
71
71
|
const editor = createEditor({
|
|
72
72
|
content: createContent(NodeFactory.text('hello world', [
|
|
73
|
-
NodeFactory.mark(
|
|
73
|
+
NodeFactory.mark(TextSetting.BACKGROUND_COLOR, { value: 'green' })
|
|
74
74
|
]))
|
|
75
75
|
});
|
|
76
76
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Editor } from '@tiptap/vue-3';
|
|
2
|
-
import { buildTestExtensions } from '
|
|
3
|
-
import { ContentNormalizer, NodeFactory } from '
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { buildTestExtensions } from '@/__tests__/utils';
|
|
3
|
+
import { ContentNormalizer, NodeFactory } from '@/services';
|
|
4
|
+
import { CaseStyle } from '@/enums';
|
|
5
|
+
import { CaseStyleExtension } from '../CaseStyle';
|
|
6
6
|
|
|
7
7
|
function createEditor({ content }) {
|
|
8
8
|
return new Editor({
|
|
9
9
|
content: ContentNormalizer.normalize(content),
|
|
10
|
-
extensions: buildTestExtensions({ include: [
|
|
10
|
+
extensions: buildTestExtensions({ include: [CaseStyleExtension] })
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -55,7 +55,7 @@ describe('apply case style', () => {
|
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
editor.commands.selectAll();
|
|
58
|
-
editor.commands.applyCaseStyle(
|
|
58
|
+
editor.commands.applyCaseStyle(CaseStyle.CAPITALIZE);
|
|
59
59
|
|
|
60
60
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
61
61
|
});
|
|
@@ -4,10 +4,10 @@ import { buildTestExtensions } from '../../__tests__/utils';
|
|
|
4
4
|
import { createCommand } from '../../utils';
|
|
5
5
|
import { FontColor } from '../FontColor';
|
|
6
6
|
import { ContentNormalizer, NodeFactory } from '../../services';
|
|
7
|
-
import {
|
|
7
|
+
import { TextSetting } from '../../enums';
|
|
8
8
|
|
|
9
9
|
const MockStylePreset = Extension.create({
|
|
10
|
-
name:
|
|
10
|
+
name: TextSetting.STYLE_PRESET,
|
|
11
11
|
|
|
12
12
|
addCommands() {
|
|
13
13
|
return {
|
|
@@ -35,7 +35,7 @@ describe('get font color', () => {
|
|
|
35
35
|
test('should get from selection', () => {
|
|
36
36
|
const editor = createEditor({
|
|
37
37
|
content: createContent(NodeFactory.text('hello world', [
|
|
38
|
-
NodeFactory.mark(
|
|
38
|
+
NodeFactory.mark(TextSetting.FONT_COLOR, { value: 'green' })
|
|
39
39
|
]))
|
|
40
40
|
});
|
|
41
41
|
|
|
@@ -80,7 +80,7 @@ describe('rendering', () => {
|
|
|
80
80
|
test('should render html', () => {
|
|
81
81
|
const editor = createEditor({
|
|
82
82
|
content: createContent(NodeFactory.text('hello world', [
|
|
83
|
-
NodeFactory.mark(
|
|
83
|
+
NodeFactory.mark(TextSetting.FONT_COLOR, { value: 'green' })
|
|
84
84
|
]))
|
|
85
85
|
});
|
|
86
86
|
|
|
@@ -7,10 +7,10 @@ import { FontFamily } from '../FontFamily';
|
|
|
7
7
|
import { FontWeight } from '../FontWeight';
|
|
8
8
|
import { FontStyle } from '../FontStyle';
|
|
9
9
|
import { ContentNormalizer, NodeFactory } from '../../services';
|
|
10
|
-
import {
|
|
10
|
+
import { TextSetting } from '../../enums';
|
|
11
11
|
|
|
12
12
|
const MockStylePreset = Extension.create({
|
|
13
|
-
name:
|
|
13
|
+
name: TextSetting.STYLE_PRESET,
|
|
14
14
|
|
|
15
15
|
addCommands() {
|
|
16
16
|
return {
|
|
@@ -57,7 +57,7 @@ describe('get font family', () => {
|
|
|
57
57
|
test('should get from selection', () => {
|
|
58
58
|
const editor = createEditor({
|
|
59
59
|
content: createContent(NodeFactory.text('hello world', [
|
|
60
|
-
NodeFactory.mark(
|
|
60
|
+
NodeFactory.mark(TextSetting.FONT_FAMILY, { value: 'Bungee' })
|
|
61
61
|
]))
|
|
62
62
|
});
|
|
63
63
|
|
|
@@ -122,7 +122,7 @@ describe('apply font family', () => {
|
|
|
122
122
|
test('should not change current font weight if available', () => {
|
|
123
123
|
const editor = createEditor({
|
|
124
124
|
content: createContent(NodeFactory.text('hello world', [
|
|
125
|
-
NodeFactory.mark(
|
|
125
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
126
126
|
]))
|
|
127
127
|
});
|
|
128
128
|
|
|
@@ -135,7 +135,7 @@ describe('apply font family', () => {
|
|
|
135
135
|
test('should apply closest font weight if current is unavailable', () => {
|
|
136
136
|
const editor = createEditor({
|
|
137
137
|
content: createContent(NodeFactory.text('hello world', [
|
|
138
|
-
NodeFactory.mark(
|
|
138
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
139
139
|
]))
|
|
140
140
|
});
|
|
141
141
|
|
|
@@ -148,8 +148,8 @@ describe('apply font family', () => {
|
|
|
148
148
|
test('should not change italic if available', () => {
|
|
149
149
|
const editor = createEditor({
|
|
150
150
|
content: createContent(NodeFactory.text('hello world', [
|
|
151
|
-
NodeFactory.mark(
|
|
152
|
-
NodeFactory.mark(
|
|
151
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' }),
|
|
152
|
+
NodeFactory.mark(TextSetting.FONT_STYLE, { italic: true })
|
|
153
153
|
]))
|
|
154
154
|
});
|
|
155
155
|
|
|
@@ -162,8 +162,8 @@ describe('apply font family', () => {
|
|
|
162
162
|
test('should remove italic if unavailable', () => {
|
|
163
163
|
const editor = createEditor({
|
|
164
164
|
content: createContent(NodeFactory.text('hello world', [
|
|
165
|
-
NodeFactory.mark(
|
|
166
|
-
NodeFactory.mark(
|
|
165
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' }),
|
|
166
|
+
NodeFactory.mark(TextSetting.FONT_STYLE, { italic: true })
|
|
167
167
|
]))
|
|
168
168
|
});
|
|
169
169
|
|
|
@@ -178,7 +178,7 @@ describe('rendering', () => {
|
|
|
178
178
|
test('should render html', () => {
|
|
179
179
|
const editor = createEditor({
|
|
180
180
|
content: createContent(NodeFactory.text('hello world', [
|
|
181
|
-
NodeFactory.mark(
|
|
181
|
+
NodeFactory.mark(TextSetting.FONT_FAMILY, { value: 'Bungee' })
|
|
182
182
|
]))
|
|
183
183
|
});
|
|
184
184
|
|
|
@@ -5,10 +5,10 @@ import { createCommand } from '../../utils';
|
|
|
5
5
|
import { FontSize } from '../FontSize';
|
|
6
6
|
import { DeviceManager } from '../DeviceManager';
|
|
7
7
|
import { ContentNormalizer, NodeFactory } from '../../services';
|
|
8
|
-
import {
|
|
8
|
+
import { TextSetting } from '../../enums';
|
|
9
9
|
|
|
10
10
|
const MockStylePreset = Extension.create({
|
|
11
|
-
name:
|
|
11
|
+
name: TextSetting.STYLE_PRESET,
|
|
12
12
|
|
|
13
13
|
addCommands() {
|
|
14
14
|
return {
|
|
@@ -48,7 +48,7 @@ describe('get font size', () => {
|
|
|
48
48
|
test('should get from selection', () => {
|
|
49
49
|
const editor = createEditor({
|
|
50
50
|
content: createContent(NodeFactory.text('hello world'[
|
|
51
|
-
NodeFactory.mark(
|
|
51
|
+
NodeFactory.mark(TextSetting.FONT_SIZE, {
|
|
52
52
|
mobile: null,
|
|
53
53
|
tablet: null,
|
|
54
54
|
desktop: '14'
|
|
@@ -95,7 +95,7 @@ describe('apply font size', () => {
|
|
|
95
95
|
test('should increase font size', () => {
|
|
96
96
|
const editor = createEditor({
|
|
97
97
|
content: createContent(NodeFactory.text('hello world', [
|
|
98
|
-
NodeFactory.mark(
|
|
98
|
+
NodeFactory.mark(TextSetting.FONT_SIZE, {
|
|
99
99
|
mobile: null,
|
|
100
100
|
tablet: null,
|
|
101
101
|
desktop: '14'
|
|
@@ -112,7 +112,7 @@ describe('apply font size', () => {
|
|
|
112
112
|
test('should not increase font size if reached limit', () => {
|
|
113
113
|
const editor = createEditor({
|
|
114
114
|
content: createContent(NodeFactory.text('hello world', [
|
|
115
|
-
NodeFactory.mark(
|
|
115
|
+
NodeFactory.mark(TextSetting.FONT_SIZE, {
|
|
116
116
|
mobile: null,
|
|
117
117
|
tablet: null,
|
|
118
118
|
desktop: '20'
|
|
@@ -129,7 +129,7 @@ describe('apply font size', () => {
|
|
|
129
129
|
test('should decrease font size', () => {
|
|
130
130
|
const editor = createEditor({
|
|
131
131
|
content: createContent(NodeFactory.text('hello world', [
|
|
132
|
-
NodeFactory.mark(
|
|
132
|
+
NodeFactory.mark(TextSetting.FONT_SIZE, {
|
|
133
133
|
mobile: null,
|
|
134
134
|
tablet: null,
|
|
135
135
|
desktop: '14'
|
|
@@ -146,7 +146,7 @@ describe('apply font size', () => {
|
|
|
146
146
|
test('should not decrease font size if reached limit', () => {
|
|
147
147
|
const editor = createEditor({
|
|
148
148
|
content: createContent(NodeFactory.text('hello world', [
|
|
149
|
-
NodeFactory.mark(
|
|
149
|
+
NodeFactory.mark(TextSetting.FONT_SIZE, {
|
|
150
150
|
mobile: null,
|
|
151
151
|
tablet: null,
|
|
152
152
|
desktop: '5'
|
|
@@ -165,7 +165,7 @@ describe('rendering', () => {
|
|
|
165
165
|
test('should render only desktop', () => {
|
|
166
166
|
const editor = createEditor({
|
|
167
167
|
content: createContent(NodeFactory.text('hello world', [
|
|
168
|
-
NodeFactory.mark(
|
|
168
|
+
NodeFactory.mark(TextSetting.FONT_SIZE, {
|
|
169
169
|
mobile: null,
|
|
170
170
|
tablet: null,
|
|
171
171
|
desktop: '14'
|
|
@@ -179,7 +179,7 @@ describe('rendering', () => {
|
|
|
179
179
|
test('should render all devices', () => {
|
|
180
180
|
const editor = createEditor({
|
|
181
181
|
content: createContent(NodeFactory.text('hello world', [
|
|
182
|
-
NodeFactory.mark(
|
|
182
|
+
NodeFactory.mark(TextSetting.FONT_SIZE, {
|
|
183
183
|
mobile: '12',
|
|
184
184
|
tablet: '14',
|
|
185
185
|
desktop: '16'
|
|
@@ -7,10 +7,10 @@ import { FontFamily } from '../FontFamily';
|
|
|
7
7
|
import { Font } from '../../models';
|
|
8
8
|
import { FontWeight } from '../FontWeight';
|
|
9
9
|
import { ContentNormalizer, NodeFactory } from '../../services';
|
|
10
|
-
import {
|
|
10
|
+
import { TextSetting } from '../../enums';
|
|
11
11
|
|
|
12
12
|
const MockStylePreset = Extension.create({
|
|
13
|
-
name:
|
|
13
|
+
name: TextSetting.STYLE_PRESET,
|
|
14
14
|
|
|
15
15
|
addCommands() {
|
|
16
16
|
return {
|
|
@@ -55,7 +55,7 @@ describe('get font style', () => {
|
|
|
55
55
|
test('should get italic from selection', () => {
|
|
56
56
|
const editor = createEditor({
|
|
57
57
|
content: createContent(NodeFactory.text('hello world', [
|
|
58
|
-
NodeFactory.mark(
|
|
58
|
+
NodeFactory.mark(TextSetting.FONT_STYLE, { italic: true })
|
|
59
59
|
]))
|
|
60
60
|
});
|
|
61
61
|
|
|
@@ -98,7 +98,7 @@ describe('apply font style', () => {
|
|
|
98
98
|
test('should remove italic', () => {
|
|
99
99
|
const editor = createEditor({
|
|
100
100
|
content: createContent(NodeFactory.text('hello world', [
|
|
101
|
-
NodeFactory.mark(
|
|
101
|
+
NodeFactory.mark(TextSetting.FONT_STYLE, { italic: true })
|
|
102
102
|
]))
|
|
103
103
|
});
|
|
104
104
|
|
|
@@ -111,7 +111,7 @@ describe('apply font style', () => {
|
|
|
111
111
|
test('should toggle italic to removed', () => {
|
|
112
112
|
const editor = createEditor({
|
|
113
113
|
content: createContent(NodeFactory.text('hello world', [
|
|
114
|
-
NodeFactory.mark(
|
|
114
|
+
NodeFactory.mark(TextSetting.FONT_STYLE, { italic: true })
|
|
115
115
|
]))
|
|
116
116
|
});
|
|
117
117
|
|
|
@@ -137,7 +137,7 @@ describe('rendering', () => {
|
|
|
137
137
|
test('should render html', () => {
|
|
138
138
|
const editor = createEditor({
|
|
139
139
|
content: createContent(NodeFactory.text('hello world', [
|
|
140
|
-
NodeFactory.mark(
|
|
140
|
+
NodeFactory.mark(TextSetting.FONT_STYLE, { italic: true })
|
|
141
141
|
]))
|
|
142
142
|
});
|
|
143
143
|
|
|
@@ -4,13 +4,13 @@ import { buildTestExtensions } from '../../__tests__/utils';
|
|
|
4
4
|
import { createCommand } from '../../utils';
|
|
5
5
|
import { ContentNormalizer, NodeFactory } from '../../services';
|
|
6
6
|
import { Font } from '../../models';
|
|
7
|
-
import {
|
|
7
|
+
import { TextSetting } from '../../enums';
|
|
8
8
|
import { FontWeight } from '../FontWeight';
|
|
9
9
|
import { FontFamily } from '../FontFamily';
|
|
10
10
|
import { FontStyle } from '../FontStyle';
|
|
11
11
|
|
|
12
12
|
const MockStylePreset = Extension.create({
|
|
13
|
-
name:
|
|
13
|
+
name: TextSetting.STYLE_PRESET,
|
|
14
14
|
|
|
15
15
|
addCommands() {
|
|
16
16
|
return {
|
|
@@ -54,7 +54,7 @@ describe('get font weight', () => {
|
|
|
54
54
|
test('should get from selection', () => {
|
|
55
55
|
const editor = createEditor({
|
|
56
56
|
content: createContent(NodeFactory.text('hello world', [
|
|
57
|
-
NodeFactory.mark(
|
|
57
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
58
58
|
]))
|
|
59
59
|
});
|
|
60
60
|
|
|
@@ -84,7 +84,7 @@ describe('get font weight', () => {
|
|
|
84
84
|
test('should get closest available font weight', () => {
|
|
85
85
|
const editor = createEditor({
|
|
86
86
|
content: createContent(NodeFactory.text('hello world', [
|
|
87
|
-
NodeFactory.mark(
|
|
87
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '800' })
|
|
88
88
|
]))
|
|
89
89
|
});
|
|
90
90
|
|
|
@@ -109,7 +109,7 @@ describe('apply font weight', () => {
|
|
|
109
109
|
test('should toggle weight to bold', () => {
|
|
110
110
|
const editor = createEditor({
|
|
111
111
|
content: createContent(NodeFactory.text('hello world', [
|
|
112
|
-
NodeFactory.mark(
|
|
112
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '400' })
|
|
113
113
|
]))
|
|
114
114
|
});
|
|
115
115
|
|
|
@@ -122,8 +122,8 @@ describe('apply font weight', () => {
|
|
|
122
122
|
test('should toggle weight to closest bold', () => {
|
|
123
123
|
const editor = createEditor({
|
|
124
124
|
content: createContent(NodeFactory.text('hello world', [
|
|
125
|
-
NodeFactory.mark(
|
|
126
|
-
NodeFactory.mark(
|
|
125
|
+
NodeFactory.mark(TextSetting.FONT_FAMILY, { value: 'Bungee' }),
|
|
126
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '400' })
|
|
127
127
|
]))
|
|
128
128
|
});
|
|
129
129
|
|
|
@@ -136,7 +136,7 @@ describe('apply font weight', () => {
|
|
|
136
136
|
test('should toggle weight to medium', () => {
|
|
137
137
|
const editor = createEditor({
|
|
138
138
|
content: createContent(NodeFactory.text('hello world', [
|
|
139
|
-
NodeFactory.mark(
|
|
139
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
140
140
|
]))
|
|
141
141
|
});
|
|
142
142
|
|
|
@@ -149,8 +149,8 @@ describe('apply font weight', () => {
|
|
|
149
149
|
test('should toggle weight to closest medium', () => {
|
|
150
150
|
const editor = createEditor({
|
|
151
151
|
content: createContent(NodeFactory.text('hello world', [
|
|
152
|
-
NodeFactory.mark(
|
|
153
|
-
NodeFactory.mark(
|
|
152
|
+
NodeFactory.mark(TextSetting.FONT_FAMILY, { value: 'Bungee' }),
|
|
153
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '800' })
|
|
154
154
|
]))
|
|
155
155
|
});
|
|
156
156
|
|
|
@@ -165,7 +165,7 @@ describe('rendering', () => {
|
|
|
165
165
|
test('should render html', () => {
|
|
166
166
|
const editor = createEditor({
|
|
167
167
|
content: createContent(NodeFactory.text('hello world', [
|
|
168
|
-
NodeFactory.mark(
|
|
168
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
169
169
|
]))
|
|
170
170
|
});
|
|
171
171
|
|
|
@@ -5,10 +5,10 @@ import { createCommand } from '../../utils';
|
|
|
5
5
|
import { DeviceManager } from '../DeviceManager';
|
|
6
6
|
import { LineHeight } from '../LineHeight';
|
|
7
7
|
import { ContentNormalizer, NodeFactory } from '../../services';
|
|
8
|
-
import {
|
|
8
|
+
import { TextSetting } from '../../enums';
|
|
9
9
|
|
|
10
10
|
const MockStylePreset = Extension.create({
|
|
11
|
-
name:
|
|
11
|
+
name: TextSetting.STYLE_PRESET,
|
|
12
12
|
|
|
13
13
|
addCommands() {
|
|
14
14
|
return {
|