@univerjs/ui 0.9.2 → 0.9.3

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.
package/lib/cjs/facade.js CHANGED
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var M=(i,e,t)=>e in i?f(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var a=(i,e,t)=>M(i,typeof e!="symbol"?e+"":e,t);const u=require("@univerjs/core/facade"),_=require("@univerjs/engine-render"),n=require("@univerjs/ui"),c=require("@univerjs/core");var j=Object.getOwnPropertyDescriptor,I=(i,e,t,r)=>{for(var s=r>1?void 0:r?j(e,t):e,o=i.length-1,d;o>=0;o--)(d=i[o])&&(s=d(s)||s);return s},m=(i,e)=>(t,r)=>e(t,r,i);class b extends u.FBase{appendTo(e){const t=typeof e=="string"?e.split("|"):e,r=t.length,s={};let o=s;const d=this.__getSchema();t.forEach((g,C)=>{C===r-1?o[g]=d:o[g]={},o=o[g]}),this._menuManagerService.mergeMenu(s)}}var h;let v=(h=class extends b{constructor(e,t,r,s){super();a(this,"_commandToRegister",new Map);a(this,"_buildingSchema");this._item=e,this._injector=t,this._commandService=r,this._menuManagerService=s;const o=typeof e.action=="string"?e.action:c.Tools.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})},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:c.CommandType.COMMAND,handler:e})}),{[this._item.id]:this._buildingSchema}}},a(h,"RibbonStartGroup",n.RibbonStartGroup),a(h,"RibbonPosition",n.RibbonPosition),a(h,"MenuManagerPosition",n.MenuManagerPosition),h);v=I([m(1,c.Inject(c.Injector)),m(2,c.ICommandService),m(3,n.IMenuManagerService)],v);let l=class extends b{constructor(e,t,r){super();a(this,"_menuByGroups",[]);a(this,"_submenus",[]);a(this,"_buildingSchema");this._item=e,this._injector=t,this._menuManagerService=r,this._buildingSchema={menuItemFactory:()=>({id:e.id,type:n.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,r)=>{const s={};t.forEach(o=>{Object.assign(s,o.__getSchema())}),e[`${this._item.id}-group-${r}`]=s}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};l=I([m(1,c.Inject(c.Injector)),m(2,n.IMenuManagerService)],l);var y=Object.getOwnPropertyDescriptor,U=(i,e,t,r)=>{for(var s=r>1?void 0:r?y(e,t):e,o=i.length-1,d;o>=0;o--)(d=i[o])&&(s=d(s)||s);return s},S=(i,e)=>(t,r)=>e(t,r,i);let p=class extends u.FBase{constructor(e,t,r,s){super();a(this,"_forceDisableDisposable",null);this._injector=e,this._renderManagerService=t,this._univerInstanceService=r,this._shortcutService=s}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){const t=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=this._renderManagerService.getRenderById(t.getUnitId());return r?(r.engine.getCanvasElement().dispatchEvent(e),this._shortcutService.dispatch(e)):void 0}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};p=U([S(0,c.Inject(c.Injector)),S(1,c.Inject(_.IRenderManagerService)),S(2,c.IUniverInstanceService),S(3,n.IShortcutService)],p);class P extends u.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(v,e)}createSubmenu(e){return this._injector.createInstance(l,e)}openSiderbar(e){return this._injector.get(n.ISidebarService).open(e)}openSidebar(e){return this.openSiderbar(e)}openDialog(e){const r=this._injector.get(n.IDialogService).open({...e,onClose:()=>{r.dispose()}});return r}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,()=>n.connectInjector(t,this._injector))}registerComponent(e,t,r){const s=this._injector.get(n.ComponentManager);return this.disposeWithMe(s.register(e,t,r))}setCurrent(e){if(!this._injector.get(_.IRenderManagerService).getRenderById(e))throw new Error("Unit not found");this._univerInstanceService.setCurrentUnitForType(e)}}u.FUniver.extend(P);class E extends u.FHooks{onBeforeCopy(e){return this._injector.get(c.ICommandService).beforeCommandExecuted(r=>{r.id===n.CopyCommand.id&&e()})}onCopy(e){return this._injector.get(c.ICommandService).onCommandExecuted(r=>{r.id===n.CopyCommand.id&&e()})}onBeforePaste(e){return this._injector.get(c.ICommandService).beforeCommandExecuted(r=>{r.id===n.PasteCommand.id&&e()})}onPaste(e){return this._injector.get(c.ICommandService).onCommandExecuted(r=>{(r.id===n.PasteCommand.id||r.id===n.SheetPasteShortKeyCommandName)&&e()})}}u.FHooks.extend(E);class F extends u.FEnum{get BuiltInUIPart(){return n.BuiltInUIPart}get KeyCode(){return n.KeyCode}}u.FEnum.extend(F);
1
+ "use strict";var f=Object.defineProperty;var M=(i,e,t)=>e in i?f(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var a=(i,e,t)=>M(i,typeof e!="symbol"?e+"":e,t);const u=require("@univerjs/core/facade"),l=require("@univerjs/engine-render"),n=require("@univerjs/ui"),c=require("@univerjs/core");var j=Object.getOwnPropertyDescriptor,I=(i,e,t,r)=>{for(var s=r>1?void 0:r?j(e,t):e,o=i.length-1,d;o>=0;o--)(d=i[o])&&(s=d(s)||s);return s},m=(i,e)=>(t,r)=>e(t,r,i);class b extends u.FBase{appendTo(e){const t=typeof e=="string"?e.split("|"):e,r=t.length,s={};let o=s;const d=this.__getSchema();t.forEach((g,C)=>{C===r-1?o[g]=d:o[g]={},o=o[g]}),this._menuManagerService.mergeMenu(s)}}var h;let v=(h=class extends b{constructor(e,t,r,s){super();a(this,"_commandToRegister",new Map);a(this,"_buildingSchema");this._item=e,this._injector=t,this._commandService=r,this._menuManagerService=s;const o=typeof e.action=="string"?e.action:c.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})},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:c.CommandType.COMMAND,handler:e})}),{[this._item.id]:this._buildingSchema}}},a(h,"RibbonStartGroup",n.RibbonStartGroup),a(h,"RibbonPosition",n.RibbonPosition),a(h,"MenuManagerPosition",n.MenuManagerPosition),h);v=I([m(1,c.Inject(c.Injector)),m(2,c.ICommandService),m(3,n.IMenuManagerService)],v);let p=class extends b{constructor(e,t,r){super();a(this,"_menuByGroups",[]);a(this,"_submenus",[]);a(this,"_buildingSchema");this._item=e,this._injector=t,this._menuManagerService=r,this._buildingSchema={menuItemFactory:()=>({id:e.id,type:n.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,r)=>{const s={};t.forEach(o=>{Object.assign(s,o.__getSchema())}),e[`${this._item.id}-group-${r}`]=s}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};p=I([m(1,c.Inject(c.Injector)),m(2,n.IMenuManagerService)],p);var y=Object.getOwnPropertyDescriptor,U=(i,e,t,r)=>{for(var s=r>1?void 0:r?y(e,t):e,o=i.length-1,d;o>=0;o--)(d=i[o])&&(s=d(s)||s);return s},S=(i,e)=>(t,r)=>e(t,r,i);let _=class extends u.FBase{constructor(e,t,r,s){super();a(this,"_forceDisableDisposable",null);this._injector=e,this._renderManagerService=t,this._univerInstanceService=r,this._shortcutService=s}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){const t=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=this._renderManagerService.getRenderById(t.getUnitId());return r?(r.engine.getCanvasElement().dispatchEvent(e),this._shortcutService.dispatch(e)):void 0}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};_=U([S(0,c.Inject(c.Injector)),S(1,c.Inject(l.IRenderManagerService)),S(2,c.IUniverInstanceService),S(3,n.IShortcutService)],_);class P extends u.FUniver{getURL(){return new URL(window.location.href)}getShortcut(){return this._injector.createInstance(_)}copy(){return this._commandService.executeCommand(n.CopyCommand.id)}paste(){return this._commandService.executeCommand(n.PasteCommand.id)}createMenu(e){return this._injector.createInstance(v,e)}createSubmenu(e){return this._injector.createInstance(p,e)}openSiderbar(e){return this._injector.get(n.ISidebarService).open(e)}openSidebar(e){return this.openSiderbar(e)}openDialog(e){const r=this._injector.get(n.IDialogService).open({...e,onClose:()=>{r.dispose()}});return r}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,()=>n.connectInjector(t,this._injector))}registerComponent(e,t,r){const s=this._injector.get(n.ComponentManager);return this.disposeWithMe(s.register(e,t,r))}setCurrent(e){if(!this._injector.get(l.IRenderManagerService).getRenderById(e))throw new Error("Unit not found");this._univerInstanceService.setCurrentUnitForType(e)}}u.FUniver.extend(P);class E extends u.FHooks{onBeforeCopy(e){return this._injector.get(c.ICommandService).beforeCommandExecuted(r=>{r.id===n.CopyCommand.id&&e()})}onCopy(e){return this._injector.get(c.ICommandService).onCommandExecuted(r=>{r.id===n.CopyCommand.id&&e()})}onBeforePaste(e){return this._injector.get(c.ICommandService).beforeCommandExecuted(r=>{r.id===n.PasteCommand.id&&e()})}onPaste(e){return this._injector.get(c.ICommandService).onCommandExecuted(r=>{(r.id===n.PasteCommand.id||r.id===n.SheetPasteShortKeyCommandName)&&e()})}}u.FHooks.extend(E);class F extends u.FEnum{get BuiltInUIPart(){return n.BuiltInUIPart}get KeyCode(){return n.KeyCode}}u.FEnum.extend(F);