@univerjs/sheets-zen-editor 0.6.10 → 0.7.0-beta.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 +1,10 @@
1
- "use strict";var H=Object.defineProperty;var G=(e,t,i)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var O=(e,t,i)=>G(e,typeof t!="symbol"?t+"":t,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),N=require("@univerjs/docs-ui"),$=require("@univerjs/engine-render"),I=require("@univerjs/sheets-ui"),d=require("@univerjs/ui"),v=require("react/jsx-runtime"),B=require("@univerjs/design"),E=require("react"),R=require("rxjs"),T=require("@univerjs/sheets"),Z={id:"zen-editor.command.open-zen-editor",type:c.CommandType.COMMAND,handler:async e=>{var D;const t=e.get(d.IZenZoneService),i=e.get(N.IEditorService),n=e.get(I.IEditorBridgeService),r=e.get(c.IUniverInstanceService),s=e.get(d.ISidebarService);s.visible&&(s.close(),await c.delayAnimationFrame()),t.open();const o=i.getEditor(c.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(o==null)return!1;const a=n.getLatestEditCellState();if(a==null)return!1;const l=(D=a.documentLayoutObject.documentModel)==null?void 0:D.getSnapshot();if(l==null)return!1;r.focusUnit(c.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const{body:f,drawings:m,drawingsOrder:g,tableSource:_,settings:C}=c.Tools.deepClone(l),p={...o.getDocumentData(),body:f,drawings:m,drawingsOrder:g,tableSource:_,settings:C},h=[{startOffset:0,endOffset:0,collapsed:!0}];return o.focus(),o.setDocumentData(p,h),o.clearUndoRedoHistory(),!0}},x={id:"zen-editor.command.cancel-zen-edit",type:c.CommandType.COMMAND,handler:async e=>{const t=e.get(d.IZenZoneService),i=e.get(I.IEditorBridgeService),n=e.get(c.IUniverInstanceService),r=e.get(d.ISidebarService);r.visible&&(r.close(),await c.delayAnimationFrame()),t.close();const s=n.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return s?(n.focusUnit(s.getUnitId()),i.refreshEditCellState(),!0):!1}},P={id:"zen-editor.command.confirm-zen-edit",type:c.CommandType.COMMAND,handler:async e=>{var f;const t=e.get(d.IZenZoneService),i=e.get(I.IEditorBridgeService),n=e.get(c.IUniverInstanceService),r=e.get(N.IEditorService),s=e.get(d.ISidebarService);s.visible&&(s.close(),await c.delayAnimationFrame()),t.close();const o=r.getEditor(c.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(o==null)return!1;const a=e.get($.IRenderManagerService),l=n.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(l){const m=l.getUnitId(),g=(f=a.getRenderById(m))==null?void 0:f.with(I.EditingRenderController);if(g){const _=c.Tools.deepClone(o.getDocumentData());_.documentStyle.documentFlavor=c.DocumentFlavor.UNSPECIFIED,g.submitCellData(new c.DocumentDataModel(_))}return n.focusUnit(l.getUnitId()),i.refreshEditCellState(),!0}return!1}},X="sheets-zen-editor.config",A={};var u=function(){return u=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},u.apply(this,arguments)},J=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(i[n[r]]=e[n[r]]);return i},j=E.forwardRef(function(e,t){var i=e.icon,n=e.id,r=e.className,s=e.extend,o=J(e,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),l=E.useRef("_".concat(te()));return V(i,"".concat(n),{defIds:i.defIds,idSuffix:l.current},u({ref:t,className:a},o),s)});function V(e,t,i,n,r){return E.createElement(e.tag,u(u({key:t},Q(e,i,r)),n),(ee(e,i).children||[]).map(function(s,o){return V(s,"".concat(t,"-").concat(e.tag,"-").concat(o),i,void 0,r)}))}function Q(e,t,i){var n=u({},e.attrs);i!=null&&i.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=i.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(s){var o=s[0],a=s[1];o==="mask"&&typeof a=="string"&&(n[o]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var r=t.defIds;return!r||r.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var o=s[0],a=s[1];typeof a=="string"&&(n[o]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function ee(e,t){var i,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((i=e.children)===null||i===void 0)&&i.length)?u(u({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?u(u({},r),{attrs:u(u({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function te(){return Math.random().toString(36).substring(2,8)}j.displayName="UniverIcon";var ne={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"}}]},Y=E.forwardRef(function(e,t){return E.createElement(j,Object.assign({},e,{id:"check-mark-single",ref:t,icon:ne}))});Y.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"}}]},W=E.forwardRef(function(e,t){return E.createElement(j,Object.assign({},e,{id:"close-single",ref:t,icon:ie}))});W.displayName="CloseSingle";class re{constructor(){O(this,"_position",null);O(this,"_position$",new R.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 k=c.createIdentifier("univer.sheet-zen-editor-manager.service"),oe="univer-zen-editor",se="univer-zen-editor-icon-wrapper",ce="univer-zen-editor-icon-container",ae="univer-zen-editor-icon-success",de="univer-zen-editor-icon-error",le="univer-zen-editor-canvas-container",S={zenEditor:oe,zenEditorIconWrapper:se,zenEditorIconContainer:ce,zenEditorIconSuccess:ae,zenEditorIconError:de,zenEditorCanvasContainer:le},ue="ZEN_EDITOR_PLUGIN_",ge=`${ue}ZEN_EDITOR_COMPONENT`,fe={id:c.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${c.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],tables:[],customBlocks:[],paragraphs:[{startIndex:0}],sectionBreaks:[{startIndex:1}]},tableSource:{},documentStyle:{pageSize:{width:595,height:Number.POSITIVE_INFINITY},documentFlavor:c.DocumentFlavor.MODERN,marginTop:0,marginBottom:0,marginRight:0,marginLeft:0,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};function Ee(){const e=E.useRef(null),t=d.useDependency(k),i=d.useDependency(N.IEditorService),n=d.useDependency(c.ICommandService);E.useEffect(()=>{const o=e.current;if(!o)return;const a=i.register({editorUnitId:c.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:fe,scrollBar:!0,backScrollOffset:100},o),l=new ResizeObserver(()=>{t.setPosition(o.getBoundingClientRect())});return l.observe(o),()=>{a.dispose(),l.unobserve(o)}},[]);function r(){const o=i.getEditor(c.DOCS_ZEN_EDITOR_UNIT_ID_KEY);o==null||o.blur(),n.executeCommand(x.id)}function s(){const o=i.getEditor(c.DOCS_ZEN_EDITOR_UNIT_ID_KEY);o==null||o.blur(),n.executeCommand(P.id)}return v.jsxs("div",{className:S.zenEditor,children:[v.jsxs("div",{className:S.zenEditorIconWrapper,children:[v.jsx("span",{className:B.clsx(S.zenEditorIconContainer,S.zenEditorIconError),onClick:r,children:v.jsx(W,{style:{fontSize:"22px"}})}),v.jsx("span",{className:B.clsx(S.zenEditorIconContainer,S.zenEditorIconSuccess),onClick:s,children:v.jsx(Y,{style:{fontSize:"22px"}})})]}),v.jsx("div",{className:S.zenEditorCanvasContainer,ref:e})]})}function Ie(e){const t=e.get(I.IEditorBridgeService);return{id:Z.id,type:d.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",hidden$:I.getCurrentExclusiveRangeInterest$(e),disabled$:t.currentEditCell$.pipe(R.switchMap(i=>I.getCurrentRangeDisable$(e,{workbookTypes:[T.WorkbookEditablePermission],worksheetTypes:[T.WorksheetEditPermission,T.WorksheetSetCellValuePermission,T.WorksheetSetCellStylePermission],rangeTypes:[T.RangeProtectionPermissionEditPoint]}).pipe(R.map(n=>{var r,s,o,a;return n||((a=(o=(s=(r=i==null?void 0:i.documentLayoutObject.documentModel)==null?void 0:r.getBody())==null?void 0:s.customBlocks)==null?void 0:o.length)!=null?a:0)>0}))))}}const _e={[d.ContextMenuPosition.MAIN_AREA]:{[d.ContextMenuGroup.OTHERS]:{[Z.id]:{order:2,menuItemFactory:Ie}}}},he={id:P.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:e=>K(e),binding:d.KeyCode.ENTER|d.MetaKeys.ALT},ve={id:x.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:e=>K(e),binding:d.KeyCode.ESC};function K(e){return e.getContextValue(c.FOCUSING_DOC)&&e.getContextValue(c.FOCUSING_UNIVER_EDITOR)&&e.getContextValue(c.EDITOR_ACTIVATED)&&!e.getContextValue(c.FOCUSING_EDITOR_STANDALONE)}var Se=Object.getOwnPropertyDescriptor,me=(e,t,i,n)=>{for(var r=n>1?void 0:n?Se(t,i):t,s=e.length-1,o;s>=0;s--)(o=e[s])&&(r=o(r)||r);return r},b=(e,t)=>(i,n)=>t(i,n,e);let M=class extends c.Disposable{constructor(e,t,i,n){super(),this._zenZoneService=e,this._commandService=t,this._menuManagerService=i,this._shortcutService=n,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(ge,Ee))}_initCommands(){[Z,x,P].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(_e)}_initShortcuts(){[he,ve].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}};M=me([b(0,d.IZenZoneService),b(1,c.ICommandService),b(2,d.IMenuManagerService),b(3,d.IShortcutService)],M);var Ce=Object.getOwnPropertyDescriptor,pe=(e,t,i,n)=>{for(var r=n>1?void 0:n?Ce(t,i):t,s=e.length-1,o;s>=0;s--)(o=e[s])&&(r=o(r)||r);return r},L=(e,t)=>(i,n)=>t(i,n,e);let U=class extends c.RxDisposable{constructor(e,t){super(),this._zenEditorManagerService=e,this._renderManagerService=t,this._initialize()}_initialize(){this._syncZenEditorSize()}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(R.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{width:t,height:i}=e,n=I.getEditorObject(c.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService);n!=null&&requestIdleCallback(()=>{n.engine.resizeBySize(t,i),this._calculatePagePosition(n),this._scrollToTop()})})}_calculatePagePosition(e){const{document:t,scene:i,docBackground:n}=e,r=i==null?void 0:i.getParent(),{width:s,height:o,pageMarginLeft:a,pageMarginTop:l}=t;if(r==null||s===Number.POSITIVE_INFINITY||o===Number.POSITIVE_INFINITY)return;const{width:f,height:m}=r;let g=0;const _=l;let C=0,y=0,p=Number.POSITIVE_INFINITY;const{scaleX:h,scaleY:D}=i.getAncestorScale();f>(s+a*2)*h?(g=f/2-s*h/2,g/=h,C=(f-a*2)/h,p=0):(g=a,C=s+a*2,p=(C-f/h)/2),m>o?y=(m-l*2)/D:y=o+l*2,i.resize(C,y),t.translate(g,_),n.translate(g,_);const w=i.getViewport(N.VIEWPORT_KEY.VIEW_MAIN);if(p!==Number.POSITIVE_INFINITY&&w!=null){const q=w.transScroll2ViewportScrollValue(p,0).x;w.scrollToBarPos({x:q})}return this}_scrollToTop(){var i;const e=(i=this._renderManagerService.getRenderById(c.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:i.with(N.DocBackScrollRenderController),t={startOffset:0,endOffset:0};e&&e.scrollToRange(t)}};U=pe([L(0,k),L(1,$.IRenderManagerService)],U);var Oe=Object.getOwnPropertyDescriptor,Te=(e,t,i,n)=>{for(var r=n>1?void 0:n?Oe(t,i):t,s=e.length-1,o;s>=0;s--)(o=e[s])&&(r=o(r)||r);return r},F=(e,t)=>(i,n)=>t(i,n,e),z;exports.UniverSheetsZenEditorPlugin=(z=class extends c.Plugin{constructor(t=A,i,n){super(),this._config=t,this._injector=i,this._configService=n;const{menu:r,...s}=c.merge({},A,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(X,s),this._initializeDependencies(this._injector)}_initializeDependencies(t){[[M],[U],[k,{useClass:re}]].forEach(n=>t.add(n))}onReady(){this._injector.get(M)}onSteady(){this._injector.get(U)}},O(z,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),O(z,"type",c.UniverInstanceType.UNIVER_SHEET),z);exports.UniverSheetsZenEditorPlugin=Te([F(1,c.Inject(c.Injector)),F(2,c.IConfigService)],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=x;exports.ConfirmZenEditCommand=P;exports.OpenZenEditorCommand=Z;
1
+ "use strict";var q=Object.defineProperty;var H=(e,t,i)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var p=(e,t,i)=>H(e,typeof t!="symbol"?t+"":t,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),N=require("@univerjs/docs-ui"),F=require("@univerjs/engine-render"),h=require("@univerjs/sheets-ui"),d=require("@univerjs/ui"),S=require("react/jsx-runtime"),k=require("@univerjs/design"),v=require("react"),R=require("rxjs"),O=require("@univerjs/sheets"),U={id:"zen-editor.command.open-zen-editor",type:s.CommandType.COMMAND,handler:async e=>{var y;const t=e.get(d.IZenZoneService),i=e.get(N.IEditorService),n=e.get(h.IEditorBridgeService),r=e.get(s.IUniverInstanceService),o=e.get(d.ISidebarService);o.visible&&(o.close(),await s.delayAnimationFrame()),t.open();const c=i.getEditor(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(c==null)return!1;const a=n.getLatestEditCellState();if(a==null)return!1;const l=(y=a.documentLayoutObject.documentModel)==null?void 0:y.getSnapshot();if(l==null)return!1;r.focusUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const{body:u,drawings:I,drawingsOrder:f,tableSource:_,settings:E}=s.Tools.deepClone(l),C={...c.getDocumentData(),body:u,drawings:I,drawingsOrder:f,tableSource:_,settings:E},m=[{startOffset:0,endOffset:0,collapsed:!0}];return c.focus(),c.setDocumentData(C,m),c.clearUndoRedoHistory(),!0}},Z={id:"zen-editor.command.cancel-zen-edit",type:s.CommandType.COMMAND,handler:async e=>{const t=e.get(d.IZenZoneService),i=e.get(h.IEditorBridgeService),n=e.get(s.IUniverInstanceService),r=e.get(d.ISidebarService);r.visible&&(r.close(),await s.delayAnimationFrame()),t.close();const o=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);return o?(n.focusUnit(o.getUnitId()),i.refreshEditCellState(),!0):!1}},P={id:"zen-editor.command.confirm-zen-edit",type:s.CommandType.COMMAND,handler:async e=>{var u;const t=e.get(d.IZenZoneService),i=e.get(h.IEditorBridgeService),n=e.get(s.IUniverInstanceService),r=e.get(N.IEditorService),o=e.get(d.ISidebarService);o.visible&&(o.close(),await s.delayAnimationFrame()),t.close();const c=r.getEditor(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(c==null)return!1;const a=e.get(F.IRenderManagerService),l=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(l){const I=l.getUnitId(),f=(u=a.getRenderById(I))==null?void 0:u.with(h.EditingRenderController);if(f){const _=s.Tools.deepClone(c.getDocumentData());_.documentStyle.documentFlavor=s.DocumentFlavor.UNSPECIFIED,f.submitCellData(new s.DocumentDataModel(_))}return n.focusUnit(l.getUnitId()),i.refreshEditCellState(),!0}return!1}},G="sheets-zen-editor.config",B={};var g=function(){return g=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},g.apply(this,arguments)},X=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(i[n[r]]=e[n[r]]);return i},j=v.forwardRef(function(e,t){var i=e.icon,n=e.id,r=e.className,o=e.extend,c=X(e,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),l=v.useRef("_".concat(ee()));return $(i,"".concat(n),{defIds:i.defIds,idSuffix:l.current},g({ref:t,className:a},c),o)});function $(e,t,i,n,r){return v.createElement(e.tag,g(g({key:t},J(e,i,r)),n),(Q(e,i).children||[]).map(function(o,c){return $(o,"".concat(t,"-").concat(e.tag,"-").concat(c),i,void 0,r)}))}function J(e,t,i){var n=g({},e.attrs);i!=null&&i.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=i.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(o){var c=o[0],a=o[1];c==="mask"&&typeof a=="string"&&(n[c]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var r=t.defIds;return!r||r.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(o){var c=o[0],a=o[1];typeof a=="string"&&(n[c]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Q(e,t){var i,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((i=e.children)===null||i===void 0)&&i.length)?g(g({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?g(g({},r),{attrs:g(g({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function ee(){return Math.random().toString(36).substring(2,8)}j.displayName="UniverIcon";var te={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"}}]},V=v.forwardRef(function(e,t){return v.createElement(j,Object.assign({},e,{id:"check-mark-single",ref:t,icon:te}))});V.displayName="CheckMarkSingle";var ne={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"}}]},Y=v.forwardRef(function(e,t){return v.createElement(j,Object.assign({},e,{id:"close-single",ref:t,icon:ne}))});Y.displayName="CloseSingle";class ie{constructor(){p(this,"_position",null);p(this,"_position$",new R.BehaviorSubject(null));p(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=s.createIdentifier("univer.sheet-zen-editor-manager.service"),re="ZEN_EDITOR_PLUGIN_",oe=`${re}ZEN_EDITOR_COMPONENT`,se={id:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${s.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],tables:[],customBlocks:[],paragraphs:[{startIndex:0}],sectionBreaks:[{startIndex:1}]},tableSource:{},documentStyle:{pageSize:{width:595,height:Number.POSITIVE_INFINITY},documentFlavor:s.DocumentFlavor.MODERN,marginTop:0,marginBottom:0,marginRight:0,marginLeft:0,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};function ce(){const e=v.useRef(null),t=d.useDependency(z),i=d.useDependency(N.IEditorService),n=d.useDependency(s.ICommandService);v.useEffect(()=>{const a=e.current;if(!a)return;const l=i.register({editorUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:se,scrollBar:!0,backScrollOffset:100},a),u=new ResizeObserver(()=>{t.setPosition(a.getBoundingClientRect())});return u.observe(a),()=>{l.dispose(),u.unobserve(a)}},[]);function r(){const a=i.getEditor(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);a==null||a.blur(),n.executeCommand(Z.id)}function o(){const a=i.getEditor(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);a==null||a.blur(),n.executeCommand(P.id)}const c="univer-flex univer-w-7 univer-cursor-pointer univer-items-center univer-justify-center univer-transition-colors";return S.jsxs("div",{className:"univer-absolute univer-inset-0 univer-size-full univer-bg-white",children:[S.jsxs("div",{className:`
2
+ univer-absolute univer-right-6 univer-top-2 univer-z-10 univer-flex univer-items-center
3
+ univer-justify-center
4
+ `,children:[S.jsx("span",{className:k.clsx(c,`
5
+ univer-text-red-500
6
+ hover:univer-text-red-600
7
+ `),onClick:r,children:S.jsx(Y,{className:"univer-size-5"})}),S.jsx("span",{className:k.clsx(c,`
8
+ univer-text-green-500
9
+ hover:univer-text-green-600
10
+ `),onClick:o,children:S.jsx(V,{className:"univer-size-5"})})]}),S.jsx("div",{ref:e,className:"univer-absolute univer-inset-0 univer-size-full"})]})}function ae(e){const t=e.get(h.IEditorBridgeService);return{id:U.id,type:d.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",hidden$:h.getCurrentExclusiveRangeInterest$(e),disabled$:t.currentEditCell$.pipe(R.switchMap(i=>h.getCurrentRangeDisable$(e,{workbookTypes:[O.WorkbookEditablePermission],worksheetTypes:[O.WorksheetEditPermission,O.WorksheetSetCellValuePermission,O.WorksheetSetCellStylePermission],rangeTypes:[O.RangeProtectionPermissionEditPoint]}).pipe(R.map(n=>{var r,o,c,a;return n||((a=(c=(o=(r=i==null?void 0:i.documentLayoutObject.documentModel)==null?void 0:r.getBody())==null?void 0:o.customBlocks)==null?void 0:c.length)!=null?a:0)>0}))))}}const de={[d.ContextMenuPosition.MAIN_AREA]:{[d.ContextMenuGroup.OTHERS]:{[U.id]:{order:2,menuItemFactory:ae}}}},le={id:P.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:e=>K(e),binding:d.KeyCode.ENTER|d.MetaKeys.ALT},ue={id:Z.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:e=>K(e),binding:d.KeyCode.ESC};function K(e){return e.getContextValue(s.FOCUSING_DOC)&&e.getContextValue(s.FOCUSING_UNIVER_EDITOR)&&e.getContextValue(s.EDITOR_ACTIVATED)&&!e.getContextValue(s.FOCUSING_EDITOR_STANDALONE)}var ge=Object.getOwnPropertyDescriptor,fe=(e,t,i,n)=>{for(var r=n>1?void 0:n?ge(t,i):t,o=e.length-1,c;o>=0;o--)(c=e[o])&&(r=c(r)||r);return r},D=(e,t)=>(i,n)=>t(i,n,e);let M=class extends s.Disposable{constructor(e,t,i,n){super(),this._zenZoneService=e,this._commandService=t,this._menuManagerService=i,this._shortcutService=n,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(oe,ce))}_initCommands(){[U,Z,P].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(de)}_initShortcuts(){[le,ue].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}};M=fe([D(0,d.IZenZoneService),D(1,s.ICommandService),D(2,d.IMenuManagerService),D(3,d.IShortcutService)],M);var ve=Object.getOwnPropertyDescriptor,he=(e,t,i,n)=>{for(var r=n>1?void 0:n?ve(t,i):t,o=e.length-1,c;o>=0;o--)(c=e[o])&&(r=c(r)||r);return r},A=(e,t)=>(i,n)=>t(i,n,e);let x=class extends s.RxDisposable{constructor(e,t){super(),this._zenEditorManagerService=e,this._renderManagerService=t,this._initialize()}_initialize(){this._syncZenEditorSize()}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(R.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{width:t,height:i}=e,n=h.getEditorObject(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService);n!=null&&requestIdleCallback(()=>{n.engine.resizeBySize(t,i),this._calculatePagePosition(n),this._scrollToTop()})})}_calculatePagePosition(e){const{document:t,scene:i,docBackground:n}=e,r=i==null?void 0:i.getParent(),{width:o,height:c,pageMarginLeft:a,pageMarginTop:l}=t;if(r==null||o===Number.POSITIVE_INFINITY||c===Number.POSITIVE_INFINITY)return;const{width:u,height:I}=r;let f=0;const _=l;let E=0,T=0,C=Number.POSITIVE_INFINITY;const{scaleX:m,scaleY:y}=i.getAncestorScale();u>(o+a*2)*m?(f=u/2-o*m/2,f/=m,E=(u-a*2)/m,C=0):(f=a,E=o+a*2,C=(E-u/m)/2),I>c?T=(I-l*2)/y:T=c+l*2,i.resize(E,T),t.translate(f,_),n.translate(f,_);const w=i.getViewport(N.VIEWPORT_KEY.VIEW_MAIN);if(C!==Number.POSITIVE_INFINITY&&w!=null){const W=w.transScroll2ViewportScrollValue(C,0).x;w.scrollToBarPos({x:W})}return this}_scrollToTop(){var i;const e=(i=this._renderManagerService.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:i.with(N.DocBackScrollRenderController),t={startOffset:0,endOffset:0};e&&e.scrollToRange(t)}};x=he([A(0,z),A(1,F.IRenderManagerService)],x);var _e=Object.getOwnPropertyDescriptor,me=(e,t,i,n)=>{for(var r=n>1?void 0:n?_e(t,i):t,o=e.length-1,c;o>=0;o--)(c=e[o])&&(r=c(r)||r);return r},L=(e,t)=>(i,n)=>t(i,n,e),b;exports.UniverSheetsZenEditorPlugin=(b=class extends s.Plugin{constructor(t=B,i,n){super(),this._config=t,this._injector=i,this._configService=n;const{menu:r,...o}=s.merge({},B,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(G,o),this._initializeDependencies(this._injector)}_initializeDependencies(t){[[M],[x],[z,{useClass:ie}]].forEach(n=>t.add(n))}onReady(){this._injector.get(M)}onSteady(){this._injector.get(x)}},p(b,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),p(b,"type",s.UniverInstanceType.UNIVER_SHEET),b);exports.UniverSheetsZenEditorPlugin=me([L(1,s.Inject(s.Injector)),L(2,s.IConfigService)],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=Z;exports.ConfirmZenEditCommand=P;exports.OpenZenEditorCommand=U;