@univerjs/sheets-thread-comment 0.2.5 → 0.2.7

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,200 @@ 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) {
326
+ this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(SetActiveCommentOperation.id);
320
327
  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);
328
+ }
329
+ const row = selections[0].primary.actualRow, col = selections[0].primary.actualColumn;
330
+ if (!this._sheetsThreadCommentModel.showCommentMarker(unitId, subUnitId, row, col)) {
331
+ this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(SetActiveCommentOperation.id);
324
332
  return;
325
333
  }
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
334
+ const commentId = this._sheetsThreadCommentModel.getByLocation(unitId, subUnitId, row, col);
335
+ commentId && this._commandService.executeCommand(SetActiveCommentOperation.id, {
336
+ unitId,
337
+ subUnitId,
338
+ commentId
331
339
  });
332
340
  }
333
341
  }
334
- if (e.id === K.id) {
335
- const t = e.params, r = this._sheetsThreadCommentPopupService.activePopup;
336
- if (!r)
342
+ if (commandInfo.id === DeleteCommentMutation.id) {
343
+ const params = commandInfo.params, active = this._sheetsThreadCommentPopupService.activePopup;
344
+ if (!active)
337
345
  return;
338
- const { unitId: i, subUnitId: s, commentId: a } = r;
339
- t.unitId === i && t.subUnitId === s && t.commentId === a && this._sheetsThreadCommentPopupService.hidePopup();
346
+ const { unitId, subUnitId, commentId } = active;
347
+ params.unitId === unitId && params.subUnitId === subUnitId && params.commentId === commentId && this._sheetsThreadCommentPopupService.hidePopup();
340
348
  }
341
349
  });
342
350
  }
343
351
  _initMenu() {
344
- const { menu: e = {} } = this._config;
352
+ const { menu = {} } = this._config;
345
353
  [
346
- Rt,
347
- Nt
348
- ].forEach((n) => {
349
- this._menuService.addMenuItem(n(this._injector), e);
354
+ threadCommentMenuFactory,
355
+ threadPanelMenuFactory
356
+ ].forEach((menuFactory) => {
357
+ this._menuService.addMenuItem(menuFactory(this._injector), menu);
350
358
  });
351
359
  }
352
360
  _initComponent() {
353
361
  [
354
- [Ue, Et],
355
- [Ze, Ut],
356
- [ie, Ee]
357
- ].forEach(([e, n]) => {
358
- this._componentManager.register(e, n);
362
+ [SHEETS_THREAD_COMMENT_MODAL, SheetsThreadCommentCell],
363
+ [THREAD_COMMENT_PANEL, SheetsThreadCommentPanel],
364
+ [COMMENT_SINGLE_ICON, CommentSingle]
365
+ ].forEach(([key, comp]) => {
366
+ this._componentManager.register(key, comp);
359
367
  });
360
368
  }
361
369
  _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)
370
+ this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async (commentInfo) => {
371
+ var _a8;
372
+ if (commentInfo) {
373
+ const { unitId, subUnitId, commentId, trigger } = commentInfo, comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
374
+ if (!comment || comment.resolved)
367
375
  return;
368
- const c = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
369
- if (!c || c.getUnitId() !== t)
376
+ const currentUnit = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
377
+ if (!currentUnit || currentUnit.getUnitId() !== unitId)
370
378
  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
379
+ this._isSwitchToCommenting = !0, ((_a8 = currentUnit.getActiveSheet()) == null ? void 0 : _a8.getSheetId()) !== subUnitId && await this._commandService.executeCommand(SetWorksheetActiveOperation.id, {
380
+ unitId,
381
+ subUnitId
374
382
  }), this._isSwitchToCommenting = !1;
375
- const d = j(a.ref), { row: p, column: v } = d;
383
+ const location = singleReferenceToGrid(comment.ref), { row, column: col } = location;
376
384
  if (!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
377
- workbookTypes: [q],
378
- worksheetTypes: [X],
379
- rangeTypes: [J]
380
- }, [{ startRow: p, startColumn: v, endRow: p, endColumn: v }]))
385
+ workbookTypes: [WorkbookCommentPermission],
386
+ worksheetTypes: [WorksheetViewPermission],
387
+ rangeTypes: [RangeProtectionPermissionViewPoint]
388
+ }, [{ startRow: row, startColumn: col, endRow: row, endColumn: col }]))
381
389
  return;
