attaching images renders
This commit is contained in:
@@ -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();
|
||||||
|
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({
|
state.editor.chain().focus().insertContent({
|
||||||
type: "text",
|
type: "text",
|
||||||
text: data.name,
|
text: data.name,
|
||||||
marks: [{ type: "link", attrs: { href: data.url } }],
|
marks: [{ type: "link", attrs: { href: data.url } }],
|
||||||
}).run();
|
}).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;
|
||||||
|
|||||||
Reference in New Issue
Block a user