No longer serialize binary blobs as data URLs

This commit is contained in:
Zef Hemel
2023-05-26 14:04:32 +02:00
parent 25c789538d
commit 1a1b942f92
10 changed files with 34 additions and 94 deletions
+1 -1
View File
@@ -180,7 +180,7 @@ export function attachmentExtension(editor: Editor) {
if (!finalFileName) {
return;
}
await editor.space.writeAttachment(finalFileName, "arraybuffer", data!);
await editor.space.writeAttachment(finalFileName, new Uint8Array(data));
let attachmentMarkdown = `[${finalFileName}](${
encodeURIComponent(finalFileName)
})`;
+3 -11
View File
@@ -33,24 +33,16 @@ class TableViewWidget extends WidgetType {
});
});
renderMarkdownToHtml(this.t, {
dom.innerHTML = renderMarkdownToHtml(this.t, {
// Annotate every element with its position so we can use it to put
// the cursor there when the user clicks on the table.
annotationPositions: true,
inlineAttachments: async (url): Promise<string> => {
inlineAttachments: (url) => {
if (!url.includes("://")) {
try {
const d = await this.editor.space.readAttachment(url, "dataurl");
return d.data as string;
} catch (e: any) {
console.error(e);
return url;
}
return `/.fs/${url}`;
}
return url;
},
}).then((html) => {
dom.innerHTML = html;
});
return dom;
}