382
- const f = 1;
383
- await this._commandService.executeCommand(dt.id, {
390
+ const GAP = 1;
391
+ await this._commandService.executeCommand(ScrollToRangeOperation.id, {
384
392
  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
393
+ startRow: Math.max(location.row - GAP, 0),
394
+ endRow: location.row + GAP,
395
+ startColumn: Math.max(location.column - GAP, 0),
396
+ endColumn: location.column + GAP
389
397
  }
390
398
  }), this._sheetsThreadCommentPopupService.showPopup({
391
- unitId: t,
392
- subUnitId: r,
393
- row: d.row,
394
- col: d.column,
395
- commentId: a.id,
396
- trigger: s
399
+ unitId,
400
+ subUnitId,
401
+ row: location.row,
402
+ col: location.column,
403
+ commentId: comment.id,
404
+ trigger
397
405
  });
398
406
  } else
399
407
  this._sheetsThreadCommentPopupService.hidePopup();
400
408
  }));
401
409
  }
402
410
  _initMarkSelection() {
403
- this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((e) => {
404
- if (!e) {
411
+ this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((activeComment) => {
412
+ if (!activeComment) {
405
413
  this._selectionShapeInfo && (this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId), this._selectionShapeInfo = null);
406
414
  return;
407
415
  }
408
- const { unitId: n, subUnitId: t, commentId: r } = e;
416
+ const { unitId, subUnitId, commentId } = activeComment;
409
417
  if (this._selectionShapeInfo) {
410
- if (this._selectionShapeInfo.unitId === n && this._selectionShapeInfo.subUnitId === t && this._selectionShapeInfo.commentId === r)
418
+ if (this._selectionShapeInfo.unitId === unitId && this._selectionShapeInfo.subUnitId === subUnitId && this._selectionShapeInfo.commentId === commentId)
411
419
  return;
412
420
  this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId), this._selectionShapeInfo = null;
413
421
  }
414
- const i = this._sheetsThreadCommentModel.getComment(n, t, r);
415
- if (!i)
422
+ const comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
423
+ if (!comment)
416
424
  return;
417
- const s = j(i.ref), { row: a, column: c } = s;
418
- if (Number.isNaN(a) || Number.isNaN(c))
425
+ const location = singleReferenceToGrid(comment.ref), { row, column } = location;
426
+ if (Number.isNaN(row) || Number.isNaN(column))
419
427
  return;
420
- const u = this._markSelectionService.addShape({
428
+ const shapeId = this._markSelectionService.addShape({
421
429
  range: {
422
- startColumn: c,
423
- endColumn: c,
424
- startRow: a,
425
- endRow: a
430
+ startColumn: column,
431
+ endColumn: column,
432
+ startRow: row,
433
+ endRow: row
426
434
  },
427
435
  style: {
428
436
  hasAutoFill: !1,
@@ -433,180 +441,181 @@ let A = class extends R {
433
441
  },
434
442
  primary: null
435
443
  });
436
- u && (this._selectionShapeInfo = {
437
- ...e,
438
- shapeId: u
444
+ shapeId && (this._selectionShapeInfo = {
445
+ ...activeComment,
446
+ shapeId
439
447
  });
440
448
  }));
441
449
  }
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();
450
+ }, __name(_a2, "SheetsThreadCommentController"), _a2);
451
+ SheetsThreadCommentController = __decorateClass$5([
452
+ OnLifecycle(LifecycleStages.Starting, SheetsThreadCommentController),
453
+ __decorateParam$5(1, IMenuService),
454
+ __decorateParam$5(2, Inject(Injector)),
455
+ __decorateParam$5(3, Inject(ComponentManager)),
456
+ __decorateParam$5(4, ICommandService),
457
+ __decorateParam$5(5, Inject(SheetsThreadCommentPopupService)),
458
+ __decorateParam$5(6, Inject(SheetsThreadCommentModel)),
459
+ __decorateParam$5(7, Inject(ThreadCommentPanelService)),
460
+ __decorateParam$5(8, IShortcutService),
461
+ __decorateParam$5(9, IUniverInstanceService),
462
+ __decorateParam$5(10, Inject(SheetPermissionInterceptorBaseController)),
463
+ __decorateParam$5(11, IMarkSelectionService)
464
+ ], SheetsThreadCommentController);
465
+ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
466
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
467
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
468
+ return kind && result && __defProp$4(target, key, result), result;
469
+ }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a3;
470
+ let SheetsThreadCommentRenderController = (_a3 = class extends Disposable {
471
+ constructor(_sheetInterceptorService, _sheetsThreadCommentModel, _univerInstanceService, _renderManagerService) {
472
+ super(), this._sheetInterceptorService = _sheetInterceptorService, this._sheetsThreadCommentModel = _sheetsThreadCommentModel, this._univerInstanceService = _univerInstanceService, this._renderManagerService = _renderManagerService, this._initViewModelIntercept(), this._initSkeletonChange();
465
473
  }
466
474
  _initViewModelIntercept() {
467
475
  this.disposeWithMe(
468
476
  this._sheetInterceptorService.intercept(
469
- ot.CELL_CONTENT,
477
+ INTERCEPTOR_POINT.CELL_CONTENT,
470
478
  {
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,
479
+ handler: /* @__PURE__ */ __name((cell, pos, next) => {
480
+ const { row, col, unitId, subUnitId } = pos;
481
+ return this._sheetsThreadCommentModel.showCommentMarker(unitId, subUnitId, row, col) ? next({
482
+ ...cell,
475
483
  markers: {
476
- ...o == null ? void 0 : o.markers,
484
+ ...cell == null ? void 0 : cell.markers,
477
485
  tr: {
478
486
  color: "#FFBD37",
479
487
  size: 6
480
488
  }
481
489
  }
482
- }) : n(o);
483
- },
490
+ }) : next(cell);
491
+ }, "handler"),
484
492
  priority: 100
485
493
  }
486
494
  )
487
495
  );
488
496
  }
489
497
  _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) {
498
+ const markSkeletonDirty = /* @__PURE__ */ __name(() => {
499
+ var _a8;
500
+ const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
501
+ if (!workbook) return;
502
+ const unitId = workbook.getUnitId(), subUnitId = (_a8 = workbook.getActiveSheet()) == null ? void 0 : _a8.getSheetId();
503
+ if (!subUnitId) {
496
504
  console.warn("No active sheet found");
497
505
  return;
498
506
  }
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();
507
+ const currentRender = this._renderManagerService.getRenderById(unitId), skeleton = currentRender == null ? void 0 : currentRender.with(SheetSkeletonManagerService).getOrCreateSkeleton({ sheetId: subUnitId });
508
+ skeleton == null || skeleton.makeDirty(!0), skeleton == null || skeleton.calculate(), currentRender && currentRender.mainComponent.makeForceDirty();
509
+ }, "markSkeletonDirty");
510
+ this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(debounceTime(16)).subscribe((update) => {
511
+ markSkeletonDirty();
504
512
  }));
