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

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 +26015 -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 +2 -2
  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 +70 -36
  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 +17 -4
  92. package/lib/components/toolbar/controls/SuperscriptControl.vue +1 -1
  93. package/lib/components/toolbar/controls/UnderlineControl.vue +1 -1
  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 +25 -11
  140. package/lib/extensions/BackgroundColor.js +15 -7
  141. package/lib/extensions/DeviceManager.js +2 -5
  142. package/lib/extensions/FontColor.js +17 -9
  143. package/lib/extensions/FontFamily.js +30 -13
  144. package/lib/extensions/FontSize.js +38 -18
  145. package/lib/extensions/FontStyle.js +30 -20
  146. package/lib/extensions/FontWeight.js +34 -23
  147. package/lib/extensions/LineHeight.js +36 -32
  148. package/lib/extensions/Link.js +92 -0
  149. package/lib/extensions/StylePreset.js +23 -22
  150. package/lib/extensions/Superscript.js +5 -1
  151. package/lib/extensions/TextDecoration.js +52 -19
  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 +2 -2
  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 +7 -6
  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
@@ -1,33 +1,40 @@
1
1
  import { createPopper } from '@popperjs/core';
2
- import { onUnmounted, onMounted, watch } from '@vue/composition-api';
3
- import { useElementRef } from '../components/base/composables';
2
+ import { useElementRef } from '../components/base';
4
3
 
