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

46 lines
2.1 KiB
TypeScript
Raw Normal View History

import { XmlComponent } from "@file/xml-components";
2018-01-10 00:29:17 +00:00
import { RelationshipAttributes } from "./relationship-attributes";
export type RelationshipType =
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings"
2018-01-29 01:54:50 +00:00
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"
2018-01-29 21:53:22 +00:00
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"
2018-02-04 00:58:34 +00:00
| "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/custom-properties"
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"
2018-06-11 00:48:50 +01:00
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"
| "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font";
export const TargetModeType = {
EXTERNAL: "External",
} as const;
2018-01-10 00:29:17 +00:00
export class Relationship extends XmlComponent {
public constructor(
id: string,
type: RelationshipType,
target: string,
targetMode?: (typeof TargetModeType)[keyof typeof TargetModeType],
) {
2018-01-10 00:29:17 +00:00
super("Relationship");
2018-01-23 01:33:12 +00:00
this.root.push(
new RelationshipAttributes({
id,
type,
target,
targetMode,
2018-01-23 01:33:12 +00:00
}),
);
2018-01-10 00:29:17 +00:00
}
}