@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.
@@ -13,6 +13,7 @@ export default {
13
13
  <style scoped>
14
14
  .zw-toolbar__row {
15
15
  display: flex;
16
+ justify-content: space-between;
16
17
  column-gap: var(--zw-offset-xs);
17
18
  padding: var(--zw-offset-xxs) var(--zw-offset-xs);
18
19
  }
@@ -1,31 +1,51 @@
1
1
  <template>
2
- <Dropdown
3
- :value="currentValue"
4
- :options="$options.listTypes"
5
- @change="apply"
6
- >
7
- <template #activator="{ open, isOpened }">
8
- <Button
9
- icon
10
- skin="toolbar"
11
- :active="isOpened || isList"
12
- @click="open"
13
- v-tooltip="'Bullet Styles'"
14
- >
15
- <Icon :name="currentIcon" size="28px" auto-color />
16
- </Button>
17
- </template>
18
-
19
- <template #option="{ option }">
20
- <DropdownOption class="zw-list-control__option" :option="option">
21
- <Icon :name="option.icon" size="28px" auto-color />
22
- </DropdownOption>
23
- </template>
24
- </Dropdown>
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
- return `list-${type}`;
63
- });
83
+ const apply = (type) => {
84
+ recentListType.value = type;
85
+ editor.chain().focus().applyList(type).run();
86
+ };
64
87
 
65
- const apply = (type) => editor.chain().focus().applyList(type).run();
88
+ const toggle = () => apply(recentListType.value || ListTypes.DISC);
66
89
 
67
90
  return {
68
91
  isList,
69
92
  currentValue,
70
93
  currentIcon,
71
- apply
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
  });
@@ -1,5 +1,9 @@
1
1
  import Base from '@tiptap/extension-superscript';
2
2
 
3
3
  export const Superscript = Base.extend({
4
- addKeyboardShortcuts: null
4
+ addKeyboardShortcuts: null,
5
+
6
+ addOptions: () => ({
7
+ HTMLAttributes: { class: 'zw-superscript' }
8
+ })
5
9
  });
@@ -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));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipify/wysiwyg",
3
- "version": "1.0.0-dev.59",
3
+ "version": "1.0.0-dev.61",
4
4
  "description": "Zipify modification of TipTap text editor",
5
5
  "main": "dist/wysiwyg.mjs",
6
6
  "repository": {