attaching images renders

This commit is contained in:
schmeeve
2026-09-23 16:54:20 -07:00
parent 3294716337
commit c2436f39ea

View File

@@ -625,11 +625,18 @@ async function uploadAttachment(input) {
throw new Error(err.detail || resp.statusText); throw new Error(err.detail || resp.statusText);
} }
const data = await resp.json(); const data = await resp.json();
state.editor.chain().focus().insertContent({ if (file.type.startsWith("image/")) {
type: "text", state.editor.chain().focus().insertContent({
text: data.name, type: "image",
marks: [{ type: "link", attrs: { href: data.url } }], attrs: { src: data.url, alt: data.name, title: data.name },
}).run(); }).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; if (status) status.textContent = "Attached " + data.name;
} catch (e) { } catch (e) {
if (status) status.textContent = "Error: " + e.message; if (status) status.textContent = "Error: " + e.message;