505
513
  }
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
514
+ }, __name(_a3, "SheetsThreadCommentRenderController"), _a3);
515
+ SheetsThreadCommentRenderController = __decorateClass$4([
516
+ OnLifecycle(LifecycleStages.Ready, SheetsThreadCommentRenderController),
517
+ __decorateParam$4(0, Inject(SheetInterceptorService)),
518
+ __decorateParam$4(1, Inject(SheetsThreadCommentModel)),
519
+ __decorateParam$4(2, IUniverInstanceService),
520
+ __decorateParam$4(3, IRenderManagerService)
521
+ ], SheetsThreadCommentRenderController);
522
+ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
523
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
524
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
525
+ return kind && result && __defProp$3(target, key, result), result;
526
+ }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3");
527
+ const transformRef = /* @__PURE__ */ __name((ref, source, target) => {
528
+ const refObj = singleReferenceToGrid(ref), offsetRow = target.row - source.row, offsetCol = target.column - source.column, targetRange = {
529
+ startColumn: refObj.column + offsetCol,
530
+ startRow: refObj.row + offsetRow,
531
+ endColumn: refObj.column + offsetCol,
532
+ endRow: refObj.row + offsetRow
525
533
  };
526
- return st(s);
527
- };
528
- let Z = class extends R {
529
- constructor(e, n, t) {
534
+ return serializeRange(targetRange);
535
+ }, "transformRef");
536
+ var _a4;
537
+ let SheetsThreadCommentCopyPasteController = (_a4 = class extends Disposable {
538
+ constructor(_sheetClipboardService, _sheetsThreadCommentModel, _threadCommentDataSourceService) {
530
539
  super();
531
- w(this, "_copyInfo");
532
- this._sheetClipboardService = e, this._sheetsThreadCommentModel = n, this._threadCommentDataSourceService = t, this._initClipboardHook();
540
+ __publicField(this, "_copyInfo");
541
+ this._sheetClipboardService = _sheetClipboardService, this._sheetsThreadCommentModel = _sheetsThreadCommentModel, this._threadCommentDataSourceService = _threadCommentDataSourceService, this._initClipboardHook();
533
542
  }
534
543
  // eslint-disable-next-line max-lines-per-function
535
544
  _initClipboardHook() {
536
545
  this.disposeWithMe(
537
546
  this._sheetClipboardService.addClipboardHook({
538
- id: Re,
539
- onBeforeCopy: (e, n, t) => {
547
+ id: SHEETS_THREAD_COMMENT,
548
+ onBeforeCopy: /* @__PURE__ */ __name((unitId, subUnitId, range) => {
540
549
  this._copyInfo = {
541
- unitId: e,
542
- subUnitId: n,
543
- range: t
550
+ unitId,
551
+ subUnitId,
552
+ range
544
553
  };
545
- },
554
+ }, "onBeforeCopy"),
546
555
  // 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]
556
+ onPasteCells: /* @__PURE__ */ __name((_pasteFrom, pasteTo, _data, payload) => {
557
+ const { unitId: targetUnitId, subUnitId: targetSubUnitId, range } = pasteTo, targetPos = {
558
+ row: range.rows[0],
559
+ column: range.cols[0]
551
560
  };
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
561
+ if (payload.copyType === COPY_TYPE.CUT && this._copyInfo) {
562
+ const { range: range2, unitId: sourceUnitId, subUnitId: sourceSubUnitId } = this._copyInfo, sourcePos = {
563
+ row: range2.startRow,
564
+ column: range2.startColumn
556
565
  };
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);
566
+ if (!(targetUnitId === sourceUnitId && targetSubUnitId === sourceSubUnitId)) {
567
+ const roots = [];
568
+ Range.foreach(range2, (row, col) => {
569
+ const comments = this._sheetsThreadCommentModel.getAllByLocation(sourceUnitId, sourceSubUnitId, row, col);
570
+ this._threadCommentDataSourceService.syncUpdateMutationToColla ? comments.forEach((comment) => {
571
+ roots.push(comment);
572
+ }) : comments.forEach(({ children, ...comment }) => {
573
+ comment.parentId || roots.push(comment);
565
574
  });
566
575
  });
567
- const g = [], f = [], E = [], D = [], ee = (C) => {
568
- g.unshift({
569
- id: K.id,
576
+ const sourceRedos = [], sourceUndos = [], targetRedos = [], targetUndos = [], handleCommentItem = /* @__PURE__ */ __name((item) => {
577
+ sourceRedos.unshift({
578
+ id: DeleteCommentMutation.id,
570
579
  params: {
571
- unitId: h,
572
- subUnitId: d,
573
- commentId: C.id
580
+ unitId: sourceUnitId,
581
+ subUnitId: sourceSubUnitId,
582
+ commentId: item.id
574
583
  }
575
- }), E.push({
576
- id: ne.id,
584
+ }), targetRedos.push({
585
+ id: AddCommentMutation.id,
577
586
  params: {
578
- unitId: i,
579
- subUnitId: s,
587
+ unitId: targetUnitId,
588
+ subUnitId: targetSubUnitId,
580
589
  comment: {
581
- ...C,
582
- ref: Wt(C.ref, p, c),
583
- unitId: i,
584
- subUnitId: s
590
+ ...item,
591
+ ref: transformRef(item.ref, sourcePos, targetPos),
592
+ unitId: targetUnitId,
593
+ subUnitId: targetSubUnitId
585
594
  },
586
595
  sync: !0
587
596
  }
588
- }), f.push({
589
- id: ne.id,
597
+ }), sourceUndos.push({
598
+ id: AddCommentMutation.id,
590
599
  params: {
591
- unitId: h,
592
- subUnitId: d,
593
- comment: C,
600
+ unitId: sourceUnitId,
601
+ subUnitId: sourceSubUnitId,
602
+ comment: item,
594
603
  sync: !0
595
604
  }
596
- }), D.unshift({
597
- id: K.id,
605
+ }), targetUndos.unshift({
606
+ id: DeleteCommentMutation.id,
598
607
  params: {
599
- unitId: i,
600
- subUnitId: s,
601
- commentId: C.id
608
+ unitId: targetUnitId,
609
+ subUnitId: targetSubUnitId,
610
+ commentId: item.id
602
611
  }
603
612
  });
604
- };
605
- return v.forEach((C) => {
606
- ee(C);
613
+ }, "handleCommentItem");
614
+ return roots.forEach((root) => {
615
+ handleCommentItem(root);
607
616
  }), {
608
- redos: [...g, ...E],
609
- undos: [...D, ...f]
617
+ redos: [...sourceRedos, ...targetRedos],
618
+ undos: [...targetUndos, ...sourceUndos]
610
619
  };
611
620
  }
612
621
  }
@@ -614,171 +623,171 @@ let Z = class extends R {
614
623
  redos: [],
615
624
  undos: []
616
625
  };
617
- }
626
+ }, "onPasteCells")
618
627
  })
619
628
  );
620
629
  }
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();
630
+ }, __name(_a4, "SheetsThreadCommentCopyPasteController"), _a4);
631
+ SheetsThreadCommentCopyPasteController = __decorateClass$3([
632
+ OnLifecycle(LifecycleStages.Rendered, SheetsThreadCommentCopyPasteController),
633
+ __decorateParam$3(0, Inject(ISheetClipboardService)),
634
+ __decorateParam$3(1, Inject(SheetsThreadCommentModel)),
635
+ __decorateParam$3(2, IThreadCommentDataSourceService)
636
+ ], SheetsThreadCommentCopyPasteController);
637
+ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
638
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
639
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
640
+ return kind && result && __defProp$2(target, key, result), result;
641
+ }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a5;
642
+ let SheetsThreadCommentHoverController = (_a5 = class extends Disposable {
643
+ constructor(_hoverManagerService, _sheetsThreadCommentPopupService, _sheetsThreadCommentModel, _sheetPermissionInterceptorBaseController) {
644
+ super(), this._hoverManagerService = _hoverManagerService, this._sheetsThreadCommentPopupService = _sheetsThreadCommentPopupService, this._sheetsThreadCommentModel = _sheetsThreadCommentModel, this._sheetPermissionInterceptorBaseController = _sheetPermissionInterceptorBaseController, this._initHoverEvent();
636
645
  }
637
646
  _initHoverEvent() {
638
647
  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) {
648
+ this._hoverManagerService.currentCell$.pipe(debounceTime(100)).subscribe((cell) => {
649
+ const currentPopup = this._sheetsThreadCommentPopupService.activePopup;
650
+ if (cell && (currentPopup && currentPopup.temp || !currentPopup)) {
651
+ const { location } = cell, { unitId, subUnitId, row, col } = location, commentId = this._sheetsThreadCommentModel.getByLocation(unitId, subUnitId, row, col);
652
+ if (commentId) {
644
653
  if (!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
645
- workbookTypes: [q],
646
- worksheetTypes: [X],
647
- rangeTypes: [J]
648
- }, [{ startRow: i, startColumn: s, endRow: i, endColumn: s }]))
654
+ workbookTypes: [WorkbookCommentPermission],
655
+ worksheetTypes: [WorksheetViewPermission],
656
+ rangeTypes: [RangeProtectionPermissionViewPoint]
657
+ }, [{ startRow: row, startColumn: col, endRow: row, endColumn: col }]))
649
658
  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,
659
+ const comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
660
+ comment && !comment.resolved && this._sheetsThreadCommentPopupService.showPopup({
661
+ unitId,
662
+ subUnitId,
663
+ row,
664
+ col,
665
+ commentId,
657
666
  temp: !0
658
667
  });
659
668
  } else
660
- e && this._sheetsThreadCommentPopupService.hidePopup();
669
+ currentPopup && this._sheetsThreadCommentPopupService.hidePopup();
661
670
  }
662
671
  })
