feat: 实现 DOCX 媒体预处理与跨端 PNG 捕获
This commit is contained in:
@@ -63,6 +63,11 @@ export interface PagedDocumentRenderOptions {
|
||||
mermaidOutput?: MermaidOutputMode;
|
||||
}
|
||||
|
||||
export interface ContinuousDocumentRenderOptions {
|
||||
shouldContinue?: () => boolean;
|
||||
geometryCss?: string;
|
||||
}
|
||||
|
||||
export interface PreviewEngineStyles {
|
||||
highlightCss: string;
|
||||
katexCss: string;
|
||||
@@ -415,7 +420,8 @@ export class PagedDocumentRuntime {
|
||||
|
||||
private applyContinuousStyles(
|
||||
documentRef: Document,
|
||||
payload: PagedPreviewPayload
|
||||
payload: PagedPreviewPayload,
|
||||
geometryCss = ""
|
||||
) {
|
||||
const style =
|
||||
this.continuousStyle ?? documentRef.createElement("style");
|
||||
@@ -427,7 +433,8 @@ export class PagedDocumentRuntime {
|
||||
this.styles.echartsCss,
|
||||
enablePrintMediaForPreview(payload.themeCss),
|
||||
documentInteractionCss,
|
||||
continuousDocumentGeometryCss
|
||||
continuousDocumentGeometryCss,
|
||||
geometryCss
|
||||
].join("\n");
|
||||
if (!style.isConnected) {
|
||||
documentRef.head.append(style);
|
||||
@@ -930,10 +937,7 @@ export class PagedDocumentRuntime {
|
||||
|
||||
async renderContinuous(
|
||||
payload: PagedPreviewPayload,
|
||||
options: Pick<
|
||||
PagedDocumentRenderOptions,
|
||||
"shouldContinue"
|
||||
> = {}
|
||||
options: ContinuousDocumentRenderOptions = {}
|
||||
): Promise<PagedDocumentRenderResult | undefined> {
|
||||
const totalStartedAt = performance.now();
|
||||
const shouldContinue = options.shouldContinue ?? (() => true);
|
||||
@@ -950,7 +954,11 @@ export class PagedDocumentRuntime {
|
||||
payload.metadata.language || "zh-CN";
|
||||
documentRef.title =
|
||||
payload.metadata.title || "Markdown 连续预览";
|
||||
this.applyContinuousStyles(documentRef, payload);
|
||||
this.applyContinuousStyles(
|
||||
documentRef,
|
||||
payload,
|
||||
options.geometryCss
|
||||
);
|
||||
|
||||
const template = documentRef.createElement("template");
|
||||
template.innerHTML = payload.articleHtml;
|
||||
@@ -963,7 +971,8 @@ export class PagedDocumentRuntime {
|
||||
const nextSignatures = nextNodes.map(createNodeSignature);
|
||||
const identity = JSON.stringify({
|
||||
themeCss: payload.themeCss,
|
||||
mermaid: payload.exportConfig.mermaid
|
||||
mermaid: payload.exportConfig.mermaid,
|
||||
geometryCss: options.geometryCss
|
||||
});
|
||||
const currentArticle =
|
||||
this.root.querySelector<HTMLElement>(":scope > #write");
|
||||
|
||||
Reference in New Issue
Block a user