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