663
672
  );
664
673
  }
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();
674
+ }, __name(_a5, "SheetsThreadCommentHoverController"), _a5);
675
+ SheetsThreadCommentHoverController = __decorateClass$2([
676
+ OnLifecycle(LifecycleStages.Rendered, SheetsThreadCommentHoverController),
677
+ __decorateParam$2(0, Inject(HoverManagerService)),
678
+ __decorateParam$2(1, Inject(SheetsThreadCommentPopupService)),
679
+ __decorateParam$2(2, Inject(SheetsThreadCommentModel)),
680
+ __decorateParam$2(3, Inject(SheetPermissionInterceptorBaseController))
681
+ ], SheetsThreadCommentHoverController);
682
+ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
683
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
684
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
685
+ return kind && result && __defProp$1(target, key, result), result;
686
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a6;
687
+ let ThreadCommentRemoveSheetsController = (_a6 = class extends Disposable {
688
+ constructor(_sheetInterceptorService, _univerInstanceService, _threadCommentModel, _threadCommentDataSourceService) {
689
+ super(), this._sheetInterceptorService = _sheetInterceptorService, this._univerInstanceService = _univerInstanceService, this._threadCommentModel = _threadCommentModel, this._threadCommentDataSourceService = _threadCommentDataSourceService, this._initSheetChange();
681
690
  }
682
691
  _initSheetChange() {
683
692
  this.disposeWithMe(
684
693
  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)
694
+ getMutations: /* @__PURE__ */ __name((commandInfo) => {
695
+ var _a8;
696
+ if (commandInfo.id === RemoveSheetCommand.id) {
697
+ const params = commandInfo.params, workbook = params.unitId ? this._univerInstanceService.getUnit(params.unitId) : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
698
+ if (!workbook)
690
699
  return { redos: [], undos: [] };
691
- const r = t.getUnitId(), i = n.subUnitId || ((e = t.getActiveSheet()) == null ? void 0 : e.getSheetId());
692
- if (!i)
700
+ const unitId = workbook.getUnitId(), subUnitId = params.subUnitId || ((_a8 = workbook.getActiveSheet()) == null ? void 0 : _a8.getSheetId());
701
+ if (!subUnitId)
693
702
  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,
703
+ 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) => ({
704
+ id: DeleteCommentMutation.id,
696
705
  params: {
697
- unitId: r,
698
- subUnitId: i,
699
- commentId: p
706
+ unitId,
707
+ subUnitId,
708
+ commentId: id
700
709
  }
701
- })), d = a.map(({ children: p, ...v }) => ({
702
- id: ne.id,
710
+ })), undos = comments.map(({ children, ...comment }) => ({
711
+ id: AddCommentMutation.id,
703
712
  params: {
704
- unitId: r,
705
- subUnitId: i,
713
+ unitId,
714
+ subUnitId,
706
715
  comment: {
707
- ...v,
708
- children: u ? p : void 0
716
+ ...comment,
717
+ children: shouldSync ? children : void 0
709
718
  },
710
- sync: !u
719
+ sync: !shouldSync
711
720
  }
712
721
  }));
713
- return { redos: h, undos: d };
722
+ return { redos, undos };
714
723
  }
715
724
  return { redos: [], undos: [] };
716
- }
725
+ }, "getMutations")
717
726
  })
