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
jerry31cdb4b2ffd7
diff --git a/packages/base-sheets/src/Controller/SheetBarController1.ts b/packages/base-sheets/src/Controller/SheetBarController1.tsnew file mode 100644index 0000000000..8b5fecc54e--- /dev/null+++ b/packages/base-sheets/src/Controller/SheetBarController1.ts@@ -0,0 +1,9 @@+import { Plugin } from '@univerjs/core';++export class SheetBarControl {+ protected _plugin: Plugin;++ constructor(plugin: Plugin) {+ this._plugin = plugin;+ }+}diff --git a/packages/base-ui/src/Common/EventManager.ts b/packages/base-ui/src/Common/EventManager.tsindex b9211de82d..0bc9e2df54 100644--- a/packages/base-ui/src/Common/EventManager.ts+++ b/packages/base-ui/src/Common/EventManager.ts@@ -14,6 +14,16 @@ export class EventManager {this._observerManager.addObserver('onUIChangeObservable', 'core', new Observable());this._observerManager.addObserver('onAfterChangeUILocaleObservable', 'core', new Observable());this._observerManager.addObserver('onViewComponentFocusChange', 'core', new Observable());- this._observerManager.addObserver('onViewComponentFocusChange', 'core', new Observable());++ // SheetBar+ this._observerManager.addObserver('onAddSheet', 'core', new Observable());+ this._observerManager.addObserver('onDeleteSheet', 'core', new Observable());+ this._observerManager.addObserver('onHideSheet', 'core', new Observable());+ this._observerManager.addObserver('onUnHideSheet', 'core', new Observable());+ this._observerManager.addObserver('onToLeftSheet', 'core', new Observable());+ this._observerManager.addObserver('onToRightSheet', 'core', new Observable());+ this._observerManager.addObserver('onCopySheet', 'core', new Observable());+ this._observerManager.addObserver('onRemoveSheet', 'core', new Observable());+ this._observerManager.addObserver('onSheetColor', 'core', new Observable());}}diff --git a/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.ts b/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.tsindex 837d17a30d..eb87f7d2fa 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, ACTION_NAMES, CommandManager, SheetActionBase } from '@univerjs/core';+import { Nullable, Plugin, ACTION_NAMES, CommandManager, SheetActionBase, UIObserver } from '@univerjs/core';import { SheetBar } from "../View/SheetBar";import styles from '../View/SheetBar/index.module.less';@@ -25,16 +25,16 @@ export class SheetBarUIController {protected _sheetList: SheetUlProps[];+ protected _sheetUl: SheetUl[];+protected _sheetIndex: number;- protected _dataId: string;+ protected _plugin: Plugin;- protected _sheetUl: SheetUl[];+ protected _dataId: string;protected _menuList: SheetUlProps[];- protected _plugin: Plugin;-protected _refreshSheetBarUI(): void {this._sheetBar.setValue({sheetList: this._sheetList,@@ -108,24 +108,25 @@ export class SheetBarUIController {}constructor(plugin: Plugin) {+ let that = this;this._plugin = plugin;this._sheetUl = [{locale: 'sheetConfig.delete',onClick: () => {- //barControl.deleteSheet();+ that.setUIObserve('onDeleteSheet', { name: 'deleteSheet' });},},{locale: 'sheetConfig.copy',onClick: () => {- //barControl.copySheet();+ that.setUIObserve('onCopySheet', { name: 'copySheet' });},},{locale: 'sheetConfig.rename',onClick: () => {- //barControl.reNameSheet();+ that.setUIObserve('onRemoveSheet', { name: 'removeSheet' });},},{@@ -138,14 +139,14 @@ export class SheetBarUIController {name: this._plugin.getPluginName() + ColorPicker.name,props: {onClick: (color: string) => {- // barControl.setSheetColor(color);+ that.setUIObserve('onSheetColor', { name: 'sheetColor', value: color });},lang: {collapseLocale: 'colorPicker.collapse',+ changeLocale: 'colorPicker.change',customColorLocale: 'colorPicker.customColor',- confirmColorLocale: 'colorPicker.confirmColor',cancelColorLocale: 'colorPicker.cancelColor',- changeLocale: 'colorPicker.change',+ confirmColorLocale: 'colorPicker.confirmColor',},},},@@ -156,26 +157,27 @@ export class SheetBarUIController {{locale: 'sheetConfig.hide',onClick: () => {- //barControl.hideSheet();+ that.setUIObserve('onHideSheet', { name: 'hideSheet' });},},{locale: 'sheetConfig.unhide',onClick: () => {- //barControl.unHideSheet();+ that.setUIObserve('onUnHideSheet', { name: 'hideSheet' });+},border: true,},{locale: 'sheetConfig.moveLeft',onClick: () => {- //barControl.moveSheet('left');+ that.setUIObserve('onToLeftSheet', { name: 'toLeftSheet' });},},{locale: 'sheetConfig.moveRight',onClick: () => {- //barControl.moveSheet('right');+ that.setUIObserve('onToRightSheet', { name: 'toRightSheet' });},},];@@ -254,6 +256,10 @@ export class SheetBarUIController {return obj;}+ setUIObserve<T>(type: string, msg: UIObserver<T>) {+ this._plugin.getContext().getObserverManager().requiredObserver<UIObserver<T>>(type, 'core').notifyObservers(msg);+ }+getSheetBar(): SheetBar {return this._sheetBar;}@@ -299,8 +305,12 @@ export class SheetBarUIController {}addSheet(position?: string, config?: SheetUlProps): void {- this._sheetBar.setValue({ sheetList: this._sheetList, menuList: this._menuList }, () => {- this._sheetBar.overGrid();+ this.setUIObserve('onAddSheet', {+ name: 'addSheet',+ value: {+ position,+ config+ }});}