Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

Improve mobile note selection and sharing actions

tianma-if1d5c5bb17358
diff --git a/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift b/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift
index 050141d8..15a25830 100644
--- a/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift
@@ -8,6 +8,7 @@ struct MemoDetailView: View {
@Environment(\.dismiss) private var dismiss
@Environment(\.colorScheme) private var colorScheme
let memoId: String
+ var initialShareImage = false
/// Present editor from the parent `WorkspaceView` (more reliable than cover on a pushed page).
var onEdit: (String, MemoEditInitialFocus) -> Void = { _, _ in }
@@ -50,6 +51,7 @@ struct MemoDetailView: View {
@State private var imagePreview: (source: String, alt: String)?
/// TipTap EditorBundle is ~4MB; keep native text visible until first setContent finishes.
@State private var bodyReady = false
+ @State private var initialShareImageHandled = false
var body: some View {
VStack(spacing: 0) {
@@ -392,6 +394,10 @@ struct MemoDetailView: View {
}
refreshSyncStatus()
TipTapWarmPool.warmIfNeeded()
+ openInitialShareImageIfReady()
+ }
+ .onChange(of: bodyReady) { _, _ in
+ openInitialShareImageIfReady()
}
.task(id: memoId) {
// Re-load if mirror was empty on first paint (rare race during bootstrap).
@@ -1103,6 +1109,12 @@ struct MemoDetailView: View {
refreshSyncStatus()
}
+ private func openInitialShareImageIfReady() {
+ guard initialShareImage, bodyReady, memo?.isDeleted == false, !initialShareImageHandled else { return }
+ initialShareImageHandled = true
+ imageShareOptionsOpen = true
+ }
+
private func shareMemo(_ memo: MemoDetail) async {
do {
let share = try await env.session.client.createMemoShare(memoId: memo.id)
diff --git a/apps/ios/EdgeEver/Features/Workspace/WorkspaceView.swift b/apps/ios/EdgeEver/Features/Workspace/WorkspaceView.swift
index b67de174..dc1d3df4 100644
--- a/apps/ios/EdgeEver/Features/Workspace/WorkspaceView.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/WorkspaceView.swift
@@ -7,6 +7,16 @@ struct EditingMemoRoute: Identifiable, Hashable {
let initialFocus: MemoEditInitialFocus
}
+private struct ShareImageMemoRoute: Hashable {
+ let memoId: String
+}
+
+private struct SelectionSharePayload: Identifiable {
+ let id = UUID()
+ let message: String
+ let url: URL
+}
+
struct WorkspaceView: View {
@Environment(AppEnvironment.self) private var env
@State private var store = WorkspaceStore()
@@ -20,6 +30,9 @@ struct WorkspaceView: View {
@State private var createLongPressConsumed = false
@State private var showMoveSheet = false
@State private var showSelectionMore = false
+ @State private var pendingMemoShare: MemoSummary?
+ @State private var pendingImageShareMemoId: String?
+ @State private var selectionSharePayload: SelectionSharePayload?
@State private var conflictItem: OutboxItem?
/// Edit is presented from the workspace root — more reliable than cover on a pushed detail page.
@State private var editingMemo: EditingMemoRoute?
@@ -73,19 +86,10 @@ struct WorkspaceView: View {
.ignoresSafeArea(.container, edges: .bottom)
.navigationBarHidden(true)
.navigationDestination(for: String.self) { memoId in
- MemoDetailView(memoId: memoId) { editId, initialFocus in
- // 1) Show edit cover over detail.
- editingMemo = EditingMemoRoute(id: editId, initialFocus: initialFocus)
- // 2) After the cover is up, silently drop detail so the underlay is the list.
- // Dismissing edit then reveals list only — no detail flash.
- DispatchQueue.main.async {
- var t = Transaction()
- t.disablesAnimations = true
- withTransaction(t) {
- path = NavigationPath()
- }
- }
- }
+ memoDetail(for: memoId)
+ }
+ .navigationDestination(for: ShareImageMemoRoute.self) { route in
+ memoDetail(for: route.memoId, shareImage: true)
}
// Android CreateMemoModal is fullScreen — not a half sheet / Form.
.fullScreenCover(isPresented: $showNewNote) {
@@ -165,11 +169,36 @@ struct WorkspaceView: View {
}
}
}
- .sheet(isPresented: $showSelectionMore) {
- SelectionMoreSheet(store: store)
- .presentationDetents([.height(290), .medium])
+ .sheet(isPresented: $showSelectionMore, onDismiss: {
+ if let memo = pendingMemoShare {
+ pendingMemoShare = nil
+ Task { await shareSelectedMemo(memo) }
+ return
+ }
+ guard let memoId = pendingImageShareMemoId else { return }
+ pendingImageShareMemoId = nil
+ store.clearSelection()
+ path.append(ShareImageMemoRoute(memoId: memoId))
+ }) {
+ SelectionMoreSheet(
+ store: store,
+ onShare: { memo in pendingMemoShare = memo },
+ onShareImage: { memo in pendingImageShareMemoId = memo.id }
+ )
+ .presentationDetents([.height(390), .medium])
.presentationDragIndicator(.hidden)
}
+ .sheet(item: $selectionSharePayload) { payload in
+ ActivityShareView(items: [payload.message, payload.url]) { _, _, error in
+ if let error {
+ shareImportAlert = ShareImportAlert(
+ title: env.preferences.t("分享失败", en: "Share failed", pl: "Udostępnianie nie powiodło się"),
+ message: error.localizedDescription
+ )
+ }
+ selectionSharePayload = nil
+ }
+ }
.sheet(item: $conflictItem) { item in
ConflictResolutionView(item: item) {
conflictItem = nil
@@ -636,6 +665,38 @@ struct WorkspaceView: View {
.frame(maxWidth: .infinity)
}
+ private func memoDetail(for memoId: String, shareImage: Bool = false) -> some View {
+ MemoDetailView(memoId: memoId, initialShareImage: shareImage) { editId, initialFocus in
+ editingMemo = EditingMemoRoute(id: editId, initialFocus: initialFocus)
+ // Keep the list under the editor so dismissing it does not flash the detail page.
+ DispatchQueue.main.async {
+ var transaction = Transaction()
+ transaction.disablesAnimations = true
+ withTransaction(transaction) {
+ path = NavigationPath()
+ }
+ }
+ }
+ }
+
+ private func shareSelectedMemo(_ memo: MemoSummary) async {
+ do {
+ let share = try await env.session.client.createMemoShare(memoId: memo.id)
+ let base = env.session.session?.baseUrl.trimmingCharacters(in: CharacterSet(charactersIn: "/")) ?? ""
+ guard let url = URL(string: "\(base)/share/\(share.token)") else { return }
+ let title = memo.title?.trimmingCharacters(in: .whitespacesAndNewlines)
+ let displayTitle = title?.isEmpty == false
+ ? title!
+ : env.preferences.t("无标题笔记", en: "Untitled note", pl: "Notatka bez tytułu")
+ selectionSharePayload = SelectionSharePayload(message: "\(displayTitle)\n\(url.absoluteString)", url: url)
+ } catch {
+ shareImportAlert = ShareImportAlert(
+ title: env.preferences.t("分享失败", en: "Share failed", pl: "Udostępnianie nie powiodło się"),
+ message: error.localizedDescription
+ )
+ }
+ }
+
private var selectionBar: some View {
let bottomInset = MobileUIMetrics.bottomSafeInset
return VStack(spacing: 0) {
@@ -868,6 +929,15 @@ struct SelectionMoreSheet: View {
@Environment(AppEnvironment.self) private var env
@Environment(\.dismiss) private var dismiss
@Bindable var store: WorkspaceStore
+ let onShare: (MemoSummary) -> Void
+ let onShareImage: (MemoSummary) -> Void
+
+ private var shareableMemo: MemoSummary? {
+ guard store.selectedMemoIds.count == 1,
+ let memo = store.memos.first(where: { store.selectedMemoIds.contains($0.id) }),
+ !memo.isDeleted else { return nil }
+ return memo
+ }
var body: some View {
VStack(spacing: 0) {
@@ -924,6 +994,26 @@ struct SelectionMoreSheet: View {
Task { await store.pinSelection(env: env, isPinned: target) }
}
+ selectionAction(
+ icon: "square.and.arrow.up",
+ label: env.preferences.t("分享笔记", en: "Share note", pl: "Udostępnij notatkę"),
+ disabled: shareableMemo == nil
+ ) {
+ guard let memo = shareableMemo else { return }
+ dismiss()
+ onShare(memo)
+ }
+
+ selectionAction(
+ icon: "photo",
+ label: env.preferences.t("分享为图片", en: "Share as image", pl: "Udostępnij jako obraz"),
+ disabled: shareableMemo == nil
+ ) {
+ guard let memo = shareableMemo else { return }
+ onShareImage(memo)
+ dismiss()
+ }
+
selectionAction(
icon: "xmark",
label: env.preferences.t("取消选择", en: "Clear selection", pl: "Wyczyść zaznaczenie"),
diff --git a/apps/mobile/src/screens/WorkspaceActionSheets.tsx b/apps/mobile/src/screens/WorkspaceActionSheets.tsx
index b30cee4e..a126e2f8 100644
--- a/apps/mobile/src/screens/WorkspaceActionSheets.tsx
+++ b/apps/mobile/src/screens/WorkspaceActionSheets.tsx
@@ -154,51 +154,6 @@ export const NotesActionsModal = ({
</Modal>
);
-export const MemoContextActionsModal = ({
- bottomOffset,
- canShare,
- memoTitle,
- onClose,
- onSelect,
- onShare,
- onShareImage,
- visible,
-}: {
- bottomOffset: number;
- canShare: boolean;
- memoTitle: string;
- onClose: () => void;
- onSelect: () => void;
- onShare: () => void;
- onShareImage: () => void;
- visible: boolean;
-}) => (
- <Modal animationType="fade" onRequestClose={onClose} transparent visible={visible}>
- <Pressable onPress={onClose} style={[styles.actionSheetBackdrop, { paddingBottom: bottomOffset }]}>
- <Pressable style={styles.listActionSheet}>
- <View style={styles.actionSheetHandle} />
- <View style={styles.listActionSheetHeader}>
- <View style={styles.listActionSheetHeaderText}>
- <Text numberOfLines={1} style={styles.actionSheetTitle}>笔记操作</Text>
- <Text numberOfLines={1} style={styles.actionSheetSubtitle}>{memoTitle}</Text>
- </View>
- <Pressable accessibilityLabel="关闭" accessibilityRole="button" onPress={onClose} style={styles.sheetCloseButton}>
- <X color="#0f172a" size={18} />
- </Pressable>
- </View>
- {canShare ? (
- <>
- <ActionSheetItem icon={<Share2 color="#0f172a" size={18} />} label="分享笔记" onPress={onShare} />
- <ActionSheetItem icon={<Image color="#0f172a" size={18} />} label="分享为图片" onPress={onShareImage} />
- <View style={styles.listActionDivider} />
- </>
- ) : null}
- <ActionSheetItem icon={<CheckSquare color="#0f172a" size={18} />} label="选择笔记" onPress={onSelect} />
- </Pressable>
- </Pressable>
- </Modal>
-);
-
const SelectionAction = ({
danger = false,
disabled = false,
@@ -265,10 +220,13 @@ export const SelectionActionBar = ({
export const SelectionMoreModal = ({
bottomOffset,
canPin,
+ canShare,
canToggleVisibleSelection,
onClear,
onClose,
onPin,
+ onShare,
+ onShareImage,
onToggleVisibleSelection,
pinLabel,
selectedCount,
@@ -277,10 +235,13 @@ export const SelectionMoreModal = ({
}: {
bottomOffset: number;
canPin: boolean;
+ canShare: boolean;
canToggleVisibleSelection: boolean;
onClear: () => void;
onClose: () => void;
onPin: () => void;
+ onShare: () => void;
+ onShareImage: () => void;
onToggleVisibleSelection: () => void;
pinLabel: string;
selectedCount: number;
@@ -312,6 +273,18 @@ export const SelectionMoreModal = ({
label={pinLabel}
onPress={onPin}
/>
+ <ActionSheetItem
+ disabled={!canShare}
+ icon={<Share2 color={canShare ? "#0f172a" : "#cbd5e1"} size={18} />}
+ label="分享笔记"
+ onPress={onShare}
+ />
+ <ActionSheetItem
+ disabled={!canShare}
+ icon={<Image color={canShare ? "#0f172a" : "#cbd5e1"} size={18} />}
+ label="分享为图片"
+ onPress={onShareImage}
+ />
<ActionSheetItem icon={<X color="#0f172a" size={18} />} label="取消选择" onPress={onClear} />
</Pressable>
</Pressable>
diff --git a/apps/mobile/src/screens/WorkspaceNotesView.tsx b/apps/mobile/src/screens/WorkspaceNotesView.tsx
index 4fb6273e..256448b1 100644
--- a/apps/mobile/src/screens/WorkspaceNotesView.tsx
+++ b/apps/mobile/src/screens/WorkspaceNotesView.tsx
@@ -472,14 +472,14 @@ const MemoCard = memo(function MemoCard({
</Pressable>
) : null}
<Pressable
- accessibilityHint={selectionMode ? undefined : (resolvedLocale !== "zh-CN" ? "Long press for note actions" : "长按打开笔记操作")}
+ accessibilityHint={selectionMode ? undefined : (resolvedLocale !== "zh-CN" ? "Long press to select this note" : "长按选择这条笔记")}
accessibilityLabel={memoTitle}
accessibilityRole="button"
delayLongPress={520}
- onLongPress={() => {
+ onLongPress={onLongPress ? () => {
handledLongPressRef.current = true;
- onLongPress?.();
- }}
+ onLongPress();
+ } : undefined}
onPress={() => {
if (handledLongPressRef.current) {
handledLongPressRef.current = false;
diff --git a/apps/mobile/src/screens/WorkspaceScreen.tsx b/apps/mobile/src/screens/WorkspaceScreen.tsx
index 0092744b..3c32437f 100644
--- a/apps/mobile/src/screens/WorkspaceScreen.tsx
+++ b/apps/mobile/src/screens/WorkspaceScreen.tsx
@@ -111,7 +111,6 @@ import {
import { RevisionHistoryModal } from "./WorkspaceRevisionHistory";
import { CreateMemoModal } from "./WorkspaceEditors";
import {
- MemoContextActionsModal,
NotesActionsModal,
SelectionActionBar,
SelectionMoreModal,
@@ -166,7 +165,6 @@ export const WorkspaceScreen = ({
const [showDescendantNotes, setShowDescendantNotes] = useState<boolean | null>(null);
const [showDescendantNotesSaveFailed, setShowDescendantNotesSaveFailed] = useState(false);
const [selectedMemoId, setSelectedMemoId] = useState<string | null>(null);
- const [contextMemo, setContextMemo] = useState<MemoSummary | null>(null);
const [imageShareFromList, setImageShareFromList] = useState(false);
const [searchText, setSearchText] = useState("");
const [createOpen, setCreateOpen] = useState(false);
@@ -1268,7 +1266,7 @@ export const WorkspaceScreen = ({
onMemoPress={handleMemoPress}
onMemoLongPress={(memo) => {
Vibration.vibrate(8);
- setContextMemo(memo);
+ selectSingleMemo(memo.id);
}}
onLoadMore={() => {
const query = searchActive ? searchQuery : memosQuery;
@@ -1345,29 +1343,6 @@ export const WorkspaceScreen = ({
visible={Boolean(selectedMemoId)}
/>
- {contextMemo ? (
- <MemoContextActionsModal
- bottomOffset={52 + safeAreaInsets.bottom}
- canShare={!contextMemo.isDeleted}
- memoTitle={localizeUntitledMemoTitle(contextMemo.title, resolvedLocale)}
- onClose={() => setContextMemo(null)}
- onSelect={() => {
- selectSingleMemo(contextMemo.id);
- setContextMemo(null);
- }}
- onShare={() => {
- shareMemoMutation.mutate(contextMemo);
- setContextMemo(null);
- }}
- onShareImage={() => {
- setContextMemo(null);
- setImageShareFromList(true);
- setSelectedMemoId(contextMemo.id);
- }}
- visible
- />
- ) : null}
-
{notebookPickerOpen ? <NotebookPickerModal
activeNotebookId={activeNotebookId}
notebooks={notebooks}
@@ -1508,6 +1483,7 @@ export const WorkspaceScreen = ({
{selectionMoreOpen ? <SelectionMoreModal
bottomOffset={58 + safeAreaInsets.bottom}
canPin={memoView !== "trash" && selectedMemoIds.size > 0 && !pinMemosMutation.isPending}
+ canShare={memoView !== "trash" && selectedMemoIds.size === 1 && selectedMemos.length === 1 && !selectedMemos[0]?.isDeleted && !shareMemoMutation.isPending}
canToggleVisibleSelection={canToggleVisibleSelection}
onClear={clearSelection}
onClose={() => setSelectionMoreOpen(false)}
@@ -1515,6 +1491,20 @@ export const WorkspaceScreen = ({
setSelectionMoreOpen(false);
pinMemosMutation.mutate({ memoIds: selectedMemoIdList, isPinned: nextSelectionPinValue });
}}
+ onShare={() => {
+ const memo = selectedMemos[0];
+ if (!memo) return;
+ setSelectionMoreOpen(false);
+ shareMemoMutation.mutate(memo);
+ }}
+ onShareImage={() => {
+ const memo = selectedMemos[0];
+ if (!memo) return;
+ setSelectionMoreOpen(false);
+ clearSelection();
+ setImageShareFromList(true);
+ setSelectedMemoId(memo.id);
+ }}
onToggleVisibleSelection={() => {
setSelectionMoreOpen(false);
toggleVisibleSelection(visibleMemos.map((memo) => memo.id));