js.documents 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/README.md
CHANGED
|
@@ -599,10 +599,10 @@ To run a single test file: `pnpm vitest run src/path/to/file.test.ts`.
|
|
|
599
599
|
- **Headless LibreOffice command-line macro dispatch (`soffice {file} {macro:///Library.Module.Name}`) needed two real, non-obvious environment fixes to run at all in this sandbox, beyond the ones already documented for HSQLDB/odm fixture generation.** (1) A prior session's forcefully-killed `soffice` process leaves macOS's own native "reopen windows after a crash" alert showing on every subsequent launch — invisible in headless/`--invisible` mode (no window to click), so `soffice` hangs indefinitely in `-[NSAlert runModal]` waiting for a response that can never arrive; `defaults write org.libreoffice.script ApplePersistenceIgnoreState -bool true` (plus removing `~/Library/Saved Application State/org.libreoffice.script.savedState`) disables it. (2) `soffice "macro:///Library.Module.Name"` with no document argument silently does nothing at all — per `soffice --help`'s own usage text, the `{file}` argument is not optional (`{file} {macro:///Library.Module.MacroName}`); a session invoking a macro with no real work to do on a document still needs a real (even trivial) file argument for the macro to actually dispatch.
|
|
600
600
|
- **A Firebird gbak backup stream's own wire format mixes two genuinely different byte-level encodings, confirmed only by testing against real bytes, not solely from reading the engine's source.** Every `rec_*`/`att_*` tag-and-attribute structure is little-endian ("VAX order", `isc_vax_integer`), one length-prefix byte per value; a row's own field-value sequence (once any RLE compression is peeled off) is standard RFC 1832 XDR — big-endian, every value (even a nominally 16-bit `SSHORT`) widened to a 4-byte-aligned unit, opaque byte runs zero-padded to the next 4-byte boundary. A genuine 64-bit-integer word-order bug (high 32 bits transmitted first, not low-first as `xdr_hyper`'s own in-memory `temp_long` array layout suggests on first reading) was caught exactly this way: a `DECIMAL(10,2)` column decoded to a nonsense value on the first real-fixture test run, not from a source-reading mistake that was obvious in advance.
|
|
601
601
|
- **STIX Two Math is embedded as a whole, unmodified `CFF ` table rather than glyph-subsetted — pdf-codec's own font-embedding scope decision, not this package's.** See pdf-codec's own README for the full CFF-embedding scope statement.
|
|
602
|
-
- **A stretchy fence in an `mrow`
|
|
602
|
+
- **A stretchy fence in an `mrow` genuinely stretches to its content on the VERTICAL axis, via the font's own `MathVariants` data, for any `mo` the operator dictionary calls stretchy — matched now by a genuine HORIZONTAL stretch for an over/under-brace spanning its own base in `munder`/`mover`/`munderover` (see the next bullet).** `layoutRowChildren` (`src/mathml/layout.ts`) targets twice the larger of the row's own non-stretchy children's half-extents about the maths axis (MathML's default `symmetric` behaviour for a fence), asks the `MathFontMetrics.stretch` port for a construction reaching it, and emits a `MathAssembledGlyphs` item: one or more glyph IDs at explicitly computed positions, rather than the Unicode text a `MathGlyphRun` carries. It has to be glyph IDs — every pre-built larger variant in this font is unencoded, as are the radical's and the over-brace's assembly pieces, with only the bracket family's own pieces given code points (the U+239B–U+23AD block). What genuinely stretches today: parentheses, square brackets, curly braces, floor/ceiling, angle brackets, and the vertical-bar/norm pair, each drawn either from a larger pre-built variant or from a real multi-part assembly sized to the content. What does not, and why:
|
|
603
603
|
- **`msqrt`/`mroot` radical signs** keep the hand-drawn hooked sign + vinculum `src/mathml/radical.ts` builds. This is not a `MathVariants` gap — the font's own radical construction stretches perfectly well, and a bare stretchy `<mo>√</mo>` in an `mrow` does now use it — but a radical *construct* needs a vinculum spanning its radicand's width, which no vertical glyph construction supplies, so switching it over means replacing the whole hand-built sign, not just its stem.
|
|
604
|
-
- **Horizontal stretching** (an over/under-brace, `U+23DE`/`U+23DF`, spanning its base in `munder`/`mover`) is not wired up. Everything below the layout engine already handles it — the port takes an `axis`, pdf-codec measures a horizontal construction correctly, and the item kind is axis-agnostic — but `layoutUnderOver` would need to derive its target from a box's *width* rather than from a row's height, and nothing in this module calls `stretch` with `'horizontal'` today.
|
|
605
604
|
- **A multi-character `mo`** (`"||"`, an operator with combining marks) is never stretched: the font's `MathVariants` data is keyed per glyph, so there is no single construction to look up.
|
|
605
|
+
- **An over/under-brace (`U+23DE`/`U+23DF`) spanning its own `munder`/`mover`/`munderover` base now genuinely stretches horizontally, via the identical `MathFontMetrics.stretch` port used for a vertical fence, just called with `axis: 'horizontal'` and a width target instead of a height one.** `layoutUnderOverChild` (`src/mathml/layout.ts`) is the call site: for each over/under script that `isStretchyOperator` accepts, it asks `stretchHorizontalOperator` to stretch to the base's own `widthPt`, computed independently for the over and under script (no shared or synchronised target — real `\overbrace{content}^{label}` semantics needs none), and falls back to the ordinary glyph run wherever the font declines (no horizontal `MathVariants` construction for that glyph, or the base is already wide enough that the construction's own base form already reaches it). `horizontallyStretchedBox` is `stretchedBox`'s horizontal-axis sibling, not a shared axis-branching function: its box width is the construction's own achieved `sizePt` (never `advanceWidthPt`, which for a horizontal assembly is only the widest individual glyph's own natural advance, far short of the whole span), and its ascent/descent come directly and unclamped from the construction's own real ink — one of the two is genuinely negative for both the over-brace and the under-brace, since each glyph's ink sits almost entirely on one side of its own drawing origin, and `layoutUnderOver` already stacks over/under content against the base's own edges using exactly that ascent/descent, with no further change needed on its part.
|
|
606
606
|
- **A stretched fence's own glyphs have no ToUnicode mapping, so pdf-codec wraps them in an `/ActualText` span carrying the operator's real text.** Text extraction, search, and copy/paste still recover `(` from a six-piece assembled bracket. A fence the base glyph already covers is left as an ordinary `MathGlyphRun` rather than converted to glyph IDs, so a plain inline `(x + 1)` renders and extracts exactly as it did before any of this existed.
|
|
607
607
|
- **The operator dictionary calls `∑`/`∏`/`⋃` and the rest of the big-operator family NOT stretchy, matching MathML3's own dictionary.** This became load-bearing once a stretchy operator genuinely stretches: STIX Two Math *does* declare vertical `MathVariants` for a summation sign, so a wrong `stretchy: true` there would visibly deform a `∑` standing next to a tall fraction. A big operator grows by selecting a larger designed size in display style — the `largeop` mechanism — never by stretching to its row.
|
|
608
608
|
- **A token element's (`mi`/`mn`/`mo`/`mtext`) own box height is the union of its characters' real per-glyph ink bounds, falling back to the font's nominal design ascent/descent only for a glyph that carries none.** `src/mathml/` still parses no glyph outlines itself — the bounds arrive through `MathFontMetrics.glyph`'s own `inkAscentPt`/`inkDescentPt`, which pdf-codec computes by walking the embedded font's Type 2 charstrings (see its README's own `cff-bounds.ts` note). The fallback is not dead code: a glyph that draws nothing (a space) or whose charstring that reader declines to walk reports neither bound, and takes the font-wide nominal extent instead, which is also what a `MathFontMetrics` implementation with no outline parsing at all would supply for every glyph.
|
|
@@ -643,7 +643,7 @@ To run a single test file: `pnpm vitest run src/path/to/file.test.ts`.
|
|
|
643
643
|
|
|
644
644
|
**docx/pptx/odt/odp/ods/odg → PDF** is a genuine layout render: the docx/odt flow/pagination engine and the pptx/odp direct-placement engine both produce real positioned text, images, tables, and (for docx/odt) numbered/bulleted lists, styled through the full cascade (theme fonts/colours, `basedOn` chains, placeholder inheritance for docx/pptx; `style:default-style`/`style:parent-style-name` chains for odt/odp). `odg` renders its vector primitives (rect/ellipse/line/path, the last emitted as real PDF `m`/`l`/`c`/`h` content-stream operators, not a polygon approximation of any curve) and reuses the pptx/odp direct-placement engine's own shape conversion for whatever text it also carries. It is a faithful **visual approximation**, not a pixel- or line-identical reproduction of what Word/PowerPoint/Writer/Impress/Draw would themselves render — how close depends on which typeface the document asks for and whether it embedded one, see the font-resolution gotcha above.
|
|
645
645
|
|
|
646
|
-
**odf → PDF (`odfToPdf`), and a formula embedded inside odt/odp/ods,** render **faithful mathematical typesetting**, not a static image or a plain-text placeholder: real box-model layout (script/limit positioning, fraction/radical geometry with correct rule thickness, table column alignment, `mathvariant` → Mathematical Alphanumeric Symbols mapping) through the embedded STIX Two Math font, with genuine per-glyph metrics (advance width, italic correction, top-accent attachment) and font-wide layout constants (axis height, fraction/radical rule thickness and gaps, script shift amounts) parsed directly from that font's own `MATH` table — not approximated or hand-tuned. A vertical fence around a tall construct genuinely stretches too, assembled from the font's own `MathVariants` pieces and sized to what it wraps, rather than drawn at a fixed base size
|
|
646
|
+
**odf → PDF (`odfToPdf`), and a formula embedded inside odt/odp/ods,** render **faithful mathematical typesetting**, not a static image or a plain-text placeholder: real box-model layout (script/limit positioning, fraction/radical geometry with correct rule thickness, table column alignment, `mathvariant` → Mathematical Alphanumeric Symbols mapping) through the embedded STIX Two Math font, with genuine per-glyph metrics (advance width, italic correction, top-accent attachment) and font-wide layout constants (axis height, fraction/radical rule thickness and gaps, script shift amounts) parsed directly from that font's own `MATH` table — not approximated or hand-tuned. A vertical fence around a tall construct genuinely stretches too, assembled from the font's own `MathVariants` pieces and sized to what it wraps, rather than drawn at a fixed base size — and an over/under-brace spanning its own `munder`/`mover`/`munderover` base stretches horizontally on the identical basis, sized to that base's own width. The honest limits: `msqrt`/`mroot` still draw a hand-built radical sign rather than the font's own stretched one (a structural reason, not because the font data is unavailable — see the Gotchas entries above); `mover`/`munder` centre geometrically rather than at the font's own declared accent-attachment point; and the operator dictionary and Greek `mathvariant` mapping each cover a deliberately bounded, common-case set rather than the full specification. For a formula anchored to a spreadsheet **cell**, position is genuinely resolved against that sheet's real column/row geometry (verified end to end against a real LibreOffice-authored `.ods`), but the rendered **size** comes from the same frame-height heuristic every engine uses, which over-estimates for a stacked formula — see the Gotchas entry on `formulaSizePtFromFrame`. **`pdfToOdf` (PDF → structured MathML) is not attempted, on either direction** — recovering a semantic operator tree (is this pair of glyphs a fraction, or a coincidentally stacked pair of ordinary characters? is a raised glyph a superscript, or just a smaller font size used for emphasis?) from nothing but positioned glyphs and paths is a categorically different, OCR-adjacent problem, with no geometry-reconstruction analogue anywhere else in this package: `reconstructWordprocessing`/`reconstructPresentation` recover paragraph/shape *structure* from geometry, never semantic *meaning* the way recognising a fraction would require.
|
|
647
647
|
|
|
648
648
|
**PDF → docx/pptx/odt/odp** is necessarily a **best-effort reconstruction** from geometry: a PDF page is just positioned glyphs and images, with no semantic paragraph or shape structure to recover. Reading order, bold/italic/colour/font-size, and page/slide count are preserved; paragraph and text-block boundaries are inferred from baseline spacing and left-margin indentation, not recovered exactly. Two further kinds of content are recovered on top of that text, each on its own explicit terms: a real `ContentTable`, but **only** where a genuine drawn gridline lattice is detected, never from text alignment (which would be inventing structure, not recovering it); and a page's vector primitives, into a nested drawing document that currently reaches the `ContentDocument` pivot but not the output bytes. Both are covered in full by their own [Gotchas](#gotchas-and-quirks) entries.
|
|
649
649
|
|
|
@@ -1,5 +1,8 @@
|
|
|
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_units = require("../../model/units.cjs");
|
|
5
|
+
const require_edit_docx_scaffold = require("./scaffold.cjs");
|
|
3
6
|
const require_edit_docx_editor = require("./editor.cjs");
|
|
4
7
|
const require_model_embedded_drawing = require("../../model/embedded-drawing.cjs");
|
|
5
8
|
const require_model_formula = require("../../model/formula.cjs");
|
|
@@ -7,7 +10,9 @@ let ooxml_js = require("ooxml.js");
|
|
|
7
10
|
//#region src/edit/docx/content.ts
|
|
8
11
|
function buildDocxPackage(content, options) {
|
|
9
12
|
if (content.kind !== "wordprocessing") throw new Error("buildDocxPackage requires a wordprocessing ContentDocument");
|
|
10
|
-
const
|
|
13
|
+
const clock = options?.clock ?? require_ports_clock.systemClock;
|
|
14
|
+
const metadata = require_model_metadata.resolveMetadataTimestamps(content.metadata, clock);
|
|
15
|
+
const editor = new require_edit_docx_editor.DocxEditor(require_edit_docx_scaffold.createEmptyDocxPackage({ metadata }));
|
|
11
16
|
content.sections.forEach((section, sectionIndex) => {
|
|
12
17
|
if (sectionIndex > 0) editor.body.appendPageBreak();
|
|
13
18
|
appendBlocks(editor.body, section.blocks, options);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as OmmlDiagnostic } from "../../shared-DLZ3IQUl.cjs";
|
|
2
|
+
import { ClockPort } from "../../ports/clock.cjs";
|
|
2
3
|
import { ContentDocument } from "document-schema.js";
|
|
3
4
|
import { Package } from "ooxml.js";
|
|
4
5
|
//#region src/edit/docx/content.d.ts
|
|
@@ -6,6 +7,7 @@ interface BuildDocxPackageOptions {
|
|
|
6
7
|
readonly onMathDiagnostic?: (diagnostic: OmmlDiagnostic, context: {
|
|
7
8
|
readonly sourcePath?: string;
|
|
8
9
|
}) => void;
|
|
10
|
+
readonly clock?: ClockPort;
|
|
9
11
|
}
|
|
10
12
|
declare function buildDocxPackage(content: ContentDocument, options?: BuildDocxPackageOptions): Package;
|
|
11
13
|
//#endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as OmmlDiagnostic } from "../../shared-DUOzjwcL.js";
|
|
2
|
+
import { ClockPort } from "../../ports/clock.js";
|
|
2
3
|
import { Package } from "ooxml.js";
|
|
3
4
|
import { ContentDocument } from "document-schema.js";
|
|
4
5
|
//#region src/edit/docx/content.d.ts
|
|
@@ -6,6 +7,7 @@ interface BuildDocxPackageOptions {
|
|
|
6
7
|
readonly onMathDiagnostic?: (diagnostic: OmmlDiagnostic, context: {
|
|
7
8
|
readonly sourcePath?: string;
|
|
8
9
|
}) => void;
|
|
10
|
+
readonly clock?: ClockPort;
|
|
9
11
|
}
|
|
10
12
|
declare function buildDocxPackage(content: ContentDocument, options?: BuildDocxPackageOptions): Package;
|
|
11
13
|
//#endregion
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
import { resolveMetadataTimestamps } from "../../model/metadata.js";
|
|
2
|
+
import { systemClock } from "../../ports/clock.js";
|
|
1
3
|
import { ptToTwips } from "../../model/units.js";
|
|
2
|
-
import {
|
|
4
|
+
import { createEmptyDocxPackage } from "./scaffold.js";
|
|
5
|
+
import { DocxEditor } from "./editor.js";
|
|
3
6
|
import { FLOW_CONTAINER_ORIGIN, drawingOfBlock, embeddedDrawingVectors } from "../../model/embedded-drawing.js";
|
|
4
7
|
import { formulaOfBlock, formulaPlaceholderText } from "../../model/formula.js";
|
|
5
8
|
import { base64ToBytes } from "ooxml.js";
|
|
6
9
|
//#region src/edit/docx/content.ts
|
|
7
10
|
function buildDocxPackage(content, options) {
|
|
8
11
|
if (content.kind !== "wordprocessing") throw new Error("buildDocxPackage requires a wordprocessing ContentDocument");
|
|
9
|
-
const
|
|
12
|
+
const clock = options?.clock ?? systemClock;
|
|
13
|
+
const metadata = resolveMetadataTimestamps(content.metadata, clock);
|
|
14
|
+
const editor = new DocxEditor(createEmptyDocxPackage({ metadata }));
|
|
10
15
|
content.sections.forEach((section, sectionIndex) => {
|
|
11
16
|
if (sectionIndex > 0) editor.body.appendPageBreak();
|
|
12
17
|
appendBlocks(editor.body, section.blocks, options);
|
|
@@ -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_docx_paragraph = require("./paragraph.cjs");
|
|
4
6
|
const require_edit_docx_scaffold = require("./scaffold.cjs");
|
|
@@ -107,8 +109,10 @@ var DocxEditor = class {
|
|
|
107
109
|
function openDocx(bytes) {
|
|
108
110
|
return new DocxEditor((0, ooxml_js.decodePackage)(bytes));
|
|
109
111
|
}
|
|
110
|
-
function createDocx() {
|
|
111
|
-
|
|
112
|
+
function createDocx(options) {
|
|
113
|
+
const clock = options?.clock ?? require_ports_clock.systemClock;
|
|
114
|
+
const metadata = require_model_metadata.resolveMetadataTimestamps({}, clock);
|
|
115
|
+
return new DocxEditor(require_edit_docx_scaffold.createEmptyDocxPackage({ metadata }));
|
|
112
116
|
}
|
|
113
117
|
//#endregion
|
|
114
118
|
exports.DocxEditor = DocxEditor;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.cjs";
|
|
1
2
|
import { DocxParagraph, ParagraphInit } from "./paragraph.cjs";
|
|
2
3
|
import { DocxTable, TableInit } from "./table.cjs";
|
|
3
4
|
import { Package } from "ooxml.js";
|
|
@@ -18,6 +19,9 @@ declare class DocxEditor {
|
|
|
18
19
|
toBytes(): Uint8Array<ArrayBuffer>;
|
|
19
20
|
}
|
|
20
21
|
declare function openDocx(bytes: Uint8Array<ArrayBuffer>): DocxEditor;
|
|
21
|
-
|
|
22
|
+
interface CreateDocxOptions {
|
|
23
|
+
readonly clock?: ClockPort;
|
|
24
|
+
}
|
|
25
|
+
declare function createDocx(options?: CreateDocxOptions): DocxEditor;
|
|
22
26
|
//#endregion
|
|
23
|
-
export { DocxBody, DocxEditor, createDocx, openDocx };
|
|
27
|
+
export { CreateDocxOptions, DocxBody, DocxEditor, createDocx, openDocx };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.js";
|
|
1
2
|
import { DocxParagraph, ParagraphInit } from "./paragraph.js";
|
|
2
3
|
import { DocxTable, TableInit } from "./table.js";
|
|
3
4
|
import { Package } from "ooxml.js";
|
|
@@ -18,6 +19,9 @@ declare class DocxEditor {
|
|
|
18
19
|
toBytes(): Uint8Array<ArrayBuffer>;
|
|
19
20
|
}
|
|
20
21
|
declare function openDocx(bytes: Uint8Array<ArrayBuffer>): DocxEditor;
|
|
21
|
-
|
|
22
|
+
interface CreateDocxOptions {
|
|
23
|
+
readonly clock?: ClockPort;
|
|
24
|
+
}
|
|
25
|
+
declare function createDocx(options?: CreateDocxOptions): DocxEditor;
|
|
22
26
|
//#endregion
|
|
23
|
-
export { DocxBody, DocxEditor, createDocx, openDocx };
|
|
27
|
+
export { CreateDocxOptions, DocxBody, DocxEditor, createDocx, openDocx };
|
package/dist/edit/docx/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 { DocxParagraph, buildParagraph } from "./paragraph.js";
|
|
3
5
|
import { createEmptyDocxPackage } from "./scaffold.js";
|
|
@@ -106,8 +108,10 @@ var DocxEditor = class {
|
|
|
106
108
|
function openDocx(bytes) {
|
|
107
109
|
return new DocxEditor(decodePackage(bytes));
|
|
108
110
|
}
|
|
109
|
-
function createDocx() {
|
|
110
|
-
|
|
111
|
+
function createDocx(options) {
|
|
112
|
+
const clock = options?.clock ?? systemClock;
|
|
113
|
+
const metadata = resolveMetadataTimestamps({}, clock);
|
|
114
|
+
return new DocxEditor(createEmptyDocxPackage({ metadata }));
|
|
111
115
|
}
|
|
112
116
|
//#endregion
|
|
113
117
|
export { DocxEditor, createDocx, openDocx };
|
|
@@ -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_opc_core_properties = require("../../opc/core-properties.cjs");
|
|
3
4
|
//#region src/edit/docx/scaffold.ts
|
|
4
5
|
const CONTENT_TYPES_NS = "http://schemas.openxmlformats.org/package/2006/content-types";
|
|
5
6
|
const RELS_NS = "http://schemas.openxmlformats.org/package/2006/relationships";
|
|
@@ -23,7 +24,7 @@ function declaration() {
|
|
|
23
24
|
]
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
|
-
function createEmptyDocxPackage() {
|
|
27
|
+
function createEmptyDocxPackage(options) {
|
|
27
28
|
const contentTypes = require_xml_fragment.el("Types", { xmlns: CONTENT_TYPES_NS }, [
|
|
28
29
|
require_xml_fragment.el("Default", {
|
|
29
30
|
Extension: "rels",
|
|
@@ -70,7 +71,7 @@ function createEmptyDocxPackage() {
|
|
|
70
71
|
"w:default": "1",
|
|
71
72
|
"w:styleId": "Normal"
|
|
72
73
|
}, [require_xml_fragment.el("w:name", { "w:val": "Normal" })])]);
|
|
73
|
-
|
|
74
|
+
const pkg = { parts: {
|
|
74
75
|
"[Content_Types].xml": {
|
|
75
76
|
kind: "xml",
|
|
76
77
|
nodes: [declaration(), contentTypes]
|
|
@@ -92,6 +93,8 @@ function createEmptyDocxPackage() {
|
|
|
92
93
|
nodes: [declaration(), styles]
|
|
93
94
|
}
|
|
94
95
|
} };
|
|
96
|
+
if (options?.metadata !== void 0) require_opc_core_properties.addCoreProperties(pkg, options.metadata);
|
|
97
|
+
return pkg;
|
|
95
98
|
}
|
|
96
99
|
//#endregion
|
|
97
100
|
exports.createEmptyDocxPackage = createEmptyDocxPackage;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { LayoutMetadata } from "document-schema.js";
|
|
1
2
|
import { Package } from "ooxml.js";
|
|
2
3
|
//#region src/edit/docx/scaffold.d.ts
|
|
3
|
-
|
|
4
|
+
interface CreateEmptyDocxPackageOptions {
|
|
5
|
+
readonly metadata?: LayoutMetadata;
|
|
6
|
+
}
|
|
7
|
+
declare function createEmptyDocxPackage(options?: CreateEmptyDocxPackageOptions): Package;
|
|
4
8
|
//#endregion
|
|
5
|
-
export { createEmptyDocxPackage };
|
|
9
|
+
export { CreateEmptyDocxPackageOptions, createEmptyDocxPackage };
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Package } from "ooxml.js";
|
|
2
|
+
import { LayoutMetadata } from "document-schema.js";
|
|
2
3
|
//#region src/edit/docx/scaffold.d.ts
|
|
3
|
-
|
|
4
|
+
interface CreateEmptyDocxPackageOptions {
|
|
5
|
+
readonly metadata?: LayoutMetadata;
|
|
6
|
+
}
|
|
7
|
+
declare function createEmptyDocxPackage(options?: CreateEmptyDocxPackageOptions): Package;
|
|
4
8
|
//#endregion
|
|
5
|
-
export { createEmptyDocxPackage };
|
|
9
|
+
export { CreateEmptyDocxPackageOptions, createEmptyDocxPackage };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { el } from "../../xml/fragment.js";
|
|
2
|
+
import { addCoreProperties } from "../../opc/core-properties.js";
|
|
2
3
|
//#region src/edit/docx/scaffold.ts
|
|
3
4
|
const CONTENT_TYPES_NS = "http://schemas.openxmlformats.org/package/2006/content-types";
|
|
4
5
|
const RELS_NS = "http://schemas.openxmlformats.org/package/2006/relationships";
|
|
@@ -22,7 +23,7 @@ function declaration() {
|
|
|
22
23
|
]
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
|
-
function createEmptyDocxPackage() {
|
|
26
|
+
function createEmptyDocxPackage(options) {
|
|
26
27
|
const contentTypes = el("Types", { xmlns: CONTENT_TYPES_NS }, [
|
|
27
28
|
el("Default", {
|
|
28
29
|
Extension: "rels",
|
|
@@ -69,7 +70,7 @@ function createEmptyDocxPackage() {
|
|
|
69
70
|
"w:default": "1",
|
|
70
71
|
"w:styleId": "Normal"
|
|
71
72
|
}, [el("w:name", { "w:val": "Normal" })])]);
|
|
72
|
-
|
|
73
|
+
const pkg = { parts: {
|
|
73
74
|
"[Content_Types].xml": {
|
|
74
75
|
kind: "xml",
|
|
75
76
|
nodes: [declaration(), contentTypes]
|
|
@@ -91,6 +92,8 @@ function createEmptyDocxPackage() {
|
|
|
91
92
|
nodes: [declaration(), styles]
|
|
92
93
|
}
|
|
93
94
|
} };
|
|
95
|
+
if (options?.metadata !== void 0) addCoreProperties(pkg, options.metadata);
|
|
96
|
+
return pkg;
|
|
94
97
|
}
|
|
95
98
|
//#endregion
|
|
96
99
|
export { createEmptyDocxPackage };
|
|
@@ -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 };
|
|
@@ -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 };
|