odf.js 1.10.4 → 1.11.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/dist/index.cjs +13 -20
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +13 -20
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -795,7 +795,6 @@ function attributeMap(element) {
|
|
|
795
795
|
for (const attribute of element.attributes) map.set(attribute.name, attribute.value);
|
|
796
796
|
return map;
|
|
797
797
|
}
|
|
798
|
-
const parseLength = parseOdfLength;
|
|
799
798
|
function formatPt(valuePt) {
|
|
800
799
|
return formatOdfLength(valuePt, "pt");
|
|
801
800
|
}
|
|
@@ -810,8 +809,6 @@ function parsePercentageMultiplier(value) {
|
|
|
810
809
|
function formatPercentageMultiplier(multiplier) {
|
|
811
810
|
return `${multiplier * 100}%`;
|
|
812
811
|
}
|
|
813
|
-
const parseColor = parseOdfColor;
|
|
814
|
-
const formatColor = formatOdfColor;
|
|
815
812
|
function parseLineDecoration(style, companionA, companionAOnValue, companionB, companionBOnValue) {
|
|
816
813
|
if (style === void 0 && companionA === void 0 && companionB === void 0) return;
|
|
817
814
|
if (style === "solid" && (companionA === void 0 || companionA === companionAOnValue) && (companionB === void 0 || companionB === companionBOnValue)) return true;
|
|
@@ -842,13 +839,13 @@ function parseTextProperties(element) {
|
|
|
842
839
|
if (fontFamily !== void 0) properties.fontFamily = fontFamily;
|
|
843
840
|
const fontSize = attrs.get(ATTR.fontSize);
|
|
844
841
|
if (fontSize !== void 0) {
|
|
845
|
-
const pt =
|
|
842
|
+
const pt = parseOdfLength(fontSize);
|
|
846
843
|
if (pt === void 0) hasUnknown = true;
|
|
847
844
|
else properties.sizePt = pt;
|
|
848
845
|
}
|
|
849
846
|
const color = attrs.get(ATTR.color);
|
|
850
847
|
if (color !== void 0) {
|
|
851
|
-
const parsed =
|
|
848
|
+
const parsed = parseOdfColor(color);
|
|
852
849
|
if (parsed === void 0) hasUnknown = true;
|
|
853
850
|
else properties.color = parsed;
|
|
854
851
|
}
|
|
@@ -867,25 +864,25 @@ function parseParagraphProperties(element) {
|
|
|
867
864
|
else if (textAlign !== void 0) hasUnknown = true;
|
|
868
865
|
const marginTop = attrs.get(ATTR.marginTop);
|
|
869
866
|
if (marginTop !== void 0) {
|
|
870
|
-
const pt =
|
|
867
|
+
const pt = parseOdfLength(marginTop);
|
|
871
868
|
if (pt === void 0) hasUnknown = true;
|
|
872
869
|
else properties.spacingBeforePt = pt;
|
|
873
870
|
}
|
|
874
871
|
const marginBottom = attrs.get(ATTR.marginBottom);
|
|
875
872
|
if (marginBottom !== void 0) {
|
|
876
|
-
const pt =
|
|
873
|
+
const pt = parseOdfLength(marginBottom);
|
|
877
874
|
if (pt === void 0) hasUnknown = true;
|
|
878
875
|
else properties.spacingAfterPt = pt;
|
|
879
876
|
}
|
|
880
877
|
const marginLeft = attrs.get(ATTR.marginLeft);
|
|
881
878
|
if (marginLeft !== void 0) {
|
|
882
|
-
const pt =
|
|
879
|
+
const pt = parseOdfLength(marginLeft);
|
|
883
880
|
if (pt === void 0) hasUnknown = true;
|
|
884
881
|
else properties.indentLeftPt = pt;
|
|
885
882
|
}
|
|
886
883
|
const textIndent = attrs.get(ATTR.textIndent);
|
|
887
884
|
if (textIndent !== void 0) {
|
|
888
|
-
const pt =
|
|
885
|
+
const pt = parseOdfLength(textIndent);
|
|
889
886
|
if (pt === void 0) hasUnknown = true;
|
|
890
887
|
else properties.indentFirstLinePt = pt;
|
|
891
888
|
}
|
|
@@ -977,7 +974,7 @@ function textPropertiesToAttributes(properties) {
|
|
|
977
974
|
});
|
|
978
975
|
if (properties.color !== void 0) attributes.push({
|
|
979
976
|
name: ATTR.color,
|
|
980
|
-
value:
|
|
977
|
+
value: formatOdfColor(properties.color)
|
|
981
978
|
});
|
|
982
979
|
return attributes;
|
|
983
980
|
}
|
|
@@ -2566,7 +2563,6 @@ function parseKnownOdfLength$1(value) {
|
|
|
2566
2563
|
if (parsed === void 0) throw new Error(`readOdt: internal error -- "${value}" is not a valid ODF length literal`);
|
|
2567
2564
|
return parsed;
|
|
2568
2565
|
}
|
|
2569
|
-
const DEFAULT_PAGE_SIZE$2 = document_schema_js.PAGE_SIZE_A4;
|
|
2570
2566
|
const DEFAULT_MARGIN_PT$1 = parseKnownOdfLength$1("2cm");
|
|
2571
2567
|
const DEFAULT_MARGINS$1 = {
|
|
2572
2568
|
topPt: DEFAULT_MARGIN_PT$1,
|
|
@@ -2596,7 +2592,7 @@ function readFirstMasterPageGeometry(pkg) {
|
|
|
2596
2592
|
const pageSize = properties === void 0 ? void 0 : parsePageSize(properties);
|
|
2597
2593
|
const margins = properties === void 0 ? void 0 : parseMargins(properties);
|
|
2598
2594
|
return {
|
|
2599
|
-
pageSize: pageSize ??
|
|
2595
|
+
pageSize: pageSize ?? document_schema_js.PAGE_SIZE_A4,
|
|
2600
2596
|
margins: margins ?? DEFAULT_MARGINS$1
|
|
2601
2597
|
};
|
|
2602
2598
|
}
|
|
@@ -2621,9 +2617,8 @@ function readOdt(pkg) {
|
|
|
2621
2617
|
//#endregion
|
|
2622
2618
|
//#region src/typed/odg/read.ts
|
|
2623
2619
|
const CONTENT_PART$4 = "content.xml";
|
|
2624
|
-
const DEFAULT_PAGE_SIZE$1 = document_schema_js.PAGE_SIZE_A4;
|
|
2625
2620
|
function readPage(page, pkg) {
|
|
2626
|
-
const size = resolveDrawPageSize(page, pkg) ??
|
|
2621
|
+
const size = resolveDrawPageSize(page, pkg) ?? document_schema_js.PAGE_SIZE_A4;
|
|
2627
2622
|
const { shapes, vectors } = readDrawPageContent(page.children, pkg);
|
|
2628
2623
|
return {
|
|
2629
2624
|
size,
|
|
@@ -2650,7 +2645,6 @@ function parseKnownOdfLength(value) {
|
|
|
2650
2645
|
if (parsed === void 0) throw new Error(`readOds: internal error -- "${value}" is not a valid ODF length literal`);
|
|
2651
2646
|
return parsed;
|
|
2652
2647
|
}
|
|
2653
|
-
const DEFAULT_PAGE_SIZE = document_schema_js.PAGE_SIZE_A4;
|
|
2654
2648
|
const DEFAULT_MARGIN_PT = parseKnownOdfLength("2cm");
|
|
2655
2649
|
const DEFAULT_MARGINS = {
|
|
2656
2650
|
topPt: DEFAULT_MARGIN_PT,
|
|
@@ -2801,14 +2795,13 @@ function readTable(tableElement, pkg) {
|
|
|
2801
2795
|
let columnCursor = 0;
|
|
2802
2796
|
const cursor = new TableCursor();
|
|
2803
2797
|
function processColumn(columnElement) {
|
|
2804
|
-
const startIndex = columnCursor;
|
|
2805
2798
|
const { widthPt, manualBreak } = readColumnLayout(columnElement, pkg);
|
|
2806
2799
|
columns.push({
|
|
2807
|
-
index:
|
|
2800
|
+
index: columnCursor,
|
|
2808
2801
|
widthPt,
|
|
2809
2802
|
hidden: isHidden(columnElement) ? true : void 0
|
|
2810
2803
|
});
|
|
2811
|
-
if (manualBreak) manualBreakColumns.push(
|
|
2804
|
+
if (manualBreak) manualBreakColumns.push(columnCursor);
|
|
2812
2805
|
columnCursor += readRepeatCount(columnElement, "table:number-columns-repeated");
|
|
2813
2806
|
}
|
|
2814
2807
|
function processRowCells(rowElement) {
|
|
@@ -2906,7 +2899,7 @@ function readPrintSettings(tableElement, pkg, repeatColumns, repeatRows, manualB
|
|
|
2906
2899
|
columns: manualBreakColumns
|
|
2907
2900
|
} : void 0;
|
|
2908
2901
|
const settings = {
|
|
2909
|
-
pageSize: pageSize ??
|
|
2902
|
+
pageSize: pageSize ?? document_schema_js.PAGE_SIZE_A4,
|
|
2910
2903
|
margins: margins ?? DEFAULT_MARGINS,
|
|
2911
2904
|
gridlines: printTokens.has("grid"),
|
|
2912
2905
|
headers: printTokens.has("headers"),
|
|
@@ -3203,7 +3196,7 @@ exports.packageCodec = packageCodec;
|
|
|
3203
3196
|
exports.paragraphPropertiesToAttributes = paragraphPropertiesToAttributes;
|
|
3204
3197
|
exports.parseBox = parseBox;
|
|
3205
3198
|
exports.parseCellReference = parseCellReference;
|
|
3206
|
-
exports.parseLength =
|
|
3199
|
+
exports.parseLength = parseOdfLength;
|
|
3207
3200
|
exports.parseLinePoints = parseLinePoints;
|
|
3208
3201
|
exports.parseMargins = parseMargins;
|
|
3209
3202
|
exports.parseOdfColor = parseOdfColor;
|
package/dist/index.d.cts
CHANGED
|
@@ -424,7 +424,6 @@ interface ParsedProperties {
|
|
|
424
424
|
properties: Partial<StyleProperties>;
|
|
425
425
|
hasUnknown: boolean;
|
|
426
426
|
}
|
|
427
|
-
declare const parseLength: typeof parseOdfLength;
|
|
428
427
|
declare function formatPt(valuePt: number): string;
|
|
429
428
|
declare function formatPercentageMultiplier(multiplier: number): string;
|
|
430
429
|
declare function parseTextProperties(element: XmlElement): ParsedProperties;
|
|
@@ -678,4 +677,4 @@ interface OdbInventory {
|
|
|
678
677
|
}
|
|
679
678
|
declare function readOdbInventory(pkg: Package): OdbInventory;
|
|
680
679
|
//#endregion
|
|
681
|
-
export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type CascadeDiagnostic, type DrawPageContent, 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, type OdbConnectionInfo, type OdbInventory, type OdfExtension, type OdfFormulaDocument, type OdfNamespacePrefix, type OdfPoint, type OdfRawPoint, type OdfRawSegment, type OdfRawSubpath, type OdfShapeGeometry, type OdfTransformFunction, type OdfViewBox, type OdgDocument, type OdmDocument, type OdmSection, type OdpDocument, type OdsDocument, type OdtDocument, type OtherPartRef, type Package, PackageSchema, type ParsedProperties, type Part, PartSchema, STYLE_FAMILIES, type StyleCascadeResult, type StyleElementChainResult, type StyleFamily, type StyleProperties, StylePropertiesSchema, StyleRegistry, type StyleRegistryOptions, 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, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, netRotationDeg, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseLength, parseLinePoints, parseMargins, parseOdfColor,
|
|
680
|
+
export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type CascadeDiagnostic, type DrawPageContent, 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, type OdbConnectionInfo, type OdbInventory, type OdfExtension, type OdfFormulaDocument, type OdfNamespacePrefix, type OdfPoint, type OdfRawPoint, type OdfRawSegment, type OdfRawSubpath, type OdfShapeGeometry, type OdfTransformFunction, type OdfViewBox, type OdgDocument, type OdmDocument, type OdmSection, type OdpDocument, type OdsDocument, type OdtDocument, type OtherPartRef, type Package, PackageSchema, type ParsedProperties, type Part, PartSchema, STYLE_FAMILIES, type StyleCascadeResult, type StyleElementChainResult, type StyleFamily, type StyleProperties, StylePropertiesSchema, StyleRegistry, type StyleRegistryOptions, 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, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, netRotationDeg, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseOdfLength as parseLength, parseOdfLength, parseLinePoints, parseMargins, parseOdfColor, parseOdfPathData, parseOdfPointsList, parseOdfTransform, parseOdfViewBox, parsePackage, parsePageSize, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, rawSubpathFromPoints, readDrawFrame, readDrawPageContent, readManifest, readMimetype, readOdbInventory, readOdfFormula, readOdfMetadata, readOdfParagraph, readOdfTable, readOdg, readOdm, readOdp, readOds, readOdt, resolveDrawPageSize, resolveOdfShapeGeometry, resolvePageLayoutProperties, resolveStyle, resolveStyleElementChain, rootElement, scaleOdfRawPoint, serializePackage, setDocumentMediaType, sniffImageFormat, sumOdfNodeLength, syncManifest, textPropertiesToAttributes, txt, unzipPackage, validateManifest, walkDrawShapes, writeManifest, writeMimetype, xmlCodec, xmlnsAttributes, zipPackage };
|
package/dist/index.d.ts
CHANGED
|
@@ -424,7 +424,6 @@ interface ParsedProperties {
|
|
|
424
424
|
properties: Partial<StyleProperties>;
|
|
425
425
|
hasUnknown: boolean;
|
|
426
426
|
}
|
|
427
|
-
declare const parseLength: typeof parseOdfLength;
|
|
428
427
|
declare function formatPt(valuePt: number): string;
|
|
429
428
|
declare function formatPercentageMultiplier(multiplier: number): string;
|
|
430
429
|
declare function parseTextProperties(element: XmlElement): ParsedProperties;
|
|
@@ -678,4 +677,4 @@ interface OdbInventory {
|
|
|
678
677
|
}
|
|
679
678
|
declare function readOdbInventory(pkg: Package): OdbInventory;
|
|
680
679
|
//#endregion
|
|
681
|
-
export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type CascadeDiagnostic, type DrawPageContent, 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, type OdbConnectionInfo, type OdbInventory, type OdfExtension, type OdfFormulaDocument, type OdfNamespacePrefix, type OdfPoint, type OdfRawPoint, type OdfRawSegment, type OdfRawSubpath, type OdfShapeGeometry, type OdfTransformFunction, type OdfViewBox, type OdgDocument, type OdmDocument, type OdmSection, type OdpDocument, type OdsDocument, type OdtDocument, type OtherPartRef, type Package, PackageSchema, type ParsedProperties, type Part, PartSchema, STYLE_FAMILIES, type StyleCascadeResult, type StyleElementChainResult, type StyleFamily, type StyleProperties, StylePropertiesSchema, StyleRegistry, type StyleRegistryOptions, 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, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, netRotationDeg, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseLength, parseLinePoints, parseMargins, parseOdfColor,
|
|
680
|
+
export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type CascadeDiagnostic, type DrawPageContent, 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, type OdbConnectionInfo, type OdbInventory, type OdfExtension, type OdfFormulaDocument, type OdfNamespacePrefix, type OdfPoint, type OdfRawPoint, type OdfRawSegment, type OdfRawSubpath, type OdfShapeGeometry, type OdfTransformFunction, type OdfViewBox, type OdgDocument, type OdmDocument, type OdmSection, type OdpDocument, type OdsDocument, type OdtDocument, type OtherPartRef, type Package, PackageSchema, type ParsedProperties, type Part, PartSchema, STYLE_FAMILIES, type StyleCascadeResult, type StyleElementChainResult, type StyleFamily, type StyleProperties, StylePropertiesSchema, StyleRegistry, type StyleRegistryOptions, 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, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, netRotationDeg, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseOdfLength as parseLength, parseOdfLength, parseLinePoints, parseMargins, parseOdfColor, parseOdfPathData, parseOdfPointsList, parseOdfTransform, parseOdfViewBox, parsePackage, parsePageSize, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, rawSubpathFromPoints, readDrawFrame, readDrawPageContent, readManifest, readMimetype, readOdbInventory, readOdfFormula, readOdfMetadata, readOdfParagraph, readOdfTable, readOdg, readOdm, readOdp, readOds, readOdt, resolveDrawPageSize, resolveOdfShapeGeometry, resolvePageLayoutProperties, resolveStyle, resolveStyleElementChain, rootElement, scaleOdfRawPoint, serializePackage, setDocumentMediaType, sniffImageFormat, sumOdfNodeLength, syncManifest, textPropertiesToAttributes, txt, unzipPackage, validateManifest, walkDrawShapes, writeManifest, writeMimetype, xmlCodec, xmlnsAttributes, zipPackage };
|
package/dist/index.js
CHANGED
|
@@ -794,7 +794,6 @@ function attributeMap(element) {
|
|
|
794
794
|
for (const attribute of element.attributes) map.set(attribute.name, attribute.value);
|
|
795
795
|
return map;
|
|
796
796
|
}
|
|
797
|
-
const parseLength = parseOdfLength;
|
|
798
797
|
function formatPt(valuePt) {
|
|
799
798
|
return formatOdfLength(valuePt, "pt");
|
|
800
799
|
}
|
|
@@ -809,8 +808,6 @@ function parsePercentageMultiplier(value) {
|
|
|
809
808
|
function formatPercentageMultiplier(multiplier) {
|
|
810
809
|
return `${multiplier * 100}%`;
|
|
811
810
|
}
|
|
812
|
-
const parseColor = parseOdfColor;
|
|
813
|
-
const formatColor = formatOdfColor;
|
|
814
811
|
function parseLineDecoration(style, companionA, companionAOnValue, companionB, companionBOnValue) {
|
|
815
812
|
if (style === void 0 && companionA === void 0 && companionB === void 0) return;
|
|
816
813
|
if (style === "solid" && (companionA === void 0 || companionA === companionAOnValue) && (companionB === void 0 || companionB === companionBOnValue)) return true;
|
|
@@ -841,13 +838,13 @@ function parseTextProperties(element) {
|
|
|
841
838
|
if (fontFamily !== void 0) properties.fontFamily = fontFamily;
|
|
842
839
|
const fontSize = attrs.get(ATTR.fontSize);
|
|
843
840
|
if (fontSize !== void 0) {
|
|
844
|
-
const pt =
|
|
841
|
+
const pt = parseOdfLength(fontSize);
|
|
845
842
|
if (pt === void 0) hasUnknown = true;
|
|
846
843
|
else properties.sizePt = pt;
|
|
847
844
|
}
|
|
848
845
|
const color = attrs.get(ATTR.color);
|
|
849
846
|
if (color !== void 0) {
|
|
850
|
-
const parsed =
|
|
847
|
+
const parsed = parseOdfColor(color);
|
|
851
848
|
if (parsed === void 0) hasUnknown = true;
|
|
852
849
|
else properties.color = parsed;
|
|
853
850
|
}
|
|
@@ -866,25 +863,25 @@ function parseParagraphProperties(element) {
|
|
|
866
863
|
else if (textAlign !== void 0) hasUnknown = true;
|
|
867
864
|
const marginTop = attrs.get(ATTR.marginTop);
|
|
868
865
|
if (marginTop !== void 0) {
|
|
869
|
-
const pt =
|
|
866
|
+
const pt = parseOdfLength(marginTop);
|
|
870
867
|
if (pt === void 0) hasUnknown = true;
|
|
871
868
|
else properties.spacingBeforePt = pt;
|
|
872
869
|
}
|
|
873
870
|
const marginBottom = attrs.get(ATTR.marginBottom);
|
|
874
871
|
if (marginBottom !== void 0) {
|
|
875
|
-
const pt =
|
|
872
|
+
const pt = parseOdfLength(marginBottom);
|
|
876
873
|
if (pt === void 0) hasUnknown = true;
|
|
877
874
|
else properties.spacingAfterPt = pt;
|
|
878
875
|
}
|
|
879
876
|
const marginLeft = attrs.get(ATTR.marginLeft);
|
|
880
877
|
if (marginLeft !== void 0) {
|
|
881
|
-
const pt =
|
|
878
|
+
const pt = parseOdfLength(marginLeft);
|
|
882
879
|
if (pt === void 0) hasUnknown = true;
|
|
883
880
|
else properties.indentLeftPt = pt;
|
|
884
881
|
}
|
|
885
882
|
const textIndent = attrs.get(ATTR.textIndent);
|
|
886
883
|
if (textIndent !== void 0) {
|
|
887
|
-
const pt =
|
|
884
|
+
const pt = parseOdfLength(textIndent);
|
|
888
885
|
if (pt === void 0) hasUnknown = true;
|
|
889
886
|
else properties.indentFirstLinePt = pt;
|
|
890
887
|
}
|
|
@@ -976,7 +973,7 @@ function textPropertiesToAttributes(properties) {
|
|
|
976
973
|
});
|
|
977
974
|
if (properties.color !== void 0) attributes.push({
|
|
978
975
|
name: ATTR.color,
|
|
979
|
-
value:
|
|
976
|
+
value: formatOdfColor(properties.color)
|
|
980
977
|
});
|
|
981
978
|
return attributes;
|
|
982
979
|
}
|
|
@@ -2565,7 +2562,6 @@ function parseKnownOdfLength$1(value) {
|
|
|
2565
2562
|
if (parsed === void 0) throw new Error(`readOdt: internal error -- "${value}" is not a valid ODF length literal`);
|
|
2566
2563
|
return parsed;
|
|
2567
2564
|
}
|
|
2568
|
-
const DEFAULT_PAGE_SIZE$2 = PAGE_SIZE_A4;
|
|
2569
2565
|
const DEFAULT_MARGIN_PT$1 = parseKnownOdfLength$1("2cm");
|
|
2570
2566
|
const DEFAULT_MARGINS$1 = {
|
|
2571
2567
|
topPt: DEFAULT_MARGIN_PT$1,
|
|
@@ -2595,7 +2591,7 @@ function readFirstMasterPageGeometry(pkg) {
|
|
|
2595
2591
|
const pageSize = properties === void 0 ? void 0 : parsePageSize(properties);
|
|
2596
2592
|
const margins = properties === void 0 ? void 0 : parseMargins(properties);
|
|
2597
2593
|
return {
|
|
2598
|
-
pageSize: pageSize ??
|
|
2594
|
+
pageSize: pageSize ?? PAGE_SIZE_A4,
|
|
2599
2595
|
margins: margins ?? DEFAULT_MARGINS$1
|
|
2600
2596
|
};
|
|
2601
2597
|
}
|
|
@@ -2620,9 +2616,8 @@ function readOdt(pkg) {
|
|
|
2620
2616
|
//#endregion
|
|
2621
2617
|
//#region src/typed/odg/read.ts
|
|
2622
2618
|
const CONTENT_PART$4 = "content.xml";
|
|
2623
|
-
const DEFAULT_PAGE_SIZE$1 = PAGE_SIZE_A4;
|
|
2624
2619
|
function readPage(page, pkg) {
|
|
2625
|
-
const size = resolveDrawPageSize(page, pkg) ??
|
|
2620
|
+
const size = resolveDrawPageSize(page, pkg) ?? PAGE_SIZE_A4;
|
|
2626
2621
|
const { shapes, vectors } = readDrawPageContent(page.children, pkg);
|
|
2627
2622
|
return {
|
|
2628
2623
|
size,
|
|
@@ -2649,7 +2644,6 @@ function parseKnownOdfLength(value) {
|
|
|
2649
2644
|
if (parsed === void 0) throw new Error(`readOds: internal error -- "${value}" is not a valid ODF length literal`);
|
|
2650
2645
|
return parsed;
|
|
2651
2646
|
}
|
|
2652
|
-
const DEFAULT_PAGE_SIZE = PAGE_SIZE_A4;
|
|
2653
2647
|
const DEFAULT_MARGIN_PT = parseKnownOdfLength("2cm");
|
|
2654
2648
|
const DEFAULT_MARGINS = {
|
|
2655
2649
|
topPt: DEFAULT_MARGIN_PT,
|
|
@@ -2800,14 +2794,13 @@ function readTable(tableElement, pkg) {
|
|
|
2800
2794
|
let columnCursor = 0;
|
|
2801
2795
|
const cursor = new TableCursor();
|
|
2802
2796
|
function processColumn(columnElement) {
|
|
2803
|
-
const startIndex = columnCursor;
|
|
2804
2797
|
const { widthPt, manualBreak } = readColumnLayout(columnElement, pkg);
|
|
2805
2798
|
columns.push({
|
|
2806
|
-
index:
|
|
2799
|
+
index: columnCursor,
|
|
2807
2800
|
widthPt,
|
|
2808
2801
|
hidden: isHidden(columnElement) ? true : void 0
|
|
2809
2802
|
});
|
|
2810
|
-
if (manualBreak) manualBreakColumns.push(
|
|
2803
|
+
if (manualBreak) manualBreakColumns.push(columnCursor);
|
|
2811
2804
|
columnCursor += readRepeatCount(columnElement, "table:number-columns-repeated");
|
|
2812
2805
|
}
|
|
2813
2806
|
function processRowCells(rowElement) {
|
|
@@ -2905,7 +2898,7 @@ function readPrintSettings(tableElement, pkg, repeatColumns, repeatRows, manualB
|
|
|
2905
2898
|
columns: manualBreakColumns
|
|
2906
2899
|
} : void 0;
|
|
2907
2900
|
const settings = {
|
|
2908
|
-
pageSize: pageSize ??
|
|
2901
|
+
pageSize: pageSize ?? PAGE_SIZE_A4,
|
|
2909
2902
|
margins: margins ?? DEFAULT_MARGINS,
|
|
2910
2903
|
gridlines: printTokens.has("grid"),
|
|
2911
2904
|
headers: printTokens.has("headers"),
|
|
@@ -3134,4 +3127,4 @@ function readOdbInventory(pkg) {
|
|
|
3134
3127
|
};
|
|
3135
3128
|
}
|
|
3136
3129
|
//#endregion
|
|
3137
|
-
export { AlignmentSchema, AttributeSchema, BinaryPartSchema, MANIFEST_PART, META_PART, MIMETYPE_PART, ManifestEntrySchema, ManifestProblemSchema, ManifestSchema, ODF_MEDIA_TYPES, ODF_NAMESPACES, PackageSchema, PartSchema, STYLE_FAMILIES, StylePropertiesSchema, StyleRegistry, TableCursor, XmlCdataSchema, XmlCommentSchema, XmlDeclarationSchema, XmlElementSchema, XmlNodeSchema, XmlPartSchema, XmlPiSchema, XmlTextSchema, applyOdfTransform, attrValue, base64ToBytes, buildManifest, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, netRotationDeg, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseLength, parseLinePoints, parseMargins, parseOdfColor,
|
|
3130
|
+
export { AlignmentSchema, AttributeSchema, BinaryPartSchema, MANIFEST_PART, META_PART, MIMETYPE_PART, ManifestEntrySchema, ManifestProblemSchema, ManifestSchema, ODF_MEDIA_TYPES, ODF_NAMESPACES, PackageSchema, PartSchema, STYLE_FAMILIES, StylePropertiesSchema, StyleRegistry, TableCursor, XmlCdataSchema, XmlCommentSchema, XmlDeclarationSchema, XmlElementSchema, XmlNodeSchema, XmlPartSchema, XmlPiSchema, XmlTextSchema, applyOdfTransform, attrValue, base64ToBytes, buildManifest, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, netRotationDeg, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseOdfLength as parseLength, parseOdfLength, parseLinePoints, parseMargins, parseOdfColor, parseOdfPathData, parseOdfPointsList, parseOdfTransform, parseOdfViewBox, parsePackage, parsePageSize, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, rawSubpathFromPoints, readDrawFrame, readDrawPageContent, readManifest, readMimetype, readOdbInventory, readOdfFormula, readOdfMetadata, readOdfParagraph, readOdfTable, readOdg, readOdm, readOdp, readOds, readOdt, resolveDrawPageSize, resolveOdfShapeGeometry, resolvePageLayoutProperties, resolveStyle, resolveStyleElementChain, rootElement, scaleOdfRawPoint, serializePackage, setDocumentMediaType, sniffImageFormat, sumOdfNodeLength, syncManifest, textPropertiesToAttributes, txt, unzipPackage, validateManifest, walkDrawShapes, writeManifest, writeMimetype, xmlCodec, xmlnsAttributes, zipPackage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odf.js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "Type-safe, lossless round-trip conversion between OpenDocument Format packages (odt, ods, odp) and JSON, hand-written and dependency-minimal, built on Zod 4 codecs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|