Skip to content

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

Fix English locale gaps in web note editors

Alok Saboo59dcc2c26282
diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx
index 3cb067bc..2df3d312 100644
--- a/apps/web/src/components/EditorPane.tsx
+++ b/apps/web/src/components/EditorPane.tsx
@@ -81,8 +81,8 @@ import { compressImageForUpload } from "@/lib/image-compression";
import { localDb, type MemoUpdateSyncPayload } from "@/lib/local-db";
import { getMemoUpdateQueueId, isMemoUpdateAlreadyApplied, queueMemoUpdate, shouldQueueMemoSaveError } from "@/lib/sync-queue";
import {
+ getEditableMemoTitle,
getNotebookMoveOptions,
- DEFAULT_MEMO_TITLE,
} from "@/lib/app-helpers";
const SUPPORTED_PASTE_IMAGE_TYPES = new Set(["image/png", "image/jpeg", "image/gif", "image/webp", "image/avif"]);
@@ -408,6 +408,7 @@ const MobileNotebookSelectSheet = ({
onClose: () => void;
onSelect: (notebookId: string) => void;
}) => {
+ const { t } = useTranslation();
const listRef = useRef<HTMLDivElement | null>(null);
useEffect(() => {
@@ -424,16 +425,16 @@ const MobileNotebookSelectSheet = ({
<DrawerContent className="inset-x-0 max-h-[62dvh] overflow-hidden border-x-0 border-b-0 pb-[env(safe-area-inset-bottom)] lg:hidden">
<header className="flex h-12 items-center justify-between border-b border-slate-200 px-4">
<DrawerHeader className="min-w-0 p-0">
- <DrawerTitle className="text-base">所在笔记本</DrawerTitle>
+ <DrawerTitle className="text-base">{t("editor.currentNotebook")}</DrawerTitle>
</DrawerHeader>
- <Button size="icon" variant="ghost" title="关闭" aria-label="关闭" onClick={onClose}>
+ <Button size="icon" variant="ghost" title={t("editor.close")} aria-label={t("editor.close")} onClick={onClose}>
<X className="h-4 w-4" />
</Button>
</header>
<Command className="min-h-0 flex-1">
- <CommandInput placeholder="搜索笔记本" />
+ <CommandInput placeholder={t("editor.searchNotebook")} />
<CommandList ref={listRef} className="max-h-[calc(62dvh-6.25rem-env(safe-area-inset-bottom))] p-2">
- <CommandEmpty>没有找到笔记本</CommandEmpty>
+ <CommandEmpty>{t("editor.noNotebookFound")}</CommandEmpty>
<CommandGroup>
{options.map((option) => {
const selected = option.id === selectedNotebookId;
@@ -448,7 +449,7 @@ const MobileNotebookSelectSheet = ({
value={option.id}
keywords={[option.name, option.selectLabel, option.slug ?? ""]}
data-mobile-notebook-select-id={option.id}
- aria-label={selected ? `当前所在笔记本:${option.name}` : `切换到 ${option.name}`}
+ aria-label={selected ? t("editor.currentNotebookAria", { name: option.name }) : t("editor.switchToNotebook", { name: option.name })}
aria-current={selected ? "page" : undefined}
disabled={isUpdating}
onSelect={() => onSelect(option.id)}
@@ -505,6 +506,7 @@ const MobileNativeEditorPane = ({
onMobileDefaultEditConsumed,
onExitMobileNativeEdit,
}: EditorPaneProps & { onExitMobileNativeEdit: () => void }) => {
+ const { t } = useTranslation();
const titleRef = useRef<HTMLInputElement | null>(null);
const tagsRef = useRef<HTMLInputElement | null>(null);
const bodyRef = useRef<HTMLTextAreaElement | null>(null);
@@ -522,7 +524,7 @@ const MobileNativeEditorPane = ({
const [mobileNotebookSheetOpen, setMobileNotebookSheetOpen] = useState(false);
const notebookOptions = useMemo(() => getNotebookMoveOptions(notebooks), [notebooks]);
const readOnly = isTrashView || Boolean(memo?.isDeleted);
- const currentNotebookLabel = notebookOptions.find((notebook) => notebook.id === memo?.notebookId)?.name ?? "笔记本";
+ const currentNotebookLabel = notebookOptions.find((notebook) => notebook.id === memo?.notebookId)?.name ?? t("editor.notebookFallback");
const getTitleValue = useCallback(() => titleRef.current?.value ?? "", []);
const getTagsValue = useCallback(() => tagsRef.current?.value ?? "", []);
@@ -755,7 +757,7 @@ const MobileNativeEditorPane = ({
const draftUpdatedAt = draft ? Date.parse(draft.updatedAt) : 0;
const remoteUpdatedAt = Date.parse(memo.updatedAt);
const useDraft = Boolean(draft && (queuedUpdate || draftUpdatedAt >= remoteUpdatedAt));
- const nextTitle = useDraft && draft ? draft.title : memo.title ?? "";
+ const nextTitle = useDraft && draft ? draft.title : getEditableMemoTitle(memo.title);
const nextTagsText = useDraft && draft ? draft.tagsText : memo.tags.join(", ");
const nextContent = useDraft && draft
? draft.contentJson
@@ -865,18 +867,18 @@ const MobileNativeEditorPane = ({
const saveLabel =
saveState === "saving"
- ? "保存中"
+ ? t("editor.saveState.saving")
: saveState === "saved"
- ? "已保存"
+ ? t("editor.saveState.saved")
: saveState === "queued"
- ? "待同步"
+ ? t("editor.saveState.queued")
: saveState === "conflict"
- ? "有冲突"
+ ? t("editor.saveState.conflict")
: saveState === "error"
- ? "保存失败"
+ ? t("editor.saveState.error")
: hasUnsavedChanges
- ? "未保存"
- : "已保存";
+ ? t("editor.saveState.unsaved")
+ : t("editor.saveState.saved");
const saveStateClassName =
saveState === "error" || saveState === "conflict"
@@ -889,9 +891,9 @@ const MobileNativeEditorPane = ({
if (!memo) {
return (
- <div className="fixed inset-0 z-[90] flex items-center justify-center bg-white text-sm text-slate-500 sm:hidden">
- 加载中
- </div>
+ <div className="fixed inset-0 z-[90] flex items-center justify-center bg-white text-sm text-slate-500 sm:hidden">
+ {t("editor.loading")}
+ </div>
);
}
@@ -901,8 +903,8 @@ const MobileNativeEditorPane = ({
<Button
size="icon"
variant="ghost"
- title={hasUnsavedChanges && !readOnly ? "保存并返回列表" : "返回列表"}
- aria-label={hasUnsavedChanges && !readOnly ? "保存并返回列表" : "返回列表"}
+ title={hasUnsavedChanges && !readOnly ? t("editor.saveAndBack") : t("editor.backToList")}
+ aria-label={hasUnsavedChanges && !readOnly ? t("editor.saveAndBack") : t("editor.backToList")}
disabled={savingRef.current || notebookUpdatePending}
onClick={() => void finishEditing(true)}
>
@@ -918,7 +920,7 @@ const MobileNativeEditorPane = ({
disabled={savingRef.current || notebookUpdatePending}
onClick={() => void finishEditing(false)}
>
- {saveState === "saving" ? "保存中" : "完成"}
+ {saveState === "saving" ? t("editor.saveState.saving") : t("editor.done")}
</button>
</div>
</header>
@@ -927,19 +929,19 @@ const MobileNativeEditorPane = ({
<div className="space-y-3 px-4 pb-4 pt-4">
<input
ref={titleRef}
- defaultValue={memo.title ?? ""}
+ defaultValue={getEditableMemoTitle(memo.title)}
readOnly={readOnly}
onInput={markDirty}
className="block w-full border-0 bg-transparent text-2xl font-bold leading-tight text-slate-950 outline-none placeholder:text-slate-300"
- placeholder={DEFAULT_MEMO_TITLE}
+ placeholder={t("common.untitledMemo")}
/>
<div className="flex flex-wrap items-center gap-2">
<button
className="flex h-8 min-w-0 max-w-full items-center gap-1 rounded-md border border-transparent bg-transparent px-2 text-sm font-medium text-slate-600 outline-none disabled:opacity-50"
type="button"
disabled={readOnly || notebookUpdatePending}
- title="所在笔记本"
- aria-label={`所在笔记本:${currentNotebookLabel}`}
+ title={t("editor.currentNotebook")}
+ aria-label={t("editor.currentNotebookAria", { name: currentNotebookLabel })}
onClick={() => setMobileNotebookSheetOpen(true)}
>
<span className="min-w-0 truncate">{currentNotebookLabel}</span>
@@ -953,7 +955,7 @@ const MobileNativeEditorPane = ({
readOnly={readOnly}
onInput={markDirty}
className="min-w-0 flex-1 bg-transparent outline-none placeholder:text-slate-400"
- placeholder="添加标签,用逗号分隔"
+ placeholder={t("editor.tagPlaceholder")}
/>
</label>
</div>
@@ -970,8 +972,8 @@ const MobileNativeEditorPane = ({
name="memo-body-native"
spellCheck
readOnly={readOnly}
- aria-label="笔记正文"
- placeholder="开始记录..."
+ aria-label={t("editor.noteBodyAria")}
+ placeholder={t("editor.placeholder")}
className="block min-h-[70dvh] w-full resize-none border-0 bg-white px-4 py-4 text-base leading-7 text-slate-900 outline-none placeholder:text-slate-400"
style={{ WebkitUserSelect: "text", userSelect: "text", caretColor: "auto" }}
/>
@@ -1064,7 +1066,7 @@ export const EditorPane = (props: EditorPaneProps) => {
if (mobileNativeEditingActive) {
return (
<div className="flex h-full min-h-0 items-center justify-center bg-white text-sm font-medium text-slate-400">
- 打开编辑器
+ {t("editor.openEditor")}
</div>
);
}
@@ -1325,7 +1327,7 @@ const RichEditorPane = ({
.focus()
.insertContent({
type: "paragraph",
- content: [{ type: "text", text: `附件:${resource.filename || file.name} ${resource.url}` }],
+ content: [{ type: "text", text: t("editor.attachmentInsertText", { filename: resource.filename || file.name, url: resource.url }) }],
})
.run();
}
@@ -1351,7 +1353,7 @@ const RichEditorPane = ({
table: { renderWrapper: true },
}),
Placeholder.configure({
- placeholder: "开始记录...",
+ placeholder: t("editor.placeholder"),
}),
],
content: memo
@@ -1852,7 +1854,7 @@ const RichEditorPane = ({
const draftUpdatedAt = draft ? Date.parse(draft.updatedAt) : 0;
const remoteUpdatedAt = Date.parse(memo.updatedAt);
const useDraft = Boolean(draft && (queuedUpdate || draftUpdatedAt >= remoteUpdatedAt));
- const nextTitle = useDraft && draft ? draft.title : memo.title ?? "";
+ const nextTitle = useDraft && draft ? draft.title : getEditableMemoTitle(memo.title);
const nextTagsText = useDraft && draft ? draft.tagsText : memo.tags.join(", ");
const nextContent = useDraft && draft
? draft.contentJson
@@ -2234,7 +2236,7 @@ const RichEditorPane = ({
return (
<div className="flex h-full min-w-0 flex-col bg-white">
{selectionActionBar}
- <div className="flex min-h-0 flex-1 items-center justify-center text-sm text-slate-500">加载中</div>
+ <div className="flex min-h-0 flex-1 items-center justify-center text-sm text-slate-500">{t("editor.loading")}</div>
</div>
);
}
@@ -2246,7 +2248,7 @@ const RichEditorPane = ({
<div className="flex min-h-0 flex-1 items-center justify-center px-8 text-center">
<div>
<Sparkles className="mx-auto mb-3 h-8 w-8 text-slate-300 animate-pulse" />
- <div className="text-sm font-medium text-slate-400">选择或新建一条笔记</div>
+ <div className="text-sm font-medium text-slate-400">{t("editor.emptySelection")}</div>
</div>
</div>
</div>
@@ -2255,18 +2257,18 @@ const RichEditorPane = ({
const saveLabel =
saveState === "saving"
- ? "保存中"
+ ? t("editor.saveState.saving")
: saveState === "saved"
- ? "已保存"
+ ? t("editor.saveState.saved")
: saveState === "queued"
- ? "待同步"
+ ? t("editor.saveState.queued")
: saveState === "conflict"
- ? "有冲突"
+ ? t("editor.saveState.conflict")
: saveState === "error"
- ? "保存失败"
+ ? t("editor.saveState.error")
: hasUnsavedChanges
- ? "未保存"
- : "已保存";
+ ? t("editor.saveState.unsaved")
+ : t("editor.saveState.saved");
const saveStateClassName =
saveState === "error" || saveState === "conflict"
@@ -2279,11 +2281,11 @@ const RichEditorPane = ({
const imageUploadLabel =
imageUploadState === "error"
- ? "上传失败"
+ ? t("editor.uploadState.failed")
: imageUploadState === "compressing"
- ? "压缩中"
+ ? t("editor.uploadState.compressing")
: imageUploadState === "uploading"
- ? "上传中"
+ ? t("editor.uploadState.uploading")
: null;
const mobileStatusLabel = imageUploadLabel ?? saveLabel;
@@ -2295,7 +2297,7 @@ const RichEditorPane = ({
: saveStateClassName;
const updatedLabel = formatDateTime(memo.updatedAt);
- const currentNotebookLabel = notebookOptions.find((notebook) => notebook.id === memo.notebookId)?.name ?? "笔记本";
+ const currentNotebookLabel = notebookOptions.find((notebook) => notebook.id === memo.notebookId)?.name ?? t("editor.notebookFallback");
const mobileDoneDisabled =
saveMutation.isPending ||
@@ -2336,7 +2338,7 @@ const RichEditorPane = ({
};
const handleMobilePromptInput = () => {
- const nextText = window.prompt("输入笔记内容");
+ const nextText = window.prompt(t("editor.typeInput"));
if (!nextText) {
focusMobileInputTarget();
return;
@@ -2357,7 +2359,7 @@ const RichEditorPane = ({
appendMobilePlainText(nextText, "clipboard-input");
} catch {
recordMobileImeDebugEvent("clipboard-error");
- window.alert("读取剪贴板失败。请确认浏览器允许剪贴板权限。");
+ window.alert(t("editor.clipboardReadFailed"));
focusMobileInputTarget();
}
};
@@ -2457,8 +2459,8 @@ const RichEditorPane = ({
className="lg:hidden"
size="icon"
variant="ghost"
- title={hasUnsavedChanges && !readOnly ? "保存并返回列表" : "返回列表"}
- aria-label={hasUnsavedChanges && !readOnly ? "保存并返回列表" : "返回列表"}
+ title={hasUnsavedChanges && !readOnly ? t("editor.saveAndBack") : t("editor.backToList")}
+ aria-label={hasUnsavedChanges && !readOnly ? t("editor.saveAndBack") : t("editor.backToList")}
disabled={mobileDoneDisabled}
onClick={handleMobileBack}
>
@@ -2468,8 +2470,8 @@ const RichEditorPane = ({
<button
className="flex h-8 w-8 items-center justify-center rounded-md text-slate-500 transition hover:bg-slate-50 hover:text-slate-900 disabled:opacity-30"
type="button"
- title="上一条笔记"
- aria-label="上一条笔记"
+ title={t("editor.previousMemo")}
+ aria-label={t("editor.previousMemo")}
disabled={!hasPreviousMemo}
onClick={onOpenPreviousMemo}
>
@@ -2478,8 +2480,8 @@ const RichEditorPane = ({
<button
className="flex h-8 w-8 items-center justify-center rounded-md text-slate-500 transition hover:bg-slate-50 hover:text-slate-900 disabled:opacity-30"
type="button"
- title="下一条笔记"
- aria-label="下一条笔记"
+ title={t("editor.nextMemo")}
+ aria-label={t("editor.nextMemo")}
disabled={!hasNextMemo}
onClick={onOpenNextMemo}
>
@@ -2505,15 +2507,15 @@ const RichEditorPane = ({
</TooltipContent>
</Tooltip>
</TooltipProvider>
- <Button size="icon" variant="ghost" title="上一条笔记" aria-label="上一条笔记" onClick={onOpenPreviousMemo} disabled={!hasPreviousMemo}>
+ <Button size="icon" variant="ghost" title={t("editor.previousMemo")} aria-label={t("editor.previousMemo")} onClick={onOpenPreviousMemo} disabled={!hasPreviousMemo}>
<ChevronLeft className="h-4 w-4" />
</Button>
- <Button size="icon" variant="ghost" title="下一条笔记" aria-label="下一条笔记" onClick={onOpenNextMemo} disabled={!hasNextMemo}>
+ <Button size="icon" variant="ghost" title={t("editor.nextMemo")} aria-label={t("editor.nextMemo")} onClick={onOpenNextMemo} disabled={!hasNextMemo}>
<ChevronRight className="h-4 w-4" />
</Button>
</div>
<span className="hidden truncate text-xs text-slate-400 sm:inline">
- 更新于 {updatedLabel}
+ {t("editor.updatedAt", { time: updatedLabel })}
</span>
</div>
@@ -2534,10 +2536,10 @@ const RichEditorPane = ({
)}
>
{imageUploadState === "error"
- ? "文件上传失败"
+ ? t("editor.uploadState.fileFailed")
: imageUploadState === "compressing"
- ? "图片压缩中"
- : "文件上传中"}
+ ? t("editor.uploadState.imageCompressing")
+ : t("editor.uploadState.fileUploading")}
</span>
)}
<span className={cn("hidden rounded-md px-2 py-1 text-xs font-medium sm:inline-flex", saveStateClassName)}>
@@ -2553,7 +2555,7 @@ const RichEditorPane = ({
disabled={mobileDoneDisabled}
onClick={handleMobileDone}
>
- {saveMutation.isPending ? "保存中" : "完成"}
+ {saveMutation.isPending ? t("editor.saveState.saving") : t("editor.done")}
</button>
)}
<input
@@ -2572,8 +2574,8 @@ const RichEditorPane = ({
className="sm:hidden"
size="icon"
variant="ghost"
- title="上传附件"
- aria-label="上传附件"
+ title={t("editor.uploadAttachment")}
+ aria-label={t("editor.uploadAttachment")}
disabled={mobileDoneDisabled || effectiveReadOnly}
onClick={() => fileInputRef.current?.click()}
>
@@ -2585,8 +2587,8 @@ const RichEditorPane = ({
className="sm:hidden"
size="icon"
variant={mobileToolbarOpen ? "soft" : "ghost"}
- title={mobileToolbarOpen ? "收起格式" : "格式"}
- aria-label={mobileToolbarOpen ? "收起格式" : "格式"}
+ title={mobileToolbarOpen ? t("editor.collapseFormat") : t("editor.format")}
+ aria-label={mobileToolbarOpen ? t("editor.collapseFormat") : t("editor.format")}
aria-pressed={mobileToolbarOpen}
disabled={effectiveReadOnly}
onClick={() => setMobileToolbarOpen((open) => !open)}
@@ -2594,10 +2596,10 @@ const RichEditorPane = ({
<Type className="h-4 w-4" />
</Button>
)}
- <Button className="hidden h-8 w-8 text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-950 focus-visible:ring-2 focus-visible:ring-slate-300 sm:inline-flex" size="icon" variant="ghost" title="搜索当前笔记" aria-label="搜索当前笔记" onClick={() => openNoteSearch()}>
+ <Button className="hidden h-8 w-8 text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-950 focus-visible:ring-2 focus-visible:ring-slate-300 sm:inline-flex" size="icon" variant="ghost" title={t("editor.searchCurrentMemo")} aria-label={t("editor.searchCurrentMemo")} onClick={() => openNoteSearch()}>
<Search className="h-5 w-5" strokeWidth={2.25} />
</Button>
- <Button className="hidden h-8 w-8 text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-950 focus-visible:ring-2 focus-visible:ring-slate-300 sm:inline-flex" size="icon" variant="ghost" title="版本历史" aria-label="版本历史" onClick={() => setHistoryOpen(true)}>
+ <Button className="hidden h-8 w-8 text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-950 focus-visible:ring-2 focus-visible:ring-slate-300 sm:inline-flex" size="icon" variant="ghost" title={t("editor.versionHistory")} aria-label={t("editor.versionHistory")} onClick={() => setHistoryOpen(true)}>
<History className="h-5 w-5" strokeWidth={2.25} />
</Button>
<GitHubRepositoryLink className="hidden h-8 w-8 justify-center rounded-md text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-950 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/70 lg:inline-flex" iconClassName="h-5 w-5" />
@@ -2607,8 +2609,8 @@ const RichEditorPane = ({
className="hidden sm:inline-flex"
size="icon"
variant="solid"
- title="保存"
- aria-label="保存"
+ title={t("editor.save")}
+ aria-label={t("editor.save")}
onClick={() => saveMutation.mutate()}
disabled={!editor || saveMutation.isPending || !hasUnsavedChanges}
>
@@ -2621,8 +2623,8 @@ const RichEditorPane = ({
className={cn(!mobileEditingActive && !readOnly && "hidden sm:inline-flex")}
size="icon"
variant="ghost"
- title="更多"
- aria-label="笔记更多操作"
+ title={t("editor.more")}
+ aria-label={t("editor.moreAria")}
>
<MoreHorizontal className="h-4 w-4" />
</Button>
@@ -2633,14 +2635,14 @@ const RichEditorPane = ({
onClick={() => openNoteSearch()}
>
<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"
onClick={openNoteReplace}
>
<ReplaceAll className="h-4 w-4 text-slate-500" />
- 替换当前笔记
+ {t("editor.replaceCurrentMemo")}
</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"
@@ -2649,7 +2651,7 @@ const RichEditorPane = ({
}}
>
<History className="h-4 w-4 text-slate-500" />
- 版本历史
+ {t("editor.versionHistory")}
</DropdownMenuItem>
{readOnly ? (
<>
@@ -2658,7 +2660,7 @@ const RichEditorPane = ({
onClick={() => void onRestored(memo.id)}
>
<RotateCcw className="h-4 w-4 text-slate-500" />
- 恢复笔记
+ {t("editor.restoreMemo")}
</DropdownMenuItem>
<DropdownMenuSeparator className="my-1 h-px bg-slate-100" />
<DropdownMenuItem
@@ -2666,7 +2668,7 @@ const RichEditorPane = ({
onClick={() => void onPermanentDeleted(memo.id)}
>
<Trash2 className="h-4 w-4" />
- 彻底删除
+ {t("editor.deleteForever")}
</DropdownMenuItem>
</>
) : (
@@ -2677,7 +2679,7 @@ const RichEditorPane = ({
onClick={() => void onDeleted(memo.id)}
>
<Trash2 className="h-4 w-4" />
- 删除笔记
+ {t("editor.deleteMemo")}
</DropdownMenuItem>
</>
)}
@@ -2696,15 +2698,15 @@ const RichEditorPane = ({
markDirty();
}}
className="block w-full rounded-md border-0 bg-transparent text-2xl font-bold leading-tight text-slate-950 outline-none transition placeholder:text-slate-300 focus-visible:bg-slate-50 focus-visible:shadow-[inset_3px_0_0_var(--brand-green)] sm:text-3xl"
- placeholder={DEFAULT_MEMO_TITLE}
+ placeholder={t("common.untitledMemo")}
/>
<div className="flex flex-wrap items-center gap-2">
<button
className="flex h-8 min-w-0 max-w-full items-center gap-1 rounded-md border border-transparent bg-transparent px-2 text-sm font-medium text-slate-600 outline-none transition hover:border-slate-200 hover:bg-slate-50 hover:text-slate-900 focus-visible:border-emerald-300 focus-visible:ring-2 focus-visible:ring-emerald-500/20 disabled:opacity-50 sm:hidden"
type="button"
disabled={effectiveReadOnly || notebookUpdatePending}
- title="所在笔记本"
- aria-label={`所在笔记本:${currentNotebookLabel}`}
+ title={t("editor.currentNotebook")}
+ aria-label={t("editor.currentNotebookAria", { name: currentNotebookLabel })}
onClick={() => setMobileNotebookSheetOpen(true)}
>
<span className="min-w-0 truncate">{currentNotebookLabel}</span>
@@ -2717,7 +2719,7 @@ const RichEditorPane = ({
onValueChange={(value) => handleNotebookChange(value)}
>
<SelectTrigger className="h-8 min-w-0 border-transparent bg-transparent px-2 text-sm font-medium text-slate-600 hover:border-slate-200 hover:bg-slate-50 hover:text-slate-900 whitespace-nowrap">
- <SelectValue placeholder="所在笔记本" />
+ <SelectValue placeholder={t("editor.notebookPlaceholder")} />
</SelectTrigger>
<SelectContent className="max-h-60 bg-white border border-slate-200 rounded-md py-1 shadow-md">
{notebookOptions.map((notebook) => (
@@ -2739,7 +2741,7 @@ const RichEditorPane = ({
markDirty();
}}
className="min-w-0 flex-1 bg-transparent outline-none placeholder:text-slate-400"
- placeholder="添加标签,用逗号分隔"
+ placeholder={t("editor.tagPlaceholder")}
/>
</label>
</div>
@@ -2751,7 +2753,7 @@ const RichEditorPane = ({
ref={noteSearchInputRef}
value={noteSearchQuery}
className="h-8 min-w-[12rem] flex-1"
- placeholder="在当前笔记内搜索"
+ placeholder={t("editor.searchPlaceholder")}
onChange={(event) => setNoteSearchQuery(event.target.value)}
onKeyDown={(event) => {
if (event.key === "Enter") {
@@ -2770,7 +2772,7 @@ const RichEditorPane = ({
ref={noteReplaceInputRef}
value={noteSearchReplacement}
className="h-8 min-w-[12rem] flex-1"
- placeholder="替换为"
+ placeholder={t("editor.replacePlaceholder")}
disabled={effectiveReadOnly}
onChange={(event) => setNoteSearchReplacement(event.target.value)}
onKeyDown={(event) => {
@@ -2798,8 +2800,8 @@ const RichEditorPane = ({
<Button
size="icon"
variant="ghost"
- title="上一个搜索结果"
- aria-label="上一个搜索结果"
+ title={t("editor.previousSearchResult")}
+ aria-label={t("editor.previousSearchResult")}
disabled={noteSearchMatches.length === 0}
onClick={() => moveNoteSearchMatch(-1)}
>
@@ -2808,8 +2810,8 @@ const RichEditorPane = ({
<Button
size="icon"
variant="ghost"
- title="下一个搜索结果"
- aria-label="下一个搜索结果"
+ title={t("editor.nextSearchResult")}
+ aria-label={t("editor.nextSearchResult")}
disabled={noteSearchMatches.length === 0}
onClick={() => moveNoteSearchMatch(1)}
>
@@ -2819,16 +2821,16 @@ const RichEditorPane = ({
<Button
size="sm"
variant="solid"
- title="全部替换"
- aria-label="全部替换"
+ title={t("editor.replaceAll")}
+ aria-label={t("editor.replaceAll")}
disabled={effectiveReadOnly || noteSearchMatches.length === 0}
onClick={replaceAllNoteSearchMatches}
>
<ReplaceAll className="h-4 w-4" />
- 全部替换
+ {t("editor.replaceAll")}
</Button>
)}
- <Button size="icon" variant="ghost" title="关闭搜索" aria-label="关闭搜索" onClick={closeNoteSearch}>
+ <Button size="icon" variant="ghost" title={t("editor.closeSearch")} aria-label={t("editor.closeSearch")} onClick={closeNoteSearch}>
<X className="h-4 w-4" />
</Button>
</div>
@@ -2865,9 +2867,9 @@ const RichEditorPane = ({
name="memo-body"
spellCheck
data-edgeever-mobile-editor="plain-textarea"
- aria-label="笔记正文"
+ aria-label={t("editor.noteBodyAria")}
className="block min-h-[60dvh] w-full resize-none border border-slate-200 bg-white px-4 py-3 pr-32 text-base leading-7 text-slate-950 outline-none placeholder:text-slate-400 sm:px-7"
- placeholder="开始记录..."
+ placeholder={t("editor.placeholder")}
style={{ WebkitUserSelect: "text", userSelect: "text", caretColor: "auto" }}
/>
<div className="absolute right-3 top-3 flex gap-2">
@@ -2876,14 +2878,14 @@ const RichEditorPane = ({
type="button"
onClick={() => void handleMobileClipboardInput()}
>
- 粘贴
+ {t("editor.paste")}
</button>
<button
className="rounded-full border border-slate-200 bg-white px-3 py-1.5 text-sm font-semibold text-slate-700 shadow-sm"
type="button"
onClick={handleMobilePromptInput}
>
- 输入
+ {t("editor.typeInput")}
</button>
</div>
</>
@@ -2893,9 +2895,9 @@ const RichEditorPane = ({
onChange={(event) => handleMarkdownSourceChange(event.target.value)}
readOnly={effectiveReadOnly}
spellCheck={false}
- aria-label="Markdown 源码"
+ aria-label={t("editor.markdownSourceAria")}
className="block min-h-[300px] h-full w-full resize-none border-0 bg-slate-950 px-4 py-3 font-mono text-sm leading-6 text-slate-100 outline-none placeholder:text-slate-500 sm:px-7"
- placeholder="# 开始记录"
+ placeholder={`# ${t("editor.placeholder")}`}
/>
) : (
<EditorContent editor={editor} />
@@ -2976,8 +2978,8 @@ const RichEditorPane = ({
className="fixed bottom-[calc(1rem+env(safe-area-inset-bottom))] right-4 z-30 h-12 w-12 rounded-full shadow-lg sm:hidden"
size="icon"
variant="solid"
- title="编辑笔记"
- aria-label="编辑笔记"
+ title={t("editor.editMemo")}
+ aria-label={t("editor.editMemo")}
onClick={() => {
if (onRequestMobileNativeEdit) {
onRequestMobileNativeEdit();
diff --git a/apps/web/src/components/MemoCard.tsx b/apps/web/src/components/MemoCard.tsx
index 136f8c46..15bc72a1 100644
--- a/apps/web/src/components/MemoCard.tsx
+++ b/apps/web/src/components/MemoCard.tsx
@@ -4,7 +4,7 @@ import { Star, Check, MoreHorizontal, RotateCcw, Trash2 } from "lucide-react";
import type { MemoSummary } from "@edgeever/shared";
import { cn } from "@/lib/utils";
import type { MemoListDensity } from "@/lib/app-helpers";
-import { MEMO_DRAG_MIME, setMemoDragPreview } from "@/lib/app-helpers";
+import { isDefaultMemoTitle, MEMO_DRAG_MIME, setMemoDragPreview } from "@/lib/app-helpers";
const MEMO_LONG_PRESS_DELAY_MS = 520;
const MEMO_LONG_PRESS_MOVE_TOLERANCE_PX = 14;
@@ -77,7 +77,7 @@ export const MemoCard = ({
const longPressTimerRef = useRef<number | null>(null);
const longPressPointRef = useRef<{ x: number; y: number } | null>(null);
const [modifierHoverActive, setModifierHoverActive] = useState(false);
- const memoTitle = memo.title?.trim() || t("common.untitledMemo");
+ const memoTitle = memo.title?.trim() && !isDefaultMemoTitle(memo.title) ? memo.title.trim() : t("common.untitledMemo");
const memoExcerpt = memo.excerpt.trim() || t("memoCard.emptyMemo");
const showSelectionControl = selectionMode || checked || multiSelectKeyDown || modifierHoverActive;
const selectionControlLabel = checked
diff --git a/apps/web/src/components/MobileStandaloneEditorParts.tsx b/apps/web/src/components/MobileStandaloneEditorParts.tsx
index cacc7ae7..9447009e 100644
--- a/apps/web/src/components/MobileStandaloneEditorParts.tsx
+++ b/apps/web/src/components/MobileStandaloneEditorParts.tsx
@@ -1,9 +1,11 @@
import { Bold, Check, ChevronDown, ImagePlus, List, Minus, Quote, Table2, Workflow } from "lucide-react";
+import { useTranslation } from "react-i18next";
import {
MOBILE_EDITOR_TOOLBAR_ACTIONS,
getMobileEditorTableMenuCopy,
getMobileEditorToolbarActionLabel,
isMobileEditorActionDisabledInTableHeader,
+ type MobileEditorLocale,
type MobileEditorTableActionId,
type MobileEditorToolbarActionId,
} from "@edgeever/shared/mobile-editor";
@@ -22,19 +24,37 @@ export const MobileEditorHeader = ({
saveState: MobileEditorSaveState;
onLeave: () => void;
}) => (
- <header className="mobile-editor-header">
- <button className="mobile-editor-back" type="button" aria-label="返回" onClick={onLeave}>
- ‹
- </button>
- <div className="mobile-editor-actions">
- <span className={`mobile-editor-status ${statusClassName}`}>{saveLabel}</span>
- <button className="mobile-editor-done" type="button" disabled={saveState === "loading"} onClick={onLeave}>
- 完成
- </button>
- </div>
- </header>
+ <MobileEditorHeaderInner saveLabel={saveLabel} statusClassName={statusClassName} saveState={saveState} onLeave={onLeave} />
);
+const MobileEditorHeaderInner = ({
+ saveLabel,
+ statusClassName,
+ saveState,
+ onLeave,
+}: {
+ saveLabel: string;
+ statusClassName: string;
+ saveState: MobileEditorSaveState;
+ onLeave: () => void;
+}) => {
+ const { t } = useTranslation();
+
+ return (
+ <header className="mobile-editor-header">
+ <button className="mobile-editor-back" type="button" aria-label={t("editor.backToList")} onClick={onLeave}>
+ ‹
+ </button>
+ <div className="mobile-editor-actions">
+ <span className={`mobile-editor-status ${statusClassName}`}>{saveLabel}</span>
+ <button className="mobile-editor-done" type="button" disabled={saveState === "loading"} onClick={onLeave}>
+ {t("editor.done")}
+ </button>
+ </div>
+ </header>
+ );
+};
+
export const MobileEditorToolbar = ({
disabled,
boldActive,
@@ -43,6 +63,7 @@ export const MobileEditorToolbar = ({
mermaidActive,
tableActive,
tableHeaderActive,
+ locale,
onPickImage,
onInsertMermaid,
onToggleBold,
@@ -58,6 +79,7 @@ export const MobileEditorToolbar = ({
mermaidActive: boolean;
tableActive: boolean;
tableHeaderActive: boolean;
+ locale: MobileEditorLocale;
onPickImage: () => void;
onInsertMermaid: () => void;
onToggleBold: () => void;
@@ -67,7 +89,7 @@ export const MobileEditorToolbar = ({
onTableAction: (action: MobileEditorTableActionId) => void;
}) => {
const [tableMenuOpen, setTableMenuOpen] = useState(false);
- const tableMenuCopy = getMobileEditorTableMenuCopy("zh-CN");
+ const tableMenuCopy = getMobileEditorTableMenuCopy(locale);
const icons: Record<MobileEditorToolbarActionId, ReactNode> = {
image: <ImagePlus aria-hidden="true" size={18} strokeWidth={2} />,
mermaid: <Workflow aria-hidden="true" size={18} strokeWidth={2} />,
@@ -117,7 +139,7 @@ export const MobileEditorToolbar = ({
{MOBILE_EDITOR_TOOLBAR_ACTIONS
.filter(({ id, requiresTable }) => !requiresTable && (!tableActive || id !== "insertTable"))
.map(({ id }) => {
- const label = getMobileEditorToolbarActionLabel(id, "zh-CN");
+ const label = getMobileEditorToolbarActionLabel(id, locale);
return (
<button
@@ -166,7 +188,7 @@ export const MobileEditorToolbar = ({
</div>
<div className="mobile-editor-table-action-list">
{MOBILE_EDITOR_TOOLBAR_ACTIONS.filter(({ requiresTable }) => requiresTable).map(({ id }) => {
- const label = getMobileEditorToolbarActionLabel(id, "zh-CN");
+ const label = getMobileEditorToolbarActionLabel(id, locale);
return (
<button
key={id}
@@ -200,12 +222,20 @@ export const MobileEditorNotebookButton = ({
disabled: boolean;
onOpen: () => void;
}) => (
- <button className="mobile-editor-notebook-button" type="button" aria-label="所在笔记本" disabled={disabled} onClick={onOpen}>
- <span>{label}</span>
- <ChevronDown aria-hidden="true" size={14} strokeWidth={2.2} />
- </button>
+ <MobileEditorNotebookButtonInner label={label} disabled={disabled} onOpen={onOpen} />
);
+const MobileEditorNotebookButtonInner = ({ label, disabled, onOpen }: { label: string; disabled: boolean; onOpen: () => void }) => {
+ const { t } = useTranslation();
+
+ return (
+ <button className="mobile-editor-notebook-button" type="button" aria-label={t("editor.currentNotebook")} disabled={disabled} onClick={onOpen}>
+ <span>{label}</span>
+ <ChevronDown aria-hidden="true" size={14} strokeWidth={2.2} />
+ </button>
+ );
+};
+
export const MobileEditorNotebookSheet = ({
options,
selectedNotebookId,
@@ -219,48 +249,78 @@ export const MobileEditorNotebookSheet = ({
onClose: () => void;
onSelect: (notebookId: string) => void;
}) => (
- <div className="mobile-editor-sheet-backdrop" role="presentation" onClick={onClose}>
- <section
- className="mobile-editor-notebook-sheet"
- role="dialog"
- aria-modal="true"
- aria-label="选择笔记本"
- onClick={(event) => event.stopPropagation()}
- >
- <div className="mobile-editor-notebook-sheet-handle" aria-hidden="true" />
- <div className="mobile-editor-notebook-sheet-header">
- <h2>所在笔记本</h2>
- <button type="button" onClick={onClose}>
- 关闭
- </button>
- </div>
- <div className="mobile-editor-notebook-list">
- {options.map((notebook) => {
- const selected = notebook.id === selectedNotebookId;
-
- return (
- <button
- key={notebook.id}
- className="mobile-editor-notebook-option"
- type="button"
- aria-current={selected ? "page" : undefined}
- disabled={updating}
- style={{ paddingLeft: `${16 + notebook.depth * 18}px` }}
- onClick={() => onSelect(notebook.id)}
- >
- <span>{notebook.name}</span>
- {selected && <Check aria-hidden="true" size={16} strokeWidth={2.4} />}
- </button>
- );
- })}
- </div>
- </section>
- </div>
+ <MobileEditorNotebookSheetInner
+ options={options}
+ selectedNotebookId={selectedNotebookId}
+ updating={updating}
+ onClose={onClose}
+ onSelect={onSelect}
+ />
);
-export const MobileEditorFallback = ({ markdown }: { markdown: string }) => (
- <details className="mobile-editor-fallback">
- <summary>查看当前正文 Markdown 备份</summary>
- <pre>{markdown}</pre>
- </details>
-);
+const MobileEditorNotebookSheetInner = ({
+ options,
+ selectedNotebookId,
+ updating,
+ onClose,
+ onSelect,
+}: {
+ options: NotebookMoveOption[];
+ selectedNotebookId?: string;
+ updating: boolean;
+ onClose: () => void;
+ onSelect: (notebookId: string) => void;
+}) => {
+ const { t } = useTranslation();
+
+ return (
+ <div className="mobile-editor-sheet-backdrop" role="presentation" onClick={onClose}>
+ <section
+ className="mobile-editor-notebook-sheet"
+ role="dialog"
+ aria-modal="true"
+ aria-label={t("editor.currentNotebook")}
+ onClick={(event) => event.stopPropagation()}
+ >
+ <div className="mobile-editor-notebook-sheet-handle" aria-hidden="true" />
+ <div className="mobile-editor-notebook-sheet-header">
+ <h2>{t("editor.currentNotebook")}</h2>
+ <button type="button" onClick={onClose}>
+ {t("editor.close")}
+ </button>
+ </div>
+ <div className="mobile-editor-notebook-list">
+ {options.map((notebook) => {
+ const selected = notebook.id === selectedNotebookId;
+
+ return (
+ <button
+ key={notebook.id}
+ className="mobile-editor-notebook-option"
+ type="button"
+ aria-current={selected ? "page" : undefined}
+ disabled={updating}
+ style={{ paddingLeft: `${16 + notebook.depth * 18}px` }}
+ onClick={() => onSelect(notebook.id)}
+ >
+ <span>{notebook.name}</span>
+ {selected && <Check aria-hidden="true" size={16} strokeWidth={2.4} />}
+ </button>
+ );
+ })}
+ </div>
+ </section>
+ </div>
+ );
+};
+
+export const MobileEditorFallback = ({ markdown }: { markdown: string }) => {
+ const { t } = useTranslation();
+
+ return (
+ <details className="mobile-editor-fallback">
+ <summary>{`${t("editor.noteBodyAria")} Markdown`}</summary>
+ <pre>{markdown}</pre>
+ </details>
+ );
+};
diff --git a/apps/web/src/components/MobileStandaloneTiptapEditor.tsx b/apps/web/src/components/MobileStandaloneTiptapEditor.tsx
index 5db1a746..9d40f74b 100644
--- a/apps/web/src/components/MobileStandaloneTiptapEditor.tsx
+++ b/apps/web/src/components/MobileStandaloneTiptapEditor.tsx
@@ -1,4 +1,5 @@
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { useTranslation } from "react-i18next";
import { EditorContent, useEditor } from "@tiptap/react";
import StarterKit from "@tiptap/starter-kit";
import Image from "@tiptap/extension-image";
@@ -13,7 +14,8 @@ import {
MobileEditorNotebookSheet,
MobileEditorToolbar,
} from "@/components/MobileStandaloneEditorParts";
-import { getNotebookMoveOptions } from "@/lib/app-helpers";
+import { getEditableMemoTitle, getNotebookMoveOptions } from "@/lib/app-helpers";
+import { defaultLocale, normalizeLocale } from "@/i18n/locales";
import { compressImageForUpload } from "@/lib/image-compression";
import { localDb, type LocalDraft } from "@/lib/local-db";
import {
@@ -22,13 +24,11 @@ import {
writeMobileEditorReturnPreview,
} from "@/lib/mobile-editor";
import {
- DEFAULT_MOBILE_EDITOR_MEMO_TITLE,
MOBILE_EDITOR_AUTO_SAVE_DELAY_MS,
MOBILE_EDITOR_INITIAL_FOCUS_DELAY_MS,
MOBILE_EDITOR_LEAVE_SAVE_TIMEOUT_MS,
getMobileEditorDraftKey,
getMobileEditorParams,
- getMobileEditorSaveLabel,
getMobileEditorStatusClassName,
normalizeMobileEditorDoc,
parseMobileEditorTags,
@@ -55,7 +55,9 @@ export const MobileStandaloneTiptapEditor = ({
onLeave,
}: MobileStandaloneTiptapEditorProps = {}) => {
const params = useMemo(() => getMobileEditorParams(), []);
+ const { t, i18n } = useTranslation();
const memoId = memoIdProp ?? params.get("memoId");
+ const locale = normalizeLocale(i18n.resolvedLanguage ?? i18n.language) ?? defaultLocale;
const draftKey = getMobileEditorDraftKey(memoId);
const [memo, setMemo] = useState<MemoDetail | null>(null);
const memoRef = useRef<MemoDetail | null>(null);
@@ -178,7 +180,7 @@ export const MobileStandaloneTiptapEditor = ({
table: { renderWrapper: true },
}),
Placeholder.configure({
- placeholder: getMobileEditorPlaceholder("zh-CN"),
+ placeholder: getMobileEditorPlaceholder(locale),
}),
],
content: emptyDoc(),
@@ -252,7 +254,7 @@ export const MobileStandaloneTiptapEditor = ({
const buildSavePayload = useCallback((currentMemo: MemoDetail) => {
const editSession = editSessionRef.current;
if (!editSession || editSession.memoId !== currentMemo.id) {
- throw new Error("编辑会话尚未就绪");
+ throw new Error(t("editor.saveState.error"));
}
return {
@@ -423,7 +425,7 @@ export const MobileStandaloneTiptapEditor = ({
return true;
}
- setError(saveError instanceof Error ? saveError.message : "保存失败,已保留本地草稿");
+ setError(saveError instanceof Error ? saveError.message : t("editor.saveState.error"));
setSaveStateStable("error");
return false;
} finally {
@@ -555,7 +557,7 @@ export const MobileStandaloneTiptapEditor = ({
}
}, 1200);
} catch (notebookError) {
- setError(notebookError instanceof Error ? notebookError.message : "切换笔记本失败");
+ setError(notebookError instanceof Error ? notebookError.message : t("editor.saveState.error"));
setSaveStateStable("error");
} finally {
setNotebookUpdatePending(false);
@@ -586,7 +588,7 @@ export const MobileStandaloneTiptapEditor = ({
})
.run();
} catch (uploadError) {
- setError(uploadError instanceof Error ? uploadError.message : "图片上传失败");
+ setError(uploadError instanceof Error ? uploadError.message : t("editor.uploadState.fileFailed"));
setSaveStateStable("error");
}
};
@@ -639,7 +641,7 @@ export const MobileStandaloneTiptapEditor = ({
useEffect(() => {
if (!memoId || !editor) {
if (!memoId) {
- setError("缺少 memoId");
+ setError(t("editor.saveState.error"));
setSaveStateStable("error");
}
return;
@@ -662,7 +664,7 @@ export const MobileStandaloneTiptapEditor = ({
editSessionRef.current = sessionData.editSession;
- const nextTitle = data.memo.title || "";
+ const nextTitle = getEditableMemoTitle(data.memo.title);
const nextTagsText = Array.isArray(data.memo.tags) ? data.memo.tags.join(", ") : "";
const nextContentJson = normalizeMobileEditorDoc(data.memo);
let draft = await readBestLocalDraft();
@@ -713,7 +715,7 @@ export const MobileStandaloneTiptapEditor = ({
if (cancelled) {
return;
}
- setError(loadError instanceof Error ? loadError.message : "加载失败");
+ setError(loadError instanceof Error ? loadError.message : t("editor.loading"));
setSaveStateStable("error");
}
})();
@@ -725,7 +727,7 @@ export const MobileStandaloneTiptapEditor = ({
initialFocusTimerRef.current = null;
}
};
- }, [editor, focusEditorAfterLoad, memoId, readBestLocalDraft, scheduleMetadataSave, setSaveStateStable]);
+ }, [editor, focusEditorAfterLoad, memoId, readBestLocalDraft, scheduleMetadataSave, setSaveStateStable, t]);
useEffect(() => {
const handlePageHide = () => {
@@ -790,12 +792,31 @@ export const MobileStandaloneTiptapEditor = ({
};
}, [currentSnapshot, draftKey, memoId, persistLocalDraft, persistReturnPreview, reconcileBackgroundSave, saveNow, sendBackgroundSave, setSaveStateStable]);
- const saveLabel = getMobileEditorSaveLabel(saveState);
+ const saveLabel =
+ saveState === "loading"
+ ? t("editor.loading")
+ : saveState === "saving"
+ ? t("editor.saveState.saving")
+ : saveState === "compressing"
+ ? t("editor.uploadState.compressing")
+ : saveState === "uploading"
+ ? t("editor.uploadState.uploading")
+ : saveState === "dirty"
+ ? t("editor.saveState.unsaved")
+ : saveState === "saved"
+ ? t("editor.saveState.saved")
+ : saveState === "local-draft"
+ ? t("editor.saveState.unsaved")
+ : saveState === "leaving"
+ ? t("editor.backToList")
+ : saveState === "error"
+ ? t("editor.saveState.error")
+ : t("editor.saveState.saved");
const statusClassName = getMobileEditorStatusClassName(saveState);
const editorActionDisabled =
!memo || !editor || saveState === "loading" || saveState === "compressing" || saveState === "uploading" || saveState === "leaving";
const currentNotebookLabel =
- notebookOptions.find((notebook) => notebook.id === memo?.notebookId)?.name ?? (notebookOptions.length === 0 ? "等待分类" : "笔记本");
+ notebookOptions.find((notebook) => notebook.id === memo?.notebookId)?.name ?? t("editor.notebookFallback");
const fallbackMarkdown = memo ? docToMarkdown(contentJsonRef.current) : "";
const tableActive = Boolean(editor?.isActive("table"));
@@ -848,7 +869,7 @@ export const MobileStandaloneTiptapEditor = ({
autoComplete="on"
autoCorrect="on"
inputMode="text"
- placeholder={DEFAULT_MOBILE_EDITOR_MEMO_TITLE}
+ placeholder={t("common.untitledMemo")}
onChange={(event) => handleTitleChange(event.target.value)}
/>
<div className="mobile-editor-meta-row">
@@ -863,7 +884,7 @@ export const MobileStandaloneTiptapEditor = ({
autoComplete="on"
autoCorrect="on"
inputMode="text"
- placeholder="添加标签,用逗号分隔"
+ placeholder={t("editor.tagPlaceholder")}
onChange={(event) => handleTagsChange(event.target.value)}
/>
</div>
@@ -876,6 +897,7 @@ export const MobileStandaloneTiptapEditor = ({
mermaidActive={Boolean(editor?.isActive("codeBlock", { language: "mermaid" }))}
tableActive={tableActive}
tableHeaderActive={tableHeaderActive}
+ locale={locale}
onPickImage={() => imageInputRef.current?.click()}
onInsertMermaid={() => runEditorCommand(() => {
if (!editor) {
diff --git a/apps/web/src/components/WorkspaceApp.tsx b/apps/web/src/components/WorkspaceApp.tsx
index a9663b7d..f677f6ff 100644
--- a/apps/web/src/components/WorkspaceApp.tsx
+++ b/apps/web/src/components/WorkspaceApp.tsx
@@ -55,7 +55,6 @@ import type {
MemoSortMode,
} from "@/lib/app-helpers";
import {
- DEFAULT_MEMO_TITLE,
MIN_MEMO_LIST_WIDTH_PX,
MAX_MEMO_LIST_WIDTH_PX,
DEFAULT_MEMO_LIST_WIDTH_PX,
@@ -1641,7 +1640,7 @@ export const WorkspaceApp = ({
setMobileBottomNavActive("home");
createMemoMutation.mutate({
notebookId: defaultMemoNotebookId,
- title: template?.title ?? DEFAULT_MEMO_TITLE,
+ title: template?.title ?? "",
contentMarkdown: template?.contentMarkdown ?? "",
tags: template?.tags ?? [],
});
diff --git a/apps/web/src/lib/app-helpers.ts b/apps/web/src/lib/app-helpers.ts
index 50461b50..14c2a48b 100644
--- a/apps/web/src/lib/app-helpers.ts
+++ b/apps/web/src/lib/app-helpers.ts
@@ -216,6 +216,11 @@ const SHORTCUT_ALIASES: Partial<Record<ShortcutAction, ShortcutBinding[]>> = {
const SHORTCUT_ACTION_VALUES: ShortcutAction[] = ["createMemo", "createNotebook", "focusSearch", "focusReplace"];
+export const isDefaultMemoTitle = (title: string | null | undefined) => title?.trim() === DEFAULT_MEMO_TITLE;
+
+export const getEditableMemoTitle = (title: string | null | undefined) =>
+ isDefaultMemoTitle(title) ? "" : title?.trim() || "";
+
export const getMemoTitle = (title: string | null | undefined) => title?.trim() || DEFAULT_MEMO_TITLE;
export const getActiveBlockValue = (editor: any): string => {
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index d0299017..668825a1 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -444,6 +444,8 @@ export const enUS = {
switchToNotebook: "Switch to {{name}}",
attachmentInsertText: "Attachment: {{filename}} {{url}}",
placeholder: "Start writing...",
+ noteBodyAria: "Note body",
+ markdownSourceAria: "Markdown source",
loading: "Loading",
emptySelection: "Select or create a note",
saveState: {
@@ -493,6 +495,10 @@ export const enUS = {
replaceAll: "Replace all",
closeSearch: "Close search",
editMemo: "Edit note",
+ openEditor: "Open editor",
+ paste: "Paste",
+ typeInput: "Type",
+ clipboardReadFailed: "Could not read the clipboard. Check that your browser allows clipboard access.",
characterCount: "{{count}} chars",
},
editorToolbar: {
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index 4ffdbfe8..0cc20f04 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -444,6 +444,8 @@ export const zhCN = {
switchToNotebook: "切换到 {{name}}",
attachmentInsertText: "附件:{{filename}} {{url}}",
placeholder: "开始记录...",
+ noteBodyAria: "笔记正文",
+ markdownSourceAria: "Markdown 源码",
loading: "加载中",
emptySelection: "选择或新建一条笔记",
saveState: {
@@ -493,6 +495,10 @@ export const zhCN = {
replaceAll: "全部替换",
closeSearch: "关闭搜索",
editMemo: "编辑笔记",
+ openEditor: "打开编辑器",
+ paste: "粘贴",
+ typeInput: "输入",
+ clipboardReadFailed: "读取剪贴板失败。请确认浏览器允许剪贴板权限。",
characterCount: "{{count}} 字",
},
editorToolbar: {