@wordpress/editor 14.11.0 → 14.12.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 (165) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +0 -8
  3. package/build/components/collab-sidebar/add-comment.js +5 -6
  4. package/build/components/collab-sidebar/add-comment.js.map +1 -1
  5. package/build/components/collab-sidebar/index.js +75 -73
  6. package/build/components/collab-sidebar/index.js.map +1 -1
  7. package/build/components/commands/index.js +142 -34
  8. package/build/components/commands/index.js.map +1 -1
  9. package/build/components/create-template-part-modal/index.js +1 -0
  10. package/build/components/create-template-part-modal/index.js.map +1 -1
  11. package/build/components/document-bar/index.js +9 -3
  12. package/build/components/document-bar/index.js.map +1 -1
  13. package/build/components/document-tools/index.js +8 -4
  14. package/build/components/document-tools/index.js.map +1 -1
  15. package/build/components/editor-interface/index.js +1 -2
  16. package/build/components/editor-interface/index.js.map +1 -1
  17. package/build/components/global-styles-provider/index.js +20 -8
  18. package/build/components/global-styles-provider/index.js.map +1 -1
  19. package/build/components/header/index.js +10 -12
  20. package/build/components/header/index.js.map +1 -1
  21. package/build/components/more-menu/index.js +9 -7
  22. package/build/components/more-menu/index.js.map +1 -1
  23. package/build/components/post-taxonomies/flat-term-selector.js +10 -8
  24. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  25. package/build/components/post-template/swap-template-button.js +0 -3
  26. package/build/components/post-template/swap-template-button.js.map +1 -1
  27. package/build/components/post-transform-panel/index.js +0 -3
  28. package/build/components/post-transform-panel/index.js.map +1 -1
  29. package/build/components/preferences-modal/index.js +26 -22
  30. package/build/components/preferences-modal/index.js.map +1 -1
  31. package/build/components/preview-dropdown/index.js +23 -4
  32. package/build/components/preview-dropdown/index.js.map +1 -1
  33. package/build/components/provider/use-block-editor-settings.js +10 -9
  34. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  35. package/build/components/sidebar/post-summary.js +2 -2
  36. package/build/components/sidebar/post-summary.js.map +1 -1
  37. package/build/components/start-page-options/index.js +0 -3
  38. package/build/components/start-page-options/index.js.map +1 -1
  39. package/build/components/start-template-options/index.js +0 -3
  40. package/build/components/start-template-options/index.js.map +1 -1
  41. package/build/components/visual-editor/index.js +5 -2
  42. package/build/components/visual-editor/index.js.map +1 -1
  43. package/build/store/actions.js +65 -16
  44. package/build/store/actions.js.map +1 -1
  45. package/build/store/constants.js +0 -2
  46. package/build/store/constants.js.map +1 -1
  47. package/build/store/index.js +0 -4
  48. package/build/store/index.js.map +1 -1
  49. package/build/store/selectors.js +2 -2
  50. package/build/store/selectors.js.map +1 -1
  51. package/build-module/components/collab-sidebar/add-comment.js +5 -6
  52. package/build-module/components/collab-sidebar/add-comment.js.map +1 -1
  53. package/build-module/components/collab-sidebar/index.js +76 -74
  54. package/build-module/components/collab-sidebar/index.js.map +1 -1
  55. package/build-module/components/commands/index.js +145 -38
  56. package/build-module/components/commands/index.js.map +1 -1
  57. package/build-module/components/create-template-part-modal/index.js +1 -0
  58. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  59. package/build-module/components/document-bar/index.js +10 -4
  60. package/build-module/components/document-bar/index.js.map +1 -1
  61. package/build-module/components/document-tools/index.js +8 -4
  62. package/build-module/components/document-tools/index.js.map +1 -1
  63. package/build-module/components/editor-interface/index.js +1 -2
  64. package/build-module/components/editor-interface/index.js.map +1 -1
  65. package/build-module/components/global-styles-provider/index.js +20 -8
  66. package/build-module/components/global-styles-provider/index.js.map +1 -1
  67. package/build-module/components/header/index.js +10 -12
  68. package/build-module/components/header/index.js.map +1 -1
  69. package/build-module/components/more-menu/index.js +9 -7
  70. package/build-module/components/more-menu/index.js.map +1 -1
  71. package/build-module/components/post-taxonomies/flat-term-selector.js +10 -8
  72. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  73. package/build-module/components/post-template/swap-template-button.js +0 -3
  74. package/build-module/components/post-template/swap-template-button.js.map +1 -1
  75. package/build-module/components/post-transform-panel/index.js +0 -3
  76. package/build-module/components/post-transform-panel/index.js.map +1 -1
  77. package/build-module/components/preferences-modal/index.js +26 -22
  78. package/build-module/components/preferences-modal/index.js.map +1 -1
  79. package/build-module/components/preview-dropdown/index.js +24 -5
  80. package/build-module/components/preview-dropdown/index.js.map +1 -1
  81. package/build-module/components/provider/use-block-editor-settings.js +11 -10
  82. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  83. package/build-module/components/sidebar/post-summary.js +2 -2
  84. package/build-module/components/sidebar/post-summary.js.map +1 -1
  85. package/build-module/components/start-page-options/index.js +0 -3
  86. package/build-module/components/start-page-options/index.js.map +1 -1
  87. package/build-module/components/start-template-options/index.js +0 -3
  88. package/build-module/components/start-template-options/index.js.map +1 -1
  89. package/build-module/components/visual-editor/index.js +5 -2
  90. package/build-module/components/visual-editor/index.js.map +1 -1
  91. package/build-module/store/actions.js +61 -14
  92. package/build-module/store/actions.js.map +1 -1
  93. package/build-module/store/constants.js +0 -2
  94. package/build-module/store/constants.js.map +1 -1
  95. package/build-module/store/index.js +0 -4
  96. package/build-module/store/index.js.map +1 -1
  97. package/build-module/store/selectors.js +2 -2
  98. package/build-module/store/selectors.js.map +1 -1
  99. package/build-style/style-rtl.css +22 -6
  100. package/build-style/style.css +22 -6
  101. package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
  102. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  103. package/build-types/components/commands/index.d.ts.map +1 -1
  104. package/build-types/components/create-template-part-modal/index.d.ts.map +1 -1
  105. package/build-types/components/document-bar/index.d.ts.map +1 -1
  106. package/build-types/components/document-tools/index.d.ts.map +1 -1
  107. package/build-types/components/editor-interface/index.d.ts.map +1 -1
  108. package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
  109. package/build-types/components/header/index.d.ts +1 -2
  110. package/build-types/components/header/index.d.ts.map +1 -1
  111. package/build-types/components/more-menu/index.d.ts.map +1 -1
  112. package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
  113. package/build-types/components/post-template/hooks.d.ts +2 -2
  114. package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
  115. package/build-types/components/post-transform-panel/index.d.ts.map +1 -1
  116. package/build-types/components/preferences-modal/index.d.ts.map +1 -1
  117. package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
  118. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  119. package/build-types/components/start-page-options/index.d.ts.map +1 -1
  120. package/build-types/components/start-template-options/index.d.ts.map +1 -1
  121. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  122. package/build-types/dataviews/store/reducer.d.ts +5 -2
  123. package/build-types/dataviews/store/reducer.d.ts.map +1 -1
  124. package/build-types/lock-unlock.d.ts +2 -2
  125. package/build-types/store/actions.d.ts +9 -1
  126. package/build-types/store/actions.d.ts.map +1 -1
  127. package/build-types/store/constants.d.ts +0 -2
  128. package/build-types/store/constants.d.ts.map +1 -1
  129. package/build-types/store/index.d.ts +9 -11
  130. package/build-types/store/index.d.ts.map +1 -1
  131. package/build-types/store/reducer.d.ts +24 -4
  132. package/build-types/store/reducer.d.ts.map +1 -1
  133. package/build-types/store/selectors.d.ts +3 -3
  134. package/build-types/store/selectors.d.ts.map +1 -1
  135. package/package.json +4 -3
  136. package/src/components/collab-sidebar/add-comment.js +17 -20
  137. package/src/components/collab-sidebar/index.js +79 -88
  138. package/src/components/commands/index.js +390 -270
  139. package/src/components/create-template-part-modal/index.js +1 -0
  140. package/src/components/document-bar/index.js +10 -1
  141. package/src/components/document-bar/style.scss +13 -0
  142. package/src/components/document-tools/index.js +7 -1
  143. package/src/components/editor-interface/index.js +0 -1
  144. package/src/components/global-styles-provider/index.js +20 -8
  145. package/src/components/header/index.js +18 -10
  146. package/src/components/more-menu/index.js +12 -7
  147. package/src/components/plugin-post-publish-panel/test/__snapshots__/index.js.snap +1 -1
  148. package/src/components/post-taxonomies/flat-term-selector.js +8 -8
  149. package/src/components/post-template/swap-template-button.js +0 -3
  150. package/src/components/post-transform-panel/index.js +0 -3
  151. package/src/components/preferences-modal/index.js +26 -19
  152. package/src/components/preferences-modal/test/index.js +1 -1
  153. package/src/components/preview-dropdown/index.js +45 -16
  154. package/src/components/provider/use-block-editor-settings.js +10 -9
  155. package/src/components/sidebar/post-summary.js +1 -1
  156. package/src/components/sidebar/style.scss +1 -3
  157. package/src/components/start-page-options/index.js +0 -3
  158. package/src/components/start-template-options/index.js +0 -3
  159. package/src/components/visual-editor/index.js +7 -1
  160. package/src/components/visual-editor/style.scss +11 -0
  161. package/src/store/actions.js +110 -33
  162. package/src/store/constants.ts +0 -2
  163. package/src/store/index.js +0 -4
  164. package/src/store/selectors.js +2 -2
  165. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 14.12.0 (2024-11-16)
6
+
5
7
  ## 14.11.0 (2024-10-30)
6
8
 
7
9
  ### Bug Fixes
package/README.md CHANGED
@@ -1631,10 +1631,6 @@ _Related_
1631
1631
 
1632
1632
  - <https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore>
1633
1633
 
1634
- _Type_
1635
-
1636
- - `Object`
1637
-
1638
1634
  ### storeConfig
1639
1635
 
1640
1636
  Post editor data store configuration.
@@ -1643,10 +1639,6 @@ _Related_
1643
1639
 
1644
1640
  - <https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore>
1645
1641
 
1646
- _Type_
1647
-
1648
- - `Object`
1649
-
1650
1642
  ### TableOfContents
1651
1643
 
1652
1644
  Renders a table of contents component.
@@ -41,25 +41,24 @@ function AddComment({
41
41
  defaultAvatar,
42
42
  clientId,
43
43
  blockCommentId,
44
- showAddCommentBoard,
45
44
  currentUser
46
45
  } = (0, _data.useSelect)(select => {
47
46
  const {
48
- getSettings
47
+ getSettings,
48
+ getSelectedBlock
49
49
  } = select(_blockEditor.store);
50
50
  const {
51
51
  __experimentalDiscussionSettings
52
52
  } = getSettings();
53
- const selectedBlock = select(_blockEditor.store).getSelectedBlock();
53
+ const selectedBlock = getSelectedBlock();
54
54
  const userData = select(_coreData.store).getCurrentUser();
55
55
  return {
56
56
  defaultAvatar: __experimentalDiscussionSettings?.avatarURL,
57
57
  clientId: selectedBlock?.clientId,
58
58
  blockCommentId: selectedBlock?.attributes?.blockCommentId,
59
- showAddCommentBoard: showCommentBoard,
60
59
  currentUser: userData
61
60
  };
62
- });
61
+ }, []);
63
62
  const userAvatar = currentUser && currentUser.avatar_urls && currentUser.avatar_urls[48] ? currentUser.avatar_urls[48] : defaultAvatar;
