123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988 |
- import {
- Et,
- F as F2,
- J,
- Mn,
- jt,
- ue as ue2,
- xn
- } from "./chunk-VMR7OHHI.js";
- import {
- g,
- p as p2
- } from "./chunk-PEI6ACTC.js";
- import {
- N as N2,
- P,
- ae,
- i,
- ne,
- oe,
- p,
- re as re2,
- se
- } from "./chunk-PG4GXCOC.js";
- import {
- De as De2,
- Er,
- Sn,
- gr,
- lf,
- me,
- tt,
- ue,
- vi,
- ws
- } from "./chunk-T4NNB5UY.js";
- import {
- F,
- Hn,
- Io,
- N,
- Nn,
- V,
- Ws,
- an,
- et,
- ko
- } from "./chunk-BW43Z7N3.js";
- import {
- fr,
- ns
- } from "./chunk-QRYBFJ3R.js";
- import "./chunk-MIOQ566M.js";
- import {
- $e,
- Ae,
- Fa,
- He,
- I1,
- P1,
- it,
- l1,
- m1,
- n1,
- u3
- } from "./chunk-POAJ2YNP.js";
- import "./chunk-GBYP4PB2.js";
- import "./chunk-PZD7N4BC.js";
- import {
- Yx
- } from "./chunk-2MK3Q52E.js";
- import "./chunk-BSDDCPAW.js";
- import "./chunk-QG2HZMYH.js";
- import {
- BehaviorSubject,
- De,
- Fe,
- Mi,
- OR,
- Ot,
- Pt,
- Ra,
- SE,
- Vn,
- W0,
- _n,
- ar,
- debounceTime,
- en,
- map,
- nt,
- nu,
- ot,
- re,
- tr,
- z0
- } from "./chunk-23V3HWTR.js";
- import {
- require_react
- } from "./chunk-GNR2UJZM.js";
- import {
- __toESM
- } from "./chunk-2LSFTFF7.js";
- // node_modules/.pnpm/@univerjs+sheets-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/sheets-thread-comment-ui/lib/es/index.js
- var import_react = __toESM(require_react());
- var Be = Object.defineProperty;
- var ke = (o, e, n) => e in o ? Be(o, e, { enumerable: true, configurable: true, writable: true, value: n }) : o[e] = n;
- var E = (o, e, n) => ke(o, typeof e != "symbol" ? e + "" : e, n);
- var $e2 = "univer.sheet.thread-comment-modal";
- var de = "comment-single";
- var Ne = "SHEET_THREAD_COMMENT";
- var $t = Object.defineProperty;
- var Nt = Object.getOwnPropertyDescriptor;
- var xt = (o, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? Nt(e, n) : e, i2 = o.length - 1, s; i2 >= 0; i2--)
- (s = o[i2]) && (r = (t ? s(e, n, r) : s(r)) || r);
- return t && r && $t(e, n, r), r;
- };
- var _e = (o, e) => (n, t) => e(n, t, o);
- var O = class extends nt {
- constructor(e, n) {
- super();
- E(this, "_lastPopup", null);
- E(this, "_activePopup");
- E(this, "_activePopup$", new BehaviorSubject(null));
- E(this, "activePopup$", this._activePopup$.asObservable());
- this._canvasPopupManagerService = e, this._zenZoneService = n, this._initZenVisible(), this.disposeWithMe(() => {
- this._activePopup$.complete();
- });
- }
- get activePopup() {
- return this._activePopup;
- }
- _initZenVisible() {
- this.disposeWithMe(this._zenZoneService.visible$.subscribe((e) => {
- e && this.hidePopup();
- }));
- }
- showPopup(e, n) {
- var m;
- const { row: t, col: r, unitId: i2, subUnitId: s } = e;
- if (this._activePopup && t === this._activePopup.row && r === this._activePopup.col && i2 === this._activePopup.unitId && s === ((m = this.activePopup) == null ? void 0 : m.subUnitId)) {
- this._activePopup = e, this._activePopup$.next(e);
- return;
- }
- if (this._lastPopup && this._lastPopup.dispose(), this._zenZoneService.visible)
- return;
- this._activePopup = e, this._activePopup$.next(e);
- const c = this._canvasPopupManagerService.attachPopupToCell(
- t,
- r,
- {
- componentKey: $e2,
- onClickOutside: () => {
- this.hidePopup();
- },
- direction: "horizontal",
- excludeOutside: [
- ...Array.from(document.querySelectorAll(".univer-thread-comment")),
- document.getElementById("thread-comment-add")
- ].filter(Boolean)
- }
- );
- if (!c)
- throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");
- const a = new Mi();
- a.add(c), a.add({
- dispose: () => {
- n == null || n();
- }
- }), this._lastPopup = a;
- }
- hidePopup() {
- this._activePopup && (this._lastPopup && this._lastPopup.dispose(), this._lastPopup = null, this._activePopup = null, this._activePopup$.next(null));
- }
- persistPopup() {
- !this._activePopup || !this._activePopup.temp || (this._activePopup = {
- ...this._activePopup,
- temp: false
- }, this._activePopup$.next(this._activePopup));
- }
- };
- O = xt([
- _e(0, ot(vi)),
- _e(1, u3)
- ], O);
- var H = {
- type: ar.OPERATION,
- id: "sheets.operation.show-comment-modal",
- handler(o) {
- var f;
- const e = o.get(F), n = o.get(_n), t = o.get(O), r = o.get(J), i2 = (f = e.getCurrentLastSelection()) == null ? void 0 : f.primary, s = o.get(p2);
- if (!i2)
- return false;
- const c = N(n);
- if (!c)
- return false;
- const { workbook: a, worksheet: m, unitId: u, subUnitId: d } = c, h = {
- workbook: a,
- worksheet: m,
- unitId: u,
- subUnitId: d,
- row: i2.startRow,
- col: i2.startColumn
- };
- t.showPopup(h);
- const l = s.getByLocation(u, d, i2.startRow, i2.startColumn);
- return l && r.setActiveComment({
- unitId: u,
- subUnitId: d,
- commentId: l,
- trigger: "context-menu"
- }), true;
- }
- };
- var Dt = "sheets-thread-comment.config";
- var fe = {};
- var jt2 = Object.defineProperty;
- var At = Object.getOwnPropertyDescriptor;
- var Vt = (o, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? At(e, n) : e, i2 = o.length - 1, s; i2 >= 0; i2--)
- (s = o[i2]) && (r = (t ? s(e, n, r) : s(r)) || r);
- return t && r && jt2(e, n, r), r;
- };
- var L = (o, e) => (n, t) => e(n, t, o);
- var W = class extends nt {
- constructor(o, e, n, t) {
- super(), this._sheetInterceptorService = o, this._sheetsThreadCommentModel = e, this._univerInstanceService = n, this._renderManagerService = t, this._initViewModelIntercept(), this._initSkeletonChange();
- }
- _initViewModelIntercept() {
- this.disposeWithMe(
- this._sheetInterceptorService.intercept(
- et.CELL_CONTENT,
- {
- effect: Vn.Style,
- handler: (o, e, n) => {
- const { row: t, col: r, unitId: i2, subUnitId: s } = e;
- return this._sheetsThreadCommentModel.showCommentMarker(i2, s, t, r) ? n({
- ...o,
- markers: {
- ...o == null ? void 0 : o.markers,
- tr: {
- color: "#FFBD37",
- size: 6
- }
- }
- }) : n(o);
- },
- priority: 100
- }
- )
- );
- }
- _initSkeletonChange() {
- const o = () => {
- var r;
- const e = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET);
- if (!e)
- return;
- const n = e.getUnitId(), t = this._renderManagerService.getRenderById(n);
- (r = t == null ? void 0 : t.mainComponent) == null || r.makeForceDirty();
- };
- this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(debounceTime(16)).subscribe(() => {
- o();
- }));
- }
- };
- W = Vt([
- L(0, ot(V)),
- L(1, ot(p2)),
- L(2, _n),
- L(3, Yx)
- ], W);
- var Ht = Object.defineProperty;
- var Lt = Object.getOwnPropertyDescriptor;
- var Bt = (o, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? Lt(e, n) : e, i2 = o.length - 1, s; i2 >= 0; i2--)
- (s = o[i2]) && (r = (t ? s(e, n, r) : s(r)) || r);
- return t && r && Ht(e, n, r), r;
- };
- var ne2 = (o, e) => (n, t) => e(n, t, o);
- var kt = (o, e, n) => {
- const t = ns(o), r = n.row - e.row, i2 = n.column - e.column, s = {
- startColumn: t.column + i2,
- startRow: t.row + r,
- endColumn: t.column + i2,
- endRow: t.row + r
- };
- return fr(s);
- };
- var Z = class extends nt {
- constructor(e, n, t) {
- super();
- E(this, "_copyInfo");
- this._sheetClipboardService = e, this._sheetsThreadCommentModel = n, this._threadCommentDataSourceService = t, this._initClipboardHook();
- }
- // eslint-disable-next-line max-lines-per-function
- _initClipboardHook() {
- this.disposeWithMe(
- this._sheetClipboardService.addClipboardHook({
- id: Ne,
- onBeforeCopy: (e, n, t) => {
- this._copyInfo = {
- unitId: e,
- subUnitId: n,
- range: t
- };
- },
- // eslint-disable-next-line max-lines-per-function
- onPasteCells: (e, n, t, r) => {
- const { unitId: i2, subUnitId: s, range: c } = n, a = {
- row: c.rows[0],
- column: c.cols[0]
- };
- if (r.copyType === gr.CUT && this._copyInfo) {
- const { range: m, unitId: u, subUnitId: d } = this._copyInfo, h = {
- row: m.startRow,
- column: m.startColumn
- };
- if (!(i2 === u && s === d)) {
- const l = [];
- tr.foreach(m, (g2, p3) => {
- const I = this._sheetsThreadCommentModel.getAllByLocation(u, d, g2, p3);
- this._threadCommentDataSourceService.syncUpdateMutationToColla ? I.forEach((v) => {
- l.push(v);
- }) : I.forEach(({ children: v, ...M }) => {
- M.parentId || l.push(M);
- });
- });
- const f = [], S = [], U = [], D = [], ee = (g2) => {
- f.unshift({
- id: N2.id,
- params: {
- unitId: u,
- subUnitId: d,
- commentId: g2.id
- }
- }), U.push({
- id: P.id,
- params: {
- unitId: i2,
- subUnitId: s,
- comment: {
- ...g2,
- ref: kt(g2.ref, h, a),
- unitId: i2,
- subUnitId: s
- },
- sync: true
- }
- }), S.push({
- id: P.id,
- params: {
- unitId: u,
- subUnitId: d,
- comment: g2,
- sync: true
- }
- }), D.unshift({
- id: N2.id,
- params: {
- unitId: i2,
- subUnitId: s,
- commentId: g2.id
- }
- });
- };
- return l.forEach((g2) => {
- ee(g2);
- }), {
- redos: [...f, ...U],
- undos: [...D, ...S]
- };
- }
- }
- return {
- redos: [],
- undos: []
- };
- }
- })
- );
- }
- };
- Z = Bt([
- ne2(0, ot(Sn)),
- ne2(1, ot(p2)),
- ne2(2, p)
- ], Z);
- var Ft = Object.defineProperty;
- var Wt = Object.getOwnPropertyDescriptor;
- var Zt = (o, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? Wt(e, n) : e, i2 = o.length - 1, s; i2 >= 0; i2--)
- (s = o[i2]) && (r = (t ? s(e, n, r) : s(r)) || r);
- return t && r && Ft(e, n, r), r;
- };
- var B = (o, e) => (n, t) => e(n, t, o);
- var z = class extends nt {
- constructor(o, e, n, t) {
- super(), this._hoverManagerService = o, this._sheetsThreadCommentPopupService = e, this._sheetsThreadCommentModel = n, this._sheetPermissionCheckController = t, this._initHoverEvent();
- }
- _initHoverEvent() {
- this.disposeWithMe(
- this._hoverManagerService.currentCell$.pipe(debounceTime(100)).subscribe((o) => {
- const e = this._sheetsThreadCommentPopupService.activePopup;
- if (o && (e && e.temp || !e)) {
- const { location: n } = o, { unitId: t, subUnitId: r, row: i2, col: s } = n, c = this._sheetsThreadCommentModel.getByLocation(t, r, i2, s);
- if (c) {
- if (!this._sheetPermissionCheckController.permissionCheckWithRanges({
- workbookTypes: [Ws],
- worksheetTypes: [Hn],
- rangeTypes: [Io]
- }, [{ startRow: i2, startColumn: s, endRow: i2, endColumn: s }]))
- return;
- const m = this._sheetsThreadCommentModel.getComment(t, r, c);
- m && !m.resolved && this._sheetsThreadCommentPopupService.showPopup({
- unitId: t,
- subUnitId: r,
- row: i2,
- col: s,
- commentId: c,
- temp: true
- });
- } else
- e && this._sheetsThreadCommentPopupService.hidePopup();
- }
- })
- );
- }
- };
- z = Zt([
- B(0, ot(Er)),
- B(1, ot(O)),
- B(2, ot(p2)),
- B(3, ot(Nn))
- ], z);
- var zt = Object.defineProperty;
- var qt = Object.getOwnPropertyDescriptor;
- var Gt = (o, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? qt(e, n) : e, i2 = o.length - 1, s; i2 >= 0; i2--)
- (s = o[i2]) && (r = (t ? s(e, n, r) : s(r)) || r);
- return t && r && zt(e, n, r), r;
- };
- var w = (o, e) => (n, t) => e(n, t, o);
- var q = class extends nt {
- constructor(e, n, t, r, i2, s, c, a, m, u) {
- super();
- E(this, "_isSwitchToCommenting", false);
- E(this, "_selectionShapeInfo", null);
- this._commandService = e, this._sheetsThreadCommentPopupService = n, this._sheetsThreadCommentModel = t, this._threadCommentPanelService = r, this._univerInstanceService = i2, this._sheetPermissionCheckController = s, this._markSelectionService = c, this._sheetSelectionService = a, this._editorBridgeService = m, this._renderManagerService = u, this._initCommandListener(), this._initPanelListener(), this._initMarkSelection(), this._initSelectionUpdateListener(), this._initEditorBridge();
- }
- _handleSelectionChange(e, n, t) {
- var h, l, f;
- const r = (h = e[0]) == null ? void 0 : h.range, i2 = this._renderManagerService.getRenderById(n), s = (l = i2 == null ? void 0 : i2.with(me).getWorksheetSkeleton(t)) == null ? void 0 : l.skeleton;
- if (!s || !r)
- return;
- const c = s.getCellWithCoordByIndex(r.startRow, r.startColumn);
- if ((((f = r.rangeType) != null ? f : De.NORMAL) !== De.NORMAL || r.endColumn - r.startColumn > 0 || r.endRow - r.startRow > 0) && !((c.isMerged || c.isMergedMainCell) && en.equals(c.mergeInfo, r))) {
- this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(F2.id);
- return;
- }
- const m = c.actualRow, u = c.actualColumn;
- if (!this._sheetsThreadCommentModel.showCommentMarker(n, t, m, u)) {
- this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(F2.id);
- return;
- }
- const d = this._sheetsThreadCommentModel.getByLocation(n, t, m, u);
- d && this._commandService.executeCommand(F2.id, {
- unitId: n,
- subUnitId: t,
- commentId: d
- });
- }
- _initSelectionUpdateListener() {
- this.disposeWithMe(
- this._sheetSelectionService.selectionMoveEnd$.subscribe((e) => {
- if (this._isSwitchToCommenting)
- return;
- const n = this._sheetSelectionService.currentSelectionParam;
- n && this._handleSelectionChange(e, n.unitId, n.sheetId);
- })
- );
- }
- _initEditorBridge() {
- this.disposeWithMe(
- this._editorBridgeService.visible$.subscribe((e) => {
- e.visible && this._sheetsThreadCommentPopupService.hidePopup();
- })
- );
- }
- _initCommandListener() {
- this._commandService.onCommandExecuted((e) => {
- if (e.id === N2.id) {
- const n = e.params, t = this._sheetsThreadCommentPopupService.activePopup;
- if (!t)
- return;
- const { unitId: r, subUnitId: i2, commentId: s } = t;
- n.unitId === r && n.subUnitId === i2 && n.commentId === s && this._sheetsThreadCommentPopupService.hidePopup();
- }
- });
- }
- _initPanelListener() {
- this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async (e) => {
- var n;
- if (e) {
- const { unitId: t, subUnitId: r, commentId: i2, trigger: s } = e, c = this._sheetsThreadCommentModel.getComment(t, r, i2);
- if (!c || c.resolved)
- return;
- const a = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET);
- if (!a || a.getUnitId() !== t)
- return;
- this._isSwitchToCommenting = true, ((n = a.getActiveSheet()) == null ? void 0 : n.getSheetId()) !== r && await this._commandService.executeCommand(an.id, {
- unitId: t,
- subUnitId: r
- }), this._isSwitchToCommenting = false;
- const d = ns(c.ref), { row: h, column: l } = d;
- if (!this._sheetPermissionCheckController.permissionCheckWithRanges({
- workbookTypes: [Ws],
- worksheetTypes: [Hn],
- rangeTypes: [Io]
- }, [{ startRow: h, startColumn: l, endRow: h, endColumn: l }]))
- return;
- const S = 1;
- if (await this._commandService.executeCommand(lf.id, {
- range: {
- startRow: Math.max(d.row - S, 0),
- endRow: d.row + S,
- startColumn: Math.max(d.column - S, 0),
- endColumn: d.column + S
- }
- }), this._editorBridgeService.isVisible().visible)
- return;
- this._sheetsThreadCommentPopupService.showPopup({
- unitId: t,
- subUnitId: r,
- row: d.row,
- col: d.column,
- commentId: c.id,
- trigger: s
- });
- } else
- this._sheetsThreadCommentPopupService.hidePopup();
- }));
- }
- _initMarkSelection() {
- this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(debounceTime(100)).subscribe((e) => {
- var h, l;
- if (!e) {
- this._selectionShapeInfo && (this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId), this._selectionShapeInfo = null);
- return;
- }
- const { unitId: n, subUnitId: t, commentId: r } = e;
- this._selectionShapeInfo && (this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId), this._selectionShapeInfo = null);
- const i2 = this._sheetsThreadCommentModel.getComment(n, t, r);
- if (!i2)
- return;
- const s = ns(i2.ref), { row: c, column: a } = s;
- if (Number.isNaN(c) || Number.isNaN(a))
- return null;
- const m = (h = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET)) == null ? void 0 : h.getSheetBySheetId(t), u = (l = m == null ? void 0 : m.getMergedCell(c, a)) != null ? l : {
- startColumn: a,
- endColumn: a,
- startRow: c,
- endRow: c
- }, d = this._markSelectionService.addShape(
- {
- range: u,
- style: {
- // hasAutoFill: false,
- fill: "rgb(255, 189, 55, 0.35)",
- strokeWidth: 1,
- stroke: "#FFBD37",
- widgets: {}
- },
- primary: null
- },
- [],
- -1
- );
- d && (this._selectionShapeInfo = {
- ...e,
- shapeId: d
- });
- }));
- }
- };
- q = Gt([
- w(0, Pt),
- w(1, ot(O)),
- w(2, ot(p2)),
- w(3, ot(J)),
- w(4, _n),
- w(5, ot(Nn)),
- w(6, ws),
- w(7, ot(F)),
- w(8, tt),
- w(9, Yx)
- ], q);
- var Jt = Object.defineProperty;
- var Yt = Object.getOwnPropertyDescriptor;
- var Kt = (o, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? Yt(e, n) : e, i2 = o.length - 1, s; i2 >= 0; i2--)
- (s = o[i2]) && (r = (t ? s(e, n, r) : s(r)) || r);
- return t && r && Jt(e, n, r), r;
- };
- var k = (o, e) => (n, t) => e(n, t, o);
- var G = class extends nt {
- constructor(o, e, n, t) {
- super(), this._sheetInterceptorService = o, this._univerInstanceService = e, this._threadCommentModel = n, this._threadCommentDataSourceService = t, this._initSheetChange();
- }
- _initSheetChange() {
- this.disposeWithMe(
- this._sheetInterceptorService.interceptCommand({
- getMutations: (o) => {
- var e;
- if (o.id === ko.id) {
- const n = o.params, t = n.unitId ? this._univerInstanceService.getUnit(n.unitId) : this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_SHEET);
- if (!t)
- return { redos: [], undos: [] };
- const r = t.getUnitId(), i2 = n.subUnitId || ((e = t.getActiveSheet()) == null ? void 0 : e.getSheetId());
- if (!i2)
- return { redos: [], undos: [] };
- const s = this._threadCommentModel.ensureMap(r, i2), c = Array.from(s.values()).filter((h) => !h.parentId), a = c.map((h) => h.id), m = this._threadCommentDataSourceService.syncUpdateMutationToColla, u = a.map((h) => ({
- id: N2.id,
- params: {
- unitId: r,
- subUnitId: i2,
- commentId: h
- }
- })), d = c.map(({ children: h, ...l }) => ({
- id: P.id,
- params: {
- unitId: r,
- subUnitId: i2,
- comment: {
- ...l,
- children: m ? h : void 0
- },
- sync: !m
- }
- }));
- return { redos: u, undos: d };
- }
- return { redos: [], undos: [] };
- }
- })
- );
- }
- };
- G = Kt([
- k(0, ot(V)),
- k(1, _n),
- k(2, ot(i)),
- k(3, p)
- ], G);
- var P2 = function() {
- return P2 = Object.assign || function(o) {
- for (var e, n = 1, t = arguments.length; n < t; n++) {
- e = arguments[n];
- for (var r in e)
- Object.prototype.hasOwnProperty.call(e, r) && (o[r] = e[r]);
- }
- return o;
- }, P2.apply(this, arguments);
- };
- var Qt = function(o, e) {
- var n = {};
- for (var t in o)
- Object.prototype.hasOwnProperty.call(o, t) && e.indexOf(t) < 0 && (n[t] = o[t]);
- if (o != null && typeof Object.getOwnPropertySymbols == "function")
- for (var r = 0, t = Object.getOwnPropertySymbols(o); r < t.length; r++)
- e.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(o, t[r]) && (n[t[r]] = o[t[r]]);
- return n;
- };
- var xe = (0, import_react.forwardRef)(function(o, e) {
- var n = o.icon, t = o.id, r = o.className, i2 = o.extend, s = Qt(o, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), a = (0, import_react.useRef)("_".concat(tn()));
- return De3(n, "".concat(t), { defIds: n.defIds, idSuffix: a.current }, P2({ ref: e, className: c }, s), i2);
- });
- function De3(o, e, n, t, r) {
- return (0, import_react.createElement)(o.tag, P2(P2({ key: e }, Xt(o, n, r)), t), (en2(o, n).children || []).map(function(i2, s) {
- return De3(i2, "".concat(e, "-").concat(o.tag, "-").concat(s), n, void 0, r);
- }));
- }
- function Xt(o, e, n) {
- var t = P2({}, o.attrs);
- n != null && n.colorChannel1 && t.fill === "colorChannel1" && (t.fill = n.colorChannel1);
- var r = e.defIds;
- return !r || r.length === 0 || (o.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + e.idSuffix), Object.entries(t).forEach(function(i2) {
- var s = i2[0], c = i2[1];
- typeof c == "string" && (t[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
- })), t;
- }
- function en2(o, e) {
- var n, t = e.defIds;
- return !t || t.length === 0 ? o : o.tag === "defs" && (!((n = o.children) === null || n === void 0) && n.length) ? P2(P2({}, o), { children: o.children.map(function(r) {
- return typeof r.attrs.id == "string" && t && t.indexOf(r.attrs.id) > -1 ? P2(P2({}, r), { attrs: P2(P2({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
- }) }) : o;
- }
- function tn() {
- return Math.random().toString(36).substring(2, 8);
- }
- xe.displayName = "UniverIcon";
- var nn = { 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" } }] };
- var je = (0, import_react.forwardRef)(function(o, e) {
- return (0, import_react.createElement)(xe, Object.assign({}, o, {
- id: "comment-single",
- ref: e,
- icon: nn
- }));
- });
- je.displayName = "CommentSingle";
- var re3 = { exports: {} };
- var j = {};
- var ve;
- function rn() {
- if (ve)
- return j;
- ve = 1;
- var o = import_react.default, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), t = Object.prototype.hasOwnProperty, r = o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i2 = { key: true, ref: true, __self: true, __source: true };
- function s(c, a, m) {
- var u, d = {}, h = null, l = null;
- m !== void 0 && (h = "" + m), a.key !== void 0 && (h = "" + a.key), a.ref !== void 0 && (l = a.ref);
- for (u in a)
- t.call(a, u) && !i2.hasOwnProperty(u) && (d[u] = a[u]);
- if (c && c.defaultProps)
- for (u in a = c.defaultProps, a)
- d[u] === void 0 && (d[u] = a[u]);
- return { $$typeof: e, type: c, key: h, ref: l, props: d, _owner: r.current };
- }
- return j.Fragment = n, j.jsx = s, j.jsxs = s, j;
- }
- var Ce;
- function on() {
- return Ce || (Ce = 1, re3.exports = rn()), re3.exports;
- }
- var Ae2 = on();
- var sn = () => {
- const o = W0(_n), e = W0(O), n = z0(e.activePopup$), t = W0(p2);
- if (z0(t.commentUpdate$), !n)
- return null;
- const { row: r, col: i2, unitId: s, subUnitId: c, trigger: a } = n, m = t.getByLocation(s, c, r, i2), u = `${re.chatAtABC(i2)}${r + 1}`, d = () => {
- e.hidePopup();
- }, h = (l) => {
- var f, S, U;
- return (U = (S = (f = o.getCurrentUnitForType(Fe.UNIVER_SHEET)) == null ? void 0 : f.getSheetBySheetId(l)) == null ? void 0 : S.getName()) != null ? U : "";
- };
- return Ae2.jsx(
- xn,
- {
- onClick: () => {
- e.persistPopup();
- },
- prefix: "cell",
- id: m,
- unitId: s,
- subUnitId: c,
- type: Fe.UNIVER_SHEET,
- refStr: u,
- onClose: d,
- getSubUnitName: h,
- autoFocus: a === "context-menu"
- }
- );
- };
- var cn = () => {
- var g2;
- const o = W0(ws), e = W0(_n), n = W0(O), t = e.getCurrentUnitForType(Fe.UNIVER_SHEET), r = t.getUnitId(), i2 = W0(Pt), s = (0, import_react.useMemo)(() => t.activeSheet$.pipe(map((p3) => p3 == null ? void 0 : p3.getSheetId())), [t.activeSheet$]), c = z0(s, (g2 = t.getActiveSheet()) == null ? void 0 : g2.getSheetId()), a = (0, import_react.useRef)(), m = W0(J), u = z0(m.activeCommentId$), d = z0(m.panelVisible$, m.panelVisible), h = (0, import_react.useCallback)((p3) => {
- const I = t.getSheets(), v = {};
- I.forEach((T, C) => {
- v[T.getSheetId()] = C;
- });
- const M = (T) => T.map((C) => {
- var me2;
- const y = ns(C.ref), Le = [(me2 = v[C.subUnitId]) != null ? me2 : 0, y.row, y.column];
- return { ...C, p: Le };
- }).sort((C, y) => C.p[0] === y.p[0] ? C.p[1] === y.p[1] ? C.p[2] - y.p[2] : C.p[1] - y.p[1] : C.p[0] - y.p[0]);
- return [
- ...M(p3.filter((T) => !T.resolved)),
- ...M(p3.filter((T) => T.resolved))
- ];
- }, [t]), l = (0, import_react.useCallback)((p3) => {
- var I;
- if (p3.unitId === r && p3.subUnitId === c && !p3.resolved) {
- const { row: v, column: M } = ns(p3.ref), T = t.getSheetBySheetId(p3.subUnitId), C = (I = T == null ? void 0 : T.getMergedCell(v, M)) != null ? I : {
- startColumn: M,
- endColumn: M,
- startRow: v,
- endRow: v
- };
- if (!Number.isNaN(v) && !Number.isNaN(M))
- return o.addShape({
- range: C,
- style: {
- // hasAutoFill: false,
- fill: "rgb(255, 189, 55, 0.35)",
- strokeWidth: 1,
- stroke: "#FFBD37",
- widgets: {}
- },
- primary: null
- });
- }
- }, [o, c, r]), f = (p3) => {
- var I, v;
- return (v = (I = t.getSheetBySheetId(p3)) == null ? void 0 : I.getName()) != null ? v : "";
- }, S = () => {
- i2.executeCommand(H.id);
- }, U = (p3) => {
- u && u.unitId === p3.unitId && u.subUnitId === p3.subUnitId && u.commentId === p3.id || (a.current && (o.removeShape(a.current), a.current = null), a.current = l(p3));
- }, D = () => {
- a.current && (o.removeShape(a.current), a.current = null);
- }, ee = (p3, I) => {
- I && n.hidePopup();
- };
- return (0, import_react.useEffect)(() => {
- !d && a.current && o.removeShape(a.current);
- }, [o, d]), Ae2.jsx(
- Mn,
- {
- unitId: r,
- subUnitId$: s,
- type: Fe.UNIVER_SHEET,
- onAdd: S,
- getSubUnitName: f,
- onResolve: ee,
- sortComments: h,
- onItemEnter: U,
- onItemLeave: D,
- onDeleteComment: () => (D(), true)
- }
- );
- };
- var an2 = (o) => ({
- id: H.id,
- type: $e.BUTTON,
- icon: de,
- title: "sheetThreadComment.menu.addComment",
- hidden$: Fa(o, Fe.UNIVER_SHEET),
- disabled$: ue(o, {
- workbookTypes: [Ws],
- worksheetTypes: [Hn],
- rangeTypes: [Io]
- })
- });
- var un = (o) => ({
- id: Et.id,
- type: $e.BUTTON,
- icon: de,
- tooltip: "sheetThreadComment.menu.commentManagement",
- disabled$: ue(o, {
- workbookTypes: [Ws],
- worksheetTypes: [Hn],
- rangeTypes: [Io]
- }),
- hidden$: Fa(o, Fe.UNIVER_SHEET)
- });
- var dn = {
- id: H.id,
- binding: I1.M | Ae.CTRL_COMMAND | Ae.ALT,
- preconditions: De2
- };
- var mn = {
- [l1.OTHERS]: {
- [Et.id]: {
- order: 1,
- menuItemFactory: un
- }
- },
- [P1.MAIN_AREA]: {
- [He.OTHERS]: {
- [H.id]: {
- order: 0,
- menuItemFactory: an2
- }
- }
- }
- };
- var hn = Object.defineProperty;
- var ln = Object.getOwnPropertyDescriptor;
- var pn = (o, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? ln(e, n) : e, i2 = o.length - 1, s; i2 >= 0; i2--)
- (s = o[i2]) && (r = (t ? s(e, n, r) : s(r)) || r);
- return t && r && hn(e, n, r), r;
- };
- var oe2 = (o, e) => (n, t) => e(n, t, o);
- var J2 = class extends nt {
- constructor(o, e, n) {
- super(), this._menuManagerService = o, this._componentManager = e, this._shortcutService = n, this._initMenu(), this._initShortcut(), this._initComponent();
- }
- _initShortcut() {
- this._shortcutService.registerShortcut(dn);
- }
- _initMenu() {
- this._menuManagerService.mergeMenu(mn);
- }
- _initComponent() {
- [
- [$e2, sn],
- [jt, cn],
- [de, je]
- ].forEach(([o, e]) => {
- this._componentManager.register(o, e);
- });
- }
- };
- J2 = pn([
- oe2(0, m1),
- oe2(1, ot(n1)),
- oe2(2, it)
- ], J2);
- var Ve = Object.defineProperty;
- var _n2 = Object.getOwnPropertyDescriptor;
- var fn = (o, e, n) => e in o ? Ve(o, e, { enumerable: true, configurable: true, writable: true, value: n }) : o[e] = n;
- var vn = (o, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? _n2(e, n) : e, i2 = o.length - 1, s; i2 >= 0; i2--)
- (s = o[i2]) && (r = (t ? s(e, n, r) : s(r)) || r);
- return t && r && Ve(e, n, r), r;
- };
- var ie = (o, e) => (n, t) => e(n, t, o);
- var He2 = (o, e, n) => fn(o, typeof e != "symbol" ? e + "" : e, n);
- var Y = class extends Ra {
- constructor(o = fe, e, n, t) {
- super(), this._config = o, this._injector = e, this._commandService = n, this._configService = t;
- const { menu: r, ...i2 } = nu(
- {},
- fe,
- this._config
- );
- r && this._configService.setConfig("menu", r, { merge: true }), this._configService.setConfig(Dt, i2);
- }
- onStarting() {
- [
- [J2],
- [W],
- [Z],
- [z],
- [G],
- [q],
- [O]
- ].forEach((o) => {
- this._injector.add(o);
- }), [H].forEach((o) => {
- this._commandService.registerCommand(o);
- }), this._injector.get(J2);
- }
- onReady() {
- this._injector.get(W), this._injector.get(G);
- }
- onRendered() {
- this._injector.get(Z), this._injector.get(z), this._injector.get(q);
- }
- };
- He2(Y, "pluginName", Ne);
- He2(Y, "type", Fe.UNIVER_SHEET);
- Y = vn([
- OR(ue2, g),
- ie(1, ot(Ot)),
- ie(2, ot(Pt)),
- ie(3, SE)
- ], Y);
- export {
- ne as AddCommentCommand,
- ae as DeleteCommentCommand,
- se as DeleteCommentTreeCommand,
- p as IThreadCommentDataSourceService,
- re2 as ResolveCommentCommand,
- Ne as SHEETS_THREAD_COMMENT,
- O as SheetsThreadCommentPopupService,
- H as ShowAddSheetCommentModalOperation,
- Y as UniverSheetsThreadCommentUIPlugin,
- ue2 as UniverThreadCommentUIPlugin,
- oe as UpdateCommentCommand
- };
- /*! Bundled license information:
- @univerjs/sheets-thread-comment-ui/lib/es/index.js:
- (**
- * @license React
- * react-jsx-runtime.production.min.js
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *)
- */
- //# sourceMappingURL=@univerjs_sheets-thread-comment-ui.js.map
|