@univerjs/sheets-zen-editor 0.2.2 → 0.2.4-alpha.0
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/README.md +11 -4
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +207 -201
- package/lib/locale/vi-VN.json +8 -0
- package/lib/locale/zh-CN.json +2 -2
- package/lib/locale/zh-TW.json +8 -0
- package/lib/types/controllers/zen-editor-ui.controller.d.ts +1 -2
- package/lib/types/controllers/zen-editor.controller.d.ts +1 -3
- package/lib/types/locale/vi-VN.d.ts +4 -0
- package/lib/types/locale/zh-TW.d.ts +4 -0
- package/lib/types/plugin.d.ts +1 -2
- package/lib/types/services/zen-editor.service.d.ts +2 -3
- package/lib/types/views/menu.d.ts +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +19 -21
package/README.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# @univerjs/sheets-zen-editor
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
## Package Overview
|
|
4
|
+
|
|
5
|
+
| Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
|
|
6
|
+
| --- | --- | --- | --- | --- | :---: | :---: |
|
|
7
|
+
| `@univerjs/sheets-zen-editor` | `UniveSheetsZenEditor` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ❌ | ⭕️ |
|
|
7
8
|
|
|
8
9
|
## Introduction
|
|
9
10
|
|
|
@@ -20,3 +21,9 @@ npm install @univerjs/sheets-zen-editor
|
|
|
20
21
|
# Using pnpm
|
|
21
22
|
pnpm add @univerjs/sheets-zen-editor
|
|
22
23
|
```
|
|
24
|
+
|
|
25
|
+
<!-- Links -->
|
|
26
|
+
[npm-version-shield]: https://img.shields.io/npm/v/@univerjs/slides?style=flat-square
|
|
27
|
+
[npm-version-link]: https://npmjs.com/package/@univerjs/slides
|
|
28
|
+
[npm-license-shield]: https://img.shields.io/npm/l/@univerjs/slides?style=flat-square
|
|
29
|
+
[npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/slides?style=flat-square
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Q=Object.defineProperty;var ee=(n,e,i)=>e in n?Q(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var O=(n,e,i)=>ee(n,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),b=require("@univerjs/docs"),U=require("@univerjs/engine-render"),M=require("@univerjs/sheets-ui"),_=require("@univerjs/ui"),F=require("rxjs"),N=require("@univerjs/sheets"),S=require("react"),k=require("clsx"),j={id:"zen-editor.operation.open-zen-editor",type:c.CommandType.OPERATION,handler:n=>!0};class te{constructor(){O(this,"_position",null);O(this,"_position$",new F.BehaviorSubject(null));O(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(e){this._position=e,this._refresh(e)}getPosition(){return this._position}_refresh(e){this._position$.next(e)}}const V=c.createIdentifier("univer.sheet-zen-editor-manager.service");var ne=Object.defineProperty,ie=Object.getOwnPropertyDescriptor,re=(n,e,i,t)=>{for(var r=t>1?void 0:t?ie(e,i):e,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=(t?s(e,i,r):s(r))||r);return t&&r&&ne(e,i,r),r},E=(n,e)=>(i,t)=>e(i,t,n);const f="__defaultDocumentZenEditorSpecialUnitId_20231218__";let P=class extends c.RxDisposable{constructor(e,i,t,r,o,s,a,d){super();O(this,"_zenEditorInitialState",!1);this._univerInstanceService=e,this._zenEditorManagerService=i,this._renderManagerService=t,this._commandService=r,this._zenZoneService=o,this._editorBridgeService=s,this._undoRedoService=a,this._textSelectionManagerService=d,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const e={id:f,body:{dataStream:`${c.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],customBlocks:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:595,height:842},documentFlavor:c.DocumentFlavor.MODERN,marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};return this._univerInstanceService.createUnit(c.UniverInstanceType.UNIVER_DOC,e)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(F.takeUntil(this.dispose$)).subscribe(e=>{var d;if(e==null)return;const i=M.getEditorObject(f,this._renderManagerService),t=this._univerInstanceService.getUniverDocInstance(f);if(i==null||t==null)return;const{width:r,height:o}=e,{engine:s}=i,a=(d=this._renderManagerService.getRenderById(f))==null?void 0:d.with(b.DocSkeletonManagerService).getSkeleton();requestIdleCallback(()=>{s.resizeBySize(r,o),this._calculatePagePosition(i),a&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){var o;this._zenEditorInitialState||(this._createZenEditorInstance(),this._zenEditorInitialState=!0),this._zenZoneService.open();const e=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);this._undoRedoService.clearUndoRedo(f),this._univerInstanceService.focusUnit(f),this._univerInstanceService.setCurrentUnitForType(f),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:U.DeviceInputEventType.PointerDown,unitId:(o=e==null?void 0:e.getUnitId())!=null?o:""});const t=this._editorBridgeService.getLatestEditCellState();if(t==null)return;this._editorSyncHandler(t);const r=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(r)}_editorSyncHandler(e){var s,a;const i=(s=e.documentLayoutObject.documentModel)==null?void 0:s.getBody(),t=i==null?void 0:i.dataStream,r=i==null?void 0:i.paragraphs;let o=[];t==null||r==null||((a=i==null?void 0:i.textRuns)!=null&&a.length&&(o=i==null?void 0:i.textRuns),this._syncContentAndRender(f,t,r,o))}_syncContentAndRender(e,i,t,r=[],o=[],s={},a=[],d=[]){var m;const h=[f,c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],l=(m=this._renderManagerService.getRenderById(e))==null?void 0:m.with(b.DocSkeletonManagerService),p=l==null?void 0:l.getSkeleton(),v=this._univerInstanceService.getUniverDocInstance(e),I=l==null?void 0:l.getViewModel();if(v==null||I==null||p==null)return;const u=v.getBody(),R=v.getSnapshot();u.dataStream=i,u.paragraphs=t,u.customBlocks=o,u.customRanges=d,R.drawings=s,R.drawingsOrder=a,e===c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(u.textRuns=[]),r.length>0&&(u.textRuns=r),I.reset(v);const C=this._getDocObject();C!=null&&(p.calculate(),h.includes(e)&&C.document.makeDirty())}_calculatePagePosition(e){const{document:i,scene:t,docBackground:r}=e,o=t==null?void 0:t.getParent(),{width:s,height:a,pageMarginLeft:d,pageMarginTop:h}=i;if(o==null||s===Number.POSITIVE_INFINITY||a===Number.POSITIVE_INFINITY)return;const{width:l,height:p}=o;let v=0,I=0,u=0,R=0,C=Number.POSITIVE_INFINITY;const{scaleX:m,scaleY:G}=t.getAncestorScale();l>(s+d*2)*m?(v=l/2-s*m/2,v/=m,u=(l-d*2)/m,C=0):(v=d,u=s+d*2,C=(u-l/m)/2),p>a?(I=p/2-a/2,R=(p-h*2)/G):(I=h,R=a+h*2),t.resize(u,R+200),i.translate(v,I),r.translate(v,I);const A=t.getViewport(b.VIEWPORT_KEY.VIEW_MAIN);if(C!==Number.POSITIVE_INFINITY&&A!=null){const J=A.transScroll2ViewportScrollValue(C,0).x;A.scrollTo({x:J})}return this}_commandExecutedListener(){const e=[j.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{e.includes(t.id)&&this._handleOpenZenEditor()}));const i=[b.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(i.includes(t.id)){const r=t.params,{unitId:o}=r;if(o===f){const s=this._univerInstanceService.getUniverDocInstance(o),a=s==null?void 0:s.getBody(),d=a==null?void 0:a.dataStream,h=a==null?void 0:a.paragraphs,l=a==null?void 0:a.textRuns,p=a==null?void 0:a.customBlocks,v=s==null?void 0:s.getDrawings(),I=s==null?void 0:s.getDrawingsOrder(),u=s==null?void 0:s.getCustomRanges();if(this._editorBridgeService.changeEditorDirty(!0),d==null||h==null)return;this._syncContentAndRender(c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,d,h,l,p,v,I,u)}}}))}_getDocObject(){return b.getDocObject(this._univerInstanceService,this._renderManagerService)}};P=re([c.OnLifecycle(c.LifecycleStages.Steady,P),E(0,c.IUniverInstanceService),E(1,V),E(2,U.IRenderManagerService),E(3,c.ICommandService),E(4,_.IZenZoneService),E(5,M.IEditorBridgeService),E(6,c.IUndoRedoService),E(7,c.Inject(b.TextSelectionManagerService))],P);const w={id:"zen-editor.command.cancel-zen-edit",type:c.CommandType.COMMAND,handler:async n=>{const e=n.get(_.IZenZoneService),i=n.get(M.IEditorBridgeService),t=n.get(c.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:U.DeviceInputEventType.Keyboard,keycode:_.KeyCode.ESC,unitId:""}),e.close();const o=t.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return o?(t.focusUnit(o.getUnitId()),i.refreshEditCellState(),!0):!1}},Z={id:"zen-editor.command.confirm-zen-edit",type:c.CommandType.COMMAND,handler:async n=>{const e=n.get(_.IZenZoneService),i=n.get(M.IEditorBridgeService),t=n.get(c.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:U.DeviceInputEventType.PointerDown,unitId:""}),e.close();const o=t.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);return o?(t.focusUnit(o.getUnitId()),i.refreshEditCellState(),!0):!1}};function se(n){return{id:j.id,group:_.MenuGroup.CONTEXT_MENU_OTHERS,type:_.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[_.MenuPosition.CONTEXT_MENU],disabled$:M.getCurrentRangeDisable$(n,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetEditPermission,N.WorksheetSetCellValuePermission,N.WorksheetSetCellStylePermission],rangeTypes:[N.RangeProtectionPermissionEditPoint]})}}var W={exports:{}},L={};/**
|
|
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
|
|
9
|
+
*/var oe=S,ce=Symbol.for("react.element"),ae=Symbol.for("react.fragment"),de=Object.prototype.hasOwnProperty,le=oe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ue={key:!0,ref:!0,__self:!0,__source:!0};function Y(n,e,i){var t,r={},o=null,s=null;i!==void 0&&(o=""+i),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(t in e)de.call(e,t)&&!ue.hasOwnProperty(t)&&(r[t]=e[t]);if(n&&n.defaultProps)for(t in e=n.defaultProps,e)r[t]===void 0&&(r[t]=e[t]);return{$$typeof:ce,type:n,key:o,ref:s,props:r,_owner:le.current}}L.Fragment=ae;L.jsx=Y;L.jsxs=Y;W.exports=L;var y=W.exports,g=function(){return g=Object.assign||function(n){for(var e,i=1,t=arguments.length;i<t;i++){e=arguments[i];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},g.apply(this,arguments)},_e=function(n,e){var i={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.indexOf(t)<0&&(i[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(n);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(n,t[r])&&(i[t[r]]=n[t[r]]);return i},B=S.forwardRef(function(n,e){var i=n.icon,t=n.id,r=n.className,o=n.extend,s=_e(n,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),d=S.useRef("_".concat(fe()));return q(i,"".concat(t),{defIds:i.defIds,idSuffix:d.current},g({ref:e,className:a},s),o)});function q(n,e,i,t,r){return S.createElement(n.tag,g(g({key:e},he(n,i,r)),t),(ve(n,i).children||[]).map(function(o,s){return q(o,"".concat(e,"-").concat(n.tag,"-").concat(s),i,void 0,r)}))}function he(n,e,i){var t=g({},n.attrs);i!=null&&i.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=i.colorChannel1);var r=e.defIds;return!r||r.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(o){var s=o[0],a=o[1];typeof a=="string"&&(t[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function ve(n,e){var i,t=e.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?g(g({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?g(g({},r),{attrs:g(g({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):n}function fe(){return Math.random().toString(36).substring(2,8)}B.displayName="UniverIcon";var ge={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=S.forwardRef(function(n,e){return S.createElement(B,Object.assign({},n,{id:"check-mark-single",ref:e,icon:ge}))});K.displayName="CheckMarkSingle";var pe={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=S.forwardRef(function(n,e){return S.createElement(B,Object.assign({},n,{id:"close-single",ref:e,icon:pe}))});H.displayName="CloseSingle";const Se="univer-zen-editor",Ie="univer-zen-editor-icon-wrapper",me="univer-zen-editor-icon-container",Ee="univer-zen-editor-icon-success",Ce="univer-zen-editor-icon-error",Oe="univer-zen-editor-canvas-container",T={zenEditor:Se,zenEditorIconWrapper:Ie,zenEditorIconContainer:me,zenEditorIconSuccess:Ee,zenEditorIconError:Ce,zenEditorCanvasContainer:Oe},ye="ZEN_EDITOR_PLUGIN_",Te=`${ye}ZEN_EDITOR_COMPONENT`;function Re(){const n=S.useRef(null),e=c.useDependency(U.IRenderManagerService),i=c.useDependency(V),t=c.useDependency(c.ICommandService);S.useEffect(()=>{const s=n.current;if(!s)return;const a=e.currentRender$.subscribe(h=>{var p;if(h!==f)return;const l=(p=e.getRenderById(f))==null?void 0:p.engine;l==null||l.setContainer(s)}),d=new ResizeObserver(()=>{const h=s.getBoundingClientRect();i.setPosition(h)});return d.observe(s),()=>{d.unobserve(s),a.unsubscribe()}},[]);function r(){t.executeCommand(w.id)}function o(){t.executeCommand(Z.id)}return y.jsxs("div",{className:T.zenEditor,children:[y.jsxs("div",{className:T.zenEditorIconWrapper,children:[y.jsx("span",{className:k(T.zenEditorIconContainer,T.zenEditorIconError),onClick:r,children:y.jsx(H,{style:{fontSize:"22px"}})}),y.jsx("span",{className:k(T.zenEditorIconContainer,T.zenEditorIconSuccess),onClick:o,children:y.jsx(K,{style:{fontSize:"22px"}})})]}),y.jsx("div",{className:T.zenEditorCanvasContainer,ref:n})]})}const be={id:Z.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:n=>X(n),binding:_.KeyCode.ENTER|_.MetaKeys.ALT},Ne={id:w.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:n=>X(n),binding:_.KeyCode.ESC};function X(n){return n.getContextValue(c.FOCUSING_DOC)&&n.getContextValue(c.FOCUSING_UNIVER_EDITOR)&&n.getContextValue(c.EDITOR_ACTIVATED)&&!n.getContextValue(c.FOCUSING_EDITOR_STANDALONE)}var ze=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,Ue=(n,e,i,t)=>{for(var r=t>1?void 0:t?xe(e,i):e,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=(t?s(e,i,r):s(r))||r);return t&&r&&ze(e,i,r),r},z=(n,e)=>(i,t)=>e(i,t,n);const Me={};let x=class extends c.Disposable{constructor(n,e,i,t,r,o){super(),this._config=n,this._injector=e,this._zenZoneService=i,this._commandService=t,this._menuService=r,this._shortcutService=o,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(Te,Re))}_initCommands(){[j,w,Z].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initMenus(){const{menu:n={}}=this._config;[se].forEach(e=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(e),n))})}_initShortcuts(){[be,Ne].forEach(n=>{this.disposeWithMe(this._shortcutService.registerShortcut(n))})}};x=Ue([c.OnLifecycle(c.LifecycleStages.Rendered,x),z(1,c.Inject(c.Injector)),z(2,_.IZenZoneService),z(3,c.ICommandService),z(4,_.IMenuService),z(5,_.IShortcutService)],x);var De=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,je=(n,e,i,t)=>{for(var r=t>1?void 0:t?Pe(e,i):e,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=(t?s(e,i,r):s(r))||r);return t&&r&&De(e,i,r),r},$=(n,e)=>(i,t)=>e(i,t,n),D;exports.UniverSheetsZenEditorPlugin=(D=class extends c.Plugin{constructor(e={},i,t){super(),this._config=e,this._injector=i,this._localeService=t,this._initializeDependencies(this._injector),this._config=c.Tools.deepMerge({},Me,this._config)}_initializeDependencies(e){[[x,{useFactory:()=>this._injector.createInstance(x,this._config)}],[P],[V,{useClass:te}]].forEach(t=>e.add(t))}},O(D,"pluginName","zen-editor"),O(D,"type",c.UniverInstanceType.UNIVER_DOC),D);exports.UniverSheetsZenEditorPlugin=je([$(1,c.Inject(c.Injector)),$(2,c.Inject(c.LocaleService))],exports.UniverSheetsZenEditorPlugin);exports.CancelZenEditCommand=w;exports.ConfirmZenEditCommand=Z;exports.OpenZenEditorOperation=j;
|
package/lib/es/index.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
var he = Object.defineProperty;
|
|
2
2
|
var _e = (t, e, i) => e in t ? he(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
|
|
3
|
-
var
|
|
4
|
-
import { CommandType as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { IZenZoneService as z, KeyCode as A, MenuGroup as Pe, MenuItemType as Ue, MenuPosition as je, MetaKeys as we, IMenuService as Le, IShortcutService as Ze } from "@univerjs/ui";
|
|
3
|
+
var E = (t, e, i) => _e(t, typeof e != "symbol" ? e + "" : e, i);
|
|
4
|
+
import { CommandType as w, createIdentifier as fe, RxDisposable as ge, DEFAULT_EMPTY_DOCUMENT_VALUE as ve, DocumentFlavor as pe, UniverInstanceType as T, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as H, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as K, OnLifecycle as Q, LifecycleStages as ee, Inject as z, IUniverInstanceService as D, ICommandService as j, IUndoRedoService as me, useDependency as U, FOCUSING_DOC as Se, FOCUSING_UNIVER_EDITOR as Ee, EDITOR_ACTIVATED as Ie, FOCUSING_EDITOR_STANDALONE as Ce, Injector as te, Disposable as Oe, Plugin as Re, Tools as ye, LocaleService as Te } from "@univerjs/core";
|
|
5
|
+
import { DocSkeletonManagerService as X, VIEWPORT_KEY as be, RichTextEditingMutation as Ne, getDocObject as ze, TextSelectionManagerService as xe } from "@univerjs/docs";
|
|
6
|
+
import { DeviceInputEventType as L, IRenderManagerService as ne } from "@univerjs/engine-render";
|
|
7
|
+
import { getEditorObject as Me, IEditorBridgeService as Z, getCurrentRangeDisable$ as Pe } from "@univerjs/sheets-ui";
|
|
8
|
+
import { IZenZoneService as x, KeyCode as V, MenuGroup as Ue, MenuItemType as we, MenuPosition as De, MetaKeys as je, IMenuService as Le, IShortcutService as Ze } from "@univerjs/ui";
|
|
10
9
|
import { BehaviorSubject as Ve, takeUntil as Ae } from "rxjs";
|
|
11
|
-
import { WorkbookEditablePermission as
|
|
12
|
-
import Ye, { forwardRef as
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
const k = {
|
|
10
|
+
import { WorkbookEditablePermission as ke, WorksheetEditPermission as $e, WorksheetSetCellValuePermission as Be, WorksheetSetCellStylePermission as Fe, RangeProtectionPermissionEditPoint as We } from "@univerjs/sheets";
|
|
11
|
+
import Ye, { forwardRef as A, useRef as ie, createElement as k, useEffect as He } from "react";
|
|
12
|
+
import G from "clsx";
|
|
13
|
+
const $ = {
|
|
16
14
|
id: "zen-editor.operation.open-zen-editor",
|
|
17
|
-
type:
|
|
15
|
+
type: w.OPERATION,
|
|
18
16
|
handler: (t) => !0
|
|
19
17
|
};
|
|
20
18
|
class Ke {
|
|
21
19
|
constructor() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
E(this, "_position", null);
|
|
21
|
+
E(this, "_position$", new Ve(null));
|
|
22
|
+
E(this, "position$", this._position$.asObservable());
|
|
25
23
|
}
|
|
26
24
|
dispose() {
|
|
27
25
|
this._position$.complete(), this._position = null;
|
|
@@ -36,30 +34,31 @@ class Ke {
|
|
|
36
34
|
this._position$.next(e);
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
|
-
const
|
|
37
|
+
const B = fe(
|
|
40
38
|
"univer.sheet-zen-editor-manager.service"
|
|
41
39
|
);
|
|
42
40
|
var Xe = Object.defineProperty, Ge = Object.getOwnPropertyDescriptor, qe = (t, e, i, n) => {
|
|
43
|
-
for (var r = n > 1 ? void 0 : n ? Ge(e, i) : e,
|
|
44
|
-
(
|
|
41
|
+
for (var r = n > 1 ? void 0 : n ? Ge(e, i) : e, o = t.length - 1, s; o >= 0; o--)
|
|
42
|
+
(s = t[o]) && (r = (n ? s(e, i, r) : s(r)) || r);
|
|
45
43
|
return n && r && Xe(e, i, r), r;
|
|
46
|
-
},
|
|
47
|
-
const
|
|
48
|
-
let
|
|
49
|
-
constructor(e, i, n, r,
|
|
44
|
+
}, m = (t, e) => (i, n) => e(i, n, t);
|
|
45
|
+
const _ = "__defaultDocumentZenEditorSpecialUnitId_20231218__";
|
|
46
|
+
let N = class extends ge {
|
|
47
|
+
constructor(e, i, n, r, o, s, c, a) {
|
|
50
48
|
super();
|
|
51
|
-
|
|
52
|
-
this.
|
|
49
|
+
E(this, "_zenEditorInitialState", !1);
|
|
50
|
+
this._univerInstanceService = e, this._zenEditorManagerService = i, this._renderManagerService = n, this._commandService = r, this._zenZoneService = o, this._editorBridgeService = s, this._undoRedoService = c, this._textSelectionManagerService = a, this._initialize();
|
|
53
51
|
}
|
|
54
52
|
_initialize() {
|
|
55
53
|
this._syncZenEditorSize(), this._commandExecutedListener();
|
|
56
54
|
}
|
|
57
55
|
_createZenEditorInstance() {
|
|
58
56
|
const e = {
|
|
59
|
-
id:
|
|
57
|
+
id: _,
|
|
60
58
|
body: {
|
|
61
59
|
dataStream: `${ve}`,
|
|
62
60
|
textRuns: [],
|
|
61
|
+
customBlocks: [],
|
|
63
62
|
paragraphs: [
|
|
64
63
|
{
|
|
65
64
|
startIndex: 0
|
|
@@ -71,7 +70,7 @@ let R = class extends fe {
|
|
|
71
70
|
width: 595,
|
|
72
71
|
height: 842
|
|
73
72
|
},
|
|
74
|
-
documentFlavor:
|
|
73
|
+
documentFlavor: pe.MODERN,
|
|
75
74
|
marginTop: 50,
|
|
76
75
|
marginBottom: 50,
|
|
77
76
|
marginRight: 40,
|
|
@@ -80,9 +79,11 @@ let R = class extends fe {
|
|
|
80
79
|
vertexAngle: 0,
|
|
81
80
|
centerAngle: 0
|
|
82
81
|
}
|
|
83
|
-
}
|
|
82
|
+
},
|
|
83
|
+
drawings: {},
|
|
84
|
+
drawingsOrder: []
|
|
84
85
|
};
|
|
85
|
-
return this._univerInstanceService.createUnit(
|
|
86
|
+
return this._univerInstanceService.createUnit(T.UNIVER_DOC, e);
|
|
86
87
|
}
|
|
87
88
|
// Listen to changes in the size of the zen editor container to set the size of the editor.
|
|
88
89
|
_syncZenEditorSize() {
|
|
@@ -90,71 +91,75 @@ let R = class extends fe {
|
|
|
90
91
|
var a;
|
|
91
92
|
if (e == null)
|
|
92
93
|
return;
|
|
93
|
-
const i = Me(
|
|
94
|
+
const i = Me(_, this._renderManagerService), n = this._univerInstanceService.getUniverDocInstance(_);
|
|
94
95
|
if (i == null || n == null)
|
|
95
96
|
return;
|
|
96
|
-
const { width: r, height:
|
|
97
|
+
const { width: r, height: o } = e, { engine: s } = i, c = (a = this._renderManagerService.getRenderById(_)) == null ? void 0 : a.with(X).getSkeleton();
|
|
97
98
|
requestIdleCallback(() => {
|
|
98
|
-
|
|
99
|
+
s.resizeBySize(r, o), this._calculatePagePosition(i), c && this._textSelectionManagerService.refreshSelection();
|
|
99
100
|
});
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
_handleOpenZenEditor() {
|
|
103
|
-
|
|
104
|
+
var o;
|
|
105
|
+
this._zenEditorInitialState || (this._createZenEditorInstance(), this._zenEditorInitialState = !0), this._zenZoneService.open();
|
|
106
|
+
const e = this._univerInstanceService.getCurrentUnitForType(T.UNIVER_SHEET);
|
|
107
|
+
this._undoRedoService.clearUndoRedo(_), this._univerInstanceService.focusUnit(_), this._univerInstanceService.setCurrentUnitForType(_), this._editorBridgeService.isVisible().visible === !1 && this._editorBridgeService.changeVisible({
|
|
104
108
|
visible: !0,
|
|
105
|
-
eventType:
|
|
109
|
+
eventType: L.PointerDown,
|
|
110
|
+
unitId: (o = e == null ? void 0 : e.getUnitId()) != null ? o : ""
|
|
106
111
|
});
|
|
107
|
-
const
|
|
108
|
-
if (
|
|
112
|
+
const n = this._editorBridgeService.getLatestEditCellState();
|
|
113
|
+
if (n == null)
|
|
109
114
|
return;
|
|
110
|
-
this._editorSyncHandler(
|
|
111
|
-
const
|
|
115
|
+
this._editorSyncHandler(n);
|
|
116
|
+
const r = [
|
|
112
117
|
{
|
|
113
118
|
startOffset: 0,
|
|
114
119
|
endOffset: 0
|
|
115
120
|
}
|
|
116
121
|
];
|
|
117
|
-
this._textSelectionManagerService.replaceTextRanges(
|
|
122
|
+
this._textSelectionManagerService.replaceTextRanges(r);
|
|
118
123
|
}
|
|
119
124
|
_editorSyncHandler(e) {
|
|
120
|
-
var
|
|
121
|
-
const i = (
|
|
122
|
-
let
|
|
123
|
-
n == null || r == null || ((c = i == null ? void 0 : i.textRuns) != null && c.length && (
|
|
125
|
+
var s, c;
|
|
126
|
+
const i = (s = e.documentLayoutObject.documentModel) == null ? void 0 : s.getBody(), n = i == null ? void 0 : i.dataStream, r = i == null ? void 0 : i.paragraphs;
|
|
127
|
+
let o = [];
|
|
128
|
+
n == null || r == null || ((c = i == null ? void 0 : i.textRuns) != null && c.length && (o = i == null ? void 0 : i.textRuns), this._syncContentAndRender(_, n, r, o));
|
|
124
129
|
}
|
|
125
|
-
_syncContentAndRender(e, i, n, r = []) {
|
|
126
|
-
var
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
],
|
|
132
|
-
if (
|
|
130
|
+
_syncContentAndRender(e, i, n, r = [], o = [], s = {}, c = [], a = []) {
|
|
131
|
+
var p;
|
|
132
|
+
const u = [
|
|
133
|
+
_,
|
|
134
|
+
K,
|
|
135
|
+
H
|
|
136
|
+
], d = (p = this._renderManagerService.getRenderById(e)) == null ? void 0 : p.with(X), g = d == null ? void 0 : d.getSkeleton(), h = this._univerInstanceService.getUniverDocInstance(e), v = d == null ? void 0 : d.getViewModel();
|
|
137
|
+
if (h == null || v == null || g == null)
|
|
133
138
|
return;
|
|
134
|
-
const l =
|
|
135
|
-
l.dataStream = i, l.paragraphs = n, e ===
|
|
136
|
-
const
|
|
137
|
-
|
|
139
|
+
const l = h.getBody(), O = h.getSnapshot();
|
|
140
|
+
l.dataStream = i, l.paragraphs = n, l.customBlocks = o, l.customRanges = a, O.drawings = s, O.drawingsOrder = c, e === H && (l.textRuns = []), r.length > 0 && (l.textRuns = r), v.reset(h);
|
|
141
|
+
const S = this._getDocObject();
|
|
142
|
+
S != null && (g.calculate(), u.includes(e) && S.document.makeDirty());
|
|
138
143
|
}
|
|
139
144
|
_calculatePagePosition(e) {
|
|
140
|
-
const { document: i, scene: n, docBackground: r } = e,
|
|
141
|
-
if (
|
|
145
|
+
const { document: i, scene: n, docBackground: r } = e, o = n == null ? void 0 : n.getParent(), { width: s, height: c, pageMarginLeft: a, pageMarginTop: u } = i;
|
|
146
|
+
if (o == null || s === Number.POSITIVE_INFINITY || c === Number.POSITIVE_INFINITY)
|
|
142
147
|
return;
|
|
143
|
-
const { width:
|
|
144
|
-
let
|
|
145
|
-
const { scaleX:
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
if (
|
|
149
|
-
const ue =
|
|
150
|
-
|
|
148
|
+
const { width: d, height: g } = o;
|
|
149
|
+
let h = 0, v = 0, l = 0, O = 0, S = Number.POSITIVE_INFINITY;
|
|
150
|
+
const { scaleX: p, scaleY: le } = n.getAncestorScale();
|
|
151
|
+
d > (s + a * 2) * p ? (h = d / 2 - s * p / 2, h /= p, l = (d - a * 2) / p, S = 0) : (h = a, l = s + a * 2, S = (l - d / p) / 2), g > c ? (v = g / 2 - c / 2, O = (g - u * 2) / le) : (v = u, O = c + u * 2), n.resize(l, O + 200), i.translate(h, v), r.translate(h, v);
|
|
152
|
+
const P = n.getViewport(be.VIEW_MAIN);
|
|
153
|
+
if (S !== Number.POSITIVE_INFINITY && P != null) {
|
|
154
|
+
const ue = P.transScroll2ViewportScrollValue(S, 0).x;
|
|
155
|
+
P.scrollTo({
|
|
151
156
|
x: ue
|
|
152
157
|
});
|
|
153
158
|
}
|
|
154
159
|
return this;
|
|
155
160
|
}
|
|
156
161
|
_commandExecutedListener() {
|
|
157
|
-
const e = [
|
|
162
|
+
const e = [$.id];
|
|
158
163
|
this.disposeWithMe(
|
|
159
164
|
this._commandService.onCommandExecuted((n) => {
|
|
160
165
|
e.includes(n.id) && this._handleOpenZenEditor();
|
|
@@ -164,12 +169,12 @@ let R = class extends fe {
|
|
|
164
169
|
this.disposeWithMe(
|
|
165
170
|
this._commandService.onCommandExecuted((n) => {
|
|
166
171
|
if (i.includes(n.id)) {
|
|
167
|
-
const r = n.params, { unitId:
|
|
168
|
-
if (
|
|
169
|
-
const
|
|
170
|
-
if (this._editorBridgeService.changeEditorDirty(!0), a == null ||
|
|
172
|
+
const r = n.params, { unitId: o } = r;
|
|
173
|
+
if (o === _) {
|
|
174
|
+
const s = this._univerInstanceService.getUniverDocInstance(o), c = s == null ? void 0 : s.getBody(), a = c == null ? void 0 : c.dataStream, u = c == null ? void 0 : c.paragraphs, d = c == null ? void 0 : c.textRuns, g = c == null ? void 0 : c.customBlocks, h = s == null ? void 0 : s.getDrawings(), v = s == null ? void 0 : s.getDrawingsOrder(), l = s == null ? void 0 : s.getCustomRanges();
|
|
175
|
+
if (this._editorBridgeService.changeEditorDirty(!0), a == null || u == null)
|
|
171
176
|
return;
|
|
172
|
-
this._syncContentAndRender(
|
|
177
|
+
this._syncContentAndRender(K, a, u, d, g, h, v, l);
|
|
173
178
|
}
|
|
174
179
|
}
|
|
175
180
|
})
|
|
@@ -179,56 +184,57 @@ let R = class extends fe {
|
|
|
179
184
|
return ze(this._univerInstanceService, this._renderManagerService);
|
|
180
185
|
}
|
|
181
186
|
};
|
|
182
|
-
|
|
183
|
-
ee
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const W = {
|
|
187
|
+
N = qe([
|
|
188
|
+
Q(ee.Steady, N),
|
|
189
|
+
m(0, D),
|
|
190
|
+
m(1, B),
|
|
191
|
+
m(2, ne),
|
|
192
|
+
m(3, j),
|
|
193
|
+
m(4, x),
|
|
194
|
+
m(5, Z),
|
|
195
|
+
m(6, me),
|
|
196
|
+
m(7, z(xe))
|
|
197
|
+
], N);
|
|
198
|
+
const F = {
|
|
195
199
|
id: "zen-editor.command.cancel-zen-edit",
|
|
196
|
-
type:
|
|
200
|
+
type: w.COMMAND,
|
|
197
201
|
handler: async (t) => {
|
|
198
|
-
const e = t.get(
|
|
202
|
+
const e = t.get(x), i = t.get(Z), n = t.get(D);
|
|
199
203
|
i.isVisible().visible && i.changeVisible({
|
|
200
204
|
visible: !1,
|
|
201
|
-
eventType:
|
|
202
|
-
keycode:
|
|
205
|
+
eventType: L.Keyboard,
|
|
206
|
+
keycode: V.ESC,
|
|
207
|
+
unitId: ""
|
|
203
208
|
}), e.close();
|
|
204
|
-
const
|
|
205
|
-
return
|
|
209
|
+
const o = n.getCurrentUnitForType(T.UNIVER_SHEET);
|
|
210
|
+
return o ? (n.focusUnit(o.getUnitId()), i.refreshEditCellState(), !0) : !1;
|
|
206
211
|
}
|
|
207
|
-
},
|
|
212
|
+
}, W = {
|
|
208
213
|
id: "zen-editor.command.confirm-zen-edit",
|
|
209
|
-
type:
|
|
214
|
+
type: w.COMMAND,
|
|
210
215
|
handler: async (t) => {
|
|
211
|
-
const e = t.get(
|
|
216
|
+
const e = t.get(x), i = t.get(Z), n = t.get(D);
|
|
212
217
|
i.isVisible().visible && i.changeVisible({
|
|
213
218
|
visible: !1,
|
|
214
|
-
eventType:
|
|
219
|
+
eventType: L.PointerDown,
|
|
220
|
+
unitId: ""
|
|
215
221
|
}), e.close();
|
|
216
|
-
const
|
|
217
|
-
return
|
|
222
|
+
const o = n.getCurrentUnitForType(T.UNIVER_SHEET);
|
|
223
|
+
return o ? (n.focusUnit(o.getUnitId()), i.refreshEditCellState(), !0) : !1;
|
|
218
224
|
}
|
|
219
225
|
};
|
|
220
226
|
function Je(t) {
|
|
221
227
|
return {
|
|
222
|
-
id:
|
|
223
|
-
group:
|
|
224
|
-
type:
|
|
228
|
+
id: $.id,
|
|
229
|
+
group: Ue.CONTEXT_MENU_OTHERS,
|
|
230
|
+
type: we.BUTTON,
|
|
225
231
|
title: "rightClick.zenEditor",
|
|
226
232
|
icon: "AmplifySingle",
|
|
227
|
-
positions: [
|
|
228
|
-
disabled$:
|
|
233
|
+
positions: [De.CONTEXT_MENU],
|
|
234
|
+
disabled$: Pe(t, { workbookTypes: [ke], worksheetTypes: [$e, Be, Fe], rangeTypes: [We] })
|
|
229
235
|
};
|
|
230
236
|
}
|
|
231
|
-
var re = { exports: {} },
|
|
237
|
+
var re = { exports: {} }, M = {};
|
|
232
238
|
/**
|
|
233
239
|
* @license React
|
|
234
240
|
* react-jsx-runtime.production.min.js
|
|
@@ -239,157 +245,157 @@ var re = { exports: {} }, x = {};
|
|
|
239
245
|
* LICENSE file in the root directory of this source tree.
|
|
240
246
|
*/
|
|
241
247
|
var Qe = Ye, et = Symbol.for("react.element"), tt = Symbol.for("react.fragment"), nt = Object.prototype.hasOwnProperty, it = Qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, rt = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
242
|
-
function
|
|
243
|
-
var n, r = {},
|
|
244
|
-
i !== void 0 && (
|
|
248
|
+
function se(t, e, i) {
|
|
249
|
+
var n, r = {}, o = null, s = null;
|
|
250
|
+
i !== void 0 && (o = "" + i), e.key !== void 0 && (o = "" + e.key), e.ref !== void 0 && (s = e.ref);
|
|
245
251
|
for (n in e) nt.call(e, n) && !rt.hasOwnProperty(n) && (r[n] = e[n]);
|
|
246
252
|
if (t && t.defaultProps) for (n in e = t.defaultProps, e) r[n] === void 0 && (r[n] = e[n]);
|
|
247
|
-
return { $$typeof: et, type: t, key:
|
|
253
|
+
return { $$typeof: et, type: t, key: o, ref: s, props: r, _owner: it.current };
|
|
248
254
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
re.exports =
|
|
253
|
-
var
|
|
254
|
-
return
|
|
255
|
+
M.Fragment = tt;
|
|
256
|
+
M.jsx = se;
|
|
257
|
+
M.jsxs = se;
|
|
258
|
+
re.exports = M;
|
|
259
|
+
var I = re.exports, f = function() {
|
|
260
|
+
return f = Object.assign || function(t) {
|
|
255
261
|
for (var e, i = 1, n = arguments.length; i < n; i++) {
|
|
256
262
|
e = arguments[i];
|
|
257
263
|
for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
|
|
258
264
|
}
|
|
259
265
|
return t;
|
|
260
|
-
},
|
|
261
|
-
},
|
|
266
|
+
}, f.apply(this, arguments);
|
|
267
|
+
}, st = function(t, e) {
|
|
262
268
|
var i = {};
|
|
263
269
|
for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (i[n] = t[n]);
|
|
264
270
|
if (t != null && typeof Object.getOwnPropertySymbols == "function")
|
|
265
271
|
for (var r = 0, n = Object.getOwnPropertySymbols(t); r < n.length; r++)
|
|
266
272
|
e.indexOf(n[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[r]) && (i[n[r]] = t[n[r]]);
|
|
267
273
|
return i;
|
|
268
|
-
},
|
|
269
|
-
var i = t.icon, n = t.id, r = t.className,
|
|
270
|
-
return
|
|
274
|
+
}, Y = A(function(t, e) {
|
|
275
|
+
var i = t.icon, n = t.id, r = t.className, o = t.extend, s = st(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(n, " ").concat(r || "").trim(), a = ie("_".concat(at()));
|
|
276
|
+
return oe(i, "".concat(n), { defIds: i.defIds, idSuffix: a.current }, f({ ref: e, className: c }, s), o);
|
|
271
277
|
});
|
|
272
|
-
function
|
|
273
|
-
return
|
|
274
|
-
return
|
|
278
|
+
function oe(t, e, i, n, r) {
|
|
279
|
+
return k(t.tag, f(f({ key: e }, ot(t, i, r)), n), (ct(t, i).children || []).map(function(o, s) {
|
|
280
|
+
return oe(o, "".concat(e, "-").concat(t.tag, "-").concat(s), i, void 0, r);
|
|
275
281
|
}));
|
|
276
282
|
}
|
|
277
|
-
function
|
|
278
|
-
var n =
|
|
283
|
+
function ot(t, e, i) {
|
|
284
|
+
var n = f({}, t.attrs);
|
|
279
285
|
i != null && i.colorChannel1 && n.fill === "colorChannel1" && (n.fill = i.colorChannel1);
|
|
280
286
|
var r = e.defIds;
|
|
281
|
-
return !r || r.length === 0 || (t.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + e.idSuffix), Object.entries(n).forEach(function(
|
|
282
|
-
var
|
|
283
|
-
typeof c == "string" && (n[
|
|
287
|
+
return !r || r.length === 0 || (t.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + e.idSuffix), Object.entries(n).forEach(function(o) {
|
|
288
|
+
var s = o[0], c = o[1];
|
|
289
|
+
typeof c == "string" && (n[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
284
290
|
})), n;
|
|
285
291
|
}
|
|
286
292
|
function ct(t, e) {
|
|
287
293
|
var i, n = e.defIds;
|
|
288
|
-
return !n || n.length === 0 ? t : t.tag === "defs" && (!((i = t.children) === null || i === void 0) && i.length) ?
|
|
289
|
-
return typeof r.attrs.id == "string" && n && n.indexOf(r.attrs.id) > -1 ?
|
|
294
|
+
return !n || n.length === 0 ? t : t.tag === "defs" && (!((i = t.children) === null || i === void 0) && i.length) ? f(f({}, t), { children: t.children.map(function(r) {
|
|
295
|
+
return typeof r.attrs.id == "string" && n && n.indexOf(r.attrs.id) > -1 ? f(f({}, r), { attrs: f(f({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
|
|
290
296
|
}) }) : t;
|
|
291
297
|
}
|
|
292
298
|
function at() {
|
|
293
299
|
return Math.random().toString(36).substring(2, 8);
|
|
294
300
|
}
|
|
295
|
-
|
|
296
|
-
var dt = { 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" } }] }, ce =
|
|
297
|
-
return
|
|
301
|
+
Y.displayName = "UniverIcon";
|
|
302
|
+
var dt = { 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" } }] }, ce = A(function(t, e) {
|
|
303
|
+
return k(Y, Object.assign({}, t, {
|
|
298
304
|
id: "check-mark-single",
|
|
299
305
|
ref: e,
|
|
300
306
|
icon: dt
|
|
301
307
|
}));
|
|
302
308
|
});
|
|
303
309
|
ce.displayName = "CheckMarkSingle";
|
|
304
|
-
var lt = { 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" } }] }, ae =
|
|
305
|
-
return
|
|
310
|
+
var lt = { 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" } }] }, ae = A(function(t, e) {
|
|
311
|
+
return k(Y, Object.assign({}, t, {
|
|
306
312
|
id: "close-single",
|
|
307
313
|
ref: e,
|
|
308
314
|
icon: lt
|
|
309
315
|
}));
|
|
310
316
|
});
|
|
311
317
|
ae.displayName = "CloseSingle";
|
|
312
|
-
const ut = "univer-zen-editor", ht = "univer-zen-editor-icon-wrapper", _t = "univer-zen-editor-icon-container", ft = "univer-zen-editor-icon-success",
|
|
318
|
+
const ut = "univer-zen-editor", ht = "univer-zen-editor-icon-wrapper", _t = "univer-zen-editor-icon-container", ft = "univer-zen-editor-icon-success", gt = "univer-zen-editor-icon-error", vt = "univer-zen-editor-canvas-container", C = {
|
|
313
319
|
zenEditor: ut,
|
|
314
320
|
zenEditorIconWrapper: ht,
|
|
315
321
|
zenEditorIconContainer: _t,
|
|
316
322
|
zenEditorIconSuccess: ft,
|
|
317
|
-
zenEditorIconError:
|
|
318
|
-
zenEditorCanvasContainer:
|
|
323
|
+
zenEditorIconError: gt,
|
|
324
|
+
zenEditorCanvasContainer: vt
|
|
319
325
|
}, pt = "ZEN_EDITOR_PLUGIN_", mt = `${pt}ZEN_EDITOR_COMPONENT`;
|
|
320
326
|
function St() {
|
|
321
|
-
const t = ie(null), e =
|
|
327
|
+
const t = ie(null), e = U(ne), i = U(B), n = U(j);
|
|
322
328
|
He(() => {
|
|
323
|
-
const
|
|
324
|
-
if (!
|
|
329
|
+
const s = t.current;
|
|
330
|
+
if (!s)
|
|
325
331
|
return;
|
|
326
|
-
const c = e.currentRender$.subscribe((
|
|
327
|
-
var
|
|
328
|
-
if (
|
|
332
|
+
const c = e.currentRender$.subscribe((u) => {
|
|
333
|
+
var g;
|
|
334
|
+
if (u !== _)
|
|
329
335
|
return;
|
|
330
|
-
const
|
|
331
|
-
|
|
336
|
+
const d = (g = e.getRenderById(_)) == null ? void 0 : g.engine;
|
|
337
|
+
d == null || d.setContainer(s);
|
|
332
338
|
}), a = new ResizeObserver(() => {
|
|
333
|
-
const
|
|
334
|
-
i.setPosition(
|
|
339
|
+
const u = s.getBoundingClientRect();
|
|
340
|
+
i.setPosition(u);
|
|
335
341
|
});
|
|
336
|
-
return a.observe(
|
|
337
|
-
a.unobserve(
|
|
342
|
+
return a.observe(s), () => {
|
|
343
|
+
a.unobserve(s), c.unsubscribe();
|
|
338
344
|
};
|
|
339
345
|
}, []);
|
|
340
346
|
function r() {
|
|
341
|
-
n.executeCommand(
|
|
347
|
+
n.executeCommand(F.id);
|
|
342
348
|
}
|
|
343
|
-
function
|
|
344
|
-
n.executeCommand(
|
|
349
|
+
function o() {
|
|
350
|
+
n.executeCommand(W.id);
|
|
345
351
|
}
|
|
346
|
-
return /* @__PURE__ */
|
|
347
|
-
/* @__PURE__ */
|
|
348
|
-
/* @__PURE__ */
|
|
352
|
+
return /* @__PURE__ */ I.jsxs("div", { className: C.zenEditor, children: [
|
|
353
|
+
/* @__PURE__ */ I.jsxs("div", { className: C.zenEditorIconWrapper, children: [
|
|
354
|
+
/* @__PURE__ */ I.jsx(
|
|
349
355
|
"span",
|
|
350
356
|
{
|
|
351
|
-
className:
|
|
357
|
+
className: G(C.zenEditorIconContainer, C.zenEditorIconError),
|
|
352
358
|
onClick: r,
|
|
353
|
-
children: /* @__PURE__ */
|
|
359
|
+
children: /* @__PURE__ */ I.jsx(ae, { style: { fontSize: "22px" } })
|
|
354
360
|
}
|
|
355
361
|
),
|
|
356
|
-
/* @__PURE__ */
|
|
362
|
+
/* @__PURE__ */ I.jsx(
|
|
357
363
|
"span",
|
|
358
364
|
{
|
|
359
|
-
className:
|
|
360
|
-
onClick:
|
|
361
|
-
children: /* @__PURE__ */
|
|
365
|
+
className: G(C.zenEditorIconContainer, C.zenEditorIconSuccess),
|
|
366
|
+
onClick: o,
|
|
367
|
+
children: /* @__PURE__ */ I.jsx(ce, { style: { fontSize: "22px" } })
|
|
362
368
|
}
|
|
363
369
|
)
|
|
364
370
|
] }),
|
|
365
|
-
/* @__PURE__ */
|
|
371
|
+
/* @__PURE__ */ I.jsx("div", { className: C.zenEditorCanvasContainer, ref: t })
|
|
366
372
|
] });
|
|
367
373
|
}
|
|
368
374
|
const Et = {
|
|
369
|
-
id:
|
|
375
|
+
id: W.id,
|
|
370
376
|
description: "shortcut.sheet.zen-edit-confirm",
|
|
371
377
|
group: "4_sheet-edit",
|
|
372
378
|
preconditions: (t) => de(t),
|
|
373
|
-
binding:
|
|
379
|
+
binding: V.ENTER | je.ALT
|
|
374
380
|
}, It = {
|
|
375
|
-
id:
|
|
381
|
+
id: F.id,
|
|
376
382
|
description: "shortcut.sheet.zen-edit-cancel",
|
|
377
383
|
group: "4_sheet-edit",
|
|
378
384
|
preconditions: (t) => de(t),
|
|
379
|
-
binding:
|
|
385
|
+
binding: V.ESC
|
|
380
386
|
};
|
|
381
387
|
function de(t) {
|
|
382
|
-
return t.getContextValue(
|
|
388
|
+
return t.getContextValue(Se) && t.getContextValue(Ee) && t.getContextValue(Ie) && !t.getContextValue(Ce);
|
|
383
389
|
}
|
|
384
|
-
var Ct = Object.defineProperty, Ot = Object.getOwnPropertyDescriptor,
|
|
385
|
-
for (var r = n > 1 ? void 0 : n ? Ot(e, i) : e,
|
|
386
|
-
(
|
|
390
|
+
var Ct = Object.defineProperty, Ot = Object.getOwnPropertyDescriptor, Rt = (t, e, i, n) => {
|
|
391
|
+
for (var r = n > 1 ? void 0 : n ? Ot(e, i) : e, o = t.length - 1, s; o >= 0; o--)
|
|
392
|
+
(s = t[o]) && (r = (n ? s(e, i, r) : s(r)) || r);
|
|
387
393
|
return n && r && Ct(e, i, r), r;
|
|
388
|
-
},
|
|
389
|
-
const
|
|
390
|
-
let
|
|
391
|
-
constructor(t, e, i, n, r,
|
|
392
|
-
super(), this._config = t, this._injector = e, this._zenZoneService = i, this._commandService = n, this._menuService = r, this._shortcutService =
|
|
394
|
+
}, R = (t, e) => (i, n) => e(i, n, t);
|
|
395
|
+
const yt = {};
|
|
396
|
+
let y = class extends Oe {
|
|
397
|
+
constructor(t, e, i, n, r, o) {
|
|
398
|
+
super(), this._config = t, this._injector = e, this._zenZoneService = i, this._commandService = n, this._menuService = r, this._shortcutService = o, this._initialize();
|
|
393
399
|
}
|
|
394
400
|
_initialize() {
|
|
395
401
|
this._initCustomComponents(), this._initCommands(), this._initMenus(), this._initShortcuts();
|
|
@@ -398,7 +404,7 @@ let I = class extends Ce {
|
|
|
398
404
|
this.disposeWithMe(this._zenZoneService.set(mt, St));
|
|
399
405
|
}
|
|
400
406
|
_initCommands() {
|
|
401
|
-
[
|
|
407
|
+
[$, F, W].forEach((t) => {
|
|
402
408
|
this.disposeWithMe(this._commandService.registerCommand(t));
|
|
403
409
|
});
|
|
404
410
|
}
|
|
@@ -417,43 +423,43 @@ let I = class extends Ce {
|
|
|
417
423
|
});
|
|
418
424
|
}
|
|
419
425
|
};
|
|
420
|
-
|
|
421
|
-
ee
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
],
|
|
428
|
-
var Tt = Object.defineProperty,
|
|
429
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
430
|
-
(
|
|
426
|
+
y = Rt([
|
|
427
|
+
Q(ee.Rendered, y),
|
|
428
|
+
R(1, z(te)),
|
|
429
|
+
R(2, x),
|
|
430
|
+
R(3, j),
|
|
431
|
+
R(4, Le),
|
|
432
|
+
R(5, Ze)
|
|
433
|
+
], y);
|
|
434
|
+
var Tt = Object.defineProperty, bt = Object.getOwnPropertyDescriptor, Nt = (t, e, i, n) => {
|
|
435
|
+
for (var r = n > 1 ? void 0 : n ? bt(e, i) : e, o = t.length - 1, s; o >= 0; o--)
|
|
436
|
+
(s = t[o]) && (r = (n ? s(e, i, r) : s(r)) || r);
|
|
431
437
|
return n && r && Tt(e, i, r), r;
|
|
432
|
-
},
|
|
433
|
-
let
|
|
438
|
+
}, q = (t, e) => (i, n) => e(i, n, t), b;
|
|
439
|
+
let J = (b = class extends Re {
|
|
434
440
|
constructor(t = {}, e, i) {
|
|
435
|
-
super(), this._config = t, this._injector = e, this._localeService = i, this._initializeDependencies(this._injector), this._config = ye.deepMerge({},
|
|
441
|
+
super(), this._config = t, this._injector = e, this._localeService = i, this._initializeDependencies(this._injector), this._config = ye.deepMerge({}, yt, this._config);
|
|
436
442
|
}
|
|
437
443
|
_initializeDependencies(t) {
|
|
438
444
|
[
|
|
439
445
|
[
|
|
440
|
-
|
|
446
|
+
y,
|
|
441
447
|
{
|
|
442
|
-
useFactory: () => this._injector.createInstance(
|
|
448
|
+
useFactory: () => this._injector.createInstance(y, this._config)
|
|
443
449
|
}
|
|
444
450
|
],
|
|
445
|
-
[
|
|
446
|
-
[
|
|
451
|
+
[N],
|
|
452
|
+
[B, { useClass: Ke }]
|
|
447
453
|
].forEach((i) => t.add(i));
|
|
448
454
|
}
|
|
449
|
-
},
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
],
|
|
455
|
+
}, E(b, "pluginName", "zen-editor"), E(b, "type", T.UNIVER_DOC), b);
|
|
456
|
+
J = Nt([
|
|
457
|
+
q(1, z(te)),
|
|
458
|
+
q(2, z(Te))
|
|
459
|
+
], J);
|
|
454
460
|
export {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
461
|
+
F as CancelZenEditCommand,
|
|
462
|
+
W as ConfirmZenEditCommand,
|
|
463
|
+
$ as OpenZenEditorOperation,
|
|
464
|
+
J as UniverSheetsZenEditorPlugin
|
|
459
465
|
};
|
package/lib/locale/zh-CN.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Disposable, ICommandService } from '@univerjs/core';
|
|
1
|
+
import { Disposable, ICommandService, Injector } from '@univerjs/core';
|
|
2
2
|
import { MenuConfig, IMenuService, IShortcutService, IZenZoneService } from '@univerjs/ui';
|
|
3
|
-
import { Injector } from '@wendellhu/redi';
|
|
4
3
|
|
|
5
4
|
export interface IUniverSheetsZenEditorUIConfig {
|
|
6
5
|
menu: MenuConfig;
|
|
@@ -3,12 +3,10 @@ import { TextSelectionManagerService } from '@univerjs/docs';
|
|
|
3
3
|
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
4
4
|
import { IEditorBridgeService } from '@univerjs/sheets-ui';
|
|
5
5
|
import { IZenZoneService } from '@univerjs/ui';
|
|
6
|
-
import { Injector } from '@wendellhu/redi';
|
|
7
6
|
import { IZenEditorManagerService } from '../services/zen-editor.service';
|
|
8
7
|
|
|
9
8
|
export declare const DOCS_ZEN_EDITOR_UNIT_ID_KEY = "__defaultDocumentZenEditorSpecialUnitId_20231218__";
|
|
10
9
|
export declare class ZenEditorController extends RxDisposable {
|
|
11
|
-
private readonly _injector;
|
|
12
10
|
private readonly _univerInstanceService;
|
|
13
11
|
private readonly _zenEditorManagerService;
|
|
14
12
|
private readonly _renderManagerService;
|
|
@@ -17,7 +15,7 @@ export declare class ZenEditorController extends RxDisposable {
|
|
|
17
15
|
private readonly _editorBridgeService;
|
|
18
16
|
private readonly _undoRedoService;
|
|
19
17
|
private readonly _textSelectionManagerService;
|
|
20
|
-
constructor(
|
|
18
|
+
constructor(_univerInstanceService: IUniverInstanceService, _zenEditorManagerService: IZenEditorManagerService, _renderManagerService: IRenderManagerService, _commandService: ICommandService, _zenZoneService: IZenZoneService, _editorBridgeService: IEditorBridgeService, _undoRedoService: IUndoRedoService, _textSelectionManagerService: TextSelectionManagerService);
|
|
21
19
|
private _initialize;
|
|
22
20
|
private _createZenEditorInstance;
|
|
23
21
|
private _syncZenEditorSize;
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { LocaleService, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
2
|
-
import { Injector } from '@wendellhu/redi';
|
|
1
|
+
import { Injector, LocaleService, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
3
2
|
import { IUniverSheetsZenEditorUIConfig } from './controllers/zen-editor-ui.controller';
|
|
4
3
|
|
|
5
4
|
export declare class UniverSheetsZenEditorPlugin extends Plugin {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Nullable } from '@univerjs/core';
|
|
2
|
-
import { IDisposable } from '@wendellhu/redi';
|
|
1
|
+
import { IDisposable, Nullable } from '@univerjs/core';
|
|
3
2
|
import { Observable } from 'rxjs';
|
|
4
3
|
|
|
5
4
|
export interface IZenEditorManagerService {
|
|
@@ -17,4 +16,4 @@ export declare class ZenEditorManagerService implements IDisposable {
|
|
|
17
16
|
getPosition(): Readonly<Nullable<DOMRect>>;
|
|
18
17
|
private _refresh;
|
|
19
18
|
}
|
|
20
|
-
export declare const IZenEditorManagerService: import('@
|
|
19
|
+
export declare const IZenEditorManagerService: import('@univerjs/core').IdentifierDecorator<ZenEditorManagerService>;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(d,
|
|
1
|
+
(function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets"),require("react"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs","@univerjs/engine-render","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/sheets","react","clsx"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.UniverSheetsZenEditor={},d.UniverCore,d.UniverDocs,d.UniverEngineRender,d.UniverSheetsUi,d.UniverUi,d.rxjs,d.UniverSheets,d.React,d.clsx))})(this,function(d,s,S,U,b,v,F,j,E,W){"use strict";var ze=Object.defineProperty;var Ue=(d,s,S)=>s in d?ze(d,s,{enumerable:!0,configurable:!0,writable:!0,value:S}):d[s]=S;var N=(d,s,S)=>Ue(d,typeof s!="symbol"?s+"":s,S);var A;const D={id:"zen-editor.operation.open-zen-editor",type:s.CommandType.OPERATION,handler:n=>!0};class J{constructor(){N(this,"_position",null);N(this,"_position$",new F.BehaviorSubject(null));N(this,"position$",this._position$.asObservable())}dispose(){this._position$.complete(),this._position=null}setPosition(t){this._position=t,this._refresh(t)}getPosition(){return this._position}_refresh(t){this._position$.next(t)}}const V=s.createIdentifier("univer.sheet-zen-editor-manager.service");var Q=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,te=(n,t,i,e)=>{for(var r=e>1?void 0:e?ee(t,i):t,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&Q(t,i,r),r},C=(n,t)=>(i,e)=>t(i,e,n);const h="__defaultDocumentZenEditorSpecialUnitId_20231218__";let P=class extends s.RxDisposable{constructor(t,i,e,r,c,o,a,l){super();N(this,"_zenEditorInitialState",!1);this._univerInstanceService=t,this._zenEditorManagerService=i,this._renderManagerService=e,this._commandService=r,this._zenZoneService=c,this._editorBridgeService=o,this._undoRedoService=a,this._textSelectionManagerService=l,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const t={id:h,body:{dataStream:`${s.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],customBlocks:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:595,height:842},documentFlavor:s.DocumentFlavor.MODERN,marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},drawings:{},drawingsOrder:[]};return this._univerInstanceService.createUnit(s.UniverInstanceType.UNIVER_DOC,t)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(F.takeUntil(this.dispose$)).subscribe(t=>{var l;if(t==null)return;const i=b.getEditorObject(h,this._renderManagerService),e=this._univerInstanceService.getUniverDocInstance(h);if(i==null||e==null)return;const{width:r,height:c}=t,{engine:o}=i,a=(l=this._renderManagerService.getRenderById(h))==null?void 0:l.with(S.DocSkeletonManagerService).getSkeleton();requestIdleCallback(()=>{o.resizeBySize(r,c),this._calculatePagePosition(i),a&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){var c;this._zenEditorInitialState||(this._createZenEditorInstance(),this._zenEditorInitialState=!0),this._zenZoneService.open();const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);this._undoRedoService.clearUndoRedo(h),this._univerInstanceService.focusUnit(h),this._univerInstanceService.setCurrentUnitForType(h),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:U.DeviceInputEventType.PointerDown,unitId:(c=t==null?void 0:t.getUnitId())!=null?c:""});const e=this._editorBridgeService.getLatestEditCellState();if(e==null)return;this._editorSyncHandler(e);const r=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(r)}_editorSyncHandler(t){var o,a;const i=(o=t.documentLayoutObject.documentModel)==null?void 0:o.getBody(),e=i==null?void 0:i.dataStream,r=i==null?void 0:i.paragraphs;let c=[];e==null||r==null||((a=i==null?void 0:i.textRuns)!=null&&a.length&&(c=i==null?void 0:i.textRuns),this._syncContentAndRender(h,e,r,c))}_syncContentAndRender(t,i,e,r=[],c=[],o={},a=[],l=[]){var O;const g=[h,s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],u=(O=this._renderManagerService.getRenderById(t))==null?void 0:O.with(S.DocSkeletonManagerService),I=u==null?void 0:u.getSkeleton(),p=this._univerInstanceService.getUniverDocInstance(t),m=u==null?void 0:u.getViewModel();if(p==null||m==null||I==null)return;const _=p.getBody(),z=p.getSnapshot();_.dataStream=i,_.paragraphs=e,_.customBlocks=c,_.customRanges=l,z.drawings=o,z.drawingsOrder=a,t===s.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(_.textRuns=[]),r.length>0&&(_.textRuns=r),m.reset(p);const R=this._getDocObject();R!=null&&(I.calculate(),g.includes(t)&&R.document.makeDirty())}_calculatePagePosition(t){const{document:i,scene:e,docBackground:r}=t,c=e==null?void 0:e.getParent(),{width:o,height:a,pageMarginLeft:l,pageMarginTop:g}=i;if(c==null||o===Number.POSITIVE_INFINITY||a===Number.POSITIVE_INFINITY)return;const{width:u,height:I}=c;let p=0,m=0,_=0,z=0,R=Number.POSITIVE_INFINITY;const{scaleX:O,scaleY:Re}=e.getAncestorScale();u>(o+l*2)*O?(p=u/2-o*O/2,p/=O,_=(u-l*2)/O,R=0):(p=l,_=o+l*2,R=(_-u/O)/2),I>a?(m=I/2-a/2,z=(I-g*2)/Re):(m=g,z=a+g*2),e.resize(_,z+200),i.translate(p,m),r.translate(p,m);const k=e.getViewport(S.VIEWPORT_KEY.VIEW_MAIN);if(R!==Number.POSITIVE_INFINITY&&k!=null){const Ne=k.transScroll2ViewportScrollValue(R,0).x;k.scrollTo({x:Ne})}return this}_commandExecutedListener(){const t=[D.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{t.includes(e.id)&&this._handleOpenZenEditor()}));const i=[S.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const r=e.params,{unitId:c}=r;if(c===h){const o=this._univerInstanceService.getUniverDocInstance(c),a=o==null?void 0:o.getBody(),l=a==null?void 0:a.dataStream,g=a==null?void 0:a.paragraphs,u=a==null?void 0:a.textRuns,I=a==null?void 0:a.customBlocks,p=o==null?void 0:o.getDrawings(),m=o==null?void 0:o.getDrawingsOrder(),_=o==null?void 0:o.getCustomRanges();if(this._editorBridgeService.changeEditorDirty(!0),l==null||g==null)return;this._syncContentAndRender(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l,g,u,I,p,m,_)}}}))}_getDocObject(){return S.getDocObject(this._univerInstanceService,this._renderManagerService)}};P=te([s.OnLifecycle(s.LifecycleStages.Steady,P),C(0,s.IUniverInstanceService),C(1,V),C(2,U.IRenderManagerService),C(3,s.ICommandService),C(4,v.IZenZoneService),C(5,b.IEditorBridgeService),C(6,s.IUndoRedoService),C(7,s.Inject(S.TextSelectionManagerService))],P);const w={id:"zen-editor.command.cancel-zen-edit",type:s.CommandType.COMMAND,handler:async n=>{const t=n.get(v.IZenZoneService),i=n.get(b.IEditorBridgeService),e=n.get(s.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:U.DeviceInputEventType.Keyboard,keycode:v.KeyCode.ESC,unitId:""}),t.close();const c=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);return c?(e.focusUnit(c.getUnitId()),i.refreshEditCellState(),!0):!1}},Z={id:"zen-editor.command.confirm-zen-edit",type:s.CommandType.COMMAND,handler:async n=>{const t=n.get(v.IZenZoneService),i=n.get(b.IEditorBridgeService),e=n.get(s.IUniverInstanceService);i.isVisible().visible&&i.changeVisible({visible:!1,eventType:U.DeviceInputEventType.PointerDown,unitId:""}),t.close();const c=e.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);return c?(e.focusUnit(c.getUnitId()),i.refreshEditCellState(),!0):!1}};function ne(n){return{id:D.id,group:v.MenuGroup.CONTEXT_MENU_OTHERS,type:v.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[v.MenuPosition.CONTEXT_MENU],disabled$:b.getCurrentRangeDisable$(n,{workbookTypes:[j.WorkbookEditablePermission],worksheetTypes:[j.WorksheetEditPermission,j.WorksheetSetCellValuePermission,j.WorksheetSetCellStylePermission],rangeTypes:[j.RangeProtectionPermissionEditPoint]})}}var Y={exports:{}},L={};/**
|
|
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
|
|
9
|
+
*/var ie=E,re=Symbol.for("react.element"),se=Symbol.for("react.fragment"),oe=Object.prototype.hasOwnProperty,ce=ie.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ae={key:!0,ref:!0,__self:!0,__source:!0};function K(n,t,i){var e,r={},c=null,o=null;i!==void 0&&(c=""+i),t.key!==void 0&&(c=""+t.key),t.ref!==void 0&&(o=t.ref);for(e in t)oe.call(t,e)&&!ae.hasOwnProperty(e)&&(r[e]=t[e]);if(n&&n.defaultProps)for(e in t=n.defaultProps,t)r[e]===void 0&&(r[e]=t[e]);return{$$typeof:re,type:n,key:c,ref:o,props:r,_owner:ce.current}}L.Fragment=se,L.jsx=K,L.jsxs=K,Y.exports=L;var y=Y.exports,f=function(){return f=Object.assign||function(n){for(var t,i=1,e=arguments.length;i<e;i++){t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},f.apply(this,arguments)},de=function(n,t){var i={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.indexOf(e)<0&&(i[e]=n[e]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(n);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(n,e[r])&&(i[e[r]]=n[e[r]]);return i},B=E.forwardRef(function(n,t){var i=n.icon,e=n.id,r=n.className,c=n.extend,o=de(n,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),l=E.useRef("_".concat(ve()));return H(i,"".concat(e),{defIds:i.defIds,idSuffix:l.current},f({ref:t,className:a},o),c)});function H(n,t,i,e,r){return E.createElement(n.tag,f(f({key:t},le(n,i,r)),e),(ue(n,i).children||[]).map(function(c,o){return H(c,"".concat(t,"-").concat(n.tag,"-").concat(o),i,void 0,r)}))}function le(n,t,i){var e=f({},n.attrs);i!=null&&i.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=i.colorChannel1);var r=t.defIds;return!r||r.length===0||(n.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(c){var o=c[0],a=c[1];typeof a=="string"&&(e[o]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function ue(n,t){var i,e=t.defIds;return!e||e.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?f(f({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?f(f({},r),{attrs:f(f({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):n}function ve(){return Math.random().toString(36).substring(2,8)}B.displayName="UniverIcon";var _e={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"}}]},X=E.forwardRef(function(n,t){return E.createElement(B,Object.assign({},n,{id:"check-mark-single",ref:t,icon:_e}))});X.displayName="CheckMarkSingle";var he={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"}}]},$=E.forwardRef(function(n,t){return E.createElement(B,Object.assign({},n,{id:"close-single",ref:t,icon:he}))});$.displayName="CloseSingle";const T={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"},fe="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT";function ge(){const n=E.useRef(null),t=s.useDependency(U.IRenderManagerService),i=s.useDependency(V),e=s.useDependency(s.ICommandService);E.useEffect(()=>{const o=n.current;if(!o)return;const a=t.currentRender$.subscribe(g=>{var I;if(g!==h)return;const u=(I=t.getRenderById(h))==null?void 0:I.engine;u==null||u.setContainer(o)}),l=new ResizeObserver(()=>{const g=o.getBoundingClientRect();i.setPosition(g)});return l.observe(o),()=>{l.unobserve(o),a.unsubscribe()}},[]);function r(){e.executeCommand(w.id)}function c(){e.executeCommand(Z.id)}return y.jsxs("div",{className:T.zenEditor,children:[y.jsxs("div",{className:T.zenEditorIconWrapper,children:[y.jsx("span",{className:W(T.zenEditorIconContainer,T.zenEditorIconError),onClick:r,children:y.jsx($,{style:{fontSize:"22px"}})}),y.jsx("span",{className:W(T.zenEditorIconContainer,T.zenEditorIconSuccess),onClick:c,children:y.jsx(X,{style:{fontSize:"22px"}})})]}),y.jsx("div",{className:T.zenEditorCanvasContainer,ref:n})]})}const pe={id:Z.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:n=>G(n),binding:v.KeyCode.ENTER|v.MetaKeys.ALT},Se={id:w.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:n=>G(n),binding:v.KeyCode.ESC};function G(n){return n.getContextValue(s.FOCUSING_DOC)&&n.getContextValue(s.FOCUSING_UNIVER_EDITOR)&&n.getContextValue(s.EDITOR_ACTIVATED)&&!n.getContextValue(s.FOCUSING_EDITOR_STANDALONE)}var Ie=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,me=(n,t,i,e)=>{for(var r=e>1?void 0:e?Ee(t,i):t,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&Ie(t,i,r),r},x=(n,t)=>(i,e)=>t(i,e,n);const Ce={};let M=class extends s.Disposable{constructor(n,t,i,e,r,c){super(),this._config=n,this._injector=t,this._zenZoneService=i,this._commandService=e,this._menuService=r,this._shortcutService=c,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(fe,ge))}_initCommands(){[D,w,Z].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initMenus(){const{menu:n={}}=this._config;[ne].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t),n))})}_initShortcuts(){[pe,Se].forEach(n=>{this.disposeWithMe(this._shortcutService.registerShortcut(n))})}};M=me([s.OnLifecycle(s.LifecycleStages.Rendered,M),x(1,s.Inject(s.Injector)),x(2,v.IZenZoneService),x(3,s.ICommandService),x(4,v.IMenuService),x(5,v.IShortcutService)],M);var Oe=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Te=(n,t,i,e)=>{for(var r=e>1?void 0:e?ye(t,i):t,c=n.length-1,o;c>=0;c--)(o=n[c])&&(r=(e?o(t,i,r):o(r))||r);return e&&r&&Oe(t,i,r),r},q=(n,t)=>(i,e)=>t(i,e,n);d.UniverSheetsZenEditorPlugin=(A=class extends s.Plugin{constructor(t={},i,e){super(),this._config=t,this._injector=i,this._localeService=e,this._initializeDependencies(this._injector),this._config=s.Tools.deepMerge({},Ce,this._config)}_initializeDependencies(t){[[M,{useFactory:()=>this._injector.createInstance(M,this._config)}],[P],[V,{useClass:J}]].forEach(e=>t.add(e))}},N(A,"pluginName","zen-editor"),N(A,"type",s.UniverInstanceType.UNIVER_DOC),A),d.UniverSheetsZenEditorPlugin=Te([q(1,s.Inject(s.Injector)),q(2,s.Inject(s.LocaleService))],d.UniverSheetsZenEditorPlugin),d.CancelZenEditCommand=w,d.ConfirmZenEditCommand=Z,d.OpenZenEditorOperation=D,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-zen-editor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4-alpha.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Zen Editor plugin for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -50,38 +50,36 @@
|
|
|
50
50
|
"lib"
|
|
51
51
|
],
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@wendellhu/redi": "0.15.5",
|
|
54
53
|
"clsx": ">=2.0.0",
|
|
55
54
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
56
55
|
"rxjs": ">=7.0.0",
|
|
57
|
-
"@univerjs/docs": "0.2.
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/sheets-ui": "0.2.
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/ui": "0.2.
|
|
56
|
+
"@univerjs/docs": "0.2.4-alpha.0",
|
|
57
|
+
"@univerjs/core": "0.2.4-alpha.0",
|
|
58
|
+
"@univerjs/engine-render": "0.2.4-alpha.0",
|
|
59
|
+
"@univerjs/sheets-ui": "0.2.4-alpha.0",
|
|
60
|
+
"@univerjs/sheets": "0.2.4-alpha.0",
|
|
61
|
+
"@univerjs/ui": "0.2.4-alpha.0"
|
|
63
62
|
},
|
|
64
63
|
"dependencies": {
|
|
65
|
-
"@univerjs/icons": "^0.1.
|
|
66
|
-
"@univerjs/sheets": "0.2.
|
|
64
|
+
"@univerjs/icons": "^0.1.64",
|
|
65
|
+
"@univerjs/sheets": "0.2.4-alpha.0"
|
|
67
66
|
},
|
|
68
67
|
"devDependencies": {
|
|
69
|
-
"@wendellhu/redi": "0.15.5",
|
|
70
68
|
"clsx": "^2.1.1",
|
|
71
69
|
"less": "^4.2.0",
|
|
72
70
|
"react": "18.3.1",
|
|
73
71
|
"rxjs": "^7.8.1",
|
|
74
72
|
"typescript": "^5.5.3",
|
|
75
|
-
"vite": "^5.3.
|
|
76
|
-
"vitest": "^
|
|
77
|
-
"@univerjs/
|
|
78
|
-
"@univerjs/
|
|
79
|
-
"@univerjs/docs": "0.2.
|
|
80
|
-
"@univerjs/engine-render": "0.2.
|
|
81
|
-
"@univerjs/shared": "0.2.
|
|
82
|
-
"@univerjs/sheets": "0.2.
|
|
83
|
-
"@univerjs/ui": "0.2.
|
|
84
|
-
"@univerjs/sheets
|
|
73
|
+
"vite": "^5.3.4",
|
|
74
|
+
"vitest": "^2.0.3",
|
|
75
|
+
"@univerjs/design": "0.2.4-alpha.0",
|
|
76
|
+
"@univerjs/core": "0.2.4-alpha.0",
|
|
77
|
+
"@univerjs/docs": "0.2.4-alpha.0",
|
|
78
|
+
"@univerjs/engine-render": "0.2.4-alpha.0",
|
|
79
|
+
"@univerjs/shared": "0.2.4-alpha.0",
|
|
80
|
+
"@univerjs/sheets-ui": "0.2.4-alpha.0",
|
|
81
|
+
"@univerjs/ui": "0.2.4-alpha.0",
|
|
82
|
+
"@univerjs/sheets": "0.2.4-alpha.0"
|
|
85
83
|
},
|
|
86
84
|
"univerSpace": {
|
|
87
85
|
".": {
|