ability to specify textDirection for section
This commit is contained in:
@ -7,6 +7,7 @@ export * from "./page-number";
|
||||
export * from "./page-borders";
|
||||
export * from "./page-margin";
|
||||
export * from "./page-borders";
|
||||
export * from "./page-text-direction";
|
||||
export * from "./line-number";
|
||||
export * from "./section-type";
|
||||
export * from "./header-footer-reference";
|
||||
|
@ -0,0 +1,22 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
import { PageTDirection, PageTextDirection } from "./page-text-direction";
|
||||
|
||||
describe("PageTextDirection", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should set the direction of the text flow to top-to-bottom-right-to-left", () => {
|
||||
const textDirection = new PageTDirection(PageTextDirection.TOP_TO_BOTTOM_RIGHT_TO_LEFT);
|
||||
|
||||
const tree = new Formatter().format(textDirection);
|
||||
|
||||
expect(tree).to.deep.equal({
|
||||
"w:textDirection": {
|
||||
_attr: {
|
||||
"w:val": "tbRl",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,22 @@
|
||||
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||
|
||||
export enum PageTextDirection {
|
||||
LEFT_TO_RIGHT_TOP_TO_BOTTOM = "lrTb",
|
||||
TOP_TO_BOTTOM_RIGHT_TO_LEFT = "tbRl",
|
||||
}
|
||||
|
||||
class PageTextDirectionAttributes extends XmlAttributeComponent<{ readonly val: PageTextDirection }> {
|
||||
protected readonly xmlKeys = { val: "w:val" };
|
||||
}
|
||||
|
||||
export class PageTDirection extends XmlComponent {
|
||||
constructor(value: PageTextDirection) {
|
||||
super("w:textDirection");
|
||||
|
||||
this.root.push(
|
||||
new PageTextDirectionAttributes({
|
||||
val: value,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user