Read section props in paragraph (#533)
* feat: support section property in ppr * spec: Add snao * fix * fixmain
parent
2b6344f31b
commit
726d0958c5
|
@ -235,6 +235,11 @@ impl Paragraph {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn section_property(mut self, s: SectionProperty) -> Self {
|
||||||
|
self.property = self.property.section_property(s);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn add_tab(mut self, t: Tab) -> Self {
|
pub fn add_tab(mut self, t: Tab) -> Self {
|
||||||
self.property = self.property.add_tab(t);
|
self.property = self.property.add_tab(t);
|
||||||
self
|
self
|
||||||
|
|
|
@ -29,6 +29,8 @@ pub struct ParagraphProperty {
|
||||||
pub widow_control: Option<bool>,
|
pub widow_control: Option<bool>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub outline_lvl: Option<OutlineLvl>,
|
pub outline_lvl: Option<OutlineLvl>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub section_property: Option<SectionProperty>,
|
||||||
pub tabs: Vec<Tab>,
|
pub tabs: Vec<Tab>,
|
||||||
// read only
|
// read only
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
@ -116,6 +118,11 @@ impl ParagraphProperty {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn section_property(mut self, s: SectionProperty) -> Self {
|
||||||
|
self.section_property = Some(s);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn paragraph_property_change(mut self, p: ParagraphPropertyChange) -> Self {
|
pub fn paragraph_property_change(mut self, p: ParagraphPropertyChange) -> Self {
|
||||||
self.paragraph_property_change = Some(p);
|
self.paragraph_property_change = Some(p);
|
||||||
self
|
self
|
||||||
|
|
|
@ -105,6 +105,11 @@ impl ElementReader for ParagraphProperty {
|
||||||
p.paragraph_property_change = Some(ppr_change);
|
p.paragraph_property_change = Some(ppr_change);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
XMLElement::SectionProperty => {
|
||||||
|
if let Ok(sp) = SectionProperty::read(r, &attributes) {
|
||||||
|
p.section_property = Some(sp);
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import { RunJSON, RunPropertyJSON } from "./run";
|
import { RunJSON, RunPropertyJSON } from "./run";
|
||||||
import { IndentJSON } from "./indent";
|
import { IndentJSON } from "./indent";
|
||||||
import { CommentRangeStartJSON, CommentRangeEndJSON } from "..";
|
import {
|
||||||
|
CommentRangeStartJSON,
|
||||||
|
CommentRangeEndJSON,
|
||||||
|
SectionPropertyJSON,
|
||||||
|
} from "..";
|
||||||
import { LineSpacingJSON } from "./line_spacing";
|
import { LineSpacingJSON } from "./line_spacing";
|
||||||
|
|
||||||
export type ParagraphChildJSON =
|
export type ParagraphChildJSON =
|
||||||
|
@ -45,6 +49,7 @@ export type ParagraphPropertyJSON = {
|
||||||
date: string;
|
date: string;
|
||||||
property: ParagraphPropertyJSON;
|
property: ParagraphPropertyJSON;
|
||||||
};
|
};
|
||||||
|
sectionProperty?: SectionPropertyJSON;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ParagraphJSON = {
|
export type ParagraphJSON = {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "docx-wasm",
|
"name": "docx-wasm",
|
||||||
"version": "0.0.276-rc18",
|
"version": "0.0.276-rc19",
|
||||||
"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
|
@ -165,6 +165,12 @@ describe("reader", () => {
|
||||||
const json = w.readDocx(buffer);
|
const json = w.readDocx(buffer);
|
||||||
expect(json).toMatchSnapshot();
|
expect(json).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("should read sectionProperty in ppr", () => {
|
||||||
|
const buffer = readFileSync("../fixtures/section_property_in_ppr/section_property_in_ppr.docx");
|
||||||
|
const json = w.readDocx(buffer);
|
||||||
|
expect(json).toMatchSnapshot();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("writer", () => {
|
describe("writer", () => {
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue