@wordpress/editor 14.30.1-next.a730c9c8c.0 → 14.31.1-next.f56bd8138.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/collab-sidebar/comment-author-info.js +2 -2
  3. package/build/components/collab-sidebar/comment-author-info.js.map +1 -1
  4. package/build/components/collab-sidebar/comments.js +87 -25
  5. package/build/components/collab-sidebar/comments.js.map +1 -1
  6. package/build/components/collab-sidebar/index.js +4 -1
  7. package/build/components/collab-sidebar/index.js.map +1 -1
  8. package/build/components/post-excerpt/panel.js +5 -2
  9. package/build/components/post-excerpt/panel.js.map +1 -1
  10. package/build/components/post-template/hooks.js +20 -5
  11. package/build/components/post-template/hooks.js.map +1 -1
  12. package/build/components/post-type-support-check/index.js +12 -1
  13. package/build/components/post-type-support-check/index.js.map +1 -1
  14. package/build/components/provider/index.js +1 -1
  15. package/build/components/provider/index.js.map +1 -1
  16. package/build/dataviews/store/private-actions.js +1 -1
  17. package/build/dataviews/store/private-actions.js.map +1 -1
  18. package/build-module/components/collab-sidebar/comment-author-info.js +3 -3
  19. package/build-module/components/collab-sidebar/comment-author-info.js.map +1 -1
  20. package/build-module/components/collab-sidebar/comments.js +91 -30
  21. package/build-module/components/collab-sidebar/comments.js.map +1 -1
  22. package/build-module/components/collab-sidebar/index.js +4 -1
  23. package/build-module/components/collab-sidebar/index.js.map +1 -1
  24. package/build-module/components/post-excerpt/panel.js +5 -2
  25. package/build-module/components/post-excerpt/panel.js.map +1 -1
  26. package/build-module/components/post-template/hooks.js +20 -5
  27. package/build-module/components/post-template/hooks.js.map +1 -1
  28. package/build-module/components/post-type-support-check/index.js +11 -1
  29. package/build-module/components/post-type-support-check/index.js.map +1 -1
  30. package/build-module/components/provider/index.js +1 -1
  31. package/build-module/components/provider/index.js.map +1 -1
  32. package/build-module/dataviews/store/private-actions.js +1 -1
  33. package/build-module/dataviews/store/private-actions.js.map +1 -1
  34. package/build-style/style-rtl.css +13 -0
  35. package/build-style/style.css +13 -0
  36. package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -1
  37. package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
  38. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  39. package/build-types/components/post-template/hooks.d.ts +1 -1
  40. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  41. package/build-types/components/post-type-support-check/index.d.ts.map +1 -1
  42. package/build-types/components/provider/index.d.ts.map +1 -1
  43. package/package.json +37 -37
  44. package/src/components/collab-sidebar/comment-author-info.js +4 -1
  45. package/src/components/collab-sidebar/comments.js +97 -39
  46. package/src/components/collab-sidebar/index.js +3 -1
  47. package/src/components/collab-sidebar/style.scss +84 -84
  48. package/src/components/post-excerpt/panel.js +6 -1
  49. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
  50. package/src/components/post-template/hooks.js +23 -7
  51. package/src/components/post-type-support-check/index.js +18 -1
  52. package/src/components/post-type-support-check/test/index.js +37 -0
  53. package/src/components/provider/index.js +4 -1
  54. package/src/dataviews/store/private-actions.ts +1 -1
  55. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 14.31.0 (2025-09-17)
6
+
5
7
  ## 14.30.0 (2025-09-03)
6
8
 
7
9
  ## 14.29.0 (2025-08-20)
@@ -64,10 +64,10 @@ var _jsxRuntime = require("react/jsx-runtime");
64
64
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
65
65
  className: "editor-collab-sidebar-panel__user-name",
66
66
  children: name !== null && name !== void 0 ? name : currentUserName
