| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844 |
- var Be = Object.defineProperty;
- var ke = (o, e, n) => e in o ? Be(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
- var E = (o, e, n) => ke(o, typeof e != "symbol" ? e + "" : e, n);
- import { Inject as _, Disposable as $, DisposableCollection as Fe, CommandType as We, IUniverInstanceService as N, InterceptorEffectEnum as Ze, UniverInstanceType as b, Range as ze, ICommandService as ce, RANGE_TYPE as he, Rectangle as qe, useDependency as R, Tools as Ge, DependentOn as Je, Injector as Ye, Plugin as Ke, merge as Qe, IConfigService as Xe } from "@univerjs/core";
- import { SheetsSelectionsService as Se, getSheetCommandTarget as et, SheetInterceptorService as ge, INTERCEPTOR_POINT as tt, SheetPermissionCheckController as Ie, WorkbookCommentPermission as K, WorksheetViewPermission as Q, RangeProtectionPermissionViewPoint as X, SetWorksheetActiveOperation as nt, RemoveSheetCommand as rt } from "@univerjs/sheets";
- import { SheetsThreadCommentModel as x, UniverSheetsThreadCommentPlugin as ot } from "@univerjs/sheets-thread-comment";
- import { ThreadCommentPanelService as ae, SetActiveCommentOperation as te, ThreadCommentTree as it, ThreadCommentPanel as st, ToggleSheetCommentPanelOperation as Pe, THREAD_COMMENT_PANEL as ct, UniverThreadCommentUIPlugin as at } from "@univerjs/thread-comment-ui";
- import { UniverThreadCommentUIPlugin as $n } from "@univerjs/thread-comment-ui";
- import { SheetCanvasPopManagerService as ut, ISheetClipboardService as dt, COPY_TYPE as mt, HoverManagerService as ht, IMarkSelectionService as Te, IEditorBridgeService as lt, SheetSkeletonManagerService as pt, ScrollToRangeOperation as _t, whenSheetEditorFocused as ft, getCurrentRangeDisable$ as be } from "@univerjs/sheets-ui";
- import { IZenZoneService as vt, useObservable as A, KeyCode as Ct, MetaKeys as le, MenuItemType as Me, getMenuHiddenObservable as we, RibbonStartGroup as St, ContextMenuPosition as gt, ContextMenuGroup as It, ComponentManager as Pt, IMenuManagerService as Tt, IShortcutService as bt } from "@univerjs/ui";
- import { BehaviorSubject as Mt, debounceTime as ue, map as wt } from "rxjs";
- import { IRenderManagerService as ye } from "@univerjs/engine-render";
- import { singleReferenceToGrid as V, serializeRange as yt } from "@univerjs/engine-formula";
- import { IThreadCommentDataSourceService as Ee, DeleteCommentMutation as F, AddCommentMutation as se, ThreadCommentModel as Et } from "@univerjs/thread-comment";
- import { AddCommentCommand as xn, DeleteCommentCommand as Dn, DeleteCommentTreeCommand as jn, IThreadCommentDataSourceService as An, ResolveCommentCommand as Vn, UpdateCommentCommand as Hn } from "@univerjs/thread-comment";
- import Rt, { forwardRef as Re, useRef as Oe, createElement as Ue, useMemo as Ot, useCallback as pe, useEffect as Ut } from "react";
- const $e = "univer.sheet.thread-comment-modal", de = "comment-single", Ne = "SHEET_THREAD_COMMENT";
- var $t = Object.defineProperty, Nt = Object.getOwnPropertyDescriptor, xt = (o, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? Nt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
- (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
- return t && r && $t(e, n, r), r;
- }, _e = (o, e) => (n, t) => e(n, t, o);
- let O = class extends $ {
- constructor(e, n) {
- super();
- E(this, "_lastPopup", null);
- E(this, "_activePopup");
- E(this, "_activePopup$", new Mt(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: i, subUnitId: s } = e;
- if (this._activePopup && t === this._activePopup.row && r === this._activePopup.col && i === 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: $e,
- 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 Fe();
- 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: !1
- }, this._activePopup$.next(this._activePopup));
- }
- };
- O = xt([
- _e(0, _(ut)),
- _e(1, vt)
- ], O);
- const H = {
- type: We.OPERATION,
- id: "sheets.operation.show-comment-modal",
- handler(o) {
- var f;
- const e = o.get(Se), n = o.get(N), t = o.get(O), r = o.get(ae), i = (f = e.getCurrentLastSelection()) == null ? void 0 : f.primary, s = o.get(x);
- if (!i)
- return !1;
- const c = et(n);
- if (!c)
- return !1;
- const { workbook: a, worksheet: m, unitId: u, subUnitId: d } = c, h = {
- workbook: a,
- worksheet: m,
- unitId: u,
- subUnitId: d,
- row: i.startRow,
- col: i.startColumn
- };
- t.showPopup(h);
- const l = s.getByLocation(u, d, i.startRow, i.startColumn);
- return l && r.setActiveComment({
- unitId: u,
- subUnitId: d,
- commentId: l,
- trigger: "context-menu"
- }), !0;
- }
- }, Dt = "sheets-thread-comment.config", fe = {};
- var jt = Object.defineProperty, At = Object.getOwnPropertyDescriptor, Vt = (o, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? At(e, n) : e, i = o.length - 1, s; i >= 0; i--)
- (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
- return t && r && jt(e, n, r), r;
- }, L = (o, e) => (n, t) => e(n, t, o);
- let W = class extends $ {
- 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(
- tt.CELL_CONTENT,
- {
- effect: Ze.Style,
- handler: (o, e, n) => {
- const { row: t, col: r, unitId: i, subUnitId: s } = e;
- return this._sheetsThreadCommentModel.showCommentMarker(i, 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(b.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(ue(16)).subscribe(() => {
- o();
- }));
- }
- };
- W = Vt([
- L(0, _(ge)),
- L(1, _(x)),
- L(2, N),
- L(3, ye)
- ], W);
- var Ht = Object.defineProperty, Lt = Object.getOwnPropertyDescriptor, Bt = (o, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? Lt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
- (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
- return t && r && Ht(e, n, r), r;
- }, ne = (o, e) => (n, t) => e(n, t, o);
- const kt = (o, e, n) => {
- const t = V(o), r = n.row - e.row, i = n.column - e.column, s = {
- startColumn: t.column + i,
- startRow: t.row + r,
- endColumn: t.column + i,
- endRow: t.row + r
- };
- return yt(s);
- };
- let Z = class extends $ {
- 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: i, subUnitId: s, range: c } = n, a = {
- row: c.rows[0],
- column: c.cols[0]
- };
- if (r.copyType === mt.CUT && this._copyInfo) {
- const { range: m, unitId: u, subUnitId: d } = this._copyInfo, h = {
- row: m.startRow,
- column: m.startColumn
- };
- if (!(i === u && s === d)) {
- const l = [];
- ze.foreach(m, (g, p) => {
- const I = this._sheetsThreadCommentModel.getAllByLocation(u, d, g, p);
- 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 = (g) => {
- f.unshift({
- id: F.id,
- params: {
- unitId: u,
- subUnitId: d,
- commentId: g.id
- }
- }), U.push({
- id: se.id,
- params: {
- unitId: i,
- subUnitId: s,
- comment: {
- ...g,
- ref: kt(g.ref, h, a),
- unitId: i,
- subUnitId: s
- },
- sync: !0
- }
- }), S.push({
- id: se.id,
- params: {
- unitId: u,
- subUnitId: d,
- comment: g,
- sync: !0
- }
- }), D.unshift({
- id: F.id,
- params: {
- unitId: i,
- subUnitId: s,
- commentId: g.id
- }
- });
- };
- return l.forEach((g) => {
- ee(g);
- }), {
- redos: [...f, ...U],
- undos: [...D, ...S]
- };
- }
- }
- return {
- redos: [],
- undos: []
- };
- }
- })
- );
- }
- };
- Z = Bt([
- ne(0, _(dt)),
- ne(1, _(x)),
- ne(2, Ee)
- ], Z);
- var Ft = Object.defineProperty, Wt = Object.getOwnPropertyDescriptor, Zt = (o, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? Wt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
- (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
- return t && r && Ft(e, n, r), r;
- }, B = (o, e) => (n, t) => e(n, t, o);
- let z = class extends $ {
- 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(ue(100)).subscribe((o) => {
- const e = this._sheetsThreadCommentPopupService.activePopup;
- if (o && (e && e.temp || !e)) {
- const { location: n } = o, { unitId: t, subUnitId: r, row: i, col: s } = n, c = this._sheetsThreadCommentModel.getByLocation(t, r, i, s);
- if (c) {
- if (!this._sheetPermissionCheckController.permissionCheckWithRanges({
- workbookTypes: [K],
- worksheetTypes: [Q],
- rangeTypes: [X]
- }, [{ startRow: i, startColumn: s, endRow: i, endColumn: s }]))
- return;
- const m = this._sheetsThreadCommentModel.getComment(t, r, c);
- m && !m.resolved && this._sheetsThreadCommentPopupService.showPopup({
- unitId: t,
- subUnitId: r,
- row: i,
- col: s,
- commentId: c,
- temp: !0
- });
- } else
- e && this._sheetsThreadCommentPopupService.hidePopup();
- }
- })
- );
- }
- };
- z = Zt([
- B(0, _(ht)),
- B(1, _(O)),
- B(2, _(x)),
- B(3, _(Ie))
- ], z);
- var zt = Object.defineProperty, qt = Object.getOwnPropertyDescriptor, Gt = (o, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? qt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
- (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
- return t && r && zt(e, n, r), r;
- }, w = (o, e) => (n, t) => e(n, t, o);
- let q = class extends $ {
- constructor(e, n, t, r, i, s, c, a, m, u) {
- super();
- E(this, "_isSwitchToCommenting", !1);
- E(this, "_selectionShapeInfo", null);
- this._commandService = e, this._sheetsThreadCommentPopupService = n, this._sheetsThreadCommentModel = t, this._threadCommentPanelService = r, this._univerInstanceService = i, 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, i = this._renderManagerService.getRenderById(n), s = (l = i == null ? void 0 : i.with(pt).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 : he.NORMAL) !== he.NORMAL || r.endColumn - r.startColumn > 0 || r.endRow - r.startRow > 0) && !((c.isMerged || c.isMergedMainCell) && qe.equals(c.mergeInfo, r))) {
- this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(te.id);
- return;
- }
- const m = c.actualRow, u = c.actualColumn;
- if (!this._sheetsThreadCommentModel.showCommentMarker(n, t, m, u)) {
- this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(te.id);
- return;
- }
- const d = this._sheetsThreadCommentModel.getByLocation(n, t, m, u);
- d && this._commandService.executeCommand(te.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 === F.id) {
- const n = e.params, t = this._sheetsThreadCommentPopupService.activePopup;
- if (!t)
- return;
- const { unitId: r, subUnitId: i, commentId: s } = t;
- n.unitId === r && n.subUnitId === i && 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: i, trigger: s } = e, c = this._sheetsThreadCommentModel.getComment(t, r, i);
- if (!c || c.resolved)
- return;
- const a = this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
- if (!a || a.getUnitId() !== t)
- return;
- this._isSwitchToCommenting = !0, ((n = a.getActiveSheet()) == null ? void 0 : n.getSheetId()) !== r && await this._commandService.executeCommand(nt.id, {
- unitId: t,
- subUnitId: r
- }), this._isSwitchToCommenting = !1;
- const d = V(c.ref), { row: h, column: l } = d;
- if (!this._sheetPermissionCheckController.permissionCheckWithRanges({
- workbookTypes: [K],
- worksheetTypes: [Q],
- rangeTypes: [X]
- }, [{ startRow: h, startColumn: l, endRow: h, endColumn: l }]))
- return;
- const S = 1;
- if (await this._commandService.executeCommand(_t.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(ue(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 i = this._sheetsThreadCommentModel.getComment(n, t, r);
- if (!i)
- return;
- const s = V(i.ref), { row: c, column: a } = s;
- if (Number.isNaN(c) || Number.isNaN(a))
- return null;
- const m = (h = this._univerInstanceService.getCurrentUnitForType(b.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, ce),
- w(1, _(O)),
- w(2, _(x)),
- w(3, _(ae)),
- w(4, N),
- w(5, _(Ie)),
- w(6, Te),
- w(7, _(Se)),
- w(8, lt),
- w(9, ye)
- ], q);
- var Jt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Kt = (o, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? Yt(e, n) : e, i = o.length - 1, s; i >= 0; i--)
- (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
- return t && r && Jt(e, n, r), r;
- }, k = (o, e) => (n, t) => e(n, t, o);
- let G = class extends $ {
- 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 === rt.id) {
- const n = o.params, t = n.unitId ? this._univerInstanceService.getUnit(n.unitId) : this._univerInstanceService.getCurrentUnitForType(b.UNIVER_SHEET);
- if (!t)
- return { redos: [], undos: [] };
- const r = t.getUnitId(), i = n.subUnitId || ((e = t.getActiveSheet()) == null ? void 0 : e.getSheetId());
- if (!i)
- return { redos: [], undos: [] };
- const s = this._threadCommentModel.ensureMap(r, i), c = Array.from(s.values()).filter((h) => !h.parentId), a = c.map((h) => h.id), m = this._threadCommentDataSourceService.syncUpdateMutationToColla, u = a.map((h) => ({
- id: F.id,
- params: {
- unitId: r,
- subUnitId: i,
- commentId: h
- }
- })), d = c.map(({ children: h, ...l }) => ({
- id: se.id,
- params: {
- unitId: r,
- subUnitId: i,
- comment: {
- ...l,
- children: m ? h : void 0
- },
- sync: !m
- }
- }));
- return { redos: u, undos: d };
- }
- return { redos: [], undos: [] };
- }
- })
- );
- }
- };
- G = Kt([
- k(0, _(ge)),
- k(1, N),
- k(2, _(Et)),
- k(3, Ee)
- ], G);
- var P = function() {
- return P = 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;
- }, P.apply(this, arguments);
- }, 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;
- }, xe = Re(function(o, e) {
- var n = o.icon, t = o.id, r = o.className, i = o.extend, s = Qt(o, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), a = Oe("_".concat(tn()));
- return De(n, "".concat(t), { defIds: n.defIds, idSuffix: a.current }, P({ ref: e, className: c }, s), i);
- });
- function De(o, e, n, t, r) {
- return Ue(o.tag, P(P({ key: e }, Xt(o, n, r)), t), (en(o, n).children || []).map(function(i, s) {
- return De(i, "".concat(e, "-").concat(o.tag, "-").concat(s), n, void 0, r);
- }));
- }
- function Xt(o, e, n) {
- var t = P({}, 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(i) {
- var s = i[0], c = i[1];
- typeof c == "string" && (t[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
- })), t;
- }
- function en(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) ? P(P({}, o), { children: o.children.map(function(r) {
- return typeof r.attrs.id == "string" && t && t.indexOf(r.attrs.id) > -1 ? P(P({}, r), { attrs: P(P({}, 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" } }] }, je = Re(function(o, e) {
- return Ue(xe, Object.assign({}, o, {
- id: "comment-single",
- ref: e,
- icon: nn
- }));
- });
- je.displayName = "CommentSingle";
- var re = { exports: {} }, j = {};
- /**
- * @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.
- */
- var ve;
- function rn() {
- if (ve) return j;
- ve = 1;
- var o = Rt, 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, i = { key: !0, ref: !0, __self: !0, __source: !0 };
- 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) && !i.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, re.exports = rn()), re.exports;
- }
- var Ae = on();
- const sn = () => {
- const o = R(N), e = R(O), n = A(e.activePopup$), t = R(x);
- if (A(t.commentUpdate$), !n)
- return null;
- const { row: r, col: i, unitId: s, subUnitId: c, trigger: a } = n, m = t.getByLocation(s, c, r, i), u = `${Ge.chatAtABC(i)}${r + 1}`, d = () => {
- e.hidePopup();
- }, h = (l) => {
- var f, S, U;
- return (U = (S = (f = o.getCurrentUnitForType(b.UNIVER_SHEET)) == null ? void 0 : f.getSheetBySheetId(l)) == null ? void 0 : S.getName()) != null ? U : "";
- };
- return /* @__PURE__ */ Ae.jsx(
- it,
- {
- onClick: () => {
- e.persistPopup();
- },
- prefix: "cell",
- id: m,
- unitId: s,
- subUnitId: c,
- type: b.UNIVER_SHEET,
- refStr: u,
- onClose: d,
- getSubUnitName: h,
- autoFocus: a === "context-menu"
- }
- );
- }, cn = () => {
- var g;
- const o = R(Te), e = R(N), n = R(O), t = e.getCurrentUnitForType(b.UNIVER_SHEET), r = t.getUnitId(), i = R(ce), s = Ot(() => t.activeSheet$.pipe(wt((p) => p == null ? void 0 : p.getSheetId())), [t.activeSheet$]), c = A(s, (g = t.getActiveSheet()) == null ? void 0 : g.getSheetId()), a = Oe(), m = R(ae), u = A(m.activeCommentId$), d = A(m.panelVisible$, m.panelVisible), h = pe((p) => {
- const I = t.getSheets(), v = {};
- I.forEach((T, C) => {
- v[T.getSheetId()] = C;
- });
- const M = (T) => T.map((C) => {
- var me;
- const y = V(C.ref), Le = [(me = v[C.subUnitId]) != null ? me : 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(p.filter((T) => !T.resolved)),
- ...M(p.filter((T) => T.resolved))
- ];
- }, [t]), l = pe((p) => {
- var I;
- if (p.unitId === r && p.subUnitId === c && !p.resolved) {
- const { row: v, column: M } = V(p.ref), T = t.getSheetBySheetId(p.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 = (p) => {
- var I, v;
- return (v = (I = t.getSheetBySheetId(p)) == null ? void 0 : I.getName()) != null ? v : "";
- }, S = () => {
- i.executeCommand(H.id);
- }, U = (p) => {
- u && u.unitId === p.unitId && u.subUnitId === p.subUnitId && u.commentId === p.id || (a.current && (o.removeShape(a.current), a.current = null), a.current = l(p));
- }, D = () => {
- a.current && (o.removeShape(a.current), a.current = null);
- }, ee = (p, I) => {
- I && n.hidePopup();
- };
- return Ut(() => {
- !d && a.current && o.removeShape(a.current);
- }, [o, d]), /* @__PURE__ */ Ae.jsx(
- st,
- {
- unitId: r,
- subUnitId$: s,
- type: b.UNIVER_SHEET,
- onAdd: S,
- getSubUnitName: f,
- onResolve: ee,
- sortComments: h,
- onItemEnter: U,
- onItemLeave: D,
- onDeleteComment: () => (D(), !0)
- }
- );
- }, an = (o) => ({
- id: H.id,
- type: Me.BUTTON,
- icon: de,
- title: "sheetThreadComment.menu.addComment",
- hidden$: we(o, b.UNIVER_SHEET),
- disabled$: be(o, {
- workbookTypes: [K],
- worksheetTypes: [Q],
- rangeTypes: [X]
- })
- }), un = (o) => ({
- id: Pe.id,
- type: Me.BUTTON,
- icon: de,
- tooltip: "sheetThreadComment.menu.commentManagement",
- disabled$: be(o, {
- workbookTypes: [K],
- worksheetTypes: [Q],
- rangeTypes: [X]
- }),
- hidden$: we(o, b.UNIVER_SHEET)
- }), dn = {
- id: H.id,
- binding: Ct.M | le.CTRL_COMMAND | le.ALT,
- preconditions: ft
- }, mn = {
- [St.OTHERS]: {
- [Pe.id]: {
- order: 1,
- menuItemFactory: un
- }
- },
- [gt.MAIN_AREA]: {
- [It.OTHERS]: {
- [H.id]: {
- order: 0,
- menuItemFactory: an
- }
- }
- }
- };
- var hn = Object.defineProperty, ln = Object.getOwnPropertyDescriptor, pn = (o, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? ln(e, n) : e, i = o.length - 1, s; i >= 0; i--)
- (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
- return t && r && hn(e, n, r), r;
- }, oe = (o, e) => (n, t) => e(n, t, o);
- let J = class extends $ {
- 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() {
- [
- [$e, sn],
- [ct, cn],
- [de, je]
- ].forEach(([o, e]) => {
- this._componentManager.register(o, e);
- });
- }
- };
- J = pn([
- oe(0, Tt),
- oe(1, _(Pt)),
- oe(2, bt)
- ], J);
- var Ve = Object.defineProperty, _n = Object.getOwnPropertyDescriptor, fn = (o, e, n) => e in o ? Ve(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n, vn = (o, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? _n(e, n) : e, i = o.length - 1, s; i >= 0; i--)
- (s = o[i]) && (r = (t ? s(e, n, r) : s(r)) || r);
- return t && r && Ve(e, n, r), r;
- }, ie = (o, e) => (n, t) => e(n, t, o), He = (o, e, n) => fn(o, typeof e != "symbol" ? e + "" : e, n);
- let Y = class extends Ke {
- constructor(o = fe, e, n, t) {
- super(), this._config = o, this._injector = e, this._commandService = n, this._configService = t;
- const { menu: r, ...i } = Qe(
- {},
- fe,
- this._config
- );
- r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(Dt, i);
- }
- onStarting() {
- [
- [J],
- [W],
- [Z],
- [z],
- [G],
- [q],
- [O]
- ].forEach((o) => {
- this._injector.add(o);
- }), [H].forEach((o) => {
- this._commandService.registerCommand(o);
- }), this._injector.get(J);
- }
- onReady() {
- this._injector.get(W), this._injector.get(G);
- }
- onRendered() {
- this._injector.get(Z), this._injector.get(z), this._injector.get(q);
- }
- };
- He(Y, "pluginName", Ne);
- He(Y, "type", b.UNIVER_SHEET);
- Y = vn([
- Je(at, ot),
- ie(1, _(Ye)),
- ie(2, _(ce)),
- ie(3, Xe)
- ], Y);
- export {
- xn as AddCommentCommand,
- Dn as DeleteCommentCommand,
- jn as DeleteCommentTreeCommand,
- An as IThreadCommentDataSourceService,
- Vn as ResolveCommentCommand,
- Ne as SHEETS_THREAD_COMMENT,
- O as SheetsThreadCommentPopupService,
- H as ShowAddSheetCommentModalOperation,
- Y as UniverSheetsThreadCommentUIPlugin,
- $n as UniverThreadCommentUIPlugin,
- Hn as UpdateCommentCommand
- };
|