@univerjs/sheets-zen-editor 0.1.12 → 0.1.14

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 ee=Object.defineProperty;var te=(n,e,i)=>e in n?ee(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var I=(n,e,i)=>(te(n,typeof e!="symbol"?e+"":e,i),i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),S=require("@wendellhu/redi"),C=require("@univerjs/docs"),z=require("@univerjs/engine-render"),D=require("@univerjs/sheets-ui"),_=require("@univerjs/ui"),F=require("rxjs"),p=require("react"),Z=require("@wendellhu/redi/react-bindings"),B=require("clsx"),L={id:"zen-editor.operation.open-zen-editor",type:a.CommandType.OPERATION,handler:n=>!0};class ne{constructor(){I(this,"_position",null);I(this,"_position$",new F.BehaviorSubject(null));I(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 w=S.createIdentifier("univer.sheet-zen-editor-manager.service");var ie=Object.defineProperty,re=Object.getOwnPropertyDescriptor,oe=(n,e,i,t)=>{for(var r=t>1?void 0:t?re(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&&ie(e,i,r),r},g=(n,e)=>(i,t)=>e(i,t,n);const v="__defaultDocumentZenEditorSpecialUnitId_20231218__";let b=class extends a.RxDisposable{constructor(e,i,t,r,o,s,c,d,l,u,h){super();I(this,"_zenEditorInitialState",!1);this._injector=e,this._univerInstanceService=i,this._zenEditorManagerService=t,this._renderManagerService=r,this._commandService=o,this._zenZoneService=s,this._editorBridgeService=c,this._undoRedoService=d,this._textSelectionManagerService=l,this._docSkeletonManagerService=u,this._docViewModelManagerService=h,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const e={id:v,body:{dataStream:`${a.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:595,height:842},marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}}};return this._univerInstanceService.createUnit(a.UniverInstanceType.UNIVER_DOC,e)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(F.takeUntil(this.dispose$)).subscribe(e=>{var d;if(e==null)return;const i=D.getEditorObject(v,this._renderManagerService),t=this._univerInstanceService.getUniverDocInstance(v);if(i==null||t==null)return;const{width:r,height:o}=e,{engine:s}=i,c=(d=this._docSkeletonManagerService.getSkeletonByUnitId(v))==null?void 0:d.skeleton;requestIdleCallback(()=>{s.resizeBySize(r,o),this._calculatePagePosition(i),c&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){this._zenEditorInitialState||(this._createZenEditorInstance(),this._zenEditorInitialState=!0),this._zenZoneService.open(),this._undoRedoService.clearUndoRedo(v),this._univerInstanceService.focusUnit(v),this._univerInstanceService.setCurrentUnitForType(v),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:z.DeviceInputEventType.PointerDown});const i=this._editorBridgeService.getLatestEditCellState();if(i==null)return;this._editorSyncHandler(i);const t=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(t)}_editorSyncHandler(e){var s,c;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||((c=i==null?void 0:i.textRuns)!=null&&c.length&&(o=i==null?void 0:i.textRuns),this._syncContentAndRender(v,t,r,o))}_syncContentAndRender(e,i,t,r=[]){const o=[v,a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=this._docSkeletonManagerService.getSkeletonByUnitId(e),c=this._univerInstanceService.getUniverDocInstance(e),d=this._docViewModelManagerService.getViewModel(e);if(c==null||d==null||s==null)return;const l=c.getBody();l.dataStream=i,l.paragraphs=t,e===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(l.textRuns=[]),r.length>0&&(l.textRuns=r),d.reset(c);const{skeleton:u}=s,h=this._getDocObject();h!=null&&(u.calculate(),o.includes(e)&&h.document.makeDirty())}_calculatePagePosition(e){const{document:i,scene:t}=e,r=t==null?void 0:t.getParent(),{width:o,height:s,pageMarginLeft:c,pageMarginTop:d}=i;if(r==null||o===Number.POSITIVE_INFINITY||s===Number.POSITIVE_INFINITY)return;const{width:l,height:u}=r;let h=0,U=0,R=0,j=0,M=Number.POSITIVE_INFINITY;const{scaleX:O,scaleY:J}=t.getAncestorScale();l>(o+c*2)*O?(h=l/2-o*O/2,h/=O,R=(l-c*2)/O,M=0):(h=c,R=o+c*2,M=(R-l/O)/2),u>s?(U=u/2-s/2,j=(u-d*2)/J):(U=d,j=s+d*2),t.resize(R,j+200),i.translate(h,U);const P=t.getViewport(C.VIEWPORT_KEY.VIEW_MAIN);if(M!==Number.POSITIVE_INFINITY&&P!=null){const Q=P.getBarScroll(M,0).x;P.scrollTo({x:Q})}return this}_commandExecutedListener(){const e=[L.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{e.includes(t.id)&&this._handleOpenZenEditor()}));const i=[C.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(i.includes(t.id)){const r=t.params,{unitId:o}=r;if(o===v){const s=this._univerInstanceService.getUniverDocInstance(o),c=s==null?void 0:s.getBody(),d=c==null?void 0:c.dataStream,l=c==null?void 0:c.paragraphs,u=c==null?void 0:c.textRuns;if(this._editorBridgeService.changeEditorDirty(!0),d==null||l==null)return;this._syncContentAndRender(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,d,l,u)}}}))}_getDocObject(){return C.getDocObject(this._univerInstanceService,this._renderManagerService)}};b=oe([a.OnLifecycle(a.LifecycleStages.Steady,b),g(0,S.Inject(S.Injector)),g(1,a.IUniverInstanceService),g(2,w),g(3,z.IRenderManagerService),g(4,a.ICommandService),g(5,_.IZenZoneService),g(6,D.IEditorBridgeService),g(7,a.IUndoRedoService),g(8,S.Inject(C.TextSelectionManagerService)),g(9,S.Inject(C.DocSkeletonManagerService)),g(10,S.Inject(C.DocViewModelManagerService))],b);const A={id:"zen-editor.command.cancel-zen-edit",type:a.CommandType.COMMAND,handler:async n=>{const e=n.get(_.IZenZoneService),i=n.get(D.IEditorBridgeService),t=n.get(a.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:z.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC}),e.close();const o=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return o?(t.focusUnit(o.getUnitId()),i.refreshEditCellState(),!0):!1}},$={id:"zen-editor.command.confirm-zen-edit",type:a.CommandType.COMMAND,handler:async n=>{const e=n.get(_.IZenZoneService),i=n.get(D.IEditorBridgeService),t=n.get(a.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:z.DeviceInputEventType.PointerDown}),e.close();const o=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return o?(t.focusUnit(o.getUnitId()),i.refreshEditCellState(),!0):!1}};function se(n){return{id:L.id,group:_.MenuGroup.CONTEXT_MENU_OTHERS,type:_.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[_.MenuPosition.CONTEXT_MENU]}}var W={exports:{}},x={};/**
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 I=(n,e,i)=>(ne(n,typeof e!="symbol"?e+"":e,i),i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),S=require("@wendellhu/redi"),C=require("@univerjs/docs"),M=require("@univerjs/engine-render"),N=require("@univerjs/sheets-ui"),_=require("@univerjs/ui"),q=require("rxjs"),T=require("@univerjs/sheets"),p=require("react"),w=require("@wendellhu/redi/react-bindings"),W=require("clsx"),k={id:"zen-editor.operation.open-zen-editor",type:a.CommandType.OPERATION,handler:n=>!0};class ie{constructor(){I(this,"_position",null);I(this,"_position$",new q.BehaviorSubject(null));I(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 re=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,se=(n,e,i,t)=>{for(var r=t>1?void 0:t?oe(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},g=(n,e)=>(i,t)=>e(i,t,n);const h="__defaultDocumentZenEditorSpecialUnitId_20231218__";let P=class extends a.RxDisposable{constructor(e,i,t,r,o,s,c,d,l,u,f){super();I(this,"_zenEditorInitialState",!1);this._injector=e,this._univerInstanceService=i,this._zenEditorManagerService=t,this._renderManagerService=r,this._commandService=o,this._zenZoneService=s,this._editorBridgeService=c,this._undoRedoService=d,this._textSelectionManagerService=l,this._docSkeletonManagerService=u,this._docViewModelManagerService=f,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const e={id:h,body:{dataStream:`${a.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:595,height:842},marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}}};return this._univerInstanceService.createUnit(a.UniverInstanceType.UNIVER_DOC,e)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(q.takeUntil(this.dispose$)).subscribe(e=>{var d;if(e==null)return;const i=N.getEditorObject(h,this._renderManagerService),t=this._univerInstanceService.getUniverDocInstance(h);if(i==null||t==null)return;const{width:r,height:o}=e,{engine:s}=i,c=(d=this._docSkeletonManagerService.getSkeletonByUnitId(h))==null?void 0:d.skeleton;requestIdleCallback(()=>{s.resizeBySize(r,o),this._calculatePagePosition(i),c&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){this._zenEditorInitialState||(this._createZenEditorInstance(),this._zenEditorInitialState=!0),this._zenZoneService.open(),this._undoRedoService.clearUndoRedo(h),this._univerInstanceService.focusUnit(h),this._univerInstanceService.setCurrentUnitForType(h),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:M.DeviceInputEventType.PointerDown});const i=this._editorBridgeService.getLatestEditCellState();if(i==null)return;this._editorSyncHandler(i);const t=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(t)}_editorSyncHandler(e){var s,c;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||((c=i==null?void 0:i.textRuns)!=null&&c.length&&(o=i==null?void 0:i.textRuns),this._syncContentAndRender(h,t,r,o))}_syncContentAndRender(e,i,t,r=[]){const o=[h,a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=this._docSkeletonManagerService.getSkeletonByUnitId(e),c=this._univerInstanceService.getUniverDocInstance(e),d=this._docViewModelManagerService.getViewModel(e);if(c==null||d==null||s==null)return;const l=c.getBody();l.dataStream=i,l.paragraphs=t,e===a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(l.textRuns=[]),r.length>0&&(l.textRuns=r),d.reset(c);const{skeleton:u}=s,f=this._getDocObject();f!=null&&(u.calculate(),o.includes(e)&&f.document.makeDirty())}_calculatePagePosition(e){const{document:i,scene:t,docBackground:r}=e,o=t==null?void 0:t.getParent(),{width:s,height:c,pageMarginLeft:d,pageMarginTop:l}=i;if(o==null||s===Number.POSITIVE_INFINITY||c===Number.POSITIVE_INFINITY)return;const{width:u,height:f}=o;let O=0,z=0,D=0,Z=0,x=Number.POSITIVE_INFINITY;const{scaleX:y,scaleY:Q}=t.getAncestorScale();u>(s+d*2)*y?(O=u/2-s*y/2,O/=y,D=(u-d*2)/y,x=0):(O=d,D=s+d*2,x=(D-u/y)/2),f>c?(z=f/2-c/2,Z=(f-l*2)/Q):(z=l,Z=c+l*2),t.resize(D,Z+200),i.translate(O,z),r.translate(O,z);const L=t.getViewport(C.VIEWPORT_KEY.VIEW_MAIN);if(x!==Number.POSITIVE_INFINITY&&L!=null){const ee=L.getBarScroll(x,0).x;L.scrollTo({x:ee})}return this}_commandExecutedListener(){const e=[k.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{e.includes(t.id)&&this._handleOpenZenEditor()}));const i=[C.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(i.includes(t.id)){const r=t.params,{unitId:o}=r;if(o===h){const s=this._univerInstanceService.getUniverDocInstance(o),c=s==null?void 0:s.getBody(),d=c==null?void 0:c.dataStream,l=c==null?void 0:c.paragraphs,u=c==null?void 0:c.textRuns;if(this._editorBridgeService.changeEditorDirty(!0),d==null||l==null)return;this._syncContentAndRender(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,d,l,u)}}}))}_getDocObject(){return C.getDocObject(this._univerInstanceService,this._renderManagerService)}};P=se([a.OnLifecycle(a.LifecycleStages.Steady,P),g(0,S.Inject(S.Injector)),g(1,a.IUniverInstanceService),g(2,A),g(3,M.IRenderManagerService),g(4,a.ICommandService),g(5,_.IZenZoneService),g(6,N.IEditorBridgeService),g(7,a.IUndoRedoService),g(8,S.Inject(C.TextSelectionManagerService)),g(9,S.Inject(C.DocSkeletonManagerService)),g(10,S.Inject(C.DocViewModelManagerService))],P);const V={id:"zen-editor.command.cancel-zen-edit",type:a.CommandType.COMMAND,handler:async n=>{const e=n.get(_.IZenZoneService),i=n.get(N.IEditorBridgeService),t=n.get(a.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:M.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC}),e.close();const o=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return o?(t.focusUnit(o.getUnitId()),i.refreshEditCellState(),!0):!1}},B={id:"zen-editor.command.confirm-zen-edit",type:a.CommandType.COMMAND,handler:async n=>{const e=n.get(_.IZenZoneService),i=n.get(N.IEditorBridgeService),t=n.get(a.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:M.DeviceInputEventType.PointerDown}),e.close();const o=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return o?(t.focusUnit(o.getUnitId()),i.refreshEditCellState(),!0):!1}};function ce(n){return{id:k.id,group:_.MenuGroup.CONTEXT_MENU_OTHERS,type:_.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[_.MenuPosition.CONTEXT_MENU],disabled$:N.getCurrentRangeDisable$(n,{workbookTypes:[T.WorkbookEditablePermission],worksheetTypes:[T.WorksheetEditPermission,T.WorksheetSetCellValuePermission,T.WorksheetSetCellStylePermission],rangeTypes:[T.RangeProtectionPermissionEditPoint]})}}var Y={exports:{}},j={};/**
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 ce=p,ae=Symbol.for("react.element"),de=Symbol.for("react.fragment"),le=Object.prototype.hasOwnProperty,ue=ce.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,_e={key:!0,ref:!0,__self:!0,__source:!0};function q(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)le.call(e,t)&&!_e.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:ae,type:n,key:o,ref:s,props:r,_owner:ue.current}}x.Fragment=de;x.jsx=q;x.jsxs=q;W.exports=x;var E=W.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)},he=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=p.forwardRef(function(n,e){var i=n.icon,t=n.id,r=n.className,o=n.extend,s=he(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),d=p.useRef("_".concat(ge()));return Y(i,"".concat(t),{defIds:i.defIds,idSuffix:d.current},f({ref:e,className:c},s),o)});function Y(n,e,i,t,r){return p.createElement(n.tag,f(f({key:e},ve(n,i,r)),t),(fe(n,i).children||[]).map(function(o,s){return Y(o,"".concat(e,"-").concat(n.tag,"-").concat(s),i,void 0,r)}))}function ve(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(o){var s=o[0],c=o[1];typeof c=="string"&&(t[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function fe(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 ge(){return Math.random().toString(36).substring(2,8)}V.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"}}]},K=p.forwardRef(function(n,e){return p.createElement(V,Object.assign({},n,{id:"check-mark-single",ref:e,icon:Se}))});K.displayName="CheckMarkSingle";const pe=K;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"}}]},H=p.forwardRef(function(n,e){return p.createElement(V,Object.assign({},n,{id:"close-single",ref:e,icon:Ie}))});H.displayName="CloseSingle";const Ee=H,me="univer-zen-editor",Ce="univer-zen-editor-icon-wrapper",Oe="univer-zen-editor-icon-container",ye="univer-zen-editor-icon-success",Te="univer-zen-editor-icon-error",ze="univer-zen-editor-canvas-container",m={zenEditor:me,zenEditorIconWrapper:Ce,zenEditorIconContainer:Oe,zenEditorIconSuccess:ye,zenEditorIconError:Te,zenEditorCanvasContainer:ze},Re="ZEN_EDITOR_PLUGIN_",Me=`${Re}ZEN_EDITOR_COMPONENT`;function Ne(){const n=p.useRef(null),e=Z.useDependency(z.IRenderManagerService),i=Z.useDependency(w),t=Z.useDependency(a.ICommandService);p.useEffect(()=>{const s=n.current;if(!s)return;const c=e.currentRender$.subscribe(l=>{var h;if(l!==v)return;const u=(h=e.getRenderById(v))==null?void 0:h.engine;u==null||u.setContainer(s)}),d=new ResizeObserver(()=>{const l=s.getBoundingClientRect();i.setPosition(l)});return d.observe(s),()=>{d.unobserve(s),c.unsubscribe()}},[]);function r(){t.executeCommand(A.id)}function o(){t.executeCommand($.id)}return E.jsxs("div",{className:m.zenEditor,children:[E.jsxs("div",{className:m.zenEditorIconWrapper,children:[E.jsx("span",{className:B(m.zenEditorIconContainer,m.zenEditorIconError),onClick:r,children:E.jsx(Ee,{style:{fontSize:"22px"}})}),E.jsx("span",{className:B(m.zenEditorIconContainer,m.zenEditorIconSuccess),onClick:o,children:E.jsx(pe,{style:{fontSize:"22px"}})})]}),E.jsx("div",{className:m.zenEditorCanvasContainer,ref:n})]})}const be={id:$.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:n=>X(n),binding:_.KeyCode.ENTER|_.MetaKeys.ALT},De={id:A.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:n=>X(n),binding:_.KeyCode.ESC};function X(n){return n.getContextValue(a.FOCUSING_DOC)&&n.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&n.getContextValue(a.EDITOR_ACTIVATED)&&!n.getContextValue(a.FOCUSING_EDITOR_STANDALONE)}var xe=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,je=(n,e,i,t)=>{for(var r=t>1?void 0:t?Ue(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&&xe(e,i,r),r},y=(n,e)=>(i,t)=>e(i,t,n);const Pe={};let T=class extends a.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(Me,Ne))}_initCommands(){[L,A,$].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,De].forEach(n=>{this.disposeWithMe(this._shortcutService.registerShortcut(n))})}};T=je([a.OnLifecycle(a.LifecycleStages.Rendered,T),y(1,S.Inject(S.Injector)),y(2,_.IZenZoneService),y(3,a.ICommandService),y(4,_.IMenuService),y(5,_.IShortcutService)],T);const Ze={shortcut:{sheet:{"zen-edit-cancel":"Cancel Zen Edit","zen-edit-confirm":"Confirm Zen Edit"}}},Le=Ze,we={shortcut:{sheet:{"zen-edit-cancel":"取消编辑(禅模式状态)","zen-edit-confirm":"放弃编辑(禅模式状态)"}}},G=we,Ae={shortcut:{sheet:{"zen-edit-cancel":"Отменить Zen редактирование","zen-edit-confirm":"Подтвердить Zen редактирование"}}},$e=Ae;var Ve=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,ke=(n,e,i,t)=>{for(var r=t>1?void 0:t?Be(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&&Ve(e,i,r),r},k=(n,e)=>(i,t)=>e(i,t,n),N;exports.UniverSheetsZenEditorPlugin=(N=class extends a.Plugin{constructor(e={},i,t){super(),this._config=e,this._injector=i,this._localeService=t,this._initialize(),this._initializeDependencies(this._injector),this._config=a.Tools.deepMerge({},Pe,this._config)}_initialize(){this._localeService.load({zhCN:G})}_initializeDependencies(e){[[T,{useFactory:()=>this._injector.createInstance(T,this._config)}],[b],[w,{useClass:ne}]].forEach(t=>e.add(t))}},I(N,"pluginName","zen-editor"),I(N,"type",a.UniverInstanceType.UNIVER_DOC),N);exports.UniverSheetsZenEditorPlugin=ke([k(1,S.Inject(S.Injector)),k(2,S.Inject(a.LocaleService))],exports.UniverSheetsZenEditorPlugin);exports.enUS=Le;exports.ruRU=$e;exports.zhCN=G;
9
+ */var ae=p,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}}j.Fragment=le;j.jsx=K;j.jsxs=K;Y.exports=j;var E=Y.exports,v=function(){return v=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},v.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},$=p.forwardRef(function(n,e){var i=n.icon,t=n.id,r=n.className,o=n.extend,s=ve(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),d=p.useRef("_".concat(Se()));return H(i,"".concat(t),{defIds:i.defIds,idSuffix:d.current},v({ref:e,className:c},s),o)});function H(n,e,i,t,r){return p.createElement(n.tag,v(v({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=v({},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],c=o[1];typeof c=="string"&&(t[s]=c.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)?v(v({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?v(v({},r),{attrs:v(v({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):n}function Se(){return Math.random().toString(36).substring(2,8)}$.displayName="UniverIcon";var pe={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=p.forwardRef(function(n,e){return p.createElement($,Object.assign({},n,{id:"check-mark-single",ref:e,icon:pe}))});X.displayName="CheckMarkSingle";const Ie=X;var Ee={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=p.forwardRef(function(n,e){return p.createElement($,Object.assign({},n,{id:"close-single",ref:e,icon:Ee}))});G.displayName="CloseSingle";const me=G,Ce="univer-zen-editor",Oe="univer-zen-editor-icon-wrapper",ye="univer-zen-editor-icon-container",Te="univer-zen-editor-icon-success",Re="univer-zen-editor-icon-error",be="univer-zen-editor-canvas-container",m={zenEditor:Ce,zenEditorIconWrapper:Oe,zenEditorIconContainer:ye,zenEditorIconSuccess:Te,zenEditorIconError:Re,zenEditorCanvasContainer:be},Me="ZEN_EDITOR_PLUGIN_",Ne=`${Me}ZEN_EDITOR_COMPONENT`;function ze(){const n=p.useRef(null),e=w.useDependency(M.IRenderManagerService),i=w.useDependency(A),t=w.useDependency(a.ICommandService);p.useEffect(()=>{const s=n.current;if(!s)return;const c=e.currentRender$.subscribe(l=>{var f;if(l!==h)return;const u=(f=e.getRenderById(h))==null?void 0:f.engine;u==null||u.setContainer(s)}),d=new ResizeObserver(()=>{const l=s.getBoundingClientRect();i.setPosition(l)});return d.observe(s),()=>{d.unobserve(s),c.unsubscribe()}},[]);function r(){t.executeCommand(V.id)}function o(){t.executeCommand(B.id)}return E.jsxs("div",{className:m.zenEditor,children:[E.jsxs("div",{className:m.zenEditorIconWrapper,children:[E.jsx("span",{className:W(m.zenEditorIconContainer,m.zenEditorIconError),onClick:r,children:E.jsx(me,{style:{fontSize:"22px"}})}),E.jsx("span",{className:W(m.zenEditorIconContainer,m.zenEditorIconSuccess),onClick:o,children:E.jsx(Ie,{style:{fontSize:"22px"}})})]}),E.jsx("div",{className:m.zenEditorCanvasContainer,ref:n})]})}const De={id:B.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:n=>J(n),binding:_.KeyCode.ENTER|_.MetaKeys.ALT},xe={id:V.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:n=>J(n),binding:_.KeyCode.ESC};function J(n){return n.getContextValue(a.FOCUSING_DOC)&&n.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&n.getContextValue(a.EDITOR_ACTIVATED)&&!n.getContextValue(a.FOCUSING_EDITOR_STANDALONE)}var Ue=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&&Ue(e,i,r),r},R=(n,e)=>(i,t)=>e(i,t,n);const Ze={};let b=class extends a.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(Ne,ze))}_initCommands(){[k,V,B].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(){[De,xe].forEach(n=>{this.disposeWithMe(this._shortcutService.registerShortcut(n))})}};b=je([a.OnLifecycle(a.LifecycleStages.Rendered,b),R(1,S.Inject(S.Injector)),R(2,_.IZenZoneService),R(3,a.ICommandService),R(4,_.IMenuService),R(5,_.IShortcutService)],b);var Le=Object.defineProperty,we=Object.getOwnPropertyDescriptor,ke=(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&&Le(e,i,r),r},F=(n,e)=>(i,t)=>e(i,t,n),U;exports.UniverSheetsZenEditorPlugin=(U=class extends a.Plugin{constructor(e={},i,t){super(),this._config=e,this._injector=i,this._localeService=t,this._initializeDependencies(this._injector),this._config=a.Tools.deepMerge({},Ze,this._config)}_initializeDependencies(e){[[b,{useFactory:()=>this._injector.createInstance(b,this._config)}],[P],[A,{useClass:ie}]].forEach(t=>e.add(t))}},I(U,"pluginName","zen-editor"),I(U,"type",a.UniverInstanceType.UNIVER_DOC),U);exports.UniverSheetsZenEditorPlugin=ke([F(1,S.Inject(S.Injector)),F(2,S.Inject(a.LocaleService))],exports.UniverSheetsZenEditorPlugin);
package/lib/es/index.js CHANGED
@@ -1,25 +1,26 @@
1
- var de = Object.defineProperty;
2
- var ue = (t, e, i) => e in t ? de(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
3
- var v = (t, e, i) => (ue(t, typeof e != "symbol" ? e + "" : e, i), i);
4
- import { CommandType as U, RxDisposable as he, UniverInstanceType as M, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as H, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as K, OnLifecycle as J, LifecycleStages as Q, DEFAULT_EMPTY_DOCUMENT_VALUE as _e, IUniverInstanceService as j, ICommandService as P, IUndoRedoService as fe, FOCUSING_DOC as ve, FOCUSING_UNIVER_EDITOR as ge, EDITOR_ACTIVATED as Se, FOCUSING_EDITOR_STANDALONE as pe, Disposable as me, Plugin as Ee, Tools as Ie, LocaleService as Ce } from "@univerjs/core";
5
- import { createIdentifier as Oe, Inject as p, Injector as Z } from "@wendellhu/redi";
6
- import { VIEWPORT_KEY as ze, RichTextEditingMutation as ye, getDocObject as Me, TextSelectionManagerService as Ne, DocSkeletonManagerService as Te, DocViewModelManagerService as be } from "@univerjs/docs";
7
- import { DeviceInputEventType as L, IRenderManagerService as ee } from "@univerjs/engine-render";
8
- import { getEditorObject as Re, IEditorBridgeService as w } from "@univerjs/sheets-ui";
9
- import { IZenZoneService as N, KeyCode as $, MenuGroup as xe, MenuItemType as De, MenuPosition as Ue, MetaKeys as je, IMenuService as Pe, IShortcutService as Ze } from "@univerjs/ui";
10
- import { BehaviorSubject as Le, takeUntil as we } from "rxjs";
11
- import $e, { forwardRef as V, useRef as te, createElement as A, useEffect as Ve } from "react";
12
- import { useDependency as D } from "@wendellhu/redi/react-bindings";
13
- import X from "clsx";
14
- const k = {
1
+ var ue = Object.defineProperty;
2
+ var he = (t, e, i) => e in t ? ue(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
3
+ var v = (t, e, i) => (he(t, typeof e != "symbol" ? e + "" : e, i), i);
4
+ import { CommandType as U, RxDisposable as _e, UniverInstanceType as N, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as K, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as X, OnLifecycle as Q, LifecycleStages as ee, DEFAULT_EMPTY_DOCUMENT_VALUE as fe, IUniverInstanceService as j, ICommandService as w, IUndoRedoService as ve, FOCUSING_DOC as ge, FOCUSING_UNIVER_EDITOR as pe, EDITOR_ACTIVATED as Se, FOCUSING_EDITOR_STANDALONE as me, Disposable as Ee, Plugin as Ie, Tools as Ce, LocaleService as Oe } from "@univerjs/core";
5
+ import { createIdentifier as ye, Inject as S, Injector as L } from "@wendellhu/redi";
6
+ import { VIEWPORT_KEY as be, RichTextEditingMutation as Te, getDocObject as Me, TextSelectionManagerService as Ne, DocSkeletonManagerService as Re, DocViewModelManagerService as ze } from "@univerjs/docs";
7
+ import { DeviceInputEventType as Z, IRenderManagerService as te } from "@univerjs/engine-render";
8
+ import { getEditorObject as xe, IEditorBridgeService as k, getCurrentRangeDisable$ as De } from "@univerjs/sheets-ui";
9
+ import { IZenZoneService as R, KeyCode as V, MenuGroup as Pe, MenuItemType as Ue, MenuPosition as je, MetaKeys as we, IMenuService as Le, IShortcutService as Ze } from "@univerjs/ui";
10
+ import { BehaviorSubject as ke, takeUntil as Ve } from "rxjs";
11
+ import { WorkbookEditablePermission as $e, WorksheetEditPermission as Ae, WorksheetSetCellValuePermission as Be, WorksheetSetCellStylePermission as We, RangeProtectionPermissionEditPoint as Fe } from "@univerjs/sheets";
12
+ import Ye, { forwardRef as $, useRef as ne, createElement as A, useEffect as He } from "react";
13
+ import { useDependency as P } from "@wendellhu/redi/react-bindings";
14
+ import G from "clsx";
15
+ const B = {
15
16
  id: "zen-editor.operation.open-zen-editor",
16
17
  type: U.OPERATION,
17
18
  handler: (t) => !0
18
19
  };
19
- class Ae {
20
+ class Ke {
20
21
  constructor() {
21
22
  v(this, "_position", null);
22
- v(this, "_position$", new Le(null));
23
+ v(this, "_position$", new ke(null));
23
24
  v(this, "position$", this._position$.asObservable());
24
25
  }
25
26
  dispose() {
@@ -35,29 +36,29 @@ class Ae {
35
36
  this._position$.next(e);
36
37
  }
37
38
  }
38
- const B = Oe(
39
+ const W = ye(
39
40
  "univer.sheet-zen-editor-manager.service"
40
41
  );
41
- var ke = Object.defineProperty, Be = Object.getOwnPropertyDescriptor, Fe = (t, e, i, n) => {
42
- for (var r = n > 1 ? void 0 : n ? Be(e, i) : e, o = t.length - 1, s; o >= 0; o--)
42
+ var Xe = Object.defineProperty, Ge = Object.getOwnPropertyDescriptor, qe = (t, e, i, n) => {
43
+ for (var r = n > 1 ? void 0 : n ? Ge(e, i) : e, o = t.length - 1, s; o >= 0; o--)
43
44
  (s = t[o]) && (r = (n ? s(e, i, r) : s(r)) || r);
44
- return n && r && ke(e, i, r), r;
45
+ return n && r && Xe(e, i, r), r;
45
46
  }, f = (t, e) => (i, n) => e(i, n, t);
46
- const h = "__defaultDocumentZenEditorSpecialUnitId_20231218__";
47
- let y = class extends he {
48
- constructor(e, i, n, r, o, s, c, a, l, d, u) {
47
+ const u = "__defaultDocumentZenEditorSpecialUnitId_20231218__";
48
+ let M = class extends _e {
49
+ constructor(e, i, n, r, o, s, c, a, d, l, _) {
49
50
  super();
50
51
  v(this, "_zenEditorInitialState", !1);
51
- this._injector = e, this._univerInstanceService = i, this._zenEditorManagerService = n, this._renderManagerService = r, this._commandService = o, this._zenZoneService = s, this._editorBridgeService = c, this._undoRedoService = a, this._textSelectionManagerService = l, this._docSkeletonManagerService = d, this._docViewModelManagerService = u, this._initialize();
52
+ this._injector = e, this._univerInstanceService = i, this._zenEditorManagerService = n, this._renderManagerService = r, this._commandService = o, this._zenZoneService = s, this._editorBridgeService = c, this._undoRedoService = a, this._textSelectionManagerService = d, this._docSkeletonManagerService = l, this._docViewModelManagerService = _, this._initialize();
52
53
  }
53
54
  _initialize() {
54
55
  this._syncZenEditorSize(), this._commandExecutedListener();
55
56
  }
56
57
  _createZenEditorInstance() {
57
58
  const e = {
58
- id: h,
59
+ id: u,
59
60
  body: {
60
- dataStream: `${_e}`,
61
+ dataStream: `${fe}`,
61
62
  textRuns: [],
62
63
  paragraphs: [
63
64
  {
@@ -80,27 +81,27 @@ let y = class extends he {
80
81
  }
81
82
  }
82
83
  };
83
- return this._univerInstanceService.createUnit(M.UNIVER_DOC, e);
84
+ return this._univerInstanceService.createUnit(N.UNIVER_DOC, e);
84
85
  }
85
86
  // Listen to changes in the size of the zen editor container to set the size of the editor.
86
87
  _syncZenEditorSize() {
87
- this._zenEditorManagerService.position$.pipe(we(this.dispose$)).subscribe((e) => {
88
+ this._zenEditorManagerService.position$.pipe(Ve(this.dispose$)).subscribe((e) => {
88
89
  var a;
89
90
  if (e == null)
90
91
  return;
91
- const i = Re(h, this._renderManagerService), n = this._univerInstanceService.getUniverDocInstance(h);
92
+ const i = xe(u, this._renderManagerService), n = this._univerInstanceService.getUniverDocInstance(u);
92
93
  if (i == null || n == null)
93
94
  return;
94
- const { width: r, height: o } = e, { engine: s } = i, c = (a = this._docSkeletonManagerService.getSkeletonByUnitId(h)) == null ? void 0 : a.skeleton;
95
+ const { width: r, height: o } = e, { engine: s } = i, c = (a = this._docSkeletonManagerService.getSkeletonByUnitId(u)) == null ? void 0 : a.skeleton;
95
96
  requestIdleCallback(() => {
96
97
  s.resizeBySize(r, o), this._calculatePagePosition(i), c && this._textSelectionManagerService.refreshSelection();
97
98
  });
98
99
  });
99
100
  }
100
101
  _handleOpenZenEditor() {
101
- this._zenEditorInitialState || (this._createZenEditorInstance(), this._zenEditorInitialState = !0), this._zenZoneService.open(), this._undoRedoService.clearUndoRedo(h), this._univerInstanceService.focusUnit(h), this._univerInstanceService.setCurrentUnitForType(h), this._editorBridgeService.isVisible().visible === !1 && this._editorBridgeService.changeVisible({
102
+ this._zenEditorInitialState || (this._createZenEditorInstance(), this._zenEditorInitialState = !0), this._zenZoneService.open(), this._undoRedoService.clearUndoRedo(u), this._univerInstanceService.focusUnit(u), this._univerInstanceService.setCurrentUnitForType(u), this._editorBridgeService.isVisible().visible === !1 && this._editorBridgeService.changeVisible({
102
103
  visible: !0,
103
- eventType: L.PointerDown
104
+ eventType: Z.PointerDown
104
105
  });
105
106
  const i = this._editorBridgeService.getLatestEditCellState();
106
107
  if (i == null)
@@ -118,55 +119,55 @@ let y = class extends he {
118
119
  var s, c;
119
120
  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;
120
121
  let o = [];
121
- n == null || r == null || ((c = i == null ? void 0 : i.textRuns) != null && c.length && (o = i == null ? void 0 : i.textRuns), this._syncContentAndRender(h, n, r, o));
122
+ n == null || r == null || ((c = i == null ? void 0 : i.textRuns) != null && c.length && (o = i == null ? void 0 : i.textRuns), this._syncContentAndRender(u, n, r, o));
122
123
  }
123
124
  _syncContentAndRender(e, i, n, r = []) {
124
125
  const o = [
125
- h,
126
- K,
127
- H
126
+ u,
127
+ X,
128
+ K
128
129
  ], s = this._docSkeletonManagerService.getSkeletonByUnitId(e), c = this._univerInstanceService.getUniverDocInstance(e), a = this._docViewModelManagerService.getViewModel(e);
129
130
  if (c == null || a == null || s == null)
130
131
  return;
131
- const l = c.getBody();
132
- l.dataStream = i, l.paragraphs = n, e === H && (l.textRuns = []), r.length > 0 && (l.textRuns = r), a.reset(c);
133
- const { skeleton: d } = s, u = this._getDocObject();
134
- u != null && (d.calculate(), o.includes(e) && u.document.makeDirty());
132
+ const d = c.getBody();
133
+ d.dataStream = i, d.paragraphs = n, e === K && (d.textRuns = []), r.length > 0 && (d.textRuns = r), a.reset(c);
134
+ const { skeleton: l } = s, _ = this._getDocObject();
135
+ _ != null && (l.calculate(), o.includes(e) && _.document.makeDirty());
135
136
  }
136
137
  _calculatePagePosition(e) {
137
- const { document: i, scene: n } = e, r = n == null ? void 0 : n.getParent(), { width: o, height: s, pageMarginLeft: c, pageMarginTop: a } = i;
138
- if (r == null || o === Number.POSITIVE_INFINITY || s === Number.POSITIVE_INFINITY)
138
+ const { document: i, scene: n, docBackground: r } = e, o = n == null ? void 0 : n.getParent(), { width: s, height: c, pageMarginLeft: a, pageMarginTop: d } = i;
139
+ if (o == null || s === Number.POSITIVE_INFINITY || c === Number.POSITIVE_INFINITY)
139
140
  return;
140
- const { width: l, height: d } = r;
141
- let u = 0, b = 0, C = 0, R = 0, O = Number.POSITIVE_INFINITY;
142
- const { scaleX: m, scaleY: ae } = n.getAncestorScale();
143
- l > (o + c * 2) * m ? (u = l / 2 - o * m / 2, u /= m, C = (l - c * 2) / m, O = 0) : (u = c, C = o + c * 2, O = (C - l / m) / 2), d > s ? (b = d / 2 - s / 2, R = (d - a * 2) / ae) : (b = a, R = s + a * 2), n.resize(C, R + 200), i.translate(u, b);
144
- const x = n.getViewport(ze.VIEW_MAIN);
145
- if (O !== Number.POSITIVE_INFINITY && x != null) {
146
- const le = x.getBarScroll(O, 0).x;
147
- x.scrollTo({
141
+ const { width: l, height: _ } = o;
142
+ let m = 0, O = 0, y = 0, x = 0, b = Number.POSITIVE_INFINITY;
143
+ const { scaleX: E, scaleY: de } = n.getAncestorScale();
144
+ l > (s + a * 2) * E ? (m = l / 2 - s * E / 2, m /= E, y = (l - a * 2) / E, b = 0) : (m = a, y = s + a * 2, b = (y - l / E) / 2), _ > c ? (O = _ / 2 - c / 2, x = (_ - d * 2) / de) : (O = d, x = c + d * 2), n.resize(y, x + 200), i.translate(m, O), r.translate(m, O);
145
+ const D = n.getViewport(be.VIEW_MAIN);
146
+ if (b !== Number.POSITIVE_INFINITY && D != null) {
147
+ const le = D.getBarScroll(b, 0).x;
148
+ D.scrollTo({
148
149
  x: le
149
150
  });
150
151
  }
151
152
  return this;
152
153
  }
153
154
  _commandExecutedListener() {
154
- const e = [k.id];
155
+ const e = [B.id];
155
156
  this.disposeWithMe(
156
157
  this._commandService.onCommandExecuted((n) => {
157
158
  e.includes(n.id) && this._handleOpenZenEditor();
158
159
  })
159
160
  );
160
- const i = [ye.id];
161
+ const i = [Te.id];
161
162
  this.disposeWithMe(
162
163
  this._commandService.onCommandExecuted((n) => {
163
164
  if (i.includes(n.id)) {
164
165
  const r = n.params, { unitId: o } = r;
165
- if (o === h) {
166
- const s = this._univerInstanceService.getUniverDocInstance(o), c = s == null ? void 0 : s.getBody(), a = c == null ? void 0 : c.dataStream, l = c == null ? void 0 : c.paragraphs, d = c == null ? void 0 : c.textRuns;
167
- if (this._editorBridgeService.changeEditorDirty(!0), a == null || l == null)
166
+ if (o === u) {
167
+ const s = this._univerInstanceService.getUniverDocInstance(o), c = s == null ? void 0 : s.getBody(), a = c == null ? void 0 : c.dataStream, d = c == null ? void 0 : c.paragraphs, l = c == null ? void 0 : c.textRuns;
168
+ if (this._editorBridgeService.changeEditorDirty(!0), a == null || d == null)
168
169
  return;
169
- this._syncContentAndRender(K, a, l, d);
170
+ this._syncContentAndRender(X, a, d, l);
170
171
  }
171
172
  }
172
173
  })
@@ -176,57 +177,58 @@ let y = class extends he {
176
177
  return Me(this._univerInstanceService, this._renderManagerService);
177
178
  }
178
179
  };
179
- y = Fe([
180
- J(Q.Steady, y),
181
- f(0, p(Z)),
180
+ M = qe([
181
+ Q(ee.Steady, M),
182
+ f(0, S(L)),
182
183
  f(1, j),
183
- f(2, B),
184
- f(3, ee),
185
- f(4, P),
186
- f(5, N),
187
- f(6, w),
188
- f(7, fe),
189
- f(8, p(Ne)),
190
- f(9, p(Te)),
191
- f(10, p(be))
192
- ], y);
184
+ f(2, W),
185
+ f(3, te),
186
+ f(4, w),
187
+ f(5, R),
188
+ f(6, k),
189
+ f(7, ve),
190
+ f(8, S(Ne)),
191
+ f(9, S(Re)),
192
+ f(10, S(ze))
193
+ ], M);
193
194
  const F = {
194
195
  id: "zen-editor.command.cancel-zen-edit",
195
196
  type: U.COMMAND,
196
197
  handler: async (t) => {
197
- const e = t.get(N), i = t.get(w), n = t.get(j);
198
+ const e = t.get(R), i = t.get(k), n = t.get(j);
198
199
  i.isVisible().visible && i.changeVisible({
199
200
  visible: !1,
200
- eventType: L.Keyboard,
201
- keycode: $.ESC
201
+ eventType: Z.Keyboard,
202
+ keycode: V.ESC
202
203
  }), e.close();
203
- const o = n.getCurrentUnitForType(M.UNIVER_SHEET);
204
+ const o = n.getCurrentUnitForType(N.UNIVER_SHEET);
204
205
  return o ? (n.focusUnit(o.getUnitId()), i.refreshEditCellState(), !0) : !1;
205
206
  }
206
- }, W = {
207
+ }, Y = {
207
208
  id: "zen-editor.command.confirm-zen-edit",
208
209
  type: U.COMMAND,
209
210
  handler: async (t) => {
210
- const e = t.get(N), i = t.get(w), n = t.get(j);
211
+ const e = t.get(R), i = t.get(k), n = t.get(j);
211
212
  i.isVisible().visible && i.changeVisible({
212
213
  visible: !1,
213
- eventType: L.PointerDown
214
+ eventType: Z.PointerDown
214
215
  }), e.close();
215
- const o = n.getCurrentUnitForType(M.UNIVER_SHEET);
216
+ const o = n.getCurrentUnitForType(N.UNIVER_SHEET);
216
217
  return o ? (n.focusUnit(o.getUnitId()), i.refreshEditCellState(), !0) : !1;
217
218
  }
218
219
  };
219
- function We(t) {
220
+ function Je(t) {
220
221
  return {
221
- id: k.id,
222
- group: xe.CONTEXT_MENU_OTHERS,
223
- type: De.BUTTON,
222
+ id: B.id,
223
+ group: Pe.CONTEXT_MENU_OTHERS,
224
+ type: Ue.BUTTON,
224
225
  title: "rightClick.zenEditor",
225
226
  icon: "AmplifySingle",
226
- positions: [Ue.CONTEXT_MENU]
227
+ positions: [je.CONTEXT_MENU],
228
+ disabled$: De(t, { workbookTypes: [$e], worksheetTypes: [Ae, Be, We], rangeTypes: [Fe] })
227
229
  };
228
230
  }
229
- var ne = { exports: {} }, T = {};
231
+ var ie = { exports: {} }, z = {};
230
232
  /**
231
233
  * @license React
232
234
  * react-jsx-runtime.production.min.js
@@ -236,31 +238,31 @@ var ne = { exports: {} }, T = {};
236
238
  * This source code is licensed under the MIT license found in the
237
239
  * LICENSE file in the root directory of this source tree.
238
240
  */
239
- var Ye = $e, He = Symbol.for("react.element"), Ke = Symbol.for("react.fragment"), Xe = Object.prototype.hasOwnProperty, Ge = Ye.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, qe = { key: !0, ref: !0, __self: !0, __source: !0 };
240
- function ie(t, e, i) {
241
+ var Qe = Ye, et = Symbol.for("react.element"), tt = Symbol.for("react.fragment"), nt = Object.prototype.hasOwnProperty, it = Qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, rt = { key: !0, ref: !0, __self: !0, __source: !0 };
242
+ function re(t, e, i) {
241
243
  var n, r = {}, o = null, s = null;
242
244
  i !== void 0 && (o = "" + i), e.key !== void 0 && (o = "" + e.key), e.ref !== void 0 && (s = e.ref);
243
245
  for (n in e)
244
- Xe.call(e, n) && !qe.hasOwnProperty(n) && (r[n] = e[n]);
246
+ nt.call(e, n) && !rt.hasOwnProperty(n) && (r[n] = e[n]);
245
247
  if (t && t.defaultProps)
246
248
  for (n in e = t.defaultProps, e)
247
249
  r[n] === void 0 && (r[n] = e[n]);
248
- return { $$typeof: He, type: t, key: o, ref: s, props: r, _owner: Ge.current };
250
+ return { $$typeof: et, type: t, key: o, ref: s, props: r, _owner: it.current };
249
251
  }
250
- T.Fragment = Ke;
251
- T.jsx = ie;
252
- T.jsxs = ie;
253
- ne.exports = T;
254
- var g = ne.exports, _ = function() {
255
- return _ = Object.assign || function(t) {
252
+ z.Fragment = tt;
253
+ z.jsx = re;
254
+ z.jsxs = re;
255
+ ie.exports = z;
256
+ var g = ie.exports, h = function() {
257
+ return h = Object.assign || function(t) {
256
258
  for (var e, i = 1, n = arguments.length; i < n; i++) {
257
259
  e = arguments[i];
258
260
  for (var r in e)
259
261
  Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
260
262
  }
261
263
  return t;
262
- }, _.apply(this, arguments);
263
- }, Je = function(t, e) {
264
+ }, h.apply(this, arguments);
265
+ }, ot = function(t, e) {
264
266
  var i = {};
265
267
  for (var n in t)
266
268
  Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (i[n] = t[n]);
@@ -268,17 +270,17 @@ var g = ne.exports, _ = function() {
268
270
  for (var r = 0, n = Object.getOwnPropertySymbols(t); r < n.length; r++)
269
271
  e.indexOf(n[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[r]) && (i[n[r]] = t[n[r]]);
270
272
  return i;
271
- }, Y = V(function(t, e) {
272
- var i = t.icon, n = t.id, r = t.className, o = t.extend, s = Je(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(n, " ").concat(r || "").trim(), a = te("_".concat(tt()));
273
- return re(i, "".concat(n), { defIds: i.defIds, idSuffix: a.current }, _({ ref: e, className: c }, s), o);
273
+ }, H = $(function(t, e) {
274
+ var i = t.icon, n = t.id, r = t.className, o = t.extend, s = ot(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(n, " ").concat(r || "").trim(), a = ne("_".concat(at()));
275
+ return oe(i, "".concat(n), { defIds: i.defIds, idSuffix: a.current }, h({ ref: e, className: c }, s), o);
274
276
  });
275
- function re(t, e, i, n, r) {
276
- return A(t.tag, _(_({ key: e }, Qe(t, i, r)), n), (et(t, i).children || []).map(function(o, s) {
277
- return re(o, "".concat(e, "-").concat(t.tag, "-").concat(s), i, void 0, r);
277
+ function oe(t, e, i, n, r) {
278
+ return A(t.tag, h(h({ key: e }, st(t, i, r)), n), (ct(t, i).children || []).map(function(o, s) {
279
+ return oe(o, "".concat(e, "-").concat(t.tag, "-").concat(s), i, void 0, r);
278
280
  }));
279
281
  }
280
- function Qe(t, e, i) {
281
- var n = _({}, t.attrs);
282
+ function st(t, e, i) {
283
+ var n = h({}, t.attrs);
282
284
  i != null && i.colorChannel1 && n.fill === "colorChannel1" && (n.fill = i.colorChannel1);
283
285
  var r = e.defIds;
284
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) {
@@ -286,56 +288,56 @@ function Qe(t, e, i) {
286
288
  typeof c == "string" && (n[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
287
289
  })), n;
288
290
  }
289
- function et(t, e) {
291
+ function ct(t, e) {
290
292
  var i, n = e.defIds;
291
- 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) {
292
- return typeof r.attrs.id == "string" && n && n.indexOf(r.attrs.id) > -1 ? _(_({}, r), { attrs: _(_({}, 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) ? h(h({}, t), { children: t.children.map(function(r) {
294
+ return typeof r.attrs.id == "string" && n && n.indexOf(r.attrs.id) > -1 ? h(h({}, r), { attrs: h(h({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
293
295
  }) }) : t;
294
296
  }
295
- function tt() {
297
+ function at() {
296
298
  return Math.random().toString(36).substring(2, 8);
297
299
  }
298
- Y.displayName = "UniverIcon";
299
- var nt = { 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" } }] }, oe = V(function(t, e) {
300
- return A(Y, Object.assign({}, t, {
300
+ H.displayName = "UniverIcon";
301
+ var dt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, se = $(function(t, e) {
302
+ return A(H, Object.assign({}, t, {
301
303
  id: "check-mark-single",
302
304
  ref: e,
303
- icon: nt
305
+ icon: dt
304
306
  }));
305
307
  });
306
- oe.displayName = "CheckMarkSingle";
307
- const it = oe;
308
- var rt = { 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" } }] }, se = V(function(t, e) {
309
- return A(Y, Object.assign({}, t, {
308
+ se.displayName = "CheckMarkSingle";
309
+ const lt = se;
310
+ var ut = { 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" } }] }, ce = $(function(t, e) {
311
+ return A(H, Object.assign({}, t, {
310
312
  id: "close-single",
311
313
  ref: e,
312
- icon: rt
314
+ icon: ut
313
315
  }));
314
316
  });
315
- se.displayName = "CloseSingle";
316
- const ot = se, st = "univer-zen-editor", ct = "univer-zen-editor-icon-wrapper", at = "univer-zen-editor-icon-container", lt = "univer-zen-editor-icon-success", dt = "univer-zen-editor-icon-error", ut = "univer-zen-editor-canvas-container", S = {
317
- zenEditor: st,
318
- zenEditorIconWrapper: ct,
319
- zenEditorIconContainer: at,
320
- zenEditorIconSuccess: lt,
321
- zenEditorIconError: dt,
322
- zenEditorCanvasContainer: ut
323
- }, ht = "ZEN_EDITOR_PLUGIN_", _t = `${ht}ZEN_EDITOR_COMPONENT`;
324
- function ft() {
325
- const t = te(null), e = D(ee), i = D(B), n = D(P);
326
- Ve(() => {
317
+ ce.displayName = "CloseSingle";
318
+ const ht = ce, _t = "univer-zen-editor", ft = "univer-zen-editor-icon-wrapper", vt = "univer-zen-editor-icon-container", gt = "univer-zen-editor-icon-success", pt = "univer-zen-editor-icon-error", St = "univer-zen-editor-canvas-container", p = {
319
+ zenEditor: _t,
320
+ zenEditorIconWrapper: ft,
321
+ zenEditorIconContainer: vt,
322
+ zenEditorIconSuccess: gt,
323
+ zenEditorIconError: pt,
324
+ zenEditorCanvasContainer: St
325
+ }, mt = "ZEN_EDITOR_PLUGIN_", Et = `${mt}ZEN_EDITOR_COMPONENT`;
326
+ function It() {
327
+ const t = ne(null), e = P(te), i = P(W), n = P(w);
328
+ He(() => {
327
329
  const s = t.current;
328
330
  if (!s)
329
331
  return;
330
- const c = e.currentRender$.subscribe((l) => {
331
- var u;
332
- if (l !== h)
332
+ const c = e.currentRender$.subscribe((d) => {
333
+ var _;
334
+ if (d !== u)
333
335
  return;
334
- const d = (u = e.getRenderById(h)) == null ? void 0 : u.engine;
335
- d == null || d.setContainer(s);
336
+ const l = (_ = e.getRenderById(u)) == null ? void 0 : _.engine;
337
+ l == null || l.setContainer(s);
336
338
  }), a = new ResizeObserver(() => {
337
- const l = s.getBoundingClientRect();
338
- i.setPosition(l);
339
+ const d = s.getBoundingClientRect();
340
+ i.setPosition(d);
339
341
  });
340
342
  return a.observe(s), () => {
341
343
  a.unobserve(s), c.unsubscribe();
@@ -345,53 +347,53 @@ function ft() {
345
347
  n.executeCommand(F.id);
346
348
  }
347
349
  function o() {
348
- n.executeCommand(W.id);
350
+ n.executeCommand(Y.id);
349
351
  }
350
- return /* @__PURE__ */ g.jsxs("div", { className: S.zenEditor, children: [
351
- /* @__PURE__ */ g.jsxs("div", { className: S.zenEditorIconWrapper, children: [
352
+ return /* @__PURE__ */ g.jsxs("div", { className: p.zenEditor, children: [
353
+ /* @__PURE__ */ g.jsxs("div", { className: p.zenEditorIconWrapper, children: [
352
354
  /* @__PURE__ */ g.jsx(
353
355
  "span",
354
356
  {
355
- className: X(S.zenEditorIconContainer, S.zenEditorIconError),
357
+ className: G(p.zenEditorIconContainer, p.zenEditorIconError),
356
358
  onClick: r,
357
- children: /* @__PURE__ */ g.jsx(ot, { style: { fontSize: "22px" } })
359
+ children: /* @__PURE__ */ g.jsx(ht, { style: { fontSize: "22px" } })
358
360
  }
359
361
  ),
360
362
  /* @__PURE__ */ g.jsx(
361
363
  "span",
362
364
  {
363
- className: X(S.zenEditorIconContainer, S.zenEditorIconSuccess),
365
+ className: G(p.zenEditorIconContainer, p.zenEditorIconSuccess),
364
366
  onClick: o,
365
- children: /* @__PURE__ */ g.jsx(it, { style: { fontSize: "22px" } })
367
+ children: /* @__PURE__ */ g.jsx(lt, { style: { fontSize: "22px" } })
366
368
  }
367
369
  )
368
370
  ] }),
369
- /* @__PURE__ */ g.jsx("div", { className: S.zenEditorCanvasContainer, ref: t })
371
+ /* @__PURE__ */ g.jsx("div", { className: p.zenEditorCanvasContainer, ref: t })
370
372
  ] });
371
373
  }
372
- const vt = {
373
- id: W.id,
374
+ const Ct = {
375
+ id: Y.id,
374
376
  description: "shortcut.sheet.zen-edit-confirm",
375
377
  group: "4_sheet-edit",
376
- preconditions: (t) => ce(t),
377
- binding: $.ENTER | je.ALT
378
- }, gt = {
378
+ preconditions: (t) => ae(t),
379
+ binding: V.ENTER | we.ALT
380
+ }, Ot = {
379
381
  id: F.id,
380
382
  description: "shortcut.sheet.zen-edit-cancel",
381
383
  group: "4_sheet-edit",
382
- preconditions: (t) => ce(t),
383
- binding: $.ESC
384
+ preconditions: (t) => ae(t),
385
+ binding: V.ESC
384
386
  };
385
- function ce(t) {
386
- return t.getContextValue(ve) && t.getContextValue(ge) && t.getContextValue(Se) && !t.getContextValue(pe);
387
+ function ae(t) {
388
+ return t.getContextValue(ge) && t.getContextValue(pe) && t.getContextValue(Se) && !t.getContextValue(me);
387
389
  }
388
- var St = Object.defineProperty, pt = Object.getOwnPropertyDescriptor, mt = (t, e, i, n) => {
389
- for (var r = n > 1 ? void 0 : n ? pt(e, i) : e, o = t.length - 1, s; o >= 0; o--)
390
+ var yt = Object.defineProperty, bt = Object.getOwnPropertyDescriptor, Tt = (t, e, i, n) => {
391
+ for (var r = n > 1 ? void 0 : n ? bt(e, i) : e, o = t.length - 1, s; o >= 0; o--)
390
392
  (s = t[o]) && (r = (n ? s(e, i, r) : s(r)) || r);
391
- return n && r && St(e, i, r), r;
392
- }, E = (t, e) => (i, n) => e(i, n, t);
393
- const Et = {};
394
- let I = class extends me {
393
+ return n && r && yt(e, i, r), r;
394
+ }, I = (t, e) => (i, n) => e(i, n, t);
395
+ const Mt = {};
396
+ let C = class extends Ee {
395
397
  constructor(t, e, i, n, r, o) {
396
398
  super(), this._config = t, this._injector = e, this._zenZoneService = i, this._commandService = n, this._menuService = r, this._shortcutService = o, this._initialize();
397
399
  }
@@ -399,10 +401,10 @@ let I = class extends me {
399
401
  this._initCustomComponents(), this._initCommands(), this._initMenus(), this._initShortcuts();
400
402
  }
401
403
  _initCustomComponents() {
402
- this.disposeWithMe(this._zenZoneService.set(_t, ft));
404
+ this.disposeWithMe(this._zenZoneService.set(Et, It));
403
405
  }
404
406
  _initCommands() {
405
- [k, F, W].forEach((t) => {
407
+ [B, F, Y].forEach((t) => {
406
408
  this.disposeWithMe(this._commandService.registerCommand(t));
407
409
  });
408
410
  }
@@ -410,79 +412,51 @@ let I = class extends me {
410
412
  const { menu: t = {} } = this._config;
411
413
  [
412
414
  // context menu
413
- We
415
+ Je
414
416
  ].forEach((e) => {
415
417
  this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e), t));
416
418
  });
417
419
  }
418
420
  _initShortcuts() {
419
- [vt, gt].forEach((t) => {
421
+ [Ct, Ot].forEach((t) => {
420
422
  this.disposeWithMe(this._shortcutService.registerShortcut(t));
421
423
  });
422
424
  }
423
425
  };
424
- I = mt([
425
- J(Q.Rendered, I),
426
- E(1, p(Z)),
427
- E(2, N),
428
- E(3, P),
429
- E(4, Pe),
430
- E(5, Ze)
431
- ], I);
432
- const It = {
433
- shortcut: {
434
- sheet: {
435
- "zen-edit-cancel": "Cancel Zen Edit",
436
- "zen-edit-confirm": "Confirm Zen Edit"
437
- }
438
- }
439
- }, $t = It, Ct = {
440
- shortcut: {
441
- sheet: {
442
- "zen-edit-cancel": "取消编辑(禅模式状态)",
443
- "zen-edit-confirm": "放弃编辑(禅模式状态)"
444
- }
445
- }
446
- }, Ot = Ct, zt = {
447
- shortcut: {
448
- sheet: {
449
- "zen-edit-cancel": "Отменить Zen редактирование",
450
- "zen-edit-confirm": "Подтвердить Zen редактирование"
451
- }
452
- }
453
- }, Vt = zt;
454
- var yt = Object.defineProperty, Mt = Object.getOwnPropertyDescriptor, Nt = (t, e, i, n) => {
455
- for (var r = n > 1 ? void 0 : n ? Mt(e, i) : e, o = t.length - 1, s; o >= 0; o--)
426
+ C = Tt([
427
+ Q(ee.Rendered, C),
428
+ I(1, S(L)),
429
+ I(2, R),
430
+ I(3, w),
431
+ I(4, Le),
432
+ I(5, Ze)
433
+ ], C);
434
+ var Nt = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, zt = (t, e, i, n) => {
435
+ for (var r = n > 1 ? void 0 : n ? Rt(e, i) : e, o = t.length - 1, s; o >= 0; o--)
456
436
  (s = t[o]) && (r = (n ? s(e, i, r) : s(r)) || r);
457
- return n && r && yt(e, i, r), r;
458
- }, G = (t, e) => (i, n) => e(i, n, t), z;
459
- let q = (z = class extends Ee {
437
+ return n && r && Nt(e, i, r), r;
438
+ }, q = (t, e) => (i, n) => e(i, n, t), T;
439
+ let J = (T = class extends Ie {
460
440
  constructor(t = {}, e, i) {
461
- super(), this._config = t, this._injector = e, this._localeService = i, this._initialize(), this._initializeDependencies(this._injector), this._config = Ie.deepMerge({}, Et, this._config);
462
- }
463
- _initialize() {
464
- this._localeService.load({ zhCN: Ot });
441
+ super(), this._config = t, this._injector = e, this._localeService = i, this._initializeDependencies(this._injector), this._config = Ce.deepMerge({}, Mt, this._config);
465
442
  }
466
443
  _initializeDependencies(t) {
467
444
  [
468
445
  [
469
- I,
446
+ C,
470
447
  {
471
- useFactory: () => this._injector.createInstance(I, this._config)
448
+ useFactory: () => this._injector.createInstance(C, this._config)
472
449
  }
473
450
  ],
474
- [y],
475
- [B, { useClass: Ae }]
451
+ [M],
452
+ [W, { useClass: Ke }]
476
453
  ].forEach((i) => t.add(i));
477
454
  }
478
- }, v(z, "pluginName", "zen-editor"), v(z, "type", M.UNIVER_DOC), z);
479
- q = Nt([
480
- G(1, p(Z)),
481
- G(2, p(Ce))
482
- ], q);
455
+ }, v(T, "pluginName", "zen-editor"), v(T, "type", N.UNIVER_DOC), T);
456
+ J = zt([
457
+ q(1, S(L)),
458
+ q(2, S(Oe))
459
+ ], J);
483
460
  export {
484
- q as UniverSheetsZenEditorPlugin,
485
- $t as enUS,
486
- Vt as ruRU,
487
- Ot as zhCN
461
+ J as UniverSheetsZenEditorPlugin
488
462
  };
@@ -0,0 +1,8 @@
1
+ {
2
+ "shortcut": {
3
+ "sheet": {
4
+ "zen-edit-cancel": "Cancel Zen Edit",
5
+ "zen-edit-confirm": "Confirm Zen Edit"
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "shortcut": {
3
+ "sheet": {
4
+ "zen-edit-cancel": "Отменить Zen редактирование",
5
+ "zen-edit-confirm": "Подтвердить Zen редактирование"
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "shortcut": {
3
+ "sheet": {
4
+ "zen-edit-cancel": "取消编辑(禅模式状态)",
5
+ "zen-edit-confirm": "放弃编辑(禅模式状态)"
6
+ }
7
+ }
8
+ }
@@ -14,4 +14,3 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export { UniverSheetsZenEditorPlugin } from './plugin';
17
- export { enUS, zhCN, ruRU } from './locale';
@@ -9,6 +9,5 @@ export declare class UniverSheetsZenEditorPlugin extends Plugin {
9
9
  static pluginName: string;
10
10
  static type: UniverInstanceType;
11
11
  constructor(_config: Partial<IUniverSheetsZenEditorUIConfig>, _injector: Injector, _localeService: LocaleService);
12
- private _initialize;
13
12
  private _initializeDependencies;
14
13
  }
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("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","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.React,d["@wendellhu/redi/react-bindings"],d.clsx))})(this,function(d,c,h,O,y,N,v,F,p,x,W){"use strict";var be=Object.defineProperty;var xe=(d,c,h)=>c in d?be(d,c,{enumerable:!0,configurable:!0,writable:!0,value:h}):d[c]=h;var C=(d,c,h)=>(xe(d,typeof c!="symbol"?c+"":c,h),h);var D;const P={id:"zen-editor.operation.open-zen-editor",type:c.CommandType.OPERATION,handler:n=>!0};class Q{constructor(){C(this,"_position",null);C(this,"_position$",new F.BehaviorSubject(null));C(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 Z=h.createIdentifier("univer.sheet-zen-editor-manager.service");var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,ne=(n,t,i,e)=>{for(var r=e>1?void 0:e?te(t,i):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&ee(t,i,r),r},I=(n,t)=>(i,e)=>t(i,e,n);const f="__defaultDocumentZenEditorSpecialUnitId_20231218__";let R=class extends c.RxDisposable{constructor(t,i,e,r,s,o,a,l,u,_,g){super();C(this,"_zenEditorInitialState",!1);this._injector=t,this._univerInstanceService=i,this._zenEditorManagerService=e,this._renderManagerService=r,this._commandService=s,this._zenZoneService=o,this._editorBridgeService=a,this._undoRedoService=l,this._textSelectionManagerService=u,this._docSkeletonManagerService=_,this._docViewModelManagerService=g,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const t={id:f,body:{dataStream:`${c.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:595,height:842},marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}}};return this._univerInstanceService.createUnit(c.UniverInstanceType.UNIVER_DOC,t)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(F.takeUntil(this.dispose$)).subscribe(t=>{var l;if(t==null)return;const i=N.getEditorObject(f,this._renderManagerService),e=this._univerInstanceService.getUniverDocInstance(f);if(i==null||e==null)return;const{width:r,height:s}=t,{engine:o}=i,a=(l=this._docSkeletonManagerService.getSkeletonByUnitId(f))==null?void 0:l.skeleton;requestIdleCallback(()=>{o.resizeBySize(r,s),this._calculatePagePosition(i),a&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){this._zenEditorInitialState||(this._createZenEditorInstance(),this._zenEditorInitialState=!0),this._zenZoneService.open(),this._undoRedoService.clearUndoRedo(f),this._univerInstanceService.focusUnit(f),this._univerInstanceService.setCurrentUnitForType(f),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:y.DeviceInputEventType.PointerDown});const i=this._editorBridgeService.getLatestEditCellState();if(i==null)return;this._editorSyncHandler(i);const e=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(e)}_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 s=[];e==null||r==null||((a=i==null?void 0:i.textRuns)!=null&&a.length&&(s=i==null?void 0:i.textRuns),this._syncContentAndRender(f,e,r,s))}_syncContentAndRender(t,i,e,r=[]){const s=[f,c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],o=this._docSkeletonManagerService.getSkeletonByUnitId(t),a=this._univerInstanceService.getUniverDocInstance(t),l=this._docViewModelManagerService.getViewModel(t);if(a==null||l==null||o==null)return;const u=a.getBody();u.dataStream=i,u.paragraphs=e,t===c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(u.textRuns=[]),r.length>0&&(u.textRuns=r),l.reset(a);const{skeleton:_}=o,g=this._getDocObject();g!=null&&(_.calculate(),s.includes(t)&&g.document.makeDirty())}_calculatePagePosition(t){const{document:i,scene:e}=t,r=e==null?void 0:e.getParent(),{width:s,height:o,pageMarginLeft:a,pageMarginTop:l}=i;if(r==null||s===Number.POSITIVE_INFINITY||o===Number.POSITIVE_INFINITY)return;const{width:u,height:_}=r;let g=0,V=0,U=0,B=0,b=Number.POSITIVE_INFINITY;const{scaleX:M,scaleY:De}=e.getAncestorScale();u>(s+a*2)*M?(g=u/2-s*M/2,g/=M,U=(u-a*2)/M,b=0):(g=a,U=s+a*2,b=(U-u/M)/2),_>o?(V=_/2-o/2,B=(_-l*2)/De):(V=l,B=o+l*2),e.resize(U,B+200),i.translate(g,V);const k=e.getViewport(O.VIEWPORT_KEY.VIEW_MAIN);if(b!==Number.POSITIVE_INFINITY&&k!=null){const Ue=k.getBarScroll(b,0).x;k.scrollTo({x:Ue})}return this}_commandExecutedListener(){const t=[P.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{t.includes(e.id)&&this._handleOpenZenEditor()}));const i=[O.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const r=e.params,{unitId:s}=r;if(s===f){const o=this._univerInstanceService.getUniverDocInstance(s),a=o==null?void 0:o.getBody(),l=a==null?void 0:a.dataStream,u=a==null?void 0:a.paragraphs,_=a==null?void 0:a.textRuns;if(this._editorBridgeService.changeEditorDirty(!0),l==null||u==null)return;this._syncContentAndRender(c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l,u,_)}}}))}_getDocObject(){return O.getDocObject(this._univerInstanceService,this._renderManagerService)}};R=ne([c.OnLifecycle(c.LifecycleStages.Steady,R),I(0,h.Inject(h.Injector)),I(1,c.IUniverInstanceService),I(2,Z),I(3,y.IRenderManagerService),I(4,c.ICommandService),I(5,v.IZenZoneService),I(6,N.IEditorBridgeService),I(7,c.IUndoRedoService),I(8,h.Inject(O.TextSelectionManagerService)),I(9,h.Inject(O.DocSkeletonManagerService)),I(10,h.Inject(O.DocViewModelManagerService))],R);const w={id:"zen-editor.command.cancel-zen-edit",type:c.CommandType.COMMAND,handler:async n=>{const t=n.get(v.IZenZoneService),i=n.get(N.IEditorBridgeService),e=n.get(c.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:v.KeyCode.ESC}),t.close();const s=e.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return s?(e.focusUnit(s.getUnitId()),i.refreshEditCellState(),!0):!1}},L={id:"zen-editor.command.confirm-zen-edit",type:c.CommandType.COMMAND,handler:async n=>{const t=n.get(v.IZenZoneService),i=n.get(N.IEditorBridgeService),e=n.get(c.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:y.DeviceInputEventType.PointerDown}),t.close();const s=e.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return s?(e.focusUnit(s.getUnitId()),i.refreshEditCellState(),!0):!1}};function ie(n){return{id:P.id,group:v.MenuGroup.CONTEXT_MENU_OTHERS,type:v.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[v.MenuPosition.CONTEXT_MENU]}}var Y={exports:{}},j={};/**
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,u,O,y,T,_,Y,M,I,Z,K){"use strict";var De=Object.defineProperty;var xe=(d,c,u)=>c in d?De(d,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):d[c]=u;var C=(d,c,u)=>(xe(d,typeof c!="symbol"?c+"":c,u),u);var x;const L={id:"zen-editor.operation.open-zen-editor",type:c.CommandType.OPERATION,handler:n=>!0};class ee{constructor(){C(this,"_position",null);C(this,"_position$",new Y.BehaviorSubject(null));C(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 k=u.createIdentifier("univer.sheet-zen-editor-manager.service");var te=Object.defineProperty,ne=Object.getOwnPropertyDescriptor,ie=(n,t,i,e)=>{for(var r=e>1?void 0:e?ne(t,i):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&te(t,i,r),r},g=(n,t)=>(i,e)=>t(i,e,n);const f="__defaultDocumentZenEditorSpecialUnitId_20231218__";let b=class extends c.RxDisposable{constructor(t,i,e,r,s,o,a,l,v,h,p){super();C(this,"_zenEditorInitialState",!1);this._injector=t,this._univerInstanceService=i,this._zenEditorManagerService=e,this._renderManagerService=r,this._commandService=s,this._zenZoneService=o,this._editorBridgeService=a,this._undoRedoService=l,this._textSelectionManagerService=v,this._docSkeletonManagerService=h,this._docViewModelManagerService=p,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const t={id:f,body:{dataStream:`${c.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:595,height:842},marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}}};return this._univerInstanceService.createUnit(c.UniverInstanceType.UNIVER_DOC,t)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(Y.takeUntil(this.dispose$)).subscribe(t=>{var l;if(t==null)return;const i=T.getEditorObject(f,this._renderManagerService),e=this._univerInstanceService.getUniverDocInstance(f);if(i==null||e==null)return;const{width:r,height:s}=t,{engine:o}=i,a=(l=this._docSkeletonManagerService.getSkeletonByUnitId(f))==null?void 0:l.skeleton;requestIdleCallback(()=>{o.resizeBySize(r,s),this._calculatePagePosition(i),a&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){this._zenEditorInitialState||(this._createZenEditorInstance(),this._zenEditorInitialState=!0),this._zenZoneService.open(),this._undoRedoService.clearUndoRedo(f),this._univerInstanceService.focusUnit(f),this._univerInstanceService.setCurrentUnitForType(f),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:y.DeviceInputEventType.PointerDown});const i=this._editorBridgeService.getLatestEditCellState();if(i==null)return;this._editorSyncHandler(i);const e=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(e)}_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 s=[];e==null||r==null||((a=i==null?void 0:i.textRuns)!=null&&a.length&&(s=i==null?void 0:i.textRuns),this._syncContentAndRender(f,e,r,s))}_syncContentAndRender(t,i,e,r=[]){const s=[f,c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],o=this._docSkeletonManagerService.getSkeletonByUnitId(t),a=this._univerInstanceService.getUniverDocInstance(t),l=this._docViewModelManagerService.getViewModel(t);if(a==null||l==null||o==null)return;const v=a.getBody();v.dataStream=i,v.paragraphs=e,t===c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(v.textRuns=[]),r.length>0&&(v.textRuns=r),l.reset(a);const{skeleton:h}=o,p=this._getDocObject();p!=null&&(h.calculate(),s.includes(t)&&p.document.makeDirty())}_calculatePagePosition(t){const{document:i,scene:e,docBackground:r}=t,s=e==null?void 0:e.getParent(),{width:o,height:a,pageMarginLeft:l,pageMarginTop:v}=i;if(s==null||o===Number.POSITIVE_INFINITY||a===Number.POSITIVE_INFINITY)return;const{width:h,height:p}=s;let z=0,U=0,P=0,W=0,w=Number.POSITIVE_INFINITY;const{scaleX:j,scaleY:je}=e.getAncestorScale();h>(o+l*2)*j?(z=h/2-o*j/2,z/=j,P=(h-l*2)/j,w=0):(z=l,P=o+l*2,w=(P-h/j)/2),p>a?(U=p/2-a/2,W=(p-v*2)/je):(U=v,W=a+v*2),e.resize(P,W+200),i.translate(z,U),r.translate(z,U);const F=e.getViewport(O.VIEWPORT_KEY.VIEW_MAIN);if(w!==Number.POSITIVE_INFINITY&&F!=null){const be=F.getBarScroll(w,0).x;F.scrollTo({x:be})}return this}_commandExecutedListener(){const t=[L.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{t.includes(e.id)&&this._handleOpenZenEditor()}));const i=[O.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const r=e.params,{unitId:s}=r;if(s===f){const o=this._univerInstanceService.getUniverDocInstance(s),a=o==null?void 0:o.getBody(),l=a==null?void 0:a.dataStream,v=a==null?void 0:a.paragraphs,h=a==null?void 0:a.textRuns;if(this._editorBridgeService.changeEditorDirty(!0),l==null||v==null)return;this._syncContentAndRender(c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l,v,h)}}}))}_getDocObject(){return O.getDocObject(this._univerInstanceService,this._renderManagerService)}};b=ie([c.OnLifecycle(c.LifecycleStages.Steady,b),g(0,u.Inject(u.Injector)),g(1,c.IUniverInstanceService),g(2,k),g(3,y.IRenderManagerService),g(4,c.ICommandService),g(5,_.IZenZoneService),g(6,T.IEditorBridgeService),g(7,c.IUndoRedoService),g(8,u.Inject(O.TextSelectionManagerService)),g(9,u.Inject(O.DocSkeletonManagerService)),g(10,u.Inject(O.DocViewModelManagerService))],b);const A={id:"zen-editor.command.cancel-zen-edit",type:c.CommandType.COMMAND,handler:async n=>{const t=n.get(_.IZenZoneService),i=n.get(T.IEditorBridgeService),e=n.get(c.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC}),t.close();const s=e.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return s?(e.focusUnit(s.getUnitId()),i.refreshEditCellState(),!0):!1}},V={id:"zen-editor.command.confirm-zen-edit",type:c.CommandType.COMMAND,handler:async n=>{const t=n.get(_.IZenZoneService),i=n.get(T.IEditorBridgeService),e=n.get(c.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:y.DeviceInputEventType.PointerDown}),t.close();const s=e.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return s?(e.focusUnit(s.getUnitId()),i.refreshEditCellState(),!0):!1}};function re(n){return{id:L.id,group:_.MenuGroup.CONTEXT_MENU_OTHERS,type:_.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[_.MenuPosition.CONTEXT_MENU],disabled$:T.getCurrentRangeDisable$(n,{workbookTypes:[M.WorkbookEditablePermission],worksheetTypes:[M.WorksheetEditPermission,M.WorksheetSetCellValuePermission,M.WorksheetSetCellStylePermission],rangeTypes:[M.RangeProtectionPermissionEditPoint]})}}var H={exports:{}},D={};/**
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 re=p,se=Symbol.for("react.element"),oe=Symbol.for("react.fragment"),ce=Object.prototype.hasOwnProperty,ae=re.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,de={key:!0,ref:!0,__self:!0,__source:!0};function $(n,t,i){var e,r={},s=null,o=null;i!==void 0&&(s=""+i),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(o=t.ref);for(e in t)ce.call(t,e)&&!de.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:se,type:n,key:s,ref:o,props:r,_owner:ae.current}}j.Fragment=oe,j.jsx=$,j.jsxs=$,Y.exports=j;var E=Y.exports,S=function(){return S=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},S.apply(this,arguments)},le=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},A=p.forwardRef(function(n,t){var i=n.icon,e=n.id,r=n.className,s=n.extend,o=le(n,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),l=p.useRef("_".concat(ve()));return K(i,"".concat(e),{defIds:i.defIds,idSuffix:l.current},S({ref:t,className:a},o),s)});function K(n,t,i,e,r){return p.createElement(n.tag,S(S({key:t},ue(n,i,r)),e),(he(n,i).children||[]).map(function(s,o){return K(s,"".concat(t,"-").concat(n.tag,"-").concat(o),i,void 0,r)}))}function ue(n,t,i){var e=S({},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(s){var o=s[0],a=s[1];typeof a=="string"&&(e[o]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function he(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)?S(S({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?S(S({},r),{attrs:S(S({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):n}function ve(){return Math.random().toString(36).substring(2,8)}A.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=p.forwardRef(function(n,t){return p.createElement(A,Object.assign({},n,{id:"check-mark-single",ref:t,icon:_e}))});H.displayName="CheckMarkSingle";const fe=H;var Se={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=p.forwardRef(function(n,t){return p.createElement(A,Object.assign({},n,{id:"close-single",ref:t,icon:Se}))});X.displayName="CloseSingle";const ge=X,m={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"},Ie="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT";function pe(){const n=p.useRef(null),t=x.useDependency(y.IRenderManagerService),i=x.useDependency(Z),e=x.useDependency(c.ICommandService);p.useEffect(()=>{const o=n.current;if(!o)return;const a=t.currentRender$.subscribe(u=>{var g;if(u!==f)return;const _=(g=t.getRenderById(f))==null?void 0:g.engine;_==null||_.setContainer(o)}),l=new ResizeObserver(()=>{const u=o.getBoundingClientRect();i.setPosition(u)});return l.observe(o),()=>{l.unobserve(o),a.unsubscribe()}},[]);function r(){e.executeCommand(w.id)}function s(){e.executeCommand(L.id)}return E.jsxs("div",{className:m.zenEditor,children:[E.jsxs("div",{className:m.zenEditorIconWrapper,children:[E.jsx("span",{className:W(m.zenEditorIconContainer,m.zenEditorIconError),onClick:r,children:E.jsx(ge,{style:{fontSize:"22px"}})}),E.jsx("span",{className:W(m.zenEditorIconContainer,m.zenEditorIconSuccess),onClick:s,children:E.jsx(fe,{style:{fontSize:"22px"}})})]}),E.jsx("div",{className:m.zenEditorCanvasContainer,ref:n})]})}const Ee={id:L.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:n=>G(n),binding:v.KeyCode.ENTER|v.MetaKeys.ALT},me={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(c.FOCUSING_DOC)&&n.getContextValue(c.FOCUSING_UNIVER_EDITOR)&&n.getContextValue(c.EDITOR_ACTIVATED)&&!n.getContextValue(c.FOCUSING_EDITOR_STANDALONE)}var Ce=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,ye=(n,t,i,e)=>{for(var r=e>1?void 0:e?Oe(t,i):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&Ce(t,i,r),r},T=(n,t)=>(i,e)=>t(i,e,n);const Te={};let z=class extends c.Disposable{constructor(n,t,i,e,r,s){super(),this._config=n,this._injector=t,this._zenZoneService=i,this._commandService=e,this._menuService=r,this._shortcutService=s,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(Ie,pe))}_initCommands(){[P,w,L].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initMenus(){const{menu:n={}}=this._config;[ie].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t),n))})}_initShortcuts(){[Ee,me].forEach(n=>{this.disposeWithMe(this._shortcutService.registerShortcut(n))})}};z=ye([c.OnLifecycle(c.LifecycleStages.Rendered,z),T(1,h.Inject(h.Injector)),T(2,v.IZenZoneService),T(3,c.ICommandService),T(4,v.IMenuService),T(5,v.IShortcutService)],z);const ze={shortcut:{sheet:{"zen-edit-cancel":"Cancel Zen Edit","zen-edit-confirm":"Confirm Zen Edit"}}},q={shortcut:{sheet:{"zen-edit-cancel":"取消编辑(禅模式状态)","zen-edit-confirm":"放弃编辑(禅模式状态)"}}},Me={shortcut:{sheet:{"zen-edit-cancel":"Отменить Zen редактирование","zen-edit-confirm":"Подтвердить Zen редактирование"}}};var Ne=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,je=(n,t,i,e)=>{for(var r=e>1?void 0:e?Re(t,i):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&Ne(t,i,r),r},J=(n,t)=>(i,e)=>t(i,e,n);d.UniverSheetsZenEditorPlugin=(D=class extends c.Plugin{constructor(t={},i,e){super(),this._config=t,this._injector=i,this._localeService=e,this._initialize(),this._initializeDependencies(this._injector),this._config=c.Tools.deepMerge({},Te,this._config)}_initialize(){this._localeService.load({zhCN:q})}_initializeDependencies(t){[[z,{useFactory:()=>this._injector.createInstance(z,this._config)}],[R],[Z,{useClass:Q}]].forEach(e=>t.add(e))}},C(D,"pluginName","zen-editor"),C(D,"type",c.UniverInstanceType.UNIVER_DOC),D),d.UniverSheetsZenEditorPlugin=je([J(1,h.Inject(h.Injector)),J(2,h.Inject(c.LocaleService))],d.UniverSheetsZenEditorPlugin),d.enUS=ze,d.ruRU=Me,d.zhCN=q,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
9
+ */var se=I,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 $(n,t,i){var e,r={},s=null,o=null;i!==void 0&&(s=""+i),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(o=t.ref);for(e in t)ae.call(t,e)&&!le.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:oe,type:n,key:s,ref:o,props:r,_owner:de.current}}D.Fragment=ce,D.jsx=$,D.jsxs=$,H.exports=D;var E=H.exports,S=function(){return S=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},S.apply(this,arguments)},ue=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=I.forwardRef(function(n,t){var i=n.icon,e=n.id,r=n.className,s=n.extend,o=ue(n,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),l=I.useRef("_".concat(_e()));return X(i,"".concat(e),{defIds:i.defIds,idSuffix:l.current},S({ref:t,className:a},o),s)});function X(n,t,i,e,r){return I.createElement(n.tag,S(S({key:t},ve(n,i,r)),e),(he(n,i).children||[]).map(function(s,o){return X(s,"".concat(t,"-").concat(n.tag,"-").concat(o),i,void 0,r)}))}function ve(n,t,i){var e=S({},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(s){var o=s[0],a=s[1];typeof a=="string"&&(e[o]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function he(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)?S(S({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?S(S({},r),{attrs:S(S({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):n}function _e(){return Math.random().toString(36).substring(2,8)}B.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=I.forwardRef(function(n,t){return I.createElement(B,Object.assign({},n,{id:"check-mark-single",ref:t,icon:fe}))});G.displayName="CheckMarkSingle";const Se=G;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=I.forwardRef(function(n,t){return I.createElement(B,Object.assign({},n,{id:"close-single",ref:t,icon:ge}))});q.displayName="CloseSingle";const pe=q,m={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"},Ie="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT";function Ee(){const n=I.useRef(null),t=Z.useDependency(y.IRenderManagerService),i=Z.useDependency(k),e=Z.useDependency(c.ICommandService);I.useEffect(()=>{const o=n.current;if(!o)return;const a=t.currentRender$.subscribe(v=>{var p;if(v!==f)return;const h=(p=t.getRenderById(f))==null?void 0:p.engine;h==null||h.setContainer(o)}),l=new ResizeObserver(()=>{const v=o.getBoundingClientRect();i.setPosition(v)});return l.observe(o),()=>{l.unobserve(o),a.unsubscribe()}},[]);function r(){e.executeCommand(A.id)}function s(){e.executeCommand(V.id)}return E.jsxs("div",{className:m.zenEditor,children:[E.jsxs("div",{className:m.zenEditorIconWrapper,children:[E.jsx("span",{className:K(m.zenEditorIconContainer,m.zenEditorIconError),onClick:r,children:E.jsx(pe,{style:{fontSize:"22px"}})}),E.jsx("span",{className:K(m.zenEditorIconContainer,m.zenEditorIconSuccess),onClick:s,children:E.jsx(Se,{style:{fontSize:"22px"}})})]}),E.jsx("div",{className:m.zenEditorCanvasContainer,ref:n})]})}const me={id:V.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:n=>J(n),binding:_.KeyCode.ENTER|_.MetaKeys.ALT},Ce={id:A.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 Oe=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Te=(n,t,i,e)=>{for(var r=e>1?void 0:e?ye(t,i):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&Oe(t,i,r),r},R=(n,t)=>(i,e)=>t(i,e,n);const Me={};let N=class extends c.Disposable{constructor(n,t,i,e,r,s){super(),this._config=n,this._injector=t,this._zenZoneService=i,this._commandService=e,this._menuService=r,this._shortcutService=s,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(Ie,Ee))}_initCommands(){[L,A,V].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initMenus(){const{menu:n={}}=this._config;[re].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t),n))})}_initShortcuts(){[me,Ce].forEach(n=>{this.disposeWithMe(this._shortcutService.registerShortcut(n))})}};N=Te([c.OnLifecycle(c.LifecycleStages.Rendered,N),R(1,u.Inject(u.Injector)),R(2,_.IZenZoneService),R(3,c.ICommandService),R(4,_.IMenuService),R(5,_.IShortcutService)],N);var Re=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,ze=(n,t,i,e)=>{for(var r=e>1?void 0:e?Ne(t,i):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&Re(t,i,r),r},Q=(n,t)=>(i,e)=>t(i,e,n);d.UniverSheetsZenEditorPlugin=(x=class extends c.Plugin{constructor(t={},i,e){super(),this._config=t,this._injector=i,this._localeService=e,this._initializeDependencies(this._injector),this._config=c.Tools.deepMerge({},Me,this._config)}_initializeDependencies(t){[[N,{useFactory:()=>this._injector.createInstance(N,this._config)}],[b],[k,{useClass:ee}]].forEach(e=>t.add(e))}},C(x,"pluginName","zen-editor"),C(x,"type",c.UniverInstanceType.UNIVER_DOC),x),d.UniverSheetsZenEditorPlugin=ze([Q(1,u.Inject(u.Injector)),Q(2,u.Inject(c.LocaleService))],d.UniverSheetsZenEditorPlugin),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.1.12",
3
+ "version": "0.1.14",
4
4
  "private": false,
5
5
  "description": "Zen Editor plugin for Univer Sheets.",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -34,7 +34,8 @@
34
34
  "require": "./lib/cjs/*",
35
35
  "types": "./lib/types/index.d.ts"
36
36
  },
37
- "./lib/*": "./lib/*"
37
+ "./lib/*": "./lib/*",
38
+ "./locale/*": "./lib/locale/*.json"
38
39
  },
39
40
  "main": "./lib/cjs/index.js",
40
41
  "module": "./lib/es/index.js",
@@ -48,40 +49,53 @@
48
49
  "files": [
49
50
  "lib"
50
51
  ],
51
- "engines": {
52
- "node": ">=16.0.0",
53
- "npm": ">=8.0.0"
54
- },
55
52
  "peerDependencies": {
56
53
  "@wendellhu/redi": "0.15.2",
57
54
  "clsx": ">=2.0.0",
58
55
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
59
56
  "rxjs": ">=7.0.0",
60
- "@univerjs/core": "0.1.12",
61
- "@univerjs/docs": "0.1.12",
62
- "@univerjs/engine-render": "0.1.12",
63
- "@univerjs/sheets-ui": "0.1.12",
64
- "@univerjs/ui": "0.1.12"
57
+ "@univerjs/core": "0.1.14",
58
+ "@univerjs/engine-render": "0.1.14",
59
+ "@univerjs/sheets": "0.1.14",
60
+ "@univerjs/docs": "0.1.14",
61
+ "@univerjs/sheets-ui": "0.1.14",
62
+ "@univerjs/ui": "0.1.14"
65
63
  },
66
64
  "dependencies": {
67
- "@univerjs/icons": "^0.1.52"
65
+ "@univerjs/icons": "^0.1.56",
66
+ "@univerjs/sheets": "0.1.14"
68
67
  },
69
68
  "devDependencies": {
70
69
  "@wendellhu/redi": "0.15.2",
71
70
  "clsx": "^2.1.1",
72
71
  "less": "^4.2.0",
73
- "react": "18.2.0",
72
+ "react": "18.3.1",
74
73
  "rxjs": "^7.8.1",
75
74
  "typescript": "^5.4.5",
76
- "vite": "^5.2.11",
75
+ "vite": "^5.2.12",
77
76
  "vitest": "^1.6.0",
78
- "@univerjs/core": "0.1.12",
79
- "@univerjs/design": "0.1.12",
80
- "@univerjs/docs": "0.1.12",
81
- "@univerjs/engine-render": "0.1.12",
82
- "@univerjs/sheets-ui": "0.1.12",
83
- "@univerjs/ui": "0.1.12",
84
- "@univerjs/shared": "0.1.12"
77
+ "@univerjs/core": "0.1.14",
78
+ "@univerjs/docs": "0.1.14",
79
+ "@univerjs/design": "0.1.14",
80
+ "@univerjs/engine-render": "0.1.14",
81
+ "@univerjs/sheets": "0.1.14",
82
+ "@univerjs/shared": "0.1.14",
83
+ "@univerjs/sheets-ui": "0.1.14",
84
+ "@univerjs/ui": "0.1.14"
85
+ },
86
+ "univerSpace": {
87
+ ".": {
88
+ "import": "./lib/es/index.js",
89
+ "require": "./lib/cjs/index.js",
90
+ "types": "./lib/types/index.d.ts"
91
+ },
92
+ "./*": {
93
+ "import": "./lib/es/*",
94
+ "require": "./lib/cjs/*",
95
+ "types": "./lib/types/index.d.ts"
96
+ },
97
+ "./lib/*": "./lib/*",
98
+ "./locale/*": "./lib/locale/*.json"
85
99
  },
86
100
  "scripts": {
87
101
  "test": "vitest run",
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright 2023-present DreamNum Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- export { default as enUS } from './en-US';
17
- export { default as zhCN } from './zh-CN';
18
- export { default as ruRU } from './ru-RU';