@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
|
@@ -28,7 +28,7 @@ import { computed, inject } from 'vue';
|
|
|
28
28
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
29
29
|
import { tooltip as vTooltip } from '../../../directives';
|
|
30
30
|
import { Dropdown, DropdownOption } from '../../base';
|
|
31
|
-
import {
|
|
31
|
+
import { TextSetting } from '../../../enums';
|
|
32
32
|
import { useRecentFonts } from './composables';
|
|
33
33
|
|
|
34
34
|
const fonts = inject(InjectionTokens.FONTS);
|
|
@@ -36,7 +36,7 @@ const editor = inject(InjectionTokens.EDITOR);
|
|
|
36
36
|
|
|
37
37
|
const defaultFontFamily = editor.commands.getDefaultFontFamily();
|
|
38
38
|
const recentFontNames = useRecentFonts({ limit: 5 });
|
|
39
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
39
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSetting.FONT_FAMILY);
|
|
40
40
|
|
|
41
41
|
const recentFontsCategory = computed(() => ({
|
|
42
42
|
id: 'Recently Used',
|
|
@@ -26,7 +26,7 @@ import { computed, inject } from 'vue';
|
|
|
26
26
|
import { Dropdown, DropdownOption } from '../../base';
|
|
27
27
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
28
28
|
import { tooltip as vTooltip } from '../../../directives';
|
|
29
|
-
import {
|
|
29
|
+
import { TextSetting } from '../../../enums';
|
|
30
30
|
|
|
31
31
|
const fontSizes = inject(InjectionTokens.FONT_SIZES);
|
|
32
32
|
const editor = inject(InjectionTokens.EDITOR);
|
|
@@ -42,7 +42,7 @@ const options = computed(() => {
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
const currentValue = editor.commands.getFontSize();
|
|
45
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
45
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSetting.FONT_SIZE);
|
|
46
46
|
|
|
47
47
|
const apply = (value) => editor.chain().focus().applyFontSize(value).run();
|
|
48
48
|
</script>
|
|
@@ -26,7 +26,7 @@ import { computed, inject, unref } from 'vue';
|
|
|
26
26
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
27
27
|
import { Dropdown, DropdownOption } from '../../base';
|
|
28
28
|
import { tooltip as vTooltip } from '../../../directives';
|
|
29
|
-
import {
|
|
29
|
+
import { TextSetting } from '../../../enums';
|
|
30
30
|
|
|
31
31
|
const editor = inject(InjectionTokens.EDITOR);
|
|
32
32
|
const font = editor.commands.getFont();
|
|
@@ -41,7 +41,7 @@ const options = computed(() => {
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
const currentValue = editor.commands.getFontWeight();
|
|
44
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
44
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSetting.FONT_WEIGHT);
|
|
45
45
|
|
|
46
46
|
const apply = (value) => editor.chain().focus().applyFontWeight(value).run();
|
|
47
47
|
</script>
|
|
@@ -24,13 +24,13 @@ import { inject } from 'vue';
|
|
|
24
24
|
import { Button, Icon } from '../../base';
|
|
25
25
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
26
26
|
import { tooltip as vTooltip } from '../../../directives';
|
|
27
|
-
import {
|
|
27
|
+
import { TextSetting } from '../../../enums';
|
|
28
28
|
|
|
29
29
|
const editor = inject(InjectionTokens.EDITOR);
|
|
30
30
|
|
|
31
31
|
const currentValue = editor.commands.isItalic();
|
|
32
32
|
const isAvailable = editor.commands.isItalicAvailable();
|
|
33
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
33
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSetting.FONT_STYLE);
|
|
34
34
|
const apply = () => editor.chain().focus().toggleItalic().run();
|
|
35
35
|
</script>
|
|
36
36
|
|
|
@@ -56,14 +56,14 @@ import { inject, ref } from 'vue';
|
|
|
56
56
|
import { Button, Icon, Modal, Range, NumberField, FieldLabel, useModalToggler } from '../../base';
|
|
57
57
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
58
58
|
import { tooltip as vTooltip } from '../../../directives';
|
|
59
|
-
import {
|
|
59
|
+
import { TextSetting } from '../../../enums';
|
|
60
60
|
|
|
61
61
|
const editor = inject(InjectionTokens.EDITOR);
|
|
62
62
|
const wrapperRef = ref(null);
|
|
63
63
|
const toggler = useModalToggler();
|
|
64
64
|
|
|
65
65
|
const currentValue = editor.commands.getLineHeight();
|
|
66
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
66
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSetting.LINE_HEIGHT);
|
|
67
67
|
|
|
68
68
|
const apply = (value) => editor.commands.applyLineHeight(String(value));
|
|
69
69
|
</script>
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
|
|
43
43
|
<script setup>
|
|
44
44
|
import { computed, inject, ref, unref } from 'vue';
|
|
45
|
-
import { InjectionTokens } from '
|
|
45
|
+
import { InjectionTokens } from '@/injectionTokens';
|
|
46
|
+
import { ListTypeList, ListType } from '@/enums';
|
|
46
47
|
import { Dropdown, DropdownOption, Button, Icon } from '../../base';
|
|
47
|
-
import { ListTypes } from '../../../enums';
|
|
48
48
|
import { tooltip as vTooltip } from '../../../directives';
|
|
49
49
|
|
|
50
|
-
const listTypes =
|
|
50
|
+
const listTypes = ListTypeList.map((type) => ({
|
|
51
51
|
id: type,
|
|
52
52
|
icon: `list-${type}`
|
|
53
53
|
}));
|
|
@@ -55,7 +55,7 @@ const listTypes = ListTypes.values.map((type) => ({
|
|
|
55
55
|
const editor = inject(InjectionTokens.EDITOR);
|
|
56
56
|
const selectionValue = editor.commands.getListType();
|
|
57
57
|
const currentValue = computed(() => unref(selectionValue) || 'none');
|
|
58
|
-
const recentListType = ref(
|
|
58
|
+
const recentListType = ref(ListType.DISC);
|
|
59
59
|
const isCurrentListSelected = computed(() => unref(selectionValue) === recentListType.value);
|
|
60
60
|
|
|
61
61
|
const currentIcon = computed(() => `list-${recentListType.value}`);
|
|
@@ -65,7 +65,7 @@ const apply = (type) => {
|
|
|
65
65
|
editor.chain().focus().applyList(type).run();
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
const toggle = () => apply(recentListType.value ||
|
|
68
|
+
const toggle = () => apply(recentListType.value || ListType.DISC);
|
|
69
69
|
</script>
|
|
70
70
|
|
|
71
71
|
<style scoped>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
2
|
import { h, ref } from 'vue';
|
|
3
|
-
import { InjectionTokens } from '
|
|
4
|
-
import {
|
|
3
|
+
import { InjectionTokens } from '@/injectionTokens';
|
|
4
|
+
import { Alignment } from '@/enums';
|
|
5
5
|
import { ButtonToggle } from '../../../base';
|
|
6
6
|
import AlignmentControl from '../AlignmentControl';
|
|
7
7
|
|
|
@@ -46,12 +46,12 @@ function createComponent({ editor, slotParams }) {
|
|
|
46
46
|
|
|
47
47
|
describe('selection value', () => {
|
|
48
48
|
test('should render value from selection', () => {
|
|
49
|
-
const editor = createEditor({ alignment:
|
|
49
|
+
const editor = createEditor({ alignment: Alignment.RIGHT });
|
|
50
50
|
const wrapper = createComponent({
|
|
51
51
|
editor,
|
|
52
52
|
slotParams: {
|
|
53
53
|
option: {
|
|
54
|
-
id:
|
|
54
|
+
id: Alignment.RIGHT,
|
|
55
55
|
tooltip: { text: 'Align Right', hotkey: 'Mod Shift R' }
|
|
56
56
|
},
|
|
57
57
|
isActive: true
|
|
@@ -59,16 +59,16 @@ describe('selection value', () => {
|
|
|
59
59
|
});
|
|
60
60
|
const buttonWrapper = wrapper.findComponent(ButtonToggle);
|
|
61
61
|
|
|
62
|
-
expect(buttonWrapper.props('value')).toBe(
|
|
62
|
+
expect(buttonWrapper.props('value')).toBe(Alignment.RIGHT);
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
test('should apply new value', () => {
|
|
66
|
-
const editor = createEditor({ alignment:
|
|
66
|
+
const editor = createEditor({ alignment: Alignment.RIGHT });
|
|
67
67
|
const wrapper = createComponent({
|
|
68
68
|
editor,
|
|
69
69
|
slotParams: {
|
|
70
70
|
option: {
|
|
71
|
-
id:
|
|
71
|
+
id: Alignment.RIGHT,
|
|
72
72
|
tooltip: { text: 'Align Right', hotkey: 'Mod Shift R' }
|
|
73
73
|
},
|
|
74
74
|
isActive: true
|
|
@@ -76,23 +76,23 @@ describe('selection value', () => {
|
|
|
76
76
|
});
|
|
77
77
|
const buttonWrapper = wrapper.findComponent(ButtonToggle);
|
|
78
78
|
|
|
79
|
-
buttonWrapper.vm.$emit('change',
|
|
79
|
+
buttonWrapper.vm.$emit('change', Alignment.CENTER);
|
|
80
80
|
|
|
81
|
-
expect(editor.commands.applyAlignment).toHaveBeenCalledWith(
|
|
81
|
+
expect(editor.commands.applyAlignment).toHaveBeenCalledWith(Alignment.CENTER);
|
|
82
82
|
});
|
|
83
83
|
});
|
|
84
84
|
|
|
85
85
|
describe('render indicator of customized styles', () => {
|
|
86
86
|
test('should render indicator', () => {
|
|
87
87
|
const editor = createEditor({
|
|
88
|
-
alignment:
|
|
88
|
+
alignment: Alignment.LEFT,
|
|
89
89
|
isSettingCustomized: true
|
|
90
90
|
});
|
|
91
91
|
const wrapper = createComponent({
|
|
92
92
|
editor,
|
|
93
93
|
slotParams: {
|
|
94
94
|
option: {
|
|
95
|
-
id:
|
|
95
|
+
id: Alignment.LEFT,
|
|
96
96
|
tooltip: { text: 'Align Left', hotkey: 'Mod Shift L' }
|
|
97
97
|
},
|
|
98
98
|
isActive: true
|
|
@@ -103,12 +103,12 @@ describe('render indicator of customized styles', () => {
|
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
test('should not render indicator', () => {
|
|
106
|
-
const editor = createEditor({ alignment:
|
|
106
|
+
const editor = createEditor({ alignment: Alignment.LEFT });
|
|
107
107
|
const wrapper = createComponent({
|
|
108
108
|
editor,
|
|
109
109
|
slotParams: {
|
|
110
110
|
option: {
|
|
111
|
-
id:
|
|
111
|
+
id: Alignment.LEFT,
|
|
112
112
|
tooltip: { text: 'Align Left', hotkey: 'Mod Shift L' }
|
|
113
113
|
},
|
|
114
114
|
isActive: true
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
2
|
import { h } from 'vue';
|
|
3
|
-
import { InjectionTokens } from '
|
|
3
|
+
import { InjectionTokens } from '@/injectionTokens';
|
|
4
|
+
import { CaseStyle } from '@/enums';
|
|
4
5
|
import { Dropdown } from '../../../base';
|
|
5
6
|
import CaseStyleControl from '../CaseStyleControl';
|
|
6
|
-
import { CaseStyles } from '../../../../enums';
|
|
7
7
|
|
|
8
8
|
const createEditor = () => ({
|
|
9
9
|
commands: {
|
|
@@ -37,8 +37,8 @@ describe('selection value', () => {
|
|
|
37
37
|
const wrapper = createComponent({ editor });
|
|
38
38
|
const dropdownWrapper = wrapper.findComponent(Dropdown);
|
|
39
39
|
|
|
40
|
-
dropdownWrapper.vm.$emit('change',
|
|
40
|
+
dropdownWrapper.vm.$emit('change', CaseStyle.UPPERCASE);
|
|
41
41
|
|
|
42
|
-
expect(editor.commands.applyCaseStyle).toHaveBeenCalledWith(
|
|
42
|
+
expect(editor.commands.applyCaseStyle).toHaveBeenCalledWith(CaseStyle.UPPERCASE);
|
|
43
43
|
});
|
|
44
44
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
2
|
import { h, ref, nextTick } from 'vue';
|
|
3
|
-
import { InjectionTokens } from '
|
|
3
|
+
import { InjectionTokens } from '@/injectionTokens';
|
|
4
|
+
import { ListType } from '@/enums';
|
|
4
5
|
import { Button, Dropdown, Icon } from '../../../base';
|
|
5
6
|
import ListControl from '../ListControl';
|
|
6
|
-
import { ListTypes } from '../../../../enums';
|
|
7
7
|
|
|
8
8
|
const createEditor = ({ listType } = {}) => ({
|
|
9
9
|
commands: {
|
|
@@ -49,11 +49,11 @@ describe('selection value', () => {
|
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
test('should pass type from selection', () => {
|
|
52
|
-
const editor = createEditor({ listType:
|
|
52
|
+
const editor = createEditor({ listType: ListType.LATIN });
|
|
53
53
|
const wrapper = createComponent({ editor });
|
|
54
54
|
const dropdownWrapper = wrapper.findComponent(Dropdown);
|
|
55
55
|
|
|
56
|
-
expect(dropdownWrapper.props('value')).toBe(
|
|
56
|
+
expect(dropdownWrapper.props('value')).toBe(ListType.LATIN);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
test('should render none icon', () => {
|
|
@@ -65,12 +65,12 @@ describe('selection value', () => {
|
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
test('should render type icon', async () => {
|
|
68
|
-
const editor = createEditor({ listType:
|
|
68
|
+
const editor = createEditor({ listType: ListType.DECIMAL });
|
|
69
69
|
const wrapper = createComponent({ editor });
|
|
70
70
|
const iconWrapper = wrapper.findComponent(Icon);
|
|
71
71
|
const dropdownWrapper = wrapper.findComponent(Dropdown);
|
|
72
72
|
|
|
73
|
-
dropdownWrapper.vm.$emit('change',
|
|
73
|
+
dropdownWrapper.vm.$emit('change', ListType.DECIMAL);
|
|
74
74
|
|
|
75
75
|
await nextTick();
|
|
76
76
|
|
|
@@ -78,13 +78,13 @@ describe('selection value', () => {
|
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
test('should apply list', () => {
|
|
81
|
-
const editor = createEditor({ listType:
|
|
81
|
+
const editor = createEditor({ listType: ListType.LATIN });
|
|
82
82
|
const wrapper = createComponent({ editor });
|
|
83
83
|
const dropdownWrapper = wrapper.findComponent(Dropdown);
|
|
84
84
|
|
|
85
|
-
dropdownWrapper.vm.$emit('change',
|
|
85
|
+
dropdownWrapper.vm.$emit('change', ListType.LATIN);
|
|
86
86
|
|
|
87
|
-
expect(editor.commands.applyList).toHaveBeenCalledWith(
|
|
87
|
+
expect(editor.commands.applyList).toHaveBeenCalledWith(ListType.LATIN);
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
test('should apply list with default type', () => {
|
|
@@ -94,6 +94,6 @@ describe('selection value', () => {
|
|
|
94
94
|
|
|
95
95
|
buttonWrapper.vm.$emit('click');
|
|
96
96
|
|
|
97
|
-
expect(editor.commands.applyList).toHaveBeenCalledWith(
|
|
97
|
+
expect(editor.commands.applyList).toHaveBeenCalledWith(ListType.DISC);
|
|
98
98
|
});
|
|
99
99
|
});
|
|
@@ -3,7 +3,7 @@ import { ref } from 'vue';
|
|
|
3
3
|
import { InjectionTokens } from '../../../../injectionTokens';
|
|
4
4
|
import { Button, Dropdown } from '../../../base';
|
|
5
5
|
import { StylePresetControl } from '../stylePreset';
|
|
6
|
-
import {
|
|
6
|
+
import { TextSetting } from '../../../../enums';
|
|
7
7
|
|
|
8
8
|
const createEditor = ({ presets, preset, customization } = {}) => ({
|
|
9
9
|
commands: {
|
|
@@ -92,7 +92,7 @@ describe('rendering', () => {
|
|
|
92
92
|
test('should enable reset if marks customized', () => {
|
|
93
93
|
const editor = createEditor({
|
|
94
94
|
customization: {
|
|
95
|
-
marks: [
|
|
95
|
+
marks: [TextSetting.FONT_SIZE],
|
|
96
96
|
attributes: []
|
|
97
97
|
}
|
|
98
98
|
});
|
|
@@ -106,7 +106,7 @@ describe('rendering', () => {
|
|
|
106
106
|
const editor = createEditor({
|
|
107
107
|
customization: {
|
|
108
108
|
marks: [],
|
|
109
|
-
attributes: [
|
|
109
|
+
attributes: [TextSetting.ALIGNMENT]
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
const wrapper = createComponent({ editor });
|
|
@@ -118,8 +118,8 @@ describe('rendering', () => {
|
|
|
118
118
|
test('should enable reset if attributes and marks customized', () => {
|
|
119
119
|
const editor = createEditor({
|
|
120
120
|
customization: {
|
|
121
|
-
marks: [
|
|
122
|
-
attributes: [
|
|
121
|
+
marks: [TextSetting.FONT_SIZE],
|
|
122
|
+
attributes: [TextSetting.ALIGNMENT]
|
|
123
123
|
}
|
|
124
124
|
});
|
|
125
125
|
const wrapper = createComponent({ editor });
|
|
@@ -148,7 +148,7 @@ describe('apply preset', () => {
|
|
|
148
148
|
dropdownWrapper.vm.$emit('change', 'regular-1');
|
|
149
149
|
|
|
150
150
|
expect(editor.commands.expandSelectionToBlock).toHaveBeenCalled();
|
|
151
|
-
expect(editor.commands.removeMarks).toHaveBeenCalledWith([
|
|
151
|
+
expect(editor.commands.removeMarks).toHaveBeenCalledWith([TextSetting.FONT_SIZE, TextSetting.FONT_WEIGHT]);
|
|
152
152
|
});
|
|
153
153
|
});
|
|
154
154
|
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
|
|
46
46
|
<script setup>
|
|
47
47
|
import { computed, ref, inject, unref } from 'vue';
|
|
48
|
-
import {
|
|
49
|
-
import { InjectionTokens } from '
|
|
50
|
-
import { RegExps } from '
|
|
48
|
+
import { LinkDestination, TextSetting } from '@/enums';
|
|
49
|
+
import { InjectionTokens } from '@/injectionTokens';
|
|
50
|
+
import { RegExps } from '@/regExps';
|
|
51
51
|
import { tooltip as vTooltip } from '../../../../directives';
|
|
52
52
|
import { useValidator } from '../../../base/composables';
|
|
53
53
|
import { Button, Icon, Modal, TextField, useModalToggler } from '../../../base';
|
|
@@ -65,7 +65,7 @@ const isEmpty = () => {
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
const isValidUrl = () => {
|
|
68
|
-
if (link.currentDestination.value.id !==
|
|
68
|
+
if (link.currentDestination.value.id !== LinkDestination.URL) return false;
|
|
69
69
|
|
|
70
70
|
const href = link.destinationHrefs.value.url;
|
|
71
71
|
const isTelOrMail = RegExps.TEL_PROTOCOL.test(href) || RegExps.MAILTO_PROTOCOL.test(href);
|
|
@@ -93,7 +93,7 @@ const resetErrors = () => {
|
|
|
93
93
|
|
|
94
94
|
const toggler = useModalToggler({
|
|
95
95
|
onBeforeOpened: () => {
|
|
96
|
-
editor.commands.extendMarkRange(
|
|
96
|
+
editor.commands.extendMarkRange(TextSetting.LINK);
|
|
97
97
|
resetErrors();
|
|
98
98
|
link.prepareInitialFields();
|
|
99
99
|
}
|
|
@@ -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: {
|