@univerjs/sheets-zen-editor 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +2 -2
- package/lib/cjs/locale/fr-FR.js +1 -0
- package/lib/es/index.js +290 -285
- package/lib/es/locale/fr-FR.js +11 -0
- package/lib/types/controllers/config.schema.d.ts +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/locale/fr-FR.d.ts +3 -0
- package/lib/umd/index.js +2 -2
- package/lib/umd/locale/fr-FR.js +1 -0
- package/package.json +15 -13
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Q=Object.defineProperty;var ee=(e,n,r)=>n in e?Q(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var O=(e,n,r)=>ee(e,typeof n!="symbol"?n+"":n,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),T=require("@univerjs/docs-ui"),Y=require("@univerjs/engine-render"),p=require("@univerjs/sheets-ui"),f=require("@univerjs/ui"),h=require("react"),W=require("rxjs"),y=require("@univerjs/sheets"),M={id:"zen-editor.command.open-zen-editor",type:o.CommandType.COMMAND,handler:async e=>{var b;const n=e.get(f.IZenZoneService),r=e.get(T.IEditorService),t=e.get(p.IEditorBridgeService),i=e.get(o.IUniverInstanceService),c=e.get(f.ISidebarService);c.visible&&(c.close(),await o.delayAnimationFrame()),n.open();const s=r.getEditor(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(s==null)return!1;const d=t.getLatestEditCellState();if(d==null)return!1;const a=(b=d.documentLayoutObject.documentModel)==null?void 0:b.getSnapshot();if(a==null)return!1;i.focusUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const{body:g,drawings:l,drawingsOrder:u,tableSource:v,settings:m}=o.Tools.deepClone(a),C={...s.getDocumentData(),body:g,drawings:l,drawingsOrder:u,tableSource:v,settings:m},E=[{startOffset:0,endOffset:0,collapsed:!0}];return s.focus(),s.setDocumentData(C,E),s.clearUndoRedoHistory(),!0}},U={id:"zen-editor.command.cancel-zen-edit",type:o.CommandType.COMMAND,handler:async e=>{const n=e.get(f.IZenZoneService),r=e.get(p.IEditorBridgeService),t=e.get(o.IUniverInstanceService),i=e.get(f.ISidebarService);i.visible&&(i.close(),await o.delayAnimationFrame()),n.close();const c=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);return c?(t.focusUnit(c.getUnitId()),r.refreshEditCellState(),!0):!1}},Z={id:"zen-editor.command.confirm-zen-edit",type:o.CommandType.COMMAND,handler:async e=>{var g;const n=e.get(f.IZenZoneService),r=e.get(p.IEditorBridgeService),t=e.get(o.IUniverInstanceService),i=e.get(T.IEditorService),c=e.get(f.ISidebarService);c.visible&&(c.close(),await o.delayAnimationFrame()),n.close();const s=i.getEditor(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(s==null)return!1;const d=e.get(Y.IRenderManagerService),a=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(a){const l=a.getUnitId(),u=(g=d.getRenderById(l))==null?void 0:g.with(p.EditingRenderController);if(u){const v=o.Tools.deepClone(s.getDocumentData());v.documentStyle.documentFlavor=o.DocumentFlavor.UNSPECIFIED,u.submitCellData(new o.DocumentDataModel(v))}return t.focusUnit(a.getUnitId()),r.refreshEditCellState(),!0}return!1}},te="sheets-zen-editor.config",ne={};var j={exports:{}},N={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var se=g,ce=Symbol.for("react.element"),ae=Symbol.for("react.fragment"),de=Object.prototype.hasOwnProperty,le=se.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ue={key:!0,ref:!0,__self:!0,__source:!0};function V(e,t,r){var n,i={},o=null,c=null;r!==void 0&&(o=""+r),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(c=t.ref);for(n in t)de.call(t,n)&&!ue.hasOwnProperty(n)&&(i[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)i[n]===void 0&&(i[n]=t[n]);return{$$typeof:ce,type:e,key:o,ref:c,props:i,_owner:le.current}}U.Fragment=ae;U.jsx=V;U.jsxs=V;F.exports=U;var E=F.exports,l=function(){return l=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},l.apply(this,arguments)},fe=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},w=g.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,o=e.extend,c=fe(e,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),d=g.useRef("_".concat(he()));return Y(r,"".concat(n),{defIds:r.defIds,idSuffix:d.current},l({ref:t,className:a},c),o)});function Y(e,t,r,n,i){return g.createElement(e.tag,l(l({key:t},ge(e,r,i)),n),(_e(e,r).children||[]).map(function(o,c){return Y(o,"".concat(t,"-").concat(e.tag,"-").concat(c),r,void 0,i)}))}function ge(e,t,r){var n=l({},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(o){var c=o[0],a=o[1];typeof a=="string"&&(n[c]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function _e(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)?l(l({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?l(l({},i),{attrs:l(l({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function he(){return Math.random().toString(36).substring(2,8)}w.displayName="UniverIcon";var ve={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"}}]},W=g.forwardRef(function(e,t){return g.createElement(w,Object.assign({},e,{id:"check-mark-single",ref:t,icon:ve}))});W.displayName="CheckMarkSingle";var Ee={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"}}]},K=g.forwardRef(function(e,t){return g.createElement(w,Object.assign({},e,{id:"close-single",ref:t,icon:Ee}))});K.displayName="CloseSingle";function q(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=q(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function A(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=q(e))&&(n&&(n+=" "),n+=t);return n}const Ie="univer-zen-editor",me="univer-zen-editor-icon-wrapper",pe="univer-zen-editor-icon-container",Se="univer-zen-editor-icon-success",Ce="univer-zen-editor-icon-error",Oe="univer-zen-editor-canvas-container",I={zenEditor:Ie,zenEditorIconWrapper:me,zenEditorIconContainer:pe,zenEditorIconSuccess:Se,zenEditorIconError:Ce,zenEditorCanvasContainer:Oe},ye="ZEN_EDITOR_PLUGIN_",Ne=`${ye}ZEN_EDITOR_COMPONENT`,Te={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 De(){const e=g.useRef(null),t=s.useDependency(j),r=s.useDependency(N.IEditorService),n=s.useDependency(s.ICommandService);g.useEffect(()=>{const c=e.current;if(!c)return;const a=r.register({editorUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:Te,scrollBar:!0,noNeedVerticalAlign:!0,backScrollOffset:100},c),d=new ResizeObserver(()=>{t.setPosition(c.getBoundingClientRect())});return d.observe(c),()=>{a.dispose(),d.unobserve(c)}},[]);function i(){n.executeCommand(x.id)}function o(){n.executeCommand(M.id)}return E.jsxs("div",{className:I.zenEditor,children:[E.jsxs("div",{className:I.zenEditorIconWrapper,children:[E.jsx("span",{className:A(I.zenEditorIconContainer,I.zenEditorIconError),onClick:i,children:E.jsx(K,{style:{fontSize:"22px"}})}),E.jsx("span",{className:A(I.zenEditorIconContainer,I.zenEditorIconSuccess),onClick:o,children:E.jsx(W,{style:{fontSize:"22px"}})})]}),E.jsx("div",{className:I.zenEditorCanvasContainer,ref:e})]})}function be(e){return{id:P.id,type:u.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",hidden$:m.getCurrentExclusiveRangeInterest$(e),disabled$:m.getCurrentRangeDisable$(e,{workbookTypes:[y.WorkbookEditablePermission],worksheetTypes:[y.WorksheetEditPermission,y.WorksheetSetCellValuePermission,y.WorksheetSetCellStylePermission],rangeTypes:[y.RangeProtectionPermissionEditPoint]})}}const Re={[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.OTHERS]:{[P.id]:{order:2,menuItemFactory:be}}}},ze={id:M.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:e=>H(e),binding:u.KeyCode.ENTER|u.MetaKeys.ALT},Pe={id:x.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:e=>H(e),binding:u.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 xe=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,Ue=(e,t,r,n)=>{for(var i=n>1?void 0:n?Me(t,r):t,o=e.length-1,c;o>=0;o--)(c=e[o])&&(i=(n?c(t,r,i):c(i))||i);return n&&i&&xe(t,r,i),i},D=(e,t)=>(r,n)=>t(r,n,e);let z=class extends s.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(Ne,De))}_initCommands(){[P,x,M].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Re)}_initShortcuts(){[ze,Pe].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}};z=Ue([D(0,u.IZenZoneService),D(1,s.ICommandService),D(2,u.IMenuManagerService),D(3,u.IShortcutService)],z);var Ze=Object.defineProperty,je=Object.getOwnPropertyDescriptor,we=(e,t,r,n)=>{for(var i=n>1?void 0:n?je(t,r):t,o=e.length-1,c;o>=0;o--)(c=e[o])&&(i=(n?c(t,r,i):c(i))||i);return n&&i&&Ze(t,r,i),i},$=(e,t)=>(r,n)=>t(r,n,e),b;exports.UniverSheetsZenEditorPlugin=(b=class extends s.Plugin{constructor(t=te,r,n){super(),this._config=t,this._injector=r,this._configService=n;const{menu:i,...o}=this._config;i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ee,o),this._initializeDependencies(this._injector)}_initializeDependencies(t){[[z],[R],[j,{useClass:ne}]].forEach(n=>t.add(n))}onReady(){this._injector.get(z)}onSteady(){this._injector.get(R)}},S(b,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),S(b,"type",s.UniverInstanceType.UNIVER_SHEET),b);exports.UniverSheetsZenEditorPlugin=we([$(1,s.Inject(s.Injector)),$(2,s.IConfigService)],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=x;exports.ConfirmZenEditCommand=M;exports.OpenZenEditorCommand=P;
|
|
9
|
+
*/var L;function re(){if(L)return N;L=1;var e=h,n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),t=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function s(d,a,g){var l,u={},v=null,m=null;g!==void 0&&(v=""+g),a.key!==void 0&&(v=""+a.key),a.ref!==void 0&&(m=a.ref);for(l in a)t.call(a,l)&&!c.hasOwnProperty(l)&&(u[l]=a[l]);if(d&&d.defaultProps)for(l in a=d.defaultProps,a)u[l]===void 0&&(u[l]=a[l]);return{$$typeof:n,type:d,key:v,ref:m,props:u,_owner:i.current}}return N.Fragment=r,N.jsx=s,N.jsxs=s,N}var $;function ie(){return $||($=1,j.exports=re()),j.exports}var I=ie(),_=function(){return _=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},_.apply(this,arguments)},oe=function(e,n){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.indexOf(t)<0&&(r[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,t=Object.getOwnPropertySymbols(e);i<t.length;i++)n.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(e,t[i])&&(r[t[i]]=e[t[i]]);return r},A=h.forwardRef(function(e,n){var r=e.icon,t=e.id,i=e.className,c=e.extend,s=oe(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(t," ").concat(i||"").trim(),a=h.useRef("_".concat(ae()));return q(r,"".concat(t),{defIds:r.defIds,idSuffix:a.current},_({ref:n,className:d},s),c)});function q(e,n,r,t,i){return h.createElement(e.tag,_(_({key:n},se(e,r,i)),t),(ce(e,r).children||[]).map(function(c,s){return q(c,"".concat(n,"-").concat(e.tag,"-").concat(s),r,void 0,i)}))}function se(e,n,r){var t=_({},e.attrs);r!=null&&r.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=r.colorChannel1);var i=n.defIds;return!i||i.length===0||(e.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(c){var s=c[0],d=c[1];typeof d=="string"&&(t[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function ce(e,n){var r,t=n.defIds;return!t||t.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?_(_({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&t&&t.indexOf(i.attrs.id)>-1?_(_({},i),{attrs:_(_({},i.attrs),{id:i.attrs.id+n.idSuffix})}):i})}):e}function ae(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var de={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},K=h.forwardRef(function(e,n){return h.createElement(A,Object.assign({},e,{id:"check-mark-single",ref:n,icon:de}))});K.displayName="CheckMarkSingle";var le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},H=h.forwardRef(function(e,n){return h.createElement(A,Object.assign({},e,{id:"close-single",ref:n,icon:le}))});H.displayName="CloseSingle";function G(e){var n,r,t="";if(typeof e=="string"||typeof e=="number")t+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(n=0;n<i;n++)e[n]&&(r=G(e[n]))&&(t&&(t+=" "),t+=r)}else for(r in e)e[r]&&(t&&(t+=" "),t+=r);return t}function F(){for(var e,n,r=0,t="",i=arguments.length;r<i;r++)(e=arguments[r])&&(n=G(e))&&(t&&(t+=" "),t+=n);return t}class ue{constructor(){O(this,"_position",null);O(this,"_position$",new W.BehaviorSubject(null));O(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(n){this._position=n,this._refresh(n)}getPosition(){return this._position}_refresh(n){this._position$.next(n)}}const B=o.createIdentifier("univer.sheet-zen-editor-manager.service"),fe="univer-zen-editor",ge="univer-zen-editor-icon-wrapper",_e="univer-zen-editor-icon-container",ve="univer-zen-editor-icon-success",he="univer-zen-editor-icon-error",me="univer-zen-editor-canvas-container",S={zenEditor:fe,zenEditorIconWrapper:ge,zenEditorIconContainer:_e,zenEditorIconSuccess:ve,zenEditorIconError:he,zenEditorCanvasContainer:me},Ee="ZEN_EDITOR_PLUGIN_",Ie=`${Ee}ZEN_EDITOR_COMPONENT`,Se={id:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],tables:[],customBlocks:[],paragraphs:[{startIndex:0}],sectionBreaks:[{startIndex:1}]},tableSource:{},documentStyle:{pageSize:{width:595,height:Number.POSITIVE_INFINITY},documentFlavor:o.DocumentFlavor.MODERN,marginTop:0,marginBottom:0,marginRight:0,marginLeft:0,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};function pe(){const e=h.useRef(null),n=o.useDependency(B),r=o.useDependency(T.IEditorService),t=o.useDependency(o.ICommandService);h.useEffect(()=>{const s=e.current;if(!s)return;const d=r.register({editorUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:Se,scrollBar:!0,noNeedVerticalAlign:!0,backScrollOffset:100},s),a=new ResizeObserver(()=>{n.setPosition(s.getBoundingClientRect())});return a.observe(s),()=>{d.dispose(),a.unobserve(s)}},[]);function i(){t.executeCommand(U.id)}function c(){t.executeCommand(Z.id)}return I.jsxs("div",{className:S.zenEditor,children:[I.jsxs("div",{className:S.zenEditorIconWrapper,children:[I.jsx("span",{className:F(S.zenEditorIconContainer,S.zenEditorIconError),onClick:i,children:I.jsx(H,{style:{fontSize:"22px"}})}),I.jsx("span",{className:F(S.zenEditorIconContainer,S.zenEditorIconSuccess),onClick:c,children:I.jsx(K,{style:{fontSize:"22px"}})})]}),I.jsx("div",{className:S.zenEditorCanvasContainer,ref:e})]})}function Ce(e){return{id:M.id,type:f.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",hidden$:p.getCurrentExclusiveRangeInterest$(e),disabled$:p.getCurrentRangeDisable$(e,{workbookTypes:[y.WorkbookEditablePermission],worksheetTypes:[y.WorksheetEditPermission,y.WorksheetSetCellValuePermission,y.WorksheetSetCellStylePermission],rangeTypes:[y.RangeProtectionPermissionEditPoint]})}}const Oe={[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[M.id]:{order:2,menuItemFactory:Ce}}}},ye={id:Z.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:e=>J(e),binding:f.KeyCode.ENTER|f.MetaKeys.ALT},Ne={id:U.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:e=>J(e),binding:f.KeyCode.ESC};function J(e){return e.getContextValue(o.FOCUSING_DOC)&&e.getContextValue(o.FOCUSING_UNIVER_EDITOR)&&e.getContextValue(o.EDITOR_ACTIVATED)&&!e.getContextValue(o.FOCUSING_EDITOR_STANDALONE)}var Te=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,be=(e,n,r,t)=>{for(var i=t>1?void 0:t?Re(n,r):n,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(t?s(n,r,i):s(i))||i);return t&&i&&Te(n,r,i),i},D=(e,n)=>(r,t)=>n(r,t,e);let P=class extends o.Disposable{constructor(e,n,r,t){super(),this._zenZoneService=e,this._commandService=n,this._menuManagerService=r,this._shortcutService=t,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(Ie,pe))}_initCommands(){[M,U,Z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Oe)}_initShortcuts(){[ye,Ne].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}};P=be([D(0,f.IZenZoneService),D(1,o.ICommandService),D(2,f.IMenuManagerService),D(3,f.IShortcutService)],P);var De=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,Pe=(e,n,r,t)=>{for(var i=t>1?void 0:t?ze(n,r):n,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(t?s(n,r,i):s(i))||i);return t&&i&&De(n,r,i),i},k=(e,n)=>(r,t)=>n(r,t,e);let x=class extends o.RxDisposable{constructor(e,n){super(),this._zenEditorManagerService=e,this._renderManagerService=n,this._initialize()}_initialize(){this._syncZenEditorSize()}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(W.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{width:n,height:r}=e,t=p.getEditorObject(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService);t!=null&&requestIdleCallback(()=>{t.engine.resizeBySize(n,r),this._calculatePagePosition(t),this._scrollToTop()})})}_calculatePagePosition(e){const{document:n,scene:r,docBackground:t}=e,i=r==null?void 0:r.getParent(),{width:c,height:s,pageMarginLeft:d,pageMarginTop:a}=n;if(i==null||c===Number.POSITIVE_INFINITY||s===Number.POSITIVE_INFINITY)return;const{width:g,height:l}=i;let u=0;const v=a;let m=0,R=0,C=Number.POSITIVE_INFINITY;const{scaleX:E,scaleY:b}=r.getAncestorScale();g>(c+d*2)*E?(u=g/2-c*E/2,u/=E,m=(g-d*2)/E,C=0):(u=d,m=c+d*2,C=(m-g/E)/2),l>s?R=(l-a*2)/b:R=s+a*2,r.resize(m,R),n.translate(u,v),t.translate(u,v);const w=r.getViewport(T.VIEWPORT_KEY.VIEW_MAIN);if(C!==Number.POSITIVE_INFINITY&&w!=null){const X=w.transScroll2ViewportScrollValue(C,0).x;w.scrollToBarPos({x:X})}return this}_scrollToTop(){var r;const e=(r=this._renderManagerService.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:r.with(T.DocBackScrollRenderController),n={startOffset:0,endOffset:0};e&&e.scrollToRange(n)}};x=Pe([k(0,B),k(1,Y.IRenderManagerService)],x);var xe=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,Ue=(e,n,r,t)=>{for(var i=t>1?void 0:t?Me(n,r):n,c=e.length-1,s;c>=0;c--)(s=e[c])&&(i=(t?s(n,r,i):s(i))||i);return t&&i&&xe(n,r,i),i},V=(e,n)=>(r,t)=>n(r,t,e),z;exports.UniverSheetsZenEditorPlugin=(z=class extends o.Plugin{constructor(n=ne,r,t){super(),this._config=n,this._injector=r,this._configService=t;const{menu:i,...c}=this._config;i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(te,c),this._initializeDependencies(this._injector)}_initializeDependencies(n){[[P],[x],[B,{useClass:ue}]].forEach(t=>n.add(t))}onReady(){this._injector.get(P)}onSteady(){this._injector.get(x)}},O(z,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),O(z,"type",o.UniverInstanceType.UNIVER_SHEET),z);exports.UniverSheetsZenEditorPlugin=Ue([V(1,o.Inject(o.Injector)),V(2,o.IConfigService)],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=U;exports.ConfirmZenEditCommand=Z;exports.OpenZenEditorCommand=M;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e={shortcut:{sheet:{"zen-edit-cancel":"Annuler l'édition plein écran","zen-edit-confirm":"Confirmer l'édition plein écran"}}};module.exports=e;
|
package/lib/es/index.js
CHANGED
|
@@ -1,156 +1,79 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { CommandType as
|
|
5
|
-
import { IEditorService as
|
|
6
|
-
import { IRenderManagerService as
|
|
7
|
-
import { IEditorBridgeService as
|
|
8
|
-
import { IZenZoneService as
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import { WorkbookEditablePermission as
|
|
12
|
-
const
|
|
1
|
+
var de = Object.defineProperty;
|
|
2
|
+
var ue = (e, n, r) => n in e ? de(e, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[n] = r;
|
|
3
|
+
var S = (e, n, r) => ue(e, typeof n != "symbol" ? n + "" : n, r);
|
|
4
|
+
import { CommandType as M, IUniverInstanceService as D, delayAnimationFrame as w, DOCS_ZEN_EDITOR_UNIT_ID_KEY as v, Tools as X, UniverInstanceType as j, DocumentFlavor as Q, DocumentDataModel as fe, createIdentifier as ge, DEFAULT_EMPTY_DOCUMENT_VALUE as he, useDependency as x, ICommandService as ee, FOCUSING_DOC as me, FOCUSING_UNIVER_EDITOR as _e, EDITOR_ACTIVATED as pe, FOCUSING_EDITOR_STANDALONE as ve, Disposable as Ee, RxDisposable as Se, Plugin as Ie, Inject as Ce, Injector as Oe, IConfigService as ye } from "@univerjs/core";
|
|
5
|
+
import { IEditorService as U, VIEWPORT_KEY as Ne, DocBackScrollRenderController as be } from "@univerjs/docs-ui";
|
|
6
|
+
import { IRenderManagerService as te } from "@univerjs/engine-render";
|
|
7
|
+
import { IEditorBridgeService as Z, EditingRenderController as Te, getCurrentExclusiveRangeInterest$ as Re, getCurrentRangeDisable$ as ze, getEditorObject as xe } from "@univerjs/sheets-ui";
|
|
8
|
+
import { IZenZoneService as R, ISidebarService as A, MenuItemType as Pe, ContextMenuPosition as Me, ContextMenuGroup as De, KeyCode as ne, MetaKeys as we, IMenuManagerService as je, IShortcutService as Ue } from "@univerjs/ui";
|
|
9
|
+
import Ze, { forwardRef as L, useRef as re, createElement as $, useEffect as Ae } from "react";
|
|
10
|
+
import { BehaviorSubject as Le, takeUntil as $e } from "rxjs";
|
|
11
|
+
import { WorkbookEditablePermission as Be, WorksheetEditPermission as ke, WorksheetSetCellValuePermission as Fe, WorksheetSetCellStylePermission as Ve, RangeProtectionPermissionEditPoint as We } from "@univerjs/sheets";
|
|
12
|
+
const B = {
|
|
13
13
|
id: "zen-editor.command.open-zen-editor",
|
|
14
|
-
type:
|
|
14
|
+
type: M.COMMAND,
|
|
15
15
|
handler: async (e) => {
|
|
16
|
-
var
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const o = r.getEditor(
|
|
16
|
+
var O;
|
|
17
|
+
const n = e.get(R), r = e.get(U), t = e.get(Z), i = e.get(D), s = e.get(A);
|
|
18
|
+
s.visible && (s.close(), await w()), n.open();
|
|
19
|
+
const o = r.getEditor(v);
|
|
20
20
|
if (o == null)
|
|
21
21
|
return !1;
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
22
|
+
const a = t.getLatestEditCellState();
|
|
23
|
+
if (a == null)
|
|
24
24
|
return !1;
|
|
25
|
-
const c = (
|
|
25
|
+
const c = (O = a.documentLayoutObject.documentModel) == null ? void 0 : O.getSnapshot();
|
|
26
26
|
if (c == null)
|
|
27
27
|
return !1;
|
|
28
|
-
i.focusUnit(
|
|
29
|
-
const { body:
|
|
28
|
+
i.focusUnit(v);
|
|
29
|
+
const { body: u, drawings: l, drawingsOrder: d, tableSource: g, settings: h } = X.deepClone(c), E = {
|
|
30
30
|
...o.getDocumentData(),
|
|
31
|
-
body:
|
|
32
|
-
drawings:
|
|
33
|
-
drawingsOrder:
|
|
34
|
-
tableSource:
|
|
35
|
-
settings:
|
|
36
|
-
},
|
|
31
|
+
body: u,
|
|
32
|
+
drawings: l,
|
|
33
|
+
drawingsOrder: d,
|
|
34
|
+
tableSource: g,
|
|
35
|
+
settings: h
|
|
36
|
+
}, m = [
|
|
37
37
|
{
|
|
38
38
|
startOffset: 0,
|
|
39
39
|
endOffset: 0,
|
|
40
40
|
collapsed: !0
|
|
41
41
|
}
|
|
42
42
|
];
|
|
43
|
-
return o.focus(), o.setDocumentData(
|
|
43
|
+
return o.focus(), o.setDocumentData(E, m), o.clearUndoRedoHistory(), !0;
|
|
44
44
|
}
|
|
45
|
-
},
|
|
45
|
+
}, k = {
|
|
46
46
|
id: "zen-editor.command.cancel-zen-edit",
|
|
47
|
-
type:
|
|
47
|
+
type: M.COMMAND,
|
|
48
48
|
handler: async (e) => {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
return
|
|
49
|
+
const n = e.get(R), r = e.get(Z), t = e.get(D), i = e.get(A);
|
|
50
|
+
i.visible && (i.close(), await w()), n.close();
|
|
51
|
+
const s = t.getCurrentUnitForType(j.UNIVER_SHEET);
|
|
52
|
+
return s ? (t.focusUnit(s.getUnitId()), r.refreshEditCellState(), !0) : !1;
|
|
53
53
|
}
|
|
54
|
-
},
|
|
54
|
+
}, F = {
|
|
55
55
|
id: "zen-editor.command.confirm-zen-edit",
|
|
56
|
-
type:
|
|
56
|
+
type: M.COMMAND,
|
|
57
57
|
handler: async (e) => {
|
|
58
|
-
var
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
const o = i.getEditor(
|
|
58
|
+
var u;
|
|
59
|
+
const n = e.get(R), r = e.get(Z), t = e.get(D), i = e.get(U), s = e.get(A);
|
|
60
|
+
s.visible && (s.close(), await w()), n.close();
|
|
61
|
+
const o = i.getEditor(v);
|
|
62
62
|
if (o == null)
|
|
63
63
|
return !1;
|
|
64
|
-
const
|
|
64
|
+
const a = e.get(te), c = t.getCurrentUnitForType(j.UNIVER_SHEET);
|
|
65
65
|
if (c) {
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
|
|
66
|
+
const l = c.getUnitId(), d = (u = a.getRenderById(l)) == null ? void 0 : u.with(Te);
|
|
67
|
+
if (d) {
|
|
68
|
+
const g = X.deepClone(o.getDocumentData());
|
|
69
|
+
g.documentStyle.documentFlavor = Q.UNSPECIFIED, d.submitCellData(new fe(g));
|
|
70
70
|
}
|
|
71
|
-
return
|
|
71
|
+
return t.focusUnit(c.getUnitId()), r.refreshEditCellState(), !0;
|
|
72
72
|
}
|
|
73
73
|
return !1;
|
|
74
74
|
}
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
constructor() {
|
|
78
|
-
v(this, "_position", null);
|
|
79
|
-
v(this, "_position$", new je(null));
|
|
80
|
-
v(this, "position$", this._position$.asObservable());
|
|
81
|
-
}
|
|
82
|
-
dispose() {
|
|
83
|
-
this._position$.complete(), this._position = null;
|
|
84
|
-
}
|
|
85
|
-
setPosition(t) {
|
|
86
|
-
this._position = t, this._refresh(t);
|
|
87
|
-
}
|
|
88
|
-
getPosition() {
|
|
89
|
-
return this._position;
|
|
90
|
-
}
|
|
91
|
-
_refresh(t) {
|
|
92
|
-
this._position$.next(t);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
const $ = de(
|
|
96
|
-
"univer.sheet-zen-editor-manager.service"
|
|
97
|
-
);
|
|
98
|
-
var Ye = Object.defineProperty, He = Object.getOwnPropertyDescriptor, Ge = (e, t, r, n) => {
|
|
99
|
-
for (var i = n > 1 ? void 0 : n ? He(t, r) : t, o = e.length - 1, s; o >= 0; o--)
|
|
100
|
-
(s = e[o]) && (i = (n ? s(t, r, i) : s(i)) || i);
|
|
101
|
-
return n && i && Ye(t, r, i), i;
|
|
102
|
-
}, k = (e, t) => (r, n) => t(r, n, e);
|
|
103
|
-
let y = class extends ue {
|
|
104
|
-
constructor(e, t) {
|
|
105
|
-
super(), this._zenEditorManagerService = e, this._renderManagerService = t, this._initialize();
|
|
106
|
-
}
|
|
107
|
-
_initialize() {
|
|
108
|
-
this._syncZenEditorSize();
|
|
109
|
-
}
|
|
110
|
-
// Listen to changes in the size of the zen editor container to set the size of the editor.
|
|
111
|
-
_syncZenEditorSize() {
|
|
112
|
-
this._zenEditorManagerService.position$.pipe(we(this.dispose$)).subscribe((e) => {
|
|
113
|
-
if (e == null)
|
|
114
|
-
return;
|
|
115
|
-
const { width: t, height: r } = e, n = Ne(p, this._renderManagerService);
|
|
116
|
-
n != null && requestIdleCallback(() => {
|
|
117
|
-
n.engine.resizeBySize(t, r), this._calculatePagePosition(n), this._scrollToTop();
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
_calculatePagePosition(e) {
|
|
122
|
-
const { document: t, scene: r, docBackground: n } = e, i = r == null ? void 0 : r.getParent(), { width: o, height: s, pageMarginLeft: c, pageMarginTop: a } = t;
|
|
123
|
-
if (i == null || o === Number.POSITIVE_INFINITY || s === Number.POSITIVE_INFINITY)
|
|
124
|
-
return;
|
|
125
|
-
const { width: u, height: g } = i;
|
|
126
|
-
let d = 0;
|
|
127
|
-
const S = a;
|
|
128
|
-
let E = 0, I = 0, _ = Number.POSITIVE_INFINITY;
|
|
129
|
-
const { scaleX: f, scaleY: oe } = r.getAncestorScale();
|
|
130
|
-
u > (o + c * 2) * f ? (d = u / 2 - o * f / 2, d /= f, E = (u - c * 2) / f, _ = 0) : (d = c, E = o + c * 2, _ = (E - u / f) / 2), g > s ? I = (g - a * 2) / oe : I = s + a * 2, r.resize(E, I), t.translate(d, S), n.translate(d, S);
|
|
131
|
-
const z = r.getViewport(Ce.VIEW_MAIN);
|
|
132
|
-
if (_ !== Number.POSITIVE_INFINITY && z != null) {
|
|
133
|
-
const se = z.transScroll2ViewportScrollValue(_, 0).x;
|
|
134
|
-
z.scrollToBarPos({
|
|
135
|
-
x: se
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
return this;
|
|
139
|
-
}
|
|
140
|
-
_scrollToTop() {
|
|
141
|
-
var r;
|
|
142
|
-
const e = (r = this._renderManagerService.getRenderById(p)) == null ? void 0 : r.with(Oe), t = {
|
|
143
|
-
startOffset: 0,
|
|
144
|
-
endOffset: 0
|
|
145
|
-
};
|
|
146
|
-
e && e.scrollToRange(t);
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
y = Ge([
|
|
150
|
-
k(0, $),
|
|
151
|
-
k(1, K)
|
|
152
|
-
], y);
|
|
153
|
-
var J = { exports: {} }, b = {};
|
|
75
|
+
}, He = "sheets-zen-editor.config", Ye = {};
|
|
76
|
+
var P = { exports: {} }, I = {};
|
|
154
77
|
/**
|
|
155
78
|
* @license React
|
|
156
79
|
* react-jsx-runtime.production.min.js
|
|
@@ -160,101 +83,128 @@ var J = { exports: {} }, b = {};
|
|
|
160
83
|
* This source code is licensed under the MIT license found in the
|
|
161
84
|
* LICENSE file in the root directory of this source tree.
|
|
162
85
|
*/
|
|
163
|
-
var
|
|
164
|
-
function
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
86
|
+
var H;
|
|
87
|
+
function Ge() {
|
|
88
|
+
if (H) return I;
|
|
89
|
+
H = 1;
|
|
90
|
+
var e = Ze, 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 l, d = {}, 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 (l in c) t.call(c, l) && !s.hasOwnProperty(l) && (d[l] = c[l]);
|
|
95
|
+
if (a && a.defaultProps) for (l in c = a.defaultProps, c) d[l] === void 0 && (d[l] = c[l]);
|
|
96
|
+
return { $$typeof: n, type: a, key: g, ref: h, props: d, _owner: i.current };
|
|
97
|
+
}
|
|
98
|
+
return I.Fragment = r, I.jsx = o, I.jsxs = o, I;
|
|
170
99
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
var
|
|
176
|
-
return
|
|
177
|
-
for (var
|
|
178
|
-
|
|
179
|
-
for (var i in
|
|
100
|
+
var Y;
|
|
101
|
+
function qe() {
|
|
102
|
+
return Y || (Y = 1, P.exports = Ge()), P.exports;
|
|
103
|
+
}
|
|
104
|
+
var _ = qe(), f = function() {
|
|
105
|
+
return f = Object.assign || function(e) {
|
|
106
|
+
for (var n, r = 1, t = arguments.length; r < t; r++) {
|
|
107
|
+
n = arguments[r];
|
|
108
|
+
for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && (e[i] = n[i]);
|
|
180
109
|
}
|
|
181
110
|
return e;
|
|
182
|
-
},
|
|
183
|
-
},
|
|
111
|
+
}, f.apply(this, arguments);
|
|
112
|
+
}, Je = function(e, n) {
|
|
184
113
|
var r = {};
|
|
185
|
-
for (var
|
|
114
|
+
for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && n.indexOf(t) < 0 && (r[t] = e[t]);
|
|
186
115
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
187
|
-
for (var i = 0,
|
|
188
|
-
|
|
116
|
+
for (var i = 0, t = Object.getOwnPropertySymbols(e); i < t.length; i++)
|
|
117
|
+
n.indexOf(t[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[i]) && (r[t[i]] = e[t[i]]);
|
|
189
118
|
return r;
|
|
190
|
-
},
|
|
191
|
-
var r = e.icon,
|
|
192
|
-
return
|
|
119
|
+
}, V = L(function(e, n) {
|
|
120
|
+
var r = e.icon, t = e.id, i = e.className, s = e.extend, o = Je(e, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(t, " ").concat(i || "").trim(), c = re("_".concat(Qe()));
|
|
121
|
+
return ie(r, "".concat(t), { defIds: r.defIds, idSuffix: c.current }, f({ ref: n, className: a }, o), s);
|
|
193
122
|
});
|
|
194
|
-
function
|
|
195
|
-
return
|
|
196
|
-
return
|
|
123
|
+
function ie(e, n, r, t, i) {
|
|
124
|
+
return $(e.tag, f(f({ key: n }, Ke(e, r, i)), t), (Xe(e, r).children || []).map(function(s, o) {
|
|
125
|
+
return ie(s, "".concat(n, "-").concat(e.tag, "-").concat(o), r, void 0, i);
|
|
197
126
|
}));
|
|
198
127
|
}
|
|
199
|
-
function
|
|
200
|
-
var
|
|
201
|
-
r != null && r.colorChannel1 &&
|
|
202
|
-
var i =
|
|
203
|
-
return !i || i.length === 0 || (e.tag === "use" &&
|
|
204
|
-
var
|
|
205
|
-
typeof
|
|
206
|
-
})),
|
|
128
|
+
function Ke(e, n, r) {
|
|
129
|
+
var t = f({}, e.attrs);
|
|
130
|
+
r != null && r.colorChannel1 && t.fill === "colorChannel1" && (t.fill = r.colorChannel1);
|
|
131
|
+
var i = n.defIds;
|
|
132
|
+
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, ")")));
|
|
135
|
+
})), t;
|
|
207
136
|
}
|
|
208
|
-
function
|
|
209
|
-
var r,
|
|
210
|
-
return !
|
|
211
|
-
return typeof i.attrs.id == "string" &&
|
|
137
|
+
function Xe(e, n) {
|
|
138
|
+
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;
|
|
212
141
|
}) }) : e;
|
|
213
142
|
}
|
|
214
|
-
function
|
|
143
|
+
function Qe() {
|
|
215
144
|
return Math.random().toString(36).substring(2, 8);
|
|
216
145
|
}
|
|
217
|
-
|
|
218
|
-
var
|
|
219
|
-
return
|
|
146
|
+
V.displayName = "UniverIcon";
|
|
147
|
+
var et = { 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" } }] }, oe = L(function(e, n) {
|
|
148
|
+
return $(V, Object.assign({}, e, {
|
|
220
149
|
id: "check-mark-single",
|
|
221
|
-
ref:
|
|
222
|
-
icon:
|
|
150
|
+
ref: n,
|
|
151
|
+
icon: et
|
|
223
152
|
}));
|
|
224
153
|
});
|
|
225
|
-
|
|
226
|
-
var
|
|
227
|
-
return
|
|
154
|
+
oe.displayName = "CheckMarkSingle";
|
|
155
|
+
var tt = { 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" } }] }, se = L(function(e, n) {
|
|
156
|
+
return $(V, Object.assign({}, e, {
|
|
228
157
|
id: "close-single",
|
|
229
|
-
ref:
|
|
230
|
-
icon:
|
|
158
|
+
ref: n,
|
|
159
|
+
icon: tt
|
|
231
160
|
}));
|
|
232
161
|
});
|
|
233
|
-
|
|
234
|
-
function
|
|
235
|
-
var
|
|
236
|
-
if (typeof e == "string" || typeof e == "number")
|
|
162
|
+
se.displayName = "CloseSingle";
|
|
163
|
+
function ce(e) {
|
|
164
|
+
var n, r, t = "";
|
|
165
|
+
if (typeof e == "string" || typeof e == "number") t += e;
|
|
237
166
|
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
238
167
|
var i = e.length;
|
|
239
|
-
for (
|
|
240
|
-
} else for (r in e) e[r] && (
|
|
241
|
-
return
|
|
168
|
+
for (n = 0; n < i; n++) e[n] && (r = ce(e[n])) && (t && (t += " "), t += r);
|
|
169
|
+
} else for (r in e) e[r] && (t && (t += " "), t += r);
|
|
170
|
+
return t;
|
|
171
|
+
}
|
|
172
|
+
function G() {
|
|
173
|
+
for (var e, n, r = 0, t = "", i = arguments.length; r < i; r++) (e = arguments[r]) && (n = ce(e)) && (t && (t += " "), t += n);
|
|
174
|
+
return t;
|
|
242
175
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
176
|
+
class nt {
|
|
177
|
+
constructor() {
|
|
178
|
+
S(this, "_position", null);
|
|
179
|
+
S(this, "_position$", new Le(null));
|
|
180
|
+
S(this, "position$", this._position$.asObservable());
|
|
181
|
+
}
|
|
182
|
+
dispose() {
|
|
183
|
+
this._position$.complete(), this._position = null;
|
|
184
|
+
}
|
|
185
|
+
setPosition(n) {
|
|
186
|
+
this._position = n, this._refresh(n);
|
|
187
|
+
}
|
|
188
|
+
getPosition() {
|
|
189
|
+
return this._position;
|
|
190
|
+
}
|
|
191
|
+
_refresh(n) {
|
|
192
|
+
this._position$.next(n);
|
|
193
|
+
}
|
|
246
194
|
}
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
195
|
+
const W = ge(
|
|
196
|
+
"univer.sheet-zen-editor-manager.service"
|
|
197
|
+
), rt = "univer-zen-editor", it = "univer-zen-editor-icon-wrapper", ot = "univer-zen-editor-icon-container", st = "univer-zen-editor-icon-success", ct = "univer-zen-editor-icon-error", at = "univer-zen-editor-canvas-container", p = {
|
|
198
|
+
zenEditor: rt,
|
|
199
|
+
zenEditorIconWrapper: it,
|
|
200
|
+
zenEditorIconContainer: ot,
|
|
201
|
+
zenEditorIconSuccess: st,
|
|
202
|
+
zenEditorIconError: ct,
|
|
203
|
+
zenEditorCanvasContainer: at
|
|
204
|
+
}, lt = "ZEN_EDITOR_PLUGIN_", dt = `${lt}ZEN_EDITOR_COMPONENT`, ut = {
|
|
205
|
+
id: v,
|
|
256
206
|
body: {
|
|
257
|
-
dataStream: `${
|
|
207
|
+
dataStream: `${he}`,
|
|
258
208
|
textRuns: [],
|
|
259
209
|
tables: [],
|
|
260
210
|
customBlocks: [],
|
|
@@ -273,7 +223,7 @@ const ct = "univer-zen-editor", at = "univer-zen-editor-icon-wrapper", lt = "uni
|
|
|
273
223
|
width: 595,
|
|
274
224
|
height: Number.POSITIVE_INFINITY
|
|
275
225
|
},
|
|
276
|
-
documentFlavor:
|
|
226
|
+
documentFlavor: Q.MODERN,
|
|
277
227
|
marginTop: 0,
|
|
278
228
|
marginBottom: 0,
|
|
279
229
|
marginRight: 0,
|
|
@@ -286,158 +236,213 @@ const ct = "univer-zen-editor", at = "univer-zen-editor-icon-wrapper", lt = "uni
|
|
|
286
236
|
drawings: {},
|
|
287
237
|
drawingsOrder: []
|
|
288
238
|
};
|
|
289
|
-
function
|
|
290
|
-
const e =
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
if (!
|
|
239
|
+
function ft() {
|
|
240
|
+
const e = re(null), n = x(W), r = x(U), t = x(ee);
|
|
241
|
+
Ae(() => {
|
|
242
|
+
const o = e.current;
|
|
243
|
+
if (!o)
|
|
294
244
|
return;
|
|
295
|
-
const
|
|
245
|
+
const a = r.register(
|
|
296
246
|
{
|
|
297
|
-
editorUnitId:
|
|
298
|
-
initialSnapshot:
|
|
247
|
+
editorUnitId: v,
|
|
248
|
+
initialSnapshot: ut,
|
|
299
249
|
scrollBar: !0,
|
|
300
250
|
noNeedVerticalAlign: !0,
|
|
301
251
|
backScrollOffset: 100
|
|
302
252
|
},
|
|
303
|
-
|
|
304
|
-
),
|
|
305
|
-
|
|
253
|
+
o
|
|
254
|
+
), c = new ResizeObserver(() => {
|
|
255
|
+
n.setPosition(o.getBoundingClientRect());
|
|
306
256
|
});
|
|
307
|
-
return
|
|
308
|
-
|
|
257
|
+
return c.observe(o), () => {
|
|
258
|
+
a.dispose(), c.unobserve(o);
|
|
309
259
|
};
|
|
310
260
|
}, []);
|
|
311
261
|
function i() {
|
|
312
|
-
|
|
262
|
+
t.executeCommand(k.id);
|
|
313
263
|
}
|
|
314
|
-
function
|
|
315
|
-
|
|
264
|
+
function s() {
|
|
265
|
+
t.executeCommand(F.id);
|
|
316
266
|
}
|
|
317
|
-
return /* @__PURE__ */
|
|
318
|
-
/* @__PURE__ */
|
|
319
|
-
/* @__PURE__ */
|
|
267
|
+
return /* @__PURE__ */ _.jsxs("div", { className: p.zenEditor, children: [
|
|
268
|
+
/* @__PURE__ */ _.jsxs("div", { className: p.zenEditorIconWrapper, children: [
|
|
269
|
+
/* @__PURE__ */ _.jsx(
|
|
320
270
|
"span",
|
|
321
271
|
{
|
|
322
|
-
className:
|
|
272
|
+
className: G(p.zenEditorIconContainer, p.zenEditorIconError),
|
|
323
273
|
onClick: i,
|
|
324
|
-
children: /* @__PURE__ */
|
|
274
|
+
children: /* @__PURE__ */ _.jsx(se, { style: { fontSize: "22px" } })
|
|
325
275
|
}
|
|
326
276
|
),
|
|
327
|
-
/* @__PURE__ */
|
|
277
|
+
/* @__PURE__ */ _.jsx(
|
|
328
278
|
"span",
|
|
329
279
|
{
|
|
330
|
-
className:
|
|
331
|
-
onClick:
|
|
332
|
-
children: /* @__PURE__ */
|
|
280
|
+
className: G(p.zenEditorIconContainer, p.zenEditorIconSuccess),
|
|
281
|
+
onClick: s,
|
|
282
|
+
children: /* @__PURE__ */ _.jsx(oe, { style: { fontSize: "22px" } })
|
|
333
283
|
}
|
|
334
284
|
)
|
|
335
285
|
] }),
|
|
336
|
-
/* @__PURE__ */
|
|
286
|
+
/* @__PURE__ */ _.jsx("div", { className: p.zenEditorCanvasContainer, ref: e })
|
|
337
287
|
] });
|
|
338
288
|
}
|
|
339
|
-
function
|
|
289
|
+
function gt(e) {
|
|
340
290
|
return {
|
|
341
|
-
id:
|
|
342
|
-
type:
|
|
291
|
+
id: B.id,
|
|
292
|
+
type: Pe.BUTTON,
|
|
343
293
|
title: "rightClick.zenEditor",
|
|
344
294
|
icon: "AmplifySingle",
|
|
345
|
-
hidden$:
|
|
346
|
-
disabled$:
|
|
295
|
+
hidden$: Re(e),
|
|
296
|
+
disabled$: ze(e, { workbookTypes: [Be], worksheetTypes: [ke, Fe, Ve], rangeTypes: [We] })
|
|
347
297
|
};
|
|
348
298
|
}
|
|
349
|
-
const
|
|
350
|
-
[
|
|
351
|
-
[
|
|
352
|
-
[
|
|
299
|
+
const ht = {
|
|
300
|
+
[Me.MAIN_AREA]: {
|
|
301
|
+
[De.OTHERS]: {
|
|
302
|
+
[B.id]: {
|
|
353
303
|
order: 2,
|
|
354
|
-
menuItemFactory:
|
|
304
|
+
menuItemFactory: gt
|
|
355
305
|
}
|
|
356
306
|
}
|
|
357
307
|
}
|
|
358
|
-
},
|
|
359
|
-
id:
|
|
308
|
+
}, mt = {
|
|
309
|
+
id: F.id,
|
|
360
310
|
description: "shortcut.sheet.zen-edit-confirm",
|
|
361
311
|
group: "4_sheet-edit",
|
|
362
|
-
preconditions: (e) =>
|
|
363
|
-
binding:
|
|
364
|
-
},
|
|
365
|
-
id:
|
|
312
|
+
preconditions: (e) => ae(e),
|
|
313
|
+
binding: ne.ENTER | we.ALT
|
|
314
|
+
}, _t = {
|
|
315
|
+
id: k.id,
|
|
366
316
|
description: "shortcut.sheet.zen-edit-cancel",
|
|
367
317
|
group: "4_sheet-edit",
|
|
368
|
-
preconditions: (e) =>
|
|
369
|
-
binding:
|
|
318
|
+
preconditions: (e) => ae(e),
|
|
319
|
+
binding: ne.ESC
|
|
370
320
|
};
|
|
371
|
-
function
|
|
372
|
-
return e.getContextValue(
|
|
321
|
+
function ae(e) {
|
|
322
|
+
return e.getContextValue(me) && e.getContextValue(_e) && e.getContextValue(pe) && !e.getContextValue(ve);
|
|
373
323
|
}
|
|
374
|
-
var
|
|
375
|
-
for (var i =
|
|
376
|
-
(
|
|
377
|
-
return
|
|
378
|
-
},
|
|
379
|
-
let
|
|
380
|
-
constructor(e,
|
|
381
|
-
super(), this._zenZoneService = e, this._commandService =
|
|
324
|
+
var pt = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, Et = (e, n, r, t) => {
|
|
325
|
+
for (var i = t > 1 ? void 0 : t ? vt(n, r) : n, s = e.length - 1, o; s >= 0; s--)
|
|
326
|
+
(o = e[s]) && (i = (t ? o(n, r, i) : o(i)) || i);
|
|
327
|
+
return t && i && pt(n, r, i), i;
|
|
328
|
+
}, y = (e, n) => (r, t) => n(r, t, e);
|
|
329
|
+
let b = class extends Ee {
|
|
330
|
+
constructor(e, n, r, t) {
|
|
331
|
+
super(), this._zenZoneService = e, this._commandService = n, this._menuManagerService = r, this._shortcutService = t, this._initialize();
|
|
382
332
|
}
|
|
383
333
|
_initialize() {
|
|
384
334
|
this._initCustomComponents(), this._initCommands(), this._initMenus(), this._initShortcuts();
|
|
385
335
|
}
|
|
386
336
|
_initCustomComponents() {
|
|
387
|
-
this.disposeWithMe(this._zenZoneService.set(
|
|
337
|
+
this.disposeWithMe(this._zenZoneService.set(dt, ft));
|
|
388
338
|
}
|
|
389
339
|
_initCommands() {
|
|
390
|
-
[
|
|
340
|
+
[B, k, F].forEach((e) => {
|
|
391
341
|
this.disposeWithMe(this._commandService.registerCommand(e));
|
|
392
342
|
});
|
|
393
343
|
}
|
|
394
344
|
_initMenus() {
|
|
395
|
-
this._menuManagerService.mergeMenu(
|
|
345
|
+
this._menuManagerService.mergeMenu(ht);
|
|
396
346
|
}
|
|
397
347
|
_initShortcuts() {
|
|
398
|
-
[
|
|
348
|
+
[mt, _t].forEach((e) => {
|
|
399
349
|
this.disposeWithMe(this._shortcutService.registerShortcut(e));
|
|
400
350
|
});
|
|
401
351
|
}
|
|
402
352
|
};
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
],
|
|
409
|
-
var
|
|
410
|
-
for (var i =
|
|
411
|
-
(
|
|
412
|
-
return
|
|
413
|
-
},
|
|
414
|
-
let
|
|
415
|
-
constructor(e
|
|
416
|
-
super(), this.
|
|
417
|
-
|
|
418
|
-
|
|
353
|
+
b = Et([
|
|
354
|
+
y(0, R),
|
|
355
|
+
y(1, ee),
|
|
356
|
+
y(2, je),
|
|
357
|
+
y(3, Ue)
|
|
358
|
+
], b);
|
|
359
|
+
var St = Object.defineProperty, It = Object.getOwnPropertyDescriptor, Ct = (e, n, r, t) => {
|
|
360
|
+
for (var i = t > 1 ? void 0 : t ? It(n, r) : n, s = e.length - 1, o; s >= 0; s--)
|
|
361
|
+
(o = e[s]) && (i = (t ? o(n, r, i) : o(i)) || i);
|
|
362
|
+
return t && i && St(n, r, i), i;
|
|
363
|
+
}, q = (e, n) => (r, t) => n(r, t, e);
|
|
364
|
+
let T = class extends Se {
|
|
365
|
+
constructor(e, n) {
|
|
366
|
+
super(), this._zenEditorManagerService = e, this._renderManagerService = n, this._initialize();
|
|
367
|
+
}
|
|
368
|
+
_initialize() {
|
|
369
|
+
this._syncZenEditorSize();
|
|
370
|
+
}
|
|
371
|
+
// Listen to changes in the size of the zen editor container to set the size of the editor.
|
|
372
|
+
_syncZenEditorSize() {
|
|
373
|
+
this._zenEditorManagerService.position$.pipe($e(this.dispose$)).subscribe((e) => {
|
|
374
|
+
if (e == null)
|
|
375
|
+
return;
|
|
376
|
+
const { width: n, height: r } = e, t = xe(v, this._renderManagerService);
|
|
377
|
+
t != null && requestIdleCallback(() => {
|
|
378
|
+
t.engine.resizeBySize(n, r), this._calculatePagePosition(t), this._scrollToTop();
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
_calculatePagePosition(e) {
|
|
383
|
+
const { document: n, scene: r, docBackground: t } = e, i = r == null ? void 0 : r.getParent(), { width: s, height: o, pageMarginLeft: a, pageMarginTop: c } = n;
|
|
384
|
+
if (i == null || s === Number.POSITIVE_INFINITY || o === Number.POSITIVE_INFINITY)
|
|
385
|
+
return;
|
|
386
|
+
const { width: u, height: l } = i;
|
|
387
|
+
let d = 0;
|
|
388
|
+
const g = c;
|
|
389
|
+
let h = 0, C = 0, E = Number.POSITIVE_INFINITY;
|
|
390
|
+
const { scaleX: m, scaleY: O } = r.getAncestorScale();
|
|
391
|
+
u > (s + a * 2) * m ? (d = u / 2 - s * m / 2, d /= m, h = (u - a * 2) / m, E = 0) : (d = a, h = s + a * 2, E = (h - u / m) / 2), l > o ? C = (l - c * 2) / O : C = o + c * 2, r.resize(h, C), n.translate(d, g), t.translate(d, g);
|
|
392
|
+
const z = r.getViewport(Ne.VIEW_MAIN);
|
|
393
|
+
if (E !== Number.POSITIVE_INFINITY && z != null) {
|
|
394
|
+
const le = z.transScroll2ViewportScrollValue(E, 0).x;
|
|
395
|
+
z.scrollToBarPos({
|
|
396
|
+
x: le
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
return this;
|
|
400
|
+
}
|
|
401
|
+
_scrollToTop() {
|
|
402
|
+
var r;
|
|
403
|
+
const e = (r = this._renderManagerService.getRenderById(v)) == null ? void 0 : r.with(be), n = {
|
|
404
|
+
startOffset: 0,
|
|
405
|
+
endOffset: 0
|
|
406
|
+
};
|
|
407
|
+
e && e.scrollToRange(n);
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
T = Ct([
|
|
411
|
+
q(0, W),
|
|
412
|
+
q(1, te)
|
|
413
|
+
], T);
|
|
414
|
+
var Ot = Object.defineProperty, yt = Object.getOwnPropertyDescriptor, Nt = (e, n, r, t) => {
|
|
415
|
+
for (var i = t > 1 ? void 0 : t ? yt(n, r) : n, s = e.length - 1, o; s >= 0; s--)
|
|
416
|
+
(o = e[s]) && (i = (t ? o(n, r, i) : o(i)) || i);
|
|
417
|
+
return t && i && Ot(n, r, i), i;
|
|
418
|
+
}, J = (e, n) => (r, t) => n(r, t, e), N;
|
|
419
|
+
let K = (N = class extends Ie {
|
|
420
|
+
constructor(e = Ye, n, r) {
|
|
421
|
+
super(), this._config = e, this._injector = n, this._configService = r;
|
|
422
|
+
const { menu: t, ...i } = this._config;
|
|
423
|
+
t && this._configService.setConfig("menu", t, { merge: !0 }), this._configService.setConfig(He, i), this._initializeDependencies(this._injector);
|
|
419
424
|
}
|
|
420
425
|
_initializeDependencies(e) {
|
|
421
426
|
[
|
|
422
|
-
[
|
|
423
|
-
[
|
|
424
|
-
[
|
|
427
|
+
[b],
|
|
428
|
+
[T],
|
|
429
|
+
[W, { useClass: nt }]
|
|
425
430
|
].forEach((r) => e.add(r));
|
|
426
431
|
}
|
|
427
432
|
onReady() {
|
|
428
|
-
this._injector.get(
|
|
433
|
+
this._injector.get(b);
|
|
429
434
|
}
|
|
430
435
|
onSteady() {
|
|
431
|
-
this._injector.get(
|
|
436
|
+
this._injector.get(T);
|
|
432
437
|
}
|
|
433
|
-
},
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
],
|
|
438
|
+
}, S(N, "pluginName", "SHEET_ZEN_EDITOR_PLUGIN"), S(N, "type", j.UNIVER_SHEET), N);
|
|
439
|
+
K = Nt([
|
|
440
|
+
J(1, Ce(Oe)),
|
|
441
|
+
J(2, ye)
|
|
442
|
+
], K);
|
|
438
443
|
export {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
444
|
+
k as CancelZenEditCommand,
|
|
445
|
+
F as ConfirmZenEditCommand,
|
|
446
|
+
B as OpenZenEditorCommand,
|
|
447
|
+
K as UniverSheetsZenEditorPlugin
|
|
443
448
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MenuConfig } from '@univerjs/ui';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const SHEETS_ZEN_EDITOR_PLUGIN_CONFIG_KEY = "sheets-zen-editor.config";
|
|
3
3
|
export declare const configSymbol: unique symbol;
|
|
4
4
|
export interface IUniverSheetsZenEditorConfig {
|
|
5
5
|
menu?: MenuConfig;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,5 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import './global.css';
|
|
16
17
|
export { CancelZenEditCommand, ConfirmZenEditCommand, OpenZenEditorCommand } from './commands/commands/zen-editor.command';
|
|
17
18
|
export { UniverSheetsZenEditorPlugin } from './plugin';
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(d,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("react"),require("rxjs"),require("@univerjs/sheets")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-ui","@univerjs/engine-render","@univerjs/sheets-ui","@univerjs/ui","react","rxjs","@univerjs/sheets"],o):(d=typeof globalThis<"u"?globalThis:d||self,o(d.UniverSheetsZenEditor={},d.UniverCore,d.UniverDocsUi,d.UniverEngineRender,d.UniverSheetsUi,d.UniverUi,d.React,d.rxjs,d.UniverSheets))})(this,function(d,o,h,F,S,f,I,k,N){"use strict";var Re=Object.defineProperty;var De=(d,o,h)=>o in d?Re(d,o,{enumerable:!0,configurable:!0,writable:!0,value:h}):d[o]=h;var T=(d,o,h)=>De(d,typeof o!="symbol"?o+"":o,h);var M;const D={id:"zen-editor.command.open-zen-editor",type:o.CommandType.COMMAND,handler:async e=>{var U;const t=e.get(f.IZenZoneService),r=e.get(h.IEditorService),n=e.get(S.IEditorBridgeService),i=e.get(o.IUniverInstanceService),a=e.get(f.ISidebarService);a.visible&&(a.close(),await o.delayAnimationFrame()),t.open();const s=r.getEditor(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(s==null)return!1;const l=n.getLatestEditCellState();if(l==null)return!1;const c=(U=l.documentLayoutObject.documentModel)==null?void 0:U.getSnapshot();if(c==null)return!1;i.focusUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const{body:g,drawings:u,drawingsOrder:v,tableSource:E,settings:m}=o.Tools.deepClone(c),y={...s.getDocumentData(),body:g,drawings:u,drawingsOrder:v,tableSource:E,settings:m},O=[{startOffset:0,endOffset:0,collapsed:!0}];return s.focus(),s.setDocumentData(y,O),s.clearUndoRedoHistory(),!0}},z={id:"zen-editor.command.cancel-zen-edit",type:o.CommandType.COMMAND,handler:async e=>{const t=e.get(f.IZenZoneService),r=e.get(S.IEditorBridgeService),n=e.get(o.IUniverInstanceService),i=e.get(f.ISidebarService);i.visible&&(i.close(),await o.delayAnimationFrame()),t.close();const a=n.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);return a?(n.focusUnit(a.getUnitId()),r.refreshEditCellState(),!0):!1}},b={id:"zen-editor.command.confirm-zen-edit",type:o.CommandType.COMMAND,handler:async e=>{var g;const t=e.get(f.IZenZoneService),r=e.get(S.IEditorBridgeService),n=e.get(o.IUniverInstanceService),i=e.get(h.IEditorService),a=e.get(f.ISidebarService);a.visible&&(a.close(),await o.delayAnimationFrame()),t.close();const s=i.getEditor(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(s==null)return!1;const l=e.get(F.IRenderManagerService),c=n.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(c){const u=c.getUnitId(),v=(g=l.getRenderById(u))==null?void 0:g.with(S.EditingRenderController);if(v){const E=o.Tools.deepClone(s.getDocumentData());E.documentStyle.documentFlavor=o.DocumentFlavor.UNSPECIFIED,v.submitCellData(new o.DocumentDataModel(E))}return n.focusUnit(c.getUnitId()),r.refreshEditCellState(),!0}return!1}},Q="sheets-zen-editor.config",ee={};var w={exports:{}},R={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var re=g,ie=Symbol.for("react.element"),oe=Symbol.for("react.fragment"),se=Object.prototype.hasOwnProperty,ce=re.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ae={key:!0,ref:!0,__self:!0,__source:!0};function V(e,t,r){var n,i={},s=null,c=null;r!==void 0&&(s=""+r),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(c=t.ref);for(n in t)se.call(t,n)&&!ae.hasOwnProperty(n)&&(i[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)i[n]===void 0&&(i[n]=t[n]);return{$$typeof:ie,type:e,key:s,ref:c,props:i,_owner:ce.current}}b.Fragment=oe,b.jsx=V,b.jsxs=V,k.exports=b;var m=k.exports,f=function(){return f=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},f.apply(this,arguments)},de=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},w=g.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,s=e.extend,c=de(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),l=g.useRef("_".concat(fe()));return W(r,"".concat(n),{defIds:r.defIds,idSuffix:l.current},f({ref:t,className:d},c),s)});function W(e,t,r,n,i){return g.createElement(e.tag,f(f({key:t},le(e,r,i)),n),(ue(e,r).children||[]).map(function(s,c){return W(s,"".concat(t,"-").concat(e.tag,"-").concat(c),r,void 0,i)}))}function le(e,t,r){var n=f({},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(s){var c=s[0],d=s[1];typeof d=="string"&&(n[c]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function ue(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)?f(f({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?f(f({},i),{attrs:f(f({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function fe(){return Math.random().toString(36).substring(2,8)}w.displayName="UniverIcon";var ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Y=g.forwardRef(function(e,t){return g.createElement(w,Object.assign({},e,{id:"check-mark-single",ref:t,icon:ve}))});Y.displayName="CheckMarkSingle";var ge={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"}}]},K=g.forwardRef(function(e,t){return g.createElement(w,Object.assign({},e,{id:"close-single",ref:t,icon:ge}))});K.displayName="CloseSingle";function H(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=H(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function G(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=H(e))&&(n&&(n+=" "),n+=t);return n}const p={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"},_e="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT",Ee={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 he(){const e=g.useRef(null),t=o.useDependency(Z),r=o.useDependency(v.IEditorService),n=o.useDependency(o.ICommandService);g.useEffect(()=>{const c=e.current;if(!c)return;const d=r.register({editorUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:Ee,scrollBar:!0,noNeedVerticalAlign:!0,backScrollOffset:100},c),l=new ResizeObserver(()=>{t.setPosition(c.getBoundingClientRect())});return l.observe(c),()=>{d.dispose(),l.unobserve(c)}},[]);function i(){n.executeCommand(z.id)}function s(){n.executeCommand(R.id)}return m.jsxs("div",{className:p.zenEditor,children:[m.jsxs("div",{className:p.zenEditorIconWrapper,children:[m.jsx("span",{className:G(p.zenEditorIconContainer,p.zenEditorIconError),onClick:i,children:m.jsx(K,{style:{fontSize:"22px"}})}),m.jsx("span",{className:G(p.zenEditorIconContainer,p.zenEditorIconSuccess),onClick:s,children:m.jsx(Y,{style:{fontSize:"22px"}})})]}),m.jsx("div",{className:p.zenEditorCanvasContainer,ref:e})]})}function Ie(e){return{id:D.id,type:u.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 me={[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.OTHERS]:{[D.id]:{order:2,menuItemFactory:Ie}}}},pe={id:R.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:e=>$(e),binding:u.KeyCode.ENTER|u.MetaKeys.ALT},Se={id:z.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:e=>$(e),binding:u.KeyCode.ESC};function $(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 Ce=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,ye=(e,t,r,n)=>{for(var i=n>1?void 0:n?Oe(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=(n?c(t,r,i):c(i))||i);return n&&i&&Ce(t,r,i),i},j=(e,t)=>(r,n)=>t(r,n,e);let M=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(_e,he))}_initCommands(){[D,z,R].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(me)}_initShortcuts(){[pe,Se].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}};M=ye([j(0,u.IZenZoneService),j(1,o.ICommandService),j(2,u.IMenuManagerService),j(3,u.IShortcutService)],M);var Ne=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,De=(e,t,r,n)=>{for(var i=n>1?void 0:n?Te(t,r):t,s=e.length-1,c;s>=0;s--)(c=e[s])&&(i=(n?c(t,r,i):c(i))||i);return n&&i&&Ne(t,r,i),i},X=(e,t)=>(r,n)=>t(r,n,e);a.UniverSheetsZenEditorPlugin=(x=class extends o.Plugin{constructor(t=J,r,n){super(),this._config=t,this._injector=r,this._configService=n;const{menu:i,...s}=this._config;i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(q,s),this._initializeDependencies(this._injector)}_initializeDependencies(t){[[M],[P],[Z,{useClass:Q}]].forEach(n=>t.add(n))}onReady(){this._injector.get(M)}onSteady(){this._injector.get(P)}},O(x,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),O(x,"type",o.UniverInstanceType.UNIVER_SHEET),x),a.UniverSheetsZenEditorPlugin=De([X(1,o.Inject(o.Injector)),X(2,o.IConfigService)],a.UniverSheetsZenEditorPlugin),a.CancelZenEditCommand=z,a.ConfirmZenEditCommand=R,a.OpenZenEditorCommand=D,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
|
9
|
+
*/var V;function ne(){if(V)return R;V=1;var e=I,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function s(l,c,g){var u,v={},E=null,m=null;g!==void 0&&(E=""+g),c.key!==void 0&&(E=""+c.key),c.ref!==void 0&&(m=c.ref);for(u in c)n.call(c,u)&&!a.hasOwnProperty(u)&&(v[u]=c[u]);if(l&&l.defaultProps)for(u in c=l.defaultProps,c)v[u]===void 0&&(v[u]=c[u]);return{$$typeof:t,type:l,key:E,ref:m,props:v,_owner:i.current}}return R.Fragment=r,R.jsx=s,R.jsxs=s,R}var W;function te(){return W||(W=1,w.exports=ne()),w.exports}var p=te(),_=function(){return _=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},_.apply(this,arguments)},re=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},A=I.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,a=e.extend,s=re(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),c=I.useRef("_".concat(se()));return Y(r,"".concat(n),{defIds:r.defIds,idSuffix:c.current},_({ref:t,className:l},s),a)});function Y(e,t,r,n,i){return I.createElement(e.tag,_(_({key:t},ie(e,r,i)),n),(oe(e,r).children||[]).map(function(a,s){return Y(a,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,i)}))}function ie(e,t,r){var n=_({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(a){var s=a[0],l=a[1];typeof l=="string"&&(n[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function oe(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?_(_({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?_(_({},i),{attrs:_(_({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function se(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var ae={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},K=I.forwardRef(function(e,t){return I.createElement(A,Object.assign({},e,{id:"check-mark-single",ref:t,icon:ae}))});K.displayName="CheckMarkSingle";var ce={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},H=I.forwardRef(function(e,t){return I.createElement(A,Object.assign({},e,{id:"close-single",ref:t,icon:ce}))});H.displayName="CloseSingle";function G(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=G(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function $(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=G(e))&&(n&&(n+=" "),n+=t);return n}class de{constructor(){T(this,"_position",null);T(this,"_position$",new k.BehaviorSubject(null));T(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(t){this._position=t,this._refresh(t)}getPosition(){return this._position}_refresh(t){this._position$.next(t)}}const B=o.createIdentifier("univer.sheet-zen-editor-manager.service"),C={zenEditor:"univer-zen-editor",zenEditorIconWrapper:"univer-zen-editor-icon-wrapper",zenEditorIconContainer:"univer-zen-editor-icon-container",zenEditorIconSuccess:"univer-zen-editor-icon-success",zenEditorIconError:"univer-zen-editor-icon-error",zenEditorCanvasContainer:"univer-zen-editor-canvas-container"},le="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT",ue={id:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],tables:[],customBlocks:[],paragraphs:[{startIndex:0}],sectionBreaks:[{startIndex:1}]},tableSource:{},documentStyle:{pageSize:{width:595,height:Number.POSITIVE_INFINITY},documentFlavor:o.DocumentFlavor.MODERN,marginTop:0,marginBottom:0,marginRight:0,marginLeft:0,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};function fe(){const e=I.useRef(null),t=o.useDependency(B),r=o.useDependency(h.IEditorService),n=o.useDependency(o.ICommandService);I.useEffect(()=>{const s=e.current;if(!s)return;const l=r.register({editorUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:ue,scrollBar:!0,noNeedVerticalAlign:!0,backScrollOffset:100},s),c=new ResizeObserver(()=>{t.setPosition(s.getBoundingClientRect())});return c.observe(s),()=>{l.dispose(),c.unobserve(s)}},[]);function i(){n.executeCommand(z.id)}function a(){n.executeCommand(b.id)}return p.jsxs("div",{className:C.zenEditor,children:[p.jsxs("div",{className:C.zenEditorIconWrapper,children:[p.jsx("span",{className:$(C.zenEditorIconContainer,C.zenEditorIconError),onClick:i,children:p.jsx(H,{style:{fontSize:"22px"}})}),p.jsx("span",{className:$(C.zenEditorIconContainer,C.zenEditorIconSuccess),onClick:a,children:p.jsx(K,{style:{fontSize:"22px"}})})]}),p.jsx("div",{className:C.zenEditorCanvasContainer,ref:e})]})}function ve(e){return{id:D.id,type:f.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",hidden$:S.getCurrentExclusiveRangeInterest$(e),disabled$:S.getCurrentRangeDisable$(e,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission,N.WorksheetSetCellValuePermission,N.WorksheetSetCellStylePermission],rangeTypes:[N.RangeProtectionPermissionEditPoint]})}}const _e={[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[D.id]:{order:2,menuItemFactory:ve}}}},ge={id:b.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:e=>q(e),binding:f.KeyCode.ENTER|f.MetaKeys.ALT},Ee={id:z.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:e=>q(e),binding:f.KeyCode.ESC};function q(e){return e.getContextValue(o.FOCUSING_DOC)&&e.getContextValue(o.FOCUSING_UNIVER_EDITOR)&&e.getContextValue(o.EDITOR_ACTIVATED)&&!e.getContextValue(o.FOCUSING_EDITOR_STANDALONE)}var he=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,me=(e,t,r,n)=>{for(var i=n>1?void 0:n?Ie(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&he(t,r,i),i},P=(e,t)=>(r,n)=>t(r,n,e);let j=class extends o.Disposable{constructor(e,t,r,n){super(),this._zenZoneService=e,this._commandService=t,this._menuManagerService=r,this._shortcutService=n,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(le,fe))}_initCommands(){[D,z,b].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(_e)}_initShortcuts(){[ge,Ee].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}};j=me([P(0,f.IZenZoneService),P(1,o.ICommandService),P(2,f.IMenuManagerService),P(3,f.IShortcutService)],j);var Se=Object.defineProperty,pe=Object.getOwnPropertyDescriptor,Ce=(e,t,r,n)=>{for(var i=n>1?void 0:n?pe(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&Se(t,r,i),i},J=(e,t)=>(r,n)=>t(r,n,e);let x=class extends o.RxDisposable{constructor(e,t){super(),this._zenEditorManagerService=e,this._renderManagerService=t,this._initialize()}_initialize(){this._syncZenEditorSize()}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(k.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{width:t,height:r}=e,n=S.getEditorObject(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService);n!=null&&requestIdleCallback(()=>{n.engine.resizeBySize(t,r),this._calculatePagePosition(n),this._scrollToTop()})})}_calculatePagePosition(e){const{document:t,scene:r,docBackground:n}=e,i=r==null?void 0:r.getParent(),{width:a,height:s,pageMarginLeft:l,pageMarginTop:c}=t;if(i==null||a===Number.POSITIVE_INFINITY||s===Number.POSITIVE_INFINITY)return;const{width:g,height:u}=i;let v=0;const E=c;let m=0,Z=0,y=Number.POSITIVE_INFINITY;const{scaleX:O,scaleY:U}=r.getAncestorScale();g>(a+l*2)*O?(v=g/2-a*O/2,v/=O,m=(g-l*2)/O,y=0):(v=l,m=a+l*2,y=(m-g/O)/2),u>s?Z=(u-c*2)/U:Z=s+c*2,r.resize(m,Z),t.translate(v,E),n.translate(v,E);const L=r.getViewport(h.VIEWPORT_KEY.VIEW_MAIN);if(y!==Number.POSITIVE_INFINITY&&L!=null){const Ne=L.transScroll2ViewportScrollValue(y,0).x;L.scrollToBarPos({x:Ne})}return this}_scrollToTop(){var r;const e=(r=this._renderManagerService.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:r.with(h.DocBackScrollRenderController),t={startOffset:0,endOffset:0};e&&e.scrollToRange(t)}};x=Ce([J(0,B),J(1,F.IRenderManagerService)],x);var Oe=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Te=(e,t,r,n)=>{for(var i=n>1?void 0:n?ye(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(n?s(t,r,i):s(i))||i);return n&&i&&Oe(t,r,i),i},X=(e,t)=>(r,n)=>t(r,n,e);d.UniverSheetsZenEditorPlugin=(M=class extends o.Plugin{constructor(t=ee,r,n){super(),this._config=t,this._injector=r,this._configService=n;const{menu:i,...a}=this._config;i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Q,a),this._initializeDependencies(this._injector)}_initializeDependencies(t){[[j],[x],[B,{useClass:de}]].forEach(n=>t.add(n))}onReady(){this._injector.get(j)}onSteady(){this._injector.get(x)}},T(M,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),T(M,"type",o.UniverInstanceType.UNIVER_SHEET),M),d.UniverSheetsZenEditorPlugin=Te([X(1,o.Inject(o.Injector)),X(2,o.IConfigService)],d.UniverSheetsZenEditorPlugin),d.CancelZenEditCommand=z,d.ConfirmZenEditCommand=b,d.OpenZenEditorCommand=D,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsZenEditorFrFR=n())})(this,function(){"use strict";return{shortcut:{sheet:{"zen-edit-cancel":"Annuler l'édition plein écran","zen-edit-confirm":"Confirmer l'édition plein écran"}}}});
|
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.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Zen Editor plugin for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -54,23 +54,25 @@
|
|
|
54
54
|
"rxjs": ">=7.0.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@univerjs/icons": "^0.2.
|
|
57
|
+
"@univerjs/icons": "^0.2.8",
|
|
58
58
|
"clsx": "^2.1.1",
|
|
59
|
-
"@univerjs/core": "0.5.
|
|
60
|
-
"@univerjs/docs-ui": "0.5.
|
|
61
|
-
"@univerjs/sheets": "0.5.
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/
|
|
64
|
-
"@univerjs/ui": "0.5.
|
|
59
|
+
"@univerjs/core": "0.5.1",
|
|
60
|
+
"@univerjs/docs-ui": "0.5.1",
|
|
61
|
+
"@univerjs/sheets": "0.5.1",
|
|
62
|
+
"@univerjs/engine-render": "0.5.1",
|
|
63
|
+
"@univerjs/ui": "0.5.1",
|
|
64
|
+
"@univerjs/sheets-ui": "0.5.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"less": "^4.2.
|
|
67
|
+
"less": "^4.2.1",
|
|
68
|
+
"postcss": "^8.4.49",
|
|
68
69
|
"react": "18.3.1",
|
|
69
70
|
"rxjs": "^7.8.1",
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
71
|
+
"tailwindcss": "^3.4.15",
|
|
72
|
+
"typescript": "^5.7.2",
|
|
73
|
+
"vite": "^6.0.1",
|
|
74
|
+
"vitest": "^2.1.6",
|
|
75
|
+
"@univerjs-infra/shared": "0.5.1"
|
|
74
76
|
},
|
|
75
77
|
"space": {
|
|
76
78
|
".": {
|