@visactor/vtable 0.21.1 → 0.21.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.
Files changed (95) hide show
  1. package/cjs/body-helper/style/ProgressBarStyle.js +1 -1
  2. package/cjs/body-helper/style/ProgressBarStyle.js.map +1 -1
  3. package/cjs/core/BaseTable.js +1 -1
  4. package/cjs/core/BaseTable.js.map +1 -1
  5. package/cjs/event/event.d.ts +5 -0
  6. package/cjs/event/event.js +5 -3
  7. package/cjs/event/event.js.map +1 -1
  8. package/cjs/event/listener/container-dom.js +53 -13
  9. package/cjs/event/listener/container-dom.js.map +1 -1
  10. package/cjs/event/listener/table-group.js +1 -20
  11. package/cjs/event/listener/table-group.js.map +1 -1
  12. package/cjs/event/listener/touch.js +23 -5
  13. package/cjs/event/listener/touch.js.map +1 -1
  14. package/cjs/index.d.ts +1 -1
  15. package/cjs/index.js +1 -1
  16. package/cjs/index.js.map +1 -1
  17. package/cjs/scenegraph/graphic/contributions/index.js +4 -2
  18. package/cjs/scenegraph/graphic/contributions/index.js.map +1 -1
  19. package/cjs/scenegraph/graphic/contributions/text-contribution-render.d.ts +12 -0
  20. package/cjs/scenegraph/graphic/contributions/text-contribution-render.js +72 -0
  21. package/cjs/scenegraph/graphic/contributions/text-contribution-render.js.map +1 -0
  22. package/cjs/scenegraph/group-creater/cell-type/image-cell.d.ts +6 -0
  23. package/cjs/scenegraph/group-creater/cell-type/image-cell.js +35 -24
  24. package/cjs/scenegraph/group-creater/cell-type/image-cell.js.map +1 -1
  25. package/cjs/scenegraph/group-creater/cell-type/progress-bar-cell.js +2 -6
  26. package/cjs/scenegraph/group-creater/cell-type/progress-bar-cell.js.map +1 -1
  27. package/cjs/scenegraph/group-creater/cell-type/video-cell.js +12 -8
  28. package/cjs/scenegraph/group-creater/cell-type/video-cell.js.map +1 -1
  29. package/cjs/scenegraph/layout/compute-col-width.js +1 -1
  30. package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
  31. package/cjs/scenegraph/layout/frozen.js +2 -2
  32. package/cjs/scenegraph/layout/frozen.js.map +1 -1
  33. package/cjs/scenegraph/layout/update-width.js +3 -3
  34. package/cjs/scenegraph/layout/update-width.js.map +1 -1
  35. package/cjs/scenegraph/scenegraph.d.ts +2 -2
  36. package/cjs/scenegraph/scenegraph.js +17 -14
  37. package/cjs/scenegraph/scenegraph.js.map +1 -1
  38. package/cjs/scenegraph/stick-text/index.js +70 -34
  39. package/cjs/scenegraph/stick-text/index.js.map +1 -1
  40. package/cjs/scenegraph/utils/text-icon-layout.js +7 -5
  41. package/cjs/scenegraph/utils/text-icon-layout.js.map +1 -1
  42. package/cjs/ts-types/column/style.d.ts +1 -0
  43. package/cjs/ts-types/column/style.js.map +1 -1
  44. package/cjs/ts-types/customElement.d.ts +1 -1
  45. package/cjs/ts-types/customElement.js.map +1 -1
  46. package/cjs/vrender.js.map +1 -1
  47. package/dist/vtable.js +547 -284
  48. package/dist/vtable.min.js +2 -2
  49. package/es/body-helper/style/ProgressBarStyle.js +1 -1
  50. package/es/body-helper/style/ProgressBarStyle.js.map +1 -1
  51. package/es/core/BaseTable.js +1 -1
  52. package/es/core/BaseTable.js.map +1 -1
  53. package/es/event/event.d.ts +5 -0
  54. package/es/event/event.js +5 -3
  55. package/es/event/event.js.map +1 -1
  56. package/es/event/listener/container-dom.js +54 -12
  57. package/es/event/listener/container-dom.js.map +1 -1
  58. package/es/event/listener/table-group.js +1 -20
  59. package/es/event/listener/table-group.js.map +1 -1
  60. package/es/event/listener/touch.js +23 -5
  61. package/es/event/listener/touch.js.map +1 -1
  62. package/es/index.d.ts +1 -1
  63. package/es/index.js +1 -1
  64. package/es/index.js.map +1 -1
  65. package/es/scenegraph/graphic/contributions/index.js +5 -2
  66. package/es/scenegraph/graphic/contributions/index.js.map +1 -1
  67. package/es/scenegraph/graphic/contributions/text-contribution-render.d.ts +12 -0
  68. package/es/scenegraph/graphic/contributions/text-contribution-render.js +69 -0
  69. package/es/scenegraph/graphic/contributions/text-contribution-render.js.map +1 -0
  70. package/es/scenegraph/group-creater/cell-type/image-cell.d.ts +6 -0
  71. package/es/scenegraph/group-creater/cell-type/image-cell.js +34 -23
  72. package/es/scenegraph/group-creater/cell-type/image-cell.js.map +1 -1
  73. package/es/scenegraph/group-creater/cell-type/progress-bar-cell.js +2 -6
  74. package/es/scenegraph/group-creater/cell-type/progress-bar-cell.js.map +1 -1
  75. package/es/scenegraph/group-creater/cell-type/video-cell.js +12 -8
  76. package/es/scenegraph/group-creater/cell-type/video-cell.js.map +1 -1
  77. package/es/scenegraph/layout/compute-col-width.js +1 -1
  78. package/es/scenegraph/layout/compute-col-width.js.map +1 -1
  79. package/es/scenegraph/layout/frozen.js +2 -2
  80. package/es/scenegraph/layout/frozen.js.map +1 -1
  81. package/es/scenegraph/layout/update-width.js +3 -3
  82. package/es/scenegraph/layout/update-width.js.map +1 -1
  83. package/es/scenegraph/scenegraph.d.ts +2 -2
  84. package/es/scenegraph/scenegraph.js +16 -14
  85. package/es/scenegraph/scenegraph.js.map +1 -1
  86. package/es/scenegraph/stick-text/index.js +70 -34
  87. package/es/scenegraph/stick-text/index.js.map +1 -1
  88. package/es/scenegraph/utils/text-icon-layout.js +5 -5
  89. package/es/scenegraph/utils/text-icon-layout.js.map +1 -1
  90. package/es/ts-types/column/style.d.ts +1 -0
  91. package/es/ts-types/column/style.js.map +1 -1
  92. package/es/ts-types/customElement.d.ts +1 -1
  93. package/es/ts-types/customElement.js.map +1 -1
  94. package/es/vrender.js.map +1 -1
  95. package/package.json +2 -2
package/dist/vtable.js CHANGED
@@ -36047,6 +36047,8 @@
36047
36047
  });
36048
36048
  image.name = 'image';
36049
36049
  image.keepAspectRatio = keepAspectRatio;
