From 1df5e255230b37cfa84aa4043366fd00be8d6e66 Mon Sep 17 00:00:00 2001 From: bokuweb Date: Fri, 31 Jan 2020 01:14:48 +0900 Subject: [PATCH] Fix run props (#29) * fix: run * fix:table * fix: package.json --- docx-wasm/example/index.ts | 1 + docx-wasm/js/index.ts | 3 ++- docx-wasm/js/run.ts | 14 +++++++------- docx-wasm/js/table-cell.ts | 2 +- docx-wasm/js/table.ts | 2 +- docx-wasm/package.json | 2 +- docx-wasm/tsconfig.json | 3 ++- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/docx-wasm/example/index.ts b/docx-wasm/example/index.ts index e4383a0..6698d1b 100644 --- a/docx-wasm/example/index.ts +++ b/docx-wasm/example/index.ts @@ -9,6 +9,7 @@ import("../js").then(w => { .bold() .highlight("yellow") .color("FF0000") + .size(40) ) ) .build(); diff --git a/docx-wasm/js/index.ts b/docx-wasm/js/index.ts index f749050..8c1fb24 100644 --- a/docx-wasm/js/index.ts +++ b/docx-wasm/js/index.ts @@ -176,7 +176,7 @@ export class Docx { break; } case "hanging": { - paragraph = paragraph.align(wasm.SpecialIndentKind.Hanging); + kind = wasm.SpecialIndentKind.Hanging; break; } } @@ -203,6 +203,7 @@ export class Docx { const cell = this.buildCell(c); row = row.add_cell(cell); }); + table = table.add_row(row); }); table = table.set_grid(new Uint32Array(t.grid)); diff --git a/docx-wasm/js/run.ts b/docx-wasm/js/run.ts index 89113da..27c8acf 100644 --- a/docx-wasm/js/run.ts +++ b/docx-wasm/js/run.ts @@ -40,37 +40,37 @@ export class Run { } size(size: number) { - this.property.size = size; + this.property = { ...this.property, size }; return this; } color(color: string) { - this.property.color = color; + this.property = { ...this.property, color }; return this; } highlight(color: string) { - this.property.highlight = color; + this.property = { ...this.property, highlight: color }; return this; } bold() { - this.property.bold = true; + this.property = { ...this.property, bold: true }; return this; } italic() { - this.property.italic = true; + this.property = { ...this.property, italic: true }; return this; } underline(type: string) { - this.property.underline = type; + this.property = { ...this.property, underline: type }; return this; } vanish() { - this.property.vanish = true; + this.property = { ...this.property, vanish: true }; return this; } } diff --git a/docx-wasm/js/table-cell.ts b/docx-wasm/js/table-cell.ts index cc5cd14..375a2ed 100644 --- a/docx-wasm/js/table-cell.ts +++ b/docx-wasm/js/table-cell.ts @@ -10,7 +10,7 @@ export type CellProperty = { export class TableCell { children: Paragraph[] = []; - property: CellProperty; + property: CellProperty = {}; addParagraph(p: Paragraph) { this.children.push(p); diff --git a/docx-wasm/js/table.ts b/docx-wasm/js/table.ts index d30a983..b3a7668 100644 --- a/docx-wasm/js/table.ts +++ b/docx-wasm/js/table.ts @@ -11,7 +11,7 @@ export type TableProperty = { export class Table { rows: TableRow[] = []; grid: number[] = []; - property: TableProperty; + property: TableProperty = {}; addRow(row: TableRow) { this.rows.push(row); diff --git a/docx-wasm/package.json b/docx-wasm/package.json index 5a23b79..ffc2081 100644 --- a/docx-wasm/package.json +++ b/docx-wasm/package.json @@ -1,6 +1,6 @@ { "name": "docx-wasm", - "version": "0.0.11", + "version": "0.0.19", "main": "dist/index.js", "author": "bokuweb ", "license": "MIT", diff --git a/docx-wasm/tsconfig.json b/docx-wasm/tsconfig.json index c45030d..605544c 100644 --- a/docx-wasm/tsconfig.json +++ b/docx-wasm/tsconfig.json @@ -14,5 +14,6 @@ "esModuleInterop": true, "outDir": "dist", "declaration": true - } + }, + "include": ["js"] }