modify relationships to support external links
This commit is contained in:
@ -4,6 +4,7 @@ export interface IRelationshipAttributesProperties {
|
||||
id: string;
|
||||
type: string;
|
||||
target: string;
|
||||
targetMode?: string;
|
||||
}
|
||||
|
||||
export class RelationshipAttributes extends XmlAttributeComponent<IRelationshipAttributesProperties> {
|
||||
@ -11,5 +12,6 @@ export class RelationshipAttributes extends XmlAttributeComponent<IRelationshipA
|
||||
id: "Id",
|
||||
type: "Type",
|
||||
target: "Target",
|
||||
targetMode: "TargetMode",
|
||||
};
|
||||
}
|
||||
|
@ -13,10 +13,13 @@ export type RelationshipType =
|
||||
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"
|
||||
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
|
||||
| "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"
|
||||
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties";
|
||||
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"
|
||||
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
|
||||
|
||||
export type TargetModeType = "External";
|
||||
|
||||
export class Relationship extends XmlComponent {
|
||||
constructor(id: string, type: RelationshipType, target: string) {
|
||||
constructor(id: string, type: RelationshipType, target: string, targetMode?: TargetModeType) {
|
||||
super("Relationship");
|
||||
|
||||
this.root.push(
|
||||
@ -24,6 +27,7 @@ export class Relationship extends XmlComponent {
|
||||
id,
|
||||
type,
|
||||
target,
|
||||
targetMode,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
import { RelationshipsAttributes } from "./attributes";
|
||||
import { Relationship, RelationshipType } from "./relationship/relationship";
|
||||
import { Relationship, RelationshipType, TargetModeType } from "./relationship/relationship";
|
||||
|
||||
export class Relationships extends XmlComponent {
|
||||
constructor() {
|
||||
@ -16,8 +16,8 @@ export class Relationships extends XmlComponent {
|
||||
this.root.push(relationship);
|
||||
}
|
||||
|
||||
public createRelationship(id: number, type: RelationshipType, target: string): Relationship {
|
||||
const relationship = new Relationship(`rId${id}`, type, target);
|
||||
public createRelationship(id: number, type: RelationshipType, target: string, targetMode?: TargetModeType): Relationship {
|
||||
const relationship = new Relationship(`rId${id}`, type, target, targetMode);
|
||||
this.addRelationship(relationship);
|
||||
|
||||
return relationship;
|
||||
|
Reference in New Issue
Block a user