5
- export function useToolbar({ wrapperRef, popperRef, offsets, isActiveRef }) {
6
- let toolbar;
4
+ export function useToolbar({ wrapperRef, offsets, isActiveRef, placementRef }) {
5
+ const wrapperEl = useElementRef(wrapperRef);
6
+ let popper;
7
7
 
8
- onMounted(() => {
9
- const wrapperEl = useElementRef(wrapperRef).value;
10
- const toolbarEl = useElementRef(popperRef).value;
11
-
12
- toolbar = createPopper(wrapperEl, toolbarEl, {
13
- placement: 'top-start',
8
+ function mount(element) {
9
+ popper = createPopper(wrapperEl.value, element, {
10
+ placement: placementRef.value,
11
+ strategy: 'fixed',
14
12
  modifiers: [
15
13
  {
16
14
  name: 'offset',
15
+ options: { offset: offsets }
16
+ },
17
+ {
18
+ name: 'preventOverflow',
17
19
  options: {
18
- offset: offsets
20
+ altAxis: true,
21
+ padding: 2
19
22
  }
23
+ },
24
+ {
25
+ name: 'flip',
26
+ enabled: false
20
27
  }
21
28
  ]
22
29
  });
23
- });
24
- const update = () => toolbar.update();
25
-
26
- watch(isActiveRef, () => {
27
- if (isActiveRef.value) update();
28
- });
30
+ }
29
31
 
30
- onUnmounted(() => toolbar.destroy());
32
+ const update = () => popper?.update();
31
33
 
32
- return { toolbar, update };
34
+ return {
35
+ update,
36
+ mount,
37
+ isActiveRef,
38
+ offsets
39
+ };
33
40
  }
@@ -10,6 +10,7 @@ describe('out click', () => {
10
10
  await waitAsyncOperation();
11
11
 
12
12
  document.dispatchEvent(new Event('click'));
13
+ await waitAsyncOperation();
13
14
 
14
15
  expect(onOutClick).toHaveBeenCalled();
15
16
  });
@@ -22,6 +23,7 @@ describe('out click', () => {
22
23
  await waitAsyncOperation();
23
24
 
24
25
  el.dispatchEvent(new Event('click'));
26
+ await waitAsyncOperation();
25
27
 
26
28
  expect(onOutClick).not.toHaveBeenCalled();
27
29
  });
@@ -36,6 +38,7 @@ describe('out click', () => {
36
38
  await waitAsyncOperation();
37
39
 
38
40
  child.dispatchEvent(new Event('click'));
41
+ await waitAsyncOperation();
39
42
 
40
43
  expect(onOutClick).not.toHaveBeenCalled();
41
44
  });
@@ -50,6 +53,7 @@ describe('out click', () => {
50
53
  outClick.unbind(el);
51
54
 
52
55
  document.dispatchEvent(new Event('click'));
56
+ await waitAsyncOperation();
53
57
 
54
58
  expect(onOutClick).not.toHaveBeenCalled();
55
59
  });
@@ -65,6 +69,7 @@ describe('out click', () => {
65
69
  await waitAsyncOperation();
66
70
 
67
71
  document.dispatchEvent(new Event('click'));
72
+ await waitAsyncOperation();
68
73
 
69
74
  expect(onOutClick).toHaveBeenCalled();
70
75
  });
@@ -80,6 +85,7 @@ describe('out click', () => {
80
85
  await waitAsyncOperation();
81
86
 
82
87
  document.dispatchEvent(new Event('click'));
88
+ await waitAsyncOperation();
83
89
 
84
90
  expect(onOutClick).not.toHaveBeenCalled();
85
91
  });
@@ -1,5 +1,18 @@
1
+ import { ContextWindow } from '../services';
2
+
1
3
  const dataStorage = new WeakMap();
2
4
 
5
+ function toggleListener(toEnable, onClick) {
6
+ const args = ['click', onClick, { capture: true }];
7
+ const action = toEnable ? 'addEventListener' : 'removeEventListener';
8
+
9
+ if (ContextWindow.window !== window) {
10
+ window.document[action](...args);
11
+ }
12
+
13
+ ContextWindow.document[action](...args);
14
+ }
15
+
3
16
  export const outClick = {
4
17
  bind(el, { value }) {
5
18
  const onOutClick = value.onOutClick || value;
@@ -8,13 +21,15 @@ export const outClick = {
8
21
  function onClick(event) {
9
22
  const isInside = event.target === el || el.contains(event.target);
10
23
 
11
- if (event.target.isConnected && !isInside) onOutClick(event);
24
+ if (event.target.isConnected && !isInside) {
25
+ setTimeout(() => onOutClick(event));
26
+ }
12
27
  }
13
28
 
14
29
  dataStorage.set(el, { callback: onClick, isEnabled });
15
30
 
16
31
  if (isEnabled) {
17
- setTimeout(() => document.addEventListener('click', onClick));
32
+ setTimeout(() => toggleListener(true, onClick));
18
33
  }
19
34
  },
20
35
 
@@ -24,14 +39,12 @@ export const outClick = {
24
39
 
25
40
  if (isEnabled === data.isEnabled) return;
26
41
 
27
- isEnabled
28
- ? document.addEventListener('click', data.callback)
29
- : document.removeEventListener('click', data.callback);
42
+ toggleListener(isEnabled, data.callback);
30
43
 
31
44
  dataStorage.set(el, { callback: data.callback, isEnabled });
32
45
  },
33
46
 
34
47
  unbind(el) {
35
- document.removeEventListener('click', dataStorage.get(el).callback);
48
+ toggleListener(false, dataStorage.get(el).callback);
36
49
  }
37
50
  };
@@ -2,5 +2,14 @@ export const Alignments = Object.freeze({
2
2
  LEFT: 'left',
3
3
  CENTER: 'center',
4
4
  RIGHT: 'right',
5
- JUSTIFY: 'justify'
5
+ JUSTIFY: 'justify',
6
+
7
+ get values() {
8
+ return [
9
+ this.LEFT,
10
+ this.CENTER,
11
+ this.RIGHT,
12
+ this.JUSTIFY
13
+ ];
14
+ }
6
15
  });
@@ -0,0 +1,4 @@
1
+ export const LinkDestinations = Object.freeze({
2
+ URL: 'url',
3
+ BLOCK: 'block'
4
+ });
@@ -0,0 +1,4 @@
1
+ export const LinkTargets = Object.freeze({
2
+ BLANK: '_blank',
3
+ SELF: '_self'
4
+ });
@@ -8,6 +8,7 @@ export const TextSettings = Object.freeze({
8
8
  FONT_WEIGHT: 'font_weight',
9
9
  LINE_HEIGHT: 'line_height',
10
10
  TEXT_DECORATION: 'text_decoration',
11
+ SUPERSCRIPT: 'superscript',
11
12
 
12
13
  get attributes() {
13
14
  return [
@@ -24,7 +25,8 @@ export const TextSettings = Object.freeze({
24
25
  this.FONT_SIZE,
25
26
  this.FONT_STYLE,
26
27
  this.FONT_WEIGHT,
27
- this.TEXT_DECORATION
28
+ this.TEXT_DECORATION,
29
+ this.SUPERSCRIPT
28
30
  ];
29
31
  }
30
32
  });
@@ -4,3 +4,5 @@ export { Alignments } from './Alignments';
4
4
  export { NodeTypes } from './NodeTypes';
5
5
  export { ListTypes } from './ListTypes';
6
6
  export { TextSettings } from './TextSettings';
7
+ export { LinkTargets } from './LinkTargets';
8
+ export { LinkDestinations } from './LinkDestinations';
@@ -1,6 +1,6 @@
1
1
  import { Extension } from '@tiptap/vue-2';
2
- import { computed } from '@vue/composition-api';
3
- import { createCommand, createKeyboardShortcut, renderInlineSetting } from '../utils';
2
+ import { computed, unref } from 'vue';
3
+ import { convertAlignment, createCommand, createKeyboardShortcut, renderInlineSetting } from '../utils';
4
4
  import { Alignments, NodeTypes, TextSettings } from '../enums';
5
5
 
6
6
  const DEFAULTS = {
@@ -19,19 +19,33 @@ export const Alignment = Extension.create({
19
19
  [TextSettings.ALIGNMENT]: {
20
20
  isRequired: false,
21
21
 
22
- parseHTML(el) {
23
- const value = el.style.textAlign;
22
+ parseHTML({ style }) {
23
+ const textAlign = convertAlignment(style.textAlign);
24
24
 
25
- return value ? { desktop: value, tablet: value, mobile: value } : null;
25
+ if (textAlign) {
26
+ return {
27
+ desktop: textAlign,
28
+ tablet: textAlign,
29
+ mobile: textAlign
30
+ };
31
+ }
32
+
33
+ const mobile = style.getPropertyValue('--zw-text-align-mobile') || null;
34
+ const tablet = style.getPropertyValue('--zw-text-align-tablet') || null;
35
+ const desktop = style.getPropertyValue('--zw-text-align-desktop') || null;
36
+
37
+ if (!mobile && !tablet && !desktop) return null;
38
+
39
+ return { desktop, tablet, mobile };
26
40
  },
27
41
 
28
42
  renderHTML(attrs) {
29
43
  if (!attrs.alignment) return null;
30
44
 
31
45
  return renderInlineSetting({
32
- mobile_text_align: attrs.alignment.mobile,
33
- tablet_text_align: attrs.alignment.tablet,
34
- desktop_text_align: attrs.alignment.desktop
46
+ text_align_mobile: attrs.alignment.mobile,
47
+ text_align_tablet: attrs.alignment.tablet,
48
+ text_align_desktop: attrs.alignment.desktop
35
49
  });
36
50
  }
37
51
  }
@@ -42,7 +56,7 @@ export const Alignment = Extension.create({
42
56
  addCommands() {
43
57
  return {
44
58
  applyAlignment: createCommand(({ commands }, value) => {
45
- const device = commands.getDevice().value;
59
+ const device = unref(commands.getDevice());
46
60
 
47
61
  commands.setBlockAttributes(this.name, { [device]: value }, DEFAULTS);
48
62
  }),
@@ -52,14 +66,14 @@ export const Alignment = Extension.create({
52
66
  const device = commands.getDevice();
53
67
  const defaultValue = commands.getDefaultAlignment();
54
68
 
55
- return computed(() => attribute.value?.[device.value] ?? defaultValue.value);
69
+ return computed(() => unref(attribute)?.[unref(device)] ?? unref(defaultValue));
56
70
  }),
57
71
 
58
72
  getDefaultAlignment: createCommand(({ commands }) => {
59
73
  const device = commands.getDevice();
60
74
  const preset = commands.getPreset();
61
75
 
62
- return computed(() => preset.value[device.value].alignment);
76
+ return computed(() => unref(preset)[unref(device)].alignment);
63
77
  })
64
78
  };
65
79
  },
@@ -1,5 +1,5 @@
1
1
  import { Mark } from '@tiptap/vue-2';
2
- import { computed } from '@vue/composition-api';
2
+ import { computed } from 'vue';
3
3
  import { convertColor, createCommand, renderMark } from '../utils';
4
4
  import { TextSettings } from '../enums';
5
5
 
@@ -22,12 +22,20 @@ export const BackgroundColor = Mark.create({
22
22
  };
23
23
  },
24
24
 
25
- parseHTML: () => [
26
- {
27
- style: 'background-color',
28
- getAttrs: (value) => ({ value: convertColor(value) })
29
- }
30
- ],
25
+ parseHTML() {
26
+ const getAttrs = (value) => ({ value: convertColor(value) });
27
+
28
+ return [
29
+ {
30
+ style: '--zw-background-color',
31
+ getAttrs
32
+ },
33
+ {
34
+ style: 'background-color',
35
+ getAttrs
36
+ }
37
+ ];
38
+ },
31
39
 
32
40
  renderHTML({ HTMLAttributes: attrs }) {
33
41
  return renderMark({ background_color: attrs.value });
@@ -1,16 +1,13 @@
1
+ import { toRef } from 'vue';
1
2
  import { Extension } from '@tiptap/vue-2';
2
3
  import { createCommand } from '../utils';
3
4
 
4
5
  export const DeviceManager = Extension.create({
5
6
  name: 'device_manager',
6
7
 
7
- addOptions: () => ({
8
- deviceRef: null
9
- }),
10
-
11
8
  addCommands() {
12
9
  return {
13
- getDevice: createCommand(() => this.options.deviceRef)
10
+ getDevice: createCommand(() => toRef(this.options, 'device'))
14
11
  };
15
12
  }
16
13
  });
@@ -1,5 +1,5 @@
1
1
  import { Mark } from '@tiptap/vue-2';
2
- import { computed } from '@vue/composition-api';
2
+ import { computed, unref } from 'vue';
3
3
  import { convertColor, createCommand, renderMark } from '../utils';
4
4
  import { TextSettings } from '../enums';
5
5
 
@@ -15,13 +15,13 @@ export const FontColor = Mark.create({
15
15
  getFontColor: createCommand(({ commands, editor }) => {
16
16
  const defaultValue = commands.getDefaultFontColor();
17
17
 
18
- return computed(() => editor.getAttributes(this.name)?.value ?? defaultValue.value);
18
+ return computed(() => editor.getAttributes(this.name)?.value ?? unref(defaultValue));
19
19
  }),
20
20
 
21
21
  getDefaultFontColor: createCommand(({ commands }) => {
22
22
  const preset = commands.getPreset();
23
23
 
24
- return computed(() => preset.value.common.color);
24
+ return computed(() => unref(preset).common.color);
25
25
  }),
26
26
 
27
27
  applyFontColor: createCommand(({ commands }, value) => {
@@ -30,12 +30,20 @@ export const FontColor = Mark.create({
30
30
  };
31
31
  },
32
32
 
33
- parseHTML: () => [
34
- {
35
- style: 'color',
36
- getAttrs: (value) => ({ value: convertColor(value) })
37
- }
38
- ],
33
+ parseHTML() {
34
+ const getAttrs = (value) => ({ value: convertColor(value) });
35
+
36
+ return [
37
+ {
38
+ style: '--zw-font-color',
39
+ getAttrs
40
+ },
41
+ {
42
+ style: 'color',
43
+ getAttrs
44
+ }
45
+ ];
46
+ },
39
47
 
40
48
  renderHTML({ HTMLAttributes: attrs }) {
41
49
  return renderMark({ font_color: attrs.value });
@@ -1,5 +1,5 @@
1
1
  import { Mark } from '@tiptap/vue-2';
2
- import { computed } from '@vue/composition-api';
2
+ import { computed, unref } from 'vue';
3
3
  import { createCommand, renderMark } from '../utils';
4
4
  import { TextSettings } from '../enums';
5
5
 
@@ -7,7 +7,8 @@ export const FontFamily = Mark.create({
7
7
  name: TextSettings.FONT_FAMILY,
8
8
 
9
9
  addOptions: () => ({
10
- fonts: []
10
+ fonts: [],
11
+ defaultFont: ''
11
12
  }),
12
13
 
13
14
  addAttributes: () => ({
@@ -20,7 +21,7 @@ export const FontFamily = Mark.create({
20
21
  commands.setMark(this.name, { value });
21
22
 
22
23
  const font = commands.findFontByName(value);
23
- let fontWeight = commands.getFontWeight().value;
24
+ let fontWeight = unref(commands.getFontWeight());
24
25
 
25
26
  if (!font.isWeightSupported(fontWeight)) {
26
27
  fontWeight = font.findClosestWeight(fontWeight);
@@ -35,7 +36,7 @@ export const FontFamily = Mark.create({
35
36
  getFont: createCommand(({ commands }) => {
36
37
  const fontFamily = commands.getFontFamily();
37
38
 
38
- return computed(() => commands.findFontByName(fontFamily.value));
39
+ return computed(() => commands.findFontByName(unref(fontFamily)));
39
40
  }),
40
41
 
41
42
  findFontByName: createCommand((_, name) => {
@@ -45,25 +46,41 @@ export const FontFamily = Mark.create({
45
46
  getFontFamily: createCommand(({ editor, commands }) => {
46
47
  const defaultValue = commands.getDefaultFontFamily();
47
48
 
48
- return computed(() => editor.getAttributes(this.name)?.value ?? defaultValue.value);
49
+ return computed(() => editor.getAttributes(this.name)?.value ?? unref(defaultValue));
49
50
  }),
50
51
 
51
52
  getDefaultFontFamily: createCommand(({ commands }) => {
52
53
  const preset = commands.getPreset();
53
54
 
54
- return computed(() => preset.value.common.font_family);
55
+ return computed(() => unref(preset).common.font_family);
55
56
  })
56
57
  };
57
58
  },
58
59
 
59
- parseHTML: () => [
60
- {
61
- style: 'font-family',
62
- getAttrs: (value) => ({ value })
63
- }
64
- ],
60
+ parseHTML() {
61
+ const getAttrs = (input) => {
62
+ const parsed = input.replace(/"/g, '');
63
+ const isExists = this.options.fonts.some((font) => font.name === parsed);
64
+ const value = isExists ? parsed : this.options.defaultFont;
65
+
66
+ return { value };
67
+ };
68
+
69
+ return [
70
+ {
71
+ style: '--zw-font-family',
72
+ getAttrs
73
+ },
74
+ {
75
+ style: 'font-family',
76
+ getAttrs
77
+ }
78
+ ];
79
+ },
65
80
 
66
81
  renderHTML({ HTMLAttributes: attrs }) {
67
- return renderMark({ font_family: attrs.value });
82
+ const font_family = attrs.value ? `"${attrs.value}"` : null;
83
+
84
+ return renderMark({ font_family });
68
85
  }
69
86
  });
@@ -1,6 +1,6 @@
1
1
  import { Mark } from '@tiptap/vue-2';
2
- import { computed } from '@vue/composition-api';
3
- import { createCommand, createKeyboardShortcut, renderMark } from '../utils';
2
+ import { computed, unref } from 'vue';
3
+ import { convertFontSize, createCommand, createKeyboardShortcut, renderMark } from '../utils';
4
4
  import { TextSettings } from '../enums';
5
5
 
6
6
  export const FontSize = Mark.create({
@@ -25,31 +25,31 @@ export const FontSize = Mark.create({
25
25
  const device = commands.getDevice();
26
26
  const defaultValue = commands.getDefaultFontSize();
27
27
 
28
- return computed(() => editor.getAttributes(this.name)?.[device.value] ?? defaultValue.value);
28
+ return computed(() => editor.getAttributes(this.name)?.[unref(device)] ?? unref(defaultValue));
29
29
  }),
30
30
 
31
31
  getDefaultFontSize: createCommand(({ commands }) => {
32
32
  const device = commands.getDevice();
33
33
  const preset = commands.getPreset();
34
34
 
35
- return computed(() => preset.value[device.value].font_size.replace('px', ''));
35
+ return computed(() => unref(preset)[unref(device)].font_size.replace('px', ''));
36
36
  }),
37
37
 
38
38
  applyFontSize: createCommand(({ commands }, value) => {
39
- const device = commands.getDevice().value;
39
+ const device = unref(commands.getDevice());
40
40
 
41
41
  commands.setMark(this.name, { [device]: value });
42
42
  }),
43
43
 
44
44
  increaseFontSize: createCommand(({ commands }) => {
45
- const size = Number(commands.getFontSize().value);
45
+ const size = Number(unref(commands.getFontSize()));
46
46
  const nextSize = Math.min(size + 1, this.options.maxSize);
47
47
 
48
48
  commands.applyFontSize(String(nextSize));
49
49
  }),
50
50
 
51
51
  decreaseFontSize: createCommand(({ commands }) => {
52
- const size = Number(commands.getFontSize().value);
52
+ const size = Number(unref(commands.getFontSize()));
53
53
  const nextSize = Math.max(size - 1, this.options.minSize);
54
54
 
55
55
  commands.applyFontSize(String(nextSize));
@@ -62,25 +62,45 @@ export const FontSize = Mark.create({
62
62
  'Mod-Shift--': createKeyboardShortcut('decreaseFontSize')
63
63
  }),
64
64
 
65
- parseHTML: () => [
66
- {
67
- style: 'font-size',
65
+ parseHTML() {
66
+ const parseSize = (value) => {
67
+ if (!value) return null;
68
68
 
69
- getAttrs: (input) => {
70
- const value = String(parseInt(input));
69
+ const wrapperEl = unref(this.options.wrapperRef);
70
+ const converted = convertFontSize(value, wrapperEl);
71
71
 
72
- return { desktop: value, tablet: value, mobile: value };
72
+ return String(converted);
73
+ };
74
+
75
+ return [
76
+ {
77
+ tag: '[style*="--zw-font-size"]',
78
+
79
+ getAttrs: ({ style }) => ({
80
+ mobile: parseSize(style.getPropertyValue('--zw-font-size-mobile')),
81
+ tablet: parseSize(style.getPropertyValue('--zw-font-size-tablet')),
82
+ desktop: parseSize(style.getPropertyValue('--zw-font-size-desktop'))
83
+ })
84
+ },
85
+ {
86
+ style: 'font-size',
87
+
88
+ getAttrs: (input) => {
89
+ const value = parseSize(input);
90
+
91
+ return { desktop: value, tablet: value, mobile: value };
92
+ }
73
93
  }
74
- }
75
- ],
94
+ ];
95
+ },
76
96
 
77
97
  renderHTML({ HTMLAttributes: attrs }) {
78
98
  const addUnits = (value) => value ? `${value}px` : null;
79
99
 
80
100
  return renderMark({
81
- mobile_font_size: addUnits(attrs.mobile),
82
- tablet_font_size: addUnits(attrs.tablet),
83
- desktop_font_size: addUnits(attrs.desktop)
101
+ font_size_mobile: addUnits(attrs.mobile),
102
+ font_size_tablet: addUnits(attrs.tablet),
103
+ font_size_desktop: addUnits(attrs.desktop)
84
104
  });
85
105
  }
86
106
  });
@@ -1,5 +1,5 @@
1
1
  import { Mark } from '@tiptap/vue-2';
2
- import { computed } from '@vue/composition-api';
2
+ import { computed, unref } from 'vue';
3
3
  import { createCommand, createKeyboardShortcut, renderMark } from '../utils';
4
4
  import { TextSettings } from '../enums';
5
5
 
@@ -15,30 +15,30 @@ export const FontStyle = Mark.create({
15
15
  isItalic: createCommand(({ editor, commands }) => {
16
16
  const defaultValue = commands.getDefaultFontStyle();
17
17
 
18
- return computed(() => editor.getAttributes(this.name)?.italic ?? defaultValue.value.italic);
18
+ return computed(() => editor.getAttributes(this.name)?.italic ?? unref(defaultValue).italic);
19
19
  }),
20
20
 
21
21
  isItalicAvailable: createCommand(({ commands }) => {
22
22
  const font = commands.getFont();
23
23
  const fontWeight = commands.getFontWeight();
24
24
 
25
- return computed(() => font.value.isItalicSupported(fontWeight.value));
25
+ return computed(() => unref(font).isItalicSupported(unref(fontWeight)));
26
26
  }),
27
27
 
28
28
  getDefaultFontStyle: createCommand(({ commands }) => {
29
29
  const preset = commands.getPreset();
30
30
 
31
31
  return computed(() => ({
32
- italic: preset.value.common.font_style === 'italic'
32
+ italic: unref(preset).common.font_style === 'italic'
33
33
  }));
34
34
  }),
35
35
 
36
36
  toggleItalic: createCommand(({ commands }) => {
37
- const isItalicAvailable = this.editor.commands.isItalicAvailable();
37
+ const isItalicAvailable = unref(this.editor.commands.isItalicAvailable());
38
38
 
39
- if (!isItalicAvailable.value) return;
39
+ if (!isItalicAvailable) return;
40
40
 
41
- commands.isItalic().value ? commands.removeItalic() : commands.applyItalic();
41
+ unref(commands.isItalic()) ? commands.removeItalic() : commands.applyItalic();
42
42
  }),
43
43
 
44
44
  applyItalic: createCommand(({ commands }) => {
@@ -56,18 +56,28 @@ export const FontStyle = Mark.create({
56
56
  'Mod-I': createKeyboardShortcut('toggleItalic')
57
57
  }),
58
58
 
59
- parseHTML: () => [
60
- {
61
- tag: 'i',
62
- attrs: { italic: true }
63
- },
64
- {
65
- style: 'font-style',
66
- getAttrs: (value) => ({ italic: value.includes('italic') })
67
- }
68
- ],
69
-
70
- renderHTML() {
71
- return renderMark({ font_style: 'italic' });
59
+ parseHTML() {
60
+ const getAttrs = (value) => value.includes('italic') && { italic: true };
61
+
62
+ return [
63
+ {
64
+ style: '--zw-font-style',
65
+ getAttrs
66
+ },
67
+ {
68
+ style: 'font-style',
69
+ getAttrs
70
+ },
71
+ {
72
+ tag: 'i',
73
+ attrs: { italic: true }
74
+ }
75
+ ];
76
+ },
77
+
78
+ renderHTML({ HTMLAttributes: attrs }) {
79
+ const font_style = attrs.italic ? 'italic' : null;
80
+
81
+ return renderMark({ font_style });
72
82
  }
73
83
  });