@wordpress/editor 14.31.1-next.f56bd8138.0 → 14.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/collab-sidebar/add-comment.js +10 -4
- package/build/components/collab-sidebar/add-comment.js.map +1 -1
- package/build/components/collab-sidebar/comment-author-info.js +39 -11
- package/build/components/collab-sidebar/comment-author-info.js.map +1 -1
- package/build/components/collab-sidebar/comment-form.js +23 -19
- package/build/components/collab-sidebar/comment-form.js.map +1 -1
- package/build/components/collab-sidebar/comment-indicator-toolbar.js +7 -4
- package/build/components/collab-sidebar/comment-indicator-toolbar.js.map +1 -1
- package/build/components/collab-sidebar/comments.js +220 -169
- package/build/components/collab-sidebar/comments.js.map +1 -1
- package/build/components/collab-sidebar/hooks.js +96 -0
- package/build/components/collab-sidebar/hooks.js.map +1 -0
- package/build/components/collab-sidebar/index.js +79 -169
- package/build/components/collab-sidebar/index.js.map +1 -1
- package/build/components/collab-sidebar/utils.js +72 -25
- package/build/components/collab-sidebar/utils.js.map +1 -1
- package/build/components/header/index.js +5 -1
- package/build/components/header/index.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +1 -1
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/dataviews/store/private-actions.js +1 -1
- package/build/dataviews/store/private-actions.js.map +1 -1
- package/build/store/actions.js +63 -2
- package/build/store/actions.js.map +1 -1
- package/build-module/components/collab-sidebar/add-comment.js +11 -5
- package/build-module/components/collab-sidebar/add-comment.js.map +1 -1
- package/build-module/components/collab-sidebar/comment-author-info.js +42 -14
- package/build-module/components/collab-sidebar/comment-author-info.js.map +1 -1
- package/build-module/components/collab-sidebar/comment-form.js +26 -22
- package/build-module/components/collab-sidebar/comment-form.js.map +1 -1
- package/build-module/components/collab-sidebar/comment-indicator-toolbar.js +8 -5
- package/build-module/components/collab-sidebar/comment-indicator-toolbar.js.map +1 -1
- package/build-module/components/collab-sidebar/comments.js +223 -172
- package/build-module/components/collab-sidebar/comments.js.map +1 -1
- package/build-module/components/collab-sidebar/hooks.js +89 -0
- package/build-module/components/collab-sidebar/hooks.js.map +1 -0
- package/build-module/components/collab-sidebar/index.js +82 -172
- package/build-module/components/collab-sidebar/index.js.map +1 -1
- package/build-module/components/collab-sidebar/utils.js +70 -24
- package/build-module/components/collab-sidebar/utils.js.map +1 -1
- package/build-module/components/header/index.js +5 -1
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +1 -1
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/dataviews/store/private-actions.js +2 -2
- package/build-module/dataviews/store/private-actions.js.map +1 -1
- package/build-module/store/actions.js +63 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-style/style-rtl.css +60 -19
- package/build-style/style.css +60 -19
- package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comment-author-info.d.ts +3 -1
- package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comment-form.d.ts +3 -5
- package/build-types/components/collab-sidebar/comment-form.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/comments.d.ts +1 -7
- package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/hooks.d.ts +6 -0
- package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/utils.d.ts +11 -6
- package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/store/actions.d.ts.map +1 -1
- package/package.json +37 -37
- package/src/components/collab-sidebar/add-comment.js +9 -4
- package/src/components/collab-sidebar/comment-author-info.js +51 -28
- package/src/components/collab-sidebar/comment-form.js +25 -24
- package/src/components/collab-sidebar/comment-indicator-toolbar.js +16 -5
- package/src/components/collab-sidebar/comments.js +271 -210
- package/src/components/collab-sidebar/hooks.js +95 -0
- package/src/components/collab-sidebar/index.js +107 -218
- package/src/components/collab-sidebar/style.scss +34 -20
- package/src/components/collab-sidebar/utils.js +73 -30
- package/src/components/header/index.js +6 -3
- package/src/components/provider/use-block-editor-settings.js +1 -0
- package/src/dataviews/store/private-actions.ts +6 -0
- package/src/store/actions.js +93 -2
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -46,28 +46,34 @@ function AddComment({
|
|
|
46
46
|
const selectedBlock = getSelectedBlock();
|
|
47
47
|
return {
|
|
48
48
|
clientId: selectedBlock?.clientId,
|
|
49
|
-
blockCommentId: selectedBlock?.attributes?.
|
|
49
|
+
blockCommentId: selectedBlock?.attributes?.metadata?.commentId,
|
|
50
50
|
isEmptyDefaultBlock: selectedBlock ? (0, _blocks.isUnmodifiedDefaultBlock)(selectedBlock) : false
|
|
51
51
|
};
|
|
52
52
|
});
|
|
53
53
|
if (!showCommentBoard || !clientId || undefined !== blockCommentId || isEmptyDefaultBlock) {
|
|
54
54
|
return null;
|
|
55
55
|
}
|
|
56
|
+
const commentLabel = (0, _i18n.__)('New Comment');
|
|
56
57
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
|
|
58
|
+
className: "editor-collab-sidebar-panel__thread is-selected",
|
|
57
59
|
spacing: "3",
|
|
58
|
-
|
|
60
|
+
tabIndex: 0,
|
|
61
|
+
role: "listitem",
|
|
59
62
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalHStack, {
|
|
60
63
|
alignment: "left",
|
|
61
64
|
spacing: "3",
|
|
62
65
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_commentAuthorInfo.default, {})
|
|
63
66
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_commentForm.default, {
|
|
64
67
|
onSubmit: inputComment => {
|
|
65
|
-
onSubmit(
|
|
68
|
+
onSubmit({
|
|
69
|
+
content: inputComment
|
|
70
|
+
});
|
|
66
71
|
},
|
|
67
72
|
onCancel: () => {
|
|
68
73
|
setShowCommentBoard(false);
|
|
69
74
|
},
|
|
70
|
-
submitButtonText: (0, _i18n._x)('Comment', 'Add comment button')
|
|
75
|
+
submitButtonText: (0, _i18n._x)('Comment', 'Add comment button'),
|
|
76
|
+
labelText: commentLabel
|
|
71
77
|
})]
|
|
72
78
|
});
|
|
73
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_data","_components","_blockEditor","_blocks","_commentAuthorInfo","_interopRequireDefault","_commentForm","_jsxRuntime","AddComment","onSubmit","showCommentBoard","setShowCommentBoard","clientId","blockCommentId","isEmptyDefaultBlock","useSelect","select","getSelectedBlock","blockEditorStore","selectedBlock","attributes","isUnmodifiedDefaultBlock","undefined","jsxs","__experimentalVStack","spacing","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_data","_components","_blockEditor","_blocks","_commentAuthorInfo","_interopRequireDefault","_commentForm","_jsxRuntime","AddComment","onSubmit","showCommentBoard","setShowCommentBoard","clientId","blockCommentId","isEmptyDefaultBlock","useSelect","select","getSelectedBlock","blockEditorStore","selectedBlock","attributes","metadata","commentId","isUnmodifiedDefaultBlock","undefined","commentLabel","__","jsxs","__experimentalVStack","className","spacing","tabIndex","role","children","jsx","__experimentalHStack","alignment","default","inputComment","content","onCancel","submitButtonText","_x","labelText"],"sources":["@wordpress/editor/src/components/collab-sidebar/add-comment.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport CommentAuthorInfo from './comment-author-info';\nimport CommentForm from './comment-form';\n\n/**\n * Renders the UI for adding a comment in the Gutenberg editor's collaboration sidebar.\n *\n * @param {Object} props - The component props.\n * @param {Function} props.onSubmit - A callback function to be called when the user submits a comment.\n * @param {boolean} props.showCommentBoard - The function to edit the comment.\n * @param {Function} props.setShowCommentBoard - The function to delete the comment.\n * @return {React.ReactNode} The rendered comment input UI.\n */\nexport function AddComment( {\n\tonSubmit,\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n} ) {\n\tconst { clientId, blockCommentId, isEmptyDefaultBlock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSelectedBlock } = select( blockEditorStore );\n\t\t\tconst selectedBlock = getSelectedBlock();\n\t\t\treturn {\n\t\t\t\tclientId: selectedBlock?.clientId,\n\t\t\t\tblockCommentId: selectedBlock?.attributes?.metadata?.commentId,\n\t\t\t\tisEmptyDefaultBlock: selectedBlock\n\t\t\t\t\t? isUnmodifiedDefaultBlock( selectedBlock )\n\t\t\t\t\t: false,\n\t\t\t};\n\t\t}\n\t);\n\n\tif (\n\t\t! showCommentBoard ||\n\t\t! clientId ||\n\t\tundefined !== blockCommentId ||\n\t\tisEmptyDefaultBlock\n\t) {\n\t\treturn null;\n\t}\n\n\tconst commentLabel = __( 'New Comment' );\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={ ( inputComment ) => {\n\t\t\t\t\tonSubmit( { content: inputComment } );\n\t\t\t\t} }\n\t\t\t\tonCancel={ () => {\n\t\t\t\t\tsetShowCommentBoard( false );\n\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IAAA,EAAC1B,WAAA,CAAA2B,oBAAM;IACNC,SAAS,EAAC,iDAAiD;IAC3DC,OAAO,EAAC,GAAG;IACXC,QAAQ,EAAG,CAAG;IACdC,IAAI,EAAC,UAAU;IAAAC,QAAA,gBAEf,IAAA1B,WAAA,CAAA2B,GAAA,EAACjC,WAAA,CAAAkC,oBAAM;MAACC,SAAS,EAAC,MAAM;MAACN,OAAO,EAAC,GAAG;MAAAG,QAAA,eACnC,IAAA1B,WAAA,CAAA2B,GAAA,EAAC9B,kBAAA,CAAAiC,OAAiB,IAAE;IAAC,CACd,CAAC,eACT,IAAA9B,WAAA,CAAA2B,GAAA,EAAC5B,YAAA,CAAA+B,OAAW;MACX5B,QAAQ,EAAK6B,YAAY,IAAM;QAC9B7B,QAAQ,CAAE;UAAE8B,OAAO,EAAED;QAAa,CAAE,CAAC;MACtC,CAAG;MACHE,QAAQ,EAAGA,CAAA,KAAM;QAChB7B,mBAAmB,CAAE,KAAM,CAAC;MAC7B,CAAG;MACH8B,gBAAgB,EAAG,IAAAC,QAAE,EAAE,SAAS,EAAE,oBAAqB,CAAG;MAC1DC,SAAS,EAAGlB;IAAc,CAC1B,CAAC;EAAA,CACK,CAAC;AAEX","ignoreList":[]}
|
|
@@ -10,11 +10,16 @@ var _date = require("@wordpress/date");
|
|
|
10
10
|
var _coreData = require("@wordpress/core-data");
|
|
11
11
|
var _data = require("@wordpress/data");
|
|
12
12
|
var _blockEditor = require("@wordpress/block-editor");
|
|
13
|
+
var _utils = require("./utils");
|
|
13
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
15
|
/**
|
|
15
16
|
* WordPress dependencies
|
|
16
17
|
*/
|
|
17
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Internal dependencies
|
|
21
|
+
*/
|
|
22
|
+
|
|
18
23
|
/**
|
|
19
24
|
* Render author information for a comment.
|
|
20
25
|
*
|
|
@@ -22,34 +27,50 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
22
27
|
* @param {string} props.avatar - URL of the author's avatar.
|
|
23
28
|
* @param {string} props.name - Name of the author.
|
|
24
29
|
* @param {string} props.date - Date of the comment.
|
|
30
|
+
* @param {string} props.userId - User ID of the author.
|
|
25
31
|
*
|
|
26
32
|
* @return {React.ReactNode} The JSX element representing the author's information.
|
|
27
33
|
*/function CommentAuthorInfo({
|
|
28
34
|
avatar,
|
|
29
35
|
name,
|
|
30
|
-
date
|
|
36
|
+
date,
|
|
37
|
+
userId
|
|
31
38
|
}) {
|
|
32
39
|
const dateSettings = (0, _date.getSettings)();
|
|
33
|
-
const [dateTimeFormat = dateSettings.formats.time] = (0, _coreData.useEntityProp)('root', 'site', 'time_format');
|
|
34
40
|
const {
|
|
35
41
|
currentUserAvatar,
|
|
36
|
-
currentUserName
|
|
42
|
+
currentUserName,
|
|
43
|
+
currentUserId,
|
|
44
|
+
dateFormat = dateSettings.formats.date
|
|
37
45
|
} = (0, _data.useSelect)(select => {
|
|
38
46
|
var _userData$avatar_urls;
|
|
39
|
-
const
|
|
47
|
+
const {
|
|
48
|
+
getCurrentUser,
|
|
49
|
+
getEntityRecord
|
|
50
|
+
} = select(_coreData.store);
|
|
40
51
|
const {
|
|
41
52
|
getSettings
|
|
42
53
|
} = select(_blockEditor.store);
|
|
54
|
+
const userData = getCurrentUser();
|
|
43
55
|
const {
|
|
44
56
|
__experimentalDiscussionSettings
|
|
45
57
|
} = getSettings();
|
|
46
58
|
const defaultAvatar = __experimentalDiscussionSettings?.avatarURL;
|
|
59
|
+
const siteSettings = getEntityRecord('root', 'site');
|
|
47
60
|
return {
|
|
48
61
|
currentUserAvatar: (_userData$avatar_urls = userData?.avatar_urls?.[48]) !== null && _userData$avatar_urls !== void 0 ? _userData$avatar_urls : defaultAvatar,
|
|
49
|
-
currentUserName: userData?.name
|
|
62
|
+
currentUserName: userData?.name,
|
|
63
|
+
currentUserId: userData?.id,
|
|
64
|
+
dateFormat: siteSettings?.date_format
|
|
50
65
|
};
|
|
51
66
|
}, []);
|
|
52
|
-
const
|
|
67
|
+
const commentDate = (0, _date.getDate)(date);
|
|
68
|
+
const commentDateTime = (0, _date.dateI18n)('c', commentDate);
|
|
69
|
+
const shouldShowHumanTimeDiff = Math.floor((new Date() - commentDate) / (1000 * 60 * 60 * 24)) < 30;
|
|
70
|
+
const commentDateText = shouldShowHumanTimeDiff ? (0, _date.humanTimeDiff)(commentDate) : (0, _date.dateI18n)(dateFormat, commentDate);
|
|
71
|
+
const tooltipText = (0, _date.dateI18n)(
|
|
72
|
+
// translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
|
|
73
|
+
(0, _i18n._x)('F j, Y g:i\xa0a', 'Comment date full date format'), date);
|
|
53
74
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
54
75
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
55
76
|
src: avatar !== null && avatar !== void 0 ? avatar : currentUserAvatar,
|
|
@@ -58,16 +79,23 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
58
79
|
,
|
|
59
80
|
alt: (0, _i18n.__)('User avatar'),
|
|
60
81
|
width: 32,
|
|
61
|
-
height: 32
|
|
82
|
+
height: 32,
|
|
83
|
+
style: {
|
|
84
|
+
borderColor: (0, _utils.getAvatarBorderColor)(userId !== null && userId !== void 0 ? userId : currentUserId)
|
|
85
|
+
}
|
|
62
86
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
|
|
63
87
|
spacing: "0",
|
|
64
88
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
65
89
|
className: "editor-collab-sidebar-panel__user-name",
|
|
66
90
|
children: name !== null && name !== void 0 ? name : currentUserName
|
|
67
|
-
}), /*#__PURE__*/(0, _jsxRuntime.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
children:
|
|
91
|
+
}), date && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tooltip, {
|
|
92
|
+
placement: "top",
|
|
93
|
+
text: tooltipText,
|
|
94
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("time", {
|
|
95
|
+
dateTime: commentDateTime,
|
|
96
|
+
className: "editor-collab-sidebar-panel__user-time",
|
|
97
|
+
children: commentDateText
|
|
98
|
+
})
|
|
71
99
|
})]
|
|
72
100
|
})]
|
|
73
101
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_date","_coreData","_data","_blockEditor","_jsxRuntime","CommentAuthorInfo","avatar","name","date","
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_date","_coreData","_data","_blockEditor","_utils","_jsxRuntime","CommentAuthorInfo","avatar","name","date","userId","dateSettings","getDateSettings","currentUserAvatar","currentUserName","currentUserId","dateFormat","formats","useSelect","select","_userData$avatar_urls","getCurrentUser","getEntityRecord","coreStore","getSettings","blockEditorStore","userData","__experimentalDiscussionSettings","defaultAvatar","avatarURL","siteSettings","avatar_urls","id","date_format","commentDate","getDate","commentDateTime","dateI18n","shouldShowHumanTimeDiff","Math","floor","Date","commentDateText","humanTimeDiff","tooltipText","_x","jsxs","Fragment","children","jsx","src","className","alt","__","width","height","style","borderColor","getAvatarBorderColor","__experimentalVStack","spacing","Tooltip","placement","text","dateTime","_default","exports","default"],"sources":["@wordpress/editor/src/components/collab-sidebar/comment-author-info.js"],"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', 'Comment 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"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAMA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AAA+C,IAAAO,WAAA,GAAAP,OAAA;AAlB/C;AACA;AACA;;AAaA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,SAASQ,iBAAiBA,CAAE;EAAEC,MAAM;EAAEC,IAAI;EAAEC,IAAI;EAAEC;AAAO,CAAC,EAAG;EAC5D,MAAMC,YAAY,GAAG,IAAAC,iBAAe,EAAC,CAAC;EACtC,MAAM;IACLC,iBAAiB;IACjBC,eAAe;IACfC,aAAa;IACbC,UAAU,GAAGL,YAAY,CAACM,OAAO,CAACR;EACnC,CAAC,GAAG,IAAAS,eAAS,EAAIC,MAAM,IAAM;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ED,oBACC,IAAAJ,WAAA,CAAAyC,IAAA,EAAAzC,WAAA,CAAA0C,QAAA;IAAAC,QAAA,gBACC,IAAA3C,WAAA,CAAA4C,GAAA;MACCC,GAAG,EAAG3C,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIM,iBAAmB;MACnCsC,SAAS,EAAC;MACV;MAAA;MACAC,GAAG,EAAG,IAAAC,QAAE,EAAE,aAAc,CAAG;MAC3BC,KAAK,EAAG,EAAI;MACZC,MAAM,EAAG,EAAI;MACbC,KAAK,EAAG;QACPC,WAAW,EAAE,IAAAC,2BAAoB,EAChChD,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIK,aACX;MACD;IAAG,CACH,CAAC,eACF,IAAAV,WAAA,CAAAyC,IAAA,EAACjD,WAAA,CAAA8D,oBAAM;MAACC,OAAO,EAAC,GAAG;MAAAZ,QAAA,gBAClB,IAAA3C,WAAA,CAAA4C,GAAA;QAAME,SAAS,EAAC,wCAAwC;QAAAH,QAAA,EACrDxC,IAAI,aAAJA,IAAI,cAAJA,IAAI,GAAIM;MAAe,CACpB,CAAC,EACLL,IAAI,iBACL,IAAAJ,WAAA,CAAA4C,GAAA,EAACpD,WAAA,CAAAgE,OAAO;QAACC,SAAS,EAAC,KAAK;QAACC,IAAI,EAAGnB,WAAa;QAAAI,QAAA,eAC5C,IAAA3C,WAAA,CAAA4C,GAAA;UACCe,QAAQ,EAAG5B,eAAiB;UAC5Be,SAAS,EAAC,wCAAwC;UAAAH,QAAA,EAEhDN;QAAe,CACZ;MAAC,CACC,CACT;IAAA,CACM,CAAC;EAAA,CACR,CAAC;AAEL;AAAC,IAAAuB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc7D,iBAAiB","ignoreList":[]}
|
|
@@ -32,51 +32,55 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
32
32
|
* @param {Function} props.onCancel - The function to call when canceling the comment update.
|
|
33
33
|
* @param {Object} props.thread - The comment thread object.
|
|
34
34
|
* @param {string} props.submitButtonText - The text to display on the submit button.
|
|
35
|
-
* @param {string?} props.
|
|
36
|
-
* @param {number?} props.rows - The number of rows for the comment input.
|
|
35
|
+
* @param {string?} props.labelText - The label text for the comment input.
|
|
37
36
|
* @return {React.ReactNode} The CommentForm component.
|
|
38
37
|
*/function CommentForm({
|
|
39
38
|
onSubmit,
|
|
40
39
|
onCancel,
|
|
41
40
|
thread,
|
|
42
41
|
submitButtonText,
|
|
43
|
-
|
|
44
|
-
rows = 4
|
|
42
|
+
labelText
|
|
45
43
|
}) {
|
|
46
44
|
var _thread$content$raw;
|
|
47
45
|
const [inputComment, setInputComment] = (0, _element.useState)((_thread$content$raw = thread?.content?.raw) !== null && _thread$content$raw !== void 0 ? _thread$content$raw : '');
|
|
48
46
|
const inputId = (0, _compose.useInstanceId)(CommentForm, 'comment-input');
|
|
49
|
-
|
|
47
|
+
const isDisabled = inputComment === thread?.content?.raw || !(0, _utils.sanitizeCommentString)(inputComment).length;
|
|
48
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
|
|
49
|
+
className: "editor-collab-sidebar-panel__comment-form",
|
|
50
|
+
spacing: "4",
|
|
50
51
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.VisuallyHidden, {
|
|
51
52
|
as: "label",
|
|
52
53
|
htmlFor: inputId,
|
|
53
|
-
children: (0, _i18n.__)('Comment')
|
|
54
|
+
children: labelText !== null && labelText !== void 0 ? labelText : (0, _i18n.__)('Comment')
|
|
54
55
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactAutosizeTextarea.default, {
|
|
55
56
|
id: inputId,
|
|
56
57
|
value: inputComment !== null && inputComment !== void 0 ? inputComment : '',
|
|
57
58
|
onChange: comment => setInputComment(comment.target.value),
|
|
58
|
-
rows:
|
|
59
|
-
maxRows: 20
|
|
60
|
-
placeholder: placeholderText || ''
|
|
59
|
+
rows: 1,
|
|
60
|
+
maxRows: 20
|
|
61
61
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
62
|
-
spacing: "
|
|
63
|
-
justify: "flex-
|
|
62
|
+
spacing: "2",
|
|
63
|
+
justify: "flex-end",
|
|
64
64
|
wrap: true,
|
|
65
65
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
66
|
-
|
|
66
|
+
size: "compact",
|
|
67
|
+
variant: "tertiary",
|
|
68
|
+
onClick: onCancel,
|
|
69
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalTruncate, {
|
|
70
|
+
children: (0, _i18n.__)('Cancel')
|
|
71
|
+
})
|
|
72
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
73
|
+
size: "compact",
|
|
67
74
|
accessibleWhenDisabled: true,
|
|
68
75
|
variant: "primary",
|
|
69
76
|
onClick: () => {
|
|
70
77
|
onSubmit(inputComment);
|
|
71
78
|
setInputComment('');
|
|
72
79
|
},
|
|
73
|
-
disabled:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
variant: "tertiary",
|
|
78
|
-
onClick: onCancel,
|
|
79
|
-
text: (0, _i18n._x)('Cancel', 'Cancel comment button')
|
|
80
|
+
disabled: isDisabled,
|
|
81
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalTruncate, {
|
|
82
|
+
children: submitButtonText
|
|
83
|
+
})
|
|
80
84
|
})]
|
|
81
85
|
})]
|
|
82
86
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactAutosizeTextarea","_interopRequireDefault","require","_element","_components","_i18n","_compose","_utils","_jsxRuntime","CommentForm","onSubmit","onCancel","thread","submitButtonText","
|
|
1
|
+
{"version":3,"names":["_reactAutosizeTextarea","_interopRequireDefault","require","_element","_components","_i18n","_compose","_utils","_jsxRuntime","CommentForm","onSubmit","onCancel","thread","submitButtonText","labelText","_thread$content$raw","inputComment","setInputComment","useState","content","raw","inputId","useInstanceId","isDisabled","sanitizeCommentString","length","jsxs","__experimentalVStack","className","spacing","children","jsx","VisuallyHidden","as","htmlFor","__","default","id","value","onChange","comment","target","rows","maxRows","__experimentalHStack","justify","wrap","Button","size","variant","onClick","__experimentalTruncate","accessibleWhenDisabled","disabled","_default","exports"],"sources":["@wordpress/editor/src/components/collab-sidebar/comment-form.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport TextareaAutosize from 'react-autosize-textarea';\n\n/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n\tButton,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { sanitizeCommentString } from './utils';\n\n/**\n * EditComment component.\n *\n * @param {Object} props - The component props.\n * @param {Function} props.onSubmit - The function to call when updating the comment.\n * @param {Function} props.onCancel - The function to call when canceling the comment update.\n * @param {Object} props.thread - The comment thread object.\n * @param {string} props.submitButtonText - The text to display on the submit button.\n * @param {string?} props.labelText - The label text for the comment input.\n * @return {React.ReactNode} The CommentForm component.\n */\nfunction CommentForm( {\n\tonSubmit,\n\tonCancel,\n\tthread,\n\tsubmitButtonText,\n\tlabelText,\n} ) {\n\tconst [ inputComment, setInputComment ] = useState(\n\t\tthread?.content?.raw ?? ''\n\t);\n\n\tconst inputId = useInstanceId( CommentForm, 'comment-input' );\n\tconst isDisabled =\n\t\tinputComment === thread?.content?.raw ||\n\t\t! sanitizeCommentString( inputComment ).length;\n\n\treturn (\n\t\t<VStack\n\t\t\tclassName=\"editor-collab-sidebar-panel__comment-form\"\n\t\t\tspacing=\"4\"\n\t\t>\n\t\t\t<VisuallyHidden as=\"label\" htmlFor={ inputId }>\n\t\t\t\t{ labelText ?? __( 'Comment' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<TextareaAutosize\n\t\t\t\tid={ inputId }\n\t\t\t\tvalue={ inputComment ?? '' }\n\t\t\t\tonChange={ ( comment ) =>\n\t\t\t\t\tsetInputComment( comment.target.value )\n\t\t\t\t}\n\t\t\t\trows={ 1 }\n\t\t\t\tmaxRows={ 20 }\n\t\t\t/>\n\t\t\t<HStack spacing=\"2\" justify=\"flex-end\" wrap>\n\t\t\t\t<Button size=\"compact\" variant=\"tertiary\" onClick={ onCancel }>\n\t\t\t\t\t<Truncate>{ __( 'Cancel' ) }</Truncate>\n\t\t\t\t</Button>\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonSubmit( inputComment );\n\t\t\t\t\t\tsetInputComment( '' );\n\t\t\t\t\t} }\n\t\t\t\t\tdisabled={ isDisabled }\n\t\t\t\t>\n\t\t\t\t\t<Truncate>{ submitButtonText }</Truncate>\n\t\t\t\t</Button>\n\t\t\t</HStack>\n\t\t</VStack>\n\t);\n}\n\nexport default CommentForm;\n"],"mappings":";;;;;;;AAGA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAOA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAAgD,IAAAM,WAAA,GAAAN,OAAA;AAtBhD;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,SAASO,WAAWA,CAAE;EACrBC,QAAQ;EACRC,QAAQ;EACRC,MAAM;EACNC,gBAAgB;EAChBC;AACD,CAAC,EAAG;EAAA,IAAAC,mBAAA;EACH,MAAM,CAAEC,YAAY,EAAEC,eAAe,CAAE,GAAG,IAAAC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OAAO,EAAGvC,QAAU;QAAAmB,QAAA,eAC7D,IAAAtB,WAAA,CAAAuB,GAAA,EAAC3B,WAAA,CAAA+C,sBAAQ;UAAArB,QAAA,EAAG,IAAAK,QAAE,EAAE,QAAS;QAAC,CAAY;MAAC,CAChC,CAAC,eACT,IAAA3B,WAAA,CAAAuB,GAAA,EAAC3B,WAAA,CAAA2C,MAAM;QACNC,IAAI,EAAC,SAAS;QACdI,sBAAsB;QACtBH,OAAO,EAAC,SAAS;QACjBC,OAAO,EAAGA,CAAA,KAAM;UACfxC,QAAQ,CAAEM,YAAa,CAAC;UACxBC,eAAe,CAAE,EAAG,CAAC;QACtB,CAAG;QACHoC,QAAQ,EAAG9B,UAAY;QAAAO,QAAA,eAEvB,IAAAtB,WAAA,CAAAuB,GAAA,EAAC3B,WAAA,CAAA+C,sBAAQ;UAAArB,QAAA,EAAGjB;QAAgB,CAAY;MAAC,CAClC,CAAC;IAAA,CACF,CAAC;EAAA,CACF,CAAC;AAEX;AAAC,IAAAyC,QAAA,GAAAC,OAAA,CAAAnB,OAAA,GAEc3B,WAAW","ignoreList":[]}
|
|
@@ -11,6 +11,7 @@ var _element = require("@wordpress/element");
|
|
|
11
11
|
var _blockEditor = require("@wordpress/block-editor");
|
|
12
12
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
13
13
|
var _lockUnlock = require("../../lock-unlock");
|
|
14
|
+
var _utils = require("./utils");
|
|
14
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
16
|
/**
|
|
16
17
|
* WordPress dependencies
|
|
@@ -49,6 +50,7 @@ const CommentAvatarIndicator = ({
|
|
|
49
50
|
participantsMap.set(authorKey, {
|
|
50
51
|
name: comment.author_name,
|
|
51
52
|
avatar: comment.author_avatar_urls?.['48'] || comment.author_avatar_urls?.['96'],
|
|
53
|
+
id: comment.author,
|
|
52
54
|
isOriginalCommenter: comment.id === thread.id,
|
|
53
55
|
date: comment.date
|
|
54
56
|
});
|
|
@@ -74,11 +76,11 @@ const CommentAvatarIndicator = ({
|
|
|
74
76
|
|
|
75
77
|
// If we hit the comment limit, show "100+" instead of exact overflow count.
|
|
76
78
|
const overflowText = threadHasMoreParticipants && overflowCount > 0 ? (0, _i18n.__)('100+') : (0, _i18n.sprintf)(
|
|
77
|
-
// translators: %s: Number of
|
|
79
|
+
// translators: %s: Number of participants.
|
|
78
80
|
(0, _i18n.__)('+%s'), overflowCount);
|
|
79
81
|
const overflowTitle = threadHasMoreParticipants && overflowCount > 0 ? (0, _i18n.__)('100+ participants') : (0, _i18n.sprintf)(
|
|
80
|
-
// translators: %s: Number of
|
|
81
|
-
(0, _i18n.
|
|
82
|
+
// translators: %s: Number of participants.
|
|
83
|
+
(0, _i18n._n)('+%s more participant', '+%s more participants', overflowCount), overflowCount);
|
|
82
84
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(CommentIconToolbarSlotFill.Fill, {
|
|
83
85
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarButton, {
|
|
84
86
|
className: (0, _clsx.default)('comment-avatar-indicator', {
|
|
@@ -94,7 +96,8 @@ const CommentAvatarIndicator = ({
|
|
|
94
96
|
alt: participant.name,
|
|
95
97
|
className: "comment-avatar",
|
|
96
98
|
style: {
|
|
97
|
-
zIndex: maxAvatars - index
|
|
99
|
+
zIndex: maxAvatars - index,
|
|
100
|
+
borderColor: (0, _utils.getAvatarBorderColor)(participant.id)
|
|
98
101
|
}
|
|
99
102
|
}, participant.name + index)), overflowCount > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
100
103
|
className: "comment-avatar-overflow",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_element","_blockEditor","_clsx","_interopRequireDefault","_lockUnlock","_jsxRuntime","CommentIconToolbarSlotFill","unlock","blockEditorPrivateApis","CommentAvatarIndicator","onClick","thread","hasMoreComments","threadParticipants","useMemo","participantsMap","Map","allComments","reply","sort","a","b","Date","date","forEach","comment","author_name","author_avatar_urls","authorKey","author","has","set","name","avatar","
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_element","_blockEditor","_clsx","_interopRequireDefault","_lockUnlock","_utils","_jsxRuntime","CommentIconToolbarSlotFill","unlock","blockEditorPrivateApis","CommentAvatarIndicator","onClick","thread","hasMoreComments","threadParticipants","useMemo","participantsMap","Map","allComments","reply","sort","a","b","Date","date","forEach","comment","author_name","author_avatar_urls","authorKey","author","has","set","name","avatar","id","isOriginalCommenter","Array","from","values","hasUnresolved","status","threadHasMoreParticipants","length","maxAvatars","visibleParticipants","slice","overflowCount","Math","max","overflowText","__","sprintf","overflowTitle","_n","jsx","Fill","children","ToolbarButton","className","clsx","label","_x","showTooltip","jsxs","map","participant","index","src","alt","style","zIndex","borderColor","getAvatarBorderColor","title","_default","exports","default"],"sources":["@wordpress/editor/src/components/collab-sidebar/comment-indicator-toolbar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToolbarButton } from '@wordpress/components';\nimport { _x, __, _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={ _x( 'View comments', 'View comment thread' ) }\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"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAKA,I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