Files
docx-js/src/file/paragraph/formatting/tab-stop.ts

52 lines
1.3 KiB
TypeScript
Raw Normal View History

2017-09-19 15:17:58 +01:00
// http://officeopenxml.com/WPtab.php
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
2016-05-18 17:06:21 +01:00
export class TabStop extends XmlComponent {
2016-05-18 17:06:21 +01:00
constructor(tab: Tab) {
super("w:tabs");
this.root.push(tab);
}
}
2017-09-19 12:51:37 +01:00
export type TabValue = "left" | "right" | "center" | "bar" | "clear" | "decimal" | "end" | "num" | "start";
2017-03-12 22:06:11 +01:00
2018-01-23 01:33:12 +00:00
export class TabAttributes extends XmlAttributeComponent<{ val: TabValue; pos: string | number }> {
protected xmlKeys = { val: "w:val", pos: "w:pos" };
2017-03-12 22:06:11 +01:00
}
export class Tab extends XmlComponent {
2017-09-19 12:51:37 +01:00
constructor(value: TabValue, position: string | number) {
2016-05-18 17:06:21 +01:00
super("w:tab");
2018-01-23 01:33:12 +00:00
this.root.push(
new TabAttributes({
val: value,
pos: position,
}),
);
2016-05-18 17:06:21 +01:00
}
}
export class MaxRightTabStop extends TabStop {
constructor() {
2016-06-10 15:03:44 +01:00
super(new Tab("right", 9026));
2016-05-18 17:06:21 +01:00
}
}
export class LeftTabStop extends TabStop {
constructor(position: number) {
super(new Tab("left", position));
}
}
2017-09-19 12:51:37 +01:00
export class RightTabStop extends TabStop {
constructor(position: number) {
super(new Tab("right", position));
}
}
export class CenterTabStop extends TabStop {
constructor(position: number) {
super(new Tab("center", position));
}
}