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