Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ref-range): support default range change util #1351

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/sheets/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ export {
handleMoveRows,
rotateRange,
runRefRangeMutations,
handleDefaultRangeChangeWithEffectRefCommands,
} from './services/ref-range/util';
export { INTERCEPTOR_POINT } from './services/sheet-interceptor/interceptor-const';
export { SheetInterceptorService } from './services/sheet-interceptor/sheet-interceptor.service';
Expand Down
56 changes: 54 additions & 2 deletions packages/sheets/src/services/ref-range/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import type { IRange, Nullable } from '@univerjs/core';
import type { ICommandInfo, IRange, Nullable } from '@univerjs/core';
import { RANGE_TYPE, Rectangle } from '@univerjs/core';

import type {
Expand All @@ -30,7 +30,7 @@ import type {
IOperator,
IRemoveRowColCommand,
} from './type';
import { OperatorType } from './type';
import { EffectRefRangId, OperatorType } from './type';

const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;
export const handleRangeTypeInput = (range: IRange) => {
Expand Down Expand Up @@ -538,3 +538,55 @@ export const runRefRangeMutations = (operators: IOperator[], range: IRange) => {
}
return result;
};

export const handleDefaultRangeChangeWithEffectRefCommands = (range: IRange, commandInfo: ICommandInfo) => {
let operator: IOperator[] = [];
switch (commandInfo.id) {
case EffectRefRangId.DeleteRangeMoveLeftCommandId:{
operator = handleDeleteRangeMoveLeft(commandInfo as IDeleteRangeMoveLeftCommand, range);
break;
}
case EffectRefRangId.DeleteRangeMoveUpCommandId:{
operator = handleDeleteRangeMoveUp(commandInfo as IDeleteRangeMoveUpCommand, range);
break;
}
case EffectRefRangId.InsertColCommandId:{
operator = handleInsertCol(commandInfo as IInsertColCommand, range);
break;
}
case EffectRefRangId.InsertRangeMoveDownCommandId:{
operator = handleInsertRangeMoveDown(commandInfo as IInsertRangeMoveDownCommand, range);
break;
}
case EffectRefRangId.InsertRangeMoveRightCommandId:{
operator = handleInsertRangeMoveRight(commandInfo as IInsertRangeMoveRightCommand, range);
break;
}
case EffectRefRangId.InsertRowCommandId:{
operator = handleInsertRow(commandInfo as IInsertRowCommand, range);
break;
}
case EffectRefRangId.MoveColsCommandId:{
operator = handleMoveCols(commandInfo as IMoveColsCommand, range);
break;
}
case EffectRefRangId.MoveRangeCommandId:{
operator = handleMoveRange(commandInfo as IMoveRangeCommand, range);
break;
}
case EffectRefRangId.MoveRowsCommandId:{
operator = handleMoveRows(commandInfo as IMoveRowsCommand, range);
break;
}
case EffectRefRangId.RemoveColCommandId:{
operator = handleIRemoveCol(commandInfo as IRemoveRowColCommand, range);
break;
}
case EffectRefRangId.RemoveRowCommandId:{
operator = handleIRemoveRow(commandInfo as IRemoveRowColCommand, range);
break;
}
}
const resultRange = runRefRangeMutations(operator, range);
return resultRange;
};
Loading