Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat(conditional-formatting): support set cfId (#1753)
Gpound.liu4a277f932c6e
diff --git a/packages/sheets-conditional-formatting-ui/src/commands/commands/move-cf.command.ts b/packages/sheets-conditional-formatting-ui/src/commands/commands/move-cf.command.tsindex 73702b1da0..1e0ee0bd27 100644--- a/packages/sheets-conditional-formatting-ui/src/commands/commands/move-cf.command.ts+++ b/packages/sheets-conditional-formatting-ui/src/commands/commands/move-cf.command.ts@@ -21,14 +21,14 @@ import {IUndoRedoService,IUniverInstanceService,} from '@univerjs/core';-import type { IMoveConditionalRuleMutationParams } from '@univerjs/sheets-conditional-formatting';-import { MoveConditionalRuleMutation, MoveConditionalRuleMutationUndoFactory } from '@univerjs/sheets-conditional-formatting';+import type { IAnchor, IMoveConditionalRuleMutationParams } from '@univerjs/sheets-conditional-formatting';+import { ConditionalFormattingRuleModel, MoveConditionalRuleMutation, MoveConditionalRuleMutationUndoFactory, transformSupportSymmetryAnchor } from '@univerjs/sheets-conditional-formatting';export interface IMoveCfCommand {unitId?: string;subUnitId?: string;- cfId: string;- targetCfId: string;+ start: IAnchor;+ end: IAnchor;};export const moveCfCommand: ICommand<IMoveCfCommand> = {type: CommandType.COMMAND,@@ -37,16 +37,22 @@ export const moveCfCommand: ICommand<IMoveCfCommand> = {if (!params) {return false;}- const { cfId, targetCfId } = params;+const undoRedoService = accessor.get(IUndoRedoService);const commandService = accessor.get(ICommandService);const univerInstanceService = accessor.get(IUniverInstanceService);+ const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);const workbook = univerInstanceService.getCurrentUniverSheetInstance();const worksheet = workbook.getActiveSheet();const unitId = params.unitId ?? workbook.getUnitId();const subUnitId = params.subUnitId ?? worksheet.getSheetId();- const config: IMoveConditionalRuleMutationParams = { unitId, subUnitId, cfId, targetCfId };- const undos = MoveConditionalRuleMutationUndoFactory(accessor, config);+ const anchorList = transformSupportSymmetryAnchor(params.start, params.end, conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId) || [], (rule) => rule.cfId);+ if (!anchorList) {+ return false;+ }+ const [start, end] = anchorList;+ const config: IMoveConditionalRuleMutationParams = { unitId, subUnitId, start, end };+ const undos = MoveConditionalRuleMutationUndoFactory(config);const result = commandService.syncExecuteCommand(MoveConditionalRuleMutation.id, config);if (result) {undoRedoService.pushUndoRedo({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.tsxindex d4a8c6e914..97df5b8c85 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@@ -45,41 +45,41 @@ interface IRuleListProps {const getRuleDescribe = (rule: IConditionFormattingRule, localeService: LocaleService) => {const ruleConfig = rule.rule;switch (ruleConfig.type) {- case CFRuleType.colorScale:{+ case CFRuleType.colorScale: {return localeService.t('sheet.cf.ruleType.colorScale');}- case CFRuleType.dataBar:{+ case CFRuleType.dataBar: {return localeService.t('sheet.cf.ruleType.dataBar');}- case CFRuleType.iconSet:{+ case CFRuleType.iconSet: {return localeService.t('sheet.cf.ruleType.iconSet');}- case CFRuleType.highlightCell:{+ case CFRuleType.highlightCell: {switch (ruleConfig.subType) {- case CFSubRuleType.average:{+ case CFSubRuleType.average: {const operator = ruleConfig.operator;return localeService.t(`sheet.cf.preview.describe.${operator}`, localeService.t('sheet.cf.subRuleType.average'));}- case CFSubRuleType.duplicateValues:{+ case CFSubRuleType.duplicateValues: {return localeService.t('sheet.cf.subRuleType.duplicateValues');}- case CFSubRuleType.uniqueValues:{+ case CFSubRuleType.uniqueValues: {return localeService.t('sheet.cf.subRuleType.uniqueValues');}- case CFSubRuleType.number:{+ case CFSubRuleType.number: {const operator = ruleConfig.operator;return localeService.t(`sheet.cf.preview.describe.${operator}`, ...Array.isArray(ruleConfig.value) ? (ruleConfig.value.map((e) => String(e))) : [String(ruleConfig.value || '')]);}- case CFSubRuleType.text:{+ case CFSubRuleType.text: {const operator = ruleConfig.operator;return localeService.t(`sheet.cf.preview.describe.${operator}`, ruleConfig.value || '');}- case CFSubRuleType.timePeriod:{+ case CFSubRuleType.timePeriod: {const operator = ruleConfig.operator;return localeService.t(`sheet.cf.preview.describe.${operator}`);}- case CFSubRuleType.rank:{+ case CFSubRuleType.rank: {if (ruleConfig.isPercent) {if (ruleConfig.isBottom) {return localeService.t('sheet.cf.preview.describe.bottomNPercent', String(ruleConfig.value));@@ -94,7 +94,7 @@ const getRuleDescribe = (rule: IConditionFormattingRule, localeService: LocaleSe}}}- case CFSubRuleType.formula:{+ case CFSubRuleType.formula: {return localeService.t('sheet.cf.ruleType.formula');}}@@ -250,7 +250,9 @@ export const RuleList = (props: IRuleListProps) => {};const cfId = ruleList[getSaveIndex(from.y)].cfId;const targetCfId = ruleList[getSaveIndex(to.y)].cfId;- commandService.executeCommand(moveCfCommand.id, { unitId, subUnitId, cfId, targetCfId } as IMoveCfCommand);+ if (cfId !== targetCfId) {+ commandService.executeCommand(moveCfCommand.id, { unitId, subUnitId, start: { id: cfId, type: 'self' }, end: { id: targetCfId, type: to.y > from.y ? 'after' : 'before' } } as IMoveCfCommand);+ }};const handleCreate = () => {@@ -303,7 +305,7 @@ export const RuleList = (props: IRuleListProps) => {</div><div ref={layoutContainerRef} className={styles.gridLayoutWrap}>- { layoutWidth+ {layoutWidth? (<GridLayoutonDragStop={handleDragStop}@@ -315,7 +317,7 @@ export const RuleList = (props: IRuleListProps) => {margin={[0, 10]}draggableHandle=".draggableHandle">- { ruleList.map((rule, index) => {+ {ruleList.map((rule, index) => {return (<div key={`${rule.cfId}`}><div className={`${styles.ruleItem} ${draggingId === index ? styles.active : ''}`} onClick={() => onClick(rule)}>diff --git a/packages/sheets-conditional-formatting/src/commands/mutations/delete-conditional-rule.mutation.ts b/packages/sheets-conditional-formatting/src/commands/mutations/delete-conditional-rule.mutation.tsindex 6da73f37a3..4d75535329 100644--- a/packages/sheets-conditional-formatting/src/commands/mutations/delete-conditional-rule.mutation.ts+++ b/packages/sheets-conditional-formatting/src/commands/mutations/delete-conditional-rule.mutation.ts@@ -21,6 +21,7 @@ import {} from '@univerjs/core';import type { IAccessor } from '@wendellhu/redi';import { ConditionalFormattingRuleModel } from '../../models/conditional-formatting-rule-model';+import { transformSupportSymmetryAnchor } from '../../utils/anchor';import type { IAddConditionalRuleMutationParams } from './add-conditional-rule.mutation';import { AddConditionalRuleMutation } from './add-conditional-rule.mutation';import type { IMoveConditionalRuleMutationParams } from './move-conditional-rule.mutation';@@ -34,18 +35,30 @@ export interface IDeleteConditionalRuleMutationParams {export const DeleteConditionalRuleMutationUndoFactory = (accessor: IAccessor, param: IDeleteConditionalRuleMutationParams) => {const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);const { unitId, subUnitId, cfId } = param;- const rule = conditionalFormattingRuleModel.getRule(unitId, subUnitId, cfId);- const ruleList = conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId);- if (rule) {- const index = ruleList!.findIndex((rule) => rule.cfId === cfId);- const nextRule = ruleList![index - 1];- const result: IMutationInfo[] = [{ id: AddConditionalRuleMutation.id,- params: { unitId, subUnitId, rule: Tools.deepClone(rule) } as IAddConditionalRuleMutationParams },- ];- if (nextRule && index !== 0) {- result.push({ id: MoveConditionalRuleMutation.id, params: {- unitId, subUnitId, cfId, targetCfId: nextRule.cfId,- } as IMoveConditionalRuleMutationParams });+ const ruleList = ([...(conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId) || [])]);+ const index = ruleList.findIndex((item) => item.cfId === cfId);+ const beforeRule = ruleList[index - 1];+ if (index > -1) {+ const rule = ruleList[index];+ const result: IMutationInfo[] = [{+ id: AddConditionalRuleMutation.id,+ params: { unitId, subUnitId, rule: Tools.deepClone(rule) } as IAddConditionalRuleMutationParams,+ }];+ ruleList.splice(index, 1);+ if (index !== 0) {+ const firstRule = ruleList[0];+ if (firstRule) {+ const transformResult = transformSupportSymmetryAnchor({ id: firstRule.cfId, type: 'before' }, { id: beforeRule.cfId, type: 'after' }, ruleList, (rule) => rule.cfId);+ if (!transformResult) {+ return result;+ }+ const [start, end] = transformResult;+ const params: IMoveConditionalRuleMutationParams = {+ unitId, subUnitId, start,+ end,+ };+ result.push({ id: MoveConditionalRuleMutation.id, params });+ }}return result;}diff --git a/packages/sheets-conditional-formatting/src/commands/mutations/move-conditional-rule.mutation.ts b/packages/sheets-conditional-formatting/src/commands/mutations/move-conditional-rule.mutation.tsindex 9ae0994a20..c99c73f1f0 100644--- a/packages/sheets-conditional-formatting/src/commands/mutations/move-conditional-rule.mutation.ts+++ b/packages/sheets-conditional-formatting/src/commands/mutations/move-conditional-rule.mutation.ts@@ -15,18 +15,19 @@*/import type { IMutation } from '@univerjs/core';-import type { IAccessor } from '@wendellhu/redi';import {CommandType,} from '@univerjs/core';import { ConditionalFormattingRuleModel } from '../../models/conditional-formatting-rule-model';+import type { IAnchor } from '../../utils/anchor';+import { anchorUndoFactory } from '../../utils/anchor';export interface IMoveConditionalRuleMutationParams {unitId: string;subUnitId: string;- cfId: string;- targetCfId: string;+ start: IAnchor;+ end: IAnchor;}export const MoveConditionalRuleMutation: IMutation<IMoveConditionalRuleMutationParams> = {@@ -36,25 +37,22 @@ export const MoveConditionalRuleMutation: IMutation<IMoveConditionalRuleMutationif (!params) {return false;}- const { unitId, subUnitId, cfId, targetCfId } = params;+ const { unitId, subUnitId, start, end } = params;const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);- conditionalFormattingRuleModel.moveRulePriority(unitId, subUnitId, cfId, targetCfId);+ conditionalFormattingRuleModel.moveRulePriority(unitId, subUnitId, start, end);return true;},};-export const MoveConditionalRuleMutationUndoFactory = (accessor: IAccessor, param: IMoveConditionalRuleMutationParams) => {- const { unitId, subUnitId, cfId } = param;- const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);- const ruleList = conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId);- if (!ruleList) {- return [];- }- const index = ruleList.findIndex((rule) => rule.cfId === cfId);- const preTargetRule = ruleList[index - 1];- if (!preTargetRule) {+export const MoveConditionalRuleMutationUndoFactory = (param: IMoveConditionalRuleMutationParams) => {+ const { unitId, subUnitId } = param;+ const undo = anchorUndoFactory(param.start, param.end);++ if (!undo) {return [];}+ const [start, end] = undo;+return [{ id: MoveConditionalRuleMutation.id,- params: { unitId, subUnitId, cfId, targetCfId: preTargetRule.cfId } as IMoveConditionalRuleMutationParams },+ params: { unitId, subUnitId, start, end } as IMoveConditionalRuleMutationParams },];};diff --git a/packages/sheets-conditional-formatting/src/commands/mutations/set-conditional-rule.mutation.ts b/packages/sheets-conditional-formatting/src/commands/mutations/set-conditional-rule.mutation.tsindex a737107826..866726900d 100644--- a/packages/sheets-conditional-formatting/src/commands/mutations/set-conditional-rule.mutation.ts+++ b/packages/sheets-conditional-formatting/src/commands/mutations/set-conditional-rule.mutation.ts@@ -25,6 +25,7 @@ import type { IConditionFormattingRule } from '../../models/type';export interface ISetConditionalRuleMutationParams {unitId: string;subUnitId: string;+ cfId?: string;rule: IConditionFormattingRule;}@@ -36,8 +37,10 @@ export const SetConditionalRuleMutation: IMutation<ISetConditionalRuleMutationPareturn false;}const { unitId, subUnitId, rule } = params;+ const cfId = params.cfId || params.rule.cfId;+const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);- conditionalFormattingRuleModel.setRule(unitId, subUnitId, rule);+ conditionalFormattingRuleModel.setRule(unitId, subUnitId, rule, cfId);return true;},};@@ -45,7 +48,7 @@ export const SetConditionalRuleMutation: IMutation<ISetConditionalRuleMutationPaexport const setConditionalRuleMutationUndoFactory = (accessor: IAccessor, param: ISetConditionalRuleMutationParams) => {const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);const { unitId, subUnitId } = param;- const cfId = param.rule.cfId;+ const cfId = param.cfId || param.rule.cfId;const rule = conditionalFormattingRuleModel.getRule(unitId, subUnitId, cfId);if (rule) {return [{@@ -53,8 +56,10 @@ export const setConditionalRuleMutationUndoFactory = (accessor: IAccessor, paramparams: {unitId,subUnitId,+ cfId,rule: Tools.deepClone(rule),- } as ISetConditionalRuleMutationParams },+ } as ISetConditionalRuleMutationParams,+ },];}return [];diff --git a/packages/sheets-conditional-formatting/src/index.ts b/packages/sheets-conditional-formatting/src/index.tsindex 3372ef66be..17f73d19e3 100644--- a/packages/sheets-conditional-formatting/src/index.ts+++ b/packages/sheets-conditional-formatting/src/index.ts@@ -23,9 +23,9 @@ export * from './commands/mutations/set-conditional-rule.mutation';export * from './models/type';export * from './models/conditional-formatting-rule-model';export * from './models/conditional-formatting-view-model';-export * from './utils/getStringFromDataStream';-export * from './utils/isRangesEqual';-export * from './utils/removeUndefinedAttr';+export * from './utils/get-string-from-data-stream';+export * from './utils/is-ranges-equal';+export * from './utils/remove-undefined-attr';export * from './utils/type';export * from './services/conditional-formatting.service';export * from './services/calculate-unit/utils';@@ -35,3 +35,5 @@ export * from './render/icon.render';export * from './render/type';export * from './models/icon-map';export * from './services/conditional-formatting-formula.service';+export * from './utils/anchor';+export * from './utils/create-cf-id';diff --git a/packages/sheets-conditional-formatting/src/models/conditional-formatting-rule-model.ts b/packages/sheets-conditional-formatting/src/models/conditional-formatting-rule-model.tsindex 6b6d3ce5ce..7edb407511 100644--- a/packages/sheets-conditional-formatting/src/models/conditional-formatting-rule-model.ts+++ b/packages/sheets-conditional-formatting/src/models/conditional-formatting-rule-model.ts@@ -17,15 +17,19 @@import { Inject, Injector } from '@wendellhu/redi';import { Range } from '@univerjs/core';import { Subject } from 'rxjs';+import { createCfId } from '../utils/create-cf-id';import { ConditionalFormattingService } from '../services/conditional-formatting.service';+import type { IAnchor } from '../utils/anchor';+import { findIndexByAnchor, moveByAnchor } from '../utils/anchor';+import type { IConditionFormattingRule, IRuleModel } from './type';import { ConditionalFormattingViewModel } from './conditional-formatting-view-model';type RuleOperatorType = 'delete' | 'set' | 'add' | 'sort';export class ConditionalFormattingRuleModel {- // Map<unitID ,<sheetId ,IConditionFormattingRule[]>>+ // Map<unitID ,<sheetId ,IConditionFormattingRule[]>>private _model: IRuleModel = new Map();- private _ruleChange$ = new Subject<{ rule: IConditionFormattingRule;unitId: string;subUnitId: string; type: RuleOperatorType }>();+ private _ruleChange$ = new Subject<{ rule: IConditionFormattingRule; unitId: string; subUnitId: string; type: RuleOperatorType }>();$ruleChange = this._ruleChange$.asObservable();constructor(@Inject(ConditionalFormattingViewModel) private _conditionalFormattingViewModel: ConditionalFormattingViewModel,@@ -84,9 +88,9 @@ export class ConditionalFormattingRuleModel {}}- setRule(unitId: string, subUnitId: string, rule: IConditionFormattingRule) {+ setRule(unitId: string, subUnitId: string, rule: IConditionFormattingRule, oldCfId: string) {const list = this._ensureList(unitId, subUnitId);- const oldRule = list.find((item) => item.cfId === rule.cfId);+ const oldRule = list.find((item) => item.cfId === oldCfId);if (oldRule) {const cfPriorityMap = list.map((item) => item.cfId).reduce((map, cur, index) => {map.set(cur, index);@@ -97,17 +101,20 @@ export class ConditionalFormattingRuleModel {// Otherwise the render will flash onceconst cloneRange = [...oldRule.ranges];const conditionalFormattingService = this._injector.get(ConditionalFormattingService);++ Object.assign(oldRule, rule);+const dispose = conditionalFormattingService.interceptorManager.intercept(conditionalFormattingService.interceptorManager.getInterceptPoints().beforeUpdateRuleResult, {handler: (config) => {- if (unitId === config?.unitId && subUnitId === config.subUnitId && rule.cfId === config.cfId) {+ if (unitId === config?.unitId && subUnitId === config.subUnitId && oldRule.cfId === config.cfId) {cloneRange.forEach((range) => {Range.foreach(range, (row, col) => {this._conditionalFormattingViewModel.deleteCellCf(unitId, subUnitId, row, col, oldRule.cfId);});});- rule.ranges.forEach((range) => {+ oldRule.ranges.forEach((range) => {Range.foreach(range, (row, col) => {- this._conditionalFormattingViewModel.pushCellCf(unitId, subUnitId, row, col, rule.cfId);+ this._conditionalFormattingViewModel.pushCellCf(unitId, subUnitId, row, col, oldRule.cfId);this._conditionalFormattingViewModel.sortCellCf(unitId, subUnitId, row, col, cfPriorityMap);});});@@ -115,14 +122,15 @@ export class ConditionalFormattingRuleModel {}},});- rule.ranges.forEach((range) => {++ oldRule.ranges.forEach((range) => {Range.foreach(range, (row, col) => {- this._conditionalFormattingViewModel.pushCellCf(unitId, subUnitId, row, col, rule.cfId);+ this._conditionalFormattingViewModel.pushCellCf(unitId, subUnitId, row, col, oldRule.cfId);});});- Object.assign(oldRule, rule);- this._conditionalFormattingViewModel.markRuleDirty(unitId, subUnitId, rule);- this._ruleChange$.next({ rule, subUnitId, unitId, type: 'set' });++ this._conditionalFormattingViewModel.markRuleDirty(unitId, subUnitId, oldRule);+ this._ruleChange$.next({ rule: oldRule, subUnitId, unitId, type: 'set' });}}@@ -151,17 +159,16 @@ export class ConditionalFormattingRuleModel {* example [1,2,3,4,5,6],if you move behind 5 to 2, then cfId=5,targetId=2.* if targetId does not exist, it defaults to top*/- moveRulePriority(unitId: string, subUnitId: string, cfId: string, targetCfId: string) {+ moveRulePriority(unitId: string, subUnitId: string, start: IAnchor, end: IAnchor) {const list = this._ensureList(unitId, subUnitId);- const curIndex = list.findIndex((item) => item.cfId === cfId);- const targetCfIndex = list.findIndex((item) => item.cfId === targetCfId);- if (targetCfIndex === -1 || curIndex === -1 || targetCfIndex === curIndex) {+ const curIndex = findIndexByAnchor(start, list, (rule) => rule.cfId);+ const targetCfIndex = findIndexByAnchor(end, list, (rule) => rule.cfId);+ if (targetCfIndex === null || curIndex === null || targetCfIndex === curIndex) {return;}const rule = list[curIndex];if (rule) {- list.splice(curIndex, 1);- list.splice(targetCfIndex, 0, rule);+ moveByAnchor(start, end, list, (rule) => rule.cfId);const cfPriorityMap = list.map((item) => item.cfId).reduce((map, cur, index) => {map.set(cur, index);return map;@@ -175,8 +182,7 @@ export class ConditionalFormattingRuleModel {}}- createCfId(unitId: string, subUnitId: string) {- const list = this._model.get(unitId)?.get(subUnitId);- return `${(list?.length || 0) + 1}`;+ createCfId(_unitId: string, _subUnitId: string) {+ return createCfId();}}diff --git a/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts b/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.tsindex 0bf7bbcaf2..f11086f48c 100644--- a/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts+++ b/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts@@ -40,7 +40,7 @@ type ComputeStatus = 'computing' | 'end' | 'error';interface IComputeCache { status: ComputeStatus };const beforeUpdateRuleResult = createInterceptorKey< { subUnitId: string; unitId: string; cfId: string }>('conditional-formatting-before-update-rule-result');-@OnLifecycle(LifecycleStages.Ready, ConditionalFormattingService)+@OnLifecycle(LifecycleStages.Starting, ConditionalFormattingService)export class ConditionalFormattingService extends Disposable {// <unitId,<subUnitId,<cfId,IComputeCache>>>private _ruleCacheMap: Map<string, Map<string, Map<string, IComputeCache>>> = new Map();diff --git a/packages/sheets-conditional-formatting/src/utils/__test__/anchor.spec.ts b/packages/sheets-conditional-formatting/src/utils/__test__/anchor.spec.tsnew file mode 100644index 0000000000..f32be22553--- /dev/null+++ b/packages/sheets-conditional-formatting/src/utils/__test__/anchor.spec.ts@@ -0,0 +1,340 @@+/**+ * 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 { beforeEach, describe, expect, it } from 'vitest';+import type { IAnchor } from '../anchor';+import { anchorUndoFactory, moveByAnchor, transformSupportSymmetryAnchor } from '../anchor';+import type { IConditionFormattingRule } from '../../models/type';++describe('Test anchor', () => {+ let list: IConditionFormattingRule[] = [];+ beforeEach(() => {+ list = [];+ new Array(10).fill('').forEach((_v, index) => {+ list.push({ cfId: String(index) } as IConditionFormattingRule);+ });+ });+ describe('Move forward from the back', () => {+ it('Move 8 in front of 2', () => {+ const startAnchor: IAnchor = { id: '8', type: 'self' };+ const endAnchor: IAnchor = { id: '2', type: 'before' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0182345679');++ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });+ it('Move 8 in behind of 2', () => {+ const startAnchor: IAnchor = { id: '8', type: 'self' };+ const endAnchor: IAnchor = { id: '2', type: 'after' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0128345679');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });+ it('Move 8 in front of 2, self', () => {+ const startAnchor: IAnchor = { id: '8', type: 'self' };+ const endAnchor: IAnchor = { id: '2', type: 'self' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0182345679');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });++ //--------------------------------------------------------------------------------------++ it('Move 7 in front of 2', () => {+ const startAnchor: IAnchor = { id: '8', type: 'before' };+ const endAnchor: IAnchor = { id: '2', type: 'before' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0172345689');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });+ it('Move 7 in behind of 2', () => {+ const startAnchor: IAnchor = { id: '8', type: 'before' };+ const endAnchor: IAnchor = { id: '2', type: 'after' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0127345689');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });+ it('Move 7 in front of 2,self', () => {+ const startAnchor: IAnchor = { id: '8', type: 'before' };+ const endAnchor: IAnchor = { id: '2', type: 'self' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0172345689');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });++ //--------------------------------------------------------------------------------------++ it('Move 9 in front of 2', () => {+ const startAnchor: IAnchor = { id: '8', type: 'after' };+ const endAnchor: IAnchor = { id: '2', type: 'before' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0192345678');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });+ it('Move 9 in behind of 2', () => {+ const startAnchor: IAnchor = { id: '8', type: 'after' };+ const endAnchor: IAnchor = { id: '2', type: 'after' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0129345678');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });++ it('Move 9 in front of 2,self', () => {+ const startAnchor: IAnchor = { id: '8', type: 'after' };+ const endAnchor: IAnchor = { id: '2', type: 'self' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0192345678');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });+ it('Move 9 in front of 0,self', () => {+ const startAnchor: IAnchor = { id: '8', type: 'after' };+ const endAnchor: IAnchor = { id: '0', type: 'self' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('9012345678');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });+ it('Move 9 in front of 0', () => {+ const startAnchor: IAnchor = { id: '8', type: 'after' };+ const endAnchor: IAnchor = { id: '0', type: 'before' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('9012345678');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });+ });+ describe('Move back and forth', () => {+ it('Move 2 in front of 8', () => {+ const startAnchor: IAnchor = { id: '2', type: 'self' };+ const endAnchor: IAnchor = { id: '8', type: 'before' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0134567289');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });+ it('Move 2 in behind of 8', () => {+ const startAnchor: IAnchor = { id: '2', type: 'self' };+ const endAnchor: IAnchor = { id: '8', type: 'after' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0134567829');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });+ it('Move 2 in front of 8, self', () => {+ const startAnchor: IAnchor = { id: '2', type: 'self' };+ const endAnchor: IAnchor = { id: '8', type: 'self' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0134567289');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });++ //--------------------------------------------------------------------------------------++ it('Move 1 in front of 8', () => {+ const startAnchor: IAnchor = { id: '2', type: 'before' };+ const endAnchor: IAnchor = { id: '8', type: 'before' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0234567189');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });+ it('Move 1 in behind of 8', () => {+ const startAnchor: IAnchor = { id: '2', type: 'before' };+ const endAnchor: IAnchor = { id: '8', type: 'after' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0234567819');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });+ it('Move 1 in front of 8,self', () => {+ const startAnchor: IAnchor = { id: '2', type: 'before' };+ const endAnchor: IAnchor = { id: '8', type: 'self' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0234567189');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });++ //--------------------------------------------------------------------------------------++ it('Move 3 in front of 8', () => {+ const startAnchor: IAnchor = { id: '2', type: 'after' };+ const endAnchor: IAnchor = { id: '8', type: 'before' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0124567389');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });+ it('Move 3 in behind of 8', () => {+ const startAnchor: IAnchor = { id: '2', type: 'after' };+ const endAnchor: IAnchor = { id: '8', type: 'after' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0124567839');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });++ it('Move 3 in front of 8,self', () => {+ const startAnchor: IAnchor = { id: '2', type: 'after' };+ const endAnchor: IAnchor = { id: '8', type: 'self' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0124567389');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });++ // -----------------------------------------------------++ it('Move 0 in front of 8', () => {+ const startAnchor: IAnchor = { id: '0', type: 'self' };+ const endAnchor: IAnchor = { id: '8', type: 'before' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('1234567089');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });++ it('Move 0 in behind of 8', () => {+ const startAnchor: IAnchor = { id: '1', type: 'before' };+ const endAnchor: IAnchor = { id: '8', type: 'before' };+ const redoList = transformSupportSymmetryAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId)!;+ expect(!!redoList).toBeTruthy();+ moveByAnchor(...redoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('1234567089');+ const undoList = anchorUndoFactory(...redoList)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });++ // -----------------------------------------------------+ it('use before and after', () => {+ const startAnchor: IAnchor = { id: '1', type: 'before' };+ const endAnchor: IAnchor = { id: '1', type: 'after' };+ moveByAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('1023456789');+ const undoList = anchorUndoFactory(startAnchor, endAnchor)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });++ it('use after and before', () => {+ const startAnchor: IAnchor = { id: '1', type: 'after' };+ const endAnchor: IAnchor = { id: '1', type: 'before' };+ moveByAnchor(startAnchor, endAnchor, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0213456789');+ const undoList = anchorUndoFactory(startAnchor, endAnchor)!;+ expect(!!undoList).toBeTruthy();+ moveByAnchor(...undoList, list, (rule) => rule.cfId);+ expect(list.map((item) => item.cfId).join('')).toBe('0123456789');+ });+ });+});diff --git a/packages/sheets-conditional-formatting/src/utils/anchor.ts b/packages/sheets-conditional-formatting/src/utils/anchor.tsnew file mode 100644index 0000000000..cdc448b254--- /dev/null+++ b/packages/sheets-conditional-formatting/src/utils/anchor.ts@@ -0,0 +1,143 @@+/**+ * 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.+ */++export interface IAnchor {+ id: string;+ type: 'before' | 'after' | 'self';+}++export const findIndexByAnchor = <T = unknown[]>(anchor: IAnchor, ruleList: T[], get: (v: T) => string): number | null => {+ if (!ruleList) {+ return null;+ }+ const anchorIndex = ruleList.findIndex((rule) => get(rule) === anchor.id);+ if (anchorIndex < 0) {+ return null;+ }+ switch (anchor.type) {+ case 'after': {+ return anchorIndex + 1;+ }+ case 'before': {+ return anchorIndex - 1;+ }+ case 'self': {+ return anchorIndex;+ }+ }+};+/**+ * This function has side effects that modify the ruleList+ * @param {IAnchor} start+ * @param {IAnchor} end+ * @param {ReturnType<ConditionalFormattingRuleModel['getSubunitRules']>} ruleList+ * @return {*}+ */+export const moveByAnchor = <T = unknown[]>(start: IAnchor, end: IAnchor, ruleList: T[], get: (v: T) => string) => {+ if (!ruleList) {+ return null;+ }+ const startIndex = findIndexByAnchor(start, ruleList, get);+ let endIndex = findIndexByAnchor(end, ruleList, get);++ if (startIndex === null || endIndex === null || startIndex === endIndex) {+ return;+ }+ const rule = ruleList.splice(startIndex, 1)[0];++ if (startIndex < endIndex) {+ endIndex = findIndexByAnchor(end, ruleList, get)!;+ }++ switch (end.type) {+ case 'before': {+ ruleList.splice(endIndex + 1, 0, rule);+ break;+ }+ case 'self':+ case 'after': {+ ruleList.splice(endIndex, 0, rule);+ break;+ }+ }+};++/**+ * Only [after,after] and [after,before] can support symmetric operations+ */+export const transformSupportSymmetryAnchor = <T = unknown[]>(start: IAnchor, end: IAnchor, ruleList: T[], get: (v: T) => string): [IAnchor, IAnchor] | null => {+ if (start.type === 'after' && ['after', 'before'].includes(end.type)) {+ return [start, end];+ }+ const _start = { ...start };+ const _end = { ...end };+ if (_start.type !== 'after') {+ const index = findIndexByAnchor(_start, ruleList, get);+ if (index === null) {+ return null;+ }+ if (index - 1 < 0) {+ const nextItem = ruleList[index + 1];+ if (!nextItem) {+ return null;+ } else {+ _start.id = get(nextItem);+ _start.type = 'before';+ }+ } else {+ const id = get(ruleList[index - 1]);+ _start.id = id;+ _start.type = 'after';+ }+ }+ if (!['after', 'before'].includes(_end.type)) {+ const index = findIndexByAnchor(_end, ruleList, get);+ if (index === null) {+ return null;+ }+ if (index === 0) {+ _end.type = 'before';+ } else if (index - 1 >= 0) {+ const id = get(ruleList[index - 1]);+ _end.id = id;+ _end.type = 'after';+ } else if (index + 1 <= ruleList.length - 1) {+ const id = get(ruleList[index + 1]);+ _end.id = id;+ _end.type = 'before';+ } else {+ return null;+ }+ }+ if (_start.id === _end.id && _start.type === _end.type) {+ return null;+ }+ return [_start, _end];+};+export const anchorUndoFactory = (start: IAnchor, end: IAnchor): [IAnchor, IAnchor] | null => {+ if (['after', 'before'].includes(end.type)) {+ if (start.type === 'after') {+ return [end, start];+ } else if (start.type === 'before') {+ return [end, { ...start, type: 'self' }];+ }+ }+ return null;+};++export const isAnchorEqual = (anchor1: IAnchor, anchor2: IAnchor) => {+ return anchor1.id === anchor2.id && anchor1.type === anchor2.type;+};diff --git a/packages/sheets-conditional-formatting/src/utils/create-cf-id.ts b/packages/sheets-conditional-formatting/src/utils/create-cf-id.tsnew file mode 100644index 0000000000..a9880c7bf8--- /dev/null+++ b/packages/sheets-conditional-formatting/src/utils/create-cf-id.ts@@ -0,0 +1,20 @@+/**+ * 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 { Tools } from '@univerjs/core';++// Given that unit and sunUnit will change in the case of replica creation, the ID will not be spelled in here+export const createCfId = () => `${Tools.generateRandomId(8)}`;diff --git a/packages/sheets-conditional-formatting/src/utils/getStringFromDataStream.ts b/packages/sheets-conditional-formatting/src/utils/get-string-from-data-stream.tssimilarity index 100%rename from packages/sheets-conditional-formatting/src/utils/getStringFromDataStream.tsrename to packages/sheets-conditional-formatting/src/utils/get-string-from-data-stream.tsdiff --git a/packages/sheets-conditional-formatting/src/utils/isRangesEqual.ts b/packages/sheets-conditional-formatting/src/utils/is-ranges-equal.tssimilarity index 100%rename from packages/sheets-conditional-formatting/src/utils/isRangesEqual.tsrename to packages/sheets-conditional-formatting/src/utils/is-ranges-equal.tsdiff --git a/packages/sheets-conditional-formatting/src/utils/removeUndefinedAttr.ts b/packages/sheets-conditional-formatting/src/utils/remove-undefined-attr.tssimilarity index 100%rename from packages/sheets-conditional-formatting/src/utils/removeUndefinedAttr.tsrename to packages/sheets-conditional-formatting/src/utils/remove-undefined-attr.ts