@univerjs/sheets-thread-comment-ui 0.25.0 → 1.0.0-alpha.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/lib/cjs/index.js CHANGED
@@ -6,12 +6,12 @@ let _univerjs_thread_comment_ui = require("@univerjs/thread-comment-ui");
6
6
  let _univerjs_ui = require("@univerjs/ui");
7
7
  let _univerjs_sheets_ui = require("@univerjs/sheets-ui");
8
8
  let rxjs = require("rxjs");
9
- let _univerjs_engine_render = require("@univerjs/engine-render");
10
- let _univerjs_engine_formula = require("@univerjs/engine-formula");
11
- let _univerjs_thread_comment = require("@univerjs/thread-comment");
12
9
  let _univerjs_icons = require("@univerjs/icons");
13
10
  let react_jsx_runtime = require("react/jsx-runtime");
11
+ let _univerjs_engine_formula = require("@univerjs/engine-formula");
14
12
  let react = require("react");
13
+ let _univerjs_engine_render = require("@univerjs/engine-render");
14
+ let _univerjs_thread_comment = require("@univerjs/thread-comment");
15
15
 
16
16
  //#region src/types/const.ts
17
17
  /**
@@ -34,7 +34,7 @@ const SHEETS_THREAD_COMMENT_PANEL = "univer.sheet.thread-comment-panel";
34
34
  const PLUGIN_NAME = "SHEET_THREAD_COMMENT_UI_PLUGIN";
35
35
 
36
36
  //#endregion
37
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
37
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
38
38
  function _typeof(o) {
39
39
  "@babel/helpers - typeof";
40
40
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -45,7 +45,7 @@ function _typeof(o) {
45
45
  }
46
46
 
47
47
  //#endregion
48
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
48
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
49
49
  function toPrimitive(t, r) {
50
50
  if ("object" != _typeof(t) || !t) return t;
51
51
  var e = t[Symbol.toPrimitive];
@@ -58,14 +58,14 @@ function toPrimitive(t, r) {
58
58
  }
59
59
 
60
60
  //#endregion
61
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
61
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
62
62
  function toPropertyKey(t) {
63
63
  var i = toPrimitive(t, "string");
64
64
  return "symbol" == _typeof(i) ? i : i + "";
65
65
  }
66
66
 
67
67
  //#endregion
68
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
68
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
69
69
  function _defineProperty(e, r, t) {
70
70
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
71
71
  value: t,
@@ -76,7 +76,7 @@ function _defineProperty(e, r, t) {
76
76
  }
77
77
 
78
78
  //#endregion
79
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
79
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
80
80
  function __decorateParam(paramIndex, decorator) {
81
81
  return function(target, key) {
82
82
  decorator(target, key, paramIndex);
@@ -84,7 +84,7 @@ function __decorateParam(paramIndex, decorator) {
84
84
  }
85
85
 
86
86
  //#endregion
87
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
87
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
88
88
  function __decorate(decorators, target, key, desc) {
89
89
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
90
90
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -98,25 +98,18 @@ let SheetsThreadCommentPopupService = class SheetsThreadCommentPopupService exte
98
98
  get activePopup() {
99
99
  return this._activePopup;
100
100
  }
101
- constructor(_canvasPopupManagerService, _zenZoneService, _cellPopupManagerService) {
101
+ constructor(_canvasPopupManagerService, _cellPopupManagerService) {
102
102
  super();
103
103
  this._canvasPopupManagerService = _canvasPopupManagerService;
104
- this._zenZoneService = _zenZoneService;
105
104
  this._cellPopupManagerService = _cellPopupManagerService;
106
105
  _defineProperty(this, "_lastPopup", null);
107
106
  _defineProperty(this, "_activePopup", void 0);
108
107
  _defineProperty(this, "_activePopup$", new rxjs.BehaviorSubject(null));
109
108
  _defineProperty(this, "activePopup$", this._activePopup$.asObservable());
110
- this._initZenVisible();
111
109
  this.disposeWithMe(() => {
112
110
  this._activePopup$.complete();
113
111
  });
114
112
  }
115
- _initZenVisible() {
116
- this.disposeWithMe(this._zenZoneService.visible$.subscribe((visible) => {
117
- if (visible) this.hidePopup();
118
- }));
119
- }
120
113
  dispose() {
121
114
  super.dispose();
122
115
  this.hidePopup();
@@ -130,7 +123,6 @@ let SheetsThreadCommentPopupService = class SheetsThreadCommentPopupService exte
130
123
  return;
131
124
  }
132
125
  if (this._lastPopup) this._lastPopup.dispose();
133
- if (this._zenZoneService.visible) return;
134
126
  this._activePopup = location;
135
127
  this._activePopup$.next(location);
136
128
  const popupDisposable = this._cellPopupManagerService.showPopup({
@@ -171,11 +163,7 @@ let SheetsThreadCommentPopupService = class SheetsThreadCommentPopupService exte
171
163
  this._activePopup$.next(this._activePopup);
172
164
  }
173
165
  };
174
- SheetsThreadCommentPopupService = __decorate([
175
- __decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.SheetCanvasPopManagerService)),
176
- __decorateParam(1, _univerjs_ui.IZenZoneService),
177
- __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.CellPopupManagerService))
178
- ], SheetsThreadCommentPopupService);
166
+ SheetsThreadCommentPopupService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.SheetCanvasPopManagerService)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.CellPopupManagerService))], SheetsThreadCommentPopupService);
179
167
 
180
168
  //#endregion
181
169
  //#region src/commands/operations/comment.operation.ts
@@ -237,7 +225,7 @@ const ToggleSheetCommentPanelOperation = {
237
225
  //#endregion
238
226
  //#region package.json
239
227
  var name = "@univerjs/sheets-thread-comment-ui";
240
- var version = "0.25.0";
228
+ var version = "1.0.0-alpha.0";
241
229
 
242
230
  //#endregion
243
231
  //#region src/config/config.ts
@@ -245,6 +233,197 @@ const SHEETS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY = "sheets-thread-comment.config
245
233
  const configSymbol = Symbol(SHEETS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY);
246
234
  const defaultPluginConfig = {};
247
235
 
236
+ //#endregion
237
+ //#region src/views/SheetsThreadCommentCell.tsx
238
+ const SheetsThreadCommentCell = () => {
239
+ const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
240
+ const sheetsThreadCommentPopupService = (0, _univerjs_ui.useDependency)(SheetsThreadCommentPopupService);
241
+ const activePopup = (0, _univerjs_ui.useObservable)(sheetsThreadCommentPopupService.activePopup$);
242
+ const sheetThreadCommentModel = (0, _univerjs_ui.useDependency)(_univerjs_sheets_thread_comment.SheetsThreadCommentModel);
243
+ (0, _univerjs_ui.useObservable)(sheetThreadCommentModel.commentUpdate$);
244
+ if (!activePopup) return null;
245
+ const { row, col, unitId, subUnitId, trigger } = activePopup;
246
+ const rootId = sheetThreadCommentModel.getByLocation(unitId, subUnitId, row, col);
247
+ const ref = `${_univerjs_core.Tools.chatAtABC(col)}${row + 1}`;
248
+ const onClose = () => {
249
+ sheetsThreadCommentPopupService.hidePopup();
250
+ };
251
+ const getSubUnitName = (id) => {
252
+ var _univerInstanceServic, _univerInstanceServic2;
253
+ return (_univerInstanceServic = (_univerInstanceServic2 = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic2 === void 0 || (_univerInstanceServic2 = _univerInstanceServic2.getSheetBySheetId(id)) === null || _univerInstanceServic2 === void 0 ? void 0 : _univerInstanceServic2.getName()) !== null && _univerInstanceServic !== void 0 ? _univerInstanceServic : "";
254
+ };
255
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_thread_comment_ui.ThreadCommentTree, {
256
+ onClick: () => {
257
+ sheetsThreadCommentPopupService.persistPopup();
258
+ },
259
+ location: _univerjs_thread_comment_ui.ThreadCommentTreeLocation.CELL,
260
+ id: rootId,
261
+ unitId,
262
+ subUnitId,
263
+ type: _univerjs_core.UniverInstanceType.UNIVER_SHEET,
264
+ refStr: ref,
265
+ onClose,
266
+ getSubUnitName,
267
+ autoFocus: trigger === "context-menu"
268
+ });
269
+ };
270
+
271
+ //#endregion
272
+ //#region src/views/SheetsThreadCommentPanel.tsx
273
+ const SheetsThreadCommentPanel = () => {
274
+ var _workbook$getActiveSh;
275
+ const markSelectionService = (0, _univerjs_ui.useDependency)(_univerjs_sheets_ui.IMarkSelectionService);
276
+ const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
277
+ const sheetsThreadCommentPopupService = (0, _univerjs_ui.useDependency)(SheetsThreadCommentPopupService);
278
+ const workbook = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
279
+ const unitId = workbook.getUnitId();
280
+ const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
281
+ const subUnitId$ = (0, react.useMemo)(() => workbook.activeSheet$.pipe((0, rxjs.map)((i) => i === null || i === void 0 ? void 0 : i.getSheetId())), [workbook.activeSheet$]);
282
+ const subUnitId = (0, _univerjs_ui.useObservable)(subUnitId$, (_workbook$getActiveSh = workbook.getActiveSheet()) === null || _workbook$getActiveSh === void 0 ? void 0 : _workbook$getActiveSh.getSheetId());
283
+ const hoverShapeId = (0, react.useRef)(null);
284
+ const panelService = (0, _univerjs_ui.useDependency)(_univerjs_thread_comment_ui.ThreadCommentPanelService);
285
+ const activeCommentId = (0, _univerjs_ui.useObservable)(panelService.activeCommentId$);
286
+ const panelVisible = (0, _univerjs_ui.useObservable)(panelService.panelVisible$, panelService.panelVisible);
287
+ const sortComments = (0, react.useCallback)((comments) => {
288
+ const worksheets = workbook.getSheets();
289
+ const sheetIndex = {};
290
+ worksheets.forEach((sheet, i) => {
291
+ sheetIndex[sheet.getSheetId()] = i;
292
+ });
293
+ const sort = (comments) => {
294
+ return comments.map((comment) => {
295
+ var _sheetIndex$comment$s;
296
+ const ref = (0, _univerjs_engine_formula.singleReferenceToGrid)(comment.ref);
297
+ const p = [
298
+ (_sheetIndex$comment$s = sheetIndex[comment.subUnitId]) !== null && _sheetIndex$comment$s !== void 0 ? _sheetIndex$comment$s : 0,
299
+ ref.row,
300
+ ref.column
301
+ ];
302
+ return {
303
+ ...comment,
304
+ p
305
+ };
306
+ }).sort((pre, aft) => {
307
+ if (pre.p[0] === aft.p[0]) {
308
+ if (pre.p[1] === aft.p[1]) return pre.p[2] - aft.p[2];
309
+ return pre.p[1] - aft.p[1];
310
+ }
311
+ return pre.p[0] - aft.p[0];
312
+ });
313
+ };
314
+ return [...sort(comments.filter((comment) => !comment.resolved)), ...sort(comments.filter((comment) => comment.resolved))];
315
+ }, [workbook]);
316
+ const showShape = (0, react.useCallback)((comment) => {
317
+ if (comment.unitId === unitId && comment.subUnitId === subUnitId && !comment.resolved) {
318
+ var _worksheet$getMergedC;
319
+ const { row, column } = (0, _univerjs_engine_formula.singleReferenceToGrid)(comment.ref);
320
+ const worksheet = workbook.getSheetBySheetId(comment.subUnitId);
321
+ const mergeInfo = (_worksheet$getMergedC = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(row, column)) !== null && _worksheet$getMergedC !== void 0 ? _worksheet$getMergedC : {
322
+ startColumn: column,
323
+ endColumn: column,
324
+ startRow: row,
325
+ endRow: row
326
+ };
327
+ if (!Number.isNaN(row) && !Number.isNaN(column)) return markSelectionService.addShape({
328
+ range: mergeInfo,
329
+ style: {
330
+ fill: "rgb(255, 189, 55, 0.35)",
331
+ strokeWidth: 1,
332
+ stroke: "#FFBD37",
333
+ widgets: {}
334
+ },
335
+ primary: null
336
+ });
337
+ }
338
+ return null;
339
+ }, [
340
+ markSelectionService,
341
+ subUnitId,
342
+ unitId
343
+ ]);
344
+ const getSubUnitName = (id) => {
345
+ var _workbook$getSheetByS, _workbook$getSheetByS2;
346
+ return (_workbook$getSheetByS = (_workbook$getSheetByS2 = workbook.getSheetBySheetId(id)) === null || _workbook$getSheetByS2 === void 0 ? void 0 : _workbook$getSheetByS2.getName()) !== null && _workbook$getSheetByS !== void 0 ? _workbook$getSheetByS : "";
347
+ };
348
+ const handleAdd = () => {
349
+ commandService.executeCommand(ShowAddSheetCommentModalOperation.id);
350
+ };
351
+ const handleHover = (comment) => {
352
+ if (hoverShapeId.current) {
353
+ markSelectionService.removeShape(hoverShapeId.current);
354
+ hoverShapeId.current = null;
355
+ }
356
+ if (activeCommentId && activeCommentId.unitId === comment.unitId && activeCommentId.subUnitId === comment.subUnitId && activeCommentId.commentId === comment.id) return;
357
+ hoverShapeId.current = showShape(comment);
358
+ };
359
+ const handleLeave = () => {
360
+ if (hoverShapeId.current) {
361
+ markSelectionService.removeShape(hoverShapeId.current);
362
+ hoverShapeId.current = null;
363
+ }
364
+ };
365
+ const handleResolve = (id, resolved) => {
366
+ if (resolved) sheetsThreadCommentPopupService.hidePopup();
367
+ };
368
+ (0, react.useEffect)(() => {
369
+ if (!panelVisible && hoverShapeId.current) {
370
+ markSelectionService.removeShape(hoverShapeId.current);
371
+ hoverShapeId.current = null;
372
+ }
373
+ }, [markSelectionService, panelVisible]);
374
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_thread_comment_ui.ThreadCommentPanel, {
375
+ unitId,
376
+ subUnitId$,
377
+ type: _univerjs_core.UniverInstanceType.UNIVER_SHEET,
378
+ onAdd: handleAdd,
379
+ getSubUnitName,
380
+ onResolve: handleResolve,
381
+ sortComments,
382
+ onItemEnter: handleHover,
383
+ onItemLeave: handleLeave,
384
+ onDeleteComment: () => {
385
+ handleLeave();
386
+ return true;
387
+ }
388
+ });
389
+ };
390
+
391
+ //#endregion
392
+ //#region src/controllers/components.controller.ts
393
+ /**
394
+ * Copyright 2023-present DreamNum Co., Ltd.
395
+ *
396
+ * Licensed under the Apache License, Version 2.0 (the "License");
397
+ * you may not use this file except in compliance with the License.
398
+ * You may obtain a copy of the License at
399
+ *
400
+ * http://www.apache.org/licenses/LICENSE-2.0
401
+ *
402
+ * Unless required by applicable law or agreed to in writing, software
403
+ * distributed under the License is distributed on an "AS IS" BASIS,
404
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
405
+ * See the License for the specific language governing permissions and
406
+ * limitations under the License.
407
+ */
408
+ let ComponentsController = class ComponentsController extends _univerjs_core.Disposable {
409
+ constructor(_componentManager, _iconManager) {
410
+ super();
411
+ this._componentManager = _componentManager;
412
+ this._iconManager = _iconManager;
413
+ this._registerComponents();
414
+ this._registerIcons();
415
+ }
416
+ _registerComponents() {
417
+ [[SHEETS_THREAD_COMMENT_MODAL, SheetsThreadCommentCell], [SHEETS_THREAD_COMMENT_PANEL, SheetsThreadCommentPanel]].forEach(([key, comp]) => {
418
+ this.disposeWithMe(this._componentManager.register(key, comp));
419
+ });
420
+ }
421
+ _registerIcons() {
422
+ this.disposeWithMe(this._iconManager.register({ CommentIcon: _univerjs_icons.CommentIcon }));
423
+ }
424
+ };
425
+ ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
426
+
248
427
  //#endregion
