Fix run props (#29)

* fix: run

* fix:table

* fix: package.json
main
bokuweb 2020-01-31 01:14:48 +09:00 committed by GitHub
parent 2c8bbbb43f
commit 1df5e25523
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 12 deletions

View File

@ -9,6 +9,7 @@ import("../js").then(w => {
.bold() .bold()
.highlight("yellow") .highlight("yellow")
.color("FF0000") .color("FF0000")
.size(40)
) )
) )
.build(); .build();

View File

@ -176,7 +176,7 @@ export class Docx {
break; break;
} }
case "hanging": { case "hanging": {
paragraph = paragraph.align(wasm.SpecialIndentKind.Hanging); kind = wasm.SpecialIndentKind.Hanging;
break; break;
} }
} }
@ -203,6 +203,7 @@ export class Docx {
const cell = this.buildCell(c); const cell = this.buildCell(c);
row = row.add_cell(cell); row = row.add_cell(cell);
}); });
table = table.add_row(row);
}); });
table = table.set_grid(new Uint32Array(t.grid)); table = table.set_grid(new Uint32Array(t.grid));

View File

@ -40,37 +40,37 @@ export class Run {
} }
size(size: number) { size(size: number) {
this.property.size = size; this.property = { ...this.property, size };
return this; return this;
} }
color(color: string) { color(color: string) {
this.property.color = color; this.property = { ...this.property, color };
return this; return this;
} }
highlight(color: string) { highlight(color: string) {
this.property.highlight = color; this.property = { ...this.property, highlight: color };
return this; return this;
} }
bold() { bold() {
this.property.bold = true; this.property = { ...this.property, bold: true };
return this; return this;
} }
italic() { italic() {
this.property.italic = true; this.property = { ...this.property, italic: true };
return this; return this;
} }
underline(type: string) { underline(type: string) {
this.property.underline = type; this.property = { ...this.property, underline: type };
return this; return this;
} }
vanish() { vanish() {
this.property.vanish = true; this.property = { ...this.property, vanish: true };
return this; return this;
} }
} }

View File

@ -10,7 +10,7 @@ export type CellProperty = {
export class TableCell { export class TableCell {
children: Paragraph[] = []; children: Paragraph[] = [];
property: CellProperty; property: CellProperty = {};
addParagraph(p: Paragraph) { addParagraph(p: Paragraph) {
this.children.push(p); this.children.push(p);

View File

@ -11,7 +11,7 @@ export type TableProperty = {
export class Table { export class Table {
rows: TableRow[] = []; rows: TableRow[] = [];
grid: number[] = []; grid: number[] = [];
property: TableProperty; property: TableProperty = {};
addRow(row: TableRow) { addRow(row: TableRow) {
this.rows.push(row); this.rows.push(row);

View File

@ -1,6 +1,6 @@
{ {
"name": "docx-wasm", "name": "docx-wasm",
"version": "0.0.11", "version": "0.0.19",
"main": "dist/index.js", "main": "dist/index.js",
"author": "bokuweb <bokuweb12@gmail.com>", "author": "bokuweb <bokuweb12@gmail.com>",
"license": "MIT", "license": "MIT",

View File

@ -14,5 +14,6 @@
"esModuleInterop": true, "esModuleInterop": true,
"outDir": "dist", "outDir": "dist",
"declaration": true "declaration": true
} },
"include": ["js"]
} }