@univerjs/uniscript 0.1.0-beta.1 → 0.1.0-beta.3
Sign up to get free protection for your applications and to get access to all the features.
- package/{LICENSE.txt → LICENSE} +0 -2
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +133 -299
- package/lib/types/services/command/batch-command.service.d.ts +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +41 -38
- package/lib/types/facade/facade.d.ts +0 -25
- package/lib/types/facade/sheet/f-range.d.ts +0 -32
- package/lib/types/facade/sheet/f-selection.d.ts +0 -27
- package/lib/types/facade/sheet/f-workbook.d.ts +0 -26
- package/lib/types/facade/sheet/f-worksheet.d.ts +0 -32
package/{LICENSE.txt → LICENSE}
RENAMED
package/lib/cjs/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var W=Object.defineProperty;var z=(t,e,n)=>e in t?W(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var f=(t,e,n)=>(z(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),u=require("@wendellhu/redi"),d=require("@univerjs/ui"),$=require("rxjs"),v=require("react"),I=require("@univerjs/design"),h=require("@wendellhu/redi/react-bindings"),V=require("monaco-editor"),H=require("@univerjs/facade"),G=require("@univerjs/sheets"),J={"script-panel":{title:"Uniscript",tooltip:{"menu-button":"Toggle Uniscript Panel"},panel:{execute:"Execute Script"}},uniscript:{message:{success:"Execution Success",failed:"Execution Failed"}}},R={"script-panel":{title:"Uniscript",tooltip:{"menu-button":"打开收起 Uniscript 面板"},panel:{execute:"执行 Uniscript"}},uniscript:{message:{success:"执行成功",failed:"执行失败"}}};class T extends c.Disposable{constructor(){super(...arguments);f(this,"_open$",new $.BehaviorSubject(!1));f(this,"open$",this._open$.pipe($.distinctUntilChanged()))}get isOpen(){return this._open$.getValue()}dispose(){this._open$.next(!1),this._open$.complete()}open(){this._open$.next(!0)}close(){this._open$.next(!1)}}const M="ScriptPanel",q={type:c.CommandType.OPERATION,id:"univer.operation.toggle-script-panel",handler:t=>{const e=t.get(T),n=t.get(d.ISidebarService);return e.isOpen?(e.close(),n.close()):(e.open(),n.open({header:{title:"script-panel.title"},children:{label:M},width:600})),!0}};var N={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 Y=v,K=Symbol.for("react.element"),Q=Symbol.for("react.fragment"),X=Object.prototype.hasOwnProperty,Z=Y.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,k={key:!0,ref:!0,__self:!0,__source:!0};function A(t,e,n){var r,i={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)X.call(e,r)&&!k.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:K,type:t,key:s,ref:o,props:i,_owner:Z.current}}x.Fragment=Q;x.jsx=A;x.jsxs=A;N.exports=x;var g=N.exports;class j extends c.Disposable{constructor(n){super();f(this,"_editorInstance",null);this._config=n}setEditorInstance(n){return this._editorInstance=n,c.toDisposable(()=>this._editorInstance=null)}getEditorInstance(){return this._editorInstance}requireVscodeEditor(){window.MonacoEnvironment||(window.MonacoEnvironment={getWorkerUrl:this._config.getWorkerUrl})}}var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,ne=(t,e,n,r)=>{for(var i=r>1?void 0:r?te(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(i=(r?o(e,n,i):o(i))||i);return r&&i&&ee(e,n,i),i},w=(t,e)=>(n,r)=>e(n,r,t);let b=class extends c.Disposable{constructor(t,e){super(),this._logService=t,this._injector=e}async execute(t){this._logService.log("[UniscriptExecutionService]","executing Uniscript...");const e=H.FUniver.newAPI(this._injector),n=new Function("univerAPI",`(() => {${t}})()`);try{return n(e),!0}catch(r){return this._logService.error(r),!1}}};b=ne([w(0,c.ILogService),w(1,u.Inject(u.Injector))],b);const re="univer-script-editor-panel",ie="univer-script-editor-content",se="univer-script-editor-actions",E={scriptEditorPanel:re,scriptEditorContent:ie,scriptEditorActions:se};function oe(){const t=v.useRef(null),e=v.useRef(null),n=v.useRef(null),r=h.useDependency(c.LocaleService),i=h.useDependency(b),s=h.useDependency(d.IShortcutService),o=h.useDependency(j),U=h.useDependency(d.IMessageService);v.useEffect(()=>{const _=e.current,l=t.current;let p=null,S=null;if(_&&l){o.requireVscodeEditor();const m=n.current=V.editor.create(_,{value:"",language:"javascript"});S=new ResizeObserver(()=>{let C=requestIdleCallback(()=>{if(!C)return;const{height:F,width:B}=l.getBoundingClientRect();m.layout({width:B,height:F}),C=void 0})}),S.observe(l);let a;p=new c.DisposableCollection,p.add(o.setEditorInstance(m)),p.add(m.onDidFocusEditorWidget(()=>{a=s.forceEscape()})),p.add(m.onDidBlurEditorWidget(()=>{a==null||a.dispose(),a=void 0})),p.add(c.toDisposable(()=>a==null?void 0:a.dispose()))}return()=>{S&&l&&S.unobserve(l),p==null||p.dispose()}},[]);const L=v.useCallback(()=>{var l;const _=(l=n.current)==null?void 0:l.getModel();_&&i.execute(_.getValue()).then(()=>{U.show({content:r.t("uniscript.message.success"),type:I.MessageType.Success})}).catch(()=>{U.show({content:r.t("uniscript.message.failed"),type:I.MessageType.Error})})},[i]);return g.jsxs("div",{className:E.scriptEditorPanel,children:[g.jsx("div",{className:E.scriptEditorContent,ref:t,children:g.jsx("div",{className:E.scriptEditorContainer,ref:e})}),g.jsx("div",{className:E.scriptEditorActions,children:g.jsx(I.Button,{type:"primary",size:"small",onClick:L,children:r.t("script-panel.panel.execute")})})]})}function ce(t){return{id:q.id,title:"toggle-script-panel",tooltip:"script-panel.tooltip.menu-button",icon:"CodeSingle",type:d.MenuItemType.BUTTON,positions:[d.MenuPosition.TOOLBAR_START],hidden$:d.getMenuHiddenObservable(t,c.UniverInstanceType.SHEET),disabled$:G.getCurrentSheetDisabled$(t)}}var le=Object.defineProperty,pe=Object.getOwnPropertyDescriptor,ae=(t,e,n,r)=>{for(var i=r>1?void 0:r?pe(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(i=(r?o(e,n,i):o(i))||i);return r&&i&&le(e,n,i),i},P=(t,e)=>(n,r)=>e(n,r,t);let y=class extends c.Disposable{constructor(t,e,n,r){super(),this._injector=t,this.disposeWithMe(e.addMenuItem(this._injector.invoke(ce))),this.disposeWithMe(r.register(M,oe)),this.disposeWithMe(n.registerCommand(q))}};y=ae([c.OnLifecycle(c.LifecycleStages.Steady,y),P(0,u.Inject(u.Injector)),P(1,d.IMenuService),P(2,c.ICommandService),P(3,u.Inject(d.ComponentManager))],y);var ue=Object.defineProperty,de=Object.getOwnPropertyDescriptor,ve=(t,e,n,r)=>{for(var i=r>1?void 0:r?de(e,n):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(i=(r?o(e,n,i):o(i))||i);return r&&i&&ue(e,n,i),i},D=(t,e)=>(n,r)=>e(n,r,t);const _e="uniscript";var O;exports.UniverUniscriptPlugin=(O=class extends c.Plugin{constructor(e,n,r){super(_e),this._config=e,this._injector=n,this._localeService=r}onStarting(e){[[y],[j,{useFactory:()=>e.createInstance(j,this._config)}],[T],[b]].forEach(r=>e.add(r)),this._localeService.load({zhCN:R})}},f(O,"type",c.PluginType.Univer),O);exports.UniverUniscriptPlugin=ve([D(1,u.Inject(u.Injector)),D(2,u.Inject(c.LocaleService))],exports.UniverUniscriptPlugin);exports.enUS=J;exports.zhCN=R;
|
package/lib/es/index.js
CHANGED
@@ -1,16 +1,17 @@
|
|
1
|
-
var
|
2
|
-
var
|
3
|
-
var
|
4
|
-
import { Disposable as
|
5
|
-
import { Inject as
|
6
|
-
import { ISidebarService as
|
7
|
-
import { BehaviorSubject as
|
8
|
-
import
|
9
|
-
import { MessageType as
|
1
|
+
var z = Object.defineProperty;
|
2
|
+
var V = (t, e, r) => e in t ? z(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
3
|
+
var u = (t, e, r) => (V(t, typeof e != "symbol" ? e + "" : e, r), r);
|
4
|
+
import { Disposable as P, CommandType as H, toDisposable as T, ILogService as G, LocaleService as M, DisposableCollection as J, UniverInstanceType as Y, OnLifecycle as K, LifecycleStages as Q, ICommandService as X, Plugin as Z, PluginType as k } from "@univerjs/core";
|
5
|
+
import { Inject as f, Injector as I } from "@wendellhu/redi";
|
6
|
+
import { ISidebarService as ee, IShortcutService as te, IMessageService as re, MenuItemType as ie, MenuPosition as ne, getMenuHiddenObservable as oe, ComponentManager as se, IMenuService as ce } from "@univerjs/ui";
|
7
|
+
import { BehaviorSubject as le, distinctUntilChanged as pe } from "rxjs";
|
8
|
+
import ae, { useRef as O, useEffect as ue, useCallback as de } from "react";
|
9
|
+
import { MessageType as $, Button as ve } from "@univerjs/design";
|
10
10
|
import { useDependency as d } from "@wendellhu/redi/react-bindings";
|
11
|
-
import { editor as
|
12
|
-
import {
|
13
|
-
|
11
|
+
import { editor as fe } from "monaco-editor";
|
12
|
+
import { FUniver as _e } from "@univerjs/facade";
|
13
|
+
import { getCurrentSheetDisabled$ as me } from "@univerjs/sheets";
|
14
|
+
const Qe = {
|
14
15
|
"script-panel": {
|
15
16
|
title: "Uniscript",
|
16
17
|
tooltip: {
|
@@ -26,7 +27,7 @@ const jt = {
|
|
26
27
|
failed: "Execution Failed"
|
27
28
|
}
|
28
29
|
}
|
29
|
-
},
|
30
|
+
}, he = {
|
30
31
|
"script-panel": {
|
31
32
|
title: "Uniscript",
|
32
33
|
tooltip: {
|
@@ -43,11 +44,11 @@ const jt = {
|
|
43
44
|
}
|
44
45
|
}
|
45
46
|
};
|
46
|
-
class
|
47
|
+
class D extends P {
|
47
48
|
constructor() {
|
48
49
|
super(...arguments);
|
49
|
-
|
50
|
-
|
50
|
+
u(this, "_open$", new le(!1));
|
51
|
+
u(this, "open$", this._open$.pipe(pe()));
|
51
52
|
}
|
52
53
|
get isOpen() {
|
53
54
|
return this._open$.getValue();
|
@@ -62,19 +63,19 @@ class V extends O {
|
|
62
63
|
this._open$.next(!1);
|
63
64
|
}
|
64
65
|
}
|
65
|
-
const
|
66
|
-
type:
|
66
|
+
const N = "ScriptPanel", A = {
|
67
|
+
type: H.OPERATION,
|
67
68
|
id: "univer.operation.toggle-script-panel",
|
68
69
|
handler: (t) => {
|
69
|
-
const e = t.get(
|
70
|
+
const e = t.get(D), r = t.get(ee);
|
70
71
|
return e.isOpen ? (e.close(), r.close()) : (e.open(), r.open({
|
71
72
|
header: { title: "script-panel.title" },
|
72
|
-
children: { label:
|
73
|
+
children: { label: N },
|
73
74
|
width: 600
|
74
75
|
})), !0;
|
75
76
|
}
|
76
77
|
};
|
77
|
-
var
|
78
|
+
var F = { exports: {} }, x = {};
|
78
79
|
/**
|
79
80
|
* @license React
|
80
81
|
* react-jsx-runtime.production.min.js
|
@@ -84,30 +85,30 @@ var J = { exports: {} }, j = {};
|
|
84
85
|
* This source code is licensed under the MIT license found in the
|
85
86
|
* LICENSE file in the root directory of this source tree.
|
86
87
|
*/
|
87
|
-
var
|
88
|
-
function
|
89
|
-
var
|
90
|
-
r !== void 0 && (
|
91
|
-
for (
|
92
|
-
|
88
|
+
var ge = ae, Se = Symbol.for("react.element"), Ee = Symbol.for("react.fragment"), Pe = Object.prototype.hasOwnProperty, xe = ge.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, Oe = { key: !0, ref: !0, __self: !0, __source: !0 };
|
89
|
+
function L(t, e, r) {
|
90
|
+
var i, n = {}, o = null, s = null;
|
91
|
+
r !== void 0 && (o = "" + r), e.key !== void 0 && (o = "" + e.key), e.ref !== void 0 && (s = e.ref);
|
92
|
+
for (i in e)
|
93
|
+
Pe.call(e, i) && !Oe.hasOwnProperty(i) && (n[i] = e[i]);
|
93
94
|
if (t && t.defaultProps)
|
94
|
-
for (
|
95
|
-
|
96
|
-
return { $$typeof:
|
95
|
+
for (i in e = t.defaultProps, e)
|
96
|
+
n[i] === void 0 && (n[i] = e[i]);
|
97
|
+
return { $$typeof: Se, type: t, key: o, ref: s, props: n, _owner: xe.current };
|
97
98
|
}
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
var v =
|
103
|
-
class
|
99
|
+
x.Fragment = Ee;
|
100
|
+
x.jsx = L;
|
101
|
+
x.jsxs = L;
|
102
|
+
F.exports = x;
|
103
|
+
var v = F.exports;
|
104
|
+
class b extends P {
|
104
105
|
constructor(r) {
|
105
106
|
super();
|
106
|
-
|
107
|
+
u(this, "_editorInstance", null);
|
107
108
|
this._config = r;
|
108
109
|
}
|
109
110
|
setEditorInstance(r) {
|
110
|
-
return this._editorInstance = r,
|
111
|
+
return this._editorInstance = r, T(() => this._editorInstance = null);
|
111
112
|
}
|
112
113
|
getEditorInstance() {
|
113
114
|
return this._editorInstance;
|
@@ -118,314 +119,147 @@ class U extends O {
|
|
118
119
|
});
|
119
120
|
}
|
120
121
|
}
|
121
|
-
var
|
122
|
-
for (var
|
123
|
-
(s = t[
|
124
|
-
return
|
125
|
-
},
|
126
|
-
let
|
127
|
-
constructor(t, e, r, n, o) {
|
128
|
-
this._workbook = t, this._worksheet = e, this._range = r, this._injector = n, this._commandService = o;
|
129
|
-
}
|
130
|
-
getRow() {
|
131
|
-
return this._range.startRow;
|
132
|
-
}
|
133
|
-
getColumn() {
|
134
|
-
return this._range.startColumn;
|
135
|
-
}
|
136
|
-
getWidth() {
|
137
|
-
return this._range.endColumn - this._range.startColumn + 1;
|
138
|
-
}
|
139
|
-
getHeight() {
|
140
|
-
return this._range.endRow - this._range.startRow + 1;
|
141
|
-
}
|
142
|
-
getValue() {
|
143
|
-
var t;
|
144
|
-
return ((t = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) == null ? void 0 : t.v) ?? null;
|
145
|
-
}
|
146
|
-
setBackgroundColor(t) {
|
147
|
-
this._commandService.executeCommand(je.id, {
|
148
|
-
unitId: this._workbook.getUnitId(),
|
149
|
-
subUnitId: this._worksheet.getSheetId(),
|
150
|
-
range: this._range,
|
151
|
-
style: {
|
152
|
-
type: "bg",
|
153
|
-
value: {
|
154
|
-
rgb: t
|
155
|
-
}
|
156
|
-
}
|
157
|
-
});
|
158
|
-
}
|
159
|
-
};
|
160
|
-
b = Be([
|
161
|
-
W(3, c(p)),
|
162
|
-
W(4, E)
|
163
|
-
], b);
|
164
|
-
var He = Object.defineProperty, qe = Object.getOwnPropertyDescriptor, Ve = (t, e, r, n) => {
|
165
|
-
for (var o = n > 1 ? void 0 : n ? qe(e, r) : e, i = t.length - 1, s; i >= 0; i--)
|
166
|
-
(s = t[i]) && (o = (n ? s(e, r, o) : s(o)) || o);
|
167
|
-
return n && o && He(e, r, o), o;
|
168
|
-
}, ze = (t, e) => (r, n) => e(r, n, t);
|
169
|
-
let R = class {
|
170
|
-
constructor(t, e, r, n) {
|
171
|
-
this._workbook = t, this._worksheet = e, this._selections = r, this._injector = n;
|
172
|
-
}
|
173
|
-
getActiveRange() {
|
174
|
-
const t = this._selections.find((e) => !!e.primary);
|
175
|
-
return t ? this._injector.createInstance(b, this._workbook, this._worksheet, t.range) : null;
|
176
|
-
}
|
177
|
-
};
|
178
|
-
R = Ve([
|
179
|
-
ze(3, c(p))
|
180
|
-
], R);
|
181
|
-
var Ge = Object.defineProperty, Je = Object.getOwnPropertyDescriptor, Ke = (t, e, r, n) => {
|
182
|
-
for (var o = n > 1 ? void 0 : n ? Je(e, r) : e, i = t.length - 1, s; i >= 0; i--)
|
183
|
-
(s = t[i]) && (o = (n ? s(e, r, o) : s(o)) || o);
|
184
|
-
return n && o && Ge(e, r, o), o;
|
185
|
-
}, x = (t, e) => (r, n) => e(r, n, t);
|
186
|
-
let I = class {
|
187
|
-
constructor(t, e, r, n, o) {
|
188
|
-
this._workbook = t, this._worksheet = e, this._injector = r, this._selectionManagerService = n, this._commandService = o;
|
189
|
-
}
|
190
|
-
getSelection() {
|
191
|
-
const t = this._selectionManagerService.getSelections();
|
192
|
-
return t ? this._injector.createInstance(R, this._workbook, this._worksheet, t) : null;
|
193
|
-
}
|
194
|
-
getRange(t, e, r, n) {
|
195
|
-
const o = {
|
196
|
-
startRow: t,
|
197
|
-
endRow: t + (r ?? 1) - 1,
|
198
|
-
startColumn: e,
|
199
|
-
endColumn: e + (n ?? 1) - 1
|
200
|
-
};
|
201
|
-
return this._injector.createInstance(b, this._workbook, this._worksheet, o);
|
202
|
-
}
|
203
|
-
setRowHeights(t, e, r) {
|
204
|
-
this._commandService.syncExecuteCommand($e.id, {
|
205
|
-
unitId: this._workbook.getUnitId(),
|
206
|
-
subUnitId: this._worksheet.getSheetId(),
|
207
|
-
ranges: [
|
208
|
-
{
|
209
|
-
startRow: t,
|
210
|
-
endRow: t + e - 1,
|
211
|
-
startColumn: 0,
|
212
|
-
endColumn: this._worksheet.getColumnCount() - 1
|
213
|
-
}
|
214
|
-
],
|
215
|
-
rowHeight: r
|
216
|
-
});
|
217
|
-
}
|
218
|
-
setColumnWidths(t, e, r) {
|
219
|
-
this._commandService.syncExecuteCommand(xe.id, {
|
220
|
-
unitId: this._workbook.getUnitId(),
|
221
|
-
subUnitId: this._worksheet.getSheetId(),
|
222
|
-
ranges: [
|
223
|
-
{
|
224
|
-
startColumn: t,
|
225
|
-
endColumn: t + e - 1,
|
226
|
-
startRow: 0,
|
227
|
-
endRow: this._worksheet.getRowCount() - 1
|
228
|
-
}
|
229
|
-
],
|
230
|
-
colWidth: r
|
231
|
-
});
|
232
|
-
}
|
233
|
-
};
|
234
|
-
I = Ke([
|
235
|
-
x(2, c(p)),
|
236
|
-
x(3, c(ye)),
|
237
|
-
x(4, E)
|
238
|
-
], I);
|
239
|
-
var Ye = Object.defineProperty, Qe = Object.getOwnPropertyDescriptor, Xe = (t, e, r, n) => {
|
240
|
-
for (var o = n > 1 ? void 0 : n ? Qe(e, r) : e, i = t.length - 1, s; i >= 0; i--)
|
241
|
-
(s = t[i]) && (o = (n ? s(e, r, o) : s(o)) || o);
|
242
|
-
return n && o && Ye(e, r, o), o;
|
243
|
-
}, A = (t, e) => (r, n) => e(r, n, t);
|
244
|
-
let k = class {
|
245
|
-
constructor(t, e, r) {
|
246
|
-
this._workbook = t, this._injector = e, this._commandService = r;
|
247
|
-
}
|
248
|
-
getActiveSheet() {
|
249
|
-
const t = this._workbook.getActiveSheet();
|
250
|
-
return t ? this._injector.createInstance(I, this._workbook, t) : null;
|
251
|
-
}
|
252
|
-
create(t, e, r) {
|
253
|
-
const n = re.deepClone(ne);
|
254
|
-
return n.rowCount = e, n.columnCount = r, n.name = t, n.id = t.toLowerCase().replace(/ /g, "-"), this._commandService.syncExecuteCommand(Ue.id, {
|
255
|
-
unitId: this._workbook.getUnitId(),
|
256
|
-
index: this._workbook.getSheets().length,
|
257
|
-
sheet: n
|
258
|
-
}), this._commandService.syncExecuteCommand(Re.id, {
|
259
|
-
unitId: this._workbook.getUnitId(),
|
260
|
-
subUnitId: this._workbook.getSheets()[this._workbook.getSheets().length - 1].getSheetId()
|
261
|
-
}), this._injector.createInstance(I, this._workbook, this._workbook.getActiveSheet());
|
262
|
-
}
|
263
|
-
};
|
264
|
-
k = Xe([
|
265
|
-
A(1, c(p)),
|
266
|
-
A(2, E)
|
267
|
-
], k);
|
268
|
-
var Ze = Object.defineProperty, et = Object.getOwnPropertyDescriptor, tt = (t, e, r, n) => {
|
269
|
-
for (var o = n > 1 ? void 0 : n ? et(e, r) : e, i = t.length - 1, s; i >= 0; i--)
|
270
|
-
(s = t[i]) && (o = (n ? s(e, r, o) : s(o)) || o);
|
271
|
-
return n && o && Ze(e, r, o), o;
|
272
|
-
}, F = (t, e) => (r, n) => e(r, n, t);
|
273
|
-
let P = class {
|
274
|
-
constructor(t, e) {
|
275
|
-
this._injector = t, this._univerInstanceService = e;
|
276
|
-
}
|
277
|
-
static newInstance(t) {
|
278
|
-
return t.createInstance(P);
|
279
|
-
}
|
280
|
-
getCurrentSheet() {
|
281
|
-
const t = this._univerInstanceService.getCurrentUniverSheetInstance();
|
282
|
-
return t ? this._injector.createInstance(k, t) : null;
|
283
|
-
}
|
284
|
-
};
|
285
|
-
P = tt([
|
286
|
-
F(0, c(p)),
|
287
|
-
F(1, oe)
|
288
|
-
], P);
|
289
|
-
var rt = Object.defineProperty, nt = Object.getOwnPropertyDescriptor, ot = (t, e, r, n) => {
|
290
|
-
for (var o = n > 1 ? void 0 : n ? nt(e, r) : e, i = t.length - 1, s; i >= 0; i--)
|
291
|
-
(s = t[i]) && (o = (n ? s(e, r, o) : s(o)) || o);
|
292
|
-
return n && o && rt(e, r, o), o;
|
293
|
-
}, N = (t, e) => (r, n) => e(r, n, t);
|
294
|
-
let C = class extends O {
|
122
|
+
var ye = Object.defineProperty, be = Object.getOwnPropertyDescriptor, Ie = (t, e, r, i) => {
|
123
|
+
for (var n = i > 1 ? void 0 : i ? be(e, r) : e, o = t.length - 1, s; o >= 0; o--)
|
124
|
+
(s = t[o]) && (n = (i ? s(e, r, n) : s(n)) || n);
|
125
|
+
return i && n && ye(e, r, n), n;
|
126
|
+
}, w = (t, e) => (r, i) => e(r, i, t);
|
127
|
+
let E = class extends P {
|
295
128
|
constructor(t, e) {
|
296
129
|
super(), this._logService = t, this._injector = e;
|
297
130
|
}
|
298
131
|
async execute(t) {
|
299
132
|
this._logService.log("[UniscriptExecutionService]", "executing Uniscript...");
|
300
|
-
const e =
|
133
|
+
const e = _e.newAPI(this._injector), r = new Function("univerAPI", `(() => {${t}})()`);
|
301
134
|
try {
|
302
135
|
return r(e), !0;
|
303
|
-
} catch (
|
304
|
-
return this._logService.error(
|
136
|
+
} catch (i) {
|
137
|
+
return this._logService.error(i), !1;
|
305
138
|
}
|
306
139
|
}
|
307
140
|
};
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
],
|
312
|
-
const
|
313
|
-
scriptEditorPanel:
|
314
|
-
scriptEditorContent:
|
315
|
-
scriptEditorActions:
|
141
|
+
E = Ie([
|
142
|
+
w(0, G),
|
143
|
+
w(1, f(I))
|
144
|
+
], E);
|
145
|
+
const Ce = "univer-script-editor-panel", je = "univer-script-editor-content", $e = "univer-script-editor-actions", h = {
|
146
|
+
scriptEditorPanel: Ce,
|
147
|
+
scriptEditorContent: je,
|
148
|
+
scriptEditorActions: $e
|
316
149
|
};
|
317
|
-
function
|
318
|
-
const t =
|
319
|
-
|
320
|
-
const
|
321
|
-
let l = null,
|
322
|
-
if (
|
150
|
+
function we() {
|
151
|
+
const t = O(null), e = O(null), r = O(null), i = d(M), n = d(E), o = d(te), s = d(b), C = d(re);
|
152
|
+
ue(() => {
|
153
|
+
const a = e.current, c = t.current;
|
154
|
+
let l = null, _ = null;
|
155
|
+
if (a && c) {
|
323
156
|
s.requireVscodeEditor();
|
324
|
-
const
|
157
|
+
const m = r.current = fe.create(a, {
|
325
158
|
value: "",
|
326
159
|
language: "javascript"
|
327
160
|
});
|
328
|
-
|
329
|
-
let
|
330
|
-
if (!
|
161
|
+
_ = new ResizeObserver(() => {
|
162
|
+
let j = requestIdleCallback(() => {
|
163
|
+
if (!j)
|
331
164
|
return;
|
332
|
-
const { height:
|
333
|
-
|
165
|
+
const { height: B, width: q } = c.getBoundingClientRect();
|
166
|
+
m.layout({ width: q, height: B }), j = void 0;
|
334
167
|
});
|
335
|
-
}),
|
336
|
-
let
|
337
|
-
l = new
|
338
|
-
|
339
|
-
|
168
|
+
}), _.observe(c);
|
169
|
+
let p;
|
170
|
+
l = new J(), l.add(s.setEditorInstance(m)), l.add(
|
171
|
+
m.onDidFocusEditorWidget(() => {
|
172
|
+
p = o.forceEscape();
|
340
173
|
})
|
341
174
|
), l.add(
|
342
|
-
|
343
|
-
|
175
|
+
m.onDidBlurEditorWidget(() => {
|
176
|
+
p == null || p.dispose(), p = void 0;
|
344
177
|
})
|
345
|
-
), l.add(
|
178
|
+
), l.add(T(() => p == null ? void 0 : p.dispose()));
|
346
179
|
}
|
347
180
|
return () => {
|
348
|
-
|
181
|
+
_ && c && _.unobserve(c), l == null || l.dispose();
|
349
182
|
};
|
350
183
|
}, []);
|
351
|
-
const
|
352
|
-
var
|
353
|
-
const
|
354
|
-
|
355
|
-
|
356
|
-
content:
|
357
|
-
type:
|
184
|
+
const W = de(() => {
|
185
|
+
var c;
|
186
|
+
const a = (c = r.current) == null ? void 0 : c.getModel();
|
187
|
+
a && n.execute(a.getValue()).then(() => {
|
188
|
+
C.show({
|
189
|
+
content: i.t("uniscript.message.success"),
|
190
|
+
type: $.Success
|
358
191
|
});
|
359
192
|
}).catch(() => {
|
360
|
-
|
361
|
-
content:
|
362
|
-
type:
|
193
|
+
C.show({
|
194
|
+
content: i.t("uniscript.message.failed"),
|
195
|
+
type: $.Error
|
363
196
|
});
|
364
197
|
});
|
365
|
-
}, [
|
366
|
-
return /* @__PURE__ */ v.jsxs("div", { className:
|
367
|
-
/* @__PURE__ */ v.jsx("div", { className:
|
368
|
-
/* @__PURE__ */ v.jsx("div", { className:
|
198
|
+
}, [n]);
|
199
|
+
return /* @__PURE__ */ v.jsxs("div", { className: h.scriptEditorPanel, children: [
|
200
|
+
/* @__PURE__ */ v.jsx("div", { className: h.scriptEditorContent, ref: t, children: /* @__PURE__ */ v.jsx("div", { className: h.scriptEditorContainer, ref: e }) }),
|
201
|
+
/* @__PURE__ */ v.jsx("div", { className: h.scriptEditorActions, children: /* @__PURE__ */ v.jsx(ve, { type: "primary", size: "small", onClick: W, children: i.t("script-panel.panel.execute") }) })
|
369
202
|
] });
|
370
203
|
}
|
371
|
-
function
|
204
|
+
function Ue(t) {
|
372
205
|
return {
|
373
|
-
id:
|
206
|
+
id: A.id,
|
374
207
|
title: "toggle-script-panel",
|
375
208
|
tooltip: "script-panel.tooltip.menu-button",
|
376
209
|
icon: "CodeSingle",
|
377
|
-
type:
|
378
|
-
positions: [
|
379
|
-
hidden$:
|
210
|
+
type: ie.BUTTON,
|
211
|
+
positions: [ne.TOOLBAR_START],
|
212
|
+
hidden$: oe(t, Y.SHEET),
|
213
|
+
disabled$: me(t)
|
380
214
|
};
|
381
215
|
}
|
382
|
-
var
|
383
|
-
for (var
|
384
|
-
(s = t[
|
385
|
-
return
|
386
|
-
},
|
387
|
-
let
|
388
|
-
constructor(t, e, r,
|
389
|
-
super(), this._injector = t, this.disposeWithMe(e.addMenuItem(this._injector.invoke(
|
216
|
+
var Re = Object.defineProperty, Te = Object.getOwnPropertyDescriptor, Me = (t, e, r, i) => {
|
217
|
+
for (var n = i > 1 ? void 0 : i ? Te(e, r) : e, o = t.length - 1, s; o >= 0; o--)
|
218
|
+
(s = t[o]) && (n = (i ? s(e, r, n) : s(n)) || n);
|
219
|
+
return i && n && Re(e, r, n), n;
|
220
|
+
}, g = (t, e) => (r, i) => e(r, i, t);
|
221
|
+
let S = class extends P {
|
222
|
+
constructor(t, e, r, i) {
|
223
|
+
super(), this._injector = t, this.disposeWithMe(e.addMenuItem(this._injector.invoke(Ue))), this.disposeWithMe(i.register(N, we)), this.disposeWithMe(r.registerCommand(A));
|
390
224
|
}
|
391
225
|
};
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
],
|
399
|
-
var
|
400
|
-
for (var
|
401
|
-
(s = t[
|
402
|
-
return
|
403
|
-
},
|
404
|
-
const
|
226
|
+
S = Me([
|
227
|
+
K(Q.Steady, S),
|
228
|
+
g(0, f(I)),
|
229
|
+
g(1, ce),
|
230
|
+
g(2, X),
|
231
|
+
g(3, f(se))
|
232
|
+
], S);
|
233
|
+
var De = Object.defineProperty, Ne = Object.getOwnPropertyDescriptor, Ae = (t, e, r, i) => {
|
234
|
+
for (var n = i > 1 ? void 0 : i ? Ne(e, r) : e, o = t.length - 1, s; o >= 0; o--)
|
235
|
+
(s = t[o]) && (n = (i ? s(e, r, n) : s(n)) || n);
|
236
|
+
return i && n && De(e, r, n), n;
|
237
|
+
}, U = (t, e) => (r, i) => e(r, i, t);
|
238
|
+
const Fe = "uniscript";
|
405
239
|
var y;
|
406
|
-
let
|
240
|
+
let R = (y = class extends Z {
|
407
241
|
constructor(t, e, r) {
|
408
|
-
super(
|
242
|
+
super(Fe), this._config = t, this._injector = e, this._localeService = r;
|
409
243
|
}
|
410
244
|
onStarting(t) {
|
411
245
|
[
|
412
246
|
// controllers
|
413
|
-
[
|
247
|
+
[S],
|
414
248
|
// services
|
415
|
-
[
|
416
|
-
[
|
417
|
-
[
|
249
|
+
[b, { useFactory: () => t.createInstance(b, this._config) }],
|
250
|
+
[D],
|
251
|
+
[E]
|
418
252
|
].forEach((r) => t.add(r)), this._localeService.load({
|
419
|
-
zhCN:
|
253
|
+
zhCN: he
|
420
254
|
});
|
421
255
|
}
|
422
|
-
},
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
],
|
256
|
+
}, u(y, "type", k.Univer), y);
|
257
|
+
R = Ae([
|
258
|
+
U(1, f(I)),
|
259
|
+
U(2, f(M))
|
260
|
+
], R);
|
427
261
|
export {
|
428
|
-
|
429
|
-
|
430
|
-
|
262
|
+
R as UniverUniscriptPlugin,
|
263
|
+
Qe as enUS,
|
264
|
+
he as zhCN
|
431
265
|
};
|
@@ -18,7 +18,7 @@ import type { IDisposable } from '@wendellhu/redi';
|
|
18
18
|
export declare class BatchCommandService implements ICommandService {
|
19
19
|
beforeCommandExecuted(listener: CommandListener): IDisposable;
|
20
20
|
registerCommand(command: ICommand<object, boolean>): IDisposable;
|
21
|
-
|
21
|
+
registerMultipleCommand(command: ICommand<object, boolean>): IDisposable;
|
22
22
|
executeCommand<P extends object = object, R = boolean>(id: string, params?: P | undefined, options?: IExecutionOptions | undefined): Promise<R>;
|
23
23
|
syncExecuteCommand<P extends object = object, R = boolean>(id: string, params?: P | undefined, options?: IExecutionOptions | undefined): R;
|
24
24
|
onCommandExecuted(listener: CommandListener): IDisposable;
|
package/lib/umd/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
(function(
|
1
|
+
(function(o,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings"),require("monaco-editor"),require("@univerjs/facade"),require("@univerjs/sheets")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","react","@univerjs/design","@wendellhu/redi/react-bindings","monaco-editor","@univerjs/facade","@univerjs/sheets"],s):(o=typeof globalThis<"u"?globalThis:o||self,s(o.UniverUniscript={},o.UniverCore,o["@wendellhu/redi"],o.UniverUi,o.rxjs,o.React,o.UniverDesign,o["@wendellhu/redi/react-bindings"],o.monaco,o.UniverFacade,o.UniverSheets))})(this,function(o,s,l,u,w,f,O,h,q,W,z){"use strict";var ae=Object.defineProperty;var de=(o,s,l)=>s in o?ae(o,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):o[s]=l;var m=(o,s,l)=>(de(o,typeof s!="symbol"?s+"":s,l),l);var b;const V={"script-panel":{title:"Uniscript",tooltip:{"menu-button":"Toggle Uniscript Panel"},panel:{execute:"Execute Script"}},uniscript:{message:{success:"Execution Success",failed:"Execution Failed"}}},C={"script-panel":{title:"Uniscript",tooltip:{"menu-button":"打开收起 Uniscript 面板"},panel:{execute:"执行 Uniscript"}},uniscript:{message:{success:"执行成功",failed:"执行失败"}}};class D extends s.Disposable{constructor(){super(...arguments);m(this,"_open$",new w.BehaviorSubject(!1));m(this,"open$",this._open$.pipe(w.distinctUntilChanged()))}get isOpen(){return this._open$.getValue()}dispose(){this._open$.next(!1),this._open$.complete()}open(){this._open$.next(!0)}close(){this._open$.next(!1)}}const T="ScriptPanel",R={type:s.CommandType.OPERATION,id:"univer.operation.toggle-script-panel",handler:n=>{const e=n.get(D),i=n.get(u.ISidebarService);return e.isOpen?(e.close(),i.close()):(e.open(),i.open({header:{title:"script-panel.title"},children:{label:T},width:600})),!0}};var M={exports:{}},g={};/**
|
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 B=f,H=Symbol.for("react.element"),G=Symbol.for("react.fragment"),J=Object.prototype.hasOwnProperty,Y=B.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,K={key:!0,ref:!0,__self:!0,__source:!0};function N(n,e,i){var t,r={},c=null,p=null;i!==void 0&&(c=""+i),e.key!==void 0&&(c=""+e.key),e.ref!==void 0&&(p=e.ref);for(t in e)J.call(e,t)&&!K.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:H,type:n,key:c,ref:p,props:r,_owner:Y.current}}g.Fragment=G,g.jsx=N,g.jsxs=N,M.exports=g;var _=M.exports;class x extends s.Disposable{constructor(i){super();m(this,"_editorInstance",null);this._config=i}setEditorInstance(i){return this._editorInstance=i,s.toDisposable(()=>this._editorInstance=null)}getEditorInstance(){return this._editorInstance}requireVscodeEditor(){window.MonacoEnvironment||(window.MonacoEnvironment={getWorkerUrl:this._config.getWorkerUrl})}}var Q=Object.defineProperty,X=Object.getOwnPropertyDescriptor,Z=(n,e,i,t)=>{for(var r=t>1?void 0:t?X(e,i):e,c=n.length-1,p;c>=0;c--)(p=n[c])&&(r=(t?p(e,i,r):p(r))||r);return t&&r&&Q(e,i,r),r},$=(n,e)=>(i,t)=>e(i,t,n);let E=class extends s.Disposable{constructor(n,e){super(),this._logService=n,this._injector=e}async execute(n){this._logService.log("[UniscriptExecutionService]","executing Uniscript...");const e=W.FUniver.newAPI(this._injector),i=new Function("univerAPI",`(() => {${n}})()`);try{return i(e),!0}catch(t){return this._logService.error(t),!1}}};E=Z([$(0,s.ILogService),$(1,l.Inject(l.Injector))],E);const j={scriptEditorPanel:"univer-script-editor-panel",scriptEditorContent:"univer-script-editor-content",scriptEditorActions:"univer-script-editor-actions"};function k(){const n=f.useRef(null),e=f.useRef(null),i=f.useRef(null),t=h.useDependency(s.LocaleService),r=h.useDependency(E),c=h.useDependency(u.IShortcutService),p=h.useDependency(x),F=h.useDependency(u.IMessageService);f.useEffect(()=>{const S=e.current,a=n.current;let d=null,U=null;if(S&&a){p.requireVscodeEditor();const I=i.current=q.editor.create(S,{value:"",language:"javascript"});U=new ResizeObserver(()=>{let L=requestIdleCallback(()=>{if(!L)return;const{height:le,width:ue}=a.getBoundingClientRect();I.layout({width:ue,height:le}),L=void 0})}),U.observe(a);let v;d=new s.DisposableCollection,d.add(p.setEditorInstance(I)),d.add(I.onDidFocusEditorWidget(()=>{v=c.forceEscape()})),d.add(I.onDidBlurEditorWidget(()=>{v==null||v.dispose(),v=void 0})),d.add(s.toDisposable(()=>v==null?void 0:v.dispose()))}return()=>{U&&a&&U.unobserve(a),d==null||d.dispose()}},[]);const pe=f.useCallback(()=>{var a;const S=(a=i.current)==null?void 0:a.getModel();S&&r.execute(S.getValue()).then(()=>{F.show({content:t.t("uniscript.message.success"),type:O.MessageType.Success})}).catch(()=>{F.show({content:t.t("uniscript.message.failed"),type:O.MessageType.Error})})},[r]);return _.jsxs("div",{className:j.scriptEditorPanel,children:[_.jsx("div",{className:j.scriptEditorContent,ref:n,children:_.jsx("div",{className:j.scriptEditorContainer,ref:e})}),_.jsx("div",{className:j.scriptEditorActions,children:_.jsx(O.Button,{type:"primary",size:"small",onClick:pe,children:t.t("script-panel.panel.execute")})})]})}function ee(n){return{id:R.id,title:"toggle-script-panel",tooltip:"script-panel.tooltip.menu-button",icon:"CodeSingle",type:u.MenuItemType.BUTTON,positions:[u.MenuPosition.TOOLBAR_START],hidden$:u.getMenuHiddenObservable(n,s.UniverInstanceType.SHEET),disabled$:z.getCurrentSheetDisabled$(n)}}var te=Object.defineProperty,ne=Object.getOwnPropertyDescriptor,ie=(n,e,i,t)=>{for(var r=t>1?void 0:t?ne(e,i):e,c=n.length-1,p;c>=0;c--)(p=n[c])&&(r=(t?p(e,i,r):p(r))||r);return t&&r&&te(e,i,r),r},y=(n,e)=>(i,t)=>e(i,t,n);let P=class extends s.Disposable{constructor(n,e,i,t){super(),this._injector=n,this.disposeWithMe(e.addMenuItem(this._injector.invoke(ee))),this.disposeWithMe(t.register(T,k)),this.disposeWithMe(i.registerCommand(R))}};P=ie([s.OnLifecycle(s.LifecycleStages.Steady,P),y(0,l.Inject(l.Injector)),y(1,u.IMenuService),y(2,s.ICommandService),y(3,l.Inject(u.ComponentManager))],P);var re=Object.defineProperty,se=Object.getOwnPropertyDescriptor,oe=(n,e,i,t)=>{for(var r=t>1?void 0:t?se(e,i):e,c=n.length-1,p;c>=0;c--)(p=n[c])&&(r=(t?p(e,i,r):p(r))||r);return t&&r&&re(e,i,r),r},A=(n,e)=>(i,t)=>e(i,t,n);const ce="uniscript";o.UniverUniscriptPlugin=(b=class extends s.Plugin{constructor(e,i,t){super(ce),this._config=e,this._injector=i,this._localeService=t}onStarting(e){[[P],[x,{useFactory:()=>e.createInstance(x,this._config)}],[D],[E]].forEach(t=>e.add(t)),this._localeService.load({zhCN:C})}},m(b,"type",s.PluginType.Univer),b),o.UniverUniscriptPlugin=oe([A(1,l.Inject(l.Injector)),A(2,l.Inject(s.LocaleService))],o.UniverUniscriptPlugin),o.enUS=V,o.zhCN=C,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "@univerjs/uniscript",
|
3
|
-
"version": "0.1.0-beta.
|
3
|
+
"version": "0.1.0-beta.3",
|
4
|
+
"private": false,
|
4
5
|
"description": "UI component library for building exceptional Univer.",
|
5
|
-
"keywords": [],
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
7
7
|
"license": "Apache-2.0",
|
8
|
-
"
|
9
|
-
"
|
10
|
-
|
11
|
-
|
12
|
-
"access": "public"
|
13
|
-
},
|
8
|
+
"keywords": [],
|
9
|
+
"sideEffects": [
|
10
|
+
"**/*.css"
|
11
|
+
],
|
14
12
|
"exports": {
|
15
13
|
".": {
|
16
14
|
"import": "./lib/es/index.js",
|
@@ -24,52 +22,57 @@
|
|
24
22
|
},
|
25
23
|
"./lib/*": "./lib/*"
|
26
24
|
},
|
25
|
+
"main": "./lib/cjs/index.js",
|
26
|
+
"module": "./lib/es/index.js",
|
27
|
+
"types": "./lib/types/index.d.ts",
|
28
|
+
"publishConfig": {
|
29
|
+
"access": "public"
|
30
|
+
},
|
27
31
|
"directories": {
|
28
32
|
"lib": "lib"
|
29
33
|
},
|
30
34
|
"files": [
|
31
35
|
"lib"
|
32
36
|
],
|
33
|
-
"
|
34
|
-
"
|
35
|
-
|
36
|
-
"private": false,
|
37
|
-
"dependencies": {
|
38
|
-
"@wendellhu/redi": "^0.12.12",
|
39
|
-
"monaco-editor": "0.45.0",
|
40
|
-
"rxjs": "^7.8.1",
|
41
|
-
"@univerjs/core": "0.1.0-beta.1",
|
42
|
-
"@univerjs/design": "0.1.0-beta.1",
|
43
|
-
"@univerjs/sheets-ui": "0.1.0-beta.1",
|
44
|
-
"@univerjs/ui": "0.1.0-beta.1",
|
45
|
-
"@univerjs/sheets": "0.1.0-beta.1"
|
46
|
-
},
|
47
|
-
"devDependencies": {
|
48
|
-
"@types/react": "^18.2.45",
|
49
|
-
"@vitejs/plugin-react": "^4.2.1",
|
50
|
-
"@vitest/coverage-istanbul": "^1.1.0",
|
51
|
-
"less": "^4.2.0",
|
52
|
-
"typescript": "^5.3.3",
|
53
|
-
"vite": "^5.0.10",
|
54
|
-
"vite-plugin-dts": "^3.6.4",
|
55
|
-
"vite-plugin-externals": "^0.6.2",
|
56
|
-
"vitest": "^1.1.0"
|
37
|
+
"engines": {
|
38
|
+
"node": ">=16.0.0",
|
39
|
+
"npm": ">=8.0.0"
|
57
40
|
},
|
58
41
|
"peerDependencies": {
|
59
|
-
"@wendellhu/redi": ">=0.12.
|
42
|
+
"@wendellhu/redi": ">=0.12.13",
|
60
43
|
"monaco-editor": ">=0.44.0",
|
61
44
|
"react": ">=16.9.0",
|
62
45
|
"rxjs": ">=7.0.0",
|
63
|
-
"@univerjs/core": "0.1.0-beta.
|
64
|
-
"@univerjs/
|
65
|
-
"@univerjs/
|
66
|
-
"@univerjs/
|
67
|
-
"@univerjs/sheets": "0.1.0-beta.
|
46
|
+
"@univerjs/core": "0.1.0-beta.3",
|
47
|
+
"@univerjs/facade": "0.1.0-beta.3",
|
48
|
+
"@univerjs/design": "0.1.0-beta.3",
|
49
|
+
"@univerjs/sheets": "0.1.0-beta.3",
|
50
|
+
"@univerjs/sheets-ui": "0.1.0-beta.3",
|
51
|
+
"@univerjs/ui": "0.1.0-beta.3"
|
52
|
+
},
|
53
|
+
"dependencies": {},
|
54
|
+
"devDependencies": {
|
55
|
+
"@types/react": "^18.2.48",
|
56
|
+
"@wendellhu/redi": "^0.12.13",
|
57
|
+
"less": "^4.2.0",
|
58
|
+
"monaco-editor": "0.45.0",
|
59
|
+
"rxjs": "^7.8.1",
|
60
|
+
"typescript": "^5.3.3",
|
61
|
+
"vite": "^5.0.12",
|
62
|
+
"vitest": "^1.2.1",
|
63
|
+
"@univerjs/core": "0.1.0-beta.3",
|
64
|
+
"@univerjs/facade": "0.1.0-beta.3",
|
65
|
+
"@univerjs/design": "0.1.0-beta.3",
|
66
|
+
"@univerjs/shared": "0.1.0-beta.3",
|
67
|
+
"@univerjs/sheets-ui": "0.1.0-beta.3",
|
68
|
+
"@univerjs/sheets": "0.1.0-beta.3",
|
69
|
+
"@univerjs/ui": "0.1.0-beta.3"
|
68
70
|
},
|
69
71
|
"scripts": {
|
70
72
|
"test": "vitest run",
|
71
73
|
"test:watch": "vitest",
|
72
74
|
"coverage": "vitest run --coverage",
|
75
|
+
"lint:types": "tsc --noEmit",
|
73
76
|
"build": "tsc && vite build"
|
74
77
|
}
|
75
78
|
}
|
@@ -1,25 +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
|
-
import { IUniverInstanceService } from '@univerjs/core';
|
17
|
-
import { Injector } from '@wendellhu/redi';
|
18
|
-
import { FWorkbook } from './sheet/f-workbook';
|
19
|
-
export declare class FUniver {
|
20
|
-
private readonly _injector;
|
21
|
-
private readonly _univerInstanceService;
|
22
|
-
static newInstance(injector: Injector): FUniver;
|
23
|
-
constructor(_injector: Injector, _univerInstanceService: IUniverInstanceService);
|
24
|
-
getCurrentSheet(): FWorkbook | null;
|
25
|
-
}
|
@@ -1,32 +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
|
-
import type { ICellV, IRange, Workbook, Worksheet } from '@univerjs/core';
|
17
|
-
import { ICommandService } from '@univerjs/core';
|
18
|
-
import { Injector } from '@wendellhu/redi';
|
19
|
-
export declare class FRange {
|
20
|
-
private readonly _workbook;
|
21
|
-
private readonly _worksheet;
|
22
|
-
private readonly _range;
|
23
|
-
private readonly _injector;
|
24
|
-
private readonly _commandService;
|
25
|
-
constructor(_workbook: Workbook, _worksheet: Worksheet, _range: IRange, _injector: Injector, _commandService: ICommandService);
|
26
|
-
getRow(): number;
|
27
|
-
getColumn(): number;
|
28
|
-
getWidth(): number;
|
29
|
-
getHeight(): number;
|
30
|
-
getValue(): ICellV | null;
|
31
|
-
setBackgroundColor(color: string): void;
|
32
|
-
}
|
@@ -1,27 +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
|
-
import type { Workbook, Worksheet } from '@univerjs/core';
|
17
|
-
import type { ISelectionWithStyle } from '@univerjs/sheets';
|
18
|
-
import { Injector } from '@wendellhu/redi';
|
19
|
-
import { FRange } from './f-range';
|
20
|
-
export declare class FSelection {
|
21
|
-
private readonly _workbook;
|
22
|
-
private readonly _worksheet;
|
23
|
-
private readonly _selections;
|
24
|
-
private readonly _injector;
|
25
|
-
constructor(_workbook: Workbook, _worksheet: Worksheet, _selections: Readonly<ISelectionWithStyle[]>, _injector: Injector);
|
26
|
-
getActiveRange(): FRange | null;
|
27
|
-
}
|
@@ -1,26 +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
|
-
import { ICommandService, type Workbook } from '@univerjs/core';
|
17
|
-
import { Injector } from '@wendellhu/redi';
|
18
|
-
import { FWorksheet } from './f-worksheet';
|
19
|
-
export declare class FWorkbook {
|
20
|
-
private readonly _workbook;
|
21
|
-
private readonly _injector;
|
22
|
-
private readonly _commandService;
|
23
|
-
constructor(_workbook: Workbook, _injector: Injector, _commandService: ICommandService);
|
24
|
-
getActiveSheet(): FWorksheet | null;
|
25
|
-
create(name: string, rows: number, column: number): FWorksheet;
|
26
|
-
}
|
@@ -1,32 +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
|
-
import { ICommandService, type Workbook, type Worksheet } from '@univerjs/core';
|
17
|
-
import { SelectionManagerService } from '@univerjs/sheets';
|
18
|
-
import { Injector } from '@wendellhu/redi';
|
19
|
-
import { FRange } from './f-range';
|
20
|
-
import { FSelection } from './f-selection';
|
21
|
-
export declare class FWorksheet {
|
22
|
-
private readonly _workbook;
|
23
|
-
private readonly _worksheet;
|
24
|
-
private readonly _injector;
|
25
|
-
private readonly _selectionManagerService;
|
26
|
-
private readonly _commandService;
|
27
|
-
constructor(_workbook: Workbook, _worksheet: Worksheet, _injector: Injector, _selectionManagerService: SelectionManagerService, _commandService: ICommandService);
|
28
|
-
getSelection(): FSelection | null;
|
29
|
-
getRange(row: number, col: number, height?: number, width?: number): FRange | null;
|
30
|
-
setRowHeights(startRow: number, numRows: number, height: number): void;
|
31
|
-
setColumnWidths(startColumn: number, numColumns: number, width: number): void;
|
32
|
-
}
|