@univerjs/sheets-thread-comment-ui 1.0.0-insiders.20260809-70eefdd → 1.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/README.md +16 -8
- package/lib/cjs/index.js +675 -156
- package/lib/cjs/locale/ar-SA.js +1 -0
- package/lib/cjs/locale/ca-ES.js +1 -0
- package/lib/cjs/locale/de-DE.js +1 -0
- package/lib/cjs/locale/en-US.js +1 -0
- package/lib/cjs/locale/es-ES.js +1 -0
- package/lib/cjs/locale/fa-IR.js +1 -0
- package/lib/cjs/locale/fr-FR.js +1 -0
- package/lib/cjs/locale/id-ID.js +1 -0
- package/lib/cjs/locale/it-IT.js +1 -0
- package/lib/cjs/locale/ja-JP.js +1 -0
- package/lib/cjs/locale/ko-KR.js +1 -0
- package/lib/cjs/locale/pl-PL.js +1 -0
- package/lib/cjs/locale/pt-BR.js +1 -0
- package/lib/cjs/locale/ru-RU.js +1 -0
- package/lib/cjs/locale/sk-SK.js +1 -0
- package/lib/cjs/locale/vi-VN.js +1 -0
- package/lib/cjs/locale/zh-CN.js +1 -0
- package/lib/cjs/locale/zh-HK.js +1 -0
- package/lib/cjs/locale/zh-TW.js +1 -0
- package/lib/es/index.js +676 -163
- package/lib/es/locale/ar-SA.js +1 -0
- package/lib/es/locale/ca-ES.js +1 -0
- package/lib/es/locale/de-DE.js +1 -0
- package/lib/es/locale/en-US.js +1 -0
- package/lib/es/locale/es-ES.js +1 -0
- package/lib/es/locale/fa-IR.js +1 -0
- package/lib/es/locale/fr-FR.js +1 -0
- package/lib/es/locale/id-ID.js +1 -0
- package/lib/es/locale/it-IT.js +1 -0
- package/lib/es/locale/ja-JP.js +1 -0
- package/lib/es/locale/ko-KR.js +1 -0
- package/lib/es/locale/pl-PL.js +1 -0
- package/lib/es/locale/pt-BR.js +1 -0
- package/lib/es/locale/ru-RU.js +1 -0
- package/lib/es/locale/sk-SK.js +1 -0
- package/lib/es/locale/vi-VN.js +1 -0
- package/lib/es/locale/zh-CN.js +1 -0
- package/lib/es/locale/zh-HK.js +1 -0
- package/lib/es/locale/zh-TW.js +1 -0
- package/lib/index.js +676 -163
- package/lib/locale/ar-SA.js +1 -0
- package/lib/locale/ca-ES.js +1 -0
- package/lib/locale/de-DE.js +1 -0
- package/lib/locale/en-US.js +1 -0
- package/lib/locale/es-ES.js +1 -0
- package/lib/locale/fa-IR.js +1 -0
- package/lib/locale/fr-FR.js +1 -0
- package/lib/locale/id-ID.js +1 -0
- package/lib/locale/it-IT.js +1 -0
- package/lib/locale/ja-JP.js +1 -0
- package/lib/locale/ko-KR.js +1 -0
- package/lib/locale/pl-PL.js +1 -0
- package/lib/locale/pt-BR.js +1 -0
- package/lib/locale/ru-RU.js +1 -0
- package/lib/locale/sk-SK.js +1 -0
- package/lib/locale/vi-VN.js +1 -0
- package/lib/locale/zh-CN.js +1 -0
- package/lib/locale/zh-HK.js +1 -0
- package/lib/locale/zh-TW.js +1 -0
- package/lib/types/commands/operations/comment.operation.d.ts +5 -0
- package/lib/types/commands/operations/mobile/show-add-sheet-comment.operation.d.ts +17 -0
- package/lib/types/controllers/mobile/components.controller.d.ts +22 -0
- package/lib/types/controllers/mobile/sheets-thread-comment.controller.d.ts +20 -0
- package/lib/types/controllers/render-controllers/drawing.render-controller.d.ts +35 -0
- package/lib/types/controllers/sheets-thread-comment-permission.controller.d.ts +1 -0
- package/lib/types/controllers/sheets-thread-comment-popup.controller.d.ts +2 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/locale/en-US.d.ts +1 -0
- package/lib/types/menu/menu.d.ts +11 -0
- package/lib/types/menu/mobile-menu.d.ts +35 -0
- package/lib/types/menu/mobile-schema.d.ts +17 -0
- package/lib/types/mobile-plugin.d.ts +31 -0
- package/lib/types/plugin.d.ts +3 -1
- package/lib/types/services/mobile/mobile-sheet-comment-draft.service.d.ts +31 -0
- package/lib/types/types/const.d.ts +1 -0
- package/lib/types/views/SheetsThreadCommentPanel.d.ts +5 -1
- package/lib/types/views/mobile/MobileSheetsThreadCommentPanel.d.ts +16 -0
- package/lib/umd/index.js +3 -1
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +15 -14
package/lib/es/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { CommandType, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Plugin, RANGE_TYPE, Range, Rectangle, Tools, UniverInstanceType, merge } from "@univerjs/core";
|
|
1
|
+
import { CommandType, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, IPermissionService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Plugin, RANGE_TYPE, Range, Rectangle, RxDisposable, ThemeService, Tools, UniverInstanceType, UserManagerService, merge, toDisposable } from "@univerjs/core";
|
|
2
|
+
import { IDrawingManagerService, UniverDrawingPlugin, getDrawingShapeKeyByDrawingSearch } from "@univerjs/drawing";
|
|
2
3
|
import { INTERCEPTOR_POINT, RangeProtectionPermissionViewPoint, SetWorksheetActiveOperation, SheetInterceptorService, SheetPermissionCheckController, SheetsSelectionsService, UniverSheetsPlugin, WorkbookCommentPermission, WorksheetViewPermission, getSheetCommandTarget } from "@univerjs/sheets";
|
|
3
4
|
import { SheetsThreadCommentModel, UniverSheetsThreadCommentPlugin } from "@univerjs/sheets-thread-comment";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { AddCommentCommand, AddCommentMutation, DeleteCommentCommand, DeleteCommentMutation, DeleteCommentTreeCommand, IThreadCommentDataSourceService, ResolveCommentCommand, ThreadCommentAnchorKind, ThreadCommentModel, UniverThreadCommentPlugin, UpdateCommentCommand, deserializeThreadCommentAnchor, serializeThreadCommentAnchor } from "@univerjs/thread-comment";
|
|
6
|
+
import { MobileThreadCommentPanel, SetActiveCommentOperation, ThreadCommentCanvasOverlay, ThreadCommentDraftService, ThreadCommentPanel, ThreadCommentPanelService, ThreadCommentTree, ThreadCommentTreeLocation, UniverThreadCommentMobileUIPlugin, UniverThreadCommentUIPlugin } from "@univerjs/thread-comment-ui";
|
|
7
|
+
import { ComponentManager, ContextMenuGroup, ContextMenuPosition, FloatingObjectToolbarPosition, IMenuManagerService, IShortcutService, ISidebarService, IconManager, KeyCode, MenuItemType, MetaKeys, RibbonInsertGroup, UniverMobileUIPlugin, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
|
|
8
|
+
import { COPY_TYPE, CellPopupManagerService, HoverManagerService, IEditorBridgeService, IMarkSelectionService, ISheetClipboardService, ScrollToRangeOperation, SheetCanvasPopManagerService, SheetSkeletonManagerService, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, deriveStateFromActiveSheet$, getCurrentRangeDisable$, whenSheetEditorFocused } from "@univerjs/sheets-ui";
|
|
9
|
+
import { BehaviorSubject, combineLatest, debounceTime, map, startWith } from "rxjs";
|
|
8
10
|
import { IRenderManagerService, UniverRenderEnginePlugin } from "@univerjs/engine-render";
|
|
9
|
-
import {
|
|
10
|
-
import { CommentIcon } from "@univerjs/icons";
|
|
11
|
-
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
import { CommentIcon, InsertCommentDoubleIcon } from "@univerjs/icons";
|
|
12
12
|
import { serializeRange, singleReferenceToGrid } from "@univerjs/engine-formula";
|
|
13
13
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
14
|
+
import { jsx } from "react/jsx-runtime";
|
|
14
15
|
|
|
15
16
|
//#region src/types/const.ts
|
|
16
17
|
/**
|
|
@@ -30,6 +31,7 @@ import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
|
30
31
|
*/
|
|
31
32
|
const SHEETS_THREAD_COMMENT_MODAL = "univer.sheet.thread-comment-modal";
|
|
32
33
|
const SHEETS_THREAD_COMMENT_PANEL = "univer.sheet.thread-comment-panel";
|
|
34
|
+
const SHOW_ADD_SHEET_COMMENT_OPERATION_ID = "sheet.operation.show-comment-modal";
|
|
33
35
|
const PLUGIN_NAME = "SHEET_THREAD_COMMENT_UI_PLUGIN";
|
|
34
36
|
|
|
35
37
|
//#endregion
|
|
@@ -168,7 +170,7 @@ SheetsThreadCommentPopupService = __decorate([__decorateParam(0, Inject(SheetCan
|
|
|
168
170
|
//#region src/commands/operations/comment.operation.ts
|
|
169
171
|
const ShowAddSheetCommentModalOperation = {
|
|
170
172
|
type: CommandType.OPERATION,
|
|
171
|
-
id:
|
|
173
|
+
id: SHOW_ADD_SHEET_COMMENT_OPERATION_ID,
|
|
172
174
|
handler(accessor) {
|
|
173
175
|
var _selectionManagerServ;
|
|
174
176
|
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
@@ -209,26 +211,84 @@ const ToggleSheetCommentPanelOperation = {
|
|
|
209
211
|
if (panelService.panelVisible) {
|
|
210
212
|
sidebarService.close();
|
|
211
213
|
panelService.setPanelVisible(false);
|
|
212
|
-
} else
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
214
|
+
} else openSheetCommentPanel(sidebarService, panelService);
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
const OpenSheetCommentPanelOperation = {
|
|
219
|
+
id: "sheet.operation.open-comment-panel",
|
|
220
|
+
type: CommandType.OPERATION,
|
|
221
|
+
handler(accessor) {
|
|
222
|
+
openSheetCommentPanel(accessor.get(ISidebarService), accessor.get(ThreadCommentPanelService));
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
function openSheetCommentPanel(sidebarService, panelService) {
|
|
227
|
+
var _sidebarService$optio;
|
|
228
|
+
if (!panelService.panelVisible || ((_sidebarService$optio = sidebarService.options.children) === null || _sidebarService$optio === void 0 ? void 0 : _sidebarService$optio.label) !== "univer.sheet.thread-comment-panel") sidebarService.open({
|
|
229
|
+
header: { title: "sheets-thread-comment-ui.panel.title" },
|
|
230
|
+
children: { label: SHEETS_THREAD_COMMENT_PANEL },
|
|
231
|
+
width: 360,
|
|
232
|
+
onClose: () => panelService.setPanelVisible(false)
|
|
233
|
+
});
|
|
234
|
+
panelService.setPanelVisible(true);
|
|
235
|
+
}
|
|
236
|
+
const AddSheetDrawingCommentOperation = {
|
|
237
|
+
id: "sheet.operation.add-drawing-comment",
|
|
238
|
+
type: CommandType.OPERATION,
|
|
239
|
+
handler(accessor) {
|
|
240
|
+
var _workbook$getActiveSh;
|
|
241
|
+
const drawing = accessor.get(IDrawingManagerService).getFocusDrawings()[0];
|
|
242
|
+
const workbook = accessor.get(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
243
|
+
if (!drawing || !workbook || drawing.unitId !== workbook.getUnitId() || drawing.subUnitId !== ((_workbook$getActiveSh = workbook.getActiveSheet()) === null || _workbook$getActiveSh === void 0 ? void 0 : _workbook$getActiveSh.getSheetId())) return false;
|
|
244
|
+
accessor.get(ThreadCommentDraftService).place({
|
|
245
|
+
unitId: drawing.unitId,
|
|
246
|
+
subUnitId: drawing.subUnitId,
|
|
247
|
+
anchor: {
|
|
248
|
+
kind: ThreadCommentAnchorKind.SHEET_DRAWING,
|
|
249
|
+
pageId: drawing.subUnitId,
|
|
250
|
+
elementId: drawing.drawingId
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
const panelService = accessor.get(ThreadCommentPanelService);
|
|
254
|
+
accessor.get(ISidebarService).open({
|
|
255
|
+
header: { title: "sheets-thread-comment-ui.panel.title" },
|
|
256
|
+
children: { label: SHEETS_THREAD_COMMENT_PANEL },
|
|
257
|
+
width: 360,
|
|
258
|
+
onClose: () => panelService.setPanelVisible(false)
|
|
259
|
+
});
|
|
260
|
+
panelService.setPanelVisible(true);
|
|
220
261
|
return true;
|
|
221
262
|
}
|
|
222
263
|
};
|
|
223
264
|
|
|
224
265
|
//#endregion
|
|
225
266
|
//#region src/menu/menu.ts
|
|
267
|
+
function getDrawingCommentDisable$(accessor) {
|
|
268
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
269
|
+
const permissionService = accessor.get(IPermissionService);
|
|
270
|
+
return deriveStateFromActiveSheet$(univerInstanceService, true, ({ workbook, worksheet }) => {
|
|
271
|
+
const unitId = workbook.getUnitId();
|
|
272
|
+
const subUnitId = worksheet.getSheetId();
|
|
273
|
+
return permissionService.composePermission$([new WorkbookCommentPermission(unitId).id, new WorksheetViewPermission(unitId, subUnitId).id]).pipe(map((permissions) => permissions.some((permission) => permission.value === false)));
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
const drawingCommentMenuFactory = (accessor) => ({
|
|
277
|
+
id: AddSheetDrawingCommentOperation.id,
|
|
278
|
+
type: MenuItemType.BUTTON,
|
|
279
|
+
icon: "InsertCommentDoubleIcon",
|
|
280
|
+
title: "sheets-thread-comment-ui.menu.addComment",
|
|
281
|
+
tooltip: "sheets-thread-comment-ui.menu.addComment",
|
|
282
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
283
|
+
disabled$: getDrawingCommentDisable$(accessor)
|
|
284
|
+
});
|
|
226
285
|
const threadCommentMenuFactory = (accessor) => {
|
|
227
286
|
return {
|
|
228
287
|
id: ShowAddSheetCommentModalOperation.id,
|
|
229
288
|
type: MenuItemType.BUTTON,
|
|
230
|
-
icon: "
|
|
289
|
+
icon: "InsertCommentDoubleIcon",
|
|
231
290
|
title: "sheets-thread-comment-ui.menu.addComment",
|
|
291
|
+
tooltip: "sheets-thread-comment-ui.menu.addComment",
|
|
232
292
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
233
293
|
disabled$: getCurrentRangeDisable$(accessor, {
|
|
234
294
|
workbookTypes: [WorkbookCommentPermission],
|
|
@@ -242,7 +302,8 @@ const threadPanelMenuFactory = (accessor) => {
|
|
|
242
302
|
id: ToggleSheetCommentPanelOperation.id,
|
|
243
303
|
type: MenuItemType.BUTTON,
|
|
244
304
|
icon: "CommentIcon",
|
|
245
|
-
|
|
305
|
+
title: "sheets-thread-comment-ui.menu.openComments",
|
|
306
|
+
tooltip: "sheets-thread-comment-ui.menu.openComments",
|
|
246
307
|
disabled$: getCurrentRangeDisable$(accessor, {
|
|
247
308
|
workbookTypes: [WorkbookCommentPermission],
|
|
248
309
|
worksheetTypes: [WorksheetViewPermission],
|
|
@@ -260,26 +321,103 @@ const AddCommentShortcut = {
|
|
|
260
321
|
//#endregion
|
|
261
322
|
//#region src/menu/schema.ts
|
|
262
323
|
const menuSchema = {
|
|
263
|
-
[RibbonInsertGroup.MEDIA]: {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
324
|
+
[RibbonInsertGroup.MEDIA]: {
|
|
325
|
+
[ToggleSheetCommentPanelOperation.id]: {
|
|
326
|
+
order: 2,
|
|
327
|
+
gridLayout: {
|
|
328
|
+
row: 1,
|
|
329
|
+
column: 3,
|
|
330
|
+
showLabel: true
|
|
331
|
+
},
|
|
332
|
+
menuItemFactory: threadPanelMenuFactory
|
|
270
333
|
},
|
|
271
|
-
|
|
272
|
-
|
|
334
|
+
[ShowAddSheetCommentModalOperation.id]: {
|
|
335
|
+
order: 2.1,
|
|
336
|
+
gridLayout: {
|
|
337
|
+
row: 2,
|
|
338
|
+
column: 3,
|
|
339
|
+
showLabel: true
|
|
340
|
+
},
|
|
341
|
+
menuItemFactory: threadCommentMenuFactory
|
|
342
|
+
}
|
|
343
|
+
},
|
|
273
344
|
[ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.OTHERS]: { [ShowAddSheetCommentModalOperation.id]: {
|
|
274
345
|
order: 0,
|
|
275
346
|
menuItemFactory: threadCommentMenuFactory
|
|
347
|
+
} } },
|
|
348
|
+
[FloatingObjectToolbarPosition.SHEET]: { [AddSheetDrawingCommentOperation.id]: {
|
|
349
|
+
order: 10,
|
|
350
|
+
menuItemFactory: drawingCommentMenuFactory
|
|
351
|
+
} },
|
|
352
|
+
[ContextMenuPosition.DRAWING]: { [ContextMenuGroup.OTHERS]: { [AddSheetDrawingCommentOperation.id]: {
|
|
353
|
+
order: 0,
|
|
354
|
+
menuItemFactory: drawingCommentMenuFactory
|
|
276
355
|
} } }
|
|
277
356
|
};
|
|
278
357
|
|
|
279
358
|
//#endregion
|
|
280
359
|
//#region package.json
|
|
281
360
|
var name = "@univerjs/sheets-thread-comment-ui";
|
|
282
|
-
var version = "1.0.0-
|
|
361
|
+
var version = "1.0.0-rc.0";
|
|
362
|
+
|
|
363
|
+
//#endregion
|
|
364
|
+
//#region src/services/mobile/mobile-sheet-comment-draft.service.ts
|
|
365
|
+
var MobileSheetCommentDraftService = class extends Disposable {
|
|
366
|
+
constructor() {
|
|
367
|
+
super();
|
|
368
|
+
_defineProperty(this, "_draft$", new BehaviorSubject(null));
|
|
369
|
+
_defineProperty(this, "draft$", this._draft$.asObservable());
|
|
370
|
+
this.disposeWithMe(() => this._draft$.complete());
|
|
371
|
+
}
|
|
372
|
+
get draft() {
|
|
373
|
+
return this._draft$.getValue();
|
|
374
|
+
}
|
|
375
|
+
place(draft) {
|
|
376
|
+
this._draft$.next(draft);
|
|
377
|
+
}
|
|
378
|
+
cancel() {
|
|
379
|
+
this._draft$.next(null);
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region src/commands/operations/mobile/show-add-sheet-comment.operation.ts
|
|
385
|
+
const ShowAddSheetCommentMobileOperation = {
|
|
386
|
+
type: CommandType.OPERATION,
|
|
387
|
+
id: SHOW_ADD_SHEET_COMMENT_OPERATION_ID,
|
|
388
|
+
handler(accessor) {
|
|
389
|
+
var _accessor$get$getCurr;
|
|
390
|
+
const activeCell = (_accessor$get$getCurr = accessor.get(SheetsSelectionsService).getCurrentLastSelection()) === null || _accessor$get$getCurr === void 0 ? void 0 : _accessor$get$getCurr.primary;
|
|
391
|
+
if (!activeCell) return false;
|
|
392
|
+
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
393
|
+
if (!target) return false;
|
|
394
|
+
const { unitId, subUnitId } = target;
|
|
395
|
+
const row = activeCell.startRow;
|
|
396
|
+
const column = activeCell.startColumn;
|
|
397
|
+
const panelService = accessor.get(ThreadCommentPanelService);
|
|
398
|
+
const mobileDraftService = accessor.get(MobileSheetCommentDraftService);
|
|
399
|
+
const rootId = accessor.get(SheetsThreadCommentModel).getByLocation(unitId, subUnitId, row, column);
|
|
400
|
+
accessor.get(ThreadCommentDraftService).cancel();
|
|
401
|
+
if (rootId) {
|
|
402
|
+
mobileDraftService.cancel();
|
|
403
|
+
panelService.setActiveComment({
|
|
404
|
+
unitId,
|
|
405
|
+
subUnitId,
|
|
406
|
+
commentId: rootId
|
|
407
|
+
});
|
|
408
|
+
} else {
|
|
409
|
+
panelService.setActiveComment(void 0);
|
|
410
|
+
mobileDraftService.place({
|
|
411
|
+
unitId,
|
|
412
|
+
subUnitId,
|
|
413
|
+
row,
|
|
414
|
+
column
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
openSheetCommentPanel(accessor.get(ISidebarService), panelService);
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
420
|
+
};
|
|
283
421
|
|
|
284
422
|
//#endregion
|
|
285
423
|
//#region src/config/config.ts
|
|
@@ -287,43 +425,9 @@ const SHEETS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY = "sheets-thread-comment.config
|
|
|
287
425
|
const configSymbol = Symbol(SHEETS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY);
|
|
288
426
|
const defaultPluginConfig = {};
|
|
289
427
|
|
|
290
|
-
//#endregion
|
|
291
|
-
//#region src/views/SheetsThreadCommentCell.tsx
|
|
292
|
-
const SheetsThreadCommentCell = () => {
|
|
293
|
-
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
294
|
-
const sheetsThreadCommentPopupService = useDependency(SheetsThreadCommentPopupService);
|
|
295
|
-
const activePopup = useObservable(sheetsThreadCommentPopupService.activePopup$);
|
|
296
|
-
const sheetThreadCommentModel = useDependency(SheetsThreadCommentModel);
|
|
297
|
-
const rootId = useObservable(activePopup ? () => sheetThreadCommentModel.commentUpdate$.pipe(map(() => sheetThreadCommentModel.getByLocation(activePopup.unitId, activePopup.subUnitId, activePopup.row, activePopup.col)), startWith(sheetThreadCommentModel.getByLocation(activePopup.unitId, activePopup.subUnitId, activePopup.row, activePopup.col))) : null, void 0, false, [activePopup, sheetThreadCommentModel]);
|
|
298
|
-
if (!activePopup) return null;
|
|
299
|
-
const { row, col, unitId, subUnitId, trigger } = activePopup;
|
|
300
|
-
const ref = `${Tools.chatAtABC(col)}${row + 1}`;
|
|
301
|
-
const onClose = () => {
|
|
302
|
-
sheetsThreadCommentPopupService.hidePopup();
|
|
303
|
-
};
|
|
304
|
-
const getSubUnitName = (id) => {
|
|
305
|
-
var _univerInstanceServic;
|
|
306
|
-
return ((_univerInstanceServic = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic === void 0 || (_univerInstanceServic = _univerInstanceServic.getSheetBySheetId(id)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getName()) ?? "";
|
|
307
|
-
};
|
|
308
|
-
return /* @__PURE__ */ jsx(ThreadCommentTree, {
|
|
309
|
-
onClick: () => {
|
|
310
|
-
sheetsThreadCommentPopupService.persistPopup();
|
|
311
|
-
},
|
|
312
|
-
location: ThreadCommentTreeLocation.CELL,
|
|
313
|
-
id: rootId,
|
|
314
|
-
unitId,
|
|
315
|
-
subUnitId,
|
|
316
|
-
type: UniverInstanceType.UNIVER_SHEET,
|
|
317
|
-
refStr: ref,
|
|
318
|
-
onClose,
|
|
319
|
-
getSubUnitName,
|
|
320
|
-
autoFocus: trigger === "context-menu"
|
|
321
|
-
});
|
|
322
|
-
};
|
|
323
|
-
|
|
324
428
|
//#endregion
|
|
325
429
|
//#region src/views/SheetsThreadCommentPanel.tsx
|
|
326
|
-
const SheetsThreadCommentPanel = () => {
|
|
430
|
+
const SheetsThreadCommentPanel = ({ ThreadCommentPanelComponent = ThreadCommentPanel } = {}) => {
|
|
327
431
|
var _workbook$getActiveSh;
|
|
328
432
|
const markSelectionService = useDependency(IMarkSelectionService);
|
|
329
433
|
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
@@ -331,6 +435,19 @@ const SheetsThreadCommentPanel = () => {
|
|
|
331
435
|
const workbook = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
332
436
|
const unitId = workbook.getUnitId();
|
|
333
437
|
const commandService = useDependency(ICommandService);
|
|
438
|
+
const draftService = useDependency(ThreadCommentDraftService);
|
|
439
|
+
const userManagerService = useDependency(UserManagerService);
|
|
440
|
+
const draft = useObservable(draftService.draft$, draftService.draft);
|
|
441
|
+
const tempDrawingComment = (draft === null || draft === void 0 ? void 0 : draft.anchor.kind) === ThreadCommentAnchorKind.SHEET_DRAWING && draft.unitId === unitId ? {
|
|
442
|
+
id: "",
|
|
443
|
+
threadId: "",
|
|
444
|
+
unitId: draft.unitId,
|
|
445
|
+
subUnitId: draft.subUnitId,
|
|
446
|
+
ref: serializeThreadCommentAnchor(draft.anchor),
|
|
447
|
+
dT: "",
|
|
448
|
+
personId: userManagerService.getCurrentUser().userID,
|
|
449
|
+
text: { dataStream: "\r\n" }
|
|
450
|
+
} : null;
|
|
334
451
|
const subUnitId$ = useMemo(() => workbook.activeSheet$.pipe(map((i) => i === null || i === void 0 ? void 0 : i.getSheetId())), [workbook.activeSheet$]);
|
|
335
452
|
const subUnitId = useObservable(subUnitId$, (_workbook$getActiveSh = workbook.getActiveSheet()) === null || _workbook$getActiveSh === void 0 ? void 0 : _workbook$getActiveSh.getSheetId());
|
|
336
453
|
const hoverShapeId = useRef(null);
|
|
@@ -345,6 +462,15 @@ const SheetsThreadCommentPanel = () => {
|
|
|
345
462
|
});
|
|
346
463
|
const sort = (comments) => {
|
|
347
464
|
return comments.map((comment) => {
|
|
465
|
+
const anchor = deserializeThreadCommentAnchor(comment.ref);
|
|
466
|
+
if ((anchor === null || anchor === void 0 ? void 0 : anchor.kind) === ThreadCommentAnchorKind.SHEET_DRAWING) return {
|
|
467
|
+
...comment,
|
|
468
|
+
p: [
|
|
469
|
+
sheetIndex[comment.subUnitId] ?? 0,
|
|
470
|
+
Number.MAX_SAFE_INTEGER,
|
|
471
|
+
0
|
|
472
|
+
]
|
|
473
|
+
};
|
|
348
474
|
const ref = singleReferenceToGrid(comment.ref);
|
|
349
475
|
const p = [
|
|
350
476
|
sheetIndex[comment.subUnitId] ?? 0,
|
|
@@ -366,6 +492,7 @@ const SheetsThreadCommentPanel = () => {
|
|
|
366
492
|
return [...sort(comments.filter((comment) => !comment.resolved)), ...sort(comments.filter((comment) => comment.resolved))];
|
|
367
493
|
}, [workbook]);
|
|
368
494
|
const showShape = useCallback((comment) => {
|
|
495
|
+
if (deserializeThreadCommentAnchor(comment.ref)) return null;
|
|
369
496
|
if (comment.unitId === unitId && comment.subUnitId === subUnitId && !comment.resolved) {
|
|
370
497
|
const { row, column } = singleReferenceToGrid(comment.ref);
|
|
371
498
|
const worksheet = workbook.getSheetBySheetId(comment.subUnitId);
|
|
@@ -422,7 +549,7 @@ const SheetsThreadCommentPanel = () => {
|
|
|
422
549
|
hoverShapeId.current = null;
|
|
423
550
|
}
|
|
424
551
|
}, [markSelectionService, panelVisible]);
|
|
425
|
-
return /* @__PURE__ */ jsx(
|
|
552
|
+
return /* @__PURE__ */ jsx(ThreadCommentPanelComponent, {
|
|
426
553
|
unitId,
|
|
427
554
|
subUnitId$,
|
|
428
555
|
type: UniverInstanceType.UNIVER_SHEET,
|
|
@@ -435,12 +562,50 @@ const SheetsThreadCommentPanel = () => {
|
|
|
435
562
|
onDeleteComment: () => {
|
|
436
563
|
handleLeave();
|
|
437
564
|
return true;
|
|
565
|
+
},
|
|
566
|
+
tempComment: tempDrawingComment,
|
|
567
|
+
onTempCommentClose: () => draftService.cancel(),
|
|
568
|
+
formatRef: (comment) => {
|
|
569
|
+
const anchor = deserializeThreadCommentAnchor(comment.ref);
|
|
570
|
+
return (anchor === null || anchor === void 0 ? void 0 : anchor.kind) === ThreadCommentAnchorKind.SHEET_DRAWING ? `#${anchor.elementId}` : comment.ref;
|
|
438
571
|
}
|
|
439
572
|
});
|
|
440
573
|
};
|
|
441
574
|
|
|
442
575
|
//#endregion
|
|
443
|
-
//#region src/
|
|
576
|
+
//#region src/views/mobile/MobileSheetsThreadCommentPanel.tsx
|
|
577
|
+
function MobileSheetsThreadCommentPanelContent(props) {
|
|
578
|
+
const draftService = useDependency(MobileSheetCommentDraftService);
|
|
579
|
+
const userManagerService = useDependency(UserManagerService);
|
|
580
|
+
const draft = useObservable(draftService.draft$, draftService.draft);
|
|
581
|
+
const tempCellComment = (draft === null || draft === void 0 ? void 0 : draft.unitId) === props.unitId ? {
|
|
582
|
+
id: "",
|
|
583
|
+
threadId: "",
|
|
584
|
+
unitId: draft.unitId,
|
|
585
|
+
subUnitId: draft.subUnitId,
|
|
586
|
+
ref: `${Tools.chatAtABC(draft.column)}${draft.row + 1}`,
|
|
587
|
+
dT: "",
|
|
588
|
+
personId: userManagerService.getCurrentUser().userID,
|
|
589
|
+
text: { dataStream: "\r\n" }
|
|
590
|
+
} : null;
|
|
591
|
+
const handleTempCommentClose = () => {
|
|
592
|
+
var _props$onTempCommentC;
|
|
593
|
+
draftService.cancel();
|
|
594
|
+
(_props$onTempCommentC = props.onTempCommentClose) === null || _props$onTempCommentC === void 0 || _props$onTempCommentC.call(props);
|
|
595
|
+
};
|
|
596
|
+
return /* @__PURE__ */ jsx(MobileThreadCommentPanel, {
|
|
597
|
+
...props,
|
|
598
|
+
tempComment: props.tempComment ?? tempCellComment,
|
|
599
|
+
onTempCommentClose: handleTempCommentClose,
|
|
600
|
+
autoFocusActiveComment: true
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
function MobileSheetsThreadCommentPanel() {
|
|
604
|
+
return /* @__PURE__ */ jsx(SheetsThreadCommentPanel, { ThreadCommentPanelComponent: MobileSheetsThreadCommentPanelContent });
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region src/controllers/mobile/components.controller.ts
|
|
444
609
|
/**
|
|
445
610
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
446
611
|
*
|
|
@@ -456,24 +621,108 @@ const SheetsThreadCommentPanel = () => {
|
|
|
456
621
|
* See the License for the specific language governing permissions and
|
|
457
622
|
* limitations under the License.
|
|
458
623
|
*/
|
|
459
|
-
let
|
|
624
|
+
let MobileComponentsController = class MobileComponentsController extends Disposable {
|
|
460
625
|
constructor(_componentManager, _iconManager) {
|
|
461
626
|
super();
|
|
462
627
|
this._componentManager = _componentManager;
|
|
463
628
|
this._iconManager = _iconManager;
|
|
464
|
-
this.
|
|
465
|
-
this.
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
470
|
-
});
|
|
629
|
+
this.disposeWithMe(this._componentManager.register(SHEETS_THREAD_COMMENT_PANEL, MobileSheetsThreadCommentPanel));
|
|
630
|
+
this.disposeWithMe(this._iconManager.register({
|
|
631
|
+
CommentIcon,
|
|
632
|
+
InsertCommentDoubleIcon
|
|
633
|
+
}));
|
|
471
634
|
}
|
|
472
|
-
|
|
473
|
-
|
|
635
|
+
};
|
|
636
|
+
MobileComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], MobileComponentsController);
|
|
637
|
+
|
|
638
|
+
//#endregion
|
|
639
|
+
//#region src/menu/mobile-menu.ts
|
|
640
|
+
function getMobileThreadCommentMenuTitle(accessor) {
|
|
641
|
+
var _selectionService$get;
|
|
642
|
+
const selectionService = accessor.get(SheetsSelectionsService);
|
|
643
|
+
const selection = (_selectionService$get = selectionService.getCurrentLastSelection()) === null || _selectionService$get === void 0 ? void 0 : _selectionService$get.primary;
|
|
644
|
+
const selectionParam = selectionService.currentSelectionParam;
|
|
645
|
+
if (!selection || !selectionParam) return "sheets-thread-comment-ui.menu.addComment";
|
|
646
|
+
return accessor.get(SheetsThreadCommentModel).getByLocation(selectionParam.unitId, selectionParam.sheetId, selection.startRow, selection.startColumn) ? "sheets-thread-comment-ui.menu.openComments" : "sheets-thread-comment-ui.menu.addComment";
|
|
647
|
+
}
|
|
648
|
+
const mobileThreadCommentMenuFactory = (accessor) => ({
|
|
649
|
+
id: ShowAddSheetCommentMobileOperation.id,
|
|
650
|
+
type: MenuItemType.BUTTON,
|
|
651
|
+
icon: "InsertCommentDoubleIcon",
|
|
652
|
+
title: "sheets-thread-comment-ui.menu.addComment",
|
|
653
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
654
|
+
disabled$: getCurrentRangeDisable$(accessor, {
|
|
655
|
+
workbookTypes: [WorkbookCommentPermission],
|
|
656
|
+
worksheetTypes: [WorksheetViewPermission],
|
|
657
|
+
rangeTypes: [RangeProtectionPermissionViewPoint]
|
|
658
|
+
})
|
|
659
|
+
});
|
|
660
|
+
const mobileContextThreadCommentMenuFactory = (accessor) => ({
|
|
661
|
+
...mobileThreadCommentMenuFactory(accessor),
|
|
662
|
+
title: getMobileThreadCommentMenuTitle(accessor)
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
//#endregion
|
|
666
|
+
//#region src/menu/mobile-schema.ts
|
|
667
|
+
const mobileMenuSchema = {
|
|
668
|
+
[RibbonInsertGroup.MEDIA]: {
|
|
669
|
+
[ToggleSheetCommentPanelOperation.id]: {
|
|
670
|
+
order: 2,
|
|
671
|
+
gridLayout: {
|
|
672
|
+
row: 1,
|
|
673
|
+
column: 3,
|
|
674
|
+
showLabel: true
|
|
675
|
+
},
|
|
676
|
+
menuItemFactory: threadPanelMenuFactory
|
|
677
|
+
},
|
|
678
|
+
[ShowAddSheetCommentMobileOperation.id]: {
|
|
679
|
+
order: 2.1,
|
|
680
|
+
gridLayout: {
|
|
681
|
+
row: 2,
|
|
682
|
+
column: 3,
|
|
683
|
+
showLabel: true
|
|
684
|
+
},
|
|
685
|
+
menuItemFactory: mobileThreadCommentMenuFactory
|
|
686
|
+
}
|
|
687
|
+
},
|
|
688
|
+
[ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.OTHERS]: { [ShowAddSheetCommentMobileOperation.id]: {
|
|
689
|
+
order: 0,
|
|
690
|
+
menuItemFactory: mobileContextThreadCommentMenuFactory
|
|
691
|
+
} } },
|
|
692
|
+
[FloatingObjectToolbarPosition.SHEET]: { [AddSheetDrawingCommentOperation.id]: {
|
|
693
|
+
order: 10,
|
|
694
|
+
menuItemFactory: drawingCommentMenuFactory
|
|
695
|
+
} },
|
|
696
|
+
[ContextMenuPosition.DRAWING]: { [ContextMenuGroup.OTHERS]: { [AddSheetDrawingCommentOperation.id]: {
|
|
697
|
+
order: 0,
|
|
698
|
+
menuItemFactory: drawingCommentMenuFactory
|
|
699
|
+
} } }
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
//#endregion
|
|
703
|
+
//#region src/controllers/mobile/sheets-thread-comment.controller.ts
|
|
704
|
+
/**
|
|
705
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
706
|
+
*
|
|
707
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
708
|
+
* you may not use this file except in compliance with the License.
|
|
709
|
+
* You may obtain a copy of the License at
|
|
710
|
+
*
|
|
711
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
712
|
+
*
|
|
713
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
714
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
715
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
716
|
+
* See the License for the specific language governing permissions and
|
|
717
|
+
* limitations under the License.
|
|
718
|
+
*/
|
|
719
|
+
let SheetsThreadCommentMobileController = class SheetsThreadCommentMobileController extends Disposable {
|
|
720
|
+
constructor(menuManagerService) {
|
|
721
|
+
super();
|
|
722
|
+
menuManagerService.mergeMenu(mobileMenuSchema);
|
|
474
723
|
}
|
|
475
724
|
};
|
|
476
|
-
|
|
725
|
+
SheetsThreadCommentMobileController = __decorate([__decorateParam(0, IMenuManagerService)], SheetsThreadCommentMobileController);
|
|
477
726
|
|
|
478
727
|
//#endregion
|
|
479
728
|
//#region src/controllers/render-controllers/render.controller.ts
|
|
@@ -652,6 +901,331 @@ SheetsThreadCommentCopyPasteController = __decorate([
|
|
|
652
901
|
__decorateParam(2, IThreadCommentDataSourceService)
|
|
653
902
|
], SheetsThreadCommentCopyPasteController);
|
|
654
903
|
|
|
904
|
+
//#endregion
|
|
905
|
+
//#region src/controllers/sheets-thread-comment-permission.controller.ts
|
|
906
|
+
let SheetsThreadCommentPermissionController = class SheetsThreadCommentPermissionController extends Disposable {
|
|
907
|
+
constructor(_localeService, _commandService, _sheetPermissionCheckController, _sheetsThreadCommentModel) {
|
|
908
|
+
super();
|
|
909
|
+
this._localeService = _localeService;
|
|
910
|
+
this._commandService = _commandService;
|
|
911
|
+
this._sheetPermissionCheckController = _sheetPermissionCheckController;
|
|
912
|
+
this._sheetsThreadCommentModel = _sheetsThreadCommentModel;
|
|
913
|
+
this._commandExecutedListener();
|
|
914
|
+
}
|
|
915
|
+
_commandExecutedListener() {
|
|
916
|
+
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
917
|
+
const { id } = command;
|
|
918
|
+
if (id === AddSheetDrawingCommentOperation.id || id === ShowAddSheetCommentModalOperation.id || id === ToggleSheetCommentPanelOperation.id) {
|
|
919
|
+
if (!this._sheetPermissionCheckController.permissionCheckWithoutRange({
|
|
920
|
+
workbookTypes: [WorkbookCommentPermission],
|
|
921
|
+
worksheetTypes: [WorksheetViewPermission]
|
|
922
|
+
})) this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("sheets-thread-comment-ui.permission.commentErr"));
|
|
923
|
+
} else if (id === AddCommentCommand.id) {
|
|
924
|
+
const { unitId, subUnitId, comment } = command.params;
|
|
925
|
+
if (!this._hasCommentPermission(unitId, subUnitId, comment.ref)) this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("sheets-thread-comment-ui.permission.commentErr"));
|
|
926
|
+
} else if (id === UpdateCommentCommand.id) {
|
|
927
|
+
const { unitId, subUnitId, payload } = command.params;
|
|
928
|
+
const { commentId } = payload;
|
|
929
|
+
const comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
|
|
930
|
+
if (comment && !this._hasCommentPermission(unitId, subUnitId, comment.ref)) this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("sheets-thread-comment-ui.permission.commentErr"));
|
|
931
|
+
} else if (id === ResolveCommentCommand.id || id === DeleteCommentCommand.id || id === DeleteCommentTreeCommand.id) {
|
|
932
|
+
const { unitId, subUnitId, commentId } = command.params;
|
|
933
|
+
const comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
|
|
934
|
+
if (comment && !this._hasCommentPermission(unitId, subUnitId, comment.ref)) this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("sheets-thread-comment-ui.permission.commentErr"));
|
|
935
|
+
}
|
|
936
|
+
}));
|
|
937
|
+
}
|
|
938
|
+
_hasCommentPermission(unitId, subUnitId, ref) {
|
|
939
|
+
const permissionTypes = {
|
|
940
|
+
workbookTypes: [WorkbookCommentPermission],
|
|
941
|
+
worksheetTypes: [WorksheetViewPermission]
|
|
942
|
+
};
|
|
943
|
+
const anchor = deserializeThreadCommentAnchor(ref);
|
|
944
|
+
if ((anchor === null || anchor === void 0 ? void 0 : anchor.kind) === ThreadCommentAnchorKind.SHEET_DRAWING) return this._sheetPermissionCheckController.permissionCheckWithoutRange(permissionTypes, unitId, subUnitId);
|
|
945
|
+
const { row, column } = singleReferenceToGrid(ref);
|
|
946
|
+
if (!Number.isFinite(row) || !Number.isFinite(column)) return false;
|
|
947
|
+
return this._sheetPermissionCheckController.permissionCheckWithRanges({
|
|
948
|
+
...permissionTypes,
|
|
949
|
+
rangeTypes: [RangeProtectionPermissionViewPoint]
|
|
950
|
+
}, [{
|
|
951
|
+
startRow: row,
|
|
952
|
+
startColumn: column,
|
|
953
|
+
endRow: row,
|
|
954
|
+
endColumn: column
|
|
955
|
+
}], unitId, subUnitId);
|
|
956
|
+
}
|
|
957
|
+
};
|
|
958
|
+
SheetsThreadCommentPermissionController = __decorate([
|
|
959
|
+
__decorateParam(0, Inject(LocaleService)),
|
|
960
|
+
__decorateParam(1, ICommandService),
|
|
961
|
+
__decorateParam(2, Inject(SheetPermissionCheckController)),
|
|
962
|
+
__decorateParam(3, Inject(SheetsThreadCommentModel))
|
|
963
|
+
], SheetsThreadCommentPermissionController);
|
|
964
|
+
|
|
965
|
+
//#endregion
|
|
966
|
+
//#region src/mobile-plugin.ts
|
|
967
|
+
let UniverSheetsThreadCommentMobileUIPlugin = class UniverSheetsThreadCommentMobileUIPlugin extends Plugin {
|
|
968
|
+
constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
|
|
969
|
+
super();
|
|
970
|
+
this._config = _config;
|
|
971
|
+
this._injector = _injector;
|
|
972
|
+
this._commandService = _commandService;
|
|
973
|
+
this._configService = _configService;
|
|
974
|
+
const { menu, ...rest } = merge({}, defaultPluginConfig, this._config);
|
|
975
|
+
if (menu) this._configService.setConfig("menu", menu, { merge: true });
|
|
976
|
+
this._configService.setConfig(SHEETS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY, rest);
|
|
977
|
+
}
|
|
978
|
+
onStarting() {
|
|
979
|
+
[
|
|
980
|
+
[MobileComponentsController],
|
|
981
|
+
[SheetsThreadCommentMobileController],
|
|
982
|
+
[SheetsThreadCommentRenderController],
|
|
983
|
+
[SheetsThreadCommentCopyPasteController],
|
|
984
|
+
[SheetsThreadCommentPopupService],
|
|
985
|
+
[SheetsThreadCommentPermissionController],
|
|
986
|
+
[MobileSheetCommentDraftService]
|
|
987
|
+
].forEach((dependency) => this._injector.add(dependency));
|
|
988
|
+
this._injector.get(MobileComponentsController);
|
|
989
|
+
[
|
|
990
|
+
AddSheetDrawingCommentOperation,
|
|
991
|
+
OpenSheetCommentPanelOperation,
|
|
992
|
+
ShowAddSheetCommentMobileOperation,
|
|
993
|
+
ToggleSheetCommentPanelOperation
|
|
994
|
+
].forEach((command) => this._commandService.registerCommand(command));
|
|
995
|
+
this._injector.get(SheetsThreadCommentMobileController);
|
|
996
|
+
}
|
|
997
|
+
onReady() {
|
|
998
|
+
this._injector.get(SheetsThreadCommentRenderController);
|
|
999
|
+
}
|
|
1000
|
+
onRendered() {
|
|
1001
|
+
this._injector.get(SheetsThreadCommentCopyPasteController);
|
|
1002
|
+
this._injector.get(SheetsThreadCommentPermissionController);
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
_defineProperty(UniverSheetsThreadCommentMobileUIPlugin, "pluginName", PLUGIN_NAME);
|
|
1006
|
+
_defineProperty(UniverSheetsThreadCommentMobileUIPlugin, "packageName", name);
|
|
1007
|
+
_defineProperty(UniverSheetsThreadCommentMobileUIPlugin, "version", version);
|
|
1008
|
+
_defineProperty(UniverSheetsThreadCommentMobileUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
1009
|
+
UniverSheetsThreadCommentMobileUIPlugin = __decorate([
|
|
1010
|
+
DependentOn(UniverRenderEnginePlugin, UniverThreadCommentPlugin, UniverSheetsPlugin, UniverThreadCommentMobileUIPlugin, UniverSheetsThreadCommentPlugin, UniverMobileUIPlugin, UniverSheetsMobileUIPlugin),
|
|
1011
|
+
__decorateParam(1, Inject(Injector)),
|
|
1012
|
+
__decorateParam(2, Inject(ICommandService)),
|
|
1013
|
+
__decorateParam(3, IConfigService)
|
|
1014
|
+
], UniverSheetsThreadCommentMobileUIPlugin);
|
|
1015
|
+
|
|
1016
|
+
//#endregion
|
|
1017
|
+
//#region src/views/SheetsThreadCommentCell.tsx
|
|
1018
|
+
const SheetsThreadCommentCell = () => {
|
|
1019
|
+
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
1020
|
+
const sheetsThreadCommentPopupService = useDependency(SheetsThreadCommentPopupService);
|
|
1021
|
+
const activePopup = useObservable(sheetsThreadCommentPopupService.activePopup$);
|
|
1022
|
+
const sheetThreadCommentModel = useDependency(SheetsThreadCommentModel);
|
|
1023
|
+
const getRootId = () => {
|
|
1024
|
+
if (!activePopup) return;
|
|
1025
|
+
const { unitId, subUnitId, row, col, commentId } = activePopup;
|
|
1026
|
+
const activeComment = commentId ? sheetThreadCommentModel.getAllByLocation(unitId, subUnitId, row, col).find((comment) => comment.id === commentId) : void 0;
|
|
1027
|
+
return activeComment && !activeComment.resolved ? activeComment.id : sheetThreadCommentModel.getByLocation(unitId, subUnitId, row, col);
|
|
1028
|
+
};
|
|
1029
|
+
const rootId = useObservable(activePopup ? () => sheetThreadCommentModel.commentUpdate$.pipe(map(() => getRootId()), startWith(getRootId())) : null, void 0, false, [activePopup, sheetThreadCommentModel]);
|
|
1030
|
+
if (!activePopup) return null;
|
|
1031
|
+
const { row, col, unitId, subUnitId, trigger } = activePopup;
|
|
1032
|
+
const ref = `${Tools.chatAtABC(col)}${row + 1}`;
|
|
1033
|
+
const onClose = () => {
|
|
1034
|
+
sheetsThreadCommentPopupService.hidePopup();
|
|
1035
|
+
};
|
|
1036
|
+
const getSubUnitName = (id) => {
|
|
1037
|
+
var _univerInstanceServic;
|
|
1038
|
+
return ((_univerInstanceServic = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic === void 0 || (_univerInstanceServic = _univerInstanceServic.getSheetBySheetId(id)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getName()) ?? "";
|
|
1039
|
+
};
|
|
1040
|
+
return /* @__PURE__ */ jsx(ThreadCommentTree, {
|
|
1041
|
+
onClick: () => {
|
|
1042
|
+
sheetsThreadCommentPopupService.persistPopup();
|
|
1043
|
+
},
|
|
1044
|
+
location: ThreadCommentTreeLocation.CELL,
|
|
1045
|
+
id: rootId,
|
|
1046
|
+
unitId,
|
|
1047
|
+
subUnitId,
|
|
1048
|
+
type: UniverInstanceType.UNIVER_SHEET,
|
|
1049
|
+
refStr: ref,
|
|
1050
|
+
onClose,
|
|
1051
|
+
getSubUnitName,
|
|
1052
|
+
autoFocus: trigger === "context-menu"
|
|
1053
|
+
});
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
//#endregion
|
|
1057
|
+
//#region src/controllers/components.controller.ts
|
|
1058
|
+
/**
|
|
1059
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1060
|
+
*
|
|
1061
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1062
|
+
* you may not use this file except in compliance with the License.
|
|
1063
|
+
* You may obtain a copy of the License at
|
|
1064
|
+
*
|
|
1065
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1066
|
+
*
|
|
1067
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1068
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1069
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1070
|
+
* See the License for the specific language governing permissions and
|
|
1071
|
+
* limitations under the License.
|
|
1072
|
+
*/
|
|
1073
|
+
let ComponentsController = class ComponentsController extends Disposable {
|
|
1074
|
+
constructor(_componentManager, _iconManager) {
|
|
1075
|
+
super();
|
|
1076
|
+
this._componentManager = _componentManager;
|
|
1077
|
+
this._iconManager = _iconManager;
|
|
1078
|
+
this._registerComponents();
|
|
1079
|
+
this._registerIcons();
|
|
1080
|
+
}
|
|
1081
|
+
_registerComponents() {
|
|
1082
|
+
[[SHEETS_THREAD_COMMENT_MODAL, SheetsThreadCommentCell], [SHEETS_THREAD_COMMENT_PANEL, SheetsThreadCommentPanel]].forEach(([key, comp]) => {
|
|
1083
|
+
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
_registerIcons() {
|
|
1087
|
+
this.disposeWithMe(this._iconManager.register({
|
|
1088
|
+
CommentIcon,
|
|
1089
|
+
InsertCommentDoubleIcon
|
|
1090
|
+
}));
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
1094
|
+
|
|
1095
|
+
//#endregion
|
|
1096
|
+
//#region src/controllers/render-controllers/drawing.render-controller.ts
|
|
1097
|
+
const SHEET_COMMENT_DRAWING_OVERLAY_KEY = "sheet-thread-comment-drawing-overlay";
|
|
1098
|
+
const SHEET_COMMENT_DRAWING_OVERLAY_LAYER_INDEX = 10100;
|
|
1099
|
+
let SheetsThreadCommentDrawingRenderController = class SheetsThreadCommentDrawingRenderController extends RxDisposable {
|
|
1100
|
+
constructor(_context, _commandService, _drawingManagerService, _commentModel, _panelService, _themeService) {
|
|
1101
|
+
super();
|
|
1102
|
+
this._context = _context;
|
|
1103
|
+
this._commandService = _commandService;
|
|
1104
|
+
this._drawingManagerService = _drawingManagerService;
|
|
1105
|
+
this._commentModel = _commentModel;
|
|
1106
|
+
this._panelService = _panelService;
|
|
1107
|
+
this._themeService = _themeService;
|
|
1108
|
+
_defineProperty(this, "_overlay", void 0);
|
|
1109
|
+
this._overlay = new ThreadCommentCanvasOverlay(SHEET_COMMENT_DRAWING_OVERLAY_KEY, {
|
|
1110
|
+
...this._getColors(),
|
|
1111
|
+
zoomRatio: 1,
|
|
1112
|
+
markers: [],
|
|
1113
|
+
underlines: []
|
|
1114
|
+
});
|
|
1115
|
+
this._context.scene.addObject(this._overlay, SHEET_COMMENT_DRAWING_OVERLAY_LAYER_INDEX);
|
|
1116
|
+
this.disposeWithMe(toDisposable(this._overlay.onPointerDown$.subscribeEvent((_event, state) => this._onOverlayPointerDown(state))));
|
|
1117
|
+
this.disposeWithMe(toDisposable(this._context.engine.onTransformChange$.subscribeEvent(() => this._syncOverlay())));
|
|
1118
|
+
this.disposeWithMe(this._context.unit.activeSheet$.subscribe(() => this._syncOverlay()));
|
|
1119
|
+
this.disposeWithMe(this._commentModel.commentUpdate$.subscribe((update) => {
|
|
1120
|
+
if (update.unitId === this._context.unitId) this._syncOverlay();
|
|
1121
|
+
}));
|
|
1122
|
+
[this._panelService.activeCommentId$, this._panelService.hoveredCommentId$].forEach((observable) => this.disposeWithMe(observable.subscribe(() => this._syncOverlay())));
|
|
1123
|
+
[
|
|
1124
|
+
this._drawingManagerService.add$,
|
|
1125
|
+
this._drawingManagerService.update$,
|
|
1126
|
+
this._drawingManagerService.remove$
|
|
1127
|
+
].forEach((observable) => this.disposeWithMe(observable.subscribe((drawings) => {
|
|
1128
|
+
if (drawings.some((drawing) => drawing.unitId === this._context.unitId)) this._syncOverlay();
|
|
1129
|
+
})));
|
|
1130
|
+
this.disposeWithMe(this._themeService.currentTheme$.subscribe(() => this._syncOverlay()));
|
|
1131
|
+
this._syncOverlay();
|
|
1132
|
+
}
|
|
1133
|
+
_onOverlayPointerDown(state) {
|
|
1134
|
+
var _this$_context$unit$g;
|
|
1135
|
+
const commentId = this._overlay.hitCommentId;
|
|
1136
|
+
const subUnitId = (_this$_context$unit$g = this._context.unit.getActiveSheet()) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.getSheetId();
|
|
1137
|
+
if (!commentId || !subUnitId) return;
|
|
1138
|
+
state.stopPropagation();
|
|
1139
|
+
this._panelService.setActiveComment({
|
|
1140
|
+
unitId: this._context.unitId,
|
|
1141
|
+
subUnitId,
|
|
1142
|
+
commentId,
|
|
1143
|
+
trigger: "sheet-canvas"
|
|
1144
|
+
});
|
|
1145
|
+
this._commandService.executeCommand(OpenSheetCommentPanelOperation.id).catch(() => void 0);
|
|
1146
|
+
}
|
|
1147
|
+
_syncOverlay() {
|
|
1148
|
+
const worksheet = this._context.unit.getActiveSheet();
|
|
1149
|
+
const subUnitId = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getSheetId();
|
|
1150
|
+
if (!worksheet || !subUnitId) {
|
|
1151
|
+
this._overlay.updateState({
|
|
1152
|
+
markers: [],
|
|
1153
|
+
underlines: [],
|
|
1154
|
+
focusedCommentIds: [],
|
|
1155
|
+
focusOutlines: []
|
|
1156
|
+
});
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
const underlines = /* @__PURE__ */ new Map();
|
|
1160
|
+
this._commentModel.query({
|
|
1161
|
+
unitIds: [this._context.unitId],
|
|
1162
|
+
subUnitIds: [subUnitId],
|
|
1163
|
+
anchorKinds: [ThreadCommentAnchorKind.SHEET_DRAWING],
|
|
1164
|
+
resolved: false
|
|
1165
|
+
}).forEach(({ root }) => {
|
|
1166
|
+
const anchor = deserializeThreadCommentAnchor(root.ref);
|
|
1167
|
+
if ((anchor === null || anchor === void 0 ? void 0 : anchor.kind) !== ThreadCommentAnchorKind.SHEET_DRAWING) return;
|
|
1168
|
+
const outline = this._getDrawingOutline(subUnitId, anchor.elementId);
|
|
1169
|
+
if (outline) underlines.set(anchor.elementId, {
|
|
1170
|
+
commentId: root.id,
|
|
1171
|
+
left: outline.left,
|
|
1172
|
+
top: outline.top + outline.height + 2 / worksheet.getZoomRatio(),
|
|
1173
|
+
width: outline.width
|
|
1174
|
+
});
|
|
1175
|
+
});
|
|
1176
|
+
const focusedCommentIds = [];
|
|
1177
|
+
const focusOutlines = /* @__PURE__ */ new Map();
|
|
1178
|
+
[this._panelService.activeCommentId, this._panelService.hoveredCommentId].forEach((target) => {
|
|
1179
|
+
if (!target || target.unitId !== this._context.unitId || target.subUnitId !== subUnitId) return;
|
|
1180
|
+
const comment = this._commentModel.getComment(target.unitId, target.subUnitId, target.commentId);
|
|
1181
|
+
const anchor = comment && deserializeThreadCommentAnchor(comment.ref);
|
|
1182
|
+
if ((anchor === null || anchor === void 0 ? void 0 : anchor.kind) !== ThreadCommentAnchorKind.SHEET_DRAWING) return;
|
|
1183
|
+
focusedCommentIds.push(target.commentId);
|
|
1184
|
+
const outline = this._getDrawingOutline(subUnitId, anchor.elementId);
|
|
1185
|
+
if (outline) focusOutlines.set(anchor.elementId, outline);
|
|
1186
|
+
});
|
|
1187
|
+
this._overlay.updateState({
|
|
1188
|
+
...this._getColors(),
|
|
1189
|
+
zoomRatio: worksheet.getZoomRatio(),
|
|
1190
|
+
markers: [],
|
|
1191
|
+
underlines: Array.from(underlines.values()),
|
|
1192
|
+
focusedCommentIds,
|
|
1193
|
+
focusOutlines: Array.from(focusOutlines.values())
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
_getDrawingOutline(subUnitId, drawingId) {
|
|
1197
|
+
var _this$_context$scene$, _this$_context$scene;
|
|
1198
|
+
const objectKey = getDrawingShapeKeyByDrawingSearch({
|
|
1199
|
+
unitId: this._context.unitId,
|
|
1200
|
+
subUnitId,
|
|
1201
|
+
drawingId
|
|
1202
|
+
});
|
|
1203
|
+
const object = ((_this$_context$scene$ = (_this$_context$scene = this._context.scene).getObjectIncludeInGroup) === null || _this$_context$scene$ === void 0 ? void 0 : _this$_context$scene$.call(_this$_context$scene, objectKey)) ?? this._context.scene.getObject(objectKey);
|
|
1204
|
+
if (!object) return null;
|
|
1205
|
+
const bounds = object.getRealBound();
|
|
1206
|
+
return {
|
|
1207
|
+
left: bounds.left,
|
|
1208
|
+
top: bounds.top,
|
|
1209
|
+
width: bounds.width,
|
|
1210
|
+
height: bounds.height
|
|
1211
|
+
};
|
|
1212
|
+
}
|
|
1213
|
+
_getColors() {
|
|
1214
|
+
return {
|
|
1215
|
+
accentColor: this._themeService.getColorFromTheme("yellow.400"),
|
|
1216
|
+
foregroundColor: this._themeService.getColorFromTheme("gray.900"),
|
|
1217
|
+
outlineColor: this._themeService.getColorFromTheme("white")
|
|
1218
|
+
};
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
SheetsThreadCommentDrawingRenderController = __decorate([
|
|
1222
|
+
__decorateParam(1, ICommandService),
|
|
1223
|
+
__decorateParam(2, IDrawingManagerService),
|
|
1224
|
+
__decorateParam(3, Inject(ThreadCommentModel)),
|
|
1225
|
+
__decorateParam(4, Inject(ThreadCommentPanelService)),
|
|
1226
|
+
__decorateParam(5, Inject(ThemeService))
|
|
1227
|
+
], SheetsThreadCommentDrawingRenderController);
|
|
1228
|
+
|
|
655
1229
|
//#endregion
|
|
656
1230
|
//#region src/controllers/sheets-thread-comment-hover.controller.ts
|
|
657
1231
|
/**
|
|
@@ -717,84 +1291,11 @@ SheetsThreadCommentHoverController = __decorate([
|
|
|
717
1291
|
__decorateParam(3, Inject(SheetPermissionCheckController))
|
|
718
1292
|
], SheetsThreadCommentHoverController);
|
|
719
1293
|
|
|
720
|
-
//#endregion
|
|
721
|
-
//#region src/controllers/sheets-thread-comment-permission.controller.ts
|
|
722
|
-
let SheetsThreadCommentPermissionController = class SheetsThreadCommentPermissionController extends Disposable {
|
|
723
|
-
constructor(_localeService, _commandService, _sheetPermissionCheckController, _sheetsThreadCommentModel) {
|
|
724
|
-
super();
|
|
725
|
-
this._localeService = _localeService;
|
|
726
|
-
this._commandService = _commandService;
|
|
727
|
-
this._sheetPermissionCheckController = _sheetPermissionCheckController;
|
|
728
|
-
this._sheetsThreadCommentModel = _sheetsThreadCommentModel;
|
|
729
|
-
this._commandExecutedListener();
|
|
730
|
-
}
|
|
731
|
-
_commandExecutedListener() {
|
|
732
|
-
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
733
|
-
const { id } = command;
|
|
734
|
-
if (id === ShowAddSheetCommentModalOperation.id || id === ToggleSheetCommentPanelOperation.id) {
|
|
735
|
-
if (!this._sheetPermissionCheckController.permissionCheckWithoutRange({
|
|
736
|
-
workbookTypes: [WorkbookCommentPermission],
|
|
737
|
-
worksheetTypes: [WorksheetViewPermission]
|
|
738
|
-
})) this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("sheets-thread-comment-ui.permission.commentErr"));
|
|
739
|
-
} else if (id === AddCommentCommand.id) {
|
|
740
|
-
const { unitId, subUnitId, comment } = command.params;
|
|
741
|
-
const { row, column } = singleReferenceToGrid(comment.ref);
|
|
742
|
-
if (!this._sheetPermissionCheckController.permissionCheckWithRanges({
|
|
743
|
-
workbookTypes: [WorkbookCommentPermission],
|
|
744
|
-
worksheetTypes: [WorksheetViewPermission],
|
|
745
|
-
rangeTypes: [RangeProtectionPermissionViewPoint]
|
|
746
|
-
}, [{
|
|
747
|
-
startRow: row,
|
|
748
|
-
startColumn: column,
|
|
749
|
-
endRow: row,
|
|
750
|
-
endColumn: column
|
|
751
|
-
}], unitId, subUnitId)) this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("sheets-thread-comment-ui.permission.commentErr"));
|
|
752
|
-
} else if (id === UpdateCommentCommand.id) {
|
|
753
|
-
const { unitId, subUnitId, payload } = command.params;
|
|
754
|
-
const { commentId } = payload;
|
|
755
|
-
const comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
|
|
756
|
-
if (comment) {
|
|
757
|
-
const { row, column } = singleReferenceToGrid(comment.ref);
|
|
758
|
-
if (!this._sheetPermissionCheckController.permissionCheckWithRanges({
|
|
759
|
-
workbookTypes: [WorkbookCommentPermission],
|
|
760
|
-
worksheetTypes: [WorksheetViewPermission],
|
|
761
|
-
rangeTypes: [RangeProtectionPermissionViewPoint]
|
|
762
|
-
}, [{
|
|
763
|
-
startRow: row,
|
|
764
|
-
startColumn: column,
|
|
765
|
-
endRow: row,
|
|
766
|
-
endColumn: column
|
|
767
|
-
}], unitId, subUnitId)) this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("sheets-thread-comment-ui.permission.commentErr"));
|
|
768
|
-
}
|
|
769
|
-
} else if (id === ResolveCommentCommand.id || id === DeleteCommentCommand.id || id === DeleteCommentTreeCommand.id) {
|
|
770
|
-
const { unitId, subUnitId, commentId } = command.params;
|
|
771
|
-
const comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
|
|
772
|
-
if (comment) {
|
|
773
|
-
const { row, column } = singleReferenceToGrid(comment.ref);
|
|
774
|
-
if (!this._sheetPermissionCheckController.permissionCheckWithRanges({
|
|
775
|
-
workbookTypes: [WorkbookCommentPermission],
|
|
776
|
-
worksheetTypes: [WorksheetViewPermission],
|
|
777
|
-
rangeTypes: [RangeProtectionPermissionViewPoint]
|
|
778
|
-
}, [{
|
|
779
|
-
startRow: row,
|
|
780
|
-
startColumn: column,
|
|
781
|
-
endRow: row,
|
|
782
|
-
endColumn: column
|
|
783
|
-
}], unitId, subUnitId)) this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("sheets-thread-comment-ui.permission.commentErr"));
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
}));
|
|
787
|
-
}
|
|
788
|
-
};
|
|
789
|
-
SheetsThreadCommentPermissionController = __decorate([
|
|
790
|
-
__decorateParam(0, Inject(LocaleService)),
|
|
791
|
-
__decorateParam(1, ICommandService),
|
|
792
|
-
__decorateParam(2, Inject(SheetPermissionCheckController)),
|
|
793
|
-
__decorateParam(3, Inject(SheetsThreadCommentModel))
|
|
794
|
-
], SheetsThreadCommentPermissionController);
|
|
795
|
-
|
|
796
1294
|
//#endregion
|
|
797
1295
|
//#region src/controllers/sheets-thread-comment-popup.controller.ts
|
|
1296
|
+
function resolveFocusedSheetComment(activeComment, hoveredComment, unitId, subUnitId) {
|
|
1297
|
+
for (const comment of [hoveredComment, activeComment]) if (comment && comment.unitId === unitId && comment.subUnitId === subUnitId) return comment;
|
|
1298
|
+
}
|
|
798
1299
|
let SheetsThreadCommentPopupController = class SheetsThreadCommentPopupController extends Disposable {
|
|
799
1300
|
constructor(_commandService, _sheetsThreadCommentPopupService, _sheetsThreadCommentModel, _threadCommentPanelService, _univerInstanceService, _sheetPermissionCheckController, _markSelectionService, _sheetSelectionService, _editorBridgeService, _renderManagerService) {
|
|
800
1301
|
super();
|
|
@@ -872,6 +1373,8 @@ let SheetsThreadCommentPopupController = class SheetsThreadCommentPopupControlle
|
|
|
872
1373
|
const { unitId, subUnitId, commentId, trigger } = commentInfo;
|
|
873
1374
|
const comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
|
|
874
1375
|
if (!comment || comment.resolved) return;
|
|
1376
|
+
const anchor = deserializeThreadCommentAnchor(comment.ref);
|
|
1377
|
+
if ((anchor === null || anchor === void 0 ? void 0 : anchor.kind) === ThreadCommentAnchorKind.SHEET_DRAWING) return;
|
|
875
1378
|
const currentUnit = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
876
1379
|
if (!currentUnit) return;
|
|
877
1380
|
if (currentUnit.getUnitId() !== unitId) return;
|
|
@@ -913,16 +1416,18 @@ let SheetsThreadCommentPopupController = class SheetsThreadCommentPopupControlle
|
|
|
913
1416
|
}));
|
|
914
1417
|
}
|
|
915
1418
|
_initMarkSelection() {
|
|
916
|
-
this.disposeWithMe(this._threadCommentPanelService.activeCommentId
|
|
917
|
-
var _this$_univerInstance;
|
|
918
|
-
|
|
1419
|
+
this.disposeWithMe(combineLatest([this._threadCommentPanelService.activeCommentId$, this._threadCommentPanelService.hoveredCommentId$]).pipe(debounceTime(100)).subscribe(([activeComment, hoveredComment]) => {
|
|
1420
|
+
var _currentUnit$getActiv2, _this$_univerInstance;
|
|
1421
|
+
const currentUnit = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
1422
|
+
const focusedComment = resolveFocusedSheetComment(activeComment, hoveredComment, currentUnit === null || currentUnit === void 0 ? void 0 : currentUnit.getUnitId(), currentUnit === null || currentUnit === void 0 || (_currentUnit$getActiv2 = currentUnit.getActiveSheet()) === null || _currentUnit$getActiv2 === void 0 ? void 0 : _currentUnit$getActiv2.getSheetId());
|
|
1423
|
+
if (!focusedComment) {
|
|
919
1424
|
if (this._selectionShapeInfo) {
|
|
920
1425
|
this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId);
|
|
921
1426
|
this._selectionShapeInfo = null;
|
|
922
1427
|
}
|
|
923
1428
|
return;
|
|
924
1429
|
}
|
|
925
|
-
const { unitId, subUnitId, commentId } =
|
|
1430
|
+
const { unitId, subUnitId, commentId } = focusedComment;
|
|
926
1431
|
if (this._selectionShapeInfo) {
|
|
927
1432
|
this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId);
|
|
928
1433
|
this._selectionShapeInfo = null;
|
|
@@ -950,7 +1455,7 @@ let SheetsThreadCommentPopupController = class SheetsThreadCommentPopupControlle
|
|
|
950
1455
|
}, [], -1);
|
|
951
1456
|
if (!shapeId) return;
|
|
952
1457
|
this._selectionShapeInfo = {
|
|
953
|
-
...
|
|
1458
|
+
...focusedComment,
|
|
954
1459
|
shapeId
|
|
955
1460
|
};
|
|
956
1461
|
}));
|
|
@@ -1006,11 +1511,12 @@ SheetsThreadCommentController = __decorate([__decorateParam(0, IMenuManagerServi
|
|
|
1006
1511
|
//#endregion
|
|
1007
1512
|
//#region src/plugin.ts
|
|
1008
1513
|
let UniverSheetsThreadCommentUIPlugin = class UniverSheetsThreadCommentUIPlugin extends Plugin {
|
|
1009
|
-
constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
|
|
1514
|
+
constructor(_config = defaultPluginConfig, _injector, _commandService, _renderManagerService, _configService) {
|
|
1010
1515
|
super();
|
|
1011
1516
|
this._config = _config;
|
|
1012
1517
|
this._injector = _injector;
|
|
1013
1518
|
this._commandService = _commandService;
|
|
1519
|
+
this._renderManagerService = _renderManagerService;
|
|
1014
1520
|
this._configService = _configService;
|
|
1015
1521
|
const { menu, ...rest } = merge({}, defaultPluginConfig, this._config);
|
|
1016
1522
|
if (menu) this._configService.setConfig("menu", menu, { merge: true });
|
|
@@ -1030,7 +1536,12 @@ let UniverSheetsThreadCommentUIPlugin = class UniverSheetsThreadCommentUIPlugin
|
|
|
1030
1536
|
].forEach((dep) => {
|
|
1031
1537
|
this._injector.add(dep);
|
|
1032
1538
|
});
|
|
1033
|
-
[
|
|
1539
|
+
[
|
|
1540
|
+
AddSheetDrawingCommentOperation,
|
|
1541
|
+
OpenSheetCommentPanelOperation,
|
|
1542
|
+
ShowAddSheetCommentModalOperation,
|
|
1543
|
+
ToggleSheetCommentPanelOperation
|
|
1544
|
+
].forEach((command) => {
|
|
1034
1545
|
this._commandService.registerCommand(command);
|
|
1035
1546
|
});
|
|
1036
1547
|
this._injector.get(SheetsThreadCommentController);
|
|
@@ -1039,6 +1550,7 @@ let UniverSheetsThreadCommentUIPlugin = class UniverSheetsThreadCommentUIPlugin
|
|
|
1039
1550
|
this._injector.get(SheetsThreadCommentRenderController);
|
|
1040
1551
|
}
|
|
1041
1552
|
onRendered() {
|
|
1553
|
+
this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, [SheetsThreadCommentDrawingRenderController]);
|
|
1042
1554
|
this._injector.get(SheetsThreadCommentCopyPasteController);
|
|
1043
1555
|
this._injector.get(SheetsThreadCommentHoverController);
|
|
1044
1556
|
this._injector.get(SheetsThreadCommentPopupController);
|
|
@@ -1050,11 +1562,12 @@ _defineProperty(UniverSheetsThreadCommentUIPlugin, "packageName", name);
|
|
|
1050
1562
|
_defineProperty(UniverSheetsThreadCommentUIPlugin, "version", version);
|
|
1051
1563
|
_defineProperty(UniverSheetsThreadCommentUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
1052
1564
|
UniverSheetsThreadCommentUIPlugin = __decorate([
|
|
1053
|
-
DependentOn(UniverRenderEnginePlugin, UniverThreadCommentPlugin, UniverSheetsPlugin, UniverThreadCommentUIPlugin, UniverSheetsThreadCommentPlugin, UniverSheetsUIPlugin),
|
|
1565
|
+
DependentOn(UniverRenderEnginePlugin, UniverThreadCommentPlugin, UniverDrawingPlugin, UniverSheetsPlugin, UniverThreadCommentUIPlugin, UniverSheetsThreadCommentPlugin, UniverSheetsUIPlugin),
|
|
1054
1566
|
__decorateParam(1, Inject(Injector)),
|
|
1055
1567
|
__decorateParam(2, Inject(ICommandService)),
|
|
1056
|
-
__decorateParam(3,
|
|
1568
|
+
__decorateParam(3, IRenderManagerService),
|
|
1569
|
+
__decorateParam(4, IConfigService)
|
|
1057
1570
|
], UniverSheetsThreadCommentUIPlugin);
|
|
1058
1571
|
|
|
1059
1572
|
//#endregion
|
|
1060
|
-
export { SheetsThreadCommentPopupService, menuSchema as SheetsThreadCommentUIMenuSchema, ShowAddSheetCommentModalOperation, ToggleSheetCommentPanelOperation, UniverSheetsThreadCommentUIPlugin };
|
|
1573
|
+
export { SheetsThreadCommentPopupService, menuSchema as SheetsThreadCommentUIMenuSchema, ShowAddSheetCommentModalOperation, ToggleSheetCommentPanelOperation, UniverSheetsThreadCommentMobileUIPlugin, UniverSheetsThreadCommentUIPlugin };
|