36050
+ image.textAlign = textAlign;
36051
+ image.textBaseline = textBaseline;
36050
36052
  if (keepAspectRatio || imageAutoSizing) {
36051
36053
  if (image.resources &&
36052
36054
  image.resources.has(image.attribute.image) &&
@@ -36134,25 +36136,40 @@
36134
36136
  const textAlign = getProp('textAlign', headerStyle, col, row, table) ?? 'left';
36135
36137
  const textBaseline = getProp('textBaseline', headerStyle, col, row, table) ?? 'middle';
36136
36138
  const padding = getQuadProps(getProp('padding', headerStyle, col, row, table)) ?? [0, 0, 0, 0];
36139
+ const { width: cellWidth, height: cellHeight, isMerge } = getCellRange(cellGroup, table);
36140
+ const colStart = cellGroup.mergeStartCol ?? cellGroup.col;
36141
+ const rowStart = cellGroup.mergeStartRow ?? cellGroup.row;
36142
+ const colEnd = cellGroup.mergeEndCol ?? cellGroup.col;
36143
+ const rowEnd = cellGroup.mergeEndCol ?? cellGroup.row;
36137
36144
  if (image.keepAspectRatio) {
36138
- const { width: cellWidth, height: cellHeight } = getCellRange(cellGroup, table);
36139
36145
  const { width: imageWidth, height: imageHeight } = calcKeepAspectRatioSize(originImage.width || originImage.videoWidth, originImage.height || originImage.videoHeight, cellWidth - (padding[1] + padding[3]), cellHeight - (padding[0] + padding[2]));
36140
36146
  const pos = calcStartPosition(0, 0, cellWidth, cellHeight, imageWidth, imageHeight, textAlign, textBaseline, padding);
36141
- image.setAttributes({
36142
- x: pos.x,
36143
- y: pos.y,
36144
- width: imageWidth,
36145
- height: imageHeight
36146
- });
36147
+ for (let col = colStart; col <= colEnd; col++) {
36148
+ for (let row = rowStart; row <= rowEnd; row++) {
36149
+ const cellGroup = table.scenegraph.getCell(col, row);
36150
+ const image = cellGroup.getChildByName('image');
36151
+ image?.setAttributes({
36152
+ x: pos.x,
36153
+ y: pos.y,
36154
+ width: imageWidth,
36155
+ height: imageHeight
36156
+ });
36157
+ }
36158
+ }
36147
36159
  }
36148
36160
  else {
36149
- const { width: cellWidth, height: cellHeight } = getCellRange(cellGroup, table);
36150
- image.setAttributes({
36151
- x: padding[3],
36152
- y: padding[0],
36153
- width: cellWidth - padding[1] - padding[3],
36154
- height: cellHeight - padding[0] - padding[2]
36155
- });
36161
+ for (let col = colStart; col <= colEnd; col++) {
36162
+ for (let row = rowStart; row <= rowEnd; row++) {
36163
+ const cellGroup = table.scenegraph.getCell(col, row);
36164
+ const image = cellGroup.getChildByName('image');
36165
+ image?.setAttributes({
36166
+ x: padding[3],
36167
+ y: padding[0],
36168
+ width: cellWidth - padding[1] - padding[3],
36169
+ height: cellHeight - padding[0] - padding[2]
36170
+ });
36171
+ }
36172
+ }
36156
36173
  }
36157
36174
  const playIcon = cellGroup.getChildByName('play-icon');
36158
36175
  if (playIcon) {
@@ -36162,12 +36179,21 @@
36162
36179
  const iconSize = Math.floor(Math.min(width - padding[1] - padding[3], height - padding[2] - padding[0]) / 2);
36163
36180
  const anchorX = left + (width > image.attribute.width ? image.attribute.x - left + image.attribute.width / 2 : width / 2);
36164
36181
  const anchorY = top + (height > image.attribute.height ? image.attribute.y - top + image.attribute.height / 2 : height / 2);
36165
- playIcon.setAttributes({
36166
- x: anchorX - iconSize / 2,
36167
- y: anchorY - iconSize / 2,
36168
- width: iconSize,
36169
- height: iconSize
36170
- });
36182
+ for (let col = colStart; col <= colEnd; col++) {
36183
+ for (let row = rowStart; row <= rowEnd; row++) {
36184
+ const cellGroup = table.scenegraph.getCell(col, row);
36185
+ const playIcon = cellGroup.getChildByName('play-icon');
36186
+ playIcon.setAttributes({
36187
+ x: anchorX - iconSize / 2,
36188
+ y: anchorY - iconSize / 2,
36189
+ width: iconSize,
36190
+ height: iconSize
36191
+ });
36192
+ }
36193
+ }
36194
+ }
36195
+ if (isMerge) {
36196
+ updateImageDxDy(cellGroup.mergeStartCol, cellGroup.mergeEndCol, cellGroup.mergeStartRow, cellGroup.mergeEndRow, table);
36171
36197
  }
36172
36198
  }
36173
36199
  function getCellRange(cellGroup, table) {
@@ -36199,6 +36225,13 @@
36199
36225
  dy: -table.getRowsHeight(cellGroup.mergeStartRow, row - 1)
36200
36226
  });
36201
36227
  }
36228
+ const playIcon = cellGroup.getChildByName('play-icon');
36229
+ if (playIcon) {
36230
+ playIcon.setAttributes({
36231
+ dx: -table.getColsWidth(cellGroup.mergeStartCol, col - 1),
36232
+ dy: -table.getRowsHeight(cellGroup.mergeStartRow, row - 1)
36233
+ });
36234
+ }
36202
36235
  }
36203
36236
  }
36204
36237
  }
@@ -36268,18 +36301,12 @@
36268
36301
  return Number(v);
36269
36302
  });
36270
36303
  const borderWidth = getQuadProps(getProp('borderLineWidth', style, col, row, table));
36271
- let barPaddingTop = Math.max(barPadding[0], borderWidth[0]);
36272
- const barPaddingRight = Math.max(barPadding[1], borderWidth[1]);
36273
- const barPaddingBottom = Math.max(barPadding[2], borderWidth[2]);
36274
- let barPaddingLeft = Math.max(barPadding[3], borderWidth[3]);
36304
+ const barPaddingTop = Math.max(barPadding[0], Math.ceil(borderWidth[0] / 2));
36305
+ const barPaddingRight = Math.max(barPadding[1], Math.floor(borderWidth[1] / 2));
36306
+ const barPaddingBottom = Math.max(barPadding[2], Math.floor(borderWidth[2] / 2));
36307
+ const barPaddingLeft = Math.max(barPadding[3], Math.ceil(borderWidth[3] / 2));
36275
36308
  contentWidth -= barPaddingRight + barPaddingLeft;
36276
36309
  contentHeight -= barPaddingBottom + barPaddingTop;
36277
- if (barPaddingTop & 1) {
36278
- barPaddingTop += 0.5;
36279
- }
36280
- if (barPaddingLeft & 1) {
36281
- barPaddingLeft += 0.5;
36282
- }
36283
36310
  const top = barPaddingTop;
36284
36311
  const left = barPaddingLeft;
36285
36312
  const right = contentWidth;
@@ -37337,6 +37364,7 @@
37337
37364
  };
37338
37365
  const wrapText = new Text$1(cellTheme.text ? Object.assign({}, cellTheme.text, attribute) : attribute);
37339
37366
  wrapText.name = 'text';
37367
+ wrapText.textBaseline = textBaseline;
37340
37368
  cellGroup.appendChild(wrapText);
37341
37369
  contentWidth = wrapText.AABBBounds.width();
37342
37370
  wrapText.AABBBounds.height();
@@ -37417,10 +37445,15 @@
37417
37445
  _contentOffset = -table.theme._contentOffset;
37418
37446
  }
37419
37447
  }
37448
+ const hierarchyOffset = range
37449
+ ? getHierarchyOffset(range.start.col, range.start.row, table)
37450
+ : getHierarchyOffset(cellGroup.col, cellGroup.row, table);
37420
37451
  const text = convertInternal(textStr).replace(/\r?\n/g, '\n').replace(/\r/g, '\n').split('\n');
37421
37452
  const attribute = {
37422
37453
  text: text.length === 1 ? text[0] : text,
37423
- maxLineWidth: autoColWidth ? Infinity : cellWidth - (padding[1] + padding[3]) - leftIconWidth - rightIconWidth,
37454
+ maxLineWidth: autoColWidth
37455
+ ? Infinity
37456
+ : cellWidth - (padding[1] + padding[3]) - leftIconWidth - rightIconWidth - hierarchyOffset,
37424
37457
  textBaseline: 'top',
37425
37458
  heightLimit: autoRowHeight ? -1 : cellHeight - (padding[0] + padding[2]),
37426
37459
  pickable: false,
@@ -37428,7 +37461,7 @@
37428
37461
  lineClamp,
37429
37462
  wordBreak: 'break-word',
37430
37463
  whiteSpace: text.length === 1 && !autoWrapText ? 'no-wrap' : 'normal',
37431
- dx: _contentOffset
37464
+ dx: _contentOffset + (!contentLeftIcons.length && !contentRightIcons.length ? hierarchyOffset : 0)
37432
37465
  };
37433
37466
  const wrapText = new Text$1(cellTheme.text ? Object.assign({}, cellTheme.text, attribute) : attribute);
37434
37467
  wrapText.name = 'text';
@@ -37904,28 +37937,33 @@
37904
37937
  if (imageAutoSizing) {
37905
37938
  _adjustWidthHeight(col, row, video.videoWidth, video.videoHeight, table.scenegraph, padding, cellGroup);
37906
37939
  }
37907
- const width = cellGroup.attribute.width;
37908
- const height = cellGroup.attribute.height;
37940
+ const { width: cellWidth, height: cellHeight, isMerge } = getCellRange(cellGroup, table);
37909
37941
  if (keepAspectRatio) {
37910
- const { width: videoWidth, height: videoHeight } = calcKeepAspectRatioSize(video.videoWidth, video.videoHeight, width - padding[1] - padding[3], height - padding[0] - padding[2]);
37911
- const pos = calcStartPosition(0, 0, width, height, videoWidth, videoHeight, textAlign, textBaseline, padding);
37942
+ const { width: videoWidth, height: videoHeight } = calcKeepAspectRatioSize(video.videoWidth, video.videoHeight, cellWidth - padding[1] - padding[3], cellHeight - padding[0] - padding[2]);
37943
+ const pos = calcStartPosition(0, 0, cellWidth, cellHeight, videoWidth, videoHeight, textAlign, textBaseline, padding);
37912
37944
  image.setAttributes({
37913
37945
  width: videoWidth,
37914
37946
  height: videoHeight,
37915
37947
  x: pos.x,
37916
- y: pos.y
37948
+ y: pos.y,
37949
+ dx: 0
37917
37950
  });
37918
37951
  }
37919
37952
  else {
37920
37953
  image.setAttributes({
37921
37954
  x: padding[3],
37922
37955
  y: padding[0],
37923
- width: width - padding[1] - padding[3],
37924
- height: height - padding[2] - padding[0]
37956
+ width: cellWidth - padding[1] - padding[3],
37957
+ height: cellHeight - padding[2] - padding[0],
37958
+ dy: 0
37925
37959
  });
37926
37960
  }
37961
+ if (isMerge) {
37962
+ updateImageDxDy(cellGroup.mergeStartCol, cellGroup.mergeEndCol, cellGroup.mergeStartRow, cellGroup.mergeEndRow, table);
37963
+ }
37927
37964
  const left = 0;
37928
37965
  const top = 0;
37966
+ const { width, height } = getCellRange(cellGroup, table);
37929
37967
  const iconSize = Math.floor(Math.min(width - padding[1] - padding[3], height - padding[2] - padding[0]) / 2);
