@wordpress/editor 14.33.4 → 14.33.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/build/components/collab-sidebar/add-comment.js +10 -12
  2. package/build/components/collab-sidebar/add-comment.js.map +2 -2
  3. package/build/components/collab-sidebar/comment-menu-item.js +36 -6
  4. package/build/components/collab-sidebar/comment-menu-item.js.map +3 -3
  5. package/build/components/collab-sidebar/comments.js +316 -318
  6. package/build/components/collab-sidebar/comments.js.map +3 -3
  7. package/build/components/collab-sidebar/index.js +38 -25
  8. package/build/components/collab-sidebar/index.js.map +3 -3
  9. package/build/components/collab-sidebar/utils.js +1 -1
  10. package/build/components/collab-sidebar/utils.js.map +2 -2
  11. package/build/components/editor/index.js +2 -2
  12. package/build/components/editor/index.js.map +3 -3
  13. package/build/components/post-excerpt/panel.js +1 -6
  14. package/build/components/post-excerpt/panel.js.map +2 -2
  15. package/build/components/post-template/block-theme.js +4 -32
  16. package/build/components/post-template/block-theme.js.map +3 -3
  17. package/build/components/post-template/create-new-template-modal.js +1 -2
  18. package/build/components/post-template/create-new-template-modal.js.map +2 -2
  19. package/build/components/post-template/hooks.js +1 -3
  20. package/build/components/post-template/hooks.js.map +2 -2
  21. package/build/components/preferences-modal/index.js +1 -1
  22. package/build/components/preferences-modal/index.js.map +1 -1
  23. package/build/components/provider/index.js +2 -3
  24. package/build/components/provider/index.js.map +2 -2
  25. package/build/components/start-page-options/index.js +4 -5
  26. package/build/components/start-page-options/index.js.map +2 -2
  27. package/build/dataviews/store/private-actions.js +3 -9
  28. package/build/dataviews/store/private-actions.js.map +2 -2
  29. package/build/store/actions.js +2 -67
  30. package/build/store/actions.js.map +2 -2
  31. package/build-module/components/collab-sidebar/add-comment.js +10 -12
  32. package/build-module/components/collab-sidebar/add-comment.js.map +2 -2
  33. package/build-module/components/collab-sidebar/comment-menu-item.js +40 -7
  34. package/build-module/components/collab-sidebar/comment-menu-item.js.map +2 -2
  35. package/build-module/components/collab-sidebar/comments.js +316 -318
  36. package/build-module/components/collab-sidebar/comments.js.map +2 -2
  37. package/build-module/components/collab-sidebar/index.js +38 -25
  38. package/build-module/components/collab-sidebar/index.js.map +2 -2
  39. package/build-module/components/collab-sidebar/utils.js +1 -1
  40. package/build-module/components/collab-sidebar/utils.js.map +2 -2
  41. package/build-module/components/editor/index.js +2 -2
  42. package/build-module/components/editor/index.js.map +2 -2
  43. package/build-module/components/post-excerpt/panel.js +1 -6
  44. package/build-module/components/post-excerpt/panel.js.map +2 -2
  45. package/build-module/components/post-template/block-theme.js +4 -32
  46. package/build-module/components/post-template/block-theme.js.map +2 -2
  47. package/build-module/components/post-template/create-new-template-modal.js +1 -2
  48. package/build-module/components/post-template/create-new-template-modal.js.map +2 -2
  49. package/build-module/components/post-template/hooks.js +1 -3
  50. package/build-module/components/post-template/hooks.js.map +2 -2
  51. package/build-module/components/preferences-modal/index.js +1 -1
  52. package/build-module/components/preferences-modal/index.js.map +1 -1
  53. package/build-module/components/provider/index.js +2 -3
  54. package/build-module/components/provider/index.js.map +2 -2
  55. package/build-module/components/start-page-options/index.js +5 -6
  56. package/build-module/components/start-page-options/index.js.map +2 -2
  57. package/build-module/dataviews/store/private-actions.js +3 -9
  58. package/build-module/dataviews/store/private-actions.js.map +2 -2
  59. package/build-module/store/actions.js +3 -68
  60. package/build-module/store/actions.js.map +2 -2
  61. package/build-style/style-rtl.css +14 -2
  62. package/build-style/style.css +14 -2
  63. package/build-types/components/collab-sidebar/add-comment.d.ts +3 -3
  64. package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
  65. package/build-types/components/collab-sidebar/comment-menu-item.d.ts +3 -2
  66. package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +1 -1
  67. package/build-types/components/collab-sidebar/comments.d.ts +4 -4
  68. package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
  69. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  70. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  71. package/build-types/components/post-excerpt/panel.d.ts.map +1 -1
  72. package/build-types/components/post-template/block-theme.d.ts.map +1 -1
  73. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  74. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  75. package/build-types/components/provider/index.d.ts.map +1 -1
  76. package/build-types/components/start-page-options/index.d.ts.map +1 -1
  77. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  78. package/build-types/store/actions.d.ts.map +1 -1
  79. package/package.json +14 -14
  80. package/src/components/collab-sidebar/add-comment.js +10 -12
  81. package/src/components/collab-sidebar/comment-menu-item.js +51 -11
  82. package/src/components/collab-sidebar/comments.js +53 -56
  83. package/src/components/collab-sidebar/index.js +66 -46
  84. package/src/components/collab-sidebar/style.scss +16 -0
  85. package/src/components/collab-sidebar/utils.js +3 -2
  86. package/src/components/editor/index.js +1 -1
  87. package/src/components/post-excerpt/panel.js +1 -11
  88. package/src/components/post-template/block-theme.js +3 -45
  89. package/src/components/post-template/create-new-template-modal.js +0 -1
  90. package/src/components/post-template/hooks.js +1 -3
  91. package/src/components/preferences-modal/index.js +1 -1
  92. package/src/components/provider/index.js +2 -5
  93. package/src/components/start-page-options/index.js +5 -6
  94. package/src/components/start-page-options/style.scss +1 -1
  95. package/src/dataviews/store/private-actions.ts +7 -16
  96. package/src/store/actions.js +3 -100
  97. package/tsconfig.tsbuildinfo +1 -1
