* fix: numpr reader

* fix
main
bokuweb 2022-01-18 14:19:23 +09:00 committed by GitHub
parent eb817c9fb2
commit 447fcae3de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19979 additions and 7 deletions

View File

@ -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/), 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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## docx-wasm@0.0.228 (18. January, 2022)
- Fixed a bug, numPr reader panic when id is none.
## docx-wasm@0.0.226, 0.0.227 (17. January, 2022) ## docx-wasm@0.0.226, 0.0.227 (17. January, 2022)
- Add `paragraphPropertyChange` api for JS. - Add `paragraphPropertyChange` api for JS.

View File

@ -4,7 +4,7 @@ use std::fs::File;
use std::io::{Read, Write}; use std::io::{Read, Write};
pub fn main() { pub fn main() {
let mut file = File::open("./ppr_del.docx").unwrap(); let mut file = File::open("./table-indent.docx").unwrap();
let mut buf = vec![]; let mut buf = vec![];
file.read_to_end(&mut buf).unwrap(); file.read_to_end(&mut buf).unwrap();

View File

@ -39,12 +39,13 @@ impl ElementReader for NumberingProperty {
return Ok(NumberingProperty::new() return Ok(NumberingProperty::new()
.id(NumberingId::new(id.expect("should id exists")))); .id(NumberingId::new(id.expect("should id exists"))));
} }
let np = NumberingProperty::new().add_num( if let Some(id) = id {
NumberingId::new(id.unwrap()), let np = NumberingProperty::new()
IndentLevel::new(level.unwrap()), .add_num(NumberingId::new(id), IndentLevel::new(level.unwrap()));
);
return Ok(np); return Ok(np);
} }
return Ok(NumberingProperty::new());
}
} }
Err(_) => return Err(ReaderError::XMLReadError), Err(_) => return Err(ReaderError::XMLReadError),
_ => {} _ => {}

View File

@ -1,6 +1,6 @@
{ {
"name": "docx-wasm", "name": "docx-wasm",
"version": "0.0.227", "version": "0.0.228",
"main": "dist/node/index.js", "main": "dist/node/index.js",
"browser": "dist/web/index.js", "browser": "dist/web/index.js",
"author": "bokuweb <bokuweb12@gmail.com>", "author": "bokuweb <bokuweb12@gmail.com>",

File diff suppressed because it is too large Load Diff

View File

@ -106,6 +106,12 @@ describe("reader", () => {
const json = w.readDocx(buffer); const json = w.readDocx(buffer);
expect(json).toMatchSnapshot(); expect(json).toMatchSnapshot();
}); });
test("should read table indent docx", () => {
const buffer = readFileSync("../fixtures/table_indent/table_indent.docx");
const json = w.readDocx(buffer);
expect(json).toMatchSnapshot();
});
}); });
describe("writer", () => { describe("writer", () => {

Binary file not shown.