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