@zipify/wysiwyg 4.11.0 → 4.11.2

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 (141) hide show
  1. package/.release-it.json +2 -1
  2. package/dist/cli.js +28 -28
  3. package/dist/node.js +26 -26
  4. package/dist/types/Wysiwyg.vue.d.ts +7 -8
  5. package/dist/types/components/base/Button.vue.d.ts +5 -10
  6. package/dist/types/components/base/ButtonToggle.vue.d.ts +9 -14
  7. package/dist/types/components/base/Checkbox.vue.d.ts +1 -1
  8. package/dist/types/components/base/FieldLabel.vue.d.ts +5 -10
  9. package/dist/types/components/base/Icon.vue.d.ts +1 -1
  10. package/dist/types/components/base/Modal.vue.d.ts +5 -14
  11. package/dist/types/components/base/ModalFloating.vue.d.ts +5 -14
  12. package/dist/types/components/base/NumberField.vue.d.ts +1 -1
  13. package/dist/types/components/base/Range.vue.d.ts +1 -1
  14. package/dist/types/components/base/ScrollView.vue.d.ts +5 -14
  15. package/dist/types/components/base/TextField.vue.d.ts +1 -1
  16. package/dist/types/components/base/colorPicker/ColorPicker.vue.d.ts +10 -517
  17. package/dist/types/components/base/dropdown/Dropdown.vue.d.ts +6 -15
  18. package/dist/types/components/base/dropdown/DropdownActivator.vue.d.ts +7 -12
  19. package/dist/types/components/base/dropdown/DropdownDivider.vue.d.ts +1 -1
  20. package/dist/types/components/base/dropdown/DropdownGroup.vue.d.ts +7 -12
  21. package/dist/types/components/base/dropdown/DropdownMenu.vue.d.ts +6 -12
  22. package/dist/types/components/base/dropdown/DropdownOption.vue.d.ts +5 -14
  23. package/dist/types/components/toolbar/ToolbarFloating.vue.d.ts +5 -14
  24. package/dist/types/components/toolbar/controls/AlignmentControl.vue.d.ts +1 -1
  25. package/dist/types/components/toolbar/controls/CaseStyleControl.vue.d.ts +1 -1
  26. package/dist/types/components/toolbar/controls/FontFamilyControl.vue.d.ts +1 -1
  27. package/dist/types/components/toolbar/controls/FontSizeControl.vue.d.ts +1 -1
  28. package/dist/types/components/toolbar/controls/FontWeightControl.vue.d.ts +1 -1
  29. package/dist/types/components/toolbar/controls/ItalicControl.vue.d.ts +1 -1
  30. package/dist/types/components/toolbar/controls/LineHeightControl.vue.d.ts +1 -3
  31. package/dist/types/components/toolbar/controls/ListControl.vue.d.ts +1 -1
  32. package/dist/types/components/toolbar/controls/RemoveFormatControl.vue.d.ts +1 -1
  33. package/dist/types/components/toolbar/controls/StrikeThroughControl.vue.d.ts +1 -1
  34. package/dist/types/components/toolbar/controls/SuperscriptControl.vue.d.ts +1 -1
  35. package/dist/types/components/toolbar/controls/UnderlineControl.vue.d.ts +1 -1
  36. package/dist/types/components/toolbar/controls/link/LinkControl.vue.d.ts +1 -3
  37. package/dist/types/components/toolbar/controls/link/LinkControlHeader.vue.d.ts +1 -1
  38. package/dist/types/components/toolbar/controls/link/composables/useLink.d.ts +11 -9
  39. package/dist/types/components/toolbar/controls/link/destination/LinkControlDestination.vue.d.ts +1 -1
  40. package/dist/types/components/toolbar/controls/link/destination/LinkControlPageBlock.vue.d.ts +1 -1
  41. package/dist/types/components/toolbar/controls/link/destination/LinkControlUrl.vue.d.ts +1 -1
  42. package/dist/types/components/toolbar/controls/stylePreset/StylePresetControl.vue.d.ts +1 -1
  43. package/dist/types/components/toolbar/controls/stylePreset/StylePresetOption.vue.d.ts +2 -4
  44. package/dist/types/enums/Alignment.d.ts +7 -0
  45. package/dist/types/enums/CaseStyle.d.ts +5 -0
  46. package/dist/types/enums/Device.d.ts +7 -0
  47. package/dist/types/enums/LinkDestination.d.ts +4 -0
  48. package/dist/types/enums/LinkTarget.d.ts +4 -0
  49. package/dist/types/enums/ListType.d.ts +10 -0
  50. package/dist/types/enums/MarkGroup.d.ts +4 -0
  51. package/dist/types/enums/NodeType.d.ts +9 -0
  52. package/dist/types/enums/TextSetting.d.ts +19 -0
  53. package/dist/types/enums/index.d.ts +9 -9
  54. package/dist/types/extensions/Alignment.d.ts +2 -1
  55. package/dist/types/extensions/CaseStyle.d.ts +2 -1
  56. package/dist/types/models/Font.d.ts +1 -0
  57. package/dist/wysiwyg.css +27 -27
  58. package/dist/wysiwyg.mjs +135 -165
  59. package/example/fonts.js +111 -111
  60. package/lib/Wysiwyg.vue +3 -3
  61. package/lib/__tests__/utils/buildTestExtensions.js +6 -6
  62. package/lib/components/toolbar/Toolbar.vue +2 -2
  63. package/lib/components/toolbar/__tests__/Toolbar.test.js +5 -5
  64. package/lib/components/toolbar/controls/AlignmentControl.vue +7 -7
  65. package/lib/components/toolbar/controls/CaseStyleControl.vue +5 -5
  66. package/lib/components/toolbar/controls/FontColorControl.vue +2 -2
  67. package/lib/components/toolbar/controls/FontFamilyControl.vue +2 -2
  68. package/lib/components/toolbar/controls/FontSizeControl.vue +2 -2
  69. package/lib/components/toolbar/controls/FontWeightControl.vue +2 -2
  70. package/lib/components/toolbar/controls/ItalicControl.vue +2 -2
  71. package/lib/components/toolbar/controls/LineHeightControl.vue +2 -2
  72. package/lib/components/toolbar/controls/ListControl.vue +5 -5
  73. package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +13 -13
  74. package/lib/components/toolbar/controls/__tests__/CaseStyleControl.test.js +4 -4
  75. package/lib/components/toolbar/controls/__tests__/ListControl.test.js +10 -10
  76. package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +6 -6
  77. package/lib/components/toolbar/controls/link/LinkControl.vue +5 -5
  78. package/lib/components/toolbar/controls/link/composables/__tests__/useLink.test.js +20 -20
  79. package/lib/components/toolbar/controls/link/composables/useLink.js +10 -10
  80. package/lib/components/toolbar/controls/link/destination/LinkControlDestination.vue +10 -7
  81. package/lib/components/toolbar/controls/link/destination/LinkControlPageBlock.vue +1 -1
  82. package/lib/enums/{Alignments.ts → Alignment.ts} +0 -8
  83. package/lib/enums/{CaseStyles.ts → CaseStyle.ts} +0 -6
  84. package/lib/enums/{Devices.ts → Device.ts} +0 -8
  85. package/lib/enums/LinkDestination.ts +4 -0
  86. package/lib/enums/LinkTarget.ts +4 -0
  87. package/lib/enums/{ListTypes.ts → ListType.ts} +0 -9
  88. package/lib/enums/MarkGroup.ts +4 -0
  89. package/lib/enums/{NodeTypes.ts → NodeType.ts} +0 -8
  90. package/lib/enums/{TextSettings.ts → TextSetting.ts} +0 -11
  91. package/lib/enums/index.ts +9 -9
  92. package/lib/extensions/Alignment.js +13 -11
  93. package/lib/extensions/BackgroundColor.js +2 -2
  94. package/lib/extensions/CaseStyle.js +8 -6
  95. package/lib/extensions/FontColor.js +4 -4
  96. package/lib/extensions/FontFamily.js +8 -6
  97. package/lib/extensions/FontSize.js +3 -3
  98. package/lib/extensions/FontStyle.js +3 -3
  99. package/lib/extensions/FontWeight.js +3 -3
  100. package/lib/extensions/LineHeight.js +4 -4
  101. package/lib/extensions/Link.js +11 -11
  102. package/lib/extensions/Margin.js +4 -4
  103. package/lib/extensions/StylePreset.js +18 -12
  104. package/lib/extensions/Superscript.js +2 -2
  105. package/lib/extensions/TextDecoration.js +2 -2
  106. package/lib/extensions/__tests__/Alignment.test.js +21 -21
  107. package/lib/extensions/__tests__/BackgroundColor.test.js +4 -4
  108. package/lib/extensions/__tests__/CaseStyle.test.js +6 -6
  109. package/lib/extensions/__tests__/FontColor.test.js +4 -4
  110. package/lib/extensions/__tests__/FontFamily.test.js +10 -10
  111. package/lib/extensions/__tests__/FontSize.test.js +9 -9
  112. package/lib/extensions/__tests__/FontStyle.test.js +6 -6
  113. package/lib/extensions/__tests__/FontWeight.test.js +11 -11
  114. package/lib/extensions/__tests__/LineHeight.test.js +2 -2
  115. package/lib/extensions/__tests__/Link.test.js +13 -13
  116. package/lib/extensions/__tests__/StylePreset.test.js +29 -29
  117. package/lib/extensions/__tests__/Superscript.test.js +5 -5
  118. package/lib/extensions/__tests__/TextDecoration.test.js +14 -14
  119. package/lib/extensions/core/Document.js +3 -3
  120. package/lib/extensions/core/Heading.js +2 -2
  121. package/lib/extensions/core/NodeProcessor.js +8 -8
  122. package/lib/extensions/core/Paragraph.js +2 -2
  123. package/lib/extensions/core/__tests__/NodeProcessor.test.js +68 -68
  124. package/lib/extensions/core/__tests__/TextProcessor.test.js +13 -13
  125. package/lib/extensions/list/ListItem.js +5 -5
  126. package/lib/extensions/list/__tests__/List.test.js +11 -11
  127. package/lib/extensions/proseMirror/PasteLinkPlugin.js +4 -4
  128. package/lib/extensions/proseMirror/PastePlugin.js +2 -2
  129. package/lib/models/Font.ts +4 -0
  130. package/lib/services/ContentSerializer.js +3 -3
  131. package/lib/services/StylePresetRenderer.js +4 -4
  132. package/lib/services/__tests__/NodeFactory.test.js +11 -11
  133. package/lib/services/__tests__/NodeSelector.test.js +18 -18
  134. package/lib/services/normalizer/JsonNormalizer.js +5 -5
  135. package/lib/services/normalizer/__tests__/JsonNormalizer.test.js +15 -15
  136. package/lib/utils/__tests__/convertAlignment.test.js +3 -3
  137. package/lib/utils/convertAlignment.js +4 -4
  138. package/package.json +17 -17
  139. package/lib/enums/LinkDestinations.ts +0 -9
  140. package/lib/enums/LinkTargets.ts +0 -9
  141. package/lib/enums/MarkGroups.ts +0 -9