64
63
  (0, _element.useEffect)(() => {
65
64
  setInputComment('');
@@ -68,7 +67,7 @@ function AddComment({
68
67
  setShowCommentBoard(false);
69
68
  setInputComment('');
70
69
  };
71
- if (!showAddCommentBoard || !clientId || undefined !== blockCommentId) {
70
+ if (!showCommentBoard || !clientId || undefined !== blockCommentId) {
72
71
  return null;
73
72
  }
74
73
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_data","_element","_components","_blockEditor","_coreData","_utils","_jsxRuntime","AddComment","onSubmit","showCommentBoard","setShowCommentBoard","_currentUser$name","inputComment","setInputComment","useState","defaultAvatar","clientId","blockCommentId","showAddCommentBoard","currentUser","useSelect","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","selectedBlock","getSelectedBlock","userData","coreStore","getCurrentUser","avatarURL","attributes","userAvatar","avatar_urls","useEffect","handleCancel","undefined","jsxs","__experimentalVStack","spacing","className","children","__experimentalHStack","alignment","jsx","src","alt","__","width","height","name","TextControl","__next40pxDefaultSize","__nextHasNoMarginBottom","value","onChange","placeholder","_x","Button","variant","text","onClick","accessibleWhenDisabled","disabled","sanitizeCommentString","length"],"sources":["@wordpress/editor/src/components/collab-sidebar/add-comment.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { useState, useEffect } from '@wordpress/element';\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tButton,\n\tTextControl,\n} from '@wordpress/components';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { sanitizeCommentString } from './utils';\n\n/**\n * Renders the UI for adding a comment in the Gutenberg editor's collaboration sidebar.\n *\n * @param {Object} props - The component props.\n * @param {Function} props.onSubmit - A callback function to be called when the user submits a comment.\n * @param {boolean} props.showCommentBoard - The function to edit the comment.\n * @param {Function} props.setShowCommentBoard - The function to delete the comment.\n * @return {JSX.Element} The rendered comment input UI.\n */\nexport function AddComment( {\n\tonSubmit,\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n} ) {\n\t// State to manage the comment thread.\n\tconst [ inputComment, setInputComment ] = useState( '' );\n\n\tconst {\n\t\tdefaultAvatar,\n\t\tclientId,\n\t\tblockCommentId,\n\t\tshowAddCommentBoard,\n\t\tcurrentUser,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\tconst selectedBlock = select( blockEditorStore ).getSelectedBlock();\n\t\tconst userData = select( coreStore ).getCurrentUser();\n\t\treturn {\n\t\t\tdefaultAvatar: __experimentalDiscussionSettings?.avatarURL,\n\t\t\tclientId: selectedBlock?.clientId,\n\t\t\tblockCommentId: selectedBlock?.attributes?.blockCommentId,\n\t\t\tshowAddCommentBoard: showCommentBoard,\n\t\t\tcurrentUser: userData,\n\t\t};\n\t} );\n\n\tconst userAvatar =\n\t\tcurrentUser && currentUser.avatar_urls && currentUser.avatar_urls[ 48 ]\n\t\t\t? currentUser.avatar_urls[ 48 ]\n\t\t\t: defaultAvatar;\n\n\tuseEffect( () => {\n\t\tsetInputComment( '' );\n\t}, [ clientId ] );\n\n\tconst handleCancel = () => {\n\t\tsetShowCommentBoard( false );\n\t\tsetInputComment( '' );\n\t};\n\n\tif ( ! showAddCommentBoard || ! clientId || undefined !== blockCommentId ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack\n\t\t\tspacing=\"3\"\n\t\t\tclassName=\"editor-collab-sidebar-panel__thread editor-collab-sidebar-panel__active-thread\"\n\t\t>\n\t\t\t<HStack alignment=\"left\" spacing=\"3\">\n\t\t\t\t<img\n\t\t\t\t\tsrc={ userAvatar }\n\t\t\t\t\t// translators: alt text for user avatar image\n\t\t\t\t\talt={ __( 'User Avatar' ) }\n\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__user-avatar\"\n\t\t\t\t\twidth={ 32 }\n\t\t\t\t\theight={ 32 }\n\t\t\t\t/>\n\t\t\t\t<span className=\"editor-collab-sidebar-panel__user-name\">\n\t\t\t\t\t{ currentUser?.name ?? '' }\n\t\t\t\t</span>\n\t\t\t</HStack>\n\t\t\t<TextControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tvalue={ inputComment }\n\t\t\t\tonChange={ setInputComment }\n\t\t\t\tplaceholder={ _x( 'Comment', 'noun' ) }\n\t\t\t/>\n\t\t\t<HStack alignment=\"right\" spacing=\"3\">\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\ttext={ _x( 'Cancel', 'Cancel comment button' ) }\n\t\t\t\t\tonClick={ handleCancel }\n\t\t\t\t/>\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\ttext={ _x( 'Comment', 'Add comment button' ) }\n\t\t\t\t\tdisabled={\n\t\t\t\t\t\t0 === sanitizeCommentString( inputComment ).length\n\t\t\t\t\t}\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonSubmit( inputComment );\n\t\t\t\t\t\tsetInputComment( '' );\n\t\t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BAAqB;MACrBC,uBAAuB;MACvBC,KAAK,EAAG1C,YAAc;MACtB2C,QAAQ,EAAG1C,eAAiB;MAC5B2C,WAAW,EAAG,IAAAC,QAAE,EAAE,SAAS,EAAE,MAAO;IAAG,CACvC,CAAC,eACF,IAAAnD,WAAA,CAAA+B,IAAA,EAACnC,WAAA,CAAAwC,oBAAM;MAACC,SAAS,EAAC,OAAO;MAACJ,OAAO,EAAC,GAAG;MAAAE,QAAA,gBACpC,IAAAnC,WAAA,CAAAsC,GAAA,EAAC1C,WAAA,CAAAwD,MAAM;QACNN,qBAAqB;QACrBO,OAAO,EAAC,UAAU;QAClBC,IAAI,EAAG,IAAAH,QAAE,EAAE,QAAQ,EAAE,uBAAwB,CAAG;QAChDI,OAAO,EAAG1B;MAAc,CACxB,CAAC,eACF,IAAA7B,WAAA,CAAAsC,GAAA,EAAC1C,WAAA,CAAAwD,MAAM;QACNN,qBAAqB;QACrBU,sBAAsB;QACtBH,OAAO,EAAC,SAAS;QACjBC,IAAI,EAAG,IAAAH,QAAE,EAAE,SAAS,EAAE,oBAAqB,CAAG;QAC9CM,QAAQ,EACP,CAAC,KAAK,IAAAC,4BAAqB,EAAEpD,YAAa,CAAC,CAACqD,MAC5C;QACDJ,OAAO,EAAGA,CAAA,KAAM;UACfrD,QAAQ,CAAEI,YAAa,CAAC;UACxBC,eAAe,CAAE,EAAG,CAAC;QACtB;MAAG,CACH,CAAC;IAAA,CACK,CAAC;EAAA,CACF,CAAC;AAEX","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_data","_element","_components","_blockEditor","_coreData","_utils","_jsxRuntime","AddComment","onSubmit","showCommentBoard","setShowCommentBoard","_currentUser$name","inputComment","setInputComment","useState","defaultAvatar","clientId","blockCommentId","currentUser","useSelect","select","getSettings","getSelectedBlock","blockEditorStore","__experimentalDiscussionSettings","selectedBlock","userData","coreStore","getCurrentUser","avatarURL","attributes","userAvatar","avatar_urls","useEffect","handleCancel","undefined","jsxs","__experimentalVStack","spacing","className","children","__experimentalHStack","alignment","jsx","src","alt","__","width","height","name","TextControl","__next40pxDefaultSize","__nextHasNoMarginBottom","value","onChange","placeholder","_x","Button","variant","text","onClick","accessibleWhenDisabled","disabled","sanitizeCommentString","length"],"sources":["@wordpress/editor/src/components/collab-sidebar/add-comment.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { useState, useEffect } from '@wordpress/element';\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tButton,\n\tTextControl,\n} from '@wordpress/components';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { sanitizeCommentString } from './utils';\n\n/**\n * Renders the UI for adding a comment in the Gutenberg editor's collaboration sidebar.\n *\n * @param {Object} props - The component props.\n * @param {Function} props.onSubmit - A callback function to be called when the user submits a comment.\n * @param {boolean} props.showCommentBoard - The function to edit the comment.\n * @param {Function} props.setShowCommentBoard - The function to delete the comment.\n * @return {JSX.Element} The rendered comment input UI.\n */\nexport function AddComment( {\n\tonSubmit,\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n} ) {\n\t// State to manage the comment thread.\n\tconst [ inputComment, setInputComment ] = useState( '' );\n\n\tconst { defaultAvatar, clientId, blockCommentId, currentUser } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, getSelectedBlock } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\t\tconst selectedBlock = getSelectedBlock();\n\t\t\tconst userData = select( coreStore ).getCurrentUser();\n\t\t\treturn {\n\t\t\t\tdefaultAvatar: __experimentalDiscussionSettings?.avatarURL,\n\t\t\t\tclientId: selectedBlock?.clientId,\n\t\t\t\tblockCommentId: selectedBlock?.attributes?.blockCommentId,\n\t\t\t\tcurrentUser: userData,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst userAvatar =\n\t\tcurrentUser && currentUser.avatar_urls && currentUser.avatar_urls[ 48 ]\n\t\t\t? currentUser.avatar_urls[ 48 ]\n\t\t\t: defaultAvatar;\n\n\tuseEffect( () => {\n\t\tsetInputComment( '' );\n\t}, [ clientId ] );\n\n\tconst handleCancel = () => {\n\t\tsetShowCommentBoard( false );\n\t\tsetInputComment( '' );\n\t};\n\n\tif ( ! showCommentBoard || ! clientId || undefined !== blockCommentId ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack\n\t\t\tspacing=\"3\"\n\t\t\tclassName=\"editor-collab-sidebar-panel__thread editor-collab-sidebar-panel__active-thread\"\n\t\t>\n\t\t\t<HStack alignment=\"left\" spacing=\"3\">\n\t\t\t\t<img\n\t\t\t\t\tsrc={ userAvatar }\n\t\t\t\t\t// translators: alt text for user avatar image\n\t\t\t\t\talt={ __( 'User Avatar' ) }\n\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__user-avatar\"\n\t\t\t\t\twidth={ 32 }\n\t\t\t\t\theight={ 32 }\n\t\t\t\t/>\n\t\t\t\t<span className=\"editor-collab-sidebar-panel__user-name\">\n\t\t\t\t\t{ currentUser?.name ?? '' }\n\t\t\t\t</span>\n\t\t\t</HStack>\n\t\t\t<TextControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tvalue={ inputComment }\n\t\t\t\tonChange={ setInputComment }\n\t\t\t\tplaceholder={ _x( 'Comment', 'noun' ) }\n\t\t\t/>\n\t\t\t<HStack alignment=\"right\" spacing=\"3\">\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\ttext={ _x( 'Cancel', 'Cancel comment button' ) }\n\t\t\t\t\tonClick={ handleCancel }\n\t\t\t\t/>\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\ttext={ _x( 'Comment', 'Add comment button' ) }\n\t\t\t\t\tdisabled={\n\t\t\t\t\t\t0 === sanitizeCommentString( inputComment ).length\n\t\t\t\t\t}\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonSubmit( inputComment );\n\t\t\t\t\t\tsetInputComment( '' );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</HStack>\n\t\t</VStack>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAMA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AAAgD,IAAAO,WAAA,GAAAP,OAAA;AAlBhD;AACA;AACA;;AAaA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,UAAUA,CAAE;EAC3BC,QAAQ;EACRC,gBAAgB;EAChBC;AACD,CAAC,EAAG;EAAA,IAAAC,iBAAA;EACH;EACA,MAAM,CAAEC,YAAY,EAAEC,eAAe,CAAE,GAAG,IAAAC,iBAAQ,EAAE,EAAG,CAAC;EAExD,MAAM;IAAEC,aAAa;IAAEC,QAAQ;IAAEC,cAAc;IAAEC;EAAY,CAAC,GAAG,IAAAC,eAAS,EACvEC,MAAM,IAAM;IACb,MAAM;MAAEC,WAAW;MAAEC;IAAiB,CAAC,GACtCF,MAAM,CAAEG,kBAAiB,CAAC;IAC3B,MAAM;MAAEC;IAAiC,CAAC,GAAGH,WAAW,CAAC,CAAC;IAC1D,MAAMI,aAAa,GAAGH,gBAAgB,CAAC,CAAC;IACxC,MAAMI,QAAQ,GAAGN,MAAM,CAAEO,eAAU,CAAC,CAACC,cAAc,CAAC,CAAC;IACrD,OAAO;MACNb,aAAa,EA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,GACrDO,WAAW,EAAE+B,IAAI,cAAAtC,iBAAA,cAAAA,iBAAA,GAAI;MAAE,CACpB,CAAC;IAAA,CACA,CAAC,eACT,IAAAL,WAAA,CAAAqC,GAAA,EAACzC,WAAA,CAAAgD,WAAW;MACXC,qBAAqB;MACrBC,uBAAuB;MACvBC,KAAK,EAAGzC,YAAc;MACtB0C,QAAQ,EAAGzC,eAAiB;MAC5B0C,WAAW,EAAG,IAAAC,QAAE,EAAE,SAAS,EAAE,MAAO;IAAG,CACvC,CAAC,eACF,IAAAlD,WAAA,CAAA8B,IAAA,EAAClC,WAAA,CAAAuC,oBAAM;MAACC,SAAS,EAAC,OAAO;MAACJ,OAAO,EAAC,GAAG;MAAAE,QAAA,gBACpC,IAAAlC,WAAA,CAAAqC,GAAA,EAACzC,WAAA,CAAAuD,MAAM;QACNN,qBAAqB;QACrBO,OAAO,EAAC,UAAU;QAClBC,IAAI,EAAG,IAAAH,QAAE,EAAE,QAAQ,EAAE,uBAAwB,CAAG;QAChDI,OAAO,EAAG1B;MAAc,CACxB,CAAC,eACF,IAAA5B,WAAA,CAAAqC,GAAA,EAACzC,WAAA,CAAAuD,MAAM;QACNN,qBAAqB;QACrBU,sBAAsB;QACtBH,OAAO,EAAC,SAAS;QACjBC,IAAI,EAAG,IAAAH,QAAE,EAAE,SAAS,EAAE,oBAAqB,CAAG;QAC9CM,QAAQ,EACP,CAAC,KAAK,IAAAC,4BAAqB,EAAEnD,YAAa,CAAC,CAACoD,MAC5C;QACDJ,OAAO,EAAGA,CAAA,KAAM;UACfpD,QAAQ,CAAEI,YAAa,CAAC;UACxBC,eAAe,CAAE,EAAG,CAAC;QACtB;MAAG,CACH,CAAC;IAAA,CACK,CAAC;EAAA,CACF,CAAC;AAEX","ignoreList":[]}
@@ -30,7 +30,6 @@ var _jsxRuntime = require("react/jsx-runtime");
30
30
  * Internal dependencies
31
31
  */
32
32
 
33
- const threadsEmptyArray = [];
34
33
  const isBlockCommentExperimentEnabled = window?.__experimentalEnableBlockComment;
35
34
  const modifyBlockCommentAttributes = settings => {
36
35
  if (!settings.attributes.blockCommentId) {
@@ -46,11 +45,10 @@ const modifyBlockCommentAttributes = settings => {
46
45
 
47
46
  // Apply the filter to all core blocks
48
47
  (0, _hooks.addFilter)('blocks.registerBlockType', 'block-comment/modify-core-block-attributes', modifyBlockCommentAttributes);
49
-
50
- /**
51
- * Renders the Collab sidebar.
52
- */
53
- function CollabSidebar() {
48
+ function CollabSidebarContent({
49
+ showCommentBoard,
50
+ setShowCommentBoard
51
+ }) {
54
52
  const {
55
53
  createNotice
56
54
  } = (0, _data.useDispatch)(_notices.store);
@@ -62,49 +60,27 @@ function CollabSidebar() {
62
60
  getEntityRecord
63
61
  } = (0, _data.resolveSelect)(_coreData.store);
64
62
  const {
65
- enableComplementaryArea
66
- } = (0, _data.useDispatch)(_interface.store);
67
- const [blockCommentID, setBlockCommentID] = (0, _element.useState)(null);
68
- const [showCommentBoard, setShowCommentBoard] = (0, _element.useState)(false);
69
- const {
70
- postId
63
+ postId,
64
+ threads
71
65
  } = (0, _data.useSelect)(select => {
72
- return {
73
- postId: select(_store.store).getCurrentPostId()
74
- };
75
- }, []);
76
- const postStatus = (0, _data.useSelect)(select => {
77
- const post = select(_store.store).getCurrentPost();
78
- return {
79
- postStatus: post?.status
80
- };
81
- }, []);
82
- const threads = (0, _data.useSelect)(select => {
83
- if (!postId) {
84
- return threadsEmptyArray;
85
- }
86
66
  const {
87
- getEntityRecords
88
- } = select(_coreData.store);
89
- const data = getEntityRecords('root', 'comment', {
90
- post: postId,
67
+ getCurrentPostId
68
+ } = select(_store.store);
69
+ const _postId = getCurrentPostId();
70
+ const data = !!_postId ? select(_coreData.store).getEntityRecords('root', 'comment', {
71
+ post: _postId,
91
72
  type: 'block_comment',
92
73
  status: 'any',
93
74
  per_page: 100
94
- });
95
- return data || threadsEmptyArray;
96
- }, [postId]);
97
- const clientId = (0, _data.useSelect)(select => {
98
- const {
99
- getSelectedBlockClientId
100
- } = select(_blockEditor.store);
101
- return getSelectedBlockClientId();
75
+ }) : null;
76
+ return {
77
+ postId: _postId,
78
+ threads: data
79
+ };
102
80
  }, []);
103
- const blockDetails = (0, _data.useSelect)(select => {
104
- return clientId ? select(_blockEditor.store).getBlock(clientId) : null;
105
- }, [clientId]);
106
-
107
- // Get the dispatch functions to save the comment and update the block attributes.
81
+ const {
82
+ getSelectedBlockClientId
83
+ } = (0, _data.useSelect)(_blockEditor.store);
108
84
  const {
109
85
  updateBlockAttributes
110
86
  } = (0, _data.useDispatch)(_blockEditor.store);
@@ -114,7 +90,7 @@ function CollabSidebar() {
114
90
  // Create a compare to store the references to all objects by id
115
91
  const compare = {};
116
92
  const result = [];
117
- const filteredComments = threads.filter(comment => comment.status !== 'trash');
93
+ const filteredComments = (threads !== null && threads !== void 0 ? threads : []).filter(comment => comment.status !== 'trash');
118
94
 
119
95
  // Initialize each object with an empty `reply` array
120
96
  filteredComments.forEach(item => {
@@ -136,10 +112,6 @@ function CollabSidebar() {
136
112
  });
137
113
  return result;
138
114
  }, [threads]);
139
- const openCollabBoard = () => {
140
- setShowCommentBoard(true);
141
- enableComplementaryArea('core', 'edit-post/collab-sidebar');
142
- };
143
115
 
144
116
  // Function to save the comment.
145
117
  const addNewComment = async (comment, parentCommentId) => {
@@ -161,7 +133,7 @@ function CollabSidebar() {
161
133
  if (savedRecord) {
162
134
  // If it's a main comment, update the block attributes with the comment id.
163
135
  if (!parentCommentId) {
164
- updateBlockAttributes(clientId, {
136
+ updateBlockAttributes(getSelectedBlockClientId(), {
165
137
  blockCommentId: savedRecord?.id
166
138
  });
167
139
  }
@@ -219,7 +191,7 @@ function CollabSidebar() {
219
191
  const childComment = await getEntityRecord('root', 'comment', commentId);
220
192
  await deleteEntityRecord('root', 'comment', commentId);
221
193
  if (childComment && !childComment.parent) {
222
- updateBlockAttributes(clientId, {
194
+ updateBlockAttributes(getSelectedBlockClientId(), {
223
195
  blockCommentId: undefined
224
196
  });
225
197
  }
@@ -230,20 +202,61 @@ function CollabSidebar() {
230
202
  isDismissible: true
231
203
  });
232
204
  };
233
- (0, _element.useEffect)(() => {
234
- if (blockDetails) {
235
- setBlockCommentID(blockDetails?.attributes.blockCommentId);
236
- }
237
- }, [postId, clientId]);
205
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
206
+ className: "editor-collab-sidebar-panel",
207
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_addComment.AddComment, {
208
+ onSubmit: addNewComment,
209
+ showCommentBoard: showCommentBoard,
210
+ setShowCommentBoard: setShowCommentBoard
211
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_comments.Comments, {
212
+ threads: resultComments,
213
+ onEditComment: onEditComment,
214
+ onAddReply: addNewComment,
215
+ onCommentDelete: onCommentDelete,
216
+ onCommentResolve: onCommentResolve
217
+ })]
218
+ });
219
+ }
220
+
221
+ /**
222
+ * Renders the Collab sidebar.
223
+ */
224
+ function CollabSidebar() {
225
+ const [showCommentBoard, setShowCommentBoard] = (0, _element.useState)(false);
226
+ const {
227
+ enableComplementaryArea
228
+ } = (0, _data.useDispatch)(_interface.store);
229
+ const {
230
+ postStatus
231
+ } = (0, _data.useSelect)(select => {
232
+ return {
233
+ postStatus: select(_store.store).getEditedPostAttribute('status')
234
+ };
235
+ }, []);
236
+ const {
237
+ blockCommentId
238
+ } = (0, _data.useSelect)(select => {
239
+ const {
240
+ getBlockAttributes,
241
+ getSelectedBlockClientId
242
+ } = select(_blockEditor.store);
243
+ const _clientId = getSelectedBlockClientId();
244
+ return {
245
+ blockCommentId: _clientId ? getBlockAttributes(_clientId)?.blockCommentId : null
246
+ };
247
+ }, []);
248
+ const openCollabBoard = () => {
249
+ setShowCommentBoard(true);
250
+ enableComplementaryArea('core', 'edit-post/collab-sidebar');
251
+ };
238
252
 
239
253
  // Check if the experimental flag is enabled.
240
- if (!isBlockCommentExperimentEnabled || postStatus.postStatus === 'publish') {
254
+ if (!isBlockCommentExperimentEnabled || postStatus === 'publish') {
241
255
  return null; // or maybe return some message indicating no threads are available.
242
256
  }
257
+ const AddCommentComponent = blockCommentId ? _commentButtonToolbar.default : _commentButton.default;
243
258
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
244
- children: [!blockCommentID && /*#__PURE__*/(0, _jsxRuntime.jsx)(_commentButton.default, {
245
- onClick: openCollabBoard
246
- }), blockCommentID > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_commentButtonToolbar.default, {
259
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(AddCommentComponent, {
247
260
  onClick: openCollabBoard
248
261
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_pluginSidebar.default, {
249
262
  identifier: _constants.collabSidebarName
@@ -251,20 +264,9 @@ function CollabSidebar() {
251
264
  ,
252
265
  title: (0, _i18n.__)('Comments'),
253
266
  icon: _icons.comment,
254
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
255
- className: "editor-collab-sidebar-panel",
256
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_addComment.AddComment, {
257
- threads: resultComments,
258
- onSubmit: addNewComment,
259
- showCommentBoard: showCommentBoard,
260
- setShowCommentBoard: setShowCommentBoard
261
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_comments.Comments, {
262
- threads: resultComments,
263
- onEditComment: onEditComment,
264
- onAddReply: addNewComment,
265
- onCommentDelete: onCommentDelete,
266
- onCommentResolve: onCommentResolve
267
- })]
267
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CollabSidebarContent, {
268
+ showCommentBoard: showCommentBoard,
269
+ setShowCommentBoard: setShowCommentBoard
268
270
  })
269
271
  })]
270
272
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_data","_element","_icons","_hooks","_notices","_coreData","_blockEditor","_interface","_pluginSidebar","_interopRequireDefault","_constants","_comments","_addComment","_store","_commentButton","_commentButtonToolbar","_jsxRuntime","threadsEmptyArray","isBlockCommentExperimentEnabled","window","__experimentalEnableBlockComment","modifyBlockCommentAttributes","settings","attributes","blockCommentId","type","addFilter","CollabSidebar","createNotice","useDispatch","noticesStore","saveEntityRecord","deleteEntityRecord","coreStore","getEntityRecord","resolveSelect","enableComplementaryArea","interfaceStore","blockCommentID","setBlockCommentID","useState","showCommentBoard","setShowCommentBoard","postId","useSelect","select","editorStore","getCurrentPostId","postStatus","post","getCurrentPost","status","threads","getEntityRecords","data","per_page","clientId","getSelectedBlockClientId","blockEditorStore","blockDetails","getBlock","updateBlockAttributes","resultComments","useMemo","compare","result","filteredComments","filter","comment","forEach","item","id","reply","parent","push","openCollabBoard","addNewComment","parentCommentId","args","content","comment_type","comment_approved","updatedArgs","savedRecord","__","isDismissible","onError","onCommentResolve","commentId","onEditComment","onCommentDelete","childComment","undefined","useEffect","jsxs","Fragment","children","jsx","default","onClick","identifier","collabSidebarName","title","icon","commentIcon","className","AddComment","onSubmit","Comments","onAddReply"],"sources":["@wordpress/editor/src/components/collab-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch, resolveSelect } from '@wordpress/data';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } 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 { collabSidebarName } from './constants';\nimport { Comments } from './comments';\nimport { AddComment } from './add-comment';\nimport { store as editorStore } from '../../store';\nimport AddCommentButton from './comment-button';\nimport AddCommentToolbarButton from './comment-button-toolbar';\n\nconst threadsEmptyArray = [];\n\nconst isBlockCommentExperimentEnabled =\n\twindow?.__experimentalEnableBlockComment;\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\n/**\n * Renders the Collab sidebar.\n */\nexport default function CollabSidebar() {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getEntityRecord } = resolveSelect( coreStore );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst [ blockCommentID, setBlockCommentID ] = useState( null );\n\tconst [ showCommentBoard, setShowCommentBoard ] = useState( false );\n\tconst { postId } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t};\n\t}, [] );\n\n\tconst postStatus = useSelect( ( select ) => {\n\t\tconst post = select( editorStore ).getCurrentPost();\n\t\treturn { postStatus: post?.status };\n\t}, [] );\n\n\tconst threads = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! postId ) {\n\t\t\t\treturn threadsEmptyArray;\n\t\t\t}\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst data = getEntityRecords( 'root', 'comment', {\n\t\t\t\tpost: postId,\n\t\t\t\ttype: 'block_comment',\n\t\t\t\tstatus: 'any',\n\t\t\t\tper_page: 100,\n\t\t\t} );\n\t\t\treturn data || threadsEmptyArray;\n\t\t},\n\t\t[ postId ]\n\t);\n\n\tconst clientId = useSelect( ( select ) => {\n\t\tconst { getSelectedBlockClientId } = select( blockEditorStore );\n\t\treturn getSelectedBlockClientId();\n\t}, [] );\n\n\tconst blockDetails = useSelect(\n\t\t( select ) => {\n\t\t\treturn clientId\n\t\t\t\t? select( blockEditorStore ).getBlock( clientId )\n\t\t\t\t: null;\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// Get the dispatch functions to save the comment and update the block attributes.\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\t// Process comments to build the tree structure\n\tconst resultComments = 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 filteredComments = threads.filter(\n\t\t\t( comment ) => comment.status !== 'trash'\n\t\t);\n\n\t\t// Initialize each object with an empty `reply` array\n\t\tfilteredComments.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\tfilteredComments.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\treturn result;\n\t}, [ threads ] );\n\n\tconst openCollabBoard = () => {\n\t\tsetShowCommentBoard( true );\n\t\tenableComplementaryArea( 'core', 'edit-post/collab-sidebar' );\n\t};\n\n\t// Function to save the comment.\n\tconst addNewComment = async ( comment, parentCommentId ) => {\n\t\tconst args = {\n\t\t\tpost: postId,\n\t\t\tcontent: comment,\n\t\t\tcomment_type: 'block_comment',\n\t\t\tcomment_approved: 0,\n\t\t};\n\n\t\t// Create a new object, conditionally including the parent property\n\t\tconst updatedArgs = {\n\t\t\t...args,\n\t\t\t...( parentCommentId ? { parent: parentCommentId } : {} ),\n\t\t};\n\n\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tupdatedArgs\n\t\t);\n\n\t\tif ( savedRecord ) {\n\t\t\t// If it's a main comment, update the block attributes with the comment id.\n\t\t\tif ( ! parentCommentId ) {\n\t\t\t\tupdateBlockAttributes( clientId, {\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? // translators: Reply added successfully\n\t\t\t\t\t __( 'Reply added successfully.' )\n\t\t\t\t\t: // translators: Comment 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} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onCommentResolve = async ( commentId ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tstatus: 'approved',\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\t// translators: Comment resolved successfully\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} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onEditComment = async ( commentId, comment ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tcontent: comment,\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\t// translators: Comment edited successfully\n\t\t\t\t__( 'Comment edited 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} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onError = () => {\n\t\tcreateNotice(\n\t\t\t'error',\n\t\t\t// translators: Error message when comment submission fails\n\t\t\t__(\n\t\t\t\t'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\tconst onCommentDelete = async ( commentId ) => {\n\t\tconst childComment = await getEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tcommentId\n\t\t);\n\t\tawait deleteEntityRecord( 'root', 'comment', commentId );\n\n\t\tif ( childComment && ! childComment.parent ) {\n\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\tblockCommentId: undefined,\n\t\t\t} );\n\t\t}\n\n\t\tcreateNotice(\n\t\t\t'snackbar',\n\t\t\t// translators: Comment deleted successfully\n\t\t\t__( 'Comment deleted successfully.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\tuseEffect( () => {\n\t\tif ( blockDetails ) {\n\t\t\tsetBlockCommentID( blockDetails?.attributes.blockCommentId );\n\t\t}\n\t}, [ postId, clientId ] );\n\n\t// Check if the experimental flag is enabled.\n\tif (\n\t\t! isBlockCommentExperimentEnabled ||\n\t\tpostStatus.postStatus === 'publish'\n\t) {\n\t\treturn null; // or maybe return some message indicating no threads are available.\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ ! blockCommentID && (\n\t\t\t\t<AddCommentButton onClick={ openCollabBoard } />\n\t\t\t) }\n\n\t\t\t{ blockCommentID > 0 && (\n\t\t\t\t<AddCommentToolbarButton onClick={ openCollabBoard } />\n\t\t\t) }\n\t\t\t<PluginSidebar\n\t\t\t\tidentifier={ collabSidebarName }\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<div className=\"editor-collab-sidebar-panel\">\n\t\t\t\t\t<AddComment\n\t\t\t\t\t\tthreads={ resultComments }\n\t\t\t\t\t\tonSubmit={ addNewComment }\n\t\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\t/>\n\t\t\t\t\t<Comments\n\t\t\t\t\t\tthreads={ resultComments }\n\t\t\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\t\t\tonAddReply={ addNewComment }\n\t\t\t\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\t\t\t\tonCommentResolve={ onCommentResolve }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</PluginSidebar>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,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,qBAAA,GAAAN,sBAAA,CAAAV,OAAA;AAA+D,IAAAiB,WAAA,GAAAjB,OAAA;AAtB/D;AACA;AACA;;AAWA;AACA;AACA;;AASA,MAAMkB,iBAAiB,GAAG,EAAE;AAE5B,MAAMC,+BAA+B,GACpCC,MAAM,EAAEC,gCAAgC;AACzC,MAAMC,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;AAChB,CAAC;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C,IAAAhF,WAAA,CAAAiF,GAAA,EAACrF,WAAA,CAAA8F,UAAU;UACVtD,OAAO,EAAGU,cAAgB;UAC1B6C,QAAQ,EAAG/B,aAAe;UAC1BnC,gBAAgB,EAAGA,gBAAkB;UACrCC,mBAAmB,EAAGA;QAAqB,CAC3C,CAAC,eACF,IAAA1B,WAAA,CAAAiF,GAAA,EAACtF,SAAA,CAAAiG,QAAQ;UACRxD,OAAO,EAAGU,cAAgB;UAC1B2B,aAAa,EAAGA,aAAe;UAC/BoB,UAAU,EAAGjC,aAAe;UAC5Bc,eAAe,EAAGA,eAAiB;UACnCH,gBAAgB,EAAGA;QAAkB,CACrC,CAAC;MAAA,CACE;IAAC,CACQ,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","_commentButtonToolbar","_jsxRuntime","isBlockCommentExperimentEnabled","window","__experimentalEnableBlockComment","modifyBlockCommentAttributes","settings","attributes","blockCommentId","type","addFilter","CollabSidebarContent","showCommentBoard","setShowCommentBoard","createNotice","useDispatch","noticesStore","saveEntityRecord","deleteEntityRecord","coreStore","getEntityRecord","resolveSelect","postId","threads","useSelect","select","getCurrentPostId","editorStore","_postId","data","getEntityRecords","post","status","per_page","getSelectedBlockClientId","blockEditorStore","updateBlockAttributes","resultComments","useMemo","compare","result","filteredComments","filter","comment","forEach","item","id","reply","parent","push","addNewComment","parentCommentId","args","content","comment_type","comment_approved","updatedArgs","savedRecord","__","isDismissible","onError","onCommentResolve","commentId","onEditComment","onCommentDelete","childComment","undefined","jsxs","className","children","jsx","AddComment","onSubmit","Comments","onAddReply","CollabSidebar","useState","enableComplementaryArea","interfaceStore","postStatus","getEditedPostAttribute","getBlockAttributes","_clientId","openCollabBoard","AddCommentComponent","AddCommentToolbarButton","AddCommentButton","Fragment","onClick","default","identifier","collabSidebarName","title","icon","commentIcon"],"sources":["@wordpress/editor/src/components/collab-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch, resolveSelect } 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 { store as coreStore } 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 { collabSidebarName } from './constants';\nimport { Comments } from './comments';\nimport { AddComment } from './add-comment';\nimport { store as editorStore } from '../../store';\nimport AddCommentButton from './comment-button';\nimport AddCommentToolbarButton from './comment-button-toolbar';\n\nconst isBlockCommentExperimentEnabled =\n\twindow?.__experimentalEnableBlockComment;\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( { showCommentBoard, setShowCommentBoard } ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getEntityRecord } = resolveSelect( coreStore );\n\n\tconst { postId, threads } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\t\tconst data = !! _postId\n\t\t\t? select( coreStore ).getEntityRecords( 'root', 'comment', {\n\t\t\t\t\tpost: _postId,\n\t\t\t\t\ttype: 'block_comment',\n\t\t\t\t\tstatus: 'any',\n\t\t\t\t\tper_page: 100,\n\t\t\t } )\n\t\t\t: null;\n\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t\tthreads: data,\n\t\t};\n\t}, [] );\n\n\tconst { getSelectedBlockClientId } = useSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\t// Process comments to build the tree structure\n\tconst resultComments = 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 filteredComments = ( threads ?? [] ).filter(\n\t\t\t( comment ) => comment.status !== 'trash'\n\t\t);\n\n\t\t// Initialize each object with an empty `reply` array\n\t\tfilteredComments.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\tfilteredComments.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\treturn result;\n\t}, [ threads ] );\n\n\t// Function to save the comment.\n\tconst addNewComment = async ( comment, parentCommentId ) => {\n\t\tconst args = {\n\t\t\tpost: postId,\n\t\t\tcontent: comment,\n\t\t\tcomment_type: 'block_comment',\n\t\t\tcomment_approved: 0,\n\t\t};\n\n\t\t// Create a new object, conditionally including the parent property\n\t\tconst updatedArgs = {\n\t\t\t...args,\n\t\t\t...( parentCommentId ? { parent: parentCommentId } : {} ),\n\t\t};\n\n\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tupdatedArgs\n\t\t);\n\n\t\tif ( savedRecord ) {\n\t\t\t// If it's a main comment, update the block attributes with the comment id.\n\t\t\tif ( ! parentCommentId ) {\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? // translators: Reply added successfully\n\t\t\t\t\t __( 'Reply added successfully.' )\n\t\t\t\t\t: // translators: Comment 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} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onCommentResolve = async ( commentId ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tstatus: 'approved',\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\t// translators: Comment resolved successfully\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} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onEditComment = async ( commentId, comment ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tcontent: comment,\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\t// translators: Comment edited successfully\n\t\t\t\t__( 'Comment edited 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} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onError = () => {\n\t\tcreateNotice(\n\t\t\t'error',\n\t\t\t// translators: Error message when comment submission fails\n\t\t\t__(\n\t\t\t\t'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\tconst onCommentDelete = async ( commentId ) => {\n\t\tconst childComment = await getEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tcommentId\n\t\t);\n\t\tawait deleteEntityRecord( 'root', 'comment', commentId );\n\n\t\tif ( childComment && ! childComment.parent ) {\n\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\tblockCommentId: undefined,\n\t\t\t} );\n\t\t}\n\n\t\tcreateNotice(\n\t\t\t'snackbar',\n\t\t\t// translators: Comment deleted successfully\n\t\t\t__( 'Comment deleted successfully.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\treturn (\n\t\t<div className=\"editor-collab-sidebar-panel\">\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\tthreads={ resultComments }\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/>\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\n\tconst { postStatus } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostStatus:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'status' ),\n\t\t};\n\t}, [] );\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', 'edit-post/collab-sidebar' );\n\t};\n\n\t// Check if the experimental flag is enabled.\n\tif ( ! isBlockCommentExperimentEnabled || postStatus === 'publish' ) {\n\t\treturn null; // or maybe return some message indicating no threads are available.\n\t}\n\n\tconst AddCommentComponent = blockCommentId\n\t\t? AddCommentToolbarButton\n\t\t: AddCommentButton;\n\n\treturn (\n\t\t<>\n\t\t\t<AddCommentComponent onClick={ openCollabBoard } />\n\t\t\t<PluginSidebar\n\t\t\t\tidentifier={ collabSidebarName }\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\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\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;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,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,c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