From af818df80039d24e98cc63f200861281f7417f59 Mon Sep 17 00:00:00 2001 From: Dolan Miu Date: Wed, 18 May 2016 17:06:21 +0100 Subject: [PATCH] added tab stops --- ts/docx/paragraph/index.ts | 11 ++++++++--- ts/docx/paragraph/tab-stop.ts | 32 ++++++++++++++++++++++++++++++++ ts/docx/tab-stop.ts | 5 ----- 3 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 ts/docx/paragraph/tab-stop.ts delete mode 100644 ts/docx/tab-stop.ts diff --git a/ts/docx/paragraph/index.ts b/ts/docx/paragraph/index.ts index afb9b0fdaa..4a30ba4b00 100644 --- a/ts/docx/paragraph/index.ts +++ b/ts/docx/paragraph/index.ts @@ -3,7 +3,7 @@ import {ThematicBreak} from "./border"; import {PageBreak} from "./page-break"; import {TextRun} from "../run/text-run"; import {ParagraphProperties} from "./properties"; -import {TabStop} from "../tab-stop"; +import {MaxRightTabStop, LeftTabStop} from "./tab-stop"; import {Style} from "./style"; import {NumberProperties} from "./unordered-list"; @@ -94,8 +94,13 @@ export class Paragraph extends XmlComponent { return this; } - addTabStop(tabStop: TabStop): Paragraph { - this.properties.push(tabStop); + maxRightTabStop(): Paragraph { + this.properties.push(new MaxRightTabStop()); + return this; + } + + leftTabStop(position: number): Paragraph { + this.properties.push(new LeftTabStop(position)) return this; } diff --git a/ts/docx/paragraph/tab-stop.ts b/ts/docx/paragraph/tab-stop.ts new file mode 100644 index 0000000000..02b719510f --- /dev/null +++ b/ts/docx/paragraph/tab-stop.ts @@ -0,0 +1,32 @@ +import {XmlComponent, Attributes} from "../xml-components"; + +class TabStop extends XmlComponent { + + constructor(tab: Tab) { + super("w:tabs"); + this.root.push(tab); + } +} + +class Tab extends XmlComponent { + + constructor(value: string, position: any) { + super("w:tab"); + this.root.push(new Attributes({ + val: value, + pos: position + })); + } +} + +export class MaxRightTabStop extends TabStop { + constructor() { + super(new Tab("right", "RIGHT_MARGIN")); + } +} + +export class LeftTabStop extends TabStop { + constructor(position: number) { + super(new Tab("left", position)); + } +} diff --git a/ts/docx/tab-stop.ts b/ts/docx/tab-stop.ts deleted file mode 100644 index 9c2e9f55c8..0000000000 --- a/ts/docx/tab-stop.ts +++ /dev/null @@ -1,5 +0,0 @@ -import {XmlComponent, Attributes} from "./xml-components"; - -export class TabStop extends XmlComponent{ - xmlKeys = {} -}