@wordpress/editor 14.33.3 → 14.33.5

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 (107) hide show
  1. package/build/bindings/post-data.js +47 -63
  2. package/build/bindings/post-data.js.map +3 -3
  3. package/build/bindings/post-meta.js +45 -39
  4. package/build/bindings/post-meta.js.map +2 -2
  5. package/build/components/collab-sidebar/add-comment.js +9 -5
  6. package/build/components/collab-sidebar/add-comment.js.map +2 -2
  7. package/build/components/collab-sidebar/comment-author-info.js +27 -15
  8. package/build/components/collab-sidebar/comment-author-info.js.map +2 -2
  9. package/build/components/collab-sidebar/comment-indicator-toolbar.js +9 -23
  10. package/build/components/collab-sidebar/comment-indicator-toolbar.js.map +3 -3
  11. package/build/components/collab-sidebar/comment-menu-item.js +36 -6
  12. package/build/components/collab-sidebar/comment-menu-item.js.map +3 -3
  13. package/build/components/collab-sidebar/comments.js +317 -301
  14. package/build/components/collab-sidebar/comments.js.map +3 -3
  15. package/build/components/collab-sidebar/hooks.js +5 -3
  16. package/build/components/collab-sidebar/hooks.js.map +2 -2
  17. package/build/components/collab-sidebar/index.js +35 -11
  18. package/build/components/collab-sidebar/index.js.map +3 -3
  19. package/build/components/collab-sidebar/utils.js +6 -3
  20. package/build/components/collab-sidebar/utils.js.map +2 -2
  21. package/build/components/editor/index.js +2 -2
  22. package/build/components/editor/index.js.map +3 -3
  23. package/build/components/more-menu/index.js +1 -1
  24. package/build/components/more-menu/index.js.map +2 -2
  25. package/build/components/visual-editor/index.js +20 -9
  26. package/build/components/visual-editor/index.js.map +2 -2
  27. package/build/store/private-actions.js +8 -0
  28. package/build/store/private-actions.js.map +2 -2
  29. package/build/store/private-selectors.js +5 -0
  30. package/build/store/private-selectors.js.map +2 -2
  31. package/build/store/reducer.js +10 -0
  32. package/build/store/reducer.js.map +2 -2
  33. package/build-module/bindings/post-data.js +47 -63
  34. package/build-module/bindings/post-data.js.map +2 -2
  35. package/build-module/bindings/post-meta.js +45 -39
  36. package/build-module/bindings/post-meta.js.map +2 -2
  37. package/build-module/components/collab-sidebar/add-comment.js +10 -6
  38. package/build-module/components/collab-sidebar/add-comment.js.map +2 -2
  39. package/build-module/components/collab-sidebar/comment-author-info.js +27 -15
  40. package/build-module/components/collab-sidebar/comment-author-info.js.map +2 -2
  41. package/build-module/components/collab-sidebar/comment-indicator-toolbar.js +15 -25
  42. package/build-module/components/collab-sidebar/comment-indicator-toolbar.js.map +2 -2
  43. package/build-module/components/collab-sidebar/comment-menu-item.js +40 -7
  44. package/build-module/components/collab-sidebar/comment-menu-item.js.map +2 -2
  45. package/build-module/components/collab-sidebar/comments.js +319 -302
  46. package/build-module/components/collab-sidebar/comments.js.map +2 -2
  47. package/build-module/components/collab-sidebar/hooks.js +5 -3
  48. package/build-module/components/collab-sidebar/hooks.js.map +2 -2
  49. package/build-module/components/collab-sidebar/index.js +35 -11
  50. package/build-module/components/collab-sidebar/index.js.map +2 -2
  51. package/build-module/components/collab-sidebar/utils.js +6 -3
  52. package/build-module/components/collab-sidebar/utils.js.map +2 -2
  53. package/build-module/components/editor/index.js +2 -2
  54. package/build-module/components/editor/index.js.map +2 -2
  55. package/build-module/components/more-menu/index.js +1 -1
  56. package/build-module/components/more-menu/index.js.map +2 -2
  57. package/build-module/components/visual-editor/index.js +20 -9
  58. package/build-module/components/visual-editor/index.js.map +2 -2
  59. package/build-module/store/private-actions.js +7 -0
  60. package/build-module/store/private-actions.js.map +2 -2
  61. package/build-module/store/private-selectors.js +4 -0
  62. package/build-module/store/private-selectors.js.map +2 -2
  63. package/build-module/store/reducer.js +9 -0
  64. package/build-module/store/reducer.js.map +2 -2
  65. package/build-style/style-rtl.css +6 -43
  66. package/build-style/style.css +6 -43
  67. package/build-types/bindings/post-data.d.ts +18 -8
  68. package/build-types/bindings/post-meta.d.ts +1 -7
  69. package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
  70. package/build-types/components/collab-sidebar/comment-author-info.d.ts +5 -16
  71. package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -1
  72. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +1 -1
  73. package/build-types/components/collab-sidebar/comment-menu-item.d.ts +3 -2
  74. package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +1 -1
  75. package/build-types/components/collab-sidebar/comments.d.ts +1 -1
  76. package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
  77. package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
  78. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  79. package/build-types/components/collab-sidebar/utils.d.ts +2 -2
  80. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  81. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  82. package/build-types/store/private-actions.d.ts +7 -0
  83. package/build-types/store/private-actions.d.ts.map +1 -1
  84. package/build-types/store/private-selectors.d.ts +7 -0
  85. package/build-types/store/private-selectors.d.ts.map +1 -1
  86. package/build-types/store/reducer.d.ts +10 -0
  87. package/build-types/store/reducer.d.ts.map +1 -1
  88. package/package.json +8 -8
  89. package/src/bindings/post-data.js +63 -111
  90. package/src/bindings/post-meta.js +55 -46
  91. package/src/bindings/test/post-meta.js +211 -0
  92. package/src/components/collab-sidebar/add-comment.js +11 -6
  93. package/src/components/collab-sidebar/comment-author-info.js +33 -26
  94. package/src/components/collab-sidebar/comment-indicator-toolbar.js +19 -29
  95. package/src/components/collab-sidebar/comment-menu-item.js +51 -11
  96. package/src/components/collab-sidebar/comments.js +47 -27
  97. package/src/components/collab-sidebar/hooks.js +6 -4
  98. package/src/components/collab-sidebar/index.js +63 -27
  99. package/src/components/collab-sidebar/style.scss +6 -46
  100. package/src/components/collab-sidebar/utils.js +15 -5
  101. package/src/components/editor/index.js +1 -1
  102. package/src/components/more-menu/index.js +1 -1
  103. package/src/components/visual-editor/index.js +27 -6
  104. package/src/store/private-actions.js +13 -0
  105. package/src/store/private-selectors.js +10 -0
  106. package/src/store/reducer.js +16 -0
  107. package/tsconfig.tsbuildinfo +1 -1