@@ -21,12 +21,3 @@ export const ListOrderedTypeList = [
21
21
  ListType.ROMAN,
22
22
  ListType.LATIN
23
23
  ];
24
-
25
- /**
26
- * @deprecated Use `ListType` instead.
27
- */
28
- export const ListTypes = {
29
- ...ListType,
30
- values: ListTypeList,
31
- ordered: ListOrderedTypeList
32
- };
@@ -0,0 +1,4 @@
1
+ export enum MarkGroup {
2
+ SETTINGS = 'settings',
3
+ ALL = '_'
4
+ }
@@ -8,11 +8,3 @@ export enum NodeType {
8
8
  }
9
9
 
10
10
  export const NodeBlockTypeList = [NodeType.PARAGRAPH, NodeType.LIST, NodeType.HEADING];
11
-
12
- /**
13
- * @deprecated Use `NodeType` instead.
14
- */
15
- export const NodeTypes = Object.freeze({
16
- ...NodeType,
17
- blocks: NodeBlockTypeList
18
- });
@@ -41,14 +41,3 @@ export const TextBlockMarkList = [
41
41
  TextSetting.TEXT_DECORATION,
42
42
  TextSetting.SUPERSCRIPT
43
43
  ];
44
-
45
- /**
46
- * @deprecated Use `TextSetting` instead.
47
- */
48
- export const TextSettings = {
49
- ...TextSetting,
50
- attributes: TextAttributeSettingList,
51
- presetAttributes: TextPresetAttributeSettingList,
52
- inlineMarks: TextInlineMarkList,
53
- marks: TextBlockMarkList
54
- };
@@ -1,9 +1,9 @@
1
- export * from './Devices';
2
- export * from './CaseStyles';
3
- export * from './Alignments';
4
- export * from './NodeTypes';
5
- export * from './ListTypes';
6
- export * from './TextSettings';
7
- export * from './MarkGroups';
8
- export * from './LinkTargets';
9
- export * from './LinkDestinations';
1
+ export * from './Device';
2
+ export * from './CaseStyle';
3
+ export * from './Alignment';
4
+ export * from './NodeType';
5
+ export * from './ListType';
6
+ export * from './TextSetting';
7
+ export * from './MarkGroup';
8
+ export * from './LinkTarget';
9
+ export * from './LinkDestination';
@@ -1,7 +1,7 @@
1
1
  import { Extension } from '@tiptap/vue-3';
