@univerjs/sheets-zen-editor 0.2.10 → 0.2.12

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 __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"),docsUi=require("@univerjs/docs-ui"),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:[],tables:[],customBlocks:[],paragraphs:[{startIndex:0}],sectionBreaks:[{startIndex:1}]},tableSource:{},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,!1)}_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);function scrollToTop(accessor){var _a4;const backScrollController=(_a4=accessor.get(engineRender.IRenderManagerService).getRenderById(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:_a4.with(docsUi.DocBackScrollRenderController),textRange={startOffset:0,endOffset:0};backScrollController&&backScrollController.scrollToRange(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,textRange)}__name(scrollToTop,"scrollToTop");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(),scrollToTop(accessor);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(),scrollToTop(accessor);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={};/**
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"),docsUi=require("@univerjs/docs-ui"),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:[],tables:[],customBlocks:[],paragraphs:[{startIndex:0}],sectionBreaks:[{startIndex:1}]},tableSource:{},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,!1)}_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);function scrollToTop(accessor){var _a4;const backScrollController=(_a4=accessor.get(engineRender.IRenderManagerService).getRenderById(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:_a4.with(docsUi.DocBackScrollRenderController),textRange={startOffset:0,endOffset:0};backScrollController&&backScrollController.scrollToRange(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,textRange)}__name(scrollToTop,"scrollToTop");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(),scrollToTop(accessor);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(),scrollToTop(accessor);const currentSheetInstance=univerInstanceManager.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);return currentSheetInstance?(univerInstanceManager.focusUnit(currentSheetInstance.getUnitId()),editorBridgeService.refreshEditCellState(),!0):!1},"handler")};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 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;
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");function ZenEditorMenuItemFactory(accessor){return{id:OpenZenEditorOperation.id,type:ui.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",hidden$:sheetsUi.getCurrentExclusiveRangeInterest$(accessor),disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellValuePermission,sheets.WorksheetSetCellStylePermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]})}}__name(ZenEditorMenuItemFactory,"ZenEditorMenuItemFactory");const menuSchema={[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.OTHERS]:{[OpenZenEditorOperation.id]:{order:2,menuItemFactory:ZenEditorMenuItemFactory}}}};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"),_a2;let ZenEditorUIController=(_a2=class extends core.Disposable{constructor(_injector,_zenZoneService,_commandService,_menuManagerService,_shortcutService){super(),this._injector=_injector,this._zenZoneService=_zenZoneService,this._commandService=_commandService,this._menuManagerService=_menuManagerService,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(){this._menuManagerService.mergeMenu(menuSchema)}_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(0,core.Inject(core.Injector)),__decorateParam$1(1,ui.IZenZoneService),__decorateParam$1(2,core.ICommandService),__decorateParam$1(3,ui.IMenuManagerService),__decorateParam$1(4,ui.IShortcutService)],ZenEditorUIController);const PLUGIN_CONFIG_KEY="sheets-zen-editor.config",defaultPluginConfig={};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=defaultPluginConfig,_injector,_configService){super(),this._config=_config,this._injector=_injector,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest),this._initializeDependencies(this._injector)}_initializeDependencies(injector){[[ZenEditorUIController],[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.IConfigService)],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=CancelZenEditCommand;exports.ConfirmZenEditCommand=ConfirmZenEditCommand;exports.OpenZenEditorOperation=OpenZenEditorOperation;
package/lib/es/index.js CHANGED
@@ -2,11 +2,11 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
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";
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, Disposable, Injector, Plugin, IConfigService } from "@univerjs/core";
6
6
  import { DocSkeletonManagerService, VIEWPORT_KEY, RichTextEditingMutation, getDocObject, TextSelectionManagerService } from "@univerjs/docs";
7
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";
8
+ import { getEditorObject, IEditorBridgeService, getCurrentExclusiveRangeInterest$, getCurrentRangeDisable$ } from "@univerjs/sheets-ui";
9
+ import { IZenZoneService, KeyCode, MetaKeys, MenuItemType, ContextMenuPosition, ContextMenuGroup, IMenuManagerService, IShortcutService } from "@univerjs/ui";
10
10
  import { BehaviorSubject, takeUntil } from "rxjs";
