@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,20 @@
|
|
|
1
|
+
export interface AnchorAxis {
|
|
2
|
+
relative: string;
|
|
3
|
+
offset?: string;
|
|
4
|
+
align?: string;
|
|
5
|
+
offsetSpecified?: boolean;
|
|
6
|
+
alignSpecified?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface AnchorPosition {
|
|
9
|
+
horizontal: AnchorAxis;
|
|
10
|
+
vertical: AnchorAxis;
|
|
11
|
+
layoutInCell?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface AnchorFrame {
|
|
14
|
+
start: number;
|
|
15
|
+
size: number;
|
|
16
|
+
}
|
|
17
|
+
/** Resolve one axis only. The other axis cannot contribute indentation or offsets. */
|
|
18
|
+
export declare function resolveAnchorAxis(axis: AnchorAxis, reference: AnchorFrame, extent: number): number | null;
|
|
19
|
+
/** Measure engine-owned reference frames for a rendered anchor. No source offsets are changed. */
|
|
20
|
+
export declare function layoutAnchor(element: HTMLElement | SVGElement, position: AnchorPosition, className: string): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { LayoutGeneration } from './layout-readiness';
|
|
2
|
+
export interface CommentPresentation {
|
|
3
|
+
key: string;
|
|
4
|
+
descriptionId: string;
|
|
5
|
+
reference: HTMLElement;
|
|
6
|
+
references: HTMLElement[];
|
|
7
|
+
popup: HTMLDetailsElement;
|
|
8
|
+
summary: HTMLElement;
|
|
9
|
+
body: HTMLElement;
|
|
10
|
+
positionedReference?: HTMLElement;
|
|
11
|
+
revision: number;
|
|
12
|
+
opening?: AbortController;
|
|
13
|
+
open: boolean;
|
|
14
|
+
restoringOpen?: boolean;
|
|
15
|
+
layout?: Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
type Binding = {
|
|
18
|
+
generation: LayoutGeneration;
|
|
19
|
+
dispose: (preserveOpen?: boolean) => void;
|
|
20
|
+
};
|
|
21
|
+
/** Native comment content is a separate story, outside body paragraphs/links. */
|
|
22
|
+
export declare class CommentLayer {
|
|
23
|
+
private className;
|
|
24
|
+
private createLayer;
|
|
25
|
+
private layoutContent;
|
|
26
|
+
readonly records: Map<string, CommentPresentation>;
|
|
27
|
+
readonly root: HTMLElement;
|
|
28
|
+
private bindingRoot;
|
|
29
|
+
private binding;
|
|
30
|
+
constructor(className: string, createLayer: () => HTMLElement, layoutContent: (body: HTMLElement) => void);
|
|
31
|
+
add(record: CommentPresentation): void;
|
|
32
|
+
private references;
|
|
33
|
+
private place;
|
|
34
|
+
private close;
|
|
35
|
+
private activate;
|
|
36
|
+
/** Bind only after mounting; generation/disposal owns every persistent hook. */
|
|
37
|
+
bind(root: HTMLElement, generation: LayoutGeneration): Promise<void>;
|
|
38
|
+
sync(root: HTMLElement, binding?: Binding, refresh?: boolean): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Part } from "../common/part";
|
|
2
|
+
import { OpenXmlPackage } from "../common/open-xml-package";
|
|
3
|
+
export type CommentsExtended = {
|
|
4
|
+
paraId: string;
|
|
5
|
+
paraIdParent?: string;
|
|
6
|
+
done: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare class CommentsExtendedPart extends Part {
|
|
9
|
+
comments: CommentsExtended[];
|
|
10
|
+
commentMap: Record<string, CommentsExtended>;
|
|
11
|
+
constructor(pkg: OpenXmlPackage, path: string);
|
|
12
|
+
parseXml(root: Element): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Part } from "../common/part";
|
|
2
|
+
import { OpenXmlPackage } from "../common/open-xml-package";
|
|
3
|
+
import { DocumentParser } from "../document-parser";
|
|
4
|
+
import { WmlComment } from "./elements";
|
|
5
|
+
export declare class CommentsPart extends Part {
|
|
6
|
+
protected _documentParser: DocumentParser;
|
|
7
|
+
comments: WmlComment[];
|
|
8
|
+
commentMap: Record<string, WmlComment>;
|
|
9
|
+
constructor(pkg: OpenXmlPackage, path: string, parser: DocumentParser);
|
|
10
|
+
parseXml(root: Element): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DomType, OpenXmlElementBase } from "../document/dom";
|
|
2
|
+
export declare class WmlComment extends OpenXmlElementBase {
|
|
3
|
+
type: DomType;
|
|
4
|
+
id: string;
|
|
5
|
+
author: string;
|
|
6
|
+
initials: string;
|
|
7
|
+
date: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class WmlCommentReference extends OpenXmlElementBase {
|
|
10
|
+
id?: string;
|
|
11
|
+
type: DomType;
|
|
12
|
+
constructor(id?: string);
|
|
13
|
+
}
|
|
14
|
+
export declare class WmlCommentRangeStart extends OpenXmlElementBase {
|
|
15
|
+
id?: string;
|
|
16
|
+
type: DomType;
|
|
17
|
+
constructor(id?: string);
|
|
18
|
+
}
|
|
19
|
+
export declare class WmlCommentRangeEnd extends OpenXmlElementBase {
|
|
20
|
+
id?: string;
|
|
21
|
+
type: DomType;
|
|
22
|
+
constructor(id?: string);
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import JSZip, { OutputType } from "jszip";
|
|
2
|
+
import { XmlParser } from "../parser/xml-parser";
|
|
3
|
+
import { Relationship } from "./relationship";
|
|
4
|
+
import { ContentType } from "./content-types";
|
|
5
|
+
export interface OpenXmlPackageOptions {
|
|
6
|
+
trimXmlDeclaration: boolean;
|
|
7
|
+
keepOrigin: boolean;
|
|
8
|
+
/** @internal A Worker-selected ZIP implementation, kept local to this document. */
|
|
9
|
+
zipLoader?: (input: any) => Promise<JSZip>;
|
|
10
|
+
}
|
|
11
|
+
export declare class OpenXmlPackage {
|
|
12
|
+
private _zip;
|
|
13
|
+
options: OpenXmlPackageOptions;
|
|
14
|
+
xmlParser: XmlParser;
|
|
15
|
+
constructor(_zip: JSZip, options: OpenXmlPackageOptions);
|
|
16
|
+
get(path: string): any;
|
|
17
|
+
update(path: string, content: any): void;
|
|
18
|
+
static load(input: Blob | any, options: OpenXmlPackageOptions): Promise<OpenXmlPackage>;
|
|
19
|
+
save(type?: any): Promise<any>;
|
|
20
|
+
load(path: string, type?: OutputType | string): Promise<any>;
|
|
21
|
+
loadRelationships(path?: string): Promise<Relationship[]>;
|
|
22
|
+
loadContentTypes(): Promise<ContentType[]>;
|
|
23
|
+
/** @internal */
|
|
24
|
+
parseXmlDocument(txt: string): Document;
|
|
25
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OpenXmlPackage } from "./open-xml-package";
|
|
2
|
+
import { Relationship } from "./relationship";
|
|
3
|
+
export declare class Part {
|
|
4
|
+
protected _package: OpenXmlPackage;
|
|
5
|
+
path: string;
|
|
6
|
+
protected _xmlDocument: Document;
|
|
7
|
+
rels: Relationship[];
|
|
8
|
+
constructor(_package: OpenXmlPackage, path: string);
|
|
9
|
+
load(): Promise<any>;
|
|
10
|
+
save(): void;
|
|
11
|
+
protected parseXml(root: Element): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { XmlParser } from "../parser/xml-parser";
|
|
2
|
+
export interface Relationship {
|
|
3
|
+
id: string;
|
|
4
|
+
type: RelationshipTypes | string;
|
|
5
|
+
target: string;
|
|
6
|
+
targetMode: "" | "External" | string;
|
|
7
|
+
}
|
|
8
|
+
export type ExternalResourcePolicy = "allow" | "block";
|
|
9
|
+
export declare function isExternalRelationship(rel: Relationship): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve a document-authored external image target without allowing protocol
|
|
12
|
+
* confusion. data:/blob: resources are local browser resources and do not need
|
|
13
|
+
* the network opt-in; HTTP(S) is available only when explicitly allowed.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveExternalResourceTarget(rel: Relationship, policy?: ExternalResourcePolicy): string;
|
|
16
|
+
export declare enum RelationshipTypes {
|
|
17
|
+
OfficeDocument = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
|
|
18
|
+
FontTable = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",
|
|
19
|
+
Image = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
20
|
+
Numbering = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",
|
|
21
|
+
Styles = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",
|
|
22
|
+
StylesWithEffects = "http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects",
|
|
23
|
+
Theme = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
|
|
24
|
+
Settings = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",
|
|
25
|
+
WebSettings = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings",
|
|
26
|
+
Hyperlink = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
|
|
27
|
+
Footnotes = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",
|
|
28
|
+
Endnotes = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",
|
|
29
|
+
Footer = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",
|
|
30
|
+
Header = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",
|
|
31
|
+
ExtendedProperties = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",
|
|
32
|
+
CoreProperties = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",
|
|
33
|
+
CustomProperties = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/custom-properties",
|
|
34
|
+
Comments = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
|
|
35
|
+
CommentsExtended = "http://schemas.microsoft.com/office/2011/relationships/commentsExtended",
|
|
36
|
+
AltChunk = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk",
|
|
37
|
+
Chart = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",
|
|
38
|
+
ChartUserShapes = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes",
|
|
39
|
+
DiagramData = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData",
|
|
40
|
+
DiagramLayout = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout",
|
|
41
|
+
DiagramQuickStyle = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle",
|
|
42
|
+
DiagramColors = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors",
|
|
43
|
+
Ink = "http://schemas.microsoft.com/office/2007/relationships/ink",
|
|
44
|
+
ContentPart = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/contentPart"
|
|
45
|
+
}
|
|
46
|
+
export declare function parseRelationships(root: Element, xml: XmlParser): Relationship[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Word/Word Online 风格的暗色模式颜色转换。
|
|
3
|
+
*
|
|
4
|
+
* Word Online 编辑器内核(roosterjs)对每一个颜色做的不是"黑白互换"或"整体取反",
|
|
5
|
+
* 而是在 CIE Lab 色彩空间中只翻转明度(L),色相/彩度(a、b)保持不变,
|
|
6
|
+
* 并且用一个"基准明度"把结果钳制在一个安全范围内,使得:
|
|
7
|
+
* - 纯黑 (#000000) 精确变为纯白;
|
|
8
|
+
* - 纯白 (#ffffff) 变为 #333333(而不是刺眼的纯黑),这正是 baseLValue=21.247(#333333 的 L 值)的由来;
|
|
9
|
+
* - 任意彩色(例如深红 rgb(99,36,35))只是整体变亮,色调基本不变,从而保证暗色背景下的可读性,
|
|
10
|
+
* 同时不会像"整体反色"那样把红色变成青色。
|
|
11
|
+
*
|
|
12
|
+
* 算法与常量对齐 roosterjs(Word Online/Outlook 网页版编辑器内核)公开的
|
|
13
|
+
* `getDarkColor(color, baseLValue = 21.247)` 实现,RGB<->Lab 转换矩阵对齐
|
|
14
|
+
* `color-convert`(sRGB, D65 白点),以尽可能贴近 Word 官方效果。
|
|
15
|
+
*/
|
|
16
|
+
/** #333333 在 CIE Lab(D65)下的明度值,也是 roosterjs 的默认基准明度。 */
|
|
17
|
+
export declare const DEFAULT_DARK_MODE_BASE_L = 21.247;
|
|
18
|
+
/**
|
|
19
|
+
* 把一个浅色模式下的 CSS 颜色字面量换算为 Word 风格暗色模式颜色:在 CIE Lab 空间中
|
|
20
|
+
* 只翻转明度(L),色相/彩度(a、b)保持不变。无法解析为具体颜色的值(CSS 变量、
|
|
21
|
+
* currentColor、transparent、渐变等)原样返回。
|
|
22
|
+
*/
|
|
23
|
+
export declare function getDarkModeColor(value: string, baseLValue?: number): string;
|
|
24
|
+
/**
|
|
25
|
+
* 对一个已经解析好的内联样式对象做暗色模式换算:认识的颜色属性(含以 -color 结尾的
|
|
26
|
+
* CSS 自定义属性、边框简写等)会被换算,其余属性原样返回。当没有任何属性发生变化时
|
|
27
|
+
* 返回同一个对象引用,避免不必要的对象拷贝。
|
|
28
|
+
*/
|
|
29
|
+
export declare function applyDarkModeToStyle<T extends Record<string, any>>(style: T, baseLValue?: number): T;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { XmlParser } from "../parser/xml-parser";
|
|
2
|
+
import { OpenXmlElement } from "./dom";
|
|
3
|
+
export interface WmlBookmarkStart extends OpenXmlElement {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
colFirst: number;
|
|
7
|
+
colLast: number;
|
|
8
|
+
}
|
|
9
|
+
export interface WmlBookmarkEnd extends OpenXmlElement {
|
|
10
|
+
id: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function parseBookmarkStart(elem: Element, xml: XmlParser): WmlBookmarkStart;
|
|
13
|
+
export declare function parseBookmarkEnd(elem: Element, xml: XmlParser): WmlBookmarkEnd;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { XmlParser } from "../parser/xml-parser";
|
|
2
|
+
import { Length } from "./common";
|
|
3
|
+
export interface Border {
|
|
4
|
+
color: string;
|
|
5
|
+
type: string;
|
|
6
|
+
size: Length;
|
|
7
|
+
frame: boolean;
|
|
8
|
+
shadow: boolean;
|
|
9
|
+
offset: Length;
|
|
10
|
+
}
|
|
11
|
+
export interface Borders {
|
|
12
|
+
top: Border;
|
|
13
|
+
left: Border;
|
|
14
|
+
right: Border;
|
|
15
|
+
bottom: Border;
|
|
16
|
+
}
|
|
17
|
+
export declare function parseBorder(elem: Element, xml: XmlParser): Border;
|
|
18
|
+
export declare function parseBorders(elem: Element, xml: XmlParser): Borders;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { XmlParser } from "../parser/xml-parser";
|
|
2
|
+
export declare const ns: {
|
|
3
|
+
wordml: string;
|
|
4
|
+
drawingml: string;
|
|
5
|
+
picture: string;
|
|
6
|
+
wordprocessingCanvas: string;
|
|
7
|
+
wordprocessingGroup: string;
|
|
8
|
+
wordprocessingShape: string;
|
|
9
|
+
chart: string;
|
|
10
|
+
diagram: string;
|
|
11
|
+
relationship: string;
|
|
12
|
+
drawing2014: string;
|
|
13
|
+
ink2010: string;
|
|
14
|
+
word2010: string;
|
|
15
|
+
compatibility: string;
|
|
16
|
+
math: string;
|
|
17
|
+
};
|
|
18
|
+
export type LengthType = "px" | "pt" | "%" | "";
|
|
19
|
+
export type Length = string;
|
|
20
|
+
export interface Font {
|
|
21
|
+
name: string;
|
|
22
|
+
family: string;
|
|
23
|
+
}
|
|
24
|
+
export interface CommonProperties {
|
|
25
|
+
fontSize: Length;
|
|
26
|
+
color: string;
|
|
27
|
+
}
|
|
28
|
+
export type LengthUsageType = {
|
|
29
|
+
mul: number;
|
|
30
|
+
unit: LengthType;
|
|
31
|
+
min?: number;
|
|
32
|
+
max?: number;
|
|
33
|
+
};
|
|
34
|
+
export declare const LengthUsage: Record<string, LengthUsageType>;
|
|
35
|
+
export declare function convertLength(val: string, usage?: LengthUsageType): string;
|
|
36
|
+
export declare function convertBoolean(v: string, defaultValue?: boolean): boolean;
|
|
37
|
+
export declare function convertPercentage(val: string): number;
|
|
38
|
+
export declare function parseCommonProperty(elem: Element, props: CommonProperties, xml: XmlParser): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OpenXmlPackage } from "../common/open-xml-package";
|
|
2
|
+
import { Part } from "../common/part";
|
|
3
|
+
import { DocumentParser } from "../document-parser";
|
|
4
|
+
import { DocumentElement } from "./document";
|
|
5
|
+
export declare class DocumentPart extends Part {
|
|
6
|
+
private _documentParser;
|
|
7
|
+
constructor(pkg: OpenXmlPackage, path: string, parser: DocumentParser);
|
|
8
|
+
body: DocumentElement;
|
|
9
|
+
parseXml(root: Element): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
export declare enum DomType {
|
|
2
|
+
Document = "document",
|
|
3
|
+
Paragraph = "paragraph",
|
|
4
|
+
Run = "run",
|
|
5
|
+
Break = "break",
|
|
6
|
+
NoBreakHyphen = "noBreakHyphen",
|
|
7
|
+
Table = "table",
|
|
8
|
+
Row = "row",
|
|
9
|
+
Cell = "cell",
|
|
10
|
+
Hyperlink = "hyperlink",
|
|
11
|
+
SmartTag = "smartTag",
|
|
12
|
+
Drawing = "drawing",
|
|
13
|
+
Image = "image",
|
|
14
|
+
Text = "text",
|
|
15
|
+
Tab = "tab",
|
|
16
|
+
PositionalTab = "positionalTab",
|
|
17
|
+
SoftHyphen = "softHyphen",
|
|
18
|
+
Symbol = "symbol",
|
|
19
|
+
BookmarkStart = "bookmarkStart",
|
|
20
|
+
BookmarkEnd = "bookmarkEnd",
|
|
21
|
+
Footer = "footer",
|
|
22
|
+
Header = "header",
|
|
23
|
+
FootnoteReference = "footnoteReference",
|
|
24
|
+
EndnoteReference = "endnoteReference",
|
|
25
|
+
Footnote = "footnote",
|
|
26
|
+
Endnote = "endnote",
|
|
27
|
+
SimpleField = "simpleField",
|
|
28
|
+
ComplexField = "complexField",
|
|
29
|
+
Instruction = "instruction",
|
|
30
|
+
VmlPicture = "vmlPicture",
|
|
31
|
+
MmlMath = "mmlMath",
|
|
32
|
+
Shape = "shape",
|
|
33
|
+
MmlMathParagraph = "mmlMathParagraph",
|
|
34
|
+
MmlFraction = "mmlFraction",
|
|
35
|
+
MmlFunction = "mmlFunction",
|
|
36
|
+
MmlFunctionName = "mmlFunctionName",
|
|
37
|
+
MmlNumerator = "mmlNumerator",
|
|
38
|
+
MmlDenominator = "mmlDenominator",
|
|
39
|
+
MmlRadical = "mmlRadical",
|
|
40
|
+
MmlBase = "mmlBase",
|
|
41
|
+
MmlDegree = "mmlDegree",
|
|
42
|
+
MmlSuperscript = "mmlSuperscript",
|
|
43
|
+
MmlSubscript = "mmlSubscript",
|
|
44
|
+
MmlPreSubSuper = "mmlPreSubSuper",
|
|
45
|
+
MmlSubArgument = "mmlSubArgument",
|
|
46
|
+
MmlSuperArgument = "mmlSuperArgument",
|
|
47
|
+
MmlNary = "mmlNary",
|
|
48
|
+
MmlDelimiter = "mmlDelimiter",
|
|
49
|
+
MmlRun = "mmlRun",
|
|
50
|
+
MmlEquationArray = "mmlEquationArray",
|
|
51
|
+
MmlLimit = "mmlLimit",
|
|
52
|
+
MmlLimitLower = "mmlLimitLower",
|
|
53
|
+
MmlLimitUpper = "mmlLimitUpper",
|
|
54
|
+
MmlSubSuperscript = "mmlSubSuperscript",
|
|
55
|
+
MmlPhantom = "mmlPhantom",
|
|
56
|
+
MmlBorderBox = "mmlBorderBox",
|
|
57
|
+
MmlAccent = "mmlAccent",
|
|
58
|
+
MmlMatrix = "mmlMatrix",
|
|
59
|
+
MmlMatrixRow = "mmlMatrixRow",
|
|
60
|
+
MmlBox = "mmlBox",
|
|
61
|
+
MmlBar = "mmlBar",
|
|
62
|
+
MmlGroupChar = "mmlGroupChar",
|
|
63
|
+
VmlElement = "vmlElement",
|
|
64
|
+
Chart = "chart",
|
|
65
|
+
SmartArt = "smartArt",
|
|
66
|
+
Ink = "ink",
|
|
67
|
+
Ruby = "ruby",
|
|
68
|
+
RubyBase = "rubyBase",
|
|
69
|
+
RubyText = "rubyText",
|
|
70
|
+
Inserted = "inserted",
|
|
71
|
+
Deleted = "deleted",
|
|
72
|
+
DeletedText = "deletedText",
|
|
73
|
+
Comment = "comment",
|
|
74
|
+
CommentReference = "commentReference",
|
|
75
|
+
CommentRangeStart = "commentRangeStart",
|
|
76
|
+
CommentRangeEnd = "commentRangeEnd",
|
|
77
|
+
AltChunk = "altChunk"
|
|
78
|
+
}
|
|
79
|
+
export interface OpenXmlElement {
|
|
80
|
+
/** 可选的只读展示地址;不保存 XML 节点,也不改动原部件。 */
|
|
81
|
+
displayAddress?: string;
|
|
82
|
+
type: DomType;
|
|
83
|
+
children?: OpenXmlElement[];
|
|
84
|
+
cssStyle?: Record<string, string>;
|
|
85
|
+
props?: Record<string, any>;
|
|
86
|
+
styleName?: string;
|
|
87
|
+
className?: string;
|
|
88
|
+
parent?: OpenXmlElement;
|
|
89
|
+
}
|
|
90
|
+
export declare abstract class OpenXmlElementBase implements OpenXmlElement {
|
|
91
|
+
type: DomType;
|
|
92
|
+
children?: OpenXmlElement[];
|
|
93
|
+
cssStyle?: Record<string, string>;
|
|
94
|
+
props?: Record<string, any>;
|
|
95
|
+
className?: string;
|
|
96
|
+
styleName?: string;
|
|
97
|
+
parent?: OpenXmlElement;
|
|
98
|
+
}
|
|
99
|
+
export interface WmlHyperlink extends OpenXmlElement {
|
|
100
|
+
id?: string;
|
|
101
|
+
anchor?: string;
|
|
102
|
+
}
|
|
103
|
+
export interface WmlAltChunk extends OpenXmlElement {
|
|
104
|
+
id?: string;
|
|
105
|
+
}
|
|
106
|
+
export interface WmlSmartTag extends OpenXmlElement {
|
|
107
|
+
uri?: string;
|
|
108
|
+
element?: string;
|
|
109
|
+
}
|
|
110
|
+
export interface WmlNoteReference extends OpenXmlElement {
|
|
111
|
+
id: string;
|
|
112
|
+
/** Custom marks are authored content and do not consume an automatic number. */
|
|
113
|
+
customMarkFollows?: boolean;
|
|
114
|
+
}
|
|
115
|
+
export interface WmlBreak extends OpenXmlElement {
|
|
116
|
+
break: "page" | "column" | "line" | "lastRenderedPageBreak" | "textWrapping" | string;
|
|
117
|
+
}
|
|
118
|
+
export interface WmlText extends OpenXmlElement {
|
|
119
|
+
text: string;
|
|
120
|
+
}
|
|
121
|
+
export interface WmlSymbol extends OpenXmlElement {
|
|
122
|
+
font: string;
|
|
123
|
+
char: number;
|
|
124
|
+
}
|
|
125
|
+
export interface WmlTable extends OpenXmlElement {
|
|
126
|
+
columns?: WmlTableColumn[];
|
|
127
|
+
cellStyle?: Record<string, string>;
|
|
128
|
+
colBandSize?: number;
|
|
129
|
+
rowBandSize?: number;
|
|
130
|
+
}
|
|
131
|
+
export interface WmlTableRow extends OpenXmlElement {
|
|
132
|
+
isHeader?: boolean;
|
|
133
|
+
gridBefore?: number;
|
|
134
|
+
gridAfter?: number;
|
|
135
|
+
}
|
|
136
|
+
export interface WmlTableCell extends OpenXmlElement {
|
|
137
|
+
horizontalMerge?: 'restart' | 'continue' | string;
|
|
138
|
+
verticalMerge?: 'restart' | 'continue' | string;
|
|
139
|
+
span?: number;
|
|
140
|
+
}
|
|
141
|
+
export interface IDomRuby extends OpenXmlElement {
|
|
142
|
+
align?: string;
|
|
143
|
+
}
|
|
144
|
+
export interface IDomRubyText extends OpenXmlElement {
|
|
145
|
+
fontSize?: string;
|
|
146
|
+
}
|
|
147
|
+
export interface IDomImage extends OpenXmlElement {
|
|
148
|
+
src: string;
|
|
149
|
+
srcRect: number[];
|
|
150
|
+
rotation: number;
|
|
151
|
+
alt?: string;
|
|
152
|
+
title?: string;
|
|
153
|
+
}
|
|
154
|
+
export interface IDomShape extends OpenXmlElement {
|
|
155
|
+
alt?: string;
|
|
156
|
+
title?: string;
|
|
157
|
+
}
|
|
158
|
+
export interface IDomChart extends OpenXmlElement {
|
|
159
|
+
id?: string;
|
|
160
|
+
title?: string;
|
|
161
|
+
alt?: string;
|
|
162
|
+
}
|
|
163
|
+
export interface IDomSmartArt extends OpenXmlElement {
|
|
164
|
+
dataId?: string;
|
|
165
|
+
layoutId?: string;
|
|
166
|
+
styleId?: string;
|
|
167
|
+
colorId?: string;
|
|
168
|
+
title?: string;
|
|
169
|
+
alt?: string;
|
|
170
|
+
}
|
|
171
|
+
export interface IDomInk extends OpenXmlElement {
|
|
172
|
+
id?: string;
|
|
173
|
+
title?: string;
|
|
174
|
+
alt?: string;
|
|
175
|
+
}
|
|
176
|
+
export interface WmlTableColumn {
|
|
177
|
+
width?: string;
|
|
178
|
+
}
|
|
179
|
+
export interface IDomNumbering {
|
|
180
|
+
id: string;
|
|
181
|
+
level: number;
|
|
182
|
+
start: number;
|
|
183
|
+
pStyleName: string;
|
|
184
|
+
pStyle: Record<string, string>;
|
|
185
|
+
rStyle: Record<string, string>;
|
|
186
|
+
levelText?: string;
|
|
187
|
+
suff: string;
|
|
188
|
+
format?: string;
|
|
189
|
+
/**
|
|
190
|
+
* OOXML w:lvlRestart value. It is one-based; 0 means never restart.
|
|
191
|
+
* Undefined means the OOXML default: restart when the previous level is used.
|
|
192
|
+
*/
|
|
193
|
+
restart?: number;
|
|
194
|
+
bullet?: NumberingPicBullet;
|
|
195
|
+
}
|
|
196
|
+
export interface NumberingPicBullet {
|
|
197
|
+
id: number;
|
|
198
|
+
src: string;
|
|
199
|
+
style?: string;
|
|
200
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OpenXmlElement } from "./dom";
|
|
2
|
+
export interface WmlInstructionText extends OpenXmlElement {
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
export interface WmlFieldChar extends OpenXmlElement {
|
|
6
|
+
charType: 'begin' | 'end' | 'separate' | string;
|
|
7
|
+
lock: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface WmlFieldSimple extends OpenXmlElement {
|
|
10
|
+
instruction: string;
|
|
11
|
+
lock: boolean;
|
|
12
|
+
dirty: boolean;
|
|
13
|
+
children?: OpenXmlElement[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { XmlParser } from "../parser/xml-parser";
|
|
2
|
+
import { Length } from "./common";
|
|
3
|
+
export interface LineSpacing {
|
|
4
|
+
after: Length;
|
|
5
|
+
before: Length;
|
|
6
|
+
line: number;
|
|
7
|
+
lineRule: "atLeast" | "exact" | "exactly" | "auto";
|
|
8
|
+
}
|
|
9
|
+
export declare function parseLineSpacing(elem: Element, xml: XmlParser): LineSpacing;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OpenXmlElement } from './dom';
|
|
2
|
+
/**
|
|
3
|
+
* Word can save an authored break and a cached position for the same boundary.
|
|
4
|
+
* Coalesce only an adjacent, unambiguous pair. Whitespace, empty paragraphs,
|
|
5
|
+
* section changes, and unknown layout nodes keep their independent boundaries.
|
|
6
|
+
* The parsed model remains reusable: copy only ancestors of removed markers.
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeCachedPageBreaks(elements: OpenXmlElement[], isHiddenRevision: (element: OpenXmlElement) => boolean): OpenXmlElement[];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { OpenXmlElement } from "./dom";
|
|
2
|
+
import { CommonProperties, Length } from "./common";
|
|
3
|
+
import { Borders } from "./border";
|
|
4
|
+
import { SectionProperties } from "./section";
|
|
5
|
+
import { LineSpacing } from "./line-spacing";
|
|
6
|
+
import { XmlParser } from "../parser/xml-parser";
|
|
7
|
+
import { RunProperties } from "./run";
|
|
8
|
+
export interface WmlParagraph extends OpenXmlElement, ParagraphProperties {
|
|
9
|
+
}
|
|
10
|
+
export interface ParagraphFrame {
|
|
11
|
+
dropCap?: string;
|
|
12
|
+
width?: Length;
|
|
13
|
+
height?: Length;
|
|
14
|
+
horizontalPosition?: Length;
|
|
15
|
+
verticalPosition?: Length;
|
|
16
|
+
horizontalAnchor?: string;
|
|
17
|
+
verticalAnchor?: string;
|
|
18
|
+
horizontalAlignment?: string;
|
|
19
|
+
verticalAlignment?: string;
|
|
20
|
+
horizontalSpace?: Length;
|
|
21
|
+
verticalSpace?: Length;
|
|
22
|
+
heightRule?: string;
|
|
23
|
+
wrap?: string;
|
|
24
|
+
lines?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface ParagraphProperties extends CommonProperties {
|
|
27
|
+
sectionProps: SectionProperties;
|
|
28
|
+
tabs: ParagraphTab[];
|
|
29
|
+
numbering: ParagraphNumbering;
|
|
30
|
+
border: Borders;
|
|
31
|
+
textAlignment: "auto" | "baseline" | "bottom" | "center" | "top" | string;
|
|
32
|
+
lineSpacing: LineSpacing;
|
|
33
|
+
keepLines: boolean;
|
|
34
|
+
keepNext: boolean;
|
|
35
|
+
pageBreakBefore: boolean;
|
|
36
|
+
widowControl: boolean;
|
|
37
|
+
outlineLevel: number;
|
|
38
|
+
frame?: ParagraphFrame;
|
|
39
|
+
styleName?: string;
|
|
40
|
+
runProps: RunProperties;
|
|
41
|
+
}
|
|
42
|
+
export interface ParagraphTab {
|
|
43
|
+
style: "bar" | "center" | "clear" | "decimal" | "end" | "num" | "start" | "left" | "right";
|
|
44
|
+
leader: "none" | "dot" | "heavy" | "hyphen" | "middleDot" | "underscore";
|
|
45
|
+
position: Length;
|
|
46
|
+
}
|
|
47
|
+
export interface ParagraphNumbering {
|
|
48
|
+
id: string;
|
|
49
|
+
level: number;
|
|
50
|
+
}
|
|
51
|
+
export declare function parseParagraphProperties(elem: Element, xml: XmlParser): ParagraphProperties;
|
|
52
|
+
export declare function parseParagraphProperty(elem: Element, props: ParagraphProperties, xml: XmlParser): boolean;
|
|
53
|
+
export declare function parseTabs(elem: Element, xml: XmlParser): ParagraphTab[];
|
|
54
|
+
export declare function parseNumbering(elem: Element, xml: XmlParser): ParagraphNumbering;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { XmlParser } from "../parser/xml-parser";
|
|
2
|
+
import { CommonProperties } from "./common";
|
|
3
|
+
import { OpenXmlElement } from "./dom";
|
|
4
|
+
export interface WmlRun extends OpenXmlElement, RunProperties {
|
|
5
|
+
id?: string;
|
|
6
|
+
verticalAlign?: string;
|
|
7
|
+
fieldRun?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface RunProperties extends CommonProperties {
|
|
10
|
+
}
|
|
11
|
+
export declare function parseRunProperties(elem: Element, xml: XmlParser): RunProperties;
|
|
12
|
+
export declare function parseRunProperty(elem: Element, props: RunProperties, xml: XmlParser): boolean;
|