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.
- package/experimental/Calendar/CalendarEventRow.vue +0 -4
- package/experimental/CommandPalette/CommandPaletteItem.vue +9 -1
- package/experimental/SpriteIcons/IconPicker.vue +2 -1
- package/experimental.ts +0 -21
- package/package.json +1 -3
- package/src/components/Breadcrumbs/Breadcrumbs.vue +2 -1
- package/src/components/DatePicker/DatePicker.md +7 -0
- package/src/components/DatePicker/DatePicker.vue +6 -0
- package/src/components/DatePicker/DateTimePicker.vue +6 -0
- package/src/components/DatePicker/composables.ts +18 -1
- package/src/components/DatePicker/utils.ts +53 -0
- package/src/components/HoverCard/HoverCard.vue +21 -5
- package/src/components/MobileNav/MobileNavItem.vue +3 -22
- package/src/components/SettingsDialog/SettingsDialog.api.md +7 -2
- package/src/components/SettingsDialog/SettingsDialog.md +2 -1
- package/src/components/SettingsDialog/SettingsRow.vue +12 -2
- package/src/components/Sidebar/SidebarItem.vue +3 -33
- package/src/components/SidebarRail/SidebarRailItem.vue +4 -17
- package/src/components/Tooltip/Tooltip.vue +8 -0
- package/src/components/shared/deferredTrigger.ts +174 -0
- package/src/components/shared/navLink.ts +45 -0
- package/src/molecules/editor/extensions/attachment/attachment-engine.ts +1 -1
- package/src/molecules/editor/extensions/content-paste/paste-html-utils.ts +16 -6
- package/src/molecules/editor/extensions/iframe/IframeNodeView.vue +26 -9
- package/src/molecules/editor/extensions/iframe/iframe-allowlist.ts +35 -16
- package/src/molecules/editor/extensions/iframe/iframe-embed-utils.ts +1 -1
- package/src/molecules/editor/extensions/iframe/iframe-extension.ts +30 -30
- package/src/molecules/editor/extensions/link/LinkEditorPopup.vue +1 -1
- package/src/molecules/editor/extensions/link/link-paste-plugin.ts +1 -1
- package/src/molecules/editor/extensions/shared/media-upload-engine.ts +1 -1
- package/src/molecules/list/ListRow.vue +8 -1
- package/src/utils/dialog.ts +20 -2
- package/src/{molecules/editor/extensions/shared → utils}/url-safety.ts +28 -16
- package/tailwind/content.js +0 -1
- package/tailwind/plugin.js +22 -0
- package/vite/doctypeInterfaceGenerator.js +52 -39
- package/vitepress/index.node.ts +0 -2
- package/experimental/TextEditor/TextEditor.api.md +0 -161
- package/experimental/TextEditor/TextEditor.vue +0 -298
- package/experimental/TextEditor/classIcon.ts +0 -21
- package/experimental/TextEditor/commands.js +0 -344
- package/experimental/TextEditor/components/CodeBlockComponent.vue +0 -103
- package/experimental/TextEditor/components/FontColor.vue +0 -153
- package/experimental/TextEditor/components/ImageViewerModal.vue +0 -463
- package/experimental/TextEditor/components/InsertImage.vue +0 -54
- package/experimental/TextEditor/components/InsertLink.vue +0 -13
- package/experimental/TextEditor/components/InsertVideo.vue +0 -14
- package/experimental/TextEditor/components/LinkPopup.vue +0 -99
- package/experimental/TextEditor/components/MediaNodeView.vue +0 -398
- package/experimental/TextEditor/components/MentionList.vue +0 -95
- package/experimental/TextEditor/components/TextEditorBubbleMenu.vue +0 -78
- package/experimental/TextEditor/components/TextEditorFixedMenu.vue +0 -78
- package/experimental/TextEditor/components/TextEditorFloatingMenu.vue +0 -61
- package/experimental/TextEditor/components/TextEditorMenu.vue +0 -218
- package/experimental/TextEditor/components/index.js +0 -0
- package/experimental/TextEditor/extensions/code-block.ts +0 -119
- package/experimental/TextEditor/extensions/color/color-extension.ts +0 -140
- package/experimental/TextEditor/extensions/color/color-styles.css +0 -25
- package/experimental/TextEditor/extensions/color/index.ts +0 -2
- package/experimental/TextEditor/extensions/content-paste-extension.ts +0 -160
- package/experimental/TextEditor/extensions/copy-styles.ts +0 -160
- package/experimental/TextEditor/extensions/emoji/EmojiList.vue +0 -55
- package/experimental/TextEditor/extensions/emoji/emoji-extension.ts +0 -55
- package/experimental/TextEditor/extensions/emoji/emojis.json +0 -7422
- package/experimental/TextEditor/extensions/heading/heading.ts +0 -20
- package/experimental/TextEditor/extensions/highlight/highlight-extension.ts +0 -241
- package/experimental/TextEditor/extensions/highlight/highlight-styles.css +0 -31
- package/experimental/TextEditor/extensions/highlight/index.ts +0 -2
- package/experimental/TextEditor/extensions/iframe/IframeNodeView.vue +0 -308
- package/experimental/TextEditor/extensions/iframe/InsertIframe.vue +0 -209
- package/experimental/TextEditor/extensions/iframe/iframe-extension.ts +0 -404
- package/experimental/TextEditor/extensions/iframe/index.ts +0 -11
- package/experimental/TextEditor/extensions/iframe/utils.ts +0 -283
- package/experimental/TextEditor/extensions/image/image-extension.ts +0 -661
- package/experimental/TextEditor/extensions/image/index.ts +0 -5
- package/experimental/TextEditor/extensions/image-group/ImageGroupNodeView.vue +0 -182
- package/experimental/TextEditor/extensions/image-group/ImageGroupUploadDialog.vue +0 -740
- package/experimental/TextEditor/extensions/image-group/image-group-extension.ts +0 -187
- package/experimental/TextEditor/extensions/image-viewer-extension.ts +0 -162
- package/experimental/TextEditor/extensions/link/index.ts +0 -1
- package/experimental/TextEditor/extensions/link/link-extension.ts +0 -323
- package/experimental/TextEditor/extensions/link/linkPasteHandler.ts +0 -51
- package/experimental/TextEditor/extensions/mention/index.ts +0 -1
- package/experimental/TextEditor/extensions/mention/mention-extension.ts +0 -204
- package/experimental/TextEditor/extensions/mention/style.css +0 -11
- package/experimental/TextEditor/extensions/shared/color-utils.ts +0 -236
- package/experimental/TextEditor/extensions/slash-commands/SlashCommandsList.vue +0 -59
- package/experimental/TextEditor/extensions/slash-commands/slash-commands-extension.ts +0 -184
- package/experimental/TextEditor/extensions/suggestion/SuggestionList.vue +0 -130
- package/experimental/TextEditor/extensions/suggestion/createSuggestionExtension.ts +0 -151
- package/experimental/TextEditor/extensions/suggestion/index.ts +0 -5
- package/experimental/TextEditor/extensions/tag/index.ts +0 -1
- package/experimental/TextEditor/extensions/tag/tag-extension.ts +0 -170
- package/experimental/TextEditor/extensions/toc-node/TocNodeView.vue +0 -439
- package/experimental/TextEditor/extensions/toc-node/index.ts +0 -3
- package/experimental/TextEditor/extensions/toc-node/toc-node-extension.ts +0 -167
- package/experimental/TextEditor/extensions/video-extension.ts +0 -653
- package/experimental/TextEditor/hljs-github.css +0 -197
- package/experimental/TextEditor/index.ts +0 -21
- package/experimental/TextEditor/style.css +0 -190
- package/experimental/TextEditor/types.ts +0 -72
- package/experimental/TextEditor/utils.js +0 -11
- package/src/utils/url-validation.ts +0 -39
|
@@ -1,463 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Teleport :to="portalTarget ?? 'body'">
|
|
3
|
-
<Transition
|
|
4
|
-
enter-active-class="transition-opacity duration-150 ease-in-out"
|
|
5
|
-
leave-active-class="transition-opacity duration-150 ease-in-out"
|
|
6
|
-
enter-from-class="opacity-0"
|
|
7
|
-
leave-to-class="opacity-0"
|
|
8
|
-
appear
|
|
9
|
-
>
|
|
10
|
-
<div
|
|
11
|
-
v-if="props.show"
|
|
12
|
-
class="fixed top-0 left-0 w-full h-full bg-black sm:bg-black/90 z-[50] flex flex-col justify-center items-center overflow-hidden touch-none"
|
|
13
|
-
ref="imageContainer"
|
|
14
|
-
@mousemove="handleActivity"
|
|
15
|
-
@touchstart="handleActivity"
|
|
16
|
-
@touchmove="handleActivity"
|
|
17
|
-
>
|
|
18
|
-
<!-- Dedicated Backdrop -->
|
|
19
|
-
<div
|
|
20
|
-
class="absolute inset-0 z-0"
|
|
21
|
-
ref="backdropElement"
|
|
22
|
-
@click="close"
|
|
23
|
-
></div>
|
|
24
|
-
|
|
25
|
-
<!-- Image Container -->
|
|
26
|
-
<div class="relative z-10 flex flex-col items-center">
|
|
27
|
-
<img
|
|
28
|
-
:src="currentImage.src"
|
|
29
|
-
:alt="currentImage.alt || 'Image preview'"
|
|
30
|
-
class="max-w-screen max-h-screen object-contain block"
|
|
31
|
-
:style="{
|
|
32
|
-
transform: `scale(${zoomLevel / 100}) translate(${panPosition.x}px, ${panPosition.y}px)`,
|
|
33
|
-
cursor:
|
|
34
|
-
zoomLevel > 100
|
|
35
|
-
? isMousePanning
|
|
36
|
-
? 'grabbing'
|
|
37
|
-
: 'grab'
|
|
38
|
-
: 'default',
|
|
39
|
-
transition:
|
|
40
|
-
isPanning || isPinching || isAnimatingPan
|
|
41
|
-
? 'none'
|
|
42
|
-
: 'transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)',
|
|
43
|
-
}"
|
|
44
|
-
@mousedown="handlePanStart"
|
|
45
|
-
draggable="false"
|
|
46
|
-
/>
|
|
47
|
-
</div>
|
|
48
|
-
|
|
49
|
-
<!-- Caption -->
|
|
50
|
-
<div
|
|
51
|
-
v-if="currentImage.alt"
|
|
52
|
-
class="absolute bottom-4 p-2 text-center rounded-1 text-white text-sm bg-black/65 z-10 transition-opacity duration-300 ease-in-out"
|
|
53
|
-
:class="{ 'opacity-0 pointer-events-none': !isControlsVisible }"
|
|
54
|
-
>
|
|
55
|
-
{{ currentImage.alt }}
|
|
56
|
-
</div>
|
|
57
|
-
|
|
58
|
-
<!-- Controls bar -->
|
|
59
|
-
<div
|
|
60
|
-
ref="controlsBar"
|
|
61
|
-
class="absolute top-4 flex items-center space-x-3 p-2 text-white z-20 transition-opacity duration-300 ease-in-out"
|
|
62
|
-
:class="{ 'opacity-0 pointer-events-none': !isControlsVisible }"
|
|
63
|
-
@touchstart.stop
|
|
64
|
-
@touchmove.stop
|
|
65
|
-
@touchend.stop
|
|
66
|
-
@mousedown.stop
|
|
67
|
-
@wheel.stop
|
|
68
|
-
>
|
|
69
|
-
<!-- Navigation controls -->
|
|
70
|
-
<div class="bg-black/65 rounded-4 flex items-center">
|
|
71
|
-
<Tooltip text="Previous image">
|
|
72
|
-
<button
|
|
73
|
-
class="p-2 hover:bg-gray-900 rounded-l-4 focus:outline-none"
|
|
74
|
-
@click.stop="previousImage"
|
|
75
|
-
>
|
|
76
|
-
<LucideChevronLeft class="size-4" />
|
|
77
|
-
</button>
|
|
78
|
-
</Tooltip>
|
|
79
|
-
|
|
80
|
-
<span class="px-2 text-sm tabular-nums text-gray-400 select-none">
|
|
81
|
-
{{ currentIndex + 1 }}/{{ props.images.length }}
|
|
82
|
-
</span>
|
|
83
|
-
|
|
84
|
-
<Tooltip text="Next image">
|
|
85
|
-
<button
|
|
86
|
-
class="p-2 hover:bg-gray-900 rounded-r-4 focus:outline-none"
|
|
87
|
-
@click.stop="nextImage"
|
|
88
|
-
>
|
|
89
|
-
<LucideChevronRight class="size-4" />
|
|
90
|
-
</button>
|
|
91
|
-
</Tooltip>
|
|
92
|
-
</div>
|
|
93
|
-
|
|
94
|
-
<!-- Zoom controls -->
|
|
95
|
-
<div class="bg-black/65 rounded-4 flex items-center">
|
|
96
|
-
<Tooltip text="Zoom out">
|
|
97
|
-
<button
|
|
98
|
-
class="p-2 hover:bg-gray-900 rounded-l-4 focus:outline-none"
|
|
99
|
-
@click.stop="zoomOut"
|
|
100
|
-
>
|
|
101
|
-
<LucideMinus class="size-4" />
|
|
102
|
-
</button>
|
|
103
|
-
</Tooltip>
|
|
104
|
-
|
|
105
|
-
<Tooltip text="Reset zoom">
|
|
106
|
-
<button
|
|
107
|
-
class="p-2 hover:bg-gray-900 text-sm text-gray-400 focus:outline-none"
|
|
108
|
-
@click.stop="resetZoom"
|
|
109
|
-
>
|
|
110
|
-
{{ zoomLevel }}%
|
|
111
|
-
</button>
|
|
112
|
-
</Tooltip>
|
|
113
|
-
|
|
114
|
-
<Tooltip text="Zoom in">
|
|
115
|
-
<button
|
|
116
|
-
class="p-2 hover:bg-gray-900 rounded-r-4 focus:outline-none"
|
|
117
|
-
@click.stop="zoomIn"
|
|
118
|
-
>
|
|
119
|
-
<LucidePlus class="size-4" />
|
|
120
|
-
</button>
|
|
121
|
-
</Tooltip>
|
|
122
|
-
</div>
|
|
123
|
-
|
|
124
|
-
<!-- Action controls -->
|
|
125
|
-
<div class="bg-black/65 rounded-4 flex items-center">
|
|
126
|
-
<Tooltip text="Download image">
|
|
127
|
-
<button
|
|
128
|
-
class="p-2 hover:bg-gray-900 rounded-l-4 focus:outline-none"
|
|
129
|
-
@click.stop="downloadImage"
|
|
130
|
-
>
|
|
131
|
-
<LucideDownload class="size-4" />
|
|
132
|
-
</button>
|
|
133
|
-
</Tooltip>
|
|
134
|
-
|
|
135
|
-
<Tooltip
|
|
136
|
-
:text="isFullscreen ? 'Exit fullscreen' : 'Enter fullscreen'"
|
|
137
|
-
>
|
|
138
|
-
<button
|
|
139
|
-
class="p-2 hover:bg-gray-900 rounded-r-4 focus:outline-none hidden sm:block"
|
|
140
|
-
@click.stop="toggleFullscreen"
|
|
141
|
-
>
|
|
142
|
-
<LucideMaximize v-if="!isFullscreen" class="size-4" />
|
|
143
|
-
<LucideMinimize v-else class="size-4" />
|
|
144
|
-
</button>
|
|
145
|
-
</Tooltip>
|
|
146
|
-
</div>
|
|
147
|
-
|
|
148
|
-
<!-- Close button -->
|
|
149
|
-
<div class="bg-black/65 rounded-4 flex items-center">
|
|
150
|
-
<Tooltip text="Close">
|
|
151
|
-
<button
|
|
152
|
-
class="p-2 hover:bg-gray-900 rounded-4 focus:outline-none"
|
|
153
|
-
@click.stop="close"
|
|
154
|
-
>
|
|
155
|
-
<LucideX class="size-4" />
|
|
156
|
-
</button>
|
|
157
|
-
</Tooltip>
|
|
158
|
-
</div>
|
|
159
|
-
</div>
|
|
160
|
-
</div>
|
|
161
|
-
</Transition>
|
|
162
|
-
</Teleport>
|
|
163
|
-
</template>
|
|
164
|
-
|
|
165
|
-
<script setup lang="ts">
|
|
166
|
-
import { usePortalTarget } from '#composables/usePortalTarget'
|
|
167
|
-
import {
|
|
168
|
-
ref,
|
|
169
|
-
onMounted,
|
|
170
|
-
onUnmounted,
|
|
171
|
-
useTemplateRef,
|
|
172
|
-
computed,
|
|
173
|
-
toRef,
|
|
174
|
-
watch,
|
|
175
|
-
} from 'vue'
|
|
176
|
-
import Tooltip from '#components/Tooltip/Tooltip.vue'
|
|
177
|
-
import { useTouchHandler } from '#composables/useTouchHandler'
|
|
178
|
-
import { useImageNavigation } from '#composables/useImageNavigation'
|
|
179
|
-
import { useZoomPan } from '#composables/useZoomPan'
|
|
180
|
-
|
|
181
|
-
import { classIcon } from '../classIcon'
|
|
182
|
-
const LucideDownload = classIcon('lucide-download')
|
|
183
|
-
const LucideMaximize = classIcon('lucide-maximize')
|
|
184
|
-
const LucideMinimize = classIcon('lucide-minimize')
|
|
185
|
-
const LucideChevronLeft = classIcon('lucide-chevron-left')
|
|
186
|
-
const LucideChevronRight = classIcon('lucide-chevron-right')
|
|
187
|
-
const LucidePlus = classIcon('lucide-plus')
|
|
188
|
-
const LucideMinus = classIcon('lucide-minus')
|
|
189
|
-
const LucideX = classIcon('lucide-x')
|
|
190
|
-
interface ImageInfo {
|
|
191
|
-
src: string
|
|
192
|
-
alt: string | null
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const props = defineProps<{
|
|
196
|
-
show: boolean
|
|
197
|
-
images: ImageInfo[]
|
|
198
|
-
initialIndex: number
|
|
199
|
-
}>()
|
|
200
|
-
|
|
201
|
-
const portalTarget = usePortalTarget()
|
|
202
|
-
|
|
203
|
-
const emit = defineEmits<{
|
|
204
|
-
'update:show': [value: boolean]
|
|
205
|
-
}>()
|
|
206
|
-
|
|
207
|
-
const imageContainer = useTemplateRef('imageContainer')
|
|
208
|
-
const backdropElement = useTemplateRef('backdropElement')
|
|
209
|
-
const controlsBar = useTemplateRef('controlsBar')
|
|
210
|
-
const controlsBarHeight = ref(0)
|
|
211
|
-
|
|
212
|
-
const isFullscreen = ref(false)
|
|
213
|
-
const touchStartZoom = ref(100)
|
|
214
|
-
|
|
215
|
-
const isControlsVisible = ref(true)
|
|
216
|
-
const inactivityTimer = ref<ReturnType<typeof setTimeout> | null>(null)
|
|
217
|
-
const INACTIVITY_TIMEOUT = 3000 // 3 seconds
|
|
218
|
-
|
|
219
|
-
const {
|
|
220
|
-
zoomLevel,
|
|
221
|
-
panPosition,
|
|
222
|
-
isMousePanning,
|
|
223
|
-
initialPanPositionOnGestureStart,
|
|
224
|
-
zoomIn,
|
|
225
|
-
zoomOut,
|
|
226
|
-
resetZoom,
|
|
227
|
-
handlePanStart,
|
|
228
|
-
snapThresholdLower,
|
|
229
|
-
snapThresholdUpper,
|
|
230
|
-
} = useZoomPan({
|
|
231
|
-
containerRef: imageContainer,
|
|
232
|
-
isEnabled: toRef(props, 'show'),
|
|
233
|
-
})
|
|
234
|
-
|
|
235
|
-
const { currentIndex, nextImage, previousImage } = useImageNavigation({
|
|
236
|
-
initialIndex: toRef(props, 'initialIndex'),
|
|
237
|
-
imageCount: computed(() => props.images.length),
|
|
238
|
-
onNavigate: resetZoom,
|
|
239
|
-
})
|
|
240
|
-
|
|
241
|
-
const currentImage = computed(() => props.images[currentIndex.value])
|
|
242
|
-
|
|
243
|
-
const {
|
|
244
|
-
isPanning: isTouchPanning,
|
|
245
|
-
isPinching,
|
|
246
|
-
isAnimatingPan,
|
|
247
|
-
} = useTouchHandler({
|
|
248
|
-
targetRef: imageContainer,
|
|
249
|
-
zoomLevel: zoomLevel,
|
|
250
|
-
panThreshold: 10,
|
|
251
|
-
onSwipeLeft: () => {
|
|
252
|
-
if (zoomLevel.value <= 100) nextImage()
|
|
253
|
-
},
|
|
254
|
-
onSwipeRight: () => {
|
|
255
|
-
if (zoomLevel.value <= 100) previousImage()
|
|
256
|
-
},
|
|
257
|
-
onDoubleTap: (event) => {
|
|
258
|
-
if (controlsBar.value?.contains(event.target as Node)) return
|
|
259
|
-
|
|
260
|
-
if (zoomLevel.value > 100) {
|
|
261
|
-
resetZoom()
|
|
262
|
-
} else {
|
|
263
|
-
zoomLevel.value = 200
|
|
264
|
-
panPosition.value = { x: 0, y: 0 }
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
onTap: (event) => {
|
|
268
|
-
if (event.target === backdropElement.value) {
|
|
269
|
-
close()
|
|
270
|
-
}
|
|
271
|
-
},
|
|
272
|
-
onPanStart: () => {
|
|
273
|
-
if (zoomLevel.value <= 100) return
|
|
274
|
-
initialPanPositionOnGestureStart.value = { ...panPosition.value }
|
|
275
|
-
},
|
|
276
|
-
onPanMove: (deltaX, deltaY) => {
|
|
277
|
-
if (zoomLevel.value <= 100) return
|
|
278
|
-
panPosition.value = {
|
|
279
|
-
x: initialPanPositionOnGestureStart.value.x + deltaX,
|
|
280
|
-
y: initialPanPositionOnGestureStart.value.y + deltaY,
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
onPanAnimate: (deltaX, deltaY) => {
|
|
284
|
-
panPosition.value = {
|
|
285
|
-
x: panPosition.value.x + deltaX,
|
|
286
|
-
y: panPosition.value.y + deltaY,
|
|
287
|
-
}
|
|
288
|
-
},
|
|
289
|
-
onPinchStart: () => {
|
|
290
|
-
touchStartZoom.value = zoomLevel.value
|
|
291
|
-
initialPanPositionOnGestureStart.value = { ...panPosition.value }
|
|
292
|
-
},
|
|
293
|
-
onPinchMove: (scale) => {
|
|
294
|
-
const newZoom = touchStartZoom.value * scale
|
|
295
|
-
let finalZoom = Math.max(25, Math.min(300, Math.round(newZoom)))
|
|
296
|
-
|
|
297
|
-
if (finalZoom > snapThresholdLower && finalZoom < snapThresholdUpper) {
|
|
298
|
-
finalZoom = 100
|
|
299
|
-
}
|
|
300
|
-
zoomLevel.value = finalZoom
|
|
301
|
-
},
|
|
302
|
-
onPinchEnd: () => {
|
|
303
|
-
if (zoomLevel.value < 100) {
|
|
304
|
-
resetZoom()
|
|
305
|
-
}
|
|
306
|
-
initialPanPositionOnGestureStart.value = { x: 0, y: 0 }
|
|
307
|
-
},
|
|
308
|
-
})
|
|
309
|
-
|
|
310
|
-
const isPanning = computed(() => isMousePanning.value || isTouchPanning.value)
|
|
311
|
-
|
|
312
|
-
function showControlsAndResetTimer() {
|
|
313
|
-
isControlsVisible.value = true
|
|
314
|
-
if (inactivityTimer.value) {
|
|
315
|
-
clearTimeout(inactivityTimer.value)
|
|
316
|
-
}
|
|
317
|
-
inactivityTimer.value = setTimeout(() => {
|
|
318
|
-
if (!isPanning.value && !isPinching.value) {
|
|
319
|
-
isControlsVisible.value = false
|
|
320
|
-
} else {
|
|
321
|
-
showControlsAndResetTimer()
|
|
322
|
-
}
|
|
323
|
-
}, INACTIVITY_TIMEOUT)
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
function handleActivity() {
|
|
327
|
-
if (!isPinching.value || !isControlsVisible.value) {
|
|
328
|
-
showControlsAndResetTimer()
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
function close() {
|
|
333
|
-
emit('update:show', false)
|
|
334
|
-
resetZoom()
|
|
335
|
-
if (inactivityTimer.value) {
|
|
336
|
-
clearTimeout(inactivityTimer.value)
|
|
337
|
-
inactivityTimer.value = null
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
function downloadImage() {
|
|
342
|
-
const imageToDownload = currentImage.value
|
|
343
|
-
|
|
344
|
-
const link = document.createElement('a')
|
|
345
|
-
link.href = imageToDownload.src
|
|
346
|
-
|
|
347
|
-
const filename =
|
|
348
|
-
imageToDownload.alt?.replace(/[^a-z0-9]/gi, '_').toLowerCase() ||
|
|
349
|
-
imageToDownload.src.split('/').pop() ||
|
|
350
|
-
'download'
|
|
351
|
-
link.download = filename.includes('.') ? filename : `${filename}.jpg`
|
|
352
|
-
|
|
353
|
-
document.body.appendChild(link)
|
|
354
|
-
link.click()
|
|
355
|
-
document.body.removeChild(link)
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
function toggleFullscreen() {
|
|
359
|
-
const container = imageContainer.value
|
|
360
|
-
|
|
361
|
-
if (!isFullscreen.value) {
|
|
362
|
-
if (container?.requestFullscreen) {
|
|
363
|
-
container.requestFullscreen()
|
|
364
|
-
isFullscreen.value = true
|
|
365
|
-
}
|
|
366
|
-
} else {
|
|
367
|
-
if (document.exitFullscreen) {
|
|
368
|
-
document.exitFullscreen()
|
|
369
|
-
isFullscreen.value = false
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
function handleFullscreenChange() {
|
|
375
|
-
isFullscreen.value = Boolean(document.fullscreenElement)
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
function handleKeyDown(event: KeyboardEvent) {
|
|
379
|
-
if (!props.show) return
|
|
380
|
-
|
|
381
|
-
handleActivity()
|
|
382
|
-
|
|
383
|
-
switch (event.key) {
|
|
384
|
-
case 'ArrowLeft':
|
|
385
|
-
if (!isPanning.value) previousImage()
|
|
386
|
-
event.preventDefault()
|
|
387
|
-
break
|
|
388
|
-
case 'ArrowRight':
|
|
389
|
-
if (!isPanning.value) nextImage()
|
|
390
|
-
event.preventDefault()
|
|
391
|
-
break
|
|
392
|
-
case '+':
|
|
393
|
-
case '=':
|
|
394
|
-
zoomIn()
|
|
395
|
-
event.preventDefault()
|
|
396
|
-
break
|
|
397
|
-
case '-':
|
|
398
|
-
zoomOut()
|
|
399
|
-
event.preventDefault()
|
|
400
|
-
break
|
|
401
|
-
case 'Escape':
|
|
402
|
-
close()
|
|
403
|
-
event.preventDefault()
|
|
404
|
-
break
|
|
405
|
-
case 'f':
|
|
406
|
-
case 'F':
|
|
407
|
-
toggleFullscreen()
|
|
408
|
-
event.preventDefault()
|
|
409
|
-
break
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
watch(
|
|
414
|
-
() => props.show,
|
|
415
|
-
(newValue) => {
|
|
416
|
-
if (newValue) {
|
|
417
|
-
isControlsVisible.value = true
|
|
418
|
-
resetZoom()
|
|
419
|
-
showControlsAndResetTimer()
|
|
420
|
-
} else {
|
|
421
|
-
if (inactivityTimer.value) {
|
|
422
|
-
clearTimeout(inactivityTimer.value)
|
|
423
|
-
inactivityTimer.value = null
|
|
424
|
-
}
|
|
425
|
-
if (isFullscreen.value && document.exitFullscreen) {
|
|
426
|
-
document.exitFullscreen()
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
},
|
|
430
|
-
)
|
|
431
|
-
|
|
432
|
-
watch(controlsBar, (newVal) => {
|
|
433
|
-
if (newVal) {
|
|
434
|
-
const updateHeight = () => {
|
|
435
|
-
controlsBarHeight.value = newVal.offsetHeight
|
|
436
|
-
}
|
|
437
|
-
const resizeObserver = new ResizeObserver(updateHeight)
|
|
438
|
-
resizeObserver.observe(newVal)
|
|
439
|
-
updateHeight()
|
|
440
|
-
onUnmounted(() => resizeObserver.disconnect())
|
|
441
|
-
} else {
|
|
442
|
-
controlsBarHeight.value = 0
|
|
443
|
-
}
|
|
444
|
-
})
|
|
445
|
-
|
|
446
|
-
onMounted(() => {
|
|
447
|
-
document.addEventListener('fullscreenchange', handleFullscreenChange)
|
|
448
|
-
document.addEventListener('keydown', handleKeyDown)
|
|
449
|
-
})
|
|
450
|
-
|
|
451
|
-
onUnmounted(() => {
|
|
452
|
-
document.removeEventListener('fullscreenchange', handleFullscreenChange)
|
|
453
|
-
document.removeEventListener('keydown', handleKeyDown)
|
|
454
|
-
|
|
455
|
-
if (inactivityTimer.value) {
|
|
456
|
-
clearTimeout(inactivityTimer.value)
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
if (isFullscreen.value && document.exitFullscreen) {
|
|
460
|
-
document.exitFullscreen()
|
|
461
|
-
}
|
|
462
|
-
})
|
|
463
|
-
</script>
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<slot v-bind="{ onClick: openFileSelector }"></slot>
|
|
3
|
-
<input
|
|
4
|
-
ref="fileInput"
|
|
5
|
-
type="file"
|
|
6
|
-
class="hidden"
|
|
7
|
-
@change="onImageSelect"
|
|
8
|
-
accept="image/*"
|
|
9
|
-
multiple
|
|
10
|
-
/>
|
|
11
|
-
<ImageGroupUploadDialog
|
|
12
|
-
v-if="showModal"
|
|
13
|
-
mode="new"
|
|
14
|
-
v-model="showModal"
|
|
15
|
-
v-model:files="selectedFiles"
|
|
16
|
-
:editor="editor"
|
|
17
|
-
@close="handleCancel"
|
|
18
|
-
/>
|
|
19
|
-
</template>
|
|
20
|
-
<script setup lang="ts">
|
|
21
|
-
import { ref, useTemplateRef } from 'vue'
|
|
22
|
-
import type { Editor } from '@tiptap/vue-3'
|
|
23
|
-
import ImageGroupUploadDialog from '../extensions/image-group/ImageGroupUploadDialog.vue'
|
|
24
|
-
|
|
25
|
-
const props = defineProps<{
|
|
26
|
-
editor: Editor
|
|
27
|
-
}>()
|
|
28
|
-
|
|
29
|
-
const fileInput = useTemplateRef<HTMLInputElement>('fileInput')
|
|
30
|
-
const showModal = ref(false)
|
|
31
|
-
const selectedFiles = ref<File[]>([])
|
|
32
|
-
|
|
33
|
-
function openFileSelector() {
|
|
34
|
-
fileInput.value?.click()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function onImageSelect(e: Event) {
|
|
38
|
-
const target = e.target as HTMLInputElement
|
|
39
|
-
const files = target.files
|
|
40
|
-
if (files && files.length > 0) {
|
|
41
|
-
if (files.length === 1) {
|
|
42
|
-
props.editor.chain().focus().uploadImage(files[0]).run()
|
|
43
|
-
} else {
|
|
44
|
-
selectedFiles.value = Array.from(files)
|
|
45
|
-
showModal.value = true
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function handleCancel() {
|
|
51
|
-
showModal.value = false
|
|
52
|
-
selectedFiles.value = []
|
|
53
|
-
}
|
|
54
|
-
</script>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<slot v-bind="{ onClick: openLinkEditor }"></slot>
|
|
3
|
-
</template>
|
|
4
|
-
<script setup lang="ts">
|
|
5
|
-
import type { Editor } from '@tiptap/vue-3'
|
|
6
|
-
|
|
7
|
-
const props = defineProps<{
|
|
8
|
-
editor: Editor
|
|
9
|
-
}>()
|
|
10
|
-
function openLinkEditor() {
|
|
11
|
-
props.editor.commands.openLinkEditor()
|
|
12
|
-
}
|
|
13
|
-
</script>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<slot v-bind="{ onClick: selectAndUploadVideo }"></slot>
|
|
3
|
-
</template>
|
|
4
|
-
<script setup lang="ts">
|
|
5
|
-
import { Editor } from '@tiptap/vue-3'
|
|
6
|
-
|
|
7
|
-
const props = defineProps<{
|
|
8
|
-
editor: Editor
|
|
9
|
-
}>()
|
|
10
|
-
|
|
11
|
-
function selectAndUploadVideo() {
|
|
12
|
-
props.editor.chain().focus().selectAndUploadVideo().run()
|
|
13
|
-
}
|
|
14
|
-
</script>
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="p-2 w-72 flex items-center gap-2 bg-surface-base shadow-xl rounded-4"
|
|
4
|
-
>
|
|
5
|
-
<TextInput
|
|
6
|
-
v-if="edit"
|
|
7
|
-
ref="input"
|
|
8
|
-
type="text"
|
|
9
|
-
class="w-full"
|
|
10
|
-
placeholder="https://example.com"
|
|
11
|
-
v-model="_href"
|
|
12
|
-
@keydown.enter="submitLink"
|
|
13
|
-
@keydown.esc="$emit('close')"
|
|
14
|
-
/>
|
|
15
|
-
<a
|
|
16
|
-
v-else
|
|
17
|
-
class="text-ink-gray-7 underline text-sm flex-1 truncate pl-1"
|
|
18
|
-
:title="_href"
|
|
19
|
-
:href="_href"
|
|
20
|
-
target="_blank"
|
|
21
|
-
>
|
|
22
|
-
{{ _href }}
|
|
23
|
-
</a>
|
|
24
|
-
<div class="shrink-0 flex items-center gap-1.5 ml-auto">
|
|
25
|
-
<template v-if="edit">
|
|
26
|
-
<Button
|
|
27
|
-
@click="submitLink"
|
|
28
|
-
tooltip="Submit"
|
|
29
|
-
icon="lucide-check"
|
|
30
|
-
variant="subtle"
|
|
31
|
-
/>
|
|
32
|
-
<Button
|
|
33
|
-
@click="props.href ? (edit = false) : $emit('updateHref', '')"
|
|
34
|
-
tooltip="Exit"
|
|
35
|
-
icon="lucide-x"
|
|
36
|
-
variant="subtle"
|
|
37
|
-
/>
|
|
38
|
-
</template>
|
|
39
|
-
<template v-else>
|
|
40
|
-
<Button
|
|
41
|
-
@click="copyLink"
|
|
42
|
-
tooltip="Copy"
|
|
43
|
-
icon="lucide-copy"
|
|
44
|
-
variant="subtle"
|
|
45
|
-
/>
|
|
46
|
-
<Button
|
|
47
|
-
@click="edit = true"
|
|
48
|
-
tooltip="Edit"
|
|
49
|
-
icon="lucide-pencil"
|
|
50
|
-
variant="subtle"
|
|
51
|
-
/>
|
|
52
|
-
<Button
|
|
53
|
-
tooltip="Remove"
|
|
54
|
-
variant="subtle"
|
|
55
|
-
@click="$emit('updateHref', '')"
|
|
56
|
-
icon="lucide-link-2-off"
|
|
57
|
-
/>
|
|
58
|
-
</template>
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
61
|
-
</template>
|
|
62
|
-
|
|
63
|
-
<script setup lang="ts">
|
|
64
|
-
import { onMounted, ref, useTemplateRef, nextTick } from 'vue'
|
|
65
|
-
import Button from '#components/Button/Button.vue'
|
|
66
|
-
import TextInput from '#components/TextInput/TextInput.vue'
|
|
67
|
-
import { isValidUrl } from '#utils/url-validation'
|
|
68
|
-
|
|
69
|
-
const props = defineProps<{
|
|
70
|
-
href: string
|
|
71
|
-
}>()
|
|
72
|
-
|
|
73
|
-
const emit = defineEmits<{
|
|
74
|
-
(e: 'updateHref', href: string): void
|
|
75
|
-
(e: 'close'): void
|
|
76
|
-
}>()
|
|
77
|
-
|
|
78
|
-
const _href = ref(props.href)
|
|
79
|
-
const input = useTemplateRef('input')
|
|
80
|
-
const edit = ref(!props.href)
|
|
81
|
-
|
|
82
|
-
const submitLink = () => {
|
|
83
|
-
if (_href.value === '' || isValidUrl(_href.value)) {
|
|
84
|
-
emit('updateHref', _href.value)
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const copyLink = async () => {
|
|
89
|
-
if (_href.value) await navigator.clipboard.writeText(_href.value)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
onMounted(async () => {
|
|
93
|
-
await nextTick()
|
|
94
|
-
if (input.value?.inputElement) {
|
|
95
|
-
input.value.inputElement.focus()
|
|
96
|
-
input.value.inputElement.select()
|
|
97
|
-
}
|
|
98
|
-
})
|
|
99
|
-
</script>
|