@wordpress/editor 14.33.3-next.36001005c.0 → 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.
Files changed (144) hide show
  1. package/build/bindings/post-data.js +49 -72
  2. package/build/bindings/post-data.js.map +3 -3
  3. package/build/bindings/post-meta.js +46 -47
  4. package/build/bindings/post-meta.js.map +2 -2
  5. package/build/bindings/term-data.js +6 -16
  6. package/build/bindings/term-data.js.map +2 -2
  7. package/build/components/block-settings-menu/content-only-settings-menu.js +186 -0
  8. package/build/components/block-settings-menu/content-only-settings-menu.js.map +7 -0
  9. package/build/components/collab-sidebar/add-comment.js +34 -7
  10. package/build/components/collab-sidebar/add-comment.js.map +3 -3
  11. package/build/components/collab-sidebar/comment-author-info.js +27 -15
  12. package/build/components/collab-sidebar/comment-author-info.js.map +2 -2
  13. package/build/components/collab-sidebar/comment-indicator-toolbar.js +15 -45
  14. package/build/components/collab-sidebar/comment-indicator-toolbar.js.map +3 -3
  15. package/build/components/collab-sidebar/comments.js +137 -35
  16. package/build/components/collab-sidebar/comments.js.map +3 -3
  17. package/build/components/collab-sidebar/hooks.js +8 -7
  18. package/build/components/collab-sidebar/hooks.js.map +2 -2
  19. package/build/components/collab-sidebar/index.js +56 -60
  20. package/build/components/collab-sidebar/index.js.map +3 -3
  21. package/build/components/editor/index.js +2 -0
  22. package/build/components/editor/index.js.map +3 -3
  23. package/build/components/header/index.js +0 -3
  24. package/build/components/header/index.js.map +3 -3
  25. package/build/components/more-menu/index.js +1 -1
  26. package/build/components/more-menu/index.js.map +2 -2
  27. package/build/components/post-template/hooks.js +7 -38
  28. package/build/components/post-template/hooks.js.map +2 -2
  29. package/build/components/provider/index.js +3 -1
  30. package/build/components/provider/index.js.map +3 -3
  31. package/build/components/visual-editor/index.js +20 -9
  32. package/build/components/visual-editor/index.js.map +2 -2
  33. package/build/store/actions.js +1 -1
  34. package/build/store/actions.js.map +2 -2
  35. package/build/store/private-actions.js +8 -0
  36. package/build/store/private-actions.js.map +2 -2
  37. package/build/store/private-selectors.js +5 -0
  38. package/build/store/private-selectors.js.map +2 -2
  39. package/build/store/reducer.js +10 -0
  40. package/build/store/reducer.js.map +2 -2
  41. package/build-module/bindings/post-data.js +49 -72
  42. package/build-module/bindings/post-data.js.map +2 -2
  43. package/build-module/bindings/post-meta.js +46 -47
  44. package/build-module/bindings/post-meta.js.map +2 -2
  45. package/build-module/bindings/term-data.js +6 -16
  46. package/build-module/bindings/term-data.js.map +2 -2
  47. package/build-module/components/block-settings-menu/content-only-settings-menu.js +161 -0
  48. package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +7 -0
  49. package/build-module/components/collab-sidebar/add-comment.js +36 -9
  50. package/build-module/components/collab-sidebar/add-comment.js.map +2 -2
  51. package/build-module/components/collab-sidebar/comment-author-info.js +27 -15
  52. package/build-module/components/collab-sidebar/comment-author-info.js.map +2 -2
  53. package/build-module/components/collab-sidebar/comment-indicator-toolbar.js +21 -37
  54. package/build-module/components/collab-sidebar/comment-indicator-toolbar.js.map +2 -2
  55. package/build-module/components/collab-sidebar/comments.js +147 -38
  56. package/build-module/components/collab-sidebar/comments.js.map +2 -2
  57. package/build-module/components/collab-sidebar/hooks.js +8 -7
  58. package/build-module/components/collab-sidebar/hooks.js.map +2 -2
  59. package/build-module/components/collab-sidebar/index.js +56 -60
  60. package/build-module/components/collab-sidebar/index.js.map +2 -2
  61. package/build-module/components/editor/index.js +2 -0
  62. package/build-module/components/editor/index.js.map +2 -2
  63. package/build-module/components/header/index.js +0 -3
  64. package/build-module/components/header/index.js.map +2 -2
  65. package/build-module/components/more-menu/index.js +1 -1
  66. package/build-module/components/more-menu/index.js.map +2 -2
  67. package/build-module/components/post-template/hooks.js +7 -38
  68. package/build-module/components/post-template/hooks.js.map +2 -2
  69. package/build-module/components/provider/index.js +3 -1
  70. package/build-module/components/provider/index.js.map +2 -2
  71. package/build-module/components/visual-editor/index.js +20 -9
  72. package/build-module/components/visual-editor/index.js.map +2 -2
  73. package/build-module/store/actions.js +1 -1
  74. package/build-module/store/actions.js.map +2 -2
  75. package/build-module/store/private-actions.js +7 -0
  76. package/build-module/store/private-actions.js.map +2 -2
  77. package/build-module/store/private-selectors.js +4 -0
  78. package/build-module/store/private-selectors.js.map +2 -2
  79. package/build-module/store/reducer.js +9 -0
  80. package/build-module/store/reducer.js.map +2 -2
  81. package/build-style/style-rtl.css +18 -66
  82. package/build-style/style.css +18 -66
  83. package/build-types/bindings/post-data.d.ts +20 -20
  84. package/build-types/bindings/post-meta.d.ts +1 -14
  85. package/build-types/bindings/term-data.d.ts +6 -16
  86. package/build-types/components/block-settings-menu/content-only-settings-menu.d.ts +2 -0
  87. package/build-types/components/block-settings-menu/content-only-settings-menu.d.ts.map +1 -0
  88. package/build-types/components/collab-sidebar/add-comment.d.ts +6 -1
  89. package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
  90. package/build-types/components/collab-sidebar/comment-author-info.d.ts +5 -16
  91. package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -1
  92. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts +1 -2
  93. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +1 -1
  94. package/build-types/components/collab-sidebar/comments.d.ts +12 -26
  95. package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
  96. package/build-types/components/collab-sidebar/hooks.d.ts +0 -1
  97. package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
  98. package/build-types/components/collab-sidebar/index.d.ts +1 -4
  99. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  100. package/build-types/components/editor/index.d.ts.map +1 -1
  101. package/build-types/components/header/index.d.ts.map +1 -1
  102. package/build-types/components/post-template/hooks.d.ts +1 -1
  103. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  104. package/build-types/components/provider/index.d.ts.map +1 -1
  105. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  106. package/build-types/store/actions.d.ts.map +1 -1
  107. package/build-types/store/private-actions.d.ts +7 -0
  108. package/build-types/store/private-actions.d.ts.map +1 -1
  109. package/build-types/store/private-selectors.d.ts +7 -0
  110. package/build-types/store/private-selectors.d.ts.map +1 -1
  111. package/build-types/store/reducer.d.ts +10 -0
  112. package/build-types/store/reducer.d.ts.map +1 -1
  113. package/package.json +38 -38
  114. package/src/bindings/post-data.js +65 -124
  115. package/src/bindings/post-meta.js +56 -58
  116. package/src/bindings/term-data.js +6 -21
  117. package/src/bindings/test/post-meta.js +211 -0
  118. package/src/components/block-settings-menu/content-only-settings-menu.js +185 -0
  119. package/src/components/block-settings-menu/content-only-settings-menu.native.js +4 -0
  120. package/src/components/block-settings-menu/style.scss +6 -0
  121. package/src/components/collab-sidebar/add-comment.js +41 -8
  122. package/src/components/collab-sidebar/comment-author-info.js +33 -26
  123. package/src/components/collab-sidebar/comment-indicator-toolbar.js +25 -51
  124. package/src/components/collab-sidebar/comments.js +147 -43
  125. package/src/components/collab-sidebar/hooks.js +9 -8
  126. package/src/components/collab-sidebar/index.js +58 -48
  127. package/src/components/collab-sidebar/style.scss +8 -69
  128. package/src/components/editor/index.js +2 -0
  129. package/src/components/editor-help/style.scss +1 -1
  130. package/src/components/header/index.js +0 -7
  131. package/src/components/more-menu/index.js +1 -1
  132. package/src/components/post-last-revision/style.scss +1 -1
  133. package/src/components/post-panel-row/style.scss +0 -1
  134. package/src/components/post-publish-panel/style.scss +1 -1
  135. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
  136. package/src/components/post-template/hooks.js +10 -51
  137. package/src/components/provider/index.js +3 -4
  138. package/src/components/visual-editor/index.js +27 -6
  139. package/src/store/actions.js +4 -1
  140. package/src/store/private-actions.js +13 -0
  141. package/src/store/private-selectors.js +10 -0
  142. package/src/store/reducer.js +16 -0
  143. package/src/style.scss +1 -0
  144. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,161 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import {
3
+ BlockSettingsMenuControls,
4
+ __unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,
5
+ store as blockEditorStore,
6
+ useBlockDisplayInformation
7
+ } from "@wordpress/block-editor";
8
+ import { store as coreStore } from "@wordpress/core-data";
9
+ import { __experimentalText as Text, MenuItem } from "@wordpress/components";
10
+ import { useSelect, useDispatch } from "@wordpress/data";
11
+ import { __, _x } from "@wordpress/i18n";
12
+ import { store as editorStore } from "../../store";
13
+ import { unlock } from "../../lock-unlock";
14
+ import usePostContentBlocks from "../provider/use-post-content-blocks";
15
+ function ContentOnlySettingsMenuItems({ clientId, onClose }) {
16
+ const postContentBlocks = usePostContentBlocks();
17
+ const { entity, onNavigateToEntityRecord, canEditTemplates } = useSelect(
18
+ (select) => {
19
+ const {
20
+ getBlockParentsByBlockName,
21
+ getSettings,
22
+ getBlockAttributes,
23
+ getBlockParents
24
+ } = select(blockEditorStore);
25
+ const { getCurrentTemplateId, getRenderingMode } = select(editorStore);
26
+ const patternParent = getBlockParentsByBlockName(
27
+ clientId,
28
+ "core/block",
29
+ true
30
+ )[0];
31
+ let record;
32
+ if (patternParent) {
33
+ record = select(coreStore).getEntityRecord(
34
+ "postType",
35
+ "wp_block",
36
+ getBlockAttributes(patternParent).ref
37
+ );
38
+ } else if (getRenderingMode() === "template-locked" && !getBlockParents(clientId).some(
39
+ (parent) => postContentBlocks.includes(parent)
40
+ )) {
41
+ record = select(coreStore).getEntityRecord(
42
+ "postType",
43
+ "wp_template",
44
+ getCurrentTemplateId()
45
+ );
46
+ }
47
+ if (!record) {
48
+ return {};
49
+ }
50
+ const _canEditTemplates = select(coreStore).canUser("create", {
51
+ kind: "postType",
52
+ name: "wp_template"
53
+ });
54
+ return {
55
+ canEditTemplates: _canEditTemplates,
56
+ entity: record,
57
+ onNavigateToEntityRecord: getSettings().onNavigateToEntityRecord
58
+ };
59
+ },
60
+ [clientId, postContentBlocks]
61
+ );
62
+ if (!entity) {
63
+ return /* @__PURE__ */ jsx(
64
+ TemplateLockContentOnlyMenuItems,
65
+ {
66
+ clientId,
67
+ onClose
68
+ }
69
+ );
70
+ }
71
+ const isPattern = entity.type === "wp_block";
72
+ let helpText = isPattern ? __(
73
+ "Edit the pattern to move, delete, or make further changes to this block."
74
+ ) : __(
75
+ "Edit the template to move, delete, or make further changes to this block."
76
+ );
77
+ if (!canEditTemplates) {
78
+ helpText = __(
79
+ "Only users with permissions to edit the template can move or delete this block"
80
+ );
81
+ }
82
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
83
+ /* @__PURE__ */ jsx(BlockSettingsMenuFirstItem, { children: /* @__PURE__ */ jsx(
84
+ MenuItem,
85
+ {
86
+ onClick: () => {
87
+ onNavigateToEntityRecord({
88
+ postId: entity.id,
89
+ postType: entity.type
90
+ });
91
+ },
92
+ disabled: !canEditTemplates,
93
+ children: isPattern ? __("Edit pattern") : __("Edit template")
94
+ }
95
+ ) }),
96
+ /* @__PURE__ */ jsx(
97
+ Text,
98
+ {
99
+ variant: "muted",
100
+ as: "p",
101
+ className: "editor-content-only-settings-menu__description",
102
+ children: helpText
103
+ }
104
+ )
105
+ ] });
106
+ }
107
+ function TemplateLockContentOnlyMenuItems({ clientId, onClose }) {
108
+ const { contentLockingParent } = useSelect(
109
+ (select) => {
110
+ const { getContentLockingParent } = unlock(
111
+ select(blockEditorStore)
112
+ );
113
+ return {
114
+ contentLockingParent: getContentLockingParent(clientId)
115
+ };
116
+ },
117
+ [clientId]
118
+ );
119
+ const blockDisplayInformation = useBlockDisplayInformation(contentLockingParent);
120
+ const blockEditorActions = useDispatch(blockEditorStore);
121
+ if (!blockDisplayInformation?.title) {
122
+ return null;
123
+ }
124
+ const { modifyContentLockBlock } = unlock(blockEditorActions);
125
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
126
+ /* @__PURE__ */ jsx(BlockSettingsMenuFirstItem, { children: /* @__PURE__ */ jsx(
127
+ MenuItem,
128
+ {
129
+ onClick: () => {
130
+ modifyContentLockBlock(contentLockingParent);
131
+ onClose();
132
+ },
133
+ children: _x("Unlock", "Unlock content locked blocks")
134
+ }
135
+ ) }),
136
+ /* @__PURE__ */ jsx(
137
+ Text,
138
+ {
139
+ variant: "muted",
140
+ as: "p",
141
+ className: "editor-content-only-settings-menu__description",
142
+ children: __(
143
+ "Temporarily unlock the parent block to edit, delete or make further changes to this block."
144
+ )
145
+ }
146
+ )
147
+ ] });
148
+ }
149
+ function ContentOnlySettingsMenu() {
150
+ return /* @__PURE__ */ jsx(BlockSettingsMenuControls, { children: ({ selectedClientIds, onClose }) => selectedClientIds.length === 1 && /* @__PURE__ */ jsx(
151
+ ContentOnlySettingsMenuItems,
152
+ {
153
+ clientId: selectedClientIds[0],
154
+ onClose
155
+ }
156
+ ) });
157
+ }
158
+ export {
159
+ ContentOnlySettingsMenu as default
160
+ };
161
+ //# sourceMappingURL=content-only-settings-menu.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/block-settings-menu/content-only-settings-menu.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\t__unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,\n\tstore as blockEditorStore,\n\tuseBlockDisplayInformation,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalText as Text, MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport usePostContentBlocks from '../provider/use-post-content-blocks';\n\nfunction ContentOnlySettingsMenuItems( { clientId, onClose } ) {\n\tconst postContentBlocks = usePostContentBlocks();\n\tconst { entity, onNavigateToEntityRecord, canEditTemplates } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockParents,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getCurrentTemplateId, getRenderingMode } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst patternParent = getBlockParentsByBlockName(\n\t\t\t\tclientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t)[ 0 ];\n\n\t\t\tlet record;\n\t\t\tif ( patternParent ) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tgetBlockAttributes( patternParent ).ref\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\tgetRenderingMode() === 'template-locked' &&\n\t\t\t\t! getBlockParents( clientId ).some( ( parent ) =>\n\t\t\t\t\tpostContentBlocks.includes( parent )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\tgetCurrentTemplateId()\n\t\t\t\t);\n\t\t\t}\n\t\t\tif ( ! record ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst _canEditTemplates = select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\treturn {\n\t\t\t\tcanEditTemplates: _canEditTemplates,\n\t\t\t\tentity: record,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetSettings().onNavigateToEntityRecord,\n\t\t\t};\n\t\t},\n\t\t[ clientId, postContentBlocks ]\n\t);\n\n\tif ( ! entity ) {\n\t\treturn (\n\t\t\t<TemplateLockContentOnlyMenuItems\n\t\t\t\tclientId={ clientId }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst isPattern = entity.type === 'wp_block';\n\tlet helpText = isPattern\n\t\t? __(\n\t\t\t\t'Edit the pattern to move, delete, or make further changes to this block.'\n\t\t )\n\t\t: __(\n\t\t\t\t'Edit the template to move, delete, or make further changes to this block.'\n\t\t );\n\n\tif ( ! canEditTemplates ) {\n\t\thelpText = __(\n\t\t\t'Only users with permissions to edit the template can move or delete this block'\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\tpostId: entity.id,\n\t\t\t\t\t\t\tpostType: entity.type,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdisabled={ ! canEditTemplates }\n\t\t\t\t>\n\t\t\t\t\t{ isPattern ? __( 'Edit pattern' ) : __( 'Edit template' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ helpText }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nfunction TemplateLockContentOnlyMenuItems( { clientId, onClose } ) {\n\tconst { contentLockingParent } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcontentLockingParent: getContentLockingParent( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst blockDisplayInformation =\n\t\tuseBlockDisplayInformation( contentLockingParent );\n\tconst blockEditorActions = useDispatch( blockEditorStore );\n\tif ( ! blockDisplayInformation?.title ) {\n\t\treturn null;\n\t}\n\n\tconst { modifyContentLockBlock } = unlock( blockEditorActions );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tmodifyContentLockBlock( contentLockingParent );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ _x( 'Unlock', 'Unlock content locked blocks' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Temporarily unlock the parent block to edit, delete or make further changes to this block.'\n\t\t\t\t) }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nexport default function ContentOnlySettingsMenu() {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) =>\n\t\t\t\tselectedClientIds.length === 1 && (\n\t\t\t\t\t<ContentOnlySettingsMenuItems\n\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"],
5
+ "mappings": "AA6EG,SAuBD,UAvBC,KAuBD,YAvBC;AA1EH;AAAA,EACC;AAAA,EACA,wCAAwC;AAAA,EACxC,SAAS;AAAA,EACT;AAAA,OACM;AACP,SAAS,SAAS,iBAAiB;AACnC,SAAS,sBAAsB,MAAM,gBAAgB;AACrD,SAAS,WAAW,mBAAmB;AACvC,SAAS,IAAI,UAAU;AAKvB,SAAS,SAAS,mBAAmB;AACrC,SAAS,cAAc;AACvB,OAAO,0BAA0B;AAEjC,SAAS,6BAA8B,EAAE,UAAU,QAAQ,GAAI;AAC9D,QAAM,oBAAoB,qBAAqB;AAC/C,QAAM,EAAE,QAAQ,0BAA0B,iBAAiB,IAAI;AAAA,IAC9D,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI,OAAQ,gBAAiB;AAC7B,YAAM,EAA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react/jsx-runtime";
2
+ import clsx from "clsx";
2
3
  import { __ } from "@wordpress/i18n";
