@univerjs/sheets-zen-editor 0.1.10 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var ee=Object.defineProperty;var te=(i,t,n)=>t in i?ee(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n;var I=(i,t,n)=>(te(i,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),g=require("@wendellhu/redi"),C=require("@univerjs/docs"),T=require("@univerjs/engine-render"),x=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:i=>!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(t){this._position=t,this._refresh(t)}getPosition(){return this._position}_refresh(t){this._position$.next(t)}}const w=g.createIdentifier("univer.sheet-zen-editor-manager.service");var ie=Object.defineProperty,re=Object.getOwnPropertyDescriptor,oe=(i,t,n,e)=>{for(var r=e>1?void 0:e?re(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&ie(t,n,r),r},S=(i,t)=>(n,e)=>t(n,e,i);const v="__defaultDocumentZenEditorSpecialUnitId_20231218__";let N=class extends a.RxDisposable{constructor(t,n,e,r,o,s,c,d,l,u,h){super();I(this,"_zenEditorInitialState",!1);this._injector=t,this._univerInstanceService=n,this._zenEditorManagerService=e,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 t={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,t)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(F.takeUntil(this.dispose$)).subscribe(t=>{var d;if(t==null)return;const n=x.getEditorObject(v,this._renderManagerService),e=this._univerInstanceService.getUniverDocInstance(v);if(n==null||e==null)return;const{width:r,height:o}=t,{engine:s}=n,c=(d=this._docSkeletonManagerService.getSkeletonByUnitId(v))==null?void 0:d.skeleton;requestIdleCallback(()=>{s.resizeBySize(r,o),this._calculatePagePosition(n),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:T.DeviceInputEventType.PointerDown});const n=this._editorBridgeService.getLatestEditCellState();if(n==null)return;this._editorSyncHandler(n);const e=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(e)}_editorSyncHandler(t){var s,c;const n=(s=t.documentLayoutObject.documentModel)==null?void 0:s.getBody(),e=n==null?void 0:n.dataStream,r=n==null?void 0:n.paragraphs;let o=[];e==null||r==null||((c=n==null?void 0:n.textRuns)!=null&&c.length&&(o=n==null?void 0:n.textRuns),this._syncContentAndRender(v,e,r,o))}_syncContentAndRender(t,n,e,r=[]){const o=[v,a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=this._docSkeletonManagerService.getSkeletonByUnitId(t),c=this._univerInstanceService.getUniverDocInstance(t),d=this._docViewModelManagerService.getViewModel(t);if(c==null||d==null||s==null)return;const l=c.getBody();l.dataStream=n,l.paragraphs=e,t===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(t)&&h.document.makeDirty())}_calculatePagePosition(t){const{document:n,scene:e}=t,r=e==null?void 0:e.getParent(),{width:o,height:s,pageMarginLeft:c,pageMarginTop:d}=n;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,z=Number.POSITIVE_INFINITY;const{scaleX:O,scaleY:J}=e.getAncestorScale();l>(o+c*2)*O?(h=l/2-o*O/2,h/=O,R=(l-c*2)/O,z=0):(h=c,R=o+c*2,z=(R-l/O)/2),u>s?(U=u/2-s/2,j=(u-d*2)/J):(U=d,j=s+d*2),e.resize(R,j+200),n.translate(h,U);const P=e.getViewport(C.VIEWPORT_KEY.VIEW_MAIN);if(z!==Number.POSITIVE_INFINITY&&P!=null){const Q=P.getBarScroll(z,0).x;P.scrollTo({x:Q})}return this}_commandExecutedListener(){const t=[L.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{t.includes(e.id)&&this._handleOpenZenEditor()}));const n=[C.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(n.includes(e.id)){const r=e.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)}};N=oe([a.OnLifecycle(a.LifecycleStages.Steady,N),S(0,g.Inject(g.Injector)),S(1,a.IUniverInstanceService),S(2,w),S(3,T.IRenderManagerService),S(4,a.ICommandService),S(5,_.IZenZoneService),S(6,x.IEditorBridgeService),S(7,a.IUndoRedoService),S(8,g.Inject(C.TextSelectionManagerService)),S(9,g.Inject(C.DocSkeletonManagerService)),S(10,g.Inject(C.DocViewModelManagerService))],N);const A={id:"zen-editor.command.cancel-zen-edit",type:a.CommandType.COMMAND,handler:async i=>{const t=i.get(_.IZenZoneService),n=i.get(x.IEditorBridgeService),e=i.get(a.IUniverInstanceService);n.isVisible().visible&&n.changeVisible({visible:!1,eventType:T.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC}),t.close();const o=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return o?(e.focusUnit(o.getUnitId()),n.refreshEditCellState(),!0):!1}},V={id:"zen-editor.command.confirm-zen-edit",type:a.CommandType.COMMAND,handler:async i=>{const t=i.get(_.IZenZoneService),n=i.get(x.IEditorBridgeService),e=i.get(a.IUniverInstanceService);n.isVisible().visible&&n.changeVisible({visible:!1,eventType:T.DeviceInputEventType.PointerDown}),t.close();const o=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return o?(e.focusUnit(o.getUnitId()),n.refreshEditCellState(),!0):!1}};function se(){return{id:L.id,group:_.MenuGroup.CONTEXT_MENU_OTHERS,type:_.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[_.MenuPosition.CONTEXT_MENU]}}var W={exports:{}},D={};/**
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={};/**
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(i,t,n){var e,r={},o=null,s=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(s=t.ref);for(e in t)le.call(t,e)&&!_e.hasOwnProperty(e)&&(r[e]=t[e]);if(i&&i.defaultProps)for(e in t=i.defaultProps,t)r[e]===void 0&&(r[e]=t[e]);return{$$typeof:ae,type:i,key:o,ref:s,props:r,_owner:ue.current}}D.Fragment=de;D.jsx=q;D.jsxs=q;W.exports=D;var E=W.exports,f=function(){return f=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},f.apply(this,arguments)},he=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},$=p.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,o=i.extend,s=he(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),d=p.useRef("_".concat(Se()));return Y(n,"".concat(e),{defIds:n.defIds,idSuffix:d.current},f({ref:t,className:c},s),o)});function Y(i,t,n,e,r){return p.createElement(i.tag,f(f({key:t},ve(i,n,r)),e),(fe(i,n).children||[]).map(function(o,s){return Y(o,"".concat(t,"-").concat(i.tag,"-").concat(s),n,void 0,r)}))}function ve(i,t,n){var e=f({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function fe(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?f(f({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?f(f({},r),{attrs:f(f({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function Se(){return Math.random().toString(36).substring(2,8)}$.displayName="UniverIcon";var ge={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.44 3.57291C14.698 3.83093 14.698 4.24927 14.44 4.50729L6.44342 12.5037C6.28721 12.6599 6.03395 12.6599 5.87774 12.5037L1.55992 8.18578C1.3019 7.92776 1.3019 7.50942 1.55993 7.2514C1.81795 6.99338 2.23629 6.99338 2.49431 7.25141L6.01916 10.7763C6.09727 10.8544 6.2239 10.8544 6.30201 10.7763L13.5056 3.57291C13.7636 3.31489 14.1819 3.31489 14.44 3.57291Z",fillRule:"evenodd",clipRule:"evenodd"}}]},K=p.forwardRef(function(i,t){return p.createElement($,Object.assign({},i,{id:"check-mark-single",ref:t,icon:ge}))});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:"M4.57061 3.65132C4.31677 3.39748 3.90521 3.39748 3.65137 3.65132C3.39753 3.90516 3.39753 4.31672 3.65137 4.57056L7.08079 7.99998L3.65123 11.4295C3.39739 11.6834 3.39739 12.0949 3.65123 12.3488C3.90507 12.6026 4.31662 12.6026 4.57047 12.3488L8.00003 8.91921L11.4295 12.3487C11.6834 12.6026 12.0949 12.6026 12.3488 12.3487C12.6026 12.0949 12.6026 11.6833 12.3488 11.4295L8.91927 7.99998L12.3486 4.57061C12.6025 4.31677 12.6025 3.90521 12.3486 3.65137C12.0948 3.39753 11.6832 3.39753 11.4294 3.65137L8.00003 7.08074L4.57061 3.65132Z"}}]},H=p.forwardRef(function(i,t){return p.createElement($,Object.assign({},i,{id:"close-single",ref:t,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",Re="univer-zen-editor-canvas-container",m={zenEditor:me,zenEditorIconWrapper:Ce,zenEditorIconContainer:Oe,zenEditorIconSuccess:ye,zenEditorIconError:Te,zenEditorCanvasContainer:Re},ze="ZEN_EDITOR_PLUGIN_",Me=`${ze}ZEN_EDITOR_COMPONENT`;function Ne(){const i=p.useRef(null),t=Z.useDependency(T.IRenderManagerService),n=Z.useDependency(w),e=Z.useDependency(a.ICommandService);p.useEffect(()=>{const s=i.current;if(!s)return;const c=t.currentRender$.subscribe(l=>{var h;if(l!==v)return;const u=(h=t.getRenderById(v))==null?void 0:h.engine;u==null||u.setContainer(s)}),d=new ResizeObserver(()=>{const l=s.getBoundingClientRect();n.setPosition(l)});return d.observe(s),()=>{d.unobserve(s),c.unsubscribe()}},[]);function r(){e.executeCommand(A.id)}function o(){e.executeCommand(V.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:i})]})}const be={id:V.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:i=>X(i),binding:_.KeyCode.ENTER|_.MetaKeys.ALT},xe={id:A.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:i=>X(i),binding:_.KeyCode.ESC};function X(i){return i.getContextValue(a.FOCUSING_DOC)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(a.EDITOR_ACTIVATED)&&!i.getContextValue(a.FOCUSING_EDITOR_STANDALONE)}var De=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,je=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ue(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&De(t,n,r),r},y=(i,t)=>(n,e)=>t(n,e,i);let b=class extends a.Disposable{constructor(i,t,n,e,r){super(),this._injector=i,this._zenZoneService=t,this._commandService=n,this._menuService=e,this._shortcutService=r,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(Me,Ne))}_initCommands(){[L,A,V].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initMenus(){[se].forEach(i=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)))})}_initShortcuts(){[be,xe].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}};b=je([a.OnLifecycle(a.LifecycleStages.Rendered,b),y(0,g.Inject(g.Injector)),y(1,_.IZenZoneService),y(2,a.ICommandService),y(3,_.IMenuService),y(4,_.IShortcutService)],b);const Pe={shortcut:{sheet:{"zen-edit-cancel":"Cancel Zen Edit","zen-edit-confirm":"Confirm Zen Edit"}}},Ze=Pe,Le={shortcut:{sheet:{"zen-edit-cancel":"取消编辑(禅模式状态)","zen-edit-confirm":"放弃编辑(禅模式状态)"}}},G=Le;var we=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Ve=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&we(t,n,r),r},k=(i,t)=>(n,e)=>t(n,e,i),M;exports.UniverSheetsZenEditorPlugin=(M=class extends a.Plugin{constructor(t,n,e){super(),this._injector=n,this._localeService=e,this._initialize(),this._initializeDependencies(this._injector)}_initialize(){this._localeService.load({zhCN:G})}_initializeDependencies(t){[[b],[N],[w,{useClass:ne}]].forEach(e=>t.add(e))}},I(M,"pluginName","zen-editor"),I(M,"type",a.UniverInstanceType.UNIVER_DOC),M);exports.UniverSheetsZenEditorPlugin=Ve([k(1,g.Inject(g.Injector)),k(2,g.Inject(a.LocaleService))],exports.UniverSheetsZenEditorPlugin);exports.enUS=Ze;exports.zhCN=G;
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;
package/lib/es/index.js CHANGED
@@ -1,22 +1,22 @@
1
1
  var de = Object.defineProperty;
2
- var ue = (n, e, i) => e in n ? de(n, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[e] = i;
3
- var v = (n, e, i) => (ue(n, 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 P, ICommandService as j, 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, LocaleService as Ie } from "@univerjs/core";
5
- import { createIdentifier as Ce, Inject as p, Injector as L } from "@wendellhu/redi";
6
- import { VIEWPORT_KEY as Oe, RichTextEditingMutation as ze, getDocObject as ye, TextSelectionManagerService as Me, DocSkeletonManagerService as Ne, DocViewModelManagerService as be } from "@univerjs/docs";
7
- import { DeviceInputEventType as w, IRenderManagerService as ee } from "@univerjs/engine-render";
8
- import { getEditorObject as Te, IEditorBridgeService as Z } from "@univerjs/sheets-ui";
9
- import { IZenZoneService as N, KeyCode as V, MenuGroup as Re, MenuItemType as xe, MenuPosition as De, MetaKeys as Ue, IMenuService as Pe, IShortcutService as je } from "@univerjs/ui";
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
10
  import { BehaviorSubject as Le, takeUntil as we } from "rxjs";
11
- import Ze, { forwardRef as $, useRef as te, createElement as A, useEffect as Ve } from "react";
11
+ import $e, { forwardRef as V, useRef as te, createElement as A, useEffect as Ve } from "react";
12
12
  import { useDependency as D } from "@wendellhu/redi/react-bindings";
13
13
  import X from "clsx";
14
14
  const k = {
15
15
  id: "zen-editor.operation.open-zen-editor",
16
16
  type: U.OPERATION,
17
- handler: (n) => !0
17
+ handler: (t) => !0
18
18
  };
19
- class $e {
19
+ class Ae {
20
20
  constructor() {
21
21
  v(this, "_position", null);
22
22
  v(this, "_position$", new Le(null));
@@ -35,20 +35,20 @@ class $e {
35
35
  this._position$.next(e);
36
36
  }
37
37
  }
38
- const B = Ce(
38
+ const B = Oe(
39
39
  "univer.sheet-zen-editor-manager.service"
40
40
  );
41
- var Ae = Object.defineProperty, ke = Object.getOwnPropertyDescriptor, Be = (n, e, i, t) => {
42
- for (var r = t > 1 ? void 0 : t ? ke(e, i) : e, o = n.length - 1, s; o >= 0; o--)
43
- (s = n[o]) && (r = (t ? s(e, i, r) : s(r)) || r);
44
- return t && r && Ae(e, i, r), r;
45
- }, f = (n, e) => (i, t) => e(i, t, n);
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--)
43
+ (s = t[o]) && (r = (n ? s(e, i, r) : s(r)) || r);
44
+ return n && r && ke(e, i, r), r;
45
+ }, f = (t, e) => (i, n) => e(i, n, t);
46
46
  const h = "__defaultDocumentZenEditorSpecialUnitId_20231218__";
47
- let z = class extends he {
48
- constructor(e, i, t, r, o, s, c, a, l, d, u) {
47
+ let y = class extends he {
48
+ constructor(e, i, n, r, o, s, c, a, l, d, u) {
49
49
  super();
50
50
  v(this, "_zenEditorInitialState", !1);
51
- this._injector = e, this._univerInstanceService = i, this._zenEditorManagerService = t, 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();
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
52
  }
53
53
  _initialize() {
54
54
  this._syncZenEditorSize(), this._commandExecutedListener();
@@ -88,8 +88,8 @@ let z = class extends he {
88
88
  var a;
89
89
  if (e == null)
90
90
  return;
91
- const i = Te(h, this._renderManagerService), t = this._univerInstanceService.getUniverDocInstance(h);
92
- if (i == null || t == null)
91
+ const i = Re(h, this._renderManagerService), n = this._univerInstanceService.getUniverDocInstance(h);
92
+ if (i == null || n == null)
93
93
  return;
94
94
  const { width: r, height: o } = e, { engine: s } = i, c = (a = this._docSkeletonManagerService.getSkeletonByUnitId(h)) == null ? void 0 : a.skeleton;
95
95
  requestIdleCallback(() => {
@@ -100,27 +100,27 @@ let z = class extends he {
100
100
  _handleOpenZenEditor() {
101
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
102
  visible: !0,
103
- eventType: w.PointerDown
103
+ eventType: L.PointerDown
104
104
  });
105
105
  const i = this._editorBridgeService.getLatestEditCellState();
106
106
  if (i == null)
107
107
  return;
108
108
  this._editorSyncHandler(i);
109
- const t = [
109
+ const n = [
110
110
  {
111
111
  startOffset: 0,
112
112
  endOffset: 0
113
113
  }
114
114
  ];
115
- this._textSelectionManagerService.replaceTextRanges(t);
115
+ this._textSelectionManagerService.replaceTextRanges(n);
116
116
  }
117
117
  _editorSyncHandler(e) {
118
118
  var s, c;
119
- 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;
119
+ 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
120
  let o = [];
121
- 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));
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
122
  }
123
- _syncContentAndRender(e, i, t, r = []) {
123
+ _syncContentAndRender(e, i, n, r = []) {
124
124
  const o = [
125
125
  h,
126
126
  K,
@@ -129,21 +129,21 @@ let z = class extends he {
129
129
  if (c == null || a == null || s == null)
130
130
  return;
131
131
  const l = c.getBody();
132
- l.dataStream = i, l.paragraphs = t, e === H && (l.textRuns = []), r.length > 0 && (l.textRuns = r), a.reset(c);
132
+ l.dataStream = i, l.paragraphs = n, e === H && (l.textRuns = []), r.length > 0 && (l.textRuns = r), a.reset(c);
133
133
  const { skeleton: d } = s, u = this._getDocObject();
134
134
  u != null && (d.calculate(), o.includes(e) && u.document.makeDirty());
135
135
  }
136
136
  _calculatePagePosition(e) {
137
- const { document: i, scene: t } = e, r = t == null ? void 0 : t.getParent(), { width: o, height: s, pageMarginLeft: c, pageMarginTop: a } = i;
137
+ const { document: i, scene: n } = e, r = n == null ? void 0 : n.getParent(), { width: o, height: s, pageMarginLeft: c, pageMarginTop: a } = i;
138
138
  if (r == null || o === Number.POSITIVE_INFINITY || s === Number.POSITIVE_INFINITY)
139
139
  return;
140
140
  const { width: l, height: d } = r;
141
- let u = 0, T = 0, I = 0, R = 0, C = Number.POSITIVE_INFINITY;
142
- const { scaleX: m, scaleY: ae } = t.getAncestorScale();
143
- l > (o + c * 2) * m ? (u = l / 2 - o * m / 2, u /= m, I = (l - c * 2) / m, C = 0) : (u = c, I = o + c * 2, C = (I - l / m) / 2), d > s ? (T = d / 2 - s / 2, R = (d - a * 2) / ae) : (T = a, R = s + a * 2), t.resize(I, R + 200), i.translate(u, T);
144
- const x = t.getViewport(Oe.VIEW_MAIN);
145
- if (C !== Number.POSITIVE_INFINITY && x != null) {
146
- const le = x.getBarScroll(C, 0).x;
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
147
  x.scrollTo({
148
148
  x: le
149
149
  });
@@ -153,15 +153,15 @@ let z = class extends he {
153
153
  _commandExecutedListener() {
154
154
  const e = [k.id];
155
155
  this.disposeWithMe(
156
- this._commandService.onCommandExecuted((t) => {
157
- e.includes(t.id) && this._handleOpenZenEditor();
156
+ this._commandService.onCommandExecuted((n) => {
157
+ e.includes(n.id) && this._handleOpenZenEditor();
158
158
  })
159
159
  );
160
- const i = [ze.id];
160
+ const i = [ye.id];
161
161
  this.disposeWithMe(
162
- this._commandService.onCommandExecuted((t) => {
163
- if (i.includes(t.id)) {
164
- const r = t.params, { unitId: o } = r;
162
+ this._commandService.onCommandExecuted((n) => {
163
+ if (i.includes(n.id)) {
164
+ const r = n.params, { unitId: o } = r;
165
165
  if (o === h) {
166
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
167
  if (this._editorBridgeService.changeEditorDirty(!0), a == null || l == null)
@@ -173,60 +173,60 @@ let z = class extends he {
173
173
  );
174
174
  }
175
175
  _getDocObject() {
176
- return ye(this._univerInstanceService, this._renderManagerService);
176
+ return Me(this._univerInstanceService, this._renderManagerService);
177
177
  }
178
178
  };
179
- z = Be([
180
- J(Q.Steady, z),
181
- f(0, p(L)),
182
- f(1, P),
179
+ y = Fe([
180
+ J(Q.Steady, y),
181
+ f(0, p(Z)),
182
+ f(1, j),
183
183
  f(2, B),
184
184
  f(3, ee),
185
- f(4, j),
185
+ f(4, P),
186
186
  f(5, N),
187
- f(6, Z),
187
+ f(6, w),
188
188
  f(7, fe),
189
- f(8, p(Me)),
190
- f(9, p(Ne)),
189
+ f(8, p(Ne)),
190
+ f(9, p(Te)),
191
191
  f(10, p(be))
192
- ], z);
192
+ ], y);
193
193
  const F = {
194
194
  id: "zen-editor.command.cancel-zen-edit",
195
195
  type: U.COMMAND,
196
- handler: async (n) => {
197
- const e = n.get(N), i = n.get(Z), t = n.get(P);
196
+ handler: async (t) => {
197
+ const e = t.get(N), i = t.get(w), n = t.get(j);
198
198
  i.isVisible().visible && i.changeVisible({
199
199
  visible: !1,
200
- eventType: w.Keyboard,
201
- keycode: V.ESC
200
+ eventType: L.Keyboard,
201
+ keycode: $.ESC
202
202
  }), e.close();
203
- const o = t.getCurrentUnitForType(M.UNIVER_SHEET);
204
- return o ? (t.focusUnit(o.getUnitId()), i.refreshEditCellState(), !0) : !1;
203
+ const o = n.getCurrentUnitForType(M.UNIVER_SHEET);
204
+ return o ? (n.focusUnit(o.getUnitId()), i.refreshEditCellState(), !0) : !1;
205
205
  }
206
206
  }, W = {
207
207
  id: "zen-editor.command.confirm-zen-edit",
208
208
  type: U.COMMAND,
209
- handler: async (n) => {
210
- const e = n.get(N), i = n.get(Z), t = n.get(P);
209
+ handler: async (t) => {
210
+ const e = t.get(N), i = t.get(w), n = t.get(j);
211
211
  i.isVisible().visible && i.changeVisible({
212
212
  visible: !1,
213
- eventType: w.PointerDown
213
+ eventType: L.PointerDown
214
214
  }), e.close();
215
- const o = t.getCurrentUnitForType(M.UNIVER_SHEET);
216
- return o ? (t.focusUnit(o.getUnitId()), i.refreshEditCellState(), !0) : !1;
215
+ const o = n.getCurrentUnitForType(M.UNIVER_SHEET);
216
+ return o ? (n.focusUnit(o.getUnitId()), i.refreshEditCellState(), !0) : !1;
217
217
  }
218
218
  };
219
- function Fe() {
219
+ function We(t) {
220
220
  return {
221
221
  id: k.id,
222
- group: Re.CONTEXT_MENU_OTHERS,
223
- type: xe.BUTTON,
222
+ group: xe.CONTEXT_MENU_OTHERS,
223
+ type: De.BUTTON,
224
224
  title: "rightClick.zenEditor",
225
225
  icon: "AmplifySingle",
226
- positions: [De.CONTEXT_MENU]
226
+ positions: [Ue.CONTEXT_MENU]
227
227
  };
228
228
  }
229
- var ne = { exports: {} }, b = {};
229
+ var ne = { exports: {} }, T = {};
230
230
  /**
231
231
  * @license React
232
232
  * react-jsx-runtime.production.min.js
@@ -236,95 +236,95 @@ var ne = { exports: {} }, b = {};
236
236
  * This source code is licensed under the MIT license found in the
237
237
  * LICENSE file in the root directory of this source tree.
238
238
  */
239
- var We = Ze, Ye = Symbol.for("react.element"), He = Symbol.for("react.fragment"), Ke = Object.prototype.hasOwnProperty, Xe = We.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, Ge = { key: !0, ref: !0, __self: !0, __source: !0 };
240
- function ie(n, e, i) {
241
- var t, r = {}, o = null, s = null;
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 n, r = {}, o = null, s = null;
242
242
  i !== void 0 && (o = "" + i), e.key !== void 0 && (o = "" + e.key), e.ref !== void 0 && (s = e.ref);
243
- for (t in e)
244
- Ke.call(e, t) && !Ge.hasOwnProperty(t) && (r[t] = e[t]);
245
- if (n && n.defaultProps)
246
- for (t in e = n.defaultProps, e)
247
- r[t] === void 0 && (r[t] = e[t]);
248
- return { $$typeof: Ye, type: n, key: o, ref: s, props: r, _owner: Xe.current };
243
+ for (n in e)
244
+ Xe.call(e, n) && !qe.hasOwnProperty(n) && (r[n] = e[n]);
245
+ if (t && t.defaultProps)
246
+ for (n in e = t.defaultProps, e)
247
+ r[n] === void 0 && (r[n] = e[n]);
248
+ return { $$typeof: He, type: t, key: o, ref: s, props: r, _owner: Ge.current };
249
249
  }
250
- b.Fragment = He;
251
- b.jsx = ie;
252
- b.jsxs = ie;
253
- ne.exports = b;
250
+ T.Fragment = Ke;
251
+ T.jsx = ie;
252
+ T.jsxs = ie;
253
+ ne.exports = T;
254
254
  var g = ne.exports, _ = function() {
255
- return _ = Object.assign || function(n) {
256
- for (var e, i = 1, t = arguments.length; i < t; i++) {
255
+ return _ = Object.assign || function(t) {
256
+ for (var e, i = 1, n = arguments.length; i < n; i++) {
257
257
  e = arguments[i];
258
258
  for (var r in e)
259
- Object.prototype.hasOwnProperty.call(e, r) && (n[r] = e[r]);
259
+ Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
260
260
  }
261
- return n;
261
+ return t;
262
262
  }, _.apply(this, arguments);
263
- }, qe = function(n, e) {
263
+ }, Je = function(t, e) {
264
264
  var i = {};
265
- for (var t in n)
266
- Object.prototype.hasOwnProperty.call(n, t) && e.indexOf(t) < 0 && (i[t] = n[t]);
267
- if (n != null && typeof Object.getOwnPropertySymbols == "function")
268
- for (var r = 0, t = Object.getOwnPropertySymbols(n); r < t.length; r++)
269
- e.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(n, t[r]) && (i[t[r]] = n[t[r]]);
265
+ for (var n in t)
266
+ Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (i[n] = t[n]);
267
+ if (t != null && typeof Object.getOwnPropertySymbols == "function")
268
+ for (var r = 0, n = Object.getOwnPropertySymbols(t); r < n.length; r++)
269
+ e.indexOf(n[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[r]) && (i[n[r]] = t[n[r]]);
270
270
  return i;
271
- }, Y = $(function(n, e) {
272
- var i = n.icon, t = n.id, r = n.className, o = n.extend, s = qe(n, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), a = te("_".concat(et()));
273
- return re(i, "".concat(t), { defIds: i.defIds, idSuffix: a.current }, _({ ref: e, className: c }, s), o);
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);
274
274
  });
275
- function re(n, e, i, t, r) {
276
- return A(n.tag, _(_({ key: e }, Je(n, i, r)), t), (Qe(n, i).children || []).map(function(o, s) {
277
- return re(o, "".concat(e, "-").concat(n.tag, "-").concat(s), i, void 0, r);
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);
278
278
  }));
279
279
  }
280
- function Je(n, e, i) {
281
- var t = _({}, n.attrs);
282
- i != null && i.colorChannel1 && t.fill === "colorChannel1" && (t.fill = i.colorChannel1);
280
+ function Qe(t, e, i) {
281
+ var n = _({}, t.attrs);
282
+ i != null && i.colorChannel1 && n.fill === "colorChannel1" && (n.fill = i.colorChannel1);
283
283
  var r = e.defIds;
284
- 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) {
284
+ 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) {
285
285
  var s = o[0], c = o[1];
286
- typeof c == "string" && (t[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
287
- })), t;
286
+ typeof c == "string" && (n[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
287
+ })), n;
288
288
  }
289
- function Qe(n, e) {
290
- var i, t = e.defIds;
291
- return !t || t.length === 0 ? n : n.tag === "defs" && (!((i = n.children) === null || i === void 0) && i.length) ? _(_({}, n), { children: n.children.map(function(r) {
292
- return typeof r.attrs.id == "string" && t && t.indexOf(r.attrs.id) > -1 ? _(_({}, r), { attrs: _(_({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
293
- }) }) : n;
289
+ function et(t, e) {
290
+ 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
+ }) }) : t;
294
294
  }
295
- function et() {
295
+ function tt() {
296
296
  return Math.random().toString(36).substring(2, 8);
297
297
  }
298
298
  Y.displayName = "UniverIcon";
299
- var tt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.44 3.57291C14.698 3.83093 14.698 4.24927 14.44 4.50729L6.44342 12.5037C6.28721 12.6599 6.03395 12.6599 5.87774 12.5037L1.55992 8.18578C1.3019 7.92776 1.3019 7.50942 1.55993 7.2514C1.81795 6.99338 2.23629 6.99338 2.49431 7.25141L6.01916 10.7763C6.09727 10.8544 6.2239 10.8544 6.30201 10.7763L13.5056 3.57291C13.7636 3.31489 14.1819 3.31489 14.44 3.57291Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, oe = $(function(n, e) {
300
- return A(Y, Object.assign({}, n, {
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, {
301
301
  id: "check-mark-single",
302
302
  ref: e,
303
- icon: tt
303
+ icon: nt
304
304
  }));
305
305
  });
306
306
  oe.displayName = "CheckMarkSingle";
307
- const nt = oe;
308
- var it = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M4.57061 3.65132C4.31677 3.39748 3.90521 3.39748 3.65137 3.65132C3.39753 3.90516 3.39753 4.31672 3.65137 4.57056L7.08079 7.99998L3.65123 11.4295C3.39739 11.6834 3.39739 12.0949 3.65123 12.3488C3.90507 12.6026 4.31662 12.6026 4.57047 12.3488L8.00003 8.91921L11.4295 12.3487C11.6834 12.6026 12.0949 12.6026 12.3488 12.3487C12.6026 12.0949 12.6026 11.6833 12.3488 11.4295L8.91927 7.99998L12.3486 4.57061C12.6025 4.31677 12.6025 3.90521 12.3486 3.65137C12.0948 3.39753 11.6832 3.39753 11.4294 3.65137L8.00003 7.08074L4.57061 3.65132Z" } }] }, se = $(function(n, e) {
309
- return A(Y, Object.assign({}, n, {
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, {
310
310
  id: "close-single",
311
311
  ref: e,
312
- icon: it
312
+ icon: rt
313
313
  }));
314
314
  });
315
315
  se.displayName = "CloseSingle";
316
- const rt = se, ot = "univer-zen-editor", st = "univer-zen-editor-icon-wrapper", ct = "univer-zen-editor-icon-container", at = "univer-zen-editor-icon-success", lt = "univer-zen-editor-icon-error", dt = "univer-zen-editor-canvas-container", S = {
317
- zenEditor: ot,
318
- zenEditorIconWrapper: st,
319
- zenEditorIconContainer: ct,
320
- zenEditorIconSuccess: at,
321
- zenEditorIconError: lt,
322
- zenEditorCanvasContainer: dt
323
- }, ut = "ZEN_EDITOR_PLUGIN_", ht = `${ut}ZEN_EDITOR_COMPONENT`;
324
- function _t() {
325
- const n = te(null), e = D(ee), i = D(B), t = D(j);
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
326
  Ve(() => {
327
- const s = n.current;
327
+ const s = t.current;
328
328
  if (!s)
329
329
  return;
330
330
  const c = e.currentRender$.subscribe((l) => {
@@ -342,10 +342,10 @@ function _t() {
342
342
  };
343
343
  }, []);
344
344
  function r() {
345
- t.executeCommand(F.id);
345
+ n.executeCommand(F.id);
346
346
  }
347
347
  function o() {
348
- t.executeCommand(W.id);
348
+ n.executeCommand(W.id);
349
349
  }
350
350
  return /* @__PURE__ */ g.jsxs("div", { className: S.zenEditor, children: [
351
351
  /* @__PURE__ */ g.jsxs("div", { className: S.zenEditorIconWrapper, children: [
@@ -354,7 +354,7 @@ function _t() {
354
354
  {
355
355
  className: X(S.zenEditorIconContainer, S.zenEditorIconError),
356
356
  onClick: r,
357
- children: /* @__PURE__ */ g.jsx(rt, { style: { fontSize: "22px" } })
357
+ children: /* @__PURE__ */ g.jsx(ot, { style: { fontSize: "22px" } })
358
358
  }
359
359
  ),
360
360
  /* @__PURE__ */ g.jsx(
@@ -362,114 +362,127 @@ function _t() {
362
362
  {
363
363
  className: X(S.zenEditorIconContainer, S.zenEditorIconSuccess),
364
364
  onClick: o,
365
- children: /* @__PURE__ */ g.jsx(nt, { style: { fontSize: "22px" } })
365
+ children: /* @__PURE__ */ g.jsx(it, { style: { fontSize: "22px" } })
366
366
  }
367
367
  )
368
368
  ] }),
369
- /* @__PURE__ */ g.jsx("div", { className: S.zenEditorCanvasContainer, ref: n })
369
+ /* @__PURE__ */ g.jsx("div", { className: S.zenEditorCanvasContainer, ref: t })
370
370
  ] });
371
371
  }
372
- const ft = {
372
+ const vt = {
373
373
  id: W.id,
374
374
  description: "shortcut.sheet.zen-edit-confirm",
375
375
  group: "4_sheet-edit",
376
- preconditions: (n) => ce(n),
377
- binding: V.ENTER | Ue.ALT
378
- }, vt = {
376
+ preconditions: (t) => ce(t),
377
+ binding: $.ENTER | je.ALT
378
+ }, gt = {
379
379
  id: F.id,
380
380
  description: "shortcut.sheet.zen-edit-cancel",
381
381
  group: "4_sheet-edit",
382
- preconditions: (n) => ce(n),
383
- binding: V.ESC
382
+ preconditions: (t) => ce(t),
383
+ binding: $.ESC
384
384
  };
385
- function ce(n) {
386
- return n.getContextValue(ve) && n.getContextValue(ge) && n.getContextValue(Se) && !n.getContextValue(pe);
385
+ function ce(t) {
386
+ return t.getContextValue(ve) && t.getContextValue(ge) && t.getContextValue(Se) && !t.getContextValue(pe);
387
387
  }
388
- var gt = Object.defineProperty, St = Object.getOwnPropertyDescriptor, pt = (n, e, i, t) => {
389
- for (var r = t > 1 ? void 0 : t ? St(e, i) : e, o = n.length - 1, s; o >= 0; o--)
390
- (s = n[o]) && (r = (t ? s(e, i, r) : s(r)) || r);
391
- return t && r && gt(e, i, r), r;
392
- }, E = (n, e) => (i, t) => e(i, t, n);
393
- let y = class extends me {
394
- constructor(n, e, i, t, r) {
395
- super(), this._injector = n, this._zenZoneService = e, this._commandService = i, this._menuService = t, this._shortcutService = r, this._initialize();
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
+ (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 {
395
+ constructor(t, e, i, n, r, o) {
396
+ super(), this._config = t, this._injector = e, this._zenZoneService = i, this._commandService = n, this._menuService = r, this._shortcutService = o, this._initialize();
396
397
  }
397
398
  _initialize() {
398
399
  this._initCustomComponents(), this._initCommands(), this._initMenus(), this._initShortcuts();
399
400
  }
400
401
  _initCustomComponents() {
401
- this.disposeWithMe(this._zenZoneService.set(ht, _t));
402
+ this.disposeWithMe(this._zenZoneService.set(_t, ft));
402
403
  }
403
404
  _initCommands() {
404
- [k, F, W].forEach((n) => {
405
- this.disposeWithMe(this._commandService.registerCommand(n));
405
+ [k, F, W].forEach((t) => {
406
+ this.disposeWithMe(this._commandService.registerCommand(t));
406
407
  });
407
408
  }
408
409
  _initMenus() {
410
+ const { menu: t = {} } = this._config;
409
411
  [
410
412
  // context menu
411
- Fe
412
- ].forEach((n) => {
413
- this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(n)));
413
+ We
414
+ ].forEach((e) => {
415
+ this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e), t));
414
416
  });
415
417
  }
416
418
  _initShortcuts() {
417
- [ft, vt].forEach((n) => {
418
- this.disposeWithMe(this._shortcutService.registerShortcut(n));
419
+ [vt, gt].forEach((t) => {
420
+ this.disposeWithMe(this._shortcutService.registerShortcut(t));
419
421
  });
420
422
  }
421
423
  };
422
- y = pt([
423
- J(Q.Rendered, y),
424
- E(0, p(L)),
425
- E(1, N),
426
- E(2, j),
427
- E(3, Pe),
428
- E(4, je)
429
- ], y);
430
- const mt = {
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 = {
431
433
  shortcut: {
432
434
  sheet: {
433
435
  "zen-edit-cancel": "Cancel Zen Edit",
434
436
  "zen-edit-confirm": "Confirm Zen Edit"
435
437
  }
436
438
  }
437
- }, Lt = mt, Et = {
439
+ }, $t = It, Ct = {
438
440
  shortcut: {
439
441
  sheet: {
440
442
  "zen-edit-cancel": "取消编辑(禅模式状态)",
441
443
  "zen-edit-confirm": "放弃编辑(禅模式状态)"
442
444
  }
443
445
  }
444
- }, It = Et;
445
- var Ct = Object.defineProperty, Ot = Object.getOwnPropertyDescriptor, zt = (n, e, i, t) => {
446
- for (var r = t > 1 ? void 0 : t ? Ot(e, i) : e, o = n.length - 1, s; o >= 0; o--)
447
- (s = n[o]) && (r = (t ? s(e, i, r) : s(r)) || r);
448
- return t && r && Ct(e, i, r), r;
449
- }, G = (n, e) => (i, t) => e(i, t, n), O;
450
- let q = (O = class extends Ee {
451
- constructor(n, e, i) {
452
- super(), this._injector = e, this._localeService = i, this._initialize(), this._initializeDependencies(this._injector);
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--)
456
+ (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 {
460
+ 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);
453
462
  }
454
463
  _initialize() {
455
- this._localeService.load({
456
- zhCN: It
457
- });
464
+ this._localeService.load({ zhCN: Ot });
458
465
  }
459
- _initializeDependencies(n) {
466
+ _initializeDependencies(t) {
460
467
  [
468
+ [
469
+ I,
470
+ {
471
+ useFactory: () => this._injector.createInstance(I, this._config)
472
+ }
473
+ ],
461
474
  [y],
462
- [z],
463
- [B, { useClass: $e }]
464
- ].forEach((i) => n.add(i));
475
+ [B, { useClass: Ae }]
476
+ ].forEach((i) => t.add(i));
465
477
  }
466
- }, v(O, "pluginName", "zen-editor"), v(O, "type", M.UNIVER_DOC), O);
467
- q = zt([
468
- G(1, p(L)),
469
- G(2, p(Ie))
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))
470
482
  ], q);
471
483
  export {
472
484
  q as UniverSheetsZenEditorPlugin,
473
- Lt as enUS,
474
- It as zhCN
485
+ $t as enUS,
486
+ Vt as ruRU,
487
+ Ot as zhCN
475
488
  };
@@ -1,5 +1,5 @@
1
- import { IShortcutItem } from '@univerjs/ui';
2
1
  import { IContextService } from '@univerjs/core';
2
+ import { IShortcutItem } from '@univerjs/ui';
3
3
 
4
4
  export declare const ZenEditorConfirmShortcut: IShortcutItem;
5
5
  export declare const ZenEditorCancelShortcut: IShortcutItem;
@@ -1,14 +1,19 @@
1
- import { Injector } from '@wendellhu/redi';
2
- import { IMenuService, IShortcutService, IZenZoneService } from '@univerjs/ui';
3
1
  import { Disposable, ICommandService } from '@univerjs/core';
2
+ import { MenuConfig, IMenuService, IShortcutService, IZenZoneService } from '@univerjs/ui';
3
+ import { Injector } from '@wendellhu/redi';
4
4
 
5
+ export interface IUniverSheetsZenEditorUIConfig {
6
+ menu: MenuConfig;
7
+ }
8
+ export declare const DefaultSheetZenEditorUiConfig: {};
5
9
  export declare class ZenEditorUIController extends Disposable {
10
+ private readonly _config;
6
11
  private readonly _injector;
7
12
  private readonly _zenZoneService;
8
13
  private readonly _commandService;
9
14
  private readonly _menuService;
10
15
  private readonly _shortcutService;
11
- constructor(_injector: Injector, _zenZoneService: IZenZoneService, _commandService: ICommandService, _menuService: IMenuService, _shortcutService: IShortcutService);
16
+ constructor(_config: Partial<IUniverSheetsZenEditorUIConfig>, _injector: Injector, _zenZoneService: IZenZoneService, _commandService: ICommandService, _menuService: IMenuService, _shortcutService: IShortcutService);
12
17
  private _initialize;
13
18
  private _initCustomComponents;
14
19
  private _initCommands;
@@ -1,10 +1,10 @@
1
- import { IZenEditorManagerService } from '../services/zen-editor.service';
2
- import { Injector } from '@wendellhu/redi';
3
- import { IZenZoneService } from '@univerjs/ui';
4
- import { IEditorBridgeService } from '@univerjs/sheets-ui';
5
- import { IRenderManagerService } from '@univerjs/engine-render';
6
- import { DocSkeletonManagerService, DocViewModelManagerService, TextSelectionManagerService } from '@univerjs/docs';
7
1
  import { ICommandService, IUndoRedoService, IUniverInstanceService, RxDisposable } from '@univerjs/core';
2
+ import { DocSkeletonManagerService, DocViewModelManagerService, TextSelectionManagerService } from '@univerjs/docs';
3
+ import { IRenderManagerService } from '@univerjs/engine-render';
4
+ import { IEditorBridgeService } from '@univerjs/sheets-ui';
5
+ import { IZenZoneService } from '@univerjs/ui';
6
+ import { Injector } from '@wendellhu/redi';
7
+ import { IZenEditorManagerService } from '../services/zen-editor.service';
8
8
 
9
9
  export declare const DOCS_ZEN_EDITOR_UNIT_ID_KEY = "__defaultDocumentZenEditorSpecialUnitId_20231218__";
10
10
  export declare class ZenEditorController extends RxDisposable {
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export { UniverSheetsZenEditorPlugin } from './plugin';
17
- export { enUS, zhCN } from './locale';
17
+ export { enUS, zhCN, ruRU } from './locale';
@@ -15,3 +15,4 @@
15
15
  */
16
16
  export { default as enUS } from './en-US';
17
17
  export { default as zhCN } from './zh-CN';
18
+ export { default as ruRU } from './ru-RU';
@@ -0,0 +1,4 @@
1
+ import { default as zhCN } from './zh-CN';
2
+
3
+ declare const locale: typeof zhCN;
4
+ export default locale;
@@ -1,14 +1,14 @@
1
- import { Injector } from '@wendellhu/redi';
2
1
  import { LocaleService, Plugin, UniverInstanceType } from '@univerjs/core';
2
+ import { Injector } from '@wendellhu/redi';
3
+ import { IUniverSheetsZenEditorUIConfig } from './controllers/zen-editor-ui.controller';
3
4
 
4
- export interface IUniverSheetsZenEditorPluginConfig {
5
- }
6
5
  export declare class UniverSheetsZenEditorPlugin extends Plugin {
6
+ private readonly _config;
7
7
  readonly _injector: Injector;
8
8
  private readonly _localeService;
9
9
  static pluginName: string;
10
10
  static type: UniverInstanceType;
11
- constructor(_config: IUniverSheetsZenEditorPluginConfig, _injector: Injector, _localeService: LocaleService);
11
+ constructor(_config: Partial<IUniverSheetsZenEditorUIConfig>, _injector: Injector, _localeService: LocaleService);
12
12
  private _initialize;
13
13
  private _initializeDependencies;
14
14
  }
@@ -1,6 +1,6 @@
1
- import { Observable } from 'rxjs';
2
- import { IDisposable } from '@wendellhu/redi';
3
1
  import { Nullable } from '@univerjs/core';
2
+ import { IDisposable } from '@wendellhu/redi';
3
+ import { Observable } from 'rxjs';
4
4
 
5
5
  export interface IZenEditorManagerService {
6
6
  position$: Observable<Nullable<DOMRect>>;
@@ -1,3 +1,4 @@
1
1
  import { IMenuButtonItem } from '@univerjs/ui';
2
+ import { IAccessor } from '@wendellhu/redi';
2
3
 
3
- export declare function ZenEditorMenuItemFactory(): IMenuButtonItem;
4
+ export declare function ZenEditorMenuItemFactory(accessor: IAccessor): IMenuButtonItem;
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,v,O,y,N,h,F,g,b,W){"use strict";var De=Object.defineProperty;var xe=(d,c,v)=>c in d?De(d,c,{enumerable:!0,configurable:!0,writable:!0,value:v}):d[c]=v;var C=(d,c,v)=>(xe(d,typeof c!="symbol"?c+"":c,v),v);var D;const P={id:"zen-editor.operation.open-zen-editor",type:c.CommandType.OPERATION,handler:i=>!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=v.createIdentifier("univer.sheet-zen-editor-manager.service");var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,ne=(i,t,n,e)=>{for(var r=e>1?void 0:e?te(t,n):t,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(e?o(t,n,r):o(r))||r);return e&&r&&ee(t,n,r),r},I=(i,t)=>(n,e)=>t(n,e,i);const f="__defaultDocumentZenEditorSpecialUnitId_20231218__";let M=class extends c.RxDisposable{constructor(t,n,e,r,s,o,a,l,u,_,p){super();C(this,"_zenEditorInitialState",!1);this._injector=t,this._univerInstanceService=n,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=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(F.takeUntil(this.dispose$)).subscribe(t=>{var l;if(t==null)return;const n=N.getEditorObject(f,this._renderManagerService),e=this._univerInstanceService.getUniverDocInstance(f);if(n==null||e==null)return;const{width:r,height:s}=t,{engine:o}=n,a=(l=this._docSkeletonManagerService.getSkeletonByUnitId(f))==null?void 0:l.skeleton;requestIdleCallback(()=>{o.resizeBySize(r,s),this._calculatePagePosition(n),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 n=this._editorBridgeService.getLatestEditCellState();if(n==null)return;this._editorSyncHandler(n);const e=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(e)}_editorSyncHandler(t){var o,a;const n=(o=t.documentLayoutObject.documentModel)==null?void 0:o.getBody(),e=n==null?void 0:n.dataStream,r=n==null?void 0:n.paragraphs;let s=[];e==null||r==null||((a=n==null?void 0:n.textRuns)!=null&&a.length&&(s=n==null?void 0:n.textRuns),this._syncContentAndRender(f,e,r,s))}_syncContentAndRender(t,n,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=n,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,p=this._getDocObject();p!=null&&(_.calculate(),s.includes(t)&&p.document.makeDirty())}_calculatePagePosition(t){const{document:n,scene:e}=t,r=e==null?void 0:e.getParent(),{width:s,height:o,pageMarginLeft:a,pageMarginTop:l}=n;if(r==null||s===Number.POSITIVE_INFINITY||o===Number.POSITIVE_INFINITY)return;const{width:u,height:_}=r;let p=0,V=0,x=0,B=0,U=Number.POSITIVE_INFINITY;const{scaleX:z,scaleY:Re}=e.getAncestorScale();u>(s+a*2)*z?(p=u/2-s*z/2,p/=z,x=(u-a*2)/z,U=0):(p=a,x=s+a*2,U=(x-u/z)/2),_>o?(V=_/2-o/2,B=(_-l*2)/Re):(V=l,B=o+l*2),e.resize(x,B+200),n.translate(p,V);const k=e.getViewport(O.VIEWPORT_KEY.VIEW_MAIN);if(U!==Number.POSITIVE_INFINITY&&k!=null){const je=k.getBarScroll(U,0).x;k.scrollTo({x:je})}return this}_commandExecutedListener(){const t=[P.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{t.includes(e.id)&&this._handleOpenZenEditor()}));const n=[O.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(n.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)}};M=ne([c.OnLifecycle(c.LifecycleStages.Steady,M),I(0,v.Inject(v.Injector)),I(1,c.IUniverInstanceService),I(2,Z),I(3,y.IRenderManagerService),I(4,c.ICommandService),I(5,h.IZenZoneService),I(6,N.IEditorBridgeService),I(7,c.IUndoRedoService),I(8,v.Inject(O.TextSelectionManagerService)),I(9,v.Inject(O.DocSkeletonManagerService)),I(10,v.Inject(O.DocViewModelManagerService))],M);const w={id:"zen-editor.command.cancel-zen-edit",type:c.CommandType.COMMAND,handler:async i=>{const t=i.get(h.IZenZoneService),n=i.get(N.IEditorBridgeService),e=i.get(c.IUniverInstanceService);n.isVisible().visible&&n.changeVisible({visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:h.KeyCode.ESC}),t.close();const s=e.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return s?(e.focusUnit(s.getUnitId()),n.refreshEditCellState(),!0):!1}},L={id:"zen-editor.command.confirm-zen-edit",type:c.CommandType.COMMAND,handler:async i=>{const t=i.get(h.IZenZoneService),n=i.get(N.IEditorBridgeService),e=i.get(c.IUniverInstanceService);n.isVisible().visible&&n.changeVisible({visible:!1,eventType:y.DeviceInputEventType.PointerDown}),t.close();const s=e.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return s?(e.focusUnit(s.getUnitId()),n.refreshEditCellState(),!0):!1}};function ie(){return{id:P.id,group:h.MenuGroup.CONTEXT_MENU_OTHERS,type:h.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[h.MenuPosition.CONTEXT_MENU]}}var Y={exports:{}},R={};/**
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={};/**
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=g,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 K(i,t,n){var e,r={},s=null,o=null;n!==void 0&&(s=""+n),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(i&&i.defaultProps)for(e in t=i.defaultProps,t)r[e]===void 0&&(r[e]=t[e]);return{$$typeof:se,type:i,key:s,ref:o,props:r,_owner:ae.current}}R.Fragment=oe,R.jsx=K,R.jsxs=K,Y.exports=R;var E=Y.exports,S=function(){return S=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},S.apply(this,arguments)},le=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},A=g.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,s=i.extend,o=le(i,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),l=g.useRef("_".concat(he()));return H(n,"".concat(e),{defIds:n.defIds,idSuffix:l.current},S({ref:t,className:a},o),s)});function H(i,t,n,e,r){return g.createElement(i.tag,S(S({key:t},ue(i,n,r)),e),(ve(i,n).children||[]).map(function(s,o){return H(s,"".concat(t,"-").concat(i.tag,"-").concat(o),n,void 0,r)}))}function ue(i,t,n){var e=S({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.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 ve(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?S(S({},i),{children:i.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})}):i}function he(){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.44 3.57291C14.698 3.83093 14.698 4.24927 14.44 4.50729L6.44342 12.5037C6.28721 12.6599 6.03395 12.6599 5.87774 12.5037L1.55992 8.18578C1.3019 7.92776 1.3019 7.50942 1.55993 7.2514C1.81795 6.99338 2.23629 6.99338 2.49431 7.25141L6.01916 10.7763C6.09727 10.8544 6.2239 10.8544 6.30201 10.7763L13.5056 3.57291C13.7636 3.31489 14.1819 3.31489 14.44 3.57291Z",fillRule:"evenodd",clipRule:"evenodd"}}]},$=g.forwardRef(function(i,t){return g.createElement(A,Object.assign({},i,{id:"check-mark-single",ref:t,icon:_e}))});$.displayName="CheckMarkSingle";const fe=$;var Se={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.57061 3.65132C4.31677 3.39748 3.90521 3.39748 3.65137 3.65132C3.39753 3.90516 3.39753 4.31672 3.65137 4.57056L7.08079 7.99998L3.65123 11.4295C3.39739 11.6834 3.39739 12.0949 3.65123 12.3488C3.90507 12.6026 4.31662 12.6026 4.57047 12.3488L8.00003 8.91921L11.4295 12.3487C11.6834 12.6026 12.0949 12.6026 12.3488 12.3487C12.6026 12.0949 12.6026 11.6833 12.3488 11.4295L8.91927 7.99998L12.3486 4.57061C12.6025 4.31677 12.6025 3.90521 12.3486 3.65137C12.0948 3.39753 11.6832 3.39753 11.4294 3.65137L8.00003 7.08074L4.57061 3.65132Z"}}]},X=g.forwardRef(function(i,t){return g.createElement(A,Object.assign({},i,{id:"close-single",ref:t,icon:Se}))});X.displayName="CloseSingle";const pe=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 ge(){const i=g.useRef(null),t=b.useDependency(y.IRenderManagerService),n=b.useDependency(Z),e=b.useDependency(c.ICommandService);g.useEffect(()=>{const o=i.current;if(!o)return;const a=t.currentRender$.subscribe(u=>{var p;if(u!==f)return;const _=(p=t.getRenderById(f))==null?void 0:p.engine;_==null||_.setContainer(o)}),l=new ResizeObserver(()=>{const u=o.getBoundingClientRect();n.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(pe,{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:i})]})}const Ee={id:L.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:i=>G(i),binding:h.KeyCode.ENTER|h.MetaKeys.ALT},me={id:w.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:i=>G(i),binding:h.KeyCode.ESC};function G(i){return i.getContextValue(c.FOCUSING_DOC)&&i.getContextValue(c.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(c.EDITOR_ACTIVATED)&&!i.getContextValue(c.FOCUSING_EDITOR_STANDALONE)}var Ce=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,ye=(i,t,n,e)=>{for(var r=e>1?void 0:e?Oe(t,n):t,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(e?o(t,n,r):o(r))||r);return e&&r&&Ce(t,n,r),r},T=(i,t)=>(n,e)=>t(n,e,i);let j=class extends c.Disposable{constructor(i,t,n,e,r){super(),this._injector=i,this._zenZoneService=t,this._commandService=n,this._menuService=e,this._shortcutService=r,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(Ie,ge))}_initCommands(){[P,w,L].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initMenus(){[ie].forEach(i=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)))})}_initShortcuts(){[Ee,me].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}};j=ye([c.OnLifecycle(c.LifecycleStages.Rendered,j),T(0,v.Inject(v.Injector)),T(1,h.IZenZoneService),T(2,c.ICommandService),T(3,h.IMenuService),T(4,h.IShortcutService)],j);const Te={shortcut:{sheet:{"zen-edit-cancel":"Cancel Zen Edit","zen-edit-confirm":"Confirm Zen Edit"}}},q={shortcut:{sheet:{"zen-edit-cancel":"取消编辑(禅模式状态)","zen-edit-confirm":"放弃编辑(禅模式状态)"}}};var ze=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Me=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ne(t,n):t,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(e?o(t,n,r):o(r))||r);return e&&r&&ze(t,n,r),r},J=(i,t)=>(n,e)=>t(n,e,i);d.UniverSheetsZenEditorPlugin=(D=class extends c.Plugin{constructor(t,n,e){super(),this._injector=n,this._localeService=e,this._initialize(),this._initializeDependencies(this._injector)}_initialize(){this._localeService.load({zhCN:q})}_initializeDependencies(t){[[j],[M],[Z,{useClass:Q}]].forEach(e=>t.add(e))}},C(D,"pluginName","zen-editor"),C(D,"type",c.UniverInstanceType.UNIVER_DOC),D),d.UniverSheetsZenEditorPlugin=Me([J(1,v.Inject(v.Injector)),J(2,v.Inject(c.LocaleService))],d.UniverSheetsZenEditorPlugin),d.enUS=Te,d.zhCN=q,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
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"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-zen-editor",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "private": false,
5
5
  "description": "Zen Editor plugin for Univer Sheets.",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,35 +53,35 @@
53
53
  "npm": ">=8.0.0"
54
54
  },
55
55
  "peerDependencies": {
56
- "@wendellhu/redi": "^0.13.3",
56
+ "@wendellhu/redi": "0.15.2",
57
57
  "clsx": ">=2.0.0",
58
58
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
59
59
  "rxjs": ">=7.0.0",
60
- "@univerjs/docs": "0.1.10",
61
- "@univerjs/core": "0.1.10",
62
- "@univerjs/engine-render": "0.1.10",
63
- "@univerjs/ui": "0.1.10",
64
- "@univerjs/sheets-ui": "0.1.10"
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"
65
65
  },
66
66
  "dependencies": {
67
- "@univerjs/icons": "^0.1.44"
67
+ "@univerjs/icons": "^0.1.52"
68
68
  },
69
69
  "devDependencies": {
70
- "@wendellhu/redi": "^0.13.3",
70
+ "@wendellhu/redi": "0.15.2",
71
71
  "clsx": "^2.1.1",
72
72
  "less": "^4.2.0",
73
73
  "react": "18.2.0",
74
74
  "rxjs": "^7.8.1",
75
75
  "typescript": "^5.4.5",
76
- "vite": "^5.2.10",
77
- "vitest": "^1.5.0",
78
- "@univerjs/core": "0.1.10",
79
- "@univerjs/design": "0.1.10",
80
- "@univerjs/docs": "0.1.10",
81
- "@univerjs/shared": "0.1.10",
82
- "@univerjs/sheets-ui": "0.1.10",
83
- "@univerjs/engine-render": "0.1.10",
84
- "@univerjs/ui": "0.1.10"
76
+ "vite": "^5.2.11",
77
+ "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"
85
85
  },
86
86
  "scripts": {
87
87
  "test": "vitest run",