@univerjs/sheets-conditional-formatting 0.25.1 → 1.0.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/cjs/facade.js +4 -4
- package/lib/cjs/index.js +263 -181
- package/lib/cjs/locale/ar-SA.js +11 -0
- package/lib/cjs/locale/ca-ES.js +11 -0
- package/lib/cjs/locale/de-DE.js +11 -0
- package/lib/cjs/locale/en-US.js +26 -0
- package/lib/cjs/locale/es-ES.js +11 -0
- package/lib/cjs/locale/fa-IR.js +11 -0
- package/lib/cjs/locale/fr-FR.js +11 -0
- package/lib/cjs/locale/id-ID.js +11 -0
- package/lib/cjs/locale/it-IT.js +11 -0
- package/lib/cjs/locale/ja-JP.js +11 -0
- package/lib/cjs/locale/ko-KR.js +11 -0
- package/lib/cjs/locale/pl-PL.js +11 -0
- package/lib/cjs/locale/pt-BR.js +11 -0
- package/lib/cjs/locale/ru-RU.js +11 -0
- package/lib/cjs/locale/sk-SK.js +11 -0
- package/lib/cjs/locale/vi-VN.js +11 -0
- package/lib/cjs/locale/zh-CN.js +11 -0
- package/lib/cjs/locale/zh-HK.js +11 -0
- package/lib/cjs/locale/zh-TW.js +11 -0
- package/lib/es/facade.js +4 -4
- package/lib/es/index.js +252 -183
- package/lib/es/locale/ar-SA.js +10 -0
- package/lib/es/locale/ca-ES.js +10 -0
- package/lib/es/locale/de-DE.js +10 -0
- package/lib/es/locale/en-US.js +25 -0
- package/lib/es/locale/es-ES.js +10 -0
- package/lib/es/locale/fa-IR.js +10 -0
- package/lib/es/locale/fr-FR.js +10 -0
- package/lib/es/locale/id-ID.js +10 -0
- package/lib/es/locale/it-IT.js +10 -0
- package/lib/es/locale/ja-JP.js +10 -0
- package/lib/es/locale/ko-KR.js +10 -0
- package/lib/es/locale/pl-PL.js +10 -0
- package/lib/es/locale/pt-BR.js +10 -0
- package/lib/es/locale/ru-RU.js +10 -0
- package/lib/es/locale/sk-SK.js +10 -0
- package/lib/es/locale/vi-VN.js +10 -0
- package/lib/es/locale/zh-CN.js +10 -0
- package/lib/es/locale/zh-HK.js +10 -0
- package/lib/es/locale/zh-TW.js +10 -0
- package/lib/facade.js +4 -4
- package/lib/index.js +252 -183
- package/lib/locale/ar-SA.js +10 -0
- package/lib/locale/ca-ES.js +10 -0
- package/lib/locale/de-DE.js +10 -0
- package/lib/locale/en-US.js +25 -0
- package/lib/locale/es-ES.js +10 -0
- package/lib/locale/fa-IR.js +10 -0
- package/lib/locale/fr-FR.js +10 -0
- package/lib/locale/id-ID.js +10 -0
- package/lib/locale/it-IT.js +10 -0
- package/lib/locale/ja-JP.js +10 -0
- package/lib/locale/ko-KR.js +10 -0
- package/lib/locale/pl-PL.js +10 -0
- package/lib/locale/pt-BR.js +10 -0
- package/lib/locale/ru-RU.js +10 -0
- package/lib/locale/sk-SK.js +10 -0
- package/lib/locale/vi-VN.js +10 -0
- package/lib/locale/zh-CN.js +10 -0
- package/lib/locale/zh-HK.js +10 -0
- package/lib/locale/zh-TW.js +10 -0
- package/lib/types/index.d.ts +23 -11
- package/lib/types/{utils/is-ranges-equal.d.ts → locale/ar-SA.d.ts} +3 -1
- package/lib/types/locale/ca-ES.d.ts +18 -0
- package/lib/types/locale/de-DE.d.ts +18 -0
- package/lib/types/locale/en-US.d.ts +26 -0
- package/lib/types/locale/es-ES.d.ts +18 -0
- package/lib/types/locale/fa-IR.d.ts +18 -0
- package/lib/types/locale/fr-FR.d.ts +18 -0
- package/lib/types/locale/id-ID.d.ts +18 -0
- package/lib/types/locale/it-IT.d.ts +18 -0
- package/lib/types/locale/ja-JP.d.ts +18 -0
- package/lib/types/locale/ko-KR.d.ts +18 -0
- package/lib/types/locale/pl-PL.d.ts +18 -0
- package/lib/types/locale/pt-BR.d.ts +18 -0
- package/lib/types/locale/ru-RU.d.ts +18 -0
- package/lib/types/locale/sk-SK.d.ts +18 -0
- package/lib/types/locale/types.d.ts +18 -0
- package/lib/types/locale/vi-VN.d.ts +18 -0
- package/lib/types/locale/zh-CN.d.ts +18 -0
- package/lib/types/locale/zh-HK.d.ts +18 -0
- package/lib/types/locale/zh-TW.d.ts +18 -0
- package/lib/types/models/conditional-formatting-range-index-model.d.ts +32 -0
- package/lib/types/models/conditional-formatting-view-model.d.ts +3 -2
- package/lib/types/models/icon-map.d.ts +2 -1
- package/lib/types/services/conditional-formatting-range-transform.service.d.ts +27 -0
- package/lib/types/services/conditional-formatting-style-composer.service.d.ts +31 -0
- package/lib/types/services/conditional-formatting.service.d.ts +7 -7
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ar-SA.js +1 -0
- package/lib/umd/locale/ca-ES.js +1 -0
- package/lib/umd/locale/de-DE.js +1 -0
- package/lib/umd/locale/en-US.js +1 -0
- package/lib/umd/locale/es-ES.js +1 -0
- package/lib/umd/locale/fa-IR.js +1 -0
- package/lib/umd/locale/fr-FR.js +1 -0
- package/lib/umd/locale/id-ID.js +1 -0
- package/lib/umd/locale/it-IT.js +1 -0
- package/lib/umd/locale/ja-JP.js +1 -0
- package/lib/umd/locale/ko-KR.js +1 -0
- package/lib/umd/locale/pl-PL.js +1 -0
- package/lib/umd/locale/pt-BR.js +1 -0
- package/lib/umd/locale/ru-RU.js +1 -0
- package/lib/umd/locale/sk-SK.js +1 -0
- package/lib/umd/locale/vi-VN.js +1 -0
- package/lib/umd/locale/zh-CN.js +1 -0
- package/lib/umd/locale/zh-HK.js +1 -0
- package/lib/umd/locale/zh-TW.js +1 -0
- package/package.json +14 -9
- package/lib/types/models/calculate-unit-v2/__test__/test.util.d.ts +0 -38
package/lib/cjs/index.js
CHANGED
|
@@ -221,7 +221,7 @@ const isAnchorEqual = (anchor1, anchor2) => {
|
|
|
221
221
|
const createCfId = () => `${(0, _univerjs_core.generateRandomId)(8)}`;
|
|
222
222
|
|
|
223
223
|
//#endregion
|
|
224
|
-
//#region \0@oxc-project+runtime@0.
|
|
224
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
225
225
|
function _typeof(o) {
|
|
226
226
|
"@babel/helpers - typeof";
|
|
227
227
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -232,7 +232,7 @@ function _typeof(o) {
|
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
//#endregion
|
|
235
|
-
//#region \0@oxc-project+runtime@0.
|
|
235
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
236
236
|
function toPrimitive(t, r) {
|
|
237
237
|
if ("object" != _typeof(t) || !t) return t;
|
|
238
238
|
var e = t[Symbol.toPrimitive];
|
|
@@ -245,14 +245,14 @@ function toPrimitive(t, r) {
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
//#endregion
|
|
248
|
-
//#region \0@oxc-project+runtime@0.
|
|
248
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
249
249
|
function toPropertyKey(t) {
|
|
250
250
|
var i = toPrimitive(t, "string");
|
|
251
251
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
//#endregion
|
|
255
|
-
//#region \0@oxc-project+runtime@0.
|
|
255
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
256
256
|
function _defineProperty(e, r, t) {
|
|
257
257
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
258
258
|
value: t,
|
|
@@ -512,6 +512,146 @@ const AddCfCommand = {
|
|
|
512
512
|
}
|
|
513
513
|
};
|
|
514
514
|
|
|
515
|
+
//#endregion
|
|
516
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
517
|
+
function __decorateParam(paramIndex, decorator) {
|
|
518
|
+
return function(target, key) {
|
|
519
|
+
decorator(target, key, paramIndex);
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
525
|
+
function __decorate(decorators, target, key, desc) {
|
|
526
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
527
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
528
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
529
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
//#endregion
|
|
533
|
+
//#region src/models/conditional-formatting-range-index-model.ts
|
|
534
|
+
let ConditionalFormattingRangeIndexModel = class ConditionalFormattingRangeIndexModel extends _univerjs_core.Disposable {
|
|
535
|
+
constructor(_conditionalFormattingRuleModel) {
|
|
536
|
+
super();
|
|
537
|
+
this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
|
|
538
|
+
_defineProperty(this, "_rTreeManager", new _univerjs_core.RTree());
|
|
539
|
+
this.rebuild();
|
|
540
|
+
this._initRuleListener();
|
|
541
|
+
}
|
|
542
|
+
getRuleIdsByCell(unitId, subUnitId, row, col) {
|
|
543
|
+
return this.getRuleIdsByRanges(unitId, subUnitId, [{
|
|
544
|
+
startRow: row,
|
|
545
|
+
endRow: row,
|
|
546
|
+
startColumn: col,
|
|
547
|
+
endColumn: col
|
|
548
|
+
}]);
|
|
549
|
+
}
|
|
550
|
+
getRuleIdsByRanges(unitId, subUnitId, ranges) {
|
|
551
|
+
if (!ranges.length) return /* @__PURE__ */ new Set();
|
|
552
|
+
const ids = this._rTreeManager.bulkSearch(ranges.map((range) => ({
|
|
553
|
+
unitId,
|
|
554
|
+
sheetId: subUnitId,
|
|
555
|
+
range
|
|
556
|
+
})));
|
|
557
|
+
return new Set(Array.from(ids).map((id) => String(id)));
|
|
558
|
+
}
|
|
559
|
+
getRulesByRanges(unitId, subUnitId, ranges) {
|
|
560
|
+
var _this$_conditionalFor;
|
|
561
|
+
const ids = this.getRuleIdsByRanges(unitId, subUnitId, ranges);
|
|
562
|
+
return ((_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : []).filter((rule) => ids.has(rule.cfId));
|
|
563
|
+
}
|
|
564
|
+
dispose() {
|
|
565
|
+
this.clear();
|
|
566
|
+
super.dispose();
|
|
567
|
+
}
|
|
568
|
+
clear() {
|
|
569
|
+
this._rTreeManager.clear();
|
|
570
|
+
}
|
|
571
|
+
rebuild() {
|
|
572
|
+
this.clear();
|
|
573
|
+
this._conditionalFormattingRuleModel.getAll().forEach((subUnitMap, unitId) => {
|
|
574
|
+
subUnitMap.forEach((rules, subUnitId) => {
|
|
575
|
+
rules.forEach((rule) => {
|
|
576
|
+
this._insert(unitId, subUnitId, rule.cfId, rule.ranges);
|
|
577
|
+
});
|
|
578
|
+
});
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
_initRuleListener() {
|
|
582
|
+
this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe((e) => {
|
|
583
|
+
const { unitId, subUnitId, rule } = e;
|
|
584
|
+
const { cfId, ranges } = rule;
|
|
585
|
+
switch (e.type) {
|
|
586
|
+
case "add":
|
|
587
|
+
this._insert(unitId, subUnitId, cfId, ranges);
|
|
588
|
+
break;
|
|
589
|
+
case "delete":
|
|
590
|
+
this._remove(unitId, subUnitId, cfId, ranges);
|
|
591
|
+
break;
|
|
592
|
+
case "set": {
|
|
593
|
+
const oldRule = e.oldRule;
|
|
594
|
+
this._remove(unitId, subUnitId, oldRule.cfId, oldRule.ranges);
|
|
595
|
+
this._insert(unitId, subUnitId, cfId, ranges);
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}));
|
|
600
|
+
}
|
|
601
|
+
_insert(unitId, subUnitId, cfId, ranges) {
|
|
602
|
+
this._rTreeManager.bulkInsert(ranges.map((range) => ({
|
|
603
|
+
unitId,
|
|
604
|
+
sheetId: subUnitId,
|
|
605
|
+
id: cfId,
|
|
606
|
+
range
|
|
607
|
+
})));
|
|
608
|
+
}
|
|
609
|
+
_remove(unitId, subUnitId, cfId, ranges) {
|
|
610
|
+
this._rTreeManager.bulkRemove(ranges.map((range) => ({
|
|
611
|
+
unitId,
|
|
612
|
+
sheetId: subUnitId,
|
|
613
|
+
id: cfId,
|
|
614
|
+
range
|
|
615
|
+
})));
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
ConditionalFormattingRangeIndexModel = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(ConditionalFormattingRuleModel))], ConditionalFormattingRangeIndexModel);
|
|
619
|
+
|
|
620
|
+
//#endregion
|
|
621
|
+
//#region src/services/conditional-formatting-range-transform.service.ts
|
|
622
|
+
var ConditionalFormattingRangeTransformService = class {
|
|
623
|
+
subtractRanges(sourceRanges, rangesToSubtract) {
|
|
624
|
+
return _univerjs_core.Rectangle.mergeRanges(_univerjs_core.Rectangle.subtractMulti(sourceRanges, rangesToSubtract));
|
|
625
|
+
}
|
|
626
|
+
addRanges(sourceRanges, rangesToAdd) {
|
|
627
|
+
return _univerjs_core.Rectangle.mergeRanges([...sourceRanges, ...rangesToAdd]);
|
|
628
|
+
}
|
|
629
|
+
applyRangeDelta(sourceRanges, rangesToSubtract, rangesToAdd) {
|
|
630
|
+
const ranges = rangesToSubtract.length ? this.subtractRanges(sourceRanges, rangesToSubtract) : sourceRanges;
|
|
631
|
+
return rangesToAdd.length ? this.addRanges(ranges, rangesToAdd) : ranges;
|
|
632
|
+
}
|
|
633
|
+
copyIntersectingRanges(sourceRanges, sourceRange, targetAnchor) {
|
|
634
|
+
const fragments = [];
|
|
635
|
+
sourceRanges.forEach((range) => {
|
|
636
|
+
const intersect = _univerjs_core.Rectangle.getIntersects(range, sourceRange);
|
|
637
|
+
if (!intersect) return;
|
|
638
|
+
fragments.push(this.translateRange(intersect, {
|
|
639
|
+
row: targetAnchor.row - sourceRange.startRow,
|
|
640
|
+
col: targetAnchor.col - sourceRange.startColumn
|
|
641
|
+
}));
|
|
642
|
+
});
|
|
643
|
+
return _univerjs_core.Rectangle.mergeRanges(fragments);
|
|
644
|
+
}
|
|
645
|
+
translateRange(range, offset) {
|
|
646
|
+
return {
|
|
647
|
+
startRow: range.startRow + offset.row,
|
|
648
|
+
endRow: range.endRow + offset.row,
|
|
649
|
+
startColumn: range.startColumn + offset.col,
|
|
650
|
+
endColumn: range.endColumn + offset.col
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
|
|
515
655
|
//#endregion
|
|
516
656
|
//#region src/commands/mutations/set-conditional-rule.mutation.ts
|
|
517
657
|
const SetConditionalRuleMutation = {
|
|
@@ -548,9 +688,10 @@ const ClearRangeCfCommand = {
|
|
|
548
688
|
type: _univerjs_core.CommandType.COMMAND,
|
|
549
689
|
id: "sheet.command.clear-range-conditional-rule",
|
|
550
690
|
handler(accessor, params) {
|
|
551
|
-
var _selectionManagerServ;
|
|
691
|
+
var _ref, _params$ranges, _selectionManagerServ;
|
|
552
692
|
if (!params) return false;
|
|
553
|
-
const
|
|
693
|
+
const conditionalFormattingRangeIndexModel = accessor.get(ConditionalFormattingRangeIndexModel);
|
|
694
|
+
const conditionalFormattingRangeTransformService = accessor.get(ConditionalFormattingRangeTransformService);
|
|
554
695
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
555
696
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
556
697
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
@@ -558,24 +699,13 @@ const ClearRangeCfCommand = {
|
|
|
558
699
|
const target = (0, _univerjs_sheets.getSheetCommandTarget)(univerInstanceService, params);
|
|
559
700
|
if (!target) return false;
|
|
560
701
|
const { unitId, subUnitId } = target;
|
|
561
|
-
const ranges = ((_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((selection) => selection.range))
|
|
562
|
-
const allRuleList =
|
|
702
|
+
const ranges = (_ref = (_params$ranges = params.ranges) !== null && _params$ranges !== void 0 ? _params$ranges : (_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((selection) => selection.range)) !== null && _ref !== void 0 ? _ref : [];
|
|
703
|
+
const allRuleList = conditionalFormattingRangeIndexModel.getRulesByRanges(unitId, subUnitId, ranges);
|
|
563
704
|
if (!(allRuleList === null || allRuleList === void 0 ? void 0 : allRuleList.length) || !ranges.length) return false;
|
|
564
705
|
const redos = [];
|
|
565
706
|
const undos = [];
|
|
566
707
|
allRuleList.forEach((oldRule) => {
|
|
567
|
-
const
|
|
568
|
-
oldRule.ranges.forEach((range) => {
|
|
569
|
-
_univerjs_core.Range.foreach(range, (row, col) => {
|
|
570
|
-
matrix.setValue(row, col, 1);
|
|
571
|
-
});
|
|
572
|
-
});
|
|
573
|
-
ranges.forEach((range) => {
|
|
574
|
-
_univerjs_core.Range.foreach(range, (row, col) => {
|
|
575
|
-
matrix.realDeleteValue(row, col);
|
|
576
|
-
});
|
|
577
|
-
});
|
|
578
|
-
const newRanges = (0, _univerjs_sheets.findAllRectangle)((0, _univerjs_sheets.createTopMatrixFromMatrix)(matrix));
|
|
708
|
+
const newRanges = conditionalFormattingRangeTransformService.subtractRanges(oldRule.ranges, ranges);
|
|
579
709
|
if (newRanges.length) {
|
|
580
710
|
const params = {
|
|
581
711
|
unitId,
|
|
@@ -750,23 +880,6 @@ const SetCfCommand = {
|
|
|
750
880
|
}
|
|
751
881
|
};
|
|
752
882
|
|
|
753
|
-
//#endregion
|
|
754
|
-
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
|
|
755
|
-
function __decorateParam(paramIndex, decorator) {
|
|
756
|
-
return function(target, key) {
|
|
757
|
-
decorator(target, key, paramIndex);
|
|
758
|
-
};
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
//#endregion
|
|
762
|
-
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
|
|
763
|
-
function __decorate(decorators, target, key, desc) {
|
|
764
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
765
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
766
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
767
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
768
|
-
}
|
|
769
|
-
|
|
770
883
|
//#endregion
|
|
771
884
|
//#region src/services/conditional-formatting-formula.service.ts
|
|
772
885
|
let ConditionalFormattingFormulaService = class ConditionalFormattingFormulaService extends _univerjs_core.Disposable {
|
|
@@ -1671,14 +1784,14 @@ var IconSetCalculateUnit = class extends BaseCalculateUnit {
|
|
|
1671
1784
|
//#region src/models/conditional-formatting-view-model.ts
|
|
1672
1785
|
const CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH = 1e3 * 3 * 3;
|
|
1673
1786
|
let ConditionalFormattingViewModel = class ConditionalFormattingViewModel extends _univerjs_core.Disposable {
|
|
1674
|
-
constructor(_injector, _conditionalFormattingRuleModel, _conditionalFormattingFormulaService, _univerInstanceService) {
|
|
1787
|
+
constructor(_injector, _conditionalFormattingRuleModel, _conditionalFormattingRangeIndexModel, _conditionalFormattingFormulaService, _univerInstanceService) {
|
|
1675
1788
|
super();
|
|
1676
1789
|
this._injector = _injector;
|
|
1677
1790
|
this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
|
|
1791
|
+
this._conditionalFormattingRangeIndexModel = _conditionalFormattingRangeIndexModel;
|
|
1678
1792
|
this._conditionalFormattingFormulaService = _conditionalFormattingFormulaService;
|
|
1679
1793
|
this._univerInstanceService = _univerInstanceService;
|
|
1680
1794
|
_defineProperty(this, "_calculateUnitManagers", /* @__PURE__ */ new Map());
|
|
1681
|
-
_defineProperty(this, "_rTreeManager", new _univerjs_core.RTree());
|
|
1682
1795
|
_defineProperty(this, "_cellCache", new _univerjs_core.LRUMap(CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH));
|
|
1683
1796
|
_defineProperty(this, "_markDirty$", new rxjs.Subject());
|
|
1684
1797
|
_defineProperty(this, "markDirty$", this._markDirty$.asObservable());
|
|
@@ -1746,16 +1859,7 @@ let ConditionalFormattingViewModel = class ConditionalFormattingViewModel extend
|
|
|
1746
1859
|
var _this$_conditionalFor;
|
|
1747
1860
|
const subunitRules = (_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : [];
|
|
1748
1861
|
const _calculateUnitManagers = this._ensureCalculateUnitManager(unitId, subUnitId);
|
|
1749
|
-
const list = this.
|
|
1750
|
-
unitId,
|
|
1751
|
-
sheetId: subUnitId,
|
|
1752
|
-
range: {
|
|
1753
|
-
startColumn: col,
|
|
1754
|
-
endColumn: col,
|
|
1755
|
-
startRow: row,
|
|
1756
|
-
endRow: row
|
|
1757
|
-
}
|
|
1758
|
-
}]);
|
|
1862
|
+
const list = this._conditionalFormattingRangeIndexModel.getRuleIdsByCell(unitId, subUnitId, row, col);
|
|
1759
1863
|
const rules = subunitRules.filter((rule) => list.has(rule.cfId));
|
|
1760
1864
|
if (!rules.length) return [];
|
|
1761
1865
|
return rules.map((rule) => {
|
|
@@ -1777,7 +1881,6 @@ let ConditionalFormattingViewModel = class ConditionalFormattingViewModel extend
|
|
|
1777
1881
|
clearCache() {
|
|
1778
1882
|
this._calculateUnitManagers.clear();
|
|
1779
1883
|
this._cellCache.clear();
|
|
1780
|
-
this._rTreeManager.clear();
|
|
1781
1884
|
}
|
|
1782
1885
|
_handleCustomFormulasSeparately() {
|
|
1783
1886
|
this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe((e) => {
|
|
@@ -1796,40 +1899,16 @@ let ConditionalFormattingViewModel = class ConditionalFormattingViewModel extend
|
|
|
1796
1899
|
this.markRuleDirty(unitId, subUnitId, cfId);
|
|
1797
1900
|
switch (e.type) {
|
|
1798
1901
|
case "add": {
|
|
1799
|
-
this._rTreeManager.bulkInsert(ranges.map((r) => ({
|
|
1800
|
-
unitId,
|
|
1801
|
-
sheetId: subUnitId,
|
|
1802
|
-
id: cfId,
|
|
1803
|
-
range: r
|
|
1804
|
-
})));
|
|
1805
1902
|
const instance = this._createRuleCalculateUnitInstance(unitId, subUnitId, rule);
|
|
1806
1903
|
if (!instance) return;
|
|
1807
1904
|
calculateUnitManager.set(rule.cfId, instance);
|
|
1808
1905
|
break;
|
|
1809
1906
|
}
|
|
1810
1907
|
case "delete":
|
|
1811
|
-
this._rTreeManager.bulkRemove(ranges.map((r) => ({
|
|
1812
|
-
unitId,
|
|
1813
|
-
sheetId: subUnitId,
|
|
1814
|
-
id: cfId,
|
|
1815
|
-
range: r
|
|
1816
|
-
})));
|
|
1817
1908
|
calculateUnitManager.delete(rule.cfId);
|
|
1818
1909
|
break;
|
|
1819
1910
|
case "set": {
|
|
1820
1911
|
const oldRule = e.oldRule;
|
|
1821
|
-
this._rTreeManager.bulkRemove(oldRule.ranges.map((r) => ({
|
|
1822
|
-
unitId,
|
|
1823
|
-
sheetId: subUnitId,
|
|
1824
|
-
id: oldRule.cfId,
|
|
1825
|
-
range: r
|
|
1826
|
-
})));
|
|
1827
|
-
this._rTreeManager.bulkInsert(ranges.map((r) => ({
|
|
1828
|
-
unitId,
|
|
1829
|
-
sheetId: subUnitId,
|
|
1830
|
-
id: cfId,
|
|
1831
|
-
range: r
|
|
1832
|
-
})));
|
|
1833
1912
|
if (oldRule.rule.type !== rule.rule.type) {
|
|
1834
1913
|
const instance = this._createRuleCalculateUnitInstance(unitId, subUnitId, rule);
|
|
1835
1914
|
if (!instance) return;
|
|
@@ -1896,8 +1975,9 @@ let ConditionalFormattingViewModel = class ConditionalFormattingViewModel extend
|
|
|
1896
1975
|
ConditionalFormattingViewModel = __decorate([
|
|
1897
1976
|
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
1898
1977
|
__decorateParam(1, (0, _univerjs_core.Inject)(ConditionalFormattingRuleModel)),
|
|
1899
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(
|
|
1900
|
-
__decorateParam(3, _univerjs_core.
|
|
1978
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(ConditionalFormattingRangeIndexModel)),
|
|
1979
|
+
__decorateParam(3, (0, _univerjs_core.Inject)(ConditionalFormattingFormulaService)),
|
|
1980
|
+
__decorateParam(4, _univerjs_core.IUniverInstanceService)
|
|
1901
1981
|
], ConditionalFormattingViewModel);
|
|
1902
1982
|
|
|
1903
1983
|
//#endregion
|
|
@@ -2213,21 +2293,6 @@ const ICON_MAP = {
|
|
|
2213
2293
|
|
|
2214
2294
|
//#endregion
|
|
2215
2295
|
//#region src/models/icon-map.ts
|
|
2216
|
-
/**
|
|
2217
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
2218
|
-
*
|
|
2219
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2220
|
-
* you may not use this file except in compliance with the License.
|
|
2221
|
-
* You may obtain a copy of the License at
|
|
2222
|
-
*
|
|
2223
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2224
|
-
*
|
|
2225
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2226
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2227
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2228
|
-
* See the License for the specific language governing permissions and
|
|
2229
|
-
* limitations under the License.
|
|
2230
|
-
*/
|
|
2231
2296
|
let IIconSetType = /* @__PURE__ */ function(IIconSetType) {
|
|
2232
2297
|
IIconSetType["threeArrows"] = "3Arrows";
|
|
2233
2298
|
IIconSetType["threeArrowsGray"] = "3ArrowsGray";
|
|
@@ -2255,7 +2320,7 @@ let IIconSetType = /* @__PURE__ */ function(IIconSetType) {
|
|
|
2255
2320
|
}({});
|
|
2256
2321
|
const iconGroup = [
|
|
2257
2322
|
{
|
|
2258
|
-
title: "
|
|
2323
|
+
title: "sheets-conditional-formatting.iconSet.direction",
|
|
2259
2324
|
group: [
|
|
2260
2325
|
{
|
|
2261
2326
|
name: "3Arrows",
|
|
@@ -2322,7 +2387,7 @@ const iconGroup = [
|
|
|
2322
2387
|
]
|
|
2323
2388
|
},
|
|
2324
2389
|
{
|
|
2325
|
-
title: "
|
|
2390
|
+
title: "sheets-conditional-formatting.iconSet.shape",
|
|
2326
2391
|
group: [
|
|
2327
2392
|
{
|
|
2328
2393
|
name: "3TrafficLights1",
|
|
@@ -2369,7 +2434,7 @@ const iconGroup = [
|
|
|
2369
2434
|
]
|
|
2370
2435
|
},
|
|
2371
2436
|
{
|
|
2372
|
-
title: "
|
|
2437
|
+
title: "sheets-conditional-formatting.iconSet.mark",
|
|
2373
2438
|
group: [
|
|
2374
2439
|
{
|
|
2375
2440
|
name: "3Symbols",
|
|
@@ -2398,7 +2463,7 @@ const iconGroup = [
|
|
|
2398
2463
|
]
|
|
2399
2464
|
},
|
|
2400
2465
|
{
|
|
2401
|
-
title: "
|
|
2466
|
+
title: "sheets-conditional-formatting.iconSet.rank",
|
|
2402
2467
|
group: [
|
|
2403
2468
|
{
|
|
2404
2469
|
name: "4Rating",
|
|
@@ -2473,7 +2538,7 @@ for (const key in iconMap) {
|
|
|
2473
2538
|
//#endregion
|
|
2474
2539
|
//#region package.json
|
|
2475
2540
|
var name = "@univerjs/sheets-conditional-formatting";
|
|
2476
|
-
var version = "0.
|
|
2541
|
+
var version = "1.0.0-alpha.1";
|
|
2477
2542
|
|
|
2478
2543
|
//#endregion
|
|
2479
2544
|
//#region src/config/config.ts
|
|
@@ -2497,10 +2562,34 @@ const configSymbol = Symbol(SHEETS_CONDITIONAL_FORMATTING_PLUGIN_CONFIG_KEY);
|
|
|
2497
2562
|
const defaultPluginConfig = {};
|
|
2498
2563
|
|
|
2499
2564
|
//#endregion
|
|
2500
|
-
//#region src/services/conditional-formatting.service.ts
|
|
2501
|
-
let
|
|
2502
|
-
|
|
2503
|
-
|
|
2565
|
+
//#region src/services/conditional-formatting-style-composer.service.ts
|
|
2566
|
+
let ConditionalFormattingStyleComposer = class ConditionalFormattingStyleComposer {
|
|
2567
|
+
constructor(_conditionalFormattingRuleModel, _conditionalFormattingViewModel) {
|
|
2568
|
+
this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
|
|
2569
|
+
this._conditionalFormattingViewModel = _conditionalFormattingViewModel;
|
|
2570
|
+
}
|
|
2571
|
+
composeStyle(unitId, subUnitId, row, col) {
|
|
2572
|
+
const cellCfs = this._conditionalFormattingViewModel.getCellCfs(unitId, subUnitId, row, col);
|
|
2573
|
+
if (!(cellCfs === null || cellCfs === void 0 ? void 0 : cellCfs.length)) return null;
|
|
2574
|
+
const matchedRules = [];
|
|
2575
|
+
let stopIfTrueIndex = -1;
|
|
2576
|
+
for (const cacheItem of cellCfs) {
|
|
2577
|
+
const rule = this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, cacheItem.cfId);
|
|
2578
|
+
if (!rule) continue;
|
|
2579
|
+
matchedRules.push({
|
|
2580
|
+
rule,
|
|
2581
|
+
cacheItem
|
|
2582
|
+
});
|
|
2583
|
+
if (stopIfTrueIndex === -1 && rule.stopIfTrue && this._isRuleMatched(rule, cacheItem.result)) stopIfTrueIndex = matchedRules.length - 1;
|
|
2584
|
+
}
|
|
2585
|
+
if (!matchedRules.length) return null;
|
|
2586
|
+
const effectiveRules = stopIfTrueIndex > -1 ? matchedRules.slice(0, stopIfTrueIndex + 1) : matchedRules;
|
|
2587
|
+
const result = {};
|
|
2588
|
+
for (let i = effectiveRules.length - 1; i >= 0; i--) {
|
|
2589
|
+
const { rule, cacheItem } = effectiveRules[i];
|
|
2590
|
+
this._mergeComposeResult(result, rule, cacheItem.result);
|
|
2591
|
+
}
|
|
2592
|
+
return result;
|
|
2504
2593
|
}
|
|
2505
2594
|
_mergeComposeResult(result, rule, ruleResult) {
|
|
2506
2595
|
const type = rule.rule.type;
|
|
@@ -2531,9 +2620,24 @@ let ConditionalFormattingService = class ConditionalFormattingService extends _u
|
|
|
2531
2620
|
}
|
|
2532
2621
|
}
|
|
2533
2622
|
}
|
|
2534
|
-
|
|
2623
|
+
_isRuleMatched(rule, ruleResult) {
|
|
2624
|
+
if (rule.rule.type === "highlightCell") return !!ruleResult && typeof ruleResult === "object" && Object.keys(ruleResult).length > 0;
|
|
2625
|
+
return !!ruleResult;
|
|
2626
|
+
}
|
|
2627
|
+
};
|
|
2628
|
+
ConditionalFormattingStyleComposer = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(ConditionalFormattingRuleModel)), __decorateParam(1, (0, _univerjs_core.Inject)(ConditionalFormattingViewModel))], ConditionalFormattingStyleComposer);
|
|
2629
|
+
|
|
2630
|
+
//#endregion
|
|
2631
|
+
//#region src/services/conditional-formatting.service.ts
|
|
2632
|
+
let ConditionalFormattingService = class ConditionalFormattingService extends _univerjs_core.Disposable {
|
|
2633
|
+
get _conditionalFormattingViewModelV2() {
|
|
2634
|
+
return this._injector.get(ConditionalFormattingViewModel);
|
|
2635
|
+
}
|
|
2636
|
+
constructor(_conditionalFormattingRuleModel, _conditionalFormattingRangeIndexModel, _conditionalFormattingStyleComposer, _injector, _univerInstanceService, _resourceManagerService, _sheetInterceptorService, _commandService) {
|
|
2535
2637
|
super();
|
|
2536
2638
|
this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
|
|
2639
|
+
this._conditionalFormattingRangeIndexModel = _conditionalFormattingRangeIndexModel;
|
|
2640
|
+
this._conditionalFormattingStyleComposer = _conditionalFormattingStyleComposer;
|
|
2537
2641
|
this._injector = _injector;
|
|
2538
2642
|
this._univerInstanceService = _univerInstanceService;
|
|
2539
2643
|
this._resourceManagerService = _resourceManagerService;
|
|
@@ -2544,31 +2648,7 @@ let ConditionalFormattingService = class ConditionalFormattingService extends _u
|
|
|
2544
2648
|
this._initSheetChange();
|
|
2545
2649
|
}
|
|
2546
2650
|
composeStyle(unitId, subUnitId, row, col) {
|
|
2547
|
-
|
|
2548
|
-
if (!(cellCfs === null || cellCfs === void 0 ? void 0 : cellCfs.length)) return null;
|
|
2549
|
-
const matchedRules = [];
|
|
2550
|
-
let stopIfTrueIndex = -1;
|
|
2551
|
-
for (const cacheItem of cellCfs) {
|
|
2552
|
-
const rule = this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, cacheItem.cfId);
|
|
2553
|
-
if (!rule) continue;
|
|
2554
|
-
matchedRules.push({
|
|
2555
|
-
rule,
|
|
2556
|
-
cacheItem
|
|
2557
|
-
});
|
|
2558
|
-
if (stopIfTrueIndex === -1 && rule.stopIfTrue && this._isRuleMatched(rule, cacheItem.result)) stopIfTrueIndex = matchedRules.length - 1;
|
|
2559
|
-
}
|
|
2560
|
-
if (!matchedRules.length) return null;
|
|
2561
|
-
const effectiveRules = stopIfTrueIndex > -1 ? matchedRules.slice(0, stopIfTrueIndex + 1) : matchedRules;
|
|
2562
|
-
const result = {};
|
|
2563
|
-
for (let i = effectiveRules.length - 1; i >= 0; i--) {
|
|
2564
|
-
const { rule, cacheItem } = effectiveRules[i];
|
|
2565
|
-
this._mergeComposeResult(result, rule, cacheItem.result);
|
|
2566
|
-
}
|
|
2567
|
-
return result;
|
|
2568
|
-
}
|
|
2569
|
-
_isRuleMatched(rule, ruleResult) {
|
|
2570
|
-
if (rule.rule.type === "highlightCell") return !!ruleResult && typeof ruleResult === "object" && Object.keys(ruleResult).length > 0;
|
|
2571
|
-
return !!ruleResult;
|
|
2651
|
+
return this._conditionalFormattingStyleComposer.composeStyle(unitId, subUnitId, row, col);
|
|
2572
2652
|
}
|
|
2573
2653
|
_initSnapshot() {
|
|
2574
2654
|
const toJson = (unitID) => {
|
|
@@ -2597,6 +2677,7 @@ let ConditionalFormattingService = class ConditionalFormattingService extends _u
|
|
|
2597
2677
|
parseJson: (json) => parseJson(json),
|
|
2598
2678
|
onUnLoad: (unitID) => {
|
|
2599
2679
|
this._conditionalFormattingRuleModel.deleteUnitId(unitID);
|
|
2680
|
+
this._conditionalFormattingRangeIndexModel.rebuild();
|
|
2600
2681
|
if ((0, _univerjs_core.isInternalEditorID)(unitID)) return;
|
|
2601
2682
|
this._conditionalFormattingViewModelV2.clearCache();
|
|
2602
2683
|
},
|
|
@@ -2686,29 +2767,24 @@ let ConditionalFormattingService = class ConditionalFormattingService extends _u
|
|
|
2686
2767
|
}
|
|
2687
2768
|
_initCellChange() {
|
|
2688
2769
|
this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
|
|
2689
|
-
const
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
const ruleItem = this._conditionalFormattingViewModelV2.getCellCfs(unitId, subUnitId, row, col);
|
|
2693
|
-
ruleItem === null || ruleItem === void 0 || ruleItem.forEach((item) => ruleIds.add(item.cfId));
|
|
2770
|
+
const markRulesDirtyByRanges = (unitId, subUnitId, ranges) => {
|
|
2771
|
+
this._conditionalFormattingRangeIndexModel.getRulesByRanges(unitId, subUnitId, ranges).forEach((rule) => {
|
|
2772
|
+
this._conditionalFormattingViewModelV2.markRuleDirty(unitId, subUnitId, rule.cfId);
|
|
2694
2773
|
});
|
|
2695
|
-
const rules = [];
|
|
2696
|
-
for (const cfId of ruleIds) {
|
|
2697
|
-
const rule = this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, cfId);
|
|
2698
|
-
if (rule) rules.push(rule);
|
|
2699
|
-
}
|
|
2700
|
-
return rules;
|
|
2701
2774
|
};
|
|
2702
2775
|
switch (commandInfo.id) {
|
|
2703
2776
|
case _univerjs_sheets.SetRangeValuesMutation.id: {
|
|
2704
2777
|
const { subUnitId, unitId, cellValue } = commandInfo.params;
|
|
2705
|
-
const
|
|
2778
|
+
const ranges = [];
|
|
2706
2779
|
new _univerjs_core.ObjectMatrix(cellValue).forValue((row, col, value) => {
|
|
2707
|
-
if (value && Object.keys(value).some((key) => ["p", "v"].includes(key)))
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2780
|
+
if (value && Object.keys(value).some((key) => ["p", "v"].includes(key))) ranges.push({
|
|
2781
|
+
startRow: row,
|
|
2782
|
+
endRow: row,
|
|
2783
|
+
startColumn: col,
|
|
2784
|
+
endColumn: col
|
|
2785
|
+
});
|
|
2711
2786
|
});
|
|
2787
|
+
markRulesDirtyByRanges(unitId, subUnitId, ranges);
|
|
2712
2788
|
break;
|
|
2713
2789
|
}
|
|
2714
2790
|
case _univerjs_sheets.InsertColMutation.id:
|
|
@@ -2718,14 +2794,10 @@ let ConditionalFormattingService = class ConditionalFormattingService extends _u
|
|
|
2718
2794
|
if (!target) return;
|
|
2719
2795
|
const { worksheet, unitId, subUnitId } = target;
|
|
2720
2796
|
const { range } = params;
|
|
2721
|
-
|
|
2797
|
+
markRulesDirtyByRanges(unitId, subUnitId, [{
|
|
2722
2798
|
...range,
|
|
2723
2799
|
endColumn: worksheet.getColumnCount() - 1
|
|
2724
|
-
};
|
|
2725
|
-
const allRules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId);
|
|
2726
|
-
if (allRules) allRules.filter((rule) => rule.ranges.some((ruleRange) => _univerjs_core.Rectangle.intersects(ruleRange, effectRange))).forEach((rule) => {
|
|
2727
|
-
this._conditionalFormattingViewModelV2.markRuleDirty(unitId, subUnitId, rule.cfId);
|
|
2728
|
-
});
|
|
2800
|
+
}]);
|
|
2729
2801
|
break;
|
|
2730
2802
|
}
|
|
2731
2803
|
case _univerjs_sheets.RemoveRowMutation.id:
|
|
@@ -2735,14 +2807,10 @@ let ConditionalFormattingService = class ConditionalFormattingService extends _u
|
|
|
2735
2807
|
if (!target) return;
|
|
2736
2808
|
const { worksheet, unitId, subUnitId } = target;
|
|
2737
2809
|
const { range } = params;
|
|
2738
|
-
|
|
2810
|
+
markRulesDirtyByRanges(unitId, subUnitId, [{
|
|
2739
2811
|
...range,
|
|
2740
2812
|
endRow: worksheet.getRowCount() - 1
|
|
2741
|
-
};
|
|
2742
|
-
const allRules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId);
|
|
2743
|
-
if (allRules) allRules.filter((rule) => rule.ranges.some((ruleRange) => _univerjs_core.Rectangle.intersects(ruleRange, effectRange))).forEach((rule) => {
|
|
2744
|
-
this._conditionalFormattingViewModelV2.markRuleDirty(unitId, subUnitId, rule.cfId);
|
|
2745
|
-
});
|
|
2813
|
+
}]);
|
|
2746
2814
|
break;
|
|
2747
2815
|
}
|
|
2748
2816
|
case _univerjs_sheets.MoveRowsMutation.id: {
|
|
@@ -2751,16 +2819,12 @@ let ConditionalFormattingService = class ConditionalFormattingService extends _u
|
|
|
2751
2819
|
if (!target) return;
|
|
2752
2820
|
const { worksheet, unitId, subUnitId } = target;
|
|
2753
2821
|
const { sourceRange, targetRange } = params;
|
|
2754
|
-
|
|
2822
|
+
markRulesDirtyByRanges(unitId, subUnitId, [{
|
|
2755
2823
|
startRow: Math.min(sourceRange.startRow, targetRange.startRow),
|
|
2756
2824
|
endRow: worksheet.getRowCount() - 1,
|
|
2757
2825
|
startColumn: 0,
|
|
2758
2826
|
endColumn: worksheet.getColumnCount() - 1
|
|
2759
|
-
};
|
|
2760
|
-
const allRules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId);
|
|
2761
|
-
if (allRules) allRules.filter((rule) => rule.ranges.some((ruleRange) => _univerjs_core.Rectangle.intersects(ruleRange, effectRange))).forEach((rule) => {
|
|
2762
|
-
this._conditionalFormattingViewModelV2.markRuleDirty(unitId, subUnitId, rule.cfId);
|
|
2763
|
-
});
|
|
2827
|
+
}]);
|
|
2764
2828
|
break;
|
|
2765
2829
|
}
|
|
2766
2830
|
case _univerjs_sheets.MoveColsMutation.id: {
|
|
@@ -2769,28 +2833,27 @@ let ConditionalFormattingService = class ConditionalFormattingService extends _u
|
|
|
2769
2833
|
if (!target) return;
|
|
2770
2834
|
const { worksheet, unitId, subUnitId } = target;
|
|
2771
2835
|
const { sourceRange, targetRange } = params;
|
|
2772
|
-
|
|
2836
|
+
markRulesDirtyByRanges(unitId, subUnitId, [{
|
|
2773
2837
|
startRow: 0,
|
|
2774
2838
|
endRow: worksheet.getRowCount() - 1,
|
|
2775
2839
|
startColumn: Math.min(sourceRange.startColumn, targetRange.startColumn),
|
|
2776
2840
|
endColumn: worksheet.getColumnCount() - 1
|
|
2777
|
-
};
|
|
2778
|
-
const allRules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId);
|
|
2779
|
-
if (allRules) allRules.filter((rule) => rule.ranges.some((ruleRange) => _univerjs_core.Rectangle.intersects(ruleRange, effectRange))).forEach((rule) => {
|
|
2780
|
-
this._conditionalFormattingViewModelV2.markRuleDirty(unitId, subUnitId, rule.cfId);
|
|
2781
|
-
});
|
|
2841
|
+
}]);
|
|
2782
2842
|
break;
|
|
2783
2843
|
}
|
|
2784
2844
|
case _univerjs_sheets.MoveRangeMutation.id: {
|
|
2785
2845
|
const { unitId, to, from } = commandInfo.params;
|
|
2786
2846
|
const handleSubUnit = (value) => {
|
|
2787
|
-
const
|
|
2847
|
+
const ranges = [];
|
|
2788
2848
|
new _univerjs_core.ObjectMatrix(value.value).forValue((row, col) => {
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2849
|
+
ranges.push({
|
|
2850
|
+
startRow: row,
|
|
2851
|
+
endRow: row,
|
|
2852
|
+
startColumn: col,
|
|
2853
|
+
endColumn: col
|
|
2854
|
+
});
|
|
2793
2855
|
});
|
|
2856
|
+
markRulesDirtyByRanges(unitId, value.subUnitId, ranges);
|
|
2794
2857
|
};
|
|
2795
2858
|
handleSubUnit(to);
|
|
2796
2859
|
handleSubUnit(from);
|
|
@@ -2798,10 +2861,7 @@ let ConditionalFormattingService = class ConditionalFormattingService extends _u
|
|
|
2798
2861
|
}
|
|
2799
2862
|
case _univerjs_sheets.ReorderRangeMutation.id: {
|
|
2800
2863
|
const { range, unitId, subUnitId } = commandInfo.params;
|
|
2801
|
-
|
|
2802
|
-
if (allRules) allRules.filter((rule) => rule.ranges.some((ruleRange) => _univerjs_core.Rectangle.intersects(ruleRange, range))).forEach((rule) => {
|
|
2803
|
-
this._conditionalFormattingViewModelV2.markRuleDirty(unitId, subUnitId, rule.cfId);
|
|
2804
|
-
});
|
|
2864
|
+
markRulesDirtyByRanges(unitId, subUnitId, [range]);
|
|
2805
2865
|
break;
|
|
2806
2866
|
}
|
|
2807
2867
|
}
|
|
@@ -2810,11 +2870,13 @@ let ConditionalFormattingService = class ConditionalFormattingService extends _u
|
|
|
2810
2870
|
};
|
|
2811
2871
|
ConditionalFormattingService = __decorate([
|
|
2812
2872
|
__decorateParam(0, (0, _univerjs_core.Inject)(ConditionalFormattingRuleModel)),
|
|
2813
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(
|
|
2814
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(
|
|
2815
|
-
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.
|
|
2816
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(
|
|
2817
|
-
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_core.
|
|
2873
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(ConditionalFormattingRangeIndexModel)),
|
|
2874
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(ConditionalFormattingStyleComposer)),
|
|
2875
|
+
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
2876
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)),
|
|
2877
|
+
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_core.IResourceManagerService)),
|
|
2878
|
+
__decorateParam(6, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
2879
|
+
__decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_core.ICommandService))
|
|
2818
2880
|
], ConditionalFormattingService);
|
|
2819
2881
|
|
|
2820
2882
|
//#endregion
|
|
@@ -2831,7 +2893,10 @@ let UniverSheetsConditionalFormattingPlugin = class UniverSheetsConditionalForma
|
|
|
2831
2893
|
[
|
|
2832
2894
|
[ConditionalFormattingService],
|
|
2833
2895
|
[ConditionalFormattingFormulaService],
|
|
2896
|
+
[ConditionalFormattingRangeTransformService],
|
|
2897
|
+
[ConditionalFormattingStyleComposer],
|
|
2834
2898
|
[ConditionalFormattingRuleModel],
|
|
2899
|
+
[ConditionalFormattingRangeIndexModel],
|
|
2835
2900
|
[ConditionalFormattingViewModel]
|
|
2836
2901
|
].forEach((dependency) => {
|
|
2837
2902
|
this._injector.add(dependency);
|
|
@@ -2853,7 +2918,11 @@ let UniverSheetsConditionalFormattingPlugin = class UniverSheetsConditionalForma
|
|
|
2853
2918
|
}
|
|
2854
2919
|
onStarting() {
|
|
2855
2920
|
this._injector.get(ConditionalFormattingService);
|
|
2856
|
-
(0, _univerjs_core.touchDependencies)(this._injector, [
|
|
2921
|
+
(0, _univerjs_core.touchDependencies)(this._injector, [
|
|
2922
|
+
[ConditionalFormattingService],
|
|
2923
|
+
[ConditionalFormattingRangeIndexModel],
|
|
2924
|
+
[ConditionalFormattingViewModel]
|
|
2925
|
+
]);
|
|
2857
2926
|
}
|
|
2858
2927
|
};
|
|
2859
2928
|
_defineProperty(UniverSheetsConditionalFormattingPlugin, "pluginName", SHEET_CONDITIONAL_FORMATTING_PLUGIN);
|
|
@@ -2985,6 +3054,13 @@ Object.defineProperty(exports, 'ConditionalFormattingFormulaService', {
|
|
|
2985
3054
|
}
|
|
2986
3055
|
});
|
|
2987
3056
|
exports.ConditionalFormattingIcon = ConditionalFormattingIcon;
|
|
3057
|
+
Object.defineProperty(exports, 'ConditionalFormattingRangeIndexModel', {
|
|
3058
|
+
enumerable: true,
|
|
3059
|
+
get: function () {
|
|
3060
|
+
return ConditionalFormattingRangeIndexModel;
|
|
3061
|
+
}
|
|
3062
|
+
});
|
|
3063
|
+
exports.ConditionalFormattingRangeTransformService = ConditionalFormattingRangeTransformService;
|
|
2988
3064
|
exports.ConditionalFormattingRuleModel = ConditionalFormattingRuleModel;
|
|
2989
3065
|
Object.defineProperty(exports, 'ConditionalFormattingService', {
|
|
2990
3066
|
enumerable: true,
|
|
@@ -2992,6 +3068,12 @@ Object.defineProperty(exports, 'ConditionalFormattingService', {
|
|
|
2992
3068
|
return ConditionalFormattingService;
|
|
2993
3069
|
}
|
|
2994
3070
|
});
|
|
3071
|
+
Object.defineProperty(exports, 'ConditionalFormattingStyleComposer', {
|
|
3072
|
+
enumerable: true,
|
|
3073
|
+
get: function () {
|
|
3074
|
+
return ConditionalFormattingStyleComposer;
|
|
3075
|
+
}
|
|
3076
|
+
});
|
|
2995
3077
|
Object.defineProperty(exports, 'ConditionalFormattingViewModel', {
|
|
2996
3078
|
enumerable: true,
|
|
2997
3079
|
get: function () {
|