@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.
- package/.eslintrc.js +1 -1
- package/config/build/example.config.js +12 -2
- package/config/build/lib.config.js +10 -2
- package/config/jest/matchers/index.js +0 -2
- package/config/jest/setupTests.js +4 -7
- package/config/jest/typing.d.ts +1 -2
- package/dist/cli.js +2 -7
- package/dist/wysiwyg.css +153 -152
- package/dist/wysiwyg.mjs +3594 -3172
- package/example/example.js +34 -35
- package/jest.config.js +4 -1
- package/lib/Wysiwyg.vue +166 -190
- package/lib/__tests__/utils/buildTestExtensions.js +1 -1
- package/lib/components/base/Button.vue +31 -37
- package/lib/components/base/ButtonToggle.vue +11 -17
- package/lib/components/base/Checkbox.vue +14 -20
- package/lib/components/base/FieldLabel.vue +7 -11
- package/lib/components/base/Icon.vue +31 -43
- package/lib/components/base/Modal.vue +59 -74
- package/lib/components/base/NumberField.vue +65 -80
- package/lib/components/base/Range.vue +46 -56
- package/lib/components/base/ScrollView.vue +13 -21
- package/lib/components/base/TextField.vue +28 -33
- package/lib/components/base/__tests__/Button.test.js +1 -1
- package/lib/components/base/__tests__/Icon.test.js +1 -1
- package/lib/components/base/__tests__/Modal.test.js +21 -13
- package/lib/components/base/__tests__/Range.test.js +1 -1
- package/lib/components/base/__tests__/TextField.test.js +8 -7
- package/lib/components/base/colorPicker/ColorPicker.vue +33 -51
- package/lib/components/base/composables/__tests__/useDeselectionLock.test.js +4 -2
- package/lib/components/base/composables/__tests__/useModalToggler.test.js +3 -1
- package/lib/components/base/composables/__tests__/useScrollView.test.js +3 -1
- package/lib/components/base/dropdown/Dropdown.vue +35 -55
- package/lib/components/base/dropdown/DropdownActivator.vue +38 -66
- package/lib/components/base/dropdown/DropdownDivider.vue +0 -6
- package/lib/components/base/dropdown/DropdownGroup.vue +8 -20
- package/lib/components/base/dropdown/DropdownMenu.vue +8 -21
- package/lib/components/base/dropdown/DropdownOption.vue +27 -45
- package/lib/components/base/dropdown/__tests__/DropdownActivator.test.js +5 -3
- package/lib/components/base/dropdown/__tests__/DropdownOption.test.js +9 -7
- package/lib/components/toolbar/Toolbar.vue +26 -42
- package/lib/components/toolbar/__tests__/Toolbar.test.js +1 -1
- package/lib/components/toolbar/base/__tests__/ToolbarDivider.test.js +1 -1
- package/lib/components/toolbar/controls/AlignmentControl.vue +27 -46
- package/lib/components/toolbar/controls/BackgroundColorControl.vue +5 -26
- package/lib/components/toolbar/controls/CaseStyleControl.vue +10 -32
- package/lib/components/toolbar/controls/FontColorControl.vue +5 -27
- package/lib/components/toolbar/controls/FontFamilyControl.vue +27 -49
- package/lib/components/toolbar/controls/FontSizeControl.vue +9 -29
- package/lib/components/toolbar/controls/FontWeightControl.vue +7 -27
- package/lib/components/toolbar/controls/ItalicControl.vue +6 -27
- package/lib/components/toolbar/controls/LineHeightControl.vue +10 -37
- package/lib/components/toolbar/controls/ListControl.vue +18 -49
- package/lib/components/toolbar/controls/RemoveFormatControl.vue +4 -21
- package/lib/components/toolbar/controls/StrikeThroughControl.vue +5 -25
- package/lib/components/toolbar/controls/StylePresetControl.vue +34 -59
- package/lib/components/toolbar/controls/SuperscriptControl.vue +5 -25
- package/lib/components/toolbar/controls/UnderlineControl.vue +5 -26
- package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +15 -13
- package/lib/components/toolbar/controls/__tests__/BackgroundColorControl.test.js +17 -15
- package/lib/components/toolbar/controls/__tests__/CaseStyleControl.test.js +9 -8
- package/lib/components/toolbar/controls/__tests__/FontColorControl.test.js +17 -15
- package/lib/components/toolbar/controls/__tests__/FontFamilyControl.test.js +14 -12
- package/lib/components/toolbar/controls/__tests__/FontSizeControl.test.js +5 -3
- package/lib/components/toolbar/controls/__tests__/FontWeightControl.test.js +3 -1
- package/lib/components/toolbar/controls/__tests__/ItalicControl.test.js +3 -1
- package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +11 -9
- package/lib/components/toolbar/controls/__tests__/ListControl.test.js +16 -14
- package/lib/components/toolbar/controls/__tests__/RemoveFormatControl.test.js +3 -1
- package/lib/components/toolbar/controls/__tests__/StrikeThroughControl.test.js +3 -1
- package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +3 -1
- package/lib/components/toolbar/controls/__tests__/SuperscriptControl.test.js +3 -1
- package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +3 -1
- package/lib/components/toolbar/controls/composables/__tests__/useRecentFonts.test.js +6 -4
- package/lib/components/toolbar/controls/link/LinkControl.vue +75 -108
- package/lib/components/toolbar/controls/link/LinkControlHeader.vue +8 -14
- package/lib/components/toolbar/controls/link/__tests__/LinkControl.test.js +5 -3
- package/lib/components/toolbar/controls/link/__tests__/LinkControlHeader.test.js +3 -1
- package/lib/components/toolbar/controls/link/composables/__tests__/useLink.test.js +5 -4
- package/lib/components/toolbar/controls/link/destination/LinkControlDestination.vue +28 -47
- package/lib/components/toolbar/controls/link/destination/LinkControlPageBlock.vue +12 -20
- package/lib/components/toolbar/controls/link/destination/LinkControlUrl.vue +18 -26
- package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlPageBlock.test.js +10 -10
- package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlUrl.test.js +12 -10
- package/lib/components/toolbar/layouts/ToolbarDesktop.vue +36 -64
- package/lib/components/toolbar/layouts/ToolbarMobile.vue +38 -66
- package/lib/components/toolbar/layouts/ToolbarPopup.vue +36 -64
- package/lib/composables/__tests__/useEditor.test.js +3 -3
- package/lib/composables/useEditor.js +1 -1
- package/lib/directives/__tests__/outClick.test.js +9 -9
- package/lib/directives/outClick.js +3 -3
- package/lib/extensions/Alignment.js +1 -1
- package/lib/extensions/BackgroundColor.js +1 -1
- package/lib/extensions/CaseStyle.js +1 -1
- package/lib/extensions/DeviceManager.js +1 -1
- package/lib/extensions/FontColor.js +1 -1
- package/lib/extensions/FontFamily.js +2 -2
- package/lib/extensions/FontSize.js +3 -3
- package/lib/extensions/FontStyle.js +1 -1
- package/lib/extensions/FontWeight.js +1 -1
- package/lib/extensions/LineHeight.js +1 -1
- package/lib/extensions/Link.js +1 -1
- package/lib/extensions/Margin.js +1 -1
- package/lib/extensions/StylePreset.js +9 -9
- package/lib/extensions/Superscript.js +1 -1
- package/lib/extensions/TextDecoration.js +1 -1
- package/lib/extensions/__tests__/Alignment.test.js +1 -1
- package/lib/extensions/__tests__/BackgroundColor.test.js +1 -1
- package/lib/extensions/__tests__/CaseStyle.test.js +1 -1
- package/lib/extensions/__tests__/FontColor.test.js +1 -1
- package/lib/extensions/__tests__/FontFamily.test.js +1 -1
- package/lib/extensions/__tests__/FontSize.test.js +1 -1
- package/lib/extensions/__tests__/FontStyle.test.js +1 -1
- package/lib/extensions/__tests__/FontWeight.test.js +1 -1
- package/lib/extensions/__tests__/LineHeight.test.js +1 -1
- package/lib/extensions/__tests__/Link.test.js +1 -1
- package/lib/extensions/__tests__/StylePreset.test.js +1 -1
- package/lib/extensions/__tests__/Superscript.test.js +1 -1
- package/lib/extensions/__tests__/TextDecoration.test.js +1 -1
- package/lib/extensions/core/NodeProcessor.js +1 -1
- package/lib/extensions/core/SelectionProcessor.js +1 -1
- package/lib/extensions/core/TextProcessor.js +1 -1
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +1 -1
- package/lib/extensions/core/__tests__/SelectionProcessor.test.js +1 -1
- package/lib/extensions/core/__tests__/TextProcessor.test.js +1 -1
- package/lib/extensions/core/index.js +1 -1
- package/lib/extensions/index.js +1 -1
- package/lib/extensions/list/List.js +4 -4
- package/lib/extensions/list/__tests__/List.test.js +1 -1
- package/package.json +19 -20
- package/config/jest/matchers/toVueEmpty.js +0 -16
- package/config/jest/matchers/toVuexActionHasBeenDispatched.js +0 -19
- package/lib/components/base/__tests__/__snapshots__/TextField.test.js.snap +0 -9
- package/lib/components/base/dropdown/__tests__/DropdownMenu.test.js +0 -67
package/example/example.js
CHANGED
|
@@ -1,42 +1,41 @@
|
|
|
1
|
-
import
|
|
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
|
-
(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
renderPresets();
|
|
7
|
+
tooltipManager.init();
|
|
8
|
+
loadFonts();
|
|
9
|
+
renderPresets();
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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/
|
|
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-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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" />
|
|
@@ -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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
event: 'change'
|
|
13
|
+
<script setup>
|
|
14
|
+
defineProps({
|
|
15
|
+
value: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true
|
|
19
18
|
},
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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>
|