@univerjs/sheets 0.5.3 → 0.5.4-experimental.20250114-7c09c35
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 +3 -3
- package/lib/es/facade.js +1526 -777
- package/lib/es/index.js +3904 -3276
- package/lib/types/basics/cell-style.d.ts +8 -0
- package/lib/types/commands/operations/selection.operation.d.ts +1 -0
- package/lib/types/commands/utils/selection-command-util.d.ts +1 -1
- package/lib/types/controllers/permission/sheet-permission-check.controller.d.ts +33 -0
- package/lib/types/controllers/permission/sheet-permission-init.controller.d.ts +29 -0
- package/lib/types/controllers/permission/sheet-permission-view-model.controller.d.ts +13 -0
- package/lib/types/facade/f-defined-name.d.ts +61 -61
- package/lib/types/facade/f-event.d.ts +85 -1
- package/lib/types/facade/f-permission.d.ts +3 -20
- package/lib/types/facade/f-range.d.ts +486 -57
- package/lib/types/facade/f-univer.d.ts +56 -11
- package/lib/types/facade/f-workbook.d.ts +87 -17
- package/lib/types/facade/f-worksheet.d.ts +158 -59
- package/lib/types/facade/index.d.ts +0 -1
- package/lib/types/facade/utils.d.ts +38 -2
- package/lib/types/index.d.ts +2 -0
- package/lib/types/model/range-theme-util.d.ts +3 -3
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +3 -3
- package/package.json +7 -7
- package/LICENSE +0 -176
package/lib/es/facade.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Inject as
|
|
5
|
-
import { WorksheetProtectionRuleModel as
|
|
6
|
-
import { IDefinedNamesService as
|
|
7
|
-
var
|
|
8
|
-
for (var
|
|
9
|
-
(i = o
|
|
10
|
-
return n &&
|
|
11
|
-
},
|
|
12
|
-
function
|
|
13
|
-
const n = t.getDefinedNameMap(
|
|
1
|
+
var Ae = Object.defineProperty;
|
|
2
|
+
var Fe = (s, e, t) => e in s ? Ae(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var k = (s, e, t) => Fe(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Inject as u, Injector as b, IAuthzIoService as ve, LocaleService as Re, ICommandService as l, IPermissionService as ee, generateRandomId as be, FBase as te, Rectangle as N, HorizontalAlign as y, VerticalAlign as U, isFormulaString as je, isCellV as Oe, isICellData as Ve, ObjectMatrix as A, Tools as Be, RANGE_TYPE as _, FBaseInitialable as ne, RichTextValue as p, BooleanNumber as m, WrapStrategy as oe, Dimension as ie, ILogService as pe, Registry as ye, toDisposable as F, Direction as D, IResourceLoaderService as Le, FEnum as ze, FEventName as se, mergeWorksheetSnapshotWithDefault as $e, UndoCommand as He, RedoCommand as Ge, UniverInstanceType as R, IUniverInstanceService as J, FUniver as Ue, CanceledError as qe } from "@univerjs/core";
|
|
5
|
+
import { WorksheetProtectionRuleModel as Ee, RangeProtectionRuleModel as Pe, WorksheetProtectionPointModel as xe, SetDefinedNameCommand as Q, SCOPE_WORKBOOK_VALUE_DEFINED_NAME as X, RemoveDefinedNameCommand as Ke, PermissionPointsDefinitions as Ye, WorkbookEditablePermission as Ne, UnitObject as E, AddWorksheetProtectionMutation as Je, DeleteWorksheetProtectionMutation as Qe, getAllWorksheetPermissionPoint as Xe, getAllWorksheetPermissionPointByPointPanel as ae, SetWorksheetPermissionPointsMutation as Ze, AddRangeProtectionMutation as et, DeleteRangeProtectionMutation as tt, SetRangeProtectionMutation as nt, WorksheetEditPermission as st, WorksheetViewPermission as rt, SetStyleCommand as f, SetRangeValuesCommand as P, SetTextWrapCommand as he, SetVerticalTextAlignCommand as ot, SetHorizontalTextAlignCommand as it, addMergeCellsUtil as $, getAddMergeMutationRangeByType as ce, RemoveWorksheetMergeCommand as at, SplitTextToColumnsCommand as ht, SetWorksheetRangeThemeStyleCommand as ct, DeleteWorksheetRangeThemeStyleCommand as dt, SheetRangeThemeService as Me, getPrimaryForRange as Z, SetSelectionsOperation as De, getNextPrimaryCell as ut, SheetsSelectionsService as We, SetWorksheetDefaultStyleMutation as mt, SetColDataCommand as de, SetRowDataCommand as ue, copyRangeStyles as W, InsertRowByRangeCommand as me, RemoveRowByRangeCommand as lt, MoveRowsCommand as gt, SetRowHiddenCommand as le, SetSpecificRowsVisibleCommand as ge, SetRowHeightCommand as _e, SetWorksheetRowIsAutoHeightCommand as _t, InsertColByRangeCommand as we, RemoveColByRangeCommand as wt, MoveColsCommand as kt, SetColHiddenCommand as ke, SetSpecificColsVisibleCommand as Se, SetColWidthCommand as St, SetFrozenCommand as H, CancelFrozenCommand as Ct, ToggleGridlinesCommand as It, SetGridlinesColorCommand as ft, SetTabColorCommand as vt, SetRangeValuesMutation as Ce, SetWorksheetHideCommand as Rt, SetWorksheetShowCommand as bt, SetWorksheetNameCommand as pt, ClearSelectionAllCommand as yt, ClearSelectionContentCommand as Ut, ClearSelectionFormatCommand as Et, InsertSheetCommand as x, SetWorksheetActiveOperation as G, RemoveSheetCommand as Pt, CopySheetCommand as xt, SetWorksheetOrderCommand as Nt, RegisterWorksheetRangeThemeStyleCommand as Mt, UnregisterWorksheetRangeThemeStyleCommand as Dt } from "@univerjs/sheets";
|
|
6
|
+
import { IDefinedNamesService as Te, serializeRange as re, FormulaDataModel as Wt, serializeRangeWithSheet as Tt, deserializeRangeWithSheet as At } from "@univerjs/engine-formula";
|
|
7
|
+
var Ft = Object.defineProperty, jt = Object.getOwnPropertyDescriptor, Ot = (s, e, t, n) => {
|
|
8
|
+
for (var r = n > 1 ? void 0 : n ? jt(e, t) : e, o = s.length - 1, i; o >= 0; o--)
|
|
9
|
+
(i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
|
|
10
|
+
return n && r && Ft(e, t, r), r;
|
|
11
|
+
}, S = (s, e) => (t, n) => e(t, n, s);
|
|
12
|
+
function Vt(s, e, t) {
|
|
13
|
+
const n = t.getDefinedNameMap(s);
|
|
14
14
|
if (n == null)
|
|
15
15
|
return e.t("definedName.defaultName") + 1;
|
|
16
|
-
const
|
|
17
|
-
if (t.getValueByName(
|
|
16
|
+
const o = Array.from(Object.values(n)).length + 1, i = e.t("definedName.defaultName") + o;
|
|
17
|
+
if (t.getValueByName(s, i) == null)
|
|
18
18
|
return i;
|
|
19
|
-
let a =
|
|
19
|
+
let a = o + 1;
|
|
20
20
|
for (; ; ) {
|
|
21
21
|
const h = e.t("definedName.defaultName") + a;
|
|
22
|
-
if (t.getValueByName(
|
|
22
|
+
if (t.getValueByName(s, h) == null)
|
|
23
23
|
return h;
|
|
24
24
|
a++;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
class
|
|
27
|
+
class L {
|
|
28
28
|
constructor() {
|
|
29
|
-
|
|
29
|
+
k(this, "_definedNameParam");
|
|
30
30
|
this._definedNameParam = {
|
|
31
|
-
id:
|
|
31
|
+
id: be(10),
|
|
32
32
|
unitId: "",
|
|
33
33
|
name: "",
|
|
34
34
|
formulaOrRefString: ""
|
|
@@ -36,12 +36,12 @@ class F {
|
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* Sets the name of the defined name builder.
|
|
39
|
-
* @param name
|
|
40
|
-
* @returns The defined name builder.
|
|
39
|
+
* @param {string} name The name of the defined name.
|
|
40
|
+
* @returns {FDefinedNameBuilder} The defined name builder.
|
|
41
41
|
* @example
|
|
42
42
|
* ```ts
|
|
43
|
-
* const workbook =
|
|
44
|
-
* const definedNameBuilder =
|
|
43
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
44
|
+
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
45
45
|
* .setName('MyDefinedName')
|
|
46
46
|
* .build();
|
|
47
47
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
@@ -52,12 +52,12 @@ class F {
|
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Sets the formula of the defined name builder.
|
|
55
|
-
* @param formula The formula of the defined name.
|
|
56
|
-
* @returns The defined name builder.
|
|
55
|
+
* @param {string }formula The formula of the defined name.
|
|
56
|
+
* @returns {FDefinedNameBuilder} The defined name builder.
|
|
57
57
|
* @example
|
|
58
58
|
* ```ts
|
|
59
|
-
* const workbook =
|
|
60
|
-
* const definedNameBuilder =
|
|
59
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
60
|
+
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
61
61
|
* .setFormula('SUM(Sheet1!$A$1)')
|
|
62
62
|
* .setName('MyDefinedName')
|
|
63
63
|
* .build();
|
|
@@ -69,12 +69,12 @@ class F {
|
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Sets the reference of the defined name builder.
|
|
72
|
-
* @param
|
|
73
|
-
* @returns The defined name builder.
|
|
72
|
+
* @param {string} a1Notation The reference of the defined name.
|
|
73
|
+
* @returns {FDefinedNameBuilder} The defined name builder.
|
|
74
74
|
* @example
|
|
75
75
|
* ```ts
|
|
76
|
-
* const workbook =
|
|
77
|
-
* const definedNameBuilder =
|
|
76
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
77
|
+
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
78
78
|
* .setRef('Sheet1!$A$1')
|
|
79
79
|
* .build();
|
|
80
80
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
@@ -85,36 +85,36 @@ class F {
|
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* Sets the reference of the defined name builder by range .
|
|
88
|
-
* @param row The start row of the range.
|
|
89
|
-
* @param column The start column of the range.
|
|
90
|
-
* @param numRows The number of rows in the range.
|
|
91
|
-
* @param numColumns The number of columns in the range.
|
|
92
|
-
* @returns The defined name builder.
|
|
88
|
+
* @param {number} row The start row of the range.
|
|
89
|
+
* @param {number} column The start column of the range.
|
|
90
|
+
* @param {number} numRows The number of rows in the range.
|
|
91
|
+
* @param {number} numColumns The number of columns in the range.
|
|
92
|
+
* @returns {FDefinedNameBuilder} The defined name builder.
|
|
93
93
|
* @example
|
|
94
94
|
* ```ts
|
|
95
|
-
* const workbook =
|
|
96
|
-
* const definedNameBuilder =
|
|
95
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
96
|
+
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
97
97
|
* .setRefByRange(1, 3, 2, 5)
|
|
98
98
|
* .build();
|
|
99
99
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
100
100
|
* ```
|
|
101
101
|
*/
|
|
102
|
-
setRefByRange(e, t, n,
|
|
103
|
-
return this._definedNameParam.formulaOrRefString =
|
|
102
|
+
setRefByRange(e, t, n, r) {
|
|
103
|
+
return this._definedNameParam.formulaOrRefString = re({
|
|
104
104
|
startRow: e,
|
|
105
105
|
endRow: e + (n != null ? n : 1) - 1,
|
|
106
106
|
startColumn: t,
|
|
107
|
-
endColumn: t + (
|
|
107
|
+
endColumn: t + (r != null ? r : 1) - 1
|
|
108
108
|
}), this;
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* Sets the comment of the defined name builder.
|
|
112
|
-
* @param comment The comment of the defined name.
|
|
113
|
-
* @returns The defined name builder.
|
|
112
|
+
* @param {string} comment The comment of the defined name.
|
|
113
|
+
* @returns {FDefinedNameBuilder} The defined name builder.
|
|
114
114
|
* @example
|
|
115
115
|
* ```ts
|
|
116
|
-
* const workbook =
|
|
117
|
-
* const definedNameBuilder =
|
|
116
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
117
|
+
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
118
118
|
* .setComment('This is a comment')
|
|
119
119
|
* .build();
|
|
120
120
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
@@ -125,12 +125,12 @@ class F {
|
|
|
125
125
|
}
|
|
126
126
|
/**
|
|
127
127
|
* Sets the hidden status of the defined name builder.
|
|
128
|
-
* @param hidden The hidden status of the defined name.
|
|
129
|
-
* @returns The defined name builder.
|
|
128
|
+
* @param {boolean} hidden The hidden status of the defined name.
|
|
129
|
+
* @returns {FDefinedNameBuilder} The defined name builder.
|
|
130
130
|
* @example
|
|
131
131
|
* ```ts
|
|
132
|
-
* const workbook =
|
|
133
|
-
* const definedNameBuilder =
|
|
132
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
133
|
+
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
134
134
|
* .setHidden(true)
|
|
135
135
|
* .build();
|
|
136
136
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
@@ -141,11 +141,11 @@ class F {
|
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
143
|
* Builds the defined name.
|
|
144
|
-
* @returns The defined name mutation parameter.
|
|
144
|
+
* @returns {FDefinedNameBuilder} The defined name mutation parameter.
|
|
145
145
|
* @example
|
|
146
146
|
* ```ts
|
|
147
|
-
* const workbook =
|
|
148
|
-
* const definedNameBuilder =
|
|
147
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
148
|
+
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
149
149
|
* .setRef('Sheet1!$A$1')
|
|
150
150
|
* .setName('MyDefinedName')
|
|
151
151
|
* .build();
|
|
@@ -159,19 +159,19 @@ class F {
|
|
|
159
159
|
return this._definedNameParam = e, this;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
let
|
|
163
|
-
constructor(
|
|
164
|
-
super(), this._definedNameParam =
|
|
162
|
+
let j = class extends te {
|
|
163
|
+
constructor(s, e, t, n, r, o, i, a, h, c) {
|
|
164
|
+
super(), this._definedNameParam = s, this._injector = e, this._commandService = t, this._permissionService = n, this._worksheetProtectionRuleModel = r, this._rangeProtectionRuleModel = o, this._worksheetProtectionPointRuleModel = i, this._authzIoService = a, this._localeService = h, this._definedNamesService = c;
|
|
165
165
|
}
|
|
166
166
|
_apply() {
|
|
167
|
-
this._definedNameParam.name === "" && (this._definedNameParam.name =
|
|
167
|
+
this._definedNameParam.name === "" && (this._definedNameParam.name = Vt(this._definedNameParam.unitId, this._localeService, this._definedNamesService)), this._commandService.syncExecuteCommand(Q.id, this._definedNameParam);
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
170
170
|
* Gets the name of the defined name.
|
|
171
|
-
* @returns The name of the defined name.
|
|
171
|
+
* @returns {string} The name of the defined name.
|
|
172
172
|
* @example
|
|
173
173
|
* ```ts
|
|
174
|
-
* const workbook =
|
|
174
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
175
175
|
* const definedName = workbook.getDefinedNames[0];
|
|
176
176
|
* console.log(definedName.getName());
|
|
177
177
|
* ```
|
|
@@ -181,49 +181,49 @@ let M = class extends Q {
|
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
183
|
* Sets the name of the defined name.
|
|
184
|
-
* @param name The name of the defined name.
|
|
184
|
+
* @param {string} name The name of the defined name.
|
|
185
185
|
* @example
|
|
186
186
|
* ```ts
|
|
187
|
-
* const workbook =
|
|
187
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
188
188
|
* const definedName = workbook.getDefinedName('MyDefinedName');
|
|
189
189
|
* definedName.setName('NewDefinedName');
|
|
190
190
|
* ```
|
|
191
191
|
*/
|
|
192
|
-
setName(
|
|
193
|
-
this._definedNameParam.name =
|
|
192
|
+
setName(s) {
|
|
193
|
+
this._definedNameParam.name = s, this._apply();
|
|
194
194
|
}
|
|
195
195
|
/**
|
|
196
196
|
* Sets the formula of the defined name.
|
|
197
|
-
* @param formula The formula of the defined name.
|
|
197
|
+
* @param {string} formula The formula of the defined name.
|
|
198
198
|
* @example
|
|
199
199
|
* ```ts
|
|
200
|
-
* const workbook =
|
|
200
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
201
201
|
* const definedName = workbook.getDefinedName('MyDefinedName');
|
|
202
202
|
* definedName.setFormula('SUM(Sheet1!$A$1)');
|
|
203
203
|
* ```
|
|
204
204
|
*/
|
|
205
|
-
setFormula(
|
|
206
|
-
this._definedNameParam.formulaOrRefString = `=${
|
|
205
|
+
setFormula(s) {
|
|
206
|
+
this._definedNameParam.formulaOrRefString = `=${s}`, this._apply();
|
|
207
207
|
}
|
|
208
208
|
/**
|
|
209
209
|
* Sets the reference of the defined name.
|
|
210
|
-
* @param refString The reference of the defined name.
|
|
210
|
+
* @param {string} refString The reference of the defined name.
|
|
211
211
|
* @example
|
|
212
212
|
* ```ts
|
|
213
|
-
* const workbook =
|
|
213
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
214
214
|
* const definedName = workbook.getDefinedNames[0];
|
|
215
215
|
* definedName.setRef('Sheet1!$A$1');
|
|
216
216
|
* ```
|
|
217
217
|
*/
|
|
218
|
-
setRef(
|
|
219
|
-
this._definedNameParam.formulaOrRefString =
|
|
218
|
+
setRef(s) {
|
|
219
|
+
this._definedNameParam.formulaOrRefString = s, this._apply();
|
|
220
220
|
}
|
|
221
221
|
/**
|
|
222
222
|
* Gets the reference of the defined name.
|
|
223
|
-
* @returns The reference of the defined name.
|
|
223
|
+
* @returns {string} The reference of the defined name.
|
|
224
224
|
* @example
|
|
225
225
|
* ```ts
|
|
226
|
-
* const workbook =
|
|
226
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
227
227
|
* const definedName = workbook.getDefinedNames[0];
|
|
228
228
|
* console.log(definedName.getFormulaOrRefString());
|
|
229
229
|
* ```
|
|
@@ -233,31 +233,31 @@ let M = class extends Q {
|
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
235
235
|
* Sets the reference of the defined name by range.
|
|
236
|
-
* @param row The start row of the range.
|
|
237
|
-
* @param column The start column of the range.
|
|
238
|
-
* @param numRows The number of rows in the range.
|
|
239
|
-
* @param numColumns The number of columns in the range.
|
|
236
|
+
* @param {number} row The start row of the range.
|
|
237
|
+
* @param {number} column The start column of the range.
|
|
238
|
+
* @param {number} numRows The number of rows in the range.
|
|
239
|
+
* @param {number} numColumns The number of columns in the range.
|
|
240
240
|
* @example
|
|
241
241
|
* ```ts
|
|
242
|
-
* const workbook =
|
|
242
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
243
243
|
* const definedName = workbook.getDefinedNames[0];
|
|
244
244
|
* definedName.setRefByRange(1, 3, 2, 5);
|
|
245
245
|
* ```
|
|
246
246
|
*/
|
|
247
|
-
setRefByRange(
|
|
248
|
-
this._definedNameParam.formulaOrRefString =
|
|
249
|
-
startRow:
|
|
250
|
-
endRow:
|
|
247
|
+
setRefByRange(s, e, t, n) {
|
|
248
|
+
this._definedNameParam.formulaOrRefString = re({
|
|
249
|
+
startRow: s,
|
|
250
|
+
endRow: s + (t != null ? t : 1) - 1,
|
|
251
251
|
startColumn: e,
|
|
252
252
|
endColumn: e + (n != null ? n : 1) - 1
|
|
253
253
|
}), this._apply();
|
|
254
254
|
}
|
|
255
255
|
/**
|
|
256
256
|
* Gets the comment of the defined name.
|
|
257
|
-
* @returns The comment of the defined name.
|
|
257
|
+
* @returns {string | undefined} The comment of the defined name.
|
|
258
258
|
* @example
|
|
259
259
|
* ```ts
|
|
260
|
-
* const workbook =
|
|
260
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
261
261
|
* const definedName = workbook.getDefinedNames[0];
|
|
262
262
|
* console.log(definedName.getComment());
|
|
263
263
|
* ```
|
|
@@ -267,74 +267,74 @@ let M = class extends Q {
|
|
|
267
267
|
}
|
|
268
268
|
/**
|
|
269
269
|
* Sets the comment of the defined name.
|
|
270
|
-
* @param comment The comment of the defined name.
|
|
270
|
+
* @param {string} comment The comment of the defined name.
|
|
271
271
|
* @example
|
|
272
272
|
* ```ts
|
|
273
|
-
* const workbook =
|
|
273
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
274
274
|
* const definedName = workbook.getDefinedNames[0];
|
|
275
275
|
* definedName.setComment('This is a comment');
|
|
276
276
|
* ```
|
|
277
277
|
*/
|
|
278
|
-
setComment(
|
|
279
|
-
this._definedNameParam.comment =
|
|
278
|
+
setComment(s) {
|
|
279
|
+
this._definedNameParam.comment = s, this._apply();
|
|
280
280
|
}
|
|
281
281
|
/**
|
|
282
282
|
* Sets the scope of the defined name to the worksheet.
|
|
283
|
-
* @param worksheet The worksheet to set the scope to.
|
|
283
|
+
* @param {FWorksheet} worksheet The worksheet to set the scope to.
|
|
284
284
|
* @example
|
|
285
285
|
* ```ts
|
|
286
|
-
* const workbook =
|
|
286
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
287
287
|
* const worksheet = workbook.getWorksheets[0];
|
|
288
288
|
* const definedName = workbook.getDefinedNames[0];
|
|
289
289
|
* definedName.setScopeToWorksheet(worksheet);
|
|
290
290
|
* ```
|
|
291
291
|
*/
|
|
292
|
-
setScopeToWorksheet(
|
|
293
|
-
this._definedNameParam.localSheetId =
|
|
292
|
+
setScopeToWorksheet(s) {
|
|
293
|
+
this._definedNameParam.localSheetId = s.getSheetId(), this._apply();
|
|
294
294
|
}
|
|
295
295
|
/**
|
|
296
296
|
* Sets the scope of the defined name to the workbook.
|
|
297
297
|
* @example
|
|
298
298
|
* ```ts
|
|
299
|
-
* const workbook =
|
|
299
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
300
300
|
* const definedName = workbook.getDefinedNames[0];
|
|
301
301
|
* definedName.setScopeToWorkbook();
|
|
302
302
|
* ```
|
|
303
303
|
*/
|
|
304
304
|
setScopeToWorkbook() {
|
|
305
|
-
this._definedNameParam.localSheetId =
|
|
305
|
+
this._definedNameParam.localSheetId = X, this._apply();
|
|
306
306
|
}
|
|
307
307
|
/**
|
|
308
308
|
* Sets the hidden status of the defined name.
|
|
309
|
-
* @param hidden The hidden status of the defined name.
|
|
309
|
+
* @param {boolean} hidden The hidden status of the defined name.
|
|
310
310
|
* @example
|
|
311
311
|
* ```ts
|
|
312
|
-
* const workbook =
|
|
312
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
313
313
|
* const definedName = workbook.getDefinedNames[0];
|
|
314
314
|
* definedName.setHidden(true);
|
|
315
315
|
* ```
|
|
316
316
|
*/
|
|
317
|
-
setHidden(
|
|
318
|
-
this._definedNameParam.hidden =
|
|
317
|
+
setHidden(s) {
|
|
318
|
+
this._definedNameParam.hidden = s, this._apply();
|
|
319
319
|
}
|
|
320
320
|
/**
|
|
321
321
|
* Deletes the defined name.
|
|
322
322
|
* @example
|
|
323
323
|
* ```ts
|
|
324
|
-
* const workbook =
|
|
324
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
325
325
|
* const definedName = workbook.getDefinedNames[0];
|
|
326
326
|
* definedName.delete();
|
|
327
327
|
* ```
|
|
328
328
|
*/
|
|
329
329
|
delete() {
|
|
330
|
-
this._commandService.syncExecuteCommand(
|
|
330
|
+
this._commandService.syncExecuteCommand(Ke.id, this._definedNameParam);
|
|
331
331
|
}
|
|
332
332
|
/**
|
|
333
333
|
* Gets the local sheet id of the defined name.
|
|
334
|
-
* @returns The local sheet id of the defined name.
|
|
334
|
+
* @returns {string | undefined} The local sheet id of the defined name.
|
|
335
335
|
* @example
|
|
336
336
|
* ```ts
|
|
337
|
-
* const workbook =
|
|
337
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
338
338
|
* const definedName = workbook.getDefinedNames[0];
|
|
339
339
|
* console.log(definedName.getLocalSheetId());
|
|
340
340
|
* ```
|
|
@@ -344,23 +344,23 @@ let M = class extends Q {
|
|
|
344
344
|
}
|
|
345
345
|
/**
|
|
346
346
|
* Checks if the defined name is in the workbook scope.
|
|
347
|
-
* @returns True if the defined name is in the workbook scope, false otherwise.
|
|
347
|
+
* @returns {boolean} True if the defined name is in the workbook scope, false otherwise.
|
|
348
348
|
* @example
|
|
349
349
|
* ```ts
|
|
350
|
-
* const workbook =
|
|
350
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
351
351
|
* const definedName = workbook.getDefinedNames[0];
|
|
352
352
|
* console.log(definedName.isWorkbookScope());
|
|
353
353
|
* ```
|
|
354
354
|
*/
|
|
355
355
|
isWorkbookScope() {
|
|
356
|
-
return this._definedNameParam.localSheetId ===
|
|
356
|
+
return this._definedNameParam.localSheetId === X;
|
|
357
357
|
}
|
|
358
358
|
/**
|
|
359
359
|
* Converts the defined name to a defined name builder.
|
|
360
|
-
* @returns The defined name builder.
|
|
360
|
+
* @returns {FDefinedNameBuilder} The defined name builder.
|
|
361
361
|
* @example
|
|
362
362
|
* ```ts
|
|
363
|
-
* const workbook =
|
|
363
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
364
364
|
* const definedName = workbook.getDefinedNames[0];
|
|
365
365
|
* const definedNameBuilder = definedName.toBuilder();
|
|
366
366
|
* const param definedNameBuilder.setName('NewDefinedName').setFormula('SUM(Sheet1!$A$1)').build();
|
|
@@ -368,70 +368,66 @@ let M = class extends Q {
|
|
|
368
368
|
* ```
|
|
369
369
|
*/
|
|
370
370
|
toBuilder() {
|
|
371
|
-
const
|
|
372
|
-
return
|
|
371
|
+
const s = this._injector.createInstance(L);
|
|
372
|
+
return s.load(this._definedNameParam), s;
|
|
373
373
|
}
|
|
374
374
|
};
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
],
|
|
386
|
-
var
|
|
387
|
-
for (var
|
|
388
|
-
(i = o
|
|
389
|
-
return n &&
|
|
390
|
-
},
|
|
391
|
-
let
|
|
392
|
-
constructor(e, t, n,
|
|
375
|
+
j = Ot([
|
|
376
|
+
S(1, u(b)),
|
|
377
|
+
S(2, l),
|
|
378
|
+
S(3, ee),
|
|
379
|
+
S(4, u(Ee)),
|
|
380
|
+
S(5, u(Pe)),
|
|
381
|
+
S(6, u(xe)),
|
|
382
|
+
S(7, u(ve)),
|
|
383
|
+
S(8, u(Re)),
|
|
384
|
+
S(9, Te)
|
|
385
|
+
], j);
|
|
386
|
+
var Bt = Object.defineProperty, Lt = Object.getOwnPropertyDescriptor, zt = (s, e, t, n) => {
|
|
387
|
+
for (var r = n > 1 ? void 0 : n ? Lt(e, t) : e, o = s.length - 1, i; o >= 0; o--)
|
|
388
|
+
(i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
|
|
389
|
+
return n && r && Bt(e, t, r), r;
|
|
390
|
+
}, v = (s, e) => (t, n) => e(t, n, s);
|
|
391
|
+
let O = class extends te {
|
|
392
|
+
constructor(e, t, n, r, o, i, a) {
|
|
393
393
|
super();
|
|
394
|
-
|
|
395
|
-
this
|
|
394
|
+
k(this, "permissionPointsDefinition", Ye);
|
|
395
|
+
k(this, "rangeRuleChangedAfterAuth$");
|
|
396
|
+
k(this, "sheetRuleChangedAfterAuth$");
|
|
397
|
+
this._injector = e, this._commandService = t, this._permissionService = n, this._worksheetProtectionRuleModel = r, this._rangeProtectionRuleModel = o, this._worksheetProtectionPointRuleModel = i, this._authzIoService = a, this.rangeRuleChangedAfterAuth$ = this._rangeProtectionRuleModel.ruleRefresh$, this.sheetRuleChangedAfterAuth$ = this._worksheetProtectionRuleModel.ruleRefresh$;
|
|
396
398
|
}
|
|
397
399
|
/**
|
|
398
400
|
* Configures a specific permission point for a workbook.
|
|
399
401
|
*
|
|
400
402
|
* This function sets or updates a permission point for a workbook identified by `unitId`.
|
|
401
403
|
* It creates a new permission point if it does not already exist, and updates the point with the provided value.
|
|
402
|
-
*
|
|
403
404
|
* @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
|
|
404
405
|
* @param {WorkbookPermissionPointConstructor} FPointClass - The constructor function for creating a permission point instance. Other point constructors can See the [permission-point documentation](https://github.com/dream-num/univer/tree/dev/packages/sheets/src/services/permission/permission-point) for more details.
|
|
405
406
|
* @param {boolean} value - The boolean value to determine whether the permission point is enabled or disabled.
|
|
406
|
-
*
|
|
407
407
|
*/
|
|
408
408
|
setWorkbookPermissionPoint(e, t, n) {
|
|
409
|
-
const
|
|
410
|
-
this._permissionService.getPermissionPoint(
|
|
409
|
+
const r = new t(e);
|
|
410
|
+
this._permissionService.getPermissionPoint(r.id) || this._permissionService.addPermissionPoint(r), this._permissionService.updatePermissionPoint(r.id, n);
|
|
411
411
|
}
|
|
412
412
|
/**
|
|
413
413
|
* This function is used to set whether the workbook can be edited
|
|
414
|
-
*
|
|
415
414
|
* @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
|
|
416
415
|
* @param {boolean} value - A value that controls whether the workbook can be edited
|
|
417
|
-
*
|
|
418
416
|
*/
|
|
419
417
|
setWorkbookEditPermission(e, t) {
|
|
420
|
-
this.setWorkbookPermissionPoint(e,
|
|
418
|
+
this.setWorkbookPermissionPoint(e, Ne, t);
|
|
421
419
|
}
|
|
422
420
|
/**
|
|
423
421
|
* This function is used to add a base permission for a worksheet.
|
|
424
|
-
*
|
|
425
422
|
* @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
|
|
426
423
|
* @param {string} subUnitId - The unique identifier of the worksheet for which the permission is being set.
|
|
427
|
-
*
|
|
428
424
|
* @returns {Promise<string | undefined>} - Returns the `permissionId` if the permission is successfully added. If the operation fails or no result is returned, it resolves to `undefined`.
|
|
429
425
|
*/
|
|
430
426
|
async addWorksheetBasePermission(e, t) {
|
|
431
427
|
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length > 0)
|
|
432
428
|
throw new Error("sheet protection cannot intersect with range protection");
|
|
433
|
-
const
|
|
434
|
-
objectType:
|
|
429
|
+
const r = await this._authzIoService.create({
|
|
430
|
+
objectType: E.Worksheet,
|
|
435
431
|
worksheetObject: {
|
|
436
432
|
collaborators: [],
|
|
437
433
|
unitID: e,
|
|
@@ -440,51 +436,48 @@ let j = class extends Q {
|
|
|
440
436
|
scope: void 0
|
|
441
437
|
}
|
|
442
438
|
});
|
|
443
|
-
if (this._commandService.syncExecuteCommand(
|
|
439
|
+
if (this._commandService.syncExecuteCommand(Je.id, {
|
|
444
440
|
unitId: e,
|
|
445
441
|
subUnitId: t,
|
|
446
442
|
rule: {
|
|
447
|
-
permissionId:
|
|
448
|
-
unitType:
|
|
443
|
+
permissionId: r,
|
|
444
|
+
unitType: E.Worksheet,
|
|
449
445
|
unitId: e,
|
|
450
446
|
subUnitId: t
|
|
451
447
|
}
|
|
452
448
|
}))
|
|
453
|
-
return
|
|
449
|
+
return r;
|
|
454
450
|
}
|
|
455
451
|
/**
|
|
456
452
|
* Delete the entire table protection set for the worksheet and reset the point permissions of the worksheet to true
|
|
457
|
-
*
|
|
458
453
|
* @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
|
|
459
454
|
* @param {string} subUnitId - The unique identifier of the worksheet for which the permission is being set.
|
|
460
455
|
*/
|
|
461
456
|
removeWorksheetPermission(e, t) {
|
|
462
|
-
this._commandService.syncExecuteCommand(
|
|
457
|
+
this._commandService.syncExecuteCommand(Qe.id, {
|
|
463
458
|
unitId: e,
|
|
464
459
|
subUnitId: t
|
|
465
|
-
}), [...
|
|
466
|
-
const
|
|
467
|
-
this._permissionService.updatePermissionPoint(
|
|
460
|
+
}), [...Xe(), ...ae()].forEach((n) => {
|
|
461
|
+
const r = new n(e, t);
|
|
462
|
+
this._permissionService.updatePermissionPoint(r.id, !0);
|
|
468
463
|
}), this._worksheetProtectionPointRuleModel.deleteRule(e, t);
|
|
469
464
|
}
|
|
470
465
|
/**
|
|
471
466
|
* Sets the worksheet permission point by updating or adding the permission point for the worksheet.
|
|
472
467
|
* If the worksheet doesn't have a base permission, it creates one to used render
|
|
473
|
-
*
|
|
474
468
|
* @param {string} unitId - The unique identifier of the workbook.
|
|
475
469
|
* @param {string} subUnitId - The unique identifier of the worksheet.
|
|
476
470
|
* @param {WorkSheetPermissionPointConstructor} FPointClass - The constructor for the permission point class.
|
|
477
471
|
* See the [permission-point documentation](https://github.com/dream-num/univer/tree/dev/packages/sheets/src/services/permission/permission-point) for more details.
|
|
478
472
|
* @param {boolean} value - The new permission value to be set for the worksheet.
|
|
479
|
-
*
|
|
480
473
|
* @returns {Promise<string | undefined>} - Returns the `permissionId` if the permission point is successfully set or created. If no permission is set, it resolves to `undefined`.
|
|
481
474
|
*/
|
|
482
|
-
async setWorksheetPermissionPoint(e, t, n,
|
|
483
|
-
const
|
|
475
|
+
async setWorksheetPermissionPoint(e, t, n, r) {
|
|
476
|
+
const o = this._worksheetProtectionRuleModel.getRule(e, t);
|
|
484
477
|
let i;
|
|
485
|
-
if (n ===
|
|
486
|
-
if (
|
|
487
|
-
i =
|
|
478
|
+
if (n === st || n === rt)
|
|
479
|
+
if (o)
|
|
480
|
+
i = o.permissionId;
|
|
488
481
|
else {
|
|
489
482
|
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length > 0)
|
|
490
483
|
throw new Error("sheet protection cannot intersect with range protection");
|
|
@@ -493,7 +486,7 @@ let j = class extends Q {
|
|
|
493
486
|
else {
|
|
494
487
|
const d = this._worksheetProtectionPointRuleModel.getRule(e, t);
|
|
495
488
|
d ? i = d.permissionId : (i = await this._authzIoService.create({
|
|
496
|
-
objectType:
|
|
489
|
+
objectType: E.Worksheet,
|
|
497
490
|
worksheetObject: {
|
|
498
491
|
collaborators: [],
|
|
499
492
|
unitID: e,
|
|
@@ -501,71 +494,67 @@ let j = class extends Q {
|
|
|
501
494
|
name: "",
|
|
502
495
|
scope: void 0
|
|
503
496
|
}
|
|
504
|
-
}), this._commandService.executeCommand(
|
|
497
|
+
}), this._commandService.executeCommand(Ze.id, { unitId: e, subUnitId: t, permissionId: i }));
|
|
505
498
|
}
|
|
506
499
|
const h = new n(e, t);
|
|
507
|
-
return this._permissionService.getPermissionPoint(h.id) || this._permissionService.addPermissionPoint(h), this._permissionService.updatePermissionPoint(h.id,
|
|
500
|
+
return this._permissionService.getPermissionPoint(h.id) || this._permissionService.addPermissionPoint(h), this._permissionService.updatePermissionPoint(h.id, r), i;
|
|
508
501
|
}
|
|
509
502
|
/**
|
|
510
503
|
* Adds a range protection to the worksheet.
|
|
511
|
-
*
|
|
512
504
|
* @param {string} unitId - The unique identifier of the workbook.
|
|
513
505
|
* @param {string} subUnitId - The unique identifier of the worksheet.
|
|
514
506
|
* @param {IRange[]} ranges - The ranges to be protected.
|
|
515
|
-
*
|
|
516
507
|
* @returns {Promise<{ permissionId: string, ruleId: string } | undefined>} - Returns an object containing the `permissionId` and `ruleId` if the range protection is successfully added. If the operation fails or no result is returned, it resolves to `undefined`. permissionId is used to stitch permission point ID,ruleId is used to store permission rules
|
|
517
508
|
*/
|
|
518
509
|
async addRangeBaseProtection(e, t, n) {
|
|
519
|
-
const
|
|
520
|
-
objectType:
|
|
510
|
+
const r = await this._authzIoService.create({
|
|
511
|
+
objectType: E.SelectRange,
|
|
521
512
|
selectRangeObject: {
|
|
522
513
|
collaborators: [],
|
|
523
514
|
unitID: e,
|
|
524
515
|
name: "",
|
|
525
516
|
scope: void 0
|
|
526
517
|
}
|
|
527
|
-
}),
|
|
518
|
+
}), o = `ruleId_${be(6)}`;
|
|
528
519
|
if (this._worksheetProtectionRuleModel.getRule(e, t))
|
|
529
520
|
throw new Error("sheet protection cannot intersect with range protection");
|
|
530
|
-
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).some((d) => d.ranges.some((
|
|
521
|
+
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).some((d) => d.ranges.some((z) => n.some((M) => N.intersects(M, z)))))
|
|
531
522
|
throw new Error("range protection cannot intersect");
|
|
532
|
-
if (this._commandService.syncExecuteCommand(
|
|
523
|
+
if (this._commandService.syncExecuteCommand(et.id, {
|
|
533
524
|
unitId: e,
|
|
534
525
|
subUnitId: t,
|
|
535
526
|
rules: [{
|
|
536
|
-
permissionId:
|
|
537
|
-
unitType:
|
|
527
|
+
permissionId: r,
|
|
528
|
+
unitType: E.SelectRange,
|
|
538
529
|
unitId: e,
|
|
539
530
|
subUnitId: t,
|
|
540
531
|
ranges: n,
|
|
541
|
-
id:
|
|
532
|
+
id: o
|
|
542
533
|
}]
|
|
543
534
|
}))
|
|
544
535
|
return {
|
|
545
|
-
permissionId:
|
|
546
|
-
ruleId:
|
|
536
|
+
permissionId: r,
|
|
537
|
+
ruleId: o
|
|
547
538
|
};
|
|
548
539
|
}
|
|
549
540
|
/**
|
|
550
541
|
* Removes the range protection from the worksheet.
|
|
551
|
-
*
|
|
552
542
|
* @param {string} unitId - The unique identifier of the workbook.
|
|
553
543
|
* @param {string} subUnitId - The unique identifier of the worksheet.
|
|
554
544
|
* @param {string[]} ruleIds - The rule IDs of the range protection to be removed.
|
|
555
545
|
*/
|
|
556
546
|
removeRangeProtection(e, t, n) {
|
|
557
|
-
this._commandService.syncExecuteCommand(
|
|
547
|
+
this._commandService.syncExecuteCommand(tt.id, {
|
|
558
548
|
unitId: e,
|
|
559
549
|
subUnitId: t,
|
|
560
550
|
ruleIds: n
|
|
561
|
-
}) && this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length === 0 && (this._worksheetProtectionPointRuleModel.deleteRule(e, t), [...
|
|
551
|
+
}) && this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length === 0 && (this._worksheetProtectionPointRuleModel.deleteRule(e, t), [...ae()].forEach((i) => {
|
|
562
552
|
const a = new i(e, t);
|
|
563
553
|
this._permissionService.updatePermissionPoint(a.id, a.value);
|
|
564
554
|
}));
|
|
565
555
|
}
|
|
566
556
|
/**
|
|
567
557
|
* Modify the permission points of a custom area
|
|
568
|
-
*
|
|
569
558
|
* @param {string} unitId - The unique identifier of the workbook.
|
|
570
559
|
* @param {string} subUnitId - The unique identifier of the worksheet within the workbook.
|
|
571
560
|
* @param {string} permissionId - The unique identifier of the permission that controls access to the range.
|
|
@@ -573,9 +562,9 @@ let j = class extends Q {
|
|
|
573
562
|
* See the [permission-point documentation](https://github.com/dream-num/univer/tree/dev/packages/sheets/src/services/permission/permission-point) for more details.
|
|
574
563
|
* @param {boolean} value - The new permission value to be set for the range (e.g., true for allowing access, false for restricting access).
|
|
575
564
|
*/
|
|
576
|
-
setRangeProtectionPermissionPoint(e, t, n,
|
|
577
|
-
const i = new
|
|
578
|
-
this._permissionService.getPermissionPoint(i.id) || this._permissionService.addPermissionPoint(i), this._permissionService.updatePermissionPoint(i.id,
|
|
565
|
+
setRangeProtectionPermissionPoint(e, t, n, r, o) {
|
|
566
|
+
const i = new r(e, t, n);
|
|
567
|
+
this._permissionService.getPermissionPoint(i.id) || this._permissionService.addPermissionPoint(i), this._permissionService.updatePermissionPoint(i.id, o);
|
|
579
568
|
}
|
|
580
569
|
/**
|
|
581
570
|
* Sets the ranges for range protection in a worksheet.
|
|
@@ -583,387 +572,768 @@ let j = class extends Q {
|
|
|
583
572
|
* This method finds the rule by unitId, subUnitId, and ruleId, and updates the rule with the provided ranges.
|
|
584
573
|
* It checks for overlaps with existing ranges in the same subunit and shows an error message if any overlap is detected.
|
|
585
574
|
* If no overlap is found, it executes the command to update the range protection with the new ranges.
|
|
586
|
-
*
|
|
587
575
|
* @param {string} unitId - The unique identifier of the workbook.
|
|
588
576
|
* @param {string} subUnitId - The unique identifier of the worksheet within the workbook.
|
|
589
577
|
* @param {string} ruleId - The ruleId of the range protection rule that is being updated.
|
|
590
578
|
* @param {IRange[]} ranges - The array of new ranges to be set for the range protection rule.
|
|
591
579
|
*/
|
|
592
|
-
setRangeProtectionRanges(e, t, n,
|
|
593
|
-
const
|
|
594
|
-
if (
|
|
595
|
-
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).filter((h) => h.id !== n).some((h) => h.ranges.some((c) =>
|
|
580
|
+
setRangeProtectionRanges(e, t, n, r) {
|
|
581
|
+
const o = this._rangeProtectionRuleModel.getRule(e, t, n);
|
|
582
|
+
if (o) {
|
|
583
|
+
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).filter((h) => h.id !== n).some((h) => h.ranges.some((c) => r.some((d) => N.intersects(d, c)))))
|
|
596
584
|
throw new Error("range protection cannot intersect");
|
|
597
|
-
this._commandService.syncExecuteCommand(
|
|
585
|
+
this._commandService.syncExecuteCommand(nt.id, {
|
|
598
586
|
unitId: e,
|
|
599
587
|
subUnitId: t,
|
|
600
588
|
ruleId: n,
|
|
601
589
|
rule: {
|
|
602
|
-
...
|
|
603
|
-
ranges:
|
|
590
|
+
...o,
|
|
591
|
+
ranges: r
|
|
604
592
|
}
|
|
605
593
|
});
|
|
606
594
|
}
|
|
607
595
|
}
|
|
608
|
-
/**
|
|
609
|
-
* Set visibility of unauthorized pop-up window
|
|
610
|
-
*
|
|
611
|
-
* @param {boolean} visible
|
|
612
|
-
*/
|
|
613
|
-
setPermissionDialogVisible(e) {
|
|
614
|
-
this._permissionService.setShowComponents(e);
|
|
615
|
-
}
|
|
616
596
|
};
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
],
|
|
626
|
-
function
|
|
627
|
-
switch (
|
|
597
|
+
O = zt([
|
|
598
|
+
v(0, u(b)),
|
|
599
|
+
v(1, l),
|
|
600
|
+
v(2, ee),
|
|
601
|
+
v(3, u(Ee)),
|
|
602
|
+
v(4, u(Pe)),
|
|
603
|
+
v(5, u(xe)),
|
|
604
|
+
v(6, u(ve))
|
|
605
|
+
], O);
|
|
606
|
+
function $t(s) {
|
|
607
|
+
switch (s) {
|
|
628
608
|
case "left":
|
|
629
|
-
return
|
|
609
|
+
return y.LEFT;
|
|
630
610
|
case "center":
|
|
631
|
-
return
|
|
611
|
+
return y.CENTER;
|
|
632
612
|
case "normal":
|
|
633
|
-
return
|
|
613
|
+
return y.RIGHT;
|
|
634
614
|
default:
|
|
635
|
-
throw new Error(`Invalid horizontal alignment: ${
|
|
615
|
+
throw new Error(`Invalid horizontal alignment: ${s}`);
|
|
636
616
|
}
|
|
637
617
|
}
|
|
638
|
-
function
|
|
639
|
-
switch (
|
|
640
|
-
case
|
|
618
|
+
function Ht(s) {
|
|
619
|
+
switch (s) {
|
|
620
|
+
case y.LEFT:
|
|
641
621
|
return "left";
|
|
642
|
-
case
|
|
622
|
+
case y.CENTER:
|
|
643
623
|
return "center";
|
|
644
|
-
case
|
|
624
|
+
case y.RIGHT:
|
|
645
625
|
return "normal";
|
|
646
626
|
default:
|
|
647
|
-
throw new Error(`Invalid horizontal alignment: ${
|
|
627
|
+
throw new Error(`Invalid horizontal alignment: ${s}`);
|
|
648
628
|
}
|
|
649
629
|
}
|
|
650
|
-
function
|
|
651
|
-
switch (
|
|
630
|
+
function Gt(s) {
|
|
631
|
+
switch (s) {
|
|
652
632
|
case "top":
|
|
653
|
-
return
|
|
633
|
+
return U.TOP;
|
|
654
634
|
case "middle":
|
|
655
|
-
return
|
|
635
|
+
return U.MIDDLE;
|
|
656
636
|
case "bottom":
|
|
657
|
-
return
|
|
637
|
+
return U.BOTTOM;
|
|
658
638
|
default:
|
|
659
|
-
throw new Error(`Invalid vertical alignment: ${
|
|
639
|
+
throw new Error(`Invalid vertical alignment: ${s}`);
|
|
660
640
|
}
|
|
661
641
|
}
|
|
662
|
-
function
|
|
663
|
-
switch (
|
|
664
|
-
case
|
|
642
|
+
function qt(s) {
|
|
643
|
+
switch (s) {
|
|
644
|
+
case U.TOP:
|
|
665
645
|
return "top";
|
|
666
|
-
case
|
|
646
|
+
case U.MIDDLE:
|
|
667
647
|
return "middle";
|
|
668
|
-
case
|
|
648
|
+
case U.BOTTOM:
|
|
669
649
|
return "bottom";
|
|
670
650
|
default:
|
|
671
|
-
throw new Error(`Invalid vertical alignment: ${
|
|
651
|
+
throw new Error(`Invalid vertical alignment: ${s}`);
|
|
672
652
|
}
|
|
673
653
|
}
|
|
674
|
-
function
|
|
675
|
-
return
|
|
676
|
-
f:
|
|
677
|
-
} :
|
|
678
|
-
v:
|
|
679
|
-
} : (
|
|
654
|
+
function V(s) {
|
|
655
|
+
return je(s) ? {
|
|
656
|
+
f: s
|
|
657
|
+
} : Oe(s) ? {
|
|
658
|
+
v: s
|
|
659
|
+
} : (Ve(s), s);
|
|
680
660
|
}
|
|
681
|
-
function
|
|
682
|
-
const t = new
|
|
683
|
-
if (
|
|
684
|
-
for (let a = 0; a <=
|
|
685
|
-
for (let h = 0; h <= i -
|
|
686
|
-
t.setValue(a + n, h +
|
|
661
|
+
function Ie(s, e) {
|
|
662
|
+
const t = new A(), { startRow: n, startColumn: r, endRow: o, endColumn: i } = e;
|
|
663
|
+
if (Be.isArray(s))
|
|
664
|
+
for (let a = 0; a <= o - n; a++)
|
|
665
|
+
for (let h = 0; h <= i - r; h++)
|
|
666
|
+
t.setValue(a + n, h + r, V(s[a][h]));
|
|
687
667
|
else
|
|
688
|
-
new
|
|
689
|
-
t.setValue(h, c,
|
|
668
|
+
new A(s).forValue((h, c, d) => {
|
|
669
|
+
t.setValue(h, c, V(d));
|
|
690
670
|
});
|
|
691
671
|
return t.getMatrix();
|
|
692
672
|
}
|
|
693
|
-
function
|
|
673
|
+
function q(s, e) {
|
|
694
674
|
return {
|
|
695
|
-
startRow:
|
|
696
|
-
endRow:
|
|
675
|
+
startRow: s.startRow,
|
|
676
|
+
endRow: s.endRow,
|
|
697
677
|
startColumn: 0,
|
|
698
678
|
endColumn: e.getColumnCount() - 1,
|
|
699
679
|
rangeType: _.ROW
|
|
700
680
|
};
|
|
701
681
|
}
|
|
702
|
-
function
|
|
682
|
+
function K(s, e) {
|
|
703
683
|
return {
|
|
704
684
|
startRow: 0,
|
|
705
685
|
endRow: e.getRowCount() - 1,
|
|
706
|
-
startColumn:
|
|
707
|
-
endColumn:
|
|
686
|
+
startColumn: s.startColumn,
|
|
687
|
+
endColumn: s.endColumn,
|
|
708
688
|
rangeType: _.COLUMN
|
|
709
689
|
};
|
|
710
690
|
}
|
|
711
|
-
var
|
|
712
|
-
for (var
|
|
713
|
-
(i = o
|
|
714
|
-
return n &&
|
|
715
|
-
},
|
|
716
|
-
let
|
|
717
|
-
constructor(
|
|
718
|
-
super(n), this._workbook =
|
|
691
|
+
var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Jt = (s, e, t, n) => {
|
|
692
|
+
for (var r = n > 1 ? void 0 : n ? Yt(e, t) : e, o = s.length - 1, i; o >= 0; o--)
|
|
693
|
+
(i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
|
|
694
|
+
return n && r && Kt(e, t, r), r;
|
|
695
|
+
}, Y = (s, e) => (t, n) => e(t, n, s);
|
|
696
|
+
let w = class extends ne {
|
|
697
|
+
constructor(s, e, t, n, r, o) {
|
|
698
|
+
super(n), this._workbook = s, this._worksheet = e, this._range = t, this._injector = n, this._commandService = r, this._formulaDataModel = o;
|
|
719
699
|
}
|
|
720
700
|
/**
|
|
721
701
|
* Get the unit ID of the current workbook
|
|
722
|
-
*
|
|
723
|
-
* @
|
|
702
|
+
* @returns {string} The unit ID of the workbook
|
|
703
|
+
* @example
|
|
704
|
+
* ```ts
|
|
705
|
+
* univerAPI.getActiveWorkbook()
|
|
706
|
+
* .getActiveSheet()
|
|
707
|
+
* .getActiveRange()
|
|
708
|
+
* .getUnitId()
|
|
709
|
+
* ```
|
|
724
710
|
*/
|
|
725
711
|
getUnitId() {
|
|
726
712
|
return this._workbook.getUnitId();
|
|
727
713
|
}
|
|
728
714
|
/**
|
|
729
715
|
* Gets the name of the worksheet
|
|
730
|
-
*
|
|
731
|
-
* @
|
|
716
|
+
* @returns {string} The name of the worksheet
|
|
717
|
+
* @example
|
|
718
|
+
* ```ts
|
|
719
|
+
* univerAPI.getActiveWorkbook()
|
|
720
|
+
* .getActiveSheet()
|
|
721
|
+
* .getActiveRange()
|
|
722
|
+
* .getSheetName()
|
|
723
|
+
* ```
|
|
732
724
|
*/
|
|
733
725
|
getSheetName() {
|
|
734
726
|
return this._worksheet.getName();
|
|
735
727
|
}
|
|
728
|
+
/**
|
|
729
|
+
* Gets the ID of the worksheet
|
|
730
|
+
* @returns {string} The ID of the worksheet
|
|
731
|
+
* @example
|
|
732
|
+
* ```ts
|
|
733
|
+
* univerAPI.getActiveWorkbook()
|
|
734
|
+
* .getActiveSheet()
|
|
735
|
+
* .getActiveRange()
|
|
736
|
+
* .getSheetId()
|
|
737
|
+
* ```
|
|
738
|
+
*/
|
|
739
|
+
getSheetId() {
|
|
740
|
+
return this._worksheet.getSheetId();
|
|
741
|
+
}
|
|
736
742
|
/**
|
|
737
743
|
* Gets the area where the statement is applied
|
|
738
|
-
*
|
|
739
|
-
* @
|
|
744
|
+
* @returns {IRange} The area where the statement is applied
|
|
745
|
+
* @example
|
|
746
|
+
* ```ts
|
|
747
|
+
* univerAPI.getActiveWorkbook()
|
|
748
|
+
* .getActiveSheet()
|
|
749
|
+
* .getActiveRange()
|
|
750
|
+
* .getRange()
|
|
751
|
+
* ```
|
|
740
752
|
*/
|
|
741
753
|
getRange() {
|
|
742
754
|
return this._range;
|
|
743
755
|
}
|
|
744
756
|
/**
|
|
745
757
|
* Gets the starting row number of the applied area
|
|
746
|
-
*
|
|
747
|
-
* @
|
|
758
|
+
* @returns {number} The starting row number of the area
|
|
759
|
+
* @example
|
|
760
|
+
* ```ts
|
|
761
|
+
* univerAPI.getActiveWorkbook()
|
|
762
|
+
* .getActiveSheet()
|
|
763
|
+
* .getActiveRange()
|
|
764
|
+
* .getRow()
|
|
765
|
+
* ```
|
|
748
766
|
*/
|
|
749
767
|
getRow() {
|
|
750
768
|
return this._range.startRow;
|
|
751
769
|
}
|
|
752
770
|
/**
|
|
753
771
|
* Gets the starting column number of the applied area
|
|
754
|
-
*
|
|
755
|
-
* @
|
|
772
|
+
* @returns {number} The starting column number of the area
|
|
773
|
+
* @example
|
|
774
|
+
* ```ts
|
|
775
|
+
* univerAPI.getActiveWorkbook()
|
|
776
|
+
* .getActiveSheet()
|
|
777
|
+
* .getActiveRange()
|
|
778
|
+
* .getColumn()
|
|
779
|
+
* ```
|
|
756
780
|
*/
|
|
757
781
|
getColumn() {
|
|
758
782
|
return this._range.startColumn;
|
|
759
783
|
}
|
|
760
784
|
/**
|
|
761
785
|
* Gets the width of the applied area
|
|
762
|
-
*
|
|
763
|
-
* @
|
|
786
|
+
* @returns {number} The width of the area
|
|
787
|
+
* @example
|
|
788
|
+
* ```ts
|
|
789
|
+
* univerAPI.getActiveWorkbook()
|
|
790
|
+
* .getActiveSheet()
|
|
791
|
+
* .getActiveRange()
|
|
792
|
+
* .getWidth()
|
|
793
|
+
* ```
|
|
764
794
|
*/
|
|
765
795
|
getWidth() {
|
|
766
796
|
return this._range.endColumn - this._range.startColumn + 1;
|
|
767
797
|
}
|
|
768
798
|
/**
|
|
769
799
|
* Gets the height of the applied area
|
|
770
|
-
*
|
|
771
|
-
* @
|
|
800
|
+
* @returns {number} The height of the area
|
|
801
|
+
* @example
|
|
802
|
+
* ```ts
|
|
803
|
+
* univerAPI.getActiveWorkbook()
|
|
804
|
+
* .getActiveSheet()
|
|
805
|
+
* .getActiveRange()
|
|
806
|
+
* .getHeight()
|
|
807
|
+
* ```
|
|
772
808
|
*/
|
|
773
809
|
getHeight() {
|
|
774
810
|
return this._range.endRow - this._range.startRow + 1;
|
|
775
811
|
}
|
|
776
|
-
/**
|
|
777
|
-
* Return first cell model data in this range
|
|
778
|
-
* @returns The cell model data
|
|
779
|
-
*/
|
|
780
|
-
getCellData() {
|
|
781
|
-
var o;
|
|
782
|
-
return (o = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) != null ? o : null;
|
|
783
|
-
}
|
|
784
812
|
/**
|
|
785
813
|
* Return range whether this range is merged
|
|
786
|
-
* @returns if true is merged
|
|
814
|
+
* @returns {boolean} if true is merged
|
|
815
|
+
* @example
|
|
816
|
+
* ```ts
|
|
817
|
+
* univerAPI.getActiveWorkbook()
|
|
818
|
+
* .getActiveSheet()
|
|
819
|
+
* .getActiveRange()
|
|
820
|
+
* .isMerged()
|
|
821
|
+
* ```
|
|
787
822
|
*/
|
|
788
823
|
isMerged() {
|
|
789
|
-
const { startColumn:
|
|
790
|
-
return this._worksheet.getMergedCellRange(e,
|
|
824
|
+
const { startColumn: s, startRow: e, endColumn: t, endRow: n } = this._range;
|
|
825
|
+
return this._worksheet.getMergedCellRange(e, s, n, t).some((o) => N.equals(o, this._range));
|
|
791
826
|
}
|
|
792
827
|
/**
|
|
793
828
|
* Return first cell style data in this range
|
|
794
|
-
* @returns The cell style data
|
|
829
|
+
* @returns {IStyleData | null} The cell style data
|
|
830
|
+
* @example
|
|
831
|
+
* ```ts
|
|
832
|
+
* univerAPI.getActiveWorkbook()
|
|
833
|
+
* .getActiveSheet()
|
|
834
|
+
* .getActiveRange()
|
|
835
|
+
* .getCellStyleData()
|
|
836
|
+
* ```
|
|
795
837
|
*/
|
|
796
838
|
getCellStyleData() {
|
|
797
839
|
var t;
|
|
798
|
-
const
|
|
799
|
-
return
|
|
840
|
+
const s = this.getCellData(), e = this._workbook.getStyles();
|
|
841
|
+
return s && e && (t = e.getStyleByCell(s)) != null ? t : null;
|
|
800
842
|
}
|
|
801
843
|
/**
|
|
802
|
-
*
|
|
803
|
-
* @returns The value of the cell.
|
|
844
|
+
* @deprecated use `getValueAndRichTextValue` instead. This api can't return rich text value.
|
|
804
845
|
*/
|
|
805
846
|
getValue() {
|
|
806
|
-
var
|
|
807
|
-
return (e = (
|
|
847
|
+
var s, e;
|
|
848
|
+
return (e = (s = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) == null ? void 0 : s.v) != null ? e : null;
|
|
808
849
|
}
|
|
809
850
|
/**
|
|
810
|
-
*
|
|
811
|
-
* Returns a two-dimensional array of values, indexed by row, then by column.
|
|
812
|
-
* @returns A two-dimensional array of values.
|
|
851
|
+
* @deprecated use `getValueAndRichTextValues` instead. This api can't return rich text value.
|
|
813
852
|
*/
|
|
814
853
|
getValues() {
|
|
815
|
-
var
|
|
816
|
-
const { startRow:
|
|
817
|
-
for (let a =
|
|
854
|
+
var o, i;
|
|
855
|
+
const { startRow: s, endRow: e, startColumn: t, endColumn: n } = this._range, r = [];
|
|
856
|
+
for (let a = s; a <= e; a++) {
|
|
818
857
|
const h = [];
|
|
819
858
|
for (let c = t; c <= n; c++)
|
|
820
|
-
h.push((i = (
|
|
821
|
-
|
|
859
|
+
h.push((i = (o = this._worksheet.getCell(a, c)) == null ? void 0 : o.v) != null ? i : null);
|
|
860
|
+
r.push(h);
|
|
822
861
|
}
|
|
823
|
-
return
|
|
862
|
+
return r;
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* Return first cell model data in this range
|
|
866
|
+
* @returns {ICellData | null} The cell model data
|
|
867
|
+
* @example
|
|
868
|
+
* ```ts
|
|
869
|
+
* univerAPI.getActiveWorkbook()
|
|
870
|
+
* .getActiveSheet()
|
|
871
|
+
* .getActiveRange()
|
|
872
|
+
* .getCellData()
|
|
873
|
+
* ```
|
|
874
|
+
*/
|
|
875
|
+
getCellData() {
|
|
876
|
+
var s;
|
|
877
|
+
return (s = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) != null ? s : null;
|
|
824
878
|
}
|
|
825
879
|
/**
|
|
826
880
|
* Returns the cell data for the cells in the range.
|
|
827
|
-
* @returns A two-dimensional array of cell data.
|
|
881
|
+
* @returns {Nullable<ICellData>[][]} A two-dimensional array of cell data.
|
|
882
|
+
* @example
|
|
883
|
+
* ```ts
|
|
884
|
+
* univerAPI.getActiveWorkbook()
|
|
885
|
+
* .getActiveSheet()
|
|
886
|
+
* .getActiveRange()
|
|
887
|
+
* .getCellDatas()
|
|
888
|
+
* ```
|
|
828
889
|
*/
|
|
829
|
-
|
|
830
|
-
const { startRow:
|
|
831
|
-
for (let
|
|
890
|
+
getCellDatas() {
|
|
891
|
+
const { startRow: s, endRow: e, startColumn: t, endColumn: n } = this._range, r = [];
|
|
892
|
+
for (let o = s; o <= e; o++) {
|
|
832
893
|
const i = [];
|
|
833
894
|
for (let a = t; a <= n; a++)
|
|
834
|
-
i.push(this._worksheet.getCellRaw(
|
|
835
|
-
|
|
895
|
+
i.push(this._worksheet.getCellRaw(o, a));
|
|
896
|
+
r.push(i);
|
|
836
897
|
}
|
|
837
|
-
return
|
|
898
|
+
return r;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* @deprecated use `getCellDatas` instead.
|
|
902
|
+
*/
|
|
903
|
+
getCellDataGrid() {
|
|
904
|
+
return this.getCellDatas();
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* Returns the rich text value for the cell at the start of this range.
|
|
908
|
+
* @returns {Nullable<RichTextValue>} The rich text value
|
|
909
|
+
* @example
|
|
910
|
+
* ```ts
|
|
911
|
+
* univerAPI.getActiveWorkbook()
|
|
912
|
+
* .getActiveSheet()
|
|
913
|
+
* .getActiveRange()
|
|
914
|
+
* .getRichTextValue()
|
|
915
|
+
* ```
|
|
916
|
+
*/
|
|
917
|
+
getRichTextValue() {
|
|
918
|
+
const s = this.getCellData();
|
|
919
|
+
return s != null && s.p ? new p(s.p) : null;
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Returns the rich text value for the cells in the range.
|
|
923
|
+
* @returns {Nullable<RichTextValue>[][]} A two-dimensional array of RichTextValue objects.
|
|
924
|
+
* @example
|
|
925
|
+
* ```ts
|
|
926
|
+
* univerAPI.getActiveWorkbook()
|
|
927
|
+
* .getActiveSheet()
|
|
928
|
+
* .getActiveRange()
|
|
929
|
+
* .getRichTextValues()
|
|
930
|
+
* ```
|
|
931
|
+
*/
|
|
932
|
+
getRichTextValues() {
|
|
933
|
+
return this.getCellDataGrid().map((e) => e.map((t) => t != null && t.p ? new p(t.p) : null));
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* Returns the value and rich text value for the cell at the start of this range.
|
|
937
|
+
* @returns {Nullable<CellValue | RichTextValue>} The value and rich text value
|
|
938
|
+
* @example
|
|
939
|
+
* ```ts
|
|
940
|
+
* univerAPI.getActiveWorkbook()
|
|
941
|
+
* .getActiveSheet()
|
|
942
|
+
* .getActiveRange()
|
|
943
|
+
* .getValueAndRichTextValue()
|
|
944
|
+
* ```
|
|
945
|
+
*/
|
|
946
|
+
getValueAndRichTextValue() {
|
|
947
|
+
const s = this.getCellData();
|
|
948
|
+
return s != null && s.p ? new p(s.p) : s == null ? void 0 : s.v;
|
|
949
|
+
}
|
|
950
|
+
/**
|
|
951
|
+
* Returns the value and rich text value for the cells in the range.
|
|
952
|
+
* @returns {Nullable<CellValue | RichTextValue>[][]} A two-dimensional array of value and rich text value
|
|
953
|
+
* @example
|
|
954
|
+
* ```ts
|
|
955
|
+
* univerAPI.getActiveWorkbook()
|
|
956
|
+
* .getActiveSheet()
|
|
957
|
+
* .getActiveRange()
|
|
958
|
+
* .getValueAndRichTextValues()
|
|
959
|
+
* ```
|
|
960
|
+
*/
|
|
961
|
+
getValueAndRichTextValues() {
|
|
962
|
+
return this.getCellDatas().map((e) => e.map((t) => t != null && t.p ? new p(t.p) : t == null ? void 0 : t.v));
|
|
838
963
|
}
|
|
839
964
|
/**
|
|
840
965
|
* Returns the formulas (A1 notation) for the cells in the range. Entries in the 2D array are empty strings for cells with no formula.
|
|
841
|
-
* @returns A two-dimensional array of formulas in string format.
|
|
966
|
+
* @returns {string[][]} A two-dimensional array of formulas in string format.
|
|
967
|
+
* @example
|
|
968
|
+
* ```ts
|
|
969
|
+
* univerAPI.getActiveWorkbook()
|
|
970
|
+
* .getActiveSheet()
|
|
971
|
+
* .getActiveRange()
|
|
972
|
+
* .getFormulas()
|
|
973
|
+
* ```
|
|
842
974
|
*/
|
|
843
975
|
getFormulas() {
|
|
844
|
-
const
|
|
976
|
+
const s = [], { startRow: e, endRow: t, startColumn: n, endColumn: r } = this._range, o = this._worksheet.getSheetId(), i = this._workbook.getUnitId();
|
|
845
977
|
for (let a = e; a <= t; a++) {
|
|
846
978
|
const h = [];
|
|
847
|
-
for (let c = n; c <=
|
|
848
|
-
const d = this._formulaDataModel.getFormulaStringByCell(a, c,
|
|
979
|
+
for (let c = n; c <= r; c++) {
|
|
980
|
+
const d = this._formulaDataModel.getFormulaStringByCell(a, c, o, i);
|
|
849
981
|
h.push(d || "");
|
|
850
982
|
}
|
|
851
|
-
|
|
983
|
+
s.push(h);
|
|
852
984
|
}
|
|
853
|
-
return
|
|
985
|
+
return s;
|
|
854
986
|
}
|
|
987
|
+
/**
|
|
988
|
+
* Returns true if the cell wrap is enabled
|
|
989
|
+
* @returns {boolean} True if the cell wrap is enabled
|
|
990
|
+
* @example
|
|
991
|
+
* ```ts
|
|
992
|
+
* univerAPI.getActiveWorkbook()
|
|
993
|
+
* .getActiveSheet()
|
|
994
|
+
* .getActiveRange()
|
|
995
|
+
* .getWrap()
|
|
996
|
+
* ```
|
|
997
|
+
*/
|
|
855
998
|
getWrap() {
|
|
856
|
-
return this._worksheet.getRange(this._range).getWrap() ===
|
|
999
|
+
return this._worksheet.getRange(this._range).getWrap() === m.TRUE;
|
|
857
1000
|
}
|
|
1001
|
+
/**
|
|
1002
|
+
* Returns the text wrapping strategy for the top left cell of the range.
|
|
1003
|
+
* @returns {WrapStrategy} The text wrapping strategy
|
|
1004
|
+
* @example
|
|
1005
|
+
* ```ts
|
|
1006
|
+
* univerAPI.getActiveWorkbook()
|
|
1007
|
+
* .getActiveSheet()
|
|
1008
|
+
* .getActiveRange()
|
|
1009
|
+
* .getWrapStrategy()
|
|
1010
|
+
* ```
|
|
1011
|
+
*/
|
|
858
1012
|
getWrapStrategy() {
|
|
859
1013
|
return this._worksheet.getRange(this._range).getWrapStrategy();
|
|
860
1014
|
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Returns the horizontal alignment for the top left cell of the range.
|
|
1017
|
+
* @returns {string} The horizontal alignment
|
|
1018
|
+
* @example
|
|
1019
|
+
* ```ts
|
|
1020
|
+
* univerAPI.getActiveWorkbook()
|
|
1021
|
+
* .getActiveSheet()
|
|
1022
|
+
* .getActiveRange()
|
|
1023
|
+
* .getHorizontalAlignment()
|
|
1024
|
+
* ```
|
|
1025
|
+
*/
|
|
861
1026
|
getHorizontalAlignment() {
|
|
862
|
-
return
|
|
1027
|
+
return Ht(this._worksheet.getRange(this._range).getHorizontalAlignment());
|
|
863
1028
|
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Returns the vertical alignment for the top left cell of the range.
|
|
1031
|
+
* @returns {string} The vertical alignment
|
|
1032
|
+
* @example
|
|
1033
|
+
* ```ts
|
|
1034
|
+
* univerAPI.getActiveWorkbook()
|
|
1035
|
+
* .getActiveSheet()
|
|
1036
|
+
* .getActiveRange()
|
|
1037
|
+
* .getVerticalAlignment()
|
|
1038
|
+
* ```
|
|
1039
|
+
*/
|
|
864
1040
|
getVerticalAlignment() {
|
|
865
|
-
return
|
|
1041
|
+
return qt(this._worksheet.getRange(this._range).getVerticalAlignment());
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Set custom meta data for first cell in current range.
|
|
1045
|
+
* @param {CustomData} data The custom meta data
|
|
1046
|
+
* @returns {FRange} This range, for chaining
|
|
1047
|
+
* ```ts
|
|
1048
|
+
* univerAPI.getActiveWorkbook()
|
|
1049
|
+
* .getActiveSheet()
|
|
1050
|
+
* .getActiveRange()
|
|
1051
|
+
* .setCustomMetaData({ key: 'value' });
|
|
1052
|
+
* ```
|
|
1053
|
+
*/
|
|
1054
|
+
setCustomMetaData(s) {
|
|
1055
|
+
return this.setValue({
|
|
1056
|
+
custom: s
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Set custom meta data for current range.
|
|
1061
|
+
* @param {CustomData[][]} datas The custom meta data
|
|
1062
|
+
* @returns {FRange} This range, for chaining
|
|
1063
|
+
* ```ts
|
|
1064
|
+
* univerAPI.getActiveWorkbook()
|
|
1065
|
+
* .getActiveSheet()
|
|
1066
|
+
* .getActiveRange()
|
|
1067
|
+
* .setCustomMetaDatas([[{ key: 'value' }]]);
|
|
1068
|
+
* ```
|
|
1069
|
+
*/
|
|
1070
|
+
setCustomMetaDatas(s) {
|
|
1071
|
+
return this.setValues(s.map((e) => e.map((t) => ({ custom: t }))));
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Returns the custom meta data for the cell at the start of this range.
|
|
1075
|
+
* @returns {CustomData | null} The custom meta data
|
|
1076
|
+
* @example
|
|
1077
|
+
* ```
|
|
1078
|
+
* univerAPI.getActiveWorkbook()
|
|
1079
|
+
* .getActiveSheet()
|
|
1080
|
+
* .getActiveRange()
|
|
1081
|
+
* .getCustomMetaData()
|
|
1082
|
+
* ```
|
|
1083
|
+
*/
|
|
1084
|
+
getCustomMetaData() {
|
|
1085
|
+
var e;
|
|
1086
|
+
const s = this.getCellData();
|
|
1087
|
+
return (e = s == null ? void 0 : s.custom) != null ? e : null;
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Returns the custom meta data for the cells in the range.
|
|
1091
|
+
* @returns {CustomData[][]} A two-dimensional array of custom meta data
|
|
1092
|
+
* @example
|
|
1093
|
+
* ```
|
|
1094
|
+
* univerAPI.getActiveWorkbook()
|
|
1095
|
+
* .getActiveSheet()
|
|
1096
|
+
* .getActiveRange()
|
|
1097
|
+
* .getCustomMetaDatas()
|
|
1098
|
+
* ```
|
|
1099
|
+
*/
|
|
1100
|
+
getCustomMetaDatas() {
|
|
1101
|
+
return this.getCellDataGrid().map((e) => e.map((t) => {
|
|
1102
|
+
var n;
|
|
1103
|
+
return (n = t == null ? void 0 : t.custom) != null ? n : null;
|
|
1104
|
+
}));
|
|
866
1105
|
}
|
|
867
1106
|
// #region editing
|
|
868
1107
|
/**
|
|
869
1108
|
* Set background color for current range.
|
|
870
|
-
* @param
|
|
1109
|
+
* @param {string} color The background color
|
|
1110
|
+
* @returns {FRange} This range, for chaining
|
|
871
1111
|
* @example
|
|
872
|
-
* ```
|
|
873
|
-
* univerAPI.getActiveWorkbook()
|
|
1112
|
+
* ```ts
|
|
1113
|
+
* univerAPI.getActiveWorkbook()
|
|
1114
|
+
* .getActiveSheet()
|
|
1115
|
+
* .getActiveRange()
|
|
1116
|
+
* .setBackgroundColor('red')
|
|
874
1117
|
* ```
|
|
875
1118
|
*/
|
|
876
|
-
setBackgroundColor(
|
|
877
|
-
return this._commandService.syncExecuteCommand(
|
|
1119
|
+
setBackgroundColor(s) {
|
|
1120
|
+
return this._commandService.syncExecuteCommand(f.id, {
|
|
878
1121
|
unitId: this._workbook.getUnitId(),
|
|
879
1122
|
subUnitId: this._worksheet.getSheetId(),
|
|
880
1123
|
range: this._range,
|
|
881
1124
|
style: {
|
|
882
1125
|
type: "bg",
|
|
883
1126
|
value: {
|
|
884
|
-
rgb:
|
|
1127
|
+
rgb: s
|
|
885
1128
|
}
|
|
886
1129
|
}
|
|
887
1130
|
}), this;
|
|
888
1131
|
}
|
|
889
1132
|
/**
|
|
890
1133
|
* Set background color for current range.
|
|
1134
|
+
* @param {string} color The background color
|
|
1135
|
+
* @returns {FRange} This range, for chaining
|
|
891
1136
|
* @example
|
|
892
|
-
* ```
|
|
1137
|
+
* ```typescript
|
|
893
1138
|
* univerAPI.getActiveWorkbook().getActiveSheet().getActiveRange().setBackground('red')
|
|
894
1139
|
* ```
|
|
895
|
-
* @param color {string}
|
|
896
1140
|
*/
|
|
897
|
-
setBackground(
|
|
898
|
-
return this.setBackgroundColor(
|
|
1141
|
+
setBackground(s) {
|
|
1142
|
+
return this.setBackgroundColor(s), this;
|
|
899
1143
|
}
|
|
900
1144
|
/**
|
|
901
|
-
*
|
|
902
|
-
* @param value
|
|
1145
|
+
* Set new value for current cell, first cell in this range.
|
|
1146
|
+
* @param {CellValue | ICellData} value The value can be a number, string, boolean, or standard cell format. If it begins with `=`, it is interpreted as a formula. The value is tiled to all cells in the range.
|
|
1147
|
+
* @returns {FRange} This range, for chaining
|
|
1148
|
+
* ```ts
|
|
1149
|
+
* univerAPI.getActiveWorkbook()
|
|
1150
|
+
* .getActiveSheet()
|
|
1151
|
+
* .getActiveRange()
|
|
1152
|
+
* .setValue(1);
|
|
1153
|
+
* ```
|
|
903
1154
|
*/
|
|
904
|
-
setValue(
|
|
905
|
-
const e =
|
|
1155
|
+
setValue(s) {
|
|
1156
|
+
const e = V(s);
|
|
906
1157
|
if (!e)
|
|
907
1158
|
throw new Error("Invalid value");
|
|
908
|
-
return this._commandService.syncExecuteCommand(
|
|
1159
|
+
return this._commandService.syncExecuteCommand(P.id, {
|
|
909
1160
|
unitId: this._workbook.getUnitId(),
|
|
910
1161
|
subUnitId: this._worksheet.getSheetId(),
|
|
911
1162
|
range: this._range,
|
|
912
1163
|
value: e
|
|
913
1164
|
}), this;
|
|
914
1165
|
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Set new value for current cell, first cell in this range.
|
|
1168
|
+
* @param {CellValue | ICellData} value The value can be a number, string, boolean, or standard cell format. If it begins with `=`, it is interpreted as a formula. The value is tiled to all cells in the range.
|
|
1169
|
+
* @returns {FRange} This range, for chaining
|
|
1170
|
+
* ```ts
|
|
1171
|
+
* univerAPI.getActiveWorkbook()
|
|
1172
|
+
* .getActiveSheet()
|
|
1173
|
+
* .getActiveRange()
|
|
1174
|
+
* .setValueForCell(1);
|
|
1175
|
+
* ```
|
|
1176
|
+
*/
|
|
1177
|
+
setValueForCell(s) {
|
|
1178
|
+
const e = V(s);
|
|
1179
|
+
if (!e)
|
|
1180
|
+
throw new Error("Invalid value");
|
|
1181
|
+
return this._commandService.syncExecuteCommand(P.id, {
|
|
1182
|
+
unitId: this._workbook.getUnitId(),
|
|
1183
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
1184
|
+
range: {
|
|
1185
|
+
startColumn: this._range.startColumn,
|
|
1186
|
+
startRow: this._range.startRow,
|
|
1187
|
+
endColumn: this._range.endColumn,
|
|
1188
|
+
endRow: this._range.endRow
|
|
1189
|
+
},
|
|
1190
|
+
value: e
|
|
1191
|
+
}), this;
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Set the rich text value for the cell at the start of this range.
|
|
1195
|
+
* @param {RichTextValue | IDocumentData} value The rich text value
|
|
1196
|
+
* @returns {FRange} The range
|
|
1197
|
+
* @example
|
|
1198
|
+
* ```
|
|
1199
|
+
* univerAPI.getActiveWorkbook()
|
|
1200
|
+
* .getActiveSheet()
|
|
1201
|
+
* .getActiveRange()
|
|
1202
|
+
* .setRichTextValueForCell(new RichTextValue().insertText('Hello'));
|
|
1203
|
+
* ```
|
|
1204
|
+
*/
|
|
1205
|
+
setRichTextValueForCell(s) {
|
|
1206
|
+
const e = s instanceof p ? s.getData() : s, t = {
|
|
1207
|
+
unitId: this._workbook.getUnitId(),
|
|
1208
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
1209
|
+
range: {
|
|
1210
|
+
startColumn: this._range.startColumn,
|
|
1211
|
+
startRow: this._range.startRow,
|
|
1212
|
+
endColumn: this._range.endColumn,
|
|
1213
|
+
endRow: this._range.endRow
|
|
1214
|
+
},
|
|
1215
|
+
value: { p: e }
|
|
1216
|
+
};
|
|
1217
|
+
return this._commandService.syncExecuteCommand(P.id, t), this;
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* Set the rich text value for the cells in the range.
|
|
1221
|
+
* @param {RichTextValue[][]} values The rich text value
|
|
1222
|
+
* @returns {FRange} The range
|
|
1223
|
+
* @example
|
|
1224
|
+
* ```ts
|
|
1225
|
+
* univerAPI
|
|
1226
|
+
* .getActiveWorkbook()
|
|
1227
|
+
* .getActiveSheet()
|
|
1228
|
+
* .getActiveRange()
|
|
1229
|
+
* .setRichTextValues([[new RichTextValue().insertText('Hello')]]);
|
|
1230
|
+
* ```
|
|
1231
|
+
*/
|
|
1232
|
+
setRichTextValues(s) {
|
|
1233
|
+
const e = s.map((r) => r.map((o) => o && { p: o instanceof p ? o.getData() : o })), t = Ie(e, this._range), n = {
|
|
1234
|
+
unitId: this._workbook.getUnitId(),
|
|
1235
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
1236
|
+
range: this._range,
|
|
1237
|
+
value: t
|
|
1238
|
+
};
|
|
1239
|
+
return this._commandService.syncExecuteCommand(P.id, n), this;
|
|
1240
|
+
}
|
|
915
1241
|
/**
|
|
916
1242
|
* Set the cell wrap of the given range.
|
|
917
1243
|
* Cells with wrap enabled (the default) resize to display their full content. Cells with wrap disabled display as much as possible in the cell without resizing or running to multiple lines.
|
|
1244
|
+
* @param {boolean} isWrapEnabled Whether to enable wrap
|
|
1245
|
+
* @returns {FRange} this range, for chaining
|
|
1246
|
+
* @example
|
|
1247
|
+
* ```ts
|
|
1248
|
+
* univerAPI.getActiveWorkbook()
|
|
1249
|
+
* .getActiveSheet()
|
|
1250
|
+
* .getActiveRange()
|
|
1251
|
+
* .setWrap(true);
|
|
1252
|
+
* ```
|
|
918
1253
|
*/
|
|
919
|
-
setWrap(
|
|
920
|
-
return this._commandService.syncExecuteCommand(
|
|
1254
|
+
setWrap(s) {
|
|
1255
|
+
return this._commandService.syncExecuteCommand(he.id, {
|
|
921
1256
|
unitId: this._workbook.getUnitId(),
|
|
922
1257
|
subUnitId: this._worksheet.getSheetId(),
|
|
923
1258
|
range: this._range,
|
|
924
|
-
value:
|
|
1259
|
+
value: s ? oe.WRAP : oe.UNSPECIFIED
|
|
925
1260
|
}), this;
|
|
926
1261
|
}
|
|
927
1262
|
/**
|
|
928
1263
|
* Sets the text wrapping strategy for the cells in the range.
|
|
1264
|
+
* @param {WrapStrategy} strategy The text wrapping strategy
|
|
1265
|
+
* @returns {FRange} this range, for chaining
|
|
1266
|
+
* @example
|
|
1267
|
+
* ```ts
|
|
1268
|
+
* univerAPI.getActiveWorkbook()
|
|
1269
|
+
* .getActiveSheet()
|
|
1270
|
+
* .getActiveRange()
|
|
1271
|
+
* .setWrapStrategy(WrapStrategy.WRAP);
|
|
1272
|
+
* ```
|
|
929
1273
|
*/
|
|
930
|
-
setWrapStrategy(
|
|
931
|
-
return this._commandService.syncExecuteCommand(
|
|
1274
|
+
setWrapStrategy(s) {
|
|
1275
|
+
return this._commandService.syncExecuteCommand(he.id, {
|
|
932
1276
|
unitId: this._workbook.getUnitId(),
|
|
933
1277
|
subUnitId: this._worksheet.getSheetId(),
|
|
934
1278
|
range: this._range,
|
|
935
|
-
value:
|
|
1279
|
+
value: s
|
|
936
1280
|
}), this;
|
|
937
1281
|
}
|
|
938
1282
|
/**
|
|
939
1283
|
* Set the vertical (top to bottom) alignment for the given range (top/middle/bottom).
|
|
1284
|
+
* @param {"top" | "middle" | "bottom"} alignment The vertical alignment
|
|
1285
|
+
* @returns {FRange} this range, for chaining
|
|
1286
|
+
* @example
|
|
1287
|
+
* ```ts
|
|
1288
|
+
* univerAPI.getActiveWorkbook()
|
|
1289
|
+
* .getActiveSheet()
|
|
1290
|
+
* .getActiveRange()
|
|
1291
|
+
* .setVerticalAlignment('top');
|
|
1292
|
+
* ```
|
|
940
1293
|
*/
|
|
941
|
-
setVerticalAlignment(
|
|
942
|
-
return this._commandService.syncExecuteCommand(
|
|
1294
|
+
setVerticalAlignment(s) {
|
|
1295
|
+
return this._commandService.syncExecuteCommand(ot.id, {
|
|
943
1296
|
unitId: this._workbook.getUnitId(),
|
|
944
1297
|
subUnitId: this._worksheet.getSheetId(),
|
|
945
1298
|
range: this._range,
|
|
946
|
-
value:
|
|
1299
|
+
value: Gt(s)
|
|
947
1300
|
}), this;
|
|
948
1301
|
}
|
|
949
1302
|
/**
|
|
950
1303
|
* Set the horizontal (left to right) alignment for the given range (left/center/right).
|
|
1304
|
+
* @param {"left" | "center" | "normal"} alignment The horizontal alignment
|
|
1305
|
+
* @returns {FRange} this range, for chaining
|
|
1306
|
+
* @example
|
|
1307
|
+
* ```ts
|
|
1308
|
+
* univerAPI.getActiveWorkbook()
|
|
1309
|
+
* .getActiveSheet()
|
|
1310
|
+
* .getActiveRange()
|
|
1311
|
+
* .setHorizontalAlignment('left');
|
|
1312
|
+
* ```
|
|
951
1313
|
*/
|
|
952
|
-
setHorizontalAlignment(
|
|
953
|
-
return this._commandService.syncExecuteCommand(
|
|
1314
|
+
setHorizontalAlignment(s) {
|
|
1315
|
+
return this._commandService.syncExecuteCommand(it.id, {
|
|
954
1316
|
unitId: this._workbook.getUnitId(),
|
|
955
1317
|
subUnitId: this._worksheet.getSheetId(),
|
|
956
1318
|
range: this._range,
|
|
957
|
-
value:
|
|
1319
|
+
value: $t(s)
|
|
958
1320
|
}), this;
|
|
959
1321
|
}
|
|
960
1322
|
/**
|
|
961
1323
|
* Sets a different value for each cell in the range. The value can be a two-dimensional array or a standard range matrix (must match the dimensions of this range), consisting of numbers, strings, Boolean values or Composed of standard cell formats. If a value begins with `=`, it is interpreted as a formula.
|
|
962
|
-
* @param value
|
|
1324
|
+
* @param {CellValue[][] | IObjectMatrixPrimitiveType<CellValue> | ICellData[][] | IObjectMatrixPrimitiveType<ICellData>} value The value can be a two-dimensional array or a standard range matrix (must match the dimensions of this range), consisting of numbers, strings, Boolean values or Composed of standard cell formats.
|
|
1325
|
+
* @returns {FRange} This range, for chaining
|
|
1326
|
+
* @example
|
|
1327
|
+
* ```ts
|
|
1328
|
+
* univerAPI.getActiveWorkbook()
|
|
1329
|
+
* .getActiveSheet()
|
|
1330
|
+
* .getActiveRange()
|
|
1331
|
+
* .setValues([[1, 2], [3, 4]]);
|
|
1332
|
+
* ```
|
|
963
1333
|
*/
|
|
964
|
-
setValues(
|
|
965
|
-
const e =
|
|
966
|
-
return this._commandService.syncExecuteCommand(
|
|
1334
|
+
setValues(s) {
|
|
1335
|
+
const e = Ie(s, this._range);
|
|
1336
|
+
return this._commandService.syncExecuteCommand(P.id, {
|
|
967
1337
|
unitId: this._workbook.getUnitId(),
|
|
968
1338
|
subUnitId: this._worksheet.getSheetId(),
|
|
969
1339
|
range: this._range,
|
|
@@ -972,15 +1342,23 @@ let k = class extends X {
|
|
|
972
1342
|
}
|
|
973
1343
|
/**
|
|
974
1344
|
* Sets the font weight for the given range (normal/bold),
|
|
975
|
-
* @param fontWeight The font weight, either 'normal' or 'bold'; a null value resets the font weight.
|
|
1345
|
+
* @param {FontWeight|null} fontWeight The font weight, either 'normal' or 'bold'; a null value resets the font weight.
|
|
1346
|
+
* @returns {FRange} This range, for chaining
|
|
1347
|
+
* @example
|
|
1348
|
+
* ```ts
|
|
1349
|
+
* univerAPI.getActiveWorkbook()
|
|
1350
|
+
* .getActiveSheet()
|
|
1351
|
+
* .getActiveRange()
|
|
1352
|
+
* .setFontWeight('bold');
|
|
1353
|
+
* ```
|
|
976
1354
|
*/
|
|
977
|
-
setFontWeight(
|
|
1355
|
+
setFontWeight(s) {
|
|
978
1356
|
let e;
|
|
979
|
-
if (
|
|
980
|
-
e =
|
|
981
|
-
else if (
|
|
982
|
-
e =
|
|
983
|
-
else if (
|
|
1357
|
+
if (s === "bold")
|
|
1358
|
+
e = m.TRUE;
|
|
1359
|
+
else if (s === "normal")
|
|
1360
|
+
e = m.FALSE;
|
|
1361
|
+
else if (s === null)
|
|
984
1362
|
e = null;
|
|
985
1363
|
else
|
|
986
1364
|
throw new Error("Invalid fontWeight");
|
|
@@ -993,19 +1371,27 @@ let k = class extends X {
|
|
|
993
1371
|
range: this._range,
|
|
994
1372
|
style: t
|
|
995
1373
|
};
|
|
996
|
-
return this._commandService.executeCommand(
|
|
1374
|
+
return this._commandService.executeCommand(f.id, n), this;
|
|
997
1375
|
}
|
|
998
1376
|
/**
|
|
999
1377
|
* Sets the font style for the given range ('italic' or 'normal').
|
|
1000
|
-
* @param fontStyle The font style, either 'italic' or 'normal'; a null value resets the font style.
|
|
1378
|
+
* @param {FontStyle|null} fontStyle The font style, either 'italic' or 'normal'; a null value resets the font style.
|
|
1379
|
+
* @returns {FRange} This range, for chaining
|
|
1380
|
+
* @example
|
|
1381
|
+
* ```ts
|
|
1382
|
+
* univerAPI.getActiveWorkbook()
|
|
1383
|
+
* .getActiveSheet()
|
|
1384
|
+
* .getActiveRange()
|
|
1385
|
+
* .setFontStyle('italic');
|
|
1386
|
+
* ```
|
|
1001
1387
|
*/
|
|
1002
|
-
setFontStyle(
|
|
1388
|
+
setFontStyle(s) {
|
|
1003
1389
|
let e;
|
|
1004
|
-
if (
|
|
1005
|
-
e =
|
|
1006
|
-
else if (
|
|
1007
|
-
e =
|
|
1008
|
-
else if (
|
|
1390
|
+
if (s === "italic")
|
|
1391
|
+
e = m.TRUE;
|
|
1392
|
+
else if (s === "normal")
|
|
1393
|
+
e = m.FALSE;
|
|
1394
|
+
else if (s === null)
|
|
1009
1395
|
e = null;
|
|
1010
1396
|
else
|
|
1011
1397
|
throw new Error("Invalid fontStyle");
|
|
@@ -1018,28 +1404,36 @@ let k = class extends X {
|
|
|
1018
1404
|
range: this._range,
|
|
1019
1405
|
style: t
|
|
1020
1406
|
};
|
|
1021
|
-
return this._commandService.executeCommand(
|
|
1407
|
+
return this._commandService.executeCommand(f.id, n), this;
|
|
1022
1408
|
}
|
|
1023
1409
|
/**
|
|
1024
1410
|
* Sets the font line style of the given range ('underline', 'line-through', or 'none').
|
|
1025
|
-
* @param fontLine The font line style, either 'underline', 'line-through', or 'none'; a null value resets the font line style.
|
|
1411
|
+
* @param {FontLine|null} fontLine The font line style, either 'underline', 'line-through', or 'none'; a null value resets the font line style.
|
|
1412
|
+
* @returns {FRange} This range, for chaining
|
|
1413
|
+
* @example
|
|
1414
|
+
* ```ts
|
|
1415
|
+
* univerAPI.getActiveWorkbook()
|
|
1416
|
+
* .getActiveSheet()
|
|
1417
|
+
* .getActiveRange()
|
|
1418
|
+
* .setFontLine('underline');
|
|
1419
|
+
* ```
|
|
1026
1420
|
*/
|
|
1027
|
-
setFontLine(
|
|
1028
|
-
if (
|
|
1421
|
+
setFontLine(s) {
|
|
1422
|
+
if (s === "underline")
|
|
1029
1423
|
this._setFontUnderline({
|
|
1030
|
-
s:
|
|
1424
|
+
s: m.TRUE
|
|
1031
1425
|
});
|
|
1032
|
-
else if (
|
|
1426
|
+
else if (s === "line-through")
|
|
1033
1427
|
this._setFontStrikethrough({
|
|
1034
|
-
s:
|
|
1428
|
+
s: m.TRUE
|
|
1035
1429
|
});
|
|
1036
|
-
else if (
|
|
1430
|
+
else if (s === "none")
|
|
1037
1431
|
this._setFontUnderline({
|
|
1038
|
-
s:
|
|
1432
|
+
s: m.FALSE
|
|
1039
1433
|
}), this._setFontStrikethrough({
|
|
1040
|
-
s:
|
|
1434
|
+
s: m.FALSE
|
|
1041
1435
|
});
|
|
1042
|
-
else if (
|
|
1436
|
+
else if (s === null)
|
|
1043
1437
|
this._setFontUnderline(null), this._setFontStrikethrough(null);
|
|
1044
1438
|
else
|
|
1045
1439
|
throw new Error("Invalid fontLine");
|
|
@@ -1047,136 +1441,215 @@ let k = class extends X {
|
|
|
1047
1441
|
}
|
|
1048
1442
|
/**
|
|
1049
1443
|
* Sets the font underline style of the given ITextDecoration
|
|
1444
|
+
* @param {ITextDecoration|null} value The font underline style of the given ITextDecoration; a null value resets the font underline style
|
|
1445
|
+
* @returns {void}
|
|
1446
|
+
* @example
|
|
1447
|
+
* ```ts
|
|
1448
|
+
* univerAPI.getActiveWorkbook()
|
|
1449
|
+
* .getActiveSheet()
|
|
1450
|
+
* .getActiveRange()
|
|
1451
|
+
* .setFontLine('underline');
|
|
1452
|
+
* ```
|
|
1050
1453
|
*/
|
|
1051
|
-
_setFontUnderline(
|
|
1454
|
+
_setFontUnderline(s) {
|
|
1052
1455
|
const e = {
|
|
1053
1456
|
type: "ul",
|
|
1054
|
-
value:
|
|
1457
|
+
value: s
|
|
1055
1458
|
}, t = {
|
|
1056
1459
|
unitId: this._workbook.getUnitId(),
|
|
1057
1460
|
subUnitId: this._worksheet.getSheetId(),
|
|
1058
1461
|
range: this._range,
|
|
1059
1462
|
style: e
|
|
1060
1463
|
};
|
|
1061
|
-
this._commandService.executeCommand(
|
|
1464
|
+
this._commandService.executeCommand(f.id, t);
|
|
1062
1465
|
}
|
|
1063
1466
|
/**
|
|
1064
1467
|
* Sets the font strikethrough style of the given ITextDecoration
|
|
1468
|
+
* @param {ITextDecoration|null} value The font strikethrough style of the given ITextDecoration; a null value resets the font strikethrough style
|
|
1469
|
+
* @returns {void}
|
|
1065
1470
|
*/
|
|
1066
|
-
_setFontStrikethrough(
|
|
1471
|
+
_setFontStrikethrough(s) {
|
|
1067
1472
|
const e = {
|
|
1068
1473
|
type: "st",
|
|
1069
|
-
value:
|
|
1474
|
+
value: s
|
|
1070
1475
|
}, t = {
|
|
1071
1476
|
unitId: this._workbook.getUnitId(),
|
|
1072
1477
|
subUnitId: this._worksheet.getSheetId(),
|
|
1073
1478
|
range: this._range,
|
|
1074
1479
|
style: e
|
|
1075
1480
|
};
|
|
1076
|
-
this._commandService.executeCommand(
|
|
1481
|
+
this._commandService.executeCommand(f.id, t);
|
|
1077
1482
|
}
|
|
1078
1483
|
/**
|
|
1079
1484
|
* Sets the font family, such as "Arial" or "Helvetica".
|
|
1080
|
-
* @param fontFamily The font family to set; a null value resets the font family.
|
|
1485
|
+
* @param {string|null} fontFamily The font family to set; a null value resets the font family.
|
|
1486
|
+
* @returns {FRange} This range, for chaining
|
|
1487
|
+
* @example
|
|
1488
|
+
* ```ts
|
|
1489
|
+
* univerAPI.getActiveWorkbook()
|
|
1490
|
+
* .getActiveSheet()
|
|
1491
|
+
* .getActiveRange()
|
|
1492
|
+
* .setFontFamily('Arial');
|
|
1493
|
+
* ```
|
|
1081
1494
|
*/
|
|
1082
|
-
setFontFamily(
|
|
1495
|
+
setFontFamily(s) {
|
|
1083
1496
|
const e = {
|
|
1084
1497
|
type: "ff",
|
|
1085
|
-
value:
|
|
1498
|
+
value: s
|
|
1086
1499
|
}, t = {
|
|
1087
1500
|
unitId: this._workbook.getUnitId(),
|
|
1088
1501
|
subUnitId: this._worksheet.getSheetId(),
|
|
1089
1502
|
range: this._range,
|
|
1090
1503
|
style: e
|
|
1091
1504
|
};
|
|
1092
|
-
return this._commandService.executeCommand(
|
|
1505
|
+
return this._commandService.executeCommand(f.id, t), this;
|
|
1093
1506
|
}
|
|
1094
1507
|
/**
|
|
1095
1508
|
* Sets the font size, with the size being the point size to use.
|
|
1096
|
-
* @param size A font size in point size. A null value resets the font size.
|
|
1509
|
+
* @param {number|null} size A font size in point size. A null value resets the font size.
|
|
1510
|
+
* @returns {FRange} This range, for chaining
|
|
1511
|
+
* @example
|
|
1512
|
+
* ```ts
|
|
1513
|
+
* univerAPI.getActiveWorkbook()
|
|
1514
|
+
* .getActiveSheet()
|
|
1515
|
+
* .getActiveRange()
|
|
1516
|
+
* .setFontSize(12);
|
|
1517
|
+
* ```
|
|
1097
1518
|
*/
|
|
1098
|
-
setFontSize(
|
|
1519
|
+
setFontSize(s) {
|
|
1099
1520
|
const e = {
|
|
1100
1521
|
type: "fs",
|
|
1101
|
-
value:
|
|
1522
|
+
value: s
|
|
1102
1523
|
}, t = {
|
|
1103
1524
|
unitId: this._workbook.getUnitId(),
|
|
1104
1525
|
subUnitId: this._worksheet.getSheetId(),
|
|
1105
1526
|
range: this._range,
|
|
1106
1527
|
style: e
|
|
1107
1528
|
};
|
|
1108
|
-
return this._commandService.executeCommand(
|
|
1529
|
+
return this._commandService.executeCommand(f.id, t), this;
|
|
1109
1530
|
}
|
|
1110
1531
|
/**
|
|
1111
1532
|
* Sets the font color in CSS notation (such as '#ffffff' or 'white').
|
|
1112
|
-
* @param color The font color in CSS notation (such as '#ffffff' or 'white'); a null value resets the color.
|
|
1533
|
+
* @param {string|null} color The font color in CSS notation (such as '#ffffff' or 'white'); a null value resets the color.
|
|
1534
|
+
* @returns {FRange} This range, for chaining
|
|
1535
|
+
* @example
|
|
1536
|
+
* ```ts
|
|
1537
|
+
* univerAPI.getActiveWorkbook()
|
|
1538
|
+
* .getActiveSheet()
|
|
1539
|
+
* .getActiveRange()
|
|
1540
|
+
* .setFontColor('#ff0000');
|
|
1541
|
+
* ```
|
|
1113
1542
|
*/
|
|
1114
|
-
setFontColor(
|
|
1543
|
+
setFontColor(s) {
|
|
1115
1544
|
const t = {
|
|
1116
1545
|
type: "cl",
|
|
1117
|
-
value:
|
|
1546
|
+
value: s === null ? null : { rgb: s }
|
|
1118
1547
|
}, n = {
|
|
1119
1548
|
unitId: this._workbook.getUnitId(),
|
|
1120
1549
|
subUnitId: this._worksheet.getSheetId(),
|
|
1121
1550
|
range: this._range,
|
|
1122
1551
|
style: t
|
|
1123
1552
|
};
|
|
1124
|
-
return this._commandService.executeCommand(
|
|
1553
|
+
return this._commandService.executeCommand(f.id, n), this;
|
|
1125
1554
|
}
|
|
1126
1555
|
// #endregion editing
|
|
1127
1556
|
//#region Merge cell
|
|
1128
1557
|
/**
|
|
1129
1558
|
* Merge cells in a range into one merged cell
|
|
1130
|
-
*
|
|
1131
|
-
* @
|
|
1132
|
-
*
|
|
1133
|
-
*
|
|
1559
|
+
* @param {boolean} [defaultMerge] - If true, only the value in the upper left cell is retained.
|
|
1560
|
+
* @returns {FRange} This range, for chaining
|
|
1561
|
+
* @example
|
|
1562
|
+
* ```ts
|
|
1563
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
1564
|
+
* const worksheet = workbook.getActiveSheet();
|
|
1565
|
+
* const range = worksheet.getRange(0, 0, 2, 2);
|
|
1566
|
+
* const merge = range.merge();
|
|
1567
|
+
* const isMerged = merge.isMerged();
|
|
1568
|
+
* console.log('debugger', isMerged);
|
|
1569
|
+
* ```
|
|
1134
1570
|
*/
|
|
1135
|
-
merge(
|
|
1571
|
+
merge(s = !0) {
|
|
1136
1572
|
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId();
|
|
1137
|
-
return
|
|
1573
|
+
return $(this._injector, e, t, [this._range], s), this;
|
|
1138
1574
|
}
|
|
1139
1575
|
/**
|
|
1140
1576
|
* Merges cells in a range horizontally.
|
|
1141
|
-
*
|
|
1142
|
-
* @
|
|
1143
|
-
*
|
|
1144
|
-
*
|
|
1577
|
+
* @param {boolean} [defaultMerge] - If true, only the value in the upper left cell is retained.
|
|
1578
|
+
* @returns {FRange} This range, for chaining
|
|
1579
|
+
* @example
|
|
1580
|
+
* ```ts
|
|
1581
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
1582
|
+
* const worksheet = workbook.getActiveSheet();
|
|
1583
|
+
* const range = worksheet.getRange(2, 2, 2, 2);
|
|
1584
|
+
* const merge = range.mergeAcross();
|
|
1585
|
+
* const allMerge = worksheet.getMergeData();
|
|
1586
|
+
* console.log(allMerge.length); // There will be two merged cells.
|
|
1587
|
+
* ```
|
|
1145
1588
|
*/
|
|
1146
|
-
mergeAcross(
|
|
1147
|
-
const e =
|
|
1148
|
-
return
|
|
1589
|
+
mergeAcross(s = !0) {
|
|
1590
|
+
const e = ce([this._range], ie.ROWS), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
|
|
1591
|
+
return $(this._injector, t, n, e, s), this;
|
|
1149
1592
|
}
|
|
1150
1593
|
/**
|
|
1151
1594
|
* Merges cells in a range vertically.
|
|
1152
|
-
*
|
|
1153
|
-
* @
|
|
1154
|
-
*
|
|
1155
|
-
*
|
|
1595
|
+
* @param {boolean} [defaultMerge] - If true, only the value in the upper left cell is retained.
|
|
1596
|
+
* @returns {FRange} This range, for chaining
|
|
1597
|
+
* @example
|
|
1598
|
+
* ```ts
|
|
1599
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
1600
|
+
* const worksheet = workbook.getActiveSheet();
|
|
1601
|
+
* const range = worksheet.getRange(4, 4, 2, 2);
|
|
1602
|
+
* const merge = range.mergeVertically();
|
|
1603
|
+
* const allMerge = worksheet.getMergeData();
|
|
1604
|
+
* console.log(allMerge.length); // There will be two merged cells.
|
|
1605
|
+
* ```
|
|
1156
1606
|
*/
|
|
1157
|
-
mergeVertically(
|
|
1158
|
-
const e =
|
|
1159
|
-
return
|
|
1607
|
+
mergeVertically(s = !0) {
|
|
1608
|
+
const e = ce([this._range], ie.COLUMNS), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
|
|
1609
|
+
return $(this._injector, t, n, e, s), this;
|
|
1160
1610
|
}
|
|
1161
1611
|
/**
|
|
1162
1612
|
* Returns true if cells in the current range overlap a merged cell.
|
|
1163
1613
|
* @returns {boolean} is overlap with a merged cell
|
|
1614
|
+
* @example
|
|
1615
|
+
* ```ts
|
|
1616
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
1617
|
+
* const worksheet = workbook.getActiveSheet();
|
|
1618
|
+
* const range = worksheet.getRange(0,0,2,2);
|
|
1619
|
+
* const merge = range.merge();
|
|
1620
|
+
* const anchor = worksheet.getRange(0,0);
|
|
1621
|
+
* const isPartOfMerge = anchor.isPartOfMerge();
|
|
1622
|
+
* console.log('debugger, isPartOfMerge) // true
|
|
1623
|
+
* ```
|
|
1164
1624
|
*/
|
|
1165
1625
|
isPartOfMerge() {
|
|
1166
|
-
const { startRow:
|
|
1167
|
-
return this._worksheet.getMergedCellRange(
|
|
1626
|
+
const { startRow: s, startColumn: e, endRow: t, endColumn: n } = this._range;
|
|
1627
|
+
return this._worksheet.getMergedCellRange(s, e, t, n).length > 0;
|
|
1168
1628
|
}
|
|
1169
1629
|
/**
|
|
1170
1630
|
* Break all horizontally- or vertically-merged cells contained within the range list into individual cells again.
|
|
1171
|
-
* @returns This range, for chaining
|
|
1631
|
+
* @returns {FRange} This range, for chaining
|
|
1632
|
+
* @example
|
|
1633
|
+
* ```ts
|
|
1634
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
1635
|
+
* const worksheet = workbook.getActiveSheet();
|
|
1636
|
+
* const range = worksheet.getRange(0,0,2,2);
|
|
1637
|
+
* const merge = range.merge();
|
|
1638
|
+
* const anchor = worksheet.getRange(0,0);
|
|
1639
|
+
* const isPartOfMergeFirst = anchor.isPartOfMerge();
|
|
1640
|
+
* console.log('debugger' isPartOfMergeFirst) // true
|
|
1641
|
+
* range.breakApart();
|
|
1642
|
+
* const isPartOfMergeSecond = anchor.isPartOfMerge();
|
|
1643
|
+
* console.log('debugger' isPartOfMergeSecond) // false
|
|
1644
|
+
* ```
|
|
1172
1645
|
*/
|
|
1173
1646
|
breakApart() {
|
|
1174
|
-
return this._commandService.executeCommand(
|
|
1647
|
+
return this._commandService.executeCommand(at.id, { ranges: [this._range] }), this;
|
|
1175
1648
|
}
|
|
1176
1649
|
//#endregion
|
|
1177
1650
|
/**
|
|
1178
1651
|
* Iterate cells in this range. Merged cells will be respected.
|
|
1179
|
-
* @param callback the callback function to be called for each cell in the range
|
|
1652
|
+
* @param {Function} callback the callback function to be called for each cell in the range
|
|
1180
1653
|
* @param {number} callback.row the row number of the cell
|
|
1181
1654
|
* @param {number} callback.col the column number of the cell
|
|
1182
1655
|
* @param {ICellData} callback.cell the cell data
|
|
@@ -1189,14 +1662,15 @@ let k = class extends X {
|
|
|
1189
1662
|
* });
|
|
1190
1663
|
* ```
|
|
1191
1664
|
*/
|
|
1192
|
-
forEach(
|
|
1193
|
-
const { startColumn: e, startRow: t, endColumn: n, endRow:
|
|
1194
|
-
this._worksheet.getMatrixWithMergedCells(t, e,
|
|
1195
|
-
o
|
|
1665
|
+
forEach(s) {
|
|
1666
|
+
const { startColumn: e, startRow: t, endColumn: n, endRow: r } = this._range;
|
|
1667
|
+
this._worksheet.getMatrixWithMergedCells(t, e, r, n).forValue((o, i, a) => {
|
|
1668
|
+
s(o, i, a);
|
|
1196
1669
|
});
|
|
1197
1670
|
}
|
|
1198
1671
|
/**
|
|
1199
1672
|
* Returns a string description of the range, in A1 notation.
|
|
1673
|
+
* @param {boolean} [withSheet] - If true, the sheet name is included in the A1 notation.
|
|
1200
1674
|
* @returns {string} The A1 notation of the range.
|
|
1201
1675
|
* ```ts
|
|
1202
1676
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -1205,8 +1679,8 @@ let k = class extends X {
|
|
|
1205
1679
|
* console.log(fRange.getA1Notation()); // A1:B2
|
|
1206
1680
|
* ```
|
|
1207
1681
|
*/
|
|
1208
|
-
getA1Notation(
|
|
1209
|
-
return
|
|
1682
|
+
getA1Notation(s) {
|
|
1683
|
+
return s ? Tt(this._worksheet.getName(), this._range) : re(this._range);
|
|
1210
1684
|
}
|
|
1211
1685
|
/**
|
|
1212
1686
|
* Sets the specified range as the active range, with the top left cell in the range as the current cell.
|
|
@@ -1230,8 +1704,8 @@ let k = class extends X {
|
|
|
1230
1704
|
* @description If the range is not a single cell, an error will be thrown.
|
|
1231
1705
|
*/
|
|
1232
1706
|
activateAsCurrentCell() {
|
|
1233
|
-
const
|
|
1234
|
-
if (
|
|
1707
|
+
const s = this._worksheet.getMergedCell(this._range.startRow, this._range.startColumn);
|
|
1708
|
+
if (s && N.equals(s, this._range) || !s && this._range.startRow === this._range.endRow && this._range.startColumn === this._range.endColumn)
|
|
1235
1709
|
return this.activate();
|
|
1236
1710
|
throw new Error("The range is not a single cell");
|
|
1237
1711
|
}
|
|
@@ -1267,14 +1741,14 @@ let k = class extends X {
|
|
|
1267
1741
|
* // 1 | 2 | 3
|
|
1268
1742
|
* // 4 | 5 | 6
|
|
1269
1743
|
*/
|
|
1270
|
-
splitTextToColumns(
|
|
1271
|
-
this._commandService.executeCommand(
|
|
1744
|
+
splitTextToColumns(s, e, t) {
|
|
1745
|
+
this._commandService.executeCommand(ht.id, {
|
|
1272
1746
|
unitId: this._workbook.getUnitId(),
|
|
1273
1747
|
subUnitId: this._worksheet.getSheetId(),
|
|
1274
1748
|
range: this._range,
|
|
1275
1749
|
delimiter: e,
|
|
1276
1750
|
customDelimiter: t,
|
|
1277
|
-
treatMultipleDelimitersAsOne:
|
|
1751
|
+
treatMultipleDelimitersAsOne: s
|
|
1278
1752
|
});
|
|
1279
1753
|
}
|
|
1280
1754
|
/**
|
|
@@ -1288,16 +1762,16 @@ let k = class extends X {
|
|
|
1288
1762
|
* fRange.useThemeStyle('default');
|
|
1289
1763
|
* ```
|
|
1290
1764
|
*/
|
|
1291
|
-
useThemeStyle(
|
|
1292
|
-
if (
|
|
1765
|
+
useThemeStyle(s) {
|
|
1766
|
+
if (s == null) {
|
|
1293
1767
|
const e = this.getUsedThemeStyle();
|
|
1294
1768
|
e && this.removeThemeStyle(e);
|
|
1295
1769
|
} else
|
|
1296
|
-
this._commandService.executeCommand(
|
|
1770
|
+
this._commandService.executeCommand(ct.id, {
|
|
1297
1771
|
unitId: this._workbook.getUnitId(),
|
|
1298
1772
|
subUnitId: this._worksheet.getSheetId(),
|
|
1299
1773
|
range: this._range,
|
|
1300
|
-
themeName:
|
|
1774
|
+
themeName: s
|
|
1301
1775
|
});
|
|
1302
1776
|
}
|
|
1303
1777
|
/**
|
|
@@ -1311,12 +1785,12 @@ let k = class extends X {
|
|
|
1311
1785
|
* fRange.removeThemeStyle('default');
|
|
1312
1786
|
* ```
|
|
1313
1787
|
*/
|
|
1314
|
-
removeThemeStyle(
|
|
1315
|
-
this._commandService.executeCommand(
|
|
1788
|
+
removeThemeStyle(s) {
|
|
1789
|
+
this._commandService.executeCommand(dt.id, {
|
|
1316
1790
|
unitId: this._workbook.getUnitId(),
|
|
1317
1791
|
subUnitId: this._worksheet.getSheetId(),
|
|
1318
1792
|
range: this._range,
|
|
1319
|
-
themeName:
|
|
1793
|
+
themeName: s
|
|
1320
1794
|
});
|
|
1321
1795
|
}
|
|
1322
1796
|
/**
|
|
@@ -1333,49 +1807,49 @@ let k = class extends X {
|
|
|
1333
1807
|
* ```
|
|
1334
1808
|
*/
|
|
1335
1809
|
getUsedThemeStyle() {
|
|
1336
|
-
return this._injector.get(
|
|
1810
|
+
return this._injector.get(Me).getAppliedRangeThemeStyle({
|
|
1337
1811
|
unitId: this._workbook.getUnitId(),
|
|
1338
1812
|
subUnitId: this._worksheet.getSheetId(),
|
|
1339
1813
|
range: this._range
|
|
1340
1814
|
});
|
|
1341
1815
|
}
|
|
1342
1816
|
};
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
],
|
|
1348
|
-
var
|
|
1349
|
-
for (var
|
|
1350
|
-
(i = o
|
|
1351
|
-
return n &&
|
|
1352
|
-
},
|
|
1353
|
-
let
|
|
1354
|
-
constructor(
|
|
1355
|
-
this._workbook =
|
|
1817
|
+
w = Jt([
|
|
1818
|
+
Y(3, u(b)),
|
|
1819
|
+
Y(4, l),
|
|
1820
|
+
Y(5, u(Wt))
|
|
1821
|
+
], w);
|
|
1822
|
+
var Qt = Object.defineProperty, Xt = Object.getOwnPropertyDescriptor, Zt = (s, e, t, n) => {
|
|
1823
|
+
for (var r = n > 1 ? void 0 : n ? Xt(e, t) : e, o = s.length - 1, i; o >= 0; o--)
|
|
1824
|
+
(i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
|
|
1825
|
+
return n && r && Qt(e, t, r), r;
|
|
1826
|
+
}, en = (s, e) => (t, n) => e(t, n, s);
|
|
1827
|
+
let B = class {
|
|
1828
|
+
constructor(s, e, t, n) {
|
|
1829
|
+
this._workbook = s, this._worksheet = e, this._selections = t, this._injector = n;
|
|
1356
1830
|
}
|
|
1357
1831
|
/**
|
|
1358
1832
|
* Represents the active selection in the sheet. Which means the selection contains the active cell.
|
|
1359
1833
|
* @returns {FRange | null} The active selection.
|
|
1360
1834
|
*/
|
|
1361
1835
|
getActiveRange() {
|
|
1362
|
-
const
|
|
1363
|
-
return
|
|
1836
|
+
const s = this._selections.find((e) => !!e.primary);
|
|
1837
|
+
return s ? this._injector.createInstance(w, this._workbook, this._worksheet, s.range) : null;
|
|
1364
1838
|
}
|
|
1365
1839
|
/**
|
|
1366
1840
|
* Represents the active selection list in the sheet.
|
|
1367
1841
|
* @returns {FRange[]} The active selection list.
|
|
1368
1842
|
*/
|
|
1369
1843
|
getActiveRangeList() {
|
|
1370
|
-
return this._selections.map((
|
|
1844
|
+
return this._selections.map((s) => this._injector.createInstance(w, this._workbook, this._worksheet, s.range));
|
|
1371
1845
|
}
|
|
1372
1846
|
/**
|
|
1373
1847
|
* Represents the current select cell in the sheet.
|
|
1374
1848
|
* @returns {ISelectionCell} The current select cell info.Pay attention to the type of the return value.
|
|
1375
1849
|
*/
|
|
1376
1850
|
getCurrentCell() {
|
|
1377
|
-
const
|
|
1378
|
-
return
|
|
1851
|
+
const s = this._selections.find((e) => !!e.primary);
|
|
1852
|
+
return s ? s.primary : null;
|
|
1379
1853
|
}
|
|
1380
1854
|
/**
|
|
1381
1855
|
* Returns the active sheet in the spreadsheet.
|
|
@@ -1390,8 +1864,8 @@ let A = class {
|
|
|
1390
1864
|
* ```
|
|
1391
1865
|
*/
|
|
1392
1866
|
getActiveSheet() {
|
|
1393
|
-
const
|
|
1394
|
-
return this._injector.createInstance(g,
|
|
1867
|
+
const s = this._injector.createInstance(I, this._workbook);
|
|
1868
|
+
return this._injector.createInstance(g, s, this._workbook, this._worksheet);
|
|
1395
1869
|
}
|
|
1396
1870
|
/**
|
|
1397
1871
|
* Update the primary cell in the selection. if the primary cell not exists in selections, add it to the selections and clear the old selections.
|
|
@@ -1407,31 +1881,31 @@ let A = class {
|
|
|
1407
1881
|
* console.log(newSelection.getActiveRange().getA1Notation()); // A1
|
|
1408
1882
|
* ```
|
|
1409
1883
|
*/
|
|
1410
|
-
updatePrimaryCell(
|
|
1884
|
+
updatePrimaryCell(s) {
|
|
1411
1885
|
const e = this._injector.get(l);
|
|
1412
1886
|
let t = [], n = !1;
|
|
1413
|
-
for (const { range:
|
|
1414
|
-
|
|
1415
|
-
range:
|
|
1416
|
-
primary:
|
|
1887
|
+
for (const { range: o, style: i } of this._selections)
|
|
1888
|
+
N.contains(o, s.getRange()) ? (t.push({
|
|
1889
|
+
range: o,
|
|
1890
|
+
primary: Z(s.getRange(), this._worksheet),
|
|
1417
1891
|
style: i
|
|
1418
1892
|
}), n = !0) : t.push({
|
|
1419
|
-
range:
|
|
1893
|
+
range: o,
|
|
1420
1894
|
primary: null,
|
|
1421
1895
|
style: i
|
|
1422
1896
|
});
|
|
1423
1897
|
n || (t = [
|
|
1424
1898
|
{
|
|
1425
|
-
range:
|
|
1426
|
-
primary:
|
|
1899
|
+
range: s.getRange(),
|
|
1900
|
+
primary: Z(s.getRange(), this._worksheet)
|
|
1427
1901
|
}
|
|
1428
1902
|
]);
|
|
1429
|
-
const
|
|
1903
|
+
const r = {
|
|
1430
1904
|
unitId: this._workbook.getUnitId(),
|
|
1431
1905
|
subUnitId: this._worksheet.getSheetId(),
|
|
1432
1906
|
selections: t
|
|
1433
1907
|
};
|
|
1434
|
-
return e.syncExecuteCommand(
|
|
1908
|
+
return e.syncExecuteCommand(De.id, r), new B(this._workbook, this._worksheet, t, this._injector);
|
|
1435
1909
|
}
|
|
1436
1910
|
/**
|
|
1437
1911
|
*Get the next primary cell in the specified direction. If the primary cell not exists in selections, return null.
|
|
@@ -1448,30 +1922,68 @@ let A = class {
|
|
|
1448
1922
|
* console.log(nextCell?.getA1Notation()); // B1
|
|
1449
1923
|
* ```
|
|
1450
1924
|
*/
|
|
1451
|
-
getNextDataRange(
|
|
1925
|
+
getNextDataRange(s) {
|
|
1452
1926
|
if (!this._selections.find((n) => !!n.primary))
|
|
1453
1927
|
return null;
|
|
1454
|
-
const t =
|
|
1455
|
-
return t ? this._injector.createInstance(
|
|
1928
|
+
const t = ut(this._selections.concat(), s, this._worksheet);
|
|
1929
|
+
return t ? this._injector.createInstance(w, this._workbook, this._worksheet, t) : null;
|
|
1456
1930
|
}
|
|
1457
1931
|
};
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
],
|
|
1461
|
-
var
|
|
1462
|
-
for (var
|
|
1463
|
-
(i = o
|
|
1464
|
-
return n &&
|
|
1465
|
-
},
|
|
1466
|
-
let g = class extends
|
|
1467
|
-
constructor(e, t, n,
|
|
1468
|
-
super(
|
|
1932
|
+
B = Zt([
|
|
1933
|
+
en(3, u(b))
|
|
1934
|
+
], B);
|
|
1935
|
+
var tn = Object.defineProperty, nn = Object.getOwnPropertyDescriptor, sn = (s, e, t, n) => {
|
|
1936
|
+
for (var r = n > 1 ? void 0 : n ? nn(e, t) : e, o = s.length - 1, i; o >= 0; o--)
|
|
1937
|
+
(i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
|
|
1938
|
+
return n && r && tn(e, t, r), r;
|
|
1939
|
+
}, T = (s, e) => (t, n) => e(t, n, s);
|
|
1940
|
+
let g = class extends ne {
|
|
1941
|
+
constructor(e, t, n, r, o, i, a) {
|
|
1942
|
+
super(r);
|
|
1943
|
+
k(this, "_eventRegistry", /* @__PURE__ */ new Map());
|
|
1469
1944
|
/**
|
|
1470
1945
|
* Sets the active selection region for this sheet.
|
|
1471
1946
|
* @param range The range to set as the active selection.
|
|
1472
1947
|
*/
|
|
1473
|
-
|
|
1474
|
-
this._fWorkbook = e, this._workbook = t, this._worksheet = n, this._injector =
|
|
1948
|
+
k(this, "setActiveSelection", this.setActiveRange);
|
|
1949
|
+
this._fWorkbook = e, this._workbook = t, this._worksheet = n, this._injector = r, this._selectionManagerService = o, this._logService = i, this._commandService = a;
|
|
1950
|
+
}
|
|
1951
|
+
getSheet() {
|
|
1952
|
+
return this._worksheet;
|
|
1953
|
+
}
|
|
1954
|
+
_ensureEventRegistry(e) {
|
|
1955
|
+
return this._eventRegistry.has(e) || this._eventRegistry.set(e, new ye()), this._eventRegistry.get(e);
|
|
1956
|
+
}
|
|
1957
|
+
/**
|
|
1958
|
+
* Add an event listener
|
|
1959
|
+
* @param event key of event
|
|
1960
|
+
* @param callback callback when event triggered
|
|
1961
|
+
* @returns {Disposable} The Disposable instance, for remove the listener
|
|
1962
|
+
* @example
|
|
1963
|
+
* ```ts
|
|
1964
|
+
* univerAPI.addEvent(univerAPI.event.UnitCreated, (params) => {
|
|
1965
|
+
* console.log('unit created', params);
|
|
1966
|
+
* });
|
|
1967
|
+
* ```
|
|
1968
|
+
*/
|
|
1969
|
+
addEvent(e, t) {
|
|
1970
|
+
return this._ensureEventRegistry(e).add(t), F(() => this._ensureEventRegistry(e).delete(t));
|
|
1971
|
+
}
|
|
1972
|
+
/**
|
|
1973
|
+
* Fire an event, used in internal only.
|
|
1974
|
+
* @param event {string} key of event
|
|
1975
|
+
* @param params {any} params of event
|
|
1976
|
+
* @returns {boolean} should cancel
|
|
1977
|
+
* @example
|
|
1978
|
+
* ```ts
|
|
1979
|
+
* this.fireEvent(univerAPI.event.UnitCreated, params);
|
|
1980
|
+
* ```
|
|
1981
|
+
*/
|
|
1982
|
+
fireEvent(e, t) {
|
|
1983
|
+
var n;
|
|
1984
|
+
return (n = this._eventRegistry.get(e)) == null || n.getData().forEach((r) => {
|
|
1985
|
+
r(t);
|
|
1986
|
+
}), t.cancel;
|
|
1475
1987
|
}
|
|
1476
1988
|
/**
|
|
1477
1989
|
* Returns the injector
|
|
@@ -1507,7 +2019,7 @@ let g = class extends X {
|
|
|
1507
2019
|
*/
|
|
1508
2020
|
getSelection() {
|
|
1509
2021
|
const e = this._selectionManagerService.getCurrentSelections();
|
|
1510
|
-
return e ? this._injector.createInstance(
|
|
2022
|
+
return e ? this._injector.createInstance(B, this._workbook, this._worksheet, e) : null;
|
|
1511
2023
|
}
|
|
1512
2024
|
// #region rows
|
|
1513
2025
|
// #region default style
|
|
@@ -1530,7 +2042,7 @@ let g = class extends X {
|
|
|
1530
2042
|
/**
|
|
1531
2043
|
* Get the default style of the worksheet column
|
|
1532
2044
|
* @param {number} index The column index
|
|
1533
|
-
* @param
|
|
2045
|
+
* @param {boolean} [keepRaw] If true, return the raw style data maybe the style name or style data, otherwise return the data from col manager
|
|
1534
2046
|
* @returns {Nullable<IStyleData> | string} The default style of the worksheet column name or style data
|
|
1535
2047
|
*/
|
|
1536
2048
|
getColumnDefaultStyle(e, t = !1) {
|
|
@@ -1543,7 +2055,7 @@ let g = class extends X {
|
|
|
1543
2055
|
*/
|
|
1544
2056
|
setDefaultStyle(e) {
|
|
1545
2057
|
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
|
|
1546
|
-
return this._commandService.syncExecuteCommand(
|
|
2058
|
+
return this._commandService.syncExecuteCommand(mt.id, {
|
|
1547
2059
|
unitId: t,
|
|
1548
2060
|
subUnitId: n,
|
|
1549
2061
|
defaultStyle: e
|
|
@@ -1556,16 +2068,16 @@ let g = class extends X {
|
|
|
1556
2068
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
1557
2069
|
*/
|
|
1558
2070
|
setColumnDefaultStyle(e, t) {
|
|
1559
|
-
const n = this._workbook.getUnitId(),
|
|
2071
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
|
|
1560
2072
|
unitId: n,
|
|
1561
|
-
subUnitId:
|
|
2073
|
+
subUnitId: r,
|
|
1562
2074
|
columnData: {
|
|
1563
2075
|
[e]: {
|
|
1564
2076
|
s: t
|
|
1565
2077
|
}
|
|
1566
2078
|
}
|
|
1567
2079
|
};
|
|
1568
|
-
return this._commandService.syncExecuteCommand(
|
|
2080
|
+
return this._commandService.syncExecuteCommand(de.id, o), this;
|
|
1569
2081
|
}
|
|
1570
2082
|
/**
|
|
1571
2083
|
* Set the default style of the worksheet column
|
|
@@ -1574,24 +2086,24 @@ let g = class extends X {
|
|
|
1574
2086
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
1575
2087
|
*/
|
|
1576
2088
|
setRowDefaultStyle(e, t) {
|
|
1577
|
-
const n = this._workbook.getUnitId(),
|
|
2089
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
|
|
1578
2090
|
unitId: n,
|
|
1579
|
-
subUnitId:
|
|
2091
|
+
subUnitId: r,
|
|
1580
2092
|
rowData: {
|
|
1581
2093
|
[e]: {
|
|
1582
2094
|
s: t
|
|
1583
2095
|
}
|
|
1584
2096
|
}
|
|
1585
2097
|
};
|
|
1586
|
-
return this._commandService.syncExecuteCommand(
|
|
2098
|
+
return this._commandService.syncExecuteCommand(ue.id, o), this;
|
|
1587
2099
|
}
|
|
1588
|
-
getRange(e, t, n,
|
|
1589
|
-
let
|
|
2100
|
+
getRange(e, t, n, r) {
|
|
2101
|
+
let o, i;
|
|
1590
2102
|
if (typeof e == "string") {
|
|
1591
|
-
const { range: a, sheetName: h } =
|
|
2103
|
+
const { range: a, sheetName: h } = At(e), c = h ? this._workbook.getSheetBySheetName(h) : this._worksheet;
|
|
1592
2104
|
if (!c)
|
|
1593
2105
|
throw new Error("Range not found");
|
|
1594
|
-
i = c,
|
|
2106
|
+
i = c, o = {
|
|
1595
2107
|
...a,
|
|
1596
2108
|
unitId: this._workbook.getUnitId(),
|
|
1597
2109
|
sheetId: i.getSheetId(),
|
|
@@ -1604,44 +2116,44 @@ let g = class extends X {
|
|
|
1604
2116
|
endColumn: a.rangeType === _.ROW ? i.getMaxColumns() - 1 : a.endColumn
|
|
1605
2117
|
};
|
|
1606
2118
|
} else if (typeof e == "number" && t !== void 0)
|
|
1607
|
-
i = this._worksheet,
|
|
2119
|
+
i = this._worksheet, o = {
|
|
1608
2120
|
startRow: e,
|
|
1609
2121
|
endRow: e + (n != null ? n : 1) - 1,
|
|
1610
2122
|
startColumn: t,
|
|
1611
|
-
endColumn: t + (
|
|
2123
|
+
endColumn: t + (r != null ? r : 1) - 1,
|
|
1612
2124
|
unitId: this._workbook.getUnitId(),
|
|
1613
2125
|
sheetId: this._worksheet.getSheetId()
|
|
1614
2126
|
};
|
|
1615
2127
|
else
|
|
1616
2128
|
throw new Error("Invalid range specification");
|
|
1617
|
-
return this._injector.createInstance(
|
|
2129
|
+
return this._injector.createInstance(w, this._workbook, i, o);
|
|
1618
2130
|
}
|
|
1619
2131
|
/**
|
|
1620
2132
|
* Returns the current number of columns in the sheet, regardless of content.
|
|
1621
|
-
* @
|
|
2133
|
+
* @returns {number} The maximum columns count of the sheet
|
|
1622
2134
|
*/
|
|
1623
2135
|
getMaxColumns() {
|
|
1624
2136
|
return this._worksheet.getMaxColumns();
|
|
1625
2137
|
}
|
|
1626
2138
|
/**
|
|
1627
2139
|
* Returns the current number of rows in the sheet, regardless of content.
|
|
1628
|
-
* @
|
|
2140
|
+
* @returns {number}The maximum rows count of the sheet
|
|
1629
2141
|
*/
|
|
1630
2142
|
getMaxRows() {
|
|
1631
2143
|
return this._worksheet.getMaxRows();
|
|
1632
2144
|
}
|
|
1633
2145
|
/**
|
|
1634
2146
|
* Inserts a row after the given row position.
|
|
1635
|
-
* @param afterPosition The row after which the new row should be added, starting at 0 for the first row.
|
|
1636
|
-
* @returns This sheet, for chaining.
|
|
2147
|
+
* @param {number} afterPosition The row after which the new row should be added, starting at 0 for the first row.
|
|
2148
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
1637
2149
|
*/
|
|
1638
2150
|
insertRowAfter(e) {
|
|
1639
2151
|
return this.insertRowsAfter(e, 1);
|
|
1640
2152
|
}
|
|
1641
2153
|
/**
|
|
1642
2154
|
* Inserts a row before the given row position.
|
|
1643
|
-
* @param beforePosition The row before which the new row should be added, starting at 0 for the first row.
|
|
1644
|
-
* @returns This sheet, for chaining.
|
|
2155
|
+
* @param {number} beforePosition The row before which the new row should be added, starting at 0 for the first row.
|
|
2156
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
1645
2157
|
*/
|
|
1646
2158
|
insertRowBefore(e) {
|
|
1647
2159
|
return this.insertRowsBefore(e, 1);
|
|
@@ -1662,11 +2174,11 @@ let g = class extends X {
|
|
|
1662
2174
|
* @returns This sheet, for chaining.
|
|
1663
2175
|
*/
|
|
1664
2176
|
insertRowsAfter(e, t) {
|
|
1665
|
-
const n = this._workbook.getUnitId(),
|
|
1666
|
-
return this._commandService.syncExecuteCommand(
|
|
2177
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = D.DOWN, i = e + 1, a = e + t, h = 0, c = this._worksheet.getColumnCount() - 1, d = W(this._worksheet, i, a, h, c, !0, e);
|
|
2178
|
+
return this._commandService.syncExecuteCommand(me.id, {
|
|
1667
2179
|
unitId: n,
|
|
1668
|
-
subUnitId:
|
|
1669
|
-
direction:
|
|
2180
|
+
subUnitId: r,
|
|
2181
|
+
direction: o,
|
|
1670
2182
|
range: {
|
|
1671
2183
|
startRow: i,
|
|
1672
2184
|
endRow: a,
|
|
@@ -1683,11 +2195,11 @@ let g = class extends X {
|
|
|
1683
2195
|
* @returns This sheet, for chaining.
|
|
1684
2196
|
*/
|
|
1685
2197
|
insertRowsBefore(e, t) {
|
|
1686
|
-
const n = this._workbook.getUnitId(),
|
|
1687
|
-
return this._commandService.syncExecuteCommand(
|
|
2198
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = D.UP, i = e, a = e + t - 1, h = 0, c = this._worksheet.getColumnCount() - 1, d = W(this._worksheet, i, a, h, c, !0, e - 1);
|
|
2199
|
+
return this._commandService.syncExecuteCommand(me.id, {
|
|
1688
2200
|
unitId: n,
|
|
1689
|
-
subUnitId:
|
|
1690
|
-
direction:
|
|
2201
|
+
subUnitId: r,
|
|
2202
|
+
direction: o,
|
|
1691
2203
|
range: {
|
|
1692
2204
|
startRow: i,
|
|
1693
2205
|
endRow: a,
|
|
@@ -1718,7 +2230,7 @@ let g = class extends X {
|
|
|
1718
2230
|
startColumn: 0,
|
|
1719
2231
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
1720
2232
|
};
|
|
1721
|
-
return this._commandService.syncExecuteCommand(
|
|
2233
|
+
return this._commandService.syncExecuteCommand(lt.id, {
|
|
1722
2234
|
range: n,
|
|
1723
2235
|
unitId: this._workbook.getUnitId(),
|
|
1724
2236
|
subUnitId: this._worksheet.getSheetId()
|
|
@@ -1731,16 +2243,16 @@ let g = class extends X {
|
|
|
1731
2243
|
* @returns This sheet, for chaining.
|
|
1732
2244
|
*/
|
|
1733
2245
|
moveRows(e, t) {
|
|
1734
|
-
const n = this._workbook.getUnitId(),
|
|
2246
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = q(e.getRange(), this._worksheet), i = o, a = {
|
|
1735
2247
|
startRow: t,
|
|
1736
2248
|
endRow: t,
|
|
1737
|
-
startColumn:
|
|
1738
|
-
endColumn:
|
|
2249
|
+
startColumn: o.startColumn,
|
|
2250
|
+
endColumn: o.endColumn
|
|
1739
2251
|
};
|
|
1740
|
-
return this._commandService.syncExecuteCommand(
|
|
2252
|
+
return this._commandService.syncExecuteCommand(gt.id, {
|
|
1741
2253
|
unitId: n,
|
|
1742
|
-
subUnitId:
|
|
1743
|
-
range:
|
|
2254
|
+
subUnitId: r,
|
|
2255
|
+
range: o,
|
|
1744
2256
|
fromRange: i,
|
|
1745
2257
|
toRange: a
|
|
1746
2258
|
}), this;
|
|
@@ -1751,114 +2263,115 @@ let g = class extends X {
|
|
|
1751
2263
|
* @returns This sheet, for chaining.
|
|
1752
2264
|
*/
|
|
1753
2265
|
hideRow(e) {
|
|
1754
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
1755
|
-
return this._commandService.syncExecuteCommand(
|
|
2266
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = q(e.getRange(), this._worksheet);
|
|
2267
|
+
return this._commandService.syncExecuteCommand(le.id, {
|
|
1756
2268
|
unitId: t,
|
|
1757
2269
|
subUnitId: n,
|
|
1758
|
-
ranges: [
|
|
2270
|
+
ranges: [r]
|
|
1759
2271
|
}), this;
|
|
1760
2272
|
}
|
|
1761
2273
|
/**
|
|
1762
2274
|
* Hides one or more consecutive rows starting at the given index. Use 0-index for this method.
|
|
1763
|
-
* @param rowIndex The starting index of the rows to hide.
|
|
1764
|
-
* @param numRows The number of rows to hide.
|
|
1765
|
-
* @returns This sheet, for chaining.
|
|
2275
|
+
* @param {number} rowIndex The starting index of the rows to hide.
|
|
2276
|
+
* @param {number} numRows The number of rows to hide.
|
|
2277
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
1766
2278
|
*/
|
|
1767
2279
|
hideRows(e, t = 1) {
|
|
1768
|
-
const n = this._workbook.getUnitId(),
|
|
2280
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
|
|
1769
2281
|
startRow: e,
|
|
1770
2282
|
endRow: e + t - 1,
|
|
1771
2283
|
startColumn: 0,
|
|
1772
2284
|
endColumn: this._worksheet.getColumnCount() - 1,
|
|
1773
2285
|
rangeType: _.ROW
|
|
1774
2286
|
};
|
|
1775
|
-
return this._commandService.syncExecuteCommand(
|
|
2287
|
+
return this._commandService.syncExecuteCommand(le.id, {
|
|
1776
2288
|
unitId: n,
|
|
1777
|
-
subUnitId:
|
|
1778
|
-
ranges: [
|
|
2289
|
+
subUnitId: r,
|
|
2290
|
+
ranges: [o]
|
|
1779
2291
|
}), this;
|
|
1780
2292
|
}
|
|
1781
2293
|
/**
|
|
1782
|
-
*
|
|
1783
|
-
* @param row The range to unhide, if hidden.
|
|
1784
|
-
* @returns This sheet, for chaining.
|
|
2294
|
+
* Make the row in the given range visible.
|
|
2295
|
+
* @param {FRange} row The range to unhide, if hidden.
|
|
2296
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
1785
2297
|
*/
|
|
1786
2298
|
unhideRow(e) {
|
|
1787
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
1788
|
-
return this._commandService.syncExecuteCommand(
|
|
2299
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = q(e.getRange(), this._worksheet);
|
|
2300
|
+
return this._commandService.syncExecuteCommand(ge.id, {
|
|
1789
2301
|
unitId: t,
|
|
1790
2302
|
subUnitId: n,
|
|
1791
|
-
ranges: [
|
|
2303
|
+
ranges: [r]
|
|
1792
2304
|
}), this;
|
|
1793
2305
|
}
|
|
1794
2306
|
/**
|
|
1795
|
-
*
|
|
1796
|
-
* @param rowIndex The starting index of the rows
|
|
1797
|
-
* @param numRows The number of rows
|
|
1798
|
-
* @returns This sheet, for chaining.
|
|
2307
|
+
* Scrolling sheet to make specific rows visible.
|
|
2308
|
+
* @param {number} rowIndex The starting index of the rows
|
|
2309
|
+
* @param {number} numRows The number of rows
|
|
2310
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
1799
2311
|
*/
|
|
1800
2312
|
showRows(e, t = 1) {
|
|
1801
|
-
const n = this._workbook.getUnitId(),
|
|
2313
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
|
|
1802
2314
|
startRow: e,
|
|
1803
2315
|
endRow: e + t - 1,
|
|
1804
2316
|
startColumn: 0,
|
|
1805
2317
|
endColumn: this._worksheet.getColumnCount() - 1,
|
|
1806
2318
|
rangeType: _.ROW
|
|
1807
2319
|
};
|
|
1808
|
-
return this._commandService.syncExecuteCommand(
|
|
2320
|
+
return this._commandService.syncExecuteCommand(ge.id, {
|
|
1809
2321
|
unitId: n,
|
|
1810
|
-
subUnitId:
|
|
1811
|
-
ranges: [
|
|
2322
|
+
subUnitId: r,
|
|
2323
|
+
ranges: [o]
|
|
1812
2324
|
}), this;
|
|
1813
2325
|
}
|
|
1814
2326
|
/**
|
|
1815
2327
|
* Sets the row height of the given row in pixels. By default, rows grow to fit cell contents. If you want to force rows to a specified height, use setRowHeightsForced(startRow, numRows, height).
|
|
1816
|
-
* @param rowPosition The row position to change.
|
|
1817
|
-
* @param height The height in pixels to set it to.
|
|
1818
|
-
* @returns This sheet, for chaining.
|
|
2328
|
+
* @param {number} rowPosition The row position to change.
|
|
2329
|
+
* @param {number} height The height in pixels to set it to.
|
|
2330
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
1819
2331
|
*/
|
|
1820
2332
|
setRowHeight(e, t) {
|
|
1821
2333
|
return this.setRowHeights(e, 1, t);
|
|
1822
2334
|
}
|
|
1823
2335
|
/**
|
|
1824
|
-
* Sets the height of the given rows in pixels.
|
|
1825
|
-
*
|
|
1826
|
-
* @param
|
|
1827
|
-
* @param
|
|
1828
|
-
* @
|
|
2336
|
+
* Sets the height of the given rows in pixels.
|
|
2337
|
+
* By default, rows grow to fit cell contents. If you want to force rows to a specified height, use setRowHeightsForced(startRow, numRows, height).
|
|
2338
|
+
* @param {number} startRow The starting row position to change.
|
|
2339
|
+
* @param {number} numRows The number of rows to change.
|
|
2340
|
+
* @param {number} height The height in pixels to set it to.
|
|
2341
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
1829
2342
|
*/
|
|
1830
2343
|
setRowHeights(e, t, n) {
|
|
1831
2344
|
var c;
|
|
1832
|
-
const
|
|
2345
|
+
const r = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), i = this._worksheet.getRowManager(), a = [], h = [];
|
|
1833
2346
|
for (let d = e; d < e + t; d++) {
|
|
1834
|
-
const
|
|
2347
|
+
const z = ((c = i.getRow(d)) == null ? void 0 : c.ah) || this._worksheet.getConfig().defaultRowHeight, M = {
|
|
1835
2348
|
startRow: d,
|
|
1836
2349
|
endRow: d,
|
|
1837
2350
|
startColumn: 0,
|
|
1838
2351
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
1839
2352
|
};
|
|
1840
|
-
n <=
|
|
2353
|
+
n <= z ? a.push(M) : h.push(M);
|
|
1841
2354
|
}
|
|
1842
|
-
return h.length > 0 && this._commandService.syncExecuteCommand(
|
|
1843
|
-
unitId:
|
|
1844
|
-
subUnitId:
|
|
2355
|
+
return h.length > 0 && this._commandService.syncExecuteCommand(_e.id, {
|
|
2356
|
+
unitId: r,
|
|
2357
|
+
subUnitId: o,
|
|
1845
2358
|
ranges: h,
|
|
1846
2359
|
value: n
|
|
1847
|
-
}), a.length > 0 && this._commandService.syncExecuteCommand(
|
|
1848
|
-
unitId:
|
|
1849
|
-
subUnitId:
|
|
2360
|
+
}), a.length > 0 && this._commandService.syncExecuteCommand(_t.id, {
|
|
2361
|
+
unitId: r,
|
|
2362
|
+
subUnitId: o,
|
|
1850
2363
|
ranges: a
|
|
1851
2364
|
}), this;
|
|
1852
2365
|
}
|
|
1853
2366
|
/**
|
|
1854
2367
|
* Sets the height of the given rows in pixels. By default, rows grow to fit cell contents. When you use setRowHeightsForced, rows are forced to the specified height even if the cell contents are taller than the row height.
|
|
1855
|
-
* @param startRow The starting row position to change.
|
|
1856
|
-
* @param numRows The number of rows to change.
|
|
1857
|
-
* @param height The height in pixels to set it to.
|
|
1858
|
-
* @returns This sheet, for chaining.
|
|
2368
|
+
* @param {number} startRow The starting row position to change.
|
|
2369
|
+
* @param {number} numRows The number of rows to change.
|
|
2370
|
+
* @param {number} height The height in pixels to set it to.
|
|
2371
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
1859
2372
|
*/
|
|
1860
2373
|
setRowHeightsForced(e, t, n) {
|
|
1861
|
-
const
|
|
2374
|
+
const r = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), i = [
|
|
1862
2375
|
{
|
|
1863
2376
|
startRow: e,
|
|
1864
2377
|
endRow: e + t - 1,
|
|
@@ -1866,9 +2379,9 @@ let g = class extends X {
|
|
|
1866
2379
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
1867
2380
|
}
|
|
1868
2381
|
];
|
|
1869
|
-
return this._commandService.syncExecuteCommand(
|
|
1870
|
-
unitId:
|
|
1871
|
-
subUnitId:
|
|
2382
|
+
return this._commandService.syncExecuteCommand(_e.id, {
|
|
2383
|
+
unitId: r,
|
|
2384
|
+
subUnitId: o,
|
|
1872
2385
|
ranges: i,
|
|
1873
2386
|
value: n
|
|
1874
2387
|
}), this;
|
|
@@ -1880,17 +2393,17 @@ let g = class extends X {
|
|
|
1880
2393
|
* @returns This sheet, for chaining.
|
|
1881
2394
|
*/
|
|
1882
2395
|
setRowCustom(e) {
|
|
1883
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
2396
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = {};
|
|
1884
2397
|
for (const [i, a] of Object.entries(e))
|
|
1885
|
-
|
|
2398
|
+
r[Number(i)] = {
|
|
1886
2399
|
custom: a
|
|
1887
2400
|
};
|
|
1888
|
-
const
|
|
2401
|
+
const o = {
|
|
1889
2402
|
unitId: t,
|
|
1890
2403
|
subUnitId: n,
|
|
1891
|
-
rowData:
|
|
2404
|
+
rowData: r
|
|
1892
2405
|
};
|
|
1893
|
-
return this._commandService.syncExecuteCommand(
|
|
2406
|
+
return this._commandService.syncExecuteCommand(ue.id, o), this;
|
|
1894
2407
|
}
|
|
1895
2408
|
// #region Column
|
|
1896
2409
|
/**
|
|
@@ -1925,11 +2438,11 @@ let g = class extends X {
|
|
|
1925
2438
|
* @returns This sheet, for chaining.
|
|
1926
2439
|
*/
|
|
1927
2440
|
insertColumnsAfter(e, t) {
|
|
1928
|
-
const n = this._workbook.getUnitId(),
|
|
1929
|
-
return this._commandService.syncExecuteCommand(
|
|
2441
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = D.RIGHT, i = 0, a = this._worksheet.getRowCount() - 1, h = e + 1, c = e + t, d = W(this._worksheet, i, a, h, c, !1, e);
|
|
2442
|
+
return this._commandService.syncExecuteCommand(we.id, {
|
|
1930
2443
|
unitId: n,
|
|
1931
|
-
subUnitId:
|
|
1932
|
-
direction:
|
|
2444
|
+
subUnitId: r,
|
|
2445
|
+
direction: o,
|
|
1933
2446
|
range: {
|
|
1934
2447
|
startRow: i,
|
|
1935
2448
|
endRow: a,
|
|
@@ -1946,11 +2459,11 @@ let g = class extends X {
|
|
|
1946
2459
|
* @returns This sheet, for chaining.
|
|
1947
2460
|
*/
|
|
1948
2461
|
insertColumnsBefore(e, t) {
|
|
1949
|
-
const n = this._workbook.getUnitId(),
|
|
1950
|
-
return this._commandService.syncExecuteCommand(
|
|
2462
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = D.LEFT, i = 0, a = this._worksheet.getRowCount() - 1, h = e, c = e + t - 1, d = W(this._worksheet, i, a, h, c, !1, e - 1);
|
|
2463
|
+
return this._commandService.syncExecuteCommand(we.id, {
|
|
1951
2464
|
unitId: n,
|
|
1952
|
-
subUnitId:
|
|
1953
|
-
direction:
|
|
2465
|
+
subUnitId: r,
|
|
2466
|
+
direction: o,
|
|
1954
2467
|
range: {
|
|
1955
2468
|
startRow: i,
|
|
1956
2469
|
endRow: a,
|
|
@@ -1981,7 +2494,7 @@ let g = class extends X {
|
|
|
1981
2494
|
startColumn: e,
|
|
1982
2495
|
endColumn: e + t - 1
|
|
1983
2496
|
};
|
|
1984
|
-
return this._commandService.syncExecuteCommand(
|
|
2497
|
+
return this._commandService.syncExecuteCommand(wt.id, {
|
|
1985
2498
|
range: n,
|
|
1986
2499
|
unitId: this._workbook.getUnitId(),
|
|
1987
2500
|
subUnitId: this._worksheet.getSheetId()
|
|
@@ -1994,16 +2507,16 @@ let g = class extends X {
|
|
|
1994
2507
|
* @returns This sheet, for chaining.
|
|
1995
2508
|
*/
|
|
1996
2509
|
moveColumns(e, t) {
|
|
1997
|
-
const n = this._workbook.getUnitId(),
|
|
2510
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = K(e.getRange(), this._worksheet), i = o, a = {
|
|
1998
2511
|
startRow: 0,
|
|
1999
2512
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2000
2513
|
startColumn: t,
|
|
2001
2514
|
endColumn: t
|
|
2002
2515
|
};
|
|
2003
|
-
return this._commandService.syncExecuteCommand(
|
|
2516
|
+
return this._commandService.syncExecuteCommand(kt.id, {
|
|
2004
2517
|
unitId: n,
|
|
2005
|
-
subUnitId:
|
|
2006
|
-
range:
|
|
2518
|
+
subUnitId: r,
|
|
2519
|
+
range: o,
|
|
2007
2520
|
fromRange: i,
|
|
2008
2521
|
toRange: a
|
|
2009
2522
|
}), this;
|
|
@@ -2014,11 +2527,11 @@ let g = class extends X {
|
|
|
2014
2527
|
* @returns This sheet, for chaining.
|
|
2015
2528
|
*/
|
|
2016
2529
|
hideColumn(e) {
|
|
2017
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
2018
|
-
return this._commandService.syncExecuteCommand(
|
|
2530
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = K(e.getRange(), this._worksheet);
|
|
2531
|
+
return this._commandService.syncExecuteCommand(ke.id, {
|
|
2019
2532
|
unitId: t,
|
|
2020
2533
|
subUnitId: n,
|
|
2021
|
-
ranges: [
|
|
2534
|
+
ranges: [r]
|
|
2022
2535
|
}), this;
|
|
2023
2536
|
}
|
|
2024
2537
|
/**
|
|
@@ -2028,50 +2541,50 @@ let g = class extends X {
|
|
|
2028
2541
|
* @returns This sheet, for chaining.
|
|
2029
2542
|
*/
|
|
2030
2543
|
hideColumns(e, t = 1) {
|
|
2031
|
-
const n = this._workbook.getUnitId(),
|
|
2544
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
|
|
2032
2545
|
startRow: 0,
|
|
2033
2546
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2034
2547
|
startColumn: e,
|
|
2035
2548
|
endColumn: e + t - 1,
|
|
2036
2549
|
rangeType: _.COLUMN
|
|
2037
2550
|
};
|
|
2038
|
-
return this._commandService.syncExecuteCommand(
|
|
2551
|
+
return this._commandService.syncExecuteCommand(ke.id, {
|
|
2039
2552
|
unitId: n,
|
|
2040
|
-
subUnitId:
|
|
2041
|
-
ranges: [
|
|
2553
|
+
subUnitId: r,
|
|
2554
|
+
ranges: [o]
|
|
2042
2555
|
}), this;
|
|
2043
2556
|
}
|
|
2044
2557
|
/**
|
|
2045
|
-
*
|
|
2558
|
+
* Show the column in the given range.
|
|
2046
2559
|
* @param column The range to unhide, if hidden.
|
|
2047
2560
|
* @returns This sheet, for chaining.
|
|
2048
2561
|
*/
|
|
2049
2562
|
unhideColumn(e) {
|
|
2050
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
2051
|
-
return this._commandService.syncExecuteCommand(
|
|
2563
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = K(e.getRange(), this._worksheet);
|
|
2564
|
+
return this._commandService.syncExecuteCommand(Se.id, {
|
|
2052
2565
|
unitId: t,
|
|
2053
2566
|
subUnitId: n,
|
|
2054
|
-
ranges: [
|
|
2567
|
+
ranges: [r]
|
|
2055
2568
|
}), this;
|
|
2056
2569
|
}
|
|
2057
2570
|
/**
|
|
2058
|
-
*
|
|
2571
|
+
* Show one or more consecutive columns starting at the given index. Use 0-index for this method.
|
|
2059
2572
|
* @param columnIndex The starting index of the columns to unhide.
|
|
2060
2573
|
* @param numColumns The number of columns to unhide.
|
|
2061
2574
|
* @returns This sheet, for chaining.
|
|
2062
2575
|
*/
|
|
2063
2576
|
showColumns(e, t = 1) {
|
|
2064
|
-
const n = this._workbook.getUnitId(),
|
|
2577
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
|
|
2065
2578
|
startRow: 0,
|
|
2066
2579
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2067
2580
|
startColumn: e,
|
|
2068
2581
|
endColumn: e + t - 1,
|
|
2069
2582
|
rangeType: _.COLUMN
|
|
2070
2583
|
};
|
|
2071
|
-
return this._commandService.syncExecuteCommand(
|
|
2584
|
+
return this._commandService.syncExecuteCommand(Se.id, {
|
|
2072
2585
|
unitId: n,
|
|
2073
|
-
subUnitId:
|
|
2074
|
-
ranges: [
|
|
2586
|
+
subUnitId: r,
|
|
2587
|
+
ranges: [o]
|
|
2075
2588
|
}), this;
|
|
2076
2589
|
}
|
|
2077
2590
|
/**
|
|
@@ -2091,7 +2604,7 @@ let g = class extends X {
|
|
|
2091
2604
|
* @returns This sheet, for chaining.
|
|
2092
2605
|
*/
|
|
2093
2606
|
setColumnWidths(e, t, n) {
|
|
2094
|
-
const
|
|
2607
|
+
const r = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), i = [
|
|
2095
2608
|
{
|
|
2096
2609
|
startColumn: e,
|
|
2097
2610
|
endColumn: e + t - 1,
|
|
@@ -2099,9 +2612,9 @@ let g = class extends X {
|
|
|
2099
2612
|
endRow: this._worksheet.getRowCount() - 1
|
|
2100
2613
|
}
|
|
2101
2614
|
];
|
|
2102
|
-
return this._commandService.syncExecuteCommand(
|
|
2103
|
-
unitId:
|
|
2104
|
-
subUnitId:
|
|
2615
|
+
return this._commandService.syncExecuteCommand(St.id, {
|
|
2616
|
+
unitId: r,
|
|
2617
|
+
subUnitId: o,
|
|
2105
2618
|
ranges: i,
|
|
2106
2619
|
value: n
|
|
2107
2620
|
}), this;
|
|
@@ -2113,17 +2626,17 @@ let g = class extends X {
|
|
|
2113
2626
|
* @returns This sheet, for chaining.
|
|
2114
2627
|
*/
|
|
2115
2628
|
setColumnCustom(e) {
|
|
2116
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
2629
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = {};
|
|
2117
2630
|
for (const [i, a] of Object.entries(e))
|
|
2118
|
-
|
|
2631
|
+
r[Number(i)] = {
|
|
2119
2632
|
custom: a
|
|
2120
2633
|
};
|
|
2121
|
-
const
|
|
2634
|
+
const o = {
|
|
2122
2635
|
unitId: t,
|
|
2123
2636
|
subUnitId: n,
|
|
2124
|
-
columnData:
|
|
2637
|
+
columnData: r
|
|
2125
2638
|
};
|
|
2126
|
-
return this._commandService.syncExecuteCommand(
|
|
2639
|
+
return this._commandService.syncExecuteCommand(de.id, o), this;
|
|
2127
2640
|
}
|
|
2128
2641
|
// #region merge cells
|
|
2129
2642
|
/**
|
|
@@ -2131,7 +2644,7 @@ let g = class extends X {
|
|
|
2131
2644
|
* @returns all merged cells
|
|
2132
2645
|
*/
|
|
2133
2646
|
getMergedRanges() {
|
|
2134
|
-
return this._worksheet.getSnapshot().mergeData.map((t) => this._injector.createInstance(
|
|
2647
|
+
return this._worksheet.getSnapshot().mergeData.map((t) => this._injector.createInstance(w, this._workbook, this._worksheet, t));
|
|
2135
2648
|
}
|
|
2136
2649
|
/**
|
|
2137
2650
|
* Get the merged cell data of the specified row and column.
|
|
@@ -2140,9 +2653,9 @@ let g = class extends X {
|
|
|
2140
2653
|
* @returns {FRange|undefined} The merged cell data, or undefined if the cell is not merged.
|
|
2141
2654
|
*/
|
|
2142
2655
|
getCellMergeData(e, t) {
|
|
2143
|
-
const
|
|
2144
|
-
if (
|
|
2145
|
-
return this._injector.createInstance(
|
|
2656
|
+
const r = this._worksheet.getMergedCell(e, t);
|
|
2657
|
+
if (r)
|
|
2658
|
+
return this._injector.createInstance(w, this._workbook, this._worksheet, r);
|
|
2146
2659
|
}
|
|
2147
2660
|
// #endregion
|
|
2148
2661
|
/**
|
|
@@ -2154,24 +2667,24 @@ let g = class extends X {
|
|
|
2154
2667
|
}
|
|
2155
2668
|
/**
|
|
2156
2669
|
* Sets the active selection region for this sheet.
|
|
2157
|
-
* @param range The range to set as the active selection.
|
|
2670
|
+
* @param {FRange} range The range to set as the active selection.
|
|
2671
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
2158
2672
|
*/
|
|
2159
2673
|
setActiveRange(e) {
|
|
2160
2674
|
const { unitId: t, sheetId: n } = e.getRange();
|
|
2161
2675
|
if (t !== this._workbook.getUnitId() || n !== this._worksheet.getSheetId())
|
|
2162
2676
|
throw new Error("Specified range must be part of the sheet.");
|
|
2163
|
-
this._fWorkbook.setActiveRange(e);
|
|
2677
|
+
return this._fWorkbook.setActiveRange(e), this;
|
|
2164
2678
|
}
|
|
2165
2679
|
/**
|
|
2166
2680
|
* Sets the frozen state of the current sheet.
|
|
2167
2681
|
* @param freeze - the scrolling viewport start range and count of freezed rows and columns.
|
|
2168
2682
|
* that means if you want to freeze the first 3 rows and 2 columns, you should set freeze as { startRow: 3, startColumn: 2, xSplit: 2, ySplit: 3 }
|
|
2169
|
-
*
|
|
2170
2683
|
* @deprecated use `setFrozenRows` and `setFrozenColumns` instead.
|
|
2171
2684
|
* @returns True if the command was successful, false otherwise.
|
|
2172
2685
|
*/
|
|
2173
2686
|
setFreeze(e) {
|
|
2174
|
-
return this._logService.warn("setFreeze is deprecated, use setFrozenRows and setFrozenColumns instead"), this._commandService.syncExecuteCommand(
|
|
2687
|
+
return this._logService.warn("setFreeze is deprecated, use setFrozenRows and setFrozenColumns instead"), this._commandService.syncExecuteCommand(H.id, {
|
|
2175
2688
|
...e,
|
|
2176
2689
|
unitId: this._workbook.getUnitId(),
|
|
2177
2690
|
subUnitId: this.getSheetId()
|
|
@@ -2182,7 +2695,7 @@ let g = class extends X {
|
|
|
2182
2695
|
* @returns True if the command was successful, false otherwise.
|
|
2183
2696
|
*/
|
|
2184
2697
|
cancelFreeze() {
|
|
2185
|
-
return this._commandService.syncExecuteCommand(
|
|
2698
|
+
return this._commandService.syncExecuteCommand(Ct.id, {
|
|
2186
2699
|
unitId: this._workbook.getUnitId(),
|
|
2187
2700
|
subUnitId: this.getSheetId()
|
|
2188
2701
|
}), this;
|
|
@@ -2190,7 +2703,6 @@ let g = class extends X {
|
|
|
2190
2703
|
/**
|
|
2191
2704
|
* Get the freeze state of the current sheet.
|
|
2192
2705
|
* @returns The freeze state of the current sheet.
|
|
2193
|
-
*
|
|
2194
2706
|
* @deprecated use `getRowFreezeStatus` and `getColumnFreezeStatus` instead.
|
|
2195
2707
|
*/
|
|
2196
2708
|
getFreeze() {
|
|
@@ -2206,10 +2718,10 @@ let g = class extends X {
|
|
|
2206
2718
|
xSplit: n
|
|
2207
2719
|
});
|
|
2208
2720
|
} else if (arguments.length === 2) {
|
|
2209
|
-
let [n = 0,
|
|
2210
|
-
n >
|
|
2211
|
-
startColumn:
|
|
2212
|
-
xSplit:
|
|
2721
|
+
let [n = 0, r = 0] = e;
|
|
2722
|
+
n > r && ([n, r] = [r, n]), this._commandService.syncExecuteCommand(H.id, {
|
|
2723
|
+
startColumn: r + 1,
|
|
2724
|
+
xSplit: r - n + 1,
|
|
2213
2725
|
startRow: t.startRow,
|
|
2214
2726
|
ySplit: t.ySplit,
|
|
2215
2727
|
unitId: this._workbook.getUnitId(),
|
|
@@ -2228,10 +2740,10 @@ let g = class extends X {
|
|
|
2228
2740
|
ySplit: n
|
|
2229
2741
|
});
|
|
2230
2742
|
} else if (arguments.length === 2) {
|
|
2231
|
-
let [n = 0,
|
|
2232
|
-
n >
|
|
2233
|
-
startRow:
|
|
2234
|
-
ySplit:
|
|
2743
|
+
let [n = 0, r = 0] = e;
|
|
2744
|
+
n > r && ([n, r] = [r, n]), this._commandService.syncExecuteCommand(H.id, {
|
|
2745
|
+
startRow: r + 1,
|
|
2746
|
+
ySplit: r - n + 1,
|
|
2235
2747
|
startColumn: t.startColumn,
|
|
2236
2748
|
xSplit: t.xSplit,
|
|
2237
2749
|
unitId: this._workbook.getUnitId(),
|
|
@@ -2242,8 +2754,7 @@ let g = class extends X {
|
|
|
2242
2754
|
}
|
|
2243
2755
|
/**
|
|
2244
2756
|
* Get the number of frozen columns.
|
|
2245
|
-
* @returns The number of frozen columns.
|
|
2246
|
-
* Returns 0 if no columns are frozen.
|
|
2757
|
+
* @returns The number of frozen columns, returns 0 if no columns are frozen.
|
|
2247
2758
|
*/
|
|
2248
2759
|
getFrozenColumns() {
|
|
2249
2760
|
const e = this.getFreeze();
|
|
@@ -2251,8 +2762,7 @@ let g = class extends X {
|
|
|
2251
2762
|
}
|
|
2252
2763
|
/**
|
|
2253
2764
|
* Get the number of frozen rows.
|
|
2254
|
-
* @returns The number of frozen rows.
|
|
2255
|
-
* Returns 0 if no rows are frozen.
|
|
2765
|
+
* @returns The number of frozen rows. returns 0 if no rows are frozen.
|
|
2256
2766
|
*/
|
|
2257
2767
|
getFrozenRows() {
|
|
2258
2768
|
const e = this.getFreeze();
|
|
@@ -2260,6 +2770,7 @@ let g = class extends X {
|
|
|
2260
2770
|
}
|
|
2261
2771
|
/**
|
|
2262
2772
|
* Get freezed rows.
|
|
2773
|
+
* @returns {IRowRange} The range of the frozen rows.
|
|
2263
2774
|
*/
|
|
2264
2775
|
getFrozenRowRange() {
|
|
2265
2776
|
const e = this._worksheet.getFreeze();
|
|
@@ -2270,6 +2781,7 @@ let g = class extends X {
|
|
|
2270
2781
|
}
|
|
2271
2782
|
/**
|
|
2272
2783
|
* Get freezed columns
|
|
2784
|
+
* @returns {IColumnRange} The range of the frozen columns.
|
|
2273
2785
|
*/
|
|
2274
2786
|
getFrozenColumnRange() {
|
|
2275
2787
|
const e = this._worksheet.getFreeze();
|
|
@@ -2292,11 +2804,12 @@ let g = class extends X {
|
|
|
2292
2804
|
* ```
|
|
2293
2805
|
*/
|
|
2294
2806
|
hasHiddenGridLines() {
|
|
2295
|
-
return this._worksheet.getConfig().showGridlines ===
|
|
2807
|
+
return this._worksheet.getConfig().showGridlines === m.FALSE;
|
|
2296
2808
|
}
|
|
2297
2809
|
/**
|
|
2298
2810
|
* Hides or reveals the sheet gridlines.
|
|
2299
2811
|
* @param {boolean} hidden If `true`, hide gridlines in this sheet; otherwise show the gridlines.
|
|
2812
|
+
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
2300
2813
|
* @example
|
|
2301
2814
|
* ``` ts
|
|
2302
2815
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -2306,10 +2819,10 @@ let g = class extends X {
|
|
|
2306
2819
|
* ```
|
|
2307
2820
|
*/
|
|
2308
2821
|
setHiddenGridlines(e) {
|
|
2309
|
-
return this._commandService.executeCommand(
|
|
2822
|
+
return this._commandService.executeCommand(It.id, {
|
|
2310
2823
|
unitId: this._workbook.getUnitId(),
|
|
2311
2824
|
subUnitId: this._worksheet.getSheetId(),
|
|
2312
|
-
showGridlines: e ?
|
|
2825
|
+
showGridlines: e ? m.FALSE : m.TRUE
|
|
2313
2826
|
}), this;
|
|
2314
2827
|
}
|
|
2315
2828
|
/**
|
|
@@ -2325,7 +2838,7 @@ let g = class extends X {
|
|
|
2325
2838
|
* ```
|
|
2326
2839
|
*/
|
|
2327
2840
|
setGridLinesColor(e) {
|
|
2328
|
-
return this._commandService.syncExecuteCommand(
|
|
2841
|
+
return this._commandService.syncExecuteCommand(ft.id, {
|
|
2329
2842
|
unitId: this._workbook.getUnitId(),
|
|
2330
2843
|
subUnitId: this._worksheet.getSheetId(),
|
|
2331
2844
|
color: e
|
|
@@ -2351,7 +2864,7 @@ let g = class extends X {
|
|
|
2351
2864
|
* ```
|
|
2352
2865
|
*/
|
|
2353
2866
|
setTabColor(e) {
|
|
2354
|
-
return this._commandService.executeCommand(
|
|
2867
|
+
return this._commandService.executeCommand(vt.id, {
|
|
2355
2868
|
unitId: this._workbook.getUnitId(),
|
|
2356
2869
|
subUnitId: this._worksheet.getSheetId(),
|
|
2357
2870
|
color: e
|
|
@@ -2390,9 +2903,9 @@ let g = class extends X {
|
|
|
2390
2903
|
*/
|
|
2391
2904
|
onCellDataChange(e) {
|
|
2392
2905
|
return this._injector.get(l).onCommandExecuted((n) => {
|
|
2393
|
-
if (n.id ===
|
|
2394
|
-
const
|
|
2395
|
-
|
|
2906
|
+
if (n.id === Ce.id) {
|
|
2907
|
+
const r = n.params;
|
|
2908
|
+
r.unitId === this._workbook.getUnitId() && r.subUnitId === this._worksheet.getSheetId() && r.cellValue && e(new A(r.cellValue));
|
|
2396
2909
|
}
|
|
2397
2910
|
});
|
|
2398
2911
|
}
|
|
@@ -2414,27 +2927,28 @@ let g = class extends X {
|
|
|
2414
2927
|
*/
|
|
2415
2928
|
onBeforeCellDataChange(e) {
|
|
2416
2929
|
return this._injector.get(l).beforeCommandExecuted((n) => {
|
|
2417
|
-
if (n.id ===
|
|
2418
|
-
const
|
|
2419
|
-
|
|
2930
|
+
if (n.id === Ce.id) {
|
|
2931
|
+
const r = n.params;
|
|
2932
|
+
r.unitId === this._workbook.getUnitId() && r.subUnitId === this._worksheet.getSheetId() && r.cellValue && e(new A(r.cellValue));
|
|
2420
2933
|
}
|
|
2421
2934
|
});
|
|
2422
2935
|
}
|
|
2423
2936
|
/**
|
|
2424
2937
|
* Hides this sheet. Has no effect if the sheet is already hidden. If this method is called on the only visible sheet, it throws an exception.
|
|
2938
|
+
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
2425
2939
|
* @example
|
|
2426
2940
|
* ```ts
|
|
2427
2941
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2428
2942
|
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
2429
2943
|
* // hide the active sheet
|
|
2430
2944
|
* fWorkSheet.hideSheet();
|
|
2431
|
-
*
|
|
2945
|
+
* ```
|
|
2432
2946
|
*/
|
|
2433
2947
|
hideSheet() {
|
|
2434
2948
|
const e = this._injector.get(l);
|
|
2435
|
-
if (this._workbook.getSheets().filter((
|
|
2949
|
+
if (this._workbook.getSheets().filter((o) => o.isSheetHidden() !== m.TRUE).length <= 1)
|
|
2436
2950
|
throw new Error("Cannot hide the only visible sheet");
|
|
2437
|
-
return e.syncExecuteCommand(
|
|
2951
|
+
return e.syncExecuteCommand(Rt.id, {
|
|
2438
2952
|
unitId: this._workbook.getUnitId(),
|
|
2439
2953
|
subUnitId: this._worksheet.getSheetId()
|
|
2440
2954
|
}), this;
|
|
@@ -2451,7 +2965,7 @@ let g = class extends X {
|
|
|
2451
2965
|
* ```
|
|
2452
2966
|
*/
|
|
2453
2967
|
showSheet() {
|
|
2454
|
-
return this._injector.get(l).syncExecuteCommand(
|
|
2968
|
+
return this._injector.get(l).syncExecuteCommand(bt.id, {
|
|
2455
2969
|
unitId: this._workbook.getUnitId(),
|
|
2456
2970
|
subUnitId: this._worksheet.getSheetId()
|
|
2457
2971
|
}), this;
|
|
@@ -2461,7 +2975,7 @@ let g = class extends X {
|
|
|
2461
2975
|
* @returns {boolean} True if the sheet is hidden; otherwise, false.
|
|
2462
2976
|
*/
|
|
2463
2977
|
isSheetHidden() {
|
|
2464
|
-
return this._worksheet.isSheetHidden() ===
|
|
2978
|
+
return this._worksheet.isSheetHidden() === m.TRUE;
|
|
2465
2979
|
}
|
|
2466
2980
|
/**
|
|
2467
2981
|
* Sets the sheet name.
|
|
@@ -2476,7 +2990,7 @@ let g = class extends X {
|
|
|
2476
2990
|
* ```
|
|
2477
2991
|
*/
|
|
2478
2992
|
setName(e) {
|
|
2479
|
-
return this._commandService.syncExecuteCommand(
|
|
2993
|
+
return this._commandService.syncExecuteCommand(pt.id, {
|
|
2480
2994
|
unitId: this._workbook.getUnitId(),
|
|
2481
2995
|
subUnitId: this._worksheet.getSheetId(),
|
|
2482
2996
|
name: e
|
|
@@ -2521,20 +3035,17 @@ let g = class extends X {
|
|
|
2521
3035
|
* ```
|
|
2522
3036
|
*/
|
|
2523
3037
|
clear(e) {
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
if (e && e.formatOnly && !e.contentsOnly)
|
|
2527
|
-
return this.clearFormats();
|
|
2528
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = this._injector.get(l), r = {
|
|
3038
|
+
e && e.contentsOnly && !e.formatOnly && this.clearContents(), e && e.formatOnly && !e.contentsOnly && this.clearFormats();
|
|
3039
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = this._injector.get(l), o = {
|
|
2529
3040
|
startRow: 0,
|
|
2530
3041
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2531
3042
|
startColumn: 0,
|
|
2532
3043
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2533
3044
|
};
|
|
2534
|
-
return
|
|
3045
|
+
return r.syncExecuteCommand(yt.id, {
|
|
2535
3046
|
unitId: t,
|
|
2536
3047
|
subUnitId: n,
|
|
2537
|
-
ranges: [
|
|
3048
|
+
ranges: [o],
|
|
2538
3049
|
options: e
|
|
2539
3050
|
}), this;
|
|
2540
3051
|
}
|
|
@@ -2550,16 +3061,16 @@ let g = class extends X {
|
|
|
2550
3061
|
* ```
|
|
2551
3062
|
*/
|
|
2552
3063
|
clearContents() {
|
|
2553
|
-
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l),
|
|
3064
|
+
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l), r = {
|
|
2554
3065
|
startRow: 0,
|
|
2555
3066
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2556
3067
|
startColumn: 0,
|
|
2557
3068
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2558
3069
|
};
|
|
2559
|
-
return n.syncExecuteCommand(
|
|
3070
|
+
return n.syncExecuteCommand(Ut.id, {
|
|
2560
3071
|
unitId: e,
|
|
2561
3072
|
subUnitId: t,
|
|
2562
|
-
ranges: [
|
|
3073
|
+
ranges: [r]
|
|
2563
3074
|
}), this;
|
|
2564
3075
|
}
|
|
2565
3076
|
/**
|
|
@@ -2574,16 +3085,16 @@ let g = class extends X {
|
|
|
2574
3085
|
* ```
|
|
2575
3086
|
*/
|
|
2576
3087
|
clearFormats() {
|
|
2577
|
-
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l),
|
|
3088
|
+
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l), r = {
|
|
2578
3089
|
startRow: 0,
|
|
2579
3090
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2580
3091
|
startColumn: 0,
|
|
2581
3092
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2582
3093
|
};
|
|
2583
|
-
return n.syncExecuteCommand(
|
|
3094
|
+
return n.syncExecuteCommand(Et.id, {
|
|
2584
3095
|
unitId: e,
|
|
2585
3096
|
subUnitId: t,
|
|
2586
|
-
ranges: [
|
|
3097
|
+
ranges: [r]
|
|
2587
3098
|
}), this;
|
|
2588
3099
|
}
|
|
2589
3100
|
/**
|
|
@@ -2619,6 +3130,7 @@ let g = class extends X {
|
|
|
2619
3130
|
return this._worksheet.getLastColumnWithContent();
|
|
2620
3131
|
}
|
|
2621
3132
|
/**
|
|
3133
|
+
* @deprecated use getLastColumn instead.
|
|
2622
3134
|
* Returns the position of the last column that has content. Same as getLastColumns.
|
|
2623
3135
|
* @returns {number} the last column of the sheet that contains content.
|
|
2624
3136
|
* @example
|
|
@@ -2633,6 +3145,7 @@ let g = class extends X {
|
|
|
2633
3145
|
return this._worksheet.getLastColumnWithContent();
|
|
2634
3146
|
}
|
|
2635
3147
|
/**
|
|
3148
|
+
* @deprecated use getLastRow instead.
|
|
2636
3149
|
* Returns the position of the last row that has content.
|
|
2637
3150
|
* @returns {number} the last row of the sheet that contains content.
|
|
2638
3151
|
* @example
|
|
@@ -2688,8 +3201,8 @@ let g = class extends X {
|
|
|
2688
3201
|
* ```
|
|
2689
3202
|
*/
|
|
2690
3203
|
insertDefinedName(e, t) {
|
|
2691
|
-
const
|
|
2692
|
-
|
|
3204
|
+
const r = this._injector.createInstance(L).setName(e).setRef(t).build();
|
|
3205
|
+
r.localSheetId = this.getSheetId(), this._fWorkbook.insertDefinedNameBuilder(r);
|
|
2693
3206
|
}
|
|
2694
3207
|
/**
|
|
2695
3208
|
* Get all the defined names in the worksheet.
|
|
@@ -2705,23 +3218,159 @@ let g = class extends X {
|
|
|
2705
3218
|
getDefinedNames() {
|
|
2706
3219
|
return this._fWorkbook.getDefinedNames().filter((t) => t.getLocalSheetId() === this.getSheetId());
|
|
2707
3220
|
}
|
|
3221
|
+
/**
|
|
3222
|
+
* Set custom metadata of worksheet
|
|
3223
|
+
* @param {CustomData | undefined} custom custom metadata
|
|
3224
|
+
* @example
|
|
3225
|
+
* ```ts
|
|
3226
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3227
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3228
|
+
* fWorkSheet.setCustomMetadata({ key: 'value' });
|
|
3229
|
+
* ```
|
|
3230
|
+
*/
|
|
3231
|
+
setCustomMetadata(e) {
|
|
3232
|
+
return this._worksheet.setCustomMetadata(e), this;
|
|
3233
|
+
}
|
|
3234
|
+
/**
|
|
3235
|
+
* Set custom metadata of row
|
|
3236
|
+
* @param {number} index row index
|
|
3237
|
+
* @param {CustomData | undefined} custom custom metadata
|
|
3238
|
+
* @example
|
|
3239
|
+
* ```ts
|
|
3240
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3241
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3242
|
+
* fWorkSheet.setRowCustomMetadata(0, { key: 'value' });
|
|
3243
|
+
* ```
|
|
3244
|
+
*/
|
|
3245
|
+
setRowCustomMetadata(e, t) {
|
|
3246
|
+
return this._worksheet.getRowManager().setCustomMetadata(e, t), this;
|
|
3247
|
+
}
|
|
3248
|
+
/**
|
|
3249
|
+
* Set custom metadata of column
|
|
3250
|
+
* @param {number} index column index
|
|
3251
|
+
* @param {CustomData | undefined} custom custom metadata
|
|
3252
|
+
* @example
|
|
3253
|
+
* ```ts
|
|
3254
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3255
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3256
|
+
* fWorkSheet.setColumnCustomMetadata(0, { key: 'value' });
|
|
3257
|
+
* ```
|
|
3258
|
+
*/
|
|
3259
|
+
setColumnCustomMetadata(e, t) {
|
|
3260
|
+
return this._worksheet.getColumnManager().setCustomMetadata(e, t), this;
|
|
3261
|
+
}
|
|
3262
|
+
/**
|
|
3263
|
+
* Get custom metadata of row
|
|
3264
|
+
* @param {number} index row index
|
|
3265
|
+
* @returns {CustomData | undefined} custom metadata
|
|
3266
|
+
* @example
|
|
3267
|
+
* ```ts
|
|
3268
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3269
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3270
|
+
* const custom = fWorkSheet.getRowCustomMetadata(0);
|
|
3271
|
+
* ```
|
|
3272
|
+
*/
|
|
3273
|
+
getRowCustomMetadata(e) {
|
|
3274
|
+
return this._worksheet.getRowManager().getCustomMetadata(e);
|
|
3275
|
+
}
|
|
3276
|
+
/**
|
|
3277
|
+
* Get custom metadata of column
|
|
3278
|
+
* @param {number} index column index
|
|
3279
|
+
* @returns {CustomData | undefined} custom metadata
|
|
3280
|
+
* @example
|
|
3281
|
+
* ```ts
|
|
3282
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3283
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3284
|
+
* const custom = fWorkSheet.getColumnCustomMetadata(0);
|
|
3285
|
+
* ```
|
|
3286
|
+
*/
|
|
3287
|
+
getColumnCustomMetadata(e) {
|
|
3288
|
+
return this._worksheet.getColumnManager().getCustomMetadata(e);
|
|
3289
|
+
}
|
|
3290
|
+
/**
|
|
3291
|
+
* Get all merged cells in the current worksheet
|
|
3292
|
+
* @returns {FRange[]} All the merged cells in the worksheet
|
|
3293
|
+
* @example
|
|
3294
|
+
* ```ts
|
|
3295
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
3296
|
+
* const worksheet = workbook.getActiveSheet();
|
|
3297
|
+
* const rangeFirst = worksheet.getRange(0, 0, 2, 2);
|
|
3298
|
+
* const mergeFirst = rangeFirst.merge();
|
|
3299
|
+
* const rangeSecond = worksheet.getRange(5, 0, 2, 2);
|
|
3300
|
+
* const mergeSecond = rangeSecond.merge();
|
|
3301
|
+
* const mergeData = worksheet.getMergeData();
|
|
3302
|
+
* console.log('debugger', mergeData);
|
|
3303
|
+
* ```
|
|
3304
|
+
*/
|
|
3305
|
+
getMergeData() {
|
|
3306
|
+
return this._worksheet.getMergeData().map((e) => this._injector.createInstance(w, this._workbook, this._worksheet, e));
|
|
3307
|
+
}
|
|
2708
3308
|
};
|
|
2709
|
-
g =
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
3309
|
+
g = sn([
|
|
3310
|
+
T(3, u(b)),
|
|
3311
|
+
T(4, u(We)),
|
|
3312
|
+
T(5, u(pe)),
|
|
3313
|
+
T(6, l)
|
|
2714
3314
|
], g);
|
|
2715
|
-
var
|
|
2716
|
-
for (var
|
|
2717
|
-
(i = o
|
|
2718
|
-
return n &&
|
|
2719
|
-
},
|
|
2720
|
-
let I = class extends
|
|
2721
|
-
constructor(e, t, n,
|
|
3315
|
+
var rn = Object.defineProperty, on = Object.getOwnPropertyDescriptor, an = (s, e, t, n) => {
|
|
3316
|
+
for (var r = n > 1 ? void 0 : n ? on(e, t) : e, o = s.length - 1, i; o >= 0; o--)
|
|
3317
|
+
(i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
|
|
3318
|
+
return n && r && rn(e, t, r), r;
|
|
3319
|
+
}, C = (s, e) => (t, n) => e(t, n, s);
|
|
3320
|
+
let I = class extends ne {
|
|
3321
|
+
constructor(e, t, n, r, o, i, a, h, c, d) {
|
|
2722
3322
|
super(t);
|
|
2723
|
-
|
|
2724
|
-
this
|
|
3323
|
+
k(this, "id");
|
|
3324
|
+
k(this, "_eventRegistry", /* @__PURE__ */ new Map());
|
|
3325
|
+
this._workbook = e, this._injector = t, this._resourceLoaderService = n, this._selectionManagerService = r, this._univerInstanceService = o, this._commandService = i, this._permissionService = a, this._logService = h, this._localeService = c, this._definedNamesService = d, this.id = this._workbook.getUnitId();
|
|
3326
|
+
}
|
|
3327
|
+
getWorkbook() {
|
|
3328
|
+
return this._workbook;
|
|
3329
|
+
}
|
|
3330
|
+
_ensureEventRegistry(e) {
|
|
3331
|
+
return this._eventRegistry.has(e) || this._eventRegistry.set(e, new ye()), this._eventRegistry.get(e);
|
|
3332
|
+
}
|
|
3333
|
+
/**
|
|
3334
|
+
* Add an event listener
|
|
3335
|
+
* @param event key of event
|
|
3336
|
+
* @param callback callback when event triggered
|
|
3337
|
+
* @returns {Disposable} The Disposable instance, for remove the listener
|
|
3338
|
+
* @example
|
|
3339
|
+
* ```ts
|
|
3340
|
+
* univerAPI.addEvent(univerAPI.event.UnitCreated, (params) => {
|
|
3341
|
+
* console.log('unit created', params);
|
|
3342
|
+
* });
|
|
3343
|
+
* ```
|
|
3344
|
+
*/
|
|
3345
|
+
addEvent(e, t) {
|
|
3346
|
+
return this._ensureEventRegistry(e).add(t), this.addUIEvent(e, t), F(() => this._ensureEventRegistry(e).delete(t));
|
|
3347
|
+
}
|
|
3348
|
+
/**
|
|
3349
|
+
* Fire an event, used in internal only.
|
|
3350
|
+
* @param event {string} key of event
|
|
3351
|
+
* @param params {any} params of event
|
|
3352
|
+
* @returns {boolean} should cancel
|
|
3353
|
+
* @example
|
|
3354
|
+
* ```ts
|
|
3355
|
+
* this.fireEvent(univerAPI.event.UnitCreated, params);
|
|
3356
|
+
* ```
|
|
3357
|
+
*/
|
|
3358
|
+
fireEvent(e, t) {
|
|
3359
|
+
var n;
|
|
3360
|
+
return (n = this._eventRegistry.get(e)) == null || n.getData().forEach((r) => {
|
|
3361
|
+
r(t);
|
|
3362
|
+
}), t.cancel;
|
|
3363
|
+
}
|
|
3364
|
+
addUIEvent(e, t) {
|
|
3365
|
+
}
|
|
3366
|
+
get Enum() {
|
|
3367
|
+
return ze.get();
|
|
3368
|
+
}
|
|
3369
|
+
/**
|
|
3370
|
+
* @returns {FEventName} The event name.
|
|
3371
|
+
*/
|
|
3372
|
+
get Event() {
|
|
3373
|
+
return se.get();
|
|
2725
3374
|
}
|
|
2726
3375
|
/**
|
|
2727
3376
|
* Get the id of the workbook.
|
|
@@ -2763,8 +3412,8 @@ let I = class extends X {
|
|
|
2763
3412
|
this._workbook.setName(e);
|
|
2764
3413
|
}
|
|
2765
3414
|
/**
|
|
2766
|
-
*
|
|
2767
|
-
* @
|
|
3415
|
+
* Save workbook snapshot data, including conditional formatting, data validation, and other plugin data.
|
|
3416
|
+
* @returns {IWorkbookData} Workbook snapshot data
|
|
2768
3417
|
* @example
|
|
2769
3418
|
* ```ts
|
|
2770
3419
|
* // The code below saves the workbook snapshot data
|
|
@@ -2777,7 +3426,7 @@ let I = class extends X {
|
|
|
2777
3426
|
}
|
|
2778
3427
|
/**
|
|
2779
3428
|
* @deprecated use 'save' instead.
|
|
2780
|
-
* @
|
|
3429
|
+
* @returns {*} {IWorkbookData} Workbook snapshot data
|
|
2781
3430
|
* @memberof FWorkbook
|
|
2782
3431
|
*/
|
|
2783
3432
|
getSnapshot() {
|
|
@@ -2785,7 +3434,7 @@ let I = class extends X {
|
|
|
2785
3434
|
}
|
|
2786
3435
|
/**
|
|
2787
3436
|
* Get the active sheet of the workbook.
|
|
2788
|
-
* @returns The active sheet of the workbook
|
|
3437
|
+
* @returns {FWorksheet} The active sheet of the workbook
|
|
2789
3438
|
* @example
|
|
2790
3439
|
* ```ts
|
|
2791
3440
|
* // The code below gets the active sheet of the workbook
|
|
@@ -2799,7 +3448,7 @@ let I = class extends X {
|
|
|
2799
3448
|
}
|
|
2800
3449
|
/**
|
|
2801
3450
|
* Gets all the worksheets in this workbook
|
|
2802
|
-
* @returns An array of all the worksheets in the workbook
|
|
3451
|
+
* @returns {FWorksheet[]} An array of all the worksheets in the workbook
|
|
2803
3452
|
* @example
|
|
2804
3453
|
* ```ts
|
|
2805
3454
|
* // The code below gets all the worksheets in the workbook
|
|
@@ -2824,24 +3473,24 @@ let I = class extends X {
|
|
|
2824
3473
|
* ```
|
|
2825
3474
|
*/
|
|
2826
3475
|
create(e, t, n) {
|
|
2827
|
-
const
|
|
2828
|
-
|
|
3476
|
+
const r = $e({});
|
|
3477
|
+
r.rowCount = t, r.columnCount = n, r.name = e, r.id = e.toLowerCase().replace(/ /g, "-"), this._commandService.syncExecuteCommand(x.id, {
|
|
2829
3478
|
unitId: this.id,
|
|
2830
3479
|
index: this._workbook.getSheets().length,
|
|
2831
|
-
sheet:
|
|
2832
|
-
}), this._commandService.syncExecuteCommand(
|
|
3480
|
+
sheet: r
|
|
3481
|
+
}), this._commandService.syncExecuteCommand(G.id, {
|
|
2833
3482
|
unitId: this.id,
|
|
2834
3483
|
subUnitId: this._workbook.getSheets()[this._workbook.getSheets().length - 1].getSheetId()
|
|
2835
3484
|
});
|
|
2836
|
-
const
|
|
2837
|
-
if (!
|
|
3485
|
+
const o = this._workbook.getActiveSheet();
|
|
3486
|
+
if (!o)
|
|
2838
3487
|
throw new Error("No active sheet found");
|
|
2839
|
-
return this._injector.createInstance(g, this, this._workbook,
|
|
3488
|
+
return this._injector.createInstance(g, this, this._workbook, o);
|
|
2840
3489
|
}
|
|
2841
3490
|
/**
|
|
2842
3491
|
* Get a worksheet by sheet id.
|
|
2843
3492
|
* @param sheetId The id of the sheet to get.
|
|
2844
|
-
* @
|
|
3493
|
+
* @returns The worksheet with given sheet id
|
|
2845
3494
|
* @example
|
|
2846
3495
|
* ```ts
|
|
2847
3496
|
* // The code below gets a worksheet by sheet id
|
|
@@ -2881,7 +3530,7 @@ let I = class extends X {
|
|
|
2881
3530
|
* ```
|
|
2882
3531
|
*/
|
|
2883
3532
|
setActiveSheet(e) {
|
|
2884
|
-
return this._commandService.syncExecuteCommand(
|
|
3533
|
+
return this._commandService.syncExecuteCommand(G.id, {
|
|
2885
3534
|
unitId: this.id,
|
|
2886
3535
|
subUnitId: e.getSheetId()
|
|
2887
3536
|
}), e;
|
|
@@ -2903,20 +3552,21 @@ let I = class extends X {
|
|
|
2903
3552
|
* ```
|
|
2904
3553
|
*/
|
|
2905
3554
|
insertSheet(e) {
|
|
2906
|
-
e != null ? this._commandService.syncExecuteCommand(
|
|
3555
|
+
e != null ? this._commandService.syncExecuteCommand(x.id, { sheet: { name: e } }) : this._commandService.syncExecuteCommand(x.id);
|
|
2907
3556
|
const t = this.id, n = this._workbook.getSheets()[this._workbook.getSheets().length - 1].getSheetId();
|
|
2908
|
-
this._commandService.syncExecuteCommand(
|
|
3557
|
+
this._commandService.syncExecuteCommand(G.id, {
|
|
2909
3558
|
unitId: t,
|
|
2910
3559
|
subUnitId: n
|
|
2911
3560
|
});
|
|
2912
|
-
const
|
|
2913
|
-
if (!
|
|
3561
|
+
const r = this._workbook.getActiveSheet();
|
|
3562
|
+
if (!r)
|
|
2914
3563
|
throw new Error("No active sheet found");
|
|
2915
|
-
return this._injector.createInstance(g, this, this._workbook,
|
|
3564
|
+
return this._injector.createInstance(g, this, this._workbook, r);
|
|
2916
3565
|
}
|
|
2917
3566
|
/**
|
|
2918
3567
|
* Deletes the specified worksheet.
|
|
2919
3568
|
* @param sheet The worksheet to delete.
|
|
3569
|
+
* @returns {boolean} True if the worksheet was deleted, false otherwise.
|
|
2920
3570
|
* @example
|
|
2921
3571
|
* ```ts
|
|
2922
3572
|
* // The code below deletes the specified worksheet
|
|
@@ -2927,7 +3577,7 @@ let I = class extends X {
|
|
|
2927
3577
|
*/
|
|
2928
3578
|
deleteSheet(e) {
|
|
2929
3579
|
const t = this.id, n = e.getSheetId();
|
|
2930
|
-
return this._commandService.syncExecuteCommand(
|
|
3580
|
+
return this._commandService.syncExecuteCommand(Pt.id, {
|
|
2931
3581
|
unitId: t,
|
|
2932
3582
|
subUnitId: n
|
|
2933
3583
|
});
|
|
@@ -2935,7 +3585,7 @@ let I = class extends X {
|
|
|
2935
3585
|
// #region editing
|
|
2936
3586
|
/**
|
|
2937
3587
|
* Undo the last action.
|
|
2938
|
-
* @returns A promise that resolves to true if the undo was successful, false otherwise.
|
|
3588
|
+
* @returns {FWorkbook} A promise that resolves to true if the undo was successful, false otherwise.
|
|
2939
3589
|
* @example
|
|
2940
3590
|
* ```ts
|
|
2941
3591
|
* // The code below undoes the last action
|
|
@@ -2944,7 +3594,7 @@ let I = class extends X {
|
|
|
2944
3594
|
* ```
|
|
2945
3595
|
*/
|
|
2946
3596
|
undo() {
|
|
2947
|
-
return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(
|
|
3597
|
+
return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(He.id), this;
|
|
2948
3598
|
}
|
|
2949
3599
|
/**
|
|
2950
3600
|
* Redo the last undone action.
|
|
@@ -2957,7 +3607,7 @@ let I = class extends X {
|
|
|
2957
3607
|
* ```
|
|
2958
3608
|
*/
|
|
2959
3609
|
redo() {
|
|
2960
|
-
return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(
|
|
3610
|
+
return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(Ge.id), this;
|
|
2961
3611
|
}
|
|
2962
3612
|
/**
|
|
2963
3613
|
* Callback for command execution.
|
|
@@ -3008,7 +3658,6 @@ let I = class extends X {
|
|
|
3008
3658
|
}
|
|
3009
3659
|
/**
|
|
3010
3660
|
* Callback for selection changes.
|
|
3011
|
-
*
|
|
3012
3661
|
* @callback onSelectionChangeCallback
|
|
3013
3662
|
* @param {IRange[]} selections The new selection.
|
|
3014
3663
|
*/
|
|
@@ -3018,46 +3667,50 @@ let I = class extends X {
|
|
|
3018
3667
|
* @returns A function to dispose the listening
|
|
3019
3668
|
*/
|
|
3020
3669
|
onSelectionChange(e) {
|
|
3021
|
-
return
|
|
3670
|
+
return F(
|
|
3022
3671
|
this._selectionManagerService.selectionMoveEnd$.subscribe((t) => {
|
|
3023
|
-
this._univerInstanceService.getCurrentUnitForType(
|
|
3672
|
+
this._univerInstanceService.getCurrentUnitForType(R.UNIVER_SHEET).getUnitId() === this.id && (t != null && t.length ? e(t.map((n) => n.range)) : e([]));
|
|
3024
3673
|
})
|
|
3025
3674
|
);
|
|
3026
3675
|
}
|
|
3027
3676
|
/**
|
|
3028
3677
|
* Used to modify the editing permissions of the workbook. When the value is false, editing is not allowed.
|
|
3029
3678
|
* @param {boolean} value editable value want to set
|
|
3679
|
+
* @returns {FWorkbook} FWorkbook instance
|
|
3030
3680
|
*/
|
|
3031
3681
|
setEditable(e) {
|
|
3032
|
-
const t = new
|
|
3033
|
-
this._permissionService.getPermissionPoint(t.id) || this._permissionService.addPermissionPoint(t), this._permissionService.updatePermissionPoint(t.id, e);
|
|
3682
|
+
const t = new Ne(this._workbook.getUnitId());
|
|
3683
|
+
return this._permissionService.getPermissionPoint(t.id) || this._permissionService.addPermissionPoint(t), this._permissionService.updatePermissionPoint(t.id, e), this;
|
|
3034
3684
|
}
|
|
3035
3685
|
/**
|
|
3036
|
-
* Sets the
|
|
3686
|
+
* Sets the selection region for active sheet.
|
|
3037
3687
|
* @param range The range to set as the active selection.
|
|
3688
|
+
* @returns {FWorkbook} FWorkbook instance
|
|
3038
3689
|
*/
|
|
3039
3690
|
setActiveRange(e) {
|
|
3040
|
-
const t = this.getActiveSheet(), n = e.getRange().sheetId || t.getSheetId(),
|
|
3041
|
-
if (!
|
|
3691
|
+
const t = this.getActiveSheet(), n = e.getRange().sheetId || t.getSheetId(), r = n ? this._workbook.getSheetBySheetId(n) : this._workbook.getActiveSheet(!0);
|
|
3692
|
+
if (!r)
|
|
3042
3693
|
throw new Error("No active sheet found");
|
|
3043
|
-
|
|
3044
|
-
const
|
|
3694
|
+
r.getSheetId() !== t.getSheetId() && this.setActiveSheet(this._injector.createInstance(g, this, this._workbook, r));
|
|
3695
|
+
const o = {
|
|
3045
3696
|
unitId: this.getId(),
|
|
3046
3697
|
subUnitId: n,
|
|
3047
|
-
selections: [e].map((i) => ({ range: i.getRange(), primary:
|
|
3698
|
+
selections: [e].map((i) => ({ range: i.getRange(), primary: Z(i.getRange(), r), style: null }))
|
|
3048
3699
|
};
|
|
3049
|
-
this._commandService.syncExecuteCommand(
|
|
3700
|
+
return this._commandService.syncExecuteCommand(De.id, o), this;
|
|
3050
3701
|
}
|
|
3051
3702
|
/**
|
|
3052
3703
|
* Returns the selected range in the active sheet, or null if there is no active range.
|
|
3053
3704
|
* @returns the active range
|
|
3054
3705
|
*/
|
|
3706
|
+
// could sheet have no active range ?
|
|
3055
3707
|
getActiveRange() {
|
|
3056
|
-
const e = this._workbook.getActiveSheet(), n = this._selectionManagerService.getCurrentSelections().find((
|
|
3057
|
-
return n ? this._injector.createInstance(
|
|
3708
|
+
const e = this._workbook.getActiveSheet(), n = this._selectionManagerService.getCurrentSelections().find((r) => !!r.primary);
|
|
3709
|
+
return n ? this._injector.createInstance(w, this._workbook, e, n.range) : null;
|
|
3058
3710
|
}
|
|
3059
3711
|
/**
|
|
3060
3712
|
* Deletes the currently active sheet.
|
|
3713
|
+
* @returns {boolean} true if the sheet was deleted, false otherwise
|
|
3061
3714
|
* @example
|
|
3062
3715
|
* ```ts
|
|
3063
3716
|
* // The code below deletes the currently active sheet and stores the new active
|
|
@@ -3082,7 +3735,7 @@ let I = class extends X {
|
|
|
3082
3735
|
* ```
|
|
3083
3736
|
*/
|
|
3084
3737
|
duplicateSheet(e) {
|
|
3085
|
-
return this._commandService.syncExecuteCommand(
|
|
3738
|
+
return this._commandService.syncExecuteCommand(xt.id, {
|
|
3086
3739
|
unitId: e.getWorkbook().getUnitId(),
|
|
3087
3740
|
subUnitId: e.getSheetId()
|
|
3088
3741
|
}), this._injector.createInstance(g, this, this._workbook, this._workbook.getActiveSheet());
|
|
@@ -3127,9 +3780,17 @@ let I = class extends X {
|
|
|
3127
3780
|
getLocale() {
|
|
3128
3781
|
return this._localeService.getCurrentLocale();
|
|
3129
3782
|
}
|
|
3783
|
+
/**
|
|
3784
|
+
* @deprecated use setSpreadsheetLocale instead.
|
|
3785
|
+
* @param {LocaleType} locale - The locale to set
|
|
3786
|
+
*/
|
|
3787
|
+
setLocale(e) {
|
|
3788
|
+
this._localeService.setLocale(e);
|
|
3789
|
+
}
|
|
3130
3790
|
/**
|
|
3131
3791
|
* Set the locale of the workbook.
|
|
3132
3792
|
* @param {LocaleType} locale The locale to set
|
|
3793
|
+
* @returns {FWorkbook} This workbook, for chaining
|
|
3133
3794
|
* @example
|
|
3134
3795
|
* ```ts
|
|
3135
3796
|
* // The code below sets the locale of the workbook
|
|
@@ -3137,8 +3798,8 @@ let I = class extends X {
|
|
|
3137
3798
|
* activeSpreadsheet.setLocale(LocaleType.EN_US);
|
|
3138
3799
|
* ```
|
|
3139
3800
|
*/
|
|
3140
|
-
|
|
3141
|
-
this._localeService.setLocale(e);
|
|
3801
|
+
setSpreadsheetLocale(e) {
|
|
3802
|
+
return this._localeService.setLocale(e), this;
|
|
3142
3803
|
}
|
|
3143
3804
|
/**
|
|
3144
3805
|
* Get the URL of the workbook.
|
|
@@ -3168,7 +3829,7 @@ let I = class extends X {
|
|
|
3168
3829
|
*/
|
|
3169
3830
|
moveSheet(e, t) {
|
|
3170
3831
|
let n = t;
|
|
3171
|
-
return n < 0 ? n = 0 : n > this._workbook.getSheets().length - 1 && (n = this._workbook.getSheets().length - 1), this._commandService.syncExecuteCommand(
|
|
3832
|
+
return n < 0 ? n = 0 : n > this._workbook.getSheets().length - 1 && (n = this._workbook.getSheets().length - 1), this._commandService.syncExecuteCommand(Nt.id, {
|
|
3172
3833
|
unitId: e.getWorkbook().getUnitId(),
|
|
3173
3834
|
order: n,
|
|
3174
3835
|
subUnitId: e.getSheetId()
|
|
@@ -3191,11 +3852,10 @@ let I = class extends X {
|
|
|
3191
3852
|
}
|
|
3192
3853
|
/**
|
|
3193
3854
|
* Get the PermissionInstance.
|
|
3194
|
-
*
|
|
3195
3855
|
* @returns {FPermission} - The PermissionInstance.
|
|
3196
3856
|
*/
|
|
3197
3857
|
getPermission() {
|
|
3198
|
-
return this._injector.createInstance(
|
|
3858
|
+
return this._injector.createInstance(O);
|
|
3199
3859
|
}
|
|
3200
3860
|
/**
|
|
3201
3861
|
* Get the defined name by name.
|
|
@@ -3210,7 +3870,7 @@ let I = class extends X {
|
|
|
3210
3870
|
*/
|
|
3211
3871
|
getDefinedName(e) {
|
|
3212
3872
|
const t = this._definedNamesService.getValueByName(this.id, e);
|
|
3213
|
-
return t ? this._injector.createInstance(
|
|
3873
|
+
return t ? this._injector.createInstance(j, { ...t, unitId: this.id }) : null;
|
|
3214
3874
|
}
|
|
3215
3875
|
/**
|
|
3216
3876
|
* Get all the defined names in the workbook.
|
|
@@ -3224,12 +3884,13 @@ let I = class extends X {
|
|
|
3224
3884
|
*/
|
|
3225
3885
|
getDefinedNames() {
|
|
3226
3886
|
const e = this._definedNamesService.getDefinedNameMap(this.id);
|
|
3227
|
-
return e ? Object.values(e).map((t) => this._injector.createInstance(
|
|
3887
|
+
return e ? Object.values(e).map((t) => this._injector.createInstance(j, { ...t, unitId: this.id })) : [];
|
|
3228
3888
|
}
|
|
3229
3889
|
/**
|
|
3230
3890
|
* Insert a defined name.
|
|
3231
3891
|
* @param {string} name The name of the defined name to insert
|
|
3232
3892
|
* @param {string} formulaOrRefString The formula(=sum(A2:b10)) or reference(A1) string of the defined name to insert
|
|
3893
|
+
* @returns {FWorkbook} The current FWorkbook instance
|
|
3233
3894
|
* @example
|
|
3234
3895
|
* ```ts
|
|
3235
3896
|
* // The code below inserts a defined name
|
|
@@ -3238,8 +3899,8 @@ let I = class extends X {
|
|
|
3238
3899
|
* ```
|
|
3239
3900
|
*/
|
|
3240
3901
|
insertDefinedName(e, t) {
|
|
3241
|
-
const
|
|
3242
|
-
|
|
3902
|
+
const r = this._injector.createInstance(L).setName(e).setRef(t).build();
|
|
3903
|
+
return r.localSheetId = X, this.insertDefinedNameBuilder(r), this;
|
|
3243
3904
|
}
|
|
3244
3905
|
/**
|
|
3245
3906
|
* Delete the defined name with the given name.
|
|
@@ -3257,7 +3918,7 @@ let I = class extends X {
|
|
|
3257
3918
|
return t ? (t.delete(), !0) : !1;
|
|
3258
3919
|
}
|
|
3259
3920
|
/**
|
|
3260
|
-
*
|
|
3921
|
+
* Insert a defined name by builder param.
|
|
3261
3922
|
* @param {ISetDefinedNameMutationParam} param The param to insert the defined name
|
|
3262
3923
|
* @example
|
|
3263
3924
|
* ```ts
|
|
@@ -3269,7 +3930,7 @@ let I = class extends X {
|
|
|
3269
3930
|
* ```
|
|
3270
3931
|
*/
|
|
3271
3932
|
insertDefinedNameBuilder(e) {
|
|
3272
|
-
e.unitId = this.getId(), this._commandService.syncExecuteCommand(
|
|
3933
|
+
e.unitId = this.getId(), this._commandService.syncExecuteCommand(Q.id, e);
|
|
3273
3934
|
}
|
|
3274
3935
|
/**
|
|
3275
3936
|
* Update the defined name with the given name.
|
|
@@ -3284,7 +3945,7 @@ let I = class extends X {
|
|
|
3284
3945
|
* ```
|
|
3285
3946
|
*/
|
|
3286
3947
|
updateDefinedNameBuilder(e) {
|
|
3287
|
-
this._commandService.syncExecuteCommand(
|
|
3948
|
+
this._commandService.syncExecuteCommand(Q.id, e);
|
|
3288
3949
|
}
|
|
3289
3950
|
/**
|
|
3290
3951
|
* Gets the registered range themes.
|
|
@@ -3298,10 +3959,11 @@ let I = class extends X {
|
|
|
3298
3959
|
* ```
|
|
3299
3960
|
*/
|
|
3300
3961
|
getRegisteredRangeThemes() {
|
|
3301
|
-
return this._injector.get(
|
|
3962
|
+
return this._injector.get(Me).getRegisteredRangeThemes();
|
|
3302
3963
|
}
|
|
3303
3964
|
/**
|
|
3304
3965
|
* Register a custom range theme style.
|
|
3966
|
+
* @param rangeThemeStyle
|
|
3305
3967
|
* @example
|
|
3306
3968
|
* ```ts
|
|
3307
3969
|
* // import {RangeThemeStyle} from '@univerjs/sheets';
|
|
@@ -3316,13 +3978,14 @@ let I = class extends X {
|
|
|
3316
3978
|
* ```
|
|
3317
3979
|
*/
|
|
3318
3980
|
registerRangeTheme(e) {
|
|
3319
|
-
this._commandService.syncExecuteCommand(
|
|
3981
|
+
this._commandService.syncExecuteCommand(Mt.id, {
|
|
3320
3982
|
unitId: this.getId(),
|
|
3321
3983
|
rangeThemeStyle: e
|
|
3322
3984
|
});
|
|
3323
3985
|
}
|
|
3324
3986
|
/**
|
|
3325
3987
|
* Unregister a custom range theme style.
|
|
3988
|
+
* @param themeName
|
|
3326
3989
|
* @example
|
|
3327
3990
|
* ```ts
|
|
3328
3991
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -3330,32 +3993,106 @@ let I = class extends X {
|
|
|
3330
3993
|
* ```
|
|
3331
3994
|
*/
|
|
3332
3995
|
unregisterRangeTheme(e) {
|
|
3333
|
-
this._commandService.syncExecuteCommand(
|
|
3996
|
+
this._commandService.syncExecuteCommand(Dt.id, {
|
|
3334
3997
|
unitId: this.getId(),
|
|
3335
3998
|
themeName: e
|
|
3336
3999
|
});
|
|
3337
4000
|
}
|
|
4001
|
+
/**
|
|
4002
|
+
* Set custom metadata of workbook
|
|
4003
|
+
* @param {CustomData | undefined} custom custom metadata
|
|
4004
|
+
* @returns {FWorkbook} FWorkbook
|
|
4005
|
+
* @example
|
|
4006
|
+
* ```ts
|
|
4007
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
4008
|
+
* fWorkbook.setCustomMetadata({ key: 'value' });
|
|
4009
|
+
* ```
|
|
4010
|
+
*/
|
|
4011
|
+
setCustomMetadata(e) {
|
|
4012
|
+
return this._workbook.setCustomMetadata(e), this;
|
|
4013
|
+
}
|
|
4014
|
+
/**
|
|
4015
|
+
* Get custom metadata of workbook
|
|
4016
|
+
* @returns {CustomData | undefined} custom metadata
|
|
4017
|
+
* @example
|
|
4018
|
+
* ```ts
|
|
4019
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
4020
|
+
* const custom = fWorkbook.getCustomMetadata();
|
|
4021
|
+
* ```
|
|
4022
|
+
*/
|
|
4023
|
+
getCustomMetadata() {
|
|
4024
|
+
return this._workbook.getCustomMetadata();
|
|
4025
|
+
}
|
|
3338
4026
|
};
|
|
3339
|
-
I =
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
4027
|
+
I = an([
|
|
4028
|
+
C(1, u(b)),
|
|
4029
|
+
C(2, u(Le)),
|
|
4030
|
+
C(3, u(We)),
|
|
4031
|
+
C(4, J),
|
|
4032
|
+
C(5, l),
|
|
4033
|
+
C(6, ee),
|
|
4034
|
+
C(7, pe),
|
|
4035
|
+
C(8, u(Re)),
|
|
4036
|
+
C(9, Te)
|
|
3349
4037
|
], I);
|
|
3350
|
-
class
|
|
4038
|
+
class hn extends Ue {
|
|
4039
|
+
getCommandSheetTarget(e) {
|
|
4040
|
+
var o;
|
|
4041
|
+
const t = e.params;
|
|
4042
|
+
if (!t) return;
|
|
4043
|
+
const n = t.unitId ? this.getUniverSheet(t.unitId) : (o = this.getActiveWorkbook) == null ? void 0 : o.call(this);
|
|
4044
|
+
if (!n)
|
|
4045
|
+
return;
|
|
4046
|
+
const r = n.getSheetBySheetId(t.subUnitId || t.sheetId) || n.getActiveSheet();
|
|
4047
|
+
if (r)
|
|
4048
|
+
return { workbook: n, worksheet: r };
|
|
4049
|
+
}
|
|
4050
|
+
getSheetTarget(e, t) {
|
|
4051
|
+
const n = this.getUniverSheet(e);
|
|
4052
|
+
if (!n)
|
|
4053
|
+
return;
|
|
4054
|
+
const r = n.getSheetBySheetId(t);
|
|
4055
|
+
if (r)
|
|
4056
|
+
return { workbook: n, worksheet: r };
|
|
4057
|
+
}
|
|
4058
|
+
_initWorkbookEvent(e) {
|
|
4059
|
+
const t = e.get(J);
|
|
4060
|
+
this.disposeWithMe(
|
|
4061
|
+
t.unitDisposed$.subscribe((n) => {
|
|
4062
|
+
this._eventRegistry.get(this.Event.WorkbookDisposed) && n.type === R.UNIVER_SHEET && this.fireEvent(
|
|
4063
|
+
this.Event.WorkbookDisposed,
|
|
4064
|
+
{
|
|
4065
|
+
unitId: n.getUnitId(),
|
|
4066
|
+
unitType: n.type,
|
|
4067
|
+
snapshot: n.getSnapshot()
|
|
4068
|
+
}
|
|
4069
|
+
);
|
|
4070
|
+
})
|
|
4071
|
+
), this.disposeWithMe(
|
|
4072
|
+
t.unitAdded$.subscribe((n) => {
|
|
4073
|
+
if (this._eventRegistry.get(this.Event.WorkbookCreated) && n.type === R.UNIVER_SHEET) {
|
|
4074
|
+
const r = n, o = e.createInstance(I, r);
|
|
4075
|
+
this.fireEvent(
|
|
4076
|
+
this.Event.WorkbookCreated,
|
|
4077
|
+
{
|
|
4078
|
+
unitId: n.getUnitId(),
|
|
4079
|
+
type: n.type,
|
|
4080
|
+
workbook: o,
|
|
4081
|
+
unit: o
|
|
4082
|
+
}
|
|
4083
|
+
);
|
|
4084
|
+
}
|
|
4085
|
+
})
|
|
4086
|
+
);
|
|
4087
|
+
}
|
|
3351
4088
|
_initialize(e) {
|
|
3352
4089
|
const t = e.get(l);
|
|
3353
4090
|
this.disposeWithMe(
|
|
3354
4091
|
t.beforeCommandExecuted((n) => {
|
|
3355
|
-
var
|
|
4092
|
+
var r;
|
|
3356
4093
|
switch (n.id) {
|
|
3357
|
-
case
|
|
3358
|
-
const
|
|
4094
|
+
case x.id: {
|
|
4095
|
+
const o = n.params, { unitId: i, index: a, sheet: h } = o || {}, c = i ? this.getUniverSheet(i) : (r = this.getActiveWorkbook) == null ? void 0 : r.call(this);
|
|
3359
4096
|
if (!c)
|
|
3360
4097
|
return;
|
|
3361
4098
|
const d = {
|
|
@@ -3367,17 +4104,17 @@ class sn extends Re {
|
|
|
3367
4104
|
this.Event.BeforeSheetCreate,
|
|
3368
4105
|
d
|
|
3369
4106
|
), d.cancel)
|
|
3370
|
-
throw new
|
|
4107
|
+
throw new qe();
|
|
3371
4108
|
break;
|
|
3372
4109
|
}
|
|
3373
4110
|
}
|
|
3374
4111
|
})
|
|
3375
4112
|
), this.disposeWithMe(
|
|
3376
4113
|
t.onCommandExecuted((n) => {
|
|
3377
|
-
var
|
|
4114
|
+
var r;
|
|
3378
4115
|
switch (n.id) {
|
|
3379
|
-
case
|
|
3380
|
-
const
|
|
4116
|
+
case x.id: {
|
|
4117
|
+
const o = n.params, { unitId: i } = o || {}, a = i ? this.getUniverSheet(i) : (r = this.getActiveWorkbook) == null ? void 0 : r.call(this);
|
|
3381
4118
|
if (!a)
|
|
3382
4119
|
return;
|
|
3383
4120
|
const h = a.getActiveSheet();
|
|
@@ -3395,66 +4132,78 @@ class sn extends Re {
|
|
|
3395
4132
|
}
|
|
3396
4133
|
}
|
|
3397
4134
|
})
|
|
3398
|
-
);
|
|
4135
|
+
), this._initWorkbookEvent(e);
|
|
3399
4136
|
}
|
|
3400
4137
|
createUniverSheet(e) {
|
|
3401
|
-
const n = this._injector.get(
|
|
4138
|
+
const n = this._injector.get(J).createUnit(R.UNIVER_SHEET, e);
|
|
3402
4139
|
return this._injector.createInstance(I, n);
|
|
3403
4140
|
}
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
return e ? this._injector.createInstance(I, e) : null;
|
|
4141
|
+
createWorkbook(e) {
|
|
4142
|
+
return this.createUniverSheet(e);
|
|
3407
4143
|
}
|
|
3408
4144
|
getActiveWorkbook() {
|
|
3409
|
-
|
|
4145
|
+
const e = this._univerInstanceService.getCurrentUnitForType(R.UNIVER_SHEET);
|
|
4146
|
+
return e ? this._injector.createInstance(I, e) : null;
|
|
4147
|
+
}
|
|
4148
|
+
getActiveUniverSheet() {
|
|
4149
|
+
return this.getActiveWorkbook();
|
|
3410
4150
|
}
|
|
3411
4151
|
getUniverSheet(e) {
|
|
3412
|
-
const t = this._univerInstanceService.getUnit(e,
|
|
4152
|
+
const t = this._univerInstanceService.getUnit(e, R.UNIVER_SHEET);
|
|
3413
4153
|
return t ? this._injector.createInstance(I, t) : null;
|
|
3414
4154
|
}
|
|
4155
|
+
getWorkbook(e) {
|
|
4156
|
+
return this.getUniverSheet(e);
|
|
4157
|
+
}
|
|
3415
4158
|
getPermission() {
|
|
3416
|
-
return this._injector.createInstance(
|
|
4159
|
+
return this._injector.createInstance(O);
|
|
3417
4160
|
}
|
|
3418
4161
|
onUniverSheetCreated(e) {
|
|
3419
|
-
const t = this._univerInstanceService.getTypeOfUnitAdded$(
|
|
3420
|
-
const
|
|
3421
|
-
e(
|
|
4162
|
+
const t = this._univerInstanceService.getTypeOfUnitAdded$(R.UNIVER_SHEET).subscribe((n) => {
|
|
4163
|
+
const r = this._injector.createInstance(I, n);
|
|
4164
|
+
e(r);
|
|
3422
4165
|
});
|
|
3423
|
-
return
|
|
4166
|
+
return F(t);
|
|
3424
4167
|
}
|
|
3425
4168
|
newDefinedName() {
|
|
3426
|
-
return this._injector.createInstance(
|
|
4169
|
+
return this._injector.createInstance(L);
|
|
3427
4170
|
}
|
|
3428
4171
|
}
|
|
3429
|
-
|
|
3430
|
-
class
|
|
4172
|
+
Ue.extend(hn);
|
|
4173
|
+
class cn extends se {
|
|
3431
4174
|
get SheetCreated() {
|
|
3432
4175
|
return "SheetCreated";
|
|
3433
4176
|
}
|
|
3434
4177
|
get BeforeSheetCreate() {
|
|
3435
4178
|
return "BeforeSheetCreate";
|
|
3436
4179
|
}
|
|
4180
|
+
get WorkbookCreated() {
|
|
4181
|
+
return "WorkbookCreated";
|
|
4182
|
+
}
|
|
4183
|
+
get WorkbookDisposed() {
|
|
4184
|
+
return "WorkbookDisposed";
|
|
4185
|
+
}
|
|
3437
4186
|
}
|
|
3438
|
-
|
|
3439
|
-
var
|
|
3440
|
-
for (var
|
|
3441
|
-
(i = o
|
|
3442
|
-
return n &&
|
|
3443
|
-
},
|
|
3444
|
-
let
|
|
3445
|
-
constructor(
|
|
3446
|
-
super(), this._injector =
|
|
4187
|
+
se.extend(cn);
|
|
4188
|
+
var dn = Object.defineProperty, un = Object.getOwnPropertyDescriptor, mn = (s, e, t, n) => {
|
|
4189
|
+
for (var r = n > 1 ? void 0 : n ? un(e, t) : e, o = s.length - 1, i; o >= 0; o--)
|
|
4190
|
+
(i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
|
|
4191
|
+
return n && r && dn(e, t, r), r;
|
|
4192
|
+
}, ln = (s, e) => (t, n) => e(t, n, s);
|
|
4193
|
+
let fe = class extends te {
|
|
4194
|
+
constructor(s) {
|
|
4195
|
+
super(), this._injector = s;
|
|
3447
4196
|
}
|
|
3448
4197
|
};
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
],
|
|
4198
|
+
fe = mn([
|
|
4199
|
+
ln(0, u(b))
|
|
4200
|
+
], fe);
|
|
3452
4201
|
export {
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
4202
|
+
O as FPermission,
|
|
4203
|
+
w as FRange,
|
|
4204
|
+
B as FSelection,
|
|
4205
|
+
cn as FSheetEventName,
|
|
4206
|
+
fe as FSheetHooks,
|
|
3458
4207
|
I as FWorkbook,
|
|
3459
4208
|
g as FWorksheet
|
|
3460
4209
|
};
|