added new run methods

This commit is contained in:
Dolan Miu
2016-07-12 08:25:53 +01:00
parent 122c87ddf8
commit ed4f7464e0
6 changed files with 89 additions and 12 deletions

15
ts/docx/run/caps.ts Normal file
View File

@ -0,0 +1,15 @@
import {XmlComponent} from "../xml-components";
export class SmallCaps extends XmlComponent {
constructor() {
super("w:smallCaps");
}
}
export class Caps extends XmlComponent {
constructor() {
super("w:caps");
}
}

View File

@ -119,15 +119,4 @@ export class Size extends XmlComponent {
val: size
}));
}
}
// TODO needs work. Add more types of vertical align
export class VerticalAlign extends XmlComponent {
constructor() {
super("w:vertAlign");
this.root.push(new Attributes({
val: "superscript"
}));
}
}

View File

@ -3,6 +3,9 @@ import {RunProperties} from "./properties";
import {Bold, Italics, Underline} from "./formatting";
import {Tab} from "./tab";
import {Break} from "./break";
import {SmallCaps, Caps} from "./caps";
import {Strike, DoubleStrike} from "./strike";
import {SubScript, SuperScript} from "./script";
export class Run extends XmlComponent {
private properties: RunProperties;
@ -38,4 +41,34 @@ export class Run extends XmlComponent {
this.root.splice(1, 0, new Tab());
return this;
}
smallCaps(): Run {
this.properties.push(new SmallCaps());
return this;
}
allCaps(): Run {
this.properties.push(new Caps());
return this;
}
strike(): Run {
this.properties.push(new Strike());
return this;
}
doubleStrike(): Run {
this.properties.push(new DoubleStrike());
return this;
}
subScript(): Run {
this.properties.push(new SubScript());
return this;
}
superScript(): Run {
this.properties.push(new SuperScript());
return this;
}
}

View File

@ -1,4 +1,4 @@
import {XmlComponent, Attributes} from "../xml-components";
import {XmlComponent} from "../xml-components";
export class RunProperties extends XmlComponent {

25
ts/docx/run/script.ts Normal file
View File

@ -0,0 +1,25 @@
import {XmlComponent, Attributes} from "../xml-components";
abstract class VerticalAlign extends XmlComponent {
constructor(type: string) {
super("w:vertAlign");
this.root.push(new Attributes({
val: "superscript"
}));
}
}
export class SuperScript extends VerticalAlign {
constructor() {
super("superscript");
}
}
export class SubScript extends VerticalAlign {
constructor() {
super("subscript");
}
}

15
ts/docx/run/strike.ts Normal file
View File

@ -0,0 +1,15 @@
import {XmlComponent} from "../xml-components";
export class Strike extends XmlComponent {
constructor() {
super("w:strike");
}
}
export class DoubleStrike extends XmlComponent {
constructor() {
super("w:dstrike");
}
}