A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix: duplicate image att. when pasting (fixes streetwriters/notesnook#800)
thecodrrd957e1b4a1f0
diff --git a/apps/web/src/components/editor/index.tsx b/apps/web/src/components/editor/index.tsxindex 0fdd30849..841742bb4 100644--- a/apps/web/src/components/editor/index.tsx+++ b/apps/web/src/components/editor/index.tsx@@ -129,19 +129,6 @@ export default function EditorManager({alignSelf: "stretch",overflow: "hidden",}}- onPaste={async (event) => {- if (!editor) return;-- if (event.clipboardData?.files?.length) {- event.preventDefault();- for (let file of event.clipboardData.files) {- const result = await attachFile(file);- if (!result) continue;-- editor.attachFile(result);- }- }- }}>{previewSession.current && (<PreviewModeNotice@@ -257,6 +244,11 @@ export function Editor(props: EditorProps) {editor?.attachFile(file);});}}+ onAttachFile={async (file) => {+ const result = await attachFile(file);+ if (!result) return;+ editor?.attachFile(result);+ }}/></EditorChrome>);diff --git a/apps/web/src/components/editor/tiptap.tsx b/apps/web/src/components/editor/tiptap.tsxindex d4aa62547..43be3a20e 100644--- a/apps/web/src/components/editor/tiptap.tsx+++ b/apps/web/src/components/editor/tiptap.tsx@@ -33,6 +33,7 @@ type TipTapProps = {onChange?: (content: string) => void;onInsertAttachment?: (type: AttachmentType) => void;onDownloadAttachment?: (attachment: Attachment) => void;+ onAttachFile?: (file: File) => void;onFocus?: () => void;content?: string;toolbarContainerId?: string;@@ -46,6 +47,7 @@ function TipTap(props: TipTapProps) {onChange,onInsertAttachment,onDownloadAttachment,+ onAttachFile,onFocus = () => {},content,toolbarContainerId,@@ -75,6 +77,18 @@ function TipTap(props: TipTapProps) {const editor = useTiptap({+ editorProps: {+ handlePaste: (view, event) => {+ if (event.clipboardData?.files?.length && onAttachFile) {+ event.preventDefault();+ event.stopPropagation();+ for (let file of event.clipboardData.files) {+ onAttachFile(file);+ }+ return true;+ }+ },+ },doubleSpacedLines,isKeyboardOpen: true,isMobile: isMobile || false,