FIX: multiple tabStop support for LibreWriter

This commit is contained in:
Ronit Ramdam BK
2022-10-14 16:38:02 +05:45
parent 059455929b
commit 629c586014
3 changed files with 37 additions and 15 deletions

View File

@ -1,10 +1,22 @@
// http://officeopenxml.com/WPtab.php
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
export interface TabStopDefinition {
type: TabStopType,
position: number | TabStopPosition,
leader?: LeaderType
}
export class TabStop extends XmlComponent {
public constructor(type: TabStopType, position: number, leader?: LeaderType) {
public constructor(tabDefs: (TabStopDefinition[] | TabStopDefinition)) {
super("w:tabs");
this.root.push(new TabStopItem(type, position, leader));
if (Array.isArray(tabDefs)) {
tabDefs.forEach((function(tabDef) {
this.root.push(new TabStopItem(tabDef));
}).bind(this));
} else {
this.root.push(new TabStopItem(tabDefs));
}
}
}
@ -41,14 +53,14 @@ export class TabAttributes extends XmlAttributeComponent<{
}
export class TabStopItem extends XmlComponent {
public constructor(value: TabStopType, position: string | number, leader?: LeaderType) {
public constructor(tabDef: TabStopDefinition) {
super("w:tab");
this.root.push(
new TabAttributes({
val: value,
pos: position,
leader,
}),
val: tabDef.type,
pos: tabDef.position,
leader: tabDef.leader,
})
);
}
}