249
428
  //#region src/controllers/render-controllers/render.controller.ts
250
429
  let SheetsThreadCommentRenderController = class SheetsThreadCommentRenderController extends _univerjs_core.Disposable {
@@ -788,158 +967,6 @@ const menuSchema = {
788
967
  } } }
789
968
  };
790
969
 
791
- //#endregion
792
- //#region src/views/sheets-thread-comment-cell/index.tsx
793
- const SheetsThreadCommentCell = () => {
794
- const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
795
- const sheetsThreadCommentPopupService = (0, _univerjs_ui.useDependency)(SheetsThreadCommentPopupService);
796
- const activePopup = (0, _univerjs_ui.useObservable)(sheetsThreadCommentPopupService.activePopup$);
797
- const sheetThreadCommentModel = (0, _univerjs_ui.useDependency)(_univerjs_sheets_thread_comment.SheetsThreadCommentModel);
798
- (0, _univerjs_ui.useObservable)(sheetThreadCommentModel.commentUpdate$);
799
- if (!activePopup) return null;
800
- const { row, col, unitId, subUnitId, trigger } = activePopup;
801
- const rootId = sheetThreadCommentModel.getByLocation(unitId, subUnitId, row, col);
802
- const ref = `${_univerjs_core.Tools.chatAtABC(col)}${row + 1}`;
803
- const onClose = () => {
804
- sheetsThreadCommentPopupService.hidePopup();
805
- };
806
- const getSubUnitName = (id) => {
807
- var _univerInstanceServic, _univerInstanceServic2;
808
- return (_univerInstanceServic = (_univerInstanceServic2 = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic2 === void 0 || (_univerInstanceServic2 = _univerInstanceServic2.getSheetBySheetId(id)) === null || _univerInstanceServic2 === void 0 ? void 0 : _univerInstanceServic2.getName()) !== null && _univerInstanceServic !== void 0 ? _univerInstanceServic : "";
809
- };
810
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_thread_comment_ui.ThreadCommentTree, {
811
- onClick: () => {
812
- sheetsThreadCommentPopupService.persistPopup();
813
- },
814
- location: _univerjs_thread_comment_ui.ThreadCommentTreeLocation.CELL,
815
- id: rootId,
816
- unitId,
817
- subUnitId,
818
- type: _univerjs_core.UniverInstanceType.UNIVER_SHEET,
819
- refStr: ref,
820
- onClose,
821
- getSubUnitName,
822
- autoFocus: trigger === "context-menu"
823
- });
824
- };
825
-
826
- //#endregion
827
- //#region src/views/sheets-thread-comment-panel/index.tsx
828
- const SheetsThreadCommentPanel = () => {
829
- var _workbook$getActiveSh;
830
- const markSelectionService = (0, _univerjs_ui.useDependency)(_univerjs_sheets_ui.IMarkSelectionService);
831
- const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
832
- const sheetsThreadCommentPopupService = (0, _univerjs_ui.useDependency)(SheetsThreadCommentPopupService);
833
- const workbook = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
834
- const unitId = workbook.getUnitId();
835
- const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
836
- const subUnitId$ = (0, react.useMemo)(() => workbook.activeSheet$.pipe((0, rxjs.map)((i) => i === null || i === void 0 ? void 0 : i.getSheetId())), [workbook.activeSheet$]);
837
- const subUnitId = (0, _univerjs_ui.useObservable)(subUnitId$, (_workbook$getActiveSh = workbook.getActiveSheet()) === null || _workbook$getActiveSh === void 0 ? void 0 : _workbook$getActiveSh.getSheetId());
838
- const hoverShapeId = (0, react.useRef)(null);
839
- const panelService = (0, _univerjs_ui.useDependency)(_univerjs_thread_comment_ui.ThreadCommentPanelService);
840
- const activeCommentId = (0, _univerjs_ui.useObservable)(panelService.activeCommentId$);
841
- const panelVisible = (0, _univerjs_ui.useObservable)(panelService.panelVisible$, panelService.panelVisible);
842
- const sortComments = (0, react.useCallback)((comments) => {
843
- const worksheets = workbook.getSheets();
844
- const sheetIndex = {};
845
- worksheets.forEach((sheet, i) => {
846
- sheetIndex[sheet.getSheetId()] = i;
847
- });
848
- const sort = (comments) => {
849
- return comments.map((comment) => {
850
- var _sheetIndex$comment$s;
851
- const ref = (0, _univerjs_engine_formula.singleReferenceToGrid)(comment.ref);
852
- const p = [
853
- (_sheetIndex$comment$s = sheetIndex[comment.subUnitId]) !== null && _sheetIndex$comment$s !== void 0 ? _sheetIndex$comment$s : 0,
854
- ref.row,
855
- ref.column
856
- ];
857
- return {
858
- ...comment,
859
- p
860
- };
861
- }).sort((pre, aft) => {
862
- if (pre.p[0] === aft.p[0]) {
863
- if (pre.p[1] === aft.p[1]) return pre.p[2] - aft.p[2];
864
- return pre.p[1] - aft.p[1];
865
- }
866
- return pre.p[0] - aft.p[0];
867
- });
868
- };
869
- return [...sort(comments.filter((comment) => !comment.resolved)), ...sort(comments.filter((comment) => comment.resolved))];
870
- }, [workbook]);
871
- const showShape = (0, react.useCallback)((comment) => {
872
- if (comment.unitId === unitId && comment.subUnitId === subUnitId && !comment.resolved) {
873
- var _worksheet$getMergedC;
874
- const { row, column } = (0, _univerjs_engine_formula.singleReferenceToGrid)(comment.ref);
875
- const worksheet = workbook.getSheetBySheetId(comment.subUnitId);
876
- const mergeInfo = (_worksheet$getMergedC = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getMergedCell(row, column)) !== null && _worksheet$getMergedC !== void 0 ? _worksheet$getMergedC : {
877
- startColumn: column,
878
- endColumn: column,
879
- startRow: row,
880
- endRow: row
881
- };
882
- if (!Number.isNaN(row) && !Number.isNaN(column)) return markSelectionService.addShape({
883
- range: mergeInfo,
884
- style: {
885
- fill: "rgb(255, 189, 55, 0.35)",
886
- strokeWidth: 1,
887
- stroke: "#FFBD37",
888
- widgets: {}
889
- },
890
- primary: null
891
- });
892
- }
893
- return null;
894
- }, [
895
- markSelectionService,
896
- subUnitId,
897
- unitId
898
- ]);
899
- const getSubUnitName = (id) => {
900
- var _workbook$getSheetByS, _workbook$getSheetByS2;
901
- return (_workbook$getSheetByS = (_workbook$getSheetByS2 = workbook.getSheetBySheetId(id)) === null || _workbook$getSheetByS2 === void 0 ? void 0 : _workbook$getSheetByS2.getName()) !== null && _workbook$getSheetByS !== void 0 ? _workbook$getSheetByS : "";
902
- };
903
- const handleAdd = () => {
904
- commandService.executeCommand(ShowAddSheetCommentModalOperation.id);
905
- };
906
- const handleHover = (comment) => {
907
- if (activeCommentId && activeCommentId.unitId === comment.unitId && activeCommentId.subUnitId === comment.subUnitId && activeCommentId.commentId === comment.id) return;
908
- if (hoverShapeId.current) {
909
- markSelectionService.removeShape(hoverShapeId.current);
910
- hoverShapeId.current = null;
911
- }
912
- hoverShapeId.current = showShape(comment);
913
- };
914
- const handleLeave = () => {
915
- if (hoverShapeId.current) {
916
- markSelectionService.removeShape(hoverShapeId.current);
917
- hoverShapeId.current = null;
918
- }
919
- };
920
- const handleResolve = (id, resolved) => {
921
- if (resolved) sheetsThreadCommentPopupService.hidePopup();
922
- };
923
- (0, react.useEffect)(() => {
924
- if (!panelVisible && hoverShapeId.current) markSelectionService.removeShape(hoverShapeId.current);
925
- }, [markSelectionService, panelVisible]);
926
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_thread_comment_ui.ThreadCommentPanel, {
927
- unitId,
928
- subUnitId$,
929
- type: _univerjs_core.UniverInstanceType.UNIVER_SHEET,
930
- onAdd: handleAdd,
931
- getSubUnitName,
932
- onResolve: handleResolve,
933
- sortComments,
934
- onItemEnter: handleHover,
935
- onItemLeave: handleLeave,
936
- onDeleteComment: () => {
937
- handleLeave();
938
- return true;
939
- }
940
- });
941
- };
942
-
943
970
  //#endregion
