@univerjs/core 1.0.0-insiders.20260813-7c9aa50 → 1.0.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/LICENSE +176 -0
- package/README.md +0 -1
- package/lib/cjs/facade.js +151 -53
- package/lib/cjs/index.js +3394 -1320
- package/lib/es/facade.js +152 -54
- package/lib/es/index.js +3151 -1109
- package/lib/facade.js +152 -54
- package/lib/index.js +3151 -1109
- package/lib/types/bases/typedef.d.ts +14 -2
- package/lib/types/common/drawing-order.d.ts +20 -0
- package/lib/types/common/lodash.d.ts +1 -1
- package/lib/types/common/url.d.ts +1 -1
- package/lib/types/docs/data-model/document-data-model.d.ts +6 -0
- package/lib/types/docs/data-model/rich-text-builder.d.ts +48 -4
- package/lib/types/docs/data-model/text-x/action-types.d.ts +19 -1
- package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +9 -3
- package/lib/types/docs/data-model/text-x/apply-utils/delete-apply.d.ts +1 -1
- package/lib/types/docs/data-model/text-x/apply-utils/insert-apply.d.ts +1 -1
- package/lib/types/docs/data-model/text-x/apply.d.ts +1 -1
- package/lib/types/docs/data-model/text-x/build-utils/drawings.d.ts +2 -1
- package/lib/types/docs/data-model/text-x/build-utils/index.d.ts +2 -0
- package/lib/types/docs/data-model/text-x/build-utils/text-x-utils.d.ts +2 -1
- package/lib/types/docs/data-model/text-x/custom-range-update.d.ts +30 -0
- package/lib/types/docs/data-model/text-x/structure-validator.d.ts +3 -3
- package/lib/types/docs/data-model/text-x/text-x.d.ts +7 -3
- package/lib/types/docs/data-model/text-x/utils.d.ts +11 -1
- package/lib/types/docs/sdt-binding.d.ts +19 -0
- package/lib/types/facade/f-blob.d.ts +11 -11
- package/lib/types/facade/f-enum.d.ts +18 -1
- package/lib/types/facade/f-event-registry.d.ts +18 -6
- package/lib/types/facade/f-event.d.ts +4 -0
- package/lib/types/facade/f-univer.d.ts +78 -24
- package/lib/types/index.d.ts +7 -0
- package/lib/types/services/command/command.service.d.ts +3 -1
- package/lib/types/services/error/error.service.d.ts +3 -0
- package/lib/types/services/permission/object-permission-rule.model.d.ts +52 -0
- package/lib/types/services/permission/object-permission.service.d.ts +110 -0
- package/lib/types/services/resource-manager/type.d.ts +1 -1
- package/lib/types/services/undoredo/undoredo.service.d.ts +3 -0
- package/lib/types/shared/index.d.ts +3 -2
- package/lib/types/shared/numfmt/api.d.ts +3 -0
- package/lib/types/shared/numfmt/date-time-edit-pattern.d.ts +17 -0
- package/lib/types/shared/numfmt/format-number.d.ts +3 -1
- package/lib/types/shared/numfmt/index.d.ts +4 -1
- package/lib/types/shared/numfmt/parse-value.d.ts +2 -0
- package/lib/types/shared/numfmt/serial-date.d.ts +31 -0
- package/lib/types/shared/numfmt/types.d.ts +4 -0
- package/lib/types/shared/numfmt/utils.d.ts +4 -1
- package/lib/types/sheets/typedef.d.ts +43 -7
- package/lib/types/sheets/workbook.d.ts +3 -1
- package/lib/types/sheets/worksheet.d.ts +8 -7
- package/lib/types/types/enum/date-system.d.ts +22 -0
- package/lib/types/types/enum/index.d.ts +1 -0
- package/lib/types/types/enum/record-filter.d.ts +30 -0
- package/lib/types/types/interfaces/i-document-data.d.ts +339 -9
- package/lib/types/types/interfaces/i-drawing.d.ts +9 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +26 -24
- package/package.json +7 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
CHANGED
package/lib/cjs/facade.js
CHANGED
|
@@ -81,7 +81,7 @@ var FBaseInitialable = class extends _univerjs_core.Disposable {
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
//#endregion
|
|
84
|
-
//#region \0@oxc-project+runtime@0.
|
|
84
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
85
85
|
function __decorateParam(paramIndex, decorator) {
|
|
86
86
|
return function(target, key) {
|
|
87
87
|
decorator(target, key, paramIndex);
|
|
@@ -89,7 +89,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
//#endregion
|
|
92
|
-
//#region \0@oxc-project+runtime@0.
|
|
92
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
93
93
|
function __decorate(decorators, target, key, desc) {
|
|
94
94
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
95
95
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -120,9 +120,9 @@ let FBlob = _FBlob = class FBlob extends FBase {
|
|
|
120
120
|
return this._injector.createInstance(_FBlob, this._blob);
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
|
-
*
|
|
123
|
+
* Returns a copy labeled with the specified MIME type. The data bytes are not converted or re-encoded.
|
|
124
124
|
* @param contentType the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
|
|
125
|
-
* @returns
|
|
125
|
+
* @returns {FBlob} A new facade containing the same data with the specified MIME type.
|
|
126
126
|
* @example
|
|
127
127
|
* ```ts
|
|
128
128
|
* const blob = univerAPI.newBlob();
|
|
@@ -148,10 +148,10 @@ let FBlob = _FBlob = class FBlob extends FBase {
|
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
150
|
* Gets the data stored in this blob.
|
|
151
|
-
* @returns the
|
|
151
|
+
* @returns {Promise<Uint8Array>} A promise resolving to the bytes; rejects if no blob data is set.
|
|
152
152
|
* @example
|
|
153
153
|
* ```ts
|
|
154
|
-
* const blob = univerAPI.newBlob();
|
|
154
|
+
* const blob = univerAPI.newBlob().setDataFromString('Hello, World!');
|
|
155
155
|
* const bytes = await blob.getBytes();
|
|
156
156
|
* console.log(bytes);
|
|
157
157
|
* ```
|
|
@@ -182,7 +182,7 @@ let FBlob = _FBlob = class FBlob extends FBase {
|
|
|
182
182
|
}
|
|
183
183
|
/**
|
|
184
184
|
* Gets the content type of the data stored in this blob.
|
|
185
|
-
* @returns
|
|
185
|
+
* @returns {string | undefined} The MIME type, or `undefined` if no blob data is set.
|
|
186
186
|
* @example
|
|
187
187
|
* ```ts
|
|
188
188
|
* const blob = univerAPI.newBlob();
|
|
@@ -195,7 +195,7 @@ let FBlob = _FBlob = class FBlob extends FBase {
|
|
|
195
195
|
return (_this$_blob = this._blob) === null || _this$_blob === void 0 ? void 0 : _this$_blob.type;
|
|
196
196
|
}
|
|
197
197
|
/**
|
|
198
|
-
* Sets the
|
|
198
|
+
* Sets the MIME type without converting or re-encoding the data bytes. Has no effect when no blob data is set.
|
|
199
199
|
* @param contentType the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
|
|
200
200
|
* @returns the blob object
|
|
201
201
|
* @example
|
|
@@ -213,7 +213,7 @@ let FBlob = _FBlob = class FBlob extends FBase {
|
|
|
213
213
|
FBlob = _FBlob = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector))], FBlob);
|
|
214
214
|
|
|
215
215
|
//#endregion
|
|
216
|
-
//#region \0@oxc-project+runtime@0.
|
|
216
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
217
217
|
function _typeof(o) {
|
|
218
218
|
"@babel/helpers - typeof";
|
|
219
219
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -224,7 +224,7 @@ function _typeof(o) {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
//#endregion
|
|
227
|
-
//#region \0@oxc-project+runtime@0.
|
|
227
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
228
228
|
function toPrimitive(t, r) {
|
|
229
229
|
if ("object" != _typeof(t) || !t) return t;
|
|
230
230
|
var e = t[Symbol.toPrimitive];
|
|
@@ -237,14 +237,14 @@ function toPrimitive(t, r) {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
//#endregion
|
|
240
|
-
//#region \0@oxc-project+runtime@0.
|
|
240
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
241
241
|
function toPropertyKey(t) {
|
|
242
242
|
var i = toPrimitive(t, "string");
|
|
243
243
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
//#endregion
|
|
247
|
-
//#region \0@oxc-project+runtime@0.
|
|
247
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
248
248
|
function _defineProperty(e, r, t) {
|
|
249
249
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
250
250
|
value: t,
|
|
@@ -275,6 +275,18 @@ function _defineProperty(e, r, t) {
|
|
|
275
275
|
* @hideconstructor
|
|
276
276
|
*/
|
|
277
277
|
var FEnum = class FEnum {
|
|
278
|
+
/** SpreadsheetML formula types. */
|
|
279
|
+
get FormulaType() {
|
|
280
|
+
return _univerjs_core.FormulaType;
|
|
281
|
+
}
|
|
282
|
+
/** Worksheet hiding states: VISIBLE (0), HIDDEN (1), VERY_HIDDEN (2). */
|
|
283
|
+
get WorksheetHiddenState() {
|
|
284
|
+
return _univerjs_core.WorksheetHiddenState;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Returns the shared registry of Facade enum values.
|
|
288
|
+
* @returns {FEnum} The registry also exposed by `univerAPI.Enum`.
|
|
289
|
+
*/
|
|
278
290
|
static get() {
|
|
279
291
|
if (this._instance) return this._instance;
|
|
280
292
|
const instance = new FEnum();
|
|
@@ -428,6 +440,17 @@ var FEnum = class FEnum {
|
|
|
428
440
|
return _univerjs_core.HorizontalAlign;
|
|
429
441
|
}
|
|
430
442
|
/**
|
|
443
|
+
* Named paragraph style types
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```ts
|
|
447
|
+
* console.log(univerAPI.Enum.NamedStyleType.HEADING_1);
|
|
448
|
+
* ```
|
|
449
|
+
*/
|
|
450
|
+
get NamedStyleType() {
|
|
451
|
+
return _univerjs_core.NamedStyleType;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
431
454
|
* Paragraph line-height interpretation modes
|
|
432
455
|
*
|
|
433
456
|
* @example
|
|
@@ -714,6 +737,10 @@ _defineProperty(FEnum, "_instance", void 0);
|
|
|
714
737
|
* @hideconstructor
|
|
715
738
|
*/
|
|
716
739
|
var FEventName = class FEventName {
|
|
740
|
+
/**
|
|
741
|
+
* Returns the shared registry of Facade event names.
|
|
742
|
+
* @returns {FEventName} The registry also exposed by `univerAPI.Event`.
|
|
743
|
+
*/
|
|
717
744
|
static get() {
|
|
718
745
|
if (this._instance) return this._instance;
|
|
719
746
|
const instance = new FEventName();
|
|
@@ -912,6 +939,13 @@ var FEventRegistry = class {
|
|
|
912
939
|
if (!this._eventRegistry.has(event)) this._eventRegistry.set(event, new _univerjs_core.Registry());
|
|
913
940
|
return this._eventRegistry.get(event);
|
|
914
941
|
}
|
|
942
|
+
/**
|
|
943
|
+
* Registers a factory for the underlying subscription that produces an event.
|
|
944
|
+
* The factory starts when the event has listeners; its subscription is disposed when the last listener is removed.
|
|
945
|
+
* @param {string} event The event name.
|
|
946
|
+
* @param {() => IDisposable | Subscription} handler Creates the underlying event subscription.
|
|
947
|
+
* @returns {IDisposable} Unregisters the factory and disposes its active subscription.
|
|
948
|
+
*/
|
|
915
949
|
registerEventHandler(event, handler) {
|
|
916
950
|
const current = this._eventHandlerMap.get(event);
|
|
917
951
|
if (current) current.add(handler);
|
|
@@ -924,6 +958,11 @@ var FEventRegistry = class {
|
|
|
924
958
|
(_this$_eventHandlerRe2 = this._eventHandlerRegisted.get(event)) === null || _this$_eventHandlerRe2 === void 0 || _this$_eventHandlerRe2.delete(handler);
|
|
925
959
|
});
|
|
926
960
|
}
|
|
961
|
+
/**
|
|
962
|
+
* Removes one event listener and stops underlying subscriptions when no listeners remain.
|
|
963
|
+
* @param {T} event The event name.
|
|
964
|
+
* @param {(params: IEventParamConfig[T]) => void} callback The previously registered callback.
|
|
965
|
+
*/
|
|
927
966
|
removeEvent(event, callback) {
|
|
928
967
|
const map = this._ensureEventRegistry(event);
|
|
929
968
|
map.delete(callback);
|
|
@@ -947,9 +986,9 @@ var FEventRegistry = class {
|
|
|
947
986
|
}
|
|
948
987
|
/**
|
|
949
988
|
* Add an event listener
|
|
950
|
-
* @param {
|
|
951
|
-
* @param {(params: IEventParamConfig[
|
|
952
|
-
* @returns {
|
|
989
|
+
* @param {T} event key of event
|
|
990
|
+
* @param {(params: IEventParamConfig[T]) => void} callback callback when event triggered
|
|
991
|
+
* @returns {IDisposable} A disposable that removes the event listener.
|
|
953
992
|
* @example
|
|
954
993
|
* ```ts
|
|
955
994
|
* univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, (params) => {
|
|
@@ -965,9 +1004,9 @@ var FEventRegistry = class {
|
|
|
965
1004
|
}
|
|
966
1005
|
/**
|
|
967
1006
|
* Fire an event, used in internal only.
|
|
968
|
-
* @param {
|
|
969
|
-
* @param {
|
|
970
|
-
* @returns {boolean}
|
|
1007
|
+
* @param {T} event key of event
|
|
1008
|
+
* @param {IEventParamConfig[T]} params params of event
|
|
1009
|
+
* @returns {boolean | undefined} The event's `cancel` value after listeners run; `undefined` if it was not set.
|
|
971
1010
|
* @example
|
|
972
1011
|
* ```ts
|
|
973
1012
|
* this.fireEvent(univerAPI.Event.LifeCycleChanged, params);
|
|
@@ -1094,7 +1133,7 @@ var _FUniver;
|
|
|
1094
1133
|
const InitializerSymbol = Symbol("initializers");
|
|
1095
1134
|
let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
1096
1135
|
/**
|
|
1097
|
-
*
|
|
1136
|
+
* Creates a Facade API instance for an existing Univer instance or its injector.
|
|
1098
1137
|
* @static
|
|
1099
1138
|
* @param {Univer | Injector} wrapped - The Univer instance or injector instance.
|
|
1100
1139
|
* @returns {FUniver} - The FUniver instance.
|
|
@@ -1110,7 +1149,7 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1110
1149
|
/**
|
|
1111
1150
|
* @ignore
|
|
1112
1151
|
*/
|
|
1113
|
-
_initialize(
|
|
1152
|
+
_initialize(_injector) {}
|
|
1114
1153
|
/**
|
|
1115
1154
|
* @ignore
|
|
1116
1155
|
*/
|
|
@@ -1122,11 +1161,11 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1122
1161
|
initializers = [];
|
|
1123
1162
|
this.prototype[InitializerSymbol] = initializers;
|
|
1124
1163
|
}
|
|
1125
|
-
initializers.push(source.prototype
|
|
1126
|
-
} else if (name !== "constructor") this.prototype
|
|
1164
|
+
initializers.push(Reflect.get(source.prototype, name));
|
|
1165
|
+
} else if (name !== "constructor") Reflect.set(this.prototype, name, Reflect.get(source.prototype, name));
|
|
1127
1166
|
});
|
|
1128
1167
|
Object.getOwnPropertyNames(source).forEach((name) => {
|
|
1129
|
-
if (name !== "prototype" && name !== "name" && name !== "length") this
|
|
1168
|
+
if (name !== "prototype" && name !== "name" && name !== "length") Reflect.set(this, name, Reflect.get(source, name));
|
|
1130
1169
|
});
|
|
1131
1170
|
}
|
|
1132
1171
|
constructor(_injector, _commandService, _univerInstanceService, _lifecycleService) {
|
|
@@ -1136,9 +1175,20 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1136
1175
|
this._univerInstanceService = _univerInstanceService;
|
|
1137
1176
|
this._lifecycleService = _lifecycleService;
|
|
1138
1177
|
_defineProperty(this, "_eventRegistry", new FEventRegistry());
|
|
1139
|
-
_defineProperty(
|
|
1140
|
-
|
|
1141
|
-
|
|
1178
|
+
_defineProperty(
|
|
1179
|
+
this,
|
|
1180
|
+
/**
|
|
1181
|
+
* Registers a factory for the subscription that produces an event.
|
|
1182
|
+
* The factory starts when listeners exist and its subscription is disposed when the last listener is removed.
|
|
1183
|
+
* @param event The event name.
|
|
1184
|
+
* @param handler Creates the underlying event subscription.
|
|
1185
|
+
* @returns A disposable that unregisters the factory and disposes its active subscription.
|
|
1186
|
+
*/
|
|
1187
|
+
"registerEventHandler",
|
|
1188
|
+
(event, handler) => {
|
|
1189
|
+
return this._eventRegistry.registerEventHandler(event, handler);
|
|
1190
|
+
}
|
|
1191
|
+
);
|
|
1142
1192
|
this.disposeWithMe(this.registerEventHandler(this.Event.LifeCycleChanged, () => (0, _univerjs_core.toDisposable)(this._lifecycleService.lifecycle$.subscribe((stage) => {
|
|
1143
1193
|
this.fireEvent(this.Event.LifeCycleChanged, { stage });
|
|
1144
1194
|
}))));
|
|
@@ -1149,12 +1199,9 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1149
1199
|
this.dispose();
|
|
1150
1200
|
});
|
|
1151
1201
|
const initializers = Object.getPrototypeOf(this)[InitializerSymbol];
|
|
1152
|
-
if (initializers) {
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
fn.apply(self, [_injector]);
|
|
1156
|
-
});
|
|
1157
|
-
}
|
|
1202
|
+
if (initializers) initializers.forEach((fn) => {
|
|
1203
|
+
fn.call(this, this._injector);
|
|
1204
|
+
});
|
|
1158
1205
|
}
|
|
1159
1206
|
_initCommandEvent(injector) {
|
|
1160
1207
|
const commandService = injector.get(_univerjs_core.ICommandService);
|
|
@@ -1257,8 +1304,8 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1257
1304
|
})));
|
|
1258
1305
|
}
|
|
1259
1306
|
/**
|
|
1260
|
-
*
|
|
1261
|
-
* @param unitId The
|
|
1307
|
+
* Disposes the document, workbook, or other Univer unit identified by `unitId`, unloading it from the application.
|
|
1308
|
+
* @param unitId The ID of the unit to dispose.
|
|
1262
1309
|
* @returns Whether the Univer instance is disposed successfully.
|
|
1263
1310
|
*
|
|
1264
1311
|
* @example
|
|
@@ -1391,6 +1438,40 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1391
1438
|
this._injector.get(_univerjs_core.LocaleService).setLocale(locale);
|
|
1392
1439
|
}
|
|
1393
1440
|
/**
|
|
1441
|
+
* Set the region used for locale-sensitive formatting.
|
|
1442
|
+
* @param {string} region - A unique region identifier.
|
|
1443
|
+
* @example
|
|
1444
|
+
* ```ts
|
|
1445
|
+
* univerAPI.setRegion('enUS');
|
|
1446
|
+
* ```
|
|
1447
|
+
*/
|
|
1448
|
+
setRegion(region) {
|
|
1449
|
+
this._injector.get(_univerjs_core.RegionService).setRegion(region);
|
|
1450
|
+
}
|
|
1451
|
+
/**
|
|
1452
|
+
* Get the region currently used for locale-sensitive formatting.
|
|
1453
|
+
* @returns {string} The current region identifier.
|
|
1454
|
+
* @example
|
|
1455
|
+
* ```ts
|
|
1456
|
+
* const currentRegion = univerAPI.getCurrentRegion();
|
|
1457
|
+
* console.log(currentRegion);
|
|
1458
|
+
* ```
|
|
1459
|
+
*/
|
|
1460
|
+
getCurrentRegion() {
|
|
1461
|
+
return this._injector.get(_univerjs_core.RegionService).getCurrentRegion();
|
|
1462
|
+
}
|
|
1463
|
+
/**
|
|
1464
|
+
* Set the current layout direction.
|
|
1465
|
+
* @param {('ltr' | 'rtl')} direction - The layout direction.
|
|
1466
|
+
* @example
|
|
1467
|
+
* ```ts
|
|
1468
|
+
* univerAPI.setDirection('rtl');
|
|
1469
|
+
* ```
|
|
1470
|
+
*/
|
|
1471
|
+
setDirection(direction) {
|
|
1472
|
+
this._injector.get(_univerjs_core.LocaleService).setDirection(direction);
|
|
1473
|
+
}
|
|
1474
|
+
/**
|
|
1394
1475
|
* Get the current locale.
|
|
1395
1476
|
* @returns {string} The current locale identifier.
|
|
1396
1477
|
* @example
|
|
@@ -1417,9 +1498,9 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1417
1498
|
/**
|
|
1418
1499
|
* Execute a command with the given id and parameters.
|
|
1419
1500
|
* @param id Identifier of the command.
|
|
1420
|
-
* @param params Parameters of this execution.
|
|
1421
|
-
* @param options Options of this execution.
|
|
1422
|
-
* @returns The result of the execution. It is a boolean value by default which indicates the command is executed.
|
|
1501
|
+
* @param [params] Parameters of this execution.
|
|
1502
|
+
* @param [options] Options of this execution.
|
|
1503
|
+
* @returns {Promise<R>} The result of the execution. It is a boolean value by default which indicates the command is executed.
|
|
1423
1504
|
*
|
|
1424
1505
|
* @example
|
|
1425
1506
|
* ```ts
|
|
@@ -1435,8 +1516,8 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1435
1516
|
/**
|
|
1436
1517
|
* Execute a command with the given id and parameters synchronously.
|
|
1437
1518
|
* @param id Identifier of the command.
|
|
1438
|
-
* @param params Parameters of this execution.
|
|
1439
|
-
* @param options Options of this execution.
|
|
1519
|
+
* @param [params] Parameters of this execution.
|
|
1520
|
+
* @param [options] Options of this execution.
|
|
1440
1521
|
* @returns The result of the execution. It is a boolean value by default which indicates the command is executed.
|
|
1441
1522
|
*
|
|
1442
1523
|
* @example
|
|
@@ -1450,20 +1531,29 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1450
1531
|
syncExecuteCommand(id, params, options) {
|
|
1451
1532
|
return this._commandService.syncExecuteCommand(id, params, options);
|
|
1452
1533
|
}
|
|
1534
|
+
/**
|
|
1535
|
+
* Enums exposed by the registered Facade extensions.
|
|
1536
|
+
*/
|
|
1453
1537
|
get Enum() {
|
|
1454
1538
|
return FEnum.get();
|
|
1455
1539
|
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Event names to use with `addEvent`.
|
|
1542
|
+
*/
|
|
1456
1543
|
get Event() {
|
|
1457
1544
|
return FEventName.get();
|
|
1458
1545
|
}
|
|
1546
|
+
/**
|
|
1547
|
+
* Utility functions exposed by the registered Facade extensions.
|
|
1548
|
+
*/
|
|
1459
1549
|
get Util() {
|
|
1460
1550
|
return FUtil.get();
|
|
1461
1551
|
}
|
|
1462
1552
|
/**
|
|
1463
1553
|
* Add an event listener
|
|
1464
|
-
* @param {
|
|
1465
|
-
* @param {(params: IEventParamConfig[
|
|
1466
|
-
* @returns {
|
|
1554
|
+
* @param {T} event key of event
|
|
1555
|
+
* @param {(params: IEventParamConfig[T]) => void} callback callback when event triggered
|
|
1556
|
+
* @returns {IDisposable} A disposable that removes the event listener.
|
|
1467
1557
|
* @example
|
|
1468
1558
|
* ```ts
|
|
1469
1559
|
* // Add life cycle changed event listener
|
|
@@ -1481,9 +1571,9 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1481
1571
|
}
|
|
1482
1572
|
/**
|
|
1483
1573
|
* Fire an event, used in internal only.
|
|
1484
|
-
* @param {
|
|
1485
|
-
* @param {
|
|
1486
|
-
* @returns {boolean}
|
|
1574
|
+
* @param {T} event key of event
|
|
1575
|
+
* @param {IEventParamConfig[T]} params params of event
|
|
1576
|
+
* @returns {boolean | undefined} The event's `cancel` value after listeners run; `undefined` if it was not set.
|
|
1487
1577
|
* @example
|
|
1488
1578
|
* ```ts
|
|
1489
1579
|
* this.fireEvent(univerAPI.Event.LifeCycleChanged, params);
|
|
@@ -1492,6 +1582,14 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1492
1582
|
fireEvent(event, params) {
|
|
1493
1583
|
return this._eventRegistry.fireEvent(event, params);
|
|
1494
1584
|
}
|
|
1585
|
+
/**
|
|
1586
|
+
* Gets the facade for reading the current user.
|
|
1587
|
+
* @returns {FUserManager} The user manager facade.
|
|
1588
|
+
* @example
|
|
1589
|
+
* ```ts
|
|
1590
|
+
* const user = univerAPI.getUserManager().getCurrentUser();
|
|
1591
|
+
* ```
|
|
1592
|
+
*/
|
|
1495
1593
|
getUserManager() {
|
|
1496
1594
|
return this._injector.createInstance(FUserManager);
|
|
1497
1595
|
}
|
|
@@ -1512,9 +1610,9 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1512
1610
|
* @example
|
|
1513
1611
|
* ```ts
|
|
1514
1612
|
* const richText = univerAPI.newRichText()
|
|
1515
|
-
* .
|
|
1516
|
-
* .
|
|
1517
|
-
* .
|
|
1613
|
+
* .text('Read ')
|
|
1614
|
+
* .link('Univer documentation', 'https://docs.univer.ai')
|
|
1615
|
+
* .text(' for details.');
|
|
1518
1616
|
* ```
|
|
1519
1617
|
*/
|
|
1520
1618
|
newRichText() {
|
|
@@ -1552,7 +1650,7 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1552
1650
|
* This is an advanced document-model API. Application and agent code should normally use
|
|
1553
1651
|
* `newRichText().paragraph({ ... })`.
|
|
1554
1652
|
*
|
|
1555
|
-
* @param {IParagraphStyle} style The paragraph style
|
|
1653
|
+
* @param {IParagraphStyle} [style] The paragraph style
|
|
1556
1654
|
* @returns {ParagraphStyleBuilder} The new paragraph style instance
|
|
1557
1655
|
* @advanced
|
|
1558
1656
|
*/
|
|
@@ -1561,7 +1659,7 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1561
1659
|
}
|
|
1562
1660
|
/**
|
|
1563
1661
|
* Create a new paragraph style value.
|
|
1564
|
-
* @param {IParagraphStyle} style - The paragraph style
|
|
1662
|
+
* @param {IParagraphStyle} [style] - The paragraph style
|
|
1565
1663
|
* @returns {ParagraphStyleValue} The new paragraph style value instance
|
|
1566
1664
|
* @example
|
|
1567
1665
|
* ```ts
|
|
@@ -1573,7 +1671,7 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1573
1671
|
}
|
|
1574
1672
|
/**
|
|
1575
1673
|
* Create a new text style.
|
|
1576
|
-
* @param {ITextStyle} style - The text style
|
|
1674
|
+
* @param {ITextStyle} [style] - The text style
|
|
1577
1675
|
* @returns {TextStyleBuilder} The new text style instance
|
|
1578
1676
|
* @example
|
|
1579
1677
|
* ```ts
|
|
@@ -1585,7 +1683,7 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1585
1683
|
}
|
|
1586
1684
|
/**
|
|
1587
1685
|
* Create a new text style value.
|
|
1588
|
-
* @param {ITextStyle} style - The text style
|
|
1686
|
+
* @param {ITextStyle} [style] - The text style
|
|
1589
1687
|
* @returns {TextStyleValue} The new text style value instance
|
|
1590
1688
|
* @example
|
|
1591
1689
|
* ```ts
|
|
@@ -1597,7 +1695,7 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
|
|
|
1597
1695
|
}
|
|
1598
1696
|
/**
|
|
1599
1697
|
* Create a new text decoration.
|
|
1600
|
-
* @param {ITextDecoration} decoration - The text decoration
|
|
1698
|
+
* @param {ITextDecoration} [decoration] - The text decoration
|
|
1601
1699
|
* @returns {TextDecorationBuilder} The new text decoration instance
|
|
1602
1700
|
* @example
|
|
1603
1701
|
* ```ts
|