Merge pull request #476 from mustapelto/empty-first-paragraph-fix
Fix for empty first paragraph
This commit is contained in:
@ -22,9 +22,6 @@ describe("Body", () => {
|
|||||||
|
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:body": [
|
"w:body": [
|
||||||
{
|
|
||||||
"w:p": {},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"w:sectPr": [
|
"w:sectPr": [
|
||||||
{ "w:pgSz": { _attr: { "w:w": 10000, "w:h": 10000, "w:orient": "portrait" } } },
|
{ "w:pgSz": { _attr: { "w:w": 10000, "w:h": 10000, "w:orient": "portrait" } } },
|
||||||
|
@ -26,6 +26,7 @@ export class Body extends XmlComponent {
|
|||||||
|
|
||||||
public prepForXml(): IXmlableObject | undefined {
|
public prepForXml(): IXmlableObject | undefined {
|
||||||
if (this.sections.length === 1) {
|
if (this.sections.length === 1) {
|
||||||
|
this.root.splice(0, 1);
|
||||||
this.root.push(this.sections.pop() as SectionProperties);
|
this.root.push(this.sections.pop() as SectionProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@ describe("File", () => {
|
|||||||
|
|
||||||
const tree = new Formatter().format(doc.Document.Body);
|
const tree = new Formatter().format(doc.Document.Body);
|
||||||
|
|
||||||
expect(tree["w:body"][1]["w:sectPr"][4]["w:headerReference"]._attr["w:type"]).to.equal("default");
|
expect(tree["w:body"][0]["w:sectPr"][4]["w:headerReference"]._attr["w:type"]).to.equal("default");
|
||||||
expect(tree["w:body"][1]["w:sectPr"][5]["w:footerReference"]._attr["w:type"]).to.equal("default");
|
expect(tree["w:body"][0]["w:sectPr"][5]["w:footerReference"]._attr["w:type"]).to.equal("default");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create with correct headers and footers", () => {
|
it("should create with correct headers and footers", () => {
|
||||||
@ -39,8 +39,8 @@ describe("File", () => {
|
|||||||
|
|
||||||
const tree = new Formatter().format(doc.Document.Body);
|
const tree = new Formatter().format(doc.Document.Body);
|
||||||
|
|
||||||
expect(tree["w:body"][1]["w:sectPr"][4]["w:headerReference"]._attr["w:type"]).to.equal("default");
|
expect(tree["w:body"][0]["w:sectPr"][4]["w:headerReference"]._attr["w:type"]).to.equal("default");
|
||||||
expect(tree["w:body"][1]["w:sectPr"][5]["w:footerReference"]._attr["w:type"]).to.equal("default");
|
expect(tree["w:body"][0]["w:sectPr"][5]["w:footerReference"]._attr["w:type"]).to.equal("default");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create with first headers and footers", () => {
|
it("should create with first headers and footers", () => {
|
||||||
@ -58,8 +58,8 @@ describe("File", () => {
|
|||||||
|
|
||||||
const tree = new Formatter().format(doc.Document.Body);
|
const tree = new Formatter().format(doc.Document.Body);
|
||||||
|
|
||||||
expect(tree["w:body"][1]["w:sectPr"][5]["w:headerReference"]._attr["w:type"]).to.equal("first");
|
expect(tree["w:body"][0]["w:sectPr"][5]["w:headerReference"]._attr["w:type"]).to.equal("first");
|
||||||
expect(tree["w:body"][1]["w:sectPr"][7]["w:footerReference"]._attr["w:type"]).to.equal("first");
|
expect(tree["w:body"][0]["w:sectPr"][7]["w:footerReference"]._attr["w:type"]).to.equal("first");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create with correct headers", () => {
|
it("should create with correct headers", () => {
|
||||||
@ -81,13 +81,13 @@ describe("File", () => {
|
|||||||
|
|
||||||
const tree = new Formatter().format(doc.Document.Body);
|
const tree = new Formatter().format(doc.Document.Body);
|
||||||
|
|
||||||
expect(tree["w:body"][1]["w:sectPr"][4]["w:headerReference"]._attr["w:type"]).to.equal("default");
|
expect(tree["w:body"][0]["w:sectPr"][4]["w:headerReference"]._attr["w:type"]).to.equal("default");
|
||||||
expect(tree["w:body"][1]["w:sectPr"][5]["w:headerReference"]._attr["w:type"]).to.equal("first");
|
expect(tree["w:body"][0]["w:sectPr"][5]["w:headerReference"]._attr["w:type"]).to.equal("first");
|
||||||
expect(tree["w:body"][1]["w:sectPr"][6]["w:headerReference"]._attr["w:type"]).to.equal("even");
|
expect(tree["w:body"][0]["w:sectPr"][6]["w:headerReference"]._attr["w:type"]).to.equal("even");
|
||||||
|
|
||||||
expect(tree["w:body"][1]["w:sectPr"][7]["w:footerReference"]._attr["w:type"]).to.equal("default");
|
expect(tree["w:body"][0]["w:sectPr"][7]["w:footerReference"]._attr["w:type"]).to.equal("default");
|
||||||
expect(tree["w:body"][1]["w:sectPr"][8]["w:footerReference"]._attr["w:type"]).to.equal("first");
|
expect(tree["w:body"][0]["w:sectPr"][8]["w:footerReference"]._attr["w:type"]).to.equal("first");
|
||||||
expect(tree["w:body"][1]["w:sectPr"][9]["w:footerReference"]._attr["w:type"]).to.equal("even");
|
expect(tree["w:body"][0]["w:sectPr"][9]["w:footerReference"]._attr["w:type"]).to.equal("even");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user