From 54c6aa407ed9871932943806a180e8e981dc5c2f Mon Sep 17 00:00:00 2001 From: lumixraku Date: Sat, 16 Nov 2024 12:03:32 +0800 Subject: [PATCH] fix: no reuse border data when insert col --- packages/core/src/sheets/worksheet.ts | 9 +++++++++ .../src/commands/commands/utils/selection-utils.ts | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/packages/core/src/sheets/worksheet.ts b/packages/core/src/sheets/worksheet.ts index 770df7651e0e..e0be1249e73e 100644 --- a/packages/core/src/sheets/worksheet.ts +++ b/packages/core/src/sheets/worksheet.ts @@ -121,6 +121,15 @@ export class Worksheet { return this._spanModel; } + getStyleDataByHash(hash: string): Nullable { + const data = this._styles.get(hash); + return { ...data }; + } + + setStyleData(style: IStyleData): Nullable { + return this._styles.setValue(style); + } + /** * Get the style of the column. * @param {number} column The column index diff --git a/packages/sheets/src/commands/commands/utils/selection-utils.ts b/packages/sheets/src/commands/commands/utils/selection-utils.ts index 3af143f252cf..073a7e60c2a5 100644 --- a/packages/sheets/src/commands/commands/utils/selection-utils.ts +++ b/packages/sheets/src/commands/commands/utils/selection-utils.ts @@ -264,6 +264,19 @@ export function copyRangeStyles( if (!cellValue[row]) { cellValue[row] = {}; } + + // univer-pro/issues/3016 insert row/column should not reuse border style + if (typeof cell.s === 'string') { + const styleData = worksheet.getStyleDataByHash(cell.s); + if (styleData) { + delete styleData.bd; + cell.s = worksheet.setStyleData(styleData); + } + } else { + const styleData = { ...cell.s }; + delete styleData.bd; + cell.s = worksheet.setStyleData(styleData); + } cellValue[row][column] = { s: cell.s }; } }