@univerjs/sheets-ui 0.5.3 → 0.5.4
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 +30 -28
- package/lib/es/facade.js +490 -117
- package/lib/es/index.js +10728 -11062
- package/lib/index.css +1 -1
- package/lib/types/commands/commands/clipboard.command.d.ts +1 -0
- package/lib/types/components/hook.d.ts +2 -0
- package/lib/types/controllers/clipboard/clipboard.controller.d.ts +4 -2
- package/lib/types/controllers/clipboard/const.d.ts +16 -0
- package/lib/types/controllers/clipboard/utils.d.ts +63 -0
- package/lib/types/controllers/config.schema.d.ts +3 -0
- package/lib/types/controllers/force-string-alert-render.controller.d.ts +5 -1
- package/lib/types/controllers/permission/sheet-permission-check-ui.controller.d.ts +24 -0
- package/lib/types/controllers/permission/sheet-permission-interceptor-canvas-render.controller.d.ts +0 -1
- package/lib/types/controllers/permission/sheet-permission-interceptor-clipboard.controller.d.ts +3 -4
- package/lib/types/controllers/permission/sheet-permission-interceptor-formula-render.controller.d.ts +0 -1
- package/lib/types/controllers/render-controllers/scroll.render-controller.d.ts +7 -4
- package/lib/types/facade/f-event.d.ts +389 -0
- package/lib/types/facade/f-permission.d.ts +4 -1
- package/lib/types/facade/f-range.d.ts +48 -5
- package/lib/types/facade/f-sheet-hooks.d.ts +50 -12
- package/lib/types/facade/f-univer.d.ts +15 -16
- package/lib/types/facade/f-workbook.d.ts +43 -28
- package/lib/types/facade/f-worksheet.d.ts +24 -11
- package/lib/types/facade/index.d.ts +3 -1
- package/lib/types/index.d.ts +13 -14
- package/lib/types/services/clipboard/clipboard.service.d.ts +25 -10
- package/lib/types/services/clipboard/type.d.ts +18 -2
- package/lib/types/services/hover-manager.service.d.ts +6 -0
- package/lib/types/services/scroll-manager.service.d.ts +10 -2
- package/lib/types/services/selection/base-selection-render.service.d.ts +3 -3
- package/lib/types/services/selection/selection-render.service.d.ts +4 -0
- package/lib/types/views/cell-alert/CellAlertPopup.d.ts +6 -1
- package/lib/types/views/clipboard/ClipboardPopupMenu.d.ts +2 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +28 -26
- package/package.json +15 -14
- package/lib/types/controllers/permission/sheet-permission-init.controller.d.ts +0 -26
- package/lib/types/controllers/permission/sheet-permission-interceptor-base.controller.d.ts +0 -36
- package/lib/types/controllers/permission/sheet-permission-view-model.controller.d.ts +0 -11
package/lib/es/facade.js
CHANGED
|
@@ -1,11 +1,236 @@
|
|
|
1
|
-
import { FUniver as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
1
|
+
import { FUniver as V, ICommandService as p, IUniverInstanceService as B, CanceledError as U, RichTextValue as j, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as I, ILogService as y, toDisposable as a, FEventName as $, awaitTime as J, InterceptorEffectEnum as q, DisposableCollection as G, generateRandomId as Q } from "@univerjs/core";
|
|
2
|
+
import { RichTextEditingMutation as ee } from "@univerjs/docs";
|
|
3
|
+
import { IRenderManagerService as g, DeviceInputEventType as T, SHEET_VIEWPORT_KEY as te, sheetContentViewportKeys as re } from "@univerjs/engine-render";
|
|
4
|
+
import { SetCellEditVisibleOperation as b, IEditorBridgeService as M, SheetPasteShortKeyCommand as A, ISheetClipboardService as K, SHEET_VIEW_KEY as E, HoverManagerService as m, DragManagerService as k, SheetScrollManagerService as R, ISheetSelectionRenderService as _, SheetSkeletonManagerService as x, ChangeZoomRatioCommand as ne, SheetsScrollRenderController as ie, SheetCanvasPopManagerService as oe, CellAlertManagerService as se, IMarkSelectionService as ae } from "@univerjs/sheets-ui";
|
|
5
|
+
import { FSheetHooks as D, FWorkbook as Y, FWorksheet as Z, FPermission as z, FRange as X } from "@univerjs/sheets/facade";
|
|
6
|
+
import { KeyCode as P, CutCommand as O, CopyCommand as W, PasteCommand as H, IClipboardInterfaceService as ce, PLAIN_TEXT_CLIPBOARD_MIME_TYPE as F, HTML_CLIPBOARD_MIME_TYPE as L, supportClipboardAPI as N, ISidebarService as le, IDialogService as de, ComponentManager as he } from "@univerjs/ui";
|
|
7
|
+
import { filter as w } from "rxjs";
|
|
8
|
+
import { SheetInterceptorService as ge, INTERCEPTOR_POINT as ve, InterceptCellContentPriority as Ce } from "@univerjs/sheets";
|
|
9
|
+
class ue extends V {
|
|
10
|
+
// eslint-disable-next-line max-lines-per-function
|
|
11
|
+
_initSheetUIEvent(e) {
|
|
12
|
+
const t = e.get(p);
|
|
13
|
+
this.disposeWithMe(t.beforeCommandExecuted((r) => {
|
|
14
|
+
if (r.id === b.id) {
|
|
15
|
+
if (!this._eventListend(this.Event.BeforeSheetEditStart) && !this._eventListend(this.Event.BeforeSheetEditEnd))
|
|
16
|
+
return;
|
|
17
|
+
const n = this.getCommandSheetTarget(r);
|
|
18
|
+
if (!n)
|
|
19
|
+
return;
|
|
20
|
+
const { workbook: i, worksheet: o } = n, s = e.get(M), c = e.get(B), d = r.params, { visible: l, keycode: S, eventType: C } = d, v = s.getEditLocation();
|
|
21
|
+
if (l) {
|
|
22
|
+
const f = {
|
|
23
|
+
row: v.row,
|
|
24
|
+
column: v.column,
|
|
25
|
+
eventType: C,
|
|
26
|
+
keycode: S,
|
|
27
|
+
workbook: i,
|
|
28
|
+
worksheet: o,
|
|
29
|
+
isZenEditor: !1
|
|
30
|
+
};
|
|
31
|
+
if (this.fireEvent(this.Event.BeforeSheetEditStart, f), f.cancel)
|
|
32
|
+
throw new U();
|
|
33
|
+
} else {
|
|
34
|
+
const f = {
|
|
35
|
+
row: v.row,
|
|
36
|
+
column: v.column,
|
|
37
|
+
eventType: C,
|
|
38
|
+
keycode: S,
|
|
39
|
+
workbook: i,
|
|
40
|
+
worksheet: o,
|
|
41
|
+
isZenEditor: !1,
|
|
42
|
+
value: j.create(c.getUnit(I).getSnapshot()),
|
|
43
|
+
isConfirm: S !== P.ESC
|
|
44
|
+
};
|
|
45
|
+
if (this.fireEvent(this.Event.BeforeSheetEditEnd, f), f.cancel)
|
|
46
|
+
throw new U();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
})), this.disposeWithMe(t.onCommandExecuted((r) => {
|
|
50
|
+
if (r.id === b.id) {
|
|
51
|
+
if (!this._eventListend(this.Event.SheetEditStarted) && !this._eventListend(this.Event.SheetEditEnded))
|
|
52
|
+
return;
|
|
53
|
+
const n = this.getCommandSheetTarget(r);
|
|
54
|
+
if (!n)
|
|
55
|
+
return;
|
|
56
|
+
const { workbook: i, worksheet: o } = n, s = e.get(M), c = r.params, { visible: d, keycode: l, eventType: S } = c, C = s.getEditLocation();
|
|
57
|
+
if (d) {
|
|
58
|
+
const v = {
|
|
59
|
+
row: C.row,
|
|
60
|
+
column: C.column,
|
|
61
|
+
eventType: S,
|
|
62
|
+
keycode: l,
|
|
63
|
+
workbook: i,
|
|
64
|
+
worksheet: o,
|
|
65
|
+
isZenEditor: !1
|
|
66
|
+
};
|
|
67
|
+
this.fireEvent(this.Event.SheetEditStarted, v);
|
|
68
|
+
} else {
|
|
69
|
+
const v = {
|
|
70
|
+
row: C.row,
|
|
71
|
+
column: C.column,
|
|
72
|
+
eventType: S,
|
|
73
|
+
keycode: l,
|
|
74
|
+
workbook: i,
|
|
75
|
+
worksheet: o,
|
|
76
|
+
isZenEditor: !1,
|
|
77
|
+
isConfirm: l !== P.ESC
|
|
78
|
+
};
|
|
79
|
+
this.fireEvent(this.Event.SheetEditEnded, v);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (r.id === ee.id) {
|
|
83
|
+
if (!this._eventListend(this.Event.SheetEditChanging))
|
|
84
|
+
return;
|
|
85
|
+
const n = this.getCommandSheetTarget(r);
|
|
86
|
+
if (!n)
|
|
87
|
+
return;
|
|
88
|
+
const { workbook: i, worksheet: o } = n, s = e.get(M), c = e.get(B), d = r.params;
|
|
89
|
+
if (!s.isVisible().visible) return;
|
|
90
|
+
const { unitId: l } = d;
|
|
91
|
+
if (l === I) {
|
|
92
|
+
const { row: S, column: C } = s.getEditLocation(), v = {
|
|
93
|
+
workbook: i,
|
|
94
|
+
worksheet: o,
|
|
95
|
+
row: S,
|
|
96
|
+
column: C,
|
|
97
|
+
value: j.create(c.getUnit(I).getSnapshot()),
|
|
98
|
+
isZenEditor: !1
|
|
99
|
+
};
|
|
100
|
+
this.fireEvent(this.Event.SheetEditChanging, v);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
_initialize(e) {
|
|
106
|
+
this._initSheetUIEvent(e);
|
|
107
|
+
const t = e.get(p);
|
|
108
|
+
this.disposeWithMe(t.beforeCommandExecuted((r) => {
|
|
109
|
+
switch (r.id) {
|
|
110
|
+
case W.id:
|
|
111
|
+
case O.id:
|
|
112
|
+
this._beforeClipboardChange();
|
|
113
|
+
break;
|
|
114
|
+
case A.id:
|
|
115
|
+
this._beforeClipboardPaste(r.params);
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
})), this.disposeWithMe(t.onCommandExecuted((r) => {
|
|
119
|
+
switch (r.id) {
|
|
120
|
+
case W.id:
|
|
121
|
+
case O.id:
|
|
122
|
+
this._clipboardChanged();
|
|
123
|
+
break;
|
|
124
|
+
case A.id:
|
|
125
|
+
this._clipboardPaste();
|
|
126
|
+
break;
|
|
127
|
+
case H.id:
|
|
128
|
+
this._clipboardPasteAsync();
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
})), this.disposeWithMe(t.beforeCommandExecuted(async (r) => {
|
|
132
|
+
switch (r.id) {
|
|
133
|
+
case H.id:
|
|
134
|
+
await this._beforeClipboardPasteAsync();
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
_generateClipboardCopyParam() {
|
|
140
|
+
const e = this.getActiveWorkbook(), t = e == null ? void 0 : e.getActiveSheet(), r = e == null ? void 0 : e.getActiveRange();
|
|
141
|
+
if (!e || !t || !r)
|
|
142
|
+
return;
|
|
143
|
+
const i = this._injector.get(K).generateCopyContent(e.getId(), t.getSheetId(), r.getRange());
|
|
144
|
+
if (!i)
|
|
145
|
+
return;
|
|
146
|
+
const { html: o, plain: s } = i;
|
|
147
|
+
return {
|
|
148
|
+
workbook: e,
|
|
149
|
+
worksheet: t,
|
|
150
|
+
text: s,
|
|
151
|
+
html: o,
|
|
152
|
+
fromSheet: t,
|
|
153
|
+
fromRange: r
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
_beforeClipboardChange() {
|
|
157
|
+
if (!this.hasEventCallback(this.Event.BeforeClipboardChange))
|
|
158
|
+
return;
|
|
159
|
+
const e = this._generateClipboardCopyParam();
|
|
160
|
+
if (e && (this.fireEvent(this.Event.BeforeClipboardChange, e), e.cancel))
|
|
161
|
+
throw new Error("Before clipboard change is canceled");
|
|
162
|
+
}
|
|
163
|
+
_clipboardChanged() {
|
|
164
|
+
if (!this.hasEventCallback(this.Event.ClipboardChanged))
|
|
165
|
+
return;
|
|
166
|
+
const e = this._generateClipboardCopyParam();
|
|
167
|
+
if (e && (this.fireEvent(this.Event.ClipboardChanged, e), e.cancel))
|
|
168
|
+
throw new Error("Clipboard changed is canceled");
|
|
169
|
+
}
|
|
170
|
+
_generateClipboardPasteParam(e) {
|
|
171
|
+
if (!e)
|
|
172
|
+
return;
|
|
173
|
+
const { htmlContent: t, textContent: r } = e, n = this.getActiveWorkbook(), i = n == null ? void 0 : n.getActiveSheet();
|
|
174
|
+
return !n || !i ? void 0 : {
|
|
175
|
+
workbook: n,
|
|
176
|
+
worksheet: i,
|
|
177
|
+
text: r,
|
|
178
|
+
html: t
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
async _generateClipboardPasteParamAsync() {
|
|
182
|
+
const e = this.getActiveWorkbook(), t = e == null ? void 0 : e.getActiveSheet();
|
|
183
|
+
if (!e || !t)
|
|
184
|
+
return;
|
|
185
|
+
const i = (await this._injector.get(ce).read())[0];
|
|
186
|
+
let o;
|
|
187
|
+
if (i) {
|
|
188
|
+
const s = i.types, c = s.indexOf(F) !== -1 ? await i.getType(F).then((l) => l && l.text()) : "", d = s.indexOf(L) !== -1 ? await i.getType(L).then((l) => l && l.text()) : "";
|
|
189
|
+
o = {
|
|
190
|
+
workbook: e,
|
|
191
|
+
worksheet: t,
|
|
192
|
+
text: c,
|
|
193
|
+
html: d
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
return o;
|
|
197
|
+
}
|
|
198
|
+
_beforeClipboardPaste(e) {
|
|
199
|
+
if (!this.hasEventCallback(this.Event.BeforeClipboardPaste))
|
|
200
|
+
return;
|
|
201
|
+
const t = this._generateClipboardPasteParam(e);
|
|
202
|
+
if (t && (this.fireEvent(this.Event.BeforeClipboardPaste, t), t.cancel))
|
|
203
|
+
throw new Error("Before clipboard paste is canceled");
|
|
204
|
+
}
|
|
205
|
+
_clipboardPaste(e) {
|
|
206
|
+
if (!this.hasEventCallback(this.Event.BeforeClipboardPaste))
|
|
207
|
+
return;
|
|
208
|
+
const t = this._generateClipboardPasteParam(e);
|
|
209
|
+
if (t && (this.fireEvent(this.Event.BeforeClipboardPaste, t), t.cancel))
|
|
210
|
+
throw new Error("Clipboard pasted is canceled");
|
|
211
|
+
}
|
|
212
|
+
async _beforeClipboardPasteAsync() {
|
|
213
|
+
if (!this.hasEventCallback(this.Event.BeforeClipboardPaste))
|
|
214
|
+
return;
|
|
215
|
+
if (!N()) {
|
|
216
|
+
this._injector.get(y).warn("[Facade]: The navigator object only supports the browser environment");
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const e = await this._generateClipboardPasteParamAsync();
|
|
220
|
+
if (e && (this.fireEvent(this.Event.BeforeClipboardPaste, e), e.cancel))
|
|
221
|
+
throw new Error("Before clipboard paste is canceled");
|
|
222
|
+
}
|
|
223
|
+
async _clipboardPasteAsync() {
|
|
224
|
+
if (!this.hasEventCallback(this.Event.ClipboardPasted))
|
|
225
|
+
return;
|
|
226
|
+
if (!N()) {
|
|
227
|
+
this._injector.get(y).warn("[Facade]: The navigator object only supports the browser environment");
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const e = await this._generateClipboardPasteParamAsync();
|
|
231
|
+
if (e && (this.fireEvent(this.Event.ClipboardPasted, e), e.cancel))
|
|
232
|
+
throw new Error("Clipboard pasted is canceled");
|
|
233
|
+
}
|
|
9
234
|
customizeColumnHeader(e) {
|
|
10
235
|
const t = this.getActiveWorkbook();
|
|
11
236
|
if (!t) {
|
|
@@ -13,7 +238,7 @@ class Z extends b {
|
|
|
13
238
|
return;
|
|
14
239
|
}
|
|
15
240
|
const r = t == null ? void 0 : t.getId();
|
|
16
|
-
this._getSheetRenderComponent(r,
|
|
241
|
+
this._getSheetRenderComponent(r, E.COLUMN).setCustomHeader(e);
|
|
17
242
|
}
|
|
18
243
|
customizeRowHeader(e) {
|
|
19
244
|
const t = this.getActiveWorkbook();
|
|
@@ -22,61 +247,118 @@ class Z extends b {
|
|
|
22
247
|
return;
|
|
23
248
|
}
|
|
24
249
|
const r = t == null ? void 0 : t.getId();
|
|
25
|
-
this._getSheetRenderComponent(r,
|
|
250
|
+
this._getSheetRenderComponent(r, E.ROW).setCustomHeader(e);
|
|
26
251
|
}
|
|
27
252
|
registerSheetRowHeaderExtension(e, ...t) {
|
|
28
|
-
const r = this._getSheetRenderComponent(e,
|
|
29
|
-
return
|
|
253
|
+
const r = this._getSheetRenderComponent(e, E.ROW), n = r.register(...t);
|
|
254
|
+
return a(() => {
|
|
30
255
|
n.dispose(), r.makeDirty(!0);
|
|
31
256
|
});
|
|
32
257
|
}
|
|
33
258
|
registerSheetColumnHeaderExtension(e, ...t) {
|
|
34
|
-
const r = this._getSheetRenderComponent(e,
|
|
35
|
-
return
|
|
259
|
+
const r = this._getSheetRenderComponent(e, E.COLUMN), n = r.register(...t);
|
|
260
|
+
return a(() => {
|
|
36
261
|
n.dispose(), r.makeDirty(!0);
|
|
37
262
|
});
|
|
38
263
|
}
|
|
39
264
|
registerSheetMainExtension(e, ...t) {
|
|
40
|
-
const r = this._getSheetRenderComponent(e,
|
|
41
|
-
return
|
|
265
|
+
const r = this._getSheetRenderComponent(e, E.MAIN), n = r.register(...t);
|
|
266
|
+
return a(() => {
|
|
42
267
|
n.dispose(), r.makeDirty(!0);
|
|
43
268
|
});
|
|
44
269
|
}
|
|
45
270
|
/**
|
|
46
271
|
* Get sheet render component from render by unitId and view key.
|
|
47
|
-
*
|
|
48
272
|
* @private
|
|
49
|
-
*
|
|
50
273
|
* @param {string} unitId The unit id of the spreadsheet.
|
|
51
274
|
* @param {SHEET_VIEW_KEY} viewKey The view key of the spreadsheet.
|
|
52
275
|
* @returns {Nullable<RenderComponentType>} The render component.
|
|
53
276
|
*/
|
|
54
277
|
_getSheetRenderComponent(e, t) {
|
|
55
|
-
const n = this._injector.get(
|
|
278
|
+
const n = this._injector.get(g).getRenderById(e);
|
|
56
279
|
if (!n)
|
|
57
280
|
throw new Error(`Render Unit with unitId ${e} not found`);
|
|
58
|
-
const { components:
|
|
59
|
-
if (!
|
|
281
|
+
const { components: i } = n, o = i.get(t);
|
|
282
|
+
if (!o)
|
|
60
283
|
throw new Error("Render component not found");
|
|
61
|
-
return
|
|
284
|
+
return o;
|
|
62
285
|
}
|
|
63
286
|
/**
|
|
64
287
|
* Get sheet hooks.
|
|
65
|
-
*
|
|
66
288
|
* @returns {FSheetHooks} FSheetHooks instance
|
|
67
289
|
*/
|
|
68
290
|
getSheetHooks() {
|
|
69
|
-
return this._injector.createInstance(
|
|
291
|
+
return this._injector.createInstance(D);
|
|
70
292
|
}
|
|
71
293
|
}
|
|
72
|
-
|
|
73
|
-
|
|
294
|
+
V.extend(ue);
|
|
295
|
+
const h = {
|
|
296
|
+
CellClicked: "CellClicked",
|
|
297
|
+
CellPointerDown: "CellPointerDown",
|
|
298
|
+
CellPointerUp: "CellPointerUp",
|
|
299
|
+
CellPointerMove: "CellPointerMove",
|
|
300
|
+
CellHover: "CellHover",
|
|
301
|
+
DragOver: "DragOver",
|
|
302
|
+
Drop: "Drop"
|
|
303
|
+
};
|
|
304
|
+
class Se extends $ {
|
|
305
|
+
get BeforeClipboardChange() {
|
|
306
|
+
return "BeforeClipboardChange";
|
|
307
|
+
}
|
|
308
|
+
get ClipboardChanged() {
|
|
309
|
+
return "ClipboardChanged";
|
|
310
|
+
}
|
|
311
|
+
get BeforeClipboardPaste() {
|
|
312
|
+
return "BeforeClipboardPaste";
|
|
313
|
+
}
|
|
314
|
+
get ClipboardPasted() {
|
|
315
|
+
return "ClipboardPasted";
|
|
316
|
+
}
|
|
317
|
+
get BeforeSheetEditStart() {
|
|
318
|
+
return "BeforeSheetEditStart";
|
|
319
|
+
}
|
|
320
|
+
get SheetEditStarted() {
|
|
321
|
+
return "SheetEditStarted";
|
|
322
|
+
}
|
|
323
|
+
get SheetEditChanging() {
|
|
324
|
+
return "SheetEditChanging";
|
|
325
|
+
}
|
|
326
|
+
get BeforeSheetEditEnd() {
|
|
327
|
+
return "BeforeSheetEditEnd";
|
|
328
|
+
}
|
|
329
|
+
get SheetEditEnded() {
|
|
330
|
+
return "SheetEditEnded";
|
|
331
|
+
}
|
|
332
|
+
get CellClicked() {
|
|
333
|
+
return h.CellClicked;
|
|
334
|
+
}
|
|
335
|
+
get CellHover() {
|
|
336
|
+
return h.CellHover;
|
|
337
|
+
}
|
|
338
|
+
get CellPointerDown() {
|
|
339
|
+
return h.CellPointerDown;
|
|
340
|
+
}
|
|
341
|
+
get CellPointerUp() {
|
|
342
|
+
return h.CellPointerUp;
|
|
343
|
+
}
|
|
344
|
+
get CellPointerMove() {
|
|
345
|
+
return h.CellPointerMove;
|
|
346
|
+
}
|
|
347
|
+
get DragOver() {
|
|
348
|
+
return "DragOver";
|
|
349
|
+
}
|
|
350
|
+
get Drop() {
|
|
351
|
+
return "Drop";
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
$.extend(Se);
|
|
355
|
+
class me extends Y {
|
|
74
356
|
openSiderbar(e) {
|
|
75
|
-
return this._logDeprecation("openSiderbar"), this._injector.get(
|
|
357
|
+
return this._logDeprecation("openSiderbar"), this._injector.get(le).open(e);
|
|
76
358
|
}
|
|
77
359
|
openDialog(e) {
|
|
78
360
|
this._logDeprecation("openDialog");
|
|
79
|
-
const r = this._injector.get(
|
|
361
|
+
const r = this._injector.get(de).open({
|
|
80
362
|
...e,
|
|
81
363
|
onClose: () => {
|
|
82
364
|
r.dispose();
|
|
@@ -85,60 +367,144 @@ class J extends R {
|
|
|
85
367
|
return r;
|
|
86
368
|
}
|
|
87
369
|
_logDeprecation(e) {
|
|
88
|
-
this._injector.get(
|
|
370
|
+
this._injector.get(y).warn("[FWorkbook]", `${e} is deprecated. Please use the function of the same name on "FUniver".`);
|
|
371
|
+
}
|
|
372
|
+
addUIEvent(e, t) {
|
|
373
|
+
const r = this.getActiveSheet(), n = {
|
|
374
|
+
workbook: this,
|
|
375
|
+
worksheet: r
|
|
376
|
+
};
|
|
377
|
+
switch (e) {
|
|
378
|
+
case h.CellClicked:
|
|
379
|
+
this.onCellClick((i) => {
|
|
380
|
+
this.fireEvent(this.Event.CellClicked, {
|
|
381
|
+
row: i.location.row,
|
|
382
|
+
column: i.location.col,
|
|
383
|
+
...n
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
break;
|
|
387
|
+
case h.CellPointerDown:
|
|
388
|
+
this.onCellPointerDown((i) => {
|
|
389
|
+
this.fireEvent(this.Event.CellPointerDown, this.generateCellParams(i));
|
|
390
|
+
});
|
|
391
|
+
break;
|
|
392
|
+
case h.CellPointerUp:
|
|
393
|
+
this.onCellPointerUp((i) => {
|
|
394
|
+
this.fireEvent(this.Event.CellPointerUp, this.generateCellParams(i));
|
|
395
|
+
});
|
|
396
|
+
break;
|
|
397
|
+
case h.CellPointerMove:
|
|
398
|
+
this.onCellPointerMove((i) => {
|
|
399
|
+
this.fireEvent(this.Event.CellPointerMove, this.generateCellParams(i));
|
|
400
|
+
});
|
|
401
|
+
break;
|
|
402
|
+
case h.CellHover:
|
|
403
|
+
this.onCellHover((i) => {
|
|
404
|
+
this.fireEvent(this.Event.CellHover, this.generateCellParams(i));
|
|
405
|
+
});
|
|
406
|
+
break;
|
|
407
|
+
case h.DragOver:
|
|
408
|
+
this.onDragOver((i) => {
|
|
409
|
+
this.fireEvent(this.Event.DragOver, {
|
|
410
|
+
row: i.location.row,
|
|
411
|
+
column: i.location.col,
|
|
412
|
+
...n
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
break;
|
|
416
|
+
case h.Drop:
|
|
417
|
+
this.onDrop((i) => {
|
|
418
|
+
this.fireEvent(this.Event.Drop, {
|
|
419
|
+
row: i.location.row,
|
|
420
|
+
column: i.location.col,
|
|
421
|
+
...n
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
return a(() => {
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
generateCellParams(e) {
|
|
429
|
+
const t = this.getActiveSheet();
|
|
430
|
+
return {
|
|
431
|
+
row: e.row,
|
|
432
|
+
column: e.col,
|
|
433
|
+
workbook: this,
|
|
434
|
+
worksheet: t
|
|
435
|
+
};
|
|
89
436
|
}
|
|
90
437
|
onCellClick(e) {
|
|
91
|
-
const t = this._injector.get(
|
|
92
|
-
return
|
|
93
|
-
t.currentClickedCell$.pipe(
|
|
438
|
+
const t = this._injector.get(m);
|
|
439
|
+
return a(
|
|
440
|
+
t.currentClickedCell$.pipe(w((r) => !!r)).subscribe((r) => {
|
|
441
|
+
e(r);
|
|
442
|
+
})
|
|
94
443
|
);
|
|
95
444
|
}
|
|
96
445
|
onCellHover(e) {
|
|
97
|
-
const t = this._injector.get(
|
|
98
|
-
return
|
|
99
|
-
t.currentRichText$.pipe(
|
|
446
|
+
const t = this._injector.get(m);
|
|
447
|
+
return a(
|
|
448
|
+
t.currentRichText$.pipe(w((r) => !!r)).subscribe(e)
|
|
100
449
|
);
|
|
101
450
|
}
|
|
102
451
|
onCellPointerDown(e) {
|
|
103
|
-
const t = this._injector.get(
|
|
104
|
-
return
|
|
452
|
+
const t = this._injector.get(m);
|
|
453
|
+
return a(
|
|
105
454
|
t.currentPointerDownCell$.subscribe(e)
|
|
106
455
|
);
|
|
107
456
|
}
|
|
108
457
|
onCellPointerUp(e) {
|
|
109
|
-
const t = this._injector.get(
|
|
110
|
-
return
|
|
458
|
+
const t = this._injector.get(m);
|
|
459
|
+
return a(
|
|
111
460
|
t.currentPointerUpCell$.subscribe(e)
|
|
112
461
|
);
|
|
113
462
|
}
|
|
114
|
-
|
|
115
|
-
const t = this._injector.get(
|
|
116
|
-
return
|
|
117
|
-
t.currentCellPosWithEvent$.pipe(
|
|
118
|
-
e(r, r.event
|
|
463
|
+
onCellPointerMove(e) {
|
|
464
|
+
const t = this._injector.get(m);
|
|
465
|
+
return a(
|
|
466
|
+
t.currentCellPosWithEvent$.pipe(w((r) => !!r)).subscribe((r) => {
|
|
467
|
+
e(r, r.event);
|
|
468
|
+
})
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
onDragOver(e) {
|
|
472
|
+
const t = this._injector.get(k);
|
|
473
|
+
return a(
|
|
474
|
+
t.currentCell$.pipe(w((r) => !!r)).subscribe((r) => {
|
|
475
|
+
e(r);
|
|
476
|
+
})
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
onDrop(e) {
|
|
480
|
+
const t = this._injector.get(k);
|
|
481
|
+
return a(
|
|
482
|
+
t.endCell$.pipe(w((r) => !!r)).subscribe((r) => {
|
|
483
|
+
e(r);
|
|
119
484
|
})
|
|
120
485
|
);
|
|
121
486
|
}
|
|
122
487
|
startEditing() {
|
|
123
|
-
return this._injector.get(
|
|
124
|
-
eventType:
|
|
488
|
+
return this._injector.get(p).syncExecuteCommand(b.id, {
|
|
489
|
+
eventType: T.Dblclick,
|
|
125
490
|
unitId: this._workbook.getUnitId(),
|
|
126
491
|
visible: !0
|
|
127
492
|
});
|
|
128
493
|
}
|
|
129
494
|
async endEditing(e) {
|
|
130
|
-
return this._injector.get(
|
|
131
|
-
eventType:
|
|
132
|
-
keycode: e ?
|
|
495
|
+
return this._injector.get(p).syncExecuteCommand(b.id, {
|
|
496
|
+
eventType: T.Keyboard,
|
|
497
|
+
keycode: e ? P.ENTER : P.ESC,
|
|
133
498
|
visible: !1,
|
|
134
499
|
unitId: this._workbook.getUnitId()
|
|
135
|
-
}), await
|
|
500
|
+
}), await J(0), !0;
|
|
136
501
|
}
|
|
137
502
|
endEditingAsync(e = !0) {
|
|
138
503
|
return this.endEditing(e);
|
|
139
504
|
}
|
|
140
505
|
/**
|
|
141
506
|
* Get scroll state of specified sheet.
|
|
507
|
+
* @param {string} sheetId - sheet id
|
|
142
508
|
* @returns {IScrollState} scroll state
|
|
143
509
|
* @example
|
|
144
510
|
* ``` ts
|
|
@@ -146,40 +512,40 @@ class J extends R {
|
|
|
146
512
|
* ```
|
|
147
513
|
*/
|
|
148
514
|
getScrollStateBySheetId(e) {
|
|
149
|
-
const t = this._workbook.getUnitId(), n = this._injector.get(
|
|
150
|
-
return n ? n.with(
|
|
515
|
+
const t = this._workbook.getUnitId(), n = this._injector.get(g).getRenderById(t);
|
|
516
|
+
return n ? n.with(R).getScrollStateByParam({ unitId: t, sheetId: e }) : null;
|
|
151
517
|
}
|
|
152
518
|
disableSelection() {
|
|
153
|
-
const e = this._workbook.getUnitId(), r = this._injector.get(
|
|
154
|
-
r && r.with(
|
|
519
|
+
const e = this._workbook.getUnitId(), r = this._injector.get(g).getRenderById(e);
|
|
520
|
+
return r && r.with(_).disableSelection(), this;
|
|
155
521
|
}
|
|
156
522
|
enableSelection() {
|
|
157
|
-
const e = this._workbook.getUnitId(), r = this._injector.get(
|
|
158
|
-
r && r.with(
|
|
523
|
+
const e = this._workbook.getUnitId(), r = this._injector.get(g).getRenderById(e);
|
|
524
|
+
return r && r.with(_).enableSelection(), this;
|
|
159
525
|
}
|
|
160
526
|
transparentSelection() {
|
|
161
|
-
const e = this._workbook.getUnitId(), r = this._injector.get(
|
|
162
|
-
r && r.with(
|
|
527
|
+
const e = this._workbook.getUnitId(), r = this._injector.get(g).getRenderById(e);
|
|
528
|
+
return r && r.with(_).transparentSelection(), this;
|
|
163
529
|
}
|
|
164
530
|
showSelection() {
|
|
165
|
-
const e = this._workbook.getUnitId(), r = this._injector.get(
|
|
166
|
-
r && r.with(
|
|
531
|
+
const e = this._workbook.getUnitId(), r = this._injector.get(g).getRenderById(e);
|
|
532
|
+
return r && r.with(_).showSelection(), this;
|
|
167
533
|
}
|
|
168
534
|
}
|
|
169
|
-
|
|
170
|
-
class
|
|
535
|
+
Y.extend(me);
|
|
536
|
+
class pe extends Z {
|
|
171
537
|
refreshCanvas() {
|
|
172
|
-
const e = this._injector.get(
|
|
538
|
+
const e = this._injector.get(g), t = this._fWorkbook.id, r = e.getRenderById(t);
|
|
173
539
|
if (!r)
|
|
174
540
|
throw new Error(`Render Unit with unitId ${t} not found`);
|
|
175
|
-
r.with(
|
|
541
|
+
r.with(x).reCalculate();
|
|
176
542
|
const n = r.mainComponent;
|
|
177
543
|
if (!n)
|
|
178
544
|
throw new Error("Main component not found");
|
|
179
|
-
n.makeDirty();
|
|
545
|
+
return n.makeDirty(), this;
|
|
180
546
|
}
|
|
181
547
|
zoom(e) {
|
|
182
|
-
return this._injector.get(
|
|
548
|
+
return this._injector.get(p).syncExecuteCommand(ne.id, {
|
|
183
549
|
unitId: this._workbook.getUnitId(),
|
|
184
550
|
subUnitId: this._worksheet.getSheetId(),
|
|
185
551
|
zoomRatio: e
|
|
@@ -189,7 +555,7 @@ class X extends M {
|
|
|
189
555
|
return this._worksheet.getZoomRatio();
|
|
190
556
|
}
|
|
191
557
|
getVisibleRange() {
|
|
192
|
-
const e = this._workbook.getUnitId(), r = this._injector.get(
|
|
558
|
+
const e = this._workbook.getUnitId(), r = this._injector.get(g).getRenderById(e);
|
|
193
559
|
let n = {
|
|
194
560
|
startColumn: 0,
|
|
195
561
|
startRow: 0,
|
|
@@ -197,60 +563,65 @@ class X extends M {
|
|
|
197
563
|
endRow: 0
|
|
198
564
|
};
|
|
199
565
|
if (!r) return n;
|
|
200
|
-
const
|
|
566
|
+
const o = r.with(x).getCurrentSkeleton();
|
|
567
|
+
if (!o) return n;
|
|
568
|
+
const s = o == null ? void 0 : o.getVisibleRanges();
|
|
201
569
|
if (!s) return n;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
for (const [E, u] of g)
|
|
206
|
-
T.indexOf(E) !== -1 && (n.startColumn = Math.min(n.startColumn, u.startColumn), n.startRow = Math.min(n.startRow, u.startRow), n.endColumn = Math.max(n.endColumn, u.endColumn), n.endRow = Math.max(n.endRow, u.endRow));
|
|
570
|
+
n = o.getVisibleRangeByViewport(te.VIEW_MAIN);
|
|
571
|
+
for (const [c, d] of s)
|
|
572
|
+
re.indexOf(c) !== -1 && (n.startColumn = Math.min(n.startColumn, d.startColumn), n.startRow = Math.min(n.startRow, d.startRow), n.endColumn = Math.max(n.endColumn, d.endColumn), n.endRow = Math.max(n.endRow, d.endRow));
|
|
207
573
|
return n;
|
|
208
574
|
}
|
|
209
575
|
scrollToCell(e, t) {
|
|
210
|
-
const r = this._workbook.getUnitId(),
|
|
211
|
-
|
|
576
|
+
const r = this._workbook.getUnitId(), i = this._injector.get(g).getRenderById(r);
|
|
577
|
+
return i && (i == null ? void 0 : i.with(ie)).scrollToCell(e, t), this;
|
|
212
578
|
}
|
|
213
579
|
getScrollState() {
|
|
214
|
-
const e =
|
|
215
|
-
|
|
580
|
+
const e = {
|
|
581
|
+
offsetX: 0,
|
|
582
|
+
offsetY: 0,
|
|
583
|
+
sheetViewStartColumn: 0,
|
|
584
|
+
sheetViewStartRow: 0
|
|
585
|
+
}, t = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), i = this._injector.get(g).getRenderById(t);
|
|
586
|
+
return i && i.with(R).getScrollStateByParam({ unitId: t, sheetId: r }) || e;
|
|
216
587
|
}
|
|
217
588
|
onScroll(e) {
|
|
218
|
-
var
|
|
219
|
-
const t = this._workbook.getUnitId(), n = (
|
|
589
|
+
var i;
|
|
590
|
+
const t = this._workbook.getUnitId(), n = (i = this._injector.get(g).getRenderById(t)) == null ? void 0 : i.with(R);
|
|
220
591
|
if (n) {
|
|
221
|
-
const
|
|
222
|
-
e(
|
|
592
|
+
const o = n.validViewportScrollInfo$.subscribe((s) => {
|
|
593
|
+
e(s);
|
|
223
594
|
});
|
|
224
|
-
return
|
|
595
|
+
return a(o);
|
|
225
596
|
}
|
|
226
|
-
return
|
|
597
|
+
return a(() => {
|
|
227
598
|
});
|
|
228
599
|
}
|
|
229
600
|
}
|
|
230
|
-
|
|
231
|
-
class
|
|
601
|
+
Z.extend(pe);
|
|
602
|
+
class be extends z {
|
|
232
603
|
setPermissionDialogVisible(e) {
|
|
233
604
|
this._permissionService.setShowComponents(e);
|
|
234
605
|
}
|
|
235
606
|
}
|
|
236
|
-
|
|
237
|
-
class
|
|
607
|
+
z.extend(be);
|
|
608
|
+
class fe extends D {
|
|
238
609
|
onCellPointerMove(e) {
|
|
239
|
-
return
|
|
610
|
+
return a(this._injector.get(m).currentPosition$.subscribe(e));
|
|
240
611
|
}
|
|
241
612
|
onCellPointerOver(e) {
|
|
242
|
-
return
|
|
613
|
+
return a(this._injector.get(m).currentCell$.subscribe(e));
|
|
243
614
|
}
|
|
244
615
|
onCellDragOver(e) {
|
|
245
|
-
return
|
|
616
|
+
return a(this._injector.get(k).currentCell$.subscribe(e));
|
|
246
617
|
}
|
|
247
618
|
onCellDrop(e) {
|
|
248
|
-
return
|
|
619
|
+
return a(this._injector.get(k).endCell$.subscribe(e));
|
|
249
620
|
}
|
|
250
|
-
onCellRender(e, t =
|
|
251
|
-
return this._injector.get(
|
|
621
|
+
onCellRender(e, t = q.Style, r = Ce.DATA_VALIDATION) {
|
|
622
|
+
return this._injector.get(ge).intercept(ve.CELL_CONTENT, {
|
|
252
623
|
effect: t,
|
|
253
|
-
handler: (n,
|
|
624
|
+
handler: (n, i, o) => o({
|
|
254
625
|
...n,
|
|
255
626
|
customRender: [
|
|
256
627
|
...(n == null ? void 0 : n.customRender) || [],
|
|
@@ -261,31 +632,31 @@ class G extends I {
|
|
|
261
632
|
});
|
|
262
633
|
}
|
|
263
634
|
onBeforeCellEdit(e) {
|
|
264
|
-
return this._injector.get(
|
|
635
|
+
return this._injector.get(p).beforeCommandExecuted((t) => {
|
|
265
636
|
const r = t.params;
|
|
266
|
-
t.id ===
|
|
637
|
+
t.id === b.id && r.visible && e(r);
|
|
267
638
|
});
|
|
268
639
|
}
|
|
269
640
|
onAfterCellEdit(e) {
|
|
270
|
-
return this._injector.get(
|
|
641
|
+
return this._injector.get(p).onCommandExecuted((t) => {
|
|
271
642
|
const r = t.params;
|
|
272
|
-
t.id ===
|
|
643
|
+
t.id === b.id && !r.visible && e(r);
|
|
273
644
|
});
|
|
274
645
|
}
|
|
275
646
|
}
|
|
276
|
-
|
|
277
|
-
class
|
|
647
|
+
D.extend(fe);
|
|
648
|
+
class Ee extends X {
|
|
278
649
|
getCell() {
|
|
279
|
-
const e = this._injector.get(
|
|
280
|
-
return e.getRenderById(t).with(
|
|
650
|
+
const e = this._injector.get(g), t = this._workbook.getUnitId(), r = this._worksheet.getSheetId();
|
|
651
|
+
return e.getRenderById(t).with(x).getWorksheetSkeleton(r).skeleton.getCellWithCoordByIndex(this._range.startRow, this._range.startColumn);
|
|
281
652
|
}
|
|
282
653
|
getCellRect() {
|
|
283
|
-
const { startX: e, startY: t, endX: r, endY: n } = this.getCell(),
|
|
284
|
-
return { ...
|
|
654
|
+
const { startX: e, startY: t, endX: r, endY: n } = this.getCell(), i = { x: e, y: t, width: r - e, height: n - t, top: t, left: e, bottom: n, right: r };
|
|
655
|
+
return { ...i, toJSON: () => JSON.stringify(i) };
|
|
285
656
|
}
|
|
286
657
|
generateHTML() {
|
|
287
658
|
var t;
|
|
288
|
-
const e = this._injector.get(
|
|
659
|
+
const e = this._injector.get(K).generateCopyContent(
|
|
289
660
|
this._workbook.getUnitId(),
|
|
290
661
|
this._worksheet.getSheetId(),
|
|
291
662
|
this._range
|
|
@@ -293,17 +664,19 @@ class Q extends y {
|
|
|
293
664
|
return (t = e == null ? void 0 : e.html) != null ? t : "";
|
|
294
665
|
}
|
|
295
666
|
attachPopup(e) {
|
|
296
|
-
|
|
667
|
+
var o, s, c;
|
|
668
|
+
e.direction = (o = e.direction) != null ? o : "horizontal", e.extraProps = (s = e.extraProps) != null ? s : {}, e.offset = (c = e.offset) != null ? c : [0, 0];
|
|
669
|
+
const { key: t, disposableCollection: r } = we(e, this._injector.get(he)), i = this._injector.get(oe).attachPopupToCell(
|
|
297
670
|
this._range.startRow,
|
|
298
671
|
this._range.startColumn,
|
|
299
672
|
{ ...e, componentKey: t },
|
|
300
673
|
this.getUnitId(),
|
|
301
674
|
this._worksheet.getSheetId()
|
|
302
675
|
);
|
|
303
|
-
return
|
|
676
|
+
return i ? (r.add(i), r) : (r.dispose(), null);
|
|
304
677
|
}
|
|
305
678
|
attachAlertPopup(e) {
|
|
306
|
-
const t = this._injector.get(
|
|
679
|
+
const t = this._injector.get(se), r = {
|
|
307
680
|
workbook: this._workbook,
|
|
308
681
|
worksheet: this._worksheet,
|
|
309
682
|
row: this._range.startRow,
|
|
@@ -321,24 +694,24 @@ class Q extends y {
|
|
|
321
694
|
};
|
|
322
695
|
}
|
|
323
696
|
highlight(e, t) {
|
|
324
|
-
const r = this._injector.get(
|
|
697
|
+
const r = this._injector.get(ae), n = r.addShape({ range: this._range, style: e, primary: t });
|
|
325
698
|
if (!n)
|
|
326
699
|
throw new Error("Failed to highlight current range");
|
|
327
|
-
return
|
|
700
|
+
return a(() => {
|
|
328
701
|
r.removeShape(n);
|
|
329
702
|
});
|
|
330
703
|
}
|
|
331
704
|
}
|
|
332
|
-
|
|
333
|
-
function
|
|
334
|
-
const { componentKey: t, isVue3: r } =
|
|
705
|
+
X.extend(Ee);
|
|
706
|
+
function we(u, e) {
|
|
707
|
+
const { componentKey: t, isVue3: r } = u;
|
|
335
708
|
let n;
|
|
336
|
-
const
|
|
337
|
-
return typeof t == "string" ? n = t : (n = `External_${
|
|
709
|
+
const i = new G();
|
|
710
|
+
return typeof t == "string" ? n = t : (n = `External_${Q(6)}`, i.add(e.register(n, t, { framework: r ? "vue3" : "react" }))), {
|
|
338
711
|
key: n,
|
|
339
|
-
disposableCollection:
|
|
712
|
+
disposableCollection: i
|
|
340
713
|
};
|
|
341
714
|
}
|
|
342
715
|
export {
|
|
343
|
-
|
|
716
|
+
we as transformComponentKey
|
|
344
717
|
};
|