@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
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
RawHTML,
|
|
6
6
|
useEffect,
|
|
7
7
|
useCallback,
|
|
8
|
-
useMemo
|
|
8
|
+
useMemo,
|
|
9
|
+
useRef
|
|
9
10
|
} from "@wordpress/element";
|
|
10
11
|
import {
|
|
11
12
|
__experimentalText as Text,
|
|
@@ -31,6 +32,7 @@ import CommentForm from "./comment-form";
|
|
|
31
32
|
import { focusCommentThread, getCommentExcerpt } from "./utils";
|
|
32
33
|
import { useFloatingThread } from "./hooks";
|
|
33
34
|
import { AddComment } from "./add-comment";
|
|
35
|
+
import { store as editorStore } from "../../store";
|
|
34
36
|
const { useBlockElement } = unlock(blockEditorPrivateApis);
|
|
35
37
|
const { Menu } = unlock(componentsPrivateApis);
|
|
36
38
|
function Comments({
|
|
@@ -49,6 +51,7 @@ function Comments({
|
|
|
49
51
|
const [selectedThread, setSelectedThread] = useState(null);
|
|
50
52
|
const [boardOffsets, setBoardOffsets] = useState({});
|
|
51
53
|
const [blockRefs, setBlockRefs] = useState({});
|
|
54
|
+
const { setCanvasMinHeight } = unlock(useDispatch(editorStore));
|
|
52
55
|
const { blockCommentId, selectedBlockClientId, orderedBlockIds } = useSelect((select) => {
|
|
53
56
|
const { getBlockAttributes, getSelectedBlockClientId } = select(blockEditorStore);
|
|
54
57
|
const clientId = getSelectedBlockClientId();
|
|
@@ -114,8 +117,9 @@ function Comments({
|
|
|
114
117
|
}
|
|
115
118
|
};
|
|
116
119
|
useEffect(() => {
|
|
117
|
-
|
|
118
|
-
|
|
120
|
+
const fallback = showCommentBoard ? "new-note-thread" : null;
|
|
121
|
+
setSelectedThread(blockCommentId ?? fallback);
|
|
122
|
+
}, [blockCommentId, showCommentBoard]);
|
|
119
123
|
const setBlockRef = useCallback((id, blockRef) => {
|
|
120
124
|
setBlockRefs((prev) => ({ ...prev, [id]: blockRef }));
|
|
121
125
|
}, []);
|
|
@@ -123,7 +127,7 @@ function Comments({
|
|
|
123
127
|
const calculateAllOffsets = () => {
|
|
124
128
|
const offsets = {};
|
|
125
129
|
if (!isFloating) {
|
|
126
|
-
return offsets;
|
|
130
|
+
return { offsets, minHeight: 0 };
|
|
127
131
|
}
|
|
128
132
|
const selectedThreadIndex = threads.findIndex(
|
|
129
133
|
(t) => t.id === selectedThread
|
|
@@ -131,7 +135,7 @@ function Comments({
|
|
|
131
135
|
const breakIndex = selectedThreadIndex === -1 ? 0 : selectedThreadIndex;
|
|
132
136
|
const selectedThreadData = threads[breakIndex];
|
|
133
137
|
if (!selectedThreadData || !blockRefs[selectedThreadData.id]) {
|
|
134
|
-
return offsets;
|
|
138
|
+
return { offsets, minHeight: 0 };
|
|
135
139
|
}
|
|
136
140
|
let blockElement = blockRefs[selectedThreadData.id];
|
|
137
141
|
let blockRect = blockElement?.getBoundingClientRect();
|
|
@@ -184,28 +188,34 @@ function Comments({
|
|
|
184
188
|
threadTop: threadTop + additionalOffset
|
|
185
189
|
};
|
|
186
190
|
}
|
|
187
|
-
|
|
191
|
+
let editorMinHeight = 0;
|
|
192
|
+
const lastThread = threads[threads.length - 1];
|
|
193
|
+
if (blockRefs[lastThread.id]) {
|
|
194
|
+
const lastBlockElement = blockRefs[lastThread.id];
|
|
195
|
+
const lastBlockRect = lastBlockElement?.getBoundingClientRect();
|
|
196
|
+
const lastThreadTop = lastBlockRect?.top || 0;
|
|
197
|
+
const lastThreadHeight = heights[lastThread.id] || 0;
|
|
198
|
+
const lastThreadOffset = offsets[lastThread.id] || 0;
|
|
199
|
+
editorMinHeight = lastThreadTop + lastThreadHeight + lastThreadOffset + 32;
|
|
200
|
+
}
|
|
201
|
+
return { offsets, minHeight: editorMinHeight };
|
|
188
202
|
};
|
|
189
|
-
const newOffsets = calculateAllOffsets();
|
|
203
|
+
const { offsets: newOffsets, minHeight } = calculateAllOffsets();
|
|
190
204
|
if (Object.keys(newOffsets).length > 0) {
|
|
191
205
|
setBoardOffsets(newOffsets);
|
|
192
206
|
}
|
|
193
|
-
|
|
207
|
+
setCanvasMinHeight(minHeight);
|
|
208
|
+
}, [
|
|
209
|
+
heights,
|
|
210
|
+
blockRefs,
|
|
211
|
+
isFloating,
|
|
212
|
+
threads,
|
|
213
|
+
selectedThread,
|
|
214
|
+
setCanvasMinHeight
|
|
215
|
+
]);
|
|
194
216
|
const hasThreads = Array.isArray(threads) && threads.length > 0;
|
|
195
217
|
if (!hasThreads && !isFloating) {
|
|
196
|
-
return
|
|
197
|
-
/* @__PURE__ */ jsx(
|
|
198
|
-
AddComment,
|
|
199
|
-
{
|
|
200
|
-
onSubmit: onAddReply,
|
|
201
|
-
showCommentBoard,
|
|
202
|
-
setShowCommentBoard,
|
|
203
|
-
commentSidebarRef
|
|
204
|
-
}
|
|
205
|
-
),
|
|
206
|
-
/* @__PURE__ */ jsx(Text, { as: "p", children: __("No notes available.") }),
|
|
207
|
-
/* @__PURE__ */ jsx(Text, { as: "p", variant: "muted", children: __("Only logged in users can see Notes.") })
|
|
208
|
-
] });
|
|
218
|
+
return null;
|
|
209
219
|
}
|
|
210
220
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
211
221
|
!isFloating && showCommentBoard && void 0 === blockCommentId && /* @__PURE__ */ jsx(
|
|
@@ -325,185 +335,181 @@ function Thread({
|
|
|
325
335
|
}
|
|
326
336
|
);
|
|
327
337
|
}
|
|
328
|
-
return (
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
349
|
-
if (event.key === "Enter" && event.currentTarget === event.target) {
|
|
350
|
-
if (isSelected) {
|
|
351
|
-
unselectThread();
|
|
352
|
-
} else {
|
|
353
|
-
handleCommentSelect();
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
if (event.key === "Escape") {
|
|
338
|
+
return /* @__PURE__ */ jsxs(
|
|
339
|
+
VStack,
|
|
340
|
+
{
|
|
341
|
+
className: clsx("editor-collab-sidebar-panel__thread", {
|
|
342
|
+
"is-selected": isSelected,
|
|
343
|
+
"is-floating": isFloating
|
|
344
|
+
}),
|
|
345
|
+
id: `comment-thread-${thread.id}`,
|
|
346
|
+
spacing: "3",
|
|
347
|
+
onClick: handleCommentSelect,
|
|
348
|
+
onMouseEnter,
|
|
349
|
+
onMouseLeave,
|
|
350
|
+
onFocus: onMouseEnter,
|
|
351
|
+
onBlur: onMouseLeave,
|
|
352
|
+
onKeyDown: (event) => {
|
|
353
|
+
if (event.defaultPrevented) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
if (event.key === "Enter" && event.currentTarget === event.target) {
|
|
357
|
+
if (isSelected) {
|
|
357
358
|
unselectThread();
|
|
358
|
-
|
|
359
|
+
} else {
|
|
360
|
+
handleCommentSelect();
|
|
359
361
|
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
362
|
+
}
|
|
363
|
+
if (event.key === "Escape") {
|
|
364
|
+
unselectThread();
|
|
365
|
+
focusCommentThread(thread.id, commentSidebarRef.current);
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
tabIndex: 0,
|
|
369
|
+
role: "treeitem",
|
|
370
|
+
"aria-label": ariaLabel,
|
|
371
|
+
"aria-expanded": isSelected,
|
|
372
|
+
ref: isFloating ? refs.setFloating : void 0,
|
|
373
|
+
style: isFloating ? { top: y } : void 0,
|
|
374
|
+
children: [
|
|
375
|
+
/* @__PURE__ */ jsx(
|
|
376
|
+
Button,
|
|
377
|
+
{
|
|
378
|
+
className: "editor-collab-sidebar-panel__skip-to-comment",
|
|
379
|
+
variant: "secondary",
|
|
380
|
+
size: "compact",
|
|
381
|
+
onClick: () => {
|
|
382
|
+
focusCommentThread(
|
|
383
|
+
thread.id,
|
|
384
|
+
commentSidebarRef.current,
|
|
385
|
+
"textarea"
|
|
386
|
+
);
|
|
387
|
+
},
|
|
388
|
+
children: __("Add new note")
|
|
389
|
+
}
|
|
390
|
+
),
|
|
391
|
+
!thread.blockClientId && /* @__PURE__ */ jsx(Text, { as: "p", weight: 500, variant: "muted", children: __("Original block deleted.") }),
|
|
392
|
+
/* @__PURE__ */ jsx(
|
|
393
|
+
CommentBoard,
|
|
394
|
+
{
|
|
395
|
+
thread,
|
|
396
|
+
isExpanded: isSelected,
|
|
397
|
+
onEdit: (params = {}) => {
|
|
398
|
+
const { status } = params;
|
|
399
|
+
onEditComment(params);
|
|
400
|
+
if (status === "approved") {
|
|
401
|
+
unselectThread();
|
|
375
402
|
focusCommentThread(
|
|
376
403
|
thread.id,
|
|
377
|
-
commentSidebarRef.current
|
|
378
|
-
"textarea"
|
|
404
|
+
commentSidebarRef.current
|
|
379
405
|
);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
onDelete: onCommentDelete,
|
|
409
|
+
reflowComments
|
|
410
|
+
}
|
|
411
|
+
),
|
|
412
|
+
isSelected && allReplies.map((reply) => /* @__PURE__ */ jsx(
|
|
413
|
+
CommentBoard,
|
|
414
|
+
{
|
|
415
|
+
thread: reply,
|
|
416
|
+
parent: thread,
|
|
417
|
+
isExpanded: isSelected,
|
|
418
|
+
onEdit: onEditComment,
|
|
419
|
+
onDelete: onCommentDelete,
|
|
420
|
+
reflowComments
|
|
421
|
+
},
|
|
422
|
+
reply.id
|
|
423
|
+
)),
|
|
424
|
+
!isSelected && restReplies.length > 0 && /* @__PURE__ */ jsx(HStack, { className: "editor-collab-sidebar-panel__more-reply-separator", children: /* @__PURE__ */ jsx(
|
|
425
|
+
Button,
|
|
426
|
+
{
|
|
427
|
+
size: "compact",
|
|
428
|
+
variant: "tertiary",
|
|
429
|
+
className: "editor-collab-sidebar-panel__more-reply-button",
|
|
430
|
+
onClick: () => {
|
|
431
|
+
setSelectedThread(thread.id);
|
|
432
|
+
focusCommentThread(
|
|
433
|
+
thread.id,
|
|
434
|
+
commentSidebarRef.current
|
|
435
|
+
);
|
|
436
|
+
},
|
|
437
|
+
children: sprintf(
|
|
438
|
+
// translators: %s: number of replies.
|
|
439
|
+
_n(
|
|
440
|
+
"%s more reply",
|
|
441
|
+
"%s more replies",
|
|
442
|
+
restReplies.length
|
|
443
|
+
),
|
|
444
|
+
restReplies.length
|
|
445
|
+
)
|
|
446
|
+
}
|
|
447
|
+
) }),
|
|
448
|
+
!isSelected && lastReply && /* @__PURE__ */ jsx(
|
|
449
|
+
CommentBoard,
|
|
450
|
+
{
|
|
451
|
+
thread: lastReply,
|
|
452
|
+
parent: thread,
|
|
453
|
+
isExpanded: isSelected,
|
|
454
|
+
onEdit: onEditComment,
|
|
455
|
+
onDelete: onCommentDelete,
|
|
456
|
+
reflowComments
|
|
457
|
+
}
|
|
458
|
+
),
|
|
459
|
+
isSelected && /* @__PURE__ */ jsxs(VStack, { spacing: "2", role: "treeitem", children: [
|
|
460
|
+
/* @__PURE__ */ jsx(HStack, { alignment: "left", spacing: "3", justify: "flex-start", children: /* @__PURE__ */ jsx(CommentAuthorInfo, {}) }),
|
|
461
|
+
/* @__PURE__ */ jsx(VStack, { spacing: "2", children: /* @__PURE__ */ jsx(
|
|
462
|
+
CommentForm,
|
|
387
463
|
{
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
464
|
+
onSubmit: (inputComment) => {
|
|
465
|
+
if ("approved" === thread.status) {
|
|
466
|
+
onEditComment({
|
|
467
|
+
id: thread.id,
|
|
468
|
+
status: "hold",
|
|
469
|
+
content: inputComment
|
|
470
|
+
});
|
|
471
|
+
} else {
|
|
472
|
+
onAddReply({
|
|
473
|
+
content: inputComment,
|
|
474
|
+
parent: thread.id
|
|
475
|
+
});
|
|
399
476
|
}
|
|
400
477
|
},
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
),
|
|
405
|
-
isSelected && allReplies.map((reply) => /* @__PURE__ */ jsx(
|
|
406
|
-
CommentBoard,
|
|
407
|
-
{
|
|
408
|
-
thread: reply,
|
|
409
|
-
parent: thread,
|
|
410
|
-
isExpanded: isSelected,
|
|
411
|
-
onEdit: onEditComment,
|
|
412
|
-
onDelete: onCommentDelete,
|
|
413
|
-
reflowComments
|
|
414
|
-
},
|
|
415
|
-
reply.id
|
|
416
|
-
)),
|
|
417
|
-
!isSelected && restReplies.length > 0 && /* @__PURE__ */ jsx(HStack, { className: "editor-collab-sidebar-panel__more-reply-separator", children: /* @__PURE__ */ jsx(
|
|
418
|
-
Button,
|
|
419
|
-
{
|
|
420
|
-
size: "compact",
|
|
421
|
-
variant: "tertiary",
|
|
422
|
-
className: "editor-collab-sidebar-panel__more-reply-button",
|
|
423
|
-
onClick: () => {
|
|
424
|
-
setSelectedThread(thread.id);
|
|
478
|
+
onCancel: (event) => {
|
|
479
|
+
event.stopPropagation();
|
|
480
|
+
unselectThread();
|
|
425
481
|
focusCommentThread(
|
|
426
482
|
thread.id,
|
|
427
483
|
commentSidebarRef.current
|
|
428
484
|
);
|
|
429
485
|
},
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
)
|
|
439
|
-
}
|
|
440
|
-
) }),
|
|
441
|
-
!isSelected && lastReply && /* @__PURE__ */ jsx(
|
|
442
|
-
CommentBoard,
|
|
443
|
-
{
|
|
444
|
-
thread: lastReply,
|
|
445
|
-
parent: thread,
|
|
446
|
-
isExpanded: isSelected,
|
|
447
|
-
onEdit: onEditComment,
|
|
448
|
-
onDelete: onCommentDelete,
|
|
486
|
+
submitButtonText: "approved" === thread.status ? __("Reopen & Reply") : __("Reply"),
|
|
487
|
+
rows: "approved" === thread.status ? 2 : 4,
|
|
488
|
+
labelText: sprintf(
|
|
489
|
+
// translators: %1$s: note identifier, %2$s: author name
|
|
490
|
+
__("Reply to note %1$s by %2$s"),
|
|
491
|
+
thread.id,
|
|
492
|
+
thread.author_name
|
|
493
|
+
),
|
|
449
494
|
reflowComments
|
|
450
495
|
}
|
|
451
|
-
)
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
},
|
|
471
|
-
onCancel: (event) => {
|
|
472
|
-
event.stopPropagation();
|
|
473
|
-
unselectThread();
|
|
474
|
-
focusCommentThread(
|
|
475
|
-
thread.id,
|
|
476
|
-
commentSidebarRef.current
|
|
477
|
-
);
|
|
478
|
-
},
|
|
479
|
-
submitButtonText: "approved" === thread.status ? __("Reopen & Reply") : __("Reply"),
|
|
480
|
-
rows: "approved" === thread.status ? 2 : 4,
|
|
481
|
-
labelText: sprintf(
|
|
482
|
-
// translators: %1$s: note identifier, %2$s: author name
|
|
483
|
-
__("Reply to note %1$s by %2$s"),
|
|
484
|
-
thread.id,
|
|
485
|
-
thread.author_name
|
|
486
|
-
),
|
|
487
|
-
reflowComments
|
|
488
|
-
}
|
|
489
|
-
) })
|
|
490
|
-
] }),
|
|
491
|
-
!!thread.blockClientId && /* @__PURE__ */ jsx(
|
|
492
|
-
Button,
|
|
493
|
-
{
|
|
494
|
-
className: "editor-collab-sidebar-panel__skip-to-block",
|
|
495
|
-
variant: "secondary",
|
|
496
|
-
size: "compact",
|
|
497
|
-
onClick: (event) => {
|
|
498
|
-
event.stopPropagation();
|
|
499
|
-
relatedBlockElement?.focus();
|
|
500
|
-
},
|
|
501
|
-
children: __("Back to block")
|
|
502
|
-
}
|
|
503
|
-
)
|
|
504
|
-
]
|
|
505
|
-
}
|
|
506
|
-
)
|
|
496
|
+
) })
|
|
497
|
+
] }),
|
|
498
|
+
!!thread.blockClientId && /* @__PURE__ */ jsx(
|
|
499
|
+
Button,
|
|
500
|
+
{
|
|
501
|
+
className: "editor-collab-sidebar-panel__skip-to-block",
|
|
502
|
+
variant: "secondary",
|
|
503
|
+
size: "compact",
|
|
504
|
+
onClick: (event) => {
|
|
505
|
+
event.stopPropagation();
|
|
506
|
+
relatedBlockElement?.focus();
|
|
507
|
+
},
|
|
508
|
+
children: __("Back to block")
|
|
509
|
+
}
|
|
510
|
+
)
|
|
511
|
+
]
|
|
512
|
+
}
|
|
507
513
|
);
|
|
508
514
|
}
|
|
509
515
|
const CommentBoard = ({
|
|
@@ -516,6 +522,7 @@ const CommentBoard = ({
|
|
|
516
522
|
}) => {
|
|
517
523
|
const [actionState, setActionState] = useState(false);
|
|
518
524
|
const [showConfirmDialog, setShowConfirmDialog] = useState(false);
|
|
525
|
+
const actionButtonRef = useRef(null);
|
|
519
526
|
const handleConfirmDelete = () => {
|
|
520
527
|
onDelete(thread);
|
|
521
528
|
setActionState(false);
|
|
@@ -524,6 +531,7 @@ const CommentBoard = ({
|
|
|
524
531
|
const handleCancel = () => {
|
|
525
532
|
setActionState(false);
|
|
526
533
|
setShowConfirmDialog(false);
|
|
534
|
+
actionButtonRef.current?.focus();
|
|
527
535
|
};
|
|
528
536
|
const isResolutionComment = thread.type === "note" && thread.meta && (thread.meta._wp_note_status === "resolved" || thread.meta._wp_note_status === "reopen");
|
|
529
537
|
const actions = [
|
|
@@ -555,131 +563,140 @@ const CommentBoard = ({
|
|
|
555
563
|
];
|
|
556
564
|
const canResolve = thread.parent === 0;
|
|
557
565
|
const moreActions = parent?.status !== "approved" ? actions.filter((item) => item.isEligible(thread)) : [];
|
|
558
|
-
return /* @__PURE__ */ jsxs(
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
566
|
+
return /* @__PURE__ */ jsxs(
|
|
567
|
+
VStack,
|
|
568
|
+
{
|
|
569
|
+
spacing: "2",
|
|
570
|
+
role: thread.parent !== 0 ? "treeitem" : void 0,
|
|
571
|
+
children: [
|
|
572
|
+
/* @__PURE__ */ jsxs(HStack, { alignment: "left", spacing: "3", justify: "flex-start", children: [
|
|
573
|
+
/* @__PURE__ */ jsx(
|
|
574
|
+
CommentAuthorInfo,
|
|
575
|
+
{
|
|
576
|
+
avatar: thread?.author_avatar_urls?.[48],
|
|
577
|
+
name: thread?.author_name,
|
|
578
|
+
date: thread?.date,
|
|
579
|
+
userId: thread?.author
|
|
580
|
+
}
|
|
581
|
+
),
|
|
582
|
+
isExpanded && /* @__PURE__ */ jsx(
|
|
583
|
+
FlexItem,
|
|
584
|
+
{
|
|
585
|
+
className: "editor-collab-sidebar-panel__comment-status",
|
|
586
|
+
onClick: (event) => {
|
|
587
|
+
event.stopPropagation();
|
|
588
|
+
},
|
|
589
|
+
children: /* @__PURE__ */ jsxs(HStack, { spacing: "0", children: [
|
|
590
|
+
canResolve && /* @__PURE__ */ jsx(
|
|
591
|
+
Button,
|
|
592
|
+
{
|
|
593
|
+
label: _x(
|
|
594
|
+
"Resolve",
|
|
595
|
+
"Mark note as resolved"
|
|
596
|
+
),
|
|
597
|
+
size: "small",
|
|
598
|
+
icon: published,
|
|
599
|
+
disabled: thread.status === "approved",
|
|
600
|
+
accessibleWhenDisabled: thread.status === "approved",
|
|
601
|
+
onClick: () => {
|
|
602
|
+
onEdit({
|
|
603
|
+
id: thread.id,
|
|
604
|
+
status: "approved"
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
}
|
|
583
608
|
),
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
accessibleWhenDisabled: thread.status === "approved",
|
|
588
|
-
onClick: () => {
|
|
589
|
-
onEdit({
|
|
590
|
-
id: thread.id,
|
|
591
|
-
status: "approved"
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
),
|
|
596
|
-
/* @__PURE__ */ jsxs(Menu, { placement: "bottom-end", children: [
|
|
597
|
-
/* @__PURE__ */ jsx(
|
|
598
|
-
Menu.TriggerButton,
|
|
599
|
-
{
|
|
600
|
-
render: /* @__PURE__ */ jsx(
|
|
601
|
-
Button,
|
|
609
|
+
/* @__PURE__ */ jsxs(Menu, { placement: "bottom-end", children: [
|
|
610
|
+
/* @__PURE__ */ jsx(
|
|
611
|
+
Menu.TriggerButton,
|
|
602
612
|
{
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
613
|
+
render: /* @__PURE__ */ jsx(
|
|
614
|
+
Button,
|
|
615
|
+
{
|
|
616
|
+
ref: actionButtonRef,
|
|
617
|
+
size: "small",
|
|
618
|
+
icon: moreVertical,
|
|
619
|
+
label: __("Actions"),
|
|
620
|
+
disabled: !moreActions.length,
|
|
621
|
+
accessibleWhenDisabled: true
|
|
622
|
+
}
|
|
623
|
+
)
|
|
608
624
|
}
|
|
609
|
-
)
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
RawHTML,
|
|
648
|
-
{
|
|
649
|
-
className: clsx(
|
|
650
|
-
"editor-collab-sidebar-panel__user-comment",
|
|
625
|
+
),
|
|
626
|
+
/* @__PURE__ */ jsx(Menu.Popover, { children: moreActions.map((action) => /* @__PURE__ */ jsx(
|
|
627
|
+
Menu.Item,
|
|
628
|
+
{
|
|
629
|
+
onClick: () => action.onClick(),
|
|
630
|
+
children: /* @__PURE__ */ jsx(Menu.ItemLabel, { children: action.title })
|
|
631
|
+
},
|
|
632
|
+
action.id
|
|
633
|
+
)) })
|
|
634
|
+
] })
|
|
635
|
+
] })
|
|
636
|
+
}
|
|
637
|
+
)
|
|
638
|
+
] }),
|
|
639
|
+
"edit" === actionState ? /* @__PURE__ */ jsx(
|
|
640
|
+
CommentForm,
|
|
641
|
+
{
|
|
642
|
+
onSubmit: (value) => {
|
|
643
|
+
onEdit({
|
|
644
|
+
id: thread.id,
|
|
645
|
+
content: value
|
|
646
|
+
});
|
|
647
|
+
setActionState(false);
|
|
648
|
+
actionButtonRef.current?.focus();
|
|
649
|
+
},
|
|
650
|
+
onCancel: () => handleCancel(),
|
|
651
|
+
thread,
|
|
652
|
+
submitButtonText: _x("Update", "verb"),
|
|
653
|
+
labelText: sprintf(
|
|
654
|
+
// translators: %1$s: note identifier, %2$s: author name.
|
|
655
|
+
__("Edit note %1$s by %2$s"),
|
|
656
|
+
thread.id,
|
|
657
|
+
thread.author_name
|
|
658
|
+
),
|
|
659
|
+
reflowComments
|
|
660
|
+
}
|
|
661
|
+
) : /* @__PURE__ */ jsx(
|
|
662
|
+
RawHTML,
|
|
651
663
|
{
|
|
652
|
-
|
|
664
|
+
className: clsx(
|
|
665
|
+
"editor-collab-sidebar-panel__user-comment",
|
|
666
|
+
{
|
|
667
|
+
"editor-collab-sidebar-panel__resolution-text": isResolutionComment
|
|
668
|
+
}
|
|
669
|
+
),
|
|
670
|
+
children: isResolutionComment ? (() => {
|
|
671
|
+
const actionText = thread.meta._wp_note_status === "resolved" ? __("Marked as resolved") : __("Reopened");
|
|
672
|
+
const content = thread?.content?.raw;
|
|
673
|
+
if (content && typeof content === "string" && content.trim() !== "") {
|
|
674
|
+
return sprintf(
|
|
675
|
+
// translators: %1$s: action label ("Marked as resolved" or "Reopened"); %2$s: note text.
|
|
676
|
+
__("%1$s: %2$s"),
|
|
677
|
+
actionText,
|
|
678
|
+
content
|
|
679
|
+
);
|
|
680
|
+
}
|
|
681
|
+
return actionText;
|
|
682
|
+
})() : thread?.content?.rendered
|
|
653
683
|
}
|
|
654
684
|
),
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
)
|
|
685
|
+
"delete" === actionState && /* @__PURE__ */ jsx(
|
|
686
|
+
ConfirmDialog,
|
|
687
|
+
{
|
|
688
|
+
isOpen: showConfirmDialog,
|
|
689
|
+
onConfirm: handleConfirmDelete,
|
|
690
|
+
onCancel: handleCancel,
|
|
691
|
+
confirmButtonText: __("Delete"),
|
|
692
|
+
children: __(
|
|
693
|
+
"Are you sure you want to delete this note? This will also delete all of this note's replies."
|
|
694
|
+
)
|
|
665
695
|
}
|
|
666
|
-
return actionText;
|
|
667
|
-
})() : thread?.content?.rendered
|
|
668
|
-
}
|
|
669
|
-
),
|
|
670
|
-
"delete" === actionState && /* @__PURE__ */ jsx(
|
|
671
|
-
ConfirmDialog,
|
|
672
|
-
{
|
|
673
|
-
isOpen: showConfirmDialog,
|
|
674
|
-
onConfirm: handleConfirmDelete,
|
|
675
|
-
onCancel: handleCancel,
|
|
676
|
-
confirmButtonText: __("Delete"),
|
|
677
|
-
children: __(
|
|
678
|
-
"Are you sure you want to delete this note? This will also delete all of this note's replies."
|
|
679
696
|
)
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
697
|
+
]
|
|
698
|
+
}
|
|
699
|
+
);
|
|
683
700
|
};
|
|
684
701
|
var comments_default = Comments;
|
|
685
702
|
export {
|