@univerjs/sheets-zen-editor 0.5.1 → 0.5.2-nightly.202412281605
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 +2 -2
- package/lib/es/index.js +125 -121
- package/lib/index.css +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +11 -11
- package/LICENSE +0 -176
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var ee=Object.defineProperty;var te=(e,n,r)=>n in e?ee(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var O=(e,n,r)=>te(e,typeof n!="symbol"?n+"":n,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),T=require("@univerjs/docs-ui"),W=require("@univerjs/engine-render"),p=require("@univerjs/sheets-ui"),f=require("@univerjs/ui"),h=require("react"),q=require("rxjs"),y=require("@univerjs/sheets"),M={id:"zen-editor.command.open-zen-editor",type:o.CommandType.COMMAND,handler:async e=>{var b;const n=e.get(f.IZenZoneService),r=e.get(T.IEditorService),t=e.get(p.IEditorBridgeService),i=e.get(o.IUniverInstanceService),c=e.get(f.ISidebarService);c.visible&&(c.close(),await o.delayAnimationFrame()),n.open();const s=r.getEditor(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(s==null)return!1;const d=t.getLatestEditCellState();if(d==null)return!1;const a=(b=d.documentLayoutObject.documentModel)==null?void 0:b.getSnapshot();if(a==null)return!1;i.focusUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const{body:g,drawings:l,drawingsOrder:u,tableSource:v,settings:m}=o.Tools.deepClone(a),C={...s.getDocumentData(),body:g,drawings:l,drawingsOrder:u,tableSource:v,settings:m},E=[{startOffset:0,endOffset:0,collapsed:!0}];return s.focus(),s.setDocumentData(C,E),s.clearUndoRedoHistory(),!0}},U={id:"zen-editor.command.cancel-zen-edit",type:o.CommandType.COMMAND,handler:async e=>{const n=e.get(f.IZenZoneService),r=e.get(p.IEditorBridgeService),t=e.get(o.IUniverInstanceService),i=e.get(f.ISidebarService);i.visible&&(i.close(),await o.delayAnimationFrame()),n.close();const c=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);return c?(t.focusUnit(c.getUnitId()),r.refreshEditCellState(),!0):!1}},Z={id:"zen-editor.command.confirm-zen-edit",type:o.CommandType.COMMAND,handler:async e=>{var g;const n=e.get(f.IZenZoneService),r=e.get(p.IEditorBridgeService),t=e.get(o.IUniverInstanceService),i=e.get(T.IEditorService),c=e.get(f.ISidebarService);c.visible&&(c.close(),await o.delayAnimationFrame()),n.close();const s=i.getEditor(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(s==null)return!1;const d=e.get(W.IRenderManagerService),a=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(a){const l=a.getUnitId(),u=(g=d.getRenderById(l))==null?void 0:g.with(p.EditingRenderController);if(u){const v=o.Tools.deepClone(s.getDocumentData());v.documentStyle.documentFlavor=o.DocumentFlavor.UNSPECIFIED,u.submitCellData(new o.DocumentDataModel(v))}return t.focusUnit(a.getUnitId()),r.refreshEditCellState(),!0}return!1}},ne="sheets-zen-editor.config",L={};var j={exports:{}},N={};/**
|
|
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 L;function re(){if(L)return N;L=1;var e=h,n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),t=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function s(d,a,g){var l,u={},v=null,m=null;g!==void 0&&(v=""+g),a.key!==void 0&&(v=""+a.key),a.ref!==void 0&&(m=a.ref);for(l in a)t.call(a,l)&&!c.hasOwnProperty(l)&&(u[l]=a[l]);if(d&&d.defaultProps)for(l in a=d.defaultProps,a)u[l]===void 0&&(u[l]=a[l]);return{$$typeof:n,type:d,key:v,ref:m,props:u,_owner:i.current}}return N.Fragment=r,N.jsx=s,N.jsxs=s,N}var $;function ie(){return $||($=1,j.exports=re()),j.exports}var I=ie(),_=function(){return _=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},_.apply(this,arguments)},oe=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,t=Object.getOwnPropertySymbols(e);i<t.length;i++)n.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(e,t[i])&&(r[t[i]]=e[t[i]]);return r},A=h.forwardRef(function(e,n){var r=e.icon,t=e.id,i=e.className,c=e.extend,s=oe(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(t," ").concat(i||"").trim(),a=h.useRef("_".concat(ae()));return q(r,"".concat(t),{defIds:r.defIds,idSuffix:a.current},_({ref:n,className:d},s),c)});function q(e,n,r,t,i){return h.createElement(e.tag,_(_({key:n},se(e,r,i)),t),(ce(e,r).children||[]).map(function(c,s){return q(c,"".concat(n,"-").concat(e.tag,"-").concat(s),r,void 0,i)}))}function se(e,n,r){var t=_({},e.attrs);r!=null&&r.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=r.colorChannel1);var i=n.defIds;return!i||i.length===0||(e.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(c){var s=c[0],d=c[1];typeof d=="string"&&(t[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function ce(e,n){var r,t=n.defIds;return!t||t.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?_(_({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&t&&t.indexOf(i.attrs.id)>-1?_(_({},i),{attrs:_(_({},i.attrs),{id:i.attrs.id+n.idSuffix})}):i})}):e}function ae(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var de={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},K=h.forwardRef(function(e,n){return h.createElement(A,Object.assign({},e,{id:"check-mark-single",ref:n,icon:de}))});K.displayName="CheckMarkSingle";var le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},H=h.forwardRef(function(e,n){return h.createElement(A,Object.assign({},e,{id:"close-single",ref:n,icon:le}))});H.displayName="CloseSingle";function G(e){var n,r,t="";if(typeof e=="string"||typeof e=="number")t+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(n=0;n<i;n++)e[n]&&(r=G(e[n]))&&(t&&(t+=" "),t+=r)}else for(r in e)e[r]&&(t&&(t+=" "),t+=r);return t}function F(){for(var e,n,r=0,t="",i=arguments.length;r<i;r++)(e=arguments[r])&&(n=G(e))&&(t&&(t+=" "),t+=n);return t}class ue{constructor(){O(this,"_position",null);O(this,"_position$",new W.BehaviorSubject(null));O(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(n){this._position=n,this._refresh(n)}getPosition(){return this._position}_refresh(n){this._position$.next(n)}}const B=o.createIdentifier("univer.sheet-zen-editor-manager.service"),fe="univer-zen-editor",ge="univer-zen-editor-icon-wrapper",_e="univer-zen-editor-icon-container",ve="univer-zen-editor-icon-success",he="univer-zen-editor-icon-error",me="univer-zen-editor-canvas-container",S={zenEditor:fe,zenEditorIconWrapper:ge,zenEditorIconContainer:_e,zenEditorIconSuccess:ve,zenEditorIconError:he,zenEditorCanvasContainer:me},Ee="ZEN_EDITOR_PLUGIN_",Ie=`${Ee}ZEN_EDITOR_COMPONENT`,Se={id:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],tables:[],customBlocks:[],paragraphs:[{startIndex:0}],sectionBreaks:[{startIndex:1}]},tableSource:{},documentStyle:{pageSize:{width:595,height:Number.POSITIVE_INFINITY},documentFlavor:o.DocumentFlavor.MODERN,marginTop:0,marginBottom:0,marginRight:0,marginLeft:0,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};function pe(){const e=h.useRef(null),n=o.useDependency(B),r=o.useDependency(T.IEditorService),t=o.useDependency(o.ICommandService);h.useEffect(()=>{const s=e.current;if(!s)return;const d=r.register({editorUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:Se,scrollBar:!0,noNeedVerticalAlign:!0,backScrollOffset:100},s),a=new ResizeObserver(()=>{n.setPosition(s.getBoundingClientRect())});return a.observe(s),()=>{d.dispose(),a.unobserve(s)}},[]);function i(){t.executeCommand(U.id)}function c(){t.executeCommand(Z.id)}return I.jsxs("div",{className:S.zenEditor,children:[I.jsxs("div",{className:S.zenEditorIconWrapper,children:[I.jsx("span",{className:F(S.zenEditorIconContainer,S.zenEditorIconError),onClick:i,children:I.jsx(H,{style:{fontSize:"22px"}})}),I.jsx("span",{className:F(S.zenEditorIconContainer,S.zenEditorIconSuccess),onClick:c,children:I.jsx(K,{style:{fontSize:"22px"}})})]}),I.jsx("div",{className:S.zenEditorCanvasContainer,ref:e})]})}function Ce(e){return{id:M.id,type:f.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",hidden$:p.getCurrentExclusiveRangeInterest$(e),disabled$:p.getCurrentRangeDisable$(e,{workbookTypes:[y.WorkbookEditablePermission],worksheetTypes:[y.WorksheetEditPermission,y.WorksheetSetCellValuePermission,y.WorksheetSetCellStylePermission],rangeTypes:[y.RangeProtectionPermissionEditPoint]})}}const Oe={[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[M.id]:{order:2,menuItemFactory:Ce}}}},ye={id:Z.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:e=>J(e),binding:f.KeyCode.ENTER|f.MetaKeys.ALT},Ne={id:U.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:e=>J(e),binding:f.KeyCode.ESC};function J(e){return e.getContextValue(o.FOCUSING_DOC)&&e.getContextValue(o.FOCUSING_UNIVER_EDITOR)&&e.getContextValue(o.EDITOR_ACTIVATED)&&!e.getContextValue(o.FOCUSING_EDITOR_STANDALONE)}var Te=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,be=(e,n,r,t)=>{for(var i=t>1?void 0:t?Re(n,r):n,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(t?s(n,r,i):s(i))||i);return t&&i&&Te(n,r,i),i},D=(e,n)=>(r,t)=>n(r,t,e);let P=class extends o.Disposable{constructor(e,n,r,t){super(),this._zenZoneService=e,this._commandService=n,this._menuManagerService=r,this._shortcutService=t,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(Ie,pe))}_initCommands(){[M,U,Z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Oe)}_initShortcuts(){[ye,Ne].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}};P=be([D(0,f.IZenZoneService),D(1,o.ICommandService),D(2,f.IMenuManagerService),D(3,f.IShortcutService)],P);var De=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,Pe=(e,n,r,t)=>{for(var i=t>1?void 0:t?ze(n,r):n,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(t?s(n,r,i):s(i))||i);return t&&i&&De(n,r,i),i},k=(e,n)=>(r,t)=>n(r,t,e);let x=class extends o.RxDisposable{constructor(e,n){super(),this._zenEditorManagerService=e,this._renderManagerService=n,this._initialize()}_initialize(){this._syncZenEditorSize()}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(W.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{width:n,height:r}=e,t=p.getEditorObject(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService);t!=null&&requestIdleCallback(()=>{t.engine.resizeBySize(n,r),this._calculatePagePosition(t),this._scrollToTop()})})}_calculatePagePosition(e){const{document:n,scene:r,docBackground:t}=e,i=r==null?void 0:r.getParent(),{width:c,height:s,pageMarginLeft:d,pageMarginTop:a}=n;if(i==null||c===Number.POSITIVE_INFINITY||s===Number.POSITIVE_INFINITY)return;const{width:g,height:l}=i;let u=0;const v=a;let m=0,R=0,C=Number.POSITIVE_INFINITY;const{scaleX:E,scaleY:b}=r.getAncestorScale();g>(c+d*2)*E?(u=g/2-c*E/2,u/=E,m=(g-d*2)/E,C=0):(u=d,m=c+d*2,C=(m-g/E)/2),l>s?R=(l-a*2)/b:R=s+a*2,r.resize(m,R),n.translate(u,v),t.translate(u,v);const w=r.getViewport(T.VIEWPORT_KEY.VIEW_MAIN);if(C!==Number.POSITIVE_INFINITY&&w!=null){const X=w.transScroll2ViewportScrollValue(C,0).x;w.scrollToBarPos({x:X})}return this}_scrollToTop(){var r;const e=(r=this._renderManagerService.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:r.with(T.DocBackScrollRenderController),n={startOffset:0,endOffset:0};e&&e.scrollToRange(n)}};x=Pe([k(0,B),k(1,Y.IRenderManagerService)],x);var xe=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,Ue=(e,n,r,t)=>{for(var i=t>1?void 0:t?Me(n,r):n,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(t?s(n,r,i):s(i))||i);return t&&i&&xe(n,r,i),i},V=(e,n)=>(r,t)=>n(r,t,e),z;exports.UniverSheetsZenEditorPlugin=(z=class extends o.Plugin{constructor(n=ne,r,t){super(),this._config=n,this._injector=r,this._configService=t;const{menu:i,...c}=this._config;i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(te,c),this._initializeDependencies(this._injector)}_initializeDependencies(n){[[P],[x],[B,{useClass:ue}]].forEach(t=>n.add(t))}onReady(){this._injector.get(P)}onSteady(){this._injector.get(x)}},O(z,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),O(z,"type",o.UniverInstanceType.UNIVER_SHEET),z);exports.UniverSheetsZenEditorPlugin=Ue([V(1,o.Inject(o.Injector)),V(2,o.IConfigService)],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=U;exports.ConfirmZenEditCommand=Z;exports.OpenZenEditorCommand=M;
|
|
9
|
+
*/var $;function re(){if($)return N;$=1;var e=h,n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),t=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function s(d,a,g){var l,u={},v=null,m=null;g!==void 0&&(v=""+g),a.key!==void 0&&(v=""+a.key),a.ref!==void 0&&(m=a.ref);for(l in a)t.call(a,l)&&!c.hasOwnProperty(l)&&(u[l]=a[l]);if(d&&d.defaultProps)for(l in a=d.defaultProps,a)u[l]===void 0&&(u[l]=a[l]);return{$$typeof:n,type:d,key:v,ref:m,props:u,_owner:i.current}}return N.Fragment=r,N.jsx=s,N.jsxs=s,N}var F;function ie(){return F||(F=1,j.exports=re()),j.exports}var I=ie(),_=function(){return _=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},_.apply(this,arguments)},oe=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,t=Object.getOwnPropertySymbols(e);i<t.length;i++)n.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(e,t[i])&&(r[t[i]]=e[t[i]]);return r},A=h.forwardRef(function(e,n){var r=e.icon,t=e.id,i=e.className,c=e.extend,s=oe(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(t," ").concat(i||"").trim(),a=h.useRef("_".concat(ae()));return K(r,"".concat(t),{defIds:r.defIds,idSuffix:a.current},_({ref:n,className:d},s),c)});function K(e,n,r,t,i){return h.createElement(e.tag,_(_({key:n},se(e,r,i)),t),(ce(e,r).children||[]).map(function(c,s){return K(c,"".concat(n,"-").concat(e.tag,"-").concat(s),r,void 0,i)}))}function se(e,n,r){var t=_({},e.attrs);r!=null&&r.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=r.colorChannel1);var i=n.defIds;return!i||i.length===0||(e.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(c){var s=c[0],d=c[1];typeof d=="string"&&(t[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function ce(e,n){var r,t=n.defIds;return!t||t.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?_(_({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&t&&t.indexOf(i.attrs.id)>-1?_(_({},i),{attrs:_(_({},i.attrs),{id:i.attrs.id+n.idSuffix})}):i})}):e}function ae(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var de={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},H=h.forwardRef(function(e,n){return h.createElement(A,Object.assign({},e,{id:"check-mark-single",ref:n,icon:de}))});H.displayName="CheckMarkSingle";var le={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=h.forwardRef(function(e,n){return h.createElement(A,Object.assign({},e,{id:"close-single",ref:n,icon:le}))});G.displayName="CloseSingle";function J(e){var n,r,t="";if(typeof e=="string"||typeof e=="number")t+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(n=0;n<i;n++)e[n]&&(r=J(e[n]))&&(t&&(t+=" "),t+=r)}else for(r in e)e[r]&&(t&&(t+=" "),t+=r);return t}function k(){for(var e,n,r=0,t="",i=arguments.length;r<i;r++)(e=arguments[r])&&(n=J(e))&&(t&&(t+=" "),t+=n);return t}class ue{constructor(){O(this,"_position",null);O(this,"_position$",new q.BehaviorSubject(null));O(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(n){this._position=n,this._refresh(n)}getPosition(){return this._position}_refresh(n){this._position$.next(n)}}const B=o.createIdentifier("univer.sheet-zen-editor-manager.service"),fe="univer-zen-editor",ge="univer-zen-editor-icon-wrapper",_e="univer-zen-editor-icon-container",ve="univer-zen-editor-icon-success",he="univer-zen-editor-icon-error",me="univer-zen-editor-canvas-container",S={zenEditor:fe,zenEditorIconWrapper:ge,zenEditorIconContainer:_e,zenEditorIconSuccess:ve,zenEditorIconError:he,zenEditorCanvasContainer:me},Ee="ZEN_EDITOR_PLUGIN_",Ie=`${Ee}ZEN_EDITOR_COMPONENT`,Se={id:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],tables:[],customBlocks:[],paragraphs:[{startIndex:0}],sectionBreaks:[{startIndex:1}]},tableSource:{},documentStyle:{pageSize:{width:595,height:Number.POSITIVE_INFINITY},documentFlavor:o.DocumentFlavor.MODERN,marginTop:0,marginBottom:0,marginRight:0,marginLeft:0,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};function pe(){const e=h.useRef(null),n=o.useDependency(B),r=o.useDependency(T.IEditorService),t=o.useDependency(o.ICommandService);h.useEffect(()=>{const s=e.current;if(!s)return;const d=r.register({editorUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:Se,scrollBar:!0,noNeedVerticalAlign:!0,backScrollOffset:100},s),a=new ResizeObserver(()=>{n.setPosition(s.getBoundingClientRect())});return a.observe(s),()=>{d.dispose(),a.unobserve(s)}},[]);function i(){t.executeCommand(U.id)}function c(){t.executeCommand(Z.id)}return I.jsxs("div",{className:S.zenEditor,children:[I.jsxs("div",{className:S.zenEditorIconWrapper,children:[I.jsx("span",{className:k(S.zenEditorIconContainer,S.zenEditorIconError),onClick:i,children:I.jsx(G,{style:{fontSize:"22px"}})}),I.jsx("span",{className:k(S.zenEditorIconContainer,S.zenEditorIconSuccess),onClick:c,children:I.jsx(H,{style:{fontSize:"22px"}})})]}),I.jsx("div",{className:S.zenEditorCanvasContainer,ref:e})]})}function Ce(e){return{id:M.id,type:f.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",hidden$:p.getCurrentExclusiveRangeInterest$(e),disabled$:p.getCurrentRangeDisable$(e,{workbookTypes:[y.WorkbookEditablePermission],worksheetTypes:[y.WorksheetEditPermission,y.WorksheetSetCellValuePermission,y.WorksheetSetCellStylePermission],rangeTypes:[y.RangeProtectionPermissionEditPoint]})}}const Oe={[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[M.id]:{order:2,menuItemFactory:Ce}}}},ye={id:Z.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:e=>X(e),binding:f.KeyCode.ENTER|f.MetaKeys.ALT},Ne={id:U.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:e=>X(e),binding:f.KeyCode.ESC};function X(e){return e.getContextValue(o.FOCUSING_DOC)&&e.getContextValue(o.FOCUSING_UNIVER_EDITOR)&&e.getContextValue(o.EDITOR_ACTIVATED)&&!e.getContextValue(o.FOCUSING_EDITOR_STANDALONE)}var Te=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,be=(e,n,r,t)=>{for(var i=t>1?void 0:t?Re(n,r):n,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(t?s(n,r,i):s(i))||i);return t&&i&&Te(n,r,i),i},D=(e,n)=>(r,t)=>n(r,t,e);let P=class extends o.Disposable{constructor(e,n,r,t){super(),this._zenZoneService=e,this._commandService=n,this._menuManagerService=r,this._shortcutService=t,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(Ie,pe))}_initCommands(){[M,U,Z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Oe)}_initShortcuts(){[ye,Ne].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}};P=be([D(0,f.IZenZoneService),D(1,o.ICommandService),D(2,f.IMenuManagerService),D(3,f.IShortcutService)],P);var De=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,Pe=(e,n,r,t)=>{for(var i=t>1?void 0:t?ze(n,r):n,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(t?s(n,r,i):s(i))||i);return t&&i&&De(n,r,i),i},V=(e,n)=>(r,t)=>n(r,t,e);let x=class extends o.RxDisposable{constructor(e,n){super(),this._zenEditorManagerService=e,this._renderManagerService=n,this._initialize()}_initialize(){this._syncZenEditorSize()}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(q.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{width:n,height:r}=e,t=p.getEditorObject(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService);t!=null&&requestIdleCallback(()=>{t.engine.resizeBySize(n,r),this._calculatePagePosition(t),this._scrollToTop()})})}_calculatePagePosition(e){const{document:n,scene:r,docBackground:t}=e,i=r==null?void 0:r.getParent(),{width:c,height:s,pageMarginLeft:d,pageMarginTop:a}=n;if(i==null||c===Number.POSITIVE_INFINITY||s===Number.POSITIVE_INFINITY)return;const{width:g,height:l}=i;let u=0;const v=a;let m=0,R=0,C=Number.POSITIVE_INFINITY;const{scaleX:E,scaleY:b}=r.getAncestorScale();g>(c+d*2)*E?(u=g/2-c*E/2,u/=E,m=(g-d*2)/E,C=0):(u=d,m=c+d*2,C=(m-g/E)/2),l>s?R=(l-a*2)/b:R=s+a*2,r.resize(m,R),n.translate(u,v),t.translate(u,v);const w=r.getViewport(T.VIEWPORT_KEY.VIEW_MAIN);if(C!==Number.POSITIVE_INFINITY&&w!=null){const Q=w.transScroll2ViewportScrollValue(C,0).x;w.scrollToBarPos({x:Q})}return this}_scrollToTop(){var r;const e=(r=this._renderManagerService.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:r.with(T.DocBackScrollRenderController),n={startOffset:0,endOffset:0};e&&e.scrollToRange(n)}};x=Pe([V(0,B),V(1,W.IRenderManagerService)],x);var xe=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,Ue=(e,n,r,t)=>{for(var i=t>1?void 0:t?Me(n,r):n,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(t?s(n,r,i):s(i))||i);return t&&i&&xe(n,r,i),i},Y=(e,n)=>(r,t)=>n(r,t,e),z;exports.UniverSheetsZenEditorPlugin=(z=class extends o.Plugin{constructor(n=L,r,t){super(),this._config=n,this._injector=r,this._configService=t;const{menu:i,...c}=o.merge({},L,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ne,c),this._initializeDependencies(this._injector)}_initializeDependencies(n){[[P],[x],[B,{useClass:ue}]].forEach(t=>n.add(t))}onReady(){this._injector.get(P)}onSteady(){this._injector.get(x)}},O(z,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),O(z,"type",o.UniverInstanceType.UNIVER_SHEET),z);exports.UniverSheetsZenEditorPlugin=Ue([Y(1,o.Inject(o.Injector)),Y(2,o.IConfigService)],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=U;exports.ConfirmZenEditCommand=Z;exports.OpenZenEditorCommand=M;
|
package/lib/es/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var S = (e, n, r) =>
|
|
4
|
-
import { CommandType as M, IUniverInstanceService as D, delayAnimationFrame as w, DOCS_ZEN_EDITOR_UNIT_ID_KEY as v, Tools as
|
|
5
|
-
import { IEditorService as U, VIEWPORT_KEY as
|
|
6
|
-
import { IRenderManagerService as
|
|
7
|
-
import { IEditorBridgeService as Z, EditingRenderController as
|
|
8
|
-
import { IZenZoneService as R, ISidebarService as A, MenuItemType as
|
|
9
|
-
import
|
|
10
|
-
import { BehaviorSubject as
|
|
11
|
-
import { WorkbookEditablePermission as
|
|
1
|
+
var ue = Object.defineProperty;
|
|
2
|
+
var fe = (e, n, r) => n in e ? ue(e, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[n] = r;
|
|
3
|
+
var S = (e, n, r) => fe(e, typeof n != "symbol" ? n + "" : n, r);
|
|
4
|
+
import { CommandType as M, IUniverInstanceService as D, delayAnimationFrame as w, DOCS_ZEN_EDITOR_UNIT_ID_KEY as v, Tools as Q, UniverInstanceType as j, DocumentFlavor as ee, DocumentDataModel as ge, createIdentifier as he, DEFAULT_EMPTY_DOCUMENT_VALUE as me, useDependency as x, ICommandService as te, FOCUSING_DOC as _e, FOCUSING_UNIVER_EDITOR as pe, EDITOR_ACTIVATED as ve, FOCUSING_EDITOR_STANDALONE as Ee, Disposable as Se, RxDisposable as Ie, Plugin as Ce, merge as Oe, Inject as ye, Injector as Ne, IConfigService as be } from "@univerjs/core";
|
|
5
|
+
import { IEditorService as U, VIEWPORT_KEY as Te, DocBackScrollRenderController as Re } from "@univerjs/docs-ui";
|
|
6
|
+
import { IRenderManagerService as ne } from "@univerjs/engine-render";
|
|
7
|
+
import { IEditorBridgeService as Z, EditingRenderController as ze, getCurrentExclusiveRangeInterest$ as xe, getCurrentRangeDisable$ as Pe, getEditorObject as Me } from "@univerjs/sheets-ui";
|
|
8
|
+
import { IZenZoneService as R, ISidebarService as A, MenuItemType as De, ContextMenuPosition as we, ContextMenuGroup as je, KeyCode as re, MetaKeys as Ue, IMenuManagerService as Ze, IShortcutService as Ae } from "@univerjs/ui";
|
|
9
|
+
import Le, { forwardRef as L, useRef as ie, createElement as $, useEffect as $e } from "react";
|
|
10
|
+
import { BehaviorSubject as Be, takeUntil as ke } from "rxjs";
|
|
11
|
+
import { WorkbookEditablePermission as Fe, WorksheetEditPermission as Ve, WorksheetSetCellValuePermission as We, WorksheetSetCellStylePermission as He, RangeProtectionPermissionEditPoint as Ye } from "@univerjs/sheets";
|
|
12
12
|
const B = {
|
|
13
13
|
id: "zen-editor.command.open-zen-editor",
|
|
14
14
|
type: M.COMMAND,
|
|
@@ -26,7 +26,7 @@ const B = {
|
|
|
26
26
|
if (c == null)
|
|
27
27
|
return !1;
|
|
28
28
|
i.focusUnit(v);
|
|
29
|
-
const { body: u, drawings: l, drawingsOrder: d, tableSource: g, settings: h } =
|
|
29
|
+
const { body: u, drawings: l, drawingsOrder: d, tableSource: g, settings: h } = Q.deepClone(c), E = {
|
|
30
30
|
...o.getDocumentData(),
|
|
31
31
|
body: u,
|
|
32
32
|
drawings: l,
|
|
@@ -61,18 +61,18 @@ const B = {
|
|
|
61
61
|
const o = i.getEditor(v);
|
|
62
62
|
if (o == null)
|
|
63
63
|
return !1;
|
|
64
|
-
const a = e.get(
|
|
64
|
+
const a = e.get(ne), c = t.getCurrentUnitForType(j.UNIVER_SHEET);
|
|
65
65
|
if (c) {
|
|
66
|
-
const l = c.getUnitId(), d = (u = a.getRenderById(l)) == null ? void 0 : u.with(
|
|
66
|
+
const l = c.getUnitId(), d = (u = a.getRenderById(l)) == null ? void 0 : u.with(ze);
|
|
67
67
|
if (d) {
|
|
68
|
-
const g =
|
|
69
|
-
g.documentStyle.documentFlavor =
|
|
68
|
+
const g = Q.deepClone(o.getDocumentData());
|
|
69
|
+
g.documentStyle.documentFlavor = ee.UNSPECIFIED, d.submitCellData(new ge(g));
|
|
70
70
|
}
|
|
71
71
|
return t.focusUnit(c.getUnitId()), r.refreshEditCellState(), !0;
|
|
72
72
|
}
|
|
73
73
|
return !1;
|
|
74
74
|
}
|
|
75
|
-
},
|
|
75
|
+
}, Ge = "sheets-zen-editor.config", H = {};
|
|
76
76
|
var P = { exports: {} }, I = {};
|
|
77
77
|
/**
|
|
78
78
|
* @license React
|
|
@@ -83,11 +83,11 @@ var P = { exports: {} }, I = {};
|
|
|
83
83
|
* This source code is licensed under the MIT license found in the
|
|
84
84
|
* LICENSE file in the root directory of this source tree.
|
|
85
85
|
*/
|
|
86
|
-
var
|
|
87
|
-
function
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
var e =
|
|
86
|
+
var Y;
|
|
87
|
+
function qe() {
|
|
88
|
+
if (Y) return I;
|
|
89
|
+
Y = 1;
|
|
90
|
+
var e = Le, n = Symbol.for("react.element"), r = Symbol.for("react.fragment"), t = Object.prototype.hasOwnProperty, i = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
91
91
|
function o(a, c, u) {
|
|
92
92
|
var l, d = {}, g = null, h = null;
|
|
93
93
|
u !== void 0 && (g = "" + u), c.key !== void 0 && (g = "" + c.key), c.ref !== void 0 && (h = c.ref);
|
|
@@ -97,11 +97,11 @@ function Ge() {
|
|
|
97
97
|
}
|
|
98
98
|
return I.Fragment = r, I.jsx = o, I.jsxs = o, I;
|
|
99
99
|
}
|
|
100
|
-
var
|
|
101
|
-
function
|
|
102
|
-
return
|
|
100
|
+
var G;
|
|
101
|
+
function Je() {
|
|
102
|
+
return G || (G = 1, P.exports = qe()), P.exports;
|
|
103
103
|
}
|
|
104
|
-
var _ =
|
|
104
|
+
var _ = Je(), f = function() {
|
|
105
105
|
return f = Object.assign || function(e) {
|
|
106
106
|
for (var n, r = 1, t = arguments.length; r < t; r++) {
|
|
107
107
|
n = arguments[r];
|
|
@@ -109,7 +109,7 @@ var _ = qe(), f = function() {
|
|
|
109
109
|
}
|
|
110
110
|
return e;
|
|
111
111
|
}, f.apply(this, arguments);
|
|
112
|
-
},
|
|
112
|
+
}, Ke = function(e, n) {
|
|
113
113
|
var r = {};
|
|
114
114
|
for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && n.indexOf(t) < 0 && (r[t] = e[t]);
|
|
115
115
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -117,15 +117,15 @@ var _ = qe(), f = function() {
|
|
|
117
117
|
n.indexOf(t[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[i]) && (r[t[i]] = e[t[i]]);
|
|
118
118
|
return r;
|
|
119
119
|
}, V = L(function(e, n) {
|
|
120
|
-
var r = e.icon, t = e.id, i = e.className, s = e.extend, o =
|
|
121
|
-
return
|
|
120
|
+
var r = e.icon, t = e.id, i = e.className, s = e.extend, o = Ke(e, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(t, " ").concat(i || "").trim(), c = ie("_".concat(et()));
|
|
121
|
+
return oe(r, "".concat(t), { defIds: r.defIds, idSuffix: c.current }, f({ ref: n, className: a }, o), s);
|
|
122
122
|
});
|
|
123
|
-
function
|
|
124
|
-
return $(e.tag, f(f({ key: n },
|
|
125
|
-
return
|
|
123
|
+
function oe(e, n, r, t, i) {
|
|
124
|
+
return $(e.tag, f(f({ key: n }, Xe(e, r, i)), t), (Qe(e, r).children || []).map(function(s, o) {
|
|
125
|
+
return oe(s, "".concat(n, "-").concat(e.tag, "-").concat(o), r, void 0, i);
|
|
126
126
|
}));
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function Xe(e, n, r) {
|
|
129
129
|
var t = f({}, e.attrs);
|
|
130
130
|
r != null && r.colorChannel1 && t.fill === "colorChannel1" && (t.fill = r.colorChannel1);
|
|
131
131
|
var i = n.defIds;
|
|
@@ -134,49 +134,49 @@ function Ke(e, n, r) {
|
|
|
134
134
|
typeof a == "string" && (t[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(n.idSuffix, ")")));
|
|
135
135
|
})), t;
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function Qe(e, n) {
|
|
138
138
|
var r, t = n.defIds;
|
|
139
139
|
return !t || t.length === 0 ? e : e.tag === "defs" && (!((r = e.children) === null || r === void 0) && r.length) ? f(f({}, e), { children: e.children.map(function(i) {
|
|
140
140
|
return typeof i.attrs.id == "string" && t && t.indexOf(i.attrs.id) > -1 ? f(f({}, i), { attrs: f(f({}, i.attrs), { id: i.attrs.id + n.idSuffix }) }) : i;
|
|
141
141
|
}) }) : e;
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function et() {
|
|
144
144
|
return Math.random().toString(36).substring(2, 8);
|
|
145
145
|
}
|
|
146
146
|
V.displayName = "UniverIcon";
|
|
147
|
-
var
|
|
147
|
+
var tt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, se = L(function(e, n) {
|
|
148
148
|
return $(V, Object.assign({}, e, {
|
|
149
149
|
id: "check-mark-single",
|
|
150
150
|
ref: n,
|
|
151
|
-
icon:
|
|
151
|
+
icon: tt
|
|
152
152
|
}));
|
|
153
153
|
});
|
|
154
|
-
|
|
155
|
-
var
|
|
154
|
+
se.displayName = "CheckMarkSingle";
|
|
155
|
+
var nt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z" } }] }, ce = L(function(e, n) {
|
|
156
156
|
return $(V, Object.assign({}, e, {
|
|
157
157
|
id: "close-single",
|
|
158
158
|
ref: n,
|
|
159
|
-
icon:
|
|
159
|
+
icon: nt
|
|
160
160
|
}));
|
|
161
161
|
});
|
|
162
|
-
|
|
163
|
-
function
|
|
162
|
+
ce.displayName = "CloseSingle";
|
|
163
|
+
function ae(e) {
|
|
164
164
|
var n, r, t = "";
|
|
165
165
|
if (typeof e == "string" || typeof e == "number") t += e;
|
|
166
166
|
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
167
167
|
var i = e.length;
|
|
168
|
-
for (n = 0; n < i; n++) e[n] && (r =
|
|
168
|
+
for (n = 0; n < i; n++) e[n] && (r = ae(e[n])) && (t && (t += " "), t += r);
|
|
169
169
|
} else for (r in e) e[r] && (t && (t += " "), t += r);
|
|
170
170
|
return t;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
173
|
-
for (var e, n, r = 0, t = "", i = arguments.length; r < i; r++) (e = arguments[r]) && (n =
|
|
172
|
+
function q() {
|
|
173
|
+
for (var e, n, r = 0, t = "", i = arguments.length; r < i; r++) (e = arguments[r]) && (n = ae(e)) && (t && (t += " "), t += n);
|
|
174
174
|
return t;
|
|
175
175
|
}
|
|
176
|
-
class
|
|
176
|
+
class rt {
|
|
177
177
|
constructor() {
|
|
178
178
|
S(this, "_position", null);
|
|
179
|
-
S(this, "_position$", new
|
|
179
|
+
S(this, "_position$", new Be(null));
|
|
180
180
|
S(this, "position$", this._position$.asObservable());
|
|
181
181
|
}
|
|
182
182
|
dispose() {
|
|
@@ -192,19 +192,19 @@ class nt {
|
|
|
192
192
|
this._position$.next(n);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
const W =
|
|
195
|
+
const W = he(
|
|
196
196
|
"univer.sheet-zen-editor-manager.service"
|
|
197
|
-
),
|
|
198
|
-
zenEditor:
|
|
199
|
-
zenEditorIconWrapper:
|
|
200
|
-
zenEditorIconContainer:
|
|
201
|
-
zenEditorIconSuccess:
|
|
202
|
-
zenEditorIconError:
|
|
203
|
-
zenEditorCanvasContainer:
|
|
204
|
-
},
|
|
197
|
+
), it = "univer-zen-editor", ot = "univer-zen-editor-icon-wrapper", st = "univer-zen-editor-icon-container", ct = "univer-zen-editor-icon-success", at = "univer-zen-editor-icon-error", lt = "univer-zen-editor-canvas-container", p = {
|
|
198
|
+
zenEditor: it,
|
|
199
|
+
zenEditorIconWrapper: ot,
|
|
200
|
+
zenEditorIconContainer: st,
|
|
201
|
+
zenEditorIconSuccess: ct,
|
|
202
|
+
zenEditorIconError: at,
|
|
203
|
+
zenEditorCanvasContainer: lt
|
|
204
|
+
}, dt = "ZEN_EDITOR_PLUGIN_", ut = `${dt}ZEN_EDITOR_COMPONENT`, ft = {
|
|
205
205
|
id: v,
|
|
206
206
|
body: {
|
|
207
|
-
dataStream: `${
|
|
207
|
+
dataStream: `${me}`,
|
|
208
208
|
textRuns: [],
|
|
209
209
|
tables: [],
|
|
210
210
|
customBlocks: [],
|
|
@@ -223,7 +223,7 @@ const W = ge(
|
|
|
223
223
|
width: 595,
|
|
224
224
|
height: Number.POSITIVE_INFINITY
|
|
225
225
|
},
|
|
226
|
-
documentFlavor:
|
|
226
|
+
documentFlavor: ee.MODERN,
|
|
227
227
|
marginTop: 0,
|
|
228
228
|
marginBottom: 0,
|
|
229
229
|
marginRight: 0,
|
|
@@ -236,16 +236,16 @@ const W = ge(
|
|
|
236
236
|
drawings: {},
|
|
237
237
|
drawingsOrder: []
|
|
238
238
|
};
|
|
239
|
-
function
|
|
240
|
-
const e =
|
|
241
|
-
|
|
239
|
+
function gt() {
|
|
240
|
+
const e = ie(null), n = x(W), r = x(U), t = x(te);
|
|
241
|
+
$e(() => {
|
|
242
242
|
const o = e.current;
|
|
243
243
|
if (!o)
|
|
244
244
|
return;
|
|
245
245
|
const a = r.register(
|
|
246
246
|
{
|
|
247
247
|
editorUnitId: v,
|
|
248
|
-
initialSnapshot:
|
|
248
|
+
initialSnapshot: ft,
|
|
249
249
|
scrollBar: !0,
|
|
250
250
|
noNeedVerticalAlign: !0,
|
|
251
251
|
backScrollOffset: 100
|
|
@@ -269,64 +269,64 @@ function ft() {
|
|
|
269
269
|
/* @__PURE__ */ _.jsx(
|
|
270
270
|
"span",
|
|
271
271
|
{
|
|
272
|
-
className:
|
|
272
|
+
className: q(p.zenEditorIconContainer, p.zenEditorIconError),
|
|
273
273
|
onClick: i,
|
|
274
|
-
children: /* @__PURE__ */ _.jsx(
|
|
274
|
+
children: /* @__PURE__ */ _.jsx(ce, { style: { fontSize: "22px" } })
|
|
275
275
|
}
|
|
276
276
|
),
|
|
277
277
|
/* @__PURE__ */ _.jsx(
|
|
278
278
|
"span",
|
|
279
279
|
{
|
|
280
|
-
className:
|
|
280
|
+
className: q(p.zenEditorIconContainer, p.zenEditorIconSuccess),
|
|
281
281
|
onClick: s,
|
|
282
|
-
children: /* @__PURE__ */ _.jsx(
|
|
282
|
+
children: /* @__PURE__ */ _.jsx(se, { style: { fontSize: "22px" } })
|
|
283
283
|
}
|
|
284
284
|
)
|
|
285
285
|
] }),
|
|
286
286
|
/* @__PURE__ */ _.jsx("div", { className: p.zenEditorCanvasContainer, ref: e })
|
|
287
287
|
] });
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function ht(e) {
|
|
290
290
|
return {
|
|
291
291
|
id: B.id,
|
|
292
|
-
type:
|
|
292
|
+
type: De.BUTTON,
|
|
293
293
|
title: "rightClick.zenEditor",
|
|
294
294
|
icon: "AmplifySingle",
|
|
295
|
-
hidden$:
|
|
296
|
-
disabled$:
|
|
295
|
+
hidden$: xe(e),
|
|
296
|
+
disabled$: Pe(e, { workbookTypes: [Fe], worksheetTypes: [Ve, We, He], rangeTypes: [Ye] })
|
|
297
297
|
};
|
|
298
298
|
}
|
|
299
|
-
const
|
|
300
|
-
[
|
|
301
|
-
[
|
|
299
|
+
const mt = {
|
|
300
|
+
[we.MAIN_AREA]: {
|
|
301
|
+
[je.OTHERS]: {
|
|
302
302
|
[B.id]: {
|
|
303
303
|
order: 2,
|
|
304
|
-
menuItemFactory:
|
|
304
|
+
menuItemFactory: ht
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
|
-
},
|
|
308
|
+
}, _t = {
|
|
309
309
|
id: F.id,
|
|
310
310
|
description: "shortcut.sheet.zen-edit-confirm",
|
|
311
311
|
group: "4_sheet-edit",
|
|
312
|
-
preconditions: (e) =>
|
|
313
|
-
binding:
|
|
314
|
-
},
|
|
312
|
+
preconditions: (e) => le(e),
|
|
313
|
+
binding: re.ENTER | Ue.ALT
|
|
314
|
+
}, pt = {
|
|
315
315
|
id: k.id,
|
|
316
316
|
description: "shortcut.sheet.zen-edit-cancel",
|
|
317
317
|
group: "4_sheet-edit",
|
|
318
|
-
preconditions: (e) =>
|
|
319
|
-
binding:
|
|
318
|
+
preconditions: (e) => le(e),
|
|
319
|
+
binding: re.ESC
|
|
320
320
|
};
|
|
321
|
-
function
|
|
322
|
-
return e.getContextValue(
|
|
321
|
+
function le(e) {
|
|
322
|
+
return e.getContextValue(_e) && e.getContextValue(pe) && e.getContextValue(ve) && !e.getContextValue(Ee);
|
|
323
323
|
}
|
|
324
|
-
var
|
|
325
|
-
for (var i = t > 1 ? void 0 : t ?
|
|
324
|
+
var vt = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, St = (e, n, r, t) => {
|
|
325
|
+
for (var i = t > 1 ? void 0 : t ? Et(n, r) : n, s = e.length - 1, o; s >= 0; s--)
|
|
326
326
|
(o = e[s]) && (i = (t ? o(n, r, i) : o(i)) || i);
|
|
327
|
-
return t && i &&
|
|
327
|
+
return t && i && vt(n, r, i), i;
|
|
328
328
|
}, y = (e, n) => (r, t) => n(r, t, e);
|
|
329
|
-
let b = class extends
|
|
329
|
+
let b = class extends Se {
|
|
330
330
|
constructor(e, n, r, t) {
|
|
331
331
|
super(), this._zenZoneService = e, this._commandService = n, this._menuManagerService = r, this._shortcutService = t, this._initialize();
|
|
332
332
|
}
|
|
@@ -334,7 +334,7 @@ let b = class extends Ee {
|
|
|
334
334
|
this._initCustomComponents(), this._initCommands(), this._initMenus(), this._initShortcuts();
|
|
335
335
|
}
|
|
336
336
|
_initCustomComponents() {
|
|
337
|
-
this.disposeWithMe(this._zenZoneService.set(
|
|
337
|
+
this.disposeWithMe(this._zenZoneService.set(ut, gt));
|
|
338
338
|
}
|
|
339
339
|
_initCommands() {
|
|
340
340
|
[B, k, F].forEach((e) => {
|
|
@@ -342,26 +342,26 @@ let b = class extends Ee {
|
|
|
342
342
|
});
|
|
343
343
|
}
|
|
344
344
|
_initMenus() {
|
|
345
|
-
this._menuManagerService.mergeMenu(
|
|
345
|
+
this._menuManagerService.mergeMenu(mt);
|
|
346
346
|
}
|
|
347
347
|
_initShortcuts() {
|
|
348
|
-
[
|
|
348
|
+
[_t, pt].forEach((e) => {
|
|
349
349
|
this.disposeWithMe(this._shortcutService.registerShortcut(e));
|
|
350
350
|
});
|
|
351
351
|
}
|
|
352
352
|
};
|
|
353
|
-
b =
|
|
353
|
+
b = St([
|
|
354
354
|
y(0, R),
|
|
355
|
-
y(1,
|
|
356
|
-
y(2,
|
|
357
|
-
y(3,
|
|
355
|
+
y(1, te),
|
|
356
|
+
y(2, Ze),
|
|
357
|
+
y(3, Ae)
|
|
358
358
|
], b);
|
|
359
|
-
var
|
|
360
|
-
for (var i = t > 1 ? void 0 : t ?
|
|
359
|
+
var It = Object.defineProperty, Ct = Object.getOwnPropertyDescriptor, Ot = (e, n, r, t) => {
|
|
360
|
+
for (var i = t > 1 ? void 0 : t ? Ct(n, r) : n, s = e.length - 1, o; s >= 0; s--)
|
|
361
361
|
(o = e[s]) && (i = (t ? o(n, r, i) : o(i)) || i);
|
|
362
|
-
return t && i &&
|
|
363
|
-
},
|
|
364
|
-
let T = class extends
|
|
362
|
+
return t && i && It(n, r, i), i;
|
|
363
|
+
}, J = (e, n) => (r, t) => n(r, t, e);
|
|
364
|
+
let T = class extends Ie {
|
|
365
365
|
constructor(e, n) {
|
|
366
366
|
super(), this._zenEditorManagerService = e, this._renderManagerService = n, this._initialize();
|
|
367
367
|
}
|
|
@@ -370,10 +370,10 @@ let T = class extends Se {
|
|
|
370
370
|
}
|
|
371
371
|
// Listen to changes in the size of the zen editor container to set the size of the editor.
|
|
372
372
|
_syncZenEditorSize() {
|
|
373
|
-
this._zenEditorManagerService.position$.pipe(
|
|
373
|
+
this._zenEditorManagerService.position$.pipe(ke(this.dispose$)).subscribe((e) => {
|
|
374
374
|
if (e == null)
|
|
375
375
|
return;
|
|
376
|
-
const { width: n, height: r } = e, t =
|
|
376
|
+
const { width: n, height: r } = e, t = Me(v, this._renderManagerService);
|
|
377
377
|
t != null && requestIdleCallback(() => {
|
|
378
378
|
t.engine.resizeBySize(n, r), this._calculatePagePosition(t), this._scrollToTop();
|
|
379
379
|
});
|
|
@@ -389,44 +389,48 @@ let T = class extends Se {
|
|
|
389
389
|
let h = 0, C = 0, E = Number.POSITIVE_INFINITY;
|
|
390
390
|
const { scaleX: m, scaleY: O } = r.getAncestorScale();
|
|
391
391
|
u > (s + a * 2) * m ? (d = u / 2 - s * m / 2, d /= m, h = (u - a * 2) / m, E = 0) : (d = a, h = s + a * 2, E = (h - u / m) / 2), l > o ? C = (l - c * 2) / O : C = o + c * 2, r.resize(h, C), n.translate(d, g), t.translate(d, g);
|
|
392
|
-
const z = r.getViewport(
|
|
392
|
+
const z = r.getViewport(Te.VIEW_MAIN);
|
|
393
393
|
if (E !== Number.POSITIVE_INFINITY && z != null) {
|
|
394
|
-
const
|
|
394
|
+
const de = z.transScroll2ViewportScrollValue(E, 0).x;
|
|
395
395
|
z.scrollToBarPos({
|
|
396
|
-
x:
|
|
396
|
+
x: de
|
|
397
397
|
});
|
|
398
398
|
}
|
|
399
399
|
return this;
|
|
400
400
|
}
|
|
401
401
|
_scrollToTop() {
|
|
402
402
|
var r;
|
|
403
|
-
const e = (r = this._renderManagerService.getRenderById(v)) == null ? void 0 : r.with(
|
|
403
|
+
const e = (r = this._renderManagerService.getRenderById(v)) == null ? void 0 : r.with(Re), n = {
|
|
404
404
|
startOffset: 0,
|
|
405
405
|
endOffset: 0
|
|
406
406
|
};
|
|
407
407
|
e && e.scrollToRange(n);
|
|
408
408
|
}
|
|
409
409
|
};
|
|
410
|
-
T =
|
|
411
|
-
|
|
412
|
-
|
|
410
|
+
T = Ot([
|
|
411
|
+
J(0, W),
|
|
412
|
+
J(1, ne)
|
|
413
413
|
], T);
|
|
414
|
-
var
|
|
415
|
-
for (var i = t > 1 ? void 0 : t ?
|
|
414
|
+
var yt = Object.defineProperty, Nt = Object.getOwnPropertyDescriptor, bt = (e, n, r, t) => {
|
|
415
|
+
for (var i = t > 1 ? void 0 : t ? Nt(n, r) : n, s = e.length - 1, o; s >= 0; s--)
|
|
416
416
|
(o = e[s]) && (i = (t ? o(n, r, i) : o(i)) || i);
|
|
417
|
-
return t && i &&
|
|
418
|
-
},
|
|
419
|
-
let
|
|
420
|
-
constructor(e =
|
|
417
|
+
return t && i && yt(n, r, i), i;
|
|
418
|
+
}, K = (e, n) => (r, t) => n(r, t, e), N;
|
|
419
|
+
let X = (N = class extends Ce {
|
|
420
|
+
constructor(e = H, n, r) {
|
|
421
421
|
super(), this._config = e, this._injector = n, this._configService = r;
|
|
422
|
-
const { menu: t, ...i } =
|
|
423
|
-
|
|
422
|
+
const { menu: t, ...i } = Oe(
|
|
423
|
+
{},
|
|
424
|
+
H,
|
|
425
|
+
this._config
|
|
426
|
+
);
|
|
427
|
+
t && this._configService.setConfig("menu", t, { merge: !0 }), this._configService.setConfig(Ge, i), this._initializeDependencies(this._injector);
|
|
424
428
|
}
|
|
425
429
|
_initializeDependencies(e) {
|
|
426
430
|
[
|
|
427
431
|
[b],
|
|
428
432
|
[T],
|
|
429
|
-
[W, { useClass:
|
|
433
|
+
[W, { useClass: rt }]
|
|
430
434
|
].forEach((r) => e.add(r));
|
|
431
435
|
}
|
|
432
436
|
onReady() {
|
|
@@ -436,13 +440,13 @@ let K = (N = class extends Ie {
|
|
|
436
440
|
this._injector.get(T);
|
|
437
441
|
}
|
|
438
442
|
}, S(N, "pluginName", "SHEET_ZEN_EDITOR_PLUGIN"), S(N, "type", j.UNIVER_SHEET), N);
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
],
|
|
443
|
+
X = bt([
|
|
444
|
+
K(1, ye(Ne)),
|
|
445
|
+
K(2, be)
|
|
446
|
+
], X);
|
|
443
447
|
export {
|
|
444
448
|
k as CancelZenEditCommand,
|
|
445
449
|
F as ConfirmZenEditCommand,
|
|
446
450
|
B as OpenZenEditorCommand,
|
|
447
|
-
|
|
451
|
+
X as UniverSheetsZenEditorPlugin
|
|
448
452
|
};
|
package/lib/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.univer-zen-editor{position:absolute;top:0;left:0;width:100%;height:100%;background-color:rgb(var(--color-white))}.univer-zen-editor-icon-wrapper{position:absolute;z-index:10;top:0;right:20px;display:flex;align-items:center;justify-content:space-around;width:60px;height:30px}.univer-zen-editor-icon-container{cursor:pointer;display:flex;align-items:center;justify-content:center;width:30px;height:30px}.univer-zen-editor-icon-success{color:rgb(var(--success-color))}.univer-zen-editor-icon-error{color:rgb(var(--error-color))}.univer-zen-editor-canvas-container{position:absolute;top:0;left:0;width:100%;height:100%}
|
|
1
|
+
*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*{scrollbar-color:initial;scrollbar-width:initial}@keyframes enter{0%{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x, 0),var(--tw-enter-translate-y, 0),0) scale3d(var(--tw-enter-scale, 1),var(--tw-enter-scale, 1),var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity, 1);transform:translate3d(var(--tw-exit-translate-x, 0),var(--tw-exit-translate-y, 0),0) scale3d(var(--tw-exit-scale, 1),var(--tw-exit-scale, 1),var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))}}.univer-zen-editor{position:absolute;top:0;left:0;width:100%;height:100%;background-color:rgb(var(--color-white))}.univer-zen-editor-icon-wrapper{position:absolute;z-index:10;top:0;right:20px;display:flex;align-items:center;justify-content:space-around;width:60px;height:30px}.univer-zen-editor-icon-container{cursor:pointer;display:flex;align-items:center;justify-content:center;width:30px;height:30px}.univer-zen-editor-icon-success{color:rgb(var(--success-color))}.univer-zen-editor-icon-error{color:rgb(var(--error-color))}.univer-zen-editor-canvas-container{position:absolute;top:0;left:0;width:100%;height:100%}
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(d,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("react"),require("rxjs"),require("@univerjs/sheets")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-ui","@univerjs/engine-render","@univerjs/sheets-ui","@univerjs/ui","react","rxjs","@univerjs/sheets"],o):(d=typeof globalThis<"u"?globalThis:d||self,o(d.UniverSheetsZenEditor={},d.UniverCore,d.UniverDocsUi,d.UniverEngineRender,d.UniverSheetsUi,d.UniverUi,d.React,d.rxjs,d.UniverSheets))})(this,function(d,o,h,F,S,f,
|
|
1
|
+
(function(d,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("react"),require("rxjs"),require("@univerjs/sheets")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-ui","@univerjs/engine-render","@univerjs/sheets-ui","@univerjs/ui","react","rxjs","@univerjs/sheets"],o):(d=typeof globalThis<"u"?globalThis:d||self,o(d.UniverSheetsZenEditor={},d.UniverCore,d.UniverDocsUi,d.UniverEngineRender,d.UniverSheetsUi,d.UniverUi,d.React,d.rxjs,d.UniverSheets))})(this,function(d,o,h,F,S,f,m,k,N){"use strict";var Re=Object.defineProperty;var De=(d,o,h)=>o in d?Re(d,o,{enumerable:!0,configurable:!0,writable:!0,value:h}):d[o]=h;var T=(d,o,h)=>De(d,typeof o!="symbol"?o+"":o,h);var M;const D={id:"zen-editor.command.open-zen-editor",type:o.CommandType.COMMAND,handler:async e=>{var U;const t=e.get(f.IZenZoneService),r=e.get(h.IEditorService),n=e.get(S.IEditorBridgeService),i=e.get(o.IUniverInstanceService),a=e.get(f.ISidebarService);a.visible&&(a.close(),await o.delayAnimationFrame()),t.open();const s=r.getEditor(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(s==null)return!1;const l=n.getLatestEditCellState();if(l==null)return!1;const c=(U=l.documentLayoutObject.documentModel)==null?void 0:U.getSnapshot();if(c==null)return!1;i.focusUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const{body:g,drawings:u,drawingsOrder:v,tableSource:E,settings:I}=o.Tools.deepClone(c),y={...s.getDocumentData(),body:g,drawings:u,drawingsOrder:v,tableSource:E,settings:I},O=[{startOffset:0,endOffset:0,collapsed:!0}];return s.focus(),s.setDocumentData(y,O),s.clearUndoRedoHistory(),!0}},z={id:"zen-editor.command.cancel-zen-edit",type:o.CommandType.COMMAND,handler:async e=>{const t=e.get(f.IZenZoneService),r=e.get(S.IEditorBridgeService),n=e.get(o.IUniverInstanceService),i=e.get(f.ISidebarService);i.visible&&(i.close(),await o.delayAnimationFrame()),t.close();const a=n.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);return a?(n.focusUnit(a.getUnitId()),r.refreshEditCellState(),!0):!1}},b={id:"zen-editor.command.confirm-zen-edit",type:o.CommandType.COMMAND,handler:async e=>{var g;const t=e.get(f.IZenZoneService),r=e.get(S.IEditorBridgeService),n=e.get(o.IUniverInstanceService),i=e.get(h.IEditorService),a=e.get(f.ISidebarService);a.visible&&(a.close(),await o.delayAnimationFrame()),t.close();const s=i.getEditor(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(s==null)return!1;const l=e.get(F.IRenderManagerService),c=n.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(c){const u=c.getUnitId(),v=(g=l.getRenderById(u))==null?void 0:g.with(S.EditingRenderController);if(v){const E=o.Tools.deepClone(s.getDocumentData());E.documentStyle.documentFlavor=o.DocumentFlavor.UNSPECIFIED,v.submitCellData(new o.DocumentDataModel(E))}return n.focusUnit(c.getUnitId()),r.refreshEditCellState(),!0}return!1}},ee="sheets-zen-editor.config",V={};var w={exports:{}},R={};/**
|
|
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 V;function ne(){if(V)return R;V=1;var e=I,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function s(l,c,g){var u,v={},E=null,m=null;g!==void 0&&(E=""+g),c.key!==void 0&&(E=""+c.key),c.ref!==void 0&&(m=c.ref);for(u in c)n.call(c,u)&&!a.hasOwnProperty(u)&&(v[u]=c[u]);if(l&&l.defaultProps)for(u in c=l.defaultProps,c)v[u]===void 0&&(v[u]=c[u]);return{$$typeof:t,type:l,key:E,ref:m,props:v,_owner:i.current}}return R.Fragment=r,R.jsx=s,R.jsxs=s,R}var W;function te(){return W||(W=1,w.exports=ne()),w.exports}var p=te(),_=function(){return _=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},_.apply(this,arguments)},re=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},A=I.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,a=e.extend,s=re(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),c=I.useRef("_".concat(se()));return Y(r,"".concat(n),{defIds:r.defIds,idSuffix:c.current},_({ref:t,className:l},s),a)});function Y(e,t,r,n,i){return I.createElement(e.tag,_(_({key:t},ie(e,r,i)),n),(oe(e,r).children||[]).map(function(a,s){return Y(a,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,i)}))}function ie(e,t,r){var n=_({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(a){var s=a[0],l=a[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function oe(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?_(_({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?_(_({},i),{attrs:_(_({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function se(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var ae={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},K=I.forwardRef(function(e,t){return I.createElement(A,Object.assign({},e,{id:"check-mark-single",ref:t,icon:ae}))});K.displayName="CheckMarkSingle";var ce={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},H=I.forwardRef(function(e,t){return I.createElement(A,Object.assign({},e,{id:"close-single",ref:t,icon:ce}))});H.displayName="CloseSingle";function G(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=G(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function $(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=G(e))&&(n&&(n+=" "),n+=t);return n}class de{constructor(){T(this,"_position",null);T(this,"_position$",new k.BehaviorSubject(null));T(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=o.createIdentifier("univer.sheet-zen-editor-manager.service"),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"},le="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT",ue={id:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],tables:[],customBlocks:[],paragraphs:[{startIndex:0}],sectionBreaks:[{startIndex:1}]},tableSource:{},documentStyle:{pageSize:{width:595,height:Number.POSITIVE_INFINITY},documentFlavor:o.DocumentFlavor.MODERN,marginTop:0,marginBottom:0,marginRight:0,marginLeft:0,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};function fe(){const e=I.useRef(null),t=o.useDependency(B),r=o.useDependency(h.IEditorService),n=o.useDependency(o.ICommandService);I.useEffect(()=>{const s=e.current;if(!s)return;const l=r.register({editorUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:ue,scrollBar:!0,noNeedVerticalAlign:!0,backScrollOffset:100},s),c=new ResizeObserver(()=>{t.setPosition(s.getBoundingClientRect())});return c.observe(s),()=>{l.dispose(),c.unobserve(s)}},[]);function i(){n.executeCommand(z.id)}function a(){n.executeCommand(b.id)}return p.jsxs("div",{className:C.zenEditor,children:[p.jsxs("div",{className:C.zenEditorIconWrapper,children:[p.jsx("span",{className:$(C.zenEditorIconContainer,C.zenEditorIconError),onClick:i,children:p.jsx(H,{style:{fontSize:"22px"}})}),p.jsx("span",{className:$(C.zenEditorIconContainer,C.zenEditorIconSuccess),onClick:a,children:p.jsx(K,{style:{fontSize:"22px"}})})]}),p.jsx("div",{className:C.zenEditorCanvasContainer,ref:e})]})}function ve(e){return{id:D.id,type:f.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",hidden$:S.getCurrentExclusiveRangeInterest$(e),disabled$:S.getCurrentRangeDisable$(e,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission,N.WorksheetSetCellValuePermission,N.WorksheetSetCellStylePermission],rangeTypes:[N.RangeProtectionPermissionEditPoint]})}}const _e={[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[D.id]:{order:2,menuItemFactory:ve}}}},ge={id:b.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:e=>q(e),binding:f.KeyCode.ENTER|f.MetaKeys.ALT},Ee={id:z.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:e=>q(e),binding:f.KeyCode.ESC};function q(e){return e.getContextValue(o.FOCUSING_DOC)&&e.getContextValue(o.FOCUSING_UNIVER_EDITOR)&&e.getContextValue(o.EDITOR_ACTIVATED)&&!e.getContextValue(o.FOCUSING_EDITOR_STANDALONE)}var he=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,me=(e,t,r,n)=>{for(var i=n>1?void 0:n?Ie(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&he(t,r,i),i},P=(e,t)=>(r,n)=>t(r,n,e);let j=class extends o.Disposable{constructor(e,t,r,n){super(),this._zenZoneService=e,this._commandService=t,this._menuManagerService=r,this._shortcutService=n,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(le,fe))}_initCommands(){[D,z,b].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(_e)}_initShortcuts(){[ge,Ee].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}};j=me([P(0,f.IZenZoneService),P(1,o.ICommandService),P(2,f.IMenuManagerService),P(3,f.IShortcutService)],j);var Se=Object.defineProperty,pe=Object.getOwnPropertyDescriptor,Ce=(e,t,r,n)=>{for(var i=n>1?void 0:n?pe(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&Se(t,r,i),i},J=(e,t)=>(r,n)=>t(r,n,e);let x=class extends o.RxDisposable{constructor(e,t){super(),this._zenEditorManagerService=e,this._renderManagerService=t,this._initialize()}_initialize(){this._syncZenEditorSize()}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(k.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{width:t,height:r}=e,n=S.getEditorObject(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService);n!=null&&requestIdleCallback(()=>{n.engine.resizeBySize(t,r),this._calculatePagePosition(n),this._scrollToTop()})})}_calculatePagePosition(e){const{document:t,scene:r,docBackground:n}=e,i=r==null?void 0:r.getParent(),{width:a,height:s,pageMarginLeft:l,pageMarginTop:c}=t;if(i==null||a===Number.POSITIVE_INFINITY||s===Number.POSITIVE_INFINITY)return;const{width:g,height:u}=i;let v=0;const E=c;let m=0,Z=0,y=Number.POSITIVE_INFINITY;const{scaleX:O,scaleY:U}=r.getAncestorScale();g>(a+l*2)*O?(v=g/2-a*O/2,v/=O,m=(g-l*2)/O,y=0):(v=l,m=a+l*2,y=(m-g/O)/2),u>s?Z=(u-c*2)/U:Z=s+c*2,r.resize(m,Z),t.translate(v,E),n.translate(v,E);const L=r.getViewport(h.VIEWPORT_KEY.VIEW_MAIN);if(y!==Number.POSITIVE_INFINITY&&L!=null){const Ne=L.transScroll2ViewportScrollValue(y,0).x;L.scrollToBarPos({x:Ne})}return this}_scrollToTop(){var r;const e=(r=this._renderManagerService.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:r.with(h.DocBackScrollRenderController),t={startOffset:0,endOffset:0};e&&e.scrollToRange(t)}};x=Ce([J(0,B),J(1,F.IRenderManagerService)],x);var Oe=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Te=(e,t,r,n)=>{for(var i=n>1?void 0:n?ye(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&Oe(t,r,i),i},X=(e,t)=>(r,n)=>t(r,n,e);d.UniverSheetsZenEditorPlugin=(M=class extends o.Plugin{constructor(t=ee,r,n){super(),this._config=t,this._injector=r,this._configService=n;const{menu:i,...a}=this._config;i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Q,a),this._initializeDependencies(this._injector)}_initializeDependencies(t){[[j],[x],[B,{useClass:de}]].forEach(n=>t.add(n))}onReady(){this._injector.get(j)}onSteady(){this._injector.get(x)}},T(M,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),T(M,"type",o.UniverInstanceType.UNIVER_SHEET),M),d.UniverSheetsZenEditorPlugin=Te([X(1,o.Inject(o.Injector)),X(2,o.IConfigService)],d.UniverSheetsZenEditorPlugin),d.CancelZenEditCommand=z,d.ConfirmZenEditCommand=b,d.OpenZenEditorCommand=D,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
9
|
+
*/var W;function ne(){if(W)return R;W=1;var e=m,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function s(l,c,g){var u,v={},E=null,I=null;g!==void 0&&(E=""+g),c.key!==void 0&&(E=""+c.key),c.ref!==void 0&&(I=c.ref);for(u in c)n.call(c,u)&&!a.hasOwnProperty(u)&&(v[u]=c[u]);if(l&&l.defaultProps)for(u in c=l.defaultProps,c)v[u]===void 0&&(v[u]=c[u]);return{$$typeof:t,type:l,key:E,ref:I,props:v,_owner:i.current}}return R.Fragment=r,R.jsx=s,R.jsxs=s,R}var Y;function te(){return Y||(Y=1,w.exports=ne()),w.exports}var p=te(),_=function(){return _=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},_.apply(this,arguments)},re=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},A=m.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,a=e.extend,s=re(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),c=m.useRef("_".concat(se()));return K(r,"".concat(n),{defIds:r.defIds,idSuffix:c.current},_({ref:t,className:l},s),a)});function K(e,t,r,n,i){return m.createElement(e.tag,_(_({key:t},ie(e,r,i)),n),(oe(e,r).children||[]).map(function(a,s){return K(a,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,i)}))}function ie(e,t,r){var n=_({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(a){var s=a[0],l=a[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function oe(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?_(_({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?_(_({},i),{attrs:_(_({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function se(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var ae={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},H=m.forwardRef(function(e,t){return m.createElement(A,Object.assign({},e,{id:"check-mark-single",ref:t,icon:ae}))});H.displayName="CheckMarkSingle";var ce={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=m.forwardRef(function(e,t){return m.createElement(A,Object.assign({},e,{id:"close-single",ref:t,icon:ce}))});G.displayName="CloseSingle";function $(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=$(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function q(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=$(e))&&(n&&(n+=" "),n+=t);return n}class de{constructor(){T(this,"_position",null);T(this,"_position$",new k.BehaviorSubject(null));T(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=o.createIdentifier("univer.sheet-zen-editor-manager.service"),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"},le="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT",ue={id:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],tables:[],customBlocks:[],paragraphs:[{startIndex:0}],sectionBreaks:[{startIndex:1}]},tableSource:{},documentStyle:{pageSize:{width:595,height:Number.POSITIVE_INFINITY},documentFlavor:o.DocumentFlavor.MODERN,marginTop:0,marginBottom:0,marginRight:0,marginLeft:0,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};function fe(){const e=m.useRef(null),t=o.useDependency(B),r=o.useDependency(h.IEditorService),n=o.useDependency(o.ICommandService);m.useEffect(()=>{const s=e.current;if(!s)return;const l=r.register({editorUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:ue,scrollBar:!0,noNeedVerticalAlign:!0,backScrollOffset:100},s),c=new ResizeObserver(()=>{t.setPosition(s.getBoundingClientRect())});return c.observe(s),()=>{l.dispose(),c.unobserve(s)}},[]);function i(){n.executeCommand(z.id)}function a(){n.executeCommand(b.id)}return p.jsxs("div",{className:C.zenEditor,children:[p.jsxs("div",{className:C.zenEditorIconWrapper,children:[p.jsx("span",{className:q(C.zenEditorIconContainer,C.zenEditorIconError),onClick:i,children:p.jsx(G,{style:{fontSize:"22px"}})}),p.jsx("span",{className:q(C.zenEditorIconContainer,C.zenEditorIconSuccess),onClick:a,children:p.jsx(H,{style:{fontSize:"22px"}})})]}),p.jsx("div",{className:C.zenEditorCanvasContainer,ref:e})]})}function ve(e){return{id:D.id,type:f.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",hidden$:S.getCurrentExclusiveRangeInterest$(e),disabled$:S.getCurrentRangeDisable$(e,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission,N.WorksheetSetCellValuePermission,N.WorksheetSetCellStylePermission],rangeTypes:[N.RangeProtectionPermissionEditPoint]})}}const _e={[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[D.id]:{order:2,menuItemFactory:ve}}}},ge={id:b.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:e=>J(e),binding:f.KeyCode.ENTER|f.MetaKeys.ALT},Ee={id:z.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:e=>J(e),binding:f.KeyCode.ESC};function J(e){return e.getContextValue(o.FOCUSING_DOC)&&e.getContextValue(o.FOCUSING_UNIVER_EDITOR)&&e.getContextValue(o.EDITOR_ACTIVATED)&&!e.getContextValue(o.FOCUSING_EDITOR_STANDALONE)}var he=Object.defineProperty,me=Object.getOwnPropertyDescriptor,Ie=(e,t,r,n)=>{for(var i=n>1?void 0:n?me(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&he(t,r,i),i},P=(e,t)=>(r,n)=>t(r,n,e);let j=class extends o.Disposable{constructor(e,t,r,n){super(),this._zenZoneService=e,this._commandService=t,this._menuManagerService=r,this._shortcutService=n,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(le,fe))}_initCommands(){[D,z,b].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(_e)}_initShortcuts(){[ge,Ee].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}};j=Ie([P(0,f.IZenZoneService),P(1,o.ICommandService),P(2,f.IMenuManagerService),P(3,f.IShortcutService)],j);var Se=Object.defineProperty,pe=Object.getOwnPropertyDescriptor,Ce=(e,t,r,n)=>{for(var i=n>1?void 0:n?pe(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&Se(t,r,i),i},X=(e,t)=>(r,n)=>t(r,n,e);let x=class extends o.RxDisposable{constructor(e,t){super(),this._zenEditorManagerService=e,this._renderManagerService=t,this._initialize()}_initialize(){this._syncZenEditorSize()}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(k.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{width:t,height:r}=e,n=S.getEditorObject(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService);n!=null&&requestIdleCallback(()=>{n.engine.resizeBySize(t,r),this._calculatePagePosition(n),this._scrollToTop()})})}_calculatePagePosition(e){const{document:t,scene:r,docBackground:n}=e,i=r==null?void 0:r.getParent(),{width:a,height:s,pageMarginLeft:l,pageMarginTop:c}=t;if(i==null||a===Number.POSITIVE_INFINITY||s===Number.POSITIVE_INFINITY)return;const{width:g,height:u}=i;let v=0;const E=c;let I=0,Z=0,y=Number.POSITIVE_INFINITY;const{scaleX:O,scaleY:U}=r.getAncestorScale();g>(a+l*2)*O?(v=g/2-a*O/2,v/=O,I=(g-l*2)/O,y=0):(v=l,I=a+l*2,y=(I-g/O)/2),u>s?Z=(u-c*2)/U:Z=s+c*2,r.resize(I,Z),t.translate(v,E),n.translate(v,E);const L=r.getViewport(h.VIEWPORT_KEY.VIEW_MAIN);if(y!==Number.POSITIVE_INFINITY&&L!=null){const Ne=L.transScroll2ViewportScrollValue(y,0).x;L.scrollToBarPos({x:Ne})}return this}_scrollToTop(){var r;const e=(r=this._renderManagerService.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:r.with(h.DocBackScrollRenderController),t={startOffset:0,endOffset:0};e&&e.scrollToRange(t)}};x=Ce([X(0,B),X(1,F.IRenderManagerService)],x);var Oe=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Te=(e,t,r,n)=>{for(var i=n>1?void 0:n?ye(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&Oe(t,r,i),i},Q=(e,t)=>(r,n)=>t(r,n,e);d.UniverSheetsZenEditorPlugin=(M=class extends o.Plugin{constructor(t=V,r,n){super(),this._config=t,this._injector=r,this._configService=n;const{menu:i,...a}=o.merge({},V,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ee,a),this._initializeDependencies(this._injector)}_initializeDependencies(t){[[j],[x],[B,{useClass:de}]].forEach(n=>t.add(n))}onReady(){this._injector.get(j)}onSteady(){this._injector.get(x)}},T(M,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),T(M,"type",o.UniverInstanceType.UNIVER_SHEET),M),d.UniverSheetsZenEditorPlugin=Te([Q(1,o.Inject(o.Injector)),Q(2,o.IConfigService)],d.UniverSheetsZenEditorPlugin),d.CancelZenEditCommand=z,d.ConfirmZenEditCommand=b,d.OpenZenEditorCommand=D,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.5.
|
|
3
|
+
"version": "0.5.2-nightly.202412281605",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Zen Editor plugin for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -56,23 +56,23 @@
|
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@univerjs/icons": "^0.2.8",
|
|
58
58
|
"clsx": "^2.1.1",
|
|
59
|
-
"@univerjs/core": "0.5.
|
|
60
|
-
"@univerjs/docs-ui": "0.5.
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/ui": "0.5.
|
|
64
|
-
"@univerjs/
|
|
59
|
+
"@univerjs/core": "0.5.2-nightly.202412281605",
|
|
60
|
+
"@univerjs/docs-ui": "0.5.2-nightly.202412281605",
|
|
61
|
+
"@univerjs/engine-render": "0.5.2-nightly.202412281605",
|
|
62
|
+
"@univerjs/sheets": "0.5.2-nightly.202412281605",
|
|
63
|
+
"@univerjs/sheets-ui": "0.5.2-nightly.202412281605",
|
|
64
|
+
"@univerjs/ui": "0.5.2-nightly.202412281605"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"less": "^4.2.1",
|
|
68
68
|
"postcss": "^8.4.49",
|
|
69
69
|
"react": "18.3.1",
|
|
70
70
|
"rxjs": "^7.8.1",
|
|
71
|
-
"tailwindcss": "^3.4.
|
|
71
|
+
"tailwindcss": "^3.4.16",
|
|
72
72
|
"typescript": "^5.7.2",
|
|
73
|
-
"vite": "^6.0.
|
|
74
|
-
"vitest": "^2.1.
|
|
75
|
-
"@univerjs-infra/shared": "0.5.
|
|
73
|
+
"vite": "^6.0.3",
|
|
74
|
+
"vitest": "^2.1.8",
|
|
75
|
+
"@univerjs-infra/shared": "0.5.2"
|
|
76
76
|
},
|
|
77
77
|
"space": {
|
|
78
78
|
".": {
|
package/LICENSE
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|