@univerjs/ui 0.6.0 → 0.6.1

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.
@@ -8,16 +8,27 @@ import { FBase } from '@univerjs/core/facade';
8
8
  export declare class FShortcut extends FBase {
9
9
  protected readonly _injector: Injector;
10
10
  protected readonly _shortcutService: IShortcutService;
11
- private _forceEscapeDisposable;
11
+ private _forceDisableDisposable;
12
12
  constructor(_injector: Injector, _shortcutService: IShortcutService);
13
13
  /**
14
14
  * Enable shortcuts of Univer.
15
15
  * @returns {FShortcut} The Facade API instance itself for chaining.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * fShortcut.enableShortcut(); // Use the FShortcut instance used by disableShortcut before, do not create a new instance
20
+ * ```
16
21
  */
17
22
  enableShortcut(): this;
18
23
  /**
19
24
  * Disable shortcuts of Univer.
20
25
  * @returns {FShortcut} The Facade API instance itself for chaining.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const fShortcut = univerAPI.getShortcut();
30
+ * fShortcut.disableShortcut();
31
+ * ```
21
32
  */
22
33
  disableShortcut(): this;
23
34
  /**
@@ -70,6 +70,11 @@ export interface IShortcutService {
70
70
  * @returns {IDisposable} a disposable that could be used to cancel the force escaping.
71
71
  */
72
72
  forceEscape(): IDisposable;
73
+ /**
74
+ * Used by API to force disable all shortcut keys, which will not be restored by selection
75
+ * @returns {IDisposable} a disposable that could be used to cancel the force disabling.
76
+ */
77
+ forceDisable(): IDisposable;
73
78
  /**
74
79
  * Dispatch a keyboard event to the shortcut service and check if there is a shortcut that matches the event.
75
80
  * @param e - the keyboard event to be dispatched.
@@ -112,6 +117,7 @@ export declare class ShortcutService extends Disposable implements IShortcutServ
112
117
  private readonly _shortcutChanged$;
113
118
  readonly shortcutChanged$: Observable<void>;
114
119
  private _forceEscaped;
120
+ private _forceDisabled;
115
121
  constructor(_commandService: ICommandService, _platformService: IPlatformService, _contextService: IContextService, _layoutService?: ILayoutService | undefined);
116
122
  getAllShortcuts(): IShortcutItem[];
117
123
  registerShortcut(shortcut: IShortcutItem): IDisposable;
@@ -119,6 +125,7 @@ export declare class ShortcutService extends Disposable implements IShortcutServ
119
125
  getShortcutDisplay(shortcut: IShortcutItem): string;
120
126
  private _emitShortcutChanged;
121
127
  forceEscape(): IDisposable;
128
+ forceDisable(): IDisposable;
122
129
  private _resolveKeyboardEvent;
123
130
  dispatch(e: KeyboardEvent): IShortcutItem<object> | undefined;
124
131
  private _getBindingFromItem;
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(i,a){typeof exports=="object"&&typeof module<"u"?a(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"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i.UniverCoreFacade,i.UniverEngineRender,i.UniverUi,i.UniverCore))})(this,function(i,a,r,d){"use strict";var E=Object.defineProperty;var x=(i,a,r)=>a in i?E(i,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[a]=r;var u=(i,a,r)=>x(i,typeof a!="symbol"?a+"":a,r);var S;var f=Object.getOwnPropertyDescriptor,l=(c,e,t,n)=>{for(var s=n>1?void 0:n?f(e,t):e,o=c.length-1,m;o>=0;o--)(m=c[o])&&(s=m(s)||s);return s},h=(c,e)=>(t,n)=>e(t,n,c);class I extends i.FBase{appendTo(e){const t=typeof e=="string"?e.split("|"):e,n=t.length,s={};let o=s;const m=this.__getSchema();t.forEach((_,U)=>{U===n-1?o[_]=m:o[_]={},o=o[_]}),this._menuManagerService.mergeMenu(s)}}let v=(S=class extends I{constructor(e,t,n,s){super();u(this,"_commandToRegister",new Map);u(this,"_buildingSchema");this._item=e,this._injector=t,this._commandService=n,this._menuManagerService=s;const o=typeof e.action=="string"?e.action:d.Tools.generateRandomId(12);o!==e.action&&this._commandToRegister.set(o,e.action),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:r.MenuItemType.BUTTON,icon:e.icon,title:e.title,tooltip:e.tooltip,commandId:o})},typeof e.order<"u"&&(this._buildingSchema.order=e.order)}__getSchema(){return this._commandToRegister.forEach((e,t)=>{this._commandService.hasCommand(t)||this._commandService.registerCommand({id:t,type:d.CommandType.COMMAND,handler:e})}),{[this._item.id]:this._buildingSchema}}},u(S,"RibbonStartGroup",r.RibbonStartGroup),u(S,"RibbonPosition",r.RibbonPosition),u(S,"MenuManagerPosition",r.MenuManagerPosition),S);v=l([h(1,d.Inject(d.Injector)),h(2,d.ICommandService),h(3,r.IMenuManagerService)],v);let p=class extends I{constructor(e,t,n){super();u(this,"_menuByGroups",[]);u(this,"_submenus",[]);u(this,"_buildingSchema");this._item=e,this._injector=t,this._menuManagerService=n,this._buildingSchema={menuItemFactory:()=>({id:e.id,type:r.MenuItemType.SUBITEMS,icon:e.icon,title:e.title,tooltip:e.tooltip})},typeof e.order<"u"&&(this._buildingSchema.order=e.order)}addSubmenu(e){return this._submenus.push(e),this}addSeparator(){return this._menuByGroups.push(this._submenus),this._submenus=[],this}__getSchema(){const e={};return this.addSeparator(),this._menuByGroups.forEach((t,n)=>{const s={};t.forEach(o=>{Object.assign(s,o.__getSchema())}),e[`${this._item.id}-group-${n}`]=s}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};p=l([h(1,d.Inject(d.Injector)),h(2,r.IMenuManagerService)],p);var j=Object.getOwnPropertyDescriptor,C=(c,e,t,n)=>{for(var s=n>1?void 0:n?j(e,t):e,o=c.length-1,m;o>=0;o--)(m=c[o])&&(s=m(s)||s);return s},b=(c,e)=>(t,n)=>e(t,n,c);let g=class extends i.FBase{constructor(e,t){super();u(this,"_forceEscapeDisposable",null);this._injector=e,this._shortcutService=t}enableShortcut(){var e;return(e=this._forceEscapeDisposable)==null||e.dispose(),this._forceEscapeDisposable=null,this}disableShortcut(){return this._forceEscapeDisposable||(this._forceEscapeDisposable=this._shortcutService.forceEscape()),this}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};g=C([b(0,d.Inject(d.Injector)),b(1,r.IShortcutService)],g);class M extends i.FUniver{getURL(){return new URL(window.location.href)}getShortcut(){return this._injector.createInstance(g)}copy(){return this._commandService.syncExecuteCommand(r.CopyCommand.id)}paste(){return this._commandService.syncExecuteCommand(r.PasteCommand.id)}createMenu(e){return this._injector.createInstance(v,e)}createSubmenu(e){return this._injector.createInstance(p,e)}openSiderbar(e){return this._injector.get(r.ISidebarService).open(e)}openSidebar(e){return this.openSiderbar(e)}openDialog(e){const n=this._injector.get(r.IDialogService).open({...e,onClose:()=>{n.dispose()}});return n}getComponentManager(){return this._injector.get(r.ComponentManager)}showMessage(e){return this._injector.get(r.IMessageService).show(e),this}setUIVisible(e,t){return this._injector.get(r.IUIPartsService).setUIVisible(e,t),this}isUIVisible(e){return this._injector.get(r.IUIPartsService).isUIVisible(e)}registerUIPart(e,t){return this._injector.get(r.IUIPartsService).registerComponent(e,()=>r.connectInjector(t,this._injector))}registerComponent(e,t,n){const s=this._injector.get(r.ComponentManager);return this.disposeWithMe(s.register(e,t,n))}setCurrent(e){if(!this._injector.get(a.IRenderManagerService).getRenderById(e))throw new Error("Unit not found");this._univerInstanceService.setCurrentUnitForType(e)}}i.FUniver.extend(M);class y extends i.FHooks{onBeforeCopy(e){return this._injector.get(d.ICommandService).beforeCommandExecuted(n=>{n.id===r.CopyCommand.id&&e()})}onCopy(e){return this._injector.get(d.ICommandService).onCommandExecuted(n=>{n.id===r.CopyCommand.id&&e()})}onBeforePaste(e){return this._injector.get(d.ICommandService).beforeCommandExecuted(n=>{n.id===r.PasteCommand.id&&e()})}onPaste(e){return this._injector.get(d.ICommandService).onCommandExecuted(n=>{(n.id===r.PasteCommand.id||n.id===r.SheetPasteShortKeyCommandName)&&e()})}}i.FHooks.extend(y);class P extends i.FEnum{get BuiltInUIPart(){return r.BuiltInUIPart}}i.FEnum.extend(P)});
1
+ (function(i,a){typeof exports=="object"&&typeof module<"u"?a(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"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i.UniverCoreFacade,i.UniverEngineRender,i.UniverUi,i.UniverCore))})(this,function(i,a,r,d){"use strict";var x=Object.defineProperty;var F=(i,a,r)=>a in i?x(i,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[a]=r;var u=(i,a,r)=>F(i,typeof a!="symbol"?a+"":a,r);var S;var f=Object.getOwnPropertyDescriptor,_=(c,e,t,n)=>{for(var s=n>1?void 0:n?f(e,t):e,o=c.length-1,m;o>=0;o--)(m=c[o])&&(s=m(s)||s);return s},h=(c,e)=>(t,n)=>e(t,n,c);class b extends i.FBase{appendTo(e){const t=typeof e=="string"?e.split("|"):e,n=t.length,s={};let o=s;const m=this.__getSchema();t.forEach((l,U)=>{U===n-1?o[l]=m:o[l]={},o=o[l]}),this._menuManagerService.mergeMenu(s)}}let v=(S=class extends b{constructor(e,t,n,s){super();u(this,"_commandToRegister",new Map);u(this,"_buildingSchema");this._item=e,this._injector=t,this._commandService=n,this._menuManagerService=s;const o=typeof e.action=="string"?e.action:d.Tools.generateRandomId(12);o!==e.action&&this._commandToRegister.set(o,e.action),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:r.MenuItemType.BUTTON,icon:e.icon,title:e.title,tooltip:e.tooltip,commandId:o})},typeof e.order<"u"&&(this._buildingSchema.order=e.order)}__getSchema(){return this._commandToRegister.forEach((e,t)=>{this._commandService.hasCommand(t)||this._commandService.registerCommand({id:t,type:d.CommandType.COMMAND,handler:e})}),{[this._item.id]:this._buildingSchema}}},u(S,"RibbonStartGroup",r.RibbonStartGroup),u(S,"RibbonPosition",r.RibbonPosition),u(S,"MenuManagerPosition",r.MenuManagerPosition),S);v=_([h(1,d.Inject(d.Injector)),h(2,d.ICommandService),h(3,r.IMenuManagerService)],v);let g=class extends b{constructor(e,t,n){super();u(this,"_menuByGroups",[]);u(this,"_submenus",[]);u(this,"_buildingSchema");this._item=e,this._injector=t,this._menuManagerService=n,this._buildingSchema={menuItemFactory:()=>({id:e.id,type:r.MenuItemType.SUBITEMS,icon:e.icon,title:e.title,tooltip:e.tooltip})},typeof e.order<"u"&&(this._buildingSchema.order=e.order)}addSubmenu(e){return this._submenus.push(e),this}addSeparator(){return this._menuByGroups.push(this._submenus),this._submenus=[],this}__getSchema(){const e={};return this.addSeparator(),this._menuByGroups.forEach((t,n)=>{const s={};t.forEach(o=>{Object.assign(s,o.__getSchema())}),e[`${this._item.id}-group-${n}`]=s}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};g=_([h(1,d.Inject(d.Injector)),h(2,r.IMenuManagerService)],g);var j=Object.getOwnPropertyDescriptor,C=(c,e,t,n)=>{for(var s=n>1?void 0:n?j(e,t):e,o=c.length-1,m;o>=0;o--)(m=c[o])&&(s=m(s)||s);return s},I=(c,e)=>(t,n)=>e(t,n,c);let p=class extends i.FBase{constructor(e,t){super();u(this,"_forceDisableDisposable",null);this._injector=e,this._shortcutService=t}enableShortcut(){var e;return(e=this._forceDisableDisposable)==null||e.dispose(),this._forceDisableDisposable=null,this}disableShortcut(){return this._forceDisableDisposable||(this._forceDisableDisposable=this._shortcutService.forceDisable()),this}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};p=C([I(0,d.Inject(d.Injector)),I(1,r.IShortcutService)],p);class M extends i.FUniver{getURL(){return new URL(window.location.href)}getShortcut(){return this._injector.createInstance(p)}copy(){return this._commandService.syncExecuteCommand(r.CopyCommand.id)}paste(){return this._commandService.syncExecuteCommand(r.PasteCommand.id)}createMenu(e){return this._injector.createInstance(v,e)}createSubmenu(e){return this._injector.createInstance(g,e)}openSiderbar(e){return this._injector.get(r.ISidebarService).open(e)}openSidebar(e){return this.openSiderbar(e)}openDialog(e){const n=this._injector.get(r.IDialogService).open({...e,onClose:()=>{n.dispose()}});return n}getComponentManager(){return this._injector.get(r.ComponentManager)}showMessage(e){return this._injector.get(r.IMessageService).show(e),this}setUIVisible(e,t){return this._injector.get(r.IUIPartsService).setUIVisible(e,t),this}isUIVisible(e){return this._injector.get(r.IUIPartsService).isUIVisible(e)}registerUIPart(e,t){return this._injector.get(r.IUIPartsService).registerComponent(e,()=>r.connectInjector(t,this._injector))}registerComponent(e,t,n){const s=this._injector.get(r.ComponentManager);return this.disposeWithMe(s.register(e,t,n))}setCurrent(e){if(!this._injector.get(a.IRenderManagerService).getRenderById(e))throw new Error("Unit not found");this._univerInstanceService.setCurrentUnitForType(e)}}i.FUniver.extend(M);class y extends i.FHooks{onBeforeCopy(e){return this._injector.get(d.ICommandService).beforeCommandExecuted(n=>{n.id===r.CopyCommand.id&&e()})}onCopy(e){return this._injector.get(d.ICommandService).onCommandExecuted(n=>{n.id===r.CopyCommand.id&&e()})}onBeforePaste(e){return this._injector.get(d.ICommandService).beforeCommandExecuted(n=>{n.id===r.PasteCommand.id&&e()})}onPaste(e){return this._injector.get(d.ICommandService).onCommandExecuted(n=>{(n.id===r.PasteCommand.id||n.id===r.SheetPasteShortKeyCommandName)&&e()})}}i.FHooks.extend(y);class P extends i.FEnum{get BuiltInUIPart(){return r.BuiltInUIPart}}i.FEnum.extend(P)});