odf.js 7.1.2 → 7.1.3
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 +2 -0
- package/dist/{codec-BVEK7_Sf.d.ts → codec-CawKgF1n.d.ts} +1 -1
- package/dist/{codec-aKINptZk.d.cts → codec-Di-8iz7o.d.cts} +1 -1
- package/dist/codec.d.cts +1 -1
- package/dist/codec.d.ts +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/{paragraph-DtC86tft.d.ts → paragraph-CU1E9yXq.d.ts} +2 -1
- package/dist/{paragraph-Bf6Iq5wC.d.cts → paragraph-Y2hh0bh2.d.cts} +2 -1
- package/dist/typed/odt/write.cjs +1 -0
- package/dist/typed/odt/write.js +2 -1
- package/dist/typed/shared/canonicalise.cjs +1 -0
- package/dist/typed/shared/canonicalise.js +1 -0
- package/dist/typed/shared/paragraph.cjs +15 -3
- package/dist/typed/shared/paragraph.d.cts +2 -2
- package/dist/typed/shared/paragraph.d.ts +2 -2
- package/dist/typed/shared/paragraph.js +15 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -148,6 +148,8 @@ Paragraphs, headings, runs (character formatting, hyperlinks), whitespace, lists
|
|
|
148
148
|
|
|
149
149
|
The fidelity constructs `readOdt` reads (fields, bookmarks, notes, annotations, tracked changes, divisions, index wrappers, forms) and embedded objects are refused **by name** rather than silently dropped — a block or paragraph carrying one throws naming exactly what it carries, since writing a document that silently lost semantic content would be worse than not writing it at all. The one deliberate exception is the quarantined residue channel: residue is opaque by construction, so re-emitting it would be actively wrong rather than merely incomplete, and it is dropped instead, a known, tracked restorable-fidelity gap rather than a silent one.
|
|
150
150
|
|
|
151
|
+
`document-schema.js`'s cross-format `ContentParagraph.preformatted` flag ([ExaDev/documents.js#1020](https://github.com/ExaDev/documents.js/issues/1020)) round-trips through `readOdt`/`writeOdt` via ODF's own predefined `Preformatted_20_Text` paragraph style (LibreOffice's real raw `style:name`, its display name's space encoded as `_20_` — the identical convention `Heading_20_1`/`Text_20_body` already follow): `readOdfParagraph` recognises the style anywhere in a paragraph's resolved `style:parent-style-name` chain, not only a direct reference, since real pasted-preformatted content typically arrives through an automatic style whose parent resolves to it; `writeOdt`/`writeOdtContent` reference it back the same way, and mint the predefined style element itself once per document so the reference actually resolves on a later read. Two narrow, documented scopes: the predefined style element is minted only by the odt writer (a table cell's own paragraphs share odt's styles part and are covered too, but `.ods` cell text and `.odp`/`.odg` shape text are not — `preformatted` written through either still degrades gracefully to "not preformatted" on its own re-read, never a crash or corrupted output); and on the one paragraph that is BOTH the first paragraph of a second-or-later section (odt's own page-style-switch anchor) AND preformatted, the page-style switch wins — ODF's `style:parent-style-name` is single-valued, so the two facts cannot both ride it at once, and every other preformatted paragraph in the document is unaffected.
|
|
152
|
+
|
|
151
153
|
`.odt`, `.ods`, `.odp`, and `.odg` all have a writer today (see [Status](#status)).
|
|
152
154
|
|
|
153
155
|
`writeOds`/`writeOdsContent` are the same shape, over `readOds`/`readOdsContent`:
|
|
@@ -18,7 +18,7 @@ import "./text-B8350HA2.js";
|
|
|
18
18
|
import "./cascade-PDS3hgrP.js";
|
|
19
19
|
import "./metadata-BUzwE_-u.js";
|
|
20
20
|
import "./list-7FO0SDqZ.js";
|
|
21
|
-
import "./paragraph-
|
|
21
|
+
import "./paragraph-CU1E9yXq.js";
|
|
22
22
|
import "./table-B_LX8Dgy.js";
|
|
23
23
|
import "./scaffold-ehGsIpZ5.js";
|
|
24
24
|
import "./transform-BFNc16LQ.js";
|
|
@@ -18,7 +18,7 @@ import "./text-pmlTqzgi.cjs";
|
|
|
18
18
|
import "./cascade-BpMwrjkB.cjs";
|
|
19
19
|
import "./metadata-CYXgXL_h.cjs";
|
|
20
20
|
import "./list-BorrTJBY.cjs";
|
|
21
|
-
import "./paragraph-
|
|
21
|
+
import "./paragraph-Y2hh0bh2.cjs";
|
|
22
22
|
import "./table-DWTKLvxt.cjs";
|
|
23
23
|
import "./scaffold-44EIMGll.cjs";
|
|
24
24
|
import "./transform-M1gbHp4j.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-Di-8iz7o.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-CawKgF1n.js";
|
|
2
2
|
export { decodePackage, encodePackage, packageCodec, xmlCodec };
|
package/dist/index.d.cts
CHANGED
|
@@ -26,7 +26,7 @@ import { a as decodeOdfText, c as measureOdfNodeLength, i as buildOdfInlineNodes
|
|
|
26
26
|
import { a as resolveStyle, i as findStyleElement, n as StyleCascadeResult, o as resolveStyleElementChain, r as StyleElementChainResult, t as CascadeDiagnostic } from "./cascade-BpMwrjkB.cjs";
|
|
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
|
-
import {
|
|
29
|
+
import { i as odfRunProperties, l as segmentOdfParagraphRuns, n as OdfParagraphWriteOptions, r as odfParagraphProperties, s as readOdfParagraph, u as writeOdfParagraph } from "./paragraph-Y2hh0bh2.cjs";
|
|
30
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";
|
|
@@ -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-Di-8iz7o.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
|
@@ -26,7 +26,7 @@ import { a as decodeOdfText, c as measureOdfNodeLength, i as buildOdfInlineNodes
|
|
|
26
26
|
import { a as resolveStyle, i as findStyleElement, n as StyleCascadeResult, o as resolveStyleElementChain, r as StyleElementChainResult, t as CascadeDiagnostic } from "./cascade-PDS3hgrP.js";
|
|
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
|
-
import {
|
|
29
|
+
import { i as odfRunProperties, l as segmentOdfParagraphRuns, n as OdfParagraphWriteOptions, r as odfParagraphProperties, s as readOdfParagraph, u as writeOdfParagraph } from "./paragraph-CU1E9yXq.js";
|
|
30
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";
|
|
@@ -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-CawKgF1n.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 };
|
|
@@ -14,6 +14,7 @@ interface OdfParagraphContext {
|
|
|
14
14
|
readonly format?: OdfResidueFormat;
|
|
15
15
|
}
|
|
16
16
|
declare function readOdfConstructBodyBlocks(body: XmlElement, pkg: Package, context: OdfParagraphContext, listIdState: OdfListIdState): ContentBlock[];
|
|
17
|
+
declare function preformattedStyleElement(): XmlElement;
|
|
17
18
|
declare function readOdfParagraph(pElement: XmlElement, pkg: Package, context?: OdfParagraphContext): ContentParagraph;
|
|
18
19
|
declare function readParagraphOrHeading(element: XmlElement, paragraph: ContentParagraph): ContentParagraph;
|
|
19
20
|
declare function odfRunProperties(run: ContentRun): StyleProperties;
|
|
@@ -25,4 +26,4 @@ interface OdfParagraphWriteOptions {
|
|
|
25
26
|
}
|
|
26
27
|
declare function writeOdfParagraph(paragraph: ContentParagraph, registry: StyleRegistry, options?: OdfParagraphWriteOptions): XmlElement;
|
|
27
28
|
//#endregion
|
|
28
|
-
export {
|
|
29
|
+
export { preformattedStyleElement as a, readParagraphOrHeading as c, odfRunProperties as i, segmentOdfParagraphRuns as l, OdfParagraphWriteOptions as n, readOdfConstructBodyBlocks as o, odfParagraphProperties as r, readOdfParagraph as s, OdfParagraphContext as t, writeOdfParagraph as u };
|
|
@@ -14,6 +14,7 @@ interface OdfParagraphContext {
|
|
|
14
14
|
readonly format?: OdfResidueFormat;
|
|
15
15
|
}
|
|
16
16
|
declare function readOdfConstructBodyBlocks(body: XmlElement, pkg: Package, context: OdfParagraphContext, listIdState: OdfListIdState): ContentBlock[];
|
|
17
|
+
declare function preformattedStyleElement(): XmlElement;
|
|
17
18
|
declare function readOdfParagraph(pElement: XmlElement, pkg: Package, context?: OdfParagraphContext): ContentParagraph;
|
|
18
19
|
declare function readParagraphOrHeading(element: XmlElement, paragraph: ContentParagraph): ContentParagraph;
|
|
19
20
|
declare function odfRunProperties(run: ContentRun): StyleProperties;
|
|
@@ -25,4 +26,4 @@ interface OdfParagraphWriteOptions {
|
|
|
25
26
|
}
|
|
26
27
|
declare function writeOdfParagraph(paragraph: ContentParagraph, registry: StyleRegistry, options?: OdfParagraphWriteOptions): XmlElement;
|
|
27
28
|
//#endregion
|
|
28
|
-
export {
|
|
29
|
+
export { preformattedStyleElement as a, readParagraphOrHeading as c, odfRunProperties as i, segmentOdfParagraphRuns as l, OdfParagraphWriteOptions as n, readOdfConstructBodyBlocks as o, odfParagraphProperties as r, readOdfParagraph as s, OdfParagraphContext as t, writeOdfParagraph as u };
|
package/dist/typed/odt/write.cjs
CHANGED
|
@@ -254,6 +254,7 @@ function writeOdtContent(document, options = {}) {
|
|
|
254
254
|
nextListStyle: 1,
|
|
255
255
|
listStyleByKind: /* @__PURE__ */ new Map()
|
|
256
256
|
};
|
|
257
|
+
state.stylesNamedStyles.children.push(require_typed_shared_paragraph.preformattedStyleElement());
|
|
257
258
|
const planned = planDocument(document.sections);
|
|
258
259
|
for (const [index, section] of planned.entries()) {
|
|
259
260
|
const masterPageName = `MP${index + 1}`;
|
package/dist/typed/odt/write.js
CHANGED
|
@@ -6,7 +6,7 @@ import { formatOdfLength } from "../shared/units.js";
|
|
|
6
6
|
import { StyleRegistry } from "../../styles/registry.js";
|
|
7
7
|
import { writeOdfMetadata } from "../shared/metadata.js";
|
|
8
8
|
import { buildOdfListStyle, closeListPlan, listKindOf, planListMembership, writeOdfList } from "../shared/list.js";
|
|
9
|
-
import { writeOdfParagraph } from "../shared/paragraph.js";
|
|
9
|
+
import { preformattedStyleElement, writeOdfParagraph } from "../shared/paragraph.js";
|
|
10
10
|
import { writeOdfTable } from "../shared/table.js";
|
|
11
11
|
import { createOdfPackage, odfPartContainer } from "../../package-io/scaffold.js";
|
|
12
12
|
import { imageExtension } from "../shared/image.js";
|
|
@@ -253,6 +253,7 @@ function writeOdtContent(document, options = {}) {
|
|
|
253
253
|
nextListStyle: 1,
|
|
254
254
|
listStyleByKind: /* @__PURE__ */ new Map()
|
|
255
255
|
};
|
|
256
|
+
state.stylesNamedStyles.children.push(preformattedStyleElement());
|
|
256
257
|
const planned = planDocument(document.sections);
|
|
257
258
|
for (const [index, section] of planned.entries()) {
|
|
258
259
|
const masterPageName = `MP${index + 1}`;
|
|
@@ -38,6 +38,7 @@ function canonicalParagraph(paragraph, listNumId) {
|
|
|
38
38
|
canonical.styleId = `Heading${paragraph.headingLevel}`;
|
|
39
39
|
}
|
|
40
40
|
if (paragraph.alignment !== void 0) canonical.alignment = paragraph.alignment;
|
|
41
|
+
if (paragraph.preformatted !== void 0) canonical.preformatted = paragraph.preformatted;
|
|
41
42
|
if (listNumId !== void 0 && paragraph.list !== void 0) canonical.list = {
|
|
42
43
|
numId: listNumId,
|
|
43
44
|
level: paragraph.list.level
|
|
@@ -37,6 +37,7 @@ function canonicalParagraph(paragraph, listNumId) {
|
|
|
37
37
|
canonical.styleId = `Heading${paragraph.headingLevel}`;
|
|
38
38
|
}
|
|
39
39
|
if (paragraph.alignment !== void 0) canonical.alignment = paragraph.alignment;
|
|
40
|
+
if (paragraph.preformatted !== void 0) canonical.preformatted = paragraph.preformatted;
|
|
40
41
|
if (listNumId !== void 0 && paragraph.list !== void 0) canonical.list = {
|
|
41
42
|
numId: listNumId,
|
|
42
43
|
level: paragraph.list.level
|
|
@@ -218,9 +218,18 @@ function runFromText(text, properties) {
|
|
|
218
218
|
color: properties.color
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
|
+
const PREFORMATTED_STYLE_NAME = "Preformatted_20_Text";
|
|
222
|
+
function preformattedStyleElement() {
|
|
223
|
+
return require_xml_fragment.el("style:style", {
|
|
224
|
+
"style:name": PREFORMATTED_STYLE_NAME,
|
|
225
|
+
"style:family": "paragraph"
|
|
226
|
+
});
|
|
227
|
+
}
|
|
221
228
|
function readOdfParagraph(pElement, pkg, context = {}) {
|
|
222
229
|
const styleName = require_xml_query.attrValue(pElement, "text:style-name");
|
|
223
230
|
const paragraphProperties = require_typed_shared_cascade.resolveStyle(styleName, "paragraph", pkg).properties;
|
|
231
|
+
const styleChain = require_typed_shared_cascade.resolveStyleElementChain(styleName, "paragraph", pkg).elements;
|
|
232
|
+
const isPreformatted = styleChain.some((style) => require_xml_query.attrValue(style, "style:name") === PREFORMATTED_STYLE_NAME);
|
|
224
233
|
const runs = [];
|
|
225
234
|
const walk = {
|
|
226
235
|
extents: [],
|
|
@@ -235,7 +244,7 @@ function readOdfParagraph(pElement, pkg, context = {}) {
|
|
|
235
244
|
let source;
|
|
236
245
|
if (context.format !== void 0) {
|
|
237
246
|
const residueElements = [];
|
|
238
|
-
if (styleName !== void 0) residueElements.push(...
|
|
247
|
+
if (styleName !== void 0) residueElements.push(...styleChain.flatMap((style) => [...require_xml_query.childrenWithTag(style, "style:paragraph-properties").filter((properties) => require_styles_properties.parseParagraphProperties(properties).hasUnknown), ...require_xml_query.childrenWithTag(style, "style:text-properties").filter((properties) => require_styles_properties.parseTextProperties(properties).hasUnknown)]));
|
|
239
248
|
if (require_xml_query.attrValue(pElement, "text:is-list-header") !== void 0) residueElements.push(require_typed_shared_constructs.odfAttributeElement(pElement, "text:is-list-header"));
|
|
240
249
|
residueElements.push(...walk.residueElements);
|
|
241
250
|
if (residueElements.length > 0) source = require_typed_shared_constructs.odfResidue(context.format, ...residueElements);
|
|
@@ -257,6 +266,7 @@ function readOdfParagraph(pElement, pkg, context = {}) {
|
|
|
257
266
|
...source !== void 0 ? { source } : {},
|
|
258
267
|
...walk.extents.length > 0 ? { constructs: walk.extents } : {},
|
|
259
268
|
styleId: styleName,
|
|
269
|
+
...isPreformatted ? { preformatted: true } : {},
|
|
260
270
|
alignment: paragraphProperties.alignment,
|
|
261
271
|
spacingBeforePt: paragraphProperties.spacingBeforePt,
|
|
262
272
|
spacingAfterPt: paragraphProperties.spacingAfterPt,
|
|
@@ -380,18 +390,20 @@ function writeOdfParagraphChildren(runs, registry) {
|
|
|
380
390
|
function writeOdfParagraph(paragraph, registry, options = {}) {
|
|
381
391
|
const properties = odfParagraphProperties(paragraph);
|
|
382
392
|
const attributes = {};
|
|
393
|
+
const parentStyleName = options.parentStyleName ?? (paragraph.preformatted === true ? PREFORMATTED_STYLE_NAME : void 0);
|
|
383
394
|
if (Object.keys(properties).length > 0) attributes["text:style-name"] = require_xml_entities.encodeXmlText(registry.intern({
|
|
384
395
|
properties,
|
|
385
396
|
family: "paragraph",
|
|
386
|
-
...
|
|
397
|
+
...parentStyleName === void 0 ? {} : { parentStyleName }
|
|
387
398
|
}));
|
|
388
|
-
else if (
|
|
399
|
+
else if (parentStyleName !== void 0) attributes["text:style-name"] = require_xml_entities.encodeXmlText(parentStyleName);
|
|
389
400
|
if (paragraph.headingLevel !== void 0) attributes["text:outline-level"] = String(paragraph.headingLevel);
|
|
390
401
|
return require_xml_fragment.el(paragraph.headingLevel === void 0 ? "text:p" : "text:h", attributes, [...writeOdfParagraphChildren(paragraph.runs, registry), ...options.trailingNodes ?? []]);
|
|
391
402
|
}
|
|
392
403
|
//#endregion
|
|
393
404
|
exports.odfParagraphProperties = odfParagraphProperties;
|
|
394
405
|
exports.odfRunProperties = odfRunProperties;
|
|
406
|
+
exports.preformattedStyleElement = preformattedStyleElement;
|
|
395
407
|
exports.readOdfConstructBodyBlocks = readOdfConstructBodyBlocks;
|
|
396
408
|
exports.readOdfParagraph = readOdfParagraph;
|
|
397
409
|
exports.readParagraphOrHeading = readParagraphOrHeading;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { OdfParagraphContext, OdfParagraphWriteOptions, odfParagraphProperties, odfRunProperties, readOdfConstructBodyBlocks, readOdfParagraph, readParagraphOrHeading, segmentOdfParagraphRuns, writeOdfParagraph };
|
|
1
|
+
import { a as preformattedStyleElement, c as readParagraphOrHeading, i as odfRunProperties, l as segmentOdfParagraphRuns, n as OdfParagraphWriteOptions, o as readOdfConstructBodyBlocks, r as odfParagraphProperties, s as readOdfParagraph, t as OdfParagraphContext, u as writeOdfParagraph } from "../../paragraph-Y2hh0bh2.cjs";
|
|
2
|
+
export { OdfParagraphContext, OdfParagraphWriteOptions, odfParagraphProperties, odfRunProperties, preformattedStyleElement, readOdfConstructBodyBlocks, readOdfParagraph, readParagraphOrHeading, segmentOdfParagraphRuns, writeOdfParagraph };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { OdfParagraphContext, OdfParagraphWriteOptions, odfParagraphProperties, odfRunProperties, readOdfConstructBodyBlocks, readOdfParagraph, readParagraphOrHeading, segmentOdfParagraphRuns, writeOdfParagraph };
|
|
1
|
+
import { a as preformattedStyleElement, c as readParagraphOrHeading, i as odfRunProperties, l as segmentOdfParagraphRuns, n as OdfParagraphWriteOptions, o as readOdfConstructBodyBlocks, r as odfParagraphProperties, s as readOdfParagraph, t as OdfParagraphContext, u as writeOdfParagraph } from "../../paragraph-CU1E9yXq.js";
|
|
2
|
+
export { OdfParagraphContext, OdfParagraphWriteOptions, odfParagraphProperties, odfRunProperties, preformattedStyleElement, readOdfConstructBodyBlocks, readOdfParagraph, readParagraphOrHeading, segmentOdfParagraphRuns, writeOdfParagraph };
|
|
@@ -217,9 +217,18 @@ function runFromText(text, properties) {
|
|
|
217
217
|
color: properties.color
|
|
218
218
|
};
|
|
219
219
|
}
|
|
220
|
+
const PREFORMATTED_STYLE_NAME = "Preformatted_20_Text";
|
|
221
|
+
function preformattedStyleElement() {
|
|
222
|
+
return el("style:style", {
|
|
223
|
+
"style:name": PREFORMATTED_STYLE_NAME,
|
|
224
|
+
"style:family": "paragraph"
|
|
225
|
+
});
|
|
226
|
+
}
|
|
220
227
|
function readOdfParagraph(pElement, pkg, context = {}) {
|
|
221
228
|
const styleName = attrValue(pElement, "text:style-name");
|
|
222
229
|
const paragraphProperties = resolveStyle(styleName, "paragraph", pkg).properties;
|
|
230
|
+
const styleChain = resolveStyleElementChain(styleName, "paragraph", pkg).elements;
|
|
231
|
+
const isPreformatted = styleChain.some((style) => attrValue(style, "style:name") === PREFORMATTED_STYLE_NAME);
|
|
223
232
|
const runs = [];
|
|
224
233
|
const walk = {
|
|
225
234
|
extents: [],
|
|
@@ -234,7 +243,7 @@ function readOdfParagraph(pElement, pkg, context = {}) {
|
|
|
234
243
|
let source;
|
|
235
244
|
if (context.format !== void 0) {
|
|
236
245
|
const residueElements = [];
|
|
237
|
-
if (styleName !== void 0) residueElements.push(...
|
|
246
|
+
if (styleName !== void 0) residueElements.push(...styleChain.flatMap((style) => [...childrenWithTag(style, "style:paragraph-properties").filter((properties) => parseParagraphProperties(properties).hasUnknown), ...childrenWithTag(style, "style:text-properties").filter((properties) => parseTextProperties(properties).hasUnknown)]));
|
|
238
247
|
if (attrValue(pElement, "text:is-list-header") !== void 0) residueElements.push(odfAttributeElement(pElement, "text:is-list-header"));
|
|
239
248
|
residueElements.push(...walk.residueElements);
|
|
240
249
|
if (residueElements.length > 0) source = odfResidue(context.format, ...residueElements);
|
|
@@ -256,6 +265,7 @@ function readOdfParagraph(pElement, pkg, context = {}) {
|
|
|
256
265
|
...source !== void 0 ? { source } : {},
|
|
257
266
|
...walk.extents.length > 0 ? { constructs: walk.extents } : {},
|
|
258
267
|
styleId: styleName,
|
|
268
|
+
...isPreformatted ? { preformatted: true } : {},
|
|
259
269
|
alignment: paragraphProperties.alignment,
|
|
260
270
|
spacingBeforePt: paragraphProperties.spacingBeforePt,
|
|
261
271
|
spacingAfterPt: paragraphProperties.spacingAfterPt,
|
|
@@ -379,14 +389,15 @@ function writeOdfParagraphChildren(runs, registry) {
|
|
|
379
389
|
function writeOdfParagraph(paragraph, registry, options = {}) {
|
|
380
390
|
const properties = odfParagraphProperties(paragraph);
|
|
381
391
|
const attributes = {};
|
|
392
|
+
const parentStyleName = options.parentStyleName ?? (paragraph.preformatted === true ? PREFORMATTED_STYLE_NAME : void 0);
|
|
382
393
|
if (Object.keys(properties).length > 0) attributes["text:style-name"] = encodeXmlText(registry.intern({
|
|
383
394
|
properties,
|
|
384
395
|
family: "paragraph",
|
|
385
|
-
...
|
|
396
|
+
...parentStyleName === void 0 ? {} : { parentStyleName }
|
|
386
397
|
}));
|
|
387
|
-
else if (
|
|
398
|
+
else if (parentStyleName !== void 0) attributes["text:style-name"] = encodeXmlText(parentStyleName);
|
|
388
399
|
if (paragraph.headingLevel !== void 0) attributes["text:outline-level"] = String(paragraph.headingLevel);
|
|
389
400
|
return el(paragraph.headingLevel === void 0 ? "text:p" : "text:h", attributes, [...writeOdfParagraphChildren(paragraph.runs, registry), ...options.trailingNodes ?? []]);
|
|
390
401
|
}
|
|
391
402
|
//#endregion
|
|
392
|
-
export { odfParagraphProperties, odfRunProperties, readOdfConstructBodyBlocks, readOdfParagraph, readParagraphOrHeading, segmentOdfParagraphRuns, writeOdfParagraph };
|
|
403
|
+
export { odfParagraphProperties, odfRunProperties, preformattedStyleElement, readOdfConstructBodyBlocks, readOdfParagraph, readParagraphOrHeading, segmentOdfParagraphRuns, writeOdfParagraph };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odf.js",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.3",
|
|
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": {
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"license": "MIT",
|
|
88
88
|
"packageManager": "pnpm@11.6.0",
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"document-schema.js": "^6.2.
|
|
90
|
+
"document-schema.js": "^6.2.1",
|
|
91
91
|
"fast-xml-parser": "^5.10.1",
|
|
92
92
|
"fflate": "^0.8.3",
|
|
93
93
|
"zod": "^4.4.3"
|