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
feat: copy current note ID across clients
tianma-ifcf1bb1aef5b5
diff --git a/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift b/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swiftindex 5f267de6..11abfc36 100644--- a/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift+++ b/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift@@ -1,5 +1,6 @@import SwiftUIimport Pow+import UIKit/// Android WorkspaceMemoDetail shell parity (detailHeader*, detailMeta*, detailEditFab).struct MemoDetailView: View {@@ -24,6 +25,7 @@ struct MemoDetailView: View {@State private var searchMatchIndex = 0@State private var showDeleteConfirm = false@State private var showMoreMenu = false+ @State private var showNoteIdCopied = false@State private var resourceTarget: ResourceTarget?@State private var imagePreview: (source: String, alt: String)?/// TipTap EditorBundle is ~4MB; keep native text visible until first setContent finishes.@@ -144,6 +146,15 @@ struct MemoDetailView: View {Button(env.preferences.t("分享链接", en: "Share link")) {Task { await shareMemo(memo) }}+ Button(+ isTemporaryMemoId(memo.id)+ ? env.preferences.t("同步后可复制笔记 ID", en: "Copy note ID after sync")+ : env.preferences.t("复制笔记 ID", en: "Copy note ID")+ ) {+ UIPasteboard.general.string = memo.id+ showNoteIdCopied = true+ }+ .disabled(isTemporaryMemoId(memo.id))Button(env.preferences.t("修订历史", en: "Revisions")) { showRevisions = true }Button(env.preferences.t("删除", en: "Delete"), role: .destructive) {showDeleteConfirm = true@@ -158,6 +169,14 @@ struct MemoDetailView: View {} message: {Text(env.preferences.t("笔记将移入回收站。", en: "The note will move to trash."))}+ .alert(+ env.preferences.t("笔记 ID 已复制", en: "Note ID copied"),+ isPresented: $showNoteIdCopied+ ) {+ Button(env.preferences.t("好", en: "OK"), role: .cancel) {}+ } message: {+ Text(memo?.id ?? memoId)+ }// Local SQLite mirror is sync and cheap — load before the first blank ProgressView frame..onAppear {if memo == nil {@@ -670,6 +689,10 @@ struct MemoDetailView: View {UIPasteboard.general.string = text}+ private func isTemporaryMemoId(_ id: String) -> Bool {+ id.hasPrefix("local:") || id.hasPrefix("local_")+ }+private func closeSearch() {searchOpen = falsesearchQuery = ""diff --git a/apps/mobile/src/lib/mobile-locale.tsx b/apps/mobile/src/lib/mobile-locale.tsxindex fd3e45f4..fd6c86f8 100644--- a/apps/mobile/src/lib/mobile-locale.tsx+++ b/apps/mobile/src/lib/mobile-locale.tsx@@ -33,6 +33,10 @@ const mobileOnlyTranslations = new Map<string, string>([["笔记操作", "Note actions"],["版本历史", "Version history"],["分享笔记", "Share note"],+ ["复制笔记 ID", "Copy note ID"],+ ["同步后可复制笔记 ID", "Copy note ID after sync"],+ ["笔记 ID 已复制", "Note ID copied"],+ ["复制笔记 ID 失败", "Could not copy note ID"],["分享失败", "Could not share"],["无法创建分享链接,请检查网络后重试。", "Could not create a share link. Check your connection and try again."],["同步冲突", "Sync conflict"],diff --git a/apps/mobile/src/screens/WorkspaceMemoDetail.tsx b/apps/mobile/src/screens/WorkspaceMemoDetail.tsxindex afd28301..175e5190 100644--- a/apps/mobile/src/screens/WorkspaceMemoDetail.tsx+++ b/apps/mobile/src/screens/WorkspaceMemoDetail.tsx@@ -1,10 +1,11 @@import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";import { DEFAULT_MEMO_TITLE, resolveMemoContentDoc, type MemoDetail, type TiptapDoc } from "@edgeever/shared";+import * as Clipboard from "expo-clipboard";import { Image as RNImage, Platform, StyleSheet, View, type ImageStyle, type StyleProp } from "react-native";import { Modal } from "react-native";import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";import { SvgXml } from "react-native-svg";-import { ActivityIndicator, ChevronDown, ChevronLeft, ChevronRight, History, MoreHorizontal, Pencil, RotateCcw, Search, Share2, Tag, Trash2, X } from "../components/icons";+import { ActivityIndicator, ChevronDown, ChevronLeft, ChevronRight, Copy, History, MoreHorizontal, Pencil, RotateCcw, Search, Share2, Tag, Trash2, X } from "../components/icons";import { Alert, Pressable, Text, TextInput } from "../components/LocalizedText";import LocalTiptapEditor, { type LocalTiptapEditorRef } from "../components/LocalTiptapEditor";import { MobileResourceActions } from "../components/MobileResourceActions";@@ -491,6 +492,23 @@ export const MemoDetailModal = ({action();};+ const canCopyMemoId = Boolean(memo && !memo.id.startsWith("local:") && !memo.id.startsWith("local_"));+ const copyMemoId = async () => {+ if (!memo || !canCopyMemoId) return;+ try {+ await Clipboard.setStringAsync(memo.id);+ Alert.alert(+ resolvedLocale === "en-US" ? "Note ID copied" : "笔记 ID 已复制",+ memo.id+ );+ } catch {+ Alert.alert(+ resolvedLocale === "en-US" ? "Could not copy note ID" : "复制笔记 ID 失败",+ resolvedLocale === "en-US" ? "Please try again." : "请稍后重试。"+ );+ }+ };+return (<Modal animationType="slide" onRequestClose={onClose} presentationStyle="fullScreen" visible={visible}><SafeAreaView style={styles.modalSafeArea}>@@ -555,7 +573,7 @@ export const MemoDetailModal = ({<Search color="#475569" size={20} /></Pressable>) : null}- {memo?.isDeleted ? (+ {memo ? (<Pressable accessibilityLabel="笔记操作" accessibilityRole="button" onPress={() => setActionsOpen(true)} style={styles.detailHeaderIconButton}><MoreHorizontal color="#475569" size={21} /></Pressable>@@ -752,19 +770,29 @@ export const MemoDetailModal = ({<Pencil color="#ffffff" size={20} /></Pressable>) : null}- {memo?.isDeleted ? (+ {memo ? (<Modal animationType="fade" onRequestClose={() => setActionsOpen(false)} transparent visible={actionsOpen}><Pressable onPress={() => setActionsOpen(false)} style={styles.actionSheetBackdrop}><Pressable style={styles.actionSheet}><View style={styles.actionSheetHandle} /><Text style={styles.actionSheetTitle}>笔记操作</Text>- <DetailActionSheetItem icon={<Search color="#0f172a" size={18} />} label="搜索当前笔记" onPress={() => closeActionsAndRun(() => {- setSearchOpen(true);- })} />- <DetailActionSheetItem icon={<History color="#0f172a" size={18} />} label="版本历史" onPress={() => closeActionsAndRun(() => onOpenRevisions(memo))} />- <DetailActionSheetItem disabled={isRestoring} icon={<RotateCcw color="#0f172a" size={18} />} label={isRestoring ? "恢复中" : "恢复笔记"} onPress={() => closeActionsAndRun(() => onRestore(memo))} />- <View style={styles.listActionDivider} />- <DetailActionSheetItem danger disabled={isDeleting} icon={<Trash2 color="#b91c1c" size={18} />} label={isDeleting ? "删除中" : "彻底删除"} onPress={() => closeActionsAndRun(() => onDelete(memo))} />+ <DetailActionSheetItem+ disabled={!canCopyMemoId}+ icon={<Copy color="#0f172a" size={18} />}+ label={canCopyMemoId ? "复制笔记 ID" : "同步后可复制笔记 ID"}+ onPress={() => closeActionsAndRun(() => void copyMemoId())}+ />+ {memo.isDeleted ? (+ <>+ <DetailActionSheetItem icon={<Search color="#0f172a" size={18} />} label="搜索当前笔记" onPress={() => closeActionsAndRun(() => {+ setSearchOpen(true);+ })} />+ <DetailActionSheetItem icon={<History color="#0f172a" size={18} />} label="版本历史" onPress={() => closeActionsAndRun(() => onOpenRevisions(memo))} />+ <DetailActionSheetItem disabled={isRestoring} icon={<RotateCcw color="#0f172a" size={18} />} label={isRestoring ? "恢复中" : "恢复笔记"} onPress={() => closeActionsAndRun(() => onRestore(memo))} />+ <View style={styles.listActionDivider} />+ <DetailActionSheetItem danger disabled={isDeleting} icon={<Trash2 color="#b91c1c" size={18} />} label={isDeleting ? "删除中" : "彻底删除"} onPress={() => closeActionsAndRun(() => onDelete(memo))} />+ </>+ ) : null}</Pressable></Pressable></Modal>diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsxindex 9633119a..eae551d8 100644--- a/apps/web/src/components/EditorPane.tsx+++ b/apps/web/src/components/EditorPane.tsx@@ -35,6 +35,7 @@ import {FileDown,Printer,Link2,+ Copy,} from "lucide-react";import { Button } from "@/components/ui/button";import { GitHubRepositoryLink } from "@/components/GitHubRepositoryLink";@@ -726,6 +727,7 @@ const RichEditorPane = ({const [mobileImeDebugActiveElement, setMobileImeDebugActiveElement] = useState(getActiveElementLabel);const [mobileImeDebugEvents, setMobileImeDebugEvents] = useState<MobileImeDebugEntry[]>([]);const [wechatCopyState, setWechatCopyState] = useState<"idle" | "copying" | "copied" | "error">("idle");+ const [memoIdCopyNotice, setMemoIdCopyNotice] = useState<{ status: "copied" | "error"; id: string } | null>(null);const noteLinkModifier = useMemo(() => typeof navigator !== "undefined" && /mac|iphone|ipad|ipod/i.test(navigator.platform) ? "⌘" : "Ctrl",[]@@ -2215,6 +2217,15 @@ const RichEditorPane = ({}}, [editor, markdownSource, useMarkdownSourceEditor]);+ const handleCopyMemoId = useCallback(async () => {+ if (!memo || isLocalMemoId(memo.id)) {+ return;+ }+ const copied = await copyTextToClipboard(memo.id);+ setMemoIdCopyNotice({ status: copied ? "copied" : "error", id: memo.id });+ window.setTimeout(() => setMemoIdCopyNotice(null), copied ? 2200 : 3000);+ }, [memo]);+const handleExportPdf = useCallback((preopenedWindow?: Window | null) => {if (!isEditorReady(editor) || !memo) {return;@@ -3489,6 +3500,14 @@ const RichEditorPane = ({<Search className="h-4 w-4 text-slate-500" />{t("editor.searchCurrentMemo")}</DropdownMenuItem>+ <DropdownMenuItem+ className="flex h-9 w-full items-center gap-2 px-3 text-left text-sm text-slate-700 hover:bg-slate-50 cursor-pointer outline-none"+ disabled={isLocalMemoId(memo.id)}+ onClick={() => void handleCopyMemoId()}+ >+ <Copy className="h-4 w-4 text-slate-500" />+ {t(isLocalMemoId(memo.id) ? "editor.copyNoteIdAfterSync" : "editor.copyNoteId")}+ </DropdownMenuItem><DropdownMenuItemclassName="flex h-9 w-full items-center gap-2 px-3 text-left text-sm text-slate-700 hover:bg-slate-50 cursor-pointer outline-none"onClick={openNoteReplace}@@ -4047,6 +4066,18 @@ const RichEditorPane = ({</div>)}+ {memoIdCopyNotice && (+ <div+ className={cn(+ "fixed bottom-5 left-1/2 z-[120] max-w-[calc(100vw-2rem)] -translate-x-1/2 truncate rounded-md px-3 py-2 text-sm font-medium text-white shadow-lg",+ memoIdCopyNotice.status === "copied" ? "bg-emerald-700" : "bg-rose-600",+ )}+ role={memoIdCopyNotice.status === "copied" ? "status" : "alert"}+ >+ {t(memoIdCopyNotice.status === "copied" ? "editor.noteIdCopied" : "editor.noteIdCopyFailed", { id: memoIdCopyNotice.id })}+ </div>+ )}+{false && useMobilePlainTextEditor && (<div className="fixed left-2 right-2 top-[max(3.5rem,env(safe-area-inset-top))] z-[70] rounded-md border border-amber-200 bg-amber-50/95 p-2 text-[11px] text-slate-800 shadow-lg backdrop-blur sm:hidden"><div className="flex items-center justify-between gap-2">diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.tsindex 10d358f0..a67177c8 100644--- a/packages/shared/src/i18n/en-US.ts+++ b/packages/shared/src/i18n/en-US.ts@@ -730,6 +730,10 @@ export const enUS = {searchCurrentMemo: "Search current note",replaceCurrentMemo: "Replace in current note",versionHistory: "Version history",+ copyNoteId: "Copy note ID",+ copyNoteIdAfterSync: "Copy note ID after sync",+ noteIdCopied: "Note ID copied: {{id}}",+ noteIdCopyFailed: "Could not copy the note ID.",exportMarkdown: "Export Markdown",exportPdf: "Export PDF",pdfExport: {diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.tsindex 3314cb67..065cb02d 100644--- a/packages/shared/src/i18n/zh-CN.ts+++ b/packages/shared/src/i18n/zh-CN.ts@@ -730,6 +730,10 @@ export const zhCN = {searchCurrentMemo: "搜索当前笔记",replaceCurrentMemo: "替换当前笔记",versionHistory: "版本历史",+ copyNoteId: "复制笔记 ID",+ copyNoteIdAfterSync: "同步后可复制笔记 ID",+ noteIdCopied: "笔记 ID 已复制:{{id}}",+ noteIdCopyFailed: "复制笔记 ID 失败。",exportMarkdown: "导出 Markdown",exportPdf: "导出 PDF",pdfExport: {diff --git a/tests/note-id-copy.test.ts b/tests/note-id-copy.test.tsnew file mode 100644index 00000000..f6a4cd86--- /dev/null+++ b/tests/note-id-copy.test.ts@@ -0,0 +1,28 @@+import { describe, expect, test } from "bun:test";+import { readFileSync } from "node:fs";++const readSource = (path: string) => readFileSync(new URL(path, import.meta.url), "utf8");++const webEditorSource = readSource("../apps/web/src/components/EditorPane.tsx");+const androidDetailSource = readSource("../apps/mobile/src/screens/WorkspaceMemoDetail.tsx");+const iosDetailSource = readSource("../apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift");++describe("copy current note ID", () => {+ test("copies the raw memo ID from the desktop and web note menu", () => {+ expect(webEditorSource).toContain("copyTextToClipboard(memo.id)");+ expect(webEditorSource).toContain('"editor.copyNoteId"');+ });++ test("copies the raw memo ID from both native mobile clients", () => {+ expect(androidDetailSource).toContain("Clipboard.setStringAsync(memo.id)");+ expect(androidDetailSource).toContain('label={canCopyMemoId ? "复制笔记 ID"');+ expect(iosDetailSource).toContain("UIPasteboard.general.string = memo.id");+ expect(iosDetailSource).toContain('env.preferences.t("复制笔记 ID", en: "Copy note ID")');+ });++ test("does not present temporary local IDs as agent-readable IDs", () => {+ expect(webEditorSource).toContain("disabled={isLocalMemoId(memo.id)}");+ expect(androidDetailSource).toContain('!memo.id.startsWith("local:")');+ expect(iosDetailSource).toContain('id.hasPrefix("local:") || id.hasPrefix("local_")');+ });+});