@zipify/wysiwyg 3.1.2 → 4.0.0-vue3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +1 -1
- package/config/build/example.config.js +12 -2
- package/config/build/lib.config.js +10 -2
- package/config/jest/matchers/index.js +0 -2
- package/config/jest/setupTests.js +4 -7
- package/config/jest/typing.d.ts +1 -2
- package/dist/cli.js +2 -7
- package/dist/wysiwyg.css +153 -152
- package/dist/wysiwyg.mjs +3594 -3172
- package/example/example.js +34 -35
- package/jest.config.js +4 -1
- package/lib/Wysiwyg.vue +166 -190
- package/lib/__tests__/utils/buildTestExtensions.js +1 -1
- package/lib/components/base/Button.vue +31 -37
- package/lib/components/base/ButtonToggle.vue +11 -17
- package/lib/components/base/Checkbox.vue +14 -20
- package/lib/components/base/FieldLabel.vue +7 -11
- package/lib/components/base/Icon.vue +31 -43
- package/lib/components/base/Modal.vue +59 -74
- package/lib/components/base/NumberField.vue +65 -80
- package/lib/components/base/Range.vue +46 -56
- package/lib/components/base/ScrollView.vue +13 -21
- package/lib/components/base/TextField.vue +28 -33
- package/lib/components/base/__tests__/Button.test.js +1 -1
- package/lib/components/base/__tests__/Icon.test.js +1 -1
- package/lib/components/base/__tests__/Modal.test.js +21 -13
- package/lib/components/base/__tests__/Range.test.js +1 -1
- package/lib/components/base/__tests__/TextField.test.js +8 -7
- package/lib/components/base/colorPicker/ColorPicker.vue +33 -51
- package/lib/components/base/composables/__tests__/useDeselectionLock.test.js +4 -2
- package/lib/components/base/composables/__tests__/useModalToggler.test.js +3 -1
- package/lib/components/base/composables/__tests__/useScrollView.test.js +3 -1
- package/lib/components/base/dropdown/Dropdown.vue +35 -55
- package/lib/components/base/dropdown/DropdownActivator.vue +38 -66
- package/lib/components/base/dropdown/DropdownDivider.vue +0 -6
- package/lib/components/base/dropdown/DropdownGroup.vue +8 -20
- package/lib/components/base/dropdown/DropdownMenu.vue +8 -21
- package/lib/components/base/dropdown/DropdownOption.vue +27 -45
- package/lib/components/base/dropdown/__tests__/DropdownActivator.test.js +5 -3
- package/lib/components/base/dropdown/__tests__/DropdownOption.test.js +9 -7
- package/lib/components/toolbar/Toolbar.vue +26 -42
- package/lib/components/toolbar/__tests__/Toolbar.test.js +1 -1
- package/lib/components/toolbar/base/__tests__/ToolbarDivider.test.js +1 -1
- package/lib/components/toolbar/controls/AlignmentControl.vue +27 -46
- package/lib/components/toolbar/controls/BackgroundColorControl.vue +5 -26
- package/lib/components/toolbar/controls/CaseStyleControl.vue +10 -32
- package/lib/components/toolbar/controls/FontColorControl.vue +5 -27
- package/lib/components/toolbar/controls/FontFamilyControl.vue +27 -49
- package/lib/components/toolbar/controls/FontSizeControl.vue +9 -29
- package/lib/components/toolbar/controls/FontWeightControl.vue +7 -27
- package/lib/components/toolbar/controls/ItalicControl.vue +6 -27
- package/lib/components/toolbar/controls/LineHeightControl.vue +10 -37
- package/lib/components/toolbar/controls/ListControl.vue +18 -49
- package/lib/components/toolbar/controls/RemoveFormatControl.vue +4 -21
- package/lib/components/toolbar/controls/StrikeThroughControl.vue +5 -25
- package/lib/components/toolbar/controls/StylePresetControl.vue +34 -59
- package/lib/components/toolbar/controls/SuperscriptControl.vue +5 -25
- package/lib/components/toolbar/controls/UnderlineControl.vue +5 -26
- package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +15 -13
- package/lib/components/toolbar/controls/__tests__/BackgroundColorControl.test.js +17 -15
- package/lib/components/toolbar/controls/__tests__/CaseStyleControl.test.js +9 -8
- package/lib/components/toolbar/controls/__tests__/FontColorControl.test.js +17 -15
- package/lib/components/toolbar/controls/__tests__/FontFamilyControl.test.js +14 -12
- package/lib/components/toolbar/controls/__tests__/FontSizeControl.test.js +5 -3
- package/lib/components/toolbar/controls/__tests__/FontWeightControl.test.js +3 -1
- package/lib/components/toolbar/controls/__tests__/ItalicControl.test.js +3 -1
- package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +11 -9
- package/lib/components/toolbar/controls/__tests__/ListControl.test.js +16 -14
- package/lib/components/toolbar/controls/__tests__/RemoveFormatControl.test.js +3 -1
- package/lib/components/toolbar/controls/__tests__/StrikeThroughControl.test.js +3 -1
- package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +3 -1
- package/lib/components/toolbar/controls/__tests__/SuperscriptControl.test.js +3 -1
- package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +3 -1
- package/lib/components/toolbar/controls/composables/__tests__/useRecentFonts.test.js +6 -4
- package/lib/components/toolbar/controls/link/LinkControl.vue +75 -108
- package/lib/components/toolbar/controls/link/LinkControlHeader.vue +8 -14
- package/lib/components/toolbar/controls/link/__tests__/LinkControl.test.js +5 -3
- package/lib/components/toolbar/controls/link/__tests__/LinkControlHeader.test.js +3 -1
- package/lib/components/toolbar/controls/link/composables/__tests__/useLink.test.js +5 -4
- package/lib/components/toolbar/controls/link/destination/LinkControlDestination.vue +28 -47
- package/lib/components/toolbar/controls/link/destination/LinkControlPageBlock.vue +12 -20
- package/lib/components/toolbar/controls/link/destination/LinkControlUrl.vue +18 -26
- package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlPageBlock.test.js +10 -10
- package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlUrl.test.js +12 -10
- package/lib/components/toolbar/layouts/ToolbarDesktop.vue +36 -64
- package/lib/components/toolbar/layouts/ToolbarMobile.vue +38 -66
- package/lib/components/toolbar/layouts/ToolbarPopup.vue +36 -64
- package/lib/composables/__tests__/useEditor.test.js +3 -3
- package/lib/composables/useEditor.js +1 -1
- package/lib/directives/__tests__/outClick.test.js +9 -9
- package/lib/directives/outClick.js +3 -3
- package/lib/extensions/Alignment.js +1 -1
- package/lib/extensions/BackgroundColor.js +1 -1
- package/lib/extensions/CaseStyle.js +1 -1
- package/lib/extensions/DeviceManager.js +1 -1
- package/lib/extensions/FontColor.js +1 -1
- package/lib/extensions/FontFamily.js +2 -2
- package/lib/extensions/FontSize.js +3 -3
- package/lib/extensions/FontStyle.js +1 -1
- package/lib/extensions/FontWeight.js +1 -1
- package/lib/extensions/LineHeight.js +1 -1
- package/lib/extensions/Link.js +1 -1
- package/lib/extensions/Margin.js +1 -1
- package/lib/extensions/StylePreset.js +9 -9
- package/lib/extensions/Superscript.js +1 -1
- package/lib/extensions/TextDecoration.js +1 -1
- package/lib/extensions/__tests__/Alignment.test.js +1 -1
- package/lib/extensions/__tests__/BackgroundColor.test.js +1 -1
- package/lib/extensions/__tests__/CaseStyle.test.js +1 -1
- package/lib/extensions/__tests__/FontColor.test.js +1 -1
- package/lib/extensions/__tests__/FontFamily.test.js +1 -1
- package/lib/extensions/__tests__/FontSize.test.js +1 -1
- package/lib/extensions/__tests__/FontStyle.test.js +1 -1
- package/lib/extensions/__tests__/FontWeight.test.js +1 -1
- package/lib/extensions/__tests__/LineHeight.test.js +1 -1
- package/lib/extensions/__tests__/Link.test.js +1 -1
- package/lib/extensions/__tests__/StylePreset.test.js +1 -1
- package/lib/extensions/__tests__/Superscript.test.js +1 -1
- package/lib/extensions/__tests__/TextDecoration.test.js +1 -1
- package/lib/extensions/core/NodeProcessor.js +1 -1
- package/lib/extensions/core/SelectionProcessor.js +1 -1
- package/lib/extensions/core/TextProcessor.js +1 -1
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +1 -1
- package/lib/extensions/core/__tests__/SelectionProcessor.test.js +1 -1
- package/lib/extensions/core/__tests__/TextProcessor.test.js +1 -1
- package/lib/extensions/core/index.js +1 -1
- package/lib/extensions/index.js +1 -1
- package/lib/extensions/list/List.js +4 -4
- package/lib/extensions/list/__tests__/List.test.js +1 -1
- package/package.json +19 -20
- package/config/jest/matchers/toVueEmpty.js +0 -16
- package/config/jest/matchers/toVuexActionHasBeenDispatched.js +0 -19
- package/lib/components/base/__tests__/__snapshots__/TextField.test.js.snap +0 -9
- package/lib/components/base/dropdown/__tests__/DropdownMenu.test.js +0 -67
|
@@ -19,19 +19,21 @@ const createEditor = ({ fontFamily } = {}) => ({
|
|
|
19
19
|
|
|
20
20
|
function createComponent({ editor }) {
|
|
21
21
|
return shallowMount(FontFamilyControl, {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
global: {
|
|
23
|
+
stubs: {
|
|
24
|
+
Dropdown: {
|
|
25
|
+
render: () => h('div'),
|
|
26
|
+
props: ['value']
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
provide: {
|
|
30
|
+
[InjectionTokens.EDITOR]: editor,
|
|
31
|
+
[InjectionTokens.FONTS]: [
|
|
32
|
+
{ name: 'Lato', category: 'test' },
|
|
33
|
+
{ name: 'Bungee', category: 'test' }
|
|
34
|
+
],
|
|
35
|
+
[InjectionTokens.LOCAL_STORAGE]: localStorage
|
|
26
36
|
}
|
|
27
|
-
},
|
|
28
|
-
provide: {
|
|
29
|
-
[InjectionTokens.EDITOR]: editor,
|
|
30
|
-
[InjectionTokens.FONTS]: [
|
|
31
|
-
{ name: 'Lato', category: 'test' },
|
|
32
|
-
{ name: 'Bungee', category: 'test' }
|
|
33
|
-
],
|
|
34
|
-
[InjectionTokens.LOCAL_STORAGE]: localStorage
|
|
35
37
|
}
|
|
36
38
|
});
|
|
37
39
|
}
|
|
@@ -19,9 +19,11 @@ const createEditor = ({ fontSize } = {}) => ({
|
|
|
19
19
|
|
|
20
20
|
function createComponent({ editor }) {
|
|
21
21
|
return shallowMount(FontSizeControl, {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
global: {
|
|
23
|
+
provide: {
|
|
24
|
+
[InjectionTokens.EDITOR]: editor,
|
|
25
|
+
[InjectionTokens.FONT_SIZES]: ['12', '23']
|
|
26
|
+
}
|
|
25
27
|
}
|
|
26
28
|
});
|
|
27
29
|
}
|
|
@@ -20,7 +20,9 @@ const createEditor = ({ fontWeight, fontWeightList } = {}) => ({
|
|
|
20
20
|
|
|
21
21
|
function createComponent({ editor }) {
|
|
22
22
|
return shallowMount(FontWeightControl, {
|
|
23
|
-
|
|
23
|
+
global: {
|
|
24
|
+
provide: { [InjectionTokens.EDITOR]: editor }
|
|
25
|
+
}
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
28
|
|
|
@@ -20,7 +20,9 @@ const createEditor = ({ isItalic, isItalicAvailable } = {}) => ({
|
|
|
20
20
|
|
|
21
21
|
function createComponent({ editor }) {
|
|
22
22
|
return shallowMount(ItalicControl, {
|
|
23
|
-
|
|
23
|
+
global: {
|
|
24
|
+
provide: { [InjectionTokens.EDITOR]: editor }
|
|
25
|
+
}
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
28
|
|
|
@@ -28,15 +28,17 @@ const createEditor = ({ height } = {}) => {
|
|
|
28
28
|
|
|
29
29
|
function createComponent({ editor } = {}) {
|
|
30
30
|
return shallowMount(LineHeightControl, {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
global: {
|
|
32
|
+
stubs: {
|
|
33
|
+
Modal: {
|
|
34
|
+
render() {
|
|
35
|
+
return h('div', null, this.$slots.default());
|
|
36
|
+
},
|
|
37
|
+
props: ['toggler']
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
provide: { [InjectionTokens.EDITOR]: editor ?? createEditor() }
|
|
41
|
+
}
|
|
40
42
|
});
|
|
41
43
|
}
|
|
42
44
|
|
|
@@ -20,20 +20,22 @@ const createEditor = ({ listType } = {}) => ({
|
|
|
20
20
|
|
|
21
21
|
function createComponent({ editor }) {
|
|
22
22
|
return shallowMount(ListControl, {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
global: {
|
|
24
|
+
stubs: {
|
|
25
|
+
Dropdown: {
|
|
26
|
+
render() {
|
|
27
|
+
const activator = this.$slots.activator({
|
|
28
|
+
open: jest.fn(),
|
|
29
|
+
isOpened: false
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return h('div', null, [activator]);
|
|
33
|
+
},
|
|
34
|
+
props: ['value']
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
provide: { [InjectionTokens.EDITOR]: editor }
|
|
38
|
+
}
|
|
37
39
|
});
|
|
38
40
|
}
|
|
39
41
|
|
|
@@ -19,7 +19,9 @@ const createEditor = ({ isStrikeThrough } = {}) => ({
|
|
|
19
19
|
|
|
20
20
|
function createComponent({ editor }) {
|
|
21
21
|
return shallowMount(StrikeThroughControl, {
|
|
22
|
-
|
|
22
|
+
global: {
|
|
23
|
+
provide: { [InjectionTokens.EDITOR]: editor }
|
|
24
|
+
}
|
|
23
25
|
});
|
|
24
26
|
}
|
|
25
27
|
|
|
@@ -27,7 +27,9 @@ const createEditor = ({ presets, preset, customization } = {}) => ({
|
|
|
27
27
|
|
|
28
28
|
function createComponent({ editor }) {
|
|
29
29
|
return shallowMount(StylePresetControl, {
|
|
30
|
-
|
|
30
|
+
global: {
|
|
31
|
+
provide: { [InjectionTokens.EDITOR]: editor }
|
|
32
|
+
}
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -19,7 +19,9 @@ const createEditor = ({ isSuperscript } = {}) => ({
|
|
|
19
19
|
|
|
20
20
|
function createComponent({ editor }) {
|
|
21
21
|
return shallowMount(SuperscriptControl, {
|
|
22
|
-
|
|
22
|
+
global: {
|
|
23
|
+
provide: { [InjectionTokens.EDITOR]: editor }
|
|
24
|
+
}
|
|
23
25
|
});
|
|
24
26
|
}
|
|
25
27
|
|
|
@@ -23,7 +23,9 @@ const createEditor = ({ isUnderline } = {}) => ({
|
|
|
23
23
|
|
|
24
24
|
function createComponent({ editor }) {
|
|
25
25
|
return shallowMount(UnderlineControl, {
|
|
26
|
-
|
|
26
|
+
global: {
|
|
27
|
+
provide: { [InjectionTokens.EDITOR]: editor }
|
|
28
|
+
}
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -18,10 +18,12 @@ function createWrapper({ initial } = {}) {
|
|
|
18
18
|
return withComponentContext(() => {
|
|
19
19
|
return useRecentFonts({ limit: 3 });
|
|
20
20
|
}, {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
global: {
|
|
22
|
+
provide: {
|
|
23
|
+
[InjectionTokens.LOCAL_STORAGE]: createStorage({
|
|
24
|
+
'wswg.recently_used_fonts': initial
|
|
25
|
+
})
|
|
26
|
+
}
|
|
25
27
|
}
|
|
26
28
|
});
|
|
27
29
|
}
|
|
@@ -38,123 +38,90 @@
|
|
|
38
38
|
</div>
|
|
39
39
|
</template>
|
|
40
40
|
|
|
41
|
-
<script>
|
|
41
|
+
<script setup>
|
|
42
42
|
import { computed, ref, inject, unref } from 'vue';
|
|
43
43
|
import { LinkDestinations, TextSettings } from '../../../../enums';
|
|
44
44
|
import { InjectionTokens } from '../../../../injectionTokens';
|
|
45
45
|
import { RegExps } from '../../../../regExps';
|
|
46
|
-
import { tooltip } from '../../../../directives';
|
|
46
|
+
import { tooltip as vTooltip } from '../../../../directives';
|
|
47
47
|
import { useValidator } from '../../../base/composables';
|
|
48
48
|
import { Button, Icon, Modal, TextField, useModalToggler } from '../../../base';
|
|
49
49
|
import LinkControlHeader from './LinkControlHeader';
|
|
50
50
|
import { useLink } from './composables';
|
|
51
51
|
import { LinkControlDestination } from './destination';
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
link.updateText(value);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const applyLink = () => {
|
|
129
|
-
urlValidator.validate();
|
|
130
|
-
nameValidator.validate();
|
|
131
|
-
|
|
132
|
-
if (urlValidator.error.value || nameValidator.error.value) return;
|
|
133
|
-
|
|
134
|
-
link.apply();
|
|
135
|
-
toggler.close();
|
|
136
|
-
link.resetDestinations();
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const removeLink = () => {
|
|
140
|
-
link.removeLink();
|
|
141
|
-
toggler.close();
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
return {
|
|
145
|
-
wrapperRef,
|
|
146
|
-
modalRef,
|
|
147
|
-
link,
|
|
148
|
-
toggler,
|
|
149
|
-
isActive,
|
|
150
|
-
nameValidator,
|
|
151
|
-
urlValidator,
|
|
152
|
-
updateLinkText,
|
|
153
|
-
resetErrors,
|
|
154
|
-
applyLink,
|
|
155
|
-
removeLink
|
|
156
|
-
};
|
|
157
|
-
}
|
|
53
|
+
const wrapperRef = ref(null);
|
|
54
|
+
const modalRef = ref(null);
|
|
55
|
+
|
|
56
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
57
|
+
|
|
58
|
+
const link = useLink();
|
|
59
|
+
|
|
60
|
+
const isEmpty = () => {
|
|
61
|
+
return link.linkData.value.text ? false : 'Can\'t be empty';
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const isValidUrl = () => {
|
|
65
|
+
if (link.currentDestination.value.id !== LinkDestinations.URL) return false;
|
|
66
|
+
|
|
67
|
+
const href = link.destinationHrefs.value.url;
|
|
68
|
+
const isTelOrMail = RegExps.TEL_PROTOCOL.test(href) || RegExps.MAILTO_PROTOCOL.test(href);
|
|
69
|
+
|
|
70
|
+
if (isTelOrMail) return false;
|
|
71
|
+
if (href.startsWith('/')) return false;
|
|
72
|
+
|
|
73
|
+
const isUrl = RegExps.URL.test(href);
|
|
74
|
+
|
|
75
|
+
return isUrl ? false : 'Please enter a valid URL';
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const nameValidator = useValidator({
|
|
79
|
+
validations: [isEmpty]
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const urlValidator = useValidator({
|
|
83
|
+
validations: [isValidUrl]
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const resetErrors = () => {
|
|
87
|
+
nameValidator.reset();
|
|
88
|
+
urlValidator.reset();
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const onBeforeOpened = () => {
|
|
92
|
+
editor.commands.extendMarkRange(TextSettings.LINK);
|
|
93
|
+
resetErrors();
|
|
94
|
+
link.prepareInitialFields();
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const toggler = useModalToggler({
|
|
98
|
+
onBeforeOpened: () => onBeforeOpened(),
|
|
99
|
+
wrapperRef,
|
|
100
|
+
modalRef
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const isLink = editor.commands.isLink();
|
|
104
|
+
const isActive = computed(() => unref(toggler.isOpened) || unref(isLink));
|
|
105
|
+
|
|
106
|
+
const updateLinkText = (value) => {
|
|
107
|
+
resetErrors();
|
|
108
|
+
link.updateText(value);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const applyLink = () => {
|
|
112
|
+
urlValidator.validate();
|
|
113
|
+
nameValidator.validate();
|
|
114
|
+
|
|
115
|
+
if (urlValidator.error.value || nameValidator.error.value) return;
|
|
116
|
+
|
|
117
|
+
link.apply();
|
|
118
|
+
toggler.close();
|
|
119
|
+
link.resetDestinations();
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const removeLink = () => {
|
|
123
|
+
link.removeLink();
|
|
124
|
+
toggler.close();
|
|
158
125
|
};
|
|
159
126
|
</script>
|
|
160
127
|
|
|
@@ -172,7 +139,7 @@ export default {
|
|
|
172
139
|
justify-content: flex-end;
|
|
173
140
|
}
|
|
174
141
|
|
|
175
|
-
|
|
142
|
+
:deep(.zw-link-modal-dropdown__option) {
|
|
176
143
|
width: 234px;
|
|
177
144
|
}
|
|
178
145
|
</style>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="zw-link-modal-header">
|
|
3
|
-
<span class="zw-link-modal-header__title">
|
|
3
|
+
<span class="zw-link-modal-header__title">
|
|
4
|
+
Link
|
|
5
|
+
</span>
|
|
4
6
|
|
|
5
7
|
<Button class="zw-link-modal-header__unlink-button" :disabled="!isLink" data-initial-focus="false" @click="removeLink">
|
|
6
8
|
<Icon class="zw-link-modal-header__unlink-icon" name="unlink" size="14px" auto-color />
|
|
@@ -9,25 +11,17 @@
|
|
|
9
11
|
</div>
|
|
10
12
|
</template>
|
|
11
13
|
|
|
12
|
-
<script>
|
|
14
|
+
<script setup>
|
|
13
15
|
import { inject } from 'vue';
|
|
14
16
|
import { Icon, Button } from '../../../base';
|
|
15
17
|
import { InjectionTokens } from '../../../../injectionTokens';
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
name: 'LinkControlHeader',
|
|
19
|
+
const emit = defineEmits(['remove-link']);
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
22
|
+
const isLink = editor.commands.isLink();
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
const editor = inject(InjectionTokens.EDITOR);
|
|
24
|
-
const isLink = editor.commands.isLink();
|
|
25
|
-
|
|
26
|
-
const removeLink = () => emit('remove-link');
|
|
27
|
-
|
|
28
|
-
return { isLink, removeLink };
|
|
29
|
-
}
|
|
30
|
-
};
|
|
24
|
+
const removeLink = () => emit('remove-link');
|
|
31
25
|
</script>
|
|
32
26
|
|
|
33
27
|
<style scoped>
|
|
@@ -11,9 +11,11 @@ const createEditor = (isActive) => ({
|
|
|
11
11
|
|
|
12
12
|
function createComponent({ editor }) {
|
|
13
13
|
return shallowMount(LinkControl, {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
global: {
|
|
15
|
+
provide: {
|
|
16
|
+
[InjectionTokens.EDITOR]: editor,
|
|
17
|
+
[InjectionTokens.PAGE_BLOCKS]: ref([{ id: 1 }])
|
|
18
|
+
}
|
|
17
19
|
}
|
|
18
20
|
});
|
|
19
21
|
}
|
|
@@ -27,10 +27,11 @@ const createEditor = (text, destination) => ({
|
|
|
27
27
|
|
|
28
28
|
function useComposable(text, destination) {
|
|
29
29
|
return withComponentContext(() => useLink(), {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
global: {
|
|
31
|
+
provide: {
|
|
32
|
+
[InjectionTokens.EDITOR]: createEditor(text, destination),
|
|
33
|
+
[InjectionTokens.PAGE_BLOCKS]: ref([{ id: 1 }, { id: 2 }])
|
|
34
|
+
}
|
|
34
35
|
}
|
|
35
36
|
});
|
|
36
37
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
color="gray"
|
|
10
10
|
:max-width="266"
|
|
11
11
|
:value="link.currentDestination.value.id"
|
|
12
|
-
:options="
|
|
12
|
+
:options="destinationTypes"
|
|
13
13
|
@change="changeDestination"
|
|
14
14
|
>
|
|
15
15
|
<template #option="{ option }">
|
|
@@ -38,66 +38,47 @@
|
|
|
38
38
|
</div>
|
|
39
39
|
</template>
|
|
40
40
|
|
|
41
|
-
<script>
|
|
41
|
+
<script setup>
|
|
42
42
|
import { computed, toRef } from 'vue';
|
|
43
43
|
import { LinkDestinations, LinkTargets } from '../../../../../enums';
|
|
44
44
|
import { Dropdown, DropdownOption, FieldLabel } from '../../../../base';
|
|
45
45
|
import LinkControlPageBlock from './LinkControlPageBlock';
|
|
46
46
|
import LinkControlUrl from './LinkControlUrl';
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const destinationTypes = [
|
|
49
|
+
{ id: LinkDestinations.URL, title: 'URL' },
|
|
50
|
+
{ id: LinkDestinations.BLOCK, title: 'Page Block' }
|
|
51
|
+
];
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
components: {
|
|
57
|
-
LinkControlPageBlock,
|
|
58
|
-
LinkControlUrl,
|
|
59
|
-
FieldLabel,
|
|
60
|
-
DropdownOption,
|
|
61
|
-
Dropdown
|
|
53
|
+
const props = defineProps({
|
|
54
|
+
link: {
|
|
55
|
+
type: Object,
|
|
56
|
+
required: true
|
|
62
57
|
},
|
|
63
58
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
validator: {
|
|
71
|
-
type: Object,
|
|
72
|
-
required: true
|
|
73
|
-
}
|
|
74
|
-
},
|
|
59
|
+
validator: {
|
|
60
|
+
type: Object,
|
|
61
|
+
required: true
|
|
62
|
+
}
|
|
63
|
+
});
|
|
75
64
|
|
|
76
|
-
|
|
77
|
-
const link = toRef(props, 'link');
|
|
78
|
-
const isURLDestination = computed(() => link.value.currentDestination.value.id === LinkDestinations.URL);
|
|
79
|
-
const isTargetBlank = computed(() => link.value.linkData.value.target === LinkTargets.BLANK);
|
|
65
|
+
const emit = defineEmits(['reset-errors']);
|
|
80
66
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (!isURLDestination.value) link.value.target = LinkTargets.SELF;
|
|
67
|
+
const link = toRef(props, 'link');
|
|
68
|
+
const isURLDestination = computed(() => link.value.currentDestination.value.id === LinkDestinations.URL);
|
|
69
|
+
const isTargetBlank = computed(() => link.value.linkData.value.target === LinkTargets.BLANK);
|
|
85
70
|
|
|
86
|
-
|
|
87
|
-
|
|
71
|
+
const changeDestination = (value) => {
|
|
72
|
+
emit('reset-errors');
|
|
73
|
+
link.value.currentDestination.value.id = value;
|
|
74
|
+
if (!isURLDestination.value) link.value.target = LinkTargets.SELF;
|
|
88
75
|
|
|
89
|
-
|
|
90
|
-
|
|
76
|
+
link.value.destinationHrefs.value.url = '';
|
|
77
|
+
};
|
|
91
78
|
|
|
92
|
-
|
|
93
|
-
|
|
79
|
+
const updateLink = (value) => {
|
|
80
|
+
emit('reset-errors');
|
|
94
81
|
|
|
95
|
-
|
|
96
|
-
isTargetBlank,
|
|
97
|
-
isURLDestination,
|
|
98
|
-
changeDestination,
|
|
99
|
-
updateLink
|
|
100
|
-
};
|
|
101
|
-
}
|
|
82
|
+
link.value.updateLink(value);
|
|
102
83
|
};
|
|
103
84
|
</script>
|
|
@@ -21,34 +21,26 @@
|
|
|
21
21
|
</div>
|
|
22
22
|
</template>
|
|
23
23
|
|
|
24
|
-
<script>
|
|
24
|
+
<script setup>
|
|
25
25
|
import { inject } from 'vue';
|
|
26
26
|
import { FieldLabel, DropdownOption, Dropdown } from '../../../../base';
|
|
27
27
|
import { InjectionTokens } from '../../../../../injectionTokens';
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
value: {
|
|
36
|
-
type: Number,
|
|
37
|
-
required: true
|
|
38
|
-
}
|
|
39
|
-
},
|
|
29
|
+
defineProps({
|
|
30
|
+
value: {
|
|
31
|
+
type: Number,
|
|
32
|
+
required: true
|
|
33
|
+
}
|
|
34
|
+
});
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
const pageBlocks = inject(InjectionTokens.PAGE_BLOCKS);
|
|
36
|
+
const emit = defineEmits(['update']);
|
|
43
37
|
|
|
44
|
-
|
|
45
|
-
const block = pageBlocks.value.find((block) => block.id === id);
|
|
38
|
+
const pageBlocks = inject(InjectionTokens.PAGE_BLOCKS);
|
|
46
39
|
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
const applyBlock = (id) => {
|
|
41
|
+
const block = pageBlocks.value.find((block) => block.id === id);
|
|
49
42
|
|
|
50
|
-
|
|
51
|
-
}
|
|
43
|
+
emit('update', block.id);
|
|
52
44
|
};
|
|
53
45
|
</script>
|
|
54
46
|
|