Introduce some functional programming techniques

This commit is contained in:
Dolan
2018-11-02 02:51:57 +00:00
parent 9cfd835171
commit 7980f14efb
108 changed files with 749 additions and 659 deletions

View File

@ -1,11 +1,10 @@
// http://officeopenxml.com/WPhyperlink.php
import { XmlComponent } from "file/xml-components";
import { TextRun } from "../run";
import { HyperlinkAttributes, IHyperlinkAttributesProperties } from "./hyperlink-attributes";
export class Hyperlink extends XmlComponent {
public linkId: number;
public readonly linkId: number;
constructor(text: string, relationshipsCount: number, anchor?: string) {
super("w:hyperlink");
@ -14,14 +13,10 @@ export class Hyperlink extends XmlComponent {
const props: IHyperlinkAttributesProperties = {
history: 1,
anchor: anchor ? anchor : undefined,
id: !anchor ? `rId${this.linkId}` : undefined,
};
if (anchor) {
props.anchor = anchor;
} else {
props.id = `rId${this.linkId}`;
}
const attributes = new HyperlinkAttributes(props);
this.root.push(attributes);
this.root.push(new TextRun(text).style("Hyperlink"));