@univerjs/uniscript 0.20.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +417 -1
- package/lib/cjs/locale/ca-ES.js +16 -1
- package/lib/cjs/locale/en-US.js +31 -1
- package/lib/cjs/locale/es-ES.js +16 -1
- package/lib/cjs/locale/fa-IR.js +16 -1
- package/lib/cjs/locale/fr-FR.js +16 -1
- package/lib/cjs/locale/ja-JP.js +16 -1
- package/lib/cjs/locale/ko-KR.js +16 -1
- package/lib/cjs/locale/ru-RU.js +16 -1
- package/lib/cjs/locale/sk-SK.js +16 -1
- package/lib/cjs/locale/vi-VN.js +16 -1
- package/lib/cjs/locale/zh-CN.js +16 -1
- package/lib/cjs/locale/zh-TW.js +16 -1
- package/lib/es/index.js +403 -1
- package/lib/es/locale/ca-ES.js +15 -1
- package/lib/es/locale/en-US.js +30 -1
- package/lib/es/locale/es-ES.js +15 -1
- package/lib/es/locale/fa-IR.js +15 -1
- package/lib/es/locale/fr-FR.js +15 -1
- package/lib/es/locale/ja-JP.js +15 -1
- package/lib/es/locale/ko-KR.js +15 -1
- package/lib/es/locale/ru-RU.js +15 -1
- package/lib/es/locale/sk-SK.js +15 -1
- package/lib/es/locale/vi-VN.js +15 -1
- package/lib/es/locale/zh-CN.js +15 -1
- package/lib/es/locale/zh-TW.js +15 -1
- package/lib/index.js +403 -1
- package/lib/locale/ca-ES.js +15 -1
- package/lib/locale/en-US.js +30 -1
- package/lib/locale/es-ES.js +15 -1
- package/lib/locale/fa-IR.js +15 -1
- package/lib/locale/fr-FR.js +15 -1
- package/lib/locale/ja-JP.js +15 -1
- package/lib/locale/ko-KR.js +15 -1
- package/lib/locale/ru-RU.js +15 -1
- package/lib/locale/sk-SK.js +15 -1
- package/lib/locale/vi-VN.js +15 -1
- package/lib/locale/zh-CN.js +15 -1
- package/lib/locale/zh-TW.js +15 -1
- package/lib/umd/index.js +1 -1
- package/package.json +9 -9
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1,417 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _univerjs_core = require("@univerjs/core");
|
|
3
|
+
let _univerjs_ui = require("@univerjs/ui");
|
|
4
|
+
let rxjs = require("rxjs");
|
|
5
|
+
let _univerjs_sheets = require("@univerjs/sheets");
|
|
6
|
+
let _univerjs_sheets_ui = require("@univerjs/sheets-ui");
|
|
7
|
+
let _univerjs_design = require("@univerjs/design");
|
|
8
|
+
let monaco_editor = require("monaco-editor");
|
|
9
|
+
let react = require("react");
|
|
10
|
+
let _univerjs_core_facade = require("@univerjs/core/facade");
|
|
11
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
|
+
|
|
13
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
|
|
14
|
+
function _typeof(o) {
|
|
15
|
+
"@babel/helpers - typeof";
|
|
16
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
17
|
+
return typeof o;
|
|
18
|
+
} : function(o) {
|
|
19
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
20
|
+
}, _typeof(o);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
|
|
25
|
+
function toPrimitive(t, r) {
|
|
26
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
27
|
+
var e = t[Symbol.toPrimitive];
|
|
28
|
+
if (void 0 !== e) {
|
|
29
|
+
var i = e.call(t, r || "default");
|
|
30
|
+
if ("object" != _typeof(i)) return i;
|
|
31
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
32
|
+
}
|
|
33
|
+
return ("string" === r ? String : Number)(t);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
|
|
38
|
+
function toPropertyKey(t) {
|
|
39
|
+
var i = toPrimitive(t, "string");
|
|
40
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
|
|
45
|
+
function _defineProperty(e, r, t) {
|
|
46
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
47
|
+
value: t,
|
|
48
|
+
enumerable: !0,
|
|
49
|
+
configurable: !0,
|
|
50
|
+
writable: !0
|
|
51
|
+
}) : e[r] = t, e;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/services/script-panel.service.ts
|
|
56
|
+
/**
|
|
57
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
58
|
+
*
|
|
59
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
60
|
+
* you may not use this file except in compliance with the License.
|
|
61
|
+
* You may obtain a copy of the License at
|
|
62
|
+
*
|
|
63
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
64
|
+
*
|
|
65
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
66
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
67
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
68
|
+
* See the License for the specific language governing permissions and
|
|
69
|
+
* limitations under the License.
|
|
70
|
+
*/
|
|
71
|
+
var ScriptPanelService = class extends _univerjs_core.Disposable {
|
|
72
|
+
constructor(..._args) {
|
|
73
|
+
super(..._args);
|
|
74
|
+
_defineProperty(this, "_open$", new rxjs.BehaviorSubject(false));
|
|
75
|
+
_defineProperty(this, "open$", this._open$.pipe((0, rxjs.distinctUntilChanged)()));
|
|
76
|
+
}
|
|
77
|
+
get isOpen() {
|
|
78
|
+
return this._open$.getValue();
|
|
79
|
+
}
|
|
80
|
+
dispose() {
|
|
81
|
+
super.dispose();
|
|
82
|
+
this._open$.next(false);
|
|
83
|
+
this._open$.complete();
|
|
84
|
+
}
|
|
85
|
+
open() {
|
|
86
|
+
this._open$.next(true);
|
|
87
|
+
}
|
|
88
|
+
close() {
|
|
89
|
+
this._open$.next(false);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/commands/operations/panel.operation.ts
|
|
95
|
+
const ScriptPanelComponentName = "ScriptPanel";
|
|
96
|
+
const ToggleScriptPanelOperation = {
|
|
97
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
98
|
+
id: "univer.operation.toggle-script-panel",
|
|
99
|
+
handler: (accessor) => {
|
|
100
|
+
const scriptPanelService = accessor.get(ScriptPanelService);
|
|
101
|
+
const sidebarService = accessor.get(_univerjs_ui.ISidebarService);
|
|
102
|
+
if (scriptPanelService.isOpen) {
|
|
103
|
+
scriptPanelService.close();
|
|
104
|
+
sidebarService.close();
|
|
105
|
+
} else {
|
|
106
|
+
scriptPanelService.open();
|
|
107
|
+
sidebarService.open({
|
|
108
|
+
header: { title: "script-panel.title" },
|
|
109
|
+
children: { label: ScriptPanelComponentName },
|
|
110
|
+
width: 600
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region package.json
|
|
119
|
+
var name = "@univerjs/uniscript";
|
|
120
|
+
var version = "0.21.0";
|
|
121
|
+
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/config/config.ts
|
|
124
|
+
const UNISCRIPT_PLUGIN_CONFIG_KEY = "uniscript.config";
|
|
125
|
+
const configSymbol = Symbol(UNISCRIPT_PLUGIN_CONFIG_KEY);
|
|
126
|
+
const defaultPluginConfig = {};
|
|
127
|
+
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/menu/menu.ts
|
|
130
|
+
function UniscriptMenuItemFactory(accessor) {
|
|
131
|
+
return {
|
|
132
|
+
id: ToggleScriptPanelOperation.id,
|
|
133
|
+
title: "toggle-script-panel",
|
|
134
|
+
tooltip: "script-panel.tooltip.menu-button",
|
|
135
|
+
icon: "CodeIcon",
|
|
136
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
137
|
+
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
|
|
138
|
+
disabled$: (0, _univerjs_sheets_ui.getCurrentRangeDisable$)(accessor, {
|
|
139
|
+
workbookTypes: [_univerjs_sheets.WorkbookEditablePermission],
|
|
140
|
+
worksheetTypes: [
|
|
141
|
+
_univerjs_sheets.WorksheetEditPermission,
|
|
142
|
+
_univerjs_sheets.WorksheetSetCellStylePermission,
|
|
143
|
+
_univerjs_sheets.WorksheetSetCellValuePermission
|
|
144
|
+
],
|
|
145
|
+
rangeTypes: [_univerjs_sheets.RangeProtectionPermissionEditPoint]
|
|
146
|
+
})
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/menu/schema.ts
|
|
152
|
+
const menuSchema = { [_univerjs_ui.RibbonOthersGroup.OTHERS]: { [ToggleScriptPanelOperation.id]: {
|
|
153
|
+
order: 0,
|
|
154
|
+
menuItemFactory: UniscriptMenuItemFactory
|
|
155
|
+
} } };
|
|
156
|
+
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
|
|
159
|
+
function __decorateParam(paramIndex, decorator) {
|
|
160
|
+
return function(target, key) {
|
|
161
|
+
decorator(target, key, paramIndex);
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
|
|
167
|
+
function __decorate(decorators, target, key, desc) {
|
|
168
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
169
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
170
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
171
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/services/script-editor.service.ts
|
|
176
|
+
let ScriptEditorService = class ScriptEditorService extends _univerjs_core.Disposable {
|
|
177
|
+
constructor(_configService) {
|
|
178
|
+
super();
|
|
179
|
+
this._configService = _configService;
|
|
180
|
+
_defineProperty(this, "_editorInstance", null);
|
|
181
|
+
}
|
|
182
|
+
dispose() {
|
|
183
|
+
super.dispose();
|
|
184
|
+
if (this._editorInstance) this._editorInstance.dispose();
|
|
185
|
+
}
|
|
186
|
+
setEditorInstance(editor) {
|
|
187
|
+
this._editorInstance = editor;
|
|
188
|
+
return (0, _univerjs_core.toDisposable)(() => this._editorInstance = null);
|
|
189
|
+
}
|
|
190
|
+
getEditorInstance() {
|
|
191
|
+
return this._editorInstance;
|
|
192
|
+
}
|
|
193
|
+
requireVscodeEditor() {
|
|
194
|
+
if (!window.MonacoEnvironment) {
|
|
195
|
+
const config = this._configService.getConfig(UNISCRIPT_PLUGIN_CONFIG_KEY);
|
|
196
|
+
window.MonacoEnvironment = { getWorkerUrl: config === null || config === void 0 ? void 0 : config.getWorkerUrl };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
ScriptEditorService = __decorate([__decorateParam(0, _univerjs_core.IConfigService)], ScriptEditorService);
|
|
201
|
+
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/services/script-execution.service.ts
|
|
204
|
+
/**
|
|
205
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
206
|
+
*
|
|
207
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
208
|
+
* you may not use this file except in compliance with the License.
|
|
209
|
+
* You may obtain a copy of the License at
|
|
210
|
+
*
|
|
211
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
212
|
+
*
|
|
213
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
214
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
215
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
216
|
+
* See the License for the specific language governing permissions and
|
|
217
|
+
* limitations under the License.
|
|
218
|
+
*/
|
|
219
|
+
const IUniscriptExecutionService = (0, _univerjs_core.createIdentifier)("univer.uniscript.execution-service");
|
|
220
|
+
let UniscriptExecutionService = class UniscriptExecutionService extends _univerjs_core.Disposable {
|
|
221
|
+
constructor(_logService, _injector) {
|
|
222
|
+
super();
|
|
223
|
+
this._logService = _logService;
|
|
224
|
+
this._injector = _injector;
|
|
225
|
+
}
|
|
226
|
+
async execute(code) {
|
|
227
|
+
this._logService.log("[UniscriptExecutionService]", "executing Uniscript...");
|
|
228
|
+
const apiInstance = _univerjs_core_facade.FUniver.newAPI(this._injector);
|
|
229
|
+
const scriptFunction = new Function("univerAPI", `(() => {${code}})()`);
|
|
230
|
+
try {
|
|
231
|
+
scriptFunction(apiInstance);
|
|
232
|
+
return true;
|
|
233
|
+
} catch (e) {
|
|
234
|
+
this._logService.error(e);
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
UniscriptExecutionService = __decorate([__decorateParam(0, _univerjs_core.ILogService), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector))], UniscriptExecutionService);
|
|
240
|
+
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region src/views/components/ScriptEditorPanel.tsx
|
|
243
|
+
function ScriptEditorPanel() {
|
|
244
|
+
const editorContentRef = (0, react.useRef)(null);
|
|
245
|
+
const editorContainerRef = (0, react.useRef)(null);
|
|
246
|
+
const monacoEditorRef = (0, react.useRef)(null);
|
|
247
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
248
|
+
const shortcutService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IShortcutService);
|
|
249
|
+
const editorService = (0, _univerjs_ui.useDependency)(ScriptEditorService);
|
|
250
|
+
const themeService = (0, _univerjs_ui.useDependency)(_univerjs_core.ThemeService);
|
|
251
|
+
(0, react.useEffect)(() => {
|
|
252
|
+
const containerElement = editorContainerRef.current;
|
|
253
|
+
const contentElement = editorContentRef.current;
|
|
254
|
+
let disposableCollection = null;
|
|
255
|
+
let resizeObserver = null;
|
|
256
|
+
if (containerElement && contentElement) {
|
|
257
|
+
editorService.requireVscodeEditor();
|
|
258
|
+
const monacoEditor = monacoEditorRef.current = monaco_editor.editor.create(containerElement, {
|
|
259
|
+
value: "",
|
|
260
|
+
language: "javascript",
|
|
261
|
+
theme: themeService.darkMode ? "vs-dark" : "vs-light"
|
|
262
|
+
});
|
|
263
|
+
resizeObserver = new ResizeObserver(() => {
|
|
264
|
+
let timer = requestIdleCallback(() => {
|
|
265
|
+
if (!timer) return;
|
|
266
|
+
const { height, width } = contentElement.getBoundingClientRect();
|
|
267
|
+
monacoEditor.layout({
|
|
268
|
+
width,
|
|
269
|
+
height
|
|
270
|
+
});
|
|
271
|
+
timer = void 0;
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
resizeObserver.observe(contentElement);
|
|
275
|
+
let terminateEscaping;
|
|
276
|
+
disposableCollection = new _univerjs_core.DisposableCollection();
|
|
277
|
+
disposableCollection.add(editorService.setEditorInstance(monacoEditor));
|
|
278
|
+
disposableCollection.add(monacoEditor.onDidFocusEditorWidget(() => {
|
|
279
|
+
terminateEscaping = shortcutService.forceEscape();
|
|
280
|
+
}));
|
|
281
|
+
disposableCollection.add(monacoEditor.onDidBlurEditorWidget(() => {
|
|
282
|
+
terminateEscaping === null || terminateEscaping === void 0 || terminateEscaping.dispose();
|
|
283
|
+
terminateEscaping = void 0;
|
|
284
|
+
}));
|
|
285
|
+
disposableCollection.add((0, _univerjs_core.toDisposable)(() => terminateEscaping === null || terminateEscaping === void 0 ? void 0 : terminateEscaping.dispose()));
|
|
286
|
+
}
|
|
287
|
+
return () => {
|
|
288
|
+
if (resizeObserver && contentElement) resizeObserver.unobserve(contentElement);
|
|
289
|
+
disposableCollection === null || disposableCollection === void 0 || disposableCollection.dispose();
|
|
290
|
+
};
|
|
291
|
+
}, [editorService, shortcutService]);
|
|
292
|
+
const startExecution = useExecution(monacoEditorRef);
|
|
293
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
294
|
+
className: "univer-h-full",
|
|
295
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
296
|
+
ref: editorContentRef,
|
|
297
|
+
className: "univer-h-[calc(100%-60px)] univer-w-full univer-overflow-hidden",
|
|
298
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ref: editorContainerRef })
|
|
299
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
300
|
+
className: "univer-mt-2.5",
|
|
301
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
302
|
+
variant: "primary",
|
|
303
|
+
onClick: startExecution,
|
|
304
|
+
children: localeService.t("script-panel.panel.execute")
|
|
305
|
+
})
|
|
306
|
+
})]
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
function useExecution(monacoEditorRef) {
|
|
310
|
+
const scriptService = (0, _univerjs_ui.useDependency)(IUniscriptExecutionService);
|
|
311
|
+
const messageService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IMessageService);
|
|
312
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
313
|
+
return (0, react.useCallback)(() => {
|
|
314
|
+
var _monacoEditorRef$curr;
|
|
315
|
+
const model = (_monacoEditorRef$curr = monacoEditorRef.current) === null || _monacoEditorRef$curr === void 0 ? void 0 : _monacoEditorRef$curr.getModel();
|
|
316
|
+
if (model) scriptService.execute(model.getValue()).then(() => {
|
|
317
|
+
messageService.show({
|
|
318
|
+
content: localeService.t("uniscript.message.success"),
|
|
319
|
+
type: _univerjs_design.MessageType.Success
|
|
320
|
+
});
|
|
321
|
+
}).catch(() => {
|
|
322
|
+
messageService.show({
|
|
323
|
+
content: localeService.t("uniscript.message.failed"),
|
|
324
|
+
type: _univerjs_design.MessageType.Error
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
}, [
|
|
328
|
+
localeService,
|
|
329
|
+
messageService,
|
|
330
|
+
monacoEditorRef,
|
|
331
|
+
scriptService
|
|
332
|
+
]);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region src/controllers/uniscript.controller.ts
|
|
337
|
+
/**
|
|
338
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
339
|
+
*
|
|
340
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
341
|
+
* you may not use this file except in compliance with the License.
|
|
342
|
+
* You may obtain a copy of the License at
|
|
343
|
+
*
|
|
344
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
345
|
+
*
|
|
346
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
347
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
348
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
349
|
+
* See the License for the specific language governing permissions and
|
|
350
|
+
* limitations under the License.
|
|
351
|
+
*/
|
|
352
|
+
let UniscriptController = class UniscriptController extends _univerjs_core.Disposable {
|
|
353
|
+
constructor(_menuManagerService, commandService, componentManager) {
|
|
354
|
+
super();
|
|
355
|
+
this._menuManagerService = _menuManagerService;
|
|
356
|
+
this._menuManagerService.mergeMenu(menuSchema);
|
|
357
|
+
this.disposeWithMe(componentManager.register(ScriptPanelComponentName, ScriptEditorPanel));
|
|
358
|
+
this.disposeWithMe(commandService.registerCommand(ToggleScriptPanelOperation));
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
UniscriptController = __decorate([
|
|
362
|
+
__decorateParam(0, _univerjs_ui.IMenuManagerService),
|
|
363
|
+
__decorateParam(1, _univerjs_core.ICommandService),
|
|
364
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager))
|
|
365
|
+
], UniscriptController);
|
|
366
|
+
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region src/plugin.ts
|
|
369
|
+
let UniverUniscriptPlugin = class UniverUniscriptPlugin extends _univerjs_core.Plugin {
|
|
370
|
+
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
371
|
+
super();
|
|
372
|
+
this._config = _config;
|
|
373
|
+
this._injector = _injector;
|
|
374
|
+
this._configService = _configService;
|
|
375
|
+
const { menu, ...rest } = (0, _univerjs_core.merge)({}, defaultPluginConfig, this._config);
|
|
376
|
+
if (menu) this._configService.setConfig("menu", menu, { merge: true });
|
|
377
|
+
this._configService.setConfig(UNISCRIPT_PLUGIN_CONFIG_KEY, rest);
|
|
378
|
+
}
|
|
379
|
+
onStarting() {
|
|
380
|
+
const injector = this._injector;
|
|
381
|
+
[
|
|
382
|
+
[UniscriptController],
|
|
383
|
+
[ScriptEditorService],
|
|
384
|
+
[ScriptPanelService]
|
|
385
|
+
].forEach((d) => injector.add(d));
|
|
386
|
+
this.registerExecution();
|
|
387
|
+
}
|
|
388
|
+
onSteady() {
|
|
389
|
+
this._injector.get(UniscriptController);
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Allows being overridden, replacing with a new UniscriptExecutionService.
|
|
393
|
+
*/
|
|
394
|
+
registerExecution() {
|
|
395
|
+
this._injector.add([IUniscriptExecutionService, { useClass: UniscriptExecutionService }]);
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
_defineProperty(UniverUniscriptPlugin, "pluginName", "UNIVER_UNISCRIPT_PLUGIN");
|
|
399
|
+
_defineProperty(UniverUniscriptPlugin, "packageName", name);
|
|
400
|
+
_defineProperty(UniverUniscriptPlugin, "version", version);
|
|
401
|
+
UniverUniscriptPlugin = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(2, _univerjs_core.IConfigService)], UniverUniscriptPlugin);
|
|
402
|
+
|
|
403
|
+
//#endregion
|
|
404
|
+
exports.IUniscriptExecutionService = IUniscriptExecutionService;
|
|
405
|
+
Object.defineProperty(exports, 'ScriptEditorService', {
|
|
406
|
+
enumerable: true,
|
|
407
|
+
get: function () {
|
|
408
|
+
return ScriptEditorService;
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
exports.ToggleScriptPanelOperation = ToggleScriptPanelOperation;
|
|
412
|
+
Object.defineProperty(exports, 'UniverUniscriptPlugin', {
|
|
413
|
+
enumerable: true,
|
|
414
|
+
get: function () {
|
|
415
|
+
return UniverUniscriptPlugin;
|
|
416
|
+
}
|
|
417
|
+
});
|
package/lib/cjs/locale/ca-ES.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/locale/ca-ES.ts
|
|
3
|
+
const locale = {
|
|
4
|
+
"script-panel": {
|
|
5
|
+
title: "Uniscript",
|
|
6
|
+
tooltip: { "menu-button": "Mostra/Oculta el panell Uniscript" },
|
|
7
|
+
panel: { execute: "Executa l'script" }
|
|
8
|
+
},
|
|
9
|
+
uniscript: { message: {
|
|
10
|
+
success: "Execució correcta",
|
|
11
|
+
failed: "Execució fallida"
|
|
12
|
+
} }
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
module.exports = locale;
|
package/lib/cjs/locale/en-US.js
CHANGED
|
@@ -1 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/locale/en-US.ts
|
|
3
|
+
/**
|
|
4
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
const locale = {
|
|
19
|
+
"script-panel": {
|
|
20
|
+
title: "Uniscript",
|
|
21
|
+
tooltip: { "menu-button": "Toggle Uniscript Panel" },
|
|
22
|
+
panel: { execute: "Execute Script" }
|
|
23
|
+
},
|
|
24
|
+
uniscript: { message: {
|
|
25
|
+
success: "Execution Success",
|
|
26
|
+
failed: "Execution Failed"
|
|
27
|
+
} }
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
module.exports = locale;
|
package/lib/cjs/locale/es-ES.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/locale/es-ES.ts
|
|
3
|
+
const locale = {
|
|
4
|
+
"script-panel": {
|
|
5
|
+
title: "Uniscript",
|
|
6
|
+
tooltip: { "menu-button": "Mostrar/Ocultar panel de Uniscript" },
|
|
7
|
+
panel: { execute: "Ejecutar script" }
|
|
8
|
+
},
|
|
9
|
+
uniscript: { message: {
|
|
10
|
+
success: "Ejecución exitosa",
|
|
11
|
+
failed: "Ejecución fallida"
|
|
12
|
+
} }
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
module.exports = locale;
|
package/lib/cjs/locale/fa-IR.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/locale/fa-IR.ts
|
|
3
|
+
const locale = {
|
|
4
|
+
"script-panel": {
|
|
5
|
+
title: "Uniscript",
|
|
6
|
+
tooltip: { "menu-button": "نمایش/مخفی کردن پنل Uniscript" },
|
|
7
|
+
panel: { execute: "اجرای اسکریپت" }
|
|
8
|
+
},
|
|
9
|
+
uniscript: { message: {
|
|
10
|
+
success: "اجرای موفق",
|
|
11
|
+
failed: "اجرای ناموفق"
|
|
12
|
+
} }
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
module.exports = locale;
|
package/lib/cjs/locale/fr-FR.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/locale/fr-FR.ts
|
|
3
|
+
const locale = {
|
|
4
|
+
"script-panel": {
|
|
5
|
+
title: "Uniscript",
|
|
6
|
+
tooltip: { "menu-button": "Basculer le panneau Uniscript" },
|
|
7
|
+
panel: { execute: "Exécuter le script" }
|
|
8
|
+
},
|
|
9
|
+
uniscript: { message: {
|
|
10
|
+
success: "Exécution réussie",
|
|
11
|
+
failed: "Échec de l'exécution"
|
|
12
|
+
} }
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
module.exports = locale;
|
package/lib/cjs/locale/ja-JP.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/locale/ja-JP.ts
|
|
3
|
+
const locale = {
|
|
4
|
+
"script-panel": {
|
|
5
|
+
title: "Uniscript",
|
|
6
|
+
tooltip: { "menu-button": "Uniscriptパネルを切り替え" },
|
|
7
|
+
panel: { execute: "スクリプトを実行" }
|
|
8
|
+
},
|
|
9
|
+
uniscript: { message: {
|
|
10
|
+
success: "実行に成功しました",
|
|
11
|
+
failed: "実行に失敗しました"
|
|
12
|
+
} }
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
module.exports = locale;
|
package/lib/cjs/locale/ko-KR.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/locale/ko-KR.ts
|
|
3
|
+
const locale = {
|
|
4
|
+
"script-panel": {
|
|
5
|
+
title: "Uniscript",
|
|
6
|
+
tooltip: { "menu-button": "Uniscript 패널 전환" },
|
|
7
|
+
panel: { execute: "스크립트 실행" }
|
|
8
|
+
},
|
|
9
|
+
uniscript: { message: {
|
|
10
|
+
success: "실행 성공",
|
|
11
|
+
failed: "실행 실패"
|
|
12
|
+
} }
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
module.exports = locale;
|
package/lib/cjs/locale/ru-RU.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/locale/ru-RU.ts
|
|
3
|
+
const locale = {
|
|
4
|
+
"script-panel": {
|
|
5
|
+
title: "Юнискрипт",
|
|
6
|
+
tooltip: { "menu-button": "Переключить панель Юнискрипт" },
|
|
7
|
+
panel: { execute: "Выполнить скрипт" }
|
|
8
|
+
},
|
|
9
|
+
uniscript: { message: {
|
|
10
|
+
success: "Выполнение успешно",
|
|
11
|
+
failed: "Выполнение не удалось"
|
|
12
|
+
} }
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
module.exports = locale;
|
package/lib/cjs/locale/sk-SK.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/locale/sk-SK.ts
|
|
3
|
+
const locale = {
|
|
4
|
+
"script-panel": {
|
|
5
|
+
title: "Uniscript",
|
|
6
|
+
tooltip: { "menu-button": "Prepnúť panel Uniscript" },
|
|
7
|
+
panel: { execute: "Spustiť skript" }
|
|
8
|
+
},
|
|
9
|
+
uniscript: { message: {
|
|
10
|
+
success: "Spustenie úspešné",
|
|
11
|
+
failed: "Spustenie zlyhalo"
|
|
12
|
+
} }
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
module.exports = locale;
|
package/lib/cjs/locale/vi-VN.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/locale/vi-VN.ts
|
|
3
|
+
const locale = {
|
|
4
|
+
"script-panel": {
|
|
5
|
+
title: "Uniscript",
|
|
6
|
+
tooltip: { "menu-button": "Mở/Thu gọn bảng điều khiển Uniscript" },
|
|
7
|
+
panel: { execute: "Thực thi Uniscript" }
|
|
8
|
+
},
|
|
9
|
+
uniscript: { message: {
|
|
10
|
+
success: "Thực thi thành công",
|
|
11
|
+
failed: "Thực thi thất bại"
|
|
12
|
+
} }
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
module.exports = locale;
|
package/lib/cjs/locale/zh-CN.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/locale/zh-CN.ts
|
|
3
|
+
const locale = {
|
|
4
|
+
"script-panel": {
|
|
5
|
+
title: "Uniscript",
|
|
6
|
+
tooltip: { "menu-button": "打开收起 Uniscript 面板" },
|
|
7
|
+
panel: { execute: "执行 Uniscript" }
|
|
8
|
+
},
|
|
9
|
+
uniscript: { message: {
|
|
10
|
+
success: "执行成功",
|
|
11
|
+
failed: "执行失败"
|
|
12
|
+
} }
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
module.exports = locale;
|
package/lib/cjs/locale/zh-TW.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/locale/zh-TW.ts
|
|
3
|
+
const locale = {
|
|
4
|
+
"script-panel": {
|
|
5
|
+
title: "Uniscript",
|
|
6
|
+
tooltip: { "menu-button": "打開收起 Uniscript 面板" },
|
|
7
|
+
panel: { execute: "執行 Uniscript" }
|
|
8
|
+
},
|
|
9
|
+
uniscript: { message: {
|
|
10
|
+
success: "執行成功",
|
|
11
|
+
failed: "執行失敗"
|
|
12
|
+
} }
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
module.exports = locale;
|