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
refactor(mobile): share selection contract
tianma-ifb12e160fea19
diff --git a/apps/mobile/src/screens/WorkspaceScreen.tsx b/apps/mobile/src/screens/WorkspaceScreen.tsxindex 34ca868e..cb6f5b5e 100644--- a/apps/mobile/src/screens/WorkspaceScreen.tsx+++ b/apps/mobile/src/screens/WorkspaceScreen.tsx@@ -78,7 +78,7 @@ import { Alert, Pressable, Text, TextInput } from "../components/LocalizedText";import Markdown, { type RenderRules } from "react-native-markdown-display";import { SvgXml } from "react-native-svg";import { buildRevisionDiffRows, createExcerpt, docToMarkdown, docToText, getNotebookDescendantIds, markdownToDoc, type ApiToken, type AuthUser, type MemoDetail, type MemoRevision, type MemoSummary, type Notebook, type ResourceListItem, type RevisionDiffRow, type TagSummary, type TiptapDoc } from "@edgeever/shared";-import { MOBILE_UI_METRICS, toggleMobileMemoFilterMode } from "@edgeever/shared/mobile-ui";+import { MOBILE_UI_METRICS, toggleMobileMemoFilterMode, toggleMobileMemoSelection } from "@edgeever/shared/mobile-ui";import { clearMobileMemoDraft, clearMobileNewMemoDraft, readMobileMemoDraft, readMobileNewMemoDraft, writeMobileMemoDraft, writeMobileNewMemoDraft, type MobileMemoDraft } from "../lib/mobile-drafts";import {readMobileImageCompressionEnabled,@@ -436,17 +436,7 @@ export const WorkspaceScreen = () => {const toggleSelectedMemo = (memoId: string) => {setSelectionMode(true);- setSelectedMemoIds((current) => {- const next = new Set(current);-- if (next.has(memoId)) {- next.delete(memoId);- } else {- next.add(memoId);- }-- return next;- });+ setSelectedMemoIds((current) => toggleMobileMemoSelection(current, memoId));};const clearSelection = () => {@@ -1320,7 +1310,7 @@ const NotesView = ({) : null}<View style={styles.mobileListTitleRow}><Pressable- accessibilityLabel={memoView === "trash" ? "返回笔记列表" : "选择笔记本"}+ accessibilityLabel={memoView === "trash" ? "返回笔记列表" : "切换笔记本"}accessibilityRole="button"onPress={memoView === "trash" ? () => onSetMemoView("notebook") : onOpenNotebookPicker}style={styles.mobileNotebookTitleButton}@@ -1331,7 +1321,7 @@ const NotesView = ({</Text>{memoView === "notebook" ? <ChevronDown color="#64748b" size={16} /> : null}</Pressable>- <Pressable accessibilityLabel={selectionMode ? "批量操作" : "笔记列表操作"} accessibilityRole="button" onPress={onOpenActions} style={styles.mobileMoreButton}>+ <Pressable accessibilityLabel={selectionMode ? "批量操作" : "列表选项"} accessibilityRole="button" onPress={onOpenActions} style={styles.mobileMoreButton}><MoreHorizontal color="#475569" size={20} /></Pressable></View>diff --git a/apps/web/src/components/WorkspaceApp.tsx b/apps/web/src/components/WorkspaceApp.tsxindex 9cbe2d34..107edc2a 100644--- a/apps/web/src/components/WorkspaceApp.tsx+++ b/apps/web/src/components/WorkspaceApp.tsx@@ -38,6 +38,7 @@ import {} from "@/lib/mobile-editor";import { cn } from "@/lib/utils";import { createExcerpt, docToText, getNotebookDescendantIds, type Notebook, type AuthUser, type MemoSummary, type MemoDetail } from "@edgeever/shared";+import { toggleMobileMemoSelection } from "@edgeever/shared/mobile-ui";import type {Pane,MemoView,@@ -67,7 +68,6 @@ import {readMemoListWidthPreference,writeMemoListWidthPreference,clampMemoListWidth,- toggleMemoSelection,getNotebookDropSortOrder,buildNotebookTree,notebookTreeContainsId,@@ -2461,7 +2461,7 @@ export const WorkspaceApp = ({setMemoSelectionMode(true);setSelectedMemoIds((current) => {if (!rangeMemoIds?.length) {- return toggleMemoSelection(current, memoId);+ return toggleMobileMemoSelection(current, memoId);}const next = new Set(current);for (const rangeMemoId of rangeMemoIds) {diff --git a/apps/web/src/lib/app-helpers.ts b/apps/web/src/lib/app-helpers.tsindex 5115b4c4..62826129 100644--- a/apps/web/src/lib/app-helpers.ts+++ b/apps/web/src/lib/app-helpers.ts@@ -508,18 +508,6 @@ export const getNotebookMoveOptions = (notebooks: Notebook[]) => {return options;};-export const toggleMemoSelection = (current: Set<string>, memoId: string) => {- const next = new Set(current);-- if (next.has(memoId)) {- next.delete(memoId);- } else {- next.add(memoId);- }-- return next;-};-export const hasMemoDragData = (dataTransfer: DataTransfer) => Array.from(dataTransfer.types).includes(MEMO_DRAG_MIME);export const hasNotebookDragData = (dataTransfer: DataTransfer) => Array.from(dataTransfer.types).includes(NOTEBOOK_DRAG_MIME);export const hasEdgeEverDragData = (dataTransfer: DataTransfer) => hasMemoDragData(dataTransfer) || hasNotebookDragData(dataTransfer);diff --git a/docs/mobile-native-parity.md b/docs/mobile-native-parity.mdindex aece65a1..36e558a2 100644--- a/docs/mobile-native-parity.md+++ b/docs/mobile-native-parity.md@@ -26,22 +26,22 @@ Build success is not a performance result. Before a Play production rollout, rec- Keep optional heavyweight features out of the startup path. A WebView may only be used for an explicitly selected compatibility editor, never as the App workspace.- Use virtualized lists and stable item components for collections.-## Feature parity status+## Mobile product scope-| PWA capability | Native status |+The App follows the mobile PWA for high-frequency layouts and interactions, but it is not a copy of every desktop management feature. Shared mobile interaction contracts belong in `@edgeever/shared`; platform-specific rendering, local persistence, protected resource loading, and save lifecycles remain separate when that preserves native performance.++| Mobile capability | Native status || --- | --- || Login and self-hosted instance connection | Implemented || Notebook hierarchy and management | Implemented |-| Memo list, filters, sort, pin, trash, batch operations | Implemented |-| Search | Implemented |-| Native Markdown create/edit flow | Implemented |-| Attachments, image compression, resource library | Implemented |-| Tags and templates | Implemented |+| Memo list, filters, sort, pin, and batch operations | Implemented |+| Local-cache search | Implemented |+| Local TipTap create/edit and autosave flow | Implemented |+| Attachments, image compression, and resource library | Implemented |+| Tag management | Implemented || Revision history and restore | Implemented |-| Offline draft and sync queue | Implemented |+| Offline drafts, local mirror, and sync queue | Implemented || MCP/API token management | Implemented |-| Password change | Pending native UI |-| Multi-user management | Pending native UI |-| Unified EdgeEver ZIP import/export | Pending native UI and filesystem bridge |+| Password change and multi-user management | Implemented |-Pending parity items must be implemented natively or through a native system bridge. They must not be solved by restoring the PWA workspace WebView.+Desktop-first management features such as unified ZIP import/export and trash browsing, restore, or empty-trash actions are intentionally excluded from the App core. Ordinary mobile deletion remains a soft delete so that recovery stays available from the desktop/PWA interface. Future mobile work should prioritize capture, reading, editing, search, sync reliability, startup speed, and interaction smoothness instead of restoring these excluded screens.diff --git a/packages/shared/src/mobile-ui.test.mjs b/packages/shared/src/mobile-ui.test.mjsindex 312d2c08..34a13ceb 100644--- a/packages/shared/src/mobile-ui.test.mjs+++ b/packages/shared/src/mobile-ui.test.mjs@@ -1,5 +1,5 @@import { describe, expect, test } from "bun:test";-import { MOBILE_UI_METRICS, toggleMobileMemoFilterMode } from "./mobile-ui.ts";+import { MOBILE_UI_METRICS, toggleMobileMemoFilterMode, toggleMobileMemoSelection } from "./mobile-ui.ts";describe("mobile UI contract", () => {test("keeps core touch targets and navigation metrics stable", () => {@@ -13,4 +13,13 @@ describe("mobile UI contract", () => {expect(toggleMobileMemoFilterMode("pinned", "pinned")).toBe("all");expect(toggleMobileMemoFilterMode("tagged", "untagged")).toBe("untagged");});++ test("shares immutable memo selection behavior across mobile clients", () => {+ const current = new Set(["memo-a"]);+ const added = toggleMobileMemoSelection(current, "memo-b");++ expect(Array.from(current)).toEqual(["memo-a"]);+ expect(Array.from(added)).toEqual(["memo-a", "memo-b"]);+ expect(Array.from(toggleMobileMemoSelection(added, "memo-a"))).toEqual(["memo-b"]);+ });});diff --git a/packages/shared/src/mobile-ui.ts b/packages/shared/src/mobile-ui.tsindex c0feb124..d666c15b 100644--- a/packages/shared/src/mobile-ui.ts+++ b/packages/shared/src/mobile-ui.ts@@ -12,3 +12,18 @@ export const toggleMobileMemoFilterMode = (current: MobileMemoFilterMode,requested: Exclude<MobileMemoFilterMode, "all">): MobileMemoFilterMode => current === requested ? "all" : requested;++export const toggleMobileMemoSelection = (+ current: ReadonlySet<string>,+ memoId: string+): Set<string> => {+ const next = new Set(current);++ if (next.has(memoId)) {+ next.delete(memoId);+ } else {+ next.add(memoId);+ }++ return next;+};