2
2
  import { computed, unref } from 'vue';
3
- import { convertAlignment, createCommand, createKeyboardShortcut, renderInlineSetting } from '../utils';
4
- import { Alignments, NodeTypes, TextSettings } from '../enums';
3
+ import { convertAlignment, createCommand, createKeyboardShortcut, renderInlineSetting } from '@/utils';
4
+ import { Alignment, NodeType, TextSetting } from '@/enums';
5
5
 
6
6
  const DEFAULTS = {
7
7
  mobile: null,
@@ -9,14 +9,14 @@ const DEFAULTS = {
9
9
  desktop: null
10
10
  };
11
11
 
12
- export const Alignment = Extension.create({
13
- name: TextSettings.ALIGNMENT,
12
+ export const AlignmentExtension = Extension.create({
13
+ name: TextSetting.ALIGNMENT,
14
14
 
15
15
  addGlobalAttributes: () => [
16
16
  {
17
- types: [NodeTypes.PARAGRAPH, NodeTypes.HEADING],
17
+ types: [NodeType.PARAGRAPH, NodeType.HEADING],
18
18
  attributes: {
19
- [TextSettings.ALIGNMENT]: {
19
+ [TextSetting.ALIGNMENT]: {
20
20
  isRequired: false,
21
21
 
22
22
  parseHTML({ style }) {
@@ -71,15 +71,17 @@ export const Alignment = Extension.create({
71
71
  const device = commands.getDevice();
72
72
  const preset = commands.getPreset();
73
73
 
74
- return computed(() => unref(preset)[unref(device)].alignment ?? Alignments.LEFT);
74
+ return computed(() => unref(preset)[unref(device)].alignment ?? Alignment.LEFT);
75
75
  })
76
76
  };
77
77
  },
78
78
 
79
79
  addKeyboardShortcuts: () => ({
80
- 'Mod-Shift-l': createKeyboardShortcut('applyAlignment', Alignments.LEFT),
81
- 'Mod-Shift-e': createKeyboardShortcut('applyAlignment', Alignments.CENTER),
82
- 'Mod-Shift-r': createKeyboardShortcut('applyAlignment', Alignments.RIGHT),
83
- 'Mod-Shift-j': createKeyboardShortcut('applyAlignment', Alignments.JUSTIFY)
80
+ 'Mod-Shift-l': createKeyboardShortcut('applyAlignment', Alignment.LEFT),
81
+ 'Mod-Shift-e': createKeyboardShortcut('applyAlignment', Alignment.CENTER),
82
+ 'Mod-Shift-r': createKeyboardShortcut('applyAlignment', Alignment.RIGHT),
83
+ 'Mod-Shift-j': createKeyboardShortcut('applyAlignment', Alignment.JUSTIFY)
84
84
  })
85
85
  });
86
+
87
+ export { AlignmentExtension as Alignment };
@@ -1,9 +1,9 @@
1
1
  import { Mark } from '@tiptap/vue-3';
2
2
  import { convertColor, createCommand, renderMark } from '../utils';
3
- import { TextSettings } from '../enums';
3
+ import { TextSetting } from '../enums';
4
4
 
5
5
  export const BackgroundColor = Mark.create({
6
- name: TextSettings.BACKGROUND_COLOR,
6
+ name: TextSetting.BACKGROUND_COLOR,
7
7
 
8
8
  addAttributes: () => ({
9
9
  value: { required: true }
@@ -1,21 +1,21 @@
1
1
  import { Extension } from '@tiptap/vue-3';
2
- import { capitalize, createCommand } from '../utils';
3
- import { CaseStyles } from '../enums';
2
+ import { capitalize, createCommand } from '@/utils';
3
+ import { CaseStyle } from '@/enums';
4
4
 
5
- export const CaseStyle = Extension.create({
5
+ export const CaseStyleExtension = Extension.create({
6
6
  name: 'case_style',
7
7
 
8
8
  addCommands() {
9
9
  return {
10
10
  applyCaseStyle: createCommand(({ commands }, value) => {
11
11
  switch (value) {
12
- case CaseStyles.CAPITALIZE:
12
+ case CaseStyle.CAPITALIZE:
13
13
  return commands.applyCapitalize();
14
14
 
15
- case CaseStyles.LOWERCASE:
15
+ case CaseStyle.LOWERCASE:
16
16
  return commands.applyLowerCase();
17
17
 
18
- case CaseStyles.UPPERCASE:
18
+ case CaseStyle.UPPERCASE:
19
19
  return commands.applyUpperCase();
20
20
  }
21
21
  }),
@@ -34,3 +34,5 @@ export const CaseStyle = Extension.create({
34
34
  };
35
35
  }
36
36
  });
37
+
38
+ export { CaseStyleExtension as CaseStyle };
@@ -1,11 +1,11 @@
1
1
  import { Mark } from '@tiptap/vue-3';
2
2
  import { computed, unref } from 'vue';
3
- import { convertColor, createCommand, renderMark } from '../utils';
4
- import { MarkGroups, TextSettings } from '../enums';
3
+ import { convertColor, createCommand, renderMark } from '@/utils';
4
+ import { MarkGroup, TextSetting } from '@/enums';
5
5
 
6
6
  export const FontColor = Mark.create({
7
- name: TextSettings.FONT_COLOR,
8
- group: MarkGroups.SETTINGS,
7
+ name: TextSetting.FONT_COLOR,
8
+ group: MarkGroup.SETTINGS,
9
9
 
10
10
  addAttributes: () => ({
11
11
  value: { required: true }
@@ -1,11 +1,11 @@
1
1
  import { Mark } from '@tiptap/vue-3';
2
2
  import { computed, unref } from 'vue';
3
- import { createCommand, renderMark } from '../utils';
4
- import { MarkGroups, TextSettings } from '../enums';
3
+ import { createCommand, renderMark } from '@/utils';
4
+ import { MarkGroup, TextSetting } from '@/enums';
5
5
 
6
6
  export const FontFamily = Mark.create({
7
- name: TextSettings.FONT_FAMILY,
8
- group: MarkGroups.SETTINGS,
7
+ name: TextSetting.FONT_FAMILY,
8
+ group: MarkGroup.SETTINGS,
9
9
 
10
10
  addOptions: () => ({
11
11
  fonts: []
@@ -28,9 +28,11 @@ export const FontFamily = Mark.create({
28
28
  commands.applyFontWeight(fontWeight);
29
29
  }
30
30
 
31
- const isItalicCustomized = commands.isSettingCustomized(TextSettings.FONT_STYLE).value;
31
+ const isItalicCustomized = commands.isSettingCustomized(TextSetting.FONT_STYLE).value;
32
32
 
33
- if (!font.isItalicSupported(fontWeight) && isItalicCustomized) {
33
+ if (font.isItalicOnly) {
34
+ commands.applyItalic();
35
+ } else if (!font.isItalicSupported(fontWeight) && isItalicCustomized) {
34
36
  commands.removeItalic();
35
37
  }
36
38
  }),
@@ -1,11 +1,11 @@
1
1
  import { Mark } from '@tiptap/vue-3';
2
2
  import { computed, unref } from 'vue';
3
3
  import { convertFontSize, createCommand, createKeyboardShortcut, renderMark } from '../utils';
4
- import { MarkGroups, TextSettings } from '../enums';
4
+ import { MarkGroup, TextSetting } from '../enums';
5
5
 
6
6
  export const FontSize = Mark.create({
7
- name: TextSettings.FONT_SIZE,
8
- group: MarkGroups.SETTINGS,
7
+ name: TextSetting.FONT_SIZE,
8
+ group: MarkGroup.SETTINGS,
9
9
 
10
10
  addOptions: () => ({
11
11
  minSize: 1,
@@ -1,11 +1,11 @@
1
1
  import { Mark } from '@tiptap/vue-3';
2
2
  import { computed, unref } from 'vue';
3
3
  import { createCommand, createKeyboardShortcut, renderMark } from '@/utils';
4
- import { MarkGroups, TextSettings } from '@/enums';
4
+ import { MarkGroup, TextSetting } from '@/enums';
5
5
 
6
6
  export const FontStyle = Mark.create({
7
- name: TextSettings.FONT_STYLE,
8
- group: MarkGroups.SETTINGS,
7
+ name: TextSetting.FONT_STYLE,
8
+ group: MarkGroup.SETTINGS,
9
9
 
10
10
  addAttributes: () => ({
11
11
  italic: { required: true }
@@ -1,11 +1,11 @@
1
1
  import { Mark } from '@tiptap/vue-3';
2
2
  import { computed, unref } from 'vue';
3
3
  import { createCommand, createKeyboardShortcut, renderMark } from '../utils';
4
- import { MarkGroups, TextSettings } from '../enums';
4
+ import { MarkGroup, TextSetting } from '../enums';
5
5
 
6
6
  export const FontWeight = Mark.create({
7
- name: TextSettings.FONT_WEIGHT,
8
- group: MarkGroups.SETTINGS,
7
+ name: TextSetting.FONT_WEIGHT,
8
+ group: MarkGroup.SETTINGS,
9
9
 
10
10
  addAttributes: () => ({
11
11
  value: { required: true }
@@ -1,7 +1,7 @@
1
1
  import { Extension } from '@tiptap/vue-3';
2
2
  import { computed, unref } from 'vue';
3
3
  import { createCommand, renderInlineSetting, convertLineHeight } from '../utils';
4
- import { NodeTypes, TextSettings } from '../enums';
4
+ import { NodeType, TextSetting } from '../enums';
5
5
 
6
6
  const DEFAULTS = {
7
7
  mobile: null,
@@ -10,14 +10,14 @@ const DEFAULTS = {
10
10
  };
11
11
 
12
12
  export const LineHeight = Extension.create({
13
- name: TextSettings.LINE_HEIGHT,
13
+ name: TextSetting.LINE_HEIGHT,
14
14
 
15
15
  addGlobalAttributes() {
16
16
  return [
17
17
  {
18
- types: [NodeTypes.PARAGRAPH, NodeTypes.HEADING],
18
+ types: [NodeType.PARAGRAPH, NodeType.HEADING],
19
19
  attributes: {
20
- [TextSettings.LINE_HEIGHT]: {
20
+ [TextSetting.LINE_HEIGHT]: {
21
21
  isRequired: false,
22
22
 
23
23
  parseHTML: (element) => {
@@ -1,12 +1,12 @@
1
1
  import Base from '@tiptap/extension-link';
2
2
  import { computed, unref } from 'vue';
3
- import { createCommand } from '../utils';
4
- import { LinkDestinations, LinkTargets, TextSettings } from '../enums';
5
- import { NodeFactory } from '../services';
3
+ import { createCommand } from '@/utils';
4
+ import { LinkDestination, LinkTarget, TextSetting } from '@/enums';
5
+ import { NodeFactory } from '@/services';
6
6
  import { PasteLinkPlugin } from './proseMirror';
7
7
 
8
8
  export const Link = Base.extend({
9
- name: TextSettings.LINK,
9
+ name: TextSetting.LINK,
10
10
 
11
11
  addOptions() {
12
12
  return {
@@ -30,23 +30,23 @@ export const Link = Base.extend({
30
30
  },
31
31
 
32
32
  target: {
33
- default: LinkTargets.SELF,
34
- parseHTML: (element) => element.getAttribute('target') || LinkTargets.SELF
33
+ default: LinkTarget.SELF,
34
+ parseHTML: (element) => element.getAttribute('target') || LinkTarget.SELF
35
35
  },
36
36
 
37
37
  destination: {
38
- default: LinkDestinations.URL,
38
+ default: LinkDestination.URL,
39
39
 
40
40
  parseHTML: (element) => {
41
41
  const href = element.getAttribute('href');
42
42
 
43
- if (!href.startsWith('#')) return LinkDestinations.URL;
43
+ if (!href.startsWith('#')) return LinkDestination.URL;
44
44
 
45
45
  const id = href.replace('#', '');
46
46
  const blocks = unref(this.options.pageBlocks);
47
47
  const block = blocks.find((block) => block.id === parseInt(id));
48
48
 
49
- return block ? LinkDestinations.BLOCK : LinkDestinations.URL;
49
+ return block ? LinkDestination.BLOCK : LinkDestination.URL;
50
50
  }
51
51
  }
52
52
  };
@@ -63,7 +63,7 @@ export const Link = Base.extend({
63
63
 
64
64
  if (!commands.getSelectedText()) {
65
65
  return commands.insertContent(NodeFactory.text(attributes.text, [
66
- NodeFactory.mark(TextSettings.LINK, attributes)
66
+ NodeFactory.mark(TextSetting.LINK, attributes)
67
67
  ]));
68
68
  }
69
69
 
@@ -96,7 +96,7 @@ export const Link = Base.extend({
96
96
  },
97
97
 
98
98
  renderHTML({ HTMLAttributes: attrs }) {
99
- const href = attrs.destination === LinkDestinations.BLOCK ? `#${attrs.href}` : attrs.href;
99
+ const href = attrs.destination === LinkDestination.BLOCK ? `#${attrs.href}` : attrs.href;
100
100
  const presetClass = unref(this.options.basePresetClass) + unref(this.options.preset).id;
101
101
  const linkAttrs = { href, target: attrs.target, class: `${presetClass} zw-style` };
102
102
 
@@ -1,17 +1,17 @@
1
1
  import { Extension } from '@tiptap/vue-3';
2
- import { NodeTypes, TextSettings } from '../enums';
2
+ import { NodeType, TextSetting } from '../enums';
3
3
  import { renderInlineSetting } from '../utils';
4
4
 
5
5
  // Fallback margins in old wysiwyg content
6
6
  export const Margin = Extension.create({
7
- name: TextSettings.MARGIN,
7
+ name: TextSetting.MARGIN,
8
8
 
9
9
  addGlobalAttributes: () => [
10
10
  {
11
- types: [NodeTypes.PARAGRAPH, NodeTypes.HEADING],
11
+ types: [NodeType.PARAGRAPH, NodeType.HEADING],
12
12
 
13
13
  attributes: {
14
- [TextSettings.MARGIN]: {
14
+ [TextSetting.MARGIN]: {
15
15
  isRequired: false,
16
16
 
17
17
  parseHTML(el) {
@@ -1,16 +1,22 @@
1
1
  import { Extension } from '@tiptap/vue-3';
2
2
  import { computed, toRef, unref } from 'vue';
3
3
  import { createCommand } from '@/utils';
4
- import { NodeTypes, TextSettings } from '@/enums';
4
+ import {
5
+ NodeType,
6
+ TextAttributeSettingList,
7
+ TextBlockMarkList,
8
+ TextPresetAttributeSettingList,
9
+ TextSetting
10
+ } from '@/enums';
5
11
  import { ContextWindow } from '@/services';
6
12
 
7
13
  export const StylePreset = Extension.create({
8
- name: TextSettings.STYLE_PRESET,
14
+ name: TextSetting.STYLE_PRESET,
9
15
 
10
16
  addGlobalAttributes() {
11
17
  return [
12
18
  {
13
- types: [NodeTypes.PARAGRAPH, NodeTypes.HEADING],
19
+ types: [NodeType.PARAGRAPH, NodeType.HEADING],
14
20
  attributes: {
15
21
  preset: {
16
22
  isRequired: false,
@@ -97,7 +103,7 @@ export const StylePreset = Extension.create({
97
103
  applyPreset: createCommand(({ commands, chain }, presetId) => {
98
104
  const presets = unref(commands.getPresetList());
99
105
  const preset = findPresetById(presets, presetId);
100
- const nodeType = preset.node?.type ?? NodeTypes.PARAGRAPH;
106
+ const nodeType = preset.node?.type ?? NodeType.PARAGRAPH;
101
107
 
102
108
  const attrs = {
103
109
  preset: { id: presetId }
@@ -107,7 +113,7 @@ export const StylePreset = Extension.create({
107
113
  attrs.level = preset.node.level;
108
114
  }
109
115
 
110
- for (const textAttribute of TextSettings.attributes) {
116
+ for (const textAttribute of TextAttributeSettingList) {
111
117
  attrs[textAttribute] = unref(commands.getBlockAttributes(textAttribute));
112
118
  }
113
119
 
@@ -119,7 +125,7 @@ export const StylePreset = Extension.create({
119
125
  }),
120
126
 
121
127
  removePreset: createCommand(({ commands }) => {
122
- commands.setNode(NodeTypes.PARAGRAPH, { preset: null });
128
+ commands.setNode(NodeType.PARAGRAPH, { preset: null });
123
129
  }),
124
130
 
125
131
  getPresetCustomization: createCommand(({ editor, commands }) => {
@@ -135,7 +141,7 @@ export const StylePreset = Extension.create({
135
141
 
136
142
  isSettingCustomized: createCommand(({ commands }, name) => {
137
143
  const customization = commands.getPresetCustomization();
138
- const group = TextSettings.presetAttributes.includes(name) ? 'attributes' : 'marks';
144
+ const group = TextPresetAttributeSettingList.includes(name) ? 'attributes' : 'marks';
139
145
 
140
146
  return computed(() => unref(customization)[group]?.includes(name) ?? false);
141
147
  }),
@@ -156,13 +162,13 @@ export const StylePreset = Extension.create({
156
162
 
157
163
  doc.nodesBetween(from, to, (node) => {
158
164
  for (const [name, value] of Object.entries(node.attrs)) {
159
- const isSetting = TextSettings.presetAttributes.includes(name);
165
+ const isSetting = TextPresetAttributeSettingList.includes(name);
160
166
 
161
167
  if (isSetting && value) attributes.add(name);
162
168
  }
163
169
 
164
170
  for (const { type } of node.marks) {
165
- if (TextSettings.marks.includes(type.name)) {
171
+ if (TextBlockMarkList.includes(type.name)) {
166
172
  marks.add(type.name);
167
173
  }
168
174
  }
@@ -178,9 +184,9 @@ export const StylePreset = Extension.create({
178
184
  chain()
179
185
  .storeSelection()
180
186
  .expandSelectionToBlock()
181
- .removeMarks(TextSettings.marks)
182
- .resetAttributes(NodeTypes.PARAGRAPH, TextSettings.presetAttributes)
183
- .resetAttributes(NodeTypes.HEADING, TextSettings.presetAttributes)
187
+ .removeMarks(TextBlockMarkList)
188
+ .resetAttributes(NodeType.PARAGRAPH, TextPresetAttributeSettingList)
189
+ .resetAttributes(NodeType.HEADING, TextPresetAttributeSettingList)
184
190
  .restoreSelection()
185
191
  .run();
186
192
  }),
@@ -1,10 +1,10 @@
1
1
  import { Mark } from '@tiptap/vue-3';
2
2
  import { computed, unref } from 'vue';
3
3
  import { createCommand } from '../utils';
4
- import { TextSettings } from '../enums';
4
+ import { TextSetting } from '../enums';
5
5
 
6
6
  export const Superscript = Mark.create({
7
- name: TextSettings.SUPERSCRIPT,
7
+ name: TextSetting.SUPERSCRIPT,
8
8
 
9
9
  addCommands() {
10
10
  return {
@@ -1,10 +1,10 @@
1
1
  import { Mark } from '@tiptap/vue-3';
2
2
  import { computed, unref } from 'vue';
3
3
  import { createCommand, createKeyboardShortcut, renderMark } from '../utils';
4
- import { TextSettings } from '../enums';
4
+ import { TextSetting } from '../enums';
5
5
 
6
6
  export const TextDecoration = Mark.create({
7
- name: TextSettings.TEXT_DECORATION,
7
+ name: TextSetting.TEXT_DECORATION,
8
8
  priority: 1000,
9
9
 
10
10
  addAttributes: () => ({
@@ -1,21 +1,21 @@
1
1
  import { Editor, Extension } from '@tiptap/vue-3';
2
2
  import { ref } from 'vue';
3
- import { buildTestExtensions } from '../../__tests__/utils';
4
- import { createCommand } from '../../utils';
5
- import { Alignment } from '../Alignment';
3
+ import { buildTestExtensions } from '@/__tests__/utils';
4
+ import { createCommand } from '@/utils';
5
+ import { Alignment, TextSetting } from '@/enums';
6
+ import { ContentNormalizer, NodeFactory } from '@/services';
7
+ import { AlignmentExtension } from '../Alignment';
6
8
  import { DeviceManager } from '../DeviceManager';
7
- import { Alignments, TextSettings } from '../../enums';
8
- import { ContentNormalizer, NodeFactory } from '../../services';
9
9
 
10
10
  const MockStylePreset = Extension.create({
11
- name: TextSettings.STYLE_PRESET,
11
+ name: TextSetting.STYLE_PRESET,
12
12
 
13
13
  addCommands() {
14
14
  return {
15
15
  getPreset: createCommand(() => ref({
16
- mobile: { alignment: Alignments.JUSTIFY },
17
- tablet: { alignment: Alignments.JUSTIFY },
18
- desktop: { alignment: Alignments.JUSTIFY }
16
+ mobile: { alignment: Alignment.JUSTIFY },
17
+ tablet: { alignment: Alignment.JUSTIFY },
18
+ desktop: { alignment: Alignment.JUSTIFY }
19
19
  }))
20
20
  };
21
21
  }
@@ -28,7 +28,7 @@ function createEditor({ content }) {
28
28
  include: [
29
29
  MockStylePreset,
30
30
  DeviceManager.configure({ device: ref('desktop') }),
31
- Alignment
31
+ AlignmentExtension
32
32
  ]
33
33
  })
34
34
  });
@@ -44,13 +44,13 @@ describe('get value', () => {
44
44
  test('should get from selection', () => {
45
45
  const editor = createEditor({
46
46
  content: createContent({
47
- alignment: { desktop: Alignments.CENTER }
47
+ alignment: { desktop: Alignment.CENTER }
48
48
  })
49
49
  });
50
50
 
51
51
  editor.commands.selectAll();
52
52
 
53
- expect(editor.commands.getAlignment().value).toEqual(Alignments.CENTER);
53
+ expect(editor.commands.getAlignment().value).toEqual(Alignment.CENTER);
54
54
  });
55
55
 
56
56
  test('should get default value', () => {
@@ -58,7 +58,7 @@ describe('get value', () => {
58
58
  content: createContent({ alignment: null })
59
59
  });
60
60
 
61
- expect(editor.commands.getDefaultAlignment().value).toEqual(Alignments.JUSTIFY);
61
+ expect(editor.commands.getDefaultAlignment().value).toEqual(Alignment.JUSTIFY);
62
62
  });
63
63
 
64
64
  test('should get from preset', () => {
@@ -66,7 +66,7 @@ describe('get value', () => {
66
66
  content: createContent({ alignment: null })
67
67
  });
68
68
 
69
- expect(editor.commands.getAlignment().value).toEqual(Alignments.JUSTIFY);
69
+ expect(editor.commands.getAlignment().value).toEqual(Alignment.JUSTIFY);
70
70
  });
71
71
  });
72
72
 
@@ -77,7 +77,7 @@ describe('change value', () => {
77
77
  });
78
78
 
79
79
  editor.commands.selectAll();
80
- editor.commands.applyAlignment(Alignments.RIGHT);
80
+ editor.commands.applyAlignment(Alignment.RIGHT);
81
81
 
82
82
  expect(editor.getJSON()).toMatchSnapshot();
83
83
  });
@@ -85,12 +85,12 @@ describe('change value', () => {
85
85
  test('should remove value', () => {
86
86
  const editor = createEditor({
87
87
  content: createContent({
88
- alignment: { desktop: Alignments.CENTER }
88
+ alignment: { desktop: Alignment.CENTER }
89
89
  })
90
90
  });
91
91
 
92
92
  editor.commands.selectAll();
93
- editor.commands.removeAlignment(TextSettings.ALIGNMENT);
93
+ editor.commands.removeAlignment(TextSetting.ALIGNMENT);
94
94
 
95
95
  expect(editor.getJSON()).toMatchSnapshot();
96
96
  });
@@ -100,7 +100,7 @@ describe('rendering', () => {
100
100
  test('should render only desktop', () => {
101
101
  const editor = createEditor({
102
102
  content: createContent({
103
- alignment: { desktop: Alignments.CENTER }
103
+ alignment: { desktop: Alignment.CENTER }
104
104
  })
105
105
  });
106
106
 
@@ -111,9 +111,9 @@ describe('rendering', () => {
111
111
  const editor = createEditor({
112
112
  content: createContent({
113
113
  alignment: {
114
- desktop: Alignments.CENTER,
115
- tablet: Alignments.RIGHT,
116
- mobile: Alignments.LEFT
114
+ desktop: Alignment.CENTER,
115
+ tablet: Alignment.RIGHT,
116
+ mobile: Alignment.LEFT
117
117
  }
118
118
  })
119
119
  });
@@ -4,10 +4,10 @@ import { buildTestExtensions } from '../../__tests__/utils';
4
4
  import { createCommand } from '../../utils';
5
5
  import { BackgroundColor } from '../BackgroundColor';
6
6
  import { ContentNormalizer, NodeFactory } from '../../services';
7
- import { TextSettings } from '../../enums';
7
+ import { TextSetting } from '../../enums';
8
8
 
9
9
  const MockStylePreset = Extension.create({
10
- name: TextSettings.STYLE_PRESET,
10
+ name: TextSetting.STYLE_PRESET,
11
11
 
12
12
  addCommands() {
13
13
  return {
@@ -35,7 +35,7 @@ describe('get background color', () => {
35
35
  test('should get from selection', () => {
36
36
  const editor = createEditor({
37
37
  content: createContent(NodeFactory.text('hello world', [
38
- NodeFactory.mark(TextSettings.BACKGROUND_COLOR, { value: 'green' })
38
+ NodeFactory.mark(TextSetting.BACKGROUND_COLOR, { value: 'green' })
39
39
  ]))
40
40
  });
41
41
 
@@ -70,7 +70,7 @@ describe('rendering', () => {
70
70
  test('should render html', () => {
71
71
  const editor = createEditor({
72
72
  content: createContent(NodeFactory.text('hello world', [
73
- NodeFactory.mark(TextSettings.BACKGROUND_COLOR, { value: 'green' })
73
+ NodeFactory.mark(TextSetting.BACKGROUND_COLOR, { value: 'green' })
74
74
  ]))
75
75
  });
76
76