@univerjs/engine-render 1.0.0-beta.1 → 1.0.0-beta.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.
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AlignTypeH, AlignTypeV, BaselineOffset, BooleanNumber, BorderStyleTypes, BulletAlignment, COLORS, CellValueType, ColorKit, ColumnResponsiveType, ColumnSeparatorType, CustomDecorationType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, Disposable, DisposableCollection, DocumentBlockRangeType, DocumentDataModel, DocumentFlavor, DocxBreakType, EventSubject, FontStyleType, GridType, HorizontalAlign, IConfigService, IContextService, IUniverInstanceService, Inject, Injector, ListGlyphType, LocaleService, LookUp, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MOVE_BUFFER_VALUE, ModernDocumentWidthMode, NAMED_STYLE_MAP, NAMED_STYLE_SPACE_MAP, NumberUnitType, ObjectMatrix, ObjectRelativeFromH, ObjectRelativeFromV, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, Range, Rectangle, Registry, SectionType, SheetSkeleton, Skeleton, SpacingRule, TabStopAlignment, TableAlignmentType, TableRowHeightRule, TableTextWrapType, TextDecoration, ThemeService, Tools, UniverInstanceType, VerticalAlign, VerticalAlignmentType, WrapStrategy, WrapTextType, checkParagraphHasIndentByStyle, createIdentifier, deleteContent, getColorStyle, getDisplayValueFromCell, horizontalLineSegmentsSubtraction, insertTextToContent, invertColorByMatrix, isCellCoverable, isClassDependencyItem, isDefaultFormat, isNullCell, isWhiteColor, merge, noop, numberToABC, numberToListABC, numfmt, regexp, registerDependencies, remove, requestImmediateMacroTask, resolveDocumentParagraphStyle, resolveSectionHeaderFooterReferences, searchArray, sortRules, sortRulesByDesc, toDisposable } from "@univerjs/core";
2
- import { BehaviorSubject, Observable, Subject, Subscription, distinctUntilChanged, shareReplay, startWith } from "rxjs";
2
+ import { BehaviorSubject, Observable, Subject, Subscription, distinctUntilChanged, merge as merge$1, shareReplay, startWith } from "rxjs";
3
3
  import { franc } from "franc-min";
4
4
  import { getOverflowAncestors } from "@floating-ui/dom";
5
5
  import { floor, max, min } from "@floating-ui/utils";
@@ -3221,6 +3221,36 @@ var Transform = class Transform {
3221
3221
  }
3222
3222
  };
3223
3223
 
3224
+ //#endregion
3225
+ //#region src/basics/transformer-config.ts
3226
+ const DEFAULT_TRANSFORMER_CONFIG = {
3227
+ resizeEnabled: true,
3228
+ rotateEnabled: true,
3229
+ rotateAnchorOffset: 28,
3230
+ rotateAnchorPosition: "bottom",
3231
+ rotateLineEnabled: false,
3232
+ rotateSize: 18,
3233
+ rotateCornerRadius: 9,
3234
+ rotateFill: "#ffffff",
3235
+ rotateStroke: "#4086f4",
3236
+ rotateStrokeWidth: 1,
3237
+ rotateIconEnabled: true,
3238
+ rotateIconStroke: "#4086f4",
3239
+ rotateIconStrokeWidth: 1.25,
3240
+ borderEnabled: true,
3241
+ borderStroke: "#4086f4",
3242
+ borderStrokeWidth: 1,
3243
+ borderSpacing: 2,
3244
+ anchorFill: "#ffffff",
3245
+ anchorStroke: "#4086f4",
3246
+ anchorStrokeWidth: 1.5,
3247
+ anchorSize: 8,
3248
+ anchorCornerRadius: 2,
3249
+ anchorStyle: "canva",
3250
+ keepRatio: true,
3251
+ moveBoundaryEnabled: true
3252
+ };
3253
+
3224
3254
  //#endregion
3225
3255
  //#region src/basics/zoom.ts
3226
3256
  const MIN_ZOOM_RATIO = .1;
