@univerjs/core 0.17.0 → 0.18.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/facade.js +1 -1
- package/lib/cjs/index.js +9 -8
- package/lib/es/facade.js +1 -1479
- package/lib/es/index.js +9 -20335
- package/lib/facade.js +1 -1479
- package/lib/index.js +9 -20335
- package/lib/types/common/async.d.ts +16 -1
- package/lib/types/common/di.d.ts +18 -2
- package/lib/types/common/interceptor.d.ts +16 -1
- package/lib/types/common/invert-color/invert-hsl.d.ts +16 -1
- package/lib/types/common/invert-color/invert-rgb.d.ts +16 -1
- package/lib/types/common/unit.d.ts +17 -2
- package/lib/types/docs/data-model/document-data-model.d.ts +24 -9
- package/lib/types/docs/data-model/empty-snapshot.d.ts +16 -1
- package/lib/types/docs/data-model/json-x/json-x.d.ts +19 -4
- package/lib/types/docs/data-model/preset-list-type.d.ts +16 -1
- package/lib/types/docs/data-model/replacement.d.ts +16 -1
- package/lib/types/docs/data-model/rich-text-builder.d.ts +21 -5
- package/lib/types/docs/data-model/text-x/action-iterator.d.ts +17 -1
- package/lib/types/docs/data-model/text-x/action-types.d.ts +17 -2
- package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +16 -1
- package/lib/types/docs/data-model/text-x/apply-utils/delete-apply.d.ts +16 -1
- package/lib/types/docs/data-model/text-x/apply-utils/insert-apply.d.ts +16 -1
- package/lib/types/docs/data-model/text-x/apply-utils/update-apply.d.ts +16 -1
- package/lib/types/docs/data-model/text-x/apply.d.ts +17 -2
- package/lib/types/docs/data-model/text-x/build-utils/custom-decoration.d.ts +17 -2
- package/lib/types/docs/data-model/text-x/build-utils/custom-range.d.ts +17 -2
- package/lib/types/docs/data-model/text-x/build-utils/drawings.d.ts +19 -4
- package/lib/types/docs/data-model/text-x/build-utils/index.d.ts +24 -9
- package/lib/types/docs/data-model/text-x/build-utils/paragraph.d.ts +18 -3
- package/lib/types/docs/data-model/text-x/build-utils/parse.d.ts +16 -1
- package/lib/types/docs/data-model/text-x/build-utils/selection.d.ts +17 -2
- package/lib/types/docs/data-model/text-x/build-utils/text-x-utils.d.ts +23 -7
- package/lib/types/docs/data-model/text-x/text-x.d.ts +18 -3
- package/lib/types/docs/data-model/text-x/transform-utils.d.ts +17 -2
- package/lib/types/docs/data-model/text-x/utils.d.ts +34 -19
- package/lib/types/docs/data-model/utils.d.ts +16 -1
- package/lib/types/facade/f-base.d.ts +17 -1
- package/lib/types/facade/f-blob.d.ts +17 -1
- package/lib/types/facade/f-doc.d.ts +17 -1
- package/lib/types/facade/f-enum.d.ts +15 -0
- package/lib/types/facade/f-event-registry.d.ts +19 -3
- package/lib/types/facade/f-event.d.ts +17 -2
- package/lib/types/facade/f-hooks.d.ts +17 -1
- package/lib/types/facade/f-univer.d.ts +20 -3
- package/lib/types/facade/f-usermanager.d.ts +17 -1
- package/lib/types/facade/f-util.d.ts +15 -0
- package/lib/types/observer/observable.d.ts +17 -1
- package/lib/types/services/authz-io/authz-io-local.service.d.ts +17 -2
- package/lib/types/services/authz-io/type.d.ts +18 -3
- package/lib/types/services/command/command.service.d.ts +20 -4
- package/lib/types/services/config/config.service.d.ts +18 -3
- package/lib/types/services/confirm/confirm.service.d.ts +17 -2
- package/lib/types/services/context/context.service.d.ts +16 -1
- package/lib/types/services/error/error.service.d.ts +16 -1
- package/lib/types/services/image-io/image-io.service.d.ts +18 -3
- package/lib/types/services/image-io/url-image.service.d.ts +17 -2
- package/lib/types/services/instance/instance.service.d.ts +22 -5
- package/lib/types/services/lifecycle/lifecycle.service.d.ts +16 -1
- package/lib/types/services/local-storage/local-storage.service.d.ts +1 -1
- package/lib/types/services/locale/locale.service.d.ts +17 -2
- package/lib/types/services/log/log.service.d.ts +16 -1
- package/lib/types/services/mention-io/mention-io-local.service.d.ts +16 -1
- package/lib/types/services/mention-io/type.d.ts +18 -3
- package/lib/types/services/permission/permission.service.d.ts +18 -2
- package/lib/types/services/permission/type.d.ts +20 -5
- package/lib/types/services/plugin/plugin-override.d.ts +16 -1
- package/lib/types/services/plugin/plugin.service.d.ts +18 -2
- package/lib/types/services/resource-loader/resource-loader.service.d.ts +17 -2
- package/lib/types/services/resource-loader/type.d.ts +17 -2
- package/lib/types/services/resource-manager/resource-manager.service.d.ts +19 -4
- package/lib/types/services/resource-manager/type.d.ts +19 -4
- package/lib/types/services/theme/theme.service.d.ts +16 -1
- package/lib/types/services/undoredo/undoredo.service.d.ts +22 -5
- package/lib/types/services/user-manager/const.d.ts +17 -1
- package/lib/types/services/user-manager/user-manager.service.d.ts +17 -2
- package/lib/types/shared/after-init-apply.d.ts +16 -1
- package/lib/types/shared/cache/image-cache.d.ts +16 -1
- package/lib/types/shared/check-if-move.d.ts +17 -2
- package/lib/types/shared/common.d.ts +22 -7
- package/lib/types/shared/compare.d.ts +16 -1
- package/lib/types/shared/dayjs.d.ts +16 -1
- package/lib/types/shared/doc-tool.d.ts +16 -1
- package/lib/types/shared/generate.d.ts +17 -2
- package/lib/types/shared/lifecycle.d.ts +18 -2
- package/lib/types/shared/lru/lru-map.d.ts +16 -1
- package/lib/types/shared/object-matrix-query.d.ts +16 -1
- package/lib/types/shared/object-matrix.d.ts +17 -2
- package/lib/types/shared/r-tree.d.ts +18 -2
- package/lib/types/shared/range.d.ts +17 -2
- package/lib/types/shared/rectangle.d.ts +17 -2
- package/lib/types/shared/rxjs.d.ts +18 -2
- package/lib/types/shared/tools.d.ts +17 -23
- package/lib/types/sheets/clone.d.ts +17 -2
- package/lib/types/sheets/column-manager.d.ts +19 -4
- package/lib/types/sheets/empty-snapshot.d.ts +16 -1
- package/lib/types/sheets/range.d.ts +23 -6
- package/lib/types/sheets/row-manager.d.ts +20 -5
- package/lib/types/sheets/sheet-skeleton.d.ts +21 -5
- package/lib/types/sheets/sheet-snapshot-utils.d.ts +16 -1
- package/lib/types/sheets/span-model.d.ts +16 -1
- package/lib/types/sheets/styles.d.ts +18 -3
- package/lib/types/sheets/typedef.d.ts +23 -7
- package/lib/types/sheets/util.d.ts +20 -4
- package/lib/types/sheets/workbook.d.ts +19 -4
- package/lib/types/sheets/worksheet.d.ts +25 -7
- package/lib/types/skeleton.d.ts +16 -1
- package/lib/types/slides/slide-model.d.ts +22 -6
- package/lib/types/types/const/const.d.ts +18 -2
- package/lib/types/types/const/page-size.d.ts +16 -1
- package/lib/types/types/interfaces/i-cell-custom-render.d.ts +20 -5
- package/lib/types/types/interfaces/i-cell-validation-data.d.ts +17 -2
- package/lib/types/types/interfaces/i-data-validation.d.ts +21 -6
- package/lib/types/types/interfaces/i-document-data-interceptor.d.ts +16 -1
- package/lib/types/types/interfaces/i-document-data.d.ts +20 -5
- package/lib/types/types/interfaces/i-drawing.d.ts +56 -3
- package/lib/types/types/interfaces/i-mention.d.ts +16 -1
- package/lib/types/types/interfaces/i-need-check-disposable.d.ts +16 -1
- package/lib/types/types/interfaces/i-placeholder.d.ts +16 -1
- package/lib/types/types/interfaces/i-shape-properties.d.ts +17 -2
- package/lib/types/types/interfaces/i-slide-data.d.ts +26 -11
- package/lib/types/types/interfaces/i-style-data.d.ts +19 -4
- package/lib/types/univer.d.ts +26 -10
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +9 -8
- package/package.json +9 -9
- package/lib/types/docs/data-model/text-x/build-utils/__test__/custom-range.spec.d.ts +0 -16
- package/lib/types/docs/data-model/text-x/build-utils/__test__/selection.spec.d.ts +0 -16
package/lib/es/facade.js
CHANGED
|
@@ -1,1479 +1 @@
|
|
|
1
|
-
var F = Object.defineProperty;
|
|
2
|
-
var q = (i, e, t) => e in i ? F(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
-
var d = (i, e, t) => q(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { Disposable as I, Inject as p, Injector as _, AbsoluteRefType as G, UniverInstanceType as R, LifecycleStages as f, DataValidationType as J, DataValidationErrorStyle as K, DataValidationRenderMode as Q, DataValidationOperator as X, DataValidationStatus as Y, CommandType as Z, BaselineOffset as k, BooleanNumber as ee, HorizontalAlign as te, TextDecoration as re, TextDirection as ie, VerticalAlign as ne, WrapStrategy as oe, BorderType as se, BorderStyleTypes as ce, AutoFillSeries as ae, ColorType as de, CommonHideTypes as le, CopyPasteType as pe, DeleteDirection as he, DeveloperMetadataVisibility as ue, Dimension as ye, Direction as ge, InterpolationPointType as ve, LocaleType as fe, MentionType as _e, ProtectionType as me, RelativeDate as Ee, SheetTypes as be, ThemeColorType as Se, LifecycleService as V, toDisposable as l, ICommandService as y, UndoCommand as h, IUndoRedoService as E, RedoCommand as u, Registry as Ce, UserManagerService as De, Rectangle as xe, numfmt as Te, Tools as we, IUniverInstanceService as W, Univer as Re, CanceledError as T, ThemeService as Oe, LocaleService as z, RichTextBuilder as je, RichTextValue as Pe, ParagraphStyleBuilder as Be, ParagraphStyleValue as He, TextStyleBuilder as Me, TextStyleValue as Ue, TextDecorationBuilder as Ie } from "@univerjs/core";
|
|
5
|
-
import { filter as b } from "rxjs";
|
|
6
|
-
class $ extends I {
|
|
7
|
-
/**
|
|
8
|
-
* @ignore
|
|
9
|
-
*/
|
|
10
|
-
static extend(e) {
|
|
11
|
-
Object.getOwnPropertyNames(e.prototype).forEach((t) => {
|
|
12
|
-
t !== "constructor" && (this.prototype[t] = e.prototype[t]);
|
|
13
|
-
}), Object.getOwnPropertyNames(e).forEach((t) => {
|
|
14
|
-
t !== "prototype" && t !== "name" && t !== "length" && (this[t] = e[t]);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
const S = /* @__PURE__ */ Symbol("initializers"), A = /* @__PURE__ */ Symbol("manualInit");
|
|
19
|
-
class Ve extends I {
|
|
20
|
-
constructor(e) {
|
|
21
|
-
if (super(), this._injector = e, !!this.constructor[A]) return;
|
|
22
|
-
const n = this, o = Object.getPrototypeOf(this)[S];
|
|
23
|
-
o && o.forEach(function(s) {
|
|
24
|
-
s.apply(n, [e]);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @ignore
|
|
29
|
-
*/
|
|
30
|
-
_initialize(e, ...t) {
|
|
31
|
-
}
|
|
32
|
-
_runInitializers(...e) {
|
|
33
|
-
const t = Object.getPrototypeOf(this)[S];
|
|
34
|
-
t != null && t.length && t.forEach((r) => r.apply(this, e));
|
|
35
|
-
}
|
|
36
|
-
static _enableManualInit() {
|
|
37
|
-
this[A] = !0;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* @ignore
|
|
41
|
-
*/
|
|
42
|
-
static extend(e) {
|
|
43
|
-
Object.getOwnPropertyNames(e.prototype).forEach((t) => {
|
|
44
|
-
if (t === "_initialize") {
|
|
45
|
-
let r = this.prototype[S];
|
|
46
|
-
r || (r = [], this.prototype[S] = r), r.push(e.prototype._initialize);
|
|
47
|
-
} else t !== "constructor" && (this.prototype[t] = e.prototype[t]);
|
|
48
|
-
}), Object.getOwnPropertyNames(e).forEach((t) => {
|
|
49
|
-
t !== "prototype" && t !== "name" && t !== "length" && (this[t] = e[t]);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
var $e = Object.getOwnPropertyDescriptor, ze = (i, e, t, r) => {
|
|
54
|
-
for (var n = r > 1 ? void 0 : r ? $e(e, t) : e, o = i.length - 1, s; o >= 0; o--)
|
|
55
|
-
(s = i[o]) && (n = s(n) || n);
|
|
56
|
-
return n;
|
|
57
|
-
}, Ae = (i, e) => (t, r) => e(t, r, i);
|
|
58
|
-
let D = class extends $ {
|
|
59
|
-
constructor(i, e) {
|
|
60
|
-
super(), this._blob = i, this._injector = e;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Returns a copy of this blob.
|
|
64
|
-
* @returns a new blob by copying the current blob
|
|
65
|
-
* @example
|
|
66
|
-
* ```ts
|
|
67
|
-
* const blob = univerAPI.newBlob();
|
|
68
|
-
* const newBlob = blob.copyBlob();
|
|
69
|
-
* console.log(newBlob);
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
copyBlob() {
|
|
73
|
-
return this._injector.createInstance(D, this._blob);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Return the data inside this object as a blob converted to the specified content type.
|
|
77
|
-
* @param contentType the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
|
|
78
|
-
* @returns a new blob by converting the current blob to the specified content type
|
|
79
|
-
* @example
|
|
80
|
-
* ```ts
|
|
81
|
-
* const blob = univerAPI.newBlob();
|
|
82
|
-
* const newBlob = blob.getAs('text/plain');
|
|
83
|
-
* console.log(newBlob);
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
getAs(i) {
|
|
87
|
-
const e = this.copyBlob();
|
|
88
|
-
return e.setContentType(i), e;
|
|
89
|
-
}
|
|
90
|
-
getDataAsString(i) {
|
|
91
|
-
return this._blob === null ? Promise.resolve("") : i === void 0 ? this._blob.text() : new Promise((e, t) => {
|
|
92
|
-
this._blob.arrayBuffer().then((r) => {
|
|
93
|
-
const n = new TextDecoder(i).decode(r);
|
|
94
|
-
e(n);
|
|
95
|
-
}).catch((r) => {
|
|
96
|
-
t(new Error(`Failed to read Blob as ArrayBuffer: ${r.message}`));
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Gets the data stored in this blob.
|
|
102
|
-
* @returns the blob content as a byte array
|
|
103
|
-
* @example
|
|
104
|
-
* ```ts
|
|
105
|
-
* const blob = univerAPI.newBlob();
|
|
106
|
-
* const bytes = await blob.getBytes();
|
|
107
|
-
* console.log(bytes);
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
getBytes() {
|
|
111
|
-
return this._blob ? this._blob.arrayBuffer().then((i) => new Uint8Array(i)) : Promise.reject(new Error("Blob is undefined or null."));
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Sets the data stored in this blob.
|
|
115
|
-
* @param bytes a byte array
|
|
116
|
-
* @returns the blob object
|
|
117
|
-
* @example
|
|
118
|
-
* ```ts
|
|
119
|
-
* const blob = univerAPI.newBlob();
|
|
120
|
-
* const bytes = new Uint8Array(10);
|
|
121
|
-
* blob.setBytes(bytes);
|
|
122
|
-
* ```
|
|
123
|
-
*/
|
|
124
|
-
setBytes(i) {
|
|
125
|
-
return this._blob = new Blob([i.buffer]), this;
|
|
126
|
-
}
|
|
127
|
-
setDataFromString(i, e) {
|
|
128
|
-
const t = e != null ? e : "text/plain", r = new Blob([i], { type: t });
|
|
129
|
-
return this._blob = r, this;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Gets the content type of the data stored in this blob.
|
|
133
|
-
* @returns the content type
|
|
134
|
-
* @example
|
|
135
|
-
* ```ts
|
|
136
|
-
* const blob = univerAPI.newBlob();
|
|
137
|
-
* const contentType = blob.getContentType();
|
|
138
|
-
* console.log(contentType);
|
|
139
|
-
* ```
|
|
140
|
-
*/
|
|
141
|
-
getContentType() {
|
|
142
|
-
var i;
|
|
143
|
-
return (i = this._blob) == null ? void 0 : i.type;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Sets the content type of the data stored in this blob.
|
|
147
|
-
* @param contentType the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
|
|
148
|
-
* @returns the blob object
|
|
149
|
-
* @example
|
|
150
|
-
* ```ts
|
|
151
|
-
* const blob = univerAPI.newBlob();
|
|
152
|
-
* blob.setContentType('text/plain');
|
|
153
|
-
* ```
|
|
154
|
-
*/
|
|
155
|
-
setContentType(i) {
|
|
156
|
-
var e;
|
|
157
|
-
return this._blob = (e = this._blob) == null ? void 0 : e.slice(0, this._blob.size, i), this;
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
D = ze([
|
|
161
|
-
Ae(1, p(_))
|
|
162
|
-
], D);
|
|
163
|
-
const g = class g {
|
|
164
|
-
static get() {
|
|
165
|
-
if (this._instance)
|
|
166
|
-
return this._instance;
|
|
167
|
-
const e = new g();
|
|
168
|
-
return this._instance = e, e;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* @ignore
|
|
172
|
-
*/
|
|
173
|
-
static extend(e) {
|
|
174
|
-
Object.getOwnPropertyNames(e.prototype).forEach((t) => {
|
|
175
|
-
t !== "constructor" && (this.prototype[t] = e.prototype[t]);
|
|
176
|
-
}), Object.getOwnPropertyNames(e).forEach((t) => {
|
|
177
|
-
t !== "prototype" && t !== "name" && t !== "length" && (this[t] = e[t]);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
constructor() {
|
|
181
|
-
for (const e in g.prototype)
|
|
182
|
-
this[e] = g.prototype[e];
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Defines different types of absolute references
|
|
186
|
-
*
|
|
187
|
-
* @example
|
|
188
|
-
* ```ts
|
|
189
|
-
* console.log(univerAPI.Enum.AbsoluteRefType);
|
|
190
|
-
* ```
|
|
191
|
-
*/
|
|
192
|
-
get AbsoluteRefType() {
|
|
193
|
-
return G;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Defines different types of Univer instances
|
|
197
|
-
*
|
|
198
|
-
* @example
|
|
199
|
-
* ```ts
|
|
200
|
-
* console.log(univerAPI.Enum.UniverInstanceType.UNIVER_SHEET);
|
|
201
|
-
* ```
|
|
202
|
-
*/
|
|
203
|
-
get UniverInstanceType() {
|
|
204
|
-
return R;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Represents different stages in the lifecycle
|
|
208
|
-
*
|
|
209
|
-
* @example
|
|
210
|
-
* ```ts
|
|
211
|
-
* console.log(univerAPI.Enum.LifecycleStages.Rendered);
|
|
212
|
-
* ```
|
|
213
|
-
*/
|
|
214
|
-
get LifecycleStages() {
|
|
215
|
-
return f;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Different types of data validation
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* ```ts
|
|
222
|
-
* console.log(univerAPI.Enum.DataValidationType.LIST);
|
|
223
|
-
* ```
|
|
224
|
-
*/
|
|
225
|
-
get DataValidationType() {
|
|
226
|
-
return J;
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Different error display styles
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* ```ts
|
|
233
|
-
* console.log(univerAPI.Enum.DataValidationErrorStyle.WARNING);
|
|
234
|
-
* ```
|
|
235
|
-
*/
|
|
236
|
-
get DataValidationErrorStyle() {
|
|
237
|
-
return K;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Different validation rendering modes
|
|
241
|
-
*
|
|
242
|
-
* @example
|
|
243
|
-
* ```ts
|
|
244
|
-
* console.log(univerAPI.Enum.DataValidationRenderMode.TEXT);
|
|
245
|
-
* ```
|
|
246
|
-
*/
|
|
247
|
-
get DataValidationRenderMode() {
|
|
248
|
-
return Q;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Different validation operators
|
|
252
|
-
*
|
|
253
|
-
* @example
|
|
254
|
-
* ```ts
|
|
255
|
-
* console.log(univerAPI.Enum.DataValidationOperator.BETWEEN);
|
|
256
|
-
* ```
|
|
257
|
-
*/
|
|
258
|
-
get DataValidationOperator() {
|
|
259
|
-
return X;
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Different validation states
|
|
263
|
-
*
|
|
264
|
-
* @example
|
|
265
|
-
* ```ts
|
|
266
|
-
* console.log(univerAPI.Enum.DataValidationStatus.VALID);
|
|
267
|
-
* ```
|
|
268
|
-
*/
|
|
269
|
-
get DataValidationStatus() {
|
|
270
|
-
return Y;
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Different types of commands
|
|
274
|
-
*
|
|
275
|
-
* @example
|
|
276
|
-
* ```ts
|
|
277
|
-
* console.log(univerAPI.Enum.CommandType.COMMAND);
|
|
278
|
-
* ```
|
|
279
|
-
*/
|
|
280
|
-
get CommandType() {
|
|
281
|
-
return Z;
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Different baseline offsets for text baseline positioning
|
|
285
|
-
*
|
|
286
|
-
* @example
|
|
287
|
-
* ```ts
|
|
288
|
-
* console.log(univerAPI.Enum.BaselineOffset.SUPERSCRIPT);
|
|
289
|
-
* ```
|
|
290
|
-
*/
|
|
291
|
-
get BaselineOffset() {
|
|
292
|
-
return k;
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Boolean number representations
|
|
296
|
-
*
|
|
297
|
-
* @example
|
|
298
|
-
* ```ts
|
|
299
|
-
* console.log(univerAPI.Enum.BooleanNumber.TRUE);
|
|
300
|
-
* ```
|
|
301
|
-
*/
|
|
302
|
-
get BooleanNumber() {
|
|
303
|
-
return ee;
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Different horizontal text alignment options
|
|
307
|
-
*
|
|
308
|
-
* @example
|
|
309
|
-
* ```ts
|
|
310
|
-
* console.log(univerAPI.Enum.HorizontalAlign.CENTER);
|
|
311
|
-
* ```
|
|
312
|
-
*/
|
|
313
|
-
get HorizontalAlign() {
|
|
314
|
-
return te;
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Different text decoration styles
|
|
318
|
-
*
|
|
319
|
-
* @example
|
|
320
|
-
* ```ts
|
|
321
|
-
* console.log(univerAPI.Enum.TextDecoration.DOUBLE);
|
|
322
|
-
* ```
|
|
323
|
-
*/
|
|
324
|
-
get TextDecoration() {
|
|
325
|
-
return re;
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Different text direction options
|
|
329
|
-
*
|
|
330
|
-
* @example
|
|
331
|
-
* ```ts
|
|
332
|
-
* console.log(univerAPI.Enum.TextDirection.LEFT_TO_RIGHT);
|
|
333
|
-
* ```
|
|
334
|
-
*/
|
|
335
|
-
get TextDirection() {
|
|
336
|
-
return ie;
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Different vertical text alignment options
|
|
340
|
-
*
|
|
341
|
-
* @example
|
|
342
|
-
* ```ts
|
|
343
|
-
* console.log(univerAPI.Enum.VerticalAlign.MIDDLE);
|
|
344
|
-
* ```
|
|
345
|
-
*/
|
|
346
|
-
get VerticalAlign() {
|
|
347
|
-
return ne;
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* Different wrap strategy options
|
|
351
|
-
*
|
|
352
|
-
* @example
|
|
353
|
-
* ```ts
|
|
354
|
-
* console.log(univerAPI.Enum.WrapStrategy.WRAP);
|
|
355
|
-
* ```
|
|
356
|
-
*/
|
|
357
|
-
get WrapStrategy() {
|
|
358
|
-
return oe;
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Different border types
|
|
362
|
-
*
|
|
363
|
-
* @example
|
|
364
|
-
* ```ts
|
|
365
|
-
* console.log(univerAPI.Enum.BorderType.OUTSIDE);
|
|
366
|
-
* ```
|
|
367
|
-
*/
|
|
368
|
-
get BorderType() {
|
|
369
|
-
return se;
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Different border style types
|
|
373
|
-
*
|
|
374
|
-
* @example
|
|
375
|
-
* ```ts
|
|
376
|
-
* console.log(univerAPI.Enum.BorderStyleTypes.NONE);
|
|
377
|
-
* ```
|
|
378
|
-
*/
|
|
379
|
-
get BorderStyleTypes() {
|
|
380
|
-
return ce;
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Auto fill series types
|
|
384
|
-
*
|
|
385
|
-
* @example
|
|
386
|
-
* ```ts
|
|
387
|
-
* console.log(univerAPI.Enum.AutoFillSeries.ALTERNATE_SERIES);
|
|
388
|
-
* ```
|
|
389
|
-
*/
|
|
390
|
-
get AutoFillSeries() {
|
|
391
|
-
return ae;
|
|
392
|
-
}
|
|
393
|
-
/**
|
|
394
|
-
* Color types
|
|
395
|
-
*
|
|
396
|
-
* @example
|
|
397
|
-
* ```ts
|
|
398
|
-
* console.log(univerAPI.Enum.ColorType.RGB);
|
|
399
|
-
* ```
|
|
400
|
-
*/
|
|
401
|
-
get ColorType() {
|
|
402
|
-
return de;
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Common hide types
|
|
406
|
-
*
|
|
407
|
-
* @example
|
|
408
|
-
* ```ts
|
|
409
|
-
* console.log(univerAPI.Enum.CommonHideTypes.ON);
|
|
410
|
-
* ```
|
|
411
|
-
*/
|
|
412
|
-
get CommonHideTypes() {
|
|
413
|
-
return le;
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* Copy paste types
|
|
417
|
-
*
|
|
418
|
-
* @example
|
|
419
|
-
* ```ts
|
|
420
|
-
* console.log(univerAPI.Enum.CopyPasteType.PASTE_VALUES);
|
|
421
|
-
* ```
|
|
422
|
-
*/
|
|
423
|
-
get CopyPasteType() {
|
|
424
|
-
return pe;
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* Delete direction types
|
|
428
|
-
*
|
|
429
|
-
* @example
|
|
430
|
-
* ```ts
|
|
431
|
-
* console.log(univerAPI.Enum.DeleteDirection.LEFT);
|
|
432
|
-
* ```
|
|
433
|
-
*/
|
|
434
|
-
get DeleteDirection() {
|
|
435
|
-
return he;
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* Developer metadata visibility types
|
|
439
|
-
*
|
|
440
|
-
* @example
|
|
441
|
-
* ```ts
|
|
442
|
-
* console.log(univerAPI.Enum.DeveloperMetadataVisibility.DOCUMENT);
|
|
443
|
-
* ```
|
|
444
|
-
*/
|
|
445
|
-
get DeveloperMetadataVisibility() {
|
|
446
|
-
return ue;
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* Dimension types
|
|
450
|
-
*
|
|
451
|
-
* @example
|
|
452
|
-
* ```ts
|
|
453
|
-
* console.log(univerAPI.Enum.Dimension.ROWS);
|
|
454
|
-
* ```
|
|
455
|
-
*/
|
|
456
|
-
get Dimension() {
|
|
457
|
-
return ye;
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
* Direction types
|
|
461
|
-
*
|
|
462
|
-
* @example
|
|
463
|
-
* ```ts
|
|
464
|
-
* console.log(univerAPI.Enum.Direction.UP);
|
|
465
|
-
* ```
|
|
466
|
-
*/
|
|
467
|
-
get Direction() {
|
|
468
|
-
return ge;
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* Interpolation point types
|
|
472
|
-
*
|
|
473
|
-
* @example
|
|
474
|
-
* ```ts
|
|
475
|
-
* console.log(univerAPI.Enum.InterpolationPointType.NUMBER);
|
|
476
|
-
* ```
|
|
477
|
-
*/
|
|
478
|
-
get InterpolationPointType() {
|
|
479
|
-
return ve;
|
|
480
|
-
}
|
|
481
|
-
/**
|
|
482
|
-
* Locale types
|
|
483
|
-
*
|
|
484
|
-
* @example
|
|
485
|
-
* ```ts
|
|
486
|
-
* console.log(univerAPI.Enum.LocaleType.EN_US);
|
|
487
|
-
* ```
|
|
488
|
-
*/
|
|
489
|
-
get LocaleType() {
|
|
490
|
-
return fe;
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* Mention types
|
|
494
|
-
*
|
|
495
|
-
* @example
|
|
496
|
-
* ```ts
|
|
497
|
-
* console.log(univerAPI.Enum.MentionType.PERSON);
|
|
498
|
-
* ```
|
|
499
|
-
*/
|
|
500
|
-
get MentionType() {
|
|
501
|
-
return _e;
|
|
502
|
-
}
|
|
503
|
-
/**
|
|
504
|
-
* Protection types
|
|
505
|
-
*
|
|
506
|
-
* @example
|
|
507
|
-
* ```ts
|
|
508
|
-
* console.log(univerAPI.Enum.ProtectionType.RANGE);
|
|
509
|
-
* ```
|
|
510
|
-
*/
|
|
511
|
-
get ProtectionType() {
|
|
512
|
-
return me;
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Relative date types
|
|
516
|
-
*
|
|
517
|
-
* @example
|
|
518
|
-
* ```ts
|
|
519
|
-
* console.log(univerAPI.Enum.RelativeDate.TODAY);
|
|
520
|
-
* ```
|
|
521
|
-
*/
|
|
522
|
-
get RelativeDate() {
|
|
523
|
-
return Ee;
|
|
524
|
-
}
|
|
525
|
-
/**
|
|
526
|
-
* Sheet types
|
|
527
|
-
*
|
|
528
|
-
* @example
|
|
529
|
-
* ```ts
|
|
530
|
-
* console.log(univerAPI.Enum.SheetTypes.GRID);
|
|
531
|
-
* ```
|
|
532
|
-
*/
|
|
533
|
-
get SheetTypes() {
|
|
534
|
-
return be;
|
|
535
|
-
}
|
|
536
|
-
/**
|
|
537
|
-
* Theme color types
|
|
538
|
-
*
|
|
539
|
-
* @example
|
|
540
|
-
* ```ts
|
|
541
|
-
* console.log(univerAPI.Enum.ThemeColorType.ACCENT1);
|
|
542
|
-
* ```
|
|
543
|
-
*/
|
|
544
|
-
get ThemeColorType() {
|
|
545
|
-
return Se;
|
|
546
|
-
}
|
|
547
|
-
};
|
|
548
|
-
/**
|
|
549
|
-
* @ignore
|
|
550
|
-
*/
|
|
551
|
-
d(g, "_instance");
|
|
552
|
-
let O = g;
|
|
553
|
-
const v = class v {
|
|
554
|
-
static get() {
|
|
555
|
-
if (this._instance)
|
|
556
|
-
return this._instance;
|
|
557
|
-
const e = new v();
|
|
558
|
-
return this._instance = e, e;
|
|
559
|
-
}
|
|
560
|
-
/**
|
|
561
|
-
* @ignore
|
|
562
|
-
*/
|
|
563
|
-
static extend(e) {
|
|
564
|
-
Object.getOwnPropertyNames(e.prototype).forEach((t) => {
|
|
565
|
-
t !== "constructor" && (this.prototype[t] = e.prototype[t]);
|
|
566
|
-
}), Object.getOwnPropertyNames(e).forEach((t) => {
|
|
567
|
-
t !== "prototype" && t !== "name" && t !== "length" && (this[t] = e[t]);
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
constructor() {
|
|
571
|
-
for (const e in v.prototype)
|
|
572
|
-
this[e] = v.prototype[e];
|
|
573
|
-
}
|
|
574
|
-
/**
|
|
575
|
-
* Event fired when a document is created
|
|
576
|
-
* @see {@link IDocCreatedParam}
|
|
577
|
-
* @example
|
|
578
|
-
* ```ts
|
|
579
|
-
* const disposable = univerAPI.addEvent(univerAPI.Event.DocCreated, (params) => {
|
|
580
|
-
* const { unitId, type, doc, unit } = params;
|
|
581
|
-
* console.log('doc created', params);
|
|
582
|
-
* });
|
|
583
|
-
*
|
|
584
|
-
* // Remove the event listener, use `disposable.dispose()`
|
|
585
|
-
* ```
|
|
586
|
-
*/
|
|
587
|
-
get DocCreated() {
|
|
588
|
-
return "DocCreated";
|
|
589
|
-
}
|
|
590
|
-
/**
|
|
591
|
-
* Event fired when a document is disposed
|
|
592
|
-
* @see {@link IDocDisposedEvent}
|
|
593
|
-
* @example
|
|
594
|
-
* ```ts
|
|
595
|
-
* const disposable = univerAPI.addEvent(univerAPI.Event.DocDisposed, (params) => {
|
|
596
|
-
* const { unitId, unitType, snapshot } = params;
|
|
597
|
-
* console.log('doc disposed', params);
|
|
598
|
-
* });
|
|
599
|
-
*
|
|
600
|
-
* // Remove the event listener, use `disposable.dispose()`
|
|
601
|
-
* ```
|
|
602
|
-
*/
|
|
603
|
-
get DocDisposed() {
|
|
604
|
-
return "DocDisposed";
|
|
605
|
-
}
|
|
606
|
-
/**
|
|
607
|
-
* Event fired when life cycle is changed
|
|
608
|
-
* @see {@link ILifeCycleChangedEvent}
|
|
609
|
-
* @example
|
|
610
|
-
* ```ts
|
|
611
|
-
* const disposable = univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, (params) => {
|
|
612
|
-
* const { stage } = params;
|
|
613
|
-
* console.log('life cycle changed', params);
|
|
614
|
-
* });
|
|
615
|
-
*
|
|
616
|
-
* // Remove the event listener, use `disposable.dispose()`
|
|
617
|
-
* ```
|
|
618
|
-
*/
|
|
619
|
-
get LifeCycleChanged() {
|
|
620
|
-
return "LifeCycleChanged";
|
|
621
|
-
}
|
|
622
|
-
/**
|
|
623
|
-
* Event fired when a redo command is executed
|
|
624
|
-
* @see {@link ICommandEvent}
|
|
625
|
-
* @example
|
|
626
|
-
* ```ts
|
|
627
|
-
* const disposable = univerAPI.addEvent(univerAPI.Event.Redo, (event) => {
|
|
628
|
-
* const { params, id, type } = event;
|
|
629
|
-
* console.log('redo command executed', event);
|
|
630
|
-
* });
|
|
631
|
-
*
|
|
632
|
-
* // Remove the event listener, use `disposable.dispose()`
|
|
633
|
-
* ```
|
|
634
|
-
*/
|
|
635
|
-
get Redo() {
|
|
636
|
-
return "Redo";
|
|
637
|
-
}
|
|
638
|
-
/**
|
|
639
|
-
* Event fired when an undo command is executed
|
|
640
|
-
* @see {@link ICommandEvent}
|
|
641
|
-
* @example
|
|
642
|
-
* ```ts
|
|
643
|
-
* const disposable = univerAPI.addEvent(univerAPI.Event.Undo, (event) => {
|
|
644
|
-
* const { params, id, type } = event;
|
|
645
|
-
* console.log('undo command executed', event);
|
|
646
|
-
* });
|
|
647
|
-
*
|
|
648
|
-
* // Remove the event listener, use `disposable.dispose()`
|
|
649
|
-
* ```
|
|
650
|
-
*/
|
|
651
|
-
get Undo() {
|
|
652
|
-
return "Undo";
|
|
653
|
-
}
|
|
654
|
-
/**
|
|
655
|
-
* Event fired before a redo command is executed
|
|
656
|
-
* @see {@link ICommandEvent}
|
|
657
|
-
* @example
|
|
658
|
-
* ```ts
|
|
659
|
-
* const disposable = univerAPI.addEvent(univerAPI.Event.BeforeRedo, (event) => {
|
|
660
|
-
* const { params, id, type } = event;
|
|
661
|
-
* console.log('before redo command executed', event);
|
|
662
|
-
*
|
|
663
|
-
* // Cancel the redo operation
|
|
664
|
-
* event.cancel = true;
|
|
665
|
-
* });
|
|
666
|
-
*
|
|
667
|
-
* // Remove the event listener, use `disposable.dispose()`
|
|
668
|
-
* ```
|
|
669
|
-
*/
|
|
670
|
-
get BeforeRedo() {
|
|
671
|
-
return "BeforeRedo";
|
|
672
|
-
}
|
|
673
|
-
/**
|
|
674
|
-
* Event fired before an undo command is executed
|
|
675
|
-
* @see {@link ICommandEvent}
|
|
676
|
-
* @example
|
|
677
|
-
* ```ts
|
|
678
|
-
* const disposable = univerAPI.addEvent(univerAPI.Event.BeforeUndo, (event) => {
|
|
679
|
-
* const { params, id, type } = event;
|
|
680
|
-
* console.log('before undo command executed', event);
|
|
681
|
-
*
|
|
682
|
-
* // Cancel the undo operation
|
|
683
|
-
* event.cancel = true;
|
|
684
|
-
* });
|
|
685
|
-
*
|
|
686
|
-
* // Remove the event listener, use `disposable.dispose()`
|
|
687
|
-
* ```
|
|
688
|
-
*/
|
|
689
|
-
get BeforeUndo() {
|
|
690
|
-
return "BeforeUndo";
|
|
691
|
-
}
|
|
692
|
-
/**
|
|
693
|
-
* Event fired when a command is executed
|
|
694
|
-
* @see {@link ICommandEvent}
|
|
695
|
-
* @example
|
|
696
|
-
* ```ts
|
|
697
|
-
* const disposable = univerAPI.addEvent(univerAPI.Event.CommandExecuted, (event) => {
|
|
698
|
-
* const { params, id, type, options } = event;
|
|
699
|
-
* console.log('command executed', event);
|
|
700
|
-
* });
|
|
701
|
-
*
|
|
702
|
-
* // Remove the event listener, use `disposable.dispose()`
|
|
703
|
-
* ```
|
|
704
|
-
*/
|
|
705
|
-
get CommandExecuted() {
|
|
706
|
-
return "CommandExecuted";
|
|
707
|
-
}
|
|
708
|
-
/**
|
|
709
|
-
* Event fired before a command is executed
|
|
710
|
-
* @see {@link ICommandEvent}
|
|
711
|
-
* @example
|
|
712
|
-
* ```ts
|
|
713
|
-
* const disposable = univerAPI.addEvent(univerAPI.Event.BeforeCommandExecute, (event) => {
|
|
714
|
-
* const { params, id, type, options } = event;
|
|
715
|
-
* console.log('before command executed', event);
|
|
716
|
-
*
|
|
717
|
-
* // Cancel the command execution
|
|
718
|
-
* event.cancel = true;
|
|
719
|
-
* });
|
|
720
|
-
*
|
|
721
|
-
* // Remove the event listener, use `disposable.dispose()`
|
|
722
|
-
* ```
|
|
723
|
-
*/
|
|
724
|
-
get BeforeCommandExecute() {
|
|
725
|
-
return "BeforeCommandExecute";
|
|
726
|
-
}
|
|
727
|
-
};
|
|
728
|
-
/**
|
|
729
|
-
* @ignore
|
|
730
|
-
*/
|
|
731
|
-
d(v, "_instance");
|
|
732
|
-
let j = v;
|
|
733
|
-
var Le = Object.getOwnPropertyDescriptor, Ne = (i, e, t, r) => {
|
|
734
|
-
for (var n = r > 1 ? void 0 : r ? Le(e, t) : e, o = i.length - 1, s; o >= 0; o--)
|
|
735
|
-
(s = i[o]) && (n = s(n) || n);
|
|
736
|
-
return n;
|
|
737
|
-
}, L = (i, e) => (t, r) => e(t, r, i);
|
|
738
|
-
let P = class extends $ {
|
|
739
|
-
constructor(i, e) {
|
|
740
|
-
super(), this._injector = i, this._lifecycleService = e;
|
|
741
|
-
}
|
|
742
|
-
/**
|
|
743
|
-
* @param callback
|
|
744
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
|
|
745
|
-
*/
|
|
746
|
-
onStarting(i) {
|
|
747
|
-
return l(this._lifecycleService.lifecycle$.pipe(b((e) => e === f.Starting)).subscribe(i));
|
|
748
|
-
}
|
|
749
|
-
/**
|
|
750
|
-
* @param callback
|
|
751
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
|
|
752
|
-
*/
|
|
753
|
-
onReady(i) {
|
|
754
|
-
return l(this._lifecycleService.lifecycle$.pipe(b((e) => e === f.Ready)).subscribe(i));
|
|
755
|
-
}
|
|
756
|
-
/**
|
|
757
|
-
* @param callback
|
|
758
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
|
|
759
|
-
*/
|
|
760
|
-
onRendered(i) {
|
|
761
|
-
return l(this._lifecycleService.lifecycle$.pipe(b((e) => e === f.Rendered)).subscribe(i));
|
|
762
|
-
}
|
|
763
|
-
/**
|
|
764
|
-
* @param callback
|
|
765
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
|
|
766
|
-
*/
|
|
767
|
-
onSteady(i) {
|
|
768
|
-
return l(this._lifecycleService.lifecycle$.pipe(b((e) => e === f.Steady)).subscribe(i));
|
|
769
|
-
}
|
|
770
|
-
/**
|
|
771
|
-
* @param callback
|
|
772
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeUndo, (event) => {})` as instead
|
|
773
|
-
*/
|
|
774
|
-
onBeforeUndo(i) {
|
|
775
|
-
return this._injector.get(y).beforeCommandExecuted((t) => {
|
|
776
|
-
if (t.id === h.id) {
|
|
777
|
-
const n = this._injector.get(E).pitchTopUndoElement();
|
|
778
|
-
n && i(n);
|
|
779
|
-
}
|
|
780
|
-
});
|
|
781
|
-
}
|
|
782
|
-
/**
|
|
783
|
-
* @param callback
|
|
784
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.Event.Undo, (event) => {})` as instead
|
|
785
|
-
*/
|
|
786
|
-
onUndo(i) {
|
|
787
|
-
return this._injector.get(y).onCommandExecuted((t) => {
|
|
788
|
-
if (t.id === h.id) {
|
|
789
|
-
const n = this._injector.get(E).pitchTopUndoElement();
|
|
790
|
-
n && i(n);
|
|
791
|
-
}
|
|
792
|
-
});
|
|
793
|
-
}
|
|
794
|
-
/**
|
|
795
|
-
* @param callback
|
|
796
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeRedo, (event) => {})` as instead
|
|
797
|
-
*/
|
|
798
|
-
onBeforeRedo(i) {
|
|
799
|
-
return this._injector.get(y).beforeCommandExecuted((t) => {
|
|
800
|
-
if (t.id === u.id) {
|
|
801
|
-
const n = this._injector.get(E).pitchTopRedoElement();
|
|
802
|
-
n && i(n);
|
|
803
|
-
}
|
|
804
|
-
});
|
|
805
|
-
}
|
|
806
|
-
/**
|
|
807
|
-
* @param callback
|
|
808
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.Event.Redo, (event) => {})` as instead
|
|
809
|
-
*/
|
|
810
|
-
onRedo(i) {
|
|
811
|
-
return this._injector.get(y).onCommandExecuted((t) => {
|
|
812
|
-
if (t.id === u.id) {
|
|
813
|
-
const n = this._injector.get(E).pitchTopRedoElement();
|
|
814
|
-
n && i(n);
|
|
815
|
-
}
|
|
816
|
-
});
|
|
817
|
-
}
|
|
818
|
-
};
|
|
819
|
-
P = Ne([
|
|
820
|
-
L(0, p(_)),
|
|
821
|
-
L(1, p(V))
|
|
822
|
-
], P);
|
|
823
|
-
var We = Object.getOwnPropertyDescriptor, Fe = (i, e, t, r) => {
|
|
824
|
-
for (var n = r > 1 ? void 0 : r ? We(e, t) : e, o = i.length - 1, s; o >= 0; o--)
|
|
825
|
-
(s = i[o]) && (n = s(n) || n);
|
|
826
|
-
return n;
|
|
827
|
-
}, qe = (i, e) => (t, r) => e(t, r, i);
|
|
828
|
-
let B = class extends Ve {
|
|
829
|
-
constructor(i, e) {
|
|
830
|
-
super(e), this.doc = i;
|
|
831
|
-
}
|
|
832
|
-
};
|
|
833
|
-
B = Fe([
|
|
834
|
-
qe(1, p(_))
|
|
835
|
-
], B);
|
|
836
|
-
class Ge {
|
|
837
|
-
constructor() {
|
|
838
|
-
d(this, "_eventRegistry", /* @__PURE__ */ new Map());
|
|
839
|
-
d(this, "_eventHandlerMap", /* @__PURE__ */ new Map());
|
|
840
|
-
d(this, "_eventHandlerRegisted", /* @__PURE__ */ new Map());
|
|
841
|
-
}
|
|
842
|
-
_ensureEventRegistry(e) {
|
|
843
|
-
return this._eventRegistry.has(e) || this._eventRegistry.set(e, new Ce()), this._eventRegistry.get(e);
|
|
844
|
-
}
|
|
845
|
-
registerEventHandler(e, t) {
|
|
846
|
-
const r = this._eventHandlerMap.get(e);
|
|
847
|
-
return r ? r.add(t) : this._eventHandlerMap.set(e, /* @__PURE__ */ new Set([t])), this._ensureEventRegistry(e).getData().length && this._initEventHandler(e), l(() => {
|
|
848
|
-
var n, o, s, c;
|
|
849
|
-
(n = this._eventHandlerMap.get(e)) == null || n.delete(t), (s = (o = this._eventHandlerRegisted.get(e)) == null ? void 0 : o.get(t)) == null || s.dispose(), (c = this._eventHandlerRegisted.get(e)) == null || c.delete(t);
|
|
850
|
-
});
|
|
851
|
-
}
|
|
852
|
-
removeEvent(e, t) {
|
|
853
|
-
const r = this._ensureEventRegistry(e);
|
|
854
|
-
if (r.delete(t), r.getData().length === 0) {
|
|
855
|
-
const n = this._eventHandlerRegisted.get(e);
|
|
856
|
-
n == null || n.forEach((o) => o.dispose()), this._eventHandlerRegisted.delete(e);
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
_initEventHandler(e) {
|
|
860
|
-
let t = this._eventHandlerRegisted.get(e);
|
|
861
|
-
const r = this._eventHandlerMap.get(e);
|
|
862
|
-
r && (!t || t.size === 0) && (t = /* @__PURE__ */ new Map(), this._eventHandlerRegisted.set(e, t), r == null || r.forEach((n) => {
|
|
863
|
-
t == null || t.set(n, l(n()));
|
|
864
|
-
}));
|
|
865
|
-
}
|
|
866
|
-
/**
|
|
867
|
-
* Add an event listener
|
|
868
|
-
* @param {string} event key of event
|
|
869
|
-
* @param {(params: IEventParamConfig[typeof event]) => void} callback callback when event triggered
|
|
870
|
-
* @returns {Disposable} The Disposable instance, for remove the listener
|
|
871
|
-
* @example
|
|
872
|
-
* ```ts
|
|
873
|
-
* univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, (params) => {
|
|
874
|
-
* const { stage } = params;
|
|
875
|
-
* console.log('life cycle changed', params);
|
|
876
|
-
* });
|
|
877
|
-
* ```
|
|
878
|
-
*/
|
|
879
|
-
addEvent(e, t) {
|
|
880
|
-
return this._ensureEventRegistry(e).add(t), this._initEventHandler(e), l(() => this.removeEvent(e, t));
|
|
881
|
-
}
|
|
882
|
-
/**
|
|
883
|
-
* Fire an event, used in internal only.
|
|
884
|
-
* @param {string} event key of event
|
|
885
|
-
* @param {any} params params of event
|
|
886
|
-
* @returns {boolean} should cancel
|
|
887
|
-
* @example
|
|
888
|
-
* ```ts
|
|
889
|
-
* this.fireEvent(univerAPI.Event.LifeCycleChanged, params);
|
|
890
|
-
* ```
|
|
891
|
-
*/
|
|
892
|
-
fireEvent(e, t) {
|
|
893
|
-
var r;
|
|
894
|
-
return (r = this._eventRegistry.get(e)) == null || r.getData().forEach((n) => {
|
|
895
|
-
n(t);
|
|
896
|
-
}), t.cancel;
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
var Je = Object.getOwnPropertyDescriptor, Ke = (i, e, t, r) => {
|
|
900
|
-
for (var n = r > 1 ? void 0 : r ? Je(e, t) : e, o = i.length - 1, s; o >= 0; o--)
|
|
901
|
-
(s = i[o]) && (n = s(n) || n);
|
|
902
|
-
return n;
|
|
903
|
-
}, N = (i, e) => (t, r) => e(t, r, i);
|
|
904
|
-
let H = class extends $ {
|
|
905
|
-
constructor(i, e) {
|
|
906
|
-
super(), this._injector = i, this._userManagerService = e;
|
|
907
|
-
}
|
|
908
|
-
/**
|
|
909
|
-
* Get current user info.
|
|
910
|
-
* @returns {IUser} Current user info.
|
|
911
|
-
* @example
|
|
912
|
-
* ```typescript
|
|
913
|
-
* univerAPI.getUserManager().getCurrentUser();
|
|
914
|
-
* ```
|
|
915
|
-
*/
|
|
916
|
-
getCurrentUser() {
|
|
917
|
-
return this._userManagerService.getCurrentUser();
|
|
918
|
-
}
|
|
919
|
-
};
|
|
920
|
-
H = Ke([
|
|
921
|
-
N(0, p(_)),
|
|
922
|
-
N(1, p(De))
|
|
923
|
-
], H);
|
|
924
|
-
const x = class x {
|
|
925
|
-
static get() {
|
|
926
|
-
if (this._instance)
|
|
927
|
-
return this._instance;
|
|
928
|
-
const e = new x();
|
|
929
|
-
return this._instance = e, e;
|
|
930
|
-
}
|
|
931
|
-
/**
|
|
932
|
-
* @ignore
|
|
933
|
-
*/
|
|
934
|
-
static extend(e) {
|
|
935
|
-
Object.getOwnPropertyNames(e.prototype).forEach((t) => {
|
|
936
|
-
t !== "constructor" && (this.prototype[t] = e.prototype[t]);
|
|
937
|
-
}), Object.getOwnPropertyNames(e).forEach((t) => {
|
|
938
|
-
t !== "prototype" && t !== "name" && t !== "length" && (this[t] = e[t]);
|
|
939
|
-
});
|
|
940
|
-
}
|
|
941
|
-
/**
|
|
942
|
-
* Rectangle utils, including range operations likes merge, subtract, split
|
|
943
|
-
*
|
|
944
|
-
* @example
|
|
945
|
-
* ```ts
|
|
946
|
-
* const ranges = [
|
|
947
|
-
* { startRow: 0, startColumn: 0, endRow: 1, endColumn: 1 },
|
|
948
|
-
* { startRow: 1, startColumn: 1, endRow: 2, endColumn: 2 }
|
|
949
|
-
* ];
|
|
950
|
-
* const merged = univerAPI.Util.rectangle.mergeRanges(ranges);
|
|
951
|
-
* console.log(merged);
|
|
952
|
-
* ```
|
|
953
|
-
*/
|
|
954
|
-
get rectangle() {
|
|
955
|
-
return xe;
|
|
956
|
-
}
|
|
957
|
-
/**
|
|
958
|
-
* Number format utils, including parse and strigify about date, price, etc
|
|
959
|
-
*
|
|
960
|
-
* @example
|
|
961
|
-
* ```ts
|
|
962
|
-
* const text = univerAPI.Util.numfmt.format('#,##0.00', 1234.567);
|
|
963
|
-
* console.log(text);
|
|
964
|
-
* ```
|
|
965
|
-
*/
|
|
966
|
-
get numfmt() {
|
|
967
|
-
return Te;
|
|
968
|
-
}
|
|
969
|
-
/**
|
|
970
|
-
* common tools
|
|
971
|
-
*
|
|
972
|
-
* @example
|
|
973
|
-
* ```ts
|
|
974
|
-
* const key = univerAPI.Util.tools.generateRandomId(6);
|
|
975
|
-
* console.log(key);
|
|
976
|
-
* ```
|
|
977
|
-
*/
|
|
978
|
-
get tools() {
|
|
979
|
-
return we;
|
|
980
|
-
}
|
|
981
|
-
};
|
|
982
|
-
/**
|
|
983
|
-
* @ignore
|
|
984
|
-
*/
|
|
985
|
-
d(x, "_instance");
|
|
986
|
-
let M = x;
|
|
987
|
-
var Qe = Object.getOwnPropertyDescriptor, Xe = (i, e, t, r) => {
|
|
988
|
-
for (var n = r > 1 ? void 0 : r ? Qe(e, t) : e, o = i.length - 1, s; o >= 0; o--)
|
|
989
|
-
(s = i[o]) && (n = s(n) || n);
|
|
990
|
-
return n;
|
|
991
|
-
}, C = (i, e) => (t, r) => e(t, r, i);
|
|
992
|
-
const w = /* @__PURE__ */ Symbol("initializers");
|
|
993
|
-
let U = class extends I {
|
|
994
|
-
constructor(e, t, r, n) {
|
|
995
|
-
super();
|
|
996
|
-
d(this, "_eventRegistry", new Ge());
|
|
997
|
-
d(this, "registerEventHandler", (e, t) => this._eventRegistry.registerEventHandler(e, t));
|
|
998
|
-
this._injector = e, this._commandService = t, this._univerInstanceService = r, this._lifecycleService = n, this.disposeWithMe(
|
|
999
|
-
this.registerEventHandler(
|
|
1000
|
-
this.Event.LifeCycleChanged,
|
|
1001
|
-
() => l(
|
|
1002
|
-
this._lifecycleService.lifecycle$.subscribe((s) => {
|
|
1003
|
-
this.fireEvent(this.Event.LifeCycleChanged, { stage: s });
|
|
1004
|
-
})
|
|
1005
|
-
)
|
|
1006
|
-
)
|
|
1007
|
-
), this._initUnitEvent(this._injector), this._initBeforeCommandEvent(this._injector), this._initCommandEvent(this._injector), this._injector.onDispose(() => {
|
|
1008
|
-
this.dispose();
|
|
1009
|
-
});
|
|
1010
|
-
const o = Object.getPrototypeOf(this)[w];
|
|
1011
|
-
if (o) {
|
|
1012
|
-
const s = this;
|
|
1013
|
-
o.forEach(function(c) {
|
|
1014
|
-
c.apply(s, [e]);
|
|
1015
|
-
});
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
/**
|
|
1019
|
-
* Create an FUniver instance, if the injector is not provided, it will create a new Univer instance.
|
|
1020
|
-
* @static
|
|
1021
|
-
* @param {Univer | Injector} wrapped - The Univer instance or injector instance.
|
|
1022
|
-
* @returns {FUniver} - The FUniver instance.
|
|
1023
|
-
*
|
|
1024
|
-
* @example
|
|
1025
|
-
* ```ts
|
|
1026
|
-
* const univerAPI = FUniver.newAPI(univer);
|
|
1027
|
-
* ```
|
|
1028
|
-
*/
|
|
1029
|
-
static newAPI(e) {
|
|
1030
|
-
return (e instanceof Re ? e.__getInjector() : e).createInstance(U);
|
|
1031
|
-
}
|
|
1032
|
-
/**
|
|
1033
|
-
* @ignore
|
|
1034
|
-
*/
|
|
1035
|
-
_initialize(e) {
|
|
1036
|
-
}
|
|
1037
|
-
/**
|
|
1038
|
-
* @ignore
|
|
1039
|
-
*/
|
|
1040
|
-
static extend(e) {
|
|
1041
|
-
Object.getOwnPropertyNames(e.prototype).forEach((t) => {
|
|
1042
|
-
if (t === "_initialize") {
|
|
1043
|
-
let r = this.prototype[w];
|
|
1044
|
-
r || (r = [], this.prototype[w] = r), r.push(e.prototype._initialize);
|
|
1045
|
-
} else t !== "constructor" && (this.prototype[t] = e.prototype[t]);
|
|
1046
|
-
}), Object.getOwnPropertyNames(e).forEach((t) => {
|
|
1047
|
-
t !== "prototype" && t !== "name" && t !== "length" && (this[t] = e[t]);
|
|
1048
|
-
});
|
|
1049
|
-
}
|
|
1050
|
-
_initCommandEvent(e) {
|
|
1051
|
-
const t = e.get(y);
|
|
1052
|
-
this.disposeWithMe(
|
|
1053
|
-
this.registerEventHandler(
|
|
1054
|
-
this.Event.Redo,
|
|
1055
|
-
() => t.onCommandExecuted((r) => {
|
|
1056
|
-
const { id: n, type: o, params: s } = r;
|
|
1057
|
-
if (r.id === u.id) {
|
|
1058
|
-
const a = { id: n, type: o, params: s };
|
|
1059
|
-
this.fireEvent(this.Event.Redo, a);
|
|
1060
|
-
}
|
|
1061
|
-
})
|
|
1062
|
-
)
|
|
1063
|
-
), this.disposeWithMe(
|
|
1064
|
-
this.registerEventHandler(
|
|
1065
|
-
this.Event.Undo,
|
|
1066
|
-
() => t.onCommandExecuted((r) => {
|
|
1067
|
-
const { id: n, type: o, params: s } = r;
|
|
1068
|
-
if (r.id === h.id) {
|
|
1069
|
-
const a = { id: n, type: o, params: s };
|
|
1070
|
-
this.fireEvent(this.Event.Undo, a);
|
|
1071
|
-
}
|
|
1072
|
-
})
|
|
1073
|
-
)
|
|
1074
|
-
), this.disposeWithMe(
|
|
1075
|
-
this.registerEventHandler(
|
|
1076
|
-
this.Event.CommandExecuted,
|
|
1077
|
-
() => t.onCommandExecuted((r, n) => {
|
|
1078
|
-
const { id: o, type: s, params: c } = r;
|
|
1079
|
-
if (r.id !== u.id && r.id !== h.id) {
|
|
1080
|
-
const m = { id: o, type: s, params: c, options: n };
|
|
1081
|
-
this.fireEvent(this.Event.CommandExecuted, m);
|
|
1082
|
-
}
|
|
1083
|
-
})
|
|
1084
|
-
)
|
|
1085
|
-
);
|
|
1086
|
-
}
|
|
1087
|
-
_initBeforeCommandEvent(e) {
|
|
1088
|
-
const t = e.get(y);
|
|
1089
|
-
this.disposeWithMe(
|
|
1090
|
-
this.registerEventHandler(
|
|
1091
|
-
this.Event.BeforeRedo,
|
|
1092
|
-
() => t.beforeCommandExecuted((r) => {
|
|
1093
|
-
const { id: n, type: o, params: s } = r;
|
|
1094
|
-
if (r.id === u.id) {
|
|
1095
|
-
const a = { id: n, type: o, params: s };
|
|
1096
|
-
if (this.fireEvent(this.Event.BeforeRedo, a), a.cancel)
|
|
1097
|
-
throw new T();
|
|
1098
|
-
}
|
|
1099
|
-
})
|
|
1100
|
-
)
|
|
1101
|
-
), this.disposeWithMe(
|
|
1102
|
-
this.registerEventHandler(
|
|
1103
|
-
this.Event.BeforeUndo,
|
|
1104
|
-
() => t.beforeCommandExecuted((r) => {
|
|
1105
|
-
const { id: n, type: o, params: s } = r;
|
|
1106
|
-
if (r.id === h.id) {
|
|
1107
|
-
const a = { id: n, type: o, params: s };
|
|
1108
|
-
if (this.fireEvent(this.Event.BeforeUndo, a), a.cancel)
|
|
1109
|
-
throw new T();
|
|
1110
|
-
}
|
|
1111
|
-
})
|
|
1112
|
-
)
|
|
1113
|
-
), this.disposeWithMe(
|
|
1114
|
-
this.registerEventHandler(
|
|
1115
|
-
this.Event.BeforeCommandExecute,
|
|
1116
|
-
() => t.beforeCommandExecuted((r, n) => {
|
|
1117
|
-
const { id: o, type: s, params: c } = r;
|
|
1118
|
-
if (r.id !== u.id && r.id !== h.id) {
|
|
1119
|
-
const m = { id: o, type: s, params: c, options: n };
|
|
1120
|
-
if (this.fireEvent(this.Event.BeforeCommandExecute, m), m.cancel)
|
|
1121
|
-
throw new T();
|
|
1122
|
-
}
|
|
1123
|
-
})
|
|
1124
|
-
)
|
|
1125
|
-
);
|
|
1126
|
-
}
|
|
1127
|
-
_initUnitEvent(e) {
|
|
1128
|
-
const t = e.get(W);
|
|
1129
|
-
this.disposeWithMe(
|
|
1130
|
-
this.registerEventHandler(
|
|
1131
|
-
this.Event.DocDisposed,
|
|
1132
|
-
() => t.unitDisposed$.subscribe((r) => {
|
|
1133
|
-
r.type === R.UNIVER_DOC && this.fireEvent(this.Event.DocDisposed, {
|
|
1134
|
-
unitId: r.getUnitId(),
|
|
1135
|
-
unitType: r.type,
|
|
1136
|
-
snapshot: r.getSnapshot()
|
|
1137
|
-
});
|
|
1138
|
-
})
|
|
1139
|
-
)
|
|
1140
|
-
), this.disposeWithMe(
|
|
1141
|
-
this.registerEventHandler(
|
|
1142
|
-
this.Event.DocCreated,
|
|
1143
|
-
() => t.unitAdded$.subscribe((r) => {
|
|
1144
|
-
if (r.type === R.UNIVER_DOC) {
|
|
1145
|
-
const n = r, o = e.createInstance(B, n);
|
|
1146
|
-
this.fireEvent(this.Event.DocCreated, {
|
|
1147
|
-
unitId: r.getUnitId(),
|
|
1148
|
-
type: r.type,
|
|
1149
|
-
doc: o,
|
|
1150
|
-
unit: o
|
|
1151
|
-
});
|
|
1152
|
-
}
|
|
1153
|
-
})
|
|
1154
|
-
)
|
|
1155
|
-
);
|
|
1156
|
-
}
|
|
1157
|
-
/**
|
|
1158
|
-
* Dispose the UniverSheet by the `unitId`. The UniverSheet would be unload from the application.
|
|
1159
|
-
* @param unitId The unit id of the UniverSheet.
|
|
1160
|
-
* @returns Whether the Univer instance is disposed successfully.
|
|
1161
|
-
*
|
|
1162
|
-
* @example
|
|
1163
|
-
* ```ts
|
|
1164
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1165
|
-
* const unitId = fWorkbook?.getId();
|
|
1166
|
-
*
|
|
1167
|
-
* if (unitId) {
|
|
1168
|
-
* univerAPI.disposeUnit(unitId);
|
|
1169
|
-
* }
|
|
1170
|
-
* ```
|
|
1171
|
-
*/
|
|
1172
|
-
disposeUnit(e) {
|
|
1173
|
-
return this._univerInstanceService.disposeUnit(e);
|
|
1174
|
-
}
|
|
1175
|
-
/**
|
|
1176
|
-
* Get the current lifecycle stage.
|
|
1177
|
-
* @returns {LifecycleStages} - The current lifecycle stage.
|
|
1178
|
-
*
|
|
1179
|
-
* @example
|
|
1180
|
-
* ```ts
|
|
1181
|
-
* const stage = univerAPI.getCurrentLifecycleStage();
|
|
1182
|
-
* console.log(stage);
|
|
1183
|
-
* ```
|
|
1184
|
-
*/
|
|
1185
|
-
getCurrentLifecycleStage() {
|
|
1186
|
-
return this._injector.get(V).stage;
|
|
1187
|
-
}
|
|
1188
|
-
/**
|
|
1189
|
-
* Undo an editing on the currently focused document.
|
|
1190
|
-
* @returns {Promise<boolean>} undo result
|
|
1191
|
-
*
|
|
1192
|
-
* @example
|
|
1193
|
-
* ```ts
|
|
1194
|
-
* await univerAPI.undo();
|
|
1195
|
-
* ```
|
|
1196
|
-
*/
|
|
1197
|
-
undo() {
|
|
1198
|
-
return this._commandService.executeCommand(h.id);
|
|
1199
|
-
}
|
|
1200
|
-
/**
|
|
1201
|
-
* Redo an editing on the currently focused document.
|
|
1202
|
-
* @returns {Promise<boolean>} redo result
|
|
1203
|
-
*
|
|
1204
|
-
* @example
|
|
1205
|
-
* ```ts
|
|
1206
|
-
* await univerAPI.redo();
|
|
1207
|
-
* ```
|
|
1208
|
-
*/
|
|
1209
|
-
redo() {
|
|
1210
|
-
return this._commandService.executeCommand(u.id);
|
|
1211
|
-
}
|
|
1212
|
-
/**
|
|
1213
|
-
* Toggle dark mode on or off.
|
|
1214
|
-
* @param {boolean} isDarkMode - Whether the dark mode is enabled.
|
|
1215
|
-
* @example
|
|
1216
|
-
* ```ts
|
|
1217
|
-
* univerAPI.toggleDarkMode(true);
|
|
1218
|
-
* ```
|
|
1219
|
-
*/
|
|
1220
|
-
toggleDarkMode(e) {
|
|
1221
|
-
this._injector.get(Oe).setDarkMode(e);
|
|
1222
|
-
}
|
|
1223
|
-
/**
|
|
1224
|
-
* Load locales for the given locale.
|
|
1225
|
-
* @description This method is utilized to load locales, which can be either built-in or custom-defined.
|
|
1226
|
-
* @param {string} locale - A unique locale identifier.
|
|
1227
|
-
* @param {ILanguagePack} locales - The locales object containing the translations.
|
|
1228
|
-
* @example
|
|
1229
|
-
* ```ts
|
|
1230
|
-
* univerAPI.loadLocales('esES', {
|
|
1231
|
-
* 'Hello World': 'Hola Mundo',
|
|
1232
|
-
* });
|
|
1233
|
-
* ```
|
|
1234
|
-
*/
|
|
1235
|
-
loadLocales(e, t) {
|
|
1236
|
-
this._injector.get(z).load({ [e]: t });
|
|
1237
|
-
}
|
|
1238
|
-
/**
|
|
1239
|
-
* Set the current locale.
|
|
1240
|
-
* @param {string} locale - A unique locale identifier.
|
|
1241
|
-
* @example
|
|
1242
|
-
* ```ts
|
|
1243
|
-
* univerAPI.setLocale('esES');
|
|
1244
|
-
* ```
|
|
1245
|
-
*/
|
|
1246
|
-
setLocale(e) {
|
|
1247
|
-
this._injector.get(z).setLocale(e);
|
|
1248
|
-
}
|
|
1249
|
-
/**
|
|
1250
|
-
* Register a callback that will be triggered before invoking a command.
|
|
1251
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeCommandExecute, (event) => {})` instead.
|
|
1252
|
-
* @param {CommandListener} callback The callback.
|
|
1253
|
-
* @returns {IDisposable} The disposable instance.
|
|
1254
|
-
*/
|
|
1255
|
-
onBeforeCommandExecute(e) {
|
|
1256
|
-
return this._commandService.beforeCommandExecuted((t, r) => {
|
|
1257
|
-
e(t, r);
|
|
1258
|
-
});
|
|
1259
|
-
}
|
|
1260
|
-
/**
|
|
1261
|
-
* Register a callback that will be triggered when a command is invoked.
|
|
1262
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.Event.CommandExecuted, (event) => {})` instead.
|
|
1263
|
-
* @param {CommandListener} callback The callback.
|
|
1264
|
-
* @returns {IDisposable} The disposable instance.
|
|
1265
|
-
*/
|
|
1266
|
-
onCommandExecuted(e) {
|
|
1267
|
-
return this._commandService.onCommandExecuted((t, r) => {
|
|
1268
|
-
e(t, r);
|
|
1269
|
-
});
|
|
1270
|
-
}
|
|
1271
|
-
/**
|
|
1272
|
-
* Execute a command with the given id and parameters.
|
|
1273
|
-
* @param id Identifier of the command.
|
|
1274
|
-
* @param params Parameters of this execution.
|
|
1275
|
-
* @param options Options of this execution.
|
|
1276
|
-
* @returns The result of the execution. It is a boolean value by default which indicates the command is executed.
|
|
1277
|
-
*
|
|
1278
|
-
* @example
|
|
1279
|
-
* ```ts
|
|
1280
|
-
* univerAPI.executeCommand('sheet.command.set-range-values', {
|
|
1281
|
-
* value: { v: "Hello, Univer!" },
|
|
1282
|
-
* range: { startRow: 0, startColumn: 0, endRow: 0, endColumn: 0 }
|
|
1283
|
-
* });
|
|
1284
|
-
* ```
|
|
1285
|
-
*/
|
|
1286
|
-
executeCommand(e, t, r) {
|
|
1287
|
-
return this._commandService.executeCommand(e, t, r);
|
|
1288
|
-
}
|
|
1289
|
-
/**
|
|
1290
|
-
* Execute a command with the given id and parameters synchronously.
|
|
1291
|
-
* @param id Identifier of the command.
|
|
1292
|
-
* @param params Parameters of this execution.
|
|
1293
|
-
* @param options Options of this execution.
|
|
1294
|
-
* @returns The result of the execution. It is a boolean value by default which indicates the command is executed.
|
|
1295
|
-
*
|
|
1296
|
-
* @example
|
|
1297
|
-
* ```ts
|
|
1298
|
-
* univerAPI.syncExecuteCommand('sheet.command.set-range-values', {
|
|
1299
|
-
* value: { v: "Hello, Univer!" },
|
|
1300
|
-
* range: { startRow: 0, startColumn: 0, endRow: 0, endColumn: 0 }
|
|
1301
|
-
* });
|
|
1302
|
-
* ```
|
|
1303
|
-
*/
|
|
1304
|
-
syncExecuteCommand(e, t, r) {
|
|
1305
|
-
return this._commandService.syncExecuteCommand(e, t, r);
|
|
1306
|
-
}
|
|
1307
|
-
/**
|
|
1308
|
-
* Get hooks.
|
|
1309
|
-
* @deprecated use `addEvent` instead.
|
|
1310
|
-
* @returns {FHooks} FHooks instance
|
|
1311
|
-
*/
|
|
1312
|
-
getHooks() {
|
|
1313
|
-
return this._injector.createInstance(P);
|
|
1314
|
-
}
|
|
1315
|
-
get Enum() {
|
|
1316
|
-
return O.get();
|
|
1317
|
-
}
|
|
1318
|
-
get Event() {
|
|
1319
|
-
return j.get();
|
|
1320
|
-
}
|
|
1321
|
-
get Util() {
|
|
1322
|
-
return M.get();
|
|
1323
|
-
}
|
|
1324
|
-
/**
|
|
1325
|
-
* Add an event listener
|
|
1326
|
-
* @param {string} event key of event
|
|
1327
|
-
* @param {(params: IEventParamConfig[typeof event]) => void} callback callback when event triggered
|
|
1328
|
-
* @returns {Disposable} The Disposable instance, for remove the listener
|
|
1329
|
-
* @example
|
|
1330
|
-
* ```ts
|
|
1331
|
-
* // Add life cycle changed event listener
|
|
1332
|
-
* const disposable = univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, (params) => {
|
|
1333
|
-
* const { stage } = params;
|
|
1334
|
-
* console.log('life cycle changed', params);
|
|
1335
|
-
* });
|
|
1336
|
-
*
|
|
1337
|
-
* // Remove the event listener, use `disposable.dispose()`
|
|
1338
|
-
* ```
|
|
1339
|
-
*/
|
|
1340
|
-
addEvent(e, t) {
|
|
1341
|
-
if (!e || !t) throw new Error("Cannot add empty event");
|
|
1342
|
-
return this._eventRegistry.addEvent(e, t);
|
|
1343
|
-
}
|
|
1344
|
-
/**
|
|
1345
|
-
* Fire an event, used in internal only.
|
|
1346
|
-
* @param {string} event key of event
|
|
1347
|
-
* @param {any} params params of event
|
|
1348
|
-
* @returns {boolean} should cancel
|
|
1349
|
-
* @example
|
|
1350
|
-
* ```ts
|
|
1351
|
-
* this.fireEvent(univerAPI.Event.LifeCycleChanged, params);
|
|
1352
|
-
* ```
|
|
1353
|
-
*/
|
|
1354
|
-
fireEvent(e, t) {
|
|
1355
|
-
return this._eventRegistry.fireEvent(e, t);
|
|
1356
|
-
}
|
|
1357
|
-
getUserManager() {
|
|
1358
|
-
return this._injector.createInstance(H);
|
|
1359
|
-
}
|
|
1360
|
-
/**
|
|
1361
|
-
* Create a new blob.
|
|
1362
|
-
* @returns {FBlob} The new blob instance
|
|
1363
|
-
* @example
|
|
1364
|
-
* ```ts
|
|
1365
|
-
* const blob = univerAPI.newBlob();
|
|
1366
|
-
* ```
|
|
1367
|
-
*/
|
|
1368
|
-
newBlob() {
|
|
1369
|
-
return this._injector.createInstance(D);
|
|
1370
|
-
}
|
|
1371
|
-
/**
|
|
1372
|
-
* Create a new rich text.
|
|
1373
|
-
* @param {IDocumentData} data
|
|
1374
|
-
* @returns {RichTextBuilder} The new rich text instance
|
|
1375
|
-
* @example
|
|
1376
|
-
* ```ts
|
|
1377
|
-
* const richText = univerAPI.newRichText({ body: { dataStream: 'Hello World\r\n' } });
|
|
1378
|
-
* const range = univerAPI.getActiveWorkbook().getActiveSheet().getRange('A1');
|
|
1379
|
-
* range.setRichTextValueForCell(richText);
|
|
1380
|
-
* ```
|
|
1381
|
-
*/
|
|
1382
|
-
newRichText(e) {
|
|
1383
|
-
return je.create(e);
|
|
1384
|
-
}
|
|
1385
|
-
/**
|
|
1386
|
-
* Create a new rich text value.
|
|
1387
|
-
* @param {IDocumentData} data - The rich text data
|
|
1388
|
-
* @returns {RichTextValue} The new rich text value instance
|
|
1389
|
-
* @example
|
|
1390
|
-
* ```ts
|
|
1391
|
-
* const richTextValue = univerAPI.newRichTextValue({ body: { dataStream: 'Hello World\r\n' } });
|
|
1392
|
-
* const range = univerAPI.getActiveWorkbook().getActiveSheet().getRange('A1');
|
|
1393
|
-
* range.setRichTextValueForCell(richTextValue);
|
|
1394
|
-
* ```
|
|
1395
|
-
*/
|
|
1396
|
-
newRichTextValue(e) {
|
|
1397
|
-
return Pe.create(e);
|
|
1398
|
-
}
|
|
1399
|
-
/**
|
|
1400
|
-
* Create a new paragraph style.
|
|
1401
|
-
* @param {IParagraphStyle} style - The paragraph style
|
|
1402
|
-
* @returns {ParagraphStyleBuilder} The new paragraph style instance
|
|
1403
|
-
* @example
|
|
1404
|
-
* ```ts
|
|
1405
|
-
* const richText = univerAPI.newRichText({ body: { dataStream: 'Hello World\r\n' } });
|
|
1406
|
-
* const paragraphStyle = univerAPI.newParagraphStyle({ textStyle: { ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE } });
|
|
1407
|
-
* richText.insertParagraph(paragraphStyle);
|
|
1408
|
-
* const range = univerAPI.getActiveWorkbook().getActiveSheet().getRange('A1');
|
|
1409
|
-
* range.setRichTextValueForCell(richText);
|
|
1410
|
-
* ```
|
|
1411
|
-
*/
|
|
1412
|
-
newParagraphStyle(e) {
|
|
1413
|
-
return Be.create(e);
|
|
1414
|
-
}
|
|
1415
|
-
/**
|
|
1416
|
-
* Create a new paragraph style value.
|
|
1417
|
-
* @param {IParagraphStyle} style - The paragraph style
|
|
1418
|
-
* @returns {ParagraphStyleValue} The new paragraph style value instance
|
|
1419
|
-
* @example
|
|
1420
|
-
* ```ts
|
|
1421
|
-
* const paragraphStyleValue = univerAPI.newParagraphStyleValue();
|
|
1422
|
-
* ```
|
|
1423
|
-
*/
|
|
1424
|
-
newParagraphStyleValue(e) {
|
|
1425
|
-
return He.create(e);
|
|
1426
|
-
}
|
|
1427
|
-
/**
|
|
1428
|
-
* Create a new text style.
|
|
1429
|
-
* @param {ITextStyle} style - The text style
|
|
1430
|
-
* @returns {TextStyleBuilder} The new text style instance
|
|
1431
|
-
* @example
|
|
1432
|
-
* ```ts
|
|
1433
|
-
* const textStyle = univerAPI.newTextStyle();
|
|
1434
|
-
* ```
|
|
1435
|
-
*/
|
|
1436
|
-
newTextStyle(e) {
|
|
1437
|
-
return Me.create(e);
|
|
1438
|
-
}
|
|
1439
|
-
/**
|
|
1440
|
-
* Create a new text style value.
|
|
1441
|
-
* @param {ITextStyle} style - The text style
|
|
1442
|
-
* @returns {TextStyleValue} The new text style value instance
|
|
1443
|
-
* @example
|
|
1444
|
-
* ```ts
|
|
1445
|
-
* const textStyleValue = univerAPI.newTextStyleValue();
|
|
1446
|
-
* ```
|
|
1447
|
-
*/
|
|
1448
|
-
newTextStyleValue(e) {
|
|
1449
|
-
return Ue.create(e);
|
|
1450
|
-
}
|
|
1451
|
-
/**
|
|
1452
|
-
* Create a new text decoration.
|
|
1453
|
-
* @param {ITextDecoration} decoration - The text decoration
|
|
1454
|
-
* @returns {TextDecorationBuilder} The new text decoration instance
|
|
1455
|
-
* @example
|
|
1456
|
-
* ```ts
|
|
1457
|
-
* const decoration = univerAPI.newTextDecoration();
|
|
1458
|
-
* ```
|
|
1459
|
-
*/
|
|
1460
|
-
newTextDecoration(e) {
|
|
1461
|
-
return new Ie(e);
|
|
1462
|
-
}
|
|
1463
|
-
};
|
|
1464
|
-
U = Xe([
|
|
1465
|
-
C(0, p(_)),
|
|
1466
|
-
C(1, y),
|
|
1467
|
-
C(2, W),
|
|
1468
|
-
C(3, p(V))
|
|
1469
|
-
], U);
|
|
1470
|
-
export {
|
|
1471
|
-
$ as FBase,
|
|
1472
|
-
Ve as FBaseInitialable,
|
|
1473
|
-
D as FBlob,
|
|
1474
|
-
O as FEnum,
|
|
1475
|
-
j as FEventName,
|
|
1476
|
-
P as FHooks,
|
|
1477
|
-
U as FUniver,
|
|
1478
|
-
M as FUtil
|
|
1479
|
-
};
|
|
1
|
+
import{AbsoluteRefType as e,AutoFillSeries as t,BaselineOffset as n,BooleanNumber as r,BorderStyleTypes as i,BorderType as a,CanceledError as o,ColorType as s,CommandType as ee,CommonHideTypes as te,CopyPasteType as ne,DataValidationErrorStyle as c,DataValidationOperator as l,DataValidationRenderMode as re,DataValidationStatus as u,DataValidationType as ie,DeleteDirection as ae,DeveloperMetadataVisibility as oe,Dimension as se,Direction as ce,Disposable as d,HorizontalAlign as le,ICommandService as f,IUndoRedoService as p,IUniverInstanceService as m,Inject as h,Injector as g,InterpolationPointType as ue,LifecycleService as _,LifecycleStages as v,LocaleService as y,LocaleType as de,MentionType as fe,ParagraphStyleBuilder as pe,ParagraphStyleValue as me,ProtectionType as he,Rectangle as ge,RedoCommand as b,Registry as _e,RelativeDate as ve,RichTextBuilder as ye,RichTextValue as be,SheetTypes as xe,TextDecoration as x,TextDecorationBuilder as S,TextDirection as C,TextStyleBuilder as w,TextStyleValue as T,ThemeColorType as E,ThemeService as D,Tools as O,UndoCommand as k,Univer as A,UniverInstanceType as j,UserManagerService as M,VerticalAlign as Se,WrapStrategy as Ce,numfmt as we,toDisposable as N}from"@univerjs/core";import{filter as P}from"rxjs";var F=class extends d{static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};const I=Symbol(`initializers`),L=Symbol(`manualInit`);var R=class extends d{constructor(e){if(super(),this._injector=e,this.constructor[L])return;let t=this,n=Object.getPrototypeOf(this)[I];n&&n.forEach(function(n){n.apply(t,[e])})}_initialize(e,...t){}_runInitializers(...e){let t=Object.getPrototypeOf(this)[I];t!=null&&t.length&&t.forEach(t=>t.apply(this,e))}static _enableManualInit(){this[L]=!0}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[I];t||(t=[],this.prototype[I]=t),t.push(e.prototype._initialize)}else t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};function z(e,t){return function(n,r){t(n,r,e)}}function B(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var V;let H=V=class extends F{constructor(e,t){super(),this._blob=e,this._injector=t}copyBlob(){return this._injector.createInstance(V,this._blob)}getAs(e){let t=this.copyBlob();return t.setContentType(e),t}getDataAsString(e){return this._blob===null?Promise.resolve(``):e===void 0?this._blob.text():new Promise((t,n)=>{this._blob.arrayBuffer().then(n=>{t(new TextDecoder(e).decode(n))}).catch(e=>{n(Error(`Failed to read Blob as ArrayBuffer: ${e.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(e=>new Uint8Array(e)):Promise.reject(Error(`Blob is undefined or null.`))}setBytes(e){return this._blob=new Blob([e.buffer]),this}setDataFromString(e,t){let n=t==null?`text/plain`:t;return this._blob=new Blob([e],{type:n}),this}getContentType(){var e;return(e=this._blob)==null?void 0:e.type}setContentType(e){var t;return this._blob=(t=this._blob)==null?void 0:t.slice(0,this._blob.size,e),this}};H=V=B([z(1,h(g))],H);function U(e){"@babel/helpers - typeof";return U=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},U(e)}function Te(e,t){if(U(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(U(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ee(e){var t=Te(e,`string`);return U(t)==`symbol`?t:t+``}function W(e,t,n){return(t=Ee(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var G=class o{static get(){if(this._instance)return this._instance;let e=new o;return this._instance=e,e}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let e in o.prototype)this[e]=o.prototype[e]}get AbsoluteRefType(){return e}get UniverInstanceType(){return j}get LifecycleStages(){return v}get DataValidationType(){return ie}get DataValidationErrorStyle(){return c}get DataValidationRenderMode(){return re}get DataValidationOperator(){return l}get DataValidationStatus(){return u}get CommandType(){return ee}get BaselineOffset(){return n}get BooleanNumber(){return r}get HorizontalAlign(){return le}get TextDecoration(){return x}get TextDirection(){return C}get VerticalAlign(){return Se}get WrapStrategy(){return Ce}get BorderType(){return a}get BorderStyleTypes(){return i}get AutoFillSeries(){return t}get ColorType(){return s}get CommonHideTypes(){return te}get CopyPasteType(){return ne}get DeleteDirection(){return ae}get DeveloperMetadataVisibility(){return oe}get Dimension(){return se}get Direction(){return ce}get InterpolationPointType(){return ue}get LocaleType(){return de}get MentionType(){return fe}get ProtectionType(){return he}get RelativeDate(){return ve}get SheetTypes(){return xe}get ThemeColorType(){return E}};W(G,`_instance`,void 0);var K=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.prototype[t]}get DocCreated(){return`DocCreated`}get DocDisposed(){return`DocDisposed`}get LifeCycleChanged(){return`LifeCycleChanged`}get Redo(){return`Redo`}get Undo(){return`Undo`}get BeforeRedo(){return`BeforeRedo`}get BeforeUndo(){return`BeforeUndo`}get CommandExecuted(){return`CommandExecuted`}get BeforeCommandExecute(){return`BeforeCommandExecute`}};W(K,`_instance`,void 0);let q=class extends F{constructor(e,t){super(),this._injector=e,this._lifecycleService=t}onStarting(e){return N(this._lifecycleService.lifecycle$.pipe(P(e=>e===v.Starting)).subscribe(e))}onReady(e){return N(this._lifecycleService.lifecycle$.pipe(P(e=>e===v.Ready)).subscribe(e))}onRendered(e){return N(this._lifecycleService.lifecycle$.pipe(P(e=>e===v.Rendered)).subscribe(e))}onSteady(e){return N(this._lifecycleService.lifecycle$.pipe(P(e=>e===v.Steady)).subscribe(e))}onBeforeUndo(e){return this._injector.get(f).beforeCommandExecuted(t=>{if(t.id===k.id){let t=this._injector.get(p).pitchTopUndoElement();t&&e(t)}})}onUndo(e){return this._injector.get(f).onCommandExecuted(t=>{if(t.id===k.id){let t=this._injector.get(p).pitchTopUndoElement();t&&e(t)}})}onBeforeRedo(e){return this._injector.get(f).beforeCommandExecuted(t=>{if(t.id===b.id){let t=this._injector.get(p).pitchTopRedoElement();t&&e(t)}})}onRedo(e){return this._injector.get(f).onCommandExecuted(t=>{if(t.id===b.id){let t=this._injector.get(p).pitchTopRedoElement();t&&e(t)}})}};q=B([z(0,h(g)),z(1,h(_))],q);let J=class extends R{constructor(e,t){super(t),this.doc=e}};J=B([z(1,h(g))],J);var De=class{constructor(){W(this,`_eventRegistry`,new Map),W(this,`_eventHandlerMap`,new Map),W(this,`_eventHandlerRegisted`,new Map)}_ensureEventRegistry(e){return this._eventRegistry.has(e)||this._eventRegistry.set(e,new _e),this._eventRegistry.get(e)}registerEventHandler(e,t){let n=this._eventHandlerMap.get(e);return n?n.add(t):this._eventHandlerMap.set(e,new Set([t])),this._ensureEventRegistry(e).getData().length&&this._initEventHandler(e),N(()=>{var n,r,i;(n=this._eventHandlerMap.get(e))==null||n.delete(t),(r=this._eventHandlerRegisted.get(e))==null||(r=r.get(t))==null||r.dispose(),(i=this._eventHandlerRegisted.get(e))==null||i.delete(t)})}removeEvent(e,t){let n=this._ensureEventRegistry(e);if(n.delete(t),n.getData().length===0){let t=this._eventHandlerRegisted.get(e);t==null||t.forEach(e=>e.dispose()),this._eventHandlerRegisted.delete(e)}}_initEventHandler(e){let t=this._eventHandlerRegisted.get(e),n=this._eventHandlerMap.get(e);n&&(!t||t.size===0)&&(t=new Map,this._eventHandlerRegisted.set(e,t),n==null||n.forEach(e=>{t==null||t.set(e,N(e()))}))}addEvent(e,t){return this._ensureEventRegistry(e).add(t),this._initEventHandler(e),N(()=>this.removeEvent(e,t))}fireEvent(e,t){var n;return(n=this._eventRegistry.get(e))==null||n.getData().forEach(e=>{e(t)}),t.cancel}};let Y=class extends F{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};Y=B([z(0,h(g)),z(1,h(M))],Y);var X=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}get rectangle(){return ge}get numfmt(){return we}get tools(){return O}};W(X,`_instance`,void 0);var Z;const Q=Symbol(`initializers`);let $=Z=class extends d{static newAPI(e){return(e instanceof A?e.__getInjector():e).createInstance(Z)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[Q];t||(t=[],this.prototype[Q]=t),t.push(e.prototype._initialize)}else t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(e,t,n,r){super(),this._injector=e,this._commandService=t,this._univerInstanceService=n,this._lifecycleService=r,W(this,`_eventRegistry`,new De),W(this,`registerEventHandler`,(e,t)=>this._eventRegistry.registerEventHandler(e,t)),this.disposeWithMe(this.registerEventHandler(this.Event.LifeCycleChanged,()=>N(this._lifecycleService.lifecycle$.subscribe(e=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:e})})))),this._initUnitEvent(this._injector),this._initBeforeCommandEvent(this._injector),this._initCommandEvent(this._injector),this._injector.onDispose(()=>{this.dispose()});let i=Object.getPrototypeOf(this)[Q];if(i){let t=this;i.forEach(function(n){n.apply(t,[e])})}}_initCommandEvent(e){let t=e.get(f);this.disposeWithMe(this.registerEventHandler(this.Event.Redo,()=>t.onCommandExecuted(e=>{let{id:t,type:n,params:r}=e;if(e.id===b.id){let e={id:t,type:n,params:r};this.fireEvent(this.Event.Redo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.Undo,()=>t.onCommandExecuted(e=>{let{id:t,type:n,params:r}=e;if(e.id===k.id){let e={id:t,type:n,params:r};this.fireEvent(this.Event.Undo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommandExecuted,()=>t.onCommandExecuted((e,t)=>{let{id:n,type:r,params:i}=e;if(e.id!==b.id&&e.id!==k.id){let e={id:n,type:r,params:i,options:t};this.fireEvent(this.Event.CommandExecuted,e)}})))}_initBeforeCommandEvent(e){let t=e.get(f);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeRedo,()=>t.beforeCommandExecuted(e=>{let{id:t,type:n,params:r}=e;if(e.id===b.id){let e={id:t,type:n,params:r};if(this.fireEvent(this.Event.BeforeRedo,e),e.cancel)throw new o}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeUndo,()=>t.beforeCommandExecuted(e=>{let{id:t,type:n,params:r}=e;if(e.id===k.id){let e={id:t,type:n,params:r};if(this.fireEvent(this.Event.BeforeUndo,e),e.cancel)throw new o}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommandExecute,()=>t.beforeCommandExecuted((e,t)=>{let{id:n,type:r,params:i}=e;if(e.id!==b.id&&e.id!==k.id){let e={id:n,type:r,params:i,options:t};if(this.fireEvent(this.Event.BeforeCommandExecute,e),e.cancel)throw new o}})))}_initUnitEvent(e){let t=e.get(m);this.disposeWithMe(this.registerEventHandler(this.Event.DocDisposed,()=>t.unitDisposed$.subscribe(e=>{e.type===j.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:e.getUnitId(),unitType:e.type,snapshot:e.getSnapshot()})}))),this.disposeWithMe(this.registerEventHandler(this.Event.DocCreated,()=>t.unitAdded$.subscribe(t=>{if(t.type===j.UNIVER_DOC){let n=t,r=e.createInstance(J,n);this.fireEvent(this.Event.DocCreated,{unitId:t.getUnitId(),type:t.type,doc:r,unit:r})}})))}disposeUnit(e){return this._univerInstanceService.disposeUnit(e)}getCurrentLifecycleStage(){return this._injector.get(_).stage}undo(){return this._commandService.executeCommand(k.id)}redo(){return this._commandService.executeCommand(b.id)}toggleDarkMode(e){this._injector.get(D).setDarkMode(e)}loadLocales(e,t){this._injector.get(y).load({[e]:t})}setLocale(e){this._injector.get(y).setLocale(e)}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((t,n)=>{e(t,n)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((t,n)=>{e(t,n)})}executeCommand(e,t,n){return this._commandService.executeCommand(e,t,n)}syncExecuteCommand(e,t,n){return this._commandService.syncExecuteCommand(e,t,n)}getHooks(){return this._injector.createInstance(q)}get Enum(){return G.get()}get Event(){return K.get()}get Util(){return X.get()}addEvent(e,t){if(!e||!t)throw Error(`Cannot add empty event`);return this._eventRegistry.addEvent(e,t)}fireEvent(e,t){return this._eventRegistry.fireEvent(e,t)}getUserManager(){return this._injector.createInstance(Y)}newBlob(){return this._injector.createInstance(H,null)}newRichText(e){return ye.create(e)}newRichTextValue(e){return be.create(e)}newParagraphStyle(e){return pe.create(e)}newParagraphStyleValue(e){return me.create(e)}newTextStyle(e){return w.create(e)}newTextStyleValue(e){return T.create(e)}newTextDecoration(e){return new S(e)}};$=Z=B([z(0,h(g)),z(1,f),z(2,m),z(3,h(_))],$);export{F as FBase,R as FBaseInitialable,H as FBlob,G as FEnum,K as FEventName,q as FHooks,$ as FUniver,X as FUtil};
|