@zipify/wysiwyg 1.0.0-dev.9 → 1.0.0-dev.90

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.
Files changed (232) hide show
  1. package/.editorconfig +1 -1
  2. package/.eslintrc.js +2 -2
  3. package/.github/dependabot.yaml +1 -0
  4. package/.lintstagedrc +2 -2
  5. package/.release-it.json +3 -1
  6. package/.stylelintrc +0 -4
  7. package/README.md +2 -2
  8. package/config/jest/setupTests.js +0 -3
  9. package/config/vite/example.config.js +25 -0
  10. package/config/vite/lib.config.js +30 -0
  11. package/config/{webpack → vite}/settings.js +0 -0
  12. package/dist/wysiwyg.css +404 -373
  13. package/dist/wysiwyg.mjs +26014 -0
  14. package/example/ExampleApp.vue +35 -4
  15. package/example/example.js +0 -3
  16. package/example/{example.html → index.html} +1 -0
  17. package/example/pageBlocks.js +31 -0
  18. package/example/presets.js +2 -2
  19. package/example/tooltip/Tooltip.js +1 -1
  20. package/jest.config.js +3 -1
  21. package/lib/Wysiwyg.vue +73 -14
  22. package/lib/__tests__/utils/index.js +0 -1
  23. package/lib/__tests__/utils/withComponentContext.js +1 -1
  24. package/lib/assets/icons/background-color.svg +3 -1
  25. package/lib/assets/icons/font-color.svg +1 -3
  26. package/lib/assets/icons/link.svg +3 -0
  27. package/lib/assets/icons/unlink.svg +3 -0
  28. package/lib/components/base/Button.vue +23 -2
  29. package/lib/components/base/Checkbox.vue +89 -0
  30. package/lib/components/base/FieldLabel.vue +2 -1
  31. package/lib/components/base/Icon.vue +3 -3
  32. package/lib/components/base/Modal.vue +1 -2
  33. package/lib/components/base/NumberField.vue +2 -2
  34. package/lib/components/base/Range.vue +1 -1
  35. package/lib/components/base/ScrollView.vue +1 -3
  36. package/lib/components/base/TextField.vue +108 -0
  37. package/lib/components/base/__tests__/Modal.test.js +7 -2
  38. package/lib/components/base/__tests__/TextField.test.js +57 -0
  39. package/lib/components/base/__tests__/__snapshots__/TextField.test.js.snap +9 -0
  40. package/lib/components/base/colorPicker/ColorPicker.vue +14 -12
  41. package/lib/components/base/colorPicker/composables/__tests__/usePickerApi.test.js +6 -6
  42. package/lib/components/base/colorPicker/composables/usePickerApi.js +15 -8
  43. package/lib/components/base/colorPicker/composables/usePickerHotkeys.js +3 -2
  44. package/lib/components/base/composables/__tests__/useActivatedListener.test.js +1 -1
  45. package/lib/components/base/composables/__tests__/useDeselectionLock.test.js +1 -1
  46. package/lib/components/base/composables/__tests__/useElementRef.test.js +1 -1
  47. package/lib/components/base/composables/__tests__/useModalToggler.test.js +1 -1
  48. package/lib/components/base/composables/__tests__/useNumberValue.test.js +1 -1
  49. package/lib/components/base/composables/__tests__/useScrollView.test.js +1 -1
  50. package/lib/components/base/composables/__tests__/useTempValue.test.js +1 -1
  51. package/lib/components/base/composables/__tests__/useValidator.test.js +44 -0
  52. package/lib/components/base/composables/index.js +1 -0
  53. package/lib/components/base/composables/useActivatedListener.js +1 -1
  54. package/lib/components/base/composables/useDeselectionLock.js +1 -1
  55. package/lib/components/base/composables/useElementRef.js +1 -1
  56. package/lib/components/base/composables/useModalToggler.js +6 -2
  57. package/lib/components/base/composables/useScrollView.js +1 -1
  58. package/lib/components/base/composables/useTempValue.js +1 -1
  59. package/lib/components/base/composables/useValidator.js +23 -0
  60. package/lib/components/base/dropdown/Dropdown.vue +16 -4
  61. package/lib/components/base/dropdown/DropdownActivator.vue +19 -3
  62. package/lib/components/base/dropdown/DropdownGroup.vue +1 -1
  63. package/lib/components/base/dropdown/DropdownMenu.vue +1 -1
  64. package/lib/components/base/dropdown/DropdownOption.vue +1 -1
  65. package/lib/components/base/dropdown/__tests__/DropdownActivator.test.js +1 -1
  66. package/lib/components/base/dropdown/__tests__/DropdownMenu.test.js +1 -1
  67. package/lib/components/base/dropdown/__tests__/DropdownOption.test.js +1 -1
  68. package/lib/components/base/dropdown/composables/__tests__/useActiveOptionManager.test.js +1 -1
  69. package/lib/components/base/dropdown/composables/__tests__/useDropdownEntityTitle.test.js +1 -1
  70. package/lib/components/base/dropdown/composables/useActiveOptionManager.js +1 -1
  71. package/lib/components/base/dropdown/composables/useDropdownEntityTitle.js +1 -1
  72. package/lib/components/base/index.js +3 -1
  73. package/lib/components/toolbar/Toolbar.vue +51 -9
  74. package/lib/components/toolbar/ToolbarDivider.vue +1 -1
  75. package/lib/components/toolbar/ToolbarFull.vue +41 -10
  76. package/lib/components/toolbar/ToolbarRow.vue +1 -0
  77. package/lib/components/toolbar/__tests__/Toolbar.test.js +6 -0
  78. package/lib/components/toolbar/controls/AlignmentControl.vue +1 -1
  79. package/lib/components/toolbar/controls/AlignmentDeviceControl.vue +1 -1
  80. package/lib/components/toolbar/controls/BackgroundColorControl.vue +1 -1
  81. package/lib/components/toolbar/controls/CaseStyleControl.vue +1 -1
  82. package/lib/components/toolbar/controls/FontColorControl.vue +1 -1
  83. package/lib/components/toolbar/controls/FontFamilyControl.vue +1 -1
  84. package/lib/components/toolbar/controls/FontSizeControl.vue +8 -1
  85. package/lib/components/toolbar/controls/FontWeightControl.vue +1 -1
  86. package/lib/components/toolbar/controls/ItalicControl.vue +1 -1
  87. package/lib/components/toolbar/controls/LineHeightControl.vue +1 -1
  88. package/lib/components/toolbar/controls/ListControl.vue +68 -34
  89. package/lib/components/toolbar/controls/RemoveFormatControl.vue +1 -1
  90. package/lib/components/toolbar/controls/StrikeThroughControl.vue +1 -1
  91. package/lib/components/toolbar/controls/StylePresetControl.vue +15 -2
  92. package/lib/components/toolbar/controls/SuperscriptControl.vue +1 -1
  93. package/lib/components/toolbar/controls/UnderlineControl.vue +2 -2
  94. package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +1 -1
  95. package/lib/components/toolbar/controls/__tests__/AlignmentDeviceControl.test.js +1 -1
  96. package/lib/components/toolbar/controls/__tests__/BackgroundColorControl.test.js +1 -1
  97. package/lib/components/toolbar/controls/__tests__/CaseStyleControl.test.js +1 -1
  98. package/lib/components/toolbar/controls/__tests__/FontColorControl.test.js +1 -1
  99. package/lib/components/toolbar/controls/__tests__/FontFamilyControl.test.js +1 -1
  100. package/lib/components/toolbar/controls/__tests__/FontSizeControl.test.js +1 -1
  101. package/lib/components/toolbar/controls/__tests__/FontWeightControl.test.js +1 -1
  102. package/lib/components/toolbar/controls/__tests__/ItalicControl.test.js +1 -1
  103. package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +1 -1
  104. package/lib/components/toolbar/controls/__tests__/ListControl.test.js +18 -3
  105. package/lib/components/toolbar/controls/__tests__/StrikeThroughControl.test.js +1 -1
  106. package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +17 -1
  107. package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +5 -1
  108. package/lib/components/toolbar/controls/composables/useRecentFonts.js +1 -1
  109. package/lib/components/toolbar/controls/index.js +1 -0
  110. package/lib/components/toolbar/controls/link/LinkControl.vue +160 -0
  111. package/lib/components/toolbar/controls/link/LinkControlApply.vue +35 -0
  112. package/lib/components/toolbar/controls/link/LinkControlHeader.vue +69 -0
  113. package/lib/components/toolbar/controls/link/__tests__/LinkControl.test.js +79 -0
  114. package/lib/components/toolbar/controls/link/__tests__/LinkControlHeader.test.js +42 -0
  115. package/lib/components/toolbar/controls/link/composables/__tests__/__snapshots__/useLink.test.js.snap +15 -0
  116. package/lib/components/toolbar/controls/link/composables/__tests__/useLink.test.js +172 -0
  117. package/lib/components/toolbar/controls/link/composables/index.js +1 -0
  118. package/lib/components/toolbar/controls/link/composables/useLink.js +82 -0
  119. package/lib/components/toolbar/controls/link/destination/LinkControlDestination.vue +103 -0
  120. package/lib/components/toolbar/controls/link/destination/LinkControlPageBlock.vue +54 -0
  121. package/lib/components/toolbar/controls/link/destination/LinkControlUrl.vue +52 -0
  122. package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlPageBlock.test.js +36 -0
  123. package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlUrl.test.js +46 -0
  124. package/lib/components/toolbar/controls/link/destination/__tests__/__snapshots__/LinkControlPageBlock.test.js.snap +9 -0
  125. package/lib/components/toolbar/controls/link/destination/__tests__/__snapshots__/LinkControlUrl.test.js.snap +17 -0
  126. package/lib/components/toolbar/controls/link/destination/index.js +1 -0
  127. package/lib/components/toolbar/controls/link/index.js +1 -0
  128. package/lib/composables/__tests__/__snapshots__/useEditor.test.js.snap +1 -0
  129. package/lib/composables/__tests__/useEditor.test.js +5 -4
  130. package/lib/composables/useEditor.js +12 -9
  131. package/lib/composables/useToolbar.js +26 -19
  132. package/lib/directives/__tests__/outClick.test.js +6 -0
  133. package/lib/directives/outClick.js +19 -6
  134. package/lib/enums/Alignments.js +10 -1
  135. package/lib/enums/LinkDestinations.js +4 -0
  136. package/lib/enums/LinkTargets.js +4 -0
  137. package/lib/enums/TextSettings.js +3 -1
  138. package/lib/enums/index.js +2 -0
  139. package/lib/extensions/Alignment.js +22 -8
  140. package/lib/extensions/BackgroundColor.js +15 -7
  141. package/lib/extensions/DeviceManager.js +2 -5
  142. package/lib/extensions/FontColor.js +15 -7
  143. package/lib/extensions/FontFamily.js +26 -9
  144. package/lib/extensions/FontSize.js +33 -13
  145. package/lib/extensions/FontStyle.js +24 -14
  146. package/lib/extensions/FontWeight.js +25 -15
  147. package/lib/extensions/LineHeight.js +33 -29
  148. package/lib/extensions/Link.js +90 -0
  149. package/lib/extensions/StylePreset.js +20 -19
  150. package/lib/extensions/Superscript.js +5 -1
  151. package/lib/extensions/TextDecoration.js +46 -13
  152. package/lib/extensions/__tests__/Alignment.test.js +14 -9
  153. package/lib/extensions/__tests__/BackgroundColor.test.js +13 -8
  154. package/lib/extensions/__tests__/CaseStyle.test.js +4 -7
  155. package/lib/extensions/__tests__/FontColor.test.js +13 -8
  156. package/lib/extensions/__tests__/FontFamily.test.js +34 -10
  157. package/lib/extensions/__tests__/FontSize.test.js +16 -10
  158. package/lib/extensions/__tests__/FontStyle.test.js +13 -8
  159. package/lib/extensions/__tests__/FontWeight.test.js +21 -8
  160. package/lib/extensions/__tests__/LineHeight.test.js +25 -14
  161. package/lib/extensions/__tests__/Link.test.js +101 -0
  162. package/lib/extensions/__tests__/StylePreset.test.js +72 -10
  163. package/lib/extensions/__tests__/TextDecoration.test.js +53 -8
  164. package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +26 -2
  165. package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +30 -1
  166. package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +18 -1
  167. package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +88 -1
  168. package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +33 -2
  169. package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +25 -4
  170. package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +47 -1
  171. package/lib/extensions/__tests__/__snapshots__/LineHeight.test.js.snap +26 -2
  172. package/lib/extensions/__tests__/__snapshots__/Link.test.js.snap +225 -0
  173. package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +6 -2
  174. package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +183 -3
  175. package/lib/extensions/core/CopyPasteProcessor.js +10 -0
  176. package/lib/extensions/core/NodeProcessor.js +1 -1
  177. package/lib/extensions/core/TextProcessor.js +11 -24
  178. package/lib/extensions/core/__tests__/NodeProcessor.test.js +4 -7
  179. package/lib/extensions/core/__tests__/SelectionProcessor.test.js +4 -7
  180. package/lib/extensions/core/__tests__/TextProcessor.test.js +139 -14
  181. package/lib/extensions/core/__tests__/__snapshots__/TextProcessor.test.js.snap +26 -0
  182. package/lib/extensions/core/index.js +11 -2
  183. package/lib/extensions/core/plugins/PastePlugin.js +57 -0
  184. package/lib/extensions/core/plugins/ProseMirrorPlugin.js +20 -0
  185. package/lib/extensions/core/plugins/index.js +1 -0
  186. package/lib/extensions/index.js +46 -34
  187. package/lib/extensions/list/List.js +5 -4
  188. package/lib/extensions/list/__tests__/List.test.js +6 -10
  189. package/lib/extensions/list/__tests__/__snapshots__/List.test.js.snap +60 -20
  190. package/lib/index.js +3 -0
  191. package/lib/injectionTokens.js +3 -1
  192. package/lib/services/ContentNormalizer.js +144 -28
  193. package/lib/services/ContextWidnow.js +23 -0
  194. package/lib/{__tests__/utils → services}/NodeFactory.js +5 -1
  195. package/lib/services/__tests__/ContentNormalizer.test.js +124 -8
  196. package/lib/services/__tests__/FavoriteColors.test.js +1 -1
  197. package/lib/services/index.js +2 -0
  198. package/lib/styles/content.css +108 -13
  199. package/lib/styles/helpers/offsets.css +16 -0
  200. package/lib/styles/variables.css +6 -0
  201. package/lib/utils/__tests__/__snapshots__/renderInlineSetting.test.js.snap +4 -4
  202. package/lib/utils/__tests__/convertAlignment.test.js +16 -0
  203. package/lib/utils/__tests__/convertFontSize.test.js +21 -0
  204. package/lib/utils/__tests__/convertLineHeight.test.js +21 -0
  205. package/lib/utils/convertAlignment.js +12 -0
  206. package/lib/utils/convertColor.js +1 -1
  207. package/lib/utils/convertFontSize.js +8 -0
  208. package/lib/utils/convertLineHeight.js +17 -0
  209. package/lib/utils/importIcon.js +7 -6
  210. package/lib/utils/index.js +4 -0
  211. package/lib/utils/isWysiwygContent.js +12 -0
  212. package/lib/utils/renderInlineSetting.js +1 -1
  213. package/package.json +26 -30
  214. package/config/webpack/example.config.js +0 -88
  215. package/config/webpack/lib.config.js +0 -44
  216. package/config/webpack/loaders/index.js +0 -6
  217. package/config/webpack/loaders/js-loader.js +0 -5
  218. package/config/webpack/loaders/style-loader.js +0 -9
  219. package/config/webpack/loaders/svg-loader.js +0 -4
  220. package/config/webpack/loaders/vue-loader.js +0 -4
  221. package/dist/wysiwyg.js +0 -2
  222. package/dist/wysiwyg.js.LICENSE.txt +0 -1
  223. package/lib/extensions/core/inputRules/closeDoubleQuote.js +0 -6
  224. package/lib/extensions/core/inputRules/closeSingleQuote.js +0 -6
  225. package/lib/extensions/core/inputRules/copyright.js +0 -6
  226. package/lib/extensions/core/inputRules/ellipsis.js +0 -6
  227. package/lib/extensions/core/inputRules/emDash.js +0 -6
  228. package/lib/extensions/core/inputRules/index.js +0 -9
  229. package/lib/extensions/core/inputRules/openDoubleQuote.js +0 -6
  230. package/lib/extensions/core/inputRules/openSingleQuote.js +0 -6
  231. package/lib/extensions/core/inputRules/registeredTrademark.js +0 -6
  232. package/lib/extensions/core/inputRules/trademark.js +0 -6
