@file-viewer/renderer-spreadsheet 2.1.11 → 2.1.13
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/spreadsheet.js +67 -7
- package/package.json +2 -2
package/dist/spreadsheet.js
CHANGED
|
@@ -351,6 +351,8 @@ const renderFileViewerSpreadsheet = async (buffer, target, _type, context) => {
|
|
|
351
351
|
let resizeObserver = null;
|
|
352
352
|
let resizeFrame = 0;
|
|
353
353
|
let scrollFrame = 0;
|
|
354
|
+
let layoutRefreshToken = 0;
|
|
355
|
+
const layoutRefreshTimers = [];
|
|
354
356
|
let viewportRange = { start: 0, end: 0 };
|
|
355
357
|
let scrollDirection = 1;
|
|
356
358
|
let lastScrollY = 0;
|
|
@@ -701,6 +703,59 @@ const renderFileViewerSpreadsheet = async (buffer, target, _type, context) => {
|
|
|
701
703
|
syncImageViewport();
|
|
702
704
|
scheduleViewportLoad();
|
|
703
705
|
}
|
|
706
|
+
const clearScheduledLayoutRefresh = () => {
|
|
707
|
+
layoutRefreshToken += 1;
|
|
708
|
+
const view = getTargetWindow(target);
|
|
709
|
+
while (layoutRefreshTimers.length) {
|
|
710
|
+
const timer = layoutRefreshTimers.pop();
|
|
711
|
+
if (timer !== undefined) {
|
|
712
|
+
view === null || view === void 0 ? void 0 : view.clearTimeout(timer);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
const refreshTableLayoutWhenVisible = () => {
|
|
717
|
+
if (disposed || !table || !virtualState.active) {
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
const rect = tableHost.getBoundingClientRect();
|
|
721
|
+
if (rect.width <= 0 || rect.height <= 0) {
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
syncTableLayout();
|
|
725
|
+
};
|
|
726
|
+
const scheduleStableFirstPaintRefresh = () => {
|
|
727
|
+
var _a;
|
|
728
|
+
clearScheduledLayoutRefresh();
|
|
729
|
+
const token = layoutRefreshToken;
|
|
730
|
+
const view = getTargetWindow(target);
|
|
731
|
+
if (!view) {
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
const delays = [0, 32, 120, 300, 700];
|
|
735
|
+
delays.forEach((delay) => {
|
|
736
|
+
const timer = view.setTimeout(() => {
|
|
737
|
+
const index = layoutRefreshTimers.indexOf(timer);
|
|
738
|
+
if (index >= 0) {
|
|
739
|
+
layoutRefreshTimers.splice(index, 1);
|
|
740
|
+
}
|
|
741
|
+
view.requestAnimationFrame(() => {
|
|
742
|
+
if (token !== layoutRefreshToken) {
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
refreshTableLayoutWhenVisible();
|
|
746
|
+
});
|
|
747
|
+
}, delay);
|
|
748
|
+
layoutRefreshTimers.push(timer);
|
|
749
|
+
});
|
|
750
|
+
void ((_a = documentRef.fonts) === null || _a === void 0 ? void 0 : _a.ready.then(() => {
|
|
751
|
+
if (token !== layoutRefreshToken) {
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
refreshTableLayoutWhenVisible();
|
|
755
|
+
}).catch(() => {
|
|
756
|
+
// Font readiness is only a paint stabilizer; rendering already has a fallback.
|
|
757
|
+
}));
|
|
758
|
+
};
|
|
704
759
|
function setColumnWidthByKey(columns, key, width) {
|
|
705
760
|
for (const column of columns) {
|
|
706
761
|
if (`${column.key}` === key) {
|
|
@@ -813,12 +868,6 @@ const renderFileViewerSpreadsheet = async (buffer, target, _type, context) => {
|
|
|
813
868
|
totalRows = meta.totalRows;
|
|
814
869
|
totalCols = meta.totalCols;
|
|
815
870
|
syncWindowStats();
|
|
816
|
-
queueMicrotask(() => {
|
|
817
|
-
if (disposed) {
|
|
818
|
-
return;
|
|
819
|
-
}
|
|
820
|
-
renderTable(ensureTable(), columns, virtualState.rows, true);
|
|
821
|
-
});
|
|
822
871
|
};
|
|
823
872
|
const clearVirtualRow = (row) => {
|
|
824
873
|
virtualState.dataKeys.forEach((key) => {
|
|
@@ -941,6 +990,7 @@ const renderFileViewerSpreadsheet = async (buffer, target, _type, context) => {
|
|
|
941
990
|
if (!meta) {
|
|
942
991
|
return;
|
|
943
992
|
}
|
|
993
|
+
const isFirstWindow = !hasInitialWindow;
|
|
944
994
|
if (!virtualState.active) {
|
|
945
995
|
initializeVirtualSheet(ws);
|
|
946
996
|
}
|
|
@@ -955,7 +1005,12 @@ const renderFileViewerSpreadsheet = async (buffer, target, _type, context) => {
|
|
|
955
1005
|
if (activeSheetId !== undefined) {
|
|
956
1006
|
sheetStateCache.set(activeSheetId, virtualState);
|
|
957
1007
|
}
|
|
958
|
-
|
|
1008
|
+
if (isFirstWindow) {
|
|
1009
|
+
renderTable(ensureTable(), virtualState.columns, virtualState.rows, true);
|
|
1010
|
+
}
|
|
1011
|
+
else {
|
|
1012
|
+
table === null || table === void 0 ? void 0 : table.draw();
|
|
1013
|
+
}
|
|
959
1014
|
loadingState = false;
|
|
960
1015
|
sheetInitializing = false;
|
|
961
1016
|
renderChrome();
|
|
@@ -963,6 +1018,9 @@ const renderFileViewerSpreadsheet = async (buffer, target, _type, context) => {
|
|
|
963
1018
|
hasNotifiedFirstPaint = true;
|
|
964
1019
|
(_a = context === null || context === void 0 ? void 0 : context.onProgressiveRender) === null || _a === void 0 ? void 0 : _a.call(context);
|
|
965
1020
|
}
|
|
1021
|
+
if (isFirstWindow) {
|
|
1022
|
+
scheduleStableFirstPaintRefresh();
|
|
1023
|
+
}
|
|
966
1024
|
const start = viewportRange.start || meta.startRow;
|
|
967
1025
|
const end = Math.max(viewportRange.end, meta.endRow - 1, meta.startRow);
|
|
968
1026
|
ensureViewportWindows(start, end);
|
|
@@ -1014,6 +1072,7 @@ const renderFileViewerSpreadsheet = async (buffer, target, _type, context) => {
|
|
|
1014
1072
|
}
|
|
1015
1073
|
renderTable(ensureTable(), cached.columns, cached.rows);
|
|
1016
1074
|
syncImageViewport();
|
|
1075
|
+
scheduleStableFirstPaintRefresh();
|
|
1017
1076
|
});
|
|
1018
1077
|
return true;
|
|
1019
1078
|
};
|
|
@@ -1128,6 +1187,7 @@ const renderFileViewerSpreadsheet = async (buffer, target, _type, context) => {
|
|
|
1128
1187
|
if (scrollFrame) {
|
|
1129
1188
|
cancelAnimationFrame(scrollFrame);
|
|
1130
1189
|
}
|
|
1190
|
+
clearScheduledLayoutRefresh();
|
|
1131
1191
|
resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
|
|
1132
1192
|
resizeObserver = null;
|
|
1133
1193
|
unregisterFileViewerZoomProvider(root);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/renderer-spreadsheet",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.13",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Standalone spreadsheet renderer plugin for Flyfish File Viewer powered by styled-exceljs and e-virt-table.",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"LICENSE"
|
|
69
69
|
],
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@file-viewer/core": "^2.1.
|
|
71
|
+
"@file-viewer/core": "^2.1.13",
|
|
72
72
|
"e-virt-table": "^1.3.26",
|
|
73
73
|
"styled-exceljs": "0.21.1",
|
|
74
74
|
"tinycolor2": "^1.6.0"
|