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