docx-wasm 0.4.18-rc2 → 0.4.18-rc21
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/node/builder.js +6 -6
- package/dist/node/builder.js.map +1 -1
- package/dist/node/doc-defaults.d.ts +1 -1
- package/dist/node/doc-defaults.js +15 -4
- package/dist/node/doc-defaults.js.map +1 -1
- package/dist/node/footer.d.ts +1 -5
- package/dist/node/footer.js +0 -8
- package/dist/node/footer.js.map +1 -1
- package/dist/node/header.d.ts +1 -5
- package/dist/node/header.js +0 -8
- package/dist/node/header.js.map +1 -1
- package/dist/node/index.d.ts +7 -2
- package/dist/node/index.js +27 -19
- package/dist/node/index.js.map +1 -1
- package/dist/node/json/bindings/PositionalTab.d.ts +8 -0
- package/dist/node/json/bindings/PositionalTab.js +3 -0
- package/dist/node/json/bindings/PositionalTab.js.map +1 -0
- package/dist/node/json/bindings/PositionalTabAlignmentType.d.ts +1 -0
- package/dist/node/json/bindings/PositionalTabAlignmentType.js +3 -0
- package/dist/node/json/bindings/PositionalTabAlignmentType.js.map +1 -0
- package/dist/node/json/bindings/PositionalTabRelativeTo.d.ts +1 -0
- package/dist/node/json/bindings/PositionalTabRelativeTo.js +3 -0
- package/dist/node/json/bindings/PositionalTabRelativeTo.js.map +1 -0
- package/dist/node/json/paragraph.d.ts +1 -0
- package/dist/node/json/run.d.ts +13 -2
- package/dist/node/level.d.ts +1 -1
- package/dist/node/level.js +11 -10
- package/dist/node/level.js.map +1 -1
- package/dist/node/paragraph-property.d.ts +21 -7
- package/dist/node/paragraph-property.js +258 -31
- package/dist/node/paragraph-property.js.map +1 -1
- package/dist/node/paragraph.d.ts +4 -1
- package/dist/node/paragraph.js +24 -16
- package/dist/node/paragraph.js.map +1 -1
- package/dist/node/pkg/docx_wasm.d.ts +609 -262
- package/dist/node/pkg/docx_wasm.js +1070 -333
- package/dist/node/pkg/docx_wasm_bg.wasm +0 -0
- package/dist/node/pkg/docx_wasm_bg.wasm.d.ts +187 -121
- package/dist/node/positional-tab.d.ts +12 -0
- package/dist/node/positional-tab.js +44 -0
- package/dist/node/positional-tab.js.map +1 -0
- package/dist/node/run-property.d.ts +74 -0
- package/dist/node/run-property.js +303 -0
- package/dist/node/run-property.js.map +1 -0
- package/dist/node/run.d.ts +4 -57
- package/dist/node/run.js +58 -177
- package/dist/node/run.js.map +1 -1
- package/dist/node/style.d.ts +3 -1
- package/dist/node/style.js +42 -42
- package/dist/node/style.js.map +1 -1
- package/dist/node/styles.d.ts +1 -1
- package/dist/node/tab-leader.d.ts +3 -0
- package/dist/node/tab-leader.js +48 -0
- package/dist/node/tab-leader.js.map +1 -0
- package/dist/node/table-cell.js +9 -9
- package/dist/node/table-cell.js.map +1 -1
- package/dist/node/table-of-contents.d.ts +3 -0
- package/dist/node/table-of-contents.js +9 -0
- package/dist/node/table-of-contents.js.map +1 -1
- package/dist/web/builder.js +6 -6
- package/dist/web/builder.js.map +1 -1
- package/dist/web/doc-defaults.d.ts +1 -1
- package/dist/web/doc-defaults.js +15 -4
- package/dist/web/doc-defaults.js.map +1 -1
- package/dist/web/footer.d.ts +1 -5
- package/dist/web/footer.js +0 -8
- package/dist/web/footer.js.map +1 -1
- package/dist/web/header.d.ts +1 -5
- package/dist/web/header.js +0 -8
- package/dist/web/header.js.map +1 -1
- package/dist/web/index.d.ts +7 -2
- package/dist/web/index.js +27 -19
- package/dist/web/index.js.map +1 -1
- package/dist/web/json/bindings/PositionalTab.d.ts +8 -0
- package/dist/web/json/bindings/PositionalTab.js +2 -0
- package/dist/web/json/bindings/PositionalTab.js.map +1 -0
- package/dist/web/json/bindings/PositionalTabAlignmentType.d.ts +1 -0
- package/dist/web/json/bindings/PositionalTabAlignmentType.js +2 -0
- package/dist/web/json/bindings/PositionalTabAlignmentType.js.map +1 -0
- package/dist/web/json/bindings/PositionalTabRelativeTo.d.ts +1 -0
- package/dist/web/json/bindings/PositionalTabRelativeTo.js +2 -0
- package/dist/web/json/bindings/PositionalTabRelativeTo.js.map +1 -0
- package/dist/web/json/paragraph.d.ts +1 -0
- package/dist/web/json/run.d.ts +13 -2
- package/dist/web/level.d.ts +1 -1
- package/dist/web/level.js +11 -10
- package/dist/web/level.js.map +1 -1
- package/dist/web/paragraph-property.d.ts +21 -7
- package/dist/web/paragraph-property.js +255 -30
- package/dist/web/paragraph-property.js.map +1 -1
- package/dist/web/paragraph.d.ts +4 -1
- package/dist/web/paragraph.js +24 -16
- package/dist/web/paragraph.js.map +1 -1
- package/dist/web/pkg/docx_wasm.d.ts +609 -262
- package/dist/web/pkg/docx_wasm_bg.js +1063 -330
- package/dist/web/pkg/docx_wasm_bg.wasm +0 -0
- package/dist/web/pkg/docx_wasm_bg.wasm.d.ts +187 -121
- package/dist/web/positional-tab.d.ts +12 -0
- package/dist/web/positional-tab.js +40 -0
- package/dist/web/positional-tab.js.map +1 -0
- package/dist/web/run-property.d.ts +74 -0
- package/dist/web/run-property.js +271 -0
- package/dist/web/run-property.js.map +1 -0
- package/dist/web/run.d.ts +4 -57
- package/dist/web/run.js +57 -172
- package/dist/web/run.js.map +1 -1
- package/dist/web/style.d.ts +3 -1
- package/dist/web/style.js +42 -42
- package/dist/web/style.js.map +1 -1
- package/dist/web/styles.d.ts +1 -1
- package/dist/web/tab-leader.d.ts +3 -0
- package/dist/web/tab-leader.js +21 -0
- package/dist/web/tab-leader.js.map +1 -0
- package/dist/web/table-cell.js +1 -1
- package/dist/web/table-cell.js.map +1 -1
- package/dist/web/table-of-contents.d.ts +3 -0
- package/dist/web/table-of-contents.js +9 -0
- package/dist/web/table-of-contents.js.map +1 -1
- package/js/builder.ts +8 -8
- package/js/doc-defaults.ts +13 -6
- package/js/footer.ts +1 -13
- package/js/header.ts +1 -13
- package/js/index.ts +30 -21
- package/js/json/bindings/PositionalTab.ts +5 -0
- package/js/json/bindings/PositionalTabAlignmentType.ts +2 -0
- package/js/json/bindings/PositionalTabRelativeTo.ts +2 -0
- package/js/json/paragraph.ts +1 -0
- package/js/json/run.ts +14 -1
- package/js/level.ts +15 -11
- package/js/paragraph-property.ts +299 -37
- package/js/paragraph.ts +28 -17
- package/js/positional-tab.ts +50 -0
- package/js/run-property.ts +383 -0
- package/js/run.ts +50 -256
- package/js/style.ts +45 -49
- package/js/styles.ts +1 -1
- package/js/tab-leader.ts +22 -0
- package/js/table-cell.ts +1 -1
- package/js/table-of-contents.ts +16 -0
- package/package.json +11 -8
package/js/run.ts
CHANGED
|
@@ -6,172 +6,20 @@ import { Tab } from "./tab";
|
|
|
6
6
|
import { Break, BreakType } from "./break";
|
|
7
7
|
import { BorderType } from "./border";
|
|
8
8
|
import { Image } from "./image";
|
|
9
|
+
import { PositionalTab } from "./positional-tab";
|
|
10
|
+
import {
|
|
11
|
+
createDefaultRunProperty,
|
|
12
|
+
RunFonts,
|
|
13
|
+
RunProperty,
|
|
14
|
+
setRunProperty,
|
|
15
|
+
VertAlignType,
|
|
16
|
+
} from "./run-property";
|
|
9
17
|
|
|
10
|
-
export type RunChild = Text | DeleteText | Tab | Break | Image;
|
|
11
|
-
|
|
12
|
-
export type TextBorder = {
|
|
13
|
-
borderType: BorderType;
|
|
14
|
-
color: string;
|
|
15
|
-
space: number;
|
|
16
|
-
size: number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type VertAlignType = "baseline" | "superscript" | "subscript";
|
|
20
|
-
|
|
21
|
-
export type RunPropertyDel = {
|
|
22
|
-
author: string;
|
|
23
|
-
date: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type RunPropertyIns = {
|
|
27
|
-
author: string;
|
|
28
|
-
date: string;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type RunProperty = {
|
|
32
|
-
style?: string;
|
|
33
|
-
size?: number;
|
|
34
|
-
color?: string;
|
|
35
|
-
highlight?: string;
|
|
36
|
-
vertAlign?: VertAlignType;
|
|
37
|
-
bold?: boolean;
|
|
38
|
-
italic?: boolean;
|
|
39
|
-
strike?: boolean;
|
|
40
|
-
underline?: string;
|
|
41
|
-
vanish?: boolean;
|
|
42
|
-
fonts?: RunFonts;
|
|
43
|
-
characterSpacing?: number;
|
|
44
|
-
textBorder?: TextBorder;
|
|
45
|
-
ins?: RunPropertyIns;
|
|
46
|
-
del?: RunPropertyDel;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const convertBorderType = (t: BorderType) => {
|
|
50
|
-
switch (t) {
|
|
51
|
-
case "nil":
|
|
52
|
-
return wasm.BorderType.Nil;
|
|
53
|
-
case "none":
|
|
54
|
-
return wasm.BorderType.None;
|
|
55
|
-
case "single":
|
|
56
|
-
return wasm.BorderType.Single;
|
|
57
|
-
case "thick":
|
|
58
|
-
return wasm.BorderType.Thick;
|
|
59
|
-
case "double":
|
|
60
|
-
return wasm.BorderType.Double;
|
|
61
|
-
case "dotted":
|
|
62
|
-
return wasm.BorderType.Dotted;
|
|
63
|
-
case "dashed":
|
|
64
|
-
return wasm.BorderType.Dashed;
|
|
65
|
-
case "dotDash":
|
|
66
|
-
return wasm.BorderType.DotDash;
|
|
67
|
-
case "dotDotDash":
|
|
68
|
-
return wasm.BorderType.DotDotDash;
|
|
69
|
-
case "triple":
|
|
70
|
-
return wasm.BorderType.Triple;
|
|
71
|
-
default:
|
|
72
|
-
return wasm.BorderType.Single;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const createDefaultRunProperty = (): RunProperty => {
|
|
77
|
-
return {};
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export class RunFonts {
|
|
81
|
-
_ascii?: string;
|
|
82
|
-
_hiAnsi?: string;
|
|
83
|
-
_eastAsia?: string;
|
|
84
|
-
_cs?: string;
|
|
85
|
-
_asciiTheme?: string;
|
|
86
|
-
_hiAnsiTheme?: string;
|
|
87
|
-
_eastAsiaTheme?: string;
|
|
88
|
-
_csTheme?: string;
|
|
89
|
-
_hint?: string;
|
|
90
|
-
|
|
91
|
-
ascii(f: string) {
|
|
92
|
-
this._ascii = f;
|
|
93
|
-
return this;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
hiAnsi(f: string) {
|
|
97
|
-
this._hiAnsi = f;
|
|
98
|
-
return this;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
cs(f: string) {
|
|
102
|
-
this._cs = f;
|
|
103
|
-
return this;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
eastAsia(f: string) {
|
|
107
|
-
this._eastAsia = f;
|
|
108
|
-
return this;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
asciiTheme(f: string) {
|
|
112
|
-
this._asciiTheme = f;
|
|
113
|
-
return this;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
hiAnsiTheme(f: string) {
|
|
117
|
-
this._hiAnsiTheme = f;
|
|
118
|
-
return this;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
csTheme(f: string) {
|
|
122
|
-
this._csTheme = f;
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
eastAsiaTheme(f: string) {
|
|
127
|
-
this._eastAsia = f;
|
|
128
|
-
return this;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
hint(f: string) {
|
|
132
|
-
this._hint = f;
|
|
133
|
-
return this;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
buildWasmObject = () => {
|
|
137
|
-
let f = wasm.createRunFonts();
|
|
138
|
-
if (this?._ascii) {
|
|
139
|
-
f = f.ascii(this._ascii);
|
|
140
|
-
}
|
|
141
|
-
if (this?._hiAnsi) {
|
|
142
|
-
f = f.hi_ansi(this._hiAnsi);
|
|
143
|
-
}
|
|
144
|
-
if (this?._cs) {
|
|
145
|
-
f = f.cs(this._cs);
|
|
146
|
-
}
|
|
147
|
-
if (this?._eastAsia) {
|
|
148
|
-
f = f.east_asia(this._eastAsia);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// theme
|
|
152
|
-
if (this?._asciiTheme) {
|
|
153
|
-
f = f.ascii_theme(this._asciiTheme);
|
|
154
|
-
}
|
|
155
|
-
if (this?._hiAnsiTheme) {
|
|
156
|
-
f = f.hi_ansi_theme(this._hiAnsiTheme);
|
|
157
|
-
}
|
|
158
|
-
if (this?._csTheme) {
|
|
159
|
-
f = f.cs_theme(this._csTheme);
|
|
160
|
-
}
|
|
161
|
-
if (this?._eastAsiaTheme) {
|
|
162
|
-
f = f.east_asia_theme(this._eastAsiaTheme);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (this?._hint) {
|
|
166
|
-
f = f.hint(this._hint);
|
|
167
|
-
}
|
|
168
|
-
return f;
|
|
169
|
-
};
|
|
170
|
-
}
|
|
18
|
+
export type RunChild = Text | DeleteText | Tab | Break | Image | PositionalTab;
|
|
171
19
|
|
|
172
20
|
export class Run {
|
|
173
21
|
children: RunChild[] = [];
|
|
174
|
-
property: RunProperty
|
|
22
|
+
property: RunProperty;
|
|
175
23
|
|
|
176
24
|
addText(text: string) {
|
|
177
25
|
this.children.push(new Text(text));
|
|
@@ -193,91 +41,103 @@ export class Run {
|
|
|
193
41
|
return this;
|
|
194
42
|
}
|
|
195
43
|
|
|
44
|
+
addPositionalTab(ptab: PositionalTab) {
|
|
45
|
+
this.children.push(ptab);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
|
|
196
49
|
addBreak(type: BreakType) {
|
|
197
50
|
this.children.push(new Break(type));
|
|
198
51
|
return this;
|
|
199
52
|
}
|
|
200
53
|
|
|
201
54
|
style(style: string) {
|
|
202
|
-
this.property
|
|
55
|
+
this.property ??= createDefaultRunProperty();
|
|
56
|
+
this.property.style(style);
|
|
203
57
|
return this;
|
|
204
58
|
}
|
|
205
59
|
|
|
206
60
|
size(size: number) {
|
|
207
|
-
this.property
|
|
61
|
+
this.property ??= createDefaultRunProperty();
|
|
62
|
+
this.property.size(size);
|
|
208
63
|
return this;
|
|
209
64
|
}
|
|
210
65
|
|
|
211
66
|
color(color: string) {
|
|
212
|
-
this.property
|
|
67
|
+
this.property ??= createDefaultRunProperty();
|
|
68
|
+
this.property.color(color);
|
|
213
69
|
return this;
|
|
214
70
|
}
|
|
215
71
|
|
|
216
72
|
highlight(color: string) {
|
|
217
|
-
this.property
|
|
73
|
+
this.property ??= createDefaultRunProperty();
|
|
74
|
+
this.property.highlight(color);
|
|
218
75
|
return this;
|
|
219
76
|
}
|
|
220
77
|
|
|
221
78
|
vertAlign(vertAlign: VertAlignType) {
|
|
222
|
-
this.property
|
|
79
|
+
this.property ??= createDefaultRunProperty();
|
|
80
|
+
this.property.vertAlign(vertAlign);
|
|
223
81
|
return this;
|
|
224
82
|
}
|
|
225
83
|
|
|
226
84
|
bold() {
|
|
227
|
-
this.property
|
|
85
|
+
this.property ??= createDefaultRunProperty();
|
|
86
|
+
this.property.bold();
|
|
228
87
|
return this;
|
|
229
88
|
}
|
|
230
89
|
|
|
231
90
|
strike() {
|
|
232
|
-
this.property
|
|
91
|
+
this.property ??= createDefaultRunProperty();
|
|
92
|
+
this.property.strike();
|
|
233
93
|
return this;
|
|
234
94
|
}
|
|
235
95
|
|
|
236
96
|
italic() {
|
|
237
|
-
this.property
|
|
97
|
+
this.property ??= createDefaultRunProperty();
|
|
98
|
+
this.property.italic();
|
|
238
99
|
return this;
|
|
239
100
|
}
|
|
240
101
|
|
|
241
102
|
underline(type: string) {
|
|
242
|
-
this.property
|
|
103
|
+
this.property ??= createDefaultRunProperty();
|
|
104
|
+
this.property.underline(type);
|
|
243
105
|
return this;
|
|
244
106
|
}
|
|
245
107
|
|
|
246
108
|
vanish() {
|
|
247
|
-
this.property
|
|
109
|
+
this.property ??= createDefaultRunProperty();
|
|
110
|
+
this.property.vanish();
|
|
248
111
|
return this;
|
|
249
112
|
}
|
|
250
113
|
|
|
251
114
|
fonts(fonts: RunFonts) {
|
|
252
|
-
this.property
|
|
115
|
+
this.property ??= createDefaultRunProperty();
|
|
116
|
+
this.property.fonts(fonts);
|
|
253
117
|
return this;
|
|
254
118
|
}
|
|
255
119
|
|
|
256
120
|
spacing(characterSpacing: number) {
|
|
257
|
-
this.property
|
|
121
|
+
this.property ??= createDefaultRunProperty();
|
|
122
|
+
this.property.spacing(characterSpacing);
|
|
258
123
|
return this;
|
|
259
124
|
}
|
|
260
125
|
|
|
261
126
|
delete(author: string, date: string) {
|
|
262
|
-
this.property
|
|
127
|
+
this.property ??= createDefaultRunProperty();
|
|
128
|
+
this.property.delete(author, date);
|
|
263
129
|
return this;
|
|
264
130
|
}
|
|
265
131
|
|
|
266
132
|
insert(author: string, date: string) {
|
|
267
|
-
this.property
|
|
133
|
+
this.property ??= createDefaultRunProperty();
|
|
134
|
+
this.property.delete(author, date);
|
|
268
135
|
return this;
|
|
269
136
|
}
|
|
270
137
|
|
|
271
138
|
textBorder(type: BorderType, size: number, space: number, color: string) {
|
|
272
|
-
this.property
|
|
273
|
-
|
|
274
|
-
textBorder: {
|
|
275
|
-
borderType: type,
|
|
276
|
-
size,
|
|
277
|
-
space,
|
|
278
|
-
color,
|
|
279
|
-
},
|
|
280
|
-
};
|
|
139
|
+
this.property ??= createDefaultRunProperty();
|
|
140
|
+
this.property.textBorder(type, size, space, color);
|
|
281
141
|
return this;
|
|
282
142
|
}
|
|
283
143
|
|
|
@@ -290,6 +150,8 @@ export class Run {
|
|
|
290
150
|
run = run.add_delete_text(child.text);
|
|
291
151
|
} else if (child instanceof Tab) {
|
|
292
152
|
run = run.add_tab();
|
|
153
|
+
} else if (child instanceof PositionalTab) {
|
|
154
|
+
run = run.add_ptab(child.buildWasmObject());
|
|
293
155
|
} else if (child instanceof Break) {
|
|
294
156
|
if (child.type === "column") {
|
|
295
157
|
run = run.add_break(wasm.BreakType.Column);
|
|
@@ -319,78 +181,10 @@ export class Run {
|
|
|
319
181
|
}
|
|
320
182
|
});
|
|
321
183
|
|
|
322
|
-
|
|
184
|
+
if (this.property) {
|
|
185
|
+
run = setRunProperty(run, this.property) as wasm.Run;
|
|
186
|
+
}
|
|
323
187
|
|
|
324
188
|
return run;
|
|
325
189
|
}
|
|
326
190
|
}
|
|
327
|
-
|
|
328
|
-
export const setRunProperty = <T extends wasm.Run | wasm.Style>(
|
|
329
|
-
target: T,
|
|
330
|
-
property: RunProperty
|
|
331
|
-
): T => {
|
|
332
|
-
if (property.style && target instanceof wasm.Run) {
|
|
333
|
-
target = target.style(property.style) as T;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
if (typeof property.size !== "undefined") {
|
|
337
|
-
target = target.size(property.size) as T;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
if (property.color) {
|
|
341
|
-
target = target.color(property.color) as T;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
if (property.highlight) {
|
|
345
|
-
target = target.highlight(property.highlight) as T;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
if (property.vertAlign) {
|
|
349
|
-
if (property.vertAlign === "superscript") {
|
|
350
|
-
target = target.vert_align(wasm.VertAlignType.SuperScript) as T;
|
|
351
|
-
} else if (property.vertAlign === "subscript") {
|
|
352
|
-
target = target.vert_align(wasm.VertAlignType.SubScript) as T;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
if (property.bold) {
|
|
357
|
-
target = target.bold() as T;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
if (property.italic) {
|
|
361
|
-
target = target.italic() as T;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
if (property.strike) {
|
|
365
|
-
target = target.strike() as T;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
if (property.underline) {
|
|
369
|
-
target = target.underline(property.underline) as T;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
if (property.vanish) {
|
|
373
|
-
target = target.vanish() as T;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
if (property.characterSpacing != null) {
|
|
377
|
-
target = target.character_spacing(property.characterSpacing) as T;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
if (property.textBorder) {
|
|
381
|
-
const { borderType, color, space, size } = property.textBorder;
|
|
382
|
-
target = target.text_border(
|
|
383
|
-
convertBorderType(borderType),
|
|
384
|
-
size,
|
|
385
|
-
space,
|
|
386
|
-
color
|
|
387
|
-
) as T;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
if (property.fonts) {
|
|
391
|
-
const fonts = property.fonts.buildWasmObject();
|
|
392
|
-
target = target.fonts(fonts) as T;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
return target;
|
|
396
|
-
};
|
package/js/style.ts
CHANGED
|
@@ -13,13 +13,13 @@ import {
|
|
|
13
13
|
VertAlignType,
|
|
14
14
|
RunFonts,
|
|
15
15
|
setRunProperty,
|
|
16
|
-
} from "./run";
|
|
16
|
+
} from "./run-property";
|
|
17
17
|
import {
|
|
18
18
|
AlignmentType,
|
|
19
19
|
createDefaultParagraphProperty,
|
|
20
|
+
createParagraphProperty,
|
|
20
21
|
LineSpacing,
|
|
21
22
|
ParagraphProperty,
|
|
22
|
-
setParagraphProperty,
|
|
23
23
|
SpecialIndentKind,
|
|
24
24
|
} from "./paragraph-property";
|
|
25
25
|
import { BorderType } from "./border";
|
|
@@ -41,7 +41,7 @@ export class Style {
|
|
|
41
41
|
this._styleId = id;
|
|
42
42
|
this._styleType = type;
|
|
43
43
|
this._name = "";
|
|
44
|
-
this._runProperty
|
|
44
|
+
this._runProperty;
|
|
45
45
|
this._tableProperty = { cellMargins: createDefaultTableCellMargins() };
|
|
46
46
|
this._runProperty = createDefaultRunProperty();
|
|
47
47
|
this._paragraphProperty = createDefaultParagraphProperty();
|
|
@@ -64,105 +64,95 @@ export class Style {
|
|
|
64
64
|
return this;
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
// TODO:
|
|
68
|
-
// runProperty = (n: RunProperty) => {
|
|
69
|
-
// this._runProperty = n;
|
|
70
|
-
// return this;
|
|
71
|
-
// };
|
|
72
|
-
|
|
73
67
|
// run property
|
|
74
68
|
style(style: string) {
|
|
75
|
-
this._runProperty
|
|
69
|
+
this._runProperty.style(style);
|
|
76
70
|
return this;
|
|
77
71
|
}
|
|
78
72
|
|
|
79
73
|
size(size: number) {
|
|
80
|
-
this._runProperty
|
|
74
|
+
this._runProperty.size(size);
|
|
81
75
|
return this;
|
|
82
76
|
}
|
|
83
77
|
|
|
84
78
|
color(color: string) {
|
|
85
|
-
this._runProperty
|
|
79
|
+
this._runProperty.color(color);
|
|
86
80
|
return this;
|
|
87
81
|
}
|
|
88
82
|
|
|
89
83
|
highlight(color: string) {
|
|
90
|
-
this._runProperty
|
|
84
|
+
this._runProperty.highlight(color);
|
|
91
85
|
return this;
|
|
92
86
|
}
|
|
93
87
|
|
|
94
88
|
vertAlign(vertAlign: VertAlignType) {
|
|
95
|
-
this._runProperty
|
|
89
|
+
this._runProperty.vertAlign(vertAlign);
|
|
96
90
|
return this;
|
|
97
91
|
}
|
|
98
92
|
|
|
99
93
|
bold() {
|
|
100
|
-
this._runProperty
|
|
94
|
+
this._runProperty.bold();
|
|
101
95
|
return this;
|
|
102
96
|
}
|
|
103
97
|
|
|
104
98
|
strike() {
|
|
105
|
-
this._runProperty
|
|
99
|
+
this._runProperty.strike();
|
|
106
100
|
return this;
|
|
107
101
|
}
|
|
108
102
|
|
|
109
103
|
italic() {
|
|
110
|
-
this._runProperty
|
|
104
|
+
this._runProperty.italic();
|
|
111
105
|
return this;
|
|
112
106
|
}
|
|
113
107
|
|
|
114
108
|
underline(type: string) {
|
|
115
|
-
this._runProperty
|
|
109
|
+
this._runProperty.underline(type);
|
|
116
110
|
return this;
|
|
117
111
|
}
|
|
118
112
|
|
|
119
113
|
vanish() {
|
|
120
|
-
this._runProperty
|
|
114
|
+
this._runProperty.vanish();
|
|
121
115
|
return this;
|
|
122
116
|
}
|
|
123
117
|
|
|
124
118
|
fonts(fonts: RunFonts) {
|
|
125
|
-
this._runProperty
|
|
119
|
+
this._runProperty.fonts(fonts);
|
|
126
120
|
return this;
|
|
127
121
|
}
|
|
128
122
|
|
|
129
123
|
characterSpacing(characterSpacing: number) {
|
|
130
|
-
this._runProperty
|
|
124
|
+
this._runProperty.spacing(characterSpacing);
|
|
131
125
|
return this;
|
|
132
126
|
}
|
|
133
127
|
|
|
134
128
|
delete(author: string, date: string) {
|
|
135
|
-
this._runProperty
|
|
129
|
+
this._runProperty.delete(author, date);
|
|
136
130
|
return this;
|
|
137
131
|
}
|
|
138
132
|
|
|
139
133
|
insert(author: string, date: string) {
|
|
140
|
-
this._runProperty
|
|
134
|
+
this._runProperty.insert(author, date);
|
|
141
135
|
return this;
|
|
142
136
|
}
|
|
143
137
|
|
|
144
138
|
textBorder(type: BorderType, size: number, space: number, color: string) {
|
|
145
|
-
this._runProperty
|
|
146
|
-
...this._runProperty,
|
|
147
|
-
textBorder: {
|
|
148
|
-
borderType: type,
|
|
149
|
-
size,
|
|
150
|
-
space,
|
|
151
|
-
color,
|
|
152
|
-
},
|
|
153
|
-
};
|
|
139
|
+
this._runProperty.textBorder(type, size, space, color);
|
|
154
140
|
return this;
|
|
155
141
|
}
|
|
156
142
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
143
|
+
paragraphProperty = (p: ParagraphProperty) => {
|
|
144
|
+
this._paragraphProperty = p;
|
|
145
|
+
return this;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
runProperty = (p: RunProperty) => {
|
|
149
|
+
this._runProperty = p;
|
|
150
|
+
return this;
|
|
151
|
+
};
|
|
162
152
|
|
|
163
153
|
// paragraph property
|
|
164
154
|
align(type: AlignmentType) {
|
|
165
|
-
this._paragraphProperty.
|
|
155
|
+
this._paragraphProperty._align = type;
|
|
166
156
|
return this;
|
|
167
157
|
}
|
|
168
158
|
|
|
@@ -190,33 +180,31 @@ export class Style {
|
|
|
190
180
|
}
|
|
191
181
|
|
|
192
182
|
keepNext(v: boolean) {
|
|
193
|
-
this._paragraphProperty =
|
|
183
|
+
this._paragraphProperty.keepNext = v;
|
|
194
184
|
return this;
|
|
195
185
|
}
|
|
196
186
|
|
|
197
187
|
keepLines(v: boolean) {
|
|
198
|
-
this._paragraphProperty =
|
|
188
|
+
this._paragraphProperty.keepLines = v;
|
|
199
189
|
return this;
|
|
200
190
|
}
|
|
201
191
|
|
|
202
192
|
pageBreakBefore(v: boolean) {
|
|
203
|
-
this._paragraphProperty =
|
|
204
|
-
...this._paragraphProperty,
|
|
205
|
-
pageBreakBefore: v,
|
|
206
|
-
};
|
|
193
|
+
this._paragraphProperty.pageBreakBefore = v;
|
|
207
194
|
return this;
|
|
208
195
|
}
|
|
209
196
|
|
|
210
197
|
widowControl(v: boolean) {
|
|
211
|
-
this._paragraphProperty =
|
|
198
|
+
this._paragraphProperty.widowControl = v;
|
|
212
199
|
return this;
|
|
213
200
|
}
|
|
214
201
|
|
|
215
202
|
outlineLevel(v: number) {
|
|
216
|
-
this._paragraphProperty =
|
|
203
|
+
this._paragraphProperty.outlineLvl = v;
|
|
217
204
|
return this;
|
|
218
205
|
}
|
|
219
206
|
|
|
207
|
+
// TODO:
|
|
220
208
|
// tableProperty = (n: TableProperty) => {
|
|
221
209
|
// this._tableProperty = n;
|
|
222
210
|
// return this;
|
|
@@ -304,11 +292,19 @@ export class Style {
|
|
|
304
292
|
s = s.link(this._link);
|
|
305
293
|
}
|
|
306
294
|
|
|
307
|
-
|
|
295
|
+
if (this._runProperty) {
|
|
296
|
+
s = setRunProperty(s, this._runProperty);
|
|
297
|
+
}
|
|
308
298
|
|
|
309
|
-
|
|
299
|
+
if (this._paragraphProperty) {
|
|
300
|
+
s = s.paragraph_property(
|
|
301
|
+
createParagraphProperty(this._paragraphProperty)
|
|
302
|
+
);
|
|
303
|
+
}
|
|
310
304
|
|
|
311
|
-
|
|
305
|
+
if (this._tableProperty) {
|
|
306
|
+
s = setTableProperty(s, this._tableProperty);
|
|
307
|
+
}
|
|
312
308
|
|
|
313
309
|
return s;
|
|
314
310
|
};
|
package/js/styles.ts
CHANGED
package/js/tab-leader.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as wasm from "./pkg";
|
|
2
|
+
import { TabLeaderType } from "./json/bindings/TabLeaderType";
|
|
3
|
+
|
|
4
|
+
export const convertTabLeader = (leader: TabLeaderType) => {
|
|
5
|
+
switch (leader) {
|
|
6
|
+
case "dot":
|
|
7
|
+
return wasm.TabLeaderType.Dot;
|
|
8
|
+
break;
|
|
9
|
+
case "heavy":
|
|
10
|
+
return wasm.TabLeaderType.Heavy;
|
|
11
|
+
case "hyphen":
|
|
12
|
+
return wasm.TabLeaderType.Hyphen;
|
|
13
|
+
case "middleDot":
|
|
14
|
+
return wasm.TabLeaderType.MiddleDot;
|
|
15
|
+
case "none":
|
|
16
|
+
return wasm.TabLeaderType.None;
|
|
17
|
+
case "underscore":
|
|
18
|
+
return wasm.TabLeaderType.Underscore;
|
|
19
|
+
default:
|
|
20
|
+
return wasm.TabLeaderType.None;
|
|
21
|
+
}
|
|
22
|
+
};
|
package/js/table-cell.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Shading } from "./shading";
|
|
|
4
4
|
import { TableCellBorders, PositionKeys } from "./table-cell-borders";
|
|
5
5
|
import { TableCellBorderPosition, TableCellBorder } from "./table-cell-border";
|
|
6
6
|
import * as wasm from "./pkg";
|
|
7
|
-
import { convertBorderType } from "./run";
|
|
7
|
+
import { convertBorderType } from "./run-property";
|
|
8
8
|
import { TableOfContents } from "./table-of-contents";
|
|
9
9
|
import { build } from "./builder";
|
|
10
10
|
import { WidthType } from ".";
|
package/js/table-of-contents.ts
CHANGED
|
@@ -3,6 +3,10 @@ import * as wasm from "./pkg";
|
|
|
3
3
|
import { Table } from "./table";
|
|
4
4
|
import { TableOfContentsItem } from "./table-of-contents-item";
|
|
5
5
|
import { build } from "./builder";
|
|
6
|
+
import {
|
|
7
|
+
createParagraphProperty,
|
|
8
|
+
ParagraphProperty,
|
|
9
|
+
} from "./paragraph-property";
|
|
6
10
|
|
|
7
11
|
export class TableOfContents {
|
|
8
12
|
_instrText?: string;
|
|
@@ -18,6 +22,7 @@ export class TableOfContents {
|
|
|
18
22
|
_beforeContents: (Paragraph | Table)[] = [];
|
|
19
23
|
_afterContents: (Paragraph | Table)[] = [];
|
|
20
24
|
_delete: { author: string; date: string } | null = null;
|
|
25
|
+
_paragraphProperty: ParagraphProperty | null = null;
|
|
21
26
|
|
|
22
27
|
constructor(instrText?: string) {
|
|
23
28
|
this._instrText = instrText;
|
|
@@ -93,6 +98,11 @@ export class TableOfContents {
|
|
|
93
98
|
return this;
|
|
94
99
|
};
|
|
95
100
|
|
|
101
|
+
paragraphProperty(p: ParagraphProperty) {
|
|
102
|
+
this._paragraphProperty = p;
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
|
|
96
106
|
buildWasmObject = () => {
|
|
97
107
|
let toc = this._instrText
|
|
98
108
|
? wasm.createTableOfContentsWithInstrText(this._instrText)
|
|
@@ -156,6 +166,12 @@ export class TableOfContents {
|
|
|
156
166
|
}
|
|
157
167
|
}
|
|
158
168
|
|
|
169
|
+
if (this._paragraphProperty) {
|
|
170
|
+
toc = toc.paragraph_property(
|
|
171
|
+
createParagraphProperty(this._paragraphProperty)
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
159
175
|
return toc;
|
|
160
176
|
};
|
|
161
177
|
}
|