@zipify/wysiwyg 3.1.2 → 4.0.0-vue3.0

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 (134) hide show
  1. package/.eslintrc.js +1 -1
  2. package/config/build/example.config.js +12 -2
  3. package/config/build/lib.config.js +10 -2
  4. package/config/jest/matchers/index.js +0 -2
  5. package/config/jest/setupTests.js +4 -7
  6. package/config/jest/typing.d.ts +1 -2
  7. package/dist/cli.js +2 -7
  8. package/dist/wysiwyg.css +153 -152
  9. package/dist/wysiwyg.mjs +3594 -3172
  10. package/example/example.js +34 -35
  11. package/jest.config.js +4 -1
  12. package/lib/Wysiwyg.vue +166 -190
  13. package/lib/__tests__/utils/buildTestExtensions.js +1 -1
  14. package/lib/components/base/Button.vue +31 -37
  15. package/lib/components/base/ButtonToggle.vue +11 -17
  16. package/lib/components/base/Checkbox.vue +14 -20
  17. package/lib/components/base/FieldLabel.vue +7 -11
  18. package/lib/components/base/Icon.vue +31 -43
  19. package/lib/components/base/Modal.vue +59 -74
  20. package/lib/components/base/NumberField.vue +65 -80
  21. package/lib/components/base/Range.vue +46 -56
  22. package/lib/components/base/ScrollView.vue +13 -21
  23. package/lib/components/base/TextField.vue +28 -33
  24. package/lib/components/base/__tests__/Button.test.js +1 -1
  25. package/lib/components/base/__tests__/Icon.test.js +1 -1
  26. package/lib/components/base/__tests__/Modal.test.js +21 -13
  27. package/lib/components/base/__tests__/Range.test.js +1 -1
  28. package/lib/components/base/__tests__/TextField.test.js +8 -7
  29. package/lib/components/base/colorPicker/ColorPicker.vue +33 -51
  30. package/lib/components/base/composables/__tests__/useDeselectionLock.test.js +4 -2
  31. package/lib/components/base/composables/__tests__/useModalToggler.test.js +3 -1
  32. package/lib/components/base/composables/__tests__/useScrollView.test.js +3 -1
  33. package/lib/components/base/dropdown/Dropdown.vue +35 -55
  34. package/lib/components/base/dropdown/DropdownActivator.vue +38 -66
  35. package/lib/components/base/dropdown/DropdownDivider.vue +0 -6
  36. package/lib/components/base/dropdown/DropdownGroup.vue +8 -20
  37. package/lib/components/base/dropdown/DropdownMenu.vue +8 -21
  38. package/lib/components/base/dropdown/DropdownOption.vue +27 -45
  39. package/lib/components/base/dropdown/__tests__/DropdownActivator.test.js +5 -3
  40. package/lib/components/base/dropdown/__tests__/DropdownOption.test.js +9 -7
  41. package/lib/components/toolbar/Toolbar.vue +26 -42
  42. package/lib/components/toolbar/__tests__/Toolbar.test.js +1 -1
  43. package/lib/components/toolbar/base/__tests__/ToolbarDivider.test.js +1 -1
  44. package/lib/components/toolbar/controls/AlignmentControl.vue +27 -46
  45. package/lib/components/toolbar/controls/BackgroundColorControl.vue +5 -26
  46. package/lib/components/toolbar/controls/CaseStyleControl.vue +10 -32
  47. package/lib/components/toolbar/controls/FontColorControl.vue +5 -27
  48. package/lib/components/toolbar/controls/FontFamilyControl.vue +27 -49
  49. package/lib/components/toolbar/controls/FontSizeControl.vue +9 -29
  50. package/lib/components/toolbar/controls/FontWeightControl.vue +7 -27
  51. package/lib/components/toolbar/controls/ItalicControl.vue +6 -27
  52. package/lib/components/toolbar/controls/LineHeightControl.vue +10 -37
  53. package/lib/components/toolbar/controls/ListControl.vue +18 -49
  54. package/lib/components/toolbar/controls/RemoveFormatControl.vue +4 -21
  55. package/lib/components/toolbar/controls/StrikeThroughControl.vue +5 -25
  56. package/lib/components/toolbar/controls/StylePresetControl.vue +34 -59
  57. package/lib/components/toolbar/controls/SuperscriptControl.vue +5 -25
  58. package/lib/components/toolbar/controls/UnderlineControl.vue +5 -26
  59. package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +15 -13
  60. package/lib/components/toolbar/controls/__tests__/BackgroundColorControl.test.js +17 -15
  61. package/lib/components/toolbar/controls/__tests__/CaseStyleControl.test.js +9 -8
  62. package/lib/components/toolbar/controls/__tests__/FontColorControl.test.js +17 -15
  63. package/lib/components/toolbar/controls/__tests__/FontFamilyControl.test.js +14 -12
  64. package/lib/components/toolbar/controls/__tests__/FontSizeControl.test.js +5 -3
  65. package/lib/components/toolbar/controls/__tests__/FontWeightControl.test.js +3 -1
  66. package/lib/components/toolbar/controls/__tests__/ItalicControl.test.js +3 -1
  67. package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +11 -9
  68. package/lib/components/toolbar/controls/__tests__/ListControl.test.js +16 -14
  69. package/lib/components/toolbar/controls/__tests__/RemoveFormatControl.test.js +3 -1
  70. package/lib/components/toolbar/controls/__tests__/StrikeThroughControl.test.js +3 -1
  71. package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +3 -1
  72. package/lib/components/toolbar/controls/__tests__/SuperscriptControl.test.js +3 -1
  73. package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +3 -1
  74. package/lib/components/toolbar/controls/composables/__tests__/useRecentFonts.test.js +6 -4
  75. package/lib/components/toolbar/controls/link/LinkControl.vue +75 -108
  76. package/lib/components/toolbar/controls/link/LinkControlHeader.vue +8 -14
  77. package/lib/components/toolbar/controls/link/__tests__/LinkControl.test.js +5 -3
  78. package/lib/components/toolbar/controls/link/__tests__/LinkControlHeader.test.js +3 -1
  79. package/lib/components/toolbar/controls/link/composables/__tests__/useLink.test.js +5 -4
  80. package/lib/components/toolbar/controls/link/destination/LinkControlDestination.vue +28 -47
  81. package/lib/components/toolbar/controls/link/destination/LinkControlPageBlock.vue +12 -20
  82. package/lib/components/toolbar/controls/link/destination/LinkControlUrl.vue +18 -26
  83. package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlPageBlock.test.js +10 -10
  84. package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlUrl.test.js +12 -10
  85. package/lib/components/toolbar/layouts/ToolbarDesktop.vue +36 -64
  86. package/lib/components/toolbar/layouts/ToolbarMobile.vue +38 -66
  87. package/lib/components/toolbar/layouts/ToolbarPopup.vue +36 -64
  88. package/lib/composables/__tests__/useEditor.test.js +3 -3
  89. package/lib/composables/useEditor.js +1 -1
  90. package/lib/directives/__tests__/outClick.test.js +9 -9
  91. package/lib/directives/outClick.js +3 -3
  92. package/lib/extensions/Alignment.js +1 -1
  93. package/lib/extensions/BackgroundColor.js +1 -1
  94. package/lib/extensions/CaseStyle.js +1 -1
  95. package/lib/extensions/DeviceManager.js +1 -1
  96. package/lib/extensions/FontColor.js +1 -1
  97. package/lib/extensions/FontFamily.js +2 -2
  98. package/lib/extensions/FontSize.js +3 -3
  99. package/lib/extensions/FontStyle.js +1 -1
  100. package/lib/extensions/FontWeight.js +1 -1
  101. package/lib/extensions/LineHeight.js +1 -1
  102. package/lib/extensions/Link.js +1 -1
  103. package/lib/extensions/Margin.js +1 -1
  104. package/lib/extensions/StylePreset.js +9 -9
  105. package/lib/extensions/Superscript.js +1 -1
  106. package/lib/extensions/TextDecoration.js +1 -1
  107. package/lib/extensions/__tests__/Alignment.test.js +1 -1
  108. package/lib/extensions/__tests__/BackgroundColor.test.js +1 -1
  109. package/lib/extensions/__tests__/CaseStyle.test.js +1 -1
  110. package/lib/extensions/__tests__/FontColor.test.js +1 -1
  111. package/lib/extensions/__tests__/FontFamily.test.js +1 -1
  112. package/lib/extensions/__tests__/FontSize.test.js +1 -1
  113. package/lib/extensions/__tests__/FontStyle.test.js +1 -1
  114. package/lib/extensions/__tests__/FontWeight.test.js +1 -1
  115. package/lib/extensions/__tests__/LineHeight.test.js +1 -1
  116. package/lib/extensions/__tests__/Link.test.js +1 -1
  117. package/lib/extensions/__tests__/StylePreset.test.js +1 -1
  118. package/lib/extensions/__tests__/Superscript.test.js +1 -1
  119. package/lib/extensions/__tests__/TextDecoration.test.js +1 -1
  120. package/lib/extensions/core/NodeProcessor.js +1 -1
  121. package/lib/extensions/core/SelectionProcessor.js +1 -1
  122. package/lib/extensions/core/TextProcessor.js +1 -1
  123. package/lib/extensions/core/__tests__/NodeProcessor.test.js +1 -1
  124. package/lib/extensions/core/__tests__/SelectionProcessor.test.js +1 -1
  125. package/lib/extensions/core/__tests__/TextProcessor.test.js +1 -1
  126. package/lib/extensions/core/index.js +1 -1
  127. package/lib/extensions/index.js +1 -1
  128. package/lib/extensions/list/List.js +4 -4
  129. package/lib/extensions/list/__tests__/List.test.js +1 -1
  130. package/package.json +19 -20
  131. package/config/jest/matchers/toVueEmpty.js +0 -16
  132. package/config/jest/matchers/toVuexActionHasBeenDispatched.js +0 -19
  133. package/lib/components/base/__tests__/__snapshots__/TextField.test.js.snap +0 -9
  134. package/lib/components/base/dropdown/__tests__/DropdownMenu.test.js +0 -67
