@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.
- package/build/bindings/post-data.js +47 -63
- package/build/bindings/post-data.js.map +3 -3
- package/build/bindings/post-meta.js +45 -39
- package/build/bindings/post-meta.js.map +2 -2
- package/build/components/collab-sidebar/add-comment.js +9 -5
- package/build/components/collab-sidebar/add-comment.js.map +2 -2
- package/build/components/collab-sidebar/comment-author-info.js +27 -15
- package/build/components/collab-sidebar/comment-author-info.js.map +2 -2
- package/build/components/collab-sidebar/comment-indicator-toolbar.js +9 -23
- package/build/components/collab-sidebar/comment-indicator-toolbar.js.map +3 -3
- package/build/components/collab-sidebar/comment-menu-item.js +36 -6
- package/build/components/collab-sidebar/comment-menu-item.js.map +3 -3
- package/build/components/collab-sidebar/comments.js +317 -301
- package/build/components/collab-sidebar/comments.js.map +3 -3
- package/build/components/collab-sidebar/hooks.js +5 -3
- package/build/components/collab-sidebar/hooks.js.map +2 -2
- package/build/components/collab-sidebar/index.js +35 -11
- package/build/components/collab-sidebar/index.js.map +3 -3
- package/build/components/collab-sidebar/utils.js +6 -3
- package/build/components/collab-sidebar/utils.js.map +2 -2
- package/build/components/editor/index.js +2 -2
- package/build/components/editor/index.js.map +3 -3
- package/build/components/more-menu/index.js +1 -1
- package/build/components/more-menu/index.js.map +2 -2
- package/build/components/visual-editor/index.js +20 -9
- package/build/components/visual-editor/index.js.map +2 -2
- package/build/store/private-actions.js +8 -0
- package/build/store/private-actions.js.map +2 -2
- package/build/store/private-selectors.js +5 -0
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/reducer.js +10 -0
- package/build/store/reducer.js.map +2 -2
- package/build-module/bindings/post-data.js +47 -63
- package/build-module/bindings/post-data.js.map +2 -2
- package/build-module/bindings/post-meta.js +45 -39
- package/build-module/bindings/post-meta.js.map +2 -2
- package/build-module/components/collab-sidebar/add-comment.js +10 -6
- package/build-module/components/collab-sidebar/add-comment.js.map +2 -2
- package/build-module/components/collab-sidebar/comment-author-info.js +27 -15
- package/build-module/components/collab-sidebar/comment-author-info.js.map +2 -2
- package/build-module/components/collab-sidebar/comment-indicator-toolbar.js +15 -25
- package/build-module/components/collab-sidebar/comment-indicator-toolbar.js.map +2 -2
- package/build-module/components/collab-sidebar/comment-menu-item.js +40 -7
- package/build-module/components/collab-sidebar/comment-menu-item.js.map +2 -2
- package/build-module/components/collab-sidebar/comments.js +319 -302
- package/build-module/components/collab-sidebar/comments.js.map +2 -2
- package/build-module/components/collab-sidebar/hooks.js +5 -3
- package/build-module/components/collab-sidebar/hooks.js.map +2 -2
- package/build-module/components/collab-sidebar/index.js +35 -11
- package/build-module/components/collab-sidebar/index.js.map +2 -2
- package/build-module/components/collab-sidebar/utils.js +6 -3
- package/build-module/components/collab-sidebar/utils.js.map +2 -2
- package/build-module/components/editor/index.js +2 -2
- package/build-module/components/editor/index.js.map +2 -2
- package/build-module/components/more-menu/index.js +1 -1
- package/build-module/components/more-menu/index.js.map +2 -2
- package/build-module/components/visual-editor/index.js +20 -9
- package/build-module/components/visual-editor/index.js.map +2 -2
- package/build-module/store/private-actions.js +7 -0
- package/build-module/store/private-actions.js.map +2 -2
- package/build-module/store/private-selectors.js +4 -0
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/reducer.js +9 -0
- package/build-module/store/reducer.js.map +2 -2
- package/build-style/style-rtl.css +6 -43
- package/build-style/style.css +6 -43
- package/build-types/bindings/post-data.d.ts +18 -8
- package/build-types/bindings/post-meta.d.ts +1 -7
- package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comment-author-info.d.ts +5 -16
- package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comment-menu-item.d.ts +3 -2
- package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comments.d.ts +1 -1
- package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/utils.d.ts +2 -2
- package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
- package/build-types/components/visual-editor/index.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts +7 -0
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +7 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +10 -0
- package/build-types/store/reducer.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/bindings/post-data.js +63 -111
- package/src/bindings/post-meta.js +55 -46
- package/src/bindings/test/post-meta.js +211 -0
- package/src/components/collab-sidebar/add-comment.js +11 -6
- package/src/components/collab-sidebar/comment-author-info.js +33 -26
- package/src/components/collab-sidebar/comment-indicator-toolbar.js +19 -29
- package/src/components/collab-sidebar/comment-menu-item.js +51 -11
- package/src/components/collab-sidebar/comments.js +47 -27
- package/src/components/collab-sidebar/hooks.js +6 -4
- package/src/components/collab-sidebar/index.js +63 -27
- package/src/components/collab-sidebar/style.scss +6 -46
- package/src/components/collab-sidebar/utils.js +15 -5
- package/src/components/editor/index.js +1 -1
- package/src/components/more-menu/index.js +1 -1
- package/src/components/visual-editor/index.js +27 -6
- package/src/store/private-actions.js +13 -0
- package/src/store/private-selectors.js +10 -0
- package/src/store/reducer.js +16 -0
- 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
|
-
|
|
135
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
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
|
-
|
|
375
|
+
} else {
|
|
376
|
+
handleCommentSelect();
|
|
376
377
|
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
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
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
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
|
-
|
|
419
|
-
|
|
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
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
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
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
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)(
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
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
|
-
|
|
602
|
-
|
|
603
|
-
|
|
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
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
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
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
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
|
-
|
|
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
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
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:
|