More #363 work, relative paths for attachments when uploading
This commit is contained in:
parent
30436d97ea
commit
cd19d455a4
@ -23,17 +23,16 @@ async function saveFile(file: UploadFile) {
|
|||||||
// root folder case
|
// root folder case
|
||||||
prefix = "";
|
prefix = "";
|
||||||
}
|
}
|
||||||
const suggestedName = prefix + file.name;
|
|
||||||
|
|
||||||
const finalFileName = await editor.prompt(
|
const finalFileName = await editor.prompt(
|
||||||
"File name for pasted attachment",
|
"File name for pasted attachment",
|
||||||
suggestedName,
|
file.name,
|
||||||
);
|
);
|
||||||
if (!finalFileName) {
|
if (!finalFileName) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await space.writeAttachment(
|
await space.writeAttachment(
|
||||||
finalFileName,
|
prefix + finalFileName,
|
||||||
file.content,
|
file.content,
|
||||||
);
|
);
|
||||||
let attachmentMarkdown = `[${finalFileName}](${encodeURI(finalFileName)})`;
|
let attachmentMarkdown = `[${finalFileName}](${encodeURI(finalFileName)})`;
|
||||||
|
@ -204,8 +204,6 @@ export function attachmentExtension(editor: Client) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
suggestedName = resolve(folderName(editor.currentPage!), suggestedName);
|
|
||||||
|
|
||||||
const finalFileName = await editor.prompt(
|
const finalFileName = await editor.prompt(
|
||||||
"File name for pasted attachment",
|
"File name for pasted attachment",
|
||||||
suggestedName,
|
suggestedName,
|
||||||
@ -214,7 +212,7 @@ export function attachmentExtension(editor: Client) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await editor.space.writeAttachment(
|
await editor.space.writeAttachment(
|
||||||
finalFileName,
|
resolve(folderName(editor.currentPage!), finalFileName),
|
||||||
new Uint8Array(data),
|
new Uint8Array(data),
|
||||||
);
|
);
|
||||||
let attachmentMarkdown = `[${finalFileName}](${encodeURI(finalFileName)})`;
|
let attachmentMarkdown = `[${finalFileName}](${encodeURI(finalFileName)})`;
|
||||||
|
Loading…
Reference in New Issue
Block a user