Files
docx-js/src/file/drawing/doc-properties/doc-properties.ts

38 lines
1008 B
TypeScript
Raw Normal View History

2022-10-26 23:09:36 +01:00
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
import { uniqueNumericId } from "@util/convenience-functions";
class DocPropertiesAttributes extends XmlAttributeComponent<{
readonly id?: number;
readonly name?: string;
readonly description?: string;
readonly title?: string;
}> {
protected readonly xmlKeys = {
id: "id",
name: "name",
description: "descr",
title: "title",
};
}
export interface DocPropertiesOptions {
readonly name: string;
readonly description: string;
readonly title: string;
}
export class DocProperties extends XmlComponent {
2022-10-26 23:09:36 +01:00
public constructor({ name, description, title }: DocPropertiesOptions = { name: "", description: "", title: "" }) {
super("wp:docPr");
2018-01-23 01:33:12 +00:00
this.root.push(
new DocPropertiesAttributes({
2022-10-26 23:09:36 +01:00
id: uniqueNumericId(),
name,
description,
title,
2018-01-23 01:33:12 +00:00
}),
);
}
}