Allow XmlComponent to take strings and remove XmlUnit
This commit is contained in:
@ -1,9 +1,11 @@
|
||||
import { XmlUnitComponent } from "../xml-components";
|
||||
import { XmlComponent } from "../xml-components";
|
||||
|
||||
export class Text extends XmlUnitComponent {
|
||||
export class Text extends XmlComponent {
|
||||
|
||||
constructor(text: string) {
|
||||
super("w:t");
|
||||
this.root = text;
|
||||
if (text) {
|
||||
this.root.push(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@ import * as _ from "lodash";
|
||||
import { BaseXmlComponent } from "./base";
|
||||
|
||||
export abstract class XmlAttributeComponent extends BaseXmlComponent {
|
||||
protected root: Object;
|
||||
private xmlKeys: Object;
|
||||
protected root: object;
|
||||
private xmlKeys: object;
|
||||
|
||||
constructor(xmlKeys: Object, properties: Object) {
|
||||
constructor(xmlKeys: object, properties: object) {
|
||||
super("_attr");
|
||||
this.xmlKeys = xmlKeys;
|
||||
|
||||
|
@ -2,7 +2,7 @@ import * as _ from "lodash";
|
||||
import { BaseXmlComponent } from "./base";
|
||||
|
||||
export abstract class XmlComponent extends BaseXmlComponent {
|
||||
protected root: BaseXmlComponent[];
|
||||
protected root: Array<BaseXmlComponent | string>;
|
||||
|
||||
constructor(rootKey: string) {
|
||||
super(rootKey);
|
||||
@ -26,4 +26,3 @@ export abstract class XmlComponent extends BaseXmlComponent {
|
||||
|
||||
export * from "./attributes"
|
||||
export * from "./default-attributes";
|
||||
export * from "./unit";
|
||||
|
@ -1,16 +0,0 @@
|
||||
import {BaseXmlComponent} from "./base";
|
||||
|
||||
export abstract class XmlUnitComponent extends BaseXmlComponent {
|
||||
protected root: string;
|
||||
|
||||
constructor(rootKey: string) {
|
||||
super(rootKey);
|
||||
}
|
||||
|
||||
public replaceKey(): void {
|
||||
if (this.root !== undefined) {
|
||||
this[this.rootKey] = this.root;
|
||||
delete this.root;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user