Skip to content

Commit

Permalink
fix(sheet): update for change (#1044)
Browse files Browse the repository at this point in the history
  • Loading branch information
DR-Univer authored Jan 8, 2024
1 parent 36fdeed commit 2867016
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
27 changes: 6 additions & 21 deletions packages/sheets-ui/src/controllers/selection.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -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());
}
Expand Down

0 comments on commit 2867016

Please sign in to comment.