@file-viewer/renderer-spreadsheet 3.3.1 → 3.3.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.
Files changed (52) hide show
  1. package/README.en.md +14 -0
  2. package/README.md +14 -0
  3. package/README.zh-CN.md +14 -0
  4. package/dist/spreadsheet/autoRowHeight.d.ts +16 -0
  5. package/dist/spreadsheet/autoRowHeight.js +208 -0
  6. package/dist/spreadsheet/chartRenderer.js +0 -5
  7. package/dist/spreadsheet/chartSampling.d.ts +0 -4
  8. package/dist/spreadsheet/chartSampling.js +0 -6
  9. package/dist/spreadsheet/comments.d.ts +40 -0
  10. package/dist/spreadsheet/comments.js +388 -0
  11. package/dist/spreadsheet/drawingAutoHeight.d.ts +7 -0
  12. package/dist/spreadsheet/drawingAutoHeight.js +51 -0
  13. package/dist/spreadsheet/rangeNavigation.d.ts +0 -2
  14. package/dist/spreadsheet/rangeNavigation.js +0 -4
  15. package/dist/spreadsheet/sourceRegion.d.ts +37 -0
  16. package/dist/spreadsheet/sourceRegion.js +54 -0
  17. package/dist/spreadsheet/state.d.ts +7 -2
  18. package/dist/spreadsheet/state.js +6 -2
  19. package/dist/spreadsheet/view.d.ts +9 -4
  20. package/dist/spreadsheet/view.js +98 -39
  21. package/dist/spreadsheet/viewport.d.ts +0 -1
  22. package/dist/spreadsheet/viewport.js +0 -2
  23. package/dist/spreadsheet/worker/sheetjs/SheetJsModel.d.ts +61 -2
  24. package/dist/spreadsheet/worker/sheetjs/SheetJsModel.js +134 -43
  25. package/dist/spreadsheet/worker/sheetjs/chartParser.d.ts +3 -2
  26. package/dist/spreadsheet/worker/sheetjs/chartParser.js +13 -24
  27. package/dist/spreadsheet/worker/sheetjs/color.js +8 -10
  28. package/dist/spreadsheet/worker/sheetjs/commentParser.d.ts +7 -0
  29. package/dist/spreadsheet/worker/sheetjs/commentParser.js +232 -0
  30. package/dist/spreadsheet/worker/sheetjs/drawingRowAnchor.d.ts +4 -0
  31. package/dist/spreadsheet/worker/sheetjs/drawingRowAnchor.js +90 -0
  32. package/dist/spreadsheet/worker/sheetjs/formulaValues.js +0 -9
  33. package/dist/spreadsheet/worker/sheetjs/parser.d.ts +40 -4
  34. package/dist/spreadsheet/worker/sheetjs/parser.js +453 -78
  35. package/dist/spreadsheet/worker/sheetjs/richDataParser.js +5 -4
  36. package/dist/spreadsheet/worker/sheetjs/richText.js +0 -1
  37. package/dist/spreadsheet/worker/sheetjs/rowSizing.d.ts +10 -0
  38. package/dist/spreadsheet/worker/sheetjs/rowSizing.js +156 -0
  39. package/dist/spreadsheet/worker/sheetjs/sheetLayout.d.ts +2 -4
  40. package/dist/spreadsheet/worker/sheetjs/sheetLayout.js +0 -8
  41. package/dist/spreadsheet/worker/sheetjs/sourceAnchor.d.ts +10 -0
  42. package/dist/spreadsheet/worker/sheetjs/sourceAnchor.js +286 -0
  43. package/dist/spreadsheet/worker/sheetjs/textEncoding.d.ts +1 -1
  44. package/dist/spreadsheet/worker/sheetjs/textEncoding.js +1 -8
  45. package/dist/spreadsheet/worker/sheetjs/workbookFont.d.ts +4 -0
  46. package/dist/spreadsheet/worker/sheetjs/workbookFont.js +15 -0
  47. package/dist/spreadsheet/worker/sheetjs/xmlBudget.d.ts +11 -0
  48. package/dist/spreadsheet/worker/sheetjs/xmlBudget.js +39 -0
  49. package/dist/spreadsheet/worker/type.d.ts +145 -3
  50. package/dist/spreadsheet.js +150 -63
  51. package/dist/worker/sheet.worker.js +49 -65
  52. package/package.json +23 -3
