@wordpress/editor 14.44.0 → 14.44.1-next.v.202604201441.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/collab-sidebar/add-comment.cjs +6 -22
- package/build/components/collab-sidebar/add-comment.cjs.map +3 -3
- package/build/components/collab-sidebar/board-store.cjs +103 -0
- package/build/components/collab-sidebar/board-store.cjs.map +7 -0
- package/build/components/collab-sidebar/comment-form.cjs +2 -10
- package/build/components/collab-sidebar/comment-form.cjs.map +2 -2
- package/build/components/collab-sidebar/comments.cjs +29 -149
- package/build/components/collab-sidebar/comments.cjs.map +3 -3
- package/build/components/collab-sidebar/floating-container.cjs +62 -0
- package/build/components/collab-sidebar/floating-container.cjs.map +7 -0
- package/build/components/collab-sidebar/hooks.cjs +49 -41
- package/build/components/collab-sidebar/hooks.cjs.map +2 -2
- package/build/components/collab-sidebar/index.cjs +2 -13
- package/build/components/collab-sidebar/index.cjs.map +2 -2
- package/build/components/collab-sidebar/utils.cjs +72 -4
- package/build/components/collab-sidebar/utils.cjs.map +2 -2
- package/build/components/collaborators-presence/avatar/component.cjs.map +1 -1
- package/build/components/collaborators-presence/index.cjs +3 -3
- package/build/components/collaborators-presence/index.cjs.map +2 -2
- package/build/components/collaborators-presence/list.cjs +3 -3
- package/build/components/collaborators-presence/list.cjs.map +2 -2
- package/build/components/media-categories/index.cjs +1 -1
- package/build/components/media-categories/index.cjs.map +1 -1
- package/build/components/more-menu/index.cjs +1 -1
- package/build/components/more-menu/index.cjs.map +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.cjs +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.cjs.map +1 -1
- package/build/components/style-book/constants.cjs +1 -1
- package/build/components/style-book/constants.cjs.map +1 -1
- package/build/components/style-book/index.cjs +1 -1
- package/build/components/style-book/index.cjs.map +1 -1
- package/build-module/components/collab-sidebar/add-comment.mjs +8 -27
- package/build-module/components/collab-sidebar/add-comment.mjs.map +2 -2
- package/build-module/components/collab-sidebar/board-store.mjs +78 -0
- package/build-module/components/collab-sidebar/board-store.mjs.map +7 -0
- package/build-module/components/collab-sidebar/comment-form.mjs +4 -12
- package/build-module/components/collab-sidebar/comment-form.mjs.map +2 -2
- package/build-module/components/collab-sidebar/comments.mjs +30 -151
- package/build-module/components/collab-sidebar/comments.mjs.map +2 -2
- package/build-module/components/collab-sidebar/floating-container.mjs +27 -0
- package/build-module/components/collab-sidebar/floating-container.mjs.map +7 -0
- package/build-module/components/collab-sidebar/hooks.mjs +51 -44
- package/build-module/components/collab-sidebar/hooks.mjs.map +2 -2
- package/build-module/components/collab-sidebar/index.mjs +2 -13
- package/build-module/components/collab-sidebar/index.mjs.map +2 -2
- package/build-module/components/collab-sidebar/utils.mjs +71 -3
- package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
- package/build-module/components/collaborators-presence/avatar/component.mjs.map +1 -1
- package/build-module/components/collaborators-presence/index.mjs +3 -3
- package/build-module/components/collaborators-presence/index.mjs.map +2 -2
- package/build-module/components/collaborators-presence/list.mjs +3 -3
- package/build-module/components/collaborators-presence/list.mjs.map +2 -2
- package/build-module/components/media-categories/index.mjs +1 -1
- package/build-module/components/media-categories/index.mjs.map +1 -1
- package/build-module/components/more-menu/index.mjs +1 -1
- package/build-module/components/more-menu/index.mjs.map +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.mjs +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.mjs.map +1 -1
- package/build-module/components/style-book/constants.mjs +1 -1
- package/build-module/components/style-book/constants.mjs.map +1 -1
- package/build-module/components/style-book/index.mjs +1 -1
- package/build-module/components/style-book/index.mjs.map +1 -1
- package/build-style/style-rtl.css +12 -30
- package/build-style/style.css +12 -30
- package/build-types/components/collab-sidebar/add-comment.d.ts +2 -6
- package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/board-store.d.ts +8 -0
- package/build-types/components/collab-sidebar/board-store.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/comment-form.d.ts +1 -3
- package/build-types/components/collab-sidebar/comment-form.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comments.d.ts +1 -3
- package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/floating-container.d.ts +8 -0
- package/build-types/components/collab-sidebar/floating-container.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/hooks.d.ts +13 -9
- package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/utils.d.ts +27 -4
- package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
- package/build-types/components/style-book/constants.d.ts +1 -1
- package/build-types/components/style-book/constants.d.ts.map +1 -1
- package/package.json +45 -45
- package/src/components/collab-sidebar/add-comment.js +9 -31
- package/src/components/collab-sidebar/board-store.js +83 -0
- package/src/components/collab-sidebar/comment-form.js +5 -14
- package/src/components/collab-sidebar/comments.js +29 -202
- package/src/components/collab-sidebar/floating-container.js +29 -0
- package/src/components/collab-sidebar/hooks.js +60 -48
- package/src/components/collab-sidebar/index.js +3 -14
- package/src/components/collab-sidebar/test/utils.js +153 -0
- package/src/components/collab-sidebar/utils.js +112 -4
- package/src/components/collaborators-presence/avatar/component.tsx +1 -1
- package/src/components/collaborators-presence/styles/collaborators-list.scss +1 -1
- package/src/components/collaborators-presence/styles/collaborators-presence.scss +1 -1
- package/src/components/document-outline/style.scss +1 -1
- package/src/components/media-categories/index.js +1 -1
- package/src/components/more-menu/index.js +1 -1
- package/src/components/post-publish-panel/maybe-upload-media.js +1 -1
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
- package/src/components/post-revisions-preview/style.scss +1 -1
- package/src/components/style-book/constants.ts +1 -1
- package/src/components/style-book/index.js +1 -1
- package/src/components/template-actions-panel/style.scss +1 -1
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from "@floating-ui/react-dom";
|
|
7
7
|
import { __ } from "@wordpress/i18n";
|
|
8
8
|
import {
|
|
9
|
+
useState,
|
|
9
10
|
useEffect,
|
|
10
11
|
useMemo,
|
|
11
|
-
|
|
12
|
-
useReducer
|
|
12
|
+
useSyncExternalStore
|
|
13
13
|
} from "@wordpress/element";
|
|
14
14
|
import { useEntityRecords, store as coreStore } from "@wordpress/core-data";
|
|
15
15
|
import { useDispatch, useRegistry, useSelect } from "@wordpress/data";
|
|
@@ -23,13 +23,10 @@ import { store as interfaceStore } from "@wordpress/interface";
|
|
|
23
23
|
import { store as editorStore } from "../../store/index.mjs";
|
|
24
24
|
import { FLOATING_NOTES_SIDEBAR } from "./constants.mjs";
|
|
25
25
|
import { unlock } from "../../lock-unlock.mjs";
|
|
26
|
-
import {
|
|
26
|
+
import { createBoardStore } from "./board-store.mjs";
|
|
27
|
+
import { calculateAllOffsets } from "./utils.mjs";
|
|
27
28
|
var { useBlockElement, cleanEmptyObject } = unlock(blockEditorPrivateApis);
|
|
28
29
|
function useBlockComments(postId) {
|
|
29
|
-
const [commentLastUpdated, reflowComments] = useReducer(
|
|
30
|
-
() => Date.now(),
|
|
31
|
-
0
|
|
32
|
-
);
|
|
33
30
|
const queryArgs = {
|
|
34
31
|
post: postId,
|
|
35
32
|
type: "note",
|
|
@@ -117,12 +114,10 @@ function useBlockComments(postId) {
|
|
|
117
114
|
}, [clientIds, threads, getBlockAttributes]);
|
|
118
115
|
return {
|
|
119
116
|
resultComments,
|
|
120
|
-
unresolvedSortedThreads
|
|
121
|
-
reflowComments,
|
|
122
|
-
commentLastUpdated
|
|
117
|
+
unresolvedSortedThreads
|
|
123
118
|
};
|
|
124
119
|
}
|
|
125
|
-
function useBlockCommentsActions(
|
|
120
|
+
function useBlockCommentsActions() {
|
|
126
121
|
const { createNotice } = useDispatch(noticesStore);
|
|
127
122
|
const { saveEntityRecord, deleteEntityRecord } = useDispatch(coreStore);
|
|
128
123
|
const { getCurrentPostId } = useSelect(editorStore);
|
|
@@ -167,10 +162,8 @@ function useBlockCommentsActions(reflowComments = noop) {
|
|
|
167
162
|
isDismissible: true
|
|
168
163
|
}
|
|
169
164
|
);
|
|
170
|
-
setTimeout(reflowComments, 300);
|
|
171
165
|
return savedRecord;
|
|
172
166
|
} catch (error) {
|
|
173
|
-
reflowComments();
|
|
174
167
|
onError(error);
|
|
175
168
|
}
|
|
176
169
|
};
|
|
@@ -226,9 +219,7 @@ function useBlockCommentsActions(reflowComments = noop) {
|
|
|
226
219
|
isDismissible: true
|
|
227
220
|
}
|
|
228
221
|
);
|
|
229
|
-
reflowComments();
|
|
230
222
|
} catch (error) {
|
|
231
|
-
reflowComments();
|
|
232
223
|
onError(error);
|
|
233
224
|
}
|
|
234
225
|
};
|
|
@@ -257,9 +248,7 @@ function useBlockCommentsActions(reflowComments = noop) {
|
|
|
257
248
|
type: "snackbar",
|
|
258
249
|
isDismissible: true
|
|
259
250
|
});
|
|
260
|
-
reflowComments();
|
|
261
251
|
} catch (error) {
|
|
262
|
-
reflowComments();
|
|
263
252
|
onError(error);
|
|
264
253
|
}
|
|
265
254
|
};
|
|
@@ -286,26 +275,47 @@ function useEnableFloatingSidebar(enabled = false) {
|
|
|
286
275
|
};
|
|
287
276
|
}, [enabled, registry]);
|
|
288
277
|
}
|
|
278
|
+
function useFloatingBoard({ threads, selectedNoteId, isFloating }) {
|
|
279
|
+
const [boardOffsets, setBoardOffsets] = useState({});
|
|
280
|
+
const [store] = useState(createBoardStore);
|
|
281
|
+
const { setCanvasMinHeight } = unlock(useDispatch(editorStore));
|
|
282
|
+
const heights = useSyncExternalStore(store.subscribe, store.getSnapshot);
|
|
283
|
+
useEffect(() => {
|
|
284
|
+
if (!isFloating) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const rafId = window.requestAnimationFrame(() => {
|
|
288
|
+
const { offsets, minHeight } = calculateAllOffsets({
|
|
289
|
+
threads,
|
|
290
|
+
selectedNoteId,
|
|
291
|
+
blockRects: store.getBlockRects(),
|
|
292
|
+
heights
|
|
293
|
+
});
|
|
294
|
+
setBoardOffsets(offsets);
|
|
295
|
+
setCanvasMinHeight(minHeight);
|
|
296
|
+
});
|
|
297
|
+
return () => window.cancelAnimationFrame(rafId);
|
|
298
|
+
}, [
|
|
299
|
+
heights,
|
|
300
|
+
isFloating,
|
|
301
|
+
selectedNoteId,
|
|
302
|
+
setCanvasMinHeight,
|
|
303
|
+
store,
|
|
304
|
+
threads
|
|
305
|
+
]);
|
|
306
|
+
return {
|
|
307
|
+
boardOffsets,
|
|
308
|
+
registerThread: store.registerThread,
|
|
309
|
+
unregisterThread: store.unregisterThread
|
|
310
|
+
};
|
|
311
|
+
}
|
|
289
312
|
function useFloatingThread({
|
|
290
313
|
thread,
|
|
291
314
|
calculatedOffset,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
setBlockRef,
|
|
295
|
-
commentLastUpdated
|
|
315
|
+
registerThread,
|
|
316
|
+
unregisterThread
|
|
296
317
|
}) {
|
|
297
318
|
const blockElement = useBlockElement(thread.blockClientId);
|
|
298
|
-
const updateHeight = useCallback(
|
|
299
|
-
(id, newHeight) => {
|
|
300
|
-
setHeights((prev) => {
|
|
301
|
-
if (prev[id] !== newHeight) {
|
|
302
|
-
return { ...prev, [id]: newHeight };
|
|
303
|
-
}
|
|
304
|
-
return prev;
|
|
305
|
-
});
|
|
306
|
-
},
|
|
307
|
-
[setHeights]
|
|
308
|
-
);
|
|
309
319
|
const { y, refs } = useFloating({
|
|
310
320
|
placement: "right-start",
|
|
311
321
|
middleware: [
|
|
@@ -319,23 +329,19 @@ function useFloatingThread({
|
|
|
319
329
|
if (blockElement) {
|
|
320
330
|
refs.setReference(blockElement);
|
|
321
331
|
}
|
|
322
|
-
}, [blockElement, refs
|
|
323
|
-
useEffect(() => {
|
|
324
|
-
if (refs.floating?.current) {
|
|
325
|
-
setBlockRef(thread.id, blockElement);
|
|
326
|
-
}
|
|
327
|
-
}, [blockElement, thread.id, refs.floating, setBlockRef]);
|
|
332
|
+
}, [blockElement, refs]);
|
|
328
333
|
useEffect(() => {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
334
|
+
const floatingEl = refs.floating?.current;
|
|
335
|
+
if (floatingEl && registerThread) {
|
|
336
|
+
registerThread(thread.id, blockElement, floatingEl);
|
|
332
337
|
}
|
|
338
|
+
return () => unregisterThread?.(thread.id);
|
|
333
339
|
}, [
|
|
340
|
+
blockElement,
|
|
334
341
|
thread.id,
|
|
335
|
-
updateHeight,
|
|
336
342
|
refs.floating,
|
|
337
|
-
|
|
338
|
-
|
|
343
|
+
registerThread,
|
|
344
|
+
unregisterThread
|
|
339
345
|
]);
|
|
340
346
|
return {
|
|
341
347
|
y,
|
|
@@ -346,6 +352,7 @@ export {
|
|
|
346
352
|
useBlockComments,
|
|
347
353
|
useBlockCommentsActions,
|
|
348
354
|
useEnableFloatingSidebar,
|
|
355
|
+
useFloatingBoard,
|
|
349
356
|
useFloatingThread
|
|
350
357
|
};
|
|
351
358
|
//# sourceMappingURL=hooks.mjs.map
|
|
@@ -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\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 { FLOATING_NOTES_SIDEBAR } from './constants';\nimport { unlock } from '../../lock-unlock';\nimport { noop } from './utils';\n\nconst { useBlockElement, cleanEmptyObject } = unlock( blockEditorPrivateApis );\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// Create a reverse map for faster lookup.\n\t\tconst commentIdToBlockClientId = Object.keys(\n\t\t\tblocksWithComments\n\t\t).reduce( ( mapping, clientId ) => {\n\t\t\tmapping[ blocksWithComments[ clientId ] ] = clientId;\n\t\t\treturn mapping;\n\t\t}, {} );\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 = commentIdToBlockClientId[ item.id ];\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', FLOATING_NOTES_SIDEBAR );\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tunsubscribe();\n\t\t\tif (\n\t\t\t\tgetActiveComplementaryArea( 'core' ) === FLOATING_NOTES_SIDEBAR\n\t\t\t) {\n\t\t\t\tdisableComplementaryArea( 'core', FLOATING_NOTES_SIDEBAR );\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 blockElement = useBlockElement( thread.blockClientId );\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 ( blockElement ) {\n\t\t\trefs.setReference( blockElement );\n\t\t}\n\t}, [ blockElement, refs, commentLastUpdated ] );\n\n\t// Track thread heights.\n\tuseEffect( () => {\n\t\tif ( refs.floating?.current ) {\n\t\t\tsetBlockRef( thread.id, blockElement );\n\t\t}\n\t}, [ blockElement, 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\ty,\n\t\trefs,\n\t};\n}\n"],
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA,UAAU;AAAA,EACV;AAAA,OACM;AAKP,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,kBAAkB,SAAS,iBAAiB;AACrD,SAAS,aAAa,aAAa,iBAAiB;AACpD;AAAA,EACC,SAAS;AAAA,EACT,eAAe;AAAA,OACT;AACP,SAAS,SAAS,oBAAoB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,SAAS,sBAAsB;AAKxC,SAAS,SAAS,mBAAmB;AACrC,SAAS,8BAA8B;AACvC,SAAS,cAAc;AACvB,SAAS,
|
|
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\tuseState,\n\tuseEffect,\n\tuseMemo,\n\tuseSyncExternalStore,\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 { FLOATING_NOTES_SIDEBAR } from './constants';\nimport { unlock } from '../../lock-unlock';\nimport { createBoardStore } from './board-store';\nimport { calculateAllOffsets } from './utils';\n\nconst { useBlockElement, cleanEmptyObject } = unlock( blockEditorPrivateApis );\n\nexport function useBlockComments( postId ) {\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// Create a reverse map for faster lookup.\n\t\tconst commentIdToBlockClientId = Object.keys(\n\t\t\tblocksWithComments\n\t\t).reduce( ( mapping, clientId ) => {\n\t\t\tmapping[ blocksWithComments[ clientId ] ] = clientId;\n\t\t\treturn mapping;\n\t\t}, {} );\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 = commentIdToBlockClientId[ item.id ];\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};\n}\n\nexport function useBlockCommentsActions() {\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\treturn savedRecord;\n\t\t} catch ( error ) {\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} catch ( error ) {\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} catch ( error ) {\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', FLOATING_NOTES_SIDEBAR );\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tunsubscribe();\n\t\t\tif (\n\t\t\t\tgetActiveComplementaryArea( 'core' ) === FLOATING_NOTES_SIDEBAR\n\t\t\t) {\n\t\t\t\tdisableComplementaryArea( 'core', FLOATING_NOTES_SIDEBAR );\n\t\t\t}\n\t\t};\n\t}, [ enabled, registry ] );\n}\n\nexport function useFloatingBoard( { threads, selectedNoteId, isFloating } ) {\n\tconst [ boardOffsets, setBoardOffsets ] = useState( {} );\n\tconst [ store ] = useState( createBoardStore );\n\tconst { setCanvasMinHeight } = unlock( useDispatch( editorStore ) );\n\n\tconst heights = useSyncExternalStore( store.subscribe, store.getSnapshot );\n\n\t// Recalc is deferred to a rAF; the cleanup cancels the pending frame\n\t// when deps change, so back-to-back updates collapse into one paint.\n\tuseEffect( () => {\n\t\tif ( ! isFloating ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst rafId = window.requestAnimationFrame( () => {\n\t\t\tconst { offsets, minHeight } = calculateAllOffsets( {\n\t\t\t\tthreads,\n\t\t\t\tselectedNoteId,\n\t\t\t\tblockRects: store.getBlockRects(),\n\t\t\t\theights,\n\t\t\t} );\n\t\t\tsetBoardOffsets( offsets );\n\t\t\tsetCanvasMinHeight( minHeight );\n\t\t} );\n\n\t\treturn () => window.cancelAnimationFrame( rafId );\n\t}, [\n\t\theights,\n\t\tisFloating,\n\t\tselectedNoteId,\n\t\tsetCanvasMinHeight,\n\t\tstore,\n\t\tthreads,\n\t] );\n\n\treturn {\n\t\tboardOffsets,\n\t\tregisterThread: store.registerThread,\n\t\tunregisterThread: store.unregisterThread,\n\t};\n}\n\nexport function useFloatingThread( {\n\tthread,\n\tcalculatedOffset,\n\tregisterThread,\n\tunregisterThread,\n} ) {\n\tconst blockElement = useBlockElement( thread.blockClientId );\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// Set the floating-ui reference element.\n\tuseEffect( () => {\n\t\tif ( blockElement ) {\n\t\t\trefs.setReference( blockElement );\n\t\t}\n\t}, [ blockElement, refs ] );\n\n\t// Register block + floating elements with the board.\n\t// The board's ResizeObserver tracks height changes automatically.\n\tuseEffect( () => {\n\t\tconst floatingEl = refs.floating?.current;\n\t\tif ( floatingEl && registerThread ) {\n\t\t\tregisterThread( thread.id, blockElement, floatingEl );\n\t\t}\n\t\treturn () => unregisterThread?.( thread.id );\n\t}, [\n\t\tblockElement,\n\t\tthread.id,\n\t\trefs.floating,\n\t\tregisterThread,\n\t\tunregisterThread,\n\t] );\n\n\treturn {\n\t\ty,\n\t\trefs,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA,UAAU;AAAA,EACV;AAAA,OACM;AAKP,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,kBAAkB,SAAS,iBAAiB;AACrD,SAAS,aAAa,aAAa,iBAAiB;AACpD;AAAA,EACC,SAAS;AAAA,EACT,eAAe;AAAA,OACT;AACP,SAAS,SAAS,oBAAoB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,SAAS,sBAAsB;AAKxC,SAAS,SAAS,mBAAmB;AACrC,SAAS,8BAA8B;AACvC,SAAS,cAAc;AACvB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,cAAc,UAAW;AAAA,IACrD;AACA,WAAO,MAAM,mBAAoB,OAAO,EAAG;AAAA,EAC5C,GAAG;AAAA,IACF;AAAA,IACA,OAAO;AAAA,IACP,KAAK;AAAA,IACL;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SAAO;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -32,11 +32,9 @@ function NotesSidebarContent({
|
|
|
32
32
|
styles,
|
|
33
33
|
comments,
|
|
34
34
|
commentSidebarRef,
|
|
35
|
-
reflowComments,
|
|
36
|
-
commentLastUpdated,
|
|
37
35
|
isFloating = false
|
|
38
36
|
}) {
|
|
39
|
-
const { onCreate, onEdit, onDelete } = useBlockCommentsActions(
|
|
37
|
+
const { onCreate, onEdit, onDelete } = useBlockCommentsActions();
|
|
40
38
|
return /* @__PURE__ */ jsx(
|
|
41
39
|
VStack,
|
|
42
40
|
{
|
|
@@ -59,8 +57,6 @@ function NotesSidebarContent({
|
|
|
59
57
|
onAddReply: onCreate,
|
|
60
58
|
onCommentDelete: onDelete,
|
|
61
59
|
commentSidebarRef,
|
|
62
|
-
reflowComments,
|
|
63
|
-
commentLastUpdated,
|
|
64
60
|
isFloating
|
|
65
61
|
}
|
|
66
62
|
)
|
|
@@ -102,12 +98,7 @@ function NotesSidebar({ postId }) {
|
|
|
102
98
|
(select) => unlock(select(editorStore)).getSelectedNote(),
|
|
103
99
|
[]
|
|
104
100
|
);
|
|
105
|
-
const {
|
|
106
|
-
resultComments,
|
|
107
|
-
unresolvedSortedThreads,
|
|
108
|
-
reflowComments,
|
|
109
|
-
commentLastUpdated
|
|
110
|
-
} = useBlockComments(postId);
|
|
101
|
+
const { resultComments, unresolvedSortedThreads } = useBlockComments(postId);
|
|
111
102
|
const showFloatingSidebar = isLargeViewport;
|
|
112
103
|
const showAllNotesSidebar = resultComments.length > 0 || !showFloatingSidebar;
|
|
113
104
|
useEnableFloatingSidebar(
|
|
@@ -195,8 +186,6 @@ function NotesSidebar({ postId }) {
|
|
|
195
186
|
{
|
|
196
187
|
comments: unresolvedSortedThreads,
|
|
197
188
|
commentSidebarRef,
|
|
198
|
-
reflowComments,
|
|
199
|
-
commentLastUpdated,
|
|
200
189
|
styles: {
|
|
201
190
|
backgroundColor
|
|
202
191
|
},
|
|
@@ -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 { useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport PluginSidebar from '../plugin-sidebar';\nimport {\n\tALL_NOTES_SIDEBAR,\n\tFLOATING_NOTES_SIDEBAR,\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 PostTypeSupportCheck from '../post-type-support-check';\nimport { unlock } from '../../lock-unlock';\n\nfunction NotesSidebarContent( {\n\tstyles,\n\tcomments,\n\tcommentSidebarRef,\n\
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,WAAW,mBAAmB;AACvC,SAAS,wBAAwB,cAAc;AAC/C,SAAS,cAAc;AACvB,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,WAAW,mBAAmB;AACvC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,SAAS,sBAAsB;AACxC,SAAS,SAAS,wBAAwB;AAK1C,OAAO,mBAAmB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,gBAAgB;AACzB,SAAS,SAAS,mBAAmB;AACrC,OAAO,wBAAwB;AAC/B,OAAO,4BAA4B;AACnC,SAAS,8BAA8B;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,OAAO,0BAA0B;AACjC,SAAS,cAAc;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __experimentalVStack as VStack } from '@wordpress/components';\nimport { useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport PluginSidebar from '../plugin-sidebar';\nimport {\n\tALL_NOTES_SIDEBAR,\n\tFLOATING_NOTES_SIDEBAR,\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 PostTypeSupportCheck from '../post-type-support-check';\nimport { unlock } from '../../lock-unlock';\n\nfunction NotesSidebarContent( {\n\tstyles,\n\tcomments,\n\tcommentSidebarRef,\n\tisFloating = false,\n} ) {\n\tconst { onCreate, onEdit, onDelete } = useBlockCommentsActions();\n\n\treturn (\n\t\t<VStack\n\t\t\tclassName=\"editor-collab-sidebar-panel\"\n\t\t\tstyle={ styles }\n\t\t\trole=\"tree\"\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\t// eslint-disable-next-line react-compiler/react-compiler\n\t\t\t\t\tcommentSidebarRef.current = node;\n\t\t\t\t}\n\t\t\t} }\n\t\t\taria-label={\n\t\t\t\tisFloating ? __( 'Unresolved notes' ) : __( 'All notes' )\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\tcommentSidebarRef={ commentSidebarRef }\n\t\t\t\tisFloating={ isFloating }\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n\nfunction NotesSidebar( { postId } ) {\n\tconst { getActiveComplementaryArea } = useSelect( interfaceStore );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst { toggleBlockSpotlight, selectBlock } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tconst { selectNote } = unlock( useDispatch( editorStore ) );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst commentSidebarRef = useRef( null );\n\n\tconst { clientId, blockCommentId, isClassicBlock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockName,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst _clientId = getSelectedBlockClientId();\n\t\t\treturn {\n\t\t\t\tclientId: _clientId,\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\tisClassicBlock: _clientId\n\t\t\t\t\t? getBlockName( _clientId ) === 'core/freeform'\n\t\t\t\t\t: false,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { isDistractionFree } = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\treturn {\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t};\n\t}, [] );\n\tconst selectedNote = useSelect(\n\t\t( select ) => unlock( select( editorStore ) ).getSelectedNote(),\n\t\t[]\n\t);\n\n\tconst { resultComments, unresolvedSortedThreads } =\n\t\tuseBlockComments( postId );\n\n\t// Only enable the floating sidebar for large viewports.\n\tconst showFloatingSidebar = isLargeViewport;\n\t// Fallback to \"All notes\" sidebar on smaller viewports.\n\tconst showAllNotesSidebar =\n\t\tresultComments.length > 0 || ! showFloatingSidebar;\n\tuseEnableFloatingSidebar(\n\t\tshowFloatingSidebar &&\n\t\t\t( unresolvedSortedThreads.length > 0 || selectedNote !== undefined )\n\t);\n\n\tuseShortcut(\n\t\t'core/editor/new-note',\n\t\t( event ) => {\n\t\t\tevent.preventDefault();\n\t\t\topenTheSidebar();\n\t\t},\n\t\t{\n\t\t\t// When multiple notes per block are supported. Remove note ID check.\n\t\t\t// See: https://github.com/WordPress/gutenberg/pull/75147.\n\t\t\tisDisabled:\n\t\t\t\tisDistractionFree ||\n\t\t\t\tisClassicBlock ||\n\t\t\t\t! clientId ||\n\t\t\t\t!! blockCommentId,\n\t\t}\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( selectedClientId ) {\n\t\tconst prevArea = await getActiveComplementaryArea( 'core' );\n\t\tconst activeNotesArea = SIDEBARS.find( ( name ) => name === prevArea );\n\t\tconst targetClientId =\n\t\t\tselectedClientId && selectedClientId !== clientId\n\t\t\t\t? selectedClientId\n\t\t\t\t: clientId;\n\t\tconst targetNote = resultComments.find(\n\t\t\t( note ) => note.blockClientId === targetClientId\n\t\t);\n\n\t\tif ( targetNote?.status === 'approved' ) {\n\t\t\tenableComplementaryArea( 'core', ALL_NOTES_SIDEBAR );\n\t\t} else if ( ! activeNotesArea || ! showAllNotesSidebar ) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core',\n\t\t\t\tshowFloatingSidebar ? FLOATING_NOTES_SIDEBAR : ALL_NOTES_SIDEBAR\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\t// A special case for the List View, where block selection isn't required to trigger an action.\n\t\t// The action won't do anything if the block is already selected.\n\t\tselectBlock( targetClientId, null );\n\t\ttoggleBlockSpotlight( targetClientId, true );\n\t\tselectNote( targetNote ? targetNote.id : 'new', { focus: true } );\n\t}\n\n\tif ( isDistractionFree ) {\n\t\treturn <AddCommentMenuItem isDistractionFree />;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ !! currentThread && (\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{ showAllNotesSidebar && (\n\t\t\t\t<PluginSidebar\n\t\t\t\t\tidentifier={ ALL_NOTES_SIDEBAR }\n\t\t\t\t\tname={ ALL_NOTES_SIDEBAR }\n\t\t\t\t\ttitle={ __( 'All notes' ) }\n\t\t\t\t\theader={\n\t\t\t\t\t\t<h2 className=\"interface-complementary-area-header__title\">\n\t\t\t\t\t\t\t{ __( 'All notes' ) }\n\t\t\t\t\t\t</h2>\n\t\t\t\t\t}\n\t\t\t\t\ticon={ commentIcon }\n\t\t\t\t\tcloseLabel={ __( 'Close Notes' ) }\n\t\t\t\t>\n\t\t\t\t\t<NotesSidebarContent\n\t\t\t\t\t\tcomments={ resultComments }\n\t\t\t\t\t\tcommentSidebarRef={ commentSidebarRef }\n\t\t\t\t\t/>\n\t\t\t\t</PluginSidebar>\n\t\t\t) }\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={ FLOATING_NOTES_SIDEBAR }\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\tcommentSidebarRef={ commentSidebarRef }\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, editorMode, revisionsMode } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getEditorMode, isRevisionsMode } = unlock(\n\t\t\tselect( editorStore )\n\t\t);\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\teditorMode: getEditorMode(),\n\t\t\trevisionsMode: isRevisionsMode(),\n\t\t};\n\t}, [] );\n\n\tif ( ! postId || typeof postId !== 'number' ) {\n\t\treturn null;\n\t}\n\n\t// Hide Notes sidebar for Code Editor and in-editor revision mode.\n\tif ( editorMode === 'text' || revisionsMode ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostTypeSupportChe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Q,GAAI,WAAY;AAAA,QACxB,QACC,oBAAC,QAAG,WAAU,8CACX,aAAI,WAAY,GACnB;AAAA,QAED,MAAO;AAAA,QACP,YAAa,GAAI,aAAc;AAAA,QAE/B;AAAA,UAAC;AAAA;AAAA,YACA,UAAW;AAAA,YACX;AAAA;AAAA,QACD;AAAA;AAAA,IACD;AAAA,IAEC,mBACD;AAAA,MAAC;AAAA;AAAA,QACA,YAAa;AAAA,QACb,QAAS;AAAA,QACT,YAAa;AAAA,QACb,WAAU;AAAA,QACV,iBAAgB;AAAA,QAChB;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACA,UAAW;AAAA,YACX;AAAA,YACA,QAAS;AAAA,cACR;AAAA,YACD;AAAA,YACA,YAAU;AAAA;AAAA,QACX;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;AAEe,SAAR,wBAAyC;AAC/C,QAAM,EAAE,QAAQ,YAAY,cAAc,IAAI,UAAW,CAAE,WAAY;AACtE,UAAM,EAAE,kBAAkB,eAAe,gBAAgB,IAAI;AAAA,MAC5D,OAAQ,WAAY;AAAA,IACrB;AACA,WAAO;AAAA,MACN,QAAQ,iBAAiB;AAAA,MACzB,YAAY,cAAc;AAAA,MAC1B,eAAe,gBAAgB;AAAA,IAChC;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,MAAK,CAAE,UAAU,OAAO,WAAW,UAAW;AAC7C,WAAO;AAAA,EACR;AAGA,MAAK,eAAe,UAAU,eAAgB;AAC7C,WAAO;AAAA,EACR;AAEA,SACC,oBAAC,wBAAqB,aAAY,gBACjC,8BAAC,gBAAa,QAAkB,GACjC;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,8 +3,10 @@ import { _x } from "@wordpress/i18n";
|
|
|
3
3
|
function sanitizeCommentString(str) {
|
|
4
4
|
return str.trim();
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
var THREAD_ALIGN_OFFSET = -16;
|
|
7
|
+
var THREAD_GAP = 16;
|
|
8
|
+
var OVERLAP_MARGIN = 20;
|
|
9
|
+
var BOARD_BOTTOM_PADDING = 32;
|
|
8
10
|
var AVATAR_BORDER_COLORS = [
|
|
9
11
|
"#C36EFF",
|
|
10
12
|
// Purple
|
|
@@ -43,6 +45,72 @@ function getCommentExcerpt(text, excerptLength = 10) {
|
|
|
43
45
|
const isTrimmed = trimmedExcerpt !== rawText;
|
|
44
46
|
return isTrimmed ? trimmedExcerpt + "\u2026" : trimmedExcerpt;
|
|
45
47
|
}
|
|
48
|
+
function calculateAllOffsets({
|
|
49
|
+
threads,
|
|
50
|
+
selectedNoteId,
|
|
51
|
+
blockRects,
|
|
52
|
+
heights
|
|
53
|
+
}) {
|
|
54
|
+
const offsets = {};
|
|
55
|
+
const anchorIndex = Math.max(
|
|
56
|
+
0,
|
|
57
|
+
threads.findIndex((thread) => thread.id === selectedNoteId)
|
|
58
|
+
);
|
|
59
|
+
const anchorThread = threads[anchorIndex];
|
|
60
|
+
if (!anchorThread || !blockRects[anchorThread.id]) {
|
|
61
|
+
return { offsets, minHeight: 0 };
|
|
62
|
+
}
|
|
63
|
+
const anchorRect = blockRects[anchorThread.id];
|
|
64
|
+
const anchorTop = anchorRect.top || 0;
|
|
65
|
+
const anchorHeight = heights[anchorThread.id] || 0;
|
|
66
|
+
offsets[anchorThread.id] = THREAD_ALIGN_OFFSET;
|
|
67
|
+
let prevAdjustedTop = anchorTop + THREAD_ALIGN_OFFSET;
|
|
68
|
+
let prevHeight = anchorHeight;
|
|
69
|
+
for (let i = anchorIndex + 1; i < threads.length; i++) {
|
|
70
|
+
const thread = threads[i];
|
|
71
|
+
const threadRect = blockRects[thread.id];
|
|
72
|
+
if (!threadRect) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const threadTop = threadRect.top || 0;
|
|
76
|
+
const threadHeight = heights[thread.id] || 0;
|
|
77
|
+
let offset = THREAD_ALIGN_OFFSET;
|
|
78
|
+
const prevBottom = prevAdjustedTop + prevHeight;
|
|
79
|
+
if (threadTop < prevBottom + THREAD_GAP) {
|
|
80
|
+
offset = prevBottom - threadTop + OVERLAP_MARGIN;
|
|
81
|
+
}
|
|
82
|
+
offsets[thread.id] = offset;
|
|
83
|
+
prevAdjustedTop = threadTop + offset;
|
|
84
|
+
prevHeight = threadHeight;
|
|
85
|
+
}
|
|
86
|
+
let belowAdjustedTop = anchorTop + THREAD_ALIGN_OFFSET;
|
|
87
|
+
for (let i = anchorIndex - 1; i >= 0; i--) {
|
|
88
|
+
const thread = threads[i];
|
|
89
|
+
const threadRect = blockRects[thread.id];
|
|
90
|
+
if (!threadRect) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const threadTop = threadRect.top || 0;
|
|
94
|
+
const threadHeight = heights[thread.id] || 0;
|
|
95
|
+
let offset = THREAD_ALIGN_OFFSET;
|
|
96
|
+
const threadBottom = threadTop + threadHeight;
|
|
97
|
+
if (threadBottom > belowAdjustedTop) {
|
|
98
|
+
offset = belowAdjustedTop - threadTop - threadHeight - OVERLAP_MARGIN;
|
|
99
|
+
}
|
|
100
|
+
offsets[thread.id] = offset;
|
|
101
|
+
belowAdjustedTop = threadTop + offset;
|
|
102
|
+
}
|
|
103
|
+
let editorMinHeight = 0;
|
|
104
|
+
const lastThread = threads[threads.length - 1];
|
|
105
|
+
const lastBlockRect = blockRects[lastThread.id];
|
|
106
|
+
if (lastBlockRect) {
|
|
107
|
+
const lastThreadTop = lastBlockRect.top || 0;
|
|
108
|
+
const lastThreadHeight = heights[lastThread.id] || 0;
|
|
109
|
+
const lastThreadOffset = offsets[lastThread.id] || 0;
|
|
110
|
+
editorMinHeight = lastThreadTop + lastThreadHeight + lastThreadOffset + BOARD_BOTTOM_PADDING;
|
|
111
|
+
}
|
|
112
|
+
return { offsets, minHeight: editorMinHeight };
|
|
113
|
+
}
|
|
46
114
|
function focusCommentThread(commentId, container, additionalSelector) {
|
|
47
115
|
if (!container) {
|
|
48
116
|
return;
|
|
@@ -72,10 +140,10 @@ function focusCommentThread(commentId, container, additionalSelector) {
|
|
|
72
140
|
}).then((element) => element?.focus());
|
|
73
141
|
}
|
|
74
142
|
export {
|
|
143
|
+
calculateAllOffsets,
|
|
75
144
|
focusCommentThread,
|
|
76
145
|
getAvatarBorderColor,
|
|
77
146
|
getCommentExcerpt,
|
|
78
|
-
noop,
|
|
79
147
|
sanitizeCommentString
|
|
80
148
|
};
|
|
81
149
|
//# sourceMappingURL=utils.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/collab-sidebar/utils.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Sanitizes a comment string by removing non-printable ASCII characters.\n *\n * @param {string} str - The comment string to sanitize.\n * @return {string} - The sanitized comment string.\n */\nexport function sanitizeCommentString( str ) {\n\treturn str.trim();\n}\n\
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AAQZ,SAAS,sBAAuB,KAAM;AAC5C,SAAO,IAAI,KAAK;AACjB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Sanitizes a comment string by removing non-printable ASCII characters.\n *\n * @param {string} str - The comment string to sanitize.\n * @return {string} - The sanitized comment string.\n */\nexport function sanitizeCommentString( str ) {\n\treturn str.trim();\n}\n\nconst THREAD_ALIGN_OFFSET = -16;\nconst THREAD_GAP = 16;\nconst OVERLAP_MARGIN = 20;\nconst BOARD_BOTTOM_PADDING = 32;\n\n/**\n * Avatar border colors chosen to be visually distinct from each other and from\n * the editor's semantic UI colors (Delta E > 10 between all pairs).\n */\nconst AVATAR_BORDER_COLORS = [\n\t'#C36EFF', // Purple\n\t'#FF51A8', // Pink\n\t'#E4780A', // Orange\n\t'#FF35EE', // Magenta\n\t'#879F11', // Olive\n\t'#46A494', // Teal\n\t'#00A2C3', // Cyan\n];\n\n/**\n * Gets the border color for an avatar based on the user ID.\n *\n * @param {number} userId - The user ID.\n * @return {string} - The border color.\n */\nexport function getAvatarBorderColor( userId ) {\n\treturn AVATAR_BORDER_COLORS[ userId % AVATAR_BORDER_COLORS.length ];\n}\n\n/**\n * Generates a comment excerpt from text based on word count type and length.\n *\n * @param {string} text - The comment text to generate excerpt from.\n * @param {number} excerptLength - The maximum length for the commentexcerpt.\n * @return {string} - The generated comment excerpt.\n */\nexport function getCommentExcerpt( text, excerptLength = 10 ) {\n\tif ( ! text ) {\n\t\treturn '';\n\t}\n\n\t/*\n\t * translators: If your word count is based on single characters (e.g. East Asian characters),\n\t * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.\n\t * Do not translate into your own language.\n\t */\n\tconst wordCountType = _x( 'words', 'Word count type. Do not translate!' );\n\n\tconst rawText = text.trim();\n\tlet trimmedExcerpt = '';\n\n\tif ( wordCountType === 'words' ) {\n\t\ttrimmedExcerpt = rawText.split( ' ', excerptLength ).join( ' ' );\n\t} else if ( wordCountType === 'characters_excluding_spaces' ) {\n\t\t/*\n\t\t * 1. Split the text at the character limit,\n\t\t * then join the substrings back into one string.\n\t\t * 2. Count the number of spaces in the text\n\t\t * by comparing the lengths of the string with and without spaces.\n\t\t * 3. Add the number to the length of the visible excerpt,\n\t\t * so that the spaces are excluded from the word count.\n\t\t */\n\t\tconst textWithSpaces = rawText.split( '', excerptLength ).join( '' );\n\n\t\tconst numberOfSpaces =\n\t\t\ttextWithSpaces.length - textWithSpaces.replaceAll( ' ', '' ).length;\n\n\t\ttrimmedExcerpt = rawText\n\t\t\t.split( '', excerptLength + numberOfSpaces )\n\t\t\t.join( '' );\n\t} else if ( wordCountType === 'characters_including_spaces' ) {\n\t\ttrimmedExcerpt = rawText.split( '', excerptLength ).join( '' );\n\t}\n\n\tconst isTrimmed = trimmedExcerpt !== rawText;\n\treturn isTrimmed ? trimmedExcerpt + '\u2026' : trimmedExcerpt;\n}\n\n/**\n * Calculate y offsets for all floating comment threads. Adjusts positions\n * to prevent overlapping by pushing threads above the selected one upward\n * and threads below it downward.\n *\n * @param {Object} params\n * @param {Array} params.threads Ordered list of thread objects.\n * @param {string|number|undefined} params.selectedNoteId ID of the currently selected thread.\n * @param {Object<string,DOMRect>} params.blockRects Pre-read bounding rects keyed by thread ID.\n * @param {Object<string,number>} params.heights Rendered heights keyed by thread ID.\n * @return {{ offsets: Object<string,number>, minHeight: number }} Computed offsets and minimum editor height.\n */\nexport function calculateAllOffsets( {\n\tthreads,\n\tselectedNoteId,\n\tblockRects,\n\theights,\n} ) {\n\tconst offsets = {};\n\n\tconst anchorIndex = Math.max(\n\t\t0,\n\t\tthreads.findIndex( ( thread ) => thread.id === selectedNoteId )\n\t);\n\n\tconst anchorThread = threads[ anchorIndex ];\n\n\tif ( ! anchorThread || ! blockRects[ anchorThread.id ] ) {\n\t\treturn { offsets, minHeight: 0 };\n\t}\n\n\tconst anchorRect = blockRects[ anchorThread.id ];\n\tconst anchorTop = anchorRect.top || 0;\n\tconst anchorHeight = heights[ anchorThread.id ] || 0;\n\n\toffsets[ anchorThread.id ] = THREAD_ALIGN_OFFSET;\n\n\t// Process threads after the anchor, offsetting overlapping threads downward.\n\tlet prevAdjustedTop = anchorTop + THREAD_ALIGN_OFFSET;\n\tlet prevHeight = anchorHeight;\n\n\tfor ( let i = anchorIndex + 1; i < threads.length; i++ ) {\n\t\tconst thread = threads[ i ];\n\t\tconst threadRect = blockRects[ thread.id ];\n\t\tif ( ! threadRect ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst threadTop = threadRect.top || 0;\n\t\tconst threadHeight = heights[ thread.id ] || 0;\n\n\t\tlet offset = THREAD_ALIGN_OFFSET;\n\n\t\tconst prevBottom = prevAdjustedTop + prevHeight;\n\t\tif ( threadTop < prevBottom + THREAD_GAP ) {\n\t\t\toffset = prevBottom - threadTop + OVERLAP_MARGIN;\n\t\t}\n\n\t\toffsets[ thread.id ] = offset;\n\n\t\tprevAdjustedTop = threadTop + offset;\n\t\tprevHeight = threadHeight;\n\t}\n\n\t// Process threads before the anchor, offsetting overlapping threads upward.\n\tlet belowAdjustedTop = anchorTop + THREAD_ALIGN_OFFSET;\n\n\tfor ( let i = anchorIndex - 1; i >= 0; i-- ) {\n\t\tconst thread = threads[ i ];\n\t\tconst threadRect = blockRects[ thread.id ];\n\t\tif ( ! threadRect ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst threadTop = threadRect.top || 0;\n\t\tconst threadHeight = heights[ thread.id ] || 0;\n\n\t\tlet offset = THREAD_ALIGN_OFFSET;\n\n\t\tconst threadBottom = threadTop + threadHeight;\n\n\t\tif ( threadBottom > belowAdjustedTop ) {\n\t\t\toffset =\n\t\t\t\tbelowAdjustedTop - threadTop - threadHeight - OVERLAP_MARGIN;\n\t\t}\n\n\t\toffsets[ thread.id ] = offset;\n\n\t\tbelowAdjustedTop = threadTop + offset;\n\t}\n\n\tlet editorMinHeight = 0;\n\tconst lastThread = threads[ threads.length - 1 ];\n\tconst lastBlockRect = blockRects[ lastThread.id ];\n\tif ( lastBlockRect ) {\n\t\tconst lastThreadTop = lastBlockRect.top || 0;\n\t\tconst lastThreadHeight = heights[ lastThread.id ] || 0;\n\t\tconst lastThreadOffset = offsets[ lastThread.id ] || 0;\n\t\teditorMinHeight =\n\t\t\tlastThreadTop +\n\t\t\tlastThreadHeight +\n\t\t\tlastThreadOffset +\n\t\t\tBOARD_BOTTOM_PADDING;\n\t}\n\n\treturn { offsets, minHeight: editorMinHeight };\n}\n\n/**\n * Shift focus to the comment thread associated with a particular comment ID.\n * If an additional selector is provided, the focus will be shifted to the element matching the selector.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {string} commentId The ID of the comment thread to focus.\n * @param {?HTMLElement} container The container element to search within.\n * @param {string} additionalSelector The additional selector to focus on.\n */\nexport function focusCommentThread( commentId, container, additionalSelector ) {\n\tif ( ! container ) {\n\t\treturn;\n\t}\n\n\t// A thread without a commentId is a new comment thread.\n\tconst threadSelector =\n\t\tcommentId && commentId !== 'new'\n\t\t\t? `[role=treeitem][id=\"comment-thread-${ commentId }\"]`\n\t\t\t: '[role=treeitem]:not([id])';\n\tconst selector = additionalSelector\n\t\t? `${ threadSelector } ${ additionalSelector }`\n\t\t: threadSelector;\n\n\treturn new Promise( ( resolve ) => {\n\t\tif ( container.querySelector( selector ) ) {\n\t\t\treturn resolve( container.querySelector( selector ) );\n\t\t}\n\n\t\tlet timer = null;\n\t\t// Wait for the element to be added to the DOM.\n\t\tconst observer = new window.MutationObserver( () => {\n\t\t\tif ( container.querySelector( selector ) ) {\n\t\t\t\tclearTimeout( timer );\n\t\t\t\tobserver.disconnect();\n\t\t\t\tresolve( container.querySelector( selector ) );\n\t\t\t}\n\t\t} );\n\n\t\tobserver.observe( container, {\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t} );\n\n\t\t// Stop trying after 3 seconds.\n\t\ttimer = setTimeout( () => {\n\t\t\tobserver.disconnect();\n\t\t\tresolve( null );\n\t\t}, 3000 );\n\t} ).then( ( element ) => element?.focus() );\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AAQZ,SAAS,sBAAuB,KAAM;AAC5C,SAAO,IAAI,KAAK;AACjB;AAEA,IAAM,sBAAsB;AAC5B,IAAM,aAAa;AACnB,IAAM,iBAAiB;AACvB,IAAM,uBAAuB;AAM7B,IAAM,uBAAuB;AAAA,EAC5B;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACD;AAQO,SAAS,qBAAsB,QAAS;AAC9C,SAAO,qBAAsB,SAAS,qBAAqB,MAAO;AACnE;AASO,SAAS,kBAAmB,MAAM,gBAAgB,IAAK;AAC7D,MAAK,CAAE,MAAO;AACb,WAAO;AAAA,EACR;AAOA,QAAM,gBAAgB,GAAI,SAAS,oCAA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,SAAO,IAAI,QAAS,CAAE,YAAa;AAClC,QAAK,UAAU,cAAe,QAAS,GAAI;AAC1C,aAAO,QAAS,UAAU,cAAe,QAAS,CAAE;AAAA,IACrD;AAEA,QAAI,QAAQ;AAEZ,UAAM,WAAW,IAAI,OAAO,iBAAkB,MAAM;AACnD,UAAK,UAAU,cAAe,QAAS,GAAI;AAC1C,qBAAc,KAAM;AACpB,iBAAS,WAAW;AACpB,gBAAS,UAAU,cAAe,QAAS,CAAE;AAAA,MAC9C;AAAA,IACD,CAAE;AAEF,aAAS,QAAS,WAAW;AAAA,MAC5B,WAAW;AAAA,MACX,SAAS;AAAA,IACV,CAAE;AAGF,YAAQ,WAAY,MAAM;AACzB,eAAS,WAAW;AACpB,cAAS,IAAK;AAAA,IACf,GAAG,GAAK;AAAA,EACT,CAAE,EAAE,KAAM,CAAE,YAAa,SAAS,MAAM,CAAE;AAC3C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/collaborators-presence/avatar/component.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport { colord, extend } from 'colord';\nimport a11yPlugin from 'colord/plugins/a11y';\n\nextend( [ a11yPlugin ] );\n\n/**\n * WordPress dependencies\n */\nimport { Icon, Tooltip } from '@wordpress/components';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { AvatarProps } from './types';\nimport { useImageLoadingStatus } from './use-image-loading-status';\n\n// Runtime equivalents of @wordpress/base-styles tokens ($gray-900, $white).\nconst GRAY_900 = '#1e1e1e';\nconst WHITE = '#fff';\n\nfunction Avatar( {\n\tclassName,\n\tsrc,\n\tname,\n\tlabel,\n\tvariant,\n\tsize = 'default',\n\tborderColor,\n\tdimmed = false,\n\tstatusIndicator,\n\tstyle,\n\t...props\n}: AvatarProps &\n\tOmit< React.HTMLAttributes< HTMLDivElement >, keyof AvatarProps > ) {\n\tconst {\n\t\tstatus: imageStatus,\n\t\thandleLoad,\n\t\thandleError,\n\t} = useImageLoadingStatus( src );\n\tconst imageLoaded = imageStatus === 'loaded';\n\n\tconst showBadge = variant === 'badge' && !! name;\n\tconst initials = name\n\t\t? name\n\t\t\t\t.split( /\\s+/ )\n\t\t\t\t.slice( 0, 2 )\n\t\t\t\t.map( ( word ) => word[ 0 ] )\n\t\t\t\t.join( '' )\n\t\t\t\t.toUpperCase()\n\t\t: undefined;\n\tconst nameColor = useMemo(\n\t\t() =>\n\t\t\tborderColor &&\n\t\t\tcolord( borderColor ).isReadable( GRAY_900, {\n\t\t\t\tlevel: 'AA',\n\t\t\t\tsize: 'normal',\n\t\t\t} )\n\t\t\t\t? GRAY_900\n\t\t\t\t: WHITE,\n\t\t[ borderColor ]\n\t);\n\n\tconst customProperties = {\n\t\t...style,\n\t\t...( borderColor\n\t\t\t? {\n\t\t\t\t\t'--editor-avatar-outline-color': borderColor,\n\t\t\t\t\t'--editor-avatar-name-color': nameColor,\n\t\t\t }\n\t\t\t: {} ),\n\t}
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport { colord, extend } from 'colord';\nimport a11yPlugin from 'colord/plugins/a11y';\n\nextend( [ a11yPlugin ] );\n\n/**\n * WordPress dependencies\n */\nimport { Icon, Tooltip } from '@wordpress/components';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { AvatarProps } from './types';\nimport { useImageLoadingStatus } from './use-image-loading-status';\n\n// Runtime equivalents of @wordpress/base-styles tokens ($gray-900, $white).\nconst GRAY_900 = '#1e1e1e';\nconst WHITE = '#fff';\n\nfunction Avatar( {\n\tclassName,\n\tsrc,\n\tname,\n\tlabel,\n\tvariant,\n\tsize = 'default',\n\tborderColor,\n\tdimmed = false,\n\tstatusIndicator,\n\tstyle,\n\t...props\n}: AvatarProps &\n\tOmit< React.HTMLAttributes< HTMLDivElement >, keyof AvatarProps > ) {\n\tconst {\n\t\tstatus: imageStatus,\n\t\thandleLoad,\n\t\thandleError,\n\t} = useImageLoadingStatus( src );\n\tconst imageLoaded = imageStatus === 'loaded';\n\n\tconst showBadge = variant === 'badge' && !! name;\n\tconst initials = name\n\t\t? name\n\t\t\t\t.split( /\\s+/ )\n\t\t\t\t.slice( 0, 2 )\n\t\t\t\t.map( ( word ) => word[ 0 ] )\n\t\t\t\t.join( '' )\n\t\t\t\t.toUpperCase()\n\t\t: undefined;\n\tconst nameColor = useMemo(\n\t\t() =>\n\t\t\tborderColor &&\n\t\t\tcolord( borderColor ).isReadable( GRAY_900, {\n\t\t\t\tlevel: 'AA',\n\t\t\t\tsize: 'normal',\n\t\t\t} )\n\t\t\t\t? GRAY_900\n\t\t\t\t: WHITE,\n\t\t[ borderColor ]\n\t);\n\n\tconst customProperties = {\n\t\t...style,\n\t\t...( borderColor\n\t\t\t? {\n\t\t\t\t\t'--editor-avatar-outline-color': borderColor,\n\t\t\t\t\t'--editor-avatar-name-color': nameColor,\n\t\t\t }\n\t\t\t: {} ),\n\t};\n\n\tconst avatar = (\n\t\t<div\n\t\t\tclassName={ clsx( 'editor-avatar', className, {\n\t\t\t\t'has-avatar-border-color': !! borderColor,\n\t\t\t\t'has-src': imageLoaded,\n\t\t\t\t'is-badge': showBadge,\n\t\t\t\t'is-small': size === 'small',\n\t\t\t\t'is-dimmed': dimmed,\n\t\t\t} ) }\n\t\t\tstyle={ customProperties }\n\t\t\trole={ name ? 'img' : undefined }\n\t\t\taria-label={ name || undefined }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t<span className=\"editor-avatar__image\">\n\t\t\t\t{ src && (\n\t\t\t\t\t<img\n\t\t\t\t\t\tsrc={ src }\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tcrossOrigin=\"anonymous\"\n\t\t\t\t\t\tclassName=\"editor-avatar__img\"\n\t\t\t\t\t\tonLoad={ handleLoad }\n\t\t\t\t\t\tonError={ handleError }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! imageLoaded && initials }\n\t\t\t</span>\n\t\t\t{ dimmed && !! statusIndicator && (\n\t\t\t\t<span className=\"editor-avatar__status-indicator\">\n\t\t\t\t\t<Icon icon={ statusIndicator } />\n\t\t\t\t</span>\n\t\t\t) }\n\t\t\t{ showBadge && (\n\t\t\t\t<span className=\"editor-avatar__name\">{ label || name }</span>\n\t\t\t) }\n\t\t</div>\n\t);\n\n\tif ( name && ( ! showBadge || label ) ) {\n\t\treturn <Tooltip text={ name }>{ avatar }</Tooltip>;\n\t}\n\n\treturn avatar;\n}\n\nexport default Avatar;\n"],
|
|
5
5
|
"mappings": ";AAGA,OAAO,UAAU;AACjB,SAAS,QAAQ,cAAc;AAC/B,OAAO,gBAAgB;AAOvB,SAAS,MAAM,eAAe;AAC9B,SAAS,eAAe;AAMxB,SAAS,6BAA6B;AAwEnC,SAEE,KAFF;AApFH,OAAQ,CAAE,UAAW,CAAE;AAevB,IAAM,WAAW;AACjB,IAAM,QAAQ;AAEd,SAAS,OAAQ;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,GAAG;AACJ,GACqE;AACpE,QAAM;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,EACD,IAAI,sBAAuB,GAAI;AAC/B,QAAM,cAAc,gBAAgB;AAEpC,QAAM,YAAY,YAAY,WAAW,CAAC,CAAE;AAC5C,QAAM,WAAW,OACd,KACC,MAAO,KAAM,EACb,MAAO,GAAG,CAAE,EACZ,IAAK,CAAE,SAAU,KAAM,CAAE,CAAE,EAC3B,KAAM,EAAG,EACT,YAAY,IACb;AACH,QAAM,YAAY;AAAA,IACjB,MACC,eACA,OAAQ,WAAY,EAAE,WAAY,UAAU;AAAA,MAC3C,OAAO;AAAA,MACP,MAAM;AAAA,IACP,CAAE,IACC,WACA;AAAA,IACJ,CAAE,WAAY;AAAA,EACf;AAEA,QAAM,mBAAmB;AAAA,IACxB,GAAG;AAAA,IACH,GAAK,cACF;AAAA,MACA,iCAAiC;AAAA,MACjC,8BAA8B;AAAA,IAC9B,IACA,CAAC;AAAA,EACL;AAEA,QAAM,SACL;AAAA,IAAC;AAAA;AAAA,MACA,WAAY,KAAM,iBAAiB,WAAW;AAAA,QAC7C,2BAA2B,CAAC,CAAE;AAAA,QAC9B,WAAW;AAAA,QACX,YAAY;AAAA,QACZ,YAAY,SAAS;AAAA,QACrB,aAAa;AAAA,MACd,CAAE;AAAA,MACF,OAAQ;AAAA,MACR,MAAO,OAAO,QAAQ;AAAA,MACtB,cAAa,QAAQ;AAAA,MACnB,GAAG;AAAA,MAEL;AAAA,6BAAC,UAAK,WAAU,wBACb;AAAA,iBACD;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA,KAAI;AAAA,cACJ,aAAY;AAAA,cACZ,WAAU;AAAA,cACV,QAAS;AAAA,cACT,SAAU;AAAA;AAAA,UACX;AAAA,UAEC,CAAE,eAAe;AAAA,WACpB;AAAA,QACE,UAAU,CAAC,CAAE,mBACd,oBAAC,UAAK,WAAU,mCACf,8BAAC,QAAK,MAAO,iBAAkB,GAChC;AAAA,QAEC,aACD,oBAAC,UAAK,WAAU,uBAAwB,mBAAS,MAAM;AAAA;AAAA;AAAA,EAEzD;AAGD,MAAK,SAAU,CAAE,aAAa,QAAU;AACvC,WAAO,oBAAC,WAAQ,MAAO,MAAS,kBAAQ;AAAA,EACzC;AAEA,SAAO;AACR;AAEA,IAAO,oBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -14,10 +14,10 @@ import { getAvatarBorderColor } from "../collab-sidebar/utils.mjs";
|
|
|
14
14
|
import { createCursorRegistry } from "../collaborators-overlay/cursor-registry.mjs";
|
|
15
15
|
|
|
16
16
|
// packages/editor/src/components/collaborators-presence/styles/collaborators-presence.scss
|
|
17
|
-
if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='
|
|
17
|
+
if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='9907eeab15']")) {
|
|
18
18
|
const style = document.createElement("style");
|
|
19
|
-
style.setAttribute("data-wp-hash", "
|
|
20
|
-
style.appendChild(document.createTextNode(".editor-collaborators-presence{align-items:center;background:#f0f0f0;border-radius:4px;display:flex;flex-shrink:0;height:32px;margin-right:8px}.editor-collaborators-presence:has(.is-pressed),.editor-collaborators-presence:hover{background-color:#e0e0e0}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button{align-items:center;background:#0000;border-radius:4px;box-sizing:border-box;color:#2f2f2f;cursor:pointer;display:flex;height:100%;padding:4px;position:relative}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button.is-pressed,.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button.is-pressed:hover,.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button:hover{background:#0000;color:#2f2f2f}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button:focus:not(:active){box-shadow:inset 0 0 0 var(--wp-admin-border-width-focus,2px) var(--wp-admin-theme-color,#007cba);outline:none}"));
|
|
19
|
+
style.setAttribute("data-wp-hash", "9907eeab15");
|
|
20
|
+
style.appendChild(document.createTextNode(".editor-collaborators-presence{align-items:center;background:#f0f0f0;border-radius:4px;display:flex;flex-shrink:0;height:32px;margin-right:8px}.editor-collaborators-presence:has(.is-pressed),.editor-collaborators-presence:hover{background-color:#e0e0e0}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button{align-items:center;background:#0000;border-radius:4px;box-sizing:border-box;color:#2f2f2f;cursor:var(--wpds-cursor-control,pointer);display:flex;height:100%;padding:4px;position:relative}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button.is-pressed,.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button.is-pressed:hover,.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button:hover{background:#0000;color:#2f2f2f}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button:focus:not(:active){box-shadow:inset 0 0 0 var(--wp-admin-border-width-focus,2px) var(--wp-admin-theme-color,#007cba);outline:none}"));
|
|
21
21
|
document.head.appendChild(style);
|
|
22
22
|
}
|
|
23
23
|
|