@univerjs/sheets-thread-comment 0.2.5 → 0.2.6

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/es/index.js CHANGED
@@ -1,86 +1,91 @@
1
- var xe = Object.defineProperty;
2
- var Ve = (o, e, n) => e in o ? xe(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
3
- var w = (o, e, n) => Ve(o, typeof e != "symbol" ? e + "" : e, n);
4
- import { Inject as l, Disposable as R, DisposableCollection as Ae, useDependency as y, IUniverInstanceService as N, Tools as me, UniverInstanceType as b, CommandType as je, ICommandService as re, OnLifecycle as B, LifecycleStages as H, Injector as pe, Range as Be, DependentOn as He, Plugin as Le } from "@univerjs/core";
5
- import { ICommandService as vn, Inject as _n, Injector as fn, Plugin as Cn, UniverInstanceType as Sn } from "@univerjs/core";
6
- import { ThreadCommentTree as ke, ThreadCommentPanelService as oe, ThreadCommentPanel as Fe, ToggleSheetCommentPanelOperation as We, SetActiveCommentOperation as ae, THREAD_COMMENT_PANEL as Ze, UniverThreadCommentUIPlugin as ze } from "@univerjs/thread-comment-ui";
7
- import { IThreadCommentMentionDataService as gn, UniverThreadCommentUIPlugin as Pn } from "@univerjs/thread-comment-ui";
8
- import { IZenZoneService as Ge, useObservable as V, KeyCode as Ke, MetaKeys as ce, MenuItemType as le, MenuPosition as ve, getMenuHiddenObservable as _e, MenuGroup as Ye, ComponentManager as qe, IMenuService as Xe, IShortcutService as Je } from "@univerjs/ui";
9
- import { SheetsSelectionsService as Qe, getSheetCommandTarget as et, WorkbookCommentPermission as q, WorksheetViewPermission as X, RangeProtectionPermissionViewPoint as J, SetSelectionsOperation as tt, SelectionMoveType as nt, SetWorksheetActiveOperation as rt, SheetInterceptorService as fe, INTERCEPTOR_POINT as ot, RemoveSheetCommand as it } from "@univerjs/sheets";
10
- import { singleReferenceToGrid as j, serializeRange as st } from "@univerjs/engine-formula";
11
- import { DeleteCommentMutation as K, IThreadCommentDataSourceService as Ce, AddCommentMutation as ne, ThreadCommentModel as at } from "@univerjs/thread-comment";
12
- import { IThreadCommentDataSourceService as bn } from "@univerjs/thread-comment";
13
- import { SheetCanvasPopManagerService as ct, IMarkSelectionService as Se, whenSheetEditorFocused as ut, getCurrentRangeDisable$ as Ie, SheetPermissionInterceptorBaseController as ge, ScrollToRangeOperation as dt, SheetSkeletonManagerService as ht, ISheetClipboardService as mt, COPY_TYPE as pt, HoverManagerService as lt } from "@univerjs/sheets-ui";
14
- import { SheetsThreadCommentModel as $, UniverSheetsThreadCommentBasePlugin as vt } from "@univerjs/sheets-thread-comment-base";
15
- import { SheetsThreadCommentModel as Mn } from "@univerjs/sheets-thread-comment-base";
16
- import Pe, { forwardRef as Te, useRef as be, createElement as we, useMemo as _t, useCallback as ue, useEffect as ft } from "react";
17
- import { BehaviorSubject as Ct, map as St, debounceTime as Me } from "rxjs";
18
- import { IRenderManagerService as It } from "@univerjs/engine-render";
19
- var I = function() {
20
- return I = Object.assign || function(o) {
21
- for (var e, n = 1, t = arguments.length; n < t; n++) {
22
- e = arguments[n];
23
- for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (o[r] = e[r]);
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
+ import { Inject, Disposable, DisposableCollection, useDependency, IUniverInstanceService, Tools, UniverInstanceType, CommandType, ICommandService, OnLifecycle, LifecycleStages, Injector, Range, DependentOn, Plugin } from "@univerjs/core";
6
+ import { ICommandService as ICommandService2, Inject as Inject2, Injector as Injector2, Plugin as Plugin2, UniverInstanceType as UniverInstanceType2 } from "@univerjs/core";
7
+ import { ThreadCommentTree, ThreadCommentPanelService, ThreadCommentPanel, ToggleSheetCommentPanelOperation, SetActiveCommentOperation, THREAD_COMMENT_PANEL, UniverThreadCommentUIPlugin } from "@univerjs/thread-comment-ui";
8
+ import { IThreadCommentMentionDataService, UniverThreadCommentUIPlugin as UniverThreadCommentUIPlugin2 } from "@univerjs/thread-comment-ui";
9
+ import { IZenZoneService, useObservable, KeyCode, MetaKeys, MenuItemType, MenuPosition, getMenuHiddenObservable, MenuGroup, ComponentManager, IMenuService, IShortcutService } from "@univerjs/ui";
10
+ import { SheetsSelectionsService, getSheetCommandTarget, WorkbookCommentPermission, WorksheetViewPermission, RangeProtectionPermissionViewPoint, SetSelectionsOperation, SelectionMoveType, SetWorksheetActiveOperation, SheetInterceptorService, INTERCEPTOR_POINT, RemoveSheetCommand } from "@univerjs/sheets";
11
+ import { singleReferenceToGrid, serializeRange } from "@univerjs/engine-formula";
12
+ import { DeleteCommentMutation, IThreadCommentDataSourceService, AddCommentMutation, ThreadCommentModel } from "@univerjs/thread-comment";
13
+ import { IThreadCommentDataSourceService as IThreadCommentDataSourceService2 } from "@univerjs/thread-comment";
14
+ import { SheetCanvasPopManagerService, IMarkSelectionService, whenSheetEditorFocused, getCurrentRangeDisable$, SheetPermissionInterceptorBaseController, ScrollToRangeOperation, SheetSkeletonManagerService, ISheetClipboardService, COPY_TYPE, HoverManagerService } from "@univerjs/sheets-ui";
15
+ import { SheetsThreadCommentModel, UniverSheetsThreadCommentBasePlugin } from "@univerjs/sheets-thread-comment-base";
16
+ import { SheetsThreadCommentModel as SheetsThreadCommentModel2 } from "@univerjs/sheets-thread-comment-base";
17
+ import React, { forwardRef, useRef, createElement, useMemo, useCallback, useEffect } from "react";
18
+ import { BehaviorSubject, map, debounceTime } from "rxjs";
19
+ import { IRenderManagerService } from "@univerjs/engine-render";
20
+ var __assign = function() {
21
+ return __assign = Object.assign || function(t) {
22
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
23
+ s = arguments[i];
24
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
24
25
  }
25
- return o;
26
- }, I.apply(this, arguments);
27
- }, gt = function(o, e) {
28
- var n = {};
29
- for (var t in o) Object.prototype.hasOwnProperty.call(o, t) && e.indexOf(t) < 0 && (n[t] = o[t]);
30
- if (o != null && typeof Object.getOwnPropertySymbols == "function")
31
- for (var r = 0, t = Object.getOwnPropertySymbols(o); r < t.length; r++)
32
- e.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(o, t[r]) && (n[t[r]] = o[t[r]]);
33
- return n;
34
- }, ye = Te(function(o, e) {
35
- var n = o.icon, t = o.id, r = o.className, i = o.extend, s = gt(o, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), c = be("_".concat(bt()));
36
- return Oe(n, "".concat(t), { defIds: n.defIds, idSuffix: c.current }, I({ ref: e, className: a }, s), i);
26
+ return t;
27
+ }, __assign.apply(this, arguments);
28
+ }, __rest = function(s, e) {
29
+ var t = {};
30
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
31
+ if (s != null && typeof Object.getOwnPropertySymbols == "function")
32
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
33
+ e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
34
+ return t;
35
+ }, IconBase = forwardRef(function(props, ref) {
36
+ var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
37
+ return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
37
38
  });
38
- function Oe(o, e, n, t, r) {
39
- return we(o.tag, I(I({ key: e }, Pt(o, n, r)), t), (Tt(o, n).children || []).map(function(i, s) {
40
- return Oe(i, "".concat(e, "-").concat(o.tag, "-").concat(s), n, void 0, r);
39
+ function render(node, id, runtimeProps, rootProps, extend) {
40
+ return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
41
+ return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
41
42
  }));
42
43
  }
43
- function Pt(o, e, n) {
44
- var t = I({}, o.attrs);
45
- n != null && n.colorChannel1 && t.fill === "colorChannel1" && (t.fill = n.colorChannel1);
46
- var r = e.defIds;
47
- return !r || r.length === 0 || (o.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + e.idSuffix), Object.entries(t).forEach(function(i) {
48
- var s = i[0], a = i[1];
49
- typeof a == "string" && (t[s] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
50
- })), t;
44
+ __name(render, "render");
45
+ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
46
+ var attrs = __assign({}, node.attrs);
47
+ extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
48
+ var defIds = runtimeProps.defIds;
49
+ return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a8) {
50
+ var key = _a8[0], value = _a8[1];
51
+ typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
52
+ })), attrs;
51
53
  }
52
- function Tt(o, e) {
53
- var n, t = e.defIds;
54
- return !t || t.length === 0 ? o : o.tag === "defs" && (!((n = o.children) === null || n === void 0) && n.length) ? I(I({}, o), { children: o.children.map(function(r) {
55
- return typeof r.attrs.id == "string" && t && t.indexOf(r.attrs.id) > -1 ? I(I({}, r), { attrs: I(I({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
56
- }) }) : o;
54
+ __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
55
+ function replaceRuntimeIdsInDefs(node, runtimeProps) {
56
+ var _a8, defIds = runtimeProps.defIds;
57
+ return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a8 = node.children) === null || _a8 === void 0) && _a8.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
58
+ return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
59
+ }) }) : node;
57
60
  }
58
- function bt() {
61
+ __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
62
+ function generateShortUuid() {
59
63
  return Math.random().toString(36).substring(2, 8);
60
64
  }
61
- ye.displayName = "UniverIcon";
62
- var wt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Ee = Te(function(o, e) {
63
- return we(ye, Object.assign({}, o, {
65
+ __name(generateShortUuid, "generateShortUuid");
66
+ IconBase.displayName = "UniverIcon";
67
+ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, CommentSingle = forwardRef(function(props, ref) {
68
+ return createElement(IconBase, Object.assign({}, props, {
64
69
  id: "comment-single",
65
- ref: e,
66
- icon: wt
70
+ ref,
71
+ icon: element
67
72
  }));
68
73
  });
69
- Ee.displayName = "CommentSingle";
70
- const Ue = "univer.sheet.thread-comment-modal", ie = "comment-single", Re = "SHEET_THREAD_COMMENT";
71
- var Mt = Object.defineProperty, yt = Object.getOwnPropertyDescriptor, Ot = (o, e, n, t) => {
72
- for (var r = t > 1 ? void 0 : t ? yt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
73
- (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
74
- return t && r && Mt(e, n, r), r;
75
- }, de = (o, e) => (n, t) => e(n, t, o);
76
- let O = class extends R {
77
- constructor(e, n) {
74
+ CommentSingle.displayName = "CommentSingle";
75
+ const SHEETS_THREAD_COMMENT_MODAL = "univer.sheet.thread-comment-modal", COMMENT_SINGLE_ICON = "comment-single", SHEETS_THREAD_COMMENT = "SHEET_THREAD_COMMENT";
76
+ var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
77
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
78
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
79
+ return kind && result && __defProp$6(target, key, result), result;
80
+ }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a;
81
+ let SheetsThreadCommentPopupService = (_a = class extends Disposable {
82
+ constructor(_canvasPopupManagerService, _zenZoneService) {
78
83
  super();
79
- w(this, "_lastPopup", null);
80
- w(this, "_activePopup");
81
- w(this, "_activePopup$", new Ct(null));
82
- w(this, "activePopup$", this._activePopup$.asObservable());
83
- this._canvasPopupManagerService = e, this._zenZoneService = n, this._initZenVisible(), this.disposeWithMe(() => {
84
+ __publicField(this, "_lastPopup", null);
85
+ __publicField(this, "_activePopup");
86
+ __publicField(this, "_activePopup$", new BehaviorSubject(null));
87
+ __publicField(this, "activePopup$", this._activePopup$.asObservable());
88
+ this._canvasPopupManagerService = _canvasPopupManagerService, this._zenZoneService = _zenZoneService, this._initZenVisible(), this.disposeWithMe(() => {
84
89
  this._activePopup$.complete();
85
90
  });
86
91
  }
@@ -88,28 +93,28 @@ let O = class extends R {
88
93
  return this._activePopup;
89
94
  }
90
95
  _initZenVisible() {
91
- this.disposeWithMe(this._zenZoneService.visible$.subscribe((e) => {
92
- e && this.hidePopup();
96
+ this.disposeWithMe(this._zenZoneService.visible$.subscribe((visible) => {
97
+ visible && this.hidePopup();
93
98
  }));
94
99
  }
95
- showPopup(e, n) {
96
- var u;
97
- const { row: t, col: r, unitId: i, subUnitId: s } = e;
98
- if (this._activePopup && t === this._activePopup.row && r === this._activePopup.col && i === this._activePopup.unitId && s === ((u = this.activePopup) == null ? void 0 : u.subUnitId)) {
99
- this._activePopup = e, this._activePopup$.next(e);
100
+ showPopup(location, onHide) {
101
+ var _a8;
102
+ const { row, col, unitId, subUnitId } = location;
103
+ if (this._activePopup && row === this._activePopup.row && col === this._activePopup.col && unitId === this._activePopup.unitId && subUnitId === ((_a8 = this.activePopup) == null ? void 0 : _a8.subUnitId)) {
104
+ this._activePopup = location, this._activePopup$.next(location);
100
105
  return;
101
106
  }
102
107
  if (this._lastPopup && this._lastPopup.dispose(), this._zenZoneService.visible)
103
108
  return;
104
- this._activePopup = e, this._activePopup$.next(e);
105
- const a = this._canvasPopupManagerService.attachPopupToCell(
106
- t,
107
- r,
109
+ this._activePopup = location, this._activePopup$.next(location);
110
+ const popupDisposable = this._canvasPopupManagerService.attachPopupToCell(
111
+ row,
112
+ col,
108
113
  {
109
- componentKey: Ue,
110
- onClickOutside: () => {
114
+ componentKey: SHEETS_THREAD_COMMENT_MODAL,
115
+ onClickOutside: /* @__PURE__ */ __name(() => {
111
116
  this.hidePopup();
112
- },
117
+ }, "onClickOutside"),
113
118
  direction: "horizontal",
114
119
  excludeOutside: [
115
120
  ...Array.from(document.querySelectorAll(".univer-thread-comment")),
@@ -117,14 +122,14 @@ let O = class extends R {
117
122
  ].filter(Boolean)
118
123
  }
119
124
  );
120
- if (!a)
125
+ if (!popupDisposable)
121
126
  throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");
122
- const c = new Ae();
123
- c.add(a), c.add({
124
- dispose: () => {
125
- n == null || n();
126
- }
127
- }), this._lastPopup = c;
127
+ const disposableCollection = new DisposableCollection();
128
+ disposableCollection.add(popupDisposable), disposableCollection.add({
129
+ dispose: /* @__PURE__ */ __name(() => {
130
+ onHide == null || onHide();
131
+ }, "dispose")
132
+ }), this._lastPopup = disposableCollection;
128
133
  }
129
134
  hidePopup() {
130
135
  this._activePopup && (this._lastPopup && this._lastPopup.dispose(), this._lastPopup = null, this._activePopup = null, this._activePopup$.next(null));
@@ -135,92 +140,92 @@ let O = class extends R {
135
140
  temp: !1
136
141
  }, this._activePopup$.next(this._activePopup));
137
142
  }
138
- };
139
- O = Ot([
140
- de(0, l(ct)),
141
- de(1, Ge)
142
- ], O);
143
- const Et = () => {
144
- const o = y(N), e = y(O), n = V(e.activePopup$), t = y($);
145
- if (V(t.commentUpdate$), !n)
143
+ }, __name(_a, "SheetsThreadCommentPopupService"), _a);
144
+ SheetsThreadCommentPopupService = __decorateClass$6([
145
+ __decorateParam$6(0, Inject(SheetCanvasPopManagerService)),
146
+ __decorateParam$6(1, IZenZoneService)
147
+ ], SheetsThreadCommentPopupService);
148
+ const SheetsThreadCommentCell = /* @__PURE__ */ __name(() => {
149
+ const univerInstanceService = useDependency(IUniverInstanceService), sheetsThreadCommentPopupService = useDependency(SheetsThreadCommentPopupService), activePopup = useObservable(sheetsThreadCommentPopupService.activePopup$), sheetThreadCommentModel = useDependency(SheetsThreadCommentModel);
150
+ if (useObservable(sheetThreadCommentModel.commentUpdate$), !activePopup)
146
151
  return null;
147
- const { row: r, col: i, unitId: s, subUnitId: a, trigger: c } = n, u = t.getByLocation(s, a, r, i), h = `${me.chatAtABC(i)}${r + 1}`, d = () => {
148
- e.hidePopup();
149
- }, p = (v) => {
150
- var g, f, E;
151
- return (E = (f = (g = o.getCurrentUnitForType(b.UNIVER_SHEET)) == null ? void 0 : g.getSheetBySheetId(v)) == null ? void 0 : f.getName()) != null ? E : "";
152
- };
153
- return /* @__PURE__ */ Pe.createElement(
154
- ke,
152
+ const { row, col, unitId, subUnitId, trigger } = activePopup, rootId = sheetThreadCommentModel.getByLocation(unitId, subUnitId, row, col), ref = `${Tools.chatAtABC(col)}${row + 1}`, onClose = /* @__PURE__ */ __name(() => {
153
+ sheetsThreadCommentPopupService.hidePopup();
154
+ }, "onClose"), getSubUnitName = /* @__PURE__ */ __name((id) => {
155
+ var _a8, _b, _c;
156
+ return (_c = (_b = (_a8 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a8.getSheetBySheetId(id)) == null ? void 0 : _b.getName()) != null ? _c : "";
157
+ }, "getSubUnitName");
158
+ return /* @__PURE__ */ React.createElement(
159
+ ThreadCommentTree,
155
160
  {
156
- onClick: () => {
157
- e.persistPopup();
158
- },
161
+ onClick: /* @__PURE__ */ __name(() => {
162
+ sheetsThreadCommentPopupService.persistPopup();
163
+ }, "onClick"),
159
164
  prefix: "cell",
160
- id: u,
161
- unitId: s,
162
- subUnitId: a,
163
- type: b.UNIVER_SHEET,
164
- refStr: h,
165
- onClose: d,
166
- getSubUnitName: p,
167
- autoFocus: c === "context-menu"
165
+ id: rootId,
166
+ unitId,
167
+ subUnitId,
168
+ type: UniverInstanceType.UNIVER_SHEET,
169
+ refStr: ref,
170
+ onClose,
171
+ getSubUnitName,
172
+ autoFocus: trigger === "context-menu"
168
173
  }
169
174
  );
170
- }, Q = {
171
- type: je.OPERATION,
175
+ }, "SheetsThreadCommentCell"), ShowAddSheetCommentModalOperation = {
176
+ type: CommandType.OPERATION,
172
177
  id: "sheets.operation.show-comment-modal",
173
- handler(o) {
174
- var g;
175
- const e = o.get(Qe), n = o.get(N), t = o.get(O), r = o.get(oe), i = (g = e.getCurrentLastSelection()) == null ? void 0 : g.primary, s = o.get($);
176
- if (!i)
178
+ handler(accessor) {
179
+ var _a8;
180
+ const selectionManagerService = accessor.get(SheetsSelectionsService), univerInstanceService = accessor.get(IUniverInstanceService), sheetsThreadCommentPopupService = accessor.get(SheetsThreadCommentPopupService), threadCommentPanelService = accessor.get(ThreadCommentPanelService), activeCell = (_a8 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a8.primary, model = accessor.get(SheetsThreadCommentModel);
181
+ if (!activeCell)
177
182
  return !1;
178
- const a = et(n);
179
- if (!a)
183
+ const result = getSheetCommandTarget(univerInstanceService);
184
+ if (!result)
180
185
  return !1;
181
- const { workbook: c, worksheet: u, unitId: h, subUnitId: d } = a, p = {
182
- workbook: c,
183
- worksheet: u,
184
- unitId: h,
185
- subUnitId: d,
186
- row: i.startRow,
187
- col: i.startColumn
186
+ const { workbook, worksheet, unitId, subUnitId } = result, location = {
187
+ workbook,
188
+ worksheet,
189
+ unitId,
190
+ subUnitId,
191
+ row: activeCell.startRow,
192
+ col: activeCell.startColumn
188
193
  };
189
- t.showPopup(p);
190
- const v = s.getByLocation(h, d, i.startRow, i.startColumn);
191
- return v && r.setActiveComment({
192
- unitId: h,
193
- subUnitId: d,
194
- commentId: v,
194
+ sheetsThreadCommentPopupService.showPopup(location);
195
+ const rootId = model.getByLocation(unitId, subUnitId, activeCell.startRow, activeCell.startColumn);
196
+ return rootId && threadCommentPanelService.setActiveComment({
197
+ unitId,
198
+ subUnitId,
199
+ commentId: rootId,
195
200
  trigger: "context-menu"
196
201
  }), !0;
197
202
  }
198
- }, Ut = () => {
199
- var C;
200
- const o = y(Se), e = y(N), n = y(O), t = e.getCurrentUnitForType(b.UNIVER_SHEET), r = t.getUnitId(), i = y(re), s = _t(() => t.activeSheet$.pipe(St((m) => m == null ? void 0 : m.getSheetId())), [t.activeSheet$]), a = V(s, (C = t.getActiveSheet()) == null ? void 0 : C.getSheetId()), c = be(), u = y(oe), h = V(u.activeCommentId$), d = V(u.panelVisible$, u.panelVisible), p = ue((m) => {
201
- const _ = t.getSheets(), S = {};
202
- _.forEach((U, P) => {
203
- S[U.getSheetId()] = P;
203
+ }, SheetsThreadCommentPanel = /* @__PURE__ */ __name(() => {
204
+ var _a8;
205
+ const markSelectionService = useDependency(IMarkSelectionService), univerInstanceService = useDependency(IUniverInstanceService), sheetsThreadCommentPopupService = useDependency(SheetsThreadCommentPopupService), workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), commandService = useDependency(ICommandService), subUnitId$ = useMemo(() => workbook.activeSheet$.pipe(map((i) => i == null ? void 0 : i.getSheetId())), [workbook.activeSheet$]), subUnitId = useObservable(subUnitId$, (_a8 = workbook.getActiveSheet()) == null ? void 0 : _a8.getSheetId()), hoverShapeId = useRef(), panelService = useDependency(ThreadCommentPanelService), activeCommentId = useObservable(panelService.activeCommentId$), panelVisible = useObservable(panelService.panelVisible$, panelService.panelVisible), sortComments = useCallback((comments) => {
206
+ const worksheets = workbook.getSheets(), sheetIndex = {};
207
+ worksheets.forEach((sheet, i) => {
208
+ sheetIndex[sheet.getSheetId()] = i;
204
209
  });
205
- const x = (U) => U.map((P) => {
206
- var se;
207
- const M = j(P.ref), De = [(se = S[P.subUnitId]) != null ? se : 0, M.row, M.column];
208
- return { ...P, p: De };
209
- }).sort((P, M) => P.p[0] === M.p[0] ? P.p[1] === M.p[1] ? P.p[2] - M.p[2] : P.p[1] - M.p[1] : P.p[0] - M.p[0]);
210
+ const sort = /* @__PURE__ */ __name((comments2) => comments2.map((comment) => {
211
+ var _a9;
212
+ const ref = singleReferenceToGrid(comment.ref), p = [(_a9 = sheetIndex[comment.subUnitId]) != null ? _a9 : 0, ref.row, ref.column];
213
+ return { ...comment, p };
214
+ }).sort((pre, aft) => pre.p[0] === aft.p[0] ? pre.p[1] === aft.p[1] ? pre.p[2] - aft.p[2] : pre.p[1] - aft.p[1] : pre.p[0] - aft.p[0]), "sort");
210
215
  return [
211
- ...x(m.filter((U) => !U.resolved)),
212
- ...x(m.filter((U) => U.resolved))
216
+ ...sort(comments.filter((comment) => !comment.resolved)),
217
+ ...sort(comments.filter((comment) => comment.resolved))
213
218
  ];
214
- }, [t]), v = ue((m) => {
215
- if (m.unitId === r && m.subUnitId === a && !m.resolved) {
216
- const { row: _, column: S } = j(m.ref);
217
- if (!Number.isNaN(_) && !Number.isNaN(S))
218
- return o.addShape({
219
+ }, [workbook]), showShape = useCallback((comment) => {
220
+ if (comment.unitId === unitId && comment.subUnitId === subUnitId && !comment.resolved) {
221
+ const { row, column } = singleReferenceToGrid(comment.ref);
222
+ if (!Number.isNaN(row) && !Number.isNaN(column))
223
+ return markSelectionService.addShape({
219
224
  range: {
220
- startColumn: S,
221
- endColumn: S,
222
- startRow: _,
223
- endRow: _
225
+ startColumn: column,
226
+ endColumn: column,
227
+ startRow: row,
228
+ endRow: row
224
229
  },
225
230
  style: {
226
231
  hasAutoFill: !1,
@@ -232,197 +237,198 @@ const Et = () => {
232
237
  primary: null
233
238
  });
234
239
  }
235
- }, [o, a, r]), g = (m) => {
236
- var _, S;
237
- return (S = (_ = t.getSheetBySheetId(m)) == null ? void 0 : _.getName()) != null ? S : "";
238
- }, f = () => {
239
- i.executeCommand(Q.id);
240
- }, E = (m) => {
241
- h && h.unitId === m.unitId && h.subUnitId === m.subUnitId && h.commentId === m.id || (c.current && (o.removeShape(c.current), c.current = null), c.current = v(m));
242
- }, D = () => {
243
- c.current && (o.removeShape(c.current), c.current = null);
244
- }, ee = (m, _) => {
245
- _ && n.hidePopup();
246
- };
247
- return ft(() => {
248
- !d && c.current && o.removeShape(c.current);
249
- }, [o, d]), /* @__PURE__ */ Pe.createElement(
250
- Fe,
240
+ }, [markSelectionService, subUnitId, unitId]), getSubUnitName = /* @__PURE__ */ __name((id) => {
241
+ var _a9, _b;
242
+ return (_b = (_a9 = workbook.getSheetBySheetId(id)) == null ? void 0 : _a9.getName()) != null ? _b : "";
243
+ }, "getSubUnitName"), handleAdd = /* @__PURE__ */ __name(() => {
244
+ commandService.executeCommand(ShowAddSheetCommentModalOperation.id);
245
+ }, "handleAdd"), handleHover = /* @__PURE__ */ __name((comment) => {
246
+ activeCommentId && activeCommentId.unitId === comment.unitId && activeCommentId.subUnitId === comment.subUnitId && activeCommentId.commentId === comment.id || (hoverShapeId.current && (markSelectionService.removeShape(hoverShapeId.current), hoverShapeId.current = null), hoverShapeId.current = showShape(comment));
247
+ }, "handleHover"), handleLeave = /* @__PURE__ */ __name(() => {
248
+ hoverShapeId.current && (markSelectionService.removeShape(hoverShapeId.current), hoverShapeId.current = null);
249
+ }, "handleLeave"), handleResolve = /* @__PURE__ */ __name((id, resolved) => {
250
+ resolved && sheetsThreadCommentPopupService.hidePopup();
251
+ }, "handleResolve");
252
+ return useEffect(() => {
253
+ !panelVisible && hoverShapeId.current && markSelectionService.removeShape(hoverShapeId.current);
254
+ }, [markSelectionService, panelVisible]), /* @__PURE__ */ React.createElement(
255
+ ThreadCommentPanel,
251
256
  {
252
- unitId: r,
253
- subUnitId$: s,
254
- type: b.UNIVER_SHEET,
255
- onAdd: f,
256
- getSubUnitName: g,
257
- onResolve: ee,
258
- sortComments: p,
259
- onItemEnter: E,
260
- onItemLeave: D,
261
- onDeleteComment: () => (D(), !0)
257
+ unitId,
258
+ subUnitId$,
259
+ type: UniverInstanceType.UNIVER_SHEET,
260
+ onAdd: handleAdd,
261
+ getSubUnitName,
262
+ onResolve: handleResolve,
263
+ sortComments,
264
+ onItemEnter: handleHover,
265
+ onItemLeave: handleLeave,
266
+ onDeleteComment: /* @__PURE__ */ __name(() => (handleLeave(), !0), "onDeleteComment")
262
267
  }
263
268
  );
264
- }, Rt = (o) => ({
265
- id: Q.id,
266
- type: le.BUTTON,
267
- positions: [ve.CONTEXT_MENU],
268
- icon: ie,
269
+ }, "SheetsThreadCommentPanel"), threadCommentMenuFactory = /* @__PURE__ */ __name((accessor) => ({
270
+ id: ShowAddSheetCommentModalOperation.id,
271
+ type: MenuItemType.BUTTON,
272
+ positions: [MenuPosition.CONTEXT_MENU],
273
+ icon: COMMENT_SINGLE_ICON,
269
274
  title: "sheetThreadComment.menu.addComment",
270
- hidden$: _e(o, b.UNIVER_SHEET),
271
- disabled$: Ie(o, {
272
- workbookTypes: [q],
273
- worksheetTypes: [X],
274
- rangeTypes: [J]
275
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
276
+ disabled$: getCurrentRangeDisable$(accessor, {
277
+ workbookTypes: [WorkbookCommentPermission],
278
+ worksheetTypes: [WorksheetViewPermission],
279
+ rangeTypes: [RangeProtectionPermissionViewPoint]
275
280
  })
276
- }), Nt = (o) => ({
277
- id: We.id,
278
- type: le.BUTTON,
279
- icon: ie,
281
+ }), "threadCommentMenuFactory"), threadPanelMenuFactory = /* @__PURE__ */ __name((accessor) => ({
282
+ id: ToggleSheetCommentPanelOperation.id,
283
+ type: MenuItemType.BUTTON,
284
+ icon: COMMENT_SINGLE_ICON,
280
285
  tooltip: "sheetThreadComment.menu.commentManagement",
281
- positions: ve.TOOLBAR_START,
282
- group: Ye.TOOLBAR_OTHERS,
283
- disabled$: Ie(o, {
284
- workbookTypes: [q],
285
- worksheetTypes: [X],
286
- rangeTypes: [J]
286
+ positions: MenuPosition.TOOLBAR_START,
287
+ group: MenuGroup.TOOLBAR_OTHERS,
288
+ disabled$: getCurrentRangeDisable$(accessor, {
289
+ workbookTypes: [WorkbookCommentPermission],
290
+ worksheetTypes: [WorksheetViewPermission],
291
+ rangeTypes: [RangeProtectionPermissionViewPoint]
287
292
  }),
288
- hidden$: _e(o, b.UNIVER_SHEET)
289
- }), $t = {
290
- id: Q.id,
291
- binding: Ke.M | ce.CTRL_COMMAND | ce.ALT,
292
- preconditions: ut
293
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET)
294
+ }), "threadPanelMenuFactory"), AddCommentShortcut = {
295
+ id: ShowAddSheetCommentModalOperation.id,
296
+ binding: KeyCode.M | MetaKeys.CTRL_COMMAND | MetaKeys.ALT,
297
+ preconditions: whenSheetEditorFocused
293
298
  };
294
- var Dt = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, Vt = (o, e, n, t) => {
295
- for (var r = t > 1 ? void 0 : t ? xt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
296
- (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
297
- return t && r && Dt(e, n, r), r;
298
- }, T = (o, e) => (n, t) => e(n, t, o);
299
- const At = {};
300
- let A = class extends R {
301
- constructor(e, n, t, r, i, s, a, c, u, h, d, p) {
299
+ var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
300
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
301
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
302
+ return kind && result && __defProp$5(target, key, result), result;
303
+ }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5");
304
+ const DefaultSheetsThreadCommentConfig = {};
305
+ var _a2;
306
+ let SheetsThreadCommentController = (_a2 = class extends Disposable {
307
+ constructor(_config, _menuService, _injector, _componentManager, _commandService, _sheetsThreadCommentPopupService, _sheetsThreadCommentModel, _threadCommentPanelService, _shortcutService, _univerInstanceService, _sheetPermissionInterceptorBaseController, _markSelectionService) {
302
308
  super();
303
- w(this, "_isSwitchToCommenting", !1);
304
- w(this, "_selectionShapeInfo", null);
305
- this._config = e, this._menuService = n, this._injector = t, this._componentManager = r, this._commandService = i, this._sheetsThreadCommentPopupService = s, this._sheetsThreadCommentModel = a, this._threadCommentPanelService = c, this._shortcutService = u, this._univerInstanceService = h, this._sheetPermissionInterceptorBaseController = d, this._markSelectionService = p, this._initMenu(), this._initShortcut(), this._initComponent(), this._initCommandListener(), this._initPanelListener(), this._initMarkSelection();
309
+ __publicField(this, "_isSwitchToCommenting", !1);
310
+ __publicField(this, "_selectionShapeInfo", null);
311
+ this._config = _config, this._menuService = _menuService, this._injector = _injector, this._componentManager = _componentManager, this._commandService = _commandService, this._sheetsThreadCommentPopupService = _sheetsThreadCommentPopupService, this._sheetsThreadCommentModel = _sheetsThreadCommentModel, this._threadCommentPanelService = _threadCommentPanelService, this._shortcutService = _shortcutService, this._univerInstanceService = _univerInstanceService, this._sheetPermissionInterceptorBaseController = _sheetPermissionInterceptorBaseController, this._markSelectionService = _markSelectionService, this._initMenu(), this._initShortcut(), this._initComponent(), this._initCommandListener(), this._initPanelListener(), this._initMarkSelection();
306
312
  }
307
313
  _initShortcut() {
308
- this._shortcutService.registerShortcut($t);
314
+ this._shortcutService.registerShortcut(AddCommentShortcut);
309
315
  }
310
316
  _initCommandListener() {
311
- this._commandService.onCommandExecuted((e) => {
312
- var n;
313
- if (e.id === tt.id) {
317
+ this._commandService.onCommandExecuted((commandInfo) => {
318
+ var _a8;
319
+ if (commandInfo.id === SetSelectionsOperation.id) {
314
320
  if (this._isSwitchToCommenting)
315
321
  return;
316
- const t = e.params, { unitId: r, subUnitId: i, selections: s, type: a } = t;
317
- if ((a === nt.MOVE_END || a === void 0) && ((n = s[0]) != null && n.primary)) {
318
- const c = s[0].range;
319
- if (c.endColumn - c.startColumn > 0 || c.endRow - c.startRow > 0)
322
+ const params = commandInfo.params, { unitId, subUnitId, selections, type } = params;
323
+ if ((type === SelectionMoveType.MOVE_END || type === void 0) && ((_a8 = selections[0]) != null && _a8.primary)) {
324
+ const range = selections[0].range;
325
+ if (range.endColumn - range.startColumn > 0 || range.endRow - range.startRow > 0)
320
326
  return;
321
- const u = s[0].primary.actualRow, h = s[0].primary.actualColumn;
322
- if (!this._sheetsThreadCommentModel.showCommentMarker(r, i, u, h)) {
323
- this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(ae.id);
327
+ const row = selections[0].primary.actualRow, col = selections[0].primary.actualColumn;
328
+ if (!this._sheetsThreadCommentModel.showCommentMarker(unitId, subUnitId, row, col)) {
329
+ this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(SetActiveCommentOperation.id);
324
330
  return;
325
331
  }
326
- const d = this._sheetsThreadCommentModel.getByLocation(r, i, u, h);
327
- d && this._commandService.executeCommand(ae.id, {
328
- unitId: r,
329
- subUnitId: i,
330
- commentId: d
332
+ const commentId = this._sheetsThreadCommentModel.getByLocation(unitId, subUnitId, row, col);
333
+ commentId && this._commandService.executeCommand(SetActiveCommentOperation.id, {
334
+ unitId,
335
+ subUnitId,
336
+ commentId
331
337
  });
332
338
  }
333
339
  }
334
- if (e.id === K.id) {
335
- const t = e.params, r = this._sheetsThreadCommentPopupService.activePopup;
336
- if (!r)
340
+ if (commandInfo.id === DeleteCommentMutation.id) {
341
+ const params = commandInfo.params, active = this._sheetsThreadCommentPopupService.activePopup;
342
+ if (!active)
337
343
  return;
338
- const { unitId: i, subUnitId: s, commentId: a } = r;
339
- t.unitId === i && t.subUnitId === s && t.commentId === a && this._sheetsThreadCommentPopupService.hidePopup();
344
+ const { unitId, subUnitId, commentId } = active;
345
+ params.unitId === unitId && params.subUnitId === subUnitId && params.commentId === commentId && this._sheetsThreadCommentPopupService.hidePopup();
340
346
  }
341
347
  });
342
348
  }
343
349
  _initMenu() {
344
- const { menu: e = {} } = this._config;
350
+ const { menu = {} } = this._config;
345
351
  [
346
- Rt,
347
- Nt
348
- ].forEach((n) => {
349
- this._menuService.addMenuItem(n(this._injector), e);
352
+ threadCommentMenuFactory,
353
+ threadPanelMenuFactory
354
+ ].forEach((menuFactory) => {
355
+ this._menuService.addMenuItem(menuFactory(this._injector), menu);
350
356
  });
351
357
  }
352
358
  _initComponent() {
353
359
  [
354
- [Ue, Et],
355
- [Ze, Ut],
356
- [ie, Ee]
357
- ].forEach(([e, n]) => {
358
- this._componentManager.register(e, n);
360
+ [SHEETS_THREAD_COMMENT_MODAL, SheetsThreadCommentCell],
361
+ [THREAD_COMMENT_PANEL, SheetsThreadCommentPanel],
362
+ [COMMENT_SINGLE_ICON, CommentSingle]
363
+ ].forEach(([key, comp]) => {
364
+ this._componentManager.register(key, comp);
359
365
  });
360
366
  }
361
367
  _initPanelListener() {
362
- this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async (e) => {
363
- var n;
364
- if (e) {
365
- const { unitId: t, subUnitId: r, commentId: i, trigger: s } = e, a = this._sheetsThreadCommentModel.getComment(t, r, i);
366
- if (!a || a.resolved)
368
+ this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async (commentInfo) => {
369
+ var _a8;
370
+ if (commentInfo) {
371
+ const { unitId, subUnitId, commentId, trigger } = commentInfo, comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
372
+ if (!comment || comment.resolved)
367
373
  return;
368
- const c = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
369
- if (!c || c.getUnitId() !== t)
374
+ const currentUnit = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
375
+ if (!currentUnit || currentUnit.getUnitId() !== unitId)
370
376
  return;
371
- this._isSwitchToCommenting = !0, ((n = c.getActiveSheet()) == null ? void 0 : n.getSheetId()) !== r && await this._commandService.executeCommand(rt.id, {
372
- unitId: t,
373
- subUnitId: r
377
+ this._isSwitchToCommenting = !0, ((_a8 = currentUnit.getActiveSheet()) == null ? void 0 : _a8.getSheetId()) !== subUnitId && await this._commandService.executeCommand(SetWorksheetActiveOperation.id, {
378
+ unitId,
379
+ subUnitId
374
380
  }), this._isSwitchToCommenting = !1;
375
- const d = j(a.ref), { row: p, column: v } = d;
381
+ const location = singleReferenceToGrid(comment.ref), { row, column: col } = location;
376
382
  if (!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
377
- workbookTypes: [q],
378
- worksheetTypes: [X],
379
- rangeTypes: [J]
380
- }, [{ startRow: p, startColumn: v, endRow: p, endColumn: v }]))
383
+ workbookTypes: [WorkbookCommentPermission],
384
+ worksheetTypes: [WorksheetViewPermission],
385
+ rangeTypes: [RangeProtectionPermissionViewPoint]
386
+ }, [{ startRow: row, startColumn: col, endRow: row, endColumn: col }]))
381
387
  return;
382
- const f = 1;
383
- await this._commandService.executeCommand(dt.id, {
388
+ const GAP = 1;
389
+ await this._commandService.executeCommand(ScrollToRangeOperation.id, {
384
390
  range: {
385
- startRow: Math.max(d.row - f, 0),
386
- endRow: d.row + f,
387
- startColumn: Math.max(d.column - f, 0),
388
- endColumn: d.column + f
391
+ startRow: Math.max(location.row - GAP, 0),
392
+ endRow: location.row + GAP,
393
+ startColumn: Math.max(location.column - GAP, 0),
394
+ endColumn: location.column + GAP
389
395
  }
390
396
  }), this._sheetsThreadCommentPopupService.showPopup({
391
- unitId: t,
392
- subUnitId: r,
393
- row: d.row,
394
- col: d.column,
395
- commentId: a.id,
396
- trigger: s
397
+ unitId,
398
+ subUnitId,
399
+ row: location.row,
400
+ col: location.column,
401
+ commentId: comment.id,
402
+ trigger
397
403
  });
398
404
  } else
399
405
  this._sheetsThreadCommentPopupService.hidePopup();
400
406
  }));
401
407
  }
402
408
  _initMarkSelection() {
403
- this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((e) => {
404
- if (!e) {
409
+ this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((activeComment) => {
410
+ if (!activeComment) {
405
411
  this._selectionShapeInfo && (this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId), this._selectionShapeInfo = null);
406
412
  return;
407
413
  }
408
- const { unitId: n, subUnitId: t, commentId: r } = e;
414
+ const { unitId, subUnitId, commentId } = activeComment;
409
415
  if (this._selectionShapeInfo) {
410
- if (this._selectionShapeInfo.unitId === n && this._selectionShapeInfo.subUnitId === t && this._selectionShapeInfo.commentId === r)
416
+ if (this._selectionShapeInfo.unitId === unitId && this._selectionShapeInfo.subUnitId === subUnitId && this._selectionShapeInfo.commentId === commentId)
411
417
  return;
412
418
  this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId), this._selectionShapeInfo = null;
413
419
  }
414
- const i = this._sheetsThreadCommentModel.getComment(n, t, r);
415
- if (!i)
420
+ const comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
421
+ if (!comment)
416
422
  return;
417
- const s = j(i.ref), { row: a, column: c } = s;
418
- if (Number.isNaN(a) || Number.isNaN(c))
423
+ const location = singleReferenceToGrid(comment.ref), { row, column } = location;
424
+ if (Number.isNaN(row) || Number.isNaN(column))
419
425
  return;
420
- const u = this._markSelectionService.addShape({
426
+ const shapeId = this._markSelectionService.addShape({
421
427
  range: {
422
- startColumn: c,
423
- endColumn: c,
424
- startRow: a,
425
- endRow: a
428
+ startColumn: column,
429
+ endColumn: column,
430
+ startRow: row,
431
+ endRow: row
426
432
  },
427
433
  style: {
428
434
  hasAutoFill: !1,
@@ -433,180 +439,181 @@ let A = class extends R {
433
439
  },
434
440
  primary: null
435
441
  });
436
- u && (this._selectionShapeInfo = {
437
- ...e,
438
- shapeId: u
442
+ shapeId && (this._selectionShapeInfo = {
443
+ ...activeComment,
444
+ shapeId
439
445
  });
440
446
  }));
441
447
  }
442
- };
443
- A = Vt([
444
- B(H.Starting, A),
445
- T(1, Xe),
446
- T(2, l(pe)),
447
- T(3, l(qe)),
448
- T(4, re),
449
- T(5, l(O)),
450
- T(6, l($)),
451
- T(7, l(oe)),
452
- T(8, Je),
453
- T(9, N),
454
- T(10, l(ge)),
455
- T(11, Se)
456
- ], A);
457
- var jt = Object.defineProperty, Bt = Object.getOwnPropertyDescriptor, Ht = (o, e, n, t) => {
458
- for (var r = t > 1 ? void 0 : t ? Bt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
459
- (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
460
- return t && r && jt(e, n, r), r;
461
- }, L = (o, e) => (n, t) => e(n, t, o);
462
- let W = class extends R {
463
- constructor(o, e, n, t) {
464
- super(), this._sheetInterceptorService = o, this._sheetsThreadCommentModel = e, this._univerInstanceService = n, this._renderManagerService = t, this._initViewModelIntercept(), this._initSkeletonChange();
448
+ }, __name(_a2, "SheetsThreadCommentController"), _a2);
449
+ SheetsThreadCommentController = __decorateClass$5([
450
+ OnLifecycle(LifecycleStages.Starting, SheetsThreadCommentController),
451
+ __decorateParam$5(1, IMenuService),
452
+ __decorateParam$5(2, Inject(Injector)),
453
+ __decorateParam$5(3, Inject(ComponentManager)),
454
+ __decorateParam$5(4, ICommandService),
455
+ __decorateParam$5(5, Inject(SheetsThreadCommentPopupService)),
456
+ __decorateParam$5(6, Inject(SheetsThreadCommentModel)),
457
+ __decorateParam$5(7, Inject(ThreadCommentPanelService)),
458
+ __decorateParam$5(8, IShortcutService),
459
+ __decorateParam$5(9, IUniverInstanceService),
460
+ __decorateParam$5(10, Inject(SheetPermissionInterceptorBaseController)),
461
+ __decorateParam$5(11, IMarkSelectionService)
462
+ ], SheetsThreadCommentController);
463
+ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
464
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
465
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
466
+ return kind && result && __defProp$4(target, key, result), result;
467
+ }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a3;
468
+ let SheetsThreadCommentRenderController = (_a3 = class extends Disposable {
469
+ constructor(_sheetInterceptorService, _sheetsThreadCommentModel, _univerInstanceService, _renderManagerService) {
470
+ super(), this._sheetInterceptorService = _sheetInterceptorService, this._sheetsThreadCommentModel = _sheetsThreadCommentModel, this._univerInstanceService = _univerInstanceService, this._renderManagerService = _renderManagerService, this._initViewModelIntercept(), this._initSkeletonChange();
465
471
  }
466
472
  _initViewModelIntercept() {
467
473
  this.disposeWithMe(
468
474
  this._sheetInterceptorService.intercept(
469
- ot.CELL_CONTENT,
475
+ INTERCEPTOR_POINT.CELL_CONTENT,
470
476
  {
471
- handler: (o, e, n) => {
472
- const { row: t, col: r, unitId: i, subUnitId: s } = e;
473
- return this._sheetsThreadCommentModel.showCommentMarker(i, s, t, r) ? n({
474
- ...o,
477
+ handler: /* @__PURE__ */ __name((cell, pos, next) => {
478
+ const { row, col, unitId, subUnitId } = pos;
479
+ return this._sheetsThreadCommentModel.showCommentMarker(unitId, subUnitId, row, col) ? next({
480
+ ...cell,
475
481
  markers: {
476
- ...o == null ? void 0 : o.markers,
482
+ ...cell == null ? void 0 : cell.markers,
477
483
  tr: {
478
484
  color: "#FFBD37",
479
485
  size: 6
480
486
  }
481
487
  }
482
- }) : n(o);
483
- },
488
+ }) : next(cell);
489
+ }, "handler"),
484
490
  priority: 100
485
491
  }
486
492
  )
487
493
  );
488
494
  }
489
495
  _initSkeletonChange() {
490
- const o = () => {
491
- var s;
492
- const e = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
493
- if (!e) return;
494
- const n = e.getUnitId(), t = (s = e.getActiveSheet()) == null ? void 0 : s.getSheetId();
495
- if (!t) {
496
+ const markSkeletonDirty = /* @__PURE__ */ __name(() => {
497
+ var _a8;
498
+ const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
499
+ if (!workbook) return;
500
+ const unitId = workbook.getUnitId(), subUnitId = (_a8 = workbook.getActiveSheet()) == null ? void 0 : _a8.getSheetId();
501
+ if (!subUnitId) {
496
502
  console.warn("No active sheet found");
497
503
  return;
498
504
  }
499
- const r = this._renderManagerService.getRenderById(n), i = r == null ? void 0 : r.with(ht).getOrCreateSkeleton({ sheetId: t });
500
- i == null || i.makeDirty(!0), i == null || i.calculate(), r && r.mainComponent.makeForceDirty();
501
- };
502
- this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(Me(16)).subscribe((e) => {
503
- o();
505
+ const currentRender = this._renderManagerService.getRenderById(unitId), skeleton = currentRender == null ? void 0 : currentRender.with(SheetSkeletonManagerService).getOrCreateSkeleton({ sheetId: subUnitId });
506
+ skeleton == null || skeleton.makeDirty(!0), skeleton == null || skeleton.calculate(), currentRender && currentRender.mainComponent.makeForceDirty();
507
+ }, "markSkeletonDirty");
508
+ this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(debounceTime(16)).subscribe((update) => {
509
+ markSkeletonDirty();
504
510
  }));
505
511
  }
506
- };
507
- W = Ht([
508
- B(H.Ready, W),
509
- L(0, l(fe)),
510
- L(1, l($)),
511
- L(2, N),
512
- L(3, It)
513
- ], W);
514
- var Lt = Object.defineProperty, kt = Object.getOwnPropertyDescriptor, Ft = (o, e, n, t) => {
515
- for (var r = t > 1 ? void 0 : t ? kt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
516
- (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
517
- return t && r && Lt(e, n, r), r;
518
- }, te = (o, e) => (n, t) => e(n, t, o);
519
- const Wt = (o, e, n) => {
520
- const t = j(o), r = n.row - e.row, i = n.column - e.column, s = {
521
- startColumn: t.column + i,
522
- startRow: t.row + r,
523
- endColumn: t.column + i,
524
- endRow: t.row + r
512
+ }, __name(_a3, "SheetsThreadCommentRenderController"), _a3);
513
+ SheetsThreadCommentRenderController = __decorateClass$4([
514
+ OnLifecycle(LifecycleStages.Ready, SheetsThreadCommentRenderController),
515
+ __decorateParam$4(0, Inject(SheetInterceptorService)),
516
+ __decorateParam$4(1, Inject(SheetsThreadCommentModel)),
517
+ __decorateParam$4(2, IUniverInstanceService),
518
+ __decorateParam$4(3, IRenderManagerService)
519
+ ], SheetsThreadCommentRenderController);
520
+ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
521
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
522
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
523
+ return kind && result && __defProp$3(target, key, result), result;
524
+ }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3");
525
+ const transformRef = /* @__PURE__ */ __name((ref, source, target) => {
526
+ const refObj = singleReferenceToGrid(ref), offsetRow = target.row - source.row, offsetCol = target.column - source.column, targetRange = {
527
+ startColumn: refObj.column + offsetCol,
528
+ startRow: refObj.row + offsetRow,
529
+ endColumn: refObj.column + offsetCol,
530
+ endRow: refObj.row + offsetRow
525
531
  };
526
- return st(s);
527
- };
528
- let Z = class extends R {
529
- constructor(e, n, t) {
532
+ return serializeRange(targetRange);
533
+ }, "transformRef");
534
+ var _a4;
535
+ let SheetsThreadCommentCopyPasteController = (_a4 = class extends Disposable {
536
+ constructor(_sheetClipboardService, _sheetsThreadCommentModel, _threadCommentDataSourceService) {
530
537
  super();
531
- w(this, "_copyInfo");
532
- this._sheetClipboardService = e, this._sheetsThreadCommentModel = n, this._threadCommentDataSourceService = t, this._initClipboardHook();
538
+ __publicField(this, "_copyInfo");
539
+ this._sheetClipboardService = _sheetClipboardService, this._sheetsThreadCommentModel = _sheetsThreadCommentModel, this._threadCommentDataSourceService = _threadCommentDataSourceService, this._initClipboardHook();
533
540
  }
534
541
  // eslint-disable-next-line max-lines-per-function
535
542
  _initClipboardHook() {
536
543
  this.disposeWithMe(
537
544
  this._sheetClipboardService.addClipboardHook({
538
- id: Re,
539
- onBeforeCopy: (e, n, t) => {
545
+ id: SHEETS_THREAD_COMMENT,
546
+ onBeforeCopy: /* @__PURE__ */ __name((unitId, subUnitId, range) => {
540
547
  this._copyInfo = {
541
- unitId: e,
542
- subUnitId: n,
543
- range: t
548
+ unitId,
549
+ subUnitId,
550
+ range
544
551
  };
545
- },
552
+ }, "onBeforeCopy"),
546
553
  // eslint-disable-next-line max-lines-per-function
547
- onPasteCells: (e, n, t, r) => {
548
- const { unitId: i, subUnitId: s, range: a } = n, c = {
549
- row: a.rows[0],
550
- column: a.cols[0]
554
+ onPasteCells: /* @__PURE__ */ __name((_pasteFrom, pasteTo, _data, payload) => {
555
+ const { unitId: targetUnitId, subUnitId: targetSubUnitId, range } = pasteTo, targetPos = {
556
+ row: range.rows[0],
557
+ column: range.cols[0]
551
558
  };
552
- if (r.copyType === pt.CUT && this._copyInfo) {
553
- const { range: u, unitId: h, subUnitId: d } = this._copyInfo, p = {
554
- row: u.startRow,
555
- column: u.startColumn
559
+ if (payload.copyType === COPY_TYPE.CUT && this._copyInfo) {
560
+ const { range: range2, unitId: sourceUnitId, subUnitId: sourceSubUnitId } = this._copyInfo, sourcePos = {
561
+ row: range2.startRow,
562
+ column: range2.startColumn
556
563
  };
557
- if (!(i === h && s === d)) {
558
- const v = [];
559
- Be.foreach(u, (C, m) => {
560
- const _ = this._sheetsThreadCommentModel.getAllByLocation(h, d, C, m);
561
- this._threadCommentDataSourceService.syncUpdateMutationToColla ? _.forEach((S) => {
562
- v.push(S);
563
- }) : _.forEach(({ children: S, ...x }) => {
564
- x.parentId || v.push(x);
564
+ if (!(targetUnitId === sourceUnitId && targetSubUnitId === sourceSubUnitId)) {
565
+ const roots = [];
566
+ Range.foreach(range2, (row, col) => {
567
+ const comments = this._sheetsThreadCommentModel.getAllByLocation(sourceUnitId, sourceSubUnitId, row, col);
568
+ this._threadCommentDataSourceService.syncUpdateMutationToColla ? comments.forEach((comment) => {
569
+ roots.push(comment);
570
+ }) : comments.forEach(({ children, ...comment }) => {
571
+ comment.parentId || roots.push(comment);
565
572
  });
566
573
  });
567
- const g = [], f = [], E = [], D = [], ee = (C) => {
568
- g.unshift({
569
- id: K.id,
574
+ const sourceRedos = [], sourceUndos = [], targetRedos = [], targetUndos = [], handleCommentItem = /* @__PURE__ */ __name((item) => {
575
+ sourceRedos.unshift({
576
+ id: DeleteCommentMutation.id,
570
577
  params: {
571
- unitId: h,
572
- subUnitId: d,
573
- commentId: C.id
578
+ unitId: sourceUnitId,
579
+ subUnitId: sourceSubUnitId,
580
+ commentId: item.id
574
581
  }
575
- }), E.push({
576
- id: ne.id,
582
+ }), targetRedos.push({
583
+ id: AddCommentMutation.id,
577
584
  params: {
578
- unitId: i,
579
- subUnitId: s,
585
+ unitId: targetUnitId,
586
+ subUnitId: targetSubUnitId,
580
587
  comment: {
581
- ...C,
582
- ref: Wt(C.ref, p, c),
583
- unitId: i,
584
- subUnitId: s
588
+ ...item,
589
+ ref: transformRef(item.ref, sourcePos, targetPos),
590
+ unitId: targetUnitId,
591
+ subUnitId: targetSubUnitId
585
592
  },
586
593
  sync: !0
587
594
  }
588
- }), f.push({
589
- id: ne.id,
595
+ }), sourceUndos.push({
596
+ id: AddCommentMutation.id,
590
597
  params: {
591
- unitId: h,
592
- subUnitId: d,
593
- comment: C,
598
+ unitId: sourceUnitId,
599
+ subUnitId: sourceSubUnitId,
600
+ comment: item,
594
601
  sync: !0
595
602
  }
596
- }), D.unshift({
597
- id: K.id,
603
+ }), targetUndos.unshift({
604
+ id: DeleteCommentMutation.id,
598
605
  params: {
599
- unitId: i,
600
- subUnitId: s,
601
- commentId: C.id
606
+ unitId: targetUnitId,
607
+ subUnitId: targetSubUnitId,
608
+ commentId: item.id
602
609
  }
603
610
  });
604
- };
605
- return v.forEach((C) => {
606
- ee(C);
611
+ }, "handleCommentItem");
612
+ return roots.forEach((root) => {
613
+ handleCommentItem(root);
607
614
  }), {
608
- redos: [...g, ...E],
609
- undos: [...D, ...f]
615
+ redos: [...sourceRedos, ...targetRedos],
616
+ undos: [...targetUndos, ...sourceUndos]
610
617
  };
611
618
  }
612
619
  }
@@ -614,171 +621,171 @@ let Z = class extends R {
614
621
  redos: [],
615
622
  undos: []
616
623
  };
617
- }
624
+ }, "onPasteCells")
618
625
  })
619
626
  );
620
627
  }
621
- };
622
- Z = Ft([
623
- B(H.Rendered, Z),
624
- te(0, l(mt)),
625
- te(1, l($)),
626
- te(2, Ce)
627
- ], Z);
628
- var Zt = Object.defineProperty, zt = Object.getOwnPropertyDescriptor, Gt = (o, e, n, t) => {
629
- for (var r = t > 1 ? void 0 : t ? zt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
630
- (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
631
- return t && r && Zt(e, n, r), r;
632
- }, k = (o, e) => (n, t) => e(n, t, o);
633
- let z = class extends R {
634
- constructor(o, e, n, t) {
635
- super(), this._hoverManagerService = o, this._sheetsThreadCommentPopupService = e, this._sheetsThreadCommentModel = n, this._sheetPermissionInterceptorBaseController = t, this._initHoverEvent();
628
+ }, __name(_a4, "SheetsThreadCommentCopyPasteController"), _a4);
629
+ SheetsThreadCommentCopyPasteController = __decorateClass$3([
630
+ OnLifecycle(LifecycleStages.Rendered, SheetsThreadCommentCopyPasteController),
631
+ __decorateParam$3(0, Inject(ISheetClipboardService)),
632
+ __decorateParam$3(1, Inject(SheetsThreadCommentModel)),
633
+ __decorateParam$3(2, IThreadCommentDataSourceService)
634
+ ], SheetsThreadCommentCopyPasteController);
635
+ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
636
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
637
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
638
+ return kind && result && __defProp$2(target, key, result), result;
639
+ }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a5;
640
+ let SheetsThreadCommentHoverController = (_a5 = class extends Disposable {
641
+ constructor(_hoverManagerService, _sheetsThreadCommentPopupService, _sheetsThreadCommentModel, _sheetPermissionInterceptorBaseController) {
642
+ super(), this._hoverManagerService = _hoverManagerService, this._sheetsThreadCommentPopupService = _sheetsThreadCommentPopupService, this._sheetsThreadCommentModel = _sheetsThreadCommentModel, this._sheetPermissionInterceptorBaseController = _sheetPermissionInterceptorBaseController, this._initHoverEvent();
636
643
  }
637
644
  _initHoverEvent() {
638
645
  this.disposeWithMe(
639
- this._hoverManagerService.currentCell$.pipe(Me(100)).subscribe((o) => {
640
- const e = this._sheetsThreadCommentPopupService.activePopup;
641
- if (o && (e && e.temp || !e)) {
642
- const { location: n } = o, { unitId: t, subUnitId: r, row: i, col: s } = n, a = this._sheetsThreadCommentModel.getByLocation(t, r, i, s);
643
- if (a) {
646
+ this._hoverManagerService.currentCell$.pipe(debounceTime(100)).subscribe((cell) => {
647
+ const currentPopup = this._sheetsThreadCommentPopupService.activePopup;
648
+ if (cell && (currentPopup && currentPopup.temp || !currentPopup)) {
649
+ const { location } = cell, { unitId, subUnitId, row, col } = location, commentId = this._sheetsThreadCommentModel.getByLocation(unitId, subUnitId, row, col);
650
+ if (commentId) {
644
651
  if (!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
645
- workbookTypes: [q],
646
- worksheetTypes: [X],
647
- rangeTypes: [J]
648
- }, [{ startRow: i, startColumn: s, endRow: i, endColumn: s }]))
652
+ workbookTypes: [WorkbookCommentPermission],
653
+ worksheetTypes: [WorksheetViewPermission],
654
+ rangeTypes: [RangeProtectionPermissionViewPoint]
655
+ }, [{ startRow: row, startColumn: col, endRow: row, endColumn: col }]))
649
656
  return;
650
- const u = this._sheetsThreadCommentModel.getComment(t, r, a);
651
- u && !u.resolved && this._sheetsThreadCommentPopupService.showPopup({
652
- unitId: t,
653
- subUnitId: r,
654
- row: i,
655
- col: s,
656
- commentId: a,
657
+ const comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
658
+ comment && !comment.resolved && this._sheetsThreadCommentPopupService.showPopup({
659
+ unitId,
660
+ subUnitId,
661
+ row,
662
+ col,
663
+ commentId,
657
664
  temp: !0
658
665
  });
659
666
  } else
660
- e && this._sheetsThreadCommentPopupService.hidePopup();
667
+ currentPopup && this._sheetsThreadCommentPopupService.hidePopup();
661
668
  }
662
669
  })
663
670
  );
664
671
  }
665
- };
666
- z = Gt([
667
- B(H.Rendered, z),
668
- k(0, l(lt)),
669
- k(1, l(O)),
670
- k(2, l($)),
671
- k(3, l(ge))
672
- ], z);
673
- var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, qt = (o, e, n, t) => {
674
- for (var r = t > 1 ? void 0 : t ? Yt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
675
- (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
676
- return t && r && Kt(e, n, r), r;
677
- }, F = (o, e) => (n, t) => e(n, t, o);
678
- let G = class extends R {
679
- constructor(o, e, n, t) {
680
- super(), this._sheetInterceptorService = o, this._univerInstanceService = e, this._threadCommentModel = n, this._threadCommentDataSourceService = t, this._initSheetChange();
672
+ }, __name(_a5, "SheetsThreadCommentHoverController"), _a5);
673
+ SheetsThreadCommentHoverController = __decorateClass$2([
674
+ OnLifecycle(LifecycleStages.Rendered, SheetsThreadCommentHoverController),
675
+ __decorateParam$2(0, Inject(HoverManagerService)),
676
+ __decorateParam$2(1, Inject(SheetsThreadCommentPopupService)),
677
+ __decorateParam$2(2, Inject(SheetsThreadCommentModel)),
678
+ __decorateParam$2(3, Inject(SheetPermissionInterceptorBaseController))
679
+ ], SheetsThreadCommentHoverController);
680
+ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
681
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
682
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
683
+ return kind && result && __defProp$1(target, key, result), result;
684
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a6;
685
+ let ThreadCommentRemoveSheetsController = (_a6 = class extends Disposable {
686
+ constructor(_sheetInterceptorService, _univerInstanceService, _threadCommentModel, _threadCommentDataSourceService) {
687
+ super(), this._sheetInterceptorService = _sheetInterceptorService, this._univerInstanceService = _univerInstanceService, this._threadCommentModel = _threadCommentModel, this._threadCommentDataSourceService = _threadCommentDataSourceService, this._initSheetChange();
681
688
  }
682
689
  _initSheetChange() {
683
690
  this.disposeWithMe(
684
691
  this._sheetInterceptorService.interceptCommand({
685
- getMutations: (o) => {
686
- var e;
687
- if (o.id === it.id) {
688
- const n = o.params, t = n.unitId ? this._univerInstanceService.getUnit(n.unitId) : this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
689
- if (!t)
692
+ getMutations: /* @__PURE__ */ __name((commandInfo) => {
693
+ var _a8;
694
+ if (commandInfo.id === RemoveSheetCommand.id) {
695
+ const params = commandInfo.params, workbook = params.unitId ? this._univerInstanceService.getUnit(params.unitId) : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
696
+ if (!workbook)
690
697
  return { redos: [], undos: [] };
691
- const r = t.getUnitId(), i = n.subUnitId || ((e = t.getActiveSheet()) == null ? void 0 : e.getSheetId());
692
- if (!i)
698
+ const unitId = workbook.getUnitId(), subUnitId = params.subUnitId || ((_a8 = workbook.getActiveSheet()) == null ? void 0 : _a8.getSheetId());
699
+ if (!subUnitId)
693
700
  return { redos: [], undos: [] };
694
- const { commentMap: s } = this._threadCommentModel.ensureMap(r, i), a = Array.from(Object.values(s)).filter((p) => !p.parentId), c = a.map((p) => p.id), u = this._threadCommentDataSourceService.syncUpdateMutationToColla, h = c.map((p) => ({
695
- id: K.id,
701
+ const { commentMap } = this._threadCommentModel.ensureMap(unitId, subUnitId), comments = Array.from(Object.values(commentMap)).filter((comment) => !comment.parentId), ids = comments.map((comment) => comment.id), shouldSync = this._threadCommentDataSourceService.syncUpdateMutationToColla, redos = ids.map((id) => ({
702
+ id: DeleteCommentMutation.id,
696
703
  params: {
697
- unitId: r,
698
- subUnitId: i,
699
- commentId: p
704
+ unitId,
705
+ subUnitId,
706
+ commentId: id
700
707
  }
701
- })), d = a.map(({ children: p, ...v }) => ({
702
- id: ne.id,
708
+ })), undos = comments.map(({ children, ...comment }) => ({
709
+ id: AddCommentMutation.id,
703
710
  params: {
704
- unitId: r,
705
- subUnitId: i,
711
+ unitId,
712
+ subUnitId,
706
713
  comment: {
707
- ...v,
708
- children: u ? p : void 0
714
+ ...comment,
715
+ children: shouldSync ? children : void 0
709
716
  },
710
- sync: !u
717
+ sync: !shouldSync
711
718
  }
712
719
  }));
713
- return { redos: h, undos: d };
720
+ return { redos, undos };
714
721
  }
715
722
  return { redos: [], undos: [] };
716
- }
723
+ }, "getMutations")
717
724
  })
718
725
  );
719
726
  }
720
- };
721
- G = qt([
722
- B(H.Ready, G),
723
- F(0, l(fe)),
724
- F(1, N),
725
- F(2, l(at)),
726
- F(3, Ce)
727
- ], G);
728
- var Ne = Object.defineProperty, Xt = Object.getOwnPropertyDescriptor, Jt = (o, e, n) => e in o ? Ne(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n, Qt = (o, e, n, t) => {
729
- for (var r = t > 1 ? void 0 : t ? Xt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
730
- (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
731
- return t && r && Ne(e, n, r), r;
732
- }, he = (o, e) => (n, t) => e(n, t, o), $e = (o, e, n) => Jt(o, typeof e != "symbol" ? e + "" : e, n);
733
- let Y = class extends Le {
734
- constructor(e = {}, n, t) {
727
+ }, __name(_a6, "ThreadCommentRemoveSheetsController"), _a6);
728
+ ThreadCommentRemoveSheetsController = __decorateClass$1([
729
+ OnLifecycle(LifecycleStages.Ready, ThreadCommentRemoveSheetsController),
730
+ __decorateParam$1(0, Inject(SheetInterceptorService)),
731
+ __decorateParam$1(1, IUniverInstanceService),
732
+ __decorateParam$1(2, Inject(ThreadCommentModel)),
733
+ __decorateParam$1(3, IThreadCommentDataSourceService)
734
+ ], ThreadCommentRemoveSheetsController);
735
+ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
736
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
737
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
738
+ return kind && result && __defProp2(target, key, result), result;
739
+ }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField"), _a7;
740
+ let UniverSheetsThreadCommentPlugin = (_a7 = class extends Plugin {
741
+ constructor(config = {}, _injector, _commandService) {
735
742
  super();
736
- w(this, "_pluginConfig");
737
- this._injector = n, this._commandService = t, this._pluginConfig = me.deepMerge({}, At, e);
743
+ __publicField(this, "_pluginConfig");
744
+ this._injector = _injector, this._commandService = _commandService, this._pluginConfig = Tools.deepMerge({}, DefaultSheetsThreadCommentConfig, config);
738
745
  }
739
- onStarting(e) {
746
+ onStarting() {
740
747
  [
741
748
  [
742
- A,
749
+ SheetsThreadCommentController,
743
750
  {
744
- useFactory: () => this._injector.createInstance(A, this._pluginConfig)
751
+ useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(SheetsThreadCommentController, this._pluginConfig), "useFactory")
745
752
  }
746
753
  ],
747
- [W],
748
- [Z],
749
- [z],
750
- [G],
751
- [O]
752
- ].forEach((n) => {
753
- e.add(n);
754
- }), [Q].forEach((n) => {
755
- this._commandService.registerCommand(n);
754
+ [SheetsThreadCommentRenderController],
755
+ [SheetsThreadCommentCopyPasteController],
756
+ [SheetsThreadCommentHoverController],
757
+ [ThreadCommentRemoveSheetsController],
758
+ [SheetsThreadCommentPopupService]
759
+ ].forEach((dep) => {
760
+ this._injector.add(dep);
761
+ }), [ShowAddSheetCommentModalOperation].forEach((command) => {
762
+ this._commandService.registerCommand(command);
756
763
  });
757
764
  }
758
- };
759
- $e(Y, "pluginName", Re);
760
- $e(Y, "type", b.UNIVER_SHEET);
761
- Y = Qt([
762
- He(ze, vt),
763
- he(1, l(pe)),
764
- he(2, l(re))
765
- ], Y);
765
+ }, __name(_a7, "UniverSheetsThreadCommentPlugin"), _a7);
766
+ __publicField2(UniverSheetsThreadCommentPlugin, "pluginName", SHEETS_THREAD_COMMENT);
767
+ __publicField2(UniverSheetsThreadCommentPlugin, "type", UniverInstanceType.UNIVER_SHEET);
768
+ UniverSheetsThreadCommentPlugin = __decorateClass([
769
+ DependentOn(UniverThreadCommentUIPlugin, UniverSheetsThreadCommentBasePlugin),
770
+ __decorateParam(1, Inject(Injector)),
771
+ __decorateParam(2, Inject(ICommandService))
772
+ ], UniverSheetsThreadCommentPlugin);
766
773
  export {
767
- vn as ICommandService,
768
- bn as IThreadCommentDataSourceService,
769
- gn as IThreadCommentMentionDataService,
770
- _n as Inject,
771
- fn as Injector,
772
- Cn as Plugin,
773
- Re as SHEETS_THREAD_COMMENT,
774
- A as SheetsThreadCommentController,
775
- Z as SheetsThreadCommentCopyPasteController,
776
- z as SheetsThreadCommentHoverController,
777
- Mn as SheetsThreadCommentModel,
778
- O as SheetsThreadCommentPopupService,
779
- Q as ShowAddSheetCommentModalOperation,
780
- G as ThreadCommentRemoveSheetsController,
781
- Sn as UniverInstanceType,
782
- Y as UniverSheetsThreadCommentPlugin,
783
- Pn as UniverThreadCommentUIPlugin
774
+ ICommandService2 as ICommandService,
775
+ IThreadCommentDataSourceService2 as IThreadCommentDataSourceService,
776
+ IThreadCommentMentionDataService,
777
+ Inject2 as Inject,
778
+ Injector2 as Injector,
779
+ Plugin2 as Plugin,
780
+ SHEETS_THREAD_COMMENT,
781
+ SheetsThreadCommentController,
782
+ SheetsThreadCommentCopyPasteController,
783
+ SheetsThreadCommentHoverController,
784
+ SheetsThreadCommentModel2 as SheetsThreadCommentModel,
785
+ SheetsThreadCommentPopupService,
786
+ ShowAddSheetCommentModalOperation,
787
+ ThreadCommentRemoveSheetsController,
788
+ UniverInstanceType2 as UniverInstanceType,
789
+ UniverSheetsThreadCommentPlugin,
790
+ UniverThreadCommentUIPlugin2 as UniverThreadCommentUIPlugin
784
791
  };