944
971
  //#region src/controllers/sheets-thread-comment.controller.ts
945
972
  /**
@@ -958,14 +985,12 @@ const SheetsThreadCommentPanel = () => {
958
985
  * limitations under the License.
959
986
  */
960
987
  let SheetsThreadCommentController = class SheetsThreadCommentController extends _univerjs_core.Disposable {
961
- constructor(_menuManagerService, _componentManager, _shortcutService) {
988
+ constructor(_menuManagerService, _shortcutService) {
962
989
  super();
963
990
  this._menuManagerService = _menuManagerService;
964
- this._componentManager = _componentManager;
965
991
  this._shortcutService = _shortcutService;
966
992
  this._initMenu();
967
993
  this._initShortcut();
968
- this._initComponent();
969
994
  }
970
995
  _initShortcut() {
971
996
  this._shortcutService.registerShortcut(AddCommentShortcut);
@@ -973,21 +998,8 @@ let SheetsThreadCommentController = class SheetsThreadCommentController extends
973
998
  _initMenu() {
974
999
  this._menuManagerService.mergeMenu(menuSchema);
975
1000
  }
976
- _initComponent() {
977
- [
978
- [SHEETS_THREAD_COMMENT_MODAL, SheetsThreadCommentCell],
979
- [SHEETS_THREAD_COMMENT_PANEL, SheetsThreadCommentPanel],
980
- ["CommentIcon", _univerjs_icons.CommentIcon]
981
- ].forEach(([key, comp]) => {
982
- this.disposeWithMe(this._componentManager.register(key, comp));
983
- });
984
- }
985
1001
  };
986
- SheetsThreadCommentController = __decorate([
987
- __decorateParam(0, _univerjs_ui.IMenuManagerService),
988
- __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)),
989
- __decorateParam(2, _univerjs_ui.IShortcutService)
990
- ], SheetsThreadCommentController);
1002
+ SheetsThreadCommentController = __decorate([__decorateParam(0, _univerjs_ui.IMenuManagerService), __decorateParam(1, _univerjs_ui.IShortcutService)], SheetsThreadCommentController);
991
1003
 
