Files
docx-js/src/file/relationships/relationships.ts

30 lines
992 B
TypeScript
Raw Normal View History

import { XmlComponent } from "file/xml-components";
2017-03-27 01:28:52 +01:00
import { RelationshipsAttributes } from "./attributes";
import { Relationship, RelationshipType, TargetModeType } from "./relationship/relationship";
2017-03-27 01:28:52 +01:00
export class Relationships extends XmlComponent {
constructor() {
super("Relationships");
2018-01-23 01:33:12 +00:00
this.root.push(
new RelationshipsAttributes({
xmlns: "http://schemas.openxmlformats.org/package/2006/relationships",
}),
);
2018-01-10 00:29:17 +00:00
}
public addRelationship(relationship: Relationship): void {
this.root.push(relationship);
}
2019-11-08 10:50:18 +01:00
public createRelationship(id: number | string, type: RelationshipType, target: string, targetMode?: TargetModeType): Relationship {
const relationship = new Relationship(`rId${id}`, type, target, targetMode);
2018-01-10 00:29:17 +00:00
this.addRelationship(relationship);
return relationship;
2017-03-27 01:28:52 +01:00
}
2018-01-29 01:55:25 +00:00
public get RelationshipCount(): number {
return this.root.length - 1;
}
2017-03-27 01:28:52 +01:00
}