@univerjs/sheets-zen-editor 0.5.5 → 0.6.0-experimental.20250125-1d060b9

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,9 +1 @@
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 s=require("@univerjs/core"),N=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"),U={id:"zen-editor.command.open-zen-editor",type:s.CommandType.COMMAND,handler:async e=>{var R;const n=e.get(f.IZenZoneService),r=e.get(N.IEditorService),t=e.get(p.IEditorBridgeService),i=e.get(s.IUniverInstanceService),c=e.get(f.ISidebarService);c.visible&&(c.close(),await s.delayAnimationFrame()),n.open();const o=r.getEditor(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(o==null)return!1;const d=t.getLatestEditCellState();if(d==null)return!1;const a=(R=d.documentLayoutObject.documentModel)==null?void 0:R.getSnapshot();if(a==null)return!1;i.focusUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const{body:_,drawings:l,drawingsOrder:u,tableSource:E,settings:I}=s.Tools.deepClone(a),C={...o.getDocumentData(),body:_,drawings:l,drawingsOrder:u,tableSource:E,settings:I},m=[{startOffset:0,endOffset:0,collapsed:!0}];return o.focus(),o.setDocumentData(C,m),o.clearUndoRedoHistory(),!0}},M={id:"zen-editor.command.cancel-zen-edit",type:s.CommandType.COMMAND,handler:async e=>{const n=e.get(f.IZenZoneService),r=e.get(p.IEditorBridgeService),t=e.get(s.IUniverInstanceService),i=e.get(f.ISidebarService);i.visible&&(i.close(),await s.delayAnimationFrame()),n.close();const c=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);return c?(t.focusUnit(c.getUnitId()),r.refreshEditCellState(),!0):!1}},Z={id:"zen-editor.command.confirm-zen-edit",type:s.CommandType.COMMAND,handler:async e=>{var _;const n=e.get(f.IZenZoneService),r=e.get(p.IEditorBridgeService),t=e.get(s.IUniverInstanceService),i=e.get(N.IEditorService),c=e.get(f.ISidebarService);c.visible&&(c.close(),await s.delayAnimationFrame()),n.close();const o=i.getEditor(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(o==null)return!1;const d=e.get(W.IRenderManagerService),a=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(a){const l=a.getUnitId(),u=(_=d.getRenderById(l))==null?void 0:_.with(p.EditingRenderController);if(u){const E=s.Tools.deepClone(o.getDocumentData());E.documentStyle.documentFlavor=s.DocumentFlavor.UNSPECIFIED,u.submitCellData(new s.DocumentDataModel(E))}return t.focusUnit(a.getUnitId()),r.refreshEditCellState(),!0}return!1}},ne="sheets-zen-editor.config",L={};var j={exports:{}},T={};/**
2
- * @license React
3
- * react-jsx-runtime.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var $;function re(){if($)return T;$=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 o(d,a,_){var l,u={},E=null,I=null;_!==void 0&&(E=""+_),a.key!==void 0&&(E=""+a.key),a.ref!==void 0&&(I=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:E,ref:I,props:u,_owner:i.current}}return T.Fragment=r,T.jsx=o,T.jsxs=o,T}var F;function ie(){return F||(F=1,j.exports=re()),j.exports}var v=ie(),g=function(){return g=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},g.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,o=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},g({ref:n,className:d},o),c)});function K(e,n,r,t,i){return h.createElement(e.tag,g(g({key:n},se(e,r,i)),t),(ce(e,r).children||[]).map(function(c,o){return K(c,"".concat(n,"-").concat(e.tag,"-").concat(o),r,void 0,i)}))}function se(e,n,r){var t=g({},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 o=c[0],d=c[1];typeof d=="string"&&(t[o]=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)?g(g({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&t&&t.indexOf(i.attrs.id)>-1?g(g({},i),{attrs:g(g({},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=s.createIdentifier("univer.sheet-zen-editor-manager.service"),fe="univer-zen-editor",_e="univer-zen-editor-icon-wrapper",ge="univer-zen-editor-icon-container",Ee="univer-zen-editor-icon-success",he="univer-zen-editor-icon-error",Ie="univer-zen-editor-canvas-container",S={zenEditor:fe,zenEditorIconWrapper:_e,zenEditorIconContainer:ge,zenEditorIconSuccess:Ee,zenEditorIconError:he,zenEditorCanvasContainer:Ie},me="ZEN_EDITOR_PLUGIN_",ve=`${me}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 pe(){const e=h.useRef(null),n=s.useDependency(B),r=s.useDependency(N.IEditorService),t=s.useDependency(s.ICommandService);h.useEffect(()=>{const o=e.current;if(!o)return;const d=r.register({editorUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:Se,scrollBar:!0,backScrollOffset:100},o),a=new ResizeObserver(()=>{n.setPosition(o.getBoundingClientRect())});return a.observe(o),()=>{d.dispose(),a.unobserve(o)}},[]);function i(){const o=r.getEditor(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);o==null||o.blur(),t.executeCommand(M.id)}function c(){const o=r.getEditor(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);o==null||o.blur(),t.executeCommand(Z.id)}return v.jsxs("div",{className:S.zenEditor,children:[v.jsxs("div",{className:S.zenEditorIconWrapper,children:[v.jsx("span",{className:k(S.zenEditorIconContainer,S.zenEditorIconError),onClick:i,children:v.jsx(G,{style:{fontSize:"22px"}})}),v.jsx("span",{className:k(S.zenEditorIconContainer,S.zenEditorIconSuccess),onClick:c,children:v.jsx(H,{style:{fontSize:"22px"}})})]}),v.jsx("div",{className:S.zenEditorCanvasContainer,ref:e})]})}function Ce(e){return{id:U.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]:{[U.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},Te={id:M.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(s.FOCUSING_DOC)&&e.getContextValue(s.FOCUSING_UNIVER_EDITOR)&&e.getContextValue(s.EDITOR_ACTIVATED)&&!e.getContextValue(s.FOCUSING_EDITOR_STANDALONE)}var Ne=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Re=(e,n,r,t)=>{for(var i=t>1?void 0:t?De(n,r):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(t?o(n,r,i):o(i))||i);return t&&i&&Ne(n,r,i),i},b=(e,n)=>(r,t)=>n(r,t,e);let P=class extends s.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(ve,pe))}_initCommands(){[U,M,Z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Oe)}_initShortcuts(){[ye,Te].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}};P=Re([b(0,f.IZenZoneService),b(1,s.ICommandService),b(2,f.IMenuManagerService),b(3,f.IShortcutService)],P);var be=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,o;c>=0;c--)(o=e[c])&&(i=(t?o(n,r,i):o(i))||i);return t&&i&&be(n,r,i),i},V=(e,n)=>(r,t)=>n(r,t,e);let x=class extends s.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(s.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:o,pageMarginLeft:d,pageMarginTop:a}=n;if(i==null||c===Number.POSITIVE_INFINITY||o===Number.POSITIVE_INFINITY)return;const{width:_,height:l}=i;let u=0;const E=a;let I=0,D=0,C=Number.POSITIVE_INFINITY;const{scaleX:m,scaleY:R}=r.getAncestorScale();_>(c+d*2)*m?(u=_/2-c*m/2,u/=m,I=(_-d*2)/m,C=0):(u=d,I=c+d*2,C=(I-_/m)/2),l>o?D=(l-a*2)/R:D=o+a*2,r.resize(I,D),n.translate(u,E),t.translate(u,E);const w=r.getViewport(N.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(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:r.with(N.DocBackScrollRenderController),n={startOffset:0,endOffset:0};e&&e.scrollToRange(n)}};x=Pe([V(0,B),V(1,W.IRenderManagerService)],x);var xe=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Me=(e,n,r,t)=>{for(var i=t>1?void 0:t?Ue(n,r):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(t?o(n,r,i):o(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 s.Plugin{constructor(n=L,r,t){super(),this._config=n,this._injector=r,this._configService=t;const{menu:i,...c}=s.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",s.UniverInstanceType.UNIVER_SHEET),z);exports.UniverSheetsZenEditorPlugin=Me([Y(1,s.Inject(s.Injector)),Y(2,s.IConfigService)],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=M;exports.ConfirmZenEditCommand=Z;exports.OpenZenEditorCommand=U;
1
+ "use strict";var G=Object.defineProperty;var X=(e,n,r)=>n in e?G(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var O=(e,n,r)=>X(e,typeof n!="symbol"?n+"":n,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),N=require("@univerjs/docs-ui"),$=require("@univerjs/engine-render"),S=require("@univerjs/sheets-ui"),l=require("@univerjs/ui"),E=require("react/jsx-runtime"),_=require("react"),V=require("rxjs"),T=require("@univerjs/sheets"),M={id:"zen-editor.command.open-zen-editor",type:s.CommandType.COMMAND,handler:async e=>{var D;const n=e.get(l.IZenZoneService),r=e.get(N.IEditorService),t=e.get(S.IEditorBridgeService),i=e.get(s.IUniverInstanceService),c=e.get(l.ISidebarService);c.visible&&(c.close(),await s.delayAnimationFrame()),n.open();const o=r.getEditor(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(o==null)return!1;const a=t.getLatestEditCellState();if(a==null)return!1;const d=(D=a.documentLayoutObject.documentModel)==null?void 0:D.getSnapshot();if(d==null)return!1;i.focusUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const{body:g,drawings:m,drawingsOrder:f,tableSource:I,settings:p}=s.Tools.deepClone(d),C={...o.getDocumentData(),body:g,drawings:m,drawingsOrder:f,tableSource:I,settings:p},h=[{startOffset:0,endOffset:0,collapsed:!0}];return o.focus(),o.setDocumentData(C,h),o.clearUndoRedoHistory(),!0}},U={id:"zen-editor.command.cancel-zen-edit",type:s.CommandType.COMMAND,handler:async e=>{const n=e.get(l.IZenZoneService),r=e.get(S.IEditorBridgeService),t=e.get(s.IUniverInstanceService),i=e.get(l.ISidebarService);i.visible&&(i.close(),await s.delayAnimationFrame()),n.close();const c=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);return c?(t.focusUnit(c.getUnitId()),r.refreshEditCellState(),!0):!1}},Z={id:"zen-editor.command.confirm-zen-edit",type:s.CommandType.COMMAND,handler:async e=>{var g;const n=e.get(l.IZenZoneService),r=e.get(S.IEditorBridgeService),t=e.get(s.IUniverInstanceService),i=e.get(N.IEditorService),c=e.get(l.ISidebarService);c.visible&&(c.close(),await s.delayAnimationFrame()),n.close();const o=i.getEditor(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(o==null)return!1;const a=e.get($.IRenderManagerService),d=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(d){const m=d.getUnitId(),f=(g=a.getRenderById(m))==null?void 0:g.with(S.EditingRenderController);if(f){const I=s.Tools.deepClone(o.getDocumentData());I.documentStyle.documentFlavor=s.DocumentFlavor.UNSPECIFIED,f.submitCellData(new s.DocumentDataModel(I))}return t.focusUnit(d.getUnitId()),r.refreshEditCellState(),!0}return!1}},J="sheets-zen-editor.config",A={};var u=function(){return u=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},u.apply(this,arguments)},Q=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},w=_.forwardRef(function(e,n){var r=e.icon,t=e.id,i=e.className,c=e.extend,o=Q(e,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(t," ").concat(i||"").trim(),d=_.useRef("_".concat(ne()));return Y(r,"".concat(t),{defIds:r.defIds,idSuffix:d.current},u({ref:n,className:a},o),c)});function Y(e,n,r,t,i){return _.createElement(e.tag,u(u({key:n},ee(e,r,i)),t),(te(e,r).children||[]).map(function(c,o){return Y(c,"".concat(n,"-").concat(e.tag,"-").concat(o),r,void 0,i)}))}function ee(e,n,r){var t=u({},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 o=c[0],a=c[1];typeof a=="string"&&(t[o]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function te(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)?u(u({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&t&&t.indexOf(i.attrs.id)>-1?u(u({},i),{attrs:u(u({},i.attrs),{id:i.attrs.id+n.idSuffix})}):i})}):e}function ne(){return Math.random().toString(36).substring(2,8)}w.displayName="UniverIcon";var re={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=_.forwardRef(function(e,n){return _.createElement(w,Object.assign({},e,{id:"check-mark-single",ref:n,icon:re}))});k.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=_.forwardRef(function(e,n){return _.createElement(w,Object.assign({},e,{id:"close-single",ref:n,icon:ie}))});W.displayName="CloseSingle";function K(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=K(e[n]))&&(t&&(t+=" "),t+=r)}else for(r in e)e[r]&&(t&&(t+=" "),t+=r);return t}function B(){for(var e,n,r=0,t="",i=arguments.length;r<i;r++)(e=arguments[r])&&(n=K(e))&&(t&&(t+=" "),t+=n);return t}class oe{constructor(){O(this,"_position",null);O(this,"_position$",new V.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 j=s.createIdentifier("univer.sheet-zen-editor-manager.service"),se="univer-zen-editor",ce="univer-zen-editor-icon-wrapper",ae="univer-zen-editor-icon-container",de="univer-zen-editor-icon-success",le="univer-zen-editor-icon-error",ue="univer-zen-editor-canvas-container",v={zenEditor:se,zenEditorIconWrapper:ce,zenEditorIconContainer:ae,zenEditorIconSuccess:de,zenEditorIconError:le,zenEditorCanvasContainer:ue},fe="ZEN_EDITOR_PLUGIN_",ge=`${fe}ZEN_EDITOR_COMPONENT`,_e={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 Ie(){const e=_.useRef(null),n=s.useDependency(j),r=s.useDependency(N.IEditorService),t=s.useDependency(s.ICommandService);_.useEffect(()=>{const o=e.current;if(!o)return;const a=r.register({editorUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:_e,scrollBar:!0,backScrollOffset:100},o),d=new ResizeObserver(()=>{n.setPosition(o.getBoundingClientRect())});return d.observe(o),()=>{a.dispose(),d.unobserve(o)}},[]);function i(){const o=r.getEditor(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);o==null||o.blur(),t.executeCommand(U.id)}function c(){const o=r.getEditor(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);o==null||o.blur(),t.executeCommand(Z.id)}return E.jsxs("div",{className:v.zenEditor,children:[E.jsxs("div",{className:v.zenEditorIconWrapper,children:[E.jsx("span",{className:B(v.zenEditorIconContainer,v.zenEditorIconError),onClick:i,children:E.jsx(W,{style:{fontSize:"22px"}})}),E.jsx("span",{className:B(v.zenEditorIconContainer,v.zenEditorIconSuccess),onClick:c,children:E.jsx(k,{style:{fontSize:"22px"}})})]}),E.jsx("div",{className:v.zenEditorCanvasContainer,ref:e})]})}function he(e){return{id:M.id,type:l.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",hidden$:S.getCurrentExclusiveRangeInterest$(e),disabled$:S.getCurrentRangeDisable$(e,{workbookTypes:[T.WorkbookEditablePermission],worksheetTypes:[T.WorksheetEditPermission,T.WorksheetSetCellValuePermission,T.WorksheetSetCellStylePermission],rangeTypes:[T.RangeProtectionPermissionEditPoint]})}}const Ee={[l.ContextMenuPosition.MAIN_AREA]:{[l.ContextMenuGroup.OTHERS]:{[M.id]:{order:2,menuItemFactory:he}}}},ve={id:Z.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:e=>H(e),binding:l.KeyCode.ENTER|l.MetaKeys.ALT},Se={id:U.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:e=>H(e),binding:l.KeyCode.ESC};function H(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 me=Object.defineProperty,pe=Object.getOwnPropertyDescriptor,Ce=(e,n,r,t)=>{for(var i=t>1?void 0:t?pe(n,r):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(t?o(n,r,i):o(i))||i);return t&&i&&me(n,r,i),i},b=(e,n)=>(r,t)=>n(r,t,e);let R=class extends s.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(ge,Ie))}_initCommands(){[M,U,Z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Ee)}_initShortcuts(){[ve,Se].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}};R=Ce([b(0,l.IZenZoneService),b(1,s.ICommandService),b(2,l.IMenuManagerService),b(3,l.IShortcutService)],R);var Oe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,Ne=(e,n,r,t)=>{for(var i=t>1?void 0:t?Te(n,r):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(t?o(n,r,i):o(i))||i);return t&&i&&Oe(n,r,i),i},L=(e,n)=>(r,t)=>n(r,t,e);let P=class extends s.RxDisposable{constructor(e,n){super(),this._zenEditorManagerService=e,this._renderManagerService=n,this._initialize()}_initialize(){this._syncZenEditorSize()}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(V.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{width:n,height:r}=e,t=S.getEditorObject(s.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:o,pageMarginLeft:a,pageMarginTop:d}=n;if(i==null||c===Number.POSITIVE_INFINITY||o===Number.POSITIVE_INFINITY)return;const{width:g,height:m}=i;let f=0;const I=d;let p=0,y=0,C=Number.POSITIVE_INFINITY;const{scaleX:h,scaleY:D}=r.getAncestorScale();g>(c+a*2)*h?(f=g/2-c*h/2,f/=h,p=(g-a*2)/h,C=0):(f=a,p=c+a*2,C=(p-g/h)/2),m>o?y=(m-d*2)/D:y=o+d*2,r.resize(p,y),n.translate(f,I),t.translate(f,I);const x=r.getViewport(N.VIEWPORT_KEY.VIEW_MAIN);if(C!==Number.POSITIVE_INFINITY&&x!=null){const q=x.transScroll2ViewportScrollValue(C,0).x;x.scrollToBarPos({x:q})}return this}_scrollToTop(){var r;const e=(r=this._renderManagerService.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:r.with(N.DocBackScrollRenderController),n={startOffset:0,endOffset:0};e&&e.scrollToRange(n)}};P=Ne([L(0,j),L(1,$.IRenderManagerService)],P);var ye=Object.defineProperty,De=Object.getOwnPropertyDescriptor,be=(e,n,r,t)=>{for(var i=t>1?void 0:t?De(n,r):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(t?o(n,r,i):o(i))||i);return t&&i&&ye(n,r,i),i},F=(e,n)=>(r,t)=>n(r,t,e),z;exports.UniverSheetsZenEditorPlugin=(z=class extends s.Plugin{constructor(n=A,r,t){super(),this._config=n,this._injector=r,this._configService=t;const{menu:i,...c}=s.merge({},A,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(J,c),this._initializeDependencies(this._injector)}_initializeDependencies(n){[[R],[P],[j,{useClass:oe}]].forEach(t=>n.add(t))}onReady(){this._injector.get(R)}onSteady(){this._injector.get(P)}},O(z,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),O(z,"type",s.UniverInstanceType.UNIVER_SHEET),z);exports.UniverSheetsZenEditorPlugin=be([F(1,s.Inject(s.Injector)),F(2,s.IConfigService)],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=U;exports.ConfirmZenEditCommand=Z;exports.OpenZenEditorCommand=M;
package/lib/es/facade.js CHANGED
@@ -99,6 +99,9 @@ class T extends k {
99
99
  }
100
100
  }));
101
101
  }
102
+ /**
103
+ * @ignore
104
+ */
102
105
  _initialize(t) {
103
106
  this._initSheetZenEditorEvent(t);
104
107
  }
package/lib/es/index.js CHANGED
@@ -1,183 +1,156 @@
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 m, 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 L, MenuItemType as De, ContextMenuPosition as we, ContextMenuGroup as je, KeyCode as re, MetaKeys as Ue, IMenuManagerService as Ze, IShortcutService as Le } from "@univerjs/ui";
9
- import Ae, { forwardRef as A, 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";
1
+ var ae = Object.defineProperty;
2
+ var de = (e, n, r) => n in e ? ae(e, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[n] = r;
3
+ var E = (e, n, r) => de(e, typeof n != "symbol" ? n + "" : n, r);
4
+ import { CommandType as M, IUniverInstanceService as D, delayAnimationFrame as R, DOCS_ZEN_EDITOR_UNIT_ID_KEY as f, Tools as X, UniverInstanceType as w, DocumentFlavor as q, DocumentDataModel as le, createIdentifier as ue, DEFAULT_EMPTY_DOCUMENT_VALUE as fe, useDependency as P, ICommandService as J, FOCUSING_DOC as ge, FOCUSING_UNIVER_EDITOR as he, EDITOR_ACTIVATED as me, FOCUSING_EDITOR_STANDALONE as pe, Disposable as ve, RxDisposable as _e, Plugin as Ee, merge as Se, Inject as Ie, Injector as Ce, IConfigService as Oe } from "@univerjs/core";
5
+ import { IEditorService as x, VIEWPORT_KEY as Ne, DocBackScrollRenderController as ye } from "@univerjs/docs-ui";
6
+ import { IRenderManagerService as Q } from "@univerjs/engine-render";
7
+ import { IEditorBridgeService as U, EditingRenderController as be, getCurrentExclusiveRangeInterest$ as Te, getCurrentRangeDisable$ as ze, getEditorObject as Pe } from "@univerjs/sheets-ui";
8
+ import { IZenZoneService as T, ISidebarService as j, MenuItemType as Me, ContextMenuPosition as De, ContextMenuGroup as Re, KeyCode as ee, MetaKeys as we, IMenuManagerService as xe, IShortcutService as Ue } from "@univerjs/ui";
9
+ import { jsxs as k, jsx as S } from "react/jsx-runtime";
10
+ import { forwardRef as Z, useRef as te, createElement as A, useEffect as je } from "react";
11
+ import { BehaviorSubject as Ze, takeUntil as Ae } from "rxjs";
12
+ import { WorkbookEditablePermission as Be, WorksheetEditPermission as Le, WorksheetSetCellValuePermission as $e, WorksheetSetCellStylePermission as Ve, RangeProtectionPermissionEditPoint as Fe } from "@univerjs/sheets";
12
13
  const B = {
13
14
  id: "zen-editor.command.open-zen-editor",
14
15
  type: M.COMMAND,
15
16
  handler: async (e) => {
16
- var O;
17
- const n = e.get(R), r = e.get(U), t = e.get(Z), i = e.get(D), s = e.get(L);
18
- s.visible && (s.close(), await w()), n.open();
19
- const o = r.getEditor(m);
17
+ var C;
18
+ const n = e.get(T), r = e.get(x), t = e.get(U), i = e.get(D), s = e.get(j);
19
+ s.visible && (s.close(), await R()), n.open();
20
+ const o = r.getEditor(f);
20
21
  if (o == null)
21
22
  return !1;
22
- const a = t.getLatestEditCellState();
23
- if (a == null)
24
- return !1;
25
- const c = (O = a.documentLayoutObject.documentModel) == null ? void 0 : O.getSnapshot();
23
+ const c = t.getLatestEditCellState();
26
24
  if (c == null)
27
25
  return !1;
28
- i.focusUnit(m);
29
- const { body: u, drawings: d, drawingsOrder: l, tableSource: g, settings: h } = Q.deepClone(c), E = {
26
+ const a = (C = c.documentLayoutObject.documentModel) == null ? void 0 : C.getSnapshot();
27
+ if (a == null)
28
+ return !1;
29
+ i.focusUnit(f);
30
+ const { body: u, drawings: p, drawingsOrder: l, tableSource: g, settings: v } = X.deepClone(a), _ = {
30
31
  ...o.getDocumentData(),
31
32
  body: u,
32
- drawings: d,
33
+ drawings: p,
33
34
  drawingsOrder: l,
34
35
  tableSource: g,
35
- settings: h
36
- }, _ = [
36
+ settings: v
37
+ }, h = [
37
38
  {
38
39
  startOffset: 0,
39
40
  endOffset: 0,
40
41
  collapsed: !0
41
42
  }
42
43
  ];
43
- return o.focus(), o.setDocumentData(E, _), o.clearUndoRedoHistory(), !0;
44
+ return o.focus(), o.setDocumentData(_, h), o.clearUndoRedoHistory(), !0;
44
45
  }
45
- }, k = {
46
+ }, L = {
46
47
  id: "zen-editor.command.cancel-zen-edit",
47
48
  type: M.COMMAND,
48
49
  handler: async (e) => {
49
- const n = e.get(R), r = e.get(Z), t = e.get(D), i = e.get(L);
50
- i.visible && (i.close(), await w()), n.close();
51
- const s = t.getCurrentUnitForType(j.UNIVER_SHEET);
50
+ const n = e.get(T), r = e.get(U), t = e.get(D), i = e.get(j);
51
+ i.visible && (i.close(), await R()), n.close();
52
+ const s = t.getCurrentUnitForType(w.UNIVER_SHEET);
52
53
  return s ? (t.focusUnit(s.getUnitId()), r.refreshEditCellState(), !0) : !1;
53
54
  }
54
- }, F = {
55
+ }, $ = {
55
56
  id: "zen-editor.command.confirm-zen-edit",
56
57
  type: M.COMMAND,
57
58
  handler: async (e) => {
58
59
  var u;
59
- const n = e.get(R), r = e.get(Z), t = e.get(D), i = e.get(U), s = e.get(L);
60
- s.visible && (s.close(), await w()), n.close();
61
- const o = i.getEditor(m);
60
+ const n = e.get(T), r = e.get(U), t = e.get(D), i = e.get(x), s = e.get(j);
61
+ s.visible && (s.close(), await R()), n.close();
62
+ const o = i.getEditor(f);
62
63
  if (o == null)
63
64
  return !1;
64
- const a = e.get(ne), c = t.getCurrentUnitForType(j.UNIVER_SHEET);
65
- if (c) {
66
- const d = c.getUnitId(), l = (u = a.getRenderById(d)) == null ? void 0 : u.with(ze);
65
+ const c = e.get(Q), a = t.getCurrentUnitForType(w.UNIVER_SHEET);
66
+ if (a) {
67
+ const p = a.getUnitId(), l = (u = c.getRenderById(p)) == null ? void 0 : u.with(be);
67
68
  if (l) {
68
- const g = Q.deepClone(o.getDocumentData());
69
- g.documentStyle.documentFlavor = ee.UNSPECIFIED, l.submitCellData(new ge(g));
69
+ const g = X.deepClone(o.getDocumentData());
70
+ g.documentStyle.documentFlavor = q.UNSPECIFIED, l.submitCellData(new le(g));
70
71
  }
71
- return t.focusUnit(c.getUnitId()), r.refreshEditCellState(), !0;
72
+ return t.focusUnit(a.getUnitId()), r.refreshEditCellState(), !0;
72
73
  }
73
74
  return !1;
74
75
  }
75
- }, Ge = "sheets-zen-editor.config", H = {};
76
- var P = { exports: {} }, I = {};
77
- /**
78
- * @license React
79
- * react-jsx-runtime.production.min.js
80
- *
81
- * Copyright (c) Facebook, Inc. and its affiliates.
82
- *
83
- * This source code is licensed under the MIT license found in the
84
- * LICENSE file in the root directory of this source tree.
85
- */
86
- var Y;
87
- function qe() {
88
- if (Y) return I;
89
- Y = 1;
90
- var e = Ae, 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
- function o(a, c, u) {
92
- var d, l = {}, g = null, h = null;
93
- u !== void 0 && (g = "" + u), c.key !== void 0 && (g = "" + c.key), c.ref !== void 0 && (h = c.ref);
94
- for (d in c) t.call(c, d) && !s.hasOwnProperty(d) && (l[d] = c[d]);
95
- if (a && a.defaultProps) for (d in c = a.defaultProps, c) l[d] === void 0 && (l[d] = c[d]);
96
- return { $$typeof: n, type: a, key: g, ref: h, props: l, _owner: i.current };
97
- }
98
- return I.Fragment = r, I.jsx = o, I.jsxs = o, I;
99
- }
100
- var G;
101
- function Je() {
102
- return G || (G = 1, P.exports = qe()), P.exports;
103
- }
104
- var p = Je(), f = function() {
105
- return f = Object.assign || function(e) {
76
+ }, ke = "sheets-zen-editor.config", W = {};
77
+ var d = function() {
78
+ return d = Object.assign || function(e) {
106
79
  for (var n, r = 1, t = arguments.length; r < t; r++) {
107
80
  n = arguments[r];
108
81
  for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && (e[i] = n[i]);
109
82
  }
110
83
  return e;
111
- }, f.apply(this, arguments);
112
- }, Ke = function(e, n) {
84
+ }, d.apply(this, arguments);
85
+ }, We = function(e, n) {
113
86
  var r = {};
114
87
  for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && n.indexOf(t) < 0 && (r[t] = e[t]);
115
88
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
116
89
  for (var i = 0, t = Object.getOwnPropertySymbols(e); i < t.length; i++)
117
90
  n.indexOf(t[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[i]) && (r[t[i]] = e[t[i]]);
118
91
  return r;
119
- }, V = A(function(e, n) {
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);
92
+ }, V = Z(function(e, n) {
93
+ var r = e.icon, t = e.id, i = e.className, s = e.extend, o = We(e, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(t, " ").concat(i || "").trim(), a = te("_".concat(Ge()));
94
+ return ne(r, "".concat(t), { defIds: r.defIds, idSuffix: a.current }, d({ ref: n, className: c }, o), s);
122
95
  });
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);
96
+ function ne(e, n, r, t, i) {
97
+ return A(e.tag, d(d({ key: n }, He(e, r, i)), t), (Ye(e, r).children || []).map(function(s, o) {
98
+ return ne(s, "".concat(n, "-").concat(e.tag, "-").concat(o), r, void 0, i);
126
99
  }));
127
100
  }
128
- function Xe(e, n, r) {
129
- var t = f({}, e.attrs);
101
+ function He(e, n, r) {
102
+ var t = d({}, e.attrs);
130
103
  r != null && r.colorChannel1 && t.fill === "colorChannel1" && (t.fill = r.colorChannel1);
131
104
  var i = n.defIds;
132
105
  return !i || i.length === 0 || (e.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + n.idSuffix), Object.entries(t).forEach(function(s) {
133
- var o = s[0], a = s[1];
134
- typeof a == "string" && (t[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(n.idSuffix, ")")));
106
+ var o = s[0], c = s[1];
107
+ typeof c == "string" && (t[o] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(n.idSuffix, ")")));
135
108
  })), t;
136
109
  }
137
- function Qe(e, n) {
110
+ function Ye(e, n) {
138
111
  var r, t = n.defIds;
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
- 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;
112
+ return !t || t.length === 0 ? e : e.tag === "defs" && (!((r = e.children) === null || r === void 0) && r.length) ? d(d({}, e), { children: e.children.map(function(i) {
113
+ return typeof i.attrs.id == "string" && t && t.indexOf(i.attrs.id) > -1 ? d(d({}, i), { attrs: d(d({}, i.attrs), { id: i.attrs.id + n.idSuffix }) }) : i;
141
114
  }) }) : e;
142
115
  }
143
- function et() {
116
+ function Ge() {
144
117
  return Math.random().toString(36).substring(2, 8);
145
118
  }
146
119
  V.displayName = "UniverIcon";
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 = A(function(e, n) {
148
- return $(V, Object.assign({}, e, {
120
+ var Ke = { 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" } }] }, re = Z(function(e, n) {
121
+ return A(V, Object.assign({}, e, {
149
122
  id: "check-mark-single",
150
123
  ref: n,
151
- icon: tt
124
+ icon: Ke
152
125
  }));
153
126
  });
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 = A(function(e, n) {
156
- return $(V, Object.assign({}, e, {
127
+ re.displayName = "CheckMarkSingle";
128
+ var Xe = { 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" } }] }, ie = Z(function(e, n) {
129
+ return A(V, Object.assign({}, e, {
157
130
  id: "close-single",
158
131
  ref: n,
159
- icon: nt
132
+ icon: Xe
160
133
  }));
161
134
  });
162
- ce.displayName = "CloseSingle";
163
- function ae(e) {
135
+ ie.displayName = "CloseSingle";
136
+ function oe(e) {
164
137
  var n, r, t = "";
165
138
  if (typeof e == "string" || typeof e == "number") t += e;
166
139
  else if (typeof e == "object") if (Array.isArray(e)) {
167
140
  var i = e.length;
168
- for (n = 0; n < i; n++) e[n] && (r = ae(e[n])) && (t && (t += " "), t += r);
141
+ for (n = 0; n < i; n++) e[n] && (r = oe(e[n])) && (t && (t += " "), t += r);
169
142
  } else for (r in e) e[r] && (t && (t += " "), t += r);
170
143
  return t;
171
144
  }
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);
145
+ function H() {
146
+ for (var e, n, r = 0, t = "", i = arguments.length; r < i; r++) (e = arguments[r]) && (n = oe(e)) && (t && (t += " "), t += n);
174
147
  return t;
175
148
  }
176
- class rt {
149
+ class qe {
177
150
  constructor() {
178
- S(this, "_position", null);
179
- S(this, "_position$", new Be(null));
180
- S(this, "position$", this._position$.asObservable());
151
+ E(this, "_position", null);
152
+ E(this, "_position$", new Ze(null));
153
+ E(this, "position$", this._position$.asObservable());
181
154
  }
182
155
  dispose() {
183
156
  this._position$.complete(), this._position = null;
@@ -192,19 +165,19 @@ class rt {
192
165
  this._position$.next(n);
193
166
  }
194
167
  }
195
- const W = he(
168
+ const F = ue(
196
169
  "univer.sheet-zen-editor-manager.service"
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", dt = "univer-zen-editor-canvas-container", v = {
198
- zenEditor: it,
199
- zenEditorIconWrapper: ot,
200
- zenEditorIconContainer: st,
201
- zenEditorIconSuccess: ct,
202
- zenEditorIconError: at,
203
- zenEditorCanvasContainer: dt
204
- }, lt = "ZEN_EDITOR_PLUGIN_", ut = `${lt}ZEN_EDITOR_COMPONENT`, ft = {
205
- id: m,
170
+ ), Je = "univer-zen-editor", Qe = "univer-zen-editor-icon-wrapper", et = "univer-zen-editor-icon-container", tt = "univer-zen-editor-icon-success", nt = "univer-zen-editor-icon-error", rt = "univer-zen-editor-canvas-container", m = {
171
+ zenEditor: Je,
172
+ zenEditorIconWrapper: Qe,
173
+ zenEditorIconContainer: et,
174
+ zenEditorIconSuccess: tt,
175
+ zenEditorIconError: nt,
176
+ zenEditorCanvasContainer: rt
177
+ }, it = "ZEN_EDITOR_PLUGIN_", ot = `${it}ZEN_EDITOR_COMPONENT`, st = {
178
+ id: f,
206
179
  body: {
207
- dataStream: `${me}`,
180
+ dataStream: `${fe}`,
208
181
  textRuns: [],
209
182
  tables: [],
210
183
  customBlocks: [],
@@ -223,7 +196,7 @@ const W = he(
223
196
  width: 595,
224
197
  height: Number.POSITIVE_INFINITY
225
198
  },
226
- documentFlavor: ee.MODERN,
199
+ documentFlavor: q.MODERN,
227
200
  marginTop: 0,
228
201
  marginBottom: 0,
229
202
  marginRight: 0,
@@ -236,98 +209,98 @@ const W = he(
236
209
  drawings: {},
237
210
  drawingsOrder: []
238
211
  };
239
- function gt() {
240
- const e = ie(null), n = x(W), r = x(U), t = x(te);
241
- $e(() => {
212
+ function ct() {
213
+ const e = te(null), n = P(F), r = P(x), t = P(J);
214
+ je(() => {
242
215
  const o = e.current;
243
216
  if (!o)
244
217
  return;
245
- const a = r.register(
218
+ const c = r.register(
246
219
  {
247
- editorUnitId: m,
248
- initialSnapshot: ft,
220
+ editorUnitId: f,
221
+ initialSnapshot: st,
249
222
  scrollBar: !0,
250
223
  backScrollOffset: 100
251
224
  },
252
225
  o
253
- ), c = new ResizeObserver(() => {
226
+ ), a = new ResizeObserver(() => {
254
227
  n.setPosition(o.getBoundingClientRect());
255
228
  });
256
- return c.observe(o), () => {
257
- a.dispose(), c.unobserve(o);
229
+ return a.observe(o), () => {
230
+ c.dispose(), a.unobserve(o);
258
231
  };
259
232
  }, []);
260
233
  function i() {
261
- const o = r.getEditor(m);
262
- o == null || o.blur(), t.executeCommand(k.id);
234
+ const o = r.getEditor(f);
235
+ o == null || o.blur(), t.executeCommand(L.id);
263
236
  }
264
237
  function s() {
265
- const o = r.getEditor(m);
266
- o == null || o.blur(), t.executeCommand(F.id);
238
+ const o = r.getEditor(f);
239
+ o == null || o.blur(), t.executeCommand($.id);
267
240
  }
268
- return /* @__PURE__ */ p.jsxs("div", { className: v.zenEditor, children: [
269
- /* @__PURE__ */ p.jsxs("div", { className: v.zenEditorIconWrapper, children: [
270
- /* @__PURE__ */ p.jsx(
241
+ return /* @__PURE__ */ k("div", { className: m.zenEditor, children: [
242
+ /* @__PURE__ */ k("div", { className: m.zenEditorIconWrapper, children: [
243
+ /* @__PURE__ */ S(
271
244
  "span",
272
245
  {
273
- className: q(v.zenEditorIconContainer, v.zenEditorIconError),
246
+ className: H(m.zenEditorIconContainer, m.zenEditorIconError),
274
247
  onClick: i,
275
- children: /* @__PURE__ */ p.jsx(ce, { style: { fontSize: "22px" } })
248
+ children: /* @__PURE__ */ S(ie, { style: { fontSize: "22px" } })
276
249
  }
277
250
  ),
278
- /* @__PURE__ */ p.jsx(
251
+ /* @__PURE__ */ S(
279
252
  "span",
280
253
  {
281
- className: q(v.zenEditorIconContainer, v.zenEditorIconSuccess),
254
+ className: H(m.zenEditorIconContainer, m.zenEditorIconSuccess),
282
255
  onClick: s,
283
- children: /* @__PURE__ */ p.jsx(se, { style: { fontSize: "22px" } })
256
+ children: /* @__PURE__ */ S(re, { style: { fontSize: "22px" } })
284
257
  }
285
258
  )
286
259
  ] }),
287
- /* @__PURE__ */ p.jsx("div", { className: v.zenEditorCanvasContainer, ref: e })
260
+ /* @__PURE__ */ S("div", { className: m.zenEditorCanvasContainer, ref: e })
288
261
  ] });
289
262
  }
290
- function ht(e) {
263
+ function at(e) {
291
264
  return {
292
265
  id: B.id,
293
- type: De.BUTTON,
266
+ type: Me.BUTTON,
294
267
  title: "rightClick.zenEditor",
295
268
  icon: "AmplifySingle",
296
- hidden$: xe(e),
297
- disabled$: Pe(e, { workbookTypes: [Fe], worksheetTypes: [Ve, We, He], rangeTypes: [Ye] })
269
+ hidden$: Te(e),
270
+ disabled$: ze(e, { workbookTypes: [Be], worksheetTypes: [Le, $e, Ve], rangeTypes: [Fe] })
298
271
  };
299
272
  }
300
- const mt = {
301
- [we.MAIN_AREA]: {
302
- [je.OTHERS]: {
273
+ const dt = {
274
+ [De.MAIN_AREA]: {
275
+ [Re.OTHERS]: {
303
276
  [B.id]: {
304
277
  order: 2,
305
- menuItemFactory: ht
278
+ menuItemFactory: at
306
279
  }
307
280
  }
308
281
  }
309
- }, _t = {
310
- id: F.id,
282
+ }, lt = {
283
+ id: $.id,
311
284
  description: "shortcut.sheet.zen-edit-confirm",
312
285
  group: "4_sheet-edit",
313
- preconditions: (e) => de(e),
314
- binding: re.ENTER | Ue.ALT
315
- }, pt = {
316
- id: k.id,
286
+ preconditions: (e) => se(e),
287
+ binding: ee.ENTER | we.ALT
288
+ }, ut = {
289
+ id: L.id,
317
290
  description: "shortcut.sheet.zen-edit-cancel",
318
291
  group: "4_sheet-edit",
319
- preconditions: (e) => de(e),
320
- binding: re.ESC
292
+ preconditions: (e) => se(e),
293
+ binding: ee.ESC
321
294
  };
322
- function de(e) {
323
- return e.getContextValue(_e) && e.getContextValue(pe) && e.getContextValue(ve) && !e.getContextValue(Ee);
295
+ function se(e) {
296
+ return e.getContextValue(ge) && e.getContextValue(he) && e.getContextValue(me) && !e.getContextValue(pe);
324
297
  }
325
- var vt = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, St = (e, n, r, t) => {
326
- for (var i = t > 1 ? void 0 : t ? Et(n, r) : n, s = e.length - 1, o; s >= 0; s--)
298
+ var ft = Object.defineProperty, gt = Object.getOwnPropertyDescriptor, ht = (e, n, r, t) => {
299
+ for (var i = t > 1 ? void 0 : t ? gt(n, r) : n, s = e.length - 1, o; s >= 0; s--)
327
300
  (o = e[s]) && (i = (t ? o(n, r, i) : o(i)) || i);
328
- return t && i && vt(n, r, i), i;
329
- }, y = (e, n) => (r, t) => n(r, t, e);
330
- let b = class extends Se {
301
+ return t && i && ft(n, r, i), i;
302
+ }, O = (e, n) => (r, t) => n(r, t, e);
303
+ let y = class extends ve {
331
304
  constructor(e, n, r, t) {
332
305
  super(), this._zenZoneService = e, this._commandService = n, this._menuManagerService = r, this._shortcutService = t, this._initialize();
333
306
  }
@@ -335,34 +308,34 @@ let b = class extends Se {
335
308
  this._initCustomComponents(), this._initCommands(), this._initMenus(), this._initShortcuts();
336
309
  }
337
310
  _initCustomComponents() {
338
- this.disposeWithMe(this._zenZoneService.set(ut, gt));
311
+ this.disposeWithMe(this._zenZoneService.set(ot, ct));
339
312
  }
340
313
  _initCommands() {
341
- [B, k, F].forEach((e) => {
314
+ [B, L, $].forEach((e) => {
342
315
  this.disposeWithMe(this._commandService.registerCommand(e));
343
316
  });
344
317
  }
345
318
  _initMenus() {
346
- this._menuManagerService.mergeMenu(mt);
319
+ this._menuManagerService.mergeMenu(dt);
347
320
  }
348
321
  _initShortcuts() {
349
- [_t, pt].forEach((e) => {
322
+ [lt, ut].forEach((e) => {
350
323
  this.disposeWithMe(this._shortcutService.registerShortcut(e));
351
324
  });
352
325
  }
353
326
  };
354
- b = St([
355
- y(0, R),
356
- y(1, te),
357
- y(2, Ze),
358
- y(3, Le)
359
- ], b);
360
- var It = Object.defineProperty, Ct = Object.getOwnPropertyDescriptor, Ot = (e, n, r, t) => {
361
- for (var i = t > 1 ? void 0 : t ? Ct(n, r) : n, s = e.length - 1, o; s >= 0; s--)
327
+ y = ht([
328
+ O(0, T),
329
+ O(1, J),
330
+ O(2, xe),
331
+ O(3, Ue)
332
+ ], y);
333
+ var mt = Object.defineProperty, pt = Object.getOwnPropertyDescriptor, vt = (e, n, r, t) => {
334
+ for (var i = t > 1 ? void 0 : t ? pt(n, r) : n, s = e.length - 1, o; s >= 0; s--)
362
335
  (o = e[s]) && (i = (t ? o(n, r, i) : o(i)) || i);
363
- return t && i && It(n, r, i), i;
364
- }, J = (e, n) => (r, t) => n(r, t, e);
365
- let T = class extends Ie {
336
+ return t && i && mt(n, r, i), i;
337
+ }, Y = (e, n) => (r, t) => n(r, t, e);
338
+ let b = class extends _e {
366
339
  constructor(e, n) {
367
340
  super(), this._zenEditorManagerService = e, this._renderManagerService = n, this._initialize();
368
341
  }
@@ -371,83 +344,83 @@ let T = class extends Ie {
371
344
  }
372
345
  // Listen to changes in the size of the zen editor container to set the size of the editor.
373
346
  _syncZenEditorSize() {
374
- this._zenEditorManagerService.position$.pipe(ke(this.dispose$)).subscribe((e) => {
347
+ this._zenEditorManagerService.position$.pipe(Ae(this.dispose$)).subscribe((e) => {
375
348
  if (e == null)
376
349
  return;
377
- const { width: n, height: r } = e, t = Me(m, this._renderManagerService);
350
+ const { width: n, height: r } = e, t = Pe(f, this._renderManagerService);
378
351
  t != null && requestIdleCallback(() => {
379
352
  t.engine.resizeBySize(n, r), this._calculatePagePosition(t), this._scrollToTop();
380
353
  });
381
354
  });
382
355
  }
383
356
  _calculatePagePosition(e) {
384
- const { document: n, scene: r, docBackground: t } = e, i = r == null ? void 0 : r.getParent(), { width: s, height: o, pageMarginLeft: a, pageMarginTop: c } = n;
357
+ const { document: n, scene: r, docBackground: t } = e, i = r == null ? void 0 : r.getParent(), { width: s, height: o, pageMarginLeft: c, pageMarginTop: a } = n;
385
358
  if (i == null || s === Number.POSITIVE_INFINITY || o === Number.POSITIVE_INFINITY)
386
359
  return;
387
- const { width: u, height: d } = i;
360
+ const { width: u, height: p } = i;
388
361
  let l = 0;
389
- const g = c;
390
- let h = 0, C = 0, E = Number.POSITIVE_INFINITY;
391
- const { scaleX: _, scaleY: O } = r.getAncestorScale();
392
- u > (s + a * 2) * _ ? (l = u / 2 - s * _ / 2, l /= _, h = (u - a * 2) / _, E = 0) : (l = a, h = s + a * 2, E = (h - u / _) / 2), d > o ? C = (d - c * 2) / O : C = o + c * 2, r.resize(h, C), n.translate(l, g), t.translate(l, g);
393
- const z = r.getViewport(Te.VIEW_MAIN);
394
- if (E !== Number.POSITIVE_INFINITY && z != null) {
395
- const le = z.transScroll2ViewportScrollValue(E, 0).x;
362
+ const g = a;
363
+ let v = 0, I = 0, _ = Number.POSITIVE_INFINITY;
364
+ const { scaleX: h, scaleY: C } = r.getAncestorScale();
365
+ u > (s + c * 2) * h ? (l = u / 2 - s * h / 2, l /= h, v = (u - c * 2) / h, _ = 0) : (l = c, v = s + c * 2, _ = (v - u / h) / 2), p > o ? I = (p - a * 2) / C : I = o + a * 2, r.resize(v, I), n.translate(l, g), t.translate(l, g);
366
+ const z = r.getViewport(Ne.VIEW_MAIN);
367
+ if (_ !== Number.POSITIVE_INFINITY && z != null) {
368
+ const ce = z.transScroll2ViewportScrollValue(_, 0).x;
396
369
  z.scrollToBarPos({
397
- x: le
370
+ x: ce
398
371
  });
399
372
  }
400
373
  return this;
401
374
  }
402
375
  _scrollToTop() {
403
376
  var r;
404
- const e = (r = this._renderManagerService.getRenderById(m)) == null ? void 0 : r.with(Re), n = {
377
+ const e = (r = this._renderManagerService.getRenderById(f)) == null ? void 0 : r.with(ye), n = {
405
378
  startOffset: 0,
406
379
  endOffset: 0
407
380
  };
408
381
  e && e.scrollToRange(n);
409
382
  }
410
383
  };
411
- T = Ot([
412
- J(0, W),
413
- J(1, ne)
414
- ], T);
415
- var yt = Object.defineProperty, Nt = Object.getOwnPropertyDescriptor, bt = (e, n, r, t) => {
416
- for (var i = t > 1 ? void 0 : t ? Nt(n, r) : n, s = e.length - 1, o; s >= 0; s--)
384
+ b = vt([
385
+ Y(0, F),
386
+ Y(1, Q)
387
+ ], b);
388
+ var _t = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, St = (e, n, r, t) => {
389
+ for (var i = t > 1 ? void 0 : t ? Et(n, r) : n, s = e.length - 1, o; s >= 0; s--)
417
390
  (o = e[s]) && (i = (t ? o(n, r, i) : o(i)) || i);
418
- return t && i && yt(n, r, i), i;
419
- }, K = (e, n) => (r, t) => n(r, t, e), N;
420
- let X = (N = class extends Ce {
421
- constructor(e = H, n, r) {
391
+ return t && i && _t(n, r, i), i;
392
+ }, G = (e, n) => (r, t) => n(r, t, e), N;
393
+ let K = (N = class extends Ee {
394
+ constructor(e = W, n, r) {
422
395
  super(), this._config = e, this._injector = n, this._configService = r;
423
- const { menu: t, ...i } = Oe(
396
+ const { menu: t, ...i } = Se(
424
397
  {},
425
- H,
398
+ W,
426
399
  this._config
427
400
  );
428
- t && this._configService.setConfig("menu", t, { merge: !0 }), this._configService.setConfig(Ge, i), this._initializeDependencies(this._injector);
401
+ t && this._configService.setConfig("menu", t, { merge: !0 }), this._configService.setConfig(ke, i), this._initializeDependencies(this._injector);
429
402
  }
430
403
  _initializeDependencies(e) {
431
404
  [
405
+ [y],
432
406
  [b],
433
- [T],
434
- [W, { useClass: rt }]
407
+ [F, { useClass: qe }]
435
408
  ].forEach((r) => e.add(r));
436
409
  }
437
410
  onReady() {
438
- this._injector.get(b);
411
+ this._injector.get(y);
439
412
  }
440
413
  onSteady() {
441
- this._injector.get(T);
414
+ this._injector.get(b);
442
415
  }
443
- }, S(N, "pluginName", "SHEET_ZEN_EDITOR_PLUGIN"), S(N, "type", j.UNIVER_SHEET), N);
444
- X = bt([
445
- K(1, ye(Ne)),
446
- K(2, be)
447
- ], X);
416
+ }, E(N, "pluginName", "SHEET_ZEN_EDITOR_PLUGIN"), E(N, "type", w.UNIVER_SHEET), N);
417
+ K = St([
418
+ G(1, Ie(Ce)),
419
+ G(2, Oe)
420
+ ], K);
448
421
  export {
449
- k as CancelZenEditCommand,
450
- F as ConfirmZenEditCommand,
422
+ L as CancelZenEditCommand,
423
+ $ as ConfirmZenEditCommand,
451
424
  B as OpenZenEditorCommand,
452
- X as UniverSheetsZenEditorPlugin
425
+ K as UniverSheetsZenEditorPlugin
453
426
  };
@@ -1,8 +1,14 @@
1
1
  import { Injector, FUniver } from '@univerjs/core';
2
+ /**
3
+ * @ignore
4
+ */
2
5
  export interface IFUniverSheetsZenEditorMixin {
3
6
  }
4
7
  export declare class FUniverSheetsZenEditorMixin extends FUniver implements IFUniverSheetsZenEditorMixin {
5
8
  private _initSheetZenEditorEvent;
9
+ /**
10
+ * @ignore
11
+ */
6
12
  _initialize(injector: Injector): void;
7
13
  }
8
14
  declare module '@univerjs/core' {
@@ -1,4 +1,7 @@
1
1
  import { FWorkbook } from '@univerjs/sheets/facade';
2
+ /**
3
+ * @ignore
4
+ */
2
5
  export interface IFWorkbookSheetsZenEditorMixin {
3
6
  /**
4
7
  * Start the zen editing process
@@ -1,3 +1,17 @@
1
- import { default as React } from 'react';
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
2
16
  export declare const ZEN_EDITOR_COMPONENT = "ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT";
3
- export declare function ZenEditor(): React.JSX.Element;
17
+ export declare function ZenEditor(): import("react/jsx-runtime").JSX.Element;
package/lib/umd/index.js CHANGED
@@ -1,9 +1 @@
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,I,F,S,f,h,k,N){"use strict";var De=Object.defineProperty;var Re=(d,o,I)=>o in d?De(d,o,{enumerable:!0,configurable:!0,writable:!0,value:I}):d[o]=I;var y=(d,o,I)=>Re(d,typeof o!="symbol"?o+"":o,I);var M;const R={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(I.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:v,drawings:u,drawingsOrder:_,tableSource:E,settings:m}=o.Tools.deepClone(c),T={...s.getDocumentData(),body:v,drawings:u,drawingsOrder:_,tableSource:E,settings:m},O=[{startOffset:0,endOffset:0,collapsed:!0}];return s.focus(),s.setDocumentData(T,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 v;const t=e.get(f.IZenZoneService),r=e.get(S.IEditorBridgeService),n=e.get(o.IUniverInstanceService),i=e.get(I.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=l.getRenderById(u))==null?void 0:v.with(S.EditingRenderController);if(_){const E=o.Tools.deepClone(s.getDocumentData());E.documentStyle.documentFlavor=o.DocumentFlavor.UNSPECIFIED,_.submitCellData(new o.DocumentDataModel(E))}return n.focusUnit(c.getUnitId()),r.refreshEditCellState(),!0}return!1}},ee="sheets-zen-editor.config",V={};var w={exports:{}},D={};/**
2
- * @license React
3
- * react-jsx-runtime.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var Y;function ne(){if(Y)return D;Y=1;var e=h,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,v){var u,_={},E=null,m=null;v!==void 0&&(E=""+v),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)&&(_[u]=c[u]);if(l&&l.defaultProps)for(u in c=l.defaultProps,c)_[u]===void 0&&(_[u]=c[u]);return{$$typeof:t,type:l,key:E,ref:m,props:_,_owner:i.current}}return D.Fragment=r,D.jsx=s,D.jsxs=s,D}var W;function te(){return W||(W=1,w.exports=ne()),w.exports}var p=te(),g=function(){return g=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},g.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=h.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=h.useRef("_".concat(se()));return K(r,"".concat(n),{defIds:r.defIds,idSuffix:c.current},g({ref:t,className:l},s),a)});function K(e,t,r,n,i){return h.createElement(e.tag,g(g({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=g({},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)?g(g({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?g(g({},i),{attrs:g(g({},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=h.forwardRef(function(e,t){return h.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=h.forwardRef(function(e,t){return h.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(){y(this,"_position",null);y(this,"_position$",new k.BehaviorSubject(null));y(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=h.useRef(null),t=o.useDependency(B),r=o.useDependency(I.IEditorService),n=o.useDependency(o.ICommandService);h.useEffect(()=>{const s=e.current;if(!s)return;const l=r.register({editorUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:ue,scrollBar:!0,backScrollOffset:100},s),c=new ResizeObserver(()=>{t.setPosition(s.getBoundingClientRect())});return c.observe(s),()=>{l.dispose(),c.unobserve(s)}},[]);function i(){const s=r.getEditor(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);s==null||s.blur(),n.executeCommand(z.id)}function a(){const s=r.getEditor(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);s==null||s.blur(),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 _e(e){return{id:R.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 ge={[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[R.id]:{order:2,menuItemFactory:_e}}}},ve={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 Ie=Object.defineProperty,he=Object.getOwnPropertyDescriptor,me=(e,t,r,n)=>{for(var i=n>1?void 0:n?he(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&&Ie(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(){[R,z,b].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(ge)}_initShortcuts(){[ve,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},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:v,height:u}=i;let _=0;const E=c;let m=0,Z=0,T=Number.POSITIVE_INFINITY;const{scaleX:O,scaleY:U}=r.getAncestorScale();v>(a+l*2)*O?(_=v/2-a*O/2,_/=O,m=(v-l*2)/O,T=0):(_=l,m=a+l*2,T=(m-v/O)/2),u>s?Z=(u-c*2)/U:Z=s+c*2,r.resize(m,Z),t.translate(_,E),n.translate(_,E);const L=r.getViewport(I.VIEWPORT_KEY.VIEW_MAIN);if(T!==Number.POSITIVE_INFINITY&&L!=null){const Ne=L.transScroll2ViewportScrollValue(T,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(I.DocBackScrollRenderController),t={startOffset:0,endOffset:0};e&&e.scrollToRange(t)}};x=Ce([X(0,B),X(1,F.IRenderManagerService)],x);var Oe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,ye=(e,t,r,n)=>{for(var i=n>1?void 0:n?Te(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)}},y(M,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),y(M,"type",o.UniverInstanceType.UNIVER_SHEET),M),d.UniverSheetsZenEditorPlugin=ye([Q(1,o.Inject(o.Injector)),Q(2,o.IConfigService)],d.UniverSheetsZenEditorPlugin),d.CancelZenEditCommand=z,d.ConfirmZenEditCommand=b,d.OpenZenEditorCommand=R,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
1
+ (function(c,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/jsx-runtime"),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/jsx-runtime","react","rxjs","@univerjs/sheets"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverSheetsZenEditor={},c.UniverCore,c.UniverDocsUi,c.UniverEngineRender,c.UniverSheetsUi,c.UniverUi,c.React,c.React,c.rxjs,c.UniverSheets))})(this,function(c,o,g,B,I,l,h,E,L,y){"use strict";var Ce=Object.defineProperty;var pe=(c,o,g)=>o in c?Ce(c,o,{enumerable:!0,configurable:!0,writable:!0,value:g}):c[o]=g;var N=(c,o,g)=>pe(c,typeof o!="symbol"?o+"":o,g);var Z;const D={id:"zen-editor.command.open-zen-editor",type:o.CommandType.COMMAND,handler:async e=>{var j;const t=e.get(l.IZenZoneService),i=e.get(g.IEditorService),n=e.get(I.IEditorBridgeService),r=e.get(o.IUniverInstanceService),a=e.get(l.ISidebarService);a.visible&&(a.close(),await o.delayAnimationFrame()),t.open();const s=i.getEditor(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(s==null)return!1;const d=n.getLatestEditCellState();if(d==null)return!1;const u=(j=d.documentLayoutObject.documentModel)==null?void 0:j.getSnapshot();if(u==null)return!1;r.focusUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const{body:_,drawings:p,drawingsOrder:v,tableSource:m,settings:O}=o.Tools.deepClone(u),T={...s.getDocumentData(),body:_,drawings:p,drawingsOrder:v,tableSource:m,settings:O},C=[{startOffset:0,endOffset:0,collapsed:!0}];return s.focus(),s.setDocumentData(T,C),s.clearUndoRedoHistory(),!0}},z={id:"zen-editor.command.cancel-zen-edit",type:o.CommandType.COMMAND,handler:async e=>{const t=e.get(l.IZenZoneService),i=e.get(I.IEditorBridgeService),n=e.get(o.IUniverInstanceService),r=e.get(l.ISidebarService);r.visible&&(r.close(),await o.delayAnimationFrame()),t.close();const a=n.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);return a?(n.focusUnit(a.getUnitId()),i.refreshEditCellState(),!0):!1}},b={id:"zen-editor.command.confirm-zen-edit",type:o.CommandType.COMMAND,handler:async e=>{var _;const t=e.get(l.IZenZoneService),i=e.get(I.IEditorBridgeService),n=e.get(o.IUniverInstanceService),r=e.get(g.IEditorService),a=e.get(l.ISidebarService);a.visible&&(a.close(),await o.delayAnimationFrame()),t.close();const s=r.getEditor(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(s==null)return!1;const d=e.get(B.IRenderManagerService),u=n.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(u){const p=u.getUnitId(),v=(_=d.getRenderById(p))==null?void 0:_.with(I.EditingRenderController);if(v){const m=o.Tools.deepClone(s.getDocumentData());m.documentStyle.documentFlavor=o.DocumentFlavor.UNSPECIFIED,v.submitCellData(new o.DocumentDataModel(m))}return n.focusUnit(u.getUnitId()),i.refreshEditCellState(),!0}return!1}},G="sheets-zen-editor.config",F={};var f=function(){return f=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},f.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},w=E.forwardRef(function(e,t){var i=e.icon,n=e.id,r=e.className,a=e.extend,s=X(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),u=E.useRef("_".concat(ee()));return $(i,"".concat(n),{defIds:i.defIds,idSuffix:u.current},f({ref:t,className:d},s),a)});function $(e,t,i,n,r){return E.createElement(e.tag,f(f({key:t},J(e,i,r)),n),(Q(e,i).children||[]).map(function(a,s){return $(a,"".concat(t,"-").concat(e.tag,"-").concat(s),i,void 0,r)}))}function J(e,t,i){var n=f({},e.attrs);i!=null&&i.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=i.colorChannel1);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(a){var s=a[0],d=a[1];typeof d=="string"&&(n[s]=d.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)?f(f({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?f(f({},r),{attrs:f(f({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function ee(){return Math.random().toString(36).substring(2,8)}w.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"}}]},V=E.forwardRef(function(e,t){return E.createElement(w,Object.assign({},e,{id:"check-mark-single",ref:t,icon:ne}))});V.displayName="CheckMarkSingle";var te={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=E.forwardRef(function(e,t){return E.createElement(w,Object.assign({},e,{id:"close-single",ref:t,icon:te}))});Y.displayName="CloseSingle";function k(e){var t,i,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(i=k(e[t]))&&(n&&(n+=" "),n+=i)}else for(i in e)e[i]&&(n&&(n+=" "),n+=i);return n}function W(){for(var e,t,i=0,n="",r=arguments.length;i<r;i++)(e=arguments[i])&&(t=k(e))&&(n&&(n+=" "),n+=t);return n}class ie{constructor(){N(this,"_position",null);N(this,"_position$",new L.BehaviorSubject(null));N(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 x=o.createIdentifier("univer.sheet-zen-editor-manager.service"),S={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"},re="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT",oe={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 se(){const e=E.useRef(null),t=o.useDependency(x),i=o.useDependency(g.IEditorService),n=o.useDependency(o.ICommandService);E.useEffect(()=>{const s=e.current;if(!s)return;const d=i.register({editorUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:oe,scrollBar:!0,backScrollOffset:100},s),u=new ResizeObserver(()=>{t.setPosition(s.getBoundingClientRect())});return u.observe(s),()=>{d.dispose(),u.unobserve(s)}},[]);function r(){const s=i.getEditor(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);s==null||s.blur(),n.executeCommand(z.id)}function a(){const s=i.getEditor(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);s==null||s.blur(),n.executeCommand(b.id)}return h.jsxs("div",{className:S.zenEditor,children:[h.jsxs("div",{className:S.zenEditorIconWrapper,children:[h.jsx("span",{className:W(S.zenEditorIconContainer,S.zenEditorIconError),onClick:r,children:h.jsx(Y,{style:{fontSize:"22px"}})}),h.jsx("span",{className:W(S.zenEditorIconContainer,S.zenEditorIconSuccess),onClick:a,children:h.jsx(V,{style:{fontSize:"22px"}})})]}),h.jsx("div",{className:S.zenEditorCanvasContainer,ref:e})]})}function ae(e){return{id:D.id,type:l.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",hidden$:I.getCurrentExclusiveRangeInterest$(e),disabled$:I.getCurrentRangeDisable$(e,{workbookTypes:[y.WorkbookEditablePermission],worksheetTypes:[y.WorksheetEditPermission,y.WorksheetSetCellValuePermission,y.WorksheetSetCellStylePermission],rangeTypes:[y.RangeProtectionPermissionEditPoint]})}}const ce={[l.ContextMenuPosition.MAIN_AREA]:{[l.ContextMenuGroup.OTHERS]:{[D.id]:{order:2,menuItemFactory:ae}}}},de={id:b.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:e=>K(e),binding:l.KeyCode.ENTER|l.MetaKeys.ALT},le={id:z.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:e=>K(e),binding:l.KeyCode.ESC};function K(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 ue=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,ge=(e,t,i,n)=>{for(var r=n>1?void 0:n?fe(t,i):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(n?s(t,i,r):s(r))||r);return n&&r&&ue(t,i,r),r},P=(e,t)=>(i,n)=>t(i,n,e);let R=class extends o.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(re,se))}_initCommands(){[D,z,b].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(ce)}_initShortcuts(){[de,le].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}};R=ge([P(0,l.IZenZoneService),P(1,o.ICommandService),P(2,l.IMenuManagerService),P(3,l.IShortcutService)],R);var ve=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,_e=(e,t,i,n)=>{for(var r=n>1?void 0:n?Ee(t,i):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(n?s(t,i,r):s(r))||r);return n&&r&&ve(t,i,r),r},H=(e,t)=>(i,n)=>t(i,n,e);let M=class extends o.RxDisposable{constructor(e,t){super(),this._zenEditorManagerService=e,this._renderManagerService=t,this._initialize()}_initialize(){this._syncZenEditorSize()}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(L.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{width:t,height:i}=e,n=I.getEditorObject(o.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:a,height:s,pageMarginLeft:d,pageMarginTop:u}=t;if(r==null||a===Number.POSITIVE_INFINITY||s===Number.POSITIVE_INFINITY)return;const{width:_,height:p}=r;let v=0;const m=u;let O=0,U=0,T=Number.POSITIVE_INFINITY;const{scaleX:C,scaleY:j}=i.getAncestorScale();_>(a+d*2)*C?(v=_/2-a*C/2,v/=C,O=(_-d*2)/C,T=0):(v=d,O=a+d*2,T=(O-_/C)/2),p>s?U=(p-u*2)/j:U=s+u*2,i.resize(O,U),t.translate(v,m),n.translate(v,m);const A=i.getViewport(g.VIEWPORT_KEY.VIEW_MAIN);if(T!==Number.POSITIVE_INFINITY&&A!=null){const me=A.transScroll2ViewportScrollValue(T,0).x;A.scrollToBarPos({x:me})}return this}_scrollToTop(){var i;const e=(i=this._renderManagerService.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:i.with(g.DocBackScrollRenderController),t={startOffset:0,endOffset:0};e&&e.scrollToRange(t)}};M=_e([H(0,x),H(1,B.IRenderManagerService)],M);var Ie=Object.defineProperty,he=Object.getOwnPropertyDescriptor,Se=(e,t,i,n)=>{for(var r=n>1?void 0:n?he(t,i):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(n?s(t,i,r):s(r))||r);return n&&r&&Ie(t,i,r),r},q=(e,t)=>(i,n)=>t(i,n,e);c.UniverSheetsZenEditorPlugin=(Z=class extends o.Plugin{constructor(t=F,i,n){super(),this._config=t,this._injector=i,this._configService=n;const{menu:r,...a}=o.merge({},F,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(G,a),this._initializeDependencies(this._injector)}_initializeDependencies(t){[[R],[M],[x,{useClass:ie}]].forEach(n=>t.add(n))}onReady(){this._injector.get(R)}onSteady(){this._injector.get(M)}},N(Z,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),N(Z,"type",o.UniverInstanceType.UNIVER_SHEET),Z),c.UniverSheetsZenEditorPlugin=Se([q(1,o.Inject(o.Injector)),q(2,o.IConfigService)],c.UniverSheetsZenEditorPlugin),c.CancelZenEditCommand=z,c.ConfirmZenEditCommand=b,c.OpenZenEditorCommand=D,Object.defineProperty(c,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.5",
3
+ "version": "0.6.0-experimental.20250125-1d060b9",
4
4
  "private": false,
5
5
  "description": "Zen Editor plugin for Univer Sheets.",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -55,19 +55,19 @@
55
55
  "lib"
56
56
  ],
57
57
  "peerDependencies": {
58
- "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
58
+ "react": ">=16.9.0 || >=17 || >=18 || >=19",
59
59
  "rxjs": ">=7.0.0"
60
60
  },
61
61
  "dependencies": {
62
- "@univerjs/icons": "^0.2.12",
62
+ "@univerjs/icons": "^0.2.14",
63
63
  "clsx": "^2.1.1",
64
- "@univerjs/core": "0.5.5",
65
- "@univerjs/docs": "0.5.5",
66
- "@univerjs/docs-ui": "0.5.5",
67
- "@univerjs/engine-render": "0.5.5",
68
- "@univerjs/sheets": "0.5.5",
69
- "@univerjs/sheets-ui": "0.5.5",
70
- "@univerjs/ui": "0.5.5"
64
+ "@univerjs/core": "0.6.0-experimental.20250125-1d060b9",
65
+ "@univerjs/docs": "0.6.0-experimental.20250125-1d060b9",
66
+ "@univerjs/engine-render": "0.6.0-experimental.20250125-1d060b9",
67
+ "@univerjs/docs-ui": "0.6.0-experimental.20250125-1d060b9",
68
+ "@univerjs/sheets": "0.6.0-experimental.20250125-1d060b9",
69
+ "@univerjs/sheets-ui": "0.6.0-experimental.20250125-1d060b9",
70
+ "@univerjs/ui": "0.6.0-experimental.20250125-1d060b9"
71
71
  },
72
72
  "devDependencies": {
73
73
  "less": "^4.2.1",
@@ -75,10 +75,10 @@
75
75
  "react": "18.3.1",
76
76
  "rxjs": "^7.8.1",
77
77
  "tailwindcss": "^3.4.17",
78
- "typescript": "^5.7.2",
78
+ "typescript": "^5.7.3",
79
79
  "vite": "^6.0.7",
80
80
  "vitest": "^2.1.8",
81
- "@univerjs-infra/shared": "0.5.5"
81
+ "@univerjs-infra/shared": "0.6.0-alpha.0"
82
82
  },
83
83
  "scripts": {
84
84
  "test": "vitest run",
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