@wordpress/editor 14.30.1-next.836ecdcae.0 → 14.31.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/CHANGELOG.md +2 -0
- package/build/bindings/api.js +2 -0
- package/build/bindings/api.js.map +1 -1
- package/build/bindings/term-data.js +171 -0
- package/build/bindings/term-data.js.map +1 -0
- package/build/components/collab-sidebar/add-comment.js +6 -3
- package/build/components/collab-sidebar/add-comment.js.map +1 -1
- package/build/components/collab-sidebar/comment-author-info.js +3 -3
- package/build/components/collab-sidebar/comment-author-info.js.map +1 -1
- package/build/components/collab-sidebar/comment-form.js +24 -8
- package/build/components/collab-sidebar/comment-form.js.map +1 -1
- package/build/components/collab-sidebar/comment-indicator-toolbar.js +112 -0
- package/build/components/collab-sidebar/comment-indicator-toolbar.js.map +1 -0
- package/build/components/collab-sidebar/comments.js +47 -58
- package/build/components/collab-sidebar/comments.js.map +1 -1
- package/build/components/collab-sidebar/index.js +120 -96
- package/build/components/collab-sidebar/index.js.map +1 -1
- package/build/components/post-excerpt/panel.js +5 -2
- package/build/components/post-excerpt/panel.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +21 -9
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-template/hooks.js +20 -5
- package/build/components/post-template/hooks.js.map +1 -1
- package/build/components/provider/index.js +1 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/dataviews/store/private-actions.js +1 -1
- package/build/dataviews/store/private-actions.js.map +1 -1
- package/build-module/bindings/api.js +2 -0
- package/build-module/bindings/api.js.map +1 -1
- package/build-module/bindings/term-data.js +165 -0
- package/build-module/bindings/term-data.js.map +1 -0
- package/build-module/components/collab-sidebar/add-comment.js +6 -3
- package/build-module/components/collab-sidebar/add-comment.js.map +1 -1
- package/build-module/components/collab-sidebar/comment-author-info.js +4 -4
- package/build-module/components/collab-sidebar/comment-author-info.js.map +1 -1
- package/build-module/components/collab-sidebar/comment-form.js +24 -9
- package/build-module/components/collab-sidebar/comment-form.js.map +1 -1
- package/build-module/components/collab-sidebar/comment-indicator-toolbar.js +104 -0
- package/build-module/components/collab-sidebar/comment-indicator-toolbar.js.map +1 -0
- package/build-module/components/collab-sidebar/comments.js +50 -61
- package/build-module/components/collab-sidebar/comments.js.map +1 -1
- package/build-module/components/collab-sidebar/index.js +121 -97
- package/build-module/components/collab-sidebar/index.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +5 -2
- package/build-module/components/post-excerpt/panel.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +21 -11
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-template/hooks.js +20 -5
- package/build-module/components/post-template/hooks.js.map +1 -1
- package/build-module/components/provider/index.js +1 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/dataviews/store/private-actions.js +1 -1
- package/build-module/dataviews/store/private-actions.js.map +1 -1
- package/build-style/style-rtl.css +71 -15
- package/build-style/style.css +71 -15
- package/build-types/bindings/api.d.ts.map +1 -1
- package/build-types/bindings/term-data.d.ts +25 -0
- package/build-types/bindings/term-data.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -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 +5 -1
- package/build-types/components/collab-sidebar/comment-form.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts +7 -0
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/comments.d.ts +3 -1
- package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +10 -1
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
- package/build-types/components/post-template/hooks.d.ts +1 -1
- package/build-types/components/post-template/hooks.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/package.json +37 -37
- package/src/bindings/api.js +2 -0
- package/src/bindings/term-data.js +159 -0
- package/src/components/collab-sidebar/add-comment.js +20 -9
- package/src/components/collab-sidebar/comment-author-info.js +14 -4
- package/src/components/collab-sidebar/comment-form.js +32 -10
- package/src/components/collab-sidebar/comment-indicator-toolbar.js +124 -0
- package/src/components/collab-sidebar/comments.js +104 -106
- package/src/components/collab-sidebar/index.js +157 -122
- package/src/components/collab-sidebar/style.scss +82 -17
- package/src/components/post-excerpt/panel.js +6 -1
- package/src/components/post-taxonomies/hierarchical-term-selector.js +25 -8
- package/src/components/post-template/hooks.js +23 -7
- package/src/components/provider/index.js +4 -1
- package/src/dataviews/store/private-actions.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/collab-sidebar/comment-button-toolbar.js +0 -37
- package/build/components/collab-sidebar/comment-button-toolbar.js.map +0 -1
- package/build-module/components/collab-sidebar/comment-button-toolbar.js +0 -30
- package/build-module/components/collab-sidebar/comment-button-toolbar.js.map +0 -1
- package/build-types/components/collab-sidebar/comment-button-toolbar.d.ts +0 -5
- package/build-types/components/collab-sidebar/comment-button-toolbar.d.ts.map +0 -1
- package/src/components/collab-sidebar/comment-button-toolbar.js +0 -29
|
@@ -7,7 +7,7 @@ import { useState, useMemo } from '@wordpress/element';
|
|
|
7
7
|
import { comment as commentIcon } from '@wordpress/icons';
|
|
8
8
|
import { addFilter } from '@wordpress/hooks';
|
|
9
9
|
import { store as noticesStore } from '@wordpress/notices';
|
|
10
|
-
import { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';
|
|
10
|
+
import { store as coreStore, useEntityBlockEditor, useEntityRecords } from '@wordpress/core-data';
|
|
11
11
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
12
12
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
13
13
|
|
|
@@ -20,7 +20,7 @@ import { Comments } from './comments';
|
|
|
20
20
|
import { AddComment } from './add-comment';
|
|
21
21
|
import { store as editorStore } from '../../store';
|
|
22
22
|
import AddCommentButton from './comment-button';
|
|
23
|
-
import
|
|
23
|
+
import CommentAvatarIndicator from './comment-indicator-toolbar';
|
|
24
24
|
import { useGlobalStylesContext } from '../global-styles-provider';
|
|
25
25
|
import { getCommentIdsFromBlocks } from './utils';
|
|
26
26
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -71,95 +71,107 @@ function CollabSidebarContent({
|
|
|
71
71
|
const {
|
|
72
72
|
updateBlockAttributes
|
|
73
73
|
} = useDispatch(blockEditorStore);
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const onError = error => {
|
|
75
|
+
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('An error occurred while performing an update.');
|
|
76
|
+
createNotice('error', errorMessage, {
|
|
77
|
+
type: 'snackbar',
|
|
78
|
+
isDismissible: true
|
|
79
|
+
});
|
|
80
|
+
};
|
|
76
81
|
const addNewComment = async (comment, parentCommentId) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
try {
|
|
83
|
+
const savedRecord = await saveEntityRecord('root', 'comment', {
|
|
84
|
+
post: postId,
|
|
85
|
+
content: comment,
|
|
86
|
+
comment_type: 'block_comment',
|
|
87
|
+
comment_approved: 0,
|
|
88
|
+
...(parentCommentId ? {
|
|
89
|
+
parent: parentCommentId
|
|
90
|
+
} : {})
|
|
91
|
+
}, {
|
|
92
|
+
throwOnError: true
|
|
93
|
+
});
|
|
83
94
|
|
|
84
|
-
// Create a new object, conditionally including the parent property
|
|
85
|
-
const updatedArgs = {
|
|
86
|
-
...args,
|
|
87
|
-
...(parentCommentId ? {
|
|
88
|
-
parent: parentCommentId
|
|
89
|
-
} : {})
|
|
90
|
-
};
|
|
91
|
-
const savedRecord = await saveEntityRecord('root', 'comment', updatedArgs);
|
|
92
|
-
if (savedRecord) {
|
|
93
95
|
// If it's a main comment, update the block attributes with the comment id.
|
|
94
|
-
if (!parentCommentId) {
|
|
96
|
+
if (!parentCommentId && savedRecord?.id) {
|
|
95
97
|
updateBlockAttributes(getSelectedBlockClientId(), {
|
|
96
|
-
blockCommentId: savedRecord
|
|
98
|
+
blockCommentId: savedRecord.id
|
|
97
99
|
});
|
|
98
100
|
}
|
|
99
|
-
createNotice('snackbar', parentCommentId ?
|
|
100
|
-
// translators: Reply added successfully
|
|
101
|
-
__('Reply added successfully.') :
|
|
102
|
-
// translators: Comment added successfully
|
|
103
|
-
__('Comment added successfully.'), {
|
|
101
|
+
createNotice('snackbar', parentCommentId ? __('Reply added successfully.') : __('Comment added successfully.'), {
|
|
104
102
|
type: 'snackbar',
|
|
105
103
|
isDismissible: true
|
|
106
104
|
});
|
|
107
|
-
}
|
|
108
|
-
onError();
|
|
105
|
+
} catch (error) {
|
|
106
|
+
onError(error);
|
|
109
107
|
}
|
|
110
108
|
};
|
|
111
109
|
const onCommentResolve = async commentId => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
110
|
+
try {
|
|
111
|
+
await saveEntityRecord('root', 'comment', {
|
|
112
|
+
id: commentId,
|
|
113
|
+
status: 'approved'
|
|
114
|
+
}, {
|
|
115
|
+
throwOnError: true
|
|
116
|
+
});
|
|
118
117
|
createNotice('snackbar', __('Comment marked as resolved.'), {
|
|
119
118
|
type: 'snackbar',
|
|
120
119
|
isDismissible: true
|
|
121
120
|
});
|
|
122
|
-
}
|
|
123
|
-
onError();
|
|
121
|
+
} catch (error) {
|
|
122
|
+
onError(error);
|
|
124
123
|
}
|
|
125
124
|
};
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
__('Comment
|
|
125
|
+
const onCommentReopen = async commentId => {
|
|
126
|
+
try {
|
|
127
|
+
await saveEntityRecord('root', 'comment', {
|
|
128
|
+
id: commentId,
|
|
129
|
+
status: 'hold'
|
|
130
|
+
}, {
|
|
131
|
+
throwOnError: true
|
|
132
|
+
});
|
|
133
|
+
createNotice('snackbar', __('Comment reopened.'), {
|
|
135
134
|
type: 'snackbar',
|
|
136
135
|
isDismissible: true
|
|
137
136
|
});
|
|
138
|
-
}
|
|
139
|
-
onError();
|
|
137
|
+
} catch (error) {
|
|
138
|
+
onError(error);
|
|
140
139
|
}
|
|
141
140
|
};
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
141
|
+
const onEditComment = async (commentId, comment) => {
|
|
142
|
+
try {
|
|
143
|
+
await saveEntityRecord('root', 'comment', {
|
|
144
|
+
id: commentId,
|
|
145
|
+
content: comment
|
|
146
|
+
}, {
|
|
147
|
+
throwOnError: true
|
|
148
|
+
});
|
|
149
|
+
createNotice('snackbar', __('Comment edited successfully.'), {
|
|
150
|
+
type: 'snackbar',
|
|
151
|
+
isDismissible: true
|
|
152
|
+
});
|
|
153
|
+
} catch (error) {
|
|
154
|
+
onError(error);
|
|
155
|
+
}
|
|
148
156
|
};
|
|
149
157
|
const onCommentDelete = async commentId => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
blockCommentId: undefined
|
|
158
|
+
try {
|
|
159
|
+
const childComment = await getEntityRecord('root', 'comment', commentId);
|
|
160
|
+
await deleteEntityRecord('root', 'comment', commentId, undefined, {
|
|
161
|
+
throwOnError: true
|
|
155
162
|
});
|
|
163
|
+
if (childComment && !childComment.parent) {
|
|
164
|
+
updateBlockAttributes(getSelectedBlockClientId(), {
|
|
165
|
+
blockCommentId: undefined
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
createNotice('snackbar', __('Comment deleted successfully.'), {
|
|
169
|
+
type: 'snackbar',
|
|
170
|
+
isDismissible: true
|
|
171
|
+
});
|
|
172
|
+
} catch (error) {
|
|
173
|
+
onError(error);
|
|
156
174
|
}
|
|
157
|
-
createNotice('snackbar',
|
|
158
|
-
// translators: Comment deleted successfully
|
|
159
|
-
__('Comment deleted successfully.'), {
|
|
160
|
-
type: 'snackbar',
|
|
161
|
-
isDismissible: true
|
|
162
|
-
});
|
|
163
175
|
};
|
|
164
176
|
return /*#__PURE__*/_jsxs("div", {
|
|
165
177
|
className: "editor-collab-sidebar-panel",
|
|
@@ -174,6 +186,7 @@ function CollabSidebarContent({
|
|
|
174
186
|
onAddReply: addNewComment,
|
|
175
187
|
onCommentDelete: onCommentDelete,
|
|
176
188
|
onCommentResolve: onCommentResolve,
|
|
189
|
+
onCommentReopen: onCommentReopen,
|
|
177
190
|
showCommentBoard: showCommentBoard,
|
|
178
191
|
setShowCommentBoard: setShowCommentBoard
|
|
179
192
|
}, getSelectedBlockClientId())]
|
|
@@ -193,28 +206,30 @@ export default function CollabSidebar() {
|
|
|
193
206
|
} = useSelect(interfaceStore);
|
|
194
207
|
const {
|
|
195
208
|
postId,
|
|
196
|
-
postType
|
|
197
|
-
postStatus,
|
|
198
|
-
threads
|
|
209
|
+
postType
|
|
199
210
|
} = useSelect(select => {
|
|
200
211
|
const {
|
|
201
212
|
getCurrentPostId,
|
|
202
213
|
getCurrentPostType
|
|
203
214
|
} = select(editorStore);
|
|
204
|
-
const _postId = getCurrentPostId();
|
|
205
|
-
const data = !!_postId && typeof _postId === 'number' ? select(coreStore).getEntityRecords('root', 'comment', {
|
|
206
|
-
post: _postId,
|
|
207
|
-
type: 'block_comment',
|
|
208
|
-
status: 'any',
|
|
209
|
-
per_page: 100
|
|
210
|
-
}) : null;
|
|
211
215
|
return {
|
|
212
|
-
postId:
|
|
213
|
-
postType: getCurrentPostType()
|
|
214
|
-
postStatus: select(editorStore).getEditedPostAttribute('status'),
|
|
215
|
-
threads: data
|
|
216
|
+
postId: getCurrentPostId(),
|
|
217
|
+
postType: getCurrentPostType()
|
|
216
218
|
};
|
|
217
219
|
}, []);
|
|
220
|
+
const queryArgs = {
|
|
221
|
+
post: postId,
|
|
222
|
+
type: 'block_comment',
|
|
223
|
+
status: 'all',
|
|
224
|
+
per_page: 100
|
|
225
|
+
};
|
|
226
|
+
const {
|
|
227
|
+
records: threads,
|
|
228
|
+
totalPages
|
|
229
|
+
} = useEntityRecords('root', 'comment', queryArgs, {
|
|
230
|
+
enabled: !!postId && typeof postId === 'number'
|
|
231
|
+
});
|
|
232
|
+
const hasMoreComments = totalPages && totalPages > 1;
|
|
218
233
|
const {
|
|
219
234
|
blockCommentId
|
|
220
235
|
} = useSelect(select => {
|
|
@@ -229,44 +244,44 @@ export default function CollabSidebar() {
|
|
|
229
244
|
}, []);
|
|
230
245
|
const openCollabBoard = () => {
|
|
231
246
|
setShowCommentBoard(true);
|
|
232
|
-
enableComplementaryArea('core',
|
|
247
|
+
enableComplementaryArea('core', collabHistorySidebarName);
|
|
233
248
|
};
|
|
234
249
|
const [blocks] = useEntityBlockEditor('postType', postType, {
|
|
235
250
|
id: postId
|
|
236
251
|
});
|
|
237
252
|
|
|
238
|
-
// Process comments to build the tree structure
|
|
253
|
+
// Process comments to build the tree structure.
|
|
239
254
|
const {
|
|
240
255
|
resultComments,
|
|
241
|
-
|
|
256
|
+
unresolvedSortedThreads
|
|
242
257
|
} = useMemo(() => {
|
|
243
|
-
// Create a compare to store the references to all objects by id
|
|
258
|
+
// Create a compare to store the references to all objects by id.
|
|
244
259
|
const compare = {};
|
|
245
260
|
const result = [];
|
|
246
|
-
const
|
|
261
|
+
const allComments = threads !== null && threads !== void 0 ? threads : [];
|
|
247
262
|
|
|
248
|
-
// Initialize each object with an empty `reply` array
|
|
249
|
-
|
|
263
|
+
// Initialize each object with an empty `reply` array.
|
|
264
|
+
allComments.forEach(item => {
|
|
250
265
|
compare[item.id] = {
|
|
251
266
|
...item,
|
|
252
267
|
reply: []
|
|
253
268
|
};
|
|
254
269
|
});
|
|
255
270
|
|
|
256
|
-
// Iterate over the data to build the tree structure
|
|
257
|
-
|
|
271
|
+
// Iterate over the data to build the tree structure.
|
|
272
|
+
allComments.forEach(item => {
|
|
258
273
|
if (item.parent === 0) {
|
|
259
|
-
// If parent is 0, it's a root item, push it to the result array
|
|
274
|
+
// If parent is 0, it's a root item, push it to the result array.
|
|
260
275
|
result.push(compare[item.id]);
|
|
261
276
|
} else if (compare[item.parent]) {
|
|
262
|
-
// Otherwise, find its parent and push it to the parent's `reply` array
|
|
277
|
+
// Otherwise, find its parent and push it to the parent's `reply` array.
|
|
263
278
|
compare[item.parent].reply.push(compare[item.id]);
|
|
264
279
|
}
|
|
265
280
|
});
|
|
266
281
|
if (0 === result?.length) {
|
|
267
282
|
return {
|
|
268
283
|
resultComments: [],
|
|
269
|
-
|
|
284
|
+
unresolvedSortedThreads: []
|
|
270
285
|
};
|
|
271
286
|
}
|
|
272
287
|
const updatedResult = result.map(item => ({
|
|
@@ -275,10 +290,12 @@ export default function CollabSidebar() {
|
|
|
275
290
|
}));
|
|
276
291
|
const blockCommentIds = getCommentIdsFromBlocks(blocks);
|
|
277
292
|
const threadIdMap = new Map(updatedResult.map(thread => [thread.id, thread]));
|
|
278
|
-
|
|
293
|
+
|
|
294
|
+
// Get comments by block order, filter out undefined threads, and exclude resolved comments.
|
|
295
|
+
const unresolvedSortedComments = blockCommentIds.map(id => threadIdMap.get(id)).filter(thread => thread !== undefined && thread.status !== 'approved');
|
|
279
296
|
return {
|
|
280
297
|
resultComments: updatedResult,
|
|
281
|
-
|
|
298
|
+
unresolvedSortedThreads: unresolvedSortedComments
|
|
282
299
|
};
|
|
283
300
|
}, [threads, blocks]);
|
|
284
301
|
|
|
@@ -296,13 +313,20 @@ export default function CollabSidebar() {
|
|
|
296
313
|
}
|
|
297
314
|
});
|
|
298
315
|
}
|
|
299
|
-
|
|
300
|
-
|
|
316
|
+
const AddCommentComponent = blockCommentId ? CommentAvatarIndicator : AddCommentButton;
|
|
317
|
+
|
|
318
|
+
// Find the current thread for the selected block.
|
|
319
|
+
const currentThread = blockCommentId ? resultComments.find(thread => thread.id === blockCommentId) : null;
|
|
320
|
+
|
|
321
|
+
// If postId is not a valid number, do not render the comment sidebar.
|
|
322
|
+
if (!(!!postId && typeof postId === 'number')) {
|
|
323
|
+
return null;
|
|
301
324
|
}
|
|
302
|
-
const AddCommentComponent = blockCommentId ? AddCommentToolbarButton : AddCommentButton;
|
|
303
325
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
304
326
|
children: [/*#__PURE__*/_jsx(AddCommentComponent, {
|
|
305
|
-
onClick: openCollabBoard
|
|
327
|
+
onClick: openCollabBoard,
|
|
328
|
+
thread: currentThread,
|
|
329
|
+
hasMoreComments: hasMoreComments
|
|
306
330
|
}), /*#__PURE__*/_jsx(PluginSidebar, {
|
|
307
331
|
identifier: collabHistorySidebarName
|
|
308
332
|
// translators: Comments sidebar title
|
|
@@ -321,7 +345,7 @@ export default function CollabSidebar() {
|
|
|
321
345
|
className: "editor-collab-sidebar",
|
|
322
346
|
headerClassName: "editor-collab-sidebar__header",
|
|
323
347
|
children: /*#__PURE__*/_jsx(CollabSidebarContent, {
|
|
324
|
-
comments:
|
|
348
|
+
comments: unresolvedSortedThreads,
|
|
325
349
|
showCommentBoard: showCommentBoard,
|
|
326
350
|
setShowCommentBoard: setShowCommentBoard,
|
|
327
351
|
styles: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","useSelect","useDispatch","resolveSelect","subscribe","useState","useMemo","comment","commentIcon","addFilter","store","noticesStore","coreStore","useEntityBlockEditor","blockEditorStore","interfaceStore","PluginSidebar","collabHistorySidebarName","collabSidebarName","Comments","AddComment","editorStore","AddCommentButton","AddCommentToolbarButton","useGlobalStylesContext","getCommentIdsFromBlocks","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","modifyBlockCommentAttributes","settings","attributes","blockCommentId","type","CollabSidebarContent","showCommentBoard","setShowCommentBoard","styles","comments","createNotice","saveEntityRecord","deleteEntityRecord","getEntityRecord","postId","select","getCurrentPostId","_postId","getSelectedBlockClientId","updateBlockAttributes","addNewComment","parentCommentId","args","post","content","comment_type","comment_approved","updatedArgs","parent","savedRecord","id","isDismissible","onError","onCommentResolve","commentId","status","onEditComment","onCommentDelete","childComment","undefined","className","style","children","onSubmit","threads","onAddReply","CollabSidebar","enableComplementaryArea","getActiveComplementaryArea","postType","postStatus","getCurrentPostType","data","getEntityRecords","per_page","getEditedPostAttribute","getBlockAttributes","_clientId","openCollabBoard","blocks","resultComments","sortedThreads","compare","result","filteredComments","filter","forEach","item","reply","push","length","updatedResult","map","reverse","blockCommentIds","threadIdMap","Map","thread","sortedComments","get","merged","GlobalStyles","backgroundColor","color","background","unsubscribe","activeSidebar","AddCommentComponent","onClick","identifier","title","icon","isPinnable","header","headerClassName"],"sources":["@wordpress/editor/src/components/collab-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseSelect,\n\tuseDispatch,\n\tresolveSelect,\n\tsubscribe,\n} from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PluginSidebar from '../plugin-sidebar';\nimport { collabHistorySidebarName, collabSidebarName } from './constants';\nimport { Comments } from './comments';\nimport { AddComment } from './add-comment';\nimport { store as editorStore } from '../../store';\nimport AddCommentButton from './comment-button';\nimport AddCommentToolbarButton from './comment-button-toolbar';\nimport { useGlobalStylesContext } from '../global-styles-provider';\nimport { getCommentIdsFromBlocks } from './utils';\n\nconst modifyBlockCommentAttributes = ( settings ) => {\n\tif ( ! settings.attributes.blockCommentId ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tblockCommentId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n};\n\n// Apply the filter to all core blocks\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-comment/modify-core-block-attributes',\n\tmodifyBlockCommentAttributes\n);\n\nfunction CollabSidebarContent( {\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tstyles,\n\tcomments,\n} ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getEntityRecord } = resolveSelect( coreStore );\n\n\tconst { postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t};\n\t}, [] );\n\n\tconst { getSelectedBlockClientId } = useSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\t// Function to save the comment.\n\tconst addNewComment = async ( comment, parentCommentId ) => {\n\t\tconst args = {\n\t\t\tpost: postId,\n\t\t\tcontent: comment,\n\t\t\tcomment_type: 'block_comment',\n\t\t\tcomment_approved: 0,\n\t\t};\n\n\t\t// Create a new object, conditionally including the parent property\n\t\tconst updatedArgs = {\n\t\t\t...args,\n\t\t\t...( parentCommentId ? { parent: parentCommentId } : {} ),\n\t\t};\n\n\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tupdatedArgs\n\t\t);\n\n\t\tif ( savedRecord ) {\n\t\t\t// If it's a main comment, update the block attributes with the comment id.\n\t\t\tif ( ! parentCommentId ) {\n\t\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\t\tblockCommentId: savedRecord?.id,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tparentCommentId\n\t\t\t\t\t? // translators: Reply added successfully\n\t\t\t\t\t __( 'Reply added successfully.' )\n\t\t\t\t\t: // translators: Comment added successfully\n\t\t\t\t\t __( 'Comment added successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onCommentResolve = async ( commentId ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tstatus: 'approved',\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\t// translators: Comment resolved successfully\n\t\t\tcreateNotice( 'snackbar', __( 'Comment marked as resolved.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onEditComment = async ( commentId, comment ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tcontent: comment,\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\t// translators: Comment edited successfully\n\t\t\t\t__( 'Comment edited successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onError = () => {\n\t\tcreateNotice(\n\t\t\t'error',\n\t\t\t// translators: Error message when comment submission fails\n\t\t\t__(\n\t\t\t\t'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\tconst onCommentDelete = async ( commentId ) => {\n\t\tconst childComment = await getEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tcommentId\n\t\t);\n\t\tawait deleteEntityRecord( 'root', 'comment', commentId );\n\n\t\tif ( childComment && ! childComment.parent ) {\n\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\tblockCommentId: undefined,\n\t\t\t} );\n\t\t}\n\n\t\tcreateNotice(\n\t\t\t'snackbar',\n\t\t\t// translators: Comment deleted successfully\n\t\t\t__( 'Comment deleted successfully.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\treturn (\n\t\t<div className=\"editor-collab-sidebar-panel\" style={ styles }>\n\t\t\t<AddComment\n\t\t\t\tonSubmit={ addNewComment }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t\t<Comments\n\t\t\t\tkey={ getSelectedBlockClientId() }\n\t\t\t\tthreads={ comments }\n\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\tonAddReply={ addNewComment }\n\t\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\t\tonCommentResolve={ onCommentResolve }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\n/**\n * Renders the Collab sidebar.\n */\nexport default function CollabSidebar() {\n\tconst [ showCommentBoard, setShowCommentBoard ] = useState( false );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst { getActiveComplementaryArea } = useSelect( interfaceStore );\n\n\tconst { postId, postType, postStatus, threads } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\t\tconst data =\n\t\t\t!! _postId && typeof _postId === 'number'\n\t\t\t\t? select( coreStore ).getEntityRecords( 'root', 'comment', {\n\t\t\t\t\t\tpost: _postId,\n\t\t\t\t\t\ttype: 'block_comment',\n\t\t\t\t\t\tstatus: 'any',\n\t\t\t\t\t\tper_page: 100,\n\t\t\t\t } )\n\t\t\t\t: null;\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostStatus:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'status' ),\n\t\t\tthreads: data,\n\t\t};\n\t}, [] );\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 openCollabBoard = () => {\n\t\tsetShowCommentBoard( true );\n\t\tenableComplementaryArea( 'core', 'edit-post/collab-sidebar' );\n\t};\n\n\tconst [ blocks ] = useEntityBlockEditor( 'postType', postType, {\n\t\tid: postId,\n\t} );\n\n\t// Process comments to build the tree structure\n\tconst { resultComments, sortedThreads } = 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 filteredComments = ( threads ?? [] ).filter(\n\t\t\t( comment ) => comment.status !== 'trash'\n\t\t);\n\n\t\t// Initialize each object with an empty `reply` array\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tcompare[ item.id ] = { ...item, reply: [] };\n\t\t} );\n\n\t\t// Iterate over the data to build the tree structure\n\t\tfilteredComments.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: [], sortedThreads: [] };\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 blockCommentIds = getCommentIdsFromBlocks( blocks );\n\n\t\tconst threadIdMap = new Map(\n\t\t\tupdatedResult.map( ( thread ) => [ thread.id, thread ] )\n\t\t);\n\n\t\tconst sortedComments = blockCommentIds\n\t\t\t.map( ( id ) => threadIdMap.get( id ) )\n\t\t\t.filter( ( thread ) => thread !== undefined );\n\n\t\treturn { resultComments: updatedResult, sortedThreads: sortedComments };\n\t}, [ threads, blocks ] );\n\n\t// Get the global styles to set the background color of the sidebar.\n\tconst { merged: GlobalStyles } = useGlobalStylesContext();\n\tconst backgroundColor = GlobalStyles?.styles?.color?.background;\n\n\tif ( 0 < resultComments.length ) {\n\t\tconst unsubscribe = subscribe( () => {\n\t\t\tconst activeSidebar = getActiveComplementaryArea( 'core' );\n\n\t\t\tif ( ! activeSidebar ) {\n\t\t\t\tenableComplementaryArea( 'core', collabSidebarName );\n\t\t\t\tunsubscribe();\n\t\t\t}\n\t\t} );\n\t}\n\n\tif ( postStatus === 'publish' ) {\n\t\treturn null; // or maybe return some message indicating no threads are available.\n\t}\n\n\tconst AddCommentComponent = blockCommentId\n\t\t? AddCommentToolbarButton\n\t\t: AddCommentButton;\n\n\treturn (\n\t\t<>\n\t\t\t<AddCommentComponent onClick={ openCollabBoard } />\n\t\t\t<PluginSidebar\n\t\t\t\tidentifier={ collabHistorySidebarName }\n\t\t\t\t// translators: Comments sidebar title\n\t\t\t\ttitle={ __( 'Comments' ) }\n\t\t\t\ticon={ commentIcon }\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ resultComments }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t\t<PluginSidebar\n\t\t\t\tisPinnable={ false }\n\t\t\t\theader={ false }\n\t\t\t\tidentifier={ collabSidebarName }\n\t\t\t\tclassName=\"editor-collab-sidebar\"\n\t\t\t\theaderClassName=\"editor-collab-sidebar__header\"\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ sortedThreads }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\tstyles={ {\n\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SACCC,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,SAAS,QACH,iBAAiB;AACxB,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,OAAO,IAAIC,WAAW,QAAQ,kBAAkB;AACzD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASD,KAAK,IAAIE,SAAS,EAAEC,oBAAoB,QAAQ,sBAAsB;AAC/E,SAASH,KAAK,IAAII,gBAAgB,QAAQ,yBAAyB;AACnE,SAASJ,KAAK,IAAIK,cAAc,QAAQ,sBAAsB;;AAE9D;AACA;AACA;AACA,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,SAASC,wBAAwB,EAAEC,iBAAiB,QAAQ,aAAa;AACzE,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASV,KAAK,IAAIW,WAAW,QAAQ,aAAa;AAClD,OAAOC,gBAAgB,MAAM,kBAAkB;AAC/C,OAAOC,uBAAuB,MAAM,0BAA0B;AAC9D,SAASC,sBAAsB,QAAQ,2BAA2B;AAClE,SAASC,uBAAuB,QAAQ,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAA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ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["__","useSelect","useDispatch","resolveSelect","subscribe","useState","useMemo","comment","commentIcon","addFilter","store","noticesStore","coreStore","useEntityBlockEditor","useEntityRecords","blockEditorStore","interfaceStore","PluginSidebar","collabHistorySidebarName","collabSidebarName","Comments","AddComment","editorStore","AddCommentButton","CommentAvatarIndicator","useGlobalStylesContext","getCommentIdsFromBlocks","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","modifyBlockCommentAttributes","settings","attributes","blockCommentId","type","CollabSidebarContent","showCommentBoard","setShowCommentBoard","styles","comments","createNotice","saveEntityRecord","deleteEntityRecord","getEntityRecord","postId","select","getCurrentPostId","_postId","getSelectedBlockClientId","updateBlockAttributes","onError","error","errorMessage","message","code","isDismissible","addNewComment","parentCommentId","savedRecord","post","content","comment_type","comment_approved","parent","throwOnError","id","onCommentResolve","commentId","status","onCommentReopen","onEditComment","onCommentDelete","childComment","undefined","className","style","children","onSubmit","threads","onAddReply","CollabSidebar","enableComplementaryArea","getActiveComplementaryArea","postType","getCurrentPostType","queryArgs","per_page","records","totalPages","enabled","hasMoreComments","getBlockAttributes","_clientId","openCollabBoard","blocks","resultComments","unresolvedSortedThreads","compare","result","allComments","forEach","item","reply","push","length","updatedResult","map","reverse","blockCommentIds","threadIdMap","Map","thread","unresolvedSortedComments","get","filter","merged","GlobalStyles","backgroundColor","color","background","unsubscribe","activeSidebar","AddCommentComponent","currentThread","find","onClick","identifier","title","icon","isPinnable","header","headerClassName"],"sources":["@wordpress/editor/src/components/collab-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseSelect,\n\tuseDispatch,\n\tresolveSelect,\n\tsubscribe,\n} from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as noticesStore } from '@wordpress/notices';\nimport {\n\tstore as coreStore,\n\tuseEntityBlockEditor,\n\tuseEntityRecords,\n} from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PluginSidebar from '../plugin-sidebar';\nimport { collabHistorySidebarName, collabSidebarName } from './constants';\nimport { Comments } from './comments';\nimport { AddComment } from './add-comment';\nimport { store as editorStore } from '../../store';\nimport AddCommentButton from './comment-button';\nimport CommentAvatarIndicator from './comment-indicator-toolbar';\nimport { useGlobalStylesContext } from '../global-styles-provider';\nimport { getCommentIdsFromBlocks } from './utils';\n\nconst modifyBlockCommentAttributes = ( settings ) => {\n\tif ( ! settings.attributes.blockCommentId ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tblockCommentId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n};\n\n// Apply the filter to all core blocks\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-comment/modify-core-block-attributes',\n\tmodifyBlockCommentAttributes\n);\n\nfunction CollabSidebarContent( {\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tstyles,\n\tcomments,\n} ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getEntityRecord } = resolveSelect( coreStore );\n\n\tconst { postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t};\n\t}, [] );\n\n\tconst { getSelectedBlockClientId } = useSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst onError = ( error ) => {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'An error occurred while performing an update.' );\n\t\tcreateNotice( 'error', errorMessage, {\n\t\t\ttype: 'snackbar',\n\t\t\tisDismissible: true,\n\t\t} );\n\t};\n\n\tconst addNewComment = async ( comment, parentCommentId ) => {\n\t\ttry {\n\t\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\t{\n\t\t\t\t\tpost: postId,\n\t\t\t\t\tcontent: comment,\n\t\t\t\t\tcomment_type: 'block_comment',\n\t\t\t\t\tcomment_approved: 0,\n\t\t\t\t\t...( parentCommentId ? { parent: parentCommentId } : {} ),\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\t// If it's a main comment, update the block attributes with the comment id.\n\t\t\tif ( ! parentCommentId && savedRecord?.id ) {\n\t\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\t\tblockCommentId: savedRecord.id,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tparentCommentId\n\t\t\t\t\t? __( 'Reply added successfully.' )\n\t\t\t\t\t: __( 'Comment added successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onCommentResolve = async ( commentId ) => {\n\t\ttry {\n\t\t\tawait saveEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\t{\n\t\t\t\t\tid: commentId,\n\t\t\t\t\tstatus: 'approved',\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tcreateNotice( 'snackbar', __( 'Comment marked as resolved.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onCommentReopen = async ( commentId ) => {\n\t\ttry {\n\t\t\tawait saveEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\t{\n\t\t\t\t\tid: commentId,\n\t\t\t\t\tstatus: 'hold',\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tcreateNotice( 'snackbar', __( 'Comment reopened.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onEditComment = async ( commentId, comment ) => {\n\t\ttry {\n\t\t\tawait saveEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\t{\n\t\t\t\t\tid: commentId,\n\t\t\t\t\tcontent: comment,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tcreateNotice( 'snackbar', __( 'Comment edited successfully.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onCommentDelete = async ( commentId ) => {\n\t\ttry {\n\t\t\tconst childComment = await getEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\tcommentId\n\t\t\t);\n\t\t\tawait deleteEntityRecord( 'root', 'comment', commentId, undefined, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\n\t\t\tif ( childComment && ! childComment.parent ) {\n\t\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\t\tblockCommentId: undefined,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice( 'snackbar', __( 'Comment deleted successfully.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\treturn (\n\t\t<div className=\"editor-collab-sidebar-panel\" style={ styles }>\n\t\t\t<AddComment\n\t\t\t\tonSubmit={ addNewComment }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t\t<Comments\n\t\t\t\tkey={ getSelectedBlockClientId() }\n\t\t\t\tthreads={ comments }\n\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\tonAddReply={ addNewComment }\n\t\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\t\tonCommentResolve={ onCommentResolve }\n\t\t\t\tonCommentReopen={ onCommentReopen }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\n/**\n * Renders the Collab sidebar.\n */\nexport default function CollabSidebar() {\n\tconst [ showCommentBoard, setShowCommentBoard ] = useState( false );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst { getActiveComplementaryArea } = useSelect( interfaceStore );\n\n\tconst { postId, postType } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\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 hasMoreComments = totalPages && totalPages > 1;\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 openCollabBoard = () => {\n\t\tsetShowCommentBoard( true );\n\t\tenableComplementaryArea( 'core', collabHistorySidebarName );\n\t};\n\n\tconst [ blocks ] = useEntityBlockEditor( 'postType', postType, {\n\t\tid: postId,\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.\n\t\tallComments.forEach( ( item ) => {\n\t\t\tcompare[ item.id ] = { ...item, reply: [] };\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 blockCommentIds = getCommentIdsFromBlocks( blocks );\n\n\t\tconst threadIdMap = new Map(\n\t\t\tupdatedResult.map( ( thread ) => [ 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 = blockCommentIds\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, blocks ] );\n\n\t// Get the global styles to set the background color of the sidebar.\n\tconst { merged: GlobalStyles } = useGlobalStylesContext();\n\tconst backgroundColor = GlobalStyles?.styles?.color?.background;\n\n\tif ( 0 < resultComments.length ) {\n\t\tconst unsubscribe = subscribe( () => {\n\t\t\tconst activeSidebar = getActiveComplementaryArea( 'core' );\n\n\t\t\tif ( ! activeSidebar ) {\n\t\t\t\tenableComplementaryArea( 'core', collabSidebarName );\n\t\t\t\tunsubscribe();\n\t\t\t}\n\t\t} );\n\t}\n\n\tconst AddCommentComponent = blockCommentId\n\t\t? CommentAvatarIndicator\n\t\t: AddCommentButton;\n\n\t// Find the current thread for the selected block.\n\tconst currentThread = blockCommentId\n\t\t? resultComments.find( ( thread ) => thread.id === blockCommentId )\n\t\t: null;\n\n\t// If postId is not a valid number, do not render the comment sidebar.\n\tif ( ! ( !! postId && typeof postId === 'number' ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<AddCommentComponent\n\t\t\t\tonClick={ openCollabBoard }\n\t\t\t\tthread={ currentThread }\n\t\t\t\thasMoreComments={ hasMoreComments }\n\t\t\t/>\n\t\t\t<PluginSidebar\n\t\t\t\tidentifier={ collabHistorySidebarName }\n\t\t\t\t// translators: Comments sidebar title\n\t\t\t\ttitle={ __( 'Comments' ) }\n\t\t\t\ticon={ commentIcon }\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ resultComments }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t\t<PluginSidebar\n\t\t\t\tisPinnable={ false }\n\t\t\t\theader={ false }\n\t\t\t\tidentifier={ collabSidebarName }\n\t\t\t\tclassName=\"editor-collab-sidebar\"\n\t\t\t\theaderClassName=\"editor-collab-sidebar__header\"\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ unresolvedSortedThreads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hC,eAAiB;MAC3BkB,MAAM,EAAGY,aAAe;MACxBjC,eAAe,EAAGA;IAAiB,CACnC,CAAC,eACFjE,IAAA,CAACX,aAAa;MACbgH,UAAU,EAAG/G;MACb;MAAA;MACAgH,KAAK,EAAGlI,EAAE,CAAE,UAAW,CAAG;MAC1BmI,IAAI,EAAG3H,WAAa;MAAAuE,QAAA,eAEpBnD,IAAA,CAACU,oBAAoB;QACpBI,QAAQ,EAAGwD,cAAgB;QAC3B3D,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA;MAAqB,CAC3C;IAAC,CACY,CAAC,eAChBZ,IAAA,CAACX,aAAa;MACbmH,UAAU,EAAG,KAAO;MACpBC,MAAM,EAAG,KAAO;MAChBJ,UAAU,EAAG9G,iBAAmB;MAChC0D,SAAS,EAAC,uBAAuB;MACjCyD,eAAe,EAAC,+BAA+B;MAAAvD,QAAA,eAE/CnD,IAAA,CAACU,oBAAoB;QACpBI,QAAQ,EAAGyD,uBAAyB;QACpC5D,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA,mBAAqB;QAC3CC,MAAM,EAAG;UACR+E;QACD;MAAG,CACH;IAAC,CACY,CAAC;EAAA,CACf,CAAC;AAEL","ignoreList":[]}
|
|
@@ -84,11 +84,13 @@ function PrivateExcerpt() {
|
|
|
84
84
|
shouldBeUsedAsDescription,
|
|
85
85
|
allowEditing
|
|
86
86
|
} = useSelect(select => {
|
|
87
|
+
var _getEditedPostAttribu;
|
|
87
88
|
const {
|
|
88
89
|
getCurrentPostType,
|
|
89
90
|
getCurrentPostId,
|
|
90
91
|
getEditedPostAttribute,
|
|
91
|
-
isEditorPanelEnabled
|
|
92
|
+
isEditorPanelEnabled,
|
|
93
|
+
__experimentalGetDefaultTemplateType
|
|
92
94
|
} = select(editorStore);
|
|
93
95
|
const postType = getCurrentPostType();
|
|
94
96
|
const isTemplateOrTemplatePart = ['wp_template', 'wp_template_part'].includes(postType);
|
|
@@ -99,11 +101,12 @@ function PrivateExcerpt() {
|
|
|
99
101
|
const _usedAttribute = isTemplateOrTemplatePart ? 'description' : 'excerpt';
|
|
100
102
|
// We need to fetch the entity in this case to check if we'll allow editing.
|
|
101
103
|
const template = isTemplateOrTemplatePart && select(coreStore).getEntityRecord('postType', postType, getCurrentPostId());
|
|
104
|
+
const fallback = isTemplateOrTemplatePart ? __experimentalGetDefaultTemplateType(template.slug).description : undefined;
|
|
102
105
|
// For post types that use excerpt as description, we do not abide
|
|
103
106
|
// by the `isEnabled` panel flag in order to render them as text.
|
|
104
107
|
const _shouldRender = isEditorPanelEnabled(PANEL_NAME) || _shouldBeUsedAsDescription;
|
|
105
108
|
return {
|
|
106
|
-
excerpt: getEditedPostAttribute(_usedAttribute),
|
|
109
|
+
excerpt: (_getEditedPostAttribu = getEditedPostAttribute(_usedAttribute)) !== null && _getEditedPostAttribu !== void 0 ? _getEditedPostAttribu : fallback,
|
|
107
110
|
shouldRender: _shouldRender,
|
|
108
111
|
shouldBeUsedAsDescription: _shouldBeUsedAsDescription,
|
|
109
112
|
// If we should render, allow editing for all post types that are not used as description.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","PanelBody","__experimentalText","Text","Dropdown","Button","__experimentalVStack","VStack","useDispatch","useSelect","useMemo","useState","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","store","coreStore","decodeEntities","PostExcerptForm","PostExcerptCheck","PluginPostExcerpt","TEMPLATE_ORIGINS","editorStore","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PANEL_NAME","ExcerptPanel","isOpened","isEnabled","postType","select","isEditorPanelOpened","isEditorPanelEnabled","getCurrentPostType","toggleEditorPanelOpened","toggleExcerptPanel","shouldUseDescriptionLabel","includes","title","opened","onToggle","children","Slot","fills","PostExcerptPanel","PrivatePostExcerptPanel","PrivateExcerpt","shouldRender","excerpt","shouldBeUsedAsDescription","allowEditing","getCurrentPostId","getEditedPostAttribute","isTemplateOrTemplatePart","isPattern","_shouldBeUsedAsDescription","_usedAttribute","template","getEntityRecord","_shouldRender","source","custom","has_theme_file","is_custom","popoverAnchor","setPopoverAnchor","label","popoverProps","anchor","headerTitle","placement","offset","shift","excerptText","align","numberOfLines","truncate","excerptPlaceholder","triggerEditLabel","className","contentClassName","focusOnMount","ref","renderToggle","__next40pxDefaultSize","onClick","variant","renderContent","onClose","spacing","hideLabelFromVision","updateOnBlur"],"sources":["@wordpress/editor/src/components/post-excerpt/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tPanelBody,\n\t__experimentalText as Text,\n\tDropdown,\n\tButton,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMemo, useState } from '@wordpress/element';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport PostExcerptForm from './index';\nimport PostExcerptCheck from './check';\nimport PluginPostExcerpt from './plugin';\nimport { TEMPLATE_ORIGINS } from '../../store/constants';\nimport { store as editorStore } from '../../store';\n\n/**\n * Module Constants\n */\nconst PANEL_NAME = 'post-excerpt';\n\nfunction ExcerptPanel() {\n\tconst { isOpened, isEnabled, postType } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisEditorPanelOpened,\n\t\t\tisEditorPanelEnabled,\n\t\t\tgetCurrentPostType,\n\t\t} = select( editorStore );\n\n\t\treturn {\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\tconst { toggleEditorPanelOpened } = useDispatch( editorStore );\n\tconst toggleExcerptPanel = () => toggleEditorPanelOpened( PANEL_NAME );\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\t// There are special cases where we want to label the excerpt as a description.\n\tconst shouldUseDescriptionLabel = [\n\t\t'wp_template',\n\t\t'wp_template_part',\n\t\t'wp_block',\n\t].includes( postType );\n\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={\n\t\t\t\tshouldUseDescriptionLabel\n\t\t\t\t\t? __( 'Description' )\n\t\t\t\t\t: __( 'Excerpt' )\n\t\t\t}\n\t\t\topened={ isOpened }\n\t\t\tonToggle={ toggleExcerptPanel }\n\t\t>\n\t\t\t<PluginPostExcerpt.Slot>\n\t\t\t\t{ ( fills ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<PostExcerptForm />\n\t\t\t\t\t\t{ fills }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</PluginPostExcerpt.Slot>\n\t\t</PanelBody>\n\t);\n}\n\n/**\n * Is rendered if the post type supports excerpts and allows editing the excerpt.\n *\n * @return {React.ReactNode} The rendered PostExcerptPanel component.\n */\nexport default function PostExcerptPanel() {\n\treturn (\n\t\t<PostExcerptCheck>\n\t\t\t<ExcerptPanel />\n\t\t</PostExcerptCheck>\n\t);\n}\n\nexport function PrivatePostExcerptPanel() {\n\treturn (\n\t\t<PostExcerptCheck>\n\t\t\t<PrivateExcerpt />\n\t\t</PostExcerptCheck>\n\t);\n}\n\nfunction PrivateExcerpt() {\n\tconst { shouldRender, excerpt, shouldBeUsedAsDescription, allowEditing } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetCurrentPostId,\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t\tisEditorPanelEnabled,\n\t\t\t} = select( editorStore );\n\t\t\tconst postType = getCurrentPostType();\n\t\t\tconst isTemplateOrTemplatePart = [\n\t\t\t\t'wp_template',\n\t\t\t\t'wp_template_part',\n\t\t\t].includes( postType );\n\t\t\tconst isPattern = postType === 'wp_block';\n\t\t\t// These post types use the `excerpt` field as a description semantically, so we need to\n\t\t\t// handle proper labeling and some flows where we should always render them as text.\n\t\t\tconst _shouldBeUsedAsDescription =\n\t\t\t\tisTemplateOrTemplatePart || isPattern;\n\t\t\tconst _usedAttribute = isTemplateOrTemplatePart\n\t\t\t\t? 'description'\n\t\t\t\t: 'excerpt';\n\t\t\t// We need to fetch the entity in this case to check if we'll allow editing.\n\t\t\tconst template =\n\t\t\t\tisTemplateOrTemplatePart &&\n\t\t\t\tselect( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tgetCurrentPostId()\n\t\t\t\t);\n\t\t\t// For post types that use excerpt as description, we do not abide\n\t\t\t// by the `isEnabled` panel flag in order to render them as text.\n\t\t\tconst _shouldRender =\n\t\t\t\tisEditorPanelEnabled( PANEL_NAME ) ||\n\t\t\t\t_shouldBeUsedAsDescription;\n\t\t\treturn {\n\t\t\t\texcerpt: getEditedPostAttribute( _usedAttribute ),\n\t\t\t\tshouldRender: _shouldRender,\n\t\t\t\tshouldBeUsedAsDescription: _shouldBeUsedAsDescription,\n\t\t\t\t// If we should render, allow editing for all post types that are not used as description.\n\t\t\t\t// For the rest allow editing only for user generated entities.\n\t\t\t\tallowEditing:\n\t\t\t\t\t_shouldRender &&\n\t\t\t\t\t( ! _shouldBeUsedAsDescription ||\n\t\t\t\t\t\tisPattern ||\n\t\t\t\t\t\t( template &&\n\t\t\t\t\t\t\ttemplate.source === TEMPLATE_ORIGINS.custom &&\n\t\t\t\t\t\t\t! template.has_theme_file &&\n\t\t\t\t\t\t\ttemplate.is_custom ) ),\n\t\t\t};\n\t\t}, [] );\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst label = shouldBeUsedAsDescription\n\t\t? __( 'Description' )\n\t\t: __( 'Excerpt' );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\t'aria-label': label,\n\t\t\theaderTitle: label,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor, label ]\n\t);\n\tif ( ! shouldRender ) {\n\t\treturn false;\n\t}\n\tconst excerptText = !! excerpt && (\n\t\t<Text align=\"left\" numberOfLines={ 4 } truncate={ allowEditing }>\n\t\t\t{ decodeEntities( excerpt ) }\n\t\t</Text>\n\t);\n\tif ( ! allowEditing ) {\n\t\treturn excerptText;\n\t}\n\tconst excerptPlaceholder = shouldBeUsedAsDescription\n\t\t? __( 'Add a description…' )\n\t\t: __( 'Add an excerpt…' );\n\tconst triggerEditLabel = shouldBeUsedAsDescription\n\t\t? __( 'Edit description' )\n\t\t: __( 'Edit excerpt' );\n\treturn (\n\t\t<VStack>\n\t\t\t{ excerptText }\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"editor-post-excerpt__dropdown\"\n\t\t\t\tcontentClassName=\"editor-post-excerpt__dropdown__content\"\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tfocusOnMount\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t\trenderToggle={ ( { onToggle } ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ excerptText ? triggerEditLabel : excerptPlaceholder }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\ttitle={ label }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t\t\t<PluginPostExcerpt.Slot>\n\t\t\t\t\t\t\t\t{ ( fills ) => (\n\t\t\t\t\t\t\t\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AE3C;MAAS,CAAC,kBAC5BpB,IAAA,CAAClB,MAAM;QACNkF,qBAAqB;QACrBC,OAAO,EAAG7C,QAAU;QACpB8C,OAAO,EAAC,MAAM;QAAA7C,QAAA,EAEZgC,WAAW,GAAGK,gBAAgB,GAAGD;MAAkB,CAC9C,CACN;MACHU,aAAa,EAAGA,CAAE;QAAEC;MAAQ,CAAC,kBAC5BhE,KAAA,CAAAF,SAAA;QAAAmB,QAAA,gBACCrB,IAAA,CAACV,sBAAsB;UACtB4B,KAAK,EAAG4B,KAAO;UACfsB,OAAO,EAAGA;QAAS,CACnB,CAAC,eAEFpE,IAAA,CAAChB,MAAM;UAACqF,OAAO,EAAG,CAAG;UAAAhD,QAAA,eACpBrB,IAAA,CAACJ,iBAAiB,CAAC0B,IAAI;YAAAD,QAAA,EAClBE,KAAK,iBACRnB,KAAA,CAAAF,SAAA;cAAAmB,QAAA,gBACCrB,IAAA,CAACN,eAAe;gBACf4E,mBAAmB;gBACnBC,YAAY;cAAA,CACZ,CAAC,EACAhD,KAAK;YAAA,CACN;UACF,CACsB;QAAC,CAClB,CAAC;MAAA,CACR;IACA,CACH,CAAC;EAAA,CACK,CAAC;AAEX","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["__","PanelBody","__experimentalText","Text","Dropdown","Button","__experimentalVStack","VStack","useDispatch","useSelect","useMemo","useState","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","store","coreStore","decodeEntities","PostExcerptForm","PostExcerptCheck","PluginPostExcerpt","TEMPLATE_ORIGINS","editorStore","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PANEL_NAME","ExcerptPanel","isOpened","isEnabled","postType","select","isEditorPanelOpened","isEditorPanelEnabled","getCurrentPostType","toggleEditorPanelOpened","toggleExcerptPanel","shouldUseDescriptionLabel","includes","title","opened","onToggle","children","Slot","fills","PostExcerptPanel","PrivatePostExcerptPanel","PrivateExcerpt","shouldRender","excerpt","shouldBeUsedAsDescription","allowEditing","_getEditedPostAttribu","getCurrentPostId","getEditedPostAttribute","__experimentalGetDefaultTemplateType","isTemplateOrTemplatePart","isPattern","_shouldBeUsedAsDescription","_usedAttribute","template","getEntityRecord","fallback","slug","description","undefined","_shouldRender","source","custom","has_theme_file","is_custom","popoverAnchor","setPopoverAnchor","label","popoverProps","anchor","headerTitle","placement","offset","shift","excerptText","align","numberOfLines","truncate","excerptPlaceholder","triggerEditLabel","className","contentClassName","focusOnMount","ref","renderToggle","__next40pxDefaultSize","onClick","variant","renderContent","onClose","spacing","hideLabelFromVision","updateOnBlur"],"sources":["@wordpress/editor/src/components/post-excerpt/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tPanelBody,\n\t__experimentalText as Text,\n\tDropdown,\n\tButton,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMemo, useState } from '@wordpress/element';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport PostExcerptForm from './index';\nimport PostExcerptCheck from './check';\nimport PluginPostExcerpt from './plugin';\nimport { TEMPLATE_ORIGINS } from '../../store/constants';\nimport { store as editorStore } from '../../store';\n\n/**\n * Module Constants\n */\nconst PANEL_NAME = 'post-excerpt';\n\nfunction ExcerptPanel() {\n\tconst { isOpened, isEnabled, postType } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisEditorPanelOpened,\n\t\t\tisEditorPanelEnabled,\n\t\t\tgetCurrentPostType,\n\t\t} = select( editorStore );\n\n\t\treturn {\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\tconst { toggleEditorPanelOpened } = useDispatch( editorStore );\n\tconst toggleExcerptPanel = () => toggleEditorPanelOpened( PANEL_NAME );\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\t// There are special cases where we want to label the excerpt as a description.\n\tconst shouldUseDescriptionLabel = [\n\t\t'wp_template',\n\t\t'wp_template_part',\n\t\t'wp_block',\n\t].includes( postType );\n\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={\n\t\t\t\tshouldUseDescriptionLabel\n\t\t\t\t\t? __( 'Description' )\n\t\t\t\t\t: __( 'Excerpt' )\n\t\t\t}\n\t\t\topened={ isOpened }\n\t\t\tonToggle={ toggleExcerptPanel }\n\t\t>\n\t\t\t<PluginPostExcerpt.Slot>\n\t\t\t\t{ ( fills ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<PostExcerptForm />\n\t\t\t\t\t\t{ fills }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</PluginPostExcerpt.Slot>\n\t\t</PanelBody>\n\t);\n}\n\n/**\n * Is rendered if the post type supports excerpts and allows editing the excerpt.\n *\n * @return {React.ReactNode} The rendered PostExcerptPanel component.\n */\nexport default function PostExcerptPanel() {\n\treturn (\n\t\t<PostExcerptCheck>\n\t\t\t<ExcerptPanel />\n\t\t</PostExcerptCheck>\n\t);\n}\n\nexport function PrivatePostExcerptPanel() {\n\treturn (\n\t\t<PostExcerptCheck>\n\t\t\t<PrivateExcerpt />\n\t\t</PostExcerptCheck>\n\t);\n}\n\nfunction PrivateExcerpt() {\n\tconst { shouldRender, excerpt, shouldBeUsedAsDescription, allowEditing } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetCurrentPostId,\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t\tisEditorPanelEnabled,\n\t\t\t\t__experimentalGetDefaultTemplateType,\n\t\t\t} = select( editorStore );\n\t\t\tconst postType = getCurrentPostType();\n\t\t\tconst isTemplateOrTemplatePart = [\n\t\t\t\t'wp_template',\n\t\t\t\t'wp_template_part',\n\t\t\t].includes( postType );\n\t\t\tconst isPattern = postType === 'wp_block';\n\t\t\t// These post types use the `excerpt` field as a description semantically, so we need to\n\t\t\t// handle proper labeling and some flows where we should always render them as text.\n\t\t\tconst _shouldBeUsedAsDescription =\n\t\t\t\tisTemplateOrTemplatePart || isPattern;\n\t\t\tconst _usedAttribute = isTemplateOrTemplatePart\n\t\t\t\t? 'description'\n\t\t\t\t: 'excerpt';\n\t\t\t// We need to fetch the entity in this case to check if we'll allow editing.\n\t\t\tconst template =\n\t\t\t\tisTemplateOrTemplatePart &&\n\t\t\t\tselect( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tgetCurrentPostId()\n\t\t\t\t);\n\t\t\tconst fallback = isTemplateOrTemplatePart\n\t\t\t\t? __experimentalGetDefaultTemplateType( template.slug )\n\t\t\t\t\t\t.description\n\t\t\t\t: undefined;\n\t\t\t// For post types that use excerpt as description, we do not abide\n\t\t\t// by the `isEnabled` panel flag in order to render them as text.\n\t\t\tconst _shouldRender =\n\t\t\t\tisEditorPanelEnabled( PANEL_NAME ) ||\n\t\t\t\t_shouldBeUsedAsDescription;\n\t\t\treturn {\n\t\t\t\texcerpt: getEditedPostAttribute( _usedAttribute ) ?? fallback,\n\t\t\t\tshouldRender: _shouldRender,\n\t\t\t\tshouldBeUsedAsDescription: _shouldBeUsedAsDescription,\n\t\t\t\t// If we should render, allow editing for all post types that are not used as description.\n\t\t\t\t// For the rest allow editing only for user generated entities.\n\t\t\t\tallowEditing:\n\t\t\t\t\t_shouldRender &&\n\t\t\t\t\t( ! _shouldBeUsedAsDescription ||\n\t\t\t\t\t\tisPattern ||\n\t\t\t\t\t\t( template &&\n\t\t\t\t\t\t\ttemplate.source === TEMPLATE_ORIGINS.custom &&\n\t\t\t\t\t\t\t! template.has_theme_file &&\n\t\t\t\t\t\t\ttemplate.is_custom ) ),\n\t\t\t};\n\t\t}, [] );\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst label = shouldBeUsedAsDescription\n\t\t? __( 'Description' )\n\t\t: __( 'Excerpt' );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\t'aria-label': label,\n\t\t\theaderTitle: label,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor, label ]\n\t);\n\tif ( ! shouldRender ) {\n\t\treturn false;\n\t}\n\tconst excerptText = !! excerpt && (\n\t\t<Text align=\"left\" numberOfLines={ 4 } truncate={ allowEditing }>\n\t\t\t{ decodeEntities( excerpt ) }\n\t\t</Text>\n\t);\n\tif ( ! allowEditing ) {\n\t\treturn excerptText;\n\t}\n\tconst excerptPlaceholder = shouldBeUsedAsDescription\n\t\t? __( 'Add a description…' )\n\t\t: __( 'Add an excerpt…' );\n\tconst triggerEditLabel = shouldBeUsedAsDescription\n\t\t? __( 'Edit description' )\n\t\t: __( 'Edit excerpt' );\n\treturn (\n\t\t<VStack>\n\t\t\t{ excerptText }\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"editor-post-excerpt__dropdown\"\n\t\t\t\tcontentClassName=\"editor-post-excerpt__dropdown__content\"\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tfocusOnMount\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t\trenderToggle={ ( { onToggle } ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ excerptText ? triggerEditLabel : excerptPlaceholder }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\ttitle={ label }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t\t\t<PluginPostExcerpt.Slot>\n\t\t\t\t\t\t\t\t{ ( fills ) => (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<PostExcerptForm\n\t\t\t\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\t\t\t\tupdateOnBlur\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t{ fills }\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</PluginPostExcerpt.Slot>\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SACCC,SAAS,EACTC,kBAAkB,IAAIC,IAAI,EAC1BC,QAAQ,EACRC,MAAM,EACNC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,oCAAoC,IAAIC,sBAAsB,QAAQ,yBAAyB;AACxG,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,cAAc,QAAQ,0BAA0B;;AAEzD;AACA;AACA;AACA,OAAOC,eAAe,MAAM,SAAS;AACrC,OAAOC,gBAAgB,MAAM,SAAS;AACtC,OAAOC,iBAAiB,MAAM,UAAU;AACxC,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASN,KAAK,IAAIO,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AAFA,SAAAC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