@univerjs/sheets-conditional-formatting 0.24.0 → 0.25.0-insiders.20260608-e4336f7
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 +142 -73
- package/lib/cjs/index.js +263 -166
- 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 +142 -73
- package/lib/es/index.js +252 -168
- 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 +142 -73
- package/lib/index.js +252 -168
- 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/facade/f-conditional-formatting-builder.d.ts +138 -69
- package/lib/types/facade/f-range.d.ts +6 -3
- package/lib/types/facade/f-worksheet.d.ts +14 -7
- package/lib/types/index.d.ts +3 -0
- package/lib/types/locale/ar-SA.d.ts +18 -0
- 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/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/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/facade.js +1 -1
- 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/LICENSE +0 -176
package/lib/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BooleanNumber, CellValueType, ColorKit, CommandType, DependentOn, Disposable, ICommandService, IConfigService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, LRUMap, ObjectMatrix, Plugin, RTree, Range, Rectangle, RefAlias, Tools, UniverInstanceType, dateKit, generateRandomId, isInternalEditorID, isRangesEqual, merge, sequenceExecute, touchDependencies } from "@univerjs/core";
|
|
2
|
-
import { CopySheetCommand, InsertColMutation, InsertRowMutation, MoveColsMutation, MoveRangeMutation, MoveRowsMutation, RemoveColMutation, RemoveRowMutation, RemoveSheetCommand, ReorderRangeMutation, SetRangeValuesMutation, SheetInterceptorService, SheetsSelectionsService,
|
|
2
|
+
import { CopySheetCommand, InsertColMutation, InsertRowMutation, MoveColsMutation, MoveRangeMutation, MoveRowsMutation, RemoveColMutation, RemoveRowMutation, RemoveSheetCommand, ReorderRangeMutation, SetRangeValuesMutation, SheetInterceptorService, SheetsSelectionsService, getSheetCommandTarget } from "@univerjs/sheets";
|
|
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";
|
|
@@ -220,7 +220,7 @@ const isAnchorEqual = (anchor1, anchor2) => {
|
|
|
220
220
|
const createCfId = () => `${generateRandomId(8)}`;
|
|
221
221
|
|
|
222
222
|
//#endregion
|
|
223
|
-
//#region \0@oxc-project+runtime@0.
|
|
223
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/typeof.js
|
|
224
224
|
function _typeof(o) {
|
|
225
225
|
"@babel/helpers - typeof";
|
|
226
226
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -231,7 +231,7 @@ function _typeof(o) {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
//#endregion
|
|
234
|
-
//#region \0@oxc-project+runtime@0.
|
|
234
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPrimitive.js
|
|
235
235
|
function toPrimitive(t, r) {
|
|
236
236
|
if ("object" != _typeof(t) || !t) return t;
|
|
237
237
|
var e = t[Symbol.toPrimitive];
|
|
@@ -244,14 +244,14 @@ function toPrimitive(t, r) {
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
//#endregion
|
|
247
|
-
//#region \0@oxc-project+runtime@0.
|
|
247
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPropertyKey.js
|
|
248
248
|
function toPropertyKey(t) {
|
|
249
249
|
var i = toPrimitive(t, "string");
|
|
250
250
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
//#endregion
|
|
254
|
-
//#region \0@oxc-project+runtime@0.
|
|
254
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/defineProperty.js
|
|
255
255
|
function _defineProperty(e, r, t) {
|
|
256
256
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
257
257
|
value: t,
|
|
@@ -511,6 +511,146 @@ const AddCfCommand = {
|
|
|
511
511
|
}
|
|
512
512
|
};
|
|
513
513
|
|
|
514
|
+
//#endregion
|
|
515
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/decorateParam.js
|
|
516
|
+
function __decorateParam(paramIndex, decorator) {
|
|
517
|
+
return function(target, key) {
|
|
518
|
+
decorator(target, key, paramIndex);
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
//#endregion
|
|
523
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/decorate.js
|
|
524
|
+
function __decorate(decorators, target, key, desc) {
|
|
525
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
526
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
527
|
+
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;
|
|
528
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
//#endregion
|
|
532
|
+
//#region src/models/conditional-formatting-range-index-model.ts
|
|
533
|
+
let ConditionalFormattingRangeIndexModel = class ConditionalFormattingRangeIndexModel extends Disposable {
|
|
534
|
+
constructor(_conditionalFormattingRuleModel) {
|
|
535
|
+
super();
|
|
536
|
+
this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
|
|
537
|
+
_defineProperty(this, "_rTreeManager", new RTree());
|
|
538
|
+
this.rebuild();
|
|
539
|
+
this._initRuleListener();
|
|
540
|
+
}
|
|
541
|
+
getRuleIdsByCell(unitId, subUnitId, row, col) {
|
|
542
|
+
return this.getRuleIdsByRanges(unitId, subUnitId, [{
|
|
543
|
+
startRow: row,
|
|
544
|
+
endRow: row,
|
|
545
|
+
startColumn: col,
|
|
546
|
+
endColumn: col
|
|
547
|
+
}]);
|
|
548
|
+
}
|
|
549
|
+
getRuleIdsByRanges(unitId, subUnitId, ranges) {
|
|
550
|
+
if (!ranges.length) return /* @__PURE__ */ new Set();
|
|
551
|
+
const ids = this._rTreeManager.bulkSearch(ranges.map((range) => ({
|
|
552
|
+
unitId,
|
|
553
|
+
sheetId: subUnitId,
|
|
554
|
+
range
|
|
555
|
+
})));
|
|
556
|
+
return new Set(Array.from(ids).map((id) => String(id)));
|
|
557
|
+
}
|
|
558
|
+
getRulesByRanges(unitId, subUnitId, ranges) {
|
|
559
|
+
var _this$_conditionalFor;
|
|
560
|
+
const ids = this.getRuleIdsByRanges(unitId, subUnitId, ranges);
|
|
561
|
+
return ((_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : []).filter((rule) => ids.has(rule.cfId));
|
|
562
|
+
}
|
|
563
|
+
dispose() {
|
|
564
|
+
this.clear();
|
|
565
|
+
super.dispose();
|
|
566
|
+
}
|
|
567
|
+
clear() {
|
|
568
|
+
this._rTreeManager.clear();
|
|
569
|
+
}
|
|
570
|
+
rebuild() {
|
|
571
|
+
this.clear();
|
|
572
|
+
this._conditionalFormattingRuleModel.getAll().forEach((subUnitMap, unitId) => {
|
|
573
|
+
subUnitMap.forEach((rules, subUnitId) => {
|
|
574
|
+
rules.forEach((rule) => {
|
|
575
|
+
this._insert(unitId, subUnitId, rule.cfId, rule.ranges);
|
|
576
|
+
});
|
|
577
|
+
});
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
_initRuleListener() {
|
|
581
|
+
this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe((e) => {
|
|
582
|
+
const { unitId, subUnitId, rule } = e;
|
|
583
|
+
const { cfId, ranges } = rule;
|
|
584
|
+
switch (e.type) {
|
|
585
|
+
case "add":
|
|
586
|
+
this._insert(unitId, subUnitId, cfId, ranges);
|
|
587
|
+
break;
|
|
588
|
+
case "delete":
|
|
589
|
+
this._remove(unitId, subUnitId, cfId, ranges);
|
|
590
|
+
break;
|
|
591
|
+
case "set": {
|
|
592
|
+
const oldRule = e.oldRule;
|
|
593
|
+
this._remove(unitId, subUnitId, oldRule.cfId, oldRule.ranges);
|
|
594
|
+
this._insert(unitId, subUnitId, cfId, ranges);
|
|
595
|
+
break;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}));
|
|
599
|
+
}
|
|
600
|
+
_insert(unitId, subUnitId, cfId, ranges) {
|
|
601
|
+
this._rTreeManager.bulkInsert(ranges.map((range) => ({
|
|
602
|
+
unitId,
|
|
603
|
+
sheetId: subUnitId,
|
|
604
|
+
id: cfId,
|
|
605
|
+
range
|
|
606
|
+
})));
|
|
607
|
+
}
|
|
608
|
+
_remove(unitId, subUnitId, cfId, ranges) {
|
|
609
|
+
this._rTreeManager.bulkRemove(ranges.map((range) => ({
|
|
610
|
+
unitId,
|
|
611
|
+
sheetId: subUnitId,
|
|
612
|
+
id: cfId,
|
|
613
|
+
range
|
|
614
|
+
})));
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
ConditionalFormattingRangeIndexModel = __decorate([__decorateParam(0, Inject(ConditionalFormattingRuleModel))], ConditionalFormattingRangeIndexModel);
|
|
618
|
+
|
|
619
|
+
//#endregion
|
|
620
|
+
//#region src/services/conditional-formatting-range-transform.service.ts
|
|
621
|
+
var ConditionalFormattingRangeTransformService = class {
|
|
622
|
+
subtractRanges(sourceRanges, rangesToSubtract) {
|
|
623
|
+
return Rectangle.mergeRanges(Rectangle.subtractMulti(sourceRanges, rangesToSubtract));
|
|
624
|
+
}
|
|
625
|
+
addRanges(sourceRanges, rangesToAdd) {
|
|
626
|
+
return Rectangle.mergeRanges([...sourceRanges, ...rangesToAdd]);
|
|
627
|
+
}
|
|
628
|
+
applyRangeDelta(sourceRanges, rangesToSubtract, rangesToAdd) {
|
|
629
|
+
const ranges = rangesToSubtract.length ? this.subtractRanges(sourceRanges, rangesToSubtract) : sourceRanges;
|
|
630
|
+
return rangesToAdd.length ? this.addRanges(ranges, rangesToAdd) : ranges;
|
|
631
|
+
}
|
|
632
|
+
copyIntersectingRanges(sourceRanges, sourceRange, targetAnchor) {
|
|
633
|
+
const fragments = [];
|
|
634
|
+
sourceRanges.forEach((range) => {
|
|
635
|
+
const intersect = Rectangle.getIntersects(range, sourceRange);
|
|
636
|
+
if (!intersect) return;
|
|
637
|
+
fragments.push(this.translateRange(intersect, {
|
|
638
|
+
row: targetAnchor.row - sourceRange.startRow,
|
|
639
|
+
col: targetAnchor.col - sourceRange.startColumn
|
|
640
|
+
}));
|
|
641
|
+
});
|
|
642
|
+
return Rectangle.mergeRanges(fragments);
|
|
643
|
+
}
|
|
644
|
+
translateRange(range, offset) {
|
|
645
|
+
return {
|
|
646
|
+
startRow: range.startRow + offset.row,
|
|
647
|
+
endRow: range.endRow + offset.row,
|
|
648
|
+
startColumn: range.startColumn + offset.col,
|
|
649
|
+
endColumn: range.endColumn + offset.col
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
|
|
514
654
|
//#endregion
|
|
515
655
|
//#region src/commands/mutations/set-conditional-rule.mutation.ts
|
|
516
656
|
const SetConditionalRuleMutation = {
|
|
@@ -547,9 +687,10 @@ const ClearRangeCfCommand = {
|
|
|
547
687
|
type: CommandType.COMMAND,
|
|
548
688
|
id: "sheet.command.clear-range-conditional-rule",
|
|
549
689
|
handler(accessor, params) {
|
|
550
|
-
var _selectionManagerServ;
|
|
690
|
+
var _ref, _params$ranges, _selectionManagerServ;
|
|
551
691
|
if (!params) return false;
|
|
552
|
-
const
|
|
692
|
+
const conditionalFormattingRangeIndexModel = accessor.get(ConditionalFormattingRangeIndexModel);
|
|
693
|
+
const conditionalFormattingRangeTransformService = accessor.get(ConditionalFormattingRangeTransformService);
|
|
553
694
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
554
695
|
const commandService = accessor.get(ICommandService);
|
|
555
696
|
const undoRedoService = accessor.get(IUndoRedoService);
|
|
@@ -557,24 +698,13 @@ const ClearRangeCfCommand = {
|
|
|
557
698
|
const target = getSheetCommandTarget(univerInstanceService, params);
|
|
558
699
|
if (!target) return false;
|
|
559
700
|
const { unitId, subUnitId } = target;
|
|
560
|
-
const ranges = ((_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((selection) => selection.range))
|
|
561
|
-
const allRuleList =
|
|
701
|
+
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 : [];
|
|
702
|
+
const allRuleList = conditionalFormattingRangeIndexModel.getRulesByRanges(unitId, subUnitId, ranges);
|
|
562
703
|
if (!(allRuleList === null || allRuleList === void 0 ? void 0 : allRuleList.length) || !ranges.length) return false;
|
|
563
704
|
const redos = [];
|
|
564
705
|
const undos = [];
|
|
565
706
|
allRuleList.forEach((oldRule) => {
|
|
566
|
-
const
|
|
567
|
-
oldRule.ranges.forEach((range) => {
|
|
568
|
-
Range.foreach(range, (row, col) => {
|
|
569
|
-
matrix.setValue(row, col, 1);
|
|
570
|
-
});
|
|
571
|
-
});
|
|
572
|
-
ranges.forEach((range) => {
|
|
573
|
-
Range.foreach(range, (row, col) => {
|
|
574
|
-
matrix.realDeleteValue(row, col);
|
|
575
|
-
});
|
|
576
|
-
});
|
|
577
|
-
const newRanges = findAllRectangle(createTopMatrixFromMatrix(matrix));
|
|
707
|
+
const newRanges = conditionalFormattingRangeTransformService.subtractRanges(oldRule.ranges, ranges);
|
|
578
708
|
if (newRanges.length) {
|
|
579
709
|
const params = {
|
|
580
710
|
unitId,
|
|
@@ -749,23 +879,6 @@ const SetCfCommand = {
|
|
|
749
879
|
}
|
|
750
880
|
};
|
|
751
881
|
|
|
752
|
-
//#endregion
|
|
753
|
-
//#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
|
|
754
|
-
function __decorateParam(paramIndex, decorator) {
|
|
755
|
-
return function(target, key) {
|
|
756
|
-
decorator(target, key, paramIndex);
|
|
757
|
-
};
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
//#endregion
|
|
761
|
-
//#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
|
|
762
|
-
function __decorate(decorators, target, key, desc) {
|
|
763
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
764
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
765
|
-
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;
|
|
766
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
767
|
-
}
|
|
768
|
-
|
|
769
882
|
//#endregion
|
|
770
883
|
//#region src/services/conditional-formatting-formula.service.ts
|
|
771
884
|
let ConditionalFormattingFormulaService = class ConditionalFormattingFormulaService extends Disposable {
|
|
@@ -1670,14 +1783,14 @@ var IconSetCalculateUnit = class extends BaseCalculateUnit {
|
|
|
1670
1783
|
//#region src/models/conditional-formatting-view-model.ts
|
|
1671
1784
|
const CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH = 1e3 * 3 * 3;
|
|
1672
1785
|
let ConditionalFormattingViewModel = class ConditionalFormattingViewModel extends Disposable {
|
|
1673
|
-
constructor(_injector, _conditionalFormattingRuleModel, _conditionalFormattingFormulaService, _univerInstanceService) {
|
|
1786
|
+
constructor(_injector, _conditionalFormattingRuleModel, _conditionalFormattingRangeIndexModel, _conditionalFormattingFormulaService, _univerInstanceService) {
|
|
1674
1787
|
super();
|
|
1675
1788
|
this._injector = _injector;
|
|
1676
1789
|
this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
|
|
1790
|
+
this._conditionalFormattingRangeIndexModel = _conditionalFormattingRangeIndexModel;
|
|
1677
1791
|
this._conditionalFormattingFormulaService = _conditionalFormattingFormulaService;
|
|
1678
1792
|
this._univerInstanceService = _univerInstanceService;
|
|
1679
1793
|
_defineProperty(this, "_calculateUnitManagers", /* @__PURE__ */ new Map());
|
|
1680
|
-
_defineProperty(this, "_rTreeManager", new RTree());
|
|
1681
1794
|
_defineProperty(this, "_cellCache", new LRUMap(CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH));
|
|
1682
1795
|
_defineProperty(this, "_markDirty$", new Subject());
|
|
1683
1796
|
_defineProperty(this, "markDirty$", this._markDirty$.asObservable());
|
|
@@ -1745,16 +1858,7 @@ let ConditionalFormattingViewModel = class ConditionalFormattingViewModel extend
|
|
|
1745
1858
|
var _this$_conditionalFor;
|
|
1746
1859
|
const subunitRules = (_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : [];
|
|
1747
1860
|
const _calculateUnitManagers = this._ensureCalculateUnitManager(unitId, subUnitId);
|
|
1748
|
-
const list = this.
|
|
1749
|
-
unitId,
|
|
1750
|
-
sheetId: subUnitId,
|
|
1751
|
-
range: {
|
|
1752
|
-
startColumn: col,
|
|
1753
|
-
endColumn: col,
|
|
1754
|
-
startRow: row,
|
|
1755
|
-
endRow: row
|
|
1756
|
-
}
|
|
1757
|
-
}]);
|
|
1861
|
+
const list = this._conditionalFormattingRangeIndexModel.getRuleIdsByCell(unitId, subUnitId, row, col);
|
|
1758
1862
|
const rules = subunitRules.filter((rule) => list.has(rule.cfId));
|
|
1759
1863
|
if (!rules.length) return [];
|
|
1760
1864
|
return rules.map((rule) => {
|
|
@@ -1776,7 +1880,6 @@ let ConditionalFormattingViewModel = class ConditionalFormattingViewModel extend
|
|
|
1776
1880
|
clearCache() {
|
|
1777
1881
|
this._calculateUnitManagers.clear();
|
|
1778
1882
|
this._cellCache.clear();
|
|
1779
|
-
this._rTreeManager.clear();
|
|
1780
1883
|
}
|
|
1781
1884
|
_handleCustomFormulasSeparately() {
|
|
1782
1885
|
this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe((e) => {
|
|
@@ -1795,40 +1898,16 @@ let ConditionalFormattingViewModel = class ConditionalFormattingViewModel extend
|
|
|
1795
1898
|
this.markRuleDirty(unitId, subUnitId, cfId);
|
|
1796
1899
|
switch (e.type) {
|
|
1797
1900
|
case "add": {
|
|
1798
|
-
this._rTreeManager.bulkInsert(ranges.map((r) => ({
|
|
1799
|
-
unitId,
|
|
1800
|
-
sheetId: subUnitId,
|
|
1801
|
-
id: cfId,
|
|
1802
|
-
range: r
|
|
1803
|
-
})));
|
|
1804
1901
|
const instance = this._createRuleCalculateUnitInstance(unitId, subUnitId, rule);
|
|
1805
1902
|
if (!instance) return;
|
|
1806
1903
|
calculateUnitManager.set(rule.cfId, instance);
|
|
1807
1904
|
break;
|
|
1808
1905
|
}
|
|
1809
1906
|
case "delete":
|
|
1810
|
-
this._rTreeManager.bulkRemove(ranges.map((r) => ({
|
|
1811
|
-
unitId,
|
|
1812
|
-
sheetId: subUnitId,
|
|
1813
|
-
id: cfId,
|
|
1814
|
-
range: r
|
|
1815
|
-
})));
|
|
1816
1907
|
calculateUnitManager.delete(rule.cfId);
|
|
1817
1908
|
break;
|
|
1818
1909
|
case "set": {
|
|
1819
1910
|
const oldRule = e.oldRule;
|
|
1820
|
-
this._rTreeManager.bulkRemove(oldRule.ranges.map((r) => ({
|
|
1821
|
-
unitId,
|
|
1822
|
-
sheetId: subUnitId,
|
|
1823
|
-
id: oldRule.cfId,
|
|
1824
|
-
range: r
|
|
1825
|
-
})));
|
|
1826
|
-
this._rTreeManager.bulkInsert(ranges.map((r) => ({
|
|
1827
|
-
unitId,
|
|
1828
|
-
sheetId: subUnitId,
|
|
1829
|
-
id: cfId,
|
|
1830
|
-
range: r
|
|
1831
|
-
})));
|
|
1832
1911
|
if (oldRule.rule.type !== rule.rule.type) {
|
|
1833
1912
|
const instance = this._createRuleCalculateUnitInstance(unitId, subUnitId, rule);
|
|
1834
1913
|
if (!instance) return;
|
|
@@ -1895,8 +1974,9 @@ let ConditionalFormattingViewModel = class ConditionalFormattingViewModel extend
|
|
|
1895
1974
|
ConditionalFormattingViewModel = __decorate([
|
|
1896
1975
|
__decorateParam(0, Inject(Injector)),
|
|
1897
1976
|
__decorateParam(1, Inject(ConditionalFormattingRuleModel)),
|
|
1898
|
-
__decorateParam(2, Inject(
|
|
1899
|
-
__decorateParam(3,
|
|
1977
|
+
__decorateParam(2, Inject(ConditionalFormattingRangeIndexModel)),
|
|
1978
|
+
__decorateParam(3, Inject(ConditionalFormattingFormulaService)),
|
|
1979
|
+
__decorateParam(4, IUniverInstanceService)
|
|
1900
1980
|
], ConditionalFormattingViewModel);
|
|
1901
1981
|
|
|
1902
1982
|
//#endregion
|
|
@@ -2254,7 +2334,7 @@ let IIconSetType = /* @__PURE__ */ function(IIconSetType) {
|
|
|
2254
2334
|
}({});
|
|
2255
2335
|
const iconGroup = [
|
|
2256
2336
|
{
|
|
2257
|
-
title: "
|
|
2337
|
+
title: "sheets-conditional-formatting.iconSet.direction",
|
|
2258
2338
|
group: [
|
|
2259
2339
|
{
|
|
2260
2340
|
name: "3Arrows",
|
|
@@ -2321,7 +2401,7 @@ const iconGroup = [
|
|
|
2321
2401
|
]
|
|
2322
2402
|
},
|
|
2323
2403
|
{
|
|
2324
|
-
title: "
|
|
2404
|
+
title: "sheets-conditional-formatting.iconSet.shape",
|
|
2325
2405
|
group: [
|
|
2326
2406
|
{
|
|
2327
2407
|
name: "3TrafficLights1",
|
|
@@ -2368,7 +2448,7 @@ const iconGroup = [
|
|
|
2368
2448
|
]
|
|
2369
2449
|
},
|
|
2370
2450
|
{
|
|
2371
|
-
title: "
|
|
2451
|
+
title: "sheets-conditional-formatting.iconSet.mark",
|
|
2372
2452
|
group: [
|
|
2373
2453
|
{
|
|
2374
2454
|
name: "3Symbols",
|
|
@@ -2397,7 +2477,7 @@ const iconGroup = [
|
|
|
2397
2477
|
]
|
|
2398
2478
|
},
|
|
2399
2479
|
{
|
|
2400
|
-
title: "
|
|
2480
|
+
title: "sheets-conditional-formatting.iconSet.rank",
|
|
2401
2481
|
group: [
|
|
2402
2482
|
{
|
|
2403
2483
|
name: "4Rating",
|
|
@@ -2472,7 +2552,7 @@ for (const key in iconMap) {
|
|
|
2472
2552
|
//#endregion
|
|
2473
2553
|
//#region package.json
|
|
2474
2554
|
var name = "@univerjs/sheets-conditional-formatting";
|
|
2475
|
-
var version = "0.
|
|
2555
|
+
var version = "0.25.0-insiders.20260608-e4336f7";
|
|
2476
2556
|
|
|
2477
2557
|
//#endregion
|
|
2478
2558
|
//#region src/config/config.ts
|
|
@@ -2496,10 +2576,34 @@ const configSymbol = Symbol(SHEETS_CONDITIONAL_FORMATTING_PLUGIN_CONFIG_KEY);
|
|
|
2496
2576
|
const defaultPluginConfig = {};
|
|
2497
2577
|
|
|
2498
2578
|
//#endregion
|
|
2499
|
-
//#region src/services/conditional-formatting.service.ts
|
|
2500
|
-
let
|
|
2501
|
-
|
|
2502
|
-
|
|
2579
|
+
//#region src/services/conditional-formatting-style-composer.service.ts
|
|
2580
|
+
let ConditionalFormattingStyleComposer = class ConditionalFormattingStyleComposer {
|
|
2581
|
+
constructor(_conditionalFormattingRuleModel, _conditionalFormattingViewModel) {
|
|
2582
|
+
this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
|
|
2583
|
+
this._conditionalFormattingViewModel = _conditionalFormattingViewModel;
|
|
2584
|
+
}
|
|
2585
|
+
composeStyle(unitId, subUnitId, row, col) {
|
|
2586
|
+
const cellCfs = this._conditionalFormattingViewModel.getCellCfs(unitId, subUnitId, row, col);
|
|
2587
|
+
if (!(cellCfs === null || cellCfs === void 0 ? void 0 : cellCfs.length)) return null;
|
|
2588
|
+
const matchedRules = [];
|
|
2589
|
+
let stopIfTrueIndex = -1;
|
|
2590
|
+
for (const cacheItem of cellCfs) {
|
|
2591
|
+
const rule = this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, cacheItem.cfId);
|
|
2592
|
+
if (!rule) continue;
|
|
2593
|
+
matchedRules.push({
|
|
2594
|
+
rule,
|
|
2595
|
+
cacheItem
|
|
2596
|
+
});
|
|
2597
|
+
if (stopIfTrueIndex === -1 && rule.stopIfTrue && this._isRuleMatched(rule, cacheItem.result)) stopIfTrueIndex = matchedRules.length - 1;
|
|
2598
|
+
}
|
|
2599
|
+
if (!matchedRules.length) return null;
|
|
2600
|
+
const effectiveRules = stopIfTrueIndex > -1 ? matchedRules.slice(0, stopIfTrueIndex + 1) : matchedRules;
|
|
2601
|
+
const result = {};
|
|
2602
|
+
for (let i = effectiveRules.length - 1; i >= 0; i--) {
|
|
2603
|
+
const { rule, cacheItem } = effectiveRules[i];
|
|
2604
|
+
this._mergeComposeResult(result, rule, cacheItem.result);
|
|
2605
|
+
}
|
|
2606
|
+
return result;
|
|
2503
2607
|
}
|
|
2504
2608
|
_mergeComposeResult(result, rule, ruleResult) {
|
|
2505
2609
|
const type = rule.rule.type;
|
|
@@ -2530,9 +2634,24 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2530
2634
|
}
|
|
2531
2635
|
}
|
|
2532
2636
|
}
|
|
2533
|
-
|
|
2637
|
+
_isRuleMatched(rule, ruleResult) {
|
|
2638
|
+
if (rule.rule.type === "highlightCell") return !!ruleResult && typeof ruleResult === "object" && Object.keys(ruleResult).length > 0;
|
|
2639
|
+
return !!ruleResult;
|
|
2640
|
+
}
|
|
2641
|
+
};
|
|
2642
|
+
ConditionalFormattingStyleComposer = __decorate([__decorateParam(0, Inject(ConditionalFormattingRuleModel)), __decorateParam(1, Inject(ConditionalFormattingViewModel))], ConditionalFormattingStyleComposer);
|
|
2643
|
+
|
|
2644
|
+
//#endregion
|
|
2645
|
+
//#region src/services/conditional-formatting.service.ts
|
|
2646
|
+
let ConditionalFormattingService = class ConditionalFormattingService extends Disposable {
|
|
2647
|
+
get _conditionalFormattingViewModelV2() {
|
|
2648
|
+
return this._injector.get(ConditionalFormattingViewModel);
|
|
2649
|
+
}
|
|
2650
|
+
constructor(_conditionalFormattingRuleModel, _conditionalFormattingRangeIndexModel, _conditionalFormattingStyleComposer, _injector, _univerInstanceService, _resourceManagerService, _sheetInterceptorService, _commandService) {
|
|
2534
2651
|
super();
|
|
2535
2652
|
this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
|
|
2653
|
+
this._conditionalFormattingRangeIndexModel = _conditionalFormattingRangeIndexModel;
|
|
2654
|
+
this._conditionalFormattingStyleComposer = _conditionalFormattingStyleComposer;
|
|
2536
2655
|
this._injector = _injector;
|
|
2537
2656
|
this._univerInstanceService = _univerInstanceService;
|
|
2538
2657
|
this._resourceManagerService = _resourceManagerService;
|
|
@@ -2543,31 +2662,7 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2543
2662
|
this._initSheetChange();
|
|
2544
2663
|
}
|
|
2545
2664
|
composeStyle(unitId, subUnitId, row, col) {
|
|
2546
|
-
|
|
2547
|
-
if (!(cellCfs === null || cellCfs === void 0 ? void 0 : cellCfs.length)) return null;
|
|
2548
|
-
const matchedRules = [];
|
|
2549
|
-
let stopIfTrueIndex = -1;
|
|
2550
|
-
for (const cacheItem of cellCfs) {
|
|
2551
|
-
const rule = this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, cacheItem.cfId);
|
|
2552
|
-
if (!rule) continue;
|
|
2553
|
-
matchedRules.push({
|
|
2554
|
-
rule,
|
|
2555
|
-
cacheItem
|
|
2556
|
-
});
|
|
2557
|
-
if (stopIfTrueIndex === -1 && rule.stopIfTrue && this._isRuleMatched(rule, cacheItem.result)) stopIfTrueIndex = matchedRules.length - 1;
|
|
2558
|
-
}
|
|
2559
|
-
if (!matchedRules.length) return null;
|
|
2560
|
-
const effectiveRules = stopIfTrueIndex > -1 ? matchedRules.slice(0, stopIfTrueIndex + 1) : matchedRules;
|
|
2561
|
-
const result = {};
|
|
2562
|
-
for (let i = effectiveRules.length - 1; i >= 0; i--) {
|
|
2563
|
-
const { rule, cacheItem } = effectiveRules[i];
|
|
2564
|
-
this._mergeComposeResult(result, rule, cacheItem.result);
|
|
2565
|
-
}
|
|
2566
|
-
return result;
|
|
2567
|
-
}
|
|
2568
|
-
_isRuleMatched(rule, ruleResult) {
|
|
2569
|
-
if (rule.rule.type === "highlightCell") return !!ruleResult && typeof ruleResult === "object" && Object.keys(ruleResult).length > 0;
|
|
2570
|
-
return !!ruleResult;
|
|
2665
|
+
return this._conditionalFormattingStyleComposer.composeStyle(unitId, subUnitId, row, col);
|
|
2571
2666
|
}
|
|
2572
2667
|
_initSnapshot() {
|
|
2573
2668
|
const toJson = (unitID) => {
|
|
@@ -2596,6 +2691,7 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2596
2691
|
parseJson: (json) => parseJson(json),
|
|
2597
2692
|
onUnLoad: (unitID) => {
|
|
2598
2693
|
this._conditionalFormattingRuleModel.deleteUnitId(unitID);
|
|
2694
|
+
this._conditionalFormattingRangeIndexModel.rebuild();
|
|
2599
2695
|
if (isInternalEditorID(unitID)) return;
|
|
2600
2696
|
this._conditionalFormattingViewModelV2.clearCache();
|
|
2601
2697
|
},
|
|
@@ -2685,29 +2781,24 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2685
2781
|
}
|
|
2686
2782
|
_initCellChange() {
|
|
2687
2783
|
this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
|
|
2688
|
-
const
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
const ruleItem = this._conditionalFormattingViewModelV2.getCellCfs(unitId, subUnitId, row, col);
|
|
2692
|
-
ruleItem === null || ruleItem === void 0 || ruleItem.forEach((item) => ruleIds.add(item.cfId));
|
|
2784
|
+
const markRulesDirtyByRanges = (unitId, subUnitId, ranges) => {
|
|
2785
|
+
this._conditionalFormattingRangeIndexModel.getRulesByRanges(unitId, subUnitId, ranges).forEach((rule) => {
|
|
2786
|
+
this._conditionalFormattingViewModelV2.markRuleDirty(unitId, subUnitId, rule.cfId);
|
|
2693
2787
|
});
|
|
2694
|
-
const rules = [];
|
|
2695
|
-
for (const cfId of ruleIds) {
|
|
2696
|
-
const rule = this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, cfId);
|
|
2697
|
-
if (rule) rules.push(rule);
|
|
2698
|
-
}
|
|
2699
|
-
return rules;
|
|
2700
2788
|
};
|
|
2701
2789
|
switch (commandInfo.id) {
|
|
2702
2790
|
case SetRangeValuesMutation.id: {
|
|
2703
2791
|
const { subUnitId, unitId, cellValue } = commandInfo.params;
|
|
2704
|
-
const
|
|
2792
|
+
const ranges = [];
|
|
2705
2793
|
new ObjectMatrix(cellValue).forValue((row, col, value) => {
|
|
2706
|
-
if (value && Object.keys(value).some((key) => ["p", "v"].includes(key)))
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2794
|
+
if (value && Object.keys(value).some((key) => ["p", "v"].includes(key))) ranges.push({
|
|
2795
|
+
startRow: row,
|
|
2796
|
+
endRow: row,
|
|
2797
|
+
startColumn: col,
|
|
2798
|
+
endColumn: col
|
|
2799
|
+
});
|
|
2710
2800
|
});
|
|
2801
|
+
markRulesDirtyByRanges(unitId, subUnitId, ranges);
|
|
2711
2802
|
break;
|
|
2712
2803
|
}
|
|
2713
2804
|
case InsertColMutation.id:
|
|
@@ -2717,14 +2808,10 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2717
2808
|
if (!target) return;
|
|
2718
2809
|
const { worksheet, unitId, subUnitId } = target;
|
|
2719
2810
|
const { range } = params;
|
|
2720
|
-
|
|
2811
|
+
markRulesDirtyByRanges(unitId, subUnitId, [{
|
|
2721
2812
|
...range,
|
|
2722
2813
|
endColumn: worksheet.getColumnCount() - 1
|
|
2723
|
-
};
|
|
2724
|
-
const allRules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId);
|
|
2725
|
-
if (allRules) allRules.filter((rule) => rule.ranges.some((ruleRange) => Rectangle.intersects(ruleRange, effectRange))).forEach((rule) => {
|
|
2726
|
-
this._conditionalFormattingViewModelV2.markRuleDirty(unitId, subUnitId, rule.cfId);
|
|
2727
|
-
});
|
|
2814
|
+
}]);
|
|
2728
2815
|
break;
|
|
2729
2816
|
}
|
|
2730
2817
|
case RemoveRowMutation.id:
|
|
@@ -2734,14 +2821,10 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2734
2821
|
if (!target) return;
|
|
2735
2822
|
const { worksheet, unitId, subUnitId } = target;
|
|
2736
2823
|
const { range } = params;
|
|
2737
|
-
|
|
2824
|
+
markRulesDirtyByRanges(unitId, subUnitId, [{
|
|
2738
2825
|
...range,
|
|
2739
2826
|
endRow: worksheet.getRowCount() - 1
|
|
2740
|
-
};
|
|
2741
|
-
const allRules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId);
|
|
2742
|
-
if (allRules) allRules.filter((rule) => rule.ranges.some((ruleRange) => Rectangle.intersects(ruleRange, effectRange))).forEach((rule) => {
|
|
2743
|
-
this._conditionalFormattingViewModelV2.markRuleDirty(unitId, subUnitId, rule.cfId);
|
|
2744
|
-
});
|
|
2827
|
+
}]);
|
|
2745
2828
|
break;
|
|
2746
2829
|
}
|
|
2747
2830
|
case MoveRowsMutation.id: {
|
|
@@ -2750,16 +2833,12 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2750
2833
|
if (!target) return;
|
|
2751
2834
|
const { worksheet, unitId, subUnitId } = target;
|
|
2752
2835
|
const { sourceRange, targetRange } = params;
|
|
2753
|
-
|
|
2836
|
+
markRulesDirtyByRanges(unitId, subUnitId, [{
|
|
2754
2837
|
startRow: Math.min(sourceRange.startRow, targetRange.startRow),
|
|
2755
2838
|
endRow: worksheet.getRowCount() - 1,
|
|
2756
2839
|
startColumn: 0,
|
|
2757
2840
|
endColumn: worksheet.getColumnCount() - 1
|
|
2758
|
-
};
|
|
2759
|
-
const allRules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId);
|
|
2760
|
-
if (allRules) allRules.filter((rule) => rule.ranges.some((ruleRange) => Rectangle.intersects(ruleRange, effectRange))).forEach((rule) => {
|
|
2761
|
-
this._conditionalFormattingViewModelV2.markRuleDirty(unitId, subUnitId, rule.cfId);
|
|
2762
|
-
});
|
|
2841
|
+
}]);
|
|
2763
2842
|
break;
|
|
2764
2843
|
}
|
|
2765
2844
|
case MoveColsMutation.id: {
|
|
@@ -2768,28 +2847,27 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2768
2847
|
if (!target) return;
|
|
2769
2848
|
const { worksheet, unitId, subUnitId } = target;
|
|
2770
2849
|
const { sourceRange, targetRange } = params;
|
|
2771
|
-
|
|
2850
|
+
markRulesDirtyByRanges(unitId, subUnitId, [{
|
|
2772
2851
|
startRow: 0,
|
|
2773
2852
|
endRow: worksheet.getRowCount() - 1,
|
|
2774
2853
|
startColumn: Math.min(sourceRange.startColumn, targetRange.startColumn),
|
|
2775
2854
|
endColumn: worksheet.getColumnCount() - 1
|
|
2776
|
-
};
|
|
2777
|
-
const allRules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId);
|
|
2778
|
-
if (allRules) allRules.filter((rule) => rule.ranges.some((ruleRange) => Rectangle.intersects(ruleRange, effectRange))).forEach((rule) => {
|
|
2779
|
-
this._conditionalFormattingViewModelV2.markRuleDirty(unitId, subUnitId, rule.cfId);
|
|
2780
|
-
});
|
|
2855
|
+
}]);
|
|
2781
2856
|
break;
|
|
2782
2857
|
}
|
|
2783
2858
|
case MoveRangeMutation.id: {
|
|
2784
2859
|
const { unitId, to, from } = commandInfo.params;
|
|
2785
2860
|
const handleSubUnit = (value) => {
|
|
2786
|
-
const
|
|
2861
|
+
const ranges = [];
|
|
2787
2862
|
new ObjectMatrix(value.value).forValue((row, col) => {
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2863
|
+
ranges.push({
|
|
2864
|
+
startRow: row,
|
|
2865
|
+
endRow: row,
|
|
2866
|
+
startColumn: col,
|
|
2867
|
+
endColumn: col
|
|
2868
|
+
});
|
|
2792
2869
|
});
|
|
2870
|
+
markRulesDirtyByRanges(unitId, value.subUnitId, ranges);
|
|
2793
2871
|
};
|
|
2794
2872
|
handleSubUnit(to);
|
|
2795
2873
|
handleSubUnit(from);
|
|
@@ -2797,10 +2875,7 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2797
2875
|
}
|
|
2798
2876
|
case ReorderRangeMutation.id: {
|
|
2799
2877
|
const { range, unitId, subUnitId } = commandInfo.params;
|
|
2800
|
-
|
|
2801
|
-
if (allRules) allRules.filter((rule) => rule.ranges.some((ruleRange) => Rectangle.intersects(ruleRange, range))).forEach((rule) => {
|
|
2802
|
-
this._conditionalFormattingViewModelV2.markRuleDirty(unitId, subUnitId, rule.cfId);
|
|
2803
|
-
});
|
|
2878
|
+
markRulesDirtyByRanges(unitId, subUnitId, [range]);
|
|
2804
2879
|
break;
|
|
2805
2880
|
}
|
|
2806
2881
|
}
|
|
@@ -2809,11 +2884,13 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2809
2884
|
};
|
|
2810
2885
|
ConditionalFormattingService = __decorate([
|
|
2811
2886
|
__decorateParam(0, Inject(ConditionalFormattingRuleModel)),
|
|
2812
|
-
__decorateParam(1, Inject(
|
|
2813
|
-
__decorateParam(2, Inject(
|
|
2814
|
-
__decorateParam(3, Inject(
|
|
2815
|
-
__decorateParam(4, Inject(
|
|
2816
|
-
__decorateParam(5, Inject(
|
|
2887
|
+
__decorateParam(1, Inject(ConditionalFormattingRangeIndexModel)),
|
|
2888
|
+
__decorateParam(2, Inject(ConditionalFormattingStyleComposer)),
|
|
2889
|
+
__decorateParam(3, Inject(Injector)),
|
|
2890
|
+
__decorateParam(4, Inject(IUniverInstanceService)),
|
|
2891
|
+
__decorateParam(5, Inject(IResourceManagerService)),
|
|
2892
|
+
__decorateParam(6, Inject(SheetInterceptorService)),
|
|
2893
|
+
__decorateParam(7, Inject(ICommandService))
|
|
2817
2894
|
], ConditionalFormattingService);
|
|
2818
2895
|
|
|
2819
2896
|
//#endregion
|
|
@@ -2830,7 +2907,10 @@ let UniverSheetsConditionalFormattingPlugin = class UniverSheetsConditionalForma
|
|
|
2830
2907
|
[
|
|
2831
2908
|
[ConditionalFormattingService],
|
|
2832
2909
|
[ConditionalFormattingFormulaService],
|
|
2910
|
+
[ConditionalFormattingRangeTransformService],
|
|
2911
|
+
[ConditionalFormattingStyleComposer],
|
|
2833
2912
|
[ConditionalFormattingRuleModel],
|
|
2913
|
+
[ConditionalFormattingRangeIndexModel],
|
|
2834
2914
|
[ConditionalFormattingViewModel]
|
|
2835
2915
|
].forEach((dependency) => {
|
|
2836
2916
|
this._injector.add(dependency);
|
|
@@ -2852,7 +2932,11 @@ let UniverSheetsConditionalFormattingPlugin = class UniverSheetsConditionalForma
|
|
|
2852
2932
|
}
|
|
2853
2933
|
onStarting() {
|
|
2854
2934
|
this._injector.get(ConditionalFormattingService);
|
|
2855
|
-
touchDependencies(this._injector, [
|
|
2935
|
+
touchDependencies(this._injector, [
|
|
2936
|
+
[ConditionalFormattingService],
|
|
2937
|
+
[ConditionalFormattingRangeIndexModel],
|
|
2938
|
+
[ConditionalFormattingViewModel]
|
|
2939
|
+
]);
|
|
2856
2940
|
}
|
|
2857
2941
|
};
|
|
2858
2942
|
_defineProperty(UniverSheetsConditionalFormattingPlugin, "pluginName", SHEET_CONDITIONAL_FORMATTING_PLUGIN);
|
|
@@ -2965,4 +3049,4 @@ function removeUndefinedAttr(obj) {
|
|
|
2965
3049
|
}
|
|
2966
3050
|
|
|
2967
3051
|
//#endregion
|
|
2968
|
-
export { AddCfCommand, AddConditionalRuleMutation, AddConditionalRuleMutationUndoFactory, CFNumberOperator, CFRuleType, CFSubRuleType, CFTextOperator, CFTimePeriodOperator, CFValueType, CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH, ClearRangeCfCommand, ClearWorksheetCfCommand, ConditionalFormattingFormulaService, ConditionalFormattingIcon, ConditionalFormattingRuleModel, ConditionalFormattingService, ConditionalFormattingViewModel, DEFAULT_BG_COLOR, DEFAULT_FONT_COLOR, DEFAULT_PADDING, DEFAULT_WIDTH, DataBar, DeleteCfCommand, DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory, IIconSetType, IconUKey, MoveCfCommand, MoveConditionalRuleMutation, MoveConditionalRuleMutationUndoFactory, SHEET_CONDITIONAL_FORMATTING_PLUGIN, SetCfCommand, SetConditionalRuleMutation, UniverSheetsConditionalFormattingPlugin, anchorUndoFactory, compareWithNumber, createCfId, createDefaultRule, createDefaultValue, createDefaultValueByValueType, dataBarUKey, defaultDataBarNativeColor, defaultDataBarPositiveColor, defaultPlaceholderColor, filterRange, findIndexByAnchor, getCacheStyleMatrix, getCellValue, getColorScaleFromValue, getMaxInFormulaResult, getOppositeOperator, getValueByType, iconGroup, iconMap, isAnchorEqual, isFloatsEqual, isNullable, isRangesEqual, moveByAnchor, removeUndefinedAttr, serialTimeToTimestamp, setConditionalRuleMutationUndoFactory, toYMD_1900, transformSupportSymmetryAnchor };
|
|
3052
|
+
export { AddCfCommand, AddConditionalRuleMutation, AddConditionalRuleMutationUndoFactory, CFNumberOperator, CFRuleType, CFSubRuleType, CFTextOperator, CFTimePeriodOperator, CFValueType, CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH, ClearRangeCfCommand, ClearWorksheetCfCommand, ConditionalFormattingFormulaService, ConditionalFormattingIcon, ConditionalFormattingRangeIndexModel, ConditionalFormattingRangeTransformService, ConditionalFormattingRuleModel, ConditionalFormattingService, ConditionalFormattingStyleComposer, ConditionalFormattingViewModel, DEFAULT_BG_COLOR, DEFAULT_FONT_COLOR, DEFAULT_PADDING, DEFAULT_WIDTH, DataBar, DeleteCfCommand, DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory, IIconSetType, IconUKey, MoveCfCommand, MoveConditionalRuleMutation, MoveConditionalRuleMutationUndoFactory, SHEET_CONDITIONAL_FORMATTING_PLUGIN, SetCfCommand, SetConditionalRuleMutation, UniverSheetsConditionalFormattingPlugin, anchorUndoFactory, compareWithNumber, createCfId, createDefaultRule, createDefaultValue, createDefaultValueByValueType, dataBarUKey, defaultDataBarNativeColor, defaultDataBarPositiveColor, defaultPlaceholderColor, filterRange, findIndexByAnchor, getCacheStyleMatrix, getCellValue, getColorScaleFromValue, getMaxInFormulaResult, getOppositeOperator, getValueByType, iconGroup, iconMap, isAnchorEqual, isFloatsEqual, isNullable, isRangesEqual, moveByAnchor, removeUndefinedAttr, serialTimeToTimestamp, setConditionalRuleMutationUndoFactory, toYMD_1900, transformSupportSymmetryAnchor };
|