feat: 实现 DOCX 可编辑字体嵌入

This commit is contained in:
SkyJourney
2026-07-31 16:18:30 +08:00
parent f3847f3e4b
commit 10bc62cee4
32 changed files with 2195 additions and 76 deletions
@@ -8,6 +8,7 @@ import {
type RenderedMarkdownDocument,
type ThemeManifest
} from "@md-to-pdf/core";
import type { DocxFontSource } from "@md-to-pdf/docx-engine";
import {
createThemeRegistry,
type ThemeRegistryOptions
@@ -48,6 +49,7 @@ export interface PreparedDocxExport {
manifest: ThemeManifest;
source: "bundled" | "local";
css: string;
fonts: DocxFontSource[];
};
}
@@ -186,11 +188,12 @@ export function createApplicationService(
);
}
const [document, themeCss] = await Promise.all([
const [document, themeCss, themeFonts] = await Promise.all([
render(parsed.data, context),
themes.getCss(theme.manifest.id)
themes.getCss(theme.manifest.id),
themes.getDocxFonts(theme.manifest.id)
]);
if (themeCss === undefined) {
if (themeCss === undefined || themeFonts === undefined) {
throw new ApplicationRequestError(
404,
"THEME_NOT_FOUND",
@@ -204,7 +207,8 @@ export function createApplicationService(
theme: {
manifest: theme.manifest,
source: theme.source,
css: themeCss
css: themeCss,
fonts: themeFonts
}
};
}