37930
37968
  const anchorX = left + (width > image.attribute.width ? image.attribute.x - left + image.attribute.width / 2 : width / 2);
37931
37969
  const anchorY = top + (height > image.attribute.height ? image.attribute.y - top + image.attribute.height / 2 : height / 2);
@@ -37955,6 +37993,9 @@
37955
37993
  cursor: 'pointer'
37956
37994
  });
37957
37995
  image.name = 'image';
37996
+ image.keepAspectRatio = keepAspectRatio;
37997
+ image.textAlign = textAlign;
37998
+ image.textBaseline = textBaseline;
37958
37999
  cellGroup.appendChild(image);
37959
38000
  return cellGroup;
37960
38001
  }
@@ -40328,7 +40369,7 @@
40328
40369
  const oldColumnWidth = columnGroup?.attribute.width ?? 0;
40329
40370
  columnGroup?.setAttribute('width', oldColumnWidth + detaX);
40330
40371
  columnGroup?.forEachChildren((cell, index) => {
40331
- const isHeightChange = updateCellWidth(scene, cell, cell.col, cell.row, oldColumnWidth, oldColumnWidth + detaX, detaX, mode === 'row-body' ? cell.col < scene.table.rowHeaderLevelCount : true, autoRowHeight);
40372
+ const isHeightChange = updateCellWidth(scene, cell, cell.col, cell.row, oldColumnWidth, oldColumnWidth + detaX, detaX, mode === 'row-body' ? cell.col < scene.table.rowHeaderLevelCount : true, autoRowHeight, scene.table.internalProps.autoWrapText);
40332
40373
  if (isHeightChange) {
40333
40374
  const mergeInfo = getCellMergeInfo(scene.table, cell.col, cell.row);
40334
40375
  if (mergeInfo && mergeInfo.end.row - mergeInfo.start.row) {
@@ -40415,7 +40456,7 @@
40415
40456
  }
40416
40457
  }
40417
40458
  }
40418
- function updateCellWidth(scene, cell, col, row, oldWidth, distWidth, detaX, isHeader, autoRowHeight) {
40459
+ function updateCellWidth(scene, cell, col, row, oldWidth, distWidth, detaX, isHeader, autoRowHeight, autoWrapText) {
40419
40460
  if (cell.attribute.width === distWidth && !cell.needUpdateWidth) {
40420
40461
  return false;
40421
40462
  }
@@ -40507,7 +40548,7 @@
40507
40548
  isHeightChange = updateMergeCellContentWidth(cellGroup, distWidth, detaX, autoRowHeight, getQuadProps(style.padding), style.textAlign, style.textBaseline, scene.table);
40508
40549
  }
40509
40550
  }
40510
- return autoRowHeight ? isHeightChange : false;
40551
+ return autoRowHeight && autoWrapText ? isHeightChange : false;
40511
40552
  }
40512
40553
  function updateMergeCellContentWidth(cellGroup, distWidth, detaX, autoRowHeight, padding, textAlign, textBaseline, table) {
40513
40554
  if (isMergeCellGroup(cellGroup)) {
@@ -42824,6 +42865,248 @@
42824
42865
  }
42825
42866
  }
42826
42867
 
