reamkit 1.15.1 → 1.15.3
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/dist/esm/core/arc-to-bezier.d.ts +23 -0
- package/dist/esm/core/arc-to-bezier.js +23 -0
- package/dist/esm/core/bidi/algorithm.d.ts +26 -0
- package/dist/esm/core/bidi/algorithm.js +21 -0
- package/dist/esm/core/bidi/char-types.d.ts +17 -0
- package/dist/esm/core/bidi/char-types.js +10 -0
- package/dist/esm/core/bidi/index.d.ts +42 -0
- package/dist/esm/core/bidi/index.js +27 -0
- package/dist/esm/core/bidi/segments.d.ts +22 -0
- package/dist/esm/core/bidi/segments.js +14 -0
- package/dist/esm/core/bytes.d.ts +20 -0
- package/dist/esm/core/bytes.js +24 -1
- package/dist/esm/core/converter/facade.d.ts +38 -1
- package/dist/esm/core/converter/facade.js +25 -0
- package/dist/esm/core/converter/project.d.ts +12 -0
- package/dist/esm/core/converter/project.js +11 -0
- package/dist/esm/core/converter/ream.d.ts +107 -0
- package/dist/esm/core/converter/ream.js +76 -0
- package/dist/esm/core/crypto/asn1.d.ts +77 -0
- package/dist/esm/core/crypto/asn1.js +65 -0
- package/dist/esm/core/crypto/cms.d.ts +25 -0
- package/dist/esm/core/crypto/cms.js +8 -0
- package/dist/esm/core/document-model/index.d.ts +7 -0
- package/dist/esm/core/document-model/types.d.ts +328 -0
- package/dist/esm/core/drawingml/chart-geometry.d.ts +125 -0
- package/dist/esm/core/drawingml/chart-geometry.js +96 -0
- package/dist/esm/core/drawingml/chart-parser.d.ts +34 -0
- package/dist/esm/core/drawingml/chart-parser.js +34 -0
- package/dist/esm/core/drawingml/chart-serializer.d.ts +12 -0
- package/dist/esm/core/drawingml/chart-serializer.js +12 -0
- package/dist/esm/core/drawingml/colors.d.ts +53 -0
- package/dist/esm/core/drawingml/colors.js +41 -0
- package/dist/esm/core/drawingml/preset-geometry.d.ts +30 -0
- package/dist/esm/core/drawingml/preset-geometry.js +30 -0
- package/dist/esm/core/drawingml/shape-render.d.ts +54 -0
- package/dist/esm/core/drawingml/shape-render.js +54 -0
- package/dist/esm/core/drawingml/sparkline-geometry.d.ts +15 -0
- package/dist/esm/core/drawingml/sparkline-geometry.js +13 -0
- package/dist/esm/core/drawingml/theme-parser.d.ts +11 -0
- package/dist/esm/core/drawingml/theme-parser.js +11 -0
- package/dist/esm/core/font/arabic-joining.d.ts +21 -0
- package/dist/esm/core/font/arabic-joining.js +16 -0
- package/dist/esm/core/font/binary-reader.d.ts +17 -0
- package/dist/esm/core/font/binary-reader.js +17 -0
- package/dist/esm/core/font/font-registry.d.ts +37 -0
- package/dist/esm/core/font/font-registry.js +31 -0
- package/dist/esm/core/font/measure.d.ts +20 -0
- package/dist/esm/core/font/measure.js +11 -0
- package/dist/esm/core/font/opentype-layout.d.ts +49 -0
- package/dist/esm/core/font/opentype-layout.js +37 -0
- package/dist/esm/core/font/ttf-parser.d.ts +32 -0
- package/dist/esm/core/font/ttf-parser.js +7 -0
- package/dist/esm/core/font/ttf-subset.d.ts +21 -0
- package/dist/esm/core/font/ttf-subset.js +21 -0
- package/dist/esm/core/fonts/provider.d.ts +8 -1
- package/dist/esm/core/fonts/provider.js +1 -0
- package/dist/esm/core/fonts/remote-fonts.d.ts +22 -0
- package/dist/esm/core/fonts/remote-fonts.js +16 -0
- package/dist/esm/core/hyphenation/index.d.ts +25 -0
- package/dist/esm/core/hyphenation/index.js +17 -0
- package/dist/esm/core/hyphenation/liang.d.ts +27 -0
- package/dist/esm/core/hyphenation/liang.js +14 -0
- package/dist/esm/core/images.d.ts +32 -0
- package/dist/esm/core/images.js +12 -0
- package/dist/esm/core/ir/adapters.d.ts +23 -0
- package/dist/esm/core/ir/features.d.ts +8 -0
- package/dist/esm/core/ir/features.js +1 -0
- package/dist/esm/core/ir/flow.d.ts +20 -0
- package/dist/esm/core/ir/index.d.ts +7 -0
- package/dist/esm/core/ir/loss.d.ts +12 -0
- package/dist/esm/core/ir/loss.js +8 -0
- package/dist/esm/core/ir/resources.d.ts +12 -0
- package/dist/esm/core/ir/resources.js +11 -0
- package/dist/esm/core/ir/sheet.d.ts +81 -0
- package/dist/esm/core/ir/units.d.ts +9 -0
- package/dist/esm/core/ir/units.js +2 -0
- package/dist/esm/core/line-breaker/cjk.d.ts +26 -0
- package/dist/esm/core/line-breaker/cjk.js +60 -0
- package/dist/esm/core/line-breaker/greedy.d.ts +14 -0
- package/dist/esm/core/line-breaker/greedy.js +14 -0
- package/dist/esm/core/line-breaker/index.d.ts +1 -0
- package/dist/esm/core/line-breaker/index.js +3 -0
- package/dist/esm/core/line-breaker/knuth-plass.d.ts +29 -5
- package/dist/esm/core/line-breaker/knuth-plass.js +10 -5
- package/dist/esm/core/numbering/apply.d.ts +19 -0
- package/dist/esm/core/numbering/apply.js +19 -0
- package/dist/esm/core/numbering/state.d.ts +15 -0
- package/dist/esm/core/numbering/state.js +15 -0
- package/dist/esm/core/ole/cfb.d.ts +19 -0
- package/dist/esm/core/ole/cfb.js +16 -0
- package/dist/esm/core/opc/core-properties.d.ts +12 -0
- package/dist/esm/core/opc/core-properties.js +5 -0
- package/dist/esm/core/opc/opc-writer.d.ts +24 -4
- package/dist/esm/core/opc/opc-writer.js +12 -0
- package/dist/esm/core/opc/package.d.ts +55 -0
- package/dist/esm/core/opc/package.js +49 -1
- package/dist/esm/core/opc/relationship-types.d.ts +8 -0
- package/dist/esm/core/opc/relationship-types.js +5 -0
- package/dist/esm/core/opc/relationships.d.ts +12 -0
- package/dist/esm/core/opc/relationships.js +7 -0
- package/dist/esm/core/po-helpers.d.ts +38 -0
- package/dist/esm/core/po-helpers.js +33 -0
- package/dist/esm/core/spreadsheet-model/types.d.ts +302 -0
- package/dist/esm/core/style-cascade/resolver.d.ts +31 -0
- package/dist/esm/core/style-cascade/resolver.js +31 -0
- package/dist/esm/core/style-cascade/table.d.ts +7 -0
- package/dist/esm/core/style-cascade/table.js +7 -0
- package/dist/esm/core/style-cascade/types.d.ts +27 -0
- package/dist/esm/core/style-cascade/types.js +2 -0
- package/dist/esm/core/vector.d.ts +67 -0
- package/dist/esm/core/vector.js +23 -0
- package/dist/esm/excel/activex-parser.d.ts +31 -0
- package/dist/esm/excel/activex-parser.js +24 -0
- package/dist/esm/excel/cell-reference.d.ts +14 -0
- package/dist/esm/excel/cell-reference.js +9 -0
- package/dist/esm/excel/column-bands.d.ts +29 -0
- package/dist/esm/excel/column-bands.js +27 -7
- package/dist/esm/excel/comments-parser.d.ts +19 -0
- package/dist/esm/excel/comments-parser.js +19 -0
- package/dist/esm/excel/conditional-format.d.ts +38 -0
- package/dist/esm/excel/conditional-format.js +25 -0
- package/dist/esm/excel/defined-name-ref.d.ts +21 -0
- package/dist/esm/excel/defined-name-ref.js +20 -0
- package/dist/esm/excel/form-control-parser.d.ts +13 -0
- package/dist/esm/excel/form-control-parser.js +5 -0
- package/dist/esm/excel/formula/context.d.ts +37 -0
- package/dist/esm/excel/formula/dates.d.ts +23 -0
- package/dist/esm/excel/formula/dates.js +20 -0
- package/dist/esm/excel/formula/eval.d.ts +21 -0
- package/dist/esm/excel/formula/eval.js +11 -0
- package/dist/esm/excel/formula/functions.d.ts +12 -0
- package/dist/esm/excel/formula/functions.js +12 -0
- package/dist/esm/excel/formula/index.d.ts +21 -0
- package/dist/esm/excel/formula/index.js +16 -0
- package/dist/esm/excel/formula/lexer.d.ts +12 -0
- package/dist/esm/excel/formula/lexer.js +10 -0
- package/dist/esm/excel/formula/parser.d.ts +20 -0
- package/dist/esm/excel/formula/parser.js +53 -0
- package/dist/esm/excel/formula/value.d.ts +53 -0
- package/dist/esm/excel/formula/value.js +30 -0
- package/dist/esm/excel/header-footer.d.ts +9 -0
- package/dist/esm/excel/header-footer.js +9 -0
- package/dist/esm/excel/number-format.d.ts +34 -0
- package/dist/esm/excel/number-format.js +34 -0
- package/dist/esm/excel/pivot-table-parser.d.ts +8 -0
- package/dist/esm/excel/pivot-table-parser.js +8 -0
- package/dist/esm/excel/print-model.d.ts +77 -1
- package/dist/esm/excel/print-model.js +230 -26
- package/dist/esm/excel/shared-strings-parser.d.ts +13 -0
- package/dist/esm/excel/shared-strings-parser.js +5 -0
- package/dist/esm/excel/sheet-drawing.d.ts +34 -0
- package/dist/esm/excel/sheet-drawing.js +21 -0
- package/dist/esm/excel/sheet-shape-parser.d.ts +12 -0
- package/dist/esm/excel/sheet-shape-parser.js +12 -0
- package/dist/esm/excel/sheet-to-flow.d.ts +29 -0
- package/dist/esm/excel/sheet-to-flow.js +24 -7
- package/dist/esm/excel/slicer-parser.d.ts +23 -0
- package/dist/esm/excel/slicer-parser.js +10 -0
- package/dist/esm/excel/styles-parser.d.ts +8 -0
- package/dist/esm/excel/styles-parser.js +8 -0
- package/dist/esm/excel/table-parser.d.ts +24 -0
- package/dist/esm/excel/table-parser.js +5 -0
- package/dist/esm/excel/workbook-parser.d.ts +17 -0
- package/dist/esm/excel/workbook-parser.js +5 -0
- package/dist/esm/excel/worksheet-parser.d.ts +9 -0
- package/dist/esm/excel/worksheet-parser.js +39 -6
- package/dist/esm/excel/xls/biff-chart.d.ts +10 -0
- package/dist/esm/excel/xls/biff-chart.js +10 -0
- package/dist/esm/excel/xls/biff-reader.d.ts +27 -0
- package/dist/esm/excel/xls/biff-reader.js +44 -0
- package/dist/esm/excel/xls/biff-styles.d.ts +20 -0
- package/dist/esm/excel/xls/biff-styles.js +20 -0
- package/dist/esm/excel/xls/escher.d.ts +27 -0
- package/dist/esm/excel/xls/escher.js +18 -0
- package/dist/esm/excel/xls/xls-reader.d.ts +6 -0
- package/dist/esm/excel/xls/xls-reader.js +6 -0
- package/dist/esm/excel/xlsx-reader.d.ts +30 -0
- package/dist/esm/excel/xlsx-reader.js +38 -4
- package/dist/esm/excel/xlsx-to-pdf.d.ts +27 -0
- package/dist/esm/excel/xlsx-writer.d.ts +14 -0
- package/dist/esm/excel/xlsx-writer.js +13 -0
- package/dist/esm/html/html-writer.d.ts +18 -0
- package/dist/esm/html/html-writer.js +18 -0
- package/dist/esm/index.d.ts +23 -0
- package/dist/esm/layout/math-layout.d.ts +39 -0
- package/dist/esm/layout/math-layout.js +18 -0
- package/dist/esm/layout/page-doc.d.ts +91 -0
- package/dist/esm/layout/styled-layout.d.ts +175 -0
- package/dist/esm/layout/styled-layout.js +136 -4
- package/dist/esm/pdf/builtin-fonts.d.ts +5 -0
- package/dist/esm/pdf/cid-font.d.ts +22 -0
- package/dist/esm/pdf/cid-font.js +10 -0
- package/dist/esm/pdf/embedded-file.d.ts +16 -0
- package/dist/esm/pdf/embedded-file.js +9 -0
- package/dist/esm/pdf/encryption.d.ts +59 -0
- package/dist/esm/pdf/encryption.js +37 -0
- package/dist/esm/pdf/icc-profile.d.ts +8 -0
- package/dist/esm/pdf/icc-profile.js +8 -0
- package/dist/esm/pdf/image-xobject.d.ts +19 -0
- package/dist/esm/pdf/image-xobject.js +9 -0
- package/dist/esm/pdf/objects.d.ts +40 -0
- package/dist/esm/pdf/objects.js +36 -0
- package/dist/esm/pdf/serialize.d.ts +18 -0
- package/dist/esm/pdf/serialize.js +18 -0
- package/dist/esm/pdf/shading.d.ts +16 -0
- package/dist/esm/pdf/shading.js +16 -0
- package/dist/esm/pdf/signature.d.ts +36 -0
- package/dist/esm/pdf/signature.js +22 -0
- package/dist/esm/pdf/struct-tree.d.ts +64 -0
- package/dist/esm/pdf/struct-tree.js +60 -0
- package/dist/esm/pdf/styled-page-emitter.d.ts +33 -0
- package/dist/esm/pdf/styled-page-emitter.js +21 -0
- package/dist/esm/pdf/styled-page-renderer.d.ts +18 -0
- package/dist/esm/pdf/styled-page-renderer.js +18 -0
- package/dist/esm/pdf/text-encoding.d.ts +16 -0
- package/dist/esm/pdf/text-page-renderer.d.ts +11 -0
- package/dist/esm/pdf/vector-graphics.d.ts +12 -0
- package/dist/esm/pdf/vector-graphics.js +12 -0
- package/dist/esm/pdf/writer.d.ts +39 -0
- package/dist/esm/pdf/writer.js +27 -0
- package/dist/esm/pdf/xmp.d.ts +16 -0
- package/dist/esm/pdf/xmp.js +9 -0
- package/dist/esm/pdf-reader/ccitt.d.ts +25 -0
- package/dist/esm/pdf-reader/ccitt.js +15 -0
- package/dist/esm/pdf-reader/cmap.d.ts +12 -0
- package/dist/esm/pdf-reader/cmap.js +9 -0
- package/dist/esm/pdf-reader/content.d.ts +69 -0
- package/dist/esm/pdf-reader/content.js +16 -0
- package/dist/esm/pdf-reader/crypto.d.ts +5 -0
- package/dist/esm/pdf-reader/crypto.js +5 -0
- package/dist/esm/pdf-reader/decrypt.d.ts +17 -0
- package/dist/esm/pdf-reader/decrypt.js +12 -0
- package/dist/esm/pdf-reader/document.d.ts +53 -0
- package/dist/esm/pdf-reader/document.js +50 -0
- package/dist/esm/pdf-reader/flow-build.d.ts +47 -0
- package/dist/esm/pdf-reader/flow-build.js +42 -0
- package/dist/esm/pdf-reader/font.d.ts +12 -0
- package/dist/esm/pdf-reader/font.js +12 -0
- package/dist/esm/pdf-reader/image-decode.d.ts +21 -0
- package/dist/esm/pdf-reader/image-decode.js +14 -0
- package/dist/esm/pdf-reader/images.d.ts +19 -0
- package/dist/esm/pdf-reader/images.js +9 -0
- package/dist/esm/pdf-reader/layout.d.ts +15 -0
- package/dist/esm/pdf-reader/layout.js +15 -0
- package/dist/esm/pdf-reader/lexer.d.ts +43 -0
- package/dist/esm/pdf-reader/lexer.js +38 -0
- package/dist/esm/pdf-reader/parser.d.ts +15 -0
- package/dist/esm/pdf-reader/parser.js +8 -0
- package/dist/esm/pdf-reader/png-encode.d.ts +9 -0
- package/dist/esm/pdf-reader/png-encode.js +8 -0
- package/dist/esm/pdf-reader/predictor.d.ts +9 -0
- package/dist/esm/pdf-reader/predictor.js +8 -0
- package/dist/esm/pdf-reader/reader.d.ts +16 -0
- package/dist/esm/pdf-reader/reader.js +16 -0
- package/dist/esm/pdf-reader/shading.d.ts +10 -0
- package/dist/esm/pdf-reader/shading.js +10 -0
- package/dist/esm/pdf-reader/struct-tree.d.ts +24 -0
- package/dist/esm/pdf-reader/struct-tree.js +12 -0
- package/dist/esm/pdf-reader/tagged.d.ts +13 -0
- package/dist/esm/pdf-reader/tagged.js +13 -0
- package/dist/esm/pdf-reader/text.d.ts +11 -0
- package/dist/esm/pdf-reader/text.js +11 -0
- package/dist/esm/pdf-reader/vector.d.ts +19 -0
- package/dist/esm/pdf-reader/vector.js +9 -0
- package/dist/esm/pptx/placeholder-cascade.d.ts +21 -0
- package/dist/esm/pptx/placeholder-cascade.js +10 -0
- package/dist/esm/pptx/ppt/ppt-reader.d.ts +16 -0
- package/dist/esm/pptx/ppt/ppt-reader.js +16 -0
- package/dist/esm/pptx/ppt/ppt-text.d.ts +55 -0
- package/dist/esm/pptx/ppt/ppt-text.js +14 -0
- package/dist/esm/pptx/pptx-reader.d.ts +21 -0
- package/dist/esm/pptx/pptx-reader.js +23 -2
- package/dist/esm/pptx/slide-parser.d.ts +102 -0
- package/dist/esm/pptx/slide-parser.js +78 -0
- package/dist/esm/pptx/sp-helpers.d.ts +28 -0
- package/dist/esm/pptx/sp-helpers.js +22 -0
- package/dist/esm/svg/svg-writer.d.ts +17 -0
- package/dist/esm/svg/svg-writer.js +16 -0
- package/dist/esm/word/doc/doc-reader.d.ts +16 -0
- package/dist/esm/word/doc/doc-reader.js +16 -0
- package/dist/esm/word/doc/doc-text.d.ts +77 -0
- package/dist/esm/word/doc/doc-text.js +13 -0
- package/dist/esm/word/document-parser.d.ts +134 -0
- package/dist/esm/word/document-parser.js +86 -0
- package/dist/esm/word/docx-reader.d.ts +16 -0
- package/dist/esm/word/docx-reader.js +18 -2
- package/dist/esm/word/docx-to-pdf.d.ts +52 -0
- package/dist/esm/word/docx-to-pdf.js +21 -0
- package/dist/esm/word/docx-writer.d.ts +17 -0
- package/dist/esm/word/docx-writer.js +17 -0
- package/dist/esm/word/drawing-parser.d.ts +88 -0
- package/dist/esm/word/drawing-parser.js +68 -0
- package/dist/esm/word/font-table.d.ts +24 -0
- package/dist/esm/word/font-table.js +24 -0
- package/dist/esm/word/numbering-parser.d.ts +11 -0
- package/dist/esm/word/numbering-parser.js +11 -0
- package/dist/esm/word/omml-parser.d.ts +15 -0
- package/dist/esm/word/omml-parser.js +15 -0
- package/dist/esm/word/omml-serializer.d.ts +9 -0
- package/dist/esm/word/omml-serializer.js +9 -0
- package/dist/esm/word/paragraph-properties.d.ts +10 -0
- package/dist/esm/word/paragraph-properties.js +10 -0
- package/dist/esm/word/po-to-flat.d.ts +11 -0
- package/dist/esm/word/po-to-flat.js +11 -0
- package/dist/esm/word/run-properties.d.ts +10 -0
- package/dist/esm/word/run-properties.js +10 -0
- package/dist/esm/word/settings-parser.d.ts +13 -0
- package/dist/esm/word/settings-parser.js +8 -0
- package/dist/esm/word/styles-parser.d.ts +10 -0
- package/dist/esm/word/styles-parser.js +10 -0
- package/dist/esm/word/table-parser.d.ts +11 -0
- package/dist/esm/word/table-parser.js +11 -0
- package/dist/esm/word/text-extractor.d.ts +9 -0
- package/dist/esm/word/xml-helpers.d.ts +44 -0
- package/dist/esm/word/xml-helpers.js +38 -0
- package/package.json +5 -2
|
@@ -1,17 +1,45 @@
|
|
|
1
1
|
import { RunProperties } from '../core/document-model/index.js';
|
|
2
2
|
import { ColorResolver } from '../core/drawingml/colors.js';
|
|
3
3
|
import { PoNode } from '../core/po-helpers.js';
|
|
4
|
+
/**
|
|
5
|
+
* §19.3.1.36 `p:ph` — a shape's placeholder reference. `type`/`idx` tie a slide
|
|
6
|
+
* shape to the matching prototype in its layout and master.
|
|
7
|
+
*/
|
|
4
8
|
export interface PlaceholderRef {
|
|
9
|
+
/** The placeholder type, e.g. `'title'`, `'ctrTitle'`, `'subTitle'`, `'body'`, `'obj'`. */
|
|
5
10
|
readonly type?: string;
|
|
6
11
|
readonly idx?: string;
|
|
7
12
|
}
|
|
13
|
+
/** An `a:xfrm` box in EMU (`off` + `ext`). */
|
|
8
14
|
export interface ShapeBoxEmu {
|
|
9
15
|
readonly x: number;
|
|
10
16
|
readonly y: number;
|
|
11
17
|
readonly cx: number;
|
|
12
18
|
readonly cy: number;
|
|
13
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* `p:nvSpPr/p:nvPr/p:ph` → the placeholder reference, or `undefined` for an
|
|
22
|
+
* ordinary (non-placeholder) shape. A bare `<p:ph/>` returns an empty ref (still
|
|
23
|
+
* a placeholder: `type` defaults to `'obj'`).
|
|
24
|
+
*/
|
|
14
25
|
export declare function parsePh(sp: PoNode): PlaceholderRef | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* An xfrm node (`a:off` + `a:ext` children) → the EMU box. Works for both
|
|
28
|
+
* `a:xfrm` (in `p:spPr`) and `p:xfrm` (on a `p:graphicFrame`), whose children are
|
|
29
|
+
* identical. Returns `undefined` for a missing or degenerate (non-positive)
|
|
30
|
+
* extent.
|
|
31
|
+
*/
|
|
15
32
|
export declare function boxFromXfrm(xfrm: PoNode | undefined): ShapeBoxEmu | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* `p:spPr/a:xfrm` → the EMU box, or `undefined` when the shape carries no
|
|
35
|
+
* explicit transform (a placeholder that inherits it from the layout/master).
|
|
36
|
+
*/
|
|
16
37
|
export declare function parseXfrmBox(spPr: PoNode | undefined): ShapeBoxEmu | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* `a:rPr` / `a:defRPr` → {@link RunProperties}. Both the direct run formatting on
|
|
40
|
+
* a slide (`a:rPr`) and the per-level defaults in a master's `p:txStyles`
|
|
41
|
+
* (`a:defRPr`) share this element, so the cascade reuses the same reader: size
|
|
42
|
+
* (`sz`, hundredths of a point), bold/italic/underline, solid colour and the
|
|
43
|
+
* latin typeface. Scheme colours and the theme font cascade come in PX5.
|
|
44
|
+
*/
|
|
17
45
|
export declare function rPrToRunProps(rPr: PoNode | undefined, colors: ColorResolver): RunProperties;
|
|
@@ -3,6 +3,11 @@ import { poAttr, poChildren, poIntAttr, poIs } from "../core/po-helpers.js";
|
|
|
3
3
|
import { resolveColorNode } from "../core/drawingml/colors.js";
|
|
4
4
|
//#region src/pptx/sp-helpers.ts
|
|
5
5
|
var isTrue = (v) => v === "1" || v === "true" || v === "on";
|
|
6
|
+
/**
|
|
7
|
+
* `p:nvSpPr/p:nvPr/p:ph` → the placeholder reference, or `undefined` for an
|
|
8
|
+
* ordinary (non-placeholder) shape. A bare `<p:ph/>` returns an empty ref (still
|
|
9
|
+
* a placeholder: `type` defaults to `'obj'`).
|
|
10
|
+
*/
|
|
6
11
|
function parsePh(sp) {
|
|
7
12
|
const nvSpPr = poChildren(sp).find((c) => poIs(c, "p:nvSpPr"));
|
|
8
13
|
const nvPr = nvSpPr ? poChildren(nvSpPr).find((c) => poIs(c, "p:nvPr")) : void 0;
|
|
@@ -15,6 +20,12 @@ function parsePh(sp) {
|
|
|
15
20
|
...idx !== void 0 ? { idx } : {}
|
|
16
21
|
};
|
|
17
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* An xfrm node (`a:off` + `a:ext` children) → the EMU box. Works for both
|
|
25
|
+
* `a:xfrm` (in `p:spPr`) and `p:xfrm` (on a `p:graphicFrame`), whose children are
|
|
26
|
+
* identical. Returns `undefined` for a missing or degenerate (non-positive)
|
|
27
|
+
* extent.
|
|
28
|
+
*/
|
|
18
29
|
function boxFromXfrm(xfrm) {
|
|
19
30
|
if (!xfrm) return void 0;
|
|
20
31
|
const off = poChildren(xfrm).find((c) => poIs(c, "a:off"));
|
|
@@ -29,9 +40,20 @@ function boxFromXfrm(xfrm) {
|
|
|
29
40
|
cy
|
|
30
41
|
};
|
|
31
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* `p:spPr/a:xfrm` → the EMU box, or `undefined` when the shape carries no
|
|
45
|
+
* explicit transform (a placeholder that inherits it from the layout/master).
|
|
46
|
+
*/
|
|
32
47
|
function parseXfrmBox(spPr) {
|
|
33
48
|
return boxFromXfrm(spPr ? poChildren(spPr).find((c) => poIs(c, "a:xfrm")) : void 0);
|
|
34
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* `a:rPr` / `a:defRPr` → {@link RunProperties}. Both the direct run formatting on
|
|
52
|
+
* a slide (`a:rPr`) and the per-level defaults in a master's `p:txStyles`
|
|
53
|
+
* (`a:defRPr`) share this element, so the cascade reuses the same reader: size
|
|
54
|
+
* (`sz`, hundredths of a point), bold/italic/underline, solid colour and the
|
|
55
|
+
* latin typeface. Scheme colours and the theme font cascade come in PX5.
|
|
56
|
+
*/
|
|
35
57
|
function rPrToRunProps(rPr, colors) {
|
|
36
58
|
if (!rPr) return {};
|
|
37
59
|
const sz = poIntAttr(rPr, "sz");
|
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import { DocumentWriter, WriteResult } from '../core/ir/adapters.js';
|
|
2
2
|
import { LaidOutDocument } from '../layout/page-doc.js';
|
|
3
|
+
/** Options for {@link writeSvg}. */
|
|
3
4
|
export interface SvgWriteOptions {
|
|
4
5
|
/** Gap between stacked pages, in px/pt (default 12). */
|
|
5
6
|
readonly pageGap?: number;
|
|
6
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Render a {@link LaidOutDocument} to a single SVG preview (ir-design §7 /
|
|
10
|
+
* stage 6). Written purely against the PageDoc schema; knows nothing about OOXML
|
|
11
|
+
* or the PDF writer. PageItem coordinates are already top-left/y-down — SVG's own
|
|
12
|
+
* frame — so they are emitted verbatim. Pages stack vertically in one `<svg>`,
|
|
13
|
+
* separated by {@link SvgWriteOptions.pageGap}, each on a white outlined rect so
|
|
14
|
+
* they read as pages.
|
|
15
|
+
*
|
|
16
|
+
* @param laid The laid-out, paginated document from the layout engine.
|
|
17
|
+
* @param opts Optional page-gap override.
|
|
18
|
+
* @returns The encoded SVG bytes plus the recorded {@link Loss} list.
|
|
19
|
+
*/
|
|
7
20
|
export declare function writeSvg(laid: LaidOutDocument, opts?: SvgWriteOptions): WriteResult;
|
|
21
|
+
/**
|
|
22
|
+
* The page-medium {@link DocumentWriter} adapter (id `'svg'`), wrapping
|
|
23
|
+
* {@link writeSvg}, with the set of {@link FEATURES} it renders.
|
|
24
|
+
*/
|
|
8
25
|
export declare const svgWriter: DocumentWriter<LaidOutDocument>;
|
|
@@ -5,6 +5,18 @@ import { paintPlan } from "../layout/page-doc.js";
|
|
|
5
5
|
import { toBase64 } from "../core/bytes.js";
|
|
6
6
|
//#region src/svg/svg-writer.ts
|
|
7
7
|
var PAGE_GAP = 12;
|
|
8
|
+
/**
|
|
9
|
+
* Render a {@link LaidOutDocument} to a single SVG preview (ir-design §7 /
|
|
10
|
+
* stage 6). Written purely against the PageDoc schema; knows nothing about OOXML
|
|
11
|
+
* or the PDF writer. PageItem coordinates are already top-left/y-down — SVG's own
|
|
12
|
+
* frame — so they are emitted verbatim. Pages stack vertically in one `<svg>`,
|
|
13
|
+
* separated by {@link SvgWriteOptions.pageGap}, each on a white outlined rect so
|
|
14
|
+
* they read as pages.
|
|
15
|
+
*
|
|
16
|
+
* @param laid The laid-out, paginated document from the layout engine.
|
|
17
|
+
* @param opts Optional page-gap override.
|
|
18
|
+
* @returns The encoded SVG bytes plus the recorded {@link Loss} list.
|
|
19
|
+
*/
|
|
8
20
|
function writeSvg(laid, opts = {}) {
|
|
9
21
|
const gap = opts.pageGap ?? PAGE_GAP;
|
|
10
22
|
const losses = [];
|
|
@@ -27,6 +39,10 @@ function writeSvg(laid, opts = {}) {
|
|
|
27
39
|
losses
|
|
28
40
|
};
|
|
29
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* The page-medium {@link DocumentWriter} adapter (id `'svg'`), wrapping
|
|
44
|
+
* {@link writeSvg}, with the set of {@link FEATURES} it renders.
|
|
45
|
+
*/
|
|
30
46
|
var svgWriter = {
|
|
31
47
|
id: "svg",
|
|
32
48
|
consumes: "page",
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import { DocumentReader, ReadResult } from '../../core/ir/adapters.js';
|
|
2
2
|
import { FlowDoc } from '../../core/ir/flow.js';
|
|
3
|
+
/**
|
|
4
|
+
* Read a legacy Word 97–2003 `.doc` (DOC-1..11) into the same {@link FlowDoc} the
|
|
5
|
+
* OOXML docx reader produces: paragraphs of formatted runs, tables (column widths,
|
|
6
|
+
* cell borders, vertical merges, shading), inline images, list items, the first
|
|
7
|
+
* section's page size and the section's headers/footers. The text + formatting is
|
|
8
|
+
* read; drawing shapes / text boxes and comments are not, so a `degraded` (or
|
|
9
|
+
* `dropped`, for an encrypted file) {@link Loss} is reported.
|
|
10
|
+
*
|
|
11
|
+
* @param bytes The `.doc` (OLE2/CFB) bytes.
|
|
12
|
+
* @returns The projected {@link FlowDoc} and the read loss(es).
|
|
13
|
+
*/
|
|
3
14
|
export declare function readDoc(bytes: Uint8Array): ReadResult<FlowDoc>;
|
|
15
|
+
/**
|
|
16
|
+
* The {@link DocumentReader} for legacy `.doc`: sniffs a Word 97–2003 binary (a
|
|
17
|
+
* CFB with a `WordDocument` stream) and reads it via {@link readDoc} into a
|
|
18
|
+
* {@link FlowDoc}.
|
|
19
|
+
*/
|
|
4
20
|
export declare const docReader: DocumentReader<FlowDoc>;
|
|
@@ -114,6 +114,17 @@ var DOC_ENCRYPTED_LOSS = {
|
|
|
114
114
|
feature: FEATURES.text,
|
|
115
115
|
detail: "legacy .doc is encrypted/obfuscated — its text cannot be read"
|
|
116
116
|
};
|
|
117
|
+
/**
|
|
118
|
+
* Read a legacy Word 97–2003 `.doc` (DOC-1..11) into the same {@link FlowDoc} the
|
|
119
|
+
* OOXML docx reader produces: paragraphs of formatted runs, tables (column widths,
|
|
120
|
+
* cell borders, vertical merges, shading), inline images, list items, the first
|
|
121
|
+
* section's page size and the section's headers/footers. The text + formatting is
|
|
122
|
+
* read; drawing shapes / text boxes and comments are not, so a `degraded` (or
|
|
123
|
+
* `dropped`, for an encrypted file) {@link Loss} is reported.
|
|
124
|
+
*
|
|
125
|
+
* @param bytes The `.doc` (OLE2/CFB) bytes.
|
|
126
|
+
* @returns The projected {@link FlowDoc} and the read loss(es).
|
|
127
|
+
*/
|
|
117
128
|
function readDoc(bytes) {
|
|
118
129
|
const content = extractDocContent(bytes);
|
|
119
130
|
const resources = new ResourceStore();
|
|
@@ -416,6 +427,11 @@ function alignmentFromJc(jc) {
|
|
|
416
427
|
default: return;
|
|
417
428
|
}
|
|
418
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* The {@link DocumentReader} for legacy `.doc`: sniffs a Word 97–2003 binary (a
|
|
432
|
+
* CFB with a `WordDocument` stream) and reads it via {@link readDoc} into a
|
|
433
|
+
* {@link FlowDoc}.
|
|
434
|
+
*/
|
|
419
435
|
var docReader = {
|
|
420
436
|
id: "doc",
|
|
421
437
|
produces: "flow",
|
|
@@ -1,21 +1,37 @@
|
|
|
1
|
+
/** Run (character) formatting decoded from a CHPX grpprl. */
|
|
1
2
|
export interface DocCharProps {
|
|
2
3
|
readonly bold?: boolean;
|
|
3
4
|
readonly italic?: boolean;
|
|
5
|
+
/** Word `kul` underline code (0 = none). */
|
|
4
6
|
readonly underlineKul?: number;
|
|
7
|
+
/** Font size in half-points. */
|
|
5
8
|
readonly sizeHalfPts?: number;
|
|
9
|
+
/** The character is special — `sprmCFSpec` (e.g. a picture placeholder). */
|
|
6
10
|
readonly fSpec?: boolean;
|
|
11
|
+
/** `sprmCPicLocation` — offset into the `Data` stream of the picture's PICF. */
|
|
7
12
|
readonly picOffset?: number;
|
|
8
13
|
}
|
|
14
|
+
/** An embedded picture: the extracted image bytes and its display size (twips). */
|
|
9
15
|
export interface DocPicture {
|
|
10
16
|
readonly bytes: Uint8Array;
|
|
11
17
|
readonly widthTwips: number;
|
|
12
18
|
readonly heightTwips: number;
|
|
13
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* One cell border (DOC-11) from a Brc80: its width in points, colour and whether
|
|
22
|
+
* it is a double line. Absent when the cell edge has no border.
|
|
23
|
+
*/
|
|
14
24
|
export interface DocBorder {
|
|
15
25
|
readonly widthPt: number;
|
|
16
26
|
readonly colorHex: string;
|
|
27
|
+
/** The border is a double line (`brcType` 0x03). */
|
|
17
28
|
readonly double?: boolean;
|
|
18
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* A table cell's TC80 descriptor (DOC-11): its four edge borders and its
|
|
32
|
+
* vertical-merge marker (`restart` = the top of a vertical span, `continue` = a
|
|
33
|
+
* cell merged into the one above). Carried per cell on the row's TTP.
|
|
34
|
+
*/
|
|
19
35
|
export interface DocTc {
|
|
20
36
|
readonly borders?: {
|
|
21
37
|
readonly top?: DocBorder;
|
|
@@ -25,31 +41,62 @@ export interface DocTc {
|
|
|
25
41
|
};
|
|
26
42
|
readonly vMerge?: 'restart' | 'continue';
|
|
27
43
|
}
|
|
44
|
+
/** Paragraph formatting decoded from a PAPX grpprl. */
|
|
28
45
|
export interface DocParaProps {
|
|
46
|
+
/** Word justification (0 left, 1 center, 2 right, 3 both, 4 distribute). */
|
|
29
47
|
readonly jc?: number;
|
|
30
48
|
readonly indentLeftTwips?: number;
|
|
31
49
|
readonly indentRightTwips?: number;
|
|
50
|
+
/** First-line indent, signed (negative = hanging). */
|
|
32
51
|
readonly indentFirstTwips?: number;
|
|
33
52
|
readonly spaceBeforeTwips?: number;
|
|
34
53
|
readonly spaceAfterTwips?: number;
|
|
54
|
+
/** The paragraph is in a table — `sprmPFInTable`. */
|
|
35
55
|
readonly inTable?: boolean;
|
|
56
|
+
/** This is the row's terminating paragraph (TTP) — `sprmPFTtp`. */
|
|
36
57
|
readonly rowEnd?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* `sprmTDefTable` rgdxaCenter — the (cols+1) cell-boundary x-positions (twips);
|
|
60
|
+
* present on the TTP. Cell `i` width = `edge[i+1] − edge[i]`.
|
|
61
|
+
*/
|
|
37
62
|
readonly cellEdgesTwips?: ReadonlyArray<number>;
|
|
63
|
+
/**
|
|
64
|
+
* `sprmTDefTable` TC80 per-cell descriptors (borders + vertical merge), one per
|
|
65
|
+
* cell, present on the TTP alongside `cellEdgesTwips` (DOC-11).
|
|
66
|
+
*/
|
|
38
67
|
readonly cellDescriptors?: ReadonlyArray<DocTc>;
|
|
68
|
+
/**
|
|
69
|
+
* `sprmTDefTableShd` — each cell's background fill hex (cvBack), or `undefined`
|
|
70
|
+
* for an auto (no-fill) cell. Indexed parallel to `cellDescriptors`.
|
|
71
|
+
*/
|
|
39
72
|
readonly cellShadings?: ReadonlyArray<string | undefined>;
|
|
73
|
+
/** `sprmPIlfo` — list-format override index (>0 ⇒ the paragraph is a list item). */
|
|
40
74
|
readonly listIlfo?: number;
|
|
75
|
+
/** `sprmPIlvl` — list level (0–8). */
|
|
41
76
|
readonly listIlvl?: number;
|
|
42
77
|
}
|
|
78
|
+
/** One maximal same-formatting run of text, or an embedded picture. */
|
|
43
79
|
export interface DocRun {
|
|
44
80
|
readonly text: string;
|
|
45
81
|
readonly props: DocCharProps;
|
|
82
|
+
/** Set instead of `text` when the run is an embedded picture. */
|
|
46
83
|
readonly picture?: DocPicture;
|
|
47
84
|
}
|
|
85
|
+
/** One paragraph: its runs plus the decoded paragraph properties. */
|
|
48
86
|
export interface DocParagraph {
|
|
49
87
|
readonly runs: ReadonlyArray<DocRun>;
|
|
50
88
|
readonly props: DocParaProps;
|
|
89
|
+
/**
|
|
90
|
+
* The paragraph was ended by a cell mark (0x07) rather than a CR — i.e. it
|
|
91
|
+
* closes a table cell. With `props.rowEnd` it also closes the row.
|
|
92
|
+
*/
|
|
51
93
|
readonly cellMark?: boolean;
|
|
52
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* The section's header/footer stories (best-effort: the binary story ordering
|
|
97
|
+
* cannot be validated against a real file, so only well-formed, non-empty stories
|
|
98
|
+
* are surfaced). `default` is the odd-page (primary) header/footer.
|
|
99
|
+
*/
|
|
53
100
|
export interface DocHeaderFooters {
|
|
54
101
|
readonly defaultHeader?: ReadonlyArray<DocParagraph>;
|
|
55
102
|
readonly defaultFooter?: ReadonlyArray<DocParagraph>;
|
|
@@ -58,11 +105,21 @@ export interface DocHeaderFooters {
|
|
|
58
105
|
readonly evenHeader?: ReadonlyArray<DocParagraph>;
|
|
59
106
|
readonly evenFooter?: ReadonlyArray<DocParagraph>;
|
|
60
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* One list level (LVL) — the format of its number (DOC-10). `nfc` is the MSONFC
|
|
110
|
+
* code (0 arabic, 1/2 upper/lower roman, 3/4 upper/lower letter, 23 bullet, 0xFF
|
|
111
|
+
* none); `xst` is the number-text template as UTF-16 code units, where a code unit
|
|
112
|
+
* ≤ 8 is a placeholder for the number of that (zero-based) level.
|
|
113
|
+
*/
|
|
61
114
|
export interface DocLvl {
|
|
62
115
|
readonly nfc: number;
|
|
63
116
|
readonly iStartAt: number;
|
|
64
117
|
readonly xst: ReadonlyArray<number>;
|
|
65
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* The document's list tables (DOC-10): an LFO → lsid map (a paragraph's 1-based
|
|
121
|
+
* `sprmPIlfo` indexes it) and, per lsid, the list's levels.
|
|
122
|
+
*/
|
|
66
123
|
export interface DocListTables {
|
|
67
124
|
readonly lfoLsids: ReadonlyArray<number>;
|
|
68
125
|
readonly lists: ReadonlyMap<number, {
|
|
@@ -70,14 +127,34 @@ export interface DocListTables {
|
|
|
70
127
|
readonly levels: ReadonlyArray<DocLvl>;
|
|
71
128
|
}>;
|
|
72
129
|
}
|
|
130
|
+
/** Everything extracted from a `.doc`'s `WordDocument` stream. */
|
|
73
131
|
export interface DocContent {
|
|
74
132
|
readonly paragraphs: ReadonlyArray<DocParagraph>;
|
|
75
133
|
readonly headerFooters?: DocHeaderFooters;
|
|
134
|
+
/** The list tables resolving a paragraph's (ilfo, ilvl) to its number format. */
|
|
76
135
|
readonly listTables?: DocListTables;
|
|
136
|
+
/**
|
|
137
|
+
* The first section's page size in points (xaPage/yaPage from its SEP), when
|
|
138
|
+
* present and sane; absent ⇒ the reader's default (US Letter) applies.
|
|
139
|
+
*/
|
|
77
140
|
readonly pageSize?: {
|
|
78
141
|
readonly widthPt: number;
|
|
79
142
|
readonly heightPt: number;
|
|
80
143
|
};
|
|
144
|
+
/** The file is encrypted/obfuscated — text cannot be read without the key. */
|
|
81
145
|
readonly encrypted: boolean;
|
|
82
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Extract a `.doc`'s `WordDocument` stream into its main-document paragraphs plus
|
|
149
|
+
* the section's header/footer stories, list tables and first-section page size.
|
|
150
|
+
* Joins the piece table (CLX → CPs/FCs), CHPX run formatting and PAPX paragraph
|
|
151
|
+
* formatting, splitting at the CR / cell marks. Every offset is bounds-checked, so
|
|
152
|
+
* a structurally odd file yields no text rather than throwing.
|
|
153
|
+
*
|
|
154
|
+
* @param bytes The `.doc` (OLE2/CFB) bytes.
|
|
155
|
+
* @returns The extracted {@link DocContent}; `encrypted` is set (with no
|
|
156
|
+
* paragraphs) for an encrypted file, and an empty result is returned when the
|
|
157
|
+
* stream is missing, not a Word file, or has no piece table (Word 6/95 is out of
|
|
158
|
+
* scope).
|
|
159
|
+
*/
|
|
83
160
|
export declare function extractDocContent(bytes: Uint8Array): DocContent;
|
|
@@ -86,6 +86,19 @@ function readSectionPageSize(wd, table) {
|
|
|
86
86
|
heightPt: ya / 20
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Extract a `.doc`'s `WordDocument` stream into its main-document paragraphs plus
|
|
91
|
+
* the section's header/footer stories, list tables and first-section page size.
|
|
92
|
+
* Joins the piece table (CLX → CPs/FCs), CHPX run formatting and PAPX paragraph
|
|
93
|
+
* formatting, splitting at the CR / cell marks. Every offset is bounds-checked, so
|
|
94
|
+
* a structurally odd file yields no text rather than throwing.
|
|
95
|
+
*
|
|
96
|
+
* @param bytes The `.doc` (OLE2/CFB) bytes.
|
|
97
|
+
* @returns The extracted {@link DocContent}; `encrypted` is set (with no
|
|
98
|
+
* paragraphs) for an encrypted file, and an empty result is returned when the
|
|
99
|
+
* stream is missing, not a Word file, or has no piece table (Word 6/95 is out of
|
|
100
|
+
* scope).
|
|
101
|
+
*/
|
|
89
102
|
function extractDocContent(bytes) {
|
|
90
103
|
const cfb = openCfb(bytes);
|
|
91
104
|
const wd = cfb.readStream("WordDocument");
|
|
@@ -2,24 +2,122 @@ import { BodyElement, Comment, Section, SectionProperties } from '../core/docume
|
|
|
2
2
|
import { ColorResolver } from '../core/drawingml/colors.js';
|
|
3
3
|
import { Loss, ResourceId } from '../core/ir/index.js';
|
|
4
4
|
import { PoNode } from '../core/po-helpers.js';
|
|
5
|
+
/**
|
|
6
|
+
* Resolves a drawing relationship id to a content-addressed `ResourceId` —
|
|
7
|
+
* supplied by the converter (which owns the OPC package and the `ResourceStore`).
|
|
8
|
+
*/
|
|
5
9
|
export type ImageResolver = (relId: string) => ResourceId | undefined;
|
|
10
|
+
/** Resolves a `w:hyperlink` `r:id` to its external target URL. */
|
|
6
11
|
export type HyperlinkResolver = (relId: string) => string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Document-wide resolvers every nested parser needs — one context object instead
|
|
14
|
+
* of threading a parameter pair through ten signatures (oop-design §8).
|
|
15
|
+
*/
|
|
7
16
|
export interface ParseContext {
|
|
17
|
+
/** Resolver for theme/scheme/auto colours. */
|
|
8
18
|
readonly resolveColor: ColorResolver;
|
|
19
|
+
/** Resolver for a drawing relationship id to a stored image. */
|
|
9
20
|
readonly resolveImage?: ImageResolver;
|
|
21
|
+
/**
|
|
22
|
+
* §17.16.22 `w:hyperlink` `r:id` → external target URL from the owning part's
|
|
23
|
+
* rels (`TargetMode="External"` only). Absent ⇒ links unwrap to plain text.
|
|
24
|
+
*/
|
|
10
25
|
readonly resolveHyperlink?: HyperlinkResolver;
|
|
26
|
+
/**
|
|
27
|
+
* SmartArt: a data relationship id (`dgm:relIds` `@r:dm`) → the diagram's
|
|
28
|
+
* pre-rendered drawing override (its `dsp:spTree`), or `undefined` when the file
|
|
29
|
+
* ships none (E-SMARTART SA2).
|
|
30
|
+
*/
|
|
11
31
|
readonly resolveDiagram?: (relId: string) => PoNode | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Sink for graceful-degradation notices (E-SMARTART SA3): a SmartArt with no
|
|
34
|
+
* drawing override records a dropped-feature {@link Loss} rather than vanishing.
|
|
35
|
+
*/
|
|
12
36
|
readonly onLoss?: (loss: Loss) => void;
|
|
37
|
+
/**
|
|
38
|
+
* §17.13.4 comment ranges currently open as the body is read — a mutable set
|
|
39
|
+
* the run collector stamps onto each run (`commentRangeRefs`). A comment range
|
|
40
|
+
* can span paragraphs, so the state is document-level, not per-paragraph. The
|
|
41
|
+
* reference is readonly; its contents mutate during the walk (CM2c).
|
|
42
|
+
*/
|
|
13
43
|
readonly openCommentRanges?: Set<string>;
|
|
14
44
|
}
|
|
45
|
+
/** The default {@link ParseContext} — just the default colour resolver. */
|
|
15
46
|
export declare const DEFAULT_PARSE_CONTEXT: ParseContext;
|
|
47
|
+
/**
|
|
48
|
+
* Parse `word/document.xml` (ECMA-376 Part 1 §17) into a flat list of
|
|
49
|
+
* {@link BodyElement}, preserving the original interleaving of paragraphs and
|
|
50
|
+
* tables.
|
|
51
|
+
*
|
|
52
|
+
* @param documentXml The raw `document.xml` bytes.
|
|
53
|
+
* @param ctx The document-wide parse context.
|
|
54
|
+
* @returns The body elements; empty when the `w:body` is absent.
|
|
55
|
+
*/
|
|
16
56
|
export declare function parseDocument(documentXml: Uint8Array, ctx?: ParseContext): Array<BodyElement>;
|
|
57
|
+
/** The empty {@link SectionProperties} fallback (no headers/footers). */
|
|
17
58
|
export declare const EMPTY_SECTION: SectionProperties;
|
|
59
|
+
/**
|
|
60
|
+
* Parse the document's final section properties (ECMA-376 Part 1 §17.6.17 — the
|
|
61
|
+
* body-level `sectPr` is the last child of `w:body` and describes the final
|
|
62
|
+
* section). Returned as a single {@link SectionProperties} for backward
|
|
63
|
+
* compatibility; multi-section documents use {@link parseSections} instead.
|
|
64
|
+
*
|
|
65
|
+
* @param documentXml The raw `document.xml` bytes.
|
|
66
|
+
* @returns The final section's properties, or {@link EMPTY_SECTION} when there is none.
|
|
67
|
+
*/
|
|
18
68
|
export declare function parseSection(documentXml: Uint8Array): SectionProperties;
|
|
69
|
+
/**
|
|
70
|
+
* Collect every section in the document (ECMA-376 §17.6): one `sectPr` per
|
|
71
|
+
* intermediate paragraph plus the body-final one. Each {@link Section} carries
|
|
72
|
+
* the exclusive `endIndex` into the body-element list, so section `i` applies to
|
|
73
|
+
* `body[sections[i-1].endIndex .. endIndex)`. A document with no `sectPr` at all
|
|
74
|
+
* returns a single empty section spanning the whole body.
|
|
75
|
+
*
|
|
76
|
+
* @param documentXml The raw `document.xml` bytes.
|
|
77
|
+
* @returns The sections in document order; empty when the `w:body` is absent.
|
|
78
|
+
*/
|
|
19
79
|
export declare function parseSections(documentXml: Uint8Array): Array<Section>;
|
|
80
|
+
/**
|
|
81
|
+
* Parse `word/header*.xml` or `word/footer*.xml`. The root is `w:hdr` or
|
|
82
|
+
* `w:ftr`, whose children are the same body-element shape as the main document.
|
|
83
|
+
*
|
|
84
|
+
* @param xml The raw header/footer part bytes.
|
|
85
|
+
* @param ctx The document-wide parse context.
|
|
86
|
+
* @returns The body elements; empty when neither root is found.
|
|
87
|
+
*/
|
|
20
88
|
export declare function parseHeaderFooter(xml: Uint8Array, ctx?: ParseContext): Array<BodyElement>;
|
|
89
|
+
/**
|
|
90
|
+
* Parse a sequence of body-level children (`w:p`, `w:tbl`, `w:sdt`,
|
|
91
|
+
* `w:bookmarkStart`) into {@link BodyElement}s, preserving order. A lone-drawing
|
|
92
|
+
* paragraph collapses to a standalone image/shape/chart block; a block-level SDT
|
|
93
|
+
* unwraps to its content; a body-level bookmark anchors onto the next paragraph.
|
|
94
|
+
*
|
|
95
|
+
* @param children The body-level child nodes.
|
|
96
|
+
* @param ctx The document-wide parse context.
|
|
97
|
+
* @returns The parsed body elements.
|
|
98
|
+
*/
|
|
21
99
|
export declare function parseBodyElements(children: ReadonlyArray<PoNode>, ctx?: ParseContext): Array<BodyElement>;
|
|
100
|
+
/**
|
|
101
|
+
* Parse `footnotes.xml` / `endnotes.xml` (§17.11) into note content by id. The
|
|
102
|
+
* separator / continuationSeparator / continuationNotice stubs (negative ids or
|
|
103
|
+
* an explicit `w:type`) are skipped — the layout draws its own separator.
|
|
104
|
+
*
|
|
105
|
+
* @param notesXml The raw notes-part bytes.
|
|
106
|
+
* @param rootTag The part's root element (`w:footnotes` or `w:endnotes`).
|
|
107
|
+
* @param noteTag The per-note element (`w:footnote` or `w:endnote`).
|
|
108
|
+
* @param ctx The document-wide parse context.
|
|
109
|
+
* @returns A map from note id to its body content.
|
|
110
|
+
*/
|
|
22
111
|
export declare function parseNotes(notesXml: Uint8Array, rootTag: 'w:footnotes' | 'w:endnotes', noteTag: 'w:footnote' | 'w:endnote', ctx?: ParseContext): Map<string, Array<BodyElement>>;
|
|
112
|
+
/**
|
|
113
|
+
* Parse `word/comments.xml` (§17.13.4) into {@link Comment}s by id, each with its
|
|
114
|
+
* block content and author/initials/date attribution. Thread metadata is added
|
|
115
|
+
* separately by {@link parseCommentThreads}.
|
|
116
|
+
*
|
|
117
|
+
* @param commentsXml The raw `comments.xml` bytes.
|
|
118
|
+
* @param ctx The document-wide parse context.
|
|
119
|
+
* @returns A map from comment id to the parsed comment.
|
|
120
|
+
*/
|
|
23
121
|
export declare function parseComments(commentsXml: Uint8Array, ctx?: ParseContext): Map<string, Comment>;
|
|
24
122
|
/** A commentsExtended entry, keyed by the comment's last-paragraph w14:paraId. */
|
|
25
123
|
export interface CommentExtension {
|
|
@@ -28,7 +126,43 @@ export interface CommentExtension {
|
|
|
28
126
|
/** w15:done — the thread is resolved. */
|
|
29
127
|
readonly done: boolean;
|
|
30
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Parse `word/commentsExtended.xml` (Microsoft w15 `commentsEx`) — a flat list
|
|
131
|
+
* of `commentEx`, each keyed by a comment's `paraId`: `paraIdParent` links a
|
|
132
|
+
* reply to its parent, `done` flags a resolved thread. Prefix-agnostic (w15 by
|
|
133
|
+
* convention).
|
|
134
|
+
*
|
|
135
|
+
* @param xml The raw `commentsExtended.xml` bytes.
|
|
136
|
+
* @returns A map from `paraId` to its {@link CommentExtension}.
|
|
137
|
+
*/
|
|
31
138
|
export declare function parseCommentsExtended(xml: Uint8Array): Map<string, CommentExtension>;
|
|
139
|
+
/**
|
|
140
|
+
* Read comments with their thread metadata: `comments.xml` for content /
|
|
141
|
+
* attribution plus the optional `commentsExtended.xml` for reply links and
|
|
142
|
+
* resolved flags (CM4). A reply gains `parentId`, a resolved thread gains `done`.
|
|
143
|
+
*
|
|
144
|
+
* @param commentsXml The raw `comments.xml` bytes.
|
|
145
|
+
* @param commentsExtendedXml The raw `commentsExtended.xml` bytes, or `undefined`.
|
|
146
|
+
* @param ctx The document-wide parse context.
|
|
147
|
+
* @returns A map from comment id to the parsed, thread-linked comment.
|
|
148
|
+
*/
|
|
32
149
|
export declare function parseCommentThreads(commentsXml: Uint8Array, commentsExtendedXml: Uint8Array | undefined, ctx?: ParseContext): Map<string, Comment>;
|
|
150
|
+
/**
|
|
151
|
+
* Parse `word/people.xml` (Microsoft w15) — maps an author display name to a
|
|
152
|
+
* presence identity (`w15:presenceInfo/@w15:userId`, usually an email), used to
|
|
153
|
+
* enrich a comment's `authorId`. Prefix-agnostic.
|
|
154
|
+
*
|
|
155
|
+
* @param xml The raw `people.xml` bytes.
|
|
156
|
+
* @returns A map from author name to userId.
|
|
157
|
+
*/
|
|
33
158
|
export declare function parsePeople(xml: Uint8Array): Map<string, string>;
|
|
159
|
+
/**
|
|
160
|
+
* Attach each comment's `authorId` by matching its author name against the
|
|
161
|
+
* {@link parsePeople} map. Comments without a matching author pass through
|
|
162
|
+
* unchanged.
|
|
163
|
+
*
|
|
164
|
+
* @param comments The comments by id.
|
|
165
|
+
* @param people The author → userId map from `people.xml`.
|
|
166
|
+
* @returns The comments with `authorId` filled in where resolvable.
|
|
167
|
+
*/
|
|
34
168
|
export declare function applyAuthorIds(comments: Map<string, Comment>, people: Map<string, string>): Map<string, Comment>;
|