@@ -56,8 +56,8 @@ function Comments({
56
56
  onEditComment,
57
57
  onAddReply,
58
58
  onCommentDelete,
59
- showCommentBoard,
60
- setShowCommentBoard,
59
+ newNoteFormState,
60
+ setNewNoteFormState,
61
61
  commentSidebarRef,
62
62
  reflowComments,
63
63
  isFloating = false,
@@ -69,19 +69,23 @@ function Comments({
69
69
  const [blockRefs, setBlockRefs] = (0, import_element.useState)({});
70
70
  const { setCanvasMinHeight } = (0, import_lock_unlock.unlock)((0, import_data.useDispatch)(import_store.store));
71
71
  const { blockCommentId, selectedBlockClientId, orderedBlockIds } = (0, import_data.useSelect)((select) => {
72
- const { getBlockAttributes, getSelectedBlockClientId } = select(import_block_editor.store);
72
+ const {
73
+ getBlockAttributes,
74
+ getSelectedBlockClientId,
75
+ getClientIdsWithDescendants
76
+ } = select(import_block_editor.store);
73
77
  const clientId = getSelectedBlockClientId();
74
78
  return {
75
79
  blockCommentId: clientId ? getBlockAttributes(clientId)?.metadata?.noteId : null,
76
80
  selectedBlockClientId: clientId,
77
- orderedBlockIds: select(import_block_editor.store).getBlockOrder()
81
+ orderedBlockIds: getClientIdsWithDescendants()
78
82
  };
79
83
  }, []);
80
84
  const relatedBlockElement = useBlockElement(selectedBlockClientId);
81
85
  const threads = (0, import_element.useMemo)(() => {
82
86
  const t = [...noteThreads];
83
87
  const orderedThreads = [];
84
- if (isFloating && showCommentBoard && void 0 === blockCommentId) {
88
+ if (isFloating && newNoteFormState === "open") {
85
89
  const newNoteThread = {
86
90
  id: "new-note-thread",
87
91
  blockClientId: selectedBlockClientId,
@@ -105,8 +109,7 @@ function Comments({
105
109
  }, [
106
110
  noteThreads,
107
111
  isFloating,
108
- showCommentBoard,
109
- blockCommentId,
112
+ newNoteFormState,
110
113
  selectedBlockClientId,
111
114
  orderedBlockIds
112
115
  ]);
@@ -128,14 +131,15 @@ function Comments({
128
131
  (0, import_utils.focusCommentThread)(prevThread.id, commentSidebarRef.current);
129
132
  } else {
130
133
  setSelectedThread(null);
131
- setShowCommentBoard(false);
134
+ setNewNoteFormState("closed");
132
135
  relatedBlockElement?.focus();
133
136
  }
134
137
  };
135
138
  (0, import_element.useEffect)(() => {
136
- const fallback = showCommentBoard ? "new-note-thread" : null;
137
- setSelectedThread(blockCommentId ?? fallback);
138
- }, [blockCommentId, showCommentBoard]);
139
+ setSelectedThread(
140
+ newNoteFormState === "open" ? "new-note-thread" : blockCommentId
141
+ );
142
+ }, [blockCommentId, newNoteFormState]);
139
143
  const setBlockRef = (0, import_element.useCallback)((id, blockRef) => {
140
144
  setBlockRefs((prev) => ({ ...prev, [id]: blockRef }));
141
145
  }, []);
@@ -231,27 +235,15 @@ function Comments({
231
235
  ]);
232
236
  const hasThreads = Array.isArray(threads) && threads.length > 0;
233
237
  if (!hasThreads && !isFloating) {
234
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
235
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
236
- import_add_comment.AddComment,
237
- {
238
- onSubmit: onAddReply,
239
- showCommentBoard,
240
- setShowCommentBoard,
241
- commentSidebarRef
242
- }
243
- ),
244
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { as: "p", children: (0, import_i18n.__)("No notes available.") }),
245
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { as: "p", variant: "muted", children: (0, import_i18n.__)("Only logged in users can see Notes.") })
246
- ] });
238
+ return null;
247
239
  }
248
240
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
249
- !isFloating && showCommentBoard && void 0 === blockCommentId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
241
+ !isFloating && newNoteFormState === "open" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
250
242
  import_add_comment.AddComment,
251
243
  {
252
244
  onSubmit: onAddReply,
253
- showCommentBoard,
254
- setShowCommentBoard,
245
+ newNoteFormState,
246
+ setNewNoteFormState,
255
247
  commentSidebarRef
256
248
  }
257
249
  ),
