fixes and functions
This commit is contained in:
@@ -70,7 +70,7 @@ function safeAttachmentUrl(value) {
|
||||
: safePublicUrl(raw, { allowMailto: false });
|
||||
}
|
||||
|
||||
export function bindNoteFiles({ editor, endpoints, getAccessToken, canDelete, canUpload, canEdit = () => true, toast, onFilesChanged = () => { } }) {
|
||||
export function bindNoteFiles({ editor, endpoints, getAccessToken, getUploadMaxSize = () => 0, canDelete, canUpload, canEdit = () => true, toast, onFilesChanged = () => { } }) {
|
||||
const dialog = document.querySelector("#files-dialog");
|
||||
const list = document.querySelector("#files-list");
|
||||
const input = document.querySelector("#file-input");
|
||||
@@ -126,6 +126,7 @@ export function bindNoteFiles({ editor, endpoints, getAccessToken, canDelete, ca
|
||||
method: "POST",
|
||||
body: form,
|
||||
headers: {},
|
||||
uploadMaxSizeBytes: getUploadMaxSize(),
|
||||
onProgress: progress => uploadToast.update(progress),
|
||||
});
|
||||
if (completed) return;
|
||||
@@ -143,13 +144,16 @@ export function bindNoteFiles({ editor, endpoints, getAccessToken, canDelete, ca
|
||||
await run();
|
||||
}
|
||||
|
||||
document.querySelector("#upload-button").addEventListener("click", () => {
|
||||
function requestUpload() {
|
||||
if (!canUpload() || !canEdit()) {
|
||||
toast("Log in with read-write access to upload files.");
|
||||
toast("You need read-write access and upload permission to upload files.");
|
||||
return;
|
||||
}
|
||||
input.click();
|
||||
});
|
||||
}
|
||||
|
||||
document.querySelector("#upload-button")?.addEventListener("click", requestUpload);
|
||||
document.querySelector("#mobile-upload-button")?.addEventListener("click", requestUpload);
|
||||
|
||||
input.addEventListener("change", async event => {
|
||||
let file = event.target.files[0];
|
||||
@@ -175,7 +179,7 @@ export function bindNoteFiles({ editor, endpoints, getAccessToken, canDelete, ca
|
||||
if (!files.length) return;
|
||||
event.preventDefault();
|
||||
if (!canUpload() || !canEdit()) {
|
||||
toast("Log in with read-write access to paste files.");
|
||||
toast("You need read-write access and upload permission to paste files.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user