@@ -48,6 +48,7 @@ var import_comment_form = __toESM(require("./comment-form"));
48
48
  var import_utils = require("./utils");
49
49
  var import_hooks = require("./hooks");
50
50
  var import_add_comment = require("./add-comment");
51
+ var import_store = require("../../store");
51
52
  const { useBlockElement } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
52
53
  const { Menu } = (0, import_lock_unlock.unlock)(import_components.privateApis);
53
54
  function Comments({
@@ -66,6 +67,7 @@ function Comments({
66
67
  const [selectedThread, setSelectedThread] = (0, import_element.useState)(null);
67
68
  const [boardOffsets, setBoardOffsets] = (0, import_element.useState)({});
68
69
  const [blockRefs, setBlockRefs] = (0, import_element.useState)({});
70
+ const { setCanvasMinHeight } = (0, import_lock_unlock.unlock)((0, import_data.useDispatch)(import_store.store));
69
71
  const { blockCommentId, selectedBlockClientId, orderedBlockIds } = (0, import_data.useSelect)((select) => {
70
72
  const { getBlockAttributes, getSelectedBlockClientId } = select(import_block_editor.store);
71
73
  const clientId = getSelectedBlockClientId();
@@ -131,8 +133,9 @@ function Comments({
131
133
  }
132
134
  };
133
135
  (0, import_element.useEffect)(() => {
134
- setSelectedThread(blockCommentId ?? void 0);
135
- }, [blockCommentId]);
136
+ const fallback = showCommentBoard ? "new-note-thread" : null;
137
+ setSelectedThread(blockCommentId ?? fallback);
138
+ }, [blockCommentId, showCommentBoard]);
136
139
  const setBlockRef = (0, import_element.useCallback)((id, blockRef) => {
137
140
  setBlockRefs((prev) => ({ ...prev, [id]: blockRef }));
138
141
  }, []);
@@ -140,7 +143,7 @@ function Comments({
140
143
  const calculateAllOffsets = () => {
141
144
  const offsets = {};
142
145
  if (!isFloating) {
143
- return offsets;
146
+ return { offsets, minHeight: 0 };
144
147
  }
145
148
  const selectedThreadIndex = threads.findIndex(
146
149
  (t) => t.id === selectedThread
@@ -148,7 +151,7 @@ function Comments({
148
151
  const breakIndex = selectedThreadIndex === -1 ? 0 : selectedThreadIndex;
149
152
  const selectedThreadData = threads[breakIndex];
150
153
  if (!selectedThreadData || !blockRefs[selectedThreadData.id]) {
151
- return offsets;
154
+ return { offsets, minHeight: 0 };
152
155
  }
153
156
  let blockElement = blockRefs[selectedThreadData.id];
154
157
  let blockRect = blockElement?.getBoundingClientRect();
@@ -201,28 +204,34 @@ function Comments({
201
204
  threadTop: threadTop + additionalOffset
202
205
  };
203
206
  }
204
- return offsets;
207
+ let editorMinHeight = 0;
208
+ const lastThread = threads[threads.length - 1];
209
+ if (blockRefs[lastThread.id]) {
210
+ const lastBlockElement = blockRefs[lastThread.id];
211
+ const lastBlockRect = lastBlockElement?.getBoundingClientRect();
212
+ const lastThreadTop = lastBlockRect?.top || 0;
213
+ const lastThreadHeight = heights[lastThread.id] || 0;
214
+ const lastThreadOffset = offsets[lastThread.id] || 0;
215
+ editorMinHeight = lastThreadTop + lastThreadHeight + lastThreadOffset + 32;
216
+ }
217
+ return { offsets, minHeight: editorMinHeight };
205
218
  };
206
- const newOffsets = calculateAllOffsets();
219
+ const { offsets: newOffsets, minHeight } = calculateAllOffsets();
207
220
  if (Object.keys(newOffsets).length > 0) {
208
221
  setBoardOffsets(newOffsets);
209
222
  }
210
- }, [heights, blockRefs, isFloating, threads, selectedThread]);
223
+ setCanvasMinHeight(minHeight);
224
+ }, [
225
+ heights,
226
+ blockRefs,
227
+ isFloating,
228
+ threads,
229
+ selectedThread,
230
+ setCanvasMinHeight
231
+ ]);
211
232
  const hasThreads = Array.isArray(threads) && threads.length > 0;
212
233
  if (!hasThreads && !isFloating) {
213
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
214
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
215
- import_add_comment.AddComment,
216
- {
217
- onSubmit: onAddReply,
218
- showCommentBoard,
219
- setShowCommentBoard,
220
- commentSidebarRef
221
- }
222
- ),
223
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { as: "p", children: (0, import_i18n.__)("No notes available.") }),
224
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { as: "p", variant: "muted", children: (0, import_i18n.__)("Only logged in users can see Notes.") })
225
- ] });
234
+ return null;
226
235
  }