@@ -264,7 +256,7 @@ function Comments({
264
256
  onEditComment,
265
257
  isSelected: selectedThread === thread.id,
266
258
  setSelectedThread,
267
- setShowCommentBoard,
259
+ setNewNoteFormState,
268
260
  commentSidebarRef,
269
261
  reflowComments,
270
262
  isFloating,
@@ -273,7 +265,7 @@ function Comments({
273
265
  setBlockRef,
274
266
  selectedThread,
275
267
  commentLastUpdated,
276
- showCommentBoard
268
+ newNoteFormState
277
269
  },
278
270
  thread.id
279
271
  ))
@@ -285,7 +277,7 @@ function Thread({
285
277
  onAddReply,
286
278
  onCommentDelete,
287
279
  isSelected,
288
- setShowCommentBoard,
280
+ setNewNoteFormState,
289
281
  commentSidebarRef,
290
282
  reflowComments,
291
283
  isFloating,
@@ -295,7 +287,7 @@ function Thread({
295
287
  setSelectedThread,
296
288
  selectedThread,
297
289
  commentLastUpdated,
298
- showCommentBoard
290
+ newNoteFormState
299
291
  }) {
300
292
  const { toggleBlockHighlight, selectBlock, toggleBlockSpotlight } = (0, import_lock_unlock.unlock)(
301
293
  (0, import_data.useDispatch)(import_block_editor.store)
@@ -320,7 +312,7 @@ function Thread({
320
312
  debouncedToggleBlockHighlight(thread.blockClientId, false);
321
313
  };
322
314
  const handleCommentSelect = () => {
323
- setShowCommentBoard(false);
315
+ setNewNoteFormState("closed");
324
316
  setSelectedThread(thread.id);
325
317
  if (!!thread.blockClientId) {
326
318
  selectBlock(thread.blockClientId, null);
@@ -329,7 +321,7 @@ function Thread({
329
321
  };
330
322
  const unselectThread = () => {
331
323
  setSelectedThread(null);
332
- setShowCommentBoard(false);
324
+ setNewNoteFormState("closed");
333
325
  toggleBlockSpotlight(thread.blockClientId, false);
334
326
  };
335
327
  const allReplies = thread?.reply || [];
@@ -348,13 +340,13 @@ function Thread({
348
340
  (0, import_i18n.__)("Original block deleted. Note: %s"),
349
341
  commentExcerpt
350
342
  );
351
- if ("new-note-thread" === thread.id && showCommentBoard && isFloating) {
343
+ if (thread.id === "new-note-thread" && newNoteFormState === "open" && isFloating) {
352
344
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
353
345
  import_add_comment.AddComment,
354
346
  {
355
347
  onSubmit: onAddReply,
356
- showCommentBoard,
357
- setShowCommentBoard,
348
+ newNoteFormState,
349
+ setNewNoteFormState,
358
350
  commentSidebarRef,
359
351
  reflowComments,
360
352
  isFloating,
@@ -363,185 +355,184 @@ function Thread({
363
355
  }
364
356
  );
365
357
  }
366
- return (
367
- // Disable reason: role="listitem" does in fact support aria-expanded.
368
- // eslint-disable-next-line jsx-a11y/role-supports-aria-props
369
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
370
- import_components.__experimentalVStack,
371
- {
372
- className: (0, import_clsx.default)("editor-collab-sidebar-panel__thread", {
373
- "is-selected": isSelected,
374
- "is-floating": isFloating
375
- }),
376
- id: `comment-thread-${thread.id}`,
377
- spacing: "3",
378
- onClick: handleCommentSelect,
379
- onMouseEnter,
380
- onMouseLeave,
381
- onFocus: onMouseEnter,
382
- onBlur: onMouseLeave,
383
- onKeyDown: (event) => {
384
- if (event.defaultPrevented) {
385
- return;
386
- }
387
- if (event.key === "Enter" && event.currentTarget === event.target) {
388
- if (isSelected) {
389
- unselectThread();
390
- } else {
391
- handleCommentSelect();
392
- }
393
- }
394
- if (event.key === "Escape") {
358
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
359
+ import_components.__experimentalVStack,
360
+ {
361
+ className: (0, import_clsx.default)("editor-collab-sidebar-panel__thread", {
362
+ "is-selected": isSelected,
363
+ "is-floating": isFloating
364
+ }),
365
+ id: `comment-thread-${thread.id}`,
366
+ spacing: "3",
367
+ onClick: handleCommentSelect,
368
+ onMouseEnter,
369
+ onMouseLeave,
370
+ onFocus: onMouseEnter,
371
+ onBlur: onMouseLeave,
372
+ onKeyDown: (event) => {
373
+ if (event.defaultPrevented) {
374
+ return;
375
+ }
376
+ if (event.key === "Enter" && event.currentTarget === event.target) {
377
+ if (isSelected) {
395
378
  unselectThread();
396
- (0, import_utils.focusCommentThread)(thread.id, commentSidebarRef.current);
379
+ } else {
380
+ handleCommentSelect();
397
381
  }
398
- },
399
- tabIndex: 0,
400
- role: "listitem",
401
- "aria-label": ariaLabel,
402
- "aria-expanded": isSelected,
403
- ref: isFloating ? refs.setFloating : void 0,
404
- style: isFloating ? { top: y } : void 0,
405
- children: [
406
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
407
- import_components.Button,
408
- {
409
- className: "editor-collab-sidebar-panel__skip-to-comment",
410
- variant: "secondary",
411
- size: "compact",
412
- onClick: () => {
413
- (0, import_utils.focusCommentThread)(
414
- thread.id,
415
- commentSidebarRef.current,
416
- "textarea"
417
- );
418
- },
419
- children: (0, import_i18n.__)("Add new note")
420
- }
421
- ),
422
- !thread.blockClientId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { as: "p", weight: 500, variant: "muted", children: (0, import_i18n.__)("Original block deleted.") }),
423
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
424
- CommentBoard,
425
- {
426
- thread,
427
- isExpanded: isSelected,
428
- onEdit: (params = {}) => {
429
- const { status } = params;
430
- onEditComment(params);
431
- if (status === "approved") {
432
- unselectThread();
382
+ }
383
+ if (event.key === "Escape") {
384
+ unselectThread();
385
+ (0, import_utils.focusCommentThread)(thread.id, commentSidebarRef.current);
386
+ }
387
+ },
388
+ tabIndex: 0,
389
+ role: "treeitem",
390
+ "aria-label": ariaLabel,
391
+ "aria-expanded": isSelected,
392
+ ref: isFloating ? refs.setFloating : void 0,
393
+ style: isFloating ? { top: y } : void 0,
394
+ children: [
395
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
396
+ import_components.Button,
397
+ {
398
+ className: "editor-collab-sidebar-panel__skip-to-comment",
399
+ variant: "secondary",
400
+ size: "compact",
401
+ onClick: () => {
402
+ (0, import_utils.focusCommentThread)(
403
+ thread.id,
404
+ commentSidebarRef.current,
405
+ "textarea"
406
+ );
407
+ },
408
+ children: (0, import_i18n.__)("Add new note")
409
+ }
410
+ ),
411
+ !thread.blockClientId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { as: "p", weight: 500, variant: "muted", children: (0, import_i18n.__)("Original block deleted.") }),
412
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
413
+ CommentBoard,
414
+ {
415
+ thread,
416
+ isExpanded: isSelected,
417
+ onEdit: (params = {}) => {
418
+ onEditComment(params);
419
+ if (params.status === "approved") {
420
+ unselectThread();
421
+ if (isFloating) {
422
+ relatedBlockElement?.focus();
423
+ } else {
433
424
  (0, import_utils.focusCommentThread)(
434
425
  thread.id,
435
426
  commentSidebarRef.current
436
427
  );
437
428
  }
438
- },
439
- onDelete: onCommentDelete,
440
- reflowComments
441
- }
442
- ),
443
- isSelected && allReplies.map((reply) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
444
- CommentBoard,
445
- {
446
- thread: reply,
447
- parent: thread,
448
- isExpanded: isSelected,
449
- onEdit: onEditComment,
450
- onDelete: onCommentDelete,
451
- reflowComments
429
+ }
430
+ },
431
+ onDelete: onCommentDelete,
432
+ reflowComments
433
+ }
434
+ ),
435
+ isSelected && allReplies.map((reply) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
436
+ CommentBoard,
437
+ {
438
+ thread: reply,
439
+ parent: thread,
440
+ isExpanded: isSelected,
441
+ onEdit: onEditComment,
442
+ onDelete: onCommentDelete,
443
+ reflowComments
444
+ },
445
+ reply.id
446
+ )),
447
+ !isSelected && restReplies.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalHStack, { className: "editor-collab-sidebar-panel__more-reply-separator", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
448
+ import_components.Button,
449
+ {
450
+ size: "compact",
451
+ variant: "tertiary",
452
+ className: "editor-collab-sidebar-panel__more-reply-button",
453
+ onClick: () => {
454
+ setSelectedThread(thread.id);
455
+ (0, import_utils.focusCommentThread)(
456
+ thread.id,
457
+ commentSidebarRef.current
458
+ );
452
459
  },
453
- reply.id
454
- )),
455
- !isSelected && restReplies.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalHStack, { className: "editor-collab-sidebar-panel__more-reply-separator", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
456
- import_components.Button,
460
+ children: (0, import_i18n.sprintf)(
461
+ // translators: %s: number of replies.
462
+ (0, import_i18n._n)(
463
+ "%s more reply",
464
+ "%s more replies",
465
+ restReplies.length
466
+ ),
467
+ restReplies.length
468
+ )
469
+ }
470
+ ) }),
471
+ !isSelected && lastReply && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
472
+ CommentBoard,
473
+ {
474
+ thread: lastReply,
475
+ parent: thread,
476
+ isExpanded: isSelected,
477
+ onEdit: onEditComment,
478
+ onDelete: onCommentDelete,
479
+ reflowComments
480
+ }
481
+ ),
482
+ isSelected && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalVStack, { spacing: "2", role: "treeitem", children: [
483
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalHStack, { alignment: "left", spacing: "3", justify: "flex-start", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_comment_author_info.default, {}) }),
484
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalVStack, { spacing: "2", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
485
+ import_comment_form.default,
457
486
  {
458
- size: "compact",
459
- variant: "tertiary",
460
- className: "editor-collab-sidebar-panel__more-reply-button",
461
- onClick: () => {
462
- setSelectedThread(thread.id);
487
+ onSubmit: (inputComment) => {
488
+ if ("approved" === thread.status) {
489
+ onEditComment({
490
+ id: thread.id,
491
+ status: "hold",
492
+ content: inputComment
493
+ });
494
+ } else {
495
+ onAddReply({
496
+ content: inputComment,
497
+ parent: thread.id
498
+ });
499
+ }
500
+ },
501
+ onCancel: (event) => {
502
+ event.stopPropagation();
503
+ unselectThread();
463
504
  (0, import_utils.focusCommentThread)(
464
505
  thread.id,
465
506
  commentSidebarRef.current
466
507
  );
467
508
  },
468
- children: (0, import_i18n.sprintf)(
469
- // translators: %s: number of replies.
470
- (0, import_i18n._n)(
471
- "%s more reply",
472
- "%s more replies",
473
- restReplies.length
474
- ),
475
- restReplies.length
476
- )
477
- }
478
- ) }),
479
- !isSelected && lastReply && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
480
- CommentBoard,
481
- {
482
- thread: lastReply,
483
- parent: thread,
484
- isExpanded: isSelected,
485
- onEdit: onEditComment,
486
- onDelete: onCommentDelete,
509
+ submitButtonText: "approved" === thread.status ? (0, import_i18n.__)("Reopen & Reply") : (0, import_i18n.__)("Reply"),
510
+ rows: "approved" === thread.status ? 2 : 4,
511
+ labelText: (0, import_i18n.sprintf)(
512
+ // translators: %1$s: note identifier, %2$s: author name
513
+ (0, import_i18n.__)("Reply to note %1$s by %2$s"),
514
+ thread.id,
515
+ thread.author_name
516
+ ),
487
517
  reflowComments
488
518
  }
489
- ),
490
- isSelected && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalVStack, { spacing: "2", children: [
491
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalHStack, { alignment: "left", spacing: "3", justify: "flex-start", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_comment_author_info.default, {}) }),
492
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalVStack, { spacing: "2", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
493
- import_comment_form.default,
494
- {
495
- onSubmit: (inputComment) => {
496
- if ("approved" === thread.status) {
497
- onEditComment({
498
- id: thread.id,
499
- status: "hold",
500
- content: inputComment
501
- });
502
- } else {
503
- onAddReply({
504
- content: inputComment,
505
- parent: thread.id
506
- });
507
- }
508
- },
509
- onCancel: (event) => {
510
- event.stopPropagation();
511
- unselectThread();
512
- (0, import_utils.focusCommentThread)(
513
- thread.id,
514
- commentSidebarRef.current
515
- );
516
- },
517
- submitButtonText: "approved" === thread.status ? (0, import_i18n.__)("Reopen & Reply") : (0, import_i18n.__)("Reply"),
518
- rows: "approved" === thread.status ? 2 : 4,
519
- labelText: (0, import_i18n.sprintf)(
520
- // translators: %1$s: note identifier, %2$s: author name
521
- (0, import_i18n.__)("Reply to note %1$s by %2$s"),
522
- thread.id,
523
- thread.author_name
524
- ),
525
- reflowComments
526
- }
527
- ) })
528
- ] }),
529
- !!thread.blockClientId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
530
- import_components.Button,
531
- {
532
- className: "editor-collab-sidebar-panel__skip-to-block",
533
- variant: "secondary",
534
- size: "compact",
535
- onClick: (event) => {
536
- event.stopPropagation();
537
- relatedBlockElement?.focus();
538
- },
539
- children: (0, import_i18n.__)("Back to block")
540
- }
541
- )
542
- ]
543
- }
544
- )
519
+ ) })
520
+ ] }),
521
+ !!thread.blockClientId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
522
+ import_components.Button,
523
+ {
524
+ className: "editor-collab-sidebar-panel__skip-to-block",
525
+ variant: "secondary",
526
+ size: "compact",
527
+ onClick: (event) => {
528
+ event.stopPropagation();
529
+ relatedBlockElement?.focus();
530
+ },
531
+ children: (0, import_i18n.__)("Back to block")
532
+ }
533
+ )
534
+ ]
535
+ }
545
536
  );
