frappe-ui 1.1.0 → 1.2.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 (103) hide show
  1. package/experimental/Calendar/CalendarEventRow.vue +0 -4
  2. package/experimental/CommandPalette/CommandPaletteItem.vue +9 -1
  3. package/experimental/SpriteIcons/IconPicker.vue +2 -1
  4. package/experimental.ts +0 -21
  5. package/package.json +1 -3
  6. package/src/components/Breadcrumbs/Breadcrumbs.vue +2 -1
  7. package/src/components/DatePicker/DatePicker.md +7 -0
  8. package/src/components/DatePicker/DatePicker.vue +6 -0
  9. package/src/components/DatePicker/DateTimePicker.vue +6 -0
  10. package/src/components/DatePicker/composables.ts +18 -1
  11. package/src/components/DatePicker/utils.ts +53 -0
  12. package/src/components/HoverCard/HoverCard.vue +21 -5
  13. package/src/components/MobileNav/MobileNavItem.vue +3 -22
  14. package/src/components/SettingsDialog/SettingsDialog.api.md +7 -2
  15. package/src/components/SettingsDialog/SettingsDialog.md +2 -1
  16. package/src/components/SettingsDialog/SettingsRow.vue +12 -2
  17. package/src/components/Sidebar/SidebarItem.vue +3 -33
  18. package/src/components/SidebarRail/SidebarRailItem.vue +4 -17
  19. package/src/components/Tooltip/Tooltip.vue +8 -0
  20. package/src/components/shared/deferredTrigger.ts +174 -0
  21. package/src/components/shared/navLink.ts +45 -0
  22. package/src/molecules/editor/extensions/attachment/attachment-engine.ts +1 -1
  23. package/src/molecules/editor/extensions/content-paste/paste-html-utils.ts +16 -6
  24. package/src/molecules/editor/extensions/iframe/IframeNodeView.vue +26 -9
  25. package/src/molecules/editor/extensions/iframe/iframe-allowlist.ts +35 -16
  26. package/src/molecules/editor/extensions/iframe/iframe-embed-utils.ts +1 -1
  27. package/src/molecules/editor/extensions/iframe/iframe-extension.ts +30 -30
  28. package/src/molecules/editor/extensions/link/LinkEditorPopup.vue +1 -1
  29. package/src/molecules/editor/extensions/link/link-paste-plugin.ts +1 -1
  30. package/src/molecules/editor/extensions/shared/media-upload-engine.ts +1 -1
  31. package/src/molecules/list/ListRow.vue +8 -1
  32. package/src/utils/dialog.ts +20 -2
  33. package/src/{molecules/editor/extensions/shared → utils}/url-safety.ts +28 -16
  34. package/tailwind/content.js +0 -1
  35. package/tailwind/plugin.js +22 -0
  36. package/vite/doctypeInterfaceGenerator.js +52 -39
  37. package/vitepress/index.node.ts +0 -2
  38. package/experimental/TextEditor/TextEditor.api.md +0 -161
  39. package/experimental/TextEditor/TextEditor.vue +0 -298
  40. package/experimental/TextEditor/classIcon.ts +0 -21
  41. package/experimental/TextEditor/commands.js +0 -344
  42. package/experimental/TextEditor/components/CodeBlockComponent.vue +0 -103
  43. package/experimental/TextEditor/components/FontColor.vue +0 -153
  44. package/experimental/TextEditor/components/ImageViewerModal.vue +0 -463
  45. package/experimental/TextEditor/components/InsertImage.vue +0 -54
  46. package/experimental/TextEditor/components/InsertLink.vue +0 -13
  47. package/experimental/TextEditor/components/InsertVideo.vue +0 -14
  48. package/experimental/TextEditor/components/LinkPopup.vue +0 -99
  49. package/experimental/TextEditor/components/MediaNodeView.vue +0 -398
  50. package/experimental/TextEditor/components/MentionList.vue +0 -95
  51. package/experimental/TextEditor/components/TextEditorBubbleMenu.vue +0 -78
  52. package/experimental/TextEditor/components/TextEditorFixedMenu.vue +0 -78
  53. package/experimental/TextEditor/components/TextEditorFloatingMenu.vue +0 -61
  54. package/experimental/TextEditor/components/TextEditorMenu.vue +0 -218
  55. package/experimental/TextEditor/components/index.js +0 -0
  56. package/experimental/TextEditor/extensions/code-block.ts +0 -119
  57. package/experimental/TextEditor/extensions/color/color-extension.ts +0 -140
  58. package/experimental/TextEditor/extensions/color/color-styles.css +0 -25
  59. package/experimental/TextEditor/extensions/color/index.ts +0 -2
  60. package/experimental/TextEditor/extensions/content-paste-extension.ts +0 -160
  61. package/experimental/TextEditor/extensions/copy-styles.ts +0 -160
  62. package/experimental/TextEditor/extensions/emoji/EmojiList.vue +0 -55
  63. package/experimental/TextEditor/extensions/emoji/emoji-extension.ts +0 -55
  64. package/experimental/TextEditor/extensions/emoji/emojis.json +0 -7422
  65. package/experimental/TextEditor/extensions/heading/heading.ts +0 -20
  66. package/experimental/TextEditor/extensions/highlight/highlight-extension.ts +0 -241
  67. package/experimental/TextEditor/extensions/highlight/highlight-styles.css +0 -31
  68. package/experimental/TextEditor/extensions/highlight/index.ts +0 -2
  69. package/experimental/TextEditor/extensions/iframe/IframeNodeView.vue +0 -308
  70. package/experimental/TextEditor/extensions/iframe/InsertIframe.vue +0 -209
  71. package/experimental/TextEditor/extensions/iframe/iframe-extension.ts +0 -404
  72. package/experimental/TextEditor/extensions/iframe/index.ts +0 -11
  73. package/experimental/TextEditor/extensions/iframe/utils.ts +0 -283
  74. package/experimental/TextEditor/extensions/image/image-extension.ts +0 -661
  75. package/experimental/TextEditor/extensions/image/index.ts +0 -5
  76. package/experimental/TextEditor/extensions/image-group/ImageGroupNodeView.vue +0 -182
  77. package/experimental/TextEditor/extensions/image-group/ImageGroupUploadDialog.vue +0 -740
  78. package/experimental/TextEditor/extensions/image-group/image-group-extension.ts +0 -187
  79. package/experimental/TextEditor/extensions/image-viewer-extension.ts +0 -162
  80. package/experimental/TextEditor/extensions/link/index.ts +0 -1
  81. package/experimental/TextEditor/extensions/link/link-extension.ts +0 -323
  82. package/experimental/TextEditor/extensions/link/linkPasteHandler.ts +0 -51
  83. package/experimental/TextEditor/extensions/mention/index.ts +0 -1
  84. package/experimental/TextEditor/extensions/mention/mention-extension.ts +0 -204
  85. package/experimental/TextEditor/extensions/mention/style.css +0 -11
  86. package/experimental/TextEditor/extensions/shared/color-utils.ts +0 -236
  87. package/experimental/TextEditor/extensions/slash-commands/SlashCommandsList.vue +0 -59
  88. package/experimental/TextEditor/extensions/slash-commands/slash-commands-extension.ts +0 -184
  89. package/experimental/TextEditor/extensions/suggestion/SuggestionList.vue +0 -130
  90. package/experimental/TextEditor/extensions/suggestion/createSuggestionExtension.ts +0 -151
  91. package/experimental/TextEditor/extensions/suggestion/index.ts +0 -5
  92. package/experimental/TextEditor/extensions/tag/index.ts +0 -1
  93. package/experimental/TextEditor/extensions/tag/tag-extension.ts +0 -170
  94. package/experimental/TextEditor/extensions/toc-node/TocNodeView.vue +0 -439
  95. package/experimental/TextEditor/extensions/toc-node/index.ts +0 -3
  96. package/experimental/TextEditor/extensions/toc-node/toc-node-extension.ts +0 -167
  97. package/experimental/TextEditor/extensions/video-extension.ts +0 -653
  98. package/experimental/TextEditor/hljs-github.css +0 -197
  99. package/experimental/TextEditor/index.ts +0 -21
  100. package/experimental/TextEditor/style.css +0 -190
  101. package/experimental/TextEditor/types.ts +0 -72
  102. package/experimental/TextEditor/utils.js +0 -11
  103. package/src/utils/url-validation.ts +0 -39
