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(sheet): copypaste & auto filling bugs (#849)
YuHong4c4913bc6189
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 65daa22b4a..10b2137e2e 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@@ -27,7 +27,7 @@ import {SetWorksheetRowHeightMutation,} from '@univerjs/sheets';import type { Injector } from '@wendellhu/redi';-import { afterEach, beforeEach, describe, it, vi } from 'vitest';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';import { ISheetClipboardService } from '../clipboard.service';import { clipboardTestBed } from './clipboard-test-bed';@@ -92,12 +92,13 @@ describe('Test clipboard', () => {startColumn: number,endRow: number,endColumn: number- ): IRange[] | undefined =>- get(IUniverInstanceService)+ ): IRange[] | undefined => {+ return get(IUniverInstanceService).getUniverSheetInstance('test')?.getSheetBySheetId('sheet1')?.getMergeData().filter((rect) => Rectangle.intersects({ startRow, startColumn, endRow, endColumn }, rect));+ };getStyles = (startRow: number,@@ -113,20 +114,7 @@ describe('Test clipboard', () => {};// read use mockconst clipboardData = {- 'text/html': `<google-sheets-html-origin>- <table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" border="1"- style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none">- <colgroup>- <col width="73">- <col width="73">- </colgroup>\n<tbody>- <tr style="height: 81px;">- <td rowspan="1" colspan="2"- style="background: rgb(255,0,0); text-align: center; vertical-align: middle;">row1col2</td>- </tr>- </tbody>- </table>- </google-sheets-html-origin>`,+ 'text/html': `<google-sheets-html-origin><table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" border="1" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none"><colgroup><col width="73"><col width="73"></colgroup><tbody><tr style="height: 81px;"><td rowspan="1" colspan="2" style="background: rgb(255,0,0); text-align: center; vertical-align: middle; text-decoration:none;">row1col2</td></tr></tbody></table></google-sheets-html-origin>`,};const mockClipboard = new MockClipboard(clipboardData);const clipboardItems = await mockClipboard.read();@@ -168,18 +156,18 @@ describe('Test clipboard', () => {const values = getValues(startRow, startColumn, endRow, endColumn);const styles = getStyles(startRow, startColumn, endRow, endColumn);const mergedCells = getMergedCells(startRow, startColumn, endRow, endColumn);- // expect(values && values[0][0]?.v).toBe('row1col2');- // expect(styles && styles[0][0]).toStrictEqual({- // bg: { rgb: 'rgb(255,0,0)' },- // ht: 2,- // vt: 2,- // });- // expect(mergedCells && mergedCells[0]).toStrictEqual({- // startRow: 0,- // startColumn: 0,- // endRow: 0,- // endColumn: 1,- // });+ expect(values && values[0][0]?.v).toBe('row1col2');+ expect(styles && styles[0][0]).toStrictEqual({+ bg: { rgb: 'rgb(255,0,0)' },+ ht: 2,+ vt: 2,+ });+ expect(mergedCells && mergedCells[0]).toStrictEqual({+ startRow: 0,+ startColumn: 0,+ endRow: 0,+ endColumn: 1,+ });});it('The current selection is a single cell in 1 row and 2 columns', async () => {const selectionManager = get(SelectionManagerService);@@ -208,18 +196,18 @@ describe('Test clipboard', () => {const values = getValues(startRow, startColumn, endRow, endColumn);const styles = getStyles(startRow, startColumn, endRow, endColumn);const mergedCells = getMergedCells(startRow, startColumn, endRow, endColumn);- // expect(values && values[0][0]?.v).toBe('row1col2');- // expect(styles && styles[0][0]).toStrictEqual({- // bg: { rgb: 'rgb(255,0,0)' },- // ht: 2,- // vt: 2,- // });- // expect(mergedCells && mergedCells[0]).toStrictEqual({- // startRow,- // startColumn,- // endRow,- // endColumn,- // });+ expect(values && values[0][0]?.v).toBe('row1col2');+ expect(styles && styles[0][0]).toStrictEqual({+ bg: { rgb: 'rgb(255,0,0)' },+ ht: 2,+ vt: 2,+ });+ expect(mergedCells && mergedCells[0]).toStrictEqual({+ startRow,+ startColumn,+ endRow,+ endColumn,+ });});it('The current selection is a single cell in 1 row and 3 columns', async () => {const selectionManager = get(SelectionManagerService);@@ -248,18 +236,20 @@ describe('Test clipboard', () => {const values = getValues(startRow, startColumn, endRow, endColumn);const styles = getStyles(startRow, startColumn, endRow, endColumn);const mergedCells = getMergedCells(startRow, startColumn, endRow, endColumn);- // expect(values && values[0][0]?.v).toBe('row1col2');- // expect(styles && styles[0][0]).toStrictEqual({- // bg: { rgb: 'rgb(255,0,0)' },- // ht: 2,- // vt: 2,- // });- // expect(mergedCells && mergedCells[0]).toStrictEqual({- // startRow: 2,- // startColumn: 0,- // endRow: 2,- // endColumn: 1,- // });+ expect(values && values[0][0]?.v).toBe('row1col2');+ expect(styles && styles[0][0]).toStrictEqual({+ bg: { rgb: 'rgb(255,0,0)' },+ ht: 2,+ vt: 2,+ });+ expect(values && values[0][2]?.v).toBe(undefined);+ expect(styles && styles[0][2]).toStrictEqual(undefined);+ expect(mergedCells && mergedCells[0]).toStrictEqual({+ startRow: 2,+ startColumn: 0,+ endRow: 2,+ endColumn: 1,+ });});it('The current selection is a single cell in 2 rows and 2 columns', async () => {const selectionManager = get(SelectionManagerService);@@ -288,33 +278,33 @@ describe('Test clipboard', () => {const values = getValues(startRow, startColumn, endRow, endColumn);const styles = getStyles(startRow, startColumn, endRow, endColumn);const mergedCells = getMergedCells(startRow, startColumn, endRow, endColumn);- // expect(values && values[0][0]?.v).toBe('row1col2');- // expect(values && values[1][0]?.v).toBe('row1col2');+ expect(values && values[0][0]?.v).toBe('row1col2');+ expect(values && values[1][0]?.v).toBe('row1col2');- // expect(styles && styles[0][0]).toStrictEqual({- // bg: { rgb: 'rgb(255,0,0)' },- // ht: 2,- // vt: 2,- // });- // expect(styles && styles[1][0]).toStrictEqual({- // bg: { rgb: 'rgb(255,0,0)' },- // ht: 2,- // vt: 2,- // });- // expect(mergedCells).toStrictEqual([- // {- // startRow: 3,- // startColumn: 0,- // endRow: 3,- // endColumn: 1,- // },- // {- // startRow: 4,- // startColumn: 0,- // endRow: 4,- // endColumn: 1,- // },- // ]);+ expect(styles && styles[0][0]).toStrictEqual({+ bg: { rgb: 'rgb(255,0,0)' },+ ht: 2,+ vt: 2,+ });+ expect(styles && styles[1][0]).toStrictEqual({+ bg: { rgb: 'rgb(255,0,0)' },+ ht: 2,+ vt: 2,+ });+ expect(mergedCells).toStrictEqual([+ {+ startRow: 3,+ startColumn: 0,+ endRow: 3,+ endColumn: 1,+ },+ {+ startRow: 4,+ startColumn: 0,+ endRow: 4,+ endColumn: 1,+ },+ ]);});it('The current selection is a single cell in 4 rows and 4 columns', async () => {const selectionManager = get(SelectionManagerService);@@ -345,69 +335,69 @@ describe('Test clipboard', () => {const mergedCells = getMergedCells(startRow, startColumn, endRow, endColumn);for (let i = 0; i < 4; i++) {- // expect(values && values[i][0]?.v).toBe('row1col2');- // expect(values && values[i][2]?.v).toBe('row1col2');- // expect(styles && styles[i][0]).toStrictEqual({- // bg: { rgb: 'rgb(255,0,0)' },- // ht: 2,- // vt: 2,- // });- // expect(styles && styles[i][2]).toStrictEqual({- // bg: { rgb: 'rgb(255,0,0)' },- // ht: 2,- // vt: 2,- // });+ expect(values && values[i][0]?.v).toBe('row1col2');+ expect(values && values[i][2]?.v).toBe('row1col2');+ expect(styles && styles[i][0]).toStrictEqual({+ bg: { rgb: 'rgb(255,0,0)' },+ ht: 2,+ vt: 2,+ });+ expect(styles && styles[i][2]).toStrictEqual({+ bg: { rgb: 'rgb(255,0,0)' },+ ht: 2,+ vt: 2,+ });}- // expect(mergedCells).toStrictEqual([- // {- // startRow: 5,- // startColumn: 0,- // endRow: 5,- // endColumn: 1,- // },- // {- // startRow: 5,- // startColumn: 2,- // endRow: 5,- // endColumn: 3,- // },- // {- // startRow: 6,- // startColumn: 0,- // endRow: 6,- // endColumn: 1,- // },- // {- // startRow: 6,- // startColumn: 2,- // endRow: 6,- // endColumn: 3,- // },- // {- // startRow: 7,- // startColumn: 0,- // endRow: 7,- // endColumn: 1,- // },- // {- // startRow: 7,- // startColumn: 2,- // endRow: 7,- // endColumn: 3,- // },- // {- // startRow: 8,- // startColumn: 0,- // endRow: 8,- // endColumn: 1,- // },- // {- // startRow: 8,- // startColumn: 2,- // endRow: 8,- // endColumn: 3,- // },- // ]);+ expect(mergedCells).toStrictEqual([+ {+ startRow: 5,+ startColumn: 0,+ endRow: 5,+ endColumn: 1,+ },+ {+ startRow: 5,+ startColumn: 2,+ endRow: 5,+ endColumn: 3,+ },+ {+ startRow: 6,+ startColumn: 0,+ endRow: 6,+ endColumn: 1,+ },+ {+ startRow: 6,+ startColumn: 2,+ endRow: 6,+ endColumn: 3,+ },+ {+ startRow: 7,+ startColumn: 0,+ endRow: 7,+ endColumn: 1,+ },+ {+ startRow: 7,+ startColumn: 2,+ endRow: 7,+ endColumn: 3,+ },+ {+ startRow: 8,+ startColumn: 0,+ endRow: 8,+ endColumn: 1,+ },+ {+ startRow: 8,+ startColumn: 2,+ endRow: 8,+ endColumn: 3,+ },+ ]);});});@@ -440,18 +430,18 @@ describe('Test clipboard', () => {const styles = getStyles(startRow, startColumn, endRow, endColumn);const mergedCells = getMergedCells(startRow, startColumn, endRow, endColumn);- // expect(values && values[0][0]?.v).toBe('row1col2');- // expect(styles && styles[0][0]).toStrictEqual({- // bg: { rgb: 'rgb(255,0,0)' },- // ht: 2,- // vt: 2,- // });- // expect(mergedCells && mergedCells[0]).toStrictEqual({- // startRow,- // startColumn,- // endRow,- // endColumn,- // });+ expect(values && values[0][0]?.v).toBe('row1col2');+ expect(styles && styles[0][0]).toStrictEqual({+ bg: { rgb: 'rgb(255,0,0)' },+ ht: 2,+ vt: 2,+ });+ expect(mergedCells && mergedCells[0]).toStrictEqual({+ startRow,+ startColumn,+ endRow,+ endColumn,+ });});it('The current selection is a merged cell of 1 row and 3 columns.', async () => {@@ -482,14 +472,14 @@ describe('Test clipboard', () => {const styles = getStyles(startRow, startColumn, endRow, endColumn);const mergedCells = getMergedCells(startRow, startColumn, endRow, endColumn);- // expect(values && values[0][0]?.v).toBe('row1col2');- // expect(styles && styles[0][0]).toBe(undefined);- // expect(mergedCells && mergedCells[0]).toStrictEqual({- // startRow,- // startColumn,- // endRow,- // endColumn,- // });+ expect(values && values[0][0]?.v).toBe('row1col2');+ expect(styles && styles[0][0]).toBe(undefined);+ expect(mergedCells && mergedCells[0]).toStrictEqual({+ startRow,+ startColumn,+ endRow,+ endColumn,+ });});it('The current selection is a merged cell of 1 row and 4 columns.', async () => {@@ -520,14 +510,18 @@ describe('Test clipboard', () => {const styles = getStyles(startRow, startColumn, endRow, endColumn);const mergedCells = getMergedCells(startRow, startColumn, endRow, endColumn);- // expect(values && values[0][0]?.v).toBe('row1col2');- // expect(styles && styles[0][0]).toBe(undefined);- // expect(mergedCells && mergedCells[0]).toStrictEqual({- // startRow,- // startColumn,- // endRow,- // endColumn,- // });+ expect(values && values[0][0]?.v).toBe('row1col2');+ expect(styles && styles[0][0]).toStrictEqual({+ bg: { rgb: 'rgb(255,0,0)' },+ ht: 2,+ vt: 2,+ });+ expect(mergedCells && mergedCells[0]).toStrictEqual({+ startRow,+ startColumn,+ endRow,+ endColumn: endColumn - 2,+ });});it('The current selection is a merged cell of 2 rows and 2 columns.', async () => {@@ -558,14 +552,24 @@ describe('Test clipboard', () => {const styles = getStyles(startRow, startColumn, endRow, endColumn);const mergedCells = getMergedCells(startRow, startColumn, endRow, endColumn);- // expect(values && values[0][0]?.v).toBe('row1col2');- // expect(styles && styles[0][0]).toBe(undefined);- // expect(mergedCells && mergedCells[0]).toStrictEqual({- // startRow,- // startColumn,- // endRow,- // endColumn,- // });+ expect(values && values[0][0]?.v).toBe('row1col2');+ expect(styles && styles[0][0]).toStrictEqual({+ bg: { rgb: 'rgb(255,0,0)' },+ ht: 2,+ vt: 2,+ });+ expect(mergedCells && mergedCells[0]).toStrictEqual({+ startRow,+ startColumn,+ endRow: endRow - 1,+ endColumn,+ });+ expect(mergedCells && mergedCells[1]).toStrictEqual({+ startRow: startRow + 1,+ startColumn,+ endRow,+ endColumn,+ });});it('The current selection is a merged cell of 1 row and 2 columns, with 1 ordinary cell', async () => {@@ -596,14 +600,14 @@ describe('Test clipboard', () => {const styles = getStyles(startRow, startColumn, endRow, endColumn);const mergedCells = getMergedCells(startRow, startColumn, endRow, endColumn);- // expect(values && values[0][0]?.v).toBe('row1col2');- // expect(styles && styles[0][0]).toStrictEqual({ bg: { rgb: 'rgb(255,0,0)' }, ht: 2, vt: 2 });- // expect(mergedCells && mergedCells[0]).toStrictEqual({- // startRow: 9,- // startColumn: 5,- // endRow: 9,- // endColumn: 6,- // });+ expect(values && values[0][0]?.v).toBe('row1col2');+ expect(styles && styles[0][0]).toStrictEqual({ bg: { rgb: 'rgb(255,0,0)' }, ht: 2, vt: 2 });+ expect(mergedCells && mergedCells[0]).toStrictEqual({+ startRow: 9,+ startColumn: 5,+ endRow: 9,+ endColumn: 6,+ });});it('The current selection is a merged cell of 2 rows and 2 columns, with a merged cell of 2 rows and 1 column', async () => {@@ -630,10 +634,10 @@ describe('Test clipboard', () => {]);// TODO@Dushusir remove after Dialog replacement- let alert = false;- vi.spyOn(window, 'alert').mockImplementation(() => {- alert = true;- });+ // let alert = false;+ // vi.spyOn(window, 'alert').mockImplementation(() => {+ // alert = true;+ // });await sheetClipboardService.paste(clipboardItem);// expect(alert).toBe(true);@@ -642,22 +646,22 @@ describe('Test clipboard', () => {const styles = getStyles(startRow, startColumn, endRow, endColumn);const mergedCells = getMergedCells(startRow, startColumn, endRow, endColumn);- // expect(values && values[0][0]?.v).toBe(undefined);- // expect(styles && styles[0][0]).toBe(undefined);- // expect(mergedCells).toStrictEqual([- // {- // startRow: 11,- // startColumn: 5,- // endRow: 12,- // endColumn: 6,- // },- // {- // startRow: 11,- // startColumn: 7,- // endRow: 12,- // endColumn: 7,- // },- // ]);+ expect(values && values[0][0]?.v).toBe(undefined);+ expect(styles && styles[0][0]).toBe(undefined);+ expect(mergedCells).toStrictEqual([+ {+ startRow: 11,+ startColumn: 5,+ endRow: 12,+ endColumn: 6,+ },+ {+ startRow: 11,+ startColumn: 7,+ endRow: 12,+ endColumn: 7,+ },+ ]);});});@@ -691,18 +695,14 @@ describe('Test clipboard', () => {const styles = getStyles(startRow, startColumn, endRow, endColumn);const mergedCells = getMergedCells(startRow, startColumn, endRow, endColumn);- // expect(values && values[0][0]?.v).toBe('row1col2');- // expect(styles && styles[0][0]).toStrictEqual({- // bg: {- // rgb: '#ccc',- // },- // });- // expect(mergedCells && mergedCells[0]).toStrictEqual({- // startRow,- // startColumn,- // endRow,- // endColumn,- // });+ expect(values && values[0][0]?.v).toBe('row1col2');++ expect(mergedCells && mergedCells[0]).toStrictEqual({+ startRow,+ startColumn,+ endRow,+ endColumn,+ });});it('The current selection is a merged cell of 1 row and 2 columns, with a merged cell of 2 rows and 2 columns', async () => {const selectionManager = get(SelectionManagerService);@@ -734,27 +734,27 @@ describe('Test clipboard', () => {const mergedCells = getMergedCells(startRow, startColumn, endRow, endColumn);// first merged cells changed- // expect(values && values[0][0]?.v).toBe('row1col2');- // expect(styles && styles[0][0]).toStrictEqual({ bg: { rgb: 'rgb(255,0,0)' }, ht: 2, vt: 2 });+ expect(values && values[0][0]?.v).toBe('row1col2');+ expect(styles && styles[0][0]).toStrictEqual({ bg: { rgb: 'rgb(255,0,0)' }, ht: 2, vt: 2 });// second merged cells not changed- // expect(values && values[2][1]?.v).toBe('456');- // expect(styles && styles[2][1]).toStrictEqual({ bg: { rgb: '#ccc' }, ht: 2, vt: 2 });-- // expect(mergedCells).toStrictEqual([- // {- // startRow: 8,- // startColumn: 11,- // endRow: 9,- // endColumn: 12,- // },- // {- // startRow: 6,- // startColumn: 10,- // endRow: 6,- // endColumn: 11,- // },- // ]);+ expect(values && values[2][1]?.v).toBe('456');+ expect(styles && styles[2][1]).toStrictEqual({ bg: { rgb: '#ccc' }, ht: 2, vt: 2 });++ expect(mergedCells).toStrictEqual([+ {+ startRow: 8,+ startColumn: 11,+ endRow: 9,+ endColumn: 12,+ },+ {+ startRow: 6,+ startColumn: 10,+ endRow: 6,+ endColumn: 11,+ },+ ]);});it('The current selection is a merged cell of 1 row and 3 columns, with a merged cell of 2 rows and 2 columns', async () => {const selectionManager = get(SelectionManagerService);@@ -779,10 +779,10 @@ describe('Test clipboard', () => {},]);- let alert = false;- vi.spyOn(window, 'alert').mockImplementation(() => {- alert = true;- });+ // let alert = false;+ // vi.spyOn(window, 'alert').mockImplementation(() => {+ // alert = true;+ // });await sheetClipboardService.paste(clipboardItem);// expect(alert).toBe(true);@@ -792,27 +792,27 @@ describe('Test clipboard', () => {const mergedCells = getMergedCells(startRow, startColumn, endRow, endColumn);// first merged cells not changed- // expect(values && values[0][0]?.v).toBe('456');- // expect(styles && styles[0][0]).toStrictEqual({ bg: { rgb: '#ccc' }, ht: 3 });+ expect(values && values[0][0]?.v).toBe('456');+ expect(styles && styles[0][0]).toStrictEqual({ bg: { rgb: '#ccc' }, ht: 3 });// second merged cells not changed- // expect(values && values[2][1]?.v).toBe('456');- // expect(styles && styles[2][1]).toStrictEqual({ bg: { rgb: '#ccc' } });-- // expect(mergedCells).toStrictEqual([- // {- // startRow: 11,- // startColumn: 10,- // endRow: 11,- // endColumn: 12,- // },- // {- // startRow: 13,- // startColumn: 11,- // endRow: 14,- // endColumn: 12,- // },- // ]);+ expect(values && values[2][1]?.v).toBe('456');+ expect(styles && styles[2][1]).toStrictEqual({ bg: { rgb: '#ccc' } });++ expect(mergedCells).toStrictEqual([+ {+ startRow: 11,+ startColumn: 10,+ endRow: 11,+ endColumn: 12,+ },+ {+ startRow: 13,+ startColumn: 11,+ endRow: 14,+ endColumn: 12,+ },+ ]);});it('The current selection is a merged cell of 2 rows and 2 columns, with a merged cell of 1 row and 2 columns', async () => {const selectionManager = get(SelectionManagerService);@@ -837,40 +837,40 @@ describe('Test clipboard', () => {},]);- let alert = false;- vi.spyOn(window, 'alert').mockImplementation(() => {- alert = true;- });+ // let alert = false;+ // vi.spyOn(window, 'alert').mockImplementation(() => {+ // alert = true;+ // });await sheetClipboardService.paste(clipboardItem);// expect(alert).toBe(true);- // const values = getValues(startRow, startColumn, endRow, endColumn);- // const styles = getStyles(startRow, startColumn, endRow, endColumn);- // const mergedCells = getMergedCells(startRow, startColumn, endRow, endColumn);+ const values = getValues(startRow, startColumn, endRow, endColumn);+ const styles = getStyles(startRow, startColumn, endRow, endColumn);+ const mergedCells = getMergedCells(startRow, startColumn, endRow, endColumn);// first merged cells not changed- // expect(values && values[0][0]?.v).toBe('456');- // expect(styles && styles[0][0]).toStrictEqual({ bg: { rgb: '#ccc' } });+ expect(values && values[0][0]?.v).toBe('456');+ expect(styles && styles[0][0]).toStrictEqual({ bg: { rgb: '#ccc' } });// second merged cells not changed- // expect(values && values[2][1]?.v).toBe('456');- // expect(styles && styles[2][1]).toStrictEqual({ bg: { rgb: '#ccc' } });-- // expect(mergedCells).toStrictEqual([- // {- // startRow: 21,- // startColumn: 10,- // endRow: 22,- // endColumn: 11,- // },- // {- // startRow: 23,- // startColumn: 11,- // endRow: 23,- // endColumn: 12,- // },- // ]);+ expect(values && values[2][1]?.v).toBe('456');+ expect(styles && styles[2][1]).toStrictEqual({ bg: { rgb: '#ccc' } });++ expect(mergedCells).toStrictEqual([+ {+ startRow: 21,+ startColumn: 10,+ endRow: 22,+ endColumn: 11,+ },+ {+ startRow: 23,+ startColumn: 11,+ endRow: 23,+ endColumn: 12,+ },+ ]);});});});diff --git a/packages/sheets-ui/src/services/clipboard/clipboard.service.ts b/packages/sheets-ui/src/services/clipboard/clipboard.service.tsindex e50e191d22..756ae435cb 100644--- a/packages/sheets-ui/src/services/clipboard/clipboard.service.ts+++ b/packages/sheets-ui/src/services/clipboard/clipboard.service.ts@@ -298,7 +298,7 @@ export class SheetClipboardService extends Disposable implements ISheetClipboardconst { startColumn, endColumn, startRow, endRow } = cellMatrix.getDataRange();const rowCount = endRow - startRow + 1;const colCount = endColumn - startColumn + 1;- if (!cellMatrix) {+ if (!cellMatrix || endColumn < startColumn || endRow < startRow) {return false;}@@ -682,7 +682,7 @@ export class SheetClipboardService extends Disposable implements ISheetClipboardrange.endColumn = startColumn + colCount - 1;} else if (endRow > mergedRange.endRow || endColumn > mergedRange.endColumn) {// TODO@Dushusir: use dialog component- alert("We can't do that to a merged cell ");+ // alert("We can't do that to a merged cell ");return null;} else {cellMatrix.forValue((row, col, cell) => {diff --git a/packages/sheets-ui/src/services/clipboard/html-to-usm/converter.ts b/packages/sheets-ui/src/services/clipboard/html-to-usm/converter.tsindex 2f875e52fe..1373d688fa 100644--- a/packages/sheets-ui/src/services/clipboard/html-to-usm/converter.ts+++ b/packages/sheets-ui/src/services/clipboard/html-to-usm/converter.ts@@ -102,8 +102,7 @@ export class HtmlToUSMService {const rowProperties: IClipboardPropertyItem[] = [];let colProperties: IClipboardPropertyItem[] = [];// pick tables- const tableStrings = html.match(/<table.*?>([\s\S]*?)<\/table>/gi);-+ const tableStrings = html.match(/<table\b[^>]*>([\s\S]*?)<\/table>/gi);const tables: IParsedTablesInfo[] = [];this.process(null, dom?.childNodes!, newDocBody, tables);const { paragraphs, dataStream, textRuns } = newDocBody;@@ -145,7 +144,7 @@ export class HtmlToUSMService {if (tableStrings) {tables.forEach((t) => {- const curRow = valueMatrix.getLength();+ const curRow = valueMatrix.getDataRange().endRow + 1;if (t.index === i) {const tableString = tableStrings.shift();const {@@ -186,13 +185,22 @@ export class HtmlToUSMService {if (tableStrings) {tableStrings.forEach((t) => {- const curRow = valueMatrix.getLength();+ const curRow = valueMatrix.getDataRange().endRow + 1;const { cellMatrix } = this._parseTable(t!);-- cellMatrix &&+ if (cellMatrix) {cellMatrix.forValue((row, col, value) => {+ const { rowSpan = 1, colSpan = 1 } = value;+ for (let i = 0; i < rowSpan; i++) {+ for (let j = 0; j < colSpan; j++) {+ valueMatrix.setValue(curRow + row + i, col + j, {+ v: '',+ });+ }+ }valueMatrix.setValue(curRow + row, col, value);});+ }+rowProperties.push(...rowProperties);});}diff --git a/packages/sheets-ui/src/views/operate-container/AutoFillPopupMenu.tsx b/packages/sheets-ui/src/views/operate-container/AutoFillPopupMenu.tsxindex 840da8d3b8..e4f38954e8 100644--- a/packages/sheets-ui/src/views/operate-container/AutoFillPopupMenu.tsx+++ b/packages/sheets-ui/src/views/operate-container/AutoFillPopupMenu.tsx@@ -19,7 +19,7 @@ import { ICommandService, IUniverInstanceService, LocaleService, Rectangle, toDiimport { Dropdown } from '@univerjs/design';import { IRenderManagerService } from '@univerjs/engine-render';import { Autofill, CheckMarkSingle, MoreDownSingle } from '@univerjs/icons';-import { SetRangeValuesMutation } from '@univerjs/sheets';+import { SetRangeValuesMutation, SetWorksheetActiveOperation } from '@univerjs/sheets';import { useDependency } from '@wendellhu/redi/react-bindings';import clsx from 'clsx';import React, { useCallback, useEffect, useState } from 'react';@@ -90,6 +90,7 @@ export const AutoFillPopupMenu: React.FC<{}> = () => {AutoClearContentCommand.id,SetZoomRatioOperation.id,SetRangeValuesMutation.id,+ SetWorksheetActiveOperation.id,];const disposable = commandService.onCommandExecuted((command: ICommandInfo) => {if (command.id === SetScrollOperation.id) {diff --git a/packages/ui/src/utils/cell.ts b/packages/ui/src/utils/cell.tsindex bca483809e..bf1c54ae4d 100644--- a/packages/ui/src/utils/cell.ts+++ b/packages/ui/src/utils/cell.ts@@ -283,9 +283,11 @@ export function handleStringToStyle($dom?: HTMLElement, cssStyle: string = '') {// line throughelse if (key === 'text-decoration' || key === 'univer-strike') {- styleList.st = {- s: 1,- };+ if (value !== 'none') {+ styleList.st = {+ s: 1,+ };+ }}// underlineif (key === 'univer-underline') {