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(facade): add ranges to setBorder (#4650)
Dushusir434943f4fa63
diff --git a/packages/sheets/src/commands/commands/set-border-command.ts b/packages/sheets/src/commands/commands/set-border-command.tsindex c0ff297cb2..1014b3a17c 100644--- a/packages/sheets/src/commands/commands/set-border-command.ts+++ b/packages/sheets/src/commands/commands/set-border-command.ts@@ -25,6 +25,7 @@ import type {IStyleData,} from '@univerjs/core';+import type { IBorderInfo } from '../../services/border-style-manager.service';import type { ISetRangeValuesMutationParams } from '../mutations/set-range-values.mutation';import type { IResult } from './utils/target-util';import {@@ -36,7 +37,7 @@ import {ObjectMatrix,Tools,} from '@univerjs/core';-import { BorderStyleManagerService, type IBorderInfo } from '../../services/border-style-manager.service';+import { BorderStyleManagerService } from '../../services/border-style-manager.service';import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mutations/set-range-values.mutation';import { getSheetCommandTarget } from './utils/target-util';@@ -53,8 +54,9 @@ function forEach(range: IRange, action: (row: number, column: number) => void):export interface ISetBorderBasicCommandParams {unitId?: string;subUnitId?: string;-+ ranges: IRange[];value: IBorderInfo;+}export interface ISetBorderPositionCommandParams {@@ -68,6 +70,7 @@ export interface ISetBorderStyleCommandParams {export interface ISetBorderCommandParams {unitId?: string;subUnitId?: string;+ ranges?: IRange[];}export interface ISetBorderColorCommandParams {@@ -546,15 +549,15 @@ export const SetBorderCommand: ICommand = {const target = getSheetCommandTarget(univerInstanceService, params);if (!target) return false;- const selections = selectionManagerService.getCurrentSelections()?.map((s) => s.range);- if (!selections?.length) {+ const ranges = params?.ranges || selectionManagerService.getCurrentSelections()?.map((s) => s.range);+ if (!ranges?.length) {return false;}const { activeBorderType } = borderStyleManagerService.getBorderInfo();if (!activeBorderType) return false;- const borderContext = getBorderContext(borderStyleManagerService, target, selections);+ const borderContext = getBorderContext(borderStyleManagerService, target, ranges);innerBorder(borderContext);outlineBorder(borderContext);otherBorders(borderContext);@@ -626,7 +629,7 @@ export const SetBorderBasicCommand: ICommand<ISetBorderBasicCommandParams> = {id: 'sheet.command.set-border-basic',type: CommandType.COMMAND,handler: (accessor: IAccessor, params: ISetBorderBasicCommandParams) => {- const { unitId, subUnitId, value } = params;+ const { unitId, subUnitId, value, ranges } = params;const { type, color, style } = value;const commandService = accessor.get(ICommandService);@@ -639,6 +642,7 @@ export const SetBorderBasicCommand: ICommand<ISetBorderBasicCommandParams> = {return commandService.syncExecuteCommand(SetBorderCommand.id, {unitId,subUnitId,+ ranges,});},};diff --git a/packages/sheets/src/facade/f-range.ts b/packages/sheets/src/facade/f-range.tsindex 9e83c168b9..b15ba1a756 100644--- a/packages/sheets/src/facade/f-range.ts+++ b/packages/sheets/src/facade/f-range.ts@@ -623,6 +623,7 @@ export class FRange extends FBaseInitialable {this._commandService.syncExecuteCommand(SetBorderBasicCommand.id, {unitId: this._workbook.getUnitId(),subUnitId: this._worksheet.getSheetId(),+ ranges: [this._range],value: {type,style,