@univerjs/sheets-zen-editor 0.1.17 → 0.2.1

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 te=Object.defineProperty;var ne=(n,e,i)=>e in n?te(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var E=(n,e,i)=>ne(n,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),p=require("@wendellhu/redi"),O=require("@univerjs/docs"),N=require("@univerjs/engine-render"),z=require("@univerjs/sheets-ui"),_=require("@univerjs/ui"),q=require("rxjs"),T=require("@univerjs/sheets"),f=require("react"),w=require("@wendellhu/redi/react-bindings"),W=require("clsx"),A={id:"zen-editor.operation.open-zen-editor",type:c.CommandType.OPERATION,handler:n=>!0};class ie{constructor(){E(this,"_position",null);E(this,"_position$",new q.BehaviorSubject(null));E(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(e){this._position=e,this._refresh(e)}getPosition(){return this._position}_refresh(e){this._position$.next(e)}}const V=p.createIdentifier("univer.sheet-zen-editor-manager.service");var re=Object.defineProperty,se=Object.getOwnPropertyDescriptor,oe=(n,e,i,t)=>{for(var r=t>1?void 0:t?se(e,i):e,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=(t?s(e,i,r):s(r))||r);return t&&r&&re(e,i,r),r},S=(n,e)=>(i,t)=>e(i,t,n);const h="__defaultDocumentZenEditorSpecialUnitId_20231218__";let P=class extends c.RxDisposable{constructor(e,i,t,r,o,s,a,d,l){super();E(this,"_zenEditorInitialState",!1);this._injector=e,this._univerInstanceService=i,this._zenEditorManagerService=t,this._renderManagerService=r,this._commandService=o,this._zenZoneService=s,this._editorBridgeService=a,this._undoRedoService=d,this._textSelectionManagerService=l,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const e={id:h,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,e)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(q.takeUntil(this.dispose$)).subscribe(e=>{var d;if(e==null)return;const i=z.getEditorObject(h,this._renderManagerService),t=this._univerInstanceService.getUniverDocInstance(h);if(i==null||t==null)return;const{width:r,height:o}=e,{engine:s}=i,a=(d=this._renderManagerService.getRenderById(h))==null?void 0:d.with(O.DocSkeletonManagerService).getSkeleton();requestIdleCallback(()=>{s.resizeBySize(r,o),this._calculatePagePosition(i),a&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){this._zenEditorInitialState||(this._createZenEditorInstance(),this._zenEditorInitialState=!0),this._zenZoneService.open(),this._undoRedoService.clearUndoRedo(h),this._univerInstanceService.focusUnit(h),this._univerInstanceService.setCurrentUnitForType(h),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:N.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,a;const i=(s=e.documentLayoutObject.documentModel)==null?void 0:s.getBody(),t=i==null?void 0:i.dataStream,r=i==null?void 0:i.paragraphs;let o=[];t==null||r==null||((a=i==null?void 0:i.textRuns)!=null&&a.length&&(o=i==null?void 0:i.textRuns),this._syncContentAndRender(h,t,r,o))}_syncContentAndRender(e,i,t,r=[]){var I;const o=[h,c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=(I=this._renderManagerService.getRenderById(e))==null?void 0:I.with(O.DocSkeletonManagerService),a=s==null?void 0:s.getSkeleton(),d=this._univerInstanceService.getUniverDocInstance(e),l=s==null?void 0:s.getViewModel();if(d==null||l==null||a==null)return;const u=d.getBody();u.dataStream=i,u.paragraphs=t,e===c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(u.textRuns=[]),r.length>0&&(u.textRuns=r),l.reset(d);const g=this._getDocObject();g!=null&&(a.calculate(),o.includes(e)&&g.document.makeDirty())}_calculatePagePosition(e){const{document:i,scene:t,docBackground:r}=e,o=t==null?void 0:t.getParent(),{width:s,height:a,pageMarginLeft:d,pageMarginTop:l}=i;if(o==null||s===Number.POSITIVE_INFINITY||a===Number.POSITIVE_INFINITY)return;const{width:u,height:g}=o;let I=0,D=0,x=0,Z=0,M=Number.POSITIVE_INFINITY;const{scaleX:y,scaleY:Q}=t.getAncestorScale();u>(s+d*2)*y?(I=u/2-s*y/2,I/=y,x=(u-d*2)/y,M=0):(I=d,x=s+d*2,M=(x-u/y)/2),g>a?(D=g/2-a/2,Z=(g-l*2)/Q):(D=l,Z=a+l*2),t.resize(x,Z+200),i.translate(I,D),r.translate(I,D);const L=t.getViewport(O.VIEWPORT_KEY.VIEW_MAIN);if(M!==Number.POSITIVE_INFINITY&&L!=null){const ee=L.transScroll2ViewportScrollValue(M,0).x;L.scrollTo({x:ee})}return this}_commandExecutedListener(){const e=[A.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{e.includes(t.id)&&this._handleOpenZenEditor()}));const i=[O.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(i.includes(t.id)){const r=t.params,{unitId:o}=r;if(o===h){const s=this._univerInstanceService.getUniverDocInstance(o),a=s==null?void 0:s.getBody(),d=a==null?void 0:a.dataStream,l=a==null?void 0:a.paragraphs,u=a==null?void 0:a.textRuns;if(this._editorBridgeService.changeEditorDirty(!0),d==null||l==null)return;this._syncContentAndRender(c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,d,l,u)}}}))}_getDocObject(){return O.getDocObject(this._univerInstanceService,this._renderManagerService)}};P=oe([c.OnLifecycle(c.LifecycleStages.Steady,P),S(0,p.Inject(p.Injector)),S(1,c.IUniverInstanceService),S(2,V),S(3,N.IRenderManagerService),S(4,c.ICommandService),S(5,_.IZenZoneService),S(6,z.IEditorBridgeService),S(7,c.IUndoRedoService),S(8,p.Inject(O.TextSelectionManagerService))],P);const B={id:"zen-editor.command.cancel-zen-edit",type:c.CommandType.COMMAND,handler:async n=>{const e=n.get(_.IZenZoneService),i=n.get(z.IEditorBridgeService),t=n.get(c.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:N.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC}),e.close();const o=t.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return o?(t.focusUnit(o.getUnitId()),i.refreshEditCellState(),!0):!1}},$={id:"zen-editor.command.confirm-zen-edit",type:c.CommandType.COMMAND,handler:async n=>{const e=n.get(_.IZenZoneService),i=n.get(z.IEditorBridgeService),t=n.get(c.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:N.DeviceInputEventType.PointerDown}),e.close();const o=t.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return o?(t.focusUnit(o.getUnitId()),i.refreshEditCellState(),!0):!1}};function ce(n){return{id:A.id,group:_.MenuGroup.CONTEXT_MENU_OTHERS,type:_.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[_.MenuPosition.CONTEXT_MENU],disabled$:z.getCurrentRangeDisable$(n,{workbookTypes:[T.WorkbookEditablePermission],worksheetTypes:[T.WorksheetEditPermission,T.WorksheetSetCellValuePermission,T.WorksheetSetCellStylePermission],rangeTypes:[T.RangeProtectionPermissionEditPoint]})}}var Y={exports:{}},j={};/**
1
+ "use strict";var te=Object.defineProperty;var ne=(n,e,i)=>e in n?te(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var E=(n,e,i)=>ne(n,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),p=require("@wendellhu/redi"),O=require("@univerjs/docs"),N=require("@univerjs/engine-render"),D=require("@univerjs/sheets-ui"),_=require("@univerjs/ui"),q=require("rxjs"),T=require("@univerjs/sheets"),f=require("react"),B=require("@wendellhu/redi/react-bindings"),F=require("clsx"),j={id:"zen-editor.operation.open-zen-editor",type:c.CommandType.OPERATION,handler:n=>!0};class ie{constructor(){E(this,"_position",null);E(this,"_position$",new q.BehaviorSubject(null));E(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 $=p.createIdentifier("univer.sheet-zen-editor-manager.service");var re=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,se=(n,e,i,t)=>{for(var r=t>1?void 0:t?oe(e,i):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(t?o(e,i,r):o(r))||r);return t&&r&&re(e,i,r),r},S=(n,e)=>(i,t)=>e(i,t,n);const h="__defaultDocumentZenEditorSpecialUnitId_20231218__";let P=class extends c.RxDisposable{constructor(e,i,t,r,s,o,a,d,l){super();E(this,"_zenEditorInitialState",!1);this._injector=e,this._univerInstanceService=i,this._zenEditorManagerService=t,this._renderManagerService=r,this._commandService=s,this._zenZoneService=o,this._editorBridgeService=a,this._undoRedoService=d,this._textSelectionManagerService=l,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const e={id:h,body:{dataStream:`${c.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:595,height:842},documentFlavor:c.DocumentFlavor.MODERN,marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}}};return this._univerInstanceService.createUnit(c.UniverInstanceType.UNIVER_DOC,e)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(q.takeUntil(this.dispose$)).subscribe(e=>{var d;if(e==null)return;const i=D.getEditorObject(h,this._renderManagerService),t=this._univerInstanceService.getUniverDocInstance(h);if(i==null||t==null)return;const{width:r,height:s}=e,{engine:o}=i,a=(d=this._renderManagerService.getRenderById(h))==null?void 0:d.with(O.DocSkeletonManagerService).getSkeleton();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(h),this._univerInstanceService.focusUnit(h),this._univerInstanceService.setCurrentUnitForType(h),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:N.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 o,a;const i=(o=e.documentLayoutObject.documentModel)==null?void 0:o.getBody(),t=i==null?void 0:i.dataStream,r=i==null?void 0:i.paragraphs;let s=[];t==null||r==null||((a=i==null?void 0:i.textRuns)!=null&&a.length&&(s=i==null?void 0:i.textRuns),this._syncContentAndRender(h,t,r,s))}_syncContentAndRender(e,i,t,r=[]){var I;const s=[h,c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],o=(I=this._renderManagerService.getRenderById(e))==null?void 0:I.with(O.DocSkeletonManagerService),a=o==null?void 0:o.getSkeleton(),d=this._univerInstanceService.getUniverDocInstance(e),l=o==null?void 0:o.getViewModel();if(d==null||l==null||a==null)return;const u=d.getBody();u.dataStream=i,u.paragraphs=t,e===c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(u.textRuns=[]),r.length>0&&(u.textRuns=r),l.reset(d);const g=this._getDocObject();g!=null&&(a.calculate(),s.includes(e)&&g.document.makeDirty())}_calculatePagePosition(e){const{document:i,scene:t,docBackground:r}=e,s=t==null?void 0:t.getParent(),{width:o,height:a,pageMarginLeft:d,pageMarginTop:l}=i;if(s==null||o===Number.POSITIVE_INFINITY||a===Number.POSITIVE_INFINITY)return;const{width:u,height:g}=s;let I=0,z=0,M=0,A=0,x=Number.POSITIVE_INFINITY;const{scaleX:y,scaleY:Q}=t.getAncestorScale();u>(o+d*2)*y?(I=u/2-o*y/2,I/=y,M=(u-d*2)/y,x=0):(I=d,M=o+d*2,x=(M-u/y)/2),g>a?(z=g/2-a/2,A=(g-l*2)/Q):(z=l,A=a+l*2),t.resize(M,A+200),i.translate(I,z),r.translate(I,z);const V=t.getViewport(O.VIEWPORT_KEY.VIEW_MAIN);if(x!==Number.POSITIVE_INFINITY&&V!=null){const ee=V.transScroll2ViewportScrollValue(x,0).x;V.scrollTo({x:ee})}return this}_commandExecutedListener(){const e=[j.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{e.includes(t.id)&&this._handleOpenZenEditor()}));const i=[O.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(i.includes(t.id)){const r=t.params,{unitId:s}=r;if(s===h){const o=this._univerInstanceService.getUniverDocInstance(s),a=o==null?void 0:o.getBody(),d=a==null?void 0:a.dataStream,l=a==null?void 0:a.paragraphs,u=a==null?void 0:a.textRuns;if(this._editorBridgeService.changeEditorDirty(!0),d==null||l==null)return;this._syncContentAndRender(c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,d,l,u)}}}))}_getDocObject(){return O.getDocObject(this._univerInstanceService,this._renderManagerService)}};P=se([c.OnLifecycle(c.LifecycleStages.Steady,P),S(0,p.Inject(p.Injector)),S(1,c.IUniverInstanceService),S(2,$),S(3,N.IRenderManagerService),S(4,c.ICommandService),S(5,_.IZenZoneService),S(6,D.IEditorBridgeService),S(7,c.IUndoRedoService),S(8,p.Inject(O.TextSelectionManagerService))],P);const Z={id:"zen-editor.command.cancel-zen-edit",type:c.CommandType.COMMAND,handler:async n=>{const e=n.get(_.IZenZoneService),i=n.get(D.IEditorBridgeService),t=n.get(c.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:N.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC}),e.close();const s=t.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return s?(t.focusUnit(s.getUnitId()),i.refreshEditCellState(),!0):!1}},L={id:"zen-editor.command.confirm-zen-edit",type:c.CommandType.COMMAND,handler:async n=>{const e=n.get(_.IZenZoneService),i=n.get(D.IEditorBridgeService),t=n.get(c.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:N.DeviceInputEventType.PointerDown}),e.close();const s=t.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return s?(t.focusUnit(s.getUnitId()),i.refreshEditCellState(),!0):!1}};function ce(n){return{id:j.id,group:_.MenuGroup.CONTEXT_MENU_OTHERS,type:_.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[_.MenuPosition.CONTEXT_MENU],disabled$:D.getCurrentRangeDisable$(n,{workbookTypes:[T.WorkbookEditablePermission],worksheetTypes:[T.WorksheetEditPermission,T.WorksheetSetCellValuePermission,T.WorksheetSetCellStylePermission],rangeTypes:[T.RangeProtectionPermissionEditPoint]})}}var Y={exports:{}},w={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ae=f,de=Symbol.for("react.element"),le=Symbol.for("react.fragment"),ue=Object.prototype.hasOwnProperty,_e=ae.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,he={key:!0,ref:!0,__self:!0,__source:!0};function K(n,e,i){var t,r={},o=null,s=null;i!==void 0&&(o=""+i),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(t in e)ue.call(e,t)&&!he.hasOwnProperty(t)&&(r[t]=e[t]);if(n&&n.defaultProps)for(t in e=n.defaultProps,e)r[t]===void 0&&(r[t]=e[t]);return{$$typeof:de,type:n,key:o,ref:s,props:r,_owner:_e.current}}j.Fragment=le;j.jsx=K;j.jsxs=K;Y.exports=j;var m=Y.exports,v=function(){return v=Object.assign||function(n){for(var e,i=1,t=arguments.length;i<t;i++){e=arguments[i];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},v.apply(this,arguments)},ve=function(n,e){var i={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.indexOf(t)<0&&(i[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(n);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(n,t[r])&&(i[t[r]]=n[t[r]]);return i},k=f.forwardRef(function(n,e){var i=n.icon,t=n.id,r=n.className,o=n.extend,s=ve(n,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),d=f.useRef("_".concat(Se()));return H(i,"".concat(t),{defIds:i.defIds,idSuffix:d.current},v({ref:e,className:a},s),o)});function H(n,e,i,t,r){return f.createElement(n.tag,v(v({key:e},fe(n,i,r)),t),(ge(n,i).children||[]).map(function(o,s){return H(o,"".concat(e,"-").concat(n.tag,"-").concat(s),i,void 0,r)}))}function fe(n,e,i){var t=v({},n.attrs);i!=null&&i.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=i.colorChannel1);var r=e.defIds;return!r||r.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(o){var s=o[0],a=o[1];typeof a=="string"&&(t[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function ge(n,e){var i,t=e.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?v(v({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?v(v({},r),{attrs:v(v({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):n}function Se(){return Math.random().toString(36).substring(2,8)}k.displayName="UniverIcon";var pe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},X=f.forwardRef(function(n,e){return f.createElement(k,Object.assign({},n,{id:"check-mark-single",ref:e,icon:pe}))});X.displayName="CheckMarkSingle";var Ie={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},G=f.forwardRef(function(n,e){return f.createElement(k,Object.assign({},n,{id:"close-single",ref:e,icon:Ie}))});G.displayName="CloseSingle";const Ee="univer-zen-editor",me="univer-zen-editor-icon-wrapper",Ce="univer-zen-editor-icon-container",Oe="univer-zen-editor-icon-success",ye="univer-zen-editor-icon-error",Te="univer-zen-editor-canvas-container",C={zenEditor:Ee,zenEditorIconWrapper:me,zenEditorIconContainer:Ce,zenEditorIconSuccess:Oe,zenEditorIconError:ye,zenEditorCanvasContainer:Te},Re="ZEN_EDITOR_PLUGIN_",be=`${Re}ZEN_EDITOR_COMPONENT`;function Ne(){const n=f.useRef(null),e=w.useDependency(N.IRenderManagerService),i=w.useDependency(V),t=w.useDependency(c.ICommandService);f.useEffect(()=>{const s=n.current;if(!s)return;const a=e.currentRender$.subscribe(l=>{var g;if(l!==h)return;const u=(g=e.getRenderById(h))==null?void 0:g.engine;u==null||u.setContainer(s)}),d=new ResizeObserver(()=>{const l=s.getBoundingClientRect();i.setPosition(l)});return d.observe(s),()=>{d.unobserve(s),a.unsubscribe()}},[]);function r(){t.executeCommand(B.id)}function o(){t.executeCommand($.id)}return m.jsxs("div",{className:C.zenEditor,children:[m.jsxs("div",{className:C.zenEditorIconWrapper,children:[m.jsx("span",{className:W(C.zenEditorIconContainer,C.zenEditorIconError),onClick:r,children:m.jsx(G,{style:{fontSize:"22px"}})}),m.jsx("span",{className:W(C.zenEditorIconContainer,C.zenEditorIconSuccess),onClick:o,children:m.jsx(X,{style:{fontSize:"22px"}})})]}),m.jsx("div",{className:C.zenEditorCanvasContainer,ref:n})]})}const ze={id:$.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:n=>J(n),binding:_.KeyCode.ENTER|_.MetaKeys.ALT},De={id:B.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:n=>J(n),binding:_.KeyCode.ESC};function J(n){return n.getContextValue(c.FOCUSING_DOC)&&n.getContextValue(c.FOCUSING_UNIVER_EDITOR)&&n.getContextValue(c.EDITOR_ACTIVATED)&&!n.getContextValue(c.FOCUSING_EDITOR_STANDALONE)}var xe=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,Ue=(n,e,i,t)=>{for(var r=t>1?void 0:t?Me(e,i):e,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=(t?s(e,i,r):s(r))||r);return t&&r&&xe(e,i,r),r},R=(n,e)=>(i,t)=>e(i,t,n);const Pe={};let b=class extends c.Disposable{constructor(n,e,i,t,r,o){super(),this._config=n,this._injector=e,this._zenZoneService=i,this._commandService=t,this._menuService=r,this._shortcutService=o,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(be,Ne))}_initCommands(){[A,B,$].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initMenus(){const{menu:n={}}=this._config;[ce].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e),n))})}_initShortcuts(){[ze,De].forEach(n=>{this.disposeWithMe(this._shortcutService.registerShortcut(n))})}};b=Ue([c.OnLifecycle(c.LifecycleStages.Rendered,b),R(1,p.Inject(p.Injector)),R(2,_.IZenZoneService),R(3,c.ICommandService),R(4,_.IMenuService),R(5,_.IShortcutService)],b);var je=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,Le=(n,e,i,t)=>{for(var r=t>1?void 0:t?Ze(e,i):e,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=(t?s(e,i,r):s(r))||r);return t&&r&&je(e,i,r),r},F=(n,e)=>(i,t)=>e(i,t,n),U;exports.UniverSheetsZenEditorPlugin=(U=class extends c.Plugin{constructor(e={},i,t){super(),this._config=e,this._injector=i,this._localeService=t,this._initializeDependencies(this._injector),this._config=c.Tools.deepMerge({},Pe,this._config)}_initializeDependencies(e){[[b,{useFactory:()=>this._injector.createInstance(b,this._config)}],[P],[V,{useClass:ie}]].forEach(t=>e.add(t))}},E(U,"pluginName","zen-editor"),E(U,"type",c.UniverInstanceType.UNIVER_DOC),U);exports.UniverSheetsZenEditorPlugin=Le([F(1,p.Inject(p.Injector)),F(2,p.Inject(c.LocaleService))],exports.UniverSheetsZenEditorPlugin);
9
+ */var ae=f,de=Symbol.for("react.element"),le=Symbol.for("react.fragment"),ue=Object.prototype.hasOwnProperty,_e=ae.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,he={key:!0,ref:!0,__self:!0,__source:!0};function K(n,e,i){var t,r={},s=null,o=null;i!==void 0&&(s=""+i),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(t in e)ue.call(e,t)&&!he.hasOwnProperty(t)&&(r[t]=e[t]);if(n&&n.defaultProps)for(t in e=n.defaultProps,e)r[t]===void 0&&(r[t]=e[t]);return{$$typeof:de,type:n,key:s,ref:o,props:r,_owner:_e.current}}w.Fragment=le;w.jsx=K;w.jsxs=K;Y.exports=w;var m=Y.exports,v=function(){return v=Object.assign||function(n){for(var e,i=1,t=arguments.length;i<t;i++){e=arguments[i];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},v.apply(this,arguments)},ve=function(n,e){var i={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.indexOf(t)<0&&(i[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(n);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(n,t[r])&&(i[t[r]]=n[t[r]]);return i},k=f.forwardRef(function(n,e){var i=n.icon,t=n.id,r=n.className,s=n.extend,o=ve(n,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),d=f.useRef("_".concat(Se()));return H(i,"".concat(t),{defIds:i.defIds,idSuffix:d.current},v({ref:e,className:a},o),s)});function H(n,e,i,t,r){return f.createElement(n.tag,v(v({key:e},fe(n,i,r)),t),(ge(n,i).children||[]).map(function(s,o){return H(s,"".concat(e,"-").concat(n.tag,"-").concat(o),i,void 0,r)}))}function fe(n,e,i){var t=v({},n.attrs);i!=null&&i.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=i.colorChannel1);var r=e.defIds;return!r||r.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(s){var o=s[0],a=s[1];typeof a=="string"&&(t[o]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function ge(n,e){var i,t=e.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?v(v({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?v(v({},r),{attrs:v(v({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):n}function Se(){return Math.random().toString(36).substring(2,8)}k.displayName="UniverIcon";var pe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},X=f.forwardRef(function(n,e){return f.createElement(k,Object.assign({},n,{id:"check-mark-single",ref:e,icon:pe}))});X.displayName="CheckMarkSingle";var Ie={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},G=f.forwardRef(function(n,e){return f.createElement(k,Object.assign({},n,{id:"close-single",ref:e,icon:Ie}))});G.displayName="CloseSingle";const Ee="univer-zen-editor",me="univer-zen-editor-icon-wrapper",Ce="univer-zen-editor-icon-container",Oe="univer-zen-editor-icon-success",ye="univer-zen-editor-icon-error",Te="univer-zen-editor-canvas-container",C={zenEditor:Ee,zenEditorIconWrapper:me,zenEditorIconContainer:Ce,zenEditorIconSuccess:Oe,zenEditorIconError:ye,zenEditorCanvasContainer:Te},Re="ZEN_EDITOR_PLUGIN_",be=`${Re}ZEN_EDITOR_COMPONENT`;function Ne(){const n=f.useRef(null),e=B.useDependency(N.IRenderManagerService),i=B.useDependency($),t=B.useDependency(c.ICommandService);f.useEffect(()=>{const o=n.current;if(!o)return;const a=e.currentRender$.subscribe(l=>{var g;if(l!==h)return;const u=(g=e.getRenderById(h))==null?void 0:g.engine;u==null||u.setContainer(o)}),d=new ResizeObserver(()=>{const l=o.getBoundingClientRect();i.setPosition(l)});return d.observe(o),()=>{d.unobserve(o),a.unsubscribe()}},[]);function r(){t.executeCommand(Z.id)}function s(){t.executeCommand(L.id)}return m.jsxs("div",{className:C.zenEditor,children:[m.jsxs("div",{className:C.zenEditorIconWrapper,children:[m.jsx("span",{className:F(C.zenEditorIconContainer,C.zenEditorIconError),onClick:r,children:m.jsx(G,{style:{fontSize:"22px"}})}),m.jsx("span",{className:F(C.zenEditorIconContainer,C.zenEditorIconSuccess),onClick:s,children:m.jsx(X,{style:{fontSize:"22px"}})})]}),m.jsx("div",{className:C.zenEditorCanvasContainer,ref:n})]})}const De={id:L.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:n=>J(n),binding:_.KeyCode.ENTER|_.MetaKeys.ALT},ze={id:Z.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:n=>J(n),binding:_.KeyCode.ESC};function J(n){return n.getContextValue(c.FOCUSING_DOC)&&n.getContextValue(c.FOCUSING_UNIVER_EDITOR)&&n.getContextValue(c.EDITOR_ACTIVATED)&&!n.getContextValue(c.FOCUSING_EDITOR_STANDALONE)}var Me=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,Ue=(n,e,i,t)=>{for(var r=t>1?void 0:t?xe(e,i):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(t?o(e,i,r):o(r))||r);return t&&r&&Me(e,i,r),r},R=(n,e)=>(i,t)=>e(i,t,n);const Pe={};let b=class extends c.Disposable{constructor(n,e,i,t,r,s){super(),this._config=n,this._injector=e,this._zenZoneService=i,this._commandService=t,this._menuService=r,this._shortcutService=s,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(be,Ne))}_initCommands(){[j,Z,L].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initMenus(){const{menu:n={}}=this._config;[ce].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e),n))})}_initShortcuts(){[De,ze].forEach(n=>{this.disposeWithMe(this._shortcutService.registerShortcut(n))})}};b=Ue([c.OnLifecycle(c.LifecycleStages.Rendered,b),R(1,p.Inject(p.Injector)),R(2,_.IZenZoneService),R(3,c.ICommandService),R(4,_.IMenuService),R(5,_.IShortcutService)],b);var je=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,Le=(n,e,i,t)=>{for(var r=t>1?void 0:t?Ze(e,i):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(t?o(e,i,r):o(r))||r);return t&&r&&je(e,i,r),r},W=(n,e)=>(i,t)=>e(i,t,n),U;exports.UniverSheetsZenEditorPlugin=(U=class extends c.Plugin{constructor(e={},i,t){super(),this._config=e,this._injector=i,this._localeService=t,this._initializeDependencies(this._injector),this._config=c.Tools.deepMerge({},Pe,this._config)}_initializeDependencies(e){[[b,{useFactory:()=>this._injector.createInstance(b,this._config)}],[P],[$,{useClass:ie}]].forEach(t=>e.add(t))}},E(U,"pluginName","zen-editor"),E(U,"type",c.UniverInstanceType.UNIVER_DOC),U);exports.UniverSheetsZenEditorPlugin=Le([W(1,p.Inject(p.Injector)),W(2,p.Inject(c.LocaleService))],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=Z;exports.ConfirmZenEditCommand=L;exports.OpenZenEditorOperation=j;
package/lib/es/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  var he = Object.defineProperty;
2
2
  var _e = (t, e, i) => e in t ? he(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
3
3
  var g = (t, e, i) => _e(t, typeof e != "symbol" ? e + "" : e, i);
4
- import { CommandType as U, RxDisposable as fe, UniverInstanceType as N, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as K, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as X, OnLifecycle as ee, LifecycleStages as te, DEFAULT_EMPTY_DOCUMENT_VALUE as ve, IUniverInstanceService as j, ICommandService as w, IUndoRedoService as ge, FOCUSING_DOC as pe, FOCUSING_UNIVER_EDITOR as me, EDITOR_ACTIVATED as Se, FOCUSING_EDITOR_STANDALONE as Ee, Disposable as Ie, Plugin as Ce, Tools as Oe, LocaleService as ye } from "@univerjs/core";
5
- import { createIdentifier as be, Inject as C, Injector as L } from "@wendellhu/redi";
6
- import { DocSkeletonManagerService as G, VIEWPORT_KEY as Te, RichTextEditingMutation as Re, getDocObject as Ne, TextSelectionManagerService as ze } from "@univerjs/docs";
4
+ import { CommandType as U, RxDisposable as fe, DEFAULT_EMPTY_DOCUMENT_VALUE as ve, DocumentFlavor as ge, UniverInstanceType as N, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as K, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as X, OnLifecycle as ee, LifecycleStages as te, IUniverInstanceService as j, ICommandService as w, IUndoRedoService as pe, FOCUSING_DOC as me, FOCUSING_UNIVER_EDITOR as Se, EDITOR_ACTIVATED as Ee, FOCUSING_EDITOR_STANDALONE as Ie, Disposable as Ce, Plugin as Oe, Tools as ye, LocaleService as be } from "@univerjs/core";
5
+ import { createIdentifier as Te, Inject as C, Injector as L } from "@wendellhu/redi";
6
+ import { DocSkeletonManagerService as G, VIEWPORT_KEY as Re, RichTextEditingMutation as Ne, getDocObject as ze, TextSelectionManagerService as xe } from "@univerjs/docs";
7
7
  import { DeviceInputEventType as Z, IRenderManagerService as ne } from "@univerjs/engine-render";
8
- import { getEditorObject as xe, IEditorBridgeService as V, getCurrentRangeDisable$ as Me } from "@univerjs/sheets-ui";
9
- import { IZenZoneService as z, KeyCode as A, MenuGroup as De, MenuItemType as Pe, MenuPosition as Ue, MetaKeys as je, IMenuService as we, IShortcutService as Le } from "@univerjs/ui";
10
- import { BehaviorSubject as Ze, takeUntil as Ve } from "rxjs";
11
- import { WorkbookEditablePermission as Ae, WorksheetEditPermission as $e, WorksheetSetCellValuePermission as Be, WorksheetSetCellStylePermission as ke, RangeProtectionPermissionEditPoint as We } from "@univerjs/sheets";
12
- import Fe, { forwardRef as $, useRef as ie, createElement as B, useEffect as Ye } from "react";
8
+ import { getEditorObject as Me, IEditorBridgeService as V, getCurrentRangeDisable$ as De } from "@univerjs/sheets-ui";
9
+ import { IZenZoneService as z, KeyCode as A, MenuGroup as Pe, MenuItemType as Ue, MenuPosition as je, MetaKeys as we, IMenuService as Le, IShortcutService as Ze } from "@univerjs/ui";
10
+ import { BehaviorSubject as Ve, takeUntil as Ae } from "rxjs";
11
+ import { WorkbookEditablePermission as $e, WorksheetEditPermission as Be, WorksheetSetCellValuePermission as ke, WorksheetSetCellStylePermission as Fe, RangeProtectionPermissionEditPoint as We } from "@univerjs/sheets";
12
+ import Ye, { forwardRef as $, useRef as ie, createElement as B, useEffect as He } from "react";
13
13
  import { useDependency as P } from "@wendellhu/redi/react-bindings";
14
14
  import q from "clsx";
15
15
  const k = {
@@ -17,10 +17,10 @@ const k = {
17
17
  type: U.OPERATION,
18
18
  handler: (t) => !0
19
19
  };
20
- class He {
20
+ class Ke {
21
21
  constructor() {
22
22
  g(this, "_position", null);
23
- g(this, "_position$", new Ze(null));
23
+ g(this, "_position$", new Ve(null));
24
24
  g(this, "position$", this._position$.asObservable());
25
25
  }
26
26
  dispose() {
@@ -36,13 +36,13 @@ class He {
36
36
  this._position$.next(e);
37
37
  }
38
38
  }
39
- const W = be(
39
+ const F = Te(
40
40
  "univer.sheet-zen-editor-manager.service"
41
41
  );
42
- var Ke = Object.defineProperty, Xe = Object.getOwnPropertyDescriptor, Ge = (t, e, i, n) => {
43
- for (var r = n > 1 ? void 0 : n ? Xe(e, i) : e, s = t.length - 1, o; s >= 0; s--)
42
+ var Xe = Object.defineProperty, Ge = Object.getOwnPropertyDescriptor, qe = (t, e, i, n) => {
43
+ for (var r = n > 1 ? void 0 : n ? Ge(e, i) : e, s = t.length - 1, o; s >= 0; s--)
44
44
  (o = t[s]) && (r = (n ? o(e, i, r) : o(r)) || r);
45
- return n && r && Ke(e, i, r), r;
45
+ return n && r && Xe(e, i, r), r;
46
46
  }, f = (t, e) => (i, n) => e(i, n, t);
47
47
  const u = "__defaultDocumentZenEditorSpecialUnitId_20231218__";
48
48
  let R = class extends fe {
@@ -71,6 +71,7 @@ let R = class extends fe {
71
71
  width: 595,
72
72
  height: 842
73
73
  },
74
+ documentFlavor: ge.MODERN,
74
75
  marginTop: 50,
75
76
  marginBottom: 50,
76
77
  marginRight: 40,
@@ -85,11 +86,11 @@ let R = class extends fe {
85
86
  }
86
87
  // Listen to changes in the size of the zen editor container to set the size of the editor.
87
88
  _syncZenEditorSize() {
88
- this._zenEditorManagerService.position$.pipe(Ve(this.dispose$)).subscribe((e) => {
89
+ this._zenEditorManagerService.position$.pipe(Ae(this.dispose$)).subscribe((e) => {
89
90
  var a;
90
91
  if (e == null)
91
92
  return;
92
- const i = xe(u, this._renderManagerService), n = this._univerInstanceService.getUniverDocInstance(u);
93
+ const i = Me(u, this._renderManagerService), n = this._univerInstanceService.getUniverDocInstance(u);
93
94
  if (i == null || n == null)
94
95
  return;
95
96
  const { width: r, height: s } = e, { engine: o } = i, c = (a = this._renderManagerService.getRenderById(u)) == null ? void 0 : a.with(G).getSkeleton();
@@ -143,7 +144,7 @@ let R = class extends fe {
143
144
  let v = 0, O = 0, y = 0, M = 0, b = Number.POSITIVE_INFINITY;
144
145
  const { scaleX: S, scaleY: le } = n.getAncestorScale();
145
146
  l > (o + a * 2) * S ? (v = l / 2 - o * S / 2, v /= S, y = (l - a * 2) / S, b = 0) : (v = a, y = o + a * 2, b = (y - l / S) / 2), _ > c ? (O = _ / 2 - c / 2, M = (_ - d * 2) / le) : (O = d, M = c + d * 2), n.resize(y, M + 200), i.translate(v, O), r.translate(v, O);
146
- const D = n.getViewport(Te.VIEW_MAIN);
147
+ const D = n.getViewport(Re.VIEW_MAIN);
147
148
  if (b !== Number.POSITIVE_INFINITY && D != null) {
148
149
  const ue = D.transScroll2ViewportScrollValue(b, 0).x;
149
150
  D.scrollTo({
@@ -159,7 +160,7 @@ let R = class extends fe {
159
160
  e.includes(n.id) && this._handleOpenZenEditor();
160
161
  })
161
162
  );
162
- const i = [Re.id];
163
+ const i = [Ne.id];
163
164
  this.disposeWithMe(
164
165
  this._commandService.onCommandExecuted((n) => {
165
166
  if (i.includes(n.id)) {
@@ -175,22 +176,22 @@ let R = class extends fe {
175
176
  );
176
177
  }
177
178
  _getDocObject() {
178
- return Ne(this._univerInstanceService, this._renderManagerService);
179
+ return ze(this._univerInstanceService, this._renderManagerService);
179
180
  }
180
181
  };
181
- R = Ge([
182
+ R = qe([
182
183
  ee(te.Steady, R),
183
184
  f(0, C(L)),
184
185
  f(1, j),
185
- f(2, W),
186
+ f(2, F),
186
187
  f(3, ne),
187
188
  f(4, w),
188
189
  f(5, z),
189
190
  f(6, V),
190
- f(7, ge),
191
- f(8, C(ze))
191
+ f(7, pe),
192
+ f(8, C(xe))
192
193
  ], R);
193
- const F = {
194
+ const W = {
194
195
  id: "zen-editor.command.cancel-zen-edit",
195
196
  type: U.COMMAND,
196
197
  handler: async (t) => {
@@ -216,15 +217,15 @@ const F = {
216
217
  return s ? (n.focusUnit(s.getUnitId()), i.refreshEditCellState(), !0) : !1;
217
218
  }
218
219
  };
219
- function qe(t) {
220
+ function Je(t) {
220
221
  return {
221
222
  id: k.id,
222
- group: De.CONTEXT_MENU_OTHERS,
223
- type: Pe.BUTTON,
223
+ group: Pe.CONTEXT_MENU_OTHERS,
224
+ type: Ue.BUTTON,
224
225
  title: "rightClick.zenEditor",
225
226
  icon: "AmplifySingle",
226
- positions: [Ue.CONTEXT_MENU],
227
- disabled$: Me(t, { workbookTypes: [Ae], worksheetTypes: [$e, Be, ke], rangeTypes: [We] })
227
+ positions: [je.CONTEXT_MENU],
228
+ disabled$: De(t, { workbookTypes: [$e], worksheetTypes: [Be, ke, Fe], rangeTypes: [We] })
228
229
  };
229
230
  }
230
231
  var re = { exports: {} }, x = {};
@@ -237,15 +238,15 @@ var re = { exports: {} }, x = {};
237
238
  * This source code is licensed under the MIT license found in the
238
239
  * LICENSE file in the root directory of this source tree.
239
240
  */
240
- var Je = Fe, Qe = Symbol.for("react.element"), et = Symbol.for("react.fragment"), tt = Object.prototype.hasOwnProperty, nt = Je.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, it = { key: !0, ref: !0, __self: !0, __source: !0 };
241
+ var Qe = Ye, et = Symbol.for("react.element"), tt = Symbol.for("react.fragment"), nt = Object.prototype.hasOwnProperty, it = Qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, rt = { key: !0, ref: !0, __self: !0, __source: !0 };
241
242
  function oe(t, e, i) {
242
243
  var n, r = {}, s = null, o = null;
243
244
  i !== void 0 && (s = "" + i), e.key !== void 0 && (s = "" + e.key), e.ref !== void 0 && (o = e.ref);
244
- for (n in e) tt.call(e, n) && !it.hasOwnProperty(n) && (r[n] = e[n]);
245
+ for (n in e) nt.call(e, n) && !rt.hasOwnProperty(n) && (r[n] = e[n]);
245
246
  if (t && t.defaultProps) for (n in e = t.defaultProps, e) r[n] === void 0 && (r[n] = e[n]);
246
- return { $$typeof: Qe, type: t, key: s, ref: o, props: r, _owner: nt.current };
247
+ return { $$typeof: et, type: t, key: s, ref: o, props: r, _owner: it.current };
247
248
  }
248
- x.Fragment = et;
249
+ x.Fragment = tt;
249
250
  x.jsx = oe;
250
251
  x.jsxs = oe;
251
252
  re.exports = x;
@@ -257,7 +258,7 @@ var p = re.exports, h = function() {
257
258
  }
258
259
  return t;
259
260
  }, h.apply(this, arguments);
260
- }, rt = function(t, e) {
261
+ }, ot = function(t, e) {
261
262
  var i = {};
262
263
  for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (i[n] = t[n]);
263
264
  if (t != null && typeof Object.getOwnPropertySymbols == "function")
@@ -265,15 +266,15 @@ var p = re.exports, h = function() {
265
266
  e.indexOf(n[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[r]) && (i[n[r]] = t[n[r]]);
266
267
  return i;
267
268
  }, H = $(function(t, e) {
268
- var i = t.icon, n = t.id, r = t.className, s = t.extend, o = rt(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(n, " ").concat(r || "").trim(), a = ie("_".concat(ct()));
269
+ var i = t.icon, n = t.id, r = t.className, s = t.extend, o = ot(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(n, " ").concat(r || "").trim(), a = ie("_".concat(at()));
269
270
  return se(i, "".concat(n), { defIds: i.defIds, idSuffix: a.current }, h({ ref: e, className: c }, o), s);
270
271
  });
271
272
  function se(t, e, i, n, r) {
272
- return B(t.tag, h(h({ key: e }, ot(t, i, r)), n), (st(t, i).children || []).map(function(s, o) {
273
+ return B(t.tag, h(h({ key: e }, st(t, i, r)), n), (ct(t, i).children || []).map(function(s, o) {
273
274
  return se(s, "".concat(e, "-").concat(t.tag, "-").concat(o), i, void 0, r);
274
275
  }));
275
276
  }
276
- function ot(t, e, i) {
277
+ function st(t, e, i) {
277
278
  var n = h({}, t.attrs);
278
279
  i != null && i.colorChannel1 && n.fill === "colorChannel1" && (n.fill = i.colorChannel1);
279
280
  var r = e.defIds;
@@ -282,43 +283,43 @@ function ot(t, e, i) {
282
283
  typeof c == "string" && (n[o] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
283
284
  })), n;
284
285
  }
285
- function st(t, e) {
286
+ function ct(t, e) {
286
287
  var i, n = e.defIds;
287
288
  return !n || n.length === 0 ? t : t.tag === "defs" && (!((i = t.children) === null || i === void 0) && i.length) ? h(h({}, t), { children: t.children.map(function(r) {
288
289
  return typeof r.attrs.id == "string" && n && n.indexOf(r.attrs.id) > -1 ? h(h({}, r), { attrs: h(h({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
289
290
  }) }) : t;
290
291
  }
291
- function ct() {
292
+ function at() {
292
293
  return Math.random().toString(36).substring(2, 8);
293
294
  }
294
295
  H.displayName = "UniverIcon";
295
- var at = { 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" } }] }, ce = $(function(t, e) {
296
+ var dt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, ce = $(function(t, e) {
296
297
  return B(H, Object.assign({}, t, {
297
298
  id: "check-mark-single",
298
299
  ref: e,
299
- icon: at
300
+ icon: dt
300
301
  }));
301
302
  });
302
303
  ce.displayName = "CheckMarkSingle";
303
- var dt = { 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" } }] }, ae = $(function(t, e) {
304
+ var lt = { 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" } }] }, ae = $(function(t, e) {
304
305
  return B(H, Object.assign({}, t, {
305
306
  id: "close-single",
306
307
  ref: e,
307
- icon: dt
308
+ icon: lt
308
309
  }));
309
310
  });
310
311
  ae.displayName = "CloseSingle";
311
- const lt = "univer-zen-editor", ut = "univer-zen-editor-icon-wrapper", ht = "univer-zen-editor-icon-container", _t = "univer-zen-editor-icon-success", ft = "univer-zen-editor-icon-error", vt = "univer-zen-editor-canvas-container", m = {
312
- zenEditor: lt,
313
- zenEditorIconWrapper: ut,
314
- zenEditorIconContainer: ht,
315
- zenEditorIconSuccess: _t,
316
- zenEditorIconError: ft,
317
- zenEditorCanvasContainer: vt
318
- }, gt = "ZEN_EDITOR_PLUGIN_", pt = `${gt}ZEN_EDITOR_COMPONENT`;
319
- function mt() {
320
- const t = ie(null), e = P(ne), i = P(W), n = P(w);
321
- Ye(() => {
312
+ const ut = "univer-zen-editor", ht = "univer-zen-editor-icon-wrapper", _t = "univer-zen-editor-icon-container", ft = "univer-zen-editor-icon-success", vt = "univer-zen-editor-icon-error", gt = "univer-zen-editor-canvas-container", m = {
313
+ zenEditor: ut,
314
+ zenEditorIconWrapper: ht,
315
+ zenEditorIconContainer: _t,
316
+ zenEditorIconSuccess: ft,
317
+ zenEditorIconError: vt,
318
+ zenEditorCanvasContainer: gt
319
+ }, pt = "ZEN_EDITOR_PLUGIN_", mt = `${pt}ZEN_EDITOR_COMPONENT`;
320
+ function St() {
321
+ const t = ie(null), e = P(ne), i = P(F), n = P(w);
322
+ He(() => {
322
323
  const o = t.current;
323
324
  if (!o)
324
325
  return;
@@ -337,7 +338,7 @@ function mt() {
337
338
  };
338
339
  }, []);
339
340
  function r() {
340
- n.executeCommand(F.id);
341
+ n.executeCommand(W.id);
341
342
  }
342
343
  function s() {
343
344
  n.executeCommand(Y.id);
@@ -364,29 +365,29 @@ function mt() {
364
365
  /* @__PURE__ */ p.jsx("div", { className: m.zenEditorCanvasContainer, ref: t })
365
366
  ] });
366
367
  }
367
- const St = {
368
+ const Et = {
368
369
  id: Y.id,
369
370
  description: "shortcut.sheet.zen-edit-confirm",
370
371
  group: "4_sheet-edit",
371
372
  preconditions: (t) => de(t),
372
- binding: A.ENTER | je.ALT
373
- }, Et = {
374
- id: F.id,
373
+ binding: A.ENTER | we.ALT
374
+ }, It = {
375
+ id: W.id,
375
376
  description: "shortcut.sheet.zen-edit-cancel",
376
377
  group: "4_sheet-edit",
377
378
  preconditions: (t) => de(t),
378
379
  binding: A.ESC
379
380
  };
380
381
  function de(t) {
381
- return t.getContextValue(pe) && t.getContextValue(me) && t.getContextValue(Se) && !t.getContextValue(Ee);
382
+ return t.getContextValue(me) && t.getContextValue(Se) && t.getContextValue(Ee) && !t.getContextValue(Ie);
382
383
  }
383
- var It = Object.defineProperty, Ct = Object.getOwnPropertyDescriptor, Ot = (t, e, i, n) => {
384
- for (var r = n > 1 ? void 0 : n ? Ct(e, i) : e, s = t.length - 1, o; s >= 0; s--)
384
+ var Ct = Object.defineProperty, Ot = Object.getOwnPropertyDescriptor, yt = (t, e, i, n) => {
385
+ for (var r = n > 1 ? void 0 : n ? Ot(e, i) : e, s = t.length - 1, o; s >= 0; s--)
385
386
  (o = t[s]) && (r = (n ? o(e, i, r) : o(r)) || r);
386
- return n && r && It(e, i, r), r;
387
+ return n && r && Ct(e, i, r), r;
387
388
  }, E = (t, e) => (i, n) => e(i, n, t);
388
- const yt = {};
389
- let I = class extends Ie {
389
+ const bt = {};
390
+ let I = class extends Ce {
390
391
  constructor(t, e, i, n, r, s) {
391
392
  super(), this._config = t, this._injector = e, this._zenZoneService = i, this._commandService = n, this._menuService = r, this._shortcutService = s, this._initialize();
392
393
  }
@@ -394,10 +395,10 @@ let I = class extends Ie {
394
395
  this._initCustomComponents(), this._initCommands(), this._initMenus(), this._initShortcuts();
395
396
  }
396
397
  _initCustomComponents() {
397
- this.disposeWithMe(this._zenZoneService.set(pt, mt));
398
+ this.disposeWithMe(this._zenZoneService.set(mt, St));
398
399
  }
399
400
  _initCommands() {
400
- [k, F, Y].forEach((t) => {
401
+ [k, W, Y].forEach((t) => {
401
402
  this.disposeWithMe(this._commandService.registerCommand(t));
402
403
  });
403
404
  }
@@ -405,33 +406,33 @@ let I = class extends Ie {
405
406
  const { menu: t = {} } = this._config;
406
407
  [
407
408
  // context menu
408
- qe
409
+ Je
409
410
  ].forEach((e) => {
410
411
  this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e), t));
411
412
  });
412
413
  }
413
414
  _initShortcuts() {
414
- [St, Et].forEach((t) => {
415
+ [Et, It].forEach((t) => {
415
416
  this.disposeWithMe(this._shortcutService.registerShortcut(t));
416
417
  });
417
418
  }
418
419
  };
419
- I = Ot([
420
+ I = yt([
420
421
  ee(te.Rendered, I),
421
422
  E(1, C(L)),
422
423
  E(2, z),
423
424
  E(3, w),
424
- E(4, we),
425
- E(5, Le)
425
+ E(4, Le),
426
+ E(5, Ze)
426
427
  ], I);
427
- var bt = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, Rt = (t, e, i, n) => {
428
- for (var r = n > 1 ? void 0 : n ? Tt(e, i) : e, s = t.length - 1, o; s >= 0; s--)
428
+ var Tt = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, Nt = (t, e, i, n) => {
429
+ for (var r = n > 1 ? void 0 : n ? Rt(e, i) : e, s = t.length - 1, o; s >= 0; s--)
429
430
  (o = t[s]) && (r = (n ? o(e, i, r) : o(r)) || r);
430
- return n && r && bt(e, i, r), r;
431
+ return n && r && Tt(e, i, r), r;
431
432
  }, J = (t, e) => (i, n) => e(i, n, t), T;
432
- let Q = (T = class extends Ce {
433
+ let Q = (T = class extends Oe {
433
434
  constructor(t = {}, e, i) {
434
- super(), this._config = t, this._injector = e, this._localeService = i, this._initializeDependencies(this._injector), this._config = Oe.deepMerge({}, yt, this._config);
435
+ super(), this._config = t, this._injector = e, this._localeService = i, this._initializeDependencies(this._injector), this._config = ye.deepMerge({}, bt, this._config);
435
436
  }
436
437
  _initializeDependencies(t) {
437
438
  [
@@ -442,14 +443,17 @@ let Q = (T = class extends Ce {
442
443
  }
443
444
  ],
444
445
  [R],
445
- [W, { useClass: He }]
446
+ [F, { useClass: Ke }]
446
447
  ].forEach((i) => t.add(i));
447
448
  }
448
449
  }, g(T, "pluginName", "zen-editor"), g(T, "type", N.UNIVER_DOC), T);
449
- Q = Rt([
450
+ Q = Nt([
450
451
  J(1, C(L)),
451
- J(2, C(ye))
452
+ J(2, C(be))
452
453
  ], Q);
453
454
  export {
455
+ W as CancelZenEditCommand,
456
+ Y as ConfirmZenEditCommand,
457
+ k as OpenZenEditorOperation,
454
458
  Q as UniverSheetsZenEditorPlugin
455
459
  };
@@ -14,3 +14,5 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export { UniverSheetsZenEditorPlugin } from './plugin';
17
+ export { OpenZenEditorOperation } from './commands/operations/zen-editor.operation';
18
+ export { CancelZenEditCommand, ConfirmZenEditCommand } from './commands/commands/zen-editor.command';
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(d,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets"),require("react"),require("@wendellhu/redi/react-bindings"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/docs","@univerjs/engine-render","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/sheets","react","@wendellhu/redi/react-bindings","clsx"],c):(d=typeof globalThis<"u"?globalThis:d||self,c(d.UniverSheetsZenEditor={},d.UniverCore,d["@wendellhu/redi"],d.UniverDocs,d.UniverEngineRender,d.UniverSheetsUi,d.UniverUi,d.rxjs,d.UniverSheets,d.React,d["@wendellhu/redi/react-bindings"],d.clsx))})(this,function(d,c,h,y,T,R,_,Y,N,p,Z,K){"use strict";var De=Object.defineProperty;var be=(d,c,h)=>c in d?De(d,c,{enumerable:!0,configurable:!0,writable:!0,value:h}):d[c]=h;var O=(d,c,h)=>be(d,typeof c!="symbol"?c+"":c,h);var M;const L={id:"zen-editor.operation.open-zen-editor",type:c.CommandType.OPERATION,handler:n=>!0};class ee{constructor(){O(this,"_position",null);O(this,"_position$",new Y.BehaviorSubject(null));O(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(t){this._position=t,this._refresh(t)}getPosition(){return this._position}_refresh(t){this._position$.next(t)}}const A=h.createIdentifier("univer.sheet-zen-editor-manager.service");var te=Object.defineProperty,ne=Object.getOwnPropertyDescriptor,ie=(n,t,i,e)=>{for(var r=e>1?void 0:e?ne(t,i):t,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=(e?s(t,i,r):s(r))||r);return e&&r&&te(t,i,r),r},g=(n,t)=>(i,e)=>t(i,e,n);const f="__defaultDocumentZenEditorSpecialUnitId_20231218__";let b=class extends c.RxDisposable{constructor(t,i,e,r,o,s,a,l,u){super();O(this,"_zenEditorInitialState",!1);this._injector=t,this._univerInstanceService=i,this._zenEditorManagerService=e,this._renderManagerService=r,this._commandService=o,this._zenZoneService=s,this._editorBridgeService=a,this._undoRedoService=l,this._textSelectionManagerService=u,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const t={id:f,body:{dataStream:`${c.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:595,height:842},marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}}};return this._univerInstanceService.createUnit(c.UniverInstanceType.UNIVER_DOC,t)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(Y.takeUntil(this.dispose$)).subscribe(t=>{var l;if(t==null)return;const i=R.getEditorObject(f,this._renderManagerService),e=this._univerInstanceService.getUniverDocInstance(f);if(i==null||e==null)return;const{width:r,height:o}=t,{engine:s}=i,a=(l=this._renderManagerService.getRenderById(f))==null?void 0:l.with(y.DocSkeletonManagerService).getSkeleton();requestIdleCallback(()=>{s.resizeBySize(r,o),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:T.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 s,a;const i=(s=t.documentLayoutObject.documentModel)==null?void 0:s.getBody(),e=i==null?void 0:i.dataStream,r=i==null?void 0:i.paragraphs;let o=[];e==null||r==null||((a=i==null?void 0:i.textRuns)!=null&&a.length&&(o=i==null?void 0:i.textRuns),this._syncContentAndRender(f,e,r,o))}_syncContentAndRender(t,i,e,r=[]){var E;const o=[f,c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=(E=this._renderManagerService.getRenderById(t))==null?void 0:E.with(y.DocSkeletonManagerService),a=s==null?void 0:s.getSkeleton(),l=this._univerInstanceService.getUniverDocInstance(t),u=s==null?void 0:s.getViewModel();if(l==null||u==null||a==null)return;const v=l.getBody();v.dataStream=i,v.paragraphs=e,t===c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(v.textRuns=[]),r.length>0&&(v.textRuns=r),u.reset(l);const I=this._getDocObject();I!=null&&(a.calculate(),o.includes(t)&&I.document.makeDirty())}_calculatePagePosition(t){const{document:i,scene:e,docBackground:r}=t,o=e==null?void 0:e.getParent(),{width:s,height:a,pageMarginLeft:l,pageMarginTop:u}=i;if(o==null||s===Number.POSITIVE_INFINITY||a===Number.POSITIVE_INFINITY)return;const{width:v,height:I}=o;let E=0,U=0,P=0,W=0,w=Number.POSITIVE_INFINITY;const{scaleX:D,scaleY:ze}=e.getAncestorScale();v>(s+l*2)*D?(E=v/2-s*D/2,E/=D,P=(v-l*2)/D,w=0):(E=l,P=s+l*2,w=(P-v/D)/2),I>a?(U=I/2-a/2,W=(I-u*2)/ze):(U=u,W=a+u*2),e.resize(P,W+200),i.translate(E,U),r.translate(E,U);const F=e.getViewport(y.VIEWPORT_KEY.VIEW_MAIN);if(w!==Number.POSITIVE_INFINITY&&F!=null){const je=F.transScroll2ViewportScrollValue(w,0).x;F.scrollTo({x:je})}return this}_commandExecutedListener(){const t=[L.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{t.includes(e.id)&&this._handleOpenZenEditor()}));const i=[y.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const r=e.params,{unitId:o}=r;if(o===f){const s=this._univerInstanceService.getUniverDocInstance(o),a=s==null?void 0:s.getBody(),l=a==null?void 0:a.dataStream,u=a==null?void 0:a.paragraphs,v=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,v)}}}))}_getDocObject(){return y.getDocObject(this._univerInstanceService,this._renderManagerService)}};b=ie([c.OnLifecycle(c.LifecycleStages.Steady,b),g(0,h.Inject(h.Injector)),g(1,c.IUniverInstanceService),g(2,A),g(3,T.IRenderManagerService),g(4,c.ICommandService),g(5,_.IZenZoneService),g(6,R.IEditorBridgeService),g(7,c.IUndoRedoService),g(8,h.Inject(y.TextSelectionManagerService))],b);const V={id:"zen-editor.command.cancel-zen-edit",type:c.CommandType.COMMAND,handler:async n=>{const t=n.get(_.IZenZoneService),i=n.get(R.IEditorBridgeService),e=n.get(c.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:T.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC}),t.close();const o=e.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return o?(e.focusUnit(o.getUnitId()),i.refreshEditCellState(),!0):!1}},B={id:"zen-editor.command.confirm-zen-edit",type:c.CommandType.COMMAND,handler:async n=>{const t=n.get(_.IZenZoneService),i=n.get(R.IEditorBridgeService),e=n.get(c.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:T.DeviceInputEventType.PointerDown}),t.close();const o=e.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return o?(e.focusUnit(o.getUnitId()),i.refreshEditCellState(),!0):!1}};function re(n){return{id:L.id,group:_.MenuGroup.CONTEXT_MENU_OTHERS,type:_.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[_.MenuPosition.CONTEXT_MENU],disabled$:R.getCurrentRangeDisable$(n,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission,N.WorksheetSetCellValuePermission,N.WorksheetSetCellStylePermission],rangeTypes:[N.RangeProtectionPermissionEditPoint]})}}var H={exports:{}},x={};/**
1
+ (function(d,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets"),require("react"),require("@wendellhu/redi/react-bindings"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/docs","@univerjs/engine-render","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/sheets","react","@wendellhu/redi/react-bindings","clsx"],c):(d=typeof globalThis<"u"?globalThis:d||self,c(d.UniverSheetsZenEditor={},d.UniverCore,d["@wendellhu/redi"],d.UniverDocs,d.UniverEngineRender,d.UniverSheetsUi,d.UniverUi,d.rxjs,d.UniverSheets,d.React,d["@wendellhu/redi/react-bindings"],d.clsx))})(this,function(d,c,h,y,T,R,_,Y,N,p,V,K){"use strict";var je=Object.defineProperty;var be=(d,c,h)=>c in d?je(d,c,{enumerable:!0,configurable:!0,writable:!0,value:h}):d[c]=h;var O=(d,c,h)=>be(d,typeof c!="symbol"?c+"":c,h);var Z;const b={id:"zen-editor.operation.open-zen-editor",type:c.CommandType.OPERATION,handler:n=>!0};class ee{constructor(){O(this,"_position",null);O(this,"_position$",new Y.BehaviorSubject(null));O(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 B=h.createIdentifier("univer.sheet-zen-editor-manager.service");var te=Object.defineProperty,ne=Object.getOwnPropertyDescriptor,ie=(n,t,i,e)=>{for(var r=e>1?void 0:e?ne(t,i):t,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=(e?s(t,i,r):s(r))||r);return e&&r&&te(t,i,r),r},g=(n,t)=>(i,e)=>t(i,e,n);const f="__defaultDocumentZenEditorSpecialUnitId_20231218__";let M=class extends c.RxDisposable{constructor(t,i,e,r,o,s,a,l,u){super();O(this,"_zenEditorInitialState",!1);this._injector=t,this._univerInstanceService=i,this._zenEditorManagerService=e,this._renderManagerService=r,this._commandService=o,this._zenZoneService=s,this._editorBridgeService=a,this._undoRedoService=l,this._textSelectionManagerService=u,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},documentFlavor:c.DocumentFlavor.MODERN,marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}}};return this._univerInstanceService.createUnit(c.UniverInstanceType.UNIVER_DOC,t)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(Y.takeUntil(this.dispose$)).subscribe(t=>{var l;if(t==null)return;const i=R.getEditorObject(f,this._renderManagerService),e=this._univerInstanceService.getUniverDocInstance(f);if(i==null||e==null)return;const{width:r,height:o}=t,{engine:s}=i,a=(l=this._renderManagerService.getRenderById(f))==null?void 0:l.with(y.DocSkeletonManagerService).getSkeleton();requestIdleCallback(()=>{s.resizeBySize(r,o),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:T.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 s,a;const i=(s=t.documentLayoutObject.documentModel)==null?void 0:s.getBody(),e=i==null?void 0:i.dataStream,r=i==null?void 0:i.paragraphs;let o=[];e==null||r==null||((a=i==null?void 0:i.textRuns)!=null&&a.length&&(o=i==null?void 0:i.textRuns),this._syncContentAndRender(f,e,r,o))}_syncContentAndRender(t,i,e,r=[]){var I;const o=[f,c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=(I=this._renderManagerService.getRenderById(t))==null?void 0:I.with(y.DocSkeletonManagerService),a=s==null?void 0:s.getSkeleton(),l=this._univerInstanceService.getUniverDocInstance(t),u=s==null?void 0:s.getViewModel();if(l==null||u==null||a==null)return;const v=l.getBody();v.dataStream=i,v.paragraphs=e,t===c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(v.textRuns=[]),r.length>0&&(v.textRuns=r),u.reset(l);const E=this._getDocObject();E!=null&&(a.calculate(),o.includes(t)&&E.document.makeDirty())}_calculatePagePosition(t){const{document:i,scene:e,docBackground:r}=t,o=e==null?void 0:e.getParent(),{width:s,height:a,pageMarginLeft:l,pageMarginTop:u}=i;if(o==null||s===Number.POSITIVE_INFINITY||a===Number.POSITIVE_INFINITY)return;const{width:v,height:E}=o;let I=0,w=0,L=0,F=0,A=Number.POSITIVE_INFINITY;const{scaleX:j,scaleY:ze}=e.getAncestorScale();v>(s+l*2)*j?(I=v/2-s*j/2,I/=j,L=(v-l*2)/j,A=0):(I=l,L=s+l*2,A=(L-v/j)/2),E>a?(w=E/2-a/2,F=(E-u*2)/ze):(w=u,F=a+u*2),e.resize(L,F+200),i.translate(I,w),r.translate(I,w);const W=e.getViewport(y.VIEWPORT_KEY.VIEW_MAIN);if(A!==Number.POSITIVE_INFINITY&&W!=null){const De=W.transScroll2ViewportScrollValue(A,0).x;W.scrollTo({x:De})}return this}_commandExecutedListener(){const t=[b.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{t.includes(e.id)&&this._handleOpenZenEditor()}));const i=[y.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const r=e.params,{unitId:o}=r;if(o===f){const s=this._univerInstanceService.getUniverDocInstance(o),a=s==null?void 0:s.getBody(),l=a==null?void 0:a.dataStream,u=a==null?void 0:a.paragraphs,v=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,v)}}}))}_getDocObject(){return y.getDocObject(this._univerInstanceService,this._renderManagerService)}};M=ie([c.OnLifecycle(c.LifecycleStages.Steady,M),g(0,h.Inject(h.Injector)),g(1,c.IUniverInstanceService),g(2,B),g(3,T.IRenderManagerService),g(4,c.ICommandService),g(5,_.IZenZoneService),g(6,R.IEditorBridgeService),g(7,c.IUndoRedoService),g(8,h.Inject(y.TextSelectionManagerService))],M);const x={id:"zen-editor.command.cancel-zen-edit",type:c.CommandType.COMMAND,handler:async n=>{const t=n.get(_.IZenZoneService),i=n.get(R.IEditorBridgeService),e=n.get(c.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:T.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC}),t.close();const o=e.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return o?(e.focusUnit(o.getUnitId()),i.refreshEditCellState(),!0):!1}},U={id:"zen-editor.command.confirm-zen-edit",type:c.CommandType.COMMAND,handler:async n=>{const t=n.get(_.IZenZoneService),i=n.get(R.IEditorBridgeService),e=n.get(c.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:T.DeviceInputEventType.PointerDown}),t.close();const o=e.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return o?(e.focusUnit(o.getUnitId()),i.refreshEditCellState(),!0):!1}};function re(n){return{id:b.id,group:_.MenuGroup.CONTEXT_MENU_OTHERS,type:_.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[_.MenuPosition.CONTEXT_MENU],disabled$:R.getCurrentRangeDisable$(n,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission,N.WorksheetSetCellValuePermission,N.WorksheetSetCellStylePermission],rangeTypes:[N.RangeProtectionPermissionEditPoint]})}}var H={exports:{}},P={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var se=p,oe=Symbol.for("react.element"),ce=Symbol.for("react.fragment"),ae=Object.prototype.hasOwnProperty,de=se.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,le={key:!0,ref:!0,__self:!0,__source:!0};function X(n,t,i){var e,r={},o=null,s=null;i!==void 0&&(o=""+i),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(s=t.ref);for(e in t)ae.call(t,e)&&!le.hasOwnProperty(e)&&(r[e]=t[e]);if(n&&n.defaultProps)for(e in t=n.defaultProps,t)r[e]===void 0&&(r[e]=t[e]);return{$$typeof:oe,type:n,key:o,ref:s,props:r,_owner:de.current}}x.Fragment=ce,x.jsx=X,x.jsxs=X,H.exports=x;var m=H.exports,S=function(){return S=Object.assign||function(n){for(var t,i=1,e=arguments.length;i<e;i++){t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},S.apply(this,arguments)},ue=function(n,t){var i={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.indexOf(e)<0&&(i[e]=n[e]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(n);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(n,e[r])&&(i[e[r]]=n[e[r]]);return i},k=p.forwardRef(function(n,t){var i=n.icon,e=n.id,r=n.className,o=n.extend,s=ue(n,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),l=p.useRef("_".concat(_e()));return $(i,"".concat(e),{defIds:i.defIds,idSuffix:l.current},S({ref:t,className:a},s),o)});function $(n,t,i,e,r){return p.createElement(n.tag,S(S({key:t},ve(n,i,r)),e),(he(n,i).children||[]).map(function(o,s){return $(o,"".concat(t,"-").concat(n.tag,"-").concat(s),i,void 0,r)}))}function ve(n,t,i){var e=S({},n.attrs);i!=null&&i.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=i.colorChannel1);var r=t.defIds;return!r||r.length===0||(n.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var s=o[0],a=o[1];typeof a=="string"&&(e[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function he(n,t){var i,e=t.defIds;return!e||e.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?S(S({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?S(S({},r),{attrs:S(S({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):n}function _e(){return Math.random().toString(36).substring(2,8)}k.displayName="UniverIcon";var fe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},G=p.forwardRef(function(n,t){return p.createElement(k,Object.assign({},n,{id:"check-mark-single",ref:t,icon:fe}))});G.displayName="CheckMarkSingle";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"}}]},q=p.forwardRef(function(n,t){return p.createElement(k,Object.assign({},n,{id:"close-single",ref:t,icon:Se}))});q.displayName="CloseSingle";const C={zenEditor:"univer-zen-editor",zenEditorIconWrapper:"univer-zen-editor-icon-wrapper",zenEditorIconContainer:"univer-zen-editor-icon-container",zenEditorIconSuccess:"univer-zen-editor-icon-success",zenEditorIconError:"univer-zen-editor-icon-error",zenEditorCanvasContainer:"univer-zen-editor-canvas-container"},pe="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT";function ge(){const n=p.useRef(null),t=Z.useDependency(T.IRenderManagerService),i=Z.useDependency(A),e=Z.useDependency(c.ICommandService);p.useEffect(()=>{const s=n.current;if(!s)return;const a=t.currentRender$.subscribe(u=>{var I;if(u!==f)return;const v=(I=t.getRenderById(f))==null?void 0:I.engine;v==null||v.setContainer(s)}),l=new ResizeObserver(()=>{const u=s.getBoundingClientRect();i.setPosition(u)});return l.observe(s),()=>{l.unobserve(s),a.unsubscribe()}},[]);function r(){e.executeCommand(V.id)}function o(){e.executeCommand(B.id)}return m.jsxs("div",{className:C.zenEditor,children:[m.jsxs("div",{className:C.zenEditorIconWrapper,children:[m.jsx("span",{className:K(C.zenEditorIconContainer,C.zenEditorIconError),onClick:r,children:m.jsx(q,{style:{fontSize:"22px"}})}),m.jsx("span",{className:K(C.zenEditorIconContainer,C.zenEditorIconSuccess),onClick:o,children:m.jsx(G,{style:{fontSize:"22px"}})})]}),m.jsx("div",{className:C.zenEditorCanvasContainer,ref:n})]})}const Ie={id:B.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:n=>J(n),binding:_.KeyCode.ENTER|_.MetaKeys.ALT},Ee={id:V.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:n=>J(n),binding:_.KeyCode.ESC};function J(n){return n.getContextValue(c.FOCUSING_DOC)&&n.getContextValue(c.FOCUSING_UNIVER_EDITOR)&&n.getContextValue(c.EDITOR_ACTIVATED)&&!n.getContextValue(c.FOCUSING_EDITOR_STANDALONE)}var me=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,Oe=(n,t,i,e)=>{for(var r=e>1?void 0:e?Ce(t,i):t,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=(e?s(t,i,r):s(r))||r);return e&&r&&me(t,i,r),r},z=(n,t)=>(i,e)=>t(i,e,n);const ye={};let j=class extends c.Disposable{constructor(n,t,i,e,r,o){super(),this._config=n,this._injector=t,this._zenZoneService=i,this._commandService=e,this._menuService=r,this._shortcutService=o,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(pe,ge))}_initCommands(){[L,V,B].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initMenus(){const{menu:n={}}=this._config;[re].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t),n))})}_initShortcuts(){[Ie,Ee].forEach(n=>{this.disposeWithMe(this._shortcutService.registerShortcut(n))})}};j=Oe([c.OnLifecycle(c.LifecycleStages.Rendered,j),z(1,h.Inject(h.Injector)),z(2,_.IZenZoneService),z(3,c.ICommandService),z(4,_.IMenuService),z(5,_.IShortcutService)],j);var Te=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,Ne=(n,t,i,e)=>{for(var r=e>1?void 0:e?Re(t,i):t,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=(e?s(t,i,r):s(r))||r);return e&&r&&Te(t,i,r),r},Q=(n,t)=>(i,e)=>t(i,e,n);d.UniverSheetsZenEditorPlugin=(M=class extends c.Plugin{constructor(t={},i,e){super(),this._config=t,this._injector=i,this._localeService=e,this._initializeDependencies(this._injector),this._config=c.Tools.deepMerge({},ye,this._config)}_initializeDependencies(t){[[j,{useFactory:()=>this._injector.createInstance(j,this._config)}],[b],[A,{useClass:ee}]].forEach(e=>t.add(e))}},O(M,"pluginName","zen-editor"),O(M,"type",c.UniverInstanceType.UNIVER_DOC),M),d.UniverSheetsZenEditorPlugin=Ne([Q(1,h.Inject(h.Injector)),Q(2,h.Inject(c.LocaleService))],d.UniverSheetsZenEditorPlugin),Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
9
+ */var se=p,oe=Symbol.for("react.element"),ce=Symbol.for("react.fragment"),ae=Object.prototype.hasOwnProperty,de=se.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,le={key:!0,ref:!0,__self:!0,__source:!0};function X(n,t,i){var e,r={},o=null,s=null;i!==void 0&&(o=""+i),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(s=t.ref);for(e in t)ae.call(t,e)&&!le.hasOwnProperty(e)&&(r[e]=t[e]);if(n&&n.defaultProps)for(e in t=n.defaultProps,t)r[e]===void 0&&(r[e]=t[e]);return{$$typeof:oe,type:n,key:o,ref:s,props:r,_owner:de.current}}P.Fragment=ce,P.jsx=X,P.jsxs=X,H.exports=P;var m=H.exports,S=function(){return S=Object.assign||function(n){for(var t,i=1,e=arguments.length;i<e;i++){t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},S.apply(this,arguments)},ue=function(n,t){var i={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.indexOf(e)<0&&(i[e]=n[e]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(n);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(n,e[r])&&(i[e[r]]=n[e[r]]);return i},k=p.forwardRef(function(n,t){var i=n.icon,e=n.id,r=n.className,o=n.extend,s=ue(n,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),l=p.useRef("_".concat(_e()));return $(i,"".concat(e),{defIds:i.defIds,idSuffix:l.current},S({ref:t,className:a},s),o)});function $(n,t,i,e,r){return p.createElement(n.tag,S(S({key:t},ve(n,i,r)),e),(he(n,i).children||[]).map(function(o,s){return $(o,"".concat(t,"-").concat(n.tag,"-").concat(s),i,void 0,r)}))}function ve(n,t,i){var e=S({},n.attrs);i!=null&&i.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=i.colorChannel1);var r=t.defIds;return!r||r.length===0||(n.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var s=o[0],a=o[1];typeof a=="string"&&(e[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function he(n,t){var i,e=t.defIds;return!e||e.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?S(S({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?S(S({},r),{attrs:S(S({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):n}function _e(){return Math.random().toString(36).substring(2,8)}k.displayName="UniverIcon";var fe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},G=p.forwardRef(function(n,t){return p.createElement(k,Object.assign({},n,{id:"check-mark-single",ref:t,icon:fe}))});G.displayName="CheckMarkSingle";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"}}]},q=p.forwardRef(function(n,t){return p.createElement(k,Object.assign({},n,{id:"close-single",ref:t,icon:Se}))});q.displayName="CloseSingle";const C={zenEditor:"univer-zen-editor",zenEditorIconWrapper:"univer-zen-editor-icon-wrapper",zenEditorIconContainer:"univer-zen-editor-icon-container",zenEditorIconSuccess:"univer-zen-editor-icon-success",zenEditorIconError:"univer-zen-editor-icon-error",zenEditorCanvasContainer:"univer-zen-editor-canvas-container"},pe="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT";function ge(){const n=p.useRef(null),t=V.useDependency(T.IRenderManagerService),i=V.useDependency(B),e=V.useDependency(c.ICommandService);p.useEffect(()=>{const s=n.current;if(!s)return;const a=t.currentRender$.subscribe(u=>{var E;if(u!==f)return;const v=(E=t.getRenderById(f))==null?void 0:E.engine;v==null||v.setContainer(s)}),l=new ResizeObserver(()=>{const u=s.getBoundingClientRect();i.setPosition(u)});return l.observe(s),()=>{l.unobserve(s),a.unsubscribe()}},[]);function r(){e.executeCommand(x.id)}function o(){e.executeCommand(U.id)}return m.jsxs("div",{className:C.zenEditor,children:[m.jsxs("div",{className:C.zenEditorIconWrapper,children:[m.jsx("span",{className:K(C.zenEditorIconContainer,C.zenEditorIconError),onClick:r,children:m.jsx(q,{style:{fontSize:"22px"}})}),m.jsx("span",{className:K(C.zenEditorIconContainer,C.zenEditorIconSuccess),onClick:o,children:m.jsx(G,{style:{fontSize:"22px"}})})]}),m.jsx("div",{className:C.zenEditorCanvasContainer,ref:n})]})}const Ee={id:U.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:n=>J(n),binding:_.KeyCode.ENTER|_.MetaKeys.ALT},Ie={id:x.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:n=>J(n),binding:_.KeyCode.ESC};function J(n){return n.getContextValue(c.FOCUSING_DOC)&&n.getContextValue(c.FOCUSING_UNIVER_EDITOR)&&n.getContextValue(c.EDITOR_ACTIVATED)&&!n.getContextValue(c.FOCUSING_EDITOR_STANDALONE)}var me=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,Oe=(n,t,i,e)=>{for(var r=e>1?void 0:e?Ce(t,i):t,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=(e?s(t,i,r):s(r))||r);return e&&r&&me(t,i,r),r},z=(n,t)=>(i,e)=>t(i,e,n);const ye={};let D=class extends c.Disposable{constructor(n,t,i,e,r,o){super(),this._config=n,this._injector=t,this._zenZoneService=i,this._commandService=e,this._menuService=r,this._shortcutService=o,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(pe,ge))}_initCommands(){[b,x,U].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initMenus(){const{menu:n={}}=this._config;[re].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t),n))})}_initShortcuts(){[Ee,Ie].forEach(n=>{this.disposeWithMe(this._shortcutService.registerShortcut(n))})}};D=Oe([c.OnLifecycle(c.LifecycleStages.Rendered,D),z(1,h.Inject(h.Injector)),z(2,_.IZenZoneService),z(3,c.ICommandService),z(4,_.IMenuService),z(5,_.IShortcutService)],D);var Te=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,Ne=(n,t,i,e)=>{for(var r=e>1?void 0:e?Re(t,i):t,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=(e?s(t,i,r):s(r))||r);return e&&r&&Te(t,i,r),r},Q=(n,t)=>(i,e)=>t(i,e,n);d.UniverSheetsZenEditorPlugin=(Z=class extends c.Plugin{constructor(t={},i,e){super(),this._config=t,this._injector=i,this._localeService=e,this._initializeDependencies(this._injector),this._config=c.Tools.deepMerge({},ye,this._config)}_initializeDependencies(t){[[D,{useFactory:()=>this._injector.createInstance(D,this._config)}],[M],[B,{useClass:ee}]].forEach(e=>t.add(e))}},O(Z,"pluginName","zen-editor"),O(Z,"type",c.UniverInstanceType.UNIVER_DOC),Z),d.UniverSheetsZenEditorPlugin=Ne([Q(1,h.Inject(h.Injector)),Q(2,h.Inject(c.LocaleService))],d.UniverSheetsZenEditorPlugin),d.CancelZenEditCommand=x,d.ConfirmZenEditCommand=U,d.OpenZenEditorOperation=b,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.17",
3
+ "version": "0.2.1",
4
4
  "private": false,
5
5
  "description": "Zen Editor plugin for Univer Sheets.",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -50,38 +50,38 @@
50
50
  "lib"
51
51
  ],
52
52
  "peerDependencies": {
53
- "@wendellhu/redi": "0.15.4",
53
+ "@wendellhu/redi": "0.15.5",
54
54
  "clsx": ">=2.0.0",
55
55
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
56
56
  "rxjs": ">=7.0.0",
57
- "@univerjs/core": "0.1.17",
58
- "@univerjs/engine-render": "0.1.17",
59
- "@univerjs/docs": "0.1.17",
60
- "@univerjs/sheets-ui": "0.1.17",
61
- "@univerjs/sheets": "0.1.17",
62
- "@univerjs/ui": "0.1.17"
57
+ "@univerjs/core": "0.2.1",
58
+ "@univerjs/docs": "0.2.1",
59
+ "@univerjs/engine-render": "0.2.1",
60
+ "@univerjs/sheets-ui": "0.2.1",
61
+ "@univerjs/ui": "0.2.1",
62
+ "@univerjs/sheets": "0.2.1"
63
63
  },
64
64
  "dependencies": {
65
- "@univerjs/icons": "^0.1.57",
66
- "@univerjs/sheets": "0.1.17"
65
+ "@univerjs/icons": "^0.1.58",
66
+ "@univerjs/sheets": "0.2.1"
67
67
  },
68
68
  "devDependencies": {
69
- "@wendellhu/redi": "0.15.4",
69
+ "@wendellhu/redi": "0.15.5",
70
70
  "clsx": "^2.1.1",
71
71
  "less": "^4.2.0",
72
72
  "react": "18.3.1",
73
73
  "rxjs": "^7.8.1",
74
- "typescript": "^5.4.5",
75
- "vite": "^5.3.1",
74
+ "typescript": "^5.5.3",
75
+ "vite": "^5.3.3",
76
76
  "vitest": "^1.6.0",
77
- "@univerjs/design": "0.1.17",
78
- "@univerjs/docs": "0.1.17",
79
- "@univerjs/engine-render": "0.1.17",
80
- "@univerjs/shared": "0.1.17",
81
- "@univerjs/sheets-ui": "0.1.17",
82
- "@univerjs/sheets": "0.1.17",
83
- "@univerjs/ui": "0.1.17",
84
- "@univerjs/core": "0.1.17"
77
+ "@univerjs/core": "0.2.1",
78
+ "@univerjs/design": "0.2.1",
79
+ "@univerjs/engine-render": "0.2.1",
80
+ "@univerjs/docs": "0.2.1",
81
+ "@univerjs/shared": "0.2.1",
82
+ "@univerjs/sheets": "0.2.1",
83
+ "@univerjs/sheets-ui": "0.2.1",
84
+ "@univerjs/ui": "0.2.1"
85
85
  },
86
86
  "univerSpace": {
87
87
  ".": {