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
fix: format copied system information
tianma-ifc6ecc4916488
diff --git a/apps/web/src/components/settings/SystemInfoPanel.test.mjs b/apps/web/src/components/settings/SystemInfoPanel.test.mjsindex 003c0e8d..374782be 100644--- a/apps/web/src/components/settings/SystemInfoPanel.test.mjs+++ b/apps/web/src/components/settings/SystemInfoPanel.test.mjs@@ -62,5 +62,7 @@ describe("system information copy feedback", () => {expect(source).toContain("systemInfo.copySucceeded");expect(source).toContain("systemInfo.copyFailed");expect(source).toContain('copyState === "error"');+ expect(source).toContain("formatSystemInfoClipboard");+ expect(source).toContain("copyHtmlToClipboard");});});diff --git a/apps/web/src/components/settings/SystemInfoPanel.tsx b/apps/web/src/components/settings/SystemInfoPanel.tsxindex 8c753a71..202e82fe 100644--- a/apps/web/src/components/settings/SystemInfoPanel.tsx+++ b/apps/web/src/components/settings/SystemInfoPanel.tsx@@ -9,6 +9,7 @@ import { Button } from "@/components/ui/button";import { useDeployedUpdateNotice } from "@/hooks/useDeployedUpdateNotice";import { detectWebClientKind } from "@/lib/client-environment";import { api, getConfiguredDesktopApiBaseUrl, type InstanceHealth } from "@/lib/api";+import { copyHtmlToClipboard } from "@/lib/clipboard";import { resolveSystemInfoDeploymentMetadata } from "@/lib/deployment-metadata";import { resolveDeploymentPlatform } from "@/lib/instance-runtime";import {@@ -18,9 +19,9 @@ import {type ClientRuntimeDiagnostics,type ClientSyncDiagnostics,} from "@/lib/system-diagnostics";+import { formatSystemInfoClipboard } from "@/lib/system-info-clipboard";import { cn } from "@/lib/utils";import { getReleaseTagForVersion, isClientAheadOfInstance } from "@/lib/version-check";-import { copyTextToClipboard } from "./settings-utils";export type SystemInfoItem = {label: string;@@ -393,10 +394,19 @@ export const SystemInfoPanel = ({ active = true }: { active?: boolean }) => {: "https://github.com/tianma-if/edgeever/releases/latest";const handleCopy = async () => {- const text = infoGroups- .map((group) => [group.title, ...group.items.map((item) => `${item.label}: ${item.value}`)].join("\n"))- .join("\n\n");- const copied = await copyTextToClipboard(text);+ const clipboard = formatSystemInfoClipboard({+ title: t("systemInfo.title"),+ fieldLabel: t("systemInfo.copyFieldLabel"),+ valueLabel: t("systemInfo.copyValueLabel"),+ groups: infoGroups,+ });+ let copied = false;+ try {+ await copyHtmlToClipboard(clipboard.html, clipboard.plainText);+ copied = true;+ } catch {+ copied = false;+ }setCopyState(copied ? "copied" : "error");if (copyResetTimeoutRef.current !== null) window.clearTimeout(copyResetTimeoutRef.current);copyResetTimeoutRef.current = window.setTimeout(() => {diff --git a/apps/web/src/lib/system-info-clipboard.test.mjs b/apps/web/src/lib/system-info-clipboard.test.mjsnew file mode 100644index 00000000..27af563f--- /dev/null+++ b/apps/web/src/lib/system-info-clipboard.test.mjs@@ -0,0 +1,51 @@+import { describe, expect, test } from "bun:test";+import { formatSystemInfoClipboard } from "./system-info-clipboard.ts";++describe("formatSystemInfoClipboard", () => {+ test("builds structured Markdown and HTML tables", () => {+ const formatted = formatSystemInfoClipboard({+ title: "系统信息",+ fieldLabel: "项目",+ valueLabel: "信息",+ groups: [{+ title: "云端实例",+ items: [+ { label: "实例版本", value: "v1.81.0" },+ { label: "实例地址", value: "https://example.com" },+ ],+ }],+ });++ expect(formatted.plainText).toBe([+ "# 系统信息",+ "",+ "## 云端实例",+ "| 项目 | 信息 |",+ "| --- | --- |",+ "| 实例版本 | v1.81.0 |",+ "| 实例地址 | https://example.com |",+ ].join("\n"));+ expect(formatted.html).toContain("<h1>系统信息</h1>");+ expect(formatted.html).toContain("<h2>云端实例</h2>");+ expect(formatted.html).toContain("<table>");+ expect(formatted.html).toContain('<th scope="row">实例版本</th><td>v1.81.0</td>');+ });++ test("escapes clipboard values for both formats", () => {+ const formatted = formatSystemInfoClipboard({+ title: "System info",+ fieldLabel: "Field",+ valueLabel: "Value",+ groups: [{+ title: "Client",+ items: [{ label: "Build | channel", value: "<script>alert('x')</script>\\next" }],+ }],+ });++ expect(formatted.plainText).toContain("Build \\| channel");+ expect(formatted.plainText).toContain("<script>alert('x')</script>");+ expect(formatted.plainText).toContain("\\\\next");+ expect(formatted.html).not.toContain("<script>");+ expect(formatted.html).toContain("<script>alert('x')</script>\\next");+ });+});diff --git a/apps/web/src/lib/system-info-clipboard.ts b/apps/web/src/lib/system-info-clipboard.tsnew file mode 100644index 00000000..9eaa9db4--- /dev/null+++ b/apps/web/src/lib/system-info-clipboard.ts@@ -0,0 +1,65 @@+export type SystemInfoClipboardItem = {+ label: string;+ value: string;+};++export type SystemInfoClipboardGroup = {+ title: string;+ items: SystemInfoClipboardItem[];+};++const escapeHtml = (value: string) => value+ .replaceAll("&", "&")+ .replaceAll("<", "<")+ .replaceAll(">", ">")+ .replaceAll('"', """)+ .replaceAll("'", "'");++const escapeMarkdownTableCell = (value: string) => value+ .replaceAll("&", "&")+ .replaceAll("<", "<")+ .replaceAll(">", ">")+ .replaceAll("\\", "\\\\")+ .replaceAll("|", "\\|")+ .replace(/\r?\n/g, "<br>");++export const formatSystemInfoClipboard = ({+ fieldLabel,+ groups,+ title,+ valueLabel,+}: {+ fieldLabel: string;+ groups: SystemInfoClipboardGroup[];+ title: string;+ valueLabel: string;+}) => {+ const plainText = [+ `# ${title}`,+ ...groups.map((group) => [+ `## ${group.title}`,+ `| ${escapeMarkdownTableCell(fieldLabel)} | ${escapeMarkdownTableCell(valueLabel)} |`,+ "| --- | --- |",+ ...group.items.map((item) => (+ `| ${escapeMarkdownTableCell(item.label)} | ${escapeMarkdownTableCell(item.value)} |`+ )),+ ].join("\n")),+ ].join("\n\n");++ const html = [+ `<h1>${escapeHtml(title)}</h1>`,+ ...groups.map((group) => [+ `<h2>${escapeHtml(group.title)}</h2>`,+ "<table>",+ `<thead><tr><th>${escapeHtml(fieldLabel)}</th><th>${escapeHtml(valueLabel)}</th></tr></thead>`,+ "<tbody>",+ ...group.items.map((item) => (+ `<tr><th scope="row">${escapeHtml(item.label)}</th><td>${escapeHtml(item.value)}</td></tr>`+ )),+ "</tbody>",+ "</table>",+ ].join("")),+ ].join("");++ return { html, plainText };+};diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.tsindex 717eb7ae..0781fad2 100644--- a/packages/shared/src/i18n/en-US.ts+++ b/packages/shared/src/i18n/en-US.ts@@ -1227,6 +1227,8 @@ export const enUS = {copy: "Copy info",copySucceeded: "System information copied to the clipboard.",copyFailed: "Copy failed. Check clipboard permissions and try again.",+ copyFieldLabel: "Field",+ copyValueLabel: "Value",clientAheadOfInstanceByPlatform: {cloudflare: "This client is newer than the connected cloud instance. You can wait for the daily automatic instance update, or run the Update deployed EdgeEver workflow.",docker: "This client is newer than the connected cloud instance. You can wait for the daily automatic instance update, or run ./update.sh in the install directory (default ~/edgeever).",diff --git a/packages/shared/src/i18n/ja.ts b/packages/shared/src/i18n/ja.tsindex a7dbcecc..c89e7f22 100644--- a/packages/shared/src/i18n/ja.ts+++ b/packages/shared/src/i18n/ja.ts@@ -1227,6 +1227,8 @@ export const ja = {copy: "情報をコピー",copySucceeded: "システム情報をクリップボードにコピーしました。",copyFailed: "コピーに失敗しました。クリップボードの権限を確認して、もう一度お試しください。",+ copyFieldLabel: "項目",+ copyValueLabel: "情報",clientAheadOfInstanceByPlatform: {cloudflare: "このクライアントは接続中のクラウドインスタンスより新しいです。毎日の自動インスタンス更新を待つか、Update deployed EdgeEver ワークフローを実行できます。",docker: "このクライアントは接続中のクラウドインスタンスより新しいです。毎日の自動インスタンス更新を待つか、インストールディレクトリで ./update.sh を実行できます(既定は ~/edgeever)。",diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.tsindex 613bf79c..e393f8ef 100644--- a/packages/shared/src/i18n/zh-CN.ts+++ b/packages/shared/src/i18n/zh-CN.ts@@ -1227,6 +1227,8 @@ export const zhCN = {copy: "复制信息",copySucceeded: "系统信息已复制到剪贴板。",copyFailed: "复制失败,请检查剪贴板权限后重试。",+ copyFieldLabel: "项目",+ copyValueLabel: "信息",clientAheadOfInstanceByPlatform: {cloudflare: "当前客户端版本高于云端实例。可等待每天自动更新,或手动运行 Update deployed EdgeEver 工作流。",docker: "当前客户端版本高于云端实例。可等待每天自动更新,或在安装目录执行 ./update.sh(默认 ~/edgeever)。",