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