Skip to content

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.

fix(sheet): update for change (#1044)

Univer286701671ad8
diff --git a/packages/sheets-ui/src/controllers/selection.controller.ts b/packages/sheets-ui/src/controllers/selection.controller.ts
index 2d9d45a76d..06124ed314 100644
--- a/packages/sheets-ui/src/controllers/selection.controller.ts
+++ b/packages/sheets-ui/src/controllers/selection.controller.ts
@@ -135,34 +135,19 @@ export class SelectionController extends Disposable {
}
this._refreshSelection(param);
-
- // this._selectionRenderService.reset();
-
- // for (const selectionWithStyle of param) {
- // if (selectionWithStyle == null) {
- // continue;
- // }
- // const selectionData =
- // this._selectionRenderService.convertSelectionRangeToData(selectionWithStyle);
- // selectionData.style = getNormalSelectionStyle(this._themeService);
- // this._selectionRenderService.addControlToCurrentByRangeData(selectionData);
- // }
})
)
);
}
- private _refreshSelection(param: readonly ISelectionWithStyle[]) {
- this._selectionRenderService.reset();
-
- for (const selectionWithStyle of param) {
- if (selectionWithStyle == null) {
- continue;
- }
+ private _refreshSelection(params: readonly ISelectionWithStyle[]) {
+ const selections = params.map((selectionWithStyle) => {
const selectionData = this._selectionRenderService.convertSelectionRangeToData(selectionWithStyle);
selectionData.style = getNormalSelectionStyle(this._themeService);
- this._selectionRenderService.addControlToCurrentByRangeData(selectionData);
- }
+ return selectionData;
+ });
+
+ this._selectionRenderService.updateControlForCurrentByRangeData(selections);
}
private _initRowHeader(sheetObject: ISheetObjectParam) {
diff --git a/packages/sheets-ui/src/services/selection/selection-render.service.ts b/packages/sheets-ui/src/services/selection/selection-render.service.ts
index 1c9c26c0f2..7ab6d3aeb9 100644
--- a/packages/sheets-ui/src/services/selection/selection-render.service.ts
+++ b/packages/sheets-ui/src/services/selection/selection-render.service.ts
@@ -67,6 +67,7 @@ export interface ISelectionRenderService {
disableSkipRemainLast(): void;
addControlToCurrentByRangeData(data: ISelectionWithCoordAndStyle): void;
+ updateControlForCurrentByRangeData(selections: ISelectionWithCoordAndStyle[]): void;
changeRuntime(skeleton: SpreadsheetSkeleton, scene: Scene, viewport?: Viewport): void;
getViewPort(): Viewport;
getCurrentControls(): SelectionShape[];
@@ -295,6 +296,35 @@ export class SelectionRenderService implements ISelectionRenderService {
currentControls.push(control);
}
+ /**
+ * update selection
+ * @param selectionRange
+ * @param curCellRange
+ * @returns
+ */
+ updateControlForCurrentByRangeData(selections: ISelectionWithCoordAndStyle[]) {
+ const currentControls = this.getCurrentControls();
+ if (!currentControls) {
+ return;
+ }
+
+ const skeleton = this._skeleton;
+
+ if (skeleton == null) {
+ return;
+ }
+
+ const { rowHeaderWidth, columnHeaderHeight } = skeleton;
+
+ for (let i = 0, len = selections.length; i < len; i++) {
+ const { rangeWithCoord, primaryWithCoord, style } = selections[i];
+
+ const control = currentControls[i];
+
+ control.update(rangeWithCoord, rowHeaderWidth, columnHeaderHeight, style, primaryWithCoord);
+ }
+ }
+
refreshSelectionMoveStart() {
this._selectionMoveStart$.next(this.getSelectionDataWithStyle());
}