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
editor: enable attachment previews for files
ammarahm-ed72275137835d
diff --git a/packages/editor/src/toolbar/tools/attachment.tsx b/packages/editor/src/toolbar/tools/attachment.tsxindex cb1599df3..c09de5154 100644--- a/packages/editor/src/toolbar/tools/attachment.tsx+++ b/packages/editor/src/toolbar/tools/attachment.tsx@@ -61,10 +61,23 @@ export function DownloadAttachment(props: ToolProps) {/>);}+const previewableFileExtensions = ["pdf"];+function canPreviewAttachment(attachment: Attachment) {+ if (!attachment) return false;+ const extension = attachment.filename?.split(".").pop();+ if (!extension) return false;++ return previewableFileExtensions.indexOf(extension) > -1;+}export function PreviewAttachment(props: ToolProps) {const { editor } = props;- if (!editor.isActive("image")) return null;+ const attachmentNode =+ findSelectedNode(editor, "attachment") || findSelectedNode(editor, "image");+ const attachment = (attachmentNode?.attrs || {}) as Attachment;++ if (!editor.isActive("image") && !canPreviewAttachment(attachment))+ return null;return (<ToolButton