rocx-docx 0.0.0-stage → 0.4.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/LICENSE +504 -0
- package/README.md +106 -2
- package/authoring.js +51 -0
- package/boundary.js +314 -0
- package/browser.js +10 -0
- package/file-io.js +88 -0
- package/generate.js +36 -0
- package/index.d.ts +106 -0
- package/node.js +14 -0
- package/package.json +50 -4
- package/pkg/rocx.js +945 -0
- package/pkg/rocx_bg.wasm +0 -0
- package/rocx-source.tar.gz +0 -0
- package/types/authoring.d.ts +120 -0
- package/types/boundary.d.ts +27 -0
- package/types/drawings.d.ts +202 -0
- package/types/editor.d.ts +316 -0
- package/types/file-io.d.ts +31 -0
- package/types/inspection.d.ts +457 -0
- package/types/resolution.d.ts +73 -0
- package/types/structured.d.ts +228 -0
- package/types/styles.d.ts +175 -0
- package/types/tables.d.ts +132 -0
- package/types/template.d.ts +45 -0
- package/types/text-layout.d.ts +348 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type { Condition, ResolvedHandle } from "./boundary.js";
|
|
2
|
+
import type { V } from "./resolution.js";
|
|
3
|
+
import type { BlockChildren, InlineChildren, ResolvedBlock, ResolvedInline } from "./text-layout.js";
|
|
4
|
+
|
|
5
|
+
interface Conditional {
|
|
6
|
+
readonly condition?: Condition;
|
|
7
|
+
}
|
|
8
|
+
interface InlineView<K extends string> {
|
|
9
|
+
readonly kind: K;
|
|
10
|
+
readonly displayText: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type HyperlinkTarget =
|
|
14
|
+
| { readonly kind: "external"; readonly url: string }
|
|
15
|
+
| { readonly kind: "bookmark"; readonly name: string };
|
|
16
|
+
export interface HyperlinkProperties {
|
|
17
|
+
readonly tooltip?: string;
|
|
18
|
+
readonly history?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface HyperlinkDeclaration extends Conditional {
|
|
21
|
+
readonly kind: "hyperlink";
|
|
22
|
+
readonly target: V<HyperlinkTarget>;
|
|
23
|
+
readonly children: V<InlineChildren>;
|
|
24
|
+
readonly properties?: V<HyperlinkProperties>;
|
|
25
|
+
}
|
|
26
|
+
export type ResolvedHyperlink = ResolvedHandle<"inline", InlineView<"hyperlink"> & {
|
|
27
|
+
readonly target: HyperlinkTarget;
|
|
28
|
+
readonly children: readonly ResolvedInline[];
|
|
29
|
+
readonly properties: HyperlinkProperties;
|
|
30
|
+
}>;
|
|
31
|
+
|
|
32
|
+
export type FieldInstruction =
|
|
33
|
+
| { readonly kind: "page" }
|
|
34
|
+
| { readonly kind: "numPages" }
|
|
35
|
+
| { readonly kind: "reference"; readonly name: string }
|
|
36
|
+
| { readonly kind: "tableOfContents" }
|
|
37
|
+
| RawFieldInstruction;
|
|
38
|
+
/** Nonempty XML text checked by Rust, not evaluated or parsed as field syntax. */
|
|
39
|
+
export interface RawFieldInstruction {
|
|
40
|
+
readonly kind: "raw";
|
|
41
|
+
readonly text: string;
|
|
42
|
+
}
|
|
43
|
+
export type FieldForm = "simple" | "complex";
|
|
44
|
+
export interface FieldProperties {
|
|
45
|
+
readonly form?: FieldForm;
|
|
46
|
+
readonly dirty?: boolean;
|
|
47
|
+
readonly locked?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface FieldDeclaration extends Conditional {
|
|
50
|
+
readonly kind: "field";
|
|
51
|
+
readonly instruction: V<FieldInstruction>;
|
|
52
|
+
readonly children: V<InlineChildren>;
|
|
53
|
+
readonly properties?: V<FieldProperties>;
|
|
54
|
+
}
|
|
55
|
+
export type ResolvedField = ResolvedHandle<"inline", InlineView<"field"> & {
|
|
56
|
+
readonly instruction: FieldInstruction;
|
|
57
|
+
readonly instructionText: string;
|
|
58
|
+
readonly children: readonly ResolvedInline[];
|
|
59
|
+
readonly properties: FieldProperties & { readonly form: FieldForm };
|
|
60
|
+
}>;
|
|
61
|
+
|
|
62
|
+
/** Rust's u32 authoring identity. Footnotes and endnotes use separate spaces. */
|
|
63
|
+
export type NoteId = number;
|
|
64
|
+
export type NoteKind = "footnote" | "endnote";
|
|
65
|
+
export interface NoteTarget {
|
|
66
|
+
readonly kind: NoteKind;
|
|
67
|
+
readonly id: NoteId;
|
|
68
|
+
}
|
|
69
|
+
export interface NoteDeclaration extends Conditional {
|
|
70
|
+
readonly kind: "note";
|
|
71
|
+
readonly target: V<NoteTarget>;
|
|
72
|
+
readonly children: V<BlockChildren>;
|
|
73
|
+
}
|
|
74
|
+
export interface NoteReferenceDeclaration extends Conditional {
|
|
75
|
+
readonly kind: "noteReference";
|
|
76
|
+
readonly target: V<NoteTarget>;
|
|
77
|
+
}
|
|
78
|
+
export type ResolvedNote = ResolvedHandle<"note", {
|
|
79
|
+
readonly target: NoteTarget;
|
|
80
|
+
readonly blocks: readonly ResolvedBlock[];
|
|
81
|
+
}>;
|
|
82
|
+
export type ResolvedNoteReference = ResolvedHandle<"inline", InlineView<"noteReference"> & {
|
|
83
|
+
readonly target: NoteTarget;
|
|
84
|
+
}>;
|
|
85
|
+
|
|
86
|
+
export interface ResolvedComment {
|
|
87
|
+
readonly text: string;
|
|
88
|
+
readonly author?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface CommentMetadata {
|
|
91
|
+
readonly author?: string;
|
|
92
|
+
readonly date?: string;
|
|
93
|
+
readonly initials?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface CommentDeclaration extends Conditional {
|
|
96
|
+
readonly kind: "comment";
|
|
97
|
+
readonly children: V<BlockChildren>;
|
|
98
|
+
readonly metadata?: V<CommentMetadata>;
|
|
99
|
+
}
|
|
100
|
+
export type ResolvedCommentBody = ResolvedHandle<"commentBody", {
|
|
101
|
+
readonly blocks: readonly ResolvedBlock[];
|
|
102
|
+
readonly metadata: CommentMetadata;
|
|
103
|
+
}>;
|
|
104
|
+
export type BookmarkName = string;
|
|
105
|
+
export type RangeId = string;
|
|
106
|
+
type FlatRangeKind =
|
|
107
|
+
| { readonly kind: "bookmark"; readonly name: BookmarkName }
|
|
108
|
+
| ({ readonly kind: "comment" } & ResolvedComment);
|
|
109
|
+
export type ResolvedRangeKind =
|
|
110
|
+
| FlatRangeKind
|
|
111
|
+
| { readonly kind: "structuredComment"; readonly comment: ResolvedCommentBody };
|
|
112
|
+
export type RangeKind =
|
|
113
|
+
| ResolvedRangeKind
|
|
114
|
+
| { readonly kind: "structuredComment"; readonly comment: CommentDeclaration };
|
|
115
|
+
export interface RangeStartDeclaration extends Conditional {
|
|
116
|
+
readonly kind: "rangeStart";
|
|
117
|
+
readonly id: V<RangeId>;
|
|
118
|
+
readonly range: V<RangeKind>;
|
|
119
|
+
}
|
|
120
|
+
export interface RangeEndDeclaration extends Conditional {
|
|
121
|
+
readonly kind: "rangeEnd";
|
|
122
|
+
readonly id: V<RangeId>;
|
|
123
|
+
}
|
|
124
|
+
export type ResolvedRangeStart = ResolvedHandle<"inline", InlineView<"rangeStart"> & {
|
|
125
|
+
readonly id: RangeId;
|
|
126
|
+
readonly range: ResolvedRangeKind;
|
|
127
|
+
}>;
|
|
128
|
+
export type ResolvedRangeEnd = ResolvedHandle<"inline", InlineView<"rangeEnd"> & {
|
|
129
|
+
readonly id: RangeId;
|
|
130
|
+
}>;
|
|
131
|
+
/** Derive a range identity using Rust's bookmark policy. */
|
|
132
|
+
export function bookmarkStart(name: BookmarkName): Promise<RangeStartDeclaration>;
|
|
133
|
+
export function bookmarkEnd(name: BookmarkName): Promise<RangeEndDeclaration>;
|
|
134
|
+
|
|
135
|
+
export type ContentControlLock = "unlocked" | "controlLocked" | "contentLocked" | "controlAndContentLocked";
|
|
136
|
+
export interface ContentControlListItem {
|
|
137
|
+
readonly displayText: string;
|
|
138
|
+
readonly value: string;
|
|
139
|
+
}
|
|
140
|
+
export type ContentControlText =
|
|
141
|
+
| { readonly kind: "rich" }
|
|
142
|
+
| { readonly kind: "plain"; readonly multiLine?: boolean }
|
|
143
|
+
| { readonly kind: "dropDown"; readonly items: readonly ContentControlListItem[]; readonly selected: string };
|
|
144
|
+
export interface ContentControlProperties {
|
|
145
|
+
readonly text?: ContentControlText;
|
|
146
|
+
readonly alias?: string;
|
|
147
|
+
readonly tag?: string;
|
|
148
|
+
readonly lock?: ContentControlLock;
|
|
149
|
+
readonly id?: number;
|
|
150
|
+
}
|
|
151
|
+
export interface InlineContentControlDeclaration extends Conditional {
|
|
152
|
+
readonly kind: "contentControl";
|
|
153
|
+
readonly children: V<InlineChildren>;
|
|
154
|
+
readonly properties?: V<ContentControlProperties>;
|
|
155
|
+
}
|
|
156
|
+
export interface BlockContentControlDeclaration extends Conditional {
|
|
157
|
+
readonly kind: "contentControl";
|
|
158
|
+
readonly children: V<BlockChildren>;
|
|
159
|
+
readonly properties?: V<ContentControlProperties>;
|
|
160
|
+
}
|
|
161
|
+
export type ResolvedContentControlProperties = ContentControlProperties & {
|
|
162
|
+
readonly text: ContentControlText;
|
|
163
|
+
};
|
|
164
|
+
export type ResolvedInlineContentControl = ResolvedHandle<"inline", InlineView<"contentControl"> & {
|
|
165
|
+
readonly children: readonly ResolvedInline[];
|
|
166
|
+
readonly properties: ResolvedContentControlProperties;
|
|
167
|
+
}>;
|
|
168
|
+
export type ResolvedBlockContentControl = ResolvedHandle<"blockControl", {
|
|
169
|
+
readonly kind: "contentControl";
|
|
170
|
+
readonly children: readonly ResolvedBlock[];
|
|
171
|
+
readonly properties: ResolvedContentControlProperties;
|
|
172
|
+
}>;
|
|
173
|
+
export function createResolvedBlockControl(
|
|
174
|
+
properties: ContentControlProperties | undefined, children: readonly ResolvedBlock[],
|
|
175
|
+
): Promise<ResolvedBlockContentControl>;
|
|
176
|
+
|
|
177
|
+
export type RevisionKind =
|
|
178
|
+
| { readonly kind: "insertion" }
|
|
179
|
+
| { readonly kind: "deletion" }
|
|
180
|
+
| { readonly kind: "moveSource"; readonly name: BookmarkName }
|
|
181
|
+
| { readonly kind: "moveDestination"; readonly name: BookmarkName };
|
|
182
|
+
export interface TextRevision {
|
|
183
|
+
readonly kind: RevisionKind;
|
|
184
|
+
readonly author: string;
|
|
185
|
+
readonly date?: string;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
type Entry<D, R> = { readonly declaration: D; readonly resolved: R };
|
|
189
|
+
type ControlEntry<D, R, S> = Entry<D, R> & { readonly scope: S };
|
|
190
|
+
export interface StructuredBlockComponents {
|
|
191
|
+
readonly blockControl: ControlEntry<BlockContentControlDeclaration, ResolvedBlockContentControl, "block">;
|
|
192
|
+
}
|
|
193
|
+
export interface StructuredInlineComponents {
|
|
194
|
+
readonly hyperlink: Entry<HyperlinkDeclaration, ResolvedHyperlink>;
|
|
195
|
+
readonly field: Entry<FieldDeclaration, ResolvedField>;
|
|
196
|
+
readonly noteReference: Entry<NoteReferenceDeclaration, ResolvedNoteReference>;
|
|
197
|
+
readonly rangeStart: Entry<RangeStartDeclaration, ResolvedRangeStart>;
|
|
198
|
+
readonly rangeEnd: Entry<RangeEndDeclaration, ResolvedRangeEnd>;
|
|
199
|
+
readonly inlineControl: ControlEntry<InlineContentControlDeclaration, ResolvedInlineContentControl, "inline">;
|
|
200
|
+
}
|
|
201
|
+
export interface StructuredStandaloneComponents {
|
|
202
|
+
readonly note: Entry<NoteDeclaration, ResolvedNote>;
|
|
203
|
+
readonly comment: Entry<CommentDeclaration, ResolvedCommentBody>;
|
|
204
|
+
}
|
|
205
|
+
export interface StructuredDocumentFields {
|
|
206
|
+
readonly notes?: V<readonly V<NoteDeclaration>[]>;
|
|
207
|
+
}
|
|
208
|
+
export interface StructuredDocumentView {
|
|
209
|
+
readonly notes: readonly ResolvedNote[];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface StructuredResolvedInlineArms {
|
|
213
|
+
readonly hyperlink: { readonly target: HyperlinkTarget; readonly properties?: HyperlinkProperties; readonly children: readonly ResolvedInline[] };
|
|
214
|
+
readonly field: { readonly instruction: FieldInstruction; readonly properties?: FieldProperties; readonly children: readonly ResolvedInline[] };
|
|
215
|
+
readonly contentControl: { readonly properties?: ContentControlProperties; readonly children: readonly ResolvedInline[] };
|
|
216
|
+
readonly noteReference: { readonly target: NoteTarget };
|
|
217
|
+
readonly rangeStart: { readonly id: RangeId; readonly range: ResolvedRangeKind };
|
|
218
|
+
readonly rangeEnd: { readonly id: RangeId };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
declare module "./resolution.js" {
|
|
222
|
+
interface ValidationValues {
|
|
223
|
+
readonly resolvedNote: ResolvedNote;
|
|
224
|
+
readonly resolvedCommentBody: ResolvedCommentBody;
|
|
225
|
+
readonly textRevision: TextRevision;
|
|
226
|
+
readonly commentMetadata: CommentMetadata;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { Rgb } from "./boundary.js";
|
|
2
|
+
import type { V } from "./resolution.js";
|
|
3
|
+
import type {
|
|
4
|
+
Alignment, LineHeight, ParagraphFormat, ResolvedParagraphFormat, ResolvedRunFormat, RunFormat,
|
|
5
|
+
RunLanguage, TabStop,
|
|
6
|
+
} from "./text-layout.js";
|
|
7
|
+
|
|
8
|
+
export interface DocumentStyleFields {
|
|
9
|
+
readonly styles?: V<readonly StyleDefinition[]>;
|
|
10
|
+
readonly numbering?: V<readonly NumberingDefinition[]>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface DocumentStyleView {
|
|
14
|
+
readonly styles: readonly ResolvedStyleDefinition[];
|
|
15
|
+
readonly numbering: readonly ResolvedNumberingDefinition[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface ScriptStyleFormat {
|
|
19
|
+
readonly language?: RunLanguage;
|
|
20
|
+
readonly boldComplexScript?: boolean;
|
|
21
|
+
readonly italicComplexScript?: boolean;
|
|
22
|
+
readonly sizeComplexScript?: number;
|
|
23
|
+
readonly rtl?: boolean;
|
|
24
|
+
readonly complexScript?: boolean;
|
|
25
|
+
readonly fontEastAsia?: string;
|
|
26
|
+
readonly fontComplexScript?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface StyleTextFormat extends ScriptStyleFormat {
|
|
30
|
+
readonly bold?: boolean;
|
|
31
|
+
readonly italic?: boolean;
|
|
32
|
+
readonly underline?: boolean;
|
|
33
|
+
readonly font?: string;
|
|
34
|
+
readonly fontSize?: number;
|
|
35
|
+
readonly color?: Rgb;
|
|
36
|
+
readonly alignment?: Alignment;
|
|
37
|
+
readonly spacingBefore?: number;
|
|
38
|
+
readonly spacingAfter?: number;
|
|
39
|
+
readonly lineHeight?: LineHeight;
|
|
40
|
+
readonly tabStops?: readonly TabStop[];
|
|
41
|
+
readonly bidi?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ParagraphStyleDefinition extends StyleTextFormat {
|
|
45
|
+
readonly kind: "paragraph";
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly baseStyle?: string;
|
|
48
|
+
readonly nextParagraphStyle?: string;
|
|
49
|
+
readonly linkedStyle?: string;
|
|
50
|
+
/** Legacy multiple of a line; mutually exclusive with lineHeight. */
|
|
51
|
+
readonly lineSpacing?: number;
|
|
52
|
+
/** Inches, unlike point-based ParagraphFormat indents. */
|
|
53
|
+
readonly leftIndent?: number;
|
|
54
|
+
/** Inches, unlike point-based ParagraphFormat indents. */
|
|
55
|
+
readonly rightIndent?: number;
|
|
56
|
+
/** Inches, unlike point-based ParagraphFormat indents. */
|
|
57
|
+
readonly firstLineIndent?: number;
|
|
58
|
+
readonly keepTogether?: boolean;
|
|
59
|
+
readonly keepWithNext?: boolean;
|
|
60
|
+
readonly pageBreakBefore?: boolean;
|
|
61
|
+
readonly widowControl?: boolean;
|
|
62
|
+
readonly suppressLineNumbers?: boolean;
|
|
63
|
+
readonly contextualSpacing?: boolean;
|
|
64
|
+
readonly mirrorIndents?: boolean;
|
|
65
|
+
readonly snapToGrid?: boolean;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface CharacterStyleDefinition {
|
|
69
|
+
readonly kind: "character";
|
|
70
|
+
readonly name: string;
|
|
71
|
+
readonly baseStyle?: string;
|
|
72
|
+
readonly linkedStyle?: string;
|
|
73
|
+
readonly format?: RunFormat;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface NumberingStyleDefinition {
|
|
77
|
+
readonly kind: "numbering";
|
|
78
|
+
readonly name: string;
|
|
79
|
+
/** ID of an authored concrete instance with local levels. */
|
|
80
|
+
readonly numberingId: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface TableSectionFormat extends StyleTextFormat {
|
|
84
|
+
readonly background?: Rgb;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface TableStyleRegions {
|
|
88
|
+
readonly wholeTable?: TableSectionFormat;
|
|
89
|
+
readonly firstRow?: TableSectionFormat;
|
|
90
|
+
readonly lastRow?: TableSectionFormat;
|
|
91
|
+
readonly firstColumn?: TableSectionFormat;
|
|
92
|
+
readonly lastColumn?: TableSectionFormat;
|
|
93
|
+
readonly banding1Row?: TableSectionFormat;
|
|
94
|
+
readonly banding2Row?: TableSectionFormat;
|
|
95
|
+
readonly banding1Column?: TableSectionFormat;
|
|
96
|
+
readonly banding2Column?: TableSectionFormat;
|
|
97
|
+
readonly topLeftCell?: TableSectionFormat;
|
|
98
|
+
readonly topRightCell?: TableSectionFormat;
|
|
99
|
+
readonly bottomLeftCell?: TableSectionFormat;
|
|
100
|
+
readonly bottomRightCell?: TableSectionFormat;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface TableStyleDefinition extends TableStyleRegions {
|
|
104
|
+
readonly kind: "table";
|
|
105
|
+
readonly name: string;
|
|
106
|
+
readonly baseStyle?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type StyleDefinition =
|
|
110
|
+
| ParagraphStyleDefinition | CharacterStyleDefinition | NumberingStyleDefinition | TableStyleDefinition;
|
|
111
|
+
|
|
112
|
+
type ResolvedTabStops = Pick<ResolvedParagraphFormat, "tabStops">;
|
|
113
|
+
|
|
114
|
+
export type ResolvedStyleDefinition =
|
|
115
|
+
| (ParagraphStyleDefinition & ResolvedTabStops)
|
|
116
|
+
| (Omit<CharacterStyleDefinition, "format"> & { readonly format: ResolvedRunFormat })
|
|
117
|
+
| NumberingStyleDefinition
|
|
118
|
+
| (Omit<TableStyleDefinition, keyof TableStyleRegions> & {
|
|
119
|
+
readonly [K in keyof TableStyleRegions]?: TableSectionFormat & ResolvedTabStops;
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
export type NumberingAlignment = "left" | "center" | "right" | "start" | "end";
|
|
123
|
+
export type NumberingSuffix = "tab" | "space" | "nothing";
|
|
124
|
+
|
|
125
|
+
export interface NumberingReference {
|
|
126
|
+
readonly id: number;
|
|
127
|
+
readonly level: number;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface NumberingStartOverride {
|
|
131
|
+
readonly level: number;
|
|
132
|
+
readonly start: number;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface NumberingLevel {
|
|
136
|
+
readonly level: number;
|
|
137
|
+
readonly start: number;
|
|
138
|
+
readonly format: string;
|
|
139
|
+
readonly text: string;
|
|
140
|
+
readonly isLegal?: boolean;
|
|
141
|
+
readonly suffix?: NumberingSuffix;
|
|
142
|
+
/** One-based restart trigger; zero requests no restart. */
|
|
143
|
+
readonly restart?: number;
|
|
144
|
+
readonly alignment?: NumberingAlignment;
|
|
145
|
+
readonly labelFormat?: RunFormat;
|
|
146
|
+
/** Lengths use points. */
|
|
147
|
+
readonly paragraphFormat?: ParagraphFormat;
|
|
148
|
+
readonly paragraphStyle?: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface NumberingDefinition {
|
|
152
|
+
readonly id: number;
|
|
153
|
+
readonly abstractId?: number;
|
|
154
|
+
readonly inheritStyle?: string;
|
|
155
|
+
readonly levels?: readonly NumberingLevel[];
|
|
156
|
+
readonly startOverrides?: readonly NumberingStartOverride[];
|
|
157
|
+
readonly levelOverrides?: readonly NumberingLevel[];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
type ResolvedNumberingLevel = Omit<NumberingLevel, "labelFormat" | "paragraphFormat"> & {
|
|
161
|
+
readonly labelFormat?: ResolvedRunFormat;
|
|
162
|
+
readonly paragraphFormat?: ResolvedParagraphFormat;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export type ResolvedNumberingDefinition = Omit<NumberingDefinition, "levels" | "startOverrides" | "levelOverrides"> & {
|
|
166
|
+
readonly levels: readonly ResolvedNumberingLevel[];
|
|
167
|
+
readonly startOverrides: readonly NumberingStartOverride[];
|
|
168
|
+
readonly levelOverrides: readonly ResolvedNumberingLevel[];
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
declare module "./resolution.js" {
|
|
172
|
+
interface ValidationValues {
|
|
173
|
+
readonly numberingDefinition: NumberingDefinition;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { Condition, ResolvedHandle, Rgb } from "./boundary.js";
|
|
2
|
+
import type { V } from "./resolution.js";
|
|
3
|
+
import type { ContentControlProperties, ResolvedContentControlProperties } from "./structured.js";
|
|
4
|
+
import type { BlockChildren, ResolvedBlock } from "./text-layout.js";
|
|
5
|
+
|
|
6
|
+
export type TableLayout = "fixed" | "autofit";
|
|
7
|
+
export type TableAlignment = "left" | "center" | "right" | "start" | "end";
|
|
8
|
+
export type VerticalMerge = "restart" | "continue";
|
|
9
|
+
export type VerticalAlignment = "top" | "center" | "bottom" | "both";
|
|
10
|
+
export type BorderLine = "single" | "dashed";
|
|
11
|
+
export type BorderSide = "top" | "left" | "bottom" | "right" | "insideH" | "insideV";
|
|
12
|
+
export type CellBorderSide = "top" | "bottom" | "start" | "end";
|
|
13
|
+
export type CellTextDirection =
|
|
14
|
+
| "leftToRight"
|
|
15
|
+
| "topToBottomRightToLeft"
|
|
16
|
+
| "bottomToTopLeftToRight"
|
|
17
|
+
| "leftToRightVertical"
|
|
18
|
+
| "topToBottomRightToLeftVertical"
|
|
19
|
+
| "topToBottomLeftToRightVertical";
|
|
20
|
+
|
|
21
|
+
export interface TableBorder {
|
|
22
|
+
readonly side: BorderSide;
|
|
23
|
+
/** Border size in eighths of a point. */
|
|
24
|
+
readonly sz: number;
|
|
25
|
+
readonly color: Rgb;
|
|
26
|
+
readonly val: BorderLine;
|
|
27
|
+
}
|
|
28
|
+
export interface CellBorder extends Omit<TableBorder, "side"> {
|
|
29
|
+
readonly side: CellBorderSide;
|
|
30
|
+
}
|
|
31
|
+
export interface TableLook {
|
|
32
|
+
readonly firstRow?: boolean;
|
|
33
|
+
readonly lastRow?: boolean;
|
|
34
|
+
readonly firstColumn?: boolean;
|
|
35
|
+
readonly lastColumn?: boolean;
|
|
36
|
+
readonly horizontalBanding?: boolean;
|
|
37
|
+
readonly verticalBanding?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface TableProperties {
|
|
40
|
+
/** Column widths in twips. Autofit ignores these during rendering. */
|
|
41
|
+
readonly columnWidths?: readonly number[];
|
|
42
|
+
readonly layout?: TableLayout;
|
|
43
|
+
readonly style?: string;
|
|
44
|
+
readonly borders?: readonly TableBorder[];
|
|
45
|
+
readonly look?: TableLook;
|
|
46
|
+
readonly alignment?: TableAlignment;
|
|
47
|
+
}
|
|
48
|
+
export type RowHeight =
|
|
49
|
+
| { readonly kind: "exact"; readonly points: number }
|
|
50
|
+
| { readonly kind: "atLeast"; readonly points: number };
|
|
51
|
+
export interface TableRowProperties {
|
|
52
|
+
readonly height?: RowHeight;
|
|
53
|
+
readonly repeatHeader?: boolean;
|
|
54
|
+
readonly cantSplit?: boolean;
|
|
55
|
+
/** Row wrappers require rich text. */
|
|
56
|
+
readonly contentControl?: ContentControlProperties;
|
|
57
|
+
}
|
|
58
|
+
/** Optional cell-local margins in points. */
|
|
59
|
+
export interface CellMargins {
|
|
60
|
+
readonly top?: number;
|
|
61
|
+
readonly start?: number;
|
|
62
|
+
readonly bottom?: number;
|
|
63
|
+
readonly end?: number;
|
|
64
|
+
}
|
|
65
|
+
export interface TableCellProperties {
|
|
66
|
+
readonly gridSpan?: number;
|
|
67
|
+
readonly vmerge?: VerticalMerge;
|
|
68
|
+
readonly borders?: readonly CellBorder[];
|
|
69
|
+
readonly backgroundColor?: Rgb;
|
|
70
|
+
readonly verticalAlignment?: VerticalAlignment;
|
|
71
|
+
readonly margins?: CellMargins;
|
|
72
|
+
readonly textDirection?: CellTextDirection;
|
|
73
|
+
/** Cell wrappers require rich text. */
|
|
74
|
+
readonly contentControl?: ContentControlProperties;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface TableDeclaration {
|
|
78
|
+
readonly kind: "table";
|
|
79
|
+
readonly rows: V<readonly V<TableRowDeclaration>[]>;
|
|
80
|
+
readonly properties?: V<TableProperties>;
|
|
81
|
+
readonly condition?: Condition;
|
|
82
|
+
}
|
|
83
|
+
export interface TableRowDeclaration {
|
|
84
|
+
readonly kind: "tableRow";
|
|
85
|
+
readonly children: V<readonly V<TableCellDeclaration>[]>;
|
|
86
|
+
readonly properties?: V<TableRowProperties>;
|
|
87
|
+
readonly condition?: Condition;
|
|
88
|
+
}
|
|
89
|
+
export interface TableCellDeclaration {
|
|
90
|
+
readonly kind: "tableCell";
|
|
91
|
+
readonly children: V<BlockChildren>;
|
|
92
|
+
readonly properties?: V<TableCellProperties>;
|
|
93
|
+
readonly condition?: Condition;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface ResolvedTableView {
|
|
97
|
+
readonly columns: number;
|
|
98
|
+
readonly properties: TableProperties & { readonly borders: readonly TableBorder[] };
|
|
99
|
+
/** Physical resolved rows, before rendering pads ragged rows. */
|
|
100
|
+
readonly rows: readonly ResolvedTableRow[];
|
|
101
|
+
}
|
|
102
|
+
export interface ResolvedTableRowView {
|
|
103
|
+
readonly properties: Omit<TableRowProperties, "contentControl"> & {
|
|
104
|
+
readonly contentControl?: ResolvedContentControlProperties;
|
|
105
|
+
};
|
|
106
|
+
readonly cells: readonly ResolvedTableCell[];
|
|
107
|
+
}
|
|
108
|
+
export interface ResolvedTableCellView extends TableCellProperties {
|
|
109
|
+
readonly gridSpan: number;
|
|
110
|
+
readonly borders: readonly CellBorder[];
|
|
111
|
+
readonly contentControl?: ResolvedContentControlProperties;
|
|
112
|
+
readonly blocks: readonly ResolvedBlock[];
|
|
113
|
+
}
|
|
114
|
+
export type ResolvedTable = ResolvedHandle<"table", ResolvedTableView>;
|
|
115
|
+
export type ResolvedTableRow = ResolvedHandle<"tableRow", ResolvedTableRowView>;
|
|
116
|
+
export type ResolvedTableCell = ResolvedHandle<"tableCell", ResolvedTableCellView>;
|
|
117
|
+
|
|
118
|
+
export interface TableComponents {
|
|
119
|
+
readonly table: { readonly declaration: TableDeclaration; readonly resolved: ResolvedTable };
|
|
120
|
+
}
|
|
121
|
+
export interface TableStandaloneComponents {
|
|
122
|
+
readonly tableRow: { readonly declaration: TableRowDeclaration; readonly resolved: ResolvedTableRow };
|
|
123
|
+
readonly tableCell: { readonly declaration: TableCellDeclaration; readonly resolved: ResolvedTableCell };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
declare module "./resolution.js" {
|
|
127
|
+
interface ValidationValues {
|
|
128
|
+
readonly tableRowProperties: TableRowProperties;
|
|
129
|
+
readonly tableCellProperties: TableCellProperties;
|
|
130
|
+
readonly cellMargins: CellMargins;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { RenderOptions } from "./boundary.js";
|
|
2
|
+
import type { ResolvedDocument } from "./text-layout.js";
|
|
3
|
+
|
|
4
|
+
export type EditScope = "body" | "bodyHeadersFooters" | "supportedStories";
|
|
5
|
+
export type TextRevisionAction = "accept" | "reject";
|
|
6
|
+
|
|
7
|
+
export interface TemplateEdits {
|
|
8
|
+
/** Applied in order to the source stories, before inserting new declarations. */
|
|
9
|
+
readonly replacements?: readonly (readonly [needle: string, replacement: string])[];
|
|
10
|
+
readonly contentControlReplacements?: Readonly<Record<string, string>>;
|
|
11
|
+
readonly textRevisionAction?: TextRevisionAction;
|
|
12
|
+
/** Zero-based among original direct body paragraphs; past the end appends. */
|
|
13
|
+
readonly paragraphIndex?: number;
|
|
14
|
+
readonly scope?: EditScope;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface TemplateSource {
|
|
18
|
+
readonly bytes: Uint8Array;
|
|
19
|
+
readonly edits?: TemplateEdits;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type PackagePart = readonly [name: string, payload: Uint8Array<ArrayBuffer>];
|
|
23
|
+
|
|
24
|
+
declare const packagePlan: unique symbol;
|
|
25
|
+
export interface PackagePlan {
|
|
26
|
+
readonly [packagePlan]: true;
|
|
27
|
+
/** Sorted by ZIP entry name. Payloads are independent copies. */
|
|
28
|
+
parts(): readonly PackagePart[];
|
|
29
|
+
/** Exact, case-sensitive lookup by OPC part name (leading slash optional). */
|
|
30
|
+
part(name: string): Uint8Array<ArrayBuffer> | undefined;
|
|
31
|
+
validate(): void;
|
|
32
|
+
toBytes(): Uint8Array<ArrayBuffer>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function compileTemplate(
|
|
36
|
+
document: ResolvedDocument,
|
|
37
|
+
source: TemplateSource,
|
|
38
|
+
options?: RenderOptions,
|
|
39
|
+
): Promise<PackagePlan>;
|
|
40
|
+
|
|
41
|
+
declare module "./text-layout.js" {
|
|
42
|
+
interface ResolvedDocument {
|
|
43
|
+
toDocxWithTemplate(source: TemplateSource, options?: RenderOptions): Uint8Array<ArrayBuffer>;
|
|
44
|
+
}
|
|
45
|
+
}
|