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(code): filterplugin protectionplugin groupplugin code eslint fix
jerry0fc37083ade1
diff --git a/packages/sheets-plugin-filter/src/FilterPlugin.tsx b/packages/sheets-plugin-filter/src/FilterPlugin.tsxindex 1a04fa47aa..d9b992cd5f 100644--- a/packages/sheets-plugin-filter/src/FilterPlugin.tsx+++ b/packages/sheets-plugin-filter/src/FilterPlugin.tsx@@ -1,10 +1,5 @@-import { ISlotElement } from '@univerjs/base-ui';-import { Command, SheetContext, IRangeData, UniverSheet, Plugin, PLUGIN_NAMES } from '@univerjs/core';-import { SheetPlugin } from '@univerjs/base-sheets';-import { en, zh } from './Locale';-import { IConfig } from './IData';-import { FilterButton } from './UI/FilterButton';-import { ACTION_NAMES, FILTER_PLUGIN_NAME } from './Const';+import { SheetContext, IRangeData, UniverSheet, Plugin } from '@univerjs/core';+import { FILTER_PLUGIN_NAME } from './Const';import { Filter, FilterList, IFilterPluginConfig } from './Domain';export class FilterPlugin extends Plugin {@@ -19,47 +14,48 @@ export class FilterPlugin extends Plugin {return new FilterPlugin(config);}- installTo(universheetInstance: UniverSheet) {+ installTo(universheetInstance: UniverSheet): void {universheetInstance.installPlugin(this);}onMounted(context: SheetContext): void {- const config: IConfig = {- context,- };- context.getLocale().load({- en,- zh,- });- context- .getPluginManager()- .getRequirePluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)- .addButton({- locale: FILTER_PLUGIN_NAME,- type: ISlotElement.JSX,- show: true,- label: <FilterButton config={config} super={this} />,- });+ // const config: IConfig = {+ // context,+ // };+ // context.getLocale().load({+ // en,+ // zh,+ // });+ // context+ // .getPluginManager()+ // .getRequirePluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)+ // .addButton({+ // locale: FILTER_PLUGIN_NAME,+ // type: ISlotElement.JSX,+ // show: true,+ // label: <FilterButton config={config} super={this} />,+ // });}addFilter(filter: Filter): void {- const context = this.getContext();- const commandManager = context.getCommandManager();- const workbook = context.getWorkBook();- const worksheet = workbook.getActiveSheet();- if (worksheet) {- const configure = {- actionName: ACTION_NAMES.ADD_FILTER_ACTION,- filter: filter.toSequence(),- sheetId: worksheet.getSheetId(),- };- const command = new Command(workbook, configure);- commandManager.invoke(command);- }+ // const context = this.getContext();+ // const commandManager = context.getCommandManager();+ // const workbook = context.getWorkBook();+ // const worksheet = workbook.getActiveSheet();+ // if (worksheet) {+ // const configure = {+ // actionName: ACTION_NAMES.ADD_FILTER_ACTION,+ // filter: filter.toSequence(),+ // sheetId: worksheet.getSheetId(),+ // };+ // const command = new Command(workbook, configure);+ // commandManager.invoke(command);+ // }}- newFilter(sheetId: string, range: IRangeData): Filter {- return new Filter(sheetId, range).withContext(this.getContext());+ newFilter(sheetId: string, range: IRangeData): Filter | null {+ //return new Filter(sheetId, range).withContext(this.getContext());+ return null;}getFilterList(): FilterList {diff --git a/packages/sheets-plugin-filter/src/main.tsx b/packages/sheets-plugin-filter/src/main.tsxindex 56ad4a698d..a21cd8c44d 100644--- a/packages/sheets-plugin-filter/src/main.tsx+++ b/packages/sheets-plugin-filter/src/main.tsx@@ -1,7 +1,6 @@import { UniverSheet } from '@univerjs/core';import { RenderEngine } from '@univerjs/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univerjs/common-plugin-data';-import { SheetPlugin } from '@univerjs/base-sheets';const uiDefaultConfigUp = {container: 'universheet-demo-up',@@ -9,6 +8,6 @@ const uiDefaultConfigUp = {const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);univerSheetUp.installPlugin(new RenderEngine());-univerSheetUp.installPlugin(new UniverComponentSheet());-univerSheetUp.installPlugin(new SheetPlugin(uiDefaultConfigUp));+// univerSheetUp.installPlugin(new UniverComponentSheet());+// univerSheetUp.installPlugin(new SheetPlugin(uiDefaultConfigUp));// univerSheetUp.installPlugin(new FilterPlugin());diff --git a/packages/sheets-plugin-group/src/Action/SetCollapseAllColumnGroupsAction.ts b/packages/sheets-plugin-group/src/Action/SetCollapseAllColumnGroupsAction.tsindex c90de9a5ea..3e0eea0fba 100644--- a/packages/sheets-plugin-group/src/Action/SetCollapseAllColumnGroupsAction.ts+++ b/packages/sheets-plugin-group/src/Action/SetCollapseAllColumnGroupsAction.ts@@ -1,4 +1,4 @@-import { ISheetActionData, SheetActionBase, Workbook, ActionObservers, ActionType } from '@univerjs/core';+import { ISheetActionData, SheetActionBase, ActionObservers, ActionType, CommandUnit } from '@univerjs/core';/*** @internal@@ -11,8 +11,8 @@ export interface ISetCollapseAllColumnGroupsData extends ISheetActionData {}* @internal*/export class SetCollapseAllColumnGroupsAction extends SheetActionBase<ISetCollapseAllColumnGroupsData, ISetCollapseAllColumnGroupsData> {- constructor(actionData: ISetCollapseAllColumnGroupsData, workbook: Workbook, observers: ActionObservers) {- super(actionData, workbook, observers);+ constructor(actionData: ISetCollapseAllColumnGroupsData, commandUnit: CommandUnit, observers: ActionObservers) {+ super(actionData, commandUnit, observers);this._doActionData = {...actionData,};diff --git a/packages/sheets-plugin-group/src/Action/SetCollapseAllRowGroupsAction.ts b/packages/sheets-plugin-group/src/Action/SetCollapseAllRowGroupsAction.tsindex 835b679516..39c90bf724 100644--- a/packages/sheets-plugin-group/src/Action/SetCollapseAllRowGroupsAction.ts+++ b/packages/sheets-plugin-group/src/Action/SetCollapseAllRowGroupsAction.ts@@ -1,4 +1,4 @@-import { ISheetActionData, SheetActionBase, Workbook, ActionObservers, ActionType } from '@univerjs/core';+import { ISheetActionData, SheetActionBase, ActionObservers, ActionType, CommandUnit } from '@univerjs/core';/*** @internal@@ -11,8 +11,8 @@ export interface ISetCollapseAllRowGroupsData extends ISheetActionData {}* @internal*/export class SetCollapseAllRowGroupsAction extends SheetActionBase<ISetCollapseAllRowGroupsData, ISetCollapseAllRowGroupsData> {- constructor(actionData: ISetCollapseAllRowGroupsData, workbook: Workbook, observers: ActionObservers) {- super(actionData, workbook, observers);+ constructor(actionData: ISetCollapseAllRowGroupsData, commandUnit: CommandUnit, observers: ActionObservers) {+ super(actionData, commandUnit, observers);this._doActionData = {...actionData,};diff --git a/packages/sheets-plugin-group/src/Apply/SetCollapseAllColumnGroups.ts b/packages/sheets-plugin-group/src/Apply/SetCollapseAllColumnGroups.tsindex 978feb5224..b75480e6d8 100644--- a/packages/sheets-plugin-group/src/Apply/SetCollapseAllColumnGroups.ts+++ b/packages/sheets-plugin-group/src/Apply/SetCollapseAllColumnGroups.ts@@ -1,4 +1,4 @@-import { GroupOpenType, StructGroup } from '../../Module/Group';+import { GroupOpenType, StructGroup } from '../Controller/StructGroup';/***diff --git a/packages/sheets-plugin-group/src/Basics/Const/index.ts b/packages/sheets-plugin-group/src/Basics/Const/index.tsindex e69de29bb2..caeb42be51 100644--- a/packages/sheets-plugin-group/src/Basics/Const/index.ts+++ b/packages/sheets-plugin-group/src/Basics/Const/index.ts@@ -0,0 +1 @@+export * from './PLUGIN_NAME';diff --git a/packages/sheets-plugin-group/src/Basics/Enum/index.ts b/packages/sheets-plugin-group/src/Basics/Enum/index.tsindex e69de29bb2..3cc114295e 100644--- a/packages/sheets-plugin-group/src/Basics/Enum/index.ts+++ b/packages/sheets-plugin-group/src/Basics/Enum/index.ts@@ -0,0 +1 @@+export * from './ACTION_NAMES';diff --git a/packages/sheets-plugin-group/src/Basics/index.ts b/packages/sheets-plugin-group/src/Basics/index.tsindex 640d1bb8b3..5694e7c22f 100644--- a/packages/sheets-plugin-group/src/Basics/index.ts+++ b/packages/sheets-plugin-group/src/Basics/index.ts@@ -1,4 +1,3 @@export * from './Const';export * from './Enum';export * from '../Locale';-export * from './Shared';diff --git a/packages/sheets-plugin-group/src/GroupPlugin.tsx b/packages/sheets-plugin-group/src/GroupPlugin.tsxindex f5c84ea978..65917767bc 100644--- a/packages/sheets-plugin-group/src/GroupPlugin.tsx+++ b/packages/sheets-plugin-group/src/GroupPlugin.tsx@@ -1,9 +1,4 @@-import { SheetContext, Plugin, PLUGIN_NAMES, UniverSheet, IOCContainer } from '@univerjs/core';-import { IToolbarItemProps, ISlotElement } from '@univerjs/base-ui';-import { SheetPlugin } from '@univerjs/base-sheets';-import { GroupButton } from './View/UI/GroupButton';-import { zh, en } from './Locale';-+import { SheetContext, Plugin, UniverSheet, IOCContainer } from '@univerjs/core';import { GROUP_PLUGIN_NAME } from './Basics/Const/PLUGIN_NAME';export interface IGroupPluginConfig {}@@ -22,23 +17,23 @@ export class GroupPlugin extends Plugin {}initialize(): void {- const context = this.getContext();-- /**- * load more Locale object- */- context.getLocale().load({- en,- zh,- });-- const item: IToolbarItemProps = {- locale: 'group',- type: ISlotElement.JSX,- show: true,- label: <GroupButton />,- };- context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.addButton(item);+ // const context = this.getContext();+ //+ // /**+ // * load more Locale object+ // */+ // context.getLocale().load({+ // en,+ // zh,+ // });+ //+ // const item: IToolbarItemProps = {+ // locale: 'group',+ // type: ISlotElement.JSX,+ // show: true,+ // label: <GroupButton />,+ // };+ // context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.addButton(item);}onMapping(IOC: IOCContainer): void {}diff --git a/packages/sheets-plugin-group/src/View/UI/GroupButton.tsx b/packages/sheets-plugin-group/src/View/UI/GroupButton.tsxindex 7846d48326..b1dbfffbec 100644--- a/packages/sheets-plugin-group/src/View/UI/GroupButton.tsx+++ b/packages/sheets-plugin-group/src/View/UI/GroupButton.tsx@@ -1,26 +1,18 @@import { Nullable, Observer } from '@univerjs/core';-import { ISelectButton, IToolbarItemProps, Component, BaseSelectProps } from '@univerjs/base-ui';+import { ISelectButton, Component, Icon } from '@univerjs/base-ui';+import { ComponentChild, RenderableProps } from 'preact';interface IProps {}-// Types for state-interface IState {- group: IToolbarItemProps;-}-export class GroupButton extends Component<IProps, IState> {+export class GroupButton extends Component<IProps> {private _localeObserver: Nullable<Observer<void>>;initialize(props: IProps) {- const OrderASCIcon = this.getComponentRender().renderFunction('OrderASCIcon');- const OrderDESCIcon = this.getComponentRender().renderFunction('OrderDESCIcon');- const OrderIcon = this.getComponentRender().renderFunction('OrderIcon');- const NextIcon = this.getComponentRender().renderFunction('NextIcon');-- const group: IToolbarItemProps = {+ const group = {locale: 'group',type: 'select',- label: <OrderASCIcon />,- icon: <NextIcon />,+ label: <Icon.Data.OrderASCIcon />,+ icon: <Icon.NextIcon />,show: true,border: false,selectType: ISelectButton.DOUBLE,@@ -28,15 +20,15 @@ export class GroupButton extends Component<IProps, IState> {children: [{locale: 'group.one',- icon: <OrderASCIcon />,+ icon: <Icon.Data.OrderASCIcon />,},{locale: 'group.two',- icon: <OrderDESCIcon />,+ icon: <Icon.Data.OrderDESCIcon />,},{locale: 'group.three',- icon: <OrderIcon />,+ icon: <Icon.Data.OrderIcon />,},],};@@ -54,7 +46,7 @@ export class GroupButton extends Component<IProps, IState> {// subscribe Locale change event- this._localeObserver = this._context+ this._localeObserver = this.getContext().getObserverManager().getObserver('onAfterChangeUILocaleObservable', 'core')?.add(() => {@@ -73,25 +65,29 @@ export class GroupButton extends Component<IProps, IState> {* set text by config setting and Locale message*/setLocale() {- const locale = this._context.getLocale();- this.setState((prevState: IState) => {- let item = prevState.group;- // set current Locale string for tooltip- item.tooltip = locale.get(`${item.locale}Label`);- item.tooltipRight = locale.get(`${item.locale}RightLabel`);-- // set current Locale string for select- item.children?.forEach((ele: IToolbarItemProps) => {- if (ele.locale) {- ele.label = locale.get(`${ele.locale}`);- }- });- item.label = typeof item.label === 'object' ? item.label : item.children![0].label;+ // const locale = this.getContext().getLocale();+ // this.setState((prevState: IState) => {+ // let item = prevState.group;+ // // set current Locale string for tooltip+ // item.tooltip = locale.get(`${item.locale}Label`);+ // item.tooltipRight = locale.get(`${item.locale}RightLabel`);+ //+ // // set current Locale string for select+ // item.children?.forEach((ele) => {+ // if (ele.locale) {+ // ele.label = locale.get(`${ele.locale}`);+ // }+ // });+ // item.label = typeof item.label === 'object' ? item.label : item.children![0].label;+ //+ // return {+ // group: item,+ // };+ // });+ }- return {- group: item,- };- });+ render(props: RenderableProps<IProps> | undefined, state: Readonly<{}> | undefined, context: any): ComponentChild {+ return undefined;}/**@@ -99,21 +95,20 @@ export class GroupButton extends Component<IProps, IState> {** @returns {void}*/- render(props: IProps, state: IState) {- const { group } = state;- const Select = this.getComponentRender().renderFunction('Select');- // Set Provider for entire Container- return (- <Select- tooltip={group.tooltip}- tooltipRight={group.tooltipRight}- border={group.border}- needChange={group.needChange}- key={group.locale}- children={group.children as BaseSelectProps[]}- label={group.label}- icon={group.icon}- />- );- }+ // render(props: IProps, state: IState) {+ // const { group } = state;+ // // Set Provider for entire Container+ // return (+ // <Select+ // tooltip={group.tooltip}+ // tooltipRight={group.tooltipRight}+ // border={group.border}+ // needChange={group.needChange}+ // key={group.locale}+ // children={group.children as BaseSelectProps[]}+ // label={group.label}+ // icon={group.icon}+ // />+ // );+ // }}diff --git a/packages/sheets-plugin-protection/src/Action/SetProtectionAction.ts b/packages/sheets-plugin-protection/src/Action/SetProtectionAction.tsindex 19cc718459..2937b07757 100644--- a/packages/sheets-plugin-protection/src/Action/SetProtectionAction.ts+++ b/packages/sheets-plugin-protection/src/Action/SetProtectionAction.ts@@ -1,4 +1,4 @@-import { SheetActionBase, ActionObservers, ISheetActionData, Workbook } from '@univerjs/core';+import { SheetActionBase, ActionObservers, ISheetActionData, CommandUnit } from '@univerjs/core';import { SetProtection } from '../Apply';import { ACTION_NAMES } from '../Basics/Enum/ACTION_NAMES';@@ -10,8 +10,8 @@ export interface ISetProtectionActionData extends ISheetActionData {export class SetProtectionAction extends SheetActionBase<ISetProtectionActionData, ISetProtectionActionData> {protected _oldValue: [boolean, string];- constructor(actionData: ISetProtectionActionData, workbook: Workbook, observers: ActionObservers) {- super(actionData, workbook, observers);+ constructor(actionData: ISetProtectionActionData, commandUnit: CommandUnit, observers: ActionObservers) {+ super(actionData, commandUnit, observers);this._doActionData = {...actionData,};diff --git a/packages/sheets-plugin-protection/src/Apply/AddAllowed.ts b/packages/sheets-plugin-protection/src/Apply/AddAllowed.tsindex 4e93547dc5..bf542d661d 100644--- a/packages/sheets-plugin-protection/src/Apply/AddAllowed.ts+++ b/packages/sheets-plugin-protection/src/Apply/AddAllowed.ts@@ -1,7 +1,7 @@import { Worksheet } from '@univerjs/core';-import { Allowed } from '@univerjs/core/src/Module/Protection';+import { Allowed } from '../Controller';export function AddAllowed(workSheet: Worksheet, allowed: Allowed) {- const protection = workSheet.getProtection();- protection.getAllowedList().addAllow(allowed);+ // const protection = workSheet.getProtection();+ // protection.getAllowedList().addAllow(allowed);}diff --git a/packages/sheets-plugin-protection/src/Apply/AddUnlock.ts b/packages/sheets-plugin-protection/src/Apply/AddUnlock.tsindex 0f5120ffc3..3d5e68f25f 100644--- a/packages/sheets-plugin-protection/src/Apply/AddUnlock.ts+++ b/packages/sheets-plugin-protection/src/Apply/AddUnlock.ts@@ -1,6 +1,6 @@import { Range, Worksheet } from '@univerjs/core';export function AddUnlock(workSheet: Worksheet, unlock: Range) {- const protection = workSheet.getProtection();- protection.getUnlockList().addUnlock(unlock);+ // const protection = workSheet.getProtection();+ // protection.getUnlockList().addUnlock(unlock);}diff --git a/packages/sheets-plugin-protection/src/Apply/RemoveAllowed.ts b/packages/sheets-plugin-protection/src/Apply/RemoveAllowed.tsindex 33350862d5..727846b61b 100644--- a/packages/sheets-plugin-protection/src/Apply/RemoveAllowed.ts+++ b/packages/sheets-plugin-protection/src/Apply/RemoveAllowed.ts@@ -1,7 +1,7 @@import { Worksheet } from '@univerjs/core';-import { Allowed } from '@univerjs/core/src/Module/Protection';+import { Allowed } from '../Controller';export function RemoveAllowed(workSheet: Worksheet, allowed: Allowed) {- const protection = workSheet.getProtection();- protection.getAllowedList().removeAllow(allowed);+ // const protection = workSheet.getProtection();+ // protection.getAllowedList().removeAllow(allowed);}diff --git a/packages/sheets-plugin-protection/src/Apply/RemoveUnlock.ts b/packages/sheets-plugin-protection/src/Apply/RemoveUnlock.tsindex f35779f709..45b3156221 100644--- a/packages/sheets-plugin-protection/src/Apply/RemoveUnlock.ts+++ b/packages/sheets-plugin-protection/src/Apply/RemoveUnlock.ts@@ -1,6 +1,6 @@import { Range, Worksheet } from '@univerjs/core';export function RemoveUnlock(workSheet: Worksheet, unlock: Range) {- const protection = workSheet.getProtection();- protection.getUnlockList().removeUnlock(unlock);+ // const protection = workSheet.getProtection();+ // protection.getUnlockList().removeUnlock(unlock);}diff --git a/packages/sheets-plugin-protection/src/Apply/SetProtection.ts b/packages/sheets-plugin-protection/src/Apply/SetProtection.tsindex b1bdf69f4f..6b41db00d6 100644--- a/packages/sheets-plugin-protection/src/Apply/SetProtection.ts+++ b/packages/sheets-plugin-protection/src/Apply/SetProtection.ts@@ -1,10 +1,11 @@import { Worksheet } from '@univerjs/core';export function SetProtection(workSheet: Worksheet, enable: boolean, password: string): [boolean, string] {- const protection = workSheet.getProtection();- const oldEnable = protection.getEnable();- const oldPassword = protection.getPassword();- protection.setPassword(password);- protection.setEnable(enable);- return [oldEnable, oldPassword];+ // const protection = workSheet.getProtection();+ // const oldEnable = protection.getEnable();+ // const oldPassword = protection.getPassword();+ // protection.setPassword(password);+ // protection.setEnable(enable);+ // return [oldEnable, oldPassword];+ return [false, ''];}diff --git a/packages/sheets-plugin-protection/src/ProtectionPlugin.tsx b/packages/sheets-plugin-protection/src/ProtectionPlugin.tsxindex 0ab2264841..7c6e93c7e8 100644--- a/packages/sheets-plugin-protection/src/ProtectionPlugin.tsx+++ b/packages/sheets-plugin-protection/src/ProtectionPlugin.tsx@@ -1,11 +1,5 @@-import { ISlotElement, ISlotProps, IToolbarItemProps } from '@univerjs/base-ui';-import { SheetContext, IOCContainer, UniverSheet, Plugin, PLUGIN_NAMES } from '@univerjs/core';-import { SheetPlugin } from '@univerjs/base-sheets';+import { SheetContext, IOCContainer, UniverSheet, Plugin } from '@univerjs/core';import { PROTECTION_PLUGIN_NAME } from './Basics/Const/PLUGIN_NAME';-import { IConfig } from './IData/IProtection';-import { en, zh } from './Locale';-import { ProtectionButton } from './UI/ProtectionButton';-import { ProtectionSide } from './UI/ProtectionSide';import { Protection } from './Controller';export interface IProtectionPluginConfig {}@@ -28,41 +22,41 @@ export class ProtectionPlugin extends Plugin {initialize(): void {const context = this.getContext();- /**- * load more Locale object- */- context.getLocale().load({- en,- zh,- });- const config: IConfig = {- context,- };-- const item: IToolbarItemProps = {- locale: PROTECTION_PLUGIN_NAME,- type: ISlotElement.JSX,- show: true,- label: <ProtectionButton config={config} />,- };- context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.addButton(item);-- // TODO- this._protectionSlider = new Protection();-- const rangeData = {- startRow: 0,- endRow: 10,- startColumn: 0,- endColumn: 10,- };-- const siderItem: ISlotProps = {- name: 'protection',- type: ISlotElement.JSX,- label: <ProtectionSide config={{ rangeData, context, protection: this._protectionSlider }} />,- };- context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.addSider(siderItem);+ // /**+ // * load more Locale object+ // */+ // context.getLocale().load({+ // en,+ // zh,+ // });+ // const config: IConfig = {+ // context,+ // };+ //+ // const item: IToolbarItemProps = {+ // locale: PROTECTION_PLUGIN_NAME,+ // type: ISlotElement.JSX,+ // show: true,+ // label: <ProtectionButton config={config} />,+ // };+ // context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.addButton(item);+ //+ // // TODO+ // this._protectionSlider = new Protection();+ //+ // const rangeData = {+ // startRow: 0,+ // endRow: 10,+ // startColumn: 0,+ // endColumn: 10,+ // };+ //+ // const siderItem: ISlotProps = {+ // name: 'protection',+ // type: ISlotElement.JSX,+ // label: <ProtectionSide config={{ rangeData, context, protection: this._protectionSlider }} />,+ // };+ // context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.addSider(siderItem);}onMapping(IOC: IOCContainer): void {}diff --git a/packages/sheets-plugin-protection/src/UI/ProtectionButton.tsx b/packages/sheets-plugin-protection/src/UI/ProtectionButton.tsxindex 2f1878697f..1eee9a64d4 100644--- a/packages/sheets-plugin-protection/src/UI/ProtectionButton.tsx+++ b/packages/sheets-plugin-protection/src/UI/ProtectionButton.tsx@@ -1,96 +1,97 @@-import { BaseComponentSheet, BaseIconProps, BaseSingleButtonProps, Component, FunctionComponent, IToolbarItemProps } from '@univerjs/base-ui';-import { PLUGIN_NAMES, Nullable, Observer, Workbook } from '@univerjs/core';-import { SheetPlugin } from '@univerjs/base-sheets';--import { PROTECTION_PLUGIN_NAME } from '../Basics/Const';-import { IProps } from '../IData/IProtection';--// Types for state-interface IState {- protection: IToolbarItemProps;-}--export class ProtectionButton extends Component<IProps, IState> {- private _localeObserver: Nullable<Observer<Workbook>>;-- SingleButton: FunctionComponent<BaseSingleButtonProps>;-- LockIcon: FunctionComponent<BaseIconProps>;-- initialize(props: IProps) {- // super();-- const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;- const render = component.getComponentRender();- this.SingleButton = render.renderFunction('SingleButton');- this.LockIcon = render.renderFunction('LockIcon');-- const protection: IToolbarItemProps = {- locale: 'protection',- type: 'single',- label: <this.LockIcon />,- show: true,- onClick: () => {- this._context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.showSiderByName(PROTECTION_PLUGIN_NAME, true);- },- };- this.state = {- protection,- };- }-- /**- * init- */- componentWillMount() {- this.setLocale();-- // subscribe Locale change event-- this._localeObserver = this._context- .getObserverManager()- .getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')- ?.add(() => {- this.setLocale();- });- }-- /**- * destory- */- componentWillUnmount() {- // this._context.getObserverManager().getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')?.remove(this._localeObserver);- }-- /**- * set text by config setting and Locale message- */- setLocale() {- const locale = this._context.getLocale();- let item = this.state.protection;- // set current Locale string for tooltip- item.tooltip = locale.get(`${item.locale}.${item.locale}Label`);- this.setState({ protection: item });- }-- /**- * Render the component's HTML- *- * @returns {void}- */- render(props: IProps, state: IState) {- const { protection } = state;- // Set Provider for entire Container- return (- <this.SingleButton- tooltip={protection.tooltip}- key={protection.locale}- name={protection.locale}- label={protection.label}- icon={protection.icon}- onClick={protection.onClick?.bind(this)}- ></this.SingleButton>- // <Select tooltip={protection.tooltip} tooltipRight={protection.tooltipRight} key={protection.name} label={protection.label} onClick={protection.onClick?.bind(this)} />- );- }-}+import { Component } from '@univerjs/base-ui';+import { Nullable, Observer, Workbook } from '@univerjs/core';+import { ComponentChild, RenderableProps } from 'preact';+import { IProps } from '../IData/IProtection';++// Types for state+// interface IState {+// protection: IToolbarItemProps;+// }++export class ProtectionButton extends Component<IProps> {+ private _localeObserver: Nullable<Observer<Workbook>>;++ // SingleButton: FunctionComponent<BaseSingleButtonProps>;+ //+ // LockIcon: FunctionComponent<BaseIconProps>;++ initialize(props: IProps) {+ // super();+ // const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ // const render = component.getComponentRender();+ // this.SingleButton = render.renderFunction('SingleButton');+ // this.LockIcon = render.renderFunction('LockIcon');+ //+ // const protection: IToolbarItemProps = {+ // locale: 'protection',+ // type: 'single',+ // label: <this.LockIcon />,+ // show: true,+ // onClick: () => {+ // this._context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.showSiderByName(PROTECTION_PLUGIN_NAME, true);+ // },+ // };+ // this.state = {+ // protection,+ // };+ }++ /**+ * init+ */+ componentWillMount() {+ this.setLocale();++ // subscribe Locale change event++ this._localeObserver = this.getContext()+ .getObserverManager()+ .getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')+ ?.add(() => {+ this.setLocale();+ });+ }++ /**+ * destory+ */+ componentWillUnmount() {+ // this._context.getObserverManager().getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')?.remove(this._localeObserver);+ }++ /**+ * set text by config setting and Locale message+ */+ setLocale() {+ // const locale = this.getContext().getLocale();+ // let item = this.state.protection;+ // // set current Locale string for tooltip+ // item.tooltip = locale.get(`${item.locale}.${item.locale}Label`);+ // this.setState({ protection: item });+ }++ render(props: RenderableProps<IProps> | undefined, state: Readonly<{}> | undefined, context: any): ComponentChild {+ return undefined;+ }++ /**+ * Render the component's HTML+ *+ * @returns {void}+ */+ // render(props: IProps, state: IState) {+ // const { protection } = state;+ // // Set Provider for entire Container+ // return (+ // <SingleButton+ // tooltip={protection.tooltip}+ // key={protection.locale}+ // name={protection.locale}+ // label={protection.label}+ // icon={protection.icon}+ // onClick={protection.onClick?.bind(this)}+ // ></SingleButton>+ // // <Select tooltip={protection.tooltip} tooltipRight={protection.tooltipRight} key={protection.name} label={protection.label} onClick={protection.onClick?.bind(this)} />+ // );+ // }+}diff --git a/packages/sheets-plugin-protection/src/main.tsx b/packages/sheets-plugin-protection/src/main.tsxindex 0d916d44f5..b39d6fd17d 100644--- a/packages/sheets-plugin-protection/src/main.tsx+++ b/packages/sheets-plugin-protection/src/main.tsx@@ -1,7 +1,6 @@import { UniverSheet } from '@univerjs/core';import { RenderEngine } from '@univerjs/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univerjs/common-plugin-data';-import { SheetPlugin } from '@univerjs/base-sheets';const uiDefaultConfigUp = {container: 'universheet-demo',@@ -9,7 +8,7 @@ const uiDefaultConfigUp = {const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);univerSheetUp.installPlugin(new RenderEngine());-univerSheetUp.installPlugin(new UniverComponentSheet());-univerSheetUp.installPlugin(new SheetPlugin(uiDefaultConfigUp));+// univerSheetUp.installPlugin(new UniverComponentSheet());+// univerSheetUp.installPlugin(new SheetPlugin(uiDefaultConfigUp));// univerSheetUp.installPlugin(new FilterPlugin());// univerSheetUp.installPlugin(new ProtectionPlugin());