documents.js 1.67.16 → 1.70.0
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/color-BHhGSqAh.d.ts +2 -0
- 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/paragraph.d.ts +1 -1
- package/dist/edit/docx/props.d.ts +1 -1
- package/dist/edit/docx/run.d.ts +1 -1
- 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/drawingml/vector.cjs +145 -0
- package/dist/edit/drawingml/vector.d.cts +3 -2
- package/dist/edit/drawingml/vector.d.ts +3 -2
- package/dist/edit/drawingml/vector.js +147 -3
- 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/page.d.ts +1 -1
- 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/odp/shape.d.ts +1 -1
- package/dist/edit/odp/slide.d.ts +2 -2
- 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 +8 -4
- 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 +9 -5
- package/dist/edit/odt/editor.js +6 -2
- package/dist/edit/odt/list.d.ts +1 -1
- package/dist/edit/odt/paragraph.d.ts +1 -1
- package/dist/edit/odt/run.d.ts +1 -1
- 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/odt/table.d.ts +1 -1
- 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/edit/pptx/shape.d.ts +1 -1
- package/dist/edit/pptx/slide.d.ts +2 -2
- package/dist/edit/pptx/table.d.ts +1 -1
- package/dist/formula-B_4mdCuK.d.ts +12 -0
- package/dist/formula-DFc2Ofsk.d.cts +12 -0
- package/dist/index.cjs +3 -1
- package/dist/index.d.cts +20 -13
- package/dist/index.d.ts +29 -22
- package/dist/index.js +3 -2
- package/dist/layout/sheets.js +3 -3
- package/dist/{list-nlhN5bat.d.ts → list-BJVehfU8.d.ts} +1 -1
- 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/block-splice.cjs +18 -0
- package/dist/model/block-splice.d.cts +9 -0
- package/dist/model/block-splice.d.ts +9 -0
- package/dist/model/block-splice.js +17 -0
- package/dist/model/color.d.ts +1 -1
- 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/odf/odp/read.cjs +38 -0
- package/dist/odf/odp/read.js +38 -0
- package/dist/odf/odt/read.cjs +100 -35
- package/dist/odf/odt/read.js +100 -35
- package/dist/odf/vector/detect.cjs +52 -0
- package/dist/odf/vector/detect.d.cts +12 -0
- package/dist/odf/vector/detect.d.ts +12 -0
- package/dist/odf/vector/detect.js +49 -0
- package/dist/ooxml/docx/embedded-objects.cjs +92 -0
- package/dist/ooxml/docx/embedded-objects.d.cts +7 -0
- package/dist/ooxml/docx/embedded-objects.d.ts +7 -0
- package/dist/ooxml/docx/embedded-objects.js +91 -0
- package/dist/ooxml/docx/formula.cjs +3 -58
- package/dist/ooxml/docx/formula.d.cts +2 -2
- package/dist/ooxml/docx/formula.d.ts +2 -2
- package/dist/ooxml/docx/formula.js +1 -58
- package/dist/ooxml/docx/read.cjs +2 -2
- package/dist/ooxml/docx/read.d.cts +1 -1
- package/dist/ooxml/docx/read.d.ts +1 -1
- package/dist/ooxml/docx/read.js +2 -2
- package/dist/ooxml/docx/vector.cjs +63 -0
- package/dist/ooxml/docx/vector.d.cts +10 -0
- package/dist/ooxml/docx/vector.d.ts +10 -0
- package/dist/ooxml/docx/vector.js +62 -0
- package/dist/ooxml/pptx/read.cjs +25 -1
- package/dist/ooxml/pptx/read.js +26 -2
- package/dist/ooxml/pptx/vector.cjs +96 -0
- package/dist/ooxml/pptx/vector.d.cts +6 -0
- package/dist/ooxml/pptx/vector.d.ts +6 -0
- package/dist/ooxml/pptx/vector.js +95 -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/dist/{paragraph-DndYbWuT.d.ts → paragraph-CjtZP77X.d.ts} +1 -1
- package/dist/{run-BhYv2wJf.d.ts → run-DDe7miD5.d.ts} +1 -1
- package/dist/{run-DtrwZwN6.d.ts → run-wB22_F5w.d.ts} +1 -1
- package/dist/{shape-B-TjU_Ej.d.ts → shape-BjX3wlig.d.ts} +1 -1
- package/dist/{shape-XGp__l-J.d.ts → shape-GV8i37zL.d.ts} +2 -2
- package/dist/{table-DQpKafyl.d.ts → table-Db91eorq.d.ts} +1 -1
- package/dist/{table-BHeUmLzZ.d.ts → table-Vf6nCixr.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/color-C98dn-pT.d.ts +0 -2
- package/dist/formula-CgydMiTt.d.ts +0 -10
- package/dist/formula-CiwPw8nY.d.cts +0 -10
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { el } from "../../xml/fragment.js";
|
|
2
|
-
import { ptToEmu } from "../../model/units.js";
|
|
3
|
-
import {
|
|
2
|
+
import { emuToPt, ptToEmu } from "../../model/units.js";
|
|
3
|
+
import { attr, childrenWithTag } from "ooxml.js";
|
|
4
|
+
import { colorToRgbHex, rgbHexToColor } from "document-schema.js";
|
|
4
5
|
//#region src/edit/drawingml/vector.ts
|
|
5
6
|
function drawingMlColorHex(color) {
|
|
6
7
|
return colorToRgbHex(color).toUpperCase();
|
|
@@ -105,5 +106,148 @@ function vectorPlacementBox(vector) {
|
|
|
105
106
|
function vectorShapeName(vector, id) {
|
|
106
107
|
return `${vector.kind.charAt(0).toUpperCase()}${vector.kind.slice(1)} ${id}`;
|
|
107
108
|
}
|
|
109
|
+
function requireChild(parent, tag) {
|
|
110
|
+
const [child] = childrenWithTag(parent, tag);
|
|
111
|
+
if (child === void 0) throw new Error(`expected a ${tag} child of ${parent.tag}`);
|
|
112
|
+
return child;
|
|
113
|
+
}
|
|
114
|
+
function requireAttrNumber(element, name) {
|
|
115
|
+
const value = attr(element, name);
|
|
116
|
+
if (value === void 0) throw new Error(`expected a ${name} attribute on ${element.tag}`);
|
|
117
|
+
const parsed = Number.parseInt(value, 10);
|
|
118
|
+
if (Number.isNaN(parsed)) throw new Error(`${element.tag}/@${name} is not an integer: ${value}`);
|
|
119
|
+
return parsed;
|
|
120
|
+
}
|
|
121
|
+
function readSrgbColor(parent) {
|
|
122
|
+
const value = attr(requireChild(parent, "a:srgbClr"), "val");
|
|
123
|
+
if (value === void 0) throw new Error("expected a val attribute on a:srgbClr");
|
|
124
|
+
return rgbHexToColor(value);
|
|
125
|
+
}
|
|
126
|
+
function readFill(parent) {
|
|
127
|
+
if (childrenWithTag(parent, "a:noFill").length > 0) return;
|
|
128
|
+
return readSrgbColor(requireChild(parent, "a:solidFill"));
|
|
129
|
+
}
|
|
130
|
+
function readOutline(spPr) {
|
|
131
|
+
const ln = requireChild(spPr, "a:ln");
|
|
132
|
+
const color = readFill(ln);
|
|
133
|
+
if (color === void 0) return;
|
|
134
|
+
return {
|
|
135
|
+
color,
|
|
136
|
+
widthPt: emuToPt(requireAttrNumber(ln, "w"))
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function readPlacement(spPr) {
|
|
140
|
+
const xfrm = requireChild(spPr, "a:xfrm");
|
|
141
|
+
const off = requireChild(xfrm, "a:off");
|
|
142
|
+
const ext = requireChild(xfrm, "a:ext");
|
|
143
|
+
const rot = attr(xfrm, "rot");
|
|
144
|
+
return {
|
|
145
|
+
frame: {
|
|
146
|
+
xPt: emuToPt(requireAttrNumber(off, "x")),
|
|
147
|
+
yPt: emuToPt(requireAttrNumber(off, "y")),
|
|
148
|
+
widthPt: emuToPt(requireAttrNumber(ext, "cx")),
|
|
149
|
+
heightPt: emuToPt(requireAttrNumber(ext, "cy"))
|
|
150
|
+
},
|
|
151
|
+
rotationDeg: rot === void 0 ? void 0 : Number.parseInt(rot, 10) / ROTATION_UNITS_PER_DEGREE,
|
|
152
|
+
flipH: attr(xfrm, "flipH") === "1",
|
|
153
|
+
flipV: attr(xfrm, "flipV") === "1"
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function readPoint(container, index) {
|
|
157
|
+
const point = childrenWithTag(container, "a:pt")[index];
|
|
158
|
+
if (point === void 0) throw new Error(`expected an a:pt at index ${index} of ${container.tag}`);
|
|
159
|
+
return {
|
|
160
|
+
xPt: emuToPt(requireAttrNumber(point, "x")),
|
|
161
|
+
yPt: emuToPt(requireAttrNumber(point, "y"))
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function readSubpaths(custGeom) {
|
|
165
|
+
return childrenWithTag(requireChild(custGeom, "a:pathLst"), "a:path").map((path) => {
|
|
166
|
+
const segments = [];
|
|
167
|
+
let start;
|
|
168
|
+
let closed = false;
|
|
169
|
+
for (const command of path.children) {
|
|
170
|
+
if (command.type !== "element") continue;
|
|
171
|
+
switch (command.tag) {
|
|
172
|
+
case "a:moveTo":
|
|
173
|
+
start = readPoint(command, 0);
|
|
174
|
+
break;
|
|
175
|
+
case "a:lnTo":
|
|
176
|
+
segments.push({
|
|
177
|
+
kind: "line",
|
|
178
|
+
to: readPoint(command, 0)
|
|
179
|
+
});
|
|
180
|
+
break;
|
|
181
|
+
case "a:cubicBezTo":
|
|
182
|
+
segments.push({
|
|
183
|
+
kind: "cubic",
|
|
184
|
+
control1: readPoint(command, 0),
|
|
185
|
+
control2: readPoint(command, 1),
|
|
186
|
+
to: readPoint(command, 2)
|
|
187
|
+
});
|
|
188
|
+
break;
|
|
189
|
+
case "a:close":
|
|
190
|
+
closed = true;
|
|
191
|
+
break;
|
|
192
|
+
default: throw new Error(`unrecognised a:path command: ${command.tag}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (start === void 0) throw new Error("an a:path carried no a:moveTo");
|
|
196
|
+
return {
|
|
197
|
+
start,
|
|
198
|
+
segments,
|
|
199
|
+
closed
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function readDrawingMlVectorOrThrow(spPr, frameOverride) {
|
|
204
|
+
const rawPlacement = readPlacement(spPr);
|
|
205
|
+
const placement = frameOverride === void 0 ? rawPlacement : {
|
|
206
|
+
...rawPlacement,
|
|
207
|
+
frame: frameOverride
|
|
208
|
+
};
|
|
209
|
+
const stroke = readOutline(spPr);
|
|
210
|
+
const [custGeom] = childrenWithTag(spPr, "a:custGeom");
|
|
211
|
+
if (custGeom !== void 0) return {
|
|
212
|
+
kind: "path",
|
|
213
|
+
frame: placement.frame,
|
|
214
|
+
rotationDeg: placement.rotationDeg,
|
|
215
|
+
subpaths: readSubpaths(custGeom),
|
|
216
|
+
fill: readFill(spPr),
|
|
217
|
+
stroke
|
|
218
|
+
};
|
|
219
|
+
const preset = attr(requireChild(spPr, "a:prstGeom"), "prst");
|
|
220
|
+
if (preset === "line") {
|
|
221
|
+
if (stroke === void 0) throw new Error("a line preset with no outline: ContentVector's own line variant requires a stroke");
|
|
222
|
+
const { xPt, yPt, widthPt, heightPt } = placement.frame;
|
|
223
|
+
return {
|
|
224
|
+
kind: "line",
|
|
225
|
+
from: {
|
|
226
|
+
xPt: placement.flipH ? xPt + widthPt : xPt,
|
|
227
|
+
yPt: placement.flipV ? yPt + heightPt : yPt
|
|
228
|
+
},
|
|
229
|
+
to: {
|
|
230
|
+
xPt: placement.flipH ? xPt : xPt + widthPt,
|
|
231
|
+
yPt: placement.flipV ? yPt : yPt + heightPt
|
|
232
|
+
},
|
|
233
|
+
stroke
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
if (preset === "rect" || preset === "ellipse") return {
|
|
237
|
+
kind: preset,
|
|
238
|
+
frame: placement.frame,
|
|
239
|
+
rotationDeg: placement.rotationDeg,
|
|
240
|
+
fill: readFill(spPr),
|
|
241
|
+
stroke
|
|
242
|
+
};
|
|
243
|
+
throw new Error(`unrecognised a:prstGeom preset: ${String(preset)}`);
|
|
244
|
+
}
|
|
245
|
+
function readDrawingMlVector(spPr, frameOverride) {
|
|
246
|
+
try {
|
|
247
|
+
return readDrawingMlVectorOrThrow(spPr, frameOverride);
|
|
248
|
+
} catch {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
108
252
|
//#endregion
|
|
109
|
-
export { buildVectorShapeProperties, drawingMlColorHex, vectorPlacementBox, vectorShapeName };
|
|
253
|
+
export { buildVectorShapeProperties, drawingMlColorHex, readDrawingMlVector, vectorPlacementBox, vectorShapeName };
|
|
@@ -1,12 +1,17 @@
|
|
|
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_content = require("../odt/content.cjs");
|
|
5
|
+
const require_edit_odg_scaffold = require("./scaffold.cjs");
|
|
3
6
|
const require_edit_odg_editor = require("./editor.cjs");
|
|
4
7
|
const require_model_paint_order = require("../../model/paint-order.cjs");
|
|
5
8
|
let odf_js = require("odf.js");
|
|
6
9
|
//#region src/edit/odg/content.ts
|
|
7
|
-
function buildOdgPackage(content) {
|
|
10
|
+
function buildOdgPackage(content, options) {
|
|
8
11
|
if (content.kind !== "drawing") throw new Error("buildOdgPackage requires a drawing ContentDocument");
|
|
9
|
-
const
|
|
12
|
+
const clock = options?.clock ?? require_ports_clock.systemClock;
|
|
13
|
+
const metadata = require_model_metadata.resolveMetadataTimestamps(content.metadata, clock);
|
|
14
|
+
const editor = new require_edit_odg_editor.OdgEditor(require_edit_odg_scaffold.createEmptyOdgPackage({ metadata }));
|
|
10
15
|
const firstPage = content.pages[0];
|
|
11
16
|
if (firstPage !== void 0) editor.pageSize = firstPage.size;
|
|
12
17
|
for (const page of content.pages) {
|
|
@@ -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/odg/content.d.ts
|
|
4
|
-
|
|
5
|
+
interface BuildOdgPackageOptions {
|
|
6
|
+
readonly clock?: ClockPort;
|
|
7
|
+
}
|
|
8
|
+
declare function buildOdgPackage(content: ContentDocument, options?: BuildOdgPackageOptions): Package;
|
|
5
9
|
//#endregion
|
|
6
|
-
export { buildOdgPackage };
|
|
10
|
+
export { BuildOdgPackageOptions, buildOdgPackage };
|
|
@@ -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/odg/content.d.ts
|
|
4
|
-
|
|
5
|
+
interface BuildOdgPackageOptions {
|
|
6
|
+
readonly clock?: ClockPort;
|
|
7
|
+
}
|
|
8
|
+
declare function buildOdgPackage(content: ContentDocument, options?: BuildOdgPackageOptions): Package;
|
|
5
9
|
//#endregion
|
|
6
|
-
export { buildOdgPackage };
|
|
10
|
+
export { BuildOdgPackageOptions, buildOdgPackage };
|
package/dist/edit/odg/content.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import { resolveMetadataTimestamps } from "../../model/metadata.js";
|
|
2
|
+
import { systemClock } from "../../ports/clock.js";
|
|
1
3
|
import { populateParagraph } from "../odt/content.js";
|
|
2
|
-
import {
|
|
4
|
+
import { createEmptyOdgPackage } from "./scaffold.js";
|
|
5
|
+
import { OdgEditor } from "./editor.js";
|
|
3
6
|
import { mergeByPaintOrder } from "../../model/paint-order.js";
|
|
4
7
|
import { base64ToBytes } from "odf.js";
|
|
5
8
|
//#region src/edit/odg/content.ts
|
|
6
|
-
function buildOdgPackage(content) {
|
|
9
|
+
function buildOdgPackage(content, options) {
|
|
7
10
|
if (content.kind !== "drawing") throw new Error("buildOdgPackage requires a drawing ContentDocument");
|
|
8
|
-
const
|
|
11
|
+
const clock = options?.clock ?? systemClock;
|
|
12
|
+
const metadata = resolveMetadataTimestamps(content.metadata, clock);
|
|
13
|
+
const editor = new OdgEditor(createEmptyOdgPackage({ metadata }));
|
|
9
14
|
const firstPage = content.pages[0];
|
|
10
15
|
if (firstPage !== void 0) editor.pageSize = firstPage.size;
|
|
11
16
|
for (const page of content.pages) {
|
package/dist/edit/odg/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_odg_scaffold = require("./scaffold.cjs");
|
|
4
6
|
const require_edit_odg_page = require("./page.cjs");
|
|
@@ -87,8 +89,10 @@ var OdgEditor = class {
|
|
|
87
89
|
function openOdg(bytes) {
|
|
88
90
|
return new OdgEditor((0, odf_js.decodePackage)(bytes));
|
|
89
91
|
}
|
|
90
|
-
function createOdg() {
|
|
91
|
-
|
|
92
|
+
function createOdg(options) {
|
|
93
|
+
const clock = options?.clock ?? require_ports_clock.systemClock;
|
|
94
|
+
const metadata = require_model_metadata.resolveMetadataTimestamps({}, clock);
|
|
95
|
+
return new OdgEditor(require_edit_odg_scaffold.createEmptyOdgPackage({ metadata }));
|
|
92
96
|
}
|
|
93
97
|
//#endregion
|
|
94
98
|
exports.OdgEditor = OdgEditor;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.cjs";
|
|
1
2
|
import { s as PageSize } from "../../geometry-DaJr8yQW.cjs";
|
|
2
3
|
import { OdgPage } from "./page.cjs";
|
|
3
4
|
import { Package } from "odf.js";
|
|
@@ -14,6 +15,9 @@ declare class OdgEditor {
|
|
|
14
15
|
toBytes(): Uint8Array<ArrayBuffer>;
|
|
15
16
|
}
|
|
16
17
|
declare function openOdg(bytes: Uint8Array<ArrayBuffer>): OdgEditor;
|
|
17
|
-
|
|
18
|
+
interface CreateOdgOptions {
|
|
19
|
+
readonly clock?: ClockPort;
|
|
20
|
+
}
|
|
21
|
+
declare function createOdg(options?: CreateOdgOptions): OdgEditor;
|
|
18
22
|
//#endregion
|
|
19
|
-
export { OdgEditor, createOdg, openOdg };
|
|
23
|
+
export { CreateOdgOptions, OdgEditor, createOdg, openOdg };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.js";
|
|
1
2
|
import { s as PageSize } from "../../geometry-DaJr8yQW.js";
|
|
2
3
|
import { OdgPage } from "./page.js";
|
|
3
4
|
import { Package } from "odf.js";
|
|
@@ -14,6 +15,9 @@ declare class OdgEditor {
|
|
|
14
15
|
toBytes(): Uint8Array<ArrayBuffer>;
|
|
15
16
|
}
|
|
16
17
|
declare function openOdg(bytes: Uint8Array<ArrayBuffer>): OdgEditor;
|
|
17
|
-
|
|
18
|
+
interface CreateOdgOptions {
|
|
19
|
+
readonly clock?: ClockPort;
|
|
20
|
+
}
|
|
21
|
+
declare function createOdg(options?: CreateOdgOptions): OdgEditor;
|
|
18
22
|
//#endregion
|
|
19
|
-
export { OdgEditor, createOdg, openOdg };
|
|
23
|
+
export { CreateOdgOptions, OdgEditor, createOdg, openOdg };
|
package/dist/edit/odg/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, createEmptyOdgPackage } from "./scaffold.js";
|
|
3
5
|
import { OdgPage } from "./page.js";
|
|
@@ -86,8 +88,10 @@ var OdgEditor = class {
|
|
|
86
88
|
function openOdg(bytes) {
|
|
87
89
|
return new OdgEditor(decodePackage$1(bytes));
|
|
88
90
|
}
|
|
89
|
-
function createOdg() {
|
|
90
|
-
|
|
91
|
+
function createOdg(options) {
|
|
92
|
+
const clock = options?.clock ?? systemClock;
|
|
93
|
+
const metadata = resolveMetadataTimestamps({}, clock);
|
|
94
|
+
return new OdgEditor(createEmptyOdgPackage({ metadata }));
|
|
91
95
|
}
|
|
92
96
|
//#endregion
|
|
93
97
|
export { OdgEditor, createOdg, openOdg };
|
package/dist/edit/odg/page.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as ImageInit } from "../../image-DHcA9kaK.js";
|
|
2
|
-
import { t as OdpShape } from "../../shape-
|
|
2
|
+
import { t as OdpShape } from "../../shape-GV8i37zL.js";
|
|
3
3
|
import { a as OdgLineVector, l as PathVectorInit, n as LineVectorInit, o as OdgPathVector, r as OdgBoxVector, s as OdgVector, t as BoxVectorInit } from "../../vector-D03KX8Ux.js";
|
|
4
4
|
import { Box, ContentVector } from "document-schema.js";
|
|
5
5
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
@@ -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/odg/scaffold.ts
|
|
@@ -75,13 +76,25 @@ function buildContentXml() {
|
|
|
75
76
|
"office:version": ODF_VERSION
|
|
76
77
|
}, [require_xml_fragment.el("office:automatic-styles"), require_xml_fragment.el("office:body", {}, [require_xml_fragment.el("office:drawing")])]);
|
|
77
78
|
}
|
|
78
|
-
function
|
|
79
|
+
function buildOfficeMeta(metadata) {
|
|
80
|
+
if (metadata === void 0) return [];
|
|
81
|
+
const children = [];
|
|
82
|
+
if (metadata.title !== void 0) children.push(require_xml_fragment.el("dc:title", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.title))]));
|
|
83
|
+
if (metadata.author !== void 0) children.push(require_xml_fragment.el("meta:initial-creator", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.author))]));
|
|
84
|
+
if (metadata.subject !== void 0) children.push(require_xml_fragment.el("dc:subject", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.subject))]));
|
|
85
|
+
for (const keyword of metadata.keywords ?? []) children.push(require_xml_fragment.el("meta:keyword", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(keyword))]));
|
|
86
|
+
if (metadata.creator !== void 0) children.push(require_xml_fragment.el("meta:generator", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.creator))]));
|
|
87
|
+
if (metadata.createdIso !== void 0) children.push(require_xml_fragment.el("meta:creation-date", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.createdIso))]));
|
|
88
|
+
if (metadata.modifiedIso !== void 0) children.push(require_xml_fragment.el("dc:date", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(metadata.modifiedIso))]));
|
|
89
|
+
return children;
|
|
90
|
+
}
|
|
91
|
+
function buildMetaXml(metadata) {
|
|
79
92
|
return require_xml_fragment.el("office:document-meta", {
|
|
80
93
|
...(0, odf_js.xmlnsAttributes)([...META_NS_PREFIXES]),
|
|
81
94
|
"office:version": ODF_VERSION
|
|
82
|
-
}, [require_xml_fragment.el("office:meta")]);
|
|
95
|
+
}, [require_xml_fragment.el("office:meta", {}, buildOfficeMeta(metadata))]);
|
|
83
96
|
}
|
|
84
|
-
function createEmptyOdgPackage() {
|
|
97
|
+
function createEmptyOdgPackage(options) {
|
|
85
98
|
const pkg = { parts: {
|
|
86
99
|
"content.xml": {
|
|
87
100
|
kind: "xml",
|
|
@@ -93,7 +106,7 @@ function createEmptyOdgPackage() {
|
|
|
93
106
|
},
|
|
94
107
|
"meta.xml": {
|
|
95
108
|
kind: "xml",
|
|
96
|
-
nodes: [declaration(), buildMetaXml()]
|
|
109
|
+
nodes: [declaration(), buildMetaXml(options?.metadata)]
|
|
97
110
|
}
|
|
98
111
|
} };
|
|
99
112
|
(0, odf_js.setDocumentMediaType)(pkg, odf_js.ODF_MEDIA_TYPES.odg);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { LayoutMetadata } from "document-schema.js";
|
|
1
2
|
import { Package } from "odf.js";
|
|
2
3
|
//#region src/edit/odg/scaffold.d.ts
|
|
3
4
|
declare const PAGE_LAYOUT_NAME = "PM1";
|
|
4
5
|
declare const MASTER_PAGE_NAME = "Standard";
|
|
5
|
-
|
|
6
|
+
interface CreateEmptyOdgPackageOptions {
|
|
7
|
+
readonly metadata?: LayoutMetadata;
|
|
8
|
+
}
|
|
9
|
+
declare function createEmptyOdgPackage(options?: CreateEmptyOdgPackageOptions): Package;
|
|
6
10
|
//#endregion
|
|
7
|
-
export { MASTER_PAGE_NAME, PAGE_LAYOUT_NAME, createEmptyOdgPackage };
|
|
11
|
+
export { CreateEmptyOdgPackageOptions, MASTER_PAGE_NAME, PAGE_LAYOUT_NAME, createEmptyOdgPackage };
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { LayoutMetadata } from "document-schema.js";
|
|
1
2
|
import { Package } from "odf.js";
|
|
2
3
|
//#region src/edit/odg/scaffold.d.ts
|
|
3
4
|
declare const PAGE_LAYOUT_NAME = "PM1";
|
|
4
5
|
declare const MASTER_PAGE_NAME = "Standard";
|
|
5
|
-
|
|
6
|
+
interface CreateEmptyOdgPackageOptions {
|
|
7
|
+
readonly metadata?: LayoutMetadata;
|
|
8
|
+
}
|
|
9
|
+
declare function createEmptyOdgPackage(options?: CreateEmptyOdgPackageOptions): Package;
|
|
6
10
|
//#endregion
|
|
7
|
-
export { MASTER_PAGE_NAME, PAGE_LAYOUT_NAME, createEmptyOdgPackage };
|
|
11
|
+
export { CreateEmptyOdgPackageOptions, MASTER_PAGE_NAME, PAGE_LAYOUT_NAME, createEmptyOdgPackage };
|
|
@@ -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/odg/scaffold.ts
|
|
5
6
|
const CONTENT_NS_PREFIXES = [
|
|
@@ -74,13 +75,25 @@ function buildContentXml() {
|
|
|
74
75
|
"office:version": ODF_VERSION
|
|
75
76
|
}, [el("office:automatic-styles"), el("office:body", {}, [el("office:drawing")])]);
|
|
76
77
|
}
|
|
77
|
-
function
|
|
78
|
+
function buildOfficeMeta(metadata) {
|
|
79
|
+
if (metadata === void 0) return [];
|
|
80
|
+
const children = [];
|
|
81
|
+
if (metadata.title !== void 0) children.push(el("dc:title", {}, [txt(encodeXmlText(metadata.title))]));
|
|
82
|
+
if (metadata.author !== void 0) children.push(el("meta:initial-creator", {}, [txt(encodeXmlText(metadata.author))]));
|
|
83
|
+
if (metadata.subject !== void 0) children.push(el("dc:subject", {}, [txt(encodeXmlText(metadata.subject))]));
|
|
84
|
+
for (const keyword of metadata.keywords ?? []) children.push(el("meta:keyword", {}, [txt(encodeXmlText(keyword))]));
|
|
85
|
+
if (metadata.creator !== void 0) children.push(el("meta:generator", {}, [txt(encodeXmlText(metadata.creator))]));
|
|
86
|
+
if (metadata.createdIso !== void 0) children.push(el("meta:creation-date", {}, [txt(encodeXmlText(metadata.createdIso))]));
|
|
87
|
+
if (metadata.modifiedIso !== void 0) children.push(el("dc:date", {}, [txt(encodeXmlText(metadata.modifiedIso))]));
|
|
88
|
+
return children;
|
|
89
|
+
}
|
|
90
|
+
function buildMetaXml(metadata) {
|
|
78
91
|
return el("office:document-meta", {
|
|
79
92
|
...xmlnsAttributes([...META_NS_PREFIXES]),
|
|
80
93
|
"office:version": ODF_VERSION
|
|
81
|
-
}, [el("office:meta")]);
|
|
94
|
+
}, [el("office:meta", {}, buildOfficeMeta(metadata))]);
|
|
82
95
|
}
|
|
83
|
-
function createEmptyOdgPackage() {
|
|
96
|
+
function createEmptyOdgPackage(options) {
|
|
84
97
|
const pkg = { parts: {
|
|
85
98
|
"content.xml": {
|
|
86
99
|
kind: "xml",
|
|
@@ -92,7 +105,7 @@ function createEmptyOdgPackage() {
|
|
|
92
105
|
},
|
|
93
106
|
"meta.xml": {
|
|
94
107
|
kind: "xml",
|
|
95
|
-
nodes: [declaration(), buildMetaXml()]
|
|
108
|
+
nodes: [declaration(), buildMetaXml(options?.metadata)]
|
|
96
109
|
}
|
|
97
110
|
} };
|
|
98
111
|
setDocumentMediaType(pkg, ODF_MEDIA_TYPES.odg);
|
|
@@ -1,12 +1,17 @@
|
|
|
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_edit_odt_content = require("../odt/content.cjs");
|
|
6
|
+
const require_edit_odp_scaffold = require("./scaffold.cjs");
|
|
4
7
|
const require_edit_odp_editor = require("./editor.cjs");
|
|
5
8
|
let odf_js = require("odf.js");
|
|
6
9
|
//#region src/edit/odp/content.ts
|
|
7
|
-
function buildOdpPackage(content) {
|
|
10
|
+
function buildOdpPackage(content, options) {
|
|
8
11
|
if (content.kind !== "presentation") throw new Error("buildOdpPackage requires a presentation ContentDocument");
|
|
9
|
-
const
|
|
12
|
+
const clock = options?.clock ?? require_ports_clock.systemClock;
|
|
13
|
+
const metadata = require_model_metadata.resolveMetadataTimestamps(content.metadata, clock);
|
|
14
|
+
const editor = new require_edit_odp_editor.OdpEditor(require_edit_odp_scaffold.createEmptyOdpPackage({ metadata }));
|
|
10
15
|
const firstSlide = content.slides[0];
|
|
11
16
|
if (firstSlide !== void 0) editor.slideSize = firstSlide.size;
|
|
12
17
|
for (const slide of content.slides) {
|
|
@@ -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/odp/content.d.ts
|
|
4
|
-
|
|
5
|
+
interface BuildOdpPackageOptions {
|
|
6
|
+
readonly clock?: ClockPort;
|
|
7
|
+
}
|
|
8
|
+
declare function buildOdpPackage(content: ContentDocument, options?: BuildOdpPackageOptions): Package;
|
|
5
9
|
//#endregion
|
|
6
|
-
export { buildOdpPackage };
|
|
10
|
+
export { BuildOdpPackageOptions, buildOdpPackage };
|
|
@@ -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/odp/content.d.ts
|
|
4
|
-
|
|
5
|
+
interface BuildOdpPackageOptions {
|
|
6
|
+
readonly clock?: ClockPort;
|
|
7
|
+
}
|
|
8
|
+
declare function buildOdpPackage(content: ContentDocument, options?: BuildOdpPackageOptions): Package;
|
|
5
9
|
//#endregion
|
|
6
|
-
export { buildOdpPackage };
|
|
10
|
+
export { BuildOdpPackageOptions, buildOdpPackage };
|
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 };
|