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
fix(paste): fix some issues with row height and column width during copy and paste (#6450)
wpxp123456c5d22f34d116
diff --git a/packages/core/src/shared/object-matrix.ts b/packages/core/src/shared/object-matrix.tsindex 9ebe52de4e..08b16a706a 100644--- a/packages/core/src/shared/object-matrix.ts+++ b/packages/core/src/shared/object-matrix.ts@@ -62,10 +62,6 @@ export function getArrayLength<T>(o: IObjectArrayPrimitiveType<T> | IObjectMatrireturn maxIndex + 1;}-/**- * This function has bug of undefined value to be inserted.- * @deprecated- */export function insertMatrixArray<T>(index: number,value: T,@@ -76,7 +72,11 @@ export function insertMatrixArray<T>(// move all items after index in backward orderfor (let i = length - 1; i >= index; i--) {- array[i + 1] = array[i];+ if (array[i] === undefined) {+ delete array[i + 1];+ } else {+ array[i + 1] = array[i];+ }}array[index] = value;diff --git a/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts b/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.tsindex 9a772001cc..5cd57a4313 100644--- a/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts+++ b/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts@@ -22,8 +22,6 @@ import type {IObjectArrayPrimitiveType,IObjectMatrixPrimitiveType,IRange,- IRowData,- Nullable,Workbook,Worksheet,} from '@univerjs/core';@@ -32,7 +30,6 @@ import type {IInsertRowMutationParams,ISetRangeValuesMutationParams,ISetWorksheetColWidthMutationParams,- ISetWorksheetRowHeightMutationParams,} from '@univerjs/sheets';import type {ICellDataWithSpanInfo,@@ -44,10 +41,8 @@ import type {import type { IScrollStateWithSearchParam } from '../../services/scroll-manager.service';import type { IUniverSheetsUIConfig } from '../config.schema';import {- BooleanNumber,DEFAULT_WORKSHEET_COLUMN_WIDTH,DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY,- DEFAULT_WORKSHEET_ROW_HEIGHT,DOCS_NORMAL_EDITOR_UNIT_ID_KEY,extractPureTextFromCell,getNumfmtParseValueFilter,@@ -81,7 +76,7 @@ import {SetRangeValuesMutation,SetRangeValuesUndoMutationFactory,SetWorksheetColWidthMutation,- SetWorksheetRowHeightMutation,+ SetWorksheetColWidthMutationFactory,} from '@univerjs/sheets';import { BuiltInUIPart, connectInjector, IMessageService, IUIPartsService } from '@univerjs/ui';import { Subject, takeUntil } from 'rxjs';@@ -227,6 +222,8 @@ export class SheetClipboardController extends RxDisposable {// register basic sheet clipboard hooksthis.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks()));+ this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingRowsHook()));+ this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingColumnsHook()));this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const disposables = this._initSpecialPasteHooks().map((hook) =>this._sheetClipboardService.addClipboardHook(hook)@@ -328,22 +325,13 @@ export class SheetClipboardController extends RxDisposable {};}- // eslint-disable-next-line max-lines-per-functionprivate _initPastingHook(): ISheetClipboardHook {const self = this;- let unitId: string | null = null;- let subUnitId: string | null = null;- let currentSheet: Worksheet | null = null;-return {id: PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE,isDefaultHook: true,- onBeforePaste({ unitId: unitId_, subUnitId: subUnitId_, range }) {- currentSheet = self._getWorksheet(unitId_, subUnitId_);- unitId = unitId_;- subUnitId = subUnitId_;-+ onBeforePaste({ range }) {// examine if pasting would cause number of cells to exceed the upper limit// this is not implemented yetconst maxConfig = self._configService.getConfig<number>(MAX_CELL_PER_SHEET_KEY);@@ -356,234 +344,133 @@ export class SheetClipboardController extends RxDisposable {}); // TODO: show error inforeturn false;}-return true;},- // eslint-disable-next-line max-lines-per-function- onPasteRows(pasteTo, rowProperties) {- const { range } = pasteTo;- const redoMutations: IMutationInfo[] = [];- const undoMutations: IMutationInfo[] = [];+ onPastePlainText(pasteTo: ISheetDiscreteRangeLocation, text: string, payload: ICopyPastePayload) {+ return self._onPastePlainText(pasteTo, text, payload);+ },- // if the range is outside ot the worksheet's boundary, we should add rows- const maxRow = currentSheet!.getMaxRows();- const rowCount = maxRow - 1;- const addingRowsCount = range.rows[range.rows.length - 1] - rowCount;- const existingRowsCount = rowProperties.length - addingRowsCount;+ onPasteCells(+ pasteFrom: ISheetDiscreteRangeLocation,+ pasteTo: ISheetDiscreteRangeLocation,+ data: ObjectMatrix<ICellDataWithSpanInfo>,+ payload: ICopyPastePayload+ ) {+ return self._onPasteCells(pasteFrom, pasteTo, data, payload);+ },+ };+ }- const rowManager = currentSheet!.getRowManager();- if (addingRowsCount > 0) {- const rowInfo: IObjectArrayPrimitiveType<IRowData> = {};- rowProperties.slice(existingRowsCount).forEach((property, index) => {- const { height: PropertyHeight } = property || {};- if (PropertyHeight) {- rowInfo[index] = {- h: Number.parseFloat(PropertyHeight),- hd: BooleanNumber.FALSE,- };- }- });+ private _initPastingRowsHook(): ISheetClipboardHook {+ const self = this;- const addRowRange = {- startColumn: range.cols[0],- endColumn: range.cols[range.cols.length - 1],- endRow: range.rows[range.rows.length - 1],- startRow: maxRow,- };+ return {+ id: PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE_ROWS,+ isDefaultHook: true,- const addRowMutation: IInsertRowMutationParams = {- unitId: unitId!,- subUnitId: subUnitId!,- range: addRowRange,- rowInfo,- };- redoMutations.push({- id: InsertRowMutation.id,- params: addRowMutation,- });- undoMutations.push({- id: RemoveRowMutation.id,- params: {- unitId,- subUnitId,- range: addRowRange,- },- });+ onPasteRows(pasteTo) {+ const redos: IMutationInfo[] = [];+ const undos: IMutationInfo[] = [];+ const { range, unitId, subUnitId } = pasteTo;+ const { rows, cols } = range;++ if (!rows || !cols || rows.length === 0 || cols.length === 0) {+ return { redos, undos };}- // get row height of existing rows- // TODO When Excel pasted, there was no width height, Do we still need to set the height?- const rowHeight: IObjectArrayPrimitiveType<number> = {};- const originRowHeight: IObjectArrayPrimitiveType<number> = {};- rowProperties.slice(0, existingRowsCount).forEach((property, index) => {- const { height: propertyHeight } = property;- if (propertyHeight) {- const rowConfigBeforePaste = rowManager.getRow(range.rows[0] + index);- const willSetHeight = Number.parseFloat(propertyHeight);- if (rowConfigBeforePaste) {- const { h = DEFAULT_WORKSHEET_ROW_HEIGHT, ah = 0 } = rowConfigBeforePaste;- const nowRowHeight = Math.max(h, ah);- if (willSetHeight > nowRowHeight) {- rowHeight[index + range.rows[0]] = willSetHeight;- originRowHeight[index + range.rows[0]] = nowRowHeight;- } else {- rowHeight[index + range.rows[0]] = nowRowHeight;- originRowHeight[index + range.rows[0]] = nowRowHeight;- }- } else {- rowHeight[index + range.rows[0]] = willSetHeight;- originRowHeight[index + range.rows[0]] = rowManager.getRow(range.rows[0] + index)?.h ?? DEFAULT_WORKSHEET_ROW_HEIGHT;- }- }- });+ const worksheet = self._getWorksheet(unitId, subUnitId);+ const worksheetLastRow = worksheet.getMaxRows() - 1;- // apply row properties to the existing rows- if (Object.keys(rowHeight).length) {- const setRowPropertyMutation: ISetWorksheetRowHeightMutationParams = {- unitId: unitId!,- subUnitId: subUnitId!,- ranges: [{- startRow: range.rows[0],- endRow: Math.min(range.rows[range.rows.length - 1], maxRow),- startColumn: range.cols[0],- endColumn: range.cols[range.cols.length - 1],- }],- rowHeight,- };- redoMutations.push({- id: SetWorksheetRowHeightMutation.id,- params: setRowPropertyMutation,- });+ const pasteRangeEndRow = rows[rows.length - 1];+ const pasteRangeStartColumn = cols[0];+ const pasteRangeEndColumn = cols[cols.length - 1];- undoMutations.push({- id: SetWorksheetRowHeightMutation.id,- params: {- ...setRowPropertyMutation,- rowHeight: originRowHeight,+ // If the range is outside ot the worksheet's boundary, we should add rows+ const addingRowsCount = pasteRangeEndRow - worksheetLastRow;+ if (addingRowsCount > 0) {+ const insertRowMutationParams: IInsertRowMutationParams = {+ unitId,+ subUnitId,+ range: {+ startRow: worksheetLastRow + 1,+ endRow: pasteRangeEndRow,+ startColumn: pasteRangeStartColumn,+ endColumn: pasteRangeEndColumn,},+ };++ redos.push({+ id: InsertRowMutation.id,+ params: insertRowMutationParams,+ });+ undos.push({+ id: RemoveRowMutation.id,+ params: insertRowMutationParams,});}return {- redos: redoMutations,- undos: undoMutations,+ redos,+ undos,};},+ };+ }- // eslint-disable-next-line max-lines-per-function- onPasteColumns(pasteTo, colProperties, pasteType) {- const { range } = pasteTo;- const redoMutations: IMutationInfo[] = [];- const undoMutations: IMutationInfo[] = [];+ private _initPastingColumnsHook(): ISheetClipboardHook {+ const self = this;- // if the range is outside ot the worksheet's boundary, we should add rows- const maxColumn = currentSheet!.getMaxColumns();- const colCount = maxColumn - 1;- const addingColsCount = range.cols[range.cols.length - 1] - colCount;- const existingColsCount = colProperties.length - addingColsCount;+ return {+ id: PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE_COLUMNS,+ isDefaultHook: true,- const defaultColumnWidth = self._configService.getConfig<number>(DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY) ?? DEFAULT_WORKSHEET_COLUMN_WIDTH;- const pasteToCols = range.cols;- const startColumn = pasteToCols[0];+ onPasteColumns(pasteTo) {+ const redos: IMutationInfo[] = [];+ const undos: IMutationInfo[] = [];+ const { range, unitId, subUnitId } = pasteTo;+ const { rows, cols } = range;- if (addingColsCount > 0) {- const addColRange = {- startRow: range.rows[0],- endRow: range.rows[range.rows.length - 1],- endColumn: range.cols[range.cols.length - 1],- startColumn: maxColumn,- };- const addColMutation: IInsertColMutationParams = {- unitId: unitId!,- subUnitId: subUnitId!,- range: addColRange,- colInfo: colProperties.slice(existingColsCount).map((property, index) => ({- w: property.width ? Math.max(+property.width, currentSheet!.getColumnWidth(pasteToCols[index])) : defaultColumnWidth,- hd: BooleanNumber.FALSE,- })),- };- redoMutations.push({- id: InsertColMutation.id,- params: addColMutation,- });- undoMutations.push({- id: RemoveColMutation.id,- params: {- unitId,- subUnitId,- range: addColRange,- },- });+ if (!rows || !cols || rows.length === 0 || cols.length === 0) {+ return { redos, undos };}- const targetSetColPropertyParams = {- unitId: unitId!,- subUnitId: subUnitId!,- ranges: [{- startRow: range.rows[0],- endRow: range.rows[range.rows.length - 1],-- startColumn: range.cols[0],- endColumn: Math.min(range.cols[range.cols.length - 1], maxColumn),- }],- };+ const worksheet = self._getWorksheet(unitId, subUnitId);+ const worksheetLastColumn = worksheet.getMaxColumns() - 1;- // apply col properties to the existing rows- if (colProperties.length > 0) {- const setColPropertyMutation: ISetWorksheetColWidthMutationParams = {- ...targetSetColPropertyParams,- colWidth: colProperties- .slice(0, existingColsCount)- .reduce((p, c, index) => {- p[index + startColumn] = c.width ? Math.max(+c.width, currentSheet!.getColumnWidth(pasteToCols[index]) ?? defaultColumnWidth) : defaultColumnWidth;- return p;- }, {} as IObjectArrayPrimitiveType<number>),- };+ const pasteRangeStartRow = rows[0];+ const pasteRangeEndRow = rows[rows.length - 1];+ const pasteRangeEndColumn = cols[cols.length - 1];- const undoSetColPropertyParams: ISetWorksheetColWidthMutationParams = {- ...targetSetColPropertyParams,- colWidth: colProperties- .slice(0, existingColsCount)- .reduce((p, c, index) => {- p[index + startColumn] = currentSheet!.getColumnWidth(pasteToCols[index]) ?? defaultColumnWidth;- return p;- }, {} as IObjectArrayPrimitiveType<Nullable<number>>),+ // If the range is outside ot the worksheet's boundary, we should add columns+ const addingColsCount = pasteRangeEndColumn - worksheetLastColumn;+ if (addingColsCount > 0) {+ const InsertColMutationParams: IInsertColMutationParams = {+ unitId,+ subUnitId,+ range: {+ startRow: pasteRangeStartRow,+ endRow: pasteRangeEndRow,+ startColumn: worksheetLastColumn + 1,+ endColumn: pasteRangeEndColumn,+ },};- redoMutations.push({- id: SetWorksheetColWidthMutation.id,- params: setColPropertyMutation,+ redos.push({+ id: InsertColMutation.id,+ params: InsertColMutationParams,});-- undoMutations.push({- id: SetWorksheetColWidthMutation.id,- params: undoSetColPropertyParams,+ undos.push({+ id: RemoveColMutation.id,+ params: InsertColMutationParams,});}return {- redos: redoMutations,- undos: undoMutations,+ redos,+ undos,};},-- onPastePlainText(pasteTo: ISheetDiscreteRangeLocation, text: string, payload: ICopyPastePayload) {- return self._onPastePlainText(pasteTo, text, payload);- },-- onPasteCells(- pasteFrom: ISheetDiscreteRangeLocation,- pasteTo: ISheetDiscreteRangeLocation,- data: ObjectMatrix<ICellDataWithSpanInfo>,- payload: ICopyPastePayload- ) {- return self._onPasteCells(pasteFrom, pasteTo, data, payload);- },-- onAfterPaste(success) {- currentSheet = null;- },};}@@ -771,74 +658,67 @@ export class SheetClipboardController extends RxDisposable {};},onPasteColumns(pasteTo, colProperties, payload) {- const workbook = self._instanceService.getCurrentUnitForType<Workbook>(UniverInstanceType.UNIVER_SHEET)!;- const unitId = workbook.getUnitId();- const subUnitId = workbook.getActiveSheet()?.getSheetId();+ const redos: IMutationInfo[] = [];+ const undos: IMutationInfo[] = [];- if (!unitId || !subUnitId) {- throw new Error('Cannot find unitId or subUnitId');+ if (payload.pasteType !== PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH) {+ return { redos, undos };}- const redoMutations: IMutationInfo[] = [];- const undoMutations: IMutationInfo[] = [];- const currentSheet = self._getWorksheet(unitId, subUnitId);-- const { range } = pasteTo;- const pasteToCols = range.cols;- const startColumn = pasteToCols[0];- // if the range is outside ot the worksheet's boundary, we should add rows- const maxColumn = currentSheet!.getMaxColumns();- const addingColsCount = range.cols[range.cols.length - 1] - maxColumn;- const existingColsCount = colProperties.length - addingColsCount;+ const { range, unitId, subUnitId } = pasteTo;+ const { rows, cols } = range;++ if (!rows || !cols || rows.length === 0 || cols.length === 0) {+ return { redos, undos };+ }++ const worksheet = self._getWorksheet(unitId, subUnitId);const defaultColumnWidth = self._configService.getConfig<number>(DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY) ?? DEFAULT_WORKSHEET_COLUMN_WIDTH;- const setColPropertyMutation: ISetWorksheetColWidthMutationParams = {- unitId: unitId!,- subUnitId: subUnitId!,- ranges: [{- startRow: range.rows[0],- endRow: Math.min(range.cols[range.cols.length - 1], maxColumn),- startColumn: range.cols[0],- endColumn: range.cols[range.cols.length - 1],- }],- colWidth: colProperties- .slice(0, existingColsCount)- .reduce((p, c, index) => {- p[index + startColumn] = c.width ? Math.max(+c.width, currentSheet!.getColumnWidth(pasteToCols[index]) ?? defaultColumnWidth) : defaultColumnWidth;- return p;- }, {} as IObjectArrayPrimitiveType<number>),- };+ const pasteRangeStartRow = rows[0];+ const pasteRangeEndRow = rows[rows.length - 1];+ const pasteRangeStartColumn = cols[0];+ const pasteRangeEndColumn = cols[cols.length - 1];- const undoSetColPropertyMutation: ISetWorksheetColWidthMutationParams = {- unitId: unitId!,- subUnitId: subUnitId!,- ranges: [{- startRow: range.rows[0],- endRow: Math.min(range.cols[range.cols.length - 1], maxColumn),- startColumn: range.cols[0],- endColumn: range.cols[range.cols.length - 1],- }],- colWidth: colProperties- .slice(0, existingColsCount)- .reduce((p, c, index) => {- p[index + startColumn] = currentSheet!.getColumnWidth(pasteToCols[index]) ?? defaultColumnWidth;- return p;- }, {} as IObjectArrayPrimitiveType<Nullable<number>>),- };+ const colPropertiesLength = colProperties.length;+ if (colPropertiesLength > 0) {+ const colWidth: IObjectArrayPrimitiveType<number> = {};- redoMutations.push({- id: SetWorksheetColWidthMutation.id,- params: setColPropertyMutation,- });+ for (let c = pasteRangeStartColumn; c <= pasteRangeEndColumn; c++) {+ const index = (c - pasteRangeStartColumn) % colPropertiesLength;+ const property = colProperties[index];+ if (property.width && Number(property.width) !== defaultColumnWidth) {+ colWidth[c] = Number(property.width);+ }+ }- undoMutations.push({- id: SetWorksheetColWidthMutation.id,- params: undoSetColPropertyMutation,- });+ const setWorksheetColWidthMutationParams: ISetWorksheetColWidthMutationParams = {+ unitId,+ subUnitId,+ ranges: [+ {+ startRow: pasteRangeStartRow,+ endRow: pasteRangeEndRow,+ startColumn: pasteRangeStartColumn,+ endColumn: pasteRangeEndColumn,+ },+ ],+ colWidth,+ };++ redos.push({+ id: SetWorksheetColWidthMutation.id,+ params: setWorksheetColWidthMutationParams,+ });+ undos.unshift({+ id: SetWorksheetColWidthMutation.id,+ params: SetWorksheetColWidthMutationFactory(setWorksheetColWidthMutationParams, worksheet),+ });+ }return {- redos: redoMutations,- undos: undoMutations,+ redos,+ undos,};},};diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-copy-filter.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-copy-filter.spec.tsindex 324465e404..3b831c746a 100644--- a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-copy-filter.spec.ts+++ b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-copy-filter.spec.ts@@ -23,6 +23,7 @@ import {SetRangeValuesMutation,SetSelectionsOperation,SetWorksheetColWidthMutation,+ SetWorksheetRowAutoHeightMutation,SetWorksheetRowHeightMutation,} from '@univerjs/sheets';import { afterEach, beforeEach, describe, expect, it } from 'vitest';@@ -90,6 +91,7 @@ describe('Test clipboard', () => {commandService.registerCommand(AddWorksheetMergeMutation);commandService.registerCommand(RemoveWorksheetMergeMutation);commandService.registerCommand(SetSelectionsOperation);+ commandService.registerCommand(SetWorksheetRowAutoHeightMutation);sheetClipboardService = get(ISheetClipboardService);diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-copy-with-default-style.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-copy-with-default-style.spec.tsindex 4e73eb8fd0..c48264148b 100644--- a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-copy-with-default-style.spec.ts+++ b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-copy-with-default-style.spec.ts@@ -23,6 +23,7 @@ import {SetRangeValuesMutation,SetSelectionsOperation,SetWorksheetColWidthMutation,+ SetWorksheetRowAutoHeightMutation,SetWorksheetRowHeightMutation,} from '@univerjs/sheets';import { afterEach, beforeEach, describe, expect, it } from 'vitest';@@ -116,6 +117,7 @@ describe('Test clipboard', () => {commandService.registerCommand(AddWorksheetMergeMutation);commandService.registerCommand(RemoveWorksheetMergeMutation);commandService.registerCommand(SetSelectionsOperation);+ commandService.registerCommand(SetWorksheetRowAutoHeightMutation);sheetClipboardService = get(ISheetClipboardService);diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-alignment.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-alignment.spec.tsindex f960ba7da0..6022873f6a 100644--- a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-alignment.spec.ts+++ b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-alignment.spec.ts@@ -22,6 +22,7 @@ import {SetRangeValuesMutation,SetSelectionsOperation,SetWorksheetColWidthMutation,+ SetWorksheetRowAutoHeightMutation,SetWorksheetRowHeightMutation,SheetsSelectionsService,} from '@univerjs/sheets';@@ -78,6 +79,8 @@ describe('Test clipboard', () => {commandService.registerCommand(AddWorksheetMergeMutation);commandService.registerCommand(RemoveWorksheetMergeMutation);commandService.registerCommand(SetSelectionsOperation);+ commandService.registerCommand(SetWorksheetRowAutoHeightMutation);+sheetSkeletonManagerService = get(SheetSkeletonManagerService);sheetClipboardService = get(ISheetClipboardService);diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-border.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-border.spec.tsindex 1d9d64b29d..f1a4a50a4b 100644--- a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-border.spec.ts+++ b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-border.spec.ts@@ -22,6 +22,7 @@ import {SetRangeValuesMutation,SetSelectionsOperation,SetWorksheetColWidthMutation,+ SetWorksheetRowAutoHeightMutation,SetWorksheetRowHeightMutation,SheetsSelectionsService,} from '@univerjs/sheets';@@ -79,6 +80,8 @@ describe('Test clipboard', () => {commandService.registerCommand(AddWorksheetMergeMutation);commandService.registerCommand(RemoveWorksheetMergeMutation);commandService.registerCommand(SetSelectionsOperation);+ commandService.registerCommand(SetWorksheetRowAutoHeightMutation);+sheetSkeletonManagerService = get(SheetSkeletonManagerService);sheetClipboardService = get(ISheetClipboardService);diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-col-width.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-col-width.spec.tsdeleted file mode 100644index ecdb633ec4..0000000000--- a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-col-width.spec.ts+++ /dev/null@@ -1,155 +0,0 @@-/**- * Copyright 2023-present DreamNum Co., Ltd.- *- * 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 { Injector, Univer } from '@univerjs/core';-import { ICommandService, IUniverInstanceService, LocaleType, RANGE_TYPE } from '@univerjs/core';-import {- AddWorksheetMergeMutation,- RemoveWorksheetMergeMutation,- SetRangeValuesMutation,- SetSelectionsOperation,- SetWorksheetColWidthMutation,- SetWorksheetRowHeightMutation,- SheetsSelectionsService,-} from '@univerjs/sheets';-import { afterEach, beforeEach, describe, expect, it } from 'vitest';-import { SheetSkeletonManagerService } from '../../sheet-skeleton-manager.service';-import { ISheetClipboardService } from '../clipboard.service';-import { parseTableRows } from '../html-to-usm/converter';-import { clipboardTestBed } from './clipboard-test-bed';--const colWidthHtml = '<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=ProgId content=Excel.Sheet><meta name=Generator content="Microsoft Excel 15"><link id=Main-File rel=Main-File href="file:////Users/yuanbin/Library/Group%20Containers/UBF8T346G9.Office/TemporaryItems/msohtmlclip/clip.htm"><link rel=File-List href="file:////Users/yuanbin/Library/Group%20Containers/UBF8T346G9.Office/TemporaryItems/msohtmlclip/clip_filelist.xml"><style><!--table{mso-displayed-decimal-separator:"\.";mso-displayed-thousand-separator:"\,";}@page{margin:1.0in .75in 1.0in .75in;mso-header-margin:.5in;mso-footer-margin:.5in;}.font5{color:windowtext;font-size:9.0pt;font-weight:400;font-style:normal;text-decoration:none;font-family:宋体;mso-generic-font-family:auto;mso-font-charset:134;}tr{mso-height-source:auto;mso-ruby-visibility:none;}col{mso-width-source:auto;mso-ruby-visibility:none;}br{mso-data-placement:same-cell;}td{padding-top:1px;padding-right:1px;padding-left:1px;mso-ignore:padding;color:black;font-size:11.0pt;font-weight:400;font-style:normal;text-decoration:none;font-family:宋体;mso-generic-font-family:auto;mso-font-charset:134;mso-number-format:General;text-align:general;vertical-align:middle;border:none;mso-background-source:auto;mso-pattern:auto;mso-protection:locked visible;white-space:nowrap;mso-rotate:0;}.xl65{text-align:center;vertical-align:bottom;}ruby{ruby-align:left;}rt{color:windowtext;font-size:9.0pt;font-weight:400;font-style:normal;text-decoration:none;font-family:宋体;mso-generic-font-family:auto;mso-font-charset:134;mso-char-type:none;display:none;}--></style></head><body link=blue vlink=purple><table border=0 cellpadding=0 cellspacing=0 width=2573 style=\'border-collapse:collapse;width:1931pt\'><col width=573 style=\'mso-width-source:userset;mso-width-alt:18346;width:430pt\'><col width=415 style=\'mso-width-source:userset;mso-width-alt:13269;width:311pt\'><col width=441 style=\'mso-width-source:userset;mso-width-alt:14122;width:331pt\'><col width=73 span=3 style=\'width:55pt\'><col width=713 style=\'mso-width-source:userset;mso-width-alt:22826;width:535pt\'><col width=139 style=\'mso-width-source:userset;mso-width-alt:4437;width:104pt\'><col width=73 style=\'width:55pt\'><tr height=67 style=\'mso-height-source:userset;height:50.0pt\'><!--StartFragment--><td height=67 width=573 style=\'height:50.0pt;width:430pt\'>test col width<span style=\'mso-spacerun:yes\'> </span></td><td width=415 style=\'width:311pt\'>test col width</td><td width=441 style=\'width:331pt\'></td><td colspan=2 width=146 style=\'mso-ignore:colspan;width:110pt\'>col width</td><td class=xl65 width=73 style=\'width:55pt\'></td><td width=713 style=\'width:535pt\'>col width</td><td width=139 style=\'width:104pt\'></td><td width=73 style=\'width:55pt\'></td><!--EndFragment--></tr></table></body></html>';--const rowHeightFloatHtml = '<meta charset=\'utf-8\'><html><head></head><body><google data-copy-id="Uv1RxY" -sheets-html-origin=""><table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none"><colgroup><col width="88"><col width="88"><col width="88"></colgroup><tbody><tr style="height: 73.546875px;"><td>qweqwe</td><td></td><td></td></tr></tbody></table></google></body></html>';--describe('Test clipboard', () => {- let univer: Univer;- let get: Injector['get'];- let commandService: ICommandService;- let sheetClipboardService: ISheetClipboardService;- let sheetSkeletonManagerService: SheetSkeletonManagerService;-- beforeEach(async () => {- const testBed = clipboardTestBed({- id: 'test',- appVersion: '3.0.0-alpha',- sheets: {- sheet1: {- id: 'sheet1',- cellData: {- 0: {- 0: {- v: 1,- },- },- },- columnCount: 100,- rowCount: 100,- },- },- locale: LocaleType.ZH_CN,- name: '',- sheetOrder: [],- styles: {},- });- univer = testBed.univer;- get = testBed.get;-- commandService = get(ICommandService);- commandService.registerCommand(SetRangeValuesMutation);- commandService.registerCommand(SetWorksheetRowHeightMutation);- commandService.registerCommand(SetWorksheetColWidthMutation);- commandService.registerCommand(AddWorksheetMergeMutation);- commandService.registerCommand(RemoveWorksheetMergeMutation);- commandService.registerCommand(SetSelectionsOperation);- sheetSkeletonManagerService = get(SheetSkeletonManagerService);- sheetClipboardService = get(ISheetClipboardService);- });-- afterEach(() => {- univer?.dispose();- });-- describe('Test paste col width ', () => {- beforeEach(() => {- const selectionManager = get(SheetsSelectionsService);-- const startRow = 10;- const startColumn = 10;- const endRow = 10;- const endColumn = 10;-- selectionManager.addSelections([- {- range: { startRow, startColumn, endRow, endColumn, rangeType: RANGE_TYPE.NORMAL },- primary: null,- style: null,- },- ]);-- sheetSkeletonManagerService.setCurrent({- sheetId: 'sheet1',- });- });- it('test col width', async () => {- const worksheet = get(IUniverInstanceService).getUniverSheetInstance('test')?.getSheetBySheetId('sheet1');- if (!worksheet) return false;- const res = await sheetClipboardService.legacyPaste(colWidthHtml);- expect(res).toBeTruthy();- const columnManager = worksheet.getColumnManager();- expect(columnManager.getColumnWidth(10)).toBe(573);- expect(columnManager.getColumnWidth(11)).toBe(415);- expect(columnManager.getColumnWidth(12)).toBe(441);- expect(columnManager.getColumnWidth(13)).toBe(88);- expect(columnManager.getColumnWidth(16)).toBe(713);- expect(columnManager.getColumnWidth(17)).toBe(139);- expect(columnManager.getColumnWidth(18)).toBe(88);- });- });-- describe('Test paste row height ', () => {- beforeEach(() => {- const selectionManager = get(SheetsSelectionsService);-- const startRow = 10;- const startColumn = 10;- const endRow = 10;- const endColumn = 10;-- selectionManager.addSelections([- {- range: { startRow, startColumn, endRow, endColumn, rangeType: RANGE_TYPE.NORMAL },- primary: null,- style: null,- },- ]);-- sheetSkeletonManagerService.setCurrent({- sheetId: 'sheet1',- });- });- it('test row height', async () => {- const worksheet = get(IUniverInstanceService).getUniverSheetInstance('test')?.getSheetBySheetId('sheet1');- if (!worksheet) return false;- const res = parseTableRows(rowHeightFloatHtml);- expect(Number(res.rowProperties[0]?.height)).toBe(73);- const pasteRes = await sheetClipboardService.legacyPaste(rowHeightFloatHtml);- expect(pasteRes).toBeTruthy();- const rowManager = worksheet.getRowManager();- expect(rowManager.getRowHeight(10)).toBe(73);- });- });-});diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-font.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-font.spec.tsindex 2c62ae463d..0d58d4c848 100644--- a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-font.spec.ts+++ b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-font.spec.ts@@ -22,6 +22,7 @@ import {SetRangeValuesMutation,SetSelectionsOperation,SetWorksheetColWidthMutation,+ SetWorksheetRowAutoHeightMutation,SetWorksheetRowHeightMutation,SheetsSelectionsService,} from '@univerjs/sheets';@@ -79,6 +80,8 @@ describe('Test clipboard', () => {commandService.registerCommand(AddWorksheetMergeMutation);commandService.registerCommand(RemoveWorksheetMergeMutation);commandService.registerCommand(SetSelectionsOperation);+ commandService.registerCommand(SetWorksheetRowAutoHeightMutation);+sheetSkeletonManagerService = get(SheetSkeletonManagerService);sheetClipboardService = get(ISheetClipboardService);diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-form-excel.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-form-excel.spec.tsindex e925c76157..0ae813f688 100644--- a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-form-excel.spec.ts+++ b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-form-excel.spec.ts@@ -23,6 +23,7 @@ import {SetRangeValuesMutation,SetSelectionsOperation,SetWorksheetColWidthMutation,+ SetWorksheetRowAutoHeightMutation,SetWorksheetRowHeightMutation,SheetsSelectionsService,} from '@univerjs/sheets';@@ -99,6 +100,7 @@ describe('Test clipboard', () => {commandService.registerCommand(RemoveWorksheetMergeMutation);commandService.registerCommand(SetSelectionsOperation);commandService.registerCommand(MoveRangeMutation);+ commandService.registerCommand(SetWorksheetRowAutoHeightMutation);sheetSkeletonManagerService = get(SheetSkeletonManagerService);sheetClipboardService = get(ISheetClipboardService);@@ -215,7 +217,14 @@ describe('Test clipboard', () => {expect(cellStyle?.bg).toStrictEqual({ rgb: 'rgb(15,158,213)' });const richTextStyle = getValues(2, 3, 2, 3)?.[0]?.[0]?.p;expect(richTextStyle?.body?.dataStream).toBe('Univer\r\n');- expect(richTextStyle?.body?.paragraphs).toStrictEqual([{ startIndex: 6 }]);+ expect(richTextStyle?.body?.paragraphs).toStrictEqual([+ {+ paragraphStyle: {+ horizontalAlign: 0,+ },+ startIndex: 6,+ },+ ]);expect(richTextStyle?.body?.textRuns).toStrictEqual([{st: 1,diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-from-google.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-from-google.spec.tsindex d61cb46a67..d0fd026854 100644--- a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-from-google.spec.ts+++ b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-from-google.spec.ts@@ -23,6 +23,7 @@ import {SetRangeValuesMutation,SetSelectionsOperation,SetWorksheetColWidthMutation,+ SetWorksheetRowAutoHeightMutation,SetWorksheetRowHeightMutation,SheetsSelectionsService,} from '@univerjs/sheets';@@ -83,6 +84,7 @@ describe('Test clipboard', () => {commandService.registerCommand(RemoveWorksheetMergeMutation);commandService.registerCommand(SetSelectionsOperation);commandService.registerCommand(MoveRangeMutation);+ commandService.registerCommand(SetWorksheetRowAutoHeightMutation);sheetSkeletonManagerService = get(SheetSkeletonManagerService);sheetClipboardService = get(ISheetClipboardService);@@ -199,7 +201,14 @@ describe('Test clipboard', () => {expect(cellStyle?.bg).toStrictEqual({ rgb: 'rgb(255,0,0)' });const richTextStyle = getValues(2, 3, 2, 3)?.[0]?.[0]?.p;expect(richTextStyle?.body?.dataStream).toBe('univer\r\n');- expect(richTextStyle?.body?.paragraphs).toStrictEqual([{ startIndex: 6 }]);+ expect(richTextStyle?.body?.paragraphs).toStrictEqual([+ {+ paragraphStyle: {+ horizontalAlign: 0,+ },+ startIndex: 6,+ },+ ]);expect(richTextStyle?.body?.textRuns).toStrictEqual([{ ed: 1, st: 0, ts: { fs: 10, ff: 'Arial' } },{diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-from-notepad.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-from-notepad.spec.tsindex f0c3091def..1ddf64d46e 100644--- a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-from-notepad.spec.ts+++ b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-from-notepad.spec.ts@@ -23,6 +23,7 @@ import {SetRangeValuesMutation,SetSelectionsOperation,SetWorksheetColWidthMutation,+ SetWorksheetRowAutoHeightMutation,SetWorksheetRowHeightMutation,SheetsSelectionsService,} from '@univerjs/sheets';@@ -78,6 +79,7 @@ describe('Test clipboard', () => {commandService.registerCommand(RemoveWorksheetMergeMutation);commandService.registerCommand(SetSelectionsOperation);commandService.registerCommand(MoveRangeMutation);+ commandService.registerCommand(SetWorksheetRowAutoHeightMutation);sheetSkeletonManagerService = get(SheetSkeletonManagerService);sheetClipboardService = get(ISheetClipboardService);diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-rotate.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-rotate.spec.tsindex f019291b30..2229464750 100644--- a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-rotate.spec.ts+++ b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-rotate.spec.ts@@ -22,6 +22,7 @@ import {SetRangeValuesMutation,SetSelectionsOperation,SetWorksheetColWidthMutation,+ SetWorksheetRowAutoHeightMutation,SetWorksheetRowHeightMutation,SheetsSelectionsService,} from '@univerjs/sheets';@@ -80,6 +81,7 @@ describe('Test clipboard', () => {commandService.registerCommand(AddWorksheetMergeMutation);commandService.registerCommand(RemoveWorksheetMergeMutation);commandService.registerCommand(SetSelectionsOperation);+ commandService.registerCommand(SetWorksheetRowAutoHeightMutation);sheetSkeletonManagerService = get(SheetSkeletonManagerService)!;sheetClipboardService = get(ISheetClipboardService);diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-service.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-service.spec.tsindex ed61e616e7..f308af0acc 100644--- a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-service.spec.ts+++ b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-service.spec.ts@@ -24,6 +24,7 @@ import {SetRangeValuesMutation,SetSelectionsOperation,SetWorksheetColWidthMutation,+ SetWorksheetRowAutoHeightMutation,SetWorksheetRowHeightMutation,SheetsSelectionsService,} from '@univerjs/sheets';@@ -73,6 +74,7 @@ describe('Test clipboard', () => {commandService.registerCommand(RemoveWorksheetMergeMutation);commandService.registerCommand(SetSelectionsOperation);commandService.registerCommand(MoveRangeMutation);+ commandService.registerCommand(SetWorksheetRowAutoHeightMutation);sheetClipboardService = get(ISheetClipboardService);diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/sheet-paste.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/sheet-paste.spec.tsindex db74a88b87..57627f0300 100644--- a/packages/sheets-ui/src/services/clipboard/__tests__/sheet-paste.spec.ts+++ b/packages/sheets-ui/src/services/clipboard/__tests__/sheet-paste.spec.ts@@ -24,6 +24,7 @@ import {SetRangeValuesMutation,SetSelectionsOperation,SetWorksheetColWidthMutation,+ SetWorksheetRowAutoHeightMutation,SetWorksheetRowHeightMutation,SheetsSelectionsService,} from '@univerjs/sheets';@@ -73,6 +74,7 @@ describe('Test clipboard', () => {commandService.registerCommand(AddWorksheetMergeMutation);commandService.registerCommand(RemoveWorksheetMergeMutation);commandService.registerCommand(SetSelectionsOperation);+ commandService.registerCommand(SetWorksheetRowAutoHeightMutation);sheetSkeletonManagerService = get(SheetSkeletonManagerService);});diff --git a/packages/sheets-ui/src/services/clipboard/clipboard.service.ts b/packages/sheets-ui/src/services/clipboard/clipboard.service.tsindex b098655bc1..e07689a8cf 100644--- a/packages/sheets-ui/src/services/clipboard/clipboard.service.ts+++ b/packages/sheets-ui/src/services/clipboard/clipboard.service.ts@@ -19,11 +19,12 @@ import type {IDisposable,IMutationInfo,IRange,+ IRowAutoHeightInfo,Nullable,Workbook,Worksheet,} from '@univerjs/core';-import type { ISetRangeValuesMutationParams, ISetSelectionsOperationParams } from '@univerjs/sheets';+import type { ISetRangeValuesMutationParams, ISetSelectionsOperationParams, ISetWorksheetRowAutoHeightMutationParams } from '@univerjs/sheets';import type { Observable } from 'rxjs';import type { IDiscreteRange } from '../../controllers/utils/range-tools';import type {@@ -67,7 +68,8 @@ import {rangeToDiscreteRange,SetSelectionsOperation,SetWorksheetActiveOperation,-+ SetWorksheetRowAutoHeightMutation,+ SetWorksheetRowAutoHeightMutationFactory,SheetsSelectionsService,} from '@univerjs/sheets';import { FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FILE_PNG_CLIPBOARD_MIME_TYPE, HTML_CLIPBOARD_MIME_TYPE, IClipboardInterfaceService, imageMimeTypeSet, INotificationService, IPlatformService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE } from '@univerjs/ui';@@ -92,6 +94,8 @@ export const PREDEFINED_HOOK_NAME_COPY = {} as const;export const PREDEFINED_HOOK_NAME_PASTE = {DEFAULT_PASTE: 'default-paste',+ DEFAULT_PASTE_ROWS: 'default-paste-rows',+ DEFAULT_PASTE_COLUMNS: 'default-paste-columns',SPECIAL_PASTE_VALUE: 'special-paste-value',SPECIAL_PASTE_FORMAT: 'special-paste-format',SPECIAL_PASTE_COL_WIDTH: 'special-paste-col-width',@@ -775,7 +779,6 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard): boolean {const { rowProperties, colProperties, cellMatrix } = data;const { unitId, subUnitId, pastedRange } = target;- const colCount = pastedRange.cols.length;const hooks = this._clipboardHooks;const enabledHooks: ISheetClipboardHook[] = [];const disableCopying = hooks.some(@@ -810,19 +813,15 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard(h) => (!h.specialPasteInfo && h.id !== PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE) || pasteType === h.id);filteredHooks.forEach((h) => {- if (rowProperties) {- const rowReturn = h.onPasteRows?.({ range: pastedRange, unitId, subUnitId }, rowProperties, {- pasteType,- });- if (rowReturn) {- redoMutationsInfo.push(...rowReturn.redos);- undoMutationsInfo.push(...rowReturn.undos);- }+ const rowReturn = h.onPasteRows?.({ range: pastedRange, unitId, subUnitId });+ if (rowReturn) {+ redoMutationsInfo.push(...rowReturn.redos);+ undoMutationsInfo.push(...rowReturn.undos);}const colReturn = h.onPasteColumns?.({ range: pastedRange, unitId, subUnitId },- colProperties || new Array(colCount).map(() => ({})),+ colProperties || [],{ pasteType });if (colReturn) {@@ -876,6 +875,18 @@ export class SheetClipboardService extends Disposable implements ISheetClipboardconst result = redoMutationsInfo.every((m) => this._commandService.syncExecuteCommand(m.id, m.params));if (result) {+ // handle auto row height for pasted range+ const autoHeightMutation = this._getPastedRangeAutoHeightMutation(+ unitId,+ subUnitId,+ pastedRange+ );+ if (autoHeightMutation) {+ this._commandService.syncExecuteCommand(autoHeightMutation.redo.id, autoHeightMutation.redo.params);+ redoMutationsInfo.push(autoHeightMutation.redo);+ undoMutationsInfo.unshift(autoHeightMutation.undo);+ }+// add to undo redo servicesthis._undoRedoService.pushUndoRedo({unitID: unitId,@@ -902,6 +913,70 @@ export class SheetClipboardService extends Disposable implements ISheetClipboardreturn result;}+ private _getPastedRangeAutoHeightMutation(+ unitId: string,+ subUnitId: string,+ pastedRange: IDiscreteRange+ ): {+ undo: IMutationInfo;+ redo: IMutationInfo;+ } | null {+ const worksheet = this._univerInstanceService.getUnit<Workbook>(unitId, UniverInstanceType.UNIVER_SHEET)?.getSheetBySheetId(subUnitId);+ if (!worksheet) {+ return null;+ }++ const skeleton = this._renderManagerService.getRenderById(unitId)?.with(SheetSkeletonManagerService).ensureSkeleton(subUnitId);+ if (!skeleton) {+ return null;+ }++ const rowManager = worksheet.getRowManager();+ const { rows, cols } = pastedRange;+ const pasteRangeStartRow = rows[0];+ const pasteRangeEndRow = rows[rows.length - 1];+ const pasteRangeStartColumn = cols[0];+ const pasteRangeEndColumn = cols[cols.length - 1];++ // If there are rows without row height set in the pasted range, we need to set them to auto height+ const needAutoHeight: IRowAutoHeightInfo[] = [];+ for (let r = pasteRangeStartRow; r <= pasteRangeEndRow; r++) {+ const rowData = rowManager.getRow(r);+ if (!rowData) {+ const autoHeight = skeleton.calculateAutoHeightInRange([+ {+ startRow: r,+ endRow: r,+ startColumn: pasteRangeStartColumn,+ endColumn: pasteRangeEndColumn,+ },+ ]);+ needAutoHeight.push(...autoHeight);+ }+ }++ if (needAutoHeight.length > 0) {+ const setWorksheetRowAutoHeightMutationParams: ISetWorksheetRowAutoHeightMutationParams = {+ unitId,+ subUnitId,+ rowsAutoHeightInfo: needAutoHeight,+ };++ return {+ redo: {+ id: SetWorksheetRowAutoHeightMutation.id,+ params: setWorksheetRowAutoHeightMutationParams,+ },+ undo: {+ id: SetWorksheetRowAutoHeightMutation.id,+ params: SetWorksheetRowAutoHeightMutationFactory(setWorksheetRowAutoHeightMutationParams, worksheet),+ },+ };+ }++ return null;+ }+private _getSetSelectionOperation(unitId: string,subUnitId: string,diff --git a/packages/sheets-ui/src/services/clipboard/type.ts b/packages/sheets-ui/src/services/clipboard/type.tsindex 25947fb292..6953b98bc3 100644--- a/packages/sheets-ui/src/services/clipboard/type.ts+++ b/packages/sheets-ui/src/services/clipboard/type.ts@@ -192,11 +192,7 @@ export interface ISheetClipboardHook {* @param payload* @returns undo and redo mutations*/- onPasteRows?(- pasteTo: ISheetDiscreteRangeLocation,- rowProperties: IClipboardPropertyItem[],- payload: ICopyPastePayload- ): {+ onPasteRows?(pasteTo: ISheetDiscreteRangeLocation): {undos: IMutationInfo[];redos: IMutationInfo[];};diff --git a/packages/sheets/src/index.ts b/packages/sheets/src/index.tsindex 8d6dce7870..76dbe58bd4 100644--- a/packages/sheets/src/index.ts+++ b/packages/sheets/src/index.ts@@ -307,11 +307,12 @@ export {type ISetWorksheetRowAutoHeightMutationParams,type ISetWorksheetRowHeightMutationParams,type ISetWorksheetRowIsAutoHeightMutationParams,-SetWorksheetRowAutoHeightMutation,SetWorksheetRowAutoHeightMutationFactory,SetWorksheetRowHeightMutation,+ SetWorksheetRowHeightMutationFactory,SetWorksheetRowIsAutoHeightMutation,+ SetWorksheetRowIsAutoHeightMutationFactory,} from './commands/mutations/set-worksheet-row-height.mutation';export { type IToggleGridlinesMutationParams, ToggleGridlinesMutation } from './commands/mutations/toggle-gridlines.mutation';export { type IUnregisterWorksheetRangeThemeStyleMutationParams, UnregisterWorksheetRangeThemeStyleMutation } from './commands/mutations/unregister-range-theme-style.mutation';