@univerjs/engine-render 0.3.0 → 0.4.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { Tools, DEFAULT_STYLES, FontStyleType, BaselineOffset, getCellInfoInMergeData, Rectangle, ColorKit, Disposable, EventSubject, checkParagraphHasIndentByStyle, DataStreamTreeTokenType, BorderStyleTypes, BooleanNumber, DisposableCollection, toDisposable, sortRules, Registry, numberToABC, Range, Inject, LocaleService, insertTextToContent, horizontalLineSegmentsSubtraction, deleteContent, DataStreamTreeNodeType, DocumentDataModel, GridType, BulletAlignment, PositionedObjectLayoutType, WrapTextType, ColumnSeparatorType, TableAlignmentType, ObjectRelativeFromV, TableTextWrapType, SpacingRule, CustomDecorationType, CustomRangeType, ObjectMatrix, SectionType, NumberUnitType, PageOrientType, HorizontalAlign, VerticalAlign, WrapStrategy, AlignTypeH, ObjectRelativeFromH, AlignTypeV, mergeWith, GlyphType as GlyphType$1, numberToListABC, PRESET_LIST_TYPE, searchArray, extractPureTextFromCell, CellValueType, isCellCoverable, isNullCell, getColorStyle, isWhiteColor, IContextService, BuildTextUtils, TextX, DEFAULT_EMPTY_DOCUMENT_VALUE, TextDecoration, COLORS, DocumentFlavor, requestImmediateMacroTask, MOVE_BUFFER_VALUE, sortRulesByDesc, Injector, isClassDependencyItem, createIdentifier, remove, UniverInstanceType, IUniverInstanceService, Plugin, IConfigService } from "@univerjs/core";
5
+ import { Tools, DEFAULT_STYLES, FontStyleType, BaselineOffset, getCellInfoInMergeData, Rectangle, ColorKit, Disposable, EventSubject, checkParagraphHasIndentByStyle, DataStreamTreeTokenType, BorderStyleTypes, BooleanNumber, DisposableCollection, toDisposable, sortRules, Registry, Range, numberToABC, Inject, LocaleService, insertTextToContent, horizontalLineSegmentsSubtraction, deleteContent, DataStreamTreeNodeType, DocumentDataModel, GridType, BulletAlignment, PositionedObjectLayoutType, WrapTextType, ColumnSeparatorType, TableAlignmentType, ObjectRelativeFromV, TableTextWrapType, SpacingRule, CustomDecorationType, CustomRangeType, ObjectMatrix, SectionType, NumberUnitType, PageOrientType, HorizontalAlign, VerticalAlign, WrapStrategy, AlignTypeH, ObjectRelativeFromH, AlignTypeV, mergeWith, GlyphType as GlyphType$1, numberToListABC, PRESET_LIST_TYPE, searchArray, extractPureTextFromCell, CellValueType, isCellCoverable, isNullCell, getColorStyle, isWhiteColor, IContextService, BuildTextUtils, TextX, DEFAULT_EMPTY_DOCUMENT_VALUE, TextDecoration, COLORS, DocumentFlavor, requestImmediateMacroTask, MOVE_BUFFER_VALUE, sortRulesByDesc, Injector, isClassDependencyItem, createIdentifier, remove, UniverInstanceType, IUniverInstanceService, Plugin, IConfigService } from "@univerjs/core";
6
6
  import { BehaviorSubject, Subject, startWith, distinctUntilChanged, Subscription, Observable, shareReplay } from "rxjs";
7
7
  var SHAPE_TYPE = /* @__PURE__ */ ((SHAPE_TYPE2) => (SHAPE_TYPE2.RECT = "rect", SHAPE_TYPE2.CIRCLE = "circle", SHAPE_TYPE2.PATH = "path", SHAPE_TYPE2))(SHAPE_TYPE || {}), LINK_VIEW_PORT_TYPE = /* @__PURE__ */ ((LINK_VIEW_PORT_TYPE2) => (LINK_VIEW_PORT_TYPE2[LINK_VIEW_PORT_TYPE2.XY = 0] = "XY", LINK_VIEW_PORT_TYPE2[LINK_VIEW_PORT_TYPE2.X = 1] = "X", LINK_VIEW_PORT_TYPE2[LINK_VIEW_PORT_TYPE2.Y = 2] = "Y", LINK_VIEW_PORT_TYPE2))(LINK_VIEW_PORT_TYPE || {});
