parent
44a236e6c0
commit
34ebfc5290
|
@ -139,7 +139,6 @@ impl BuildXML for TableOfContents {
|
|||
.add_instr_text(InstrText::TOC(self.instr.clone()))
|
||||
.add_field_char(FieldCharType::Separate, false),
|
||||
);
|
||||
let p2 = Paragraph::new().add_run(Run::new().add_field_char(FieldCharType::End, false));
|
||||
|
||||
let mut b = XMLBuilder::new()
|
||||
.open_structured_tag()
|
||||
|
@ -157,18 +156,35 @@ impl BuildXML for TableOfContents {
|
|||
}
|
||||
}
|
||||
|
||||
b = b.add_child(&p1).add_child(&p2);
|
||||
b = b.add_child(&p1);
|
||||
|
||||
for c in self.after_contents.iter() {
|
||||
let p2 = Paragraph::new().add_run(Run::new().add_field_char(FieldCharType::End, false));
|
||||
if self.after_contents.is_empty() {
|
||||
b = b.add_child(&p2);
|
||||
} else {
|
||||
for (i, c) in self.after_contents.iter().enumerate() {
|
||||
match c {
|
||||
TocContent::Paragraph(p) => {
|
||||
// Merge paragraph
|
||||
if i == 0 {
|
||||
let mut new_p = p.clone();
|
||||
new_p.children.insert(
|
||||
0,
|
||||
ParagraphChild::Run(Box::new(
|
||||
Run::new().add_field_char(FieldCharType::End, false),
|
||||
)),
|
||||
);
|
||||
b = b.add_child(&new_p)
|
||||
} else {
|
||||
b = b.add_child(p);
|
||||
}
|
||||
}
|
||||
TocContent::Table(t) => {
|
||||
b = b.add_child(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
b.close().close().build()
|
||||
} else {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "docx-wasm",
|
||||
"version": "0.0.276",
|
||||
"version": "0.0.277-rc0",
|
||||
"main": "dist/node/index.js",
|
||||
"browser": "dist/web/index.js",
|
||||
"author": "bokuweb <bokuweb12@gmail.com>",
|
||||
|
|
|
@ -151930,7 +151930,7 @@ exports[`writer should write ToC with instrText 2`] = `
|
|||
"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" standalone=\\"yes\\"?>
|
||||
<w:document xmlns:o=\\"urn:schemas-microsoft-com:office:office\\" xmlns:r=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\\" xmlns:v=\\"urn:schemas-microsoft-com:vml\\" xmlns:w=\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\" xmlns:w10=\\"urn:schemas-microsoft-com:office:word\\" xmlns:wp=\\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\\" xmlns:wps=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\\" xmlns:wpg=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\\" xmlns:mc=\\"http://schemas.openxmlformats.org/markup-compatibility/2006\\" xmlns:wp14=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\\" xmlns:w14=\\"http://schemas.microsoft.com/office/word/2010/wordml\\" xmlns:w15=\\"http://schemas.microsoft.com/office/word/2012/wordml\\" mc:Ignorable=\\"w14 wp14\\">
|
||||
<w:body><w:sdt><w:sdtPr><w:rPr /><w:alias w:val=\\"Table of contents\\" />
|
||||
</w:sdtPr><w:sdtContent><w:p w14:paraId=\\"00000001\\"><w:pPr><w:rPr /></w:pPr><w:r><w:rPr /><w:t xml:space=\\"preserve\\">Before contents</w:t></w:r></w:p><w:p w14:paraId=\\"00000001\\"><w:pPr><w:rPr /></w:pPr><w:r><w:rPr /><w:fldChar w:fldCharType=\\"begin\\" w:dirty=\\"true\\" /><w:instrText>TOC \\\\u</w:instrText><w:fldChar w:fldCharType=\\"separate\\" w:dirty=\\"false\\" /></w:r></w:p><w:p w14:paraId=\\"00000002\\"><w:pPr><w:rPr /></w:pPr><w:r><w:rPr /><w:fldChar w:fldCharType=\\"end\\" w:dirty=\\"false\\" /></w:r></w:p><w:p w14:paraId=\\"00000002\\"><w:pPr><w:rPr /></w:pPr><w:r><w:rPr /><w:t xml:space=\\"preserve\\">After contents</w:t></w:r></w:p></w:sdtContent>
|
||||
</w:sdtPr><w:sdtContent><w:p w14:paraId=\\"00000001\\"><w:pPr><w:rPr /></w:pPr><w:r><w:rPr /><w:t xml:space=\\"preserve\\">Before contents</w:t></w:r></w:p><w:p w14:paraId=\\"00000001\\"><w:pPr><w:rPr /></w:pPr><w:r><w:rPr /><w:fldChar w:fldCharType=\\"begin\\" w:dirty=\\"true\\" /><w:instrText>TOC \\\\u</w:instrText><w:fldChar w:fldCharType=\\"separate\\" w:dirty=\\"false\\" /></w:r></w:p><w:p w14:paraId=\\"00000002\\"><w:pPr><w:rPr /></w:pPr><w:r><w:rPr /><w:fldChar w:fldCharType=\\"end\\" w:dirty=\\"false\\" /></w:r><w:r><w:rPr /><w:t xml:space=\\"preserve\\">After contents</w:t></w:r></w:p></w:sdtContent>
|
||||
</w:sdt><w:p w14:paraId=\\"00000003\\"><w:pPr><w:rPr /><w:pStyle w:val=\\"Heading1\\" /><w:pageBreakBefore />
|
||||
</w:pPr><w:r><w:rPr /><w:t xml:space=\\"preserve\\">Hello!!</w:t></w:r></w:p><w:p w14:paraId=\\"00000004\\"><w:pPr><w:rPr /><w:pStyle w:val=\\"Heading2\\" /><w:pageBreakBefore />
|
||||
</w:pPr><w:r><w:rPr /><w:t xml:space=\\"preserve\\">World</w:t></w:r></w:p><w:sectPr><w:pgSz w:w=\\"11906\\" w:h=\\"16838\\" /><w:pgMar w:top=\\"1985\\" w:right=\\"1701\\" w:bottom=\\"1701\\" w:left=\\"1701\\" w:header=\\"851\\" w:footer=\\"992\\" w:gutter=\\"0\\" /><w:cols w:space=\\"425\\" w:num=\\"1\\" /><w:docGrid w:type=\\"lines\\" w:linePitch=\\"360\\" /></w:sectPr></w:body>
|
||||
|
|
Loading…
Reference in New Issue