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
feat(ui): support for disabling enablement in contextmenu service (#1244)
白熱3d065175efbd
diff --git a/packages/ui/src/services/contextmenu/contextmenu.service.ts b/packages/ui/src/services/contextmenu/contextmenu.service.tsindex 9c26f684ad..6b2927e7a6 100644--- a/packages/ui/src/services/contextmenu/contextmenu.service.ts+++ b/packages/ui/src/services/contextmenu/contextmenu.service.ts@@ -25,6 +25,10 @@ export interface IContextMenuHandler {}export interface IContextMenuService {+ disabled: boolean;++ enable(): void;+ disable(): void;triggerContextMenu(event: IPointerEvent | IMouseEvent, menuType: string): void;registerContextMenuHandler(handler: IContextMenuHandler): IDisposable;}@@ -34,8 +38,21 @@ export const IContextMenuService = createIdentifier<IContextMenuService>('univerexport class DesktopContextMenuService extends Disposable implements IContextMenuService {private _currentHandler: IContextMenuHandler | null = null;+ disabled: boolean = false;++ disable(): void {+ this.disabled = true;+ }++ enable(): void {+ this.disabled = false;+ }+triggerContextMenu(event: IPointerEvent | IMouseEvent, menuType: string): void {event.stopPropagation();++ if (this.disabled) return;+this._currentHandler?.handleContextMenu(event, menuType);}