reamkit 1.31.0 → 1.32.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/README.md +10 -0
- package/dist/esm/core/bidi/index.d.ts +10 -0
- package/dist/esm/core/bidi/index.js +18 -2
- package/dist/esm/core/converter/facade.js +10 -5
- package/dist/esm/core/converter/project.js +1 -0
- package/dist/esm/core/converter/ream.js +17 -6
- package/dist/esm/core/converter/sheet-images.d.ts +17 -0
- package/dist/esm/core/converter/sheet-images.js +33 -0
- package/dist/esm/core/document-model/index.d.ts +1 -1
- package/dist/esm/core/document-model/types.d.ts +112 -0
- package/dist/esm/core/drawingml/chart-geometry.d.ts +21 -8
- package/dist/esm/core/drawingml/chart-geometry.js +198 -108
- package/dist/esm/core/drawingml/chart-parser.js +73 -2
- package/dist/esm/core/drawingml/colors.d.ts +6 -0
- package/dist/esm/core/drawingml/colors.js +23 -3
- package/dist/esm/core/drawingml/shape-render.d.ts +3 -1
- package/dist/esm/core/drawingml/shape-render.js +4 -2
- package/dist/esm/core/font/measure.d.ts +9 -0
- package/dist/esm/core/font/measure.js +9 -1
- package/dist/esm/core/fonts/families.js +4 -2
- package/dist/esm/core/fonts/scripts.js +4 -2
- package/dist/esm/core/ir/flow.d.ts +6 -0
- package/dist/esm/core/ir/sheet.d.ts +43 -0
- package/dist/esm/core/number-format.js +16 -11
- package/dist/esm/core/spreadsheet-model/index.d.ts +1 -1
- package/dist/esm/core/spreadsheet-model/types.d.ts +96 -0
- package/dist/esm/core/style-cascade/resolver.js +4 -2
- package/dist/esm/excel/column-bands.d.ts +39 -6
- package/dist/esm/excel/column-bands.js +41 -17
- package/dist/esm/excel/comments-parser.js +19 -0
- package/dist/esm/excel/conditional-format.d.ts +7 -3
- package/dist/esm/excel/conditional-format.js +77 -39
- package/dist/esm/excel/formula/context.d.ts +18 -0
- package/dist/esm/excel/formula/eval.js +51 -0
- package/dist/esm/excel/formula/index.d.ts +2 -2
- package/dist/esm/excel/formula/lexer.d.ts +1 -1
- package/dist/esm/excel/formula/lexer.js +41 -0
- package/dist/esm/excel/formula/parser.d.ts +25 -0
- package/dist/esm/excel/formula/parser.js +95 -0
- package/dist/esm/excel/print-model.d.ts +38 -1
- package/dist/esm/excel/print-model.js +522 -80
- package/dist/esm/excel/shared-strings-parser.d.ts +9 -0
- package/dist/esm/excel/shared-strings-parser.js +11 -1
- package/dist/esm/excel/sheet-drawing.d.ts +38 -2
- package/dist/esm/excel/sheet-drawing.js +47 -13
- package/dist/esm/excel/sheet-shape-parser.d.ts +6 -2
- package/dist/esm/excel/sheet-shape-parser.js +18 -6
- package/dist/esm/excel/sheet-to-flow.d.ts +17 -0
- package/dist/esm/excel/sheet-to-flow.js +434 -47
- package/dist/esm/excel/styles-parser.d.ts +9 -0
- package/dist/esm/excel/styles-parser.js +80 -26
- package/dist/esm/excel/table-parser.js +5 -0
- package/dist/esm/excel/table-style-presets.d.ts +26 -0
- package/dist/esm/excel/table-style-presets.js +1555 -0
- package/dist/esm/excel/table-style.d.ts +13 -0
- package/dist/esm/excel/table-style.js +75 -0
- package/dist/esm/excel/tint.d.ts +10 -0
- package/dist/esm/excel/tint.js +75 -0
- package/dist/esm/excel/vml-drawing.d.ts +41 -3
- package/dist/esm/excel/vml-drawing.js +143 -10
- package/dist/esm/excel/worksheet-parser.js +89 -15
- package/dist/esm/excel/xls/biff-reader.js +10 -2
- package/dist/esm/excel/xlsx-reader.js +195 -14
- package/dist/esm/excel/xlsx-writer.js +8 -7
- package/dist/esm/html/html-writer.js +202 -20
- package/dist/esm/layout/fit-pages.d.ts +11 -0
- package/dist/esm/layout/fit-pages.js +86 -0
- package/dist/esm/layout/line-paint.d.ts +58 -0
- package/dist/esm/layout/line-paint.js +107 -0
- package/dist/esm/layout/page-doc.d.ts +51 -0
- package/dist/esm/layout/page-doc.js +141 -1
- package/dist/esm/layout/styled-layout.d.ts +7 -0
- package/dist/esm/layout/styled-layout.js +274 -51
- package/dist/esm/layout/turned-section.js +14 -2
- package/dist/esm/markdown/markdown-writer.js +17 -6
- package/dist/esm/pdf/styled-page-emitter.js +49 -71
- package/dist/esm/pdf/styled-page-renderer.js +1 -1
- package/dist/esm/pdf-reader/font.js +3 -3
- package/dist/esm/svg/svg-text.d.ts +58 -0
- package/dist/esm/svg/svg-text.js +322 -0
- package/dist/esm/svg/svg-writer.js +135 -71
- package/dist/esm/word/docx-writer.js +11 -2
- package/package.json +5 -1
|
@@ -296,6 +296,21 @@ export interface PageItemBase {
|
|
|
296
296
|
* photograph the slide is made of (corpus: tdf156808, tdf157635, tdf156856).
|
|
297
297
|
*/
|
|
298
298
|
readonly behind?: boolean;
|
|
299
|
+
/**
|
|
300
|
+
* The item stands IN FRONT of the page's text and covers it — a drawing
|
|
301
|
+
* floating over a spreadsheet's cells. A page paints its text after its
|
|
302
|
+
* shapes, so such items are painted as a second layer, every pass again,
|
|
303
|
+
* once the first layer's text is down.
|
|
304
|
+
*/
|
|
305
|
+
readonly over?: boolean;
|
|
306
|
+
/**
|
|
307
|
+
* The part of the page the item may paint, when it is cut off — a
|
|
308
|
+
* spreadsheet's drawing printed in pieces, each piece seen only over the
|
|
309
|
+
* rows and columns of its own page (TableOverlay). Top-left frame, like the
|
|
310
|
+
* item itself. Items sharing a window paint together, in their own order,
|
|
311
|
+
* after the rest of their layer.
|
|
312
|
+
*/
|
|
313
|
+
readonly window?: PageWindow;
|
|
299
314
|
/**
|
|
300
315
|
* The picture this item belongs to, when it is part of one. A metafile is a
|
|
301
316
|
* list of drawing orders, and text among them is BOTH over what came before
|
|
@@ -313,6 +328,13 @@ export interface PageItemBase {
|
|
|
313
328
|
*/
|
|
314
329
|
readonly artifact?: 'pagination';
|
|
315
330
|
}
|
|
331
|
+
/** A rectangle of the page, top-left frame: what a {@link PageItemBase.window} lets through. */
|
|
332
|
+
export interface PageWindow {
|
|
333
|
+
readonly x: Pt;
|
|
334
|
+
readonly y: Pt;
|
|
335
|
+
readonly width: Pt;
|
|
336
|
+
readonly height: Pt;
|
|
337
|
+
}
|
|
316
338
|
/** A laid-out line of text (tokens carry their fonts/sizes/positions). */
|
|
317
339
|
export interface TextLineItem extends PageItemBase {
|
|
318
340
|
readonly type: 'line';
|
|
@@ -466,6 +488,35 @@ export interface PagePaintPlan {
|
|
|
466
488
|
readonly ordered: ReadonlyArray<ReadonlyArray<PageItem>>;
|
|
467
489
|
}
|
|
468
490
|
export declare function paintPlan(commands: ReadonlyArray<PageItem>): PagePaintPlan;
|
|
491
|
+
/**
|
|
492
|
+
* A page's items in the layers they paint in: first the page's own, then each
|
|
493
|
+
* group seen through a window of its own, then the same again for the items
|
|
494
|
+
* that stand in front of the page's text (PageItemBase.over). Each layer is
|
|
495
|
+
* painted pass by pass on its own, so a writer can cut a windowed one off with
|
|
496
|
+
* a single clip. A page with neither comes back as one layer, its items as
|
|
497
|
+
* they were.
|
|
498
|
+
*
|
|
499
|
+
* @param commands The page's items, in the order the layout placed them.
|
|
500
|
+
* @returns The layers, in paint order; empty ones left out.
|
|
501
|
+
*/
|
|
502
|
+
export declare function pageLayers(commands: ReadonlyArray<PageItem>): Array<{
|
|
503
|
+
readonly items: Array<PageItem>;
|
|
504
|
+
readonly window?: PageWindow;
|
|
505
|
+
}>;
|
|
506
|
+
/**
|
|
507
|
+
* The part of the page an item can paint, top-left frame — generous where it
|
|
508
|
+
* cannot be exact (a turned line, a turned picture), so that what falls
|
|
509
|
+
* outside it surely paints nothing there.
|
|
510
|
+
*
|
|
511
|
+
* @param item The item.
|
|
512
|
+
* @returns Its box: left, top, right and bottom edges.
|
|
513
|
+
*/
|
|
514
|
+
export declare function pageItemBounds(item: PageItem): {
|
|
515
|
+
x0: number;
|
|
516
|
+
y0: number;
|
|
517
|
+
x1: number;
|
|
518
|
+
y1: number;
|
|
519
|
+
};
|
|
469
520
|
export interface LaidOutDocument {
|
|
470
521
|
readonly pages: ReadonlyArray<LaidOutPage>;
|
|
471
522
|
readonly resources: ResourceStore;
|
|
@@ -60,8 +60,148 @@ function paintPlan(commands) {
|
|
|
60
60
|
ordered: [...ordered.entries()].sort((a, b) => (orderOf.get(a[0]) ?? 0) - (orderOf.get(b[0]) ?? 0)).map(([, run]) => run)
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* A page's items in the layers they paint in: first the page's own, then each
|
|
65
|
+
* group seen through a window of its own, then the same again for the items
|
|
66
|
+
* that stand in front of the page's text (PageItemBase.over). Each layer is
|
|
67
|
+
* painted pass by pass on its own, so a writer can cut a windowed one off with
|
|
68
|
+
* a single clip. A page with neither comes back as one layer, its items as
|
|
69
|
+
* they were.
|
|
70
|
+
*
|
|
71
|
+
* @param commands The page's items, in the order the layout placed them.
|
|
72
|
+
* @returns The layers, in paint order; empty ones left out.
|
|
73
|
+
*/
|
|
74
|
+
function pageLayers(commands) {
|
|
75
|
+
if (!commands.some((c) => c.over === true || c.window !== void 0)) return [{ items: [...commands] }];
|
|
76
|
+
const out = [];
|
|
77
|
+
for (const over of [false, true]) {
|
|
78
|
+
const layer = commands.filter((c) => c.over === true === over);
|
|
79
|
+
const plain = layer.filter((c) => c.window === void 0);
|
|
80
|
+
if (plain.length > 0 || !over) out.push({ items: plain });
|
|
81
|
+
const windows = /* @__PURE__ */ new Map();
|
|
82
|
+
for (const c of layer) {
|
|
83
|
+
const w = c.window;
|
|
84
|
+
if (!w) continue;
|
|
85
|
+
const key = `${w.x} ${w.y} ${w.width} ${w.height}`;
|
|
86
|
+
const group = windows.get(key);
|
|
87
|
+
if (group) group.items.push(c);
|
|
88
|
+
else windows.set(key, {
|
|
89
|
+
items: [c],
|
|
90
|
+
window: w
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
out.push(...windows.values());
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The part of the page an item can paint, top-left frame — generous where it
|
|
99
|
+
* cannot be exact (a turned line, a turned picture), so that what falls
|
|
100
|
+
* outside it surely paints nothing there.
|
|
101
|
+
*
|
|
102
|
+
* @param item The item.
|
|
103
|
+
* @returns Its box: left, top, right and bottom edges.
|
|
104
|
+
*/
|
|
105
|
+
function pageItemBounds(item) {
|
|
106
|
+
switch (item.type) {
|
|
107
|
+
case "fill": return {
|
|
108
|
+
x0: item.x,
|
|
109
|
+
y0: item.y,
|
|
110
|
+
x1: item.x + item.width,
|
|
111
|
+
y1: item.y + item.height
|
|
112
|
+
};
|
|
113
|
+
case "border": {
|
|
114
|
+
const half = item.borderSizePt / 2;
|
|
115
|
+
return {
|
|
116
|
+
x0: item.x - half,
|
|
117
|
+
y0: item.y - half,
|
|
118
|
+
x1: item.x + item.width + half,
|
|
119
|
+
y1: item.y + item.height + half
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
case "image": {
|
|
123
|
+
if (!item.rotationDeg) return {
|
|
124
|
+
x0: item.x,
|
|
125
|
+
y0: item.y,
|
|
126
|
+
x1: item.x + item.width,
|
|
127
|
+
y1: item.y + item.height
|
|
128
|
+
};
|
|
129
|
+
const r = Math.hypot(item.width, item.height) / 2;
|
|
130
|
+
const cx = item.x + item.width / 2;
|
|
131
|
+
const cy = item.y + item.height / 2;
|
|
132
|
+
return {
|
|
133
|
+
x0: cx - r,
|
|
134
|
+
y0: cy - r,
|
|
135
|
+
x1: cx + r,
|
|
136
|
+
y1: cy + r
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
case "line": {
|
|
140
|
+
if (item.clip) return {
|
|
141
|
+
x0: item.clip.x,
|
|
142
|
+
y0: item.clip.y,
|
|
143
|
+
x1: item.clip.x + item.clip.width,
|
|
144
|
+
y1: item.clip.y + item.clip.height
|
|
145
|
+
};
|
|
146
|
+
const size = item.line.maxFontSizePt;
|
|
147
|
+
const width = item.line.contentWidthPt;
|
|
148
|
+
if (item.rotationDeg || item.warp) {
|
|
149
|
+
const r = width + size;
|
|
150
|
+
return {
|
|
151
|
+
x0: item.originX - r,
|
|
152
|
+
y0: item.baselineY - r,
|
|
153
|
+
x1: item.originX + r,
|
|
154
|
+
y1: item.baselineY + r
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
x0: item.originX,
|
|
159
|
+
y0: item.baselineY - size,
|
|
160
|
+
x1: item.originX + width,
|
|
161
|
+
y1: item.baselineY + (item.line.metricDescentPt ?? size * .25)
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
case "shape": {
|
|
165
|
+
const [a, b, c, d, e, f] = item.shape.transform;
|
|
166
|
+
let x0 = Infinity;
|
|
167
|
+
let y0 = Infinity;
|
|
168
|
+
let x1 = -Infinity;
|
|
169
|
+
let y1 = -Infinity;
|
|
170
|
+
const take = (x, y) => {
|
|
171
|
+
const px = a * x + c * y + e;
|
|
172
|
+
const py = b * x + d * y + f;
|
|
173
|
+
x0 = Math.min(x0, px);
|
|
174
|
+
y0 = Math.min(y0, py);
|
|
175
|
+
x1 = Math.max(x1, px);
|
|
176
|
+
y1 = Math.max(y1, py);
|
|
177
|
+
};
|
|
178
|
+
for (const path of item.shape.paths) for (const seg of path.segments) {
|
|
179
|
+
if (seg.op === "close") continue;
|
|
180
|
+
if (seg.op === "cubic") {
|
|
181
|
+
take(seg.x1, seg.y1);
|
|
182
|
+
take(seg.x2, seg.y2);
|
|
183
|
+
}
|
|
184
|
+
take(seg.x, seg.y);
|
|
185
|
+
}
|
|
186
|
+
if (x0 > x1) return {
|
|
187
|
+
x0: 0,
|
|
188
|
+
y0: 0,
|
|
189
|
+
x1: 0,
|
|
190
|
+
y1: 0
|
|
191
|
+
};
|
|
192
|
+
const pad = (item.shape.stroke?.widthPt ?? 0) / 2 + 1;
|
|
193
|
+
const sh = item.shape.shadow;
|
|
194
|
+
return {
|
|
195
|
+
x0: x0 - pad + Math.min(0, sh?.dxPt ?? 0) - (sh?.blurPt ?? 0),
|
|
196
|
+
y0: y0 - pad + Math.min(0, sh?.dyPt ?? 0) - (sh?.blurPt ?? 0),
|
|
197
|
+
x1: x1 + pad + Math.max(0, sh?.dxPt ?? 0) + (sh?.blurPt ?? 0),
|
|
198
|
+
y1: y1 + pad + Math.max(0, sh?.dyPt ?? 0) + (sh?.blurPt ?? 0)
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
63
203
|
function assertNeverPageItem(item) {
|
|
64
204
|
throw new Error(`Unhandled PageItem kind: ${String(item.type)}`);
|
|
65
205
|
}
|
|
66
206
|
//#endregion
|
|
67
|
-
export { paintPlan };
|
|
207
|
+
export { pageItemBounds, pageLayers, paintPlan };
|
|
@@ -61,6 +61,13 @@ export interface StyledRenderOptions {
|
|
|
61
61
|
readonly layoutProfile?: LayoutProfile;
|
|
62
62
|
/** The application whose rules the document is set by (see {@link TypesetBy}). */
|
|
63
63
|
readonly typesetBy?: TypesetBy;
|
|
64
|
+
/**
|
|
65
|
+
* The document's front floats COVER the text under them. A spreadsheet's
|
|
66
|
+
* drawings float over its cells — a note's box hides the value beside its
|
|
67
|
+
* cell, a chart the data it sits on — where the passes a page is painted in
|
|
68
|
+
* put every line of text over every shape. See `FlowDoc.floatsOverText`.
|
|
69
|
+
*/
|
|
70
|
+
readonly floatsOverText?: boolean;
|
|
64
71
|
/**
|
|
65
72
|
* Per-run font resolution: when supplied, each text run picks the registry of
|
|
66
73
|
* its declared family (sans→arimo / serif→tinos / mono→cousine via the run's
|