diff --git a/static/app.js b/static/app.js index bd89a33..d137337 100644 --- a/static/app.js +++ b/static/app.js @@ -625,11 +625,18 @@ async function uploadAttachment(input) { throw new Error(err.detail || resp.statusText); } const data = await resp.json(); - state.editor.chain().focus().insertContent({ - type: "text", - text: data.name, - marks: [{ type: "link", attrs: { href: data.url } }], - }).run(); + if (file.type.startsWith("image/")) { + state.editor.chain().focus().insertContent({ + type: "image", + attrs: { src: data.url, alt: data.name, title: data.name }, + }).run(); + } else { + state.editor.chain().focus().insertContent({ + type: "text", + text: data.name, + marks: [{ type: "link", attrs: { href: data.url } }], + }).run(); + } if (status) status.textContent = "Attached " + data.name; } catch (e) { if (status) status.textContent = "Error: " + e.message;