@univerjs/sheets-zen-editor 0.5.4 → 0.5.5-nightly.202501201336
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +37 -36
- package/lib/umd/index.js +2 -2
- package/package.json +9 -9
- package/LICENSE +0 -176
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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
|
|
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
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var $;function re(){if($)return N;$=1;var e=m,n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),t=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function s(d,a,g){var l,u={},h=null,v=null;g!==void 0&&(h=""+g),a.key!==void 0&&(h=""+a.key),a.ref!==void 0&&(v=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:h,ref:v,props:u,_owner:i.current}}return N.Fragment=r,N.jsx=s,N.jsxs=s,N}var F;function ie(){return F||(F=1,j.exports=re()),j.exports}var I=ie(),_=function(){return _=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},_.apply(this,arguments)},oe=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,t=Object.getOwnPropertySymbols(e);i<t.length;i++)n.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(e,t[i])&&(r[t[i]]=e[t[i]]);return r},A=m.forwardRef(function(e,n){var r=e.icon,t=e.id,i=e.className,c=e.extend,s=oe(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(t," ").concat(i||"").trim(),a=m.useRef("_".concat(ae()));return K(r,"".concat(t),{defIds:r.defIds,idSuffix:a.current},_({ref:n,className:d},s),c)});function K(e,n,r,t,i){return m.createElement(e.tag,_(_({key:n},se(e,r,i)),t),(ce(e,r).children||[]).map(function(c,s){return K(c,"".concat(n,"-").concat(e.tag,"-").concat(s),r,void 0,i)}))}function se(e,n,r){var t=_({},e.attrs);r!=null&&r.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=r.colorChannel1);var i=n.defIds;return!i||i.length===0||(e.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(c){var s=c[0],d=c[1];typeof d=="string"&&(t[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function ce(e,n){var r,t=n.defIds;return!t||t.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?_(_({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&t&&t.indexOf(i.attrs.id)>-1?_(_({},i),{attrs:_(_({},i.attrs),{id:i.attrs.id+n.idSuffix})}):i})}):e}function ae(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var de={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},H=m.forwardRef(function(e,n){return m.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=m.forwardRef(function(e,n){return m.createElement(A,Object.assign({},e,{id:"close-single",ref:n,icon:le}))});G.displayName="CloseSingle";function J(e){var n,r,t="";if(typeof e=="string"||typeof e=="number")t+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(n=0;n<i;n++)e[n]&&(r=J(e[n]))&&(t&&(t+=" "),t+=r)}else for(r in e)e[r]&&(t&&(t+=" "),t+=r);return t}function k(){for(var e,n,r=0,t="",i=arguments.length;r<i;r++)(e=arguments[r])&&(n=J(e))&&(t&&(t+=" "),t+=n);return t}class ue{constructor(){O(this,"_position",null);O(this,"_position$",new q.BehaviorSubject(null));O(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(n){this._position=n,this._refresh(n)}getPosition(){return this._position}_refresh(n){this._position$.next(n)}}const B=o.createIdentifier("univer.sheet-zen-editor-manager.service"),fe="univer-zen-editor",ge="univer-zen-editor-icon-wrapper",_e="univer-zen-editor-icon-container",he="univer-zen-editor-icon-success",me="univer-zen-editor-icon-error",ve="univer-zen-editor-canvas-container",S={zenEditor:fe,zenEditorIconWrapper:ge,zenEditorIconContainer:_e,zenEditorIconSuccess:he,zenEditorIconError:me,zenEditorCanvasContainer:ve},Ee="ZEN_EDITOR_PLUGIN_",Ie=`${Ee}ZEN_EDITOR_COMPONENT`,Se={id:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],tables:[],customBlocks:[],paragraphs:[{startIndex:0}],sectionBreaks:[{startIndex:1}]},tableSource:{},documentStyle:{pageSize:{width:595,height:Number.POSITIVE_INFINITY},documentFlavor:o.DocumentFlavor.MODERN,marginTop:0,marginBottom:0,marginRight:0,marginLeft:0,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};function pe(){const e=m.useRef(null),n=o.useDependency(B),r=o.useDependency(T.IEditorService),t=o.useDependency(o.ICommandService);m.useEffect(()=>{const s=e.current;if(!s)return;const d=r.register({editorUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:Se,scrollBar:!0,noNeedVerticalAlign:!0,backScrollOffset:100},s),a=new ResizeObserver(()=>{n.setPosition(s.getBoundingClientRect())});return a.observe(s),()=>{d.dispose(),a.unobserve(s)}},[]);function i(){t.executeCommand(U.id)}function c(){t.executeCommand(Z.id)}return I.jsxs("div",{className:S.zenEditor,children:[I.jsxs("div",{className:S.zenEditorIconWrapper,children:[I.jsx("span",{className:k(S.zenEditorIconContainer,S.zenEditorIconError),onClick:i,children:I.jsx(G,{style:{fontSize:"22px"}})}),I.jsx("span",{className:k(S.zenEditorIconContainer,S.zenEditorIconSuccess),onClick:c,children:I.jsx(H,{style:{fontSize:"22px"}})})]}),I.jsx("div",{className:S.zenEditorCanvasContainer,ref:e})]})}function Ce(e){return{id:M.id,type:f.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",hidden$:p.getCurrentExclusiveRangeInterest$(e),disabled$:p.getCurrentRangeDisable$(e,{workbookTypes:[y.WorkbookEditablePermission],worksheetTypes:[y.WorksheetEditPermission,y.WorksheetSetCellValuePermission,y.WorksheetSetCellStylePermission],rangeTypes:[y.RangeProtectionPermissionEditPoint]})}}const Oe={[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[M.id]:{order:2,menuItemFactory:Ce}}}},ye={id:Z.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:e=>X(e),binding:f.KeyCode.ENTER|f.MetaKeys.ALT},Ne={id:U.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:e=>X(e),binding:f.KeyCode.ESC};function X(e){return e.getContextValue(o.FOCUSING_DOC)&&e.getContextValue(o.FOCUSING_UNIVER_EDITOR)&&e.getContextValue(o.EDITOR_ACTIVATED)&&!e.getContextValue(o.FOCUSING_EDITOR_STANDALONE)}var Te=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,be=(e,n,r,t)=>{for(var i=t>1?void 0:t?Re(n,r):n,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(t?s(n,r,i):s(i))||i);return t&&i&&Te(n,r,i),i},D=(e,n)=>(r,t)=>n(r,t,e);let P=class extends o.Disposable{constructor(e,n,r,t){super(),this._zenZoneService=e,this._commandService=n,this._menuManagerService=r,this._shortcutService=t,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(Ie,pe))}_initCommands(){[M,U,Z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Oe)}_initShortcuts(){[ye,Ne].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}};P=be([D(0,f.IZenZoneService),D(1,o.ICommandService),D(2,f.IMenuManagerService),D(3,f.IShortcutService)],P);var De=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,Pe=(e,n,r,t)=>{for(var i=t>1?void 0:t?ze(n,r):n,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(t?s(n,r,i):s(i))||i);return t&&i&&De(n,r,i),i},V=(e,n)=>(r,t)=>n(r,t,e);let x=class extends o.RxDisposable{constructor(e,n){super(),this._zenEditorManagerService=e,this._renderManagerService=n,this._initialize()}_initialize(){this._syncZenEditorSize()}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(q.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{width:n,height:r}=e,t=p.getEditorObject(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService);t!=null&&requestIdleCallback(()=>{t.engine.resizeBySize(n,r),this._calculatePagePosition(t),this._scrollToTop()})})}_calculatePagePosition(e){const{document:n,scene:r,docBackground:t}=e,i=r==null?void 0:r.getParent(),{width:c,height:s,pageMarginLeft:d,pageMarginTop:a}=n;if(i==null||c===Number.POSITIVE_INFINITY||s===Number.POSITIVE_INFINITY)return;const{width:g,height:l}=i;let u=0;const h=a;let v=0,R=0,C=Number.POSITIVE_INFINITY;const{scaleX:E,scaleY:b}=r.getAncestorScale();g>(c+d*2)*E?(u=g/2-c*E/2,u/=E,v=(g-d*2)/E,C=0):(u=d,v=c+d*2,C=(v-g/E)/2),l>s?R=(l-a*2)/b:R=s+a*2,r.resize(v,R),n.translate(u,h),t.translate(u,h);const w=r.getViewport(T.VIEWPORT_KEY.VIEW_MAIN);if(C!==Number.POSITIVE_INFINITY&&w!=null){const Q=w.transScroll2ViewportScrollValue(C,0).x;w.scrollToBarPos({x:Q})}return this}_scrollToTop(){var r;const e=(r=this._renderManagerService.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:r.with(T.DocBackScrollRenderController),n={startOffset:0,endOffset:0};e&&e.scrollToRange(n)}};x=Pe([V(0,B),V(1,W.IRenderManagerService)],x);var xe=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,Ue=(e,n,r,t)=>{for(var i=t>1?void 0:t?Me(n,r):n,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(t?s(n,r,i):s(i))||i);return t&&i&&xe(n,r,i),i},Y=(e,n)=>(r,t)=>n(r,t,e),z;exports.UniverSheetsZenEditorPlugin=(z=class extends o.Plugin{constructor(n=L,r,t){super(),this._config=n,this._injector=r,this._configService=t;const{menu:i,...c}=o.merge({},L,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ne,c),this._initializeDependencies(this._injector)}_initializeDependencies(n){[[P],[x],[B,{useClass:ue}]].forEach(t=>n.add(t))}onReady(){this._injector.get(P)}onSteady(){this._injector.get(x)}},O(z,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),O(z,"type",o.UniverInstanceType.UNIVER_SHEET),z);exports.UniverSheetsZenEditorPlugin=Ue([Y(1,o.Inject(o.Injector)),Y(2,o.IConfigService)],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=U;exports.ConfirmZenEditCommand=Z;exports.OpenZenEditorCommand=M;
|
|
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;
|
package/lib/es/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var ue = Object.defineProperty;
|
|
2
2
|
var fe = (e, n, r) => n in e ? ue(e, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[n] = r;
|
|
3
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
|
|
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
5
|
import { IEditorService as U, VIEWPORT_KEY as Te, DocBackScrollRenderController as Re } from "@univerjs/docs-ui";
|
|
6
6
|
import { IRenderManagerService as ne } from "@univerjs/engine-render";
|
|
7
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
|
|
9
|
-
import
|
|
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
10
|
import { BehaviorSubject as Be, takeUntil as ke } from "rxjs";
|
|
11
11
|
import { WorkbookEditablePermission as Fe, WorksheetEditPermission as Ve, WorksheetSetCellValuePermission as We, WorksheetSetCellStylePermission as He, RangeProtectionPermissionEditPoint as Ye } from "@univerjs/sheets";
|
|
12
12
|
const B = {
|
|
@@ -14,9 +14,9 @@ const B = {
|
|
|
14
14
|
type: M.COMMAND,
|
|
15
15
|
handler: async (e) => {
|
|
16
16
|
var O;
|
|
17
|
-
const n = e.get(R), r = e.get(U), t = e.get(Z), i = e.get(D), s = e.get(
|
|
17
|
+
const n = e.get(R), r = e.get(U), t = e.get(Z), i = e.get(D), s = e.get(L);
|
|
18
18
|
s.visible && (s.close(), await w()), n.open();
|
|
19
|
-
const o = r.getEditor(
|
|
19
|
+
const o = r.getEditor(m);
|
|
20
20
|
if (o == null)
|
|
21
21
|
return !1;
|
|
22
22
|
const a = t.getLatestEditCellState();
|
|
@@ -25,7 +25,7 @@ const B = {
|
|
|
25
25
|
const c = (O = a.documentLayoutObject.documentModel) == null ? void 0 : O.getSnapshot();
|
|
26
26
|
if (c == null)
|
|
27
27
|
return !1;
|
|
28
|
-
i.focusUnit(
|
|
28
|
+
i.focusUnit(m);
|
|
29
29
|
const { body: u, drawings: d, drawingsOrder: l, tableSource: g, settings: h } = Q.deepClone(c), E = {
|
|
30
30
|
...o.getDocumentData(),
|
|
31
31
|
body: u,
|
|
@@ -33,20 +33,20 @@ const B = {
|
|
|
33
33
|
drawingsOrder: l,
|
|
34
34
|
tableSource: g,
|
|
35
35
|
settings: h
|
|
36
|
-
},
|
|
36
|
+
}, _ = [
|
|
37
37
|
{
|
|
38
38
|
startOffset: 0,
|
|
39
39
|
endOffset: 0,
|
|
40
40
|
collapsed: !0
|
|
41
41
|
}
|
|
42
42
|
];
|
|
43
|
-
return o.focus(), o.setDocumentData(E,
|
|
43
|
+
return o.focus(), o.setDocumentData(E, _), o.clearUndoRedoHistory(), !0;
|
|
44
44
|
}
|
|
45
45
|
}, k = {
|
|
46
46
|
id: "zen-editor.command.cancel-zen-edit",
|
|
47
47
|
type: M.COMMAND,
|
|
48
48
|
handler: async (e) => {
|
|
49
|
-
const n = e.get(R), r = e.get(Z), t = e.get(D), i = e.get(
|
|
49
|
+
const n = e.get(R), r = e.get(Z), t = e.get(D), i = e.get(L);
|
|
50
50
|
i.visible && (i.close(), await w()), n.close();
|
|
51
51
|
const s = t.getCurrentUnitForType(j.UNIVER_SHEET);
|
|
52
52
|
return s ? (t.focusUnit(s.getUnitId()), r.refreshEditCellState(), !0) : !1;
|
|
@@ -56,9 +56,9 @@ const B = {
|
|
|
56
56
|
type: M.COMMAND,
|
|
57
57
|
handler: async (e) => {
|
|
58
58
|
var u;
|
|
59
|
-
const n = e.get(R), r = e.get(Z), t = e.get(D), i = e.get(U), s = e.get(
|
|
59
|
+
const n = e.get(R), r = e.get(Z), t = e.get(D), i = e.get(U), s = e.get(L);
|
|
60
60
|
s.visible && (s.close(), await w()), n.close();
|
|
61
|
-
const o = i.getEditor(
|
|
61
|
+
const o = i.getEditor(m);
|
|
62
62
|
if (o == null)
|
|
63
63
|
return !1;
|
|
64
64
|
const a = e.get(ne), c = t.getCurrentUnitForType(j.UNIVER_SHEET);
|
|
@@ -87,7 +87,7 @@ var Y;
|
|
|
87
87
|
function qe() {
|
|
88
88
|
if (Y) return I;
|
|
89
89
|
Y = 1;
|
|
90
|
-
var e =
|
|
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
91
|
function o(a, c, u) {
|
|
92
92
|
var d, l = {}, g = null, h = null;
|
|
93
93
|
u !== void 0 && (g = "" + u), c.key !== void 0 && (g = "" + c.key), c.ref !== void 0 && (h = c.ref);
|
|
@@ -101,7 +101,7 @@ var G;
|
|
|
101
101
|
function Je() {
|
|
102
102
|
return G || (G = 1, P.exports = qe()), P.exports;
|
|
103
103
|
}
|
|
104
|
-
var
|
|
104
|
+
var p = Je(), f = function() {
|
|
105
105
|
return f = Object.assign || function(e) {
|
|
106
106
|
for (var n, r = 1, t = arguments.length; r < t; r++) {
|
|
107
107
|
n = arguments[r];
|
|
@@ -116,7 +116,7 @@ var _ = Je(), f = function() {
|
|
|
116
116
|
for (var i = 0, t = Object.getOwnPropertySymbols(e); i < t.length; i++)
|
|
117
117
|
n.indexOf(t[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[i]) && (r[t[i]] = e[t[i]]);
|
|
118
118
|
return r;
|
|
119
|
-
}, V =
|
|
119
|
+
}, V = A(function(e, n) {
|
|
120
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
121
|
return oe(r, "".concat(t), { defIds: r.defIds, idSuffix: c.current }, f({ ref: n, className: a }, o), s);
|
|
122
122
|
});
|
|
@@ -144,7 +144,7 @@ function et() {
|
|
|
144
144
|
return Math.random().toString(36).substring(2, 8);
|
|
145
145
|
}
|
|
146
146
|
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 =
|
|
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
148
|
return $(V, Object.assign({}, e, {
|
|
149
149
|
id: "check-mark-single",
|
|
150
150
|
ref: n,
|
|
@@ -152,7 +152,7 @@ var tt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em"
|
|
|
152
152
|
}));
|
|
153
153
|
});
|
|
154
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 =
|
|
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
156
|
return $(V, Object.assign({}, e, {
|
|
157
157
|
id: "close-single",
|
|
158
158
|
ref: n,
|
|
@@ -194,7 +194,7 @@ class rt {
|
|
|
194
194
|
}
|
|
195
195
|
const W = he(
|
|
196
196
|
"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",
|
|
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
198
|
zenEditor: it,
|
|
199
199
|
zenEditorIconWrapper: ot,
|
|
200
200
|
zenEditorIconContainer: st,
|
|
@@ -202,7 +202,7 @@ const W = he(
|
|
|
202
202
|
zenEditorIconError: at,
|
|
203
203
|
zenEditorCanvasContainer: dt
|
|
204
204
|
}, lt = "ZEN_EDITOR_PLUGIN_", ut = `${lt}ZEN_EDITOR_COMPONENT`, ft = {
|
|
205
|
-
id:
|
|
205
|
+
id: m,
|
|
206
206
|
body: {
|
|
207
207
|
dataStream: `${me}`,
|
|
208
208
|
textRuns: [],
|
|
@@ -244,10 +244,9 @@ function gt() {
|
|
|
244
244
|
return;
|
|
245
245
|
const a = r.register(
|
|
246
246
|
{
|
|
247
|
-
editorUnitId:
|
|
247
|
+
editorUnitId: m,
|
|
248
248
|
initialSnapshot: ft,
|
|
249
249
|
scrollBar: !0,
|
|
250
|
-
noNeedVerticalAlign: !0,
|
|
251
250
|
backScrollOffset: 100
|
|
252
251
|
},
|
|
253
252
|
o
|
|
@@ -259,31 +258,33 @@ function gt() {
|
|
|
259
258
|
};
|
|
260
259
|
}, []);
|
|
261
260
|
function i() {
|
|
262
|
-
|
|
261
|
+
const o = r.getEditor(m);
|
|
262
|
+
o == null || o.blur(), t.executeCommand(k.id);
|
|
263
263
|
}
|
|
264
264
|
function s() {
|
|
265
|
-
|
|
265
|
+
const o = r.getEditor(m);
|
|
266
|
+
o == null || o.blur(), t.executeCommand(F.id);
|
|
266
267
|
}
|
|
267
|
-
return /* @__PURE__ */
|
|
268
|
-
/* @__PURE__ */
|
|
269
|
-
/* @__PURE__ */
|
|
268
|
+
return /* @__PURE__ */ p.jsxs("div", { className: v.zenEditor, children: [
|
|
269
|
+
/* @__PURE__ */ p.jsxs("div", { className: v.zenEditorIconWrapper, children: [
|
|
270
|
+
/* @__PURE__ */ p.jsx(
|
|
270
271
|
"span",
|
|
271
272
|
{
|
|
272
|
-
className: q(
|
|
273
|
+
className: q(v.zenEditorIconContainer, v.zenEditorIconError),
|
|
273
274
|
onClick: i,
|
|
274
|
-
children: /* @__PURE__ */
|
|
275
|
+
children: /* @__PURE__ */ p.jsx(ce, { style: { fontSize: "22px" } })
|
|
275
276
|
}
|
|
276
277
|
),
|
|
277
|
-
/* @__PURE__ */
|
|
278
|
+
/* @__PURE__ */ p.jsx(
|
|
278
279
|
"span",
|
|
279
280
|
{
|
|
280
|
-
className: q(
|
|
281
|
+
className: q(v.zenEditorIconContainer, v.zenEditorIconSuccess),
|
|
281
282
|
onClick: s,
|
|
282
|
-
children: /* @__PURE__ */
|
|
283
|
+
children: /* @__PURE__ */ p.jsx(se, { style: { fontSize: "22px" } })
|
|
283
284
|
}
|
|
284
285
|
)
|
|
285
286
|
] }),
|
|
286
|
-
/* @__PURE__ */
|
|
287
|
+
/* @__PURE__ */ p.jsx("div", { className: v.zenEditorCanvasContainer, ref: e })
|
|
287
288
|
] });
|
|
288
289
|
}
|
|
289
290
|
function ht(e) {
|
|
@@ -354,7 +355,7 @@ b = St([
|
|
|
354
355
|
y(0, R),
|
|
355
356
|
y(1, te),
|
|
356
357
|
y(2, Ze),
|
|
357
|
-
y(3,
|
|
358
|
+
y(3, Le)
|
|
358
359
|
], b);
|
|
359
360
|
var It = Object.defineProperty, Ct = Object.getOwnPropertyDescriptor, Ot = (e, n, r, t) => {
|
|
360
361
|
for (var i = t > 1 ? void 0 : t ? Ct(n, r) : n, s = e.length - 1, o; s >= 0; s--)
|
|
@@ -373,7 +374,7 @@ let T = class extends Ie {
|
|
|
373
374
|
this._zenEditorManagerService.position$.pipe(ke(this.dispose$)).subscribe((e) => {
|
|
374
375
|
if (e == null)
|
|
375
376
|
return;
|
|
376
|
-
const { width: n, height: r } = e, t = Me(
|
|
377
|
+
const { width: n, height: r } = e, t = Me(m, this._renderManagerService);
|
|
377
378
|
t != null && requestIdleCallback(() => {
|
|
378
379
|
t.engine.resizeBySize(n, r), this._calculatePagePosition(t), this._scrollToTop();
|
|
379
380
|
});
|
|
@@ -387,8 +388,8 @@ let T = class extends Ie {
|
|
|
387
388
|
let l = 0;
|
|
388
389
|
const g = c;
|
|
389
390
|
let h = 0, C = 0, E = Number.POSITIVE_INFINITY;
|
|
390
|
-
const { scaleX:
|
|
391
|
-
u > (s + a * 2) *
|
|
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);
|
|
392
393
|
const z = r.getViewport(Te.VIEW_MAIN);
|
|
393
394
|
if (E !== Number.POSITIVE_INFINITY && z != null) {
|
|
394
395
|
const le = z.transScroll2ViewportScrollValue(E, 0).x;
|
|
@@ -400,7 +401,7 @@ let T = class extends Ie {
|
|
|
400
401
|
}
|
|
401
402
|
_scrollToTop() {
|
|
402
403
|
var r;
|
|
403
|
-
const e = (r = this._renderManagerService.getRenderById(
|
|
404
|
+
const e = (r = this._renderManagerService.getRenderById(m)) == null ? void 0 : r.with(Re), n = {
|
|
404
405
|
startOffset: 0,
|
|
405
406
|
endOffset: 0
|
|
406
407
|
};
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(d,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("react"),require("rxjs"),require("@univerjs/sheets")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-ui","@univerjs/engine-render","@univerjs/sheets-ui","@univerjs/ui","react","rxjs","@univerjs/sheets"],o):(d=typeof globalThis<"u"?globalThis:d||self,o(d.UniverSheetsZenEditor={},d.UniverCore,d.UniverDocsUi,d.UniverEngineRender,d.UniverSheetsUi,d.UniverUi,d.React,d.rxjs,d.UniverSheets))})(this,function(d,o,
|
|
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
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var W;function ne(){if(W)return R;W=1;var e=m,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function s(l,c,v){var u,_={},E=null,I=null;v!==void 0&&(E=""+v),c.key!==void 0&&(E=""+c.key),c.ref!==void 0&&(I=c.ref);for(u in c)n.call(c,u)&&!a.hasOwnProperty(u)&&(_[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:I,props:_,_owner:i.current}}return R.Fragment=r,R.jsx=s,R.jsxs=s,R}var Y;function te(){return Y||(Y=1,w.exports=ne()),w.exports}var p=te(),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=m.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,a=e.extend,s=re(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),c=m.useRef("_".concat(se()));return K(r,"".concat(n),{defIds:r.defIds,idSuffix:c.current},g({ref:t,className:l},s),a)});function K(e,t,r,n,i){return m.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=m.forwardRef(function(e,t){return m.createElement(A,Object.assign({},e,{id:"check-mark-single",ref:t,icon:ae}))});H.displayName="CheckMarkSingle";var ce={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},G=m.forwardRef(function(e,t){return m.createElement(A,Object.assign({},e,{id:"close-single",ref:t,icon:ce}))});G.displayName="CloseSingle";function $(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=$(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function q(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=$(e))&&(n&&(n+=" "),n+=t);return n}class de{constructor(){T(this,"_position",null);T(this,"_position$",new k.BehaviorSubject(null));T(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(t){this._position=t,this._refresh(t)}getPosition(){return this._position}_refresh(t){this._position$.next(t)}}const B=o.createIdentifier("univer.sheet-zen-editor-manager.service"),C={zenEditor:"univer-zen-editor",zenEditorIconWrapper:"univer-zen-editor-icon-wrapper",zenEditorIconContainer:"univer-zen-editor-icon-container",zenEditorIconSuccess:"univer-zen-editor-icon-success",zenEditorIconError:"univer-zen-editor-icon-error",zenEditorCanvasContainer:"univer-zen-editor-canvas-container"},le="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT",ue={id:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],tables:[],customBlocks:[],paragraphs:[{startIndex:0}],sectionBreaks:[{startIndex:1}]},tableSource:{},documentStyle:{pageSize:{width:595,height:Number.POSITIVE_INFINITY},documentFlavor:o.DocumentFlavor.MODERN,marginTop:0,marginBottom:0,marginRight:0,marginLeft:0,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};function fe(){const e=m.useRef(null),t=o.useDependency(B),r=o.useDependency(h.IEditorService),n=o.useDependency(o.ICommandService);m.useEffect(()=>{const s=e.current;if(!s)return;const l=r.register({editorUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:ue,scrollBar:!0,noNeedVerticalAlign:!0,backScrollOffset:100},s),c=new ResizeObserver(()=>{t.setPosition(s.getBoundingClientRect())});return c.observe(s),()=>{l.dispose(),c.unobserve(s)}},[]);function i(){n.executeCommand(z.id)}function a(){n.executeCommand(b.id)}return p.jsxs("div",{className:C.zenEditor,children:[p.jsxs("div",{className:C.zenEditorIconWrapper,children:[p.jsx("span",{className:q(C.zenEditorIconContainer,C.zenEditorIconError),onClick:i,children:p.jsx(G,{style:{fontSize:"22px"}})}),p.jsx("span",{className:q(C.zenEditorIconContainer,C.zenEditorIconSuccess),onClick:a,children:p.jsx(H,{style:{fontSize:"22px"}})})]}),p.jsx("div",{className:C.zenEditorCanvasContainer,ref:e})]})}function _e(e){return{id:D.id,type:f.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",hidden$:S.getCurrentExclusiveRangeInterest$(e),disabled$:S.getCurrentRangeDisable$(e,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission,N.WorksheetSetCellValuePermission,N.WorksheetSetCellStylePermission],rangeTypes:[N.RangeProtectionPermissionEditPoint]})}}const ge={[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[D.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 he=Object.defineProperty,me=Object.getOwnPropertyDescriptor,Ie=(e,t,r,n)=>{for(var i=n>1?void 0:n?me(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&he(t,r,i),i},P=(e,t)=>(r,n)=>t(r,n,e);let j=class extends o.Disposable{constructor(e,t,r,n){super(),this._zenZoneService=e,this._commandService=t,this._menuManagerService=r,this._shortcutService=n,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(le,fe))}_initCommands(){[D,z,b].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(ge)}_initShortcuts(){[ve,Ee].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}};j=Ie([P(0,f.IZenZoneService),P(1,o.ICommandService),P(2,f.IMenuManagerService),P(3,f.IShortcutService)],j);var Se=Object.defineProperty,pe=Object.getOwnPropertyDescriptor,Ce=(e,t,r,n)=>{for(var i=n>1?void 0:n?pe(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&Se(t,r,i),i},X=(e,t)=>(r,n)=>t(r,n,e);let x=class extends o.RxDisposable{constructor(e,t){super(),this._zenEditorManagerService=e,this._renderManagerService=t,this._initialize()}_initialize(){this._syncZenEditorSize()}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(k.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{width:t,height:r}=e,n=S.getEditorObject(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService);n!=null&&requestIdleCallback(()=>{n.engine.resizeBySize(t,r),this._calculatePagePosition(n),this._scrollToTop()})})}_calculatePagePosition(e){const{document:t,scene:r,docBackground:n}=e,i=r==null?void 0:r.getParent(),{width:a,height:s,pageMarginLeft:l,pageMarginTop:c}=t;if(i==null||a===Number.POSITIVE_INFINITY||s===Number.POSITIVE_INFINITY)return;const{width:v,height:u}=i;let _=0;const E=c;let I=0,Z=0,y=Number.POSITIVE_INFINITY;const{scaleX:O,scaleY:U}=r.getAncestorScale();v>(a+l*2)*O?(_=v/2-a*O/2,_/=O,I=(v-l*2)/O,y=0):(_=l,I=a+l*2,y=(I-v/O)/2),u>s?Z=(u-c*2)/U:Z=s+c*2,r.resize(I,Z),t.translate(_,E),n.translate(_,E);const L=r.getViewport(h.VIEWPORT_KEY.VIEW_MAIN);if(y!==Number.POSITIVE_INFINITY&&L!=null){const Ne=L.transScroll2ViewportScrollValue(y,0).x;L.scrollToBarPos({x:Ne})}return this}_scrollToTop(){var r;const e=(r=this._renderManagerService.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:r.with(h.DocBackScrollRenderController),t={startOffset:0,endOffset:0};e&&e.scrollToRange(t)}};x=Ce([X(0,B),X(1,F.IRenderManagerService)],x);var Oe=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Te=(e,t,r,n)=>{for(var i=n>1?void 0:n?ye(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&Oe(t,r,i),i},Q=(e,t)=>(r,n)=>t(r,n,e);d.UniverSheetsZenEditorPlugin=(M=class extends o.Plugin{constructor(t=V,r,n){super(),this._config=t,this._injector=r,this._configService=n;const{menu:i,...a}=o.merge({},V,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ee,a),this._initializeDependencies(this._injector)}_initializeDependencies(t){[[j],[x],[B,{useClass:de}]].forEach(n=>t.add(n))}onReady(){this._injector.get(j)}onSteady(){this._injector.get(x)}},T(M,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),T(M,"type",o.UniverInstanceType.UNIVER_SHEET),M),d.UniverSheetsZenEditorPlugin=Te([Q(1,o.Inject(o.Injector)),Q(2,o.IConfigService)],d.UniverSheetsZenEditorPlugin),d.CancelZenEditCommand=z,d.ConfirmZenEditCommand=b,d.OpenZenEditorCommand=D,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
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"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-zen-editor",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5-nightly.202501201336",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Zen Editor plugin for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@univerjs/icons": "^0.2.12",
|
|
63
63
|
"clsx": "^2.1.1",
|
|
64
|
-
"@univerjs/
|
|
65
|
-
"@univerjs/
|
|
66
|
-
"@univerjs/
|
|
67
|
-
"@univerjs/sheets": "0.5.
|
|
68
|
-
"@univerjs/
|
|
69
|
-
"@univerjs/ui": "0.5.
|
|
70
|
-
"@univerjs/
|
|
64
|
+
"@univerjs/core": "0.5.5-nightly.202501201336",
|
|
65
|
+
"@univerjs/docs": "0.5.5-nightly.202501201336",
|
|
66
|
+
"@univerjs/engine-render": "0.5.5-nightly.202501201336",
|
|
67
|
+
"@univerjs/sheets": "0.5.5-nightly.202501201336",
|
|
68
|
+
"@univerjs/ui": "0.5.5-nightly.202501201336",
|
|
69
|
+
"@univerjs/sheets-ui": "0.5.5-nightly.202501201336",
|
|
70
|
+
"@univerjs/docs-ui": "0.5.5-nightly.202501201336"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"less": "^4.2.1",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"typescript": "^5.7.2",
|
|
79
79
|
"vite": "^6.0.7",
|
|
80
80
|
"vitest": "^2.1.8",
|
|
81
|
-
"@univerjs-infra/shared": "0.5.
|
|
81
|
+
"@univerjs-infra/shared": "0.5.5"
|
|
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
|