Skip to content

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

Add visible progress while copying notes for publishing

tianma-if9918570868c8
diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx
index 156294be..a4d50434 100644
--- a/apps/web/src/components/EditorPane.tsx
+++ b/apps/web/src/components/EditorPane.tsx
@@ -32,6 +32,7 @@ import {
} from "lucide-react";
import { Button } from "@/components/ui/button";
import { ClipboardCopyNotice } from "@/components/ClipboardCopyNotice";
+import { WeChatCopyProgress } from "@/components/WeChatCopyProgress";
import { MemoEditorHeaderActions } from "@/components/MemoEditorHeaderActions";
import { MemoEditorMetadataRow } from "@/components/MemoEditorMetadataRow";
import { MemoEditorFocusModeButton, MemoEditorTopRowLeading } from "@/components/MemoEditorTopRowLeading";
@@ -4291,6 +4292,8 @@ const RichEditorPane = ({
</ClipboardCopyNotice>
)}
+ {wechatCopyState === "copying" && <WeChatCopyProgress />}
+
{(wechatCopyState === "copied" || wechatCopyState === "error") && (
<ClipboardCopyNotice status={wechatCopyState === "copied" ? "copied" : "error"}>
{t(wechatCopyState === "copied" ? "editor.copiedToWeChat" : "editor.copyToWeChatFailed")}
diff --git a/apps/web/src/components/MemoListPane.tsx b/apps/web/src/components/MemoListPane.tsx
index cbe3b41c..5ca95774 100644
--- a/apps/web/src/components/MemoListPane.tsx
+++ b/apps/web/src/components/MemoListPane.tsx
@@ -66,6 +66,7 @@ import {
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from "@/components/ui/select";
import { MemoCard } from "./MemoCard";
import { ClipboardCopyNotice } from "./ClipboardCopyNotice";
+import { WeChatCopyProgress } from "./WeChatCopyProgress";
import { cn } from "@/lib/utils";
import { WORKSPACE_PAGE_TITLE_CLASSNAME } from "@/lib/workspace-ui";
import type { Notebook, MemoSummary } from "@edgeever/shared";
@@ -520,6 +521,9 @@ export const MemoListPane = ({
const [moveTargetNotebookId, setMoveTargetNotebookId] = useState("");
const [memoIdCopyNotice, setMemoIdCopyNotice] = useState<{ status: "copied" | "error"; id: string } | null>(null);
const [wechatCopyNotice, setWechatCopyNotice] = useState<"copied" | "error" | null>(null);
+ const [wechatCopyPending, setWechatCopyPending] = useState(false);
+ const wechatCopyPendingRef = useRef(false);
+ const wechatCopyNoticeTimerRef = useRef<number | null>(null);
const [fileDragActive, setFileDragActive] = useState(false);
const filterOptions = useMemo(() => getMemoFilterOptions(t), [t]);
@@ -533,6 +537,12 @@ export const MemoListPane = ({
const [searchFocused, setSearchFocused] = useState(false);
const mobileSearchInputRef = useRef<HTMLInputElement | null>(null);
const listRootRef = useRef<HTMLDivElement | null>(null);
+
+ useEffect(() => () => {
+ if (wechatCopyNoticeTimerRef.current !== null) {
+ window.clearTimeout(wechatCopyNoticeTimerRef.current);
+ }
+ }, []);
const listScrollRef = useRef<HTMLDivElement | null>(null);
const [listScrollElement, setListScrollElement] = useState<HTMLDivElement | null>(null);
const [isDesktopList, setIsDesktopList] = useState(isDesktopViewport);
@@ -662,12 +672,26 @@ export const MemoListPane = ({
const handleCopyContextMemoToWeChat = async () => {
const memo = memoContextMenu?.memo;
- if (!memo || memo.diagramKind || memo.structuredTable || memo.infographic) return;
+ if (!memo || memo.diagramKind || memo.structuredTable || memo.infographic || wechatCopyPendingRef.current) return;
setMemoContextMenu(null);
- const result = await onCopyMemoToWeChat(memo.id);
- if (result === "editor") return;
- setWechatCopyNotice(result);
- window.setTimeout(() => setWechatCopyNotice(null), result === "copied" ? 2200 : 2600);
+ wechatCopyPendingRef.current = true;
+ if (wechatCopyNoticeTimerRef.current !== null) {
+ window.clearTimeout(wechatCopyNoticeTimerRef.current);
+ }
+ setWechatCopyNotice(null);
+ setWechatCopyPending(true);
+ try {
+ const result = await onCopyMemoToWeChat(memo.id);
+ if (result === "editor") return;
+ setWechatCopyNotice(result);
+ wechatCopyNoticeTimerRef.current = window.setTimeout(() => setWechatCopyNotice(null), result === "copied" ? 2200 : 2600);
+ } catch {
+ setWechatCopyNotice("error");
+ wechatCopyNoticeTimerRef.current = window.setTimeout(() => setWechatCopyNotice(null), 2600);
+ } finally {
+ wechatCopyPendingRef.current = false;
+ setWechatCopyPending(false);
+ }
};
useEffect(() => {
@@ -1719,6 +1743,8 @@ export const MemoListPane = ({
</ClipboardCopyNotice>
)}
+ {wechatCopyPending && <WeChatCopyProgress />}
+
{wechatCopyNotice && (
<ClipboardCopyNotice status={wechatCopyNotice}>
{t(wechatCopyNotice === "copied" ? "editor.copiedToWeChat" : "editor.copyToWeChatFailed")}
diff --git a/apps/web/src/components/WeChatCopyProgress.tsx b/apps/web/src/components/WeChatCopyProgress.tsx
new file mode 100644
index 00000000..df37001a
--- /dev/null
+++ b/apps/web/src/components/WeChatCopyProgress.tsx
@@ -0,0 +1,22 @@
+import { createPortal } from "react-dom";
+import { useTranslation } from "react-i18next";
+import { LoaderCircle } from "lucide-react";
+
+export const WeChatCopyProgress = () => {
+ const { t } = useTranslation();
+ if (typeof document === "undefined") return null;
+
+ return createPortal(
+ <div className="fixed inset-0 z-[130] flex cursor-progress items-center justify-center bg-slate-950/25 px-4">
+ <div
+ className="flex max-w-full items-center gap-3 rounded-xl bg-card px-5 py-4 text-sm font-medium text-slate-900 shadow-xl"
+ role="status"
+ aria-live="polite"
+ >
+ <LoaderCircle className="h-5 w-5 shrink-0 animate-spin text-[var(--brand-green)]" aria-hidden="true" />
+ <span>{t("editor.copyingToWeChat")}</span>
+ </div>
+ </div>,
+ document.body,
+ );
+};
diff --git a/apps/web/src/components/editor/useEditorDocumentActions.ts b/apps/web/src/components/editor/useEditorDocumentActions.ts
index e4007c32..db87234f 100644
--- a/apps/web/src/components/editor/useEditorDocumentActions.ts
+++ b/apps/web/src/components/editor/useEditorDocumentActions.ts
@@ -1,4 +1,4 @@
-import { useCallback, useEffect, useState } from "react";
+import { useCallback, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import type { Editor } from "@tiptap/react";
import { docToMarkdown, markdownToDoc, type MemoDetail, type TiptapDoc } from "@edgeever/shared";
@@ -54,6 +54,14 @@ export const useEditorDocumentActions = ({
const [imageShareOpen, setImageShareOpen] = useState(false);
const [imageShareSource, setImageShareSource] = useState<ShareNoteImageSource | null>(null);
const [wechatCopyState, setWechatCopyState] = useState<WechatCopyState>("idle");
+ const wechatCopyPendingRef = useRef(false);
+ const wechatCopyResetTimerRef = useRef<number | null>(null);
+
+ useEffect(() => () => {
+ if (wechatCopyResetTimerRef.current !== null) {
+ window.clearTimeout(wechatCopyResetTimerRef.current);
+ }
+ }, []);
const resolveExportContent = useCallback(
() => resolveEditorExportContent({
@@ -67,10 +75,14 @@ export const useEditorDocumentActions = ({
);
const handleCopyToWeChat = useCallback(async () => {
- if (!isEditorReady(editor)) {
+ if (!isEditorReady(editor) || wechatCopyPendingRef.current) {
return;
}
+ wechatCopyPendingRef.current = true;
+ if (wechatCopyResetTimerRef.current !== null) {
+ window.clearTimeout(wechatCopyResetTimerRef.current);
+ }
setWechatCopyState("copying");
try {
if (useMarkdownSourceEditor) {
@@ -79,10 +91,12 @@ export const useEditorDocumentActions = ({
await copyEditorToWeChat(editor);
}
setWechatCopyState("copied");
- window.setTimeout(() => setWechatCopyState("idle"), 2200);
+ wechatCopyResetTimerRef.current = window.setTimeout(() => setWechatCopyState("idle"), 2200);
} catch {
setWechatCopyState("error");
- window.setTimeout(() => setWechatCopyState("idle"), 2600);
+ wechatCopyResetTimerRef.current = window.setTimeout(() => setWechatCopyState("idle"), 2600);
+ } finally {
+ wechatCopyPendingRef.current = false;
}
}, [editor, markdownSource, useMarkdownSourceEditor]);
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index 1d6b81fa..a90c9c11 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -2146,7 +2146,7 @@ export const enUS = {
hidePhonePreview: "Hide phone preview",
phonePreviewEmpty: "Start writing to see how this note reads on a phone.",
phonePreviewFollow: "Follow scroll",
- copyingToWeChat: "Preparing rich text",
+ copyingToWeChat: "Copying to clipboard, please wait…",
copiedToWeChat: "Copied",
copyToWeChatFailed: "Copy failed",
outline: "Outline",
diff --git a/packages/shared/src/i18n/ja.ts b/packages/shared/src/i18n/ja.ts
index 3b49086b..25d7bda4 100644
--- a/packages/shared/src/i18n/ja.ts
+++ b/packages/shared/src/i18n/ja.ts
@@ -2146,7 +2146,7 @@ export const ja = {
hidePhonePreview: "スマホプレビューを隠す",
phonePreviewEmpty: "書き始めると、このノートのスマホでの読み味がここに表示されます。",
phonePreviewFollow: "スクロール追従",
- copyingToWeChat: "リッチテキストを準備中",
+ copyingToWeChat: "クリップボードにコピー中です。お待ちください…",
copiedToWeChat: "コピーしました",
copyToWeChatFailed: "コピーに失敗",
outline: "アウトライン",
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index 1a7d67c3..a6622242 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -2144,7 +2144,7 @@ export const zhCN = {
hidePhonePreview: "隐藏手机预览",
phonePreviewEmpty: "开始写作后,这里会显示手机阅读效果。",
phonePreviewFollow: "滚动跟随",
- copyingToWeChat: "正在准备富文本内容",
+ copyingToWeChat: "正在复制到剪贴板,请稍候…",
copiedToWeChat: "已复制",
copyToWeChatFailed: "复制失败",
outline: "文档大纲",