mirror of https://github.com/usememos/memos.git
parent
0dbc35a2ba
commit
2db57b139a
|
|
@ -29,8 +29,29 @@ export const EditorContent = forwardRef<EditorRefActions, EditorContentProps>(({
|
|||
dispatch(actions.updateContent(content));
|
||||
};
|
||||
|
||||
const handlePaste = () => {
|
||||
// Paste handling is managed by the Editor component internally
|
||||
const handlePaste = (event: React.ClipboardEvent<Element>) => {
|
||||
const clipboard = event.clipboardData;
|
||||
if (!clipboard) return;
|
||||
|
||||
const files: File[] = [];
|
||||
if (clipboard.items && clipboard.items.length > 0) {
|
||||
for (const item of Array.from(clipboard.items)) {
|
||||
if (item.kind !== "file") continue;
|
||||
const file = item.getAsFile();
|
||||
if (file) files.push(file);
|
||||
}
|
||||
} else if (clipboard.files && clipboard.files.length > 0) {
|
||||
files.push(...Array.from(clipboard.files));
|
||||
}
|
||||
|
||||
if (files.length === 0) return;
|
||||
|
||||
const localFiles: LocalFile[] = files.map((file) => ({
|
||||
file,
|
||||
previewUrl: createBlobUrl(file),
|
||||
}));
|
||||
localFiles.forEach((localFile) => dispatch(actions.addLocalFile(localFile)));
|
||||
event.preventDefault();
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Reference in New Issue