42868
+ let customAlphabetCharSet = '';
42869
+ const textMeasureModule = new ContainerModule((bind, unbind, isBound, rebind) => {
42870
+ if (isBound(TextMeasureContribution)) {
42871
+ rebind(TextMeasureContribution).to(FastTextMeasureContribution).inSingletonScope();
42872
+ }
42873
+ else {
42874
+ bind(TextMeasureContribution).to(FastTextMeasureContribution).inSingletonScope();
42875
+ }
42876
+ });
42877
+ const restoreTextMeasureModule = new ContainerModule((bind, unbind, isBound, rebind) => {
42878
+ if (isBound(TextMeasureContribution)) {
42879
+ rebind(TextMeasureContribution).to(DefaultTextMeasureContribution).inSingletonScope();
42880
+ }
42881
+ else {
42882
+ bind(TextMeasureContribution).to(DefaultTextMeasureContribution).inSingletonScope();
42883
+ }
42884
+ });
42885
+ const initTextMeasure = (textSpec, option, useNaiveCanvas) => {
42886
+ return new TextMeasure$1({
42887
+ defaultFontParams: {
42888
+ fontFamily: DefaultTextStyle.fontFamily,
42889
+ fontSize: DefaultTextStyle.fontSize
42890
+ },
42891
+ getTextBounds: useNaiveCanvas ? undefined : getTextBounds$1,
42892
+ specialCharSet: `{}()//&-/: .,@%'"~…=${TextMeasure$1.ALPHABET_CHAR_SET}${TextMeasure$1.ALPHABET_CHAR_SET.toUpperCase()}0123456789${customAlphabetCharSet}`,
42893
+ ...(option ?? {})
42894
+ }, textSpec);
42895
+ };
42896
+ const fastTextMeasureCache = new Map();
42897
+ function getFastTextMeasure(fontSize, fontWeight, fontFamily, fontStyle = 'normal') {
42898
+ const key = `${fontSize}-${fontWeight}-${fontFamily}-${fontStyle}`;
42899
+ const cache = fastTextMeasureCache.get(key);
42900
+ if (cache) {
42901
+ return cache;
42902
+ }
42903
+ const fastTextMeasure = initTextMeasure({
42904
+ fontSize,
42905
+ fontFamily,
42906
+ fontWeight,
42907
+ fontStyle
42908
+ });
42909
+ fastTextMeasureCache.set(key, fastTextMeasure);
42910
+ return fastTextMeasure;
42911
+ }
42912
+ class FastTextMeasureContribution extends DefaultTextMeasureContribution {
42913
+ measureTextWidth(text, options) {
42914
+ const { fontSize, fontFamily = 'Arial,sans-serif', fontWeight = 'normal', fontStyle = 'normal' } = options;
42915
+ const fastTextMeasure = getFastTextMeasure(fontSize, fontWeight, fontFamily, fontStyle);
42916
+ const textMeasure = fastTextMeasure.measure(text);
42917
+ return textMeasure.width;
42918
+ }
42919
+ measureText(text, options) {
42920
+ const { fontSize, fontFamily = 'Arial,sans-serif', fontWeight = 'normal', fontStyle = 'normal' } = options;
42921
+ const fastTextMeasure = getFastTextMeasure(fontSize, fontWeight, fontFamily, fontStyle);
42922
+ const textMeasure = fastTextMeasure.measure(text);
42923
+ return textMeasure;
42924
+ }
42925
+ }
42926
+ class TextMeasureTool {
42927
+ measureText(text, options) {
42928
+ const { fontSize, fontFamily = 'Arial,sans-serif', fontWeight = 'normal', fontStyle = 'normal' } = options;
42929
+ const fastTextMeasure = getFastTextMeasure(fontSize, fontWeight, fontFamily, fontStyle);
42930
+ const textMeasure = fastTextMeasure.measure(text);
42931
+ return textMeasure;
42932
+ }
42933
+ measureTextWidth(text, options) {
42934
+ const { fontSize, fontFamily = 'Arial,sans-serif', fontWeight = 'normal', fontStyle = 'normal' } = options;
42935
+ const fastTextMeasure = getFastTextMeasure(fontSize, fontWeight, fontFamily, fontStyle);
42936
+ const textMeasure = fastTextMeasure.measure(text);
42937
+ return textMeasure.width;
42938
+ }
42939
+ clipText(text, options, width) {
42940
+ if (text.length === 0) {
42941
+ return { str: '', width: 0 };
42942
+ }
42943
+ let length = this.measureTextWidth(text, options);
42944
+ if (length <= width) {
42945
+ return { str: text, width: length };
42946
+ }
42947
+ length = this.measureTextWidth(text[0], options);
42948
+ if (length > width) {
42949
+ return { str: '', width: 0 };
42950
+ }
42951
+ return this._clipText(text, options, width, 0, text.length - 1);
42952
+ }
42953
+ _clipText(text, options, width, leftIdx, rightIdx) {
42954
+ const middleIdx = Math.floor((leftIdx + rightIdx) / 2);
42955
+ const subText = text.substring(0, middleIdx + 1);
42956
+ const strWidth = this.measureTextWidth(subText, options);
42957
+ let length;
42958
+ if (strWidth > width) {
42959
+ if (subText.length <= 1) {
42960
+ return { str: '', width: 0 };
42961
+ }
42962
+ const str = text.substring(0, middleIdx);
42963
+ length = this.measureTextWidth(str, options);
42964
+ if (length <= width) {
42965
+ return { str, width: length };
42966
+ }
42967
+ return this._clipText(text, options, width, leftIdx, middleIdx);
42968
+ }
42969
+ else if (strWidth < width) {
42970
+ if (middleIdx >= text.length - 1) {
42971
+ return { str: text, width: this.measureTextWidth(text, options) };
42972
+ }
42973
+ const str = text.substring(0, middleIdx + 2);
42974
+ length = this.measureTextWidth(str, options);
42975
+ if (length >= width) {
42976
+ return { str: subText, width: strWidth };
42977
+ }
42978
+ return this._clipText(text, options, width, middleIdx, rightIdx);
42979
+ }
42980
+ return { str: subText, width: strWidth };
42981
+ }
42982
+ clipTextWithSuffix(text, options, width, suffix) {
42983
+ if (suffix === '') {
42984
+ return this.clipText(text, options, width);
42985
+ }
42986
+ if (text.length === 0) {
42987
+ return { str: '', width: 0 };
42988
+ }
42989
+ const length = this.measureTextWidth(text, options);
42990
+ if (length <= width) {
42991
+ return { str: text, width: length };
42992
+ }
42993
+ const suffixWidth = this.measureTextWidth(suffix, options);
42994
+ if (suffixWidth > width) {
42995
+ return { str: '', width: 0 };
42996
+ }
42997
+ width -= suffixWidth;
42998
+ const data = this._clipText(text, options, width, 0, text.length - 1);
42999
+ data.str += suffix;
43000
+ data.width += suffixWidth;
43001
+ return data;
43002
+ }
43003
+ }
43004
+ const textMeasure = new TextMeasureTool();
43005
+ function setCustomAlphabetCharSet(str) {
43006
+ customAlphabetCharSet = str;
43007
+ fastTextMeasureCache.clear();
43008
+ }
43009
+ function restoreMeasureText() {
43010
+ container.load(restoreTextMeasureModule);
43011
+ }
43012
+
43013
+ let SuffixTextBeforeRenderContribution = class SuffixTextBeforeRenderContribution {
43014
+ time = BaseRenderContributionTime.afterFillStroke;
43015
+ useStyle = true;
43016
+ order = 0;
43017
+ drawShape(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb, doFillOrStroke) {
43018
+ const { text: str, underline = textAttribute.underline, lineThrough = textAttribute.lineThrough, direction = textAttribute.direction, whiteSpace = textAttribute.whiteSpace, fontSize = textAttribute.fontSize, verticalMode = textAttribute.verticalMode, ellipsis = textAttribute.ellipsis, textAlign = textAttribute.textAlign, textBaseline = textAttribute.textBaseline, x: originX = textAttribute.x, y: originY = textAttribute.y } = text.attribute;
43019
+ let isEmpty = false;
43020
+ if (Array.isArray(text)) {
43021
+ const layoutData = text.cache?.layoutData;
43022
+ if (ellipsis && layoutData && layoutData.lines.every(line => line.str === '')) {
43023
+ isEmpty = true;
43024
+ }
43025
+ }
43026
+ else {
43027
+ const { cache } = text;
43028
+ if (ellipsis && cache && cache.clipedText === '' && cache.clipedWidth === 0) {
43029
+ isEmpty = true;
43030
+ }
43031
+ }
43032
+ if (!isEmpty) {
43033
+ return;
43034
+ }
43035
+ const textStr = isString$4(ellipsis) ? ellipsis : '...';
43036
+ const lineHeight = calculateLineHeight(text.attribute.lineHeight, fontSize) ?? fontSize;
43037
+ let dy = 0;
43038
+ if (lineHeight !== fontSize) {
43039
+ if (textBaseline === 'top') {
43040
+ dy = (lineHeight - fontSize) / 2;
43041
+ }
43042
+ else if (textBaseline === 'middle') ;
43043
+ else if (textBaseline === 'bottom') {
43044
+ dy = -(lineHeight - fontSize) / 2;
43045
+ }
43046
+ else ;
43047
+ }
43048
+ if (doStroke) {
43049
+ if (strokeCb) {
43050
+ strokeCb(context, text.attribute, textAttribute);
43051
+ }
43052
+ else if (sVisible) {
43053
+ context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);
43054
+ context.strokeText(textStr, originX, originY + dy);
43055
+ }
43056
+ }
43057
+ if (doFill) {
43058
+ if (fillCb) {
43059
+ fillCb(context, text.attribute, textAttribute);
43060
+ }
43061
+ else if (fVisible) {
43062
+ context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);
43063
+ context.fillText(textStr, originX, originY + dy);
43064
+ this.drawUnderLine(underline, lineThrough, text, originX, originY + dy, 0, textAttribute, context, textStr);
43065
+ }
43066
+ }
43067
+ }
43068
+ drawUnderLine(underline, lineThrough, text, x, y, z, textAttribute, context, textStr) {
43069
+ if (lineThrough + underline <= 0) {
43070
+ return;
43071
+ }
43072
+ const { textAlign = textAttribute.textAlign, textBaseline = textAttribute.textBaseline, fontSize = textAttribute.fontSize, fontFamily = textAttribute.fontFamily, fontWeight = textAttribute.fontWeight, fontStyle = textAttribute.fontStyle, fill = textAttribute.fill, opacity = textAttribute.opacity, underlineOffset = textAttribute.underlineOffset, underlineDash = textAttribute.underlineDash, fillOpacity = textAttribute.fillOpacity } = text.attribute;
43073
+ if (!underline && !lineThrough) {
43074
+ return;
43075
+ }
43076
+ const w = textMeasure.measureTextWidth(textStr, {
43077
+ fontSize,
43078
+ fontFamily,
43079
+ fontWeight,
43080
+ fontStyle
43081
+ });
43082
+ const offsetX = textDrawOffsetX(textAlign, w);
43083
+ const offsetY = textLayoutOffsetY(textBaseline, fontSize, fontSize);
43084
+ const attribute = { lineWidth: 0, stroke: fill, opacity, strokeOpacity: fillOpacity };
43085
+ if (underline) {
43086
+ attribute.lineWidth = underline;
43087
+ context.setStrokeStyle(text, attribute, x, y, textAttribute);
43088
+ context.setLineDash(underlineDash);
43089
+ context.beginPath();
43090
+ const dy = y + offsetY + fontSize + underlineOffset;
43091
+ context.moveTo(x + offsetX, dy, z);
43092
+ context.lineTo(x + offsetX + w, dy, z);
43093
+ context.stroke();
43094
+ }
43095
+ if (lineThrough) {
43096
+ attribute.lineWidth = lineThrough;
43097
+ context.setStrokeStyle(text, attribute, x, y, textAttribute);
43098
+ context.beginPath();
43099
+ const dy = y + offsetY + fontSize / 2;
43100
+ context.moveTo(x + offsetX, dy, z);
43101
+ context.lineTo(x + offsetX + w, dy, z);
43102
+ context.stroke();
43103
+ }
43104
+ }
43105
+ };
43106
+ SuffixTextBeforeRenderContribution = __decorate([
43107
+ injectable()
43108
+ ], SuffixTextBeforeRenderContribution);
43109
+
42827
43110
  var splitModule = new ContainerModule((bind, unbind, isBound, rebind) => {
42828
43111
  if (isBound(SplitRectBeforeRenderContribution$1)) {
42829
43112
  rebind(SplitRectBeforeRenderContribution$1).to(SplitRectBeforeRenderContribution).inSingletonScope();
@@ -42868,6 +43151,8 @@
42868
43151
  bind(GroupRenderContribution).toService(ClipBodyGroupAfterRenderContribution);
42869
43152
  bind(VTableDrawItemInterceptorContribution).toSelf().inSingletonScope();
42870
43153
  bind(DrawItemInterceptor).toService(VTableDrawItemInterceptorContribution);
43154
+ bind(SuffixTextBeforeRenderContribution).toSelf().inSingletonScope();
43155
+ bind(TextRenderContribution).toService(SuffixTextBeforeRenderContribution);
42871
43156
  });
42872
43157
 
42873
43158
  function computeColsWidth(table, colStart, colEnd, update) {
@@ -42961,7 +43246,7 @@
42961
43246
  table.scenegraph.updateColWidth(col, newColWidth - oldColWidths[col], true, true);
42962
43247
  }
42963
43248
  }
42964
- table.scenegraph.updateContainer();
43249
+ table.scenegraph.updateContainer(true);
42965
43250
  }
42966
43251
  }
42967
43252
  function computeColWidth(col, startRow, endRow, table, forceCompute = false) {
@@ -45575,9 +45860,10 @@
45575
45860
  break;
45576
45861
  }
45577
45862
  [colStart, colEnd].forEach((col) => {
45578
- if (table._getCellStyle(col, row)?.textStick) {
45863
+ const style = table._getCellStyle(col, row);
45864
+ if (style?.textStick) {
45579
45865
  const cellGroup = table.scenegraph.getCell(col, row);
45580
- adjustCellContentHorizontalLayout(cellGroup, frozenColsWidth + table.tableX, table.tableNoFrameWidth - table.getRightFrozenColsWidth() + table.tableX, changedCells, table);
45866
+ adjustCellContentHorizontalLayout(cellGroup, frozenColsWidth + table.tableX, table.tableNoFrameWidth - table.getRightFrozenColsWidth() + table.tableX, changedCells, style?.textStickBaseOnAlign, table);
45581
45867
  }
45582
45868
  });
45583
45869
  }
@@ -45586,10 +45872,10 @@
45586
45872
  break;
45587
45873
  }
45588
45874
  [rowStart, rowEnd].forEach((row) => {
45589
- if (table._getCellStyle(col, row)?.textStick &&
45590
- table.internalProps.layoutMap.rowHierarchyType !== 'tree') {
45875
+ const style = table._getCellStyle(col, row);
45876
+ if (style?.textStick && table.internalProps.layoutMap.rowHierarchyType !== 'tree') {
45591
45877
  const cellGroup = table.scenegraph.getCell(col, row);
45592
- adjustCellContentVerticalLayout(cellGroup, frozenRowsHeight + table.tableY, table.tableNoFrameHeight - table.getBottomFrozenRowsHeight() + table.tableY, changedCells, table);
45878
+ adjustCellContentVerticalLayout(cellGroup, frozenRowsHeight + table.tableY, table.tableNoFrameHeight - table.getBottomFrozenRowsHeight() + table.tableY, changedCells, style?.textStickBaseOnAlign, table);
45593
45879
  }
45594
45880
  });
45595
45881
  }
