AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
fix(web): open note references on click
tianma-if8004574e7435
diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsxindex c02423b8..b5f1de44 100644--- a/apps/web/src/components/EditorPane.tsx+++ b/apps/web/src/components/EditorPane.tsx@@ -159,6 +159,7 @@ import {getStoredEditorLinkOpenMode,resolveEditorLinkRequireModifier,shouldOpenEditorLink,+ shouldOpenInternalNoteLink,shouldShowEditorLinkOpenHint,type EditorLinkOpenMode,} from "@/lib/editor-link-click";@@ -1645,11 +1646,16 @@ const RichEditorPane = ({}, [cancelResourceMenuHide, isMobileViewport, showResourceMenu]);const showEditorLinkOpenHint = useCallback((target: EventTarget | null) => {+ const link = getEditorNavigableLinkFromEventTarget(target);+ if (parseMemoLinkHref(link?.getAttribute("href"))) {+ setNoteLinkHintPosition(null);+ return;+ }+if (!shouldShowEditorLinkOpenHint(Boolean(editor?.isEditable), isMobileViewport, editorLinkOpenMode)) {return;}- const link = getEditorNavigableLinkFromEventTarget(target);if (link) {setNoteLinkHintPosition(getNoteLinkHintPosition(link));} else {@@ -1685,10 +1691,20 @@ const RichEditorPane = ({}, [scheduleResourceMenuHide]);const handleEditorClickCapture = useCallback((event: ReactMouseEvent<HTMLDivElement>) => {+ const noteLink = getNoteLinkFromEventTarget(event.target);+ const memoId = parseMemoLinkHref(noteLink?.getAttribute("href"));+ if (shouldOpenInternalNoteLink(event, memoId)) {+ event.preventDefault();+ event.stopPropagation();+ setNoteLinkHintPosition(null);+ onOpenMemo?.(memoId as string);+ return;+ }+if (event.button === 0 && !event.ctrlKey && !event.metaKey) {showEditorLinkOpenHint(event.target);}- }, [showEditorLinkOpenHint]);+ }, [onOpenMemo, showEditorLinkOpenHint]);const handleEditorFocusCapture = useCallback((event: ReactFocusEvent<HTMLDivElement>) => {if (showAttachmentMenu(event.target)) return;diff --git a/apps/web/src/lib/editor-link-click.test.mjs b/apps/web/src/lib/editor-link-click.test.mjsindex 1a213fd8..4236e8e1 100644--- a/apps/web/src/lib/editor-link-click.test.mjs+++ b/apps/web/src/lib/editor-link-click.test.mjs@@ -2,6 +2,7 @@ import { describe, expect, test } from "bun:test";import {resolveStoredEditorLinkOpenMode,shouldOpenEditorLink,+ shouldOpenInternalNoteLink,shouldShowEditorLinkOpenHint,} from "./editor-link-click.ts";@@ -50,6 +51,14 @@ describe("editor link click policy", () => {expect(shouldOpenEditorLink(primaryClick, false, { requireModifier: true })).toBe(true);});+ test("opens an internal note reference on a primary click with or without modifiers", () => {+ expect(shouldOpenInternalNoteLink(primaryClick, "memo-1")).toBe(true);+ expect(shouldOpenInternalNoteLink({ ...primaryClick, metaKey: true }, "memo-1")).toBe(true);+ expect(shouldOpenInternalNoteLink({ ...primaryClick, ctrlKey: true }, "memo-1")).toBe(true);+ expect(shouldOpenInternalNoteLink({ ...primaryClick, button: 1 }, "memo-1")).toBe(false);+ expect(shouldOpenInternalNoteLink(primaryClick, null)).toBe(false);+ });+test("does not handle non-primary buttons", () => {expect(shouldOpenEditorLink({ ...primaryClick, button: 1 }, false)).toBe(false);expect(shouldOpenEditorLink({ ...primaryClick, button: 1 }, true, { requireModifier: true })).toBe(false);diff --git a/apps/web/src/lib/editor-link-click.ts b/apps/web/src/lib/editor-link-click.tsindex e96ee304..eae157e0 100644--- a/apps/web/src/lib/editor-link-click.ts+++ b/apps/web/src/lib/editor-link-click.ts@@ -64,6 +64,12 @@ export type ShouldOpenEditorLinkOptions = {requireModifier?: boolean;};+/** Internal note references are navigation controls, not editable web hyperlinks. */+export const shouldOpenInternalNoteLink = (+ event: EditorLinkClick,+ memoId: string | null+): boolean => Boolean(memoId) && event.button === 0;+/*** Decide whether a primary click should open a navigable editor link.* Read-only documents always open on primary click.diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.tsindex 19d4661d..3001b3ad 100644--- a/packages/shared/src/i18n/en-US.ts+++ b/packages/shared/src/i18n/en-US.ts@@ -197,9 +197,9 @@ export const enUS = {aiSpaceShortcutTitle: "Open AI with Space in an empty block",aiSpaceShortcutDescription: "Press Space in an empty rich-text block to open the AI assistant. Turn this off to enter a normal space instead.",aiSpaceShortcutAria: "Open AI with Space in an empty block",- linkOpenModifierTitle: "Open links with Ctrl/⌘ + click while editing",- linkOpenModifierDescription: "On by default: hold Ctrl/⌘ and click to open links, preventing accidental opens while editing. Turn off to use a single click. Desktop only.",- linkOpenModifierAria: "Require Ctrl or ⌘ click to open links while editing",+ linkOpenModifierTitle: "Open web links with Ctrl/⌘ + click while editing",+ linkOpenModifierDescription: "On by default: hold Ctrl/⌘ and click to open web links, preventing accidental opens while editing. Note references always open with one click. Desktop only.",+ linkOpenModifierAria: "Require Ctrl or ⌘ click to open web links while editing",syncIntervalTitle: "Automatic sync interval",syncIntervalDescription: "Sync edits to the server automatically while keeping local drafts available immediately.",syncIntervals: { "30s": "Every 30 seconds", "5m": "Every 5 minutes", "15m": "Every 15 minutes", "30m": "Every 30 minutes", "1h": "Every hour", "2h": "Every 2 hours" },diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.tsindex e1a0c796..09bd4a13 100644--- a/packages/shared/src/i18n/zh-CN.ts+++ b/packages/shared/src/i18n/zh-CN.ts@@ -197,9 +197,9 @@ export const zhCN = {aiSpaceShortcutTitle: "空白段落按 Space 唤起 AI",aiSpaceShortcutDescription: "开启后,在富文本编辑器的空白段落按 Space 会打开 AI 助手;关闭后 Space 恢复普通输入。",aiSpaceShortcutAria: "空白段落按 Space 是否唤起 AI",- linkOpenModifierTitle: "编辑时用 Ctrl/⌘ + 点击打开链接",- linkOpenModifierDescription: "默认开启:需按住 Ctrl/⌘ 再点击链接,避免编辑时误触;关闭后可单击打开(仅桌面)。",- linkOpenModifierAria: "编辑时是否需要 Ctrl 或 ⌘ 再点击才能打开链接",+ linkOpenModifierTitle: "编辑时用 Ctrl/⌘ + 点击打开网页链接",+ linkOpenModifierDescription: "默认开启:网页链接需按住 Ctrl/⌘ 再点击,避免编辑时误触;笔记引用始终单击打开(仅桌面)。",+ linkOpenModifierAria: "编辑时是否需要 Ctrl 或 ⌘ 再点击才能打开网页链接",syncIntervalTitle: "自动同步间隔",syncIntervalDescription: "定期将编辑内容同步到服务器,本地草稿仍会即时保留。",syncIntervals: { "30s": "每 30 秒", "5m": "每 5 分钟", "15m": "每 15 分钟", "30m": "每 30 分钟", "1h": "每 1 小时", "2h": "每 2 小时" },