diff --git a/apps/web/src/components/editor/index.tsx b/apps/web/src/components/editor/index.tsx index 426212fde..159e77253 100644 --- a/apps/web/src/components/editor/index.tsx +++ b/apps/web/src/components/editor/index.tsx @@ -784,14 +784,21 @@ function DropZone(props: DropZoneProps) { display: "none" }} onDrop={async (e) => { - const { activeEditorId, getEditor } = useEditorManager.getState(); - const editor = getEditor(activeEditorId || "")?.editor; - if (!e.dataTransfer.files?.length || !editor) return; + try { + const { activeEditorId, getEditor } = useEditorManager.getState(); + const editor = getEditor(activeEditorId || "")?.editor; + if (!e.dataTransfer.files?.length || !editor) return; - e.preventDefault(); - const attachments = await attachFiles(Array.from(e.dataTransfer.files)); - for (const attachment of attachments || []) { - editor.attachFile(attachment); + e.preventDefault(); + const attachments = await attachFiles( + Array.from(e.dataTransfer.files) + ); + for (const attachment of attachments || []) { + editor.attachFile(attachment); + } + } catch (e) { + logger.error(e as Error, "Failed to attach file from drag and drop"); + showToast("error", strings.failedToAttachFile()); } }} > diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po index 6536d15cb..5eba0b11d 100644 --- a/packages/intl/locale/en.po +++ b/packages/intl/locale/en.po @@ -2761,6 +2761,10 @@ msgstr "Faced an issue or have a suggestion? Click here to create a bug report" msgid "Failed" msgstr "Failed" +#: src/strings.ts:2637 +msgid "Failed to attach file" +msgstr "Failed to attach file" + #: src/strings.ts:1936 msgid "Failed to copy note" msgstr "Failed to copy note" diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po index db8f7b51d..299fe1114 100644 --- a/packages/intl/locale/pseudo-LOCALE.po +++ b/packages/intl/locale/pseudo-LOCALE.po @@ -2750,6 +2750,10 @@ msgstr "" msgid "Failed" msgstr "" +#: src/strings.ts:2637 +msgid "Failed to attach file" +msgstr "" + #: src/strings.ts:1936 msgid "Failed to copy note" msgstr "" diff --git a/packages/intl/src/strings.ts b/packages/intl/src/strings.ts index a31841975..62200a8ad 100644 --- a/packages/intl/src/strings.ts +++ b/packages/intl/src/strings.ts @@ -2633,5 +2633,6 @@ Use this if changes from other devices are not appearing on this device. This wi exportCsv: () => t`Export CSV`, importCsv: () => t`Import CSV`, noContent: () => t`This note is empty`, - deleteData: () => t`Delete data` + deleteData: () => t`Delete data`, + failedToAttachFile: () => t`Failed to attach file` };