office-viewer 0.3.1 → 0.3.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.
@@ -0,0 +1,500 @@
1
+ @charset "UTF-8";
2
+ /* 默认 CSS 样式,目前主要是 Excel 使用 */
3
+ .ov-excel {
4
+ /* 从 office 365 中复制的默认字体 */
5
+ font-family: "Aptos Narrow", "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
6
+ display: flex;
7
+ flex-direction: column;
8
+ --bar-bg-color: #f5f5f5;
9
+ --bar-input-bg-color: #ffffff;
10
+ --active-sheet-color: #217346;
11
+ }
12
+
13
+ .excel-button {
14
+ height: 32px;
15
+ color: rgb(255, 255, 255);
16
+ padding: 0px 11px;
17
+ box-sizing: border-box;
18
+ border: 1px solid transparent;
19
+ display: inline-block;
20
+ text-decoration: none;
21
+ text-align: center;
22
+ cursor: pointer;
23
+ vertical-align: top;
24
+ border-radius: 2px;
25
+ font-size: 14px;
26
+ font-weight: 600;
27
+ position: relative;
28
+ margin-right: 4px;
29
+ width: 64px;
30
+ }
31
+
32
+ .excel-button-primary {
33
+ background-color: rgb(0, 120, 212);
34
+ }
35
+
36
+ /* Excel 工具栏,目前没编辑功能所以还没实现 */
37
+ .ov-excel-toolbar {
38
+ height: 30px;
39
+ line-height: 30px;
40
+ }
41
+
42
+ .excel-checkbox-list-wrapper .excel-checkbox-list {
43
+ margin-top: 4px;
44
+ }
45
+
46
+ .excel-checkbox-container label {
47
+ cursor: pointer;
48
+ padding: 4px 0;
49
+ display: block;
50
+ }
51
+
52
+ .excel-checkbox-container label:hover {
53
+ background-color: #f6f6f6;
54
+ }
55
+
56
+ .excel-checkbox-container input {
57
+ vertical-align: middle;
58
+ }
59
+
60
+ .excel-checkbox-container span {
61
+ vertical-align: middle;
62
+ }
63
+
64
+ .excel-divider {
65
+ display: block;
66
+ height: 1px;
67
+ background-color: rgb(225, 223, 221);
68
+ margin: 2px 12px 2px;
69
+ color: rgb(200, 198, 196);
70
+ border-radius: 0.5px;
71
+ }
72
+
73
+ .excel-input {
74
+ display: inline-block;
75
+ box-sizing: border-box;
76
+ width: 100%;
77
+ border-radius: 4px;
78
+ padding: 4px 12px;
79
+ border: 1px solid rgb(209, 209, 209);
80
+ }
81
+
82
+ .excel-input-border-less {
83
+ display: block;
84
+ border: none;
85
+ width: 100%;
86
+ height: 100%;
87
+ padding: 0 2px;
88
+ }
89
+
90
+ .excel-input-border-less:focus {
91
+ outline: none;
92
+ }
93
+
94
+ .excel-select {
95
+ border-color: rgb(209, 209, 209);
96
+ border-radius: 4px;
97
+ }
98
+
99
+ /* Excel 公式栏 */
100
+ .ov-excel-formula-bar {
101
+ height: 34px;
102
+ display: flex;
103
+ flex-direction: row;
104
+ background-color: var(--bar-bg-color);
105
+ }
106
+
107
+ .ov-excel-formula-bar__name-box {
108
+ text-align: center;
109
+ width: 64px;
110
+ margin: 4px 0 4px 4px;
111
+ padding: 0 4px;
112
+ line-height: 26px;
113
+ border: 1px solid #e1dfdd;
114
+ background-color: var(--bar-input-bg-color);
115
+ }
116
+
117
+ /* fx 按钮 */
118
+ .ov-excel-formula-bar__function-button {
119
+ width: 30px;
120
+ }
121
+
122
+ /* fx 按钮右边的输入框 */
123
+ .ov-excel-formula-bar__text-box {
124
+ margin: 4px;
125
+ line-height: 26px;
126
+ border: 1px solid #e1dfdd;
127
+ flex: 1;
128
+ padding: 0 4px;
129
+ background-color: var(--bar-input-bg-color);
130
+ }
131
+
132
+ /* Excel sheet 标签页 */
133
+ .ov-excel-sheet-tab-bar {
134
+ height: 32px;
135
+ line-height: 32px;
136
+ display: flex;
137
+ flex-direction: row;
138
+ background-color: var(--bar-bg-color);
139
+ }
140
+
141
+ .ov-excel-sheet-tab-bar__nav {
142
+ display: flex;
143
+ }
144
+
145
+ .ov-excel-sheet-tab-bar__nav-icon {
146
+ height: 16px;
147
+ padding: 4px 4px;
148
+ }
149
+
150
+ .ov-excel-sheet-tab-bar__nav-icon svg {
151
+ height: 16px;
152
+ width: 16px;
153
+ }
154
+
155
+ .ov-excel-sheet-tab-bar__nav-icon svg path {
156
+ fill: #b1b1b1;
157
+ }
158
+
159
+ .ov-excel-sheet-tab-bar__nav-icon--enabled {
160
+ cursor: pointer;
161
+ }
162
+
163
+ .ov-excel-sheet-tab-bar__nav-icon--enabled svg path {
164
+ fill: #000000;
165
+ }
166
+
167
+ .ov-excel-sheet-tab-bar__menu {
168
+ position: relative;
169
+ }
170
+
171
+ .ov-excel-sheet-tab-bar__menu-icon {
172
+ cursor: pointer;
173
+ height: 16px;
174
+ padding: 4px 8px;
175
+ }
176
+
177
+ .ov-excel-sheet-tab-bar__menu-icon svg {
178
+ height: 16px;
179
+ width: 16px;
180
+ }
181
+
182
+ .ov-excel-sheet-tab-bar__menu-list {
183
+ background-color: #fff;
184
+ border-radius: 4px;
185
+ border: 1px solid rgb(199, 199, 199);
186
+ box-shadow: rgba(0, 0, 0, 0.133) 0px 3.2px 7.2px 0px, rgba(0, 0, 0, 0.11) 0px 0.6px 1.8px 0px;
187
+ display: none;
188
+ position: absolute;
189
+ bottom: 32px;
190
+ left: 0;
191
+ max-height: 400px;
192
+ overflow-x: hidden;
193
+ overflow-y: auto;
194
+ z-index: 15;
195
+ user-select: none;
196
+ }
197
+
198
+ .ov-excel-sheet-tab-bar__menu-list-item {
199
+ padding: 4px 8px;
200
+ cursor: pointer;
201
+ white-space: nowrap;
202
+ }
203
+
204
+ .ov-excel-sheet-tab-bar__menu-list-item:hover {
205
+ background-color: #e1dfdd;
206
+ }
207
+
208
+ .ov-excel-sheet-tab-bar__menu-list-item--active {
209
+ background-color: #e1dfdd;
210
+ }
211
+
212
+ .ov-excel-sheet-tab-bar__list-container {
213
+ position: relative;
214
+ overflow: hidden;
215
+ flex: 1 1 0;
216
+ user-select: none;
217
+ }
218
+
219
+ .ov-excel-sheet-tab-bar__list-container--enable-left-nav::before {
220
+ content: "";
221
+ position: absolute;
222
+ top: 0;
223
+ bottom: 0;
224
+ left: 0;
225
+ width: 30px;
226
+ background-image: linear-gradient(to right, #dcdcdc, rgba(220, 220, 220, 0.1));
227
+ }
228
+
229
+ .ov-excel-sheet-tab-bar__list-container--enable-right-nav::after {
230
+ content: "";
231
+ position: absolute;
232
+ top: 0;
233
+ bottom: 0;
234
+ right: 0;
235
+ width: 30px;
236
+ background-image: linear-gradient(to left, #dcdcdc, rgba(220, 220, 220, 0.1));
237
+ }
238
+
239
+ .ov-excel-sheet-tab-bar__list {
240
+ width: 0;
241
+ display: flex;
242
+ flex-direction: row;
243
+ }
244
+
245
+ .ov-excel-sheet-tab-bar__list-tab {
246
+ display: inline-block;
247
+ position: relative;
248
+ padding: 0 8px;
249
+ font-size: 14px;
250
+ margin: 4px 4px;
251
+ border-radius: 4px;
252
+ line-height: 24px;
253
+ white-space: nowrap;
254
+ }
255
+ .ov-excel-sheet-tab-bar__list-tab:hover {
256
+ cursor: pointer;
257
+ background-color: #e1dfdd;
258
+ }
259
+
260
+ .ov-excel-sheet-tab-bar__list-tab--active {
261
+ cursor: default;
262
+ }
263
+
264
+ .ov-excel-sheet-tab-bar__list-tab--active::before {
265
+ content: "";
266
+ position: absolute;
267
+ display: inline-block;
268
+ top: 0;
269
+ bottom: -4px;
270
+ left: 0;
271
+ right: 0;
272
+ color: transparent;
273
+ border-bottom: 3px solid var(--active-sheet-color);
274
+ padding-bottom: 5px;
275
+ width: calc(100% - 18px);
276
+ margin: auto;
277
+ transition: width 0.4s cubic-bezier(0.17, 0.17, 0, 1) 0s;
278
+ }
279
+
280
+ .ov-excel-sheet-tab-bar__status {
281
+ margin-left: 12px;
282
+ margin-right: 12px;
283
+ }
284
+
285
+ .ov-excel-sheet-tab-bar__status-text {
286
+ margin-right: 16px;
287
+ }
288
+
289
+ .ov-excel-sheet-tab-bar__zoom-level {
290
+ display: flex;
291
+ flex-direction: row;
292
+ padding: 0 8px;
293
+ }
294
+
295
+ .ov-excel-sheet-tab-bar__zoom-value {
296
+ margin: 0 8px;
297
+ }
298
+
299
+ .ov-excel-sheet-tab-bar__zoom-in,
300
+ .ov-excel-sheet-tab-bar__zoom-out {
301
+ cursor: pointer;
302
+ }
303
+
304
+ /* Excel 内容区域,这个包含表头 */
305
+ .ov-excel-content {
306
+ flex: 1;
307
+ position: relative;
308
+ overflow: hidden;
309
+ z-index: 1;
310
+ }
311
+
312
+ /** Excel 数据区域,不包含表头,目前这个区域主要是给 drawing 用 */
313
+ .ov-excel-data {
314
+ position: absolute;
315
+ right: 0;
316
+ bottom: 0;
317
+ overflow: hidden;
318
+ user-select: none;
319
+ z-index: 2;
320
+ }
321
+
322
+ .ov-excel-canvas {
323
+ position: absolute;
324
+ left: 0;
325
+ top: 0;
326
+ }
327
+
328
+ .ov-excel-scrollbar-y {
329
+ position: absolute;
330
+ top: 0;
331
+ right: 0;
332
+ bottom: 0;
333
+ z-index: 3;
334
+ }
335
+
336
+ .ov-excel-scrollbar-x {
337
+ position: absolute;
338
+ left: 0;
339
+ right: 0;
340
+ bottom: 0;
341
+ z-index: 3;
342
+ }
343
+
344
+ .ov-excel-scrollbar-content-x {
345
+ overflow-x: auto;
346
+ overflow-y: hidden;
347
+ }
348
+
349
+ .ov-excel-scrollbar-content-y {
350
+ overflow-x: hidden;
351
+ }
352
+
353
+ /** 缩放的控制界面 */
354
+ .ov-excel-resize-box {
355
+ position: absolute;
356
+ border: 1px solid #4af;
357
+ z-index: 3;
358
+ }
359
+
360
+ .ov-excel-resize-box-control {
361
+ position: absolute;
362
+ width: 14px;
363
+ height: 14px;
364
+ border-radius: 50%;
365
+ border: 2px solid #fff;
366
+ box-sizing: border-box;
367
+ background: #4af;
368
+ border: 2px solid #fff;
369
+ z-index: 5;
370
+ }
371
+
372
+ .ov-excel-auto-filter-icon-container {
373
+ position: absolute;
374
+ }
375
+
376
+ .ov-excel-auto-filter-icon {
377
+ cursor: pointer;
378
+ position: absolute;
379
+ right: 2px;
380
+ top: 2px;
381
+ bottom: 2px;
382
+ z-index: 3;
383
+ }
384
+
385
+ .ov-excel-auto-filter-icon svg {
386
+ width: 100%;
387
+ height: 100%;
388
+ }
389
+
390
+ .ov-excel-auto-filter-menu {
391
+ position: absolute;
392
+ display: none;
393
+ flex-direction: column;
394
+ right: -240px;
395
+ width: 240px;
396
+ height: 440px;
397
+ border-radius: 4px;
398
+ box-shadow: rgba(0, 0, 0, 0.133) 0px 3.2px 7.2px 0px, rgba(0, 0, 0, 0.11) 0px 0.6px 1.8px 0px;
399
+ z-index: 4;
400
+ background-color: white;
401
+ }
402
+
403
+ .excel-auto-filter__menu-sort {
404
+ display: flex;
405
+ flex-direction: row;
406
+ column-gap: 4px;
407
+ padding: 8px;
408
+ }
409
+
410
+ .ov-excel-auto-filter__sort-button {
411
+ cursor: pointer;
412
+ flex: 1;
413
+ display: flex;
414
+ flex-direction: row;
415
+ line-height: 24px;
416
+ height: 24px;
417
+ padding: 2px;
418
+ }
419
+
420
+ .ov-excel-auto-filter__sort-button-text {
421
+ flex: 1;
422
+ }
423
+
424
+ .ov-excel-auto-filter__sort-button-icon {
425
+ height: 24px;
426
+ width: 24px;
427
+ }
428
+
429
+ .ov-excel-auto-filter__sort-button-icon svg {
430
+ height: 100%;
431
+ width: 100%;
432
+ }
433
+
434
+ .ov-excel-auto-filter__sort-button:hover {
435
+ background-color: #f5f5f5;
436
+ }
437
+
438
+ .ov-excel-auto-filter__sort-button-active {
439
+ background-color: #f5f5f5;
440
+ }
441
+
442
+ .ov-excel-auto-filter__menu-filter-filters {
443
+ flex-grow: 1;
444
+ display: flex;
445
+ flex-direction: column;
446
+ min-height: 0;
447
+ }
448
+
449
+ .ov-excel-auto-filter__menu-filter-filters .excel-checkbox-list-wrapper {
450
+ display: flex;
451
+ flex-grow: 1;
452
+ flex-direction: column;
453
+ padding: 8px;
454
+ min-height: 0;
455
+ }
456
+
457
+ .ov-excel-auto-filter__menu-filter-filters .excel-checkbox-list {
458
+ flex-grow: 1;
459
+ overflow-y: auto;
460
+ overflow-x: hidden;
461
+ }
462
+
463
+ .ov-excel-auto-filter-menu__custom-filters {
464
+ display: flex;
465
+ flex-direction: column;
466
+ padding: 8px;
467
+ }
468
+
469
+ /** 单个规则 */
470
+ .ov-excel-auto-filter-menu__custom-filters-item-input {
471
+ display: flex;
472
+ flex-direction: row;
473
+ margin-bottom: 4px;
474
+ }
475
+
476
+ .ov-excel-auto-filter-menu__custom-filters-item-input > select {
477
+ margin-right: 4px;
478
+ }
479
+
480
+ .ov-excel-auto-filter-menu__custom-filters .excel-radio-wrapper {
481
+ margin: 4px 0;
482
+ text-align: center;
483
+ }
484
+
485
+ .excel-cell-editor {
486
+ position: absolute;
487
+ }
488
+
489
+ .excel-chart {
490
+ position: absolute;
491
+ z-index: 10;
492
+ }
493
+
494
+ .excel-pic {
495
+ position: absolute;
496
+ z-index: 10;
497
+ overflow: hidden;
498
+ }
499
+
500
+ /*# sourceMappingURL=office.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sourceRoot":"","sources":["../scss/excel/excel.scss","../scss/excel/button.scss","../scss/excel/toolbar.scss","../scss/excel/checkbox.scss","../scss/excel/divider.scss","../scss/excel/input.scss","../scss/excel/select.scss","../scss/excel/formula-bar.scss","../scss/excel/sheet-tab-bar.scss","../scss/excel/sheet-tab/tab-list.scss","../scss/excel/content.scss","../scss/excel/scroll-bar.scss","../scss/excel/resize-box.scss","../scss/excel/auto-filter.scss","../scss/excel/auto-filter/sort-state.scss","../scss/excel/auto-filter/filters.scss","../scss/excel/auto-filter/custom-filters.scss","../scss/excel/cell-editor.scss","../scss/excel/chart.scss","../scss/excel/pic.scss"],"names":[],"mappings":";AAAA;AAEA;AACE;EACA;EAGA;EACA;EACA;EACA;EACA;;;ACXF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;;;ACpBF;AACA;EACE;EACA;;;ACHF;EACE;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE;;;ACnBF;EACE;EACA;EACA;EACA;EACA;EACA;;;ACNF;EACE;EACA;EACA;EACA;EACA;EACA,QLwBa;;;AKrBf;EACE;EACA;EACA;EACA;EACA;;;AAGF;EACE;;;AClBF;EACE;EACA;;;ACFF;AACA;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGF;AACA;EACE;;;AAGF;AACA;EACE;EACA;EACA;EACA;EACA;EACA;;;AC9BF;AACA;EACE;EACA;EACA;EACA;EACA;;;ACNF;EACE;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,ST5BqB;ES6BrB;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE,kBTrCe;;;ASwCjB;EACE,kBTzCe;;;AS4CjB;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;;AAOF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;;AAEA;EACE;EACA,kBT9Fa;;;ASkGjB;EACE;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;ADpIF;EACE;EACA;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;;;AAGF;AAAA;EAEE;;;AEhCF;AACA;EACE;EACA;EACA;EACA,SVSgB;;;AUNlB;AACA;EACE;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;;;ACrBF;EACE;EACA;EACA;EACA;EACA,SXamB;;;AWVrB;EACE;EACA;EACA;EACA;EACA,SXKmB;;;AWFrB;EACE;EACA;;;AAGF;EACE;;;ACtBF;AAEA;EACE;EACA;EACA,SZamB;;;AYVrB;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SZG2B;;;AapB7B;EACE;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA,SbMoB;;;AaHtB;EACE;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA,SbXoB;EaYpB;;;AC7BF;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE;;;AAGF;EACE;;;ACpCF;EACE;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;;;AClBF;EACE;EACA;EACA;;;AAGF;AACA;EACE;EACA;EACA;;;AAGF;EACE;;;AAGF;EACE;EACA;;;ACnBF;EACE;;;ACDF;EACE;EACA,SlBqBc;;;AmBvBhB;EACE;EACA,SnBsBY;EmBrBZ","file":"office.css"}
package/esm/Excel.d.ts CHANGED
@@ -42,6 +42,7 @@ export default class Excel implements OfficeViewer {
42
42
  * 加载 Excel 文件
43
43
  */
44
44
  loadExcel(): Promise<void>;
45
+ loaded: boolean;
45
46
  /**
46
47
  * 加载 CSV 文件
47
48
  */
package/esm/Excel.js CHANGED
@@ -53,6 +53,8 @@ var defaultRenderOptions = {
53
53
  var Excel = /** @class */ (function () {
54
54
  function Excel(docFile, fileName, renderOptions, parser) {
55
55
  if (parser === void 0) { parser = new ZipPackageParser(); }
56
+ // 后续优化一下
57
+ this.loaded = false;
56
58
  this.id = Excel.globalId++;
57
59
  this.parser = parser;
58
60
  this.docFile = docFile;
@@ -71,6 +73,9 @@ var Excel = /** @class */ (function () {
71
73
  return __generator(this, function (_b) {
72
74
  switch (_b.label) {
73
75
  case 0:
76
+ if (this.loaded) {
77
+ return [2 /*return*/];
78
+ }
74
79
  this.parser.load(this.docFile);
75
80
  startParse = performance.now();
76
81
  _a = this;
@@ -81,6 +86,7 @@ var Excel = /** @class */ (function () {
81
86
  console.log('parse time', performance.now() - startParse, 'ms');
82
87
  console.log('excelFile', this.excelFile);
83
88
  }
89
+ this.loaded = true;
84
90
  return [2 /*return*/];
85
91
  }
86
92
  });
@@ -95,6 +101,9 @@ var Excel = /** @class */ (function () {
95
101
  return __generator(this, function (_b) {
96
102
  switch (_b.label) {
97
103
  case 0:
104
+ if (this.loaded) {
105
+ return [2 /*return*/];
106
+ }
98
107
  // 目前 csv 的实现复用了 xlsx 的解析
99
108
  this.parser.load(emptyXLSX);
100
109
  _a = this;
@@ -112,6 +121,7 @@ var Excel = /** @class */ (function () {
112
121
  if (this.fileName) {
113
122
  this.excelFile.workbook.sheets[0].name = this.fileName.split('/').pop();
114
123
  }
124
+ this.loaded = true;
115
125
  return [2 /*return*/];
116
126
  }
117
127
  });
@@ -70,7 +70,7 @@ var ScrollBar = /** @class */ (function () {
70
70
  xScrollBarContent.addEventListener('scroll', function (event) {
71
71
  var currentSheet = _this.workbook.getActiveSheet();
72
72
  var sheetScrollLeft = currentSheet.getScrollLeft();
73
- var scrollBarLeft = yScrollBarContent.scrollTop;
73
+ var scrollBarLeft = xScrollBarContent.scrollLeft;
74
74
  if (Math.round(sheetScrollLeft) !== Math.round(scrollBarLeft)) {
75
75
  currentSheet.setScrollLeft(xScrollBarContent.scrollLeft);
76
76
  _this.workbook.uiEvent.emit('SCROLL_X', xScrollBarContent.scrollLeft);
package/lib/Excel.d.ts CHANGED
@@ -42,6 +42,7 @@ export default class Excel implements OfficeViewer {
42
42
  * 加载 Excel 文件
43
43
  */
44
44
  loadExcel(): Promise<void>;
45
+ loaded: boolean;
45
46
  /**
46
47
  * 加载 CSV 文件
47
48
  */
package/lib/Excel.js CHANGED
@@ -75,6 +75,8 @@ var defaultRenderOptions = {
75
75
  var Excel = /** @class */ (function () {
76
76
  function Excel(docFile, fileName, renderOptions, parser) {
77
77
  if (parser === void 0) { parser = new ZipPackageParser["default"](); }
78
+ // 后续优化一下
79
+ this.loaded = false;
78
80
  this.id = Excel.globalId++;
79
81
  this.parser = parser;
80
82
  this.docFile = docFile;
@@ -93,6 +95,9 @@ var Excel = /** @class */ (function () {
93
95
  return tslib.__generator(this, function (_b) {
94
96
  switch (_b.label) {
95
97
  case 0:
98
+ if (this.loaded) {
99
+ return [2 /*return*/];
100
+ }
96
101
  this.parser.load(this.docFile);
97
102
  startParse = performance.now();
98
103
  _a = this;
@@ -103,6 +108,7 @@ var Excel = /** @class */ (function () {
103
108
  console.log('parse time', performance.now() - startParse, 'ms');
104
109
  console.log('excelFile', this.excelFile);
105
110
  }
111
+ this.loaded = true;
106
112
  return [2 /*return*/];
107
113
  }
108
114
  });
@@ -117,6 +123,9 @@ var Excel = /** @class */ (function () {
117
123
  return tslib.__generator(this, function (_b) {
118
124
  switch (_b.label) {
119
125
  case 0:
126
+ if (this.loaded) {
127
+ return [2 /*return*/];
128
+ }
120
129
  // 目前 csv 的实现复用了 xlsx 的解析
121
130
  this.parser.load(emptyXLSX.emptyXLSX);
122
131
  _a = this;
@@ -134,6 +143,7 @@ var Excel = /** @class */ (function () {
134
143
  if (this.fileName) {
135
144
  this.excelFile.workbook.sheets[0].name = this.fileName.split('/').pop();
136
145
  }
146
+ this.loaded = true;
137
147
  return [2 /*return*/];
138
148
  }
139
149
  });
@@ -13,4 +13,4 @@ import { PackageParser } from './package/PackageParser';
13
13
  * @param parser 文件解析器,支持 zip 和 xml 两种,也可以扩展
14
14
  * @returns OfficeViewer 实例
15
15
  */
16
- export declare function createOfficeViewer(docFile: ArrayBuffer, renderOptions?: Partial<RenderOptions>, fileName?: string, parser?: PackageParser): Promise<Word | UnSupport | Excel>;
16
+ export declare function createOfficeViewer(docFile: ArrayBuffer, renderOptions?: Partial<RenderOptions>, fileName?: string, parser?: PackageParser): Promise<Excel | Word | UnSupport>;
@@ -74,7 +74,7 @@ var ScrollBar = /** @class */ (function () {
74
74
  xScrollBarContent.addEventListener('scroll', function (event) {
75
75
  var currentSheet = _this.workbook.getActiveSheet();
76
76
  var sheetScrollLeft = currentSheet.getScrollLeft();
77
- var scrollBarLeft = yScrollBarContent.scrollTop;
77
+ var scrollBarLeft = xScrollBarContent.scrollLeft;
78
78
  if (Math.round(sheetScrollLeft) !== Math.round(scrollBarLeft)) {
79
79
  currentSheet.setScrollLeft(xScrollBarContent.scrollLeft);
80
80
  _this.workbook.uiEvent.emit('SCROLL_X', xScrollBarContent.scrollLeft);
@@ -3,4 +3,4 @@
3
3
  */
4
4
  import { CT_SortState } from '../../../../openxml/ExcelTypes';
5
5
  import { RangeRef } from '../../../types/RangeRef';
6
- export declare function getColumnSortOrder(colIndex: number, rangeRef: RangeRef, sortState?: CT_SortState): "desc" | "none" | "asc";
6
+ export declare function getColumnSortOrder(colIndex: number, rangeRef: RangeRef, sortState?: CT_SortState): "none" | "asc" | "desc";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "office-viewer",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "office 文档在线预览",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -8,7 +8,7 @@
8
8
  "scripts": {
9
9
  "dev": "vite --host",
10
10
  "start": "vite --host",
11
- "build": "npm run clean-dist && cross-env NODE_ENV=production rollup -c && sass scss/office.scss dist/index.css",
11
+ "build": "npm run clean-dist && cross-env NODE_ENV=production rollup -c && sass scss/office.scss dist/office.css",
12
12
  "build-esm": "npm run clean-dist && cross-env NODE_ENV=production rollup -c rollup.esm.config.js",
13
13
  "test": "jest",
14
14
  "lib": "npm run clean-dist && cross-env NODE_ENV=production IS_LIB=1 rollup -c",
@@ -119,4 +119,4 @@
119
119
  "printBasicPrototype": false
120
120
  }
121
121
  }
122
- }
122
+ }