@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
|
@@ -9,64 +9,46 @@
|
|
|
9
9
|
</Button>
|
|
10
10
|
</template>
|
|
11
11
|
|
|
12
|
-
<script>
|
|
12
|
+
<script setup>
|
|
13
13
|
import { computed, inject, nextTick, onMounted, ref, toRef } from 'vue';
|
|
14
14
|
import Button from '../Button';
|
|
15
15
|
import { useScrollView } from '../composables';
|
|
16
16
|
import { InjectionTokens } from './injectionTokens';
|
|
17
17
|
import { useDropdownEntityTitle } from './composables';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
props: {
|
|
27
|
-
option: {
|
|
28
|
-
type: Object,
|
|
29
|
-
required: true
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
setup(props) {
|
|
34
|
-
const activeOptionManager = inject(InjectionTokens.ACTIVE_MANAGER);
|
|
35
|
-
const dropdownToggler = inject(InjectionTokens.TOGGLER);
|
|
36
|
-
const session = inject(InjectionTokens.SESSION);
|
|
19
|
+
const props = defineProps({
|
|
20
|
+
option: {
|
|
21
|
+
type: Object,
|
|
22
|
+
required: true
|
|
23
|
+
}
|
|
24
|
+
});
|
|
37
25
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const isActive = computed(() => props.option.id === activeOptionManager.activeOption.value?.id);
|
|
42
|
-
const classes = computed(() => ({ 'zw-dropdown__option--active': isActive.value }));
|
|
26
|
+
const activeOptionManager = inject(InjectionTokens.ACTIVE_MANAGER);
|
|
27
|
+
const dropdownToggler = inject(InjectionTokens.TOGGLER);
|
|
28
|
+
const session = inject(InjectionTokens.SESSION);
|
|
43
29
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
30
|
+
const optionRef = ref(null);
|
|
31
|
+
const scrollView = useScrollView();
|
|
32
|
+
const optionTitle = useDropdownEntityTitle(toRef(props, 'option'));
|
|
33
|
+
const isActive = computed(() => props.option.id === activeOptionManager.activeOption.value?.id);
|
|
34
|
+
const classes = computed(() => ({ 'zw-dropdown__option--active': isActive.value }));
|
|
48
35
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
function activate() {
|
|
37
|
+
activeOptionManager.activateOption(props.option);
|
|
38
|
+
dropdownToggler.close();
|
|
39
|
+
}
|
|
52
40
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
onMounted(async () => {
|
|
42
|
+
if (isActive.value && !session.scrolled) {
|
|
43
|
+
session.scrolled = true; // Prevent multiple scrolling to option
|
|
56
44
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
await nextTick();
|
|
46
|
+
const el = optionRef.value.$el;
|
|
47
|
+
const offset = el.offsetHeight * 1.5;
|
|
60
48
|
|
|
61
|
-
|
|
62
|
-
optionTitle,
|
|
63
|
-
classes,
|
|
64
|
-
isActive,
|
|
65
|
-
optionRef,
|
|
66
|
-
activate
|
|
67
|
-
};
|
|
49
|
+
scrollView.scrollToElement(el, { offset });
|
|
68
50
|
}
|
|
69
|
-
};
|
|
51
|
+
});
|
|
70
52
|
</script>
|
|
71
53
|
|
|
72
54
|
<style scoped>
|
|
@@ -15,9 +15,11 @@ const createActiveOptionManager = ({ activeOption } = {}) => ({
|
|
|
15
15
|
|
|
16
16
|
function createComponent({ toggler, activeOptionManager } = {}) {
|
|
17
17
|
return shallowMount(DropdownActivator, {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
global: {
|
|
19
|
+
provide: {
|
|
20
|
+
[InjectionTokens.TOGGLER]: toggler ?? createToggler(),
|
|
21
|
+
[InjectionTokens.ACTIVE_MANAGER]: activeOptionManager ?? createActiveOptionManager()
|
|
22
|
+
}
|
|
21
23
|
}
|
|
22
24
|
});
|
|
23
25
|
}
|
|
@@ -17,13 +17,15 @@ const createToggler = () => ({
|
|
|
17
17
|
|
|
18
18
|
function createComponent({ option, activeManager, toggler }) {
|
|
19
19
|
return shallowMount(DropdownOption, {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
props: { option },
|
|
21
|
+
|
|
22
|
+
global: {
|
|
23
|
+
provide: {
|
|
24
|
+
[InjectionTokens.ACTIVE_MANAGER]: activeManager ?? createActiveManager(),
|
|
25
|
+
[InjectionTokens.TOGGLER]: toggler ?? createToggler(),
|
|
26
|
+
[InjectionTokens.SESSION]: {},
|
|
27
|
+
[SCROLL_VIEW]: ref(null)
|
|
28
|
+
}
|
|
27
29
|
}
|
|
28
30
|
});
|
|
29
31
|
}
|
|
@@ -1,64 +1,47 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<keep-alive>
|
|
3
3
|
<transition name="zw-toolbar-" duration="150">
|
|
4
|
-
<div class="zw-toolbar"
|
|
4
|
+
<div class="zw-toolbar" ref="toolbarRef" v-if="isVisible">
|
|
5
5
|
<component :is="layoutComponent" />
|
|
6
6
|
</div>
|
|
7
7
|
</transition>
|
|
8
8
|
</keep-alive>
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
|
-
<script>
|
|
11
|
+
<script setup>
|
|
12
12
|
import { computed, ref, watch } from 'vue';
|
|
13
13
|
import { Devices } from '../../enums';
|
|
14
14
|
import { ToolbarDesktop, ToolbarMobile, ToolbarPopup } from './layouts';
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
device: {
|
|
21
|
-
type: String,
|
|
22
|
-
required: true
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
toolbar: {
|
|
26
|
-
type: Object,
|
|
27
|
-
required: true
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
popupMode: {
|
|
31
|
-
type: Boolean,
|
|
32
|
-
required: true
|
|
33
|
-
}
|
|
16
|
+
const props = defineProps({
|
|
17
|
+
device: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: true
|
|
34
20
|
},
|
|
35
21
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
22
|
+
toolbar: {
|
|
23
|
+
type: Object,
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
39
26
|
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
popupMode: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
required: true
|
|
30
|
+
}
|
|
31
|
+
});
|
|
42
32
|
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
const layoutComponent = computed(() => {
|
|
34
|
+
if (props.popupMode) return ToolbarPopup;
|
|
45
35
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
36
|
+
return props.device === Devices.MOBILE ? ToolbarMobile : ToolbarDesktop;
|
|
37
|
+
});
|
|
49
38
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}));
|
|
39
|
+
const isVisible = computed(() => props.toolbar.isActiveRef.value);
|
|
40
|
+
const toolbarRef = ref(null);
|
|
53
41
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
toolbarRef,
|
|
58
|
-
toolbarStyles
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
};
|
|
42
|
+
watch(toolbarRef, (toolbarEl) => {
|
|
43
|
+
toolbarEl && props.toolbar.mount(toolbarEl);
|
|
44
|
+
});
|
|
62
45
|
</script>
|
|
63
46
|
|
|
64
47
|
<style scoped>
|
|
@@ -69,6 +52,7 @@ export default {
|
|
|
69
52
|
z-index: 999999;
|
|
70
53
|
text-align: left;
|
|
71
54
|
position: absolute;
|
|
55
|
+
--zw-toolbar-offset-y: calc(v-bind("toolbar.offsets[1]") * 1px)
|
|
72
56
|
}
|
|
73
57
|
|
|
74
58
|
.zw-toolbar::before,
|
|
@@ -98,7 +82,7 @@ export default {
|
|
|
98
82
|
transition: opacity 0s ease-in;
|
|
99
83
|
}
|
|
100
84
|
|
|
101
|
-
.zw-toolbar--enter,
|
|
85
|
+
.zw-toolbar--enter-from,
|
|
102
86
|
.zw-toolbar--leave-to {
|
|
103
87
|
opacity: 0;
|
|
104
88
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<ButtonToggle :value="currentValue" :options="
|
|
2
|
+
<ButtonToggle :value="currentValue" :options="alignments" @change="toggle">
|
|
3
3
|
<template #option="{ isActive, option, activate }">
|
|
4
4
|
<Button
|
|
5
5
|
class="zw-position--relative"
|
|
@@ -15,59 +15,40 @@
|
|
|
15
15
|
</ButtonToggle>
|
|
16
16
|
</template>
|
|
17
17
|
|
|
18
|
-
<script>
|
|
18
|
+
<script setup>
|
|
19
19
|
import { inject, computed, unref } from 'vue';
|
|
20
20
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
21
21
|
import { Alignments } from '../../../enums';
|
|
22
22
|
import { ButtonToggle, Button, Icon } from '../../base';
|
|
23
|
-
import { tooltip } from '../../../directives';
|
|
23
|
+
import { tooltip as vTooltip } from '../../../directives';
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
id: Alignments.LEFT,
|
|
31
|
-
tooltip: { text: 'Align Left', hotkey: 'Mod Shift L' }
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
id: Alignments.CENTER,
|
|
35
|
-
tooltip: { text: 'Align Center', hotkey: 'Mod Shift E' }
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
id: Alignments.RIGHT,
|
|
39
|
-
tooltip: { text: 'Align Right', hotkey: 'Mod Shift R' }
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
id: Alignments.JUSTIFY,
|
|
43
|
-
tooltip: { text: 'Justify', hotkey: 'Mod Shift J' }
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
|
|
47
|
-
components: {
|
|
48
|
-
ButtonToggle,
|
|
49
|
-
Button,
|
|
50
|
-
Icon
|
|
25
|
+
const alignments = [
|
|
26
|
+
{
|
|
27
|
+
id: Alignments.LEFT,
|
|
28
|
+
tooltip: { text: 'Align Left', hotkey: 'Mod Shift L' }
|
|
51
29
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
tooltip
|
|
30
|
+
{
|
|
31
|
+
id: Alignments.CENTER,
|
|
32
|
+
tooltip: { text: 'Align Center', hotkey: 'Mod Shift E' }
|
|
55
33
|
},
|
|
34
|
+
{
|
|
35
|
+
id: Alignments.RIGHT,
|
|
36
|
+
tooltip: { text: 'Align Right', hotkey: 'Mod Shift R' }
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: Alignments.JUSTIFY,
|
|
40
|
+
tooltip: { text: 'Justify', hotkey: 'Mod Shift J' }
|
|
41
|
+
}
|
|
42
|
+
];
|
|
56
43
|
|
|
57
|
-
|
|
58
|
-
const editor = inject(InjectionTokens.EDITOR);
|
|
59
|
-
const alignment = editor.commands.getAlignment();
|
|
60
|
-
const currentValue = computed(() => unref(alignment) ?? 'none');
|
|
44
|
+
const emit = defineEmits(['applied']);
|
|
61
45
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
46
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
47
|
+
const alignment = editor.commands.getAlignment();
|
|
48
|
+
const currentValue = computed(() => unref(alignment) ?? 'none');
|
|
66
49
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
};
|
|
50
|
+
function toggle(value) {
|
|
51
|
+
editor.chain().focus().toggleAlignment(value).run();
|
|
52
|
+
emit('applied');
|
|
53
|
+
}
|
|
73
54
|
</script>
|
|
@@ -14,35 +14,14 @@
|
|
|
14
14
|
</ColorPicker>
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
|
-
<script>
|
|
17
|
+
<script setup>
|
|
18
18
|
import { inject } from 'vue';
|
|
19
19
|
import { ColorPicker, Button, Icon } from '../../base';
|
|
20
20
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
21
|
-
import { tooltip } from '../../../directives';
|
|
21
|
+
import { tooltip as vTooltip } from '../../../directives';
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
name: 'BackgroundColorControl',
|
|
23
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Button,
|
|
29
|
-
Icon
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
directives: {
|
|
33
|
-
tooltip
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
setup() {
|
|
37
|
-
const editor = inject(InjectionTokens.EDITOR);
|
|
38
|
-
|
|
39
|
-
const currentValue = editor.commands.getBackgroundColor();
|
|
40
|
-
const apply = (color) => editor.chain().applyBackgroundColor(color).run();
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
currentValue,
|
|
44
|
-
apply
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
};
|
|
25
|
+
const currentValue = editor.commands.getBackgroundColor();
|
|
26
|
+
const apply = (color) => editor.chain().applyBackgroundColor(color).run();
|
|
48
27
|
</script>
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<Dropdown
|
|
3
|
-
:options="$options.styles"
|
|
4
|
-
@change="apply"
|
|
5
|
-
>
|
|
2
|
+
<Dropdown :options="styles" @change="apply">
|
|
6
3
|
<template #activator="{ open, isOpened }">
|
|
7
4
|
<Button
|
|
8
5
|
icon
|
|
@@ -17,38 +14,19 @@
|
|
|
17
14
|
</Dropdown>
|
|
18
15
|
</template>
|
|
19
16
|
|
|
20
|
-
<script>
|
|
17
|
+
<script setup>
|
|
21
18
|
import { inject } from 'vue';
|
|
22
19
|
import { CaseStyles } from '../../../enums';
|
|
23
20
|
import { Dropdown, Button, Icon } from '../../base';
|
|
24
21
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
25
|
-
import { tooltip } from '../../../directives';
|
|
22
|
+
import { tooltip as vTooltip } from '../../../directives';
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const styles = [
|
|
25
|
+
{ id: CaseStyles.UPPERCASE, title: 'UPPERCASE' },
|
|
26
|
+
{ id: CaseStyles.LOWERCASE, title: 'lowercase' },
|
|
27
|
+
{ id: CaseStyles.CAPITALIZE, title: 'Capitalize' }
|
|
28
|
+
];
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Button,
|
|
33
|
-
Icon
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
directives: {
|
|
37
|
-
tooltip
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
styles: [
|
|
41
|
-
{ id: CaseStyles.UPPERCASE, title: 'UPPERCASE' },
|
|
42
|
-
{ id: CaseStyles.LOWERCASE, title: 'lowercase' },
|
|
43
|
-
{ id: CaseStyles.CAPITALIZE, title: 'Capitalize' }
|
|
44
|
-
],
|
|
45
|
-
|
|
46
|
-
setup() {
|
|
47
|
-
const editor = inject(InjectionTokens.EDITOR);
|
|
48
|
-
|
|
49
|
-
const apply = (value) => editor.chain().focus().applyCaseStyle(value).run();
|
|
50
|
-
|
|
51
|
-
return { apply };
|
|
52
|
-
}
|
|
53
|
-
};
|
|
30
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
31
|
+
const apply = (value) => editor.chain().focus().applyCaseStyle(value).run();
|
|
54
32
|
</script>
|
|
@@ -14,36 +14,14 @@
|
|
|
14
14
|
</ColorPicker>
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
|
-
<script>
|
|
17
|
+
<script setup>
|
|
18
18
|
import { inject } from 'vue';
|
|
19
19
|
import { ColorPicker, Button, Icon } from '../../base';
|
|
20
20
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
21
|
-
import { tooltip } from '../../../directives';
|
|
21
|
+
import { tooltip as vTooltip } from '../../../directives';
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
name: 'FontColorControl',
|
|
23
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Button,
|
|
29
|
-
Icon
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
directives: {
|
|
33
|
-
tooltip
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
setup() {
|
|
37
|
-
const editor = inject(InjectionTokens.EDITOR);
|
|
38
|
-
|
|
39
|
-
const currentValue = editor.commands.getFontColor();
|
|
40
|
-
|
|
41
|
-
const apply = (color) => editor.chain().applyFontColor(color).run();
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
currentValue,
|
|
45
|
-
apply
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
};
|
|
25
|
+
const currentValue = editor.commands.getFontColor();
|
|
26
|
+
const apply = (color) => editor.chain().applyFontColor(color).run();
|
|
49
27
|
</script>
|
|
@@ -17,69 +17,47 @@
|
|
|
17
17
|
</Dropdown>
|
|
18
18
|
</template>
|
|
19
19
|
|
|
20
|
-
<script>
|
|
20
|
+
<script setup>
|
|
21
21
|
import { computed, inject } from 'vue';
|
|
22
22
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
23
|
-
import { tooltip } from '../../../directives';
|
|
23
|
+
import { tooltip as vTooltip } from '../../../directives';
|
|
24
24
|
import { Dropdown, DropdownOption } from '../../base';
|
|
25
25
|
import { useRecentFonts } from './composables';
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const fonts = inject(InjectionTokens.FONTS);
|
|
28
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
Dropdown,
|
|
32
|
-
DropdownOption
|
|
33
|
-
},
|
|
30
|
+
const recentFontNames = useRecentFonts({ limit: 5 });
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
32
|
+
const recentFontsCategory = computed(() => ({
|
|
33
|
+
id: 'Recently Used',
|
|
34
|
+
options: recentFontNames.fonts.value.map((name) => ({ id: name }))
|
|
35
|
+
}));
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const editor = inject(InjectionTokens.EDITOR);
|
|
37
|
+
const options = computed(() => {
|
|
38
|
+
const list = {};
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
options: recentFontNames.fonts.value.map((name) => ({ id: name }))
|
|
48
|
-
}));
|
|
49
|
-
|
|
50
|
-
const options = computed(() => {
|
|
51
|
-
const list = {};
|
|
52
|
-
|
|
53
|
-
for (const font of fonts) {
|
|
54
|
-
list[font.category] ??= { id: font.category, options: [] };
|
|
55
|
-
list[font.category].options.push({ id: font.name });
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (recentFontNames.isEmpty.value) {
|
|
59
|
-
return Object.values(list);
|
|
60
|
-
}
|
|
40
|
+
for (const font of fonts) {
|
|
41
|
+
list[font.category] ??= { id: font.category, options: [] };
|
|
42
|
+
list[font.category].options.push({ id: font.name });
|
|
43
|
+
}
|
|
61
44
|
|
|
62
|
-
|
|
63
|
-
|
|
45
|
+
if (recentFontNames.isEmpty.value) {
|
|
46
|
+
return Object.values(list);
|
|
47
|
+
}
|
|
64
48
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
49
|
+
return [recentFontsCategory.value, ...Object.values(list)];
|
|
50
|
+
});
|
|
68
51
|
|
|
69
|
-
|
|
52
|
+
function renderOptionStyles(option) {
|
|
53
|
+
return { '--zw-font-family-option': `"${option.id}"` };
|
|
54
|
+
}
|
|
70
55
|
|
|
71
|
-
|
|
72
|
-
recentFontNames.add(fontFamily);
|
|
73
|
-
editor.chain().focus().applyFontFamily(fontFamily).run();
|
|
74
|
-
};
|
|
56
|
+
const currentValue = editor.commands.getFont();
|
|
75
57
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
renderOptionStyles,
|
|
80
|
-
apply
|
|
81
|
-
};
|
|
82
|
-
}
|
|
58
|
+
const apply = (fontFamily) => {
|
|
59
|
+
recentFontNames.add(fontFamily);
|
|
60
|
+
editor.chain().focus().applyFontFamily(fontFamily).run();
|
|
83
61
|
};
|
|
84
62
|
</script>
|
|
85
63
|
|
|
@@ -8,42 +8,22 @@
|
|
|
8
8
|
/>
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
|
-
<script>
|
|
11
|
+
<script setup>
|
|
12
12
|
import { computed, inject } from 'vue';
|
|
13
13
|
import { Dropdown } from '../../base';
|
|
14
14
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
15
|
-
import { tooltip } from '../../../directives';
|
|
15
|
+
import { tooltip as vTooltip } from '../../../directives';
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const fontSizes = inject(InjectionTokens.FONT_SIZES);
|
|
18
|
+
const editor = inject(InjectionTokens.EDITOR);
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const options = computed(() => {
|
|
21
|
+
return fontSizes.map((size) => ({ id: size, title: `${size}px` }));
|
|
22
|
+
});
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
tooltip
|
|
26
|
-
},
|
|
24
|
+
const currentValue = editor.commands.getFontSize();
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
const fontSizes = inject(InjectionTokens.FONT_SIZES);
|
|
30
|
-
const editor = inject(InjectionTokens.EDITOR);
|
|
31
|
-
|
|
32
|
-
const options = computed(() => {
|
|
33
|
-
return fontSizes.map((size) => ({ id: size, title: `${size}px` }));
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const currentValue = editor.commands.getFontSize();
|
|
37
|
-
|
|
38
|
-
const apply = (value) => editor.chain().focus().applyFontSize(value).run();
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
options,
|
|
42
|
-
currentValue,
|
|
43
|
-
apply
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
};
|
|
26
|
+
const apply = (value) => editor.chain().focus().applyFontSize(value).run();
|
|
47
27
|
</script>
|
|
48
28
|
|
|
49
29
|
<style scoped>
|