From b72cbc919c4c29ed635fbad0a6355f9ff10c11c0 Mon Sep 17 00:00:00 2001 From: gggpound Date: Mon, 8 Apr 2024 14:57:27 +0800 Subject: [PATCH 1/9] feat(conditional-formatting): highlight selection when hover rule --- .../src/components/hook/useHighlightRange.ts | 51 +++++++++++++++++++ .../src/components/panel/rule-list/index.tsx | 15 +++++- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 packages/sheets-conditional-formatting-ui/src/components/hook/useHighlightRange.ts diff --git a/packages/sheets-conditional-formatting-ui/src/components/hook/useHighlightRange.ts b/packages/sheets-conditional-formatting-ui/src/components/hook/useHighlightRange.ts new file mode 100644 index 000000000000..55f9c7995bbc --- /dev/null +++ b/packages/sheets-conditional-formatting-ui/src/components/hook/useHighlightRange.ts @@ -0,0 +1,51 @@ +/** + * Copyright 2023-present DreamNum Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { useEffect } from 'react'; +import type { IRange } from '@univerjs/core'; +import { useDependency } from '@wendellhu/redi/react-bindings'; +import { IMarkSelectionService } from '@univerjs/sheets-ui'; + +export const useHighlightRange = (ranges: IRange[] = []) => { + const markSelectionService = useDependency(IMarkSelectionService); + useEffect(() => { + const ids = ranges.map((range) => markSelectionService.addShape({ + range, + style: { + hasAutoFill: false, + fill: 'rgba(73, 184, 17, 0.05)', + strokeWidth: 1, + stroke: '#49B811', + widgets: {}, + }, + primary: { + startColumn: range.startColumn, + endColumn: range.endColumn, + startRow: range.startRow, + endRow: range.endRow, + actualRow: range.startRow, + actualColumn: range.startColumn, + isMerged: false, + isMergedMainCell: false, + }, + })); + return () => { + ids.forEach((id) => { + id && markSelectionService.removeShape(id); + }); + }; + }, [ranges]); +}; diff --git a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-list/index.tsx b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-list/index.tsx index 97df5b8c85db..c2d32eda630e 100644 --- a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-list/index.tsx +++ b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-list/index.tsx @@ -18,6 +18,7 @@ import React, { useEffect, useRef, useState } from 'react'; import { Select, Tooltip } from '@univerjs/design'; import { useDependency } from '@wendellhu/redi/react-bindings'; +import type { IRange } from '@univerjs/core'; import { ICommandService, IUniverInstanceService, LocaleService, Rectangle } from '@univerjs/core'; import { SelectionManagerService, SetSelectionsOperation, SetWorksheetActiveOperation } from '@univerjs/sheets'; import { serializeRange } from '@univerjs/engine-formula'; @@ -35,6 +36,7 @@ import 'react-resizable/css/styles.css'; import { Preview } from '../../preview'; import { ConditionalFormattingI18nController } from '../../../controllers/cf.i18n.controller'; import { ClearWorksheetCfCommand } from '../../../commands/commands/clear-worksheet-cf.command'; +import { useHighlightRange } from '../../hook/useHighlightRange'; import styles from './index.module.less'; @@ -115,15 +117,19 @@ export const RuleList = (props: IRuleListProps) => { const unitId = workbook.getUnitId(); const worksheet = workbook.getActiveSheet(); const subUnitId = worksheet.getSheetId(); + + const [currentRuleRanges, currentRuleRangesSet] = useState([]); const [selectValue, selectValueSet] = useState('2'); const [fetchRuleListId, fetchRuleListIdSet] = useState(0); const [draggingId, draggingIdSet] = useState(-1); const [layoutWidth, layoutWidthSet] = useState(defaultWidth); const layoutContainerRef = useRef(null); + const selectOption = [ { label: localeService.t('sheet.cf.panel.workSheet'), value: '2' }, { label: localeService.t('sheet.cf.panel.selectedRange'), value: '1' }, ]; + const getRuleList = () => { const ruleList = conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId); if (!ruleList || !ruleList.length) { @@ -146,6 +152,8 @@ export const RuleList = (props: IRuleListProps) => { }; const [ruleList, ruleListSet] = useState(getRuleList); + useHighlightRange(currentRuleRanges); + useEffect(() => { const disposable = commandService.onCommandExecuted((commandInfo) => { if (commandInfo.id === SetWorksheetActiveOperation.id) { @@ -320,7 +328,12 @@ export const RuleList = (props: IRuleListProps) => { {ruleList.map((rule, index) => { return (
-
onClick(rule)}> +
currentRuleRangesSet(rule.ranges)} + onMouseLeave={() => currentRuleRangesSet([])} + onClick={() => onClick(rule)} + className={`${styles.ruleItem} ${draggingId === index ? styles.active : ''}`} + >
e.stopPropagation()} From 192545dce4c0eac057fc2960a73b1f2d73edd460 Mon Sep 17 00:00:00 2001 From: gggpound Date: Mon, 8 Apr 2024 19:00:14 +0800 Subject: [PATCH 2/9] feat(conditional-formatting): support data bar only show value --- .../src/components/panel/rule-edit/dataBar.tsx | 10 ++++++++-- .../components/panel/rule-edit/index.module.less | 13 ++++++++----- .../components/panel/rule-list/index.module.less | 2 +- .../src/locale/en-US.ts | 1 + .../src/locale/zh-CN.ts | 1 + .../src/models/type.ts | 1 + 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/dataBar.tsx b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/dataBar.tsx index a770d8037cd9..761189225afa 100644 --- a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/dataBar.tsx +++ b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/dataBar.tsx @@ -15,7 +15,7 @@ */ import React, { useEffect, useMemo, useRef, useState } from 'react'; -import { InputNumber, Radio, RadioGroup, Select } from '@univerjs/design'; +import { Checkbox, InputNumber, Radio, RadioGroup, Select } from '@univerjs/design'; import { useDependency } from '@wendellhu/redi/react-bindings'; import { createInternalEditorID, IUniverInstanceService, LocaleService } from '@univerjs/core'; import { TextEditor } from '@univerjs/ui'; @@ -142,6 +142,8 @@ export const DataBarStyleEditor = (props: IStyleEditorProps) => { return value.value === undefined ? defaultV : value.value; }); + const [isShowValue, isShowValueSet] = useState(true); + const getResult = (option: { minValueType: CFValueType ; minValue: number | string; maxValueType: CFValueType ; @@ -208,7 +210,7 @@ export const DataBarStyleEditor = (props: IStyleEditorProps) => { {localeService.t('sheet.cf.panel.fillType')}
-
+
{ @@ -223,6 +225,10 @@ export const DataBarStyleEditor = (props: IStyleEditorProps) => { {localeService.t('sheet.cf.panel.gradient')} +
+ { isShowValueSet(!v); }} /> + {localeService.t('sheet.cf.panel.onlyShowDataBar')} +
diff --git a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/index.module.less b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/index.module.less index f6bac9be761a..a6488b2231f2 100644 --- a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/index.module.less +++ b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/index.module.less @@ -17,17 +17,20 @@ justify-content: flex-end; margin-bottom: var(--margin-base); } + + .util-item { + display: flex; + justify-content: flex-start; + align-items: center; + font-size: var(--font-size-xxs); + } + .icon-set { .render-config { display: flex; align-items: center; font-size: var(--font-size-xxs); justify-content: flex-start; - .util-item { - display: flex; - justify-content: flex-start; - align-items: center; - } } .flex { display: flex; diff --git a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-list/index.module.less b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-list/index.module.less index 392cd54a4ea4..ef00837ba813 100644 --- a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-list/index.module.less +++ b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-list/index.module.less @@ -7,7 +7,7 @@ align-items: center; .select { color: rgb(var(--text-color)); - width: 126px; + width: 138px; .select-selector { border: none; padding: 0; diff --git a/packages/sheets-conditional-formatting-ui/src/locale/en-US.ts b/packages/sheets-conditional-formatting-ui/src/locale/en-US.ts index e5bda71d1bee..c042c065b7fb 100644 --- a/packages/sheets-conditional-formatting-ui/src/locale/en-US.ts +++ b/packages/sheets-conditional-formatting-ui/src/locale/en-US.ts @@ -77,6 +77,7 @@ const locale: typeof zhCN = { workSheet: 'Entire Sheet', selectedRange: 'Selected Range', managerRuleSelect: 'Manage {0} Rules', + onlyShowDataBar: 'Only Show Data Bars', }, preview: { describe: { diff --git a/packages/sheets-conditional-formatting-ui/src/locale/zh-CN.ts b/packages/sheets-conditional-formatting-ui/src/locale/zh-CN.ts index aa5d66675f31..9d8d525ab7a2 100644 --- a/packages/sheets-conditional-formatting-ui/src/locale/zh-CN.ts +++ b/packages/sheets-conditional-formatting-ui/src/locale/zh-CN.ts @@ -75,6 +75,7 @@ const locale = { workSheet: '整张工作表', selectedRange: '所选单元格', managerRuleSelect: '管理 {0} 的规则', + onlyShowDataBar: '仅显示数据条', }, preview: { describe: { diff --git a/packages/sheets-conditional-formatting/src/models/type.ts b/packages/sheets-conditional-formatting/src/models/type.ts index 1762ad868fa3..f03a3e62ac28 100644 --- a/packages/sheets-conditional-formatting/src/models/type.ts +++ b/packages/sheets-conditional-formatting/src/models/type.ts @@ -78,6 +78,7 @@ export interface IAverageHighlightCell extends IHighlightCell { export interface IDataBar extends IBaseCfRule { type: CFRuleType.dataBar; + isShowValue: boolean; config: { min: IValueConfig; max: IValueConfig; From fefd80f00bb3b9e2ece9d2ae5efdb8d8d0c452e2 Mon Sep 17 00:00:00 2001 From: gggpound Date: Mon, 8 Apr 2024 20:28:42 +0800 Subject: [PATCH 3/9] feat(conditional-formatting): support match error --- packages/engine-formula/src/index.ts | 2 +- .../src/components/panel/rule-edit/highlightCell.tsx | 8 ++++++-- .../src/services/calculate-unit/highlight-cell.ts | 7 +++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/engine-formula/src/index.ts b/packages/engine-formula/src/index.ts index 281ffa9d5091..18b75f5503d7 100644 --- a/packages/engine-formula/src/index.ts +++ b/packages/engine-formula/src/index.ts @@ -31,7 +31,7 @@ export type { IDirtyUnitSheetDefinedNameMap, } from './basics/common'; export { isInDirtyRange } from './basics/dirty'; -export { ErrorType } from './basics/error-type'; +export { ErrorType, ERROR_TYPE_SET } from './basics/error-type'; export { FunctionType, type IFunctionInfo, type IFunctionParam } from './basics/function'; export { type IFunctionNames } from './basics/function'; export { includeFormulaLexerToken, isFormulaLexerToken, normalizeSheetName } from './basics/match-token'; diff --git a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/highlightCell.tsx b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/highlightCell.tsx index 16bab70e539d..2ef6e73b50df 100644 --- a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/highlightCell.tsx +++ b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/highlightCell.tsx @@ -145,7 +145,10 @@ const getOperatorOptions = (type: CFSubRuleType.duplicateValues | CFSubRuleType. createOptionItem(CFTextOperator.equal, localeService), createOptionItem(CFTextOperator.notEqual, localeService), createOptionItem(CFTextOperator.containsBlanks, localeService), - createOptionItem(CFTextOperator.notContainsBlanks, localeService)]; + createOptionItem(CFTextOperator.notContainsBlanks, localeService), + createOptionItem(CFTextOperator.containsErrors, localeService), + createOptionItem(CFTextOperator.notContainsErrors, localeService), + ]; } case CFSubRuleType.number:{ return [ @@ -203,7 +206,8 @@ export const HighlightCellStyleEditor = (props: IStyleEditorProps getOperatorOptions(subType, localeService), [subType]); const [operator, operatorSet] = useState(() => { diff --git a/packages/sheets-conditional-formatting/src/services/calculate-unit/highlight-cell.ts b/packages/sheets-conditional-formatting/src/services/calculate-unit/highlight-cell.ts index 33dc1e85b104..2e58047f09e5 100644 --- a/packages/sheets-conditional-formatting/src/services/calculate-unit/highlight-cell.ts +++ b/packages/sheets-conditional-formatting/src/services/calculate-unit/highlight-cell.ts @@ -17,7 +17,7 @@ import type { IStyleBase } from '@univerjs/core'; import { CellValueType, ObjectMatrix, Range, Rectangle, Tools } from '@univerjs/core'; import dayjs from 'dayjs'; -import { deserializeRangeWithSheet, generateStringWithSequence, LexerTreeBuilder, sequenceNodeType, serializeRange } from '@univerjs/engine-formula'; +import { deserializeRangeWithSheet, ERROR_TYPE_SET, generateStringWithSequence, LexerTreeBuilder, sequenceNodeType, serializeRange } from '@univerjs/engine-formula'; import { CFNumberOperator, CFRuleType, CFSubRuleType, CFTextOperator, CFTimePeriodOperator } from '../../base/const'; import type { IAverageHighlightCell, IConditionFormattingRule, IFormulaHighlightCell, IHighlightCell, INumberHighlightCell, IRankHighlightCell, ITextHighlightCell, ITimePeriodHighlightCell } from '../../models/type'; import { ConditionalFormattingFormulaService, FormulaResultStatus } from '../conditional-formatting-formula.service'; @@ -132,11 +132,10 @@ export const highlightCellCalculateUnit: ICalculateUnit = { return !/^\s*$/.test(v); } case CFTextOperator.containsErrors:{ - // wait do do. - return false; + return (ERROR_TYPE_SET as Set).has(v); } case CFTextOperator.notContainsErrors:{ - return false; + return !(ERROR_TYPE_SET as Set).has(v); } case CFTextOperator.containsText:{ return v.indexOf(condition) > -1; From dcf0462e966766a5abae468bbd35e5c62ac96af1 Mon Sep 17 00:00:00 2001 From: gggpound Date: Tue, 9 Apr 2024 16:46:54 +0800 Subject: [PATCH 4/9] feat(conditional-formatting): update the mapping between the icon set and Excel --- .../src/models/icon-map.ts | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/sheets-conditional-formatting/src/models/icon-map.ts b/packages/sheets-conditional-formatting/src/models/icon-map.ts index e85ce07c51d7..a0dc0258883c 100644 --- a/packages/sheets-conditional-formatting/src/models/icon-map.ts +++ b/packages/sheets-conditional-formatting/src/models/icon-map.ts @@ -18,14 +18,18 @@ import ICON_MAP from '../assets/icon-map.json'; export type IIconItem = string; -export const iconGroup: { title: string;group: { name: string;list: string[] }[] }[] = [ +export const iconGroup: { title: string; group: { name: string; list: string[] }[] }[] = [ { title: 'sheet.cf.iconSet.direction', group: [ { name: '3Arrows', list: [ICON_MAP.arrow['up-green'], ICON_MAP.arrow['right-gold'], ICON_MAP.arrow['down-red']] }, - { name: '_3Shape', list: [ICON_MAP.shape.up, ICON_MAP.shape.cross, ICON_MAP.shape.down] }, + { name: '3ArrowsGray', list: [ICON_MAP.arrow['up-gray'], ICON_MAP.arrow['right-gray'], ICON_MAP.arrow['down-gray']] }, { name: '4Arrows', list: [ICON_MAP.arrow['up-green'], ICON_MAP.arrow['rightAndUp-gold'], ICON_MAP.arrow['rightAndDown-gold'], ICON_MAP.arrow['down-red']] }, + { name: '4ArrowsGray', list: [ICON_MAP.arrow['down-gray'], ICON_MAP.arrow['rightAndDown-gray'], ICON_MAP.arrow['rightAndUp-gray'], ICON_MAP.arrow['up-gray']] }, { name: '5Arrows', list: [ICON_MAP.arrow['up-green'], ICON_MAP.arrow['rightAndUp-gold'], ICON_MAP.arrow['right-gold'], ICON_MAP.arrow['rightAndDown-gold'], ICON_MAP.arrow['down-red']] }, + { name: '5ArrowsGray', list: [ICON_MAP.arrow['down-gray'], ICON_MAP.arrow['rightAndDown-gray'], ICON_MAP.arrow['right-gray'], ICON_MAP.arrow['rightAndUp-gray'], ICON_MAP.arrow['up-gray']] }, + { name: '3Triangles', list: [ICON_MAP.shape.down, ICON_MAP.shape.cross, ICON_MAP.shape.up] }, + ], }, @@ -38,13 +42,13 @@ export const iconGroup: { title: string;group: { name: string;list: string[] }[] { name: '3Signs', list: [ICON_MAP.shape['roundness-greed'], ICON_MAP.shape['triangle-gold'], ICON_MAP.shape['rhomboid-red']], }, + { name: '3TrafficLights2', list: [ICON_MAP.shape['indicate-red'], ICON_MAP.shape['indicate-gold'], ICON_MAP.shape['indicate-greed']] }, { name: '4RedToBlack', list: [ICON_MAP.shape['roundness-red'], ICON_MAP.shape['roundness-pink'], ICON_MAP.shape['roundness-gray'], ICON_MAP.shape['roundness-black']], }, { name: '4TrafficLights', list: [ICON_MAP.shape['roundness-greed'], ICON_MAP.shape['roundness-gold'], ICON_MAP.shape['roundness-red'], ICON_MAP.shape['roundness-black']], }, - { name: '_3Indicate', list: [ICON_MAP.shape['indicate-greed'], ICON_MAP.shape['indicate-gold'], ICON_MAP.shape['indicate-red']] }, ], }, { @@ -57,7 +61,7 @@ export const iconGroup: { title: string;group: { name: string;list: string[] }[] name: '3Symbols2', list: [ICON_MAP.feedback2.correct2, ICON_MAP.feedback2.warn2, ICON_MAP.feedback2.mistake2], }, { - name: '3Flags', list: [ICON_MAP.flag['flag-green'], ICON_MAP.flag['flag-gold'], ICON_MAP.flag['flag-red']], + name: '3Flags', list: [ICON_MAP.flag['flag-red'], ICON_MAP.flag['flag-gold'], ICON_MAP.flag['flag-green']], }, ], @@ -66,19 +70,22 @@ export const iconGroup: { title: string;group: { name: string;list: string[] }[] title: 'sheet.cf.iconSet.rank', group: [ { - name: '3Stars', list: [ICON_MAP.star.starEmpty, ICON_MAP.star.starIncomplete, ICON_MAP.star.starFull], + name: '4Rating', list: [ICON_MAP.signal.signal100, ICON_MAP.signal.signal75, ICON_MAP.signal.signal50, ICON_MAP.signal.signal25], + }, + { + name: '5Rating', list: [ICON_MAP.signal.signal100, ICON_MAP.signal.signal75, ICON_MAP.signal.signal50, ICON_MAP.signal.signal25, ICON_MAP.signal.signal0], }, { name: '5Quarters', list: [ICON_MAP.progress.progress0, ICON_MAP.progress.progress25, ICON_MAP.progress.progress50, ICON_MAP.progress.progress75, ICON_MAP.progress.progress100], }, { - name: '5Rating', list: [ICON_MAP.feeling.guffaw, ICON_MAP.feeling.smile, ICON_MAP.feeling.noninductive, ICON_MAP.feeling.dissatisfied, ICON_MAP.feeling.impatient], + name: '_5Felling', list: [ICON_MAP.feeling.guffaw, ICON_MAP.feeling.smile, ICON_MAP.feeling.noninductive, ICON_MAP.feeling.dissatisfied, ICON_MAP.feeling.impatient], }, { - name: '_5Rating2', list: [ICON_MAP.signal.signal0, ICON_MAP.signal.signal25, ICON_MAP.signal.signal50, ICON_MAP.signal.signal75, ICON_MAP.signal.signal100], + name: '5Boxes', list: [ICON_MAP.cell['cell-0'], ICON_MAP.cell['cell-25'], ICON_MAP.cell['cell-50'], ICON_MAP.cell['cell-75'], ICON_MAP.cell['cell-100']], }, { - name: '_5Rating3', list: [ICON_MAP.cell['cell-0'], ICON_MAP.cell['cell-25'], ICON_MAP.cell['cell-50'], ICON_MAP.cell['cell-75'], ICON_MAP.cell['cell-100']], + name: '3Stars', list: [ICON_MAP.star.starFull, ICON_MAP.star.starIncomplete, ICON_MAP.star.starEmpty], }, ], }, From f3d1776d20d318bb02a04563a9f5e32ee2dee647 Mon Sep 17 00:00:00 2001 From: gggpound Date: Tue, 9 Apr 2024 16:56:29 +0800 Subject: [PATCH 5/9] fix(conditional-formatting): supports entire rows and columns --- .../src/components/panel/rule-edit/index.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/index.tsx b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/index.tsx index d656a1d4d641..e51ad35abaf2 100644 --- a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/index.tsx +++ b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/index.tsx @@ -23,7 +23,7 @@ import { Button, Select } from '@univerjs/design'; import { RangeSelector } from '@univerjs/ui'; import type { IRemoveSheetMutationParams } from '@univerjs/sheets'; -import { RemoveSheetMutation, SelectionManagerService, SetWorksheetActiveOperation } from '@univerjs/sheets'; +import { RemoveSheetMutation, SelectionManagerService, setEndForRange, SetWorksheetActiveOperation } from '@univerjs/sheets'; import type { IConditionFormattingRule } from '@univerjs/sheets-conditional-formatting'; import { CFRuleType, CFSubRuleType, ConditionalFormattingRuleModel, SHEET_CONDITIONAL_FORMATTING_PLUGIN } from '@univerjs/sheets-conditional-formatting'; import type { IAddCfCommandParams } from '../../../commands/commands/add-cf.command'; @@ -182,9 +182,10 @@ export const RuleEdit = (props: IRuleEditProps) => { const handleSubmit = () => { const beforeSubmitResult = interceptorManager.fetchThroughInterceptors(interceptorManager.getInterceptPoints().beforeSubmit)(true, null); const getRanges = () => { - const ranges = rangeResult.current; - const isError = ranges.some((range) => Number.isNaN(range.startRow) || Number.isNaN(range.startColumn)); - return isError ? [] : ranges; + const worksheet = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet(); + const ranges = rangeResult.current.map((range) => setEndForRange(range, worksheet.getRowCount(), worksheet.getColumnCount())); + const result = ranges.filter((range) => !(Number.isNaN(range.startRow) || Number.isNaN(range.startColumn))); + return result; }; if (beforeSubmitResult) { From 1e3396c744ed154027f4d7e954ca01522567c757 Mon Sep 17 00:00:00 2001 From: gggpound Date: Tue, 9 Apr 2024 17:32:58 +0800 Subject: [PATCH 6/9] feat(conditional-formatting): support data bar hide value --- .../open-conditional-formatting-panel.ts | 1 + .../components/panel/rule-edit/dataBar.tsx | 40 +++++++++++++------ .../src/controllers/cf.render.controller.ts | 6 +++ .../src/render/type.ts | 2 + .../src/services/__test__/cf.service.spec.ts | 1 + .../src/services/calculate-unit/data-bar.ts | 17 ++++---- 6 files changed, 46 insertions(+), 21 deletions(-) diff --git a/packages/sheets-conditional-formatting-ui/src/commands/operations/open-conditional-formatting-panel.ts b/packages/sheets-conditional-formatting-ui/src/commands/operations/open-conditional-formatting-panel.ts index de29977d59fc..6ccaddb806af 100644 --- a/packages/sheets-conditional-formatting-ui/src/commands/operations/open-conditional-formatting-panel.ts +++ b/packages/sheets-conditional-formatting-ui/src/commands/operations/open-conditional-formatting-panel.ts @@ -100,6 +100,7 @@ export const OpenConditionalFormattingOperator: ICommand = { ranges, rule: { type: CFRuleType.dataBar, + isShowValue: true, }, } as unknown as IConditionFormattingRule; conditionalFormattingMenuController.openPanel(rule); diff --git a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/dataBar.tsx b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/dataBar.tsx index 761189225afa..f45d2156dcee 100644 --- a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/dataBar.tsx +++ b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/dataBar.tsx @@ -142,7 +142,13 @@ export const DataBarStyleEditor = (props: IStyleEditorProps) => { return value.value === undefined ? defaultV : value.value; }); - const [isShowValue, isShowValueSet] = useState(true); + const [isShowValue, isShowValueSet] = useState(() => { + const defaultV = true; + if (!rule) { + return defaultV; + } + return rule.isShowValue === undefined ? defaultV : !!rule.isShowValue; + }); const getResult = (option: { minValueType: CFValueType ; minValue: number | string; @@ -150,6 +156,7 @@ export const DataBarStyleEditor = (props: IStyleEditorProps) => { maxValue: number | string; isGradient: string; positiveColor: string; + isShowValue: boolean; nativeColor: string; }) => { const config: { min: IValueConfig; max: IValueConfig; @@ -162,16 +169,16 @@ export const DataBarStyleEditor = (props: IStyleEditorProps) => { positiveColor: option.positiveColor, nativeColor: option.nativeColor, }; - return { config, type: CFRuleType.dataBar }; + return { config, type: CFRuleType.dataBar, isShowValue: option.isShowValue }; }; useEffect(() => { const dispose = interceptorManager.intercept(interceptorManager.getInterceptPoints().submit, { handler() { - return getResult({ isGradient, minValue, minValueType, maxValue, maxValueType, positiveColor, nativeColor }); + return getResult({ isGradient, minValue, minValueType, maxValue, maxValueType, positiveColor, nativeColor, isShowValue }); }, }); return dispose as () => void; - }, [isGradient, minValue, minValueType, maxValue, maxValueType, positiveColor, nativeColor, interceptorManager]); + }, [isGradient, minValue, minValueType, maxValue, maxValueType, positiveColor, nativeColor, interceptorManager, isShowValue]); const _handleChange = (option: { minValueType: CFValueType ; minValue: number | string; @@ -179,6 +186,7 @@ export const DataBarStyleEditor = (props: IStyleEditorProps) => { maxValue: number | string; isGradient: string; positiveColor: string; + isShowValue: boolean; nativeColor: string; }) => { props.onChange(getResult(option)); }; @@ -186,11 +194,11 @@ export const DataBarStyleEditor = (props: IStyleEditorProps) => { const handlePositiveColorChange = (color: string) => { positiveColorSet(color); - _handleChange({ isGradient, minValue, minValueType, maxValue, maxValueType, positiveColor: color, nativeColor }); + _handleChange({ isGradient, minValue, minValueType, maxValue, maxValueType, positiveColor: color, nativeColor, isShowValue }); }; const handleNativeColorChange = (color: string) => { nativeColorSet(color); - _handleChange({ isGradient, minValue, minValueType, maxValue, maxValueType, positiveColor, nativeColor: color }); + _handleChange({ isGradient, minValue, minValueType, maxValue, maxValueType, positiveColor, nativeColor: color, isShowValue }); }; const isShowInput = (type: string) => { @@ -203,7 +211,7 @@ export const DataBarStyleEditor = (props: IStyleEditorProps) => { {localeService.t('sheet.cf.panel.styleRule')}
- +
@@ -215,7 +223,7 @@ export const DataBarStyleEditor = (props: IStyleEditorProps) => { value={isGradient} onChange={(v) => { isGradientSet(v as string); - _handleChange({ isGradient: v as string, minValue, minValueType, maxValue, maxValueType, positiveColor, nativeColor }); + _handleChange({ isGradient: v as string, minValue, minValueType, maxValue, maxValueType, positiveColor, nativeColor, isShowValue }); }} > @@ -226,7 +234,13 @@ export const DataBarStyleEditor = (props: IStyleEditorProps) => {
- { isShowValueSet(!v); }} /> + { + isShowValueSet(!v); + _handleChange({ isGradient: v as string, minValue, minValueType, maxValue, maxValueType, positiveColor, nativeColor, isShowValue: !v }); + }} + /> {localeService.t('sheet.cf.panel.onlyShowDataBar')}
@@ -261,7 +275,7 @@ export const DataBarStyleEditor = (props: IStyleEditorProps) => { minValueTypeSet(v as CFValueType); const value = createDefaultValueByValueType(v as CFValueType, 10); minValueSet(value); - _handleChange({ isGradient, minValue: value, minValueType: v as CFValueType, maxValue, maxValueType, positiveColor, nativeColor }); + _handleChange({ isGradient, minValue: value, minValueType: v as CFValueType, maxValue, maxValueType, positiveColor, nativeColor, isShowValue }); }} /> @@ -273,7 +287,7 @@ export const DataBarStyleEditor = (props: IStyleEditorProps) => { value={minValue} onChange={(v) => { minValueSet(v || 0); - _handleChange({ isGradient, minValue: v || 0, minValueType, maxValue, maxValueType, positiveColor, nativeColor }); + _handleChange({ isGradient, minValue: v || 0, minValueType, maxValue, maxValueType, positiveColor, nativeColor, isShowValue }); }} />
@@ -286,7 +300,7 @@ export const DataBarStyleEditor = (props: IStyleEditorProps) => { maxValueTypeSet(v as CFValueType); const value = createDefaultValueByValueType(v as CFValueType, 90); maxValueSet(value); - _handleChange({ isGradient, minValue, minValueType, maxValue: value, maxValueType: v as CFValueType, positiveColor, nativeColor }); + _handleChange({ isGradient, minValue, minValueType, maxValue: value, maxValueType: v as CFValueType, positiveColor, nativeColor, isShowValue }); }} /> { value={maxValue} onChange={(v) => { maxValueSet(v || 0); - _handleChange({ isGradient, minValue, minValueType, maxValue: v || 0, maxValueType, positiveColor, nativeColor }); + _handleChange({ isGradient, minValue, minValueType, maxValue: v || 0, maxValueType, positiveColor, nativeColor, isShowValue }); }} />
diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.render.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.render.controller.ts index 90ab82d35772..57da07f8c1e9 100644 --- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.render.controller.ts +++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.render.controller.ts @@ -108,6 +108,12 @@ export class RenderController extends Disposable { } if (result.dataBar) { cloneCell.dataBar = result.dataBar; + if (!result.dataBar.isShowValue) { + if (!cloneCell.fontRenderExtension) { + cloneCell.fontRenderExtension = {}; + } + cloneCell.fontRenderExtension.isSkip = true; + } } if (result.iconSet) { cloneCell.iconSet = result.iconSet; diff --git a/packages/sheets-conditional-formatting/src/render/type.ts b/packages/sheets-conditional-formatting/src/render/type.ts index 9e72f22be3fb..b955f0cf0b7d 100644 --- a/packages/sheets-conditional-formatting/src/render/type.ts +++ b/packages/sheets-conditional-formatting/src/render/type.ts @@ -22,6 +22,8 @@ export interface IDataBarRenderParams { value: number; // -100 - 100. startPoint: number; //0-100 isGradient: boolean; + isShowValue: boolean; + } export interface IDataBarCellData extends ICellData { dataBar?: IDataBarRenderParams; diff --git a/packages/sheets-conditional-formatting/src/services/__test__/cf.service.spec.ts b/packages/sheets-conditional-formatting/src/services/__test__/cf.service.spec.ts index 5fe320523474..2adf89e4b97c 100644 --- a/packages/sheets-conditional-formatting/src/services/__test__/cf.service.spec.ts +++ b/packages/sheets-conditional-formatting/src/services/__test__/cf.service.spec.ts @@ -721,6 +721,7 @@ describe('Test conditional formatting service', () => { stopIfTrue: false, rule: { type: CFRuleType.dataBar, + isShowValue: true, config: { min: { value: 2, type: CFValueType.num }, max: { value: 5, type: CFValueType.num }, diff --git a/packages/sheets-conditional-formatting/src/services/calculate-unit/data-bar.ts b/packages/sheets-conditional-formatting/src/services/calculate-unit/data-bar.ts index 22af5c15e83a..977e1894b944 100644 --- a/packages/sheets-conditional-formatting/src/services/calculate-unit/data-bar.ts +++ b/packages/sheets-conditional-formatting/src/services/calculate-unit/data-bar.ts @@ -30,7 +30,7 @@ export const dataBarCellCalculateUnit: ICalculateUnit = { const conditionalFormattingFormulaService = context.accessor.get(ConditionalFormattingFormulaService); const { worksheet } = context; - const matrix = new ObjectMatrix< number>(); + const matrix = new ObjectMatrix(); rule.ranges.forEach((range) => { Range.foreach(range, (row, col) => { @@ -43,7 +43,7 @@ export const dataBarCellCalculateUnit: ICalculateUnit = { }); }); - const computeResult = new ObjectMatrix(); + const computeResult = new ObjectMatrix(); rule.ranges.forEach((range) => { Range.foreach(range, (row, col) => { computeResult.setValue(row, col, EMPTY_STYLE as IDataBarRenderParams); @@ -55,8 +55,8 @@ export const dataBarCellCalculateUnit: ICalculateUnit = { let min = 0; let max = 0; - // If the formula triggers the calculation, wait for the result, - // and use the previous style cache until the result comes out。 + // If the formula triggers the calculation, wait for the result, + // and use the previous style cache until the result comes out。 if (_min.status === FormulaResultStatus.WAIT) { return conditionalFormattingFormulaService.getCache(context.unitId, context.subUnitId, rule.cfId) || computeResult; } else if (_min.status === FormulaResultStatus.SUCCESS) { @@ -75,6 +75,7 @@ export const dataBarCellCalculateUnit: ICalculateUnit = { } const isGradient = ruleConfig.config.isGradient; + const isShowValue = ruleConfig.isShowValue; const getSafeValue = (v: number) => Math.max(Math.min(100, v), 0); @@ -88,7 +89,7 @@ export const dataBarCellCalculateUnit: ICalculateUnit = { return; } const v = getSafeValue((max - value) / length * 100); - computeResult.setValue(row, col, { color: ruleConfig.config.nativeColor, startPoint, value: -v, isGradient }); + computeResult.setValue(row, col, { color: ruleConfig.config.nativeColor, startPoint, value: -v, isGradient, isShowValue }); }); } else if (min < 0 && max > 0) { const length = Math.abs(max) + Math.abs(min); @@ -99,10 +100,10 @@ export const dataBarCellCalculateUnit: ICalculateUnit = { } if (value > 0) { const v = getSafeValue(Math.min(value / max, 1) * 100); - computeResult.setValue(row, col, { color: ruleConfig.config.positiveColor, startPoint, value: v, isGradient }); + computeResult.setValue(row, col, { color: ruleConfig.config.positiveColor, startPoint, value: v, isGradient, isShowValue }); } else { const v = getSafeValue(Math.min(Math.abs(value) / Math.abs(min), 1) * 100); - computeResult.setValue(row, col, { color: ruleConfig.config.nativeColor, startPoint, value: -v, isGradient }); + computeResult.setValue(row, col, { color: ruleConfig.config.nativeColor, startPoint, value: -v, isGradient, isShowValue }); } }); } else if (min >= 0 && max > 0) { @@ -113,7 +114,7 @@ export const dataBarCellCalculateUnit: ICalculateUnit = { return; } const v = getSafeValue((1 - (max - value) / length) * 100); - computeResult.setValue(row, col, { color: ruleConfig.config.positiveColor, startPoint, value: v, isGradient }); + computeResult.setValue(row, col, { color: ruleConfig.config.positiveColor, startPoint, value: v, isGradient, isShowValue }); }); } return computeResult; From bbe0a5336ca2537a5c098bc28332edb013e9ba54 Mon Sep 17 00:00:00 2001 From: gggpound Date: Tue, 9 Apr 2024 17:38:21 +0800 Subject: [PATCH 7/9] fix(conditional-formatting): lint --- .../src/commands/commands/add-data-bar-cf.command.ts | 4 +++- .../src/services/__test__/cf.service.spec.ts | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/sheets-conditional-formatting-ui/src/commands/commands/add-data-bar-cf.command.ts b/packages/sheets-conditional-formatting-ui/src/commands/commands/add-data-bar-cf.command.ts index 01a361cbb3e3..e2d63b2c032f 100644 --- a/packages/sheets-conditional-formatting-ui/src/commands/commands/add-data-bar-cf.command.ts +++ b/packages/sheets-conditional-formatting-ui/src/commands/commands/add-data-bar-cf.command.ts @@ -31,6 +31,7 @@ interface IAddUniqueValuesConditionalRuleParams { nativeColor: IDataBar['config']['nativeColor']; positiveColor: IDataBar['config']['positiveColor']; isGradient: IDataBar['config']['isGradient']; + isShowValue: IDataBar['isShowValue']; } export const AddDataBarConditionalRuleCommand: ICommand = { @@ -40,7 +41,7 @@ export const AddDataBarConditionalRuleCommand: ICommand { startPoint: 0, value: 0, isGradient: true, + isShowValue: true, }, }); expect(three).toEqual({ @@ -756,6 +757,7 @@ describe('Test conditional formatting service', () => { startPoint: 0, value: 33.333333333333336, isGradient: true, + isShowValue: true, }, }); @@ -765,6 +767,7 @@ describe('Test conditional formatting service', () => { startPoint: 0, value: 66.66666666666667, isGradient: true, + isShowValue: true, }, }); expect(five).toEqual({ @@ -773,6 +776,7 @@ describe('Test conditional formatting service', () => { startPoint: 0, value: 100, isGradient: true, + isShowValue: true, }, }); }); From 700f0e2dcb420bb54ee43dc8528b3d05c3e9b680 Mon Sep 17 00:00:00 2001 From: gggpound Date: Tue, 9 Apr 2024 21:06:09 +0800 Subject: [PATCH 8/9] fix(conditional-formatting): the toggle panel highlight does not disappear --- .../src/components/panel/rule-list/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-list/index.tsx b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-list/index.tsx index c2d32eda630e..4a5ac59f05d3 100644 --- a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-list/index.tsx +++ b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-list/index.tsx @@ -329,7 +329,9 @@ export const RuleList = (props: IRuleListProps) => { return (
currentRuleRangesSet(rule.ranges)} + onMouseMove={() => { + rule.ranges !== currentRuleRanges && currentRuleRangesSet(rule.ranges); + }} onMouseLeave={() => currentRuleRangesSet([])} onClick={() => onClick(rule)} className={`${styles.ruleItem} ${draggingId === index ? styles.active : ''}`} From 8155af4c55b19c59ee33498abda43b8209ef13e2 Mon Sep 17 00:00:00 2001 From: gggpound Date: Wed, 10 Apr 2024 15:20:42 +0800 Subject: [PATCH 9/9] fix(conditional-formatting): isShowValue have race problems --- .../src/controllers/cf.render.controller.ts | 20 +++------- .../src/services/__test__/cf.service.spec.ts | 6 +++ .../conditional-formatting.service.ts | 40 +++++++++++-------- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.render.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.render.controller.ts index 57da07f8c1e9..83cbdabfe039 100644 --- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.render.controller.ts +++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.render.controller.ts @@ -106,26 +106,18 @@ export class RenderController extends Disposable { if (result.style) { Object.assign(s, result.style); } - if (result.dataBar) { - cloneCell.dataBar = result.dataBar; - if (!result.dataBar.isShowValue) { - if (!cloneCell.fontRenderExtension) { - cloneCell.fontRenderExtension = {}; - } + if (!cloneCell.fontRenderExtension) { + cloneCell.fontRenderExtension = {}; + if (!result.isShowValue) { cloneCell.fontRenderExtension.isSkip = true; } } + if (result.dataBar) { + cloneCell.dataBar = result.dataBar; + } if (result.iconSet) { cloneCell.iconSet = result.iconSet; - if (!cloneCell.fontRenderExtension) { - cloneCell.fontRenderExtension = {}; - } - cloneCell.fontRenderExtension.leftOffset = DEFAULT_PADDING + DEFAULT_WIDTH; - - if (!result.iconSet.isShowValue) { - cloneCell.fontRenderExtension.isSkip = true; - } } return next(cloneCell); diff --git a/packages/sheets-conditional-formatting/src/services/__test__/cf.service.spec.ts b/packages/sheets-conditional-formatting/src/services/__test__/cf.service.spec.ts index f8a76f3aecda..42d61a89b7a9 100644 --- a/packages/sheets-conditional-formatting/src/services/__test__/cf.service.spec.ts +++ b/packages/sheets-conditional-formatting/src/services/__test__/cf.service.spec.ts @@ -750,6 +750,7 @@ describe('Test conditional formatting service', () => { isGradient: true, isShowValue: true, }, + isShowValue: true, }); expect(three).toEqual({ dataBar: { @@ -759,6 +760,8 @@ describe('Test conditional formatting service', () => { isGradient: true, isShowValue: true, }, + isShowValue: true, + }); expect(four).toEqual({ @@ -769,6 +772,8 @@ describe('Test conditional formatting service', () => { isGradient: true, isShowValue: true, }, + isShowValue: true, + }); expect(five).toEqual({ dataBar: { @@ -778,6 +783,7 @@ describe('Test conditional formatting service', () => { isGradient: true, isShowValue: true, }, + isShowValue: true, }); }); }); diff --git a/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts b/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts index f11086f48c90..b598a1cd9083 100644 --- a/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts +++ b/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts @@ -39,13 +39,13 @@ type ComputeStatus = 'computing' | 'end' | 'error'; interface IComputeCache { status: ComputeStatus }; -const beforeUpdateRuleResult = createInterceptorKey< { subUnitId: string; unitId: string; cfId: string }>('conditional-formatting-before-update-rule-result'); +const beforeUpdateRuleResult = createInterceptorKey<{ subUnitId: string; unitId: string; cfId: string }>('conditional-formatting-before-update-rule-result'); @OnLifecycle(LifecycleStages.Starting, ConditionalFormattingService) export class ConditionalFormattingService extends Disposable { // >> private _ruleCacheMap: Map>> = new Map(); - private _ruleComputeStatus$: Subject<{ status: ComputeStatus;result?: ObjectMatrix;unitId: string; subUnitId: string; cfId: string }> = new Subject(); + private _ruleComputeStatus$: Subject<{ status: ComputeStatus; result?: ObjectMatrix; unitId: string; subUnitId: string; cfId: string }> = new Subject(); public ruleComputeStatus$ = this._ruleComputeStatus$.asObservable(); public interceptorManager = new InterceptorManager({ beforeUpdateRuleResult }); @@ -100,15 +100,17 @@ export class ConditionalFormattingService extends Disposable { const ruleCache = ruleCacheItem?.ruleCache as IDataBarRenderParams; if (ruleCache && ruleCache !== EMPTY_STYLE) { pre.dataBar = ruleCache; + pre.isShowValue = ruleCache.isShowValue; } } else if (type === CFRuleType.iconSet) { const ruleCache = ruleCacheItem?.ruleCache as IIconSetRenderParams; if (ruleCache && ruleCache !== EMPTY_STYLE) { pre.iconSet = ruleCache; + pre.isShowValue = ruleCache.isShowValue; } } return pre; - }, {} as { style?: IHighlightCell['style'] } & IDataBarCellData & IIconSetCellData); + }, {} as { style?: IHighlightCell['style'] } & IDataBarCellData & IIconSetCellData & { isShowValue: boolean }); return result; } return null; @@ -261,7 +263,7 @@ export class ConditionalFormattingService extends Disposable { }; switch (commandInfo.id) { - case SetRangeValuesMutation.id:{ + case SetRangeValuesMutation.id: { const params = commandInfo.params as ISetRangeValuesMutationParams; const { subUnitId, unitId, cellValue } = params; const cellMatrix: [number, number][] = []; @@ -280,7 +282,7 @@ export class ConditionalFormattingService extends Disposable { break; } case InsertColMutation.id: - case RemoveColMutation.id:{ + case RemoveColMutation.id: { const { range, unitId, subUnitId } = commandInfo.params as IInsertColMutationParams; const allRules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId); const effectRange: IRange = { ...range, endColumn: Number.MAX_SAFE_INTEGER }; @@ -294,7 +296,7 @@ export class ConditionalFormattingService extends Disposable { break; } case RemoveRowMutation.id: - case InsertRowMutation.id:{ + case InsertRowMutation.id: { const { range, unitId, subUnitId } = commandInfo.params as IRemoveRowsMutationParams; const allRules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId); const effectRange: IRange = { ...range, endRow: Number.MAX_SAFE_INTEGER }; @@ -307,13 +309,15 @@ export class ConditionalFormattingService extends Disposable { } break; } - case MoveRowsMutation.id:{ + case MoveRowsMutation.id: { const { sourceRange, targetRange, unitId, subUnitId } = commandInfo.params as IMoveRowsMutationParams; const allRules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId); - const effectRange: IRange = { startRow: Math.min(sourceRange.startRow, targetRange.startRow), - endRow: Number.MAX_SAFE_INTEGER, - startColumn: 0, - endColumn: Number.MAX_SAFE_INTEGER }; + const effectRange: IRange = { + startRow: Math.min(sourceRange.startRow, targetRange.startRow), + endRow: Number.MAX_SAFE_INTEGER, + startColumn: 0, + endColumn: Number.MAX_SAFE_INTEGER, + }; if (allRules) { const effectRule = allRules.filter((rule) => rule.ranges.some((ruleRange) => Rectangle.intersects(ruleRange, effectRange))); effectRule.forEach((rule) => { @@ -323,13 +327,15 @@ export class ConditionalFormattingService extends Disposable { } break; } - case MoveColsMutation.id:{ + case MoveColsMutation.id: { const { sourceRange, targetRange, unitId, subUnitId } = commandInfo.params as IMoveColumnsMutationParams; const allRules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId); - const effectRange: IRange = { startRow: 0, - endRow: Number.MAX_SAFE_INTEGER, - startColumn: Math.min(sourceRange.startColumn, targetRange.startColumn), - endColumn: Number.MAX_SAFE_INTEGER }; + const effectRange: IRange = { + startRow: 0, + endRow: Number.MAX_SAFE_INTEGER, + startColumn: Math.min(sourceRange.startColumn, targetRange.startColumn), + endColumn: Number.MAX_SAFE_INTEGER, + }; if (allRules) { const effectRule = allRules.filter((rule) => rule.ranges.some((ruleRange) => Rectangle.intersects(ruleRange, effectRange))); effectRule.forEach((rule) => { @@ -339,7 +345,7 @@ export class ConditionalFormattingService extends Disposable { } break; } - case MoveRangeMutation.id:{ + case MoveRangeMutation.id: { const { unitId, to, from } = commandInfo.params as IMoveRangeMutationParams; const handleSubUnit = (value: IMoveRangeMutationParams['from']) => { const cellMatrix: [number, number][] = [];