227
236
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
228
237
  !isFloating && showCommentBoard && void 0 === blockCommentId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -342,185 +351,181 @@ function Thread({
342
351
  }
343
352
  );
344
353
  }
345
- return (
346
- // Disable reason: role="listitem" does in fact support aria-expanded.
347
- // eslint-disable-next-line jsx-a11y/role-supports-aria-props
348
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
349
- import_components.__experimentalVStack,
350
- {
351
- className: (0, import_clsx.default)("editor-collab-sidebar-panel__thread", {
352
- "is-selected": isSelected,
353
- "is-floating": isFloating
354
- }),
355
- id: `comment-thread-${thread.id}`,
356
- spacing: "3",
357
- onClick: handleCommentSelect,
358
- onMouseEnter,
359
- onMouseLeave,
360
- onFocus: onMouseEnter,
361
- onBlur: onMouseLeave,
362
- onKeyDown: (event) => {
363
- if (event.defaultPrevented) {
364
- return;
365
- }
366
- if (event.key === "Enter" && event.currentTarget === event.target) {
367
- if (isSelected) {
368
- unselectThread();
369
- } else {
370
- handleCommentSelect();
371
- }
372
- }
373
- if (event.key === "Escape") {
354
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
355
+ import_components.__experimentalVStack,
356
+ {
357
+ className: (0, import_clsx.default)("editor-collab-sidebar-panel__thread", {
358
+ "is-selected": isSelected,
359
+ "is-floating": isFloating
360
+ }),
361
+ id: `comment-thread-${thread.id}`,
362
+ spacing: "3",
363
+ onClick: handleCommentSelect,
364
+ onMouseEnter,
365
+ onMouseLeave,
366
+ onFocus: onMouseEnter,
367
+ onBlur: onMouseLeave,
368
+ onKeyDown: (event) => {
369
+ if (event.defaultPrevented) {
370
+ return;
371
+ }
372
+ if (event.key === "Enter" && event.currentTarget === event.target) {
373
+ if (isSelected) {
374
374
  unselectThread();
375
- (0, import_utils.focusCommentThread)(thread.id, commentSidebarRef.current);
375
+ } else {
376
+ handleCommentSelect();
376
377
  }
377
- },
378
- tabIndex: 0,
379
- role: "listitem",
380
- "aria-label": ariaLabel,
381
- "aria-expanded": isSelected,
382
- ref: isFloating ? refs.setFloating : void 0,
383
- style: isFloating ? { top: y } : void 0,
384
- children: [
385
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
386
- import_components.Button,
387
- {
388
- className: "editor-collab-sidebar-panel__skip-to-comment",
389
- variant: "secondary",
390
- size: "compact",
391
- onClick: () => {
378
+ }
379
+ if (event.key === "Escape") {
380
+ unselectThread();
381
+ (0, import_utils.focusCommentThread)(thread.id, commentSidebarRef.current);
382
+ }
383
+ },
384
+ tabIndex: 0,
385
+ role: "treeitem",
386
+ "aria-label": ariaLabel,
387
+ "aria-expanded": isSelected,
388
+ ref: isFloating ? refs.setFloating : void 0,
389
+ style: isFloating ? { top: y } : void 0,
390
+ children: [
391
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
392
+ import_components.Button,
393
+ {
394
+ className: "editor-collab-sidebar-panel__skip-to-comment",
395
+ variant: "secondary",
396
+ size: "compact",
397
+ onClick: () => {
398
+ (0, import_utils.focusCommentThread)(
399
+ thread.id,
400
+ commentSidebarRef.current,
401
+ "textarea"
402
+ );
403
+ },
404
+ children: (0, import_i18n.__)("Add new note")
405
+ }
406
+ ),
407
+ !thread.blockClientId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { as: "p", weight: 500, variant: "muted", children: (0, import_i18n.__)("Original block deleted.") }),
408
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
409
+ CommentBoard,
410
+ {
411
+ thread,
412
+ isExpanded: isSelected,
413
+ onEdit: (params = {}) => {
414
+ const { status } = params;
415
+ onEditComment(params);
416
+ if (status === "approved") {
417
+ unselectThread();
392
418
  (0, import_utils.focusCommentThread)(
393
419
  thread.id,
394
- commentSidebarRef.current,
395
- "textarea"
420
+ commentSidebarRef.current
396
421
  );
397
- },
398
- children: (0, import_i18n.__)("Add new note")
399
- }
400
- ),
401
- !thread.blockClientId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalText, { as: "p", weight: 500, variant: "muted", children: (0, import_i18n.__)("Original block deleted.") }),
402
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
403
- CommentBoard,
422
+ }
423
+ },
424
+ onDelete: onCommentDelete,
425
+ reflowComments
426
+ }
427
+ ),
428
+ isSelected && allReplies.map((reply) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
429
+ CommentBoard,
430
+ {
431
+ thread: reply,
432
+ parent: thread,
433
+ isExpanded: isSelected,
434
+ onEdit: onEditComment,
435
+ onDelete: onCommentDelete,
436
+ reflowComments
437
+ },
438
+ reply.id
439
+ )),
440
+ !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)(
441
+ import_components.Button,
442
+ {
443
+ size: "compact",
444
+ variant: "tertiary",
445
+ className: "editor-collab-sidebar-panel__more-reply-button",
446
+ onClick: () => {
447
+ setSelectedThread(thread.id);
448
+ (0, import_utils.focusCommentThread)(
449
+ thread.id,
450
+ commentSidebarRef.current
451
+ );
452
+ },
453
+ children: (0, import_i18n.sprintf)(
454
+ // translators: %s: number of replies.
455
+ (0, import_i18n._n)(
456
+ "%s more reply",
457
+ "%s more replies",
458
+ restReplies.length
459
+ ),
460
+ restReplies.length
461
+ )
462
+ }
463
+ ) }),
464
+ !isSelected && lastReply && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
465
+ CommentBoard,
466
+ {
467
+ thread: lastReply,
468
+ parent: thread,
469
+ isExpanded: isSelected,
470
+ onEdit: onEditComment,
471
+ onDelete: onCommentDelete,
472
+ reflowComments
473
+ }
474
+ ),
475
+ isSelected && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalVStack, { spacing: "2", role: "treeitem", children: [
476
+ /* @__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, {}) }),
477
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalVStack, { spacing: "2", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
478
+ import_comment_form.default,
404
479
  {
405
- thread,
406
- isExpanded: isSelected,
407
- onEdit: (params = {}) => {
408
- const { status } = params;
409
- onEditComment(params);
410
- if (status === "approved") {
411
- unselectThread();
412
- (0, import_utils.focusCommentThread)(
413
- thread.id,
414
- commentSidebarRef.current
415
- );
480
+ onSubmit: (inputComment) => {
481
+ if ("approved" === thread.status) {
482
+ onEditComment({
483
+ id: thread.id,
484
+ status: "hold",
485
+ content: inputComment
486
+ });
487
+ } else {
488
+ onAddReply({
489
+ content: inputComment,
490
+ parent: thread.id
491
+ });
416
492
  }
417
493
  },
418
- onDelete: onCommentDelete,
419
- reflowComments
420
- }
421
- ),
422
- isSelected && allReplies.map((reply) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
423
- CommentBoard,
424
- {
425
- thread: reply,
426
- parent: thread,
427
- isExpanded: isSelected,
428
- onEdit: onEditComment,
429
- onDelete: onCommentDelete,
430
- reflowComments
431
- },
432
- reply.id
433
- )),
434
- !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)(
435
- import_components.Button,
436
- {
437
- size: "compact",
438
- variant: "tertiary",
439
- className: "editor-collab-sidebar-panel__more-reply-button",
440
- onClick: () => {
441
- setSelectedThread(thread.id);
494
+ onCancel: (event) => {
495
+ event.stopPropagation();
496
+ unselectThread();
442
497
  (0, import_utils.focusCommentThread)(
443
498
  thread.id,
444
499
  commentSidebarRef.current
445
500
  );
446
501
  },
447
- children: (0, import_i18n.sprintf)(
448
- // translators: %s: number of replies.
449
- (0, import_i18n._n)(
450
- "%s more reply",
451
- "%s more replies",
452
- restReplies.length
453
- ),
454
- restReplies.length
455
- )
456
- }
457
- ) }),
458
- !isSelected && lastReply && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
459
- CommentBoard,
460
- {
461
- thread: lastReply,
462
- parent: thread,
463
- isExpanded: isSelected,
464
- onEdit: onEditComment,
465
- onDelete: onCommentDelete,
502
+ submitButtonText: "approved" === thread.status ? (0, import_i18n.__)("Reopen & Reply") : (0, import_i18n.__)("Reply"),
503
+ rows: "approved" === thread.status ? 2 : 4,
504
+ labelText: (0, import_i18n.sprintf)(
505
+ // translators: %1$s: note identifier, %2$s: author name
506
+ (0, import_i18n.__)("Reply to note %1$s by %2$s"),
507
+ thread.id,
508
+ thread.author_name
509
+ ),
466
510
  reflowComments
467
511
  }
468
- ),
469
- isSelected && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalVStack, { spacing: "2", children: [
470
- /* @__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, {}) }),
471
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalVStack, { spacing: "2", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
472
- import_comment_form.default,
473
- {
474
- onSubmit: (inputComment) => {
475
- if ("approved" === thread.status) {
476
- onEditComment({
477
- id: thread.id,
478
- status: "hold",
479
- content: inputComment
480
- });
481
- } else {
482
- onAddReply({
483
- content: inputComment,
484
- parent: thread.id
485
- });
486
- }
487
- },
488
- onCancel: (event) => {
489
- event.stopPropagation();
490
- unselectThread();
491
- (0, import_utils.focusCommentThread)(
492
- thread.id,
493
- commentSidebarRef.current
494
- );
495
- },
496
- submitButtonText: "approved" === thread.status ? (0, import_i18n.__)("Reopen & Reply") : (0, import_i18n.__)("Reply"),
497
- rows: "approved" === thread.status ? 2 : 4,
498
- labelText: (0, import_i18n.sprintf)(
499
- // translators: %1$s: note identifier, %2$s: author name
500
- (0, import_i18n.__)("Reply to note %1$s by %2$s"),
501
- thread.id,
502
- thread.author_name
503
- ),
504
- reflowComments
505
- }
506
- ) })
507
- ] }),
508
- !!thread.blockClientId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
509
- import_components.Button,
510
- {
511
- className: "editor-collab-sidebar-panel__skip-to-block",
512
- variant: "secondary",
513
- size: "compact",
514
- onClick: (event) => {
515
- event.stopPropagation();
516
- relatedBlockElement?.focus();
517
- },
518
- children: (0, import_i18n.__)("Back to block")
519
- }
520
- )
521
- ]
522
- }
523
- )
512
+ ) })
513
+ ] }),
514
+ !!thread.blockClientId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
515
+ import_components.Button,
516
+ {
517
+ className: "editor-collab-sidebar-panel__skip-to-block",
518
+ variant: "secondary",
519
+ size: "compact",
520
+ onClick: (event) => {
521
+ event.stopPropagation();
522
+ relatedBlockElement?.focus();
523
+ },
524
+ children: (0, import_i18n.__)("Back to block")
525
+ }
526
+ )
527
+ ]
528
+ }
524
529
  );
525
530
  }
526
531
  const CommentBoard = ({
@@ -533,6 +538,7 @@ const CommentBoard = ({
533
538
  }) => {
534
539
  const [actionState, setActionState] = (0, import_element.useState)(false);
535
540
  const [showConfirmDialog, setShowConfirmDialog] = (0, import_element.useState)(false);
541
+ const actionButtonRef = (0, import_element.useRef)(null);
536
542
  const handleConfirmDelete = () => {
537
543
  onDelete(thread);
538
544
  setActionState(false);
@@ -541,6 +547,7 @@ const CommentBoard = ({
541
547
  const handleCancel = () => {
542
548
  setActionState(false);
543
549
  setShowConfirmDialog(false);
550
+ actionButtonRef.current?.focus();
544
551
  };
545
552
  const isResolutionComment = thread.type === "note" && thread.meta && (thread.meta._wp_note_status === "resolved" || thread.meta._wp_note_status === "reopen");
546
553
  const actions = [
@@ -572,131 +579,140 @@ const CommentBoard = ({
572
579
  ];
573
580
  const canResolve = thread.parent === 0;
574
581
  const moreActions = parent?.status !== "approved" ? actions.filter((item) => item.isEligible(thread)) : [];
575
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalVStack, { spacing: "2", children: [
576
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { alignment: "left", spacing: "3", justify: "flex-start", children: [
577
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
578
- import_comment_author_info.default,
579
- {
580
- avatar: thread?.author_avatar_urls?.[48],
581
- name: thread?.author_name,
582
- date: thread?.date,
583
- userId: thread?.author
584
- }
585
- ),
586
- isExpanded && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
587
- import_components.FlexItem,
588
- {
589
- className: "editor-collab-sidebar-panel__comment-status",
590
- onClick: (event) => {
591
- event.stopPropagation();
592
- },
593
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { spacing: "0", children: [
594
- canResolve && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
595
- import_components.Button,
596
- {
597
- label: (0, import_i18n._x)(
598
- "Resolve",
599
- "Mark note as resolved"
582
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
583
+ import_components.__experimentalVStack,
584
+ {
585
+ spacing: "2",
586
+ role: thread.parent !== 0 ? "treeitem" : void 0,
587
+ children: [
588
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { alignment: "left", spacing: "3", justify: "flex-start", children: [
589
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
590
+ import_comment_author_info.default,
591
+ {
592
+ avatar: thread?.author_avatar_urls?.[48],
593
+ name: thread?.author_name,
594
+ date: thread?.date,
595
+ userId: thread?.author
596
+ }
597
+ ),
598
+ isExpanded && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
599
+ import_components.FlexItem,
600
+ {
601
+ className: "editor-collab-sidebar-panel__comment-status",
602
+ onClick: (event) => {
603
+ event.stopPropagation();
604
+ },
605
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { spacing: "0", children: [
606
+ canResolve && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
607
+ import_components.Button,
608
+ {
609
+ label: (0, import_i18n._x)(
610
+ "Resolve",
611
+ "Mark note as resolved"
612
+ ),
613
+ size: "small",
614
+ icon: import_icons.published,
615
+ disabled: thread.status === "approved",
616
+ accessibleWhenDisabled: thread.status === "approved",
617
+ onClick: () => {
618
+ onEdit({
619
+ id: thread.id,
620
+ status: "approved"
621
+ });
622
+ }
623
+ }
600
624
  ),
601
- size: "small",
602
- icon: import_icons.published,
603
- disabled: thread.status === "approved",
604
- accessibleWhenDisabled: thread.status === "approved",
605
- onClick: () => {
606
- onEdit({
607
- id: thread.id,
608
- status: "approved"
609
- });
610
- }
611
- }
612
- ),
613
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Menu, { placement: "bottom-end", children: [
614
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
615
- Menu.TriggerButton,
616
- {
617
- render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
618
- import_components.Button,
625
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Menu, { placement: "bottom-end", children: [
626
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
627
+ Menu.TriggerButton,
619
628
  {
620
- size: "small",
621
- icon: import_icons.moreVertical,
622
- label: (0, import_i18n.__)("Actions"),
623
- disabled: !moreActions.length,
624
- accessibleWhenDisabled: true
629
+ render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
630
+ import_components.Button,
631
+ {
632
+ ref: actionButtonRef,
633
+ size: "small",
634
+ icon: import_icons.moreVertical,
635
+ label: (0, import_i18n.__)("Actions"),
636
+ disabled: !moreActions.length,
637
+ accessibleWhenDisabled: true
638
+ }
639
+ )
625
640
  }
626
- )
627
- }
628
- ),
629
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu.Popover, { children: moreActions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
630
- Menu.Item,
631
- {
632
- onClick: () => action.onClick(),
633
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu.ItemLabel, { children: action.title })
634
- },
635
- action.id
636
- )) })
637
- ] })
638
- ] })
639
- }
640
- )
641
- ] }),
642
- "edit" === actionState ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
643
- import_comment_form.default,
644
- {
645
- onSubmit: (value) => {
646
- onEdit({
647
- id: thread.id,
648
- content: value
649
- });
650
- setActionState(false);
651
- },
652
- onCancel: () => handleCancel(),
653
- thread,
654
- submitButtonText: (0, import_i18n._x)("Update", "verb"),
655
- labelText: (0, import_i18n.sprintf)(
656
- // translators: %1$s: note identifier, %2$s: author name.
657
- (0, import_i18n.__)("Edit note %1$s by %2$s"),
658
- thread.id,
659
- thread.author_name
660
- ),
661
- reflowComments
662
- }
663
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
664
- import_element.RawHTML,
665
- {
666
- className: (0, import_clsx.default)(
667
- "editor-collab-sidebar-panel__user-comment",
641
+ ),
642
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu.Popover, { children: moreActions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
643
+ Menu.Item,
644
+ {
645
+ onClick: () => action.onClick(),
646
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu.ItemLabel, { children: action.title })
647
+ },
648
+ action.id
649
+ )) })
650
+ ] })
651
+ ] })
652
+ }
653
+ )
654
+ ] }),
655
+ "edit" === actionState ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
656
+ import_comment_form.default,
657
+ {
658
+ onSubmit: (value) => {
659
+ onEdit({
660
+ id: thread.id,
661
+ content: value
662
+ });
663
+ setActionState(false);
664
+ actionButtonRef.current?.focus();
665
+ },
666
+ onCancel: () => handleCancel(),
667
+ thread,
668
+ submitButtonText: (0, import_i18n._x)("Update", "verb"),
669
+ labelText: (0, import_i18n.sprintf)(
670
+ // translators: %1$s: note identifier, %2$s: author name.
671
+ (0, import_i18n.__)("Edit note %1$s by %2$s"),
672
+ thread.id,
673
+ thread.author_name
674
+ ),
675
+ reflowComments
676
+ }
677
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
678
+ import_element.RawHTML,
668
679
  {
669
- "editor-collab-sidebar-panel__resolution-text": isResolutionComment
680
+ className: (0, import_clsx.default)(
681
+ "editor-collab-sidebar-panel__user-comment",
682
+ {
683
+ "editor-collab-sidebar-panel__resolution-text": isResolutionComment
684
+ }
685
+ ),
686
+ children: isResolutionComment ? (() => {
687
+ const actionText = thread.meta._wp_note_status === "resolved" ? (0, import_i18n.__)("Marked as resolved") : (0, import_i18n.__)("Reopened");
688
+ const content = thread?.content?.raw;
689
+ if (content && typeof content === "string" && content.trim() !== "") {
690
+ return (0, import_i18n.sprintf)(
691
+ // translators: %1$s: action label ("Marked as resolved" or "Reopened"); %2$s: note text.
692
+ (0, import_i18n.__)("%1$s: %2$s"),
693
+ actionText,
694
+ content
695
+ );
696
+ }
697
+ return actionText;
698
+ })() : thread?.content?.rendered
670
699
  }
671
700
  ),
672
- children: isResolutionComment ? (() => {
673
- const actionText = thread.meta._wp_note_status === "resolved" ? (0, import_i18n.__)("Marked as resolved") : (0, import_i18n.__)("Reopened");
674
- const content = thread?.content?.raw;
675
- if (content && typeof content === "string" && content.trim() !== "") {
676
- return (0, import_i18n.sprintf)(
677
- // translators: %1$s: action label ("Marked as resolved" or "Reopened"); %2$s: note text.
678
- (0, import_i18n.__)("%1$s: %2$s"),
679
- actionText,
680
- content
681
- );
701
+ "delete" === actionState && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
702
+ import_components.__experimentalConfirmDialog,
703
+ {
704
+ isOpen: showConfirmDialog,
705
+ onConfirm: handleConfirmDelete,
706
+ onCancel: handleCancel,
707
+ confirmButtonText: (0, import_i18n.__)("Delete"),
708
+ children: (0, import_i18n.__)(
709
+ "Are you sure you want to delete this note? This will also delete all of this note's replies."
710
+ )
682
711
  }
683
- return actionText;
684
- })() : thread?.content?.rendered
685
- }
686
- ),
687
- "delete" === actionState && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
688
- import_components.__experimentalConfirmDialog,
689
- {
690
- isOpen: showConfirmDialog,
691
- onConfirm: handleConfirmDelete,
692
- onCancel: handleCancel,
693
- confirmButtonText: (0, import_i18n.__)("Delete"),
694
- children: (0, import_i18n.__)(
695
- "Are you sure you want to delete this note? This will also delete all of this note's replies."
696
712
  )
697
- }
698
- )
699
- ] });
713
+ ]
714
+ }
715
+ );
700
716
  };
701
717
  var comments_default = Comments;
702
718
  // Annotate the CommonJS export names for ESM import in node: