@evotecit/officeimo 0.1.1 → 0.1.2
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/bundles/officeimo-canopyx.js +95 -85
- package/bundles/officeimo-canopyx.mjs +29 -19
- package/bundles/officeimo-datatables.js +95 -85
- package/bundles/officeimo-datatables.mjs +29 -19
- package/bundles/officeimo-pdf.js +15 -14
- package/bundles/officeimo-pdf.mjs +3 -2
- package/bundles/officeimo-xlsx.js +78 -69
- package/bundles/officeimo-xlsx.mjs +26 -17
- package/bundles/officeimo.js +95 -85
- package/bundles/officeimo.mjs +29 -19
- package/dist/opc/index.js +14 -9
- package/dist/pdf/pages.js +3 -2
- package/dist/xlsx/workbook.js +7 -4
- package/dist/xlsx/worksheet.js +2 -1
- package/dist/xml/index.js +3 -3
- package/package.json +1 -1
|
@@ -1502,6 +1502,8 @@ const { OfficeIMOError } = _m2;
|
|
|
1502
1502
|
const { ChunkedTextSink } = _m3;
|
|
1503
1503
|
|
|
1504
1504
|
const xmlDeclaration = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
|
|
1505
|
+
const xmlEscapes = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'",
|
|
1506
|
+
"\r": " ", "\n": " ", "\t": "	" };
|
|
1505
1507
|
/** XML 1.0 characters; Unicode mode retains valid surrogate pairs. */
|
|
1506
1508
|
function cleanXml(value, policy = "strip") {
|
|
1507
1509
|
if (policy !== "strip" && policy !== "reject")
|
|
@@ -1513,9 +1515,7 @@ function cleanXml(value, policy = "strip") {
|
|
|
1513
1515
|
}
|
|
1514
1516
|
/** Escape data, including whitespace that XML parsers otherwise normalize. */
|
|
1515
1517
|
function escapeXml(value, policy = "strip") {
|
|
1516
|
-
|
|
1517
|
-
"\r": " ", "\n": " ", "\t": "	" };
|
|
1518
|
-
return cleanXml(value, policy).replace(/[&<>"'\r\n\t]/g, c => escapes[c]);
|
|
1518
|
+
return cleanXml(value, policy).replace(/[&<>"'\r\n\t]/g, c => xmlEscapes[c]);
|
|
1519
1519
|
}
|
|
1520
1520
|
/** Encode an OOXML ST_Xstring attribute without interpreting literal escape tokens as characters. */
|
|
1521
1521
|
function escapeOoxmlAttribute(value, policy = "strip") {
|
|
@@ -2113,8 +2113,11 @@ class OpcPackage {
|
|
|
2113
2113
|
return uri;
|
|
2114
2114
|
}
|
|
2115
2115
|
addPart(part) {
|
|
2116
|
-
const uri
|
|
2117
|
-
|
|
2116
|
+
const { uri: requestedUri, contentType, data } = part;
|
|
2117
|
+
// Structural accessors and byte ownership are captured before reserving metadata.
|
|
2118
|
+
const capturedData = data instanceof Uint8Array ? new Uint8Array(data) : data;
|
|
2119
|
+
const uri = this.reserve(requestedUri, contentType);
|
|
2120
|
+
this.parts.set(uri.toLowerCase(), { uri, contentType, data: capturedData });
|
|
2118
2121
|
}
|
|
2119
2122
|
/** @internal */
|
|
2120
2123
|
addPrepared(uri, type, prepared) {
|
|
@@ -2139,17 +2142,19 @@ class OpcPackage {
|
|
|
2139
2142
|
checkAbort(this.options.signal);
|
|
2140
2143
|
this.open();
|
|
2141
2144
|
source = source === "/" ? source : partUri(source);
|
|
2142
|
-
|
|
2145
|
+
const { id, type, target: requestedTarget, external } = relationship;
|
|
2146
|
+
this.open();
|
|
2147
|
+
if (!/^[A-Za-z_][A-Za-z0-9_.-]*$/.test(id))
|
|
2143
2148
|
throw new TypeError("Relationship id must be an XML ID.");
|
|
2144
|
-
if (!/^[A-Za-z][A-Za-z0-9+.-]*:[^\s<>"']+$/.test(
|
|
2149
|
+
if (!/^[A-Za-z][A-Za-z0-9+.-]*:[^\s<>"']+$/.test(type))
|
|
2145
2150
|
throw new TypeError("Relationship type must be an absolute URI.");
|
|
2146
|
-
const target =
|
|
2147
|
-
if (
|
|
2151
|
+
const target = external ? requestedTarget : partUri(requestedTarget);
|
|
2152
|
+
if (external && (!target || /[\u0000-\u0020]/.test(target)))
|
|
2148
2153
|
throw new TypeError("Invalid external relationship target.");
|
|
2149
2154
|
const key = source.toLowerCase(), list = this.relationships.get(key) ?? new Map();
|
|
2150
|
-
if (list.has(
|
|
2151
|
-
throw new TypeError("Duplicate relationship id: " +
|
|
2152
|
-
list.set(
|
|
2155
|
+
if (list.has(id))
|
|
2156
|
+
throw new TypeError("Duplicate relationship id: " + id);
|
|
2157
|
+
list.set(id, { id, type, target, ...(external === undefined ? {} : { external }) });
|
|
2153
2158
|
this.relationships.set(key, list);
|
|
2154
2159
|
}
|
|
2155
2160
|
setProperties(core = {}, app = {}) {
|
|
@@ -3960,7 +3965,8 @@ class Worksheet {
|
|
|
3960
3965
|
});
|
|
3961
3966
|
const originalCharacters = typeof value === "string" ? value.length : 0;
|
|
3962
3967
|
let reservedCharacters = this.preserved || header || footer ? originalCharacters : undefined;
|
|
3963
|
-
|
|
3968
|
+
// Cleaning removes characters; ordinary strings cannot cross Excel's limit.
|
|
3969
|
+
if (type === "string" && originalCharacters > 32767 && cleanXml(value, this.book.settings.invalidCharacterPolicy).length > 32767) {
|
|
3964
3970
|
const cell = col.letter + row;
|
|
3965
3971
|
if (link || this.linkedCells.has(cell))
|
|
3966
3972
|
throw new TypeError("A text-preservation cell cannot also have an external hyperlink.");
|
|
@@ -5158,12 +5164,15 @@ class Workbook {
|
|
|
5158
5164
|
});
|
|
5159
5165
|
}
|
|
5160
5166
|
addPart(part) {
|
|
5167
|
+
this.assertOpen();
|
|
5168
|
+
const { uri, contentType, data, relationship } = part;
|
|
5169
|
+
const capturedRelationship = relationship && { id: relationship.id, type: relationship.type, source: relationship.source };
|
|
5161
5170
|
this.assertOpen();
|
|
5162
5171
|
// Reserve now so collisions and invalid names fail at the call site.
|
|
5163
|
-
this.package.addPart(
|
|
5164
|
-
if (
|
|
5165
|
-
const { source,
|
|
5166
|
-
this.package.addRelationship(source ?? "/xl/workbook.xml", {
|
|
5172
|
+
this.package.addPart({ uri, contentType, data });
|
|
5173
|
+
if (capturedRelationship) {
|
|
5174
|
+
const { source, id, type } = capturedRelationship;
|
|
5175
|
+
this.package.addRelationship(source ?? "/xl/workbook.xml", { id, type, target: uri });
|
|
5167
5176
|
}
|
|
5168
5177
|
}
|
|
5169
5178
|
/** Complete the archive and return counts. Does not close or dispose a caller-owned sink. */
|
|
@@ -8860,7 +8869,7 @@ class PdfPages {
|
|
|
8860
8869
|
// Charge physical repeats without recapturing callbacks or making them semantic duplicates.
|
|
8861
8870
|
for (const cell of header.cells)
|
|
8862
8871
|
if (!this.bandCellBudget && this.paintedHeaderBudgetCells.has(cell.source ?? cell))
|
|
8863
|
-
this.settings.budget.cell(cell.lines.map(line => line.text).join(""));
|
|
8872
|
+
this.settings.budget.cell(this.settings.budget.limits.maxTextCharacters === undefined ? "" : cell.lines.map(line => line.text).join(""));
|
|
8864
8873
|
const elements = this.tableStructure ? header.cells.map(cell => this.tableStructure.owner(cell.source ?? cell)) : undefined;
|
|
8865
8874
|
const repeated = header.cells.map(cell => this.paintedHeaderCells.has(cell.source ?? cell));
|
|
8866
8875
|
this.draw(header, 0, header.lines, elements, repeated);
|
|
@@ -8881,7 +8890,8 @@ class PdfPages {
|
|
|
8881
8890
|
const { padding, fontSize } = this.settings, n = pdfNumber, height = lineCount * row.lineHeight + padding * 2;
|
|
8882
8891
|
for (const [index, cell] of row.cells.entries()) {
|
|
8883
8892
|
if (this.bandCellBudget)
|
|
8884
|
-
this.settings.budget.cell(
|
|
8893
|
+
this.settings.budget.cell(this.settings.budget.limits.maxTextCharacters === undefined ? "" :
|
|
8894
|
+
(cell.height === undefined ? cell.lines.slice(firstLine, firstLine + lineCount) : cell.lines).map(line => line.text).join(""));
|
|
8885
8895
|
const x = this.layout.lefts[cell.first], cellHeight = cell.height ?? height;
|
|
8886
8896
|
if (cell.style.background)
|
|
8887
8897
|
this.add(this.artifact("q " + this.rgb(cell.style.background) + " rg " + n(x) + " " + n(this.y - cellHeight) + " " + n(cell.width) + " " + n(cellHeight) + " re f Q\n"));
|