@open-file-viewer/core 0.1.17 → 0.1.18
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 +6 -6
- package/dist/index.cjs +22 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -11
- package/dist/index.js.map +1 -1
- package/dist/style.css +2 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -331,7 +331,7 @@ function getFileNameFromUrl(source) {
|
|
|
331
331
|
function getExtension(name) {
|
|
332
332
|
const clean = name.split("?")[0]?.split("#")[0] || "";
|
|
333
333
|
const index = clean.lastIndexOf(".");
|
|
334
|
-
return index >= 0 ? clean.slice(index + 1).toLowerCase() : "";
|
|
334
|
+
return index >= 0 ? clean.slice(index + 1).split("!", 1)[0].toLowerCase() : "";
|
|
335
335
|
}
|
|
336
336
|
function isTextLike(file) {
|
|
337
337
|
const textFileName = normalizeFileName(file.name);
|
|
@@ -590,7 +590,7 @@ var defaultMessages = {
|
|
|
590
590
|
};
|
|
591
591
|
function resolveMessages(options) {
|
|
592
592
|
return {
|
|
593
|
-
...defaultMessages[options.locale || "
|
|
593
|
+
...defaultMessages[options.locale || "en-US"],
|
|
594
594
|
...options.messages
|
|
595
595
|
};
|
|
596
596
|
}
|
|
@@ -8464,7 +8464,7 @@ async function renderSheet(panel, arrayBuffer, extension) {
|
|
|
8464
8464
|
heading.textContent = sheetName;
|
|
8465
8465
|
const sheet = workbook.Sheets[sheetName];
|
|
8466
8466
|
const sheetImages = workbookImages.get(sheetName) || [];
|
|
8467
|
-
const range = trimWorkbookSheetRange(sheet, xlsx.utils.decode_range(sheet["!ref"] || "A1:A1"), xlsx.utils.decode_cell);
|
|
8467
|
+
const range = trimWorkbookSheetRange(sheet, xlsx.utils.decode_range(sheet["!ref"] || "A1:A1"), xlsx.utils.decode_cell, sheetImages);
|
|
8468
8468
|
const rowCount = range.e.r - range.s.r + 1;
|
|
8469
8469
|
const columnCount = range.e.c - range.s.c + 1;
|
|
8470
8470
|
const formulaRows = collectFormulaRows(sheet, range, xlsx.utils.encode_cell);
|
|
@@ -8563,7 +8563,7 @@ function renderSheetFallback(panel, extension, detail) {
|
|
|
8563
8563
|
async function readWorkbookSheetImages(arrayBuffer) {
|
|
8564
8564
|
const zip = await JSZip3.loadAsync(arrayBuffer);
|
|
8565
8565
|
const fileNames = Object.keys(zip.files);
|
|
8566
|
-
if (!fileNames.some((name) => /^xl\/drawings\/.+\.xml$/i.test(name))
|
|
8566
|
+
if (!fileNames.some((name) => /^xl\/drawings\/.+\.xml$/i.test(name))) {
|
|
8567
8567
|
return /* @__PURE__ */ new Map();
|
|
8568
8568
|
}
|
|
8569
8569
|
const workbookXml = await zip.file("xl/workbook.xml")?.async("text");
|
|
@@ -8623,6 +8623,7 @@ async function readWorksheetDrawingImages(zip, drawingPath) {
|
|
|
8623
8623
|
const images = [];
|
|
8624
8624
|
for (const anchor of anchors) {
|
|
8625
8625
|
const from = Array.from(anchor.children).find((element) => element.localName === "from");
|
|
8626
|
+
const to = Array.from(anchor.children).find((element) => element.localName === "to");
|
|
8626
8627
|
const embedId = findDrawingImageRelationshipId(anchor);
|
|
8627
8628
|
const mediaRel = drawingRels.find((rel) => rel.id === embedId && /\/image$/i.test(rel.type));
|
|
8628
8629
|
const mediaPath = resolveOfficeRelationshipTarget(drawingPath, mediaRel?.target);
|
|
@@ -8634,6 +8635,8 @@ async function readWorksheetDrawingImages(zip, drawingPath) {
|
|
|
8634
8635
|
images.push({
|
|
8635
8636
|
row: readDrawingMarkerIndex(from, "row"),
|
|
8636
8637
|
column: readDrawingMarkerIndex(from, "col"),
|
|
8638
|
+
endRow: to ? readDrawingMarkerIndex(to, "row") : void 0,
|
|
8639
|
+
endColumn: to ? readDrawingMarkerIndex(to, "col") : void 0,
|
|
8637
8640
|
fileName: mediaPath.split("/").pop() || "image",
|
|
8638
8641
|
mimeType,
|
|
8639
8642
|
dataUrl: `data:${mimeType};base64,${await mediaFile.async("base64")}`,
|
|
@@ -9089,7 +9092,7 @@ function chartText(element) {
|
|
|
9089
9092
|
function chartStringValues(element) {
|
|
9090
9093
|
return Array.from(element.querySelectorAll("*")).filter((item) => item.localName === "v" || item.localName === "t").map((item) => item.textContent?.trim() || "").filter(Boolean);
|
|
9091
9094
|
}
|
|
9092
|
-
function trimWorkbookSheetRange(sheet, range, decodeCell) {
|
|
9095
|
+
function trimWorkbookSheetRange(sheet, range, decodeCell, images = []) {
|
|
9093
9096
|
let minRow = Number.POSITIVE_INFINITY;
|
|
9094
9097
|
let minColumn = Number.POSITIVE_INFINITY;
|
|
9095
9098
|
let maxRow = Number.NEGATIVE_INFINITY;
|
|
@@ -9114,17 +9117,21 @@ function trimWorkbookSheetRange(sheet, range, decodeCell) {
|
|
|
9114
9117
|
include(merge.s.r, merge.s.c);
|
|
9115
9118
|
include(merge.e.r, merge.e.c);
|
|
9116
9119
|
}
|
|
9120
|
+
for (const image of images) {
|
|
9121
|
+
include(image.row, image.column);
|
|
9122
|
+
include(image.endRow ?? image.row, image.endColumn ?? image.column);
|
|
9123
|
+
}
|
|
9117
9124
|
if (!Number.isFinite(minRow) || !Number.isFinite(minColumn) || !Number.isFinite(maxRow) || !Number.isFinite(maxColumn)) {
|
|
9118
9125
|
return range;
|
|
9119
9126
|
}
|
|
9120
9127
|
return {
|
|
9121
9128
|
s: {
|
|
9122
|
-
r:
|
|
9123
|
-
c:
|
|
9129
|
+
r: minRow,
|
|
9130
|
+
c: minColumn
|
|
9124
9131
|
},
|
|
9125
9132
|
e: {
|
|
9126
|
-
r:
|
|
9127
|
-
c:
|
|
9133
|
+
r: maxRow,
|
|
9134
|
+
c: maxColumn
|
|
9128
9135
|
}
|
|
9129
9136
|
};
|
|
9130
9137
|
}
|
|
@@ -9255,7 +9262,9 @@ function createWorkbookSheetTable(sheet, range, sheetIndex, viewport, encodeCell
|
|
|
9255
9262
|
cell.classList.add("ofv-cell-multiline");
|
|
9256
9263
|
}
|
|
9257
9264
|
appendWorkbookCellImages(cell, imagesByCell.get(`${rowIndex}:${columnIndex}`), text);
|
|
9258
|
-
|
|
9265
|
+
if (rowIndex === rowStart) {
|
|
9266
|
+
appendColumnResizeHandle(cell, columnIndex, columnSizing);
|
|
9267
|
+
}
|
|
9259
9268
|
row.append(cell);
|
|
9260
9269
|
}
|
|
9261
9270
|
table.append(row);
|
|
@@ -9481,7 +9490,9 @@ function createParsedSheetTable(sheet, sheetIndex, viewport, columnSizing, reren
|
|
|
9481
9490
|
if (value.includes("\n")) {
|
|
9482
9491
|
cell.classList.add("ofv-cell-multiline");
|
|
9483
9492
|
}
|
|
9484
|
-
|
|
9493
|
+
if (rowIndex === viewport.rowStart) {
|
|
9494
|
+
appendColumnResizeHandle(cell, columnIndex, columnSizing);
|
|
9495
|
+
}
|
|
9485
9496
|
row.append(cell);
|
|
9486
9497
|
}
|
|
9487
9498
|
table.append(row);
|