@@ -45598,9 +45884,10 @@
45598
45884
  break;
45599
45885
  }
45600
45886
  [rowStart, rowEnd].forEach((row) => {
45601
- if (table._getCellStyle(col, row)?.textStick) {
45887
+ const style = table._getCellStyle(col, row);
45888
+ if (style?.textStick) {
45602
45889
  const cellGroup = table.scenegraph.getCell(col, row);
45603
- adjustCellContentVerticalLayout(cellGroup, frozenRowsHeight + table.tableY, table.tableNoFrameHeight - table.getBottomFrozenRowsHeight() + table.tableY, changedCells, table);
45890
+ adjustCellContentVerticalLayout(cellGroup, frozenRowsHeight + table.tableY, table.tableNoFrameHeight - table.getBottomFrozenRowsHeight() + table.tableY, changedCells, style?.textStickBaseOnAlign, table);
45604
45891
  }
45605
45892
  });
45606
45893
  }
@@ -45609,14 +45896,15 @@
45609
45896
  break;
45610
45897
  }
45611
45898
  [colStart, colEnd].forEach((col) => {
45899
+ const style = table._getCellStyle(col, row);
45612
45900
  if (table._getCellStyle(col, row)?.textStick) {
45613
45901
  const cellGroup = table.scenegraph.getCell(col, row);
45614
- adjustCellContentHorizontalLayout(cellGroup, frozenColsWidth + table.tableX, table.tableNoFrameWidth - table.getRightFrozenColsWidth() + table.tableX, changedCells, table);
45902
+ adjustCellContentHorizontalLayout(cellGroup, frozenColsWidth + table.tableX, table.tableNoFrameWidth - table.getRightFrozenColsWidth() + table.tableX, changedCells, style?.textStickBaseOnAlign, table);
45615
45903
  }
45616
45904
  });
45617
45905
  }
45618
45906
  }
