@univerjs/sheets-zen-editor 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +274 -298
- package/lib/types/controllers/zen-editor.controller.d.ts +1 -0
- package/lib/umd/index.js +2 -2
- package/package.json +24 -20
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://npmjs.org/packages/@univerjs/sheets-zen-editor)
|
|
4
4
|
[](https://img.shields.io/npm/l/@univerjs/sheets-zen-editor)
|
|
5
|
+

|
|
6
|
+

|
|
5
7
|
|
|
6
8
|
## Introduction
|
|
7
9
|
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var ee=Object.defineProperty;var te=(i,t,n)=>t in i?ee(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n;var E=(i,t,n)=>(te(i,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),p=require("@wendellhu/redi"),C=require("@univerjs/docs"),z=require("@univerjs/engine-render"),N=require("@univerjs/sheets-ui"),v=require("@univerjs/ui"),W=require("rxjs"),g=require("react"),P=require("@wendellhu/redi/react-bindings"),V=require("clsx"),L={id:"zen-editor.operation.open-zen-editor",type:a.CommandType.OPERATION,handler:i=>!0};class ne{constructor(){E(this,"_position",null);E(this,"_position$",new W.BehaviorSubject(null));E(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 w=p.createIdentifier("univer.sheet-zen-editor-manager.service");var ie=Object.defineProperty,re=Object.getOwnPropertyDescriptor,oe=(i,t,n,e)=>{for(var r=e>1?void 0:e?re(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&ie(t,n,r),r},S=(i,t)=>(n,e)=>t(n,e,i);const h="__defaultDocumentZenEditorSpecialUnitId_20231218__";let b=class extends a.RxDisposable{constructor(t,n,e,r,o,s,c,d,l,u){super();E(this,"_zenEditorInitialState",!1);this._currentUniverService=t,this._zenEditorManagerService=n,this._renderManagerService=e,this._commandService=r,this._zenZoneService=o,this._editorBridgeService=s,this._undoRedoService=c,this._textSelectionManagerService=d,this._docSkeletonManagerService=l,this._docViewModelManagerService=u,this._initialize()}_initialize(){this._syncZenEditorSize(),this._commandExecutedListener()}_createZenEditorInstance(){const t={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}}};this._currentUniverService.createDoc(t)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(W.takeUntil(this.dispose$)).subscribe(t=>{var d;if(t==null)return;const n=N.getEditorObject(h,this._renderManagerService),e=this._currentUniverService.getUniverDocInstance(h);if(n==null||e==null)return;const{width:r,height:o}=t,{engine:s}=n,c=(d=this._docSkeletonManagerService.getSkeletonByUnitId(h))==null?void 0:d.skeleton;requestIdleCallback(()=>{s.resizeBySize(r,o),this._calculatePagePosition(n),c&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){this._zenEditorInitialState||(this._createZenEditorInstance(),this._zenEditorInitialState=!0),this._zenZoneService.open(),this._undoRedoService.clearUndoRedo(h),this._currentUniverService.focusUniverInstance(h),this._currentUniverService.setCurrentUniverDocInstance(h),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:z.DeviceInputEventType.PointerDown});const n=this._editorBridgeService.getLatestEditCellState();if(n==null)return;this._editorSyncHandler(n);const e=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(e)}_editorSyncHandler(t){var s,c;const n=(s=t.documentLayoutObject.documentModel)==null?void 0:s.getBody(),e=n==null?void 0:n.dataStream,r=n==null?void 0:n.paragraphs;let o=[];e==null||r==null||((c=n==null?void 0:n.textRuns)!=null&&c.length&&(o=n==null?void 0:n.textRuns),this._syncContentAndRender(h,e,r,o))}_syncContentAndRender(t,n,e,r=[]){const o=[h,a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,a.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=this._docSkeletonManagerService.getSkeletonByUnitId(t),c=this._currentUniverService.getUniverDocInstance(t),d=this._docViewModelManagerService.getViewModel(t);if(c==null||d==null||s==null)return;const l=c.getBody();l.dataStream=n,l.paragraphs=e,t===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(t)&&f.document.makeDirty())}_calculatePagePosition(t){const{document:n,scene:e}=t,r=e==null?void 0:e.getParent(),{width:o,height:s,pageMarginLeft:c,pageMarginTop:d}=n;if(r==null||o===Number.POSITIVE_INFINITY||s===Number.POSITIVE_INFINITY)return;const{width:l,height:u}=r;let f=0,D=0,M=0,U=0,R=Number.POSITIVE_INFINITY;const{scaleX:O,scaleY:J}=e.getAncestorScale();l>(o+c*2)*O?(f=l/2-o*O/2,f/=O,M=(l-c*2)/O,R=0):(f=c,M=o+c*2,R=(M-l/O)/2),u>s?(D=u/2-s/2,U=(u-d*2)/J):(D=d,U=s+d*2),e.resize(M,U+200),n.translate(f,D);const j=e.getViewport(C.VIEWPORT_KEY.VIEW_MAIN);if(R!==Number.POSITIVE_INFINITY&&j!=null){const Q=j.getBarScroll(R,0).x;j.scrollTo({x:Q})}return this}_commandExecutedListener(){const t=[L.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{t.includes(e.id)&&this._handleOpenZenEditor()}));const n=[C.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(n.includes(e.id)){const r=e.params,{unitId:o}=r;if(o===h){const s=this._currentUniverService.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._currentUniverService,this._renderManagerService)}};b=oe([a.OnLifecycle(a.LifecycleStages.Steady,b),S(0,a.IUniverInstanceService),S(1,w),S(2,z.IRenderManagerService),S(3,a.ICommandService),S(4,v.IZenZoneService),S(5,N.IEditorBridgeService),S(6,a.IUndoRedoService),S(7,p.Inject(C.TextSelectionManagerService)),S(8,p.Inject(C.DocSkeletonManagerService)),S(9,p.Inject(C.DocViewModelManagerService))],b);const A={id:"zen-editor.command.cancel-zen-edit",type:a.CommandType.COMMAND,handler:async i=>{const t=i.get(v.IZenZoneService),n=i.get(N.IEditorBridgeService),e=i.get(a.IUniverInstanceService);n.isVisible().visible&&n.changeVisible({visible:!1,eventType:z.DeviceInputEventType.Keyboard,keycode:v.KeyCode.ESC}),t.close();const o=e.getCurrentUniverSheetInstance();return e.focusUniverInstance(o.getUnitId()),n.refreshEditCellState(),!0}},$={id:"zen-editor.command.confirm-zen-edit",type:a.CommandType.COMMAND,handler:async i=>{const t=i.get(v.IZenZoneService),n=i.get(N.IEditorBridgeService),e=i.get(a.IUniverInstanceService);n.isVisible().visible&&n.changeVisible({visible:!1,eventType:z.DeviceInputEventType.PointerDown}),t.close();const o=e.getCurrentUniverSheetInstance();return e.focusUniverInstance(o.getUnitId()),n.refreshEditCellState(),!0}};function se(){return{id:L.id,group:v.MenuGroup.CONTEXT_MENU_OTHERS,type:v.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[v.MenuPosition.CONTEXT_MENU]}}var q={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
|
|
9
|
+
*/var ce=g,ae=Symbol.for("react.element"),de=Symbol.for("react.fragment"),le=Object.prototype.hasOwnProperty,ue=ce.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ve={key:!0,ref:!0,__self:!0,__source:!0};function F(i,t,n){var e,r={},o=null,s=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(s=t.ref);for(e in t)le.call(t,e)&&!ve.hasOwnProperty(e)&&(r[e]=t[e]);if(i&&i.defaultProps)for(e in t=i.defaultProps,t)r[e]===void 0&&(r[e]=t[e]);return{$$typeof:ae,type:i,key:o,ref:s,props:r,_owner:ue.current}}x.Fragment=de;x.jsx=F;x.jsxs=F;q.exports=x;var I=q.exports,_=function(){return _=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},_.apply(this,arguments)},he=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},B=g.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,o=i.extend,s=he(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),d=g.useRef("_".concat(Se()));return Y(n,"".concat(e),{defIds:n.defIds,idSuffix:d.current},_({ref:t,className:c},s),o)});function Y(i,t,n,e,r){return g.createElement(i.tag,_(_({key:t},_e(i,n,r)),e),(fe(i,n).children||[]).map(function(o,s){return Y(o,"".concat(t,"-").concat(i.tag,"-").concat(s),n,void 0,r)}))}function _e(i,t,n){var e=_({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function fe(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?_(_({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?_(_({},r),{attrs:_(_({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function Se(){return Math.random().toString(36).substring(2,8)}B.displayName="UniverIcon";var ge={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.44 3.57291C14.698 3.83093 14.698 4.24927 14.44 4.50729L6.44342 12.5037C6.28721 12.6599 6.03395 12.6599 5.87774 12.5037L1.55992 8.18578C1.3019 7.92776 1.3019 7.50942 1.55993 7.2514C1.81795 6.99338 2.23629 6.99338 2.49431 7.25141L6.01916 10.7763C6.09727 10.8544 6.2239 10.8544 6.30201 10.7763L13.5056 3.57291C13.7636 3.31489 14.1819 3.31489 14.44 3.57291Z",fillRule:"evenodd",clipRule:"evenodd"}}]},K=g.forwardRef(function(i,t){return g.createElement(B,Object.assign({},i,{id:"check-mark-single",ref:t,icon:ge}))});K.displayName="CheckMarkSingle";const pe=K;var Ie={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.57061 3.65132C4.31677 3.39748 3.90521 3.39748 3.65137 3.65132C3.39753 3.90516 3.39753 4.31672 3.65137 4.57056L7.08079 7.99998L3.65123 11.4295C3.39739 11.6834 3.39739 12.0949 3.65123 12.3488C3.90507 12.6026 4.31662 12.6026 4.57047 12.3488L8.00003 8.91921L11.4295 12.3487C11.6834 12.6026 12.0949 12.6026 12.3488 12.3487C12.6026 12.0949 12.6026 11.6833 12.3488 11.4295L8.91927 7.99998L12.3486 4.57061C12.6025 4.31677 12.6025 3.90521 12.3486 3.65137C12.0948 3.39753 11.6832 3.39753 11.4294 3.65137L8.00003 7.08074L4.57061 3.65132Z"}}]},H=g.forwardRef(function(i,t){return g.createElement(B,Object.assign({},i,{id:"close-single",ref:t,icon:Ie}))});H.displayName="CloseSingle";const me=H,Ee="univer-zen-editor",Ce="univer-zen-editor-icon-wrapper",Oe="univer-zen-editor-icon-container",ye="univer-zen-editor-icon-success",ze="univer-zen-editor-icon-error",Me="univer-zen-editor-canvas-container",m={zenEditor:Ee,zenEditorIconWrapper:Ce,zenEditorIconContainer:Oe,zenEditorIconSuccess:ye,zenEditorIconError:ze,zenEditorCanvasContainer:Me},Re="ZEN_EDITOR_PLUGIN_",be=`${Re}ZEN_EDITOR_COMPONENT`;function Te(){const i=g.useRef(null),t=P.useDependency(z.IRenderManagerService),n=P.useDependency(w),e=P.useDependency(a.ICommandService);g.useEffect(()=>{const s=i.current;if(!s)return;const c=t.currentRender$.subscribe(l=>{var f;if(l!==h)return;const u=(f=t.getRenderById(h))==null?void 0:f.engine;u==null||u.setContainer(s)}),d=new ResizeObserver(()=>{const l=s.getBoundingClientRect();n.setPosition(l)});return d.observe(s),()=>{d.unobserve(s),c.unsubscribe()}},[]);function r(){e.executeCommand(A.id)}function o(){e.executeCommand($.id)}return I.jsxs("div",{className:m.zenEditor,children:[I.jsxs("div",{className:m.zenEditorIconWrapper,children:[I.jsx("span",{className:V(m.zenEditorIconContainer,m.zenEditorIconError),onClick:r,children:I.jsx(me,{style:{fontSize:"22px"}})}),I.jsx("span",{className:V(m.zenEditorIconContainer,m.zenEditorIconSuccess),onClick:o,children:I.jsx(pe,{style:{fontSize:"22px"}})})]}),I.jsx("div",{className:m.zenEditorCanvasContainer,ref:i})]})}const Ne={id:$.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:i=>X(i),binding:v.KeyCode.ENTER|v.MetaKeys.ALT},xe={id:A.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:i=>X(i),binding:v.KeyCode.ESC};function X(i){return i.getContextValue(a.FOCUSING_DOC)&&i.getContextValue(a.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(a.EDITOR_ACTIVATED)}var De=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,je=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ue(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&De(t,n,r),r},y=(i,t)=>(n,e)=>t(n,e,i);let T=class extends a.Disposable{constructor(i,t,n,e,r){super(),this._injector=i,this._zenZoneService=t,this._commandService=n,this._menuService=e,this._shortcutService=r,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(be,Te))}_initCommands(){[L,A,$].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initMenus(){[se].forEach(i=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)))})}_initShortcuts(){[Ne,xe].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}};T=je([a.OnLifecycle(a.LifecycleStages.Rendered,T),y(0,p.Inject(p.Injector)),y(1,v.IZenZoneService),y(2,a.ICommandService),y(3,v.IMenuService),y(4,v.IShortcutService)],T);const Pe={shortcut:{sheet:{"zen-edit-cancel":"Cancel Zen Edit","zen-edit-confirm":"Confirm Zen Edit"}}},Ze=Pe,Le={shortcut:{sheet:{"zen-edit-cancel":"取消编辑(禅模式状态)","zen-edit-confirm":"放弃编辑(禅模式状态)"}}},G=Le;var we=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,$e=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ae(t,n):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(e?s(t,n,r):s(r))||r);return e&&r&&we(t,n,r),r},k=(i,t)=>(n,e)=>t(n,e,i),Z;exports.UniverSheetsZenEditorPlugin=(Z=class extends a.Plugin{constructor(t,n,e){super("zen-editor"),this._injector=n,this._localeService=e,this._initialize(),this._initializeDependencies(this._injector)}_initialize(){this._localeService.load({zhCN:G})}_initializeDependencies(t){[[T],[b],[w,{useClass:ne}]].forEach(e=>t.add(e))}onRendered(){}onDestroy(){}},E(Z,"type",a.PluginType.Doc),Z);exports.UniverSheetsZenEditorPlugin=$e([k(1,p.Inject(p.Injector)),k(2,p.Inject(a.LocaleService))],exports.UniverSheetsZenEditorPlugin);exports.enUS=Ze;exports.zhCN=G;
|
package/lib/es/index.js
CHANGED
|
@@ -1,59 +1,61 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { CommandType as
|
|
5
|
-
import { createIdentifier as
|
|
6
|
-
import {
|
|
7
|
-
import { DeviceInputEventType as
|
|
8
|
-
import { getEditorObject as
|
|
9
|
-
import { IZenZoneService as M, KeyCode as
|
|
10
|
-
import { BehaviorSubject as
|
|
11
|
-
import
|
|
12
|
-
import { useDependency as
|
|
13
|
-
import
|
|
14
|
-
const
|
|
1
|
+
var de = Object.defineProperty;
|
|
2
|
+
var le = (i, e, n) => e in i ? de(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n;
|
|
3
|
+
var S = (i, e, n) => (le(i, typeof e != "symbol" ? e + "" : e, n), n);
|
|
4
|
+
import { CommandType as D, RxDisposable as ue, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as F, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as Y, OnLifecycle as G, LifecycleStages as q, DEFAULT_EMPTY_DOCUMENT_VALUE as he, IUniverInstanceService as U, ICommandService as P, IUndoRedoService as _e, FOCUSING_DOC as fe, FOCUSING_UNIVER_EDITOR as ve, EDITOR_ACTIVATED as ge, Disposable as Se, Plugin as pe, PluginType as me, LocaleService as Ee } from "@univerjs/core";
|
|
5
|
+
import { createIdentifier as Ie, Inject as p, Injector as J } from "@wendellhu/redi";
|
|
6
|
+
import { VIEWPORT_KEY as Ce, RichTextEditingMutation as Oe, getDocObject as ze, TextSelectionManagerService as Me, DocSkeletonManagerService as be, DocViewModelManagerService as ye } from "@univerjs/docs";
|
|
7
|
+
import { DeviceInputEventType as j, IRenderManagerService as Q } from "@univerjs/engine-render";
|
|
8
|
+
import { getEditorObject as xe, IEditorBridgeService as w } from "@univerjs/sheets-ui";
|
|
9
|
+
import { IZenZoneService as M, KeyCode as L, MenuGroup as Ne, MenuItemType as Re, MenuPosition as Te, MetaKeys as De, IMenuService as Ue, IShortcutService as Pe } from "@univerjs/ui";
|
|
10
|
+
import { BehaviorSubject as je, takeUntil as we } from "rxjs";
|
|
11
|
+
import Le, { forwardRef as Z, useRef as ee, createElement as $, useEffect as Ze } from "react";
|
|
12
|
+
import { useDependency as R } from "@wendellhu/redi/react-bindings";
|
|
13
|
+
import H from "clsx";
|
|
14
|
+
const A = {
|
|
15
15
|
id: "zen-editor.operation.open-zen-editor",
|
|
16
|
-
type:
|
|
17
|
-
handler: (
|
|
16
|
+
type: D.OPERATION,
|
|
17
|
+
handler: (i) => !0
|
|
18
18
|
};
|
|
19
|
-
class
|
|
19
|
+
class $e {
|
|
20
20
|
constructor() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
S(this, "_position", null);
|
|
22
|
+
S(this, "_position$", new je(null));
|
|
23
|
+
S(this, "position$", this._position$.asObservable());
|
|
24
24
|
}
|
|
25
25
|
dispose() {
|
|
26
26
|
this._position$.complete(), this._position = null;
|
|
27
27
|
}
|
|
28
|
-
setPosition(
|
|
29
|
-
this._position =
|
|
28
|
+
setPosition(e) {
|
|
29
|
+
this._position = e, this._refresh(e);
|
|
30
30
|
}
|
|
31
31
|
getPosition() {
|
|
32
32
|
return this._position;
|
|
33
33
|
}
|
|
34
|
-
_refresh(
|
|
35
|
-
this._position$.next(
|
|
34
|
+
_refresh(e) {
|
|
35
|
+
this._position$.next(e);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
const
|
|
38
|
+
const V = Ie(
|
|
39
39
|
"univer.sheet-zen-editor-manager.service"
|
|
40
40
|
);
|
|
41
|
-
var
|
|
42
|
-
for (var r =
|
|
43
|
-
(
|
|
44
|
-
return
|
|
45
|
-
},
|
|
46
|
-
const
|
|
47
|
-
let O = class extends
|
|
48
|
-
constructor(e,
|
|
49
|
-
super()
|
|
41
|
+
var Ae = Object.defineProperty, Ve = Object.getOwnPropertyDescriptor, ke = (i, e, n, t) => {
|
|
42
|
+
for (var r = t > 1 ? void 0 : t ? Ve(e, n) : e, o = i.length - 1, s; o >= 0; o--)
|
|
43
|
+
(s = i[o]) && (r = (t ? s(e, n, r) : s(r)) || r);
|
|
44
|
+
return t && r && Ae(e, n, r), r;
|
|
45
|
+
}, f = (i, e) => (n, t) => e(n, t, i);
|
|
46
|
+
const u = "__defaultDocumentZenEditorSpecialUnitId_20231218__";
|
|
47
|
+
let O = class extends ue {
|
|
48
|
+
constructor(e, n, t, r, o, s, c, a, d, l) {
|
|
49
|
+
super();
|
|
50
|
+
S(this, "_zenEditorInitialState", !1);
|
|
51
|
+
this._currentUniverService = e, this._zenEditorManagerService = n, this._renderManagerService = t, this._commandService = r, this._zenZoneService = o, this._editorBridgeService = s, this._undoRedoService = c, this._textSelectionManagerService = a, this._docSkeletonManagerService = d, this._docViewModelManagerService = l, this._initialize();
|
|
50
52
|
}
|
|
51
53
|
_initialize() {
|
|
52
|
-
this._syncZenEditorSize(), this._commandExecutedListener()
|
|
54
|
+
this._syncZenEditorSize(), this._commandExecutedListener();
|
|
53
55
|
}
|
|
54
56
|
_createZenEditorInstance() {
|
|
55
57
|
const e = {
|
|
56
|
-
id:
|
|
58
|
+
id: u,
|
|
57
59
|
body: {
|
|
58
60
|
dataStream: `${he}`,
|
|
59
61
|
textRuns: [],
|
|
@@ -82,148 +84,148 @@ let O = class extends le {
|
|
|
82
84
|
}
|
|
83
85
|
// Listen to changes in the size of the zen editor container to set the size of the editor.
|
|
84
86
|
_syncZenEditorSize() {
|
|
85
|
-
this._zenEditorManagerService.position$.pipe(
|
|
86
|
-
var
|
|
87
|
+
this._zenEditorManagerService.position$.pipe(we(this.dispose$)).subscribe((e) => {
|
|
88
|
+
var a;
|
|
87
89
|
if (e == null)
|
|
88
90
|
return;
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
91
|
+
const n = xe(u, this._renderManagerService), t = this._currentUniverService.getUniverDocInstance(u);
|
|
92
|
+
if (n == null || t == null)
|
|
91
93
|
return;
|
|
92
|
-
const { width:
|
|
94
|
+
const { width: r, height: o } = e, { engine: s } = n, c = (a = this._docSkeletonManagerService.getSkeletonByUnitId(u)) == null ? void 0 : a.skeleton;
|
|
93
95
|
requestIdleCallback(() => {
|
|
94
|
-
s.resizeBySize(
|
|
96
|
+
s.resizeBySize(r, o), this._calculatePagePosition(n), c && this._textSelectionManagerService.refreshSelection();
|
|
95
97
|
});
|
|
96
98
|
});
|
|
97
99
|
}
|
|
98
100
|
_handleOpenZenEditor() {
|
|
99
|
-
this._zenZoneService.open(), this._undoRedoService.clearUndoRedo(
|
|
101
|
+
this._zenEditorInitialState || (this._createZenEditorInstance(), this._zenEditorInitialState = !0), this._zenZoneService.open(), this._undoRedoService.clearUndoRedo(u), this._currentUniverService.focusUniverInstance(u), this._currentUniverService.setCurrentUniverDocInstance(u), this._editorBridgeService.isVisible().visible === !1 && this._editorBridgeService.changeVisible({
|
|
100
102
|
visible: !0,
|
|
101
|
-
eventType:
|
|
103
|
+
eventType: j.PointerDown
|
|
102
104
|
});
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
105
|
+
const n = this._editorBridgeService.getLatestEditCellState();
|
|
106
|
+
if (n == null)
|
|
105
107
|
return;
|
|
106
|
-
this._editorSyncHandler(
|
|
107
|
-
const
|
|
108
|
+
this._editorSyncHandler(n);
|
|
109
|
+
const t = [
|
|
108
110
|
{
|
|
109
111
|
startOffset: 0,
|
|
110
112
|
endOffset: 0
|
|
111
113
|
}
|
|
112
114
|
];
|
|
113
|
-
this._textSelectionManagerService.replaceTextRanges(
|
|
115
|
+
this._textSelectionManagerService.replaceTextRanges(t);
|
|
114
116
|
}
|
|
115
117
|
_editorSyncHandler(e) {
|
|
116
|
-
var s,
|
|
117
|
-
const
|
|
118
|
-
let
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
_syncContentAndRender(e,
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
], s = this._docSkeletonManagerService.getSkeletonByUnitId(e),
|
|
127
|
-
if (
|
|
118
|
+
var s, c;
|
|
119
|
+
const n = (s = e.documentLayoutObject.documentModel) == null ? void 0 : s.getBody(), t = n == null ? void 0 : n.dataStream, r = n == null ? void 0 : n.paragraphs;
|
|
120
|
+
let o = [];
|
|
121
|
+
t == null || r == null || ((c = n == null ? void 0 : n.textRuns) != null && c.length && (o = n == null ? void 0 : n.textRuns), this._syncContentAndRender(u, t, r, o));
|
|
122
|
+
}
|
|
123
|
+
_syncContentAndRender(e, n, t, r = []) {
|
|
124
|
+
const o = [
|
|
125
|
+
u,
|
|
126
|
+
Y,
|
|
127
|
+
F
|
|
128
|
+
], s = this._docSkeletonManagerService.getSkeletonByUnitId(e), c = this._currentUniverService.getUniverDocInstance(e), a = this._docViewModelManagerService.getViewModel(e);
|
|
129
|
+
if (c == null || a == null || s == null)
|
|
128
130
|
return;
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
const { skeleton:
|
|
132
|
-
|
|
131
|
+
const d = c.getBody();
|
|
132
|
+
d.dataStream = n, d.paragraphs = t, e === F && (d.textRuns = []), r.length > 0 && (d.textRuns = r), a.reset(c);
|
|
133
|
+
const { skeleton: l } = s, _ = this._getDocObject();
|
|
134
|
+
_ != null && (l.calculate(), o.includes(e) && _.document.makeDirty());
|
|
133
135
|
}
|
|
134
136
|
_calculatePagePosition(e) {
|
|
135
|
-
const { document:
|
|
136
|
-
if (
|
|
137
|
+
const { document: n, scene: t } = e, r = t == null ? void 0 : t.getParent(), { width: o, height: s, pageMarginLeft: c, pageMarginTop: a } = n;
|
|
138
|
+
if (r == null || o === Number.POSITIVE_INFINITY || s === Number.POSITIVE_INFINITY)
|
|
137
139
|
return;
|
|
138
|
-
const { width:
|
|
139
|
-
let
|
|
140
|
-
const { scaleX:
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
if (C !== Number.POSITIVE_INFINITY &&
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
x:
|
|
140
|
+
const { width: d, height: l } = r;
|
|
141
|
+
let _ = 0, y = 0, I = 0, x = 0, C = Number.POSITIVE_INFINITY;
|
|
142
|
+
const { scaleX: m, scaleY: ce } = t.getAncestorScale();
|
|
143
|
+
d > (o + c * 2) * m ? (_ = d / 2 - o * m / 2, _ /= m, I = (d - c * 2) / m, C = 0) : (_ = c, I = o + c * 2, C = (I - d / m) / 2), l > s ? (y = l / 2 - s / 2, x = (l - a * 2) / ce) : (y = a, x = s + a * 2), t.resize(I, x + 200), n.translate(_, y);
|
|
144
|
+
const N = t.getViewport(Ce.VIEW_MAIN);
|
|
145
|
+
if (C !== Number.POSITIVE_INFINITY && N != null) {
|
|
146
|
+
const ae = N.getBarScroll(C, 0).x;
|
|
147
|
+
N.scrollTo({
|
|
148
|
+
x: ae
|
|
147
149
|
});
|
|
148
150
|
}
|
|
149
151
|
return this;
|
|
150
152
|
}
|
|
151
153
|
_commandExecutedListener() {
|
|
152
|
-
const e = [
|
|
154
|
+
const e = [A.id];
|
|
153
155
|
this.disposeWithMe(
|
|
154
|
-
this._commandService.onCommandExecuted((
|
|
155
|
-
e.includes(
|
|
156
|
+
this._commandService.onCommandExecuted((t) => {
|
|
157
|
+
e.includes(t.id) && this._handleOpenZenEditor();
|
|
156
158
|
})
|
|
157
159
|
);
|
|
158
|
-
const
|
|
160
|
+
const n = [Oe.id];
|
|
159
161
|
this.disposeWithMe(
|
|
160
|
-
this._commandService.onCommandExecuted((
|
|
161
|
-
if (
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
-
const s = this._currentUniverService.getUniverDocInstance(
|
|
165
|
-
if (this._editorBridgeService.changeEditorDirty(!0),
|
|
162
|
+
this._commandService.onCommandExecuted((t) => {
|
|
163
|
+
if (n.includes(t.id)) {
|
|
164
|
+
const r = t.params, { unitId: o } = r;
|
|
165
|
+
if (o === u) {
|
|
166
|
+
const s = this._currentUniverService.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;
|
|
167
|
+
if (this._editorBridgeService.changeEditorDirty(!0), a == null || d == null)
|
|
166
168
|
return;
|
|
167
|
-
this._syncContentAndRender(
|
|
169
|
+
this._syncContentAndRender(Y, a, d, l);
|
|
168
170
|
}
|
|
169
171
|
}
|
|
170
172
|
})
|
|
171
173
|
);
|
|
172
174
|
}
|
|
173
175
|
_getDocObject() {
|
|
174
|
-
return
|
|
176
|
+
return ze(this._currentUniverService, this._renderManagerService);
|
|
175
177
|
}
|
|
176
178
|
};
|
|
177
|
-
O =
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
179
|
+
O = ke([
|
|
180
|
+
G(q.Steady, O),
|
|
181
|
+
f(0, U),
|
|
182
|
+
f(1, V),
|
|
183
|
+
f(2, Q),
|
|
184
|
+
f(3, P),
|
|
185
|
+
f(4, M),
|
|
186
|
+
f(5, w),
|
|
187
|
+
f(6, _e),
|
|
188
|
+
f(7, p(Me)),
|
|
189
|
+
f(8, p(be)),
|
|
190
|
+
f(9, p(ye))
|
|
189
191
|
], O);
|
|
190
|
-
const
|
|
192
|
+
const k = {
|
|
191
193
|
id: "zen-editor.command.cancel-zen-edit",
|
|
192
|
-
type:
|
|
193
|
-
handler: async (
|
|
194
|
-
const
|
|
194
|
+
type: D.COMMAND,
|
|
195
|
+
handler: async (i) => {
|
|
196
|
+
const e = i.get(M), n = i.get(w), t = i.get(U);
|
|
195
197
|
n.isVisible().visible && n.changeVisible({
|
|
196
198
|
visible: !1,
|
|
197
|
-
eventType:
|
|
198
|
-
keycode:
|
|
199
|
-
}),
|
|
200
|
-
const
|
|
201
|
-
return
|
|
199
|
+
eventType: j.Keyboard,
|
|
200
|
+
keycode: L.ESC
|
|
201
|
+
}), e.close();
|
|
202
|
+
const o = t.getCurrentUniverSheetInstance();
|
|
203
|
+
return t.focusUniverInstance(o.getUnitId()), n.refreshEditCellState(), !0;
|
|
202
204
|
}
|
|
203
|
-
},
|
|
205
|
+
}, B = {
|
|
204
206
|
id: "zen-editor.command.confirm-zen-edit",
|
|
205
|
-
type:
|
|
206
|
-
handler: async (
|
|
207
|
-
const
|
|
207
|
+
type: D.COMMAND,
|
|
208
|
+
handler: async (i) => {
|
|
209
|
+
const e = i.get(M), n = i.get(w), t = i.get(U);
|
|
208
210
|
n.isVisible().visible && n.changeVisible({
|
|
209
211
|
visible: !1,
|
|
210
|
-
eventType:
|
|
211
|
-
}),
|
|
212
|
-
const
|
|
213
|
-
return
|
|
212
|
+
eventType: j.PointerDown
|
|
213
|
+
}), e.close();
|
|
214
|
+
const o = t.getCurrentUniverSheetInstance();
|
|
215
|
+
return t.focusUniverInstance(o.getUnitId()), n.refreshEditCellState(), !0;
|
|
214
216
|
}
|
|
215
217
|
};
|
|
216
|
-
function
|
|
218
|
+
function Be() {
|
|
217
219
|
return {
|
|
218
|
-
id:
|
|
219
|
-
group:
|
|
220
|
-
type:
|
|
220
|
+
id: A.id,
|
|
221
|
+
group: Ne.CONTEXT_MENU_OTHERS,
|
|
222
|
+
type: Re.BUTTON,
|
|
221
223
|
title: "rightClick.zenEditor",
|
|
222
224
|
icon: "AmplifySingle",
|
|
223
|
-
positions: [
|
|
225
|
+
positions: [Te.CONTEXT_MENU]
|
|
224
226
|
};
|
|
225
227
|
}
|
|
226
|
-
var
|
|
228
|
+
var te = { exports: {} }, b = {};
|
|
227
229
|
/**
|
|
228
230
|
* @license React
|
|
229
231
|
* react-jsx-runtime.production.min.js
|
|
@@ -233,270 +235,244 @@ var ee = { exports: {} }, b = {};
|
|
|
233
235
|
* This source code is licensed under the MIT license found in the
|
|
234
236
|
* LICENSE file in the root directory of this source tree.
|
|
235
237
|
*/
|
|
236
|
-
var
|
|
237
|
-
function
|
|
238
|
-
var
|
|
239
|
-
n !== void 0 && (
|
|
240
|
-
for (
|
|
241
|
-
|
|
242
|
-
if (
|
|
243
|
-
for (
|
|
244
|
-
r[
|
|
245
|
-
return { $$typeof:
|
|
238
|
+
var We = Le, Fe = Symbol.for("react.element"), Ye = Symbol.for("react.fragment"), He = Object.prototype.hasOwnProperty, Ke = We.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, Xe = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
239
|
+
function ne(i, e, n) {
|
|
240
|
+
var t, r = {}, o = null, s = null;
|
|
241
|
+
n !== void 0 && (o = "" + n), e.key !== void 0 && (o = "" + e.key), e.ref !== void 0 && (s = e.ref);
|
|
242
|
+
for (t in e)
|
|
243
|
+
He.call(e, t) && !Xe.hasOwnProperty(t) && (r[t] = e[t]);
|
|
244
|
+
if (i && i.defaultProps)
|
|
245
|
+
for (t in e = i.defaultProps, e)
|
|
246
|
+
r[t] === void 0 && (r[t] = e[t]);
|
|
247
|
+
return { $$typeof: Fe, type: i, key: o, ref: s, props: r, _owner: Ke.current };
|
|
246
248
|
}
|
|
247
|
-
b.Fragment =
|
|
248
|
-
b.jsx =
|
|
249
|
-
b.jsxs =
|
|
250
|
-
|
|
251
|
-
var
|
|
252
|
-
return
|
|
253
|
-
for (var
|
|
254
|
-
|
|
255
|
-
for (var r in
|
|
256
|
-
Object.prototype.hasOwnProperty.call(
|
|
249
|
+
b.Fragment = Ye;
|
|
250
|
+
b.jsx = ne;
|
|
251
|
+
b.jsxs = ne;
|
|
252
|
+
te.exports = b;
|
|
253
|
+
var v = te.exports, h = function() {
|
|
254
|
+
return h = Object.assign || function(i) {
|
|
255
|
+
for (var e, n = 1, t = arguments.length; n < t; n++) {
|
|
256
|
+
e = arguments[n];
|
|
257
|
+
for (var r in e)
|
|
258
|
+
Object.prototype.hasOwnProperty.call(e, r) && (i[r] = e[r]);
|
|
257
259
|
}
|
|
258
|
-
return
|
|
259
|
-
},
|
|
260
|
-
},
|
|
260
|
+
return i;
|
|
261
|
+
}, h.apply(this, arguments);
|
|
262
|
+
}, Ge = function(i, e) {
|
|
261
263
|
var n = {};
|
|
262
|
-
for (var
|
|
263
|
-
Object.prototype.hasOwnProperty.call(
|
|
264
|
-
if (
|
|
265
|
-
for (var r = 0,
|
|
266
|
-
|
|
264
|
+
for (var t in i)
|
|
265
|
+
Object.prototype.hasOwnProperty.call(i, t) && e.indexOf(t) < 0 && (n[t] = i[t]);
|
|
266
|
+
if (i != null && typeof Object.getOwnPropertySymbols == "function")
|
|
267
|
+
for (var r = 0, t = Object.getOwnPropertySymbols(i); r < t.length; r++)
|
|
268
|
+
e.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(i, t[r]) && (n[t[r]] = i[t[r]]);
|
|
267
269
|
return n;
|
|
268
|
-
},
|
|
269
|
-
var n =
|
|
270
|
-
return
|
|
270
|
+
}, W = Z(function(i, e) {
|
|
271
|
+
var n = i.icon, t = i.id, r = i.className, o = i.extend, s = Ge(i, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), a = ee("_".concat(Qe()));
|
|
272
|
+
return ie(n, "".concat(t), { defIds: n.defIds, idSuffix: a.current }, h({ ref: e, className: c }, s), o);
|
|
271
273
|
});
|
|
272
|
-
function
|
|
273
|
-
return
|
|
274
|
-
return
|
|
274
|
+
function ie(i, e, n, t, r) {
|
|
275
|
+
return $(i.tag, h(h({ key: e }, qe(i, n, r)), t), (Je(i, n).children || []).map(function(o, s) {
|
|
276
|
+
return ie(o, "".concat(e, "-").concat(i.tag, "-").concat(s), n, void 0, r);
|
|
275
277
|
}));
|
|
276
278
|
}
|
|
277
|
-
function
|
|
278
|
-
var
|
|
279
|
-
n != null && n.colorChannel1 &&
|
|
280
|
-
var r =
|
|
281
|
-
return !r || r.length === 0 || (
|
|
282
|
-
var
|
|
283
|
-
typeof c == "string" && (
|
|
284
|
-
})),
|
|
279
|
+
function qe(i, e, n) {
|
|
280
|
+
var t = h({}, i.attrs);
|
|
281
|
+
n != null && n.colorChannel1 && t.fill === "colorChannel1" && (t.fill = n.colorChannel1);
|
|
282
|
+
var r = e.defIds;
|
|
283
|
+
return !r || r.length === 0 || (i.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + e.idSuffix), Object.entries(t).forEach(function(o) {
|
|
284
|
+
var s = o[0], c = o[1];
|
|
285
|
+
typeof c == "string" && (t[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
286
|
+
})), t;
|
|
285
287
|
}
|
|
286
|
-
function
|
|
287
|
-
var n,
|
|
288
|
-
return !
|
|
289
|
-
return typeof r.attrs.id == "string" &&
|
|
290
|
-
}) }) :
|
|
288
|
+
function Je(i, e) {
|
|
289
|
+
var n, t = e.defIds;
|
|
290
|
+
return !t || t.length === 0 ? i : i.tag === "defs" && (!((n = i.children) === null || n === void 0) && n.length) ? h(h({}, i), { children: i.children.map(function(r) {
|
|
291
|
+
return typeof r.attrs.id == "string" && t && t.indexOf(r.attrs.id) > -1 ? h(h({}, r), { attrs: h(h({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
|
|
292
|
+
}) }) : i;
|
|
291
293
|
}
|
|
292
|
-
function
|
|
294
|
+
function Qe() {
|
|
293
295
|
return Math.random().toString(36).substring(2, 8);
|
|
294
296
|
}
|
|
295
|
-
|
|
296
|
-
var
|
|
297
|
-
|
|
298
|
-
attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" },
|
|
299
|
-
children: [
|
|
300
|
-
{
|
|
301
|
-
tag: "path",
|
|
302
|
-
attrs: {
|
|
303
|
-
fill: "currentColor",
|
|
304
|
-
d: "M14.44 3.57291C14.698 3.83093 14.698 4.24927 14.44 4.50729L6.44342 12.5037C6.28721 12.6599 6.03395 12.6599 5.87774 12.5037L1.55992 8.18578C1.3019 7.92776 1.3019 7.50942 1.55993 7.2514C1.81795 6.99338 2.23629 6.99338 2.49431 7.25141L6.01916 10.7763C6.09727 10.8544 6.2239 10.8544 6.30201 10.7763L13.5056 3.57291C13.7636 3.31489 14.1819 3.31489 14.44 3.57291Z",
|
|
305
|
-
fillRule: "evenodd",
|
|
306
|
-
clipRule: "evenodd"
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
]
|
|
310
|
-
}, ie = L(function(e, t) {
|
|
311
|
-
return Z(B, Object.assign({}, e, {
|
|
297
|
+
W.displayName = "UniverIcon";
|
|
298
|
+
var et = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.44 3.57291C14.698 3.83093 14.698 4.24927 14.44 4.50729L6.44342 12.5037C6.28721 12.6599 6.03395 12.6599 5.87774 12.5037L1.55992 8.18578C1.3019 7.92776 1.3019 7.50942 1.55993 7.2514C1.81795 6.99338 2.23629 6.99338 2.49431 7.25141L6.01916 10.7763C6.09727 10.8544 6.2239 10.8544 6.30201 10.7763L13.5056 3.57291C13.7636 3.31489 14.1819 3.31489 14.44 3.57291Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, re = Z(function(i, e) {
|
|
299
|
+
return $(W, Object.assign({}, i, {
|
|
312
300
|
id: "check-mark-single",
|
|
313
|
-
ref:
|
|
314
|
-
icon:
|
|
301
|
+
ref: e,
|
|
302
|
+
icon: et
|
|
315
303
|
}));
|
|
316
304
|
});
|
|
317
|
-
|
|
318
|
-
const
|
|
319
|
-
var
|
|
320
|
-
|
|
321
|
-
attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" },
|
|
322
|
-
children: [
|
|
323
|
-
{
|
|
324
|
-
tag: "path",
|
|
325
|
-
attrs: {
|
|
326
|
-
fill: "currentColor",
|
|
327
|
-
d: "M4.57061 3.65132C4.31677 3.39748 3.90521 3.39748 3.65137 3.65132C3.39753 3.90516 3.39753 4.31672 3.65137 4.57056L7.08079 7.99998L3.65123 11.4295C3.39739 11.6834 3.39739 12.0949 3.65123 12.3488C3.90507 12.6026 4.31662 12.6026 4.57047 12.3488L8.00003 8.91921L11.4295 12.3487C11.6834 12.6026 12.0949 12.6026 12.3488 12.3487C12.6026 12.0949 12.6026 11.6833 12.3488 11.4295L8.91927 7.99998L12.3486 4.57061C12.6025 4.31677 12.6025 3.90521 12.3486 3.65137C12.0948 3.39753 11.6832 3.39753 11.4294 3.65137L8.00003 7.08074L4.57061 3.65132Z"
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
]
|
|
331
|
-
}, re = L(function(e, t) {
|
|
332
|
-
return Z(B, Object.assign({}, e, {
|
|
305
|
+
re.displayName = "CheckMarkSingle";
|
|
306
|
+
const tt = re;
|
|
307
|
+
var nt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M4.57061 3.65132C4.31677 3.39748 3.90521 3.39748 3.65137 3.65132C3.39753 3.90516 3.39753 4.31672 3.65137 4.57056L7.08079 7.99998L3.65123 11.4295C3.39739 11.6834 3.39739 12.0949 3.65123 12.3488C3.90507 12.6026 4.31662 12.6026 4.57047 12.3488L8.00003 8.91921L11.4295 12.3487C11.6834 12.6026 12.0949 12.6026 12.3488 12.3487C12.6026 12.0949 12.6026 11.6833 12.3488 11.4295L8.91927 7.99998L12.3486 4.57061C12.6025 4.31677 12.6025 3.90521 12.3486 3.65137C12.0948 3.39753 11.6832 3.39753 11.4294 3.65137L8.00003 7.08074L4.57061 3.65132Z" } }] }, oe = Z(function(i, e) {
|
|
308
|
+
return $(W, Object.assign({}, i, {
|
|
333
309
|
id: "close-single",
|
|
334
|
-
ref:
|
|
335
|
-
icon:
|
|
310
|
+
ref: e,
|
|
311
|
+
icon: nt
|
|
336
312
|
}));
|
|
337
313
|
});
|
|
338
|
-
|
|
339
|
-
const
|
|
340
|
-
zenEditor:
|
|
341
|
-
zenEditorIconWrapper:
|
|
342
|
-
zenEditorIconContainer:
|
|
343
|
-
zenEditorIconSuccess:
|
|
344
|
-
zenEditorIconError:
|
|
345
|
-
zenEditorCanvasContainer:
|
|
346
|
-
},
|
|
347
|
-
function
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
const
|
|
351
|
-
if (!
|
|
314
|
+
oe.displayName = "CloseSingle";
|
|
315
|
+
const it = oe, rt = "univer-zen-editor", ot = "univer-zen-editor-icon-wrapper", st = "univer-zen-editor-icon-container", ct = "univer-zen-editor-icon-success", at = "univer-zen-editor-icon-error", dt = "univer-zen-editor-canvas-container", g = {
|
|
316
|
+
zenEditor: rt,
|
|
317
|
+
zenEditorIconWrapper: ot,
|
|
318
|
+
zenEditorIconContainer: st,
|
|
319
|
+
zenEditorIconSuccess: ct,
|
|
320
|
+
zenEditorIconError: at,
|
|
321
|
+
zenEditorCanvasContainer: dt
|
|
322
|
+
}, lt = "ZEN_EDITOR_PLUGIN_", ut = `${lt}ZEN_EDITOR_COMPONENT`;
|
|
323
|
+
function ht() {
|
|
324
|
+
const i = ee(null), e = R(Q), n = R(V), t = R(P);
|
|
325
|
+
Ze(() => {
|
|
326
|
+
const s = i.current;
|
|
327
|
+
if (!s)
|
|
352
328
|
return;
|
|
353
|
-
const c =
|
|
354
|
-
var
|
|
355
|
-
if (d !==
|
|
329
|
+
const c = e.currentRender$.subscribe((d) => {
|
|
330
|
+
var _;
|
|
331
|
+
if (d !== u)
|
|
356
332
|
return;
|
|
357
|
-
const
|
|
358
|
-
|
|
333
|
+
const l = (_ = e.getRenderById(u)) == null ? void 0 : _.engine;
|
|
334
|
+
l == null || l.setContainer(s);
|
|
359
335
|
}), a = new ResizeObserver(() => {
|
|
360
|
-
const d =
|
|
336
|
+
const d = s.getBoundingClientRect();
|
|
361
337
|
n.setPosition(d);
|
|
362
338
|
});
|
|
363
|
-
return a.observe(
|
|
364
|
-
a.unobserve(
|
|
339
|
+
return a.observe(s), () => {
|
|
340
|
+
a.unobserve(s), c.unsubscribe();
|
|
365
341
|
};
|
|
366
342
|
}, []);
|
|
367
343
|
function r() {
|
|
368
|
-
|
|
344
|
+
t.executeCommand(k.id);
|
|
369
345
|
}
|
|
370
|
-
function
|
|
371
|
-
|
|
346
|
+
function o() {
|
|
347
|
+
t.executeCommand(B.id);
|
|
372
348
|
}
|
|
373
|
-
return /* @__PURE__ */
|
|
374
|
-
/* @__PURE__ */
|
|
375
|
-
/* @__PURE__ */
|
|
349
|
+
return /* @__PURE__ */ v.jsxs("div", { className: g.zenEditor, children: [
|
|
350
|
+
/* @__PURE__ */ v.jsxs("div", { className: g.zenEditorIconWrapper, children: [
|
|
351
|
+
/* @__PURE__ */ v.jsx(
|
|
376
352
|
"span",
|
|
377
353
|
{
|
|
378
|
-
className:
|
|
354
|
+
className: H(g.zenEditorIconContainer, g.zenEditorIconError),
|
|
379
355
|
onClick: r,
|
|
380
|
-
children: /* @__PURE__ */
|
|
356
|
+
children: /* @__PURE__ */ v.jsx(it, { style: { fontSize: "22px" } })
|
|
381
357
|
}
|
|
382
358
|
),
|
|
383
|
-
/* @__PURE__ */
|
|
359
|
+
/* @__PURE__ */ v.jsx(
|
|
384
360
|
"span",
|
|
385
361
|
{
|
|
386
|
-
className:
|
|
387
|
-
onClick:
|
|
388
|
-
children: /* @__PURE__ */
|
|
362
|
+
className: H(g.zenEditorIconContainer, g.zenEditorIconSuccess),
|
|
363
|
+
onClick: o,
|
|
364
|
+
children: /* @__PURE__ */ v.jsx(tt, { style: { fontSize: "22px" } })
|
|
389
365
|
}
|
|
390
366
|
)
|
|
391
367
|
] }),
|
|
392
|
-
/* @__PURE__ */
|
|
368
|
+
/* @__PURE__ */ v.jsx("div", { className: g.zenEditorCanvasContainer, ref: i })
|
|
393
369
|
] });
|
|
394
370
|
}
|
|
395
|
-
const
|
|
396
|
-
id:
|
|
371
|
+
const _t = {
|
|
372
|
+
id: B.id,
|
|
397
373
|
description: "shortcut.sheet.zen-edit-confirm",
|
|
398
374
|
group: "4_sheet-edit",
|
|
399
|
-
preconditions: (
|
|
400
|
-
binding:
|
|
401
|
-
},
|
|
402
|
-
id:
|
|
375
|
+
preconditions: (i) => se(i),
|
|
376
|
+
binding: L.ENTER | De.ALT
|
|
377
|
+
}, ft = {
|
|
378
|
+
id: k.id,
|
|
403
379
|
description: "shortcut.sheet.zen-edit-cancel",
|
|
404
380
|
group: "4_sheet-edit",
|
|
405
|
-
preconditions: (
|
|
406
|
-
binding:
|
|
381
|
+
preconditions: (i) => se(i),
|
|
382
|
+
binding: L.ESC
|
|
407
383
|
};
|
|
408
|
-
function
|
|
409
|
-
return
|
|
384
|
+
function se(i) {
|
|
385
|
+
return i.getContextValue(fe) && i.getContextValue(ve) && i.getContextValue(ge);
|
|
410
386
|
}
|
|
411
|
-
var
|
|
412
|
-
for (var r =
|
|
413
|
-
(
|
|
414
|
-
return
|
|
415
|
-
}, E = (
|
|
416
|
-
let z = class extends
|
|
417
|
-
constructor(
|
|
418
|
-
super(), this._injector =
|
|
387
|
+
var vt = Object.defineProperty, gt = Object.getOwnPropertyDescriptor, St = (i, e, n, t) => {
|
|
388
|
+
for (var r = t > 1 ? void 0 : t ? gt(e, n) : e, o = i.length - 1, s; o >= 0; o--)
|
|
389
|
+
(s = i[o]) && (r = (t ? s(e, n, r) : s(r)) || r);
|
|
390
|
+
return t && r && vt(e, n, r), r;
|
|
391
|
+
}, E = (i, e) => (n, t) => e(n, t, i);
|
|
392
|
+
let z = class extends Se {
|
|
393
|
+
constructor(i, e, n, t, r) {
|
|
394
|
+
super(), this._injector = i, this._zenZoneService = e, this._commandService = n, this._menuService = t, this._shortcutService = r, this._initialize();
|
|
419
395
|
}
|
|
420
396
|
_initialize() {
|
|
421
397
|
this._initCustomComponents(), this._initCommands(), this._initMenus(), this._initShortcuts();
|
|
422
398
|
}
|
|
423
399
|
_initCustomComponents() {
|
|
424
|
-
this.disposeWithMe(this._zenZoneService.set(
|
|
400
|
+
this.disposeWithMe(this._zenZoneService.set(ut, ht));
|
|
425
401
|
}
|
|
426
402
|
_initCommands() {
|
|
427
|
-
[
|
|
428
|
-
this.disposeWithMe(this._commandService.registerCommand(
|
|
403
|
+
[A, k, B].forEach((i) => {
|
|
404
|
+
this.disposeWithMe(this._commandService.registerCommand(i));
|
|
429
405
|
});
|
|
430
406
|
}
|
|
431
407
|
_initMenus() {
|
|
432
408
|
[
|
|
433
409
|
// context menu
|
|
434
|
-
|
|
435
|
-
].forEach((
|
|
436
|
-
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(
|
|
410
|
+
Be
|
|
411
|
+
].forEach((i) => {
|
|
412
|
+
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)));
|
|
437
413
|
});
|
|
438
414
|
}
|
|
439
415
|
_initShortcuts() {
|
|
440
|
-
[
|
|
441
|
-
this.disposeWithMe(this._shortcutService.registerShortcut(
|
|
416
|
+
[_t, ft].forEach((i) => {
|
|
417
|
+
this.disposeWithMe(this._shortcutService.registerShortcut(i));
|
|
442
418
|
});
|
|
443
419
|
}
|
|
444
420
|
};
|
|
445
|
-
z =
|
|
446
|
-
|
|
447
|
-
E(0,
|
|
421
|
+
z = St([
|
|
422
|
+
G(q.Rendered, z),
|
|
423
|
+
E(0, p(J)),
|
|
448
424
|
E(1, M),
|
|
449
|
-
E(2,
|
|
450
|
-
E(3,
|
|
451
|
-
E(4,
|
|
425
|
+
E(2, P),
|
|
426
|
+
E(3, Ue),
|
|
427
|
+
E(4, Pe)
|
|
452
428
|
], z);
|
|
453
|
-
const
|
|
429
|
+
const pt = {
|
|
454
430
|
shortcut: {
|
|
455
431
|
sheet: {
|
|
456
432
|
"zen-edit-cancel": "Cancel Zen Edit",
|
|
457
433
|
"zen-edit-confirm": "Confirm Zen Edit"
|
|
458
434
|
}
|
|
459
435
|
}
|
|
460
|
-
},
|
|
436
|
+
}, jt = pt, mt = {
|
|
461
437
|
shortcut: {
|
|
462
438
|
sheet: {
|
|
463
439
|
"zen-edit-cancel": "取消编辑(禅模式状态)",
|
|
464
440
|
"zen-edit-confirm": "放弃编辑(禅模式状态)"
|
|
465
441
|
}
|
|
466
442
|
}
|
|
467
|
-
};
|
|
468
|
-
var
|
|
469
|
-
for (var r =
|
|
470
|
-
(
|
|
471
|
-
return
|
|
472
|
-
},
|
|
473
|
-
let
|
|
474
|
-
constructor(
|
|
475
|
-
super("zen-editor"), this._injector =
|
|
443
|
+
}, Et = mt;
|
|
444
|
+
var It = Object.defineProperty, Ct = Object.getOwnPropertyDescriptor, Ot = (i, e, n, t) => {
|
|
445
|
+
for (var r = t > 1 ? void 0 : t ? Ct(e, n) : e, o = i.length - 1, s; o >= 0; o--)
|
|
446
|
+
(s = i[o]) && (r = (t ? s(e, n, r) : s(r)) || r);
|
|
447
|
+
return t && r && It(e, n, r), r;
|
|
448
|
+
}, K = (i, e) => (n, t) => e(n, t, i), T;
|
|
449
|
+
let X = (T = class extends pe {
|
|
450
|
+
constructor(i, e, n) {
|
|
451
|
+
super("zen-editor"), this._injector = e, this._localeService = n, this._initialize(), this._initializeDependencies(this._injector);
|
|
476
452
|
}
|
|
477
453
|
_initialize() {
|
|
478
454
|
this._localeService.load({
|
|
479
|
-
zhCN:
|
|
455
|
+
zhCN: Et
|
|
480
456
|
});
|
|
481
457
|
}
|
|
482
|
-
_initializeDependencies(
|
|
458
|
+
_initializeDependencies(i) {
|
|
483
459
|
[
|
|
484
460
|
[z],
|
|
485
461
|
[O],
|
|
486
|
-
[
|
|
487
|
-
].forEach((n) =>
|
|
462
|
+
[V, { useClass: $e }]
|
|
463
|
+
].forEach((n) => i.add(n));
|
|
488
464
|
}
|
|
489
465
|
onRendered() {
|
|
490
466
|
}
|
|
491
467
|
onDestroy() {
|
|
492
468
|
}
|
|
493
|
-
},
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
],
|
|
469
|
+
}, S(T, "type", me.Doc), T);
|
|
470
|
+
X = Ot([
|
|
471
|
+
K(1, p(J)),
|
|
472
|
+
K(2, p(Ee))
|
|
473
|
+
], X);
|
|
498
474
|
export {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
475
|
+
X as UniverSheetsZenEditorPlugin,
|
|
476
|
+
jt as enUS,
|
|
477
|
+
Et as zhCN
|
|
502
478
|
};
|
|
@@ -35,6 +35,7 @@ export declare class ZenEditorController extends RxDisposable {
|
|
|
35
35
|
private _initialize;
|
|
36
36
|
private _createZenEditorInstance;
|
|
37
37
|
private _syncZenEditorSize;
|
|
38
|
+
private _zenEditorInitialState;
|
|
38
39
|
private _handleOpenZenEditor;
|
|
39
40
|
private _editorSyncHandler;
|
|
40
41
|
private _syncContentAndRender;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
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,v,C,y,T,h,W,g,b,F){"use strict";var je=Object.defineProperty;var xe=(d,c,v)=>c in d?je(d,c,{enumerable:!0,configurable:!0,writable:!0,value:v}):d[c]=v;var O=(d,c,v)=>(xe(d,typeof c!="symbol"?c+"":c,v),v);var A;const U={id:"zen-editor.operation.open-zen-editor",type:c.CommandType.OPERATION,handler:i=>!0};class Q{constructor(){O(this,"_position",null);O(this,"_position$",new W.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 P=v.createIdentifier("univer.sheet-zen-editor-manager.service");var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,ne=(i,t,n,e)=>{for(var r=e>1?void 0:e?te(t,n):t,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(e?o(t,n,r):o(r))||r);return e&&r&&ee(t,n,r),r},p=(i,t)=>(n,e)=>t(n,e,i);const f="__defaultDocumentZenEditorSpecialUnitId_20231218__";let R=class extends c.RxDisposable{constructor(t,n,e,r,s,o,a,l,u,_){super();O(this,"_zenEditorInitialState",!1);this._currentUniverService=t,this._zenEditorManagerService=n,this._renderManagerService=e,this._commandService=r,this._zenZoneService=s,this._editorBridgeService=o,this._undoRedoService=a,this._textSelectionManagerService=l,this._docSkeletonManagerService=u,this._docViewModelManagerService=_,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}}};this._currentUniverService.createDoc(t)}_syncZenEditorSize(){this._zenEditorManagerService.position$.pipe(W.takeUntil(this.dispose$)).subscribe(t=>{var l;if(t==null)return;const n=T.getEditorObject(f,this._renderManagerService),e=this._currentUniverService.getUniverDocInstance(f);if(n==null||e==null)return;const{width:r,height:s}=t,{engine:o}=n,a=(l=this._docSkeletonManagerService.getSkeletonByUnitId(f))==null?void 0:l.skeleton;requestIdleCallback(()=>{o.resizeBySize(r,s),this._calculatePagePosition(n),a&&this._textSelectionManagerService.refreshSelection()})})}_handleOpenZenEditor(){this._zenEditorInitialState||(this._createZenEditorInstance(),this._zenEditorInitialState=!0),this._zenZoneService.open(),this._undoRedoService.clearUndoRedo(f),this._currentUniverService.focusUniverInstance(f),this._currentUniverService.setCurrentUniverDocInstance(f),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:y.DeviceInputEventType.PointerDown});const n=this._editorBridgeService.getLatestEditCellState();if(n==null)return;this._editorSyncHandler(n);const e=[{startOffset:0,endOffset:0}];this._textSelectionManagerService.replaceTextRanges(e)}_editorSyncHandler(t){var o,a;const n=(o=t.documentLayoutObject.documentModel)==null?void 0:o.getBody(),e=n==null?void 0:n.dataStream,r=n==null?void 0:n.paragraphs;let s=[];e==null||r==null||((a=n==null?void 0:n.textRuns)!=null&&a.length&&(s=n==null?void 0:n.textRuns),this._syncContentAndRender(f,e,r,s))}_syncContentAndRender(t,n,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._currentUniverService.getUniverDocInstance(t),l=this._docViewModelManagerService.getViewModel(t);if(a==null||l==null||o==null)return;const u=a.getBody();u.dataStream=n,u.paragraphs=e,t===c.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(u.textRuns=[]),r.length>0&&(u.textRuns=r),l.reset(a);const{skeleton:_}=o,I=this._getDocObject();I!=null&&(_.calculate(),s.includes(t)&&I.document.makeDirty())}_calculatePagePosition(t){const{document:n,scene:e}=t,r=e==null?void 0:e.getParent(),{width:s,height:o,pageMarginLeft:a,pageMarginTop:l}=n;if(r==null||s===Number.POSITIVE_INFINITY||o===Number.POSITIVE_INFINITY)return;const{width:u,height:_}=r;let I=0,B=0,j=0,V=0,x=Number.POSITIVE_INFINITY;const{scaleX:M,scaleY:Ne}=e.getAncestorScale();u>(s+a*2)*M?(I=u/2-s*M/2,I/=M,j=(u-a*2)/M,x=0):(I=a,j=s+a*2,x=(j-u/M)/2),_>o?(B=_/2-o/2,V=(_-l*2)/Ne):(B=l,V=o+l*2),e.resize(j,V+200),n.translate(I,B);const k=e.getViewport(C.VIEWPORT_KEY.VIEW_MAIN);if(x!==Number.POSITIVE_INFINITY&&k!=null){const De=k.getBarScroll(x,0).x;k.scrollTo({x:De})}return this}_commandExecutedListener(){const t=[U.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{t.includes(e.id)&&this._handleOpenZenEditor()}));const n=[C.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(n.includes(e.id)){const r=e.params,{unitId:s}=r;if(s===f){const o=this._currentUniverService.getUniverDocInstance(s),a=o==null?void 0:o.getBody(),l=a==null?void 0:a.dataStream,u=a==null?void 0:a.paragraphs,_=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,_)}}}))}_getDocObject(){return C.getDocObject(this._currentUniverService,this._renderManagerService)}};R=ne([c.OnLifecycle(c.LifecycleStages.Steady,R),p(0,c.IUniverInstanceService),p(1,P),p(2,y.IRenderManagerService),p(3,c.ICommandService),p(4,h.IZenZoneService),p(5,T.IEditorBridgeService),p(6,c.IUndoRedoService),p(7,v.Inject(C.TextSelectionManagerService)),p(8,v.Inject(C.DocSkeletonManagerService)),p(9,v.Inject(C.DocViewModelManagerService))],R);const Z={id:"zen-editor.command.cancel-zen-edit",type:c.CommandType.COMMAND,handler:async i=>{const t=i.get(h.IZenZoneService),n=i.get(T.IEditorBridgeService),e=i.get(c.IUniverInstanceService);n.isVisible().visible&&n.changeVisible({visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:h.KeyCode.ESC}),t.close();const s=e.getCurrentUniverSheetInstance();return e.focusUniverInstance(s.getUnitId()),n.refreshEditCellState(),!0}},w={id:"zen-editor.command.confirm-zen-edit",type:c.CommandType.COMMAND,handler:async i=>{const t=i.get(h.IZenZoneService),n=i.get(T.IEditorBridgeService),e=i.get(c.IUniverInstanceService);n.isVisible().visible&&n.changeVisible({visible:!1,eventType:y.DeviceInputEventType.PointerDown}),t.close();const s=e.getCurrentUniverSheetInstance();return e.focusUniverInstance(s.getUnitId()),n.refreshEditCellState(),!0}};function ie(){return{id:U.id,group:h.MenuGroup.CONTEXT_MENU_OTHERS,type:h.MenuItemType.BUTTON,title:"rightClick.zenEditor",icon:"AmplifySingle",positions:[h.MenuPosition.CONTEXT_MENU]}}var Y={exports:{}},N={};/**
|
|
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 re=g,se=Symbol.for("react.element"),oe=Symbol.for("react.fragment"),ce=Object.prototype.hasOwnProperty,ae=re.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,de={key:!0,ref:!0,__self:!0,__source:!0};function K(i,t,n){var e,r={},s=null,o=null;n!==void 0&&(s=""+n),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(o=t.ref);for(e in t)ce.call(t,e)&&!de.hasOwnProperty(e)&&(r[e]=t[e]);if(i&&i.defaultProps)for(e in t=i.defaultProps,t)r[e]===void 0&&(r[e]=t[e]);return{$$typeof:se,type:i,key:s,ref:o,props:r,_owner:ae.current}}N.Fragment=oe,N.jsx=K,N.jsxs=K,Y.exports=N;var E=Y.exports,S=function(){return S=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},S.apply(this,arguments)},le=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},L=g.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,s=i.extend,o=le(i,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),l=g.useRef("_".concat(he()));return $(n,"".concat(e),{defIds:n.defIds,idSuffix:l.current},S({ref:t,className:a},o),s)});function $(i,t,n,e,r){return g.createElement(i.tag,S(S({key:t},ue(i,n,r)),e),(ve(i,n).children||[]).map(function(s,o){return $(s,"".concat(t,"-").concat(i.tag,"-").concat(o),n,void 0,r)}))}function ue(i,t,n){var e=S({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.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 ve(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?S(S({},i),{children:i.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})}):i}function he(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var _e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.44 3.57291C14.698 3.83093 14.698 4.24927 14.44 4.50729L6.44342 12.5037C6.28721 12.6599 6.03395 12.6599 5.87774 12.5037L1.55992 8.18578C1.3019 7.92776 1.3019 7.50942 1.55993 7.2514C1.81795 6.99338 2.23629 6.99338 2.49431 7.25141L6.01916 10.7763C6.09727 10.8544 6.2239 10.8544 6.30201 10.7763L13.5056 3.57291C13.7636 3.31489 14.1819 3.31489 14.44 3.57291Z",fillRule:"evenodd",clipRule:"evenodd"}}]},H=g.forwardRef(function(i,t){return g.createElement(L,Object.assign({},i,{id:"check-mark-single",ref:t,icon:_e}))});H.displayName="CheckMarkSingle";const fe=H;var Se={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.57061 3.65132C4.31677 3.39748 3.90521 3.39748 3.65137 3.65132C3.39753 3.90516 3.39753 4.31672 3.65137 4.57056L7.08079 7.99998L3.65123 11.4295C3.39739 11.6834 3.39739 12.0949 3.65123 12.3488C3.90507 12.6026 4.31662 12.6026 4.57047 12.3488L8.00003 8.91921L11.4295 12.3487C11.6834 12.6026 12.0949 12.6026 12.3488 12.3487C12.6026 12.0949 12.6026 11.6833 12.3488 11.4295L8.91927 7.99998L12.3486 4.57061C12.6025 4.31677 12.6025 3.90521 12.3486 3.65137C12.0948 3.39753 11.6832 3.39753 11.4294 3.65137L8.00003 7.08074L4.57061 3.65132Z"}}]},X=g.forwardRef(function(i,t){return g.createElement(L,Object.assign({},i,{id:"close-single",ref:t,icon:Se}))});X.displayName="CloseSingle";const ge=X,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"},pe="ZEN_EDITOR_PLUGIN_ZEN_EDITOR_COMPONENT";function Ie(){const i=g.useRef(null),t=b.useDependency(y.IRenderManagerService),n=b.useDependency(P),e=b.useDependency(c.ICommandService);g.useEffect(()=>{const o=i.current;if(!o)return;const a=t.currentRender$.subscribe(u=>{var I;if(u!==f)return;const _=(I=t.getRenderById(f))==null?void 0:I.engine;_==null||_.setContainer(o)}),l=new ResizeObserver(()=>{const u=o.getBoundingClientRect();n.setPosition(u)});return l.observe(o),()=>{l.unobserve(o),a.unsubscribe()}},[]);function r(){e.executeCommand(Z.id)}function s(){e.executeCommand(w.id)}return E.jsxs("div",{className:m.zenEditor,children:[E.jsxs("div",{className:m.zenEditorIconWrapper,children:[E.jsx("span",{className:F(m.zenEditorIconContainer,m.zenEditorIconError),onClick:r,children:E.jsx(ge,{style:{fontSize:"22px"}})}),E.jsx("span",{className:F(m.zenEditorIconContainer,m.zenEditorIconSuccess),onClick:s,children:E.jsx(fe,{style:{fontSize:"22px"}})})]}),E.jsx("div",{className:m.zenEditorCanvasContainer,ref:i})]})}const Ee={id:w.id,description:"shortcut.sheet.zen-edit-confirm",group:"4_sheet-edit",preconditions:i=>G(i),binding:h.KeyCode.ENTER|h.MetaKeys.ALT},me={id:Z.id,description:"shortcut.sheet.zen-edit-cancel",group:"4_sheet-edit",preconditions:i=>G(i),binding:h.KeyCode.ESC};function G(i){return i.getContextValue(c.FOCUSING_DOC)&&i.getContextValue(c.FOCUSING_UNIVER_EDITOR)&&i.getContextValue(c.EDITOR_ACTIVATED)}var Ce=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,ye=(i,t,n,e)=>{for(var r=e>1?void 0:e?Oe(t,n):t,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(e?o(t,n,r):o(r))||r);return e&&r&&Ce(t,n,r),r},z=(i,t)=>(n,e)=>t(n,e,i);let D=class extends c.Disposable{constructor(i,t,n,e,r){super(),this._injector=i,this._zenZoneService=t,this._commandService=n,this._menuService=e,this._shortcutService=r,this._initialize()}_initialize(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts()}_initCustomComponents(){this.disposeWithMe(this._zenZoneService.set(pe,Ie))}_initCommands(){[U,Z,w].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initMenus(){[ie].forEach(i=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)))})}_initShortcuts(){[Ee,me].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}};D=ye([c.OnLifecycle(c.LifecycleStages.Rendered,D),z(0,v.Inject(v.Injector)),z(1,h.IZenZoneService),z(2,c.ICommandService),z(3,h.IMenuService),z(4,h.IShortcutService)],D);const ze={shortcut:{sheet:{"zen-edit-cancel":"Cancel Zen Edit","zen-edit-confirm":"Confirm Zen Edit"}}},q={shortcut:{sheet:{"zen-edit-cancel":"取消编辑(禅模式状态)","zen-edit-confirm":"放弃编辑(禅模式状态)"}}};var Me=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,Re=(i,t,n,e)=>{for(var r=e>1?void 0:e?Te(t,n):t,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(e?o(t,n,r):o(r))||r);return e&&r&&Me(t,n,r),r},J=(i,t)=>(n,e)=>t(n,e,i);d.UniverSheetsZenEditorPlugin=(A=class extends c.Plugin{constructor(t,n,e){super("zen-editor"),this._injector=n,this._localeService=e,this._initialize(),this._initializeDependencies(this._injector)}_initialize(){this._localeService.load({zhCN:q})}_initializeDependencies(t){[[D],[R],[P,{useClass:Q}]].forEach(e=>t.add(e))}onRendered(){}onDestroy(){}},O(A,"type",c.PluginType.Doc),A),d.UniverSheetsZenEditorPlugin=Re([J(1,v.Inject(v.Injector)),J(2,v.Inject(c.LocaleService))],d.UniverSheetsZenEditorPlugin),d.enUS=ze,d.zhCN=q,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.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Zen Editor plugin for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -17,7 +17,12 @@
|
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/dream-num/univer/issues"
|
|
19
19
|
},
|
|
20
|
-
"keywords": [
|
|
20
|
+
"keywords": [
|
|
21
|
+
"univer"
|
|
22
|
+
],
|
|
23
|
+
"sideEffects": [
|
|
24
|
+
"**/*.css"
|
|
25
|
+
],
|
|
21
26
|
"exports": {
|
|
22
27
|
".": {
|
|
23
28
|
"import": "./lib/es/index.js",
|
|
@@ -48,19 +53,18 @@
|
|
|
48
53
|
"npm": ">=8.0.0"
|
|
49
54
|
},
|
|
50
55
|
"peerDependencies": {
|
|
51
|
-
"@wendellhu/redi": "
|
|
56
|
+
"@wendellhu/redi": "0.13.0",
|
|
52
57
|
"clsx": ">=2.0.0",
|
|
53
58
|
"react": ">=16.9.0",
|
|
54
59
|
"rxjs": ">=7.0.0",
|
|
55
|
-
"@univerjs/core": "0.1.
|
|
56
|
-
"@univerjs/docs": "0.1.
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/sheets-ui": "0.1.
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/ui": "0.1.2"
|
|
60
|
+
"@univerjs/core": "0.1.4",
|
|
61
|
+
"@univerjs/docs": "0.1.4",
|
|
62
|
+
"@univerjs/engine-render": "0.1.4",
|
|
63
|
+
"@univerjs/sheets-ui": "0.1.4",
|
|
64
|
+
"@univerjs/ui": "0.1.4"
|
|
61
65
|
},
|
|
62
66
|
"dependencies": {
|
|
63
|
-
"@univerjs/icons": "^0.1.
|
|
67
|
+
"@univerjs/icons": "^0.1.42"
|
|
64
68
|
},
|
|
65
69
|
"devDependencies": {
|
|
66
70
|
"@wendellhu/redi": "^0.13.0",
|
|
@@ -68,16 +72,16 @@
|
|
|
68
72
|
"less": "^4.2.0",
|
|
69
73
|
"react": "^18.2.0",
|
|
70
74
|
"rxjs": "^7.8.1",
|
|
71
|
-
"typescript": "^5.
|
|
72
|
-
"vite": "^5.1.
|
|
73
|
-
"vitest": "^1.
|
|
74
|
-
"@univerjs/core": "0.1.
|
|
75
|
-
"@univerjs/design": "0.1.
|
|
76
|
-
"@univerjs/
|
|
77
|
-
"@univerjs/
|
|
78
|
-
"@univerjs/sheets-ui": "0.1.
|
|
79
|
-
"@univerjs/
|
|
80
|
-
"@univerjs/
|
|
75
|
+
"typescript": "^5.4.2",
|
|
76
|
+
"vite": "^5.1.6",
|
|
77
|
+
"vitest": "^1.4.0",
|
|
78
|
+
"@univerjs/core": "0.1.4",
|
|
79
|
+
"@univerjs/design": "0.1.4",
|
|
80
|
+
"@univerjs/docs": "0.1.4",
|
|
81
|
+
"@univerjs/shared": "0.1.4",
|
|
82
|
+
"@univerjs/sheets-ui": "0.1.4",
|
|
83
|
+
"@univerjs/ui": "0.1.4",
|
|
84
|
+
"@univerjs/engine-render": "0.1.4"
|
|
81
85
|
},
|
|
82
86
|
"scripts": {
|
|
83
87
|
"test": "vitest run",
|