@vervedoc/core 3.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +405 -0
  3. package/dist/DocxEditor.d.ts +17 -0
  4. package/dist/actuator/Actuator.d.ts +22 -0
  5. package/dist/assets/runtime.worker-BUGfHnel.js.map +1 -0
  6. package/dist/core.js +3997 -0
  7. package/dist/core.js.map +1 -0
  8. package/dist/core.umd.cjs +135 -0
  9. package/dist/core.umd.cjs.map +1 -0
  10. package/dist/docxParser/constants.d.ts +42 -0
  11. package/dist/docxParser/docx.parser.d.ts +13 -0
  12. package/dist/docxParser/index.d.ts +13 -0
  13. package/dist/docxParser/types.d.ts +170 -0
  14. package/dist/docxParser/worker/builder/element.builder.d.ts +6 -0
  15. package/dist/docxParser/worker/docx.parse.worker.d.ts +1 -0
  16. package/dist/docxParser/worker/numbering.resolver.d.ts +29 -0
  17. package/dist/docxParser/worker/parsers/chart.parser.d.ts +16 -0
  18. package/dist/docxParser/worker/parsers/comment.parser.d.ts +5 -0
  19. package/dist/docxParser/worker/parsers/hyperlink.parser.d.ts +14 -0
  20. package/dist/docxParser/worker/parsers/image.parser.d.ts +12 -0
  21. package/dist/docxParser/worker/parsers/list.parser.d.ts +6 -0
  22. package/dist/docxParser/worker/parsers/ooxml.chart.parser.d.ts +4 -0
  23. package/dist/docxParser/worker/parsers/paragraph.parser.d.ts +10 -0
  24. package/dist/docxParser/worker/parsers/run.parser.d.ts +22 -0
  25. package/dist/docxParser/worker/parsers/section.parser.d.ts +20 -0
  26. package/dist/docxParser/worker/parsers/table.parser.d.ts +11 -0
  27. package/dist/docxParser/worker/parsers/toc.parser.d.ts +13 -0
  28. package/dist/docxParser/worker/relationship.resolver.d.ts +17 -0
  29. package/dist/docxParser/worker/style.resolver.d.ts +33 -0
  30. package/dist/docxParser/worker/theme.resolver.d.ts +21 -0
  31. package/dist/docxParser/worker/xml.helper.d.ts +36 -0
  32. package/dist/export/ExportComponent.d.ts +9 -0
  33. package/dist/i18n/I18n.d.ts +8 -0
  34. package/dist/index-OrDfS8Mp.js +16762 -0
  35. package/dist/index-OrDfS8Mp.js.map +1 -0
  36. package/dist/index.d.ts +26 -0
  37. package/dist/table-contextmenu/TableContextMenu.d.ts +48 -0
  38. package/dist/table-contextmenu/TableContextMenuComponent.d.ts +7 -0
  39. package/dist/utils/clipboard.d.ts +11 -0
  40. package/dist/utils/print.d.ts +7 -0
  41. package/dist/worker/WorkerComponent.d.ts +8 -0
  42. package/dist/worker/WorkerManager.d.ts +21 -0
  43. package/dist/worker/WorkerMessage.d.ts +21 -0
  44. package/dist/worker/runtime.worker.d.ts +1 -0
  45. package/package.json +60 -0
