diff --git a/docx-wasm/js/doc-props.ts b/docx-wasm/js/doc-props.ts new file mode 100644 index 0000000..07c9a86 --- /dev/null +++ b/docx-wasm/js/doc-props.ts @@ -0,0 +1,14 @@ +export class DocProps { + _createdAt: string | null = null; + _updatedAt: string | null = null; + + createdAt(date: string) { + this._createdAt = date; + return this; + } + + updatedAt(date: string) { + this._updatedAt = date; + return this; + } +} diff --git a/docx-wasm/js/index.ts b/docx-wasm/js/index.ts index 46176cd..e62de56 100644 --- a/docx-wasm/js/index.ts +++ b/docx-wasm/js/index.ts @@ -16,6 +16,7 @@ import { Numbering } from "./numbering"; import { BookmarkStart } from "./bookmark-start"; import { BookmarkEnd } from "./bookmark-end"; import { Settings } from "./settings"; +import { DocProps } from "./doc-props"; import { Styles } from "./styles"; import { SectionProperty, PageMargin } from "./section-property"; import { DocxJSON } from "./json"; @@ -56,6 +57,7 @@ export class Docx { abstractNumberings: AbstractNumbering[] = []; numberings: Numbering[] = []; settings: Settings = new Settings(); + docProps: DocProps = new DocProps(); sectionProperty: SectionProperty = new SectionProperty(); styles = new Styles(); @@ -100,6 +102,16 @@ export class Docx { return this; } + createdAt(date: string) { + this.docProps.createdAt(date); + return this; + } + + updatedAt(date: string) { + this.docProps.updatedAt(date); + return this; + } + addDocVar(name: string, val: string) { this.settings.addDocVar(name, val); return this; @@ -665,6 +677,14 @@ export class Docx { } } + if (this.docProps._createdAt) { + docx = docx.created_at(this.docProps._createdAt); + } + + if (this.docProps._updatedAt) { + docx = docx.updated_at(this.docProps._updatedAt); + } + return docx; } diff --git a/docx-wasm/package.json b/docx-wasm/package.json index 7ed7290..07d7753 100644 --- a/docx-wasm/package.json +++ b/docx-wasm/package.json @@ -1,6 +1,6 @@ { "name": "docx-wasm", - "version": "0.0.137", + "version": "0.0.138", "main": "dist/node/index.js", "browser": "dist/web/index.js", "author": "bokuweb ", diff --git a/docx-wasm/src/doc.rs b/docx-wasm/src/doc.rs index f28f217..274de30 100644 --- a/docx-wasm/src/doc.rs +++ b/docx-wasm/src/doc.rs @@ -43,6 +43,16 @@ impl Docx { self } + pub fn created_at(mut self, date: &str) -> Self { + self.0.doc_props = self.0.doc_props.created_at(date); + self + } + + pub fn updated_at(mut self, date: &str) -> Self { + self.0.doc_props = self.0.doc_props.updated_at(date); + self + } + pub fn doc_id(mut self, id: &str) -> Docx { self.0 = self.0.doc_id(id); self