718
727
  );
719
728
  }
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) {
729
+ }, __name(_a6, "ThreadCommentRemoveSheetsController"), _a6);
730
+ ThreadCommentRemoveSheetsController = __decorateClass$1([
731
+ OnLifecycle(LifecycleStages.Ready, ThreadCommentRemoveSheetsController),
732
+ __decorateParam$1(0, Inject(SheetInterceptorService)),
733
+ __decorateParam$1(1, IUniverInstanceService),
734
+ __decorateParam$1(2, Inject(ThreadCommentModel)),
735
+ __decorateParam$1(3, IThreadCommentDataSourceService)
736
+ ], ThreadCommentRemoveSheetsController);
737
+ 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) => {
738
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
739
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
740
+ return kind && result && __defProp2(target, key, result), result;
741
+ }, "__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;
742
+ let UniverSheetsThreadCommentPlugin = (_a7 = class extends Plugin {
743
+ constructor(config = {}, _injector, _commandService) {
735
744
  super();
736
- w(this, "_pluginConfig");
737
- this._injector = n, this._commandService = t, this._pluginConfig = me.deepMerge({}, At, e);
745
+ __publicField(this, "_pluginConfig");
746
+ this._injector = _injector, this._commandService = _commandService, this._pluginConfig = Tools.deepMerge({}, DefaultSheetsThreadCommentConfig, config);
738
747
  }
739
- onStarting(e) {
748
+ onStarting() {
740
749
  [
741
750
  [
742
- A,
751
+ SheetsThreadCommentController,
743
752
  {
744
- useFactory: () => this._injector.createInstance(A, this._pluginConfig)
753
+ useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(SheetsThreadCommentController, this._pluginConfig), "useFactory")
745
754
  }
746
755
  ],
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);
756
+ [SheetsThreadCommentRenderController],
757
+ [SheetsThreadCommentCopyPasteController],
758
+ [SheetsThreadCommentHoverController],
759
+ [ThreadCommentRemoveSheetsController],
760
+ [SheetsThreadCommentPopupService]
761
+ ].forEach((dep) => {
762
+ this._injector.add(dep);
763
+ }), [ShowAddSheetCommentModalOperation].forEach((command) => {
764
+ this._commandService.registerCommand(command);
756
765
  });
757
766
  }
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);
767
+ }, __name(_a7, "UniverSheetsThreadCommentPlugin"), _a7);
768
+ __publicField2(UniverSheetsThreadCommentPlugin, "pluginName", SHEETS_THREAD_COMMENT);
769
+ __publicField2(UniverSheetsThreadCommentPlugin, "type", UniverInstanceType.UNIVER_SHEET);
770
+ UniverSheetsThreadCommentPlugin = __decorateClass([
771
+ DependentOn(UniverThreadCommentUIPlugin, UniverSheetsThreadCommentBasePlugin),
772
+ __decorateParam(1, Inject(Injector)),
773
+ __decorateParam(2, Inject(ICommandService))
774
+ ], UniverSheetsThreadCommentPlugin);
766
775
  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
776
+ ICommandService2 as ICommandService,
777
+ IThreadCommentDataSourceService2 as IThreadCommentDataSourceService,
778
+ IThreadCommentMentionDataService,
779
+ Inject2 as Inject,
780
+ Injector2 as Injector,
781
+ Plugin2 as Plugin,
782
+ SHEETS_THREAD_COMMENT,
783
+ SheetsThreadCommentController,
784
+ SheetsThreadCommentCopyPasteController,
785
+ SheetsThreadCommentHoverController,
786
+ SheetsThreadCommentModel2 as SheetsThreadCommentModel,
787
+ SheetsThreadCommentPopupService,
788
+ ShowAddSheetCommentModalOperation,
789
+ ThreadCommentRemoveSheetsController,
790
+ UniverInstanceType2 as UniverInstanceType,
791
+ UniverSheetsThreadCommentPlugin,
792
+ UniverThreadCommentUIPlugin2 as UniverThreadCommentUIPlugin
784
793
  };