@file-viewer/docx 0.3.33 → 0.3.35
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 +15397 -4
- package/dist/docx-preview.min.js +25 -4
- package/dist/docx-preview.min.mjs +25 -4
- package/dist/docx-preview.mjs +15396 -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 +567 -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,7 @@
|
|
|
1
|
+
export interface EmfToSvgOptions {
|
|
2
|
+
maxRecords?: number;
|
|
3
|
+
maxShapes?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare function isEmfBinary(data: Uint8Array): boolean;
|
|
6
|
+
export declare function convertEmfToSvgDataUrl(data: Uint8Array, options?: EmfToSvgOptions): string | null;
|
|
7
|
+
export declare function convertEmfToSvg(data: Uint8Array, options?: EmfToSvgOptions): string | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface WmfToSvgOptions {
|
|
2
|
+
maxRecords?: number;
|
|
3
|
+
maxShapes?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare function isWmfBinary(data: Uint8Array): boolean;
|
|
6
|
+
export declare function convertWmfToSvgDataUrl(data: Uint8Array, options?: WmfToSvgOptions): string | null;
|
|
7
|
+
export declare function convertWmfToSvg(data: Uint8Array, options?: WmfToSvgOptions): string | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OpenXmlElementBase, DomType } from "../document/dom";
|
|
2
|
+
export declare abstract class WmlBaseNote implements OpenXmlElementBase {
|
|
3
|
+
type: DomType;
|
|
4
|
+
id: string;
|
|
5
|
+
noteType: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class WmlFootnote extends WmlBaseNote {
|
|
8
|
+
type: DomType;
|
|
9
|
+
}
|
|
10
|
+
export declare class WmlEndnote extends WmlBaseNote {
|
|
11
|
+
type: DomType;
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { OpenXmlPackage } from "../common/open-xml-package";
|
|
2
|
+
import { Part } from "../common/part";
|
|
3
|
+
import { DocumentParser } from "../document-parser";
|
|
4
|
+
import { WmlBaseNote, WmlEndnote, WmlFootnote } from "./elements";
|
|
5
|
+
export declare class BaseNotePart<T extends WmlBaseNote> extends Part {
|
|
6
|
+
protected _documentParser: DocumentParser;
|
|
7
|
+
notes: T[];
|
|
8
|
+
constructor(pkg: OpenXmlPackage, path: string, parser: DocumentParser);
|
|
9
|
+
}
|
|
10
|
+
export declare class FootnotesPart extends BaseNotePart<WmlFootnote> {
|
|
11
|
+
constructor(pkg: OpenXmlPackage, path: string, parser: DocumentParser);
|
|
12
|
+
parseXml(root: Element): void;
|
|
13
|
+
}
|
|
14
|
+
export declare class EndnotesPart extends BaseNotePart<WmlEndnote> {
|
|
15
|
+
constructor(pkg: OpenXmlPackage, path: string, parser: DocumentParser);
|
|
16
|
+
parseXml(root: Element): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { XmlParser } from '../parser/xml-parser';
|
|
2
|
+
export type NoteKind = 'footnote' | 'endnote';
|
|
3
|
+
export type NoteRestart = 'continuous' | 'eachSect' | 'eachPage';
|
|
4
|
+
export interface NoteProperties {
|
|
5
|
+
/** Retained for compatibility with previously parsed settings snapshots. */
|
|
6
|
+
nummeringFormat?: string;
|
|
7
|
+
numberingFormat?: string;
|
|
8
|
+
start?: number;
|
|
9
|
+
restart?: NoteRestart;
|
|
10
|
+
defaultNoteIds?: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare function parseNoteProperties(element: Element, xml: XmlParser): NoteProperties;
|
|
13
|
+
export interface EffectiveNoteProperties {
|
|
14
|
+
format: string;
|
|
15
|
+
start: number;
|
|
16
|
+
restart: NoteRestart;
|
|
17
|
+
}
|
|
18
|
+
export declare function resolveNoteProperties(document: NoteProperties, section: NoteProperties): EffectiveNoteProperties;
|
|
19
|
+
export interface NoteAssignment {
|
|
20
|
+
id: string;
|
|
21
|
+
kind: NoteKind;
|
|
22
|
+
custom: boolean;
|
|
23
|
+
value: number | null;
|
|
24
|
+
properties: EffectiveNoteProperties;
|
|
25
|
+
}
|
|
26
|
+
/** Numbering scope is independent of layout ownership and source note IDs. */
|
|
27
|
+
export declare class NoteNumbering {
|
|
28
|
+
assignments: Map<string, NoteAssignment>;
|
|
29
|
+
private counters;
|
|
30
|
+
assign(kind: NoteKind, id: string, custom: boolean, properties: EffectiveNoteProperties, section: string, page: string): NoteAssignment;
|
|
31
|
+
}
|
|
32
|
+
/** Note reference labels follow the note numbering formats, not field-column names. */
|
|
33
|
+
export declare function formatNoteLabel(assignment: NoteAssignment): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OpenXmlPackage } from "../common/open-xml-package";
|
|
2
|
+
import { Part } from "../common/part";
|
|
3
|
+
import { DocumentParser } from "../document-parser";
|
|
4
|
+
import { IDomNumbering } from "../document/dom";
|
|
5
|
+
import { AbstractNumbering, Numbering, NumberingBulletPicture, NumberingPartProperties } from "./numbering";
|
|
6
|
+
export declare class NumberingPart extends Part implements NumberingPartProperties {
|
|
7
|
+
private _documentParser;
|
|
8
|
+
constructor(pkg: OpenXmlPackage, path: string, parser: DocumentParser);
|
|
9
|
+
numberings: Numbering[];
|
|
10
|
+
abstractNumberings: AbstractNumbering[];
|
|
11
|
+
bulletPictures: NumberingBulletPicture[];
|
|
12
|
+
domNumberings: IDomNumbering[];
|
|
13
|
+
parseXml(root: Element): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ParagraphProperties } from "../document/paragraph";
|
|
2
|
+
import { RunProperties } from "../document/run";
|
|
3
|
+
import { XmlParser } from "../parser/xml-parser";
|
|
4
|
+
export interface NumberingPartProperties {
|
|
5
|
+
numberings: Numbering[];
|
|
6
|
+
abstractNumberings: AbstractNumbering[];
|
|
7
|
+
bulletPictures: NumberingBulletPicture[];
|
|
8
|
+
}
|
|
9
|
+
export interface Numbering {
|
|
10
|
+
id: string;
|
|
11
|
+
abstractId: string;
|
|
12
|
+
overrides: NumberingLevelOverride[];
|
|
13
|
+
}
|
|
14
|
+
export interface NumberingLevelOverride {
|
|
15
|
+
level: number;
|
|
16
|
+
start: number;
|
|
17
|
+
numberingLevel: NumberingLevel;
|
|
18
|
+
}
|
|
19
|
+
export interface AbstractNumbering {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
multiLevelType: "singleLevel" | "multiLevel" | "hybridMultilevel" | string;
|
|
23
|
+
levels: NumberingLevel[];
|
|
24
|
+
numberingStyleLink: string;
|
|
25
|
+
styleLink: string;
|
|
26
|
+
}
|
|
27
|
+
export interface NumberingLevel {
|
|
28
|
+
level: number;
|
|
29
|
+
start: string;
|
|
30
|
+
restart: number;
|
|
31
|
+
format: 'lowerRoman' | 'lowerLetter' | string;
|
|
32
|
+
text: string;
|
|
33
|
+
justification: string;
|
|
34
|
+
bulletPictureId: string;
|
|
35
|
+
paragraphStyle: string;
|
|
36
|
+
paragraphProps: ParagraphProperties;
|
|
37
|
+
runProps: RunProperties;
|
|
38
|
+
}
|
|
39
|
+
export interface NumberingBulletPicture {
|
|
40
|
+
id: string;
|
|
41
|
+
referenceId: string;
|
|
42
|
+
style: string;
|
|
43
|
+
}
|
|
44
|
+
export declare function parseNumberingPart(elem: Element, xml: XmlParser): NumberingPartProperties;
|
|
45
|
+
export declare function parseNumbering(elem: Element, xml: XmlParser): Numbering;
|
|
46
|
+
export declare function parseAbstractNumbering(elem: Element, xml: XmlParser): AbstractNumbering;
|
|
47
|
+
export declare function parseNumberingLevel(elem: Element, xml: XmlParser): NumberingLevel;
|
|
48
|
+
export declare function parseNumberingLevelOverrride(elem: Element, xml: XmlParser): NumberingLevelOverride;
|
|
49
|
+
export declare function parseNumberingBulletPicture(elem: Element, xml: XmlParser): NumberingBulletPicture;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Length, LengthUsageType } from "../document/common";
|
|
2
|
+
/** XML operations required by the OOXML parser, supplied by the active runtime. */
|
|
3
|
+
export interface XmlRuntime {
|
|
4
|
+
parse(source: string): Document;
|
|
5
|
+
serialize(node: Node): string;
|
|
6
|
+
}
|
|
7
|
+
/** Configure the parser before handling documents in a runtime without browser XML APIs. */
|
|
8
|
+
export declare function setXmlRuntime(value: XmlRuntime): void;
|
|
9
|
+
export declare function parseXmlString(xmlString: string, trimXmlDeclaration?: boolean): Document;
|
|
10
|
+
export declare function serializeXmlString(elem: Node): string;
|
|
11
|
+
export declare class XmlParser {
|
|
12
|
+
elements(elem: Element, localName?: string): Element[];
|
|
13
|
+
element(elem: Element, localName: string): Element;
|
|
14
|
+
elementAttr(elem: Element, localName: string, attrLocalName: string): string;
|
|
15
|
+
attrs(elem: Element): Attr[];
|
|
16
|
+
attr(elem: Element, localName: string): string;
|
|
17
|
+
private rawAttr;
|
|
18
|
+
private descendantAttr;
|
|
19
|
+
private cnfStyleValue;
|
|
20
|
+
intAttr(node: Element, attrName: string, defaultValue?: number): number;
|
|
21
|
+
hexAttr(node: Element, attrName: string, defaultValue?: number): number;
|
|
22
|
+
floatAttr(node: Element, attrName: string, defaultValue?: number): number;
|
|
23
|
+
boolAttr(node: Element, attrName: string, defaultValue?: boolean): boolean;
|
|
24
|
+
lengthAttr(node: Element, attrName: string, usage?: LengthUsageType): Length;
|
|
25
|
+
}
|
|
26
|
+
declare const globalXmlParser: XmlParser;
|
|
27
|
+
export default globalXmlParser;
|
package/dist/review.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Word-compatible tracked-change display modes. */
|
|
2
|
+
export type ReviewMode = "final" | "original" | "simple" | "all";
|
|
3
|
+
export type ReviewModeOption = ReviewMode | "auto";
|
|
4
|
+
export type ReviewChangeKind = "insert" | "delete" | "move-from" | "move-to" | "format" | "comment";
|
|
5
|
+
export type ReviewChangePresentation = "inline" | "balloon";
|
|
6
|
+
export interface ReviewFormatChange {
|
|
7
|
+
property: string;
|
|
8
|
+
before?: string;
|
|
9
|
+
after?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ReviewChange {
|
|
12
|
+
id?: string;
|
|
13
|
+
/** All OOXML revision ids represented by this logical Word review item. */
|
|
14
|
+
ids?: string[];
|
|
15
|
+
kind: ReviewChangeKind;
|
|
16
|
+
author?: string;
|
|
17
|
+
date?: string;
|
|
18
|
+
text: string;
|
|
19
|
+
/** Word keeps insertions inline and places deletions/formatting/comments in balloons. */
|
|
20
|
+
presentation?: ReviewChangePresentation;
|
|
21
|
+
formatChanges?: ReviewFormatChange[];
|
|
22
|
+
}
|
|
23
|
+
export interface ReviewModeOptions {
|
|
24
|
+
reviewMode?: ReviewModeOption;
|
|
25
|
+
renderChanges?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function resolveReviewMode(options?: ReviewModeOptions): ReviewMode;
|
|
28
|
+
/** True only when the caller explicitly enabled the review-preview surface. */
|
|
29
|
+
export declare function isReviewPreviewEnabled(options?: ReviewModeOptions): boolean;
|
|
30
|
+
export declare function reviewModeShowsInsertions(mode: ReviewMode): boolean;
|
|
31
|
+
export declare function reviewModeShowsDeletions(mode: ReviewMode): boolean;
|
|
32
|
+
/** Change review visibility only; use renderDocument for paragraph/pagination changes. */
|
|
33
|
+
export declare function setDocxReviewMode(container: HTMLElement, mode: ReviewMode): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Collect Word-level review items rather than exposing every raw OOXML wrapper.
|
|
36
|
+
*
|
|
37
|
+
* Word producers may split one edit into many adjacent w:ins/w:del elements and
|
|
38
|
+
* may nest a later deletion inside an earlier insertion. Text is therefore
|
|
39
|
+
* assigned to the innermost active revision and adjacent fragments from the
|
|
40
|
+
* same author/time session are coalesced inside each paragraph.
|
|
41
|
+
*/
|
|
42
|
+
export declare function collectDocxReviewChanges(documentOrRoot: any): ReviewChange[];
|
|
43
|
+
export declare function resolveDocxReviewState(documentOrRoot: any, requested: ReviewModeOption | null | undefined): {
|
|
44
|
+
enabled: boolean;
|
|
45
|
+
mode: ReviewMode;
|
|
46
|
+
automatic: boolean;
|
|
47
|
+
changeCount: number;
|
|
48
|
+
};
|
|
49
|
+
export declare function reviewAuthorColor(author?: string): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize a document-authored hyperlink and reject protocols that can execute
|
|
3
|
+
* script, address local files, or escape the host's link policy. Relative URLs
|
|
4
|
+
* remain available because they resolve within the embedding application.
|
|
5
|
+
*/
|
|
6
|
+
export declare function sanitizeDocumentHyperlink(value: string): string | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type TrustedHTMLLike = string | object;
|
|
2
|
+
/** Brand OOXML only for the inert XML parser sink on the browser main thread. */
|
|
3
|
+
export declare function trustedXmlForParsing(xml: string): TrustedHTMLLike;
|
|
4
|
+
/**
|
|
5
|
+
* Mount explicitly enabled altChunk HTML only after removing active elements,
|
|
6
|
+
* event handlers, CSS and all URL-bearing attributes. The iframe itself keeps
|
|
7
|
+
* a maximally restricted sandbox and does not receive raw document input.
|
|
8
|
+
*/
|
|
9
|
+
export declare function setSafeAltChunkSrcdoc(frame: HTMLIFrameElement, html: string): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OpenXmlPackage } from "../common/open-xml-package";
|
|
2
|
+
import { Part } from "../common/part";
|
|
3
|
+
import { WmlSettings } from "./settings";
|
|
4
|
+
export declare class SettingsPart extends Part {
|
|
5
|
+
settings: WmlSettings;
|
|
6
|
+
constructor(pkg: OpenXmlPackage, path: string);
|
|
7
|
+
parseXml(root: Element): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Length } from "../document/common";
|
|
2
|
+
import { XmlParser } from "../parser/xml-parser";
|
|
3
|
+
import { NoteProperties } from "../notes/properties";
|
|
4
|
+
export { parseNoteProperties } from "../notes/properties";
|
|
5
|
+
export type { NoteProperties } from "../notes/properties";
|
|
6
|
+
export interface WmlSettings {
|
|
7
|
+
defaultTabStop: Length;
|
|
8
|
+
footnoteProps: NoteProperties;
|
|
9
|
+
endnoteProps: NoteProperties;
|
|
10
|
+
autoHyphenation: boolean;
|
|
11
|
+
kinsoku: boolean;
|
|
12
|
+
overflowPunctuation: boolean;
|
|
13
|
+
topLinePunctuation: boolean;
|
|
14
|
+
autoSpaceDE: boolean;
|
|
15
|
+
autoSpaceDN: boolean;
|
|
16
|
+
noLineBreaksAfter: string;
|
|
17
|
+
noLineBreaksBefore: string;
|
|
18
|
+
/** True when w:evenAndOddHeaders enables distinct even-page header/footer references. */
|
|
19
|
+
evenAndOddHeaders: boolean;
|
|
20
|
+
/** True when the compatibility setting allows document grid line pitch inside table cells. */
|
|
21
|
+
adjustLineHeightInTable: boolean;
|
|
22
|
+
/** True when w:splitPgBreakAndParaMark moves a trailing page-break paragraph mark forward. */
|
|
23
|
+
splitPageBreakAndParagraphMark: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function parseSettings(elem: Element, xml: XmlParser): WmlSettings;
|
|
@@ -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 { IDomStyle } from "../document/style";
|
|
5
|
+
export declare class StylesPart extends Part {
|
|
6
|
+
styles: IDomStyle[];
|
|
7
|
+
private _documentParser;
|
|
8
|
+
constructor(pkg: OpenXmlPackage, path: string, parser: DocumentParser);
|
|
9
|
+
parseXml(root: Element): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OpenXmlPackage } from "../common/open-xml-package";
|
|
2
|
+
import { Part } from "../common/part";
|
|
3
|
+
import { DmlTheme } from "./theme";
|
|
4
|
+
export declare class ThemePart extends Part {
|
|
5
|
+
theme: DmlTheme;
|
|
6
|
+
constructor(pkg: OpenXmlPackage, path: string);
|
|
7
|
+
parseXml(root: Element): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { XmlParser } from "../parser/xml-parser";
|
|
2
|
+
export declare class DmlTheme {
|
|
3
|
+
colorScheme: DmlColorScheme;
|
|
4
|
+
fontScheme: DmlFontScheme;
|
|
5
|
+
}
|
|
6
|
+
export interface DmlColorScheme {
|
|
7
|
+
name: string;
|
|
8
|
+
colors: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export interface DmlFontScheme {
|
|
11
|
+
name: string;
|
|
12
|
+
majorFont: DmlFormInfo;
|
|
13
|
+
minorFont: DmlFormInfo;
|
|
14
|
+
}
|
|
15
|
+
export interface DmlFormInfo {
|
|
16
|
+
latinTypeface: string;
|
|
17
|
+
eaTypeface: string;
|
|
18
|
+
csTypeface: string;
|
|
19
|
+
scriptTypefaces: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
export declare function themeScriptForLanguage(language: string): string;
|
|
22
|
+
export declare function parseTheme(elem: Element, xml: XmlParser): DmlTheme;
|
|
23
|
+
export declare function parseColorScheme(elem: Element, xml: XmlParser): DmlColorScheme;
|
|
24
|
+
export declare function parseFontScheme(elem: Element, xml: XmlParser): DmlFontScheme;
|
|
25
|
+
export declare function parseFontInfo(elem: Element, xml: XmlParser): DmlFormInfo;
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare function escapeClassName(className: string): string;
|
|
2
|
+
export declare function encloseFontFamily(fontFamily: string): string;
|
|
3
|
+
export declare function isEastAsianFontFamily(typeface: string): boolean;
|
|
4
|
+
export declare function eastAsianFontFamilyStack(typeface: string, script?: string): string[];
|
|
5
|
+
/** Common Founder/WPS family and PostScript aliases. No font binary is bundled. */
|
|
6
|
+
export declare function fangzhengFontFamilyAliases(typeface: string): string[];
|
|
7
|
+
export declare function splitPath(path: string): [string, string];
|
|
8
|
+
export declare function resolvePath(path: string, base: string): string;
|
|
9
|
+
export declare function keyBy<T = any>(array: T[], by: (x: T) => any): Record<any, T>;
|
|
10
|
+
export declare function blobToBase64(blob: Blob): Promise<string>;
|
|
11
|
+
export declare function isObject(item: any): boolean;
|
|
12
|
+
export declare function isString(item: unknown): item is string;
|
|
13
|
+
export declare function mergeDeep(target: any, ...sources: any[]): any;
|
|
14
|
+
export declare function parseCssRules(text: string): Record<string, string>;
|
|
15
|
+
export declare function formatCssRules(style: Record<string, string>): string;
|
|
16
|
+
export declare function asArray<T>(val: T | T[]): T[];
|
|
17
|
+
export declare function clamp(val: any, min: any, max: any): any;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DocumentParser } from '../document-parser';
|
|
2
|
+
import { OpenXmlElementBase, DomType } from '../document/dom';
|
|
3
|
+
export declare class VmlElement extends OpenXmlElementBase {
|
|
4
|
+
type: DomType;
|
|
5
|
+
tagName: string;
|
|
6
|
+
cssStyleText?: string;
|
|
7
|
+
attrs: Record<string, string>;
|
|
8
|
+
isGroup?: boolean;
|
|
9
|
+
coordOrigin?: [number, number];
|
|
10
|
+
coordSize?: [number, number];
|
|
11
|
+
textInset?: [string, string, string, string];
|
|
12
|
+
rotation?: number;
|
|
13
|
+
wrapType?: string;
|
|
14
|
+
imageHref?: {
|
|
15
|
+
id: string;
|
|
16
|
+
title: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare function parseVmlElement(elem: Element, parser: DocumentParser): VmlElement;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { DocumentParser } from './document-parser';
|
|
2
|
+
import { ExternalResourcePolicy, Relationship } from './common/relationship';
|
|
3
|
+
import { Part } from './common/part';
|
|
4
|
+
import { FontTablePart } from './font-table/font-table';
|
|
5
|
+
import { DocumentPart } from './document/document-part';
|
|
6
|
+
import { NumberingPart } from './numbering/numbering-part';
|
|
7
|
+
import { StylesPart } from './styles/styles-part';
|
|
8
|
+
import { ExtendedPropsPart } from "./document-props/extended-props-part";
|
|
9
|
+
import { CorePropsPart } from "./document-props/core-props-part";
|
|
10
|
+
import { ThemePart } from "./theme/theme-part";
|
|
11
|
+
import { EndnotesPart, FootnotesPart } from "./notes/parts";
|
|
12
|
+
import { SettingsPart } from "./settings/settings-part";
|
|
13
|
+
import { CommentsPart } from "./comments/comments-part";
|
|
14
|
+
import { CommentsExtendedPart } from "./comments/comments-extended-part";
|
|
15
|
+
import { ContentType } from "./common/content-types";
|
|
16
|
+
/** Worker 快照中的单个 part,用于跨线程传递已解析的文档结构。 */
|
|
17
|
+
export interface WordDocumentSnapshotPart {
|
|
18
|
+
kind: string;
|
|
19
|
+
path: string;
|
|
20
|
+
rels?: Relationship[];
|
|
21
|
+
data: any;
|
|
22
|
+
}
|
|
23
|
+
/** Worker 到主线程的文档快照,避免把不可克隆的类实例直接 postMessage。 */
|
|
24
|
+
export interface WordDocumentSnapshot {
|
|
25
|
+
rels: Relationship[];
|
|
26
|
+
contentTypes: ContentType[];
|
|
27
|
+
parts: WordDocumentSnapshotPart[];
|
|
28
|
+
assetDataUrls: Record<string, string>;
|
|
29
|
+
textParts: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* DOCX 包装类。
|
|
33
|
+
* 管理 OPC 包、relationship、content types 和各类 Word part 的懒加载,是解析器与渲染器共享的文档上下文。
|
|
34
|
+
*/
|
|
35
|
+
export declare class WordDocument {
|
|
36
|
+
private _package;
|
|
37
|
+
private _parser;
|
|
38
|
+
private _options;
|
|
39
|
+
rels: Relationship[];
|
|
40
|
+
parts: Part[];
|
|
41
|
+
partsMap: Record<string, Part>;
|
|
42
|
+
contentTypes: ContentType[];
|
|
43
|
+
documentPart: DocumentPart;
|
|
44
|
+
fontTablePart: FontTablePart;
|
|
45
|
+
numberingPart: NumberingPart;
|
|
46
|
+
stylesPart: StylesPart;
|
|
47
|
+
footnotesPart: FootnotesPart;
|
|
48
|
+
endnotesPart: EndnotesPart;
|
|
49
|
+
themePart: ThemePart;
|
|
50
|
+
corePropsPart: CorePropsPart;
|
|
51
|
+
extendedPropsPart: ExtendedPropsPart;
|
|
52
|
+
settingsPart: SettingsPart;
|
|
53
|
+
commentsPart: CommentsPart;
|
|
54
|
+
commentsExtendedPart: CommentsExtendedPart;
|
|
55
|
+
private _snapshotAssetDataUrls;
|
|
56
|
+
private _snapshotTextParts;
|
|
57
|
+
/** 从 Worker 快照恢复 WordDocument,主要服务于 parseAsyncInWorker。 */
|
|
58
|
+
static fromSnapshot(snapshot: WordDocumentSnapshot, options: any): WordDocument;
|
|
59
|
+
/** 打开 DOCX/ZIP 包并加载顶层关系指向的核心 part。 */
|
|
60
|
+
static load(blob: Blob | any, parser: DocumentParser, options: any): Promise<WordDocument>;
|
|
61
|
+
private restoreSnapshotPart;
|
|
62
|
+
createSnapshot(): Promise<WordDocumentSnapshot>;
|
|
63
|
+
private snapshotPart;
|
|
64
|
+
private preloadSnapshotRelationshipTargets;
|
|
65
|
+
private blobWithContentType;
|
|
66
|
+
save(type?: string): Promise<any>;
|
|
67
|
+
private loadRelationshipPart;
|
|
68
|
+
loadRelationshipXml(id: string, part?: Part): Promise<Document>;
|
|
69
|
+
loadRelationshipText(id: string, part?: Part): Promise<string>;
|
|
70
|
+
loadRelationshipBlobUrl(id: string, part?: Part, externalResourcePolicy?: ExternalResourcePolicy): Promise<string>;
|
|
71
|
+
loadDocumentImage(id: string, part?: Part, externalResourcePolicy?: ExternalResourcePolicy): Promise<string>;
|
|
72
|
+
loadNumberingImage(id: string): Promise<string>;
|
|
73
|
+
loadFont(id: string, key: string): Promise<string>;
|
|
74
|
+
loadAltChunk(id: string, part?: Part): Promise<string>;
|
|
75
|
+
private blobToURL;
|
|
76
|
+
private loadPackageAssetUrl;
|
|
77
|
+
private loadPackageAssetDataUrl;
|
|
78
|
+
private convertMetafileAsset;
|
|
79
|
+
private isConvertibleMetafileAsset;
|
|
80
|
+
private defaultMetafileContentType;
|
|
81
|
+
private contentTypeForPath;
|
|
82
|
+
findPartByRelId(id: string, basePart?: Part): Part;
|
|
83
|
+
getRelById(part: Part, id: string): Relationship;
|
|
84
|
+
getPathById(part: Part, id: string): string;
|
|
85
|
+
/** 解析 relationship target 为规范化包内路径。 */
|
|
86
|
+
resolveRelationshipTarget(part: Part, rel: Relationship): string;
|
|
87
|
+
}
|
|
88
|
+
/** 解码 Word 嵌入字体的 XOR 混淆头,返回可交给浏览器加载的字体字节。 */
|
|
89
|
+
export declare function deobfuscate(data: Uint8Array, guidKey: string): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/docx",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.35",
|
|
4
4
|
"description": "Pure HTML DOCX renderer fork for browser-based Word previews.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -24,44 +24,46 @@
|
|
|
24
24
|
"url": "git+https://github.com/flyfish-dev/docxjs.git"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"jszip": ">=3.
|
|
27
|
+
"jszip": ">=3.10.2",
|
|
28
|
+
"@xmldom/xmldom": "^0.9.12"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"rollup": "^4.9.1",
|
|
31
|
-
"@
|
|
32
|
+
"@types/node": "24.19.1",
|
|
32
33
|
"@rollup/plugin-terser": "^1.0.0",
|
|
33
34
|
"@rollup/plugin-typescript": "^12.1.4",
|
|
34
35
|
"terser": "^5.43.1",
|
|
35
36
|
"jasmine-core": "^5.1.0",
|
|
36
|
-
"
|
|
37
|
-
"karma-chrome-launcher": "^3.1.0",
|
|
38
|
-
"karma-firefox-launcher": "^2.1.2",
|
|
39
|
-
"karma-jasmine": "^5.0.0",
|
|
37
|
+
"playwright": "1.61.1",
|
|
40
38
|
"tslib": "^2.4.0",
|
|
41
|
-
"typescript": "^5.0.3"
|
|
39
|
+
"typescript": "^5.0.3",
|
|
40
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
41
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
42
|
+
"jsdom": "^27.4.0"
|
|
42
43
|
},
|
|
43
44
|
"overrides": {
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"brace-expansion": "1.1.18",
|
|
47
|
-
"serialize-javascript": "7.1.0",
|
|
48
|
-
"socket.io-parser": "4.2.7"
|
|
45
|
+
"brace-expansion": "1.1.21",
|
|
46
|
+
"serialize-javascript": "7.1.0"
|
|
49
47
|
},
|
|
50
48
|
"scripts": {
|
|
51
|
-
"build": "node scripts/
|
|
52
|
-
"build-prod": "
|
|
49
|
+
"build": "node scripts/clean-dist.cjs && rollup --config rollup.config.mjs && tsc --project tsconfig.build.json && node scripts/copy-build-assets.cjs",
|
|
50
|
+
"build-prod": "npm run build",
|
|
53
51
|
"typecheck": "tsc --noEmit --pretty false",
|
|
54
52
|
"watch": "rollup --config rollup.config.mjs --watch",
|
|
55
|
-
"verify": "npm run typecheck && npm run build && npm run test:regression",
|
|
53
|
+
"verify": "npm run typecheck && npm run build && npm run test:regression && npm run test:package && npm run test:worker",
|
|
56
54
|
"test:regression": "node scripts/run-regressions.cjs",
|
|
57
|
-
"e2e": "
|
|
58
|
-
"e2e:security": "
|
|
59
|
-
"e2e:chart": "
|
|
60
|
-
"e2e:header-guard": "
|
|
61
|
-
"e2e:native-revisions": "
|
|
62
|
-
"e2e-watch": "
|
|
55
|
+
"e2e": "node scripts/run-browser-specs.cjs all",
|
|
56
|
+
"e2e:security": "node scripts/run-browser-specs.cjs security",
|
|
57
|
+
"e2e:chart": "node scripts/run-browser-specs.cjs chart",
|
|
58
|
+
"e2e:header-guard": "node scripts/run-browser-specs.cjs header-guard",
|
|
59
|
+
"e2e:native-revisions": "node scripts/verify-native-revisions-browser.mjs",
|
|
60
|
+
"e2e-watch": "node scripts/run-browser-specs.cjs all --watch",
|
|
63
61
|
"build:rollup": "rollup --config rollup.config.mjs",
|
|
64
|
-
"build-prod:rollup": "rollup --config rollup.config.mjs
|
|
62
|
+
"build-prod:rollup": "rollup --config rollup.config.mjs",
|
|
63
|
+
"test:package": "node scripts/check-package.cjs",
|
|
64
|
+
"e2e:worker": "node scripts/check-worker-build.cjs",
|
|
65
|
+
"prepack": "npm run build",
|
|
66
|
+
"test:worker": "node scripts/check-worker-protocol.cjs"
|
|
65
67
|
},
|
|
66
68
|
"publishConfig": {
|
|
67
69
|
"access": "public"
|
|
@@ -78,9 +80,14 @@
|
|
|
78
80
|
"jsdelivr": "./dist/docx-preview.min.js",
|
|
79
81
|
"exports": {
|
|
80
82
|
".": {
|
|
81
|
-
"import":
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
"import": {
|
|
84
|
+
"types": "./dist/docx-preview-esm.d.mts",
|
|
85
|
+
"default": "./dist/docx-preview.mjs"
|
|
86
|
+
},
|
|
87
|
+
"require": {
|
|
88
|
+
"types": "./dist/docx-preview.d.ts",
|
|
89
|
+
"default": "./dist/docx-preview.js"
|
|
90
|
+
}
|
|
84
91
|
},
|
|
85
92
|
"./browser": "./dist/docx-preview.js",
|
|
86
93
|
"./browser.min": "./dist/docx-preview.min.js",
|