@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/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.137.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.137.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.137.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.137.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.137.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.137.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.133.0/helpers/esm/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.133.0/helpers/esm/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
|
|
@@ -2212,21 +2292,6 @@ const ICON_MAP = {
|
|
|
2212
2292
|
|
|
2213
2293
|
//#endregion
|
|
2214
2294
|
//#region src/models/icon-map.ts
|
|
2215
|
-
/**
|
|
2216
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
2217
|
-
*
|
|
2218
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2219
|
-
* you may not use this file except in compliance with the License.
|
|
2220
|
-
* You may obtain a copy of the License at
|
|
2221
|
-
*
|
|
2222
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2223
|
-
*
|
|
2224
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2225
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2226
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2227
|
-
* See the License for the specific language governing permissions and
|
|
2228
|
-
* limitations under the License.
|
|
2229
|
-
*/
|
|
2230
2295
|
let IIconSetType = /* @__PURE__ */ function(IIconSetType) {
|
|
2231
2296
|
IIconSetType["threeArrows"] = "3Arrows";
|
|
2232
2297
|
IIconSetType["threeArrowsGray"] = "3ArrowsGray";
|
|
@@ -2254,7 +2319,7 @@ let IIconSetType = /* @__PURE__ */ function(IIconSetType) {
|
|
|
2254
2319
|
}({});
|
|
2255
2320
|
const iconGroup = [
|
|
2256
2321
|
{
|
|
2257
|
-
title: "
|
|
2322
|
+
title: "sheets-conditional-formatting.iconSet.direction",
|
|
2258
2323
|
group: [
|
|
2259
2324
|
{
|
|
2260
2325
|
name: "3Arrows",
|
|
@@ -2321,7 +2386,7 @@ const iconGroup = [
|
|
|
2321
2386
|
]
|
|
2322
2387
|
},
|
|
2323
2388
|
{
|
|
2324
|
-
title: "
|
|
2389
|
+
title: "sheets-conditional-formatting.iconSet.shape",
|
|
2325
2390
|
group: [
|
|
2326
2391
|
{
|
|
2327
2392
|
name: "3TrafficLights1",
|
|
@@ -2368,7 +2433,7 @@ const iconGroup = [
|
|
|
2368
2433
|
]
|
|
2369
2434
|
},
|
|
2370
2435
|
{
|
|
2371
|
-
title: "
|
|
2436
|
+
title: "sheets-conditional-formatting.iconSet.mark",
|
|
2372
2437
|
group: [
|
|
2373
2438
|
{
|
|
2374
2439
|
name: "3Symbols",
|
|
@@ -2397,7 +2462,7 @@ const iconGroup = [
|
|
|
2397
2462
|
]
|
|
2398
2463
|
},
|
|
2399
2464
|
{
|
|
2400
|
-
title: "
|
|
2465
|
+
title: "sheets-conditional-formatting.iconSet.rank",
|
|
2401
2466
|
group: [
|
|
2402
2467
|
{
|
|
2403
2468
|
name: "4Rating",
|
|
@@ -2472,7 +2537,7 @@ for (const key in iconMap) {
|
|
|
2472
2537
|
//#endregion
|
|
2473
2538
|
//#region package.json
|
|
2474
2539
|
var name = "@univerjs/sheets-conditional-formatting";
|
|
2475
|
-
var version = "0.
|
|
2540
|
+
var version = "1.0.0-alpha.1";
|
|
2476
2541
|
|
|
2477
2542
|
//#endregion
|
|
2478
2543
|
//#region src/config/config.ts
|
|
@@ -2496,10 +2561,34 @@ const configSymbol = Symbol(SHEETS_CONDITIONAL_FORMATTING_PLUGIN_CONFIG_KEY);
|
|
|
2496
2561
|
const defaultPluginConfig = {};
|
|
2497
2562
|
|
|
2498
2563
|
//#endregion
|
|
2499
|
-
//#region src/services/conditional-formatting.service.ts
|
|
2500
|
-
let
|
|
2501
|
-
|
|
2502
|
-
|
|
2564
|
+
//#region src/services/conditional-formatting-style-composer.service.ts
|
|
2565
|
+
let ConditionalFormattingStyleComposer = class ConditionalFormattingStyleComposer {
|
|
2566
|
+
constructor(_conditionalFormattingRuleModel, _conditionalFormattingViewModel) {
|
|
2567
|
+
this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
|
|
2568
|
+
this._conditionalFormattingViewModel = _conditionalFormattingViewModel;
|
|
2569
|
+
}
|
|
2570
|
+
composeStyle(unitId, subUnitId, row, col) {
|
|
2571
|
+
const cellCfs = this._conditionalFormattingViewModel.getCellCfs(unitId, subUnitId, row, col);
|
|
2572
|
+
if (!(cellCfs === null || cellCfs === void 0 ? void 0 : cellCfs.length)) return null;
|
|
2573
|
+
const matchedRules = [];
|
|
2574
|
+
let stopIfTrueIndex = -1;
|
|
2575
|
+
for (const cacheItem of cellCfs) {
|
|
2576
|
+
const rule = this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, cacheItem.cfId);
|
|
2577
|
+
if (!rule) continue;
|
|
2578
|
+
matchedRules.push({
|
|
2579
|
+
rule,
|
|
2580
|
+
cacheItem
|
|
2581
|
+
});
|
|
2582
|
+
if (stopIfTrueIndex === -1 && rule.stopIfTrue && this._isRuleMatched(rule, cacheItem.result)) stopIfTrueIndex = matchedRules.length - 1;
|
|
2583
|
+
}
|
|
2584
|
+
if (!matchedRules.length) return null;
|
|
2585
|
+
const effectiveRules = stopIfTrueIndex > -1 ? matchedRules.slice(0, stopIfTrueIndex + 1) : matchedRules;
|
|
2586
|
+
const result = {};
|
|
2587
|
+
for (let i = effectiveRules.length - 1; i >= 0; i--) {
|
|
2588
|
+
const { rule, cacheItem } = effectiveRules[i];
|
|
2589
|
+
this._mergeComposeResult(result, rule, cacheItem.result);
|
|
2590
|
+
}
|
|
2591
|
+
return result;
|
|
2503
2592
|
}
|
|
2504
2593
|
_mergeComposeResult(result, rule, ruleResult) {
|
|
2505
2594
|
const type = rule.rule.type;
|
|
@@ -2530,9 +2619,24 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2530
2619
|
}
|
|
2531
2620
|
}
|
|
2532
2621
|
}
|
|
2533
|
-
|
|
2622
|
+
_isRuleMatched(rule, ruleResult) {
|
|
2623
|
+
if (rule.rule.type === "highlightCell") return !!ruleResult && typeof ruleResult === "object" && Object.keys(ruleResult).length > 0;
|
|
2624
|
+
return !!ruleResult;
|
|
2625
|
+
}
|
|
2626
|
+
};
|
|
2627
|
+
ConditionalFormattingStyleComposer = __decorate([__decorateParam(0, Inject(ConditionalFormattingRuleModel)), __decorateParam(1, Inject(ConditionalFormattingViewModel))], ConditionalFormattingStyleComposer);
|
|
2628
|
+
|
|
2629
|
+
//#endregion
|
|
2630
|
+
//#region src/services/conditional-formatting.service.ts
|
|
2631
|
+
let ConditionalFormattingService = class ConditionalFormattingService extends Disposable {
|
|
2632
|
+
get _conditionalFormattingViewModelV2() {
|
|
2633
|
+
return this._injector.get(ConditionalFormattingViewModel);
|
|
2634
|
+
}
|
|
2635
|
+
constructor(_conditionalFormattingRuleModel, _conditionalFormattingRangeIndexModel, _conditionalFormattingStyleComposer, _injector, _univerInstanceService, _resourceManagerService, _sheetInterceptorService, _commandService) {
|
|
2534
2636
|
super();
|
|
2535
2637
|
this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
|
|
2638
|
+
this._conditionalFormattingRangeIndexModel = _conditionalFormattingRangeIndexModel;
|
|
2639
|
+
this._conditionalFormattingStyleComposer = _conditionalFormattingStyleComposer;
|
|
2536
2640
|
this._injector = _injector;
|
|
2537
2641
|
this._univerInstanceService = _univerInstanceService;
|
|
2538
2642
|
this._resourceManagerService = _resourceManagerService;
|
|
@@ -2543,31 +2647,7 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2543
2647
|
this._initSheetChange();
|
|
2544
2648
|
}
|
|
2545
2649
|
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;
|
|
2650
|
+
return this._conditionalFormattingStyleComposer.composeStyle(unitId, subUnitId, row, col);
|
|
2571
2651
|
}
|
|
2572
2652
|
_initSnapshot() {
|
|
2573
2653
|
const toJson = (unitID) => {
|
|
@@ -2596,6 +2676,7 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2596
2676
|
parseJson: (json) => parseJson(json),
|
|
2597
2677
|
onUnLoad: (unitID) => {
|
|
2598
2678
|
this._conditionalFormattingRuleModel.deleteUnitId(unitID);
|
|
2679
|
+
this._conditionalFormattingRangeIndexModel.rebuild();
|
|
2599
2680
|
if (isInternalEditorID(unitID)) return;
|
|
2600
2681
|
this._conditionalFormattingViewModelV2.clearCache();
|
|
2601
2682
|
},
|
|
@@ -2685,29 +2766,24 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2685
2766
|
}
|
|
2686
2767
|
_initCellChange() {
|
|
2687
2768
|
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));
|
|
2769
|
+
const markRulesDirtyByRanges = (unitId, subUnitId, ranges) => {
|
|
2770
|
+
this._conditionalFormattingRangeIndexModel.getRulesByRanges(unitId, subUnitId, ranges).forEach((rule) => {
|
|
2771
|
+
this._conditionalFormattingViewModelV2.markRuleDirty(unitId, subUnitId, rule.cfId);
|
|
2693
2772
|
});
|
|
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
2773
|
};
|
|
2701
2774
|
switch (commandInfo.id) {
|
|
2702
2775
|
case SetRangeValuesMutation.id: {
|
|
2703
2776
|
const { subUnitId, unitId, cellValue } = commandInfo.params;
|
|
2704
|
-
const
|
|
2777
|
+
const ranges = [];
|
|
2705
2778
|
new ObjectMatrix(cellValue).forValue((row, col, value) => {
|
|
2706
|
-
if (value && Object.keys(value).some((key) => ["p", "v"].includes(key)))
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2779
|
+
if (value && Object.keys(value).some((key) => ["p", "v"].includes(key))) ranges.push({
|
|
2780
|
+
startRow: row,
|
|
2781
|
+
endRow: row,
|
|
2782
|
+
startColumn: col,
|
|
2783
|
+
endColumn: col
|
|
2784
|
+
});
|
|
2710
2785
|
});
|
|
2786
|
+
markRulesDirtyByRanges(unitId, subUnitId, ranges);
|
|
2711
2787
|
break;
|
|
2712
2788
|
}
|
|
2713
2789
|
case InsertColMutation.id:
|
|
@@ -2717,14 +2793,10 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2717
2793
|
if (!target) return;
|
|
2718
2794
|
const { worksheet, unitId, subUnitId } = target;
|
|
2719
2795
|
const { range } = params;
|
|
2720
|
-
|
|
2796
|
+
markRulesDirtyByRanges(unitId, subUnitId, [{
|
|
2721
2797
|
...range,
|
|
2722
2798
|
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
|
-
});
|
|
2799
|
+
}]);
|
|
2728
2800
|
break;
|
|
2729
2801
|
}
|
|
2730
2802
|
case RemoveRowMutation.id:
|
|
@@ -2734,14 +2806,10 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2734
2806
|
if (!target) return;
|
|
2735
2807
|
const { worksheet, unitId, subUnitId } = target;
|
|
2736
2808
|
const { range } = params;
|
|
2737
|
-
|
|
2809
|
+
markRulesDirtyByRanges(unitId, subUnitId, [{
|
|
2738
2810
|
...range,
|
|
2739
2811
|
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
|
-
});
|
|
2812
|
+
}]);
|
|
2745
2813
|
break;
|
|
2746
2814
|
}
|
|
2747
2815
|
case MoveRowsMutation.id: {
|
|
@@ -2750,16 +2818,12 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2750
2818
|
if (!target) return;
|
|
2751
2819
|
const { worksheet, unitId, subUnitId } = target;
|
|
2752
2820
|
const { sourceRange, targetRange } = params;
|
|
2753
|
-
|
|
2821
|
+
markRulesDirtyByRanges(unitId, subUnitId, [{
|
|
2754
2822
|
startRow: Math.min(sourceRange.startRow, targetRange.startRow),
|
|
2755
2823
|
endRow: worksheet.getRowCount() - 1,
|
|
2756
2824
|
startColumn: 0,
|
|
2757
2825
|
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
|
-
});
|
|
2826
|
+
}]);
|
|
2763
2827
|
break;
|
|
2764
2828
|
}
|
|
2765
2829
|
case MoveColsMutation.id: {
|
|
@@ -2768,28 +2832,27 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2768
2832
|
if (!target) return;
|
|
2769
2833
|
const { worksheet, unitId, subUnitId } = target;
|
|
2770
2834
|
const { sourceRange, targetRange } = params;
|
|
2771
|
-
|
|
2835
|
+
markRulesDirtyByRanges(unitId, subUnitId, [{
|
|
2772
2836
|
startRow: 0,
|
|
2773
2837
|
endRow: worksheet.getRowCount() - 1,
|
|
2774
2838
|
startColumn: Math.min(sourceRange.startColumn, targetRange.startColumn),
|
|
2775
2839
|
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
|
-
});
|
|
2840
|
+
}]);
|
|
2781
2841
|
break;
|
|
2782
2842
|
}
|
|
2783
2843
|
case MoveRangeMutation.id: {
|
|
2784
2844
|
const { unitId, to, from } = commandInfo.params;
|
|
2785
2845
|
const handleSubUnit = (value) => {
|
|
2786
|
-
const
|
|
2846
|
+
const ranges = [];
|
|
2787
2847
|
new ObjectMatrix(value.value).forValue((row, col) => {
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2848
|
+
ranges.push({
|
|
2849
|
+
startRow: row,
|
|
2850
|
+
endRow: row,
|
|
2851
|
+
startColumn: col,
|
|
2852
|
+
endColumn: col
|
|
2853
|
+
});
|
|
2792
2854
|
});
|
|
2855
|
+
markRulesDirtyByRanges(unitId, value.subUnitId, ranges);
|
|
2793
2856
|
};
|
|
2794
2857
|
handleSubUnit(to);
|
|
2795
2858
|
handleSubUnit(from);
|
|
@@ -2797,10 +2860,7 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2797
2860
|
}
|
|
2798
2861
|
case ReorderRangeMutation.id: {
|
|
2799
2862
|
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
|
-
});
|
|
2863
|
+
markRulesDirtyByRanges(unitId, subUnitId, [range]);
|
|
2804
2864
|
break;
|
|
2805
2865
|
}
|
|
2806
2866
|
}
|
|
@@ -2809,11 +2869,13 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2809
2869
|
};
|
|
2810
2870
|
ConditionalFormattingService = __decorate([
|
|
2811
2871
|
__decorateParam(0, Inject(ConditionalFormattingRuleModel)),
|
|
2812
|
-
__decorateParam(1, Inject(
|
|
2813
|
-
__decorateParam(2, Inject(
|
|
2814
|
-
__decorateParam(3, Inject(
|
|
2815
|
-
__decorateParam(4, Inject(
|
|
2816
|
-
__decorateParam(5, Inject(
|
|
2872
|
+
__decorateParam(1, Inject(ConditionalFormattingRangeIndexModel)),
|
|
2873
|
+
__decorateParam(2, Inject(ConditionalFormattingStyleComposer)),
|
|
2874
|
+
__decorateParam(3, Inject(Injector)),
|
|
2875
|
+
__decorateParam(4, Inject(IUniverInstanceService)),
|
|
2876
|
+
__decorateParam(5, Inject(IResourceManagerService)),
|
|
2877
|
+
__decorateParam(6, Inject(SheetInterceptorService)),
|
|
2878
|
+
__decorateParam(7, Inject(ICommandService))
|
|
2817
2879
|
], ConditionalFormattingService);
|
|
2818
2880
|
|
|
2819
2881
|
//#endregion
|
|
@@ -2830,7 +2892,10 @@ let UniverSheetsConditionalFormattingPlugin = class UniverSheetsConditionalForma
|
|
|
2830
2892
|
[
|
|
2831
2893
|
[ConditionalFormattingService],
|
|
2832
2894
|
[ConditionalFormattingFormulaService],
|
|
2895
|
+
[ConditionalFormattingRangeTransformService],
|
|
2896
|
+
[ConditionalFormattingStyleComposer],
|
|
2833
2897
|
[ConditionalFormattingRuleModel],
|
|
2898
|
+
[ConditionalFormattingRangeIndexModel],
|
|
2834
2899
|
[ConditionalFormattingViewModel]
|
|
2835
2900
|
].forEach((dependency) => {
|
|
2836
2901
|
this._injector.add(dependency);
|
|
@@ -2852,7 +2917,11 @@ let UniverSheetsConditionalFormattingPlugin = class UniverSheetsConditionalForma
|
|
|
2852
2917
|
}
|
|
2853
2918
|
onStarting() {
|
|
2854
2919
|
this._injector.get(ConditionalFormattingService);
|
|
2855
|
-
touchDependencies(this._injector, [
|
|
2920
|
+
touchDependencies(this._injector, [
|
|
2921
|
+
[ConditionalFormattingService],
|
|
2922
|
+
[ConditionalFormattingRangeIndexModel],
|
|
2923
|
+
[ConditionalFormattingViewModel]
|
|
2924
|
+
]);
|
|
2856
2925
|
}
|
|
2857
2926
|
};
|
|
2858
2927
|
_defineProperty(UniverSheetsConditionalFormattingPlugin, "pluginName", SHEET_CONDITIONAL_FORMATTING_PLUGIN);
|
|
@@ -2965,4 +3034,4 @@ function removeUndefinedAttr(obj) {
|
|
|
2965
3034
|
}
|
|
2966
3035
|
|
|
2967
3036
|
//#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 };
|
|
3037
|
+
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 };
|