@@ -4143,6 +4173,8 @@ var UniverRenderingContext2D = class {
4143
4173
  constructor(context, options) {
4144
4174
  _defineProperty(this, "__mode", "rendering");
4145
4175
  _defineProperty(this, "_transformCache", void 0);
4176
+ _defineProperty(this, "_bitmapMutationId", 0);
4177
+ _defineProperty(this, "_bitmapMutationTrackingDepth", 0);
4146
4178
  _defineProperty(this, "canvas", void 0);
4147
4179
  _defineProperty(this, "_context", void 0);
4148
4180
  _defineProperty(this, "_systemType", void 0);
@@ -4161,6 +4193,19 @@ var UniverRenderingContext2D = class {
4161
4193
  setId(id) {
4162
4194
  this._id = id;
4163
4195
  }
4196
+ detectBitmapMutation(callback) {
4197
+ const mutationId = this._bitmapMutationId;
4198
+ this._bitmapMutationTrackingDepth++;
4199
+ try {
4200
+ callback();
4201
+ } finally {
4202
+ this._bitmapMutationTrackingDepth--;
4203
+ }
4204
+ return mutationId !== this._bitmapMutationId;
4205
+ }
4206
+ _markBitmapMutation() {
4207
+ if (this._bitmapMutationTrackingDepth > 0) this._bitmapMutationId++;
4208
+ }
4164
4209
  isContextLost() {
4165
4210
  return this._context.isContextLost();
4166
4211
  }
@@ -4390,7 +4435,9 @@ var UniverRenderingContext2D = class {
4390
4435
  this._context.resetTransform();
4391
4436
  }
4392
4437
  drawFocusIfNeeded(...args) {
4393
- return this._context.drawFocusIfNeeded(...args);
4438
+ const result = this._context.drawFocusIfNeeded(...args);
4439
+ this._markBitmapMutation();
4440
+ return result;
4394
4441
  }
4395
4442
  /**
4396
4443
  * reset canvas context transform
@@ -4399,6 +4446,7 @@ var UniverRenderingContext2D = class {
4399
4446
  reset() {
4400
4447
  this._transformCache = null;
4401
4448
  this._context.reset();
4449
+ this._markBitmapMutation();
4402
4450
  }
4403
4451
  /**
4404
4452
  * arc function.
@@ -4472,6 +4520,7 @@ var UniverRenderingContext2D = class {
4472
4520
  */
4473
4521
  clearRect(x, y, width, height) {
4474
4522
  this._context.clearRect(x, y, width, height);
4523
+ this._markBitmapMutation();
4475
4524
  }
4476
4525
  /**
4477
4526
  * clearRect function.
@@ -4545,6 +4594,7 @@ var UniverRenderingContext2D = class {
4545
4594
  if (a.length === 3) _context.drawImage(args[0], args[1], args[2]);
4546
4595
  else if (a.length === 5) _context.drawImage(args[0], args[1], args[2], args[3], args[4]);
4547
4596
  else if (a.length === 9) _context.drawImage(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
4597
+ this._markBitmapMutation();
4548
4598
  }
4549
4599
  /**
4550
4600
  * ellipse function.
@@ -4558,6 +4608,7 @@ var UniverRenderingContext2D = class {
4558
4608
  }
4559
4609
  fill(...args) {
4560
4610
  this._context.fill(...args);
4611
+ this._markBitmapMutation();
4561
4612
  }
4562
4613
  /**
4563
4614
  * fillRect function.
@@ -4565,6 +4616,7 @@ var UniverRenderingContext2D = class {
4565
4616
  */
4566
4617
  fillRect(x, y, width, height) {
4567
4618
  this._context.fillRect(x, y, width, height);
4619
+ this._markBitmapMutation();
4568
4620
  }
4569
4621
  /**
4570
4622
  * fillRect function precision.
@@ -4584,6 +4636,7 @@ var UniverRenderingContext2D = class {
4584
4636
  */
4585
4637
  strokeRect(x, y, width, height) {
4586
4638
  this._context.strokeRect(x, y, width, height);
4639
+ this._markBitmapMutation();
4587
4640
  }
4588
4641
  /**
4589
4642
  * strokeRect function precision.
@@ -4604,6 +4657,7 @@ var UniverRenderingContext2D = class {
4604
4657
  fillText(text, x, y, maxWidth) {
4605
4658
  if (maxWidth) this._context.fillText(text, x, y, maxWidth);
4606
4659
  else this._context.fillText(text, x, y);
4660
+ this._markBitmapMutation();
4607
4661
  }
4608
4662
  /**
4609
4663
  * fillText function.
@@ -4617,6 +4671,7 @@ var UniverRenderingContext2D = class {
4617
4671
  maxWidth = fixLineWidthByScale(maxWidth, scaleX);
4618
4672
  this._context.fillText(text, x, y, maxWidth);
4619
4673
  } else this._context.fillText(text, x, y);
4674
+ this._markBitmapMutation();
4620
4675
  }
4621
4676
  /**
4622
4677
  * measureText function.
@@ -4697,6 +4752,7 @@ var UniverRenderingContext2D = class {
4697
4752
  */
4698
4753
  putImageData(imageData, dx, dy) {
4699
4754
  this._context.putImageData(imageData, dx, dy);
4755
+ this._markBitmapMutation();
4700
4756
  }
4701
4757
  /**
4702
4758
  * quadraticCurveTo function.
@@ -4765,6 +4821,7 @@ var UniverRenderingContext2D = class {
4765
4821
  stroke(path2d) {
4766
4822
  if (path2d) this._context.stroke(path2d);
4767
4823
  else this._context.stroke();
4824
+ this._markBitmapMutation();
4768
4825
  }
4769
4826
  /**
4770
4827
  * strokeText function.
@@ -4772,6 +4829,7 @@ var UniverRenderingContext2D = class {
4772
4829
  */
4773
4830
  strokeText(text, x, y, maxWidth) {
4774
4831
  this._context.strokeText(text, x, y, maxWidth);
4832
+ this._markBitmapMutation();
4775
4833
  }
4776
4834
  /**
4777
4835
  * strokeText function precision.
@@ -4896,7 +4954,7 @@ var Canvas = class {
4896
4954
  this._canvasEle.style.outline = "0";
4897
4955
  const context = this._canvasEle.getContext("2d");
4898
4956
  if (context == null) throw new Error("context is not support");
4899
- if (props.mode === 1) this._context = new UniverPrintingContext(context);
4957
+ if (props.mode === 1) this._context = new UniverPrintingContext(context, { canvasColorService: props.colorService });
4900
4958
  else this._context = new UniverRenderingContext(context, { canvasColorService: props.colorService });
4901
4959
  this.setSize(props.width, props.height, props.pixelRatio);
4902
4960
  }
@@ -11957,8 +12015,10 @@ const SHAPE_OBJECT_ARRAY = [
11957
12015
  "globalCompositeOperation",
11958
12016
  "paintFirst",
11959
12017
  "stroke",
12018
+ "strokeOpacity",
11960
12019
  "strokeScaleEnabled",
11961
12020
  "fill",
12021
+ "fillOpacity",
11962
12022
  "fillAfterStrokeEnabled",
11963
12023
  "hitStrokeWidth",
11964
12024
  "strokeLineJoin",
@@ -11988,8 +12048,10 @@ var Shape = class extends BaseObject {
11988
12048
  _defineProperty(this, "_globalCompositeOperation", "source-over");
11989
12049
  _defineProperty(this, "_paintFirst", "fill");
11990
12050
  _defineProperty(this, "_stroke", void 0);
12051
+ _defineProperty(this, "_strokeOpacity", void 0);
11991
12052
  _defineProperty(this, "_strokeScaleEnabled", false);
11992
12053
  _defineProperty(this, "_fill", void 0);
12054
+ _defineProperty(this, "_fillOpacity", void 0);
11993
12055
  _defineProperty(this, "_fillAfterStrokeEnabled", false);
11994
12056
  _defineProperty(this, "_hitStrokeWidth", 0);
11995
12057
  _defineProperty(this, "_strokeLineJoin", "round");
@@ -12027,12 +12089,18 @@ var Shape = class extends BaseObject {
12027
12089
  get stroke() {
12028
12090
  return this._stroke;
12029
12091
  }
12092
+ get strokeOpacity() {
12093
+ return this._strokeOpacity;
12094
+ }
12030
12095
  get strokeScaleEnabled() {
12031
12096
  return this._strokeScaleEnabled;
12032
12097
  }
12033
12098
  get fill() {
12034
12099
  return this._fill;
12035
12100
  }
12101
+ get fillOpacity() {
12102
+ return this._fillOpacity;
12103
+ }
12036
12104
  get fillAfterStrokeEnabled() {
12037
12105
  return this._fillAfterStrokeEnabled;
12038
12106
  }
@@ -12098,6 +12166,7 @@ var Shape = class extends BaseObject {
12098
12166
  if (!props.fill) return;
12099
12167
  ctx.save();
12100
12168
  this._setFillStyles(ctx, props);
12169
+ ctx.globalAlpha *= props.fillOpacity ?? 1;
12101
12170
  if (props.fillRule === "evenodd") ctx.fill("evenodd");
12102
12171
  else ctx.fill();
12103
12172
  ctx.restore();
@@ -12107,10 +12176,11 @@ var Shape = class extends BaseObject {
12107
12176
  * @param {UniverRenderingContext} ctx SheetContext to render on
12108
12177
  */
12109
12178
  static _renderStroke(ctx, props) {
12110
- const { stroke, strokeWidth, strokeScaleEnabled } = props;
12179
+ const { stroke, strokeWidth } = props;
12111
12180
  if (!stroke || strokeWidth === void 0 || !Number.isFinite(strokeWidth) || strokeWidth <= 0) return;
12112
12181
  ctx.save();
12113
12182
  this._setStrokeStyles(ctx, props);
12183
+ ctx.globalAlpha *= props.strokeOpacity ?? 1;
12114
12184
  ctx.stroke();
12115
12185
  ctx.restore();
12116
12186
  }
@@ -15411,13 +15481,14 @@ function getCustomDecorationStyle(customDecoration) {
15411
15481
 
15412
15482
  //#endregion
15413
15483
  //#region src/components/docs/layout/style/custom-range.ts
15484
+ const CUSTOM_RANGE_COLOR_TOKEN = "blue.600";
15414
15485
  function getCustomRangeStyle(customRange) {
15415
15486
  if (customRange.rangeType === CustomRangeType.HYPERLINK || customRange.rangeType === CustomRangeType.MENTION || customRange.rangeType === CustomRangeType.CUSTOM) {
15416
15487
  var _customRange$properti;
15417
15488
  const preserveTextColor = ((_customRange$properti = customRange.properties) === null || _customRange$properti === void 0 ? void 0 : _customRange$properti.textColorMode) === "text";
15418
15489
  return {
15419
- ...customRange.active ?? true ? { ul: { s: BooleanNumber.TRUE } } : null,
15420
- ...preserveTextColor ? null : { cl: { rgb: "#274fee" } }
15490
+ ...customRange.rangeType === CustomRangeType.HYPERLINK || (customRange.active ?? true) ? { ul: { s: BooleanNumber.TRUE } } : null,
15491
+ ...preserveTextColor ? null : { cl: { rgb: CUSTOM_RANGE_COLOR_TOKEN } }
15421
15492
  };
15422
15493
  }
15423
15494
  return null;
@@ -15518,7 +15589,10 @@ function getLineHeightConfig(sectionBreakConfig, paragraphConfig) {
15518
15589
  const gridType = sectionBreakConfig.gridType ?? (useWordStyleLineHeight ? GridType.DEFAULT : GridType.LINES);
15519
15590
  const hasLineGrid = gridType === GridType.LINES || gridType === GridType.LINES_AND_CHARS;
15520
15591
  const defaultSnapToGrid = useWordStyleLineHeight && (!hasLineGrid || isInsideTable && adjustLineHeightInTable !== BooleanNumber.TRUE) ? BooleanNumber.FALSE : BooleanNumber.TRUE;
15521
- const { lineSpacing = 0, spacingRule = SpacingRule.AUTO, snapToGrid = defaultSnapToGrid } = paragraphStyle;
15592
+ const { lineSpacing: requestedLineSpacing = 0, spacingRule: requestedSpacingRule = SpacingRule.AUTO, snapToGrid = defaultSnapToGrid } = paragraphStyle;
15593
+ const hasValidLineSpacing = Number.isFinite(requestedLineSpacing) && requestedLineSpacing > 0;
15594
+ const lineSpacing = hasValidLineSpacing ? requestedLineSpacing : 0;
15595
+ const spacingRule = hasValidLineSpacing ? requestedSpacingRule : SpacingRule.AUTO;
15522
15596
  let lineSpacingApply = lineSpacing;
15523
15597
  if (useWordStyleLineHeight && lineSpacing === 0 && spacingRule === SpacingRule.AUTO) lineSpacingApply = 1;
15524
15598
  else if (!useWordStyleLineHeight && (gridType === GridType.LINES || gridType === GridType.LINES_AND_CHARS) && lineSpacing === 0 && spacingRule === SpacingRule.AUTO) lineSpacingApply = 1;
@@ -18430,24 +18504,15 @@ function allocateHorizontalWidths(columns, contentWidth) {
18430
18504
  }
18431
18505
  function compressToFit(widths, minWidths, overflow) {
18432
18506
  const nextWidths = [...widths];
18433
- let remainingOverflow = overflow;
18434
- let flexibleIndexes = getFlexibleIndexes(nextWidths, minWidths);
18435
- while (remainingOverflow > 0 && flexibleIndexes.length > 0) {
18436
- const totalShrink = flexibleIndexes.reduce((sum, item) => sum + item.shrink, 0);
18437
- for (const item of flexibleIndexes) {
18438
- const shrink = Math.min(item.shrink, remainingOverflow * item.shrink / totalShrink);
18439
- nextWidths[item.index] -= shrink;
18440
- remainingOverflow -= shrink;
18441
- }
18442
- flexibleIndexes = getFlexibleIndexes(nextWidths, minWidths);
18443
- }
18444
- return nextWidths;
18445
- }
18446
- function getFlexibleIndexes(widths, minWidths) {
18447
- return widths.map((width, index) => ({
18507
+ const flexibleIndexes = nextWidths.map((width, index) => ({
18448
18508
  index,
18449
18509
  shrink: Math.max(0, width - minWidths[index])
18450
18510
  })).filter((item) => item.shrink > 0);
18511
+ const totalShrink = flexibleIndexes.reduce((sum, item) => sum + item.shrink, 0);
18512
+ const appliedOverflow = Math.min(overflow, totalShrink);
18513
+ if (appliedOverflow <= 0 || totalShrink <= 0) return nextWidths;
18514
+ for (const item of flexibleIndexes) nextWidths[item.index] -= appliedOverflow * item.shrink / totalShrink;
18515
+ return nextWidths;
18451
18516
  }
18452
18517
  function getMinWidth(column) {
18453
18518
  var _column$minWidth;
@@ -20022,7 +20087,17 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
20022
20087
  _defineProperty(this, "_handleBorderMatrix", new ObjectMatrix());
20023
20088
  _defineProperty(this, "_showGridlines", BooleanNumber.TRUE);
20024
20089
  _defineProperty(this, "_gridlinesColor", void 0);
20090
+ _defineProperty(this, "_defaultGridlinesColor", void 0);
20025
20091
  _defineProperty(this, "_scene", null);
20092
+ const themeService = _injector.get(ThemeService);
20093
+ this.disposeWithMe(themeService.currentTheme$.subscribe(() => {
20094
+ var _this$_scene, _this$_scene2;
20095
+ const gray200 = themeService.getColorFromTheme("gray.200");
20096
+ const gray900 = themeService.getColorFromTheme("gray.900");
20097
+ this._defaultGridlinesColor = ColorKit.mix(gray200, gray900, .07).toHexString();
20098
+ (_this$_scene = this._scene) === null || _this$_scene === void 0 || _this$_scene.getViewports().forEach((viewport) => viewport.markDirty(true));
20099
+ (_this$_scene2 = this._scene) === null || _this$_scene2 === void 0 || _this$_scene2.makeDirty(true);
20100
+ }));
20026
20101
  this._updateLayout();
20027
20102
  this.disposeWithMe(this._contextService.subscribeContextValue$(RENDER_RAW_FORMULA_KEY).pipe(startWith(false), distinctUntilChanged()).subscribe((renderRaw) => {
20028
20103
  this._renderRawFormula = renderRaw;
@@ -20076,6 +20151,9 @@ let SpreadsheetSkeleton = class SpreadsheetSkeleton extends SheetSkeleton {
20076
20151
  get gridlinesColor() {
20077
20152
  return this._gridlinesColor;
20078
20153
  }
20154
+ get defaultGridlinesColor() {
20155
+ return this._defaultGridlinesColor;
20156
+ }
20079
20157
  dispose() {
20080
20158
  super.dispose();
20081
20159
  this._drawingRange = {
@@ -22097,6 +22175,15 @@ var Border$1 = class extends docExtension {
22097
22175
  };
22098
22176
  DocumentsSpanAndLineExtensionRegistry.add(new Border$1());
22099
22177
 
22178
+ //#endregion
22179
+ //#region src/components/docs/layout/style/color.ts
22180
+ const THEME_COLOR_TOKEN_PATTERN = /^[a-z][a-z0-9-]*\.\d+$/i;
22181
+ function getColorStyleForCanvas(color) {
22182
+ const rgb = color === null || color === void 0 ? void 0 : color.rgb;
22183
+ if (rgb && THEME_COLOR_TOKEN_PATTERN.test(rgb)) return rgb;
22184
+ return getColorStyle(color);
22185
+ }
22186
+
22100
22187
  //#endregion
22101
22188
  //#region src/components/docs/extensions/font-and-base-line.ts
22102
22189
  const UNIQUE_KEY$1 = "DefaultDocsFontAndBaseLineExtension";
@@ -22141,7 +22228,7 @@ var FontAndBaseLine = class extends docExtension {
22141
22228
  }
22142
22229
  }
22143
22230
  const { cl: colorStyle, va: baselineOffset, textFill, glow, outerShadow } = textStyle;
22144
- const fontColor = getColorStyle(colorStyle) || "rgb(0,0,0)";
22231
+ const fontColor = getColorStyleForCanvas(colorStyle) || "rgb(0,0,0)";
22145
22232
  if (baselineOffset === BaselineOffset.SUPERSCRIPT) spanPointWithFont.y += -bBox.spo;
22146
22233
  else if (baselineOffset === BaselineOffset.SUBSCRIPT) spanPointWithFont.y += bBox.sbo;
22147
22234
  const drawText = () => {
@@ -22461,7 +22548,7 @@ var Line$1 = class extends docExtension {
22461
22548
  const lineAlignOffset = isAccounting ? Vector2.create(0, alignOffset.y) : alignOffset;
22462
22549
  const { centerAngle: centerAngleDeg = 0, vertexAngle: vertexAngleDeg = 0 } = renderConfig;
22463
22550
  ctx.save();
22464
- ctx.strokeStyle = (c === BooleanNumber.TRUE ? getColorStyle((_glyph$ts = glyph.ts) === null || _glyph$ts === void 0 ? void 0 : _glyph$ts.cl) : getColorStyle(colorStyle)) || "rgb(0,0,0)";
22551
+ ctx.strokeStyle = (c === BooleanNumber.TRUE ? getColorStyleForCanvas((_glyph$ts = glyph.ts) === null || _glyph$ts === void 0 ? void 0 : _glyph$ts.cl) : getColorStyleForCanvas(colorStyle)) || "rgb(0,0,0)";
22465
22552
  this._setLineType(ctx, lineType ?? TextDecoration.SINGLE, lineWidth);
22466
22553
  startY += this._isDouble(lineType) ? -.8 : 0;
22467
22554
  const centerAngle = degToRad(centerAngleDeg);
@@ -23060,7 +23147,7 @@ var Documents = class Documents extends DocComponent {
23060
23147
  } else {
23061
23148
  this._drawLiquid.translateSave();
23062
23149
  this._drawLiquid.translateLine(line, true, true);
23063
- this._drawLineBackground(ctx, nestedPage, line, column.width);
23150
+ this._drawLineBackground(ctx, nestedPage, line, column.width, parentPage.marginLeft, parentPage.marginTop);
23064
23151
  const divideLength = divides.length;
23065
23152
  for (let i = 0; i < divideLength; i++) {
23066
23153
  const divide = divides[i];
@@ -23345,6 +23432,11 @@ const CUSTOM_EXTENSION_KEY = "DefaultCustomExtension";
23345
23432
  const MARKER_EXTENSION_KEY = "DefaultMarkerExtension";
23346
23433
  const RANGE_PROTECTION_VIEW_EXTENSION_KEY = "RANGE_PROTECTION_CAN_VIEW_RENDER_EXTENSION_KEY";
23347
23434
  const RANGE_PROTECTION_HIDDEN_EXTENSION_KEY = "RANGE_PROTECTION_CAN_NOT_VIEW_RENDER_EXTENSION_KEY";
23435
+ const PRINTING_GRIDLINES_COLOR = getColor([
23436
+ 214,
23437
+ 216,
23438
+ 219
23439
+ ]);
23348
23440
  function pushSparseCellRange(ranges, row, col) {
23349
23441
  const last = ranges[ranges.length - 1];
23350
23442
  if (last && last.startRow === row && last.endRow === row && last.endColumn + 1 === col) {
@@ -23571,7 +23663,6 @@ var Spreadsheet = class extends SheetComponent {
23571
23663
  extension.draw(ctx, parentScale, spreadsheetSkeleton, extensionDiffRanges, {
23572
23664
  viewRanges: extensionViewRanges,
23573
23665
  checkOutOfViewBound: true,
23574
- fontRenderRanges: extension === this._fontExtension && !isMergeRepair ? spreadsheetSkeleton.incrementalFontRenderRanges : void 0,
23575
23666
  hasMergeData,
23576
23667
  viewportKey: viewportInfo.viewportKey,
23577
23668
  viewBound: viewportInfo.cacheBound,
@@ -23955,11 +24046,7 @@ var Spreadsheet = class extends SheetComponent {
23955
24046
  if (!rowHeightAccumulation || !columnWidthAccumulation || columnTotalWidth === void 0 || rowTotalHeight === void 0) return;
23956
24047
  ctx.save();
23957
24048
  ctx.setLineWidthByPrecision(1);
23958
- const defaultGridlinesColor = ctx.__mode === "printing" ? getColor([
23959
- 214,
23960
- 216,
23961
- 219
23962
- ]) : "mix(gray.200, gray.900, 0.07)";
24049
+ const defaultGridlinesColor = ctx.__mode === "printing" ? PRINTING_GRIDLINES_COLOR : spreadsheetSkeleton.defaultGridlinesColor;
23963
24050
  ctx.strokeStyle = gridlinesColor ?? ctx.renderConfig.gridlinesColor ?? defaultGridlinesColor;
23964
24051
  const columnWidthAccumulationLength = columnWidthAccumulation.length;
23965
24052
  const rowHeightAccumulationLength = rowHeightAccumulation.length;
@@ -24304,7 +24391,12 @@ function scrollAndClearCanvas(ctx, pixelRatio, scrollRenderInfos, dirtyBounds) {
24304
24391
  const targetY = (bounds.top + Math.max(0, offsetY)) * pixelRatio;
24305
24392
  const pixelCopyWidth = copyWidth * pixelRatio;
24306
24393
  const pixelCopyHeight = copyHeight * pixelRatio;
24394
+ ctx.save();
24395
+ ctx.beginPath();
24396
+ ctx.rect(targetX, targetY, pixelCopyWidth, pixelCopyHeight);
24397
+ ctx.clip();
24307
24398
  ctx.drawImage(ctx.canvas, sourceX, sourceY, pixelCopyWidth, pixelCopyHeight, targetX, targetY, pixelCopyWidth, pixelCopyHeight);
24399
+ ctx.restore();
24308
24400
  }
24309
24401
  clearCanvasBounds(ctx, pixelRatio, dirtyBounds);
24310
24402
  ctx.restore();
@@ -26655,8 +26747,10 @@ var ScrollBar = class ScrollBar extends Disposable {
26655
26747
  _defineProperty(this, "_thumbDefaultBackgroundColor", "gray.300");
26656
26748
  _defineProperty(this, "_thumbHoverBackgroundColor", "gray.400");
26657
26749
  _defineProperty(this, "_thumbActiveBackgroundColor", "gray.500");
26658
- _defineProperty(this, "_trackBackgroundColor", "alpha(white, 0.5)");
26659
- _defineProperty(this, "_trackBorderColor", "alpha(white, 0.7)");
26750
+ _defineProperty(this, "_trackBackgroundColor", "gray.0");
26751
+ _defineProperty(this, "_trackBorderColor", "gray.0");
26752
+ _defineProperty(this, "_trackBackgroundOpacity", .5);
26753
+ _defineProperty(this, "_trackBorderOpacity", .7);
26660
26754
  _defineProperty(this, "_trackThickness", DEFAULT_TRACK_SIZE);
26661
26755
  _defineProperty(this, "_vThumbMargin", DEFAULT_THUMB_MARGIN);
26662
26756
  _defineProperty(this, "_hThumbMargin", DEFAULT_THUMB_MARGIN);
@@ -26685,6 +26779,8 @@ var ScrollBar = class ScrollBar extends Disposable {
26685
26779
  if (props[key] !== void 0) this[`_${key}`] = props[key];
26686
26780
  });
26687
26781
  if (Tools.isDefine(props.thumbBackgroundColor)) this._thumbDefaultBackgroundColor = props.thumbBackgroundColor;
26782
+ if (Tools.isDefine(props.trackBackgroundColor)) this._trackBackgroundOpacity = 1;
26783
+ if (Tools.isDefine(props.trackBorderColor)) this._trackBorderOpacity = 1;
26688
26784
  if (Tools.isDefine(props.barSize)) this._trackThickness = props.barSize;
26689
26785
  if (Tools.isDefine(props.barBorder)) this._trackBorderThickness = props.barBorder;
26690
26786
  if (Tools.isDefine(props.thumbMargin)) {
@@ -26999,8 +27095,10 @@ var ScrollBar = class ScrollBar extends Disposable {
26999
27095
  if (this._enableHorizontal) {
27000
27096
  this.horizonScrollTrack = new Rect("__horizonBarRect__", {
27001
27097
  fill: this._trackBackgroundColor,
27098
+ fillOpacity: this._trackBackgroundOpacity,
27002
27099
  strokeWidth: this._trackBorderThickness,
27003
- stroke: this._trackBorderColor
27100
+ stroke: this._trackBorderColor,
27101
+ strokeOpacity: this._trackBorderOpacity
27004
27102
  });
27005
27103
  this.horizonThumbRect = new Rect("__horizonThumbRect__", {
27006
27104
  radius: 6,
@@ -27010,8 +27108,10 @@ var ScrollBar = class ScrollBar extends Disposable {
27010
27108
  if (this._enableVertical) {
27011
27109
  this.verticalScrollTrack = new Rect("__verticalBarRect__", {
27012
27110
  fill: this._trackBackgroundColor,
27111
+ fillOpacity: this._trackBackgroundOpacity,
27013
27112
  strokeWidth: this._trackBorderThickness,
27014
- stroke: this._trackBorderColor
27113
+ stroke: this._trackBorderColor,
27114
+ strokeOpacity: this._trackBorderOpacity
27015
27115
  });
27016
27116
  this.verticalThumbRect = new Rect("__verticalThumbRect__", {
27017
27117
  radius: 6,
@@ -27020,8 +27120,10 @@ var ScrollBar = class ScrollBar extends Disposable {
27020
27120
  }
27021
27121
  if (this._enableHorizontal && this._enableVertical) this.placeholderBarRect = new Rect("__placeholderBarRect__", {
27022
27122
  fill: this._trackBackgroundColor,
27123
+ fillOpacity: this._trackBackgroundOpacity,
27023
27124
  strokeWidth: this._trackBorderThickness,
27024
- stroke: this._trackBorderColor
27125
+ stroke: this._trackBorderColor,
27126
+ strokeOpacity: this._trackBorderOpacity
27025
27127
  });
27026
27128
  }
27027
27129
  _initialVerticalEvent() {
@@ -27967,68 +28069,28 @@ var DumbCanvasColorService = class {
27967
28069
  return color;
27968
28070
  }
27969
28071
  };
27970
- const DARK_RENDER_COLOR_OVERRIDES = {
27971
- "#17212b": "#e2e8f0",
27972
- "#64748b": "#94a3b8",
27973
- "#d9e0e7": "#253044",
27974
- "#edf1f5": "#1b2535",
27975
- "#eef2f6": "#1b2535",
27976
- "#f2f5f8": "#101827",
27977
- "#f3f6fa": "#18243a",
27978
- "#f4f8ff": "#172a46",
27979
- "#f5f9ff": "#12233a",
27980
- "#f7f9fb": "#0d1422",
27981
- "#f7f9fc": "#0d1422",
27982
- "#f8fafc": "#0f172a",
27983
- "#fbfcfd": "#07111f",
27984
- "#fcfdff": "#050914",
27985
- "#e8f1ff": "#173a69",
27986
- "#eaf5ff": "#12315a",
27987
- "#dbeafe": "#1e3a8a",
27988
- "#bfdbfe": "#60a5fa",
27989
- "#93c5fd": "#60a5fa",
27990
- "#8eb6f5": "#60a5fa",
27991
- "#60a5fa": "#60a5fa",
27992
- "#2563eb": "#60a5fa",
27993
- "#1d64d8": "#93c5fd",
27994
- "#1d5cff": "#60a5fa",
27995
- "#0f766e": "#2dd4bf",
27996
- "#d7f4ef": "#134e4a",
27997
- "rgba(37,99,235,0.05)": "rgba(96,165,250,0.16)",
27998
- "rgba(37,99,235,0.06)": "rgba(96,165,250,0.18)",
27999
- "rgba(37,99,235,0.08)": "rgba(96,165,250,0.22)",
28000
- "rgba(37,99,235,0.12)": "rgba(96,165,250,0.26)",
28001
- "rgba(37,99,235,0.18)": "rgba(96,165,250,0.30)",
28002
- "rgba(37,99,235,0.28)": "rgba(96,165,250,0.38)",
28003
- "rgba(239,246,255,0.88)": "rgba(30,64,175,0.72)",
28004
- "rgba(148,163,184,0.45)": "rgba(148,163,184,0.52)"
28005
- };
28006
- const COLOR_MIX_REGEXP = /^mix\(\s*([^,()]+)\s*,\s*([^,()]+)\s*,\s*(0(?:\.\d+)?|1(?:\.0+)?)\s*\)$/;
28007
- const COLOR_ALPHA_REGEXP = /^alpha\(\s*([^,()]+)\s*,\s*(0(?:\.\d+)?|1(?:\.0+)?)\s*\)$/;
28008
28072
  let CanvasColorService = class CanvasColorService extends Disposable {
28009
28073
  constructor(_themeService) {
28010
28074
  super();
28011
28075
  this._themeService = _themeService;
28012
28076
  _defineProperty(this, "_darkModeCache", /* @__PURE__ */ new Map());
28013
- _defineProperty(this, "_resolvedColorCache", /* @__PURE__ */ new Map());
28077
+ _defineProperty(this, "_resolvedThemeColors", /* @__PURE__ */ new Map());
28014
28078
  _defineProperty(this, "_invertAlgo", invertColorByMatrix);
28015
- this.disposeWithMe(this._themeService.currentTheme$.subscribe(() => {
28016
- this._resolvedColorCache.clear();
28079
+ this.disposeWithMe(this._themeService.currentTheme$.subscribe((theme) => {
28080
+ this._cacheThemeColors(theme);
28017
28081
  this._darkModeCache.clear();
28018
28082
  }));
28019
28083
  }
28020
28084
  getRenderColor(inputColor) {
28021
- const color = this._resolveColor(inputColor);
28085
+ const color = this._resolvedThemeColors.get(inputColor) ?? inputColor;
28022
28086
  if (!this._themeService.darkMode) return color;
28023
28087
  if (this._darkModeCache.has(color)) return this._darkModeCache.get(color);
28024
- if (normalizeRenderColor(color) === "transparent") {
28088
+ if (color.trim().toLowerCase() === "transparent") {
28025
28089
  this._darkModeCache.set(color, "transparent");
28026
28090
  return "transparent";
28027
28091
  }
28028
28092
  let cachedColor = "";
28029
- const mappedColor = getDarkRenderColorOverride(color);
28030
- if (mappedColor) cachedColor = mappedColor;
28031
- else if (color.startsWith("#")) {
28093
+ if (color.startsWith("#")) {
28032
28094
  cachedColor = rgbToHex(this._invertAlgo(hexToRgb(color)));
28033
28095
  if (color.length === 5) {
28034
28096
  const alpha = color.charAt(4);
@@ -28057,50 +28119,12 @@ let CanvasColorService = class CanvasColorService extends Disposable {
28057
28119
  this._darkModeCache.set(color, cachedColor);
28058
28120
  return cachedColor;
28059
28121
  }
28060
- _resolveColor(inputColor) {
28061
- const cachedColor = this._resolvedColorCache.get(inputColor);
28062
- if (cachedColor !== void 0) return cachedColor;
28063
- const mixMatch = inputColor.match(COLOR_MIX_REGEXP);
28064
- if (mixMatch) {
28065
- const color1 = this._resolveThemeColor(mixMatch[1].trim());
28066
- const color2 = this._resolveThemeColor(mixMatch[2].trim());
28067
- const amount = Number(mixMatch[3]);
28068
- const color = ColorKit.mix(color1, color2, amount).toHexString();
28069
- this._resolvedColorCache.set(inputColor, color);
28070
- return color;
28071
- }
28072
- const alphaMatch = inputColor.match(COLOR_ALPHA_REGEXP);
28073
- if (alphaMatch) {
28074
- const colorKit = new ColorKit(this._resolveThemeColor(alphaMatch[1].trim()));
28075
- if (!colorKit.isValid) throw new Error(`[CanvasColorService]: illegal color "${inputColor}"`);
28076
- const color = colorKit.setAlpha(Number(alphaMatch[2])).toRgbString();
28077
- this._resolvedColorCache.set(inputColor, color);
28078
- return color;
28079
- }
28080
- if (inputColor.trim().startsWith("alpha(")) throw new Error(`[CanvasColorService]: illegal color "${inputColor}"`);
28081
- const color = this._resolveThemeColor(inputColor);
28082
- if (color !== inputColor) this._resolvedColorCache.set(inputColor, color);
28083
- return color;
28084
- }
28085
- _resolveThemeColor(inputColor) {
28086
- let color = inputColor;
28087
- if (color.includes(".")) {
28088
- const themeColor = this._themeService.getColorFromTheme(color);
28089
- if (typeof themeColor === "string" && this._themeService.isValidThemeColor(color)) color = themeColor;
28090
- }
28091
- return color;
28122
+ _cacheThemeColors(theme) {
28123
+ this._resolvedThemeColors.clear();
28124
+ for (const [paletteName, palette] of Object.entries(theme)) for (const [tokenName, color] of Object.entries(palette)) if (typeof color === "string") this._resolvedThemeColors.set(`${paletteName}.${tokenName}`, color);
28092
28125
  }
28093
28126
  };
28094
28127
  CanvasColorService = __decorate([__decorateParam(0, Inject(ThemeService))], CanvasColorService);
28095
- function getDarkRenderColorOverride(color) {
28096
- const normalized = normalizeRenderColor(color);
28097
- return DARK_RENDER_COLOR_OVERRIDES[normalized] ?? null;
28098
- }
28099
- function normalizeRenderColor(color) {
28100
- const trimmed = color.trim().toLowerCase();
28101
- if (trimmed.startsWith("rgb")) return trimmed.replace(/\s+/g, "");
28102
- return trimmed;
28103
- }
28104
28128
  function hexToRgb(_hex) {
28105
28129
  const hex = _hex.replace(/^#/, "");
28106
28130
  let r;
@@ -28768,7 +28792,7 @@ Engine = __decorate([__decorateParam(2, ICanvasColorService)], Engine);
28768
28792
  //#endregion
28769
28793
  //#region package.json
28770
28794
  var name = "@univerjs/engine-render";
28771
- var version = "1.0.0-beta.1";
28795
+ var version = "1.0.0-beta.2";
28772
28796
 
28773
28797
  //#endregion
28774
28798
  //#region src/config/config.ts
@@ -29223,7 +29247,6 @@ const DEFAULT_TRANSFORMER_LAYER_INDEX = 2;
29223
29247
  const MINI_WIDTH_LIMIT = 20;
29224
29248
  const MINI_HEIGHT_LIMIT = 20;
29225
29249
  const DEFAULT_CONTROL_PLUS_INDEX = 5e3;
29226
- const SINGLE_ACTIVE_OBJECT_TYPE_MAP = /* @__PURE__ */ new Set([6]);
29227
29250
  const ROTATE_ICON_SIZE = 14;
29228
29251
  var TransformerRotateIcon = class extends Rect {
29229
29252
  _draw(ctx) {
@@ -29277,32 +29300,32 @@ var Transformer = class extends Disposable {
29277
29300
  _defineProperty(this, "hoverEnabled", false);
29278
29301
  _defineProperty(this, "hoverEnterFunc", void 0);
29279
29302
  _defineProperty(this, "hoverLeaveFunc", void 0);
29280
- _defineProperty(this, "resizeEnabled", true);
29281
- _defineProperty(this, "rotateEnabled", true);
29303
+ _defineProperty(this, "resizeEnabled", DEFAULT_TRANSFORMER_CONFIG.resizeEnabled);
29304
+ _defineProperty(this, "rotateEnabled", DEFAULT_TRANSFORMER_CONFIG.rotateEnabled);
29282
29305
  _defineProperty(this, "rotationSnaps", []);
29283
29306
  _defineProperty(this, "rotationSnapTolerance", 5);
29284
- _defineProperty(this, "rotateAnchorOffset", 50);
29285
- _defineProperty(this, "rotateAnchorPosition", "top");
29286
- _defineProperty(this, "rotateLineEnabled", true);
29287
- _defineProperty(this, "rotateSize", 10);
29288
- _defineProperty(this, "rotateCornerRadius", 10);
29289
- _defineProperty(this, "rotateFill", void 0);
29290
- _defineProperty(this, "rotateStroke", void 0);
29291
- _defineProperty(this, "rotateStrokeWidth", void 0);
29292
- _defineProperty(this, "rotateIconEnabled", false);
29293
- _defineProperty(this, "rotateIconStroke", void 0);
29294
- _defineProperty(this, "rotateIconStrokeWidth", 1.5);
29295
- _defineProperty(this, "borderEnabled", true);
29296
- _defineProperty(this, "borderStroke", "rgb(97, 97, 97)");
29297
- _defineProperty(this, "borderStrokeWidth", 1);
29307
+ _defineProperty(this, "rotateAnchorOffset", DEFAULT_TRANSFORMER_CONFIG.rotateAnchorOffset);
29308
+ _defineProperty(this, "rotateAnchorPosition", DEFAULT_TRANSFORMER_CONFIG.rotateAnchorPosition);
29309
+ _defineProperty(this, "rotateLineEnabled", DEFAULT_TRANSFORMER_CONFIG.rotateLineEnabled);
29310
+ _defineProperty(this, "rotateSize", DEFAULT_TRANSFORMER_CONFIG.rotateSize);
29311
+ _defineProperty(this, "rotateCornerRadius", DEFAULT_TRANSFORMER_CONFIG.rotateCornerRadius);
29312
+ _defineProperty(this, "rotateFill", DEFAULT_TRANSFORMER_CONFIG.rotateFill);
29313
+ _defineProperty(this, "rotateStroke", DEFAULT_TRANSFORMER_CONFIG.rotateStroke);
29314
+ _defineProperty(this, "rotateStrokeWidth", DEFAULT_TRANSFORMER_CONFIG.rotateStrokeWidth);
29315
+ _defineProperty(this, "rotateIconEnabled", DEFAULT_TRANSFORMER_CONFIG.rotateIconEnabled);
29316
+ _defineProperty(this, "rotateIconStroke", DEFAULT_TRANSFORMER_CONFIG.rotateIconStroke);
29317
+ _defineProperty(this, "rotateIconStrokeWidth", DEFAULT_TRANSFORMER_CONFIG.rotateIconStrokeWidth);
29318
+ _defineProperty(this, "borderEnabled", DEFAULT_TRANSFORMER_CONFIG.borderEnabled);
29319
+ _defineProperty(this, "borderStroke", DEFAULT_TRANSFORMER_CONFIG.borderStroke);
29320
+ _defineProperty(this, "borderStrokeWidth", DEFAULT_TRANSFORMER_CONFIG.borderStrokeWidth);
29298
29321
  _defineProperty(this, "borderDash", []);
29299
- _defineProperty(this, "borderSpacing", 0);
29300
- _defineProperty(this, "anchorFill", "rgb(255, 255, 255)");
29301
- _defineProperty(this, "anchorStroke", "rgb(185, 185, 185)");
29302
- _defineProperty(this, "anchorStrokeWidth", 1);
29303
- _defineProperty(this, "anchorSize", 10);
29304
- _defineProperty(this, "anchorCornerRadius", 10);
29305
- _defineProperty(this, "anchorStyle", "default");
29322
+ _defineProperty(this, "borderSpacing", DEFAULT_TRANSFORMER_CONFIG.borderSpacing);
29323
+ _defineProperty(this, "anchorFill", DEFAULT_TRANSFORMER_CONFIG.anchorFill);
29324
+ _defineProperty(this, "anchorStroke", DEFAULT_TRANSFORMER_CONFIG.anchorStroke);
29325
+ _defineProperty(this, "anchorStrokeWidth", DEFAULT_TRANSFORMER_CONFIG.anchorStrokeWidth);
29326
+ _defineProperty(this, "anchorSize", DEFAULT_TRANSFORMER_CONFIG.anchorSize);
29327
+ _defineProperty(this, "anchorCornerRadius", DEFAULT_TRANSFORMER_CONFIG.anchorCornerRadius);
29328
+ _defineProperty(this, "anchorStyle", DEFAULT_TRANSFORMER_CONFIG.anchorStyle);
29306
29329
  _defineProperty(this, "anchorSideLongSize", 16);
29307
29330
  _defineProperty(this, "anchorSideShortSize", 5);
29308
29331
  _defineProperty(this, "anchorSideCornerRadius", 2.5);
@@ -29310,11 +29333,11 @@ var Transformer = class extends Disposable {
29310
29333
  _defineProperty(this, "anchorShadowBlur", 0);
29311
29334
  _defineProperty(this, "anchorShadowOffsetX", 0);
29312
29335
  _defineProperty(this, "anchorShadowOffsetY", 0);
29313
- _defineProperty(this, "keepRatio", true);
29336
+ _defineProperty(this, "keepRatio", DEFAULT_TRANSFORMER_CONFIG.keepRatio);
29314
29337
  _defineProperty(this, "centeredScaling", false);
29315
29338
  _defineProperty(this, "zeroLeft", 0);
29316
29339
  _defineProperty(this, "zeroTop", 0);
29317
- _defineProperty(this, "moveBoundaryEnabled", true);
29340
+ _defineProperty(this, "moveBoundaryEnabled", DEFAULT_TRANSFORMER_CONFIG.moveBoundaryEnabled);
29318
29341
  _defineProperty(
29319
29342
  this,
29320
29343
  /**
@@ -30647,7 +30670,7 @@ var Transformer = class extends Disposable {
30647
30670
  const { isCropper } = this._getConfig(applyObject);
30648
30671
  const targetObject = this._findGroupObject(applyObject);
30649
30672
  if (this._selectedObjectMap.has(targetObject.oKey)) return;
30650
- if (!evt.ctrlKey || SINGLE_ACTIVE_OBJECT_TYPE_MAP.has(targetObject.objectType)) {
30673
+ if (!evt.ctrlKey) {
30651
30674
  this._selectedObjectMap.clear();
30652
30675
  this._clearControlMap();
30653
30676
  }
@@ -30772,6 +30795,7 @@ var Scene = class extends Disposable {
30772
30795
  _defineProperty(this, "_layers", []);
30773
30796
  _defineProperty(this, "_viewports", []);
30774
30797
  _defineProperty(this, "_preserveEngineOnRender", false);
30798
+ _defineProperty(this, "_hasPostRenderCanvasMutation", false);
30775
30799
  _defineProperty(this, "_scrollbarDragViewport", null);
30776
30800
  _defineProperty(this, "_isScrollbarSeeking", false);
30777
30801
  _defineProperty(this, "_isScrollbarPreviewDirty", false);
@@ -31307,12 +31331,19 @@ var Scene = class extends Disposable {
31307
31331
  }
31308
31332
  this._estimatedFullRenderDuration += (duration - this._estimatedFullRenderDuration) * SCROLLBAR_SEEK_RENDER_COST_SAMPLE_WEIGHT;
31309
31333
  }
31334
+ _notifyAfterRender(canvasInstance) {
31335
+ if (!canvasInstance) {
31336
+ this._afterRender$.next(canvasInstance);
31337
+ return false;
31338
+ }
31339
+ return canvasInstance.getContext().detectBitmapMutation(() => this._afterRender$.next(canvasInstance));
31340
+ }
31310
31341
  render(parentCtx) {
31311
31342
  var _this$getEngine2;
31312
31343
  if (!this.isDirty()) return;
31313
31344
  const layers = this._layers.sort(sortRules);
31314
31345
  const canvasInstance = (_this$getEngine2 = this.getEngine()) === null || _this$getEngine2 === void 0 ? void 0 : _this$getEngine2.getCanvas();
31315
- const shouldTryPreservingEngine = this._preserveEngineOnRender && parentCtx == null && canvasInstance != null;
31346
+ const shouldTryPreservingEngine = this._preserveEngineOnRender && !this._hasPostRenderCanvasMutation && parentCtx == null && canvasInstance != null;
31316
31347
  const isScrollbarSeekRender = this._isScrollbarSeeking && parentCtx == null && canvasInstance != null;
31317
31348
  const shouldMeasureFullRender = parentCtx == null && canvasInstance != null;
31318
31349
  const fullRenderStartedAt = Tools.now();
@@ -31344,7 +31375,7 @@ var Scene = class extends Disposable {
31344
31375
  }
31345
31376
  this._beforeRender$.next(canvasInstance);
31346
31377
  for (let i = 0, len = layers.length; i < len; i++) layers[i].render(parentCtx, i === len - 1, layerRenderOptions);
31347
- this._afterRender$.next(canvasInstance);
31378
+ this._hasPostRenderCanvasMutation = this._notifyAfterRender(canvasInstance);
31348
31379
  this._recordRenderedViewportScrollPositions();
31349
31380
  if (shouldMeasureFullRender) this._recordFullRenderDuration(Tools.now() - fullRenderStartedAt, isScrollbarSeekRender);
31350
31381
  }
@@ -31945,7 +31976,7 @@ let RenderManagerService = class RenderManagerService extends Disposable {
31945
31976
  _defineProperty(this, "_renderDisposed$", new Subject());
31946
31977
  _defineProperty(this, "disposed$", this._renderDisposed$.asObservable());
31947
31978
  _defineProperty(this, "_renderDependencies", /* @__PURE__ */ new Map());
31948
- this._initDarkModeListener();
31979
+ this._initThemeListener();
31949
31980
  }
31950
31981
  dispose() {
31951
31982
  super.dispose();
@@ -31986,8 +32017,8 @@ let RenderManagerService = class RenderManagerService extends Disposable {
31986
32017
  _getRenderDepsByType(type) {
31987
32018
  return Array.from(this._renderDependencies.get(type) ?? []);
31988
32019
  }
31989
- _initDarkModeListener() {
31990
- this.disposeWithMe(this._themeService.darkMode$.subscribe(() => {
32020
+ _initThemeListener() {
32021
+ this.disposeWithMe(merge$1(this._themeService.currentTheme$, this._themeService.darkMode$).subscribe(() => {
31991
32022
  this.getRenderAll().forEach((renderer) => {
31992
32023
  renderer.components.forEach((component) => {
31993
32024
  component.makeForceDirty(true);
@@ -33258,4 +33289,4 @@ var Viewport = class {
33258
33289
  };
33259
33290
 
33260
33291
  //#endregion
33261
- export { AlignmentSnapSession, BASE_OBJECT_ARRAY, BG_Z_INDEX, BORDER_TYPE, BORDER_Z_INDEX, Background, BaseObject, Border, BreakType, CHECK_OBJECT_ARRAY, CIRCLE_OBJECT_ARRAY, COLOR_BLACK_RGB, CURSOR_TYPE, Canvas, CanvasColorService, CanvasRenderMode, CheckboxShape, Circle, ColumnHeaderLayout, ComponentExtension, Control, Custom, CustomObject, DEFAULT_DOCUMENT_FONTSIZE, DEFAULT_FONTFACE_PLANE, DEFAULT_FRAME_LIST_SIZE, DEFAULT_FRAME_SAMPLE_SIZE, DEFAULT_MEASURE_TEXT, DEFAULT_OFFSET_SPACING, DEFAULT_PADDING_DATA, DEFAULT_SKELETON_FOOTER, DEFAULT_SKELETON_HEADER, DOCS_EXTENSION_TYPE, DOCUMENT_CONTEXT_CLIP_TYPE, DRAWING_OBJECT_LAYER_INDEX, DRAWING_OBJECT_LOWER_LAYER_INDEX, DRAWING_OBJECT_UPPER_LAYER_INDEX, DashedRect, DataStreamTreeNode, DeviceInputEventType, DeviceType, DocBackground, DocSimpleSkeleton, DocumentEditArea, DocumentSkeleton, DocumentSkeletonPageType, DocumentViewModel, Documents, DocumentsSpanAndLineExtensionRegistry, Drawing, DrawingGroupObject, DumbCanvasColorService, EXPAND_SIZE_FOR_RENDER_OVERFLOW, Engine, EventConstants, FIX_ONE_PIXEL_BLUR_OFFSET, FONT_EXTENSION_Z_INDEX, Font, FontCache, GlyphType, Group, HitCanvas, ICanvasColorService, INITIAL_MATRIX, INITIAL_Path2, IRenderManagerService, IWatermarkTypeEnum, Image$1 as Image, IsSafari, LINK_VIEW_PORT_TYPE, Layer, Line, LineType, Liquid, MAIN_VIEW_PORT_KEY, MAXIMUM_COL_WIDTH, MAXIMUM_ROW_HEIGHT, MEASURE_EXTENT, MEASURE_EXTENT_FOR_PARAGRAPH, MIDDLE_CELL_POS_MAGIC_NUMBER, MIN_COL_WIDTH, MIN_TEXT_RENDER_HEIGHT_IN_SCREEN_PX, Marker, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, ORIENTATION_TYPE, ObjectType, PATH_OBJECT_ARRAY, PRINTING_BG_Z_INDEX, PageLayoutType, Path, Path2, PerformanceMonitor, PointerInput, RECT_OBJECT_ARRAY, REGULAR_POLYGON_OBJECT_ARRAY, RENDER_CLASS_TYPE, RENDER_RAW_FORMULA_KEY, RICHTEXT_OBJECT_ARRAY, Rect, RegularPolygon, RenderComponent, RenderManagerService, RenderUnit, RichText, RollingAverage, RowHeaderLayout, SHAPE_OBJECT_ARRAY, SHAPE_TYPE, SHEET_EXTENSION_PREFIX, SHEET_EXTENSION_TYPE, SHEET_VIEWPORT_KEY, SLIDE_NAVIGATION_KEY, Scene, SceneCanvas, SceneViewer, ScrollBar, ScrollTimer, ScrollTimerType, Shape, SheetColumnHeaderExtensionRegistry, SheetComponent, SheetExtension, SheetRowHeaderExtensionRegistry, ShowGridlinesState, SkeletonType, Slide, Spreadsheet, SpreadsheetColumnHeader, SpreadsheetExtensionRegistry, SpreadsheetHeader, SpreadsheetRowHeader, SpreadsheetSkeleton, TEXT_OBJECT_ARRAY, TRANSFORM_CHANGE_OBSERVABLE_TYPE, Text, Transform, UNIVER_WATERMARK_LAYER_INDEX, UNIVER_WATERMARK_STORAGE_KEY, UniverPrintingContext, UniverRenderEnginePlugin, UniverRenderingContext, UniverRenderingContext2D, VERTICAL_ROTATE_ANGLE, Vector2, Viewport, WatermarkLayer, calculateCellImageRect, calculateRectRotate, cancelRequestFrame, checkStyle, cjk, clampRange, clearLineByBorderType, combineDrawingEffectFilter, compareDocumentSkeletonNestedPagePathOrder, convertTextRotation, convertTransformToOffsetX, convertTransformToOffsetY, createCanvasElement, createDrawingEffectFilter, createImageElement, degToRad, documentSkeletonLineIterator, documentSkeletonTableIterator, drawDiagonalLineByBorderType, drawLineByBorderType, expandDrawingEffectBounds, expandRangeIfIntersects, fixLineWidthByScale, generateRandomKey, getAlignmentRectXAnchors, getAlignmentRectYAnchors, getCellPositionByIndex, getCharSpaceApply, getCheckboxShapeSize, getClosestAlignmentOffset, getColor, getCurrentScrollXY, getCurrentTypeOfRenderer, getDPI, getDevicePixelRatio, getDocsCustomBlockRenderViewport, getDocsSkeletonPageSize, getDocsTableRenderViewport, getDocsTableViewportLeft, getDocumentSkeletonColumnPagePathInfo, getDocumentSkeletonNestedPageOffset, getDrawingGroupState, getFirstGrapheme, getFontStyleString, getGeneralNumberDisplayText, getGroupState, getLastColumn, getLastLine, getLineOffset, getLineWidth, getLineWith, getNextWheelZoomRatio, getNumberUnitValue, getOffsetRectForDom, getPageFromPath, getParagraphByGlyph, getPointerPrefix, getRenderTransformBaseOnParentBound, getRotateOffsetAndFarthestHypotenuse, getRotateOrientation, getRotatedBoundInGroup, getScale, getShrinkToFitScale, getSizeForDom, getSystemHighlightColor, getTableIdAndSliceIndex, getTranslateInSpreadContextWithPixelRatio, getValueType, glyphIterator, hasAllLatin, hasArabic, hasBasicLatin, hasLatinExtendedA, hasLatinExtendedB, hasLatinOneSupplement, hasListGlyph, hasScrollableOverflow, hasSpace, hasThai, hasTibetan, inViewRanges, injectStyle, isArray, isCheckboxGlyph, isCjkCenterAlignedPunctuation, isCjkLeftAlignedPunctuation, isCjkRightAlignedPunctuation, isDate, isEmojiGrapheme, isFirstGlyph, isFunction, isIndentByGlyph, isLastGlyph, isNumber, isObject, isPlaceholderOrSpace, isRectIntersect, isRegExp, isSameLine, isString, lineIterator, measureDocumentNoWrapTextRangeWidth, measureDocumentNoWrapTextWidth, measureDocumentUnbreakableTextWidth, measureDocumentWrappedTextWidth, mergeInfoOffset, normalizeAlignmentRect, parseDataStreamToTree, pixelToPt, precisionTo, ptToMM, ptToPixel, ptToPx, pxToInch, pxToNum, pxToPt, radToDeg, renderImageWatermark, renderTextWatermark, renderUserInfoWatermark, renderWatermark, requestNewFrame, resolveDrawingEffectMasks, resolveGlowEffect, resolveOuterShadowEffect, scaleDocumentDataForShrinkToFit, scrollAndClearCanvas, setDocsCustomBlockRenderViewportProvider, setDocsTableRenderViewportProvider, setLineType, sheetContentViewportKeys, sheetHeaderViewportKeys, shouldRenderRowText, startWithEmoji, toPx, transformObjectOutOfGroup, withCurrentTypeOfRenderer };
33292
+ export { AlignmentSnapSession, BASE_OBJECT_ARRAY, BG_Z_INDEX, BORDER_TYPE, BORDER_Z_INDEX, Background, BaseObject, Border, BreakType, CHECK_OBJECT_ARRAY, CIRCLE_OBJECT_ARRAY, COLOR_BLACK_RGB, CURSOR_TYPE, Canvas, CanvasColorService, CanvasRenderMode, CheckboxShape, Circle, ColumnHeaderLayout, ComponentExtension, Control, Custom, CustomObject, DEFAULT_DOCUMENT_FONTSIZE, DEFAULT_FONTFACE_PLANE, DEFAULT_FRAME_LIST_SIZE, DEFAULT_FRAME_SAMPLE_SIZE, DEFAULT_MEASURE_TEXT, DEFAULT_OFFSET_SPACING, DEFAULT_PADDING_DATA, DEFAULT_SKELETON_FOOTER, DEFAULT_SKELETON_HEADER, DEFAULT_TRANSFORMER_CONFIG, DOCS_EXTENSION_TYPE, DOCUMENT_CONTEXT_CLIP_TYPE, DRAWING_OBJECT_LAYER_INDEX, DRAWING_OBJECT_LOWER_LAYER_INDEX, DRAWING_OBJECT_UPPER_LAYER_INDEX, DashedRect, DataStreamTreeNode, DeviceInputEventType, DeviceType, DocBackground, DocSimpleSkeleton, DocumentEditArea, DocumentSkeleton, DocumentSkeletonPageType, DocumentViewModel, Documents, DocumentsSpanAndLineExtensionRegistry, Drawing, DrawingGroupObject, DumbCanvasColorService, EXPAND_SIZE_FOR_RENDER_OVERFLOW, Engine, EventConstants, FIX_ONE_PIXEL_BLUR_OFFSET, FONT_EXTENSION_Z_INDEX, Font, FontCache, GlyphType, Group, HitCanvas, ICanvasColorService, INITIAL_MATRIX, INITIAL_Path2, IRenderManagerService, IWatermarkTypeEnum, Image$1 as Image, IsSafari, LINK_VIEW_PORT_TYPE, Layer, Line, LineType, Liquid, MAIN_VIEW_PORT_KEY, MAXIMUM_COL_WIDTH, MAXIMUM_ROW_HEIGHT, MEASURE_EXTENT, MEASURE_EXTENT_FOR_PARAGRAPH, MIDDLE_CELL_POS_MAGIC_NUMBER, MIN_COL_WIDTH, MIN_TEXT_RENDER_HEIGHT_IN_SCREEN_PX, Marker, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, ORIENTATION_TYPE, ObjectType, PATH_OBJECT_ARRAY, PRINTING_BG_Z_INDEX, PageLayoutType, Path, Path2, PerformanceMonitor, PointerInput, RECT_OBJECT_ARRAY, REGULAR_POLYGON_OBJECT_ARRAY, RENDER_CLASS_TYPE, RENDER_RAW_FORMULA_KEY, RICHTEXT_OBJECT_ARRAY, Rect, RegularPolygon, RenderComponent, RenderManagerService, RenderUnit, RichText, RollingAverage, RowHeaderLayout, SHAPE_OBJECT_ARRAY, SHAPE_TYPE, SHEET_EXTENSION_PREFIX, SHEET_EXTENSION_TYPE, SHEET_VIEWPORT_KEY, SLIDE_NAVIGATION_KEY, Scene, SceneCanvas, SceneViewer, ScrollBar, ScrollTimer, ScrollTimerType, Shape, SheetColumnHeaderExtensionRegistry, SheetComponent, SheetExtension, SheetRowHeaderExtensionRegistry, ShowGridlinesState, SkeletonType, Slide, Spreadsheet, SpreadsheetColumnHeader, SpreadsheetExtensionRegistry, SpreadsheetHeader, SpreadsheetRowHeader, SpreadsheetSkeleton, TEXT_OBJECT_ARRAY, TRANSFORM_CHANGE_OBSERVABLE_TYPE, Text, Transform, UNIVER_WATERMARK_LAYER_INDEX, UNIVER_WATERMARK_STORAGE_KEY, UniverPrintingContext, UniverRenderEnginePlugin, UniverRenderingContext, UniverRenderingContext2D, VERTICAL_ROTATE_ANGLE, Vector2, Viewport, WatermarkLayer, calculateCellImageRect, calculateRectRotate, cancelRequestFrame, checkStyle, cjk, clampRange, clearLineByBorderType, combineDrawingEffectFilter, compareDocumentSkeletonNestedPagePathOrder, convertTextRotation, convertTransformToOffsetX, convertTransformToOffsetY, createCanvasElement, createDrawingEffectFilter, createImageElement, degToRad, documentSkeletonLineIterator, documentSkeletonTableIterator, drawDiagonalLineByBorderType, drawLineByBorderType, expandDrawingEffectBounds, expandRangeIfIntersects, fixLineWidthByScale, generateRandomKey, getAlignmentRectXAnchors, getAlignmentRectYAnchors, getCellPositionByIndex, getCharSpaceApply, getCheckboxShapeSize, getClosestAlignmentOffset, getColor, getCurrentScrollXY, getCurrentTypeOfRenderer, getDPI, getDevicePixelRatio, getDocsCustomBlockRenderViewport, getDocsSkeletonPageSize, getDocsTableRenderViewport, getDocsTableViewportLeft, getDocumentSkeletonColumnPagePathInfo, getDocumentSkeletonNestedPageOffset, getDrawingGroupState, getFirstGrapheme, getFontStyleString, getGeneralNumberDisplayText, getGroupState, getLastColumn, getLastLine, getLineOffset, getLineWidth, getLineWith, getNextWheelZoomRatio, getNumberUnitValue, getOffsetRectForDom, getPageFromPath, getParagraphByGlyph, getPointerPrefix, getRenderTransformBaseOnParentBound, getRotateOffsetAndFarthestHypotenuse, getRotateOrientation, getRotatedBoundInGroup, getScale, getShrinkToFitScale, getSizeForDom, getSystemHighlightColor, getTableIdAndSliceIndex, getTranslateInSpreadContextWithPixelRatio, getValueType, glyphIterator, hasAllLatin, hasArabic, hasBasicLatin, hasLatinExtendedA, hasLatinExtendedB, hasLatinOneSupplement, hasListGlyph, hasScrollableOverflow, hasSpace, hasThai, hasTibetan, inViewRanges, injectStyle, isArray, isCheckboxGlyph, isCjkCenterAlignedPunctuation, isCjkLeftAlignedPunctuation, isCjkRightAlignedPunctuation, isDate, isEmojiGrapheme, isFirstGlyph, isFunction, isIndentByGlyph, isLastGlyph, isNumber, isObject, isPlaceholderOrSpace, isRectIntersect, isRegExp, isSameLine, isString, lineIterator, measureDocumentNoWrapTextRangeWidth, measureDocumentNoWrapTextWidth, measureDocumentUnbreakableTextWidth, measureDocumentWrappedTextWidth, mergeInfoOffset, normalizeAlignmentRect, parseDataStreamToTree, pixelToPt, precisionTo, ptToMM, ptToPixel, ptToPx, pxToInch, pxToNum, pxToPt, radToDeg, renderImageWatermark, renderTextWatermark, renderUserInfoWatermark, renderWatermark, requestNewFrame, resolveDrawingEffectMasks, resolveGlowEffect, resolveOuterShadowEffect, scaleDocumentDataForShrinkToFit, scrollAndClearCanvas, setDocsCustomBlockRenderViewportProvider, setDocsTableRenderViewportProvider, setLineType, sheetContentViewportKeys, sheetHeaderViewportKeys, shouldRenderRowText, startWithEmoji, toPx, transformObjectOutOfGroup, withCurrentTypeOfRenderer };