45619
- function adjustCellContentVerticalLayout(cellGroup, minTop, maxTop, changedCells, table) {
45907
+ function adjustCellContentVerticalLayout(cellGroup, minTop, maxTop, changedCells, textStickBaseOnAlign, table) {
45620
45908
  if (isNumber$4(cellGroup.mergeStartCol) &&
45621
45909
  isNumber$4(cellGroup.mergeStartRow) &&
45622
45910
  isNumber$4(cellGroup.mergeEndCol) &&
@@ -45625,15 +45913,15 @@
45625
45913
  for (let col = colStart; col <= colEnd; col++) {
45626
45914
  for (let row = rowStart; row <= rowEnd; row++) {
45627
45915
  const singleCellGroup = table.scenegraph.getCell(col, row);
45628
- dealVertical(singleCellGroup, minTop, maxTop, changedCells);
45916
+ dealVertical(singleCellGroup, minTop, maxTop, changedCells, textStickBaseOnAlign);
45629
45917
  }
45630
45918
  }
45631
45919
  }
45632
45920
  else {
45633
- dealVertical(cellGroup, minTop, maxTop, changedCells);
45921
+ dealVertical(cellGroup, minTop, maxTop, changedCells, textStickBaseOnAlign);
45634
45922
  }
45635
45923
  }
45636
- function dealVertical(cellGroup, minTop, maxTop, changedCells) {
45924
+ function dealVertical(cellGroup, minTop, maxTop, changedCells, textStickBaseOnAlign) {
45637
45925
  const graphic = cellGroup.getChildByName('text', true) || cellGroup.getChildByName('image', true);
45638
45926
  if (!graphic) {
45639
45927
  return;
@@ -45648,10 +45936,30 @@
45648
45936
  return;
45649
45937
  }
45650
45938
  }
45939
+ const textBaseline = graphic.textBaseline ?? 'top';
45651
45940
  graphic.AABBBounds.width();
45652
45941
  const textTop = graphic.globalAABBBounds.y1;
45653
45942
  const textBottom = graphic.globalAABBBounds.y2;
45654
- if (textTop < minTop) {
45943
+ if (textBaseline === 'middle' && textStickBaseOnAlign) {
45944
+ const cellTop = cellGroup.globalAABBBounds.y1 + (cellGroup.firstChild?.attribute.dy ?? 0);
45945
+ const cellBottom = cellTop + (cellGroup.contentHeight ?? cellGroup.attribute.height ?? 0);
45946
+ if (cellTop < minTop || cellBottom > maxTop) {
45947
+ const visibleCellTop = Math.max(cellTop, minTop);
45948
+ const visibleCellBottom = Math.min(cellBottom, maxTop);
45949
+ const delta = graphic.globalTransMatrix.f - (visibleCellBottom + visibleCellTop) / 2;
45950
+ !changedCells.has(`${cellGroup.col}-${cellGroup.row}`) &&
45951
+ changedCells.set(`${cellGroup.col}-${cellGroup.row}`, {
45952
+ col: cellGroup.col,
45953
+ row: cellGroup.row,
45954
+ dx: cellGroup.firstChild?.attribute.dx ?? 0,
45955
+ dy: cellGroup.firstChild?.attribute.dy ?? 0
45956
+ });
45957
+ cellGroup.forEachChildren((child) => {
45958
+ child.setAttribute('dy', (child.attribute.dy ?? 0) - delta + 2);
45959
+ });
45960
+ }
45961
+ }
45962
+ else if (textTop < minTop) {
45655
45963
  const deltaHeight = textTop - minTop;
45656
45964
  !changedCells.has(`${cellGroup.col}-${cellGroup.row}`) &&
45657
45965
  changedCells.set(`${cellGroup.col}-${cellGroup.row}`, {
@@ -45678,7 +45986,7 @@
45678
45986
  });
45679
45987
  }
45680
45988
  }
45681
- function adjustCellContentHorizontalLayout(cellGroup, minLeft, maxLeft, changedCells, table) {
45989
+ function adjustCellContentHorizontalLayout(cellGroup, minLeft, maxLeft, changedCells, textStickBaseOnAlign, table) {
45682
45990
  if (isNumber$4(cellGroup.mergeStartCol) &&
45683
45991
  isNumber$4(cellGroup.mergeStartRow) &&
45684
45992
  isNumber$4(cellGroup.mergeEndCol) &&
@@ -45687,23 +45995,53 @@
45687
45995
  for (let col = colStart; col <= colEnd; col++) {
45688
45996
  for (let row = rowStart; row <= rowEnd; row++) {
45689
45997
  const singleCellGroup = table.scenegraph.getCell(col, row);
45690
- dealHorizontal(singleCellGroup, minLeft, maxLeft, changedCells);
45998
+ dealHorizontal(singleCellGroup, minLeft, maxLeft, changedCells, textStickBaseOnAlign);
45691
45999
  }
45692
46000
  }
45693
46001
  }
45694
46002
  else {
45695
- dealHorizontal(cellGroup, minLeft, maxLeft, changedCells);
46003
+ dealHorizontal(cellGroup, minLeft, maxLeft, changedCells, textStickBaseOnAlign);
45696
46004
  }
45697
46005
  }
45698
- function dealHorizontal(cellGroup, minLeft, maxLeft, changedCells) {
45699
- const text = cellGroup.getChildByName('text', true);
45700
- if (!text) {
46006
+ function dealHorizontal(cellGroup, minLeft, maxLeft, changedCells, textStickBaseOnAlign) {
46007
+ const graphic = cellGroup.getChildByName('text', true) || cellGroup.getChildByName('image', true);
46008
+ if (!graphic) {
45701
46009
  return;
45702
46010
  }
45703
- text.AABBBounds.width();
45704
- const textLeft = text.globalAABBBounds.x1;
45705
- const textRight = text.globalAABBBounds.x2;
45706
- if (textLeft < minLeft) {
46011
+ if (graphic.type === 'image') {
46012
+ const { image: url } = graphic.attribute;
46013
+ if (!url || !graphic.resources) {
46014
+ return;
46015
+ }
46016
+ const res = graphic.resources.get(url);
46017
+ if (res.state !== 'success') {
46018
+ return;
46019
+ }
46020
+ }
46021
+ const textAlign = graphic.attribute.textAlign ?? graphic.textAlign ?? 'left';
46022
+ graphic.AABBBounds.width();
46023
+ const textLeft = graphic.globalAABBBounds.x1;
46024
+ const textRight = graphic.globalAABBBounds.x2;
46025
+ if (textAlign === 'center' && textStickBaseOnAlign) {
46026
+ const cellLeft = cellGroup.globalAABBBounds.x1 + (cellGroup.firstChild?.attribute.dx ?? 0);
46027
+ const cellRight = cellLeft + (cellGroup.contentWidth ?? cellGroup.attribute.width ?? 0);
46028
+ if (cellLeft < minLeft || cellRight > maxLeft) {
46029
+ const visibleCellLeft = Math.max(cellLeft, minLeft);
46030
+ const visibleCellRight = Math.min(cellRight, maxLeft);
46031
+ const delta = graphic.globalTransMatrix.e - (visibleCellRight + visibleCellLeft) / 2;
46032
+ !changedCells.has(`${cellGroup.col}-${cellGroup.row}`) &&
46033
+ changedCells.set(`${cellGroup.col}-${cellGroup.row}`, {
46034
+ col: cellGroup.col,
46035
+ row: cellGroup.row,
46036
+ dx: cellGroup.firstChild?.attribute.dx ?? 0,
46037
+ dy: cellGroup.firstChild?.attribute.dy ?? 0
46038
+ });
46039
+ cellGroup.forEachChildren((child) => {
46040
+ child.setAttribute('dx', (child.attribute.dx ?? 0) - delta + 2);
46041
+ });
46042
+ }
46043
+ }
46044
+ else if (textLeft < minLeft) {
45707
46045
  const deltaWidth = textLeft - minLeft;
45708
46046
  !changedCells.has(`${cellGroup.col}-${cellGroup.row}`) &&
45709
46047
  changedCells.set(`${cellGroup.col}-${cellGroup.row}`, {
@@ -45770,7 +46108,7 @@
45770
46108
  scene.colHeaderGroup.setAttribute('x', scene.cornerHeaderGroup.attribute.width);
45771
46109
  scene.updateContainer();
45772
46110
  scene.updateBorderSizeAndPosition();
45773
- if (!scene.isPivot && !scene.transpose) {
46111
+ if (!scene.isPivot && !scene.table.transpose) {
45774
46112
  scene.component.setFrozenColumnShadow(scene.table.frozenColCount - 1);
45775
46113
  }
45776
46114
  scene.hasFrozen = true;
@@ -45806,7 +46144,7 @@
45806
46144
  scene.colHeaderGroup.setAttribute('x', scene.cornerHeaderGroup.attribute.width);
45807
46145
  scene.updateContainer();
45808
46146
  scene.updateBorderSizeAndPosition();
45809
- if (!scene.isPivot && !scene.transpose) {
46147
+ if (!scene.isPivot && !scene.table.transpose) {
45810
46148
  scene.component.setFrozenColumnShadow(scene.table.frozenColCount - 1);
45811
46149
  }
45812
46150
  scene.hasFrozen = true;
@@ -46265,151 +46603,6 @@
46265
46603
  return x;
46266
46604
  }
46267
46605
 
46268
- let customAlphabetCharSet = '';
46269
- const textMeasureModule = new ContainerModule((bind, unbind, isBound, rebind) => {
46270
- if (isBound(TextMeasureContribution)) {
46271
- rebind(TextMeasureContribution).to(FastTextMeasureContribution).inSingletonScope();
46272
- }
46273
- else {
46274
- bind(TextMeasureContribution).to(FastTextMeasureContribution).inSingletonScope();
46275
- }
46276
- });
46277
- const restoreTextMeasureModule = new ContainerModule((bind, unbind, isBound, rebind) => {
46278
- if (isBound(TextMeasureContribution)) {
46279
- rebind(TextMeasureContribution).to(DefaultTextMeasureContribution).inSingletonScope();
46280
- }
46281
- else {
46282
- bind(TextMeasureContribution).to(DefaultTextMeasureContribution).inSingletonScope();
46283
- }
46284
- });
46285
- const initTextMeasure = (textSpec, option, useNaiveCanvas) => {
46286
- return new TextMeasure$1({
46287
- defaultFontParams: {
46288
- fontFamily: DefaultTextStyle.fontFamily,
46289
- fontSize: DefaultTextStyle.fontSize
46290
- },
46291
- getTextBounds: useNaiveCanvas ? undefined : getTextBounds$1,
46292
- specialCharSet: `{}()//&-/: .,@%'"~…=${TextMeasure$1.ALPHABET_CHAR_SET}${TextMeasure$1.ALPHABET_CHAR_SET.toUpperCase()}0123456789${customAlphabetCharSet}`,
46293
- ...(option ?? {})
46294
- }, textSpec);
46295
- };
46296
- const fastTextMeasureCache = new Map();
46297
- function getFastTextMeasure(fontSize, fontWeight, fontFamily, fontStyle = 'normal') {
46298
- const key = `${fontSize}-${fontWeight}-${fontFamily}-${fontStyle}`;
46299
- const cache = fastTextMeasureCache.get(key);
46300
- if (cache) {
46301
- return cache;
46302
- }
46303
- const fastTextMeasure = initTextMeasure({
46304
- fontSize,
46305
- fontFamily,
46306
- fontWeight,
46307
- fontStyle
46308
- });
46309
- fastTextMeasureCache.set(key, fastTextMeasure);
46310
- return fastTextMeasure;
46311
- }
46312
- class FastTextMeasureContribution extends DefaultTextMeasureContribution {
46313
- measureTextWidth(text, options) {
46314
- const { fontSize, fontFamily = 'Arial,sans-serif', fontWeight = 'normal', fontStyle = 'normal' } = options;
46315
- const fastTextMeasure = getFastTextMeasure(fontSize, fontWeight, fontFamily, fontStyle);
46316
- const textMeasure = fastTextMeasure.measure(text);
46317
- return textMeasure.width;
46318
- }
46319
- measureText(text, options) {
46320
- const { fontSize, fontFamily = 'Arial,sans-serif', fontWeight = 'normal', fontStyle = 'normal' } = options;
46321
- const fastTextMeasure = getFastTextMeasure(fontSize, fontWeight, fontFamily, fontStyle);
46322
- const textMeasure = fastTextMeasure.measure(text);
46323
- return textMeasure;
46324
- }
46325
- }
46326
- class TextMeasureTool {
46327
- measureText(text, options) {
46328
- const { fontSize, fontFamily = 'Arial,sans-serif', fontWeight = 'normal', fontStyle = 'normal' } = options;
46329
- const fastTextMeasure = getFastTextMeasure(fontSize, fontWeight, fontFamily, fontStyle);
46330
- const textMeasure = fastTextMeasure.measure(text);
46331
- return textMeasure;
46332
- }
46333
- measureTextWidth(text, options) {
46334
- const { fontSize, fontFamily = 'Arial,sans-serif', fontWeight = 'normal', fontStyle = 'normal' } = options;
46335
- const fastTextMeasure = getFastTextMeasure(fontSize, fontWeight, fontFamily, fontStyle);
46336
- const textMeasure = fastTextMeasure.measure(text);
46337
- return textMeasure.width;
46338
- }
46339
- clipText(text, options, width) {
46340
- if (text.length === 0) {
46341
- return { str: '', width: 0 };
46342
- }
46343
- let length = this.measureTextWidth(text, options);
46344
- if (length <= width) {
46345
- return { str: text, width: length };
46346
- }
46347
- length = this.measureTextWidth(text[0], options);
46348
- if (length > width) {
46349
- return { str: '', width: 0 };
46350
- }
46351
- return this._clipText(text, options, width, 0, text.length - 1);
46352
- }
46353
- _clipText(text, options, width, leftIdx, rightIdx) {
46354
- const middleIdx = Math.floor((leftIdx + rightIdx) / 2);
46355
- const subText = text.substring(0, middleIdx + 1);
46356
- const strWidth = this.measureTextWidth(subText, options);
46357
- let length;
46358
- if (strWidth > width) {
46359
- if (subText.length <= 1) {
46360
- return { str: '', width: 0 };
46361
- }
46362
- const str = text.substring(0, middleIdx);
46363
- length = this.measureTextWidth(str, options);
46364
- if (length <= width) {
46365
- return { str, width: length };
46366
- }
46367
- return this._clipText(text, options, width, leftIdx, middleIdx);
46368
- }
46369
- else if (strWidth < width) {
46370
- if (middleIdx >= text.length - 1) {
46371
- return { str: text, width: this.measureTextWidth(text, options) };
46372
- }
46373
- const str = text.substring(0, middleIdx + 2);
46374
- length = this.measureTextWidth(str, options);
46375
- if (length >= width) {
46376
- return { str: subText, width: strWidth };
46377
- }
46378
- return this._clipText(text, options, width, middleIdx, rightIdx);
46379
- }
46380
- return { str: subText, width: strWidth };
46381
- }
46382
- clipTextWithSuffix(text, options, width, suffix) {
46383
- if (suffix === '') {
46384
- return this.clipText(text, options, width);
46385
- }
46386
- if (text.length === 0) {
46387
- return { str: '', width: 0 };
46388
- }
46389
- const length = this.measureTextWidth(text, options);
46390
- if (length <= width) {
46391
- return { str: text, width: length };
46392
- }
46393
- const suffixWidth = this.measureTextWidth(suffix, options);
46394
- if (suffixWidth > width) {
46395
- return { str: '', width: 0 };
46396
- }
46397
- width -= suffixWidth;
46398
- const data = this._clipText(text, options, width, 0, text.length - 1);
46399
- data.str += suffix;
46400
- data.width += suffixWidth;
46401
- return data;
46402
- }
46403
- }
46404
- const textMeasure = new TextMeasureTool();
46405
- function setCustomAlphabetCharSet(str) {
46406
- customAlphabetCharSet = str;
46407
- fastTextMeasureCache.clear();
46408
- }
46409
- function restoreMeasureText() {
46410
- container.load(restoreTextMeasureModule);
46411
- }
46412
-
46413
46606
  function hideHoverIcon(col, row, scene) {
46414
46607
  if (col === -1 || row === -1) {
46415
46608
  return;
@@ -47059,13 +47252,13 @@
47059
47252
  stage;
47060
47253
  table;
47061
47254
  isPivot;
47062
- transpose;
47063
47255
  hasFrozen;
47064
47256
  frozenColCount;
47065
47257
  frozenRowCount;
47066
47258
  clear;
47067
47259
  mergeMap;
47068
47260
  _dealAutoFillHeightOriginRowsHeight;
47261
+ _needUpdateContainer = false;
47069
47262
  constructor(table) {
47070
47263
  this.table = table;
47071
47264
  this.hasFrozen = false;
@@ -47137,7 +47330,6 @@
47137
47330
  }
47138
47331
  initSceneGraph() {
47139
47332
  this.isPivot = this.table.isPivotTable();
47140
- this.transpose = this.table.options.transpose;
47141
47333
  initSceneGraph(this);
47142
47334
  }
47143
47335
  clearCells() {
@@ -47455,7 +47647,7 @@
47455
47647
  updateColWidth(col, detaX, skipUpdateContainer, skipTableWidthMap) {
47456
47648
  updateColWidth(this, col, Math.round(detaX), skipTableWidthMap);
47457
47649
  if (!skipUpdateContainer) {
47458
- this.updateContainer();
47650
+ this.updateContainer(true);
47459
47651
  }
47460
47652
  }
47461
47653
  updateChartSize(col) {
@@ -47465,7 +47657,7 @@
47465
47657
  this.table.isPivotChart() && updateChartState(this, datum);
47466
47658
  }
47467
47659
  updateCheckboxCellState(col, row, checked) {
47468
- if (this.transpose) {
47660
+ if (this.table.transpose) {
47469
47661
  this.bodyGroup.children?.forEach((columnGroup) => {
47470
47662
  columnGroup
47471
47663
  .getChildAt(row)
@@ -47489,7 +47681,7 @@
47489
47681
  }
47490
47682
  }
47491
47683
  updateHeaderCheckboxCellState(col, row, checked) {
47492
- if (this.transpose) {
47684
+ if (this.table.transpose) {
47493
47685
  this.rowHeaderGroup.children?.forEach((columnGroup) => {
47494
47686
  columnGroup
47495
47687
  .getChildAt(row)
@@ -47800,7 +47992,7 @@
47800
47992
  this.updateNextFrame();
47801
47993
  }
47802
47994
  afterScenegraphCreated() {
47803
- if (!this.isPivot && !this.transpose) {
47995
+ if (!this.isPivot && !this.table.transpose) {
47804
47996
  this.component.setFrozenColumnShadow(this.table.frozenColCount - 1);
47805
47997
  }
47806
47998
  this.table.stateManager.checkFrozen();
@@ -48016,11 +48208,26 @@
48016
48208
  this.bottomFrozenGroup.setAttribute('x', this.table.getFrozenColsWidth());
48017
48209
  this.bodyGroup.setAttribute('x', this.rowHeaderGroup.attribute.width);
48018
48210
  }
48019
- updateContainer() {
48020
- this.updateContainerAttrWidthAndX();
48021
- this.updateTableSize();
48022
- this.component.updateScrollBar();
48023
- this.updateNextFrame();
48211
+ updateContainer(async = false) {
48212
+ if (async) {
48213
+ if (!this._needUpdateContainer) {
48214
+ this._needUpdateContainer = true;
48215
+ setTimeout(() => {
48216
+ this.updateContainerAttrWidthAndX();
48217
+ this.updateTableSize();
48218
+ this.component.updateScrollBar();
48219
+ this.updateNextFrame();
48220
+ this._needUpdateContainer = false;
48221
+ }, 0);
48222
+ }
48223
+ }
48224
+ else {
48225
+ this.updateContainerAttrWidthAndX();
48226
+ this.updateTableSize();
48227
+ this.component.updateScrollBar();
48228
+ this.updateNextFrame();
48229
+ this._needUpdateContainer = false;
48230
+ }
48024
48231
  }
48025
48232
  updateCellContentWhileResize(col, row) {
48026
48233
  const type = this.table.getBodyColumnType(col, row);
@@ -48122,7 +48329,7 @@
48122
48329
  }
48123
48330
  sortCell() {
48124
48331
  if (this.isPivot) ;
48125
- else if (this.transpose) {
48332
+ else if (this.table.transpose) {
48126
48333
  this.proxy.sortCellHorizontal();
48127
48334
  }
48128
48335
  else {
@@ -48201,7 +48408,7 @@
48201
48408
  }
48202
48409
  }
48203
48410
  this.table.stateManager.checkFrozen();
48204
- if (!this.isPivot && !this.transpose) {
48411
+ if (!this.isPivot && !this.table.transpose) {
48205
48412
  this.component.setFrozenColumnShadow(this.table.frozenColCount - 1);
48206
48413
  }
48207
48414
  this.component.updateScrollBar();
@@ -48212,7 +48419,7 @@
48212
48419
  this.recalculateColWidths();
48213
48420
  this.recalculateRowHeights();
48214
48421
  this.table.stateManager.checkFrozen();
48215
- if (!this.isPivot && !this.transpose) {
48422
+ if (!this.isPivot && !this.table.transpose) {
48216
48423
  this.component.setFrozenColumnShadow(this.table.frozenColCount - 1);
48217
48424
  }
48218
48425
  this.component.updateScrollBar();
@@ -50236,39 +50443,6 @@
50236
50443
  function bindTableGroupListener(eventManager) {
50237
50444
  const table = eventManager.table;
50238
50445
  const stateManager = table.stateManager;
50239
- document.body.addEventListener('pointerdown', e => {
50240
- table.eventManager.LastBodyPointerXY = { x: e.x, y: e.y };
50241
- table.eventManager.isDown = true;
50242
- });
50243
- document.addEventListener('pointerup', e => {
50244
- table.eventManager.LastBodyPointerXY = null;
50245
- table.eventManager.isDown = false;
50246
- table.eventManager.isDraging = false;
50247
- });
50248
- document.body.addEventListener('pointermove', (e) => {
50249
- if (table.eventManager.isDown && table.eventManager.LastBodyPointerXY) {
50250
- const lastX = table.eventManager.LastBodyPointerXY?.x ?? e.x;
50251
- const lastY = table.eventManager.LastBodyPointerXY?.y ?? e.y;
50252
- if (Math.abs(lastX - e.x) > 1 || Math.abs(lastY - e.y) > 1) {
50253
- table.eventManager.isDraging = true;
50254
- }
50255
- }
50256
- const { x, y } = table._getMouseAbstractPoint(e, false);
50257
- if (stateManager.interactionState === InteractionState.scrolling) {
50258
- return;
50259
- }
50260
- if (stateManager.interactionState === InteractionState.grabing) {
50261
- if (stateManager.isResizeCol()) {
50262
- eventManager.dealColumnResize(x, y);
50263
- if (table.hasListeners(TABLE_EVENT_TYPE.RESIZE_COLUMN)) {
50264
- table.fireListeners(TABLE_EVENT_TYPE.RESIZE_COLUMN, {
50265
- col: table.stateManager.columnResize.col,
50266
- colWidth: table.getColWidth(table.stateManager.columnResize.col)
50267
- });
50268
- }
50269
- }
50270
- }
50271
- });
50272
50446
  table.scenegraph.tableGroup.addEventListener('pointermove', (e) => {
50273
50447
  const lastX = table.eventManager.LastPointerXY?.x ?? e.x;
50274
50448
  const lastY = table.eventManager.LastPointerXY?.y ?? e.y;
@@ -51179,12 +51353,12 @@
51179
51353
  const ranges = table.stateManager.select.ranges;
51180
51354
  const col = Math.min(ranges[0].start.col, ranges[0].end.col);
51181
51355
  const row = Math.min(ranges[0].start.row, ranges[0].end.row);
51356
+ const values = [];
51182
51357
  navigator.clipboard.read().then(clipboardItems => {
51183
51358
  for (const item of clipboardItems) {
51184
51359
  if (item.types.includes('text/html')) {
51185
51360
  item.getType('text/html').then(blob => {
51186
51361
  blob.text().then(pastedData => {
51187
- const values = [];
51188
51362
  if (pastedData && /(<table)|(<TABLE)/g.test(pastedData)) {
51189
51363
  const regex = /<tr[^>]*>(.*?)<\/tr>/gs;
51190
51364
  const matches = Array.from(pastedData.matchAll(regex));
@@ -51204,22 +51378,33 @@
51204
51378
  });
51205
51379
  values.push(rowValues);
51206
51380
  }
51381
+ table.changeCellValues(col, row, values, true);
51207
51382
  }
51208
51383
  else {
51209
- const rows = pastedData.split('\n');
51210
- rows.forEach(function (rowCells, rowIndex) {
51211
- const cells = rowCells.split('\t');
51212
- const rowValues = [];
51213
- values.push(rowValues);
51214
- cells.forEach(function (cell, cellIndex) {
51215
- if (cellIndex === cells.length - 1) {
51216
- cell = cell.trim();
51384
+ navigator.clipboard.read().then(clipboardItems => {
51385
+ for (const item of clipboardItems) {
51386
+ if (item.types.includes('text/plain')) {
51387
+ item.getType('text/plain').then(blob => {
51388
+ blob.text().then(pastedData => {
51389
+ const rows = pastedData.split('\n');
51390
+ rows.forEach(function (rowCells, rowIndex) {
51391
+ const cells = rowCells.split('\t');
51392
+ const rowValues = [];
51393
+ values.push(rowValues);
51394
+ cells.forEach(function (cell, cellIndex) {
51395
+ if (cellIndex === cells.length - 1) {
51396
+ cell = cell.trim();
51397
+ }
51398
+ rowValues.push(cell);
51399
+ });
51400
+ });
51401
+ table.changeCellValues(col, row, values, true);
51402
+ });
51403
+ });
51217
51404
  }
51218
- rowValues.push(cell);
51219
- });
51405
+ }
51220
51406
  });
51221
51407
  }
51222
- table.changeCellValues(col, row, values, true);
51223
51408
  });
51224
51409
  });
51225
51410
  }
@@ -51227,26 +51412,22 @@
51227
51412
  item.getType('text/plain').then(blob => {
51228
51413
  blob.text().then(pastedData => {
51229
51414
  const rows = pastedData.replace(/\r(?!\n)/g, '\r\n').split('\r\n');
51230
- const values = [];
51231
51415
  if (rows.length > 1 && rows[rows.length - 1] === '') {
51232
51416
  rows.pop();
51233
51417
  }
51234
51418
  rows.forEach(function (rowCells, rowIndex) {
51235
51419
  const cells = rowCells.split('\t');
51236
- const rowValues = [];
51237
- values.push(rowValues);
51238
51420
  cells.forEach(function (cell, cellIndex) {
51239
51421
  if (cell.includes('\n')) {
51240
51422
  cell = cell
51241
51423
  .replace(/^"(.*)"$/, '$1')
51242
51424
  .replace(/["]*/g, match => new Array(Math.floor(match.length / 2)).fill('"').join(''));
51243
51425
  }
51244
- rowValues.push(cell);
51245
51426
  });
51246
51427
  });
51247
- table.changeCellValues(col, row, values, true);
51248
51428
  });
51249
51429
  });
51430
+ table.changeCellValues(col, row, values, true);
51250
51431
  }
51251
51432
  else ;
51252
51433
  }
@@ -51265,6 +51446,57 @@
51265
51446
  }
51266
51447
  table.resize();
51267
51448
  });
51449
+ const globalPointerdownCallback = (e) => {
51450
+ table.eventManager.LastBodyPointerXY = { x: e.x, y: e.y };
51451
+ table.eventManager.isDown = true;
51452
+ };
51453
+ eventManager.globalEventListeners.push({
51454
+ name: 'pointerdown',
51455
+ env: 'body',
51456
+ callback: globalPointerdownCallback
51457
+ });
51458
+ document.body.addEventListener('pointerdown', globalPointerdownCallback);
51459
+ const globalPointerupCallback = (e) => {
51460
+ table.eventManager.LastBodyPointerXY = null;
51461
+ table.eventManager.isDown = false;
51462
+ table.eventManager.isDraging = false;
51463
+ };
51464
+ eventManager.globalEventListeners.push({
51465
+ name: 'pointerup',
51466
+ env: 'document',
51467
+ callback: globalPointerupCallback
51468
+ });
51469
+ document.addEventListener('pointerup', globalPointerupCallback);
51470
+ const globalPointermoveCallback = (e) => {
51471
+ if (table.eventManager.isDown && table.eventManager.LastBodyPointerXY) {
51472
+ const lastX = table.eventManager.LastBodyPointerXY?.x ?? e.x;
51473
+ const lastY = table.eventManager.LastBodyPointerXY?.y ?? e.y;
51474
+ if (Math.abs(lastX - e.x) > 1 || Math.abs(lastY - e.y) > 1) {
51475
+ table.eventManager.isDraging = true;
51476
+ }
51477
+ }
51478
+ const { x, y } = table._getMouseAbstractPoint(e, false);
51479
+ if (stateManager.interactionState === InteractionState.scrolling) {
51480
+ return;
51481
+ }
51482
+ if (stateManager.interactionState === InteractionState.grabing) {
51483
+ if (stateManager.isResizeCol()) {
51484
+ eventManager.dealColumnResize(x, y);
51485
+ if (table.hasListeners(TABLE_EVENT_TYPE.RESIZE_COLUMN)) {
51486
+ table.fireListeners(TABLE_EVENT_TYPE.RESIZE_COLUMN, {
51487
+ col: table.stateManager.columnResize.col,
51488
+ colWidth: table.getColWidth(table.stateManager.columnResize.col)
51489
+ });
51490
+ }
51491
+ }
51492
+ }
51493
+ };
51494
+ eventManager.globalEventListeners.push({
51495
+ name: 'pointermove',
51496
+ env: 'body',
51497
+ callback: globalPointermoveCallback
51498
+ });
51499
+ document.body.addEventListener('pointermove', globalPointermoveCallback);
51268
51500
  }
51269
51501
 
51270
51502
  function bindTouchListener(eventManager) {
@@ -51283,7 +51515,7 @@
51283
51515
  timestamp: Date.now()
51284
51516
  });
51285
51517
  });
51286
- window.addEventListener('touchmove', (e) => {
51518
+ const globalTouchMoveCallback = (e) => {
51287
51519
  if (eventManager.touchMove) {
51288
51520
  e.preventDefault();
51289
51521
  }
@@ -51309,8 +51541,14 @@
51309
51541
  (Math.abs(deltaY) <= Math.abs(deltaX) && deltaX !== 0 && isHorizontalScrollable(deltaX, stateManager)))) {
51310
51542
  e.preventDefault();
51311
51543
  }
51312
- }, { passive: false });
51313
- window.addEventListener('touchend', (e) => {
51544
+ };
51545
+ window.addEventListener('touchmove', globalTouchMoveCallback, { passive: false });
51546
+ eventManager.globalEventListeners.push({
51547
+ name: 'touchmove',
51548
+ env: 'window',
51549
+ callback: globalTouchMoveCallback
51550
+ });
51551
+ const globalTouchEndCallback = (e) => {
51314
51552
  eventManager.touchEnd = true;
51315
51553
  eventManager.touchMove = false;
51316
51554
  if (!eventManager.isTouchdown || !isTouchEvent$1(e)) {
@@ -51333,8 +51571,14 @@
51333
51571
  }
51334
51572
  eventManager.isTouchdown = false;
51335
51573
  eventManager.touchMovePoints = [];
51574
+ };
51575
+ window.addEventListener('touchend', globalTouchEndCallback);
51576
+ eventManager.globalEventListeners.push({
51577
+ name: 'touchend',
51578
+ env: 'window',
51579
+ callback: globalTouchEndCallback
51336
51580
  });
51337
- window.addEventListener('touchcancel', (e) => {
51581
+ const globalTouchCancelCallback = (e) => {
51338
51582
  eventManager.touchEnd = true;
51339
51583
  eventManager.touchMove = false;
51340
51584
  if (!eventManager.isTouchdown) {
@@ -51342,6 +51586,12 @@
51342
51586
  }
51343
51587
  eventManager.isTouchdown = false;
51344
51588
  eventManager.touchMovePoints = [];
51589
+ };
51590
+ window.addEventListener('touchcancel', globalTouchCancelCallback);
51591
+ eventManager.globalEventListeners.push({
51592
+ name: 'touchcancel',
51593
+ env: 'window',
51594
+ callback: globalTouchCancelCallback
51345
51595
  });
51346
51596
  }
51347
51597
  function isTouchEvent$1(e) {
@@ -51517,6 +51767,7 @@
51517
51767
  LastBodyPointerXY;
51518
51768
  isDown = false;
51519
51769
  isDraging = false;
51770
+ globalEventListeners = [];
51520
51771
  constructor(table) {
51521
51772
  this.table = table;
51522
51773
  if (Env.mode === 'node') {
@@ -51743,6 +51994,18 @@
51743
51994
  }
51744
51995
  release() {
51745
51996
  this.gesture.release();
51997
+ this.globalEventListeners.forEach(item => {
51998
+ if (item.env === 'document') {
51999
+ document.removeEventListener(item.name, item.callback);
52000
+ }
52001
+ else if (item.env === 'body') {
52002
+ document.body.removeEventListener(item.name, item.callback);
52003
+ }
52004
+ else if (item.env === 'window') {
52005
+ window.removeEventListener(item.name, item.callback);
52006
+ }
52007
+ });
52008
+ this.globalEventListeners = [];
51746
52009
  }
51747
52010
  }
51748
52011
 
@@ -51790,7 +52053,7 @@
51790
52053
  this._barHeight = style.barHeight ?? 3;
51791
52054
  this._barHeight = style.barHeight ?? 3;
51792
52055
  this._barBottom = style.barBottom ?? 0;
51793
- this._barPadding = style.barPadding ?? [1, 1, 1, 1];
52056
+ this._barPadding = style.barPadding ?? [0, 0, 0, 0];
51794
52057
  this._showBarMark = style.showBarMark ?? false;
51795
52058
  this._barMarkPositiveColor = style.barMarkPositiveColor ?? '#4dbd74';
51796
52059
  this._barMarkNegativeColor = style.barMarkNegativeColor ?? '#f86c6b';
@@ -54944,7 +55207,7 @@
54944
55207
  return TABLE_EVENT_TYPE;
54945
55208
  }
54946
55209
  options;
54947
- version = "0.21.1";
55210
+ version = "0.21.2";
54948
55211
  pagination;
54949
55212
  id = `VTable${Date.now()}`;
54950
55213
  headerStyleCache;
@@ -66532,7 +66795,7 @@
66532
66795
  }
66533
66796
 
66534
66797
  registerForVrender();
66535
- const version = "0.21.1";
66798
+ const version = "0.21.2";
66536
66799
  function getIcons() {
66537
66800
  return get$2();
66538
66801
  }