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