Skip to content

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

feat(web): overhaul note image share with poster styling, smartisan themes, and rich customization

tianma-ifcb1900e31cda
diff --git a/apps/web/src/components/dialogs/ShareNoteImageDialog.tsx b/apps/web/src/components/dialogs/ShareNoteImageDialog.tsx
index 0d3bc64a..132b39fa 100644
--- a/apps/web/src/components/dialogs/ShareNoteImageDialog.tsx
+++ b/apps/web/src/components/dialogs/ShareNoteImageDialog.tsx
@@ -1,4 +1,4 @@
-import { Download, LoaderCircle, Share2 } from "lucide-react";
+import { Check, Copy, Download, LoaderCircle, Palette, Share2, Type } from "lucide-react";
import { useEffect, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
@@ -12,12 +12,16 @@ import {
DialogTitle,
} from "@/components/ui/dialog";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
+import { copyImageBlobToClipboard } from "@/lib/clipboard";
import {
createNoteImage,
downloadPreparedNoteImage,
type DownloadNoteImageOptions,
- type NoteImageBackground,
+ type NoteImageCardWidth,
+ type NoteImageFontSize,
+ type NoteImageFontStyle,
type NoteImageFormat,
+ type NoteImageTheme,
type PreparedNoteImage,
} from "@/lib/note-image-export";
import { getHtmlImageEmbedNoticeKind } from "@/lib/note-html-export";
@@ -25,6 +29,40 @@ import { cn } from "@/lib/utils";
export type ShareNoteImageSource = Omit<DownloadNoteImageOptions, "background" | "format">;
+const THEME_OPTIONS: Array<{
+ id: NoteImageTheme;
+ previewBg: string;
+ dotColor: string;
+ isDark?: boolean;
+}> = [
+ { id: "slate", previewBg: "linear-gradient(135deg, #f8fafc, #e2e8f0)", dotColor: "#16a06e" },
+ { id: "aurora", previewBg: "linear-gradient(135deg, #a7f3d0, #67e8f9, #c4b5fd)", dotColor: "#0d9488" },
+ { id: "sunset", previewBg: "linear-gradient(135deg, #fde68a, #fbcfe8, #fed7aa)", dotColor: "#ea580c" },
+ { id: "midnight", previewBg: "linear-gradient(135deg, #090d16, #1e1b4b)", dotColor: "#34d399", isDark: true },
+ { id: "mint", previewBg: "linear-gradient(135deg, #ecfdf5, #a7f3d0)", dotColor: "#059669" },
+ { id: "lavender", previewBg: "linear-gradient(135deg, #f5f3ff, #ddd6fe, #c4b5fd)", dotColor: "#7c3aed" },
+ { id: "notepad", previewBg: "linear-gradient(135deg, #fbf7ee, #f4ede0)", dotColor: "#c2410c" },
+ { id: "xuan", previewBg: "linear-gradient(135deg, #f7f6f2, #ebe8e1)", dotColor: "#b91c1c" },
+];
+
+const FONT_OPTIONS: Array<{ id: NoteImageFontStyle; labelKey: string }> = [
+ { id: "sans", labelKey: "editor.imageShare.fontStyles.sans" },
+ { id: "serif", labelKey: "editor.imageShare.fontStyles.serif" },
+ { id: "mono", labelKey: "editor.imageShare.fontStyles.mono" },
+];
+
+const SIZE_OPTIONS: Array<{ id: NoteImageFontSize; labelKey: string }> = [
+ { id: "sm", labelKey: "editor.imageShare.fontSizes.sm" },
+ { id: "md", labelKey: "editor.imageShare.fontSizes.md" },
+ { id: "lg", labelKey: "editor.imageShare.fontSizes.lg" },
+];
+
+const WIDTH_OPTIONS: Array<{ id: NoteImageCardWidth; labelKey: string }> = [
+ { id: "compact", labelKey: "editor.imageShare.cardWidths.compact" },
+ { id: "standard", labelKey: "editor.imageShare.cardWidths.standard" },
+ { id: "wide", labelKey: "editor.imageShare.cardWidths.wide" },
+];
+
export const ShareNoteImageDialog = ({
open,
onOpenChange,
@@ -36,24 +74,34 @@ export const ShareNoteImageDialog = ({
}) => {
const { t } = useTranslation();
const [format, setFormat] = useState<NoteImageFormat>("png");
- const [background, setBackground] = useState<NoteImageBackground>("slate");
- const [showNotebook, setShowNotebook] = useState(true);
- const [showTags, setShowTags] = useState(true);
+ const [theme, setTheme] = useState<NoteImageTheme>("slate");
+ const [fontStyle, setFontStyle] = useState<NoteImageFontStyle>("serif");
+ const [fontSize, setFontSize] = useState<NoteImageFontSize>("lg");
+ const [cardWidth, setCardWidth] = useState<NoteImageCardWidth>("standard");
+ const [showTitle, setShowTitle] = useState(true);
+ const [showNotebook, setShowNotebook] = useState(false);
+ const [showTags, setShowTags] = useState(false);
const [showUpdatedAt, setShowUpdatedAt] = useState(true);
const [showBranding, setShowBranding] = useState(true);
const [prepared, setPrepared] = useState<PreparedNoteImage | null>(null);
const [previewUrl, setPreviewUrl] = useState("");
const [error, setError] = useState(false);
+ const [copied, setCopied] = useState(false);
const generationRef = useRef(0);
useEffect(() => {
if (!open) return;
setFormat("png");
- setBackground("slate");
- setShowNotebook(true);
- setShowTags(true);
+ setTheme("slate");
+ setFontStyle("serif");
+ setFontSize("lg");
+ setCardWidth("standard");
+ setShowTitle(true);
+ setShowNotebook(false);
+ setShowTags(false);
setShowUpdatedAt(true);
setShowBranding(true);
+ setCopied(false);
}, [open, source.title]);
useEffect(() => {
@@ -64,39 +112,72 @@ export const ShareNoteImageDialog = ({
const timer = window.setTimeout(() => {
void createNoteImage({
...source,
- background,
+ theme,
+ background: theme,
+ fontStyle,
+ fontSize,
+ cardWidth,
+ showTitle,
+ showNotebook,
+ showTags,
+ showUpdatedAt,
branding: showBranding,
format,
notebook: showNotebook ? source.notebook : "",
tags: showTags ? source.tags : [],
updatedAt: showUpdatedAt ? source.updatedAt : "",
- }).then((result) => {
- if (generation !== generationRef.current) return;
- setPreviewUrl((current) => {
- if (current) URL.revokeObjectURL(current);
- return URL.createObjectURL(result.blob);
+ })
+ .then((result) => {
+ if (generation !== generationRef.current) return;
+ setPreviewUrl((current) => {
+ if (current) URL.revokeObjectURL(current);
+ return URL.createObjectURL(result.blob);
+ });
+ setPrepared(result);
+ })
+ .catch(() => {
+ if (generation === generationRef.current) setError(true);
});
- setPrepared(result);
- }).catch(() => {
- if (generation === generationRef.current) setError(true);
- });
}, 180);
return () => window.clearTimeout(timer);
- }, [background, format, open, showBranding, showNotebook, showTags, showUpdatedAt, source]);
+ }, [
+ cardWidth,
+ fontSize,
+ fontStyle,
+ format,
+ open,
+ showBranding,
+ showNotebook,
+ showTags,
+ showTitle,
+ showUpdatedAt,
+ source,
+ theme,
+ ]);
useEffect(() => () => {
generationRef.current += 1;
if (previewUrl) URL.revokeObjectURL(previewUrl);
}, [previewUrl]);
- const shareFile = useMemo(() => prepared
- ? new File([prepared.blob], prepared.filename, { type: prepared.mimeType })
- : null, [prepared]);
+ const shareFile = useMemo(
+ () => (prepared ? new File([prepared.blob], prepared.filename, { type: prepared.mimeType }) : null),
+ [prepared],
+ );
const canUseSystemShare = Boolean(
shareFile && navigator.canShare?.({ files: [shareFile] }) && navigator.share,
);
const noticeKind = prepared ? getHtmlImageEmbedNoticeKind(prepared.images) : "none";
+ const handleCopyImage = async () => {
+ if (!prepared) return;
+ const success = await copyImageBlobToClipboard(prepared.blob);
+ if (success) {
+ setCopied(true);
+ window.setTimeout(() => setCopied(false), 2000);
+ }
+ };
+
const share = async () => {
if (!prepared || !shareFile) return;
try {
@@ -115,21 +196,22 @@ export const ShareNoteImageDialog = ({
return (
<Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent className="max-h-[92vh] max-w-4xl gap-0 overflow-hidden p-0">
- <DialogHeader className="border-b border-slate-200 px-5 py-4 pr-12 text-left">
- <DialogTitle className="flex items-center gap-2 text-base">
- <Share2 className="h-5 w-5 text-emerald-600" />
+ <DialogContent className="max-h-[94vh] max-w-5xl gap-0 overflow-hidden p-0">
+ <DialogHeader className="border-b border-slate-200 px-5 py-3.5 pr-12 text-left">
+ <DialogTitle className="flex items-center gap-2 text-base font-semibold">
+ <Share2 className="h-4.5 w-4.5 text-emerald-600" />
{t("editor.imageShare.title")}
</DialogTitle>
- <DialogDescription>{t("editor.imageShare.description")}</DialogDescription>
+ <DialogDescription className="sr-only">{t("editor.imageShare.description")}</DialogDescription>
</DialogHeader>
- <div className="grid min-h-0 flex-1 gap-0 md:grid-cols-[minmax(0,1fr)_18rem]">
- <div className="min-h-64 overflow-auto bg-slate-100 p-4 md:max-h-[68vh]">
+ <div className="grid min-h-0 flex-1 gap-0 md:grid-cols-[minmax(0,1fr)_20rem]">
+ <div className="flex min-h-72 items-center justify-center overflow-auto bg-slate-100/90 p-4 sm:p-6 md:max-h-[72vh]">
{previewUrl && prepared ? (
<img
alt={t("editor.imageShare.previewAlt")}
- className="mx-auto block h-auto w-full max-w-[32rem] rounded-md shadow-lg"
+ className="mx-auto block h-auto max-w-full rounded-xl shadow-xl transition-all duration-200"
+ style={{ maxHeight: "calc(72vh - 3rem)" }}
src={previewUrl}
/>
) : error ? (
@@ -138,89 +220,207 @@ export const ShareNoteImageDialog = ({
</div>
) : (
<div className="flex min-h-64 items-center justify-center gap-2 text-sm text-slate-500" role="status">
- <LoaderCircle className="h-5 w-5 animate-spin" />
+ <LoaderCircle className="h-5 w-5 animate-spin text-emerald-600" />
{t("editor.imageShare.generating")}
</div>
)}
</div>
- <div className="space-y-5 overflow-y-auto border-t border-slate-200 p-5 md:max-h-[68vh] md:border-l md:border-t-0">
- <fieldset className="space-y-2">
- <legend className="text-xs font-semibold uppercase tracking-wide text-slate-500">
- {t("editor.imageShare.background")}
+ <div className="space-y-5 overflow-y-auto border-t border-slate-200 p-5 md:max-h-[72vh] md:border-l md:border-t-0">
+ {/* Theme Selector */}
+ <fieldset className="space-y-2.5">
+ <legend className="flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider text-slate-500">
+ <Palette className="h-3.5 w-3.5" />
+ {t("editor.imageShare.theme")}
+ </legend>
+ <div className="grid grid-cols-2 gap-2">
+ {THEME_OPTIONS.map((item) => {
+ const isSelected = theme === item.id;
+ const label = t(`editor.imageShare.themes.${item.id}`);
+ return (
+ <button
+ key={item.id}
+ aria-pressed={isSelected}
+ className={cn(
+ "group relative flex items-center gap-2.5 rounded-lg border p-2 text-left text-xs font-medium transition-all outline-none focus-visible:ring-2 focus-visible:ring-emerald-500",
+ isSelected
+ ? "border-emerald-500 bg-emerald-50/40 text-emerald-950 ring-1 ring-emerald-500"
+ : "border-slate-200 bg-white text-slate-700 hover:border-slate-300 hover:bg-slate-50/70",
+ )}
+ type="button"
+ onClick={() => setTheme(item.id)}
+ >
+ <span
+ className="h-6 w-6 shrink-0 rounded-md border border-black/10 shadow-sm"
+ style={{ background: item.previewBg }}
+ />
+ <span className="truncate">{label}</span>
+ </button>
+ );
+ })}
+ </div>
+ </fieldset>
+
+ {/* Typography and Layout */}
+ <fieldset className="space-y-3">
+ <legend className="flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider text-slate-500">
+ <Type className="h-3.5 w-3.5" />
+ {t("editor.imageShare.fontStyle")}
</legend>
- <div className="grid grid-cols-3 gap-2">
- {(["slate", "mint", "warm"] as const).map((value) => (
+ <div className="grid grid-cols-3 gap-1.5">
+ {FONT_OPTIONS.map((item) => (
<button
- key={value}
- aria-pressed={background === value}
+ key={item.id}
+ aria-pressed={fontStyle === item.id}
className={cn(
- "h-10 rounded-md border text-xs font-medium outline-none focus-visible:ring-2 focus-visible:ring-emerald-500",
- value === "slate" && "bg-slate-50",
- value === "mint" && "bg-emerald-50",
- value === "warm" && "bg-amber-50",
- background === value ? "border-emerald-500 ring-1 ring-emerald-500" : "border-slate-200",
+ "h-8 rounded-md border text-xs font-medium transition-colors outline-none focus-visible:ring-2 focus-visible:ring-emerald-500",
+ fontStyle === item.id
+ ? "border-emerald-500 bg-emerald-50 text-emerald-900 font-semibold"
+ : "border-slate-200 bg-white text-slate-600 hover:bg-slate-50",
)}
type="button"
- onClick={() => setBackground(value)}
+ onClick={() => setFontStyle(item.id)}
>
- {t(`editor.imageShare.backgrounds.${value}`)}
+ {t(item.labelKey)}
</button>
))}
</div>
+
+ {/* Font Size */}
+ <div className="space-y-1.5 pt-1">
+ <div className="text-xs font-medium text-slate-600">{t("editor.imageShare.fontSize")}</div>
+ <div className="grid grid-cols-3 gap-1.5">
+ {SIZE_OPTIONS.map((item) => (
+ <button
+ key={item.id}
+ aria-pressed={fontSize === item.id}
+ className={cn(
+ "h-7 rounded border text-xs font-medium transition-colors outline-none focus-visible:ring-2 focus-visible:ring-emerald-500",
+ fontSize === item.id
+ ? "border-emerald-500 bg-emerald-50/80 text-emerald-900 font-semibold"
+ : "border-slate-200 bg-white text-slate-600 hover:bg-slate-50",
+ )}
+ type="button"
+ onClick={() => setFontSize(item.id)}
+ >
+ {t(item.labelKey)}
+ </button>
+ ))}
+ </div>
+ </div>
+
+ {/* Card Width */}
+ <div className="space-y-1.5 pt-1">
+ <div className="text-xs font-medium text-slate-600">{t("editor.imageShare.cardWidth")}</div>
+ <div className="grid grid-cols-3 gap-1.5">
+ {WIDTH_OPTIONS.map((item) => (
+ <button
+ key={item.id}
+ aria-pressed={cardWidth === item.id}
+ className={cn(
+ "h-7 rounded border text-xs font-medium transition-colors outline-none focus-visible:ring-2 focus-visible:ring-emerald-500",
+ cardWidth === item.id
+ ? "border-emerald-500 bg-emerald-50/80 text-emerald-900 font-semibold"
+ : "border-slate-200 bg-white text-slate-600 hover:bg-slate-50",
+ )}
+ type="button"
+ onClick={() => setCardWidth(item.id)}
+ >
+ {t(item.labelKey)}
+ </button>
+ ))}
+ </div>
+ </div>
</fieldset>
- <fieldset className="space-y-3">
- <legend className="text-xs font-semibold uppercase tracking-wide text-slate-500">
+ {/* Metadata / Content Toggles */}
+ <fieldset className="space-y-2.5">
+ <legend className="text-xs font-semibold uppercase tracking-wider text-slate-500">
{t("editor.imageShare.metadata")}
</legend>
- {([
- ["notebook", showNotebook, setShowNotebook],
- ["tags", showTags, setShowTags],
- ["updatedAt", showUpdatedAt, setShowUpdatedAt],
- ["branding", showBranding, setShowBranding],
- ] as const).map(([key, checked, setChecked]) => (
- <label key={key} className="flex cursor-pointer items-center gap-2 text-sm text-slate-700">
- <Checkbox checked={checked} onCheckedChange={(value) => setChecked(value === true)} />
- {t(`editor.imageShare.fields.${key}`)}
- </label>
- ))}
+ <div className="space-y-2">
+ {([
+ ["title", showTitle, setShowTitle],
+ ["notebook", showNotebook, setShowNotebook],
+ ["tags", showTags, setShowTags],
+ ["updatedAt", showUpdatedAt, setShowUpdatedAt],
+ ["branding", showBranding, setShowBranding],
+ ] as const).map(([key, checked, setChecked]) => (
+ <label key={key} className="flex cursor-pointer items-center gap-2 text-xs text-slate-700">
+ <Checkbox checked={checked} onCheckedChange={(value) => setChecked(value === true)} />
+ {t(`editor.imageShare.fields.${key}`)}
+ </label>
+ ))}
+ </div>
</fieldset>
- <label className="grid gap-2 text-xs font-semibold uppercase tracking-wide text-slate-500">
+ {/* Format Selection */}
+ <label className="grid gap-1.5 text-xs font-semibold uppercase tracking-wider text-slate-500">
{t("editor.imageShare.format")}
<Select value={format} onValueChange={(value) => setFormat(value as NoteImageFormat)}>
- <SelectTrigger className="font-normal normal-case tracking-normal text-slate-700">
+ <SelectTrigger className="h-8 text-xs font-normal normal-case tracking-normal text-slate-700">
<SelectValue />
</SelectTrigger>
<SelectContent>
- <SelectItem value="png">PNG · {t("editor.imageShare.pngHint")}</SelectItem>
- <SelectItem value="jpeg">JPEG · {t("editor.imageShare.jpegHint")}</SelectItem>
+ <SelectItem className="text-xs" value="png">
+ PNG · {t("editor.imageShare.pngHint")}
+ </SelectItem>
+ <SelectItem className="text-xs" value="jpeg">
+ JPEG · {t("editor.imageShare.jpegHint")}
+ </SelectItem>
</SelectContent>
</Select>
</label>
{noticeKind !== "none" ? (
<p className="text-xs leading-5 text-amber-700">
- {t(noticeKind === "partial" ? "editor.imageExport.imageEmbedPartial" : "editor.imageExport.imageEmbedFailed", prepared?.images)}
+ {t(
+ noticeKind === "partial"
+ ? "editor.imageExport.imageEmbedPartial"
+ : "editor.imageExport.imageEmbedFailed",
+ prepared?.images,
+ )}
</p>
) : null}
{prepared && prepared.height > 12_000 ? (
- <p className="text-xs leading-5 text-amber-700">
- {t("editor.imageShare.longImageWarning")}
- </p>
+ <p className="text-xs leading-5 text-amber-700">{t("editor.imageShare.longImageWarning")}</p>
) : null}
</div>
</div>
- <DialogFooter className="border-t border-slate-200 px-5 py-4">
- <Button variant="ghost" onClick={() => onOpenChange(false)}>{t("common.cancel")}</Button>
- <Button variant={canUseSystemShare ? "outline" : "solid"} disabled={!prepared} onClick={download}>
+ <DialogFooter className="border-t border-slate-200 px-5 py-3.5">
+ <Button variant="ghost" size="sm" onClick={() => onOpenChange(false)}>
+ {t("common.cancel")}
+ </Button>
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={!prepared}
+ onClick={() => void handleCopyImage()}
+ >
+ {copied ? (
+ <>
+ <Check className="h-4 w-4 text-emerald-600" />
+ <span className="text-emerald-700">{t("editor.imageShare.copied")}</span>
+ </>
+ ) : (
+ <>
+ <Copy className="h-4 w-4" />
+ {t("editor.imageShare.copyImage")}
+ </>
+ )}
+ </Button>
+ <Button
+ variant={canUseSystemShare ? "outline" : "solid"}
+ size="sm"
+ disabled={!prepared}
+ onClick={download}
+ >
<Download className="h-4 w-4" />
{t("editor.imageShare.download")}
</Button>
{canUseSystemShare ? (
- <Button variant="solid" disabled={!prepared} onClick={() => void share()}>
+ <Button variant="solid" size="sm" disabled={!prepared} onClick={() => void share()}>
<Share2 className="h-4 w-4" />
{t("editor.imageShare.share")}
</Button>
@@ -230,3 +430,4 @@ export const ShareNoteImageDialog = ({
</Dialog>
);
};
+
diff --git a/apps/web/src/lib/clipboard.ts b/apps/web/src/lib/clipboard.ts
index 29c1594d..077711d6 100644
--- a/apps/web/src/lib/clipboard.ts
+++ b/apps/web/src/lib/clipboard.ts
@@ -66,3 +66,48 @@ export const copyHtmlToClipboard = async (html: string, plainText: string) => {
container.remove();
if (!copied) throw new Error("Clipboard copy was not available");
};
+
+export const copyImageBlobToClipboard = async (blob: Blob): Promise<boolean> => {
+ if (typeof window === "undefined" || !navigator.clipboard?.write || typeof ClipboardItem === "undefined") {
+ return false;
+ }
+ try {
+ const type = blob.type === "image/jpeg" ? "image/jpeg" : "image/png";
+ await navigator.clipboard.write([
+ new ClipboardItem({
+ [type]: blob,
+ }),
+ ]);
+ return true;
+ } catch (error) {
+ // If writing jpeg directly fails in some browsers (e.g. Safari only supports image/png),
+ // try converting blob to png via an image/canvas in memory
+ try {
+ const img = document.createElement("img");
+ const url = URL.createObjectURL(blob);
+ img.src = url;
+ await new Promise<void>((resolve, reject) => {
+ img.onload = () => resolve();
+ img.onerror = () => reject(new Error("Image load failed for clipboard conversion"));
+ });
+ const canvas = document.createElement("canvas");
+ canvas.width = img.naturalWidth;
+ canvas.height = img.naturalHeight;
+ const ctx = canvas.getContext("2d");
+ ctx?.drawImage(img, 0, 0);
+ URL.revokeObjectURL(url);
+ const pngBlob = await new Promise<Blob | null>((resolve) => canvas.toBlob(resolve, "image/png"));
+ if (!pngBlob) return false;
+ await navigator.clipboard.write([
+ new ClipboardItem({
+ "image/png": pngBlob,
+ }),
+ ]);
+ return true;
+ } catch {
+ console.warn("Failed to write image blob to clipboard:", error);
+ return false;
+ }
+ }
+};
+
diff --git a/apps/web/src/lib/note-image-export.test.mjs b/apps/web/src/lib/note-image-export.test.mjs
index 1fee799b..1ba372ef 100644
--- a/apps/web/src/lib/note-image-export.test.mjs
+++ b/apps/web/src/lib/note-image-export.test.mjs
@@ -1,6 +1,9 @@
import { describe, expect, test } from "bun:test";
import {
buildImageExportBasename,
+ buildNoteImageCardMarkup,
+ generateCardCss,
+ NOTE_IMAGE_THEMES,
} from "./note-image-export.ts";
describe("note image export helpers", () => {
@@ -9,4 +12,101 @@ describe("note image export helpers", () => {
expect(buildImageExportBasename("CON", "Untitled")).toBe("_CON");
expect(buildImageExportBasename(" ", "Untitled")).toBe("Untitled");
});
+
+ test("generates rich card markup with title, notebook, tags, and footer branding", () => {
+ const markup = buildNoteImageCardMarkup({
+ title: "My Note",
+ notebook: "Work",
+ tags: ["important", "idea"],
+ updatedAt: "2026-08-22 19:00",
+ bodyHtml: "<p>Hello World</p>",
+ fontStyle: "sans",
+ showTitle: true,
+ showNotebook: true,
+ showTags: true,
+ showUpdatedAt: true,
+ showBranding: true,
+ });
+
+ expect(markup).toContain("My Note");
+ expect(markup).toContain("Work");
+ expect(markup).toContain("#important");
+ expect(markup).toContain("#idea");
+ expect(markup).toContain("2026-08-22 19:00");
+ expect(markup).toContain("Hello World");
+ expect(markup).toContain("EdgeEver");
+ });
+
+ test("includes terminal header bar when fontStyle is mono", () => {
+ const markup = buildNoteImageCardMarkup({
+ title: "Geek Note",
+ notebook: "Dev",
+ tags: [],
+ updatedAt: "",
+ bodyHtml: "<pre><code>console.log('hi')</code></pre>",
+ fontStyle: "mono",
+ showTitle: true,
+ showBranding: false,
+ });
+
+ expect(markup).toContain("edgeever-terminal-header");
+ expect(markup).toContain("dot-red");
+ expect(markup).toContain("dot-green");
+ expect(markup).not.toContain("edgeever-card-footer");
+ });
+
+ test("generates valid card CSS with selected theme variables", () => {
+ const midnightCss = generateCardCss({
+ theme: "midnight",
+ fontStyle: "mono",
+ fontSize: "lg",
+ cardWidth: "wide",
+ });
+
+ expect(midnightCss).toContain(NOTE_IMAGE_THEMES.midnight.canvasBg);
+ expect(midnightCss).toContain("800px");
+ expect(midnightCss).toContain("JetBrains Mono");
+ });
+
+ test("generates notepad theme with tear strip, ruled lines, and brand logo", () => {
+ const markup = buildNoteImageCardMarkup({
+ title: "Notepad Note",
+ notebook: "Work",
+ bodyHtml: "<p>Smartisan style note line</p>",
+ theme: "notepad",
+ fontStyle: "serif",
+ showTitle: true,
+ showNotebook: false,
+ showTags: false,
+ showUpdatedAt: true,
+ showBranding: true,
+ });
+
+ expect(markup).toContain("edgeever-card-tear-strip");
+ expect(markup).toContain("edgeever-brand-logo");
+ expect(markup).not.toContain("edgeever-meta-notebook");
+
+ const notepadCss = generateCardCss({
+ theme: "notepad",
+ fontStyle: "serif",
+ fontSize: "lg",
+ cardWidth: "standard",
+ });
+ expect(notepadCss).toContain("edgeever-card-tear-strip");
+ expect(notepadCss).toContain("edgeever-brand-logo");
+ });
+
+ test("generates xuan rice paper theme with brand logo", () => {
+ const markup = buildNoteImageCardMarkup({
+ title: "Poem Note",
+ bodyHtml: "<p>东方诗意</p>",
+ theme: "xuan",
+ fontStyle: "serif",
+ showTitle: true,
+ showBranding: true,
+ });
+
+ expect(markup).toContain("edgeever-brand-logo");
+ });
});
+
diff --git a/apps/web/src/lib/note-image-export.ts b/apps/web/src/lib/note-image-export.ts
index 46f20b96..4701d625 100644
--- a/apps/web/src/lib/note-image-export.ts
+++ b/apps/web/src/lib/note-image-export.ts
@@ -1,12 +1,16 @@
import { toCanvas } from "html-to-image";
import type { HtmlImageEmbedResult, NoteHtmlExportMeta } from "@/lib/note-html-export";
import {
- buildNoteHtmlContentMarkup,
+ escapeHtml,
prepareNoteBodyHtmlForExport,
} from "@/lib/note-html-export";
export type NoteImageFormat = "jpeg" | "png";
-export type NoteImageBackground = "mint" | "slate" | "warm";
+export type NoteImageTheme = "slate" | "aurora" | "sunset" | "midnight" | "mint" | "notepad" | "xuan" | "lavender";
+export type NoteImageBackground = NoteImageTheme | "warm";
+export type NoteImageFontStyle = "sans" | "serif" | "mono";
+export type NoteImageFontSize = "sm" | "md" | "lg";
+export type NoteImageCardWidth = "compact" | "standard" | "wide";
export type DownloadNoteImageOptions = NoteHtmlExportMeta & {
bodyHtml: string;
@@ -14,6 +18,14 @@ export type DownloadNoteImageOptions = NoteHtmlExportMeta & {
fallbackTitle: string;
format: NoteImageFormat;
background?: NoteImageBackground;
+ theme?: NoteImageTheme;
+ fontStyle?: NoteImageFontStyle;
+ fontSize?: NoteImageFontSize;
+ cardWidth?: NoteImageCardWidth;
+ showTitle?: boolean;
+ showNotebook?: boolean;
+ showTags?: boolean;
+ showUpdatedAt?: boolean;
styles: string;
};
@@ -27,24 +39,307 @@ export type PreparedNoteImage = {
};
export const NOTE_IMAGE_EXPORT_WIDTH = 768;
-export const NOTE_IMAGE_EXPORT_PIXEL_RATIO = 1.5;
+export const NOTE_IMAGE_EXPORT_PIXEL_RATIO = 2;
+
+export const NOTE_IMAGE_CARD_WIDTH_PIXELS: Record<NoteImageCardWidth, number> = {
+ compact: 560,
+ standard: 680,
+ wide: 800,
+};
const WINDOWS_RESERVED_NAME = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i;
-const NOTE_IMAGE_BACKGROUND_COLORS: Record<NoteImageBackground, string> = {
- mint: "#ecfdf5",
+
+export const NOTE_IMAGE_BACKGROUND_COLORS: Record<NoteImageBackground, string> = {
slate: "#f8fafc",
+ aurora: "#a7f3d0",
+ sunset: "#fde68a",
+ midnight: "#090d16",
+ mint: "#ecfdf5",
+ notepad: "#fbf7ee",
+ xuan: "#f7f6f2",
+ lavender: "#f5f3ff",
warm: "#fffbeb",
};
-const NOTE_IMAGE_SHARE_STYLES = `
- .edgeever-image-share { padding: 40px 28px 32px; }
- .edgeever-image-share .edgeever-html-document { border-radius: 16px; padding: 40px 36px 32px; }
- .edgeever-image-share .edgeever-html-title { margin-bottom: 14px; font-size: 36px; letter-spacing: -0.02em; line-height: 1.24; }
- .edgeever-image-share .edgeever-html-meta { margin-bottom: 28px; padding-bottom: 18px; }
- .edgeever-image-share .edgeever-html-content { font-size: 17px; line-height: 1.82; }
- .edgeever-image-share .edgeever-image-brand { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 40px; border-top: 1px solid #e2e8f0; padding-top: 20px; color: #64748b; font-size: 13px; font-weight: 650; letter-spacing: 0.01em; }
- .edgeever-image-share .edgeever-image-brand-mark { width: 9px; height: 9px; border-radius: 3px; background: #16a06e; }
- .edgeever-image-share .edgeever-image-brand-name { color: #07130b; font-weight: 760; }
-`;
+
+export type ThemeStyleConfig = {
+ canvasBg: string;
+ cardBg: string;
+ cardBorder: string;
+ cardShadow: string;
+ textColor: string;
+ headingColor: string;
+ metaColor: string;
+ metaBg: string;
+ metaBorder: string;
+ accentColor: string;
+ accentSubtle: string;
+ linkBg: string;
+ dividerColor: string;
+ codeBg: string;
+ codeBorder: string;
+ codeColor: string;
+ quoteBg: string;
+ quoteBorder: string;
+ tableThBg: string;
+ tableBorder: string;
+ brandText: string;
+ brandMark: string;
+ isDark?: boolean;
+};
+
+export const NOTE_IMAGE_THEMES: Record<NoteImageTheme, ThemeStyleConfig> = {
+ slate: {
+ canvasBg: "linear-gradient(145deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%)",
+ cardBg: "#ffffff",
+ cardBorder: "1px solid rgba(226, 232, 240, 0.85)",
+ cardShadow: "0 2px 4px rgba(15, 23, 42, 0.02), 0 12px 28px -4px rgba(15, 23, 42, 0.07), 0 24px 60px -12px rgba(15, 23, 42, 0.06)",
+ textColor: "#1e293b",
+ headingColor: "#0f172a",
+ metaColor: "#64748b",
+ metaBg: "#f8fafc",
+ metaBorder: "#e2e8f0",
+ accentColor: "#16a06e",
+ accentSubtle: "rgba(22, 160, 110, 0.16)",
+ linkBg: "rgba(22, 160, 110, 0.08)",
+ dividerColor: "#e2e8f0",
+ codeBg: "#f8fafc",
+ codeBorder: "#e2e8f0",
+ codeColor: "#0f172a",
+ quoteBg: "rgba(240, 253, 244, 0.7)",
+ quoteBorder: "#10b981",
+ tableThBg: "#f8fafc",
+ tableBorder: "#e2e8f0",
+ brandText: "#07130b",
+ brandMark: "#16a06e",
+ },
+ aurora: {
+ canvasBg: "linear-gradient(135deg, #a7f3d0 0%, #67e8f9 40%, #c4b5fd 100%)",
+ cardBg: "rgba(255, 255, 255, 0.96)",
+ cardBorder: "1px solid rgba(255, 255, 255, 0.95)",
+ cardShadow: "0 24px 60px -12px rgba(14, 165, 233, 0.28), 0 4px 16px rgba(0, 0, 0, 0.04)",
+ textColor: "#1e293b",
+ headingColor: "#0f172a",
+ metaColor: "#475569",
+ metaBg: "rgba(241, 245, 249, 0.85)",
+ metaBorder: "rgba(203, 213, 225, 0.7)",
+ accentColor: "#0d9488",
+ accentSubtle: "rgba(13, 148, 136, 0.18)",
+ linkBg: "rgba(13, 148, 136, 0.09)",
+ dividerColor: "rgba(226, 232, 240, 0.8)",
+ codeBg: "rgba(248, 250, 252, 0.95)",
+ codeBorder: "rgba(226, 232, 240, 0.8)",
+ codeColor: "#0f172a",
+ quoteBg: "rgba(240, 253, 250, 0.85)",
+ quoteBorder: "#14b8a6",
+ tableThBg: "#f1f5f9",
+ tableBorder: "#cbd5e1",
+ brandText: "#0f172a",
+ brandMark: "#0d9488",
+ },
+ sunset: {
+ canvasBg: "linear-gradient(135deg, #fde68a 0%, #fbcfe8 45%, #fed7aa 100%)",
+ cardBg: "#fffdfa",
+ cardBorder: "1px solid rgba(253, 230, 138, 0.7)",
+ cardShadow: "0 24px 60px -12px rgba(244, 63, 94, 0.18), 0 4px 16px rgba(0, 0, 0, 0.03)",
+ textColor: "#292524",
+ headingColor: "#1c1917",
+ metaColor: "#78716c",
+ metaBg: "rgba(254, 243, 199, 0.75)",
+ metaBorder: "rgba(253, 230, 138, 0.8)",
+ accentColor: "#ea580c",
+ accentSubtle: "rgba(234, 88, 12, 0.15)",
+ linkBg: "rgba(234, 88, 12, 0.08)",
+ dividerColor: "rgba(254, 215, 170, 0.7)",
+ codeBg: "#fffbeb",
+ codeBorder: "#fde68a",
+ codeColor: "#1c1917",
+ quoteBg: "rgba(255, 247, 237, 0.85)",
+ quoteBorder: "#f97316",
+ tableThBg: "#fef3c7",
+ tableBorder: "#fde68a",
+ brandText: "#1c1917",
+ brandMark: "#ea580c",
+ },
+ midnight: {
+ canvasBg: "linear-gradient(135deg, #090d16 0%, #0f172a 50%, #1e1b4b 100%)",
+ cardBg: "#131b2e",
+ cardBorder: "1px solid rgba(255, 255, 255, 0.14)",
+ cardShadow: "0 24px 60px -12px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.08)",
+ textColor: "#cbd5e1",
+ headingColor: "#f8fafc",
+ metaColor: "#94a3b8",
+ metaBg: "rgba(30, 41, 59, 0.85)",
+ metaBorder: "rgba(51, 65, 85, 0.8)",
+ accentColor: "#34d399",
+ accentSubtle: "rgba(52, 211, 153, 0.2)",
+ linkBg: "rgba(52, 211, 153, 0.12)",
+ dividerColor: "rgba(51, 65, 85, 0.7)",
+ codeBg: "#0b1120",
+ codeBorder: "#1e293b",
+ codeColor: "#e2e8f0",
+ quoteBg: "rgba(16, 185, 129, 0.12)",
+ quoteBorder: "#34d399",
+ tableThBg: "#1e293b",
+ tableBorder: "#334155",
+ brandText: "#f8fafc",
+ brandMark: "#34d399",
+ isDark: true,
+ },
+ mint: {
+ canvasBg: "linear-gradient(135deg, #ecfdf5 0%, #d1fae5 50%, #a7f3d0 100%)",
+ cardBg: "#ffffff",
+ cardBorder: "1px solid rgba(167, 243, 208, 0.85)",
+ cardShadow: "0 20px 50px -15px rgba(16, 185, 129, 0.2), 0 4px 16px rgba(16, 185, 129, 0.06)",
+ textColor: "#134e4a",
+ headingColor: "#042f2e",
+ metaColor: "#0f766e",
+ metaBg: "#ccfbf1",
+ metaBorder: "#99f6e4",
+ accentColor: "#059669",
+ accentSubtle: "rgba(5, 150, 105, 0.18)",
+ linkBg: "rgba(5, 150, 105, 0.1)",
+ dividerColor: "#a7f3d0",
+ codeBg: "#f0fdf4",
+ codeBorder: "#a7f3d0",
+ codeColor: "#064e3b",
+ quoteBg: "rgba(236, 253, 245, 0.85)",
+ quoteBorder: "#10b981",
+ tableThBg: "#ccfbf1",
+ tableBorder: "#99f6e4",
+ brandText: "#042f2e",
+ brandMark: "#059669",
+ },
+ notepad: {
+ canvasBg: "linear-gradient(135deg, #fbf7ee 0%, #f4ede0 100%)",
+ cardBg: "#fefdfa",
+ cardBorder: "1px solid rgba(220, 205, 180, 0.85)",
+ cardShadow: "0 2px 4px rgba(100, 80, 50, 0.04), 0 16px 36px -8px rgba(100, 80, 50, 0.12), 0 28px 64px -16px rgba(100, 80, 50, 0.08)",
+ textColor: "#2c2419",
+ headingColor: "#1a140d",
+ metaColor: "#8c7b68",
+ metaBg: "rgba(240, 230, 214, 0.6)",
+ metaBorder: "#dfd3c3",
+ accentColor: "#c2410c",
+ accentSubtle: "rgba(194, 65, 12, 0.15)",
+ linkBg: "rgba(194, 65, 12, 0.08)",
+ dividerColor: "#e8decb",
+ codeBg: "#f5efe4",
+ codeBorder: "#e2d5c3",
+ codeColor: "#1a140d",
+ quoteBg: "rgba(248, 241, 230, 0.85)",
+ quoteBorder: "#d97706",
+ tableThBg: "#f5ede0",
+ tableBorder: "#dfd3c3",
+ brandText: "#1a140d",
+ brandMark: "#c2410c",
+ },
+ xuan: {
+ canvasBg: "linear-gradient(135deg, #f7f6f2 0%, #ebe8e1 100%)",
+ cardBg: "#fdfcf7",
+ cardBorder: "1px solid rgba(210, 205, 195, 0.8)",
+ cardShadow: "0 20px 48px -12px rgba(40, 35, 30, 0.1), 0 4px 16px rgba(40, 35, 30, 0.03)",
+ textColor: "#242220",
+ headingColor: "#0f0e0d",
+ metaColor: "#736d66",
+ metaBg: "#f0eee8",
+ metaBorder: "#dedad2",
+ accentColor: "#b91c1c",
+ accentSubtle: "rgba(185, 28, 28, 0.15)",
+ linkBg: "rgba(185, 28, 28, 0.08)",
+ dividerColor: "#e3dfd6",
+ codeBg: "#f4f2eb",
+ codeBorder: "#dedad2",
+ codeColor: "#0f0e0d",
+ quoteBg: "rgba(245, 243, 238, 0.85)",
+ quoteBorder: "#b91c1c",
+ tableThBg: "#edeae2",
+ tableBorder: "#dedad2",
+ brandText: "#0f0e0d",
+ brandMark: "#b91c1c",
+ },
+ lavender: {
+ canvasBg: "linear-gradient(135deg, #f5f3ff 0%, #ede9fe 50%, #ddd6fe 100%)",
+ cardBg: "#ffffff",
+ cardBorder: "1px solid rgba(221, 214, 254, 0.85)",
+ cardShadow: "0 20px 48px -12px rgba(124, 58, 237, 0.16), 0 2px 8px rgba(124, 58, 237, 0.04)",
+ textColor: "#1e1b4b",
+ headingColor: "#0f0a2e",
+ metaColor: "#6b21a8",
+ metaBg: "#f5f3ff",
+ metaBorder: "#ddd6fe",
+ accentColor: "#7c3aed",
+ accentSubtle: "rgba(124, 58, 237, 0.18)",
+ linkBg: "rgba(124, 58, 237, 0.08)",
+ dividerColor: "#e9d5ff",
+ codeBg: "#faf5ff",
+ codeBorder: "#e9d5ff",
+ codeColor: "#4c1d95",
+ quoteBg: "rgba(245, 243, 255, 0.85)",
+ quoteBorder: "#8b5cf6",
+ tableThBg: "#f5f3ff",
+ tableBorder: "#ddd6fe",
+ brandText: "#1e1b4b",
+ brandMark: "#7c3aed",
+ },
+};
+
+export const NOTE_IMAGE_FONT_FAMILIES: Record<NoteImageFontStyle, string> = {
+ sans: 'system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif',
+ serif: '"Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "Hiragino Mincho ProN", Georgia, "Times New Roman", serif',
+ mono: '"JetBrains Mono", "SF Mono", "Fira Code", Menlo, Monaco, Consolas, "Liberation Mono", monospace',
+};
+
+export const NOTE_IMAGE_FONT_SIZES: Record<
+ NoteImageFontSize,
+ {
+ base: string;
+ lineHeight: string;
+ title: string;
+ h1: string;
+ h2: string;
+ h3: string;
+ meta: string;
+ code: string;
+ }
+> = {
+ sm: {
+ base: "14.5px",
+ lineHeight: "1.72",
+ title: "28px",
+ h1: "21px",
+ h2: "18px",
+ h3: "16px",
+ meta: "12px",
+ code: "12.5px",
+ },
+ md: {
+ base: "16px",
+ lineHeight: "1.8",
+ title: "32px",
+ h1: "24px",
+ h2: "20px",
+ h3: "17.5px",
+ meta: "13px",
+ code: "13.5px",
+ },
+ lg: {
+ base: "18px",
+ lineHeight: "1.86",
+ title: "36px",
+ h1: "27px",
+ h2: "22.5px",
+ h3: "19px",
+ meta: "14px",
+ code: "15px",
+ },
+};
+
+const resolveTheme = (background?: NoteImageBackground, theme?: NoteImageTheme): NoteImageTheme => {
+ if (theme && NOTE_IMAGE_THEMES[theme]) return theme;
+ if (background === "warm") return "sunset";
+ if (background && NOTE_IMAGE_THEMES[background as NoteImageTheme]) return background as NoteImageTheme;
+ return "slate";
+};
export const buildImageExportBasename = (title: string, fallback: string) => {
const sanitized = title
@@ -57,12 +352,527 @@ export const buildImageExportBasename = (title: string, fallback: string) => {
return WINDOWS_RESERVED_NAME.test(basename) ? `_${basename}` : basename;
};
+export const buildNoteImageCardMarkup = ({
+ title,
+ notebook = "",
+ tags = [],
+ updatedAt = "",
+ bodyHtml,
+ theme = "slate",
+ fontStyle = "serif",
+ showTitle = true,
+ showNotebook = false,
+ showTags = false,
+ showUpdatedAt = true,
+ showBranding = true,
+}: {
+ title: string;
+ notebook?: string;
+ tags?: string[];
+ updatedAt?: string;
+ bodyHtml: string;
+ theme?: NoteImageTheme;
+ fontStyle?: NoteImageFontStyle;
+ showTitle?: boolean;
+ showNotebook?: boolean;
+ showTags?: boolean;
+ showUpdatedAt?: boolean;
+ showBranding?: boolean;
+}) => {
+ const isMono = fontStyle === "mono";
+ const isNotepad = theme === "notepad";
+
+ const terminalBarHtml = isMono
+ ? `<div class="edgeever-terminal-header">
+ <span class="edgeever-terminal-dot dot-red"></span>
+ <span class="edgeever-terminal-dot dot-yellow"></span>
+ <span class="edgeever-terminal-dot dot-green"></span>
+ <span class="edgeever-terminal-name">${escapeHtml(notebook || "note.md")}</span>
+ </div>`
+ : "";
+
+ const tearStripHtml = isNotepad ? `<div class="edgeever-card-tear-strip"></div>` : "";
+
+ const hasMeta = (showNotebook && Boolean(notebook)) || (showUpdatedAt && Boolean(updatedAt)) || (showTags && tags.length > 0);
+ let metaHtml = "";
+ if (hasMeta) {
+ const parts: string[] = [];
+ if (showNotebook && notebook) {
+ parts.push(
+ `<span class="edgeever-meta-pill edgeever-meta-notebook"><svg class="edgeever-icon" viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1-2.5-2.5Z"/><path d="M6 6h10"/><path d="M6 10h10"/></svg>${escapeHtml(notebook)}</span>`,
+ );
+ }
+ if (showUpdatedAt && updatedAt) {
+ parts.push(
+ `<span class="edgeever-meta-pill edgeever-meta-date"><svg class="edgeever-icon" viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="4" rx="2" ry="2"/><line x1="16" x2="16" y1="2" y2="6"/><line x1="8" x2="8" y1="2" y2="6"/><line x1="3" x2="21" y1="10" y2="10"/></svg>${escapeHtml(updatedAt)}</span>`,
+ );
+ }
+ if (showTags && tags.length > 0) {
+ for (const tag of tags) {
+ parts.push(`<span class="edgeever-meta-pill edgeever-meta-tag">#${escapeHtml(tag)}</span>`);
+ }
+ }
+ metaHtml = `<div class="edgeever-card-meta">${parts.join("")}</div>`;
+ }
+
+ const titleHtml = showTitle && title ? `<h1 class="edgeever-card-title">${escapeHtml(title)}</h1>` : "";
+ const dividerHtml = (titleHtml || metaHtml) ? `<div class="edgeever-card-divider"></div>` : "";
+
+ const brandBadgeHtml = `<div class="edgeever-brand-badge">
+ <svg class="edgeever-brand-logo" viewBox="0 0 1024 1024" width="20" height="20" xmlns="http://www.w3.org/2000/svg">
+ <rect x="100" y="100" width="824" height="824" rx="188" fill="#16a06e" />
+ <g transform="translate(100 100) scale(0.74234234) translate(-72 -72)">
+ <path fill="#07130b" fill-rule="evenodd" d="M253.5 707.5Q249 678 249.5 655Q250 632 253.5 611.5Q257 591 264.5 568.5Q272 546 281 530Q290 514 287 485Q284 456 283.5 417Q283 378 285 351.5Q287 325 292 299Q297 273 304.5 254.5Q312 236 318.5 227.5Q325 219 336 213Q347 207 358.5 207.5Q370 208 383 213.5Q396 219 407 226.5Q418 234 428 242.5Q438 251 455 268.5Q472 286 485.5 303.5Q499 321 510.5 339Q522 357 528 368.5Q534 380 534 385.5Q534 391 532.5 394.5Q531 398 527.5 401Q524 404 518 405Q512 406 507 404Q502 402 499.5 399.5Q497 397 491.5 386Q486 375 474 357Q462 339 450.5 324.5Q439 310 426 296.5Q413 283 400.5 272.5Q388 262 377 255.5Q366 249 361 248Q356 247 352.5 249.5Q349 252 344.5 261Q340 270 337 280Q334 290 329 325.5Q324 361 323.5 400Q323 439 327 479.5Q331 520 321 538Q311 556 306 568.5Q301 581 297 596Q293 611 291 624.5Q289 638 289 661Q289 684 292 702Q295 720 301 739.5Q307 759 315.5 776.5Q324 794 335 810Q346 826 358 838.5Q370 851 386.5 863.5Q403 876 419.5 884.5Q436 893 456 899.5Q476 906 501 909.5Q526 913 529.5 916Q533 919 534.5 922Q536 925 536 931.5Q536 938 532.5 943Q529 948 524 950Q519 952 505.5 951Q492 950 473 946Q454 942 426 931Q398 920 385.5 912.5Q373 905 359.5 894.5Q346 884 333.5 871.5Q321 859 313 849Q305 839 291 815Q277 791 267.5 764Q258 737 253.5 707.5ZM719 941.5Q716 936 717 929Q718 922 721 918.5Q724 915 727 913.5Q730 912 749 910Q768 908 785 903.5Q802 899 823 889.5Q844 880 860.5 868.5Q877 857 887.5 847Q898 837 911 820Q924 803 932 788.5Q940 774 947.5 753.5Q955 733 959.5 708Q964 683 964 660.5Q964 638 960.5 617.5Q957 597 952.5 582.5Q948 568 943.5 558Q939 548 931 535Q923 522 927 479Q931 436 930.5 400Q930 364 925.5 329Q921 294 917 280Q913 266 909 258.5Q905 251 902 249Q899 247 893 248.5Q887 250 867.5 264Q848 278 835.5 290.5Q823 303 810.5 318Q798 333 783.5 354Q769 375 762 387.5Q755 400 751 402.5Q747 405 742 405.5Q737 406 732 404Q727 402 723.5 397Q720 392 720.5 385Q721 378 736.5 353Q752 328 768 307.5Q784 287 803.5 267Q823 247 834 238Q845 229 858.5 221Q872 213 881 210Q890 207 899.5 207Q909 207 918.5 212Q928 217 935.5 226.5Q943 236 949.5 252Q956 268 960 286Q964 304 967.5 344.5Q971 385 970.5 418Q970 451 967 482.5Q964 514 972 528Q980 542 986 558Q992 574 996 591Q1000 608 1002 624.5Q1004 641 1003.5 667Q1003 693 998 719.5Q993 746 985 768Q977 790 964.5 812Q952 834 940 849Q928 864 915.5 876Q903 888 892.5 896Q882 904 858 917Q834 930 820 935Q806 940 789.5 944Q773 948 753 950Q733 952 727.5 949.5Q722 947 719 941.5ZM378.5 728Q373 718 373 714.5Q373 711 375.5 708Q378 705 387 699Q396 693 405 689Q414 685 426 682.5Q438 680 447.5 680Q457 680 467.5 682Q478 684 490 690Q502 696 512.5 706.5Q523 717 530.5 733Q538 749 539.5 762Q541 775 537 778Q533 781 515.5 784Q498 787 481 786.5Q464 786 451 783Q438 780 428.5 775.5Q419 771 412 766Q405 761 394.5 749.5Q384 738 378.5 728ZM713.5 778Q710 775 710.5 767Q711 759 714 749Q717 739 723.5 727.5Q730 716 740.5 706Q751 696 762 690.5Q773 685 785.5 682.5Q798 680 813 681Q828 682 843.5 688Q859 694 869.5 702.5Q880 711 880 714.5Q880 718 871.5 732Q863 746 853 755.5Q843 765 830.5 772Q818 779 804 782.5Q790 786 772.5 786.5Q755 787 736 784Q717 781 713.5 778ZM406 710Q395 716 398 722.5Q401 729 410 738.5Q419 748 427 753Q435 758 441 760Q447 762 444.5 749.5Q442 737 442.5 726.5Q443 716 445 707.5Q447 699 432 701.5Q417 704 406 710ZM819.5 701Q806 699 808 708.5Q810 718 810 730.5Q810 743 808 750.5Q806 758 806 760Q806 762 807 762Q808 762 815 759Q822 756 830.5 750Q839 744 846 736Q853 728 855.5 722Q858 716 845.5 709.5Q833 703 819.5 701ZM471 759.5Q469 763 469 765Q469 767 472 767.5Q475 768 488.5 768Q502 768 512 766Q522 764 519.5 754Q517 744 511 734Q505 724 498.5 718Q492 712 484.5 708Q477 704 475.5 704Q474 704 475 723Q476 742 474.5 749Q473 756 471 759.5ZM733 750.5Q730 759 730 761.5Q730 764 737 765.5Q744 767 763.5 767Q783 767 779.5 752Q776 737 776 730.5Q776 724 778 714Q780 704 770.5 708Q761 712 753 719.5Q745 727 740.5 734.5Q736 742 733 750.5ZM592.5 848.5Q588 841 588 836.5Q588 832 590 829Q592 826 599.5 822.5Q607 819 613.5 818Q620 817 626.5 817Q633 817 642.5 819Q652 821 655 822.5Q658 824 661.5 828.5Q665 833 664.5 838Q664 843 659.5 850Q655 857 645 867Q635 877 631.5 878.5Q628 880 625 879.5Q622 879 617.5 876Q613 873 605 864.5Q597 856 592.5 848.5Z" />
+ </g>
+ </svg>
+ <span class="edgeever-brand-name">EdgeEver</span>
+ </div>`;
+
+ const footerHtml = showBranding
+ ? `<footer class="edgeever-card-footer">
+ <div class="edgeever-card-footer-meta">
+ <span class="edgeever-footer-slogan">Think, capture, and flourish</span>
+ </div>
+ ${brandBadgeHtml}
+ </footer>`
+ : "";
+
+ return `<div class="edgeever-image-wrapper">
+ <article class="edgeever-image-card" data-theme="${theme}">
+ ${tearStripHtml}
+ ${terminalBarHtml}
+ <header class="edgeever-card-header">
+ ${metaHtml}
+ ${titleHtml}
+ ${dividerHtml}
+ </header>
+ <div class="edgeever-card-body">
+ ${bodyHtml}
+ </div>
+ ${footerHtml}
+ </article>
+</div>`;
+};
+
+export const generateCardCss = ({
+ theme = "slate",
+ fontStyle = "serif",
+ fontSize = "lg",
+ cardWidth = "standard",
+}: {
+ theme: NoteImageTheme;
+ fontStyle: NoteImageFontStyle;
+ fontSize: NoteImageFontSize;
+ cardWidth: NoteImageCardWidth;
+}) => {
+ const themeCfg = NOTE_IMAGE_THEMES[theme] || NOTE_IMAGE_THEMES.slate;
+ const fontFam = NOTE_IMAGE_FONT_FAMILIES[fontStyle] || NOTE_IMAGE_FONT_FAMILIES.sans;
+ const sizeCfg = NOTE_IMAGE_FONT_SIZES[fontSize] || NOTE_IMAGE_FONT_SIZES.md;
+ const widthPx = NOTE_IMAGE_CARD_WIDTH_PIXELS[cardWidth] || 680;
+
+ return `
+ :root {
+ --ee-canvas-bg: ${themeCfg.canvasBg};
+ --ee-card-bg: ${themeCfg.cardBg};
+ --ee-card-border: ${themeCfg.cardBorder};
+ --ee-card-shadow: ${themeCfg.cardShadow};
+ --ee-text-color: ${themeCfg.textColor};
+ --ee-heading-color: ${themeCfg.headingColor};
+ --ee-meta-color: ${themeCfg.metaColor};
+ --ee-meta-bg: ${themeCfg.metaBg};
+ --ee-meta-border: ${themeCfg.metaBorder};
+ --ee-accent: ${themeCfg.accentColor};
+ --ee-accent-subtle: ${themeCfg.accentSubtle};
+ --ee-link-bg: ${themeCfg.linkBg};
+ --ee-divider: ${themeCfg.dividerColor};
+ --ee-code-bg: ${themeCfg.codeBg};
+ --ee-code-border: ${themeCfg.codeBorder};
+ --ee-code-color: ${themeCfg.codeColor};
+ --ee-quote-bg: ${themeCfg.quoteBg};
+ --ee-quote-border: ${themeCfg.quoteBorder};
+ --ee-table-th-bg: ${themeCfg.tableThBg};
+ --ee-table-border: ${themeCfg.tableBorder};
+ --ee-brand-text: ${themeCfg.brandText};
+ --ee-brand-mark: ${themeCfg.brandMark};
+
+ --ee-font-family: ${fontFam};
+ --ee-base-size: ${sizeCfg.base};
+ --ee-line-height: ${sizeCfg.lineHeight};
+ --ee-title-size: ${sizeCfg.title};
+ --ee-h1-size: ${sizeCfg.h1};
+ --ee-h2-size: ${sizeCfg.h2};
+ --ee-h3-size: ${sizeCfg.h3};
+ --ee-meta-size: ${sizeCfg.meta};
+ --ee-code-size: ${sizeCfg.code};
+ }
+
+ * { box-sizing: border-box; }
+
+ .edgeever-image-wrapper {
+ width: ${widthPx}px;
+ padding: 38px 32px 44px;
+ background: var(--ee-canvas-bg);
+ font-family: var(--ee-font-family);
+ box-sizing: border-box;
+ margin: 0;
+ color: var(--ee-text-color);
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ }
+
+ .edgeever-image-card {
+ background: var(--ee-card-bg);
+ border: var(--ee-card-border);
+ border-radius: 20px;
+ box-shadow: var(--ee-card-shadow);
+ padding: 40px 38px 36px;
+ position: relative;
+ overflow: hidden;
+ }
+
+ .edgeever-terminal-header {
+ display: flex;
+ align-items: center;
+ gap: 7px;
+ padding: 12px 18px;
+ margin: -40px -38px 26px;
+ border-bottom: var(--ee-card-border);
+ background: var(--ee-meta-bg);
+ }
+ .edgeever-terminal-dot {
+ width: 10.5px;
+ height: 10.5px;
+ border-radius: 50%;
+ display: inline-block;
+ }
+ .dot-red { background: #ff5f56; }
+ .dot-yellow { background: #ffbd2e; }
+ .dot-green { background: #27c93f; }
+ .edgeever-terminal-name {
+ margin-left: 6px;
+ font-size: 12px;
+ color: var(--ee-meta-color);
+ font-family: inherit;
+ opacity: 0.9;
+ }
+
+ .edgeever-card-meta {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 8px;
+ margin-bottom: 16px;
+ }
+
+ .edgeever-meta-pill {
+ display: inline-flex;
+ align-items: center;
+ gap: 5.5px;
+ padding: 3.5px 10px;
+ border-radius: 9999px;
+ background: var(--ee-meta-bg);
+ border: 1px solid var(--ee-meta-border);
+ color: var(--ee-meta-color);
+ font-size: var(--ee-meta-size);
+ font-weight: 550;
+ line-height: 1.2;
+ }
+ .edgeever-icon {
+ display: inline-block;
+ vertical-align: middle;
+ stroke: currentColor;
+ }
+ .edgeever-meta-tag {
+ background: var(--ee-link-bg);
+ border-color: var(--ee-accent-subtle);
+ color: var(--ee-accent);
+ font-weight: 600;
+ }
+
+ .edgeever-card-title {
+ margin: 0 0 16px;
+ font-size: var(--ee-title-size);
+ font-weight: 780;
+ line-height: 1.25;
+ letter-spacing: -0.026em;
+ color: var(--ee-heading-color);
+ word-break: break-word;
+ }
+
+ .edgeever-card-divider {
+ height: 1px;
+ background: linear-gradient(90deg, var(--ee-divider) 0%, transparent 95%);
+ margin: 0 0 24px;
+ }
+
+ .edgeever-card-body {
+ font-size: var(--ee-base-size);
+ line-height: var(--ee-line-height);
+ color: var(--ee-text-color);
+ overflow-wrap: anywhere;
+ }
+
+ .edgeever-card-body > :first-child { margin-top: 0; }
+ .edgeever-card-body > :last-child { margin-bottom: 0; }
+
+ .edgeever-card-body h1,
+ .edgeever-card-body h2,
+ .edgeever-card-body h3 {
+ color: var(--ee-heading-color);
+ line-height: 1.28;
+ font-weight: 720;
+ letter-spacing: -0.015em;
+ }
+ .edgeever-card-body h1 {
+ font-size: var(--ee-h1-size);
+ margin: 1.6em 0 0.7em;
+ border-left: 3.5px solid var(--ee-accent);
+ padding-left: 10px;
+ margin-left: -13.5px;
+ }
+ .edgeever-card-body h2 { font-size: var(--ee-h2-size); margin: 1.4em 0 0.6em; }
+ .edgeever-card-body h3 { font-size: var(--ee-h3-size); margin: 1.2em 0 0.5em; }
+
+ .edgeever-card-body p { margin: 0 0 1em; }
+
+ .edgeever-card-body ul,
+ .edgeever-card-body ol {
+ margin: 0 0 1.1em;
+ padding-left: 1.5em;
+ }
+ .edgeever-card-body li { margin: 0.3em 0; }
+
+ .edgeever-card-body ul[data-type="taskList"] {
+ padding-left: 0;
+ list-style: none;
+ }
+ .edgeever-card-body ul[data-type="taskList"] li[data-checked] {
+ display: flex;
+ align-items: flex-start;
+ gap: 0.6rem;
+ margin: 0.4rem 0;
+ }
+ .edgeever-card-body ul[data-type="taskList"] li[data-checked="true"] {
+ opacity: 0.7;
+ text-decoration: line-through;
+ }
+ .edgeever-card-body ul[data-type="taskList"] li[data-checked] > label {
+ display: inline-flex;
+ flex: 0 0 auto;
+ margin-top: 0.2rem;
+ }
+ .edgeever-card-body ul[data-type="taskList"] li[data-checked] > label input {
+ width: 1.1rem;
+ height: 1.1rem;
+ margin: 0;
+ accent-color: var(--ee-accent);
+ }
+ .edgeever-card-body ul[data-type="taskList"] li[data-checked] > div {
+ min-width: 0;
+ flex: 1 1 auto;
+ }
+ .edgeever-card-body ul[data-type="taskList"] li[data-checked] > div > p {
+ margin-bottom: 0;
+ }
+
+ .edgeever-card-body blockquote {
+ margin: 1.3em 0;
+ border-left: 4px solid var(--ee-quote-border);
+ background: var(--ee-quote-bg);
+ padding: 12px 18px;
+ border-radius: 0 10px 10px 0;
+ color: var(--ee-text-color);
+ font-size: 0.98em;
+ line-height: 1.75;
+ }
+ .edgeever-card-body blockquote p:last-child { margin-bottom: 0; }
+
+ .edgeever-card-body hr {
+ margin: 1.8em 0;
+ border: 0;
+ border-top: 1px solid var(--ee-divider);
+ }
+
+ .edgeever-card-body a {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ color: var(--ee-accent);
+ text-decoration: none;
+ font-weight: 600;
+ background: var(--ee-link-bg);
+ border: 1px solid var(--ee-accent-subtle);
+ padding: 1.5px 8px;
+ border-radius: 6px;
+ line-height: 1.45;
+ vertical-align: baseline;
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
+ }
+
+ .edgeever-card-body code {
+ border-radius: 5px;
+ background: var(--ee-code-bg);
+ border: 1px solid var(--ee-code-border);
+ color: var(--ee-code-color);
+ padding: 2px 6px;
+ font-family: ui-monospace, "SF Mono", "JetBrains Mono", Consolas, monospace;
+ font-size: var(--ee-code-size);
+ }
+
+ .edgeever-card-body pre,
+ .edgeever-card-body .edgeever-code-source {
+ max-width: 100%;
+ margin: 1.3em 0;
+ border: 1px solid var(--ee-code-border);
+ border-radius: 10px;
+ background: var(--ee-code-bg);
+ padding: 14px 18px;
+ color: var(--ee-code-color);
+ font-family: ui-monospace, "SF Mono", "JetBrains Mono", Consolas, monospace;
+ font-size: var(--ee-code-size);
+ line-height: 1.6;
+ overflow-x: auto;
+ overflow-wrap: anywhere;
+ white-space: pre-wrap;
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
+ }
+
+ .edgeever-card-body pre code {
+ background: transparent;
+ border: 0;
+ padding: 0;
+ color: inherit;
+ }
+
+ .edgeever-card-body img,
+ .edgeever-card-body .edgeever-html-mermaid svg {
+ display: block;
+ width: auto;
+ max-width: 100%;
+ height: auto;
+ max-height: 80vh;
+ border-radius: 10px;
+ margin: 1.3em auto;
+ object-fit: contain;
+ }
+
+ .edgeever-card-body figure,
+ .edgeever-card-body .edgeever-html-mermaid {
+ max-width: 100%;
+ margin: 1.3em auto;
+ }
+
+ .edgeever-card-body table {
+ width: 100%;
+ margin: 1.4em 0;
+ border-collapse: separate;
+ border-spacing: 0;
+ border-radius: 8px;
+ overflow: hidden;
+ border: 1px solid var(--ee-table-border);
+ font-size: calc(var(--ee-base-size) * 0.92);
+ line-height: 1.5;
+ }
+
+ .edgeever-card-body th,
+ .edgeever-card-body td {
+ padding: 9px 13px;
+ text-align: left;
+ vertical-align: top;
+ border-bottom: 1px solid var(--ee-table-border);
+ border-right: 1px solid var(--ee-table-border);
+ }
+
+ .edgeever-card-body th {
+ background: var(--ee-table-th-bg);
+ color: var(--ee-heading-color);
+ font-weight: 650;
+ }
+
+ .edgeever-card-body tr:last-child td { border-bottom: 0; }
+ .edgeever-card-body td:last-child,
+ .edgeever-card-body th:last-child { border-right: 0; }
+
+ .edgeever-card-body [data-edgeever-theme-block] {
+ margin: 1.3em 0;
+ border: 1px solid var(--ee-meta-border);
+ border-left: 4px solid var(--ee-accent);
+ border-radius: 10px;
+ background: var(--ee-meta-bg);
+ padding: 12px 16px;
+ }
+
+ .edgeever-card-body .edgeever-image-controls,
+ .edgeever-card-body .edgeever-code-copy-button,
+ .edgeever-card-body .edgeever-theme-block__toolbar,
+ .edgeever-card-body .edgeever-mermaid-source {
+ display: none !important;
+ }
+
+ .edgeever-card-footer {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ margin-top: 36px;
+ border-top: 1px solid var(--ee-divider);
+ padding-top: 22px;
+ }
+
+ .edgeever-card-footer-meta {
+ font-size: 12px;
+ color: var(--ee-meta-color);
+ font-weight: 500;
+ opacity: 0.85;
+ }
+
+ .edgeever-brand-badge {
+ display: inline-flex;
+ align-items: center;
+ gap: 7.5px;
+ font-size: 13px;
+ font-weight: 650;
+ color: var(--ee-brand-text);
+ opacity: 0.95;
+ }
+
+ .edgeever-brand-logo {
+ display: inline-block;
+ vertical-align: middle;
+ border-radius: 5px;
+ }
+
+ .edgeever-brand-name {
+ font-weight: 760;
+ letter-spacing: -0.01em;
+ color: var(--ee-brand-text);
+ }
+
+ ${theme === "notepad" ? `
+ .edgeever-image-card[data-theme="notepad"] .edgeever-card-body p,
+ .edgeever-image-card[data-theme="notepad"] .edgeever-card-body li {
+ background-image: linear-gradient(to bottom, transparent calc(100% - 1px), #e8decb calc(100% - 1px));
+ background-size: 100% 1.86em;
+ background-position: 0 0.15em;
+ }
+ .edgeever-card-tear-strip {
+ height: 8px;
+ background-image: radial-gradient(circle at 50% 0, transparent 4px, var(--ee-card-bg) 4.5px);
+ background-size: 14px 8px;
+ background-repeat: repeat-x;
+ margin: -24px -28px 16px -28px;
+ opacity: 0.9;
+ }
+ ` : ""}
+ `;
+};
+
const canvasToImageBlob = (canvas: HTMLCanvasElement, format: NoteImageFormat) =>
new Promise<Blob>((resolve, reject) => {
canvas.toBlob(
- (blob) => blob ? resolve(blob) : reject(new Error("Image renderer returned an empty file")),
+ (blob) => (blob ? resolve(blob) : reject(new Error("Image renderer returned an empty file"))),
format === "jpeg" ? "image/jpeg" : "image/png",
- format === "jpeg" ? 0.9 : 1,
+ format === "jpeg" ? 0.92 : 1,
);
});
@@ -79,17 +889,19 @@ export const downloadPreparedNoteImage = ({ blob, filename }: Pick<PreparedNoteI
};
const waitForImages = async (root: HTMLElement) => {
- await Promise.all(Array.from(root.querySelectorAll("img")).map(async (image) => {
- if (image.complete) return;
- try {
- await image.decode();
- } catch {
- // The HTML preparation stage reports resources that could not be embedded.
- }
- }));
+ await Promise.all(
+ Array.from(root.querySelectorAll("img")).map(async (image) => {
+ if (image.complete) return;
+ try {
+ await image.decode();
+ } catch {
+ // The HTML preparation stage reports resources that could not be embedded.
+ }
+ }),
+ );
};
-const renderImage = async (source: HTMLElement, format: NoteImageFormat, backgroundColor: string) => {
+const renderImage = async (source: HTMLElement, format: NoteImageFormat, backgroundColor: string, targetWidth: number) => {
await document.fonts?.ready;
await waitForImages(source);
const totalHeight = Math.max(1, Math.ceil(source.getBoundingClientRect().height));
@@ -99,58 +911,77 @@ const renderImage = async (source: HTMLElement, format: NoteImageFormat, backgro
height: totalHeight,
pixelRatio: NOTE_IMAGE_EXPORT_PIXEL_RATIO,
skipFonts: true,
- width: NOTE_IMAGE_EXPORT_WIDTH,
+ width: targetWidth,
});
return { blob: await canvasToImageBlob(canvas, format), height: canvas.height, width: canvas.width };
};
export const createNoteImage = async ({
bodyHtml,
- branding = false,
+ branding = true,
title,
notebook,
tags,
updatedAt,
fallbackTitle,
format,
- background = "slate",
+ background,
+ theme,
+ fontStyle = "serif",
+ fontSize = "lg",
+ cardWidth = "standard",
+ showTitle = true,
+ showNotebook = false,
+ showTags = false,
+ showUpdatedAt = true,
styles,
}: DownloadNoteImageOptions): Promise<PreparedNoteImage> => {
+ const resolvedTheme = resolveTheme(background, theme);
+ const targetWidth = NOTE_IMAGE_CARD_WIDTH_PIXELS[cardWidth] || 680;
+ const themeCfg = NOTE_IMAGE_THEMES[resolvedTheme];
+
const prepared = await prepareNoteBodyHtmlForExport(bodyHtml);
const host = document.createElement("div");
host.style.cssText = [
"position:fixed",
"left:-100000px",
"top:0",
- `width:${NOTE_IMAGE_EXPORT_WIDTH}px`,
+ `width:${targetWidth}px`,
"pointer-events:none",
].join(";");
+
const style = document.createElement("style");
- style.textContent = `${styles}\n${NOTE_IMAGE_SHARE_STYLES}`;
+ style.textContent = `${styles}\n${generateCardCss({ theme: resolvedTheme, fontStyle, fontSize, cardWidth })}`;
host.appendChild(style);
- host.insertAdjacentHTML("beforeend", buildNoteHtmlContentMarkup({
- title,
- notebook,
- tags,
- updatedAt,
- bodyHtml: prepared.bodyHtml,
- }));
+
+ host.insertAdjacentHTML(
+ "beforeend",
+ buildNoteImageCardMarkup({
+ title,
+ notebook,
+ tags,
+ updatedAt,
+ bodyHtml: prepared.bodyHtml,
+ theme: resolvedTheme,
+ fontStyle,
+ showTitle,
+ showNotebook,
+ showTags,
+ showUpdatedAt,
+ showBranding: branding,
+ }),
+ );
+
const source = host.lastElementChild as HTMLElement;
- source.classList.add("edgeever-image-share");
- if (branding) {
- const footer = document.createElement("footer");
- footer.className = "edgeever-image-brand";
- footer.innerHTML = '<span class="edgeever-image-brand-mark"></span><span>Made with <span class="edgeever-image-brand-name">EdgeEver</span></span>';
- source.querySelector(".edgeever-html-document")?.appendChild(footer);
- }
- source.style.width = `${NOTE_IMAGE_EXPORT_WIDTH}px`;
+ source.style.width = `${targetWidth}px`;
source.style.maxWidth = "none";
source.style.margin = "0";
- source.style.backgroundColor = NOTE_IMAGE_BACKGROUND_COLORS[background];
+
document.body.appendChild(host);
try {
- const image = await renderImage(source, format, NOTE_IMAGE_BACKGROUND_COLORS[background]);
+ const canvasBgColor = NOTE_IMAGE_BACKGROUND_COLORS[resolvedTheme] || themeCfg.canvasBg;
+ const image = await renderImage(source, format, canvasBgColor, targetWidth);
const basename = buildImageExportBasename(title, fallbackTitle);
const extension = format === "jpeg" ? "jpg" : "png";
const filename = `${basename}.${extension}`;
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index d440552a..cea8a531 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -1019,27 +1019,60 @@ export const enUS = {
},
imageShare: {
title: "Share as image",
- description: "Preview the complete long image and choose what information to include.",
+ description: "Generate a beautiful share card with customizable themes, typography, and layout.",
previewAlt: "Note image share preview",
generating: "Generating preview…",
+ theme: "Theme",
background: "Background",
+ themes: {
+ slate: "Classic Light",
+ aurora: "Aurora",
+ sunset: "Sunset",
+ midnight: "Midnight",
+ mint: "Mint",
+ lavender: "Lavender",
+ notepad: "Classic Notepad",
+ xuan: "Rice Paper",
+ },
backgrounds: {
slate: "Clean",
mint: "Mint",
warm: "Warm",
},
- metadata: "Note information",
+ fontStyle: "Typography",
+ fontStyles: {
+ sans: "Modern Sans",
+ serif: "Editorial Serif",
+ mono: "Geek Mono",
+ },
+ fontSize: "Font Size",
+ fontSizes: {
+ sm: "Compact",
+ md: "Standard",
+ lg: "Comfortable",
+ },
+ cardWidth: "Card Width",
+ cardWidths: {
+ compact: "Compact (560px)",
+ standard: "Standard (680px)",
+ wide: "Wide (800px)",
+ },
+ metadata: "Content Elements",
fields: {
+ title: "Title",
notebook: "Notebook",
tags: "Tags",
updatedAt: "Updated time",
branding: "EdgeEver branding",
},
- format: "Image format",
- pngHint: "best for text",
- jpegHint: "smaller file",
- share: "Share image",
- download: "Download image",
+ format: "Image Format",
+ pngHint: "lossless · crisp text",
+ jpegHint: "compressed · smaller file",
+ share: "Share",
+ download: "Download",
+ copyImage: "Copy Image",
+ copied: "Copied to clipboard",
+ copyFailed: "Copy failed, please download instead",
action: "Share as image",
longImageWarning: "This image is very long. Some social platforms may compress it; keep the downloaded original for best quality.",
},
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index 110f200b..2985ed66 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -1017,27 +1017,60 @@ export const zhCN = {
},
imageShare: {
title: "分享为图片",
- description: "预览完整长图,并选择图片中包含的笔记信息。",
+ description: "生成精美分享卡片,自定义主题、字体与版式。",
previewAlt: "笔记分享图片预览",
generating: "正在生成预览…",
+ theme: "主题风格",
background: "背景",
+ themes: {
+ slate: "经典浅色",
+ aurora: "极光渐变",
+ sunset: "暮色晚霞",
+ midnight: "暗夜曜石",
+ mint: "薄荷",
+ lavender: "紫雾流光",
+ notepad: "经典便签",
+ xuan: "水墨宣纸",
+ },
backgrounds: {
slate: "简洁",
mint: "薄荷",
warm: "暖色",
},
- metadata: "笔记信息",
+ fontStyle: "字体风格",
+ fontStyles: {
+ sans: "现代无衬线",
+ serif: "文艺衬线",
+ mono: "极客等宽",
+ },
+ fontSize: "字号大小",
+ fontSizes: {
+ sm: "紧凑",
+ md: "标准",
+ lg: "舒适",
+ },
+ cardWidth: "卡片宽度",
+ cardWidths: {
+ compact: "紧凑 (560px)",
+ standard: "标准 (680px)",
+ wide: "宽屏 (800px)",
+ },
+ metadata: "显示内容",
fields: {
+ title: "笔记标题",
notebook: "笔记本",
tags: "标签",
updatedAt: "更新时间",
branding: "EdgeEver 品牌标识",
},
format: "图片格式",
- pngHint: "文字更清晰",
- jpegHint: "文件更小",
- share: "分享图片",
+ pngHint: "超清无损 · 文字清晰",
+ jpegHint: "高压缩比 · 体积小",
+ share: "系统分享",
download: "下载图片",
+ copyImage: "复制图片",
+ copied: "已复制到剪贴板",
+ copyFailed: "复制失败,请尝试下载",
action: "分享为图片",
longImageWarning: "图片较长,部分社交平台可能会压缩画质;建议保留下载的原图。",
},