@@ -0,0 +1,42 @@
1
+ export declare const NS: {
2
+ readonly w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
3
+ readonly r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
4
+ readonly a: "http://schemas.openxmlformats.org/drawingml/2006/main";
5
+ readonly wp: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
6
+ readonly c: "http://schemas.openxmlformats.org/drawingml/2006/chart";
7
+ readonly v: "urn:schemas-microsoft-com:vml";
8
+ readonly pic: "http://schemas.openxmlformats.org/drawingml/2006/picture";
9
+ readonly mc: "http://schemas.openxmlformats.org/markup-compatibility/2006";
10
+ readonly wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
11
+ readonly rel: "http://schemas.openxmlformats.org/package/2006/relationships";
12
+ readonly m: "http://schemas.openxmlformats.org/officeDocument/2006/math";
13
+ };
14
+ /** Twip(1/1440 英寸)转 px(96dpi) */
15
+ export declare function twipToPx(twip: number): number;
16
+ /** 半磅转磅(字号:Word sz 值 / 2) */
17
+ export declare function halfPtToPt(halfPt: number): number;
18
+ /**
19
+ * 半磅转像素(Word sz 单位 → canvas px,96dpi)
20
+ * Word sz = 半磅,pt = sz/2,px = pt × 96/72
21
+ * 即 px = sz × (96 / 144) = sz × (2/3)
22
+ */
23
+ export declare function halfPtToPx(halfPt: number): number;
24
+ /** EMU 转 px(1 英寸 = 914400 EMU = 96px) */
25
+ export declare function emuToPx(emu: number): number;
26
+ /** 八分之一磅转 px(边框宽度) */
27
+ export declare function eighthPtToPx(val: number): number;
28
+ /** Word 高亮颜色名 → CSS hex */
29
+ export declare const HIGHLIGHT_COLOR_MAP: Record<string, string>;
30
+ export declare function normalizeFont(rawFontName: string | undefined): string | undefined;
31
+ export declare const NUM_FMT_MAP: Record<string, {
32
+ listType: string;
33
+ listStyle: string;
34
+ }>;
35
+ export declare const ALIGNMENT_MAP: Record<string, string>;
36
+ export declare const BORDER_TYPE_MAP: Record<string, number>;
37
+ /**
38
+ * OOXML 中 themeFill / themeColor 可能使用语义名(如 background1),
39
+ * 需映射到 clrScheme 中的实际槽位名(如 lt1)
40
+ */
41
+ export declare const THEME_COLOR_SEMANTIC_MAP: Record<string, string>;
42
+ export declare const TRANSPARENT_1PX_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==";
@@ -0,0 +1,13 @@
1
+ import { IDocxParseResult, IDocxParseOptions } from './types';
2
+ export declare class DocxParser {
3
+ private options;
4
+ constructor(options?: IDocxParseOptions);
5
+ parse(arrayBuffer: ArrayBuffer): Promise<IDocxParseResult>;
6
+ parseFromFile(file: File): Promise<IDocxParseResult>;
7
+ private parseDocumentSync;
8
+ private readZipEntry;
9
+ private extractMediaFiles;
10
+ private extractChartRelFiles;
11
+ private extractChartXmlFiles;
12
+ private getMergedOptions;
13
+ }
@@ -0,0 +1,13 @@
1
+ import { DocxParser } from './docx.parser';
2
+ import { IDocxParseOptions, IDocxParseResult } from './types';
3
+ export type { IDocxParseResult, IDocxParseOptions } from './types';
4
+ export { DocxParser } from './docx.parser';
5
+ /**
6
+ * 创建解析器实例的工厂函数
7
+ */
8
+ export declare function createDocxParser(options?: IDocxParseOptions): DocxParser;
9
+ /**
10
+ * 快捷解析函数(保持与旧 API 兼容)
11
+ */
12
+ export declare function parseDocx(data: ArrayBuffer | File, options?: IDocxParseOptions): Promise<IDocxParseResult>;
13
+ export default DocxParser;
@@ -0,0 +1,170 @@
1
+ import { IElement } from '@vervedoc/docx-editor-schema';
2
+ export interface IDocxParseResult {
3
+ success: boolean;
4
+ elements: IElement[];
5
+ comments?: DocxCommentMeta[];
6
+ html?: string;
7
+ error?: string;
8
+ }
9
+ export interface IChartRenderer {
10
+ renderToDataUrl(option: unknown, width: number, height: number, pixelRatio?: number): string;
11
+ }
12
+ export interface IDocxParseOptions {
13
+ preserveStyles?: boolean;
14
+ defaultFont?: string;
15
+ defaultSize?: number;
16
+ targetInnerWidth?: number;
17
+ tableWidthMode?: 'fit' | 'word';
18
+ defaultTableRowHeight?: number;
19
+ defaultTableTdPadding?: [number, number, number, number];
20
+ forceDefaultLineHeight?: number;
21
+ chartRenderer?: IChartRenderer;
22
+ }
23
+ export declare const DEFAULT_OPTIONS: Required<Pick<IDocxParseOptions, 'preserveStyles' | 'defaultFont' | 'defaultSize' | 'tableWidthMode' | 'defaultTableRowHeight' | 'forceDefaultLineHeight'>> & {
24
+ defaultTableTdPadding: [number, number, number, number];
25
+ };
26
+ export interface IWorkerRequest {
27
+ documentXml: string;
28
+ stylesXml: string | null;
29
+ numberingXml: string | null;
30
+ themeXml: string | null;
31
+ documentRels: string | null;
32
+ commentsXml: string | null;
33
+ chartRelsMap: Record<string, string>;
34
+ chartXmlMap: Record<string, string>;
35
+ mediaMap: Record<string, string>;
36
+ options: IDocxParseOptions;
37
+ }
38
+ export interface IWorkerResponse {
39
+ success: boolean;
40
+ elements: IElement[];
41
+ error?: string;
42
+ }
43
+ export type DocNode = ParagraphNode | TableNode | ColumnNode;
44
+ export interface ParagraphNode {
45
+ type: 'paragraph';
46
+ chunks: InlineChunk[];
47
+ style: ParagraphStyle;
48
+ }
49
+ export interface TableNode {
50
+ type: 'table';
51
+ rows: TableRowNode[];
52
+ colWidths: number[];
53
+ borderType?: string;
54
+ borderColor?: string;
55
+ borderWidth?: number;
56
+ }
57
+ export interface ColumnNode {
58
+ type: 'column';
59
+ columns: number;
60
+ colWidths: number[];
61
+ colSpace: number;
62
+ separator: boolean;
63
+ groups: ParagraphNode[][];
64
+ }
65
+ export interface TableRowNode {
66
+ height?: number;
67
+ cells: TableCellNode[];
68
+ }
69
+ export interface TableCellNode {
70
+ paragraphs: ParagraphNode[];
71
+ colspan: number;
72
+ rowspan: number;
73
+ backgroundColor?: string;
74
+ verticalAlign?: string;
75
+ borderTypes?: number[];
76
+ borderStyle?: string;
77
+ width?: number;
78
+ }
79
+ export interface ParagraphStyle {
80
+ rowFlex?: string;
81
+ spacingBefore?: number;
82
+ spacingAfter?: number;
83
+ lineHeight?: number;
84
+ /** 行高规则:auto=倍率, exact=精确值(px), atLeast=最小值(px) */
85
+ lineHeightRule?: 'auto' | 'exact' | 'atLeast';
86
+ indentLeft?: number;
87
+ indentRight?: number;
88
+ firstLineIndent?: number;
89
+ paragraphColor?: string;
90
+ titleLevel?: number;
91
+ listType?: string;
92
+ listStyle?: string;
93
+ listLevel?: number;
94
+ numId?: string;
95
+ /** 制表符停止位 */
96
+ tabStops?: Array<{
97
+ pos: number;
98
+ type: string;
99
+ }>;
100
+ }
101
+ export type InlineChunk = TextChunk | ImageChunk | HyperlinkChunk | BreakChunk | TabChunk | BookmarkChunk | CommentMarkerChunk;
102
+ export interface TextChunk {
103
+ type: 'text';
104
+ value: string;
105
+ style: RunStyle;
106
+ revision?: {
107
+ id: string;
108
+ type: 'insert' | 'delete';
109
+ author: string;
110
+ date: string;
111
+ };
112
+ }
113
+ export interface ImageChunk {
114
+ type: 'image';
115
+ src: string;
116
+ width: number;
117
+ height: number;
118
+ display?: string;
119
+ floatPosition?: {
120
+ x: number;
121
+ y: number;
122
+ };
123
+ }
124
+ export interface HyperlinkChunk {
125
+ type: 'hyperlink';
126
+ url: string;
127
+ children: TextChunk[];
128
+ }
129
+ export interface BreakChunk {
130
+ type: 'break';
131
+ breakType: 'line' | 'page' | 'column';
132
+ }
133
+ export interface TabChunk {
134
+ type: 'tab';
135
+ }
136
+ export interface BookmarkChunk {
137
+ type: 'bookmark';
138
+ name: string;
139
+ }
140
+ export interface CommentMarkerChunk {
141
+ type: 'commentMarker';
142
+ markType: 'start' | 'end';
143
+ commentId: string;
144
+ }
145
+ export interface RunStyle {
146
+ bold?: boolean;
147
+ italic?: boolean;
148
+ underline?: boolean;
149
+ strikeout?: boolean;
150
+ font?: string;
151
+ size?: number;
152
+ color?: string;
153
+ highlight?: string;
154
+ letterSpacing?: number;
155
+ vertAlign?: 'superscript' | 'subscript';
156
+ textDecoration?: {
157
+ style: string;
158
+ };
159
+ }
160
+ export interface ResolvedStyle {
161
+ paragraph: ParagraphStyle;
162
+ run: RunStyle;
163
+ }
164
+ export interface DocxCommentMeta {
165
+ id: string;
166
+ author: string;
167
+ date: string;
168
+ initials?: string;
169
+ content: string;
170
+ }
@@ -0,0 +1,6 @@
1
+ import { IElement } from '@vervedoc/docx-editor-schema';
2
+ import { DocNode, IDocxParseOptions, DocxCommentMeta } from '../../types';
3
+ /**
4
+ * 将中间表示 DocNode[] 转换为编辑器 IElement[]
5
+ */
6
+ export declare function buildElements(nodes: DocNode[], options: IDocxParseOptions, _commentMetas?: Map<string, DocxCommentMeta>): IElement[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ export interface NumberingInfo {
2
+ listType: string;
3
+ listStyle: string;
4
+ level: number;
5
+ indentLeft?: number;
6
+ indentHanging?: number;
7
+ }
8
+ /**
9
+ * 列表编号解析器:解析 word/numbering.xml
10
+ *
11
+ * 支持:
12
+ * - <w:abstractNum>:抽象编号定义(含各级格式)
13
+ * - <w:num>:具体编号实例(引用 abstractNum)
14
+ * - <w:lvlOverride>:级别覆盖(如 startOverride 重置起始值)
15
+ */
16
+ export declare class NumberingResolver {
17
+ private abstractNums;
18
+ private numRefs;
19
+ constructor(numberingXml: string | null);
20
+ /**
21
+ * 根据 numId 和列表层级解析编号信息
22
+ * 返回 null 表示找不到对应定义
23
+ */
24
+ resolve(numId: string, level: number): NumberingInfo | null;
25
+ private parseNumberingXml;
26
+ private parseAbstractNums;
27
+ private parseNumReferences;
28
+ private mapLevelToInfo;
29
+ }
@@ -0,0 +1,16 @@
1
+ import { ImageChunk } from '../../types';
2
+ import { RelationshipEntry } from '../relationship.resolver';
3
+ /**
4
+ * 从 <w:drawing> 中提取图表预览图
5
+ *
6
+ * 策略:
7
+ * 1. 检测 <c:chart r:id="rIdX"/>
8
+ * 2. 查找图表 .rels 文件中的预览图
9
+ * 3. 回退到 <a:blipFill> 缓存图片
10
+ * 4. 无预览图则返回 null
11
+ */
12
+ export declare function parseChart(drawingEl: Element, documentRels: Map<string, RelationshipEntry>, chartRelsMap: Record<string, string>, mediaMap: Record<string, string>): ImageChunk | null;
13
+ /**
14
+ * 检测 drawing 中是否包含图表
15
+ */
16
+ export declare function isChartDrawing(drawingEl: Element): boolean;
@@ -0,0 +1,5 @@
1
+ import { DocxCommentMeta } from '../../types';
2
+ /**
3
+ * 解析 word/comments.xml,返回 commentId → DocxCommentMeta 映射
4
+ */
5
+ export declare function parseComments(commentsXml: string | null): Map<string, DocxCommentMeta>;
@@ -0,0 +1,14 @@
1
+ import { HyperlinkChunk, RunStyle } from '../../types';
2
+ import { StyleResolver } from '../style.resolver';
3
+ import { ThemeData } from '../theme.resolver';
4
+ import { RelationshipEntry } from '../relationship.resolver';
5
+ /**
6
+ * 解析 <w:hyperlink> 元素
7
+ *
8
+ * 支持:
9
+ * - 外部链接(r:id → rels 中的目标 URL)
10
+ * - 内部书签锚点(w:anchor → "#anchorName")
11
+ *
12
+ * 默认样式:rPr 未明确设置颜色时使用超链接蓝色,未明确设置下划线时添加下划线
13
+ */
14
+ export declare function parseHyperlink(hyperlinkEl: Element, styleResolver: StyleResolver, theme: ThemeData, baseRunStyle: RunStyle, rels: Map<string, RelationshipEntry>): HyperlinkChunk | null;
@@ -0,0 +1,12 @@
1
+ import { ImageChunk } from '../../types';
2
+ import { RelationshipEntry } from '../relationship.resolver';
3
+ export interface PageMargins {
4
+ top: number;
5
+ bottom: number;
6
+ left: number;
7
+ right: number;
8
+ }
9
+ /**
10
+ * 解析 <w:drawing> 元素
11
+ */
12
+ export declare function parseImage(drawingEl: Element, rels: Map<string, RelationshipEntry>, mediaMap: Record<string, string>, pageMargins?: PageMargins): ImageChunk | null;
@@ -0,0 +1,6 @@
1
+ import { ParagraphStyle } from '../../types';
2
+ import { NumberingResolver } from '../numbering.resolver';
3
+ /**
4
+ * 检测段落是否为列表项,并填充列表信息
5
+ */
6
+ export declare function resolveListInfo(style: ParagraphStyle, numberingResolver: NumberingResolver): void;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 解析 OOXML chart XML,返回 ECharts option
3
+ */
4
+ export declare function parseOoxmlChartToOption(chartXml: string): any | null;
@@ -0,0 +1,10 @@
1
+ import { ParagraphNode } from '../../types';
2
+ import { StyleResolver } from '../style.resolver';
3
+ import { ThemeData } from '../theme.resolver';
4
+ import { NumberingResolver } from '../numbering.resolver';
5
+ import { RelationshipEntry } from '../relationship.resolver';
6
+ import { PageMargins } from './image.parser';
7
+ /**
8
+ * 解析 <w:p> 元素为 ParagraphNode
9
+ */
10
+ export declare function parseParagraph(paragraphEl: Element, styleResolver: StyleResolver, theme: ThemeData, numberingResolver: NumberingResolver, rels: Map<string, RelationshipEntry>, mediaMap: Record<string, string>, pageMargins?: PageMargins, defaultFontSize?: number): ParagraphNode;
@@ -0,0 +1,22 @@
1
+ import { RunStyle, InlineChunk } from '../../types';
2
+ import { StyleResolver } from '../style.resolver';
3
+ import { ThemeData } from '../theme.resolver';
4
+ /**
5
+ * 全局脚注 / 尾注计数器(每次 parseSync 开始前由 DocxParser 重置)
6
+ */
7
+ export declare const footnoteCounter: {
8
+ value: number;
9
+ };
10
+ /**
11
+ * 解析 <w:r> 元素,返回 InlineChunk 列表
12
+ *
13
+ * 处理内容:
14
+ * <w:t> 文本
15
+ * <w:br> 换行 / 分页 / 分栏符
16
+ * <w:tab> 制表符
17
+ * <w:sym> 符号字符
18
+ * <w:softHyphen> 软连字符(忽略)
19
+ * <w:noBreakHyphen> 不换行连字符(输出 "-")
20
+ * <w:footnoteReference> / <w:endnoteReference> 脚注 / 尾注(输出上标序号)
21
+ */
22
+ export declare function parseRun(runEl: Element, styleResolver: StyleResolver, _theme: ThemeData, baseRunStyle: RunStyle): InlineChunk[];
@@ -0,0 +1,20 @@
1
+ import { ParagraphNode, ColumnNode } from '../../types';
2
+ /** 分节类型:nextPage / evenPage / oddPage 均产生分页,continuous / nextColumn 不分页 */
3
+ export type SectionBreakType = 'nextPage' | 'evenPage' | 'oddPage' | 'continuous' | 'nextColumn';
4
+ export interface SectionProperties {
5
+ /** 分节类型,默认 nextPage */
6
+ breakType: SectionBreakType;
7
+ columns: number;
8
+ colWidths: number[];
9
+ colSpace: number;
10
+ separator: boolean;
11
+ }
12
+ /**
13
+ * 解析 <w:sectPr> 中的分节属性(分页类型 + 分栏)
14
+ */
15
+ export declare function parseSectionProperties(sectPrEl: Element): SectionProperties;
16
+ /**
17
+ * 将段落列表按分栏属性分组,构建 ColumnNode
18
+ * ColumnNode 是编辑器原生分栏格式(推荐)
19
+ */
20
+ export declare function buildColumnNode(paragraphs: ParagraphNode[], sectionProps: SectionProperties, targetInnerWidth: number): ColumnNode;
@@ -0,0 +1,11 @@
1
+ import { TableNode } from '../../types';
2
+ import { StyleResolver } from '../style.resolver';
3
+ import { ThemeData } from '../theme.resolver';
4
+ import { NumberingResolver } from '../numbering.resolver';
5
+ import { RelationshipEntry } from '../relationship.resolver';
6
+ import { PageMargins } from './image.parser';
7
+ /**
8
+ * 解析 <w:tbl> 元素为 TableNode
9
+ * 支持嵌套表格、合并单元格(colspan / rowspan)、单元格边框
10
+ */
11
+ export declare function parseTable(tableEl: Element, styleResolver: StyleResolver, theme: ThemeData, numberingResolver: NumberingResolver, rels: Map<string, RelationshipEntry>, mediaMap: Record<string, string>, pageMargins?: PageMargins): TableNode;
@@ -0,0 +1,13 @@
1
+ import { ParagraphNode } from '../../types';
2
+ import { StyleResolver } from '../style.resolver';
3
+ import { ThemeData } from '../theme.resolver';
4
+ import { NumberingResolver } from '../numbering.resolver';
5
+ import { RelationshipEntry } from '../relationship.resolver';
6
+ /**
7
+ * 检测元素是否为 TOC(目录)结构化文档标签
8
+ */
9
+ export declare function isTocSdt(sdtEl: Element): boolean;
10
+ /**
11
+ * 解析 TOC SDT 为段落列表(当作普通段落处理)
12
+ */
13
+ export declare function parseTocContent(sdtEl: Element, styleResolver: StyleResolver, theme: ThemeData, numberingResolver: NumberingResolver, rels: Map<string, RelationshipEntry>, mediaMap: Record<string, string>): ParagraphNode[];
@@ -0,0 +1,17 @@
1
+ export interface RelationshipEntry {
2
+ id: string;
3
+ type: string;
4
+ target: string;
5
+ }
6
+ /**
7
+ * 解析 .rels 文件,建立 rId → target 映射
8
+ */
9
+ export declare function parseRelationships(relsXml: string): Map<string, RelationshipEntry>;
10
+ /**
11
+ * 通过 rId 获取 target 路径
12
+ */
13
+ export declare function getTargetByRId(rels: Map<string, RelationshipEntry>, rId: string): string | null;
14
+ /**
15
+ * 查找指定类型的 relationship
16
+ */
17
+ export declare function findRelByType(rels: Map<string, RelationshipEntry>, typeSubstring: string): RelationshipEntry | null;
@@ -0,0 +1,33 @@
1
+ import { ParagraphStyle, RunStyle, ResolvedStyle } from '../types';
2
+ import { ThemeData } from './theme.resolver';
3
+ /**
4
+ * 样式解析器:解析 word/styles.xml,提供完整的样式继承链查询
5
+ *
6
+ * 合并优先级(低 → 高):
7
+ * docDefaults → basedOn 链(从根祖先到直接父级)→ 当前 styleId → 段落/run 局部属性
8
+ */
9
+ export declare class StyleResolver {
10
+ private styleMap;
11
+ private defaultParagraphStyle;
12
+ private defaultRunStyle;
13
+ private theme;
14
+ constructor(stylesXml: string | null, theme: ThemeData);
15
+ /**
16
+ * 解析段落属性 <w:pPr>,返回局部 ParagraphStyle(不含继承链)
17
+ */
18
+ parseParagraphProperties(pPr: Element): ParagraphStyle;
19
+ /**
20
+ * 解析 Run 属性 <w:rPr>,返回局部 RunStyle(不含继承链)
21
+ */
22
+ parseRunProperties(rPr: Element): RunStyle;
23
+ /**
24
+ * 根据 styleId 解析完整样式(含 docDefaults + 完整继承链)
25
+ */
26
+ resolveStyle(styleId: string | null): ResolvedStyle;
27
+ getDefaultRunStyle(): RunStyle;
28
+ getDefaultParagraphStyle(): ParagraphStyle;
29
+ private parseStylesXml;
30
+ private parseDocDefaults;
31
+ private parseStyleElement;
32
+ }
33
+ export declare function resolveShdFill(shd: Element, theme: ThemeData): string | null;
@@ -0,0 +1,21 @@
1
+ export interface ThemeData {
2
+ colors: Map<string, string>;
3
+ majorFont: string | null;
4
+ minorFont: string | null;
5
+ }
6
+ /**
7
+ * 解析 word/theme/theme1.xml,提取颜色方案和字体方案
8
+ */
9
+ export declare function parseTheme(themeXml: string | null): ThemeData;
10
+ /**
11
+ * 将主题颜色名(含语义别名)解析为 #RRGGBB 颜色字符串
12
+ *
13
+ * tint / shade 为 OOXML 十六进制字符串(0x00-0xFF),在 HSL 色彩空间运算:
14
+ * tint:L_new = L + (1 - L) * factor (变亮)
15
+ * shade:L_new = L * factor (变暗)
16
+ */
17
+ export declare function resolveThemeColor(theme: ThemeData, themeColorName: string, themeTint?: string, themeShade?: string): string | null;
18
+ /**
19
+ * 解析主题字体引用(asciiTheme / eastAsiaTheme 属性值)
20
+ */
21
+ export declare function resolveThemeFont(theme: ThemeData, fontRef: string | null | undefined): string | null;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * 解析 XML 字符串为 Document
3
+ */
4
+ export declare function parseXml(xmlString: string): Document;
5
+ /**
6
+ * 获取指定命名空间下的子元素(直接子元素)
7
+ */
8
+ export declare function getChildrenByTag(parent: Element, ns: string, localName: string): Element[];
9
+ /**
10
+ * 获取第一个指定命名空间下的子元素
11
+ */
12
+ export declare function getFirstChildByTag(parent: Element, ns: string, localName: string): Element | null;
13
+ /**
14
+ * 获取 w:val 属性值
15
+ */
16
+ export declare function getWVal(el: Element | null): string | null;
17
+ /**
18
+ * 获取指定命名空间的属性值
19
+ */
20
+ export declare function getAttr(el: Element, ns: string, name: string): string | null;
21
+ /**
22
+ * 获取属性(兼容带前缀和不带前缀的写法)
23
+ */
24
+ export declare function getAttrVal(el: Element, attrName: string): string | null;
25
+ /**
26
+ * 遍历直接子元素(所有命名空间)
27
+ */
28
+ export declare function forEachChild(parent: Element, callback: (child: Element) => void): void;
29
+ /**
30
+ * 获取所有后代元素(指定命名空间和标签名)
31
+ */
32
+ export declare function getElementsByTag(parent: Element, ns: string, localName: string): Element[];
33
+ /**
34
+ * 检查元素是否存在(用于 boolean 属性如 <w:b/>)
35
+ */
36
+ export declare function hasChild(parent: Element, ns: string, localName: string): boolean;
@@ -0,0 +1,9 @@
1
+ type Draw = any;
2
+ type Command = any;
3
+ export declare class ExportComponent {
4
+ private _command;
5
+ install(draw: Draw, command: Command): this;
6
+ exportDocx(payload?: any): Promise<Blob | null>;
7
+ previewHtml(payload?: any): string;
8
+ }
9
+ export {};
@@ -0,0 +1,8 @@
1
+ type Draw = any;
2
+ type ILang = any;
3
+ type DeepPartial<T> = T;
4
+ export declare class I18n {
5
+ install(_draw: Draw): this;
6
+ setLang(_locale: string, _lang: DeepPartial<ILang>): void;
7
+ }
8
+ export {};