ability to specify textDirection for section

This commit is contained in:
Katz Sakai
2021-11-19 22:30:38 +09:00
parent c01d3d9f67
commit 9cddfb4ce7
5 changed files with 67 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import { VerticalAlign } from "file/vertical-align";
import { PageOrientation } from "./properties";
import { LineNumberRestartFormat } from "./properties/line-number";
import { PageBorderOffsetFrom } from "./properties/page-borders";
import { PageTextDirection } from "./properties/page-text-direction";
import { SectionType } from "./properties/section-type";
import { sectionMarginDefaults, sectionPageSizeDefaults, SectionProperties } from "./section-properties";
@ -258,5 +259,19 @@ describe("SectionProperties", () => {
"w:lnNumType": { _attr: { "w:countBy": 2, "w:distance": 4, "w:restart": "continuous", "w:start": 2 } },
});
});
it("should create section properties with text flow direction", () => {
const properties = new SectionProperties({
page: {
textDirection: PageTextDirection.TOP_TO_BOTTOM_RIGHT_TO_LEFT,
},
});
const tree = new Formatter().format(properties);
expect(Object.keys(tree)).to.deep.equal(["w:sectPr"]);
const type = tree["w:sectPr"].find((item) => item["w:textDirection"] !== undefined);
expect(type).to.deep.equal({
"w:textDirection": { _attr: { "w:val": "tbRl" } },
});
});
});
});