chunk-VMR7OHHI.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968
  1. import {
  2. D,
  3. ae,
  4. i,
  5. ne,
  6. oe,
  7. pe,
  8. re as re2,
  9. se
  10. } from "./chunk-PG4GXCOC.js";
  11. import {
  12. He,
  13. Ra as Ra2,
  14. cf
  15. } from "./chunk-MIOQ566M.js";
  16. import {
  17. I1,
  18. rt
  19. } from "./chunk-POAJ2YNP.js";
  20. import {
  21. Gf,
  22. Po,
  23. UO,
  24. qO,
  25. r_,
  26. sC
  27. } from "./chunk-GBYP4PB2.js";
  28. import {
  29. BehaviorSubject,
  30. Dt,
  31. Fe,
  32. OR,
  33. Ot,
  34. Pt,
  35. Ra,
  36. SE,
  37. Vr,
  38. W0,
  39. _n,
  40. ar,
  41. debounceTime,
  42. filter,
  43. kE,
  44. mn,
  45. nt,
  46. nu,
  47. ot,
  48. qt,
  49. re,
  50. rr,
  51. st,
  52. su,
  53. z0
  54. } from "./chunk-23V3HWTR.js";
  55. import {
  56. require_react
  57. } from "./chunk-GNR2UJZM.js";
  58. import {
  59. __toESM
  60. } from "./chunk-2LSFTFF7.js";
  61. // node_modules/.pnpm/@univerjs+thread-comment-ui@0.5.5_@grpc+grpc-js@1.13.4_react-dom@18.3.1_react@18.3.1_rxjs@7.8.1_typescript@5.4.5/node_modules/@univerjs/thread-comment-ui/lib/es/index.js
  62. var import_react = __toESM(require_react());
  63. var qe = Object.defineProperty;
  64. var Ze = (t, e, n) => e in t ? qe(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n;
  65. var V = (t, e, n) => Ze(t, typeof e != "symbol" ? e + "" : e, n);
  66. var St = Object.defineProperty;
  67. var yt = Object.getOwnPropertyDescriptor;
  68. var Tt = (t, e, n, r) => {
  69. for (var o = r > 1 ? void 0 : r ? yt(e, n) : e, s = t.length - 1, l; s >= 0; s--)
  70. (l = t[s]) && (o = (r ? l(e, n, o) : l(o)) || o);
  71. return r && o && St(e, n, o), o;
  72. };
  73. var Se = (t, e) => (n, r) => e(n, r, t);
  74. var J = class extends nt {
  75. constructor(e, n) {
  76. super();
  77. V(this, "_panelVisible", false);
  78. V(this, "_panelVisible$", new BehaviorSubject(false));
  79. V(this, "_activeCommentId");
  80. V(this, "_activeCommentId$", new BehaviorSubject(void 0));
  81. V(this, "panelVisible$", this._panelVisible$.asObservable());
  82. V(this, "activeCommentId$", this._activeCommentId$.asObservable());
  83. this._sidebarService = e, this._univerInstanceService = n, this._init(), this.disposeWithMe(() => {
  84. this._activeCommentId$.complete(), this._panelVisible$.complete();
  85. });
  86. }
  87. _init() {
  88. this.disposeWithMe(
  89. this._sidebarService.sidebarOptions$.subscribe((e) => {
  90. e.visible || this.setPanelVisible(false);
  91. })
  92. ), this.disposeWithMe(
  93. this._univerInstanceService.getCurrentTypeOfUnit$(Fe.UNIVER_SHEET).pipe(filter((e) => !e)).subscribe(() => {
  94. this._sidebarService.close();
  95. })
  96. );
  97. }
  98. get panelVisible() {
  99. return this._panelVisible;
  100. }
  101. get activeCommentId() {
  102. return this._activeCommentId;
  103. }
  104. setPanelVisible(e) {
  105. this._panelVisible = e, this._panelVisible$.next(e);
  106. }
  107. setActiveComment(e) {
  108. this._activeCommentId = e, this._activeCommentId$.next(e);
  109. }
  110. };
  111. J = Tt([
  112. Se(0, ot(rt)),
  113. Se(1, _n)
  114. ], J);
  115. var jt = "thread-comment-panel";
  116. var Nt = "UNIVER_THREAD_COMMENT_UI_PLUGIN";
  117. var Et = {
  118. id: "thread-comment-ui.operation.toggle-panel",
  119. type: ar.OPERATION,
  120. handler(t) {
  121. const e = t.get(rt), n = t.get(J);
  122. return n.panelVisible ? (e.close(), n.setPanelVisible(false)) : (e.open({
  123. header: { title: "threadCommentUI.panel.title" },
  124. children: { label: jt },
  125. width: 330
  126. }), n.setPanelVisible(true)), true;
  127. }
  128. };
  129. var F = {
  130. id: "thread-comment-ui.operation.set-active-comment",
  131. type: ar.OPERATION,
  132. handler(t, e) {
  133. return t.get(J).setActiveComment(e), true;
  134. }
  135. };
  136. var Ut = "thread-comment-ui.config";
  137. var ye = {};
  138. var De = Object.defineProperty;
  139. var Pt2 = Object.getOwnPropertyDescriptor;
  140. var Ot2 = (t, e, n) => e in t ? De(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n;
  141. var Rt = (t, e, n, r) => {
  142. for (var o = r > 1 ? void 0 : r ? Pt2(e, n) : e, s = t.length - 1, l; s >= 0; s--)
  143. (l = t[s]) && (o = (r ? l(e, n, o) : l(o)) || o);
  144. return r && o && De(e, n, o), o;
  145. };
  146. var fe = (t, e) => (n, r) => e(n, r, t);
  147. var He2 = (t, e, n) => Ot2(t, typeof e != "symbol" ? e + "" : e, n);
  148. var ue = class extends Ra {
  149. constructor(t = ye, e, n, r) {
  150. super(), this._config = t, this._injector = e, this._commandService = n, this._configService = r;
  151. const { menu: o, ...s } = nu(
  152. {},
  153. ye,
  154. this._config
  155. );
  156. o && this._configService.setConfig("menu", o, { merge: true }), this._configService.setConfig(Ut, s);
  157. }
  158. onStarting() {
  159. var t;
  160. kE([
  161. [J]
  162. ], (t = this._config) == null ? void 0 : t.overrides).forEach((e) => {
  163. this._injector.add(e);
  164. }), [Et, F].forEach((e) => {
  165. this._commandService.registerCommand(e);
  166. });
  167. }
  168. };
  169. He2(ue, "pluginName", Nt);
  170. He2(ue, "type", Fe.UNIVER_UNKNOWN);
  171. ue = Rt([
  172. OR(D),
  173. fe(1, ot(Ot)),
  174. fe(2, Pt),
  175. fe(3, SE)
  176. ], ue);
  177. var ve = { exports: {} };
  178. var ee = {};
  179. var Te;
  180. function $t() {
  181. if (Te)
  182. return ee;
  183. Te = 1;
  184. var t = import_react.default, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, o = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: true, ref: true, __self: true, __source: true };
  185. function l(h, c, x) {
  186. var C, T = {}, b = null, _ = null;
  187. x !== void 0 && (b = "" + x), c.key !== void 0 && (b = "" + c.key), c.ref !== void 0 && (_ = c.ref);
  188. for (C in c)
  189. r.call(c, C) && !s.hasOwnProperty(C) && (T[C] = c[C]);
  190. if (h && h.defaultProps)
  191. for (C in c = h.defaultProps, c)
  192. T[C] === void 0 && (T[C] = c[C]);
  193. return { $$typeof: e, type: h, key: b, ref: _, props: T, _owner: o.current };
  194. }
  195. return ee.Fragment = n, ee.jsx = l, ee.jsxs = l, ee;
  196. }
  197. var je;
  198. function Dt2() {
  199. return je || (je = 1, ve.exports = $t()), ve.exports;
  200. }
  201. var i2 = Dt2();
  202. var $ = function() {
  203. return $ = Object.assign || function(t) {
  204. for (var e, n = 1, r = arguments.length; n < r; n++) {
  205. e = arguments[n];
  206. for (var o in e)
  207. Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
  208. }
  209. return t;
  210. }, $.apply(this, arguments);
  211. };
  212. var Ht = function(t, e) {
  213. var n = {};
  214. for (var r in t)
  215. Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
  216. if (t != null && typeof Object.getOwnPropertySymbols == "function")
  217. for (var o = 0, r = Object.getOwnPropertySymbols(t); o < r.length; o++)
  218. e.indexOf(r[o]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[o]) && (n[r[o]] = t[r[o]]);
  219. return n;
  220. };
  221. var z = (0, import_react.forwardRef)(function(t, e) {
  222. var n = t.icon, r = t.id, o = t.className, s = t.extend, l = Ht(t, ["icon", "id", "className", "extend"]), h = "univerjs-icon univerjs-icon-".concat(r, " ").concat(o || "").trim(), c = (0, import_react.useRef)("_".concat(kt()));
  223. return Me(n, "".concat(r), { defIds: n.defIds, idSuffix: c.current }, $({ ref: e, className: h }, l), s);
  224. });
  225. function Me(t, e, n, r, o) {
  226. return (0, import_react.createElement)(t.tag, $($({ key: e }, Mt(t, n, o)), r), (wt(t, n).children || []).map(function(s, l) {
  227. return Me(s, "".concat(e, "-").concat(t.tag, "-").concat(l), n, void 0, o);
  228. }));
  229. }
  230. function Mt(t, e, n) {
  231. var r = $({}, t.attrs);
  232. n != null && n.colorChannel1 && r.fill === "colorChannel1" && (r.fill = n.colorChannel1);
  233. var o = e.defIds;
  234. return !o || o.length === 0 || (t.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(s) {
  235. var l = s[0], h = s[1];
  236. typeof h == "string" && (r[l] = h.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
  237. })), r;
  238. }
  239. function wt(t, e) {
  240. var n, r = e.defIds;
  241. return !r || r.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? $($({}, t), { children: t.children.map(function(o) {
  242. return typeof o.attrs.id == "string" && r && r.indexOf(o.attrs.id) > -1 ? $($({}, o), { attrs: $($({}, o.attrs), { id: o.attrs.id + e.idSuffix }) }) : o;
  243. }) }) : t;
  244. }
  245. function kt() {
  246. return Math.random().toString(36).substring(2, 8);
  247. }
  248. z.displayName = "UniverIcon";
  249. var Lt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z", fillRule: "evenodd", clipRule: "evenodd" } }] };
  250. var we = (0, import_react.forwardRef)(function(t, e) {
  251. return (0, import_react.createElement)(z, Object.assign({}, t, {
  252. id: "delete-single",
  253. ref: e,
  254. icon: Lt
  255. }));
  256. });
  257. we.displayName = "DeleteSingle";
  258. var At = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z" } }] };
  259. var ke = (0, import_react.forwardRef)(function(t, e) {
  260. return (0, import_react.createElement)(z, Object.assign({}, t, {
  261. id: "increase-single",
  262. ref: e,
  263. icon: At
  264. }));
  265. });
  266. ke.displayName = "IncreaseSingle";
  267. var Vt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z" } }] };
  268. var Le = (0, import_react.forwardRef)(function(t, e) {
  269. return (0, import_react.createElement)(z, Object.assign({}, t, {
  270. id: "more-horizontal-single",
  271. ref: e,
  272. icon: Vt
  273. }));
  274. });
  275. Le.displayName = "MoreHorizontalSingle";
  276. var Bt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { stroke: "currentColor", d: "M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.2 } }, { tag: "path", attrs: { stroke: "currentColor", d: "M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.2 } }, { tag: "path", attrs: { stroke: "currentColor", d: "M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252", strokeLinecap: "round", strokeWidth: 1.2 } }] };
  277. var Ae = (0, import_react.forwardRef)(function(t, e) {
  278. return (0, import_react.createElement)(z, Object.assign({}, t, {
  279. id: "reply-to-comment-single",
  280. ref: e,
  281. icon: Bt
  282. }));
  283. });
  284. Ae.displayName = "ReplyToCommentSingle";
  285. var Ft = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z", fillRule: "evenodd", clipRule: "evenodd" } }] };
  286. var Ve = (0, import_react.forwardRef)(function(t, e) {
  287. return (0, import_react.createElement)(z, Object.assign({}, t, {
  288. id: "resolved-single",
  289. ref: e,
  290. icon: Ft
  291. }));
  292. });
  293. Ve.displayName = "ResolvedSingle";
  294. var Wt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "circle", attrs: { cx: 8.73, cy: 8.4, r: 6.4, stroke: "currentColor", strokeWidth: 1.2 } }, { tag: "path", attrs: { stroke: "currentColor", d: "M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.2 } }] };
  295. var Be = (0, import_react.forwardRef)(function(t, e) {
  296. return (0, import_react.createElement)(z, Object.assign({}, t, {
  297. id: "solve-single",
  298. ref: e,
  299. icon: Wt
  300. }));
  301. });
  302. Be.displayName = "SolveSingle";
  303. function Fe2(t) {
  304. var e, n, r = "";
  305. if (typeof t == "string" || typeof t == "number")
  306. r += t;
  307. else if (typeof t == "object")
  308. if (Array.isArray(t)) {
  309. var o = t.length;
  310. for (e = 0; e < o; e++)
  311. t[e] && (n = Fe2(t[e])) && (r && (r += " "), r += n);
  312. } else
  313. for (n in t)
  314. t[n] && (r && (r += " "), r += n);
  315. return r;
  316. }
  317. function zt() {
  318. for (var t, e, n = 0, r = "", o = arguments.length; n < o; n++)
  319. (t = arguments[n]) && (e = Fe2(t)) && (r && (r += " "), r += e);
  320. return r;
  321. }
  322. var qt2 = "univer-thread-comment-editor-buttons";
  323. var Zt = "univer-thread-comment-editor-suggestion";
  324. var Jt = "univer-thread-comment-editor-suggestionActive";
  325. var Kt = "univer-thread-comment-editor-suggestion-icon";
  326. var Ne = {
  327. threadCommentEditorButtons: qt2,
  328. threadCommentEditorSuggestion: Zt,
  329. threadCommentEditorSuggestionActive: Jt,
  330. threadCommentEditorSuggestionIcon: Kt
  331. };
  332. function Ee(t) {
  333. return {
  334. id: "d",
  335. body: t,
  336. documentStyle: {}
  337. };
  338. }
  339. var We = (0, import_react.forwardRef)((t, e) => {
  340. var M;
  341. const { comment: n, onSave: r, id: o, onCancel: s, autoFocus: l, unitId: h, type: c } = t, x = W0(Pt), C = W0(Vr), [T, b] = (0, import_react.useState)(false), _ = W0(He), u = (0, import_react.useRef)(null), g = c === Fe.UNIVER_SHEET ? su : h, [O, j] = (0, import_react.useState)(() => {
  342. var m, f, I;
  343. return st.transform.getPlainText((I = (f = (m = u.current) == null ? void 0 : m.getDocumentData().body) == null ? void 0 : f.dataStream) != null ? I : "");
  344. });
  345. (0, import_react.useEffect)(() => {
  346. var f, I, d, v;
  347. j(st.transform.getPlainText((d = (I = (f = u.current) == null ? void 0 : f.getDocumentData().body) == null ? void 0 : I.dataStream) != null ? d : ""));
  348. const m = (v = u.current) == null ? void 0 : v.selectionChange$.subscribe(() => {
  349. var q, N, y;
  350. j(st.transform.getPlainText((y = (N = (q = u.current) == null ? void 0 : q.getDocumentData().body) == null ? void 0 : N.dataStream) != null ? y : ""));
  351. });
  352. return () => m == null ? void 0 : m.unsubscribe();
  353. }, [(M = u.current) == null ? void 0 : M.selectionChange$]);
  354. const D2 = (0, import_react.useMemo)(() => ({
  355. keyCodes: [{ keyCode: I1.ENTER }],
  356. handler: (m) => {
  357. m === I1.ENTER && x.executeCommand(
  358. Ra2.id
  359. );
  360. }
  361. }), [x]);
  362. (0, import_react.useImperativeHandle)(e, () => ({
  363. reply(m) {
  364. var f, I;
  365. (f = u.current) == null || f.focus(), (I = u.current) == null || I.setDocumentData(Ee(m));
  366. }
  367. }));
  368. const S = () => {
  369. if (u.current) {
  370. const m = re.deepClone(u.current.getDocumentData().body);
  371. b(false), r == null || r({
  372. ...n,
  373. text: m
  374. }), u.current.replaceText(""), setTimeout(() => {
  375. var f, I;
  376. (f = u.current) == null || f.setSelectionRanges([]), (I = u.current) == null || I.blur();
  377. }, 10);
  378. }
  379. };
  380. return i2.jsxs("div", { className: Ne.threadCommentEditor, onClick: (m) => m.preventDefault(), children: [
  381. i2.jsx(
  382. cf,
  383. {
  384. ref: u,
  385. autoFocus: l,
  386. style: { width: "100%" },
  387. keyboardEventConfig: D2,
  388. placeholder: C.t("threadCommentUI.editor.placeholder"),
  389. initialValue: (n == null ? void 0 : n.text) && Ee(n.text),
  390. onFocusChange: (m) => m && b(m),
  391. isSingle: false,
  392. maxHeight: 64,
  393. onClickOutside: () => {
  394. setTimeout(() => {
  395. _.focus(g);
  396. }, 30);
  397. }
  398. }
  399. ),
  400. T ? i2.jsxs("div", { className: Ne.threadCommentEditorButtons, children: [
  401. i2.jsx(
  402. Po,
  403. {
  404. style: { marginRight: 12 },
  405. onClick: () => {
  406. var m;
  407. s == null || s(), b(false), (m = u.current) == null || m.replaceText("", true), x.executeCommand(F.id);
  408. },
  409. children: C.t("threadCommentUI.editor.cancel")
  410. }
  411. ),
  412. i2.jsx(
  413. Po,
  414. {
  415. type: "primary",
  416. disabled: !O,
  417. onClick: S,
  418. children: C.t(o ? "threadCommentUI.editor.save" : "threadCommentUI.editor.reply")
  419. }
  420. )
  421. ] }) : null
  422. ] });
  423. });
  424. var Gt = (t) => {
  425. const { dataStream: e, customRanges: n } = t, r = e.endsWith(`\r
  426. `) ? e.length - 2 : e.length, o = [];
  427. let s = 0;
  428. return n == null || n.forEach((l) => {
  429. s < l.startIndex && o.push({
  430. type: "text",
  431. content: e.slice(s, l.startIndex)
  432. }), o.push({
  433. type: "mention",
  434. content: {
  435. label: e.slice(l.startIndex, l.endIndex + 1),
  436. id: l.rangeId
  437. }
  438. }), s = l.endIndex + 1;
  439. }), o.push({
  440. type: "text",
  441. content: e.slice(s, r)
  442. }), o;
  443. };
  444. var Yt = (t) => {
  445. const { paragraphs: e = [] } = t;
  446. let n = 0;
  447. return e.map((r) => {
  448. const o = Dt(t, n, r.startIndex);
  449. return n = r.startIndex + 1, Gt(o);
  450. });
  451. };
  452. var Qt = (t) => {
  453. let e = "";
  454. const n = [];
  455. return t.forEach((r) => {
  456. switch (r.type) {
  457. case "text":
  458. e += r.content;
  459. break;
  460. case "mention": {
  461. const o = e.length;
  462. e += r.content.label;
  463. const s = e.length - 1;
  464. n.push({
  465. rangeId: r.content.id,
  466. rangeType: mn.MENTION,
  467. startIndex: o,
  468. endIndex: s,
  469. properties: {}
  470. });
  471. break;
  472. }
  473. }
  474. }), e += `
  475. \r`, {
  476. textRuns: [],
  477. paragraphs: [
  478. {
  479. startIndex: e.length - 2,
  480. paragraphStyle: {}
  481. }
  482. ],
  483. sectionBreaks: [
  484. {
  485. startIndex: e.length - 1
  486. }
  487. ],
  488. dataStream: e,
  489. customRanges: n
  490. };
  491. };
  492. var Xt = "univer-thread-comment";
  493. var en = "univer-thread-comment-active";
  494. var tn = "univer-thread-comment-content";
  495. var nn = "univer-thread-comment-highlight";
  496. var rn = "univer-thread-comment-icon-container";
  497. var on = "univer-thread-comment-icon";
  498. var an = "univer-thread-comment-title";
  499. var sn = "univer-thread-comment-title-position";
  500. var dn = "univer-thread-comment-title-highlight";
  501. var ln = "univer-thread-comment-title-position-text";
  502. var mn2 = "univer-thread-comment-username";
  503. var cn = "univer-thread-comment-item";
  504. var un = "univer-thread-comment-item-head";
  505. var hn = "univer-thread-comment-item-title";
  506. var Cn = "univer-thread-comment-item-title-position";
  507. var fn = "univer-thread-comment-item-title-highlight";
  508. var vn = "univer-thread-comment-item-time";
  509. var pn = "univer-thread-comment-item-content";
  510. var gn = "univer-thread-comment-item-at";
  511. var p = {
  512. threadComment: Xt,
  513. threadCommentActive: en,
  514. threadCommentContent: tn,
  515. threadCommentHighlight: nn,
  516. threadCommentIconContainer: rn,
  517. threadCommentIcon: on,
  518. threadCommentTitle: an,
  519. threadCommentTitlePosition: sn,
  520. threadCommentTitleHighlight: dn,
  521. threadCommentTitlePositionText: ln,
  522. threadCommentUsername: mn2,
  523. threadCommentItem: cn,
  524. threadCommentItemHead: un,
  525. threadCommentItemTitle: hn,
  526. threadCommentItemTitlePosition: Cn,
  527. threadCommentItemTitleHighlight: fn,
  528. threadCommentItemTime: vn,
  529. threadCommentItemContent: pn,
  530. threadCommentItemAt: gn
  531. };
  532. var ze = "__mock__";
  533. var In = (t) => {
  534. const { item: e, unitId: n, subUnitId: r, editing: o, onEditingChange: s, onReply: l, resolved: h, isRoot: c, onClose: x, onDeleteComment: C, type: T } = t, b = W0(Pt), _ = W0(Vr), u = W0(rr), g = u.getUser(e.personId), O = z0(u.currentUser$), j = (O == null ? void 0 : O.userID) === e.personId, D2 = e.id === ze, [S, M] = (0, import_react.useState)(false), m = () => {
  535. (C == null ? void 0 : C(e)) !== false && (b.executeCommand(
  536. c ? se.id : ae.id,
  537. {
  538. unitId: n,
  539. subUnitId: r,
  540. commentId: e.id
  541. }
  542. ), c && (x == null || x()));
  543. };
  544. return i2.jsxs("div", { className: p.threadCommentItem, onMouseLeave: () => M(false), onMouseEnter: () => M(true), children: [
  545. i2.jsx("img", { className: p.threadCommentItemHead, src: g == null ? void 0 : g.avatar }),
  546. i2.jsxs("div", { className: p.threadCommentItemTitle, children: [
  547. i2.jsx("div", { className: p.threadCommentUsername, children: (g == null ? void 0 : g.name) || " " }),
  548. i2.jsxs("div", { children: [
  549. D2 || h ? null : S ? i2.jsx("div", { className: p.threadCommentIcon, onClick: () => l(g), children: i2.jsx(Ae, {}) }) : null,
  550. j && !D2 && !h ? i2.jsx(
  551. sC,
  552. {
  553. overlay: i2.jsxs(UO, { children: [
  554. i2.jsx(qO, { onClick: () => s == null ? void 0 : s(true), children: _.t("threadCommentUI.item.edit") }, "edit"),
  555. i2.jsx(qO, { onClick: m, children: _.t("threadCommentUI.item.delete") }, "delete")
  556. ] }),
  557. children: i2.jsx("div", { className: p.threadCommentIcon, children: i2.jsx(Le, {}) })
  558. }
  559. ) : null
  560. ] })
  561. ] }),
  562. i2.jsx("div", { className: p.threadCommentItemTime, children: e.dT }),
  563. o ? i2.jsx(
  564. We,
  565. {
  566. type: T,
  567. id: e.id,
  568. comment: e,
  569. onCancel: () => s == null ? void 0 : s(false),
  570. autoFocus: true,
  571. unitId: n,
  572. subUnitId: r,
  573. onSave: ({ text: f, attachments: I }) => {
  574. s == null || s(false), b.executeCommand(
  575. oe.id,
  576. {
  577. unitId: n,
  578. subUnitId: r,
  579. payload: {
  580. commentId: e.id,
  581. text: f,
  582. attachments: I
  583. }
  584. }
  585. );
  586. }
  587. }
  588. ) : i2.jsx("div", { className: p.threadCommentItemContent, children: Yt(e.text).map((f, I) => i2.jsx("div", { children: f.map((d, v) => {
  589. switch (d.type) {
  590. case "mention":
  591. return i2.jsxs("a", { className: p.threadCommentItemAt, children: [
  592. d.content.label,
  593. " "
  594. ] }, v);
  595. default:
  596. return d.content;
  597. }
  598. }) }, I)) })
  599. ] });
  600. };
  601. var xn = (t) => {
  602. var Q, X, se2;
  603. const {
  604. id: e,
  605. unitId: n,
  606. subUnitId: r,
  607. refStr: o,
  608. showEdit: s = true,
  609. onClick: l,
  610. showHighlight: h,
  611. onClose: c,
  612. getSubUnitName: x,
  613. prefix: C,
  614. autoFocus: T,
  615. onMouseEnter: b,
  616. onMouseLeave: _,
  617. onAddComment: u,
  618. onDeleteComment: g,
  619. onResolve: O,
  620. type: j
  621. } = t, D2 = W0(i), [S, M] = (0, import_react.useState)(false), [m, f] = (0, import_react.useState)(""), I = (0, import_react.useMemo)(() => D2.commentUpdate$.pipe(debounceTime(16)), [D2]);
  622. z0(I);
  623. const d = e ? D2.getCommentWithChildren(n, r, e) : null, v = W0(Pt), q = W0(rr), N = d == null ? void 0 : d.root.resolved, y = z0(q.currentUser$), Z = (0, import_react.useRef)(null), ie = [
  624. ...d ? [d.root] : (
  625. // mock empty comment
  626. [{
  627. id: ze,
  628. text: {
  629. dataStream: `
  630. \r`
  631. },
  632. personId: (Q = y == null ? void 0 : y.userID) != null ? Q : "",
  633. ref: o != null ? o : "",
  634. dT: "",
  635. unitId: n,
  636. subUnitId: r,
  637. threadId: ""
  638. }]
  639. ),
  640. ...(X = d == null ? void 0 : d.children) != null ? X : []
  641. ], R = (0, import_react.useRef)(null), K = (E) => {
  642. E.stopPropagation(), N ? v.executeCommand(F.id, {
  643. unitId: n,
  644. subUnitId: r,
  645. commentId: e
  646. }) : v.executeCommand(F.id), v.executeCommand(re2.id, {
  647. unitId: n,
  648. subUnitId: r,
  649. commentId: e,
  650. resolved: !N
  651. }), O == null || O(!N);
  652. }, w = (E) => {
  653. E.stopPropagation(), v.executeCommand(F.id), !(d != null && d.root && (g == null ? void 0 : g(d.root)) === false) && (v.executeCommand(
  654. se.id,
  655. {
  656. unitId: n,
  657. subUnitId: r,
  658. commentId: e
  659. }
  660. ), c == null || c());
  661. };
  662. (0, import_react.useEffect)(() => _ == null ? void 0 : _(), []);
  663. const G = x((se2 = d == null ? void 0 : d.root.subUnitId) != null ? se2 : r), Y = s && !m && !N, ae2 = `${o || (d == null ? void 0 : d.root.ref) || ""}${G ? " · " : ""}${G}`;
  664. return i2.jsxs(
  665. "div",
  666. {
  667. className: zt(p.threadComment, {
  668. [p.threadCommentActive]: !N && (h || S || C === "cell")
  669. }),
  670. onClick: l,
  671. id: `${C}-${n}-${r}-${e}`,
  672. onMouseEnter: () => {
  673. b == null || b(), M(true);
  674. },
  675. onMouseLeave: () => {
  676. _ == null || _(), M(false);
  677. },
  678. children: [
  679. !N && h ? i2.jsx("div", { className: p.threadCommentHighlight }) : null,
  680. i2.jsxs("div", { className: p.threadCommentTitle, children: [
  681. i2.jsxs("div", { className: p.threadCommentTitlePosition, children: [
  682. i2.jsx("div", { className: p.threadCommentTitleHighlight }),
  683. i2.jsx(Gf, { showIfEllipsis: true, title: ae2, children: i2.jsx("div", { className: p.threadCommentTitlePositionText, children: ae2 }) })
  684. ] }),
  685. d ? i2.jsxs("div", { className: p.threadCommentIconContainer, children: [
  686. i2.jsx(
  687. "div",
  688. {
  689. onClick: K,
  690. className: p.threadCommentIcon,
  691. style: { color: N ? "rgb(var(--green-500))" : "" },
  692. children: N ? i2.jsx(Ve, {}) : i2.jsx(Be, {})
  693. }
  694. ),
  695. (y == null ? void 0 : y.userID) === d.root.personId ? i2.jsx("div", { className: p.threadCommentIcon, onClick: w, children: i2.jsx(we, {}) }) : null
  696. ] }) : null
  697. ] }),
  698. i2.jsx("div", { className: p.threadCommentContent, ref: R, children: ie.map(
  699. (E) => i2.jsx(
  700. In,
  701. {
  702. onClose: c,
  703. unitId: n,
  704. subUnitId: r,
  705. item: E,
  706. isRoot: E.id === (d == null ? void 0 : d.root.id),
  707. editing: m === E.id,
  708. resolved: d == null ? void 0 : d.root.resolved,
  709. type: j,
  710. onEditingChange: (a) => {
  711. f(a ? E.id : "");
  712. },
  713. onReply: (a) => {
  714. a && requestAnimationFrame(() => {
  715. var H;
  716. (H = Z.current) == null || H.reply(Qt([{
  717. type: "mention",
  718. content: {
  719. id: a.userID,
  720. label: a.name
  721. }
  722. }]));
  723. });
  724. },
  725. onAddComment: u,
  726. onDeleteComment: g
  727. },
  728. E.id
  729. )
  730. ) }),
  731. Y ? i2.jsx("div", { children: i2.jsx(
  732. We,
  733. {
  734. ref: Z,
  735. type: j,
  736. unitId: n,
  737. subUnitId: r,
  738. onSave: async ({ text: E, attachments: a }) => {
  739. const H = {
  740. text: E,
  741. attachments: a,
  742. dT: pe(),
  743. id: qt(),
  744. ref: o,
  745. personId: y == null ? void 0 : y.userID,
  746. parentId: d == null ? void 0 : d.root.id,
  747. unitId: n,
  748. subUnitId: r,
  749. threadId: d == null ? void 0 : d.root.threadId
  750. };
  751. (u == null ? void 0 : u(H)) !== false && (await v.executeCommand(
  752. ne.id,
  753. {
  754. unitId: n,
  755. subUnitId: r,
  756. comment: H
  757. }
  758. ), R.current && (R.current.scrollTop = R.current.scrollHeight));
  759. },
  760. autoFocus: T || !d,
  761. onCancel: () => {
  762. d || c == null || c();
  763. }
  764. },
  765. `${T}`
  766. ) }) : null
  767. ]
  768. }
  769. );
  770. };
  771. var bn = "univer-thread-comment-panel";
  772. var _n2 = "univer-thread-comment";
  773. var Sn = "univer-thread-comment-panel-forms";
  774. var yn = "univer-select";
  775. var Tn = "univer-thread-comment-panel-empty";
  776. var jn = "univer-thread-comment-panel-add";
  777. var Nn = "univer-thread-comment-panel-solved";
  778. var te = {
  779. threadCommentPanel: bn,
  780. threadComment: _n2,
  781. threadCommentPanelForms: Sn,
  782. select: yn,
  783. threadCommentPanelEmpty: Tn,
  784. threadCommentPanelAdd: jn,
  785. threadCommentPanelSolved: Nn
  786. };
  787. var Mn = (t) => {
  788. const {
  789. unitId: e,
  790. subUnitId$: n,
  791. type: r,
  792. onAdd: o,
  793. getSubUnitName: s,
  794. onResolve: l,
  795. sortComments: h,
  796. onItemLeave: c,
  797. onItemEnter: x,
  798. disableAdd: C,
  799. tempComment: T,
  800. onAddComment: b,
  801. onDeleteComment: _,
  802. showComments: u
  803. } = t, [g, O] = (0, import_react.useState)("all"), [j, D2] = (0, import_react.useState)("all"), S = W0(Vr), M = W0(rr), m = W0(i), [f, I] = (0, import_react.useState)(() => m.getUnit(e)), d = W0(J), v = z0(d.activeCommentId$), q = z0(m.commentUpdate$), N = W0(Pt), y = z0(n), Z = (0, import_react.useRef)(true), ie = "panel", R = z0(M.currentUser$), K = (0, import_react.useMemo)(() => {
  804. var le;
  805. const a = g === "all" ? f : (le = f.filter((P) => P.subUnitId === y)) != null ? le : [], H = h != null ? h : (P) => P, de = a.map((P) => {
  806. var A;
  807. return { ...P.root, children: (A = P.children) != null ? A : [], users: P.relativeUsers };
  808. });
  809. if (u) {
  810. const P = /* @__PURE__ */ new Map();
  811. return de.forEach((A) => {
  812. P.set(A.id, A);
  813. }), [...u, ""].map((A) => P.get(A)).filter(Boolean);
  814. } else
  815. return H(de);
  816. }, [u, g, f, h, y]), w = (0, import_react.useMemo)(() => [
  817. ...K.filter((a) => !a.resolved),
  818. ...K.filter((a) => a.resolved)
  819. ], [K]), G = (0, import_react.useMemo)(() => j === "resolved" ? w.filter((a) => a.resolved) : j === "unsolved" ? w.filter((a) => !a.resolved) : j === "concern_me" && R != null && R.userID ? w.filter((a) => a == null ? void 0 : a.users.has(R.userID)) : w, [w, R == null ? void 0 : R.userID, j]), Y = T ? [T, ...G] : G, ae2 = Y.filter((a) => !a.resolved), Q = Y.filter((a) => a.resolved), X = j !== "all" || g !== "all", se2 = () => {
  820. D2("all"), O("all");
  821. };
  822. (0, import_react.useEffect)(() => {
  823. e && I(
  824. m.getUnit(e)
  825. );
  826. }, [e, m, q]), (0, import_react.useEffect)(() => {
  827. var P;
  828. if (!v)
  829. return;
  830. if (!Z.current) {
  831. Z.current = true;
  832. return;
  833. }
  834. const { unitId: a, subUnitId: H, commentId: de } = v, le = `${ie}-${a}-${H}-${de}`;
  835. (P = document.getElementById(le)) == null || P.scrollIntoView({ block: "center" });
  836. }, [v]);
  837. const E = (a) => i2.jsx(
  838. xn,
  839. {
  840. prefix: ie,
  841. getSubUnitName: s,
  842. id: a.id,
  843. unitId: a.unitId,
  844. subUnitId: a.subUnitId,
  845. refStr: a.ref,
  846. type: r,
  847. showEdit: (v == null ? void 0 : v.commentId) === a.id,
  848. showHighlight: (v == null ? void 0 : v.commentId) === a.id,
  849. onClick: () => {
  850. Z.current = false, a.resolved ? N.executeCommand(F.id) : N.executeCommand(
  851. F.id,
  852. {
  853. unitId: a.unitId,
  854. subUnitId: a.subUnitId,
  855. commentId: a.id,
  856. temp: false
  857. }
  858. );
  859. },
  860. onMouseEnter: () => x == null ? void 0 : x(a),
  861. onMouseLeave: () => c == null ? void 0 : c(a),
  862. onAddComment: b,
  863. onDeleteComment: _,
  864. onResolve: (H) => l == null ? void 0 : l(a.id, H)
  865. },
  866. a.id
  867. );
  868. return i2.jsxs("div", { className: te.threadCommentPanel, children: [
  869. i2.jsxs("div", { className: te.threadCommentPanelForms, children: [
  870. r === Fe.UNIVER_SHEET ? i2.jsx(
  871. r_,
  872. {
  873. borderless: true,
  874. value: g,
  875. onChange: (a) => O(a),
  876. options: [
  877. {
  878. value: "current",
  879. label: S.t("threadCommentUI.filter.sheet.current")
  880. },
  881. {
  882. value: "all",
  883. label: S.t("threadCommentUI.filter.sheet.all")
  884. }
  885. ]
  886. }
  887. ) : null,
  888. i2.jsx(
  889. r_,
  890. {
  891. borderless: true,
  892. value: j,
  893. onChange: (a) => D2(a),
  894. options: [
  895. {
  896. value: "all",
  897. label: S.t("threadCommentUI.filter.status.all")
  898. },
  899. {
  900. value: "resolved",
  901. label: S.t("threadCommentUI.filter.status.resolved")
  902. },
  903. {
  904. value: "unsolved",
  905. label: S.t("threadCommentUI.filter.status.unsolved")
  906. },
  907. {
  908. value: "concern_me",
  909. label: S.t("threadCommentUI.filter.status.concernMe")
  910. }
  911. ]
  912. }
  913. )
  914. ] }),
  915. ae2.map(E),
  916. Q.length ? i2.jsx("div", { className: te.threadCommentPanelSolved, children: "已解决" }) : null,
  917. Q.map(E),
  918. Y.length ? null : i2.jsxs("div", { className: te.threadCommentPanelEmpty, children: [
  919. X ? S.t("threadCommentUI.panel.filterEmpty") : S.t("threadCommentUI.panel.empty"),
  920. X ? i2.jsx(
  921. Po,
  922. {
  923. onClick: se2,
  924. type: "link",
  925. children: S.t("threadCommentUI.panel.reset")
  926. }
  927. ) : i2.jsxs(
  928. Po,
  929. {
  930. id: "thread-comment-add",
  931. className: te.threadCommentPanelAdd,
  932. type: "primary",
  933. onClick: o,
  934. disabled: C,
  935. children: [
  936. i2.jsx(ke, {}),
  937. S.t("threadCommentUI.panel.addComment")
  938. ]
  939. }
  940. )
  941. ] })
  942. ] });
  943. };
  944. export {
  945. J,
  946. jt,
  947. Et,
  948. F,
  949. ue,
  950. xn,
  951. Mn
  952. };
  953. /*! Bundled license information:
  954. @univerjs/thread-comment-ui/lib/es/index.js:
  955. (**
  956. * @license React
  957. * react-jsx-runtime.production.min.js
  958. *
  959. * Copyright (c) Facebook, Inc. and its affiliates.
  960. *
  961. * This source code is licensed under the MIT license found in the
  962. * LICENSE file in the root directory of this source tree.
  963. *)
  964. */
  965. //# sourceMappingURL=chunk-VMR7OHHI.js.map