@@ -24,7 +24,7 @@
24
24
  </template>
25
25
 
26
26
  <script>
27
- import { provide } from '@vue/composition-api';
27
+ import { provide } from 'vue';
28
28
  import ScrollView from '../ScrollView';
29
29
  import { InjectionTokens } from './injectionTokens';
30
30
  import DropdownGroup from './DropdownGroup';
@@ -10,7 +10,7 @@
10
10
  </template>
11
11
 
12
12
  <script>
13
- import { computed, inject, nextTick, onMounted, ref, toRef } from '@vue/composition-api';
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';
@@ -1,5 +1,5 @@
1
1
  import { shallowMount } from '@vue/test-utils';
2
- import { ref } from '@vue/composition-api';
2
+ import { ref } from 'vue';
3
3
  import DropdownActivator from '../DropdownActivator';
4
4
  import { InjectionTokens } from '../injectionTokens';
5
5
  import Button from '../../Button';
@@ -1,5 +1,5 @@
1
1
  import { shallowMount } from '@vue/test-utils';
2
- import { ref } from '@vue/composition-api';
2
+ import { ref } from 'vue';
3
3
  import { InjectionTokens } from '../injectionTokens';
4
4
  import DropdownMenu from '../DropdownMenu';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { shallowMount } from '@vue/test-utils';