@@ -1,5 +1,6 @@
1
1
  import type { Column, ConfigType } from 'e-virt-table';
2
- import type { SheetCellMetadata, SheetModel } from './worker/type.js';
2
+ import type { FileViewerSpreadsheetOptions } from '@file-viewer/core';
3
+ import type { SheetCellMetadata, SheetComment, SheetModel } from './worker/type.js';
3
4
  import { type CellStyleCache, type SheetDefaults, type VirtualSheetState } from './state.js';
4
5
  export declare const INDEX_COLUMN_WIDTH = 68;
5
6
  export declare const SPREADSHEET_MIN_ZOOM = 0.25;
@@ -12,6 +13,9 @@ interface TableConfigOptions {
12
13
  darkMode?: boolean;
13
14
  resizableColumns?: boolean;
14
15
  resizableRows?: boolean;
16
+ comments?: SheetComment[];
17
+ showComment?: (comment: SheetComment, anchor: HTMLElement, focus?: boolean) => void;
18
+ commentLabel?: (comment: SheetComment) => string;
15
19
  copySelection?: (params: SpreadsheetCopyParams) => void;
16
20
  searchCell?: (row: number, col: number) => 'active' | 'match' | undefined;
17
21
  sheetDefaults: SheetDefaults;
@@ -27,14 +31,15 @@ interface SpreadsheetCopyParams {
27
31
  export declare const buildFont: (style: Record<string, any>) => string | undefined;
28
32
  export declare const getRowHeight: (heights: number | number[] | undefined, index: number, fallback: number) => number;
29
33
  export declare const normalizeRowHeight: (height: number | undefined, fallback: number) => number;
30
- export declare const detectIndexOffset: (ws: SheetModel) => 0 | 1;
31
- export declare const buildColumns: (ws: SheetModel) => {
34
+ export declare const detectIndexOffset: (ws: SheetModel, mode?: FileViewerSpreadsheetOptions["rowNumberMode"]) => 0 | 1;
35
+ export declare const buildColumns: (ws: SheetModel, mode?: FileViewerSpreadsheetOptions["rowNumberMode"]) => {
32
36
  columns: Column[];
33
37
  dataKeys: string[];
34
38
  };
35
39
  export declare const getDisplayColumns: (columns: Column[], zoomScale?: number) => Column[];
36
40
  export declare const getSearchColumnLeft: (columns: Column[], key: string) => number | undefined;
37
41
  export declare const createTextLayer: (documentRef: Document, value: unknown, style: CellStyleCache, padding: number) => HTMLSpanElement;
42
+ export declare const createAutoHeightProbe: (documentRef: Document, value: unknown, style: CellStyleCache, width: number, zoom: number) => HTMLSpanElement;
38
43
  export declare const normalizeCellStyle: (meta: SheetCellMetadata | undefined) => CellStyleCache | undefined;
39
- export declare const createTableConfig: ({ hostHeight, darkMode, resizableColumns, resizableRows, copySelection, searchCell, sheetDefaults, virtualState, zoomScale }: TableConfigOptions) => ConfigType;
44
+ export declare const createTableConfig: ({ hostHeight, darkMode, resizableColumns, resizableRows, comments, showComment, commentLabel, copySelection, searchCell, sheetDefaults, virtualState, zoomScale }: TableConfigOptions) => ConfigType;
40
45
  export {};
@@ -4,7 +4,7 @@ export const INDEX_COLUMN_WIDTH = 68;
4
4
  export const SPREADSHEET_MIN_ZOOM = 0.25;
5
5
  export const SPREADSHEET_MAX_ZOOM = 2.5;
6
6
  const TABLE_FONT_FAMILY = 'Aptos, Calibri, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif';
7
- const TABLE_FONT_SIZE = 11;
7
+ const TABLE_FONT_SIZE = 11 * 96 / 72;
8
8
  const MIN_RENDERABLE_ROW_HEIGHT = 8;
9
9
  const HIDDEN_ROW_HEIGHT = 0.1;
10
10
  const CELL_PADDING = 2;
@@ -235,12 +235,9 @@ export const getRowHeight = (heights, index, fallback) => {
235
235
  }
236
236
  return (_a = heights === null || heights === void 0 ? void 0 : heights[index]) !== null && _a !== void 0 ? _a : fallback;
237
237
  };
238
- // Excel 已经给出了行高时,预览层不再二次猜测。
239
- // 只有完全缺失时才回退到默认行高,同时给极小值留一个最小可渲染下限。
240
238
  export const normalizeRowHeight = (height, fallback) => {
241
239
  if (typeof height === 'number' && Number.isFinite(height)) {
242
240
  if (height <= 0) {
243
- // e-virt-table 内部用 item._height || CELL_HEIGHT,0 会被误判为未设置。
244
241
  return HIDDEN_ROW_HEIGHT;
245
242
  }
246
243
  return Math.max(Math.ceil(height), MIN_RENDERABLE_ROW_HEIGHT);
@@ -257,33 +254,28 @@ const isPlainTextCell = (value) => {
257
254
  }
258
255
  return !/^\d+([./:-]\d+)*$/.test(text);
259
256
  };
260
- // 普通明细表通常会把第一行当成字段表头,而报表类工作表往往需要保留原始 Excel 行号。
261
- // 这里只在“首行像简单字段头且没有合并单元格”时,才给左侧序号做 1 行偏移。
262
- export const detectIndexOffset = (ws) => {
257
+ export const detectIndexOffset = (ws, mode = 'source') => {
258
+ if (mode !== 'legacy-records')
259
+ return 0;
263
260
  const meta = ws.meta;
264
261
  const rows = ws.data || [];
265
- if (!meta || rows.length < 2 || (ws.merge || []).length) {
262
+ if (!meta || rows.length < 2 || (ws.merge || []).length)
266
263
  return 0;
267
- }
268
- const firstRow = rows[0] || [];
269
- const secondRow = rows[1] || [];
270
- const firstRowValues = firstRow.filter(value => `${value !== null && value !== void 0 ? value : ''}`.trim() !== '');
271
- const secondRowValues = secondRow.filter(value => `${value !== null && value !== void 0 ? value : ''}`.trim() !== '');
272
- if (firstRowValues.length < Math.min(Math.max(Math.floor(meta.totalCols / 2), 3), 6)) {
264
+ const firstRowValues = (rows[0] || []).filter(value => `${value !== null && value !== void 0 ? value : ''}`.trim() !== '');
265
+ const secondRowValues = (rows[1] || []).filter(value => `${value !== null && value !== void 0 ? value : ''}`.trim() !== '');
266
+ if (firstRowValues.length < Math.min(Math.max(Math.floor(meta.totalCols / 2), 3), 6))
273
267
  return 0;
274
- }
275
- if (!firstRowValues.every(isPlainTextCell) || secondRowValues.length < 2) {
268
+ if (!firstRowValues.every(isPlainTextCell) || secondRowValues.length < 2)
276
269
  return 0;
277
- }
278
270
  return 1;
279
271
  };
280
- export const buildColumns = (ws) => {
272
+ export const buildColumns = (ws, mode = 'source') => {
281
273
  var _a;
282
274
  const columnsMeta = getSheetColumnsMeta(ws);
283
275
  const colWidths = getSheetColWidths(ws);
284
276
  const columns = [{
285
277
  key: INDEX_COLUMN_KEY,
286
- title: '',
278
+ title: mode === 'legacy-records' ? '#' : '',
287
279
  type: 'index',
288
280
  fixed: 'left',
289
281
  width: INDEX_COLUMN_WIDTH,
@@ -345,7 +337,6 @@ const scaleColumn = (column, zoomScale) => {
345
337
  }
346
338
  return nextColumn;
347
339
  };
348
- // Excel 预览优先忠实还原原始列宽,不再为了“铺满容器”二次拉伸列宽。
349
340
  export const getDisplayColumns = (columns, zoomScale = 1) => {
350
341
  const normalizedScale = normalizeZoomScale(zoomScale);
351
342
  if (normalizedScale === 1) {
@@ -431,7 +422,6 @@ const shouldRenderTextInOverlay = (style, column) => {
431
422
  if (!hasTextLayout(style)) {
432
423
  return false;
433
424
  }
434
- // e-virt-table 的列级 align 可以交给 canvas;只有单元格级布局差异才用 DOM 覆盖层补齐。
435
425
  return !!((style === null || style === void 0 ? void 0 : style.wrapText) ||
436
426
  (style === null || style === void 0 ? void 0 : style.shrinkToFit) ||
437
427
  ((style === null || style === void 0 ? void 0 : style.horizontalAlign) && style.horizontalAlign !== ((column === null || column === void 0 ? void 0 : column.align) || 'left')) ||
@@ -769,6 +759,12 @@ export const createTextLayer = (documentRef, value, style, padding) => {
769
759
  }
770
760
  return text;
771
761
  };
762
+ export const createAutoHeightProbe = (documentRef, value, style, width, zoom) => {
763
+ const scaled = scaleCellStyle(style, zoom) || {};
764
+ const probe = createTextLayer(documentRef, value, { ...scaled, font: scaled.font || getBodyFont(zoom) }, scaleNumber(CELL_PADDING, zoom));
765
+ Object.assign(probe.style, { width: `${width}px`, height: 'auto', minHeight: '0', overflow: 'visible', alignItems: 'flex-start', transform: 'none' });
766
+ return probe;
767
+ };
772
768
  const applyOverflowLayout = (text, overflowLayout) => {
773
769
  if (!overflowLayout) {
774
770
  return;
@@ -782,8 +778,6 @@ const applyOverflowLayout = (text, overflowLayout) => {
782
778
  textOverflow: 'clip'
783
779
  });
784
780
  };
785
- // e-virt-table 的普通样式接口不支持 Excel 式四边边框和单元格级换行/垂直对齐,
786
- // 这里借助官方的 BODY_CELL_RENDER_METHOD,只在可视区补轻量 DOM 覆盖层。
787
781
  const renderCellOverlay = (cellEl, borderStyle, textStyle, textValue, renderText, overflowLayout, zoomScale) => {
788
782
  const documentRef = cellEl.ownerDocument;
789
783
  cellEl.replaceChildren();
@@ -905,7 +899,8 @@ export const normalizeCellStyle = (meta) => {
905
899
  }
906
900
  return nextStyle;
907
901
  };
908
- export const createTableConfig = ({ hostHeight, darkMode = false, resizableColumns = false, resizableRows = false, copySelection, searchCell, sheetDefaults, virtualState, zoomScale = 1 }) => {
902
+ export const createTableConfig = ({ hostHeight, darkMode = false, resizableColumns = false, resizableRows = false, comments = [], showComment, commentLabel, copySelection, searchCell, sheetDefaults, virtualState, zoomScale = 1 }) => {
903
+ const commentsByCell = new Map(comments.map(comment => [displayCellKey(comment.row, comment.col + 1), comment]));
909
904
  const normalizedScale = normalizeZoomScale(zoomScale);
910
905
  const scaledPadding = scaleNumber(CELL_PADDING, normalizedScale);
911
906
  const scaledHeaderHeight = scaleNumber(HEADER_HEIGHT, normalizedScale);
@@ -913,11 +908,42 @@ export const createTableConfig = ({ hostHeight, darkMode = false, resizableColum
913
908
  const scaledCellWidth = scaleNumber(sheetDefaults.colWidth, normalizedScale);
914
909
  const headerStyle = getIndexCellStyle(normalizedScale, darkMode);
915
910
  const loadingStyle = getLoadingCellStyle(normalizedScale, darkMode);
916
- const spanMethod = ({ rowIndex, colIndex, column }) => {
911
+ let firstVisibleColumn = 1;
912
+ const getProjectedMerge = (rowIndex, colIndex, column) => {
913
+ const cellKey = getCellCacheKey(rowIndex, colIndex, column);
914
+ const anchorKey = virtualState.mergeCoveredMap.get(cellKey);
915
+ const merge = anchorKey ? virtualState.mergeStartMap.get(anchorKey) : undefined;
916
+ const displayCol = getDataColumnIndex(column, colIndex) + 1;
917
+ if (!merge || merge.row !== rowIndex || displayCol !== firstVisibleColumn ||
918
+ merge.col >= displayCol || displayCol >= merge.col + merge.colspan) {
919
+ return undefined;
920
+ }
921
+ let width = 0;
922
+ let offsetLeft = 0;
923
+ for (let col = merge.col; col < merge.col + merge.colspan; col += 1) {
924
+ const sourceWidth = getRenderColumnWidth(virtualState.columns[col]);
925
+ const scaledWidth = sourceWidth > 0 ? scaleNumber(sourceWidth, normalizedScale) : 0;
926
+ width += scaledWidth;
927
+ if (col < displayCol)
928
+ offsetLeft += scaledWidth;
929
+ }
930
+ return { merge, anchorKey: anchorKey, width, offsetLeft, colspan: merge.col + merge.colspan - displayCol };
931
+ };
932
+ const spanMethod = ({ rowIndex, colIndex, column, visibleLeafColumns }) => {
933
+ if (visibleLeafColumns === null || visibleLeafColumns === void 0 ? void 0 : visibleLeafColumns.length) {
934
+ const visibleDataColumns = visibleLeafColumns.filter(item => item.key !== INDEX_COLUMN_KEY && isVisibleDataColumn(item));
935
+ if (visibleDataColumns.length) {
936
+ firstVisibleColumn = Math.min(...visibleDataColumns.map(item => getDataColumnIndex(item, 1) + 1));
937
+ }
938
+ }
917
939
  if (colIndex === 0) {
918
940
  return;
919
941
  }
920
942
  const key = getCellCacheKey(rowIndex, colIndex, column);
943
+ const projected = getProjectedMerge(rowIndex, colIndex, column);
944
+ if (projected) {
945
+ return { rowspan: projected.merge.rowspan, colspan: projected.colspan };
946
+ }
921
947
  if (virtualState.mergeCoveredMap.has(key)) {
922
948
  return { rowspan: 0, colspan: 0 };
923
949
  }
@@ -942,8 +968,9 @@ export const createTableConfig = ({ hostHeight, darkMode = false, resizableColum
942
968
  if (getRowState(currentRow) !== RowState.Loaded) {
943
969
  return loadingStyle;
944
970
  }
945
- const style = scaleCellStyle(virtualState.cellCache.get(getCellCacheKey(rowIndex, colIndex, column)), normalizedScale);
946
- const match = searchCell === null || searchCell === void 0 ? void 0 : searchCell(rowIndex, getDataColumnIndex(column, colIndex));
971
+ const projected = getProjectedMerge(rowIndex, colIndex, column);
972
+ const style = scaleCellStyle(virtualState.cellCache.get((projected === null || projected === void 0 ? void 0 : projected.anchorKey) || getCellCacheKey(rowIndex, colIndex, column)), normalizedScale);
973
+ const match = searchCell === null || searchCell === void 0 ? void 0 : searchCell(rowIndex, projected ? projected.merge.col - 1 : getDataColumnIndex(column, colIndex));
947
974
  return match ? { ...style, backgroundColor: match === 'active' ? '#ffbf47' : '#fff1a8', color: '#202124' } : style;
948
975
  };
949
976
  const renderMethod = ({ row, rowIndex, colIndex, column, value }) => {
@@ -951,20 +978,24 @@ export const createTableConfig = ({ hostHeight, darkMode = false, resizableColum
951
978
  if (colIndex === 0 || isHiddenVirtualRow(currentRow) || getRowState(currentRow) !== RowState.Loaded) {
952
979
  return undefined;
953
980
  }
954
- const cellKey = getCellCacheKey(rowIndex, colIndex, column);
955
- if (virtualState.mergeCoveredMap.has(cellKey)) {
981
+ const ownCellKey = getCellCacheKey(rowIndex, colIndex, column);
982
+ const projected = getProjectedMerge(rowIndex, colIndex, column);
983
+ if (virtualState.mergeCoveredMap.has(ownCellKey) && !projected) {
956
984
  return undefined;
957
985
  }
986
+ const cellKey = (projected === null || projected === void 0 ? void 0 : projected.anchorKey) || ownCellKey;
958
987
  const style = scaleCellStyle(virtualState.cellCache.get(cellKey), normalizedScale);
959
- const dataColIndex = getDataColumnIndex(column, colIndex);
988
+ const dataColIndex = projected ? projected.merge.col - 1 : getDataColumnIndex(column, colIndex);
989
+ const renderValue = projected ? currentRow[getDataKey(dataColIndex)] : value;
960
990
  const measureDocument = typeof document === 'undefined' ? undefined : document;
961
- const overflowLayout = getExcelOverflowLayout(virtualState, currentRow, rowIndex, dataColIndex, column, style, value, normalizedScale, measureDocument);
962
- const mirror = !hasRenderableValue(value)
991
+ const overflowLayout = projected ? { left: -projected.offsetLeft, width: projected.width } : getExcelOverflowLayout(virtualState, currentRow, rowIndex, dataColIndex, column, style, renderValue, normalizedScale, measureDocument);
992
+ const mirror = !projected && !hasRenderableValue(renderValue)
963
993
  ? getLeftOverflowMirror(virtualState, currentRow, rowIndex, dataColIndex, normalizedScale, measureDocument)
964
994
  : undefined;
965
995
  const match = searchCell === null || searchCell === void 0 ? void 0 : searchCell(rowIndex, dataColIndex);
966
996
  const renderText = shouldRenderTextInOverlay(style, column) || !!overflowLayout || !!mirror || !!match;
967
- if (!hasBorder(style) && !renderText) {
997
+ const comment = commentsByCell.get(cellKey);
998
+ if (!hasBorder(style) && !renderText && !comment) {
968
999
  return undefined;
969
1000
  }
970
1001
  return ((cellEl) => {
@@ -978,7 +1009,35 @@ export const createTableConfig = ({ hostHeight, darkMode = false, resizableColum
978
1009
  const collapsedStyle = hasBorder(style)
979
1010
  ? getCollapsedBorderStyle(virtualState, rowIndex, dataColIndex, baseStyle, normalizedScale)
980
1011
  : baseStyle;
981
- renderCellOverlay(cellEl, collapsedStyle, (mirror === null || mirror === void 0 ? void 0 : mirror.style) || collapsedStyle, mirror ? mirror.value : value, renderText, (mirror === null || mirror === void 0 ? void 0 : mirror.overflowLayout) || overflowLayout, normalizedScale);
1012
+ renderCellOverlay(cellEl, projected ? { ...collapsedStyle, borderLeft: undefined } : collapsedStyle, (mirror === null || mirror === void 0 ? void 0 : mirror.style) || collapsedStyle, mirror ? mirror.value : renderValue, renderText, (mirror === null || mirror === void 0 ? void 0 : mirror.overflowLayout) || overflowLayout, normalizedScale);
1013
+ if (comment) {
1014
+ cellEl.style.pointerEvents = 'auto';
1015
+ const indicator = cellEl.ownerDocument.createElement('button');
1016
+ indicator.type = 'button';
1017
+ indicator.className = 'excel-comment-indicator';
1018
+ indicator.dataset.cell = comment.address;
1019
+ indicator.dataset.kind = comment.kind;
1020
+ indicator.dataset.resolved = String(comment.resolved);
1021
+ indicator.setAttribute('aria-label', (commentLabel === null || commentLabel === void 0 ? void 0 : commentLabel(comment)) || comment.address);
1022
+ const open = (event) => { event.stopPropagation(); showComment === null || showComment === void 0 ? void 0 : showComment(comment, indicator); };
1023
+ indicator.addEventListener('pointerdown', event => event.stopPropagation());
1024
+ indicator.addEventListener('click', open);
1025
+ indicator.addEventListener('keydown', event => {
1026
+ if (event.key === 'Enter' || event.key === ' ') {
1027
+ event.preventDefault();
1028
+ open(event);
1029
+ }
1030
+ });
1031
+ let hoverTimer;
1032
+ indicator.addEventListener('pointerenter', () => {
1033
+ hoverTimer = setTimeout(() => {
1034
+ if (indicator.isConnected)
1035
+ showComment === null || showComment === void 0 ? void 0 : showComment(comment, indicator, false);
1036
+ }, 250);
1037
+ });
1038
+ indicator.addEventListener('pointerleave', () => clearTimeout(hoverTimer));
1039
+ cellEl.append(indicator);
1040
+ }
982
1041
  cellEl.style.boxShadow = match === 'active' ? 'inset 0 0 0 2px #9a5700' : '';
983
1042
  if (match) {
984
1043
  cellEl.dataset.spreadsheetSearch = match;
@@ -996,8 +1055,8 @@ export const createTableConfig = ({ hostHeight, darkMode = false, resizableColum
996
1055
  return {
997
1056
  ROW_KEY: ROW_KEY_FIELD,
998
1057
  DISABLED: true,
999
- HEIGHT: Math.max(hostHeight, 240),
1000
- MAX_HEIGHT: Math.max(hostHeight, 240),
1058
+ HEIGHT: hostHeight > 0 ? hostHeight : 240,
1059
+ MAX_HEIGHT: hostHeight > 0 ? hostHeight : 240,
1001
1060
  HEADER_HEIGHT: scaledHeaderHeight,
1002
1061
  CELL_HEIGHT: scaledCellHeight,
1003
1062
  CELL_WIDTH: scaledCellWidth,
@@ -1045,8 +1104,6 @@ export const createTableConfig = ({ hostHeight, darkMode = false, resizableColum
1045
1104
  RESIZE_ROW_LINE_COLOR: EXCEL_GREEN,
1046
1105
  RESIZE_ROW_MIN_HEIGHT: scaleNumber(RESIZABLE_ROW_MIN_HEIGHT, normalizedScale),
1047
1106
  ENABLE_KEYBOARD: true,
1048
- // The table finder only indexes loaded rows and competes with the viewer's
1049
- // workbook-wide search shortcut. Keep one search owner for all integrations.
1050
1107
  ENABLE_FINDER: false,
1051
1108
  ENABLE_COPY: true,
1052
1109
  BEFORE_COPY_METHOD: copySelection
@@ -1055,7 +1112,6 @@ export const createTableConfig = ({ hostHeight, darkMode = false, resizableColum
1055
1112
  return undefined;
1056
1113
  }
1057
1114
  : undefined,
1058
- // 预览态只开放“拖动扩选”的交互,不允许真正写回单元格内容。
1059
1115
  BEFORE_AUTOFILL_DATA_METHOD: () => [],
1060
1116
  SPAN_METHOD: spanMethod,
1061
1117
  HEADER_CELL_STYLE_METHOD: headerStyleMethod,
@@ -1072,6 +1128,9 @@ export const createTableConfig = ({ hostHeight, darkMode = false, resizableColum
1072
1128
  if (getRowState(row) !== RowState.Loaded) {
1073
1129
  return '';
1074
1130
  }
1131
+ if (getProjectedMerge(rowIndex, colIndex, column)) {
1132
+ return '';
1133
+ }
1075
1134
  const currentRow = row;
1076
1135
  const style = scaleCellStyle(virtualState.cellCache.get(getCellCacheKey(rowIndex, colIndex, column)), normalizedScale);
1077
1136
  const dataColIndex = getDataColumnIndex(column, colIndex);
@@ -1,7 +1,6 @@
1
1
  import type { Column } from 'e-virt-table';
2
2
  import { type VirtualRow, type VirtualSheetState } from './state.js';
3
3
  export declare const shouldFillSpreadsheetViewport: (enabled: boolean | undefined, type?: string) => boolean;
4
- /** Display-only padding. The parser's dimensions, rows and columns stay authoritative. */
5
4
  export declare class SpreadsheetViewportFill {
6
5
  private sourceRows?;
7
6
  private rows;
@@ -12,7 +12,6 @@ const columnLabel = (index) => {
12
12
  }
13
13
  return label;
14
14
  };
15
- /** Display-only padding. The parser's dimensions, rows and columns stay authoritative. */
16
15
  export class SpreadsheetViewportFill {
17
16
  constructor() {
18
17
  this.rows = [];
@@ -52,7 +51,6 @@ export class SpreadsheetViewportFill {
52
51
  verticalAlign: 'middle',
53
52
  }))) : state.columns;
54
53
  }
55
- // Blank rows use default metrics even when the host allows resizing data rows.
56
54
  for (let index = state.totalRows; index < this.rows.length; index += 1)
57
55
  this.rows[index]._height = rowHeight;
58
56
  return { rows: this.rows, columns: this.columns };
@@ -1,5 +1,5 @@
1
- import type { CellObject, Range, WorkSheet } from 'styled-exceljs';
2
- import type { CellMerge, SheetChartDefinition, SheetCellImage, SheetCellMetadata, SheetColumn, SheetModel, SheetStructure, SheetWindow } from '../type.js';
1
+ import type { CellObject, CellStyle, Range, WorkSheet } from 'styled-exceljs';
2
+ import type { CellMerge, SheetChartDefinition, SheetCellImage, SheetCellMetadata, SheetColumn, SheetModel, SheetStructure, SheetWindow, SheetRegion } from '../type.js';
3
3
  export declare const createAutoFitSampleRanges: (totalRowCount: number, totalColCount: number) => Range[];
4
4
  export declare const defaults: {
5
5
  rowHeight: number;
@@ -12,6 +12,7 @@ interface SheetSliceOptions {
12
12
  totalCols?: number;
13
13
  charts?: SheetChartDefinition[];
14
14
  cellImages?: SheetCellImage[];
15
+ defaultFont?: CellStyle['font'];
15
16
  }
16
17
  interface SheetObjectOptions {
17
18
  includeLayout?: boolean;
@@ -19,6 +20,7 @@ interface SheetObjectOptions {
19
20
  export declare const formatCellValue: (cell?: CellObject) => string;
20
21
  export default class SheetJsModel implements SheetModel {
21
22
  private readonly _ws;
23
+ private readonly _defaultFont?;
22
24
  private readonly _startRow;
23
25
  private readonly _pageSize;
24
26
  private readonly _totalRows?;
@@ -65,6 +67,7 @@ export default class SheetJsModel implements SheetModel {
65
67
  private getCharts;
66
68
  private getAllMerge;
67
69
  private getData;
70
+ private getCellMetadata;
68
71
  private getCell;
69
72
  private getMerge;
70
73
  private getRowHeights;
@@ -77,6 +80,62 @@ export default class SheetJsModel implements SheetModel {
77
80
  private getColWidths;
78
81
  private getColumns;
79
82
  private getStructure;
83
+ toRegionObject(region: SheetRegion): {
84
+ coordinateSpace: "region-local";
85
+ region: {
86
+ id: number;
87
+ startRow: number;
88
+ startCol: number;
89
+ rowCount: number;
90
+ colCount: number;
91
+ };
92
+ defaults: {
93
+ rowHeight: number;
94
+ colWidth: number;
95
+ };
96
+ data: string[][];
97
+ cell: Record<string, SheetCellMetadata>;
98
+ rows: {
99
+ sourceRow: number;
100
+ height: number;
101
+ fixed: boolean;
102
+ hidden: boolean;
103
+ }[];
104
+ columns: {
105
+ sourceCol: number;
106
+ title: string;
107
+ hidden: boolean;
108
+ width: number;
109
+ }[];
110
+ merges: {
111
+ source: CellMerge;
112
+ anchorValue: string;
113
+ anchorMetadata: SheetCellMetadata | undefined;
114
+ contained: boolean;
115
+ }[];
116
+ sourceObjects: {
117
+ images: {
118
+ id: string | undefined;
119
+ src: string | undefined;
120
+ anchor: import("styled-exceljs").DrawingAnchor | undefined;
121
+ contentType: string | undefined;
122
+ rowAnchor: import("../type.js").SheetRowAnchor | undefined;
123
+ }[];
124
+ charts: SheetChartDefinition[];
125
+ cellImages: SheetCellImage[];
126
+ };
127
+ sourceGeometry: {
128
+ rows: {
129
+ index: number;
130
+ size: number;
131
+ }[];
132
+ columns: {
133
+ index: number;
134
+ size: number;
135
+ }[];
136
+ };
137
+ autoHeightDisabled: boolean;
138
+ };
80
139
  toObject(options?: SheetObjectOptions): object;
81
140
  }
82
141
  export {};