documents.js 1.68.0 → 1.70.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/edit/docx/content.cjs +6 -1
- package/dist/edit/docx/content.d.cts +2 -0
- package/dist/edit/docx/content.d.ts +2 -0
- package/dist/edit/docx/content.js +7 -2
- package/dist/edit/docx/editor.cjs +6 -2
- package/dist/edit/docx/editor.d.cts +6 -2
- package/dist/edit/docx/editor.d.ts +6 -2
- package/dist/edit/docx/editor.js +6 -2
- package/dist/edit/docx/scaffold.cjs +5 -2
- package/dist/edit/docx/scaffold.d.cts +6 -2
- package/dist/edit/docx/scaffold.d.ts +6 -2
- package/dist/edit/docx/scaffold.js +5 -2
- package/dist/edit/odg/content.cjs +7 -2
- package/dist/edit/odg/content.d.cts +6 -2
- package/dist/edit/odg/content.d.ts +6 -2
- package/dist/edit/odg/content.js +8 -3
- package/dist/edit/odg/editor.cjs +6 -2
- package/dist/edit/odg/editor.d.cts +6 -2
- package/dist/edit/odg/editor.d.ts +6 -2
- package/dist/edit/odg/editor.js +6 -2
- package/dist/edit/odg/scaffold.cjs +17 -4
- package/dist/edit/odg/scaffold.d.cts +6 -2
- package/dist/edit/odg/scaffold.d.ts +6 -2
- package/dist/edit/odg/scaffold.js +18 -5
- package/dist/edit/odp/content.cjs +7 -2
- package/dist/edit/odp/content.d.cts +6 -2
- package/dist/edit/odp/content.d.ts +6 -2
- package/dist/edit/odp/content.js +8 -3
- package/dist/edit/odp/editor.cjs +6 -2
- package/dist/edit/odp/editor.d.cts +6 -2
- package/dist/edit/odp/editor.d.ts +6 -2
- package/dist/edit/odp/editor.js +6 -2
- package/dist/edit/odp/scaffold.cjs +17 -4
- package/dist/edit/odp/scaffold.d.cts +6 -2
- package/dist/edit/odp/scaffold.d.ts +6 -2
- package/dist/edit/odp/scaffold.js +18 -5
- package/dist/edit/ods/content.cjs +7 -2
- package/dist/edit/ods/content.d.cts +6 -2
- package/dist/edit/ods/content.d.ts +6 -2
- package/dist/edit/ods/content.js +8 -3
- package/dist/edit/ods/editor.cjs +6 -2
- package/dist/edit/ods/editor.d.cts +6 -2
- package/dist/edit/ods/editor.d.ts +6 -2
- package/dist/edit/ods/editor.js +6 -2
- package/dist/edit/ods/scaffold.cjs +17 -4
- package/dist/edit/ods/scaffold.d.cts +6 -2
- package/dist/edit/ods/scaffold.d.ts +6 -2
- package/dist/edit/ods/scaffold.js +18 -5
- package/dist/edit/odt/content.cjs +7 -2
- package/dist/edit/odt/content.d.cts +6 -2
- package/dist/edit/odt/content.d.ts +6 -2
- package/dist/edit/odt/content.js +8 -3
- package/dist/edit/odt/editor.cjs +6 -2
- package/dist/edit/odt/editor.d.cts +6 -2
- package/dist/edit/odt/editor.d.ts +6 -2
- package/dist/edit/odt/editor.js +6 -2
- package/dist/edit/odt/scaffold.cjs +17 -4
- package/dist/edit/odt/scaffold.d.cts +6 -2
- package/dist/edit/odt/scaffold.d.ts +6 -2
- package/dist/edit/odt/scaffold.js +18 -5
- package/dist/edit/pptx/content.cjs +7 -2
- package/dist/edit/pptx/content.d.cts +6 -2
- package/dist/edit/pptx/content.d.ts +6 -2
- package/dist/edit/pptx/content.js +8 -3
- package/dist/edit/pptx/editor.cjs +6 -2
- package/dist/edit/pptx/editor.d.cts +6 -2
- package/dist/edit/pptx/editor.d.ts +6 -2
- package/dist/edit/pptx/editor.js +6 -2
- package/dist/edit/pptx/scaffold.cjs +3 -1
- package/dist/edit/pptx/scaffold.d.cts +6 -2
- package/dist/edit/pptx/scaffold.d.ts +6 -2
- package/dist/edit/pptx/scaffold.js +3 -1
- package/dist/index.cjs +3 -1
- package/dist/index.d.cts +20 -13
- package/dist/index.d.ts +20 -13
- package/dist/index.js +3 -2
- package/dist/mathml/layout.cjs +42 -3
- package/dist/mathml/layout.js +42 -3
- package/dist/mathml/operators.cjs +12 -0
- package/dist/mathml/operators.js +12 -0
- package/dist/model/metadata.cjs +13 -0
- package/dist/model/metadata.d.cts +6 -0
- package/dist/model/metadata.d.ts +6 -0
- package/dist/model/metadata.js +12 -0
- package/dist/opc/core-properties.cjs +65 -0
- package/dist/opc/core-properties.d.cts +6 -0
- package/dist/opc/core-properties.d.ts +6 -0
- package/dist/opc/core-properties.js +64 -0
- package/dist/opc/rels.cjs +11 -4
- package/dist/opc/rels.d.cts +2 -1
- package/dist/opc/rels.d.ts +2 -1
- package/dist/opc/rels.js +11 -5
- package/package.json +2 -2
package/dist/edit/odp/content.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import { resolveMetadataTimestamps } from "../../model/metadata.js";
|
|
2
|
+
import { systemClock } from "../../ports/clock.js";
|
|
1
3
|
import { drawingOfBlock, embeddedDrawingVectors } from "../../model/embedded-drawing.js";
|
|
2
4
|
import { populateOdtTable, populateParagraph } from "../odt/content.js";
|
|
3
|
-
import {
|
|
5
|
+
import { createEmptyOdpPackage } from "./scaffold.js";
|
|
6
|
+
import { OdpEditor } from "./editor.js";
|
|
4
7
|
import { base64ToBytes } from "odf.js";
|
|
5
8
|
//#region src/edit/odp/content.ts
|
|
6
|
-
function buildOdpPackage(content) {
|
|
9
|
+
function buildOdpPackage(content, options) {
|
|
7
10
|
if (content.kind !== "presentation") throw new Error("buildOdpPackage requires a presentation ContentDocument");
|
|
8
|
-
const
|
|
11
|
+
const clock = options?.clock ?? systemClock;
|
|
12
|
+
const metadata = resolveMetadataTimestamps(content.metadata, clock);
|
|
13
|
+
const editor = new OdpEditor(createEmptyOdpPackage({ metadata }));
|
|
9
14
|
const firstSlide = content.slides[0];
|
|
10
15
|
if (firstSlide !== void 0) editor.slideSize = firstSlide.size;
|
|
11
16
|
for (const slide of content.slides) {
|
package/dist/edit/odp/editor.cjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_metadata = require("../../model/metadata.cjs");
|
|
3
|
+
const require_ports_clock = require("../../ports/clock.cjs");
|
|
2
4
|
const require_xml_fragment = require("../../xml/fragment.cjs");
|
|
3
5
|
const require_edit_odp_scaffold = require("./scaffold.cjs");
|
|
4
6
|
const require_edit_odp_slide = require("./slide.cjs");
|
|
@@ -104,8 +106,10 @@ var OdpEditor = class {
|
|
|
104
106
|
function openOdp(bytes) {
|
|
105
107
|
return new OdpEditor((0, odf_js.decodePackage)(bytes));
|
|
106
108
|
}
|
|
107
|
-
function createOdp() {
|
|
108
|
-
|
|
109
|
+
function createOdp(options) {
|
|
110
|
+
const clock = options?.clock ?? require_ports_clock.systemClock;
|
|
111
|
+
const metadata = require_model_metadata.resolveMetadataTimestamps({}, clock);
|
|
112
|
+
return new OdpEditor(require_edit_odp_scaffold.createEmptyOdpPackage({ metadata }));
|
|
109
113
|
}
|
|
110
114
|
//#endregion
|
|
111
115
|
exports.OdpEditor = OdpEditor;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.cjs";
|
|
1
2
|
import { s as PageSize } from "../../geometry-DaJr8yQW.cjs";
|
|
2
3
|
import { OdpSlide } from "./slide.cjs";
|
|
3
4
|
import { Package } from "odf.js";
|
|
@@ -15,6 +16,9 @@ declare class OdpEditor {
|
|
|
15
16
|
toBytes(): Uint8Array<ArrayBuffer>;
|
|
16
17
|
}
|
|
17
18
|
declare function openOdp(bytes: Uint8Array<ArrayBuffer>): OdpEditor;
|
|
18
|
-
|
|
19
|
+
interface CreateOdpOptions {
|
|
20
|
+
readonly clock?: ClockPort;
|
|
21
|
+
}
|
|
22
|
+
declare function createOdp(options?: CreateOdpOptions): OdpEditor;
|
|
19
23
|
//#endregion
|
|
20
|
-
export { OdpEditor, createOdp, openOdp };
|
|
24
|
+
export { CreateOdpOptions, OdpEditor, createOdp, openOdp };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.js";
|
|
1
2
|
import { s as PageSize } from "../../geometry-DaJr8yQW.js";
|
|
2
3
|
import { OdpSlide } from "./slide.js";
|
|
3
4
|
import { Package } from "odf.js";
|
|
@@ -15,6 +16,9 @@ declare class OdpEditor {
|
|
|
15
16
|
toBytes(): Uint8Array<ArrayBuffer>;
|
|
16
17
|
}
|
|
17
18
|
declare function openOdp(bytes: Uint8Array<ArrayBuffer>): OdpEditor;
|
|
18
|
-
|
|
19
|
+
interface CreateOdpOptions {
|
|
20
|
+
readonly clock?: ClockPort;
|
|
21
|
+
}
|
|
22
|
+
declare function createOdp(options?: CreateOdpOptions): OdpEditor;
|
|
19
23
|
//#endregion
|
|
20
|
-
export { OdpEditor, createOdp, openOdp };
|
|
24
|
+
export { CreateOdpOptions, OdpEditor, createOdp, openOdp };
|
package/dist/edit/odp/editor.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolveMetadataTimestamps } from "../../model/metadata.js";
|
|
2
|
+
import { systemClock } from "../../ports/clock.js";
|
|
1
3
|
import { el } from "../../xml/fragment.js";
|
|
2
4
|
import { MASTER_PAGE_NAME, createEmptyOdpPackage } from "./scaffold.js";
|
|
3
5
|
import { OdpSlide } from "./slide.js";
|
|
@@ -103,8 +105,10 @@ var OdpEditor = class {
|
|
|
103
105
|
function openOdp(bytes) {
|
|
104
106
|
return new OdpEditor(decodePackage$1(bytes));
|
|
105
107
|
}
|
|
106
|
-
function createOdp() {
|
|
107
|
-
|
|
108
|
+
function createOdp(options) {
|
|
109
|
+
const clock = options?.clock ?? systemClock;
|
|
110
|
+
const metadata = resolveMetadataTimestamps({}, clock);
|
|
111
|
+
return new OdpEditor(createEmptyOdpPackage({ metadata }));
|
|
108
112
|
}
|
|
109
113
|
//#endregion
|
|
110
114
|
export { OdpEditor, createOdp, openOdp };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_xml_fragment = require("../../xml/fragment.cjs");
|
|
3
|
+
const require_xml_entities = require("../../xml/entities.cjs");
|
|
3
4
|
let odf_js = require("odf.js");
|
|
4
5
|
let document_schema_js = require("document-schema.js");
|
|
5
6
|
//#region src/edit/odp/scaffold.ts
|
|
@@ -77,13 +78,25 @@ function buildContentXml() {
|
|
|
77
78
|
"office:version": ODF_VERSION
|
|
78
79
|
}, [require_xml_fragment.el("office:automatic-styles"), require_xml_fragment.el("office:body", {}, [require_xml_fragment.el("office:presentation")])]);
|
|
79
80
|
}
|
|
80
|
-
function
|
|
81
|
+
function buildOfficeMeta(metadata) {
|
|
82
|
+
if (metadata === void 0) return [];
|
|
83
|
+
const children = [];
|
|
84
|
+
if (metadata.title !== void 0) children.push(require_xml_fragment.el("dc:title", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.title))]));
|
|
85
|
+
if (metadata.author !== void 0) children.push(require_xml_fragment.el("meta:initial-creator", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.author))]));
|
|
86
|
+
if (metadata.subject !== void 0) children.push(require_xml_fragment.el("dc:subject", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.subject))]));
|
|
87
|
+
for (const keyword of metadata.keywords ?? []) children.push(require_xml_fragment.el("meta:keyword", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(keyword))]));
|
|
88
|
+
if (metadata.creator !== void 0) children.push(require_xml_fragment.el("meta:generator", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.creator))]));
|
|
89
|
+
if (metadata.createdIso !== void 0) children.push(require_xml_fragment.el("meta:creation-date", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.createdIso))]));
|
|
90
|
+
if (metadata.modifiedIso !== void 0) children.push(require_xml_fragment.el("dc:date", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.modifiedIso))]));
|
|
91
|
+
return children;
|
|
92
|
+
}
|
|
93
|
+
function buildMetaXml(metadata) {
|
|
81
94
|
return require_xml_fragment.el("office:document-meta", {
|
|
82
95
|
...(0, odf_js.xmlnsAttributes)([...META_NS_PREFIXES]),
|
|
83
96
|
"office:version": ODF_VERSION
|
|
84
|
-
}, [require_xml_fragment.el("office:meta")]);
|
|
97
|
+
}, [require_xml_fragment.el("office:meta", {}, buildOfficeMeta(metadata))]);
|
|
85
98
|
}
|
|
86
|
-
function createEmptyOdpPackage() {
|
|
99
|
+
function createEmptyOdpPackage(options) {
|
|
87
100
|
const pkg = { parts: {
|
|
88
101
|
"content.xml": {
|
|
89
102
|
kind: "xml",
|
|
@@ -95,7 +108,7 @@ function createEmptyOdpPackage() {
|
|
|
95
108
|
},
|
|
96
109
|
"meta.xml": {
|
|
97
110
|
kind: "xml",
|
|
98
|
-
nodes: [declaration(), buildMetaXml()]
|
|
111
|
+
nodes: [declaration(), buildMetaXml(options?.metadata)]
|
|
99
112
|
}
|
|
100
113
|
} };
|
|
101
114
|
(0, odf_js.setDocumentMediaType)(pkg, odf_js.ODF_MEDIA_TYPES.odp);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { LayoutMetadata } from "document-schema.js";
|
|
1
2
|
import { Package } from "odf.js";
|
|
2
3
|
//#region src/edit/odp/scaffold.d.ts
|
|
3
4
|
declare const PAGE_LAYOUT_NAME = "PM1";
|
|
4
5
|
declare const MASTER_PAGE_NAME = "Standard";
|
|
5
|
-
|
|
6
|
+
interface CreateEmptyOdpPackageOptions {
|
|
7
|
+
readonly metadata?: LayoutMetadata;
|
|
8
|
+
}
|
|
9
|
+
declare function createEmptyOdpPackage(options?: CreateEmptyOdpPackageOptions): Package;
|
|
6
10
|
//#endregion
|
|
7
|
-
export { MASTER_PAGE_NAME, PAGE_LAYOUT_NAME, createEmptyOdpPackage };
|
|
11
|
+
export { CreateEmptyOdpPackageOptions, MASTER_PAGE_NAME, PAGE_LAYOUT_NAME, createEmptyOdpPackage };
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { LayoutMetadata } from "document-schema.js";
|
|
1
2
|
import { Package } from "odf.js";
|
|
2
3
|
//#region src/edit/odp/scaffold.d.ts
|
|
3
4
|
declare const PAGE_LAYOUT_NAME = "PM1";
|
|
4
5
|
declare const MASTER_PAGE_NAME = "Standard";
|
|
5
|
-
|
|
6
|
+
interface CreateEmptyOdpPackageOptions {
|
|
7
|
+
readonly metadata?: LayoutMetadata;
|
|
8
|
+
}
|
|
9
|
+
declare function createEmptyOdpPackage(options?: CreateEmptyOdpPackageOptions): Package;
|
|
6
10
|
//#endregion
|
|
7
|
-
export { MASTER_PAGE_NAME, PAGE_LAYOUT_NAME, createEmptyOdpPackage };
|
|
11
|
+
export { CreateEmptyOdpPackageOptions, MASTER_PAGE_NAME, PAGE_LAYOUT_NAME, createEmptyOdpPackage };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SLIDE_SIZE_WIDESCREEN } from "../../model/geometry.js";
|
|
2
|
-
import { el } from "../../xml/fragment.js";
|
|
2
|
+
import { el, txt } from "../../xml/fragment.js";
|
|
3
|
+
import { encodeXmlText } from "../../xml/entities.js";
|
|
3
4
|
import { ODF_MEDIA_TYPES, setDocumentMediaType, syncManifest, xmlnsAttributes } from "odf.js";
|
|
4
5
|
//#region src/edit/odp/scaffold.ts
|
|
5
6
|
const CONTENT_NS_PREFIXES = [
|
|
@@ -76,13 +77,25 @@ function buildContentXml() {
|
|
|
76
77
|
"office:version": ODF_VERSION
|
|
77
78
|
}, [el("office:automatic-styles"), el("office:body", {}, [el("office:presentation")])]);
|
|
78
79
|
}
|
|
79
|
-
function
|
|
80
|
+
function buildOfficeMeta(metadata) {
|
|
81
|
+
if (metadata === void 0) return [];
|
|
82
|
+
const children = [];
|
|
83
|
+
if (metadata.title !== void 0) children.push(el("dc:title", {}, [txt(encodeXmlText(metadata.title))]));
|
|
84
|
+
if (metadata.author !== void 0) children.push(el("meta:initial-creator", {}, [txt(encodeXmlText(metadata.author))]));
|
|
85
|
+
if (metadata.subject !== void 0) children.push(el("dc:subject", {}, [txt(encodeXmlText(metadata.subject))]));
|
|
86
|
+
for (const keyword of metadata.keywords ?? []) children.push(el("meta:keyword", {}, [txt(encodeXmlText(keyword))]));
|
|
87
|
+
if (metadata.creator !== void 0) children.push(el("meta:generator", {}, [txt(encodeXmlText(metadata.creator))]));
|
|
88
|
+
if (metadata.createdIso !== void 0) children.push(el("meta:creation-date", {}, [txt(encodeXmlText(metadata.createdIso))]));
|
|
89
|
+
if (metadata.modifiedIso !== void 0) children.push(el("dc:date", {}, [txt(encodeXmlText(metadata.modifiedIso))]));
|
|
90
|
+
return children;
|
|
91
|
+
}
|
|
92
|
+
function buildMetaXml(metadata) {
|
|
80
93
|
return el("office:document-meta", {
|
|
81
94
|
...xmlnsAttributes([...META_NS_PREFIXES]),
|
|
82
95
|
"office:version": ODF_VERSION
|
|
83
|
-
}, [el("office:meta")]);
|
|
96
|
+
}, [el("office:meta", {}, buildOfficeMeta(metadata))]);
|
|
84
97
|
}
|
|
85
|
-
function createEmptyOdpPackage() {
|
|
98
|
+
function createEmptyOdpPackage(options) {
|
|
86
99
|
const pkg = { parts: {
|
|
87
100
|
"content.xml": {
|
|
88
101
|
kind: "xml",
|
|
@@ -94,7 +107,7 @@ function createEmptyOdpPackage() {
|
|
|
94
107
|
},
|
|
95
108
|
"meta.xml": {
|
|
96
109
|
kind: "xml",
|
|
97
|
-
nodes: [declaration(), buildMetaXml()]
|
|
110
|
+
nodes: [declaration(), buildMetaXml(options?.metadata)]
|
|
98
111
|
}
|
|
99
112
|
} };
|
|
100
113
|
setDocumentMediaType(pkg, ODF_MEDIA_TYPES.odp);
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_metadata = require("../../model/metadata.cjs");
|
|
3
|
+
const require_ports_clock = require("../../ports/clock.cjs");
|
|
4
|
+
const require_edit_ods_scaffold = require("./scaffold.cjs");
|
|
2
5
|
const require_edit_ods_editor = require("./editor.cjs");
|
|
3
6
|
//#region src/edit/ods/content.ts
|
|
4
|
-
function buildOdsPackage(content) {
|
|
7
|
+
function buildOdsPackage(content, options) {
|
|
5
8
|
if (content.kind !== "spreadsheet") throw new Error("buildOdsPackage requires a spreadsheet ContentDocument");
|
|
6
|
-
const
|
|
9
|
+
const clock = options?.clock ?? require_ports_clock.systemClock;
|
|
10
|
+
const metadata = require_model_metadata.resolveMetadataTimestamps(content.metadata, clock);
|
|
11
|
+
const editor = new require_edit_ods_editor.OdsEditor(require_edit_ods_scaffold.createEmptyOdsPackage({ metadata }));
|
|
7
12
|
if (content.sheets.length > 0) editor.removeSheetAt(0);
|
|
8
13
|
for (const sheet of content.sheets) {
|
|
9
14
|
const odsSheet = editor.addSheet(sheet.name);
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.cjs";
|
|
1
2
|
import { ContentDocument } from "document-schema.js";
|
|
2
3
|
import { Package } from "odf.js";
|
|
3
4
|
//#region src/edit/ods/content.d.ts
|
|
4
|
-
|
|
5
|
+
interface BuildOdsPackageOptions {
|
|
6
|
+
readonly clock?: ClockPort;
|
|
7
|
+
}
|
|
8
|
+
declare function buildOdsPackage(content: ContentDocument, options?: BuildOdsPackageOptions): Package;
|
|
5
9
|
//#endregion
|
|
6
|
-
export { buildOdsPackage };
|
|
10
|
+
export { BuildOdsPackageOptions, buildOdsPackage };
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.js";
|
|
1
2
|
import { ContentDocument } from "document-schema.js";
|
|
2
3
|
import { Package } from "odf.js";
|
|
3
4
|
//#region src/edit/ods/content.d.ts
|
|
4
|
-
|
|
5
|
+
interface BuildOdsPackageOptions {
|
|
6
|
+
readonly clock?: ClockPort;
|
|
7
|
+
}
|
|
8
|
+
declare function buildOdsPackage(content: ContentDocument, options?: BuildOdsPackageOptions): Package;
|
|
5
9
|
//#endregion
|
|
6
|
-
export { buildOdsPackage };
|
|
10
|
+
export { BuildOdsPackageOptions, buildOdsPackage };
|
package/dist/edit/ods/content.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveMetadataTimestamps } from "../../model/metadata.js";
|
|
2
|
+
import { systemClock } from "../../ports/clock.js";
|
|
3
|
+
import { createEmptyOdsPackage } from "./scaffold.js";
|
|
4
|
+
import { OdsEditor } from "./editor.js";
|
|
2
5
|
//#region src/edit/ods/content.ts
|
|
3
|
-
function buildOdsPackage(content) {
|
|
6
|
+
function buildOdsPackage(content, options) {
|
|
4
7
|
if (content.kind !== "spreadsheet") throw new Error("buildOdsPackage requires a spreadsheet ContentDocument");
|
|
5
|
-
const
|
|
8
|
+
const clock = options?.clock ?? systemClock;
|
|
9
|
+
const metadata = resolveMetadataTimestamps(content.metadata, clock);
|
|
10
|
+
const editor = new OdsEditor(createEmptyOdsPackage({ metadata }));
|
|
6
11
|
if (content.sheets.length > 0) editor.removeSheetAt(0);
|
|
7
12
|
for (const sheet of content.sheets) {
|
|
8
13
|
const odsSheet = editor.addSheet(sheet.name);
|
package/dist/edit/ods/editor.cjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_metadata = require("../../model/metadata.cjs");
|
|
3
|
+
const require_ports_clock = require("../../ports/clock.cjs");
|
|
2
4
|
const require_xml_fragment = require("../../xml/fragment.cjs");
|
|
3
5
|
const require_edit_odt_automatic_styles = require("../odt/automatic-styles.cjs");
|
|
4
6
|
const require_edit_ods_scaffold = require("./scaffold.cjs");
|
|
@@ -75,8 +77,10 @@ var OdsEditor = class {
|
|
|
75
77
|
function openOds(bytes) {
|
|
76
78
|
return new OdsEditor((0, odf_js.decodePackage)(bytes));
|
|
77
79
|
}
|
|
78
|
-
function createOds() {
|
|
79
|
-
|
|
80
|
+
function createOds(options) {
|
|
81
|
+
const clock = options?.clock ?? require_ports_clock.systemClock;
|
|
82
|
+
const metadata = require_model_metadata.resolveMetadataTimestamps({}, clock);
|
|
83
|
+
return new OdsEditor(require_edit_ods_scaffold.createEmptyOdsPackage({ metadata }));
|
|
80
84
|
}
|
|
81
85
|
//#endregion
|
|
82
86
|
exports.OdsEditor = OdsEditor;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.cjs";
|
|
1
2
|
import { OdsSheet } from "./sheet.cjs";
|
|
2
3
|
import { Package } from "odf.js";
|
|
3
4
|
//#region src/edit/ods/editor.d.ts
|
|
@@ -12,6 +13,9 @@ declare class OdsEditor {
|
|
|
12
13
|
toBytes(): Uint8Array<ArrayBuffer>;
|
|
13
14
|
}
|
|
14
15
|
declare function openOds(bytes: Uint8Array<ArrayBuffer>): OdsEditor;
|
|
15
|
-
|
|
16
|
+
interface CreateOdsOptions {
|
|
17
|
+
readonly clock?: ClockPort;
|
|
18
|
+
}
|
|
19
|
+
declare function createOds(options?: CreateOdsOptions): OdsEditor;
|
|
16
20
|
//#endregion
|
|
17
|
-
export { OdsEditor, createOds, openOds };
|
|
21
|
+
export { CreateOdsOptions, OdsEditor, createOds, openOds };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.js";
|
|
1
2
|
import { OdsSheet } from "./sheet.js";
|
|
2
3
|
import { Package } from "odf.js";
|
|
3
4
|
//#region src/edit/ods/editor.d.ts
|
|
@@ -12,6 +13,9 @@ declare class OdsEditor {
|
|
|
12
13
|
toBytes(): Uint8Array<ArrayBuffer>;
|
|
13
14
|
}
|
|
14
15
|
declare function openOds(bytes: Uint8Array<ArrayBuffer>): OdsEditor;
|
|
15
|
-
|
|
16
|
+
interface CreateOdsOptions {
|
|
17
|
+
readonly clock?: ClockPort;
|
|
18
|
+
}
|
|
19
|
+
declare function createOds(options?: CreateOdsOptions): OdsEditor;
|
|
16
20
|
//#endregion
|
|
17
|
-
export { OdsEditor, createOds, openOds };
|
|
21
|
+
export { CreateOdsOptions, OdsEditor, createOds, openOds };
|
package/dist/edit/ods/editor.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolveMetadataTimestamps } from "../../model/metadata.js";
|
|
2
|
+
import { systemClock } from "../../ports/clock.js";
|
|
1
3
|
import { el } from "../../xml/fragment.js";
|
|
2
4
|
import { ensureAutomaticStyles } from "../odt/automatic-styles.js";
|
|
3
5
|
import { MASTER_PAGE_NAME, SHEET_TABLE_STYLE_NAME, createEmptyOdsPackage } from "./scaffold.js";
|
|
@@ -74,8 +76,10 @@ var OdsEditor = class {
|
|
|
74
76
|
function openOds(bytes) {
|
|
75
77
|
return new OdsEditor(decodePackage$1(bytes));
|
|
76
78
|
}
|
|
77
|
-
function createOds() {
|
|
78
|
-
|
|
79
|
+
function createOds(options) {
|
|
80
|
+
const clock = options?.clock ?? systemClock;
|
|
81
|
+
const metadata = resolveMetadataTimestamps({}, clock);
|
|
82
|
+
return new OdsEditor(createEmptyOdsPackage({ metadata }));
|
|
79
83
|
}
|
|
80
84
|
//#endregion
|
|
81
85
|
export { OdsEditor, createOds, openOds };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_xml_fragment = require("../../xml/fragment.cjs");
|
|
3
|
+
const require_xml_entities = require("../../xml/entities.cjs");
|
|
3
4
|
let odf_js = require("odf.js");
|
|
4
5
|
let document_schema_js = require("document-schema.js");
|
|
5
6
|
//#region src/edit/ods/scaffold.ts
|
|
@@ -96,13 +97,25 @@ function buildContentXml() {
|
|
|
96
97
|
"office:version": ODF_VERSION
|
|
97
98
|
}, [require_xml_fragment.el("office:automatic-styles", {}, [buildSheetTableStyle()]), require_xml_fragment.el("office:body", {}, [require_xml_fragment.el("office:spreadsheet", {}, [buildCalculationSettings(), table])])]);
|
|
98
99
|
}
|
|
99
|
-
function
|
|
100
|
+
function buildOfficeMeta(metadata) {
|
|
101
|
+
if (metadata === void 0) return [];
|
|
102
|
+
const children = [];
|
|
103
|
+
if (metadata.title !== void 0) children.push(require_xml_fragment.el("dc:title", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.title))]));
|
|
104
|
+
if (metadata.author !== void 0) children.push(require_xml_fragment.el("meta:initial-creator", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.author))]));
|
|
105
|
+
if (metadata.subject !== void 0) children.push(require_xml_fragment.el("dc:subject", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.subject))]));
|
|
106
|
+
for (const keyword of metadata.keywords ?? []) children.push(require_xml_fragment.el("meta:keyword", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(keyword))]));
|
|
107
|
+
if (metadata.creator !== void 0) children.push(require_xml_fragment.el("meta:generator", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.creator))]));
|
|
108
|
+
if (metadata.createdIso !== void 0) children.push(require_xml_fragment.el("meta:creation-date", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.createdIso))]));
|
|
109
|
+
if (metadata.modifiedIso !== void 0) children.push(require_xml_fragment.el("dc:date", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.modifiedIso))]));
|
|
110
|
+
return children;
|
|
111
|
+
}
|
|
112
|
+
function buildMetaXml(metadata) {
|
|
100
113
|
return require_xml_fragment.el("office:document-meta", {
|
|
101
114
|
...(0, odf_js.xmlnsAttributes)([...META_NS_PREFIXES]),
|
|
102
115
|
"office:version": ODF_VERSION
|
|
103
|
-
}, [require_xml_fragment.el("office:meta")]);
|
|
116
|
+
}, [require_xml_fragment.el("office:meta", {}, buildOfficeMeta(metadata))]);
|
|
104
117
|
}
|
|
105
|
-
function createEmptyOdsPackage() {
|
|
118
|
+
function createEmptyOdsPackage(options) {
|
|
106
119
|
const pkg = { parts: {
|
|
107
120
|
"content.xml": {
|
|
108
121
|
kind: "xml",
|
|
@@ -114,7 +127,7 @@ function createEmptyOdsPackage() {
|
|
|
114
127
|
},
|
|
115
128
|
"meta.xml": {
|
|
116
129
|
kind: "xml",
|
|
117
|
-
nodes: [declaration(), buildMetaXml()]
|
|
130
|
+
nodes: [declaration(), buildMetaXml(options?.metadata)]
|
|
118
131
|
}
|
|
119
132
|
} };
|
|
120
133
|
(0, odf_js.setDocumentMediaType)(pkg, odf_js.ODF_MEDIA_TYPES.ods);
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { LayoutMetadata } from "document-schema.js";
|
|
1
2
|
import { Package } from "odf.js";
|
|
2
3
|
//#region src/edit/ods/scaffold.d.ts
|
|
3
4
|
declare const PAGE_LAYOUT_NAME = "PM1";
|
|
4
5
|
declare const MASTER_PAGE_NAME = "Standard";
|
|
5
6
|
declare const SHEET_TABLE_STYLE_NAME = "OdsTable";
|
|
6
7
|
declare const DEFAULT_SHEET_NAME = "Sheet1";
|
|
7
|
-
|
|
8
|
+
interface CreateEmptyOdsPackageOptions {
|
|
9
|
+
readonly metadata?: LayoutMetadata;
|
|
10
|
+
}
|
|
11
|
+
declare function createEmptyOdsPackage(options?: CreateEmptyOdsPackageOptions): Package;
|
|
8
12
|
//#endregion
|
|
9
|
-
export { DEFAULT_SHEET_NAME, MASTER_PAGE_NAME, PAGE_LAYOUT_NAME, SHEET_TABLE_STYLE_NAME, createEmptyOdsPackage };
|
|
13
|
+
export { CreateEmptyOdsPackageOptions, DEFAULT_SHEET_NAME, MASTER_PAGE_NAME, PAGE_LAYOUT_NAME, SHEET_TABLE_STYLE_NAME, createEmptyOdsPackage };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { LayoutMetadata } from "document-schema.js";
|
|
1
2
|
import { Package } from "odf.js";
|
|
2
3
|
//#region src/edit/ods/scaffold.d.ts
|
|
3
4
|
declare const PAGE_LAYOUT_NAME = "PM1";
|
|
4
5
|
declare const MASTER_PAGE_NAME = "Standard";
|
|
5
6
|
declare const SHEET_TABLE_STYLE_NAME = "OdsTable";
|
|
6
7
|
declare const DEFAULT_SHEET_NAME = "Sheet1";
|
|
7
|
-
|
|
8
|
+
interface CreateEmptyOdsPackageOptions {
|
|
9
|
+
readonly metadata?: LayoutMetadata;
|
|
10
|
+
}
|
|
11
|
+
declare function createEmptyOdsPackage(options?: CreateEmptyOdsPackageOptions): Package;
|
|
8
12
|
//#endregion
|
|
9
|
-
export { DEFAULT_SHEET_NAME, MASTER_PAGE_NAME, PAGE_LAYOUT_NAME, SHEET_TABLE_STYLE_NAME, createEmptyOdsPackage };
|
|
13
|
+
export { CreateEmptyOdsPackageOptions, DEFAULT_SHEET_NAME, MASTER_PAGE_NAME, PAGE_LAYOUT_NAME, SHEET_TABLE_STYLE_NAME, createEmptyOdsPackage };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PAGE_SIZE_A4 } from "../../model/geometry.js";
|
|
2
|
-
import { el } from "../../xml/fragment.js";
|
|
2
|
+
import { el, txt } from "../../xml/fragment.js";
|
|
3
|
+
import { encodeXmlText } from "../../xml/entities.js";
|
|
3
4
|
import { ODF_MEDIA_TYPES, setDocumentMediaType, syncManifest, xmlnsAttributes } from "odf.js";
|
|
4
5
|
//#region src/edit/ods/scaffold.ts
|
|
5
6
|
const CONTENT_NS_PREFIXES = [
|
|
@@ -95,13 +96,25 @@ function buildContentXml() {
|
|
|
95
96
|
"office:version": ODF_VERSION
|
|
96
97
|
}, [el("office:automatic-styles", {}, [buildSheetTableStyle()]), el("office:body", {}, [el("office:spreadsheet", {}, [buildCalculationSettings(), table])])]);
|
|
97
98
|
}
|
|
98
|
-
function
|
|
99
|
+
function buildOfficeMeta(metadata) {
|
|
100
|
+
if (metadata === void 0) return [];
|
|
101
|
+
const children = [];
|
|
102
|
+
if (metadata.title !== void 0) children.push(el("dc:title", {}, [txt(encodeXmlText(metadata.title))]));
|
|
103
|
+
if (metadata.author !== void 0) children.push(el("meta:initial-creator", {}, [txt(encodeXmlText(metadata.author))]));
|
|
104
|
+
if (metadata.subject !== void 0) children.push(el("dc:subject", {}, [txt(encodeXmlText(metadata.subject))]));
|
|
105
|
+
for (const keyword of metadata.keywords ?? []) children.push(el("meta:keyword", {}, [txt(encodeXmlText(keyword))]));
|
|
106
|
+
if (metadata.creator !== void 0) children.push(el("meta:generator", {}, [txt(encodeXmlText(metadata.creator))]));
|
|
107
|
+
if (metadata.createdIso !== void 0) children.push(el("meta:creation-date", {}, [txt(encodeXmlText(metadata.createdIso))]));
|
|
108
|
+
if (metadata.modifiedIso !== void 0) children.push(el("dc:date", {}, [txt(encodeXmlText(metadata.modifiedIso))]));
|
|
109
|
+
return children;
|
|
110
|
+
}
|
|
111
|
+
function buildMetaXml(metadata) {
|
|
99
112
|
return el("office:document-meta", {
|
|
100
113
|
...xmlnsAttributes([...META_NS_PREFIXES]),
|
|
101
114
|
"office:version": ODF_VERSION
|
|
102
|
-
}, [el("office:meta")]);
|
|
115
|
+
}, [el("office:meta", {}, buildOfficeMeta(metadata))]);
|
|
103
116
|
}
|
|
104
|
-
function createEmptyOdsPackage() {
|
|
117
|
+
function createEmptyOdsPackage(options) {
|
|
105
118
|
const pkg = { parts: {
|
|
106
119
|
"content.xml": {
|
|
107
120
|
kind: "xml",
|
|
@@ -113,7 +126,7 @@ function createEmptyOdsPackage() {
|
|
|
113
126
|
},
|
|
114
127
|
"meta.xml": {
|
|
115
128
|
kind: "xml",
|
|
116
|
-
nodes: [declaration(), buildMetaXml()]
|
|
129
|
+
nodes: [declaration(), buildMetaXml(options?.metadata)]
|
|
117
130
|
}
|
|
118
131
|
} };
|
|
119
132
|
setDocumentMediaType(pkg, ODF_MEDIA_TYPES.ods);
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_metadata = require("../../model/metadata.cjs");
|
|
3
|
+
const require_ports_clock = require("../../ports/clock.cjs");
|
|
2
4
|
const require_model_embedded_drawing = require("../../model/embedded-drawing.cjs");
|
|
3
5
|
const require_model_formula = require("../../model/formula.cjs");
|
|
6
|
+
const require_edit_odt_scaffold = require("./scaffold.cjs");
|
|
4
7
|
const require_edit_odt_editor = require("./editor.cjs");
|
|
5
8
|
//#region src/edit/odt/content.ts
|
|
6
|
-
function buildOdtPackage(content) {
|
|
9
|
+
function buildOdtPackage(content, options) {
|
|
7
10
|
if (content.kind !== "wordprocessing") throw new Error("buildOdtPackage requires a wordprocessing ContentDocument");
|
|
8
|
-
const
|
|
11
|
+
const clock = options?.clock ?? require_ports_clock.systemClock;
|
|
12
|
+
const metadata = require_model_metadata.resolveMetadataTimestamps(content.metadata, clock);
|
|
13
|
+
const editor = new require_edit_odt_editor.OdtEditor(require_edit_odt_scaffold.createEmptyOdtPackage({ metadata }));
|
|
9
14
|
content.sections.forEach((section, sectionIndex) => {
|
|
10
15
|
if (sectionIndex > 0) editor.body.appendPageBreak();
|
|
11
16
|
appendBlocks(editor.body, section.blocks);
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.cjs";
|
|
1
2
|
import { t as OdtParagraph } from "../../paragraph-BXbXKPy3.cjs";
|
|
2
3
|
import { t as OdtTable } from "../../table-DjYcNOFm.cjs";
|
|
3
4
|
import { ContentDocument, ContentParagraph, ContentTable } from "document-schema.js";
|
|
4
5
|
import { Package } from "odf.js";
|
|
5
6
|
//#region src/edit/odt/content.d.ts
|
|
6
|
-
|
|
7
|
+
interface BuildOdtPackageOptions {
|
|
8
|
+
readonly clock?: ClockPort;
|
|
9
|
+
}
|
|
10
|
+
declare function buildOdtPackage(content: ContentDocument, options?: BuildOdtPackageOptions): Package;
|
|
7
11
|
declare function populateParagraph(paragraph: OdtParagraph, block: ContentParagraph): void;
|
|
8
12
|
declare function populateOdtTable(table: OdtTable, block: ContentTable): void;
|
|
9
13
|
//#endregion
|
|
10
|
-
export { buildOdtPackage, populateOdtTable, populateParagraph };
|
|
14
|
+
export { BuildOdtPackageOptions, buildOdtPackage, populateOdtTable, populateParagraph };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.js";
|
|
1
2
|
import { t as OdtParagraph } from "../../paragraph-CjtZP77X.js";
|
|
2
3
|
import { t as OdtTable } from "../../table-Vf6nCixr.js";
|
|
3
4
|
import { ContentDocument, ContentParagraph, ContentTable } from "document-schema.js";
|
|
4
5
|
import { Package } from "odf.js";
|
|
5
6
|
//#region src/edit/odt/content.d.ts
|
|
6
|
-
|
|
7
|
+
interface BuildOdtPackageOptions {
|
|
8
|
+
readonly clock?: ClockPort;
|
|
9
|
+
}
|
|
10
|
+
declare function buildOdtPackage(content: ContentDocument, options?: BuildOdtPackageOptions): Package;
|
|
7
11
|
declare function populateParagraph(paragraph: OdtParagraph, block: ContentParagraph): void;
|
|
8
12
|
declare function populateOdtTable(table: OdtTable, block: ContentTable): void;
|
|
9
13
|
//#endregion
|
|
10
|
-
export { buildOdtPackage, populateOdtTable, populateParagraph };
|
|
14
|
+
export { BuildOdtPackageOptions, buildOdtPackage, populateOdtTable, populateParagraph };
|
package/dist/edit/odt/content.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { resolveMetadataTimestamps } from "../../model/metadata.js";
|
|
2
|
+
import { systemClock } from "../../ports/clock.js";
|
|
1
3
|
import { FLOW_CONTAINER_ORIGIN, drawingOfBlock, embeddedDrawingVectors } from "../../model/embedded-drawing.js";
|
|
2
4
|
import { formulaOfBlock, formulaPlaceholderText } from "../../model/formula.js";
|
|
3
|
-
import {
|
|
5
|
+
import { createEmptyOdtPackage } from "./scaffold.js";
|
|
6
|
+
import { OdtEditor } from "./editor.js";
|
|
4
7
|
//#region src/edit/odt/content.ts
|
|
5
|
-
function buildOdtPackage(content) {
|
|
8
|
+
function buildOdtPackage(content, options) {
|
|
6
9
|
if (content.kind !== "wordprocessing") throw new Error("buildOdtPackage requires a wordprocessing ContentDocument");
|
|
7
|
-
const
|
|
10
|
+
const clock = options?.clock ?? systemClock;
|
|
11
|
+
const metadata = resolveMetadataTimestamps(content.metadata, clock);
|
|
12
|
+
const editor = new OdtEditor(createEmptyOdtPackage({ metadata }));
|
|
8
13
|
content.sections.forEach((section, sectionIndex) => {
|
|
9
14
|
if (sectionIndex > 0) editor.body.appendPageBreak();
|
|
10
15
|
appendBlocks(editor.body, section.blocks);
|
package/dist/edit/odt/editor.cjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_metadata = require("../../model/metadata.cjs");
|
|
3
|
+
const require_ports_clock = require("../../ports/clock.cjs");
|
|
2
4
|
const require_edit_odt_automatic_styles = require("./automatic-styles.cjs");
|
|
3
5
|
const require_edit_odg_vector = require("../odg/vector.cjs");
|
|
4
6
|
const require_edit_odt_formula = require("./formula.cjs");
|
|
@@ -103,8 +105,10 @@ var OdtEditor = class {
|
|
|
103
105
|
function openOdt(bytes) {
|
|
104
106
|
return new OdtEditor((0, odf_js.decodePackage)(bytes));
|
|
105
107
|
}
|
|
106
|
-
function createOdt() {
|
|
107
|
-
|
|
108
|
+
function createOdt(options) {
|
|
109
|
+
const clock = options?.clock ?? require_ports_clock.systemClock;
|
|
110
|
+
const metadata = require_model_metadata.resolveMetadataTimestamps({}, clock);
|
|
111
|
+
return new OdtEditor(require_edit_odt_scaffold.createEmptyOdtPackage({ metadata }));
|
|
108
112
|
}
|
|
109
113
|
//#endregion
|
|
110
114
|
exports.OdtEditor = OdtEditor;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.cjs";
|
|
1
2
|
import { t as Box$1 } from "../../geometry-DaJr8yQW.cjs";
|
|
2
3
|
import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-BXbXKPy3.cjs";
|
|
3
4
|
import { t as OdtList } from "../../list-BzcN-LTJ.cjs";
|
|
@@ -24,6 +25,9 @@ declare class OdtEditor {
|
|
|
24
25
|
toBytes(): Uint8Array<ArrayBuffer>;
|
|
25
26
|
}
|
|
26
27
|
declare function openOdt(bytes: Uint8Array<ArrayBuffer>): OdtEditor;
|
|
27
|
-
|
|
28
|
+
interface CreateOdtOptions {
|
|
29
|
+
readonly clock?: ClockPort;
|
|
30
|
+
}
|
|
31
|
+
declare function createOdt(options?: CreateOdtOptions): OdtEditor;
|
|
28
32
|
//#endregion
|
|
29
|
-
export { OdtBody, OdtEditor, createOdt, openOdt };
|
|
33
|
+
export { CreateOdtOptions, OdtBody, OdtEditor, createOdt, openOdt };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.js";
|
|
1
2
|
import { t as Box$1 } from "../../geometry-DaJr8yQW.js";
|
|
2
3
|
import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-CjtZP77X.js";
|
|
3
4
|
import { t as OdtList } from "../../list-BJVehfU8.js";
|
|
@@ -24,6 +25,9 @@ declare class OdtEditor {
|
|
|
24
25
|
toBytes(): Uint8Array<ArrayBuffer>;
|
|
25
26
|
}
|
|
26
27
|
declare function openOdt(bytes: Uint8Array<ArrayBuffer>): OdtEditor;
|
|
27
|
-
|
|
28
|
+
interface CreateOdtOptions {
|
|
29
|
+
readonly clock?: ClockPort;
|
|
30
|
+
}
|
|
31
|
+
declare function createOdt(options?: CreateOdtOptions): OdtEditor;
|
|
28
32
|
//#endregion
|
|
29
|
-
export { OdtBody, OdtEditor, createOdt, openOdt };
|
|
33
|
+
export { CreateOdtOptions, OdtBody, OdtEditor, createOdt, openOdt };
|
package/dist/edit/odt/editor.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolveMetadataTimestamps } from "../../model/metadata.js";
|
|
2
|
+
import { systemClock } from "../../ports/clock.js";
|
|
1
3
|
import { ensurePageBreakStyleName } from "./automatic-styles.js";
|
|
2
4
|
import { buildVectorElement } from "../odg/vector.js";
|
|
3
5
|
import { insertFormulaFrameMedia } from "./formula.js";
|
|
@@ -102,8 +104,10 @@ var OdtEditor = class {
|
|
|
102
104
|
function openOdt(bytes) {
|
|
103
105
|
return new OdtEditor(decodePackage(bytes));
|
|
104
106
|
}
|
|
105
|
-
function createOdt() {
|
|
106
|
-
|
|
107
|
+
function createOdt(options) {
|
|
108
|
+
const clock = options?.clock ?? systemClock;
|
|
109
|
+
const metadata = resolveMetadataTimestamps({}, clock);
|
|
110
|
+
return new OdtEditor(createEmptyOdtPackage({ metadata }));
|
|
107
111
|
}
|
|
108
112
|
//#endregion
|
|
109
113
|
export { OdtEditor, createOdt, openOdt };
|