@univerjs/ui 1.0.0-alpha.7 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -214,13 +214,6 @@ export interface IFUniverUIMixin {
214
214
  * ```
215
215
  */
216
216
  createSubmenu(submenuItem: IFacadeSubmenuItem): FSubmenu;
217
- /**
218
- * Open a sidebar.
219
- * @deprecated Please use `univerAPI.openSidebar` instead.
220
- * @param {ISidebarMethodOptions} params the sidebar options
221
- * @returns {IDisposable} the disposable object
222
- */
223
- openSiderbar(params: ISidebarMethodOptions): IDisposable;
224
217
  /**
225
218
  * Open a sidebar.
226
219
  * @param {ISidebarMethodOptions} params the sidebar options
@@ -435,7 +428,6 @@ export declare class FUniverUIMixin extends FUniver implements IFUniverUIMixin {
435
428
  paste(): Promise<boolean>;
436
429
  createMenu(menuItem: IFacadeMenuItem): FMenu;
437
430
  createSubmenu(submenuItem: IFacadeSubmenuItem): FSubmenu;
438
- openSiderbar(params: ISidebarMethodOptions): IDisposable;
439
431
  openSidebar(params: ISidebarMethodOptions): IDisposable;
440
432
  openDialog(dialog: IDialogPartMethodOptions): IDisposable;
441
433
  getComponentManager(): ComponentManager;
@@ -14,9 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import './f-univer';
17
- import './f-hooks';
18
17
  import './f-menu-builder';
19
18
  import './f-enum';
20
- export type * from './f-hooks';
21
19
  export type * from './f-menu-builder';
22
20
  export type * from './f-univer';
@@ -43,7 +43,7 @@ export type { IContextMenuHandler } from './services/contextmenu/contextmenu.ser
43
43
  export { DesktopDialogService } from './services/dialog/desktop-dialog.service';
44
44
  export { IDialogService } from './services/dialog/dialog.service';
45
45
  export { CanvasFloatDomPreviewService, CanvasFloatDomService } from './services/dom/canvas-dom-layer.service';
46
- export type { ICanvasFloatDomPreview, ICanvasFloatDomPreviewRequest, IFloatDom, IFloatDomLayout } from './services/dom/canvas-dom-layer.service';
46
+ export type { ICanvasFloatDomPreview, ICanvasFloatDomPreviewRequest, IFloatDom, IFloatDomLayout, } from './services/dom/canvas-dom-layer.service';
47
47
  export { FontService, IFontService } from './services/font.service';
48
48
  export type { IFontConfig } from './services/font.service';
49
49
  export { DesktopGalleryService } from './services/gallery/desktop-gallery.service';
@@ -74,12 +74,13 @@ export { IUIRuntimeScopeService, UIRuntimeScopeService } from './services/runtim
74
74
  export type { IUIRuntimeScope } from './services/runtime-scope/ui-runtime-scope.service';
75
75
  export { KeyCode, MetaKeys } from './services/shortcut/keycode';
76
76
  export { ShortcutPanelService } from './services/shortcut/shortcut-panel.service';
77
- export { IShortcutService, ShortcutService } from './services/shortcut/shortcut.service';
77
+ export { IShortcutService, NativeTextEditorShortcutBehavior, ShortcutService, } from './services/shortcut/shortcut.service';
78
78
  export type { IShortcutItem } from './services/shortcut/shortcut.service';
79
79
  export { DesktopSidebarService } from './services/sidebar/desktop-sidebar.service';
80
80
  export { useSidebarClick } from './services/sidebar/hooks/use-sidebar-click';
81
81
  export { ILeftSidebarService, ISidebarService } from './services/sidebar/sidebar.service';
82
82
  export { ThemeSwitcherService } from './services/theme-switcher/theme-switcher.service';
83
+ export { IWorkbenchService, WorkbenchService } from './services/workbench/workbench.service';
83
84
  export * from './utils';
84
85
  export { COLOR_PICKER_COMPONENT } from './views/color-picker/interface';
85
86
  export { ComponentContainer, useComponentsOfPart } from './views/components/ComponentContainer';
@@ -67,12 +67,15 @@ export declare function shouldForwardFloatDomEvents(layer: Pick<IFloatDom, 'even
67
67
  export declare function shouldRenderFloatDomLayer(layer: Pick<IFloatDom, 'unitId' | 'preserveOnFocusChange'>, currentUnitId: string | null | undefined): boolean;
68
68
  export declare class CanvasFloatDomService extends Disposable {
69
69
  private _domLayerMap;
70
+ private _scopedRenderRootCount;
70
71
  private _domLayers$;
71
72
  domLayers$: Observable<[string, IFloatDom][]>;
72
73
  get domLayers(): [string, IFloatDom][];
73
74
  private _notice;
74
75
  updateFloatDom(id: string, item: Partial<IFloatDom>): void;
75
76
  addFloatDom(item: IFloatDom): void;
77
+ hasScopedRenderRoot(unitId: string): boolean;
78
+ registerScopedRenderRoot(unitId: string): import("@wendellhu/redi").IDisposable;
76
79
  removeFloatDom(id: string): void;
77
80
  removeAll(): void;
78
81
  dispose(): void;
@@ -41,6 +41,7 @@ export interface IUIPartsService {
41
41
  visible: boolean;
42
42
  }>;
43
43
  registerComponent(part: ComponentPartKey, componentFactory: () => ComponentType): IDisposable;
44
+ registerDisabledUIParts(parts: readonly ComponentPartKey[], disabled$: Observable<boolean>): IDisposable;
44
45
  getComponents(part: ComponentPartKey): Set<ComponentRenderer>;
45
46
  setUIVisible(part: ComponentPartKey, visible: boolean): void;
46
47
  isUIVisible(part: ComponentPartKey): boolean;
@@ -48,6 +49,7 @@ export interface IUIPartsService {
48
49
  export declare const IUIPartsService: import("@wendellhu/redi").IdentifierDecorator<IUIPartsService>;
49
50
  export declare class UIPartsService extends Disposable implements IUIPartsService {
50
51
  private _componentsByPart;
52
+ private _disabledUIParts;
51
53
  private readonly _componentRegistered$;
52
54
  readonly componentRegistered$: Observable<string>;
53
55
  private readonly _uiVisible;
@@ -59,6 +61,7 @@ export declare class UIPartsService extends Disposable implements IUIPartsServic
59
61
  dispose(): void;
60
62
  setUIVisible(part: ComponentPartKey, visible: boolean): void;
61
63
  isUIVisible(part: ComponentPartKey): boolean;
64
+ registerDisabledUIParts(parts: readonly ComponentPartKey[], disabled$: Observable<boolean>): IDisposable;
62
65
  registerComponent<T>(part: ComponentPartKey, componentFactory: () => React.ComponentType<T>): IDisposable;
63
66
  getComponents(part: ComponentPartKey): Set<ComponentType>;
64
67
  }
@@ -20,6 +20,14 @@ import { ILayoutService } from '../layout/layout.service';
20
20
  import { IPlatformService } from '../platform/platform.service';
21
21
  import { IUIRuntimeScopeService } from '../runtime-scope/ui-runtime-scope.service';
22
22
  import { KeyCode } from './keycode';
23
+ /**
24
+ * Defines whether a Univer shortcut should yield to the browser's native behavior
25
+ * when the keyboard event originates from an editable text element.
26
+ */
27
+ export declare enum NativeTextEditorShortcutBehavior {
28
+ ALLOW_NATIVE = 0,
29
+ OVERRIDE_NATIVE = 1
30
+ }
23
31
  /**
24
32
  * A shortcut item that could be registered to the {@link IShortcutService}.
25
33
  */
@@ -35,6 +43,10 @@ export interface IShortcutItem<P extends object = object> {
35
43
  * would be passed to the callback.
36
44
  */
37
45
  preconditions?: (contextService: IContextService) => boolean;
46
+ /**
47
+ * A callback that examines the keyboard event before this shortcut is selected.
48
+ */
49
+ eventPreconditions?: (event: KeyboardEvent) => boolean;
38
50
  /**
39
51
  * The binding of the shortcut. It should be a combination of {@link KeyCode} and {@link MetaKeys}.
40
52
  *
@@ -55,6 +67,11 @@ export interface IShortcutItem<P extends object = object> {
55
67
  * The binding of the shortcut for Linux. If the property is not specified, the default binding would be used.
56
68
  */
57
69
  linux?: number;
70
+ /**
71
+ * Controls whether this shortcut can override the browser's native behavior
72
+ * for editable text elements. Native behavior is preserved by default.
73
+ */
74
+ nativeTextEditorBehavior?: NativeTextEditorShortcutBehavior;
58
75
  /**
59
76
  * The group of the menu item should belong to. The shortcut item would be rendered in the
60
77
  * panel if this is set.
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { IDisposable } from '@univerjs/core';
17
+ import type { Observable } from 'rxjs';
18
+ import { Disposable } from '@univerjs/core';
19
+ export interface IWorkbenchService {
20
+ readonly skeletonVisible$: Observable<boolean>;
21
+ acquireSkeleton(): IDisposable;
22
+ }
23
+ export declare const IWorkbenchService: import("@wendellhu/redi").IdentifierDecorator<IWorkbenchService>;
24
+ export declare class WorkbenchService extends Disposable implements IWorkbenchService {
25
+ private readonly _tokens;
26
+ private readonly _skeletonVisible$;
27
+ readonly skeletonVisible$: Observable<boolean>;
28
+ acquireSkeleton(): IDisposable;
29
+ dispose(): void;
30
+ }
@@ -27,6 +27,7 @@ interface IContextMenuPanelProps {
27
27
  className?: string;
28
28
  activeItemIds?: string[];
29
29
  hiddenItemIds?: string[];
30
+ flowQuickGroups?: boolean;
30
31
  sizeVariant?: ContextMenuSizeVariant;
31
32
  autoFocus?: boolean;
32
33
  autoFocusTarget?: ContextMenuAutoFocusTarget;
@@ -47,6 +48,6 @@ export declare function hasRenderableContextMenuSchema(menuSchema: IMenuSchema):
47
48
  export declare function shouldShowContextMenuGroupSeparator(visibleSchemas: IMenuSchema[], index: number): boolean;
48
49
  export declare function getContextMenuQuickGroupColumns(menuSchema: IMenuSchema): number | undefined;
49
50
  export declare function getNextMenuButtonByDirection(buttons: HTMLButtonElement[], activeIndex: number, key: string): HTMLButtonElement;
50
- export declare function getContextMenuSchemaRenderGroups(visibleSchemas: IMenuSchema[], sizeVariant: ContextMenuSizeVariant): IContextMenuSchemaRenderGroup[];
51
+ export declare function getContextMenuSchemaRenderGroups(visibleSchemas: IMenuSchema[], flowQuickGroups?: boolean): IContextMenuSchemaRenderGroup[];
51
52
  export declare function ContextMenuPanel(props: IContextMenuPanelProps): import("react").JSX.Element | null;
52
53
  export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { LocaleService } from '@univerjs/core';
17
+ export interface IWorkbenchSkeletonProps {
18
+ darkMode: boolean;
19
+ direction: ReturnType<LocaleService['getDirection']>;
20
+ overlay?: boolean;
21
+ }
22
+ export declare function WorkbenchSkeleton({ darkMode, direction, overlay }: IWorkbenchSkeletonProps): import("react").JSX.Element;
@@ -27,7 +27,7 @@ export type EmojiCategory = Exclude<keyof typeof emojis, 'frequent'>;
27
27
  export declare const EMOJI_RECENT_LIMIT = 11;
28
28
  export declare const EMOJI_CATEGORIES: {
29
29
  key: EmojiCategory;
30
- titleKey: "ui.row" | "ui.column" | "ui.common-edit" | "ui.toggle-shortcut-panel" | "ui.global-shortcut" | "ui.fontFamily.not-supported" | "ui.fontFamily.arial" | "ui.fontFamily.times-new-roman" | "ui.fontFamily.tahoma" | "ui.fontFamily.verdana" | "ui.fontFamily.microsoft-yahei" | "ui.fontFamily.simsun" | "ui.fontFamily.simhei" | "ui.fontFamily.kaiti" | "ui.fontFamily.fangsong" | "ui.fontFamily.nsimsun" | "ui.fontFamily.stxinwei" | "ui.fontFamily.stxingkai" | "ui.fontFamily.stliti" | "ui.ribbon.start" | "ui.ribbon.view" | "ui.ribbon.insert" | "ui.ribbon.data" | "ui.ribbon.startDesc" | "ui.ribbon.insertDesc" | "ui.ribbon.formulas" | "ui.ribbon.formulasDesc" | "ui.ribbon.dataDesc" | "ui.ribbon.viewDesc" | "ui.ribbon.others" | "ui.ribbon.othersDesc" | "ui.ribbon.more" | "ui.clipboard.authentication.title" | "ui.clipboard.authentication.content" | "ui.featureSearch.title" | "ui.featureSearch.empty" | "ui.featureSearch.placeholder" | "ui.featureSearch.ribbon" | "ui.featureSearch.contextMenu" | "ui.emojiPicker.search" | "ui.emojiPicker.objects" | "ui.emojiPicker.random" | "ui.emojiPicker.recents" | "ui.emojiPicker.emojis" | "ui.emojiPicker.animals" | "ui.emojiPicker.food" | "ui.emojiPicker.activities" | "ui.emojiPicker.places" | "ui.emojiPicker.symbols" | "ui.emojiPicker.searchResults" | "ui.emojiPicker.noResults" | `ui.emojiPicker.emojiSearchIndex.${string}` | `ui.emojiPicker.emojiTitles.${string}` | "ui.symbolPicker.mathematics" | "ui.symbolPicker.greek" | "ui.symbolPicker.common" | "ui.toolbar.heading.title" | "ui.toolbar.heading.normal" | "ui.toolbar.heading.subTitle" | "ui.toolbar.heading.tooltip" | "ui.shortcut-panel.title" | "ui.shortcut.copy" | "ui.shortcut.cut" | "ui.shortcut.paste" | "ui.shortcut.shortcut-panel" | "ui.shortcut.undo" | "ui.shortcut.redo" | "ui.navigation.next" | "ui.navigation.back" | "ui.navigation.previous" | "ui.sidebar.close" | "ui.sidebar.resize" | "ui.sidebar.panel" | "ui.beforeClose.title" | "ui.textEditor.formulaError" | "ui.textEditor.rangeError" | "ui.rangeSelector.title" | "ui.rangeSelector.cancel" | "ui.rangeSelector.addAnotherRange" | "ui.rangeSelector.buttonTooltip" | "ui.rangeSelector.placeHolder" | "ui.rangeSelector.confirm" | "ui.zoom-slider.resetTo";
30
+ titleKey: "ui.column" | "ui.row" | "ui.common-edit" | "ui.toggle-shortcut-panel" | "ui.global-shortcut" | "ui.fontFamily.not-supported" | "ui.fontFamily.arial" | "ui.fontFamily.times-new-roman" | "ui.fontFamily.tahoma" | "ui.fontFamily.verdana" | "ui.fontFamily.microsoft-yahei" | "ui.fontFamily.simsun" | "ui.fontFamily.simhei" | "ui.fontFamily.kaiti" | "ui.fontFamily.fangsong" | "ui.fontFamily.nsimsun" | "ui.fontFamily.stxinwei" | "ui.fontFamily.stxingkai" | "ui.fontFamily.stliti" | "ui.ribbon.start" | "ui.ribbon.view" | "ui.ribbon.insert" | "ui.ribbon.data" | "ui.ribbon.startDesc" | "ui.ribbon.insertDesc" | "ui.ribbon.formulas" | "ui.ribbon.formulasDesc" | "ui.ribbon.dataDesc" | "ui.ribbon.viewDesc" | "ui.ribbon.others" | "ui.ribbon.othersDesc" | "ui.ribbon.more" | "ui.clipboard.authentication.title" | "ui.clipboard.authentication.content" | "ui.featureSearch.title" | "ui.featureSearch.empty" | "ui.featureSearch.placeholder" | "ui.featureSearch.ribbon" | "ui.featureSearch.contextMenu" | "ui.emojiPicker.search" | "ui.emojiPicker.objects" | "ui.emojiPicker.random" | "ui.emojiPicker.recents" | "ui.emojiPicker.emojis" | "ui.emojiPicker.animals" | "ui.emojiPicker.food" | "ui.emojiPicker.activities" | "ui.emojiPicker.places" | "ui.emojiPicker.symbols" | "ui.emojiPicker.searchResults" | "ui.emojiPicker.noResults" | `ui.emojiPicker.emojiSearchIndex.${string}` | `ui.emojiPicker.emojiTitles.${string}` | "ui.symbolPicker.mathematics" | "ui.symbolPicker.greek" | "ui.symbolPicker.common" | "ui.toolbar.heading.title" | "ui.toolbar.heading.normal" | "ui.toolbar.heading.subTitle" | "ui.toolbar.heading.tooltip" | "ui.shortcut-panel.title" | "ui.shortcut.copy" | "ui.shortcut.cut" | "ui.shortcut.paste" | "ui.shortcut.shortcut-panel" | "ui.shortcut.undo" | "ui.shortcut.redo" | "ui.navigation.next" | "ui.navigation.back" | "ui.navigation.previous" | "ui.sidebar.close" | "ui.sidebar.resize" | "ui.sidebar.panel" | "ui.beforeClose.title" | "ui.textEditor.formulaError" | "ui.textEditor.rangeError" | "ui.rangeSelector.title" | "ui.rangeSelector.cancel" | "ui.rangeSelector.addAnotherRange" | "ui.rangeSelector.buttonTooltip" | "ui.rangeSelector.placeHolder" | "ui.rangeSelector.confirm" | "ui.zoom-slider.resetTo";
31
31
  }[];
32
32
  export declare function getDefaultRecentEmojis(): IEmojiItem[];
33
33
  export declare function getAllEmojis(): IEmojiItem[];
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(require("@univerjs/core/facade"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("@univerjs/core")):typeof define==`function`&&define.amd?define([`@univerjs/core/facade`,`@univerjs/engine-render`,`@univerjs/ui`,`@univerjs/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade,e.UniverEngineRender,e.UniverUi,e.UniverCore))})(this,function(e,t,n,r){function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){return function(n,r){t(n,r,e)}}function l(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var u=class extends e.FBase{appendTo(e){let t=typeof e==`string`?e.split(`|`):e,n=t.length,r={},i=r,a=this.__getSchema();t.forEach((e,t)=>{t===n-1?i[e]=a:i[e]={},i=i[e]}),this._menuManagerService.mergeMenu(r)}};let d=class extends u{constructor(e,t,i,a){super(),this._item=e,this._injector=t,this._commandService=i,this._menuManagerService=a,s(this,`_commandToRegister`,new Map),s(this,`_buildingSchema`,void 0);let o=typeof e.action==`string`?e.action:(0,r.generateRandomId)(12);o!==e.action&&this._commandToRegister.set(o,e.action),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:n.MenuItemType.BUTTON,icon:e.icon,title:e.title,tooltip:e.tooltip,commandId:o})},e.order!==void 0&&(this._buildingSchema.order=e.order)}__getSchema(){return this._commandToRegister.forEach((e,t)=>{this._commandService.hasCommand(t)||this._commandService.registerCommand({id:t,type:r.CommandType.COMMAND,handler:e})}),{[this._item.id]:this._buildingSchema}}};s(d,`RibbonStartGroup`,n.RibbonStartGroup),s(d,`RibbonPosition`,n.RibbonPosition),s(d,`MenuManagerPosition`,n.MenuManagerPosition),d=l([c(1,(0,r.Inject)(r.Injector)),c(2,r.ICommandService),c(3,n.IMenuManagerService)],d);let f=class extends u{constructor(e,t,r){super(),this._item=e,this._injector=t,this._menuManagerService=r,s(this,`_menuByGroups`,[]),s(this,`_submenus`,[]),s(this,`_buildingSchema`,void 0),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:n.MenuItemType.SUBITEMS,icon:e.icon,title:e.title,tooltip:e.tooltip})},e.order!==void 0&&(this._buildingSchema.order=e.order)}addSubmenu(e){return this._submenus.push(e),this}addSeparator(){return this._menuByGroups.push(this._submenus),this._submenus=[],this}__getSchema(){let e={};return this.addSeparator(),this._menuByGroups.forEach((t,n)=>{let r={};t.forEach(e=>{Object.assign(r,e.__getSchema())}),e[`${this._item.id}-group-${n}`]=r}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};f=l([c(1,(0,r.Inject)(r.Injector)),c(2,n.IMenuManagerService)],f);let p=class extends e.FBase{constructor(e,t,n,r){super(),this._injector=e,this._renderManagerService=t,this._univerInstanceService=n,this._shortcutService=r,s(this,`_forceDisableDisposable`,null)}enableShortcut(){var e;return(e=this._forceDisableDisposable)==null||e.dispose(),this._forceDisableDisposable=null,this}disableShortcut(){return this._forceDisableDisposable||(this._forceDisableDisposable=this._shortcutService.forceDisable()),this}triggerShortcut(e){let t=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET);if(!t)return;let n=this._renderManagerService.getRenderById(t.getUnitId());if(n)return n.engine.getCanvasElement().dispatchEvent(e),this._shortcutService.dispatch(e)}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};p=l([c(0,(0,r.Inject)(r.Injector)),c(1,(0,r.Inject)(t.IRenderManagerService)),c(2,r.IUniverInstanceService),c(3,n.IShortcutService)],p);var m=class extends e.FUniver{getURL(){return new URL(window.location.href)}getShortcut(){return this._injector.createInstance(p)}copy(){return this._commandService.executeCommand(n.CopyCommand.id)}paste(){return this._commandService.executeCommand(n.PasteCommand.id)}createMenu(e){return this._injector.createInstance(d,e)}createSubmenu(e){return this._injector.createInstance(f,e)}openSiderbar(e){return this._injector.get(n.ISidebarService).open(e)}openSidebar(e){return this.openSiderbar(e)}openDialog(e){let t=this._injector.get(n.IDialogService).open({...e,onClose:()=>{t.dispose()}});return t}getComponentManager(){return this._injector.get(n.ComponentManager)}showMessage(e){return this._injector.get(n.IMessageService).show(e),this}setUIVisible(e,t){return this._injector.get(n.IUIPartsService).setUIVisible(e,t),this}isUIVisible(e){return this._injector.get(n.IUIPartsService).isUIVisible(e)}registerUIPart(e,t){return this._injector.get(n.IUIPartsService).registerComponent(e,()=>(0,n.connectInjector)(t,this._injector))}registerComponent(e,t,r){let i=this._injector.get(n.ComponentManager);return this.disposeWithMe(i.register(e,t,r))}setCurrent(e){if(!this._injector.get(t.IRenderManagerService).getRenderById(e))throw Error(`Unit not found`);this._univerInstanceService.setCurrentUnitForType(e)}addFonts(e){let t=this._injector.get(n.IFontService);e.forEach(e=>{t.addFont(e)})}};e.FUniver.extend(m);var h=class extends e.FHooks{onBeforeCopy(e){return this._injector.get(r.ICommandService).beforeCommandExecuted(t=>{t.id===n.CopyCommand.id&&e()})}onCopy(e){return this._injector.get(r.ICommandService).onCommandExecuted(t=>{t.id===n.CopyCommand.id&&e()})}onBeforePaste(e){return this._injector.get(r.ICommandService).beforeCommandExecuted(t=>{t.id===n.PasteCommand.id&&e()})}onPaste(e){return this._injector.get(r.ICommandService).onCommandExecuted(t=>{(t.id===n.PasteCommand.id||t.id===n.SheetPasteShortKeyCommandName)&&e()})}};e.FHooks.extend(h);var g=class extends e.FEnum{get BuiltInUIPart(){return n.BuiltInUIPart}get KeyCode(){return n.KeyCode}};e.FEnum.extend(g)});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(require("@univerjs/core/facade"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("@univerjs/core")):typeof define==`function`&&define.amd?define([`@univerjs/core/facade`,`@univerjs/engine-render`,`@univerjs/ui`,`@univerjs/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade,e.UniverEngineRender,e.UniverUi,e.UniverCore))})(this,function(e,t,n,r){function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){return function(n,r){t(n,r,e)}}function l(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var u=class extends e.FBase{appendTo(e){let t=typeof e==`string`?e.split(`|`):e,n=t.length,r={},i=r,a=this.__getSchema();t.forEach((e,t)=>{t===n-1?i[e]=a:i[e]={},i=i[e]}),this._menuManagerService.mergeMenu(r)}};let d=class extends u{constructor(e,t,i,a){super(),this._item=e,this._injector=t,this._commandService=i,this._menuManagerService=a,s(this,`_commandToRegister`,new Map),s(this,`_buildingSchema`,void 0);let o=typeof e.action==`string`?e.action:(0,r.generateRandomId)(12);o!==e.action&&this._commandToRegister.set(o,e.action),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:n.MenuItemType.BUTTON,icon:e.icon,title:e.title,tooltip:e.tooltip,commandId:o})},e.order!==void 0&&(this._buildingSchema.order=e.order)}__getSchema(){return this._commandToRegister.forEach((e,t)=>{this._commandService.hasCommand(t)||this._commandService.registerCommand({id:t,type:r.CommandType.COMMAND,handler:e})}),{[this._item.id]:this._buildingSchema}}};s(d,`RibbonStartGroup`,n.RibbonStartGroup),s(d,`RibbonPosition`,n.RibbonPosition),s(d,`MenuManagerPosition`,n.MenuManagerPosition),d=l([c(1,(0,r.Inject)(r.Injector)),c(2,r.ICommandService),c(3,n.IMenuManagerService)],d);let f=class extends u{constructor(e,t,r){super(),this._item=e,this._injector=t,this._menuManagerService=r,s(this,`_menuByGroups`,[]),s(this,`_submenus`,[]),s(this,`_buildingSchema`,void 0),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:n.MenuItemType.SUBITEMS,icon:e.icon,title:e.title,tooltip:e.tooltip})},e.order!==void 0&&(this._buildingSchema.order=e.order)}addSubmenu(e){return this._submenus.push(e),this}addSeparator(){return this._menuByGroups.push(this._submenus),this._submenus=[],this}__getSchema(){let e={};return this.addSeparator(),this._menuByGroups.forEach((t,n)=>{let r={};t.forEach(e=>{Object.assign(r,e.__getSchema())}),e[`${this._item.id}-group-${n}`]=r}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};f=l([c(1,(0,r.Inject)(r.Injector)),c(2,n.IMenuManagerService)],f);let p=class extends e.FBase{constructor(e,t,n,r){super(),this._injector=e,this._renderManagerService=t,this._univerInstanceService=n,this._shortcutService=r,s(this,`_forceDisableDisposable`,null)}enableShortcut(){var e;return(e=this._forceDisableDisposable)==null||e.dispose(),this._forceDisableDisposable=null,this}disableShortcut(){return this._forceDisableDisposable||=this._shortcutService.forceDisable(),this}triggerShortcut(e){let t=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET);if(!t)return;let n=this._renderManagerService.getRenderUnitById(t.getUnitId());if(n)return n.engine.getCanvasElement().dispatchEvent(e),this._shortcutService.dispatch(e)}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};p=l([c(0,(0,r.Inject)(r.Injector)),c(1,(0,r.Inject)(t.IRenderManagerService)),c(2,r.IUniverInstanceService),c(3,n.IShortcutService)],p);var m=class extends e.FUniver{getURL(){return new URL(window.location.href)}getShortcut(){return this._injector.createInstance(p)}copy(){return this._commandService.executeCommand(n.CopyCommand.id)}paste(){return this._commandService.executeCommand(n.PasteCommand.id)}createMenu(e){return this._injector.createInstance(d,e)}createSubmenu(e){return this._injector.createInstance(f,e)}openSidebar(e){return this._injector.get(n.ISidebarService).open(e)}openDialog(e){let t=this._injector.get(n.IDialogService).open({...e,onClose:()=>{t.dispose()}});return t}getComponentManager(){return this._injector.get(n.ComponentManager)}showMessage(e){return this._injector.get(n.IMessageService).show(e),this}setUIVisible(e,t){return this._injector.get(n.IUIPartsService).setUIVisible(e,t),this}isUIVisible(e){return this._injector.get(n.IUIPartsService).isUIVisible(e)}registerUIPart(e,t){return this._injector.get(n.IUIPartsService).registerComponent(e,()=>(0,n.connectInjector)(t,this._injector))}registerComponent(e,t,r){let i=this._injector.get(n.ComponentManager);return this.disposeWithMe(i.register(e,t,r))}setCurrent(e){if(!this._injector.get(t.IRenderManagerService).getRenderUnitById(e))throw Error(`Unit not found`);this._univerInstanceService.setCurrentUnitForType(e)}addFonts(e){let t=this._injector.get(n.IFontService);e.forEach(e=>{t.addFont(e)})}};e.FUniver.extend(m);var h=class extends e.FEnum{get BuiltInUIPart(){return n.BuiltInUIPart}get KeyCode(){return n.KeyCode}};e.FEnum.extend(h)});