mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: support uploads multi files (#191)
This commit is contained in:
@ -209,21 +209,27 @@ const MemoEditor: React.FC<Props> = () => {
|
||||
|
||||
const handleUploadFileBtnClick = useCallback(() => {
|
||||
const inputEl = document.createElement("input");
|
||||
inputEl.style.position = "fixed";
|
||||
inputEl.style.top = "-100vh";
|
||||
inputEl.style.left = "-100vw";
|
||||
document.body.appendChild(inputEl);
|
||||
inputEl.type = "file";
|
||||
inputEl.multiple = false;
|
||||
inputEl.accept = "image/png, image/gif, image/jpeg";
|
||||
inputEl.multiple = true;
|
||||
inputEl.accept = "image/*";
|
||||
inputEl.onchange = async () => {
|
||||
if (!inputEl.files || inputEl.files.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const file = inputEl.files[0];
|
||||
const url = await handleUploadFile(file);
|
||||
if (url) {
|
||||
editorRef.current?.insertText(``);
|
||||
for (const file of inputEl.files) {
|
||||
const url = await handleUploadFile(file);
|
||||
if (url) {
|
||||
editorRef.current?.insertText(``);
|
||||
}
|
||||
}
|
||||
};
|
||||
inputEl.click();
|
||||
document.body.removeChild(inputEl);
|
||||
}, []);
|
||||
|
||||
const handleFullscreenBtnClick = () => {
|
||||
|
Reference in New Issue
Block a user