@univerjs/sheets-zen-editor 0.2.4-alpha.0 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Q=Object.defineProperty;var ee=(n,e,i)=>e in n?Q(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var O=(n,e,i)=>ee(n,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),b=require("@univerjs/docs"),U=require("@univerjs/engine-render"),M=require("@univerjs/sheets-ui"),_=require("@univerjs/ui"),F=require("rxjs"),N=require("@univerjs/sheets"),S=require("react"),k=require("clsx"),j={id:"zen-editor.operation.open-zen-editor",type:c.CommandType.OPERATION,handler:n=>!0};class te{constructor(){O(this,"_position",null);O(this,"_position$",new F.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 V=c.createIdentifier("univer.sheet-zen-editor-manager.service");var ne=Object.defineProperty,ie=Object.getOwnPropertyDescriptor,re=(n,e,i,t)=>{for(var r=t>1?void 0:t?ie(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&&ne(e,i,r),r},E=(n,e)=>(i,t)=>e(i,t,n);const f="__defaultDocumentZenEditorSpecialUnitId_20231218__";let P=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(F.takeUntil(this.dispose$)).subscribe(e=>{var d;if(e==null)return;const i=M.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(b.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:U.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(b.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(),R=v.getSnapshot();u.dataStream=i,u.paragraphs=t,u.customBlocks=o,u.customRanges=d,R.drawings=s,R.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,R=0,C=Number.POSITIVE_INFINITY;const{scaleX:m,scaleY:G}=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,R=(p-h*2)/G):(I=h,R=a+h*2),t.resize(u,R+200),i.translate(v,I),r.translate(v,I);const A=t.getViewport(b.VIEWPORT_KEY.VIEW_MAIN);if(C!==Number.POSITIVE_INFINITY&&A!=null){const J=A.transScroll2ViewportScrollValue(C,0).x;A.scrollTo({x:J})}return this}_commandExecutedListener(){const e=[j.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{e.includes(t.id)&&this._handleOpenZenEditor()}));const i=[b.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 b.getDocObject(this._univerInstanceService,this._renderManagerService)}};P=re([c.OnLifecycle(c.LifecycleStages.Steady,P),E(0,c.IUniverInstanceService),E(1,V),E(2,U.IRenderManagerService),E(3,c.ICommandService),E(4,_.IZenZoneService),E(5,M.IEditorBridgeService),E(6,c.IUndoRedoService),E(7,c.Inject(b.TextSelectionManagerService))],P);const w={id:"zen-editor.command.cancel-zen-edit",type:c.CommandType.COMMAND,handler:async n=>{const e=n.get(_.IZenZoneService),i=n.get(M.IEditorBridgeService),t=n.get(c.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:U.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}},Z={id:"zen-editor.command.confirm-zen-edit",type:c.CommandType.COMMAND,handler:async n=>{const e=n.get(_.IZenZoneService),i=n.get(M.IEditorBridgeService),t=n.get(c.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:U.DeviceInputEventType.PointerDown,unitId:""}),e.close();const o=t.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return o?(t.focusUnit(o.getUnitId()),i.refreshEditCellState(),!0):!1}};function se(n){return{id:j.id,group:_.MenuGroup.CONTEXT_MENU_OTHERS,type:_.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[_.MenuPosition.CONTEXT_MENU],disabled$:M.getCurrentRangeDisable$(n,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission,N.WorksheetSetCellValuePermission,N.WorksheetSetCellStylePermission],rangeTypes:[N.RangeProtectionPermissionEditPoint]})}}var W={exports:{}},L={};/**
1
+ "use strict";var J=Object.defineProperty;var Q=(n,e,i)=>e in n?J(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var C=(n,e,i)=>Q(n,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),R=require("@univerjs/docs"),U=require("@univerjs/engine-render"),z=require("@univerjs/sheets-ui"),_=require("@univerjs/ui"),$=require("rxjs"),D=require("@univerjs/sheets"),g=require("react"),B=require("clsx"),P={id:"zen-editor.operation.open-zen-editor",type:s.CommandType.OPERATION,handler:n=>!0};class ee{constructor(){C(this,"_position",null);C(this,"_position$",new $.BehaviorSubject(null));C(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(e){this._position=e,this._refresh(e)}getPosition(){return this._position}_refresh(e){this._position$.next(e)}}const A=s.createIdentifier("univer.sheet-zen-editor-manager.service");var te=Object.defineProperty,ne=Object.getOwnPropertyDescriptor,ie=(n,e,i,t)=>{for(var r=t>1?void 0:t?ne(e,i):e,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(t?o(e,i,r):o(r))||r);return t&&r&&te(e,i,r),r},p=(n,e)=>(i,t)=>e(i,t,n);let M=class extends s.RxDisposable{constructor(e,i,t,r,c,o,a,d){super();C(this,"_zenEditorInitialState",!1);this._univerInstanceService=e,this._zenEditorManagerService=i,this._renderManagerService=t,this._commandService=r,this._zenZoneService=c,this._editorBridgeService=o,this._undoRedoService=a,this._textSelectionManagerService=d,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const e={id:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${s.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],customBlocks:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:595,height:842},documentFlavor:s.DocumentFlavor.MODERN,marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};return this._univerInstanceService.createUnit(s.UniverInstanceType.UNIVER_DOC,e)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe($.takeUntil(this.dispose$)).subscribe(e=>{var d;if(e==null)return;const i=z.getEditorObject(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService),t=this._univerInstanceService.getUniverDocInstance(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(i==null||t==null)return;const{width:r,height:c}=e,{engine:o}=i,a=(d=this._renderManagerService.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:d.with(R.DocSkeletonManagerService).getSkeleton();requestIdleCallback(()=>{o.resizeBySize(r,c),this._calculatePagePosition(i),a&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){var c;this._zenEditorInitialState||(this._createZenEditorInstance(),this._zenEditorInitialState=!0),this._zenZoneService.open();const e=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);this._undoRedoService.clearUndoRedo(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._univerInstanceService.focusUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._univerInstanceService.setCurrentUnitForType(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:U.DeviceInputEventType.PointerDown,unitId:(c=e==null?void 0:e.getUnitId())!=null?c:""});const t=this._editorBridgeService.getLatestEditCellState();if(t==null)return;this._editorSyncHandler(t);const r=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(r)}_editorSyncHandler(e){var o,a;const i=(o=e.documentLayoutObject.documentModel)==null?void 0:o.getBody(),t=i==null?void 0:i.dataStream,r=i==null?void 0:i.paragraphs;let c=[];t==null||r==null||((a=i==null?void 0:i.textRuns)!=null&&a.length&&(c=i==null?void 0:i.textRuns),this._syncContentAndRender(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,t,r,c))}_syncContentAndRender(e,i,t,r=[],c=[],o={},a=[],d=[]){var S;const h=[s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],l=(S=this._renderManagerService.getRenderById(e))==null?void 0:S.with(R.DocSkeletonManagerService),I=l==null?void 0:l.getSkeleton(),v=this._univerInstanceService.getUniverDocInstance(e),E=l==null?void 0:l.getViewModel();if(v==null||E==null||I==null)return;const u=v.getBody(),N=v.getSnapshot();u.dataStream=i,u.paragraphs=t,u.customBlocks=c,u.customRanges=d,N.drawings=o,N.drawingsOrder=a,e===s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(u.textRuns=[]),r.length>0&&(u.textRuns=r),E.reset(v);const m=this._getDocObject();m!=null&&(I.calculate(),h.includes(e)&&m.document.makeDirty())}_calculatePagePosition(e){const{document:i,scene:t,docBackground:r}=e,c=t==null?void 0:t.getParent(),{width:o,height:a,pageMarginLeft:d,pageMarginTop:h}=i;if(c==null||o===Number.POSITIVE_INFINITY||a===Number.POSITIVE_INFINITY)return;const{width:l,height:I}=c;let v=0,E=0,u=0,N=0,m=Number.POSITIVE_INFINITY;const{scaleX:S,scaleY:X}=t.getAncestorScale();l>(o+d*2)*S?(v=l/2-o*S/2,v/=S,u=(l-d*2)/S,m=0):(v=d,u=o+d*2,m=(u-l/S)/2),I>a?(E=I/2-a/2,N=(I-h*2)/X):(E=h,N=a+h*2),t.resize(u,N+200),i.translate(v,E),r.translate(v,E);const L=t.getViewport(R.VIEWPORT_KEY.VIEW_MAIN);if(m!==Number.POSITIVE_INFINITY&&L!=null){const G=L.transScroll2ViewportScrollValue(m,0).x;L.scrollToBarPos({x:G})}return this}_commandExecutedListener(){const e=[P.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{e.includes(t.id)&&this._handleOpenZenEditor()}));const i=[R.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(i.includes(t.id)){const r=t.params,{unitId:c}=r;if(c===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY){const o=this._univerInstanceService.getUniverDocInstance(c),a=o==null?void 0:o.getBody(),d=a==null?void 0:a.dataStream,h=a==null?void 0:a.paragraphs,l=a==null?void 0:a.textRuns,I=a==null?void 0:a.customBlocks,v=o==null?void 0:o.getDrawings(),E=o==null?void 0:o.getDrawingsOrder(),u=o==null?void 0:o.getCustomRanges();if(this._editorBridgeService.changeEditorDirty(!0),d==null||h==null)return;this._syncContentAndRender(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,d,h,l,I,v,E,u)}}}))}_getDocObject(){return R.getDocObject(this._univerInstanceService,this._renderManagerService)}};M=ie([s.OnLifecycle(s.LifecycleStages.Steady,M),p(0,s.IUniverInstanceService),p(1,A),p(2,U.IRenderManagerService),p(3,s.ICommandService),p(4,_.IZenZoneService),p(5,z.IEditorBridgeService),p(6,s.IUndoRedoService),p(7,s.Inject(R.TextSelectionManagerService))],M);const Z={id:"zen-editor.command.cancel-zen-edit",type:s.CommandType.COMMAND,handler:async n=>{const e=n.get(_.IZenZoneService),i=n.get(z.IEditorBridgeService),t=n.get(s.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:U.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC,unitId:""}),e.close();const c=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);return c?(t.focusUnit(c.getUnitId()),i.refreshEditCellState(),!0):!1}},j={id:"zen-editor.command.confirm-zen-edit",type:s.CommandType.COMMAND,handler:async n=>{const e=n.get(_.IZenZoneService),i=n.get(z.IEditorBridgeService),t=n.get(s.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:U.DeviceInputEventType.PointerDown,unitId:""}),e.close();const c=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);return c?(t.focusUnit(c.getUnitId()),i.refreshEditCellState(),!0):!1}};function re(n){return{id:P.id,group:_.MenuGroup.CONTEXT_MENU_OTHERS,type:_.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[_.MenuPosition.CONTEXT_MENU],disabled$:z.getCurrentRangeDisable$(n,{workbookTypes:[D.WorkbookEditablePermission],worksheetTypes:[D.WorksheetEditPermission,D.WorksheetSetCellValuePermission,D.WorksheetSetCellStylePermission],rangeTypes:[D.RangeProtectionPermissionEditPoint]})}}var Y={exports:{}},w={};/**
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 oe=S,ce=Symbol.for("react.element"),ae=Symbol.for("react.fragment"),de=Object.prototype.hasOwnProperty,le=oe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ue={key:!0,ref:!0,__self:!0,__source:!0};function Y(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)de.call(e,t)&&!ue.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:ce,type:n,key:o,ref:s,props:r,_owner:le.current}}L.Fragment=ae;L.jsx=Y;L.jsxs=Y;W.exports=L;var y=W.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)},_e=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},B=S.forwardRef(function(n,e){var i=n.icon,t=n.id,r=n.className,o=n.extend,s=_e(n,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),d=S.useRef("_".concat(fe()));return q(i,"".concat(t),{defIds:i.defIds,idSuffix:d.current},g({ref:e,className:a},s),o)});function q(n,e,i,t,r){return S.createElement(n.tag,g(g({key:e},he(n,i,r)),t),(ve(n,i).children||[]).map(function(o,s){return q(o,"".concat(e,"-").concat(n.tag,"-").concat(s),i,void 0,r)}))}function he(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 ve(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 fe(){return Math.random().toString(36).substring(2,8)}B.displayName="UniverIcon";var ge={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"}}]},K=S.forwardRef(function(n,e){return S.createElement(B,Object.assign({},n,{id:"check-mark-single",ref:e,icon:ge}))});K.displayName="CheckMarkSingle";var pe={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"}}]},H=S.forwardRef(function(n,e){return S.createElement(B,Object.assign({},n,{id:"close-single",ref:e,icon:pe}))});H.displayName="CloseSingle";const Se="univer-zen-editor",Ie="univer-zen-editor-icon-wrapper",me="univer-zen-editor-icon-container",Ee="univer-zen-editor-icon-success",Ce="univer-zen-editor-icon-error",Oe="univer-zen-editor-canvas-container",T={zenEditor:Se,zenEditorIconWrapper:Ie,zenEditorIconContainer:me,zenEditorIconSuccess:Ee,zenEditorIconError:Ce,zenEditorCanvasContainer:Oe},ye="ZEN_EDITOR_PLUGIN_",Te=`${ye}ZEN_EDITOR_COMPONENT`;function Re(){const n=S.useRef(null),e=c.useDependency(U.IRenderManagerService),i=c.useDependency(V),t=c.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(w.id)}function o(){t.executeCommand(Z.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(H,{style:{fontSize:"22px"}})}),y.jsx("span",{className:k(T.zenEditorIconContainer,T.zenEditorIconSuccess),onClick:o,children:y.jsx(K,{style:{fontSize:"22px"}})})]}),y.jsx("div",{className:T.zenEditorCanvasContainer,ref:n})]})}const be={id:Z.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:n=>X(n),binding:_.KeyCode.ENTER|_.MetaKeys.ALT},Ne={id:w.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:n=>X(n),binding:_.KeyCode.ESC};function X(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 ze=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,Ue=(n,e,i,t)=>{for(var r=t>1?void 0:t?xe(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&&ze(e,i,r),r},z=(n,e)=>(i,t)=>e(i,t,n);const Me={};let x=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(Te,Re))}_initCommands(){[j,w,Z].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initMenus(){const{menu:n={}}=this._config;[se].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e),n))})}_initShortcuts(){[be,Ne].forEach(n=>{this.disposeWithMe(this._shortcutService.registerShortcut(n))})}};x=Ue([c.OnLifecycle(c.LifecycleStages.Rendered,x),z(1,c.Inject(c.Injector)),z(2,_.IZenZoneService),z(3,c.ICommandService),z(4,_.IMenuService),z(5,_.IShortcutService)],x);var De=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,je=(n,e,i,t)=>{for(var r=t>1?void 0:t?Pe(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&&De(e,i,r),r},$=(n,e)=>(i,t)=>e(i,t,n),D;exports.UniverSheetsZenEditorPlugin=(D=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({},Me,this._config)}_initializeDependencies(e){[[x,{useFactory:()=>this._injector.createInstance(x,this._config)}],[P],[V,{useClass:te}]].forEach(t=>e.add(t))}},O(D,"pluginName","zen-editor"),O(D,"type",c.UniverInstanceType.UNIVER_DOC),D);exports.UniverSheetsZenEditorPlugin=je([$(1,c.Inject(c.Injector)),$(2,c.Inject(c.LocaleService))],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=w;exports.ConfirmZenEditCommand=Z;exports.OpenZenEditorOperation=j;
9
+ */var se=g,oe=Symbol.for("react.element"),ce=Symbol.for("react.fragment"),ae=Object.prototype.hasOwnProperty,de=se.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,le={key:!0,ref:!0,__self:!0,__source:!0};function K(n,e,i){var t,r={},c=null,o=null;i!==void 0&&(c=""+i),e.key!==void 0&&(c=""+e.key),e.ref!==void 0&&(o=e.ref);for(t in e)ae.call(e,t)&&!le.hasOwnProperty(t)&&(r[t]=e[t]);if(n&&n.defaultProps)for(t in e=n.defaultProps,e)r[t]===void 0&&(r[t]=e[t]);return{$$typeof:oe,type:n,key:c,ref:o,props:r,_owner:de.current}}w.Fragment=ce;w.jsx=K;w.jsxs=K;Y.exports=w;var O=Y.exports,f=function(){return f=Object.assign||function(n){for(var e,i=1,t=arguments.length;i<t;i++){e=arguments[i];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},f.apply(this,arguments)},ue=function(n,e){var i={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.indexOf(t)<0&&(i[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(n);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(n,t[r])&&(i[t[r]]=n[t[r]]);return i},V=g.forwardRef(function(n,e){var i=n.icon,t=n.id,r=n.className,c=n.extend,o=ue(n,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),d=g.useRef("_".concat(ve()));return F(i,"".concat(t),{defIds:i.defIds,idSuffix:d.current},f({ref:e,className:a},o),c)});function F(n,e,i,t,r){return g.createElement(n.tag,f(f({key:e},_e(n,i,r)),t),(he(n,i).children||[]).map(function(c,o){return F(c,"".concat(e,"-").concat(n.tag,"-").concat(o),i,void 0,r)}))}function _e(n,e,i){var t=f({},n.attrs);i!=null&&i.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=i.colorChannel1);var r=e.defIds;return!r||r.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(c){var o=c[0],a=c[1];typeof a=="string"&&(t[o]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function he(n,e){var i,t=e.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?f(f({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?f(f({},r),{attrs:f(f({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):n}function ve(){return Math.random().toString(36).substring(2,8)}V.displayName="UniverIcon";var fe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},W=g.forwardRef(function(n,e){return g.createElement(V,Object.assign({},n,{id:"check-mark-single",ref:e,icon:fe}))});W.displayName="CheckMarkSingle";var Ie={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},q=g.forwardRef(function(n,e){return g.createElement(V,Object.assign({},n,{id:"close-single",ref:e,icon:Ie}))});q.displayName="CloseSingle";const ge="univer-zen-editor",Ee="univer-zen-editor-icon-wrapper",Se="univer-zen-editor-icon-container",pe="univer-zen-editor-icon-success",me="univer-zen-editor-icon-error",Ce="univer-zen-editor-canvas-container",T={zenEditor:ge,zenEditorIconWrapper:Ee,zenEditorIconContainer:Se,zenEditorIconSuccess:pe,zenEditorIconError:me,zenEditorCanvasContainer:Ce},Oe="ZEN_EDITOR_PLUGIN_",Te=`${Oe}ZEN_EDITOR_COMPONENT`;function Ne(){const n=g.useRef(null),e=s.useDependency(U.IRenderManagerService),i=s.useDependency(A),t=s.useDependency(s.ICommandService);g.useEffect(()=>{const o=n.current;if(!o)return;const a=e.currentRender$.subscribe(h=>{var I;if(h!==s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)return;const l=(I=e.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:I.engine;l==null||l.setContainer(o)}),d=new ResizeObserver(()=>{const h=o.getBoundingClientRect();i.setPosition(h)});return d.observe(o),()=>{d.unobserve(o),a.unsubscribe()}},[]);function r(){t.executeCommand(Z.id)}function c(){t.executeCommand(j.id)}return O.jsxs("div",{className:T.zenEditor,children:[O.jsxs("div",{className:T.zenEditorIconWrapper,children:[O.jsx("span",{className:B(T.zenEditorIconContainer,T.zenEditorIconError),onClick:r,children:O.jsx(q,{style:{fontSize:"22px"}})}),O.jsx("span",{className:B(T.zenEditorIconContainer,T.zenEditorIconSuccess),onClick:c,children:O.jsx(W,{style:{fontSize:"22px"}})})]}),O.jsx("div",{className:T.zenEditorCanvasContainer,ref:n})]})}const Re={id:j.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:n=>H(n),binding:_.KeyCode.ENTER|_.MetaKeys.ALT},De={id:Z.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:n=>H(n),binding:_.KeyCode.ESC};function H(n){return n.getContextValue(s.FOCUSING_DOC)&&n.getContextValue(s.FOCUSING_UNIVER_EDITOR)&&n.getContextValue(s.EDITOR_ACTIVATED)&&!n.getContextValue(s.FOCUSING_EDITOR_STANDALONE)}var ye=Object.defineProperty,be=Object.getOwnPropertyDescriptor,Ue=(n,e,i,t)=>{for(var r=t>1?void 0:t?be(e,i):e,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(t?o(e,i,r):o(r))||r);return t&&r&&ye(e,i,r),r},y=(n,e)=>(i,t)=>e(i,t,n);const ze={};let b=class extends s.Disposable{constructor(n,e,i,t,r,c){super(),this._config=n,this._injector=e,this._zenZoneService=i,this._commandService=t,this._menuService=r,this._shortcutService=c,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(Te,Ne))}_initCommands(){[P,Z,j].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initMenus(){const{menu:n={}}=this._config;[re].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e),n))})}_initShortcuts(){[Re,De].forEach(n=>{this.disposeWithMe(this._shortcutService.registerShortcut(n))})}};b=Ue([s.OnLifecycle(s.LifecycleStages.Rendered,b),y(1,s.Inject(s.Injector)),y(2,_.IZenZoneService),y(3,s.ICommandService),y(4,_.IMenuService),y(5,_.IShortcutService)],b);var xe=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,Pe=(n,e,i,t)=>{for(var r=t>1?void 0:t?Me(e,i):e,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(t?o(e,i,r):o(r))||r);return t&&r&&xe(e,i,r),r},k=(n,e)=>(i,t)=>e(i,t,n),x;exports.UniverSheetsZenEditorPlugin=(x=class extends s.Plugin{constructor(e={},i,t){super(),this._config=e,this._injector=i,this._localeService=t,this._initializeDependencies(this._injector),this._config=s.Tools.deepMerge({},ze,this._config)}_initializeDependencies(e){[[b,{useFactory:()=>this._injector.createInstance(b,this._config)}],[M],[A,{useClass:ee}]].forEach(t=>e.add(t))}},C(x,"pluginName","zen-editor"),C(x,"type",s.UniverInstanceType.UNIVER_DOC),x);exports.UniverSheetsZenEditorPlugin=Pe([k(1,s.Inject(s.Injector)),k(2,s.Inject(s.LocaleService))],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=Z;exports.ConfirmZenEditCommand=j;exports.OpenZenEditorOperation=P;
package/lib/es/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  var he = Object.defineProperty;
2
- var _e = (t, e, i) => e in t ? he(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
3
- var E = (t, e, i) => _e(t, typeof e != "symbol" ? e + "" : e, i);
4
- import { CommandType as w, createIdentifier as fe, RxDisposable as ge, DEFAULT_EMPTY_DOCUMENT_VALUE as ve, DocumentFlavor as pe, UniverInstanceType as T, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as H, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as K, OnLifecycle as Q, LifecycleStages as ee, Inject as z, IUniverInstanceService as D, ICommandService as j, IUndoRedoService as me, useDependency as U, FOCUSING_DOC as Se, FOCUSING_UNIVER_EDITOR as Ee, EDITOR_ACTIVATED as Ie, FOCUSING_EDITOR_STANDALONE as Ce, Injector as te, Disposable as Oe, Plugin as Re, Tools as ye, LocaleService as Te } from "@univerjs/core";
2
+ var fe = (t, e, i) => e in t ? he(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
3
+ var E = (t, e, i) => fe(t, typeof e != "symbol" ? e + "" : e, i);
4
+ import { CommandType as w, createIdentifier as _e, RxDisposable as ge, DOCS_ZEN_EDITOR_UNIT_ID_KEY as f, DEFAULT_EMPTY_DOCUMENT_VALUE as ve, DocumentFlavor as pe, UniverInstanceType as T, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as H, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as K, OnLifecycle as Q, LifecycleStages as ee, Inject as z, IUniverInstanceService as D, ICommandService as j, IUndoRedoService as me, useDependency as U, FOCUSING_DOC as Se, FOCUSING_UNIVER_EDITOR as Ee, EDITOR_ACTIVATED as Ie, FOCUSING_EDITOR_STANDALONE as Ce, Injector as te, Disposable as Oe, Plugin as Re, Tools as ye, LocaleService as Te } from "@univerjs/core";
5
5
  import { DocSkeletonManagerService as X, VIEWPORT_KEY as be, RichTextEditingMutation as Ne, getDocObject as ze, TextSelectionManagerService as xe } from "@univerjs/docs";
6
6
  import { DeviceInputEventType as L, IRenderManagerService as ne } from "@univerjs/engine-render";
7
7
  import { getEditorObject as Me, IEditorBridgeService as Z, getCurrentRangeDisable$ as Pe } from "@univerjs/sheets-ui";
8
8
  import { IZenZoneService as x, KeyCode as V, MenuGroup as Ue, MenuItemType as we, MenuPosition as De, MetaKeys as je, IMenuService as Le, IShortcutService as Ze } from "@univerjs/ui";
9
9
  import { BehaviorSubject as Ve, takeUntil as Ae } from "rxjs";
10
- import { WorkbookEditablePermission as ke, WorksheetEditPermission as $e, WorksheetSetCellValuePermission as Be, WorksheetSetCellStylePermission as Fe, RangeProtectionPermissionEditPoint as We } from "@univerjs/sheets";
10
+ import { WorkbookEditablePermission as ke, WorksheetEditPermission as Be, WorksheetSetCellValuePermission as $e, WorksheetSetCellStylePermission as Fe, RangeProtectionPermissionEditPoint as We } from "@univerjs/sheets";
11
11
  import Ye, { forwardRef as A, useRef as ie, createElement as k, useEffect as He } from "react";
12
12
  import G from "clsx";
13
- const $ = {
13
+ const B = {
14
14
  id: "zen-editor.operation.open-zen-editor",
15
15
  type: w.OPERATION,
16
16
  handler: (t) => !0
@@ -34,7 +34,7 @@ class Ke {
34
34
  this._position$.next(e);
35
35
  }
36
36
  }
37
- const B = fe(
37
+ const $ = _e(
38
38
  "univer.sheet-zen-editor-manager.service"
39
39
  );
40
40
  var Xe = Object.defineProperty, Ge = Object.getOwnPropertyDescriptor, qe = (t, e, i, n) => {
@@ -42,7 +42,6 @@ var Xe = Object.defineProperty, Ge = Object.getOwnPropertyDescriptor, qe = (t, e
42
42
  (s = t[o]) && (r = (n ? s(e, i, r) : s(r)) || r);
43
43
  return n && r && Xe(e, i, r), r;
44
44
  }, m = (t, e) => (i, n) => e(i, n, t);
45
- const _ = "__defaultDocumentZenEditorSpecialUnitId_20231218__";
46
45
  let N = class extends ge {
47
46
  constructor(e, i, n, r, o, s, c, a) {
48
47
  super();
@@ -54,7 +53,7 @@ let N = class extends ge {
54
53
  }
55
54
  _createZenEditorInstance() {
56
55
  const e = {
57
- id: _,
56
+ id: f,
58
57
  body: {
59
58
  dataStream: `${ve}`,
60
59
  textRuns: [],
@@ -91,10 +90,10 @@ let N = class extends ge {
91
90
  var a;
92
91
  if (e == null)
93
92
  return;
94
- const i = Me(_, this._renderManagerService), n = this._univerInstanceService.getUniverDocInstance(_);
93
+ const i = Me(f, this._renderManagerService), n = this._univerInstanceService.getUniverDocInstance(f);
95
94
  if (i == null || n == null)
96
95
  return;
97
- const { width: r, height: o } = e, { engine: s } = i, c = (a = this._renderManagerService.getRenderById(_)) == null ? void 0 : a.with(X).getSkeleton();
96
+ const { width: r, height: o } = e, { engine: s } = i, c = (a = this._renderManagerService.getRenderById(f)) == null ? void 0 : a.with(X).getSkeleton();
98
97
  requestIdleCallback(() => {
99
98
  s.resizeBySize(r, o), this._calculatePagePosition(i), c && this._textSelectionManagerService.refreshSelection();
100
99
  });
@@ -104,7 +103,7 @@ let N = class extends ge {
104
103
  var o;
105
104
  this._zenEditorInitialState || (this._createZenEditorInstance(), this._zenEditorInitialState = !0), this._zenZoneService.open();
106
105
  const e = this._univerInstanceService.getCurrentUnitForType(T.UNIVER_SHEET);
107
- this._undoRedoService.clearUndoRedo(_), this._univerInstanceService.focusUnit(_), this._univerInstanceService.setCurrentUnitForType(_), this._editorBridgeService.isVisible().visible === !1 && this._editorBridgeService.changeVisible({
106
+ this._undoRedoService.clearUndoRedo(f), this._univerInstanceService.focusUnit(f), this._univerInstanceService.setCurrentUnitForType(f), this._editorBridgeService.isVisible().visible === !1 && this._editorBridgeService.changeVisible({
108
107
  visible: !0,
109
108
  eventType: L.PointerDown,
110
109
  unitId: (o = e == null ? void 0 : e.getUnitId()) != null ? o : ""
@@ -125,12 +124,12 @@ let N = class extends ge {
125
124
  var s, c;
126
125
  const i = (s = e.documentLayoutObject.documentModel) == null ? void 0 : s.getBody(), n = i == null ? void 0 : i.dataStream, r = i == null ? void 0 : i.paragraphs;
127
126
  let o = [];
128
- n == null || r == null || ((c = i == null ? void 0 : i.textRuns) != null && c.length && (o = i == null ? void 0 : i.textRuns), this._syncContentAndRender(_, n, r, o));
127
+ n == null || r == null || ((c = i == null ? void 0 : i.textRuns) != null && c.length && (o = i == null ? void 0 : i.textRuns), this._syncContentAndRender(f, n, r, o));
129
128
  }
130
129
  _syncContentAndRender(e, i, n, r = [], o = [], s = {}, c = [], a = []) {
131
130
  var p;
132
131
  const u = [
133
- _,
132
+ f,
134
133
  K,
135
134
  H
136
135
  ], d = (p = this._renderManagerService.getRenderById(e)) == null ? void 0 : p.with(X), g = d == null ? void 0 : d.getSkeleton(), h = this._univerInstanceService.getUniverDocInstance(e), v = d == null ? void 0 : d.getViewModel();
@@ -152,14 +151,14 @@ let N = class extends ge {
152
151
  const P = n.getViewport(be.VIEW_MAIN);
153
152
  if (S !== Number.POSITIVE_INFINITY && P != null) {
154
153
  const ue = P.transScroll2ViewportScrollValue(S, 0).x;
155
- P.scrollTo({
154
+ P.scrollToBarPos({
156
155
  x: ue
157
156
  });
158
157
  }
159
158
  return this;
160
159
  }
161
160
  _commandExecutedListener() {
162
- const e = [$.id];
161
+ const e = [B.id];
163
162
  this.disposeWithMe(
164
163
  this._commandService.onCommandExecuted((n) => {
165
164
  e.includes(n.id) && this._handleOpenZenEditor();
@@ -170,7 +169,7 @@ let N = class extends ge {
170
169
  this._commandService.onCommandExecuted((n) => {
171
170
  if (i.includes(n.id)) {
172
171
  const r = n.params, { unitId: o } = r;
173
- if (o === _) {
172
+ if (o === f) {
174
173
  const s = this._univerInstanceService.getUniverDocInstance(o), c = s == null ? void 0 : s.getBody(), a = c == null ? void 0 : c.dataStream, u = c == null ? void 0 : c.paragraphs, d = c == null ? void 0 : c.textRuns, g = c == null ? void 0 : c.customBlocks, h = s == null ? void 0 : s.getDrawings(), v = s == null ? void 0 : s.getDrawingsOrder(), l = s == null ? void 0 : s.getCustomRanges();
175
174
  if (this._editorBridgeService.changeEditorDirty(!0), a == null || u == null)
176
175
  return;
@@ -187,7 +186,7 @@ let N = class extends ge {
187
186
  N = qe([
188
187
  Q(ee.Steady, N),
189
188
  m(0, D),
190
- m(1, B),
189
+ m(1, $),
191
190
  m(2, ne),
192
191
  m(3, j),
193
192
  m(4, x),
@@ -225,13 +224,13 @@ const F = {
225
224
  };
226
225
  function Je(t) {
227
226
  return {
228
- id: $.id,
227
+ id: B.id,
229
228
  group: Ue.CONTEXT_MENU_OTHERS,
230
229
  type: we.BUTTON,
231
230
  title: "rightClick.zenEditor",
232
231
  icon: "AmplifySingle",
233
232
  positions: [De.CONTEXT_MENU],
234
- disabled$: Pe(t, { workbookTypes: [ke], worksheetTypes: [$e, Be, Fe], rangeTypes: [We] })
233
+ disabled$: Pe(t, { workbookTypes: [ke], worksheetTypes: [Be, $e, Fe], rangeTypes: [We] })
235
234
  };
236
235
  }
237
236
  var re = { exports: {} }, M = {};
@@ -256,14 +255,14 @@ M.Fragment = tt;
256
255
  M.jsx = se;
257
256
  M.jsxs = se;
258
257
  re.exports = M;
259
- var I = re.exports, f = function() {
260
- return f = Object.assign || function(t) {
258
+ var I = re.exports, _ = function() {
259
+ return _ = Object.assign || function(t) {
261
260
  for (var e, i = 1, n = arguments.length; i < n; i++) {
262
261
  e = arguments[i];
263
262
  for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
264
263
  }
265
264
  return t;
266
- }, f.apply(this, arguments);
265
+ }, _.apply(this, arguments);
267
266
  }, st = function(t, e) {
268
267
  var i = {};
269
268
  for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (i[n] = t[n]);
@@ -273,15 +272,15 @@ var I = re.exports, f = function() {
273
272
  return i;
274
273
  }, Y = A(function(t, e) {
275
274
  var i = t.icon, n = t.id, r = t.className, o = t.extend, s = st(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(n, " ").concat(r || "").trim(), a = ie("_".concat(at()));
276
- return oe(i, "".concat(n), { defIds: i.defIds, idSuffix: a.current }, f({ ref: e, className: c }, s), o);
275
+ return oe(i, "".concat(n), { defIds: i.defIds, idSuffix: a.current }, _({ ref: e, className: c }, s), o);
277
276
  });
278
277
  function oe(t, e, i, n, r) {
279
- return k(t.tag, f(f({ key: e }, ot(t, i, r)), n), (ct(t, i).children || []).map(function(o, s) {
278
+ return k(t.tag, _(_({ key: e }, ot(t, i, r)), n), (ct(t, i).children || []).map(function(o, s) {
280
279
  return oe(o, "".concat(e, "-").concat(t.tag, "-").concat(s), i, void 0, r);
281
280
  }));
282
281
  }
283
282
  function ot(t, e, i) {
284
- var n = f({}, t.attrs);
283
+ var n = _({}, t.attrs);
285
284
  i != null && i.colorChannel1 && n.fill === "colorChannel1" && (n.fill = i.colorChannel1);
286
285
  var r = e.defIds;
287
286
  return !r || r.length === 0 || (t.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + e.idSuffix), Object.entries(n).forEach(function(o) {
@@ -291,8 +290,8 @@ function ot(t, e, i) {
291
290
  }
292
291
  function ct(t, e) {
293
292
  var i, n = e.defIds;
294
- return !n || n.length === 0 ? t : t.tag === "defs" && (!((i = t.children) === null || i === void 0) && i.length) ? f(f({}, t), { children: t.children.map(function(r) {
295
- return typeof r.attrs.id == "string" && n && n.indexOf(r.attrs.id) > -1 ? f(f({}, r), { attrs: f(f({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
293
+ return !n || n.length === 0 ? t : t.tag === "defs" && (!((i = t.children) === null || i === void 0) && i.length) ? _(_({}, t), { children: t.children.map(function(r) {
294
+ return typeof r.attrs.id == "string" && n && n.indexOf(r.attrs.id) > -1 ? _(_({}, r), { attrs: _(_({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
296
295
  }) }) : t;
297
296
  }
298
297
  function at() {
@@ -315,25 +314,25 @@ var lt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em"
315
314
  }));
316
315
  });
317
316
  ae.displayName = "CloseSingle";
318
- const ut = "univer-zen-editor", ht = "univer-zen-editor-icon-wrapper", _t = "univer-zen-editor-icon-container", ft = "univer-zen-editor-icon-success", gt = "univer-zen-editor-icon-error", vt = "univer-zen-editor-canvas-container", C = {
317
+ const ut = "univer-zen-editor", ht = "univer-zen-editor-icon-wrapper", ft = "univer-zen-editor-icon-container", _t = "univer-zen-editor-icon-success", gt = "univer-zen-editor-icon-error", vt = "univer-zen-editor-canvas-container", C = {
319
318
  zenEditor: ut,
320
319
  zenEditorIconWrapper: ht,
321
- zenEditorIconContainer: _t,
322
- zenEditorIconSuccess: ft,
320
+ zenEditorIconContainer: ft,
321
+ zenEditorIconSuccess: _t,
323
322
  zenEditorIconError: gt,
324
323
  zenEditorCanvasContainer: vt
325
324
  }, pt = "ZEN_EDITOR_PLUGIN_", mt = `${pt}ZEN_EDITOR_COMPONENT`;
326
325
  function St() {
327
- const t = ie(null), e = U(ne), i = U(B), n = U(j);
326
+ const t = ie(null), e = U(ne), i = U($), n = U(j);
328
327
  He(() => {
329
328
  const s = t.current;
330
329
  if (!s)
331
330
  return;
332
331
  const c = e.currentRender$.subscribe((u) => {
333
332
  var g;
334
- if (u !== _)
333
+ if (u !== f)
335
334
  return;
336
- const d = (g = e.getRenderById(_)) == null ? void 0 : g.engine;
335
+ const d = (g = e.getRenderById(f)) == null ? void 0 : g.engine;
337
336
  d == null || d.setContainer(s);
338
337
  }), a = new ResizeObserver(() => {
339
338
  const u = s.getBoundingClientRect();
@@ -404,7 +403,7 @@ let y = class extends Oe {
404
403
  this.disposeWithMe(this._zenZoneService.set(mt, St));
405
404
  }
406
405
  _initCommands() {
407
- [$, F, W].forEach((t) => {
406
+ [B, F, W].forEach((t) => {
408
407
  this.disposeWithMe(this._commandService.registerCommand(t));
409
408
  });
410
409
  }
@@ -449,7 +448,7 @@ let J = (b = class extends Re {
449
448
  }
450
449
  ],
451
450
  [N],
452
- [B, { useClass: Ke }]
451
+ [$, { useClass: Ke }]
453
452
  ].forEach((i) => t.add(i));
454
453
  }
455
454
  }, E(b, "pluginName", "zen-editor"), E(b, "type", T.UNIVER_DOC), b);
@@ -460,6 +459,6 @@ J = Nt([
460
459
  export {
461
460
  F as CancelZenEditCommand,
462
461
  W as ConfirmZenEditCommand,
463
- $ as OpenZenEditorOperation,
462
+ B as OpenZenEditorOperation,
464
463
  J as UniverSheetsZenEditorPlugin
465
464
  };
@@ -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/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets"),require("react"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs","@univerjs/engine-render","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/sheets","react","clsx"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.UniverSheetsZenEditor={},d.UniverCore,d.UniverDocs,d.UniverEngineRender,d.UniverSheetsUi,d.UniverUi,d.rxjs,d.UniverSheets,d.React,d.clsx))})(this,function(d,s,S,U,b,v,F,j,E,W){"use strict";var ze=Object.defineProperty;var Ue=(d,s,S)=>s in d?ze(d,s,{enumerable:!0,configurable:!0,writable:!0,value:S}):d[s]=S;var N=(d,s,S)=>Ue(d,typeof s!="symbol"?s+"":s,S);var A;const D={id:"zen-editor.operation.open-zen-editor",type:s.CommandType.OPERATION,handler:n=>!0};class J{constructor(){N(this,"_position",null);N(this,"_position$",new F.BehaviorSubject(null));N(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(t){this._position=t,this._refresh(t)}getPosition(){return this._position}_refresh(t){this._position$.next(t)}}const V=s.createIdentifier("univer.sheet-zen-editor-manager.service");var Q=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,te=(n,t,i,e)=>{for(var r=e>1?void 0:e?ee(t,i):t,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&Q(t,i,r),r},C=(n,t)=>(i,e)=>t(i,e,n);const h="__defaultDocumentZenEditorSpecialUnitId_20231218__";let P=class extends s.RxDisposable{constructor(t,i,e,r,c,o,a,l){super();N(this,"_zenEditorInitialState",!1);this._univerInstanceService=t,this._zenEditorManagerService=i,this._renderManagerService=e,this._commandService=r,this._zenZoneService=c,this._editorBridgeService=o,this._undoRedoService=a,this._textSelectionManagerService=l,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const t={id:h,body:{dataStream:`${s.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],customBlocks:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:595,height:842},documentFlavor:s.DocumentFlavor.MODERN,marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};return this._univerInstanceService.createUnit(s.UniverInstanceType.UNIVER_DOC,t)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(F.takeUntil(this.dispose$)).subscribe(t=>{var l;if(t==null)return;const i=b.getEditorObject(h,this._renderManagerService),e=this._univerInstanceService.getUniverDocInstance(h);if(i==null||e==null)return;const{width:r,height:c}=t,{engine:o}=i,a=(l=this._renderManagerService.getRenderById(h))==null?void 0:l.with(S.DocSkeletonManagerService).getSkeleton();requestIdleCallback(()=>{o.resizeBySize(r,c),this._calculatePagePosition(i),a&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){var c;this._zenEditorInitialState||(this._createZenEditorInstance(),this._zenEditorInitialState=!0),this._zenZoneService.open();const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);this._undoRedoService.clearUndoRedo(h),this._univerInstanceService.focusUnit(h),this._univerInstanceService.setCurrentUnitForType(h),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:U.DeviceInputEventType.PointerDown,unitId:(c=t==null?void 0:t.getUnitId())!=null?c:""});const e=this._editorBridgeService.getLatestEditCellState();if(e==null)return;this._editorSyncHandler(e);const r=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(r)}_editorSyncHandler(t){var o,a;const i=(o=t.documentLayoutObject.documentModel)==null?void 0:o.getBody(),e=i==null?void 0:i.dataStream,r=i==null?void 0:i.paragraphs;let c=[];e==null||r==null||((a=i==null?void 0:i.textRuns)!=null&&a.length&&(c=i==null?void 0:i.textRuns),this._syncContentAndRender(h,e,r,c))}_syncContentAndRender(t,i,e,r=[],c=[],o={},a=[],l=[]){var O;const g=[h,s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],u=(O=this._renderManagerService.getRenderById(t))==null?void 0:O.with(S.DocSkeletonManagerService),I=u==null?void 0:u.getSkeleton(),p=this._univerInstanceService.getUniverDocInstance(t),m=u==null?void 0:u.getViewModel();if(p==null||m==null||I==null)return;const _=p.getBody(),z=p.getSnapshot();_.dataStream=i,_.paragraphs=e,_.customBlocks=c,_.customRanges=l,z.drawings=o,z.drawingsOrder=a,t===s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(_.textRuns=[]),r.length>0&&(_.textRuns=r),m.reset(p);const R=this._getDocObject();R!=null&&(I.calculate(),g.includes(t)&&R.document.makeDirty())}_calculatePagePosition(t){const{document:i,scene:e,docBackground:r}=t,c=e==null?void 0:e.getParent(),{width:o,height:a,pageMarginLeft:l,pageMarginTop:g}=i;if(c==null||o===Number.POSITIVE_INFINITY||a===Number.POSITIVE_INFINITY)return;const{width:u,height:I}=c;let p=0,m=0,_=0,z=0,R=Number.POSITIVE_INFINITY;const{scaleX:O,scaleY:Re}=e.getAncestorScale();u>(o+l*2)*O?(p=u/2-o*O/2,p/=O,_=(u-l*2)/O,R=0):(p=l,_=o+l*2,R=(_-u/O)/2),I>a?(m=I/2-a/2,z=(I-g*2)/Re):(m=g,z=a+g*2),e.resize(_,z+200),i.translate(p,m),r.translate(p,m);const k=e.getViewport(S.VIEWPORT_KEY.VIEW_MAIN);if(R!==Number.POSITIVE_INFINITY&&k!=null){const Ne=k.transScroll2ViewportScrollValue(R,0).x;k.scrollTo({x:Ne})}return this}_commandExecutedListener(){const t=[D.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{t.includes(e.id)&&this._handleOpenZenEditor()}));const i=[S.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const r=e.params,{unitId:c}=r;if(c===h){const o=this._univerInstanceService.getUniverDocInstance(c),a=o==null?void 0:o.getBody(),l=a==null?void 0:a.dataStream,g=a==null?void 0:a.paragraphs,u=a==null?void 0:a.textRuns,I=a==null?void 0:a.customBlocks,p=o==null?void 0:o.getDrawings(),m=o==null?void 0:o.getDrawingsOrder(),_=o==null?void 0:o.getCustomRanges();if(this._editorBridgeService.changeEditorDirty(!0),l==null||g==null)return;this._syncContentAndRender(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l,g,u,I,p,m,_)}}}))}_getDocObject(){return S.getDocObject(this._univerInstanceService,this._renderManagerService)}};P=te([s.OnLifecycle(s.LifecycleStages.Steady,P),C(0,s.IUniverInstanceService),C(1,V),C(2,U.IRenderManagerService),C(3,s.ICommandService),C(4,v.IZenZoneService),C(5,b.IEditorBridgeService),C(6,s.IUndoRedoService),C(7,s.Inject(S.TextSelectionManagerService))],P);const w={id:"zen-editor.command.cancel-zen-edit",type:s.CommandType.COMMAND,handler:async n=>{const t=n.get(v.IZenZoneService),i=n.get(b.IEditorBridgeService),e=n.get(s.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:U.DeviceInputEventType.Keyboard,keycode:v.KeyCode.ESC,unitId:""}),t.close();const c=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);return c?(e.focusUnit(c.getUnitId()),i.refreshEditCellState(),!0):!1}},Z={id:"zen-editor.command.confirm-zen-edit",type:s.CommandType.COMMAND,handler:async n=>{const t=n.get(v.IZenZoneService),i=n.get(b.IEditorBridgeService),e=n.get(s.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:U.DeviceInputEventType.PointerDown,unitId:""}),t.close();const c=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);return c?(e.focusUnit(c.getUnitId()),i.refreshEditCellState(),!0):!1}};function ne(n){return{id:D.id,group:v.MenuGroup.CONTEXT_MENU_OTHERS,type:v.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[v.MenuPosition.CONTEXT_MENU],disabled$:b.getCurrentRangeDisable$(n,{workbookTypes:[j.WorkbookEditablePermission],worksheetTypes:[j.WorksheetEditPermission,j.WorksheetSetCellValuePermission,j.WorksheetSetCellStylePermission],rangeTypes:[j.RangeProtectionPermissionEditPoint]})}}var Y={exports:{}},L={};/**
1
+ (function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets"),require("react"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs","@univerjs/engine-render","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/sheets","react","clsx"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.UniverSheetsZenEditor={},d.UniverCore,d.UniverDocs,d.UniverEngineRender,d.UniverSheetsUi,d.UniverUi,d.rxjs,d.UniverSheets,d.React,d.clsx))})(this,function(d,s,E,D,U,_,k,z,S,Y){"use strict";var ye=Object.defineProperty;var De=(d,s,E)=>s in d?ye(d,s,{enumerable:!0,configurable:!0,writable:!0,value:E}):d[s]=E;var R=(d,s,E)=>De(d,typeof s!="symbol"?s+"":s,E);var L;const x={id:"zen-editor.operation.open-zen-editor",type:s.CommandType.OPERATION,handler:n=>!0};class q{constructor(){R(this,"_position",null);R(this,"_position$",new k.BehaviorSubject(null));R(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(t){this._position=t,this._refresh(t)}getPosition(){return this._position}_refresh(t){this._position$.next(t)}}const A=s.createIdentifier("univer.sheet-zen-editor-manager.service");var J=Object.defineProperty,Q=Object.getOwnPropertyDescriptor,ee=(n,t,i,e)=>{for(var r=e>1?void 0:e?Q(t,i):t,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&J(t,i,r),r},m=(n,t)=>(i,e)=>t(i,e,n);let M=class extends s.RxDisposable{constructor(t,i,e,r,c,o,a,l){super();R(this,"_zenEditorInitialState",!1);this._univerInstanceService=t,this._zenEditorManagerService=i,this._renderManagerService=e,this._commandService=r,this._zenZoneService=c,this._editorBridgeService=o,this._undoRedoService=a,this._textSelectionManagerService=l,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const t={id:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${s.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],customBlocks:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:595,height:842},documentFlavor:s.DocumentFlavor.MODERN,marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};return this._univerInstanceService.createUnit(s.UniverInstanceType.UNIVER_DOC,t)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(k.takeUntil(this.dispose$)).subscribe(t=>{var l;if(t==null)return;const i=U.getEditorObject(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService),e=this._univerInstanceService.getUniverDocInstance(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(i==null||e==null)return;const{width:r,height:c}=t,{engine:o}=i,a=(l=this._renderManagerService.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:l.with(E.DocSkeletonManagerService).getSkeleton();requestIdleCallback(()=>{o.resizeBySize(r,c),this._calculatePagePosition(i),a&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){var c;this._zenEditorInitialState||(this._createZenEditorInstance(),this._zenEditorInitialState=!0),this._zenZoneService.open();const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);this._undoRedoService.clearUndoRedo(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._univerInstanceService.focusUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._univerInstanceService.setCurrentUnitForType(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:D.DeviceInputEventType.PointerDown,unitId:(c=t==null?void 0:t.getUnitId())!=null?c:""});const e=this._editorBridgeService.getLatestEditCellState();if(e==null)return;this._editorSyncHandler(e);const r=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(r)}_editorSyncHandler(t){var o,a;const i=(o=t.documentLayoutObject.documentModel)==null?void 0:o.getBody(),e=i==null?void 0:i.dataStream,r=i==null?void 0:i.paragraphs;let c=[];e==null||r==null||((a=i==null?void 0:i.textRuns)!=null&&a.length&&(c=i==null?void 0:i.textRuns),this._syncContentAndRender(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,e,r,c))}_syncContentAndRender(t,i,e,r=[],c=[],o={},a=[],l=[]){var C;const f=[s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],u=(C=this._renderManagerService.getRenderById(t))==null?void 0:C.with(E.DocSkeletonManagerService),g=u==null?void 0:u.getSkeleton(),I=this._univerInstanceService.getUniverDocInstance(t),p=u==null?void 0:u.getViewModel();if(I==null||p==null||g==null)return;const v=I.getBody(),y=I.getSnapshot();v.dataStream=i,v.paragraphs=e,v.customBlocks=c,v.customRanges=l,y.drawings=o,y.drawingsOrder=a,t===s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(v.textRuns=[]),r.length>0&&(v.textRuns=r),p.reset(I);const N=this._getDocObject();N!=null&&(g.calculate(),f.includes(t)&&N.document.makeDirty())}_calculatePagePosition(t){const{document:i,scene:e,docBackground:r}=t,c=e==null?void 0:e.getParent(),{width:o,height:a,pageMarginLeft:l,pageMarginTop:f}=i;if(c==null||o===Number.POSITIVE_INFINITY||a===Number.POSITIVE_INFINITY)return;const{width:u,height:g}=c;let I=0,p=0,v=0,y=0,N=Number.POSITIVE_INFINITY;const{scaleX:C,scaleY:Ne}=e.getAncestorScale();u>(o+l*2)*C?(I=u/2-o*C/2,I/=C,v=(u-l*2)/C,N=0):(I=l,v=o+l*2,N=(v-u/C)/2),g>a?(p=g/2-a/2,y=(g-f*2)/Ne):(p=f,y=a+f*2),e.resize(v,y+200),i.translate(I,p),r.translate(I,p);const B=e.getViewport(E.VIEWPORT_KEY.VIEW_MAIN);if(N!==Number.POSITIVE_INFINITY&&B!=null){const Re=B.transScroll2ViewportScrollValue(N,0).x;B.scrollToBarPos({x:Re})}return this}_commandExecutedListener(){const t=[x.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{t.includes(e.id)&&this._handleOpenZenEditor()}));const i=[E.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const r=e.params,{unitId:c}=r;if(c===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY){const o=this._univerInstanceService.getUniverDocInstance(c),a=o==null?void 0:o.getBody(),l=a==null?void 0:a.dataStream,f=a==null?void 0:a.paragraphs,u=a==null?void 0:a.textRuns,g=a==null?void 0:a.customBlocks,I=o==null?void 0:o.getDrawings(),p=o==null?void 0:o.getDrawingsOrder(),v=o==null?void 0:o.getCustomRanges();if(this._editorBridgeService.changeEditorDirty(!0),l==null||f==null)return;this._syncContentAndRender(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l,f,u,g,I,p,v)}}}))}_getDocObject(){return E.getDocObject(this._univerInstanceService,this._renderManagerService)}};M=ee([s.OnLifecycle(s.LifecycleStages.Steady,M),m(0,s.IUniverInstanceService),m(1,A),m(2,D.IRenderManagerService),m(3,s.ICommandService),m(4,_.IZenZoneService),m(5,U.IEditorBridgeService),m(6,s.IUndoRedoService),m(7,s.Inject(E.TextSelectionManagerService))],M);const P={id:"zen-editor.command.cancel-zen-edit",type:s.CommandType.COMMAND,handler:async n=>{const t=n.get(_.IZenZoneService),i=n.get(U.IEditorBridgeService),e=n.get(s.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:D.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC,unitId:""}),t.close();const c=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);return c?(e.focusUnit(c.getUnitId()),i.refreshEditCellState(),!0):!1}},Z={id:"zen-editor.command.confirm-zen-edit",type:s.CommandType.COMMAND,handler:async n=>{const t=n.get(_.IZenZoneService),i=n.get(U.IEditorBridgeService),e=n.get(s.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:D.DeviceInputEventType.PointerDown,unitId:""}),t.close();const c=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);return c?(e.focusUnit(c.getUnitId()),i.refreshEditCellState(),!0):!1}};function te(n){return{id:x.id,group:_.MenuGroup.CONTEXT_MENU_OTHERS,type:_.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[_.MenuPosition.CONTEXT_MENU],disabled$:U.getCurrentRangeDisable$(n,{workbookTypes:[z.WorkbookEditablePermission],worksheetTypes:[z.WorksheetEditPermission,z.WorksheetSetCellValuePermission,z.WorksheetSetCellStylePermission],rangeTypes:[z.RangeProtectionPermissionEditPoint]})}}var F={exports:{}},w={};/**
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 ie=E,re=Symbol.for("react.element"),se=Symbol.for("react.fragment"),oe=Object.prototype.hasOwnProperty,ce=ie.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ae={key:!0,ref:!0,__self:!0,__source:!0};function K(n,t,i){var e,r={},c=null,o=null;i!==void 0&&(c=""+i),t.key!==void 0&&(c=""+t.key),t.ref!==void 0&&(o=t.ref);for(e in t)oe.call(t,e)&&!ae.hasOwnProperty(e)&&(r[e]=t[e]);if(n&&n.defaultProps)for(e in t=n.defaultProps,t)r[e]===void 0&&(r[e]=t[e]);return{$$typeof:re,type:n,key:c,ref:o,props:r,_owner:ce.current}}L.Fragment=se,L.jsx=K,L.jsxs=K,Y.exports=L;var y=Y.exports,f=function(){return f=Object.assign||function(n){for(var t,i=1,e=arguments.length;i<e;i++){t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},f.apply(this,arguments)},de=function(n,t){var i={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.indexOf(e)<0&&(i[e]=n[e]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(n);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(n,e[r])&&(i[e[r]]=n[e[r]]);return i},B=E.forwardRef(function(n,t){var i=n.icon,e=n.id,r=n.className,c=n.extend,o=de(n,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),l=E.useRef("_".concat(ve()));return H(i,"".concat(e),{defIds:i.defIds,idSuffix:l.current},f({ref:t,className:a},o),c)});function H(n,t,i,e,r){return E.createElement(n.tag,f(f({key:t},le(n,i,r)),e),(ue(n,i).children||[]).map(function(c,o){return H(c,"".concat(t,"-").concat(n.tag,"-").concat(o),i,void 0,r)}))}function le(n,t,i){var e=f({},n.attrs);i!=null&&i.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=i.colorChannel1);var r=t.defIds;return!r||r.length===0||(n.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(c){var o=c[0],a=c[1];typeof a=="string"&&(e[o]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function ue(n,t){var i,e=t.defIds;return!e||e.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?f(f({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?f(f({},r),{attrs:f(f({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):n}function ve(){return Math.random().toString(36).substring(2,8)}B.displayName="UniverIcon";var _e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},X=E.forwardRef(function(n,t){return E.createElement(B,Object.assign({},n,{id:"check-mark-single",ref:t,icon:_e}))});X.displayName="CheckMarkSingle";var he={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"}}]},$=E.forwardRef(function(n,t){return E.createElement(B,Object.assign({},n,{id:"close-single",ref:t,icon:he}))});$.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"},fe="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT";function ge(){const n=E.useRef(null),t=s.useDependency(U.IRenderManagerService),i=s.useDependency(V),e=s.useDependency(s.ICommandService);E.useEffect(()=>{const o=n.current;if(!o)return;const a=t.currentRender$.subscribe(g=>{var I;if(g!==h)return;const u=(I=t.getRenderById(h))==null?void 0:I.engine;u==null||u.setContainer(o)}),l=new ResizeObserver(()=>{const g=o.getBoundingClientRect();i.setPosition(g)});return l.observe(o),()=>{l.unobserve(o),a.unsubscribe()}},[]);function r(){e.executeCommand(w.id)}function c(){e.executeCommand(Z.id)}return y.jsxs("div",{className:T.zenEditor,children:[y.jsxs("div",{className:T.zenEditorIconWrapper,children:[y.jsx("span",{className:W(T.zenEditorIconContainer,T.zenEditorIconError),onClick:r,children:y.jsx($,{style:{fontSize:"22px"}})}),y.jsx("span",{className:W(T.zenEditorIconContainer,T.zenEditorIconSuccess),onClick:c,children:y.jsx(X,{style:{fontSize:"22px"}})})]}),y.jsx("div",{className:T.zenEditorCanvasContainer,ref:n})]})}const pe={id:Z.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:n=>G(n),binding:v.KeyCode.ENTER|v.MetaKeys.ALT},Se={id:w.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:n=>G(n),binding:v.KeyCode.ESC};function G(n){return n.getContextValue(s.FOCUSING_DOC)&&n.getContextValue(s.FOCUSING_UNIVER_EDITOR)&&n.getContextValue(s.EDITOR_ACTIVATED)&&!n.getContextValue(s.FOCUSING_EDITOR_STANDALONE)}var Ie=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,me=(n,t,i,e)=>{for(var r=e>1?void 0:e?Ee(t,i):t,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&Ie(t,i,r),r},x=(n,t)=>(i,e)=>t(i,e,n);const Ce={};let M=class extends s.Disposable{constructor(n,t,i,e,r,c){super(),this._config=n,this._injector=t,this._zenZoneService=i,this._commandService=e,this._menuService=r,this._shortcutService=c,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(fe,ge))}_initCommands(){[D,w,Z].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initMenus(){const{menu:n={}}=this._config;[ne].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t),n))})}_initShortcuts(){[pe,Se].forEach(n=>{this.disposeWithMe(this._shortcutService.registerShortcut(n))})}};M=me([s.OnLifecycle(s.LifecycleStages.Rendered,M),x(1,s.Inject(s.Injector)),x(2,v.IZenZoneService),x(3,s.ICommandService),x(4,v.IMenuService),x(5,v.IShortcutService)],M);var Oe=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Te=(n,t,i,e)=>{for(var r=e>1?void 0:e?ye(t,i):t,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&Oe(t,i,r),r},q=(n,t)=>(i,e)=>t(i,e,n);d.UniverSheetsZenEditorPlugin=(A=class extends s.Plugin{constructor(t={},i,e){super(),this._config=t,this._injector=i,this._localeService=e,this._initializeDependencies(this._injector),this._config=s.Tools.deepMerge({},Ce,this._config)}_initializeDependencies(t){[[M,{useFactory:()=>this._injector.createInstance(M,this._config)}],[P],[V,{useClass:J}]].forEach(e=>t.add(e))}},N(A,"pluginName","zen-editor"),N(A,"type",s.UniverInstanceType.UNIVER_DOC),A),d.UniverSheetsZenEditorPlugin=Te([q(1,s.Inject(s.Injector)),q(2,s.Inject(s.LocaleService))],d.UniverSheetsZenEditorPlugin),d.CancelZenEditCommand=w,d.ConfirmZenEditCommand=Z,d.OpenZenEditorOperation=D,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
9
+ */var ne=S,ie=Symbol.for("react.element"),re=Symbol.for("react.fragment"),se=Object.prototype.hasOwnProperty,oe=ne.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ce={key:!0,ref:!0,__self:!0,__source:!0};function K(n,t,i){var e,r={},c=null,o=null;i!==void 0&&(c=""+i),t.key!==void 0&&(c=""+t.key),t.ref!==void 0&&(o=t.ref);for(e in t)se.call(t,e)&&!ce.hasOwnProperty(e)&&(r[e]=t[e]);if(n&&n.defaultProps)for(e in t=n.defaultProps,t)r[e]===void 0&&(r[e]=t[e]);return{$$typeof:ie,type:n,key:c,ref:o,props:r,_owner:oe.current}}w.Fragment=re,w.jsx=K,w.jsxs=K,F.exports=w;var O=F.exports,h=function(){return h=Object.assign||function(n){for(var t,i=1,e=arguments.length;i<e;i++){t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},h.apply(this,arguments)},ae=function(n,t){var i={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.indexOf(e)<0&&(i[e]=n[e]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(n);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(n,e[r])&&(i[e[r]]=n[e[r]]);return i},V=S.forwardRef(function(n,t){var i=n.icon,e=n.id,r=n.className,c=n.extend,o=ae(n,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),l=S.useRef("_".concat(ue()));return W(i,"".concat(e),{defIds:i.defIds,idSuffix:l.current},h({ref:t,className:a},o),c)});function W(n,t,i,e,r){return S.createElement(n.tag,h(h({key:t},de(n,i,r)),e),(le(n,i).children||[]).map(function(c,o){return W(c,"".concat(t,"-").concat(n.tag,"-").concat(o),i,void 0,r)}))}function de(n,t,i){var e=h({},n.attrs);i!=null&&i.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=i.colorChannel1);var r=t.defIds;return!r||r.length===0||(n.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(c){var o=c[0],a=c[1];typeof a=="string"&&(e[o]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function le(n,t){var i,e=t.defIds;return!e||e.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?h(h({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?h(h({},r),{attrs:h(h({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):n}function ue(){return Math.random().toString(36).substring(2,8)}V.displayName="UniverIcon";var _e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},H=S.forwardRef(function(n,t){return S.createElement(V,Object.assign({},n,{id:"check-mark-single",ref:t,icon:_e}))});H.displayName="CheckMarkSingle";var ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},X=S.forwardRef(function(n,t){return S.createElement(V,Object.assign({},n,{id:"close-single",ref:t,icon:ve}))});X.displayName="CloseSingle";const T={zenEditor:"univer-zen-editor",zenEditorIconWrapper:"univer-zen-editor-icon-wrapper",zenEditorIconContainer:"univer-zen-editor-icon-container",zenEditorIconSuccess:"univer-zen-editor-icon-success",zenEditorIconError:"univer-zen-editor-icon-error",zenEditorCanvasContainer:"univer-zen-editor-canvas-container"},he="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT";function fe(){const n=S.useRef(null),t=s.useDependency(D.IRenderManagerService),i=s.useDependency(A),e=s.useDependency(s.ICommandService);S.useEffect(()=>{const o=n.current;if(!o)return;const a=t.currentRender$.subscribe(f=>{var g;if(f!==s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)return;const u=(g=t.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:g.engine;u==null||u.setContainer(o)}),l=new ResizeObserver(()=>{const f=o.getBoundingClientRect();i.setPosition(f)});return l.observe(o),()=>{l.unobserve(o),a.unsubscribe()}},[]);function r(){e.executeCommand(P.id)}function c(){e.executeCommand(Z.id)}return O.jsxs("div",{className:T.zenEditor,children:[O.jsxs("div",{className:T.zenEditorIconWrapper,children:[O.jsx("span",{className:Y(T.zenEditorIconContainer,T.zenEditorIconError),onClick:r,children:O.jsx(X,{style:{fontSize:"22px"}})}),O.jsx("span",{className:Y(T.zenEditorIconContainer,T.zenEditorIconSuccess),onClick:c,children:O.jsx(H,{style:{fontSize:"22px"}})})]}),O.jsx("div",{className:T.zenEditorCanvasContainer,ref:n})]})}const Ie={id:Z.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:n=>$(n),binding:_.KeyCode.ENTER|_.MetaKeys.ALT},Ee={id:P.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:n=>$(n),binding:_.KeyCode.ESC};function $(n){return n.getContextValue(s.FOCUSING_DOC)&&n.getContextValue(s.FOCUSING_UNIVER_EDITOR)&&n.getContextValue(s.EDITOR_ACTIVATED)&&!n.getContextValue(s.FOCUSING_EDITOR_STANDALONE)}var ge=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,pe=(n,t,i,e)=>{for(var r=e>1?void 0:e?Se(t,i):t,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&ge(t,i,r),r},b=(n,t)=>(i,e)=>t(i,e,n);const me={};let j=class extends s.Disposable{constructor(n,t,i,e,r,c){super(),this._config=n,this._injector=t,this._zenZoneService=i,this._commandService=e,this._menuService=r,this._shortcutService=c,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(he,fe))}_initCommands(){[x,P,Z].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initMenus(){const{menu:n={}}=this._config;[te].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t),n))})}_initShortcuts(){[Ie,Ee].forEach(n=>{this.disposeWithMe(this._shortcutService.registerShortcut(n))})}};j=pe([s.OnLifecycle(s.LifecycleStages.Rendered,j),b(1,s.Inject(s.Injector)),b(2,_.IZenZoneService),b(3,s.ICommandService),b(4,_.IMenuService),b(5,_.IShortcutService)],j);var Ce=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Te=(n,t,i,e)=>{for(var r=e>1?void 0:e?Oe(t,i):t,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&Ce(t,i,r),r},G=(n,t)=>(i,e)=>t(i,e,n);d.UniverSheetsZenEditorPlugin=(L=class extends s.Plugin{constructor(t={},i,e){super(),this._config=t,this._injector=i,this._localeService=e,this._initializeDependencies(this._injector),this._config=s.Tools.deepMerge({},me,this._config)}_initializeDependencies(t){[[j,{useFactory:()=>this._injector.createInstance(j,this._config)}],[M],[A,{useClass:q}]].forEach(e=>t.add(e))}},R(L,"pluginName","zen-editor"),R(L,"type",s.UniverInstanceType.UNIVER_DOC),L),d.UniverSheetsZenEditorPlugin=Te([G(1,s.Inject(s.Injector)),G(2,s.Inject(s.LocaleService))],d.UniverSheetsZenEditorPlugin),d.CancelZenEditCommand=P,d.ConfirmZenEditCommand=Z,d.OpenZenEditorOperation=x,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-zen-editor",
3
- "version": "0.2.4-alpha.0",
3
+ "version": "0.2.5",
4
4
  "private": false,
5
5
  "description": "Zen Editor plugin for Univer Sheets.",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,16 +53,16 @@
53
53
  "clsx": ">=2.0.0",
54
54
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
55
55
  "rxjs": ">=7.0.0",
56
- "@univerjs/docs": "0.2.4-alpha.0",
57
- "@univerjs/core": "0.2.4-alpha.0",
58
- "@univerjs/engine-render": "0.2.4-alpha.0",
59
- "@univerjs/sheets-ui": "0.2.4-alpha.0",
60
- "@univerjs/sheets": "0.2.4-alpha.0",
61
- "@univerjs/ui": "0.2.4-alpha.0"
56
+ "@univerjs/core": "0.2.5",
57
+ "@univerjs/engine-render": "0.2.5",
58
+ "@univerjs/docs": "0.2.5",
59
+ "@univerjs/sheets": "0.2.5",
60
+ "@univerjs/sheets-ui": "0.2.5",
61
+ "@univerjs/ui": "0.2.5"
62
62
  },
63
63
  "dependencies": {
64
- "@univerjs/icons": "^0.1.64",
65
- "@univerjs/sheets": "0.2.4-alpha.0"
64
+ "@univerjs/icons": "^0.1.65",
65
+ "@univerjs/sheets": "0.2.5"
66
66
  },
67
67
  "devDependencies": {
68
68
  "clsx": "^2.1.1",
@@ -72,14 +72,14 @@
72
72
  "typescript": "^5.5.3",
73
73
  "vite": "^5.3.4",
74
74
  "vitest": "^2.0.3",
75
- "@univerjs/design": "0.2.4-alpha.0",
76
- "@univerjs/core": "0.2.4-alpha.0",
77
- "@univerjs/docs": "0.2.4-alpha.0",
78
- "@univerjs/engine-render": "0.2.4-alpha.0",
79
- "@univerjs/shared": "0.2.4-alpha.0",
80
- "@univerjs/sheets-ui": "0.2.4-alpha.0",
81
- "@univerjs/ui": "0.2.4-alpha.0",
82
- "@univerjs/sheets": "0.2.4-alpha.0"
75
+ "@univerjs/core": "0.2.5",
76
+ "@univerjs/design": "0.2.5",
77
+ "@univerjs/engine-render": "0.2.5",
78
+ "@univerjs/shared": "0.2.5",
79
+ "@univerjs/sheets": "0.2.5",
80
+ "@univerjs/sheets-ui": "0.2.5",
81
+ "@univerjs/ui": "0.2.5",
82
+ "@univerjs/docs": "0.2.5"
83
83
  },
84
84
  "univerSpace": {
85
85
  ".": {