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
flush
jerry18f5ae8acbe0
diff --git a/packages/core/src/Command/SheetActionBase.ts b/packages/core/src/Command/SheetActionBase.tsindex c982e3df57..987b540e09 100644--- a/packages/core/src/Command/SheetActionBase.ts+++ b/packages/core/src/Command/SheetActionBase.ts@@ -22,6 +22,8 @@ export abstract class SheetActionBase<O extends ISheetActionData = D,R = void> extends ActionBase<D, O, R> {+ protected _commandUnit: CommandUnit;+protected _workbook: Workbook;protected constructor(@@ -33,6 +35,7 @@ export abstract class SheetActionBase<if (commandUnit.WorkBookUnit == null) {throw new Error('action workbook domain can not be null!');}+ this._commandUnit = commandUnit;this._workbook = commandUnit.WorkBookUnit;}diff --git a/packages/core/src/Sheets/Action/RemoveSheetAction.ts b/packages/core/src/Sheets/Action/RemoveSheetAction.tsindex f15dfa6608..8b5b845a6f 100644--- a/packages/core/src/Sheets/Action/RemoveSheetAction.ts+++ b/packages/core/src/Sheets/Action/RemoveSheetAction.ts@@ -1,9 +1,9 @@-import { InsertSheet, RemoveSheet } from '../Apply';+import { InsertSheetApply, RemoveSheetApply } from '../Apply';import { IWorksheetConfig } from '../../Interfaces';+import { CommandUnit } from '../../Command';import { SheetActionBase, ISheetActionData } from '../../Command/SheetActionBase';-import { ActionObservers, ActionType } from '../../Command/ActionObservers';import { IInsertSheetActionData } from './InsertSheetAction';-import { CommandUnit } from '../../Command';+import { ActionObservers, ActionType } from '../../Command/ActionObservers';export interface IRemoveSheetActionData extends ISheetActionData {sheetId: string;@@ -35,8 +35,7 @@ export class RemoveSheetAction extends SheetActionBase<}redo(): { index: number; sheet: IWorksheetConfig } {- const workbook = this.getWorkBook();- const result = RemoveSheet(workbook, this._doActionData.sheetId);+ const result = RemoveSheetApply(this._commandUnit, this._doActionData);this._observers.notifyObservers({type: ActionType.REDO,data: this._doActionData,@@ -47,12 +46,12 @@ export class RemoveSheetAction extends SheetActionBase<undo(): void {const workbook = this.getWorkBook();+ InsertSheetApply(this._commandUnit, this._oldActionData);this._observers.notifyObservers({type: ActionType.UNDO,data: this._oldActionData,action: this,});- InsertSheet(workbook, this._oldActionData.index, this._oldActionData.sheet);}validate(): boolean {diff --git a/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.ts b/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.tsindex dcccbdab54..b76ee6923c 100644--- a/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.ts+++ b/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.ts@@ -1,5 +1,5 @@import { BaseMenuItem, BaseUlProps, ColorPicker } from '@univerjs/base-ui';-import { Nullable, Plugin, CommandManager, SheetActionBase, UIObserver, SetSheetOrderAction, InsertSheetAction, SetWorkSheetNameAction, SetTabColorAction, SetWorkSheetHideAction, SetWorkSheetActivateAction, SetWorkSheetStatusAction } from '@univerjs/core';+import { Nullable, Plugin, CommandManager, SheetActionBase, UIObserver, SetSheetOrderAction, InsertSheetAction, SetWorkSheetNameAction, SetTabColorAction, SetWorkSheetHideAction, SetWorkSheetActivateAction, SetWorkSheetStatusAction, RemoveSheetAction } from '@univerjs/core';import { SheetUIPlugin, SHEET_UI_PLUGIN_NAME } from '..';import { SheetBar } from "../View/SheetBar";import styles from '../View/SheetBar/index.module.less';@@ -96,7 +96,9 @@ export class SheetBarUIController {},}));this._sheetIndex = sheets.findIndex((sheet) => sheet.getStatus() === 1);- this._dataId = sheets[this._sheetIndex].getSheetId();+ if (this._sheetIndex > -1) {+ this._dataId = sheets[this._sheetIndex].getSheetId();+ }}protected _refreshComponent(): void {@@ -178,10 +180,13 @@ export class SheetBarUIController {case SetWorkSheetActivateAction.NAME:case SetSheetOrderAction.NAME:case InsertSheetAction.NAME:+ case RemoveSheetAction.NAME:case SetWorkSheetNameAction.NAME:+ case InsertSheetAction.NAME:case SetTabColorAction.NAME:case SetWorkSheetHideAction.NAME:case SetWorkSheetStatusAction.NAME: {+ debugger// update data;this._refreshSheetData();// set ui bar sheetList;