11
11
  import { DocBackScrollRenderController } from "@univerjs/docs-ui";
12
12
  import { WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetSetCellStylePermission, RangeProtectionPermissionEditPoint } from "@univerjs/sheets";
@@ -239,18 +239,6 @@ const CancelZenEditCommand = {
239
239
  return currentSheetInstance ? (univerInstanceManager.focusUnit(currentSheetInstance.getUnitId()), editorBridgeService.refreshEditCellState(), !0) : !1;
240
240
  }, "handler")
241
241
  };
242
- function ZenEditorMenuItemFactory(accessor) {
243
- return {
244
- id: OpenZenEditorOperation.id,
245
- group: MenuGroup.CONTEXT_MENU_OTHERS,
246
- type: MenuItemType.BUTTON,
247
- title: "rightClick.zenEditor",
248
- icon: "AmplifySingle",
249
- positions: [MenuPosition.CONTEXT_MENU],
250
- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
251
- };
252
- }
253
- __name(ZenEditorMenuItemFactory, "ZenEditorMenuItemFactory");
254
242
  var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
255
243
  /**
256
244
  * @license React
@@ -412,16 +400,35 @@ function whenZenEditorActivated(contextService) {
412
400
  return contextService.getContextValue(FOCUSING_DOC) && contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && contextService.getContextValue(EDITOR_ACTIVATED) && !contextService.getContextValue(FOCUSING_EDITOR_STANDALONE);
413
401
  }
414
402
  __name(whenZenEditorActivated, "whenZenEditorActivated");
403
+ function ZenEditorMenuItemFactory(accessor) {
404
+ return {
405
+ id: OpenZenEditorOperation.id,
406
+ type: MenuItemType.BUTTON,
407
+ title: "rightClick.zenEditor",
408
+ icon: "AmplifySingle",
409
+ hidden$: getCurrentExclusiveRangeInterest$(accessor),
410
+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
411
+ };
412
+ }
413
+ __name(ZenEditorMenuItemFactory, "ZenEditorMenuItemFactory");
414
+ const menuSchema = {
415
+ [ContextMenuPosition.MAIN_AREA]: {
416
+ [ContextMenuGroup.OTHERS]: {
417
+ [OpenZenEditorOperation.id]: {
418
+ order: 2,
419
+ menuItemFactory: ZenEditorMenuItemFactory
420
+ }
421
+ }
422
+ }
423
+ };
415
424
  var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
416
425
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
417
426
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
418
427
  return kind && result && __defProp$1(target, key, result), result;
419
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
420
- const DefaultSheetZenEditorUiConfig = {};
421
- var _a2;
428
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a2;
422
429
  let ZenEditorUIController = (_a2 = class extends Disposable {
423
- constructor(_config, _injector, _zenZoneService, _commandService, _menuService, _shortcutService) {
424
- super(), this._config = _config, this._injector = _injector, this._zenZoneService = _zenZoneService, this._commandService = _commandService, this._menuService = _menuService, this._shortcutService = _shortcutService, this._initialize();
430
+ constructor(_injector, _zenZoneService, _commandService, _menuManagerService, _shortcutService) {
431
+ super(), this._injector = _injector, this._zenZoneService = _zenZoneService, this._commandService = _commandService, this._menuManagerService = _menuManagerService, this._shortcutService = _shortcutService, this._initialize();
425
432
  }
426
433
  _initialize() {
427
434
  this._initCustomComponents(), this._initCommands(), this._initMenus(), this._initShortcuts();
@@ -435,13 +442,7 @@ let ZenEditorUIController = (_a2 = class extends Disposable {
435
442
  });
436
443
  }
437
444
  _initMenus() {
438
- const { menu = {} } = this._config;
439
- [
440
- // context menu
441
- ZenEditorMenuItemFactory
442
- ].forEach((factory) => {
443
- this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory), menu));
444
- });
445
+ this._menuManagerService.mergeMenu(menuSchema);
445
446
  }
446
447
  _initShortcuts() {
447
448
  [ZenEditorConfirmShortcut, ZenEditorCancelShortcut].forEach((item) => {
@@ -451,29 +452,27 @@ let ZenEditorUIController = (_a2 = class extends Disposable {
451
452
  }, __name(_a2, "ZenEditorUIController"), _a2);
452
453
  ZenEditorUIController = __decorateClass$1([
453
454
  OnLifecycle(LifecycleStages.Rendered, ZenEditorUIController),
454
- __decorateParam$1(1, Inject(Injector)),
455
- __decorateParam$1(2, IZenZoneService),
456
- __decorateParam$1(3, ICommandService),
457
- __decorateParam$1(4, IMenuService),
458
- __decorateParam$1(5, IShortcutService)
455
+ __decorateParam$1(0, Inject(Injector)),
456
+ __decorateParam$1(1, IZenZoneService),
457
+ __decorateParam$1(2, ICommandService),
458
+ __decorateParam$1(3, IMenuManagerService),
459
+ __decorateParam$1(4, IShortcutService)
459
460
  ], ZenEditorUIController);
461
+ const PLUGIN_CONFIG_KEY = "sheets-zen-editor.config", defaultPluginConfig = {};
460
462
  var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
461
463
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
462
464
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
463
465
  return kind && result && __defProp2(target, key, result), result;
464
466
  }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a3;
465
467
  let UniverSheetsZenEditorPlugin = (_a3 = class extends Plugin {
466
- constructor(_config = {}, _injector, _localeService) {
467
- super(), this._config = _config, this._injector = _injector, this._localeService = _localeService, this._initializeDependencies(this._injector), this._config = Tools.deepMerge({}, DefaultSheetZenEditorUiConfig, this._config);
468
+ constructor(_config = defaultPluginConfig, _injector, _configService) {
469
+ super(), this._config = _config, this._injector = _injector, this._configService = _configService;
470
+ const { menu, ...rest } = this._config;
471
+ menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest), this._initializeDependencies(this._injector);
468
472
  }
469
473
  _initializeDependencies(injector) {
470
474
  [
471
- [
472
- ZenEditorUIController,
473
- {
474
- useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(ZenEditorUIController, this._config), "useFactory")
475
- }
476
- ],
475
+ [ZenEditorUIController],
477
476
  [ZenEditorController],
478
477
  [IZenEditorManagerService, { useClass: ZenEditorManagerService }]
479
478
  ].forEach((dependency) => injector.add(dependency));
@@ -481,7 +480,7 @@ let UniverSheetsZenEditorPlugin = (_a3 = class extends Plugin {
481
480
  }, __name(_a3, "UniverSheetsZenEditorPlugin"), __publicField(_a3, "pluginName", "zen-editor"), __publicField(_a3, "type", UniverInstanceType.UNIVER_SHEET), _a3);
482
481
  UniverSheetsZenEditorPlugin = __decorateClass([
483
482
  __decorateParam(1, Inject(Injector)),
484
- __decorateParam(2, Inject(LocaleService))
483
+ __decorateParam(2, IConfigService)
485
484
  ], UniverSheetsZenEditorPlugin);
486
485
  export {
487
486
  CancelZenEditCommand,
@@ -0,0 +1,7 @@
1
+ import { MenuConfig } from '@univerjs/ui';
2
+ export declare const PLUGIN_CONFIG_KEY = "sheets-zen-editor.config";
3
+ export declare const configSymbol: unique symbol;
4
+ export interface IUniverSheetsZenEditorConfig {
5
+ menu?: MenuConfig;
6
+ }
7
+ export declare const defaultPluginConfig: IUniverSheetsZenEditorConfig;
@@ -0,0 +1,2 @@
1
+ import { MenuSchemaType } from '@univerjs/ui';
2
+ export declare const menuSchema: MenuSchemaType;
@@ -1,17 +1,12 @@
1
1
  import { Disposable, ICommandService, Injector } from '@univerjs/core';
2
- import { MenuConfig, IMenuService, IShortcutService, IZenZoneService } from '@univerjs/ui';
3
- export interface IUniverSheetsZenEditorUIConfig {
4
- menu: MenuConfig;
5
- }
6
- export declare const DefaultSheetZenEditorUiConfig: {};
2
+ import { IMenuManagerService, IShortcutService, IZenZoneService } from '@univerjs/ui';
7
3
  export declare class ZenEditorUIController extends Disposable {
8
- private readonly _config;
9
4
  private readonly _injector;
10
5
  private readonly _zenZoneService;
11
6
  private readonly _commandService;
12
- private readonly _menuService;
7
+ private readonly _menuManagerService;
13
8
  private readonly _shortcutService;
14
- constructor(_config: Partial<IUniverSheetsZenEditorUIConfig>, _injector: Injector, _zenZoneService: IZenZoneService, _commandService: ICommandService, _menuService: IMenuService, _shortcutService: IShortcutService);
9
+ constructor(_injector: Injector, _zenZoneService: IZenZoneService, _commandService: ICommandService, _menuManagerService: IMenuManagerService, _shortcutService: IShortcutService);
15
10
  private _initialize;
16
11
  private _initCustomComponents;
17
12
  private _initCommands;
@@ -1,11 +1,11 @@
1
- import { Injector, LocaleService, Plugin, UniverInstanceType } from '@univerjs/core';
2
- import { IUniverSheetsZenEditorUIConfig } from './controllers/zen-editor-ui.controller';
1
+ import { IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
+ import { IUniverSheetsZenEditorConfig } from './controllers/config.schema';
3
3
  export declare class UniverSheetsZenEditorPlugin extends Plugin {
4
4
  private readonly _config;
5
5
  readonly _injector: Injector;
6
- private readonly _localeService;
6
+ private readonly _configService;
7
7
  static pluginName: string;
8
8
  static type: UniverInstanceType;
9
- constructor(_config: Partial<IUniverSheetsZenEditorUIConfig>, _injector: Injector, _localeService: LocaleService);
9
+ constructor(_config: Partial<IUniverSheetsZenEditorConfig>, _injector: Injector, _configService: IConfigService);
10
10
  private _initializeDependencies;
11
11
  }
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
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/docs-ui"),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/docs-ui","@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.UniverDocsUi,global.UniverSheets,global.React,global.clsx))})(this,function(exports2,core,docs,engineRender,sheetsUi,ui,rxjs,docsUi,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:[],tables:[],customBlocks:[],paragraphs:[{startIndex:0}],sectionBreaks:[{startIndex:1}]},tableSource:{},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,!1)}_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);function scrollToTop(accessor){var _a2;const backScrollController=(_a2=accessor.get(engineRender.IRenderManagerService).getRenderById(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:_a2.with(docsUi.DocBackScrollRenderController),textRange={startOffset:0,endOffset:0};backScrollController&&backScrollController.scrollToRange(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,textRange)}__name(scrollToTop,"scrollToTop");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(),scrollToTop(accessor);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(),scrollToTop(accessor);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={};/**
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/docs-ui"),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/docs-ui","@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.UniverDocsUi,global.UniverSheets,global.React,global.clsx))})(this,function(exports2,core,docs,engineRender,sheetsUi,ui,rxjs,docsUi,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:[],tables:[],customBlocks:[],paragraphs:[{startIndex:0}],sectionBreaks:[{startIndex:1}]},tableSource:{},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,!1)}_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);function scrollToTop(accessor){var _a2;const backScrollController=(_a2=accessor.get(engineRender.IRenderManagerService).getRenderById(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:_a2.with(docsUi.DocBackScrollRenderController),textRange={startOffset:0,endOffset:0};backScrollController&&backScrollController.scrollToRange(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,textRange)}__name(scrollToTop,"scrollToTop");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(),scrollToTop(accessor);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(),scrollToTop(accessor);const currentSheetInstance=univerInstanceManager.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);return currentSheetInstance?(univerInstanceManager.focusUnit(currentSheetInstance.getUnitId()),editorBridgeService.refreshEditCellState(),!0):!1},"handler")};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 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"})});
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");function ZenEditorMenuItemFactory(accessor){return{id:OpenZenEditorOperation.id,type:ui.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",hidden$:sheetsUi.getCurrentExclusiveRangeInterest$(accessor),disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellValuePermission,sheets.WorksheetSetCellStylePermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]})}}__name(ZenEditorMenuItemFactory,"ZenEditorMenuItemFactory");const menuSchema={[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.OTHERS]:{[OpenZenEditorOperation.id]:{order:2,menuItemFactory:ZenEditorMenuItemFactory}}}};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");let ZenEditorUIController=(_b=class extends core.Disposable{constructor(_injector,_zenZoneService,_commandService,_menuManagerService,_shortcutService){super(),this._injector=_injector,this._zenZoneService=_zenZoneService,this._commandService=_commandService,this._menuManagerService=_menuManagerService,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(){this._menuManagerService.mergeMenu(menuSchema)}_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(0,core.Inject(core.Injector)),__decorateParam$1(1,ui.IZenZoneService),__decorateParam$1(2,core.ICommandService),__decorateParam$1(3,ui.IMenuManagerService),__decorateParam$1(4,ui.IShortcutService)],ZenEditorUIController);const PLUGIN_CONFIG_KEY="sheets-zen-editor.config",defaultPluginConfig={};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=defaultPluginConfig,_injector,_configService){super(),this._config=_config,this._injector=_injector,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest),this._initializeDependencies(this._injector)}_initializeDependencies(injector){[[ZenEditorUIController],[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.IConfigService)],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.10",
3
+ "version": "0.2.12",
4
4
  "private": false,
5
5
  "description": "Zen Editor plugin for Univer Sheets.",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,17 +53,17 @@
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/docs": "0.2.10",
57
- "@univerjs/core": "0.2.10",
58
- "@univerjs/engine-render": "0.2.10",
59
- "@univerjs/sheets": "0.2.10",
60
- "@univerjs/docs-ui": "0.2.10",
61
- "@univerjs/sheets-ui": "0.2.10",
62
- "@univerjs/ui": "0.2.10"
56
+ "@univerjs/core": "0.2.12",
57
+ "@univerjs/docs": "0.2.12",
58
+ "@univerjs/engine-render": "0.2.12",
59
+ "@univerjs/docs-ui": "0.2.12",
60
+ "@univerjs/sheets": "0.2.12",
61
+ "@univerjs/sheets-ui": "0.2.12",
62
+ "@univerjs/ui": "0.2.12"
63
63
  },
64
64
  "dependencies": {
65
65
  "@univerjs/icons": "^0.1.77",
66
- "@univerjs/sheets": "0.2.10"
66
+ "@univerjs/sheets": "0.2.12"
67
67
  },
68
68
  "devDependencies": {
69
69
  "clsx": "^2.1.1",
@@ -73,15 +73,15 @@
73
73
  "typescript": "^5.5.4",
74
74
  "vite": "^5.4.2",
75
75
  "vitest": "^2.0.5",
76
- "@univerjs/core": "0.2.10",
77
- "@univerjs/design": "0.2.10",
78
- "@univerjs/docs": "0.2.10",
79
- "@univerjs/docs-ui": "0.2.10",
80
- "@univerjs/engine-render": "0.2.10",
81
- "@univerjs/shared": "0.2.10",
82
- "@univerjs/sheets": "0.2.10",
83
- "@univerjs/sheets-ui": "0.2.10",
84
- "@univerjs/ui": "0.2.10"
76
+ "@univerjs/core": "0.2.12",
77
+ "@univerjs/design": "0.2.12",
78
+ "@univerjs/docs": "0.2.12",
79
+ "@univerjs/docs-ui": "0.2.12",
80
+ "@univerjs/engine-render": "0.2.12",
81
+ "@univerjs/shared": "0.2.12",
82
+ "@univerjs/sheets": "0.2.12",
83
+ "@univerjs/sheets-ui": "0.2.12",
84
+ "@univerjs/ui": "0.2.12"
85
85
  },
86
86
  "univerSpace": {
87
87
  ".": {