@univerjs/sheets-zen-editor 0.5.4 → 0.5.5-experimental.20250123-34738ff
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/facade.js +1 -1
- package/lib/cjs/index.js +1 -9
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/facade.js +91 -82
- package/lib/es/index.js +282 -295
- package/lib/es/locale/en-US.js +2 -2
- package/lib/es/locale/fa-IR.js +2 -2
- package/lib/es/locale/fr-FR.js +2 -2
- package/lib/es/locale/ru-RU.js +2 -2
- package/lib/es/locale/vi-VN.js +2 -2
- package/lib/es/locale/zh-CN.js +2 -2
- package/lib/es/locale/zh-TW.js +2 -2
- package/lib/types/facade/f-univer.d.ts +3 -0
- package/lib/types/views/zen-editor/ZenEditor.d.ts +16 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -9
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +12 -12
- package/LICENSE +0 -176
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});const core=require("@univerjs/core"),docs=require("@univerjs/docs"),sheetsUi=require("@univerjs/sheets-ui"),sheetsZenEditor=require("@univerjs/sheets-zen-editor"),facade=require("@univerjs/sheets/facade"),_FUniverSheetsZenEditorMixin=class _FUniverSheetsZenEditorMixin extends core.FUniver{_initSheetZenEditorEvent(injector){const commandService=injector.get(core.ICommandService);this.disposeWithMe(commandService.beforeCommandExecuted(commandInfo=>{if(commandInfo.id===sheetsZenEditor.OpenZenEditorCommand.id||commandInfo.id===sheetsZenEditor.CancelZenEditCommand.id||commandInfo.id===sheetsZenEditor.ConfirmZenEditCommand.id){if(!this._eventListend(this.Event.BeforeSheetEditStart)&&!this._eventListend(this.Event.BeforeSheetEditEnd))return;const target=this.getCommandSheetTarget(commandInfo);if(!target)return;const{workbook,worksheet}=target,editorBridgeService=injector.get(sheetsUi.IEditorBridgeService),univerInstanceService=injector.get(core.IUniverInstanceService),params=commandInfo.params,{keycode,eventType}=params,loc=editorBridgeService.getEditLocation();if(commandInfo.id===sheetsZenEditor.OpenZenEditorCommand.id){const eventParams={row:loc.row,column:loc.column,eventType,keycode,workbook,worksheet,isZenEditor:!0};if(this.fireEvent(this.Event.BeforeSheetEditStart,eventParams),eventParams.cancel)throw new core.CanceledError}else{const eventParams={row:loc.row,column:loc.column,eventType,keycode,workbook,worksheet,isZenEditor:!0,value:core.RichTextValue.create(univerInstanceService.getUnit(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY).getSnapshot()),isConfirm:commandInfo.id===sheetsZenEditor.ConfirmZenEditCommand.id};if(this.fireEvent(this.Event.BeforeSheetEditEnd,eventParams),eventParams.cancel)throw new core.CanceledError}}})),this.disposeWithMe(commandService.onCommandExecuted(commandInfo=>{if(commandInfo.id===sheetsZenEditor.OpenZenEditorCommand.id||commandInfo.id===sheetsZenEditor.CancelZenEditCommand.id||commandInfo.id===sheetsZenEditor.ConfirmZenEditCommand.id){if(!this._eventListend(this.Event.SheetEditStarted)&&!this._eventListend(this.Event.SheetEditEnded))return;const target=this.getCommandSheetTarget(commandInfo);if(!target)return;const{workbook,worksheet}=target,editorBridgeService=injector.get(sheetsUi.IEditorBridgeService),params=commandInfo.params,{keycode,eventType}=params,loc=editorBridgeService.getEditLocation();if(commandInfo.id===sheetsZenEditor.OpenZenEditorCommand.id){const eventParams={row:loc.row,column:loc.column,eventType,keycode,workbook,worksheet,isZenEditor:!0};this.fireEvent(this.Event.SheetEditStarted,eventParams)}else{const eventParams={row:loc.row,column:loc.column,eventType,keycode,workbook,worksheet,isZenEditor:!0,isConfirm:commandInfo.id===sheetsZenEditor.ConfirmZenEditCommand.id};this.fireEvent(this.Event.SheetEditEnded,eventParams)}}if(commandInfo.id===docs.RichTextEditingMutation.id){if(!this._eventListend(this.Event.SheetEditChanging))return;const target=this.getCommandSheetTarget(commandInfo);if(!target)return;const{workbook,worksheet}=target,editorBridgeService=injector.get(sheetsUi.IEditorBridgeService),univerInstanceService=injector.get(core.IUniverInstanceService),params=commandInfo.params;if(!editorBridgeService.isVisible().visible)return;const{unitId}=params;if(unitId===core.DOCS_ZEN_EDITOR_UNIT_ID_KEY){const{row,column}=editorBridgeService.getEditLocation(),eventParams={workbook,worksheet,row,column,value:core.RichTextValue.create(univerInstanceService.getUnit(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY).getSnapshot()),isZenEditor:!0};this.fireEvent(this.Event.SheetEditChanging,eventParams)}}}))}_initialize(injector){this._initSheetZenEditorEvent(injector)}};__name(_FUniverSheetsZenEditorMixin,"FUniverSheetsZenEditorMixin");let FUniverSheetsZenEditorMixin=_FUniverSheetsZenEditorMixin;core.FUniver.extend(FUniverSheetsZenEditorMixin);const _FWorkbookSheetsZenEditorMixin=class _FWorkbookSheetsZenEditorMixin extends facade.FWorkbook{startZenEditingAsync(){return this._injector.get(core.ICommandService).executeCommand(sheetsZenEditor.OpenZenEditorCommand.id)}endZenEditingAsync(save=!0){const commandService=this._injector.get(core.ICommandService);return save?commandService.executeCommand(sheetsZenEditor.ConfirmZenEditCommand.id):commandService.executeCommand(sheetsZenEditor.CancelZenEditCommand.id)}};__name(_FWorkbookSheetsZenEditorMixin,"FWorkbookSheetsZenEditorMixin");let FWorkbookSheetsZenEditorMixin=_FWorkbookSheetsZenEditorMixin;facade.FWorkbook.extend(FWorkbookSheetsZenEditorMixin);
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
"use strict";var ee=Object.defineProperty;var te=(e,n,r)=>n in e?ee(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var O=(e,n,r)=>te(e,typeof n!="symbol"?n+"":n,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),T=require("@univerjs/docs-ui"),W=require("@univerjs/engine-render"),p=require("@univerjs/sheets-ui"),f=require("@univerjs/ui"),m=require("react"),q=require("rxjs"),y=require("@univerjs/sheets"),M={id:"zen-editor.command.open-zen-editor",type:o.CommandType.COMMAND,handler:async e=>{var b;const n=e.get(f.IZenZoneService),r=e.get(T.IEditorService),t=e.get(p.IEditorBridgeService),i=e.get(o.IUniverInstanceService),c=e.get(f.ISidebarService);c.visible&&(c.close(),await o.delayAnimationFrame()),n.open();const s=r.getEditor(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(s==null)return!1;const d=t.getLatestEditCellState();if(d==null)return!1;const a=(b=d.documentLayoutObject.documentModel)==null?void 0:b.getSnapshot();if(a==null)return!1;i.focusUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const{body:g,drawings:l,drawingsOrder:u,tableSource:h,settings:v}=o.Tools.deepClone(a),C={...s.getDocumentData(),body:g,drawings:l,drawingsOrder:u,tableSource:h,settings:v},E=[{startOffset:0,endOffset:0,collapsed:!0}];return s.focus(),s.setDocumentData(C,E),s.clearUndoRedoHistory(),!0}},U={id:"zen-editor.command.cancel-zen-edit",type:o.CommandType.COMMAND,handler:async e=>{const n=e.get(f.IZenZoneService),r=e.get(p.IEditorBridgeService),t=e.get(o.IUniverInstanceService),i=e.get(f.ISidebarService);i.visible&&(i.close(),await o.delayAnimationFrame()),n.close();const c=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);return c?(t.focusUnit(c.getUnitId()),r.refreshEditCellState(),!0):!1}},Z={id:"zen-editor.command.confirm-zen-edit",type:o.CommandType.COMMAND,handler:async e=>{var g;const n=e.get(f.IZenZoneService),r=e.get(p.IEditorBridgeService),t=e.get(o.IUniverInstanceService),i=e.get(T.IEditorService),c=e.get(f.ISidebarService);c.visible&&(c.close(),await o.delayAnimationFrame()),n.close();const s=i.getEditor(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(s==null)return!1;const d=e.get(W.IRenderManagerService),a=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(a){const l=a.getUnitId(),u=(g=d.getRenderById(l))==null?void 0:g.with(p.EditingRenderController);if(u){const h=o.Tools.deepClone(s.getDocumentData());h.documentStyle.documentFlavor=o.DocumentFlavor.UNSPECIFIED,u.submitCellData(new o.DocumentDataModel(h))}return t.focusUnit(a.getUnitId()),r.refreshEditCellState(),!0}return!1}},ne="sheets-zen-editor.config",L={};var j={exports:{}},N={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var $;function re(){if($)return 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;
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@univerjs/core"),docsUi=require("@univerjs/docs-ui"),engineRender=require("@univerjs/engine-render"),sheetsUi=require("@univerjs/sheets-ui"),ui=require("@univerjs/ui"),jsxRuntime=require("react/jsx-runtime"),react=require("react"),rxjs=require("rxjs"),sheets=require("@univerjs/sheets"),OpenZenEditorCommand={id:"zen-editor.command.open-zen-editor",type:core.CommandType.COMMAND,handler:__name(async accessor=>{var _a4;const zenZoneService=accessor.get(ui.IZenZoneService),editorService=accessor.get(docsUi.IEditorService),editorBridgeService=accessor.get(sheetsUi.IEditorBridgeService),univerInstanceService=accessor.get(core.IUniverInstanceService),sideBarService=accessor.get(ui.ISidebarService);sideBarService.visible&&(sideBarService.close(),await core.delayAnimationFrame()),zenZoneService.open();const editor=editorService.getEditor(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(editor==null)return!1;const editCellState=editorBridgeService.getLatestEditCellState();if(editCellState==null)return!1;const snapshot=(_a4=editCellState.documentLayoutObject.documentModel)==null?void 0:_a4.getSnapshot();if(snapshot==null)return!1;univerInstanceService.focusUnit(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const{body,drawings,drawingsOrder,tableSource,settings}=core.Tools.deepClone(snapshot),newSnapshot={...editor.getDocumentData(),body,drawings,drawingsOrder,tableSource,settings},textRanges=[{startOffset:0,endOffset:0,collapsed:!0}];return editor.focus(),editor.setDocumentData(newSnapshot,textRanges),editor.clearUndoRedoHistory(),!0},"handler")},CancelZenEditCommand={id:"zen-editor.command.cancel-zen-edit",type:core.CommandType.COMMAND,handler:__name(async accessor=>{const zenZoneEditorService=accessor.get(ui.IZenZoneService),editorBridgeService=accessor.get(sheetsUi.IEditorBridgeService),univerInstanceManager=accessor.get(core.IUniverInstanceService),sideBarService=accessor.get(ui.ISidebarService);sideBarService.visible&&(sideBarService.close(),await core.delayAnimationFrame()),zenZoneEditorService.close();const currentSheetInstance=univerInstanceManager.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);return currentSheetInstance?(univerInstanceManager.focusUnit(currentSheetInstance.getUnitId()),editorBridgeService.refreshEditCellState(),!0):!1},"handler")},ConfirmZenEditCommand={id:"zen-editor.command.confirm-zen-edit",type:core.CommandType.COMMAND,handler:__name(async accessor=>{var _a4;const zenZoneEditorService=accessor.get(ui.IZenZoneService),editorBridgeService=accessor.get(sheetsUi.IEditorBridgeService),univerInstanceManager=accessor.get(core.IUniverInstanceService),editorService=accessor.get(docsUi.IEditorService),sideBarService=accessor.get(ui.ISidebarService);sideBarService.visible&&(sideBarService.close(),await core.delayAnimationFrame()),zenZoneEditorService.close();const editor=editorService.getEditor(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY);if(editor==null)return!1;const renderManagerService=accessor.get(engineRender.IRenderManagerService),currentSheetInstance=univerInstanceManager.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(currentSheetInstance){const currentSheetId=currentSheetInstance.getUnitId(),editingRenderController=(_a4=renderManagerService.getRenderById(currentSheetId))==null?void 0:_a4.with(sheetsUi.EditingRenderController);if(editingRenderController){const snapshot=core.Tools.deepClone(editor.getDocumentData());snapshot.documentStyle.documentFlavor=core.DocumentFlavor.UNSPECIFIED,editingRenderController.submitCellData(new core.DocumentDataModel(snapshot))}return univerInstanceManager.focusUnit(currentSheetInstance.getUnitId()),editorBridgeService.refreshEditCellState(),!0}return!1},"handler")},SHEETS_ZEN_EDITOR_PLUGIN_CONFIG_KEY="sheets-zen-editor.config",defaultPluginConfig={};var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=react.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=react.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return react.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a4){var key=_a4[0],value=_a4[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a4,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a4=node.children)===null||_a4===void 0)&&_a4.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid");IconBase.displayName="UniverIcon";var element$1={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"}}]},CheckMarkSingle=react.forwardRef(function(props,ref){return react.createElement(IconBase,Object.assign({},props,{id:"check-mark-single",ref,icon:element$1}))});CheckMarkSingle.displayName="CheckMarkSingle";var element={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"}}]},CloseSingle=react.forwardRef(function(props,ref){return react.createElement(IconBase,Object.assign({},props,{id:"close-single",ref,icon:element}))});CloseSingle.displayName="CloseSingle";function r(e){var t,f,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}__name(r,"r");function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}__name(clsx,"clsx");const _ZenEditorManagerService=class _ZenEditorManagerService{constructor(){__publicField(this,"_position",null);__publicField(this,"_position$",new rxjs.BehaviorSubject(null));__publicField(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(param){this._position=param,this._refresh(param)}getPosition(){return this._position}_refresh(param){this._position$.next(param)}};__name(_ZenEditorManagerService,"ZenEditorManagerService");let ZenEditorManagerService=_ZenEditorManagerService;const IZenEditorManagerService=core.createIdentifier("univer.sheet-zen-editor-manager.service"),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",styles={zenEditor,zenEditorIconWrapper,zenEditorIconContainer,zenEditorIconSuccess,zenEditorIconError,zenEditorCanvasContainer},COMPONENT_PREFIX="ZEN_EDITOR_PLUGIN_",ZEN_EDITOR_COMPONENT=`${COMPONENT_PREFIX}ZEN_EDITOR_COMPONENT`,INITIAL_SNAPSHOT={id:core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,body:{dataStream:`${core.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],tables:[],customBlocks:[],paragraphs:[{startIndex:0}],sectionBreaks:[{startIndex:1}]},tableSource:{},documentStyle:{pageSize:{width:595,height:Number.POSITIVE_INFINITY},documentFlavor:core.DocumentFlavor.MODERN,marginTop:0,marginBottom:0,marginRight:0,marginLeft:0,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};function ZenEditor(){const editorRef=react.useRef(null),zenEditorService=core.useDependency(IZenEditorManagerService),editorService=core.useDependency(docsUi.IEditorService),commandService=core.useDependency(core.ICommandService);react.useEffect(()=>{const editorDom=editorRef.current;if(!editorDom)return;const registerSubscription=editorService.register({editorUnitId:core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,initialSnapshot:INITIAL_SNAPSHOT,scrollBar:!0,backScrollOffset:100},editorDom),resizeObserver=new ResizeObserver(()=>{zenEditorService.setPosition(editorDom.getBoundingClientRect())});return resizeObserver.observe(editorDom),()=>{registerSubscription.dispose(),resizeObserver.unobserve(editorDom)}},[]);function handleCloseBtnClick(){const editor=editorService.getEditor(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY);editor==null||editor.blur(),commandService.executeCommand(CancelZenEditCommand.id)}__name(handleCloseBtnClick,"handleCloseBtnClick");function handleConfirmBtnClick(){const editor=editorService.getEditor(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY);editor==null||editor.blur(),commandService.executeCommand(ConfirmZenEditCommand.id)}return __name(handleConfirmBtnClick,"handleConfirmBtnClick"),jsxRuntime.jsxs("div",{className:styles.zenEditor,children:[jsxRuntime.jsxs("div",{className:styles.zenEditorIconWrapper,children:[jsxRuntime.jsx("span",{className:clsx(styles.zenEditorIconContainer,styles.zenEditorIconError),onClick:handleCloseBtnClick,children:jsxRuntime.jsx(CloseSingle,{style:{fontSize:"22px"}})}),jsxRuntime.jsx("span",{className:clsx(styles.zenEditorIconContainer,styles.zenEditorIconSuccess),onClick:handleConfirmBtnClick,children:jsxRuntime.jsx(CheckMarkSingle,{style:{fontSize:"22px"}})})]}),jsxRuntime.jsx("div",{className:styles.zenEditorCanvasContainer,ref:editorRef})]})}__name(ZenEditor,"ZenEditor");function ZenEditorMenuItemFactory(accessor){return{id:OpenZenEditorCommand.id,type:ui.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",hidden$:sheetsUi.getCurrentExclusiveRangeInterest$(accessor),disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellValuePermission,sheets.WorksheetSetCellStylePermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]})}}__name(ZenEditorMenuItemFactory,"ZenEditorMenuItemFactory");const menuSchema={[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.OTHERS]:{[OpenZenEditorCommand.id]:{order:2,menuItemFactory:ZenEditorMenuItemFactory}}}},ZenEditorConfirmShortcut={id:ConfirmZenEditCommand.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:__name(contextService=>whenZenEditorActivated(contextService),"preconditions"),binding:ui.KeyCode.ENTER|ui.MetaKeys.ALT},ZenEditorCancelShortcut={id:CancelZenEditCommand.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:__name(contextService=>whenZenEditorActivated(contextService),"preconditions"),binding:ui.KeyCode.ESC};function whenZenEditorActivated(contextService){return contextService.getContextValue(core.FOCUSING_DOC)&&contextService.getContextValue(core.FOCUSING_UNIVER_EDITOR)&&contextService.getContextValue(core.EDITOR_ACTIVATED)&&!contextService.getContextValue(core.FOCUSING_EDITOR_STANDALONE)}__name(whenZenEditorActivated,"whenZenEditorActivated");var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2"),_a;let ZenEditorUIController=(_a=class extends core.Disposable{constructor(_zenZoneService,_commandService,_menuManagerService,_shortcutService){super(),this._zenZoneService=_zenZoneService,this._commandService=_commandService,this._menuManagerService=_menuManagerService,this._shortcutService=_shortcutService,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(ZEN_EDITOR_COMPONENT,ZenEditor))}_initCommands(){[OpenZenEditorCommand,CancelZenEditCommand,ConfirmZenEditCommand].forEach(c=>{this.disposeWithMe(this._commandService.registerCommand(c))})}_initMenus(){this._menuManagerService.mergeMenu(menuSchema)}_initShortcuts(){[ZenEditorConfirmShortcut,ZenEditorCancelShortcut].forEach(item=>{this.disposeWithMe(this._shortcutService.registerShortcut(item))})}},__name(_a,"ZenEditorUIController"),_a);ZenEditorUIController=__decorateClass$2([__decorateParam$2(0,ui.IZenZoneService),__decorateParam$2(1,core.ICommandService),__decorateParam$2(2,ui.IMenuManagerService),__decorateParam$2(3,ui.IShortcutService)],ZenEditorUIController);var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1"),_a2;let ZenEditorController=(_a2=class extends core.RxDisposable{constructor(_zenEditorManagerService,_renderManagerService){super(),this._zenEditorManagerService=_zenEditorManagerService,this._renderManagerService=_renderManagerService,this._initialize()}_initialize(){this._syncZenEditorSize()}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(rxjs.takeUntil(this.dispose$)).subscribe(position=>{if(position==null)return;const{width,height}=position,editorObject=sheetsUi.getEditorObject(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY,this._renderManagerService);editorObject!=null&&requestIdleCallback(()=>{editorObject.engine.resizeBySize(width,height),this._calculatePagePosition(editorObject),this._scrollToTop()})})}_calculatePagePosition(currentRender){const{document:docsComponent,scene,docBackground}=currentRender,parent=scene==null?void 0:scene.getParent(),{width:docsWidth,height:docsHeight,pageMarginLeft,pageMarginTop}=docsComponent;if(parent==null||docsWidth===Number.POSITIVE_INFINITY||docsHeight===Number.POSITIVE_INFINITY)return;const{width:engineWidth,height:engineHeight}=parent;let docsLeft=0;const docsTop=pageMarginTop;let sceneWidth=0,sceneHeight=0,scrollToX=Number.POSITIVE_INFINITY;const{scaleX,scaleY}=scene.getAncestorScale();engineWidth>(docsWidth+pageMarginLeft*2)*scaleX?(docsLeft=engineWidth/2-docsWidth*scaleX/2,docsLeft/=scaleX,sceneWidth=(engineWidth-pageMarginLeft*2)/scaleX,scrollToX=0):(docsLeft=pageMarginLeft,sceneWidth=docsWidth+pageMarginLeft*2,scrollToX=(sceneWidth-engineWidth/scaleX)/2),engineHeight>docsHeight?sceneHeight=(engineHeight-pageMarginTop*2)/scaleY:sceneHeight=docsHeight+pageMarginTop*2,scene.resize(sceneWidth,sceneHeight),docsComponent.translate(docsLeft,docsTop),docBackground.translate(docsLeft,docsTop);const viewport=scene.getViewport(docsUi.VIEWPORT_KEY.VIEW_MAIN);if(scrollToX!==Number.POSITIVE_INFINITY&&viewport!=null){const actualX=viewport.transScroll2ViewportScrollValue(scrollToX,0).x;viewport.scrollToBarPos({x:actualX})}return this}_scrollToTop(){var _a4;const backScrollController=(_a4=this._renderManagerService.getRenderById(core.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:_a4.with(docsUi.DocBackScrollRenderController),textRange={startOffset:0,endOffset:0};backScrollController&&backScrollController.scrollToRange(textRange)}},__name(_a2,"ZenEditorController"),_a2);ZenEditorController=__decorateClass$1([__decorateParam$1(0,IZenEditorManagerService),__decorateParam$1(1,engineRender.IRenderManagerService)],ZenEditorController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),_a3;exports.UniverSheetsZenEditorPlugin=(_a3=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_configService){super(),this._config=_config,this._injector=_injector,this._configService=_configService;const{menu,...rest}=core.merge({},defaultPluginConfig,this._config);menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(SHEETS_ZEN_EDITOR_PLUGIN_CONFIG_KEY,rest),this._initializeDependencies(this._injector)}_initializeDependencies(injector){[[ZenEditorUIController],[ZenEditorController],[IZenEditorManagerService,{useClass:ZenEditorManagerService}]].forEach(dependency=>injector.add(dependency))}onReady(){this._injector.get(ZenEditorUIController)}onSteady(){this._injector.get(ZenEditorController)}},__name(_a3,"UniverSheetsZenEditorPlugin"),__publicField(_a3,"pluginName","SHEET_ZEN_EDITOR_PLUGIN"),__publicField(_a3,"type",core.UniverInstanceType.UNIVER_SHEET),_a3);exports.UniverSheetsZenEditorPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.IConfigService)],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=CancelZenEditCommand;exports.ConfirmZenEditCommand=ConfirmZenEditCommand;exports.OpenZenEditorCommand=OpenZenEditorCommand;
|
package/lib/cjs/locale/en-US.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={shortcut:{sheet:{"zen-edit-cancel":"Cancel Zen Edit","zen-edit-confirm":"Confirm Zen Edit"}}};module.exports=locale;
|
package/lib/cjs/locale/fa-IR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={shortcut:{sheet:{"zen-edit-cancel":"لغو ویرایش Zen","zen-edit-confirm":"تایید ویرایش Zen"}}};module.exports=locale;
|
package/lib/cjs/locale/fr-FR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={shortcut:{sheet:{"zen-edit-cancel":"Annuler l'édition plein écran","zen-edit-confirm":"Confirmer l'édition plein écran"}}};module.exports=locale;
|
package/lib/cjs/locale/ru-RU.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={shortcut:{sheet:{"zen-edit-cancel":"Отменить Zen редактирование","zen-edit-confirm":"Подтвердить Zen редактирование"}}};module.exports=locale;
|
package/lib/cjs/locale/vi-VN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={shortcut:{sheet:{"zen-edit-cancel":"Hủy chỉnh sửa (trạng thái Zen mode)","zen-edit-confirm":"Bỏ chỉnh sửa (trạng thái Zen mode)"}}};module.exports=locale;
|
package/lib/cjs/locale/zh-CN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={shortcut:{sheet:{"zen-edit-cancel":"取消编辑(禅模式状态)","zen-edit-confirm":"放弃编辑(禅模式状态)"}}};module.exports=locale;
|
package/lib/cjs/locale/zh-TW.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const locale={shortcut:{sheet:{"zen-edit-cancel":"取消編輯(禪模式狀態)","zen-edit-confirm":"放棄編輯(禪模式狀態)"}}};module.exports=locale;
|
package/lib/es/facade.js
CHANGED
|
@@ -1,116 +1,125 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
3
|
+
import { FUniver, ICommandService, IUniverInstanceService, CanceledError, RichTextValue, DOCS_ZEN_EDITOR_UNIT_ID_KEY } from "@univerjs/core";
|
|
4
|
+
import { RichTextEditingMutation } from "@univerjs/docs";
|
|
5
|
+
import { IEditorBridgeService } from "@univerjs/sheets-ui";
|
|
6
|
+
import { OpenZenEditorCommand, CancelZenEditCommand, ConfirmZenEditCommand } from "@univerjs/sheets-zen-editor";
|
|
7
|
+
import { FWorkbook } from "@univerjs/sheets/facade";
|
|
8
|
+
const _FUniverSheetsZenEditorMixin = class _FUniverSheetsZenEditorMixin extends FUniver {
|
|
7
9
|
// eslint-disable-next-line max-lines-per-function
|
|
8
|
-
_initSheetZenEditorEvent(
|
|
9
|
-
const
|
|
10
|
-
this.disposeWithMe(
|
|
11
|
-
if (
|
|
10
|
+
_initSheetZenEditorEvent(injector) {
|
|
11
|
+
const commandService = injector.get(ICommandService);
|
|
12
|
+
this.disposeWithMe(commandService.beforeCommandExecuted((commandInfo) => {
|
|
13
|
+
if (commandInfo.id === OpenZenEditorCommand.id || commandInfo.id === CancelZenEditCommand.id || commandInfo.id === ConfirmZenEditCommand.id) {
|
|
12
14
|
if (!this._eventListend(this.Event.BeforeSheetEditStart) && !this._eventListend(this.Event.BeforeSheetEditEnd))
|
|
13
15
|
return;
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
16
|
+
const target = this.getCommandSheetTarget(commandInfo);
|
|
17
|
+
if (!target)
|
|
16
18
|
return;
|
|
17
|
-
const { workbook
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
row:
|
|
21
|
-
column:
|
|
22
|
-
eventType
|
|
23
|
-
keycode
|
|
24
|
-
workbook
|
|
25
|
-
worksheet
|
|
19
|
+
const { workbook, worksheet } = target, editorBridgeService = injector.get(IEditorBridgeService), univerInstanceService = injector.get(IUniverInstanceService), params = commandInfo.params, { keycode, eventType } = params, loc = editorBridgeService.getEditLocation();
|
|
20
|
+
if (commandInfo.id === OpenZenEditorCommand.id) {
|
|
21
|
+
const eventParams = {
|
|
22
|
+
row: loc.row,
|
|
23
|
+
column: loc.column,
|
|
24
|
+
eventType,
|
|
25
|
+
keycode,
|
|
26
|
+
workbook,
|
|
27
|
+
worksheet,
|
|
26
28
|
isZenEditor: !0
|
|
27
29
|
};
|
|
28
|
-
if (this.fireEvent(this.Event.BeforeSheetEditStart,
|
|
29
|
-
throw new
|
|
30
|
+
if (this.fireEvent(this.Event.BeforeSheetEditStart, eventParams), eventParams.cancel)
|
|
31
|
+
throw new CanceledError();
|
|
30
32
|
} else {
|
|
31
|
-
const
|
|
32
|
-
row:
|
|
33
|
-
column:
|
|
34
|
-
eventType
|
|
35
|
-
keycode
|
|
36
|
-
workbook
|
|
37
|
-
worksheet
|
|
33
|
+
const eventParams = {
|
|
34
|
+
row: loc.row,
|
|
35
|
+
column: loc.column,
|
|
36
|
+
eventType,
|
|
37
|
+
keycode,
|
|
38
|
+
workbook,
|
|
39
|
+
worksheet,
|
|
38
40
|
isZenEditor: !0,
|
|
39
|
-
value:
|
|
40
|
-
isConfirm:
|
|
41
|
+
value: RichTextValue.create(univerInstanceService.getUnit(DOCS_ZEN_EDITOR_UNIT_ID_KEY).getSnapshot()),
|
|
42
|
+
isConfirm: commandInfo.id === ConfirmZenEditCommand.id
|
|
41
43
|
};
|
|
42
|
-
if (this.fireEvent(this.Event.BeforeSheetEditEnd,
|
|
43
|
-
throw new
|
|
44
|
+
if (this.fireEvent(this.Event.BeforeSheetEditEnd, eventParams), eventParams.cancel)
|
|
45
|
+
throw new CanceledError();
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
|
-
})), this.disposeWithMe(
|
|
47
|
-
if (
|
|
48
|
+
})), this.disposeWithMe(commandService.onCommandExecuted((commandInfo) => {
|
|
49
|
+
if (commandInfo.id === OpenZenEditorCommand.id || commandInfo.id === CancelZenEditCommand.id || commandInfo.id === ConfirmZenEditCommand.id) {
|
|
48
50
|
if (!this._eventListend(this.Event.SheetEditStarted) && !this._eventListend(this.Event.SheetEditEnded))
|
|
49
51
|
return;
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
52
|
+
const target = this.getCommandSheetTarget(commandInfo);
|
|
53
|
+
if (!target)
|
|
52
54
|
return;
|
|
53
|
-
const { workbook
|
|
54
|
-
if (
|
|
55
|
-
const
|
|
56
|
-
row:
|
|
57
|
-
column:
|
|
58
|
-
eventType
|
|
59
|
-
keycode
|
|
60
|
-
workbook
|
|
61
|
-
worksheet
|
|
55
|
+
const { workbook, worksheet } = target, editorBridgeService = injector.get(IEditorBridgeService), params = commandInfo.params, { keycode, eventType } = params, loc = editorBridgeService.getEditLocation();
|
|
56
|
+
if (commandInfo.id === OpenZenEditorCommand.id) {
|
|
57
|
+
const eventParams = {
|
|
58
|
+
row: loc.row,
|
|
59
|
+
column: loc.column,
|
|
60
|
+
eventType,
|
|
61
|
+
keycode,
|
|
62
|
+
workbook,
|
|
63
|
+
worksheet,
|
|
62
64
|
isZenEditor: !0
|
|
63
65
|
};
|
|
64
|
-
this.fireEvent(this.Event.SheetEditStarted,
|
|
66
|
+
this.fireEvent(this.Event.SheetEditStarted, eventParams);
|
|
65
67
|
} else {
|
|
66
|
-
const
|
|
67
|
-
row:
|
|
68
|
-
column:
|
|
69
|
-
eventType
|
|
70
|
-
keycode
|
|
71
|
-
workbook
|
|
72
|
-
worksheet
|
|
68
|
+
const eventParams = {
|
|
69
|
+
row: loc.row,
|
|
70
|
+
column: loc.column,
|
|
71
|
+
eventType,
|
|
72
|
+
keycode,
|
|
73
|
+
workbook,
|
|
74
|
+
worksheet,
|
|
73
75
|
isZenEditor: !0,
|
|
74
|
-
isConfirm:
|
|
76
|
+
isConfirm: commandInfo.id === ConfirmZenEditCommand.id
|
|
75
77
|
};
|
|
76
|
-
this.fireEvent(this.Event.SheetEditEnded,
|
|
78
|
+
this.fireEvent(this.Event.SheetEditEnded, eventParams);
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
|
-
if (
|
|
81
|
+
if (commandInfo.id === RichTextEditingMutation.id) {
|
|
80
82
|
if (!this._eventListend(this.Event.SheetEditChanging))
|
|
81
83
|
return;
|
|
82
|
-
const
|
|
83
|
-
if (!
|
|
84
|
+
const target = this.getCommandSheetTarget(commandInfo);
|
|
85
|
+
if (!target)
|
|
84
86
|
return;
|
|
85
|
-
const { workbook
|
|
86
|
-
if (!
|
|
87
|
-
const { unitId
|
|
88
|
-
if (
|
|
89
|
-
const { row
|
|
90
|
-
workbook
|
|
91
|
-
worksheet
|
|
92
|
-
row
|
|
93
|
-
column
|
|
94
|
-
value:
|
|
87
|
+
const { workbook, worksheet } = target, editorBridgeService = injector.get(IEditorBridgeService), univerInstanceService = injector.get(IUniverInstanceService), params = commandInfo.params;
|
|
88
|
+
if (!editorBridgeService.isVisible().visible) return;
|
|
89
|
+
const { unitId } = params;
|
|
90
|
+
if (unitId === DOCS_ZEN_EDITOR_UNIT_ID_KEY) {
|
|
91
|
+
const { row, column } = editorBridgeService.getEditLocation(), eventParams = {
|
|
92
|
+
workbook,
|
|
93
|
+
worksheet,
|
|
94
|
+
row,
|
|
95
|
+
column,
|
|
96
|
+
value: RichTextValue.create(univerInstanceService.getUnit(DOCS_ZEN_EDITOR_UNIT_ID_KEY).getSnapshot()),
|
|
95
97
|
isZenEditor: !0
|
|
96
98
|
};
|
|
97
|
-
this.fireEvent(this.Event.SheetEditChanging,
|
|
99
|
+
this.fireEvent(this.Event.SheetEditChanging, eventParams);
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
}));
|
|
101
103
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
+
/**
|
|
105
|
+
* @ignore
|
|
106
|
+
*/
|
|
107
|
+
_initialize(injector) {
|
|
108
|
+
this._initSheetZenEditorEvent(injector);
|
|
104
109
|
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
};
|
|
111
|
+
__name(_FUniverSheetsZenEditorMixin, "FUniverSheetsZenEditorMixin");
|
|
112
|
+
let FUniverSheetsZenEditorMixin = _FUniverSheetsZenEditorMixin;
|
|
113
|
+
FUniver.extend(FUniverSheetsZenEditorMixin);
|
|
114
|
+
const _FWorkbookSheetsZenEditorMixin = class _FWorkbookSheetsZenEditorMixin extends FWorkbook {
|
|
108
115
|
startZenEditingAsync() {
|
|
109
|
-
return this._injector.get(
|
|
116
|
+
return this._injector.get(ICommandService).executeCommand(OpenZenEditorCommand.id);
|
|
110
117
|
}
|
|
111
|
-
endZenEditingAsync(
|
|
112
|
-
const
|
|
113
|
-
return
|
|
118
|
+
endZenEditingAsync(save = !0) {
|
|
119
|
+
const commandService = this._injector.get(ICommandService);
|
|
120
|
+
return save ? commandService.executeCommand(ConfirmZenEditCommand.id) : commandService.executeCommand(CancelZenEditCommand.id);
|
|
114
121
|
}
|
|
115
|
-
}
|
|
116
|
-
|
|
122
|
+
};
|
|
123
|
+
__name(_FWorkbookSheetsZenEditorMixin, "FWorkbookSheetsZenEditorMixin");
|
|
124
|
+
let FWorkbookSheetsZenEditorMixin = _FWorkbookSheetsZenEditorMixin;
|
|
125
|
+
FWorkbook.extend(FWorkbookSheetsZenEditorMixin);
|