3
- import { useSelect } from "@wordpress/data";
4
+ import { useSelect, useDispatch } from "@wordpress/data";
4
5
  import {
5
6
  __experimentalHStack as HStack,
6
7
  __experimentalVStack as VStack
@@ -12,13 +13,17 @@ import {
12
13
  import { unlock } from "../../lock-unlock";
13
14
  import CommentAuthorInfo from "./comment-author-info";
14
15
  import CommentForm from "./comment-form";
15
- import { focusCommentThread } from "./utils";
16
+ import { focusCommentThread, noop } from "./utils";
16
17
  const { useBlockElement } = unlock(blockEditorPrivateApis);
17
18
  function AddComment({
18
19
  onSubmit,
19
20
  showCommentBoard,
20
21
  setShowCommentBoard,
21
- commentSidebarRef
22
+ commentSidebarRef,
23
+ reflowComments = noop,
24
+ isFloating = false,
25
+ y,
26
+ refs
22
27
  }) {
23
28
  const { clientId, blockCommentId } = useSelect((select) => {
24
29
  const { getSelectedBlock } = select(blockEditorStore);
@@ -29,16 +34,40 @@ function AddComment({
29
34
  };
30
35
  }, []);
31
36
  const blockElement = useBlockElement(clientId);
37
+ const { toggleBlockSpotlight } = unlock(useDispatch(blockEditorStore));
38
+ const unselectThread = () => {
39
+ setShowCommentBoard(false);
40
+ blockElement?.focus();
41
+ toggleBlockSpotlight(clientId, false);
42
+ };
32
43
  if (!showCommentBoard || !clientId || void 0 !== blockCommentId) {
33
44
  return null;
34
45
  }
35
46
  return /* @__PURE__ */ jsxs(
36
47
  VStack,
37
48
  {
38
- className: "editor-collab-sidebar-panel__thread is-selected",
49
+ className: clsx(
50
+ "editor-collab-sidebar-panel__thread is-selected",
51
+ {
52
+ "is-floating": isFloating
53
+ }
54
+ ),
39
55
  spacing: "3",
40
56
  tabIndex: 0,
57
+ "aria-label": __("New note"),
41
58
  role: "listitem",
59
+ ref: isFloating ? refs.setFloating : void 0,
60
+ style: isFloating ? (
61
+ // Delay showing the floating note box until a Y position is known to prevent blink.
62
+ { top: y, opacity: !y ? 0 : void 0 }
63
+ ) : void 0,
64
+ onBlur: (event) => {
65
+ if (event.currentTarget.contains(event.relatedTarget)) {
66
+ return;
67
+ }
68
+ toggleBlockSpotlight(clientId, false);
69
+ setShowCommentBoard(false);
70
+ },
42
71
  children: [
43
72
  /* @__PURE__ */ jsx(HStack, { alignment: "left", spacing: "3", children: /* @__PURE__ */ jsx(CommentAuthorInfo, {}) }),
44
73
  /* @__PURE__ */ jsx(
@@ -49,12 +78,10 @@ function AddComment({
49
78
  focusCommentThread(id, commentSidebarRef.current);
50
79
  setShowCommentBoard(false);
51
80
  },
52
- onCancel: () => {
53
- setShowCommentBoard(false);
54
- blockElement?.focus();
55
- },
81
+ onCancel: unselectThread,
82
+ reflowComments,
56
83
  submitButtonText: __("Add note"),
57
- labelText: __("New Note")
84
+ labelText: __("New note")
58
85
  }
59
86
  )
60
87
  ]
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collab-sidebar/add-comment.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\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 } from './utils';\n\nconst { useBlockElement } = unlock( blockEditorPrivateApis );\n\nexport function AddComment( {\n\tonSubmit,\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tcommentSidebarRef,\n} ) {\n\tconst { clientId, blockCommentId } = useSelect( ( select ) => {\n\t\tconst { getSelectedBlock } = select( blockEditorStore );\n\t\tconst selectedBlock = getSelectedBlock();\n\t\treturn {\n\t\t\tclientId: selectedBlock?.clientId,\n\t\t\tblockCommentId: selectedBlock?.attributes?.metadata?.noteId,\n\t\t};\n\t}, [] );\n\tconst blockElement = useBlockElement( clientId );\n\n\tif ( ! showCommentBoard || ! clientId || undefined !== blockCommentId ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack\n\t\t\tclassName=\"editor-collab-sidebar-panel__thread is-selected\"\n\t\t\tspacing=\"3\"\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"listitem\"\n\t\t>\n\t\t\t<HStack alignment=\"left\" spacing=\"3\">\n\t\t\t\t<CommentAuthorInfo />\n\t\t\t</HStack>\n\t\t\t<CommentForm\n\t\t\t\tonSubmit={ async ( inputComment ) => {\n\t\t\t\t\tconst { id } = await onSubmit( { content: inputComment } );\n\t\t\t\t\tfocusCommentThread( id, commentSidebarRef.current );\n\t\t\t\t\tsetShowCommentBoard( false );\n\t\t\t\t} }\n\t\t\t\tonCancel={ () => {\n\t\t\t\t\tsetShowCommentBoard( false );\n\t\t\t\t\tblockElement?.focus();\n\t\t\t\t} }\n\t\t\t\tsubmitButtonText={ __( 'Add note' ) }\n\t\t\t\tlabelText={ __( 'New Note' ) }\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"],
5
- "mappings": "AA6CE,SAOE,KAPF;AA1CF,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B;AAAA,EACC,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP;AAAA,EACC,SAAS;AAAA,EACT,eAAe;AAAA,OACT;AAKP,SAAS,cAAc;AACvB,OAAO,uBAAuB;AAC9B,OAAO,iBAAiB;AACxB,SAAS,0BAA0B;AAEnC,MAAM,EAAE,gBAAgB,IAAI,OAAQ,sBAAuB;AAEpD,SAAS,WAAY;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,EAAE,UAAU,eAAe,IAAI,UAAW,CAAE,WAAY;AAC7D,UAAM,EAAE,iBAAiB,IAAI,OAAQ,gBAAiB;AACtD,UAAM,gBAAgB,iBAAiB;AACvC,WAAO;AAAA,MACN,UAAU,eAAe;AAAA,MACzB,gBAAgB,eAAe,YAAY,UAAU;AAAA,IACtD;AAAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,eAAe,gBAAiB,QAAS;AAE/C,MAAK,CAAE,oBAAoB,CAAE,YAAY,WAAc,gBAAiB;AACvE,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,SAAQ;AAAA,MACR,UAAW;AAAA,MACX,MAAK;AAAA,MAEL;AAAA,4BAAC,UAAO,WAAU,QAAO,SAAQ,KAChC,8BAAC,qBAAkB,GACpB;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACA,UAAW,OAAQ,iBAAkB;AACpC,oBAAM,EAAE,GAAG,IAAI,MAAM,SAAU,EAAE,SAAS,aAAa,CAAE;AACzD,iCAAoB,IAAI,kBAAkB,OAAQ;AAClD,kCAAqB,KAAM;AAAA,YAC5B;AAAA,YACA,UAAW,MAAM;AAChB,kCAAqB,KAAM;AAC3B,4BAAc,MAAM;AAAA,YACrB;AAAA,YACA,kBAAmB,GAAI,UAAW;AAAA,YAClC,WAAY,GAAI,UAAW;AAAA;AAAA,QAC5B;AAAA;AAAA;AAAA,EACD;AAEF;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\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, noop } from './utils';\n\nconst { useBlockElement } = unlock( blockEditorPrivateApis );\n\nexport function AddComment( {\n\tonSubmit,\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tcommentSidebarRef,\n\treflowComments = noop,\n\tisFloating = false,\n\ty,\n\trefs,\n} ) {\n\tconst { clientId, blockCommentId } = useSelect( ( select ) => {\n\t\tconst { getSelectedBlock } = select( blockEditorStore );\n\t\tconst selectedBlock = getSelectedBlock();\n\t\treturn {\n\t\t\tclientId: selectedBlock?.clientId,\n\t\t\tblockCommentId: selectedBlock?.attributes?.metadata?.noteId,\n\t\t};\n\t}, [] );\n\tconst blockElement = useBlockElement( clientId );\n\tconst { toggleBlockSpotlight } = unlock( useDispatch( blockEditorStore ) );\n\n\tconst unselectThread = () => {\n\t\tsetShowCommentBoard( false );\n\t\tblockElement?.focus();\n\t\ttoggleBlockSpotlight( clientId, false );\n\t};\n\n\tif ( ! showCommentBoard || ! clientId || undefined !== blockCommentId ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack\n\t\t\tclassName={ clsx(\n\t\t\t\t'editor-collab-sidebar-panel__thread is-selected',\n\t\t\t\t{\n\t\t\t\t\t'is-floating': isFloating,\n\t\t\t\t}\n\t\t\t) }\n\t\t\tspacing=\"3\"\n\t\t\ttabIndex={ 0 }\n\t\t\taria-label={ __( 'New note' ) }\n\t\t\trole=\"listitem\"\n\t\t\tref={ isFloating ? refs.setFloating : undefined }\n\t\t\tstyle={\n\t\t\t\tisFloating\n\t\t\t\t\t? // Delay showing the floating note box until a Y position is known to prevent blink.\n\t\t\t\t\t { top: y, opacity: ! y ? 0 : undefined }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tonBlur={ ( event ) => {\n\t\t\t\tif ( event.currentTarget.contains( event.relatedTarget ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttoggleBlockSpotlight( clientId, false );\n\t\t\t\tsetShowCommentBoard( false );\n\t\t\t} }\n\t\t>\n\t\t\t<HStack alignment=\"left\" spacing=\"3\">\n\t\t\t\t<CommentAuthorInfo />\n\t\t\t</HStack>\n\t\t\t<CommentForm\n\t\t\t\tonSubmit={ async ( inputComment ) => {\n\t\t\t\t\tconst { id } = await onSubmit( { content: inputComment } );\n\t\t\t\t\tfocusCommentThread( id, commentSidebarRef.current );\n\t\t\t\t\tsetShowCommentBoard( false );\n\t\t\t\t} }\n\t\t\t\tonCancel={ unselectThread }\n\t\t\t\treflowComments={ reflowComments }\n\t\t\t\tsubmitButtonText={ __( 'Add note' ) }\n\t\t\t\tlabelText={ __( 'New note' ) }\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"],
5
+ "mappings": "AA4DE,SA2BE,KA3BF;AAzDF,OAAO,UAAU;AAIjB,SAAS,UAAU;AACnB,SAAS,WAAW,mBAAmB;AACvC;AAAA,EACC,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP;AAAA,EACC,SAAS;AAAA,EACT,eAAe;AAAA,OACT;AAKP,SAAS,cAAc;AACvB,OAAO,uBAAuB;AAC9B,OAAO,iBAAiB;AACxB,SAAS,oBAAoB,YAAY;AAEzC,MAAM,EAAE,gBAAgB,IAAI,OAAQ,sBAAuB;AAEpD,SAAS,WAAY;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb;AAAA,EACA;AACD,GAAI;AACH,QAAM,EAAE,UAAU,eAAe,IAAI,UAAW,CAAE,WAAY;AAC7D,UAAM,EAAE,iBAAiB,IAAI,OAAQ,gBAAiB;AACtD,UAAM,gBAAgB,iBAAiB;AACvC,WAAO;AAAA,MACN,UAAU,eAAe;AAAA,MACzB,gBAAgB,eAAe,YAAY,UAAU;AAAA,IACtD;AAAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,eAAe,gBAAiB,QAAS;AAC/C,QAAM,EAAE,qBAAqB,IAAI,OAAQ,YAAa,gBAAiB,CAAE;AAEzE,QAAM,iBAAiB,MAAM;AAC5B,wBAAqB,KAAM;AAC3B,kBAAc,MAAM;AACpB,yBAAsB,UAAU,KAAM;AAAA,EACvC;AAEA,MAAK,CAAE,oBAAoB,CAAE,YAAY,WAAc,gBAAiB;AACvE,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAY;AAAA,QACX;AAAA,QACA;AAAA,UACC,eAAe;AAAA,QAChB;AAAA,MACD;AAAA,MACA,SAAQ;AAAA,MACR,UAAW;AAAA,MACX,cAAa,GAAI,UAAW;AAAA,MAC5B,MAAK;AAAA,MACL,KAAM,aAAa,KAAK,cAAc;AAAA,MACtC,OACC;AAAA;AAAA,QAEG,EAAE,KAAK,GAAG,SAAS,CAAE,IAAI,IAAI,OAAU;AAAA,UACvC;AAAA,MAEJ,QAAS,CAAE,UAAW;AACrB,YAAK,MAAM,cAAc,SAAU,MAAM,aAAc,GAAI;AAC1D;AAAA,QACD;AACA,6BAAsB,UAAU,KAAM;AACtC,4BAAqB,KAAM;AAAA,MAC5B;AAAA,MAEA;AAAA,4BAAC,UAAO,WAAU,QAAO,SAAQ,KAChC,8BAAC,qBAAkB,GACpB;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACA,UAAW,OAAQ,iBAAkB;AACpC,oBAAM,EAAE,GAAG,IAAI,MAAM,SAAU,EAAE,SAAS,aAAa,CAAE;AACzD,iCAAoB,IAAI,kBAAkB,OAAQ;AAClD,kCAAqB,KAAM;AAAA,YAC5B;AAAA,YACA,UAAW;AAAA,YACX;AAAA,YACA,kBAAmB,GAAI,UAAW;AAAA,YAClC,WAAY,GAAI,UAAW;AAAA;AAAA,QAC5B;AAAA;AAAA;AAAA,EACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -12,26 +12,38 @@ import { useSelect } from "@wordpress/data";
12
12
  import { store as blockEditorStore } from "@wordpress/block-editor";
13
13
  import { getAvatarBorderColor } from "./utils";
14
14
  function CommentAuthorInfo({ avatar, name, date, userId }) {
15
+ const hasAvatar = !!avatar;
15
16
  const dateSettings = getDateSettings();
16
17
  const {
17
18
  currentUserAvatar,
18
19
  currentUserName,
19
20
  currentUserId,
20
21
  dateFormat = dateSettings.formats.date
21
- } = useSelect((select) => {
22
- const { getCurrentUser, getEntityRecord } = select(coreStore);
23
- const { getSettings } = select(blockEditorStore);
24
- const userData = getCurrentUser();
25
- const { __experimentalDiscussionSettings } = getSettings();
26
- const defaultAvatar = __experimentalDiscussionSettings?.avatarURL;
27
- const siteSettings = getEntityRecord("root", "site");
28
- return {
29
- currentUserAvatar: userData?.avatar_urls?.[48] ?? defaultAvatar,
30
- currentUserName: userData?.name,
31
- currentUserId: userData?.id,
32
- dateFormat: siteSettings?.date_format
33
- };
34
- }, []);
22
+ } = useSelect(
23
+ (select) => {
24
+ const { canUser, getCurrentUser, getEntityRecord } = select(coreStore);
25
+ const siteSettings = canUser("read", {
26
+ kind: "root",
27
+ name: "site"
28
+ }) ? getEntityRecord("root", "site") : void 0;
29
+ if (hasAvatar) {
30
+ return {
31
+ dateFormat: siteSettings?.date_format
32
+ };
33
+ }
34
+ const { getSettings } = select(blockEditorStore);
35
+ const { __experimentalDiscussionSettings } = getSettings();
36
+ const defaultAvatar = __experimentalDiscussionSettings?.avatarURL;
37
+ const userData = getCurrentUser();
38
+ return {
39
+ currentUserAvatar: userData?.avatar_urls?.[48] ?? defaultAvatar,
40
+ currentUserName: userData?.name,
41
+ currentUserId: userData?.id,
42
+ dateFormat: siteSettings?.date_format
43
+ };
44
+ },
45
+ [hasAvatar]
46
+ );
35
47
  const commentDate = getDate(date);
36
48
  const commentDateTime = dateI18n("c", commentDate);
37
49
  const shouldShowHumanTimeDiff = Math.floor((/* @__PURE__ */ new Date() - commentDate) / (1e3 * 60 * 60 * 24)) < 30;
@@ -59,7 +71,7 @@ function CommentAuthorInfo({ avatar, name, date, userId }) {
59
71
  ),
60
72
  /* @__PURE__ */ jsxs(VStack, { spacing: "0", children: [
61
73
  /* @__PURE__ */ jsx("span", { className: "editor-collab-sidebar-panel__user-name", children: name ?? currentUserName }),
62
- date && /* @__PURE__ */ jsx(Tooltip, { placement: "top", text: tooltipText, children: /* @__PURE__ */ jsx(
74
+ date && /* @__PURE__ */ jsx(Tooltip, { text: tooltipText, children: /* @__PURE__ */ jsx(
63
75
  "time",
64
76
  {
65
77
  dateTime: commentDateTime,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collab-sidebar/comment-author-info.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Tooltip, __experimentalVStack as VStack } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tdateI18n,\n\tgetSettings as getDateSettings,\n\thumanTimeDiff,\n\tgetDate,\n} from '@wordpress/date';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { getAvatarBorderColor } from './utils';\n\n/**\n * Render author information for a comment.\n *\n * @param {Object} props - Component properties.\n * @param {string} props.avatar - URL of the author's avatar.\n * @param {string} props.name - Name of the author.\n * @param {string} props.date - Date of the comment.\n * @param {string} props.userId - User ID of the author.\n *\n * @return {React.ReactNode} The JSX element representing the author's information.\n */\nfunction CommentAuthorInfo( { avatar, name, date, userId } ) {\n\tconst dateSettings = getDateSettings();\n\tconst {\n\t\tcurrentUserAvatar,\n\t\tcurrentUserName,\n\t\tcurrentUserId,\n\t\tdateFormat = dateSettings.formats.date,\n\t} = useSelect( ( select ) => {\n\t\tconst { getCurrentUser, getEntityRecord } = select( coreStore );\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst userData = getCurrentUser();\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\tconst defaultAvatar = __experimentalDiscussionSettings?.avatarURL;\n\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\treturn {\n\t\t\tcurrentUserAvatar: userData?.avatar_urls?.[ 48 ] ?? defaultAvatar,\n\t\t\tcurrentUserName: userData?.name,\n\t\t\tcurrentUserId: userData?.id,\n\t\t\tdateFormat: siteSettings?.date_format,\n\t\t};\n\t}, [] );\n\n\tconst commentDate = getDate( date );\n\tconst commentDateTime = dateI18n( 'c', commentDate );\n\tconst shouldShowHumanTimeDiff =\n\t\tMath.floor( ( new Date() - commentDate ) / ( 1000 * 60 * 60 * 24 ) ) <\n\t\t30;\n\n\tconst commentDateText = shouldShowHumanTimeDiff\n\t\t? humanTimeDiff( commentDate )\n\t\t: dateI18n( dateFormat, commentDate );\n\n\tconst tooltipText = dateI18n(\n\t\t// translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.\n\t\t_x( 'F j, Y g:i\\xa0a', 'Note date full date format' ),\n\t\tdate\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<img\n\t\t\t\tsrc={ avatar || currentUserAvatar }\n\t\t\t\tclassName=\"editor-collab-sidebar-panel__user-avatar\"\n\t\t\t\t// translators: alt text for user avatar image\n\t\t\t\talt={ __( 'User avatar' ) }\n\t\t\t\twidth={ 32 }\n\t\t\t\theight={ 32 }\n\t\t\t\tstyle={ {\n\t\t\t\t\tborderColor: getAvatarBorderColor(\n\t\t\t\t\t\tuserId ?? currentUserId\n\t\t\t\t\t),\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<VStack spacing=\"0\">\n\t\t\t\t<span className=\"editor-collab-sidebar-panel__user-name\">\n\t\t\t\t\t{ name ?? currentUserName }\n\t\t\t\t</span>\n\t\t\t\t{ date && (\n\t\t\t\t\t<Tooltip placement=\"top\" text={ tooltipText }>\n\t\t\t\t\t\t<time\n\t\t\t\t\t\t\tdateTime={ commentDateTime }\n\t\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__user-time\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ commentDateText }\n\t\t\t\t\t\t</time>\n\t\t\t\t\t</Tooltip>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</>\n\t);\n}\n\nexport default CommentAuthorInfo;\n"],
5
- "mappings": "AAsEE,mBACC,KAaA,YAdD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aAAc;AAAA,QACxB,OAAQ;AAAA,QACR,QAAS;AAAA,QACT,OAAQ;AAAA,UACP,aAAa;AAAA,YACZ,UAAU;AAAA,UACX;AAAA,QACD;AAAA;AAAA,IACD;AAAA,IACA,qBAAC,UAAO,SAAQ,KACf;AAAA,0BAAC,UAAK,WAAU,0CACb,kBAAQ,iBACX;AAAA,MACE,QACD,oBAAC,WAAQ,WAAU,OAAM,MAAO,aAC/B;AAAA,QAAC;AAAA;AAAA,UACA,UAAW;AAAA,UACX,WAAU;AAAA,UAER;AAAA;AAAA,MACH,GACD;AAAA,OAEF;AAAA,KACD;AAEF;AAEA,IAAO,8BAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Tooltip, __experimentalVStack as VStack } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tdateI18n,\n\tgetSettings as getDateSettings,\n\thumanTimeDiff,\n\tgetDate,\n} from '@wordpress/date';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { getAvatarBorderColor } from './utils';\n\nfunction CommentAuthorInfo( { avatar, name, date, userId } ) {\n\tconst hasAvatar = !! avatar;\n\tconst dateSettings = getDateSettings();\n\tconst {\n\t\tcurrentUserAvatar,\n\t\tcurrentUserName,\n\t\tcurrentUserId,\n\t\tdateFormat = dateSettings.formats.date,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getCurrentUser, getEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\tif ( hasAvatar ) {\n\t\t\t\treturn {\n\t\t\t\t\tdateFormat: siteSettings?.date_format,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\t\tconst defaultAvatar = __experimentalDiscussionSettings?.avatarURL;\n\t\t\tconst userData = getCurrentUser();\n\t\t\treturn {\n\t\t\t\tcurrentUserAvatar:\n\t\t\t\t\tuserData?.avatar_urls?.[ 48 ] ?? defaultAvatar,\n\t\t\t\tcurrentUserName: userData?.name,\n\t\t\t\tcurrentUserId: userData?.id,\n\t\t\t\tdateFormat: siteSettings?.date_format,\n\t\t\t};\n\t\t},\n\t\t[ hasAvatar ]\n\t);\n\n\tconst commentDate = getDate( date );\n\tconst commentDateTime = dateI18n( 'c', commentDate );\n\tconst shouldShowHumanTimeDiff =\n\t\tMath.floor( ( new Date() - commentDate ) / ( 1000 * 60 * 60 * 24 ) ) <\n\t\t30;\n\n\tconst commentDateText = shouldShowHumanTimeDiff\n\t\t? humanTimeDiff( commentDate )\n\t\t: dateI18n( dateFormat, commentDate );\n\n\tconst tooltipText = dateI18n(\n\t\t// translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.\n\t\t_x( 'F j, Y g:i\\xa0a', 'Note date full date format' ),\n\t\tdate\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<img\n\t\t\t\tsrc={ avatar || currentUserAvatar }\n\t\t\t\tclassName=\"editor-collab-sidebar-panel__user-avatar\"\n\t\t\t\t// translators: alt text for user avatar image\n\t\t\t\talt={ __( 'User avatar' ) }\n\t\t\t\twidth={ 32 }\n\t\t\t\theight={ 32 }\n\t\t\t\tstyle={ {\n\t\t\t\t\tborderColor: getAvatarBorderColor(\n\t\t\t\t\t\tuserId ?? currentUserId\n\t\t\t\t\t),\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<VStack spacing=\"0\">\n\t\t\t\t<span className=\"editor-collab-sidebar-panel__user-name\">\n\t\t\t\t\t{ name ?? currentUserName }\n\t\t\t\t</span>\n\t\t\t\t{ date && (\n\t\t\t\t\t<Tooltip text={ tooltipText }>\n\t\t\t\t\t\t<time\n\t\t\t\t\t\t\tdateTime={ commentDateTime }\n\t\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__user-time\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ commentDateText }\n\t\t\t\t\t\t</time>\n\t\t\t\t\t</Tooltip>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</>\n\t);\n}\n\nexport default CommentAuthorInfo;\n"],
5
+ "mappings": "AA6EE,mBACC,KAaA,YAdD;AA1EF,SAAS,SAAS,wBAAwB,cAAc;AACxD,SAAS,IAAI,UAAU;AACvB;AAAA,EACC;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,OACM;AACP,SAAS,SAAS,iBAAiB;AACnC,SAAS,iBAAiB;AAC1B,SAAS,SAAS,wBAAwB;AAK1C,SAAS,4BAA4B;AAErC,SAAS,kBAAmB,EAAE,QAAQ,MAAM,MAAM,OAAO,GAAI;AAC5D,QAAM,YAAY,CAAC,CAAE;AACrB,QAAM,eAAe,gBAAgB;AACrC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa,aAAa,QAAQ;AAAA,EACnC,IAAI;AAAA,IACH,CAAE,WAAY;AACb,YAAM,EAAE,SAAS,gBAAgB,gBAAgB,IAChD,OAAQ,SAAU;AACnB,YAAM,eAAe,QAAS,QAAQ;AAAA,QACrC,MAAM;AAAA,QACN,MAAM;AAAA,MACP,CAAE,IACC,gBAAiB,QAAQ,MAAO,IAChC;AAEH,UAAK,WAAY;AAChB,eAAO;AAAA,UACN,YAAY,cAAc;AAAA,QAC3B;AAAA,MACD;AAEA,YAAM,EAAE,YAAY,IAAI,OAAQ,gBAAiB;AACjD,YAAM,EAAE,iCAAiC,IAAI,YAAY;AACzD,YAAM,gBAAgB,kCAAkC;AACxD,YAAM,WAAW,eAAe;AAChC,aAAO;AAAA,QACN,mBACC,UAAU,cAAe,EAAG,KAAK;AAAA,QAClC,iBAAiB,UAAU;AAAA,QAC3B,eAAe,UAAU;AAAA,QACzB,YAAY,cAAc;AAAA,MAC3B;AAAA,IACD;AAAA,IACA,CAAE,SAAU;AAAA,EACb;AAEA,QAAM,cAAc,QAAS,IAAK;AAClC,QAAM,kBAAkB,SAAU,KAAK,WAAY;AACnD,QAAM,0BACL,KAAK,OAAS,oBAAI,KAAK,IAAI,gBAAkB,MAAO,KAAK,KAAK,GAAK,IACnE;AAED,QAAM,kBAAkB,0BACrB,cAAe,WAAY,IAC3B,SAAU,YAAY,WAAY;AAErC,QAAM,cAAc;AAAA;AAAA,IAEnB,GAAI,mBAAmB,4BAA6B;AAAA,IACpD;AAAA,EACD;AAEA,SACC,iCACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,KAAM,UAAU;AAAA,QAChB,WAAU;AAAA,QAEV,KAAM,GAAI,aAAc;AAAA,QACxB,OAAQ;AAAA,QACR,QAAS;AAAA,QACT,OAAQ;AAAA,UACP,aAAa;AAAA,YACZ,UAAU;AAAA,UACX;AAAA,QACD;AAAA;AAAA,IACD;AAAA,IACA,qBAAC,UAAO,SAAQ,KACf;AAAA,0BAAC,UAAK,WAAU,0CACb,kBAAQ,iBACX;AAAA,MACE,QACD,oBAAC,WAAQ,MAAO,aACf;AAAA,QAAC;AAAA;AAAA,UACA,UAAW;AAAA,UACX,WAAU;AAAA,UAER;AAAA;AAAA,MACH,GACD;AAAA,OAEF;AAAA,KACD;AAEF;AAEA,IAAO,8BAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,13 +1,16 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { ToolbarButton } from "@wordpress/components";
3
- import { __, _n, sprintf } from "@wordpress/i18n";
2
+ import {
3
+ ToolbarButton,
4
+ __experimentalText as Text,
5
+ __experimentalHStack as HStack
6
+ } from "@wordpress/components";
7
+ import { __, sprintf } from "@wordpress/i18n";
4
8
  import { useMemo } from "@wordpress/element";
5
9
  import { privateApis as blockEditorPrivateApis } from "@wordpress/block-editor";
6
- import clsx from "clsx";
7
10
  import { unlock } from "../../lock-unlock";
8
11
  import { getAvatarBorderColor } from "./utils";
9
12
  const { CommentIconToolbarSlotFill } = unlock(blockEditorPrivateApis);
10
- const CommentAvatarIndicator = ({ onClick, thread, hasMoreComments }) => {
13
+ const CommentAvatarIndicator = ({ onClick, thread }) => {
11
14
  const threadParticipants = useMemo(() => {
12
15
  if (!thread) {
13
16
  return [];
@@ -17,13 +20,11 @@ const CommentAvatarIndicator = ({ onClick, thread, hasMoreComments }) => {
17
20
  allComments.sort((a, b) => new Date(a.date) - new Date(b.date));
18
21
  allComments.forEach((comment) => {
19
22
  if (comment.author_name && comment.author_avatar_urls) {
20
- const authorKey = `${comment.author}-${comment.author_name}`;
21
- if (!participantsMap.has(authorKey)) {
22
- participantsMap.set(authorKey, {
23
+ if (!participantsMap.has(comment.author)) {
24
+ participantsMap.set(comment.author, {
23
25
  name: comment.author_name,
24
26
  avatar: comment.author_avatar_urls?.["48"] || comment.author_avatar_urls?.["96"],
25
27
  id: comment.author,
26
- isOriginalCommenter: comment.id === thread.id,
27
28
  date: comment.date
28
29
  });
29
30
  }
@@ -31,62 +32,45 @@ const CommentAvatarIndicator = ({ onClick, thread, hasMoreComments }) => {
31
32
  });
32
33
  return Array.from(participantsMap.values());
33
34
  }, [thread]);
34
- const hasUnresolved = thread?.status !== "approved";
35
- const threadHasMoreParticipants = hasMoreComments && thread?.reply && 1 + thread.reply.length >= 100;
36
35
  if (!threadParticipants.length) {
37
36
  return null;
38
37
  }
39
38
  const maxAvatars = 3;
40
- const visibleParticipants = threadParticipants.slice(0, maxAvatars);
41
- const overflowCount = Math.max(0, threadParticipants.length - maxAvatars);
39
+ const isOverflow = threadParticipants.length > maxAvatars;
40
+ const visibleParticipants = isOverflow ? threadParticipants.slice(0, maxAvatars - 1) : threadParticipants;
41
+ const overflowCount = Math.max(
42
+ 0,
43
+ threadParticipants.length - visibleParticipants.length
44
+ );
45
+ const threadHasMoreParticipants = threadParticipants.length > 100;
42
46
  const overflowText = threadHasMoreParticipants && overflowCount > 0 ? __("100+") : sprintf(
43
47
  // translators: %s: Number of participants.
44
48
  __("+%s"),
45
49
  overflowCount
46
50
  );
47
- const overflowTitle = threadHasMoreParticipants && overflowCount > 0 ? __("100+ participants") : sprintf(
48
- // translators: %s: Number of participants.
49
- _n(
50
- "+%s more participant",
51
- "+%s more participants",
52
- overflowCount
53
- ),
54
- overflowCount
55
- );
56
51
  return /* @__PURE__ */ jsx(CommentIconToolbarSlotFill.Fill, { children: /* @__PURE__ */ jsx(
57
52
  ToolbarButton,
58
53
  {
59
- className: clsx("comment-avatar-indicator", {
60
- "has-unresolved": hasUnresolved
61
- }),
54
+ className: "comment-avatar-indicator",
62
55
  label: __("View notes"),
63
56
  onClick,
64
57
  showTooltip: true,
65
- children: /* @__PURE__ */ jsxs("div", { className: "comment-avatar-stack", children: [
66
- visibleParticipants.map((participant, index) => /* @__PURE__ */ jsx(
58
+ children: /* @__PURE__ */ jsxs(HStack, { spacing: "1", children: [
59
+ visibleParticipants.map((participant) => /* @__PURE__ */ jsx(
67
60
  "img",
68
61
  {
69
62
  src: participant.avatar,
70
63
  alt: participant.name,
71
64
  className: "comment-avatar",
72
65
  style: {
73
- zIndex: maxAvatars - index,
74
66
  borderColor: getAvatarBorderColor(
75
67
  participant.id
76
68
  )
77
69
  }
78
70
  },
79
- participant.name + index
71
+ participant.id
80
72
  )),
81
- overflowCount > 0 && /* @__PURE__ */ jsx(
82
- "div",
83
- {
84
- className: "comment-avatar-overflow",
85
- style: { zIndex: 0 },
86
- title: overflowTitle,
87
- children: overflowText
88
- }
89
- )
73
+ overflowCount > 0 && /* @__PURE__ */ jsx(Text, { weight: 500, children: overflowText })
90
74
  ] })
91
75
  }
92
76
  ) });
@@ -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 { ToolbarButton } from '@wordpress/components';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * External dependencies\n */\nimport clsx from 'clsx';\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, hasMoreComments } ) => {\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\tconst authorKey = `${ comment.author }-${ comment.author_name }`;\n\t\t\t\tif ( ! participantsMap.has( authorKey ) ) {\n\t\t\t\t\tparticipantsMap.set( authorKey, {\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\tisOriginalCommenter: comment.id === thread.id,\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\tconst hasUnresolved = thread?.status !== 'approved';\n\n\t// Check if this specific thread has more participants due to pagination.\n\t// If we have pagination AND this thread + its replies equals or exceeds the API limit,\n\t// then this thread likely has more participants that weren't loaded.\n\tconst threadHasMoreParticipants =\n\t\thasMoreComments && thread?.reply && 1 + thread.reply.length >= 100;\n\n\tif ( ! threadParticipants.length ) {\n\t\treturn null;\n\t}\n\n\t// Show up to 3 avatars, with overflow indicator.\n\tconst maxAvatars = 3;\n\tconst visibleParticipants = threadParticipants.slice( 0, maxAvatars );\n\tconst overflowCount = Math.max( 0, threadParticipants.length - maxAvatars );\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\tconst overflowTitle =\n\t\tthreadHasMoreParticipants && overflowCount > 0\n\t\t\t? __( '100+ participants' )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %s: Number of participants.\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'+%s more participant',\n\t\t\t\t\t\t'+%s more participants',\n\t\t\t\t\t\toverflowCount\n\t\t\t\t\t),\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={ clsx( 'comment-avatar-indicator', {\n\t\t\t\t\t'has-unresolved': hasUnresolved,\n\t\t\t\t} ) }\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<div className=\"comment-avatar-stack\">\n\t\t\t\t\t{ visibleParticipants.map( ( participant, index ) => (\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tkey={ participant.name + index }\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\tzIndex: maxAvatars - index,\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<div\n\t\t\t\t\t\t\tclassName=\"comment-avatar-overflow\"\n\t\t\t\t\t\t\tstyle={ { zIndex: 0 } }\n\t\t\t\t\t\t\ttitle={ overflowTitle }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ overflowText }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</ToolbarButton>\n\t\t</CommentIconToolbarSlotFill.Fill>\n\t);\n};\n\nexport default CommentAvatarIndicator;\n"],
5
- "mappings": "AAwGI,SAEE,KAFF;AArGJ,SAAS,qBAAqB;AAC9B,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,eAAe;AACxB,SAAS,eAAe,8BAA8B;AAKtD,OAAO,UAAU;AAKjB,SAAS,cAAc;AACvB,SAAS,4BAA4B;AAErC,MAAM,EAAE,2BAA2B,IAAI,OAAQ,sBAAuB;AAEtE,MAAM,yBAAyB,CAAE,EAAE,SAAS,QAAQ,gBAAgB,MAAO;AAC1E,QAAM,qBAAqB,QAAS,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,cAAM,YAAY,GAAI,QAAQ,MAAO,IAAK,QAAQ,WAAY;AAC9D,YAAK,CAAE,gBAAgB,IAAK,SAAU,GAAI;AACzC,0BAAgB,IAAK,WAAW;AAAA,Y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,aAAa;AAAA,cACrB,aAAa;AAAA,gBACZ,YAAY;AAAA,cACb;AAAA,YACD;AAAA;AAAA,UATM,YAAY,OAAO;AAAA,QAU1B,CACC;AAAA,QACA,gBAAgB,KACjB;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,OAAQ,EAAE,QAAQ,EAAE;AAAA,YACpB,OAAQ;AAAA,YAEN;AAAA;AAAA,QACH;AAAA,SAEF;AAAA;AAAA,EACD,GACD;AAEF;AAEA,IAAO,oCAAQ;",
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{ overfl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