From ca6e24179dd7b7fc7c0a7b37e168dc58ad0916d7 Mon Sep 17 00:00:00 2001 From: bokuweb Date: Wed, 2 Nov 2022 13:58:58 +0900 Subject: [PATCH] fix: types (#561) * fix: types * rc32 --- CHANGELOG.md | 4 ++++ docx-core/src/reader/styles.rs | 5 +++-- docx-wasm/js/json/table.ts | 23 +++++++++++------------ docx-wasm/package.json | 2 +- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd03d88..c7cbef6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## docx-wasm@0.0.276-rc32 (1. Nov, 2022) + +- Fix TableProperty json types. + ## docx-wasm@0.0.276-rc31 (1. Nov, 2022) - Support `specVanish`. diff --git a/docx-core/src/reader/styles.rs b/docx-core/src/reader/styles.rs index 1a12817..52f5b02 100644 --- a/docx-core/src/reader/styles.rs +++ b/docx-core/src/reader/styles.rs @@ -19,8 +19,9 @@ impl FromXML for Styles { let e = XMLElement::from_str(&name.local_name).unwrap(); match e { XMLElement::Style => { - let s = Style::read(&mut parser, &attributes)?; - styles = styles.add_style(s); + if let Ok(s) = Style::read(&mut parser, &attributes) { + styles = styles.add_style(s); + } continue; } XMLElement::DocDefaults => { diff --git a/docx-wasm/js/json/table.ts b/docx-wasm/js/json/table.ts index e6bdcdc..d932e34 100644 --- a/docx-wasm/js/json/table.ts +++ b/docx-wasm/js/json/table.ts @@ -24,7 +24,6 @@ export type TableCellPropertyJSON = { verticalMerge: "restart" | "continue" | null; verticalAlign: "top" | "center" | "bottom" | null; textDirection: TextDirectionType | null; - hasNumbering: boolean; shading: ShadingJSON | null; }; @@ -70,21 +69,21 @@ export type TablePropertyJSON = { widthType: WidthType; } | null; justification: "left" | "center" | "right"; - borders: { - top: BorderJSON; - left: BorderJSON; - bottom: BorderJSON; - right: BorderJSON; - insideH: BorderJSON; - insideV: BorderJSON; + borders?: { + top?: BorderJSON | null; + left?: BorderJSON | null; + bottom?: BorderJSON | null; + right?: BorderJSON | null; + insideH?: BorderJSON | null; + insideV?: BorderJSON | null; } | null; margins: TableCellMarginsJSON | null; - indent: { + indent?: { width: number; widthType: WidthType; - }; - style: string | null; - layout: TableLayoutType | null; + } | null; + style?: string | null; + layout?: TableLayoutType | null; }; export type TableJSON = { diff --git a/docx-wasm/package.json b/docx-wasm/package.json index d40bc53..326bcca 100644 --- a/docx-wasm/package.json +++ b/docx-wasm/package.json @@ -1,6 +1,6 @@ { "name": "docx-wasm", - "version": "0.0.276-rc31", + "version": "0.0.276-rc32", "main": "dist/node/index.js", "browser": "dist/web/index.js", "author": "bokuweb ",