feat: 建立 DOCX 共享协议与准备服务
This commit is contained in:
@@ -9,12 +9,14 @@
|
||||
src/
|
||||
document.ts Markdown 文档、分页载荷、结果与耗时模型
|
||||
document-link.ts 跨端链接分类与 PDF 本地链接编码协议
|
||||
docx.ts DOCX 请求、能力、错误、结果与文件名协议
|
||||
export-config.ts 纸张、边距、页眉页脚、页码与图表配置
|
||||
theme.ts 主题清单、主题能力与 CSS 载荷模型
|
||||
index.ts 公共导出入口
|
||||
tests/
|
||||
document.test.ts
|
||||
document-link.test.ts
|
||||
docx.test.ts
|
||||
export-config.test.ts
|
||||
```
|
||||
|
||||
@@ -23,13 +25,20 @@ tests/
|
||||
```ts
|
||||
import {
|
||||
classifyDocumentLink,
|
||||
createDocxFileName,
|
||||
createPagedDocumentPayload,
|
||||
defaultExportConfig,
|
||||
docxExportRequestSchema,
|
||||
exportConfigSchema
|
||||
} from "@md-to-pdf/core";
|
||||
|
||||
const link = classifyDocumentLink("../docs/example.md");
|
||||
const config = exportConfigSchema.parse(defaultExportConfig);
|
||||
const docxRequest = docxExportRequestSchema.parse({
|
||||
markdown: "# Example",
|
||||
exportConfig: config
|
||||
});
|
||||
const docxFileName = createDocxFileName("example.md");
|
||||
const payload = createPagedDocumentPayload({
|
||||
document,
|
||||
fileName: "example.md",
|
||||
@@ -38,6 +47,10 @@ const payload = createPagedDocumentPayload({
|
||||
});
|
||||
```
|
||||
|
||||
DOCX 协议固定 Pandoc `3.9.0.2`,并统一定义跨 HTTP/IPC 使用的请求、
|
||||
capability、错误码、结果、诊断和耗时类型。该包只描述数据协议,不启动
|
||||
Pandoc 或读写临时文件。
|
||||
|
||||
`classifyDocumentLink()` 只负责稳定分类,不执行平台动作。Web 根据分类
|
||||
处理锚点和网络链接;Desktop 决定是否调用浏览器、系统程序或打开新的
|
||||
Markdown 窗口。精确 PDF 使用保留的 `.invalid` 地址暂存本地链接,
|
||||
|
||||
Reference in New Issue
Block a user