@univerjs/sheets-conditional-formatting 1.4.0 → 1.5.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
@@ -3,7 +3,7 @@ import { CopySheetCommand, InsertColMutation, InsertRowMutation, MoveColsMutatio
3
3
  import { BehaviorSubject, Subject } from "rxjs";
4
4
  import { BooleanValue, ERROR_TYPE_SET, FormulaResultStatus, OtherFormulaBizType, RegisterOtherFormulaService, UniverFormulaEnginePlugin } from "@univerjs/engine-formula";
5
5
  import { bufferTime, distinctUntilChanged, filter, map } from "rxjs/operators";
6
- import { FIX_ONE_PIXEL_BLUR_OFFSET, SheetExtension, SpreadsheetExtensionRegistry, isObject } from "@univerjs/engine-render";
6
+ import { FIX_ONE_PIXEL_BLUR_OFFSET, SheetExtension, SpreadsheetExtensionRegistry, UniverRenderingContext, isObject } from "@univerjs/engine-render";
7
7
 
8
8
  // src/base/const.ts
9
9
  const SHEET_CONDITIONAL_FORMATTING_PLUGIN = "SHEET_CONDITIONAL_FORMATTING_PLUGIN";
@@ -215,7 +215,7 @@ const isAnchorEqual = (anchor1, anchor2) => {
215
215
  */
216
216
  const createCfId = () => `${generateRandomId(8)}`;
217
217
 
218
- // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
218
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
219
219
  function _typeof(o) {
220
220
  "@babel/helpers - typeof";
221
221
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -225,25 +225,25 @@ function _typeof(o) {
225
225
  }, _typeof(o);
226
226
  }
227
227
 
228
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
229
- function toPrimitive(t, r) {
228
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
229
+ function toPrimitive(t, e) {
230
230
  if ("object" != _typeof(t) || !t) return t;
231
- var e = t[Symbol.toPrimitive];
232
- if (void 0 !== e) {
233
- var i = e.call(t, r || "default");
231
+ var r;
232
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
233
+ var i = r.call(t, e || "default");
234
234
  if ("object" != _typeof(i)) return i;
235
235
  throw new TypeError("@@toPrimitive must return a primitive value.");
236
236
  }
237
- return ("string" === r ? String : Number)(t);
237
+ return ("string" === e ? String : Number)(t);
238
238
  }
239
239
 
240
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
240
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
241
241
  function toPropertyKey(t) {
242
242
  var i = toPrimitive(t, "string");
243
243
  return "symbol" == _typeof(i) ? i : i + "";
244
244
  }
245
245
 
246
- // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
246
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
247
247
  function _defineProperty(e, r, t) {
248
248
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
249
249
  value: t,
@@ -499,14 +499,14 @@ const AddCfCommand = {
499
499
  }
500
500
  };
501
501
 
502
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
502
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
503
503
  function __decorateParam(paramIndex, decorator) {
504
504
  return function(target, key) {
505
505
  decorator(target, key, paramIndex);
506
506
  };
507
507
  }
508
508
 
509
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
509
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
510
510
  function __decorate(decorators, target, key, desc) {
511
511
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
512
512
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -603,14 +603,15 @@ ConditionalFormattingRangeIndexModel = __decorate([__decorateParam(0, Inject(Con
603
603
  // src/services/conditional-formatting-range-transform.service.ts
604
604
  var ConditionalFormattingRangeTransformService = class {
605
605
  subtractRanges(sourceRanges, rangesToSubtract) {
606
- return Rectangle.mergeRanges(Rectangle.subtractMulti(sourceRanges, rangesToSubtract));
606
+ return this._keepCoveredRangeType(Rectangle.mergeRanges(Rectangle.subtractMulti(sourceRanges, rangesToSubtract)), sourceRanges);
607
607
  }
608
608
  addRanges(sourceRanges, rangesToAdd) {
609
- return Rectangle.mergeRanges([...sourceRanges, ...rangesToAdd]);
609
+ return this._keepCoveredRangeType(Rectangle.mergeRanges([...sourceRanges, ...rangesToAdd]), sourceRanges);
610
610
  }
611
611
  applyRangeDelta(sourceRanges, rangesToSubtract, rangesToAdd) {
612
- const ranges = rangesToSubtract.length ? this.subtractRanges(sourceRanges, rangesToSubtract) : sourceRanges;
613
- return rangesToAdd.length ? this.addRanges(ranges, rangesToAdd) : ranges;
612
+ const ranges = rangesToSubtract.length ? Rectangle.mergeRanges(Rectangle.subtractMulti(sourceRanges, rangesToSubtract)) : sourceRanges;
613
+ const merged = rangesToAdd.length ? Rectangle.mergeRanges([...ranges, ...rangesToAdd]) : ranges;
614
+ return this._keepCoveredRangeType(merged, sourceRanges);
614
615
  }
615
616
  copyIntersectingRanges(sourceRanges, sourceRange, targetAnchor) {
616
617
  const fragments = [];
@@ -632,6 +633,21 @@ var ConditionalFormattingRangeTransformService = class {
632
633
  endColumn: range.endColumn + offset.col
633
634
  };
634
635
  }
636
+ /**
637
+ * Rebuilding ranges from coordinates drops `rangeType`. A result range that still covers exactly
638
+ * the same cells as a whole column/row source has to keep that type, otherwise a rule that was
639
+ * not actually changed (for example adding an already covered range) degrades to concrete rows.
640
+ * Results that no longer match a source range are genuine partial coverage and stay concrete.
641
+ */
642
+ _keepCoveredRangeType(ranges, sourceRanges) {
643
+ return ranges.map((range) => {
644
+ const source = sourceRanges.find((item) => item.rangeType && item.startRow === range.startRow && item.endRow === range.endRow && item.startColumn === range.startColumn && item.endColumn === range.endColumn);
645
+ return source ? {
646
+ ...range,
647
+ rangeType: source.rangeType
648
+ } : range;
649
+ });
650
+ }
635
651
  };
636
652
 
637
653
  // src/commands/mutations/set-conditional-rule.mutation.ts
@@ -1199,6 +1215,154 @@ var ColorScaleCalculateUnit = class extends BaseCalculateUnit {
1199
1215
  }
1200
1216
  };
1201
1217
 
1218
+ // src/render/conditional-formatting-raster-cache.ts
1219
+ /**
1220
+ * Copyright 2023-present DreamNum Co., Ltd.
1221
+ *
1222
+ * Licensed under the Apache License, Version 2.0 (the "License");
1223
+ * you may not use this file except in compliance with the License.
1224
+ * You may obtain a copy of the License at
1225
+ *
1226
+ * http://www.apache.org/licenses/LICENSE-2.0
1227
+ *
1228
+ * Unless required by applicable law or agreed to in writing, software
1229
+ * distributed under the License is distributed on an "AS IS" BASIS,
1230
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1231
+ * See the License for the specific language governing permissions and
1232
+ * limitations under the License.
1233
+ */
1234
+ const MAX_ENTRIES = 128;
1235
+ const MAX_PIXELS = 524288;
1236
+ const MAX_BITMAP_PIXELS = 131072;
1237
+ /** Retain physical pixels without mutating image sources already submitted to the destination. */
1238
+ var ConditionalFormattingRasterCache = class extends Disposable {
1239
+ constructor(..._args) {
1240
+ super(..._args);
1241
+ _defineProperty(this, "_bitmaps", /* @__PURE__ */ new Map());
1242
+ _defineProperty(this, "_pixels", 0);
1243
+ }
1244
+ draw(ctx, x, y, width, height, variant, draw, strokeWidth = 0) {
1245
+ var _native$getContextAtt;
1246
+ this.ensureNotDisposed();
1247
+ const native = ctx._context;
1248
+ const m = native === null || native === void 0 ? void 0 : native.getTransform();
1249
+ const colorSpace = native === null || native === void 0 || (_native$getContextAtt = native.getContextAttributes) === null || _native$getContextAtt === void 0 || (_native$getContextAtt = _native$getContextAtt.call(native)) === null || _native$getContextAtt === void 0 ? void 0 : _native$getContextAtt.colorSpace;
1250
+ if (!m || ctx.__mode === "printing" || typeof document === "undefined" || m.a !== m.d || m.a <= 0 || m.b || m.c || native.globalAlpha !== 1 || native.globalCompositeOperation !== "source-over" || colorSpace && colorSpace !== "srgb" || native.shadowBlur || native.shadowOffsetX || native.shadowOffsetY || ![
1251
+ "rgba(0, 0, 0, 0)",
1252
+ "transparent",
1253
+ "#00000000"
1254
+ ].includes(native.shadowColor) || native.filter && native.filter !== "none" || width <= 0 || height <= 0 || typeof native.fillStyle !== "string" || typeof native.strokeStyle !== "string") {
1255
+ draw(ctx, x, y);
1256
+ return;
1257
+ }
1258
+ const px = x * m.a + m.e;
1259
+ const py = y * m.d + m.f;
1260
+ const padding = Math.max(2, Math.ceil(strokeWidth * m.a / 2) + 1);
1261
+ const left = Math.floor(px) - padding;
1262
+ const top = Math.floor(py) - padding;
1263
+ const pixelWidth = Math.ceil(px + width * m.a) - left + padding;
1264
+ const pixelHeight = Math.ceil(py + height * m.d) - top + padding;
1265
+ const pixels = pixelWidth * pixelHeight;
1266
+ if (!Number.isFinite(pixels) || pixels > MAX_BITMAP_PIXELS) {
1267
+ draw(ctx, x, y);
1268
+ return;
1269
+ }
1270
+ const localX = px - left;
1271
+ const localY = py - top;
1272
+ const dash = native.getLineDash();
1273
+ const key = JSON.stringify([
1274
+ variant,
1275
+ width,
1276
+ height,
1277
+ m.a,
1278
+ localX,
1279
+ localY,
1280
+ strokeWidth,
1281
+ native.fillStyle,
1282
+ native.strokeStyle,
1283
+ dash,
1284
+ native.lineDashOffset,
1285
+ native.lineCap,
1286
+ native.lineJoin,
1287
+ native.miterLimit,
1288
+ native.imageSmoothingEnabled,
1289
+ native.imageSmoothingQuality
1290
+ ]);
1291
+ let bitmap = this._bitmaps.get(key);
1292
+ if (!bitmap) {
1293
+ const canvas = document.createElement("canvas");
1294
+ canvas.width = pixelWidth;
1295
+ canvas.height = pixelHeight;
1296
+ const context = canvas.getContext("2d");
1297
+ if (!context) {
1298
+ draw(ctx, x, y);
1299
+ return;
1300
+ }
1301
+ const paint = new UniverRenderingContext(context);
1302
+ paint.setTransform(m.a, 0, 0, m.d, localX, localY);
1303
+ paint.setLineDash(dash);
1304
+ paint.lineDashOffset = native.lineDashOffset;
1305
+ paint.lineCap = native.lineCap;
1306
+ paint.lineJoin = native.lineJoin;
1307
+ paint.miterLimit = native.miterLimit;
1308
+ paint.imageSmoothingEnabled = native.imageSmoothingEnabled;
1309
+ paint.imageSmoothingQuality = native.imageSmoothingQuality;
1310
+ draw(paint, 0, 0);
1311
+ while (this._bitmaps.size >= MAX_ENTRIES || this._pixels + pixels > MAX_PIXELS) {
1312
+ const oldestKey = this._bitmaps.keys().next().value;
1313
+ if (oldestKey === void 0) break;
1314
+ this._pixels -= this._bitmaps.get(oldestKey).pixels;
1315
+ this._bitmaps.delete(oldestKey);
1316
+ }
1317
+ bitmap = {
1318
+ canvas,
1319
+ pixels
1320
+ };
1321
+ this._bitmaps.set(key, bitmap);
1322
+ this._pixels += pixels;
1323
+ }
1324
+ ctx.save();
1325
+ try {
1326
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
1327
+ ctx.imageSmoothingEnabled = false;
1328
+ ctx.drawImage(bitmap.canvas, left, top);
1329
+ } finally {
1330
+ ctx.restore();
1331
+ }
1332
+ }
1333
+ dispose() {
1334
+ for (const { canvas } of this._bitmaps.values()) {
1335
+ canvas.width = 0;
1336
+ canvas.height = 0;
1337
+ }
1338
+ this._bitmaps.clear();
1339
+ this._pixels = 0;
1340
+ super.dispose();
1341
+ }
1342
+ };
1343
+
1344
+ // src/render/resolve-render-ranges.ts
1345
+ function resolveRenderRanges(worksheet, sourceRanges, resolver) {
1346
+ if (!resolver) return sourceRanges;
1347
+ const mergedRanges = worksheet.getMergeData().length ? sourceRanges.flatMap((range) => worksheet.getMergedCellRange(range.startRow, range.startColumn, range.endRow, range.endColumn)) : [];
1348
+ const queryRanges = mergedRanges.length ? [...sourceRanges, ...mergedRanges.map((range) => ({
1349
+ startRow: range.startRow,
1350
+ endRow: range.startRow,
1351
+ startColumn: range.startColumn,
1352
+ endColumn: range.startColumn
1353
+ }))] : sourceRanges;
1354
+ const resolved = resolver(worksheet.getUnitId(), worksheet.getSheetId(), queryRanges);
1355
+ if (!resolved) return sourceRanges;
1356
+ if (!mergedRanges.length || !resolved.length) return resolved;
1357
+ const formattedMerges = mergedRanges.filter((merge) => resolved.some((range) => Rectangle.intersects(merge, range)));
1358
+ const clipped = [];
1359
+ for (const source of sourceRanges) for (const range of [...resolved, ...formattedMerges]) {
1360
+ const intersection = getIntersectRange(source, range);
1361
+ if (intersection) clipped.push(intersection);
1362
+ }
1363
+ return clipped.length > 1 ? Rectangle.mergeRanges(clipped) : clipped;
1364
+ }
1365
+
1202
1366
  // src/render/data-bar.render.ts
1203
1367
  const dataBarUKey = "sheet-conditional-rule-data-bar";
1204
1368
  const defaultDataBarPositiveColor = "#ffbe38";
@@ -1209,11 +1373,13 @@ const stringifyRange$1 = (range) => {
1209
1373
  const { startRow, endRow, startColumn, endColumn } = range;
1210
1374
  return `${startRow}-${endRow}-${startColumn}-${endColumn}`;
1211
1375
  };
1212
- var DataBar = class extends SheetExtension {
1376
+ var DataBar = class DataBar extends SheetExtension {
1213
1377
  constructor(..._args) {
1214
1378
  super(..._args);
1379
+ _defineProperty(this, "viewportCacheReusable", this.constructor === DataBar);
1215
1380
  _defineProperty(this, "_paddingRightAndLeft", 2);
1216
1381
  _defineProperty(this, "_paddingTopAndBottom", 2);
1382
+ _defineProperty(this, "_rasterCache", new ConditionalFormattingRasterCache());
1217
1383
  _defineProperty(this, "_renderRangeResolver", null);
1218
1384
  _defineProperty(this, "uKey", dataBarUKey);
1219
1385
  _defineProperty(this, "Z_INDEX", EXTENSION_Z_INDEX$1);
@@ -1227,7 +1393,7 @@ var DataBar = class extends SheetExtension {
1227
1393
  if (!worksheet) return false;
1228
1394
  const mergeCellRendered = /* @__PURE__ */ new Set();
1229
1395
  const sourceRanges = (diffRanges === null || diffRanges === void 0 ? void 0 : diffRanges.length) ? diffRanges : [spreadsheetSkeleton.rowColumnSegment];
1230
- const renderRanges = this._renderRangeResolver && worksheet.getMergeData().length === 0 ? this._renderRangeResolver(worksheet.getUnitId(), worksheet.getSheetId(), sourceRanges) ?? sourceRanges : sourceRanges;
1396
+ const renderRanges = resolveRenderRanges(worksheet, sourceRanges, this._renderRangeResolver);
1231
1397
  if (!renderRanges.length) return;
1232
1398
  ctx.save();
1233
1399
  renderRanges.forEach((range) => {
@@ -1250,43 +1416,42 @@ var DataBar = class extends SheetExtension {
1250
1416
  const borderHeight = endY + FIX_ONE_PIXEL_BLUR_OFFSET - startY;
1251
1417
  const width = borderWidth - this._paddingRightAndLeft * 2;
1252
1418
  const height = borderHeight - this._paddingTopAndBottom * 2;
1253
- if (value > 0) {
1254
- const dataBarWidth = Math.max(width * (1 - startPoint / 100) * value / 100, 1);
1255
- const x0 = startX + this._paddingRightAndLeft + startPoint / 100 * width;
1256
- const y0 = startY + this._paddingTopAndBottom;
1419
+ const positive = value > 0;
1420
+ const dataBarWidth = Math.max(positive ? width * (1 - startPoint / 100) * value / 100 : width * startPoint / 100 * Math.abs(value) / 100, 1);
1421
+ const x0 = startX + this._paddingRightAndLeft + startPoint / 100 * width - (positive ? 0 : dataBarWidth);
1422
+ const y0 = startY + this._paddingTopAndBottom;
1423
+ ctx.fillStyle = color;
1424
+ ctx.strokeStyle = color;
1425
+ const fillColor = ctx.fillStyle;
1426
+ const strokeColor = ctx.strokeStyle;
1427
+ this._drawAtLocalOrigin(ctx, x0, y0, dataBarWidth, height, (paint, x, y) => {
1257
1428
  if (isGradient) {
1258
- const gradient = ctx.createLinearGradient(x0, y0, x0 + dataBarWidth, y0);
1259
- gradient.addColorStop(0, color);
1260
- gradient.addColorStop(1, "rgb(255 255 255)");
1261
- ctx.fillStyle = gradient;
1262
- ctx.strokeStyle = color;
1263
- ctx.lineWidth = 1;
1264
- } else ctx.fillStyle = color;
1265
- this._drawRectWithRoundedCorner(ctx, x0, y0, dataBarWidth, height, false, true, true, false);
1266
- if (isGradient) ctx.stroke();
1267
- } else {
1268
- const dataBarWidth = Math.max(width * startPoint / 100 * Math.abs(value) / 100, 1);
1269
- const x0 = startX + this._paddingRightAndLeft + startPoint / 100 * width - dataBarWidth;
1270
- const y0 = startY + this._paddingTopAndBottom;
1271
- if (isGradient) {
1272
- const gradient = ctx.createLinearGradient(x0, y0, x0 + dataBarWidth, y0);
1273
- gradient.addColorStop(0, "rgb(255 255 255)");
1274
- gradient.addColorStop(1, color);
1275
- ctx.fillStyle = gradient;
1276
- ctx.strokeStyle = color;
1277
- ctx.lineWidth = 1;
1278
- } else ctx.fillStyle = color;
1279
- this._drawRectWithRoundedCorner(ctx, x0, y0, dataBarWidth, height, true, false, false, true);
1280
- if (isGradient) ctx.stroke();
1281
- }
1429
+ const gradient = paint.createLinearGradient(x, y, x + dataBarWidth, y);
1430
+ gradient.addColorStop(0, positive ? color : "rgb(255 255 255)");
1431
+ gradient.addColorStop(1, positive ? "rgb(255 255 255)" : color);
1432
+ paint.fillStyle = gradient;
1433
+ paint.strokeStyle = paint === ctx ? color : strokeColor;
1434
+ paint.lineWidth = 1;
1435
+ } else paint.fillStyle = paint === ctx ? color : fillColor;
1436
+ this._drawRectWithRoundedCorner(paint, x, y, dataBarWidth, height, !positive, positive, positive, !positive);
1437
+ if (isGradient) paint.stroke();
1438
+ }, `${positive}:${isGradient}:${this._radius}:${color}`, isGradient ? 1 : 0);
1282
1439
  });
1283
1440
  });
1284
1441
  ctx.restore();
1285
1442
  }
1286
1443
  dispose() {
1444
+ this._rasterCache.dispose();
1287
1445
  this._renderRangeResolver = null;
1288
1446
  super.dispose();
1289
1447
  }
1448
+ _drawAtLocalOrigin(ctx, x, y, width, height, draw, variant = "", strokeWidth = 0) {
1449
+ if (typeof navigator !== "undefined" && (ctx.getBrowserType() === "Safari" || Tools.isIPhone())) {
1450
+ draw(ctx, x, y);
1451
+ return;
1452
+ }
1453
+ this._rasterCache.draw(ctx, x, y, width, height, variant, draw, strokeWidth);
1454
+ }
1290
1455
  _drawRectWithRoundedCorner(ctx, x, y, width, height, topLeftRadius, topRightRadius, bottomRightRadius, bottomLeftRadius) {
1291
1456
  const radius = this._radius;
1292
1457
  if (!height || !width) return;
@@ -2543,7 +2708,7 @@ for (const key in iconMap) {
2543
2708
 
2544
2709
  // package.json
2545
2710
  var name = "@univerjs/sheets-conditional-formatting";
2546
- var version = "1.4.0";
2711
+ var version = "1.5.1";
2547
2712
 
2548
2713
  // src/config/config.ts
2549
2714
  /**
@@ -2805,7 +2970,9 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
2805
2970
  };
2806
2971
  switch (commandInfo.id) {
2807
2972
  case SetRangeValuesMutation.id: {
2973
+ var _this$_conditionalFor;
2808
2974
  const { subUnitId, unitId, cellValue } = commandInfo.params;
2975
+ if (!((_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) === null || _this$_conditionalFor === void 0 ? void 0 : _this$_conditionalFor.length)) break;
2809
2976
  const ranges = [];
2810
2977
  new ObjectMatrix(cellValue).forValue((row, col, value) => {
2811
2978
  if (value && Object.keys(value).some((key) => ["p", "v"].includes(key))) ranges.push({
@@ -2975,12 +3142,15 @@ const stringifyRange = (range) => {
2975
3142
  const { startRow, endRow, startColumn, endColumn } = range;
2976
3143
  return `${startRow}-${endRow}-${startColumn}-${endColumn}`;
2977
3144
  };
2978
- var ConditionalFormattingIcon = class extends SheetExtension {
3145
+ var ConditionalFormattingIcon = class ConditionalFormattingIcon extends SheetExtension {
2979
3146
  constructor() {
2980
3147
  super();
3148
+ _defineProperty(this, "viewportCacheReusable", this.constructor === ConditionalFormattingIcon);
2981
3149
  _defineProperty(this, "_paddingRightAndLeft", 2);
2982
3150
  _defineProperty(this, "_width", 15);
2983
3151
  _defineProperty(this, "_imageMap", /* @__PURE__ */ new Map());
3152
+ _defineProperty(this, "_rasterCache", new ConditionalFormattingRasterCache());
3153
+ _defineProperty(this, "_pendingImages", /* @__PURE__ */ new Set());
2984
3154
  _defineProperty(this, "_renderRangeResolver", null);
2985
3155
  _defineProperty(this, "uKey", IconUKey);
2986
3156
  _defineProperty(this, "Z_INDEX", EXTENSION_Z_INDEX);
@@ -2995,7 +3165,7 @@ var ConditionalFormattingIcon = class extends SheetExtension {
2995
3165
  if (!worksheet) return false;
2996
3166
  const mergeCellRendered = /* @__PURE__ */ new Set();
2997
3167
  const sourceRanges = (diffRanges === null || diffRanges === void 0 ? void 0 : diffRanges.length) ? diffRanges : [spreadsheetSkeleton.rowColumnSegment];
2998
- const renderRanges = this._renderRangeResolver && worksheet.getMergeData().length === 0 ? this._renderRangeResolver(worksheet.getUnitId(), worksheet.getSheetId(), sourceRanges) ?? sourceRanges : sourceRanges;
3168
+ const renderRanges = resolveRenderRanges(worksheet, sourceRanges, this._renderRangeResolver);
2999
3169
  if (!renderRanges.length) return;
3000
3170
  ctx.save();
3001
3171
  renderRanges.forEach((range) => {
@@ -3021,22 +3191,40 @@ var ConditionalFormattingIcon = class extends SheetExtension {
3021
3191
  const borderHeight = endY - startY;
3022
3192
  if (this._width > borderHeight || this._width > borderWidth + this._paddingRightAndLeft * 2) return;
3023
3193
  const y = (borderHeight - this._width) / 2 + startY;
3024
- ctx.drawImage(icon, startX + this._paddingRightAndLeft, y, this._width, this._width);
3194
+ this._drawIcon(ctx, icon, startX + this._paddingRightAndLeft, y);
3025
3195
  });
3026
3196
  });
3027
3197
  ctx.restore();
3028
3198
  }
3029
3199
  dispose() {
3200
+ this._rasterCache.dispose();
3201
+ for (const image of this._pendingImages) image.onload = null;
3202
+ this._pendingImages.clear();
3203
+ this._imageMap.clear();
3030
3204
  this._renderRangeResolver = null;
3031
3205
  super.dispose();
3032
3206
  }
3207
+ _drawIcon(ctx, image, x, y) {
3208
+ if (!ctx._context || ctx.__mode === "printing" || ctx.getSystemType() !== "Linux") {
3209
+ ctx.drawImage(image, x, y, this._width, this._width);
3210
+ return;
3211
+ }
3212
+ this._rasterCache.draw(ctx, x, y, this._width, this._width, image.src, (paint, left, top) => {
3213
+ paint.drawImage(image, left, top, this._width, this._width);
3214
+ });
3215
+ }
3033
3216
  _init() {
3034
3217
  for (const type in iconMap) iconMap[type].forEach((base64, index) => {
3035
3218
  const key = this._createKey(type, String(index));
3036
3219
  const image = new Image();
3037
3220
  image.onload = () => {
3221
+ var _this$parent;
3222
+ image.onload = null;
3223
+ this._pendingImages.delete(image);
3038
3224
  this._imageMap.set(key, image);
3225
+ (_this$parent = this.parent) === null || _this$parent === void 0 || _this$parent.makeDirty(true);
3039
3226
  };
3227
+ this._pendingImages.add(image);
3040
3228
  image.src = base64;
3041
3229
  });
3042
3230
  }
package/lib/facade.js CHANGED
@@ -3,7 +3,7 @@ import { AddCfCommand, CFNumberOperator, CFRuleType, CFSubRuleType, CFTextOperat
3
3
  import { FRange, FWorksheet } from "@univerjs/sheets/facade";
4
4
  import { FEnum } from "@univerjs/core/facade";
5
5
 
6
- // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
6
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
7
7
  function _typeof(o) {
8
8
  "@babel/helpers - typeof";
9
9
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -13,25 +13,25 @@ function _typeof(o) {
13
13
  }, _typeof(o);
14
14
  }
15
15
 
16
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
17
- function toPrimitive(t, r) {
16
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
17
+ function toPrimitive(t, e) {
18
18
  if ("object" != _typeof(t) || !t) return t;
19
- var e = t[Symbol.toPrimitive];
20
- if (void 0 !== e) {
21
- var i = e.call(t, r || "default");
19
+ var r;
20
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
21
+ var i = r.call(t, e || "default");
22
22
  if ("object" != _typeof(i)) return i;
23
23
  throw new TypeError("@@toPrimitive must return a primitive value.");
24
24
  }
25
- return ("string" === r ? String : Number)(t);
25
+ return ("string" === e ? String : Number)(t);
26
26
  }
27
27
 
28
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
28
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
29
29
  function toPropertyKey(t) {
30
30
  var i = toPrimitive(t, "string");
31
31
  return "symbol" == _typeof(i) ? i : i + "";
32
32
  }
33
33
 
34
- // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
34
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
35
35
  function _defineProperty(e, r, t) {
36
36
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
37
37
  value: t,