2
- import { ref } from '@vue/composition-api';
2
+ import { ref } from 'vue';
3
3
  import DropdownOption from '../DropdownOption';
4
4
  import { InjectionTokens } from '../injectionTokens';
5
5
  import Button from '../../Button';
@@ -1,4 +1,4 @@
1
- import { nextTick, ref } from '@vue/composition-api';
1
+ import { nextTick, ref } from 'vue';
2
2
  import { useActiveOptionManager } from '../useActiveOptionManager';
3
3
 
4
4
  describe('manage active option', () => {
@@ -1,4 +1,4 @@
1
- import { ref } from '@vue/composition-api';
1
+ import { ref } from 'vue';
2
2
  import { useDropdownEntityTitle } from '../useDropdownEntityTitle';
3
3
 
4
4
  describe('resolve title', () => {
@@ -1,4 +1,4 @@
1
- import { ref, watch } from '@vue/composition-api';
1
+ import { ref, watch } from 'vue';
2
2
 
3
3
  export function useActiveOptionManager({ optionsRef, inputRef, stateless, onChange }) {
4
4
  const activeOption = ref(null);
@@ -1,4 +1,4 @@
1
- import { computed } from '@vue/composition-api';
1
+ import { computed } from 'vue';
2
2
 
3
3
  export function useDropdownEntityTitle(entityRef) {
4
4
  return computed(() => entityRef.value?.title || entityRef.value?.id || '');
@@ -6,6 +6,8 @@ export { default as FieldLabel } from './FieldLabel';
6
6
  export { default as Range } from './Range';
7
7
  export { default as NumberField } from './NumberField';
8
8
  export { default as Modal } from './Modal';
9
- export { useModalToggler } from './composables';
9
+ export { default as TextField } from './TextField';
10
+ export { default as Checkbox } from './Checkbox';
11
+ export { useModalToggler, useElementRef } from './composables';
10
12
  export * from './dropdown';
11
13
  export * from './colorPicker';
@@ -1,13 +1,15 @@
1
1
  <template>
2
- <Transition name="zw-toolbar-" :duration="800">
3
- <div class="zw-toolbar">
4
- <component :is="toolbarComponent" />
5
- </div>
6
- </Transition>
2
+ <keep-alive>
3
+ <transition name="zw-toolbar-" duration="150">
4
+ <div class="zw-toolbar" :style="toolbarStyles" ref="toolbarRef" v-if="isVisible">
5
+ <component :is="toolbarComponent" />
6
+ </div>
7
+ </transition>
8
+ </keep-alive>
7
9
  </template>
8
10
 
9
11
  <script>
10
- import { computed } from '@vue/composition-api';
12
+ import { computed, ref, watch } from 'vue';
11
13
  import { Devices } from '../../enums';
12
14
  import ToolbarFull from './ToolbarFull';
13
15
  import ToolbarDevice from './ToolbarDevice';
@@ -19,6 +21,11 @@ export default {
19
21
  device: {
20
22
  type: String,
21
23
  required: true
24
+ },
25
+
26
+ toolbar: {
27
+ type: Object,
28
+ required: true
22
29
  }
23
30
  },
24
31
 
@@ -26,8 +33,23 @@ export default {
26
33
  const toolbarComponent = computed(() => {
27
34
  return props.device === Devices.DESKTOP ? ToolbarFull : ToolbarDevice;
28
35
  });
36
+ const isVisible = computed(() => props.toolbar.isActiveRef.value);
37
+ const toolbarRef = ref(null);
38
+
39
+ watch(toolbarRef, (toolbarEl) => {
40
+ toolbarEl && props.toolbar.mount(toolbarEl);
41
+ });
42
+
43
+ const toolbarStyles = computed(() => ({
44
+ '--zw-toolbar-offset-y': `${props.toolbar.offsets[1]}px`
45
+ }));
29
46
 
30
- return { toolbarComponent };
47
+ return {
48
+ toolbarComponent,
49
+ isVisible,
50
+ toolbarRef,
51
+ toolbarStyles
52
+ };
31
53
  }
32
54
  };
33
55
  </script>
@@ -37,12 +59,32 @@ export default {
37
59
  border-radius: 2px;
38
60
  background-color: rgb(var(--zw-color-n15));
39
61
  color: rgb(var(--zw-color-n70));
40
- z-index: 999;
62
+ z-index: 999999;
63
+ text-align: left;
64
+ position: absolute;
65
+ }
66
+
67
+ .zw-toolbar::before,
68
+ .zw-toolbar::after {
69
+ content: "";
70
+ display: block;
71
+ width: 100%;
72
+ height: calc(var(--zw-toolbar-offset-y) + 4px);
73
+ position: absolute;
74
+ --zw-toolbar-safe-zone: calc(-1 * var(--zw-toolbar-offset-y));
75
+ }
76
+
77
+ .zw-toolbar::before {
78
+ top: var(--zw-toolbar-safe-zone);
79
+ }
80
+
81
+ .zw-toolbar::after {
82
+ bottom: var(--zw-toolbar-safe-zone);
41
83
  }
42
84
 
43
85
  .zw-toolbar--enter-active,
44
86
  .zw-toolbar--leave-active {
45
- transition: opacity 0.15s ease-out;
87
+ transition: opacity 150ms ease-out;
46
88
  }
47
89
 
48
90
  .zw-toolbar--leave-active {
@@ -3,7 +3,7 @@
3
3
  </template>
4
4
 
5
5
  <script>
6
- import { computed } from '@vue/composition-api';
6
+ import { computed } from 'vue';
7
7
 
8
8
  export default {
9
9
  name: 'ToolbarDivider',
@@ -14,31 +14,52 @@
14
14
  <FontColorControl />
15
15
  <BackgroundColorControl />
16
16
  </ToolbarGroup>
17
+
18
+ <template v-if="isPopupMode">
19
+ <ToolbarDivider vertical />
20
+
21
+ <ToolbarGroup>
22
+ <ItalicControl />
23
+ <UnderlineControl />
24
+ <StrikeThroughControl />
25
+ <SuperscriptControl />
26
+ <CaseStyleControl />
27
+ </ToolbarGroup>
28
+ </template>
17
29
  </ToolbarRow>
18
30
 
19
31
  <ToolbarDivider horizontal />
20
32
 
21
33
  <ToolbarRow>
22
- <ToolbarGroup>
23
- <ItalicControl />
24
- <UnderlineControl />
25
- <StrikeThroughControl />
26
- <SuperscriptControl />
27
- <CaseStyleControl />
28
- </ToolbarGroup>
34
+ <template v-if="!isPopupMode">
35
+ <ToolbarGroup>
36
+ <ItalicControl />
37
+ <UnderlineControl />
38
+ <StrikeThroughControl />
39
+ <SuperscriptControl />
40
+ <CaseStyleControl />
41
+ </ToolbarGroup>
42
+
43
+ <ToolbarDivider vertical />
44
+ </template>
29
45
 
30
- <ToolbarDivider vertical />
31
46
  <AlignmentControl />
32
47
  <ToolbarDivider vertical />
33
48
 
34
49
  <ToolbarGroup>
35
50
  <LineHeightControl />
51
+ </ToolbarGroup>
52
+
53
+ <ToolbarDivider vertical />
54
+
55
+ <ToolbarGroup>
36
56
  <ListControl />
37
57
  </ToolbarGroup>
38
58
 
39
59
  <ToolbarDivider vertical />
40
60
 
41
61
  <ToolbarGroup>
62
+ <LinkControl />
42
63
  <RemoveFormatControl />
43
64
  </ToolbarGroup>
44
65
  </ToolbarRow>
@@ -46,6 +67,8 @@
46
67
  </template>
47
68
 
48
69
  <script>
70
+ import { inject } from 'vue';
71
+ import { InjectionTokens } from '../../injectionTokens';
49
72
  import ToolbarDivider from './ToolbarDivider';
50
73
  import ToolbarRow from './ToolbarRow';
51
74
  import ToolbarGroup from './ToolbarGroup';
@@ -64,7 +87,8 @@ import {
64
87
  SuperscriptControl,
65
88
  UnderlineControl,
66
89
  ListControl,
67
- RemoveFormatControl
90
+ RemoveFormatControl,
91
+ LinkControl
68
92
  } from './controls';
69
93
 
70
94
  export default {
@@ -88,7 +112,14 @@ export default {
88
112
  AlignmentControl,
89
113
  LineHeightControl,
90
114
  ListControl,
91
- RemoveFormatControl
115
+ RemoveFormatControl,
116
+ LinkControl
117
+ },
118
+
119
+ setup() {
120
+ const isPopupMode = inject(InjectionTokens.POPUP_MODE);
121
+
122
+ return { isPopupMode };
92
123
  }
93
124
  };
94
125
  </script>
@@ -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,4 +1,5 @@
1
1
  import { shallowMount } from '@vue/test-utils';
2
+ import { ref } from 'vue';
2
3
  import { Devices } from '../../../enums';
3
4
  import Toolbar from '../Toolbar';
4
5
  import ToolbarFull from '../ToolbarFull';
@@ -7,6 +8,11 @@ import ToolbarDevice from '../ToolbarDevice';
7
8
  function createComponent({ device }) {
8
9
  return shallowMount(Toolbar, {
9
10
  propsData: {
11
+ toolbar: {
12
+ mount: jest.fn(),
13
+ isActiveRef: ref({ value: true }),
14
+ offsets: [0, 8]
15
+ },
10
16
  device: device ?? Devices.DESKTOP
11
17
  }
12
18
  });
@@ -15,7 +15,7 @@
15
15
  </template>
16
16
 
17
17
  <script>
18
- import { inject } from '@vue/composition-api';
18
+ import { inject } from 'vue';
19
19
  import { InjectionTokens } from '../../../injectionTokens';
20
20
  import { Alignments } from '../../../enums';
21
21
  import { ButtonToggle, Button, Icon } from '../../base';
@@ -17,7 +17,7 @@
17
17
  </template>
18
18
 
19
19
  <script>
20
- import { inject, ref } from '@vue/composition-api';
20
+ import { inject, ref } from 'vue';
21
21
  import { InjectionTokens } from '../../../injectionTokens';
22
22
  import { Button, Icon, Modal, useModalToggler } from '../../base';
23
23
  import { tooltip } from '../../../directives';
@@ -15,7 +15,7 @@
15
15
  </template>
16
16
 
17
17
  <script>
18
- import { inject } from '@vue/composition-api';
18
+ import { inject } from 'vue';
19
19
  import { ColorPicker, Button, Icon } from '../../base';
20
20
  import { InjectionTokens } from '../../../injectionTokens';
21
21
  import { tooltip } from '../../../directives';
@@ -18,7 +18,7 @@
18
18
  </template>
19
19
 
20
20
  <script>
21
- import { inject } from '@vue/composition-api';
21
+ import { inject } from 'vue';
22
22
  import { CaseStyles } from '../../../enums';
23
23
  import { Dropdown, Button, Icon } from '../../base';
24
24
  import { InjectionTokens } from '../../../injectionTokens';
@@ -15,7 +15,7 @@
15
15
  </template>
16
16
 
17
17
  <script>
18
- import { inject } from '@vue/composition-api';
18
+ import { inject } from 'vue';
19
19
  import { ColorPicker, Button, Icon } from '../../base';
20
20
  import { InjectionTokens } from '../../../injectionTokens';
21
21
  import { tooltip } from '../../../directives';
@@ -18,7 +18,7 @@
18
18
  </template>
19
19
 
20
20
  <script>
21
- import { computed, inject } from '@vue/composition-api';
21
+ import { computed, inject } from 'vue';
22
22
  import { InjectionTokens } from '../../../injectionTokens';
23
23
  import { tooltip } from '../../../directives';
24
24
  import { Dropdown, DropdownOption } from '../../base';
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <Dropdown
3
+ class="zw-font-size-control"
3
4
  :options="options"
4
5
  :value="currentValue"
5
6
  @change="apply"
@@ -8,7 +9,7 @@
8
9
  </template>
9
10
 
10
11
  <script>
11
- import { computed, inject } from '@vue/composition-api';
12
+ import { computed, inject } from 'vue';
12
13
  import { Dropdown } from '../../base';
13
14
  import { InjectionTokens } from '../../../injectionTokens';
14
15
  import { tooltip } from '../../../directives';
@@ -43,3 +44,9 @@ export default {
43
44
  }
44
45
  };
45
46
  </script>
47
+
48
+ <style scoped>
49
+ .zw-font-size-control {
50
+ width: 64px;
51
+ }
52
+ </style>
@@ -8,7 +8,7 @@
8
8
  </template>
9
9
 
10
10
  <script>
11
- import { computed, inject } from '@vue/composition-api';
11
+ import { computed, inject } from 'vue';
12
12
  import { InjectionTokens } from '../../../injectionTokens';
13
13
  import { Dropdown } from '../../base';
14
14
  import { tooltip } from '../../../directives';
@@ -12,7 +12,7 @@
12
12
  </template>
13
13
 
14
14
  <script>
15
- import { inject } from '@vue/composition-api';
15
+ import { inject } from 'vue';
16
16
  import { Button, Icon } from '../../base';
17
17
  import { InjectionTokens } from '../../../injectionTokens';
18
18
  import { tooltip } from '../../../directives';
@@ -40,7 +40,7 @@
40
40
  </template>
41
41
 
42
42
  <script>
43
- import { inject, ref } from '@vue/composition-api';
43
+ import { inject, ref } from 'vue';
44
44
  import { Button, Icon, Modal, Range, NumberField, FieldLabel, useModalToggler } from '../../base';
45
45
  import { InjectionTokens } from '../../../injectionTokens';
46
46
  import { tooltip } from '../../../directives';
@@ -1,35 +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
21
- class="zw-list-control__option"
22
- :option="option"
23
- v-tooltip="option.tooltip"
24
- >
25
- <Icon :name="option.icon" size="28px" auto-color />
26
- </DropdownOption>
27
- </template>
28
- </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>
29
45
  </template>
30
46
 
31
47
  <script>
32
- import { computed, inject } from '@vue/composition-api';
48
+ import { computed, inject, ref } from 'vue';
33
49
  import { InjectionTokens } from '../../../injectionTokens';
34
50
  import { Dropdown, DropdownOption, Button, Icon } from '../../base';
35
51
  import { ListTypes } from '../../../enums';
@@ -59,26 +75,44 @@ export default {
59
75
  const selectionValue = editor.commands.getListType();
60
76
  const isList = computed(() => !!selectionValue.value);
61
77
  const currentValue = computed(() => selectionValue.value || 'none');
78
+ const recentListType = ref(ListTypes.DISC);
79
+ const isCurrentListSelected = computed(() => selectionValue.value === recentListType.value);
62
80
 
63
- const currentIcon = computed(() => {
64
- const type = selectionValue.value || ListTypes.DISC;
81
+ const currentIcon = computed(() => `list-${recentListType.value}`);
65
82
 
66
- return `list-${type}`;
67
- });
83
+ const apply = (type) => {
84
+ recentListType.value = type;
85
+ editor.chain().focus().applyList(type).run();
86
+ };
68
87
 
69
- const apply = (type) => editor.chain().focus().applyList(type).run();
88
+ const toggle = () => apply(recentListType.value || ListTypes.DISC);
70
89
 
71
90
  return {
72
91
  isList,
73
92
  currentValue,
74
93
  currentIcon,
75
- apply
94
+ isCurrentListSelected,
95
+ apply,
96
+ toggle
76
97
  };
77
98
  }
78
99
  };
79
100
  </script>
80
101
 
81
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
+
82
116
  .zw-list-control__option {
83
117
  padding: 0 var(--zw-offset-xs);
84
118
  display: flex;
@@ -10,7 +10,7 @@
10
10
  </template>
11
11
 
12
12
  <script>
13
- import { inject } from '@vue/composition-api';
13
+ import { inject } from 'vue';
14
14
  import { Button, Icon } from '../../base';
15
15
  import { InjectionTokens } from '../../../injectionTokens';
16
16
  import { tooltip } from '../../../directives';
@@ -11,7 +11,7 @@
11
11
  </template>
12
12
 
13
13
  <script>
14
- import { inject } from '@vue/composition-api';
14
+ import { inject } from 'vue';
15
15
  import { Button, Icon } from '../../base';
16
16
  import { InjectionTokens } from '../../../injectionTokens';
17
17
  import { tooltip } from '../../../directives';
@@ -21,10 +21,13 @@
21
21
  </template>
22
22
 
23
23
  <script>
24
- import { computed, inject } from '@vue/composition-api';
24
+ import { computed, inject } from 'vue';
25
25
  import { InjectionTokens } from '../../../injectionTokens';
26
26
  import { Dropdown, Button, Icon } from '../../base';
27
27
  import { tooltip } from '../../../directives';
28
+ import { TextSettings } from '../../../enums';
29
+
30
+ const CLEAR_MARKS = [TextSettings.FONT_SIZE, TextSettings.FONT_WEIGHT];
28
31
 
29
32
  export default {
30
33
  name: 'StylePresetControl',
@@ -59,7 +62,17 @@ export default {
59
62
  }));
60
63
  });
61
64
 
62
- const apply = (value) => editor.chain().focus().applyPreset(value).run();
65
+ const apply = (value) => {
66
+ editor.chain()
67
+ .focus()
68
+ .applyPreset(value)
69
+ .storeSelection()
70
+ .expandSelectionToBlock()
71
+ .unsetMarks(CLEAR_MARKS)
72
+ .restoreSelection()
73
+ .run();
74
+ };
75
+
63
76
  const removeCustomization = () => editor.chain().focus().removePresetCustomization().run();
64
77
 
65
78
  return {
@@ -11,7 +11,7 @@
11
11
  </template>
12
12
 
13
13
  <script>
14
- import { computed, inject } from '@vue/composition-api';
14
+ import { computed, inject } from 'vue';
15
15
  import { Button, Icon } from '../../base';
16
16
  import { InjectionTokens } from '../../../injectionTokens';
17
17
  import { tooltip } from '../../../directives';
@@ -11,7 +11,7 @@
11
11
  </template>
12
12
 
13
13
  <script>
14
- import { inject } from '@vue/composition-api';
14
+ import { inject, computed } from 'vue';
15
15
  import { Button, Icon } from '../../base';
16
16
  import { InjectionTokens } from '../../../injectionTokens';
17
17
  import { tooltip } from '../../../directives';
@@ -31,7 +31,7 @@ export default {
31
31
  setup() {
32
32
  const editor = inject(InjectionTokens.EDITOR);
33
33
 
34
- const currentValue = editor.commands.isUnderline();
34
+ const currentValue = computed(() => editor.commands.isUnderline().value);
35
35
  const apply = () => editor.chain().focus().toggleUnderline().run();
36
36
 
37
37
  return {
@@ -1,5 +1,5 @@
1
1
  import { shallowMount } from '@vue/test-utils';
2
- import { h, ref } from '@vue/composition-api';
2
+ import { h, ref } from 'vue';
3
3
  import { InjectionTokens } from '../../../../injectionTokens';
4
4
  import { Alignments } from '../../../../enums';
5
5
  import { ButtonToggle } from '../../../base';