@file-viewer/renderer-spreadsheet 2.2.2 → 2.2.4
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 +41 -16
- package/package.json +5 -5
package/dist/spreadsheet.js
CHANGED
|
@@ -10,6 +10,8 @@ const E_VIRT_TABLE_STYLE_MARKERS = [
|
|
|
10
10
|
'.e-virt-table-editor',
|
|
11
11
|
'.e-virt-table-context-menu',
|
|
12
12
|
];
|
|
13
|
+
const SPREADSHEET_STYLE_SCOPE = '.excel-wrapper[data-file-viewer-spreadsheet-root]';
|
|
14
|
+
const E_VIRT_TABLE_ROTATE_KEYFRAME = 'file-viewer-e-virt-table-rotate';
|
|
13
15
|
const spreadsheetStyle = `
|
|
14
16
|
.excel-wrapper{position:relative;width:100%;height:100%;display:flex;flex-direction:column;background:var(--file-viewer-render-surface-background,#fff);color:#172033;font-family:Aptos,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif}
|
|
15
17
|
.excel-wrapper *{box-sizing:border-box}
|
|
@@ -20,7 +22,7 @@ const spreadsheetStyle = `
|
|
|
20
22
|
.excel-wrapper .table-host .e-virt-table-container{height:100%!important}
|
|
21
23
|
.excel-wrapper .table-host .e-virt-table-stage{overflow:hidden}
|
|
22
24
|
.excel-wrapper .sheet-loading{position:absolute;right:18px;bottom:18px;z-index:20;display:inline-flex;align-items:center;gap:8px;padding:10px 14px;border-radius:14px;background:rgba(33,163,102,.1);border:1px solid rgba(33,163,102,.2);box-shadow:0 8px 20px rgba(33,163,102,.12);color:#1a7f50;font-size:12px;font-weight:700;pointer-events:none}
|
|
23
|
-
.excel-wrapper .sheet-loading-dot{width:8px;height:8px;flex-shrink:0;border-radius:999px;background:#21a366;box-shadow:0 0 0 6px rgba(33,163,102,.12);animation:
|
|
25
|
+
.excel-wrapper .sheet-loading-dot{width:8px;height:8px;flex-shrink:0;border-radius:999px;background:#21a366;box-shadow:0 0 0 6px rgba(33,163,102,.12);animation:file-viewer-spreadsheet-loading-pulse 1.2s ease-in-out infinite}
|
|
24
26
|
.excel-wrapper .sheet-loading-summary{color:#5f6368}
|
|
25
27
|
.excel-wrapper .excel-image-viewport{position:absolute;z-index:35;overflow:hidden;pointer-events:none}
|
|
26
28
|
.excel-wrapper .excel-image-layer{position:absolute;inset:0 auto auto 0;width:0;height:0;transform-origin:0 0;will-change:transform}
|
|
@@ -34,7 +36,7 @@ const spreadsheetStyle = `
|
|
|
34
36
|
.excel-wrapper .loading-kicker{display:block;color:#21a366;font-size:12px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}
|
|
35
37
|
.excel-wrapper .loading-copy strong{display:block;margin-top:6px;color:#183828;font-size:20px;line-height:1.3}
|
|
36
38
|
.excel-wrapper .loading-copy p{margin:8px 0 0;color:#64748b;font-size:13px;line-height:1.5}
|
|
37
|
-
.excel-wrapper .loading-spinner{width:28px;height:28px;border-radius:999px;border:3px solid rgba(33,163,102,.16);border-top-color:#21a366;animation:
|
|
39
|
+
.excel-wrapper .loading-spinner{width:28px;height:28px;border-radius:999px;border:3px solid rgba(33,163,102,.16);border-top-color:#21a366;animation:file-viewer-spreadsheet-loading-spin .8s linear infinite}
|
|
38
40
|
.excel-wrapper .error{position:absolute;left:50%;top:50%;z-index:1000;transform:translate(-50%,-50%);max-width:min(520px,calc(100% - 48px));padding:16px 18px;border-radius:16px;background:#fff7ed;color:#9a3412;border:1px solid rgba(234,88,12,.18);box-shadow:0 18px 42px rgba(154,52,18,.12);font-size:14px;line-height:1.6}
|
|
39
41
|
.excel-wrapper .toolbar{min-height:44px;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 12px;border-top:1px solid #e5e7eb;background:#f8fafc}
|
|
40
42
|
.excel-wrapper .btn-group{min-width:0;max-width:100%;flex:1 1 auto;display:flex;align-items:center;gap:6px;overflow-x:auto;overflow-y:hidden;scrollbar-gutter:stable;scrollbar-width:thin;overscroll-behavior-x:contain}
|
|
@@ -55,10 +57,11 @@ const spreadsheetStyle = `
|
|
|
55
57
|
.excel-wrapper[data-spreadsheet-theme='dark'] .loading-copy strong{color:#f0fdf4}
|
|
56
58
|
.excel-wrapper[data-spreadsheet-theme='dark'] .loading-copy p{color:#94a3b8}
|
|
57
59
|
.excel-wrapper[data-spreadsheet-theme='dark'] .error{border-color:rgba(251,146,60,.28);background:#2a1710;color:#fdba74;box-shadow:0 20px 48px rgba(0,0,0,.36)}
|
|
58
|
-
@keyframes
|
|
59
|
-
@keyframes
|
|
60
|
+
@keyframes file-viewer-spreadsheet-loading-spin{to{transform:rotate(360deg)}}
|
|
61
|
+
@keyframes file-viewer-spreadsheet-loading-pulse{0%,100%{opacity:.55;transform:scale(.9)}50%{opacity:1;transform:scale(1)}}
|
|
60
62
|
@media (max-width:720px){.excel-wrapper .toolbar{align-items:stretch;flex-direction:column}.excel-wrapper .btn-group{flex:0 0 auto}.excel-wrapper .summary{max-width:none;white-space:normal}.excel-wrapper .sheet-loading{left:12px;right:12px;bottom:58px;justify-content:center}.excel-wrapper .loading-card{margin:18px;flex-direction:column;text-align:center}}
|
|
61
63
|
`;
|
|
64
|
+
const scopedSpreadsheetStyle = spreadsheetStyle.replace(/\.excel-wrapper/g, SPREADSHEET_STYLE_SCOPE);
|
|
62
65
|
const isEVirtTableConstructor = (value) => {
|
|
63
66
|
return typeof value === 'function';
|
|
64
67
|
};
|
|
@@ -106,10 +109,11 @@ const collectEVirtTableStyleDocuments = (documentRef) => [
|
|
|
106
109
|
const collectStyleElements = (documents) => documents.flatMap(candidateDocument => { var _a; return Array.from(((_a = candidateDocument.head) === null || _a === void 0 ? void 0 : _a.querySelectorAll('style')) || []); });
|
|
107
110
|
let loadedEVirtTableStyleText = '';
|
|
108
111
|
// e-virt-table bundles its complete stylesheet into the ESM entry and injects
|
|
109
|
-
//
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
112
|
+
// unscoped :root, .dark, and table selectors into document.head. Capture that
|
|
113
|
+
// exact version-matched CSS, remove only the node created by our import, and
|
|
114
|
+
// install a scoped copy beside the renderer for both light and shadow DOM.
|
|
115
|
+
// Independent layout, overlay, editor, and menu markers avoid mistaking an
|
|
116
|
+
// app's partial compatibility overrides for the complete vendor sheet.
|
|
113
117
|
export const resolveEVirtTableStyleText = (documentRef) => {
|
|
114
118
|
var _a;
|
|
115
119
|
const styles = collectStyleElements(collectEVirtTableStyleDocuments(documentRef));
|
|
@@ -130,6 +134,7 @@ const loadEVirtTable = async (documentRef) => {
|
|
|
130
134
|
if (injectedStyle) {
|
|
131
135
|
loadedEVirtTableStyleText = injectedStyle.textContent || '';
|
|
132
136
|
}
|
|
137
|
+
injectedStyles.forEach(style => style.remove());
|
|
133
138
|
return {
|
|
134
139
|
constructor: resolveEVirtTableConstructor(module),
|
|
135
140
|
// The vendor entry injects CSS while its dynamic import is evaluated.
|
|
@@ -139,13 +144,32 @@ const loadEVirtTable = async (documentRef) => {
|
|
|
139
144
|
};
|
|
140
145
|
};
|
|
141
146
|
export const scopeEVirtTableStyleText = (cssText, shadow) => {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
const rootScope = shadow
|
|
148
|
+
? `:host,${SPREADSHEET_STYLE_SCOPE}`
|
|
149
|
+
: SPREADSHEET_STYLE_SCOPE;
|
|
150
|
+
const darkScope = shadow
|
|
151
|
+
? `:host(.dark),${SPREADSHEET_STYLE_SCOPE}[data-spreadsheet-theme='dark']`
|
|
152
|
+
: `${SPREADSHEET_STYLE_SCOPE}[data-spreadsheet-theme='dark']`;
|
|
153
|
+
const scopeSelector = (selector) => {
|
|
154
|
+
const normalized = selector.trim();
|
|
155
|
+
if (normalized === ':root') {
|
|
156
|
+
return rootScope;
|
|
157
|
+
}
|
|
158
|
+
if (normalized === '.dark') {
|
|
159
|
+
return darkScope;
|
|
160
|
+
}
|
|
161
|
+
return `${SPREADSHEET_STYLE_SCOPE} ${normalized}`;
|
|
162
|
+
};
|
|
163
|
+
return cssText
|
|
164
|
+
.replace(/@keyframes\s+rotate\b/g, `@keyframes ${E_VIRT_TABLE_ROTATE_KEYFRAME}`)
|
|
165
|
+
.replace(/animation:\s*rotate\b/g, `animation:${E_VIRT_TABLE_ROTATE_KEYFRAME}`)
|
|
166
|
+
.replace(/(^|})\s*(:root|\.dark|\.e-virt-table-[^{}]+)\{/g, (_match, boundary, selectorList) => {
|
|
167
|
+
const scopedSelectors = selectorList
|
|
168
|
+
.split(',')
|
|
169
|
+
.map(scopeSelector)
|
|
170
|
+
.join(',');
|
|
171
|
+
return `${boundary}${scopedSelectors}{`;
|
|
172
|
+
});
|
|
149
173
|
};
|
|
150
174
|
const getTargetWindow = (target) => {
|
|
151
175
|
return target.ownerDocument.defaultView;
|
|
@@ -407,7 +431,7 @@ const createSpreadsheetWorkerFactory = (target, bufferByteLength, context) => {
|
|
|
407
431
|
}
|
|
408
432
|
};
|
|
409
433
|
};
|
|
410
|
-
const createStyle = (documentRef, cssText =
|
|
434
|
+
const createStyle = (documentRef, cssText = scopedSpreadsheetStyle) => {
|
|
411
435
|
const style = documentRef.createElement('style');
|
|
412
436
|
style.textContent = cssText;
|
|
413
437
|
return style;
|
|
@@ -511,6 +535,7 @@ const renderFileViewerSpreadsheet = async (buffer, target, type, context) => {
|
|
|
511
535
|
const darkMode = resolveFileViewerColorScheme((_d = context === null || context === void 0 ? void 0 : context.options) === null || _d === void 0 ? void 0 : _d.theme, systemDark) === 'dark';
|
|
512
536
|
const root = documentRef.createElement('div');
|
|
513
537
|
root.className = 'excel-wrapper';
|
|
538
|
+
root.dataset.fileViewerSpreadsheetRoot = 'true';
|
|
514
539
|
root.dataset.spreadsheetTheme = darkMode ? 'dark' : 'light';
|
|
515
540
|
root.dataset.viewerZoomProvider = 'xlsx';
|
|
516
541
|
const loading = documentRef.createElement('div');
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/renderer-spreadsheet",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"description": "Standalone spreadsheet renderer plugin for
|
|
6
|
+
"description": "Standalone spreadsheet renderer plugin for File Viewer powered by styled-exceljs and e-virt-table.",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"file-viewer",
|
|
9
9
|
"renderer",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"registry": "https://registry.npmjs.org/"
|
|
26
26
|
},
|
|
27
27
|
"author": {
|
|
28
|
-
"name": "
|
|
29
|
-
"email": "
|
|
28
|
+
"name": "Yu Wang",
|
|
29
|
+
"email": "admin@flyfish.dev"
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"LICENSE"
|
|
71
71
|
],
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@file-viewer/core": "2.2.
|
|
73
|
+
"@file-viewer/core": "2.2.4",
|
|
74
74
|
"@xmldom/xmldom": "^0.9.10",
|
|
75
75
|
"e-virt-table": "^1.3.26",
|
|
76
76
|
"jszip": "^3.10.1",
|