reamkit 1.16.0 → 1.18.0
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/bidi/segments.js +1 -2
- package/dist/esm/core/converter/project.js +5 -1
- package/dist/esm/core/document-model/index.d.ts +1 -1
- package/dist/esm/core/document-model/types.d.ts +526 -8
- package/dist/esm/core/drawingml/chart-geometry.d.ts +8 -12
- package/dist/esm/core/drawingml/chart-geometry.js +58 -9
- package/dist/esm/core/drawingml/chart-parser.js +44 -5
- package/dist/esm/core/drawingml/colors.d.ts +1 -1
- package/dist/esm/core/drawingml/colors.js +27 -1
- package/dist/esm/core/drawingml/preset-geometry.js +233 -0
- package/dist/esm/core/drawingml/shape-render.d.ts +12 -0
- package/dist/esm/core/drawingml/shape-render.js +116 -3
- package/dist/esm/core/drawingml/theme-parser.d.ts +10 -0
- package/dist/esm/core/drawingml/theme-parser.js +19 -1
- package/dist/esm/core/font/measure.d.ts +5 -0
- package/dist/esm/core/font/measure.js +21 -1
- package/dist/esm/core/images.d.ts +2 -2
- package/dist/esm/core/images.js +219 -0
- package/dist/esm/core/ir/flow.d.ts +23 -1
- package/dist/esm/core/lzw.d.ts +17 -0
- package/dist/esm/core/lzw.js +83 -0
- package/dist/esm/core/metafile/emf.d.ts +16 -0
- package/dist/esm/core/metafile/emf.js +635 -0
- package/dist/esm/core/metafile/picture.d.ts +106 -0
- package/dist/esm/core/metafile/picture.js +55 -0
- package/dist/esm/core/metafile/wmf.d.ts +9 -0
- package/dist/esm/core/metafile/wmf.js +371 -0
- package/dist/esm/core/numbering/apply.d.ts +5 -3
- package/dist/esm/core/numbering/apply.js +42 -11
- package/dist/esm/core/numbering/index.js +2 -0
- package/dist/esm/core/numbering/state.d.ts +13 -1
- package/dist/esm/core/numbering/state.js +256 -15
- package/dist/esm/core/po-helpers.js +16 -1
- package/dist/esm/core/style-cascade/resolver.js +66 -11
- package/dist/esm/core/style-cascade/table.js +35 -11
- package/dist/esm/core/style-cascade/types.d.ts +42 -1
- package/dist/esm/core/style-cascade/types.js +4 -0
- package/dist/esm/core/tiff.d.ts +20 -0
- package/dist/esm/core/tiff.js +339 -0
- package/dist/esm/core/vector.d.ts +22 -0
- package/dist/esm/excel/print-model.js +4 -2
- package/dist/esm/excel/sheet-to-flow.js +10 -8
- package/dist/esm/excel/worksheet-parser.js +1 -1
- package/dist/esm/html/html-writer.js +20 -5
- package/dist/esm/layout/page-doc.d.ts +107 -4
- package/dist/esm/layout/styled-layout.d.ts +44 -2
- package/dist/esm/layout/styled-layout.js +2330 -283
- package/dist/esm/pdf/shading.js +76 -6
- package/dist/esm/pdf/styled-page-emitter.js +294 -45
- package/dist/esm/pdf/vector-graphics.d.ts +29 -2
- package/dist/esm/pdf/vector-graphics.js +96 -12
- package/dist/esm/pdf-reader/image-decode.js +7 -75
- package/dist/esm/pptx/pptx-reader.js +1 -0
- package/dist/esm/pptx/slide-parser.d.ts +21 -4
- package/dist/esm/pptx/slide-parser.js +86 -23
- package/dist/esm/svg/svg-writer.js +2 -2
- package/dist/esm/word/document-parser.d.ts +96 -7
- package/dist/esm/word/document-parser.js +540 -116
- package/dist/esm/word/docx-reader.js +135 -43
- package/dist/esm/word/docx-writer.js +6 -1
- package/dist/esm/word/drawing-parser.d.ts +58 -5
- package/dist/esm/word/drawing-parser.js +1632 -63
- package/dist/esm/word/index.d.ts +4 -4
- package/dist/esm/word/numbering-parser.d.ts +2 -1
- package/dist/esm/word/numbering-parser.js +107 -21
- package/dist/esm/word/paragraph-properties.d.ts +11 -1
- package/dist/esm/word/paragraph-properties.js +219 -10
- package/dist/esm/word/run-properties.js +45 -1
- package/dist/esm/word/settings-parser.d.ts +24 -0
- package/dist/esm/word/settings-parser.js +31 -5
- package/dist/esm/word/shading.d.ts +11 -0
- package/dist/esm/word/shading.js +64 -0
- package/dist/esm/word/styles-parser.js +8 -2
- package/dist/esm/word/table-parser.d.ts +9 -1
- package/dist/esm/word/table-parser.js +182 -30
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { BorderStyle } from '../core/document-model/index.js';
|
|
1
|
+
import { BorderStyle, ImageCrop, PictureOutline, ShapeShadow } from '../core/document-model/index.js';
|
|
2
2
|
import { Pt, ResourceId, ResourceStore } from '../core/ir/index.js';
|
|
3
3
|
import { FontMeasure, ParsedTtf } from '../core/font/index.js';
|
|
4
4
|
import { ResolvedParagraphProperties, ResolvedRunProperties } from '../core/style-cascade/index.js';
|
|
5
|
-
import { PathSegment, VectorShape } from '../core/vector.js';
|
|
5
|
+
import { PathSegment, StrokeStyle, VectorPath, VectorShape } from '../core/vector.js';
|
|
6
6
|
import { PreparedImage } from '../core/images.js';
|
|
7
|
+
import { MetaPicture } from '../core/metafile/picture.js';
|
|
7
8
|
/** A font bound into a {@link LaidOutDocument}: the parsed face plus what layout/emit need from it. */
|
|
8
9
|
export interface FontResource {
|
|
9
10
|
readonly resourceName: string;
|
|
@@ -42,6 +43,17 @@ export interface TextToken {
|
|
|
42
43
|
* element separate from the item body.
|
|
43
44
|
*/
|
|
44
45
|
readonly listMarker?: true;
|
|
46
|
+
/**
|
|
47
|
+
* §17.3.3.1 — the token is the break of a `w:br w:type="column"`: what
|
|
48
|
+
* follows it belongs in the next column.
|
|
49
|
+
*/
|
|
50
|
+
readonly columnBreak?: true;
|
|
51
|
+
/**
|
|
52
|
+
* §17.3.1.38 — the token IS a tab: its width is the distance to the stop it
|
|
53
|
+
* advances to, resolved once the line is known, and its text is whatever
|
|
54
|
+
* leader fills that gap.
|
|
55
|
+
*/
|
|
56
|
+
readonly tab?: true;
|
|
45
57
|
/**
|
|
46
58
|
* The token falls inside a comment range (`commentRangeRefs`): the emitter
|
|
47
59
|
* fills a soft highlight behind it (E-COMMENTS CM2c).
|
|
@@ -69,6 +81,39 @@ export interface ImageToken {
|
|
|
69
81
|
readonly imageResourceName: string;
|
|
70
82
|
readonly widthPt: number;
|
|
71
83
|
readonly heightPt: number;
|
|
84
|
+
/** §20.1.2.2.24 — the frame the picture is drawn with, when it has one. */
|
|
85
|
+
readonly outline?: PictureOutline;
|
|
86
|
+
/** §20.1.8.40 — the drop shadow under the picture, when it casts one. */
|
|
87
|
+
readonly shadow?: ShapeShadow;
|
|
88
|
+
/** §14.1.2.10 — the contrast/brightness wash the picture is drawn through. */
|
|
89
|
+
readonly wash?: {
|
|
90
|
+
readonly gain: number;
|
|
91
|
+
readonly black: number;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* MS-EMF / MS-WMF — the picture to DRAW in this token's box, for an inline
|
|
95
|
+
* metafile: it has no raster to place, so the emitter plays its primitives
|
|
96
|
+
* where the token stands.
|
|
97
|
+
*/
|
|
98
|
+
readonly metafile?: MetafileDrawing;
|
|
99
|
+
/** §20.1.8.55 `a:srcRect` — the part of the source the frame shows. */
|
|
100
|
+
readonly crop?: ImageCrop;
|
|
101
|
+
/** §20.1.7.6 — degrees clockwise about the box's centre. */
|
|
102
|
+
readonly rotationDeg?: number;
|
|
103
|
+
/** §20.1.7.6 — the picture drawn mirrored in its box. */
|
|
104
|
+
readonly flipH?: boolean;
|
|
105
|
+
readonly flipV?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* §20.4.2.6 — where the picture itself sits inside the reserved box when the
|
|
108
|
+
* drawing asked for an effect extent: offsets from the box's left edge and
|
|
109
|
+
* from the baseline, plus the drawn size. Absent ⇒ the picture fills the box.
|
|
110
|
+
*/
|
|
111
|
+
readonly drawBox?: {
|
|
112
|
+
readonly dxPt: number;
|
|
113
|
+
readonly dyPt: number;
|
|
114
|
+
readonly widthPt: number;
|
|
115
|
+
readonly heightPt: number;
|
|
116
|
+
};
|
|
72
117
|
/** Constants kept to satisfy {@link Token} consumers — they never read these for images. */
|
|
73
118
|
readonly isSpace: false;
|
|
74
119
|
readonly bidiLevel: number;
|
|
@@ -121,6 +166,12 @@ export interface Line {
|
|
|
121
166
|
readonly firstLine: boolean;
|
|
122
167
|
readonly resolved: ResolvedParagraphProperties;
|
|
123
168
|
isLastInParagraph: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* ECMA-376 §17.15.1.35 — the line ends at a soft line break in a document
|
|
171
|
+
* that asked for `w:doNotExpandShiftReturn`, so justification leaves it at
|
|
172
|
+
* its natural width (as the paragraph's own last line is left).
|
|
173
|
+
*/
|
|
174
|
+
readonly noJustify?: boolean;
|
|
124
175
|
/**
|
|
125
176
|
* Max ascent/descent contributed by math tokens (0 when none) — they straddle
|
|
126
177
|
* the baseline, so the line height/descent must grow to fit them.
|
|
@@ -136,13 +187,39 @@ export interface Line {
|
|
|
136
187
|
readonly metricDescentPt?: number;
|
|
137
188
|
}
|
|
138
189
|
/** An image bound into a {@link LaidOutDocument}: its resource name plus the decoded/validated bytes. */
|
|
190
|
+
/**
|
|
191
|
+
* MS-EMF / MS-WMF — a metafile picture, ready to draw: paths and words in a
|
|
192
|
+
* local y-up frame whose origin is the picture box's bottom-left corner. The
|
|
193
|
+
* same vocabulary a chart's layout carries, because a metafile draws the same
|
|
194
|
+
* two things.
|
|
195
|
+
*/
|
|
196
|
+
export interface MetafileDrawing {
|
|
197
|
+
readonly shapes: ReadonlyArray<{
|
|
198
|
+
readonly paths: ReadonlyArray<VectorPath>;
|
|
199
|
+
readonly fillColorHex?: string;
|
|
200
|
+
readonly stroke?: StrokeStyle;
|
|
201
|
+
}>;
|
|
202
|
+
readonly texts: ReadonlyArray<{
|
|
203
|
+
readonly line: Line;
|
|
204
|
+
readonly x: number;
|
|
205
|
+
readonly y: number;
|
|
206
|
+
readonly rotationDeg?: number;
|
|
207
|
+
}>;
|
|
208
|
+
}
|
|
139
209
|
export interface ImageResource {
|
|
140
210
|
readonly resourceName: string;
|
|
141
211
|
/**
|
|
142
212
|
* Decoded/validated at layout time (the probe); the emit phase replays it
|
|
143
|
-
* without touching the source bytes again.
|
|
213
|
+
* without touching the source bytes again. Absent for a METAFILE, which has
|
|
214
|
+
* no raster to embed: it is drawn as the primitives `metafile` holds.
|
|
144
215
|
*/
|
|
145
|
-
readonly prepared
|
|
216
|
+
readonly prepared?: PreparedImage;
|
|
217
|
+
/**
|
|
218
|
+
* MS-EMF / MS-WMF — the picture read out of the resource, in its own logical
|
|
219
|
+
* units. A metafile is a little drawing program, not a raster; the layout
|
|
220
|
+
* turns these into the same primitives a chart is made of.
|
|
221
|
+
*/
|
|
222
|
+
readonly metafile?: MetaPicture;
|
|
146
223
|
}
|
|
147
224
|
/**
|
|
148
225
|
* The fields every {@link PageItem} shares (ir-design §6, frozen at stage 6.4):
|
|
@@ -154,6 +231,11 @@ export interface ImageResource {
|
|
|
154
231
|
* numbers — they are not page-frame coordinates.
|
|
155
232
|
*/
|
|
156
233
|
export interface PageItemBase {
|
|
234
|
+
/**
|
|
235
|
+
* §20.4.2.3 — the float's `relativeHeight`. Items with one are sorted by it
|
|
236
|
+
* inside their layer before the page is written; the rest keep their order.
|
|
237
|
+
*/
|
|
238
|
+
readonly z?: number;
|
|
157
239
|
/**
|
|
158
240
|
* Tagged PDF (§14.8): the logical structure node this item's content belongs
|
|
159
241
|
* to. Set only on body content in tagged mode; undefined text in the line pass
|
|
@@ -225,6 +307,27 @@ export interface ImageItem extends PageItemBase {
|
|
|
225
307
|
readonly width: Pt;
|
|
226
308
|
readonly height: Pt;
|
|
227
309
|
readonly imageResourceName: string;
|
|
310
|
+
/** §20.1.8.55 `a:srcRect` — the part of the source the frame shows. */
|
|
311
|
+
readonly crop?: ImageCrop;
|
|
312
|
+
/** §14.1.2.10 — the contrast/brightness wash the picture is drawn through. */
|
|
313
|
+
readonly wash?: {
|
|
314
|
+
readonly gain: number;
|
|
315
|
+
readonly black: number;
|
|
316
|
+
};
|
|
317
|
+
/** §20.1.7.6 — degrees clockwise about the box's centre. */
|
|
318
|
+
readonly rotationDeg?: number;
|
|
319
|
+
/** §20.1.7.6 — the picture drawn mirrored in its box. */
|
|
320
|
+
readonly flipH?: boolean;
|
|
321
|
+
readonly flipV?: boolean;
|
|
322
|
+
/**
|
|
323
|
+
* §20.1.8.14 — a picture FILL is the shape's outline painted with a picture,
|
|
324
|
+
* so it is clipped to that outline: the paths in the shape's local frame and
|
|
325
|
+
* the matrix that maps them onto the page.
|
|
326
|
+
*/
|
|
327
|
+
readonly clip?: {
|
|
328
|
+
readonly paths: ReadonlyArray<VectorPath>;
|
|
329
|
+
readonly transform: readonly [number, number, number, number, number, number];
|
|
330
|
+
};
|
|
228
331
|
}
|
|
229
332
|
/**
|
|
230
333
|
* DrawingML vector geometry. `shape.transform` maps the shape's local y-up frame
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { BodyElement, Chart, Comment, DocumentInfo, Numbering, Section, SectionProperties, StyleSheet } from '../core/document-model/index.js';
|
|
1
|
+
import { BodyElement, Chart, Comment, DocumentInfo, Numbering, Section, SectionProperties, ShapeFill, StyleSheet } from '../core/document-model/index.js';
|
|
2
2
|
import { FontRegistry } from '../core/font/index.js';
|
|
3
3
|
import { FamilyKey } from '../core/fonts/index.js';
|
|
4
4
|
import { Hyphenator } from '../core/hyphenation/index.js';
|
|
5
|
+
import { Pt, ResourceStore } from '../core/ir/index.js';
|
|
5
6
|
import { LaidOutDocument, PageItem } from './page-doc.js';
|
|
6
7
|
import { AttachedFile } from '../pdf/embedded-file.js';
|
|
7
8
|
import { SignaturePlaceholder } from '../pdf/signature.js';
|
|
8
9
|
import { PdfEncryptOptions } from '../pdf/encryption.js';
|
|
9
|
-
import { ResourceStore } from '../core/ir/index.js';
|
|
10
10
|
import { StructTreeBuilder } from '../pdf/struct-tree.js';
|
|
11
11
|
/**
|
|
12
12
|
* PDF/A conformance string: part 1 (ISO 19005-1, PDF 1.4) / 2 (ISO 19005-2) / 3
|
|
@@ -75,6 +75,12 @@ export interface StyledRenderOptions {
|
|
|
75
75
|
* `body[sections[N-1].endIndex..sections[N].endIndex)`).
|
|
76
76
|
*/
|
|
77
77
|
readonly sections?: ReadonlyArray<Section>;
|
|
78
|
+
/**
|
|
79
|
+
* §17.6.5 — the pitch of the document grid the text is laid on. Set by the
|
|
80
|
+
* layout itself, per section (see {@link SectionRenderCtx.options}); callers
|
|
81
|
+
* state it on the section, not here.
|
|
82
|
+
*/
|
|
83
|
+
readonly gridLinePitchPt?: Pt;
|
|
78
84
|
/** Header/footer body content keyed by relationship id. */
|
|
79
85
|
readonly headersFooters?: ReadonlyMap<string, ReadonlyArray<BodyElement>>;
|
|
80
86
|
/**
|
|
@@ -149,6 +155,24 @@ export interface StyledRenderOptions {
|
|
|
149
155
|
* converter fills this from the document's default `w:lang`.
|
|
150
156
|
*/
|
|
151
157
|
readonly language?: string;
|
|
158
|
+
/**
|
|
159
|
+
* ECMA-376 §17.15.1.35 `w:doNotExpandShiftReturn` — when set, a justified
|
|
160
|
+
* line that ends at a soft line break (`w:br`) is drawn at its natural width
|
|
161
|
+
* instead of being stretched out to the measure.
|
|
162
|
+
*/
|
|
163
|
+
readonly doNotExpandShiftReturn?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* ECMA-376 §17.2.1 `w:background` — the colour every page is painted before
|
|
166
|
+
* anything else is drawn on it. Absent ⇒ the paper's own white.
|
|
167
|
+
*/
|
|
168
|
+
readonly pageBackgroundColorHex?: string;
|
|
169
|
+
/** §17.2.1 — the background's gradient or picture, when it has one. */
|
|
170
|
+
readonly pageBackgroundFill?: ShapeFill;
|
|
171
|
+
/**
|
|
172
|
+
* ECMA-376 §17.15.1.38 `w:gutterAtTop` — the binding space belongs to the
|
|
173
|
+
* TOP margin, not the left.
|
|
174
|
+
*/
|
|
175
|
+
readonly gutterAtTop?: boolean;
|
|
152
176
|
/**
|
|
153
177
|
* §7.6 PDF encryption (AES-256, R6). Only honoured on the ASYNC conversion
|
|
154
178
|
* path (WebCrypto); mutually exclusive with `pdfA` (ISO 19005 forbids
|
|
@@ -175,6 +199,12 @@ export type { DocumentInfo } from '../core/document-model/index.js';
|
|
|
175
199
|
export declare const A4_WIDTH = 595;
|
|
176
200
|
/** A4 page height in points (the page-geometry fallback). */
|
|
177
201
|
export declare const A4_HEIGHT = 842;
|
|
202
|
+
/**
|
|
203
|
+
* How far a space may be squeezed below its natural width — the shrink the
|
|
204
|
+
* line breaker offers when it weighs a line, and therefore the shrink the
|
|
205
|
+
* emitter owes it back when it draws one.
|
|
206
|
+
*/
|
|
207
|
+
export declare const GLUE_SHRINK_RATIO = 0.3;
|
|
178
208
|
/**
|
|
179
209
|
* §17.13.6.2 — a bookmark's GoTo destination: the page (0-based) and the y-up
|
|
180
210
|
* top of the anchoring paragraph's first line.
|
|
@@ -274,6 +304,18 @@ export interface SectionRenderCtx {
|
|
|
274
304
|
readonly footerSet: HeaderFooterSet;
|
|
275
305
|
readonly titlePg: boolean;
|
|
276
306
|
readonly evenAndOddHeaders: boolean;
|
|
307
|
+
/**
|
|
308
|
+
* §17.6.22 — the section begins on the page already in hand, at the point the
|
|
309
|
+
* one before it stopped, rather than on a fresh one.
|
|
310
|
+
*/
|
|
311
|
+
readonly continuous: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* The render options this section's content is laid out with: `options` plus
|
|
314
|
+
* whatever the section itself decides for its text — today only §17.6.5's
|
|
315
|
+
* document grid, which is a property of the SECTION and is needed by every
|
|
316
|
+
* paragraph in it. Absent on a bare context built outside a layout run.
|
|
317
|
+
*/
|
|
318
|
+
readonly options?: StyledRenderOptions;
|
|
277
319
|
}
|
|
278
320
|
interface HfBandEntry {
|
|
279
321
|
readonly commands: Array<PageItem>;
|