992
1004
  //#endregion
993
1005
  //#region src/plugin.ts
@@ -1003,6 +1015,8 @@ let UniverSheetsThreadCommentUIPlugin = class UniverSheetsThreadCommentUIPlugin
1003
1015
  this._configService.setConfig(SHEETS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY, rest);
1004
1016
  }
1005
1017
  onStarting() {
1018
+ this._injector.add([ComponentsController]);
1019
+ this._injector.get(ComponentsController);
1006
1020
  [
1007
1021
  [SheetsThreadCommentController],
1008
1022
  [SheetsThreadCommentRenderController],
@@ -1041,36 +1055,6 @@ UniverSheetsThreadCommentUIPlugin = __decorate([
1041
1055
  ], UniverSheetsThreadCommentUIPlugin);
1042
1056
 
1043
1057
  //#endregion
1044
- Object.defineProperty(exports, 'AddCommentCommand', {
1045
- enumerable: true,
1046
- get: function () {
1047
- return _univerjs_thread_comment.AddCommentCommand;
1048
- }
1049
- });
1050
- Object.defineProperty(exports, 'DeleteCommentCommand', {
1051
- enumerable: true,
1052
- get: function () {
1053
- return _univerjs_thread_comment.DeleteCommentCommand;
1054
- }
1055
- });
1056
- Object.defineProperty(exports, 'DeleteCommentTreeCommand', {
1057
- enumerable: true,
1058
- get: function () {
1059
- return _univerjs_thread_comment.DeleteCommentTreeCommand;
1060
- }
1061
- });
1062
- Object.defineProperty(exports, 'IThreadCommentDataSourceService', {
1063
- enumerable: true,
1064
- get: function () {
1065
- return _univerjs_thread_comment.IThreadCommentDataSourceService;
1066
- }
1067
- });
1068
- Object.defineProperty(exports, 'ResolveCommentCommand', {
1069
- enumerable: true,
1070
- get: function () {
1071
- return _univerjs_thread_comment.ResolveCommentCommand;
1072
- }
1073
- });
1074
1058
  Object.defineProperty(exports, 'SheetsThreadCommentPopupService', {
1075
1059
  enumerable: true,
1076
1060
  get: function () {
@@ -1084,16 +1068,4 @@ Object.defineProperty(exports, 'UniverSheetsThreadCommentUIPlugin', {
1084
1068
  get: function () {
1085
1069
  return UniverSheetsThreadCommentUIPlugin;
1086
1070
  }
1087
- });
1088
- Object.defineProperty(exports, 'UniverThreadCommentUIPlugin', {
1089
- enumerable: true,
1090
- get: function () {
1091
- return _univerjs_thread_comment_ui.UniverThreadCommentUIPlugin;
1092
- }
1093
- });
1094
- Object.defineProperty(exports, 'UpdateCommentCommand', {
1095
- enumerable: true,
1096
- get: function () {
1097
- return _univerjs_thread_comment.UpdateCommentCommand;
1098
- }
1099
1071
  });