@file-viewer/docx 0.3.33 → 0.3.34
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.
- package/README.md +49 -9
- package/dist/THIRD_PARTY_NOTICES.txt +1038 -0
- package/dist/anchor-layout.d.ts +20 -0
- package/dist/comment-layer.d.ts +40 -0
- package/dist/comments/comments-extended-part.d.ts +13 -0
- package/dist/comments/comments-part.d.ts +11 -0
- package/dist/comments/elements.d.ts +23 -0
- package/dist/common/content-types.d.ts +7 -0
- package/dist/common/open-xml-package.d.ts +25 -0
- package/dist/common/part.d.ts +12 -0
- package/dist/common/relationship.d.ts +46 -0
- package/dist/dark-mode-color.d.ts +29 -0
- package/dist/display-address.d.ts +5 -0
- package/dist/document/bookmarks.d.ts +13 -0
- package/dist/document/border.d.ts +18 -0
- package/dist/document/common.d.ts +38 -0
- package/dist/document/document-part.d.ts +10 -0
- package/dist/document/document.d.ts +9 -0
- package/dist/document/dom.d.ts +200 -0
- package/dist/document/fields.d.ts +14 -0
- package/dist/document/line-spacing.d.ts +9 -0
- package/dist/document/page-breaks.d.ts +8 -0
- package/dist/document/paragraph.d.ts +54 -0
- package/dist/document/run.d.ts +12 -0
- package/dist/document/section.d.ts +82 -0
- package/dist/document/style.d.ts +21 -0
- package/dist/document/symbol-encoding.d.ts +28 -0
- package/dist/document-parser.d.ts +156 -0
- package/dist/document-props/core-props-part.d.ts +6 -0
- package/dist/document-props/core-props.d.ts +12 -0
- package/dist/document-props/custom-props-part.d.ts +6 -0
- package/dist/document-props/custom-props.d.ts +8 -0
- package/dist/document-props/extended-props-part.d.ts +6 -0
- package/dist/document-props/extended-props.d.ts +14 -0
- package/dist/docx-preview-esm.d.mts +3 -0
- package/dist/docx-preview-worker.d.ts +1 -0
- package/dist/docx-preview.d.ts +84 -13
- package/dist/docx-preview.js +15387 -4
- package/dist/docx-preview.min.js +25 -4
- package/dist/docx-preview.min.mjs +25 -4
- package/dist/docx-preview.mjs +15386 -4
- package/dist/docx-preview.worker.js +15473 -4
- package/dist/font-table/font-table.d.ts +6 -0
- package/dist/font-table/fonts.d.ts +15 -0
- package/dist/header-footer/elements.d.ts +7 -0
- package/dist/header-footer/parts.d.ts +18 -0
- package/dist/html-renderer.d.ts +566 -0
- package/dist/html.d.ts +16 -0
- package/dist/input-validation.d.ts +2 -0
- package/dist/javascript.d.ts +8 -0
- package/dist/jszip.min.js +2 -2
- package/dist/layout-coordinates.d.ts +23 -0
- package/dist/layout-readiness.d.ts +17 -0
- package/dist/length.d.ts +11 -0
- package/dist/license-gate.d.ts +4 -0
- package/dist/metafile/emf-to-svg.d.ts +7 -0
- package/dist/metafile/wmf-to-svg.d.ts +7 -0
- package/dist/notes/elements.d.ts +12 -0
- package/dist/notes/parts.d.ts +17 -0
- package/dist/notes/properties.d.ts +33 -0
- package/dist/numbering/numbering-part.d.ts +14 -0
- package/dist/numbering/numbering.d.ts +49 -0
- package/dist/parser/xml-parser.d.ts +27 -0
- package/dist/review.d.ts +49 -0
- package/dist/security/links.d.ts +6 -0
- package/dist/security/trusted-types.d.ts +10 -0
- package/dist/settings/settings-part.d.ts +8 -0
- package/dist/settings/settings.d.ts +25 -0
- package/dist/styles/styles-part.d.ts +10 -0
- package/dist/table-diagonals.d.ts +2 -0
- package/dist/theme/theme-part.d.ts +8 -0
- package/dist/theme/theme.d.ts +25 -0
- package/dist/utils.d.ts +17 -0
- package/dist/vml/vml.d.ts +19 -0
- package/dist/word-document.d.ts +89 -0
- package/package.json +33 -26
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { XmlParser } from "../parser/xml-parser";
|
|
2
|
+
import { Borders } from "./border";
|
|
3
|
+
import { Length } from "./common";
|
|
4
|
+
import { NoteProperties } from "../notes/properties";
|
|
5
|
+
export interface Column {
|
|
6
|
+
space: Length;
|
|
7
|
+
width: Length;
|
|
8
|
+
}
|
|
9
|
+
export interface Columns {
|
|
10
|
+
space: Length;
|
|
11
|
+
numberOfColumns: number;
|
|
12
|
+
separator: boolean;
|
|
13
|
+
equalWidth: boolean;
|
|
14
|
+
columns: Column[];
|
|
15
|
+
}
|
|
16
|
+
export interface PageSize {
|
|
17
|
+
width: Length;
|
|
18
|
+
height: Length;
|
|
19
|
+
orientation: "landscape" | string;
|
|
20
|
+
}
|
|
21
|
+
export interface PageNumber {
|
|
22
|
+
start: number;
|
|
23
|
+
chapSep: "colon" | "emDash" | "endash" | "hyphen" | "period" | string;
|
|
24
|
+
chapStyle: string;
|
|
25
|
+
format: "none" | "cardinalText" | "decimal" | "decimalEnclosedCircle" | "decimalEnclosedFullstop" | "decimalEnclosedParen" | "decimalZero" | "lowerLetter" | "lowerRoman" | "ordinalText" | "upperLetter" | "upperRoman" | string;
|
|
26
|
+
}
|
|
27
|
+
export interface PageMargins {
|
|
28
|
+
top: Length;
|
|
29
|
+
right: Length;
|
|
30
|
+
bottom: Length;
|
|
31
|
+
left: Length;
|
|
32
|
+
header: Length;
|
|
33
|
+
footer: Length;
|
|
34
|
+
gutter: Length;
|
|
35
|
+
}
|
|
36
|
+
export interface DocumentGrid {
|
|
37
|
+
type: "default" | "lines" | "linesAndChars" | "snapToChars" | string;
|
|
38
|
+
linePitch: Length;
|
|
39
|
+
/**
|
|
40
|
+
* CSS letter-spacing approximation for w:docGrid@charSpace.
|
|
41
|
+
*
|
|
42
|
+
* OOXML stores the delta from the Normal-style character pitch in
|
|
43
|
+
* 1/4096 point units. This is a point delta, not an em value.
|
|
44
|
+
*/
|
|
45
|
+
charSpace: Length;
|
|
46
|
+
/** Raw Open XML value: desired character pitch delta multiplied by 4096. */
|
|
47
|
+
charSpaceRaw: number;
|
|
48
|
+
}
|
|
49
|
+
export declare enum SectionType {
|
|
50
|
+
Continuous = "continuous",
|
|
51
|
+
NextPage = "nextPage",
|
|
52
|
+
NextColumn = "nextColumn",
|
|
53
|
+
EvenPage = "evenPage",
|
|
54
|
+
OddPage = "oddPage"
|
|
55
|
+
}
|
|
56
|
+
export declare function isSectionPageBreak(type: string): boolean;
|
|
57
|
+
export declare function isSectionColumnBreak(type: string): boolean;
|
|
58
|
+
export interface FooterHeaderReference {
|
|
59
|
+
id: string;
|
|
60
|
+
type: string | "first" | "even" | "default";
|
|
61
|
+
}
|
|
62
|
+
export interface SectionProperties {
|
|
63
|
+
type: SectionType | string;
|
|
64
|
+
pageSize: PageSize;
|
|
65
|
+
pageMargins: PageMargins;
|
|
66
|
+
pageBorders: Borders;
|
|
67
|
+
pageNumber: PageNumber;
|
|
68
|
+
columns: Columns;
|
|
69
|
+
docGrid: DocumentGrid;
|
|
70
|
+
footerRefs: FooterHeaderReference[];
|
|
71
|
+
headerRefs: FooterHeaderReference[];
|
|
72
|
+
titlePage: boolean;
|
|
73
|
+
footnoteProps?: NoteProperties;
|
|
74
|
+
endnoteProps?: NoteProperties;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Word applies page geometry even when generated DOCX files omit all or part
|
|
78
|
+
* of sectPr/pgSz/pgMar. Resolve those application defaults in the document
|
|
79
|
+
* model so main-thread and Worker rendering share the same behavior without
|
|
80
|
+
* rewriting the original OOXML package.
|
|
81
|
+
*/
|
|
82
|
+
export declare function parseSectionProperties(elem?: Element, xml?: XmlParser): SectionProperties;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ParagraphProperties } from "./paragraph";
|
|
2
|
+
import { RunProperties } from "./run";
|
|
3
|
+
export interface IDomStyle {
|
|
4
|
+
id: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
cssName?: string;
|
|
7
|
+
aliases?: string[];
|
|
8
|
+
target: string;
|
|
9
|
+
basedOn?: string;
|
|
10
|
+
isDefault?: boolean;
|
|
11
|
+
styles: IDomSubStyle[];
|
|
12
|
+
linked?: string;
|
|
13
|
+
next?: string;
|
|
14
|
+
paragraphProps: ParagraphProperties;
|
|
15
|
+
runProps: RunProperties;
|
|
16
|
+
}
|
|
17
|
+
export interface IDomSubStyle {
|
|
18
|
+
target: string;
|
|
19
|
+
mod?: string;
|
|
20
|
+
values: Record<string, string>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*! @license Adobe Symbol Encoding to Unicode
|
|
2
|
+
* Copyright (c) 1991-2011 Unicode, Inc. All Rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* This file is provided as-is by Unicode, Inc. (The Unicode Consortium). No
|
|
5
|
+
* claims are made as to fitness for any particular purpose. No warranties of
|
|
6
|
+
* any kind are expressed or implied. The recipient agrees to determine
|
|
7
|
+
* applicability of information provided. If this file has been provided on
|
|
8
|
+
* magnetic media by Unicode, Inc., the sole remedy for any claim will be
|
|
9
|
+
* exchange of defective media within 90 days of receipt.
|
|
10
|
+
*
|
|
11
|
+
* Unicode, Inc. hereby grants the right to freely use the information
|
|
12
|
+
* supplied in this file in the creation of products supporting the
|
|
13
|
+
* Unicode Standard, and to make copies of this file in any form for
|
|
14
|
+
* internal or external distribution as long as this notice remains
|
|
15
|
+
* attached.
|
|
16
|
+
*
|
|
17
|
+
* Source: https://www.unicode.org/Public/MAPPINGS/VENDORS/ADOBE/symbol.txt
|
|
18
|
+
*/
|
|
19
|
+
export interface DecodedSymbol {
|
|
20
|
+
text: string;
|
|
21
|
+
normalized: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* w:sym selects a font-specific character, including Word's F000 byte offset.
|
|
25
|
+
* Resolve known Symbol encoding slots to their Unicode glyph so missing legacy
|
|
26
|
+
* symbol fonts do not turn authored marks into private-use tofu.
|
|
27
|
+
*/
|
|
28
|
+
export declare function decodeWordSymbol(font: string, code: number): DecodedSymbol;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { DomType, WmlTable, IDomNumbering, WmlHyperlink, WmlSmartTag, IDomImage, IDomShape, OpenXmlElement, WmlTableColumn, WmlTableCell, WmlTableRow, NumberingPicBullet, WmlAltChunk, IDomChart, IDomSmartArt, IDomInk, IDomRuby } from './document/dom';
|
|
2
|
+
import { DocumentElement } from './document/document';
|
|
3
|
+
import { WmlParagraph } from './document/paragraph';
|
|
4
|
+
import { WmlRun } from './document/run';
|
|
5
|
+
import { IDomStyle, IDomSubStyle } from './document/style';
|
|
6
|
+
import { WmlFieldSimple } from './document/fields';
|
|
7
|
+
/**
|
|
8
|
+
* "auto" 颜色的解析结果。使用 CSS 变量而不是字面量 "black",
|
|
9
|
+
* 这样暗色模式只需在渲染层改变变量值,无需重新解析文档。
|
|
10
|
+
* 变量未定义时(例如未启用暗色模式)回退到原有的 black 字面量,行为与之前完全一致。
|
|
11
|
+
*/
|
|
12
|
+
export declare var autos: {
|
|
13
|
+
shd: string;
|
|
14
|
+
color: string;
|
|
15
|
+
borderColor: string;
|
|
16
|
+
highlight: string;
|
|
17
|
+
};
|
|
18
|
+
/** XML 到内部 DOM 的解析选项,决定宽度保留、调试日志和修订内容处理。 */
|
|
19
|
+
export interface DocumentParserOptions {
|
|
20
|
+
exposeDisplayTargets?: boolean;
|
|
21
|
+
ignoreWidth: boolean;
|
|
22
|
+
debug: boolean;
|
|
23
|
+
hideWebHiddenContent: boolean;
|
|
24
|
+
renderChanges?: boolean;
|
|
25
|
+
reviewMode?: "final" | "original" | "simple" | "all" | "auto";
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* DOCX XML 解析器。
|
|
29
|
+
* 它把 WordprocessingML 的 body、段落、run、表格、图片、字段等节点转换为渲染器可消费的内部 DOM。
|
|
30
|
+
*/
|
|
31
|
+
export declare class DocumentParser {
|
|
32
|
+
private readonly paragraphAddress;
|
|
33
|
+
/** 当前解析策略;构造时会与默认值合并,后续方法都从这里读取兼容开关。 */
|
|
34
|
+
options: DocumentParserOptions;
|
|
35
|
+
constructor(options?: Partial<DocumentParserOptions>);
|
|
36
|
+
parseNotes(xmlDoc: Element, elemName: string, elemClass: any): any[];
|
|
37
|
+
parseComments(xmlDoc: Element): any[];
|
|
38
|
+
/** 解析主文档 word/document.xml,输出包含正文和节属性的根节点。 */
|
|
39
|
+
parseDocumentFile(xmlDoc: Element): DocumentElement;
|
|
40
|
+
parseBackground(elem: Element): any;
|
|
41
|
+
/** 解析 body/header/footer/comment 等容器内的块级元素。 */
|
|
42
|
+
parseBodyElements(element: Element): OpenXmlElement[];
|
|
43
|
+
/** 解析 styles.xml 中的样式定义,并保留继承关系供渲染阶段合并。 */
|
|
44
|
+
parseStylesFile(xstyles: Element): IDomStyle[];
|
|
45
|
+
parseDefaultStyles(node: Element): IDomStyle;
|
|
46
|
+
parseStyle(node: Element): IDomStyle;
|
|
47
|
+
parseTableStyle(node: Element): IDomSubStyle[];
|
|
48
|
+
parseNumberingFile(node: Element): IDomNumbering[];
|
|
49
|
+
cloneNumberingLevel(level: IDomNumbering, id: string): IDomNumbering;
|
|
50
|
+
parseNumberingPicBullet(elem: Element): NumberingPicBullet;
|
|
51
|
+
parseAbstractNumbering(node: Element, bullets: any[]): IDomNumbering[];
|
|
52
|
+
parseNumberingLevel(id: string, node: Element, bullets: any[]): IDomNumbering;
|
|
53
|
+
parseSdt(node: Element, parser: Function): OpenXmlElement[];
|
|
54
|
+
parseInserted(node: Element, parentParser: Function): OpenXmlElement;
|
|
55
|
+
parseDeleted(node: Element, parentParser: Function): OpenXmlElement;
|
|
56
|
+
parseRevision(type: DomType.Inserted | DomType.Deleted, node: Element, parentParser: Function, kind?: "insert" | "delete" | "move-from" | "move-to"): OpenXmlElement;
|
|
57
|
+
parseAltChunk(node: Element): WmlAltChunk;
|
|
58
|
+
/** 解析单个段落,合并 pPr、run、超链接、书签、批注和复杂字段。 */
|
|
59
|
+
parseParagraph(node: Element): OpenXmlElement;
|
|
60
|
+
parseParagraphProperties(elem: Element, paragraph: WmlParagraph): void;
|
|
61
|
+
parseFrame(node: Element, paragraph: WmlParagraph): void;
|
|
62
|
+
parseHyperlink(node: Element, parent?: OpenXmlElement): WmlHyperlink;
|
|
63
|
+
parseSmartTag(node: Element, parent?: OpenXmlElement): WmlSmartTag;
|
|
64
|
+
parseSimpleField(node: Element, parent?: OpenXmlElement): WmlFieldSimple;
|
|
65
|
+
/** 解析文本 run,将文本、制表符、换行、图片、字段和 run 属性收集到同一节点下。 */
|
|
66
|
+
parseRun(node: Element, parent?: OpenXmlElement): WmlRun;
|
|
67
|
+
parseRuby(elem: Element): IDomRuby;
|
|
68
|
+
parseRubyContent(elem: Element, type: DomType.RubyBase | DomType.RubyText): OpenXmlElement;
|
|
69
|
+
parseMathElement(elem: Element): OpenXmlElement | null;
|
|
70
|
+
hasVisibleMathContent(elem: OpenXmlElement): boolean;
|
|
71
|
+
parseMathProperies(elem: Element): Record<string, any>;
|
|
72
|
+
parseRunProperties(elem: Element, run: WmlRun): void;
|
|
73
|
+
parseVmlPicture(elem: Element): OpenXmlElement;
|
|
74
|
+
checkAlternateContent(elem: Element): Element;
|
|
75
|
+
/** 解析 DrawingML 图片/形状/图表/SmartArt,并处理浮动定位与环绕方式。 */
|
|
76
|
+
parseDrawing(node: Element): OpenXmlElement;
|
|
77
|
+
parseDrawingWrapper(node: Element): OpenXmlElement;
|
|
78
|
+
/** Map explicit column/paragraph offsets onto the float exclusion box. */
|
|
79
|
+
applyDrawingFloatOffsets(drawing: OpenXmlElement, wrapper: Element): OpenXmlElement;
|
|
80
|
+
parseWrapPolygon(elem: Element): string;
|
|
81
|
+
parseGraphic(elem: Element): OpenXmlElement;
|
|
82
|
+
parseDrawingContainer(elem: Element, parentTransform?: any): IDomShape;
|
|
83
|
+
parseDmlGroupTransform(elem: Element, parentTransform?: any): any;
|
|
84
|
+
parseDmlPositionedPicture(elem: Element, transform?: any): IDomImage;
|
|
85
|
+
parseDmlPositionedShape(elem: Element, transform?: any): IDomShape;
|
|
86
|
+
parseDmlShapeBounds(spPr: Element, transform?: any): {
|
|
87
|
+
left: number;
|
|
88
|
+
top: number;
|
|
89
|
+
width: number;
|
|
90
|
+
height: number;
|
|
91
|
+
};
|
|
92
|
+
parseDmlFillStyle(spPr: Element): any;
|
|
93
|
+
parseDmlLineStyle(line: Element): any;
|
|
94
|
+
parseDmlCustomGeometry(geom: Element): any;
|
|
95
|
+
parseDmlPathData(path: Element, width: number, height: number): string;
|
|
96
|
+
dmlCoord(value: string, width: number, height: number): number;
|
|
97
|
+
dmlVerticalAlign(bodyPr: Element): string;
|
|
98
|
+
applyDmlTextInsets(bodyPr: Element, cssStyle: Record<string, string>): void;
|
|
99
|
+
parseDmlTextBoxProperties(bodyPr: Element): Record<string, any>;
|
|
100
|
+
emuToPt(value: number): number;
|
|
101
|
+
pt(value: number): string;
|
|
102
|
+
parseChartReference(elem: Element): IDomChart;
|
|
103
|
+
parseSmartArtReference(elem: Element): IDomSmartArt;
|
|
104
|
+
parseInkReference(elem: Element): IDomInk;
|
|
105
|
+
parseGraphicPlaceholder(label: string): IDomShape;
|
|
106
|
+
parseWordprocessingShape(elem: Element): IDomShape;
|
|
107
|
+
parseDmlShapeProperties(elem: Element, style: Record<string, string>): void;
|
|
108
|
+
parseDmlColor(elem: Element): string;
|
|
109
|
+
resolveDmlSchemeColor(value: string): string;
|
|
110
|
+
dmlSchemeColorFallback(value: string): string;
|
|
111
|
+
applyDmlColorTransforms(elem: Element, color: string): string;
|
|
112
|
+
findDescendant(elem: Element, localName: string): Element;
|
|
113
|
+
parsePicture(elem: Element): IDomImage;
|
|
114
|
+
/** 解析表格结构,包含 tblPr、tblGrid、tr、tc、合并单元格和嵌套内容。 */
|
|
115
|
+
parseTable(node: Element): WmlTable;
|
|
116
|
+
parseTableColumns(node: Element): WmlTableColumn[];
|
|
117
|
+
parseTableProperties(elem: Element, table: WmlTable): void;
|
|
118
|
+
parseTableIndentation(node: Element): string;
|
|
119
|
+
parseTablePosition(node: Element, table: WmlTable): void;
|
|
120
|
+
parseTableRow(node: Element): WmlTableRow;
|
|
121
|
+
/**
|
|
122
|
+
* Older producers such as Apache POI may emit the deprecated hMerge form
|
|
123
|
+
* instead of gridSpan. Normalize each valid restart/continue run so every
|
|
124
|
+
* later table-layout stage sees the same grid model.
|
|
125
|
+
*/
|
|
126
|
+
normalizeHorizontalMerges(cells: WmlTableCell[]): WmlTableCell[];
|
|
127
|
+
parseTableRowProperties(elem: Element, row: WmlTableRow): void;
|
|
128
|
+
parseTableCell(node: Element): OpenXmlElement;
|
|
129
|
+
parseTableCellProperties(elem: Element, cell: WmlTableCell): void;
|
|
130
|
+
addStructuralRevision(element: OpenXmlElement, node: Element, kind: "insert" | "delete"): void;
|
|
131
|
+
addFormatRevision(element: OpenXmlElement, node: Element, kind: string, currentPropertiesNode?: Element): void;
|
|
132
|
+
captureFormatProperties(node?: Element): Record<string, string>;
|
|
133
|
+
serializeFormatProperty(node: Element): string;
|
|
134
|
+
revisionMetadata(node: Element, kind: string): {
|
|
135
|
+
id: string;
|
|
136
|
+
author: string;
|
|
137
|
+
date: string;
|
|
138
|
+
kind: string;
|
|
139
|
+
};
|
|
140
|
+
parseTableCellVerticalText(elem: Element, cell: WmlTableCell): void;
|
|
141
|
+
parseDefaultProperties(elem: Element, style?: Record<string, string>, childStyle?: Record<string, string>, handler?: (prop: Element) => boolean): Record<string, string>;
|
|
142
|
+
parseFitText(node: Element, style: Record<string, string>): void;
|
|
143
|
+
parseEastAsianLayout(node: Element, style: Record<string, string>): void;
|
|
144
|
+
parseUnderline(node: Element, style: Record<string, string>): void;
|
|
145
|
+
parseFont(node: Element, style: Record<string, string>, languages?: {
|
|
146
|
+
latin?: string;
|
|
147
|
+
eastAsia?: string;
|
|
148
|
+
bidi?: string;
|
|
149
|
+
}): void;
|
|
150
|
+
scriptThemeFontValue(value: string, language: string): string;
|
|
151
|
+
parseIndentation(node: Element, style: Record<string, string>): void;
|
|
152
|
+
parseSpacing(node: Element, style: Record<string, string>): void;
|
|
153
|
+
parseMarginProperties(node: Element, output: Record<string, string>): void;
|
|
154
|
+
parseTrHeight(node: Element, output: Record<string, string>): void;
|
|
155
|
+
parseBorderProperties(node: Element, output: Record<string, string>): void;
|
|
156
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { XmlParser } from "../parser/xml-parser";
|
|
2
|
+
export interface CorePropsDeclaration {
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
subject: string;
|
|
6
|
+
creator: string;
|
|
7
|
+
keywords: string;
|
|
8
|
+
language: string;
|
|
9
|
+
lastModifiedBy: string;
|
|
10
|
+
revision: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function parseCoreProps(root: Element, xmlParser: XmlParser): CorePropsDeclaration;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { XmlParser } from "../parser/xml-parser";
|
|
2
|
+
export interface ExtendedPropsDeclaration {
|
|
3
|
+
template: string;
|
|
4
|
+
totalTime: number;
|
|
5
|
+
pages: number;
|
|
6
|
+
words: number;
|
|
7
|
+
characters: number;
|
|
8
|
+
application: string;
|
|
9
|
+
lines: number;
|
|
10
|
+
paragraphs: number;
|
|
11
|
+
company: string;
|
|
12
|
+
appVersion: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function parseExtendedProps(root: Element, xmlParser: XmlParser): ExtendedPropsDeclaration;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/docx-preview.d.ts
CHANGED
|
@@ -1,33 +1,82 @@
|
|
|
1
|
+
import { h } from './html';
|
|
2
|
+
import type { ReviewModeOption } from './review';
|
|
3
|
+
export { collectDocxReviewChanges, resolveDocxReviewState, setDocxReviewMode } from './review';
|
|
4
|
+
export type { ReviewChange, ReviewChangeKind, ReviewChangePresentation, ReviewFormatChange, ReviewMode, ReviewModeOption } from './review';
|
|
5
|
+
/** DOCX 解析和渲染的总配置,业务侧通常只需要覆盖其中少量字段。 */
|
|
1
6
|
export interface Options {
|
|
2
7
|
/** Emit read-only part/paragraph identities for independent display adapters. Off by default. */
|
|
3
8
|
exposeDisplayTargets?: boolean;
|
|
4
9
|
inWrapper: boolean;
|
|
5
10
|
hideWrapperOnPrint: boolean;
|
|
6
11
|
ignoreWidth: boolean;
|
|
12
|
+
/** In flow mode, Word page height is still preserved as a visual min-height. */
|
|
7
13
|
ignoreHeight: boolean;
|
|
14
|
+
/** Keep print-layout pages at an exact Word page height. Disable to use Word page height as min-height. */
|
|
8
15
|
fixedPageHeight: boolean;
|
|
9
16
|
ignoreFonts: boolean;
|
|
10
17
|
breakPages: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Enables the stricter Word-layout compatibility path. The renderer uses measured
|
|
20
|
+
* post-render pagination, tries to split oversized paragraphs/tables instead of
|
|
21
|
+
* leaving them overflowing, preserves widow/orphan constraints where the browser
|
|
22
|
+
* exposes enough geometry, and applies East Asian grid/kinsoku compatibility CSS.
|
|
23
|
+
*/
|
|
11
24
|
strictWordCompatibility: boolean;
|
|
25
|
+
/** Pixel slack tolerated by measured pagination before a page is considered overflowing. */
|
|
12
26
|
paginationTolerance: number;
|
|
27
|
+
/** Safety cap for the measured pagination loop. */
|
|
13
28
|
maxDynamicPaginationPasses: number;
|
|
29
|
+
/** Await fonts, images and the measured pagination pass in renderAsync before resolving. */
|
|
14
30
|
awaitLayout: boolean;
|
|
31
|
+
/** Use a Web Worker for ZIP/XML parsing and relationship preloading when workerUrl is available. */
|
|
15
32
|
useWorker: boolean;
|
|
33
|
+
/** URL of dist/docx-preview.worker.js or an equivalent same-origin worker bundle. */
|
|
16
34
|
workerUrl?: string;
|
|
35
|
+
/** Application-owned Worker factory for strict Trusted Types/CSP deployments. */
|
|
17
36
|
workerFactory?: () => Worker;
|
|
37
|
+
/** Explicit same-origin HTTP(S) or Blob JSZip URL without credentials; relative URLs resolve against the Worker script. Omit to use the bundled dependency. */
|
|
18
38
|
workerJsZipUrl?: string;
|
|
39
|
+
/** Fall back to main-thread parsing if worker construction or parsing fails. */
|
|
19
40
|
workerFallback: boolean;
|
|
41
|
+
/** Abort worker parsing after this many milliseconds. 0 disables the timeout. */
|
|
20
42
|
workerTimeout: number;
|
|
43
|
+
/** Yield after rendering this many pages to keep the browser responsive. */
|
|
21
44
|
renderPageBatchSize: number;
|
|
45
|
+
/** Yield after this many milliseconds of renderer work. */
|
|
22
46
|
renderYieldEveryMs: number;
|
|
47
|
+
/** Progress hook used by demos/integrations. Not posted to workers. */
|
|
23
48
|
progress?: (event: DocxProgressEvent) => void;
|
|
49
|
+
/** Runtime token issued by the sealed WASM license gate. */
|
|
24
50
|
licenseToken?: unknown;
|
|
51
|
+
/**
|
|
52
|
+
* Preserve Word's stored complex-field result runs when they are present. This is the
|
|
53
|
+
* default for PAGEREF/TOC/cross-reference fields because those values are calculated by
|
|
54
|
+
* Word and saved in the document. PAGE/NUMPAGES are still refreshed after pagination.
|
|
55
|
+
*/
|
|
25
56
|
preserveComplexFieldResults: boolean;
|
|
57
|
+
/** Update PAGEREF fields from browser-calculated anchors instead of using Word's stored field result. */
|
|
26
58
|
updatePageReferences: boolean;
|
|
59
|
+
/** Hide w:webHidden content. The print-layout renderer shows it by default because webHidden affects only web view. */
|
|
27
60
|
hideWebHiddenContent: boolean;
|
|
61
|
+
/** Controls whether links that leave the rendered DOCX receive an active href. Internal bookmark links are always preserved. */
|
|
28
62
|
externalLinkPolicy: "allow" | "block";
|
|
63
|
+
/**
|
|
64
|
+
* Controls whether TargetMode="External" image relationships may load HTTP(S)
|
|
65
|
+
* resources. The default is block. Package-embedded images and local data:/blob:
|
|
66
|
+
* image URLs remain available without enabling network access.
|
|
67
|
+
*/
|
|
29
68
|
externalResourcePolicy: "allow" | "block";
|
|
69
|
+
/**
|
|
70
|
+
* Word Online-style dark mode: every color (text, backgrounds/highlights, borders, theme
|
|
71
|
+
* colors, shape fills/strokes) is converted in CIE Lab space by inverting only the
|
|
72
|
+
* lightness channel around the "L" of #333333, keeping hue/chroma unchanged - the same
|
|
73
|
+
* lightness-inversion approach Microsoft uses for this exact purpose (see roosterjs'
|
|
74
|
+
* getDarkColor). Black becomes white, white becomes #333333, and any other color keeps its
|
|
75
|
+
* hue while becoming light enough to read on a dark page. Purely a rendering-time CSS
|
|
76
|
+
* transform; print output always reverts to the original light-mode colors.
|
|
77
|
+
*/
|
|
30
78
|
darkMode: boolean;
|
|
79
|
+
/** 打开后会输出兼容性警告和解析兜底信息,便于定位复杂文档问题。 */
|
|
31
80
|
debug: boolean;
|
|
32
81
|
experimental: boolean;
|
|
33
82
|
className: string;
|
|
@@ -39,30 +88,27 @@ export interface Options {
|
|
|
39
88
|
ignoreLastRenderedPageBreak: boolean;
|
|
40
89
|
useBase64URL: boolean;
|
|
41
90
|
renderChanges: boolean;
|
|
42
|
-
|
|
91
|
+
/** Word-style tracked-change view. Omit to keep review preview disabled. */
|
|
92
|
+
reviewMode?: ReviewModeOption;
|
|
93
|
+
/** Keep deletion balloons by default; inline mode is available to hosts without a review rail. */
|
|
94
|
+
reviewPresentation?: "inline" | "balloon";
|
|
43
95
|
renderComments: boolean;
|
|
44
96
|
renderAltChunks: boolean;
|
|
45
|
-
h:
|
|
46
|
-
}
|
|
47
|
-
export type ReviewMode = "final" | "original" | "simple" | "all";
|
|
48
|
-
export type ReviewChangeKind = "insert" | "delete" | "move-from" | "move-to" | "format";
|
|
49
|
-
export interface ReviewChange {
|
|
50
|
-
id?: string;
|
|
51
|
-
kind: ReviewChangeKind;
|
|
52
|
-
author?: string;
|
|
53
|
-
date?: string;
|
|
54
|
-
text: string;
|
|
97
|
+
h: typeof h;
|
|
55
98
|
}
|
|
99
|
+
/** 解析、渲染、布局各阶段的进度事件,用于 Demo loading 或宿主侧状态提示。 */
|
|
56
100
|
export interface DocxProgressEvent {
|
|
57
101
|
phase: "worker" | "parse" | "render" | "layout" | "done" | string;
|
|
58
102
|
current?: number;
|
|
59
103
|
total?: number;
|
|
60
104
|
message?: string;
|
|
61
105
|
}
|
|
106
|
+
/** 页面布局快照中的字段结果,主要用于 PAGE/NUMPAGES/PAGEREF 等动态域调试。 */
|
|
62
107
|
export interface LayoutFieldSnapshot {
|
|
63
108
|
instruction: string;
|
|
64
109
|
value: string;
|
|
65
110
|
}
|
|
111
|
+
/** 单页渲染后的几何和内容摘要,可帮助判断分页溢出、锚点和媒体加载情况。 */
|
|
66
112
|
export interface LayoutPageSnapshot {
|
|
67
113
|
index: number;
|
|
68
114
|
section: string;
|
|
@@ -78,19 +124,44 @@ export interface LayoutPageSnapshot {
|
|
|
78
124
|
floats: number;
|
|
79
125
|
unresolvedMedia: number;
|
|
80
126
|
}
|
|
127
|
+
/** 完整布局快照,记录总页数、溢出页和未解析媒体数量。 */
|
|
81
128
|
export interface LayoutSnapshot {
|
|
82
129
|
pageCount: number;
|
|
83
130
|
overflowPages: number[];
|
|
84
131
|
unresolvedMedia: number;
|
|
132
|
+
textLength: number;
|
|
133
|
+
fields: LayoutFieldSnapshot[];
|
|
134
|
+
floats: number;
|
|
85
135
|
pages: LayoutPageSnapshot[];
|
|
86
136
|
}
|
|
137
|
+
/** 默认选项保持接近 Word 打印布局,同时允许 Worker 和动态分页提升大文档体验。 */
|
|
87
138
|
export declare const defaultOptions: Options;
|
|
139
|
+
/** 只解析 DOCX 包,返回 WordDocument;不会向页面写入任何 DOM。 */
|
|
88
140
|
export declare function parseAsync(data: Blob | any, userOptions?: Partial<Options>): Promise<any>;
|
|
141
|
+
/**
|
|
142
|
+
* Create detached document nodes. Mount the returned nodes, then call
|
|
143
|
+
* awaitRenderedLayout(container, options) when measured layout is needed.
|
|
144
|
+
* Nodes that have not been mounted do not start a background polling timer.
|
|
145
|
+
*/
|
|
89
146
|
export declare function renderDocument(document: any, userOptions?: Partial<Options>): Promise<any>;
|
|
147
|
+
/**
|
|
148
|
+
* 一站式渲染入口:解析文件、生成 DOM、插入容器,并按需等待字体/图片/分页测量完成。
|
|
149
|
+
* Demo 和普通浏览器集成优先使用该方法。
|
|
150
|
+
*/
|
|
90
151
|
export declare function renderAsync(data: Blob | any, bodyContainer: HTMLElement, styleContainer?: HTMLElement, userOptions?: Partial<Options>): Promise<any>;
|
|
152
|
+
/** 使用 Web Worker 完成 ZIP/XML 解析,避免大文档阻塞主线程。 */
|
|
91
153
|
export declare function parseAsyncInWorker(data: Blob | any, userOptions?: Partial<Options>): Promise<any>;
|
|
154
|
+
/**
|
|
155
|
+
* Wait for fonts, images, tabs, drawings and dynamic pagination before collecting
|
|
156
|
+
* diagnostics. Reject with AbortError if the container is detached; reject with
|
|
157
|
+
* Error if pagination fails or the existing pagination wait budget is exhausted.
|
|
158
|
+
*/
|
|
92
159
|
export declare function awaitRenderedLayout(container: HTMLElement, userOptions?: Partial<Options>): Promise<LayoutSnapshot>;
|
|
160
|
+
/** Release document-scoped layout, comment and bookmark handlers on replacement/unmount. */
|
|
161
|
+
export declare function disposeRenderedDocument(container: HTMLElement): void;
|
|
162
|
+
/** 从当前 DOM 收集分页和媒体加载状态,不触发重新渲染。 */
|
|
93
163
|
export declare function collectLayoutSnapshot(container: HTMLElement, userOptions?: Partial<Options>): LayoutSnapshot;
|
|
164
|
+
/** 让 CSS counter 生成的编号继承段落首个真实 run 的字体,避免标题编号退回默认字号。 */
|
|
165
|
+
export declare function syncNumberingMarkerStyles(container: HTMLElement, className?: string): void;
|
|
166
|
+
/** 把长任务让回浏览器事件循环,避免连续渲染页面时 UI 卡死。 */
|
|
94
167
|
export declare function yieldToBrowser(): Promise<void>;
|
|
95
|
-
export declare function collectDocxReviewChanges(documentOrRoot: any): ReviewChange[];
|
|
96
|
-
export declare function setDocxReviewMode(container: HTMLElement, mode: ReviewMode): boolean;
|