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: open internal links in new tab for middle mouse click (#7688)
01zulfi2ca02937df56
diff --git a/apps/web/src/components/editor/tiptap.tsx b/apps/web/src/components/editor/tiptap.tsxindex 1c86b144d..461497431 100644--- a/apps/web/src/components/editor/tiptap.tsx+++ b/apps/web/src/components/editor/tiptap.tsx@@ -297,11 +297,12 @@ function TipTap(props: TipTapProps) {previewAttachment: onPreviewAttachment,createInternalLink: onInsertInternalLink,getAttachmentData: onGetAttachmentData,- openLink: (url) => {+ openLink: (url, openInNewTab) => {const link = parseInternalLink(url);if (link && link.type === "note") {useEditorStore.getState().openSession(link.id, {- activeBlockId: link.params?.blockId || undefined+ activeBlockId: link.params?.blockId || undefined,+ openInNewTab: openInNewTab});} else window.open(url, "_blank");}diff --git a/packages/editor/src/extensions/link/helpers/clickHandler.ts b/packages/editor/src/extensions/link/helpers/clickHandler.tsindex 0c8d0d4bf..1da14825a 100644--- a/packages/editor/src/extensions/link/helpers/clickHandler.ts+++ b/packages/editor/src/extensions/link/helpers/clickHandler.ts@@ -31,7 +31,9 @@ export function clickHandler(options: ClickHandlerOptions): Plugin {key: new PluginKey("handleClickLink"),props: {handleClick: (view, pos, event) => {- if (event.button !== 0) {+ const isMainClick = event.button === 0;+ const isAuxClick = event.button === 1;+ if (!isMainClick && !isAuxClick) {return false;}@@ -56,7 +58,9 @@ export function clickHandler(options: ClickHandlerOptions): Plugin {if (link && href) {if (options.editor.storage.openLink) {event.preventDefault();- setTimeout(() => options.editor.storage.openLink?.(href));+ setTimeout(() =>+ options.editor.storage.openLink?.(href, isAuxClick)+ );}return true;diff --git a/packages/editor/src/index.ts b/packages/editor/src/index.tsindex f74746389..36a1ed0ac 100644--- a/packages/editor/src/index.ts+++ b/packages/editor/src/index.ts@@ -89,7 +89,7 @@ import { InlineCode } from "./extensions/inline-code/inline-code.js";interface TiptapStorage {dateFormat?: DateTimeOptions["dateFormat"];timeFormat?: DateTimeOptions["timeFormat"];- openLink?: (url: string) => void;+ openLink?: (url: string, openInNewTab?: boolean) => void;downloadAttachment?: (attachment: Attachment) => void;openAttachmentPicker?: (type: AttachmentType) => void;previewAttachment?: (attachment: Attachment) => void;