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/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Paragraph } from "./paragraph";
|
|
|
2
2
|
import { LineSpacing, ParagraphProperty } from "./paragraph-property";
|
|
3
3
|
import { Table } from "./table";
|
|
4
4
|
import { TableOfContents } from "./table-of-contents";
|
|
5
|
-
import { RunFonts } from "./run";
|
|
5
|
+
import { RunFonts } from "./run-property";
|
|
6
6
|
import { AbstractNumbering } from "./abstract-numbering";
|
|
7
7
|
import { Numbering } from "./numbering";
|
|
8
8
|
import { BookmarkStart } from "./bookmark-start";
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
PageMargin,
|
|
22
22
|
PageOrientationType,
|
|
23
23
|
} from "./section-property";
|
|
24
|
-
import { DocGridType, DocxJSON } from "./json";
|
|
24
|
+
import { CommentJSON, DocGridType, DocxJSON } from "./json";
|
|
25
25
|
|
|
26
26
|
import * as wasm from "./pkg";
|
|
27
27
|
import { Level } from "./level";
|
|
@@ -290,31 +290,31 @@ export class Docx {
|
|
|
290
290
|
level = level.suffix(wasm.LevelSuffixType.Tab);
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
if (l.runProperty.
|
|
293
|
+
if (l.runProperty._bold) {
|
|
294
294
|
level = level.bold();
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
if (l.runProperty.
|
|
297
|
+
if (l.runProperty._italic) {
|
|
298
298
|
level = level.italic();
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
if (l.runProperty.
|
|
302
|
-
level = level.size(l.runProperty.
|
|
301
|
+
if (l.runProperty._size) {
|
|
302
|
+
level = level.size(l.runProperty._size);
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
if (l.runProperty.
|
|
305
|
+
if (l.runProperty._fonts) {
|
|
306
306
|
let f = wasm.createRunFonts();
|
|
307
|
-
if (l.runProperty.
|
|
308
|
-
f = f.ascii(l.runProperty.
|
|
307
|
+
if (l.runProperty._fonts._ascii) {
|
|
308
|
+
f = f.ascii(l.runProperty._fonts._ascii);
|
|
309
309
|
}
|
|
310
|
-
if (l.runProperty.
|
|
311
|
-
f = f.hi_ansi(l.runProperty.
|
|
310
|
+
if (l.runProperty._fonts._hiAnsi) {
|
|
311
|
+
f = f.hi_ansi(l.runProperty._fonts._hiAnsi);
|
|
312
312
|
}
|
|
313
|
-
if (l.runProperty.
|
|
314
|
-
f = f.cs(l.runProperty.
|
|
313
|
+
if (l.runProperty._fonts._cs) {
|
|
314
|
+
f = f.cs(l.runProperty._fonts._cs);
|
|
315
315
|
}
|
|
316
|
-
if (l.runProperty.
|
|
317
|
-
f = f.east_asia(l.runProperty.
|
|
316
|
+
if (l.runProperty._fonts._eastAsia) {
|
|
317
|
+
f = f.east_asia(l.runProperty._fonts._eastAsia);
|
|
318
318
|
}
|
|
319
319
|
level = level.fonts(f);
|
|
320
320
|
}
|
|
@@ -548,20 +548,20 @@ export class Docx {
|
|
|
548
548
|
|
|
549
549
|
if (this.styles?.docDefaults) {
|
|
550
550
|
if (this.styles.docDefaults.runProperty) {
|
|
551
|
-
if (this.styles.docDefaults.runProperty.
|
|
551
|
+
if (this.styles.docDefaults.runProperty._fonts) {
|
|
552
552
|
const fonts = this.buildRunFonts(
|
|
553
|
-
this.styles.docDefaults.runProperty.
|
|
553
|
+
this.styles.docDefaults.runProperty._fonts
|
|
554
554
|
);
|
|
555
555
|
docx = docx.default_fonts(fonts);
|
|
556
556
|
}
|
|
557
557
|
|
|
558
|
-
if (this.styles.docDefaults.runProperty.
|
|
559
|
-
docx = docx.default_size(this.styles.docDefaults.runProperty.
|
|
558
|
+
if (this.styles.docDefaults.runProperty._size) {
|
|
559
|
+
docx = docx.default_size(this.styles.docDefaults.runProperty._size);
|
|
560
560
|
}
|
|
561
561
|
|
|
562
|
-
if (this.styles.docDefaults.runProperty.
|
|
562
|
+
if (this.styles.docDefaults.runProperty._characterSpacing) {
|
|
563
563
|
docx = docx.default_spacing(
|
|
564
|
-
this.styles.docDefaults.runProperty.
|
|
564
|
+
this.styles.docDefaults.runProperty._characterSpacing
|
|
565
565
|
);
|
|
566
566
|
}
|
|
567
567
|
}
|
|
@@ -626,6 +626,13 @@ export class Docx {
|
|
|
626
626
|
return JSON.parse(json) as DocxJSON;
|
|
627
627
|
}
|
|
628
628
|
|
|
629
|
+
commentsJson() {
|
|
630
|
+
const docx = this.createDocx();
|
|
631
|
+
const json = docx.comments_json();
|
|
632
|
+
docx.free();
|
|
633
|
+
return JSON.parse(json) as { comments: CommentJSON[] };
|
|
634
|
+
}
|
|
635
|
+
|
|
629
636
|
build() {
|
|
630
637
|
const docx = this.createDocx();
|
|
631
638
|
const buf = docx.build(this.hasNumberings);
|
|
@@ -651,6 +658,7 @@ export * from "./table-of-contents";
|
|
|
651
658
|
export * from "./table-of-contents-item";
|
|
652
659
|
export * from "./table-row";
|
|
653
660
|
export * from "./run";
|
|
661
|
+
export * from "./run-property";
|
|
654
662
|
export * from "./text";
|
|
655
663
|
export * from "./style";
|
|
656
664
|
export * from "./styles";
|
|
@@ -672,3 +680,4 @@ export * from "./page-num";
|
|
|
672
680
|
export * from "./num-pages";
|
|
673
681
|
export * from "./footer";
|
|
674
682
|
export * from "./image";
|
|
683
|
+
export * from "./positional-tab";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PositionalTabAlignmentType } from "./PositionalTabAlignmentType";
|
|
2
|
+
import type { PositionalTabRelativeTo } from "./PositionalTabRelativeTo";
|
|
3
|
+
import type { TabLeaderType } from "./TabLeaderType";
|
|
4
|
+
|
|
5
|
+
export interface PositionalTab { alignment: PositionalTabAlignmentType, relativeTo: PositionalTabRelativeTo, leader: TabLeaderType, }
|
package/js/json/paragraph.ts
CHANGED
package/js/json/run.ts
CHANGED
|
@@ -7,10 +7,13 @@ import {
|
|
|
7
7
|
DeleteJSONData,
|
|
8
8
|
} from "..";
|
|
9
9
|
import { BorderType } from "../border";
|
|
10
|
-
import { VertAlignType } from "../run";
|
|
10
|
+
import { VertAlignType } from "../run-property";
|
|
11
11
|
import { FieldChar } from "./bindings/FieldChar";
|
|
12
12
|
import { InstrHyperlink } from "./bindings/InstrHyperlink";
|
|
13
13
|
import { InstrToC } from "./bindings/InstrToC";
|
|
14
|
+
import { PositionalTabAlignmentType } from "./bindings/PositionalTabAlignmentType";
|
|
15
|
+
import { PositionalTabRelativeTo } from "./bindings/PositionalTabRelativeTo";
|
|
16
|
+
import { TabLeaderType } from "./bindings/TabLeaderType";
|
|
14
17
|
|
|
15
18
|
export type TextBorderJSON = {
|
|
16
19
|
borderType: BorderType;
|
|
@@ -61,6 +64,7 @@ export type RunChildJSON =
|
|
|
61
64
|
| TabJSON
|
|
62
65
|
| BreakJSON
|
|
63
66
|
| DrawingJSON
|
|
67
|
+
| PtabJSON
|
|
64
68
|
| ShapeJSON
|
|
65
69
|
| CommentRangeStartJSON
|
|
66
70
|
| CommentRangeEndJSON
|
|
@@ -75,6 +79,15 @@ export type TextJSON = {
|
|
|
75
79
|
};
|
|
76
80
|
};
|
|
77
81
|
|
|
82
|
+
export type PtabJSON = {
|
|
83
|
+
type: "ptab";
|
|
84
|
+
data: {
|
|
85
|
+
alignment: PositionalTabAlignmentType;
|
|
86
|
+
relativeTo: PositionalTabRelativeTo;
|
|
87
|
+
leader: TabLeaderType;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
78
91
|
export type SymJSON = {
|
|
79
92
|
type: "sym";
|
|
80
93
|
data: {
|
package/js/level.ts
CHANGED
|
@@ -4,7 +4,11 @@ import {
|
|
|
4
4
|
ParagraphProperty,
|
|
5
5
|
SpecialIndentKind,
|
|
6
6
|
} from "./paragraph-property";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
createDefaultRunProperty,
|
|
9
|
+
RunFonts,
|
|
10
|
+
RunProperty,
|
|
11
|
+
} from "./run-property";
|
|
8
12
|
|
|
9
13
|
export type LevelSuffixType = "nothing" | "tab" | "space";
|
|
10
14
|
|
|
@@ -15,7 +19,7 @@ export class Level {
|
|
|
15
19
|
text: string;
|
|
16
20
|
jc: string;
|
|
17
21
|
paragraphProperty: ParagraphProperty = createDefaultParagraphProperty();
|
|
18
|
-
runProperty: RunProperty =
|
|
22
|
+
runProperty: RunProperty = createDefaultRunProperty();
|
|
19
23
|
levelSuffix: LevelSuffixType;
|
|
20
24
|
|
|
21
25
|
constructor(
|
|
@@ -52,47 +56,47 @@ export class Level {
|
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
size(size: number) {
|
|
55
|
-
this.runProperty
|
|
59
|
+
this.runProperty.size(size);
|
|
56
60
|
return this;
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
color(color: string) {
|
|
60
|
-
this.runProperty
|
|
64
|
+
this.runProperty.color(color);
|
|
61
65
|
return this;
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
highlight(color: string) {
|
|
65
|
-
this.runProperty
|
|
69
|
+
this.runProperty.highlight(color);
|
|
66
70
|
return this;
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
bold() {
|
|
70
|
-
this.runProperty
|
|
74
|
+
this.runProperty.bold();
|
|
71
75
|
return this;
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
italic() {
|
|
75
|
-
this.runProperty
|
|
79
|
+
this.runProperty.italic();
|
|
76
80
|
return this;
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
underline(type: string) {
|
|
80
|
-
this.runProperty
|
|
84
|
+
this.runProperty.underline(type);
|
|
81
85
|
return this;
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
vanish() {
|
|
85
|
-
this.runProperty
|
|
89
|
+
this.runProperty.vanish();
|
|
86
90
|
return this;
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
fonts(fonts: RunFonts) {
|
|
90
|
-
this.runProperty
|
|
94
|
+
this.runProperty.fonts(fonts);
|
|
91
95
|
return this;
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
characterSpacing(characterSpacing: number) {
|
|
95
|
-
this.runProperty
|
|
99
|
+
this.runProperty.spacing(characterSpacing);
|
|
96
100
|
return this;
|
|
97
101
|
}
|
|
98
102
|
}
|
package/js/paragraph-property.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { RunProperty, createDefaultRunProperty } from "./run";
|
|
1
|
+
import { RunProperty, createDefaultRunProperty } from "./run-property";
|
|
2
2
|
|
|
3
3
|
import * as wasm from "./pkg";
|
|
4
4
|
import { TextAlignmentType } from "./json/bindings/TextAlignmentType";
|
|
5
5
|
import { Tab } from "./json/bindings/Tab";
|
|
6
6
|
import { AlignmentType } from "./json/bindings/AlignmentType";
|
|
7
|
+
import { TabValueType } from "./json/bindings/TabValueType";
|
|
8
|
+
import { TabLeaderType } from "./json/bindings/TabLeaderType";
|
|
7
9
|
|
|
8
10
|
export { AlignmentType } from "./json/bindings/AlignmentType";
|
|
9
11
|
|
|
@@ -60,9 +62,9 @@ export class LineSpacing {
|
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
export
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
export class ParagraphProperty {
|
|
66
|
+
_align?: AlignmentType;
|
|
67
|
+
_textAlignment?: TextAlignmentType;
|
|
66
68
|
styleId?: string;
|
|
67
69
|
indent?: {
|
|
68
70
|
left: number;
|
|
@@ -75,26 +77,60 @@ export type ParagraphProperty = {
|
|
|
75
77
|
level: number;
|
|
76
78
|
};
|
|
77
79
|
lineSpacing?: LineSpacing;
|
|
78
|
-
runProperty: RunProperty;
|
|
80
|
+
runProperty: RunProperty = createDefaultRunProperty();
|
|
79
81
|
keepNext: boolean;
|
|
80
82
|
keepLines: boolean;
|
|
81
83
|
pageBreakBefore: boolean;
|
|
82
84
|
widowControl: boolean;
|
|
83
85
|
paragraphPropertyChange?: ParagraphPropertyChange;
|
|
84
86
|
outlineLvl?: number | null;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
snapToGrid?: boolean;
|
|
88
|
+
_adjustRightInd?: number;
|
|
89
|
+
_tabs?: Tab[];
|
|
87
90
|
frameProperty?: FrameProperty;
|
|
88
|
-
|
|
91
|
+
|
|
92
|
+
constructor() {}
|
|
93
|
+
|
|
94
|
+
tabs(
|
|
95
|
+
tabs: {
|
|
96
|
+
val: TabValueType | null;
|
|
97
|
+
leader: TabLeaderType | null;
|
|
98
|
+
pos: number | null;
|
|
99
|
+
}[]
|
|
100
|
+
) {
|
|
101
|
+
this._tabs = tabs;
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
align(type: AlignmentType) {
|
|
106
|
+
this._align = type;
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
textAlignment(type: TextAlignmentType) {
|
|
111
|
+
this._textAlignment = type;
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
adjustRightInd(v: number) {
|
|
116
|
+
this._adjustRightInd = v;
|
|
117
|
+
return this;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
style(id: string) {
|
|
121
|
+
this.styleId = id;
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
89
125
|
|
|
90
126
|
export const createDefaultParagraphProperty = (): ParagraphProperty => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
127
|
+
let p = new ParagraphProperty();
|
|
128
|
+
p.runProperty = createDefaultRunProperty();
|
|
129
|
+
p.keepNext = false;
|
|
130
|
+
p.keepLines = false;
|
|
131
|
+
p.pageBreakBefore = false;
|
|
132
|
+
p.widowControl = false;
|
|
133
|
+
return p;
|
|
98
134
|
};
|
|
99
135
|
|
|
100
136
|
export const createParagraphAlignment = (
|
|
@@ -169,17 +205,17 @@ export class ParagraphPropertyChange {
|
|
|
169
205
|
}
|
|
170
206
|
|
|
171
207
|
align(type: AlignmentType) {
|
|
172
|
-
this._property.
|
|
208
|
+
this._property._align = type;
|
|
173
209
|
return this;
|
|
174
210
|
}
|
|
175
211
|
|
|
176
212
|
textAlignment(type: TextAlignmentType) {
|
|
177
|
-
this._property.
|
|
213
|
+
this._property._textAlignment = type;
|
|
178
214
|
return this;
|
|
179
215
|
}
|
|
180
216
|
|
|
181
217
|
adjustRightInd(v: number) {
|
|
182
|
-
this._property.
|
|
218
|
+
this._property._adjustRightInd = v;
|
|
183
219
|
return this;
|
|
184
220
|
}
|
|
185
221
|
|
|
@@ -250,22 +286,23 @@ export const buildLineSpacing = (
|
|
|
250
286
|
return spacing;
|
|
251
287
|
};
|
|
252
288
|
|
|
289
|
+
// @deprecated
|
|
253
290
|
export const setParagraphProperty = <T extends wasm.Paragraph | wasm.Style>(
|
|
254
291
|
target: T,
|
|
255
292
|
property: ParagraphProperty
|
|
256
293
|
): T => {
|
|
257
|
-
const alignment = createParagraphAlignment(property.
|
|
294
|
+
const alignment = createParagraphAlignment(property._align);
|
|
258
295
|
if (alignment != null) {
|
|
259
296
|
target = target.align(alignment) as T;
|
|
260
297
|
}
|
|
261
298
|
|
|
262
|
-
const textAlignment = createParagraphTextAlignment(property.
|
|
299
|
+
const textAlignment = createParagraphTextAlignment(property._textAlignment);
|
|
263
300
|
if (textAlignment != null) {
|
|
264
301
|
target = target.text_alignment(textAlignment) as T;
|
|
265
302
|
}
|
|
266
303
|
|
|
267
|
-
if (property.
|
|
268
|
-
target = target.adjust_right_ind(property.
|
|
304
|
+
if (property._adjustRightInd != null) {
|
|
305
|
+
target = target.adjust_right_ind(property._adjustRightInd) as T;
|
|
269
306
|
}
|
|
270
307
|
|
|
271
308
|
if (typeof property.indent !== "undefined") {
|
|
@@ -294,10 +331,14 @@ export const setParagraphProperty = <T extends wasm.Paragraph | wasm.Style>(
|
|
|
294
331
|
target = target.numbering(numbering.id, numbering.level) as T;
|
|
295
332
|
}
|
|
296
333
|
|
|
297
|
-
if (property.runProperty.
|
|
334
|
+
if (property.runProperty._bold) {
|
|
298
335
|
target = target.bold() as T;
|
|
299
336
|
}
|
|
300
337
|
|
|
338
|
+
if (property.runProperty._color) {
|
|
339
|
+
target = target.color(property.runProperty._color) as T;
|
|
340
|
+
}
|
|
341
|
+
|
|
301
342
|
if (typeof property.lineSpacing !== "undefined") {
|
|
302
343
|
const spacing = buildLineSpacing(property);
|
|
303
344
|
if (spacing) {
|
|
@@ -305,27 +346,27 @@ export const setParagraphProperty = <T extends wasm.Paragraph | wasm.Style>(
|
|
|
305
346
|
}
|
|
306
347
|
}
|
|
307
348
|
|
|
308
|
-
if (property.runProperty.
|
|
349
|
+
if (property.runProperty._italic) {
|
|
309
350
|
target = target.italic() as T;
|
|
310
351
|
}
|
|
311
352
|
|
|
312
|
-
if (property.runProperty.
|
|
313
|
-
target = target.size(property.runProperty.
|
|
353
|
+
if (property.runProperty._size) {
|
|
354
|
+
target = target.size(property.runProperty._size) as T;
|
|
314
355
|
}
|
|
315
356
|
|
|
316
|
-
if (property.runProperty.
|
|
357
|
+
if (property.runProperty._fonts) {
|
|
317
358
|
let f = wasm.createRunFonts();
|
|
318
|
-
if (property.runProperty.
|
|
319
|
-
f = f.ascii(property.runProperty.
|
|
359
|
+
if (property.runProperty._fonts._ascii) {
|
|
360
|
+
f = f.ascii(property.runProperty._fonts._ascii);
|
|
320
361
|
}
|
|
321
|
-
if (property.runProperty.
|
|
322
|
-
f = f.hi_ansi(property.runProperty.
|
|
362
|
+
if (property.runProperty._fonts._hiAnsi) {
|
|
363
|
+
f = f.hi_ansi(property.runProperty._fonts._hiAnsi);
|
|
323
364
|
}
|
|
324
|
-
if (property.runProperty.
|
|
325
|
-
f = f.cs(property.runProperty.
|
|
365
|
+
if (property.runProperty._fonts._cs) {
|
|
366
|
+
f = f.cs(property.runProperty._fonts._cs);
|
|
326
367
|
}
|
|
327
|
-
if (property.runProperty.
|
|
328
|
-
f = f.east_asia(property.runProperty.
|
|
368
|
+
if (property.runProperty._fonts._eastAsia) {
|
|
369
|
+
f = f.east_asia(property.runProperty._fonts._eastAsia);
|
|
329
370
|
}
|
|
330
371
|
target = target.fonts(f) as T;
|
|
331
372
|
}
|
|
@@ -334,6 +375,10 @@ export const setParagraphProperty = <T extends wasm.Paragraph | wasm.Style>(
|
|
|
334
375
|
target = target.keep_lines(true) as T;
|
|
335
376
|
}
|
|
336
377
|
|
|
378
|
+
if (property.snapToGrid != null) {
|
|
379
|
+
target = target.snap_to_grid(!!property.snapToGrid) as T;
|
|
380
|
+
}
|
|
381
|
+
|
|
337
382
|
if (property.keepNext) {
|
|
338
383
|
target = target.keep_next(true) as T;
|
|
339
384
|
}
|
|
@@ -350,8 +395,8 @@ export const setParagraphProperty = <T extends wasm.Paragraph | wasm.Style>(
|
|
|
350
395
|
target = target.outline_lvl(property.outlineLvl) as T;
|
|
351
396
|
}
|
|
352
397
|
|
|
353
|
-
if (property.
|
|
354
|
-
for (const tab of property.
|
|
398
|
+
if (property._tabs) {
|
|
399
|
+
for (const tab of property._tabs) {
|
|
355
400
|
let val: wasm.TabValueType | undefined;
|
|
356
401
|
let leader: wasm.TabLeaderType | undefined;
|
|
357
402
|
switch (tab.val) {
|
|
@@ -452,3 +497,220 @@ export const setParagraphProperty = <T extends wasm.Paragraph | wasm.Style>(
|
|
|
452
497
|
|
|
453
498
|
return target;
|
|
454
499
|
};
|
|
500
|
+
|
|
501
|
+
export const createParagraphProperty = (
|
|
502
|
+
property: ParagraphProperty
|
|
503
|
+
): wasm.ParagraphProperty => {
|
|
504
|
+
let p = wasm.createParagraphProperty();
|
|
505
|
+
const alignment = createParagraphAlignment(property._align);
|
|
506
|
+
if (alignment != null) {
|
|
507
|
+
p = p.align(alignment);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
const textAlignment = createParagraphTextAlignment(property._textAlignment);
|
|
511
|
+
if (textAlignment != null) {
|
|
512
|
+
p = p.text_alignment(textAlignment);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
if (property._adjustRightInd != null) {
|
|
516
|
+
p = p.adjust_right_ind(property._adjustRightInd);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
if (typeof property.indent !== "undefined") {
|
|
520
|
+
const { indent } = property;
|
|
521
|
+
let kind;
|
|
522
|
+
switch (property.indent.specialIndentKind) {
|
|
523
|
+
case "firstLine": {
|
|
524
|
+
kind = wasm.SpecialIndentKind.FirstLine;
|
|
525
|
+
break;
|
|
526
|
+
}
|
|
527
|
+
case "hanging": {
|
|
528
|
+
kind = wasm.SpecialIndentKind.Hanging;
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
p = p.indent(indent.left, kind, indent.specialIndentSize, indent.right);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
if (typeof property.lineSpacing !== "undefined") {
|
|
536
|
+
const spacing = buildLineSpacing(property);
|
|
537
|
+
if (spacing) {
|
|
538
|
+
p = p.line_spacing(spacing);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
if (typeof property.numbering !== "undefined") {
|
|
543
|
+
const { numbering } = property;
|
|
544
|
+
p = p.numbering(numbering.id, numbering.level);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
let runProperty = wasm.createRunProperty();
|
|
548
|
+
if (property.runProperty._bold) {
|
|
549
|
+
runProperty = runProperty.bold();
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
if (property.runProperty._color) {
|
|
553
|
+
runProperty = runProperty.color(property.runProperty._color);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
if (property.runProperty._italic) {
|
|
557
|
+
runProperty = runProperty.italic();
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
if (property.runProperty._size) {
|
|
561
|
+
runProperty = runProperty.size(property.runProperty._size);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
if (property.runProperty._fonts) {
|
|
565
|
+
let f = wasm.createRunFonts();
|
|
566
|
+
if (property.runProperty._fonts._ascii) {
|
|
567
|
+
f = f.ascii(property.runProperty._fonts._ascii);
|
|
568
|
+
}
|
|
569
|
+
if (property.runProperty._fonts._hiAnsi) {
|
|
570
|
+
f = f.hi_ansi(property.runProperty._fonts._hiAnsi);
|
|
571
|
+
}
|
|
572
|
+
if (property.runProperty._fonts._cs) {
|
|
573
|
+
f = f.cs(property.runProperty._fonts._cs);
|
|
574
|
+
}
|
|
575
|
+
if (property.runProperty._fonts._eastAsia) {
|
|
576
|
+
f = f.east_asia(property.runProperty._fonts._eastAsia);
|
|
577
|
+
}
|
|
578
|
+
runProperty = runProperty.fonts(f);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
if (property.runProperty) {
|
|
582
|
+
p = p.run_property(runProperty);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
if (property.keepLines) {
|
|
586
|
+
p = p.keep_lines(true);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
if (property.snapToGrid != null) {
|
|
590
|
+
p = p.snap_to_grid(!!property.snapToGrid);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
if (property.keepNext) {
|
|
594
|
+
p = p.keep_next(true);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
if (property.pageBreakBefore) {
|
|
598
|
+
p = p.page_break_before(true);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if (property.widowControl) {
|
|
602
|
+
p = p.widow_control(true);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
if (property.outlineLvl != null) {
|
|
606
|
+
p = p.outline_lvl(property.outlineLvl);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
if (property.styleId) {
|
|
610
|
+
p = p.style(property.styleId);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
if (property._tabs) {
|
|
614
|
+
for (const tab of property._tabs) {
|
|
615
|
+
let val: wasm.TabValueType | undefined;
|
|
616
|
+
let leader: wasm.TabLeaderType | undefined;
|
|
617
|
+
switch (tab.val) {
|
|
618
|
+
case "bar":
|
|
619
|
+
val = wasm.TabValueType.Bar;
|
|
620
|
+
break;
|
|
621
|
+
case "bar":
|
|
622
|
+
val = wasm.TabValueType.Bar;
|
|
623
|
+
break;
|
|
624
|
+
case "center":
|
|
625
|
+
val = wasm.TabValueType.Center;
|
|
626
|
+
break;
|
|
627
|
+
case "clear":
|
|
628
|
+
val = wasm.TabValueType.Clear;
|
|
629
|
+
break;
|
|
630
|
+
case "decimal":
|
|
631
|
+
val = wasm.TabValueType.Decimal;
|
|
632
|
+
break;
|
|
633
|
+
case "end":
|
|
634
|
+
val = wasm.TabValueType.End;
|
|
635
|
+
break;
|
|
636
|
+
case "right":
|
|
637
|
+
val = wasm.TabValueType.Right;
|
|
638
|
+
break;
|
|
639
|
+
case "num":
|
|
640
|
+
val = wasm.TabValueType.Num;
|
|
641
|
+
break;
|
|
642
|
+
case "start":
|
|
643
|
+
val = wasm.TabValueType.Start;
|
|
644
|
+
break;
|
|
645
|
+
case "left":
|
|
646
|
+
val = wasm.TabValueType.Left;
|
|
647
|
+
break;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
switch (tab.leader) {
|
|
651
|
+
case "dot":
|
|
652
|
+
leader = wasm.TabLeaderType.Dot;
|
|
653
|
+
break;
|
|
654
|
+
case "heavy":
|
|
655
|
+
leader = wasm.TabLeaderType.Heavy;
|
|
656
|
+
break;
|
|
657
|
+
case "hyphen":
|
|
658
|
+
leader = wasm.TabLeaderType.Hyphen;
|
|
659
|
+
break;
|
|
660
|
+
case "middleDot":
|
|
661
|
+
leader = wasm.TabLeaderType.MiddleDot;
|
|
662
|
+
break;
|
|
663
|
+
case "none":
|
|
664
|
+
leader = wasm.TabLeaderType.None;
|
|
665
|
+
break;
|
|
666
|
+
case "underscore":
|
|
667
|
+
leader = wasm.TabLeaderType.None;
|
|
668
|
+
break;
|
|
669
|
+
}
|
|
670
|
+
p = p.add_tab(val, leader, tab.pos ?? undefined);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
if (property.frameProperty) {
|
|
675
|
+
let frameProperty = wasm.createFrameProperty();
|
|
676
|
+
if (property.frameProperty?.h != null) {
|
|
677
|
+
frameProperty = frameProperty.height(property.frameProperty.h);
|
|
678
|
+
}
|
|
679
|
+
if (property.frameProperty?.hRule != null) {
|
|
680
|
+
frameProperty = frameProperty.h_rule(property.frameProperty.hRule);
|
|
681
|
+
}
|
|
682
|
+
if (property.frameProperty?.hAnchor != null) {
|
|
683
|
+
frameProperty = frameProperty.h_anchor(property.frameProperty.hAnchor);
|
|
684
|
+
}
|
|
685
|
+
if (property.frameProperty?.hSpace != null) {
|
|
686
|
+
frameProperty = frameProperty.h_space(property.frameProperty.hSpace);
|
|
687
|
+
}
|
|
688
|
+
if (property.frameProperty?.vAnchor != null) {
|
|
689
|
+
frameProperty = frameProperty.v_anchor(property.frameProperty.vAnchor);
|
|
690
|
+
}
|
|
691
|
+
if (property.frameProperty?.vSpace != null) {
|
|
692
|
+
frameProperty = frameProperty.v_space(property.frameProperty.vSpace);
|
|
693
|
+
}
|
|
694
|
+
if (property.frameProperty?.w != null) {
|
|
695
|
+
frameProperty = frameProperty.width(property.frameProperty.w);
|
|
696
|
+
}
|
|
697
|
+
if (property.frameProperty?.wrap != null) {
|
|
698
|
+
frameProperty = frameProperty.wrap(property.frameProperty.wrap);
|
|
699
|
+
}
|
|
700
|
+
if (property.frameProperty?.x != null) {
|
|
701
|
+
frameProperty = frameProperty.x(property.frameProperty.x);
|
|
702
|
+
}
|
|
703
|
+
if (property.frameProperty?.xAlign != null) {
|
|
704
|
+
frameProperty = frameProperty.x_align(property.frameProperty.xAlign);
|
|
705
|
+
}
|
|
706
|
+
if (property.frameProperty?.y != null) {
|
|
707
|
+
frameProperty = frameProperty.y(property.frameProperty.y);
|
|
708
|
+
}
|
|
709
|
+
if (property.frameProperty?.yAlign != null) {
|
|
710
|
+
frameProperty = frameProperty.y_align(property.frameProperty.yAlign);
|
|
711
|
+
}
|
|
712
|
+
p = p.frame_property(frameProperty);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
return p;
|
|
716
|
+
};
|