fix: collect images in nested table (#493)

* fix: collect images in nested table

* fix

Co-authored-by: bokuweb <bokuweb@bokuwebnombp.lan>
main
bokuweb 2022-06-13 19:02:19 +09:00 committed by GitHub
parent 86cc64b2a4
commit 1f0877bbad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 3 deletions

View File

@ -863,8 +863,12 @@ impl Docx {
&mut image_bufs, &mut image_bufs,
); );
} }
TableCellContent::Table(_) => { TableCellContent::Table(table) => {
// TODO: support comment collect_images_from_table(
table,
&mut images,
&mut image_bufs,
);
} }
} }
} }
@ -960,6 +964,27 @@ fn collect_images_from_paragraph(
} }
} }
fn collect_images_from_table(
table: &mut Table,
images: &mut Vec<(String, String)>,
image_bufs: &mut Vec<(String, Vec<u8>)>,
) {
for TableChild::TableRow(row) in &mut table.rows {
for TableRowChild::TableCell(cell) in &mut row.cells {
for content in &mut cell.children {
match content {
TableCellContent::Paragraph(paragraph) => {
collect_images_from_paragraph(paragraph, images, image_bufs);
}
TableCellContent::Table(table) => {
collect_images_from_table(table, images, image_bufs)
}
}
}
}
}
}
fn update_document_by_toc( fn update_document_by_toc(
document_children: Vec<DocumentChild>, document_children: Vec<DocumentChild>,
styles: &Styles, styles: &Styles,

View File

@ -1,6 +1,6 @@
{ {
"name": "docx-wasm", "name": "docx-wasm",
"version": "0.0.264", "version": "0.0.265",
"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>",