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(sheet): export some util functions from sheets (#1135)
YuHonge9b279779298
diff --git a/packages/sheets/src/commands/mutations/empty.mutation.ts b/packages/sheets/src/commands/mutations/empty.mutation.tsnew file mode 100644index 0000000000..4a1b60ebc7--- /dev/null+++ b/packages/sheets/src/commands/mutations/empty.mutation.ts@@ -0,0 +1,26 @@+/**+ * 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 type { IMutation } from '@univerjs/core';+import { CommandType } from '@univerjs/core';++export const EmptyMutation: IMutation<{}, boolean> = {+ id: 'sheet.mutation.empty',+ type: CommandType.MUTATION,+ handler: () => {+ return true;+ },+};diff --git a/packages/sheets/src/index.ts b/packages/sheets/src/index.tsindex 775231b7a0..36fcae0ac7 100644--- a/packages/sheets/src/index.ts+++ b/packages/sheets/src/index.ts@@ -175,6 +175,7 @@ export {} from './commands/mutations/add-worksheet-merge.mutation';export { DeleteRangeMutation } from './commands/mutations/delete-range.mutation';export { handleDeleteRangeMutation } from './commands/mutations/delete-range.mutation';+export { EmptyMutation } from './commands/mutations/empty.mutation';export { InsertRangeMutation } from './commands/mutations/insert-range.mutation';export { handleInsertRangeMutation } from './commands/mutations/insert-range.mutation';export {@@ -257,6 +258,9 @@ export { RefRangeService } from './services/ref-range/ref-range.service';export type { EffectRefRangeParams, IOperator } from './services/ref-range/type';export { EffectRefRangId, OperatorType } from './services/ref-range/type';export {+ handleBaseInsertRange,+ handleBaseMoveRowsCols,+ handleBaseRemoveRange,handleDeleteRangeMoveLeft,handleDeleteRangeMoveUp,handleInsertCol,@@ -268,6 +272,7 @@ export {handleMoveCols,handleMoveRange,handleMoveRows,+ rotateRange,runRefRangeMutations,} from './services/ref-range/util';export { INTERCEPTOR_POINT } from './services/sheet-interceptor/interceptor-const';diff --git a/packages/sheets/src/services/ref-range/util.ts b/packages/sheets/src/services/ref-range/util.tsindex 3bc6652ccc..338fd70f1e 100644--- a/packages/sheets/src/services/ref-range/util.ts+++ b/packages/sheets/src/services/ref-range/util.ts@@ -32,7 +32,7 @@ import type {} from './type';import { OperatorType } from './type';-const rotateRange = (range: IRange): IRange => {+export const rotateRange = (range: IRange): IRange => {// rotate {startRow:2,endRow:3,startCol:3,endCol:10} to// {startRow:3,endRow:10,startCol:2,endRow:3}return {@@ -49,7 +49,7 @@ interface ILine {/*** see docs/tldr/ref-range/move-rows-cols.tldr*/-const handleBaseMoveRowsCols = (+export const handleBaseMoveRowsCols = (fromRange: ILine,toRange: ILine,effectRange: ILine@@ -227,7 +227,7 @@ export const handleMoveRange = (param: IMoveRangeCommand, targetRange: IRange) =};// see docs/tldr/ref-range/remove-rows-cols.tldr-const handleBaseRemoveRange = (removeRange: IRange, targetRange: IRange) => {+export const handleBaseRemoveRange = (removeRange: IRange, targetRange: IRange) => {const getLength = (range: IRange): number => range.endColumn - range.startColumn + 1;const getRowLength = (range: IRange): number => range.endRow - range.startRow + 1;if (removeRange.startRow <= targetRange.startRow && removeRange.endRow >= targetRange.endRow) {@@ -315,7 +315,7 @@ export const handleIRemoveRow = (param: IRemoveRowColCommand, targetRange: IRangreturn operators;};// see docs/tldr/ref-range/insert-rows-cols.tldr-const handleBaseInsertRange = (insertRange: IRange, targetRange: IRange) => {+export const handleBaseInsertRange = (insertRange: IRange, targetRange: IRange) => {const getLength = (range: IRange): number => range.endColumn - range.startColumn + 1;if (insertRange.startRow <= targetRange.startRow && insertRange.endRow >= targetRange.endRow) {if (