odf.js 6.4.0 → 7.0.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 +1 -1
- package/dist/{codec-DTAgph2r.d.ts → codec-BVEK7_Sf.d.ts} +1 -1
- package/dist/{codec-CFdlbFLJ.d.cts → codec-aKINptZk.d.cts} +1 -1
- package/dist/codec.d.cts +1 -1
- package/dist/codec.d.ts +1 -1
- package/dist/image/sniff.cjs +26 -0
- package/dist/image/sniff.d.cts +1 -1
- package/dist/image/sniff.d.ts +1 -1
- package/dist/image/sniff.js +26 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/manifest.cjs +2 -0
- package/dist/manifest.js +2 -0
- package/dist/{sniff-DGOBHA0O.d.cts → sniff-eR8lObzF.d.cts} +1 -1
- package/dist/{sniff-DGOBHA0O.d.ts → sniff-eR8lObzF.d.ts} +1 -1
- package/dist/{table-XuniPr2I.d.ts → table-B_LX8Dgy.d.ts} +2 -2
- package/dist/{table-CECMtPxZ.d.cts → table-DWTKLvxt.d.cts} +2 -2
- package/dist/typed/draw/write-shapes.cjs +2 -1
- package/dist/typed/draw/write-shapes.js +2 -1
- package/dist/typed/ods/write.cjs +12 -3
- package/dist/typed/ods/write.js +13 -4
- package/dist/typed/odt/write.cjs +2 -1
- package/dist/typed/odt/write.js +2 -1
- package/dist/typed/shared/canonicalise.cjs +9 -1
- package/dist/typed/shared/canonicalise.d.cts +3 -2
- package/dist/typed/shared/canonicalise.d.ts +3 -2
- package/dist/typed/shared/canonicalise.js +10 -3
- package/dist/typed/shared/image.cjs +12 -0
- package/dist/typed/shared/image.d.cts +5 -0
- package/dist/typed/shared/image.d.ts +5 -0
- package/dist/typed/shared/image.js +11 -0
- package/dist/typed/shared/table.cjs +7 -2
- package/dist/typed/shared/table.d.cts +1 -1
- package/dist/typed/shared/table.d.ts +1 -1
- package/dist/typed/shared/table.js +7 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -451,7 +451,7 @@ Layered from a lossless core outward, mirroring `ooxml.js`:
|
|
|
451
451
|
- **A rotated `draw:rect`/`ellipse`/`path`/`custom-shape` reads its own `rotationDeg`** via the same `resolveOdfShapeGeometry` machinery `draw:frame` uses, composing any enclosing `draw:g` rotation.
|
|
452
452
|
- **Every `ContentShape`/`ContentVector` carries a resolved `paintOrder`** so true relative paint order survives across the independently-ordered `shapes`/`vectors` arrays.
|
|
453
453
|
- **`svg:fill-rule` and `draw:stroke` map onto `ContentVector.fillRule`/`ContentStroke.style`.** A dotted pattern and `"double"` stroke have no ODF vector-stroke counterpart and remain unread.
|
|
454
|
-
- **`readOdsContent`/`readTableCell` resolve cell `background`/`borders`/`alignment`/`verticalAlignment` from the real style cascade.** An explicit `fo:border-*` of `"none"`/`"hidden"` clears an inherited edge.
|
|
454
|
+
- **`readOdsContent`/`readTableCell` resolve cell `background`/`borders`/`alignment`/`verticalAlignment` from the real style cascade.** An explicit `fo:border-*` of `"none"`/`"hidden"` clears an inherited edge. A cell's own `background` always reads back as a `'solid'` `ContentCellFill` (ExaDev/documents.js#951): `fo:background-color` is a flat OASIS colour attribute with no two-colour pattern-fill vocabulary at all, unlike WordprocessingML's `w:shd` or SpreadsheetML's `patternFill`. Writing a `'pattern'` fill therefore approximates through `resolveCellFillColor`'s own single representative colour (its foreground, falling back to its background) rather than refusing outright, since a flat approximation is strictly more useful than dropping the fill entirely for a format that genuinely cannot state one.
|
|
455
455
|
- **`readOdsContent` reads sheet-anchored drawings** — cell-anchored `draw:frame`s (coordinates relative to the cell) and page-anchored ones (in `table:shapes`). An embedded chart resolves as a `chart`-kind object whose document is a frame-sized drawing page carrying the chart's own cached data table, with the `chart:chart` element quarantined in residue. A sheet cannot carry a floating text box or bare vector; each is skipped.
|
|
456
456
|
- **`readDrawObjectReference` resolves a frame's embedded sub-document kind from its own `content.xml`, not the manifest.** A `draw:object` must be checked _before_ the frame's preview image, since an embedded-object frame also carries a preview `draw:image`.
|
|
457
457
|
|
|
@@ -19,7 +19,7 @@ import "./cascade-PDS3hgrP.js";
|
|
|
19
19
|
import "./metadata-BUzwE_-u.js";
|
|
20
20
|
import "./list-7FO0SDqZ.js";
|
|
21
21
|
import "./paragraph-DtC86tft.js";
|
|
22
|
-
import "./table-
|
|
22
|
+
import "./table-B_LX8Dgy.js";
|
|
23
23
|
import "./scaffold-ehGsIpZ5.js";
|
|
24
24
|
import "./transform-BFNc16LQ.js";
|
|
25
25
|
import "./masterpage-BLK2OJ9q.js";
|
|
@@ -19,7 +19,7 @@ import "./cascade-BpMwrjkB.cjs";
|
|
|
19
19
|
import "./metadata-CYXgXL_h.cjs";
|
|
20
20
|
import "./list-BorrTJBY.cjs";
|
|
21
21
|
import "./paragraph-Bf6Iq5wC.cjs";
|
|
22
|
-
import "./table-
|
|
22
|
+
import "./table-DWTKLvxt.cjs";
|
|
23
23
|
import "./scaffold-44EIMGll.cjs";
|
|
24
24
|
import "./transform-M1gbHp4j.cjs";
|
|
25
25
|
import "./masterpage-KqZshNGZ.cjs";
|
package/dist/codec.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as xmlCodec, n as encodePackage, r as packageCodec, t as decodePackage } from "./codec-
|
|
1
|
+
import { i as xmlCodec, n as encodePackage, r as packageCodec, t as decodePackage } from "./codec-aKINptZk.cjs";
|
|
2
2
|
export { decodePackage, encodePackage, packageCodec, xmlCodec };
|
package/dist/codec.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as xmlCodec, n as encodePackage, r as packageCodec, t as decodePackage } from "./codec-
|
|
1
|
+
import { i as xmlCodec, n as encodePackage, r as packageCodec, t as decodePackage } from "./codec-BVEK7_Sf.js";
|
|
2
2
|
export { decodePackage, encodePackage, packageCodec, xmlCodec };
|
package/dist/image/sniff.cjs
CHANGED
|
@@ -15,14 +15,40 @@ const JPEG_SIGNATURE = [
|
|
|
15
15
|
216,
|
|
16
16
|
255
|
|
17
17
|
];
|
|
18
|
+
const GIF87A_SIGNATURE = [
|
|
19
|
+
71,
|
|
20
|
+
73,
|
|
21
|
+
70,
|
|
22
|
+
56,
|
|
23
|
+
55,
|
|
24
|
+
97
|
|
25
|
+
];
|
|
26
|
+
const GIF89A_SIGNATURE = [
|
|
27
|
+
71,
|
|
28
|
+
73,
|
|
29
|
+
70,
|
|
30
|
+
56,
|
|
31
|
+
57,
|
|
32
|
+
97
|
|
33
|
+
];
|
|
18
34
|
function startsWith(bytes, signature) {
|
|
19
35
|
if (bytes.length < signature.length) return false;
|
|
20
36
|
for (let i = 0; i < signature.length; i++) if (bytes[i] !== signature[i]) return false;
|
|
21
37
|
return true;
|
|
22
38
|
}
|
|
39
|
+
const SVG_SNIFF_WINDOW = 1024;
|
|
40
|
+
function looksLikeSvg(bytes) {
|
|
41
|
+
const window = bytes.subarray(0, Math.min(bytes.length, SVG_SNIFF_WINDOW));
|
|
42
|
+
let text = "";
|
|
43
|
+
for (const byte of window) text += String.fromCharCode(byte);
|
|
44
|
+
const trimmed = text.trimStart();
|
|
45
|
+
return trimmed.startsWith("<?xml") || trimmed.startsWith("<svg");
|
|
46
|
+
}
|
|
23
47
|
function sniffImageFormat(bytes) {
|
|
24
48
|
if (startsWith(bytes, PNG_SIGNATURE)) return "png";
|
|
25
49
|
if (startsWith(bytes, JPEG_SIGNATURE)) return "jpeg";
|
|
50
|
+
if (startsWith(bytes, GIF87A_SIGNATURE) || startsWith(bytes, GIF89A_SIGNATURE)) return "gif";
|
|
51
|
+
if (looksLikeSvg(bytes)) return "svg";
|
|
26
52
|
}
|
|
27
53
|
//#endregion
|
|
28
54
|
exports.sniffImageFormat = sniffImageFormat;
|
package/dist/image/sniff.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as sniffImageFormat, t as ImageFormat } from "../sniff-
|
|
1
|
+
import { n as sniffImageFormat, t as ImageFormat } from "../sniff-eR8lObzF.cjs";
|
|
2
2
|
export { ImageFormat, sniffImageFormat };
|
package/dist/image/sniff.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as sniffImageFormat, t as ImageFormat } from "../sniff-
|
|
1
|
+
import { n as sniffImageFormat, t as ImageFormat } from "../sniff-eR8lObzF.js";
|
|
2
2
|
export { ImageFormat, sniffImageFormat };
|
package/dist/image/sniff.js
CHANGED
|
@@ -14,14 +14,40 @@ const JPEG_SIGNATURE = [
|
|
|
14
14
|
216,
|
|
15
15
|
255
|
|
16
16
|
];
|
|
17
|
+
const GIF87A_SIGNATURE = [
|
|
18
|
+
71,
|
|
19
|
+
73,
|
|
20
|
+
70,
|
|
21
|
+
56,
|
|
22
|
+
55,
|
|
23
|
+
97
|
|
24
|
+
];
|
|
25
|
+
const GIF89A_SIGNATURE = [
|
|
26
|
+
71,
|
|
27
|
+
73,
|
|
28
|
+
70,
|
|
29
|
+
56,
|
|
30
|
+
57,
|
|
31
|
+
97
|
|
32
|
+
];
|
|
17
33
|
function startsWith(bytes, signature) {
|
|
18
34
|
if (bytes.length < signature.length) return false;
|
|
19
35
|
for (let i = 0; i < signature.length; i++) if (bytes[i] !== signature[i]) return false;
|
|
20
36
|
return true;
|
|
21
37
|
}
|
|
38
|
+
const SVG_SNIFF_WINDOW = 1024;
|
|
39
|
+
function looksLikeSvg(bytes) {
|
|
40
|
+
const window = bytes.subarray(0, Math.min(bytes.length, SVG_SNIFF_WINDOW));
|
|
41
|
+
let text = "";
|
|
42
|
+
for (const byte of window) text += String.fromCharCode(byte);
|
|
43
|
+
const trimmed = text.trimStart();
|
|
44
|
+
return trimmed.startsWith("<?xml") || trimmed.startsWith("<svg");
|
|
45
|
+
}
|
|
22
46
|
function sniffImageFormat(bytes) {
|
|
23
47
|
if (startsWith(bytes, PNG_SIGNATURE)) return "png";
|
|
24
48
|
if (startsWith(bytes, JPEG_SIGNATURE)) return "jpeg";
|
|
49
|
+
if (startsWith(bytes, GIF87A_SIGNATURE) || startsWith(bytes, GIF89A_SIGNATURE)) return "gif";
|
|
50
|
+
if (looksLikeSvg(bytes)) return "svg";
|
|
25
51
|
}
|
|
26
52
|
//#endregion
|
|
27
53
|
export { sniffImageFormat };
|
package/dist/index.d.cts
CHANGED
|
@@ -8,7 +8,7 @@ import { n as unzipPackage, r as zipPackage, t as ZipEntry } from "./zip-ie17sOo
|
|
|
8
8
|
import { n as bytesToBase64, t as base64ToBytes } from "./base64--HuymRl_.cjs";
|
|
9
9
|
import { n as OdfNamespacePrefix, r as xmlnsAttributes, t as ODF_NAMESPACES } from "./ns-Cihto3Fx.cjs";
|
|
10
10
|
import { n as OdfExtension, r as mediaTypeForExtension, t as ODF_MEDIA_TYPES } from "./media-type-BOLkcHkJ.cjs";
|
|
11
|
-
import { n as sniffImageFormat, t as ImageFormat } from "./sniff-
|
|
11
|
+
import { n as sniffImageFormat, t as ImageFormat } from "./sniff-eR8lObzF.cjs";
|
|
12
12
|
import { n as writeMimetype, t as readMimetype } from "./mimetype-1BaQzNiS.cjs";
|
|
13
13
|
import { n as txt, t as el } from "./fragment-9dNg-m46.cjs";
|
|
14
14
|
import { n as encodeXmlText, t as decodeXmlText } from "./entities-BZlXvHqu.cjs";
|
|
@@ -27,7 +27,7 @@ import { a as resolveStyle, i as findStyleElement, n as StyleCascadeResult, o as
|
|
|
27
27
|
import { i as writeOdfMetadata, n as buildOdfMetaNodes, r as readOdfMetadata, t as META_PART } from "./metadata-CYXgXL_h.cjs";
|
|
28
28
|
import { a as OdfListParagraphReader, f as readOdfListParagraphs, i as OdfListIdState, m as writeOdfList, o as buildOdfListStyle, p as resolveOdfListKind, r as OdfListEntry, u as mintOdfListNumId } from "./list-BorrTJBY.cjs";
|
|
29
29
|
import { c as segmentOdfParagraphRuns, i as odfRunProperties, l as writeOdfParagraph, n as OdfParagraphWriteOptions, o as readOdfParagraph, r as odfParagraphProperties } from "./paragraph-Bf6Iq5wC.cjs";
|
|
30
|
-
import { c as writeOdfTable, s as readOdfTable } from "./table-
|
|
30
|
+
import { c as writeOdfTable, s as readOdfTable } from "./table-DWTKLvxt.cjs";
|
|
31
31
|
import { n as createOdfPackage, r as odfPartContainer, t as DEFAULT_ODF_VERSION } from "./scaffold-44EIMGll.cjs";
|
|
32
32
|
import { a as composeOdfGroupTransform, c as resolveOdfShapeGeometry, i as applyOdfTransform, n as OdfShapeGeometry, o as netRotationDeg, r as OdfTransformFunction, s as parseOdfTransform, t as OdfPoint } from "./transform-M1gbHp4j.cjs";
|
|
33
33
|
import { n as resolveDrawPageSize, r as resolvePageLayoutProperties } from "./masterpage-KqZshNGZ.cjs";
|
|
@@ -55,5 +55,5 @@ import { n as transformToOoo1Package, t as transformOoo1Package } from "./transf
|
|
|
55
55
|
import { a as readSxi, c as readSxwContent, i as readSxdContent, n as readSxcContent, o as readSxiContent, r as readSxd, s as readSxw, t as readSxc } from "./read-BgnLFuSi.cjs";
|
|
56
56
|
import { a as writeSxi, c as writeSxwContent, i as writeSxdContent, n as writeSxcContent, o as writeSxiContent, r as writeSxd, s as writeSxw, t as writeSxc } from "./write-BZXpT8F6.cjs";
|
|
57
57
|
import { a as OdbReportGroup, i as OdbReportFunction, n as OdbReportBand, o as readOdbReport, r as OdbReportElement, t as OdbReport } from "./report-39DyUx5W.cjs";
|
|
58
|
-
import { a as Alignment, i as xmlCodec, n as encodePackage, o as AlignmentSchema, r as packageCodec, s as DocumentTree, t as decodePackage } from "./codec-
|
|
58
|
+
import { a as Alignment, i as xmlCodec, n as encodePackage, o as AlignmentSchema, r as packageCodec, s as DocumentTree, t as decodePackage } from "./codec-aKINptZk.cjs";
|
|
59
59
|
export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type CascadeDiagnostic, DEFAULT_ODF_VERSION, type DocumentTree, type DrawPageContent, type EmbeddedDocumentKind, type EmbeddedDrawObject, type ImageFormat, type InternRequest, type LengthUnit, MANIFEST_PART, META_PART, MIMETYPE_PART, type Manifest, type ManifestEntry, ManifestEntrySchema, type ManifestProblem, ManifestProblemSchema, ManifestSchema, ODF_MEDIA_TYPES, ODF_NAMESPACES, OOO1_MEDIA_TYPES, OOO1_NAMESPACES, type OdbComponentInfo, type OdbConnectionInfo, type OdbForm, type OdbFormControl, type OdbFormDefinition, type OdbInventory, type OdbQueryInfo, type OdbReport, type OdbReportBand, type OdbReportElement, type OdbReportFunction, type OdbReportGroup, type OdfExtension, type OdfFormulaDocument, type OdfListEntry, type OdfListIdState, type OdfListParagraphReader, type OdfNamespacePrefix, type OdfParagraphWriteOptions, type OdfPoint, type OdfRawPoint, type OdfRawSegment, type OdfRawSubpath, type OdfShapeGeometry, type OdfTextSegment, type OdfTextSegmentKind, type OdfTransformFunction, type OdfViewBox, type OdgDocument, type OdgWriteOptions, type OdmDocument, type OdmSection, type OdpDocument, type OdpWriteOptions, type OdsDocument, type OdsWriteOptions, type OdtDocument, type OdtHeaderFooterPart, type OdtHeaderFooterVariant, type OdtReadOptions, type OdtWriteOptions, type Ooo1Extension, type Ooo1NamespacePrefix, type OtherPartRef, type Package, PackageSchema, type ParsedProperties, type Part, PartSchema, STYLE_FAMILIES, type StyleCascadeResult, type StyleElementChainResult, type StyleFamily, type StyleProperties, StylePropertiesSchema, StyleRegistry, type StyleRegistryOptions, type SubDocumentPackageOptions, TableCursor, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, type ZipEntry, applyOdfTransform, attrValue, base64ToBytes, buildManifest, buildOdfInlineNodes, buildOdfListStyle, buildOdfMetaNodes, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, createOdfPackage, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatOdfNumber, formatOdfPathData, formatOdfViewBox, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isOoo1NamespacePrefix, isOoo1Package, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, mintOdfListNumId, netRotationDeg, normaliseOdgContent, normaliseOdpContent, normaliseOdsContent, normaliseOdtContent, odfMediaTypeForOoo1MediaType, odfParagraphProperties, odfPartContainer, odfRunProperties, ooo1MediaTypeForExtension, ooo1MediaTypeForOdfMediaType, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseOdfLength as parseLength, parseOdfLength, parseLinePoints, parseMargins, parseOdfColor, parseOdfPathData, parseOdfPointsList, parseOdfTransform, parseOdfViewBox, parsePackage, parsePageSize, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, rawSubpathFromPoints, readDrawFrame, readDrawImageBlock, readDrawObjectReference, readDrawPageContent, readManifest, readMimetype, readOdbForm, readOdbInventory, readOdbReport, readOdfFormControlConstructs, readOdfFormDefinitions, readOdfFormula, readOdfFormulaContent, readOdfFormulaMathMl, readOdfListParagraphs, readOdfMetadata, readOdfParagraph, readOdfTable, readOdg, readOdgContent, readOdm, readOdp, readOdpContent, readOds, readOdsContent, readOdt, readOdtContent, readSxc, readSxcContent, readSxd, readSxdContent, readSxi, readSxiContent, readSxw, readSxwContent, resolveDrawPageSize, resolveOdbComponent, resolveOdfListKind, resolveOdfShapeGeometry, resolvePageLayoutProperties, resolveStyle, resolveStyleElementChain, rootElement, scaleOdfRawPoint, segmentOdfParagraphRuns, segmentOdfText, serializePackage, setDocumentMediaType, sniffImageFormat, subDocumentPackage, sumOdfNodeLength, syncManifest, textPropertiesToAttributes, transformOoo1Package, transformToOoo1Package, txt, unzipPackage, validateManifest, walkDrawShapes, writeDrawFrame, writeDrawShapes, writeDrawVector, writeDrawVectors, writeManifest, writeMimetype, writeOdfList, writeOdfMetadata, writeOdfParagraph, writeOdfTable, writeOdg, writeOdgContent, writeOdp, writeOdpContent, writeOds, writeOdsContent, writeOdt, writeOdtContent, writeSxc, writeSxcContent, writeSxd, writeSxdContent, writeSxi, writeSxiContent, writeSxw, writeSxwContent, xmlCodec, xmlnsAttributes, zipPackage };
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { n as unzipPackage, r as zipPackage, t as ZipEntry } from "./zip-ie17sOo
|
|
|
8
8
|
import { n as bytesToBase64, t as base64ToBytes } from "./base64--HuymRl_.js";
|
|
9
9
|
import { n as OdfNamespacePrefix, r as xmlnsAttributes, t as ODF_NAMESPACES } from "./ns-Cihto3Fx.js";
|
|
10
10
|
import { n as OdfExtension, r as mediaTypeForExtension, t as ODF_MEDIA_TYPES } from "./media-type-BOLkcHkJ.js";
|
|
11
|
-
import { n as sniffImageFormat, t as ImageFormat } from "./sniff-
|
|
11
|
+
import { n as sniffImageFormat, t as ImageFormat } from "./sniff-eR8lObzF.js";
|
|
12
12
|
import { n as writeMimetype, t as readMimetype } from "./mimetype-DvMCOzmu.js";
|
|
13
13
|
import { n as txt, t as el } from "./fragment-ClgCV_if.js";
|
|
14
14
|
import { n as encodeXmlText, t as decodeXmlText } from "./entities-BZlXvHqu.js";
|
|
@@ -27,7 +27,7 @@ import { a as resolveStyle, i as findStyleElement, n as StyleCascadeResult, o as
|
|
|
27
27
|
import { i as writeOdfMetadata, n as buildOdfMetaNodes, r as readOdfMetadata, t as META_PART } from "./metadata-BUzwE_-u.js";
|
|
28
28
|
import { a as OdfListParagraphReader, f as readOdfListParagraphs, i as OdfListIdState, m as writeOdfList, o as buildOdfListStyle, p as resolveOdfListKind, r as OdfListEntry, u as mintOdfListNumId } from "./list-7FO0SDqZ.js";
|
|
29
29
|
import { c as segmentOdfParagraphRuns, i as odfRunProperties, l as writeOdfParagraph, n as OdfParagraphWriteOptions, o as readOdfParagraph, r as odfParagraphProperties } from "./paragraph-DtC86tft.js";
|
|
30
|
-
import { c as writeOdfTable, s as readOdfTable } from "./table-
|
|
30
|
+
import { c as writeOdfTable, s as readOdfTable } from "./table-B_LX8Dgy.js";
|
|
31
31
|
import { n as createOdfPackage, r as odfPartContainer, t as DEFAULT_ODF_VERSION } from "./scaffold-ehGsIpZ5.js";
|
|
32
32
|
import { a as composeOdfGroupTransform, c as resolveOdfShapeGeometry, i as applyOdfTransform, n as OdfShapeGeometry, o as netRotationDeg, r as OdfTransformFunction, s as parseOdfTransform, t as OdfPoint } from "./transform-BFNc16LQ.js";
|
|
33
33
|
import { n as resolveDrawPageSize, r as resolvePageLayoutProperties } from "./masterpage-BLK2OJ9q.js";
|
|
@@ -55,5 +55,5 @@ import { n as transformToOoo1Package, t as transformOoo1Package } from "./transf
|
|
|
55
55
|
import { a as readSxi, c as readSxwContent, i as readSxdContent, n as readSxcContent, o as readSxiContent, r as readSxd, s as readSxw, t as readSxc } from "./read-CqaZ01kU.js";
|
|
56
56
|
import { a as writeSxi, c as writeSxwContent, i as writeSxdContent, n as writeSxcContent, o as writeSxiContent, r as writeSxd, s as writeSxw, t as writeSxc } from "./write-SKnCTU4C.js";
|
|
57
57
|
import { a as OdbReportGroup, i as OdbReportFunction, n as OdbReportBand, o as readOdbReport, r as OdbReportElement, t as OdbReport } from "./report-x9RuNwmr.js";
|
|
58
|
-
import { a as Alignment, i as xmlCodec, n as encodePackage, o as AlignmentSchema, r as packageCodec, s as DocumentTree, t as decodePackage } from "./codec-
|
|
58
|
+
import { a as Alignment, i as xmlCodec, n as encodePackage, o as AlignmentSchema, r as packageCodec, s as DocumentTree, t as decodePackage } from "./codec-BVEK7_Sf.js";
|
|
59
59
|
export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type CascadeDiagnostic, DEFAULT_ODF_VERSION, type DocumentTree, type DrawPageContent, type EmbeddedDocumentKind, type EmbeddedDrawObject, type ImageFormat, type InternRequest, type LengthUnit, MANIFEST_PART, META_PART, MIMETYPE_PART, type Manifest, type ManifestEntry, ManifestEntrySchema, type ManifestProblem, ManifestProblemSchema, ManifestSchema, ODF_MEDIA_TYPES, ODF_NAMESPACES, OOO1_MEDIA_TYPES, OOO1_NAMESPACES, type OdbComponentInfo, type OdbConnectionInfo, type OdbForm, type OdbFormControl, type OdbFormDefinition, type OdbInventory, type OdbQueryInfo, type OdbReport, type OdbReportBand, type OdbReportElement, type OdbReportFunction, type OdbReportGroup, type OdfExtension, type OdfFormulaDocument, type OdfListEntry, type OdfListIdState, type OdfListParagraphReader, type OdfNamespacePrefix, type OdfParagraphWriteOptions, type OdfPoint, type OdfRawPoint, type OdfRawSegment, type OdfRawSubpath, type OdfShapeGeometry, type OdfTextSegment, type OdfTextSegmentKind, type OdfTransformFunction, type OdfViewBox, type OdgDocument, type OdgWriteOptions, type OdmDocument, type OdmSection, type OdpDocument, type OdpWriteOptions, type OdsDocument, type OdsWriteOptions, type OdtDocument, type OdtHeaderFooterPart, type OdtHeaderFooterVariant, type OdtReadOptions, type OdtWriteOptions, type Ooo1Extension, type Ooo1NamespacePrefix, type OtherPartRef, type Package, PackageSchema, type ParsedProperties, type Part, PartSchema, STYLE_FAMILIES, type StyleCascadeResult, type StyleElementChainResult, type StyleFamily, type StyleProperties, StylePropertiesSchema, StyleRegistry, type StyleRegistryOptions, type SubDocumentPackageOptions, TableCursor, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, type ZipEntry, applyOdfTransform, attrValue, base64ToBytes, buildManifest, buildOdfInlineNodes, buildOdfListStyle, buildOdfMetaNodes, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, createOdfPackage, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatOdfNumber, formatOdfPathData, formatOdfViewBox, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isOoo1NamespacePrefix, isOoo1Package, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, mintOdfListNumId, netRotationDeg, normaliseOdgContent, normaliseOdpContent, normaliseOdsContent, normaliseOdtContent, odfMediaTypeForOoo1MediaType, odfParagraphProperties, odfPartContainer, odfRunProperties, ooo1MediaTypeForExtension, ooo1MediaTypeForOdfMediaType, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseOdfLength as parseLength, parseOdfLength, parseLinePoints, parseMargins, parseOdfColor, parseOdfPathData, parseOdfPointsList, parseOdfTransform, parseOdfViewBox, parsePackage, parsePageSize, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, rawSubpathFromPoints, readDrawFrame, readDrawImageBlock, readDrawObjectReference, readDrawPageContent, readManifest, readMimetype, readOdbForm, readOdbInventory, readOdbReport, readOdfFormControlConstructs, readOdfFormDefinitions, readOdfFormula, readOdfFormulaContent, readOdfFormulaMathMl, readOdfListParagraphs, readOdfMetadata, readOdfParagraph, readOdfTable, readOdg, readOdgContent, readOdm, readOdp, readOdpContent, readOds, readOdsContent, readOdt, readOdtContent, readSxc, readSxcContent, readSxd, readSxdContent, readSxi, readSxiContent, readSxw, readSxwContent, resolveDrawPageSize, resolveOdbComponent, resolveOdfListKind, resolveOdfShapeGeometry, resolvePageLayoutProperties, resolveStyle, resolveStyleElementChain, rootElement, scaleOdfRawPoint, segmentOdfParagraphRuns, segmentOdfText, serializePackage, setDocumentMediaType, sniffImageFormat, subDocumentPackage, sumOdfNodeLength, syncManifest, textPropertiesToAttributes, transformOoo1Package, transformToOoo1Package, txt, unzipPackage, validateManifest, walkDrawShapes, writeDrawFrame, writeDrawShapes, writeDrawVector, writeDrawVectors, writeManifest, writeMimetype, writeOdfList, writeOdfMetadata, writeOdfParagraph, writeOdfTable, writeOdg, writeOdgContent, writeOdp, writeOdpContent, writeOds, writeOdsContent, writeOdt, writeOdtContent, writeSxc, writeSxcContent, writeSxd, writeSxdContent, writeSxi, writeSxiContent, writeSxw, writeSxwContent, xmlCodec, xmlnsAttributes, zipPackage };
|
package/dist/manifest.cjs
CHANGED
|
@@ -82,6 +82,8 @@ function resolvePartMediaType(path, bytes, overrides) {
|
|
|
82
82
|
const sniffed = require_image_sniff.sniffImageFormat(bytes);
|
|
83
83
|
if (sniffed === "png") return "image/png";
|
|
84
84
|
if (sniffed === "jpeg") return "image/jpeg";
|
|
85
|
+
if (sniffed === "gif") return "image/gif";
|
|
86
|
+
if (sniffed === "svg") return "image/svg+xml";
|
|
85
87
|
}
|
|
86
88
|
return "";
|
|
87
89
|
}
|
package/dist/manifest.js
CHANGED
|
@@ -81,6 +81,8 @@ function resolvePartMediaType(path, bytes, overrides) {
|
|
|
81
81
|
const sniffed = sniffImageFormat(bytes);
|
|
82
82
|
if (sniffed === "png") return "image/png";
|
|
83
83
|
if (sniffed === "jpeg") return "image/jpeg";
|
|
84
|
+
if (sniffed === "gif") return "image/gif";
|
|
85
|
+
if (sniffed === "svg") return "image/svg+xml";
|
|
84
86
|
}
|
|
85
87
|
return "";
|
|
86
88
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/image/sniff.d.ts
|
|
2
|
-
type ImageFormat = "png" | "jpeg";
|
|
2
|
+
type ImageFormat = "png" | "jpeg" | "gif" | "svg";
|
|
3
3
|
declare function sniffImageFormat(bytes: Uint8Array<ArrayBuffer>): ImageFormat | undefined;
|
|
4
4
|
//#endregion
|
|
5
5
|
export { sniffImageFormat as n, ImageFormat as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/image/sniff.d.ts
|
|
2
|
-
type ImageFormat = "png" | "jpeg";
|
|
2
|
+
type ImageFormat = "png" | "jpeg" | "gif" | "svg";
|
|
3
3
|
declare function sniffImageFormat(bytes: Uint8Array<ArrayBuffer>): ImageFormat | undefined;
|
|
4
4
|
//#endregion
|
|
5
5
|
export { sniffImageFormat as n, ImageFormat as t };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { l as XmlElement } from "./node-B6JX5CRX.js";
|
|
2
2
|
import { r as Package } from "./package-otZYrxiO.js";
|
|
3
3
|
import { a as StyleRegistry } from "./registry-C_16-N6i.js";
|
|
4
|
-
import { Alignment,
|
|
4
|
+
import { Alignment, ContentBorder, ContentCellBorders, ContentCellFill, ContentTable } from "document-schema.js";
|
|
5
5
|
//#region src/typed/shared/table.d.ts
|
|
6
6
|
type BorderEdgeKey = "left" | "right" | "top" | "bottom";
|
|
7
7
|
declare const BORDER_EDGE_KEYS: readonly BorderEdgeKey[];
|
|
8
8
|
declare const BORDER_EDGE_ATTRS: Readonly<Record<BorderEdgeKey, string>>;
|
|
9
9
|
interface CellStyleDecoration {
|
|
10
|
-
background?:
|
|
10
|
+
background?: ContentCellFill;
|
|
11
11
|
borders?: ContentCellBorders;
|
|
12
12
|
alignment?: Alignment;
|
|
13
13
|
verticalAlignment?: "top" | "middle" | "bottom";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { l as XmlElement } from "./node-B6JX5CRX.cjs";
|
|
2
2
|
import { r as Package } from "./package-DMk9fuTI.cjs";
|
|
3
3
|
import { a as StyleRegistry } from "./registry-PoQIRgbY.cjs";
|
|
4
|
-
import { Alignment,
|
|
4
|
+
import { Alignment, ContentBorder, ContentCellBorders, ContentCellFill, ContentTable } from "document-schema.js";
|
|
5
5
|
//#region src/typed/shared/table.d.ts
|
|
6
6
|
type BorderEdgeKey = "left" | "right" | "top" | "bottom";
|
|
7
7
|
declare const BORDER_EDGE_KEYS: readonly BorderEdgeKey[];
|
|
8
8
|
declare const BORDER_EDGE_ATTRS: Readonly<Record<BorderEdgeKey, string>>;
|
|
9
9
|
interface CellStyleDecoration {
|
|
10
|
-
background?:
|
|
10
|
+
background?: ContentCellFill;
|
|
11
11
|
borders?: ContentCellBorders;
|
|
12
12
|
alignment?: Alignment;
|
|
13
13
|
verticalAlignment?: "top" | "middle" | "bottom";
|
|
@@ -5,6 +5,7 @@ const require_typed_shared_units = require("../shared/units.cjs");
|
|
|
5
5
|
const require_typed_shared_list = require("../shared/list.cjs");
|
|
6
6
|
const require_typed_shared_paragraph = require("../shared/paragraph.cjs");
|
|
7
7
|
const require_typed_shared_table = require("../shared/table.cjs");
|
|
8
|
+
const require_typed_shared_image = require("../shared/image.cjs");
|
|
8
9
|
const require_typed_shared_canonicalise = require("../shared/canonicalise.cjs");
|
|
9
10
|
//#region src/typed/draw/write-shapes.ts
|
|
10
11
|
function unsupportedShapeContent(what) {
|
|
@@ -145,7 +146,7 @@ function writeShapeTextBox(paragraphs, state) {
|
|
|
145
146
|
}
|
|
146
147
|
const PICTURES_DIRECTORY = "Pictures";
|
|
147
148
|
function writeShapeImage(image, state) {
|
|
148
|
-
const extension = image.format
|
|
149
|
+
const extension = require_typed_shared_image.imageExtension(image.format);
|
|
149
150
|
const path = `${PICTURES_DIRECTORY}/image${state.nextImage}.${extension}`;
|
|
150
151
|
state.nextImage += 1;
|
|
151
152
|
state.pkg.parts[path] = {
|
|
@@ -4,6 +4,7 @@ import { formatOdfLength, formatOdfNumber } from "../shared/units.js";
|
|
|
4
4
|
import { buildOdfListStyle, closeListPlan, listKindOf, planListMembership, writeOdfList } from "../shared/list.js";
|
|
5
5
|
import { writeOdfParagraph } from "../shared/paragraph.js";
|
|
6
6
|
import { writeOdfTable } from "../shared/table.js";
|
|
7
|
+
import { imageExtension } from "../shared/image.js";
|
|
7
8
|
import { canonicalImage, canonicalParagraph, canonicalTable } from "../shared/canonicalise.js";
|
|
8
9
|
//#region src/typed/draw/write-shapes.ts
|
|
9
10
|
function unsupportedShapeContent(what) {
|
|
@@ -144,7 +145,7 @@ function writeShapeTextBox(paragraphs, state) {
|
|
|
144
145
|
}
|
|
145
146
|
const PICTURES_DIRECTORY = "Pictures";
|
|
146
147
|
function writeShapeImage(image, state) {
|
|
147
|
-
const extension = image.format
|
|
148
|
+
const extension = imageExtension(image.format);
|
|
148
149
|
const path = `${PICTURES_DIRECTORY}/image${state.nextImage}.${extension}`;
|
|
149
150
|
state.nextImage += 1;
|
|
150
151
|
state.pkg.parts[path] = {
|
package/dist/typed/ods/write.cjs
CHANGED
|
@@ -11,6 +11,7 @@ const require_typed_shared_metadata = require("../shared/metadata.cjs");
|
|
|
11
11
|
const require_typed_shared_paragraph = require("../shared/paragraph.cjs");
|
|
12
12
|
const require_typed_shared_table = require("../shared/table.cjs");
|
|
13
13
|
const require_package_io_scaffold = require("../../package-io/scaffold.cjs");
|
|
14
|
+
const require_typed_shared_image = require("../shared/image.cjs");
|
|
14
15
|
require("../../embedded-Bxyss_ck.cjs");
|
|
15
16
|
let document_schema_js = require("document-schema.js");
|
|
16
17
|
//#region src/typed/ods/write.ts
|
|
@@ -94,7 +95,8 @@ function writeCellParagraphs(cell, registry) {
|
|
|
94
95
|
}
|
|
95
96
|
function sheetCellStyle(cell, registry) {
|
|
96
97
|
const cellProperties = {};
|
|
97
|
-
|
|
98
|
+
const backgroundColor = cell.background === void 0 ? void 0 : (0, document_schema_js.resolveCellFillColor)(cell.background);
|
|
99
|
+
if (backgroundColor !== void 0) cellProperties["fo:background-color"] = require_typed_shared_color.formatOdfColor(backgroundColor);
|
|
98
100
|
if (cell.borders !== void 0) for (const edge of require_typed_shared_table.BORDER_EDGE_KEYS) {
|
|
99
101
|
const border = cell.borders[edge];
|
|
100
102
|
if (border !== void 0) cellProperties[require_typed_shared_table.BORDER_EDGE_ATTRS[edge]] = require_typed_shared_table.formatBorderEdge(border);
|
|
@@ -190,7 +192,7 @@ function groupImagesByPosition(images) {
|
|
|
190
192
|
return byPosition;
|
|
191
193
|
}
|
|
192
194
|
function writeSheetImageFrame(image, state) {
|
|
193
|
-
const extension = image.format
|
|
195
|
+
const extension = require_typed_shared_image.imageExtension(image.format);
|
|
194
196
|
const path = `${PICTURES_DIRECTORY}/image${state.nextImage}.${extension}`;
|
|
195
197
|
state.nextImage += 1;
|
|
196
198
|
state.pkg.parts[path] = {
|
|
@@ -356,6 +358,13 @@ function writeSheet(sheet, state) {
|
|
|
356
358
|
function canonicalColor(color) {
|
|
357
359
|
return (0, document_schema_js.rgbHexToColor)((0, document_schema_js.colorToRgbHex)(color));
|
|
358
360
|
}
|
|
361
|
+
function canonicalCellFill(fill) {
|
|
362
|
+
const color = (0, document_schema_js.resolveCellFillColor)(fill);
|
|
363
|
+
return color === void 0 ? void 0 : {
|
|
364
|
+
kind: "solid",
|
|
365
|
+
color: canonicalColor(color)
|
|
366
|
+
};
|
|
367
|
+
}
|
|
359
368
|
function canonicalRun(run) {
|
|
360
369
|
const canonical = { text: run.text };
|
|
361
370
|
if (run.bold !== void 0) canonical.bold = run.bold;
|
|
@@ -430,7 +439,7 @@ function canonicalCell(cell) {
|
|
|
430
439
|
if (runs.length > 0) canonical.runs = runs;
|
|
431
440
|
if (cell.colSpan !== void 0) canonical.colSpan = cell.colSpan;
|
|
432
441
|
if (cell.rowSpan !== void 0) canonical.rowSpan = cell.rowSpan;
|
|
433
|
-
if (cell.background !== void 0) canonical.background =
|
|
442
|
+
if (cell.background !== void 0) canonical.background = canonicalCellFill(cell.background);
|
|
434
443
|
if (cell.borders !== void 0) {
|
|
435
444
|
const borders = {};
|
|
436
445
|
for (const edge of require_typed_shared_table.BORDER_EDGE_KEYS) {
|
package/dist/typed/ods/write.js
CHANGED
|
@@ -10,8 +10,9 @@ import { writeOdfMetadata } from "../shared/metadata.js";
|
|
|
10
10
|
import { segmentOdfParagraphRuns, writeOdfParagraph } from "../shared/paragraph.js";
|
|
11
11
|
import { BORDER_EDGE_ATTRS, BORDER_EDGE_KEYS, formatBorderEdge } from "../shared/table.js";
|
|
12
12
|
import { createOdfPackage, odfPartContainer } from "../../package-io/scaffold.js";
|
|
13
|
+
import { imageExtension } from "../shared/image.js";
|
|
13
14
|
import "../../embedded-BnavfkP-.js";
|
|
14
|
-
import { colorToRgbHex, flattenTree, rgbHexToColor } from "document-schema.js";
|
|
15
|
+
import { colorToRgbHex, flattenTree, resolveCellFillColor, rgbHexToColor } from "document-schema.js";
|
|
15
16
|
//#region src/typed/ods/write.ts
|
|
16
17
|
const CONTENT_PART = "content.xml";
|
|
17
18
|
const STYLES_PART = "styles.xml";
|
|
@@ -93,7 +94,8 @@ function writeCellParagraphs(cell, registry) {
|
|
|
93
94
|
}
|
|
94
95
|
function sheetCellStyle(cell, registry) {
|
|
95
96
|
const cellProperties = {};
|
|
96
|
-
|
|
97
|
+
const backgroundColor = cell.background === void 0 ? void 0 : resolveCellFillColor(cell.background);
|
|
98
|
+
if (backgroundColor !== void 0) cellProperties["fo:background-color"] = formatOdfColor(backgroundColor);
|
|
97
99
|
if (cell.borders !== void 0) for (const edge of BORDER_EDGE_KEYS) {
|
|
98
100
|
const border = cell.borders[edge];
|
|
99
101
|
if (border !== void 0) cellProperties[BORDER_EDGE_ATTRS[edge]] = formatBorderEdge(border);
|
|
@@ -189,7 +191,7 @@ function groupImagesByPosition(images) {
|
|
|
189
191
|
return byPosition;
|
|
190
192
|
}
|
|
191
193
|
function writeSheetImageFrame(image, state) {
|
|
192
|
-
const extension = image.format
|
|
194
|
+
const extension = imageExtension(image.format);
|
|
193
195
|
const path = `${PICTURES_DIRECTORY}/image${state.nextImage}.${extension}`;
|
|
194
196
|
state.nextImage += 1;
|
|
195
197
|
state.pkg.parts[path] = {
|
|
@@ -355,6 +357,13 @@ function writeSheet(sheet, state) {
|
|
|
355
357
|
function canonicalColor(color) {
|
|
356
358
|
return rgbHexToColor(colorToRgbHex(color));
|
|
357
359
|
}
|
|
360
|
+
function canonicalCellFill(fill) {
|
|
361
|
+
const color = resolveCellFillColor(fill);
|
|
362
|
+
return color === void 0 ? void 0 : {
|
|
363
|
+
kind: "solid",
|
|
364
|
+
color: canonicalColor(color)
|
|
365
|
+
};
|
|
366
|
+
}
|
|
358
367
|
function canonicalRun(run) {
|
|
359
368
|
const canonical = { text: run.text };
|
|
360
369
|
if (run.bold !== void 0) canonical.bold = run.bold;
|
|
@@ -429,7 +438,7 @@ function canonicalCell(cell) {
|
|
|
429
438
|
if (runs.length > 0) canonical.runs = runs;
|
|
430
439
|
if (cell.colSpan !== void 0) canonical.colSpan = cell.colSpan;
|
|
431
440
|
if (cell.rowSpan !== void 0) canonical.rowSpan = cell.rowSpan;
|
|
432
|
-
if (cell.background !== void 0) canonical.background =
|
|
441
|
+
if (cell.background !== void 0) canonical.background = canonicalCellFill(cell.background);
|
|
433
442
|
if (cell.borders !== void 0) {
|
|
434
443
|
const borders = {};
|
|
435
444
|
for (const edge of BORDER_EDGE_KEYS) {
|
package/dist/typed/odt/write.cjs
CHANGED
|
@@ -10,6 +10,7 @@ const require_typed_shared_list = require("../shared/list.cjs");
|
|
|
10
10
|
const require_typed_shared_paragraph = require("../shared/paragraph.cjs");
|
|
11
11
|
const require_typed_shared_table = require("../shared/table.cjs");
|
|
12
12
|
const require_package_io_scaffold = require("../../package-io/scaffold.cjs");
|
|
13
|
+
const require_typed_shared_image = require("../shared/image.cjs");
|
|
13
14
|
const require_typed_shared_canonicalise = require("../shared/canonicalise.cjs");
|
|
14
15
|
let document_schema_js = require("document-schema.js");
|
|
15
16
|
//#region src/typed/odt/write.ts
|
|
@@ -163,7 +164,7 @@ function listStyleNameFor(kind, state) {
|
|
|
163
164
|
return name;
|
|
164
165
|
}
|
|
165
166
|
function writeImageFrame(image, state) {
|
|
166
|
-
const extension = image.format
|
|
167
|
+
const extension = require_typed_shared_image.imageExtension(image.format);
|
|
167
168
|
const path = `${PICTURES_DIRECTORY}/image${state.nextImage}.${extension}`;
|
|
168
169
|
state.nextImage += 1;
|
|
169
170
|
state.pkg.parts[path] = {
|
package/dist/typed/odt/write.js
CHANGED
|
@@ -9,6 +9,7 @@ import { buildOdfListStyle, closeListPlan, listKindOf, planListMembership, write
|
|
|
9
9
|
import { writeOdfParagraph } from "../shared/paragraph.js";
|
|
10
10
|
import { writeOdfTable } from "../shared/table.js";
|
|
11
11
|
import { createOdfPackage, odfPartContainer } from "../../package-io/scaffold.js";
|
|
12
|
+
import { imageExtension } from "../shared/image.js";
|
|
12
13
|
import { canonicalImage, canonicalMetadata, canonicalParagraph, canonicalTable } from "../shared/canonicalise.js";
|
|
13
14
|
import { flattenTree } from "document-schema.js";
|
|
14
15
|
//#region src/typed/odt/write.ts
|
|
@@ -162,7 +163,7 @@ function listStyleNameFor(kind, state) {
|
|
|
162
163
|
return name;
|
|
163
164
|
}
|
|
164
165
|
function writeImageFrame(image, state) {
|
|
165
|
-
const extension = image.format
|
|
166
|
+
const extension = imageExtension(image.format);
|
|
166
167
|
const path = `${PICTURES_DIRECTORY}/image${state.nextImage}.${extension}`;
|
|
167
168
|
state.nextImage += 1;
|
|
168
169
|
state.pkg.parts[path] = {
|
|
@@ -8,6 +8,13 @@ function unsupportedContent(what, where) {
|
|
|
8
8
|
function canonicalColor(color) {
|
|
9
9
|
return (0, document_schema_js.rgbHexToColor)((0, document_schema_js.colorToRgbHex)(color));
|
|
10
10
|
}
|
|
11
|
+
function canonicalCellFill(fill) {
|
|
12
|
+
const color = (0, document_schema_js.resolveCellFillColor)(fill);
|
|
13
|
+
return color === void 0 ? void 0 : {
|
|
14
|
+
kind: "solid",
|
|
15
|
+
color: canonicalColor(color)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
11
18
|
function canonicalRun(run) {
|
|
12
19
|
const canonical = { text: run.text };
|
|
13
20
|
if (run.bold !== void 0) canonical.bold = run.bold;
|
|
@@ -52,7 +59,7 @@ function canonicalCell(cell, covered) {
|
|
|
52
59
|
}) };
|
|
53
60
|
if (cell.colSpan !== void 0) canonical.colSpan = cell.colSpan;
|
|
54
61
|
if (cell.rowSpan !== void 0) canonical.rowSpan = cell.rowSpan;
|
|
55
|
-
if (cell.background !== void 0) canonical.background =
|
|
62
|
+
if (cell.background !== void 0) canonical.background = canonicalCellFill(cell.background);
|
|
56
63
|
if (cell.borders !== void 0) {
|
|
57
64
|
const borders = {};
|
|
58
65
|
for (const edge of [
|
|
@@ -118,6 +125,7 @@ function canonicalImage(image) {
|
|
|
118
125
|
return canonical;
|
|
119
126
|
}
|
|
120
127
|
//#endregion
|
|
128
|
+
exports.canonicalCellFill = canonicalCellFill;
|
|
121
129
|
exports.canonicalColor = canonicalColor;
|
|
122
130
|
exports.canonicalImage = canonicalImage;
|
|
123
131
|
exports.canonicalMetadata = canonicalMetadata;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Color, ContentImageBlock, ContentParagraph, ContentRun, ContentTable, LayoutMetadata } from "document-schema.js";
|
|
1
|
+
import { Color, ContentCellFill, ContentImageBlock, ContentParagraph, ContentRun, ContentTable, LayoutMetadata } from "document-schema.js";
|
|
2
2
|
//#region src/typed/shared/canonicalise.d.ts
|
|
3
3
|
declare function canonicalColor(color: Color): Color;
|
|
4
|
+
declare function canonicalCellFill(fill: ContentCellFill): ContentCellFill | undefined;
|
|
4
5
|
declare function canonicalRun(run: ContentRun): ContentRun;
|
|
5
6
|
declare function canonicalParagraph(paragraph: ContentParagraph, listNumId: string | undefined): ContentParagraph;
|
|
6
7
|
declare function canonicalTable(table: ContentTable): ContentTable;
|
|
7
8
|
declare function canonicalMetadata(metadata: LayoutMetadata): LayoutMetadata;
|
|
8
9
|
declare function canonicalImage(image: ContentImageBlock): ContentImageBlock;
|
|
9
10
|
//#endregion
|
|
10
|
-
export { canonicalColor, canonicalImage, canonicalMetadata, canonicalParagraph, canonicalRun, canonicalTable };
|
|
11
|
+
export { canonicalCellFill, canonicalColor, canonicalImage, canonicalMetadata, canonicalParagraph, canonicalRun, canonicalTable };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Color, ContentImageBlock, ContentParagraph, ContentRun, ContentTable, LayoutMetadata } from "document-schema.js";
|
|
1
|
+
import { Color, ContentCellFill, ContentImageBlock, ContentParagraph, ContentRun, ContentTable, LayoutMetadata } from "document-schema.js";
|
|
2
2
|
//#region src/typed/shared/canonicalise.d.ts
|
|
3
3
|
declare function canonicalColor(color: Color): Color;
|
|
4
|
+
declare function canonicalCellFill(fill: ContentCellFill): ContentCellFill | undefined;
|
|
4
5
|
declare function canonicalRun(run: ContentRun): ContentRun;
|
|
5
6
|
declare function canonicalParagraph(paragraph: ContentParagraph, listNumId: string | undefined): ContentParagraph;
|
|
6
7
|
declare function canonicalTable(table: ContentTable): ContentTable;
|
|
7
8
|
declare function canonicalMetadata(metadata: LayoutMetadata): LayoutMetadata;
|
|
8
9
|
declare function canonicalImage(image: ContentImageBlock): ContentImageBlock;
|
|
9
10
|
//#endregion
|
|
10
|
-
export { canonicalColor, canonicalImage, canonicalMetadata, canonicalParagraph, canonicalRun, canonicalTable };
|
|
11
|
+
export { canonicalCellFill, canonicalColor, canonicalImage, canonicalMetadata, canonicalParagraph, canonicalRun, canonicalTable };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { segmentOdfParagraphRuns } from "./paragraph.js";
|
|
2
|
-
import { colorToRgbHex, rgbHexToColor } from "document-schema.js";
|
|
2
|
+
import { colorToRgbHex, resolveCellFillColor, rgbHexToColor } from "document-schema.js";
|
|
3
3
|
//#region src/typed/shared/canonicalise.ts
|
|
4
4
|
function unsupportedContent(what, where) {
|
|
5
5
|
return /* @__PURE__ */ new Error(`${where} carries ${what}, which no ODF writer in this package can produce yet -- refusing to state a canonical form for content that would be silently lost on write. See ExaDev/documents.js for the tracked follow-up covering the fidelity constructs and embedded objects.`);
|
|
@@ -7,6 +7,13 @@ function unsupportedContent(what, where) {
|
|
|
7
7
|
function canonicalColor(color) {
|
|
8
8
|
return rgbHexToColor(colorToRgbHex(color));
|
|
9
9
|
}
|
|
10
|
+
function canonicalCellFill(fill) {
|
|
11
|
+
const color = resolveCellFillColor(fill);
|
|
12
|
+
return color === void 0 ? void 0 : {
|
|
13
|
+
kind: "solid",
|
|
14
|
+
color: canonicalColor(color)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
10
17
|
function canonicalRun(run) {
|
|
11
18
|
const canonical = { text: run.text };
|
|
12
19
|
if (run.bold !== void 0) canonical.bold = run.bold;
|
|
@@ -51,7 +58,7 @@ function canonicalCell(cell, covered) {
|
|
|
51
58
|
}) };
|
|
52
59
|
if (cell.colSpan !== void 0) canonical.colSpan = cell.colSpan;
|
|
53
60
|
if (cell.rowSpan !== void 0) canonical.rowSpan = cell.rowSpan;
|
|
54
|
-
if (cell.background !== void 0) canonical.background =
|
|
61
|
+
if (cell.background !== void 0) canonical.background = canonicalCellFill(cell.background);
|
|
55
62
|
if (cell.borders !== void 0) {
|
|
56
63
|
const borders = {};
|
|
57
64
|
for (const edge of [
|
|
@@ -117,4 +124,4 @@ function canonicalImage(image) {
|
|
|
117
124
|
return canonical;
|
|
118
125
|
}
|
|
119
126
|
//#endregion
|
|
120
|
-
export { canonicalColor, canonicalImage, canonicalMetadata, canonicalParagraph, canonicalRun, canonicalTable };
|
|
127
|
+
export { canonicalCellFill, canonicalColor, canonicalImage, canonicalMetadata, canonicalParagraph, canonicalRun, canonicalTable };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/typed/shared/image.ts
|
|
3
|
+
function imageExtension(format) {
|
|
4
|
+
switch (format) {
|
|
5
|
+
case "png": return "png";
|
|
6
|
+
case "jpeg": return "jpg";
|
|
7
|
+
case "svg": return "svg";
|
|
8
|
+
case "gif": return "gif";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.imageExtension = imageExtension;
|
|
@@ -6,6 +6,7 @@ const require_typed_shared_color = require("./color.cjs");
|
|
|
6
6
|
const require_xml_query = require("../../xml/query.cjs");
|
|
7
7
|
const require_typed_shared_cascade = require("./cascade.cjs");
|
|
8
8
|
const require_typed_shared_paragraph = require("./paragraph.cjs");
|
|
9
|
+
let document_schema_js = require("document-schema.js");
|
|
9
10
|
//#region src/typed/shared/table.ts
|
|
10
11
|
function readRepeatCount(element, attrName) {
|
|
11
12
|
const raw = require_xml_query.attrValue(element, attrName);
|
|
@@ -110,7 +111,10 @@ function readCellStyleDecoration(elements) {
|
|
|
110
111
|
if (textAlignValue === "left" || textAlignValue === "center" || textAlignValue === "right" || textAlignValue === "justify") alignment = textAlignValue;
|
|
111
112
|
}
|
|
112
113
|
return {
|
|
113
|
-
background
|
|
114
|
+
background: background === void 0 ? void 0 : {
|
|
115
|
+
kind: "solid",
|
|
116
|
+
color: background
|
|
117
|
+
},
|
|
114
118
|
borders: bordersFromAccumulated(borderAccumulator),
|
|
115
119
|
alignment,
|
|
116
120
|
verticalAlignment
|
|
@@ -175,7 +179,8 @@ function formatBorderEdge(border) {
|
|
|
175
179
|
}
|
|
176
180
|
function tableCellStyle(cell, registry) {
|
|
177
181
|
const attributes = {};
|
|
178
|
-
|
|
182
|
+
const backgroundColor = cell.background === void 0 ? void 0 : (0, document_schema_js.resolveCellFillColor)(cell.background);
|
|
183
|
+
if (backgroundColor !== void 0) attributes["fo:background-color"] = require_typed_shared_color.formatOdfColor(backgroundColor);
|
|
179
184
|
const borders = cell.borders;
|
|
180
185
|
if (borders !== void 0) for (const edge of BORDER_EDGE_KEYS) {
|
|
181
186
|
const border = borders[edge];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as formatBorderEdge, c as writeOdfTable, i as CellStyleDecoration, n as BORDER_EDGE_KEYS, o as readCellStyleDecoration, r as BorderEdgeKey, s as readOdfTable, t as BORDER_EDGE_ATTRS } from "../../table-
|
|
1
|
+
import { a as formatBorderEdge, c as writeOdfTable, i as CellStyleDecoration, n as BORDER_EDGE_KEYS, o as readCellStyleDecoration, r as BorderEdgeKey, s as readOdfTable, t as BORDER_EDGE_ATTRS } from "../../table-DWTKLvxt.cjs";
|
|
2
2
|
export { BORDER_EDGE_ATTRS, BORDER_EDGE_KEYS, BorderEdgeKey, CellStyleDecoration, formatBorderEdge, readCellStyleDecoration, readOdfTable, writeOdfTable };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as formatBorderEdge, c as writeOdfTable, i as CellStyleDecoration, n as BORDER_EDGE_KEYS, o as readCellStyleDecoration, r as BorderEdgeKey, s as readOdfTable, t as BORDER_EDGE_ATTRS } from "../../table-
|
|
1
|
+
import { a as formatBorderEdge, c as writeOdfTable, i as CellStyleDecoration, n as BORDER_EDGE_KEYS, o as readCellStyleDecoration, r as BorderEdgeKey, s as readOdfTable, t as BORDER_EDGE_ATTRS } from "../../table-B_LX8Dgy.js";
|
|
2
2
|
export { BORDER_EDGE_ATTRS, BORDER_EDGE_KEYS, BorderEdgeKey, CellStyleDecoration, formatBorderEdge, readCellStyleDecoration, readOdfTable, writeOdfTable };
|
|
@@ -5,6 +5,7 @@ import { formatOdfColor, parseOdfColor } from "./color.js";
|
|
|
5
5
|
import { attrValue, childrenWithTag } from "../../xml/query.js";
|
|
6
6
|
import { findStyleElement } from "./cascade.js";
|
|
7
7
|
import { readOdfParagraph, readParagraphOrHeading, writeOdfParagraph } from "./paragraph.js";
|
|
8
|
+
import { resolveCellFillColor } from "document-schema.js";
|
|
8
9
|
//#region src/typed/shared/table.ts
|
|
9
10
|
function readRepeatCount(element, attrName) {
|
|
10
11
|
const raw = attrValue(element, attrName);
|
|
@@ -109,7 +110,10 @@ function readCellStyleDecoration(elements) {
|
|
|
109
110
|
if (textAlignValue === "left" || textAlignValue === "center" || textAlignValue === "right" || textAlignValue === "justify") alignment = textAlignValue;
|
|
110
111
|
}
|
|
111
112
|
return {
|
|
112
|
-
background
|
|
113
|
+
background: background === void 0 ? void 0 : {
|
|
114
|
+
kind: "solid",
|
|
115
|
+
color: background
|
|
116
|
+
},
|
|
113
117
|
borders: bordersFromAccumulated(borderAccumulator),
|
|
114
118
|
alignment,
|
|
115
119
|
verticalAlignment
|
|
@@ -174,7 +178,8 @@ function formatBorderEdge(border) {
|
|
|
174
178
|
}
|
|
175
179
|
function tableCellStyle(cell, registry) {
|
|
176
180
|
const attributes = {};
|
|
177
|
-
|
|
181
|
+
const backgroundColor = cell.background === void 0 ? void 0 : resolveCellFillColor(cell.background);
|
|
182
|
+
if (backgroundColor !== void 0) attributes["fo:background-color"] = formatOdfColor(backgroundColor);
|
|
178
183
|
const borders = cell.borders;
|
|
179
184
|
if (borders !== void 0) for (const edge of BORDER_EDGE_KEYS) {
|
|
180
185
|
const border = borders[edge];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odf.js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Type-safe, lossless round-trip conversion between OpenDocument Format packages (odt, ods, odp) and JSON, plus read support for the pre-OASIS OpenOffice.org 1.x documents ODF was based on (sxw, sxc, sxi, sxd), hand-written and dependency-minimal, built on Zod 4 codecs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"license": "MIT",
|
|
86
86
|
"packageManager": "pnpm@11.6.0",
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"document-schema.js": "^
|
|
88
|
+
"document-schema.js": "^6.0.0",
|
|
89
89
|
"fast-xml-parser": "^5.10.1",
|
|
90
90
|
"fflate": "^0.8.3",
|
|
91
91
|
"zod": "^4.4.3"
|