Skip to content

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

feat: configure automatic sync interval

tianma-if1f0d96c041c1
diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx
index 733403cf..a6fbce5d 100644
--- a/apps/web/src/components/EditorPane.tsx
+++ b/apps/web/src/components/EditorPane.tsx
@@ -100,7 +100,6 @@ import { RELEASE_STATUS_EVENT } from "@/lib/release-notice";
const SUPPORTED_PASTE_IMAGE_TYPES = new Set(["image/png", "image/jpeg", "image/gif", "image/webp", "image/avif"]);
const MOBILE_EDITOR_QUERY = "(max-width: 639px)";
-const EDITOR_AUTO_SAVE_DELAY_MS = 1200;
const MOBILE_DRAFT_PERSIST_DELAY_MS = 800;
const NOTE_SEARCH_HIGHLIGHT_PLUGIN_KEY = new PluginKey("edgeever-note-search-highlight");
@@ -500,6 +499,7 @@ type EditorPaneProps = {
isLoading: boolean;
contentSearchQuery?: string;
imageCompressionEnabled: boolean;
+ autoSaveIntervalMs: number | null;
hasNextMemo: boolean;
hasPreviousMemo: boolean;
onBackToList: () => void;
@@ -524,6 +524,7 @@ const MobileNativeEditorPane = ({
memo,
notebooks,
isTrashView,
+ autoSaveIntervalMs,
onBackToList,
onSaved,
onMobileDefaultEditConsumed,
@@ -709,14 +710,17 @@ const MobileNativeEditorPane = ({
if (saveTimerRef.current !== null) {
window.clearTimeout(saveTimerRef.current);
- }
- saveTimerRef.current = window.setTimeout(() => {
saveTimerRef.current = null;
- if (hasUnsavedChangesRef.current) {
- void saveCurrent();
- }
- }, EDITOR_AUTO_SAVE_DELAY_MS);
- }, [persistDraft, saveCurrent]);
+ }
+ if (autoSaveIntervalMs !== null) {
+ saveTimerRef.current = window.setTimeout(() => {
+ saveTimerRef.current = null;
+ if (hasUnsavedChangesRef.current) {
+ void saveCurrent();
+ }
+ }, autoSaveIntervalMs);
+ }
+ }, [autoSaveIntervalMs, persistDraft, saveCurrent]);
useEffect(() => {
document.documentElement.classList.add("edgeever-mobile-native-editing");
@@ -1121,6 +1125,7 @@ const RichEditorPane = ({
isLoading,
contentSearchQuery = "",
imageCompressionEnabled,
+ autoSaveIntervalMs,
hasNextMemo,
hasPreviousMemo,
onBackToList,
@@ -2173,21 +2178,23 @@ const RichEditorPane = ({
if (mobileSaveTimerRef.current !== null) {
window.clearTimeout(mobileSaveTimerRef.current);
}
- mobileSaveTimerRef.current = window.setTimeout(() => {
- mobileSaveTimerRef.current = null;
- if (
- !memoRef.current ||
- memoRef.current.isDeleted ||
- !hasUnsavedChangesRef.current ||
- saveMutation.isPending ||
- saveState === "conflict"
- ) {
- return;
- }
+ if (autoSaveIntervalMs !== null) {
+ mobileSaveTimerRef.current = window.setTimeout(() => {
+ mobileSaveTimerRef.current = null;
+ if (
+ !memoRef.current ||
+ memoRef.current.isDeleted ||
+ !hasUnsavedChangesRef.current ||
+ saveMutation.isPending ||
+ saveState === "conflict"
+ ) {
+ return;
+ }
- saveMutation.mutate();
- }, EDITOR_AUTO_SAVE_DELAY_MS);
- }, [getMobilePlainTextValue, persistCurrentDraft, saveMutation, saveState, tagsText, title]);
+ saveMutation.mutate();
+ }, autoSaveIntervalMs);
+ }
+ }, [autoSaveIntervalMs, getMobilePlainTextValue, persistCurrentDraft, saveMutation, saveState, tagsText, title]);
useEffect(() => {
markMobilePlainTextDirtyRef.current = markMobilePlainTextDirty;
@@ -2254,12 +2261,16 @@ const RichEditorPane = ({
return;
}
+ if (autoSaveIntervalMs === null) {
+ return;
+ }
+
const timer = window.setTimeout(() => {
saveMutation.mutate();
- }, EDITOR_AUTO_SAVE_DELAY_MS);
+ }, autoSaveIntervalMs);
return () => window.clearTimeout(timer);
- }, [dirtyVersion, editor, hasUnsavedChanges, memo, saveMutation, saveState, useMobilePlainTextEditor]);
+ }, [autoSaveIntervalMs, dirtyVersion, editor, hasUnsavedChanges, memo, saveMutation, saveState, useMobilePlainTextEditor]);
if (isSelectionMode) {
return (
diff --git a/apps/web/src/components/MobileStandaloneTiptapEditor.tsx b/apps/web/src/components/MobileStandaloneTiptapEditor.tsx
index ba9d18e4..04d488c0 100644
--- a/apps/web/src/components/MobileStandaloneTiptapEditor.tsx
+++ b/apps/web/src/components/MobileStandaloneTiptapEditor.tsx
@@ -14,7 +14,7 @@ import {
MobileEditorNotebookSheet,
MobileEditorToolbar,
} from "@/components/MobileStandaloneEditorParts";
-import { getEditableMemoTitle, getNotebookMoveOptions } from "@/lib/app-helpers";
+import { getEditableMemoTitle, getNotebookMoveOptions, readAutoSaveIntervalPreference } from "@/lib/app-helpers";
import { defaultLocale, normalizeLocale } from "@/i18n/locales";
import { compressImageForUpload } from "@/lib/image-compression";
import { localDb, type LocalDraft } from "@/lib/local-db";
@@ -24,7 +24,6 @@ import {
writeMobileEditorReturnPreview,
} from "@/lib/mobile-editor";
import {
- MOBILE_EDITOR_AUTO_SAVE_DELAY_MS,
MOBILE_EDITOR_INITIAL_FOCUS_DELAY_MS,
MOBILE_EDITOR_LEAVE_SAVE_TIMEOUT_MS,
getMobileEditorDraftKey,
@@ -201,10 +200,13 @@ export const MobileStandaloneTiptapEditor = ({
if (saveTimerRef.current !== null) {
window.clearTimeout(saveTimerRef.current);
}
- saveTimerRef.current = window.setTimeout(() => {
- saveTimerRef.current = null;
- void saveNowRef.current();
- }, MOBILE_EDITOR_AUTO_SAVE_DELAY_MS);
+ const autoSaveIntervalMs = readAutoSaveIntervalPreference();
+ if (autoSaveIntervalMs !== null) {
+ saveTimerRef.current = window.setTimeout(() => {
+ saveTimerRef.current = null;
+ void saveNowRef.current();
+ }, autoSaveIntervalMs);
+ }
},
});
@@ -450,10 +452,13 @@ export const MobileStandaloneTiptapEditor = ({
if (saveTimerRef.current !== null) {
window.clearTimeout(saveTimerRef.current);
}
- saveTimerRef.current = window.setTimeout(() => {
- saveTimerRef.current = null;
- void saveNow();
- }, MOBILE_EDITOR_AUTO_SAVE_DELAY_MS);
+ const autoSaveIntervalMs = readAutoSaveIntervalPreference();
+ if (autoSaveIntervalMs !== null) {
+ saveTimerRef.current = window.setTimeout(() => {
+ saveTimerRef.current = null;
+ void saveNow();
+ }, autoSaveIntervalMs);
+ }
}, [persistLocalDraft, saveNow, setSaveStateStable]);
const persistReturnPreview = useCallback(() => {
diff --git a/apps/web/src/components/SettingsPane.tsx b/apps/web/src/components/SettingsPane.tsx
index caee0c12..86c10f7b 100644
--- a/apps/web/src/components/SettingsPane.tsx
+++ b/apps/web/src/components/SettingsPane.tsx
@@ -32,6 +32,8 @@ interface SettingsPaneProps {
onOpenTemplates: () => void;
imageCompressionEnabled: boolean;
onImageCompressionChange: (enabled: boolean) => void;
+ autoSaveIntervalMs: number | null;
+ onAutoSaveIntervalChange: (intervalMs: number | null) => void;
shortcutSettings: ShortcutSettings;
onShortcutSettingsChange: (settings: ShortcutSettings) => void;
onLogout: () => void;
@@ -66,6 +68,8 @@ export const SettingsPane = ({
onOpenTemplates,
imageCompressionEnabled,
onImageCompressionChange,
+ autoSaveIntervalMs,
+ onAutoSaveIntervalChange,
shortcutSettings,
onShortcutSettingsChange,
onLogout,
@@ -170,6 +174,8 @@ export const SettingsPane = ({
<PreferenceCard
imageCompressionEnabled={imageCompressionEnabled}
onImageCompressionChange={onImageCompressionChange}
+ autoSaveIntervalMs={autoSaveIntervalMs}
+ onAutoSaveIntervalChange={onAutoSaveIntervalChange}
shortcutSettings={shortcutSettings}
onShortcutSettingsChange={onShortcutSettingsChange}
/>
diff --git a/apps/web/src/components/WorkspaceApp.tsx b/apps/web/src/components/WorkspaceApp.tsx
index 652d0bd5..ec8e6a4f 100644
--- a/apps/web/src/components/WorkspaceApp.tsx
+++ b/apps/web/src/components/WorkspaceApp.tsx
@@ -59,7 +59,9 @@ import {
MAX_MEMO_LIST_WIDTH_PX,
DEFAULT_MEMO_LIST_WIDTH_PX,
isTextEntryTarget,
+ readAutoSaveIntervalPreference,
readImageCompressionPreference,
+ writeAutoSaveIntervalPreference,
writeImageCompressionPreference,
readDesktopFocusModePreference,
writeDesktopFocusModePreference,
@@ -691,6 +693,7 @@ export const WorkspaceApp = ({
});
const [multiSelectKeyDown, setMultiSelectKeyDown] = useState(false);
const [imageCompressionEnabled, setImageCompressionEnabled] = useState(readImageCompressionPreference);
+ const [autoSaveIntervalMs, setAutoSaveIntervalMs] = useState(readAutoSaveIntervalPreference);
const [desktopFocusMode, setDesktopFocusMode] = useState(readDesktopFocusModePreference);
const [shortcutSettings, setShortcutSettings] = useState<ShortcutSettings>(readShortcutSettingsPreference);
const [rightView, setRightView] = useState<"editor" | "settings" | "assets" | "tags" | "templates" | "evernote-migration">(() =>
@@ -1011,6 +1014,12 @@ export const WorkspaceApp = ({
writeImageCompressionPreference(imageCompressionEnabled);
}, [imageCompressionEnabled]);
+ useEffect(() => {
+ writeAutoSaveIntervalPreference(
+ autoSaveIntervalMs === null ? "1m" : autoSaveIntervalMs === 300_000 ? "5m" : autoSaveIntervalMs === 900_000 ? "15m" : autoSaveIntervalMs === 1_800_000 ? "30m" : autoSaveIntervalMs === 3_600_000 ? "1h" : "1m"
+ );
+ }, [autoSaveIntervalMs]);
+
useEffect(() => {
writeShortcutSettingsPreference(shortcutSettings);
}, [shortcutSettings]);
@@ -2705,6 +2714,8 @@ export const WorkspaceApp = ({
onOpenTemplates={handleOpenTemplates}
imageCompressionEnabled={imageCompressionEnabled}
onImageCompressionChange={setImageCompressionEnabled}
+ autoSaveIntervalMs={autoSaveIntervalMs}
+ onAutoSaveIntervalChange={setAutoSaveIntervalMs}
shortcutSettings={shortcutSettings}
onShortcutSettingsChange={setShortcutSettings}
onLogout={onLogout}
@@ -2748,6 +2759,7 @@ export const WorkspaceApp = ({
searchFocusToken={noteSearchFocusToken}
replaceFocusToken={noteReplaceFocusToken}
imageCompressionEnabled={imageCompressionEnabled}
+ autoSaveIntervalMs={autoSaveIntervalMs}
selectionActionBar={memoSelectionActionBar}
hasNextMemo={Boolean(nextMemoId)}
hasPreviousMemo={Boolean(previousMemoId)}
diff --git a/apps/web/src/components/settings/PreferenceCard.tsx b/apps/web/src/components/settings/PreferenceCard.tsx
index c945f4f1..46997e1f 100644
--- a/apps/web/src/components/settings/PreferenceCard.tsx
+++ b/apps/web/src/components/settings/PreferenceCard.tsx
@@ -1,7 +1,7 @@
-import { ChartNoAxesCombined, Image, Languages, Palette } from "lucide-react";
+import { ChartNoAxesCombined, Image, Languages, Palette, RefreshCw } from "lucide-react";
import { useState } from "react";
import { useTranslation } from "react-i18next";
-import type { ShortcutSettings } from "@/lib/app-helpers";
+import { writeAutoSaveIntervalPreference, type AutoSaveIntervalPreference, type ShortcutSettings } from "@/lib/app-helpers";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
@@ -20,6 +20,8 @@ import { EDITOR_THEME_NAMES, MERMAID_THEME_NAMES, useTheme } from "../ThemeProvi
interface PreferenceCardProps {
imageCompressionEnabled: boolean;
onImageCompressionChange: (enabled: boolean) => void;
+ autoSaveIntervalMs: number | null;
+ onAutoSaveIntervalChange: (intervalMs: number | null) => void;
shortcutSettings: ShortcutSettings;
onShortcutSettingsChange: (settings: ShortcutSettings) => void;
}
@@ -27,6 +29,8 @@ interface PreferenceCardProps {
export const PreferenceCard = ({
imageCompressionEnabled,
onImageCompressionChange,
+ autoSaveIntervalMs,
+ onAutoSaveIntervalChange,
shortcutSettings,
onShortcutSettingsChange,
}: PreferenceCardProps) => {
@@ -40,6 +44,9 @@ export const PreferenceCard = ({
void changeAppLocalePreference(preference);
};
+ const autoSaveIntervalPreference: AutoSaveIntervalPreference =
+ autoSaveIntervalMs === 300_000 ? "5m" : autoSaveIntervalMs === 900_000 ? "15m" : autoSaveIntervalMs === 1_800_000 ? "30m" : autoSaveIntervalMs === 3_600_000 ? "1h" : "1m";
+
return (
<Card className="w-full min-w-0 overflow-hidden shadow-none">
<CardHeader className="p-4">
@@ -77,6 +84,39 @@ export const PreferenceCard = ({
</div>
</div>
+ <div className="flex min-h-16 flex-col items-start gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4">
+ <div className="flex min-w-0 items-start gap-3">
+ <RefreshCw className="mt-0.5 h-4 w-4 shrink-0 text-emerald-700" />
+ <div className="min-w-0">
+ <div className="text-sm font-semibold text-slate-900">{t("settings.autoSaveIntervalTitle")}</div>
+ <div className="mt-0.5 text-xs leading-4 text-slate-500">{t("settings.autoSaveIntervalDescription")}</div>
+ </div>
+ </div>
+ <div className="w-full shrink-0 sm:w-44">
+ <Select
+ value={autoSaveIntervalPreference}
+ onValueChange={(value) => {
+ const preference = value as AutoSaveIntervalPreference;
+ writeAutoSaveIntervalPreference(preference);
+ onAutoSaveIntervalChange(
+ preference === "5m" ? 300_000 : preference === "15m" ? 900_000 : preference === "30m" ? 1_800_000 : preference === "1h" ? 3_600_000 : 60_000
+ );
+ }}
+ >
+ <SelectTrigger aria-label={t("settings.autoSaveIntervalTitle")} className="h-9 bg-white">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="1m">{t("settings.autoSaveIntervals.1m")}</SelectItem>
+ <SelectItem value="5m">{t("settings.autoSaveIntervals.5m")}</SelectItem>
+ <SelectItem value="15m">{t("settings.autoSaveIntervals.15m")}</SelectItem>
+ <SelectItem value="30m">{t("settings.autoSaveIntervals.30m")}</SelectItem>
+ <SelectItem value="1h">{t("settings.autoSaveIntervals.1h")}</SelectItem>
+ </SelectContent>
+ </Select>
+ </div>
+ </div>
+
<div className="flex min-h-16 flex-col items-start gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4">
<div className="flex min-w-0 items-start gap-3">
<Palette className="mt-0.5 h-4 w-4 shrink-0 text-emerald-700" />
diff --git a/apps/web/src/lib/app-helpers.ts b/apps/web/src/lib/app-helpers.ts
index 46229fb2..d3289e3b 100644
--- a/apps/web/src/lib/app-helpers.ts
+++ b/apps/web/src/lib/app-helpers.ts
@@ -208,6 +208,7 @@ export { buildNotebookTree, type NotebookNode };
export { DEFAULT_MEMO_TITLE };
export const IMAGE_COMPRESSION_STORAGE_KEY = "edgeever.imageCompressionEnabled";
+export const AUTO_SAVE_INTERVAL_STORAGE_KEY = "edgeever.autoSaveInterval";
export const DESKTOP_FOCUS_MODE_STORAGE_KEY = "edgeever.desktopFocusMode";
export const MEMO_LIST_DENSITY_STORAGE_KEY = "edgeever.memoListDensity";
export const MEMO_LIST_WIDTH_STORAGE_KEY = "edgeever.memoListWidth";
@@ -217,6 +218,17 @@ export const DEFAULT_MEMO_LIST_WIDTH_PX = 360;
export const MIN_MEMO_LIST_WIDTH_PX = 300;
export const MAX_MEMO_LIST_WIDTH_PX = 540;
+export type AutoSaveIntervalPreference = "1m" | "5m" | "15m" | "30m" | "1h" | "off";
+export const DEFAULT_AUTO_SAVE_INTERVAL_MS = 60_000;
+const AUTO_SAVE_INTERVAL_VALUES: Record<AutoSaveIntervalPreference, number | null> = {
+ "1m": 60_000,
+ "5m": 300_000,
+ "15m": 900_000,
+ "30m": 1_800_000,
+ "1h": 3_600_000,
+ off: null,
+};
+
export const MEMO_DRAG_MIME = "application/x-edgeever-memos";
export const NOTEBOOK_DRAG_MIME = "application/x-edgeever-notebook";
@@ -323,6 +335,23 @@ export const writeImageCompressionPreference = (enabled: boolean) => {
}
};
+export const readAutoSaveIntervalPreference = (): number | null => {
+ try {
+ const stored = window.localStorage.getItem(AUTO_SAVE_INTERVAL_STORAGE_KEY) as AutoSaveIntervalPreference | null;
+ return stored && stored in AUTO_SAVE_INTERVAL_VALUES ? AUTO_SAVE_INTERVAL_VALUES[stored] : DEFAULT_AUTO_SAVE_INTERVAL_MS;
+ } catch {
+ return DEFAULT_AUTO_SAVE_INTERVAL_MS;
+ }
+};
+
+export const writeAutoSaveIntervalPreference = (preference: AutoSaveIntervalPreference) => {
+ try {
+ window.localStorage.setItem(AUTO_SAVE_INTERVAL_STORAGE_KEY, preference);
+ } catch {
+ // Local storage can be unavailable in private or restricted browser contexts.
+ }
+};
+
export const readDesktopFocusModePreference = () => {
try {
return window.localStorage.getItem(DESKTOP_FOCUS_MODE_STORAGE_KEY) === "true";
diff --git a/apps/web/src/lib/mobile-editor-standalone.ts b/apps/web/src/lib/mobile-editor-standalone.ts
index 18ee0d06..ef4cd2e1 100644
--- a/apps/web/src/lib/mobile-editor-standalone.ts
+++ b/apps/web/src/lib/mobile-editor-standalone.ts
@@ -1,7 +1,6 @@
import { emptyDoc, resolveMemoContentDoc, type MemoDetail, type Resource, type TiptapDoc } from "@edgeever/shared";
import { ApiRequestError } from "@/lib/api";
-export const MOBILE_EDITOR_AUTO_SAVE_DELAY_MS = 1200;
export const MOBILE_EDITOR_LEAVE_SAVE_TIMEOUT_MS = 1600;
export const MOBILE_EDITOR_INITIAL_FOCUS_DELAY_MS = 160;
export const MOBILE_EDITOR_DRAFT_STORAGE_PREFIX = "edgeever-mobile-tiptap-draft:";
diff --git a/package.json b/package.json
index a3116f73..734d2c61 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "edgeever",
- "version": "1.6.11",
+ "version": "1.6.12",
"private": true,
"type": "module",
"workspaces": [
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index 9a5f94c9..75e37c84 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -148,6 +148,9 @@ export const enUS = {
imageCompressionTitle: "Compress note images",
imageCompressionDescription: "Compress large images locally before upload to reduce storage use.",
imageCompressionAria: "Compress note images",
+ autoSaveIntervalTitle: "Automatic sync interval",
+ autoSaveIntervalDescription: "Sync edits to the server automatically while keeping local drafts available immediately.",
+ autoSaveIntervals: { "1m": "Every minute", "5m": "Every 5 minutes", "15m": "Every 15 minutes", "30m": "Every 30 minutes", "1h": "Every hour" },
mermaidThemeTitle: "Diagram theme",
mermaidThemeDescription: "Choose the visual theme for diagrams in notes.",
editorThemeTitle: "Editor theme",
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index 2e33d4bd..5d727f31 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -148,6 +148,9 @@ export const zhCN = {
imageCompressionTitle: "压缩笔记内图片",
imageCompressionDescription: "上传大图时在本地压缩,节省资源占用。",
imageCompressionAria: "是否压缩笔记内图片",
+ autoSaveIntervalTitle: "自动同步间隔",
+ autoSaveIntervalDescription: "定期将编辑内容同步到服务器,本地草稿仍会即时保留。",
+ autoSaveIntervals: { "1m": "每 1 分钟", "5m": "每 5 分钟", "15m": "每 15 分钟", "30m": "每 30 分钟", "1h": "每 1 小时" },
mermaidThemeTitle: "图表主题",
mermaidThemeDescription: "选择笔记中图表的视觉主题。",
editorThemeTitle: "编辑器主题",