FIX: added legacy support for TabStop
This commit is contained in:
@ -8,14 +8,18 @@ export interface TabStopDefinition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class TabStop extends XmlComponent {
|
export class TabStop extends XmlComponent {
|
||||||
public constructor(tabDefs: (TabStopDefinition[] | TabStopDefinition)) {
|
public constructor(tabDefs: (TabStopDefinition[] | TabStopDefinition | TabStopType), position?: number, leader?: LeaderType) {
|
||||||
super("w:tabs");
|
super("w:tabs");
|
||||||
if (Array.isArray(tabDefs)) {
|
if (typeof tabDefs === "string"){
|
||||||
tabDefs.forEach((function(tabDef) {
|
this.root.push(new TabStopItem(tabDefs, position, leader));
|
||||||
this.root.push(new TabStopItem(tabDef));
|
|
||||||
}).bind(this));
|
|
||||||
} else {
|
} else {
|
||||||
this.root.push(new TabStopItem(tabDefs));
|
if (Array.isArray(tabDefs)) {
|
||||||
|
tabDefs.forEach((function(tabDef) {
|
||||||
|
this.root.push(new TabStopItem(tabDef));
|
||||||
|
}).bind(this));
|
||||||
|
} else {
|
||||||
|
this.root.push(new TabStopItem(tabDefs));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,14 +57,26 @@ export class TabAttributes extends XmlAttributeComponent<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class TabStopItem extends XmlComponent {
|
export class TabStopItem extends XmlComponent {
|
||||||
public constructor(tabDef: TabStopDefinition) {
|
public constructor(tabDef: (TabStopDefinition | TabStopType), position?: number, leader?: LeaderType) {
|
||||||
super("w:tab");
|
super("w:tab");
|
||||||
this.root.push(
|
if (typeof tabDef === "string") {
|
||||||
new TabAttributes({
|
if (typeof position === "number")
|
||||||
val: tabDef.type,
|
this.root.push(
|
||||||
pos: tabDef.position,
|
new TabAttributes({
|
||||||
leader: tabDef.leader,
|
val: tabDef,
|
||||||
})
|
pos: position,
|
||||||
);
|
leader,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
else throw Error("Undefined position: " + position);
|
||||||
|
} else {
|
||||||
|
this.root.push(
|
||||||
|
new TabAttributes({
|
||||||
|
val: tabDef.type,
|
||||||
|
pos: tabDef.position,
|
||||||
|
leader: tabDef.leader,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user