tiptapify 0.0.5 → 0.0.7
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/README.md +7 -1
- package/dist/tiptapify.css +1 -1
- package/dist/{tiptapify.es.js → tiptapify.mjs} +52867 -51790
- package/dist/tiptapify.umd.js +41 -43
- package/package.json +8 -8
- package/src/components/Footer.vue +5 -6
- package/src/components/MenuBubble.vue +61 -47
- package/src/components/MenuFloating.vue +38 -34
- package/src/components/Tiptapify.vue +139 -23
- package/src/components/Toolbar/Group.vue +43 -0
- package/src/components/Toolbar/GroupDropdown.vue +85 -0
- package/src/components/Toolbar/Index.vue +51 -79
- package/src/components/Toolbar/Toggle.vue +33 -0
- package/src/components/Toolbar/items/actions.ts +32 -0
- package/src/components/Toolbar/items/alignment.ts +60 -0
- package/src/components/Toolbar/items/format.ts +73 -0
- package/src/components/Toolbar/items/formatExtra.ts +73 -0
- package/src/components/Toolbar/items/list.ts +70 -0
- package/src/components/Toolbar/items/media.ts +202 -0
- package/src/components/Toolbar/items/misc.ts +59 -0
- package/src/components/Toolbar/items/style.ts +146 -0
- package/src/components/Toolbar/items.ts +73 -545
- package/src/components/editorExtensions.ts +6 -4
- package/src/components/index.ts +13 -0
- package/src/{components/extensions → extensions}/components/LinkDialog.vue +11 -8
- package/src/extensions/components/PreviewDialog.vue +45 -0
- package/src/{components/extensions/components/ShowSource.vue → extensions/components/ShowSourceDialog.vue} +11 -7
- package/src/extensions/components/TableBuilder.vue +138 -0
- package/src/extensions/preview.ts +53 -0
- package/src/{components/extensions → extensions}/view-source.ts +1 -3
- package/src/i18n/locales/de.json +64 -45
- package/src/i18n/locales/en.json +21 -2
- package/src/i18n/locales/es.json +27 -8
- package/src/i18n/locales/fr.json +26 -7
- package/src/i18n/locales/it.json +36 -17
- package/src/i18n/locales/pl.json +28 -9
- package/src/i18n/locales/ru.json +21 -2
- package/src/i18n/locales/ua.json +21 -2
- package/src/utils/helpers.ts +17 -0
- package/src/composable/useEditor.ts +0 -35
- /package/src/{components/extensions → extensions}/components/slashCommands/CommandsList.vue +0 -0
- /package/src/{components/extensions → extensions}/components/slashCommands/suggestion.ts +0 -0
- /package/src/{components/extensions → extensions}/slash-commands.ts +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
1
|
+
import { getActionsItems } from "@tiptapify/components/Toolbar/items/actions";
|
|
2
|
+
import { getAlignmentItems } from "@tiptapify/components/Toolbar/items/alignment";
|
|
3
|
+
import { getFormatExtraItems } from "@tiptapify/components/Toolbar/items/formatExtra";
|
|
4
|
+
import { getFormatItems } from "@tiptapify/components/Toolbar/items/format";
|
|
5
|
+
import { getListItems } from "@tiptapify/components/Toolbar/items/list";
|
|
6
|
+
import { getMediaItems } from "@tiptapify/components/Toolbar/items/media";
|
|
7
|
+
import { getMiscItems } from "@tiptapify/components/Toolbar/items/misc";
|
|
8
|
+
import { getStyleItems } from "@tiptapify/components/Toolbar/items/style";
|
|
9
|
+
import { ComputedRef, Ref, ref } from "vue";
|
|
9
10
|
|
|
10
11
|
interface ToolbarItemAttrs {
|
|
11
12
|
[key: string]: Function | any
|
|
@@ -15,26 +16,33 @@ interface ToolbarItemProps {
|
|
|
15
16
|
[key: string]: any
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
interface ToolbarItem {
|
|
19
|
+
export interface ToolbarItem {
|
|
19
20
|
name: string|number,
|
|
20
21
|
tooltip: string,
|
|
21
22
|
icon: string|ComputedRef<string>,
|
|
22
23
|
noI18n?: boolean,
|
|
23
24
|
enabled: boolean,
|
|
25
|
+
component?: any,
|
|
24
26
|
modelValue?: any,
|
|
25
|
-
section?: string,
|
|
26
27
|
group?: boolean,
|
|
28
|
+
toggle?: boolean,
|
|
27
29
|
props?: ToolbarItemProps,
|
|
28
30
|
attrs?: ToolbarItemAttrs,
|
|
29
|
-
children?: ToolbarItem[],
|
|
31
|
+
children?: ToolbarItems|ToolbarItem[],
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
export interface ToolbarItems {
|
|
33
35
|
[key: string]: ToolbarItem
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
export interface ToolbarItemSection {
|
|
39
|
+
group?: boolean,
|
|
40
|
+
toggle?: boolean,
|
|
41
|
+
items: ToolbarItems,
|
|
42
|
+
}
|
|
43
|
+
|
|
36
44
|
export interface ToolbarItemSections {
|
|
37
|
-
[key: string]:
|
|
45
|
+
[key: string]: ToolbarItemSection
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
export function toolbarItems(
|
|
@@ -44,22 +52,16 @@ export function toolbarItems(
|
|
|
44
52
|
customHeadingLevels: Array<number>,
|
|
45
53
|
toolbarLinkButton: Ref,
|
|
46
54
|
): ToolbarItemSections {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const fontSizes = [6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 32, 48, 64, 96]
|
|
59
|
-
|
|
60
|
-
const lineHeights = [1, 1.5, 2, 3, 4]
|
|
61
|
-
|
|
62
|
-
const allMenuItems: ToolbarItems = {
|
|
55
|
+
const styleItems = ref(getStyleItems(editor.value, fontMeasure, customHeadingLevels))
|
|
56
|
+
const formatItems = ref(getFormatItems(editor.value))
|
|
57
|
+
const formatExtraItems = ref(getFormatExtraItems(editor.value))
|
|
58
|
+
const alignmentItems = ref(getAlignmentItems(editor.value))
|
|
59
|
+
const listItems = ref(getListItems(editor.value))
|
|
60
|
+
const actionsItems = ref(getActionsItems(editor.value))
|
|
61
|
+
const miscItems = ref(getMiscItems(editor.value))
|
|
62
|
+
const mediaItems = ref(getMediaItems(editor.value, toolbarLinkButton))
|
|
63
|
+
|
|
64
|
+
const allMenuItems: ToolbarItemSections = {
|
|
63
65
|
/**
|
|
64
66
|
* todo
|
|
65
67
|
*
|
|
@@ -67,505 +69,20 @@ export function toolbarItems(
|
|
|
67
69
|
* tables
|
|
68
70
|
* media (image, video)
|
|
69
71
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
click: () => editor.value.chain().focus().setParagraph().run()
|
|
79
|
-
},
|
|
80
|
-
props: {
|
|
81
|
-
color: computed(() => editor.value.isActive('heading') ? 'primary' : ''),
|
|
82
|
-
},
|
|
83
|
-
children: [
|
|
84
|
-
{
|
|
85
|
-
name: `paragraph`,
|
|
86
|
-
tooltip: `style.paragraph`,
|
|
87
|
-
icon: mdiIcons[`mdiFormatParagraph`],
|
|
88
|
-
noI18n: true,
|
|
89
|
-
enabled: true,
|
|
90
|
-
props: {
|
|
91
|
-
color: computed(() => {
|
|
92
|
-
return editor.value.isActive('paragraph') ? 'primary' : ''
|
|
93
|
-
}),
|
|
94
|
-
},
|
|
95
|
-
attrs: {
|
|
96
|
-
click: () => editor.value.chain().focus().setParagraph().run()
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
].concat(
|
|
100
|
-
headingLevels.value.map(level => {
|
|
101
|
-
return {
|
|
102
|
-
name: `H${level}`,
|
|
103
|
-
tooltip: `style.headings.h${level}`,
|
|
104
|
-
icon: mdiIcons[`mdiFormatHeader${level}`],
|
|
105
|
-
noI18n: true,
|
|
106
|
-
enabled: true,
|
|
107
|
-
props: {
|
|
108
|
-
color: computed(() => {
|
|
109
|
-
return editor.value.isActive('heading', { level }) ? 'primary' : ''
|
|
110
|
-
}),
|
|
111
|
-
},
|
|
112
|
-
attrs: {
|
|
113
|
-
click: () => editor.value.chain().focus().toggleHeading({ level }).run()
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
})
|
|
117
|
-
)
|
|
118
|
-
},
|
|
119
|
-
fontFamily: {
|
|
120
|
-
name: 'font-family',
|
|
121
|
-
tooltip: 'style.fontFamily',
|
|
122
|
-
icon: mdi.mdiFormatFont,
|
|
123
|
-
section: 'style',
|
|
124
|
-
modelValue: null,
|
|
125
|
-
enabled: true,
|
|
126
|
-
attrs: {
|
|
127
|
-
click: () => editor.value.chain().focus().unsetFontFamily().run()
|
|
128
|
-
},
|
|
129
|
-
children: fonts.map((font) => {
|
|
130
|
-
return {
|
|
131
|
-
name: font.name,
|
|
132
|
-
tooltip: '',
|
|
133
|
-
icon: '',
|
|
134
|
-
enabled: true,
|
|
135
|
-
noI18n: true,
|
|
136
|
-
props: {
|
|
137
|
-
color: computed(() => editor.value.isActive('textStyle', { fontFamily: font.fontFamily }) ? 'primary' : ''),
|
|
138
|
-
style: `font-family: ${font.fontFamily};`
|
|
139
|
-
},
|
|
140
|
-
attrs: {
|
|
141
|
-
click: () => editor.value.chain().focus().setFontFamily(font.fontFamily).run()
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
})
|
|
145
|
-
},
|
|
146
|
-
fontSize: {
|
|
147
|
-
name: 'font-size',
|
|
148
|
-
tooltip: 'style.fontSize',
|
|
149
|
-
icon: mdi.mdiFormatSize,
|
|
150
|
-
section: 'style',
|
|
151
|
-
modelValue: computed(() => editor.value.getAttributes('textStyle').fontSize || null),
|
|
152
|
-
enabled: true,
|
|
153
|
-
attrs: {
|
|
154
|
-
click: () => editor.value.chain().focus().unsetFontSize().run()
|
|
155
|
-
},
|
|
156
|
-
children: fontSizes.map((fontSize) => {
|
|
157
|
-
return {
|
|
158
|
-
name: `${fontSize}${fontMeasure}`,
|
|
159
|
-
tooltip: '',
|
|
160
|
-
icon: '',
|
|
161
|
-
enabled: true,
|
|
162
|
-
noI18n: true,
|
|
163
|
-
props: {
|
|
164
|
-
color: computed(() => editor.value.isActive('textStyle', { fontSizes: fontSize }) ? 'primary' : ''),
|
|
165
|
-
},
|
|
166
|
-
attrs: {
|
|
167
|
-
click: () => editor.value.chain().focus().setFontSize(`${fontSize}${fontMeasure}`).run()
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
})
|
|
171
|
-
},
|
|
172
|
-
lineHeight: {
|
|
173
|
-
name: 'line-height',
|
|
174
|
-
tooltip: 'style.lineHeight',
|
|
175
|
-
icon: mdi.mdiFormatLineHeight,
|
|
176
|
-
section: 'style',
|
|
177
|
-
modelValue: null,
|
|
178
|
-
enabled: true,
|
|
179
|
-
attrs: {
|
|
180
|
-
click: () => editor.value.chain().focus().unsetLineHeight().run()
|
|
181
|
-
},
|
|
182
|
-
children: lineHeights.map((lineHeight) => {
|
|
183
|
-
return {
|
|
184
|
-
name: lineHeight,
|
|
185
|
-
tooltip: '',
|
|
186
|
-
icon: '',
|
|
187
|
-
enabled: true,
|
|
188
|
-
noI18n: true,
|
|
189
|
-
props: {
|
|
190
|
-
color: computed(() => editor.value.isActive('textStyle', { lineHeights: lineHeight }) ? 'primary' : ''),
|
|
191
|
-
},
|
|
192
|
-
attrs: {
|
|
193
|
-
click: () => editor.value.chain().focus().setLineHeight(lineHeight).run()
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
})
|
|
197
|
-
},
|
|
198
|
-
|
|
199
|
-
bold: {
|
|
200
|
-
name: 'bold',
|
|
201
|
-
tooltip: 'format.bold',
|
|
202
|
-
icon: mdi.mdiFormatBold,
|
|
203
|
-
section: 'format',
|
|
204
|
-
enabled: true,
|
|
205
|
-
props: {
|
|
206
|
-
disabled: computed(() => !editor.value.can().chain().focus().toggleBold().run()),
|
|
207
|
-
color: computed(() => editor.value.isActive('bold') ? 'primary' : ''),
|
|
208
|
-
},
|
|
209
|
-
attrs: {
|
|
210
|
-
click: () => editor.value.chain().focus().toggleBold().run()
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
italic: {
|
|
214
|
-
name: 'italic',
|
|
215
|
-
tooltip: 'format.italic',
|
|
216
|
-
icon: mdi.mdiFormatItalic,
|
|
217
|
-
section: 'format',
|
|
218
|
-
enabled: true,
|
|
219
|
-
props: {
|
|
220
|
-
disabled: computed(() => !editor.value.can().chain().focus().toggleItalic().run()),
|
|
221
|
-
color: computed(() => editor.value.isActive('italic') ? 'primary' : ''),
|
|
222
|
-
},
|
|
223
|
-
attrs: {
|
|
224
|
-
click: () => editor.value.chain().focus().toggleItalic().run()
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
strike: {
|
|
228
|
-
name: 'strike',
|
|
229
|
-
tooltip: 'format.strike',
|
|
230
|
-
icon: mdi.mdiFormatStrikethroughVariant,
|
|
231
|
-
section: 'format',
|
|
232
|
-
enabled: true,
|
|
233
|
-
props: {
|
|
234
|
-
disabled: computed(() => !editor.value.can().chain().focus().toggleStrike().run()),
|
|
235
|
-
color: computed(() => editor.value.isActive('strike') ? 'primary' : ''),
|
|
236
|
-
},
|
|
237
|
-
attrs: {
|
|
238
|
-
click: () => editor.value.chain().focus().toggleStrike().run()
|
|
239
|
-
}
|
|
240
|
-
},
|
|
241
|
-
underline: {
|
|
242
|
-
name: 'underline',
|
|
243
|
-
tooltip: 'format.underline',
|
|
244
|
-
icon: mdi.mdiFormatUnderline,
|
|
245
|
-
section: 'format',
|
|
246
|
-
enabled: true,
|
|
247
|
-
props: {
|
|
248
|
-
disabled: computed(() => !editor.value.can().chain().focus().toggleUnderline().run()),
|
|
249
|
-
color: computed(() => editor.value.isActive('underline') ? 'primary' : ''),
|
|
250
|
-
},
|
|
251
|
-
attrs: {
|
|
252
|
-
click: () => editor.value.chain().focus().toggleUnderline().run()
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
highlight: {
|
|
256
|
-
name: 'highlight',
|
|
257
|
-
tooltip: 'format.highlight',
|
|
258
|
-
icon: mdi.mdiMarker,
|
|
259
|
-
section: 'format',
|
|
260
|
-
enabled: true,
|
|
261
|
-
props: {
|
|
262
|
-
disabled: computed(() => !editor.value.can().chain().focus().toggleHighlight().run()),
|
|
263
|
-
color: computed(() => editor.value.isActive('highlight') ? 'primary' : ''),
|
|
264
|
-
},
|
|
265
|
-
attrs: {
|
|
266
|
-
click: () => editor.value.chain().focus().toggleHighlight().run()
|
|
267
|
-
}
|
|
268
|
-
},
|
|
269
|
-
formatClear: {
|
|
270
|
-
name: 'format clear',
|
|
271
|
-
tooltip: 'format.formatClear',
|
|
272
|
-
icon: mdi.mdiFormatClear,
|
|
273
|
-
section: 'format',
|
|
274
|
-
enabled: true,
|
|
275
|
-
props: {
|
|
276
|
-
disabled: computed(() => !editor.value.can().chain().focus().unsetAllMarks().run()),
|
|
277
|
-
},
|
|
278
|
-
attrs: {
|
|
279
|
-
click: () => editor.value.chain().focus().unsetAllMarks().clearNodes().run()
|
|
280
|
-
}
|
|
281
|
-
},
|
|
282
|
-
|
|
283
|
-
code: {
|
|
284
|
-
name: 'code',
|
|
285
|
-
tooltip: 'format.code',
|
|
286
|
-
icon: mdi.mdiXml,
|
|
287
|
-
section: 'format_extra',
|
|
288
|
-
enabled: true,
|
|
289
|
-
props: {
|
|
290
|
-
disabled: computed(() => !editor.value.can().chain().focus().toggleCode().run()),
|
|
291
|
-
color: computed(() => editor.value.isActive('code') ? 'primary' : ''),
|
|
292
|
-
},
|
|
293
|
-
attrs: {
|
|
294
|
-
click: () => editor.value.chain().focus().toggleCode().run()
|
|
295
|
-
}
|
|
296
|
-
},
|
|
297
|
-
codeBlock: {
|
|
298
|
-
name: 'codeblock',
|
|
299
|
-
tooltip: 'format.codeblock',
|
|
300
|
-
icon: mdi.mdiCodeBlockTags,
|
|
301
|
-
section: 'format_extra',
|
|
302
|
-
enabled: true,
|
|
303
|
-
props: {
|
|
304
|
-
disabled: computed(() => !editor.value.can().chain().focus().toggleCodeBlock().run()),
|
|
305
|
-
color: computed(() => editor.value.isActive('codeBlock') ? 'primary' : ''),
|
|
306
|
-
},
|
|
307
|
-
attrs: {
|
|
308
|
-
click: () => editor.value.chain().focus().toggleCodeBlock().run()
|
|
309
|
-
}
|
|
310
|
-
},
|
|
311
|
-
blockquote: {
|
|
312
|
-
name: 'blockquote',
|
|
313
|
-
tooltip: 'format.blockquote',
|
|
314
|
-
icon: mdi.mdiCommentQuote,
|
|
315
|
-
section: 'format_extra',
|
|
316
|
-
enabled: true,
|
|
317
|
-
props: {
|
|
318
|
-
disabled: computed(() => !editor.value.can().chain().focus().toggleBlockquote().run()),
|
|
319
|
-
color: computed(() => editor.value.isActive('blockquote') ? 'primary' : ''),
|
|
320
|
-
},
|
|
321
|
-
attrs: {
|
|
322
|
-
click: () => editor.value.chain().focus().toggleBlockquote().run()
|
|
323
|
-
}
|
|
324
|
-
},
|
|
325
|
-
|
|
326
|
-
sup: {
|
|
327
|
-
name: 'sup',
|
|
328
|
-
tooltip: 'format.sup',
|
|
329
|
-
icon: mdi.mdiFormatSuperscript,
|
|
330
|
-
enabled: true,
|
|
331
|
-
props: {
|
|
332
|
-
disabled: computed(() => !editor.value.can().chain().focus().toggleSuperscript().run()),
|
|
333
|
-
color: computed(() => editor.value.isActive('superscript') ? 'primary' : ''),
|
|
334
|
-
},
|
|
335
|
-
attrs: {
|
|
336
|
-
click: () => editor.value.chain().focus().toggleSuperscript().run()
|
|
337
|
-
}
|
|
338
|
-
},
|
|
339
|
-
sub: {
|
|
340
|
-
name: 'sub',
|
|
341
|
-
tooltip: 'format.sub',
|
|
342
|
-
icon: mdi.mdiFormatSubscript,
|
|
343
|
-
enabled: true,
|
|
344
|
-
props: {
|
|
345
|
-
disabled: computed(() => !editor.value.can().chain().focus().toggleSubscript().run()),
|
|
346
|
-
color: computed(() => editor.value.isActive('subscript') ? 'primary' : ''),
|
|
347
|
-
},
|
|
348
|
-
attrs: {
|
|
349
|
-
click: () => editor.value.chain().focus().toggleSubscript().run()
|
|
350
|
-
}
|
|
351
|
-
},
|
|
352
|
-
|
|
353
|
-
alignment: {
|
|
354
|
-
name: 'alignment',
|
|
355
|
-
tooltip: 'alignment',
|
|
356
|
-
icon: '',
|
|
357
|
-
section: 'alignment',
|
|
358
|
-
enabled: true,
|
|
359
|
-
group: true,
|
|
360
|
-
children: [
|
|
361
|
-
{
|
|
362
|
-
name: 'alignments.left',
|
|
363
|
-
tooltip: 'alignments.left',
|
|
364
|
-
icon: mdi.mdiFormatAlignLeft,
|
|
365
|
-
enabled: true,
|
|
366
|
-
props: {
|
|
367
|
-
color: computed(() => editor.value.isActive('text-align', { align: 'left' }) ? 'primary' : ''),
|
|
368
|
-
},
|
|
369
|
-
attrs: {
|
|
370
|
-
click: () => editor.value.chain().focus().toggleTextAlign('left').run()
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
name: 'alignments.center',
|
|
375
|
-
tooltip: 'alignments.center',
|
|
376
|
-
icon: mdi.mdiFormatAlignCenter,
|
|
377
|
-
enabled: true,
|
|
378
|
-
props: {
|
|
379
|
-
color: computed(() => editor.value.isActive('text-align', { align: 'center' }) ? 'primary' : ''),
|
|
380
|
-
},
|
|
381
|
-
attrs: {
|
|
382
|
-
click: () => editor.value.chain().focus().toggleTextAlign('center').run()
|
|
383
|
-
}
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
name: 'alignments.right',
|
|
387
|
-
tooltip: 'alignments.right',
|
|
388
|
-
icon: mdi.mdiFormatAlignRight,
|
|
389
|
-
enabled: true,
|
|
390
|
-
props: {
|
|
391
|
-
color: computed(() => editor.value.isActive('text-align', { align: 'right' }) ? 'primary' : ''),
|
|
392
|
-
},
|
|
393
|
-
attrs: {
|
|
394
|
-
click: () => editor.value.chain().focus().toggleTextAlign('right').run()
|
|
395
|
-
}
|
|
396
|
-
},
|
|
397
|
-
{
|
|
398
|
-
name: 'alignments.justify',
|
|
399
|
-
tooltip: 'alignments.justify',
|
|
400
|
-
icon: mdi.mdiFormatAlignJustify,
|
|
401
|
-
enabled: true,
|
|
402
|
-
props: {
|
|
403
|
-
color: computed(() => editor.value.isActive('text-align', { align: 'justify' }) ? 'primary' : ''),
|
|
404
|
-
},
|
|
405
|
-
attrs: {
|
|
406
|
-
click: () => editor.value.chain().focus().toggleTextAlign('justify').run()
|
|
407
|
-
}
|
|
408
|
-
},
|
|
409
|
-
]
|
|
410
|
-
},
|
|
411
|
-
|
|
412
|
-
list: {
|
|
413
|
-
name: 'list',
|
|
414
|
-
tooltip: 'list',
|
|
415
|
-
icon: mdi.mdiFormatListGroup,
|
|
416
|
-
section: 'list',
|
|
417
|
-
enabled: true,
|
|
418
|
-
group: true,
|
|
419
|
-
children: [
|
|
420
|
-
{
|
|
421
|
-
name: 'lists.bullet',
|
|
422
|
-
tooltip: 'lists.bullet',
|
|
423
|
-
icon: mdi.mdiFormatListBulleted,
|
|
424
|
-
enabled: true,
|
|
425
|
-
props: {
|
|
426
|
-
color: computed(() => editor.value.isActive('bulletList') ? 'primary' : ''),
|
|
427
|
-
},
|
|
428
|
-
attrs: {
|
|
429
|
-
click: () => editor.value.chain().focus().toggleBulletList().run()
|
|
430
|
-
}
|
|
431
|
-
},
|
|
432
|
-
{
|
|
433
|
-
name: 'lists.numbered',
|
|
434
|
-
tooltip: 'lists.numbered',
|
|
435
|
-
icon: mdi.mdiFormatListNumbered,
|
|
436
|
-
enabled: true,
|
|
437
|
-
props: {
|
|
438
|
-
color: computed(() => editor.value.isActive('orderedList') ? 'primary' : ''),
|
|
439
|
-
},
|
|
440
|
-
attrs: {
|
|
441
|
-
click: () => editor.value.chain().focus().toggleOrderedList().run()
|
|
442
|
-
}
|
|
443
|
-
},
|
|
444
|
-
{
|
|
445
|
-
name: 'lists.task',
|
|
446
|
-
tooltip: 'lists.task',
|
|
447
|
-
icon: mdi.mdiFormatListChecks,
|
|
448
|
-
enabled: true,
|
|
449
|
-
props: {
|
|
450
|
-
color: computed(() => editor.value.isActive('taskList') ? 'primary' : ''),
|
|
451
|
-
},
|
|
452
|
-
attrs: {
|
|
453
|
-
click: () => editor.value.chain().focus().toggleTaskList().run()
|
|
454
|
-
}
|
|
455
|
-
},
|
|
456
|
-
{
|
|
457
|
-
name: 'lists.indent',
|
|
458
|
-
tooltip: 'lists.indent',
|
|
459
|
-
icon: mdi.mdiFormatIndentIncrease,
|
|
460
|
-
enabled: true,
|
|
461
|
-
props: {
|
|
462
|
-
disabled: computed(() => !editor.value.can().sinkListItem('listItem')),
|
|
463
|
-
active: false,
|
|
464
|
-
},
|
|
465
|
-
attrs: {
|
|
466
|
-
click: () => editor.value.chain().focus().sinkListItem('listItem').run()
|
|
467
|
-
}
|
|
468
|
-
},
|
|
469
|
-
{
|
|
470
|
-
name: 'lists.outdent',
|
|
471
|
-
tooltip: 'lists.outdent',
|
|
472
|
-
icon: mdi.mdiFormatIndentDecrease,
|
|
473
|
-
enabled: true,
|
|
474
|
-
props: {
|
|
475
|
-
disabled: computed(() => !editor.value.can().liftListItem('listItem')),
|
|
476
|
-
active: false,
|
|
477
|
-
},
|
|
478
|
-
attrs: {
|
|
479
|
-
click: () => editor.value.chain().focus().liftListItem('listItem').run()
|
|
480
|
-
}
|
|
481
|
-
},
|
|
482
|
-
]
|
|
483
|
-
},
|
|
484
|
-
|
|
485
|
-
link: {
|
|
486
|
-
name: 'format.link',
|
|
487
|
-
tooltip: 'format.link',
|
|
488
|
-
icon: computed(() => editor.value.isActive('link') ? mdi.mdiLinkOff : mdi.mdiLink),
|
|
489
|
-
section: 'media',
|
|
490
|
-
enabled: true,
|
|
491
|
-
props: {
|
|
492
|
-
color: computed(() => editor.value.isActive('link') ? 'primary' : ''),
|
|
493
|
-
disabled: computed(() => editor.value.isActive('code') || editor.value.isActive('codeBlock')),
|
|
494
|
-
},
|
|
495
|
-
attrs: {
|
|
496
|
-
click: computed(() => {
|
|
497
|
-
return editor.value.isActive('link')
|
|
498
|
-
? editor.value.chain().focus().unsetLink().run
|
|
499
|
-
: toolbarLinkButton.value?.open
|
|
500
|
-
})
|
|
501
|
-
}
|
|
502
|
-
},
|
|
503
|
-
|
|
504
|
-
undo: {
|
|
505
|
-
name: 'undo',
|
|
506
|
-
tooltip: 'action.undo',
|
|
507
|
-
icon: mdi.mdiUndo,
|
|
508
|
-
section: 'actions',
|
|
509
|
-
enabled: true,
|
|
510
|
-
props: {
|
|
511
|
-
disabled: computed(() => !editor.value.can().chain().focus().undo().run()),
|
|
512
|
-
},
|
|
513
|
-
attrs: {
|
|
514
|
-
click: () => editor.value.chain().focus().undo().run()
|
|
515
|
-
}
|
|
516
|
-
},
|
|
517
|
-
redo: {
|
|
518
|
-
name: 'redo',
|
|
519
|
-
tooltip: 'action.redo',
|
|
520
|
-
icon: mdi.mdiRedo,
|
|
521
|
-
section: 'actions',
|
|
522
|
-
enabled: true,
|
|
523
|
-
props: {
|
|
524
|
-
disabled: computed(() => !editor.value.can().chain().focus().redo().run()),
|
|
525
|
-
},
|
|
526
|
-
attrs: {
|
|
527
|
-
click: () => editor.value.chain().focus().redo().run()
|
|
528
|
-
}
|
|
529
|
-
},
|
|
530
|
-
|
|
531
|
-
line: {
|
|
532
|
-
name: 'line',
|
|
533
|
-
tooltip: 'format.line',
|
|
534
|
-
icon: mdi.mdiMinus,
|
|
535
|
-
section: 'misc',
|
|
536
|
-
enabled: true,
|
|
537
|
-
props: {},
|
|
538
|
-
attrs: {
|
|
539
|
-
click: () => editor.value.chain().focus().setHorizontalRule().run()
|
|
540
|
-
}
|
|
541
|
-
},
|
|
542
|
-
break: {
|
|
543
|
-
name: 'break',
|
|
544
|
-
tooltip: 'format.break',
|
|
545
|
-
icon: mdi.mdiFormatPageBreak,
|
|
546
|
-
section: 'misc',
|
|
547
|
-
enabled: true,
|
|
548
|
-
props: {},
|
|
549
|
-
attrs: {
|
|
550
|
-
click: () => editor.value.chain().focus().setHardBreak().run()
|
|
551
|
-
}
|
|
552
|
-
},
|
|
553
|
-
source: {
|
|
554
|
-
name: 'source',
|
|
555
|
-
tooltip: 'misc.source',
|
|
556
|
-
icon: mdi.mdiCodeTags,
|
|
557
|
-
section: 'misc',
|
|
558
|
-
enabled: true,
|
|
559
|
-
props: {},
|
|
560
|
-
attrs: {
|
|
561
|
-
click: () => editor.value.commands.showSource()
|
|
562
|
-
}
|
|
563
|
-
},
|
|
72
|
+
style: { group: true, items: styleItems.value },
|
|
73
|
+
format: { group: true, items: formatItems.value },
|
|
74
|
+
format_extra: { group: true, items: formatExtraItems.value },
|
|
75
|
+
media: { group: true, items: mediaItems.value },
|
|
76
|
+
alignment: { toggle: true, items: alignmentItems.value },
|
|
77
|
+
list: { group: true, items: listItems.value },
|
|
78
|
+
actions: { group: true, items: actionsItems.value },
|
|
79
|
+
misc: { group: true, items: miscItems.value },
|
|
564
80
|
}
|
|
565
81
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
82
|
+
const pluginsList: Array<string> = []
|
|
83
|
+
Object.keys(allMenuItems).forEach(section => {
|
|
84
|
+
Object.keys(allMenuItems[section]).forEach(item => pluginsList.push(item))
|
|
85
|
+
})
|
|
569
86
|
|
|
570
87
|
if (items.list.length) {
|
|
571
88
|
items.list.forEach(item => {
|
|
@@ -575,31 +92,42 @@ export function toolbarItems(
|
|
|
575
92
|
})
|
|
576
93
|
}
|
|
577
94
|
|
|
95
|
+
const toolbarItems: ToolbarItemSections = {}
|
|
96
|
+
|
|
578
97
|
const sections = {}
|
|
579
|
-
const toolbarItems: { [key: string]: ToolbarItems } = {}
|
|
580
|
-
pluginsList.forEach(key => {
|
|
581
|
-
const item = allMenuItems[key]
|
|
582
98
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
99
|
+
Object.keys(allMenuItems).forEach(sectionName => {
|
|
100
|
+
const section = allMenuItems[sectionName]
|
|
101
|
+
Object.keys(section.items).forEach(plugin => {
|
|
102
|
+
const item = section.items[plugin]
|
|
103
|
+
|
|
104
|
+
if (items.list.length) {
|
|
105
|
+
item.enabled = items.list.includes(plugin)
|
|
106
|
+
if (items.exclude) {
|
|
107
|
+
item.enabled = !item.enabled
|
|
108
|
+
}
|
|
587
109
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
110
|
+
|
|
111
|
+
if (typeof toolbarItems[sectionName] === 'undefined') {
|
|
112
|
+
sections[sectionName] = 0
|
|
113
|
+
toolbarItems[sectionName] = {
|
|
114
|
+
group: section.group ?? false,
|
|
115
|
+
toggle: section.toggle ?? false,
|
|
116
|
+
items: {},
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
toolbarItems[sectionName].items[plugin] = item
|
|
121
|
+
|
|
122
|
+
if (item.enabled) {
|
|
123
|
+
sections[sectionName]++
|
|
124
|
+
}
|
|
125
|
+
})
|
|
598
126
|
})
|
|
599
127
|
|
|
600
|
-
Object.keys(sections).forEach(
|
|
601
|
-
if (sections[
|
|
602
|
-
delete toolbarItems[
|
|
128
|
+
Object.keys(sections).forEach(sectionName => {
|
|
129
|
+
if (sections[sectionName] === 0) {
|
|
130
|
+
delete toolbarItems[sectionName]
|
|
603
131
|
}
|
|
604
132
|
})
|
|
605
133
|
|
|
@@ -25,9 +25,10 @@ import { CodeBlockLowlight } from '@tiptap/extension-code-block-lowlight'
|
|
|
25
25
|
|
|
26
26
|
import { Link } from '@tiptap/extension-link'
|
|
27
27
|
import CodeBlockComponent from '@tiptapify/components/CodeBlockComponent.vue'
|
|
28
|
-
import { ViewSource } from '@tiptapify/
|
|
29
|
-
import
|
|
30
|
-
import
|
|
28
|
+
import { ViewSource } from '@tiptapify/extensions/view-source'
|
|
29
|
+
import { Preview } from '@tiptapify/extensions/preview'
|
|
30
|
+
import SlashCommands from '@tiptapify/extensions/slash-commands'
|
|
31
|
+
import suggestion from '@tiptapify/extensions/components/slashCommands/suggestion'
|
|
31
32
|
|
|
32
33
|
// load all languages with "all" or common languages with "common"
|
|
33
34
|
import { common, createLowlight } from 'lowlight'
|
|
@@ -94,7 +95,8 @@ export function editorExtensions (placeholder: string, slashCommands: boolean) {
|
|
|
94
95
|
}),
|
|
95
96
|
Placeholder.configure({ placeholder }),
|
|
96
97
|
CharacterCount,
|
|
97
|
-
ViewSource
|
|
98
|
+
ViewSource,
|
|
99
|
+
Preview
|
|
98
100
|
]
|
|
99
101
|
|
|
100
102
|
if (slashCommands) {
|