docx-wasm 0.4.12-beta2 → 0.4.12-beta4
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/footer.d.ts +3 -1
- package/dist/node/footer.js +4 -0
- package/dist/node/footer.js.map +1 -1
- package/dist/node/header.d.ts +3 -1
- package/dist/node/header.js +4 -0
- package/dist/node/header.js.map +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +31 -6
- package/dist/node/index.js.map +1 -1
- package/dist/node/json/paragraph.d.ts +3 -0
- package/dist/node/page-num.d.ts +31 -0
- package/dist/node/page-num.js +135 -0
- package/dist/node/page-num.js.map +1 -0
- package/dist/node/pkg/docx_wasm.d.ts +139 -60
- package/dist/node/pkg/docx_wasm.js +253 -77
- package/dist/node/pkg/docx_wasm_bg.wasm +0 -0
- package/dist/node/pkg/docx_wasm_bg.wasm.d.ts +83 -67
- package/dist/web/footer.d.ts +3 -1
- package/dist/web/footer.js +4 -0
- package/dist/web/footer.js.map +1 -1
- package/dist/web/header.d.ts +3 -1
- package/dist/web/header.js +4 -0
- package/dist/web/header.js.map +1 -1
- package/dist/web/index.d.ts +1 -0
- package/dist/web/index.js +31 -6
- package/dist/web/index.js.map +1 -1
- package/dist/web/json/paragraph.d.ts +3 -0
- package/dist/web/page-num.d.ts +31 -0
- package/dist/web/page-num.js +108 -0
- package/dist/web/page-num.js.map +1 -0
- package/dist/web/pkg/docx_wasm.d.ts +139 -60
- package/dist/web/pkg/docx_wasm_bg.js +251 -76
- package/dist/web/pkg/docx_wasm_bg.wasm +0 -0
- package/dist/web/pkg/docx_wasm_bg.wasm.d.ts +83 -67
- package/js/footer.ts +7 -1
- package/js/header.ts +7 -1
- package/js/index.ts +25 -6
- package/js/json/paragraph.ts +4 -0
- package/js/page-num.ts +132 -0
- package/package.json +1 -1
package/js/footer.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { PageNum } from "./page-num";
|
|
1
2
|
import { Paragraph } from "./paragraph";
|
|
2
3
|
import { Table } from "./table";
|
|
3
4
|
|
|
4
5
|
export class Footer {
|
|
5
6
|
hasNumberings = false;
|
|
6
|
-
children: (Paragraph | Table)[] = [];
|
|
7
|
+
children: (Paragraph | Table | PageNum)[] = [];
|
|
7
8
|
|
|
8
9
|
addParagraph(p: Paragraph) {
|
|
9
10
|
if (p.hasNumberings) {
|
|
@@ -20,4 +21,9 @@ export class Footer {
|
|
|
20
21
|
this.children.push(t);
|
|
21
22
|
return this;
|
|
22
23
|
}
|
|
24
|
+
|
|
25
|
+
addPageNum(p: PageNum) {
|
|
26
|
+
this.children.push(p);
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
23
29
|
}
|
package/js/header.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { PageNum } from "./page-num";
|
|
1
2
|
import { Paragraph } from "./paragraph";
|
|
2
3
|
import { Table } from "./table";
|
|
3
4
|
|
|
4
5
|
export class Header {
|
|
5
6
|
hasNumberings = false;
|
|
6
|
-
children: (Paragraph | Table)[] = [];
|
|
7
|
+
children: (Paragraph | Table | PageNum)[] = [];
|
|
7
8
|
|
|
8
9
|
addParagraph(p: Paragraph) {
|
|
9
10
|
if (p.hasNumberings) {
|
|
@@ -20,4 +21,9 @@ export class Header {
|
|
|
20
21
|
this.children.push(t);
|
|
21
22
|
return this;
|
|
22
23
|
}
|
|
24
|
+
|
|
25
|
+
addPageNum(p: PageNum) {
|
|
26
|
+
this.children.push(p);
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
23
29
|
}
|
package/js/index.ts
CHANGED
|
@@ -422,8 +422,11 @@ export class Docx {
|
|
|
422
422
|
this.sectionProperty._header.children.forEach((c) => {
|
|
423
423
|
if (c instanceof Paragraph) {
|
|
424
424
|
header = header.add_paragraph(build(c));
|
|
425
|
-
} else {
|
|
425
|
+
} else if (c instanceof Table) {
|
|
426
426
|
header = header.add_table(c.build());
|
|
427
|
+
} else {
|
|
428
|
+
const p = c.build();
|
|
429
|
+
header = header.add_page_num(p);
|
|
427
430
|
}
|
|
428
431
|
});
|
|
429
432
|
docx = docx.header(header);
|
|
@@ -434,8 +437,11 @@ export class Docx {
|
|
|
434
437
|
this.sectionProperty._firstHeader.children.forEach((c) => {
|
|
435
438
|
if (c instanceof Paragraph) {
|
|
436
439
|
header = header.add_paragraph(build(c));
|
|
437
|
-
} else {
|
|
440
|
+
} else if (c instanceof Table) {
|
|
438
441
|
header = header.add_table(c.build());
|
|
442
|
+
} else {
|
|
443
|
+
const p = c.build();
|
|
444
|
+
header = header.add_page_num(p);
|
|
439
445
|
}
|
|
440
446
|
});
|
|
441
447
|
docx = docx.first_header(header);
|
|
@@ -446,8 +452,11 @@ export class Docx {
|
|
|
446
452
|
this.sectionProperty._evenHeader.children.forEach((c) => {
|
|
447
453
|
if (c instanceof Paragraph) {
|
|
448
454
|
header = header.add_paragraph(build(c));
|
|
449
|
-
} else {
|
|
455
|
+
} else if (c instanceof Table) {
|
|
450
456
|
header = header.add_table(c.build());
|
|
457
|
+
} else {
|
|
458
|
+
const p = c.build();
|
|
459
|
+
header = header.add_page_num(p);
|
|
451
460
|
}
|
|
452
461
|
});
|
|
453
462
|
docx = docx.even_header(header);
|
|
@@ -458,8 +467,11 @@ export class Docx {
|
|
|
458
467
|
this.sectionProperty._footer.children.forEach((c) => {
|
|
459
468
|
if (c instanceof Paragraph) {
|
|
460
469
|
footer = footer.add_paragraph(build(c));
|
|
461
|
-
} else {
|
|
470
|
+
} else if (c instanceof Table) {
|
|
462
471
|
footer = footer.add_table(c.build());
|
|
472
|
+
} else {
|
|
473
|
+
const p = c.build();
|
|
474
|
+
footer = footer.add_page_num(p);
|
|
463
475
|
}
|
|
464
476
|
});
|
|
465
477
|
docx = docx.footer(footer);
|
|
@@ -470,8 +482,11 @@ export class Docx {
|
|
|
470
482
|
this.sectionProperty._firstFooter.children.forEach((c) => {
|
|
471
483
|
if (c instanceof Paragraph) {
|
|
472
484
|
footer = footer.add_paragraph(build(c));
|
|
473
|
-
} else {
|
|
485
|
+
} else if (c instanceof Table) {
|
|
474
486
|
footer = footer.add_table(c.build());
|
|
487
|
+
} else {
|
|
488
|
+
const p = c.build();
|
|
489
|
+
footer = footer.add_page_num(p);
|
|
475
490
|
}
|
|
476
491
|
});
|
|
477
492
|
docx = docx.first_footer(footer);
|
|
@@ -482,8 +497,11 @@ export class Docx {
|
|
|
482
497
|
this.sectionProperty._evenFooter.children.forEach((c) => {
|
|
483
498
|
if (c instanceof Paragraph) {
|
|
484
499
|
footer = footer.add_paragraph(build(c));
|
|
485
|
-
} else {
|
|
500
|
+
} else if (c instanceof Table) {
|
|
486
501
|
footer = footer.add_table(c.build());
|
|
502
|
+
} else {
|
|
503
|
+
const p = c.build();
|
|
504
|
+
footer = footer.add_page_num(p);
|
|
487
505
|
}
|
|
488
506
|
});
|
|
489
507
|
docx = docx.even_footer(footer);
|
|
@@ -668,5 +686,6 @@ export * from "./tab";
|
|
|
668
686
|
export * from "./json";
|
|
669
687
|
export * from "./webextension";
|
|
670
688
|
export * from "./header";
|
|
689
|
+
export * from "./page-num";
|
|
671
690
|
export * from "./footer";
|
|
672
691
|
export * from "./image";
|
package/js/json/paragraph.ts
CHANGED
|
@@ -6,6 +6,9 @@ import {
|
|
|
6
6
|
SectionPropertyJSON,
|
|
7
7
|
} from "..";
|
|
8
8
|
import { LineSpacingJSON } from "./line_spacing";
|
|
9
|
+
import { FrameProperty as FramePropertyJSON } from "./bindings/FrameProperty";
|
|
10
|
+
|
|
11
|
+
export { FrameProperty as FramePropertyJSON } from "./bindings/FrameProperty";
|
|
9
12
|
|
|
10
13
|
export type ParagraphChildJSON =
|
|
11
14
|
| RunJSON
|
|
@@ -76,6 +79,7 @@ export type ParagraphPropertyJSON = {
|
|
|
76
79
|
};
|
|
77
80
|
sectionProperty?: SectionPropertyJSON;
|
|
78
81
|
tabs: CustomTabStopJSON[];
|
|
82
|
+
frameProperty?: FramePropertyJSON;
|
|
79
83
|
};
|
|
80
84
|
|
|
81
85
|
export type ParagraphJSON = {
|
package/js/page-num.ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import * as wasm from "./pkg/docx_wasm";
|
|
2
|
+
|
|
3
|
+
export type FrameProperty = {
|
|
4
|
+
h?: number;
|
|
5
|
+
hRule?: string;
|
|
6
|
+
hAnchor?: string;
|
|
7
|
+
hSpace?: number;
|
|
8
|
+
vAnchor?: string;
|
|
9
|
+
vSpace?: number;
|
|
10
|
+
w?: number;
|
|
11
|
+
wrap?: string;
|
|
12
|
+
x?: number;
|
|
13
|
+
xAlign?: string;
|
|
14
|
+
y?: number;
|
|
15
|
+
yAlign?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export class PageNum {
|
|
19
|
+
frameProperty: FrameProperty | null = null;
|
|
20
|
+
|
|
21
|
+
height(h: number) {
|
|
22
|
+
this.frameProperty = { ...this.frameProperty };
|
|
23
|
+
this.frameProperty.h = h;
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
hRule(r: string) {
|
|
27
|
+
this.frameProperty = { ...this.frameProperty };
|
|
28
|
+
this.frameProperty.hRule = r;
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
hAnchor(a: string) {
|
|
33
|
+
this.frameProperty = { ...this.frameProperty };
|
|
34
|
+
this.frameProperty.hAnchor = a;
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
hSpace(s: number) {
|
|
39
|
+
this.frameProperty = { ...this.frameProperty };
|
|
40
|
+
this.frameProperty.hSpace = s;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
vAnchor(a: string) {
|
|
45
|
+
this.frameProperty = { ...this.frameProperty };
|
|
46
|
+
this.frameProperty.vAnchor = a;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
vSpace(s: number) {
|
|
51
|
+
this.frameProperty = { ...this.frameProperty };
|
|
52
|
+
this.frameProperty.vSpace = s;
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
width(w: number) {
|
|
57
|
+
this.frameProperty = { ...this.frameProperty };
|
|
58
|
+
this.frameProperty.w = w;
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
wrap(w: string) {
|
|
63
|
+
this.frameProperty = { ...this.frameProperty };
|
|
64
|
+
this.frameProperty.wrap = w;
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
x(x: number) {
|
|
69
|
+
this.frameProperty = { ...this.frameProperty };
|
|
70
|
+
this.frameProperty.x = x;
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
xAlign(a: string) {
|
|
75
|
+
this.frameProperty = { ...this.frameProperty };
|
|
76
|
+
this.frameProperty.xAlign = a;
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
y(y: number) {
|
|
81
|
+
this.frameProperty = { ...this.frameProperty };
|
|
82
|
+
this.frameProperty.y = y;
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
yAlign(y: string) {
|
|
87
|
+
this.frameProperty = { ...this.frameProperty };
|
|
88
|
+
this.frameProperty.yAlign = y;
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
build() {
|
|
93
|
+
let pageNum = wasm.createPageNum();
|
|
94
|
+
if (this.frameProperty?.h != null) {
|
|
95
|
+
pageNum = pageNum.height(this.frameProperty.h);
|
|
96
|
+
}
|
|
97
|
+
if (this.frameProperty?.hRule != null) {
|
|
98
|
+
pageNum = pageNum.h_rule(this.frameProperty.hRule);
|
|
99
|
+
}
|
|
100
|
+
if (this.frameProperty?.hAnchor != null) {
|
|
101
|
+
pageNum = pageNum.h_anchor(this.frameProperty.hAnchor);
|
|
102
|
+
}
|
|
103
|
+
if (this.frameProperty?.hSpace != null) {
|
|
104
|
+
pageNum = pageNum.h_space(this.frameProperty.hSpace);
|
|
105
|
+
}
|
|
106
|
+
if (this.frameProperty?.vAnchor != null) {
|
|
107
|
+
pageNum = pageNum.v_anchor(this.frameProperty.vAnchor);
|
|
108
|
+
}
|
|
109
|
+
if (this.frameProperty?.vSpace != null) {
|
|
110
|
+
pageNum = pageNum.v_space(this.frameProperty.vSpace);
|
|
111
|
+
}
|
|
112
|
+
if (this.frameProperty?.w != null) {
|
|
113
|
+
pageNum = pageNum.width(this.frameProperty.w);
|
|
114
|
+
}
|
|
115
|
+
if (this.frameProperty?.wrap != null) {
|
|
116
|
+
pageNum = pageNum.wrap(this.frameProperty.wrap);
|
|
117
|
+
}
|
|
118
|
+
if (this.frameProperty?.x != null) {
|
|
119
|
+
pageNum = pageNum.x(this.frameProperty.x);
|
|
120
|
+
}
|
|
121
|
+
if (this.frameProperty?.xAlign != null) {
|
|
122
|
+
pageNum = pageNum.x_align(this.frameProperty.xAlign);
|
|
123
|
+
}
|
|
124
|
+
if (this.frameProperty?.y != null) {
|
|
125
|
+
pageNum = pageNum.y(this.frameProperty.y);
|
|
126
|
+
}
|
|
127
|
+
if (this.frameProperty?.yAlign != null) {
|
|
128
|
+
pageNum = pageNum.y_align(this.frameProperty.yAlign);
|
|
129
|
+
}
|
|
130
|
+
return pageNum;
|
|
131
|
+
}
|
|
132
|
+
}
|