feat(notes): show loader on image upload button while uploading

This commit is contained in:
Julien Calixte
2026-05-25 21:23:22 +02:00
parent 6a0f0d08d2
commit 4ab0be75e7

View File

@@ -118,17 +118,23 @@ const { uploadImage } = useImageUpload({
const fileInput = ref<HTMLInputElement | null>(null)
const editKey = ref(0)
const isUploading = ref(false)
const onImagePicked = async (e: Event) => {
const input = e.target as HTMLInputElement
const file = input.files?.[0]
input.value = ""
if (!file || !path.value) return
isUploading.value = true
try {
const result = await uploadImage(file)
if (!result) return
const suffix = rawContent.value.endsWith("\n") ? "" : "\n\n"
rawContent.value = `${rawContent.value}${suffix}![](${result.filename})\n`
editKey.value++
} finally {
isUploading.value = false
}
}
const {
@@ -298,10 +304,16 @@ const onBadgeClick = async () => {
<button
v-if="isMarkdown && mode === 'edit'"
class="action button is-text is-light"
title="Upload image"
:title="isUploading ? 'Uploading…' : 'Upload image'"
:disabled="isUploading"
@click="fileInput?.click()"
>
<span
v-if="isUploading"
class="loading loading-spinner loading-sm"
></span>
<svg
v-else
xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-photo-plus"
width="24"