added #color and #size methods to Run
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
import { Break } from "./break";
|
import { Break } from "./break";
|
||||||
import { Caps, SmallCaps } from "./caps";
|
import { Caps, SmallCaps } from "./caps";
|
||||||
import { Bold, Italics } from "./formatting";
|
import { Bold, Color, Italics, Size } from "./formatting";
|
||||||
import { RunProperties } from "./properties";
|
import { RunProperties } from "./properties";
|
||||||
import { RunFonts } from "./run-fonts";
|
import { RunFonts } from "./run-fonts";
|
||||||
import { SubScript, SuperScript } from "./script";
|
import { SubScript, SuperScript } from "./script";
|
||||||
@ -34,6 +34,16 @@ export class Run extends XmlComponent {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public color(color: string): Run {
|
||||||
|
this.properties.push(new Color(color));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public size(size: number): Run {
|
||||||
|
this.properties.push(new Size(size));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public break(): Run {
|
public break(): Run {
|
||||||
this.root.splice(1, 0, new Break());
|
this.root.splice(1, 0, new Break());
|
||||||
return this;
|
return this;
|
||||||
|
@ -117,4 +117,28 @@ describe("Run", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#color", () => {
|
||||||
|
it("should set the run to the color given", () => {
|
||||||
|
run.color("001122");
|
||||||
|
const tree = new Formatter().format(run);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:r": [
|
||||||
|
{"w:rPr": [{"w:color": [{_attr: {"w:val": "001122"}}]}]},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("#size", () => {
|
||||||
|
it("should set the run to the given size", () => {
|
||||||
|
run.size(24);
|
||||||
|
const tree = new Formatter().format(run);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:r": [
|
||||||
|
{"w:rPr": [{"w:sz": [{_attr: {"w:val": 24}}]}]},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user