@zipify/wysiwyg 1.0.0-dev.59 → 1.0.0-dev.61
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/dist/wysiwyg.css +1 -1
- package/dist/wysiwyg.mjs +238 -207
- package/lib/components/toolbar/ToolbarRow.vue +1 -0
- package/lib/components/toolbar/controls/ListControl.vue +68 -30
- package/lib/components/toolbar/controls/__tests__/ListControl.test.js +18 -3
- package/lib/extensions/Superscript.js +5 -1
- package/lib/styles/content.css +8 -0
- package/package.json +1 -1
|
@@ -1,31 +1,51 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
<div class="zpa-list-control">
|
|
3
|
+
<Button
|
|
4
|
+
icon
|
|
5
|
+
skin="toolbar"
|
|
6
|
+
:active="isCurrentListSelected"
|
|
7
|
+
@click="toggle"
|
|
8
|
+
v-tooltip="'Bullets'"
|
|
9
|
+
>
|
|
10
|
+
<Icon :name="currentIcon" size="28px" auto-color />
|
|
11
|
+
</Button>
|
|
12
|
+
|
|
13
|
+
<Dropdown
|
|
14
|
+
:value="currentValue"
|
|
15
|
+
:options="$options.listTypes"
|
|
16
|
+
@change="apply"
|
|
17
|
+
>
|
|
18
|
+
<template #activator="{ open, isOpened }">
|
|
19
|
+
<Button
|
|
20
|
+
icon
|
|
21
|
+
skin="toolbar"
|
|
22
|
+
:active="isOpened"
|
|
23
|
+
@click="open"
|
|
24
|
+
v-tooltip="'Bullet Styles'"
|
|
25
|
+
>
|
|
26
|
+
<Icon
|
|
27
|
+
class="zw-list-control__activator"
|
|
28
|
+
name="arrow"
|
|
29
|
+
size="8px"
|
|
30
|
+
auto-color
|
|
31
|
+
/>
|
|
32
|
+
</Button>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<template #option="{ option }">
|
|
36
|
+
<DropdownOption
|
|
37
|
+
class="zw-list-control__option"
|
|
38
|
+
:option="option"
|
|
39
|
+
>
|
|
40
|
+
<Icon :name="option.icon" size="28px" auto-color />
|
|
41
|
+
</DropdownOption>
|
|
42
|
+
</template>
|
|
43
|
+
</Dropdown>
|
|
44
|
+
</div>
|
|
25
45
|
</template>
|
|
26
46
|
|
|
27
47
|
<script>
|
|
28
|
-
import { computed, inject } from 'vue';
|
|
48
|
+
import { computed, inject, ref } from 'vue';
|
|
29
49
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
30
50
|
import { Dropdown, DropdownOption, Button, Icon } from '../../base';
|
|
31
51
|
import { ListTypes } from '../../../enums';
|
|
@@ -55,26 +75,44 @@ export default {
|
|
|
55
75
|
const selectionValue = editor.commands.getListType();
|
|
56
76
|
const isList = computed(() => !!selectionValue.value);
|
|
57
77
|
const currentValue = computed(() => selectionValue.value || 'none');
|
|
78
|
+
const recentListType = ref(ListTypes.DISC);
|
|
79
|
+
const isCurrentListSelected = computed(() => selectionValue.value === recentListType.value);
|
|
58
80
|
|
|
59
|
-
const currentIcon = computed(() => {
|
|
60
|
-
const type = selectionValue.value || ListTypes.DISC;
|
|
81
|
+
const currentIcon = computed(() => `list-${recentListType.value}`);
|
|
61
82
|
|
|
62
|
-
|
|
63
|
-
|
|
83
|
+
const apply = (type) => {
|
|
84
|
+
recentListType.value = type;
|
|
85
|
+
editor.chain().focus().applyList(type).run();
|
|
86
|
+
};
|
|
64
87
|
|
|
65
|
-
const
|
|
88
|
+
const toggle = () => apply(recentListType.value || ListTypes.DISC);
|
|
66
89
|
|
|
67
90
|
return {
|
|
68
91
|
isList,
|
|
69
92
|
currentValue,
|
|
70
93
|
currentIcon,
|
|
71
|
-
|
|
94
|
+
isCurrentListSelected,
|
|
95
|
+
apply,
|
|
96
|
+
toggle
|
|
72
97
|
};
|
|
73
98
|
}
|
|
74
99
|
};
|
|
75
100
|
</script>
|
|
76
101
|
|
|
77
102
|
<style scoped>
|
|
103
|
+
.zpa-list-control {
|
|
104
|
+
display: flex;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.zpa-list-control:hover {
|
|
108
|
+
color: rgb(var(--zw-color-white));
|
|
109
|
+
background-color: rgb(var(--zw-color-n5));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.zw-list-control__activator {
|
|
113
|
+
padding: 0 var(--zw-offset-xs);
|
|
114
|
+
}
|
|
115
|
+
|
|
78
116
|
.zw-list-control__option {
|
|
79
117
|
padding: 0 var(--zw-offset-xs);
|
|
80
118
|
display: flex;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
|
-
import { h, ref } from 'vue';
|
|
2
|
+
import { h, ref, nextTick } from 'vue';
|
|
3
3
|
import { InjectionTokens } from '../../../../injectionTokens';
|
|
4
|
-
import { Dropdown, Icon } from '../../../base';
|
|
4
|
+
import { Button, Dropdown, Icon } from '../../../base';
|
|
5
5
|
import ListControl from '../ListControl';
|
|
6
6
|
import { ListTypes } from '../../../../enums';
|
|
7
7
|
|
|
@@ -62,10 +62,15 @@ describe('selection value', () => {
|
|
|
62
62
|
expect(iconWrapper.props('name')).toBe('list-disc');
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
test('should render type icon', () => {
|
|
65
|
+
test('should render type icon', async () => {
|
|
66
66
|
const editor = createEditor({ listType: ListTypes.DECIMAL });
|
|
67
67
|
const wrapper = createComponent({ editor });
|
|
68
68
|
const iconWrapper = wrapper.findComponent(Icon);
|
|
69
|
+
const dropdownWrapper = wrapper.findComponent(Dropdown);
|
|
70
|
+
|
|
71
|
+
dropdownWrapper.vm.$emit('change', ListTypes.DECIMAL);
|
|
72
|
+
|
|
73
|
+
await nextTick();
|
|
69
74
|
|
|
70
75
|
expect(iconWrapper.props('name')).toBe('list-decimal');
|
|
71
76
|
});
|
|
@@ -79,4 +84,14 @@ describe('selection value', () => {
|
|
|
79
84
|
|
|
80
85
|
expect(editor.commands.applyList).toHaveBeenCalledWith(ListTypes.LATIN);
|
|
81
86
|
});
|
|
87
|
+
|
|
88
|
+
test('should apply list with default type', () => {
|
|
89
|
+
const editor = createEditor();
|
|
90
|
+
const wrapper = createComponent({ editor });
|
|
91
|
+
const buttonWrapper = wrapper.findComponent(Button);
|
|
92
|
+
|
|
93
|
+
buttonWrapper.vm.$emit('click');
|
|
94
|
+
|
|
95
|
+
expect(editor.commands.applyList).toHaveBeenCalledWith(ListTypes.DISC);
|
|
96
|
+
});
|
|
82
97
|
});
|
package/lib/styles/content.css
CHANGED
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
pointer-events: none;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
.zw-superscript {
|
|
14
|
+
font-size: 75%;
|
|
15
|
+
line-height: 0;
|
|
16
|
+
position: relative;
|
|
17
|
+
vertical-align: initial;
|
|
18
|
+
top: -0.5em;
|
|
19
|
+
}
|
|
20
|
+
|
|
13
21
|
.zw-style.zw-style.zw-style {
|
|
14
22
|
font-weight: var(--zw-font-weight, var(--zw-preset-font-weight));
|
|
15
23
|
font-family: var(--zw-font-family, var(--zw-preset-font-family));
|