@@ -1,398 +0,0 @@
1
- <script setup lang="ts">
2
- // @ts-nocheck -- frozen v0 code, kept out of type-check (see tsconfig.app.json)
3
- import { ref, onMounted, onUnmounted, computed, h } from 'vue'
4
- import { NodeViewWrapper, nodeViewProps } from '@tiptap/vue-3'
5
- import { Button } from '#components/Button'
6
- import { Spinner } from '#components/Spinner'
7
- import Tooltip from '#components/Tooltip/Tooltip.vue'
8
- import { localFileMap } from '../extensions/image/image-extension'
9
- import { ErrorMessage } from '#components/ErrorMessage'
10
- import { classIcon } from '../classIcon'
11
- const LucideAlignLeft = classIcon('lucide-align-left')
12
- const LucideAlignCenter = classIcon('lucide-align-center')
13
- const LucideAlignRight = classIcon('lucide-align-right')
14
- const LucideWrapText = classIcon('lucide-wrap-text')
15
- const LucideFloatLeft = classIcon('lucide-align-horizontal-justify-start')
16
- const LucideFloatRight = classIcon('lucide-align-horizontal-justify-end')
17
- const LucideNoFloat = classIcon('lucide-align-vertical-space-around')
18
- const LucideCaptions = classIcon('lucide-captions')
19
- const LucideMoveDiagonal2 = classIcon('lucide-move-diagonal-2')
20
- const LucideRotateCw = classIcon('lucide-rotate-cw')
21
- const props = defineProps(nodeViewProps)
22
-
23
- const mediaRef = ref<HTMLImageElement | HTMLVideoElement | null>(null)
24
- const containerRef = ref<HTMLDivElement | null>(null)
25
- const isResizing = ref(false)
26
- const startDragX = ref(0)
27
- const startWidth = ref(0)
28
- const originalAspectRatio = ref(1)
29
-
30
- const showAlignPopper = ref(false)
31
- const showFloatPopper = ref(false)
32
- const alignButtonRef = ref<HTMLElement | null>(null)
33
- const floatButtonRef = ref<HTMLElement | null>(null)
34
-
35
- const showCaption = ref(props.node.attrs.alt ? true : false)
36
- const isVideo = computed(() => props.node.type.name === 'video')
37
- const isUploaded = computed(() => Boolean(props.node.attrs.src))
38
- const fileContent = computed(() => localFileMap.get(props.node.attrs.uploadId)?.b64)
39
-
40
- const currentAlignIcon = computed(() => {
41
- return (
42
- {
43
- left: LucideAlignLeft,
44
- center: LucideAlignCenter,
45
- right: LucideAlignRight,
46
- }[props.node.attrs.align] || LucideAlignLeft
47
- )
48
- })
49
-
50
- const currentFloatIcon = computed(() => {
51
- return (
52
- {
53
- left: LucideFloatLeft,
54
- right: LucideFloatRight,
55
- }[props.node.attrs.float] || LucideWrapText
56
- )
57
- })
58
-
59
- function selectMedia() {
60
- props.editor.commands.setNodeSelection(props.getPos())
61
- }
62
-
63
- const caption = ref(props.node.attrs.alt || '')
64
- const isEditable = ref(false)
65
-
66
- onMounted(() => {
67
- isEditable.value = props.editor.isEditable
68
- if (mediaRef.value) {
69
- updateAspectRatio()
70
- }
71
-
72
- document.addEventListener('click', handleClickOutside)
73
- })
74
-
75
- onUnmounted(() => {
76
- document.removeEventListener('click', handleClickOutside)
77
- })
78
-
79
- function handleClickOutside(event: MouseEvent) {
80
- const target = event.target as HTMLElement
81
- if (alignButtonRef.value && !alignButtonRef.value.contains(target)) {
82
- showAlignPopper.value = false
83
- }
84
- if (floatButtonRef.value && !floatButtonRef.value.contains(target)) {
85
- showFloatPopper.value = false
86
- }
87
- }
88
-
89
- props.editor.on('update', () => {
90
- isEditable.value = props.editor.isEditable
91
- })
92
-
93
- function updateAspectRatio() {
94
- if (!mediaRef.value) return
95
-
96
- let width, height
97
- if (isVideo.value) {
98
- const video = mediaRef.value as HTMLVideoElement
99
- width = props.node.attrs.width || video.videoWidth
100
- height = props.node.attrs.height || video.videoHeight
101
- } else {
102
- const img = mediaRef.value as HTMLImageElement
103
- width = props.node.attrs.width || img.naturalWidth
104
- height = props.node.attrs.height || img.naturalHeight
105
- }
106
-
107
- if (width && height) {
108
- originalAspectRatio.value = height / width
109
- }
110
- }
111
-
112
- function handleMediaLoaded() {
113
- updateAspectRatio()
114
- }
115
-
116
- function updateCaption(event: Event) {
117
- const newCaption = (event.target as HTMLInputElement).value
118
- caption.value = newCaption
119
- props.updateAttributes({ alt: newCaption })
120
- }
121
-
122
- function handleKeydown(event: KeyboardEvent) {
123
- if (event.key === 'Enter') {
124
- event.preventDefault()
125
- createParagraphAfterMedia()
126
- } else if (event.key === 'Escape' || event.key === 'ArrowDown') {
127
- event.preventDefault()
128
- setCursorAfterMedia()
129
- }
130
- if (event.key === 'ArrowUp') {
131
- event.preventDefault()
132
- setCursorBeforeMedia()
133
- }
134
- if (event.key === 'Backspace' && caption.value === '') {
135
- event.preventDefault()
136
- toggleCaptions()
137
- }
138
- }
139
-
140
- function setCursorAt(pos: number) {
141
- props.editor.commands.focus()
142
- props.editor.chain().setTextSelection(pos).scrollIntoView().run()
143
- }
144
-
145
- function createParagraphAfterMedia() {
146
- const pos = props.getPos()
147
- props.editor.commands.focus()
148
- props.editor
149
- .chain()
150
- .setTextSelection(pos + 1)
151
- .createParagraphNear()
152
- .scrollIntoView()
153
- .run()
154
- }
155
-
156
- function setCursorAfterMedia() {
157
- const pos = props.getPos()
158
- setCursorAt(pos + 1)
159
- }
160
-
161
- function setCursorBeforeMedia() {
162
- const pos = props.getPos()
163
- setCursorAt(pos - 1)
164
- }
165
-
166
- function startResize(event: MouseEvent) {
167
- if (!isEditable.value) return
168
- selectMedia()
169
- isResizing.value = true
170
- startDragX.value = event.clientX
171
- startWidth.value = mediaRef.value?.offsetWidth || props.node.attrs.width || 0
172
-
173
- let width, height
174
- if (isVideo.value) {
175
- const video = mediaRef.value as HTMLVideoElement
176
- width = props.node.attrs.width || video.videoWidth
177
- height = props.node.attrs.height || video.videoHeight
178
- } else {
179
- const img = mediaRef.value as HTMLImageElement
180
- width = props.node.attrs.width || img.naturalWidth
181
- height = props.node.attrs.height || img.naturalHeight
182
- }
183
-
184
- if (width && height) {
185
- originalAspectRatio.value = height / width
186
- } else {
187
- originalAspectRatio.value = 1
188
- }
189
-
190
- window.addEventListener('mousemove', handleResize)
191
- window.addEventListener('mouseup', stopResize)
192
- document.body.style.cursor = 'ew-resize'
193
- }
194
-
195
- function handleResize(event: MouseEvent) {
196
- if (!isResizing.value || !mediaRef.value || !containerRef.value) return
197
-
198
- const editorElement = props.editor.view.dom
199
- const editorWidth = editorElement.clientWidth
200
-
201
- const deltaX = event.clientX - startDragX.value
202
- let newWidth = startWidth.value + deltaX
203
-
204
- newWidth = Math.max(50, Math.min(newWidth, editorWidth))
205
-
206
- const newHeight = newWidth * originalAspectRatio.value
207
-
208
- mediaRef.value.style.width = `${newWidth}px`
209
- mediaRef.value.style.height = `${newHeight}px`
210
- containerRef.value.style.width = `${newWidth}px`
211
- }
212
-
213
- function stopResize() {
214
- if (!isResizing.value) return
215
-
216
- isResizing.value = false
217
- window.removeEventListener('mousemove', handleResize)
218
- window.removeEventListener('mouseup', stopResize)
219
- document.body.style.cursor = ''
220
-
221
- if (mediaRef.value && containerRef.value) {
222
- const finalWidth = mediaRef.value.offsetWidth
223
- const finalHeight = mediaRef.value.offsetHeight
224
- props.updateAttributes({ width: finalWidth, height: finalHeight })
225
-
226
- mediaRef.value.style.width = ''
227
- mediaRef.value.style.height = ''
228
- containerRef.value.style.width = ''
229
- }
230
- }
231
-
232
- function setAlignment(align: 'left' | 'center' | 'right') {
233
- props.editor.commands.setImageAlign(align)
234
- showAlignPopper.value = false
235
- }
236
-
237
- function setFloat(float: 'left' | 'right' | null) {
238
- if (isVideo.value) props.editor.commands.setVideoFloat(float)
239
- else props.editor.commands.setImageFloat(float)
240
- showFloatPopper.value = false
241
- }
242
-
243
- function toggleAlignPopper(event: MouseEvent) {
244
- event.stopPropagation()
245
- showAlignPopper.value = !showAlignPopper.value
246
- showFloatPopper.value = false
247
- }
248
-
249
- function toggleFloatPopper(event: MouseEvent) {
250
- event.stopPropagation()
251
- showFloatPopper.value = !showFloatPopper.value
252
- showAlignPopper.value = false
253
- }
254
-
255
- function toggleCaptions() {
256
- showCaption.value = !showCaption.value
257
- if (!showCaption.value) {
258
- caption.value = ''
259
- props.updateAttributes({ alt: '' })
260
- }
261
- }
262
-
263
- const wrapperClasses = (float: string) => [
264
- 'w-fit m-2',
265
- float === 'right' ? 'float-right ml-5' : 'float-left mr-5',
266
- ]
267
- </script>
268
-
269
- <template>
270
- <NodeViewWrapper as="div" :class="node.attrs.float ? wrapperClasses(node.attrs.float) : 'my-2'">
271
- <div ref="containerRef" class="group relative overflow-hidden not-prose rounded-[2px]" :class="[
272
- {
273
- 'ring-2 ring-outline-gray-3 ring-offset-2': selected,
274
- },
275
- node.attrs.align === 'center' || !node.attrs.align ? 'mx-auto' : '',
276
- node.attrs.align === 'right' ? 'ml-auto mr-0' : '',
277
- node.attrs.align === 'left' ? 'mr-auto ml-0' : '',
278
- !node.attrs.float && 'block max-w-full',
279
- ]" :style="{
280
- width: node.attrs.width ? `${node.attrs.width}px` : 'auto',
281
- }">
282
- <div v-if="isUploaded || fileContent" class="relative">
283
- <img v-if="!isVideo" ref="mediaRef" class="rounded-[2px]" :class="!isUploaded && 'opacity-40'" :src="node.attrs.src || fileContent"
284
- :alt="node.attrs.alt || ''" :width="node.attrs.width" :height="node.attrs.height"
285
- @click.stop="selectMedia" @load="handleMediaLoaded" />
286
- <video v-else ref="mediaRef" class="rounded-[2px]" :class="!isUploaded && 'opacity-40'" :src="node.attrs.src || fileContent"
287
- :width="node.attrs.width" :height="node.attrs.height" :autoplay="node.attrs.autoplay"
288
- :loop="node.attrs.loop" :muted="node.attrs.muted" :controls="isUploaded" @click.stop="selectMedia"
289
- @loadedmetadata="handleMediaLoaded" />
290
-
291
- <div v-if="isUploaded" class="absolute top-2 right-2 items-center bg-black/65 px-1.5 py-1 gap-2 rounded-4"
292
- :class="selected && isEditable ? 'flex' : 'hidden'">
293
- <button>
294
- <LucideCaptions @click="toggleCaptions" class="size-4"
295
- :class="[showCaption ? 'text-ink-base' : 'text-ink-gray-4']" />
296
- </button>
297
- <button v-if="!isVideo" @click.stop="toggleAlignPopper"
298
- class="hover:text-ink-base text-ink-gray-4"
299
- :class="[node.attrs.align ? 'text-ink-base' : 'text-ink-gray-4']">
300
- <component :is="currentAlignIcon" class="size-4" />
301
- </button>
302
- <!-- <button @click.stop="toggleFloatPopper" class="hover:text-ink-base text-ink-gray-4"
303
- :class="[node.attrs.float ? 'text-ink-base' : 'text-ink-gray-4']">
304
- <component :is="currentFloatIcon" class="size-4" />
305
- </button> -->
306
-
307
- <div ref="alignButtonRef" v-if="showAlignPopper && !isVideo"
308
- class="absolute top-full mt-1 right-6 bg-black/65 rounded-4 shadow-lg px-1.5 py-1 z-50 gap-2.5 flex items-center">
309
- <Tooltip text="Align left" class="h-5">
310
- <button @click="setAlignment('left')" class="text-ink-gray-4 hover:text-ink-base" :class="node.attrs.align === 'left'
311
- ? 'text-ink-base'
312
- : 'text-ink-gray-4'
313
- ">
314
- <LucideAlignLeft class="size-4" />
315
- </button>
316
- </Tooltip>
317
- <Tooltip text="Align center" class="h-5">
318
- <button @click="setAlignment('center')" class="text-ink-gray-4 hover:text-ink-base" :class="node.attrs.align === 'center'
319
- ? 'text-ink-base'
320
- : 'text-ink-gray-4'
321
- ">
322
- <LucideAlignCenter class="size-4" />
323
- </button>
324
- </Tooltip>
325
- <Tooltip text="Align right" class="h-5">
326
- <button @click="setAlignment('right')" class="text-ink-gray-4 hover:text-ink-base" :class="node.attrs.align === 'right'
327
- ? 'text-ink-base'
328
- : 'text-ink-gray-4'
329
- ">
330
- <LucideAlignRight class="size-4" />
331
- </button>
332
- </Tooltip>
333
- </div>
334
-
335
- <div v-if="showFloatPopper" ref="floatButtonRef"
336
- class="absolute top-full mt-1 right-0 bg-black/65 rounded-4 shadow-lg px-1.5 py-1 z-50 gap-2.5 flex items-center">
337
- <Tooltip text="Float left" class="h-5">
338
- <button @click="setFloat('left')" class="text-ink-gray-4 hover:text-ink-base" :class="node.attrs.float === 'left'
339
- ? 'text-ink-base'
340
- : 'text-ink-gray-4'
341
- ">
342
- <LucideFloatLeft class="size-4" />
343
- </button>
344
- </Tooltip>
345
- <Tooltip text="Float right" class="h-5">
346
- <button @click="setFloat('right')" class="text-ink-gray-4 hover:text-ink-base" :class="node.attrs.float === 'right'
347
- ? 'text-ink-base'
348
- : 'text-ink-gray-4'
349
- ">
350
- <LucideFloatRight class="size-4" />
351
- </button>
352
- </Tooltip>
353
- <Tooltip v-if="node.attrs.float" text="Remove float" class="h-5">
354
- <button @click="setFloat(null)" class="text-ink-gray-4 hover:text-ink-base hover:bg-transparent">
355
- <LucideNoFloat class="size-4" />
356
- </button>
357
- </Tooltip>
358
- </div>
359
- </div>
360
-
361
- <Button
362
- v-else
363
- variant="solid"
364
- class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2"
365
- :icon-left="h(LucideRotateCw, { class: 'size-4' })"
366
- label="Try again"
367
- @click="isVideo ? editor.commands.reuploadVideo(node.attrs.uploadId) : editor.commands.reuploadImage(node.attrs.uploadId)"
368
- />
369
-
370
- <button v-if="selected && isEditable && isUploaded" class="absolute bottom-2 right-2 cursor-nw-resize bg-black/65 rounded-4 p-1"
371
- @mousedown.prevent="startResize">
372
- <LucideMoveDiagonal2 class="text-white size-4" />
373
- </button>
374
- <div v-if="node.attrs.loading" class="inset-0 absolute flex items-center justify-center z-10">
375
- <div
376
- class="bg-gray-900/80 p-2 inset-0 leading-none rounded-1 flex flex-col items-center justify-center gap-2">
377
- <div class="flex items-center gap-2">
378
- <Spinner class="text-gray-100 size-4" />
379
- <span class="text-gray-100">Uploading {{ isVideo ? 'video' : 'image' }}...</span>
380
- </div>
381
- </div>
382
- </div>
383
- </div>
384
- <div v-else class="flex flex-col items-center justify-center gap-2 border rounded-4 text-ink-gray-6 text-sm py-5 max-w-full" :class="{ 'border-none': selected }" :style="{ width: node.attrs.width + 'px', aspectRatio: node.attrs.width && node.attrs.height ? `${node.attrs.width} / ${node.attrs.height}` : undefined,}">
385
- <div class="text-ink-gray-8 text-base">This {{ isVideo ? 'video' : 'image' }} hasn't yet been uploaded.</div>
386
- <div v-if="node.attrs.error" class="text-sm text-ink-red-7">{{ node.attrs.error }}</div>
387
- </div>
388
-
389
- <input v-if="(node.attrs.alt || showCaption) && !node.attrs.error" v-model="caption"
390
- class="w-full text-center bg-transparent text-sm text-ink-gray-6 h-7 border-none focus:ring-0 placeholder-ink-gray-4"
391
- placeholder="Add caption" :disabled="!isEditable" @change="updateCaption" @keydown="handleKeydown" />
392
-
393
- <div v-if="node.attrs.error && fileContent" class="w-full py-1.5 text-center">
394
- <ErrorMessage :message="`Upload failed: ${node.attrs.error}`" />
395
- </div>
396
- </div>
397
- </NodeViewWrapper>
398
- </template>
@@ -1,95 +0,0 @@
1
- <template>
2
- <div>
3
- <div
4
- v-if="items.length"
5
- class="min-w-40 rounded-6 border bg-surface-base p-1 text-base shadow-lg"
6
- >
7
- <button
8
- :class="[
9
- index === selectedIndex ? 'bg-surface-gray-2' : '',
10
- 'flex w-full items-center whitespace-nowrap rounded-5 px-2 py-2 text-sm text-ink-gray-9',
11
- ]"
12
- v-for="(item, index) in items"
13
- :key="index"
14
- @click="selectItem(index)"
15
- @mouseover="selectedIndex = index"
16
- >
17
- {{ item.label }}
18
- </button>
19
- </div>
20
- </div>
21
- </template>
22
-
23
- <script>
24
- export default {
25
- props: {
26
- items: {
27
- type: Array,
28
- required: true,
29
- },
30
- command: {
31
- type: Function,
32
- required: true,
33
- },
34
- },
35
- data() {
36
- return {
37
- selectedIndex: 0,
38
- }
39
- },
40
- watch: {
41
- items() {
42
- this.selectedIndex = 0
43
- },
44
- },
45
- methods: {
46
- onKeyDown({ event }) {
47
- if (event.key === 'ArrowUp') {
48
- this.upHandler()
49
- return true
50
- }
51
- if (event.key === 'ArrowDown') {
52
- this.downHandler()
53
- return true
54
- }
55
- if (event.key === 'Enter') {
56
- this.enterHandler()
57
- return true
58
- }
59
- return false
60
- },
61
- upHandler() {
62
- this.selectedIndex =
63
- (this.selectedIndex + this.items.length - 1) % this.items.length
64
- },
65
- downHandler() {
66
- this.selectedIndex = (this.selectedIndex + 1) % this.items.length
67
- },
68
- enterHandler() {
69
- this.selectItem(this.selectedIndex)
70
- },
71
- selectItem(index) {
72
- const item = this.items[index]
73
- if (item) {
74
- this.command({ id: item.value, label: item.label })
75
- }
76
- },
77
- },
78
- }
79
- </script>
80
-
81
- <style>
82
- .item {
83
- display: block;
84
- margin: 0;
85
- width: 100%;
86
- text-align: left;
87
- background: transparent;
88
- border-radius: 0.4rem;
89
- border: 1px solid transparent;
90
- padding: 0.2rem 0.4rem;
91
- }
92
- .item.is-selected {
93
- border-color: #000;
94
- }
95
- </style>
@@ -1,78 +0,0 @@
1
- <template>
2
- <BubbleMenu
3
- v-if="bubbleMenuButtons"
4
- class="bubble-menu rounded-5 z-[100]"
5
- :class="bubbleMenuButtons.length > 1 && 'shadow-sm'"
6
- :editor="editor"
7
- v-bind="options"
8
- >
9
- <TextEditorMenu
10
- class="rounded-4"
11
- :class="bubbleMenuButtons.length > 1 && 'shadow-lg'"
12
- :buttons="bubbleMenuButtons"
13
- />
14
- </BubbleMenu>
15
- </template>
16
- <script>
17
- import { BubbleMenu } from '@tiptap/vue-3/menus'
18
- import { createEditorButton } from '../utils'
19
- import TextEditorMenu from './TextEditorMenu.vue'
20
-
21
- export default {
22
- name: 'TextEditorBubbleMenu',
23
- props: ['buttons', 'options'],
24
- components: { BubbleMenu, TextEditorMenu },
25
- inject: ['editor'],
26
- computed: {
27
- bubbleMenuButtons() {
28
- if (!this.buttons) return false
29
-
30
- let buttons
31
- if (Array.isArray(this.buttons)) {
32
- buttons = this.buttons
33
- } else {
34
- buttons = [
35
- 'Paragraph',
36
- 'Heading 2',
37
- 'Heading 3',
38
- 'Separator',
39
- 'Bold',
40
- 'Italic',
41
- 'Strikethrough',
42
- 'FontColor',
43
- 'Link',
44
- 'Separator',
45
- 'Bullet List',
46
- 'Numbered List',
47
- 'Task List',
48
- 'Separator',
49
- 'Align Left',
50
- 'Align Center',
51
- 'Align Right',
52
- 'Separator',
53
- 'Image',
54
- 'Video',
55
- 'Blockquote',
56
- 'Code',
57
- [
58
- 'InsertTable',
59
- 'AddColumnBefore',
60
- 'AddColumnAfter',
61
- 'DeleteColumn',
62
- 'AddRowBefore',
63
- 'AddRowAfter',
64
- 'DeleteRow',
65
- 'MergeCells',
66
- 'SplitCell',
67
- 'ToggleHeaderColumn',
68
- 'ToggleHeaderRow',
69
- 'ToggleHeaderCell',
70
- 'DeleteTable',
71
- ],
72
- ]
73
- }
74
- return buttons.map(createEditorButton)
75
- },
76
- },
77
- }
78
- </script>
@@ -1,78 +0,0 @@
1
- <template>
2
- <TextEditorMenu v-if="fixedMenuButtons" :buttons="fixedMenuButtons" />
3
- </template>
4
- <script>
5
- import TextEditorMenu from './TextEditorMenu.vue'
6
- import { createEditorButton } from '../utils'
7
-
8
- export default {
9
- name: 'TextEditorFixedMenu',
10
- props: ['buttons'],
11
- components: { TextEditorMenu },
12
- inject: ['editor'],
13
- computed: {
14
- fixedMenuButtons() {
15
- if (!this.buttons) return false
16
- let buttons
17
- if (Array.isArray(this.buttons)) {
18
- buttons = [...this.buttons]
19
- } else {
20
- buttons = [
21
- 'Paragraph',
22
- [
23
- 'Heading 1',
24
- 'Heading 2',
25
- 'Heading 3',
26
- 'Heading 4',
27
- 'Heading 5',
28
- 'Heading 6',
29
- ],
30
- 'Separator',
31
- 'Bold',
32
- 'Italic',
33
- 'Strikethrough',
34
- 'Link',
35
- 'FontColor',
36
- 'Separator',
37
- 'Bullet List',
38
- 'Numbered List',
39
- 'Task List',
40
- 'Separator',
41
- 'Align Left',
42
- 'Align Center',
43
- 'Align Right',
44
- 'Separator',
45
- 'Image',
46
- 'Video',
47
- 'Blockquote',
48
- 'Code',
49
- 'Iframe',
50
- 'Separator',
51
- 'Horizontal Rule',
52
- [
53
- 'InsertTable',
54
- 'AddColumnBefore',
55
- 'AddColumnAfter',
56
- 'DeleteColumn',
57
- 'AddRowBefore',
58
- 'AddRowAfter',
59
- 'DeleteRow',
60
- 'MergeCells',
61
- 'SplitCell',
62
- 'ToggleHeaderColumn',
63
- 'ToggleHeaderRow',
64
- 'ToggleHeaderCell',
65
- 'DeleteTable',
66
- ],
67
- 'Separator',
68
- 'TableOfContents',
69
- 'Separator',
70
- 'Undo',
71
- 'Redo',
72
- ]
73
- }
74
- return buttons.map(createEditorButton)
75
- },
76
- },
77
- }
78
- </script>