546
537
  }
547
538
  const CommentBoard = ({
@@ -595,133 +586,140 @@ const CommentBoard = ({
595
586
  ];
596
587
  const canResolve = thread.parent === 0;
597
588
  const moreActions = parent?.status !== "approved" ? actions.filter((item) => item.isEligible(thread)) : [];
598
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalVStack, { spacing: "2", children: [
599
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { alignment: "left", spacing: "3", justify: "flex-start", children: [
600
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
601
- import_comment_author_info.default,
602
- {
603
- avatar: thread?.author_avatar_urls?.[48],
604
- name: thread?.author_name,
605
- date: thread?.date,
606
- userId: thread?.author
607
- }
608
- ),
609
- isExpanded && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
610
- import_components.FlexItem,
611
- {
612
- className: "editor-collab-sidebar-panel__comment-status",
613
- onClick: (event) => {
614
- event.stopPropagation();
615
- },
616
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { spacing: "0", children: [
617
- canResolve && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
618
- import_components.Button,
619
- {
620
- label: (0, import_i18n._x)(
621
- "Resolve",
622
- "Mark note as resolved"
589
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
590
+ import_components.__experimentalVStack,
591
+ {
592
+ spacing: "2",
593
+ role: thread.parent !== 0 ? "treeitem" : void 0,
594
+ children: [
595
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { alignment: "left", spacing: "3", justify: "flex-start", children: [
596
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
597
+ import_comment_author_info.default,
598
+ {
599
+ avatar: thread?.author_avatar_urls?.[48],
600
+ name: thread?.author_name,
601
+ date: thread?.date,
602
+ userId: thread?.author
603
+ }
604
+ ),
605
+ isExpanded && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
606
+ import_components.FlexItem,
607
+ {
608
+ className: "editor-collab-sidebar-panel__comment-status",
609
+ onClick: (event) => {
610
+ event.stopPropagation();
611
+ },
612
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { spacing: "0", children: [
613
+ canResolve && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
614
+ import_components.Button,
615
+ {
616
+ label: (0, import_i18n._x)(
617
+ "Resolve",
618
+ "Mark note as resolved"
619
+ ),
620
+ size: "small",
621
+ icon: import_icons.published,
622
+ disabled: thread.status === "approved",
623
+ accessibleWhenDisabled: thread.status === "approved",
624
+ onClick: () => {
625
+ onEdit({
626
+ id: thread.id,
627
+ status: "approved"
628
+ });
629
+ }
630
+ }
623
631
  ),
624
- size: "small",
625
- icon: import_icons.published,
626
- disabled: thread.status === "approved",
627
- accessibleWhenDisabled: thread.status === "approved",
628
- onClick: () => {
629
- onEdit({
630
- id: thread.id,
631
- status: "approved"
632
- });
633
- }
634
- }
635
- ),
636
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Menu, { placement: "bottom-end", children: [
637
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
638
- Menu.TriggerButton,
639
- {
640
- render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
641
- import_components.Button,
632
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Menu, { placement: "bottom-end", children: [
633
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
634
+ Menu.TriggerButton,
642
635
  {
643
- ref: actionButtonRef,
644
- size: "small",
645
- icon: import_icons.moreVertical,
646
- label: (0, import_i18n.__)("Actions"),
647
- disabled: !moreActions.length,
648
- accessibleWhenDisabled: true
636
+ render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
637
+ import_components.Button,
638
+ {
639
+ ref: actionButtonRef,
640
+ size: "small",
641
+ icon: import_icons.moreVertical,
642
+ label: (0, import_i18n.__)("Actions"),
643
+ disabled: !moreActions.length,
644
+ accessibleWhenDisabled: true
645
+ }
646
+ )
649
647
  }
650
- )
651
- }
652
- ),
653
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu.Popover, { children: moreActions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
654
- Menu.Item,
655
- {
656
- onClick: () => action.onClick(),
657
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu.ItemLabel, { children: action.title })
658
- },
659
- action.id
660
- )) })
661
- ] })
662
- ] })
663
- }
664
- )
665
- ] }),
666
- "edit" === actionState ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
667
- import_comment_form.default,
668
- {
669
- onSubmit: (value) => {
670
- onEdit({
671
- id: thread.id,
672
- content: value
673
- });
674
- setActionState(false);
675
- actionButtonRef.current?.focus();
676
- },
677
- onCancel: () => handleCancel(),
678
- thread,
679
- submitButtonText: (0, import_i18n._x)("Update", "verb"),
680
- labelText: (0, import_i18n.sprintf)(
681
- // translators: %1$s: note identifier, %2$s: author name.
682
- (0, import_i18n.__)("Edit note %1$s by %2$s"),
683
- thread.id,
684
- thread.author_name
685
- ),
686
- reflowComments
687
- }
688
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
689
- import_element.RawHTML,
690
- {
691
- className: (0, import_clsx.default)(
692
- "editor-collab-sidebar-panel__user-comment",
648
+ ),
649
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu.Popover, { children: moreActions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
650
+ Menu.Item,
651
+ {
652
+ onClick: () => action.onClick(),
653
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu.ItemLabel, { children: action.title })
654
+ },
655
+ action.id
656
+ )) })
657
+ ] })
658
+ ] })
659
+ }
660
+ )
661
+ ] }),
662
+ "edit" === actionState ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
663
+ import_comment_form.default,
693
664
  {
694
- "editor-collab-sidebar-panel__resolution-text": isResolutionComment
665
+ onSubmit: (value) => {
666
+ onEdit({
667
+ id: thread.id,
668
+ content: value
669
+ });
670
+ setActionState(false);
671
+ actionButtonRef.current?.focus();
672
+ },
673
+ onCancel: () => handleCancel(),
674
+ thread,
675
+ submitButtonText: (0, import_i18n._x)("Update", "verb"),
676
+ labelText: (0, import_i18n.sprintf)(
677
+ // translators: %1$s: note identifier, %2$s: author name.
678
+ (0, import_i18n.__)("Edit note %1$s by %2$s"),
679
+ thread.id,
680
+ thread.author_name
681
+ ),
682
+ reflowComments
683
+ }
684
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
685
+ import_element.RawHTML,
686
+ {
687
+ className: (0, import_clsx.default)(
688
+ "editor-collab-sidebar-panel__user-comment",
689
+ {
690
+ "editor-collab-sidebar-panel__resolution-text": isResolutionComment
691
+ }
692
+ ),
693
+ children: isResolutionComment ? (() => {
694
+ const actionText = thread.meta._wp_note_status === "resolved" ? (0, import_i18n.__)("Marked as resolved") : (0, import_i18n.__)("Reopened");
695
+ const content = thread?.content?.raw;
696
+ if (content && typeof content === "string" && content.trim() !== "") {
697
+ return (0, import_i18n.sprintf)(
698
+ // translators: %1$s: action label ("Marked as resolved" or "Reopened"); %2$s: note text.
699
+ (0, import_i18n.__)("%1$s: %2$s"),
700
+ actionText,
701
+ content
702
+ );
703
+ }
704
+ return actionText;
705
+ })() : thread?.content?.rendered
695
706
  }
