strapi-plugin-comments 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -104,7 +104,7 @@ In our minimum support we're following [official Node.js releases timelines](htt
104
104
 
105
105
  **Supported Strapi versions**:
106
106
 
107
- - Strapi v5.6.0 (recently tested)
107
+ - Strapi v5.7.0 (recently tested)
108
108
  - Strapi v5.x
109
109
 
110
110
  > This plugin is designed for **Strapi v5**. To get support for other Strapi versions, please follow the [versions](#-versions) section.
@@ -1,8 +1,8 @@
1
1
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
- import { a0 as Alert, e as Button, f as ForwardRef$4x, B as Box, a1 as ForwardRef$1f, F as Flex, T as Typography, Y as Grid, m as Field, a2 as MultiSelect, a3 as MultiSelectOption, a4 as Accordion, a5 as SwitchImpl, a6 as Toggle, a7 as ForwardRef$59 } from "./index-Bx2boY6h.mjs";
2
+ import { a0 as Alert, e as Button, f as ForwardRef$4x, B as Box, a1 as ForwardRef$1f, F as Flex, T as Typography, Y as Grid, m as Field, a2 as MultiSelect, a3 as MultiSelectOption, a4 as Accordion, a5 as SwitchImpl, a6 as Toggle, a7 as ForwardRef$59 } from "./index-BIorFYba.mjs";
3
3
  import { useTracking, useNotification, Page, Layouts, Form } from "@strapi/strapi/admin";
4
4
  import { useMutation, useQuery, useQueryClient, QueryClient } from "@tanstack/react-query";
5
- import { u as useAPI, f as CommonProviders, a as usePermissions, g as getMessage, l as lodashExports, e as ConfirmationDialog } from "./index-CIqMAf50.mjs";
5
+ import { u as useAPI, f as CommonProviders, a as usePermissions, g as getMessage, l as lodashExports, e as ConfirmationDialog } from "./index-_exHAK6u.mjs";
6
6
  import { useMemo, useRef, useState, useCallback } from "react";
7
7
  import styled from "styled-components";
8
8
  const RenderIf = ({
@@ -11815,7 +11815,7 @@ function isTopLayer(element) {
11815
11815
  function isContainingBlock(elementOrCss) {
11816
11816
  const webkit2 = isWebKit();
11817
11817
  const css2 = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
11818
- return css2.transform !== "none" || css2.perspective !== "none" || (css2.containerType ? css2.containerType !== "normal" : false) || !webkit2 && (css2.backdropFilter ? css2.backdropFilter !== "none" : false) || !webkit2 && (css2.filter ? css2.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css2.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css2.contain || "").includes(value));
11818
+ return ["transform", "translate", "scale", "rotate", "perspective"].some((value) => css2[value] ? css2[value] !== "none" : false) || (css2.containerType ? css2.containerType !== "normal" : false) || !webkit2 && (css2.backdropFilter ? css2.backdropFilter !== "none" : false) || !webkit2 && (css2.filter ? css2.filter !== "none" : false) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((value) => (css2.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css2.contain || "").includes(value));
11819
11819
  }
11820
11820
  function getContainingBlock(element) {
11821
11821
  let currentNode = getParentNode(element);
@@ -12321,6 +12321,9 @@ const platform = {
12321
12321
  isElement,
12322
12322
  isRTL
12323
12323
  };
12324
+ function rectsAreEqual(a2, b2) {
12325
+ return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
12326
+ }
12324
12327
  function observeMove(element, onMove) {
12325
12328
  let io = null;
12326
12329
  let timeoutId;
@@ -12339,12 +12342,13 @@ function observeMove(element, onMove) {
12339
12342
  threshold = 1;
12340
12343
  }
12341
12344
  cleanup();
12345
+ const elementRectForRootMargin = element.getBoundingClientRect();
12342
12346
  const {
12343
12347
  left,
12344
12348
  top: top2,
12345
12349
  width,
12346
12350
  height
12347
- } = element.getBoundingClientRect();
12351
+ } = elementRectForRootMargin;
12348
12352
  if (!skip) {
12349
12353
  onMove();
12350
12354
  }
@@ -12375,6 +12379,9 @@ function observeMove(element, onMove) {
12375
12379
  refresh(false, ratio);
12376
12380
  }
12377
12381
  }
12382
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
12383
+ refresh();
12384
+ }
12378
12385
  isFirstUpdate = false;
12379
12386
  }
12380
12387
  try {
@@ -12438,7 +12445,7 @@ function autoUpdate(reference, floating, update, options) {
12438
12445
  }
12439
12446
  function frameLoop() {
12440
12447
  const nextRefRect = getBoundingClientRect(reference);
12441
- if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
12448
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
12442
12449
  update();
12443
12450
  }
12444
12451
  prevRefRect = nextRefRect;
@@ -20425,7 +20432,7 @@ function findMinIndex(value, array) {
20425
20432
  }
20426
20433
  function countColumn(string2, tabSize, to = string2.length) {
20427
20434
  let n2 = 0;
20428
- for (let i = 0; i < to; ) {
20435
+ for (let i = 0; i < to && i < string2.length; ) {
20429
20436
  if (string2.charCodeAt(i) == 9) {
20430
20437
  n2 += tabSize - n2 % tabSize;
20431
20438
  i++;
@@ -24273,16 +24280,16 @@ function applyDOMChange(view, domChange) {
24273
24280
  return false;
24274
24281
  if (!change && domChange.typeOver && !sel.empty && newSel && newSel.main.empty) {
24275
24282
  change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };
24283
+ } else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 && /^\. ?$/.test(change.insert.toString()) && view.contentDOM.getAttribute("autocorrect") == "off") {
24284
+ if (newSel && change.insert.length == 2)
24285
+ newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
24286
+ change = { from: change.from, to: change.to, insert: Text.of([change.insert.toString().replace(".", " ")]) };
24276
24287
  } else if (change && change.from >= sel.from && change.to <= sel.to && (change.from != sel.from || change.to != sel.to) && sel.to - sel.from - (change.to - change.from) <= 4) {
24277
24288
  change = {
24278
24289
  from: sel.from,
24279
24290
  to: sel.to,
24280
24291
  insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))
24281
24292
  };
24282
- } else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 && /^\. ?$/.test(change.insert.toString()) && view.contentDOM.getAttribute("autocorrect") == "off") {
24283
- if (newSel && change.insert.length == 2)
24284
- newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
24285
- change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
24286
24293
  } else if (browser.chrome && change && change.from == change.to && change.from == sel.head && change.insert.toString() == "\n " && view.lineWrapping) {
24287
24294
  if (newSel)
24288
24295
  newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
@@ -25918,6 +25925,10 @@ function visiblePixelRange(dom, paddingTop) {
25918
25925
  bottom: Math.max(top2, bottom) - (rect.top + paddingTop)
25919
25926
  };
25920
25927
  }
25928
+ function inWindow(elt) {
25929
+ let rect = elt.getBoundingClientRect(), win = elt.ownerDocument.defaultView || window;
25930
+ return rect.left < win.innerWidth && rect.right > 0 && rect.top < win.innerHeight && rect.bottom > 0;
25931
+ }
25921
25932
  function fullPixelRange(dom, paddingTop) {
25922
25933
  let rect = dom.getBoundingClientRect();
25923
25934
  return {
@@ -26118,7 +26129,7 @@ class ViewState {
26118
26129
  if (inView)
26119
26130
  measureContent = true;
26120
26131
  }
26121
- if (!this.inView && !this.scrollTarget)
26132
+ if (!this.inView && !this.scrollTarget && !inWindow(view.dom))
26122
26133
  return 0;
26123
26134
  let contentWidth = domRect.width;
26124
26135
  if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
@@ -27235,7 +27246,7 @@ class EditContextManager {
27235
27246
  selectionEnd: this.toContextPos(view.state.selection.main.head)
27236
27247
  });
27237
27248
  this.handlers.textupdate = (e2) => {
27238
- let { anchor } = view.state.selection.main;
27249
+ let main = view.state.selection.main, { anchor, head } = main;
27239
27250
  let from = this.toEditorPos(e2.updateRangeStart), to = this.toEditorPos(e2.updateRangeEnd);
27240
27251
  if (view.inputState.composing >= 0 && !this.composing)
27241
27252
  this.composing = { contextBase: e2.updateRangeStart, editorBase: from, drifted: false };
@@ -27244,8 +27255,14 @@ class EditContextManager {
27244
27255
  change.from = anchor;
27245
27256
  else if (change.to == this.to && anchor > this.to)
27246
27257
  change.to = anchor;
27247
- if (change.from == change.to && !change.insert.length)
27258
+ if (change.from == change.to && !change.insert.length) {
27259
+ let newSel = EditorSelection.single(this.toEditorPos(e2.selectionStart), this.toEditorPos(e2.selectionEnd));
27260
+ if (!newSel.main.eq(main))
27261
+ view.dispatch({ selection: newSel, userEvent: "select" });
27248
27262
  return;
27263
+ }
27264
+ if ((browser.mac || browser.android) && change.from == head - 1 && /^\. ?$/.test(e2.text) && view.contentDOM.getAttribute("autocorrect") == "off")
27265
+ change = { from, to, insert: Text.of([e2.text.replace(".", " ")]) };
27249
27266
  this.pendingContextChange = change;
27250
27267
  if (!view.state.readOnly) {
27251
27268
  let newLen = this.to - this.from + (change.to - change.from + change.insert.length);
@@ -51171,7 +51188,7 @@ const index = {
51171
51188
  id: `${pluginId}.plugin.name`,
51172
51189
  defaultMessage: displayName
51173
51190
  },
51174
- Component: () => import("./index-Db2zwbpe.mjs"),
51191
+ Component: () => import("./index-D1DAMkhj.mjs"),
51175
51192
  permissions: pluginPermissions.access
51176
51193
  });
51177
51194
  app.createSettingSection(
@@ -51190,7 +51207,7 @@ const index = {
51190
51207
  },
51191
51208
  id: "comments",
51192
51209
  to: `/settings/${pluginId}`,
51193
- Component: () => import("./index-BgN4aUMA.mjs"),
51210
+ Component: () => import("./index-BC5Odn17.mjs"),
51194
51211
  permissions: pluginPermissions.settings
51195
51212
  }
51196
51213
  ]
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const jsxRuntime = require("react/jsx-runtime");
3
- const index = require("./index-B-ygLKrb.js");
3
+ const index = require("./index-Ccb93U47.js");
4
4
  const reactQuery = require("@tanstack/react-query");
5
5
  const React = require("react");
6
6
  const admin = require("@strapi/strapi/admin");
@@ -11833,7 +11833,7 @@ function isTopLayer(element) {
11833
11833
  function isContainingBlock(elementOrCss) {
11834
11834
  const webkit2 = isWebKit();
11835
11835
  const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
11836
- return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit2 && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit2 && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
11836
+ return ["transform", "translate", "scale", "rotate", "perspective"].some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit2 && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit2 && (css.filter ? css.filter !== "none" : false) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
11837
11837
  }
11838
11838
  function getContainingBlock(element) {
11839
11839
  let currentNode = getParentNode(element);
@@ -12339,6 +12339,9 @@ const platform = {
12339
12339
  isElement,
12340
12340
  isRTL
12341
12341
  };
12342
+ function rectsAreEqual(a2, b2) {
12343
+ return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
12344
+ }
12342
12345
  function observeMove(element, onMove) {
12343
12346
  let io = null;
12344
12347
  let timeoutId;
@@ -12357,12 +12360,13 @@ function observeMove(element, onMove) {
12357
12360
  threshold = 1;
12358
12361
  }
12359
12362
  cleanup();
12363
+ const elementRectForRootMargin = element.getBoundingClientRect();
12360
12364
  const {
12361
12365
  left,
12362
12366
  top: top2,
12363
12367
  width,
12364
12368
  height
12365
- } = element.getBoundingClientRect();
12369
+ } = elementRectForRootMargin;
12366
12370
  if (!skip) {
12367
12371
  onMove();
12368
12372
  }
@@ -12393,6 +12397,9 @@ function observeMove(element, onMove) {
12393
12397
  refresh(false, ratio);
12394
12398
  }
12395
12399
  }
12400
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
12401
+ refresh();
12402
+ }
12396
12403
  isFirstUpdate = false;
12397
12404
  }
12398
12405
  try {
@@ -12456,7 +12463,7 @@ function autoUpdate(reference, floating, update, options) {
12456
12463
  }
12457
12464
  function frameLoop() {
12458
12465
  const nextRefRect = getBoundingClientRect(reference);
12459
- if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
12466
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
12460
12467
  update();
12461
12468
  }
12462
12469
  prevRefRect = nextRefRect;
@@ -20443,7 +20450,7 @@ function findMinIndex(value, array) {
20443
20450
  }
20444
20451
  function countColumn(string2, tabSize, to = string2.length) {
20445
20452
  let n2 = 0;
20446
- for (let i = 0; i < to; ) {
20453
+ for (let i = 0; i < to && i < string2.length; ) {
20447
20454
  if (string2.charCodeAt(i) == 9) {
20448
20455
  n2 += tabSize - n2 % tabSize;
20449
20456
  i++;
@@ -24291,16 +24298,16 @@ function applyDOMChange(view, domChange) {
24291
24298
  return false;
24292
24299
  if (!change && domChange.typeOver && !sel.empty && newSel && newSel.main.empty) {
24293
24300
  change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };
24301
+ } else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 && /^\. ?$/.test(change.insert.toString()) && view.contentDOM.getAttribute("autocorrect") == "off") {
24302
+ if (newSel && change.insert.length == 2)
24303
+ newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
24304
+ change = { from: change.from, to: change.to, insert: Text.of([change.insert.toString().replace(".", " ")]) };
24294
24305
  } else if (change && change.from >= sel.from && change.to <= sel.to && (change.from != sel.from || change.to != sel.to) && sel.to - sel.from - (change.to - change.from) <= 4) {
24295
24306
  change = {
24296
24307
  from: sel.from,
24297
24308
  to: sel.to,
24298
24309
  insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))
24299
24310
  };
24300
- } else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 && /^\. ?$/.test(change.insert.toString()) && view.contentDOM.getAttribute("autocorrect") == "off") {
24301
- if (newSel && change.insert.length == 2)
24302
- newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
24303
- change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
24304
24311
  } else if (browser.chrome && change && change.from == change.to && change.from == sel.head && change.insert.toString() == "\n " && view.lineWrapping) {
24305
24312
  if (newSel)
24306
24313
  newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
@@ -25936,6 +25943,10 @@ function visiblePixelRange(dom, paddingTop) {
25936
25943
  bottom: Math.max(top2, bottom) - (rect.top + paddingTop)
25937
25944
  };
25938
25945
  }
25946
+ function inWindow(elt) {
25947
+ let rect = elt.getBoundingClientRect(), win = elt.ownerDocument.defaultView || window;
25948
+ return rect.left < win.innerWidth && rect.right > 0 && rect.top < win.innerHeight && rect.bottom > 0;
25949
+ }
25939
25950
  function fullPixelRange(dom, paddingTop) {
25940
25951
  let rect = dom.getBoundingClientRect();
25941
25952
  return {
@@ -26136,7 +26147,7 @@ class ViewState {
26136
26147
  if (inView)
26137
26148
  measureContent = true;
26138
26149
  }
26139
- if (!this.inView && !this.scrollTarget)
26150
+ if (!this.inView && !this.scrollTarget && !inWindow(view.dom))
26140
26151
  return 0;
26141
26152
  let contentWidth = domRect.width;
26142
26153
  if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
@@ -27253,7 +27264,7 @@ class EditContextManager {
27253
27264
  selectionEnd: this.toContextPos(view.state.selection.main.head)
27254
27265
  });
27255
27266
  this.handlers.textupdate = (e2) => {
27256
- let { anchor } = view.state.selection.main;
27267
+ let main = view.state.selection.main, { anchor, head } = main;
27257
27268
  let from = this.toEditorPos(e2.updateRangeStart), to = this.toEditorPos(e2.updateRangeEnd);
27258
27269
  if (view.inputState.composing >= 0 && !this.composing)
27259
27270
  this.composing = { contextBase: e2.updateRangeStart, editorBase: from, drifted: false };
@@ -27262,8 +27273,14 @@ class EditContextManager {
27262
27273
  change.from = anchor;
27263
27274
  else if (change.to == this.to && anchor > this.to)
27264
27275
  change.to = anchor;
27265
- if (change.from == change.to && !change.insert.length)
27276
+ if (change.from == change.to && !change.insert.length) {
27277
+ let newSel = EditorSelection.single(this.toEditorPos(e2.selectionStart), this.toEditorPos(e2.selectionEnd));
27278
+ if (!newSel.main.eq(main))
27279
+ view.dispatch({ selection: newSel, userEvent: "select" });
27266
27280
  return;
27281
+ }
27282
+ if ((browser.mac || browser.android) && change.from == head - 1 && /^\. ?$/.test(e2.text) && view.contentDOM.getAttribute("autocorrect") == "off")
27283
+ change = { from, to, insert: Text.of([e2.text.replace(".", " ")]) };
27267
27284
  this.pendingContextChange = change;
27268
27285
  if (!view.state.readOnly) {
27269
27286
  let newLen = this.to - this.from + (change.to - change.from + change.insert.length);
@@ -51189,7 +51206,7 @@ const index = {
51189
51206
  id: `${pluginId}.plugin.name`,
51190
51207
  defaultMessage: displayName
51191
51208
  },
51192
- Component: () => Promise.resolve().then(() => require("./index-CWfr5ejx.js")),
51209
+ Component: () => Promise.resolve().then(() => require("./index-k7z0V0lj.js")),
51193
51210
  permissions: pluginPermissions.access
51194
51211
  });
51195
51212
  app.createSettingSection(
@@ -51208,7 +51225,7 @@ const index = {
51208
51225
  },
51209
51226
  id: "comments",
51210
51227
  to: `/settings/${pluginId}`,
51211
- Component: () => Promise.resolve().then(() => require("./index-D8uskGzQ.js")),
51228
+ Component: () => Promise.resolve().then(() => require("./index-R1krliyC.js")),
51212
51229
  permissions: pluginPermissions.settings
51213
51230
  }
51214
51231
  ]
@@ -1,9 +1,9 @@
1
1
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import { useNotification, Form, Page, Layouts, useTracking, useQueryParams, SearchInput, Pagination } from "@strapi/strapi/admin";
3
3
  import { useNavigate, useParams, Routes, Route, Navigate } from "react-router-dom";
4
- import { S as SubNav, a as SubNavHeader, b as SubNavSections, c as SubNavSection, d as SubNavLink, p as pluginId, B as Box, T as Typography, D as Divider, F as Flex, C as CheckboxImpl, e as Button, I as IconButton, f as ForwardRef$4x, g as ForwardRef$3$, h as Badge, i as IconButtonGroup$1, P as Portal$1, j as FocusTrap, k as ForwardRef$45, l as ForwardRef$3B, m as Field, n as SingleSelect, o as SingleSelectOption, q as ForwardRef$4X, r as ForwardRef$2v, s as ForwardRef$f, t as ForwardRef$1R, u as Popover, v as ForwardRef$v, w as ForwardRef$4R, x as ForwardRef$1L, y as ForwardRef$4d, z as ForwardRef$2l, A as ForwardRef$11, M as Modal, E as Table, G as Thead, H as Tr, J as Th, K as Tbody, L as ForwardRef$1r, N as ForwardRef$j, O as ForwardRef$3x, Q as ForwardRef$1d, R as ForwardRef$R, U as Avatar, V as Loader, W as Link, X as ForwardRef$51, Y as Grid, Z as Td, _ as SimpleMenu, $ as MenuItem } from "./index-Bx2boY6h.mjs";
4
+ import { S as SubNav, a as SubNavHeader, b as SubNavSections, c as SubNavSection, d as SubNavLink, p as pluginId, B as Box, T as Typography, D as Divider, F as Flex, C as CheckboxImpl, e as Button, I as IconButton, f as ForwardRef$4x, g as ForwardRef$3$, h as Badge, i as IconButtonGroup$1, P as Portal$1, j as FocusTrap, k as ForwardRef$45, l as ForwardRef$3B, m as Field, n as SingleSelect, o as SingleSelectOption, q as ForwardRef$4X, r as ForwardRef$2v, s as ForwardRef$f, t as ForwardRef$1R, u as Popover, v as ForwardRef$v, w as ForwardRef$4R, x as ForwardRef$1L, y as ForwardRef$4d, z as ForwardRef$2l, A as ForwardRef$11, M as Modal, E as Table, G as Thead, H as Tr, J as Th, K as Tbody, L as ForwardRef$1r, N as ForwardRef$j, O as ForwardRef$3x, Q as ForwardRef$1d, R as ForwardRef$R, U as Avatar, V as Loader, W as Link, X as ForwardRef$51, Y as Grid, Z as Td, _ as SimpleMenu, $ as MenuItem } from "./index-BIorFYba.mjs";
5
5
  import { useQuery, useQueryClient, useMutation } from "@tanstack/react-query";
6
- import { u as useAPI, l as lodashExports, C as COMMENT_STATUS, R as REPORT_STATUS, g as getMessage, a as usePermissions, U as UserContext, b as getDefaultExportFromCjs, c as useIntl, d as REPORT_REASON, e as ConfirmationDialog, f as CommonProviders } from "./index-CIqMAf50.mjs";
6
+ import { u as useAPI, l as lodashExports, C as COMMENT_STATUS, R as REPORT_STATUS, g as getMessage, a as usePermissions, U as UserContext, b as getDefaultExportFromCjs, c as useIntl, d as REPORT_REASON, e as ConfirmationDialog, f as CommonProviders } from "./index-_exHAK6u.mjs";
7
7
  import { create } from "zustand/react";
8
8
  import * as React from "react";
9
9
  import { useCallback, useMemo, useContext, useState, useRef, Fragment as Fragment$1 } from "react";
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
- const index$2 = require("./index-B-ygLKrb.js");
4
+ const index$2 = require("./index-Ccb93U47.js");
5
5
  const admin = require("@strapi/strapi/admin");
6
6
  const reactQuery = require("@tanstack/react-query");
7
- const index$1 = require("./index-DFAPx7Bl.js");
7
+ const index$1 = require("./index-COoWcAcA.js");
8
8
  const React = require("react");
9
9
  const styled = require("styled-components");
10
10
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { a8 as darkTheme, a9 as lightTheme, aa as DesignSystemProvider, ab as pluginPermissions, ac as __assign, ad as __rest, p as pluginId, ae as Dialog, F as Flex, af as ForwardRef$3, T as Typography, e as Button } from "./index-Bx2boY6h.mjs";
2
+ import { a8 as darkTheme, a9 as lightTheme, aa as DesignSystemProvider, ab as pluginPermissions, ac as __assign, ad as __rest, p as pluginId, ae as Dialog, F as Flex, af as ForwardRef$3, T as Typography, e as Button } from "./index-BIorFYba.mjs";
3
3
  import { useQuery, QueryClient, QueryClientProvider } from "@tanstack/react-query";
4
4
  import * as React from "react";
5
5
  import { useMemo, createContext, useState } from "react";
@@ -3831,10 +3831,10 @@ lodash.exports;
3831
3831
  return result2;
3832
3832
  };
3833
3833
  }
3834
- var bind3 = baseRest(function(func, thisArg, partials) {
3834
+ var bind2 = baseRest(function(func, thisArg, partials) {
3835
3835
  var bitmask = WRAP_BIND_FLAG;
3836
3836
  if (partials.length) {
3837
- var holders = replaceHolders(partials, getHolder(bind3));
3837
+ var holders = replaceHolders(partials, getHolder(bind2));
3838
3838
  bitmask |= WRAP_PARTIAL_FLAG;
3839
3839
  }
3840
3840
  return createWrap(func, bitmask, thisArg, partials, holders);
@@ -4841,7 +4841,7 @@ lodash.exports;
4841
4841
  var bindAll = flatRest(function(object, methodNames) {
4842
4842
  arrayEach(methodNames, function(key) {
4843
4843
  key = toKey(key);
4844
- baseAssignValue(object, key, bind3(object[key], object));
4844
+ baseAssignValue(object, key, bind2(object[key], object));
4845
4845
  });
4846
4846
  return object;
4847
4847
  });
@@ -5038,7 +5038,7 @@ lodash.exports;
5038
5038
  lodash2.assignWith = assignWith;
5039
5039
  lodash2.at = at;
5040
5040
  lodash2.before = before;
5041
- lodash2.bind = bind3;
5041
+ lodash2.bind = bind2;
5042
5042
  lodash2.bindAll = bindAll;
5043
5043
  lodash2.bindKey = bindKey;
5044
5044
  lodash2.castArray = castArray;
@@ -5755,7 +5755,7 @@ var objectInspect = function inspect_(obj, options, depth, seen) {
5755
5755
  var ys = arrObjKeys(obj, inspect2);
5756
5756
  var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
5757
5757
  var protoTag = obj instanceof Object ? "" : "null prototype";
5758
- var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr$1(obj), 8, -1) : protoTag ? "Object" : "";
5758
+ var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
5759
5759
  var constructorTag = isPlainObject || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
5760
5760
  var tag = constructorTag + (stringTag || protoTag ? "[" + $join.call($concat$1.call([], stringTag || [], protoTag || []), ": ") + "] " : "");
5761
5761
  if (ys.length === 0) {
@@ -5777,25 +5777,25 @@ function quote(s) {
5777
5777
  return $replace$1.call(String(s), /"/g, "&quot;");
5778
5778
  }
5779
5779
  function isArray$3(obj) {
5780
- return toStr$1(obj) === "[object Array]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5780
+ return toStr(obj) === "[object Array]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5781
5781
  }
5782
5782
  function isDate(obj) {
5783
- return toStr$1(obj) === "[object Date]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5783
+ return toStr(obj) === "[object Date]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5784
5784
  }
5785
5785
  function isRegExp$1(obj) {
5786
- return toStr$1(obj) === "[object RegExp]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5786
+ return toStr(obj) === "[object RegExp]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5787
5787
  }
5788
5788
  function isError(obj) {
5789
- return toStr$1(obj) === "[object Error]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5789
+ return toStr(obj) === "[object Error]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5790
5790
  }
5791
5791
  function isString(obj) {
5792
- return toStr$1(obj) === "[object String]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5792
+ return toStr(obj) === "[object String]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5793
5793
  }
5794
5794
  function isNumber(obj) {
5795
- return toStr$1(obj) === "[object Number]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5795
+ return toStr(obj) === "[object Number]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5796
5796
  }
5797
5797
  function isBoolean(obj) {
5798
- return toStr$1(obj) === "[object Boolean]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5798
+ return toStr(obj) === "[object Boolean]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
5799
5799
  }
5800
5800
  function isSymbol(obj) {
5801
5801
  if (hasShammedSymbols) {
@@ -5831,7 +5831,7 @@ var hasOwn$1 = Object.prototype.hasOwnProperty || function(key) {
5831
5831
  function has$3(obj, key) {
5832
5832
  return hasOwn$1.call(obj, key);
5833
5833
  }
5834
- function toStr$1(obj) {
5834
+ function toStr(obj) {
5835
5835
  return objectToString.call(obj);
5836
5836
  }
5837
5837
  function nameOf(f) {
@@ -6140,7 +6140,7 @@ var syntax = SyntaxError;
6140
6140
  var uri = URIError;
6141
6141
  var abs$1 = Math.abs;
6142
6142
  var floor$1 = Math.floor;
6143
- var max$2 = Math.max;
6143
+ var max$1 = Math.max;
6144
6144
  var min$1 = Math.min;
6145
6145
  var pow$1 = Math.pow;
6146
6146
  var round$1 = Math.round;
@@ -6269,78 +6269,99 @@ function requireObject_getPrototypeOf() {
6269
6269
  Object_getPrototypeOf = $Object2.getPrototypeOf || null;
6270
6270
  return Object_getPrototypeOf;
6271
6271
  }
6272
- var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
6273
- var toStr = Object.prototype.toString;
6274
- var max$1 = Math.max;
6275
- var funcType = "[object Function]";
6276
- var concatty = function concatty2(a, b) {
6277
- var arr = [];
6278
- for (var i = 0; i < a.length; i += 1) {
6279
- arr[i] = a[i];
6280
- }
6281
- for (var j = 0; j < b.length; j += 1) {
6282
- arr[j + a.length] = b[j];
6283
- }
6284
- return arr;
6285
- };
6286
- var slicy = function slicy2(arrLike, offset) {
6287
- var arr = [];
6288
- for (var i = offset, j = 0; i < arrLike.length; i += 1, j += 1) {
6289
- arr[j] = arrLike[i];
6290
- }
6291
- return arr;
6292
- };
6293
- var joiny = function(arr, joiner) {
6294
- var str = "";
6295
- for (var i = 0; i < arr.length; i += 1) {
6296
- str += arr[i];
6297
- if (i + 1 < arr.length) {
6298
- str += joiner;
6272
+ var implementation;
6273
+ var hasRequiredImplementation;
6274
+ function requireImplementation() {
6275
+ if (hasRequiredImplementation) return implementation;
6276
+ hasRequiredImplementation = 1;
6277
+ var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
6278
+ var toStr2 = Object.prototype.toString;
6279
+ var max2 = Math.max;
6280
+ var funcType = "[object Function]";
6281
+ var concatty = function concatty2(a, b) {
6282
+ var arr = [];
6283
+ for (var i = 0; i < a.length; i += 1) {
6284
+ arr[i] = a[i];
6285
+ }
6286
+ for (var j = 0; j < b.length; j += 1) {
6287
+ arr[j + a.length] = b[j];
6288
+ }
6289
+ return arr;
6290
+ };
6291
+ var slicy = function slicy2(arrLike, offset) {
6292
+ var arr = [];
6293
+ for (var i = offset, j = 0; i < arrLike.length; i += 1, j += 1) {
6294
+ arr[j] = arrLike[i];
6299
6295
  }
6300
- }
6301
- return str;
6302
- };
6303
- var implementation$1 = function bind(that) {
6304
- var target = this;
6305
- if (typeof target !== "function" || toStr.apply(target) !== funcType) {
6306
- throw new TypeError(ERROR_MESSAGE + target);
6307
- }
6308
- var args = slicy(arguments, 1);
6309
- var bound;
6310
- var binder = function() {
6311
- if (this instanceof bound) {
6312
- var result = target.apply(
6313
- this,
6314
- concatty(args, arguments)
6315
- );
6316
- if (Object(result) === result) {
6317
- return result;
6296
+ return arr;
6297
+ };
6298
+ var joiny = function(arr, joiner) {
6299
+ var str = "";
6300
+ for (var i = 0; i < arr.length; i += 1) {
6301
+ str += arr[i];
6302
+ if (i + 1 < arr.length) {
6303
+ str += joiner;
6318
6304
  }
6319
- return this;
6320
6305
  }
6321
- return target.apply(
6322
- that,
6323
- concatty(args, arguments)
6324
- );
6306
+ return str;
6325
6307
  };
6326
- var boundLength = max$1(0, target.length - args.length);
6327
- var boundArgs = [];
6328
- for (var i = 0; i < boundLength; i++) {
6329
- boundArgs[i] = "$" + i;
6330
- }
6331
- bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
6332
- if (target.prototype) {
6333
- var Empty = function Empty2() {
6308
+ implementation = function bind2(that) {
6309
+ var target = this;
6310
+ if (typeof target !== "function" || toStr2.apply(target) !== funcType) {
6311
+ throw new TypeError(ERROR_MESSAGE + target);
6312
+ }
6313
+ var args = slicy(arguments, 1);
6314
+ var bound;
6315
+ var binder = function() {
6316
+ if (this instanceof bound) {
6317
+ var result = target.apply(
6318
+ this,
6319
+ concatty(args, arguments)
6320
+ );
6321
+ if (Object(result) === result) {
6322
+ return result;
6323
+ }
6324
+ return this;
6325
+ }
6326
+ return target.apply(
6327
+ that,
6328
+ concatty(args, arguments)
6329
+ );
6334
6330
  };
6335
- Empty.prototype = target.prototype;
6336
- bound.prototype = new Empty();
6337
- Empty.prototype = null;
6338
- }
6339
- return bound;
6340
- };
6341
- var implementation = implementation$1;
6342
- var functionBind = Function.prototype.bind || implementation;
6343
- var functionCall = Function.prototype.call;
6331
+ var boundLength = max2(0, target.length - args.length);
6332
+ var boundArgs = [];
6333
+ for (var i = 0; i < boundLength; i++) {
6334
+ boundArgs[i] = "$" + i;
6335
+ }
6336
+ bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
6337
+ if (target.prototype) {
6338
+ var Empty = function Empty2() {
6339
+ };
6340
+ Empty.prototype = target.prototype;
6341
+ bound.prototype = new Empty();
6342
+ Empty.prototype = null;
6343
+ }
6344
+ return bound;
6345
+ };
6346
+ return implementation;
6347
+ }
6348
+ var functionBind;
6349
+ var hasRequiredFunctionBind;
6350
+ function requireFunctionBind() {
6351
+ if (hasRequiredFunctionBind) return functionBind;
6352
+ hasRequiredFunctionBind = 1;
6353
+ var implementation2 = requireImplementation();
6354
+ functionBind = Function.prototype.bind || implementation2;
6355
+ return functionBind;
6356
+ }
6357
+ var functionCall;
6358
+ var hasRequiredFunctionCall;
6359
+ function requireFunctionCall() {
6360
+ if (hasRequiredFunctionCall) return functionCall;
6361
+ hasRequiredFunctionCall = 1;
6362
+ functionCall = Function.prototype.call;
6363
+ return functionCall;
6364
+ }
6344
6365
  var functionApply;
6345
6366
  var hasRequiredFunctionApply;
6346
6367
  function requireFunctionApply() {
@@ -6350,14 +6371,14 @@ function requireFunctionApply() {
6350
6371
  return functionApply;
6351
6372
  }
6352
6373
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
6353
- var bind$2 = functionBind;
6374
+ var bind$2 = requireFunctionBind();
6354
6375
  var $apply$1 = requireFunctionApply();
6355
- var $call$2 = functionCall;
6376
+ var $call$2 = requireFunctionCall();
6356
6377
  var $reflectApply = reflectApply;
6357
6378
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
6358
- var bind$1 = functionBind;
6379
+ var bind$1 = requireFunctionBind();
6359
6380
  var $TypeError$4 = type;
6360
- var $call$1 = functionCall;
6381
+ var $call$1 = requireFunctionCall();
6361
6382
  var $actualApply = actualApply;
6362
6383
  var callBindApplyHelpers = function callBindBasic(args) {
6363
6384
  if (args.length < 1 || typeof args[0] !== "function") {
@@ -6423,8 +6444,8 @@ function requireHasown() {
6423
6444
  hasRequiredHasown = 1;
6424
6445
  var call = Function.prototype.call;
6425
6446
  var $hasOwn = Object.prototype.hasOwnProperty;
6426
- var bind3 = functionBind;
6427
- hasown = bind3.call(call, $hasOwn);
6447
+ var bind2 = requireFunctionBind();
6448
+ hasown = bind2.call(call, $hasOwn);
6428
6449
  return hasown;
6429
6450
  }
6430
6451
  var undefined$1;
@@ -6438,7 +6459,7 @@ var $TypeError$3 = type;
6438
6459
  var $URIError = uri;
6439
6460
  var abs = abs$1;
6440
6461
  var floor = floor$1;
6441
- var max = max$2;
6462
+ var max = max$1;
6442
6463
  var min = min$1;
6443
6464
  var pow = pow$1;
6444
6465
  var round = round$1;
@@ -6472,7 +6493,7 @@ var getProto = requireGetProto();
6472
6493
  var $ObjectGPO = requireObject_getPrototypeOf();
6473
6494
  var $ReflectGPO = requireReflect_getPrototypeOf();
6474
6495
  var $apply = requireFunctionApply();
6475
- var $call = functionCall;
6496
+ var $call = requireFunctionCall();
6476
6497
  var needsEval = {};
6477
6498
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
6478
6499
  var INTRINSICS = {
@@ -6642,13 +6663,13 @@ var LEGACY_ALIASES = {
6642
6663
  "%WeakMapPrototype%": ["WeakMap", "prototype"],
6643
6664
  "%WeakSetPrototype%": ["WeakSet", "prototype"]
6644
6665
  };
6645
- var bind2 = functionBind;
6666
+ var bind = requireFunctionBind();
6646
6667
  var hasOwn = requireHasown();
6647
- var $concat = bind2.call($call, Array.prototype.concat);
6648
- var $spliceApply = bind2.call($apply, Array.prototype.splice);
6649
- var $replace = bind2.call($call, String.prototype.replace);
6650
- var $strSlice = bind2.call($call, String.prototype.slice);
6651
- var $exec = bind2.call($call, RegExp.prototype.exec);
6668
+ var $concat = bind.call($call, Array.prototype.concat);
6669
+ var $spliceApply = bind.call($apply, Array.prototype.splice);
6670
+ var $replace = bind.call($call, String.prototype.replace);
6671
+ var $strSlice = bind.call($call, String.prototype.slice);
6672
+ var $exec = bind.call($call, RegExp.prototype.exec);
6652
6673
  var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
6653
6674
  var reEscapeChar = /\\(\\)?/g;
6654
6675
  var stringToPath = function stringToPath2(string) {
@@ -3,9 +3,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const admin = require("@strapi/strapi/admin");
5
5
  const reactRouterDom = require("react-router-dom");
6
- const index = require("./index-B-ygLKrb.js");
6
+ const index = require("./index-Ccb93U47.js");
7
7
  const reactQuery = require("@tanstack/react-query");
8
- const index$1 = require("./index-DFAPx7Bl.js");
8
+ const index$1 = require("./index-COoWcAcA.js");
9
9
  const react = require("zustand/react");
10
10
  const React = require("react");
11
11
  const styled = require("styled-components");
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
- const index = require("../_chunks/index-B-ygLKrb.js");
2
+ const index = require("../_chunks/index-Ccb93U47.js");
3
3
  require("react");
4
4
  module.exports = index.index;
@@ -1,4 +1,4 @@
1
- import { ag } from "../_chunks/index-Bx2boY6h.mjs";
1
+ import { ag } from "../_chunks/index-BIorFYba.mjs";
2
2
  import "react";
3
3
  export {
4
4
  ag as default
@@ -8451,7 +8451,7 @@ const newCommentValidator = (enabledCollections, relation, payload) => {
8451
8451
  };
8452
8452
  const updateCommentValidator = (enabledCollections, payload) => {
8453
8453
  return validate(
8454
- getCommentSchema(enabledCollections).pick({ content: true, relation: true }).merge(getStringToNumberValidator({ commentId: AVAILABLE_OPERATORS.single })).safeParse(payload)
8454
+ getCommentSchema(enabledCollections).pick({ content: true, relation: true, author: true }).merge(getStringToNumberValidator({ commentId: AVAILABLE_OPERATORS.single })).safeParse(payload)
8455
8455
  );
8456
8456
  };
8457
8457
  const getRelationSchema = (enabledCollections) => zod.z.object({
@@ -9027,8 +9027,9 @@ const controllers$1 = ({ strapi: strapi2 }) => ({
9027
9027
  if (isRight(configResult)) {
9028
9028
  const config2 = unwrapEither(configResult);
9029
9029
  const result = updateCommentValidator(config2.enabledCollections, {
9030
- ...ctx.query,
9031
- ...ctx.params
9030
+ ...ctx.params,
9031
+ content: ctx.request.body.content,
9032
+ author: ctx.request.body.author
9032
9033
  });
9033
9034
  if (isRight(result)) {
9034
9035
  return await this.getService("client").update(
@@ -9983,8 +9984,7 @@ const clientService = ({ strapi: strapi2 }) => {
9983
9984
  throw unwrapEither(threadData);
9984
9985
  }
9985
9986
  const linkToThread = unwrapEither(threadData);
9986
- const isValidContext = this.getCommonService().isValidUserContext(user);
9987
- if (!isValidContext) {
9987
+ if (!author && !this.getCommonService().isValidUserContext(user)) {
9988
9988
  throw resolveUserContextError(user);
9989
9989
  }
9990
9990
  const clearContent = await this.getCommonService().checkBadWords(content);
@@ -10021,19 +10021,22 @@ const clientService = ({ strapi: strapi2 }) => {
10021
10021
  return sanitizedEntity;
10022
10022
  },
10023
10023
  // Update a comment
10024
- async update({ commentId, content }, user) {
10025
- const validContext = this.getCommonService().isValidUserContext(user);
10026
- if (!validContext) {
10024
+ async update({ commentId, content, author, relation }, user) {
10025
+ if (!author && !this.getCommonService().isValidUserContext(user)) {
10027
10026
  throw resolveUserContextError(user);
10028
10027
  }
10028
+ const authorId = user?.id || author?.id;
10029
10029
  if (await this.getCommonService().checkBadWords(content)) {
10030
10030
  const blockedAuthorProps = await this.getCommonService().getConfig(CONFIG_PARAMS$1.AUTHOR_BLOCKED_PROPS, []);
10031
- const entity = await getCommentRepository(strapi2).update({
10032
- where: { id: commentId },
10033
- data: { content },
10034
- populate: { threadOf: true, authorUser: true }
10035
- });
10036
- return this.getCommonService().sanitizeCommentEntity(entity, blockedAuthorProps);
10031
+ const existingComment = await this.getCommonService().findOne({ id: commentId, related: relation });
10032
+ if (existingComment && existingComment.author?.id?.toString() === authorId?.toString()) {
10033
+ const entity = await getCommentRepository(strapi2).update({
10034
+ where: { id: commentId },
10035
+ data: { content },
10036
+ populate: { threadOf: true, authorUser: true }
10037
+ });
10038
+ return this.getCommonService().sanitizeCommentEntity(entity, blockedAuthorProps);
10039
+ }
10037
10040
  }
10038
10041
  },
10039
10042
  // Report abuse in comment
@@ -10084,7 +10087,7 @@ const clientService = ({ strapi: strapi2 }) => {
10084
10087
  }
10085
10088
  },
10086
10089
  async markAsRemoved({ commentId, relation, authorId }, user) {
10087
- if (!this.getCommonService().isValidUserContext(user)) {
10090
+ if (!authorId && !this.getCommonService().isValidUserContext(user)) {
10088
10091
  throw resolveUserContextError(user);
10089
10092
  }
10090
10093
  const author = user?.id || authorId;
@@ -10347,12 +10350,10 @@ const commonService = ({ strapi: strapi2 }) => ({
10347
10350
  authorUser: true
10348
10351
  }
10349
10352
  });
10350
- console.log("findOne::entity", entity);
10351
10353
  if (!entity) {
10352
10354
  throw new PluginError$1(400, "Comment does not exist. Check your payload please.");
10353
10355
  }
10354
10356
  const doNotPopulateAuthor = await this.getConfig(CONFIG_PARAMS.AUTHOR_BLOCKED_PROPS, []);
10355
- console.log("doNotPopulateAuthor", doNotPopulateAuthor);
10356
10357
  const item = this.sanitizeCommentEntity(entity, doNotPopulateAuthor);
10357
10358
  return filterOurResolvedReports(item);
10358
10359
  },
@@ -8450,7 +8450,7 @@ const newCommentValidator = (enabledCollections, relation, payload) => {
8450
8450
  };
8451
8451
  const updateCommentValidator = (enabledCollections, payload) => {
8452
8452
  return validate(
8453
- getCommentSchema(enabledCollections).pick({ content: true, relation: true }).merge(getStringToNumberValidator({ commentId: AVAILABLE_OPERATORS.single })).safeParse(payload)
8453
+ getCommentSchema(enabledCollections).pick({ content: true, relation: true, author: true }).merge(getStringToNumberValidator({ commentId: AVAILABLE_OPERATORS.single })).safeParse(payload)
8454
8454
  );
8455
8455
  };
8456
8456
  const getRelationSchema = (enabledCollections) => z.object({
@@ -9026,8 +9026,9 @@ const controllers$1 = ({ strapi: strapi2 }) => ({
9026
9026
  if (isRight(configResult)) {
9027
9027
  const config2 = unwrapEither(configResult);
9028
9028
  const result = updateCommentValidator(config2.enabledCollections, {
9029
- ...ctx.query,
9030
- ...ctx.params
9029
+ ...ctx.params,
9030
+ content: ctx.request.body.content,
9031
+ author: ctx.request.body.author
9031
9032
  });
9032
9033
  if (isRight(result)) {
9033
9034
  return await this.getService("client").update(
@@ -9982,8 +9983,7 @@ const clientService = ({ strapi: strapi2 }) => {
9982
9983
  throw unwrapEither(threadData);
9983
9984
  }
9984
9985
  const linkToThread = unwrapEither(threadData);
9985
- const isValidContext = this.getCommonService().isValidUserContext(user);
9986
- if (!isValidContext) {
9986
+ if (!author && !this.getCommonService().isValidUserContext(user)) {
9987
9987
  throw resolveUserContextError(user);
9988
9988
  }
9989
9989
  const clearContent = await this.getCommonService().checkBadWords(content);
@@ -10020,19 +10020,22 @@ const clientService = ({ strapi: strapi2 }) => {
10020
10020
  return sanitizedEntity;
10021
10021
  },
10022
10022
  // Update a comment
10023
- async update({ commentId, content }, user) {
10024
- const validContext = this.getCommonService().isValidUserContext(user);
10025
- if (!validContext) {
10023
+ async update({ commentId, content, author, relation }, user) {
10024
+ if (!author && !this.getCommonService().isValidUserContext(user)) {
10026
10025
  throw resolveUserContextError(user);
10027
10026
  }
10027
+ const authorId = user?.id || author?.id;
10028
10028
  if (await this.getCommonService().checkBadWords(content)) {
10029
10029
  const blockedAuthorProps = await this.getCommonService().getConfig(CONFIG_PARAMS$1.AUTHOR_BLOCKED_PROPS, []);
10030
- const entity = await getCommentRepository(strapi2).update({
10031
- where: { id: commentId },
10032
- data: { content },
10033
- populate: { threadOf: true, authorUser: true }
10034
- });
10035
- return this.getCommonService().sanitizeCommentEntity(entity, blockedAuthorProps);
10030
+ const existingComment = await this.getCommonService().findOne({ id: commentId, related: relation });
10031
+ if (existingComment && existingComment.author?.id?.toString() === authorId?.toString()) {
10032
+ const entity = await getCommentRepository(strapi2).update({
10033
+ where: { id: commentId },
10034
+ data: { content },
10035
+ populate: { threadOf: true, authorUser: true }
10036
+ });
10037
+ return this.getCommonService().sanitizeCommentEntity(entity, blockedAuthorProps);
10038
+ }
10036
10039
  }
10037
10040
  },
10038
10041
  // Report abuse in comment
@@ -10083,7 +10086,7 @@ const clientService = ({ strapi: strapi2 }) => {
10083
10086
  }
10084
10087
  },
10085
10088
  async markAsRemoved({ commentId, relation, authorId }, user) {
10086
- if (!this.getCommonService().isValidUserContext(user)) {
10089
+ if (!authorId && !this.getCommonService().isValidUserContext(user)) {
10087
10090
  throw resolveUserContextError(user);
10088
10091
  }
10089
10092
  const author = user?.id || authorId;
@@ -10346,12 +10349,10 @@ const commonService = ({ strapi: strapi2 }) => ({
10346
10349
  authorUser: true
10347
10350
  }
10348
10351
  });
10349
- console.log("findOne::entity", entity);
10350
10352
  if (!entity) {
10351
10353
  throw new PluginError$1(400, "Comment does not exist. Check your payload please.");
10352
10354
  }
10353
10355
  const doNotPopulateAuthor = await this.getConfig(CONFIG_PARAMS.AUTHOR_BLOCKED_PROPS, []);
10354
- console.log("doNotPopulateAuthor", doNotPopulateAuthor);
10355
10356
  const item = this.sanitizeCommentEntity(entity, doNotPopulateAuthor);
10356
10357
  return filterOurResolvedReports(item);
10357
10358
  },
@@ -724,7 +724,10 @@ declare const controllers: ({ strapi }: StrapiContext) => {
724
724
  total?: number;
725
725
  };
726
726
  }>;
727
- put(ctx: RequestContext): Promise<{
727
+ put(ctx: RequestContext<{
728
+ content: string;
729
+ author: unknown;
730
+ }>): Promise<{
728
731
  id?: number;
729
732
  documentId?: string;
730
733
  content?: string;
@@ -2505,7 +2505,10 @@ declare const controllers: {
2505
2505
  total?: number;
2506
2506
  };
2507
2507
  }>;
2508
- put(ctx: import("../@types").RequestContext): Promise<{
2508
+ put(ctx: import("../@types").RequestContext<{
2509
+ content: string;
2510
+ author: unknown;
2511
+ }>): Promise<{
2509
2512
  id?: number;
2510
2513
  documentId?: string;
2511
2514
  content?: string;
@@ -2575,7 +2575,10 @@ declare const _default: {
2575
2575
  total?: number;
2576
2576
  };
2577
2577
  }>;
2578
- put(ctx: import("./@types").RequestContext): Promise<{
2578
+ put(ctx: import("./@types").RequestContext<{
2579
+ content: string;
2580
+ author: unknown;
2581
+ }>): Promise<{
2579
2582
  id?: number;
2580
2583
  documentId?: string;
2581
2584
  content?: string;
@@ -7819,8 +7822,14 @@ declare const _default: {
7819
7822
  author?: any;
7820
7823
  };
7821
7824
  }>;
7822
- update({ commentId, content }: {
7825
+ update({ commentId, content, author, relation }: {
7823
7826
  content?: string;
7827
+ author?: {
7828
+ name?: string;
7829
+ id?: number;
7830
+ email?: string;
7831
+ avatar?: string;
7832
+ };
7824
7833
  relation?: `${string}::${string}.${string}`;
7825
7834
  commentId?: number;
7826
7835
  }, user?: import("./@types").AdminUser): Promise<{
@@ -1976,7 +1976,7 @@ export declare const clientService: ({ strapi }: StrapiContext) => {
1976
1976
  author?: any;
1977
1977
  };
1978
1978
  }>;
1979
- update({ commentId, content }: client.UpdateCommentValidatorSchema, user?: AdminUser): Promise<{
1979
+ update({ commentId, content, author, relation }: client.UpdateCommentValidatorSchema, user?: AdminUser): Promise<{
1980
1980
  id?: number;
1981
1981
  documentId?: string;
1982
1982
  content?: string;
@@ -4795,8 +4795,14 @@ declare const pluginServices: {
4795
4795
  author?: any;
4796
4796
  };
4797
4797
  }>;
4798
- update({ commentId, content }: {
4798
+ update({ commentId, content, author, relation }: {
4799
4799
  content?: string;
4800
+ author?: {
4801
+ name?: string;
4802
+ id?: number;
4803
+ email?: string;
4804
+ avatar?: string;
4805
+ };
4800
4806
  relation?: `${string}::${string}.${string}`;
4801
4807
  commentId?: number;
4802
4808
  }, user?: import("../@types").AdminUser): Promise<{
@@ -17,6 +17,12 @@ export declare const newCommentValidator: (enabledCollections: string[], relatio
17
17
  export type NewCommentValidatorSchema = ExtractRightEither<ReturnType<typeof newCommentValidator>>;
18
18
  export declare const updateCommentValidator: (enabledCollections: string[], payload: object) => import("../../../utils/Either").Left<import("../../../utils/PluginError").default> | import("../../../utils/Either").Right<{
19
19
  content?: string;
20
+ author?: {
21
+ name?: string;
22
+ id?: number;
23
+ email?: string;
24
+ avatar?: string;
25
+ };
20
26
  relation?: `${string}::${string}.${string}`;
21
27
  commentId?: number;
22
28
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-comments",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Strapi - Comments plugin",
5
5
  "strapi": {
6
6
  "name": "comments",
@@ -67,12 +67,12 @@
67
67
  "devDependencies": {
68
68
  "@jest/types": "29.5.x",
69
69
  "@sensinum/strapi-utils": "^1.0.4",
70
- "@strapi/plugin-cloud": "^5.6.0",
71
- "@strapi/plugin-graphql": "5.6.0",
72
- "@strapi/plugin-users-permissions": "^5.6.0",
70
+ "@strapi/plugin-cloud": "^5.7.0",
71
+ "@strapi/plugin-graphql": "5.7.0",
72
+ "@strapi/plugin-users-permissions": "^5.7.0",
73
73
  "@strapi/sdk-plugin": "^5.2.8",
74
- "@strapi/strapi": "^5.6.0",
75
- "@strapi/types": "^5.6.0",
74
+ "@strapi/strapi": "^5.7.0",
75
+ "@strapi/types": "^5.7.0",
76
76
  "@types/jest": "^29.5.12",
77
77
  "@types/koa": "^2.15.0",
78
78
  "@types/react": "^18.3.8",
@@ -90,7 +90,7 @@
90
90
  },
91
91
  "peerDependencies": {
92
92
  "@strapi/sdk-plugin": "^5.2.8",
93
- "@strapi/strapi": "^5.6.0",
93
+ "@strapi/strapi": "^5.7.0",
94
94
  "react": "^18.3.1",
95
95
  "react-dom": "^18.3.1",
96
96
  "react-router-dom": "^6.26.2",