@forevka/wordcanvas 0.7.0 → 0.7.2
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 +48 -1
- package/dist-lib/assets/{worker-BsOsK39A.js → worker-4HYrkNrG.js} +12276 -11981
- package/dist-lib/assets/worker-CJpwUzKh.js +2403 -0
- package/dist-lib/blockFactory-B_CLnkUh.js +106 -0
- package/dist-lib/browser-p_rkUcqE.js +1339 -0
- package/dist-lib/builder.js +365 -109
- package/dist-lib/editorApp-mTD0YNv-.js +9863 -0
- package/dist-lib/export.js +4670 -4567
- package/dist-lib/generate-toc.js +5 -5
- package/dist-lib/import.js +4 -1538
- package/dist-lib/{lists-BegzmTmD.js → lists-Sc5I40JO.js} +2 -2
- package/dist-lib/measure.js +2 -2
- package/dist-lib/{measureHost-CMiJKdlk.js → measureHost-B2aKX7lF.js} +1 -1
- package/dist-lib/metrics-BUMIC9Mv.js +164 -0
- package/dist-lib/pipeline-DD0nxAYM.js +1850 -0
- package/dist-lib/recalc-docx.js +2 -2
- package/dist-lib/recalcToc-CFCGCgij.js +3985 -0
- package/dist-lib/styleProps-DhqDEfvc.js +149 -0
- package/dist-lib/stylesheet-B6oczA-L.js +141 -0
- package/dist-lib/toc-Dj57zdz-.js +213 -0
- package/dist-lib/{webmcp-B7Gvd58E.js → webmcp-CXghUon_.js} +2 -2
- package/dist-lib/{wordcanvas-BAxBeErX.js → wordcanvas-D5DI9ZR1.js} +49 -23
- package/dist-lib/wordcanvas.js +1 -1
- package/dist-node/{chunk-GXFDF7UY.js → chunk-57L5XMCL.js} +327 -59
- package/dist-node/chunk-57L5XMCL.js.map +7 -0
- package/dist-node/{chunk-TBSXA2I4.js → chunk-EGSAVPCC.js} +1 -1
- package/dist-node/chunk-EGSAVPCC.js.map +7 -0
- package/dist-node/{chunk-4PDVRJF6.js → chunk-EMY2P524.js} +32 -2
- package/dist-node/chunk-EMY2P524.js.map +7 -0
- package/dist-node/{chunk-2RCPB7UZ.js → chunk-KJV7GJ3H.js} +1 -1
- package/dist-node/chunk-KJV7GJ3H.js.map +7 -0
- package/dist-node/{chunk-XDUDPPJW.js → chunk-PIMVQULL.js} +93 -24
- package/dist-node/chunk-PIMVQULL.js.map +7 -0
- package/dist-node/{chunk-BRAPV465.js → chunk-SA26UVIJ.js} +2 -2
- package/dist-node/{chunk-IJLL6IFJ.js → chunk-T3253N22.js} +202 -13
- package/dist-node/{chunk-IJLL6IFJ.js.map → chunk-T3253N22.js.map} +2 -2
- package/dist-node/{chunk-4ICCHZX4.js → chunk-U27EBKBG.js} +37 -1
- package/dist-node/chunk-U27EBKBG.js.map +7 -0
- package/dist-node/{engine-FRCX7PXF.js → engine-5F7DUU4W.js} +4 -4
- package/dist-node/export.js +178 -52
- package/dist-node/export.js.map +2 -2
- package/dist-node/generate-toc.js +7 -7
- package/dist-node/import.js +3 -3
- package/dist-node/measure.js +2 -2
- package/dist-node/recalc-docx.js +5 -5
- package/dist-node/recalc-docx.js.map +1 -1
- package/package.json +1 -1
- package/types/model.d.ts +277 -225
- package/types/recalc-docx.d.ts +27 -27
- package/types/wordcanvas.d.ts +212 -157
- package/dist-lib/assets/worker-BbFAIxdy.js +0 -2163
- package/dist-lib/blockFactory-Bcy0U40y.js +0 -178
- package/dist-lib/browser-5Sv4CuNy.js +0 -1284
- package/dist-lib/editorApp-DvjFPHiy.js +0 -7582
- package/dist-lib/metrics-CkAo4zh8.js +0 -143
- package/dist-lib/recalcToc-uaLWt59L.js +0 -3835
- package/dist-lib/styleProps-Db5pEkG8.js +0 -127
- package/dist-lib/toc-CZel_Kk3.js +0 -127
- package/dist-node/chunk-2RCPB7UZ.js.map +0 -7
- package/dist-node/chunk-4ICCHZX4.js.map +0 -7
- package/dist-node/chunk-4PDVRJF6.js.map +0 -7
- package/dist-node/chunk-GXFDF7UY.js.map +0 -7
- package/dist-node/chunk-TBSXA2I4.js.map +0 -7
- package/dist-node/chunk-XDUDPPJW.js.map +0 -7
- /package/dist-node/{chunk-BRAPV465.js.map → chunk-SA26UVIJ.js.map} +0 -0
- /package/dist-node/{engine-FRCX7PXF.js.map → engine-5F7DUU4W.js.map} +0 -0
package/types/model.d.ts
CHANGED
|
@@ -1,225 +1,277 @@
|
|
|
1
|
-
// Public document-model types for @forevka/wordcanvas. Hand-written (like
|
|
2
|
-
// wordcanvas.d.ts) so the published surface stays self-contained and stable;
|
|
3
|
-
// mirrors shared/src/model — the editor, builder, and exporters all consume
|
|
4
|
-
// this same plain-data shape.
|
|
5
|
-
|
|
6
|
-
export interface CharStyle {
|
|
7
|
-
fontFamily: string;
|
|
8
|
-
fontSizePx: number;
|
|
9
|
-
bold: boolean;
|
|
10
|
-
italic: boolean;
|
|
11
|
-
underline: boolean;
|
|
12
|
-
strikethrough: boolean;
|
|
13
|
-
/** CSS color, e.g. "#202124". */
|
|
14
|
-
color: string;
|
|
15
|
-
/** Hidden text (OOXML w:vanish) — preserved but never laid out or painted. */
|
|
16
|
-
hidden?: boolean;
|
|
17
|
-
letterSpacingPx?: number;
|
|
18
|
-
/** Background highlight (Word's text highlight). */
|
|
19
|
-
highlightColor?: string | undefined;
|
|
20
|
-
/** Sub/superscript. */
|
|
21
|
-
verticalAlign?: "sub" | "super" | undefined;
|
|
22
|
-
/** Hyperlink target; linked runs paint blue+underlined. */
|
|
23
|
-
link?: string | undefined;
|
|
24
|
-
/** Footnote reference id — this run is the marker. */
|
|
25
|
-
footnoteRef?: string | undefined;
|
|
26
|
-
/** Content-control membership (properties live in Document.sdts). */
|
|
27
|
-
sdtId?: string | undefined;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export interface
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
1
|
+
// Public document-model types for @forevka/wordcanvas. Hand-written (like
|
|
2
|
+
// wordcanvas.d.ts) so the published surface stays self-contained and stable;
|
|
3
|
+
// mirrors shared/src/model — the editor, builder, and exporters all consume
|
|
4
|
+
// this same plain-data shape.
|
|
5
|
+
|
|
6
|
+
export interface CharStyle {
|
|
7
|
+
fontFamily: string;
|
|
8
|
+
fontSizePx: number;
|
|
9
|
+
bold: boolean;
|
|
10
|
+
italic: boolean;
|
|
11
|
+
underline: boolean;
|
|
12
|
+
strikethrough: boolean;
|
|
13
|
+
/** CSS color, e.g. "#202124". */
|
|
14
|
+
color: string;
|
|
15
|
+
/** Hidden text (OOXML w:vanish) — preserved but never laid out or painted. */
|
|
16
|
+
hidden?: boolean;
|
|
17
|
+
letterSpacingPx?: number;
|
|
18
|
+
/** Background highlight (Word's text highlight). */
|
|
19
|
+
highlightColor?: string | undefined;
|
|
20
|
+
/** Sub/superscript. */
|
|
21
|
+
verticalAlign?: "sub" | "super" | undefined;
|
|
22
|
+
/** Hyperlink target; linked runs paint blue+underlined. */
|
|
23
|
+
link?: string | undefined;
|
|
24
|
+
/** Footnote reference id — this run is the marker. */
|
|
25
|
+
footnoteRef?: string | undefined;
|
|
26
|
+
/** Content-control membership (properties live in Document.sdts). */
|
|
27
|
+
sdtId?: string | undefined;
|
|
28
|
+
/** Character-style reference (w:rStyle → a type==="character" NamedStyle).
|
|
29
|
+
* Reference only — concrete formatting stays baked on the run. */
|
|
30
|
+
charStyleId?: string | undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface TabStop {
|
|
34
|
+
/** Position from the left content edge, px. */
|
|
35
|
+
posPx: number;
|
|
36
|
+
align?: "left" | "center" | "right" | "decimal";
|
|
37
|
+
leader?: "none" | "dot" | "dash" | "underscore";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ParaStyle {
|
|
41
|
+
align: "left" | "center" | "right" | "justify";
|
|
42
|
+
/** Line height multiplier. */
|
|
43
|
+
lineHeight: number;
|
|
44
|
+
spaceBeforePx: number;
|
|
45
|
+
spaceAfterPx: number;
|
|
46
|
+
indentFirstLinePx: number;
|
|
47
|
+
indentLeftPx: number;
|
|
48
|
+
indentRightPx?: number;
|
|
49
|
+
keepWithNext?: boolean;
|
|
50
|
+
keepLinesTogether?: boolean;
|
|
51
|
+
/** This paragraph starts a new page. */
|
|
52
|
+
pageBreakBefore?: boolean;
|
|
53
|
+
/** List membership: definition id + level 0..8. */
|
|
54
|
+
list?: { listId: string; level: number } | undefined;
|
|
55
|
+
/** Named style reference into Document.stylesheet (e.g. "Heading1"). */
|
|
56
|
+
namedStyle?: string;
|
|
57
|
+
columnBreakBefore?: boolean;
|
|
58
|
+
tabStops?: TabStop[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Style-homogeneous span of text. */
|
|
62
|
+
export interface Run {
|
|
63
|
+
text: string;
|
|
64
|
+
style: CharStyle;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface Paragraph {
|
|
68
|
+
kind: "paragraph";
|
|
69
|
+
/** Stable unique id. */
|
|
70
|
+
id: string;
|
|
71
|
+
revision: number;
|
|
72
|
+
runs: Run[];
|
|
73
|
+
style: ParaStyle;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface ImageBlock {
|
|
77
|
+
kind: "image";
|
|
78
|
+
id: string;
|
|
79
|
+
revision: number;
|
|
80
|
+
/** Image URL — use data: URLs for portable documents. */
|
|
81
|
+
src: string;
|
|
82
|
+
/** Content address of the bytes (sha256 hex), when registered. */
|
|
83
|
+
mediaId?: string;
|
|
84
|
+
widthPx: number;
|
|
85
|
+
heightPx: number;
|
|
86
|
+
align: "left" | "center" | "right";
|
|
87
|
+
/** 'block' (default): own line. 'square': floats per align, text wraps. */
|
|
88
|
+
wrap?: "block" | "square";
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface CellBorder {
|
|
92
|
+
color: string;
|
|
93
|
+
widthPx: number;
|
|
94
|
+
style?: "single" | "double" | "dashed" | "dotted";
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface CellBorders {
|
|
98
|
+
top?: CellBorder;
|
|
99
|
+
right?: CellBorder;
|
|
100
|
+
bottom?: CellBorder;
|
|
101
|
+
left?: CellBorder;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface CellMargin {
|
|
105
|
+
top: number;
|
|
106
|
+
right: number;
|
|
107
|
+
bottom: number;
|
|
108
|
+
left: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface TableCell {
|
|
112
|
+
id: string;
|
|
113
|
+
blocks: Block[];
|
|
114
|
+
colSpan?: number;
|
|
115
|
+
rowSpan?: number;
|
|
116
|
+
/** Background fill (CSS color). */
|
|
117
|
+
shading?: string;
|
|
118
|
+
borders?: CellBorders;
|
|
119
|
+
margin?: CellMargin;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface TableRow {
|
|
123
|
+
cells: TableCell[];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface TableCondOverrides {
|
|
127
|
+
firstRow?: boolean;
|
|
128
|
+
lastRow?: boolean;
|
|
129
|
+
firstCol?: boolean;
|
|
130
|
+
lastCol?: boolean;
|
|
131
|
+
bandRows?: boolean;
|
|
132
|
+
bandCols?: boolean;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface TableBlock {
|
|
136
|
+
kind: "table";
|
|
137
|
+
id: string;
|
|
138
|
+
revision: number;
|
|
139
|
+
rows: TableRow[];
|
|
140
|
+
/** Column widths as fractions of content width (sum = 1). Absent = equal. */
|
|
141
|
+
colFractions?: number[];
|
|
142
|
+
/** Table-style reference (→ Document.tableStyles); effective cell formatting is baked. */
|
|
143
|
+
styleId?: string | undefined;
|
|
144
|
+
/** Which conditional bands of the referenced style are active (w:tblLook). */
|
|
145
|
+
condOverrides?: TableCondOverrides;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export type Block = Paragraph | ImageBlock | TableBlock;
|
|
149
|
+
|
|
150
|
+
/** Conditional-format slots of a table style (OOXML w:tblStylePr types). */
|
|
151
|
+
export type TableCond =
|
|
152
|
+
| "wholeTable"
|
|
153
|
+
| "firstRow" | "lastRow" | "firstCol" | "lastCol"
|
|
154
|
+
| "band1Horz" | "band2Horz" | "band1Vert" | "band2Vert"
|
|
155
|
+
| "nwCell" | "neCell" | "swCell" | "seCell";
|
|
156
|
+
|
|
157
|
+
export interface TableCondProps {
|
|
158
|
+
char?: Partial<CharStyle>;
|
|
159
|
+
para?: Partial<ParaStyle>;
|
|
160
|
+
shading?: string;
|
|
161
|
+
borders?: CellBorders;
|
|
162
|
+
margin?: CellMargin;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface TableStyle {
|
|
166
|
+
id: string;
|
|
167
|
+
name: string;
|
|
168
|
+
basedOn?: string;
|
|
169
|
+
conds: Partial<Record<TableCond, TableCondProps>>;
|
|
170
|
+
rowBandSize?: number;
|
|
171
|
+
colBandSize?: number;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export type BandContainer = "header" | "footer" | "headerFirst" | "headerEven" | "footerFirst" | "footerEven";
|
|
175
|
+
|
|
176
|
+
export interface SectionProps {
|
|
177
|
+
pageWidthPx: number;
|
|
178
|
+
pageHeightPx: number;
|
|
179
|
+
marginPx: { top: number; right: number; bottom: number; left: number };
|
|
180
|
+
/** Newspaper columns. Absent = single column. */
|
|
181
|
+
columns?: { count: number; gapPx: number };
|
|
182
|
+
pageNumberStart?: number;
|
|
183
|
+
headerDistancePx?: number;
|
|
184
|
+
footerDistancePx?: number;
|
|
185
|
+
/** Header/footer block stories. {page}/{pages} tokens in run text are
|
|
186
|
+
* substituted per page at layout time. */
|
|
187
|
+
header?: Block[];
|
|
188
|
+
footer?: Block[];
|
|
189
|
+
headerFirst?: Block[];
|
|
190
|
+
headerEven?: Block[];
|
|
191
|
+
footerFirst?: Block[];
|
|
192
|
+
footerEven?: Block[];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export type NamedStyleType = "paragraph" | "character";
|
|
196
|
+
|
|
197
|
+
export interface NamedStyle {
|
|
198
|
+
/** Shares the docx styleId space ("Normal", "Heading1", …). */
|
|
199
|
+
id: string;
|
|
200
|
+
/** Display name. */
|
|
201
|
+
name: string;
|
|
202
|
+
/** Paragraph vs character style. Optional; untyped styles read as "paragraph". */
|
|
203
|
+
type?: NamedStyleType;
|
|
204
|
+
basedOn?: string;
|
|
205
|
+
char: Partial<CharStyle>;
|
|
206
|
+
para: Partial<ParaStyle>;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface Stylesheet {
|
|
210
|
+
styles: NamedStyle[];
|
|
211
|
+
defaultStyleId: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export type ListNumberFormat = "bullet" | "decimal" | "lowerLetter" | "upperLetter" | "lowerRoman" | "upperRoman";
|
|
215
|
+
|
|
216
|
+
export interface ListLevel {
|
|
217
|
+
format: ListNumberFormat;
|
|
218
|
+
/** Marker pattern; %N is level N-1's counter (e.g. "%1."). Ignored for bullets. */
|
|
219
|
+
text: string;
|
|
220
|
+
bulletChar?: string;
|
|
221
|
+
indentLeftPx: number;
|
|
222
|
+
hangingPx: number;
|
|
223
|
+
start: number;
|
|
224
|
+
markerStyle?: Partial<CharStyle>;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export interface ListDefinition {
|
|
228
|
+
id: string;
|
|
229
|
+
/** Up to 9 levels (0..8). */
|
|
230
|
+
levels: ListLevel[];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface DocPosition {
|
|
234
|
+
blockId: string;
|
|
235
|
+
offset: number;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface BookmarkRange {
|
|
239
|
+
start: DocPosition;
|
|
240
|
+
end: DocPosition;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export type SdtType = "richText" | "plainText" | "checkbox" | "dropDown" | "comboBox" | "date";
|
|
244
|
+
|
|
245
|
+
export interface SdtProps {
|
|
246
|
+
type: SdtType;
|
|
247
|
+
alias?: string;
|
|
248
|
+
tag?: string;
|
|
249
|
+
placeholder?: boolean;
|
|
250
|
+
listItems?: { display: string; value: string }[];
|
|
251
|
+
dateFormat?: string;
|
|
252
|
+
checked?: boolean;
|
|
253
|
+
lockContent?: boolean;
|
|
254
|
+
lockControl?: boolean;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export interface Document {
|
|
258
|
+
section: SectionProps;
|
|
259
|
+
blocks: Block[];
|
|
260
|
+
stylesheet?: Stylesheet;
|
|
261
|
+
/** List definitions keyed by id. */
|
|
262
|
+
lists?: Record<string, ListDefinition>;
|
|
263
|
+
/** Table styles keyed by id (docx styleId space). */
|
|
264
|
+
tableStyles?: Record<string, TableStyle>;
|
|
265
|
+
/** Footnote bodies keyed by ref id. */
|
|
266
|
+
footnotes?: Record<string, Paragraph[]>;
|
|
267
|
+
/** Content-control properties keyed by sdtId. */
|
|
268
|
+
sdts?: Record<string, SdtProps>;
|
|
269
|
+
/** Bookmark name → character range. */
|
|
270
|
+
bookmarks?: Record<string, BookmarkRange>;
|
|
271
|
+
/** The document's `TOC` field instruction (e.g. ` TOC \o "1-3" \h `), captured
|
|
272
|
+
* on import. Absent when the document has no TOC field. */
|
|
273
|
+
tocInstruction?: string;
|
|
274
|
+
/** Block id of the paragraph holding the (empty/placeholder) `TOC` field, captured
|
|
275
|
+
* on import so a headless render can build the entries at the right spot. */
|
|
276
|
+
tocAnchorBlockId?: string;
|
|
277
|
+
}
|
package/types/recalc-docx.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
// Public types for @forevka/wordcanvas/recalc-docx — patch a .docx's cached TOC /
|
|
2
|
-
// cross-reference page numbers IN PLACE (drift-free: the file is never re-exported,
|
|
3
|
-
// so every field and unmodeled byte survives). Hand-written + self-contained.
|
|
4
|
-
// Await installMeasureHost() (from "@forevka/wordcanvas/export/measure") first —
|
|
5
|
-
// the layout pass measures text.
|
|
6
|
-
|
|
7
|
-
import type { Document } from "./model";
|
|
8
|
-
|
|
9
|
-
export type { Document } from "./model";
|
|
10
|
-
|
|
11
|
-
export interface PatchResult {
|
|
12
|
-
bytes: Uint8Array;
|
|
13
|
-
/** PAGEREF cached numbers rewritten to a new value. */
|
|
14
|
-
changed: number;
|
|
15
|
-
/** PAGEREF results left untouched because the cached value was non-arabic. */
|
|
16
|
-
skipped: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** Rewrite cached PAGEREF page numbers from a bookmark → page-number map,
|
|
20
|
-
* preserving every field and other part. */
|
|
21
|
-
export declare function patchTocPageNumbers(
|
|
22
|
-
docxBytes: Uint8Array,
|
|
23
|
-
pages: Record<string, string>,
|
|
24
|
-
): PatchResult;
|
|
25
|
-
|
|
26
|
-
/** Lay `doc` out and patch the original `docxBytes` from the resulting page map. */
|
|
27
|
-
export declare function patchTocFromLayout(docxBytes: Uint8Array, doc: Document): PatchResult;
|
|
1
|
+
// Public types for @forevka/wordcanvas/recalc-docx — patch a .docx's cached TOC /
|
|
2
|
+
// cross-reference page numbers IN PLACE (drift-free: the file is never re-exported,
|
|
3
|
+
// so every field and unmodeled byte survives). Hand-written + self-contained.
|
|
4
|
+
// Await installMeasureHost() (from "@forevka/wordcanvas/export/measure") first —
|
|
5
|
+
// the layout pass measures text.
|
|
6
|
+
|
|
7
|
+
import type { Document } from "./model";
|
|
8
|
+
|
|
9
|
+
export type { Document } from "./model";
|
|
10
|
+
|
|
11
|
+
export interface PatchResult {
|
|
12
|
+
bytes: Uint8Array;
|
|
13
|
+
/** PAGEREF cached numbers rewritten to a new value. */
|
|
14
|
+
changed: number;
|
|
15
|
+
/** PAGEREF results left untouched because the cached value was non-arabic. */
|
|
16
|
+
skipped: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Rewrite cached PAGEREF page numbers from a bookmark → page-number map,
|
|
20
|
+
* preserving every field and other part. */
|
|
21
|
+
export declare function patchTocPageNumbers(
|
|
22
|
+
docxBytes: Uint8Array,
|
|
23
|
+
pages: Record<string, string>,
|
|
24
|
+
): PatchResult;
|
|
25
|
+
|
|
26
|
+
/** Lay `doc` out and patch the original `docxBytes` from the resulting page map. */
|
|
27
|
+
export declare function patchTocFromLayout(docxBytes: Uint8Array, doc: Document): PatchResult;
|