696
707
  ),
697
- children: isResolutionComment ? (() => {
698
- const actionText = thread.meta._wp_note_status === "resolved" ? (0, import_i18n.__)("Marked as resolved") : (0, import_i18n.__)("Reopened");
699
- const content = thread?.content?.raw;
700
- if (content && typeof content === "string" && content.trim() !== "") {
701
- return (0, import_i18n.sprintf)(
702
- // translators: %1$s: action label ("Marked as resolved" or "Reopened"); %2$s: note text.
703
- (0, import_i18n.__)("%1$s: %2$s"),
704
- actionText,
705
- content
706
- );
708
+ "delete" === actionState && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
709
+ import_components.__experimentalConfirmDialog,
710
+ {
711
+ isOpen: showConfirmDialog,
712
+ onConfirm: handleConfirmDelete,
713
+ onCancel: handleCancel,
714
+ confirmButtonText: (0, import_i18n.__)("Delete"),
715
+ children: (0, import_i18n.__)(
716
+ "Are you sure you want to delete this note? This will also delete all of this note's replies."
717
+ )
707
718
  }
708
- return actionText;
709
- })() : thread?.content?.rendered
710
- }
711
- ),
712
- "delete" === actionState && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
713
- import_components.__experimentalConfirmDialog,
714
- {
715
- isOpen: showConfirmDialog,
716
- onConfirm: handleConfirmDelete,
717
- onCancel: handleCancel,
718
- confirmButtonText: (0, import_i18n.__)("Delete"),
719
- children: (0, import_i18n.__)(
720
- "Are you sure you want to delete this note? This will also delete all of this note's replies."
721
719
  )
722
- }
723
- )
724
- ] });
720
+ ]
721
+ }
722
+ );
725
723
  };
726
724
  var comments_default = Comments;
727
725
  // Annotate the CommonJS export names for ESM import in node: