@wordpress/editor 14.31.0 → 14.31.1-next.233ccab9b.0
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/components/collab-sidebar/add-comment.js +6 -2
- package/build/components/collab-sidebar/add-comment.js.map +1 -1
- package/build/components/collab-sidebar/comment-author-info.js +39 -11
- package/build/components/collab-sidebar/comment-author-info.js.map +1 -1
- package/build/components/collab-sidebar/comment-form.js +23 -19
- package/build/components/collab-sidebar/comment-form.js.map +1 -1
- package/build/components/collab-sidebar/comment-indicator-toolbar.js +7 -4
- package/build/components/collab-sidebar/comment-indicator-toolbar.js.map +1 -1
- package/build/components/collab-sidebar/comments.js +141 -86
- package/build/components/collab-sidebar/comments.js.map +1 -1
- package/build/components/collab-sidebar/hooks.js +96 -0
- package/build/components/collab-sidebar/hooks.js.map +1 -0
- package/build/components/collab-sidebar/index.js +44 -135
- package/build/components/collab-sidebar/index.js.map +1 -1
- package/build/components/collab-sidebar/utils.js +27 -27
- package/build/components/collab-sidebar/utils.js.map +1 -1
- package/build/components/header/index.js +5 -1
- package/build/components/header/index.js.map +1 -1
- package/build/components/post-type-support-check/index.js +12 -1
- package/build/components/post-type-support-check/index.js.map +1 -1
- package/build-module/components/collab-sidebar/add-comment.js +7 -3
- package/build-module/components/collab-sidebar/add-comment.js.map +1 -1
- package/build-module/components/collab-sidebar/comment-author-info.js +43 -15
- package/build-module/components/collab-sidebar/comment-author-info.js.map +1 -1
- package/build-module/components/collab-sidebar/comment-form.js +26 -22
- package/build-module/components/collab-sidebar/comment-form.js.map +1 -1
- package/build-module/components/collab-sidebar/comment-indicator-toolbar.js +8 -5
- package/build-module/components/collab-sidebar/comment-indicator-toolbar.js.map +1 -1
- package/build-module/components/collab-sidebar/comments.js +145 -91
- package/build-module/components/collab-sidebar/comments.js.map +1 -1
- package/build-module/components/collab-sidebar/hooks.js +89 -0
- package/build-module/components/collab-sidebar/hooks.js.map +1 -0
- package/build-module/components/collab-sidebar/index.js +47 -138
- package/build-module/components/collab-sidebar/index.js.map +1 -1
- package/build-module/components/collab-sidebar/utils.js +26 -26
- package/build-module/components/collab-sidebar/utils.js.map +1 -1
- package/build-module/components/header/index.js +5 -1
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/post-type-support-check/index.js +11 -1
- package/build-module/components/post-type-support-check/index.js.map +1 -1
- package/build-style/style-rtl.css +66 -9
- package/build-style/style.css +66 -9
- package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comment-author-info.d.ts +3 -1
- package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comment-form.d.ts +3 -5
- package/build-types/components/collab-sidebar/comment-form.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/comments.d.ts +1 -7
- package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/hooks.d.ts +6 -0
- package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/utils.d.ts +4 -7
- package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/post-type-support-check/index.d.ts.map +1 -1
- package/package.json +37 -37
- package/src/components/collab-sidebar/add-comment.js +5 -2
- package/src/components/collab-sidebar/comment-author-info.js +53 -27
- package/src/components/collab-sidebar/comment-form.js +25 -24
- package/src/components/collab-sidebar/comment-indicator-toolbar.js +16 -5
- package/src/components/collab-sidebar/comments.js +203 -164
- package/src/components/collab-sidebar/hooks.js +94 -0
- package/src/components/collab-sidebar/index.js +63 -174
- package/src/components/collab-sidebar/style.scss +98 -83
- package/src/components/collab-sidebar/utils.js +20 -31
- package/src/components/header/index.js +6 -3
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
- package/src/components/post-type-support-check/index.js +18 -1
- package/src/components/post-type-support-check/test/index.js +37 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -7,17 +7,25 @@ import clsx from 'clsx';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useState, RawHTML } from '@wordpress/element';
|
|
10
|
-
import { __experimentalHStack as HStack, __experimentalVStack as VStack, __experimentalConfirmDialog as ConfirmDialog, Button,
|
|
10
|
+
import { __experimentalHStack as HStack, __experimentalVStack as VStack, __experimentalConfirmDialog as ConfirmDialog, Button, privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
11
11
|
import { published, moreVertical } from '@wordpress/icons';
|
|
12
|
-
import { __, _x,
|
|
13
|
-
import { useSelect } from '@wordpress/data';
|
|
14
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
12
|
+
import { __, _x, sprintf, _n } from '@wordpress/i18n';
|
|
13
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
14
|
+
import { store as blockEditorStore, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Internal dependencies
|
|
18
18
|
*/
|
|
19
|
+
import { unlock } from '../../lock-unlock';
|
|
19
20
|
import CommentAuthorInfo from './comment-author-info';
|
|
20
21
|
import CommentForm from './comment-form';
|
|
22
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
23
|
+
const {
|
|
24
|
+
useBlockElement
|
|
25
|
+
} = unlock(blockEditorPrivateApis);
|
|
26
|
+
const {
|
|
27
|
+
Menu
|
|
28
|
+
} = unlock(componentsPrivateApis);
|
|
21
29
|
|
|
22
30
|
/**
|
|
23
31
|
* Renders the Comments component.
|
|
@@ -27,21 +35,14 @@ import CommentForm from './comment-form';
|
|
|
27
35
|
* @param {Function} props.onEditComment - The function to handle comment editing.
|
|
28
36
|
* @param {Function} props.onAddReply - The function to add a reply to a comment.
|
|
29
37
|
* @param {Function} props.onCommentDelete - The function to delete a comment.
|
|
30
|
-
* @param {Function} props.onCommentResolve - The function to mark a comment as resolved.
|
|
31
|
-
* @param {Function} props.onCommentReopen - The function to reopen a resolved comment.
|
|
32
|
-
* @param {boolean} props.showCommentBoard - Whether to show the comment board.
|
|
33
38
|
* @param {Function} props.setShowCommentBoard - The function to set the comment board visibility.
|
|
34
39
|
* @return {React.ReactNode} The rendered Comments component.
|
|
35
40
|
*/
|
|
36
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
37
41
|
export function Comments({
|
|
38
42
|
threads,
|
|
39
43
|
onEditComment,
|
|
40
44
|
onAddReply,
|
|
41
45
|
onCommentDelete,
|
|
42
|
-
onCommentResolve,
|
|
43
|
-
onCommentReopen,
|
|
44
|
-
showCommentBoard,
|
|
45
46
|
setShowCommentBoard
|
|
46
47
|
}) {
|
|
47
48
|
const {
|
|
@@ -51,89 +52,104 @@ export function Comments({
|
|
|
51
52
|
getBlockAttributes,
|
|
52
53
|
getSelectedBlockClientId
|
|
53
54
|
} = select(blockEditorStore);
|
|
54
|
-
const
|
|
55
|
+
const clientId = getSelectedBlockClientId();
|
|
55
56
|
return {
|
|
56
|
-
blockCommentId:
|
|
57
|
+
blockCommentId: clientId ? getBlockAttributes(clientId)?.blockCommentId : null
|
|
57
58
|
};
|
|
58
59
|
}, []);
|
|
59
|
-
const [focusThread, setFocusThread] = useState(
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
64
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
65
|
-
children: [
|
|
66
|
-
// If there are no comments, show a message indicating no comments are available.
|
|
67
|
-
(!Array.isArray(threads) || threads.length === 0) && /*#__PURE__*/_jsx(VStack, {
|
|
60
|
+
const [focusThread = blockCommentId, setFocusThread] = useState();
|
|
61
|
+
const hasThreads = Array.isArray(threads) && threads.length > 0;
|
|
62
|
+
if (!hasThreads) {
|
|
63
|
+
return /*#__PURE__*/_jsx(VStack, {
|
|
68
64
|
alignment: "left",
|
|
69
65
|
className: "editor-collab-sidebar-panel__thread",
|
|
70
66
|
justify: "flex-start",
|
|
71
|
-
spacing: "
|
|
67
|
+
spacing: "2",
|
|
72
68
|
children:
|
|
73
69
|
// translators: message displayed when there are no comments available
|
|
74
70
|
__('No comments available')
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
onCommentDelete: onCommentDelete,
|
|
87
|
-
onCommentResolve: onCommentResolve,
|
|
88
|
-
onCommentReopen: onCommentReopen,
|
|
89
|
-
onEditComment: onEditComment,
|
|
90
|
-
isFocused: focusThread === thread.id,
|
|
91
|
-
clearThreadFocus: clearThreadFocus,
|
|
92
|
-
setFocusThread: setFocusThread
|
|
93
|
-
})
|
|
94
|
-
}, thread.id))]
|
|
95
|
-
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return threads.map(thread => /*#__PURE__*/_jsx(Thread, {
|
|
74
|
+
thread: thread,
|
|
75
|
+
onAddReply: onAddReply,
|
|
76
|
+
onCommentDelete: onCommentDelete,
|
|
77
|
+
onEditComment: onEditComment,
|
|
78
|
+
isFocused: focusThread === thread.id,
|
|
79
|
+
setFocusThread: setFocusThread,
|
|
80
|
+
setShowCommentBoard: setShowCommentBoard
|
|
81
|
+
}, thread.id));
|
|
96
82
|
}
|
|
97
83
|
function Thread({
|
|
98
84
|
thread,
|
|
99
85
|
onEditComment,
|
|
100
86
|
onAddReply,
|
|
101
87
|
onCommentDelete,
|
|
102
|
-
onCommentResolve,
|
|
103
|
-
onCommentReopen,
|
|
104
88
|
isFocused,
|
|
105
|
-
|
|
106
|
-
|
|
89
|
+
setFocusThread,
|
|
90
|
+
setShowCommentBoard
|
|
107
91
|
}) {
|
|
108
|
-
|
|
92
|
+
const {
|
|
93
|
+
flashBlock
|
|
94
|
+
} = useDispatch(blockEditorStore);
|
|
95
|
+
const relatedBlockElement = useBlockElement(thread.blockClientId);
|
|
96
|
+
const handleCommentSelect = ({
|
|
97
|
+
id,
|
|
98
|
+
blockClientId
|
|
99
|
+
}) => {
|
|
100
|
+
setShowCommentBoard(false);
|
|
101
|
+
setFocusThread(id);
|
|
102
|
+
if (blockClientId && relatedBlockElement) {
|
|
103
|
+
relatedBlockElement.scrollIntoView({
|
|
104
|
+
behavior: 'instant',
|
|
105
|
+
block: 'center'
|
|
106
|
+
});
|
|
107
|
+
flashBlock(blockClientId);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const clearThreadFocus = () => {
|
|
111
|
+
setFocusThread(null);
|
|
112
|
+
setShowCommentBoard(false);
|
|
113
|
+
};
|
|
114
|
+
const replies = thread?.reply;
|
|
115
|
+
const lastReply = !!replies.length ? replies[replies.length - 1] : undefined;
|
|
116
|
+
const restReplies = !!replies.length ? replies.slice(0, -1) : [];
|
|
117
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
118
|
+
className: clsx('editor-collab-sidebar-panel__thread', {
|
|
119
|
+
'editor-collab-sidebar-panel__focus-thread': isFocused
|
|
120
|
+
}),
|
|
121
|
+
id: thread.id,
|
|
122
|
+
spacing: "2",
|
|
123
|
+
onClick: () => handleCommentSelect(thread),
|
|
109
124
|
children: [/*#__PURE__*/_jsx(CommentBoard, {
|
|
110
125
|
thread: thread,
|
|
111
|
-
onResolve: onCommentResolve,
|
|
112
|
-
onReopen: onCommentReopen,
|
|
113
126
|
onEdit: onEditComment,
|
|
114
127
|
onDelete: onCommentDelete,
|
|
115
128
|
status: thread.status
|
|
116
|
-
}),
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
129
|
+
}), isFocused && replies.map(reply => /*#__PURE__*/_jsx(VStack, {
|
|
130
|
+
className: "editor-collab-sidebar-panel__child-thread",
|
|
131
|
+
id: reply.id,
|
|
132
|
+
spacing: "2",
|
|
133
|
+
children: /*#__PURE__*/_jsx(CommentBoard, {
|
|
134
|
+
thread: reply,
|
|
135
|
+
onEdit: 'approved' !== thread.status ? onEditComment : undefined,
|
|
136
|
+
onDelete: 'approved' !== thread.status ? onCommentDelete : undefined
|
|
137
|
+
})
|
|
138
|
+
}, reply.id)), !isFocused && restReplies.length > 0 && /*#__PURE__*/_jsx(HStack, {
|
|
139
|
+
className: "editor-collab-sidebar-panel__more-reply-separator",
|
|
140
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
141
|
+
size: "compact",
|
|
142
|
+
variant: "tertiary",
|
|
143
|
+
className: "editor-collab-sidebar-panel__more-reply-button",
|
|
121
144
|
onClick: () => setFocusThread(thread.id),
|
|
122
145
|
children: sprintf(
|
|
123
146
|
// translators: %s: number of replies.
|
|
124
|
-
_n('%s more reply', '%s more replies',
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
thread: reply,
|
|
131
|
-
onEdit: onEditComment,
|
|
132
|
-
onDelete: onCommentDelete
|
|
133
|
-
}), 'approved' === thread.status && /*#__PURE__*/_jsx(CommentBoard, {
|
|
134
|
-
thread: reply
|
|
135
|
-
})]
|
|
136
|
-
}, reply.id))]
|
|
147
|
+
_n('%s more reply', '%s more replies', restReplies.length), restReplies.length)
|
|
148
|
+
})
|
|
149
|
+
}), !isFocused && lastReply && /*#__PURE__*/_jsx(CommentBoard, {
|
|
150
|
+
thread: lastReply,
|
|
151
|
+
onEdit: 'approved' !== thread.status ? onEditComment : undefined,
|
|
152
|
+
onDelete: 'approved' !== thread.status ? onCommentDelete : undefined
|
|
137
153
|
}), isFocused && /*#__PURE__*/_jsxs(VStack, {
|
|
138
154
|
className: "editor-collab-sidebar-panel__child-thread",
|
|
139
155
|
spacing: "2",
|
|
@@ -143,22 +159,29 @@ function Thread({
|
|
|
143
159
|
justify: "flex-start",
|
|
144
160
|
children: /*#__PURE__*/_jsx(CommentAuthorInfo, {})
|
|
145
161
|
}), /*#__PURE__*/_jsx(VStack, {
|
|
146
|
-
spacing: "
|
|
147
|
-
className: "editor-collab-sidebar-panel__comment-field",
|
|
162
|
+
spacing: "2",
|
|
148
163
|
children: /*#__PURE__*/_jsx(CommentForm, {
|
|
149
164
|
onSubmit: inputComment => {
|
|
150
165
|
if ('approved' === thread.status) {
|
|
151
|
-
|
|
166
|
+
onEditComment({
|
|
167
|
+
id: thread.id,
|
|
168
|
+
status: 'hold'
|
|
169
|
+
});
|
|
152
170
|
}
|
|
153
|
-
onAddReply(
|
|
171
|
+
onAddReply({
|
|
172
|
+
content: inputComment,
|
|
173
|
+
parent: thread.id
|
|
174
|
+
});
|
|
154
175
|
},
|
|
155
176
|
onCancel: event => {
|
|
156
177
|
event.stopPropagation(); // Prevent the parent onClick from being triggered
|
|
157
178
|
clearThreadFocus();
|
|
158
179
|
},
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
180
|
+
submitButtonText: 'approved' === thread.status ? __('Reopen & Reply') : __('Reply'),
|
|
181
|
+
rows: 'approved' === thread.status ? 2 : 4,
|
|
182
|
+
labelText: sprintf(
|
|
183
|
+
// translators: %1$s: comment identifier, %2$s: author name
|
|
184
|
+
__('Reply to Comment %1$s by %2$s'), thread.id, thread?.author_name || 'Unknown')
|
|
162
185
|
})
|
|
163
186
|
})]
|
|
164
187
|
})]
|
|
@@ -166,8 +189,6 @@ function Thread({
|
|
|
166
189
|
}
|
|
167
190
|
const CommentBoard = ({
|
|
168
191
|
thread,
|
|
169
|
-
onResolve,
|
|
170
|
-
onReopen,
|
|
171
192
|
onEdit,
|
|
172
193
|
onDelete,
|
|
173
194
|
status
|
|
@@ -175,7 +196,7 @@ const CommentBoard = ({
|
|
|
175
196
|
const [actionState, setActionState] = useState(false);
|
|
176
197
|
const [showConfirmDialog, setShowConfirmDialog] = useState(false);
|
|
177
198
|
const handleConfirmDelete = () => {
|
|
178
|
-
onDelete(thread
|
|
199
|
+
onDelete(thread);
|
|
179
200
|
setActionState(false);
|
|
180
201
|
setShowConfirmDialog(false);
|
|
181
202
|
};
|
|
@@ -184,22 +205,29 @@ const CommentBoard = ({
|
|
|
184
205
|
setShowConfirmDialog(false);
|
|
185
206
|
};
|
|
186
207
|
const actions = [onEdit && status !== 'approved' && {
|
|
208
|
+
id: 'edit',
|
|
187
209
|
title: _x('Edit', 'Edit comment'),
|
|
188
210
|
onClick: () => {
|
|
189
211
|
setActionState('edit');
|
|
190
212
|
}
|
|
191
213
|
}, onDelete && {
|
|
214
|
+
id: 'delete',
|
|
192
215
|
title: _x('Delete', 'Delete comment'),
|
|
193
216
|
onClick: () => {
|
|
194
217
|
setActionState('delete');
|
|
195
218
|
setShowConfirmDialog(true);
|
|
196
219
|
}
|
|
197
|
-
},
|
|
220
|
+
}, onEdit && status === 'approved' && {
|
|
221
|
+
id: 'reopen',
|
|
198
222
|
title: _x('Reopen', 'Reopen comment'),
|
|
199
223
|
onClick: () => {
|
|
200
|
-
|
|
224
|
+
onEdit({
|
|
225
|
+
id: thread.id,
|
|
226
|
+
status: 'hold'
|
|
227
|
+
});
|
|
201
228
|
}
|
|
202
229
|
}];
|
|
230
|
+
const canResolve = thread?.parent === 0;
|
|
203
231
|
const moreActions = actions.filter(item => item?.onClick);
|
|
204
232
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
205
233
|
children: [/*#__PURE__*/_jsxs(HStack, {
|
|
@@ -209,38 +237,64 @@ const CommentBoard = ({
|
|
|
209
237
|
children: [/*#__PURE__*/_jsx(CommentAuthorInfo, {
|
|
210
238
|
avatar: thread?.author_avatar_urls?.[48],
|
|
211
239
|
name: thread?.author_name,
|
|
212
|
-
date: thread?.date
|
|
240
|
+
date: thread?.date,
|
|
241
|
+
userId: thread?.author
|
|
213
242
|
}), /*#__PURE__*/_jsx("span", {
|
|
214
243
|
className: "editor-collab-sidebar-panel__comment-status",
|
|
215
244
|
children: /*#__PURE__*/_jsxs(HStack, {
|
|
216
245
|
alignment: "right",
|
|
217
246
|
justify: "flex-end",
|
|
218
247
|
spacing: "0",
|
|
219
|
-
children: [
|
|
248
|
+
children: [canResolve && /*#__PURE__*/_jsx(Button, {
|
|
220
249
|
label: _x('Resolve', 'Mark comment as resolved'),
|
|
221
250
|
size: "small",
|
|
222
251
|
icon: published,
|
|
223
252
|
disabled: status === 'approved',
|
|
224
253
|
accessibleWhenDisabled: status === 'approved',
|
|
225
254
|
onClick: () => {
|
|
226
|
-
|
|
255
|
+
onEdit({
|
|
256
|
+
id: thread.id,
|
|
257
|
+
status: 'approved'
|
|
258
|
+
});
|
|
227
259
|
}
|
|
228
|
-
}),
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
260
|
+
}), /*#__PURE__*/_jsxs(Menu, {
|
|
261
|
+
placement: "bottom-end",
|
|
262
|
+
children: [/*#__PURE__*/_jsx(Menu.TriggerButton, {
|
|
263
|
+
render: /*#__PURE__*/_jsx(Button, {
|
|
264
|
+
size: "small",
|
|
265
|
+
icon: moreVertical,
|
|
266
|
+
label: __('Actions'),
|
|
267
|
+
disabled: !moreActions.length,
|
|
268
|
+
accessibleWhenDisabled: true
|
|
269
|
+
})
|
|
270
|
+
}), /*#__PURE__*/_jsx(Menu.Popover, {
|
|
271
|
+
children: moreActions.map(action => /*#__PURE__*/_jsx(Menu.Item, {
|
|
272
|
+
onClick: event => {
|
|
273
|
+
event.stopPropagation();
|
|
274
|
+
action.onClick();
|
|
275
|
+
},
|
|
276
|
+
children: /*#__PURE__*/_jsx(Menu.ItemLabel, {
|
|
277
|
+
children: action.title
|
|
278
|
+
})
|
|
279
|
+
}, action.id))
|
|
280
|
+
})]
|
|
233
281
|
})]
|
|
234
282
|
})
|
|
235
283
|
})]
|
|
236
284
|
}), 'edit' === actionState ? /*#__PURE__*/_jsx(CommentForm, {
|
|
237
285
|
onSubmit: value => {
|
|
238
|
-
onEdit(
|
|
286
|
+
onEdit({
|
|
287
|
+
id: thread.id,
|
|
288
|
+
content: value
|
|
289
|
+
});
|
|
239
290
|
setActionState(false);
|
|
240
291
|
},
|
|
241
292
|
onCancel: () => handleCancel(),
|
|
242
293
|
thread: thread,
|
|
243
|
-
submitButtonText: _x('Update', 'verb')
|
|
294
|
+
submitButtonText: _x('Update', 'verb'),
|
|
295
|
+
labelText: sprintf(
|
|
296
|
+
// translators: %1$s: comment identifier, %2$s: author name.
|
|
297
|
+
__('Edit Comment %1$s by %2$s'), thread.id, thread?.author_name || 'Unknown')
|
|
244
298
|
}) : /*#__PURE__*/_jsx(RawHTML, {
|
|
245
299
|
className: "editor-collab-sidebar-panel__user-comment",
|
|
246
300
|
children: thread?.content?.rendered
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","useState","RawHTML","__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalConfirmDialog","ConfirmDialog","Button","DropdownMenu","published","moreVertical","__","_x","_n","sprintf","useSelect","store","blockEditorStore","CommentAuthorInfo","CommentForm","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","Comments","threads","onEditComment","onAddReply","onCommentDelete","onCommentResolve","onCommentReopen","showCommentBoard","setShowCommentBoard","blockCommentId","select","getBlockAttributes","getSelectedBlockClientId","_clientId","focusThread","setFocusThread","clearThreadFocus","children","Array","isArray","length","alignment","className","justify","spacing","map","thread","id","onClick","Thread","isFocused","CommentBoard","onResolve","onReopen","onEdit","onDelete","status","reply","__next40pxDefaultSize","variant","onSubmit","inputComment","onCancel","event","stopPropagation","placeholderText","submitButtonText","rows","actionState","setActionState","showConfirmDialog","setShowConfirmDialog","handleConfirmDelete","handleCancel","actions","title","moreActions","filter","item","avatar","author_avatar_urls","name","author_name","date","parent","label","size","icon","disabled","accessibleWhenDisabled","controls","value","content","rendered","isOpen","onConfirm","confirmButtonText"],"sources":["@wordpress/editor/src/components/collab-sidebar/comments.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useState, RawHTML } from '@wordpress/element';\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalConfirmDialog as ConfirmDialog,\n\tButton,\n\tDropdownMenu,\n} from '@wordpress/components';\nimport { published, moreVertical } from '@wordpress/icons';\nimport { __, _x, _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport CommentAuthorInfo from './comment-author-info';\nimport CommentForm from './comment-form';\n\n/**\n * Renders the Comments component.\n *\n * @param {Object} props - The component props.\n * @param {Array} props.threads - The array of comment threads.\n * @param {Function} props.onEditComment - The function to handle comment editing.\n * @param {Function} props.onAddReply - The function to add a reply to a comment.\n * @param {Function} props.onCommentDelete - The function to delete a comment.\n * @param {Function} props.onCommentResolve - The function to mark a comment as resolved.\n * @param {Function} props.onCommentReopen - The function to reopen a resolved comment.\n * @param {boolean} props.showCommentBoard - Whether to show the comment board.\n * @param {Function} props.setShowCommentBoard - The function to set the comment board visibility.\n * @return {React.ReactNode} The rendered Comments component.\n */\nexport function Comments( {\n\tthreads,\n\tonEditComment,\n\tonAddReply,\n\tonCommentDelete,\n\tonCommentResolve,\n\tonCommentReopen,\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n} ) {\n\tconst { blockCommentId } = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\t\tselect( blockEditorStore );\n\t\tconst _clientId = getSelectedBlockClientId();\n\n\t\treturn {\n\t\t\tblockCommentId: _clientId\n\t\t\t\t? getBlockAttributes( _clientId )?.blockCommentId\n\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst [ focusThread, setFocusThread ] = useState(\n\t\tshowCommentBoard && blockCommentId ? blockCommentId : null\n\t);\n\n\tconst clearThreadFocus = () => {\n\t\tsetFocusThread( null );\n\t\tsetShowCommentBoard( false );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t{\n\t\t\t\t// If there are no comments, show a message indicating no comments are available.\n\t\t\t\t( ! Array.isArray( threads ) || threads.length === 0 ) && (\n\t\t\t\t\t<VStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__thread\"\n\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t\tspacing=\"3\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// translators: message displayed when there are no comments available\n\t\t\t\t\t\t\t__( 'No comments available' )\n\t\t\t\t\t\t}\n\t\t\t\t\t</VStack>\n\t\t\t\t)\n\t\t\t}\n\t\t\t{ Array.isArray( threads ) &&\n\t\t\t\tthreads.length > 0 &&\n\t\t\t\tthreads.map( ( thread ) => (\n\t\t\t\t\t<VStack\n\t\t\t\t\t\tkey={ thread.id }\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'editor-collab-sidebar-panel__thread',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'editor-collab-sidebar-panel__active-thread':\n\t\t\t\t\t\t\t\t\tblockCommentId &&\n\t\t\t\t\t\t\t\t\tblockCommentId === thread.id,\n\t\t\t\t\t\t\t\t'editor-collab-sidebar-panel__focus-thread':\n\t\t\t\t\t\t\t\t\tfocusThread && focusThread === thread.id,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tid={ thread.id }\n\t\t\t\t\t\tspacing=\"3\"\n\t\t\t\t\t\tonClick={ () => setFocusThread( thread.id ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Thread\n\t\t\t\t\t\t\tthread={ thread }\n\t\t\t\t\t\t\tonAddReply={ onAddReply }\n\t\t\t\t\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\t\t\t\t\tonCommentResolve={ onCommentResolve }\n\t\t\t\t\t\t\tonCommentReopen={ onCommentReopen }\n\t\t\t\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\t\t\t\tisFocused={ focusThread === thread.id }\n\t\t\t\t\t\t\tclearThreadFocus={ clearThreadFocus }\n\t\t\t\t\t\t\tsetFocusThread={ setFocusThread }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction Thread( {\n\tthread,\n\tonEditComment,\n\tonAddReply,\n\tonCommentDelete,\n\tonCommentResolve,\n\tonCommentReopen,\n\tisFocused,\n\tclearThreadFocus,\n\tsetFocusThread,\n} ) {\n\treturn (\n\t\t<>\n\t\t\t<CommentBoard\n\t\t\t\tthread={ thread }\n\t\t\t\tonResolve={ onCommentResolve }\n\t\t\t\tonReopen={ onCommentReopen }\n\t\t\t\tonEdit={ onEditComment }\n\t\t\t\tonDelete={ onCommentDelete }\n\t\t\t\tstatus={ thread.status }\n\t\t\t/>\n\t\t\t{ 0 < thread?.reply?.length && (\n\t\t\t\t<>\n\t\t\t\t\t{ ! isFocused && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__show-more-reply\"\n\t\t\t\t\t\t\tonClick={ () => setFocusThread( thread.id ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: number of replies.\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'%s more reply',\n\t\t\t\t\t\t\t\t\t'%s more replies',\n\t\t\t\t\t\t\t\t\tthread?.reply?.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tthread?.reply?.length\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ isFocused &&\n\t\t\t\t\t\tthread.reply.map( ( reply ) => (\n\t\t\t\t\t\t\t<VStack\n\t\t\t\t\t\t\t\tkey={ reply.id }\n\t\t\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__child-thread\"\n\t\t\t\t\t\t\t\tid={ reply.id }\n\t\t\t\t\t\t\t\tspacing=\"2\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ 'approved' !== thread.status && (\n\t\t\t\t\t\t\t\t\t<CommentBoard\n\t\t\t\t\t\t\t\t\t\tthread={ reply }\n\t\t\t\t\t\t\t\t\t\tonEdit={ onEditComment }\n\t\t\t\t\t\t\t\t\t\tonDelete={ onCommentDelete }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ 'approved' === thread.status && (\n\t\t\t\t\t\t\t\t\t<CommentBoard thread={ reply } />\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t) ) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ isFocused && (\n\t\t\t\t<VStack\n\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__child-thread\"\n\t\t\t\t\tspacing=\"2\"\n\t\t\t\t>\n\t\t\t\t\t<HStack alignment=\"left\" spacing=\"3\" justify=\"flex-start\">\n\t\t\t\t\t\t<CommentAuthorInfo />\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<VStack\n\t\t\t\t\t\tspacing=\"3\"\n\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__comment-field\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<CommentForm\n\t\t\t\t\t\t\tonSubmit={ ( inputComment ) => {\n\t\t\t\t\t\t\t\tif ( 'approved' === thread.status ) {\n\t\t\t\t\t\t\t\t\tonCommentReopen( thread.id );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonAddReply( inputComment, thread.id );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonCancel={ ( event ) => {\n\t\t\t\t\t\t\t\tevent.stopPropagation(); // Prevent the parent onClick from being triggered\n\t\t\t\t\t\t\t\tclearThreadFocus();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tplaceholderText={\n\t\t\t\t\t\t\t\t'approved' === thread.status &&\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Adding a comment will re-open this discussion….'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsubmitButtonText={\n\t\t\t\t\t\t\t\t'approved' === thread.status\n\t\t\t\t\t\t\t\t\t? _x(\n\t\t\t\t\t\t\t\t\t\t\t'Reopen & Reply',\n\t\t\t\t\t\t\t\t\t\t\t'Reopen comment and add reply'\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: _x( 'Reply', 'Add reply comment' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trows={ 'approved' === thread.status ? 2 : 4 }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t</VStack>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nconst CommentBoard = ( {\n\tthread,\n\tonResolve,\n\tonReopen,\n\tonEdit,\n\tonDelete,\n\tstatus,\n} ) => {\n\tconst [ actionState, setActionState ] = useState( false );\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tconst handleConfirmDelete = () => {\n\t\tonDelete( thread.id );\n\t\tsetActionState( false );\n\t\tsetShowConfirmDialog( false );\n\t};\n\n\tconst handleCancel = () => {\n\t\tsetActionState( false );\n\t\tsetShowConfirmDialog( false );\n\t};\n\n\tconst actions = [\n\t\tonEdit &&\n\t\t\tstatus !== 'approved' && {\n\t\t\t\ttitle: _x( 'Edit', 'Edit comment' ),\n\t\t\t\tonClick: () => {\n\t\t\t\t\tsetActionState( 'edit' );\n\t\t\t\t},\n\t\t\t},\n\t\tonDelete && {\n\t\t\ttitle: _x( 'Delete', 'Delete comment' ),\n\t\t\tonClick: () => {\n\t\t\t\tsetActionState( 'delete' );\n\t\t\t\tsetShowConfirmDialog( true );\n\t\t\t},\n\t\t},\n\t\tonReopen &&\n\t\t\tstatus === 'approved' && {\n\t\t\t\ttitle: _x( 'Reopen', 'Reopen comment' ),\n\t\t\t\tonClick: () => {\n\t\t\t\t\tonReopen( thread.id );\n\t\t\t\t},\n\t\t\t},\n\t];\n\n\tconst moreActions = actions.filter( ( item ) => item?.onClick );\n\n\treturn (\n\t\t<>\n\t\t\t<HStack alignment=\"left\" spacing=\"3\" justify=\"flex-start\">\n\t\t\t\t<CommentAuthorInfo\n\t\t\t\t\tavatar={ thread?.author_avatar_urls?.[ 48 ] }\n\t\t\t\t\tname={ thread?.author_name }\n\t\t\t\t\tdate={ thread?.date }\n\t\t\t\t/>\n\t\t\t\t<span className=\"editor-collab-sidebar-panel__comment-status\">\n\t\t\t\t\t<HStack alignment=\"right\" justify=\"flex-end\" spacing=\"0\">\n\t\t\t\t\t\t{ 0 === thread?.parent && onResolve && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t\t'Resolve',\n\t\t\t\t\t\t\t\t\t'Mark comment as resolved'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\ticon={ published }\n\t\t\t\t\t\t\t\tdisabled={ status === 'approved' }\n\t\t\t\t\t\t\t\taccessibleWhenDisabled={ status === 'approved' }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonResolve( thread.id );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ 0 < moreActions.length && (\n\t\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t\t'Select an action',\n\t\t\t\t\t\t\t\t\t'Select comment action'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__comment-dropdown-menu\"\n\t\t\t\t\t\t\t\tcontrols={ moreActions }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</HStack>\n\t\t\t\t</span>\n\t\t\t</HStack>\n\t\t\t{ 'edit' === actionState ? (\n\t\t\t\t<CommentForm\n\t\t\t\t\tonSubmit={ ( value ) => {\n\t\t\t\t\t\tonEdit( thread.id, value );\n\t\t\t\t\t\tsetActionState( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonCancel={ () => handleCancel() }\n\t\t\t\t\tthread={ thread }\n\t\t\t\t\tsubmitButtonText={ _x( 'Update', 'verb' ) }\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<RawHTML className=\"editor-collab-sidebar-panel__user-comment\">\n\t\t\t\t\t{ thread?.content?.rendered }\n\t\t\t\t</RawHTML>\n\t\t\t) }\n\t\t\t{ 'delete' === actionState && (\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\t\tonConfirm={ handleConfirmDelete }\n\t\t\t\t\tonCancel={ handleCancel }\n\t\t\t\t\tconfirmButtonText={ __( 'Delete' ) }\n\t\t\t\t>\n\t\t\t\t\t{\n\t\t\t\t\t\t// translators: message displayed when confirming an action\n\t\t\t\t\t\t__( 'Are you sure you want to delete this comment?' )\n\t\t\t\t\t}\n\t\t\t\t</ConfirmDialog>\n\t\t\t) }\n\t\t</>\n\t);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SACCC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,2BAA2B,IAAIC,aAAa,EAC5CC,MAAM,EACNC,YAAY,QACN,uBAAuB;AAC9B,SAASC,SAAS,EAAEC,YAAY,QAAQ,kBAAkB;AAC1D,SAASC,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAA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,CAAE,KAAM,CAAC;MACxB,CAAG;MACHP,QAAQ,EAAGA,CAAA,KAAMW,YAAY,CAAC,CAAG;MACjC3B,MAAM,EAAGA,MAAQ;MACjBoB,gBAAgB,EAAG5D,EAAE,CAAE,QAAQ,EAAE,MAAO;IAAG,CAC3C,CAAC,gBAEFS,IAAA,CAACrB,OAAO;MAACgD,SAAS,EAAC,2CAA2C;MAAAL,QAAA,EAC3DS,MAAM,EAAE8C,OAAO,EAAEC;IAAQ,CACnB,CACT,EACC,QAAQ,KAAKzB,WAAW,iBACzBrD,IAAA,CAACf,aAAa;MACb8F,MAAM,EAAGxB,iBAAmB;MAC5ByB,SAAS,EAAGvB,mBAAqB;MACjCV,QAAQ,EAAGW,YAAc;MACzBuB,iBAAiB,EAAG3F,EAAE,CAAE,QAAS,CAAG;MAAAgC,QAAA;MAGnC;MACAhC,EAAE,CAAE,+CAAgD;IAAC,CAExC,CACf;EAAA,CACA,CAAC;AAEL,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","useState","RawHTML","__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalConfirmDialog","ConfirmDialog","Button","privateApis","componentsPrivateApis","published","moreVertical","__","_x","sprintf","_n","useSelect","useDispatch","store","blockEditorStore","blockEditorPrivateApis","unlock","CommentAuthorInfo","CommentForm","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","useBlockElement","Menu","Comments","threads","onEditComment","onAddReply","onCommentDelete","setShowCommentBoard","blockCommentId","select","getBlockAttributes","getSelectedBlockClientId","clientId","focusThread","setFocusThread","hasThreads","Array","isArray","length","alignment","className","justify","spacing","children","map","thread","Thread","isFocused","id","flashBlock","relatedBlockElement","blockClientId","handleCommentSelect","scrollIntoView","behavior","block","clearThreadFocus","replies","reply","lastReply","undefined","restReplies","slice","onClick","CommentBoard","onEdit","onDelete","status","size","variant","onSubmit","inputComment","content","parent","onCancel","event","stopPropagation","submitButtonText","rows","labelText","author_name","actionState","setActionState","showConfirmDialog","setShowConfirmDialog","handleConfirmDelete","handleCancel","actions","title","canResolve","moreActions","filter","item","avatar","author_avatar_urls","name","date","userId","author","label","icon","disabled","accessibleWhenDisabled","placement","TriggerButton","render","Popover","action","Item","ItemLabel","value","rendered","isOpen","onConfirm","confirmButtonText"],"sources":["@wordpress/editor/src/components/collab-sidebar/comments.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useState, RawHTML } from '@wordpress/element';\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalConfirmDialog as ConfirmDialog,\n\tButton,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\n\nimport { published, moreVertical } from '@wordpress/icons';\nimport { __, _x, sprintf, _n } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport CommentAuthorInfo from './comment-author-info';\nimport CommentForm from './comment-form';\n\nconst { useBlockElement } = unlock( blockEditorPrivateApis );\nconst { Menu } = unlock( componentsPrivateApis );\n\n/**\n * Renders the Comments component.\n *\n * @param {Object} props - The component props.\n * @param {Array} props.threads - The array of comment threads.\n * @param {Function} props.onEditComment - The function to handle comment editing.\n * @param {Function} props.onAddReply - The function to add a reply to a comment.\n * @param {Function} props.onCommentDelete - The function to delete a comment.\n * @param {Function} props.setShowCommentBoard - The function to set the comment board visibility.\n * @return {React.ReactNode} The rendered Comments component.\n */\nexport function Comments( {\n\tthreads,\n\tonEditComment,\n\tonAddReply,\n\tonCommentDelete,\n\tsetShowCommentBoard,\n} ) {\n\tconst { blockCommentId } = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\t\tselect( blockEditorStore );\n\t\tconst clientId = getSelectedBlockClientId();\n\t\treturn {\n\t\t\tblockCommentId: clientId\n\t\t\t\t? getBlockAttributes( clientId )?.blockCommentId\n\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\tconst [ focusThread = blockCommentId, setFocusThread ] = useState();\n\n\tconst hasThreads = Array.isArray( threads ) && threads.length > 0;\n\tif ( ! hasThreads ) {\n\t\treturn (\n\t\t\t<VStack\n\t\t\t\talignment=\"left\"\n\t\t\t\tclassName=\"editor-collab-sidebar-panel__thread\"\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tspacing=\"2\"\n\t\t\t>\n\t\t\t\t{\n\t\t\t\t\t// translators: message displayed when there are no comments available\n\t\t\t\t\t__( 'No comments available' )\n\t\t\t\t}\n\t\t\t</VStack>\n\t\t);\n\t}\n\n\treturn threads.map( ( thread ) => (\n\t\t<Thread\n\t\t\tkey={ thread.id }\n\t\t\tthread={ thread }\n\t\t\tonAddReply={ onAddReply }\n\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\tonEditComment={ onEditComment }\n\t\t\tisFocused={ focusThread === thread.id }\n\t\t\tsetFocusThread={ setFocusThread }\n\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t/>\n\t) );\n}\n\nfunction Thread( {\n\tthread,\n\tonEditComment,\n\tonAddReply,\n\tonCommentDelete,\n\tisFocused,\n\tsetFocusThread,\n\tsetShowCommentBoard,\n} ) {\n\tconst { flashBlock } = useDispatch( blockEditorStore );\n\tconst relatedBlockElement = useBlockElement( thread.blockClientId );\n\n\tconst handleCommentSelect = ( { id, blockClientId } ) => {\n\t\tsetShowCommentBoard( false );\n\t\tsetFocusThread( id );\n\t\tif ( blockClientId && relatedBlockElement ) {\n\t\t\trelatedBlockElement.scrollIntoView( {\n\t\t\t\tbehavior: 'instant',\n\t\t\t\tblock: 'center',\n\t\t\t} );\n\t\t\tflashBlock( blockClientId );\n\t\t}\n\t};\n\n\tconst clearThreadFocus = () => {\n\t\tsetFocusThread( null );\n\t\tsetShowCommentBoard( false );\n\t};\n\n\tconst replies = thread?.reply;\n\tconst lastReply = !! replies.length\n\t\t? replies[ replies.length - 1 ]\n\t\t: undefined;\n\tconst restReplies = !! replies.length ? replies.slice( 0, -1 ) : [];\n\n\treturn (\n\t\t<VStack\n\t\t\tclassName={ clsx( 'editor-collab-sidebar-panel__thread', {\n\t\t\t\t'editor-collab-sidebar-panel__focus-thread': isFocused,\n\t\t\t} ) }\n\t\t\tid={ thread.id }\n\t\t\tspacing=\"2\"\n\t\t\tonClick={ () => handleCommentSelect( thread ) }\n\t\t>\n\t\t\t<CommentBoard\n\t\t\t\tthread={ thread }\n\t\t\t\tonEdit={ onEditComment }\n\t\t\t\tonDelete={ onCommentDelete }\n\t\t\t\tstatus={ thread.status }\n\t\t\t/>\n\t\t\t{ isFocused &&\n\t\t\t\treplies.map( ( reply ) => (\n\t\t\t\t\t<VStack\n\t\t\t\t\t\tkey={ reply.id }\n\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__child-thread\"\n\t\t\t\t\t\tid={ reply.id }\n\t\t\t\t\t\tspacing=\"2\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<CommentBoard\n\t\t\t\t\t\t\tthread={ reply }\n\t\t\t\t\t\t\tonEdit={\n\t\t\t\t\t\t\t\t'approved' !== thread.status\n\t\t\t\t\t\t\t\t\t? onEditComment\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonDelete={\n\t\t\t\t\t\t\t\t'approved' !== thread.status\n\t\t\t\t\t\t\t\t\t? onCommentDelete\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t) ) }\n\t\t\t{ ! isFocused && restReplies.length > 0 && (\n\t\t\t\t<HStack className=\"editor-collab-sidebar-panel__more-reply-separator\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__more-reply-button\"\n\t\t\t\t\t\tonClick={ () => setFocusThread( thread.id ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t// translators: %s: number of replies.\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'%s more reply',\n\t\t\t\t\t\t\t\t'%s more replies',\n\t\t\t\t\t\t\t\trestReplies.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\trestReplies.length\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t) }\n\t\t\t{ ! isFocused && lastReply && (\n\t\t\t\t<CommentBoard\n\t\t\t\t\tthread={ lastReply }\n\t\t\t\t\tonEdit={\n\t\t\t\t\t\t'approved' !== thread.status ? onEditComment : undefined\n\t\t\t\t\t}\n\t\t\t\t\tonDelete={\n\t\t\t\t\t\t'approved' !== thread.status\n\t\t\t\t\t\t\t? onCommentDelete\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isFocused && (\n\t\t\t\t<VStack\n\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__child-thread\"\n\t\t\t\t\tspacing=\"2\"\n\t\t\t\t>\n\t\t\t\t\t<HStack alignment=\"left\" spacing=\"3\" justify=\"flex-start\">\n\t\t\t\t\t\t<CommentAuthorInfo />\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<VStack spacing=\"2\">\n\t\t\t\t\t\t<CommentForm\n\t\t\t\t\t\t\tonSubmit={ ( inputComment ) => {\n\t\t\t\t\t\t\t\tif ( 'approved' === thread.status ) {\n\t\t\t\t\t\t\t\t\tonEditComment( {\n\t\t\t\t\t\t\t\t\t\tid: thread.id,\n\t\t\t\t\t\t\t\t\t\tstatus: 'hold',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonAddReply( {\n\t\t\t\t\t\t\t\t\tcontent: inputComment,\n\t\t\t\t\t\t\t\t\tparent: thread.id,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonCancel={ ( event ) => {\n\t\t\t\t\t\t\t\tevent.stopPropagation(); // Prevent the parent onClick from being triggered\n\t\t\t\t\t\t\t\tclearThreadFocus();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsubmitButtonText={\n\t\t\t\t\t\t\t\t'approved' === thread.status\n\t\t\t\t\t\t\t\t\t? __( 'Reopen & Reply' )\n\t\t\t\t\t\t\t\t\t: __( 'Reply' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trows={ 'approved' === thread.status ? 2 : 4 }\n\t\t\t\t\t\t\tlabelText={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %1$s: comment identifier, %2$s: author name\n\t\t\t\t\t\t\t\t__( 'Reply to Comment %1$s by %2$s' ),\n\t\t\t\t\t\t\t\tthread.id,\n\t\t\t\t\t\t\t\tthread?.author_name || 'Unknown'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t</VStack>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nconst CommentBoard = ( { thread, onEdit, onDelete, status } ) => {\n\tconst [ actionState, setActionState ] = useState( false );\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tconst handleConfirmDelete = () => {\n\t\tonDelete( thread );\n\t\tsetActionState( false );\n\t\tsetShowConfirmDialog( false );\n\t};\n\n\tconst handleCancel = () => {\n\t\tsetActionState( false );\n\t\tsetShowConfirmDialog( false );\n\t};\n\n\tconst actions = [\n\t\tonEdit &&\n\t\t\tstatus !== 'approved' && {\n\t\t\t\tid: 'edit',\n\t\t\t\ttitle: _x( 'Edit', 'Edit comment' ),\n\t\t\t\tonClick: () => {\n\t\t\t\t\tsetActionState( 'edit' );\n\t\t\t\t},\n\t\t\t},\n\t\tonDelete && {\n\t\t\tid: 'delete',\n\t\t\ttitle: _x( 'Delete', 'Delete comment' ),\n\t\t\tonClick: () => {\n\t\t\t\tsetActionState( 'delete' );\n\t\t\t\tsetShowConfirmDialog( true );\n\t\t\t},\n\t\t},\n\t\tonEdit &&\n\t\t\tstatus === 'approved' && {\n\t\t\t\tid: 'reopen',\n\t\t\t\ttitle: _x( 'Reopen', 'Reopen comment' ),\n\t\t\t\tonClick: () => {\n\t\t\t\t\tonEdit( { id: thread.id, status: 'hold' } );\n\t\t\t\t},\n\t\t\t},\n\t];\n\n\tconst canResolve = thread?.parent === 0;\n\tconst moreActions = actions.filter( ( item ) => item?.onClick );\n\n\treturn (\n\t\t<>\n\t\t\t<HStack alignment=\"left\" spacing=\"3\" justify=\"flex-start\">\n\t\t\t\t<CommentAuthorInfo\n\t\t\t\t\tavatar={ thread?.author_avatar_urls?.[ 48 ] }\n\t\t\t\t\tname={ thread?.author_name }\n\t\t\t\t\tdate={ thread?.date }\n\t\t\t\t\tuserId={ thread?.author }\n\t\t\t\t/>\n\t\t\t\t<span className=\"editor-collab-sidebar-panel__comment-status\">\n\t\t\t\t\t<HStack alignment=\"right\" justify=\"flex-end\" spacing=\"0\">\n\t\t\t\t\t\t{ canResolve && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t\t'Resolve',\n\t\t\t\t\t\t\t\t\t'Mark comment as resolved'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\ticon={ published }\n\t\t\t\t\t\t\t\tdisabled={ status === 'approved' }\n\t\t\t\t\t\t\t\taccessibleWhenDisabled={ status === 'approved' }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonEdit( {\n\t\t\t\t\t\t\t\t\t\tid: thread.id,\n\t\t\t\t\t\t\t\t\t\tstatus: 'approved',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Menu placement=\"bottom-end\">\n\t\t\t\t\t\t\t<Menu.TriggerButton\n\t\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\t\t\t\t\tdisabled={ ! moreActions.length }\n\t\t\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<Menu.Popover>\n\t\t\t\t\t\t\t\t{ moreActions.map( ( action ) => (\n\t\t\t\t\t\t\t\t\t<Menu.Item\n\t\t\t\t\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\taction.onClick();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<Menu.ItemLabel>\n\t\t\t\t\t\t\t\t\t\t\t{ action.title }\n\t\t\t\t\t\t\t\t\t\t</Menu.ItemLabel>\n\t\t\t\t\t\t\t\t\t</Menu.Item>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</Menu.Popover>\n\t\t\t\t\t\t</Menu>\n\t\t\t\t\t</HStack>\n\t\t\t\t</span>\n\t\t\t</HStack>\n\t\t\t{ 'edit' === actionState ? (\n\t\t\t\t<CommentForm\n\t\t\t\t\tonSubmit={ ( value ) => {\n\t\t\t\t\t\tonEdit( {\n\t\t\t\t\t\t\tid: thread.id,\n\t\t\t\t\t\t\tcontent: value,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tsetActionState( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonCancel={ () => handleCancel() }\n\t\t\t\t\tthread={ thread }\n\t\t\t\t\tsubmitButtonText={ _x( 'Update', 'verb' ) }\n\t\t\t\t\tlabelText={ sprintf(\n\t\t\t\t\t\t// translators: %1$s: comment identifier, %2$s: author name.\n\t\t\t\t\t\t__( 'Edit Comment %1$s by %2$s' ),\n\t\t\t\t\t\tthread.id,\n\t\t\t\t\t\tthread?.author_name || 'Unknown'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<RawHTML className=\"editor-collab-sidebar-panel__user-comment\">\n\t\t\t\t\t{ thread?.content?.rendered }\n\t\t\t\t</RawHTML>\n\t\t\t) }\n\t\t\t{ 'delete' === actionState && (\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\t\tonConfirm={ handleConfirmDelete }\n\t\t\t\t\tonCancel={ handleCancel }\n\t\t\t\t\tconfirmButtonText={ __( 'Delete' ) }\n\t\t\t\t>\n\t\t\t\t\t{\n\t\t\t\t\t\t// translators: message displayed when confirming an action\n\t\t\t\t\t\t__( 'Are you sure you want to delete this comment?' )\n\t\t\t\t\t}\n\t\t\t\t</ConfirmDialog>\n\t\t\t) }\n\t\t</>\n\t);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SACCC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,2BAA2B,IAAIC,aAAa,EAC5CC,MAAM,EACNC,WAAW,IAAIC,qBAAqB,QAC9B,uBAAuB;AAE9B,SAASC,SAAS,EAAEC,YAAY,QAAQ,kBAAkB;AAC1D,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,EAAEC,EAAE,QAAQ,iBAAiB;AACrD,SAASC,SAAS,EAAEC,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AC,GARXmB,MAAM,CAAC3D,EASH,CACV;YAAC,CACU,CAAC;UAAA,CACV,CAAC;QAAA,CACA;MAAC,CACJ,CAAC;IAAA,CACA,CAAC,EACP,MAAM,KAAKiC,WAAW,gBACvBlE,IAAA,CAACF,WAAW;MACXyD,QAAQ,EAAKwC,KAAK,IAAM;QACvB7C,MAAM,CAAE;UACPjB,EAAE,EAAEH,MAAM,CAACG,EAAE;UACbwB,OAAO,EAAEsC;QACV,CAAE,CAAC;QACH5B,cAAc,CAAE,KAAM,CAAC;MACxB,CAAG;MACHR,QAAQ,EAAGA,CAAA,KAAMY,YAAY,CAAC,CAAG;MACjCzC,MAAM,EAAGA,MAAQ;MACjBgC,gBAAgB,EAAG1E,EAAE,CAAE,QAAQ,EAAE,MAAO,CAAG;MAC3C4E,SAAS,EAAG3E,OAAO;MAClB;MACAF,EAAE,CAAE,2BAA4B,CAAC,EACjC2C,MAAM,CAACG,EAAE,EACTH,MAAM,EAAEmC,WAAW,IAAI,SACxB;IAAG,CACH,CAAC,gBAEFjE,IAAA,CAACzB,OAAO;MAACkD,SAAS,EAAC,2CAA2C;MAAAG,QAAA,EAC3DE,MAAM,EAAE2B,OAAO,EAAEuC;IAAQ,CACnB,CACT,EACC,QAAQ,KAAK9B,WAAW,iBACzBlE,IAAA,CAACnB,aAAa;MACboH,MAAM,EAAG7B,iBAAmB;MAC5B8B,SAAS,EAAG5B,mBAAqB;MACjCX,QAAQ,EAAGY,YAAc;MACzB4B,iBAAiB,EAAGhH,EAAE,CAAE,QAAS,CAAG;MAAAyC,QAAA;MAGnC;MACAzC,EAAE,CAAE,+CAAgD;IAAC,CAExC,CACf;EAAA,CACA,CAAC;AAEL,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useMemo } from '@wordpress/element';
|
|
5
|
+
import { useEntityRecords } from '@wordpress/core-data';
|
|
6
|
+
import { useSelect } from '@wordpress/data';
|
|
7
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
8
|
+
export function useBlockComments(postId) {
|
|
9
|
+
const queryArgs = {
|
|
10
|
+
post: postId,
|
|
11
|
+
type: 'block_comment',
|
|
12
|
+
status: 'all',
|
|
13
|
+
per_page: 100
|
|
14
|
+
};
|
|
15
|
+
const {
|
|
16
|
+
records: threads,
|
|
17
|
+
totalPages
|
|
18
|
+
} = useEntityRecords('root', 'comment', queryArgs, {
|
|
19
|
+
enabled: !!postId && typeof postId === 'number'
|
|
20
|
+
});
|
|
21
|
+
const blocksWithComments = useSelect(select => {
|
|
22
|
+
const {
|
|
23
|
+
getBlockAttributes,
|
|
24
|
+
getClientIdsWithDescendants
|
|
25
|
+
} = select(blockEditorStore);
|
|
26
|
+
return getClientIdsWithDescendants().reduce((results, clientId) => {
|
|
27
|
+
const commentId = getBlockAttributes(clientId)?.blockCommentId;
|
|
28
|
+
if (commentId) {
|
|
29
|
+
results[commentId] = clientId;
|
|
30
|
+
}
|
|
31
|
+
return results;
|
|
32
|
+
}, {});
|
|
33
|
+
}, []);
|
|
34
|
+
|
|
35
|
+
// Process comments to build the tree structure.
|
|
36
|
+
const {
|
|
37
|
+
resultComments,
|
|
38
|
+
unresolvedSortedThreads
|
|
39
|
+
} = useMemo(() => {
|
|
40
|
+
// Create a compare to store the references to all objects by id.
|
|
41
|
+
const compare = {};
|
|
42
|
+
const result = [];
|
|
43
|
+
const allComments = threads !== null && threads !== void 0 ? threads : [];
|
|
44
|
+
|
|
45
|
+
// Initialize each object with an empty `reply` array and map blockClientId.
|
|
46
|
+
allComments.forEach(item => {
|
|
47
|
+
compare[item.id] = {
|
|
48
|
+
...item,
|
|
49
|
+
reply: [],
|
|
50
|
+
blockClientId: item.parent === 0 ? blocksWithComments[item.id] : null
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Iterate over the data to build the tree structure.
|
|
55
|
+
allComments.forEach(item => {
|
|
56
|
+
if (item.parent === 0) {
|
|
57
|
+
// If parent is 0, it's a root item, push it to the result array.
|
|
58
|
+
result.push(compare[item.id]);
|
|
59
|
+
} else if (compare[item.parent]) {
|
|
60
|
+
// Otherwise, find its parent and push it to the parent's `reply` array.
|
|
61
|
+
compare[item.parent].reply.push(compare[item.id]);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
if (0 === result?.length) {
|
|
65
|
+
return {
|
|
66
|
+
resultComments: [],
|
|
67
|
+
unresolvedSortedThreads: []
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const updatedResult = result.map(item => ({
|
|
71
|
+
...item,
|
|
72
|
+
reply: [...item.reply].reverse()
|
|
73
|
+
}));
|
|
74
|
+
const threadIdMap = new Map(updatedResult.map(thread => [String(thread.id), thread]));
|
|
75
|
+
|
|
76
|
+
// Get comments by block order, filter out undefined threads, and exclude resolved comments.
|
|
77
|
+
const unresolvedSortedComments = Object.keys(blocksWithComments).map(id => threadIdMap.get(id)).filter(thread => thread !== undefined && thread.status !== 'approved');
|
|
78
|
+
return {
|
|
79
|
+
resultComments: updatedResult,
|
|
80
|
+
unresolvedSortedThreads: unresolvedSortedComments
|
|
81
|
+
};
|
|
82
|
+
}, [threads, blocksWithComments]);
|
|
83
|
+
return {
|
|
84
|
+
resultComments,
|
|
85
|
+
unresolvedSortedThreads,
|
|
86
|
+
totalPages
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useMemo","useEntityRecords","useSelect","store","blockEditorStore","useBlockComments","postId","queryArgs","post","type","status","per_page","records","threads","totalPages","enabled","blocksWithComments","select","getBlockAttributes","getClientIdsWithDescendants","reduce","results","clientId","commentId","blockCommentId","resultComments","unresolvedSortedThreads","compare","result","allComments","forEach","item","id","reply","blockClientId","parent","push","length","updatedResult","map","reverse","threadIdMap","Map","thread","String","unresolvedSortedComments","Object","keys","get","filter","undefined"],"sources":["@wordpress/editor/src/components/collab-sidebar/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nexport function useBlockComments( postId ) {\n\tconst queryArgs = {\n\t\tpost: postId,\n\t\ttype: 'block_comment',\n\t\tstatus: 'all',\n\t\tper_page: 100,\n\t};\n\n\tconst { records: threads, totalPages } = useEntityRecords(\n\t\t'root',\n\t\t'comment',\n\t\tqueryArgs,\n\t\t{ enabled: !! postId && typeof postId === 'number' }\n\t);\n\n\tconst blocksWithComments = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getClientIdsWithDescendants } =\n\t\t\tselect( blockEditorStore );\n\n\t\treturn getClientIdsWithDescendants().reduce( ( results, clientId ) => {\n\t\t\tconst commentId = getBlockAttributes( clientId )?.blockCommentId;\n\t\t\tif ( commentId ) {\n\t\t\t\tresults[ commentId ] = clientId;\n\t\t\t}\n\t\t\treturn results;\n\t\t}, {} );\n\t}, [] );\n\n\t// Process comments to build the tree structure.\n\tconst { resultComments, unresolvedSortedThreads } = useMemo( () => {\n\t\t// Create a compare to store the references to all objects by id.\n\t\tconst compare = {};\n\t\tconst result = [];\n\n\t\tconst allComments = threads ?? [];\n\n\t\t// Initialize each object with an empty `reply` array and map blockClientId.\n\t\tallComments.forEach( ( item ) => {\n\t\t\tcompare[ item.id ] = {\n\t\t\t\t...item,\n\t\t\t\treply: [],\n\t\t\t\tblockClientId:\n\t\t\t\t\titem.parent === 0 ? blocksWithComments[ item.id ] : null,\n\t\t\t};\n\t\t} );\n\n\t\t// Iterate over the data to build the tree structure.\n\t\tallComments.forEach( ( item ) => {\n\t\t\tif ( item.parent === 0 ) {\n\t\t\t\t// If parent is 0, it's a root item, push it to the result array.\n\t\t\t\tresult.push( compare[ item.id ] );\n\t\t\t} else if ( compare[ item.parent ] ) {\n\t\t\t\t// Otherwise, find its parent and push it to the parent's `reply` array.\n\t\t\t\tcompare[ item.parent ].reply.push( compare[ item.id ] );\n\t\t\t}\n\t\t} );\n\n\t\tif ( 0 === result?.length ) {\n\t\t\treturn { resultComments: [], unresolvedSortedThreads: [] };\n\t\t}\n\n\t\tconst updatedResult = result.map( ( item ) => ( {\n\t\t\t...item,\n\t\t\treply: [ ...item.reply ].reverse(),\n\t\t} ) );\n\n\t\tconst threadIdMap = new Map(\n\t\t\tupdatedResult.map( ( thread ) => [ String( thread.id ), thread ] )\n\t\t);\n\n\t\t// Get comments by block order, filter out undefined threads, and exclude resolved comments.\n\t\tconst unresolvedSortedComments = Object.keys( blocksWithComments )\n\t\t\t.map( ( id ) => threadIdMap.get( id ) )\n\t\t\t.filter(\n\t\t\t\t( thread ) =>\n\t\t\t\t\tthread !== undefined && thread.status !== 'approved'\n\t\t\t);\n\n\t\treturn {\n\t\t\tresultComments: updatedResult,\n\t\t\tunresolvedSortedThreads: unresolvedSortedComments,\n\t\t};\n\t}, [ threads, blocksWithComments ] );\n\n\treturn { resultComments, unresolvedSortedThreads, totalPages };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AAEnE,OAAO,SAASC,gBAAgBA,CAAEC,MAAM,EAAG;EAC1C,MAAMC,SAAS,GAAG;IACjBC,IAAI,EAAEF,MAAM;IACZG,IAAI,EAAE,eAAe;IACrBC,MAAM,EAAE,KAAK;IACbC,QAAQ,EAAE;EACX,CAAC;EAED,MAAM;IAAEC,OAAO,EAAEC,OAAO;IAAEC;EAAW,CAAC,GAAGb,gBAAgB,CACxD,MAAM,EACN,SAAS,EACTM,SAAS,EACT;IAAEQ,OAAO,EAAE,CAAC,CAAET,MAAM,IAAI,OAAOA,MAAM,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