@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
|
@@ -8,40 +8,20 @@
|
|
|
8
8
|
/>
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
|
-
<script>
|
|
11
|
+
<script setup>
|
|
12
12
|
import { computed, inject, unref } from 'vue';
|
|
13
13
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
14
14
|
import { Dropdown } from '../../base';
|
|
15
|
-
import { tooltip } from '../../../directives';
|
|
15
|
+
import { tooltip as vTooltip } from '../../../directives';
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
18
|
+
const font = editor.commands.getFont();
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
Dropdown
|
|
22
|
-
},
|
|
20
|
+
const options = computed(() => unref(font).weights.map((style) => ({ id: style })));
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
tooltip
|
|
26
|
-
},
|
|
22
|
+
const currentValue = editor.commands.getFontWeight();
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
const editor = inject(InjectionTokens.EDITOR);
|
|
30
|
-
const font = editor.commands.getFont();
|
|
31
|
-
|
|
32
|
-
const options = computed(() => unref(font).weights.map((style) => ({ id: style })));
|
|
33
|
-
|
|
34
|
-
const currentValue = editor.commands.getFontWeight();
|
|
35
|
-
|
|
36
|
-
const apply = (value) => editor.chain().focus().applyFontWeight(value).run();
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
options,
|
|
40
|
-
currentValue,
|
|
41
|
-
apply
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
};
|
|
24
|
+
const apply = (value) => editor.chain().focus().applyFontWeight(value).run();
|
|
45
25
|
</script>
|
|
46
26
|
|
|
47
27
|
<style scoped>
|
|
@@ -11,38 +11,17 @@
|
|
|
11
11
|
</Button>
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
|
-
<script>
|
|
14
|
+
<script setup>
|
|
15
15
|
import { inject } from 'vue';
|
|
16
16
|
import { Button, Icon } from '../../base';
|
|
17
17
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
18
|
-
import { tooltip } from '../../../directives';
|
|
18
|
+
import { tooltip as vTooltip } from '../../../directives';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
name: 'ItalicControl',
|
|
20
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
Button,
|
|
25
|
-
Icon
|
|
26
|
-
},
|
|
22
|
+
const currentValue = editor.commands.isItalic();
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
setup() {
|
|
33
|
-
const editor = inject(InjectionTokens.EDITOR);
|
|
34
|
-
|
|
35
|
-
const currentValue = editor.commands.isItalic();
|
|
36
|
-
|
|
37
|
-
const isAvailable = editor.commands.isItalicAvailable();
|
|
38
|
-
const apply = () => editor.chain().focus().toggleItalic().run();
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
isAvailable,
|
|
42
|
-
currentValue,
|
|
43
|
-
apply
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
};
|
|
24
|
+
const isAvailable = editor.commands.isItalicAvailable();
|
|
25
|
+
const apply = () => editor.chain().focus().toggleItalic().run();
|
|
47
26
|
</script>
|
|
48
27
|
|
|
@@ -39,48 +39,21 @@
|
|
|
39
39
|
</div>
|
|
40
40
|
</template>
|
|
41
41
|
|
|
42
|
-
<script>
|
|
43
|
-
import { inject, ref } from 'vue';
|
|
42
|
+
<script setup>
|
|
43
|
+
import { computed, inject, ref, unref } from 'vue';
|
|
44
44
|
import { Button, Icon, Modal, Range, NumberField, FieldLabel, useModalToggler } from '../../base';
|
|
45
45
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
46
|
-
import { tooltip } from '../../../directives';
|
|
46
|
+
import { tooltip as vTooltip } from '../../../directives';
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const wrapperRef = ref(null);
|
|
49
|
+
const modalRef = ref(null);
|
|
50
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
51
|
+
const toggler = useModalToggler({ wrapperRef, modalRef });
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
Range,
|
|
53
|
-
Modal,
|
|
54
|
-
Icon,
|
|
55
|
-
Button,
|
|
56
|
-
NumberField,
|
|
57
|
-
FieldLabel
|
|
58
|
-
},
|
|
53
|
+
const currentValue = editor.commands.getLineHeight();
|
|
59
54
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
setup() {
|
|
65
|
-
const wrapperRef = ref(null);
|
|
66
|
-
const modalRef = ref(null);
|
|
67
|
-
const editor = inject(InjectionTokens.EDITOR);
|
|
68
|
-
const toggler = useModalToggler({ wrapperRef, modalRef });
|
|
69
|
-
|
|
70
|
-
const currentValue = editor.commands.getLineHeight();
|
|
71
|
-
|
|
72
|
-
const apply = (value) => editor.commands.applyLineHeight(String(value));
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
wrapperRef,
|
|
76
|
-
modalRef,
|
|
77
|
-
isOpened: toggler.isOpened,
|
|
78
|
-
toggler,
|
|
79
|
-
currentValue,
|
|
80
|
-
apply
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
};
|
|
55
|
+
const apply = (value) => editor.commands.applyLineHeight(String(value));
|
|
56
|
+
const isOpened = computed(() => unref(toggler.isOpened));
|
|
84
57
|
</script>
|
|
85
58
|
|
|
86
59
|
<style scoped>
|
|
@@ -10,11 +10,7 @@
|
|
|
10
10
|
<Icon :name="currentIcon" size="28px" auto-color />
|
|
11
11
|
</Button>
|
|
12
12
|
|
|
13
|
-
<Dropdown
|
|
14
|
-
:value="currentValue"
|
|
15
|
-
:options="$options.listTypes"
|
|
16
|
-
@change="apply"
|
|
17
|
-
>
|
|
13
|
+
<Dropdown :value="currentValue" :options="listTypes" @change="apply">
|
|
18
14
|
<template #activator="{ open, isOpened }">
|
|
19
15
|
<Button
|
|
20
16
|
icon
|
|
@@ -44,59 +40,32 @@
|
|
|
44
40
|
</div>
|
|
45
41
|
</template>
|
|
46
42
|
|
|
47
|
-
<script>
|
|
43
|
+
<script setup>
|
|
48
44
|
import { computed, inject, ref, unref } from 'vue';
|
|
49
45
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
50
46
|
import { Dropdown, DropdownOption, Button, Icon } from '../../base';
|
|
51
47
|
import { ListTypes } from '../../../enums';
|
|
52
|
-
import { tooltip } from '../../../directives';
|
|
53
|
-
|
|
54
|
-
export default {
|
|
55
|
-
name: 'ListControl',
|
|
56
|
-
|
|
57
|
-
listTypes: ListTypes.values.map((type) => ({
|
|
58
|
-
id: type,
|
|
59
|
-
icon: `list-${type}`
|
|
60
|
-
})),
|
|
61
|
-
|
|
62
|
-
components: {
|
|
63
|
-
Dropdown,
|
|
64
|
-
DropdownOption,
|
|
65
|
-
Button,
|
|
66
|
-
Icon
|
|
67
|
-
},
|
|
48
|
+
import { tooltip as vTooltip } from '../../../directives';
|
|
68
49
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
50
|
+
const listTypes = ListTypes.values.map((type) => ({
|
|
51
|
+
id: type,
|
|
52
|
+
icon: `list-${type}`
|
|
53
|
+
}));
|
|
72
54
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const recentListType = ref(ListTypes.DISC);
|
|
79
|
-
const isCurrentListSelected = computed(() => unref(selectionValue) === recentListType.value);
|
|
55
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
56
|
+
const selectionValue = editor.commands.getListType();
|
|
57
|
+
const currentValue = computed(() => unref(selectionValue) || 'none');
|
|
58
|
+
const recentListType = ref(ListTypes.DISC);
|
|
59
|
+
const isCurrentListSelected = computed(() => unref(selectionValue) === recentListType.value);
|
|
80
60
|
|
|
81
|
-
|
|
61
|
+
const currentIcon = computed(() => `list-${recentListType.value}`);
|
|
82
62
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const toggle = () => apply(recentListType.value || ListTypes.DISC);
|
|
89
|
-
|
|
90
|
-
return {
|
|
91
|
-
isList,
|
|
92
|
-
currentValue,
|
|
93
|
-
currentIcon,
|
|
94
|
-
isCurrentListSelected,
|
|
95
|
-
apply,
|
|
96
|
-
toggle
|
|
97
|
-
};
|
|
98
|
-
}
|
|
63
|
+
const apply = (type) => {
|
|
64
|
+
recentListType.value = type;
|
|
65
|
+
editor.chain().focus().applyList(type).run();
|
|
99
66
|
};
|
|
67
|
+
|
|
68
|
+
const toggle = () => apply(recentListType.value || ListTypes.DISC);
|
|
100
69
|
</script>
|
|
101
70
|
|
|
102
71
|
<style scoped>
|
|
@@ -9,29 +9,12 @@
|
|
|
9
9
|
</Button>
|
|
10
10
|
</template>
|
|
11
11
|
|
|
12
|
-
<script>
|
|
12
|
+
<script setup>
|
|
13
13
|
import { inject } from 'vue';
|
|
14
14
|
import { Button, Icon } from '../../base';
|
|
15
15
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
16
|
-
import { tooltip } from '../../../directives';
|
|
16
|
+
import { tooltip as vTooltip } from '../../../directives';
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
components: {
|
|
22
|
-
Icon,
|
|
23
|
-
Button
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
directives: {
|
|
27
|
-
tooltip
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
setup() {
|
|
31
|
-
const editor = inject(InjectionTokens.EDITOR);
|
|
32
|
-
const apply = () => editor.chain().focus().removeFormat().run();
|
|
33
|
-
|
|
34
|
-
return { apply };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
18
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
19
|
+
const apply = () => editor.chain().focus().removeFormat().run();
|
|
37
20
|
</script>
|
|
@@ -10,35 +10,15 @@
|
|
|
10
10
|
</Button>
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
|
-
<script>
|
|
13
|
+
<script setup>
|
|
14
14
|
import { inject } from 'vue';
|
|
15
15
|
import { Button, Icon } from '../../base';
|
|
16
16
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
17
|
-
import { tooltip } from '../../../directives';
|
|
17
|
+
import { tooltip as vTooltip } from '../../../directives';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
name: 'StrikeThroughControl',
|
|
19
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Icon
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
directives: {
|
|
28
|
-
tooltip
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
setup() {
|
|
32
|
-
const editor = inject(InjectionTokens.EDITOR);
|
|
33
|
-
|
|
34
|
-
const currentValue = editor.commands.isStrikeThrough();
|
|
35
|
-
const apply = () => editor.chain().focus().toggleStrikeThrough().run();
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
currentValue,
|
|
39
|
-
apply
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
};
|
|
21
|
+
const currentValue = editor.commands.isStrikeThrough();
|
|
22
|
+
const apply = () => editor.chain().focus().toggleStrikeThrough().run();
|
|
43
23
|
</script>
|
|
44
24
|
|
|
@@ -20,73 +20,48 @@
|
|
|
20
20
|
</div>
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
|
-
<script>
|
|
23
|
+
<script setup>
|
|
24
24
|
import { computed, inject, unref } from 'vue';
|
|
25
25
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
26
26
|
import { Dropdown, Button, Icon } from '../../base';
|
|
27
|
-
import { tooltip } from '../../../directives';
|
|
27
|
+
import { tooltip as vTooltip } from '../../../directives';
|
|
28
28
|
import { TextSettings } from '../../../enums';
|
|
29
29
|
|
|
30
30
|
const CLEAR_MARKS = [TextSettings.FONT_SIZE, TextSettings.FONT_WEIGHT];
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
id: preset.id,
|
|
61
|
-
title: preset.name
|
|
62
|
-
}));
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const apply = (value) => {
|
|
66
|
-
editor.chain()
|
|
67
|
-
.focus()
|
|
68
|
-
.applyPreset(value)
|
|
69
|
-
.storeSelection()
|
|
70
|
-
.expandSelectionToBlock()
|
|
71
|
-
.removeMarks(CLEAR_MARKS)
|
|
72
|
-
.restoreSelection()
|
|
73
|
-
.run();
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const tooltip = computed(() => isCustomized.value ? 'Reset Styles to Page Styles' : '');
|
|
77
|
-
|
|
78
|
-
const removeCustomization = () => editor.chain().focus().removePresetCustomization().run();
|
|
79
|
-
|
|
80
|
-
return {
|
|
81
|
-
options,
|
|
82
|
-
preset,
|
|
83
|
-
tooltip,
|
|
84
|
-
isCustomized,
|
|
85
|
-
apply,
|
|
86
|
-
removeCustomization
|
|
87
|
-
};
|
|
88
|
-
}
|
|
32
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
33
|
+
|
|
34
|
+
const presets = editor.commands.getPresetList();
|
|
35
|
+
const preset = editor.commands.getPreset();
|
|
36
|
+
const customization = editor.commands.getPresetCustomization();
|
|
37
|
+
|
|
38
|
+
const isCustomized = computed(() => {
|
|
39
|
+
const { attributes, marks } = unref(customization);
|
|
40
|
+
|
|
41
|
+
return !!attributes.length || !!marks.length;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const options = computed(() => {
|
|
45
|
+
return unref(presets).map((preset) => ({
|
|
46
|
+
id: preset.id,
|
|
47
|
+
title: preset.name
|
|
48
|
+
}));
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const apply = (value) => {
|
|
52
|
+
editor.chain()
|
|
53
|
+
.focus()
|
|
54
|
+
.applyPreset(value)
|
|
55
|
+
.storeSelection()
|
|
56
|
+
.expandSelectionToBlock()
|
|
57
|
+
.removeMarks(CLEAR_MARKS)
|
|
58
|
+
.restoreSelection()
|
|
59
|
+
.run();
|
|
89
60
|
};
|
|
61
|
+
|
|
62
|
+
const tooltip = computed(() => isCustomized.value ? 'Reset Styles to Page Styles' : '');
|
|
63
|
+
|
|
64
|
+
const removeCustomization = () => editor.chain().focus().removePresetCustomization().run();
|
|
90
65
|
</script>
|
|
91
66
|
|
|
92
67
|
<style scoped>
|
|
@@ -10,35 +10,15 @@
|
|
|
10
10
|
</Button>
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
|
-
<script>
|
|
13
|
+
<script setup>
|
|
14
14
|
import { inject } from 'vue';
|
|
15
15
|
import { Button, Icon } from '../../base';
|
|
16
16
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
17
|
-
import { tooltip } from '../../../directives';
|
|
17
|
+
import { tooltip as vTooltip } from '../../../directives';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
name: 'SuperscriptControl',
|
|
19
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Icon
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
directives: {
|
|
28
|
-
tooltip
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
setup() {
|
|
32
|
-
const editor = inject(InjectionTokens.EDITOR);
|
|
33
|
-
|
|
34
|
-
const currentValue = editor.commands.isSuperscript();
|
|
35
|
-
const apply = () => editor.chain().focus().toggleSuperscript().run();
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
currentValue,
|
|
39
|
-
apply
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
};
|
|
21
|
+
const currentValue = editor.commands.isSuperscript();
|
|
22
|
+
const apply = () => editor.chain().focus().toggleSuperscript().run();
|
|
43
23
|
</script>
|
|
44
24
|
|
|
@@ -10,36 +10,15 @@
|
|
|
10
10
|
</Button>
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
|
-
<script>
|
|
13
|
+
<script setup>
|
|
14
14
|
import { inject } from 'vue';
|
|
15
15
|
import { Button, Icon } from '../../base';
|
|
16
16
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
17
|
-
import { tooltip } from '../../../directives';
|
|
17
|
+
import { tooltip as vTooltip } from '../../../directives';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
name: 'UnderlineControl',
|
|
19
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Icon
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
directives: {
|
|
28
|
-
tooltip
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
setup() {
|
|
32
|
-
const editor = inject(InjectionTokens.EDITOR);
|
|
33
|
-
|
|
34
|
-
const currentValue = editor.commands.isUnderline();
|
|
35
|
-
|
|
36
|
-
const apply = () => editor.chain().focus().toggleUnderline().run();
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
currentValue,
|
|
40
|
-
apply
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
};
|
|
21
|
+
const currentValue = editor.commands.isUnderline();
|
|
22
|
+
const apply = () => editor.chain().focus().toggleUnderline().run();
|
|
44
23
|
</script>
|
|
45
24
|
|
|
@@ -20,20 +20,22 @@ const createEditor = ({ alignment } = {}) => ({
|
|
|
20
20
|
|
|
21
21
|
function createComponent({ editor, slotParams }) {
|
|
22
22
|
return shallowMount(AlignmentControl, {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
global: {
|
|
24
|
+
stubs: {
|
|
25
|
+
ButtonToggle: {
|
|
26
|
+
render() {
|
|
27
|
+
const children = this.$slots.option({
|
|
28
|
+
...slotParams,
|
|
29
|
+
activate: jest.fn()
|
|
30
|
+
});
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
return h('div', null, children);
|
|
33
|
+
},
|
|
34
|
+
props: ['value']
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
provide: { [InjectionTokens.EDITOR]: editor }
|
|
38
|
+
}
|
|
37
39
|
});
|
|
38
40
|
}
|
|
39
41
|
|
|
@@ -19,22 +19,24 @@ const createEditor = ({ backgroundColor } = {}) => ({
|
|
|
19
19
|
|
|
20
20
|
function createComponent({ editor }) {
|
|
21
21
|
return shallowMount(BackgroundColorControl, {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
global: {
|
|
23
|
+
stubs: {
|
|
24
|
+
ColorPicker: {
|
|
25
|
+
name: 'ColorPicker',
|
|
26
|
+
props: ['value'],
|
|
27
|
+
|
|
28
|
+
render() {
|
|
29
|
+
const children = this.$slots.activator({
|
|
30
|
+
toggle: jest.fn(),
|
|
31
|
+
isOpened: false
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return h('div', null, children);
|
|
35
|
+
}
|
|
34
36
|
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
},
|
|
38
|
+
provide: { [InjectionTokens.EDITOR]: editor }
|
|
39
|
+
}
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -19,14 +19,15 @@ const createEditor = () => ({
|
|
|
19
19
|
|
|
20
20
|
function createComponent({ editor }) {
|
|
21
21
|
return shallowMount(CaseStyleControl, {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
global: {
|
|
23
|
+
stubs: {
|
|
24
|
+
Dropdown: {
|
|
25
|
+
render: () => h('div'),
|
|
26
|
+
props: ['value']
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
provide: { [InjectionTokens.EDITOR]: editor }
|
|
30
|
+
}
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -19,22 +19,24 @@ const createEditor = ({ fontColor } = {}) => ({
|
|
|
19
19
|
|
|
20
20
|
function createComponent({ editor }) {
|
|
21
21
|
return shallowMount(FontColorControl, {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
global: {
|
|
23
|
+
stubs: {
|
|
24
|
+
ColorPicker: {
|
|
25
|
+
name: 'ColorPicker',
|
|
26
|
+
props: ['value'],
|
|
27
|
+
|
|
28
|
+
render() {
|
|
29
|
+
const children = this.$slots.activator({
|
|
30
|
+
toggle: jest.fn(),
|
|
31
|
+
isOpened: false
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return h('div', null, children);
|
|
35
|
+
}
|
|
34
36
|
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
},
|
|
38
|
+
provide: { [InjectionTokens.EDITOR]: editor }
|
|
39
|
+
}
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
42
|
|