@univerjs/sheets-zen-editor 0.2.5 → 0.2.7

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var J=Object.defineProperty;var Q=(n,e,i)=>e in n?J(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var C=(n,e,i)=>Q(n,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),R=require("@univerjs/docs"),U=require("@univerjs/engine-render"),z=require("@univerjs/sheets-ui"),_=require("@univerjs/ui"),$=require("rxjs"),D=require("@univerjs/sheets"),g=require("react"),B=require("clsx"),P={id:"zen-editor.operation.open-zen-editor",type:s.CommandType.OPERATION,handler:n=>!0};class ee{constructor(){C(this,"_position",null);C(this,"_position$",new $.BehaviorSubject(null));C(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(e){this._position=e,this._refresh(e)}getPosition(){return this._position}_refresh(e){this._position$.next(e)}}const A=s.createIdentifier("univer.sheet-zen-editor-manager.service");var te=Object.defineProperty,ne=Object.getOwnPropertyDescriptor,ie=(n,e,i,t)=>{for(var r=t>1?void 0:t?ne(e,i):e,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(t?o(e,i,r):o(r))||r);return t&&r&&te(e,i,r),r},p=(n,e)=>(i,t)=>e(i,t,n);let M=class extends s.RxDisposable{constructor(e,i,t,r,c,o,a,d){super();C(this,"_zenEditorInitialState",!1);this._univerInstanceService=e,this._zenEditorManagerService=i,this._renderManagerService=t,this._commandService=r,this._zenZoneService=c,this._editorBridgeService=o,this._undoRedoService=a,this._textSelectionManagerService=d,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const e={id:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${s.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],customBlocks:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:595,height:842},documentFlavor:s.DocumentFlavor.MODERN,marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};return this._univerInstanceService.createUnit(s.UniverInstanceType.UNIVER_DOC,e)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe($.takeUntil(this.dispose$)).subscribe(e=>{var d;if(e==null)return;const i=z.getEditorObject(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService),t=this._univerInstanceService.getUniverDocInstance(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(i==null||t==null)return;const{width:r,height:c}=e,{engine:o}=i,a=(d=this._renderManagerService.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:d.with(R.DocSkeletonManagerService).getSkeleton();requestIdleCallback(()=>{o.resizeBySize(r,c),this._calculatePagePosition(i),a&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){var c;this._zenEditorInitialState||(this._createZenEditorInstance(),this._zenEditorInitialState=!0),this._zenZoneService.open();const e=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);this._undoRedoService.clearUndoRedo(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._univerInstanceService.focusUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._univerInstanceService.setCurrentUnitForType(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:U.DeviceInputEventType.PointerDown,unitId:(c=e==null?void 0:e.getUnitId())!=null?c:""});const t=this._editorBridgeService.getLatestEditCellState();if(t==null)return;this._editorSyncHandler(t);const r=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(r)}_editorSyncHandler(e){var o,a;const i=(o=e.documentLayoutObject.documentModel)==null?void 0:o.getBody(),t=i==null?void 0:i.dataStream,r=i==null?void 0:i.paragraphs;let c=[];t==null||r==null||((a=i==null?void 0:i.textRuns)!=null&&a.length&&(c=i==null?void 0:i.textRuns),this._syncContentAndRender(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,t,r,c))}_syncContentAndRender(e,i,t,r=[],c=[],o={},a=[],d=[]){var S;const h=[s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],l=(S=this._renderManagerService.getRenderById(e))==null?void 0:S.with(R.DocSkeletonManagerService),I=l==null?void 0:l.getSkeleton(),v=this._univerInstanceService.getUniverDocInstance(e),E=l==null?void 0:l.getViewModel();if(v==null||E==null||I==null)return;const u=v.getBody(),N=v.getSnapshot();u.dataStream=i,u.paragraphs=t,u.customBlocks=c,u.customRanges=d,N.drawings=o,N.drawingsOrder=a,e===s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(u.textRuns=[]),r.length>0&&(u.textRuns=r),E.reset(v);const m=this._getDocObject();m!=null&&(I.calculate(),h.includes(e)&&m.document.makeDirty())}_calculatePagePosition(e){const{document:i,scene:t,docBackground:r}=e,c=t==null?void 0:t.getParent(),{width:o,height:a,pageMarginLeft:d,pageMarginTop:h}=i;if(c==null||o===Number.POSITIVE_INFINITY||a===Number.POSITIVE_INFINITY)return;const{width:l,height:I}=c;let v=0,E=0,u=0,N=0,m=Number.POSITIVE_INFINITY;const{scaleX:S,scaleY:X}=t.getAncestorScale();l>(o+d*2)*S?(v=l/2-o*S/2,v/=S,u=(l-d*2)/S,m=0):(v=d,u=o+d*2,m=(u-l/S)/2),I>a?(E=I/2-a/2,N=(I-h*2)/X):(E=h,N=a+h*2),t.resize(u,N+200),i.translate(v,E),r.translate(v,E);const L=t.getViewport(R.VIEWPORT_KEY.VIEW_MAIN);if(m!==Number.POSITIVE_INFINITY&&L!=null){const G=L.transScroll2ViewportScrollValue(m,0).x;L.scrollToBarPos({x:G})}return this}_commandExecutedListener(){const e=[P.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{e.includes(t.id)&&this._handleOpenZenEditor()}));const i=[R.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(i.includes(t.id)){const r=t.params,{unitId:c}=r;if(c===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY){const o=this._univerInstanceService.getUniverDocInstance(c),a=o==null?void 0:o.getBody(),d=a==null?void 0:a.dataStream,h=a==null?void 0:a.paragraphs,l=a==null?void 0:a.textRuns,I=a==null?void 0:a.customBlocks,v=o==null?void 0:o.getDrawings(),E=o==null?void 0:o.getDrawingsOrder(),u=o==null?void 0:o.getCustomRanges();if(this._editorBridgeService.changeEditorDirty(!0),d==null||h==null)return;this._syncContentAndRender(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,d,h,l,I,v,E,u)}}}))}_getDocObject(){return R.getDocObject(this._univerInstanceService,this._renderManagerService)}};M=ie([s.OnLifecycle(s.LifecycleStages.Steady,M),p(0,s.IUniverInstanceService),p(1,A),p(2,U.IRenderManagerService),p(3,s.ICommandService),p(4,_.IZenZoneService),p(5,z.IEditorBridgeService),p(6,s.IUndoRedoService),p(7,s.Inject(R.TextSelectionManagerService))],M);const Z={id:"zen-editor.command.cancel-zen-edit",type:s.CommandType.COMMAND,handler:async n=>{const e=n.get(_.IZenZoneService),i=n.get(z.IEditorBridgeService),t=n.get(s.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:U.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC,unitId:""}),e.close();const c=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);return c?(t.focusUnit(c.getUnitId()),i.refreshEditCellState(),!0):!1}},j={id:"zen-editor.command.confirm-zen-edit",type:s.CommandType.COMMAND,handler:async n=>{const e=n.get(_.IZenZoneService),i=n.get(z.IEditorBridgeService),t=n.get(s.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:U.DeviceInputEventType.PointerDown,unitId:""}),e.close();const c=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);return c?(t.focusUnit(c.getUnitId()),i.refreshEditCellState(),!0):!1}};function re(n){return{id:P.id,group:_.MenuGroup.CONTEXT_MENU_OTHERS,type:_.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[_.MenuPosition.CONTEXT_MENU],disabled$:z.getCurrentRangeDisable$(n,{workbookTypes:[D.WorkbookEditablePermission],worksheetTypes:[D.WorksheetEditPermission,D.WorksheetSetCellValuePermission,D.WorksheetSetCellStylePermission],rangeTypes:[D.RangeProtectionPermissionEditPoint]})}}var Y={exports:{}},w={};/**
1
+ "use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@univerjs/core"),docs=require("@univerjs/docs"),engineRender=require("@univerjs/engine-render"),sheetsUi=require("@univerjs/sheets-ui"),ui=require("@univerjs/ui"),rxjs=require("rxjs"),sheets=require("@univerjs/sheets"),require$$0=require("react"),clsx=require("clsx"),OpenZenEditorOperation={id:"zen-editor.operation.open-zen-editor",type:core.CommandType.OPERATION,handler:__name(accessor=>!0,"handler")},_ZenEditorManagerService=class _ZenEditorManagerService{constructor(){__publicField(this,"_position",null);__publicField(this,"_position$",new rxjs.BehaviorSubject(null));__publicField(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(param){this._position=param,this._refresh(param)}getPosition(){return this._position}_refresh(param){this._position$.next(param)}};__name(_ZenEditorManagerService,"ZenEditorManagerService");let ZenEditorManagerService=_ZenEditorManagerService;const IZenEditorManagerService=core.createIdentifier("univer.sheet-zen-editor-manager.service");var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2"),_a;let ZenEditorController=(_a=class extends core.RxDisposable{constructor(_univerInstanceService,_zenEditorManagerService,_renderManagerService,_commandService,_zenZoneService,_editorBridgeService,_undoRedoService,_textSelectionManagerService){super();__publicField(this,"_zenEditorInitialState",!1);this._univerInstanceService=_univerInstanceService,this._zenEditorManagerService=_zenEditorManagerService,this._renderManagerService=_renderManagerService,this._commandService=_commandService,this._zenZoneService=_zenZoneService,this._editorBridgeService=_editorBridgeService,this._undoRedoService=_undoRedoService,this._textSelectionManagerService=_textSelectionManagerService,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const INITIAL_SNAPSHOT={id:core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${core.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],customBlocks:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:595,height:842},documentFlavor:core.DocumentFlavor.MODERN,marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};return this._univerInstanceService.createUnit(core.UniverInstanceType.UNIVER_DOC,INITIAL_SNAPSHOT)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(rxjs.takeUntil(this.dispose$)).subscribe(position=>{var _a4;if(position==null)return;const editorObject=sheetsUi.getEditorObject(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService),zenEditorDataModel=this._univerInstanceService.getUniverDocInstance(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(editorObject==null||zenEditorDataModel==null)return;const{width,height}=position,{engine}=editorObject,skeleton=(_a4=this._renderManagerService.getRenderById(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:_a4.with(docs.DocSkeletonManagerService).getSkeleton();requestIdleCallback(()=>{engine.resizeBySize(width,height),this._calculatePagePosition(editorObject),skeleton&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){var _a4;this._zenEditorInitialState||(this._createZenEditorInstance(),this._zenEditorInitialState=!0),this._zenZoneService.open();const currentSheet=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);this._undoRedoService.clearUndoRedo(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._univerInstanceService.focusUnit(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._univerInstanceService.setCurrentUnitForType(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:engineRender.DeviceInputEventType.PointerDown,unitId:(_a4=currentSheet==null?void 0:currentSheet.getUnitId())!=null?_a4:""});const editCellState=this._editorBridgeService.getLatestEditCellState();if(editCellState==null)return;this._editorSyncHandler(editCellState);const textRanges=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(textRanges)}_editorSyncHandler(param){var _a4,_b;const body=(_a4=param.documentLayoutObject.documentModel)==null?void 0:_a4.getBody(),dataStream=body==null?void 0:body.dataStream,paragraphs=body==null?void 0:body.paragraphs;let textRuns=[];dataStream==null||paragraphs==null||((_b=body==null?void 0:body.textRuns)!=null&&_b.length&&(textRuns=body==null?void 0:body.textRuns),this._syncContentAndRender(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,dataStream,paragraphs,textRuns))}_syncContentAndRender(unitId,dataStream,paragraphs,textRuns=[],customBlocks=[],drawings={},drawingsOrder=[],customRanges=[]){var _a4;const INCLUDE_LIST=[core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],docSkeletonManagerService=(_a4=this._renderManagerService.getRenderById(unitId))==null?void 0:_a4.with(docs.DocSkeletonManagerService),skeleton=docSkeletonManagerService==null?void 0:docSkeletonManagerService.getSkeleton(),docDataModel=this._univerInstanceService.getUniverDocInstance(unitId),docViewModel=docSkeletonManagerService==null?void 0:docSkeletonManagerService.getViewModel();if(docDataModel==null||docViewModel==null||skeleton==null)return;const docBody=docDataModel.getBody(),snapshot=docDataModel.getSnapshot();docBody.dataStream=dataStream,docBody.paragraphs=paragraphs,docBody.customBlocks=customBlocks,docBody.customRanges=customRanges,snapshot.drawings=drawings,snapshot.drawingsOrder=drawingsOrder,unitId===core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(docBody.textRuns=[]),textRuns.length>0&&(docBody.textRuns=textRuns),docViewModel.reset(docDataModel);const currentRender=this._getDocObject();currentRender!=null&&(skeleton.calculate(),INCLUDE_LIST.includes(unitId)&&currentRender.document.makeDirty())}_calculatePagePosition(currentRender){const{document:docsComponent,scene,docBackground}=currentRender,parent=scene==null?void 0:scene.getParent(),{width:docsWidth,height:docsHeight,pageMarginLeft,pageMarginTop}=docsComponent;if(parent==null||docsWidth===Number.POSITIVE_INFINITY||docsHeight===Number.POSITIVE_INFINITY)return;const{width:engineWidth,height:engineHeight}=parent;let docsLeft=0,docsTop=0,sceneWidth=0,sceneHeight=0,scrollToX=Number.POSITIVE_INFINITY;const{scaleX,scaleY}=scene.getAncestorScale();engineWidth>(docsWidth+pageMarginLeft*2)*scaleX?(docsLeft=engineWidth/2-docsWidth*scaleX/2,docsLeft/=scaleX,sceneWidth=(engineWidth-pageMarginLeft*2)/scaleX,scrollToX=0):(docsLeft=pageMarginLeft,sceneWidth=docsWidth+pageMarginLeft*2,scrollToX=(sceneWidth-engineWidth/scaleX)/2),engineHeight>docsHeight?(docsTop=engineHeight/2-docsHeight/2,sceneHeight=(engineHeight-pageMarginTop*2)/scaleY):(docsTop=pageMarginTop,sceneHeight=docsHeight+pageMarginTop*2),scene.resize(sceneWidth,sceneHeight+200),docsComponent.translate(docsLeft,docsTop),docBackground.translate(docsLeft,docsTop);const viewport=scene.getViewport(docs.VIEWPORT_KEY.VIEW_MAIN);if(scrollToX!==Number.POSITIVE_INFINITY&&viewport!=null){const actualX=viewport.transScroll2ViewportScrollValue(scrollToX,0).x;viewport.scrollToBarPos({x:actualX})}return this}_commandExecutedListener(){const updateCommandList=[OpenZenEditorOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(command=>{updateCommandList.includes(command.id)&&this._handleOpenZenEditor()}));const editCommandList=[docs.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(command=>{if(editCommandList.includes(command.id)){const params=command.params,{unitId}=params;if(unitId===core.DOCS_ZEN_EDITOR_UNIT_ID_KEY){const editorDocDataModel=this._univerInstanceService.getUniverDocInstance(unitId),docBody=editorDocDataModel==null?void 0:editorDocDataModel.getBody(),dataStream=docBody==null?void 0:docBody.dataStream,paragraphs=docBody==null?void 0:docBody.paragraphs,textRuns=docBody==null?void 0:docBody.textRuns,customBlocks=docBody==null?void 0:docBody.customBlocks,drawings=editorDocDataModel==null?void 0:editorDocDataModel.getDrawings(),drawingsOrder=editorDocDataModel==null?void 0:editorDocDataModel.getDrawingsOrder(),customRanges=editorDocDataModel==null?void 0:editorDocDataModel.getCustomRanges();if(this._editorBridgeService.changeEditorDirty(!0),dataStream==null||paragraphs==null)return;this._syncContentAndRender(core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,dataStream,paragraphs,textRuns,customBlocks,drawings,drawingsOrder,customRanges)}}}))}_getDocObject(){return docs.getDocObject(this._univerInstanceService,this._renderManagerService)}},__name(_a,"ZenEditorController"),_a);ZenEditorController=__decorateClass$2([core.OnLifecycle(core.LifecycleStages.Steady,ZenEditorController),__decorateParam$2(0,core.IUniverInstanceService),__decorateParam$2(1,IZenEditorManagerService),__decorateParam$2(2,engineRender.IRenderManagerService),__decorateParam$2(3,core.ICommandService),__decorateParam$2(4,ui.IZenZoneService),__decorateParam$2(5,sheetsUi.IEditorBridgeService),__decorateParam$2(6,core.IUndoRedoService),__decorateParam$2(7,core.Inject(docs.TextSelectionManagerService))],ZenEditorController);const CancelZenEditCommand={id:"zen-editor.command.cancel-zen-edit",type:core.CommandType.COMMAND,handler:__name(async accessor=>{const zenZoneEditorService=accessor.get(ui.IZenZoneService),editorBridgeService=accessor.get(sheetsUi.IEditorBridgeService),univerInstanceManager=accessor.get(core.IUniverInstanceService);editorBridgeService.isVisible().visible&&editorBridgeService.changeVisible({visible:!1,eventType:engineRender.DeviceInputEventType.Keyboard,keycode:ui.KeyCode.ESC,unitId:""}),zenZoneEditorService.close();const currentSheetInstance=univerInstanceManager.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);return currentSheetInstance?(univerInstanceManager.focusUnit(currentSheetInstance.getUnitId()),editorBridgeService.refreshEditCellState(),!0):!1},"handler")},ConfirmZenEditCommand={id:"zen-editor.command.confirm-zen-edit",type:core.CommandType.COMMAND,handler:__name(async accessor=>{const zenZoneEditorService=accessor.get(ui.IZenZoneService),editorBridgeService=accessor.get(sheetsUi.IEditorBridgeService),univerInstanceManager=accessor.get(core.IUniverInstanceService);editorBridgeService.isVisible().visible&&editorBridgeService.changeVisible({visible:!1,eventType:engineRender.DeviceInputEventType.PointerDown,unitId:""}),zenZoneEditorService.close();const currentSheetInstance=univerInstanceManager.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);return currentSheetInstance?(univerInstanceManager.focusUnit(currentSheetInstance.getUnitId()),editorBridgeService.refreshEditCellState(),!0):!1},"handler")};function ZenEditorMenuItemFactory(accessor){return{id:OpenZenEditorOperation.id,group:ui.MenuGroup.CONTEXT_MENU_OTHERS,type:ui.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[ui.MenuPosition.CONTEXT_MENU],disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellValuePermission,sheets.WorksheetSetCellStylePermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]})}}__name(ZenEditorMenuItemFactory,"ZenEditorMenuItemFactory");var jsxRuntime={exports:{}},reactJsxRuntime_production_min={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var se=g,oe=Symbol.for("react.element"),ce=Symbol.for("react.fragment"),ae=Object.prototype.hasOwnProperty,de=se.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,le={key:!0,ref:!0,__self:!0,__source:!0};function K(n,e,i){var t,r={},c=null,o=null;i!==void 0&&(c=""+i),e.key!==void 0&&(c=""+e.key),e.ref!==void 0&&(o=e.ref);for(t in e)ae.call(e,t)&&!le.hasOwnProperty(t)&&(r[t]=e[t]);if(n&&n.defaultProps)for(t in e=n.defaultProps,e)r[t]===void 0&&(r[t]=e[t]);return{$$typeof:oe,type:n,key:c,ref:o,props:r,_owner:de.current}}w.Fragment=ce;w.jsx=K;w.jsxs=K;Y.exports=w;var O=Y.exports,f=function(){return f=Object.assign||function(n){for(var e,i=1,t=arguments.length;i<t;i++){e=arguments[i];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},f.apply(this,arguments)},ue=function(n,e){var i={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.indexOf(t)<0&&(i[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(n);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(n,t[r])&&(i[t[r]]=n[t[r]]);return i},V=g.forwardRef(function(n,e){var i=n.icon,t=n.id,r=n.className,c=n.extend,o=ue(n,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),d=g.useRef("_".concat(ve()));return F(i,"".concat(t),{defIds:i.defIds,idSuffix:d.current},f({ref:e,className:a},o),c)});function F(n,e,i,t,r){return g.createElement(n.tag,f(f({key:e},_e(n,i,r)),t),(he(n,i).children||[]).map(function(c,o){return F(c,"".concat(e,"-").concat(n.tag,"-").concat(o),i,void 0,r)}))}function _e(n,e,i){var t=f({},n.attrs);i!=null&&i.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=i.colorChannel1);var r=e.defIds;return!r||r.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(c){var o=c[0],a=c[1];typeof a=="string"&&(t[o]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function he(n,e){var i,t=e.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?f(f({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?f(f({},r),{attrs:f(f({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):n}function ve(){return Math.random().toString(36).substring(2,8)}V.displayName="UniverIcon";var fe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},W=g.forwardRef(function(n,e){return g.createElement(V,Object.assign({},n,{id:"check-mark-single",ref:e,icon:fe}))});W.displayName="CheckMarkSingle";var Ie={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},q=g.forwardRef(function(n,e){return g.createElement(V,Object.assign({},n,{id:"close-single",ref:e,icon:Ie}))});q.displayName="CloseSingle";const ge="univer-zen-editor",Ee="univer-zen-editor-icon-wrapper",Se="univer-zen-editor-icon-container",pe="univer-zen-editor-icon-success",me="univer-zen-editor-icon-error",Ce="univer-zen-editor-canvas-container",T={zenEditor:ge,zenEditorIconWrapper:Ee,zenEditorIconContainer:Se,zenEditorIconSuccess:pe,zenEditorIconError:me,zenEditorCanvasContainer:Ce},Oe="ZEN_EDITOR_PLUGIN_",Te=`${Oe}ZEN_EDITOR_COMPONENT`;function Ne(){const n=g.useRef(null),e=s.useDependency(U.IRenderManagerService),i=s.useDependency(A),t=s.useDependency(s.ICommandService);g.useEffect(()=>{const o=n.current;if(!o)return;const a=e.currentRender$.subscribe(h=>{var I;if(h!==s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)return;const l=(I=e.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:I.engine;l==null||l.setContainer(o)}),d=new ResizeObserver(()=>{const h=o.getBoundingClientRect();i.setPosition(h)});return d.observe(o),()=>{d.unobserve(o),a.unsubscribe()}},[]);function r(){t.executeCommand(Z.id)}function c(){t.executeCommand(j.id)}return O.jsxs("div",{className:T.zenEditor,children:[O.jsxs("div",{className:T.zenEditorIconWrapper,children:[O.jsx("span",{className:B(T.zenEditorIconContainer,T.zenEditorIconError),onClick:r,children:O.jsx(q,{style:{fontSize:"22px"}})}),O.jsx("span",{className:B(T.zenEditorIconContainer,T.zenEditorIconSuccess),onClick:c,children:O.jsx(W,{style:{fontSize:"22px"}})})]}),O.jsx("div",{className:T.zenEditorCanvasContainer,ref:n})]})}const Re={id:j.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:n=>H(n),binding:_.KeyCode.ENTER|_.MetaKeys.ALT},De={id:Z.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:n=>H(n),binding:_.KeyCode.ESC};function H(n){return n.getContextValue(s.FOCUSING_DOC)&&n.getContextValue(s.FOCUSING_UNIVER_EDITOR)&&n.getContextValue(s.EDITOR_ACTIVATED)&&!n.getContextValue(s.FOCUSING_EDITOR_STANDALONE)}var ye=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Ue=(n,e,i,t)=>{for(var r=t>1?void 0:t?be(e,i):e,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(t?o(e,i,r):o(r))||r);return t&&r&&ye(e,i,r),r},y=(n,e)=>(i,t)=>e(i,t,n);const ze={};let b=class extends s.Disposable{constructor(n,e,i,t,r,c){super(),this._config=n,this._injector=e,this._zenZoneService=i,this._commandService=t,this._menuService=r,this._shortcutService=c,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(Te,Ne))}_initCommands(){[P,Z,j].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initMenus(){const{menu:n={}}=this._config;[re].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e),n))})}_initShortcuts(){[Re,De].forEach(n=>{this.disposeWithMe(this._shortcutService.registerShortcut(n))})}};b=Ue([s.OnLifecycle(s.LifecycleStages.Rendered,b),y(1,s.Inject(s.Injector)),y(2,_.IZenZoneService),y(3,s.ICommandService),y(4,_.IMenuService),y(5,_.IShortcutService)],b);var xe=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,Pe=(n,e,i,t)=>{for(var r=t>1?void 0:t?Me(e,i):e,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(t?o(e,i,r):o(r))||r);return t&&r&&xe(e,i,r),r},k=(n,e)=>(i,t)=>e(i,t,n),x;exports.UniverSheetsZenEditorPlugin=(x=class extends s.Plugin{constructor(e={},i,t){super(),this._config=e,this._injector=i,this._localeService=t,this._initializeDependencies(this._injector),this._config=s.Tools.deepMerge({},ze,this._config)}_initializeDependencies(e){[[b,{useFactory:()=>this._injector.createInstance(b,this._config)}],[M],[A,{useClass:ee}]].forEach(t=>e.add(t))}},C(x,"pluginName","zen-editor"),C(x,"type",s.UniverInstanceType.UNIVER_DOC),x);exports.UniverSheetsZenEditorPlugin=Pe([k(1,s.Inject(s.Injector)),k(2,s.Inject(s.LocaleService))],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=Z;exports.ConfirmZenEditCommand=j;exports.OpenZenEditorOperation=P;
9
+ */var f=require$$0,k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};function q(c,a,g){var b,d={},e=null,h=null;g!==void 0&&(e=""+g),a.key!==void 0&&(e=""+a.key),a.ref!==void 0&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)d[b]===void 0&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}__name(q,"q");reactJsxRuntime_production_min.Fragment=l;reactJsxRuntime_production_min.jsx=q;reactJsxRuntime_production_min.jsxs=q;jsxRuntime.exports=reactJsxRuntime_production_min;var jsxRuntimeExports=jsxRuntime.exports,__assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n2=arguments.length;i<n2;i++){s=arguments[i];for(var p2 in s)Object.prototype.hasOwnProperty.call(s,p2)&&(t[p2]=s[p2])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p2 in s)Object.prototype.hasOwnProperty.call(s,p2)&&e.indexOf(p2)<0&&(t[p2]=s[p2]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p2=Object.getOwnPropertySymbols(s);i<p2.length;i++)e.indexOf(p2[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p2[i])&&(t[p2[i]]=s[p2[i]]);return t},IconBase=require$$0.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=require$$0.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return require$$0.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a4){var key=_a4[0],value=_a4[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a4,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a4=node.children)===null||_a4===void 0)&&_a4.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid");IconBase.displayName="UniverIcon";var element$1={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},CheckMarkSingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"check-mark-single",ref,icon:element$1}))});CheckMarkSingle.displayName="CheckMarkSingle";var element={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},CloseSingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"close-single",ref,icon:element}))});CloseSingle.displayName="CloseSingle";const zenEditor="univer-zen-editor",zenEditorIconWrapper="univer-zen-editor-icon-wrapper",zenEditorIconContainer="univer-zen-editor-icon-container",zenEditorIconSuccess="univer-zen-editor-icon-success",zenEditorIconError="univer-zen-editor-icon-error",zenEditorCanvasContainer="univer-zen-editor-canvas-container",styles={zenEditor,zenEditorIconWrapper,zenEditorIconContainer,zenEditorIconSuccess,zenEditorIconError,zenEditorCanvasContainer},COMPONENT_PREFIX="ZEN_EDITOR_PLUGIN_",ZEN_EDITOR_COMPONENT=`${COMPONENT_PREFIX}ZEN_EDITOR_COMPONENT`;function ZenEditor(){const editorRef=require$$0.useRef(null),renderManagerService=core.useDependency(engineRender.IRenderManagerService),zenEditorManagerService=core.useDependency(IZenEditorManagerService),commandService=core.useDependency(core.ICommandService);require$$0.useEffect(()=>{const editor=editorRef.current;if(!editor)return;const renderSubscription=renderManagerService.currentRender$.subscribe(param=>{var _a4;if(param!==core.DOCS_ZEN_EDITOR_UNIT_ID_KEY)return;const engine=(_a4=renderManagerService.getRenderById(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:_a4.engine;engine==null||engine.setContainer(editor)}),resizeObserver=new ResizeObserver(()=>{const editorRect=editor.getBoundingClientRect();zenEditorManagerService.setPosition(editorRect)});return resizeObserver.observe(editor),()=>{resizeObserver.unobserve(editor),renderSubscription.unsubscribe()}},[]);function handleCloseBtnClick(){commandService.executeCommand(CancelZenEditCommand.id)}__name(handleCloseBtnClick,"handleCloseBtnClick");function handleConfirmBtnClick(){commandService.executeCommand(ConfirmZenEditCommand.id)}return __name(handleConfirmBtnClick,"handleConfirmBtnClick"),jsxRuntimeExports.jsxs("div",{className:styles.zenEditor,children:[jsxRuntimeExports.jsxs("div",{className:styles.zenEditorIconWrapper,children:[jsxRuntimeExports.jsx("span",{className:clsx(styles.zenEditorIconContainer,styles.zenEditorIconError),onClick:handleCloseBtnClick,children:jsxRuntimeExports.jsx(CloseSingle,{style:{fontSize:"22px"}})}),jsxRuntimeExports.jsx("span",{className:clsx(styles.zenEditorIconContainer,styles.zenEditorIconSuccess),onClick:handleConfirmBtnClick,children:jsxRuntimeExports.jsx(CheckMarkSingle,{style:{fontSize:"22px"}})})]}),jsxRuntimeExports.jsx("div",{className:styles.zenEditorCanvasContainer,ref:editorRef})]})}__name(ZenEditor,"ZenEditor");const ZenEditorConfirmShortcut={id:ConfirmZenEditCommand.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:__name(contextService=>whenZenEditorActivated(contextService),"preconditions"),binding:ui.KeyCode.ENTER|ui.MetaKeys.ALT},ZenEditorCancelShortcut={id:CancelZenEditCommand.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:__name(contextService=>whenZenEditorActivated(contextService),"preconditions"),binding:ui.KeyCode.ESC};function whenZenEditorActivated(contextService){return contextService.getContextValue(core.FOCUSING_DOC)&&contextService.getContextValue(core.FOCUSING_UNIVER_EDITOR)&&contextService.getContextValue(core.EDITOR_ACTIVATED)&&!contextService.getContextValue(core.FOCUSING_EDITOR_STANDALONE)}__name(whenZenEditorActivated,"whenZenEditorActivated");var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");const DefaultSheetZenEditorUiConfig={};var _a2;let ZenEditorUIController=(_a2=class extends core.Disposable{constructor(_config,_injector,_zenZoneService,_commandService,_menuService,_shortcutService){super(),this._config=_config,this._injector=_injector,this._zenZoneService=_zenZoneService,this._commandService=_commandService,this._menuService=_menuService,this._shortcutService=_shortcutService,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(ZEN_EDITOR_COMPONENT,ZenEditor))}_initCommands(){[OpenZenEditorOperation,CancelZenEditCommand,ConfirmZenEditCommand].forEach(c=>{this.disposeWithMe(this._commandService.registerCommand(c))})}_initMenus(){const{menu={}}=this._config;[ZenEditorMenuItemFactory].forEach(factory=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory),menu))})}_initShortcuts(){[ZenEditorConfirmShortcut,ZenEditorCancelShortcut].forEach(item=>{this.disposeWithMe(this._shortcutService.registerShortcut(item))})}},__name(_a2,"ZenEditorUIController"),_a2);ZenEditorUIController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Rendered,ZenEditorUIController),__decorateParam$1(1,core.Inject(core.Injector)),__decorateParam$1(2,ui.IZenZoneService),__decorateParam$1(3,core.ICommandService),__decorateParam$1(4,ui.IMenuService),__decorateParam$1(5,ui.IShortcutService)],ZenEditorUIController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),_a3;exports.UniverSheetsZenEditorPlugin=(_a3=class extends core.Plugin{constructor(_config={},_injector,_localeService){super(),this._config=_config,this._injector=_injector,this._localeService=_localeService,this._initializeDependencies(this._injector),this._config=core.Tools.deepMerge({},DefaultSheetZenEditorUiConfig,this._config)}_initializeDependencies(injector){[[ZenEditorUIController,{useFactory:__name(()=>this._injector.createInstance(ZenEditorUIController,this._config),"useFactory")}],[ZenEditorController],[IZenEditorManagerService,{useClass:ZenEditorManagerService}]].forEach(dependency=>injector.add(dependency))}},__name(_a3,"UniverSheetsZenEditorPlugin"),__publicField(_a3,"pluginName","zen-editor"),__publicField(_a3,"type",core.UniverInstanceType.UNIVER_SHEET),_a3);exports.UniverSheetsZenEditorPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.Inject(core.LocaleService))],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=CancelZenEditCommand;exports.ConfirmZenEditCommand=ConfirmZenEditCommand;exports.OpenZenEditorOperation=OpenZenEditorOperation;
package/lib/es/index.js CHANGED
@@ -1,61 +1,63 @@
1
- var he = Object.defineProperty;
2
- var fe = (t, e, i) => e in t ? he(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
3
- var E = (t, e, i) => fe(t, typeof e != "symbol" ? e + "" : e, i);
4
- import { CommandType as w, createIdentifier as _e, RxDisposable as ge, DOCS_ZEN_EDITOR_UNIT_ID_KEY as f, DEFAULT_EMPTY_DOCUMENT_VALUE as ve, DocumentFlavor as pe, UniverInstanceType as T, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as H, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as K, OnLifecycle as Q, LifecycleStages as ee, Inject as z, IUniverInstanceService as D, ICommandService as j, IUndoRedoService as me, useDependency as U, FOCUSING_DOC as Se, FOCUSING_UNIVER_EDITOR as Ee, EDITOR_ACTIVATED as Ie, FOCUSING_EDITOR_STANDALONE as Ce, Injector as te, Disposable as Oe, Plugin as Re, Tools as ye, LocaleService as Te } from "@univerjs/core";
5
- import { DocSkeletonManagerService as X, VIEWPORT_KEY as be, RichTextEditingMutation as Ne, getDocObject as ze, TextSelectionManagerService as xe } from "@univerjs/docs";
6
- import { DeviceInputEventType as L, IRenderManagerService as ne } from "@univerjs/engine-render";
7
- import { getEditorObject as Me, IEditorBridgeService as Z, getCurrentRangeDisable$ as Pe } from "@univerjs/sheets-ui";
8
- import { IZenZoneService as x, KeyCode as V, MenuGroup as Ue, MenuItemType as we, MenuPosition as De, MetaKeys as je, IMenuService as Le, IShortcutService as Ze } from "@univerjs/ui";
9
- import { BehaviorSubject as Ve, takeUntil as Ae } from "rxjs";
10
- import { WorkbookEditablePermission as ke, WorksheetEditPermission as Be, WorksheetSetCellValuePermission as $e, WorksheetSetCellStylePermission as Fe, RangeProtectionPermissionEditPoint as We } from "@univerjs/sheets";
11
- import Ye, { forwardRef as A, useRef as ie, createElement as k, useEffect as He } from "react";
12
- import G from "clsx";
13
- const B = {
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
+ import { CommandType, createIdentifier, RxDisposable, DOCS_ZEN_EDITOR_UNIT_ID_KEY, DEFAULT_EMPTY_DOCUMENT_VALUE, DocumentFlavor, UniverInstanceType, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, OnLifecycle, LifecycleStages, Inject, IUniverInstanceService, ICommandService, IUndoRedoService, useDependency, FOCUSING_DOC, FOCUSING_UNIVER_EDITOR, EDITOR_ACTIVATED, FOCUSING_EDITOR_STANDALONE, Injector, Disposable, Plugin, Tools, LocaleService } from "@univerjs/core";
6
+ import { DocSkeletonManagerService, VIEWPORT_KEY, RichTextEditingMutation, getDocObject, TextSelectionManagerService } from "@univerjs/docs";
7
+ import { DeviceInputEventType, IRenderManagerService } from "@univerjs/engine-render";
8
+ import { getEditorObject, IEditorBridgeService, getCurrentRangeDisable$ } from "@univerjs/sheets-ui";
9
+ import { IZenZoneService, KeyCode, MenuGroup, MenuItemType, MenuPosition, MetaKeys, IMenuService, IShortcutService } from "@univerjs/ui";
10
+ import { BehaviorSubject, takeUntil } from "rxjs";
11
+ import { WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetSetCellStylePermission, RangeProtectionPermissionEditPoint } from "@univerjs/sheets";
12
+ import require$$0, { forwardRef, useRef, createElement, useEffect } from "react";
13
+ import clsx from "clsx";
14
+ const OpenZenEditorOperation = {
14
15
  id: "zen-editor.operation.open-zen-editor",
15
- type: w.OPERATION,
16
- handler: (t) => !0
17
- };
18
- class Ke {
16
+ type: CommandType.OPERATION,
17
+ handler: /* @__PURE__ */ __name((accessor) => !0, "handler")
18
+ }, _ZenEditorManagerService = class _ZenEditorManagerService {
19
19
  constructor() {
20
- E(this, "_position", null);
21
- E(this, "_position$", new Ve(null));
22
- E(this, "position$", this._position$.asObservable());
20
+ __publicField(this, "_position", null);
21
+ __publicField(this, "_position$", new BehaviorSubject(null));
22
+ __publicField(this, "position$", this._position$.asObservable());
23
23
  }
24
24
  dispose() {
25
25
  this._position$.complete(), this._position = null;
26
26
  }
27
- setPosition(e) {
28
- this._position = e, this._refresh(e);
27
+ setPosition(param) {
28
+ this._position = param, this._refresh(param);
29
29
  }
30
30
  getPosition() {
31
31
  return this._position;
32
32
  }
33
- _refresh(e) {
34
- this._position$.next(e);
33
+ _refresh(param) {
34
+ this._position$.next(param);
35
35
  }
36
- }
37
- const $ = _e(
36
+ };
37
+ __name(_ZenEditorManagerService, "ZenEditorManagerService");
38
+ let ZenEditorManagerService = _ZenEditorManagerService;
39
+ const IZenEditorManagerService = createIdentifier(
38
40
  "univer.sheet-zen-editor-manager.service"
39
41
  );
40
- var Xe = Object.defineProperty, Ge = Object.getOwnPropertyDescriptor, qe = (t, e, i, n) => {
41
- for (var r = n > 1 ? void 0 : n ? Ge(e, i) : e, o = t.length - 1, s; o >= 0; o--)
42
- (s = t[o]) && (r = (n ? s(e, i, r) : s(r)) || r);
43
- return n && r && Xe(e, i, r), r;
44
- }, m = (t, e) => (i, n) => e(i, n, t);
45
- let N = class extends ge {
46
- constructor(e, i, n, r, o, s, c, a) {
42
+ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
43
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
44
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
45
+ return kind && result && __defProp$2(target, key, result), result;
46
+ }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a;
47
+ let ZenEditorController = (_a = class extends RxDisposable {
48
+ constructor(_univerInstanceService, _zenEditorManagerService, _renderManagerService, _commandService, _zenZoneService, _editorBridgeService, _undoRedoService, _textSelectionManagerService) {
47
49
  super();
48
- E(this, "_zenEditorInitialState", !1);
49
- this._univerInstanceService = e, this._zenEditorManagerService = i, this._renderManagerService = n, this._commandService = r, this._zenZoneService = o, this._editorBridgeService = s, this._undoRedoService = c, this._textSelectionManagerService = a, this._initialize();
50
+ __publicField(this, "_zenEditorInitialState", !1);
51
+ this._univerInstanceService = _univerInstanceService, this._zenEditorManagerService = _zenEditorManagerService, this._renderManagerService = _renderManagerService, this._commandService = _commandService, this._zenZoneService = _zenZoneService, this._editorBridgeService = _editorBridgeService, this._undoRedoService = _undoRedoService, this._textSelectionManagerService = _textSelectionManagerService, this._initialize();
50
52
  }
51
53
  _initialize() {
52
54
  this._syncZenEditorSize(), this._commandExecutedListener();
53
55
  }
54
56
  _createZenEditorInstance() {
55
- const e = {
56
- id: f,
57
+ const INITIAL_SNAPSHOT = {
58
+ id: DOCS_ZEN_EDITOR_UNIT_ID_KEY,
57
59
  body: {
58
- dataStream: `${ve}`,
60
+ dataStream: `${DEFAULT_EMPTY_DOCUMENT_VALUE}`,
59
61
  textRuns: [],
60
62
  customBlocks: [],
61
63
  paragraphs: [
@@ -69,7 +71,7 @@ let N = class extends ge {
69
71
  width: 595,
70
72
  height: 842
71
73
  },
72
- documentFlavor: pe.MODERN,
74
+ documentFlavor: DocumentFlavor.MODERN,
73
75
  marginTop: 50,
74
76
  marginBottom: 50,
75
77
  marginRight: 40,
@@ -82,158 +84,159 @@ let N = class extends ge {
82
84
  drawings: {},
83
85
  drawingsOrder: []
84
86
  };
85
- return this._univerInstanceService.createUnit(T.UNIVER_DOC, e);
87
+ return this._univerInstanceService.createUnit(UniverInstanceType.UNIVER_DOC, INITIAL_SNAPSHOT);
86
88
  }
87
89
  // Listen to changes in the size of the zen editor container to set the size of the editor.
88
90
  _syncZenEditorSize() {
89
- this._zenEditorManagerService.position$.pipe(Ae(this.dispose$)).subscribe((e) => {
90
- var a;
91
- if (e == null)
91
+ this._zenEditorManagerService.position$.pipe(takeUntil(this.dispose$)).subscribe((position) => {
92
+ var _a4;
93
+ if (position == null)
92
94
  return;
93
- const i = Me(f, this._renderManagerService), n = this._univerInstanceService.getUniverDocInstance(f);
94
- if (i == null || n == null)
95
+ const editorObject = getEditorObject(DOCS_ZEN_EDITOR_UNIT_ID_KEY, this._renderManagerService), zenEditorDataModel = this._univerInstanceService.getUniverDocInstance(DOCS_ZEN_EDITOR_UNIT_ID_KEY);
96
+ if (editorObject == null || zenEditorDataModel == null)
95
97
  return;
96
- const { width: r, height: o } = e, { engine: s } = i, c = (a = this._renderManagerService.getRenderById(f)) == null ? void 0 : a.with(X).getSkeleton();
98
+ const { width, height } = position, { engine } = editorObject, skeleton = (_a4 = this._renderManagerService.getRenderById(DOCS_ZEN_EDITOR_UNIT_ID_KEY)) == null ? void 0 : _a4.with(DocSkeletonManagerService).getSkeleton();
97
99
  requestIdleCallback(() => {
98
- s.resizeBySize(r, o), this._calculatePagePosition(i), c && this._textSelectionManagerService.refreshSelection();
100
+ engine.resizeBySize(width, height), this._calculatePagePosition(editorObject), skeleton && this._textSelectionManagerService.refreshSelection();
99
101
  });
100
102
  });
101
103
  }
102
104
  _handleOpenZenEditor() {
103
- var o;
105
+ var _a4;
104
106
  this._zenEditorInitialState || (this._createZenEditorInstance(), this._zenEditorInitialState = !0), this._zenZoneService.open();
105
- const e = this._univerInstanceService.getCurrentUnitForType(T.UNIVER_SHEET);
106
- this._undoRedoService.clearUndoRedo(f), this._univerInstanceService.focusUnit(f), this._univerInstanceService.setCurrentUnitForType(f), this._editorBridgeService.isVisible().visible === !1 && this._editorBridgeService.changeVisible({
107
+ const currentSheet = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
108
+ this._undoRedoService.clearUndoRedo(DOCS_ZEN_EDITOR_UNIT_ID_KEY), this._univerInstanceService.focusUnit(DOCS_ZEN_EDITOR_UNIT_ID_KEY), this._univerInstanceService.setCurrentUnitForType(DOCS_ZEN_EDITOR_UNIT_ID_KEY), this._editorBridgeService.isVisible().visible === !1 && this._editorBridgeService.changeVisible({
107
109
  visible: !0,
108
- eventType: L.PointerDown,
109
- unitId: (o = e == null ? void 0 : e.getUnitId()) != null ? o : ""
110
+ eventType: DeviceInputEventType.PointerDown,
111
+ unitId: (_a4 = currentSheet == null ? void 0 : currentSheet.getUnitId()) != null ? _a4 : ""
110
112
  });
111
- const n = this._editorBridgeService.getLatestEditCellState();
112
- if (n == null)
113
+ const editCellState = this._editorBridgeService.getLatestEditCellState();
114
+ if (editCellState == null)
113
115
  return;
114
- this._editorSyncHandler(n);
115
- const r = [
116
+ this._editorSyncHandler(editCellState);
117
+ const textRanges = [
116
118
  {
117
119
  startOffset: 0,
118
120
  endOffset: 0
119
121
  }
120
122
  ];
121
- this._textSelectionManagerService.replaceTextRanges(r);
123
+ this._textSelectionManagerService.replaceTextRanges(textRanges);
122
124
  }
123
- _editorSyncHandler(e) {
124
- var s, c;
125
- const i = (s = e.documentLayoutObject.documentModel) == null ? void 0 : s.getBody(), n = i == null ? void 0 : i.dataStream, r = i == null ? void 0 : i.paragraphs;
126
- let o = [];
127
- n == null || r == null || ((c = i == null ? void 0 : i.textRuns) != null && c.length && (o = i == null ? void 0 : i.textRuns), this._syncContentAndRender(f, n, r, o));
125
+ _editorSyncHandler(param) {
126
+ var _a4, _b;
127
+ const body = (_a4 = param.documentLayoutObject.documentModel) == null ? void 0 : _a4.getBody(), dataStream = body == null ? void 0 : body.dataStream, paragraphs = body == null ? void 0 : body.paragraphs;
128
+ let textRuns = [];
129
+ dataStream == null || paragraphs == null || ((_b = body == null ? void 0 : body.textRuns) != null && _b.length && (textRuns = body == null ? void 0 : body.textRuns), this._syncContentAndRender(DOCS_ZEN_EDITOR_UNIT_ID_KEY, dataStream, paragraphs, textRuns));
128
130
  }
129
- _syncContentAndRender(e, i, n, r = [], o = [], s = {}, c = [], a = []) {
130
- var p;
131
- const u = [
132
- f,
133
- K,
134
- H
135
- ], d = (p = this._renderManagerService.getRenderById(e)) == null ? void 0 : p.with(X), g = d == null ? void 0 : d.getSkeleton(), h = this._univerInstanceService.getUniverDocInstance(e), v = d == null ? void 0 : d.getViewModel();
136
- if (h == null || v == null || g == null)
131
+ _syncContentAndRender(unitId, dataStream, paragraphs, textRuns = [], customBlocks = [], drawings = {}, drawingsOrder = [], customRanges = []) {
132
+ var _a4;
133
+ const INCLUDE_LIST = [
134
+ DOCS_ZEN_EDITOR_UNIT_ID_KEY,
135
+ DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
136
+ DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY
137
+ ], docSkeletonManagerService = (_a4 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a4.with(DocSkeletonManagerService), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton(), docDataModel = this._univerInstanceService.getUniverDocInstance(unitId), docViewModel = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getViewModel();
138
+ if (docDataModel == null || docViewModel == null || skeleton == null)
137
139
  return;
138
- const l = h.getBody(), O = h.getSnapshot();
139
- l.dataStream = i, l.paragraphs = n, l.customBlocks = o, l.customRanges = a, O.drawings = s, O.drawingsOrder = c, e === H && (l.textRuns = []), r.length > 0 && (l.textRuns = r), v.reset(h);
140
- const S = this._getDocObject();
141
- S != null && (g.calculate(), u.includes(e) && S.document.makeDirty());
140
+ const docBody = docDataModel.getBody(), snapshot = docDataModel.getSnapshot();
141
+ docBody.dataStream = dataStream, docBody.paragraphs = paragraphs, docBody.customBlocks = customBlocks, docBody.customRanges = customRanges, snapshot.drawings = drawings, snapshot.drawingsOrder = drawingsOrder, unitId === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY && (docBody.textRuns = []), textRuns.length > 0 && (docBody.textRuns = textRuns), docViewModel.reset(docDataModel);
142
+ const currentRender = this._getDocObject();
143
+ currentRender != null && (skeleton.calculate(), INCLUDE_LIST.includes(unitId) && currentRender.document.makeDirty());
142
144
  }
143
- _calculatePagePosition(e) {
144
- const { document: i, scene: n, docBackground: r } = e, o = n == null ? void 0 : n.getParent(), { width: s, height: c, pageMarginLeft: a, pageMarginTop: u } = i;
145
- if (o == null || s === Number.POSITIVE_INFINITY || c === Number.POSITIVE_INFINITY)
145
+ _calculatePagePosition(currentRender) {
146
+ const { document: docsComponent, scene, docBackground } = currentRender, parent = scene == null ? void 0 : scene.getParent(), { width: docsWidth, height: docsHeight, pageMarginLeft, pageMarginTop } = docsComponent;
147
+ if (parent == null || docsWidth === Number.POSITIVE_INFINITY || docsHeight === Number.POSITIVE_INFINITY)
146
148
  return;
147
- const { width: d, height: g } = o;
148
- let h = 0, v = 0, l = 0, O = 0, S = Number.POSITIVE_INFINITY;
149
- const { scaleX: p, scaleY: le } = n.getAncestorScale();
150
- d > (s + a * 2) * p ? (h = d / 2 - s * p / 2, h /= p, l = (d - a * 2) / p, S = 0) : (h = a, l = s + a * 2, S = (l - d / p) / 2), g > c ? (v = g / 2 - c / 2, O = (g - u * 2) / le) : (v = u, O = c + u * 2), n.resize(l, O + 200), i.translate(h, v), r.translate(h, v);
151
- const P = n.getViewport(be.VIEW_MAIN);
152
- if (S !== Number.POSITIVE_INFINITY && P != null) {
153
- const ue = P.transScroll2ViewportScrollValue(S, 0).x;
154
- P.scrollToBarPos({
155
- x: ue
149
+ const { width: engineWidth, height: engineHeight } = parent;
150
+ let docsLeft = 0, docsTop = 0, sceneWidth = 0, sceneHeight = 0, scrollToX = Number.POSITIVE_INFINITY;
151
+ const { scaleX, scaleY } = scene.getAncestorScale();
152
+ engineWidth > (docsWidth + pageMarginLeft * 2) * scaleX ? (docsLeft = engineWidth / 2 - docsWidth * scaleX / 2, docsLeft /= scaleX, sceneWidth = (engineWidth - pageMarginLeft * 2) / scaleX, scrollToX = 0) : (docsLeft = pageMarginLeft, sceneWidth = docsWidth + pageMarginLeft * 2, scrollToX = (sceneWidth - engineWidth / scaleX) / 2), engineHeight > docsHeight ? (docsTop = engineHeight / 2 - docsHeight / 2, sceneHeight = (engineHeight - pageMarginTop * 2) / scaleY) : (docsTop = pageMarginTop, sceneHeight = docsHeight + pageMarginTop * 2), scene.resize(sceneWidth, sceneHeight + 200), docsComponent.translate(docsLeft, docsTop), docBackground.translate(docsLeft, docsTop);
153
+ const viewport = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
154
+ if (scrollToX !== Number.POSITIVE_INFINITY && viewport != null) {
155
+ const actualX = viewport.transScroll2ViewportScrollValue(scrollToX, 0).x;
156
+ viewport.scrollToBarPos({
157
+ x: actualX
156
158
  });
157
159
  }
158
160
  return this;
159
161
  }
160
162
  _commandExecutedListener() {
161
- const e = [B.id];
163
+ const updateCommandList = [OpenZenEditorOperation.id];
162
164
  this.disposeWithMe(
163
- this._commandService.onCommandExecuted((n) => {
164
- e.includes(n.id) && this._handleOpenZenEditor();
165
+ this._commandService.onCommandExecuted((command) => {
166
+ updateCommandList.includes(command.id) && this._handleOpenZenEditor();
165
167
  })
166
168
  );
167
- const i = [Ne.id];
169
+ const editCommandList = [RichTextEditingMutation.id];
168
170
  this.disposeWithMe(
169
- this._commandService.onCommandExecuted((n) => {
170
- if (i.includes(n.id)) {
171
- const r = n.params, { unitId: o } = r;
172
- if (o === f) {
173
- const s = this._univerInstanceService.getUniverDocInstance(o), c = s == null ? void 0 : s.getBody(), a = c == null ? void 0 : c.dataStream, u = c == null ? void 0 : c.paragraphs, d = c == null ? void 0 : c.textRuns, g = c == null ? void 0 : c.customBlocks, h = s == null ? void 0 : s.getDrawings(), v = s == null ? void 0 : s.getDrawingsOrder(), l = s == null ? void 0 : s.getCustomRanges();
174
- if (this._editorBridgeService.changeEditorDirty(!0), a == null || u == null)
171
+ this._commandService.onCommandExecuted((command) => {
172
+ if (editCommandList.includes(command.id)) {
173
+ const params = command.params, { unitId } = params;
174
+ if (unitId === DOCS_ZEN_EDITOR_UNIT_ID_KEY) {
175
+ const editorDocDataModel = this._univerInstanceService.getUniverDocInstance(unitId), docBody = editorDocDataModel == null ? void 0 : editorDocDataModel.getBody(), dataStream = docBody == null ? void 0 : docBody.dataStream, paragraphs = docBody == null ? void 0 : docBody.paragraphs, textRuns = docBody == null ? void 0 : docBody.textRuns, customBlocks = docBody == null ? void 0 : docBody.customBlocks, drawings = editorDocDataModel == null ? void 0 : editorDocDataModel.getDrawings(), drawingsOrder = editorDocDataModel == null ? void 0 : editorDocDataModel.getDrawingsOrder(), customRanges = editorDocDataModel == null ? void 0 : editorDocDataModel.getCustomRanges();
176
+ if (this._editorBridgeService.changeEditorDirty(!0), dataStream == null || paragraphs == null)
175
177
  return;
176
- this._syncContentAndRender(K, a, u, d, g, h, v, l);
178
+ this._syncContentAndRender(DOCS_NORMAL_EDITOR_UNIT_ID_KEY, dataStream, paragraphs, textRuns, customBlocks, drawings, drawingsOrder, customRanges);
177
179
  }
178
180
  }
179
181
  })
180
182
  );
181
183
  }
182
184
  _getDocObject() {
183
- return ze(this._univerInstanceService, this._renderManagerService);
185
+ return getDocObject(this._univerInstanceService, this._renderManagerService);
184
186
  }
185
- };
186
- N = qe([
187
- Q(ee.Steady, N),
188
- m(0, D),
189
- m(1, $),
190
- m(2, ne),
191
- m(3, j),
192
- m(4, x),
193
- m(5, Z),
194
- m(6, me),
195
- m(7, z(xe))
196
- ], N);
197
- const F = {
187
+ }, __name(_a, "ZenEditorController"), _a);
188
+ ZenEditorController = __decorateClass$2([
189
+ OnLifecycle(LifecycleStages.Steady, ZenEditorController),
190
+ __decorateParam$2(0, IUniverInstanceService),
191
+ __decorateParam$2(1, IZenEditorManagerService),
192
+ __decorateParam$2(2, IRenderManagerService),
193
+ __decorateParam$2(3, ICommandService),
194
+ __decorateParam$2(4, IZenZoneService),
195
+ __decorateParam$2(5, IEditorBridgeService),
196
+ __decorateParam$2(6, IUndoRedoService),
197
+ __decorateParam$2(7, Inject(TextSelectionManagerService))
198
+ ], ZenEditorController);
199
+ const CancelZenEditCommand = {
198
200
  id: "zen-editor.command.cancel-zen-edit",
199
- type: w.COMMAND,
200
- handler: async (t) => {
201
- const e = t.get(x), i = t.get(Z), n = t.get(D);
202
- i.isVisible().visible && i.changeVisible({
201
+ type: CommandType.COMMAND,
202
+ handler: /* @__PURE__ */ __name(async (accessor) => {
203
+ const zenZoneEditorService = accessor.get(IZenZoneService), editorBridgeService = accessor.get(IEditorBridgeService), univerInstanceManager = accessor.get(IUniverInstanceService);
204
+ editorBridgeService.isVisible().visible && editorBridgeService.changeVisible({
203
205
  visible: !1,
204
- eventType: L.Keyboard,
205
- keycode: V.ESC,
206
+ eventType: DeviceInputEventType.Keyboard,
207
+ keycode: KeyCode.ESC,
206
208
  unitId: ""
207
- }), e.close();
208
- const o = n.getCurrentUnitForType(T.UNIVER_SHEET);
209
- return o ? (n.focusUnit(o.getUnitId()), i.refreshEditCellState(), !0) : !1;
210
- }
211
- }, W = {
209
+ }), zenZoneEditorService.close();
210
+ const currentSheetInstance = univerInstanceManager.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
211
+ return currentSheetInstance ? (univerInstanceManager.focusUnit(currentSheetInstance.getUnitId()), editorBridgeService.refreshEditCellState(), !0) : !1;
212
+ }, "handler")
213
+ }, ConfirmZenEditCommand = {
212
214
  id: "zen-editor.command.confirm-zen-edit",
213
- type: w.COMMAND,
214
- handler: async (t) => {
215
- const e = t.get(x), i = t.get(Z), n = t.get(D);
216
- i.isVisible().visible && i.changeVisible({
215
+ type: CommandType.COMMAND,
216
+ handler: /* @__PURE__ */ __name(async (accessor) => {
217
+ const zenZoneEditorService = accessor.get(IZenZoneService), editorBridgeService = accessor.get(IEditorBridgeService), univerInstanceManager = accessor.get(IUniverInstanceService);
218
+ editorBridgeService.isVisible().visible && editorBridgeService.changeVisible({
217
219
  visible: !1,
218
- eventType: L.PointerDown,
220
+ eventType: DeviceInputEventType.PointerDown,
219
221
  unitId: ""
220
- }), e.close();
221
- const o = n.getCurrentUnitForType(T.UNIVER_SHEET);
222
- return o ? (n.focusUnit(o.getUnitId()), i.refreshEditCellState(), !0) : !1;
223
- }
222
+ }), zenZoneEditorService.close();
223
+ const currentSheetInstance = univerInstanceManager.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
224
+ return currentSheetInstance ? (univerInstanceManager.focusUnit(currentSheetInstance.getUnitId()), editorBridgeService.refreshEditCellState(), !0) : !1;
225
+ }, "handler")
224
226
  };
225
- function Je(t) {
227
+ function ZenEditorMenuItemFactory(accessor) {
226
228
  return {
227
- id: B.id,
228
- group: Ue.CONTEXT_MENU_OTHERS,
229
- type: we.BUTTON,
229
+ id: OpenZenEditorOperation.id,
230
+ group: MenuGroup.CONTEXT_MENU_OTHERS,
231
+ type: MenuItemType.BUTTON,
230
232
  title: "rightClick.zenEditor",
231
233
  icon: "AmplifySingle",
232
- positions: [De.CONTEXT_MENU],
233
- disabled$: Pe(t, { workbookTypes: [ke], worksheetTypes: [Be, $e, Fe], rangeTypes: [We] })
234
+ positions: [MenuPosition.CONTEXT_MENU],
235
+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
234
236
  };
235
237
  }
236
- var re = { exports: {} }, M = {};
238
+ __name(ZenEditorMenuItemFactory, "ZenEditorMenuItemFactory");
239
+ var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
237
240
  /**
238
241
  * @license React
239
242
  * react-jsx-runtime.production.min.js
@@ -243,222 +246,231 @@ var re = { exports: {} }, M = {};
243
246
  * This source code is licensed under the MIT license found in the
244
247
  * LICENSE file in the root directory of this source tree.
245
248
  */
246
- var Qe = Ye, et = Symbol.for("react.element"), tt = Symbol.for("react.fragment"), nt = Object.prototype.hasOwnProperty, it = Qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, rt = { key: !0, ref: !0, __self: !0, __source: !0 };
247
- function se(t, e, i) {
248
- var n, r = {}, o = null, s = null;
249
- i !== void 0 && (o = "" + i), e.key !== void 0 && (o = "" + e.key), e.ref !== void 0 && (s = e.ref);
250
- for (n in e) nt.call(e, n) && !rt.hasOwnProperty(n) && (r[n] = e[n]);
251
- if (t && t.defaultProps) for (n in e = t.defaultProps, e) r[n] === void 0 && (r[n] = e[n]);
252
- return { $$typeof: et, type: t, key: o, ref: s, props: r, _owner: it.current };
249
+ var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
250
+ function q(c, a, g) {
251
+ var b, d = {}, e = null, h = null;
252
+ g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h = a.ref);
253
+ for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
254
+ if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
255
+ return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
253
256
  }
254
- M.Fragment = tt;
255
- M.jsx = se;
256
- M.jsxs = se;
257
- re.exports = M;
258
- var I = re.exports, _ = function() {
259
- return _ = Object.assign || function(t) {
260
- for (var e, i = 1, n = arguments.length; i < n; i++) {
261
- e = arguments[i];
262
- for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
257
+ __name(q, "q");
258
+ reactJsxRuntime_production_min.Fragment = l;
259
+ reactJsxRuntime_production_min.jsx = q;
260
+ reactJsxRuntime_production_min.jsxs = q;
261
+ jsxRuntime.exports = reactJsxRuntime_production_min;
262
+ var jsxRuntimeExports = jsxRuntime.exports, __assign = function() {
263
+ return __assign = Object.assign || function(t) {
264
+ for (var s, i = 1, n2 = arguments.length; i < n2; i++) {
265
+ s = arguments[i];
266
+ for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && (t[p2] = s[p2]);
263
267
  }
264
268
  return t;
265
- }, _.apply(this, arguments);
266
- }, st = function(t, e) {
267
- var i = {};
268
- for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (i[n] = t[n]);
269
- if (t != null && typeof Object.getOwnPropertySymbols == "function")
270
- for (var r = 0, n = Object.getOwnPropertySymbols(t); r < n.length; r++)
271
- e.indexOf(n[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[r]) && (i[n[r]] = t[n[r]]);
272
- return i;
273
- }, Y = A(function(t, e) {
274
- var i = t.icon, n = t.id, r = t.className, o = t.extend, s = st(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(n, " ").concat(r || "").trim(), a = ie("_".concat(at()));
275
- return oe(i, "".concat(n), { defIds: i.defIds, idSuffix: a.current }, _({ ref: e, className: c }, s), o);
269
+ }, __assign.apply(this, arguments);
270
+ }, __rest = function(s, e) {
271
+ var t = {};
272
+ for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && e.indexOf(p2) < 0 && (t[p2] = s[p2]);
273
+ if (s != null && typeof Object.getOwnPropertySymbols == "function")
274
+ for (var i = 0, p2 = Object.getOwnPropertySymbols(s); i < p2.length; i++)
275
+ e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p2[i]) && (t[p2[i]] = s[p2[i]]);
276
+ return t;
277
+ }, IconBase = forwardRef(function(props, ref) {
278
+ var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
279
+ return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
276
280
  });
277
- function oe(t, e, i, n, r) {
278
- return k(t.tag, _(_({ key: e }, ot(t, i, r)), n), (ct(t, i).children || []).map(function(o, s) {
279
- return oe(o, "".concat(e, "-").concat(t.tag, "-").concat(s), i, void 0, r);
281
+ function render(node, id, runtimeProps, rootProps, extend) {
282
+ return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
283
+ return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
280
284
  }));
281
285
  }
282
- function ot(t, e, i) {
283
- var n = _({}, t.attrs);
284
- i != null && i.colorChannel1 && n.fill === "colorChannel1" && (n.fill = i.colorChannel1);
285
- var r = e.defIds;
286
- return !r || r.length === 0 || (t.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + e.idSuffix), Object.entries(n).forEach(function(o) {
287
- var s = o[0], c = o[1];
288
- typeof c == "string" && (n[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
289
- })), n;
286
+ __name(render, "render");
287
+ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
288
+ var attrs = __assign({}, node.attrs);
289
+ extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
290
+ var defIds = runtimeProps.defIds;
291
+ return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a4) {
292
+ var key = _a4[0], value = _a4[1];
293
+ typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
294
+ })), attrs;
290
295
  }
291
- function ct(t, e) {
292
- var i, n = e.defIds;
293
- return !n || n.length === 0 ? t : t.tag === "defs" && (!((i = t.children) === null || i === void 0) && i.length) ? _(_({}, t), { children: t.children.map(function(r) {
294
- return typeof r.attrs.id == "string" && n && n.indexOf(r.attrs.id) > -1 ? _(_({}, r), { attrs: _(_({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
295
- }) }) : t;
296
+ __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
297
+ function replaceRuntimeIdsInDefs(node, runtimeProps) {
298
+ var _a4, defIds = runtimeProps.defIds;
299
+ return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a4 = node.children) === null || _a4 === void 0) && _a4.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
300
+ return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
301
+ }) }) : node;
296
302
  }
297
- function at() {
303
+ __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
304
+ function generateShortUuid() {
298
305
  return Math.random().toString(36).substring(2, 8);
299
306
  }
300
- Y.displayName = "UniverIcon";
301
- var dt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, ce = A(function(t, e) {
302
- return k(Y, Object.assign({}, t, {
307
+ __name(generateShortUuid, "generateShortUuid");
308
+ IconBase.displayName = "UniverIcon";
309
+ var element$1 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, CheckMarkSingle = forwardRef(function(props, ref) {
310
+ return createElement(IconBase, Object.assign({}, props, {
303
311
  id: "check-mark-single",
304
- ref: e,
305
- icon: dt
312
+ ref,
313
+ icon: element$1
306
314
  }));
307
315
  });
308
- ce.displayName = "CheckMarkSingle";
309
- var lt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z" } }] }, ae = A(function(t, e) {
310
- return k(Y, Object.assign({}, t, {
316
+ CheckMarkSingle.displayName = "CheckMarkSingle";
317
+ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z" } }] }, CloseSingle = forwardRef(function(props, ref) {
318
+ return createElement(IconBase, Object.assign({}, props, {
311
319
  id: "close-single",
312
- ref: e,
313
- icon: lt
320
+ ref,
321
+ icon: element
314
322
  }));
315
323
  });
316
- ae.displayName = "CloseSingle";
317
- const ut = "univer-zen-editor", ht = "univer-zen-editor-icon-wrapper", ft = "univer-zen-editor-icon-container", _t = "univer-zen-editor-icon-success", gt = "univer-zen-editor-icon-error", vt = "univer-zen-editor-canvas-container", C = {
318
- zenEditor: ut,
319
- zenEditorIconWrapper: ht,
320
- zenEditorIconContainer: ft,
321
- zenEditorIconSuccess: _t,
322
- zenEditorIconError: gt,
323
- zenEditorCanvasContainer: vt
324
- }, pt = "ZEN_EDITOR_PLUGIN_", mt = `${pt}ZEN_EDITOR_COMPONENT`;
325
- function St() {
326
- const t = ie(null), e = U(ne), i = U($), n = U(j);
327
- He(() => {
328
- const s = t.current;
329
- if (!s)
324
+ CloseSingle.displayName = "CloseSingle";
325
+ const zenEditor = "univer-zen-editor", zenEditorIconWrapper = "univer-zen-editor-icon-wrapper", zenEditorIconContainer = "univer-zen-editor-icon-container", zenEditorIconSuccess = "univer-zen-editor-icon-success", zenEditorIconError = "univer-zen-editor-icon-error", zenEditorCanvasContainer = "univer-zen-editor-canvas-container", styles = {
326
+ zenEditor,
327
+ zenEditorIconWrapper,
328
+ zenEditorIconContainer,
329
+ zenEditorIconSuccess,
330
+ zenEditorIconError,
331
+ zenEditorCanvasContainer
332
+ }, COMPONENT_PREFIX = "ZEN_EDITOR_PLUGIN_", ZEN_EDITOR_COMPONENT = `${COMPONENT_PREFIX}ZEN_EDITOR_COMPONENT`;
333
+ function ZenEditor() {
334
+ const editorRef = useRef(null), renderManagerService = useDependency(IRenderManagerService), zenEditorManagerService = useDependency(IZenEditorManagerService), commandService = useDependency(ICommandService);
335
+ useEffect(() => {
336
+ const editor = editorRef.current;
337
+ if (!editor)
330
338
  return;
331
- const c = e.currentRender$.subscribe((u) => {
332
- var g;
333
- if (u !== f)
339
+ const renderSubscription = renderManagerService.currentRender$.subscribe((param) => {
340
+ var _a4;
341
+ if (param !== DOCS_ZEN_EDITOR_UNIT_ID_KEY)
334
342
  return;
335
- const d = (g = e.getRenderById(f)) == null ? void 0 : g.engine;
336
- d == null || d.setContainer(s);
337
- }), a = new ResizeObserver(() => {
338
- const u = s.getBoundingClientRect();
339
- i.setPosition(u);
343
+ const engine = (_a4 = renderManagerService.getRenderById(DOCS_ZEN_EDITOR_UNIT_ID_KEY)) == null ? void 0 : _a4.engine;
344
+ engine == null || engine.setContainer(editor);
345
+ }), resizeObserver = new ResizeObserver(() => {
346
+ const editorRect = editor.getBoundingClientRect();
347
+ zenEditorManagerService.setPosition(editorRect);
340
348
  });
341
- return a.observe(s), () => {
342
- a.unobserve(s), c.unsubscribe();
349
+ return resizeObserver.observe(editor), () => {
350
+ resizeObserver.unobserve(editor), renderSubscription.unsubscribe();
343
351
  };
344
352
  }, []);
345
- function r() {
346
- n.executeCommand(F.id);
353
+ function handleCloseBtnClick() {
354
+ commandService.executeCommand(CancelZenEditCommand.id);
347
355
  }
348
- function o() {
349
- n.executeCommand(W.id);
356
+ __name(handleCloseBtnClick, "handleCloseBtnClick");
357
+ function handleConfirmBtnClick() {
358
+ commandService.executeCommand(ConfirmZenEditCommand.id);
350
359
  }
351
- return /* @__PURE__ */ I.jsxs("div", { className: C.zenEditor, children: [
352
- /* @__PURE__ */ I.jsxs("div", { className: C.zenEditorIconWrapper, children: [
353
- /* @__PURE__ */ I.jsx(
360
+ return __name(handleConfirmBtnClick, "handleConfirmBtnClick"), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.zenEditor, children: [
361
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.zenEditorIconWrapper, children: [
362
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
354
363
  "span",
355
364
  {
356
- className: G(C.zenEditorIconContainer, C.zenEditorIconError),
357
- onClick: r,
358
- children: /* @__PURE__ */ I.jsx(ae, { style: { fontSize: "22px" } })
365
+ className: clsx(styles.zenEditorIconContainer, styles.zenEditorIconError),
366
+ onClick: handleCloseBtnClick,
367
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(CloseSingle, { style: { fontSize: "22px" } })
359
368
  }
360
369
  ),
361
- /* @__PURE__ */ I.jsx(
370
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
362
371
  "span",
363
372
  {
364
- className: G(C.zenEditorIconContainer, C.zenEditorIconSuccess),
365
- onClick: o,
366
- children: /* @__PURE__ */ I.jsx(ce, { style: { fontSize: "22px" } })
373
+ className: clsx(styles.zenEditorIconContainer, styles.zenEditorIconSuccess),
374
+ onClick: handleConfirmBtnClick,
375
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(CheckMarkSingle, { style: { fontSize: "22px" } })
367
376
  }
368
377
  )
369
378
  ] }),
370
- /* @__PURE__ */ I.jsx("div", { className: C.zenEditorCanvasContainer, ref: t })
379
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.zenEditorCanvasContainer, ref: editorRef })
371
380
  ] });
372
381
  }
373
- const Et = {
374
- id: W.id,
382
+ __name(ZenEditor, "ZenEditor");
383
+ const ZenEditorConfirmShortcut = {
384
+ id: ConfirmZenEditCommand.id,
375
385
  description: "shortcut.sheet.zen-edit-confirm",
376
386
  group: "4_sheet-edit",
377
- preconditions: (t) => de(t),
378
- binding: V.ENTER | je.ALT
379
- }, It = {
380
- id: F.id,
387
+ preconditions: /* @__PURE__ */ __name((contextService) => whenZenEditorActivated(contextService), "preconditions"),
388
+ binding: KeyCode.ENTER | MetaKeys.ALT
389
+ }, ZenEditorCancelShortcut = {
390
+ id: CancelZenEditCommand.id,
381
391
  description: "shortcut.sheet.zen-edit-cancel",
382
392
  group: "4_sheet-edit",
383
- preconditions: (t) => de(t),
384
- binding: V.ESC
393
+ preconditions: /* @__PURE__ */ __name((contextService) => whenZenEditorActivated(contextService), "preconditions"),
394
+ binding: KeyCode.ESC
385
395
  };
386
- function de(t) {
387
- return t.getContextValue(Se) && t.getContextValue(Ee) && t.getContextValue(Ie) && !t.getContextValue(Ce);
396
+ function whenZenEditorActivated(contextService) {
397
+ return contextService.getContextValue(FOCUSING_DOC) && contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && contextService.getContextValue(EDITOR_ACTIVATED) && !contextService.getContextValue(FOCUSING_EDITOR_STANDALONE);
388
398
  }
389
- var Ct = Object.defineProperty, Ot = Object.getOwnPropertyDescriptor, Rt = (t, e, i, n) => {
390
- for (var r = n > 1 ? void 0 : n ? Ot(e, i) : e, o = t.length - 1, s; o >= 0; o--)
391
- (s = t[o]) && (r = (n ? s(e, i, r) : s(r)) || r);
392
- return n && r && Ct(e, i, r), r;
393
- }, R = (t, e) => (i, n) => e(i, n, t);
394
- const yt = {};
395
- let y = class extends Oe {
396
- constructor(t, e, i, n, r, o) {
397
- super(), this._config = t, this._injector = e, this._zenZoneService = i, this._commandService = n, this._menuService = r, this._shortcutService = o, this._initialize();
399
+ __name(whenZenEditorActivated, "whenZenEditorActivated");
400
+ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
401
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
402
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
403
+ return kind && result && __defProp$1(target, key, result), result;
404
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
405
+ const DefaultSheetZenEditorUiConfig = {};
406
+ var _a2;
407
+ let ZenEditorUIController = (_a2 = class extends Disposable {
408
+ constructor(_config, _injector, _zenZoneService, _commandService, _menuService, _shortcutService) {
409
+ super(), this._config = _config, this._injector = _injector, this._zenZoneService = _zenZoneService, this._commandService = _commandService, this._menuService = _menuService, this._shortcutService = _shortcutService, this._initialize();
398
410
  }
399
411
  _initialize() {
400
412
  this._initCustomComponents(), this._initCommands(), this._initMenus(), this._initShortcuts();
401
413
  }
402
414
  _initCustomComponents() {
403
- this.disposeWithMe(this._zenZoneService.set(mt, St));
415
+ this.disposeWithMe(this._zenZoneService.set(ZEN_EDITOR_COMPONENT, ZenEditor));
404
416
  }
405
417
  _initCommands() {
406
- [B, F, W].forEach((t) => {
407
- this.disposeWithMe(this._commandService.registerCommand(t));
418
+ [OpenZenEditorOperation, CancelZenEditCommand, ConfirmZenEditCommand].forEach((c) => {
419
+ this.disposeWithMe(this._commandService.registerCommand(c));
408
420
  });
409
421
  }
410
422
  _initMenus() {
411
- const { menu: t = {} } = this._config;
423
+ const { menu = {} } = this._config;
412
424
  [
413
425
  // context menu
414
- Je
415
- ].forEach((e) => {
416
- this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e), t));
426
+ ZenEditorMenuItemFactory
427
+ ].forEach((factory) => {
428
+ this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory), menu));
417
429
  });
418
430
  }
419
431
  _initShortcuts() {
420
- [Et, It].forEach((t) => {
421
- this.disposeWithMe(this._shortcutService.registerShortcut(t));
432
+ [ZenEditorConfirmShortcut, ZenEditorCancelShortcut].forEach((item) => {
433
+ this.disposeWithMe(this._shortcutService.registerShortcut(item));
422
434
  });
423
435
  }
424
- };
425
- y = Rt([
426
- Q(ee.Rendered, y),
427
- R(1, z(te)),
428
- R(2, x),
429
- R(3, j),
430
- R(4, Le),
431
- R(5, Ze)
432
- ], y);
433
- var Tt = Object.defineProperty, bt = Object.getOwnPropertyDescriptor, Nt = (t, e, i, n) => {
434
- for (var r = n > 1 ? void 0 : n ? bt(e, i) : e, o = t.length - 1, s; o >= 0; o--)
435
- (s = t[o]) && (r = (n ? s(e, i, r) : s(r)) || r);
436
- return n && r && Tt(e, i, r), r;
437
- }, q = (t, e) => (i, n) => e(i, n, t), b;
438
- let J = (b = class extends Re {
439
- constructor(t = {}, e, i) {
440
- super(), this._config = t, this._injector = e, this._localeService = i, this._initializeDependencies(this._injector), this._config = ye.deepMerge({}, yt, this._config);
436
+ }, __name(_a2, "ZenEditorUIController"), _a2);
437
+ ZenEditorUIController = __decorateClass$1([
438
+ OnLifecycle(LifecycleStages.Rendered, ZenEditorUIController),
439
+ __decorateParam$1(1, Inject(Injector)),
440
+ __decorateParam$1(2, IZenZoneService),
441
+ __decorateParam$1(3, ICommandService),
442
+ __decorateParam$1(4, IMenuService),
443
+ __decorateParam$1(5, IShortcutService)
444
+ ], ZenEditorUIController);
445
+ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
446
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
447
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
448
+ return kind && result && __defProp2(target, key, result), result;
449
+ }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a3;
450
+ let UniverSheetsZenEditorPlugin = (_a3 = class extends Plugin {
451
+ constructor(_config = {}, _injector, _localeService) {
452
+ super(), this._config = _config, this._injector = _injector, this._localeService = _localeService, this._initializeDependencies(this._injector), this._config = Tools.deepMerge({}, DefaultSheetZenEditorUiConfig, this._config);
441
453
  }
442
- _initializeDependencies(t) {
454
+ _initializeDependencies(injector) {
443
455
  [
444
456
  [
445
- y,
457
+ ZenEditorUIController,
446
458
  {
447
- useFactory: () => this._injector.createInstance(y, this._config)
459
+ useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(ZenEditorUIController, this._config), "useFactory")
448
460
  }
449
461
  ],
450
- [N],
451
- [$, { useClass: Ke }]
452
- ].forEach((i) => t.add(i));
462
+ [ZenEditorController],
463
+ [IZenEditorManagerService, { useClass: ZenEditorManagerService }]
464
+ ].forEach((dependency) => injector.add(dependency));
453
465
  }
454
- }, E(b, "pluginName", "zen-editor"), E(b, "type", T.UNIVER_DOC), b);
455
- J = Nt([
456
- q(1, z(te)),
457
- q(2, z(Te))
458
- ], J);
466
+ }, __name(_a3, "UniverSheetsZenEditorPlugin"), __publicField(_a3, "pluginName", "zen-editor"), __publicField(_a3, "type", UniverInstanceType.UNIVER_SHEET), _a3);
467
+ UniverSheetsZenEditorPlugin = __decorateClass([
468
+ __decorateParam(1, Inject(Injector)),
469
+ __decorateParam(2, Inject(LocaleService))
470
+ ], UniverSheetsZenEditorPlugin);
459
471
  export {
460
- F as CancelZenEditCommand,
461
- W as ConfirmZenEditCommand,
462
- B as OpenZenEditorOperation,
463
- J as UniverSheetsZenEditorPlugin
472
+ CancelZenEditCommand,
473
+ ConfirmZenEditCommand,
474
+ OpenZenEditorOperation,
475
+ UniverSheetsZenEditorPlugin
464
476
  };
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets"),require("react"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs","@univerjs/engine-render","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/sheets","react","clsx"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.UniverSheetsZenEditor={},d.UniverCore,d.UniverDocs,d.UniverEngineRender,d.UniverSheetsUi,d.UniverUi,d.rxjs,d.UniverSheets,d.React,d.clsx))})(this,function(d,s,E,D,U,_,k,z,S,Y){"use strict";var ye=Object.defineProperty;var De=(d,s,E)=>s in d?ye(d,s,{enumerable:!0,configurable:!0,writable:!0,value:E}):d[s]=E;var R=(d,s,E)=>De(d,typeof s!="symbol"?s+"":s,E);var L;const x={id:"zen-editor.operation.open-zen-editor",type:s.CommandType.OPERATION,handler:n=>!0};class q{constructor(){R(this,"_position",null);R(this,"_position$",new k.BehaviorSubject(null));R(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(t){this._position=t,this._refresh(t)}getPosition(){return this._position}_refresh(t){this._position$.next(t)}}const A=s.createIdentifier("univer.sheet-zen-editor-manager.service");var J=Object.defineProperty,Q=Object.getOwnPropertyDescriptor,ee=(n,t,i,e)=>{for(var r=e>1?void 0:e?Q(t,i):t,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&J(t,i,r),r},m=(n,t)=>(i,e)=>t(i,e,n);let M=class extends s.RxDisposable{constructor(t,i,e,r,c,o,a,l){super();R(this,"_zenEditorInitialState",!1);this._univerInstanceService=t,this._zenEditorManagerService=i,this._renderManagerService=e,this._commandService=r,this._zenZoneService=c,this._editorBridgeService=o,this._undoRedoService=a,this._textSelectionManagerService=l,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const t={id:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${s.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],customBlocks:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:595,height:842},documentFlavor:s.DocumentFlavor.MODERN,marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};return this._univerInstanceService.createUnit(s.UniverInstanceType.UNIVER_DOC,t)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(k.takeUntil(this.dispose$)).subscribe(t=>{var l;if(t==null)return;const i=U.getEditorObject(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService),e=this._univerInstanceService.getUniverDocInstance(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(i==null||e==null)return;const{width:r,height:c}=t,{engine:o}=i,a=(l=this._renderManagerService.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:l.with(E.DocSkeletonManagerService).getSkeleton();requestIdleCallback(()=>{o.resizeBySize(r,c),this._calculatePagePosition(i),a&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){var c;this._zenEditorInitialState||(this._createZenEditorInstance(),this._zenEditorInitialState=!0),this._zenZoneService.open();const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);this._undoRedoService.clearUndoRedo(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._univerInstanceService.focusUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._univerInstanceService.setCurrentUnitForType(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:D.DeviceInputEventType.PointerDown,unitId:(c=t==null?void 0:t.getUnitId())!=null?c:""});const e=this._editorBridgeService.getLatestEditCellState();if(e==null)return;this._editorSyncHandler(e);const r=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(r)}_editorSyncHandler(t){var o,a;const i=(o=t.documentLayoutObject.documentModel)==null?void 0:o.getBody(),e=i==null?void 0:i.dataStream,r=i==null?void 0:i.paragraphs;let c=[];e==null||r==null||((a=i==null?void 0:i.textRuns)!=null&&a.length&&(c=i==null?void 0:i.textRuns),this._syncContentAndRender(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,e,r,c))}_syncContentAndRender(t,i,e,r=[],c=[],o={},a=[],l=[]){var C;const f=[s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],u=(C=this._renderManagerService.getRenderById(t))==null?void 0:C.with(E.DocSkeletonManagerService),g=u==null?void 0:u.getSkeleton(),I=this._univerInstanceService.getUniverDocInstance(t),p=u==null?void 0:u.getViewModel();if(I==null||p==null||g==null)return;const v=I.getBody(),y=I.getSnapshot();v.dataStream=i,v.paragraphs=e,v.customBlocks=c,v.customRanges=l,y.drawings=o,y.drawingsOrder=a,t===s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(v.textRuns=[]),r.length>0&&(v.textRuns=r),p.reset(I);const N=this._getDocObject();N!=null&&(g.calculate(),f.includes(t)&&N.document.makeDirty())}_calculatePagePosition(t){const{document:i,scene:e,docBackground:r}=t,c=e==null?void 0:e.getParent(),{width:o,height:a,pageMarginLeft:l,pageMarginTop:f}=i;if(c==null||o===Number.POSITIVE_INFINITY||a===Number.POSITIVE_INFINITY)return;const{width:u,height:g}=c;let I=0,p=0,v=0,y=0,N=Number.POSITIVE_INFINITY;const{scaleX:C,scaleY:Ne}=e.getAncestorScale();u>(o+l*2)*C?(I=u/2-o*C/2,I/=C,v=(u-l*2)/C,N=0):(I=l,v=o+l*2,N=(v-u/C)/2),g>a?(p=g/2-a/2,y=(g-f*2)/Ne):(p=f,y=a+f*2),e.resize(v,y+200),i.translate(I,p),r.translate(I,p);const B=e.getViewport(E.VIEWPORT_KEY.VIEW_MAIN);if(N!==Number.POSITIVE_INFINITY&&B!=null){const Re=B.transScroll2ViewportScrollValue(N,0).x;B.scrollToBarPos({x:Re})}return this}_commandExecutedListener(){const t=[x.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{t.includes(e.id)&&this._handleOpenZenEditor()}));const i=[E.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const r=e.params,{unitId:c}=r;if(c===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY){const o=this._univerInstanceService.getUniverDocInstance(c),a=o==null?void 0:o.getBody(),l=a==null?void 0:a.dataStream,f=a==null?void 0:a.paragraphs,u=a==null?void 0:a.textRuns,g=a==null?void 0:a.customBlocks,I=o==null?void 0:o.getDrawings(),p=o==null?void 0:o.getDrawingsOrder(),v=o==null?void 0:o.getCustomRanges();if(this._editorBridgeService.changeEditorDirty(!0),l==null||f==null)return;this._syncContentAndRender(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l,f,u,g,I,p,v)}}}))}_getDocObject(){return E.getDocObject(this._univerInstanceService,this._renderManagerService)}};M=ee([s.OnLifecycle(s.LifecycleStages.Steady,M),m(0,s.IUniverInstanceService),m(1,A),m(2,D.IRenderManagerService),m(3,s.ICommandService),m(4,_.IZenZoneService),m(5,U.IEditorBridgeService),m(6,s.IUndoRedoService),m(7,s.Inject(E.TextSelectionManagerService))],M);const P={id:"zen-editor.command.cancel-zen-edit",type:s.CommandType.COMMAND,handler:async n=>{const t=n.get(_.IZenZoneService),i=n.get(U.IEditorBridgeService),e=n.get(s.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:D.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC,unitId:""}),t.close();const c=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);return c?(e.focusUnit(c.getUnitId()),i.refreshEditCellState(),!0):!1}},Z={id:"zen-editor.command.confirm-zen-edit",type:s.CommandType.COMMAND,handler:async n=>{const t=n.get(_.IZenZoneService),i=n.get(U.IEditorBridgeService),e=n.get(s.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:D.DeviceInputEventType.PointerDown,unitId:""}),t.close();const c=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);return c?(e.focusUnit(c.getUnitId()),i.refreshEditCellState(),!0):!1}};function te(n){return{id:x.id,group:_.MenuGroup.CONTEXT_MENU_OTHERS,type:_.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[_.MenuPosition.CONTEXT_MENU],disabled$:U.getCurrentRangeDisable$(n,{workbookTypes:[z.WorkbookEditablePermission],worksheetTypes:[z.WorksheetEditPermission,z.WorksheetSetCellValuePermission,z.WorksheetSetCellStylePermission],rangeTypes:[z.RangeProtectionPermissionEditPoint]})}}var F={exports:{}},w={};/**
1
+ (function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets"),require("react"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs","@univerjs/engine-render","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/sheets","react","clsx"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverSheetsZenEditor={},global.UniverCore,global.UniverDocs,global.UniverEngineRender,global.UniverSheetsUi,global.UniverUi,global.rxjs,global.UniverSheets,global.React,global.clsx))})(this,function(exports2,core,docs,engineRender,sheetsUi,ui,rxjs,sheets,require$$0,clsx){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c;const OpenZenEditorOperation={id:"zen-editor.operation.open-zen-editor",type:core.CommandType.OPERATION,handler:__name(accessor=>!0,"handler")},_ZenEditorManagerService=class _ZenEditorManagerService{constructor(){__publicField(this,"_position",null);__publicField(this,"_position$",new rxjs.BehaviorSubject(null));__publicField(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(param){this._position=param,this._refresh(param)}getPosition(){return this._position}_refresh(param){this._position$.next(param)}};__name(_ZenEditorManagerService,"ZenEditorManagerService");let ZenEditorManagerService=_ZenEditorManagerService;const IZenEditorManagerService=core.createIdentifier("univer.sheet-zen-editor-manager.service");var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");let ZenEditorController=(_a=class extends core.RxDisposable{constructor(_univerInstanceService,_zenEditorManagerService,_renderManagerService,_commandService,_zenZoneService,_editorBridgeService,_undoRedoService,_textSelectionManagerService){super();__publicField(this,"_zenEditorInitialState",!1);this._univerInstanceService=_univerInstanceService,this._zenEditorManagerService=_zenEditorManagerService,this._renderManagerService=_renderManagerService,this._commandService=_commandService,this._zenZoneService=_zenZoneService,this._editorBridgeService=_editorBridgeService,this._undoRedoService=_undoRedoService,this._textSelectionManagerService=_textSelectionManagerService,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const INITIAL_SNAPSHOT={id:core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${core.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],customBlocks:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:595,height:842},documentFlavor:core.DocumentFlavor.MODERN,marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};return this._univerInstanceService.createUnit(core.UniverInstanceType.UNIVER_DOC,INITIAL_SNAPSHOT)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(rxjs.takeUntil(this.dispose$)).subscribe(position=>{var _a2;if(position==null)return;const editorObject=sheetsUi.getEditorObject(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService),zenEditorDataModel=this._univerInstanceService.getUniverDocInstance(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(editorObject==null||zenEditorDataModel==null)return;const{width,height}=position,{engine}=editorObject,skeleton=(_a2=this._renderManagerService.getRenderById(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:_a2.with(docs.DocSkeletonManagerService).getSkeleton();requestIdleCallback(()=>{engine.resizeBySize(width,height),this._calculatePagePosition(editorObject),skeleton&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){var _a2;this._zenEditorInitialState||(this._createZenEditorInstance(),this._zenEditorInitialState=!0),this._zenZoneService.open();const currentSheet=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);this._undoRedoService.clearUndoRedo(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._univerInstanceService.focusUnit(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._univerInstanceService.setCurrentUnitForType(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:engineRender.DeviceInputEventType.PointerDown,unitId:(_a2=currentSheet==null?void 0:currentSheet.getUnitId())!=null?_a2:""});const editCellState=this._editorBridgeService.getLatestEditCellState();if(editCellState==null)return;this._editorSyncHandler(editCellState);const textRanges=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(textRanges)}_editorSyncHandler(param){var _a2,_b2;const body=(_a2=param.documentLayoutObject.documentModel)==null?void 0:_a2.getBody(),dataStream=body==null?void 0:body.dataStream,paragraphs=body==null?void 0:body.paragraphs;let textRuns=[];dataStream==null||paragraphs==null||((_b2=body==null?void 0:body.textRuns)!=null&&_b2.length&&(textRuns=body==null?void 0:body.textRuns),this._syncContentAndRender(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,dataStream,paragraphs,textRuns))}_syncContentAndRender(unitId,dataStream,paragraphs,textRuns=[],customBlocks=[],drawings={},drawingsOrder=[],customRanges=[]){var _a2;const INCLUDE_LIST=[core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],docSkeletonManagerService=(_a2=this._renderManagerService.getRenderById(unitId))==null?void 0:_a2.with(docs.DocSkeletonManagerService),skeleton=docSkeletonManagerService==null?void 0:docSkeletonManagerService.getSkeleton(),docDataModel=this._univerInstanceService.getUniverDocInstance(unitId),docViewModel=docSkeletonManagerService==null?void 0:docSkeletonManagerService.getViewModel();if(docDataModel==null||docViewModel==null||skeleton==null)return;const docBody=docDataModel.getBody(),snapshot=docDataModel.getSnapshot();docBody.dataStream=dataStream,docBody.paragraphs=paragraphs,docBody.customBlocks=customBlocks,docBody.customRanges=customRanges,snapshot.drawings=drawings,snapshot.drawingsOrder=drawingsOrder,unitId===core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(docBody.textRuns=[]),textRuns.length>0&&(docBody.textRuns=textRuns),docViewModel.reset(docDataModel);const currentRender=this._getDocObject();currentRender!=null&&(skeleton.calculate(),INCLUDE_LIST.includes(unitId)&&currentRender.document.makeDirty())}_calculatePagePosition(currentRender){const{document:docsComponent,scene,docBackground}=currentRender,parent=scene==null?void 0:scene.getParent(),{width:docsWidth,height:docsHeight,pageMarginLeft,pageMarginTop}=docsComponent;if(parent==null||docsWidth===Number.POSITIVE_INFINITY||docsHeight===Number.POSITIVE_INFINITY)return;const{width:engineWidth,height:engineHeight}=parent;let docsLeft=0,docsTop=0,sceneWidth=0,sceneHeight=0,scrollToX=Number.POSITIVE_INFINITY;const{scaleX,scaleY}=scene.getAncestorScale();engineWidth>(docsWidth+pageMarginLeft*2)*scaleX?(docsLeft=engineWidth/2-docsWidth*scaleX/2,docsLeft/=scaleX,sceneWidth=(engineWidth-pageMarginLeft*2)/scaleX,scrollToX=0):(docsLeft=pageMarginLeft,sceneWidth=docsWidth+pageMarginLeft*2,scrollToX=(sceneWidth-engineWidth/scaleX)/2),engineHeight>docsHeight?(docsTop=engineHeight/2-docsHeight/2,sceneHeight=(engineHeight-pageMarginTop*2)/scaleY):(docsTop=pageMarginTop,sceneHeight=docsHeight+pageMarginTop*2),scene.resize(sceneWidth,sceneHeight+200),docsComponent.translate(docsLeft,docsTop),docBackground.translate(docsLeft,docsTop);const viewport=scene.getViewport(docs.VIEWPORT_KEY.VIEW_MAIN);if(scrollToX!==Number.POSITIVE_INFINITY&&viewport!=null){const actualX=viewport.transScroll2ViewportScrollValue(scrollToX,0).x;viewport.scrollToBarPos({x:actualX})}return this}_commandExecutedListener(){const updateCommandList=[OpenZenEditorOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(command=>{updateCommandList.includes(command.id)&&this._handleOpenZenEditor()}));const editCommandList=[docs.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(command=>{if(editCommandList.includes(command.id)){const params=command.params,{unitId}=params;if(unitId===core.DOCS_ZEN_EDITOR_UNIT_ID_KEY){const editorDocDataModel=this._univerInstanceService.getUniverDocInstance(unitId),docBody=editorDocDataModel==null?void 0:editorDocDataModel.getBody(),dataStream=docBody==null?void 0:docBody.dataStream,paragraphs=docBody==null?void 0:docBody.paragraphs,textRuns=docBody==null?void 0:docBody.textRuns,customBlocks=docBody==null?void 0:docBody.customBlocks,drawings=editorDocDataModel==null?void 0:editorDocDataModel.getDrawings(),drawingsOrder=editorDocDataModel==null?void 0:editorDocDataModel.getDrawingsOrder(),customRanges=editorDocDataModel==null?void 0:editorDocDataModel.getCustomRanges();if(this._editorBridgeService.changeEditorDirty(!0),dataStream==null||paragraphs==null)return;this._syncContentAndRender(core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,dataStream,paragraphs,textRuns,customBlocks,drawings,drawingsOrder,customRanges)}}}))}_getDocObject(){return docs.getDocObject(this._univerInstanceService,this._renderManagerService)}},__name(_a,"ZenEditorController"),_a);ZenEditorController=__decorateClass$2([core.OnLifecycle(core.LifecycleStages.Steady,ZenEditorController),__decorateParam$2(0,core.IUniverInstanceService),__decorateParam$2(1,IZenEditorManagerService),__decorateParam$2(2,engineRender.IRenderManagerService),__decorateParam$2(3,core.ICommandService),__decorateParam$2(4,ui.IZenZoneService),__decorateParam$2(5,sheetsUi.IEditorBridgeService),__decorateParam$2(6,core.IUndoRedoService),__decorateParam$2(7,core.Inject(docs.TextSelectionManagerService))],ZenEditorController);const CancelZenEditCommand={id:"zen-editor.command.cancel-zen-edit",type:core.CommandType.COMMAND,handler:__name(async accessor=>{const zenZoneEditorService=accessor.get(ui.IZenZoneService),editorBridgeService=accessor.get(sheetsUi.IEditorBridgeService),univerInstanceManager=accessor.get(core.IUniverInstanceService);editorBridgeService.isVisible().visible&&editorBridgeService.changeVisible({visible:!1,eventType:engineRender.DeviceInputEventType.Keyboard,keycode:ui.KeyCode.ESC,unitId:""}),zenZoneEditorService.close();const currentSheetInstance=univerInstanceManager.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);return currentSheetInstance?(univerInstanceManager.focusUnit(currentSheetInstance.getUnitId()),editorBridgeService.refreshEditCellState(),!0):!1},"handler")},ConfirmZenEditCommand={id:"zen-editor.command.confirm-zen-edit",type:core.CommandType.COMMAND,handler:__name(async accessor=>{const zenZoneEditorService=accessor.get(ui.IZenZoneService),editorBridgeService=accessor.get(sheetsUi.IEditorBridgeService),univerInstanceManager=accessor.get(core.IUniverInstanceService);editorBridgeService.isVisible().visible&&editorBridgeService.changeVisible({visible:!1,eventType:engineRender.DeviceInputEventType.PointerDown,unitId:""}),zenZoneEditorService.close();const currentSheetInstance=univerInstanceManager.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);return currentSheetInstance?(univerInstanceManager.focusUnit(currentSheetInstance.getUnitId()),editorBridgeService.refreshEditCellState(),!0):!1},"handler")};function ZenEditorMenuItemFactory(accessor){return{id:OpenZenEditorOperation.id,group:ui.MenuGroup.CONTEXT_MENU_OTHERS,type:ui.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[ui.MenuPosition.CONTEXT_MENU],disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellValuePermission,sheets.WorksheetSetCellStylePermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]})}}__name(ZenEditorMenuItemFactory,"ZenEditorMenuItemFactory");var jsxRuntime={exports:{}},reactJsxRuntime_production_min={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ne=S,ie=Symbol.for("react.element"),re=Symbol.for("react.fragment"),se=Object.prototype.hasOwnProperty,oe=ne.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ce={key:!0,ref:!0,__self:!0,__source:!0};function K(n,t,i){var e,r={},c=null,o=null;i!==void 0&&(c=""+i),t.key!==void 0&&(c=""+t.key),t.ref!==void 0&&(o=t.ref);for(e in t)se.call(t,e)&&!ce.hasOwnProperty(e)&&(r[e]=t[e]);if(n&&n.defaultProps)for(e in t=n.defaultProps,t)r[e]===void 0&&(r[e]=t[e]);return{$$typeof:ie,type:n,key:c,ref:o,props:r,_owner:oe.current}}w.Fragment=re,w.jsx=K,w.jsxs=K,F.exports=w;var O=F.exports,h=function(){return h=Object.assign||function(n){for(var t,i=1,e=arguments.length;i<e;i++){t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},h.apply(this,arguments)},ae=function(n,t){var i={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.indexOf(e)<0&&(i[e]=n[e]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(n);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(n,e[r])&&(i[e[r]]=n[e[r]]);return i},V=S.forwardRef(function(n,t){var i=n.icon,e=n.id,r=n.className,c=n.extend,o=ae(n,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),l=S.useRef("_".concat(ue()));return W(i,"".concat(e),{defIds:i.defIds,idSuffix:l.current},h({ref:t,className:a},o),c)});function W(n,t,i,e,r){return S.createElement(n.tag,h(h({key:t},de(n,i,r)),e),(le(n,i).children||[]).map(function(c,o){return W(c,"".concat(t,"-").concat(n.tag,"-").concat(o),i,void 0,r)}))}function de(n,t,i){var e=h({},n.attrs);i!=null&&i.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=i.colorChannel1);var r=t.defIds;return!r||r.length===0||(n.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(c){var o=c[0],a=c[1];typeof a=="string"&&(e[o]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function le(n,t){var i,e=t.defIds;return!e||e.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?h(h({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?h(h({},r),{attrs:h(h({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):n}function ue(){return Math.random().toString(36).substring(2,8)}V.displayName="UniverIcon";var _e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},H=S.forwardRef(function(n,t){return S.createElement(V,Object.assign({},n,{id:"check-mark-single",ref:t,icon:_e}))});H.displayName="CheckMarkSingle";var ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},X=S.forwardRef(function(n,t){return S.createElement(V,Object.assign({},n,{id:"close-single",ref:t,icon:ve}))});X.displayName="CloseSingle";const T={zenEditor:"univer-zen-editor",zenEditorIconWrapper:"univer-zen-editor-icon-wrapper",zenEditorIconContainer:"univer-zen-editor-icon-container",zenEditorIconSuccess:"univer-zen-editor-icon-success",zenEditorIconError:"univer-zen-editor-icon-error",zenEditorCanvasContainer:"univer-zen-editor-canvas-container"},he="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT";function fe(){const n=S.useRef(null),t=s.useDependency(D.IRenderManagerService),i=s.useDependency(A),e=s.useDependency(s.ICommandService);S.useEffect(()=>{const o=n.current;if(!o)return;const a=t.currentRender$.subscribe(f=>{var g;if(f!==s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)return;const u=(g=t.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:g.engine;u==null||u.setContainer(o)}),l=new ResizeObserver(()=>{const f=o.getBoundingClientRect();i.setPosition(f)});return l.observe(o),()=>{l.unobserve(o),a.unsubscribe()}},[]);function r(){e.executeCommand(P.id)}function c(){e.executeCommand(Z.id)}return O.jsxs("div",{className:T.zenEditor,children:[O.jsxs("div",{className:T.zenEditorIconWrapper,children:[O.jsx("span",{className:Y(T.zenEditorIconContainer,T.zenEditorIconError),onClick:r,children:O.jsx(X,{style:{fontSize:"22px"}})}),O.jsx("span",{className:Y(T.zenEditorIconContainer,T.zenEditorIconSuccess),onClick:c,children:O.jsx(H,{style:{fontSize:"22px"}})})]}),O.jsx("div",{className:T.zenEditorCanvasContainer,ref:n})]})}const Ie={id:Z.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:n=>$(n),binding:_.KeyCode.ENTER|_.MetaKeys.ALT},Ee={id:P.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:n=>$(n),binding:_.KeyCode.ESC};function $(n){return n.getContextValue(s.FOCUSING_DOC)&&n.getContextValue(s.FOCUSING_UNIVER_EDITOR)&&n.getContextValue(s.EDITOR_ACTIVATED)&&!n.getContextValue(s.FOCUSING_EDITOR_STANDALONE)}var ge=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,pe=(n,t,i,e)=>{for(var r=e>1?void 0:e?Se(t,i):t,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&ge(t,i,r),r},b=(n,t)=>(i,e)=>t(i,e,n);const me={};let j=class extends s.Disposable{constructor(n,t,i,e,r,c){super(),this._config=n,this._injector=t,this._zenZoneService=i,this._commandService=e,this._menuService=r,this._shortcutService=c,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(he,fe))}_initCommands(){[x,P,Z].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initMenus(){const{menu:n={}}=this._config;[te].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t),n))})}_initShortcuts(){[Ie,Ee].forEach(n=>{this.disposeWithMe(this._shortcutService.registerShortcut(n))})}};j=pe([s.OnLifecycle(s.LifecycleStages.Rendered,j),b(1,s.Inject(s.Injector)),b(2,_.IZenZoneService),b(3,s.ICommandService),b(4,_.IMenuService),b(5,_.IShortcutService)],j);var Ce=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Te=(n,t,i,e)=>{for(var r=e>1?void 0:e?Oe(t,i):t,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&Ce(t,i,r),r},G=(n,t)=>(i,e)=>t(i,e,n);d.UniverSheetsZenEditorPlugin=(L=class extends s.Plugin{constructor(t={},i,e){super(),this._config=t,this._injector=i,this._localeService=e,this._initializeDependencies(this._injector),this._config=s.Tools.deepMerge({},me,this._config)}_initializeDependencies(t){[[j,{useFactory:()=>this._injector.createInstance(j,this._config)}],[M],[A,{useClass:q}]].forEach(e=>t.add(e))}},R(L,"pluginName","zen-editor"),R(L,"type",s.UniverInstanceType.UNIVER_DOC),L),d.UniverSheetsZenEditorPlugin=Te([G(1,s.Inject(s.Injector)),G(2,s.Inject(s.LocaleService))],d.UniverSheetsZenEditorPlugin),d.CancelZenEditCommand=P,d.ConfirmZenEditCommand=Z,d.OpenZenEditorOperation=x,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
9
+ */var f=require$$0,k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};function q(c,a,g){var b,d={},e=null,h=null;g!==void 0&&(e=""+g),a.key!==void 0&&(e=""+a.key),a.ref!==void 0&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)d[b]===void 0&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}__name(q,"q"),reactJsxRuntime_production_min.Fragment=l,reactJsxRuntime_production_min.jsx=q,reactJsxRuntime_production_min.jsxs=q,jsxRuntime.exports=reactJsxRuntime_production_min;var jsxRuntimeExports=jsxRuntime.exports,__assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n2=arguments.length;i<n2;i++){s=arguments[i];for(var p2 in s)Object.prototype.hasOwnProperty.call(s,p2)&&(t[p2]=s[p2])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p2 in s)Object.prototype.hasOwnProperty.call(s,p2)&&e.indexOf(p2)<0&&(t[p2]=s[p2]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p2=Object.getOwnPropertySymbols(s);i<p2.length;i++)e.indexOf(p2[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p2[i])&&(t[p2[i]]=s[p2[i]]);return t},IconBase=require$$0.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=require$$0.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return require$$0.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a2){var key=_a2[0],value=_a2[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a2,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a2=node.children)===null||_a2===void 0)&&_a2.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid"),IconBase.displayName="UniverIcon";var element$1={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},CheckMarkSingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"check-mark-single",ref,icon:element$1}))});CheckMarkSingle.displayName="CheckMarkSingle";var element={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},CloseSingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"close-single",ref,icon:element}))});CloseSingle.displayName="CloseSingle";const styles={zenEditor:"univer-zen-editor",zenEditorIconWrapper:"univer-zen-editor-icon-wrapper",zenEditorIconContainer:"univer-zen-editor-icon-container",zenEditorIconSuccess:"univer-zen-editor-icon-success",zenEditorIconError:"univer-zen-editor-icon-error",zenEditorCanvasContainer:"univer-zen-editor-canvas-container"},ZEN_EDITOR_COMPONENT="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT";function ZenEditor(){const editorRef=require$$0.useRef(null),renderManagerService=core.useDependency(engineRender.IRenderManagerService),zenEditorManagerService=core.useDependency(IZenEditorManagerService),commandService=core.useDependency(core.ICommandService);require$$0.useEffect(()=>{const editor=editorRef.current;if(!editor)return;const renderSubscription=renderManagerService.currentRender$.subscribe(param=>{var _a2;if(param!==core.DOCS_ZEN_EDITOR_UNIT_ID_KEY)return;const engine=(_a2=renderManagerService.getRenderById(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:_a2.engine;engine==null||engine.setContainer(editor)}),resizeObserver=new ResizeObserver(()=>{const editorRect=editor.getBoundingClientRect();zenEditorManagerService.setPosition(editorRect)});return resizeObserver.observe(editor),()=>{resizeObserver.unobserve(editor),renderSubscription.unsubscribe()}},[]);function handleCloseBtnClick(){commandService.executeCommand(CancelZenEditCommand.id)}__name(handleCloseBtnClick,"handleCloseBtnClick");function handleConfirmBtnClick(){commandService.executeCommand(ConfirmZenEditCommand.id)}return __name(handleConfirmBtnClick,"handleConfirmBtnClick"),jsxRuntimeExports.jsxs("div",{className:styles.zenEditor,children:[jsxRuntimeExports.jsxs("div",{className:styles.zenEditorIconWrapper,children:[jsxRuntimeExports.jsx("span",{className:clsx(styles.zenEditorIconContainer,styles.zenEditorIconError),onClick:handleCloseBtnClick,children:jsxRuntimeExports.jsx(CloseSingle,{style:{fontSize:"22px"}})}),jsxRuntimeExports.jsx("span",{className:clsx(styles.zenEditorIconContainer,styles.zenEditorIconSuccess),onClick:handleConfirmBtnClick,children:jsxRuntimeExports.jsx(CheckMarkSingle,{style:{fontSize:"22px"}})})]}),jsxRuntimeExports.jsx("div",{className:styles.zenEditorCanvasContainer,ref:editorRef})]})}__name(ZenEditor,"ZenEditor");const ZenEditorConfirmShortcut={id:ConfirmZenEditCommand.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:__name(contextService=>whenZenEditorActivated(contextService),"preconditions"),binding:ui.KeyCode.ENTER|ui.MetaKeys.ALT},ZenEditorCancelShortcut={id:CancelZenEditCommand.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:__name(contextService=>whenZenEditorActivated(contextService),"preconditions"),binding:ui.KeyCode.ESC};function whenZenEditorActivated(contextService){return contextService.getContextValue(core.FOCUSING_DOC)&&contextService.getContextValue(core.FOCUSING_UNIVER_EDITOR)&&contextService.getContextValue(core.EDITOR_ACTIVATED)&&!contextService.getContextValue(core.FOCUSING_EDITOR_STANDALONE)}__name(whenZenEditorActivated,"whenZenEditorActivated");var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");const DefaultSheetZenEditorUiConfig={};let ZenEditorUIController=(_b=class extends core.Disposable{constructor(_config,_injector,_zenZoneService,_commandService,_menuService,_shortcutService){super(),this._config=_config,this._injector=_injector,this._zenZoneService=_zenZoneService,this._commandService=_commandService,this._menuService=_menuService,this._shortcutService=_shortcutService,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(ZEN_EDITOR_COMPONENT,ZenEditor))}_initCommands(){[OpenZenEditorOperation,CancelZenEditCommand,ConfirmZenEditCommand].forEach(c=>{this.disposeWithMe(this._commandService.registerCommand(c))})}_initMenus(){const{menu={}}=this._config;[ZenEditorMenuItemFactory].forEach(factory=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory),menu))})}_initShortcuts(){[ZenEditorConfirmShortcut,ZenEditorCancelShortcut].forEach(item=>{this.disposeWithMe(this._shortcutService.registerShortcut(item))})}},__name(_b,"ZenEditorUIController"),_b);ZenEditorUIController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Rendered,ZenEditorUIController),__decorateParam$1(1,core.Inject(core.Injector)),__decorateParam$1(2,ui.IZenZoneService),__decorateParam$1(3,core.ICommandService),__decorateParam$1(4,ui.IMenuService),__decorateParam$1(5,ui.IShortcutService)],ZenEditorUIController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam");exports2.UniverSheetsZenEditorPlugin=(_c=class extends core.Plugin{constructor(_config={},_injector,_localeService){super(),this._config=_config,this._injector=_injector,this._localeService=_localeService,this._initializeDependencies(this._injector),this._config=core.Tools.deepMerge({},DefaultSheetZenEditorUiConfig,this._config)}_initializeDependencies(injector){[[ZenEditorUIController,{useFactory:__name(()=>this._injector.createInstance(ZenEditorUIController,this._config),"useFactory")}],[ZenEditorController],[IZenEditorManagerService,{useClass:ZenEditorManagerService}]].forEach(dependency=>injector.add(dependency))}},__name(_c,"UniverSheetsZenEditorPlugin"),__publicField(_c,"pluginName","zen-editor"),__publicField(_c,"type",core.UniverInstanceType.UNIVER_SHEET),_c),exports2.UniverSheetsZenEditorPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.Inject(core.LocaleService))],exports2.UniverSheetsZenEditorPlugin),exports2.CancelZenEditCommand=CancelZenEditCommand,exports2.ConfirmZenEditCommand=ConfirmZenEditCommand,exports2.OpenZenEditorOperation=OpenZenEditorOperation,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-zen-editor",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "private": false,
5
5
  "description": "Zen Editor plugin for Univer Sheets.",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,33 +53,33 @@
53
53
  "clsx": ">=2.0.0",
54
54
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
55
55
  "rxjs": ">=7.0.0",
56
- "@univerjs/core": "0.2.5",
57
- "@univerjs/engine-render": "0.2.5",
58
- "@univerjs/docs": "0.2.5",
59
- "@univerjs/sheets": "0.2.5",
60
- "@univerjs/sheets-ui": "0.2.5",
61
- "@univerjs/ui": "0.2.5"
56
+ "@univerjs/core": "0.2.7",
57
+ "@univerjs/docs": "0.2.7",
58
+ "@univerjs/engine-render": "0.2.7",
59
+ "@univerjs/sheets": "0.2.7",
60
+ "@univerjs/sheets-ui": "0.2.7",
61
+ "@univerjs/ui": "0.2.7"
62
62
  },
63
63
  "dependencies": {
64
- "@univerjs/icons": "^0.1.65",
65
- "@univerjs/sheets": "0.2.5"
64
+ "@univerjs/icons": "^0.1.72",
65
+ "@univerjs/sheets": "0.2.7"
66
66
  },
67
67
  "devDependencies": {
68
68
  "clsx": "^2.1.1",
69
69
  "less": "^4.2.0",
70
70
  "react": "18.3.1",
71
71
  "rxjs": "^7.8.1",
72
- "typescript": "^5.5.3",
73
- "vite": "^5.3.4",
74
- "vitest": "^2.0.3",
75
- "@univerjs/core": "0.2.5",
76
- "@univerjs/design": "0.2.5",
77
- "@univerjs/engine-render": "0.2.5",
78
- "@univerjs/shared": "0.2.5",
79
- "@univerjs/sheets": "0.2.5",
80
- "@univerjs/sheets-ui": "0.2.5",
81
- "@univerjs/ui": "0.2.5",
82
- "@univerjs/docs": "0.2.5"
72
+ "typescript": "^5.5.4",
73
+ "vite": "^5.3.5",
74
+ "vitest": "^2.0.5",
75
+ "@univerjs/core": "0.2.7",
76
+ "@univerjs/docs": "0.2.7",
77
+ "@univerjs/engine-render": "0.2.7",
78
+ "@univerjs/shared": "0.2.7",
79
+ "@univerjs/design": "0.2.7",
80
+ "@univerjs/sheets": "0.2.7",
81
+ "@univerjs/sheets-ui": "0.2.7",
82
+ "@univerjs/ui": "0.2.7"
83
83
  },
84
84
  "univerSpace": {
85
85
  ".": {