Skip to content

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

fix(web): restyle the phone preview frame and move its toggle

tianma-iff6d8129f60f5
diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx
index 8c284f78..2ed87bf7 100644
--- a/apps/web/src/components/EditorPane.tsx
+++ b/apps/web/src/components/EditorPane.tsx
@@ -164,7 +164,7 @@ import {
import { copyEditorToWeChat, copyMarkdownToWeChat } from "@/lib/wechat-copy";
import { isPaperEditorTheme, publishEditorCssVars, resolvePaperEditorTheme } from "@/lib/publish-layout";
import { ThemeBlock } from "./ThemeBlock";
-import { EditorPhonePreview } from "./EditorPhonePreview";
+import { EditorPhonePreview, PhonePreviewGlyph } from "./EditorPhonePreview";
import { downloadMarkdownFile } from "@/lib/note-markdown-export";
import { NOTE_HTML_FULL_STYLES } from "@/lib/note-html-export-assets";
import { downloadNoteHtmlFile, getHtmlImageEmbedNoticeKind } from "@/lib/note-html-export";
@@ -3908,6 +3908,30 @@ const RichEditorPane = ({
</Button>
</IconTooltip>
)}
+ {!isMobileViewport && !useMobilePlainTextEditor && !useMarkdownSourceEditor && (
+ <TooltipProvider delayDuration={0} skipDelayDuration={0}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ className={cn(
+ "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 xl:inline-flex",
+ phonePreviewOpen && "bg-emerald-50 text-emerald-800 hover:bg-emerald-50 hover:text-emerald-900",
+ )}
+ size="icon"
+ variant="ghost"
+ aria-label={phonePreviewOpen ? t("editor.hidePhonePreview") : t("editor.showPhonePreview")}
+ aria-pressed={phonePreviewOpen || undefined}
+ onClick={() => handlePhonePreviewChange(!phonePreviewOpen)}
+ >
+ <PhonePreviewGlyph className="h-4 w-4" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent side="bottom">
+ {phonePreviewOpen ? t("editor.hidePhonePreview") : t("editor.showPhonePreview")}
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ )}
<TooltipProvider delayDuration={0} skipDelayDuration={0}>
<Tooltip>
<TooltipTrigger asChild>
@@ -4144,8 +4168,6 @@ const RichEditorPane = ({
onPickExternalLink={openExternalLinkDialog}
externalLinkActive={externalLinkActive}
onPickNoteLink={() => setNoteLinkPickerOpen(true)}
- phonePreview={phonePreviewOpen}
- onPhonePreviewChange={handlePhonePreviewChange}
/>
)}
<EditorSaveRecoveryBanner
diff --git a/apps/web/src/components/EditorPhonePreview.tsx b/apps/web/src/components/EditorPhonePreview.tsx
index b2497a73..1ad76044 100644
--- a/apps/web/src/components/EditorPhonePreview.tsx
+++ b/apps/web/src/components/EditorPhonePreview.tsx
@@ -11,6 +11,15 @@ import {
writeEditorPhonePreviewFollowPreference,
} from "@/lib/app-helpers";
+export const PhonePreviewGlyph = ({ className }: { className?: string }) => (
+ <svg viewBox="0 0 16 16" className={className} fill="none" aria-hidden="true">
+ <rect x="3.6" y="1.1" width="8.8" height="13.8" rx="2" stroke="currentColor" strokeWidth="1.4" />
+ <rect x="5.15" y="3.35" width="5.7" height="7.15" rx="0.55" fill="currentColor" opacity="0.2" />
+ <rect x="6.35" y="2.15" width="3.3" height="0.85" rx="0.42" fill="currentColor" />
+ <rect x="6.7" y="12.55" width="2.6" height="0.7" rx="0.35" fill="currentColor" />
+ </svg>
+);
+
type EditorPhonePreviewProps = {
editor: Editor | null;
title?: string;
@@ -18,9 +27,6 @@ type EditorPhonePreviewProps = {
className?: string;
};
-const formatPhoneTime = () =>
- new Intl.DateTimeFormat(undefined, { hour: "numeric", minute: "2-digit" }).format(new Date());
-
const BLOCK_SELECTOR =
"p, h1, h2, h3, li, blockquote, pre, img, table, hr, figure, [data-edgeever-theme-block]";
@@ -68,17 +74,10 @@ export const EditorPhonePreview = ({ editor, title, scrollContainer, className }
const { mermaidTheme } = useMermaidTheme();
const previewSyncGeneration = useRef(0);
const [markup, setMarkup] = useState({ html: "", style: "", paper: false });
- const [clock, setClock] = useState(formatPhoneTime);
const [follow, setFollow] = useState(readEditorPhonePreviewFollowPreference);
const previewRef = useRef<HTMLDivElement | null>(null);
const syncingRef = useRef(false);
- useEffect(() => {
- const tick = () => setClock(formatPhoneTime());
- const timer = window.setInterval(tick, 30_000);
- return () => window.clearInterval(timer);
- }, []);
-
useEffect(() => {
if (!editor || editor.isDestroyed) {
setMarkup({ html: "", style: "", paper: false });
@@ -204,31 +203,9 @@ export const EditorPhonePreview = ({ editor, title, scrollContainer, className }
<span className="edgeever-phone-device__vol-down" aria-hidden="true" />
<span className="edgeever-phone-device__power" aria-hidden="true" />
<div className="edgeever-phone-device__screen">
+ <div className="edgeever-phone-device__top" aria-hidden="true" />
<div className="edgeever-phone-device__island" aria-hidden="true">
<span className="edgeever-phone-device__lens" />
- <span className="edgeever-phone-device__lens edgeever-phone-device__lens--wide" />
- </div>
- <div className="edgeever-phone-device__status" aria-hidden="true">
- <span className="edgeever-phone-device__time">{clock}</span>
- <span className="edgeever-phone-device__status-icons">
- <svg viewBox="0 0 17 12" width="17" height="12" aria-hidden="true">
- <rect x="0" y="8" width="3" height="4" rx="0.6" fill="currentColor" />
- <rect x="4.5" y="5.5" width="3" height="6.5" rx="0.6" fill="currentColor" />
- <rect x="9" y="3" width="3" height="9" rx="0.6" fill="currentColor" />
- <rect x="13.5" y="0" width="3" height="12" rx="0.6" fill="currentColor" />
- </svg>
- <svg viewBox="0 0 16 12" width="16" height="12" aria-hidden="true">
- <path
- fill="currentColor"
- d="M8 10.15a1.15 1.15 0 1 0 0 2.3 1.15 1.15 0 0 0 0-2.3Zm0-3.45c1.46 0 2.8.58 3.78 1.53l-1.15 1.16a3.2 3.2 0 0 0-5.26 0L4.22 8.23A5.25 5.25 0 0 1 8 6.7Zm0-3.4c2.46 0 4.7 1 6.37 2.62L13.2 7.08A7.15 7.15 0 0 0 8 4.95a7.15 7.15 0 0 0-5.2 2.13L1.63 5.92A9.55 9.55 0 0 1 8 3.3Z"
- />
- </svg>
- <svg viewBox="0 0 27 13" width="25" height="12" aria-hidden="true">
- <rect x="0.7" y="0.7" width="22" height="11.6" rx="2.6" fill="none" stroke="currentColor" strokeWidth="1.2" opacity="0.35" />
- <rect x="2.3" y="2.3" width="17" height="8.4" rx="1.5" fill="currentColor" />
- <path d="M24.3 4.15v4.7c.95-.5 1.45-1.25 1.45-2.35s-.5-1.85-1.45-2.35Z" fill="currentColor" opacity="0.35" />
- </svg>
- </span>
</div>
<div
className={cn("edgeever-phone-preview", markup.paper ? "edgeever-phone-preview--article" : "edgeever-phone-preview--editor")}
diff --git a/apps/web/src/components/EditorToolbar.tsx b/apps/web/src/components/EditorToolbar.tsx
index 8e5a7425..3e461429 100644
--- a/apps/web/src/components/EditorToolbar.tsx
+++ b/apps/web/src/components/EditorToolbar.tsx
@@ -152,8 +152,6 @@ export const EditorToolbar = ({
onPickExternalLink,
onPickNoteLink,
externalLinkActive = false,
- phonePreview = false,
- onPhonePreviewChange,
}: {
editor: Editor | null;
readOnly: boolean;
@@ -165,8 +163,6 @@ export const EditorToolbar = ({
onPickExternalLink?: () => void;
onPickNoteLink?: () => void;
externalLinkActive?: boolean;
- phonePreview?: boolean;
- onPhonePreviewChange?: (open: boolean) => void;
}) => {
const { t } = useTranslation();
const { markdownThemePreference, setMarkdownTheme } = useMarkdownTheme();
@@ -422,22 +418,6 @@ export const EditorToolbar = ({
))}
</SelectContent>
</Select>
- {onPhonePreviewChange ? (
- <span className="hidden xl:inline-flex">
- <EditorToolbarButton
- title={phonePreview ? t("editor.hidePhonePreview") : t("editor.showPhonePreview")}
- active={phonePreview}
- onClick={() => onPhonePreviewChange(!phonePreview)}
- >
- <svg viewBox="0 0 16 16" className="h-4 w-4" fill="none" aria-hidden="true">
- <rect x="3.6" y="1.1" width="8.8" height="13.8" rx="2" stroke="currentColor" strokeWidth="1.4" />
- <rect x="5.15" y="3.35" width="5.7" height="7.15" rx="0.55" fill="currentColor" opacity="0.2" />
- <rect x="6.35" y="2.15" width="3.3" height="0.85" rx="0.42" fill="currentColor" />
- <rect x="6.7" y="12.55" width="2.6" height="0.7" rx="0.35" fill="currentColor" />
- </svg>
- </EditorToolbarButton>
- </span>
- ) : null}
<MemoEditorToolbarDivider className="hidden sm:block" />
<Select
value={blockValue}
diff --git a/apps/web/src/lib/markdown-theme.test.mjs b/apps/web/src/lib/markdown-theme.test.mjs
index 3833f5be..6a4bf844 100644
--- a/apps/web/src/lib/markdown-theme.test.mjs
+++ b/apps/web/src/lib/markdown-theme.test.mjs
@@ -71,12 +71,12 @@ describe("markdown theme contracts", () => {
expect(toolbar).toContain("namedEditorThemes");
});
- test("the rich-text toolbar can toggle a live phone preview", () => {
+ test("phone preview is toggled from the note header instead of the format toolbar", () => {
const toolbar = readFileSync(new URL("../components/EditorToolbar.tsx", import.meta.url), "utf8");
const editorPane = readFileSync(new URL("../components/EditorPane.tsx", import.meta.url), "utf8");
- expect(toolbar).toContain("onPhonePreviewChange");
- expect(toolbar).toContain('t("editor.showPhonePreview")');
- expect(toolbar).not.toContain("{t(\"editor.phonePreview\")}");
+ expect(toolbar).not.toContain("onPhonePreviewChange");
+ expect(editorPane).toContain("PhonePreviewGlyph");
+ expect(editorPane).toContain("handlePhonePreviewChange");
expect(editorPane).toContain("EditorPhonePreview");
expect(editorPane).toContain("phonePreviewOpen");
expect(editorPane).toContain("readEditorPhonePreviewPreference");
@@ -84,7 +84,9 @@ describe("markdown theme contracts", () => {
expect(preview).toContain("edgeever-phone-device");
expect(preview).toContain("edgeever-phone-device__island");
expect(preview).toContain("edgeever-phone-device__lens");
+ expect(preview).toContain("edgeever-phone-device__top");
expect(preview).toContain("edgeever-phone-device__home");
+ expect(preview).not.toContain("edgeever-phone-device__status");
expect(preview).toContain("buildPhonePreviewHtml");
expect(preview).toContain("embedMermaidForPreview");
expect(preview).toContain("phonePreviewFollow");
diff --git a/apps/web/src/styles/globals.css b/apps/web/src/styles/globals.css
index 97180432..bf3b38cd 100644
--- a/apps/web/src/styles/globals.css
+++ b/apps/web/src/styles/globals.css
@@ -701,16 +701,12 @@ textarea {
position: relative;
width: 331px;
height: 686px;
- border-radius: 52px;
- background:
- linear-gradient(165deg, #6a6a6e 0%, #3e3e42 12%, #1f1f22 38%, #2c2c30 72%, #121214 100%);
+ border-radius: 48px;
+ background: #1c1c1e;
box-shadow:
- inset 0 1px 0 rgba(255, 255, 255, 0.38),
- inset 0 -10px 18px rgba(255, 255, 255, 0.05),
- inset 0 0 0 1px rgba(0, 0, 0, 0.55),
- 0 0 0 1px #0c0c0e,
- 0 22px 48px rgba(15, 23, 42, 0.18),
- 0 48px 90px rgba(15, 23, 42, 0.16);
+ inset 0 0 0 1px #3a3a3c,
+ 0 0 0 1.5px #111,
+ 0 18px 40px rgba(15, 23, 42, 0.16);
}
.edgeever-phone-device__silent,
@@ -718,10 +714,10 @@ textarea {
.edgeever-phone-device__vol-down,
.edgeever-phone-device__power {
position: absolute;
- background: linear-gradient(180deg, #4a4a4e, #1c1c1f);
+ background: linear-gradient(180deg, #d4d4d8, #71717a);
box-shadow:
- inset 0 1px 0 rgba(255, 255, 255, 0.18),
- 0 0 0 0.5px rgba(0, 0, 0, 0.45);
+ inset 0 1px 0 rgba(255, 255, 255, 0.35),
+ 0 0 0 0.5px rgba(0, 0, 0, 0.35);
}
.edgeever-phone-device__silent {
@@ -753,97 +749,73 @@ textarea {
.edgeever-phone-device__screen {
position: absolute;
- inset: 6.8% 3.7% 3.1%;
+ inset: 10px 8px 10px;
overflow: hidden;
- border-radius: 38px;
+ border-radius: 40px;
background: #fff;
- box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22);
}
:root.dark .edgeever-phone-device__screen {
background: #111;
}
+.edgeever-phone-device__top {
+ position: absolute;
+ top: 0;
+ right: 0;
+ left: 0;
+ z-index: 3;
+ height: 44px;
+ pointer-events: none;
+ background: #fff;
+ border-radius: 40px 40px 0 0;
+}
+
+:root.dark .edgeever-phone-device__top {
+ background: #111;
+}
+
.edgeever-phone-device__island {
position: absolute;
- top: 8px;
+ top: 9px;
left: 50%;
z-index: 4;
display: flex;
- width: 88px;
- height: 26px;
+ width: 96px;
+ height: 28px;
align-items: center;
- justify-content: center;
- gap: 8px;
+ justify-content: flex-end;
+ padding-right: 8px;
transform: translateX(-50%);
border-radius: 20px;
- background: #050505;
- box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
+ background: #0a0a0a;
}
.edgeever-phone-device__lens {
- width: 8px;
- height: 8px;
- border-radius: 50%;
- background: radial-gradient(circle at 32% 32%, #5b6c88, #182033 58%, #050505 100%);
- box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
-}
-
-.edgeever-phone-device__lens--wide {
width: 11px;
height: 11px;
-}
-
-.edgeever-phone-device__status {
- position: absolute;
- top: 0;
- right: 0;
- left: 0;
- z-index: 3;
- display: flex;
- height: 48px;
- align-items: flex-end;
- justify-content: space-between;
- padding: 0 22px 7px;
- color: #111;
- pointer-events: none;
-}
-
-:root.dark .edgeever-phone-device__status {
- color: #f4f4f5;
-}
-
-.edgeever-phone-device__time {
- font-family: -apple-system, "SF Pro Text", "PingFang SC", sans-serif;
- font-size: 13.5px;
- font-weight: 600;
- font-variant-numeric: tabular-nums;
- letter-spacing: -0.03em;
-}
-
-.edgeever-phone-device__status-icons {
- display: flex;
- align-items: center;
- gap: 5px;
+ border-radius: 50%;
+ background: radial-gradient(circle at 35% 32%, #4a6080, #152033 55%, #050505 100%);
+ box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.edgeever-phone-device__home {
position: absolute;
- bottom: 6px;
+ bottom: 7px;
left: 50%;
z-index: 4;
width: 108px;
height: 4px;
transform: translateX(-50%);
border-radius: 99px;
- background: rgba(15, 15, 16, 0.92);
+ background: rgba(15, 15, 16, 0.88);
}
.edgeever-phone-preview {
height: 100%;
overflow-y: auto;
overscroll-behavior: contain;
- padding: 52px 16px 26px;
+ padding: 48px 16px 26px;
background: var(--publish-bg, #fff);
-webkit-overflow-scrolling: touch;
}