@wordpress/editor 14.33.3 → 14.33.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bindings/post-data.js +47 -63
- package/build/bindings/post-data.js.map +3 -3
- package/build/bindings/post-meta.js +45 -39
- package/build/bindings/post-meta.js.map +2 -2
- package/build/components/collab-sidebar/add-comment.js +8 -4
- package/build/components/collab-sidebar/add-comment.js.map +2 -2
- package/build/components/collab-sidebar/comment-author-info.js +27 -15
- package/build/components/collab-sidebar/comment-author-info.js.map +2 -2
- package/build/components/collab-sidebar/comment-indicator-toolbar.js +9 -23
- package/build/components/collab-sidebar/comment-indicator-toolbar.js.map +3 -3
- package/build/components/collab-sidebar/comments.js +32 -7
- package/build/components/collab-sidebar/comments.js.map +3 -3
- package/build/components/collab-sidebar/hooks.js +5 -3
- package/build/components/collab-sidebar/hooks.js.map +2 -2
- package/build/components/collab-sidebar/index.js +18 -7
- package/build/components/collab-sidebar/index.js.map +2 -2
- package/build/components/more-menu/index.js +1 -1
- package/build/components/more-menu/index.js.map +2 -2
- package/build/components/visual-editor/index.js +20 -9
- package/build/components/visual-editor/index.js.map +2 -2
- package/build/store/private-actions.js +8 -0
- package/build/store/private-actions.js.map +2 -2
- package/build/store/private-selectors.js +5 -0
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/reducer.js +10 -0
- package/build/store/reducer.js.map +2 -2
- package/build-module/bindings/post-data.js +47 -63
- package/build-module/bindings/post-data.js.map +2 -2
- package/build-module/bindings/post-meta.js +45 -39
- package/build-module/bindings/post-meta.js.map +2 -2
- package/build-module/components/collab-sidebar/add-comment.js +9 -5
- package/build-module/components/collab-sidebar/add-comment.js.map +2 -2
- package/build-module/components/collab-sidebar/comment-author-info.js +27 -15
- package/build-module/components/collab-sidebar/comment-author-info.js.map +2 -2
- package/build-module/components/collab-sidebar/comment-indicator-toolbar.js +15 -25
- package/build-module/components/collab-sidebar/comment-indicator-toolbar.js.map +2 -2
- package/build-module/components/collab-sidebar/comments.js +34 -8
- package/build-module/components/collab-sidebar/comments.js.map +2 -2
- package/build-module/components/collab-sidebar/hooks.js +5 -3
- package/build-module/components/collab-sidebar/hooks.js.map +2 -2
- package/build-module/components/collab-sidebar/index.js +18 -7
- package/build-module/components/collab-sidebar/index.js.map +2 -2
- package/build-module/components/more-menu/index.js +1 -1
- package/build-module/components/more-menu/index.js.map +2 -2
- package/build-module/components/visual-editor/index.js +20 -9
- package/build-module/components/visual-editor/index.js.map +2 -2
- package/build-module/store/private-actions.js +7 -0
- package/build-module/store/private-actions.js.map +2 -2
- package/build-module/store/private-selectors.js +4 -0
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/reducer.js +9 -0
- package/build-module/store/reducer.js.map +2 -2
- package/build-style/style-rtl.css +6 -43
- package/build-style/style.css +6 -43
- package/build-types/bindings/post-data.d.ts +18 -8
- package/build-types/bindings/post-meta.d.ts +1 -7
- package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comment-author-info.d.ts +5 -16
- package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
- package/build-types/components/visual-editor/index.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts +7 -0
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +7 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +10 -0
- package/build-types/store/reducer.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/bindings/post-data.js +63 -111
- package/src/bindings/post-meta.js +55 -46
- package/src/bindings/test/post-meta.js +211 -0
- package/src/components/collab-sidebar/add-comment.js +10 -5
- package/src/components/collab-sidebar/comment-author-info.js +33 -26
- package/src/components/collab-sidebar/comment-indicator-toolbar.js +19 -29
- package/src/components/collab-sidebar/comments.js +39 -8
- package/src/components/collab-sidebar/hooks.js +6 -4
- package/src/components/collab-sidebar/index.js +26 -8
- package/src/components/collab-sidebar/style.scss +6 -46
- package/src/components/more-menu/index.js +1 -1
- package/src/components/visual-editor/index.js +27 -6
- package/src/store/private-actions.js +13 -0
- package/src/store/private-selectors.js +10 -0
- package/src/store/reducer.js +16 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/collab-sidebar/comment-indicator-toolbar.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": ["blockEditorPrivateApis"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tToolbarButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { getAvatarBorderColor } from './utils';\n\nconst { CommentIconToolbarSlotFill } = unlock( blockEditorPrivateApis );\n\nconst CommentAvatarIndicator = ( { onClick, thread } ) => {\n\tconst threadParticipants = useMemo( () => {\n\t\tif ( ! thread ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst participantsMap = new Map();\n\t\tconst allComments = [ thread, ...thread.reply ];\n\n\t\t// Sort by date to show participants in chronological order.\n\t\tallComments.sort( ( a, b ) => new Date( a.date ) - new Date( b.date ) );\n\n\t\tallComments.forEach( ( comment ) => {\n\t\t\t// Track thread participants (original commenter + repliers).\n\t\t\tif ( comment.author_name && comment.author_avatar_urls ) {\n\t\t\t\tif ( ! participantsMap.has( comment.author ) ) {\n\t\t\t\t\tparticipantsMap.set( comment.author, {\n\t\t\t\t\t\tname: comment.author_name,\n\t\t\t\t\t\tavatar:\n\t\t\t\t\t\t\tcomment.author_avatar_urls?.[ '48' ] ||\n\t\t\t\t\t\t\tcomment.author_avatar_urls?.[ '96' ],\n\t\t\t\t\t\tid: comment.author,\n\t\t\t\t\t\tdate: comment.date,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\n\t\treturn Array.from( participantsMap.values() );\n\t}, [ thread ] );\n\n\tif ( ! threadParticipants.length ) {\n\t\treturn null;\n\t}\n\n\t// If there are more than 3 participants, show 2 avatars and a \"+n\" number.\n\tconst maxAvatars = 3;\n\tconst isOverflow = threadParticipants.length > maxAvatars;\n\tconst visibleParticipants = isOverflow\n\t\t? threadParticipants.slice( 0, maxAvatars - 1 )\n\t\t: threadParticipants;\n\tconst overflowCount = Math.max(\n\t\t0,\n\t\tthreadParticipants.length - visibleParticipants.length\n\t);\n\tconst threadHasMoreParticipants = threadParticipants.length > 100;\n\n\t// If we hit the comment limit, show \"100+\" instead of exact overflow count.\n\tconst overflowText =\n\t\tthreadHasMoreParticipants && overflowCount > 0\n\t\t\t? __( '100+' )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %s: Number of participants.\n\t\t\t\t\t__( '+%s' ),\n\t\t\t\t\toverflowCount\n\t\t\t );\n\n\treturn (\n\t\t<CommentIconToolbarSlotFill.Fill>\n\t\t\t<ToolbarButton\n\t\t\t\tclassName=\"comment-avatar-indicator\"\n\t\t\t\tlabel={ __( 'View notes' ) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tshowTooltip\n\t\t\t>\n\t\t\t\t<HStack spacing=\"1\">\n\t\t\t\t\t{ visibleParticipants.map( ( participant ) => (\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tkey={ participant.id }\n\t\t\t\t\t\t\tsrc={ participant.avatar }\n\t\t\t\t\t\t\talt={ participant.name }\n\t\t\t\t\t\t\tclassName=\"comment-avatar\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tborderColor: getAvatarBorderColor(\n\t\t\t\t\t\t\t\t\tparticipant.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) ) }\n\t\t\t\t\t{ overflowCount > 0 && (\n\t\t\t\t\t\t<Text weight={ 500 }>{ overflowText }</Text>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t</ToolbarButton>\n\t\t</CommentIconToolbarSlotFill.Fill>\n\t);\n};\n\nexport default CommentAvatarIndicator;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqFI;AAlFJ,wBAIO;AACP,kBAA4B;AAC5B,qBAAwB;AACxB,0BAAsD;AAKtD,yBAAuB;AACvB,mBAAqC;AAErC,MAAM,EAAE,2BAA2B,QAAI,2BAAQ,oBAAAA,WAAuB;AAEtE,MAAM,yBAAyB,CAAE,EAAE,SAAS,OAAO,MAAO;AACzD,QAAM,yBAAqB,wBAAS,MAAM;AACzC,QAAK,CAAE,QAAS;AACf,aAAO,CAAC;AAAA,IACT;AAEA,UAAM,kBAAkB,oBAAI,IAAI;AAChC,UAAM,cAAc,CAAE,QAAQ,GAAG,OAAO,KAAM;AAG9C,gBAAY,KAAM,CAAE,GAAG,MAAO,IAAI,KAAM,EAAE,IAAK,IAAI,IAAI,KAAM,EAAE,IAAK,CAAE;AAEtE,gBAAY,QAAS,CAAE,YAAa;AAEnC,UAAK,QAAQ,eAAe,QAAQ,oBAAqB;AACxD,YAAK,CAAE,gBAAgB,IAAK,QAAQ,MAAO,GAAI;AAC9C,0BAAgB,IAAK,QAAQ,QAAQ;AAAA,YACpC,MAAM,QAAQ;AAAA,YACd,QACC,QAAQ,qBAAsB,IAAK,KACn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
|
}
|
|
@@ -48,6 +48,7 @@ var import_comment_form = __toESM(require("./comment-form"));
|
|
|
48
48
|
var import_utils = require("./utils");
|
|
49
49
|
var import_hooks = require("./hooks");
|
|
50
50
|
var import_add_comment = require("./add-comment");
|
|
51
|
+
var import_store = require("../../store");
|
|
51
52
|
const { useBlockElement } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
|
|
52
53
|
const { Menu } = (0, import_lock_unlock.unlock)(import_components.privateApis);
|
|
53
54
|
function Comments({
|
|
@@ -66,6 +67,7 @@ function Comments({
|
|
|
66
67
|
const [selectedThread, setSelectedThread] = (0, import_element.useState)(null);
|
|
67
68
|
const [boardOffsets, setBoardOffsets] = (0, import_element.useState)({});
|
|
68
69
|
const [blockRefs, setBlockRefs] = (0, import_element.useState)({});
|
|
70
|
+
const { setCanvasMinHeight } = (0, import_lock_unlock.unlock)((0, import_data.useDispatch)(import_store.store));
|
|
69
71
|
const { blockCommentId, selectedBlockClientId, orderedBlockIds } = (0, import_data.useSelect)((select) => {
|
|
70
72
|
const { getBlockAttributes, getSelectedBlockClientId } = select(import_block_editor.store);
|
|
71
73
|
const clientId = getSelectedBlockClientId();
|
|
@@ -131,8 +133,9 @@ function Comments({
|
|
|
131
133
|
}
|
|
132
134
|
};
|
|
133
135
|
(0, import_element.useEffect)(() => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
+
const fallback = showCommentBoard ? "new-note-thread" : null;
|
|
137
|
+
setSelectedThread(blockCommentId ?? fallback);
|
|
138
|
+
}, [blockCommentId, showCommentBoard]);
|
|
136
139
|
const setBlockRef = (0, import_element.useCallback)((id, blockRef) => {
|
|
137
140
|
setBlockRefs((prev) => ({ ...prev, [id]: blockRef }));
|
|
138
141
|
}, []);
|
|
@@ -140,7 +143,7 @@ function Comments({
|
|
|
140
143
|
const calculateAllOffsets = () => {
|
|
141
144
|
const offsets = {};
|
|
142
145
|
if (!isFloating) {
|
|
143
|
-
return offsets;
|
|
146
|
+
return { offsets, minHeight: 0 };
|
|
144
147
|
}
|
|
145
148
|
const selectedThreadIndex = threads.findIndex(
|
|
146
149
|
(t) => t.id === selectedThread
|
|
@@ -148,7 +151,7 @@ function Comments({
|
|
|
148
151
|
const breakIndex = selectedThreadIndex === -1 ? 0 : selectedThreadIndex;
|
|
149
152
|
const selectedThreadData = threads[breakIndex];
|
|
150
153
|
if (!selectedThreadData || !blockRefs[selectedThreadData.id]) {
|
|
151
|
-
return offsets;
|
|
154
|
+
return { offsets, minHeight: 0 };
|
|
152
155
|
}
|
|
153
156
|
let blockElement = blockRefs[selectedThreadData.id];
|
|
154
157
|
let blockRect = blockElement?.getBoundingClientRect();
|
|
@@ -201,13 +204,31 @@ function Comments({
|
|
|
201
204
|
threadTop: threadTop + additionalOffset
|
|
202
205
|
};
|
|
203
206
|
}
|
|
204
|
-
|
|
207
|
+
let editorMinHeight = 0;
|
|
208
|
+
const lastThread = threads[threads.length - 1];
|
|
209
|
+
if (blockRefs[lastThread.id]) {
|
|
210
|
+
const lastBlockElement = blockRefs[lastThread.id];
|
|
211
|
+
const lastBlockRect = lastBlockElement?.getBoundingClientRect();
|
|
212
|
+
const lastThreadTop = lastBlockRect?.top || 0;
|
|
213
|
+
const lastThreadHeight = heights[lastThread.id] || 0;
|
|
214
|
+
const lastThreadOffset = offsets[lastThread.id] || 0;
|
|
215
|
+
editorMinHeight = lastThreadTop + lastThreadHeight + lastThreadOffset + 32;
|
|
216
|
+
}
|
|
217
|
+
return { offsets, minHeight: editorMinHeight };
|
|
205
218
|
};
|
|
206
|
-
const newOffsets = calculateAllOffsets();
|
|
219
|
+
const { offsets: newOffsets, minHeight } = calculateAllOffsets();
|
|
207
220
|
if (Object.keys(newOffsets).length > 0) {
|
|
208
221
|
setBoardOffsets(newOffsets);
|
|
209
222
|
}
|
|
210
|
-
|
|
223
|
+
setCanvasMinHeight(minHeight);
|
|
224
|
+
}, [
|
|
225
|
+
heights,
|
|
226
|
+
blockRefs,
|
|
227
|
+
isFloating,
|
|
228
|
+
threads,
|
|
229
|
+
selectedThread,
|
|
230
|
+
setCanvasMinHeight
|
|
231
|
+
]);
|
|
211
232
|
const hasThreads = Array.isArray(threads) && threads.length > 0;
|
|
212
233
|
if (!hasThreads && !isFloating) {
|
|
213
234
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
@@ -533,6 +554,7 @@ const CommentBoard = ({
|
|
|
533
554
|
}) => {
|
|
534
555
|
const [actionState, setActionState] = (0, import_element.useState)(false);
|
|
535
556
|
const [showConfirmDialog, setShowConfirmDialog] = (0, import_element.useState)(false);
|
|
557
|
+
const actionButtonRef = (0, import_element.useRef)(null);
|
|
536
558
|
const handleConfirmDelete = () => {
|
|
537
559
|
onDelete(thread);
|
|
538
560
|
setActionState(false);
|
|
@@ -541,6 +563,7 @@ const CommentBoard = ({
|
|
|
541
563
|
const handleCancel = () => {
|
|
542
564
|
setActionState(false);
|
|
543
565
|
setShowConfirmDialog(false);
|
|
566
|
+
actionButtonRef.current?.focus();
|
|
544
567
|
};
|
|
545
568
|
const isResolutionComment = thread.type === "note" && thread.meta && (thread.meta._wp_note_status === "resolved" || thread.meta._wp_note_status === "reopen");
|
|
546
569
|
const actions = [
|
|
@@ -617,6 +640,7 @@ const CommentBoard = ({
|
|
|
617
640
|
render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
618
641
|
import_components.Button,
|
|
619
642
|
{
|
|
643
|
+
ref: actionButtonRef,
|
|
620
644
|
size: "small",
|
|
621
645
|
icon: import_icons.moreVertical,
|
|
622
646
|
label: (0, import_i18n.__)("Actions"),
|
|
@@ -648,6 +672,7 @@ const CommentBoard = ({
|
|
|
648
672
|
content: value
|
|
649
673
|
});
|
|
650
674
|
setActionState(false);
|
|
675
|
+
actionButtonRef.current?.focus();
|
|
651
676
|
},
|
|
652
677
|
onCancel: () => handleCancel(),
|
|
653
678
|
thread,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/collab-sidebar/comments.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tRawHTML,\n\tuseEffect,\n\tuseCallback,\n\tuseMemo,\n} from '@wordpress/element';\nimport {\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalConfirmDialog as ConfirmDialog,\n\tButton,\n\tFlexItem,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useDebounce } from '@wordpress/compose';\n\nimport { published, moreVertical } from '@wordpress/icons';\nimport { __, _x, sprintf, _n } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\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';\nimport { focusCommentThread, getCommentExcerpt } from './utils';\nimport { useFloatingThread } from './hooks';\nimport { AddComment } from './add-comment';\n\nconst { useBlockElement } = unlock( blockEditorPrivateApis );\nconst { Menu } = unlock( componentsPrivateApis );\n\nexport function Comments( {\n\tthreads: noteThreads,\n\tonEditComment,\n\tonAddReply,\n\tonCommentDelete,\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tcommentSidebarRef,\n\treflowComments,\n\tisFloating = false,\n\tcommentLastUpdated,\n} ) {\n\tconst [ heights, setHeights ] = useState( {} );\n\tconst [ selectedThread, setSelectedThread ] = useState( null );\n\tconst [ boardOffsets, setBoardOffsets ] = useState( {} );\n\tconst [ blockRefs, setBlockRefs ] = useState( {} );\n\n\tconst { blockCommentId, selectedBlockClientId, orderedBlockIds } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\treturn {\n\t\t\t\tblockCommentId: clientId\n\t\t\t\t\t? getBlockAttributes( clientId )?.metadata?.noteId\n\t\t\t\t\t: null,\n\t\t\t\tselectedBlockClientId: clientId,\n\t\t\t\torderedBlockIds: select( blockEditorStore ).getBlockOrder(),\n\t\t\t};\n\t\t}, [] );\n\n\tconst relatedBlockElement = useBlockElement( selectedBlockClientId );\n\n\tconst threads = useMemo( () => {\n\t\tconst t = [ ...noteThreads ];\n\t\tconst orderedThreads = [];\n\t\t// In floating mode, when the note board is shown, and as long\n\t\t// as the selected block doesn't have an existing note attached -\n\t\t// add a \"new note\" entry to the threads. This special thread type\n\t\t// gets sorted and floated like regular threads, but shows an AddComment\n\t\t// component instead of a regular comment thread.\n\t\tif ( isFloating && showCommentBoard && undefined === blockCommentId ) {\n\t\t\t// Insert the new note entry at the correct location for its blockId.\n\t\t\tconst newNoteThread = {\n\t\t\t\tid: 'new-note-thread',\n\t\t\t\tblockClientId: selectedBlockClientId,\n\t\t\t\tcontent: { rendered: '' },\n\t\t\t};\n\t\t\t// Insert the new comment block at the right order within the threads.\n\t\t\torderedBlockIds.forEach( ( blockId ) => {\n\t\t\t\tif ( blockId === selectedBlockClientId ) {\n\t\t\t\t\torderedThreads.push( newNoteThread );\n\t\t\t\t} else {\n\t\t\t\t\tconst threadForBlock = t.find(\n\t\t\t\t\t\t( thread ) => thread.blockClientId === blockId\n\t\t\t\t\t);\n\t\t\t\t\tif ( threadForBlock ) {\n\t\t\t\t\t\torderedThreads.push( threadForBlock );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\t\t\treturn orderedThreads;\n\t\t}\n\t\treturn t;\n\t}, [\n\t\tnoteThreads,\n\t\tisFloating,\n\t\tshowCommentBoard,\n\t\tblockCommentId,\n\t\tselectedBlockClientId,\n\t\torderedBlockIds,\n\t] );\n\n\tconst handleDelete = async ( comment ) => {\n\t\tconst currentIndex = threads.findIndex( ( t ) => t.id === comment.id );\n\t\tconst nextThread = threads[ currentIndex + 1 ];\n\t\tconst prevThread = threads[ currentIndex - 1 ];\n\n\t\tawait onCommentDelete( comment );\n\n\t\tif ( comment.parent !== 0 ) {\n\t\t\t// Move focus to the parent thread when a reply was deleted.\n\t\t\tsetSelectedThread( comment.parent );\n\t\t\tfocusCommentThread( comment.parent, commentSidebarRef.current );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( nextThread ) {\n\t\t\tsetSelectedThread( nextThread.id );\n\t\t\tfocusCommentThread( nextThread.id, commentSidebarRef.current );\n\t\t} else if ( prevThread ) {\n\t\t\tsetSelectedThread( prevThread.id );\n\t\t\tfocusCommentThread( prevThread.id, commentSidebarRef.current );\n\t\t} else {\n\t\t\tsetSelectedThread( null );\n\t\t\tsetShowCommentBoard( false );\n\t\t\t// Move focus to the related block.\n\t\t\trelatedBlockElement?.focus();\n\t\t}\n\t};\n\n\t// Auto-select the related comment thread when a block is selected.\n\tuseEffect( () => {\n\t\tsetSelectedThread( blockCommentId ?? undefined );\n\t}, [ blockCommentId ] );\n\n\tconst setBlockRef = useCallback( ( id, blockRef ) => {\n\t\tsetBlockRefs( ( prev ) => ( { ...prev, [ id ]: blockRef } ) );\n\t}, [] );\n\n\t// Recalculate floating comment thread offsets whenever the heights change.\n\tuseEffect( () => {\n\t\t/**\n\t\t * Calculate the y offsets for all comment threads. Account for potentially\n\t\t * overlapping threads and adjust their positions accordingly.\n\t\t */\n\t\tconst calculateAllOffsets = () => {\n\t\t\tconst offsets = {};\n\n\t\t\tif ( ! isFloating ) {\n\t\t\t\treturn offsets;\n\t\t\t}\n\n\t\t\t// Find the index of the selected thread.\n\t\t\tconst selectedThreadIndex = threads.findIndex(\n\t\t\t\t( t ) => t.id === selectedThread\n\t\t\t);\n\n\t\t\tconst breakIndex =\n\t\t\t\tselectedThreadIndex === -1 ? 0 : selectedThreadIndex;\n\n\t\t\t// If there is a selected thread, push threads above up and threads below down.\n\t\t\tconst selectedThreadData = threads[ breakIndex ];\n\n\t\t\tif (\n\t\t\t\t! selectedThreadData ||\n\t\t\t\t! blockRefs[ selectedThreadData.id ]\n\t\t\t) {\n\t\t\t\treturn offsets;\n\t\t\t}\n\n\t\t\tlet blockElement = blockRefs[ selectedThreadData.id ];\n\t\t\tlet blockRect = blockElement?.getBoundingClientRect();\n\t\t\tconst selectedThreadTop = blockRect?.top || 0;\n\t\t\tconst selectedThreadHeight = heights[ selectedThreadData.id ] || 0;\n\n\t\t\toffsets[ selectedThreadData.id ] = -16;\n\n\t\t\tlet previousThreadData = {\n\t\t\t\tthreadTop: selectedThreadTop - 16,\n\t\t\t\tthreadHeight: selectedThreadHeight,\n\t\t\t};\n\n\t\t\t// Process threads after the selected thread, offsetting any overlapping\n\t\t\t// threads downward.\n\t\t\tfor ( let i = breakIndex + 1; i < threads.length; i++ ) {\n\t\t\t\tconst thread = threads[ i ];\n\t\t\t\tif ( ! blockRefs[ thread.id ] ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tblockElement = blockRefs[ thread.id ];\n\t\t\t\tblockRect = blockElement?.getBoundingClientRect();\n\t\t\t\tconst threadTop = blockRect?.top || 0;\n\t\t\t\tconst threadHeight = heights[ thread.id ] || 0;\n\n\t\t\t\tlet additionalOffset = -16;\n\n\t\t\t\t// Check if the thread overlaps with the previous one.\n\t\t\t\tconst previousBottom =\n\t\t\t\t\tpreviousThreadData.threadTop +\n\t\t\t\t\tpreviousThreadData.threadHeight;\n\t\t\t\tif ( threadTop < previousBottom + 16 ) {\n\t\t\t\t\t// Shift down by the difference plus a margin to avoid overlap.\n\t\t\t\t\tadditionalOffset = previousBottom - threadTop + 20;\n\t\t\t\t}\n\n\t\t\t\toffsets[ thread.id ] = additionalOffset;\n\n\t\t\t\t// Update for next iteration.\n\t\t\t\tpreviousThreadData = {\n\t\t\t\t\tthreadTop: threadTop + additionalOffset,\n\t\t\t\t\tthreadHeight,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Process threads before the selected thread, offsetting any overlapping\n\t\t\t// threads upward.\n\t\t\tlet nextThreadData = {\n\t\t\t\tthreadTop: selectedThreadTop - 16,\n\t\t\t};\n\n\t\t\tfor ( let i = selectedThreadIndex - 1; i >= 0; i-- ) {\n\t\t\t\tconst thread = threads[ i ];\n\t\t\t\tif ( ! blockRefs[ thread.id ] ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tblockElement = blockRefs[ thread.id ];\n\t\t\t\tblockRect = blockElement?.getBoundingClientRect();\n\t\t\t\tconst threadTop = blockRect?.top || 0;\n\t\t\t\tconst threadHeight = heights[ thread.id ] || 0;\n\n\t\t\t\tlet additionalOffset = -16;\n\n\t\t\t\t// Calculate the bottom position of this thread with default offset.\n\t\t\t\tconst threadBottom = threadTop + threadHeight;\n\n\t\t\t\t// Check if this thread's bottom would overlap with the next thread's top.\n\t\t\t\tif ( threadBottom > nextThreadData.threadTop ) {\n\t\t\t\t\t// Shift up by the difference plus a margin to avoid overlap.\n\t\t\t\t\tadditionalOffset =\n\t\t\t\t\t\tnextThreadData.threadTop -\n\t\t\t\t\t\tthreadTop -\n\t\t\t\t\t\tthreadHeight -\n\t\t\t\t\t\t20;\n\t\t\t\t}\n\n\t\t\t\toffsets[ thread.id ] = additionalOffset;\n\n\t\t\t\t// Update for next iteration (going upward).\n\t\t\t\tnextThreadData = {\n\t\t\t\t\tthreadTop: threadTop + additionalOffset,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn offsets;\n\t\t};\n\t\tconst newOffsets = calculateAllOffsets();\n\t\tif ( Object.keys( newOffsets ).length > 0 ) {\n\t\t\tsetBoardOffsets( newOffsets );\n\t\t}\n\t}, [ heights, blockRefs, isFloating, threads, selectedThread ] );\n\n\tconst hasThreads = Array.isArray( threads ) && threads.length > 0;\n\tif ( ! hasThreads && ! isFloating ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<AddComment\n\t\t\t\t\tonSubmit={ onAddReply }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\tcommentSidebarRef={ commentSidebarRef }\n\t\t\t\t/>\n\t\t\t\t<Text as=\"p\">{ __( 'No notes available.' ) }</Text>\n\t\t\t\t<Text as=\"p\" variant=\"muted\">\n\t\t\t\t\t{ __( 'Only logged in users can see Notes.' ) }\n\t\t\t\t</Text>\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ ! isFloating &&\n\t\t\t\tshowCommentBoard &&\n\t\t\t\tundefined === blockCommentId && (\n\t\t\t\t\t<AddComment\n\t\t\t\t\t\tonSubmit={ onAddReply }\n\t\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\t\tcommentSidebarRef={ commentSidebarRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t{ threads.map( ( thread ) => (\n\t\t\t\t<Thread\n\t\t\t\t\tkey={ thread.id }\n\t\t\t\t\tthread={ thread }\n\t\t\t\t\tonAddReply={ onAddReply }\n\t\t\t\t\tonCommentDelete={ handleDelete }\n\t\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\t\tisSelected={ selectedThread === thread.id }\n\t\t\t\t\tsetSelectedThread={ setSelectedThread }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\tcommentSidebarRef={ commentSidebarRef }\n\t\t\t\t\treflowComments={ reflowComments }\n\t\t\t\t\tisFloating={ isFloating }\n\t\t\t\t\tcalculatedOffset={ boardOffsets[ thread.id ] ?? 0 }\n\t\t\t\t\tsetHeights={ setHeights }\n\t\t\t\t\tsetBlockRef={ setBlockRef }\n\t\t\t\t\tselectedThread={ selectedThread }\n\t\t\t\t\tcommentLastUpdated={ commentLastUpdated }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction Thread( {\n\tthread,\n\tonEditComment,\n\tonAddReply,\n\tonCommentDelete,\n\tisSelected,\n\tsetShowCommentBoard,\n\tcommentSidebarRef,\n\treflowComments,\n\tisFloating,\n\tcalculatedOffset,\n\tsetHeights,\n\tsetBlockRef,\n\tsetSelectedThread,\n\tselectedThread,\n\tcommentLastUpdated,\n\tshowCommentBoard,\n} ) {\n\tconst { toggleBlockHighlight, selectBlock, toggleBlockSpotlight } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tconst relatedBlockElement = useBlockElement( thread.blockClientId );\n\tconst debouncedToggleBlockHighlight = useDebounce(\n\t\ttoggleBlockHighlight,\n\t\t50\n\t);\n\tconst { y, refs } = useFloatingThread( {\n\t\tthread,\n\t\tcalculatedOffset,\n\t\tsetHeights,\n\t\tsetBlockRef,\n\t\tselectedThread,\n\t\tcommentLastUpdated,\n\t} );\n\n\tconst onMouseEnter = () => {\n\t\tdebouncedToggleBlockHighlight( thread.blockClientId, true );\n\t};\n\n\tconst onMouseLeave = () => {\n\t\tdebouncedToggleBlockHighlight( thread.blockClientId, false );\n\t};\n\n\tconst handleCommentSelect = () => {\n\t\tsetShowCommentBoard( false );\n\t\tsetSelectedThread( thread.id );\n\t\tif ( !! thread.blockClientId ) {\n\t\t\t// Pass `null` as the second parameter to prevent focusing the block.\n\t\t\tselectBlock( thread.blockClientId, null );\n\t\t\ttoggleBlockSpotlight( thread.blockClientId, true );\n\t\t}\n\t};\n\n\tconst unselectThread = () => {\n\t\tsetSelectedThread( null );\n\t\tsetShowCommentBoard( false );\n\t\ttoggleBlockSpotlight( thread.blockClientId, false );\n\t};\n\n\tconst allReplies = thread?.reply || [];\n\n\tconst lastReply =\n\t\tallReplies.length > 0 ? allReplies[ allReplies.length - 1 ] : undefined;\n\tconst restReplies = allReplies.length > 0 ? allReplies.slice( 0, -1 ) : [];\n\n\tconst commentExcerpt = getCommentExcerpt(\n\t\tstripHTML( thread.content?.rendered ),\n\t\t10\n\t);\n\tconst ariaLabel = !! thread.blockClientId\n\t\t? sprintf(\n\t\t\t\t// translators: %s: note excerpt\n\t\t\t\t__( 'Note: %s' ),\n\t\t\t\tcommentExcerpt\n\t\t )\n\t\t: sprintf(\n\t\t\t\t// translators: %s: note excerpt\n\t\t\t\t__( 'Original block deleted. Note: %s' ),\n\t\t\t\tcommentExcerpt\n\t\t );\n\n\tif ( 'new-note-thread' === thread.id && showCommentBoard && isFloating ) {\n\t\treturn (\n\t\t\t<AddComment\n\t\t\t\tonSubmit={ onAddReply }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\tcommentSidebarRef={ commentSidebarRef }\n\t\t\t\treflowComments={ reflowComments }\n\t\t\t\tisFloating={ isFloating }\n\t\t\t\ty={ y }\n\t\t\t\trefs={ refs }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t// Disable reason: role=\"listitem\" does in fact support aria-expanded.\n\t\t// eslint-disable-next-line jsx-a11y/role-supports-aria-props\n\t\t<VStack\n\t\t\tclassName={ clsx( 'editor-collab-sidebar-panel__thread', {\n\t\t\t\t'is-selected': isSelected,\n\t\t\t\t'is-floating': isFloating,\n\t\t\t} ) }\n\t\t\tid={ `comment-thread-${ thread.id }` }\n\t\t\tspacing=\"3\"\n\t\t\tonClick={ handleCommentSelect }\n\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\tonFocus={ onMouseEnter }\n\t\t\tonBlur={ onMouseLeave }\n\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Expand or Collapse thread.\n\t\t\t\tif (\n\t\t\t\t\tevent.key === 'Enter' &&\n\t\t\t\t\tevent.currentTarget === event.target\n\t\t\t\t) {\n\t\t\t\t\tif ( isSelected ) {\n\t\t\t\t\t\tunselectThread();\n\t\t\t\t\t} else {\n\t\t\t\t\t\thandleCommentSelect();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Collapse thread and focus the thread.\n\t\t\t\tif ( event.key === 'Escape' ) {\n\t\t\t\t\tunselectThread();\n\t\t\t\t\tfocusCommentThread( thread.id, commentSidebarRef.current );\n\t\t\t\t}\n\t\t\t} }\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"listitem\"\n\t\t\taria-label={ ariaLabel }\n\t\t\taria-expanded={ isSelected }\n\t\t\tref={ isFloating ? refs.setFloating : undefined }\n\t\t\tstyle={ isFloating ? { top: y } : undefined }\n\t\t>\n\t\t\t<Button\n\t\t\t\tclassName=\"editor-collab-sidebar-panel__skip-to-comment\"\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\tsize=\"compact\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tfocusCommentThread(\n\t\t\t\t\t\tthread.id,\n\t\t\t\t\t\tcommentSidebarRef.current,\n\t\t\t\t\t\t'textarea'\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Add new note' ) }\n\t\t\t</Button>\n\t\t\t{ ! thread.blockClientId && (\n\t\t\t\t<Text as=\"p\" weight={ 500 } variant=\"muted\">\n\t\t\t\t\t{ __( 'Original block deleted.' ) }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t\t<CommentBoard\n\t\t\t\tthread={ thread }\n\t\t\t\tisExpanded={ isSelected }\n\t\t\t\tonEdit={ ( params = {} ) => {\n\t\t\t\t\tconst { status } = params;\n\t\t\t\t\tonEditComment( params );\n\t\t\t\t\tif ( status === 'approved' ) {\n\t\t\t\t\t\tunselectThread();\n\t\t\t\t\t\tfocusCommentThread(\n\t\t\t\t\t\t\tthread.id,\n\t\t\t\t\t\t\tcommentSidebarRef.current\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\tonDelete={ onCommentDelete }\n\t\t\t\treflowComments={ reflowComments }\n\t\t\t/>\n\t\t\t{ isSelected &&\n\t\t\t\tallReplies.map( ( reply ) => (\n\t\t\t\t\t<CommentBoard\n\t\t\t\t\t\tkey={ reply.id }\n\t\t\t\t\t\tthread={ reply }\n\t\t\t\t\t\tparent={ thread }\n\t\t\t\t\t\tisExpanded={ isSelected }\n\t\t\t\t\t\tonEdit={ onEditComment }\n\t\t\t\t\t\tonDelete={ onCommentDelete }\n\t\t\t\t\t\treflowComments={ reflowComments }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t{ ! isSelected && 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={ () => {\n\t\t\t\t\t\t\tsetSelectedThread( thread.id );\n\t\t\t\t\t\t\tfocusCommentThread(\n\t\t\t\t\t\t\t\tthread.id,\n\t\t\t\t\t\t\t\tcommentSidebarRef.current\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\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{ ! isSelected && lastReply && (\n\t\t\t\t<CommentBoard\n\t\t\t\t\tthread={ lastReply }\n\t\t\t\t\tparent={ thread }\n\t\t\t\t\tisExpanded={ isSelected }\n\t\t\t\t\tonEdit={ onEditComment }\n\t\t\t\t\tonDelete={ onCommentDelete }\n\t\t\t\t\treflowComments={ reflowComments }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isSelected && (\n\t\t\t\t<VStack spacing=\"2\">\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\t// For reopening, include the content in the reopen action.\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\tcontent: inputComment,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// For regular replies, add as separate comment.\n\t\t\t\t\t\t\t\t\tonAddReply( {\n\t\t\t\t\t\t\t\t\t\tcontent: inputComment,\n\t\t\t\t\t\t\t\t\t\tparent: thread.id,\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\tonCancel={ ( event ) => {\n\t\t\t\t\t\t\t\t// Prevent the parent onClick from being triggered.\n\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\tunselectThread();\n\t\t\t\t\t\t\t\tfocusCommentThread(\n\t\t\t\t\t\t\t\t\tthread.id,\n\t\t\t\t\t\t\t\t\tcommentSidebarRef.current\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? __( '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: note identifier, %2$s: author name\n\t\t\t\t\t\t\t\t__( 'Reply to note %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\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\treflowComments={ reflowComments }\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\t{ !! thread.blockClientId && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__skip-to-block\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\trelatedBlockElement?.focus();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Back to block' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nconst CommentBoard = ( {\n\tthread,\n\tparent,\n\tisExpanded,\n\tonEdit,\n\tonDelete,\n\treflowComments,\n} ) => {\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\t// Check if this is a resolution comment by checking metadata.\n\tconst isResolutionComment =\n\t\tthread.type === 'note' &&\n\t\tthread.meta &&\n\t\t( thread.meta._wp_note_status === 'resolved' ||\n\t\t\tthread.meta._wp_note_status === 'reopen' );\n\n\tconst actions = [\n\t\t{\n\t\t\tid: 'edit',\n\t\t\ttitle: __( 'Edit' ),\n\t\t\tisEligible: ( { status } ) => status !== 'approved',\n\t\t\tonClick: () => {\n\t\t\t\tsetActionState( 'edit' );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: 'reopen',\n\t\t\ttitle: _x( 'Reopen', 'Reopen note' ),\n\t\t\tisEligible: ( { status } ) => status === 'approved',\n\t\t\tonClick: () => {\n\t\t\t\tonEdit( { id: thread.id, status: 'hold' } );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: 'delete',\n\t\t\ttitle: __( 'Delete' ),\n\t\t\tisEligible: () => true,\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];\n\n\tconst canResolve = thread.parent === 0;\n\tconst moreActions =\n\t\tparent?.status !== 'approved'\n\t\t\t? actions.filter( ( item ) => item.isEligible( thread ) )\n\t\t\t: [];\n\n\treturn (\n\t\t<VStack spacing=\"2\">\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{ isExpanded && (\n\t\t\t\t\t<FlexItem\n\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__comment-status\"\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t// Prevent the thread from being selected.\n\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<HStack spacing=\"0\">\n\t\t\t\t\t\t\t{ canResolve && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t\t\t'Resolve',\n\t\t\t\t\t\t\t\t\t\t'Mark note as resolved'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\ticon={ published }\n\t\t\t\t\t\t\t\t\tdisabled={ thread.status === 'approved' }\n\t\t\t\t\t\t\t\t\taccessibleWhenDisabled={\n\t\t\t\t\t\t\t\t\t\tthread.status === 'approved'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonEdit( {\n\t\t\t\t\t\t\t\t\t\t\tid: thread.id,\n\t\t\t\t\t\t\t\t\t\t\tstatus: 'approved',\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/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<Menu placement=\"bottom-end\">\n\t\t\t\t\t\t\t\t<Menu.TriggerButton\n\t\t\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\t\t\t\t\t\tdisabled={ ! moreActions.length }\n\t\t\t\t\t\t\t\t\t\t\taccessibleWhenDisabled\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/>\n\t\t\t\t\t\t\t\t<Menu.Popover>\n\t\t\t\t\t\t\t\t\t{ moreActions.map( ( action ) => (\n\t\t\t\t\t\t\t\t\t\t<Menu.Item\n\t\t\t\t\t\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => action.onClick() }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<Menu.ItemLabel>\n\t\t\t\t\t\t\t\t\t\t\t\t{ action.title }\n\t\t\t\t\t\t\t\t\t\t\t</Menu.ItemLabel>\n\t\t\t\t\t\t\t\t\t\t</Menu.Item>\n\t\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t\t</Menu.Popover>\n\t\t\t\t\t\t\t</Menu>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t) }\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: note identifier, %2$s: author name.\n\t\t\t\t\t\t__( 'Edit note %1$s by %2$s' ),\n\t\t\t\t\t\tthread.id,\n\t\t\t\t\t\tthread.author_name\n\t\t\t\t\t) }\n\t\t\t\t\treflowComments={ reflowComments }\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<RawHTML\n\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t'editor-collab-sidebar-panel__user-comment',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'editor-collab-sidebar-panel__resolution-text':\n\t\t\t\t\t\t\t\tisResolutionComment,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ isResolutionComment\n\t\t\t\t\t\t? ( () => {\n\t\t\t\t\t\t\t\tconst actionText =\n\t\t\t\t\t\t\t\t\tthread.meta._wp_note_status === 'resolved'\n\t\t\t\t\t\t\t\t\t\t? __( 'Marked as resolved' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Reopened' );\n\t\t\t\t\t\t\t\tconst content = thread?.content?.raw;\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tcontent &&\n\t\t\t\t\t\t\t\t\ttypeof content === 'string' &&\n\t\t\t\t\t\t\t\t\tcontent.trim() !== ''\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\treturn sprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %1$s: action label (\"Marked as resolved\" or \"Reopened\"); %2$s: note text.\n\t\t\t\t\t\t\t\t\t\t__( '%1$s: %2$s' ),\n\t\t\t\t\t\t\t\t\t\tactionText,\n\t\t\t\t\t\t\t\t\t\tcontent\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// If no content, just show the action.\n\t\t\t\t\t\t\t\treturn actionText;\n\t\t\t\t\t\t } )()\n\t\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\"Are you sure you want to delete this note? This will also delete all of this note's replies.\"\n\t\t\t\t\t) }\n\t\t\t\t</ConfirmDialog>\n\t\t\t) }\n\t\t</VStack>\n\t);\n};\n\nexport default Comments;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4RG;AAzRH,kBAAiB;AAKjB,qBAMO;AACP,wBAQO;AACP,qBAA4B;AAE5B,mBAAwC;AACxC,kBAAoC;AACpC,kBAAuC;AACvC,iBAAiD;AACjD,0BAGO;AAKP,yBAAuB;AACvB,iCAA8B;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BAAAI;AAAA,MAAA;AAAA,QACA,QAAS;AAAA,QACT,WAAY;AAAA,QACZ,UAAW;AAAA,QACX,uBAAoB,gBAAI,QAAS;AAAA,QAE/B;AAAA,UACD;AAAA,QACD;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;AAEA,IAAO,mBAAQ;",
|
|
6
|
-
"names": ["blockEditorPrivateApis", "componentsPrivateApis", "blockEditorStore", "Text", "stripHTML", "VStack", "clsx", "HStack", "CommentAuthorInfo", "CommentForm", "ConfirmDialog"]
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tRawHTML,\n\tuseEffect,\n\tuseCallback,\n\tuseMemo,\n\tuseRef,\n} from '@wordpress/element';\nimport {\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalConfirmDialog as ConfirmDialog,\n\tButton,\n\tFlexItem,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useDebounce } from '@wordpress/compose';\n\nimport { published, moreVertical } from '@wordpress/icons';\nimport { __, _x, sprintf, _n } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\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';\nimport { focusCommentThread, getCommentExcerpt } from './utils';\nimport { useFloatingThread } from './hooks';\nimport { AddComment } from './add-comment';\nimport { store as editorStore } from '../../store';\n\nconst { useBlockElement } = unlock( blockEditorPrivateApis );\nconst { Menu } = unlock( componentsPrivateApis );\n\nexport function Comments( {\n\tthreads: noteThreads,\n\tonEditComment,\n\tonAddReply,\n\tonCommentDelete,\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tcommentSidebarRef,\n\treflowComments,\n\tisFloating = false,\n\tcommentLastUpdated,\n} ) {\n\tconst [ heights, setHeights ] = useState( {} );\n\tconst [ selectedThread, setSelectedThread ] = useState( null );\n\tconst [ boardOffsets, setBoardOffsets ] = useState( {} );\n\tconst [ blockRefs, setBlockRefs ] = useState( {} );\n\n\tconst { setCanvasMinHeight } = unlock( useDispatch( editorStore ) );\n\tconst { blockCommentId, selectedBlockClientId, orderedBlockIds } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\treturn {\n\t\t\t\tblockCommentId: clientId\n\t\t\t\t\t? getBlockAttributes( clientId )?.metadata?.noteId\n\t\t\t\t\t: null,\n\t\t\t\tselectedBlockClientId: clientId,\n\t\t\t\torderedBlockIds: select( blockEditorStore ).getBlockOrder(),\n\t\t\t};\n\t\t}, [] );\n\n\tconst relatedBlockElement = useBlockElement( selectedBlockClientId );\n\n\tconst threads = useMemo( () => {\n\t\tconst t = [ ...noteThreads ];\n\t\tconst orderedThreads = [];\n\t\t// In floating mode, when the note board is shown, and as long\n\t\t// as the selected block doesn't have an existing note attached -\n\t\t// add a \"new note\" entry to the threads. This special thread type\n\t\t// gets sorted and floated like regular threads, but shows an AddComment\n\t\t// component instead of a regular comment thread.\n\t\tif ( isFloating && showCommentBoard && undefined === blockCommentId ) {\n\t\t\t// Insert the new note entry at the correct location for its blockId.\n\t\t\tconst newNoteThread = {\n\t\t\t\tid: 'new-note-thread',\n\t\t\t\tblockClientId: selectedBlockClientId,\n\t\t\t\tcontent: { rendered: '' },\n\t\t\t};\n\t\t\t// Insert the new comment block at the right order within the threads.\n\t\t\torderedBlockIds.forEach( ( blockId ) => {\n\t\t\t\tif ( blockId === selectedBlockClientId ) {\n\t\t\t\t\torderedThreads.push( newNoteThread );\n\t\t\t\t} else {\n\t\t\t\t\tconst threadForBlock = t.find(\n\t\t\t\t\t\t( thread ) => thread.blockClientId === blockId\n\t\t\t\t\t);\n\t\t\t\t\tif ( threadForBlock ) {\n\t\t\t\t\t\torderedThreads.push( threadForBlock );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\t\t\treturn orderedThreads;\n\t\t}\n\t\treturn t;\n\t}, [\n\t\tnoteThreads,\n\t\tisFloating,\n\t\tshowCommentBoard,\n\t\tblockCommentId,\n\t\tselectedBlockClientId,\n\t\torderedBlockIds,\n\t] );\n\n\tconst handleDelete = async ( comment ) => {\n\t\tconst currentIndex = threads.findIndex( ( t ) => t.id === comment.id );\n\t\tconst nextThread = threads[ currentIndex + 1 ];\n\t\tconst prevThread = threads[ currentIndex - 1 ];\n\n\t\tawait onCommentDelete( comment );\n\n\t\tif ( comment.parent !== 0 ) {\n\t\t\t// Move focus to the parent thread when a reply was deleted.\n\t\t\tsetSelectedThread( comment.parent );\n\t\t\tfocusCommentThread( comment.parent, commentSidebarRef.current );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( nextThread ) {\n\t\t\tsetSelectedThread( nextThread.id );\n\t\t\tfocusCommentThread( nextThread.id, commentSidebarRef.current );\n\t\t} else if ( prevThread ) {\n\t\t\tsetSelectedThread( prevThread.id );\n\t\t\tfocusCommentThread( prevThread.id, commentSidebarRef.current );\n\t\t} else {\n\t\t\tsetSelectedThread( null );\n\t\t\tsetShowCommentBoard( false );\n\t\t\t// Move focus to the related block.\n\t\t\trelatedBlockElement?.focus();\n\t\t}\n\t};\n\n\t// Auto-select the related comment thread when a block is selected.\n\tuseEffect( () => {\n\t\t// Fallback to 'new-note-thread' when showing the comment board for a new note.\n\t\tconst fallback = showCommentBoard ? 'new-note-thread' : null;\n\t\tsetSelectedThread( blockCommentId ?? fallback );\n\t}, [ blockCommentId, showCommentBoard ] );\n\n\tconst setBlockRef = useCallback( ( id, blockRef ) => {\n\t\tsetBlockRefs( ( prev ) => ( { ...prev, [ id ]: blockRef } ) );\n\t}, [] );\n\n\t// Recalculate floating comment thread offsets whenever the heights change.\n\tuseEffect( () => {\n\t\t/**\n\t\t * Calculate the y offsets for all comment threads. Account for potentially\n\t\t * overlapping threads and adjust their positions accordingly.\n\t\t */\n\t\tconst calculateAllOffsets = () => {\n\t\t\tconst offsets = {};\n\n\t\t\tif ( ! isFloating ) {\n\t\t\t\treturn { offsets, minHeight: 0 };\n\t\t\t}\n\n\t\t\t// Find the index of the selected thread.\n\t\t\tconst selectedThreadIndex = threads.findIndex(\n\t\t\t\t( t ) => t.id === selectedThread\n\t\t\t);\n\n\t\t\tconst breakIndex =\n\t\t\t\tselectedThreadIndex === -1 ? 0 : selectedThreadIndex;\n\n\t\t\t// If there is a selected thread, push threads above up and threads below down.\n\t\t\tconst selectedThreadData = threads[ breakIndex ];\n\n\t\t\tif (\n\t\t\t\t! selectedThreadData ||\n\t\t\t\t! blockRefs[ selectedThreadData.id ]\n\t\t\t) {\n\t\t\t\treturn { offsets, minHeight: 0 };\n\t\t\t}\n\n\t\t\tlet blockElement = blockRefs[ selectedThreadData.id ];\n\t\t\tlet blockRect = blockElement?.getBoundingClientRect();\n\t\t\tconst selectedThreadTop = blockRect?.top || 0;\n\t\t\tconst selectedThreadHeight = heights[ selectedThreadData.id ] || 0;\n\n\t\t\toffsets[ selectedThreadData.id ] = -16;\n\n\t\t\tlet previousThreadData = {\n\t\t\t\tthreadTop: selectedThreadTop - 16,\n\t\t\t\tthreadHeight: selectedThreadHeight,\n\t\t\t};\n\n\t\t\t// Process threads after the selected thread, offsetting any overlapping\n\t\t\t// threads downward.\n\t\t\tfor ( let i = breakIndex + 1; i < threads.length; i++ ) {\n\t\t\t\tconst thread = threads[ i ];\n\t\t\t\tif ( ! blockRefs[ thread.id ] ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tblockElement = blockRefs[ thread.id ];\n\t\t\t\tblockRect = blockElement?.getBoundingClientRect();\n\t\t\t\tconst threadTop = blockRect?.top || 0;\n\t\t\t\tconst threadHeight = heights[ thread.id ] || 0;\n\n\t\t\t\tlet additionalOffset = -16;\n\n\t\t\t\t// Check if the thread overlaps with the previous one.\n\t\t\t\tconst previousBottom =\n\t\t\t\t\tpreviousThreadData.threadTop +\n\t\t\t\t\tpreviousThreadData.threadHeight;\n\t\t\t\tif ( threadTop < previousBottom + 16 ) {\n\t\t\t\t\t// Shift down by the difference plus a margin to avoid overlap.\n\t\t\t\t\tadditionalOffset = previousBottom - threadTop + 20;\n\t\t\t\t}\n\n\t\t\t\toffsets[ thread.id ] = additionalOffset;\n\n\t\t\t\t// Update for next iteration.\n\t\t\t\tpreviousThreadData = {\n\t\t\t\t\tthreadTop: threadTop + additionalOffset,\n\t\t\t\t\tthreadHeight,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Process threads before the selected thread, offsetting any overlapping\n\t\t\t// threads upward.\n\t\t\tlet nextThreadData = {\n\t\t\t\tthreadTop: selectedThreadTop - 16,\n\t\t\t};\n\n\t\t\tfor ( let i = selectedThreadIndex - 1; i >= 0; i-- ) {\n\t\t\t\tconst thread = threads[ i ];\n\t\t\t\tif ( ! blockRefs[ thread.id ] ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tblockElement = blockRefs[ thread.id ];\n\t\t\t\tblockRect = blockElement?.getBoundingClientRect();\n\t\t\t\tconst threadTop = blockRect?.top || 0;\n\t\t\t\tconst threadHeight = heights[ thread.id ] || 0;\n\n\t\t\t\tlet additionalOffset = -16;\n\n\t\t\t\t// Calculate the bottom position of this thread with default offset.\n\t\t\t\tconst threadBottom = threadTop + threadHeight;\n\n\t\t\t\t// Check if this thread's bottom would overlap with the next thread's top.\n\t\t\t\tif ( threadBottom > nextThreadData.threadTop ) {\n\t\t\t\t\t// Shift up by the difference plus a margin to avoid overlap.\n\t\t\t\t\tadditionalOffset =\n\t\t\t\t\t\tnextThreadData.threadTop -\n\t\t\t\t\t\tthreadTop -\n\t\t\t\t\t\tthreadHeight -\n\t\t\t\t\t\t20;\n\t\t\t\t}\n\n\t\t\t\toffsets[ thread.id ] = additionalOffset;\n\n\t\t\t\t// Update for next iteration (going upward).\n\t\t\t\tnextThreadData = {\n\t\t\t\t\tthreadTop: threadTop + additionalOffset,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlet editorMinHeight = 0;\n\t\t\t// Take the calculated top of the final note plus its height as the editor min height.\n\t\t\tconst lastThread = threads[ threads.length - 1 ];\n\t\t\tif ( blockRefs[ lastThread.id ] ) {\n\t\t\t\tconst lastBlockElement = blockRefs[ lastThread.id ];\n\t\t\t\tconst lastBlockRect = lastBlockElement?.getBoundingClientRect();\n\t\t\t\tconst lastThreadTop = lastBlockRect?.top || 0;\n\t\t\t\tconst lastThreadHeight = heights[ lastThread.id ] || 0;\n\t\t\t\tconst lastThreadOffset = offsets[ lastThread.id ] || 0;\n\t\t\t\teditorMinHeight =\n\t\t\t\t\tlastThreadTop + lastThreadHeight + lastThreadOffset + 32;\n\t\t\t}\n\n\t\t\treturn { offsets, minHeight: editorMinHeight };\n\t\t};\n\t\tconst { offsets: newOffsets, minHeight } = calculateAllOffsets();\n\t\tif ( Object.keys( newOffsets ).length > 0 ) {\n\t\t\tsetBoardOffsets( newOffsets );\n\t\t}\n\t\t// Ensure the editor has enough height to scroll to all notes.\n\t\tsetCanvasMinHeight( minHeight );\n\t}, [\n\t\theights,\n\t\tblockRefs,\n\t\tisFloating,\n\t\tthreads,\n\t\tselectedThread,\n\t\tsetCanvasMinHeight,\n\t] );\n\n\tconst hasThreads = Array.isArray( threads ) && threads.length > 0;\n\tif ( ! hasThreads && ! isFloating ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<AddComment\n\t\t\t\t\tonSubmit={ onAddReply }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\tcommentSidebarRef={ commentSidebarRef }\n\t\t\t\t/>\n\t\t\t\t<Text as=\"p\">{ __( 'No notes available.' ) }</Text>\n\t\t\t\t<Text as=\"p\" variant=\"muted\">\n\t\t\t\t\t{ __( 'Only logged in users can see Notes.' ) }\n\t\t\t\t</Text>\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ ! isFloating &&\n\t\t\t\tshowCommentBoard &&\n\t\t\t\tundefined === blockCommentId && (\n\t\t\t\t\t<AddComment\n\t\t\t\t\t\tonSubmit={ onAddReply }\n\t\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\t\tcommentSidebarRef={ commentSidebarRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t{ threads.map( ( thread ) => (\n\t\t\t\t<Thread\n\t\t\t\t\tkey={ thread.id }\n\t\t\t\t\tthread={ thread }\n\t\t\t\t\tonAddReply={ onAddReply }\n\t\t\t\t\tonCommentDelete={ handleDelete }\n\t\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\t\tisSelected={ selectedThread === thread.id }\n\t\t\t\t\tsetSelectedThread={ setSelectedThread }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\tcommentSidebarRef={ commentSidebarRef }\n\t\t\t\t\treflowComments={ reflowComments }\n\t\t\t\t\tisFloating={ isFloating }\n\t\t\t\t\tcalculatedOffset={ boardOffsets[ thread.id ] ?? 0 }\n\t\t\t\t\tsetHeights={ setHeights }\n\t\t\t\t\tsetBlockRef={ setBlockRef }\n\t\t\t\t\tselectedThread={ selectedThread }\n\t\t\t\t\tcommentLastUpdated={ commentLastUpdated }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction Thread( {\n\tthread,\n\tonEditComment,\n\tonAddReply,\n\tonCommentDelete,\n\tisSelected,\n\tsetShowCommentBoard,\n\tcommentSidebarRef,\n\treflowComments,\n\tisFloating,\n\tcalculatedOffset,\n\tsetHeights,\n\tsetBlockRef,\n\tsetSelectedThread,\n\tselectedThread,\n\tcommentLastUpdated,\n\tshowCommentBoard,\n} ) {\n\tconst { toggleBlockHighlight, selectBlock, toggleBlockSpotlight } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tconst relatedBlockElement = useBlockElement( thread.blockClientId );\n\tconst debouncedToggleBlockHighlight = useDebounce(\n\t\ttoggleBlockHighlight,\n\t\t50\n\t);\n\tconst { y, refs } = useFloatingThread( {\n\t\tthread,\n\t\tcalculatedOffset,\n\t\tsetHeights,\n\t\tsetBlockRef,\n\t\tselectedThread,\n\t\tcommentLastUpdated,\n\t} );\n\n\tconst onMouseEnter = () => {\n\t\tdebouncedToggleBlockHighlight( thread.blockClientId, true );\n\t};\n\n\tconst onMouseLeave = () => {\n\t\tdebouncedToggleBlockHighlight( thread.blockClientId, false );\n\t};\n\n\tconst handleCommentSelect = () => {\n\t\tsetShowCommentBoard( false );\n\t\tsetSelectedThread( thread.id );\n\t\tif ( !! thread.blockClientId ) {\n\t\t\t// Pass `null` as the second parameter to prevent focusing the block.\n\t\t\tselectBlock( thread.blockClientId, null );\n\t\t\ttoggleBlockSpotlight( thread.blockClientId, true );\n\t\t}\n\t};\n\n\tconst unselectThread = () => {\n\t\tsetSelectedThread( null );\n\t\tsetShowCommentBoard( false );\n\t\ttoggleBlockSpotlight( thread.blockClientId, false );\n\t};\n\n\tconst allReplies = thread?.reply || [];\n\n\tconst lastReply =\n\t\tallReplies.length > 0 ? allReplies[ allReplies.length - 1 ] : undefined;\n\tconst restReplies = allReplies.length > 0 ? allReplies.slice( 0, -1 ) : [];\n\n\tconst commentExcerpt = getCommentExcerpt(\n\t\tstripHTML( thread.content?.rendered ),\n\t\t10\n\t);\n\tconst ariaLabel = !! thread.blockClientId\n\t\t? sprintf(\n\t\t\t\t// translators: %s: note excerpt\n\t\t\t\t__( 'Note: %s' ),\n\t\t\t\tcommentExcerpt\n\t\t )\n\t\t: sprintf(\n\t\t\t\t// translators: %s: note excerpt\n\t\t\t\t__( 'Original block deleted. Note: %s' ),\n\t\t\t\tcommentExcerpt\n\t\t );\n\n\tif ( 'new-note-thread' === thread.id && showCommentBoard && isFloating ) {\n\t\treturn (\n\t\t\t<AddComment\n\t\t\t\tonSubmit={ onAddReply }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\tcommentSidebarRef={ commentSidebarRef }\n\t\t\t\treflowComments={ reflowComments }\n\t\t\t\tisFloating={ isFloating }\n\t\t\t\ty={ y }\n\t\t\t\trefs={ refs }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t// Disable reason: role=\"listitem\" does in fact support aria-expanded.\n\t\t// eslint-disable-next-line jsx-a11y/role-supports-aria-props\n\t\t<VStack\n\t\t\tclassName={ clsx( 'editor-collab-sidebar-panel__thread', {\n\t\t\t\t'is-selected': isSelected,\n\t\t\t\t'is-floating': isFloating,\n\t\t\t} ) }\n\t\t\tid={ `comment-thread-${ thread.id }` }\n\t\t\tspacing=\"3\"\n\t\t\tonClick={ handleCommentSelect }\n\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\tonFocus={ onMouseEnter }\n\t\t\tonBlur={ onMouseLeave }\n\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Expand or Collapse thread.\n\t\t\t\tif (\n\t\t\t\t\tevent.key === 'Enter' &&\n\t\t\t\t\tevent.currentTarget === event.target\n\t\t\t\t) {\n\t\t\t\t\tif ( isSelected ) {\n\t\t\t\t\t\tunselectThread();\n\t\t\t\t\t} else {\n\t\t\t\t\t\thandleCommentSelect();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Collapse thread and focus the thread.\n\t\t\t\tif ( event.key === 'Escape' ) {\n\t\t\t\t\tunselectThread();\n\t\t\t\t\tfocusCommentThread( thread.id, commentSidebarRef.current );\n\t\t\t\t}\n\t\t\t} }\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"listitem\"\n\t\t\taria-label={ ariaLabel }\n\t\t\taria-expanded={ isSelected }\n\t\t\tref={ isFloating ? refs.setFloating : undefined }\n\t\t\tstyle={ isFloating ? { top: y } : undefined }\n\t\t>\n\t\t\t<Button\n\t\t\t\tclassName=\"editor-collab-sidebar-panel__skip-to-comment\"\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\tsize=\"compact\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tfocusCommentThread(\n\t\t\t\t\t\tthread.id,\n\t\t\t\t\t\tcommentSidebarRef.current,\n\t\t\t\t\t\t'textarea'\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Add new note' ) }\n\t\t\t</Button>\n\t\t\t{ ! thread.blockClientId && (\n\t\t\t\t<Text as=\"p\" weight={ 500 } variant=\"muted\">\n\t\t\t\t\t{ __( 'Original block deleted.' ) }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t\t<CommentBoard\n\t\t\t\tthread={ thread }\n\t\t\t\tisExpanded={ isSelected }\n\t\t\t\tonEdit={ ( params = {} ) => {\n\t\t\t\t\tconst { status } = params;\n\t\t\t\t\tonEditComment( params );\n\t\t\t\t\tif ( status === 'approved' ) {\n\t\t\t\t\t\tunselectThread();\n\t\t\t\t\t\tfocusCommentThread(\n\t\t\t\t\t\t\tthread.id,\n\t\t\t\t\t\t\tcommentSidebarRef.current\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\tonDelete={ onCommentDelete }\n\t\t\t\treflowComments={ reflowComments }\n\t\t\t/>\n\t\t\t{ isSelected &&\n\t\t\t\tallReplies.map( ( reply ) => (\n\t\t\t\t\t<CommentBoard\n\t\t\t\t\t\tkey={ reply.id }\n\t\t\t\t\t\tthread={ reply }\n\t\t\t\t\t\tparent={ thread }\n\t\t\t\t\t\tisExpanded={ isSelected }\n\t\t\t\t\t\tonEdit={ onEditComment }\n\t\t\t\t\t\tonDelete={ onCommentDelete }\n\t\t\t\t\t\treflowComments={ reflowComments }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t{ ! isSelected && 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={ () => {\n\t\t\t\t\t\t\tsetSelectedThread( thread.id );\n\t\t\t\t\t\t\tfocusCommentThread(\n\t\t\t\t\t\t\t\tthread.id,\n\t\t\t\t\t\t\t\tcommentSidebarRef.current\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\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{ ! isSelected && lastReply && (\n\t\t\t\t<CommentBoard\n\t\t\t\t\tthread={ lastReply }\n\t\t\t\t\tparent={ thread }\n\t\t\t\t\tisExpanded={ isSelected }\n\t\t\t\t\tonEdit={ onEditComment }\n\t\t\t\t\tonDelete={ onCommentDelete }\n\t\t\t\t\treflowComments={ reflowComments }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isSelected && (\n\t\t\t\t<VStack spacing=\"2\">\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\t// For reopening, include the content in the reopen action.\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\tcontent: inputComment,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// For regular replies, add as separate comment.\n\t\t\t\t\t\t\t\t\tonAddReply( {\n\t\t\t\t\t\t\t\t\t\tcontent: inputComment,\n\t\t\t\t\t\t\t\t\t\tparent: thread.id,\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\tonCancel={ ( event ) => {\n\t\t\t\t\t\t\t\t// Prevent the parent onClick from being triggered.\n\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\tunselectThread();\n\t\t\t\t\t\t\t\tfocusCommentThread(\n\t\t\t\t\t\t\t\t\tthread.id,\n\t\t\t\t\t\t\t\t\tcommentSidebarRef.current\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? __( '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: note identifier, %2$s: author name\n\t\t\t\t\t\t\t\t__( 'Reply to note %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\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\treflowComments={ reflowComments }\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\t{ !! thread.blockClientId && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__skip-to-block\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\trelatedBlockElement?.focus();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Back to block' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nconst CommentBoard = ( {\n\tthread,\n\tparent,\n\tisExpanded,\n\tonEdit,\n\tonDelete,\n\treflowComments,\n} ) => {\n\tconst [ actionState, setActionState ] = useState( false );\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\tconst actionButtonRef = useRef( null );\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\tactionButtonRef.current?.focus();\n\t};\n\n\t// Check if this is a resolution comment by checking metadata.\n\tconst isResolutionComment =\n\t\tthread.type === 'note' &&\n\t\tthread.meta &&\n\t\t( thread.meta._wp_note_status === 'resolved' ||\n\t\t\tthread.meta._wp_note_status === 'reopen' );\n\n\tconst actions = [\n\t\t{\n\t\t\tid: 'edit',\n\t\t\ttitle: __( 'Edit' ),\n\t\t\tisEligible: ( { status } ) => status !== 'approved',\n\t\t\tonClick: () => {\n\t\t\t\tsetActionState( 'edit' );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: 'reopen',\n\t\t\ttitle: _x( 'Reopen', 'Reopen note' ),\n\t\t\tisEligible: ( { status } ) => status === 'approved',\n\t\t\tonClick: () => {\n\t\t\t\tonEdit( { id: thread.id, status: 'hold' } );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: 'delete',\n\t\t\ttitle: __( 'Delete' ),\n\t\t\tisEligible: () => true,\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];\n\n\tconst canResolve = thread.parent === 0;\n\tconst moreActions =\n\t\tparent?.status !== 'approved'\n\t\t\t? actions.filter( ( item ) => item.isEligible( thread ) )\n\t\t\t: [];\n\n\treturn (\n\t\t<VStack spacing=\"2\">\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{ isExpanded && (\n\t\t\t\t\t<FlexItem\n\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__comment-status\"\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t// Prevent the thread from being selected.\n\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<HStack spacing=\"0\">\n\t\t\t\t\t\t\t{ canResolve && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t\t\t'Resolve',\n\t\t\t\t\t\t\t\t\t\t'Mark note as resolved'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\ticon={ published }\n\t\t\t\t\t\t\t\t\tdisabled={ thread.status === 'approved' }\n\t\t\t\t\t\t\t\t\taccessibleWhenDisabled={\n\t\t\t\t\t\t\t\t\t\tthread.status === 'approved'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonEdit( {\n\t\t\t\t\t\t\t\t\t\t\tid: thread.id,\n\t\t\t\t\t\t\t\t\t\t\tstatus: 'approved',\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/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<Menu placement=\"bottom-end\">\n\t\t\t\t\t\t\t\t<Menu.TriggerButton\n\t\t\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tref={ actionButtonRef }\n\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\t\t\t\t\t\tdisabled={ ! moreActions.length }\n\t\t\t\t\t\t\t\t\t\t\taccessibleWhenDisabled\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/>\n\t\t\t\t\t\t\t\t<Menu.Popover>\n\t\t\t\t\t\t\t\t\t{ moreActions.map( ( action ) => (\n\t\t\t\t\t\t\t\t\t\t<Menu.Item\n\t\t\t\t\t\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => action.onClick() }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<Menu.ItemLabel>\n\t\t\t\t\t\t\t\t\t\t\t\t{ action.title }\n\t\t\t\t\t\t\t\t\t\t\t</Menu.ItemLabel>\n\t\t\t\t\t\t\t\t\t\t</Menu.Item>\n\t\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t\t</Menu.Popover>\n\t\t\t\t\t\t\t</Menu>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t) }\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\tactionButtonRef.current?.focus();\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: note identifier, %2$s: author name.\n\t\t\t\t\t\t__( 'Edit note %1$s by %2$s' ),\n\t\t\t\t\t\tthread.id,\n\t\t\t\t\t\tthread.author_name\n\t\t\t\t\t) }\n\t\t\t\t\treflowComments={ reflowComments }\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<RawHTML\n\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t'editor-collab-sidebar-panel__user-comment',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'editor-collab-sidebar-panel__resolution-text':\n\t\t\t\t\t\t\t\tisResolutionComment,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ isResolutionComment\n\t\t\t\t\t\t? ( () => {\n\t\t\t\t\t\t\t\tconst actionText =\n\t\t\t\t\t\t\t\t\tthread.meta._wp_note_status === 'resolved'\n\t\t\t\t\t\t\t\t\t\t? __( 'Marked as resolved' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Reopened' );\n\t\t\t\t\t\t\t\tconst content = thread?.content?.raw;\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tcontent &&\n\t\t\t\t\t\t\t\t\ttypeof content === 'string' &&\n\t\t\t\t\t\t\t\t\tcontent.trim() !== ''\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\treturn sprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %1$s: action label (\"Marked as resolved\" or \"Reopened\"); %2$s: note text.\n\t\t\t\t\t\t\t\t\t\t__( '%1$s: %2$s' ),\n\t\t\t\t\t\t\t\t\t\tactionText,\n\t\t\t\t\t\t\t\t\t\tcontent\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// If no content, just show the action.\n\t\t\t\t\t\t\t\treturn actionText;\n\t\t\t\t\t\t } )()\n\t\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\"Are you sure you want to delete this note? This will also delete all of this note's replies.\"\n\t\t\t\t\t) }\n\t\t\t\t</ConfirmDialog>\n\t\t\t) }\n\t\t</VStack>\n\t);\n};\n\nexport default Comments;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwTG;AArTH,kBAAiB;AAKjB,qBAOO;AACP,wBAQO;AACP,qBAA4B;AAE5B,mBAAwC;AACxC,kBAAoC;AACpC,kBAAuC;AACvC,iBAAiD;AACjD,0BAGO;AAKP,yBAAuB;AACvB,iCAA8B;AAC9B,0BAAwB;AACxB,mBAAsD;AACtD,mBAAkC;AAClC,yBAA2B;AAC3B,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AM,aAAa;AAAA,QAC9B;AAAA,QACA,sBAAmB,gBAAI,UAAU,MAAO;AAAA,QACxC,eAAY;AAAA;AAAA,cAEX,gBAAI,wBAAyB;AAAA,UAC7B,OAAO;AAAA,UACP,OAAO;AAAA,QACR;AAAA,QACA;AAAA;AAAA,IACD,IAEA;AAAA,MAAC;AAAA;AAAA,QACA,eAAY,YAAAH;AAAA,UACX;AAAA,UACA;AAAA,YACC,gDACC;AAAA,UACF;AAAA,QACD;AAAA,QAEE,iCACG,MAAM;AACR,gBAAM,aACL,OAAO,KAAK,oBAAoB,iBAC7B,gBAAI,oBAAqB,QACzB,gBAAI,UAAW;AACnB,gBAAM,UAAU,QAAQ,SAAS;AAEjC,cACC,WACA,OAAO,YAAY,YACnB,QAAQ,KAAK,MAAM,IAClB;AACD,uBAAO;AAAA;AAAA,kBAEN,gBAAI,YAAa;AAAA,cACjB;AAAA,cACA;AAAA,YACD;AAAA,UACD;AAEA,iBAAO;AAAA,QACP,GAAI,IACJ,QAAQ,SAAS;AAAA;AAAA,IACrB;AAAA,IAEC,aAAa,eACd;AAAA,MAAC,kBAAAI;AAAA,MAAA;AAAA,QACA,QAAS;AAAA,QACT,WAAY;AAAA,QACZ,UAAW;AAAA,QACX,uBAAoB,gBAAI,QAAS;AAAA,QAE/B;AAAA,UACD;AAAA,QACD;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;AAEA,IAAO,mBAAQ;",
|
|
6
|
+
"names": ["blockEditorPrivateApis", "componentsPrivateApis", "editorStore", "blockEditorStore", "Text", "stripHTML", "VStack", "clsx", "HStack", "CommentAuthorInfo", "CommentForm", "ConfirmDialog"]
|
|
7
7
|
}
|
|
@@ -65,6 +65,9 @@ function useBlockComments(postId) {
|
|
|
65
65
|
};
|
|
66
66
|
}, []);
|
|
67
67
|
const { resultComments, unresolvedSortedThreads } = (0, import_element.useMemo)(() => {
|
|
68
|
+
if (!threads || threads.length === 0) {
|
|
69
|
+
return { resultComments: [], unresolvedSortedThreads: [] };
|
|
70
|
+
}
|
|
68
71
|
const blocksWithComments = clientIds.reduce((results, clientId) => {
|
|
69
72
|
const commentId = getBlockAttributes(clientId)?.metadata?.noteId;
|
|
70
73
|
if (commentId) {
|
|
@@ -74,8 +77,7 @@ function useBlockComments(postId) {
|
|
|
74
77
|
}, {});
|
|
75
78
|
const compare = {};
|
|
76
79
|
const result = [];
|
|
77
|
-
|
|
78
|
-
allComments.forEach((item) => {
|
|
80
|
+
threads.forEach((item) => {
|
|
79
81
|
const itemBlock = Object.keys(blocksWithComments).find(
|
|
80
82
|
(key) => blocksWithComments[key] === item.id
|
|
81
83
|
);
|
|
@@ -85,7 +87,7 @@ function useBlockComments(postId) {
|
|
|
85
87
|
blockClientId: item.parent === 0 ? itemBlock : null
|
|
86
88
|
};
|
|
87
89
|
});
|
|
88
|
-
|
|
90
|
+
threads.forEach((item) => {
|
|
89
91
|
if (item.parent === 0) {
|
|
90
92
|
result.push(compare[item.id]);
|
|
91
93
|
} else if (compare[item.parent]) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/collab-sidebar/hooks.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport {\n\tuseFloating,\n\toffset as offsetMiddleware,\n\tautoUpdate,\n} from '@floating-ui/react-dom';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseCallback,\n\tuseReducer,\n} from '@wordpress/element';\nimport { useEntityRecords, store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport {\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { collabSidebarName } from './constants';\nimport { unlock } from '../../lock-unlock';\nimport { noop } from './utils';\n\nconst { useBlockElementRef, cleanEmptyObject } = unlock(\n\tblockEditorPrivateApis\n);\n\nexport function useBlockComments( postId ) {\n\tconst [ commentLastUpdated, reflowComments ] = useReducer(\n\t\t() => Date.now(),\n\t\t0\n\t);\n\n\tconst queryArgs = {\n\t\tpost: postId,\n\t\ttype: 'note',\n\t\tstatus: 'all',\n\t\tper_page: -1,\n\t};\n\n\tconst { records: threads } = 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 { getBlockAttributes } = useSelect( blockEditorStore );\n\tconst { clientIds } = useSelect( ( select ) => {\n\t\tconst { getClientIdsWithDescendants } = select( blockEditorStore );\n\t\treturn {\n\t\t\tclientIds: getClientIdsWithDescendants(),\n\t\t};\n\t}, [] );\n\n\t// Process comments to build the tree structure.\n\tconst { resultComments, unresolvedSortedThreads } = useMemo( () => {\n\t\tconst blocksWithComments = clientIds.reduce( ( results, clientId ) => {\n\t\t\tconst commentId = getBlockAttributes( clientId )?.metadata?.noteId;\n\t\t\tif ( commentId ) {\n\t\t\t\tresults[ clientId ] = commentId;\n\t\t\t}\n\t\t\treturn results;\n\t\t}, {} );\n\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\tconst itemBlock = Object.keys( blocksWithComments ).find(\n\t\t\t\t( key ) => blocksWithComments[ key ] === item.id\n\t\t\t);\n\n\t\t\tcompare[ item.id ] = {\n\t\t\t\t...item,\n\t\t\t\treply: [],\n\t\t\t\tblockClientId: item.parent === 0 ? itemBlock : 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// Prepare sets to determine which threads are linked to existing blocks.\n\t\tconst mappedIds = new Set(\n\t\t\tObject.values( blocksWithComments ).map( ( id ) => String( id ) )\n\t\t);\n\n\t\t// Get comments by block order, first unresolved, then resolved.\n\t\tconst unresolvedSortedComments = Object.values( blocksWithComments )\n\t\t\t.map( ( commentId ) => threadIdMap.get( String( commentId ) ) )\n\t\t\t.filter(\n\t\t\t\t( thread ) => thread !== undefined && thread.status === 'hold'\n\t\t\t);\n\n\t\tconst resolvedSortedComments = Object.values( blocksWithComments )\n\t\t\t.map( ( commentId ) => threadIdMap.get( String( commentId ) ) )\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\t// Append orphaned notes (whose related block was deleted or missing).\n\t\tconst orphanedComments = updatedResult.filter(\n\t\t\t( thread ) => ! mappedIds.has( String( thread.id ) )\n\t\t);\n\n\t\tconst allSortedComments = [\n\t\t\t...unresolvedSortedComments,\n\t\t\t...resolvedSortedComments,\n\t\t\t...orphanedComments,\n\t\t];\n\n\t\treturn {\n\t\t\tresultComments: allSortedComments,\n\t\t\tunresolvedSortedThreads: unresolvedSortedComments,\n\t\t};\n\t}, [ clientIds, threads, getBlockAttributes ] );\n\n\treturn {\n\t\tresultComments,\n\t\tunresolvedSortedThreads,\n\t\treflowComments,\n\t\tcommentLastUpdated,\n\t};\n}\n\nexport function useBlockCommentsActions( reflowComments = noop ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getCurrentPostId } = useSelect( editorStore );\n\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\tuseSelect( 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? decodeEntities( 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 onCreate = async ( { content, parent } ) => {\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: getCurrentPostId(),\n\t\t\t\t\tcontent,\n\t\t\t\t\tstatus: 'hold',\n\t\t\t\t\ttype: 'note',\n\t\t\t\t\tparent: parent || 0,\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 ( ! parent && savedRecord?.id ) {\n\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\tconst metadata = getBlockAttributes( clientId )?.metadata;\n\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t...metadata,\n\t\t\t\t\t\tnoteId: savedRecord.id,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tparent ? __( 'Reply added.' ) : __( 'Note added.' ),\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\tsetTimeout( reflowComments, 300 );\n\t\t\treturn savedRecord;\n\t\t} catch ( error ) {\n\t\t\treflowComments();\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onEdit = async ( { id, content, status } ) => {\n\t\tconst messageType = status ? status : 'updated';\n\t\tconst messages = {\n\t\t\tapproved: __( 'Note marked as resolved.' ),\n\t\t\thold: __( 'Note reopened.' ),\n\t\t\tupdated: __( 'Note updated.' ),\n\t\t};\n\n\t\ttry {\n\t\t\t// For resolution or reopen actions, create a new note with metadata.\n\t\t\tif ( status === 'approved' || status === 'hold' ) {\n\t\t\t\t// First, update the thread status.\n\t\t\t\tawait saveEntityRecord(\n\t\t\t\t\t'root',\n\t\t\t\t\t'comment',\n\t\t\t\t\t{\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tstatus,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tthrowOnError: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\t// Then create a new comment with the metadata.\n\t\t\t\tconst newCommentData = {\n\t\t\t\t\tpost: getCurrentPostId(),\n\t\t\t\t\tcontent: content || '', // Empty content for resolve, content for reopen.\n\t\t\t\t\ttype: 'note',\n\t\t\t\t\tstatus,\n\t\t\t\t\tparent: id,\n\t\t\t\t\tmeta: {\n\t\t\t\t\t\t_wp_note_status:\n\t\t\t\t\t\t\tstatus === 'approved' ? 'resolved' : 'reopen',\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\tawait saveEntityRecord( 'root', 'comment', newCommentData, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst updateData = {\n\t\t\t\t\tid,\n\t\t\t\t\tcontent,\n\t\t\t\t\tstatus,\n\t\t\t\t};\n\n\t\t\t\tawait saveEntityRecord( 'root', 'comment', updateData, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tmessages[ messageType ] ?? __( 'Note updated.' ),\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\treflowComments();\n\t\t} catch ( error ) {\n\t\t\treflowComments();\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onDelete = async ( comment ) => {\n\t\ttry {\n\t\t\tawait deleteEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\tcomment.id,\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( ! comment.parent ) {\n\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\tconst metadata = getBlockAttributes( clientId )?.metadata;\n\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\tmetadata: cleanEmptyObject( {\n\t\t\t\t\t\t...metadata,\n\t\t\t\t\t\tnoteId: undefined,\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice( 'snackbar', __( 'Note deleted.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t\treflowComments();\n\t\t} catch ( error ) {\n\t\t\treflowComments();\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\treturn { onCreate, onEdit, onDelete };\n}\n\nexport function useEnableFloatingSidebar( enabled = false ) {\n\tconst registry = useRegistry();\n\tuseEffect( () => {\n\t\tif ( ! enabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { getActiveComplementaryArea } =\n\t\t\tregistry.select( interfaceStore );\n\t\tconst { disableComplementaryArea, enableComplementaryArea } =\n\t\t\tregistry.dispatch( interfaceStore );\n\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Return `null` to indicate the user hid the complementary area.\n\t\t\tif ( getActiveComplementaryArea( 'core' ) === null ) {\n\t\t\t\tenableComplementaryArea( 'core', collabSidebarName );\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tunsubscribe();\n\t\t\tif ( getActiveComplementaryArea( 'core' ) === collabSidebarName ) {\n\t\t\t\tdisableComplementaryArea( 'core', collabSidebarName );\n\t\t\t}\n\t\t};\n\t}, [ enabled, registry ] );\n}\n\nexport function useFloatingThread( {\n\tthread,\n\tcalculatedOffset,\n\tsetHeights,\n\tselectedThread,\n\tsetBlockRef,\n\tcommentLastUpdated,\n} ) {\n\tconst blockRef = useRef();\n\tuseBlockElementRef( thread.blockClientId, blockRef );\n\n\tconst updateHeight = useCallback(\n\t\t( id, newHeight ) => {\n\t\t\tsetHeights( ( prev ) => {\n\t\t\t\tif ( prev[ id ] !== newHeight ) {\n\t\t\t\t\treturn { ...prev, [ id ]: newHeight };\n\t\t\t\t}\n\t\t\t\treturn prev;\n\t\t\t} );\n\t\t},\n\t\t[ setHeights ]\n\t);\n\n\t// Use floating-ui to track the block element's position with the calculated offset.\n\tconst { y, refs } = useFloating( {\n\t\tplacement: 'right-start',\n\t\tmiddleware: [\n\t\t\toffsetMiddleware( {\n\t\t\t\tcrossAxis: calculatedOffset || -16,\n\t\t\t} ),\n\t\t],\n\t\twhileElementsMounted: autoUpdate,\n\t} );\n\n\t// Store the block reference for each thread.\n\tuseEffect( () => {\n\t\tif ( blockRef.current ) {\n\t\t\trefs.setReference( blockRef.current );\n\t\t}\n\t}, [ blockRef, refs, commentLastUpdated ] );\n\n\t// Track thread heights.\n\tuseEffect( () => {\n\t\tif ( refs.floating?.current ) {\n\t\t\tsetBlockRef( thread.id, blockRef.current );\n\t\t}\n\t}, [ thread.id, refs.floating, setBlockRef ] );\n\n\t// When the selected thread changes, update heights, triggering offset recalculation.\n\tuseEffect( () => {\n\t\tif ( refs.floating?.current ) {\n\t\t\tconst newHeight = refs.floating.current.scrollHeight;\n\t\t\tupdateHeight( thread.id, newHeight );\n\t\t}\n\t}, [\n\t\tthread.id,\n\t\tupdateHeight,\n\t\trefs.floating,\n\t\tselectedThread,\n\t\tcommentLastUpdated,\n\t] );\n\n\treturn {\n\t\tblockRef,\n\t\ty,\n\t\trefs,\n\t};\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAIO;AAKP,kBAAmB;AACnB,qBAMO;AACP,uBAAqD;AACrD,kBAAoD;AACpD,0BAGO;AACP,qBAAsC;AACtC,2BAA+B;AAC/B,uBAAwC;AAKxC,mBAAqC;AACrC,uBAAkC;AAClC,yBAAuB;AACvB,mBAAqB;AAErB,MAAM,EAAE,oBAAoB,iBAAiB,QAAI;AAAA,EAChD,oBAAAA;AACD;AAEO,SAAS,iBAAkB,QAAS;AAC1C,QAAM,CAAE,oBAAoB,cAAe,QAAI;AAAA,IAC9C,MAAM,KAAK,IAAI;AAAA,IACf;AAAA,EACD;AAEA,QAAM,YAAY;AAAA,IACjB,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,UAAU;AAAA,EACX;AAEA,QAAM,EAAE,SAAS,QAAQ,QAAI;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA,EAAE,SAAS,CAAC,CAAE,UAAU,OAAO,WAAW,SAAS;AAAA,EACpD;AAEA,QAAM,EAAE,mBAAmB,QAAI,uBAAW,oBAAAC,KAAiB;AAC3D,QAAM,EAAE,UAAU,QAAI,uBAAW,CAAE,WAAY;AAC9C,UAAM,EAAE,4BAA4B,IAAI,OAAQ,oBAAAA,KAAiB;AACjE,WAAO;AAAA,MACN,WAAW,4BAA4B;AAAA,IACxC;AAAA,EACD,GAAG,CAAC,CAAE;AAGN,QAAM,EAAE,gBAAgB,wBAAwB,QAAI,wBAAS,MAAM;AAClE,UAAM,qBAAqB,UAAU,OAAQ,CAAE,SAAS,aAAc;AACrE,YAAM,YAAY,mBAAoB,QAAS,GAAG,UAAU;AAC5D,UAAK,WAAY;AAChB,gBAAS,QAAS,IAAI;AAAA,MACvB;AACA,aAAO;AAAA,IACR,GAAG,CAAC,CAAE;AAGN,UAAM,UAAU,CAAC;AACjB,UAAM,SAAS,CAAC;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport {\n\tuseFloating,\n\toffset as offsetMiddleware,\n\tautoUpdate,\n} from '@floating-ui/react-dom';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseCallback,\n\tuseReducer,\n} from '@wordpress/element';\nimport { useEntityRecords, store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport {\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { collabSidebarName } from './constants';\nimport { unlock } from '../../lock-unlock';\nimport { noop } from './utils';\n\nconst { useBlockElementRef, cleanEmptyObject } = unlock(\n\tblockEditorPrivateApis\n);\n\nexport function useBlockComments( postId ) {\n\tconst [ commentLastUpdated, reflowComments ] = useReducer(\n\t\t() => Date.now(),\n\t\t0\n\t);\n\n\tconst queryArgs = {\n\t\tpost: postId,\n\t\ttype: 'note',\n\t\tstatus: 'all',\n\t\tper_page: -1,\n\t};\n\n\tconst { records: threads } = 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 { getBlockAttributes } = useSelect( blockEditorStore );\n\tconst { clientIds } = useSelect( ( select ) => {\n\t\tconst { getClientIdsWithDescendants } = select( blockEditorStore );\n\t\treturn {\n\t\t\tclientIds: getClientIdsWithDescendants(),\n\t\t};\n\t}, [] );\n\n\t// Process comments to build the tree structure.\n\tconst { resultComments, unresolvedSortedThreads } = useMemo( () => {\n\t\tif ( ! threads || threads.length === 0 ) {\n\t\t\treturn { resultComments: [], unresolvedSortedThreads: [] };\n\t\t}\n\n\t\tconst blocksWithComments = clientIds.reduce( ( results, clientId ) => {\n\t\t\tconst commentId = getBlockAttributes( clientId )?.metadata?.noteId;\n\t\t\tif ( commentId ) {\n\t\t\t\tresults[ clientId ] = commentId;\n\t\t\t}\n\t\t\treturn results;\n\t\t}, {} );\n\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\t// Initialize each object with an empty `reply` array and map blockClientId.\n\t\tthreads.forEach( ( item ) => {\n\t\t\tconst itemBlock = Object.keys( blocksWithComments ).find(\n\t\t\t\t( key ) => blocksWithComments[ key ] === item.id\n\t\t\t);\n\n\t\t\tcompare[ item.id ] = {\n\t\t\t\t...item,\n\t\t\t\treply: [],\n\t\t\t\tblockClientId: item.parent === 0 ? itemBlock : null,\n\t\t\t};\n\t\t} );\n\n\t\t// Iterate over the data to build the tree structure.\n\t\tthreads.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// Prepare sets to determine which threads are linked to existing blocks.\n\t\tconst mappedIds = new Set(\n\t\t\tObject.values( blocksWithComments ).map( ( id ) => String( id ) )\n\t\t);\n\n\t\t// Get comments by block order, first unresolved, then resolved.\n\t\tconst unresolvedSortedComments = Object.values( blocksWithComments )\n\t\t\t.map( ( commentId ) => threadIdMap.get( String( commentId ) ) )\n\t\t\t.filter(\n\t\t\t\t( thread ) => thread !== undefined && thread.status === 'hold'\n\t\t\t);\n\n\t\tconst resolvedSortedComments = Object.values( blocksWithComments )\n\t\t\t.map( ( commentId ) => threadIdMap.get( String( commentId ) ) )\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\t// Append orphaned notes (whose related block was deleted or missing).\n\t\tconst orphanedComments = updatedResult.filter(\n\t\t\t( thread ) => ! mappedIds.has( String( thread.id ) )\n\t\t);\n\n\t\tconst allSortedComments = [\n\t\t\t...unresolvedSortedComments,\n\t\t\t...resolvedSortedComments,\n\t\t\t...orphanedComments,\n\t\t];\n\n\t\treturn {\n\t\t\tresultComments: allSortedComments,\n\t\t\tunresolvedSortedThreads: unresolvedSortedComments,\n\t\t};\n\t}, [ clientIds, threads, getBlockAttributes ] );\n\n\treturn {\n\t\tresultComments,\n\t\tunresolvedSortedThreads,\n\t\treflowComments,\n\t\tcommentLastUpdated,\n\t};\n}\n\nexport function useBlockCommentsActions( reflowComments = noop ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getCurrentPostId } = useSelect( editorStore );\n\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\tuseSelect( 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? decodeEntities( 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 onCreate = async ( { content, parent } ) => {\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: getCurrentPostId(),\n\t\t\t\t\tcontent,\n\t\t\t\t\tstatus: 'hold',\n\t\t\t\t\ttype: 'note',\n\t\t\t\t\tparent: parent || 0,\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 ( ! parent && savedRecord?.id ) {\n\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\tconst metadata = getBlockAttributes( clientId )?.metadata;\n\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t...metadata,\n\t\t\t\t\t\tnoteId: savedRecord.id,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tparent ? __( 'Reply added.' ) : __( 'Note added.' ),\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\tsetTimeout( reflowComments, 300 );\n\t\t\treturn savedRecord;\n\t\t} catch ( error ) {\n\t\t\treflowComments();\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onEdit = async ( { id, content, status } ) => {\n\t\tconst messageType = status ? status : 'updated';\n\t\tconst messages = {\n\t\t\tapproved: __( 'Note marked as resolved.' ),\n\t\t\thold: __( 'Note reopened.' ),\n\t\t\tupdated: __( 'Note updated.' ),\n\t\t};\n\n\t\ttry {\n\t\t\t// For resolution or reopen actions, create a new note with metadata.\n\t\t\tif ( status === 'approved' || status === 'hold' ) {\n\t\t\t\t// First, update the thread status.\n\t\t\t\tawait saveEntityRecord(\n\t\t\t\t\t'root',\n\t\t\t\t\t'comment',\n\t\t\t\t\t{\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tstatus,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tthrowOnError: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\t// Then create a new comment with the metadata.\n\t\t\t\tconst newCommentData = {\n\t\t\t\t\tpost: getCurrentPostId(),\n\t\t\t\t\tcontent: content || '', // Empty content for resolve, content for reopen.\n\t\t\t\t\ttype: 'note',\n\t\t\t\t\tstatus,\n\t\t\t\t\tparent: id,\n\t\t\t\t\tmeta: {\n\t\t\t\t\t\t_wp_note_status:\n\t\t\t\t\t\t\tstatus === 'approved' ? 'resolved' : 'reopen',\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\tawait saveEntityRecord( 'root', 'comment', newCommentData, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst updateData = {\n\t\t\t\t\tid,\n\t\t\t\t\tcontent,\n\t\t\t\t\tstatus,\n\t\t\t\t};\n\n\t\t\t\tawait saveEntityRecord( 'root', 'comment', updateData, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tmessages[ messageType ] ?? __( 'Note updated.' ),\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\treflowComments();\n\t\t} catch ( error ) {\n\t\t\treflowComments();\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onDelete = async ( comment ) => {\n\t\ttry {\n\t\t\tawait deleteEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\tcomment.id,\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( ! comment.parent ) {\n\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\tconst metadata = getBlockAttributes( clientId )?.metadata;\n\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\tmetadata: cleanEmptyObject( {\n\t\t\t\t\t\t...metadata,\n\t\t\t\t\t\tnoteId: undefined,\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice( 'snackbar', __( 'Note deleted.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t\treflowComments();\n\t\t} catch ( error ) {\n\t\t\treflowComments();\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\treturn { onCreate, onEdit, onDelete };\n}\n\nexport function useEnableFloatingSidebar( enabled = false ) {\n\tconst registry = useRegistry();\n\tuseEffect( () => {\n\t\tif ( ! enabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { getActiveComplementaryArea } =\n\t\t\tregistry.select( interfaceStore );\n\t\tconst { disableComplementaryArea, enableComplementaryArea } =\n\t\t\tregistry.dispatch( interfaceStore );\n\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Return `null` to indicate the user hid the complementary area.\n\t\t\tif ( getActiveComplementaryArea( 'core' ) === null ) {\n\t\t\t\tenableComplementaryArea( 'core', collabSidebarName );\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tunsubscribe();\n\t\t\tif ( getActiveComplementaryArea( 'core' ) === collabSidebarName ) {\n\t\t\t\tdisableComplementaryArea( 'core', collabSidebarName );\n\t\t\t}\n\t\t};\n\t}, [ enabled, registry ] );\n}\n\nexport function useFloatingThread( {\n\tthread,\n\tcalculatedOffset,\n\tsetHeights,\n\tselectedThread,\n\tsetBlockRef,\n\tcommentLastUpdated,\n} ) {\n\tconst blockRef = useRef();\n\tuseBlockElementRef( thread.blockClientId, blockRef );\n\n\tconst updateHeight = useCallback(\n\t\t( id, newHeight ) => {\n\t\t\tsetHeights( ( prev ) => {\n\t\t\t\tif ( prev[ id ] !== newHeight ) {\n\t\t\t\t\treturn { ...prev, [ id ]: newHeight };\n\t\t\t\t}\n\t\t\t\treturn prev;\n\t\t\t} );\n\t\t},\n\t\t[ setHeights ]\n\t);\n\n\t// Use floating-ui to track the block element's position with the calculated offset.\n\tconst { y, refs } = useFloating( {\n\t\tplacement: 'right-start',\n\t\tmiddleware: [\n\t\t\toffsetMiddleware( {\n\t\t\t\tcrossAxis: calculatedOffset || -16,\n\t\t\t} ),\n\t\t],\n\t\twhileElementsMounted: autoUpdate,\n\t} );\n\n\t// Store the block reference for each thread.\n\tuseEffect( () => {\n\t\tif ( blockRef.current ) {\n\t\t\trefs.setReference( blockRef.current );\n\t\t}\n\t}, [ blockRef, refs, commentLastUpdated ] );\n\n\t// Track thread heights.\n\tuseEffect( () => {\n\t\tif ( refs.floating?.current ) {\n\t\t\tsetBlockRef( thread.id, blockRef.current );\n\t\t}\n\t}, [ thread.id, refs.floating, setBlockRef ] );\n\n\t// When the selected thread changes, update heights, triggering offset recalculation.\n\tuseEffect( () => {\n\t\tif ( refs.floating?.current ) {\n\t\t\tconst newHeight = refs.floating.current.scrollHeight;\n\t\t\tupdateHeight( thread.id, newHeight );\n\t\t}\n\t}, [\n\t\tthread.id,\n\t\tupdateHeight,\n\t\trefs.floating,\n\t\tselectedThread,\n\t\tcommentLastUpdated,\n\t] );\n\n\treturn {\n\t\tblockRef,\n\t\ty,\n\t\trefs,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAIO;AAKP,kBAAmB;AACnB,qBAMO;AACP,uBAAqD;AACrD,kBAAoD;AACpD,0BAGO;AACP,qBAAsC;AACtC,2BAA+B;AAC/B,uBAAw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ACD,GAAG;AAAA,IACF,OAAO;AAAA,IACP;AAAA,IACA,KAAK;AAAA,IACL;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["blockEditorPrivateApis", "blockEditorStore", "noticesStore", "coreStore", "editorStore", "interfaceStore", "offsetMiddleware"]
|
|
7
7
|
}
|
|
@@ -50,6 +50,7 @@ var import_global_styles_provider = require("../global-styles-provider");
|
|
|
50
50
|
var import_hooks = require("./hooks");
|
|
51
51
|
var import_utils = require("./utils");
|
|
52
52
|
var import_post_type_support_check = __toESM(require("../post-type-support-check"));
|
|
53
|
+
var import_lock_unlock = require("../../lock-unlock");
|
|
53
54
|
function NotesSidebarContent({
|
|
54
55
|
showCommentBoard,
|
|
55
56
|
setShowCommentBoard,
|
|
@@ -96,13 +97,17 @@ function NotesSidebar({ postId, mode }) {
|
|
|
96
97
|
const [showCommentBoard, setShowCommentBoard] = (0, import_element.useState)(false);
|
|
97
98
|
const { getActiveComplementaryArea } = (0, import_data.useSelect)(import_interface.store);
|
|
98
99
|
const { enableComplementaryArea } = (0, import_data.useDispatch)(import_interface.store);
|
|
100
|
+
const { toggleBlockSpotlight } = (0, import_lock_unlock.unlock)((0, import_data.useDispatch)(import_block_editor.store));
|
|
99
101
|
const isLargeViewport = (0, import_compose.useViewportMatch)("medium");
|
|
100
102
|
const commentSidebarRef = (0, import_element.useRef)(null);
|
|
101
103
|
const showFloatingSidebar = isLargeViewport && mode === "post-only";
|
|
102
|
-
const blockCommentId = (0, import_data.useSelect)((select) => {
|
|
104
|
+
const { clientId, blockCommentId } = (0, import_data.useSelect)((select) => {
|
|
103
105
|
const { getBlockAttributes, getSelectedBlockClientId } = select(import_block_editor.store);
|
|
104
|
-
const
|
|
105
|
-
return
|
|
106
|
+
const _clientId = getSelectedBlockClientId();
|
|
107
|
+
return {
|
|
108
|
+
clientId: _clientId,
|
|
109
|
+
blockCommentId: _clientId ? getBlockAttributes(_clientId)?.metadata?.noteId : null
|
|
110
|
+
};
|
|
106
111
|
}, []);
|
|
107
112
|
const {
|
|
108
113
|
resultComments,
|
|
@@ -138,6 +143,7 @@ function NotesSidebar({ postId, mode }) {
|
|
|
138
143
|
// Focus a comment thread when there's a selected block with a comment.
|
|
139
144
|
!blockCommentId ? "textarea" : void 0
|
|
140
145
|
);
|
|
146
|
+
toggleBlockSpotlight(clientId, true);
|
|
141
147
|
}
|
|
142
148
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
143
149
|
blockCommentId && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -153,7 +159,8 @@ function NotesSidebar({ postId, mode }) {
|
|
|
153
159
|
{
|
|
154
160
|
identifier: import_constants.collabHistorySidebarName,
|
|
155
161
|
name: import_constants.collabHistorySidebarName,
|
|
156
|
-
title: (0, import_i18n.__)("
|
|
162
|
+
title: (0, import_i18n.__)("All notes"),
|
|
163
|
+
header: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "interface-complementary-area-header__title", children: (0, import_i18n.__)("All notes") }),
|
|
157
164
|
icon: import_icons.comment,
|
|
158
165
|
closeLabel: (0, import_i18n.__)("Close Notes"),
|
|
159
166
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -198,16 +205,20 @@ function NotesSidebar({ postId, mode }) {
|
|
|
198
205
|
] });
|
|
199
206
|
}
|
|
200
207
|
function NotesSidebarContainer() {
|
|
201
|
-
const { postId, mode } = (0, import_data.useSelect)((select) => {
|
|
202
|
-
const { getCurrentPostId, getRenderingMode } = select(import_store.store);
|
|
208
|
+
const { postId, mode, editorMode } = (0, import_data.useSelect)((select) => {
|
|
209
|
+
const { getCurrentPostId, getRenderingMode, getEditorMode } = select(import_store.store);
|
|
203
210
|
return {
|
|
204
211
|
postId: getCurrentPostId(),
|
|
205
|
-
mode: getRenderingMode()
|
|
212
|
+
mode: getRenderingMode(),
|
|
213
|
+
editorMode: getEditorMode()
|
|
206
214
|
};
|
|
207
215
|
}, []);
|
|
208
216
|
if (!postId || typeof postId !== "number") {
|
|
209
217
|
return null;
|
|
210
218
|
}
|
|
219
|
+
if (editorMode === "text") {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
211
222
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_post_type_support_check.default, { supportKeys: "editor.notes", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NotesSidebar, { postId, mode }) });
|
|
212
223
|
}
|
|
213
224
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/collab-sidebar/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __experimentalVStack as VStack } from '@wordpress/components';\nimport { useState, useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { comment as commentIcon } from '@wordpress/icons';\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 {\n\tcollabHistorySidebarName,\n\tcollabSidebarName,\n\tSIDEBARS,\n} from './constants';\nimport { Comments } from './comments';\nimport { store as editorStore } from '../../store';\nimport AddCommentMenuItem from './comment-menu-item';\nimport CommentAvatarIndicator from './comment-indicator-toolbar';\nimport { useGlobalStylesContext } from '../global-styles-provider';\nimport {\n\tuseBlockComments,\n\tuseBlockCommentsActions,\n\tuseEnableFloatingSidebar,\n} from './hooks';\nimport { focusCommentThread } from './utils';\nimport PostTypeSupportCheck from '../post-type-support-check';\n\nfunction NotesSidebarContent( {\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tstyles,\n\tcomments,\n\tcommentSidebarRef,\n\treflowComments,\n\tcommentLastUpdated,\n\tisFloating = false,\n} ) {\n\tconst { onCreate, onEdit, onDelete } =\n\t\tuseBlockCommentsActions( reflowComments );\n\n\treturn (\n\t\t<VStack\n\t\t\tclassName=\"editor-collab-sidebar-panel\"\n\t\t\tstyle={ styles }\n\t\t\trole=\"list\"\n\t\t\tspacing=\"3\"\n\t\t\tjustify=\"flex-start\"\n\t\t\tref={ ( node ) => {\n\t\t\t\t// Sometimes previous sidebar unmounts after the new one mounts.\n\t\t\t\t// This ensures we always have the latest reference.\n\t\t\t\tif ( node ) {\n\t\t\t\t\tcommentSidebarRef.current = node;\n\t\t\t\t}\n\t\t\t} }\n\t\t>\n\t\t\t<Comments\n\t\t\t\tthreads={ comments }\n\t\t\t\tonEditComment={ onEdit }\n\t\t\t\tonAddReply={ onCreate }\n\t\t\t\tonCommentDelete={ onDelete }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\tcommentSidebarRef={ commentSidebarRef }\n\t\t\t\treflowComments={ reflowComments }\n\t\t\t\tcommentLastUpdated={ commentLastUpdated }\n\t\t\t\tisFloating={ isFloating }\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n\nfunction NotesSidebar( { postId, mode } ) {\n\tconst [ showCommentBoard, setShowCommentBoard ] = useState( false );\n\tconst { getActiveComplementaryArea } = useSelect( interfaceStore );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst commentSidebarRef = useRef( null );\n\n\tconst showFloatingSidebar = isLargeViewport && mode === 'post-only';\n\n\tconst blockCommentId = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\t\tselect( blockEditorStore );\n\t\tconst
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __experimentalVStack as VStack } from '@wordpress/components';\nimport { useState, useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { comment as commentIcon } from '@wordpress/icons';\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 {\n\tcollabHistorySidebarName,\n\tcollabSidebarName,\n\tSIDEBARS,\n} from './constants';\nimport { Comments } from './comments';\nimport { store as editorStore } from '../../store';\nimport AddCommentMenuItem from './comment-menu-item';\nimport CommentAvatarIndicator from './comment-indicator-toolbar';\nimport { useGlobalStylesContext } from '../global-styles-provider';\nimport {\n\tuseBlockComments,\n\tuseBlockCommentsActions,\n\tuseEnableFloatingSidebar,\n} from './hooks';\nimport { focusCommentThread } from './utils';\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport { unlock } from '../../lock-unlock';\n\nfunction NotesSidebarContent( {\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tstyles,\n\tcomments,\n\tcommentSidebarRef,\n\treflowComments,\n\tcommentLastUpdated,\n\tisFloating = false,\n} ) {\n\tconst { onCreate, onEdit, onDelete } =\n\t\tuseBlockCommentsActions( reflowComments );\n\n\treturn (\n\t\t<VStack\n\t\t\tclassName=\"editor-collab-sidebar-panel\"\n\t\t\tstyle={ styles }\n\t\t\trole=\"list\"\n\t\t\tspacing=\"3\"\n\t\t\tjustify=\"flex-start\"\n\t\t\tref={ ( node ) => {\n\t\t\t\t// Sometimes previous sidebar unmounts after the new one mounts.\n\t\t\t\t// This ensures we always have the latest reference.\n\t\t\t\tif ( node ) {\n\t\t\t\t\tcommentSidebarRef.current = node;\n\t\t\t\t}\n\t\t\t} }\n\t\t>\n\t\t\t<Comments\n\t\t\t\tthreads={ comments }\n\t\t\t\tonEditComment={ onEdit }\n\t\t\t\tonAddReply={ onCreate }\n\t\t\t\tonCommentDelete={ onDelete }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\tcommentSidebarRef={ commentSidebarRef }\n\t\t\t\treflowComments={ reflowComments }\n\t\t\t\tcommentLastUpdated={ commentLastUpdated }\n\t\t\t\tisFloating={ isFloating }\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n\nfunction NotesSidebar( { postId, mode } ) {\n\tconst [ showCommentBoard, setShowCommentBoard ] = useState( false );\n\tconst { getActiveComplementaryArea } = useSelect( interfaceStore );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst { toggleBlockSpotlight } = unlock( useDispatch( blockEditorStore ) );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst commentSidebarRef = useRef( null );\n\n\tconst showFloatingSidebar = isLargeViewport && mode === 'post-only';\n\n\tconst { clientId, blockCommentId } = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\t\tselect( blockEditorStore );\n\t\tconst _clientId = getSelectedBlockClientId();\n\t\treturn {\n\t\t\tclientId: _clientId,\n\t\t\tblockCommentId: _clientId\n\t\t\t\t? getBlockAttributes( _clientId )?.metadata?.noteId\n\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst {\n\t\tresultComments,\n\t\tunresolvedSortedThreads,\n\t\treflowComments,\n\t\tcommentLastUpdated,\n\t} = useBlockComments( postId );\n\tuseEnableFloatingSidebar(\n\t\tshowFloatingSidebar &&\n\t\t\t( unresolvedSortedThreads.length > 0 || showCommentBoard )\n\t);\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\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\tasync function openTheSidebar() {\n\t\tconst prevArea = await getActiveComplementaryArea( 'core' );\n\t\tconst activeNotesArea = SIDEBARS.find( ( name ) => name === prevArea );\n\n\t\tif ( currentThread?.status === 'approved' ) {\n\t\t\tenableComplementaryArea( 'core', collabHistorySidebarName );\n\t\t} else if ( ! activeNotesArea ) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core',\n\t\t\t\tshowFloatingSidebar\n\t\t\t\t\t? collabSidebarName\n\t\t\t\t\t: collabHistorySidebarName\n\t\t\t);\n\t\t}\n\n\t\tconst currentArea = await getActiveComplementaryArea( 'core' );\n\t\t// Bail out if the current active area is not one of note sidebars.\n\t\tif ( ! SIDEBARS.includes( currentArea ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetShowCommentBoard( ! blockCommentId );\n\t\tfocusCommentThread(\n\t\t\tblockCommentId,\n\t\t\tcommentSidebarRef.current,\n\t\t\t// Focus a comment thread when there's a selected block with a comment.\n\t\t\t! blockCommentId ? 'textarea' : undefined\n\t\t);\n\t\ttoggleBlockSpotlight( clientId, true );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ blockCommentId && (\n\t\t\t\t<CommentAvatarIndicator\n\t\t\t\t\tthread={ currentThread }\n\t\t\t\t\tonClick={ openTheSidebar }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<AddCommentMenuItem onClick={ openTheSidebar } />\n\t\t\t<PluginSidebar\n\t\t\t\tidentifier={ collabHistorySidebarName }\n\t\t\t\tname={ collabHistorySidebarName }\n\t\t\t\ttitle={ __( 'All notes' ) }\n\t\t\t\theader={\n\t\t\t\t\t<h2 className=\"interface-complementary-area-header__title\">\n\t\t\t\t\t\t{ __( 'All notes' ) }\n\t\t\t\t\t</h2>\n\t\t\t\t}\n\t\t\t\ticon={ commentIcon }\n\t\t\t\tcloseLabel={ __( 'Close Notes' ) }\n\t\t\t>\n\t\t\t\t<NotesSidebarContent\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\tcommentSidebarRef={ commentSidebarRef }\n\t\t\t\t\treflowComments={ reflowComments }\n\t\t\t\t\tcommentLastUpdated={ commentLastUpdated }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t\t{ isLargeViewport && (\n\t\t\t\t<PluginSidebar\n\t\t\t\t\tisPinnable={ false }\n\t\t\t\t\theader={ false }\n\t\t\t\t\tidentifier={ collabSidebarName }\n\t\t\t\t\tclassName=\"editor-collab-sidebar\"\n\t\t\t\t\theaderClassName=\"editor-collab-sidebar__header\"\n\t\t\t\t\tbackgroundColor={ backgroundColor }\n\t\t\t\t>\n\t\t\t\t\t<NotesSidebarContent\n\t\t\t\t\t\tcomments={ unresolvedSortedThreads }\n\t\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\t\tcommentSidebarRef={ commentSidebarRef }\n\t\t\t\t\t\treflowComments={ reflowComments }\n\t\t\t\t\t\tcommentLastUpdated={ commentLastUpdated }\n\t\t\t\t\t\tstyles={ {\n\t\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisFloating\n\t\t\t\t\t/>\n\t\t\t\t</PluginSidebar>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default function NotesSidebarContainer() {\n\tconst { postId, mode, editorMode } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getRenderingMode, getEditorMode } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tmode: getRenderingMode(),\n\t\t\teditorMode: getEditorMode(),\n\t\t};\n\t}, [] );\n\n\tif ( ! postId || typeof postId !== 'number' ) {\n\t\treturn null;\n\t}\n\n\t// Hide Notes sidebar in Code Editor mode since block-level commenting.\n\tif ( editorMode === 'text' ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"editor.notes\">\n\t\t\t<NotesSidebar postId={ postId } mode={ mode } />\n\t\t</PostTypeSupportCheck>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+DG;AA5DH,kBAAmB;AACnB,kBAAuC;AACvC,wBAA+C;AAC/C,qBAAiC;AACjC,qBAAiC;AACjC,mBAAuC;AACvC,0BAA0C;AAC1C,uBAAwC;AAKxC,4BAA0B;AAC1B,uBAIO;AACP,sBAAyB;AACzB,mBAAqC;AACrC,+BAA+B;AAC/B,uCAAmC;AACnC,oCAAuC;AACvC,mBAIO;AACP,mBAAmC;AACnC,qCAAiC;AACjC,yBAAuB;AAEvB,SAAS,oBAAqB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AACd,GAAI;AACH,QAAM,EAAE,UAAU,QAAQ,SAAS,QAClC,sCAAyB,cAAe;AAEzC,SACC;AAAA,IAAC,kBAAAA;AAAA,IAAA;AAAA,MACA,WAAU;AAAA,MACV,OAAQ;AAAA,MACR,MAAK;AAAA,MACL,SAAQ;AAAA,MACR,SAAQ;AAAA,MACR,KAAM,CAAE,SAAU;AAGjB,YAAK,MAAO;AACX,4BAAkB,UAAU;AAAA,QAC7B;AAAA,MACD;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACA,SAAU;AAAA,UACV,eAAgB;AAAA,UAChB,YAAa;AAAA,UACb,iBAAkB;AAAA,UAClB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;AAEA,SAAS,aAAc,EAAE,QAAQ,KAAK,GAAI;AACzC,QAAM,CAAE,kBAAkB,mBAAoB,QAAI,yBAAU,KAAM;AAClE,QAAM,EAAE,2BAA2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AM,iBAAiB;AAAA,MACvB,YAAY,cAAc;AAAA,IAC3B;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,MAAK,CAAE,UAAU,OAAO,WAAW,UAAW;AAC7C,WAAO;AAAA,EACR;AAGA,MAAK,eAAe,QAAS;AAC5B,WAAO;AAAA,EACR;AAEA,SACC,4CAAC,+BAAAC,SAAA,EAAqB,aAAY,gBACjC,sDAAC,gBAAa,QAAkB,MAAc,GAC/C;AAEF;",
|
|
6
6
|
"names": ["VStack", "interfaceStore", "blockEditorStore", "CommentAvatarIndicator", "AddCommentMenuItem", "PluginSidebar", "commentIcon", "editorStore", "PostTypeSupportCheck"]
|
|
7
7
|
}
|