@univerjs/sheets-zen-editor 0.2.3 → 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/lib/cjs/index.js +2 -2
- package/lib/es/index.js +142 -139
- 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/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/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 w,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { IZenZoneService as x, KeyCode as A, MenuGroup as De, MenuItemType as we, MenuPosition as Ue, MetaKeys as je, 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
10
|
import { WorkbookEditablePermission as ke, WorksheetEditPermission as $e, WorksheetSetCellValuePermission as Be, WorksheetSetCellStylePermission as Fe, RangeProtectionPermissionEditPoint as We } from "@univerjs/sheets";
|
|
12
|
-
import Ye, { forwardRef as
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
const B = {
|
|
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
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,20 +34,20 @@ 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
41
|
for (var r = n > 1 ? void 0 : n ? Ge(e, i) : e, o = t.length - 1, s; o >= 0; o--)
|
|
44
42
|
(s = t[o]) && (r = (n ? s(e, i, r) : s(r)) || r);
|
|
45
43
|
return n && r && Xe(e, i, r), r;
|
|
46
|
-
},
|
|
44
|
+
}, m = (t, e) => (i, n) => e(i, n, t);
|
|
47
45
|
const _ = "__defaultDocumentZenEditorSpecialUnitId_20231218__";
|
|
48
|
-
let N = class extends
|
|
49
|
-
constructor(e, i, n, r, o, s, c, a
|
|
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();
|
|
@@ -58,7 +56,7 @@ let N = class extends fe {
|
|
|
58
56
|
const e = {
|
|
59
57
|
id: _,
|
|
60
58
|
body: {
|
|
61
|
-
dataStream: `${
|
|
59
|
+
dataStream: `${ve}`,
|
|
62
60
|
textRuns: [],
|
|
63
61
|
customBlocks: [],
|
|
64
62
|
paragraphs: [
|
|
@@ -72,7 +70,7 @@ let N = class extends fe {
|
|
|
72
70
|
width: 595,
|
|
73
71
|
height: 842
|
|
74
72
|
},
|
|
75
|
-
documentFlavor:
|
|
73
|
+
documentFlavor: pe.MODERN,
|
|
76
74
|
marginTop: 50,
|
|
77
75
|
marginBottom: 50,
|
|
78
76
|
marginRight: 40,
|
|
@@ -85,7 +83,7 @@ let N = class extends fe {
|
|
|
85
83
|
drawings: {},
|
|
86
84
|
drawingsOrder: []
|
|
87
85
|
};
|
|
88
|
-
return this._univerInstanceService.createUnit(
|
|
86
|
+
return this._univerInstanceService.createUnit(T.UNIVER_DOC, e);
|
|
89
87
|
}
|
|
90
88
|
// Listen to changes in the size of the zen editor container to set the size of the editor.
|
|
91
89
|
_syncZenEditorSize() {
|
|
@@ -96,28 +94,32 @@ let N = class extends fe {
|
|
|
96
94
|
const i = Me(_, this._renderManagerService), n = this._univerInstanceService.getUniverDocInstance(_);
|
|
97
95
|
if (i == null || n == null)
|
|
98
96
|
return;
|
|
99
|
-
const { width: r, height: o } = e, { engine: s } = i, c = (a = this._renderManagerService.getRenderById(_)) == null ? void 0 : a.with(
|
|
97
|
+
const { width: r, height: o } = e, { engine: s } = i, c = (a = this._renderManagerService.getRenderById(_)) == null ? void 0 : a.with(X).getSkeleton();
|
|
100
98
|
requestIdleCallback(() => {
|
|
101
99
|
s.resizeBySize(r, o), this._calculatePagePosition(i), c && this._textSelectionManagerService.refreshSelection();
|
|
102
100
|
});
|
|
103
101
|
});
|
|
104
102
|
}
|
|
105
103
|
_handleOpenZenEditor() {
|
|
106
|
-
|
|
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({
|
|
107
108
|
visible: !0,
|
|
108
|
-
eventType:
|
|
109
|
+
eventType: L.PointerDown,
|
|
110
|
+
unitId: (o = e == null ? void 0 : e.getUnitId()) != null ? o : ""
|
|
109
111
|
});
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
112
|
+
const n = this._editorBridgeService.getLatestEditCellState();
|
|
113
|
+
if (n == null)
|
|
112
114
|
return;
|
|
113
|
-
this._editorSyncHandler(
|
|
114
|
-
const
|
|
115
|
+
this._editorSyncHandler(n);
|
|
116
|
+
const r = [
|
|
115
117
|
{
|
|
116
118
|
startOffset: 0,
|
|
117
119
|
endOffset: 0
|
|
118
120
|
}
|
|
119
121
|
];
|
|
120
|
-
this._textSelectionManagerService.replaceTextRanges(
|
|
122
|
+
this._textSelectionManagerService.replaceTextRanges(r);
|
|
121
123
|
}
|
|
122
124
|
_editorSyncHandler(e) {
|
|
123
125
|
var s, c;
|
|
@@ -125,31 +127,31 @@ let N = class extends fe {
|
|
|
125
127
|
let o = [];
|
|
126
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));
|
|
127
129
|
}
|
|
128
|
-
_syncContentAndRender(e, i, n, r = [], o = [], s = {}, c = []) {
|
|
129
|
-
var
|
|
130
|
-
const
|
|
130
|
+
_syncContentAndRender(e, i, n, r = [], o = [], s = {}, c = [], a = []) {
|
|
131
|
+
var p;
|
|
132
|
+
const u = [
|
|
131
133
|
_,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
], d = (
|
|
135
|
-
if (
|
|
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)
|
|
136
138
|
return;
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
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());
|
|
141
143
|
}
|
|
142
144
|
_calculatePagePosition(e) {
|
|
143
|
-
const { document: i, scene: n, docBackground: r } = e, o = n == null ? void 0 : n.getParent(), { width: s, height: c, pageMarginLeft: a, pageMarginTop:
|
|
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;
|
|
144
146
|
if (o == null || s === Number.POSITIVE_INFINITY || c === Number.POSITIVE_INFINITY)
|
|
145
147
|
return;
|
|
146
|
-
const { width:
|
|
147
|
-
let
|
|
148
|
-
const { scaleX:
|
|
149
|
-
|
|
150
|
-
const P = n.getViewport(
|
|
151
|
-
if (
|
|
152
|
-
const ue = P.transScroll2ViewportScrollValue(
|
|
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;
|
|
153
155
|
P.scrollTo({
|
|
154
156
|
x: ue
|
|
155
157
|
});
|
|
@@ -157,7 +159,7 @@ let N = class extends fe {
|
|
|
157
159
|
return this;
|
|
158
160
|
}
|
|
159
161
|
_commandExecutedListener() {
|
|
160
|
-
const e = [
|
|
162
|
+
const e = [$.id];
|
|
161
163
|
this.disposeWithMe(
|
|
162
164
|
this._commandService.onCommandExecuted((n) => {
|
|
163
165
|
e.includes(n.id) && this._handleOpenZenEditor();
|
|
@@ -169,10 +171,10 @@ let N = class extends fe {
|
|
|
169
171
|
if (i.includes(n.id)) {
|
|
170
172
|
const r = n.params, { unitId: o } = r;
|
|
171
173
|
if (o === _) {
|
|
172
|
-
const s = this._univerInstanceService.getUniverDocInstance(o), c = s == null ? void 0 : s.getBody(), a = c == null ? void 0 : c.dataStream,
|
|
173
|
-
if (this._editorBridgeService.changeEditorDirty(!0), a == null ||
|
|
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)
|
|
174
176
|
return;
|
|
175
|
-
this._syncContentAndRender(
|
|
177
|
+
this._syncContentAndRender(K, a, u, d, g, h, v, l);
|
|
176
178
|
}
|
|
177
179
|
}
|
|
178
180
|
})
|
|
@@ -183,51 +185,52 @@ let N = class extends fe {
|
|
|
183
185
|
}
|
|
184
186
|
};
|
|
185
187
|
N = qe([
|
|
186
|
-
ee
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
v(8, T(xe))
|
|
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))
|
|
196
197
|
], N);
|
|
197
|
-
const
|
|
198
|
+
const F = {
|
|
198
199
|
id: "zen-editor.command.cancel-zen-edit",
|
|
199
200
|
type: w.COMMAND,
|
|
200
201
|
handler: async (t) => {
|
|
201
|
-
const e = t.get(x), i = t.get(
|
|
202
|
+
const e = t.get(x), i = t.get(Z), n = t.get(D);
|
|
202
203
|
i.isVisible().visible && i.changeVisible({
|
|
203
204
|
visible: !1,
|
|
204
|
-
eventType:
|
|
205
|
-
keycode:
|
|
205
|
+
eventType: L.Keyboard,
|
|
206
|
+
keycode: V.ESC,
|
|
207
|
+
unitId: ""
|
|
206
208
|
}), e.close();
|
|
207
|
-
const o = n.getCurrentUnitForType(
|
|
209
|
+
const o = n.getCurrentUnitForType(T.UNIVER_SHEET);
|
|
208
210
|
return o ? (n.focusUnit(o.getUnitId()), i.refreshEditCellState(), !0) : !1;
|
|
209
211
|
}
|
|
210
|
-
},
|
|
212
|
+
}, W = {
|
|
211
213
|
id: "zen-editor.command.confirm-zen-edit",
|
|
212
214
|
type: w.COMMAND,
|
|
213
215
|
handler: async (t) => {
|
|
214
|
-
const e = t.get(x), i = t.get(
|
|
216
|
+
const e = t.get(x), i = t.get(Z), n = t.get(D);
|
|
215
217
|
i.isVisible().visible && i.changeVisible({
|
|
216
218
|
visible: !1,
|
|
217
|
-
eventType:
|
|
219
|
+
eventType: L.PointerDown,
|
|
220
|
+
unitId: ""
|
|
218
221
|
}), e.close();
|
|
219
|
-
const o = n.getCurrentUnitForType(
|
|
222
|
+
const o = n.getCurrentUnitForType(T.UNIVER_SHEET);
|
|
220
223
|
return o ? (n.focusUnit(o.getUnitId()), i.refreshEditCellState(), !0) : !1;
|
|
221
224
|
}
|
|
222
225
|
};
|
|
223
226
|
function Je(t) {
|
|
224
227
|
return {
|
|
225
|
-
id:
|
|
226
|
-
group:
|
|
228
|
+
id: $.id,
|
|
229
|
+
group: Ue.CONTEXT_MENU_OTHERS,
|
|
227
230
|
type: we.BUTTON,
|
|
228
231
|
title: "rightClick.zenEditor",
|
|
229
232
|
icon: "AmplifySingle",
|
|
230
|
-
positions: [
|
|
233
|
+
positions: [De.CONTEXT_MENU],
|
|
231
234
|
disabled$: Pe(t, { workbookTypes: [ke], worksheetTypes: [$e, Be, Fe], rangeTypes: [We] })
|
|
232
235
|
};
|
|
233
236
|
}
|
|
@@ -253,7 +256,7 @@ M.Fragment = tt;
|
|
|
253
256
|
M.jsx = se;
|
|
254
257
|
M.jsxs = se;
|
|
255
258
|
re.exports = M;
|
|
256
|
-
var
|
|
259
|
+
var I = re.exports, f = function() {
|
|
257
260
|
return f = Object.assign || function(t) {
|
|
258
261
|
for (var e, i = 1, n = arguments.length; i < n; i++) {
|
|
259
262
|
e = arguments[i];
|
|
@@ -268,12 +271,12 @@ var E = re.exports, f = function() {
|
|
|
268
271
|
for (var r = 0, n = Object.getOwnPropertySymbols(t); r < n.length; r++)
|
|
269
272
|
e.indexOf(n[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[r]) && (i[n[r]] = t[n[r]]);
|
|
270
273
|
return i;
|
|
271
|
-
},
|
|
274
|
+
}, Y = A(function(t, e) {
|
|
272
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()));
|
|
273
276
|
return oe(i, "".concat(n), { defIds: i.defIds, idSuffix: a.current }, f({ ref: e, className: c }, s), o);
|
|
274
277
|
});
|
|
275
278
|
function oe(t, e, i, n, r) {
|
|
276
|
-
return
|
|
279
|
+
return k(t.tag, f(f({ key: e }, ot(t, i, r)), n), (ct(t, i).children || []).map(function(o, s) {
|
|
277
280
|
return oe(o, "".concat(e, "-").concat(t.tag, "-").concat(s), i, void 0, r);
|
|
278
281
|
}));
|
|
279
282
|
}
|
|
@@ -295,24 +298,24 @@ function ct(t, e) {
|
|
|
295
298
|
function at() {
|
|
296
299
|
return Math.random().toString(36).substring(2, 8);
|
|
297
300
|
}
|
|
298
|
-
|
|
299
|
-
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 =
|
|
300
|
-
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, {
|
|
301
304
|
id: "check-mark-single",
|
|
302
305
|
ref: e,
|
|
303
306
|
icon: dt
|
|
304
307
|
}));
|
|
305
308
|
});
|
|
306
309
|
ce.displayName = "CheckMarkSingle";
|
|
307
|
-
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 =
|
|
308
|
-
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, {
|
|
309
312
|
id: "close-single",
|
|
310
313
|
ref: e,
|
|
311
314
|
icon: lt
|
|
312
315
|
}));
|
|
313
316
|
});
|
|
314
317
|
ae.displayName = "CloseSingle";
|
|
315
|
-
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",
|
|
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 = {
|
|
316
319
|
zenEditor: ut,
|
|
317
320
|
zenEditorIconWrapper: ht,
|
|
318
321
|
zenEditorIconContainer: _t,
|
|
@@ -321,76 +324,76 @@ const ut = "univer-zen-editor", ht = "univer-zen-editor-icon-wrapper", _t = "uni
|
|
|
321
324
|
zenEditorCanvasContainer: vt
|
|
322
325
|
}, pt = "ZEN_EDITOR_PLUGIN_", mt = `${pt}ZEN_EDITOR_COMPONENT`;
|
|
323
326
|
function St() {
|
|
324
|
-
const t = ie(null), e =
|
|
327
|
+
const t = ie(null), e = U(ne), i = U(B), n = U(j);
|
|
325
328
|
He(() => {
|
|
326
329
|
const s = t.current;
|
|
327
330
|
if (!s)
|
|
328
331
|
return;
|
|
329
|
-
const c = e.currentRender$.subscribe((
|
|
330
|
-
var
|
|
331
|
-
if (
|
|
332
|
+
const c = e.currentRender$.subscribe((u) => {
|
|
333
|
+
var g;
|
|
334
|
+
if (u !== _)
|
|
332
335
|
return;
|
|
333
|
-
const
|
|
334
|
-
|
|
336
|
+
const d = (g = e.getRenderById(_)) == null ? void 0 : g.engine;
|
|
337
|
+
d == null || d.setContainer(s);
|
|
335
338
|
}), a = new ResizeObserver(() => {
|
|
336
|
-
const
|
|
337
|
-
i.setPosition(
|
|
339
|
+
const u = s.getBoundingClientRect();
|
|
340
|
+
i.setPosition(u);
|
|
338
341
|
});
|
|
339
342
|
return a.observe(s), () => {
|
|
340
343
|
a.unobserve(s), c.unsubscribe();
|
|
341
344
|
};
|
|
342
345
|
}, []);
|
|
343
346
|
function r() {
|
|
344
|
-
n.executeCommand(
|
|
347
|
+
n.executeCommand(F.id);
|
|
345
348
|
}
|
|
346
349
|
function o() {
|
|
347
|
-
n.executeCommand(
|
|
350
|
+
n.executeCommand(W.id);
|
|
348
351
|
}
|
|
349
|
-
return /* @__PURE__ */
|
|
350
|
-
/* @__PURE__ */
|
|
351
|
-
/* @__PURE__ */
|
|
352
|
+
return /* @__PURE__ */ I.jsxs("div", { className: C.zenEditor, children: [
|
|
353
|
+
/* @__PURE__ */ I.jsxs("div", { className: C.zenEditorIconWrapper, children: [
|
|
354
|
+
/* @__PURE__ */ I.jsx(
|
|
352
355
|
"span",
|
|
353
356
|
{
|
|
354
|
-
className:
|
|
357
|
+
className: G(C.zenEditorIconContainer, C.zenEditorIconError),
|
|
355
358
|
onClick: r,
|
|
356
|
-
children: /* @__PURE__ */
|
|
359
|
+
children: /* @__PURE__ */ I.jsx(ae, { style: { fontSize: "22px" } })
|
|
357
360
|
}
|
|
358
361
|
),
|
|
359
|
-
/* @__PURE__ */
|
|
362
|
+
/* @__PURE__ */ I.jsx(
|
|
360
363
|
"span",
|
|
361
364
|
{
|
|
362
|
-
className:
|
|
365
|
+
className: G(C.zenEditorIconContainer, C.zenEditorIconSuccess),
|
|
363
366
|
onClick: o,
|
|
364
|
-
children: /* @__PURE__ */
|
|
367
|
+
children: /* @__PURE__ */ I.jsx(ce, { style: { fontSize: "22px" } })
|
|
365
368
|
}
|
|
366
369
|
)
|
|
367
370
|
] }),
|
|
368
|
-
/* @__PURE__ */
|
|
371
|
+
/* @__PURE__ */ I.jsx("div", { className: C.zenEditorCanvasContainer, ref: t })
|
|
369
372
|
] });
|
|
370
373
|
}
|
|
371
374
|
const Et = {
|
|
372
|
-
id:
|
|
375
|
+
id: W.id,
|
|
373
376
|
description: "shortcut.sheet.zen-edit-confirm",
|
|
374
377
|
group: "4_sheet-edit",
|
|
375
378
|
preconditions: (t) => de(t),
|
|
376
|
-
binding:
|
|
379
|
+
binding: V.ENTER | je.ALT
|
|
377
380
|
}, It = {
|
|
378
|
-
id:
|
|
381
|
+
id: F.id,
|
|
379
382
|
description: "shortcut.sheet.zen-edit-cancel",
|
|
380
383
|
group: "4_sheet-edit",
|
|
381
384
|
preconditions: (t) => de(t),
|
|
382
|
-
binding:
|
|
385
|
+
binding: V.ESC
|
|
383
386
|
};
|
|
384
387
|
function de(t) {
|
|
385
|
-
return t.getContextValue(
|
|
388
|
+
return t.getContextValue(Se) && t.getContextValue(Ee) && t.getContextValue(Ie) && !t.getContextValue(Ce);
|
|
386
389
|
}
|
|
387
|
-
var Ct = Object.defineProperty, Ot = Object.getOwnPropertyDescriptor,
|
|
390
|
+
var Ct = Object.defineProperty, Ot = Object.getOwnPropertyDescriptor, Rt = (t, e, i, n) => {
|
|
388
391
|
for (var r = n > 1 ? void 0 : n ? Ot(e, i) : e, o = t.length - 1, s; o >= 0; o--)
|
|
389
392
|
(s = t[o]) && (r = (n ? s(e, i, r) : s(r)) || r);
|
|
390
393
|
return n && r && Ct(e, i, r), r;
|
|
391
|
-
},
|
|
392
|
-
const
|
|
393
|
-
let
|
|
394
|
+
}, R = (t, e) => (i, n) => e(i, n, t);
|
|
395
|
+
const yt = {};
|
|
396
|
+
let y = class extends Oe {
|
|
394
397
|
constructor(t, e, i, n, r, o) {
|
|
395
398
|
super(), this._config = t, this._injector = e, this._zenZoneService = i, this._commandService = n, this._menuService = r, this._shortcutService = o, this._initialize();
|
|
396
399
|
}
|
|
@@ -401,7 +404,7 @@ let b = class extends Ce {
|
|
|
401
404
|
this.disposeWithMe(this._zenZoneService.set(mt, St));
|
|
402
405
|
}
|
|
403
406
|
_initCommands() {
|
|
404
|
-
[
|
|
407
|
+
[$, F, W].forEach((t) => {
|
|
405
408
|
this.disposeWithMe(this._commandService.registerCommand(t));
|
|
406
409
|
});
|
|
407
410
|
}
|
|
@@ -420,43 +423,43 @@ let b = class extends Ce {
|
|
|
420
423
|
});
|
|
421
424
|
}
|
|
422
425
|
};
|
|
423
|
-
|
|
424
|
-
ee
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
],
|
|
431
|
-
var Tt = Object.defineProperty,
|
|
432
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
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--)
|
|
433
436
|
(s = t[o]) && (r = (n ? s(e, i, r) : s(r)) || r);
|
|
434
437
|
return n && r && Tt(e, i, r), r;
|
|
435
|
-
},
|
|
436
|
-
let
|
|
438
|
+
}, q = (t, e) => (i, n) => e(i, n, t), b;
|
|
439
|
+
let J = (b = class extends Re {
|
|
437
440
|
constructor(t = {}, e, i) {
|
|
438
|
-
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);
|
|
439
442
|
}
|
|
440
443
|
_initializeDependencies(t) {
|
|
441
444
|
[
|
|
442
445
|
[
|
|
443
|
-
|
|
446
|
+
y,
|
|
444
447
|
{
|
|
445
|
-
useFactory: () => this._injector.createInstance(
|
|
448
|
+
useFactory: () => this._injector.createInstance(y, this._config)
|
|
446
449
|
}
|
|
447
450
|
],
|
|
448
451
|
[N],
|
|
449
|
-
[
|
|
452
|
+
[B, { useClass: Ke }]
|
|
450
453
|
].forEach((i) => t.add(i));
|
|
451
454
|
}
|
|
452
|
-
},
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
],
|
|
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);
|
|
457
460
|
export {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
461
|
+
F as CancelZenEditCommand,
|
|
462
|
+
W as ConfirmZenEditCommand,
|
|
463
|
+
$ as OpenZenEditorOperation,
|
|
464
|
+
J as UniverSheetsZenEditorPlugin
|
|
462
465
|
};
|
|
@@ -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/
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/sheets": "0.2.
|
|
61
|
-
"@univerjs/sheets
|
|
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/design": "0.2.
|
|
78
|
-
"@univerjs/
|
|
79
|
-
"@univerjs/
|
|
80
|
-
"@univerjs/engine-render": "0.2.
|
|
81
|
-
"@univerjs/shared": "0.2.
|
|
82
|
-
"@univerjs/sheets-ui": "0.2.
|
|
83
|
-
"@univerjs/
|
|
84
|
-
"@univerjs/
|
|
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
|
".": {
|