8
8
  const MIDDLE_CELL_POS_MAGIC_NUMBER = 1, DEFAULT_FONTFACE_PLANE = '"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif', DEFAULT_SKELETON_HEADER_FOOTER = {
@@ -1743,7 +1743,7 @@ function expandRangeIfIntersects(mainRanges, ranges) {
1743
1743
  return mainRanges.concat(intersects);
1744
1744
  }
1745
1745
  __name(expandRangeIfIntersects, "expandRangeIfIntersects");
1746
- function clampRanges(range) {
1746
+ function clampRange(range) {
1747
1747
  return {
1748
1748
  startRow: Math.max(0, range.startRow),
1749
1749
  startColumn: Math.max(0, range.startColumn),
@@ -1751,7 +1751,7 @@ function clampRanges(range) {
1751
1751
  endColumn: Math.max(0, range.endColumn)
1752
1752
  };
1753
1753
  }
1754
- __name(clampRanges, "clampRanges");
1754
+ __name(clampRange, "clampRange");
1755
1755
  function getSystemHighlightColor() {
1756
1756
  const hiddenEle = document.createElement("div");
1757
1757
  hiddenEle.style.width = "0", hiddenEle.style.height = "0", hiddenEle.style.backgroundColor = "highlight", document.body.append(hiddenEle);
@@ -3177,13 +3177,47 @@ __name(drawLineByBorderType, "drawLineByBorderType");
3177
3177
  function drawDiagonalLineByBorderType(ctx, type, position) {
3178
3178
  let drawStartX = 0, drawStartY = 0, drawEndX = 0, drawEndY = 0;
3179
3179
  const { startX, startY, endX, endY } = position;
3180
- type === BORDER_TYPE.TL_BR ? (drawStartX = startX, drawStartY = startY, drawEndX = endX, drawEndY = endY) : type === BORDER_TYPE.TL_BC ? (drawStartX = startX, drawStartY = startY, drawEndX = (startX + endX) / 2, drawEndY = endY) : type === BORDER_TYPE.TL_MR ? (drawStartX = startX, drawStartY = startY, drawEndX = endX, drawEndY = (startY + endY) / 2) : type === BORDER_TYPE.BL_TR ? (drawStartX = startX, drawStartY = endY, drawEndX = endX, drawEndY = startY) : type === BORDER_TYPE.ML_TR ? (drawStartX = startX, drawStartY = (startY + endY) / 2, drawEndX = endX, drawEndY = startY) : type === BORDER_TYPE.BC_TR && (drawStartX = (startX + endX) / 2, drawStartY = endY, drawEndX = endX, drawEndY = startY), ctx.beginPath(), ctx.moveToByPrecision(drawStartX, drawStartY), ctx.lineToByPrecision(drawEndX, drawEndY), ctx.closePathByEnv(), ctx.stroke();
3180
+ switch (type) {
3181
+ case BORDER_TYPE.TL_BR:
3182
+ drawStartX = startX, drawStartY = startY, drawEndX = endX, drawEndY = endY;
3183
+ break;
3184
+ case BORDER_TYPE.TL_BC:
3185
+ drawStartX = startX, drawStartY = startY, drawEndX = (startX + endX) / 2, drawEndY = endY;
3186
+ break;
3187
+ case BORDER_TYPE.TL_MR:
3188
+ drawStartX = startX, drawStartY = startY, drawEndX = endX, drawEndY = (startY + endY) / 2;
3189
+ break;
3190
+ case BORDER_TYPE.BL_TR:
3191
+ drawStartX = startX, drawStartY = endY, drawEndX = endX, drawEndY = startY;
3192
+ break;
3193
+ case BORDER_TYPE.ML_TR:
3194
+ drawStartX = startX, drawStartY = (startY + endY) / 2, drawEndX = endX, drawEndY = startY;
3195
+ break;
3196
+ case BORDER_TYPE.BC_TR:
3197
+ drawStartX = (startX + endX) / 2, drawStartY = endY, drawEndX = endX, drawEndY = startY;
3198
+ break;
3199
+ }
3200
+ ctx.beginPath(), ctx.moveToByPrecision(drawStartX, drawStartY), ctx.lineToByPrecision(drawEndX, drawEndY), ctx.closePathByEnv(), ctx.stroke();
3181
3201
  }
3182
3202
  __name(drawDiagonalLineByBorderType, "drawDiagonalLineByBorderType");
3183
3203
  function clearLineByBorderType(ctx, type, position) {
3184
3204
  let drawStartX = 0, drawStartY = 0, drawEndX = 0, drawEndY = 0;
3185
3205
  const { startX, startY, endX, endY } = position;
3186
- type === BORDER_TYPE.TOP ? (drawStartX = startX, drawStartY = startY, drawEndX = endX, drawEndY = startY) : type === BORDER_TYPE.BOTTOM ? (drawStartX = startX, drawStartY = endY, drawEndX = endX, drawEndY = endY) : type === BORDER_TYPE.LEFT ? (drawStartX = startX, drawStartY = startY, drawEndX = startX, drawEndY = endY) : type === BORDER_TYPE.RIGHT && (drawStartX = endX, drawStartY = startY, drawEndX = endX, drawEndY = endY), ctx.beginPath(), ctx.clearRectForTexture(drawStartX, drawStartY, drawEndX - drawStartX, drawEndY - drawStartY);
3206
+ switch (type) {
3207
+ case BORDER_TYPE.TOP:
3208
+ drawStartX = startX, drawStartY = startY, drawEndX = endX, drawEndY = startY;
3209
+ break;
3210
+ case BORDER_TYPE.BOTTOM:
3211
+ drawStartX = startX, drawStartY = endY, drawEndX = endX, drawEndY = endY;
3212
+ break;
3213
+ case BORDER_TYPE.LEFT:
3214
+ drawStartX = startX, drawStartY = startY, drawEndX = startX, drawEndY = endY;
3215
+ break;
3216
+ case BORDER_TYPE.RIGHT:
3217
+ drawStartX = endX, drawStartY = startY, drawEndX = endX, drawEndY = endY;
3218
+ break;
3219
+ }
3220
+ ctx.beginPath(), ctx.clearRectForTexture(drawStartX, drawStartY, drawEndX - drawStartX, drawEndY - drawStartY);
3187
3221
  }
3188
3222
  __name(clearLineByBorderType, "clearLineByBorderType");
3189
3223
  function setLineType(ctx, style) {
@@ -3593,6 +3627,7 @@ const _UniverRenderingContext2D = class _UniverRenderingContext2D {
3593
3627
  __publicField(this, "__mode", "rendering");
3594
3628
  __publicField(this, "_system");
3595
3629
  __publicField(this, "_browser");
3630
+ __publicField(this, "_transformCache");
3596
3631
  __publicField(this, "canvas");
3597
3632
  __publicField(this, "_context");
3598
3633
  __publicField(this, "_systemType");
@@ -3789,8 +3824,8 @@ const _UniverRenderingContext2D = class _UniverRenderingContext2D {
3789
3824
  this._context.textBaseline = val;
3790
3825
  }
3791
3826
  _getScale() {
3792
- const m = this.getTransform();
3793
- return {
3827
+ const m = this._transformCache || this.getTransform();
3828
+ return !this._transformCache && m && (this._transformCache = m), {
3794
3829
  scaleX: m.a,
3795
3830
  scaleY: m.d
3796
3831
  };
@@ -3818,7 +3853,7 @@ const _UniverRenderingContext2D = class _UniverRenderingContext2D {
3818
3853
  return this._context.getTransform();
3819
3854
  }
3820
3855
  resetTransform() {
3821
- this._context.resetTransform();
3856
+ this._transformCache = null, this._context.resetTransform();
3822
3857
  }
3823
3858
  drawFocusIfNeeded(...args) {
3824
3859
  return this._context.drawFocusIfNeeded(...args);
@@ -3828,7 +3863,7 @@ const _UniverRenderingContext2D = class _UniverRenderingContext2D {
3828
3863
  * @method
3829
3864
  */
3830
3865
  reset() {
3831
- this._context.reset();
3866
+ this._transformCache = null, this._context.reset();
3832
3867
  }
3833
3868
  /**
3834
3869
  * arc function.
@@ -4126,7 +4161,7 @@ const _UniverRenderingContext2D = class _UniverRenderingContext2D {
4126
4161
  return this._context.getLineDash();
4127
4162
  }
4128
4163
  setTransform(...args) {
4129
- this._context.setTransform(...args);
4164
+ this._transformCache = null, this._context.setTransform(...args);
4130
4165
  }
4131
4166
  /**
4132
4167
  * stroke function.
@@ -4155,7 +4190,7 @@ const _UniverRenderingContext2D = class _UniverRenderingContext2D {
4155
4190
  * @method
4156
4191
  */
4157
4192
  transform(a, b, c, d, e, f) {
4158
- this._context.transform(a, b, c, d, e, f);
4193
+ this._context.transform(a, b, c, d, e, f), this._transformCache = null;
4159
4194
  }
4160
4195
  /**
4161
4196
  * translate function.
@@ -4604,32 +4639,65 @@ let Background$1 = (_a = class extends SheetExtension {
4604
4639
  var _a10;
4605
4640
  return (_a10 = this.parent) != null && _a10.isPrinting ? this.PRINTING_Z_INDEX : this.Z_INDEX;
4606
4641
  }
4642
+ // eslint-disable-next-line max-lines-per-function
4607
4643
  draw(ctx, _parentScale, spreadsheetSkeleton, diffRanges, { viewRanges, checkOutOfViewBound }) {
4608
- const { stylesCache, worksheet, rowHeightAccumulation, columnTotalWidth, columnWidthAccumulation, rowTotalHeight } = spreadsheetSkeleton, { background: backgroundCache, backgroundPositions } = stylesCache;
4609
- if (!worksheet || !backgroundCache || !rowHeightAccumulation || !columnWidthAccumulation || columnTotalWidth === void 0 || rowTotalHeight === void 0)
4644
+ const { stylesCache, worksheet, rowHeightAccumulation, columnTotalWidth, columnWidthAccumulation, rowTotalHeight } = spreadsheetSkeleton, { background: bgMatrixCacheByColor, backgroundPositions } = stylesCache;
4645
+ if (!worksheet || !bgMatrixCacheByColor || !rowHeightAccumulation || !columnWidthAccumulation || columnTotalWidth === void 0 || rowTotalHeight === void 0)
4610
4646
  return;
4611
4647
  ctx.save();
4612
- const { scaleX, scaleY } = ctx.getScale(), renderBGCore = /* @__PURE__ */ __name((rgb) => {
4613
- ctx.beginPath();
4614
- const bgColorMatrix = backgroundCache[rgb];
4648
+ const { scaleX, scaleY } = ctx.getScale(), renderBGContext = {
4649
+ ctx,
4650
+ backgroundPositions,
4651
+ scaleX,
4652
+ scaleY,
4653
+ checkOutOfViewBound,
4654
+ viewRanges,
4655
+ diffRanges,
4656
+ spreadsheetSkeleton
4657
+ }, mergeRanges = [];
4658
+ viewRanges.forEach((range) => {
4659
+ const intersectMergeRangesInViewRanges = spreadsheetSkeleton.worksheet.getMergedCellRange(range.startRow, range.startColumn, range.endRow, range.endColumn);
4660
+ mergeRanges.push(...intersectMergeRangesInViewRanges);
4661
+ });
4662
+ const renderBGCore = /* @__PURE__ */ __name((rgb) => {
4663
+ const bgColorMatrix = bgMatrixCacheByColor[rgb];
4615
4664
  ctx.fillStyle = rgb || getColor([255, 255, 255]);
4616
- const backgroundPaths = new Path2D(), renderBGByCell = /* @__PURE__ */ __name((row, col) => {
4617
- if (!checkOutOfViewBound && !inViewRanges(viewRanges, row, col))
4618
- return !0;
4619
- const cellInfo = backgroundPositions == null ? void 0 : backgroundPositions.getValue(row, col);
4620
- if (cellInfo == null)
4621
- return !0;
4622
- let { startY, endY, startX, endX } = cellInfo;
4623
- const { isMerged, isMergedMainCell, mergeInfo } = cellInfo, combineWithMergeRanges = diffRanges && diffRanges.length > 0 ? diffRanges : viewRanges;
4624
- if (!inViewRanges(combineWithMergeRanges, row, col) || (isMergedMainCell && (startY = mergeInfo.startY, endY = mergeInfo.endY, startX = mergeInfo.startX, endX = mergeInfo.endX), isMerged)) return !0;
4625
- const visibleRow = spreadsheetSkeleton.worksheet.getRowVisible(row), visibleCol = spreadsheetSkeleton.worksheet.getColVisible(col);
4626
- if (!visibleRow || !visibleCol) return !0;
4627
- const startXPrecise = fixLineWidthByScale(startX, scaleX), startYPrecise = fixLineWidthByScale(startY, scaleY), endXPrecise = fixLineWidthByScale(endX, scaleX), endYPrecise = fixLineWidthByScale(endY, scaleY);
4628
- backgroundPaths.rect(startXPrecise, startYPrecise, endXPrecise - startXPrecise, endYPrecise - startYPrecise);
4629
- }, "renderBGByCell");
4630
- bgColorMatrix.forValue(renderBGByCell), ctx.fill(backgroundPaths), ctx.closePath();
4631
- }, "renderBGCore");
4632
- Object.keys(backgroundCache).forEach(renderBGCore), ctx.restore();
4665
+ const backgroundPaths = new Path2D();
4666
+ renderBGContext.backgroundPaths = backgroundPaths, ctx.beginPath(), viewRanges.forEach((range) => {
4667
+ Range.foreach(range, (row, col) => {
4668
+ if (spreadsheetSkeleton.worksheet.getSpanModel().getMergeDataIndex(row, col) !== -1)
4669
+ return;
4670
+ const cellInfo = spreadsheetSkeleton.getCellByIndexWithNoHeader(row, col);
4671
+ if (!cellInfo) return;
4672
+ bgColorMatrix.getValue(row, col) && (renderBGContext.cellInfo = cellInfo, this.renderBGByCell(renderBGContext, row, col));
4673
+ });
4674
+ }), ctx.fill(backgroundPaths), ctx.closePath();
4675
+ }, "renderBGCore"), renderBGForMergedCells = /* @__PURE__ */ __name((rgb) => {
4676
+ const bgColorMatrix = bgMatrixCacheByColor[rgb];
4677
+ ctx.fillStyle = rgb || getColor([255, 255, 255]);
4678
+ const backgroundPaths = new Path2D();
4679
+ renderBGContext.backgroundPaths = backgroundPaths, ctx.beginPath(), mergeRanges.forEach((range) => {
4680
+ if (bgColorMatrix.getValue(range.startRow, range.startColumn)) {
4681
+ const cellInfo = spreadsheetSkeleton.getCellByIndexWithNoHeader(range.startRow, range.startColumn);
4682
+ if (!cellInfo) return;
4683
+ renderBGContext.cellInfo = cellInfo, this.renderBGByCell(renderBGContext, range.startRow, range.startColumn);
4684
+ }
4685
+ }), ctx.fill(backgroundPaths), ctx.closePath();
4686
+ }, "renderBGForMergedCells");
4687
+ Object.keys(bgMatrixCacheByColor).forEach((rgb) => {
4688
+ renderBGCore(rgb), renderBGForMergedCells(rgb);
4689
+ }), ctx.restore();
4690
+ }
4691
+ renderBGByCell(bgContext, row, col) {
4692
+ const { spreadsheetSkeleton, backgroundPaths, scaleX, scaleY, viewRanges, diffRanges, cellInfo } = bgContext;
4693
+ let { startY, endY, startX, endX } = cellInfo;
4694
+ const { isMerged, isMergedMainCell, mergeInfo } = cellInfo, renderRange = diffRanges && diffRanges.length > 0 ? diffRanges : viewRanges;
4695
+ if (startY = mergeInfo.startY, endY = mergeInfo.endY, startX = mergeInfo.startX, endX = mergeInfo.endX, !isMerged && !isMergedMainCell && !inViewRanges(renderRange, row, col))
4696
+ return !0;
4697
+ const visibleRow = spreadsheetSkeleton.worksheet.getRowVisible(row), visibleCol = spreadsheetSkeleton.worksheet.getColVisible(col);
4698
+ if (!visibleRow || !visibleCol) return !0;
4699
+ const startXPrecise = fixLineWidthByScale(startX, scaleX), startYPrecise = fixLineWidthByScale(startY, scaleY), endXPrecise = fixLineWidthByScale(endX, scaleX), endYPrecise = fixLineWidthByScale(endY, scaleY);
4700
+ backgroundPaths.rect(startXPrecise, startYPrecise, endXPrecise - startXPrecise, endYPrecise - startYPrecise);
4633
4701
  }
4634
4702
  }, __name(_a, "Background"), _a);
4635
4703
  SpreadsheetExtensionRegistry.add(Background$1);
@@ -4640,51 +4708,63 @@ let Border$1 = (_a2 = class extends SheetExtension {
4640
4708
  super(...arguments);
4641
4709
  __publicField(this, "uKey", UNIQUE_KEY$9);
4642
4710
  __publicField(this, "Z_INDEX", BORDER_Z_INDEX);
4711
+ __publicField(this, "preStyle");
4712
+ __publicField(this, "preColor");
4643
4713
  }
4644
- // eslint-disable-next-line max-lines-per-function
4645
- draw(ctx, _parentScale, spreadsheetSkeleton, diffRanges) {
4714
+ draw(ctx, _parentScale, spreadsheetSkeleton, diffRanges, { viewRanges }) {
4646
4715
  const { stylesCache, overflowCache, worksheet, rowHeightAccumulation, columnTotalWidth, columnWidthAccumulation, rowTotalHeight } = spreadsheetSkeleton;
4647
4716
  if (!worksheet || !rowHeightAccumulation || !columnWidthAccumulation || columnTotalWidth === void 0 || rowTotalHeight === void 0)
4648
4717
  return;
4649
- ctx.save();
4650
- let preStyle, preColor;
4651
- ctx.translateWithPrecisionRatio(FIX_ONE_PIXEL_BLUR_OFFSET, FIX_ONE_PIXEL_BLUR_OFFSET);
4718
+ ctx.save(), ctx.translateWithPrecisionRatio(FIX_ONE_PIXEL_BLUR_OFFSET, FIX_ONE_PIXEL_BLUR_OFFSET);
4652
4719
  const precisionScale = this._getScale(ctx.getScale()), { border } = stylesCache;
4653
- border == null || border.forValue((rowIndex, columnIndex, borderCaches) => {
4654
- if (!borderCaches)
4655
- return !0;
4656
- const cellInfo = spreadsheetSkeleton.getCellByIndexWithNoHeader(rowIndex, columnIndex), { startY: cellStartY, endY: cellEndY, startX: cellStartX, endX: cellEndX } = cellInfo, { isMerged, isMergedMainCell, mergeInfo } = cellInfo;
4657
- if (!isMerged) {
4658
- const visibleRow = spreadsheetSkeleton.worksheet.getRowVisible(rowIndex), visibleCol = spreadsheetSkeleton.worksheet.getColVisible(columnIndex);
4659
- if (!visibleRow || !visibleCol) return !0;
4660
- }
4661
- if (!this.isRenderDiffRangesByRow(mergeInfo.startRow, mergeInfo.endRow, diffRanges))
4662
- return !0;
4663
- for (const key in borderCaches) {
4664
- const { type, style, color } = borderCaches[key];
4665
- if (style === BorderStyleTypes.NONE)
4666
- continue;
4667
- let startY = cellStartY, endY = cellEndY, startX = cellStartX, endX = cellEndX;
4668
- if (type !== BORDER_TYPE.TOP && type !== BORDER_TYPE.BOTTOM && type !== BORDER_TYPE.LEFT && type !== BORDER_TYPE.RIGHT) {
4669
- if (isMerged)
4670
- return !0;
4671
- isMergedMainCell && (startY = mergeInfo.startY, endY = mergeInfo.endY, startX = mergeInfo.startX, endX = mergeInfo.endX);
4672
- }
4673
- const lineWidth = getLineWidth(style);
4674
- style !== preStyle && (setLineType(ctx, style), ctx.setLineWidthByPrecision(lineWidth), preStyle = style), color !== preColor && (ctx.strokeStyle = color || COLOR_BLACK_RGB, preColor = color), drawDiagonalLineByBorderType(ctx, type, {
4675
- startX,
4676
- startY,
4677
- endX,
4678
- endY
4679
- }), !this._getOverflowExclusion(overflowCache, type, rowIndex, columnIndex) && drawLineByBorderType(ctx, type, (lineWidth - 1) / 2 / precisionScale, {
4680
- startX,
4681
- startY,
4682
- endX,
4683
- endY
4684
- });
4685
- }
4720
+ if (!border) return;
4721
+ const renderBorderContext = {
4722
+ ctx,
4723
+ precisionScale,
4724
+ overflowCache,
4725
+ diffRanges,
4726
+ viewRanges,
4727
+ spreadsheetSkeleton
4728
+ };
4729
+ ctx.beginPath(), viewRanges.forEach((range) => {
4730
+ Range.foreach(range, (row, col) => {
4731
+ const borderConfig = border.getValue(row, col);
4732
+ borderConfig && this.renderBorderByCell(renderBorderContext, row, col, borderConfig);
4733
+ });
4686
4734
  }), ctx.closePath(), ctx.restore();
4687
4735
  }
4736
+ renderBorderByCell(renderBorderContext, row, col, borderCacheItem) {
4737
+ const { ctx, precisionScale, overflowCache, spreadsheetSkeleton, diffRanges } = renderBorderContext, cellInfo = spreadsheetSkeleton.getCellByIndexWithNoHeader(row, col), { startY: cellStartY, endY: cellEndY, startX: cellStartX, endX: cellEndX } = cellInfo, { isMerged, isMergedMainCell, mergeInfo } = cellInfo;
4738
+ if (!isMerged) {
4739
+ const visibleRow = spreadsheetSkeleton.worksheet.getRowVisible(row), visibleCol = spreadsheetSkeleton.worksheet.getColVisible(col);
4740
+ if (!visibleRow || !visibleCol) return !0;
4741
+ }
4742
+ if (!this.isRenderDiffRangesByRow(mergeInfo.startRow, mergeInfo.endRow, diffRanges))
4743
+ return !0;
4744
+ for (const key in borderCacheItem) {
4745
+ const { type, style, color } = borderCacheItem[key];
4746
+ if (style === BorderStyleTypes.NONE)
4747
+ continue;
4748
+ let startY = cellStartY, endY = cellEndY, startX = cellStartX, endX = cellEndX;
4749
+ if (type !== BORDER_TYPE.TOP && type !== BORDER_TYPE.BOTTOM && type !== BORDER_TYPE.LEFT && type !== BORDER_TYPE.RIGHT) {
4750
+ if (isMerged)
4751
+ return !0;
4752
+ isMergedMainCell && (startY = mergeInfo.startY, endY = mergeInfo.endY, startX = mergeInfo.startX, endX = mergeInfo.endX);
4753
+ }
4754
+ const lineWidth = getLineWidth(style);
4755
+ setLineType(ctx, style), ctx.setLineWidthByPrecision(lineWidth), ctx.strokeStyle = color || COLOR_BLACK_RGB, drawDiagonalLineByBorderType(ctx, type, {
4756
+ startX,
4757
+ startY,
4758
+ endX,
4759
+ endY
4760
+ }), !this._getOverflowExclusion(overflowCache, type, row, col) && drawLineByBorderType(ctx, type, (lineWidth - 1) / 2 / precisionScale, {
4761
+ startX,
4762
+ startY,
4763
+ endX,
4764
+ endY
4765
+ });
4766
+ }
4767
+ }
4688
4768
  _getOverflowExclusion(overflowCache, type, borderRow, borderColumn) {
4689
4769
  let isDraw = !1;
4690
4770
  return type === BORDER_TYPE.TOP || type === BORDER_TYPE.BOTTOM || overflowCache == null || overflowCache.forRow((row, rowArray) => {
@@ -4835,6 +4915,7 @@ const UNIQUE_KEY$7 = "DefaultCustomExtension", Z_INDEX$1 = 55, stringifyRange$1
4835
4915
  __name(_Custom, "Custom");
4836
4916
  let Custom = _Custom;
4837
4917
  SpreadsheetExtensionRegistry.add(Custom);
4918
+ const FONT_EXTENSION_Z_INDEX = 45, EXPAND_SIZE_FOR_RENDER_OVERFLOW = 20;
4838
4919
  var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
4839
4920
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4840
4921
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
@@ -23999,9 +24080,9 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
23999
24080
  const cache = {
24000
24081
  nearestNodeList: [],
24001
24082
  nearestNodeDistanceList: []
24002
- }, { pages, skeHeaders, skeFooters } = skeletonData, editArea = this.findEditAreaByCoord(coord, pageLayoutType, pageMarginLeft, pageMarginTop).editArea;
24083
+ }, { pages, skeHeaders, skeFooters } = skeletonData, editArea = this.findEditAreaByCoord(coord, pageLayoutType, pageMarginLeft, pageMarginTop).editArea, pageLength = pages.length;
24003
24084
  if (this._findLiquid.reset(), restrictions == null)
24004
- for (let pi = 0, len = pages.length; pi < len; pi++) {
24085
+ for (let pi = 0; pi < pageLength; pi++) {
24005
24086
  const page = pages[pi], { headerId, footerId, pageWidth } = page;
24006
24087
  let exactMatch = null;
24007
24088
  if (editArea === DocumentEditArea.HEADER || editArea === DocumentEditArea.FOOTER) {
@@ -24014,7 +24095,8 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24014
24095
  pi,
24015
24096
  cache,
24016
24097
  x,
24017
- y
24098
+ y,
24099
+ pageLength
24018
24100
  ));
24019
24101
  const footerSke = (_b = skeFooters.get(footerId)) == null ? void 0 : _b.get(pageWidth);
24020
24102
  footerSke && (exactMatch = exactMatch != null ? exactMatch : this._collectNearestNode(
@@ -24025,7 +24107,8 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24025
24107
  pi,
24026
24108
  cache,
24027
24109
  x,
24028
- y
24110
+ y,
24111
+ pageLength
24029
24112
  ));
24030
24113
  } else
24031
24114
  exactMatch = this._collectNearestNode(
@@ -24036,7 +24119,8 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24036
24119
  pi,
24037
24120
  cache,
24038
24121
  x,
24039
- y
24122
+ y,
24123
+ pageLength
24040
24124
  );
24041
24125
  if (exactMatch)
24042
24126
  return exactMatch;
@@ -24046,7 +24130,7 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24046
24130
  const { segmentId, segmentPage, strict } = restrictions;
24047
24131
  let exactMatch = null;
24048
24132
  if (strict === !1)
24049
- for (let pi = 0, len = pages.length; pi < len; pi++) {
24133
+ for (let pi = 0; pi < pageLength; pi++) {
24050
24134
  const page = pages[pi], { headerId, footerId, pageWidth } = page;
24051
24135
  if (segmentId !== "") {
24052
24136
  const headerSke = (_c = skeHeaders.get(headerId)) == null ? void 0 : _c.get(pageWidth);
@@ -24058,7 +24142,8 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24058
24142
  pi,
24059
24143
  cache,
24060
24144
  x,
24061
- y
24145
+ y,
24146
+ pageLength
24062
24147
  ));
24063
24148
  const footerSke = (_d = skeFooters.get(footerId)) == null ? void 0 : _d.get(pageWidth);
24064
24149
  footerSke && (exactMatch = exactMatch != null ? exactMatch : this._collectNearestNode(
@@ -24069,7 +24154,8 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24069
24154
  pi,
24070
24155
  cache,
24071
24156
  x,
24072
- y
24157
+ y,
24158
+ pageLength
24073
24159
  ));
24074
24160
  } else
24075
24161
  exactMatch = this._collectNearestNode(
@@ -24080,14 +24166,15 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24080
24166
  pi,
24081
24167
  cache,
24082
24168
  x,
24083
- y
24169
+ y,
24170
+ pageLength
24084
24171
  );
24085
24172
  if (exactMatch)
24086
24173
  return exactMatch;
24087
24174
  this._translatePage(page, pageLayoutType, pageMarginLeft, pageMarginTop);
24088
24175
  }
24089
24176
  else
24090
- for (let pi = 0, len = pages.length; pi < len; pi++) {
24177
+ for (let pi = 0; pi < pageLength; pi++) {
24091
24178
  const page = pages[pi];
24092
24179
  if (segmentId) {
24093
24180
  if (segmentPage !== pi) {
@@ -24103,7 +24190,8 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24103
24190
  segmentPage,
24104
24191
  cache,
24105
24192
  x,
24106
- y
24193
+ y,
24194
+ pageLength
24107
24195
  ));
24108
24196
  } else
24109
24197
  exactMatch = this._collectNearestNode(
@@ -24114,7 +24202,8 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24114
24202
  pi,
24115
24203
  cache,
24116
24204
  x,
24117
- y
24205
+ y,
24206
+ pageLength
24118
24207
  );
24119
24208
  if (exactMatch)
24120
24209
  return exactMatch;
@@ -24123,11 +24212,16 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24123
24212
  }
24124
24213
  return this._getNearestNode(cache.nearestNodeList, cache.nearestNodeDistanceList);
24125
24214
  }
24126
- _collectNearestNode(segmentPage, pageType, page, segmentId, pi, cache, x, y, nestLevel = 0) {
24215
+ _collectNearestNode(segmentPage, pageType, page, segmentId, pi, cache, x, y, pageLength, nestLevel = 0) {
24127
24216
  var _a10, _b, _c, _d, _e, _f, _g, _h, _i;
24128
24217
  const { sections, skeTables } = segmentPage;
24129
24218
  this._findLiquid.translateSave();
24130
- const pageLeft = this._findLiquid.x, pageRight = pageLeft + page.pageWidth, pageTop = this._findLiquid.y + (pageType === DocumentSkeletonPageType.FOOTER ? page.pageHeight - segmentPage.pageHeight : 0), pageBottom = pageTop + segmentPage.pageHeight, pointInPage = x >= pageLeft && x <= pageRight && y >= pageTop && y <= pageBottom;
24219
+ const pageLeft = this._findLiquid.x, pageRight = pageLeft + page.pageWidth, pageTop = this._findLiquid.y + (pageType === DocumentSkeletonPageType.FOOTER ? page.pageHeight - segmentPage.pageHeight : 0), pageBottom = pageTop + segmentPage.pageHeight;
24220
+ let pointInPage = x >= pageLeft && x <= pageRight && y >= pageTop && y <= pageBottom;
24221
+ if (nestLevel === 0 && pageType === DocumentSkeletonPageType.BODY) {
24222
+ const isFirstPage = pi === 0, isLastPage = pi === pageLength - 1, halfMarginTop = page.originMarginTop / 2;
24223
+ isFirstPage && isLastPage ? pointInPage = !0 : isFirstPage ? pointInPage = y <= pageBottom + halfMarginTop : isLastPage ? pointInPage = y >= pageTop - halfMarginTop : pointInPage = y >= pageTop - halfMarginTop && y <= pageBottom + halfMarginTop;
24224
+ }
24131
24225
  switch (pageType) {
24132
24226
  case DocumentSkeletonPageType.HEADER: {
24133
24227
  this._findLiquid.translatePagePadding({
@@ -24231,6 +24325,7 @@ const _DocumentSkeleton = class _DocumentSkeleton extends Skeleton {
24231
24325
  cache,
24232
24326
  x,
24233
24327
  y,
24328
+ pageLength,
24234
24329
  nestLevel + 1
24235
24330
  ), (_g = this._findLiquid) == null || _g.translateRestore();
24236
24331
  }
@@ -24570,7 +24665,7 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
24570
24665
  /**
24571
24666
  * Range of visible area(range in viewBounds)
24572
24667
  */
24573
- __publicField(this, "_rowColumnSegment", {
24668
+ __publicField(this, "_visibleRange", {
24574
24669
  startRow: -1,
24575
24670
  endRow: -1,
24576
24671
  startColumn: -1,
@@ -24617,7 +24712,10 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
24617
24712
  * Range of visible area(range in viewBounds)
24618
24713
  */
24619
24714
  get rowColumnSegment() {
24620
- return this._rowColumnSegment;
24715
+ return this._visibleRange;
24716
+ }
24717
+ get visibleArea() {
24718
+ return this._visibleRange;
24621
24719
  }
24622
24720
  // get dataMergeCache(): IRange[] {
24623
24721
  // return this._dataMergeCache;
@@ -24641,7 +24739,7 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
24641
24739
  return this.columnHeaderHeight + this._marginTop;
24642
24740
  }
24643
24741
  dispose() {
24644
- super.dispose(), this._rowHeightAccumulation = [], this._columnWidthAccumulation = [], this._rowTotalHeight = 0, this._columnTotalWidth = 0, this._rowHeaderWidth = 0, this._columnHeaderHeight = 0, this._rowColumnSegment = {
24742
+ super.dispose(), this._rowHeightAccumulation = [], this._columnWidthAccumulation = [], this._rowTotalHeight = 0, this._columnTotalWidth = 0, this._rowHeaderWidth = 0, this._columnHeaderHeight = 0, this._visibleRange = {
24645
24743
  startRow: -1,
24646
24744
  endRow: -1,
24647
24745
  startColumn: -1,
@@ -24699,7 +24797,7 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
24699
24797
  * @returns boolean
24700
24798
  */
24701
24799
  calculateSegment(bounds) {
24702
- return !this._worksheetData || (this._updateLayout(), !this._rowHeightAccumulation || !this._columnWidthAccumulation) ? !1 : (bounds != null && (this._rowColumnSegment = this.getRowColumnSegment(bounds)), !0);
24800
+ return !this._worksheetData || (this._updateLayout(), !this._rowHeightAccumulation || !this._columnWidthAccumulation) ? !1 : (bounds != null && (this._visibleRange = this.getRowColumnSegment(bounds)), !0);
24703
24801
  }
24704
24802
  calculateWithoutClearingCache(bounds) {
24705
24803
  if (this.calculateSegment(bounds))
@@ -25035,6 +25133,12 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25035
25133
  mergeInfo
25036
25134
  };
25037
25135
  }
25136
+ /**
25137
+ * New merge info, but position without header.
25138
+ * @param row
25139
+ * @param column
25140
+ * @returns {ISelectionCellWithMergeInfo} cellInfo with merge info
25141
+ */
25038
25142
  getCellByIndexWithNoHeader(row, column) {
25039
25143
  const { rowHeightAccumulation, columnWidthAccumulation } = this, primary = getCellByIndexWithMergeInfo(
25040
25144
  row,
@@ -25341,7 +25445,6 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25341
25445
  // return mergeRangeCache;
25342
25446
  // }
25343
25447
  /**
25344
- * @deprecated use _getCellMergeInfo instead.
25345
25448
  * get the current row and column segment visible merge data
25346
25449
  * @returns {IRange} The visible merge data
25347
25450
  */
@@ -25355,21 +25458,23 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25355
25458
  } : range = { startRow: 0, startColumn: 0, endRow: this.rowHeightAccumulation.length - 1, endColumn: endColumnLast }, this.worksheet.getSpanModel().getMergedCellRangeForSkeleton(range.startRow, range.startColumn, range.endRow, range.endColumn);
25356
25459
  }
25357
25460
  _calculateStylesCache() {
25358
- const rowColumnSegment = this._rowColumnSegment, columnWidthAccumulation = this.columnWidthAccumulation, { startRow, endRow, startColumn, endColumn } = rowColumnSegment;
25359
- if (!(endColumn === -1 || endRow === -1)) {
25360
- for (let r = startRow; r <= endRow; r++)
25361
- if (this.worksheet.getRowVisible(r) !== !1) {
25362
- for (let c = startColumn; c <= endColumn; c++)
25363
- this._setStylesCache(r, c, {
25364
- cacheItem: { bg: !0, border: !0 }
25365
- });
25366
- for (let c = 0; c < startColumn; c++)
25461
+ const rowColumnSegment = this._visibleRange, columnWidthAccumulation = this.columnWidthAccumulation, { startRow, endRow, startColumn, endColumn } = rowColumnSegment;
25462
+ if (endColumn === -1 || endRow === -1) return;
25463
+ const mergeRanges = this.getCurrentRowColumnSegmentMergeData(this._visibleRange);
25464
+ for (const mergeRange of mergeRanges)
25465
+ this._setStylesCache(mergeRange.startRow, mergeRange.startColumn, {
25466
+ mergeRange
25467
+ });
25468
+ for (let r = startRow; r <= endRow; r++)
25469
+ if (this.worksheet.getRowVisible(r) !== !1) {
25470
+ for (let c = startColumn; c <= endColumn; c++)
25471
+ this._setStylesCache(r, c, { cacheItem: { bg: !0, border: !0 } });
25472
+ for (let c = 0; c < startColumn; c++)
25473
+ this._setStylesCache(r, c, { cacheItem: { bg: !1, border: !1 } });
25474
+ if (endColumn !== 0)
25475
+ for (let c = endColumn + 1; c < columnWidthAccumulation.length; c++)
25367
25476
  this._setStylesCache(r, c, { cacheItem: { bg: !1, border: !1 } });
25368
- if (endColumn !== 0)
25369
- for (let c = endColumn + 1; c < columnWidthAccumulation.length; c++)
25370
- this._setStylesCache(r, c, { cacheItem: { bg: !1, border: !1 } });
25371
- }
25372
- }
25477
+ }
25373
25478
  }
25374
25479
  resetCache() {
25375
25480
  this._resetCache();
@@ -25442,7 +25547,7 @@ let SpreadsheetSkeleton = (_a6 = class extends Skeleton {
25442
25547
  return;
25443
25548
  options || (options = { cacheItem: { bg: !0, border: !0 } });
25444
25549
  const { isMerged, isMergedMainCell, startRow, startColumn, endRow, endColumn } = this._getCellMergeInfo(row, col);
25445
- if (options && (options.mergeRange = { startRow, startColumn, endRow, endColumn }), this.worksheet.getColVisible(col) === !1 || this.worksheet.getRowVisible(row) === !1) {
25550
+ if (options.mergeRange = { startRow, startColumn, endRow, endColumn }, this.worksheet.getColVisible(col) === !1 || this.worksheet.getRowVisible(row) === !1) {
25446
25551
  if (isMerged && !isMergedMainCell)
25447
25552
  return;
25448
25553
  if (!isMergedMainCell)
@@ -25658,95 +25763,119 @@ SpreadsheetSkeleton = __decorateClass$3([
25658
25763
  __decorateParam$3(4, Inject(LocaleService)),
25659
25764
  __decorateParam$3(5, IContextService)
25660
25765
  ], SpreadsheetSkeleton);
25661
- const UNIQUE_KEY$6 = "DefaultFontExtension", EXTENSION_Z_INDEX = 45, _Font = class _Font extends SheetExtension {
25766
+ const UNIQUE_KEY$6 = "DefaultFontExtension", _Font = class _Font extends SheetExtension {
25662
25767
  constructor() {
25663
25768
  super(...arguments);
25664
25769
  __publicField(this, "uKey", UNIQUE_KEY$6);
25665
- __publicField(this, "Z_INDEX", EXTENSION_Z_INDEX);
25770
+ __publicField(this, "Z_INDEX", FONT_EXTENSION_Z_INDEX);
25666
25771
  }
25667
25772
  getDocuments() {
25668
25773
  const parent = this.parent;
25669
25774
  return parent == null ? void 0 : parent.getDocuments();
25670
25775
  }
25671
25776
  draw(ctx, parentScale, spreadsheetSkeleton, diffRanges, moreBoundsInfo) {
25672
- const { stylesCache, overflowCache, worksheet } = spreadsheetSkeleton, { fontMatrix } = stylesCache;
25777
+ const { stylesCache, worksheet } = spreadsheetSkeleton, { fontMatrix } = stylesCache;
25673
25778
  if (!spreadsheetSkeleton || !worksheet || !fontMatrix) return;
25674
25779
  const { rowHeightAccumulation, columnTotalWidth, columnWidthAccumulation, rowTotalHeight } = spreadsheetSkeleton;
25675
25780
  if (!rowHeightAccumulation || !columnWidthAccumulation || columnTotalWidth === void 0 || rowTotalHeight === void 0 || !worksheet)
25676
25781
  return;
25782
+ const scale = this._getScale(parentScale), { viewRanges = [], checkOutOfViewBound } = moreBoundsInfo, renderFontContext = {
25783
+ ctx,
25784
+ scale,
25785
+ rowHeightAccumulation,
25786
+ columnTotalWidth,
25787
+ columnWidthAccumulation,
25788
+ rowTotalHeight,
25789
+ viewRanges,
25790
+ checkOutOfViewBound: checkOutOfViewBound || !0,
25791
+ diffRanges,
25792
+ spreadsheetSkeleton
25793
+ };
25677
25794
  ctx.save();
25678
- const scale = this._getScale(parentScale), { viewRanges = [], checkOutOfViewBound } = moreBoundsInfo, renderFontByCellMatrix = /* @__PURE__ */ __name((rowIndex, columnIndex, docsConfig) => {
25679
- var _a10, _b, _c, _d, _e;
25680
- if (!checkOutOfViewBound && !inViewRanges(viewRanges, rowIndex, columnIndex))
25681
- return !0;
25682
- const cellInfo = spreadsheetSkeleton.getCellByIndexWithNoHeader(
25683
- rowIndex,
25684
- columnIndex
25795
+ const uniqueMergeRanges = [], mergeRangeIDSet = /* @__PURE__ */ new Set();
25796
+ viewRanges.forEach((range) => {
25797
+ range.startColumn -= EXPAND_SIZE_FOR_RENDER_OVERFLOW, range.endColumn += EXPAND_SIZE_FOR_RENDER_OVERFLOW, range = clampRange(range), spreadsheetSkeleton.worksheet.getMergedCellRange(range.startRow, range.startColumn, range.endRow, range.endColumn).forEach((mergeRange) => {
25798
+ const mergeRangeIndex = spreadsheetSkeleton.worksheet.getSpanModel().getMergeDataIndex(mergeRange.startRow, mergeRange.startColumn);
25799
+ mergeRangeIDSet.has(mergeRangeIndex) || (mergeRangeIDSet.add(mergeRangeIndex), uniqueMergeRanges.push(mergeRange));
25800
+ }), Range.foreach(range, (row, col) => {
25801
+ if (spreadsheetSkeleton.worksheet.getSpanModel().getMergeDataIndex(row, col) !== -1)
25802
+ return;
25803
+ const cellInfo = spreadsheetSkeleton.getCellByIndexWithNoHeader(row, col);
25804
+ cellInfo && (renderFontContext.cellInfo = cellInfo, this.renderFontEachCell(renderFontContext, row, col, fontMatrix));
25805
+ });
25806
+ }), uniqueMergeRanges.forEach((range) => {
25807
+ const cellInfo = spreadsheetSkeleton.getCellByIndexWithNoHeader(range.startRow, range.startColumn);
25808
+ renderFontContext.cellInfo = cellInfo, this.renderFontEachCell(renderFontContext, range.startRow, range.startColumn, fontMatrix);
25809
+ }), ctx.restore();
25810
+ }
25811
+ renderFontEachCell(renderFontContext, row, col, fontMatrix) {
25812
+ var _a10;
25813
+ const { ctx, viewRanges, diffRanges, spreadsheetSkeleton, cellInfo } = renderFontContext;
25814
+ let { startY, endY, startX, endX } = cellInfo;
25815
+ const { isMerged, isMergedMainCell, mergeInfo } = cellInfo;
25816
+ if (isMerged && !isMergedMainCell)
25817
+ return !0;
25818
+ isMergedMainCell && (startY = mergeInfo.startY, endY = mergeInfo.endY, startX = mergeInfo.startX, endX = mergeInfo.endX);
25819
+ const fontsConfig = fontMatrix.getValue(row, col);
25820
+ if (!fontsConfig) return !0;
25821
+ const overflowRange = spreadsheetSkeleton.overflowCache.getValue(row, col), renderRange = diffRanges && diffRanges.length > 0 ? diffRanges : viewRanges;
25822
+ if (!overflowRange && (!isMergedMainCell && !isMerged) && !inViewRanges(renderRange, row, col))
25823
+ return !0;
25824
+ const visibleRow = spreadsheetSkeleton.worksheet.getRowVisible(row), visibleCol = spreadsheetSkeleton.worksheet.getColVisible(col);
25825
+ if (!visibleRow || !visibleCol) return !0;
25826
+ const cellData = spreadsheetSkeleton.worksheet.getCell(row, col) || {};
25827
+ if ((_a10 = cellData.fontRenderExtension) != null && _a10.isSkip)
25828
+ return !0;
25829
+ ctx.save(), ctx.beginPath(), renderFontContext.overflowRectangle = overflowRange, renderFontContext.cellData = cellData, renderFontContext.startX = startX, renderFontContext.startY = startY, renderFontContext.endX = endX, renderFontContext.endY = endY, this._clipTextOverflow(renderFontContext, row, col, fontMatrix), ctx.translate(startX + FIX_ONE_PIXEL_BLUR_OFFSET, startY + FIX_ONE_PIXEL_BLUR_OFFSET), this._renderDocuments(ctx, fontsConfig, startX, startY, endX, endY, row, col, spreadsheetSkeleton.overflowCache), ctx.closePath(), ctx.restore();
25830
+ }
25831
+ _clipTextOverflow(renderFontContext, row, col, fontMatrix) {
25832
+ var _a10, _b, _c, _d;
25833
+ const { ctx, scale, overflowRectangle, rowHeightAccumulation, columnWidthAccumulation, cellData } = renderFontContext;
25834
+ let { startX, endX, startY, endY } = renderFontContext;
25835
+ const fontsConfig = fontMatrix.getValue(row, col), { horizontalAlign, vertexAngle = 0, centerAngle = 0 } = fontsConfig;
25836
+ let horizontalAlignOverFlow = horizontalAlign;
25837
+ horizontalAlign === HorizontalAlign.UNSPECIFIED && (centerAngle === VERTICAL_ROTATE_ANGLE && vertexAngle === VERTICAL_ROTATE_ANGLE ? horizontalAlignOverFlow = HorizontalAlign.CENTER : (vertexAngle > 0 && vertexAngle !== VERTICAL_ROTATE_ANGLE || vertexAngle === -VERTICAL_ROTATE_ANGLE) && (horizontalAlignOverFlow = HorizontalAlign.RIGHT));
25838
+ const rightOffset = (_b = (_a10 = cellData.fontRenderExtension) == null ? void 0 : _a10.rightOffset) != null ? _b : 0, leftOffset = (_d = (_c = cellData.fontRenderExtension) == null ? void 0 : _c.leftOffset) != null ? _d : 0;
25839
+ let isOverflow = !0;
25840
+ vertexAngle === 0 && (startX = startX + leftOffset, endX = endX - rightOffset, (rightOffset !== 0 || leftOffset !== 0) && (isOverflow = !1));
25841
+ const cellWidth = endX - startX, cellHeight = endY - startY;
25842
+ if (overflowRectangle && isOverflow) {
25843
+ const { startColumn, startRow, endColumn, endRow } = overflowRectangle;
25844
+ startColumn === endColumn && startColumn === col ? (ctx.rectByPrecision(
25845
+ startX + 1 / scale,
25846
+ startY + 1 / scale,
25847
+ cellWidth - 2 / scale,
25848
+ cellHeight - 2 / scale
25849
+ ), ctx.clip()) : horizontalAlignOverFlow === HorizontalAlign.CENTER ? this._clipRectangleForOverflow(
25850
+ ctx,
25851
+ startRow,
25852
+ endRow,
25853
+ startColumn,
25854
+ endColumn,
25855
+ scale,
25856
+ rowHeightAccumulation,
25857
+ columnWidthAccumulation
25858
+ ) : horizontalAlignOverFlow === HorizontalAlign.RIGHT ? this._clipRectangleForOverflow(
25859
+ ctx,
25860
+ startRow,
25861
+ row,
25862
+ startColumn,
25863
+ col,
25864
+ scale,
25865
+ rowHeightAccumulation,
25866
+ columnWidthAccumulation
25867
+ ) : this._clipRectangleForOverflow(
25868
+ ctx,
25869
+ row,
25870
+ endRow,
25871
+ col,
25872
+ endColumn,
25873
+ scale,
25874
+ rowHeightAccumulation,
25875
+ columnWidthAccumulation
25685
25876
  );
25686
- let { startY, endY, startX, endX } = cellInfo;
25687
- const { isMerged, isMergedMainCell, mergeInfo } = cellInfo;
25688
- if (isMerged)
25689
- return !0;
25690
- {
25691
- const visibleRow = spreadsheetSkeleton.worksheet.getRowVisible(rowIndex), visibleCol = spreadsheetSkeleton.worksheet.getColVisible(columnIndex);
25692
- if (!visibleRow || !visibleCol) return !0;
25693
- }
25694
- const mergeTo = diffRanges && diffRanges.length > 0 ? diffRanges : viewRanges, combineWithMergeRanges = expandRangeIfIntersects([...mergeTo], [mergeInfo]);
25695
- if (!inRowViewRanges(combineWithMergeRanges, rowIndex) || (isMergedMainCell && (startY = mergeInfo.startY, endY = mergeInfo.endY, startX = mergeInfo.startX, endX = mergeInfo.endX), diffRanges && !this.isRowInRanges(mergeInfo.startRow, mergeInfo.endRow, diffRanges)))
25696
- return !0;
25697
- const overflowRectangle = overflowCache.getValue(rowIndex, columnIndex), { horizontalAlign, vertexAngle = 0, centerAngle = 0 } = docsConfig;
25698
- if (!overflowRectangle && !inViewRanges(combineWithMergeRanges, rowIndex, columnIndex))
25699
- return !0;
25700
- let horizontalAlignOverFlow = horizontalAlign;
25701
- horizontalAlign === HorizontalAlign.UNSPECIFIED && (centerAngle === VERTICAL_ROTATE_ANGLE && vertexAngle === VERTICAL_ROTATE_ANGLE ? horizontalAlignOverFlow = HorizontalAlign.CENTER : (vertexAngle > 0 && vertexAngle !== VERTICAL_ROTATE_ANGLE || vertexAngle === -VERTICAL_ROTATE_ANGLE) && (horizontalAlignOverFlow = HorizontalAlign.RIGHT));
25702
- const cellData = worksheet.getCell(rowIndex, columnIndex) || {};
25703
- if ((_a10 = cellData.fontRenderExtension) != null && _a10.isSkip)
25704
- return !0;
25705
- ctx.save(), ctx.beginPath();
25706
- const rightOffset = (_c = (_b = cellData.fontRenderExtension) == null ? void 0 : _b.rightOffset) != null ? _c : 0, leftOffset = (_e = (_d = cellData.fontRenderExtension) == null ? void 0 : _d.leftOffset) != null ? _e : 0;
25707
- let isOverflow = !0;
25708
- vertexAngle === 0 && (startX = startX + leftOffset, endX = endX - rightOffset, (rightOffset !== 0 || leftOffset !== 0) && (isOverflow = !1));
25709
- const cellWidth = endX - startX, cellHeight = endY - startY;
25710
- if (overflowRectangle && isOverflow) {
25711
- const { startColumn, startRow, endColumn, endRow } = overflowRectangle;
25712
- startColumn === endColumn && startColumn === columnIndex ? (ctx.rectByPrecision(
25713
- startX + 1 / scale,
25714
- startY + 1 / scale,
25715
- cellWidth - 2 / scale,
25716
- cellHeight - 2 / scale
25717
- ), ctx.clip()) : horizontalAlignOverFlow === HorizontalAlign.CENTER ? this._clipRectangleForOverflow(
25718
- ctx,
25719
- startRow,
25720
- endRow,
25721
- startColumn,
25722
- endColumn,
25723
- scale,
25724
- rowHeightAccumulation,
25725
- columnWidthAccumulation
25726
- ) : horizontalAlignOverFlow === HorizontalAlign.RIGHT ? this._clipRectangleForOverflow(
25727
- ctx,
25728
- startRow,
25729
- rowIndex,
25730
- startColumn,
25731
- columnIndex,
25732
- scale,
25733
- rowHeightAccumulation,
25734
- columnWidthAccumulation
25735
- ) : this._clipRectangleForOverflow(
25736
- ctx,
25737
- rowIndex,
25738
- endRow,
25739
- columnIndex,
25740
- endColumn,
25741
- scale,
25742
- rowHeightAccumulation,
25743
- columnWidthAccumulation
25744
- );
25745
- } else
25746
- ctx.rectByPrecision(startX + 1 / scale, startY + 1 / scale, cellWidth - 2 / scale, cellHeight - 2 / scale), ctx.clip();
25747
- ctx.translate(startX + FIX_ONE_PIXEL_BLUR_OFFSET, startY + FIX_ONE_PIXEL_BLUR_OFFSET), this._renderDocuments(ctx, docsConfig, startX, startY, endX, endY, rowIndex, columnIndex, overflowCache), ctx.closePath(), ctx.restore();
25748
- }, "renderFontByCellMatrix");
25749
- fontMatrix.forValue(renderFontByCellMatrix), ctx.restore();
25877
+ } else
25878
+ ctx.rectByPrecision(startX + 1 / scale, startY + 1 / scale, cellWidth - 2 / scale, cellHeight - 2 / scale), ctx.clip();
25750
25879
  }
25751
25880
  _renderDocuments(ctx, docsConfig, startX, startY, endX, endY, row, column, overflowCache) {
25752
25881
  const documents = this.getDocuments();
@@ -26046,8 +26175,8 @@ const UNIQUE_KEY$3 = "DefaultDocsBackgroundExtension", DOC_EXTENSION_Z_INDEX$2 =
26046
26175
  const { contentHeight = 0 } = line2, { ts: textStyle, width, content } = span;
26047
26176
  if ((textStyle == null ? void 0 : textStyle.bg) == null)
26048
26177
  return;
26049
- const { bg } = textStyle, background = getColorStyle(bg), { spanStartPoint = Vector2.create(0, 0) } = this.extensionOffset, DELTA = 1.5;
26050
- background && content !== "\r" && (ctx.fillStyle = background, ctx.fillRectByPrecision(spanStartPoint.x - 0.5, spanStartPoint.y - 1, width + 1, contentHeight + 2 * DELTA));
26178
+ const { bg } = textStyle, background = getColorStyle(bg), { spanStartPoint = Vector2.create(0, 0) } = this.extensionOffset, DELTA = 1;
26179
+ background && content !== "\r" && (ctx.fillStyle = background, ctx.fillRectByPrecision(spanStartPoint.x - 0.5, spanStartPoint.y + 1, width + 1, contentHeight + 2 * DELTA));
26051
26180
  }
26052
26181
  clearCache() {
26053
26182
  this._preBackgroundColor = "";
@@ -28441,7 +28570,8 @@ const OBJECT_KEY = "__SHEET_EXTENSION_FONT_DOCUMENT_INSTANCE__", _Spreadsheet =
28441
28570
  extension.draw(ctx, parentScale, spreadsheetSkeleton, diffRanges, {
28442
28571
  viewRanges,
28443
28572
  checkOutOfViewBound: !0,
28444
- viewportKey: viewportInfo.viewportKey
28573
+ viewportKey: viewportInfo.viewportKey,
28574
+ viewBound: viewportInfo.cacheBound
28445
28575
  }), this.addRenderFrameTimeMetricToScene(timeKey, Tools.now() - st, scene);
28446
28576
  }
28447
28577
  }
@@ -29091,6 +29221,10 @@ const _CustomObject = class _CustomObject extends BaseObject {
29091
29221
  __name(_CustomObject, "CustomObject");
29092
29222
  let CustomObject = _CustomObject;
29093
29223
  const min = Math.min, max = Math.max, floor = Math.floor;
29224
+ function hasWindow() {
29225
+ return typeof window < "u";
29226
+ }
29227
+ __name(hasWindow, "hasWindow");
29094
29228
  function getNodeName(node) {
29095
29229
  return isNode(node) ? (node.nodeName || "").toLowerCase() : "#document";
29096
29230
  }
@@ -29106,15 +29240,15 @@ function getDocumentElement(node) {
29106
29240
  }
29107
29241
  __name(getDocumentElement, "getDocumentElement");
29108
29242
  function isNode(value) {
29109
- return value instanceof Node || value instanceof getWindow(value).Node;
29243
+ return hasWindow() ? value instanceof Node || value instanceof getWindow(value).Node : !1;
29110
29244
  }
29111
29245
  __name(isNode, "isNode");
29112
29246
  function isHTMLElement(value) {
29113
- return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
29247
+ return hasWindow() ? value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement : !1;
29114
29248
  }
29115
29249
  __name(isHTMLElement, "isHTMLElement");
29116
29250
  function isShadowRoot(value) {
29117
- return typeof ShadowRoot > "u" ? !1 : value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
29251
+ return !hasWindow() || typeof ShadowRoot > "u" ? !1 : value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
29118
29252
  }
29119
29253
  __name(isShadowRoot, "isShadowRoot");
29120
29254
  function isOverflowElement(element) {
@@ -31407,6 +31541,8 @@ const _Scene = class _Scene extends ThinScene {
31407
31541
  __publicField(this, "addObject$", this._addObject$.asObservable());
31408
31542
  __publicField(this, "_beforeRender$", new BehaviorSubject(null));
31409
31543
  __publicField(this, "beforeRender$", this._beforeRender$.asObservable());
31544
+ __publicField(this, "_afterRender$", new BehaviorSubject(null));
31545
+ __publicField(this, "afterRender$", this._afterRender$.asObservable());
31410
31546
  /**
31411
31547
  * Transformer constructor. Transformer is a special type of group that allow you transform
31412
31548
  * primitives and shapes. Transforming tool is not changing `width` and `height` properties of nodes
@@ -31764,10 +31900,11 @@ const _Scene = class _Scene extends ThinScene {
31764
31900
  if (!this.isDirty())
31765
31901
  return;
31766
31902
  !parentCtx && ((_a10 = this.getEngine()) == null || _a10.clearCanvas());
31767
- const layers = this._layers.sort(sortRules);
31768
- this._beforeRender$.next((_b = this.getEngine()) == null ? void 0 : _b.getCanvas());
31903
+ const layers = this._layers.sort(sortRules), canvasInstance = (_b = this.getEngine()) == null ? void 0 : _b.getCanvas();
31904
+ this._beforeRender$.next(canvasInstance);
31769
31905
  for (let i = 0, len = layers.length; i < len; i++)
31770
31906
  layers[i].render(parentCtx, i === len - 1);
31907
+ this._afterRender$.next(canvasInstance);
31771
31908
  }
31772
31909
  async requestRender(parentCtx) {
31773
31910
  return new Promise((resolve, _reject) => {
@@ -32796,7 +32933,7 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32796
32933
  return this._makeDefaultViewport();
32797
32934
  const sceneTrans = this._scene.transform.clone();
32798
32935
  let width = this._width, height = this._height;
32799
- const size = this._getViewPortSize();
32936
+ const size = this._calcViewPortSize();
32800
32937
  width = size.width, height = size.height;
32801
32938
  const xFrom = this.left, xTo = (width || 0) + this.left, yFrom = this.top, yTo = (height || 0) + this.top, topLeft = this.transformVector2SceneCoord(Vector2.FromArray([xFrom, yFrom])), bottomRight = this.transformVector2SceneCoord(Vector2.FromArray([xTo, yTo])), viewBound = {
32802
32939
  left: topLeft.x,
@@ -32893,7 +33030,7 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32893
33030
  isHit(coord) {
32894
33031
  if (this.isActive === !1)
32895
33032
  return;
32896
- const { width, height } = this._getViewPortSize();
33033
+ const { width, height } = this._calcViewPortSize();
32897
33034
  return coord.x >= this.left && coord.x <= this.left + (width || 0) && coord.y >= this.top && coord.y <= this.top + (height || 0);
32898
33035
  }
32899
33036
  pickScrollBar(coord) {
@@ -32922,7 +33059,7 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32922
33059
  isLimitedY: !1
32923
33060
  };
32924
33061
  scrollX = scrollX != null ? scrollX : this.scrollX, scrollY = scrollY != null ? scrollY : this.scrollY;
32925
- const { height, width } = this._getViewPortSize();
33062
+ const { height, width } = this._calcViewPortSize();
32926
33063
  this._sceneWCurrVpAfterScale <= width && (scrollX = 0), this._sceneHCurrVpAfterScale <= height && (scrollY = 0);
32927
33064
  const limitX = (_a10 = this._scrollBar) == null ? void 0 : _a10.limitX, limitY = (_b = this._scrollBar) == null ? void 0 : _b.limitY;
32928
33065
  let isLimitedX = !1, isLimitedY = !1;
@@ -32940,7 +33077,7 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32940
33077
  * @returns
32941
33078
  */
32942
33079
  _limitViewportScroll(viewportScrollX, viewportScrollY) {
32943
- const { width, height } = this._getViewPortSize(), freezeHeight = this._paddingEndY - this._paddingStartY, freezeWidth = this._paddingEndX - this._paddingStartX, scaleY = this.scene.scaleY, scaleX = this.scene.scaleX, maxViewportScrollX = this._sceneWidthAfterScale - freezeWidth * scaleX - width, maxViewportScrollY = this._sceneHeightAfterScale - freezeHeight * scaleY - height;
33080
+ const { width, height } = this._calcViewPortSize(), freezeHeight = this._paddingEndY - this._paddingStartY, freezeWidth = this._paddingEndX - this._paddingStartX, scaleY = this.scene.scaleY, scaleX = this.scene.scaleX, maxViewportScrollX = this._sceneWidthAfterScale - freezeWidth * scaleX - width, maxViewportScrollY = this._sceneHeightAfterScale - freezeHeight * scaleY - height;
32944
33081
  return {
32945
33082
  viewportScrollX: Tools.clamp(viewportScrollX, this._paddingStartX, maxViewportScrollX / scaleX),
32946
33083
  viewportScrollY: Tools.clamp(viewportScrollY, this._paddingStartY, maxViewportScrollY / scaleY),
@@ -32968,7 +33105,7 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32968
33105
  */
32969
33106
  _resizeCacheCanvas() {
32970
33107
  var _a10;
32971
- const { width, height } = this._getViewPortSize();
33108
+ const { width, height } = this._calcViewPortSize();
32972
33109
  this.width = width, this.height = height;
32973
33110
  const scaleX = this.scene.scaleX, scaleY = this.scene.scaleY, canvasW = width !== 0 ? width + this.bufferEdgeX * 2 * scaleX : 0, canvasH = height !== 0 ? height + this.bufferEdgeY * 2 * scaleY : 0;
32974
33111
  (_a10 = this._cacheCanvas) == null || _a10.setSize(canvasW, canvasH), this.cacheBound = this._viewBound, this.preCacheBound = null, this.markForceDirty(!0);
@@ -32978,7 +33115,7 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32978
33115
  */
32979
33116
  _updateScrollByViewportScrollValue() {
32980
33117
  if (!this.width || this.width < 0 || !this.height || this.height < 0) return;
32981
- const { width, height } = this._getViewPortSize(), sceneWidthCurrVpAfterScale = (this._scene.width - this._paddingEndX) * this._scene.scaleX, sceneHeightCurrVpAfterScale = (this._scene.height - this._paddingEndY) * this._scene.scaleY;
33118
+ const { width, height } = this._calcViewPortSize(), sceneWidthCurrVpAfterScale = (this._scene.width - this._paddingEndX) * this._scene.scaleX, sceneHeightCurrVpAfterScale = (this._scene.height - this._paddingEndY) * this._scene.scaleY;
32982
33119
  if (this._sceneWCurrVpAfterScale = sceneWidthCurrVpAfterScale, this._sceneHCurrVpAfterScale = sceneHeightCurrVpAfterScale, this._sceneWidthAfterScale = this._scene.width * this._scene.scaleX, this._sceneHeightAfterScale = this._scene.height * this._scene.scaleY, this._scrollBar) {
32983
33120
  this._scrollBar.resize(width, height, sceneWidthCurrVpAfterScale, sceneHeightCurrVpAfterScale);
32984
33121
  const viewportScrollX = this.viewportScrollX, viewportScrollY = this.viewportScrollY;
@@ -32989,11 +33126,11 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
32989
33126
  }
32990
33127
  this.markForceDirty(!0);
32991
33128
  }
32992
- _getViewPortSize() {
33129
+ _calcViewPortSize() {
32993
33130
  const parent = this._scene.getParent(), { width: parentWidth, height: parentHeight } = parent, { scaleX = 1, scaleY = 1 } = this._scene;
32994
33131
  let width, height;
32995
33132
  const left = this._leftOrigin * scaleX, top = this._topOrigin * scaleY;
32996
- return this._left = left, this._top = top, this._explicitViewportWidthSet ? width = (this._widthOrigin || 0) * scaleX : width = parentWidth - (this._left + this._right), this._explicitViewportHeightSet ? height = (this._heightOrigin || 0) * scaleY : height = parentHeight - (this._top + this._bottom), {
33133
+ return this._left = left, this._top = top, Tools.isDefine(this._widthOrigin) || this._explicitViewportWidthSet ? width = (this._widthOrigin || 0) * scaleX : width = parentWidth - (this._left + this._right), Tools.isDefine(this._heightOrigin) || this._explicitViewportHeightSet ? height = (this._heightOrigin || 0) * scaleY : height = parentHeight - (this._top + this._bottom), {
32997
33134
  width,
32998
33135
  height,
32999
33136
  parentHeight
@@ -33170,7 +33307,7 @@ const MOUSE_WHEEL_SPEED_SMOOTHING_FACTOR = 3, _Viewport = class _Viewport {
33170
33307
  parent.classType === RENDER_CLASS_TYPE.SCENE_VIEWER ? this._scrollBar.render(ctx) : parent.classType === RENDER_CLASS_TYPE.ENGINE && this._scrollBar.render(ctx);
33171
33308
  }
33172
33309
  _setViewportSize(props) {
33173
- Tools.isDefine(props == null ? void 0 : props.top) && (this.top = props.top), Tools.isDefine(props == null ? void 0 : props.left) && (this.left = props.left), Tools.isDefine(props == null ? void 0 : props.bottom) && (this.bottom = props.bottom), Tools.isDefine(props == null ? void 0 : props.right) && (this.right = props.right), Tools.isDefine(props == null ? void 0 : props.width) && this._explicitViewportWidthSet ? (this.width = props == null ? void 0 : props.width, this._widthOrigin = this.width) : (this.width = null, this._widthOrigin = null), Tools.isDefine(props == null ? void 0 : props.height) && this._explicitViewportHeightSet ? (this.height = props == null ? void 0 : props.height, this._heightOrigin = this.height) : (this.height = null, this._heightOrigin = null);
33310
+ Tools.isDefine(props == null ? void 0 : props.top) && (this.top = props.top), Tools.isDefine(props == null ? void 0 : props.left) && (this.left = props.left), Tools.isDefine(props == null ? void 0 : props.bottom) && (this.bottom = props.bottom), Tools.isDefine(props == null ? void 0 : props.right) && (this.right = props.right), Tools.isDefine(props == null ? void 0 : props.width) ? (this.width = props == null ? void 0 : props.width, this._widthOrigin = props == null ? void 0 : props.width) : (this.width = null, this._widthOrigin = null), Tools.isDefine(props == null ? void 0 : props.height) ? (this.height = props == null ? void 0 : props.height, this._heightOrigin = props == null ? void 0 : props.height) : (this.height = null, this._heightOrigin = null);
33174
33311
  }
33175
33312
  /**
33176
33313
  * main canvas element resize
@@ -33314,7 +33451,7 @@ export {
33314
33451
  calculateRectRotate,
33315
33452
  cancelRequestFrame,
33316
33453
  checkStyle,
33317
- clampRanges,
33454
+ clampRange,
33318
33455
  clearLineByBorderType,
33319
33456
  convertTextRotation,
33320
33457
  createCanvasElement,