67
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("time", {
67
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("time", {
68
68
  dateTime: (0, _date.dateI18n)('c', date ? (0, _date.getDate)(date) : currentDate),
69
69
  className: "editor-collab-sidebar-panel__user-time",
70
- children: (0, _date.dateI18n)(dateTimeFormat, date ? (0, _date.getDate)(date) : currentDate)
70
+ children: [(0, _date.dateI18n)(dateTimeFormat, date ? (0, _date.getDate)(date) : currentDate), /*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), (0, _date.humanTimeDiff)(date ? (0, _date.getDate)(date) : currentDate)]
71
71
  })]
72
72
  })]
73
73
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_i18n","_date","_coreData","_data","_blockEditor","_jsxRuntime","CommentAuthorInfo","avatar","name","date","dateSettings","getDateSettings","dateTimeFormat","formats","time","useEntityProp","currentUserAvatar","currentUserName","useSelect","select","_userData$avatar_urls","userData","coreStore","getCurrentUser","getSettings","blockEditorStore","__experimentalDiscussionSettings","defaultAvatar","avatarURL","avatar_urls","currentDate","Date","jsxs","Fragment","children","jsx","src","className","alt","__","width","height","__experimentalVStack","spacing","dateTime","dateI18n","getDate","_default","exports","default"],"sources":["@wordpress/editor/src/components/collab-sidebar/comment-author-info.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalVStack as VStack } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tdateI18n,\n\tgetDate,\n\tgetSettings as getDateSettings,\n} from '@wordpress/date';\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\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 *\n * @return {React.ReactNode} The JSX element representing the author's information.\n */\nfunction CommentAuthorInfo( { avatar, name, date } ) {\n\tconst dateSettings = getDateSettings();\n\tconst [ dateTimeFormat = dateSettings.formats.time ] = useEntityProp(\n\t\t'root',\n\t\t'site',\n\t\t'time_format'\n\t);\n\n\tconst { currentUserAvatar, currentUserName } = useSelect( ( select ) => {\n\t\tconst userData = select( coreStore ).getCurrentUser();\n\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\tconst defaultAvatar = __experimentalDiscussionSettings?.avatarURL;\n\t\treturn {\n\t\t\tcurrentUserAvatar: userData?.avatar_urls?.[ 48 ] ?? defaultAvatar,\n\t\t\tcurrentUserName: userData?.name,\n\t\t};\n\t}, [] );\n\n\tconst currentDate = new Date();\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/>\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<time\n\t\t\t\t\tdateTime={ dateI18n(\n\t\t\t\t\t\t'c',\n\t\t\t\t\t\tdate ? getDate( date ) : currentDate\n\t\t\t\t\t) }\n\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__user-time\"\n\t\t\t\t>\n\t\t\t\t\t{ dateI18n(\n\t\t\t\t\t\tdateTimeFormat,\n\t\t\t\t\t\tdate ? getDate( date ) : currentDate\n\t\t\t\t\t) }\n\t\t\t\t</time>\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;AAKA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AAAoE,IAAAM,WAAA,GAAAN,OAAA;AAZpE;AACA;AACA;;AA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AAI,CACb,CAAC,eACF,IAAApC,WAAA,CAAA2B,IAAA,EAAClC,WAAA,CAAA4C,oBAAM;MAACC,OAAO,EAAC,GAAG;MAAAT,QAAA,gBAClB,IAAA7B,WAAA,CAAA8B,GAAA;QAAME,SAAS,EAAC,wCAAwC;QAAAH,QAAA,EACrD1B,IAAI,aAAJA,IAAI,cAAJA,IAAI,GAAIS;MAAe,CACpB,CAAC,eACP,IAAAZ,WAAA,CAAA8B,GAAA;QACCS,QAAQ,EAAG,IAAAC,cAAQ,EAClB,GAAG,EACHpC,IAAI,GAAG,IAAAqC,aAAO,EAAErC,IAAK,CAAC,GAAGqB,WAC1B,CAAG;QACHO,SAAS,EAAC,wCAAwC;QAAAH,QAAA,EAEhD,IAAAW,cAAQ,EACTjC,cAAc,EACdH,IAAI,GAAG,IAAAqC,aAAO,EAAErC,IAAK,CAAC,GAAGqB,WAC1B;MAAC,CACI,CAAC;IAAA,CACA,CAAC;EAAA,CACR,CAAC;AAEL;AAAC,IAAAiB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc3C,iBAAiB","ignoreList":[]}
1
+ {"version":3,"names":["_components","require","_i18n","_date","_coreData","_data","_blockEditor","_jsxRuntime","CommentAuthorInfo","avatar","name","date","dateSettings","getDateSettings","dateTimeFormat","formats","time","useEntityProp","currentUserAvatar","currentUserName","useSelect","select","_userData$avatar_urls","userData","coreStore","getCurrentUser","getSettings","blockEditorStore","__experimentalDiscussionSettings","defaultAvatar","avatarURL","avatar_urls","currentDate","Date","jsxs","Fragment","children","jsx","src","className","alt","__","width","height","__experimentalVStack","spacing","dateTime","dateI18n","getDate","humanTimeDiff","_default","exports","default"],"sources":["@wordpress/editor/src/components/collab-sidebar/comment-author-info.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalVStack as VStack } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tdateI18n,\n\tgetSettings as getDateSettings,\n\thumanTimeDiff,\n\tgetDate,\n} from '@wordpress/date';\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\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 *\n * @return {React.ReactNode} The JSX element representing the author's information.\n */\nfunction CommentAuthorInfo( { avatar, name, date } ) {\n\tconst dateSettings = getDateSettings();\n\tconst [ dateTimeFormat = dateSettings.formats.time ] = useEntityProp(\n\t\t'root',\n\t\t'site',\n\t\t'time_format'\n\t);\n\n\tconst { currentUserAvatar, currentUserName } = useSelect( ( select ) => {\n\t\tconst userData = select( coreStore ).getCurrentUser();\n\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\tconst defaultAvatar = __experimentalDiscussionSettings?.avatarURL;\n\t\treturn {\n\t\t\tcurrentUserAvatar: userData?.avatar_urls?.[ 48 ] ?? defaultAvatar,\n\t\t\tcurrentUserName: userData?.name,\n\t\t};\n\t}, [] );\n\n\tconst currentDate = new Date();\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/>\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<time\n\t\t\t\t\tdateTime={ dateI18n(\n\t\t\t\t\t\t'c',\n\t\t\t\t\t\tdate ? getDate( date ) : currentDate\n\t\t\t\t\t) }\n\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__user-time\"\n\t\t\t\t>\n\t\t\t\t\t{ dateI18n(\n\t\t\t\t\t\tdateTimeFormat,\n\t\t\t\t\t\tdate ? getDate( date ) : currentDate\n\t\t\t\t\t) }\n\t\t\t\t\t<br />\n\t\t\t\t\t{ humanTimeDiff( date ? getDate( date ) : currentDate ) }\n\t\t\t\t</time>\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;AAAoE,IAAAM,WAAA,GAAAN,OAAA;AAbpE;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,SAASO,iBAAiBA,CAAE;EAAEC,MAAM;EAAEC,IAAI;EAAEC;AAAK,CAAC,EAAG;EACpD,MAAMC,YAAY,GAAG,IAAAC,iBAAe,EAAC,CAAC;EACtC,MAAM,CAAEC,cAAc,GAAGF,YAAY,CAACG,OAAO,CAACC,IAAI,CAAE,GAAG,IAAAC,uBAAa,EACnE,MAAM,EACN,MAAM,EACN,aACD,CAAC;EAED,MAAM;IAAEC,iBAAiB;IAAEC;EAAgB,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAAA,IAAAC,qBAAA;IACvE,MAAMC,QAAQ,GAAGF,MAAM,CAAEG,eAAU,CAAC,CAACC,cAAc,CAAC,CAAC;IAErD,MAAM;MAAEC;IAAY,CAAC,GAAGL,MAAM,CAAEM,kBAAiB,CAAC;IAClD,MAAM;MAAEC;IAAiC,CAAC,GAAGF,WAAW,CAAC,CAAC;IAC1D,MAAMG,aAAa,GAAGD,gCAAgC,EAAEE,SAAS;IACjE,OAAO;MACNZ,iBAAiB,GAAAI,qBAAA,GAAEC,QAAQ,EAA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A,CACA,CAAC;EAAA,CACR,CAAC;AAEL;AAAC,IAAAkB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc5C,iBAAiB","ignoreList":[]}
@@ -12,6 +12,7 @@ var _icons = require("@wordpress/icons");
12
12
  var _i18n = require("@wordpress/i18n");
13
13
  var _data = require("@wordpress/data");
14
14
  var _blockEditor = require("@wordpress/block-editor");
15
+ var _lockUnlock = require("../../lock-unlock");
15
16
  var _commentAuthorInfo = _interopRequireDefault(require("./comment-author-info"));
16
17
  var _commentForm = _interopRequireDefault(require("./comment-form"));
17
18
  var _jsxRuntime = require("react/jsx-runtime");
@@ -27,6 +28,32 @@ var _jsxRuntime = require("react/jsx-runtime");
27
28
  * Internal dependencies
28
29
  */
29
30
 
31
+ const {
32
+ useBlockElement
33
+ } = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
34
+
35
+ /**
36
+ * Finds the first block that has the specified comment ID.
37
+ *
38
+ * @param {string} commentId - The comment ID to search for.
39
+ * @param {Array} blockList - The list of blocks to search through.
40
+ * @return {string|null} The client ID of the found block, or null if not found.
41
+ */
42
+ const findBlockByCommentId = (commentId, blockList) => {
43
+ for (const block of blockList) {
44
+ if (block.attributes?.blockCommentId === commentId) {
45
+ return block.clientId;
46
+ }
47
+ if (block.innerBlocks) {
48
+ const found = findBlockByCommentId(commentId, block.innerBlocks);
49
+ if (found) {
50
+ return found;
51
+ }
52
+ }
53
+ }
54
+ return null;
55
+ };
56
+
30
57
  /**
31
58
  * Renders the Comments component.
32
59
  *
@@ -52,22 +79,34 @@ function Comments({
52
79
  setShowCommentBoard
53
80
  }) {
54
81
  const {
55
- blockCommentId
82
+ blockCommentId,
83
+ blocks
56
84
  } = (0, _data.useSelect)(select => {
57
85
  const {
58
86
  getBlockAttributes,
59
- getSelectedBlockClientId
87
+ getSelectedBlockClientId,
88
+ getBlocks
60
89
  } = select(_blockEditor.store);
61
90
  const _clientId = getSelectedBlockClientId();
62
91
  return {
63
- blockCommentId: _clientId ? getBlockAttributes(_clientId)?.blockCommentId : null
92
+ blockCommentId: _clientId ? getBlockAttributes(_clientId)?.blockCommentId : null,
93
+ blocks: getBlocks()
64
94
  };
65
95
  }, []);
66
- const [focusThread, setFocusThread] = (0, _element.useState)(showCommentBoard && blockCommentId ? blockCommentId : null);
96
+ const {
97
+ flashBlock
98
+ } = (0, _data.useDispatch)(_blockEditor.store);
67
99
  const clearThreadFocus = () => {
68
100
  setFocusThread(null);
69
101
  setShowCommentBoard(false);
70
102
  };
103
+ const [focusThread, setFocusThread] = (0, _element.useState)(showCommentBoard && blockCommentId ? blockCommentId : null);
104
+ (0, _element.useEffect)(() => {
105
+ // Highlight comment when block is selected.
106
+ if (blockCommentId && !focusThread) {
107
+ setFocusThread(blockCommentId);
108
+ }
109
+ }, [blockCommentId, focusThread, blocks, setFocusThread]);
71
110
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
72
111
  children: [
73
112
  // If there are no comments, show a message indicating no comments are available.
@@ -79,25 +118,20 @@ function Comments({
79
118
  children:
80
119
  // translators: message displayed when there are no comments available
81
120
  (0, _i18n.__)('No comments available')
82
- }), Array.isArray(threads) && threads.length > 0 && threads.map(thread => /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalVStack, {
83
- className: (0, _clsx.default)('editor-collab-sidebar-panel__thread', {
84
- 'editor-collab-sidebar-panel__active-thread': blockCommentId && blockCommentId === thread.id,
85
- 'editor-collab-sidebar-panel__focus-thread': focusThread && focusThread === thread.id
86
- }),
87
- id: thread.id,
88
- spacing: "3",
89
- onClick: () => setFocusThread(thread.id),
90
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Thread, {
91
- thread: thread,
92
- onAddReply: onAddReply,
93
- onCommentDelete: onCommentDelete,
94
- onCommentResolve: onCommentResolve,
95
- onCommentReopen: onCommentReopen,
96
- onEditComment: onEditComment,
97
- isFocused: focusThread === thread.id,
98
- clearThreadFocus: clearThreadFocus,
99
- setFocusThread: setFocusThread
100
- })
121
+ }), Array.isArray(threads) && threads.length > 0 && threads.map(thread => /*#__PURE__*/(0, _jsxRuntime.jsx)(Thread, {
122
+ thread: thread,
123
+ onAddReply: onAddReply,
124
+ onCommentDelete: onCommentDelete,
125
+ onCommentResolve: onCommentResolve,
126
+ onCommentReopen: onCommentReopen,
127
+ onEditComment: onEditComment,
128
+ isFocused: focusThread === thread.id,
129
+ clearThreadFocus: clearThreadFocus,
130
+ setFocusThread: setFocusThread,
131
+ blockCommentId: blockCommentId,
132
+ blocks: blocks,
133
+ flashBlock: flashBlock,
134
+ setShowCommentBoard: setShowCommentBoard
101
135
  }, thread.id))]
102
136
  });
103
137
  }
@@ -110,9 +144,37 @@ function Thread({
110
144
  onCommentReopen,
111
145
  isFocused,
112
146
  clearThreadFocus,
113
- setFocusThread
147
+ setFocusThread,
148
+ blocks,
149
+ flashBlock,
150
+ setShowCommentBoard
114
151
  }) {
115
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
152
+ // Find first block that has this comment ID - run at component root level.
153
+ const relatedBlock = (0, _element.useMemo)(() => {
154
+ if (!thread.id || !blocks) {
155
+ return null;
156
+ }
157
+ return findBlockByCommentId(thread.id, blocks);
158
+ }, [thread.id, blocks]);
159
+ const relatedBlockElement = useBlockElement(relatedBlock);
160
+ const handleCommentSelect = threadId => {
161
+ setShowCommentBoard(false);
162
+ setFocusThread(threadId);
163
+ if (relatedBlock && relatedBlockElement) {
164
+ relatedBlockElement.scrollIntoView({
165
+ behavior: 'instant',
166
+ block: 'center'
167
+ });
168
+ flashBlock(relatedBlock);
169
+ }
170
+ };
171
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
172
+ className: (0, _clsx.default)('editor-collab-sidebar-panel__thread', {
173
+ 'editor-collab-sidebar-panel__focus-thread': isFocused
174
+ }),
175
+ id: thread.id,
176
+ spacing: "3",
177
+ onClick: () => handleCommentSelect(thread.id),
116
178
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(CommentBoard, {
117
179
  thread: thread,
118
180
  onResolve: onCommentResolve,
@@ -1 +1 @@
1
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_element","_components","_icons","_i18n","_data","_blockEditor","_commentAuthorInfo","_commentForm","_jsxRuntime","Comments","threads","onEditComment","onAddReply","onCommentDelete","onCommentResolve","onCommentReopen","showCommentBoard","setShowCommentBoard","blockCommentId","useSelect","select","getBlockAttributes","getSelectedBlockClientId","blockEditorStore","_clientId","focusThread","setFocusThread","useState","clearThreadFocus","jsxs","Fragment","children","Array","isArray","length","jsx","__experimentalVStack","alignment","className","justify","spacing","__","map","thread","clsx","id","onClick","Thread","isFocused","CommentBoard","onResolve","onReopen","onEdit","onDelete","status","reply","Button","__next40pxDefaultSize","variant","sprintf","_n","__experimentalHStack","default","onSubmit","inputComment","onCancel","event","stopPropagation","placeholderText","submitButtonText","_x","rows","actionState","setActionState","showConfirmDialog","setShowConfirmDialog","handleConfirmDelete","handleCancel","actions","title","moreActions","filter","item","avatar","author_avatar_urls","name","author_name","date","parent","label","size","icon","published","disabled","accessibleWhenDisabled","DropdownMenu","moreVertical","controls","value","RawHTML","content","rendered","__experimentalConfirmDialog","isOpen","onConfirm","confirmButtonText"],"sources":["@wordpress/editor/src/components/collab-sidebar/comments.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useState, RawHTML } from '@wordpress/element';\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalConfirmDialog as ConfirmDialog,\n\tButton,\n\tDropdownMenu,\n} from '@wordpress/components';\nimport { published, moreVertical } from '@wordpress/icons';\nimport { __, _x, _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport CommentAuthorInfo from './comment-author-info';\nimport CommentForm from './comment-form';\n\n/**\n * Renders the Comments component.\n *\n * @param {Object} props - The component props.\n * @param {Array} props.threads - The array of comment threads.\n * @param {Function} props.onEditComment - The function to handle comment editing.\n * @param {Function} props.onAddReply - The function to add a reply to a comment.\n * @param {Function} props.onCommentDelete - The function to delete a comment.\n * @param {Function} props.onCommentResolve - The function to mark a comment as resolved.\n * @param {Function} props.onCommentReopen - The function to reopen a resolved comment.\n * @param {boolean} props.showCommentBoard - Whether to show the comment board.\n * @param {Function} props.setShowCommentBoard - The function to set the comment board visibility.\n * @return {React.ReactNode} The rendered Comments component.\n */\nexport function Comments( {\n\tthreads,\n\tonEditComment,\n\tonAddReply,\n\tonCommentDelete,\n\tonCommentResolve,\n\tonCommentReopen,\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n} ) {\n\tconst { blockCommentId } = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\t\tselect( blockEditorStore );\n\t\tconst _clientId = getSelectedBlockClientId();\n\n\t\treturn {\n\t\t\tblockCommentId: _clientId\n\t\t\t\t? getBlockAttributes( _clientId )?.blockCommentId\n\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst [ focusThread, setFocusThread ] = useState(\n\t\tshowCommentBoard && blockCommentId ? blockCommentId : null\n\t);\n\n\tconst clearThreadFocus = () => {\n\t\tsetFocusThread( null );\n\t\tsetShowCommentBoard( false );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t{\n\t\t\t\t// If there are no comments, show a message indicating no comments are available.\n\t\t\t\t( ! Array.isArray( threads ) || threads.length === 0 ) && (\n\t\t\t\t\t<VStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__thread\"\n\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t\tspacing=\"3\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// translators: message displayed when there are no comments available\n\t\t\t\t\t\t\t__( 'No comments available' )\n\t\t\t\t\t\t}\n\t\t\t\t\t</VStack>\n\t\t\t\t)\n\t\t\t}\n\t\t\t{ Array.isArray( threads ) &&\n\t\t\t\tthreads.length > 0 &&\n\t\t\t\tthreads.map( ( thread ) => (\n\t\t\t\t\t<VStack\n\t\t\t\t\t\tkey={ thread.id }\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'editor-collab-sidebar-panel__thread',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'editor-collab-sidebar-panel__active-thread':\n\t\t\t\t\t\t\t\t\tblockCommentId &&\n\t\t\t\t\t\t\t\t\tblockCommentId === thread.id,\n\t\t\t\t\t\t\t\t'editor-collab-sidebar-panel__focus-thread':\n\t\t\t\t\t\t\t\t\tfocusThread && focusThread === thread.id,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tid={ thread.id }\n\t\t\t\t\t\tspacing=\"3\"\n\t\t\t\t\t\tonClick={ () => setFocusThread( thread.id ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Thread\n\t\t\t\t\t\t\tthread={ thread }\n\t\t\t\t\t\t\tonAddReply={ onAddReply }\n\t\t\t\t\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\t\t\t\t\tonCommentResolve={ onCommentResolve }\n\t\t\t\t\t\t\tonCommentReopen={ onCommentReopen }\n\t\t\t\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\t\t\t\tisFocused={ focusThread === thread.id }\n\t\t\t\t\t\t\tclearThreadFocus={ clearThreadFocus }\n\t\t\t\t\t\t\tsetFocusThread={ setFocusThread }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction Thread( {\n\tthread,\n\tonEditComment,\n\tonAddReply,\n\tonCommentDelete,\n\tonCommentResolve,\n\tonCommentReopen,\n\tisFocused,\n\tclearThreadFocus,\n\tsetFocusThread,\n} ) {\n\treturn (\n\t\t<>\n\t\t\t<CommentBoard\n\t\t\t\tthread={ thread }\n\t\t\t\tonResolve={ onCommentResolve }\n\t\t\t\tonReopen={ onCommentReopen }\n\t\t\t\tonEdit={ onEditComment }\n\t\t\t\tonDelete={ onCommentDelete }\n\t\t\t\tstatus={ thread.status }\n\t\t\t/>\n\t\t\t{ 0 < thread?.reply?.length && (\n\t\t\t\t<>\n\t\t\t\t\t{ ! isFocused && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__show-more-reply\"\n\t\t\t\t\t\t\tonClick={ () => setFocusThread( thread.id ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: number of replies.\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'%s more reply',\n\t\t\t\t\t\t\t\t\t'%s more replies',\n\t\t\t\t\t\t\t\t\tthread?.reply?.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tthread?.reply?.length\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ isFocused &&\n\t\t\t\t\t\tthread.reply.map( ( reply ) => (\n\t\t\t\t\t\t\t<VStack\n\t\t\t\t\t\t\t\tkey={ reply.id }\n\t\t\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__child-thread\"\n\t\t\t\t\t\t\t\tid={ reply.id }\n\t\t\t\t\t\t\t\tspacing=\"2\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ 'approved' !== thread.status && (\n\t\t\t\t\t\t\t\t\t<CommentBoard\n\t\t\t\t\t\t\t\t\t\tthread={ reply }\n\t\t\t\t\t\t\t\t\t\tonEdit={ onEditComment }\n\t\t\t\t\t\t\t\t\t\tonDelete={ onCommentDelete }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ 'approved' === thread.status && (\n\t\t\t\t\t\t\t\t\t<CommentBoard thread={ reply } />\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t) ) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ isFocused && (\n\t\t\t\t<VStack\n\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__child-thread\"\n\t\t\t\t\tspacing=\"2\"\n\t\t\t\t>\n\t\t\t\t\t<HStack alignment=\"left\" spacing=\"3\" justify=\"flex-start\">\n\t\t\t\t\t\t<CommentAuthorInfo />\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<VStack\n\t\t\t\t\t\tspacing=\"3\"\n\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__comment-field\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<CommentForm\n\t\t\t\t\t\t\tonSubmit={ ( inputComment ) => {\n\t\t\t\t\t\t\t\tif ( 'approved' === thread.status ) {\n\t\t\t\t\t\t\t\t\tonCommentReopen( thread.id );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonAddReply( inputComment, thread.id );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonCancel={ ( event ) => {\n\t\t\t\t\t\t\t\tevent.stopPropagation(); // Prevent the parent onClick from being triggered\n\t\t\t\t\t\t\t\tclearThreadFocus();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tplaceholderText={\n\t\t\t\t\t\t\t\t'approved' === thread.status &&\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Adding a comment will re-open this discussion….'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsubmitButtonText={\n\t\t\t\t\t\t\t\t'approved' === thread.status\n\t\t\t\t\t\t\t\t\t? _x(\n\t\t\t\t\t\t\t\t\t\t\t'Reopen & Reply',\n\t\t\t\t\t\t\t\t\t\t\t'Reopen comment and add reply'\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: _x( 'Reply', 'Add reply comment' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trows={ 'approved' === thread.status ? 2 : 4 }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t</VStack>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nconst CommentBoard = ( {\n\tthread,\n\tonResolve,\n\tonReopen,\n\tonEdit,\n\tonDelete,\n\tstatus,\n} ) => {\n\tconst [ actionState, setActionState ] = useState( false );\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tconst handleConfirmDelete = () => {\n\t\tonDelete( thread.id );\n\t\tsetActionState( false );\n\t\tsetShowConfirmDialog( false );\n\t};\n\n\tconst handleCancel = () => {\n\t\tsetActionState( false );\n\t\tsetShowConfirmDialog( false );\n\t};\n\n\tconst actions = [\n\t\tonEdit &&\n\t\t\tstatus !== 'approved' && {\n\t\t\t\ttitle: _x( 'Edit', 'Edit comment' ),\n\t\t\t\tonClick: () => {\n\t\t\t\t\tsetActionState( 'edit' );\n\t\t\t\t},\n\t\t\t},\n\t\tonDelete && {\n\t\t\ttitle: _x( 'Delete', 'Delete comment' ),\n\t\t\tonClick: () => {\n\t\t\t\tsetActionState( 'delete' );\n\t\t\t\tsetShowConfirmDialog( true );\n\t\t\t},\n\t\t},\n\t\tonReopen &&\n\t\t\tstatus === 'approved' && {\n\t\t\t\ttitle: _x( 'Reopen', 'Reopen comment' ),\n\t\t\t\tonClick: () => {\n\t\t\t\t\tonReopen( thread.id );\n\t\t\t\t},\n\t\t\t},\n\t];\n\n\tconst moreActions = actions.filter( ( item ) => item?.onClick );\n\n\treturn (\n\t\t<>\n\t\t\t<HStack alignment=\"left\" spacing=\"3\" justify=\"flex-start\">\n\t\t\t\t<CommentAuthorInfo\n\t\t\t\t\tavatar={ thread?.author_avatar_urls?.[ 48 ] }\n\t\t\t\t\tname={ thread?.author_name }\n\t\t\t\t\tdate={ thread?.date }\n\t\t\t\t/>\n\t\t\t\t<span className=\"editor-collab-sidebar-panel__comment-status\">\n\t\t\t\t\t<HStack alignment=\"right\" justify=\"flex-end\" spacing=\"0\">\n\t\t\t\t\t\t{ 0 === thread?.parent && onResolve && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t\t'Resolve',\n\t\t\t\t\t\t\t\t\t'Mark comment as resolved'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\ticon={ published }\n\t\t\t\t\t\t\t\tdisabled={ status === 'approved' }\n\t\t\t\t\t\t\t\taccessibleWhenDisabled={ status === 'approved' }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonResolve( thread.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\t{ 0 < moreActions.length && (\n\t\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t\t'Select an action',\n\t\t\t\t\t\t\t\t\t'Select comment action'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__comment-dropdown-menu\"\n\t\t\t\t\t\t\t\tcontrols={ moreActions }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</HStack>\n\t\t\t\t</span>\n\t\t\t</HStack>\n\t\t\t{ 'edit' === actionState ? (\n\t\t\t\t<CommentForm\n\t\t\t\t\tonSubmit={ ( value ) => {\n\t\t\t\t\t\tonEdit( thread.id, value );\n\t\t\t\t\t\tsetActionState( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonCancel={ () => handleCancel() }\n\t\t\t\t\tthread={ thread }\n\t\t\t\t\tsubmitButtonText={ _x( 'Update', 'verb' ) }\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<RawHTML className=\"editor-collab-sidebar-panel__user-comment\">\n\t\t\t\t\t{ thread?.content?.rendered }\n\t\t\t\t</RawHTML>\n\t\t\t) }\n\t\t\t{ 'delete' === actionState && (\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\t\tonConfirm={ handleConfirmDelete }\n\t\t\t\t\tonCancel={ handleCancel }\n\t\t\t\t\tconfirmButtonText={ __( 'Delete' ) }\n\t\t\t\t>\n\t\t\t\t\t{\n\t\t\t\t\t\t// translators: message displayed when confirming an action\n\t\t\t\t\t\t__( 'Are you sure you want to delete this comment?' )\n\t\t\t\t\t}\n\t\t\t\t</ConfirmDialog>\n\t\t\t) }\n\t\t</>\n\t);\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAOA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAKA,IAAAO,kBAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,YAAA,GAAAT,sBAAA,CAAAC,OAAA;AAAyC,IAAAS,WAAA,GAAAT,OAAA;AAzBzC;AACA;AACA;;AAGA;AACA;AACA;;AAcA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASU,QAAQA,CAAE;EACzBC,OAAO;EACPC,aAAa;EACbC,UAAU;EACVC,eAAe;EACfC,gBAAgB;EAChBC,eAAe;EACfC,gBAAgB;EAChBC;AACD,CAAC,EAAG;EACH,MAAM;IAAEC;EAAe,CAAC,GAAG,IAAAC,eAAS,EAAI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,CAAG;YACHhC,SAAS,EAAC,oDAAoD;YAC9D2D,QAAQ,EAAGjB;UAAa,CACxB,CACD;QAAA,CACM;MAAC,CACJ,CAAC;IAAA,CACA,CAAC,EACP,MAAM,KAAKR,WAAW,gBACvB,IAAAhE,WAAA,CAAA2B,GAAA,EAAC5B,YAAA,CAAAuD,OAAW;MACXC,QAAQ,EAAKmC,KAAK,IAAM;QACvB9C,MAAM,CAAET,MAAM,CAACE,EAAE,EAAEqD,KAAM,CAAC;QAC1BzB,cAAc,CAAE,KAAM,CAAC;MACxB,CAAG;MACHR,QAAQ,EAAGA,CAAA,KAAMY,YAAY,CAAC,CAAG;MACjClC,MAAM,EAAGA,MAAQ;MACjB0B,gBAAgB,EAAG,IAAAC,QAAE,EAAE,QAAQ,EAAE,MAAO;IAAG,CAC3C,CAAC,gBAEF,IAAA9D,WAAA,CAAA2B,GAAA,EAACnC,QAAA,CAAAmG,OAAO;MAAC7D,SAAS,EAAC,2CAA2C;MAAAP,QAAA,EAC3DY,MAAM,EAAEyD,OAAO,EAAEC;IAAQ,CACnB,CACT,EACC,QAAQ,KAAK7B,WAAW,iBACzB,IAAAhE,WAAA,CAAA2B,GAAA,EAAClC,WAAA,CAAAqG,2BAAa;MACbC,MAAM,EAAG7B,iBAAmB;MAC5B8B,SAAS,EAAG5B,mBAAqB;MACjCX,QAAQ,EAAGY,YAAc;MACzB4B,iBAAiB,EAAG,IAAAhE,QAAE,EAAE,QAAS,CAAG;MAAAV,QAAA;MAGnC;MACA,IAAAU,QAAE,EAAE,+CAAgD;IAAC,CAExC,CACf;EAAA,CACA,CAAC;AAEL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_clsx","_interopRequireDefault","require","_element","_components","_icons","_i18n","_data","_blockEditor","_lockUnlock","_commentAuthorInfo","_commentForm","_jsxRuntime","useBlockElement","unlock","blockEditorPrivateApis","findBlockByCommentId","commentId","blockList","block","attributes","blockCommentId","clientId","innerBlocks","found","Comments","threads","onEditComment","onAddReply","onCommentDelete","onCommentResolve","onCommentReopen","showCommentBoard","setShowCommentBoard","blocks","useSelect","select","getBlockAttributes","getSelectedBlockClientId","getBlocks","blockEditorStore","_clientId","flashBlock","useDispatch","clearThreadFocus","setFocusThread","focusThread","useState","useEffect","jsxs","Fragment","children","Array","isArray","length","jsx","__experimentalVStack","alignment","className","justify","spacing","__","map","thread","Thread","isFocused","id","relatedBlock","useMemo","relatedBlockElement","handleCommentSelect","threadId","scrollIntoView","behavior","clsx","onClick","CommentBoard","onResolve","onReopen","onEdit","onDelete","status","reply","Button","__next40pxDefaultSize","variant","sprintf","_n","__experimentalHStack","default","onSubmit","inputComment","onCancel","event","stopPropagation","placeholderText","submitButtonText","_x","rows","actionState","setActionState","showConfirmDialog","setShowConfirmDialog","handleConfirmDelete","handleCancel","actions","title","moreActions","filter","item","avatar","author_avatar_urls","name","author_name","date","parent","label","size","icon","published","disabled","accessibleWhenDisabled","DropdownMenu","moreVertical","controls","value","RawHTML","content","rendered","__experimentalConfirmDialog","isOpen","onConfirm","confirmButtonText"],"sources":["@wordpress/editor/src/components/collab-sidebar/comments.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useState, RawHTML, useEffect, useMemo } from '@wordpress/element';\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalConfirmDialog as ConfirmDialog,\n\tButton,\n\tDropdownMenu,\n} from '@wordpress/components';\n\nimport { published, moreVertical } from '@wordpress/icons';\nimport { __, _x, sprintf, _n } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\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';\n\nconst { useBlockElement } = unlock( blockEditorPrivateApis );\n\n/**\n * Finds the first block that has the specified comment ID.\n *\n * @param {string} commentId - The comment ID to search for.\n * @param {Array} blockList - The list of blocks to search through.\n * @return {string|null} The client ID of the found block, or null if not found.\n */\nconst findBlockByCommentId = ( commentId, blockList ) => {\n\tfor ( const block of blockList ) {\n\t\tif ( block.attributes?.blockCommentId === commentId ) {\n\t\t\treturn block.clientId;\n\t\t}\n\t\tif ( block.innerBlocks ) {\n\t\t\tconst found = findBlockByCommentId( commentId, block.innerBlocks );\n\t\t\tif ( found ) {\n\t\t\t\treturn found;\n\t\t\t}\n\t\t}\n\t}\n\treturn null;\n};\n\n/**\n * Renders the Comments component.\n *\n * @param {Object} props - The component props.\n * @param {Array} props.threads - The array of comment threads.\n * @param {Function} props.onEditComment - The function to handle comment editing.\n * @param {Function} props.onAddReply - The function to add a reply to a comment.\n * @param {Function} props.onCommentDelete - The function to delete a comment.\n * @param {Function} props.onCommentResolve - The function to mark a comment as resolved.\n * @param {Function} props.onCommentReopen - The function to reopen a resolved comment.\n * @param {boolean} props.showCommentBoard - Whether to show the comment board.\n * @param {Function} props.setShowCommentBoard - The function to set the comment board visibility.\n * @return {React.ReactNode} The rendered Comments component.\n */\nexport function Comments( {\n\tthreads,\n\tonEditComment,\n\tonAddReply,\n\tonCommentDelete,\n\tonCommentResolve,\n\tonCommentReopen,\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n} ) {\n\tconst { blockCommentId, blocks } = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId, getBlocks } =\n\t\t\tselect( blockEditorStore );\n\t\tconst _clientId = getSelectedBlockClientId();\n\t\treturn {\n\t\t\tblockCommentId: _clientId\n\t\t\t\t? getBlockAttributes( _clientId )?.blockCommentId\n\t\t\t\t: null,\n\t\t\tblocks: getBlocks(),\n\t\t};\n\t}, [] );\n\n\tconst { flashBlock } = useDispatch( blockEditorStore );\n\n\tconst clearThreadFocus = () => {\n\t\tsetFocusThread( null );\n\t\tsetShowCommentBoard( false );\n\t};\n\n\tconst [ focusThread, setFocusThread ] = useState(\n\t\tshowCommentBoard && blockCommentId ? blockCommentId : null\n\t);\n\n\tuseEffect( () => {\n\t\t// Highlight comment when block is selected.\n\t\tif ( blockCommentId && ! focusThread ) {\n\t\t\tsetFocusThread( blockCommentId );\n\t\t}\n\t}, [ blockCommentId, focusThread, blocks, setFocusThread ] );\n\n\treturn (\n\t\t<>\n\t\t\t{\n\t\t\t\t// If there are no comments, show a message indicating no comments are available.\n\t\t\t\t( ! Array.isArray( threads ) || threads.length === 0 ) && (\n\t\t\t\t\t<VStack\n\t\t\t\t\t\talignment=\"left\"\n\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__thread\"\n\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t\tspacing=\"3\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// translators: message displayed when there are no comments available\n\t\t\t\t\t\t\t__( 'No comments available' )\n\t\t\t\t\t\t}\n\t\t\t\t\t</VStack>\n\t\t\t\t)\n\t\t\t}\n\t\t\t{ Array.isArray( threads ) &&\n\t\t\t\tthreads.length > 0 &&\n\t\t\t\tthreads.map( ( thread ) => (\n\t\t\t\t\t<Thread\n\t\t\t\t\t\tkey={ thread.id }\n\t\t\t\t\t\tthread={ thread }\n\t\t\t\t\t\tonAddReply={ onAddReply }\n\t\t\t\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\t\t\t\tonCommentResolve={ onCommentResolve }\n\t\t\t\t\t\tonCommentReopen={ onCommentReopen }\n\t\t\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\t\t\tisFocused={ focusThread === thread.id }\n\t\t\t\t\t\tclearThreadFocus={ clearThreadFocus }\n\t\t\t\t\t\tsetFocusThread={ setFocusThread }\n\t\t\t\t\t\tblockCommentId={ blockCommentId }\n\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\tflashBlock={ flashBlock }\n\t\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t</>\n\t);\n}\n\nfunction Thread( {\n\tthread,\n\tonEditComment,\n\tonAddReply,\n\tonCommentDelete,\n\tonCommentResolve,\n\tonCommentReopen,\n\tisFocused,\n\tclearThreadFocus,\n\tsetFocusThread,\n\tblocks,\n\tflashBlock,\n\tsetShowCommentBoard,\n} ) {\n\t// Find first block that has this comment ID - run at component root level.\n\tconst relatedBlock = useMemo( () => {\n\t\tif ( ! thread.id || ! blocks ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn findBlockByCommentId( thread.id, blocks );\n\t}, [ thread.id, blocks ] );\n\n\tconst relatedBlockElement = useBlockElement( relatedBlock );\n\n\tconst handleCommentSelect = ( threadId ) => {\n\t\tsetShowCommentBoard( false );\n\t\tsetFocusThread( threadId );\n\t\tif ( relatedBlock && relatedBlockElement ) {\n\t\t\trelatedBlockElement.scrollIntoView( {\n\t\t\t\tbehavior: 'instant',\n\t\t\t\tblock: 'center',\n\t\t\t} );\n\t\t\tflashBlock( relatedBlock );\n\t\t}\n\t};\n\n\treturn (\n\t\t<VStack\n\t\t\tclassName={ clsx( 'editor-collab-sidebar-panel__thread', {\n\t\t\t\t'editor-collab-sidebar-panel__focus-thread': isFocused,\n\t\t\t} ) }\n\t\t\tid={ thread.id }\n\t\t\tspacing=\"3\"\n\t\t\tonClick={ () => handleCommentSelect( thread.id ) }\n\t\t>\n\t\t\t<CommentBoard\n\t\t\t\tthread={ thread }\n\t\t\t\tonResolve={ onCommentResolve }\n\t\t\t\tonReopen={ onCommentReopen }\n\t\t\t\tonEdit={ onEditComment }\n\t\t\t\tonDelete={ onCommentDelete }\n\t\t\t\tstatus={ thread.status }\n\t\t\t/>\n\t\t\t{ 0 < thread?.reply?.length && (\n\t\t\t\t<>\n\t\t\t\t\t{ ! isFocused && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__show-more-reply\"\n\t\t\t\t\t\t\tonClick={ () => setFocusThread( thread.id ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: number of replies.\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'%s more reply',\n\t\t\t\t\t\t\t\t\t'%s more replies',\n\t\t\t\t\t\t\t\t\tthread?.reply?.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tthread?.reply?.length\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ isFocused &&\n\t\t\t\t\t\tthread.reply.map( ( reply ) => (\n\t\t\t\t\t\t\t<VStack\n\t\t\t\t\t\t\t\tkey={ reply.id }\n\t\t\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__child-thread\"\n\t\t\t\t\t\t\t\tid={ reply.id }\n\t\t\t\t\t\t\t\tspacing=\"2\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ 'approved' !== thread.status && (\n\t\t\t\t\t\t\t\t\t<CommentBoard\n\t\t\t\t\t\t\t\t\t\tthread={ reply }\n\t\t\t\t\t\t\t\t\t\tonEdit={ onEditComment }\n\t\t\t\t\t\t\t\t\t\tonDelete={ onCommentDelete }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ 'approved' === thread.status && (\n\t\t\t\t\t\t\t\t\t<CommentBoard thread={ reply } />\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t) ) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ isFocused && (\n\t\t\t\t<VStack\n\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__child-thread\"\n\t\t\t\t\tspacing=\"2\"\n\t\t\t\t>\n\t\t\t\t\t<HStack alignment=\"left\" spacing=\"3\" justify=\"flex-start\">\n\t\t\t\t\t\t<CommentAuthorInfo />\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<VStack\n\t\t\t\t\t\tspacing=\"3\"\n\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__comment-field\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<CommentForm\n\t\t\t\t\t\t\tonSubmit={ ( inputComment ) => {\n\t\t\t\t\t\t\t\tif ( 'approved' === thread.status ) {\n\t\t\t\t\t\t\t\t\tonCommentReopen( thread.id );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonAddReply( inputComment, thread.id );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonCancel={ ( event ) => {\n\t\t\t\t\t\t\t\tevent.stopPropagation(); // Prevent the parent onClick from being triggered\n\t\t\t\t\t\t\t\tclearThreadFocus();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tplaceholderText={\n\t\t\t\t\t\t\t\t'approved' === thread.status &&\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Adding a comment will re-open this discussion….'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsubmitButtonText={\n\t\t\t\t\t\t\t\t'approved' === thread.status\n\t\t\t\t\t\t\t\t\t? _x(\n\t\t\t\t\t\t\t\t\t\t\t'Reopen & Reply',\n\t\t\t\t\t\t\t\t\t\t\t'Reopen comment and add reply'\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: _x( 'Reply', 'Add reply comment' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trows={ 'approved' === thread.status ? 2 : 4 }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t</VStack>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nconst CommentBoard = ( {\n\tthread,\n\tonResolve,\n\tonReopen,\n\tonEdit,\n\tonDelete,\n\tstatus,\n} ) => {\n\tconst [ actionState, setActionState ] = useState( false );\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tconst handleConfirmDelete = () => {\n\t\tonDelete( thread.id );\n\t\tsetActionState( false );\n\t\tsetShowConfirmDialog( false );\n\t};\n\n\tconst handleCancel = () => {\n\t\tsetActionState( false );\n\t\tsetShowConfirmDialog( false );\n\t};\n\n\tconst actions = [\n\t\tonEdit &&\n\t\t\tstatus !== 'approved' && {\n\t\t\t\ttitle: _x( 'Edit', 'Edit comment' ),\n\t\t\t\tonClick: () => {\n\t\t\t\t\tsetActionState( 'edit' );\n\t\t\t\t},\n\t\t\t},\n\t\tonDelete && {\n\t\t\ttitle: _x( 'Delete', 'Delete comment' ),\n\t\t\tonClick: () => {\n\t\t\t\tsetActionState( 'delete' );\n\t\t\t\tsetShowConfirmDialog( true );\n\t\t\t},\n\t\t},\n\t\tonReopen &&\n\t\t\tstatus === 'approved' && {\n\t\t\t\ttitle: _x( 'Reopen', 'Reopen comment' ),\n\t\t\t\tonClick: () => {\n\t\t\t\t\tonReopen( thread.id );\n\t\t\t\t},\n\t\t\t},\n\t];\n\n\tconst moreActions = actions.filter( ( item ) => item?.onClick );\n\n\treturn (\n\t\t<>\n\t\t\t<HStack alignment=\"left\" spacing=\"3\" justify=\"flex-start\">\n\t\t\t\t<CommentAuthorInfo\n\t\t\t\t\tavatar={ thread?.author_avatar_urls?.[ 48 ] }\n\t\t\t\t\tname={ thread?.author_name }\n\t\t\t\t\tdate={ thread?.date }\n\t\t\t\t/>\n\t\t\t\t<span className=\"editor-collab-sidebar-panel__comment-status\">\n\t\t\t\t\t<HStack alignment=\"right\" justify=\"flex-end\" spacing=\"0\">\n\t\t\t\t\t\t{ 0 === thread?.parent && onResolve && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t\t'Resolve',\n\t\t\t\t\t\t\t\t\t'Mark comment as resolved'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\ticon={ published }\n\t\t\t\t\t\t\t\tdisabled={ status === 'approved' }\n\t\t\t\t\t\t\t\taccessibleWhenDisabled={ status === 'approved' }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonResolve( thread.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\t{ 0 < moreActions.length && (\n\t\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t\t'Select an action',\n\t\t\t\t\t\t\t\t\t'Select comment action'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__comment-dropdown-menu\"\n\t\t\t\t\t\t\t\tcontrols={ moreActions }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</HStack>\n\t\t\t\t</span>\n\t\t\t</HStack>\n\t\t\t{ 'edit' === actionState ? (\n\t\t\t\t<CommentForm\n\t\t\t\t\tonSubmit={ ( value ) => {\n\t\t\t\t\t\tonEdit( thread.id, value );\n\t\t\t\t\t\tsetActionState( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonCancel={ () => handleCancel() }\n\t\t\t\t\tthread={ thread }\n\t\t\t\t\tsubmitButtonText={ _x( 'Update', 'verb' ) }\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<RawHTML className=\"editor-collab-sidebar-panel__user-comment\">\n\t\t\t\t\t{ thread?.content?.rendered }\n\t\t\t\t</RawHTML>\n\t\t\t) }\n\t\t\t{ 'delete' === actionState && (\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\t\tonConfirm={ handleConfirmDelete }\n\t\t\t\t\tonCancel={ handleCancel }\n\t\t\t\t\tconfirmButtonText={ __( 'Delete' ) }\n\t\t\t\t>\n\t\t\t\t\t{\n\t\t\t\t\t\t// translators: message displayed when confirming an action\n\t\t\t\t\t\t__( 'Are you sure you want to delete this comment?' )\n\t\t\t\t\t}\n\t\t\t\t</ConfirmDialog>\n\t\t\t) }\n\t\t</>\n\t);\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAQA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAQA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,YAAA,GAAAV,sBAAA,CAAAC,OAAA;AAAyC,IAAAU,WAAA,GAAAV,OAAA;AA9BzC;AACA;AACA;;AAGA;AACA;AACA;;AAkBA;AACA;AACA;;AAKA,MAAM;EAAEW;AAAgB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,GAAGA,CAAEC,SAAS,EAAEC,SAAS,KAAM;EACxD,KAAM,MAAMC,KAAK,IAAID,SAAS,EAAG;IAChC,IAAKC,KAAK,CAACC,UAAU,EAAEC,cAAc,KAAKJ,SAAS,EAAG;MACrD,OAAOE,KAAK,CAACG,QAAQ;IACtB;IACA,IAAKH,KAAK,CAACI,WAAW,EAAG;MACxB,MAAMC,KAAK,GAAGR,oBAAoB,CAAEC,SAAS,EAAEE,KAAK,CAACI,WAAY,CAAC;MAClE,IAAKC,KAAK,EAAG;QACZ,OAAOA,KAAK;MACb;IACD;EACD;EACA,OAAO,IAAI;AACZ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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E,QAAQ,EAAGjB;UAAa,CACxB,CACD;QAAA,CACM;MAAC,CACJ,CAAC;IAAA,CACA,CAAC,EACP,MAAM,KAAKR,WAAW,gBACvB,IAAAvF,WAAA,CAAA2C,GAAA,EAAC5C,YAAA,CAAA8E,OAAW;MACXC,QAAQ,EAAKmC,KAAK,IAAM;QACvB9C,MAAM,CAAEhB,MAAM,CAACG,EAAE,EAAE2D,KAAM,CAAC;QAC1BzB,cAAc,CAAE,KAAM,CAAC;MACxB,CAAG;MACHR,QAAQ,EAAGA,CAAA,KAAMY,YAAY,CAAC,CAAG;MACjCzC,MAAM,EAAGA,MAAQ;MACjBiC,gBAAgB,EAAG,IAAAC,QAAE,EAAE,QAAQ,EAAE,MAAO;IAAG,CAC3C,CAAC,gBAEF,IAAArF,WAAA,CAAA2C,GAAA,EAACpD,QAAA,CAAA2H,OAAO;MAACpE,SAAS,EAAC,2CAA2C;MAAAP,QAAA,EAC3DY,MAAM,EAAEgE,OAAO,EAAEC;IAAQ,CACnB,CACT,EACC,QAAQ,KAAK7B,WAAW,iBACzB,IAAAvF,WAAA,CAAA2C,GAAA,EAACnD,WAAA,CAAA6H,2BAAa;MACbC,MAAM,EAAG7B,iBAAmB;MAC5B8B,SAAS,EAAG5B,mBAAqB;MACjCX,QAAQ,EAAGY,YAAc;MACzB4B,iBAAiB,EAAG,IAAAvE,QAAE,EAAE,QAAS,CAAG;MAAAV,QAAA;MAGnC;MACA,IAAAU,QAAE,EAAE,+CAAgD;IAAC,CAExC,CACf;EAAA,CACA,CAAC;AAEL,CAAC","ignoreList":[]}
@@ -234,7 +234,9 @@ function CollabSidebar() {
234
234
  const {
235
235
  records: threads,
236
236
  totalPages
237
- } = (0, _coreData.useEntityRecords)('root', 'comment', queryArgs);
237
+ } = (0, _coreData.useEntityRecords)('root', 'comment', queryArgs, {
238
+ enabled: !!postId && typeof postId === 'number'
239
+ });
238
240
  const hasMoreComments = totalPages && totalPages > 1;
239
241
  const {
240
242
  blockCommentId
@@ -339,6 +341,7 @@ function CollabSidebar() {
339
341
  ,
340
342
  title: (0, _i18n.__)('Comments'),
341
343
  icon: _icons.comment,
344
+ closeLabel: (0, _i18n.__)('Close Comments'),
342
345
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CollabSidebarContent, {
343
346
  comments: resultComments,
344
347
  showCommentBoard: showCommentBoard,
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_data","_element","_icons","_hooks","_notices","_coreData","_blockEditor","_interface","_pluginSidebar","_interopRequireDefault","_constants","_comments","_addComment","_store","_commentButton","_commentIndicatorToolbar","_globalStylesProvider","_utils","_jsxRuntime","modifyBlockCommentAttributes","settings","attributes","blockCommentId","type","addFilter","CollabSidebarContent","showCommentBoard","setShowCommentBoard","styles","comments","createNotice","useDispatch","noticesStore","saveEntityRecord","deleteEntityRecord","coreStore","getEntityRecord","resolveSelect","postId","useSelect","select","getCurrentPostId","editorStore","_postId","getSelectedBlockClientId","blockEditorStore","updateBlockAttributes","onError","error","errorMessage","message","code","__","isDismissible","addNewComment","comment","parentCommentId","savedRecord","post","content","comment_type","comment_approved","parent","throwOnError","id","onCommentResolve","commentId","status","onCommentReopen","onEditComment","onCommentDelete","childComment","undefined","jsxs","className","style","children","jsx","AddComment","onSubmit","Comments","threads","onAddReply","CollabSidebar","useState","enableComplementaryArea","interfaceStore","getActiveComplementaryArea","postType","getCurrentPostType","queryArgs","per_page","records","totalPages","useEntityRecords","hasMoreComments","getBlockAttributes","_clientId","openCollabBoard","collabHistorySidebarName","blocks","useEntityBlockEditor","resultComments","unresolvedSortedThreads","useMemo","compare","result","allComments","forEach","item","reply","push","length","updatedResult","map","reverse","blockCommentIds","getCommentIdsFromBlocks","threadIdMap","Map","thread","unresolvedSortedComments","get","filter","merged","GlobalStyles","useGlobalStylesContext","backgroundColor","color","background","unsubscribe","subscribe","activeSidebar","collabSidebarName","AddCommentComponent","CommentAvatarIndicator","AddCommentButton","currentThread","find","Fragment","onClick","default","identifier","title","icon","commentIcon","isPinnable","header","headerClassName"],"sources":["@wordpress/editor/src/components/collab-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseSelect,\n\tuseDispatch,\n\tresolveSelect,\n\tsubscribe,\n} from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as noticesStore } from '@wordpress/notices';\nimport {\n\tstore as coreStore,\n\tuseEntityBlockEditor,\n\tuseEntityRecords,\n} from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PluginSidebar from '../plugin-sidebar';\nimport { collabHistorySidebarName, collabSidebarName } from './constants';\nimport { Comments } from './comments';\nimport { AddComment } from './add-comment';\nimport { store as editorStore } from '../../store';\nimport AddCommentButton from './comment-button';\nimport CommentAvatarIndicator from './comment-indicator-toolbar';\nimport { useGlobalStylesContext } from '../global-styles-provider';\nimport { getCommentIdsFromBlocks } from './utils';\n\nconst modifyBlockCommentAttributes = ( settings ) => {\n\tif ( ! settings.attributes.blockCommentId ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tblockCommentId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n};\n\n// Apply the filter to all core blocks\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-comment/modify-core-block-attributes',\n\tmodifyBlockCommentAttributes\n);\n\nfunction CollabSidebarContent( {\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tstyles,\n\tcomments,\n} ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getEntityRecord } = resolveSelect( coreStore );\n\n\tconst { postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t};\n\t}, [] );\n\n\tconst { getSelectedBlockClientId } = useSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst onError = ( error ) => {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'An error occurred while performing an update.' );\n\t\tcreateNotice( 'error', errorMessage, {\n\t\t\ttype: 'snackbar',\n\t\t\tisDismissible: true,\n\t\t} );\n\t};\n\n\tconst addNewComment = async ( comment, parentCommentId ) => {\n\t\ttry {\n\t\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\t{\n\t\t\t\t\tpost: postId,\n\t\t\t\t\tcontent: comment,\n\t\t\t\t\tcomment_type: 'block_comment',\n\t\t\t\t\tcomment_approved: 0,\n\t\t\t\t\t...( parentCommentId ? { parent: parentCommentId } : {} ),\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\t// If it's a main comment, update the block attributes with the comment id.\n\t\t\tif ( ! parentCommentId && savedRecord?.id ) {\n\t\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\t\tblockCommentId: savedRecord.id,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tparentCommentId\n\t\t\t\t\t? __( 'Reply added successfully.' )\n\t\t\t\t\t: __( 'Comment added successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onCommentResolve = async ( commentId ) => {\n\t\ttry {\n\t\t\tawait saveEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\t{\n\t\t\t\t\tid: commentId,\n\t\t\t\t\tstatus: 'approved',\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tcreateNotice( 'snackbar', __( 'Comment marked as resolved.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onCommentReopen = async ( commentId ) => {\n\t\ttry {\n\t\t\tawait saveEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\t{\n\t\t\t\t\tid: commentId,\n\t\t\t\t\tstatus: 'hold',\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tcreateNotice( 'snackbar', __( 'Comment reopened.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onEditComment = async ( commentId, comment ) => {\n\t\ttry {\n\t\t\tawait saveEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\t{\n\t\t\t\t\tid: commentId,\n\t\t\t\t\tcontent: comment,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tcreateNotice( 'snackbar', __( 'Comment edited successfully.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onCommentDelete = async ( commentId ) => {\n\t\ttry {\n\t\t\tconst childComment = await getEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\tcommentId\n\t\t\t);\n\t\t\tawait deleteEntityRecord( 'root', 'comment', commentId, undefined, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\n\t\t\tif ( childComment && ! childComment.parent ) {\n\t\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\t\tblockCommentId: undefined,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice( 'snackbar', __( 'Comment deleted successfully.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\treturn (\n\t\t<div className=\"editor-collab-sidebar-panel\" style={ styles }>\n\t\t\t<AddComment\n\t\t\t\tonSubmit={ addNewComment }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t\t<Comments\n\t\t\t\tkey={ getSelectedBlockClientId() }\n\t\t\t\tthreads={ comments }\n\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\tonAddReply={ addNewComment }\n\t\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\t\tonCommentResolve={ onCommentResolve }\n\t\t\t\tonCommentReopen={ onCommentReopen }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\n/**\n * Renders the Collab sidebar.\n */\nexport default function CollabSidebar() {\n\tconst [ showCommentBoard, setShowCommentBoard ] = useState( false );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst { getActiveComplementaryArea } = useSelect( interfaceStore );\n\n\tconst { postId, postType } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\tconst queryArgs = {\n\t\tpost: postId,\n\t\ttype: 'block_comment',\n\t\tstatus: 'all',\n\t\tper_page: 100,\n\t};\n\n\tconst { records: threads, totalPages } = useEntityRecords(\n\t\t'root',\n\t\t'comment',\n\t\tqueryArgs\n\t);\n\n\tconst hasMoreComments = totalPages && totalPages > 1;\n\n\tconst { blockCommentId } = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\t\tselect( blockEditorStore );\n\t\tconst _clientId = getSelectedBlockClientId();\n\n\t\treturn {\n\t\t\tblockCommentId: _clientId\n\t\t\t\t? getBlockAttributes( _clientId )?.blockCommentId\n\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst openCollabBoard = () => {\n\t\tsetShowCommentBoard( true );\n\t\tenableComplementaryArea( 'core', collabHistorySidebarName );\n\t};\n\n\tconst [ blocks ] = useEntityBlockEditor( 'postType', postType, {\n\t\tid: postId,\n\t} );\n\n\t// Process comments to build the tree structure.\n\tconst { resultComments, unresolvedSortedThreads } = useMemo( () => {\n\t\t// Create a compare to store the references to all objects by id.\n\t\tconst compare = {};\n\t\tconst result = [];\n\n\t\tconst allComments = threads ?? [];\n\n\t\t// Initialize each object with an empty `reply` array.\n\t\tallComments.forEach( ( item ) => {\n\t\t\tcompare[ item.id ] = { ...item, reply: [] };\n\t\t} );\n\n\t\t// Iterate over the data to build the tree structure.\n\t\tallComments.forEach( ( item ) => {\n\t\t\tif ( item.parent === 0 ) {\n\t\t\t\t// If parent is 0, it's a root item, push it to the result array.\n\t\t\t\tresult.push( compare[ item.id ] );\n\t\t\t} else if ( compare[ item.parent ] ) {\n\t\t\t\t// Otherwise, find its parent and push it to the parent's `reply` array.\n\t\t\t\tcompare[ item.parent ].reply.push( compare[ item.id ] );\n\t\t\t}\n\t\t} );\n\n\t\tif ( 0 === result?.length ) {\n\t\t\treturn { resultComments: [], unresolvedSortedThreads: [] };\n\t\t}\n\n\t\tconst updatedResult = result.map( ( item ) => ( {\n\t\t\t...item,\n\t\t\treply: [ ...item.reply ].reverse(),\n\t\t} ) );\n\n\t\tconst blockCommentIds = getCommentIdsFromBlocks( blocks );\n\n\t\tconst threadIdMap = new Map(\n\t\t\tupdatedResult.map( ( thread ) => [ thread.id, thread ] )\n\t\t);\n\n\t\t// Get comments by block order, filter out undefined threads, and exclude resolved comments.\n\t\tconst unresolvedSortedComments = blockCommentIds\n\t\t\t.map( ( id ) => threadIdMap.get( id ) )\n\t\t\t.filter(\n\t\t\t\t( thread ) =>\n\t\t\t\t\tthread !== undefined && thread.status !== 'approved'\n\t\t\t);\n\n\t\treturn {\n\t\t\tresultComments: updatedResult,\n\t\t\tunresolvedSortedThreads: unresolvedSortedComments,\n\t\t};\n\t}, [ threads, blocks ] );\n\n\t// Get the global styles to set the background color of the sidebar.\n\tconst { merged: GlobalStyles } = useGlobalStylesContext();\n\tconst backgroundColor = GlobalStyles?.styles?.color?.background;\n\n\tif ( 0 < resultComments.length ) {\n\t\tconst unsubscribe = subscribe( () => {\n\t\t\tconst activeSidebar = getActiveComplementaryArea( 'core' );\n\n\t\t\tif ( ! activeSidebar ) {\n\t\t\t\tenableComplementaryArea( 'core', collabSidebarName );\n\t\t\t\tunsubscribe();\n\t\t\t}\n\t\t} );\n\t}\n\n\tconst AddCommentComponent = blockCommentId\n\t\t? CommentAvatarIndicator\n\t\t: AddCommentButton;\n\n\t// Find the current thread for the selected block.\n\tconst currentThread = blockCommentId\n\t\t? resultComments.find( ( thread ) => thread.id === blockCommentId )\n\t\t: null;\n\n\t// If postId is not a valid number, do not render the comment sidebar.\n\tif ( ! ( !! postId && typeof postId === 'number' ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<AddCommentComponent\n\t\t\t\tonClick={ openCollabBoard }\n\t\t\t\tthread={ currentThread }\n\t\t\t\thasMoreComments={ hasMoreComments }\n\t\t\t/>\n\t\t\t<PluginSidebar\n\t\t\t\tidentifier={ collabHistorySidebarName }\n\t\t\t\t// translators: Comments sidebar title\n\t\t\t\ttitle={ __( 'Comments' ) }\n\t\t\t\ticon={ commentIcon }\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ resultComments }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t\t<PluginSidebar\n\t\t\t\tisPinnable={ false }\n\t\t\t\theader={ false }\n\t\t\t\tidentifier={ collabSidebarName }\n\t\t\t\tclassName=\"editor-collab-sidebar\"\n\t\t\t\theaderClassName=\"editor-collab-sidebar__header\"\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ unresolvedSortedThreads }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\tstyles={ {\n\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAMA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAKA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAKA,IAAAS,cAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,UAAA,GAAAX,OAAA;AACA,IAAAY,SAAA,GAAAZ,OAAA;AACA,IAAAa,WAAA,GAAAb,OAAA;AACA,IAAAc,MAAA,GAAAd,OAAA;AACA,IAAAe,cAAA,GAAAL,sBAAA,CAAAV,OAAA;AACA,IAAAgB,wBAAA,GAAAN,sBAAA,CAAAV,OAAA;AACA,IAAAiB,qBAAA,GAAAjB,OAAA;AACA,IAAAkB,MAAA,GAAAlB,OAAA;AAAkD,IAAAmB,WAAA,GAAAnB,OAAA;AAjClD;AACA;AACA;;AAoBA;AACA;AACA;;AAWA,MAAMoB,4BAA4B,GAAKC,QAA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C,GACjE,IAAI;;EAEP;EACA,IAAK,EAAI,CAAC,CAAEgB,MAAM,IAAI,OAAOA,MAAM,KAAK,QAAQ,CAAE,EAAG;IACpD,OAAO,IAAI;EACZ;EAEA,oBACC,IAAApB,WAAA,CAAAuD,IAAA,EAAAvD,WAAA,CAAAyH,QAAA;IAAA/D,QAAA,gBACC,IAAA1D,WAAA,CAAA2D,GAAA,EAACyD,mBAAmB;MACnBM,OAAO,EAAG1C,eAAiB;MAC3BsB,MAAM,EAAGiB,aAAe;MACxB1C,eAAe,EAAGA;IAAiB,CACnC,CAAC,eACF,IAAA7E,WAAA,CAAA2D,GAAA,EAACrE,cAAA,CAAAqI,OAAa;MACbC,UAAU,EAAG3C;MACb;MAAA;MACA4C,KAAK,EAAG,IAAA3F,QAAE,EAAE,UAAW,CAAG;MAC1B4F,IAAI,EAAGC,cAAa;MAAArE,QAAA,eAEpB,IAAA1D,WAAA,CAAA2D,GAAA,EAACpD,oBAAoB;QACpBI,QAAQ,EAAGyE,cAAgB;QAC3B5E,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA;MAAqB,CAC3C;IAAC,CACY,CAAC,eAChB,IAAAT,WAAA,CAAA2D,GAAA,EAACrE,cAAA,CAAAqI,OAAa;MACbK,UAAU,EAAG,KAAO;MACpBC,MAAM,EAAG,KAAO;MAChBL,UAAU,EAAGT,4BAAmB;MAChC3D,SAAS,EAAC,uBAAuB;MACjC0E,eAAe,EAAC,+BAA+B;MAAAxE,QAAA,eAE/C,IAAA1D,WAAA,CAAA2D,GAAA,EAACpD,oBAAoB;QACpBI,QAAQ,EAAG0E,uBAAyB;QACpC7E,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA,mBAAqB;QAC3CC,MAAM,EAAG;UACRmG;QACD;MAAG,CACH;IAAC,CACY,CAAC;EAAA,CACf,CAAC;AAEL","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_data","_element","_icons","_hooks","_notices","_coreData","_blockEditor","_interface","_pluginSidebar","_interopRequireDefault","_constants","_comments","_addComment","_store","_commentButton","_commentIndicatorToolbar","_globalStylesProvider","_utils","_jsxRuntime","modifyBlockCommentAttributes","settings","attributes","blockCommentId","type","addFilter","CollabSidebarContent","showCommentBoard","setShowCommentBoard","styles","comments","createNotice","useDispatch","noticesStore","saveEntityRecord","deleteEntityRecord","coreStore","getEntityRecord","resolveSelect","postId","useSelect","select","getCurrentPostId","editorStore","_postId","getSelectedBlockClientId","blockEditorStore","updateBlockAttributes","onError","error","errorMessage","message","code","__","isDismissible","addNewComment","comment","parentCommentId","savedRecord","post","content","comment_type","comment_approved","parent","throwOnError","id","onCommentResolve","commentId","status","onCommentReopen","onEditComment","onCommentDelete","childComment","undefined","jsxs","className","style","children","jsx","AddComment","onSubmit","Comments","threads","onAddReply","CollabSidebar","useState","enableComplementaryArea","interfaceStore","getActiveComplementaryArea","postType","getCurrentPostType","queryArgs","per_page","records","totalPages","useEntityRecords","enabled","hasMoreComments","getBlockAttributes","_clientId","openCollabBoard","collabHistorySidebarName","blocks","useEntityBlockEditor","resultComments","unresolvedSortedThreads","useMemo","compare","result","allComments","forEach","item","reply","push","length","updatedResult","map","reverse","blockCommentIds","getCommentIdsFromBlocks","threadIdMap","Map","thread","unresolvedSortedComments","get","filter","merged","GlobalStyles","useGlobalStylesContext","backgroundColor","color","background","unsubscribe","subscribe","activeSidebar","collabSidebarName","AddCommentComponent","CommentAvatarIndicator","AddCommentButton","currentThread","find","Fragment","onClick","default","identifier","title","icon","commentIcon","closeLabel","isPinnable","header","headerClassName"],"sources":["@wordpress/editor/src/components/collab-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseSelect,\n\tuseDispatch,\n\tresolveSelect,\n\tsubscribe,\n} from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as noticesStore } from '@wordpress/notices';\nimport {\n\tstore as coreStore,\n\tuseEntityBlockEditor,\n\tuseEntityRecords,\n} from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PluginSidebar from '../plugin-sidebar';\nimport { collabHistorySidebarName, collabSidebarName } from './constants';\nimport { Comments } from './comments';\nimport { AddComment } from './add-comment';\nimport { store as editorStore } from '../../store';\nimport AddCommentButton from './comment-button';\nimport CommentAvatarIndicator from './comment-indicator-toolbar';\nimport { useGlobalStylesContext } from '../global-styles-provider';\nimport { getCommentIdsFromBlocks } from './utils';\n\nconst modifyBlockCommentAttributes = ( settings ) => {\n\tif ( ! settings.attributes.blockCommentId ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tblockCommentId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n};\n\n// Apply the filter to all core blocks\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-comment/modify-core-block-attributes',\n\tmodifyBlockCommentAttributes\n);\n\nfunction CollabSidebarContent( {\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tstyles,\n\tcomments,\n} ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getEntityRecord } = resolveSelect( coreStore );\n\n\tconst { postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t};\n\t}, [] );\n\n\tconst { getSelectedBlockClientId } = useSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst onError = ( error ) => {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'An error occurred while performing an update.' );\n\t\tcreateNotice( 'error', errorMessage, {\n\t\t\ttype: 'snackbar',\n\t\t\tisDismissible: true,\n\t\t} );\n\t};\n\n\tconst addNewComment = async ( comment, parentCommentId ) => {\n\t\ttry {\n\t\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\t{\n\t\t\t\t\tpost: postId,\n\t\t\t\t\tcontent: comment,\n\t\t\t\t\tcomment_type: 'block_comment',\n\t\t\t\t\tcomment_approved: 0,\n\t\t\t\t\t...( parentCommentId ? { parent: parentCommentId } : {} ),\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\t// If it's a main comment, update the block attributes with the comment id.\n\t\t\tif ( ! parentCommentId && savedRecord?.id ) {\n\t\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\t\tblockCommentId: savedRecord.id,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tparentCommentId\n\t\t\t\t\t? __( 'Reply added successfully.' )\n\t\t\t\t\t: __( 'Comment added successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onCommentResolve = async ( commentId ) => {\n\t\ttry {\n\t\t\tawait saveEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\t{\n\t\t\t\t\tid: commentId,\n\t\t\t\t\tstatus: 'approved',\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tcreateNotice( 'snackbar', __( 'Comment marked as resolved.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onCommentReopen = async ( commentId ) => {\n\t\ttry {\n\t\t\tawait saveEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\t{\n\t\t\t\t\tid: commentId,\n\t\t\t\t\tstatus: 'hold',\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tcreateNotice( 'snackbar', __( 'Comment reopened.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onEditComment = async ( commentId, comment ) => {\n\t\ttry {\n\t\t\tawait saveEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\t{\n\t\t\t\t\tid: commentId,\n\t\t\t\t\tcontent: comment,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tcreateNotice( 'snackbar', __( 'Comment edited successfully.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onCommentDelete = async ( commentId ) => {\n\t\ttry {\n\t\t\tconst childComment = await getEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\tcommentId\n\t\t\t);\n\t\t\tawait deleteEntityRecord( 'root', 'comment', commentId, undefined, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\n\t\t\tif ( childComment && ! childComment.parent ) {\n\t\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\t\tblockCommentId: undefined,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice( 'snackbar', __( 'Comment deleted successfully.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\treturn (\n\t\t<div className=\"editor-collab-sidebar-panel\" style={ styles }>\n\t\t\t<AddComment\n\t\t\t\tonSubmit={ addNewComment }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t\t<Comments\n\t\t\t\tkey={ getSelectedBlockClientId() }\n\t\t\t\tthreads={ comments }\n\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\tonAddReply={ addNewComment }\n\t\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\t\tonCommentResolve={ onCommentResolve }\n\t\t\t\tonCommentReopen={ onCommentReopen }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\n/**\n * Renders the Collab sidebar.\n */\nexport default function CollabSidebar() {\n\tconst [ showCommentBoard, setShowCommentBoard ] = useState( false );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst { getActiveComplementaryArea } = useSelect( interfaceStore );\n\n\tconst { postId, postType } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\tconst queryArgs = {\n\t\tpost: postId,\n\t\ttype: 'block_comment',\n\t\tstatus: 'all',\n\t\tper_page: 100,\n\t};\n\n\tconst { records: threads, totalPages } = useEntityRecords(\n\t\t'root',\n\t\t'comment',\n\t\tqueryArgs,\n\t\t{ enabled: !! postId && typeof postId === 'number' }\n\t);\n\n\tconst hasMoreComments = totalPages && totalPages > 1;\n\n\tconst { blockCommentId } = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\t\tselect( blockEditorStore );\n\t\tconst _clientId = getSelectedBlockClientId();\n\n\t\treturn {\n\t\t\tblockCommentId: _clientId\n\t\t\t\t? getBlockAttributes( _clientId )?.blockCommentId\n\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst openCollabBoard = () => {\n\t\tsetShowCommentBoard( true );\n\t\tenableComplementaryArea( 'core', collabHistorySidebarName );\n\t};\n\n\tconst [ blocks ] = useEntityBlockEditor( 'postType', postType, {\n\t\tid: postId,\n\t} );\n\n\t// Process comments to build the tree structure.\n\tconst { resultComments, unresolvedSortedThreads } = useMemo( () => {\n\t\t// Create a compare to store the references to all objects by id.\n\t\tconst compare = {};\n\t\tconst result = [];\n\n\t\tconst allComments = threads ?? [];\n\n\t\t// Initialize each object with an empty `reply` array.\n\t\tallComments.forEach( ( item ) => {\n\t\t\tcompare[ item.id ] = { ...item, reply: [] };\n\t\t} );\n\n\t\t// Iterate over the data to build the tree structure.\n\t\tallComments.forEach( ( item ) => {\n\t\t\tif ( item.parent === 0 ) {\n\t\t\t\t// If parent is 0, it's a root item, push it to the result array.\n\t\t\t\tresult.push( compare[ item.id ] );\n\t\t\t} else if ( compare[ item.parent ] ) {\n\t\t\t\t// Otherwise, find its parent and push it to the parent's `reply` array.\n\t\t\t\tcompare[ item.parent ].reply.push( compare[ item.id ] );\n\t\t\t}\n\t\t} );\n\n\t\tif ( 0 === result?.length ) {\n\t\t\treturn { resultComments: [], unresolvedSortedThreads: [] };\n\t\t}\n\n\t\tconst updatedResult = result.map( ( item ) => ( {\n\t\t\t...item,\n\t\t\treply: [ ...item.reply ].reverse(),\n\t\t} ) );\n\n\t\tconst blockCommentIds = getCommentIdsFromBlocks( blocks );\n\n\t\tconst threadIdMap = new Map(\n\t\t\tupdatedResult.map( ( thread ) => [ thread.id, thread ] )\n\t\t);\n\n\t\t// Get comments by block order, filter out undefined threads, and exclude resolved comments.\n\t\tconst unresolvedSortedComments = blockCommentIds\n\t\t\t.map( ( id ) => threadIdMap.get( id ) )\n\t\t\t.filter(\n\t\t\t\t( thread ) =>\n\t\t\t\t\tthread !== undefined && thread.status !== 'approved'\n\t\t\t);\n\n\t\treturn {\n\t\t\tresultComments: updatedResult,\n\t\t\tunresolvedSortedThreads: unresolvedSortedComments,\n\t\t};\n\t}, [ threads, blocks ] );\n\n\t// Get the global styles to set the background color of the sidebar.\n\tconst { merged: GlobalStyles } = useGlobalStylesContext();\n\tconst backgroundColor = GlobalStyles?.styles?.color?.background;\n\n\tif ( 0 < resultComments.length ) {\n\t\tconst unsubscribe = subscribe( () => {\n\t\t\tconst activeSidebar = getActiveComplementaryArea( 'core' );\n\n\t\t\tif ( ! activeSidebar ) {\n\t\t\t\tenableComplementaryArea( 'core', collabSidebarName );\n\t\t\t\tunsubscribe();\n\t\t\t}\n\t\t} );\n\t}\n\n\tconst AddCommentComponent = blockCommentId\n\t\t? CommentAvatarIndicator\n\t\t: AddCommentButton;\n\n\t// Find the current thread for the selected block.\n\tconst currentThread = blockCommentId\n\t\t? resultComments.find( ( thread ) => thread.id === blockCommentId )\n\t\t: null;\n\n\t// If postId is not a valid number, do not render the comment sidebar.\n\tif ( ! ( !! postId && typeof postId === 'number' ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<AddCommentComponent\n\t\t\t\tonClick={ openCollabBoard }\n\t\t\t\tthread={ currentThread }\n\t\t\t\thasMoreComments={ hasMoreComments }\n\t\t\t/>\n\t\t\t<PluginSidebar\n\t\t\t\tidentifier={ collabHistorySidebarName }\n\t\t\t\t// translators: Comments sidebar title\n\t\t\t\ttitle={ __( 'Comments' ) }\n\t\t\t\ticon={ commentIcon }\n\t\t\t\tcloseLabel={ __( 'Close Comments' ) }\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ resultComments }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t\t<PluginSidebar\n\t\t\t\tisPinnable={ false }\n\t\t\t\theader={ false }\n\t\t\t\tidentifier={ collabSidebarName }\n\t\t\t\tclassName=\"editor-collab-sidebar\"\n\t\t\t\theaderClassName=\"editor-collab-sidebar__header\"\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ unresolvedSortedThreads }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\tstyles={ {\n\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAMA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAKA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAKA,IAAAS,cAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,UAAA,GAAAX,OAAA;AACA,IAAAY,SAAA,GAAAZ,OAAA;AACA,IAAAa,WAAA,GAAAb,OAAA;AACA,IAAAc,MAAA,GAAAd,OAAA;AACA,IAAAe,cAAA,GAAAL,sBAAA,CAAAV,OAAA;AACA,IAAAgB,wBAAA,GAAAN,sBAAA,CAAAV,OAAA;AACA,IAAAiB,qBAAA,GAAAjB,OAAA;AACA,IAAAkB,MAAA,GAAAlB,OAAA;AAAkD,IAAAmB,WAAA,GAAAnB,OAAA;AAjClD;AACA;AACA;;AAoBA;AACA;AACA;;AAWA,MAAMoB,4BAA4B,GAAKC,QAAQ,IAAM;EACpD,IAAK,CAAEA,QAAQ,CAACC,UAAU,CAACC,cAAc,EAAG;IAC3CF,QAAQ,CAACC,UAAU,GAAG;MACrB,GAAGD,QAAQ,CAACC,UAAU;MACtBC,cAAc,EAAE;QACfC,IAAI,EAAE;MACP;IACD,CAAC;EACF;EAEA,OAAOH,QAAQ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EA,oBACC,IAAApB,WAAA,CAAAuD,IAAA,EAAAvD,WAAA,CAAA0H,QAAA;IAAAhE,QAAA,gBACC,IAAA1D,WAAA,CAAA2D,GAAA,EAAC0D,mBAAmB;MACnBM,OAAO,EAAG1C,eAAiB;MAC3BsB,MAAM,EAAGiB,aAAe;MACxB1C,eAAe,EAAGA;IAAiB,CACnC,CAAC,eACF,IAAA9E,WAAA,CAAA2D,GAAA,EAACrE,cAAA,CAAAsI,OAAa;MACbC,UAAU,EAAG3C;MACb;MAAA;MACA4C,KAAK,EAAG,IAAA5F,QAAE,EAAE,UAAW,CAAG;MAC1B6F,IAAI,EAAGC,cAAa;MACpBC,UAAU,EAAG,IAAA/F,QAAE,EAAE,gBAAiB,CAAG;MAAAwB,QAAA,eAErC,IAAA1D,WAAA,CAAA2D,GAAA,EAACpD,oBAAoB;QACpBI,QAAQ,EAAG0E,cAAgB;QAC3B7E,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA;MAAqB,CAC3C;IAAC,CACY,CAAC,eAChB,IAAAT,WAAA,CAAA2D,GAAA,EAACrE,cAAA,CAAAsI,OAAa;MACbM,UAAU,EAAG,KAAO;MACpBC,MAAM,EAAG,KAAO;MAChBN,UAAU,EAAGT,4BAAmB;MAChC5D,SAAS,EAAC,uBAAuB;MACjC4E,eAAe,EAAC,+BAA+B;MAAA1E,QAAA,eAE/C,IAAA1D,WAAA,CAAA2D,GAAA,EAACpD,oBAAoB;QACpBI,QAAQ,EAAG2E,uBAAyB;QACpC9E,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA,mBAAqB;QAC3CC,MAAM,EAAG;UACRoG;QACD;MAAG,CACH;IAAC,CACY,CAAC;EAAA,CACf,CAAC;AAEL","ignoreList":[]}
@@ -91,11 +91,13 @@ function PrivateExcerpt() {
91
91
  shouldBeUsedAsDescription,
92
92
  allowEditing
93
93
  } = (0, _data.useSelect)(select => {
94
+ var _getEditedPostAttribu;
94
95
  const {
95
96
  getCurrentPostType,
96
97
  getCurrentPostId,
97
98
  getEditedPostAttribute,
98
- isEditorPanelEnabled
99
+ isEditorPanelEnabled,
100
+ __experimentalGetDefaultTemplateType
99
101
  } = select(_store.store);
100
102
  const postType = getCurrentPostType();
101
103
  const isTemplateOrTemplatePart = ['wp_template', 'wp_template_part'].includes(postType);
@@ -106,11 +108,12 @@ function PrivateExcerpt() {
106
108
  const _usedAttribute = isTemplateOrTemplatePart ? 'description' : 'excerpt';
107
109
  // We need to fetch the entity in this case to check if we'll allow editing.
108
110
  const template = isTemplateOrTemplatePart && select(_coreData.store).getEntityRecord('postType', postType, getCurrentPostId());
111
+ const fallback = isTemplateOrTemplatePart ? __experimentalGetDefaultTemplateType(template.slug).description : undefined;
109
112
  // For post types that use excerpt as description, we do not abide
110
113
  // by the `isEnabled` panel flag in order to render them as text.
111
114
  const _shouldRender = isEditorPanelEnabled(PANEL_NAME) || _shouldBeUsedAsDescription;
112
115
  return {
113
- excerpt: getEditedPostAttribute(_usedAttribute),
116
+ excerpt: (_getEditedPostAttribu = getEditedPostAttribute(_usedAttribute)) !== null && _getEditedPostAttribu !== void 0 ? _getEditedPostAttribu : fallback,
114
117
  shouldRender: _shouldRender,
115
118
  shouldBeUsedAsDescription: _shouldBeUsedAsDescription,
116
119
  // If we should render, allow editing for all post types that are not used as description.
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_components","_data","_element","_blockEditor","_coreData","_htmlEntities","_index","_interopRequireDefault","_check","_plugin","_constants","_store","_jsxRuntime","PANEL_NAME","ExcerptPanel","isOpened","isEnabled","postType","useSelect","select","isEditorPanelOpened","isEditorPanelEnabled","getCurrentPostType","editorStore","toggleEditorPanelOpened","useDispatch","toggleExcerptPanel","shouldUseDescriptionLabel","includes","jsx","PanelBody","title","__","opened","onToggle","children","default","Slot","fills","jsxs","Fragment","PostExcerptPanel","PrivatePostExcerptPanel","PrivateExcerpt","shouldRender","excerpt","shouldBeUsedAsDescription","allowEditing","getCurrentPostId","getEditedPostAttribute","isTemplateOrTemplatePart","isPattern","_shouldBeUsedAsDescription","_usedAttribute","template","coreStore","getEntityRecord","_shouldRender","source","TEMPLATE_ORIGINS","custom","has_theme_file","is_custom","popoverAnchor","setPopoverAnchor","useState","label","popoverProps","useMemo","anchor","headerTitle","placement","offset","shift","excerptText","__experimentalText","align","numberOfLines","truncate","decodeEntities","excerptPlaceholder","triggerEditLabel","__experimentalVStack","Dropdown","className","contentClassName","focusOnMount","ref","renderToggle","Button","__next40pxDefaultSize","onClick","variant","renderContent","onClose","__experimentalInspectorPopoverHeader","spacing","hideLabelFromVision","updateOnBlur"],"sources":["@wordpress/editor/src/components/post-excerpt/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tPanelBody,\n\t__experimentalText as Text,\n\tDropdown,\n\tButton,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMemo, useState } from '@wordpress/element';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport PostExcerptForm from './index';\nimport PostExcerptCheck from './check';\nimport PluginPostExcerpt from './plugin';\nimport { TEMPLATE_ORIGINS } from '../../store/constants';\nimport { store as editorStore } from '../../store';\n\n/**\n * Module Constants\n */\nconst PANEL_NAME = 'post-excerpt';\n\nfunction ExcerptPanel() {\n\tconst { isOpened, isEnabled, postType } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisEditorPanelOpened,\n\t\t\tisEditorPanelEnabled,\n\t\t\tgetCurrentPostType,\n\t\t} = select( editorStore );\n\n\t\treturn {\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\tconst { toggleEditorPanelOpened } = useDispatch( editorStore );\n\tconst toggleExcerptPanel = () => toggleEditorPanelOpened( PANEL_NAME );\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\t// There are special cases where we want to label the excerpt as a description.\n\tconst shouldUseDescriptionLabel = [\n\t\t'wp_template',\n\t\t'wp_template_part',\n\t\t'wp_block',\n\t].includes( postType );\n\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={\n\t\t\t\tshouldUseDescriptionLabel\n\t\t\t\t\t? __( 'Description' )\n\t\t\t\t\t: __( 'Excerpt' )\n\t\t\t}\n\t\t\topened={ isOpened }\n\t\t\tonToggle={ toggleExcerptPanel }\n\t\t>\n\t\t\t<PluginPostExcerpt.Slot>\n\t\t\t\t{ ( fills ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<PostExcerptForm />\n\t\t\t\t\t\t{ fills }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</PluginPostExcerpt.Slot>\n\t\t</PanelBody>\n\t);\n}\n\n/**\n * Is rendered if the post type supports excerpts and allows editing the excerpt.\n *\n * @return {React.ReactNode} The rendered PostExcerptPanel component.\n */\nexport default function PostExcerptPanel() {\n\treturn (\n\t\t<PostExcerptCheck>\n\t\t\t<ExcerptPanel />\n\t\t</PostExcerptCheck>\n\t);\n}\n\nexport function PrivatePostExcerptPanel() {\n\treturn (\n\t\t<PostExcerptCheck>\n\t\t\t<PrivateExcerpt />\n\t\t</PostExcerptCheck>\n\t);\n}\n\nfunction PrivateExcerpt() {\n\tconst { shouldRender, excerpt, shouldBeUsedAsDescription, allowEditing } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetCurrentPostId,\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t\tisEditorPanelEnabled,\n\t\t\t} = select( editorStore );\n\t\t\tconst postType = getCurrentPostType();\n\t\t\tconst isTemplateOrTemplatePart = [\n\t\t\t\t'wp_template',\n\t\t\t\t'wp_template_part',\n\t\t\t].includes( postType );\n\t\t\tconst isPattern = postType === 'wp_block';\n\t\t\t// These post types use the `excerpt` field as a description semantically, so we need to\n\t\t\t// handle proper labeling and some flows where we should always render them as text.\n\t\t\tconst _shouldBeUsedAsDescription =\n\t\t\t\tisTemplateOrTemplatePart || isPattern;\n\t\t\tconst _usedAttribute = isTemplateOrTemplatePart\n\t\t\t\t? 'description'\n\t\t\t\t: 'excerpt';\n\t\t\t// We need to fetch the entity in this case to check if we'll allow editing.\n\t\t\tconst template =\n\t\t\t\tisTemplateOrTemplatePart &&\n\t\t\t\tselect( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tgetCurrentPostId()\n\t\t\t\t);\n\t\t\t// For post types that use excerpt as description, we do not abide\n\t\t\t// by the `isEnabled` panel flag in order to render them as text.\n\t\t\tconst _shouldRender =\n\t\t\t\tisEditorPanelEnabled( PANEL_NAME ) ||\n\t\t\t\t_shouldBeUsedAsDescription;\n\t\t\treturn {\n\t\t\t\texcerpt: getEditedPostAttribute( _usedAttribute ),\n\t\t\t\tshouldRender: _shouldRender,\n\t\t\t\tshouldBeUsedAsDescription: _shouldBeUsedAsDescription,\n\t\t\t\t// If we should render, allow editing for all post types that are not used as description.\n\t\t\t\t// For the rest allow editing only for user generated entities.\n\t\t\t\tallowEditing:\n\t\t\t\t\t_shouldRender &&\n\t\t\t\t\t( ! _shouldBeUsedAsDescription ||\n\t\t\t\t\t\tisPattern ||\n\t\t\t\t\t\t( template &&\n\t\t\t\t\t\t\ttemplate.source === TEMPLATE_ORIGINS.custom &&\n\t\t\t\t\t\t\t! template.has_theme_file &&\n\t\t\t\t\t\t\ttemplate.is_custom ) ),\n\t\t\t};\n\t\t}, [] );\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst label = shouldBeUsedAsDescription\n\t\t? __( 'Description' )\n\t\t: __( 'Excerpt' );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\t'aria-label': label,\n\t\t\theaderTitle: label,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor, label ]\n\t);\n\tif ( ! shouldRender ) {\n\t\treturn false;\n\t}\n\tconst excerptText = !! excerpt && (\n\t\t<Text align=\"left\" numberOfLines={ 4 } truncate={ allowEditing }>\n\t\t\t{ decodeEntities( excerpt ) }\n\t\t</Text>\n\t);\n\tif ( ! allowEditing ) {\n\t\treturn excerptText;\n\t}\n\tconst excerptPlaceholder = shouldBeUsedAsDescription\n\t\t? __( 'Add a description…' )\n\t\t: __( 'Add an excerpt…' );\n\tconst triggerEditLabel = shouldBeUsedAsDescription\n\t\t? __( 'Edit description' )\n\t\t: __( 'Edit excerpt' );\n\treturn (\n\t\t<VStack>\n\t\t\t{ excerptText }\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"editor-post-excerpt__dropdown\"\n\t\t\t\tcontentClassName=\"editor-post-excerpt__dropdown__content\"\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tfocusOnMount\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t\trenderToggle={ ( { onToggle } ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ excerptText ? triggerEditLabel : excerptPlaceholder }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\ttitle={ label }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\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Z,CAAC,EACA5D,KAAK;YAAA,CACN;UACF,CACsB;QAAC,CAClB,CAAC;MAAA,CACR;IACA,CACH,CAAC;EAAA,CACK,CAAC;AAEX","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_components","_data","_element","_blockEditor","_coreData","_htmlEntities","_index","_interopRequireDefault","_check","_plugin","_constants","_store","_jsxRuntime","PANEL_NAME","ExcerptPanel","isOpened","isEnabled","postType","useSelect","select","isEditorPanelOpened","isEditorPanelEnabled","getCurrentPostType","editorStore","toggleEditorPanelOpened","useDispatch","toggleExcerptPanel","shouldUseDescriptionLabel","includes","jsx","PanelBody","title","__","opened","onToggle","children","default","Slot","fills","jsxs","Fragment","PostExcerptPanel","PrivatePostExcerptPanel","PrivateExcerpt","shouldRender","excerpt","shouldBeUsedAsDescription","allowEditing","_getEditedPostAttribu","getCurrentPostId","getEditedPostAttribute","__experimentalGetDefaultTemplateType","isTemplateOrTemplatePart","isPattern","_shouldBeUsedAsDescription","_usedAttribute","template","coreStore","getEntityRecord","fallback","slug","description","undefined","_shouldRender","source","TEMPLATE_ORIGINS","custom","has_theme_file","is_custom","popoverAnchor","setPopoverAnchor","useState","label","popoverProps","useMemo","anchor","headerTitle","placement","offset","shift","excerptText","__experimentalText","align","numberOfLines","truncate","decodeEntities","excerptPlaceholder","triggerEditLabel","__experimentalVStack","Dropdown","className","contentClassName","focusOnMount","ref","renderToggle","Button","__next40pxDefaultSize","onClick","variant","renderContent","onClose","__experimentalInspectorPopoverHeader","spacing","hideLabelFromVision","updateOnBlur"],"sources":["@wordpress/editor/src/components/post-excerpt/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tPanelBody,\n\t__experimentalText as Text,\n\tDropdown,\n\tButton,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMemo, useState } from '@wordpress/element';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport PostExcerptForm from './index';\nimport PostExcerptCheck from './check';\nimport PluginPostExcerpt from './plugin';\nimport { TEMPLATE_ORIGINS } from '../../store/constants';\nimport { store as editorStore } from '../../store';\n\n/**\n * Module Constants\n */\nconst PANEL_NAME = 'post-excerpt';\n\nfunction ExcerptPanel() {\n\tconst { isOpened, isEnabled, postType } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisEditorPanelOpened,\n\t\t\tisEditorPanelEnabled,\n\t\t\tgetCurrentPostType,\n\t\t} = select( editorStore );\n\n\t\treturn {\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\tconst { toggleEditorPanelOpened } = useDispatch( editorStore );\n\tconst toggleExcerptPanel = () => toggleEditorPanelOpened( PANEL_NAME );\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\t// There are special cases where we want to label the excerpt as a description.\n\tconst shouldUseDescriptionLabel = [\n\t\t'wp_template',\n\t\t'wp_template_part',\n\t\t'wp_block',\n\t].includes( postType );\n\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={\n\t\t\t\tshouldUseDescriptionLabel\n\t\t\t\t\t? __( 'Description' )\n\t\t\t\t\t: __( 'Excerpt' )\n\t\t\t}\n\t\t\topened={ isOpened }\n\t\t\tonToggle={ toggleExcerptPanel }\n\t\t>\n\t\t\t<PluginPostExcerpt.Slot>\n\t\t\t\t{ ( fills ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<PostExcerptForm />\n\t\t\t\t\t\t{ fills }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</PluginPostExcerpt.Slot>\n\t\t</PanelBody>\n\t);\n}\n\n/**\n * Is rendered if the post type supports excerpts and allows editing the excerpt.\n *\n * @return {React.ReactNode} The rendered PostExcerptPanel component.\n */\nexport default function PostExcerptPanel() {\n\treturn (\n\t\t<PostExcerptCheck>\n\t\t\t<ExcerptPanel />\n\t\t</PostExcerptCheck>\n\t);\n}\n\nexport function PrivatePostExcerptPanel() {\n\treturn (\n\t\t<PostExcerptCheck>\n\t\t\t<PrivateExcerpt />\n\t\t</PostExcerptCheck>\n\t);\n}\n\nfunction PrivateExcerpt() {\n\tconst { shouldRender, excerpt, shouldBeUsedAsDescription, allowEditing } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetCurrentPostId,\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t\tisEditorPanelEnabled,\n\t\t\t\t__experimentalGetDefaultTemplateType,\n\t\t\t} = select( editorStore );\n\t\t\tconst postType = getCurrentPostType();\n\t\t\tconst isTemplateOrTemplatePart = [\n\t\t\t\t'wp_template',\n\t\t\t\t'wp_template_part',\n\t\t\t].includes( postType );\n\t\t\tconst isPattern = postType === 'wp_block';\n\t\t\t// These post types use the `excerpt` field as a description semantically, so we need to\n\t\t\t// handle proper labeling and some flows where we should always render them as text.\n\t\t\tconst _shouldBeUsedAsDescription =\n\t\t\t\tisTemplateOrTemplatePart || isPattern;\n\t\t\tconst _usedAttribute = isTemplateOrTemplatePart\n\t\t\t\t? 'description'\n\t\t\t\t: 'excerpt';\n\t\t\t// We need to fetch the entity in this case to check if we'll allow editing.\n\t\t\tconst template =\n\t\t\t\tisTemplateOrTemplatePart &&\n\t\t\t\tselect( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tgetCurrentPostId()\n\t\t\t\t);\n\t\t\tconst fallback = isTemplateOrTemplatePart\n\t\t\t\t? __experimentalGetDefaultTemplateType( template.slug )\n\t\t\t\t\t\t.description\n\t\t\t\t: undefined;\n\t\t\t// For post types that use excerpt as description, we do not abide\n\t\t\t// by the `isEnabled` panel flag in order to render them as text.\n\t\t\tconst _shouldRender =\n\t\t\t\tisEditorPanelEnabled( PANEL_NAME ) ||\n\t\t\t\t_shouldBeUsedAsDescription;\n\t\t\treturn {\n\t\t\t\texcerpt: getEditedPostAttribute( _usedAttribute ) ?? fallback,\n\t\t\t\tshouldRender: _shouldRender,\n\t\t\t\tshouldBeUsedAsDescription: _shouldBeUsedAsDescription,\n\t\t\t\t// If we should render, allow editing for all post types that are not used as description.\n\t\t\t\t// For the rest allow editing only for user generated entities.\n\t\t\t\tallowEditing:\n\t\t\t\t\t_shouldRender &&\n\t\t\t\t\t( ! _shouldBeUsedAsDescription ||\n\t\t\t\t\t\tisPattern ||\n\t\t\t\t\t\t( template &&\n\t\t\t\t\t\t\ttemplate.source === TEMPLATE_ORIGINS.custom &&\n\t\t\t\t\t\t\t! template.has_theme_file &&\n\t\t\t\t\t\t\ttemplate.is_custom ) ),\n\t\t\t};\n\t\t}, [] );\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst label = shouldBeUsedAsDescription\n\t\t? __( 'Description' )\n\t\t: __( 'Excerpt' );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\t'aria-label': label,\n\t\t\theaderTitle: label,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor, label ]\n\t);\n\tif ( ! shouldRender ) {\n\t\treturn false;\n\t}\n\tconst excerptText = !! excerpt && (\n\t\t<Text align=\"left\" numberOfLines={ 4 } truncate={ allowEditing }>\n\t\t\t{ decodeEntities( excerpt ) }\n\t\t</Text>\n\t);\n\tif ( ! allowEditing ) {\n\t\treturn excerptText;\n\t}\n\tconst excerptPlaceholder = shouldBeUsedAsDescription\n\t\t? __( 'Add a description…' )\n\t\t: __( 'Add an excerpt…' );\n\tconst triggerEditLabel = shouldBeUsedAsDescription\n\t\t? __( 'Edit description' )\n\t\t: __( 'Edit excerpt' );\n\treturn (\n\t\t<VStack>\n\t\t\t{ excerptText }\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"editor-post-excerpt__dropdown\"\n\t\t\t\tcontentClassName=\"editor-post-excerpt__dropdown__content\"\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tfocusOnMount\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t\trenderToggle={ ( { onToggle } ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ excerptText ? triggerEditLabel : excerptPlaceholder }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\ttitle={ label }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t\t\t<PluginPostExcerpt.Slot>\n\t\t\t\t\t\t\t\t{ ( fills ) => (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<PostExcerptForm\n\t\t\t\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\t\t\t\tupdateOnBlur\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t{ fills }\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</PluginPostExcerpt.Slot>\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"],"mappings":";;;;;;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AAY;MACZC,GAAG,EAAGvB,gBAAkB;MACxBwB,YAAY,EAAGA,CAAE;QAAE5D;MAAS,CAAC,kBAC5B,IAAAtB,WAAA,CAAAiB,GAAA,EAAC7B,WAAA,CAAA+F,MAAM;QACNC,qBAAqB;QACrBC,OAAO,EAAG/D,QAAU;QACpBgE,OAAO,EAAC,MAAM;QAAA/D,QAAA,EAEZ6C,WAAW,GAAGO,gBAAgB,GAAGD;MAAkB,CAC9C,CACN;MACHa,aAAa,EAAGA,CAAE;QAAEC;MAAQ,CAAC,kBAC5B,IAAAxF,WAAA,CAAA2B,IAAA,EAAA3B,WAAA,CAAA4B,QAAA;QAAAL,QAAA,gBACC,IAAAvB,WAAA,CAAAiB,GAAA,EAAC1B,YAAA,CAAAkG,oCAAsB;UACtBtE,KAAK,EAAGyC,KAAO;UACf4B,OAAO,EAAGA;QAAS,CACnB,CAAC,eAEF,IAAAxF,WAAA,CAAAiB,GAAA,EAAC7B,WAAA,CAAAwF,oBAAM;UAACc,OAAO,EAAG,CAAG;UAAAnE,QAAA,eACpB,IAAAvB,WAAA,CAAAiB,GAAA,EAACpB,OAAA,CAAA2B,OAAiB,CAACC,IAAI;YAAAF,QAAA,EAClBG,KAAK,iBACR,IAAA1B,WAAA,CAAA2B,IAAA,EAAA3B,WAAA,CAAA4B,QAAA;cAAAL,QAAA,gBACC,IAAAvB,WAAA,CAAAiB,GAAA,EAACvB,MAAA,CAAA8B,OAAe;gBACfmE,mBAAmB;gBACnBC,YAAY;cAAA,CACZ,CAAC,EACAlE,KAAK;YAAA,CACN;UACF,CACsB;QAAC,CAClB,CAAC;MAAA,CACR;IACA,CACH,CAAC;EAAA,CACK,CAAC;AAEX","ignoreList":[]}
@@ -60,16 +60,31 @@ function useAllowSwitchingTemplates() {
60
60
  }, [postId, postType]);
61
61
  }
62
62
  function useTemplates(postType) {
63
- return (0, _data.useSelect)(select => select(_coreData.store).getEntityRecords('postType', 'wp_template', {
64
- per_page: -1,
65
- post_type: postType
66
- }), [postType]);
63
+ // To do: create a new selector to checks if templates exist at all instead
64
+ // of and unbound request. In the modal, the user templates should be
65
+ // paginated and we should not make an unbound request.
66
+ const {
67
+ staticTemplates,
68
+ templates
69
+ } = (0, _data.useSelect)(select => {
70
+ return {
71
+ staticTemplates: select(_coreData.store).getEntityRecords('postType', 'wp_registered_template', {
72
+ per_page: -1,
73
+ post_type: postType
74
+ }),
75
+ templates: select(_coreData.store).getEntityRecords('postType', 'wp_template', {
76
+ per_page: -1,
77
+ post_type: postType
78
+ })
79
+ };
80
+ }, [postType]);
81
+ return (0, _element.useMemo)(() => [...(staticTemplates || []), ...(templates || [])], [staticTemplates, templates]);
67
82
  }
68
83
  function useAvailableTemplates(postType) {
69
84
  const currentTemplateSlug = useCurrentTemplateSlug();
70
85
  const allowSwitchingTemplate = useAllowSwitchingTemplates();
71
86
  const templates = useTemplates(postType);
72
- return (0, _element.useMemo)(() => allowSwitchingTemplate && templates?.filter(template => template.is_custom && template.slug !== currentTemplateSlug && !!template.content.raw // Skip empty templates.
87
+ return (0, _element.useMemo)(() => allowSwitchingTemplate && templates?.filter(template => (template.is_custom || template.type === 'wp_template') && template.slug !== currentTemplateSlug && !!template.content.raw // Skip empty templates.
73
88
  ), [templates, currentTemplateSlug, allowSwitchingTemplate]);
74
89
  }
75
90
  function useCurrentTemplateSlug() {