@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,7 +1,7 @@
|
|
|
1
1
|
import { ref } from 'vue';
|
|
2
|
-
import { withComponentContext } from '
|
|
3
|
-
import { InjectionTokens } from '
|
|
4
|
-
import {
|
|
2
|
+
import { withComponentContext } from '@/__tests__/utils';
|
|
3
|
+
import { InjectionTokens } from '@/injectionTokens';
|
|
4
|
+
import { LinkDestination, LinkTarget } from '@/enums';
|
|
5
5
|
import { useLink } from '../useLink';
|
|
6
6
|
|
|
7
7
|
const createEditor = (text, destination) => ({
|
|
@@ -42,8 +42,8 @@ describe('init link', () => {
|
|
|
42
42
|
|
|
43
43
|
link.prepareInitialFields();
|
|
44
44
|
|
|
45
|
-
expect(link.currentDestination.value.id).toBe(
|
|
46
|
-
expect(link.linkData.value.target).toBe(
|
|
45
|
+
expect(link.currentDestination.value.id).toBe(LinkDestination.URL);
|
|
46
|
+
expect(link.linkData.value.target).toBe(LinkTarget.SELF);
|
|
47
47
|
expect(link.destinationHrefs.value).toMatchSnapshot();
|
|
48
48
|
});
|
|
49
49
|
|
|
@@ -66,7 +66,7 @@ describe('actions with link', () => {
|
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
test('should update block destination', () => {
|
|
69
|
-
const link = useComposable('hello world',
|
|
69
|
+
const link = useComposable('hello world', LinkDestination.BLOCK);
|
|
70
70
|
|
|
71
71
|
link.prepareInitialFields();
|
|
72
72
|
link.updateLink('3456');
|
|
@@ -91,9 +91,9 @@ describe('actions with link', () => {
|
|
|
91
91
|
link.apply();
|
|
92
92
|
|
|
93
93
|
expect(link.editor.commands.applyLink).toHaveBeenCalledWith({
|
|
94
|
-
destination:
|
|
94
|
+
destination: LinkDestination.URL,
|
|
95
95
|
href: '/world',
|
|
96
|
-
target:
|
|
96
|
+
target: LinkTarget.SELF,
|
|
97
97
|
text: 'hello'
|
|
98
98
|
});
|
|
99
99
|
});
|
|
@@ -103,7 +103,7 @@ describe('actions with link', () => {
|
|
|
103
103
|
|
|
104
104
|
link.updateTarget(false);
|
|
105
105
|
|
|
106
|
-
expect(link.linkData.value.target).toBe(
|
|
106
|
+
expect(link.linkData.value.target).toBe(LinkTarget.SELF);
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
test('should apply link target to current window', () => {
|
|
@@ -111,7 +111,7 @@ describe('actions with link', () => {
|
|
|
111
111
|
|
|
112
112
|
link.updateTarget(true);
|
|
113
113
|
|
|
114
|
-
expect(link.linkData.value.target).toBe(
|
|
114
|
+
expect(link.linkData.value.target).toBe(LinkTarget.BLANK);
|
|
115
115
|
});
|
|
116
116
|
|
|
117
117
|
test('should reset destination', () => {
|
|
@@ -133,9 +133,9 @@ describe('format link', () => {
|
|
|
133
133
|
link.apply();
|
|
134
134
|
|
|
135
135
|
expect(link.editor.commands.applyLink).toHaveBeenCalledWith({
|
|
136
|
-
destination:
|
|
136
|
+
destination: LinkDestination.URL,
|
|
137
137
|
href: 'https://world.com',
|
|
138
|
-
target:
|
|
138
|
+
target: LinkTarget.SELF,
|
|
139
139
|
text: 'hello'
|
|
140
140
|
});
|
|
141
141
|
});
|
|
@@ -149,9 +149,9 @@ describe('format link', () => {
|
|
|
149
149
|
link.apply();
|
|
150
150
|
|
|
151
151
|
expect(link.editor.commands.applyLink).toHaveBeenCalledWith({
|
|
152
|
-
destination:
|
|
152
|
+
destination: LinkDestination.URL,
|
|
153
153
|
href: 'https://world.com',
|
|
154
|
-
target:
|
|
154
|
+
target: LinkTarget.SELF,
|
|
155
155
|
text: 'hello'
|
|
156
156
|
});
|
|
157
157
|
});
|
|
@@ -165,9 +165,9 @@ describe('format link', () => {
|
|
|
165
165
|
link.apply();
|
|
166
166
|
|
|
167
167
|
expect(link.editor.commands.applyLink).toHaveBeenCalledWith({
|
|
168
|
-
destination:
|
|
168
|
+
destination: LinkDestination.URL,
|
|
169
169
|
href: '/world/new',
|
|
170
|
-
target:
|
|
170
|
+
target: LinkTarget.SELF,
|
|
171
171
|
text: 'hello'
|
|
172
172
|
});
|
|
173
173
|
});
|
|
@@ -181,9 +181,9 @@ describe('format link', () => {
|
|
|
181
181
|
link.apply();
|
|
182
182
|
|
|
183
183
|
expect(link.editor.commands.applyLink).toHaveBeenCalledWith({
|
|
184
|
-
destination:
|
|
184
|
+
destination: LinkDestination.URL,
|
|
185
185
|
href: 'tel:0123456789',
|
|
186
|
-
target:
|
|
186
|
+
target: LinkTarget.SELF,
|
|
187
187
|
text: 'hello'
|
|
188
188
|
});
|
|
189
189
|
});
|
|
@@ -197,9 +197,9 @@ describe('format link', () => {
|
|
|
197
197
|
link.apply();
|
|
198
198
|
|
|
199
199
|
expect(link.editor.commands.applyLink).toHaveBeenCalledWith({
|
|
200
|
-
destination:
|
|
200
|
+
destination: LinkDestination.URL,
|
|
201
201
|
href: 'mailto:example@gmail.com',
|
|
202
|
-
target:
|
|
202
|
+
target: LinkTarget.SELF,
|
|
203
203
|
text: 'hello'
|
|
204
204
|
});
|
|
205
205
|
});
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { ref, inject } from 'vue';
|
|
2
|
-
import {
|
|
3
|
-
import { InjectionTokens } from '
|
|
4
|
-
import { RegExps } from '
|
|
2
|
+
import { LinkTarget, LinkDestination, TextSetting } from '@/enums';
|
|
3
|
+
import { InjectionTokens } from '@/injectionTokens';
|
|
4
|
+
import { RegExps } from '@/regExps';
|
|
5
5
|
|
|
6
6
|
// TODO NEED refactor it
|
|
7
7
|
export function useLink() {
|
|
8
8
|
const editor = inject(InjectionTokens.EDITOR);
|
|
9
9
|
const pageBlocks = inject(InjectionTokens.PAGE_BLOCKS);
|
|
10
10
|
|
|
11
|
-
const linkData = ref({ text: '', target:
|
|
11
|
+
const linkData = ref({ text: '', target: LinkTarget.SELF, destination: LinkDestination.URL });
|
|
12
12
|
const destinationHrefs = ref({ block: pageBlocks.value[0].id, url: '' });
|
|
13
|
-
const currentDestination = ref({ id:
|
|
13
|
+
const currentDestination = ref({ id: LinkDestination.URL });
|
|
14
14
|
|
|
15
15
|
function updateTarget(isChecked) {
|
|
16
|
-
linkData.value.target = isChecked ?
|
|
16
|
+
linkData.value.target = isChecked ? LinkTarget.BLANK : LinkTarget.SELF;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
function prepareInitialFields() {
|
|
20
20
|
editor.commands.expandSelectionToLink();
|
|
21
21
|
linkData.value.text = editor.commands.getSelectedText();
|
|
22
22
|
|
|
23
|
-
const { destination, href, target } = editor.getAttributes(
|
|
23
|
+
const { destination, href, target } = editor.getAttributes(TextSetting.LINK);
|
|
24
24
|
|
|
25
|
-
currentDestination.value.id = destination ||
|
|
26
|
-
linkData.value.target = target ||
|
|
25
|
+
currentDestination.value.id = destination || LinkDestination.URL;
|
|
26
|
+
linkData.value.target = target || LinkTarget.SELF;
|
|
27
27
|
destinationHrefs.value[currentDestination.value.id] = href || '';
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -33,7 +33,7 @@ export function useLink() {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
function getFormattedHref() {
|
|
36
|
-
if (currentDestination.value.id ===
|
|
36
|
+
if (currentDestination.value.id === LinkDestination.URL) {
|
|
37
37
|
const url = destinationHrefs.value.url;
|
|
38
38
|
const isTelOrMail = RegExps.TEL_PROTOCOL.test(url) || RegExps.MAILTO_PROTOCOL.test(url);
|
|
39
39
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
3
|
<FieldLabel class="zw-margin-bottom--xxs">
|
|
4
|
-
|
|
4
|
+
Click Action
|
|
5
5
|
</FieldLabel>
|
|
6
6
|
|
|
7
7
|
<Dropdown
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
<script setup>
|
|
42
42
|
import { computed, toRef } from 'vue';
|
|
43
|
-
import {
|
|
43
|
+
import { LinkDestination, LinkTarget } from '@/enums';
|
|
44
44
|
import { Dropdown, DropdownOption, FieldLabel } from '../../../../base';
|
|
45
45
|
import LinkControlPageBlock from './LinkControlPageBlock';
|
|
46
46
|
import LinkControlUrl from './LinkControlUrl';
|
|
@@ -60,18 +60,21 @@ const props = defineProps({
|
|
|
60
60
|
const emit = defineEmits(['reset-errors']);
|
|
61
61
|
|
|
62
62
|
const destinationTypes = [
|
|
63
|
-
{ id:
|
|
64
|
-
{ id:
|
|
63
|
+
{ id: LinkDestination.URL, title: 'URL' },
|
|
64
|
+
{ id: LinkDestination.BLOCK, title: 'Page Section' }
|
|
65
65
|
];
|
|
66
66
|
|
|
67
67
|
const link = toRef(props, 'link');
|
|
68
|
-
const isURLDestination = computed(() => link.value.currentDestination.value.id ===
|
|
69
|
-
const isTargetBlank = computed(() => link.value.linkData.value.target ===
|
|
68
|
+
const isURLDestination = computed(() => link.value.currentDestination.value.id === LinkDestination.URL);
|
|
69
|
+
const isTargetBlank = computed(() => link.value.linkData.value.target === LinkTarget.BLANK);
|
|
70
70
|
|
|
71
71
|
const changeDestination = (value) => {
|
|
72
72
|
emit('reset-errors');
|
|
73
73
|
link.value.currentDestination.value.id = value;
|
|
74
|
-
|
|
74
|
+
|
|
75
|
+
if (!isURLDestination.value) {
|
|
76
|
+
link.value.target = LinkTarget.SELF;
|
|
77
|
+
}
|
|
75
78
|
|
|
76
79
|
link.value.destinationHrefs.value.url = '';
|
|
77
80
|
};
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
|
|
24
24
|
<script setup>
|
|
25
25
|
import { inject } from 'vue';
|
|
26
|
+
import { InjectionTokens } from '@/injectionTokens';
|
|
26
27
|
import { FieldLabel, DropdownOption, Dropdown } from '../../../../base';
|
|
27
|
-
import { InjectionTokens } from '../../../../../injectionTokens';
|
|
28
28
|
|
|
29
29
|
defineProps({
|
|
30
30
|
value: {
|
|
@@ -8,11 +8,3 @@ export enum NodeType {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const NodeBlockTypeList = [NodeType.PARAGRAPH, NodeType.LIST, NodeType.HEADING];
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated Use `NodeType` instead.
|
|
14
|
-
*/
|
|
15
|
-
export const NodeTypes = Object.freeze({
|
|
16
|
-
...NodeType,
|
|
17
|
-
blocks: NodeBlockTypeList
|
|
18
|
-
});
|
|
@@ -41,14 +41,3 @@ export const TextBlockMarkList = [
|
|
|
41
41
|
TextSetting.TEXT_DECORATION,
|
|
42
42
|
TextSetting.SUPERSCRIPT
|
|
43
43
|
];
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @deprecated Use `TextSetting` instead.
|
|
47
|
-
*/
|
|
48
|
-
export const TextSettings = {
|
|
49
|
-
...TextSetting,
|
|
50
|
-
attributes: TextAttributeSettingList,
|
|
51
|
-
presetAttributes: TextPresetAttributeSettingList,
|
|
52
|
-
inlineMarks: TextInlineMarkList,
|
|
53
|
-
marks: TextBlockMarkList
|
|
54
|
-
};
|
package/lib/enums/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
1
|
+
export * from './Device';
|
|
2
|
+
export * from './CaseStyle';
|
|
3
|
+
export * from './Alignment';
|
|
4
|
+
export * from './NodeType';
|
|
5
|
+
export * from './ListType';
|
|
6
|
+
export * from './TextSetting';
|
|
7
|
+
export * from './MarkGroup';
|
|
8
|
+
export * from './LinkTarget';
|
|
9
|
+
export * from './LinkDestination';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/vue-3';
|
|
2
2
|
import { computed, unref } from 'vue';
|
|
3
|
-
import { convertAlignment, createCommand, createKeyboardShortcut, renderInlineSetting } from '
|
|
4
|
-
import {
|
|
3
|
+
import { convertAlignment, createCommand, createKeyboardShortcut, renderInlineSetting } from '@/utils';
|
|
4
|
+
import { Alignment, NodeType, TextSetting } from '@/enums';
|
|
5
5
|
|
|
6
6
|
const DEFAULTS = {
|
|
7
7
|
mobile: null,
|
|
@@ -9,14 +9,14 @@ const DEFAULTS = {
|
|
|
9
9
|
desktop: null
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
export const
|
|
13
|
-
name:
|
|
12
|
+
export const AlignmentExtension = Extension.create({
|
|
13
|
+
name: TextSetting.ALIGNMENT,
|
|
14
14
|
|
|
15
15
|
addGlobalAttributes: () => [
|
|
16
16
|
{
|
|
17
|
-
types: [
|
|
17
|
+
types: [NodeType.PARAGRAPH, NodeType.HEADING],
|
|
18
18
|
attributes: {
|
|
19
|
-
[
|
|
19
|
+
[TextSetting.ALIGNMENT]: {
|
|
20
20
|
isRequired: false,
|
|
21
21
|
|
|
22
22
|
parseHTML({ style }) {
|
|
@@ -71,15 +71,17 @@ export const Alignment = Extension.create({
|
|
|
71
71
|
const device = commands.getDevice();
|
|
72
72
|
const preset = commands.getPreset();
|
|
73
73
|
|
|
74
|
-
return computed(() => unref(preset)[unref(device)].alignment ??
|
|
74
|
+
return computed(() => unref(preset)[unref(device)].alignment ?? Alignment.LEFT);
|
|
75
75
|
})
|
|
76
76
|
};
|
|
77
77
|
},
|
|
78
78
|
|
|
79
79
|
addKeyboardShortcuts: () => ({
|
|
80
|
-
'Mod-Shift-l': createKeyboardShortcut('applyAlignment',
|
|
81
|
-
'Mod-Shift-e': createKeyboardShortcut('applyAlignment',
|
|
82
|
-
'Mod-Shift-r': createKeyboardShortcut('applyAlignment',
|
|
83
|
-
'Mod-Shift-j': createKeyboardShortcut('applyAlignment',
|
|
80
|
+
'Mod-Shift-l': createKeyboardShortcut('applyAlignment', Alignment.LEFT),
|
|
81
|
+
'Mod-Shift-e': createKeyboardShortcut('applyAlignment', Alignment.CENTER),
|
|
82
|
+
'Mod-Shift-r': createKeyboardShortcut('applyAlignment', Alignment.RIGHT),
|
|
83
|
+
'Mod-Shift-j': createKeyboardShortcut('applyAlignment', Alignment.JUSTIFY)
|
|
84
84
|
})
|
|
85
85
|
});
|
|
86
|
+
|
|
87
|
+
export { AlignmentExtension as Alignment };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-3';
|
|
2
2
|
import { convertColor, createCommand, renderMark } from '../utils';
|
|
3
|
-
import {
|
|
3
|
+
import { TextSetting } from '../enums';
|
|
4
4
|
|
|
5
5
|
export const BackgroundColor = Mark.create({
|
|
6
|
-
name:
|
|
6
|
+
name: TextSetting.BACKGROUND_COLOR,
|
|
7
7
|
|
|
8
8
|
addAttributes: () => ({
|
|
9
9
|
value: { required: true }
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/vue-3';
|
|
2
|
-
import { capitalize, createCommand } from '
|
|
3
|
-
import {
|
|
2
|
+
import { capitalize, createCommand } from '@/utils';
|
|
3
|
+
import { CaseStyle } from '@/enums';
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const CaseStyleExtension = Extension.create({
|
|
6
6
|
name: 'case_style',
|
|
7
7
|
|
|
8
8
|
addCommands() {
|
|
9
9
|
return {
|
|
10
10
|
applyCaseStyle: createCommand(({ commands }, value) => {
|
|
11
11
|
switch (value) {
|
|
12
|
-
case
|
|
12
|
+
case CaseStyle.CAPITALIZE:
|
|
13
13
|
return commands.applyCapitalize();
|
|
14
14
|
|
|
15
|
-
case
|
|
15
|
+
case CaseStyle.LOWERCASE:
|
|
16
16
|
return commands.applyLowerCase();
|
|
17
17
|
|
|
18
|
-
case
|
|
18
|
+
case CaseStyle.UPPERCASE:
|
|
19
19
|
return commands.applyUpperCase();
|
|
20
20
|
}
|
|
21
21
|
}),
|
|
@@ -34,3 +34,5 @@ export const CaseStyle = Extension.create({
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
|
+
|
|
38
|
+
export { CaseStyleExtension as CaseStyle };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-3';
|
|
2
2
|
import { computed, unref } from 'vue';
|
|
3
|
-
import { convertColor, createCommand, renderMark } from '
|
|
4
|
-
import {
|
|
3
|
+
import { convertColor, createCommand, renderMark } from '@/utils';
|
|
4
|
+
import { MarkGroup, TextSetting } from '@/enums';
|
|
5
5
|
|
|
6
6
|
export const FontColor = Mark.create({
|
|
7
|
-
name:
|
|
8
|
-
group:
|
|
7
|
+
name: TextSetting.FONT_COLOR,
|
|
8
|
+
group: MarkGroup.SETTINGS,
|
|
9
9
|
|
|
10
10
|
addAttributes: () => ({
|
|
11
11
|
value: { required: true }
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-3';
|
|
2
2
|
import { computed, unref } from 'vue';
|
|
3
|
-
import { createCommand, renderMark } from '
|
|
4
|
-
import {
|
|
3
|
+
import { createCommand, renderMark } from '@/utils';
|
|
4
|
+
import { MarkGroup, TextSetting } from '@/enums';
|
|
5
5
|
|
|
6
6
|
export const FontFamily = Mark.create({
|
|
7
|
-
name:
|
|
8
|
-
group:
|
|
7
|
+
name: TextSetting.FONT_FAMILY,
|
|
8
|
+
group: MarkGroup.SETTINGS,
|
|
9
9
|
|
|
10
10
|
addOptions: () => ({
|
|
11
11
|
fonts: []
|
|
@@ -28,7 +28,7 @@ export const FontFamily = Mark.create({
|
|
|
28
28
|
commands.applyFontWeight(fontWeight);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const isItalicCustomized = commands.isSettingCustomized(
|
|
31
|
+
const isItalicCustomized = commands.isSettingCustomized(TextSetting.FONT_STYLE).value;
|
|
32
32
|
|
|
33
33
|
if (!font.isItalicSupported(fontWeight) && isItalicCustomized) {
|
|
34
34
|
commands.removeItalic();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-3';
|
|
2
2
|
import { computed, unref } from 'vue';
|
|
3
3
|
import { convertFontSize, createCommand, createKeyboardShortcut, renderMark } from '../utils';
|
|
4
|
-
import {
|
|
4
|
+
import { MarkGroup, TextSetting } from '../enums';
|
|
5
5
|
|
|
6
6
|
export const FontSize = Mark.create({
|
|
7
|
-
name:
|
|
8
|
-
group:
|
|
7
|
+
name: TextSetting.FONT_SIZE,
|
|
8
|
+
group: MarkGroup.SETTINGS,
|
|
9
9
|
|
|
10
10
|
addOptions: () => ({
|
|
11
11
|
minSize: 1,
|
|
@@ -1,11 +1,11 @@
|
|
|
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 { MarkGroup, TextSetting } from '@/enums';
|
|
5
5
|
|
|
6
6
|
export const FontStyle = Mark.create({
|
|
7
|
-
name:
|
|
8
|
-
group:
|
|
7
|
+
name: TextSetting.FONT_STYLE,
|
|
8
|
+
group: MarkGroup.SETTINGS,
|
|
9
9
|
|
|
10
10
|
addAttributes: () => ({
|
|
11
11
|
italic: { required: true }
|
|
@@ -1,11 +1,11 @@
|
|
|
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 { MarkGroup, TextSetting } from '../enums';
|
|
5
5
|
|
|
6
6
|
export const FontWeight = Mark.create({
|
|
7
|
-
name:
|
|
8
|
-
group:
|
|
7
|
+
name: TextSetting.FONT_WEIGHT,
|
|
8
|
+
group: MarkGroup.SETTINGS,
|
|
9
9
|
|
|
10
10
|
addAttributes: () => ({
|
|
11
11
|
value: { required: true }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/vue-3';
|
|
2
2
|
import { computed, unref } from 'vue';
|
|
3
3
|
import { createCommand, renderInlineSetting, convertLineHeight } from '../utils';
|
|
4
|
-
import {
|
|
4
|
+
import { NodeType, TextSetting } from '../enums';
|
|
5
5
|
|
|
6
6
|
const DEFAULTS = {
|
|
7
7
|
mobile: null,
|
|
@@ -10,14 +10,14 @@ const DEFAULTS = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export const LineHeight = Extension.create({
|
|
13
|
-
name:
|
|
13
|
+
name: TextSetting.LINE_HEIGHT,
|
|
14
14
|
|
|
15
15
|
addGlobalAttributes() {
|
|
16
16
|
return [
|
|
17
17
|
{
|
|
18
|
-
types: [
|
|
18
|
+
types: [NodeType.PARAGRAPH, NodeType.HEADING],
|
|
19
19
|
attributes: {
|
|
20
|
-
[
|
|
20
|
+
[TextSetting.LINE_HEIGHT]: {
|
|
21
21
|
isRequired: false,
|
|
22
22
|
|
|
23
23
|
parseHTML: (element) => {
|
package/lib/extensions/Link.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Base from '@tiptap/extension-link';
|
|
2
2
|
import { computed, unref } from 'vue';
|
|
3
|
-
import { createCommand } from '
|
|
4
|
-
import {
|
|
5
|
-
import { NodeFactory } from '
|
|
3
|
+
import { createCommand } from '@/utils';
|
|
4
|
+
import { LinkDestination, LinkTarget, TextSetting } from '@/enums';
|
|
5
|
+
import { NodeFactory } from '@/services';
|
|
6
6
|
import { PasteLinkPlugin } from './proseMirror';
|
|
7
7
|
|
|
8
8
|
export const Link = Base.extend({
|
|
9
|
-
name:
|
|
9
|
+
name: TextSetting.LINK,
|
|
10
10
|
|
|
11
11
|
addOptions() {
|
|
12
12
|
return {
|
|
@@ -30,23 +30,23 @@ export const Link = Base.extend({
|
|
|
30
30
|
},
|
|
31
31
|
|
|
32
32
|
target: {
|
|
33
|
-
default:
|
|
34
|
-
parseHTML: (element) => element.getAttribute('target') ||
|
|
33
|
+
default: LinkTarget.SELF,
|
|
34
|
+
parseHTML: (element) => element.getAttribute('target') || LinkTarget.SELF
|
|
35
35
|
},
|
|
36
36
|
|
|
37
37
|
destination: {
|
|
38
|
-
default:
|
|
38
|
+
default: LinkDestination.URL,
|
|
39
39
|
|
|
40
40
|
parseHTML: (element) => {
|
|
41
41
|
const href = element.getAttribute('href');
|
|
42
42
|
|
|
43
|
-
if (!href.startsWith('#')) return
|
|
43
|
+
if (!href.startsWith('#')) return LinkDestination.URL;
|
|
44
44
|
|
|
45
45
|
const id = href.replace('#', '');
|
|
46
46
|
const blocks = unref(this.options.pageBlocks);
|
|
47
47
|
const block = blocks.find((block) => block.id === parseInt(id));
|
|
48
48
|
|
|
49
|
-
return block ?
|
|
49
|
+
return block ? LinkDestination.BLOCK : LinkDestination.URL;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
};
|
|
@@ -63,7 +63,7 @@ export const Link = Base.extend({
|
|
|
63
63
|
|
|
64
64
|
if (!commands.getSelectedText()) {
|
|
65
65
|
return commands.insertContent(NodeFactory.text(attributes.text, [
|
|
66
|
-
NodeFactory.mark(
|
|
66
|
+
NodeFactory.mark(TextSetting.LINK, attributes)
|
|
67
67
|
]));
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -96,7 +96,7 @@ export const Link = Base.extend({
|
|
|
96
96
|
},
|
|
97
97
|
|
|
98
98
|
renderHTML({ HTMLAttributes: attrs }) {
|
|
99
|
-
const href = attrs.destination ===
|
|
99
|
+
const href = attrs.destination === LinkDestination.BLOCK ? `#${attrs.href}` : attrs.href;
|
|
100
100
|
const presetClass = unref(this.options.basePresetClass) + unref(this.options.preset).id;
|
|
101
101
|
const linkAttrs = { href, target: attrs.target, class: `${presetClass} zw-style` };
|
|
102
102
|
|
package/lib/extensions/Margin.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/vue-3';
|
|
2
|
-
import {
|
|
2
|
+
import { NodeType, TextSetting } from '../enums';
|
|
3
3
|
import { renderInlineSetting } from '../utils';
|
|
4
4
|
|
|
5
5
|
// Fallback margins in old wysiwyg content
|
|
6
6
|
export const Margin = Extension.create({
|
|
7
|
-
name:
|
|
7
|
+
name: TextSetting.MARGIN,
|
|
8
8
|
|
|
9
9
|
addGlobalAttributes: () => [
|
|
10
10
|
{
|
|
11
|
-
types: [
|
|
11
|
+
types: [NodeType.PARAGRAPH, NodeType.HEADING],
|
|
12
12
|
|
|
13
13
|
attributes: {
|
|
14
|
-
[
|
|
14
|
+
[TextSetting.MARGIN]: {
|
|
15
15
|
isRequired: false,
|
|
16
16
|
|
|
17
17
|
parseHTML(el) {
|