Compare commits

...

2 Commits

Author SHA1 Message Date
Julien Calixte
60e3849c20 fix(notes): always insert blank line before appended image link 2026-05-25 21:23:31 +02:00
Julien Calixte
4ab0be75e7 feat(notes): show loader on image upload button while uploading 2026-05-25 21:23:22 +02:00

View File

@@ -118,17 +118,24 @@ 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
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++
isUploading.value = true
try {
const result = await uploadImage(file)
if (!result) return
const trimmed = rawContent.value.replace(/\n+$/, "")
const prefix = trimmed ? `${trimmed}\n\n` : ""
rawContent.value = `${prefix}![](${result.filename})\n`
editKey.value++
} finally {
isUploading.value = false
}
}
const {
@@ -298,10 +305,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"