@@ -1,42 +1,41 @@
1
- import Vue from 'vue';
1
+ import { createApp, h } from 'vue';
2
2
  import ExampleApp from './ExampleApp';
3
3
  import { loadFonts } from './fonts';
4
4
  import { renderPresets } from './presets';
5
5
  import { tooltipManager } from './tooltip';
6
6
 
7
- (async () => {
8
- tooltipManager.init();
9
- loadFonts();
10
- renderPresets();
7
+ tooltipManager.init();
8
+ loadFonts();
9
+ renderPresets();
11
10
 
12
- if (!sessionStorage.getItem('wswg-data')) {
13
- sessionStorage.setItem('wswg-data', JSON.stringify({
14
- type: 'doc',
15
- content: [
16
- {
17
- type: 'paragraph',
18
- content: [
19
- {
20
- type: 'text',
21
- text: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate deleniti doloremque doloribus nobis praesentium repellendus soluta. Ab distinctio eos eveniet quaerat quia recusandae repellendus. Error optio perferendis qui sapiente sequi.'
22
- }
23
- ]
24
- },
25
- {
26
- type: 'paragraph',
27
- content: [
28
- {
29
- type: 'text',
30
- text: 'Ab et laborum molestias omnis provident soluta suscipit tenetur voluptatum! Accusamus aliquam asperiores blanditiis dolorum enim, inventore ipsa molestias, omnis optio quod rem repellendus reprehenderit saepe, suscipit tempora ullam voluptatibus?'
31
- }
32
- ]
33
- }
34
- ]
35
- }));
36
- }
11
+ if (!sessionStorage.getItem('wswg-data')) {
12
+ sessionStorage.setItem('wswg-data', JSON.stringify({
13
+ type: 'doc',
14
+ content: [
15
+ {
16
+ type: 'paragraph',
17
+ content: [
18
+ {
19
+ type: 'text',
20
+ text: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate deleniti doloremque doloribus nobis praesentium repellendus soluta. Ab distinctio eos eveniet quaerat quia recusandae repellendus. Error optio perferendis qui sapiente sequi.'
21
+ }
22
+ ]
23
+ },
24
+ {
25
+ type: 'paragraph',
26
+ content: [
27
+ {
28
+ type: 'text',
29
+ text: 'Ab et laborum molestias omnis provident soluta suscipit tenetur voluptatum! Accusamus aliquam asperiores blanditiis dolorum enim, inventore ipsa molestias, omnis optio quod rem repellendus reprehenderit saepe, suscipit tempora ullam voluptatibus?'
30
+ }
31
+ ]
32
+ }
33
+ ]
34
+ }));
35
+ }
37
36
 
38
- new Vue({
39
- el: '[data-app]',
40
- render: (h) => h(ExampleApp)
41
- });
42
- })();
37
+ const app = createApp({
38
+ render: () => h(ExampleApp)
39
+ });
40
+
41
+ app.mount('[data-app]');
package/jest.config.js CHANGED
@@ -3,7 +3,7 @@ module.exports = {
3
3
  moduleFileExtensions: ['js', 'json', 'vue', 'scss'],
4
4
  transform: {
5
5
  '^.+\\.js$': 'babel-jest',
6
- '^.+\\.vue$': '@vue/vue2-jest',
6
+ '^.+\\.vue$': '@vue/vue3-jest',
7
7
  'node_modules/@zipify/.+': 'babel-jest'
8
8
  },
9
9
  transformIgnorePatterns: ['node_modules/(?!@zipify)/'],
@@ -14,6 +14,9 @@ module.exports = {
14
14
  printBasicPrototype: true
15
15
  },
16
16
  testEnvironment: '<rootDir>/config/jest/TestEnvironment.js',
17
+ testEnvironmentOptions: {
18
+ customExportConditions: ['node', 'node-addons']
19
+ },
17
20
  setupFilesAfterEnv: ['<rootDir>/config/jest/setupMatchers.js'],
18
21
  setupFiles: ['<rootDir>/config/jest/setupTests.js'],
19
22
  collectCoverageFrom: ['<rootDir>/lib/**/*.{js,vue}'],
package/lib/Wysiwyg.vue CHANGED
@@ -11,8 +11,8 @@
11
11
  </div>
12
12
  </template>
13
13
 
14
- <script>
15
- import { EditorContent } from '@tiptap/vue-2';
14
+ <script setup>
15
+ import { EditorContent } from '@tiptap/vue-3';
16
16
  import { provide, toRef, ref, computed } from 'vue';
17
17
  import { Toolbar } from './components';
18
18
  import { useToolbar, useEditor } from './composables';
@@ -20,200 +20,176 @@ import { buildExtensions } from './extensions';
20
20
  import { InjectionTokens } from './injectionTokens';
21
21
  import { ContextWindow, FavoriteColors, Storage } from './services';
22
22
  import { Devices } from './enums';
23
- import { outClick } from './directives';
24
23
  import { Font } from './models';
25
24
 
26
25
  const MIN_FONT_SIZE = 5;
27
26
  const MAX_FONT_SIZE = 112;
28
27
 
29
- export default {
30
- name: 'Wysiwyg',
31
-
32
- components: {
33
- Toolbar,
34
- EditorContent
35
- },
36
-
37
- directives: {
38
- outClick
39
- },
40
-
41
- props: {
42
- value: {
43
- type: [String, Object],
44
- required: true
45
- },
46
-
47
- presets: {
48
- type: Array,
49
- required: true
50
- },
51
-
52
- defaultPresetId: {
53
- type: [Number, String],
54
- required: true
55
- },
56
-
57
- linkPresetId: {
58
- type: [Number, String],
59
- required: true
60
- },
61
-
62
- basePresetClass: {
63
- type: String,
64
- required: true
65
- },
66
-
67
- makePresetVariable: {
68
- type: Function,
69
- required: true
70
- },
71
-
72
- fonts: {
73
- type: Array,
74
- required: true
75
- },
76
-
77
- active: {
78
- type: Boolean,
79
- required: true
80
- },
81
-
82
- device: {
83
- type: String,
84
- required: false,
85
- default: Devices.DESKTOP
86
- },
87
-
88
- favoriteColors: {
89
- type: Array,
90
- required: false,
91
- default: () => []
92
- },
93
-
94
- toolbarOffsets: {
95
- type: Array,
96
- required: false,
97
- default: () => [0, 8]
98
- },
99
-
100
- toolbarPlacement: {
101
- type: String,
102
- required: false,
103
- default: 'top-start'
104
- },
105
-
106
- baseListClass: {
107
- type: String,
108
- required: false,
109
- default: 'zw-list--'
110
- },
111
-
112
- pageBlocks: {
113
- type: Array,
114
- required: true
115
- },
116
-
117
- readonly: {
118
- type: Boolean,
119
- required: false,
120
- default: false
121
- },
122
-
123
- // Temporary until migrations static accordion to sidebar
124
- popupMode: {
125
- type: Boolean,
126
- required: false,
127
- default: false
128
- },
129
-
130
- // Requires Window type but it different in iframe and outside
131
- // eslint-disable-next-line vue/require-prop-types
132
- window: {
133
- required: false,
134
- default: () => window
135
- }
136
- },
137
-
138
- emits: [
139
- 'input',
140
- 'update-favorite-colors'
141
- ],
142
-
143
- setup(props, { emit }) {
144
- ContextWindow.use(props.window);
145
-
146
- const fonts = props.fonts.map((font) => new Font(font));
147
- const toolbarRef = ref(null);
148
- const wysiwygRef = ref(null);
149
- const wrapperRef = computed(() => wysiwygRef.value?.$el || document.body);
150
- const isToolbarActiveRef = computed(() => props.active && !props.readonly);
151
-
152
- const toolbar = useToolbar({
153
- wrapperRef: wysiwygRef,
154
- placementRef: toRef(props, 'toolbarPlacement'),
155
- isActiveRef: isToolbarActiveRef,
156
- offsets: props.toolbarOffsets
157
- });
158
- const updateToolbar = () => toolbar.update();
159
-
160
- function onChange(content) {
161
- emit('input', content);
162
- updateToolbar();
163
- }
164
-
165
- const pageBlocks = toRef(props, 'pageBlocks');
166
-
167
- const { editor, getContent } = useEditor({
168
- content: toRef(props, 'value'),
169
- onChange: (content) => onChange(content),
170
- isReadonlyRef: toRef(props, 'readonly'),
171
-
172
- extensions: buildExtensions({
173
- fonts,
174
- minFontSize: MIN_FONT_SIZE,
175
- maxFontSize: MAX_FONT_SIZE,
176
- presetsRef: toRef(props, 'presets'),
177
- defaultPresetId: props.defaultPresetId,
178
- linkPresetId: props.linkPresetId,
179
- makePresetVariable: props.makePresetVariable,
180
- basePresetClass: props.basePresetClass,
181
- baseListClass: props.baseListClass,
182
- deviceRef: toRef(props, 'device'),
183
- pageBlocksRef: pageBlocks,
184
- wrapperRef
185
- })
186
- });
187
-
188
- const fontSizes = new Array(MAX_FONT_SIZE - MIN_FONT_SIZE + 1)
189
- .fill(0)
190
- .map((_, index) => String(index + MIN_FONT_SIZE));
191
-
192
- const favoriteColors = new FavoriteColors({
193
- listRef: toRef(props, 'favoriteColors'),
194
- triggerUpdate: (colors) => emit('update-favorite-colors', colors)
195
- });
196
-
197
- const getContentCustomization = () => editor.commands.getContentCustomization();
198
-
199
- provide(InjectionTokens.EDITOR, editor);
200
- provide(InjectionTokens.FONTS, fonts);
201
- provide(InjectionTokens.FONT_SIZES, fontSizes);
202
- provide(InjectionTokens.LOCAL_STORAGE, new Storage(localStorage));
203
- provide(InjectionTokens.FAVORITE_COLORS, favoriteColors);
204
- provide(InjectionTokens.PAGE_BLOCKS, pageBlocks);
205
-
206
- return {
207
- editor,
208
- toolbarRef,
209
- wysiwygRef,
210
- toolbar,
211
- updateToolbar,
212
- getContent,
213
- getContentCustomization
214
- };
28
+ const props = defineProps({
29
+ modelValue: {
30
+ type: [String, Object],
31
+ required: true
32
+ },
33
+
34
+ presets: {
35
+ type: Array,
36
+ required: true
37
+ },
38
+
39
+ defaultPresetId: {
40
+ type: [Number, String],
41
+ required: true
42
+ },
43
+
44
+ linkPresetId: {
45
+ type: [Number, String],
46
+ required: true
47
+ },
48
+
49
+ basePresetClass: {
50
+ type: String,
51
+ required: true
52
+ },
53
+
54
+ makePresetVariable: {
55
+ type: Function,
56
+ required: true
57
+ },
58
+
59
+ fonts: {
60
+ type: Array,
61
+ required: true
62
+ },
63
+
64
+ active: {
65
+ type: Boolean,
66
+ required: true
67
+ },
68
+
69
+ device: {
70
+ type: String,
71
+ required: false,
72
+ default: Devices.DESKTOP
73
+ },
74
+
75
+ favoriteColors: {
76
+ type: Array,
77
+ required: false,
78
+ default: () => []
79
+ },
80
+
81
+ toolbarOffsets: {
82
+ type: Array,
83
+ required: false,
84
+ default: () => [0, 8]
85
+ },
86
+
87
+ toolbarPlacement: {
88
+ type: String,
89
+ required: false,
90
+ default: 'top-start'
91
+ },
92
+
93
+ baseListClass: {
94
+ type: String,
95
+ required: false,
96
+ default: 'zw-list--'
97
+ },
98
+
99
+ pageBlocks: {
100
+ type: Array,
101
+ required: true
102
+ },
103
+
104
+ readonly: {
105
+ type: Boolean,
106
+ required: false,
107
+ default: false
108
+ },
109
+
110
+ // Temporary until migrations static accordion to sidebar
111
+ popupMode: {
112
+ type: Boolean,
113
+ required: false,
114
+ default: false
115
+ },
116
+
117
+ // Requires Window type but it different in iframe and outside
118
+ // eslint-disable-next-line vue/require-prop-types
119
+ window: {
120
+ required: false,
121
+ default: () => window
215
122
  }
216
- };
123
+ });
124
+
125
+ const emit = defineEmits( [
126
+ 'update:modelValue',
127
+ 'update-favorite-colors'
128
+ ]);
129
+
130
+ ContextWindow.use(props.window);
131
+
132
+ const fonts = props.fonts.map((font) => new Font(font));
133
+ const toolbarRef = ref(null);
134
+ const wysiwygRef = ref(null);
135
+ const wrapperRef = computed(() => wysiwygRef.value?.$el || document.body);
136
+ const isToolbarActiveRef = computed(() => props.active && !props.readonly);
137
+
138
+ const toolbar = useToolbar({
139
+ wrapperRef: wysiwygRef,
140
+ placementRef: toRef(props, 'toolbarPlacement'),
141
+ isActiveRef: isToolbarActiveRef,
142
+ offsets: props.toolbarOffsets
143
+ });
144
+ const updateToolbar = () => toolbar.update();
145
+
146
+ function onChange(content) {
147
+ emit('update:modelValue', content);
148
+ updateToolbar();
149
+ }
150
+
151
+ const pageBlocks = toRef(props, 'pageBlocks');
152
+
153
+ const { editor, getContent } = useEditor({
154
+ content: toRef(props, 'modelValue'),
155
+ onChange: (content) => onChange(content),
156
+ isReadonlyRef: toRef(props, 'readonly'),
157
+
158
+ extensions: buildExtensions({
159
+ fonts,
160
+ minFontSize: MIN_FONT_SIZE,
161
+ maxFontSize: MAX_FONT_SIZE,
162
+ presetsRef: toRef(props, 'presets'),
163
+ defaultPresetId: props.defaultPresetId,
164
+ linkPresetId: props.linkPresetId,
165
+ makePresetVariable: props.makePresetVariable,
166
+ basePresetClass: props.basePresetClass,
167
+ baseListClass: props.baseListClass,
168
+ deviceRef: toRef(props, 'device'),
169
+ pageBlocksRef: pageBlocks,
170
+ wrapperRef
171
+ })
172
+ });
173
+
174
+ const fontSizes = new Array(MAX_FONT_SIZE - MIN_FONT_SIZE + 1)
175
+ .fill(0)
176
+ .map((_, index) => String(index + MIN_FONT_SIZE));
177
+
178
+ const favoriteColors = new FavoriteColors({
179
+ listRef: toRef(props, 'favoriteColors'),
180
+ triggerUpdate: (colors) => emit('update-favorite-colors', colors)
181
+ });
182
+
183
+ const getContentCustomization = () => editor.commands.getContentCustomization();
184
+
185
+ provide(InjectionTokens.EDITOR, editor);
186
+ provide(InjectionTokens.FONTS, fonts);
187
+ provide(InjectionTokens.FONT_SIZES, fontSizes);
188
+ provide(InjectionTokens.LOCAL_STORAGE, new Storage(localStorage));
189
+ provide(InjectionTokens.FAVORITE_COLORS, favoriteColors);
190
+ provide(InjectionTokens.PAGE_BLOCKS, pageBlocks);
191
+
192
+ defineExpose({ getContentCustomization, getContent, updateToolbar });
217
193
  </script>
218
194
 
219
195
  <style src="./styles/main.css" />
@@ -1,4 +1,4 @@
1
- import { Mark } from '@tiptap/vue-2';
1
+ import { Mark } from '@tiptap/vue-3';
2
2
  import { buildCoreExtensions } from '../../extensions/core';
3
3
  import { MarkGroups, TextSettings } from '../../enums';
4
4
 
@@ -10,49 +10,43 @@
10
10
  </button>
11
11
  </template>
12
12
 
13
- <script>
13
+ <script setup>
14
14
  import { computed } from 'vue';
15
15
 
16
- export default {
17
- name: 'Button',
18
-
19
- props: {
20
- skin: {
21
- type: String,
22
- required: false,
23
- validator: (skin) => ['toolbar', 'primary', 'secondary', 'none'].includes(skin),
24
- default: 'none'
25
- },
26
-
27
- active: {
28
- type: Boolean,
29
- required: false,
30
- default: false
31
- },
32
-
33
- disabled: {
34
- type: Boolean,
35
- required: false,
36
- default: false
37
- },
38
-
39
- icon: {
40
- type: Boolean,
41
- required: false,
42
- default: false
43
- }
16
+ const props = defineProps({
17
+ skin: {
18
+ type: String,
19
+ required: false,
20
+ validator: (skin) => ['toolbar', 'primary', 'secondary', 'none'].includes(skin),
21
+ default: 'none'
44
22
  },
45
23
 
46
- setup(props) {
47
- const classes = computed(() => ({
48
- [`zw-button--${props.skin}`]: props.skin !== 'none',
49
- 'zw-button--active': props.active,
50
- 'zw-button--icon': props.icon
51
- }));
24
+ active: {
25
+ type: Boolean,
26
+ required: false,
27
+ default: false
28
+ },
29
+
30
+ disabled: {
31
+ type: Boolean,
32
+ required: false,
33
+ default: false
34
+ },
52
35
 
53
- return { classes };
36
+ icon: {
37
+ type: Boolean,
38
+ required: false,
39
+ default: false
54
40
  }
55
- };
41
+ });
42
+
43
+ defineEmits(['click']);
44
+
45
+ const classes = computed(() => ({
46
+ [`zw-button--${props.skin}`]: props.skin !== 'none',
47
+ 'zw-button--active': props.active,
48
+ 'zw-button--icon': props.icon
49
+ }));
56
50
  </script>
57
51
 
58
52
  <style scoped>
@@ -10,26 +10,20 @@
10
10
  </div>
11
11
  </template>
12
12
 
13
- <script>
14
- export default {
15
- name: 'ButtonToggle',
16
-
17
- model: {
18
- event: 'change'
13
+ <script setup>
14
+ defineProps({
15
+ value: {
16
+ type: String,
17
+ required: true
19
18
  },
20
19
 
21
- props: {
22
- value: {
23
- type: String,
24
- required: true
25
- },
26
-
27
- options: {
28
- type: Array,
29
- required: true
30
- }
20
+ options: {
21
+ type: Array,
22
+ required: true
31
23
  }
32
- };
24
+ });
25
+
26
+ defineEmits(['change']);
33
27
  </script>
34
28
 
35
29
  <style scoped>
@@ -6,29 +6,23 @@
6
6
  </label>
7
7
  </template>
8
8
 
9
- <script>
10
- export default {
11
- name: 'Checkbox',
12
-
13
- props: {
14
- value: {
15
- type: Boolean,
16
- required: true
17
- },
18
-
19
- label: {
20
- type: String,
21
- required: false,
22
- default: null
23
- }
9
+ <script setup>
10
+ const props = defineProps({
11
+ value: {
12
+ type: Boolean,
13
+ required: true
24
14
  },
25
15
 
26
- setup(props, { emit }) {
27
- const onCheckedChanged = () => emit('input', !props.value);
28
-
29
- return { onCheckedChanged };
16
+ label: {
17
+ type: String,
18
+ required: false,
19
+ default: null
30
20
  }
31
- };
21
+ });
22
+
23
+ const emit = defineEmits(['input']);
24
+
25
+ const onCheckedChanged = () => emit('input', !props.value);
32
26
  </script>
33
27
 
34
28
  <style scoped>
@@ -4,18 +4,14 @@
4
4
  </label>
5
5
  </template>
6
6
 
7
- <script>
8
- export default {
9
- name: 'FieldLabel',
10
-
11
- props: {
12
- fieldId: {
13
- type: String,
14
- required: false,
15
- default: null
16
- }
7
+ <script setup>
8
+ defineProps({
9
+ fieldId: {
10
+ type: String,
11
+ required: false,
12
+ default: null
17
13
  }
18
- };
14
+ });
19
15
  </script>
20
16
 
21
17
  <style scoped>