fix: collect images in nested table (#493)
* fix: collect images in nested table * fix Co-authored-by: bokuweb <bokuweb@bokuwebnombp.lan>main
parent
86cc64b2a4
commit
1f0877bbad
|
@ -863,8 +863,12 @@ impl Docx {
|
|||
&mut image_bufs,
|
||||
);
|
||||
}
|
||||
TableCellContent::Table(_) => {
|
||||
// TODO: support comment
|
||||
TableCellContent::Table(table) => {
|
||||
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(
|
||||
document_children: Vec<DocumentChild>,
|
||||
styles: &Styles,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "docx-wasm",
|
||||
"version": "0.0.264",
|
||||
"version": "0.0.265",
|
||||
"main": "dist/node/index.js",
|
||||
"browser": "dist/web/index.js",
|
||||
"author": "bokuweb <bokuweb12@gmail.com>",
|
||||
|
|
Loading…
Reference in New Issue