@wordpress/editor 14.15.1 → 14.17.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 (215) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +20 -20
  3. package/build/bindings/pattern-overrides.js +1 -1
  4. package/build/bindings/pattern-overrides.js.map +1 -1
  5. package/build/components/collab-sidebar/index.js +1 -4
  6. package/build/components/collab-sidebar/index.js.map +1 -1
  7. package/build/components/document-outline/check.js +3 -3
  8. package/build/components/document-outline/check.js.map +1 -1
  9. package/build/components/document-outline/index.js +2 -2
  10. package/build/components/document-outline/index.js.map +1 -1
  11. package/build/components/header/index.js +14 -8
  12. package/build/components/header/index.js.map +1 -1
  13. package/build/components/page-attributes/check.js +3 -3
  14. package/build/components/page-attributes/check.js.map +1 -1
  15. package/build/components/post-excerpt/index.js +1 -1
  16. package/build/components/post-excerpt/index.js.map +1 -1
  17. package/build/components/post-pending-status/check.js +3 -3
  18. package/build/components/post-pending-status/check.js.map +1 -1
  19. package/build/components/post-preview-button/index.js +7 -1
  20. package/build/components/post-preview-button/index.js.map +1 -1
  21. package/build/components/post-publish-button/index.js +2 -2
  22. package/build/components/post-publish-button/index.js.map +1 -1
  23. package/build/components/post-publish-button/post-publish-button-or-toggle.js +1 -1
  24. package/build/components/post-publish-button/post-publish-button-or-toggle.js.map +1 -1
  25. package/build/components/post-schedule/check.js +3 -3
  26. package/build/components/post-schedule/check.js.map +1 -1
  27. package/build/components/post-schedule/index.js +1 -1
  28. package/build/components/post-schedule/index.js.map +1 -1
  29. package/build/components/post-sticky/check.js +3 -3
  30. package/build/components/post-sticky/check.js.map +1 -1
  31. package/build/components/post-taxonomies/check.js +1 -1
  32. package/build/components/post-taxonomies/check.js.map +1 -1
  33. package/build/components/post-template/swap-template-button.js +1 -1
  34. package/build/components/post-template/swap-template-button.js.map +1 -1
  35. package/build/components/post-trash/check.js +3 -3
  36. package/build/components/post-trash/check.js.map +1 -1
  37. package/build/components/post-type-support-check/index.js +6 -6
  38. package/build/components/post-type-support-check/index.js.map +1 -1
  39. package/build/components/post-url/check.js +3 -3
  40. package/build/components/post-url/check.js.map +1 -1
  41. package/build/components/preferences-modal/index.js +1 -1
  42. package/build/components/preferences-modal/index.js.map +1 -1
  43. package/build/components/provider/index.js +25 -17
  44. package/build/components/provider/index.js.map +1 -1
  45. package/build/components/sidebar/post-summary.js +1 -1
  46. package/build/components/sidebar/post-summary.js.map +1 -1
  47. package/build/components/start-page-options/index.js +15 -6
  48. package/build/components/start-page-options/index.js.map +1 -1
  49. package/build/components/theme-support-check/index.js +4 -4
  50. package/build/components/theme-support-check/index.js.map +1 -1
  51. package/build/components/visual-editor/edit-template-blocks-notification.js +1 -1
  52. package/build/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  53. package/build/components/visual-editor/index.js +2 -2
  54. package/build/components/visual-editor/index.js.map +1 -1
  55. package/build/dataviews/fields/content-preview/content-preview-view.js +101 -0
  56. package/build/dataviews/fields/content-preview/content-preview-view.js.map +1 -0
  57. package/build/dataviews/fields/content-preview/index.js +26 -0
  58. package/build/dataviews/fields/content-preview/index.js.map +1 -0
  59. package/build/dataviews/store/private-actions.js +3 -1
  60. package/build/dataviews/store/private-actions.js.map +1 -1
  61. package/build/store/private-actions.js +1 -1
  62. package/build/store/private-actions.js.map +1 -1
  63. package/build/store/private-selectors.js +7 -1
  64. package/build/store/private-selectors.js.map +1 -1
  65. package/build/store/selectors.js +4 -4
  66. package/build/store/selectors.js.map +1 -1
  67. package/build-module/bindings/pattern-overrides.js +1 -1
  68. package/build-module/bindings/pattern-overrides.js.map +1 -1
  69. package/build-module/components/collab-sidebar/index.js +1 -4
  70. package/build-module/components/collab-sidebar/index.js.map +1 -1
  71. package/build-module/components/document-outline/check.js +3 -3
  72. package/build-module/components/document-outline/check.js.map +1 -1
  73. package/build-module/components/document-outline/index.js +2 -2
  74. package/build-module/components/document-outline/index.js.map +1 -1
  75. package/build-module/components/header/index.js +14 -8
  76. package/build-module/components/header/index.js.map +1 -1
  77. package/build-module/components/page-attributes/check.js +3 -3
  78. package/build-module/components/page-attributes/check.js.map +1 -1
  79. package/build-module/components/post-excerpt/index.js +1 -1
  80. package/build-module/components/post-excerpt/index.js.map +1 -1
  81. package/build-module/components/post-pending-status/check.js +3 -3
  82. package/build-module/components/post-pending-status/check.js.map +1 -1
  83. package/build-module/components/post-preview-button/index.js +7 -1
  84. package/build-module/components/post-preview-button/index.js.map +1 -1
  85. package/build-module/components/post-publish-button/index.js +2 -2
  86. package/build-module/components/post-publish-button/index.js.map +1 -1
  87. package/build-module/components/post-publish-button/post-publish-button-or-toggle.js +1 -1
  88. package/build-module/components/post-publish-button/post-publish-button-or-toggle.js.map +1 -1
  89. package/build-module/components/post-schedule/check.js +3 -3
  90. package/build-module/components/post-schedule/check.js.map +1 -1
  91. package/build-module/components/post-schedule/index.js +1 -1
  92. package/build-module/components/post-schedule/index.js.map +1 -1
  93. package/build-module/components/post-sticky/check.js +3 -3
  94. package/build-module/components/post-sticky/check.js.map +1 -1
  95. package/build-module/components/post-taxonomies/check.js +1 -1
  96. package/build-module/components/post-taxonomies/check.js.map +1 -1
  97. package/build-module/components/post-template/swap-template-button.js +1 -1
  98. package/build-module/components/post-template/swap-template-button.js.map +1 -1
  99. package/build-module/components/post-trash/check.js +3 -3
  100. package/build-module/components/post-trash/check.js.map +1 -1
  101. package/build-module/components/post-type-support-check/index.js +6 -6
  102. package/build-module/components/post-type-support-check/index.js.map +1 -1
  103. package/build-module/components/post-url/check.js +3 -3
  104. package/build-module/components/post-url/check.js.map +1 -1
  105. package/build-module/components/preferences-modal/index.js +1 -1
  106. package/build-module/components/preferences-modal/index.js.map +1 -1
  107. package/build-module/components/provider/index.js +25 -17
  108. package/build-module/components/provider/index.js.map +1 -1
  109. package/build-module/components/sidebar/post-summary.js +1 -1
  110. package/build-module/components/sidebar/post-summary.js.map +1 -1
  111. package/build-module/components/start-page-options/index.js +15 -6
  112. package/build-module/components/start-page-options/index.js.map +1 -1
  113. package/build-module/components/theme-support-check/index.js +4 -4
  114. package/build-module/components/theme-support-check/index.js.map +1 -1
  115. package/build-module/components/visual-editor/edit-template-blocks-notification.js +1 -1
  116. package/build-module/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  117. package/build-module/components/visual-editor/index.js +2 -2
  118. package/build-module/components/visual-editor/index.js.map +1 -1
  119. package/build-module/dataviews/fields/content-preview/content-preview-view.js +95 -0
  120. package/build-module/dataviews/fields/content-preview/content-preview-view.js.map +1 -0
  121. package/build-module/dataviews/fields/content-preview/index.js +19 -0
  122. package/build-module/dataviews/fields/content-preview/index.js.map +1 -0
  123. package/build-module/dataviews/store/private-actions.js +2 -1
  124. package/build-module/dataviews/store/private-actions.js.map +1 -1
  125. package/build-module/store/private-actions.js +1 -1
  126. package/build-module/store/private-actions.js.map +1 -1
  127. package/build-module/store/private-selectors.js +7 -1
  128. package/build-module/store/private-selectors.js.map +1 -1
  129. package/build-module/store/selectors.js +4 -4
  130. package/build-module/store/selectors.js.map +1 -1
  131. package/build-style/style-rtl.css +35 -31
  132. package/build-style/style.css +35 -31
  133. package/build-types/components/autocompleters/user.d.ts +5 -1
  134. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  135. package/build-types/components/document-outline/check.d.ts +5 -5
  136. package/build-types/components/document-outline/check.d.ts.map +1 -1
  137. package/build-types/components/header/index.d.ts.map +1 -1
  138. package/build-types/components/page-attributes/check.d.ts +5 -5
  139. package/build-types/components/page-attributes/check.d.ts.map +1 -1
  140. package/build-types/components/post-author/hook.d.ts +1 -1
  141. package/build-types/components/post-pending-status/check.d.ts +5 -5
  142. package/build-types/components/post-pending-status/check.d.ts.map +1 -1
  143. package/build-types/components/post-preview-button/index.d.ts.map +1 -1
  144. package/build-types/components/post-schedule/check.d.ts +5 -5
  145. package/build-types/components/post-schedule/check.d.ts.map +1 -1
  146. package/build-types/components/post-sticky/check.d.ts +5 -5
  147. package/build-types/components/post-sticky/check.d.ts.map +1 -1
  148. package/build-types/components/post-taxonomies/check.d.ts +2 -2
  149. package/build-types/components/post-taxonomies/check.d.ts.map +1 -1
  150. package/build-types/components/post-taxonomies/index.d.ts +1 -1
  151. package/build-types/components/post-taxonomies/index.d.ts.map +1 -1
  152. package/build-types/components/post-template/hooks.d.ts +1 -1
  153. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  154. package/build-types/components/post-trash/check.d.ts +5 -5
  155. package/build-types/components/post-trash/check.d.ts.map +1 -1
  156. package/build-types/components/post-type-support-check/index.d.ts +8 -8
  157. package/build-types/components/post-type-support-check/index.d.ts.map +1 -1
  158. package/build-types/components/post-url/check.d.ts +5 -5
  159. package/build-types/components/post-url/check.d.ts.map +1 -1
  160. package/build-types/components/provider/index.d.ts +9 -9
  161. package/build-types/components/provider/index.d.ts.map +1 -1
  162. package/build-types/components/start-page-options/index.d.ts.map +1 -1
  163. package/build-types/components/theme-support-check/index.d.ts +6 -6
  164. package/build-types/components/theme-support-check/index.d.ts.map +1 -1
  165. package/build-types/components/visual-editor/edit-template-blocks-notification.d.ts +1 -1
  166. package/build-types/dataviews/fields/content-preview/content-preview-view.d.ts +5 -0
  167. package/build-types/dataviews/fields/content-preview/content-preview-view.d.ts.map +1 -0
  168. package/build-types/dataviews/fields/content-preview/index.d.ts +8 -0
  169. package/build-types/dataviews/fields/content-preview/index.d.ts.map +1 -0
  170. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  171. package/build-types/store/private-selectors.d.ts.map +1 -1
  172. package/build-types/store/selectors.d.ts +5 -5
  173. package/build-types/store/selectors.d.ts.map +1 -1
  174. package/package.json +37 -37
  175. package/src/bindings/pattern-overrides.js +1 -1
  176. package/src/components/autocompleters/style.scss +1 -1
  177. package/src/components/collab-sidebar/index.js +1 -4
  178. package/src/components/document-bar/style.scss +4 -2
  179. package/src/components/document-outline/check.js +3 -3
  180. package/src/components/document-outline/index.js +2 -2
  181. package/src/components/document-tools/style.scss +3 -2
  182. package/src/components/header/index.js +26 -23
  183. package/src/components/page-attributes/check.js +3 -3
  184. package/src/components/post-excerpt/index.js +1 -1
  185. package/src/components/post-featured-image/style.scss +4 -2
  186. package/src/components/post-pending-status/check.js +3 -3
  187. package/src/components/post-preview-button/index.js +5 -1
  188. package/src/components/post-publish-button/index.js +2 -2
  189. package/src/components/post-publish-button/post-publish-button-or-toggle.js +1 -1
  190. package/src/components/post-publish-panel/style.scss +5 -3
  191. package/src/components/post-schedule/check.js +3 -3
  192. package/src/components/post-schedule/index.js +1 -1
  193. package/src/components/post-sticky/check.js +3 -3
  194. package/src/components/post-taxonomies/check.js +1 -1
  195. package/src/components/post-template/swap-template-button.js +1 -1
  196. package/src/components/post-text-editor/style.scss +4 -2
  197. package/src/components/post-trash/check.js +3 -3
  198. package/src/components/post-type-support-check/index.js +6 -6
  199. package/src/components/post-url/check.js +3 -3
  200. package/src/components/preferences-modal/index.js +1 -1
  201. package/src/components/provider/index.js +32 -20
  202. package/src/components/sidebar/post-summary.js +1 -1
  203. package/src/components/start-page-options/index.js +20 -12
  204. package/src/components/theme-support-check/index.js +4 -4
  205. package/src/components/visual-editor/edit-template-blocks-notification.js +1 -1
  206. package/src/components/visual-editor/index.js +2 -2
  207. package/src/dataviews/fields/content-preview/content-preview-view.tsx +108 -0
  208. package/src/dataviews/fields/content-preview/index.tsx +21 -0
  209. package/src/dataviews/fields/content-preview/style.scss +21 -0
  210. package/src/dataviews/store/private-actions.ts +4 -0
  211. package/src/store/private-actions.js +1 -1
  212. package/src/store/private-selectors.js +15 -8
  213. package/src/store/selectors.js +4 -4
  214. package/src/style.scss +1 -0
  215. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 14.17.0 (2025-01-29)
6
+
7
+ ## 14.16.0 (2025-01-15)
8
+
5
9
  ## 14.15.0 (2025-01-02)
6
10
 
7
11
  ## 14.14.0 (2024-12-11)
package/README.md CHANGED
@@ -293,11 +293,11 @@ Component check if there are any headings (core/heading blocks) present in the d
293
293
  _Parameters_
294
294
 
295
295
  - _props_ `Object`: Props.
296
- - _props.children_ `React.ReactElement`: Children to be rendered.
296
+ - _props.children_ `React.ReactNode`: Children to be rendered.
297
297
 
298
298
  _Returns_
299
299
 
300
- - `React.ReactElement`: The component to be rendered or null if there are headings.
300
+ - `React.ReactNode`: The component to be rendered or null if there are headings.
301
301
 
302
302
  ### EditorHistoryRedo
303
303
 
@@ -379,7 +379,7 @@ _Parameters_
379
379
  - _props.post_ `[Object]`: The post object to edit. This is required.
380
380
  - _props.\_\_unstableTemplate_ `[Object]`: The template object wrapper the edited post. This is optional and can only be used when the post type supports templates (like posts and pages).
381
381
  - _props.settings_ `[Object]`: The settings object to use for the editor. This is optional and can be used to override the default settings.
382
- - _props.children_ `[Element]`: Children elements for which the BlockEditorProvider context should apply. This is optional.
382
+ - _props.children_ `[React.ReactNode]`: Children elements for which the BlockEditorProvider context should apply. This is optional.
383
383
 
384
384
  _Returns_
385
385
 
@@ -524,11 +524,11 @@ Wrapper component that renders its children only if the post type supports page
524
524
  _Parameters_
525
525
 
526
526
  - _props_ `Object`: - The component props.
527
- - _props.children_ `React.ReactElement`: - The child components to render.
527
+ - _props.children_ `React.ReactNode`: - The child components to render.
528
528
 
529
529
  _Returns_
530
530
 
531
- - `React.ReactElement`: The rendered child components or null if page attributes are not supported.
531
+ - `React.ReactNode`: The rendered child components or null if page attributes are not supported.
532
532
 
533
533
  ### PageAttributesOrder
534
534
 
@@ -1211,11 +1211,11 @@ This component checks the publishing status of the current post. If the post is
1211
1211
  _Parameters_
1212
1212
 
1213
1213
  - _props_ `Object`: Component properties.
1214
- - _props.children_ `React.ReactElement`: Children to be rendered.
1214
+ - _props.children_ `React.ReactNode`: Children to be rendered.
1215
1215
 
1216
1216
  _Returns_
1217
1217
 
1218
- - `React.ReactElement`: The rendered child elements or null if the post is already published or the user doesn't have the capability to publish.
1218
+ - `React.ReactNode`: The rendered child elements or null if the post is already published or the user doesn't have the capability to publish.
1219
1219
 
1220
1220
  ### PostPingbacks
1221
1221
 
@@ -1287,11 +1287,11 @@ Wrapper component that renders its children only if post has a publish action.
1287
1287
  _Parameters_
1288
1288
 
1289
1289
  - _props_ `Object`: Props.
1290
- - _props.children_ `React.ReactElement`: Children to be rendered.
1290
+ - _props.children_ `React.ReactNode`: Children to be rendered.
1291
1291
 
1292
1292
  _Returns_
1293
1293
 
1294
- - `React.ReactElement`: - The component to be rendered or null if there is no publish action.
1294
+ - `React.ReactNode`: - The component to be rendered or null if there is no publish action.
1295
1295
 
1296
1296
  ### PostScheduleLabel
1297
1297
 
@@ -1328,11 +1328,11 @@ Wrapper component that renders its children only if post has a sticky action.
1328
1328
  _Parameters_
1329
1329
 
1330
1330
  - _props_ `Object`: Props.
1331
- - _props.children_ `React.ReactElement`: Children to be rendered.
1331
+ - _props.children_ `React.ReactNode`: Children to be rendered.
1332
1332
 
1333
1333
  _Returns_
1334
1334
 
1335
- - `React.ReactElement`: The component to be rendered or null if post type is not 'post' or hasStickyAction is false.
1335
+ - `React.ReactNode`: The component to be rendered or null if post type is not 'post' or hasStickyAction is false.
1336
1336
 
1337
1337
  ### PostSwitchToDraftButton
1338
1338
 
@@ -1374,7 +1374,7 @@ _Parameters_
1374
1374
 
1375
1375
  _Returns_
1376
1376
 
1377
- - `React.ReactElement`: The rendered children components or null if the current post type has no taxonomies.
1377
+ - `React.ReactNode`: The rendered children components or null if the current post type has no taxonomies.
1378
1378
 
1379
1379
  ### PostTaxonomiesFlatTermSelector
1380
1380
 
@@ -1463,11 +1463,11 @@ Wrapper component that renders its children only if the post can be trashed.
1463
1463
  _Parameters_
1464
1464
 
1465
1465
  - _props_ `Object`: The component props.
1466
- - _props.children_ `React.ReactElement`: The child components.
1466
+ - _props.children_ `React.ReactNode`: The child components.
1467
1467
 
1468
1468
  _Returns_
1469
1469
 
1470
- - `React.ReactElement | null`: The rendered child components or null if the post can't be trashed.
1470
+ - `React.ReactNode`: The rendered child components or null if the post can't be trashed.
1471
1471
 
1472
1472
  ### PostTypeSupportCheck
1473
1473
 
@@ -1476,12 +1476,12 @@ A component which renders its own children only if the current editor post type
1476
1476
  _Parameters_
1477
1477
 
1478
1478
  - _props_ `Object`: Props.
1479
- - _props.children_ `React.ReactElement`: Children to be rendered if post type supports.
1479
+ - _props.children_ `React.ReactNode`: Children to be rendered if post type supports.
1480
1480
  - _props.supportKeys_ `(string|string[])`: String or string array of keys to test.
1481
1481
 
1482
1482
  _Returns_
1483
1483
 
1484
- - `React.ReactElement`: The component to be rendered.
1484
+ - `React.ReactNode`: The component to be rendered.
1485
1485
 
1486
1486
  ### PostURL
1487
1487
 
@@ -1509,11 +1509,11 @@ Check if the post URL is valid and visible.
1509
1509
  _Parameters_
1510
1510
 
1511
1511
  - _props_ `Object`: The component props.
1512
- - _props.children_ `React.ReactElement`: The child components.
1512
+ - _props.children_ `React.ReactNode`: The child components.
1513
1513
 
1514
1514
  _Returns_
1515
1515
 
1516
- - `React.ReactElement`: The child components if the post URL is valid and visible, otherwise null.
1516
+ - `React.ReactNode`: The child components if the post URL is valid and visible, otherwise null.
1517
1517
 
1518
1518
  ### PostURLLabel
1519
1519
 
@@ -1657,12 +1657,12 @@ Checks if the current theme supports specific features and renders the children
1657
1657
  _Parameters_
1658
1658
 
1659
1659
  - _props_ `Object`: The component props.
1660
- - _props.children_ `React.ReactElement`: The children to render if the theme supports the specified features.
1660
+ - _props.children_ `React.ReactNode`: The children to render if the theme supports the specified features.
1661
1661
  - _props.supportKeys_ `string|string[]`: The key(s) of the theme support(s) to check.
1662
1662
 
1663
1663
  _Returns_
1664
1664
 
1665
- - `React.ReactElement`: The rendered children if the theme supports the specified features, otherwise null.
1665
+ - `React.ReactNode`: The rendered children if the theme supports the specified features, otherwise null.
1666
1666
 
1667
1667
  ### TimeToRead
1668
1668
 
@@ -28,7 +28,7 @@ var _default = exports.default = {
28
28
  for (const attributeName of Object.keys(bindings)) {
29
29
  const overridableValue = patternOverridesContent?.[currentBlockAttributes?.metadata?.name]?.[attributeName];
30
30
 
31
- // If it has not been overriden, return the original value.
31
+ // If it has not been overridden, return the original value.
32
32
  // Check undefined because empty string is a valid value.
33
33
  if (overridableValue === undefined) {
34
34
  overridesValues[attributeName] = currentBlockAttributes[attributeName];
@@ -1 +1 @@
1
- {"version":3,"names":["_blockEditor","require","CONTENT","_default","exports","default","name","getValues","select","clientId","context","bindings","patternOverridesContent","getBlockAttributes","blockEditorStore","currentBlockAttributes","overridesValues","attributeName","Object","keys","overridableValue","metadata","undefined","setValues","dispatch","getBlockParentsByBlockName","getBlocks","blockName","patternClientId","attributes","entries","reduce","attrs","key","newValue","syncBlocksWithSameName","blocks","block","updateBlockAttributes","innerBlocks","currentBindingValue","acc","value","canUserEditValue"],"sources":["@wordpress/editor/src/bindings/pattern-overrides.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nconst CONTENT = 'content';\n\nexport default {\n\tname: 'core/pattern-overrides',\n\tgetValues( { select, clientId, context, bindings } ) {\n\t\tconst patternOverridesContent = context[ 'pattern/overrides' ];\n\t\tconst { getBlockAttributes } = select( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\n\t\tconst overridesValues = {};\n\t\tfor ( const attributeName of Object.keys( bindings ) ) {\n\t\t\tconst overridableValue =\n\t\t\t\tpatternOverridesContent?.[\n\t\t\t\t\tcurrentBlockAttributes?.metadata?.name\n\t\t\t\t]?.[ attributeName ];\n\n\t\t\t// If it has not been overriden, return the original value.\n\t\t\t// Check undefined because empty string is a valid value.\n\t\t\tif ( overridableValue === undefined ) {\n\t\t\t\toverridesValues[ attributeName ] =\n\t\t\t\t\tcurrentBlockAttributes[ attributeName ];\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\toverridesValues[ attributeName ] =\n\t\t\t\t\toverridableValue === '' ? undefined : overridableValue;\n\t\t\t}\n\t\t}\n\t\treturn overridesValues;\n\t},\n\tsetValues( { select, dispatch, clientId, bindings } ) {\n\t\tconst { getBlockAttributes, getBlockParentsByBlockName, getBlocks } =\n\t\t\tselect( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\t\tconst blockName = currentBlockAttributes?.metadata?.name;\n\t\tif ( ! blockName ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\tclientId,\n\t\t\t'core/block',\n\t\t\ttrue\n\t\t);\n\n\t\t// Extract the updated attributes from the source bindings.\n\t\tconst attributes = Object.entries( bindings ).reduce(\n\t\t\t( attrs, [ key, { newValue } ] ) => {\n\t\t\t\tattrs[ key ] = newValue;\n\t\t\t\treturn attrs;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\t// If there is no pattern client ID, sync blocks with the same name and same attributes.\n\t\tif ( ! patternClientId ) {\n\t\t\tconst syncBlocksWithSameName = ( blocks ) => {\n\t\t\t\tfor ( const block of blocks ) {\n\t\t\t\t\tif ( block.attributes?.metadata?.name === blockName ) {\n\t\t\t\t\t\tdispatch( blockEditorStore ).updateBlockAttributes(\n\t\t\t\t\t\t\tblock.clientId,\n\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tsyncBlocksWithSameName( block.innerBlocks );\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tsyncBlocksWithSameName( getBlocks() );\n\t\t\treturn;\n\t\t}\n\t\tconst currentBindingValue =\n\t\t\tgetBlockAttributes( patternClientId )?.[ CONTENT ];\n\n\t\tdispatch( blockEditorStore ).updateBlockAttributes( patternClientId, {\n\t\t\t[ CONTENT ]: {\n\t\t\t\t...currentBindingValue,\n\t\t\t\t[ blockName ]: {\n\t\t\t\t\t...currentBindingValue?.[ blockName ],\n\t\t\t\t\t...Object.entries( attributes ).reduce(\n\t\t\t\t\t\t( acc, [ key, value ] ) => {\n\t\t\t\t\t\t\t// TODO: We need a way to represent `undefined` in the serialized overrides.\n\t\t\t\t\t\t\t// Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871\n\t\t\t\t\t\t\t// We use an empty string to represent undefined for now until\n\t\t\t\t\t\t\t// we support a richer format for overrides and the block bindings API.\n\t\t\t\t\t\t\tacc[ key ] = value === undefined ? '' : value;\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{}\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t},\n\t\t} );\n\t},\n\tcanUserEditValue: () => true,\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,MAAMC,OAAO,GAAG,SAAS;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEX;EACdC,IAAI,EAAE,wBAAwB;EAC9BC,SAASA,CAAE;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,OAAO;IAAEC;EAAS,CAAC,EAAG;IACpD,MAAMC,uBAAuB,GAAGF,OAAO,CAAE,mBAAmB,CAAE;IAC9D,MAAM;MAAEG;IAAmB,CAAC,GAAGL,MAAM,CAAEM,kBAAiB,CAAC;IACzD,MAAMC,sBAAsB,GAAGF,kBAAkB,CAAEJ,QAAS,CAAC;IAE7D,MAAMO,eAAe,GAAG,CAAC,CAAC;IAC1B,KAAM,MAAMC,aAAa,IAAIC,MAAM,CAACC,IAAI,CAAER,QAAS,CAAC,EAAG;MACtD,MAAMS,gBAAgB,GACrBR,uBAAuB,GACtBG,sBAAsB,EAAEM,QAAQ,EAAEf,IAAI,CACtC,GAAIW,aAAa,CAAE;;MAErB;MACA;MACA,IAAKG,gBAAgB,KAAKE,SAAS,EAAG;QACrCN,eAAe,CAAEC,aAAa,CAAE,GAC/BF,sBAAsB,CAAEE,aAAa,CAAE;QACxC;MACD,CAAC,MAAM;QACND,eAAe,CAAEC,aAAa,CAAE,GAC/BG,gBAAgB,KAAK,EAAE,GAAGE,SAAS,GAAGF,gBAA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GAAI1B,OAAO,CAAE;IAEnDsB,QAAQ,CAAEV,kBAAiB,CAAC,CAACwB,qBAAqB,CAAEV,eAAe,EAAE;MACpE,CAAE1B,OAAO,GAAI;QACZ,GAAGsC,mBAAmB;QACtB,CAAEb,SAAS,GAAI;UACd,GAAGa,mBAAmB,GAAIb,SAAS,CAAE;UACrC,GAAGT,MAAM,CAACY,OAAO,CAAED,UAAW,CAAC,CAACE,MAAM,CACrC,CAAEU,GAAG,EAAE,CAAER,GAAG,EAAES,KAAK,CAAE,KAAM;YAC1B;YACA;YACA;YACA;YACAD,GAAG,CAAER,GAAG,CAAE,GAAGS,KAAK,KAAKpB,SAAS,GAAG,EAAE,GAAGoB,KAAK;YAC7C,OAAOD,GAAG;UACX,CAAC,EACD,CAAC,CACF;QACD;MACD;IACD,CAAE,CAAC;EACJ,CAAC;EACDE,gBAAgB,EAAEA,CAAA,KAAM;AACzB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_blockEditor","require","CONTENT","_default","exports","default","name","getValues","select","clientId","context","bindings","patternOverridesContent","getBlockAttributes","blockEditorStore","currentBlockAttributes","overridesValues","attributeName","Object","keys","overridableValue","metadata","undefined","setValues","dispatch","getBlockParentsByBlockName","getBlocks","blockName","patternClientId","attributes","entries","reduce","attrs","key","newValue","syncBlocksWithSameName","blocks","block","updateBlockAttributes","innerBlocks","currentBindingValue","acc","value","canUserEditValue"],"sources":["@wordpress/editor/src/bindings/pattern-overrides.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nconst CONTENT = 'content';\n\nexport default {\n\tname: 'core/pattern-overrides',\n\tgetValues( { select, clientId, context, bindings } ) {\n\t\tconst patternOverridesContent = context[ 'pattern/overrides' ];\n\t\tconst { getBlockAttributes } = select( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\n\t\tconst overridesValues = {};\n\t\tfor ( const attributeName of Object.keys( bindings ) ) {\n\t\t\tconst overridableValue =\n\t\t\t\tpatternOverridesContent?.[\n\t\t\t\t\tcurrentBlockAttributes?.metadata?.name\n\t\t\t\t]?.[ attributeName ];\n\n\t\t\t// If it has not been overridden, return the original value.\n\t\t\t// Check undefined because empty string is a valid value.\n\t\t\tif ( overridableValue === undefined ) {\n\t\t\t\toverridesValues[ attributeName ] =\n\t\t\t\t\tcurrentBlockAttributes[ attributeName ];\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\toverridesValues[ attributeName ] =\n\t\t\t\t\toverridableValue === '' ? undefined : overridableValue;\n\t\t\t}\n\t\t}\n\t\treturn overridesValues;\n\t},\n\tsetValues( { select, dispatch, clientId, bindings } ) {\n\t\tconst { getBlockAttributes, getBlockParentsByBlockName, getBlocks } =\n\t\t\tselect( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\t\tconst blockName = currentBlockAttributes?.metadata?.name;\n\t\tif ( ! blockName ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\tclientId,\n\t\t\t'core/block',\n\t\t\ttrue\n\t\t);\n\n\t\t// Extract the updated attributes from the source bindings.\n\t\tconst attributes = Object.entries( bindings ).reduce(\n\t\t\t( attrs, [ key, { newValue } ] ) => {\n\t\t\t\tattrs[ key ] = newValue;\n\t\t\t\treturn attrs;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\t// If there is no pattern client ID, sync blocks with the same name and same attributes.\n\t\tif ( ! patternClientId ) {\n\t\t\tconst syncBlocksWithSameName = ( blocks ) => {\n\t\t\t\tfor ( const block of blocks ) {\n\t\t\t\t\tif ( block.attributes?.metadata?.name === blockName ) {\n\t\t\t\t\t\tdispatch( blockEditorStore ).updateBlockAttributes(\n\t\t\t\t\t\t\tblock.clientId,\n\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tsyncBlocksWithSameName( block.innerBlocks );\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tsyncBlocksWithSameName( getBlocks() );\n\t\t\treturn;\n\t\t}\n\t\tconst currentBindingValue =\n\t\t\tgetBlockAttributes( patternClientId )?.[ CONTENT ];\n\n\t\tdispatch( blockEditorStore ).updateBlockAttributes( patternClientId, {\n\t\t\t[ CONTENT ]: {\n\t\t\t\t...currentBindingValue,\n\t\t\t\t[ blockName ]: {\n\t\t\t\t\t...currentBindingValue?.[ blockName ],\n\t\t\t\t\t...Object.entries( attributes ).reduce(\n\t\t\t\t\t\t( acc, [ key, value ] ) => {\n\t\t\t\t\t\t\t// TODO: We need a way to represent `undefined` in the serialized overrides.\n\t\t\t\t\t\t\t// Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871\n\t\t\t\t\t\t\t// We use an empty string to represent undefined for now until\n\t\t\t\t\t\t\t// we support a richer format for overrides and the block bindings API.\n\t\t\t\t\t\t\tacc[ key ] = value === undefined ? '' : value;\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{}\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t},\n\t\t} );\n\t},\n\tcanUserEditValue: () => true,\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,MAAMC,OAAO,GAAG,SAAS;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEX;EACdC,IAAI,EAAE,wBAAwB;EAC9BC,SAASA,CAAE;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,OAAO;IAAEC;EAAS,CAAC,EAAG;IACpD,MAAMC,uBAAuB,GAAGF,OAAO,CAAE,mBAAmB,CAAE;IAC9D,MAAM;MAAEG;IAAmB,CAAC,GAAGL,MAAM,CAAEM,kBAAiB,CAAC;IACzD,MAAMC,sBAAsB,GAAGF,kBAAkB,CAAEJ,QAAS,CAAC;IAE7D,MAAMO,eAAe,GAAG,CAAC,CAAC;IAC1B,KAAM,MAAMC,aAA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AAK,IAAID,MAAM,EAAG;UAC7B,IAAKC,KAAK,CAACR,UAAU,EAAER,QAAQ,EAAEf,IAAI,KAAKqB,SAAS,EAAG;YACrDH,QAAQ,CAAEV,kBAAiB,CAAC,CAACwB,qBAAqB,CACjDD,KAAK,CAAC5B,QAAQ,EACdoB,UACD,CAAC;UACF;UACAM,sBAAsB,CAAEE,KAAK,CAACE,WAAY,CAAC;QAC5C;MACD,CAAC;MAEDJ,sBAAsB,CAAET,SAAS,CAAC,CAAE,CAAC;MACrC;IACD;IACA,MAAMc,mBAAmB,GACxB3B,kBAAkB,CAAEe,eAAgB,CAAC,GAAI1B,OAAO,CAAE;IAEnDsB,QAAQ,CAAEV,kBAAiB,CAAC,CAACwB,qBAAqB,CAAEV,eAAe,EAAE;MACpE,CAAE1B,OAAO,GAAI;QACZ,GAAGsC,mBAAmB;QACtB,CAAEb,SAAS,GAAI;UACd,GAAGa,mBAAmB,GAAIb,SAAS,CAAE;UACrC,GAAGT,MAAM,CAACY,OAAO,CAAED,UAAW,CAAC,CAACE,MAAM,CACrC,CAAEU,GAAG,EAAE,CAAER,GAAG,EAAES,KAAK,CAAE,KAAM;YAC1B;YACA;YACA;YACA;YACAD,GAAG,CAAER,GAAG,CAAE,GAAGS,KAAK,KAAKpB,SAAS,GAAG,EAAE,GAAGoB,KAAK;YAC7C,OAAOD,GAAG;UACX,CAAC,EACD,CAAC,CACF;QACD;MACD;IACD,CAAE,CAAC;EACJ,CAAC;EACDE,gBAAgB,EAAEA,CAAA,KAAM;AACzB,CAAC","ignoreList":[]}
@@ -33,7 +33,6 @@ var _jsxRuntime = require("react/jsx-runtime");
33
33
  * Internal dependencies
34
34
  */
35
35
 
36
- const isBlockCommentExperimentEnabled = window?.__experimentalEnableBlockComment;
37
36
  const modifyBlockCommentAttributes = settings => {
38
37
  if (!settings.attributes.blockCommentId) {
39
38
  settings.attributes = {
@@ -306,9 +305,7 @@ function CollabSidebar() {
306
305
  }
307
306
  });
308
307
  }
309
-
310
- // Check if the experimental flag is enabled.
311
- if (!isBlockCommentExperimentEnabled || postStatus === 'publish') {
308
+ if (postStatus === 'publish') {
312
309
  return null; // or maybe return some message indicating no threads are available.
313
310
  }
314
311
  const AddCommentComponent = blockCommentId ? _commentButtonToolbar.default : _commentButton.default;
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_data","_element","_icons","_hooks","_notices","_coreData","_blockEditor","_interface","_pluginSidebar","_interopRequireDefault","_constants","_comments","_addComment","_store","_commentButton","_commentButtonToolbar","_globalStylesProvider","_utils","_jsxRuntime","isBlockCommentExperimentEnabled","window","__experimentalEnableBlockComment","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","addNewComment","comment","parentCommentId","args","post","content","comment_type","comment_approved","updatedArgs","parent","savedRecord","id","__","isDismissible","onError","onCommentResolve","commentId","status","onEditComment","onCommentDelete","childComment","undefined","jsxs","className","style","children","jsx","AddComment","onSubmit","Comments","threads","onAddReply","CollabSidebar","useState","enableComplementaryArea","interfaceStore","getActiveComplementaryArea","postType","postStatus","getCurrentPostType","data","getEntityRecords","per_page","getEditedPostAttribute","getBlockAttributes","_clientId","openCollabBoard","blocks","useEntityBlockEditor","resultComments","sortedThreads","useMemo","compare","result","filteredComments","filter","forEach","item","reply","push","length","updatedResult","map","reverse","blockCommentIds","getCommentIdsFromBlocks","threadIdMap","Map","thread","sortedComments","get","merged","GlobalStyles","useGlobalStylesContext","backgroundColor","color","background","unsubscribe","subscribe","activeSidebar","collabSidebarName","AddCommentComponent","AddCommentToolbarButton","AddCommentButton","Fragment","onClick","default","identifier","collabHistorySidebarName","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 { store as coreStore, useEntityBlockEditor } 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 AddCommentToolbarButton from './comment-button-toolbar';\nimport { useGlobalStylesContext } from '../global-styles-provider';\nimport { getCommentIdsFromBlocks } from './utils';\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( {\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\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\" 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\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, postStatus, threads } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\t\tconst data =\n\t\t\t!! _postId && typeof _postId === 'number'\n\t\t\t\t? select( coreStore ).getEntityRecords( 'root', 'comment', {\n\t\t\t\t\t\tpost: _postId,\n\t\t\t\t\t\ttype: 'block_comment',\n\t\t\t\t\t\tstatus: 'any',\n\t\t\t\t\t\tper_page: 100,\n\t\t\t\t } )\n\t\t\t\t: null;\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostStatus:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'status' ),\n\t\t\tthreads: data,\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\tconst [ blocks ] = useEntityBlockEditor( 'postType', postType, {\n\t\tid: postId,\n\t} );\n\n\t// Process comments to build the tree structure\n\tconst { resultComments, sortedThreads } = 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\tif ( 0 === result?.length ) {\n\t\t\treturn { resultComments: [], sortedThreads: [] };\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\tconst sortedComments = blockCommentIds\n\t\t\t.map( ( id ) => threadIdMap.get( id ) )\n\t\t\t.filter( ( thread ) => thread !== undefined );\n\n\t\treturn { resultComments: updatedResult, sortedThreads: sortedComments };\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\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={ 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={ sortedThreads }\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,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EA,MAAM2C,mBAAmB,GAAG1G,cAAc,GACvC2G,6BAAuB,GACvBC,sBAAgB;EAEnB,oBACC,IAAAnH,WAAA,CAAAsD,IAAA,EAAAtD,WAAA,CAAAoH,QAAA;IAAA3D,QAAA,gBACC,IAAAzD,WAAA,CAAA0D,GAAA,EAACuD,mBAAmB;MAACI,OAAO,EAAGvC;IAAiB,CAAE,CAAC,eACnD,IAAA9E,WAAA,CAAA0D,GAAA,EAACpE,cAAA,CAAAgI,OAAa;MACbC,UAAU,EAAGC;MACb;MAAA;MACAC,KAAK,EAAG,IAAA7E,QAAE,EAAE,UAAW,CAAG;MAC1B8E,IAAI,EAAGC,cAAa;MAAAlE,QAAA,eAEpB,IAAAzD,WAAA,CAAA0D,GAAA,EAAChD,oBAAoB;QACpBI,QAAQ,EAAGmE,cAAgB;QAC3BtE,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA;MAAqB,CAC3C;IAAC,CACY,CAAC,eAChB,IAAAZ,WAAA,CAAA0D,GAAA,EAACpE,cAAA,CAAAgI,OAAa;MACbM,UAAU,EAAG,KAAO;MACpBC,MAAM,EAAG,KAAO;MAChBN,UAAU,EAAGP,4BAAmB;MAChCzD,SAAS,EAAC,uBAAuB;MACjCuE,eAAe,EAAC,+BAA+B;MAAArE,QAAA,eAE/C,IAAAzD,WAAA,CAAA0D,GAAA,EAAChD,oBAAoB;QACpBI,QAAQ,EAAGoE,aAAe;QAC1BvE,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA,mBAAqB;QAC3CC,MAAM,EAAG;UACR6F;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","_commentButtonToolbar","_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","addNewComment","comment","parentCommentId","args","post","content","comment_type","comment_approved","updatedArgs","parent","savedRecord","id","__","isDismissible","onError","onCommentResolve","commentId","status","onEditComment","onCommentDelete","childComment","undefined","jsxs","className","style","children","jsx","AddComment","onSubmit","Comments","threads","onAddReply","CollabSidebar","useState","enableComplementaryArea","interfaceStore","getActiveComplementaryArea","postType","postStatus","getCurrentPostType","data","getEntityRecords","per_page","getEditedPostAttribute","getBlockAttributes","_clientId","openCollabBoard","blocks","useEntityBlockEditor","resultComments","sortedThreads","useMemo","compare","result","filteredComments","filter","forEach","item","reply","push","length","updatedResult","map","reverse","blockCommentIds","getCommentIdsFromBlocks","threadIdMap","Map","thread","sortedComments","get","merged","GlobalStyles","useGlobalStylesContext","backgroundColor","color","background","unsubscribe","subscribe","activeSidebar","collabSidebarName","AddCommentComponent","AddCommentToolbarButton","AddCommentButton","Fragment","onClick","default","identifier","collabHistorySidebarName","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 { store as coreStore, useEntityBlockEditor } 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 AddCommentToolbarButton from './comment-button-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\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\" 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\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, postStatus, threads } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\t\tconst data =\n\t\t\t!! _postId && typeof _postId === 'number'\n\t\t\t\t? select( coreStore ).getEntityRecords( 'root', 'comment', {\n\t\t\t\t\t\tpost: _postId,\n\t\t\t\t\t\ttype: 'block_comment',\n\t\t\t\t\t\tstatus: 'any',\n\t\t\t\t\t\tper_page: 100,\n\t\t\t\t } )\n\t\t\t\t: null;\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostStatus:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'status' ),\n\t\t\tthreads: data,\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\tconst [ blocks ] = useEntityBlockEditor( 'postType', postType, {\n\t\tid: postId,\n\t} );\n\n\t// Process comments to build the tree structure\n\tconst { resultComments, sortedThreads } = 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\tif ( 0 === result?.length ) {\n\t\t\treturn { resultComments: [], sortedThreads: [] };\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\tconst sortedComments = blockCommentIds\n\t\t\t.map( ( id ) => threadIdMap.get( id ) )\n\t\t\t.filter( ( thread ) => thread !== undefined );\n\n\t\treturn { resultComments: updatedResult, sortedThreads: sortedComments };\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\tif ( 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={ 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={ sortedThreads }\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;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;AACA,IA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C;IAAC,CACY,CAAC,eAChB,IAAAT,WAAA,CAAAuD,GAAA,EAACjE,cAAA,CAAA6H,OAAa;MACbM,UAAU,EAAG,KAAO;MACpBC,MAAM,EAAG,KAAO;MAChBN,UAAU,EAAGP,4BAAmB;MAChCzD,SAAS,EAAC,uBAAuB;MACjCuE,eAAe,EAAC,+BAA+B;MAAArE,QAAA,eAE/C,IAAAtD,WAAA,CAAAuD,GAAA,EAAChD,oBAAoB;QACpBI,QAAQ,EAAGoE,aAAe;QAC1BvE,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA,mBAAqB;QAC3CC,MAAM,EAAG;UACR6F;QACD;MAAG,CACH;IAAC,CACY,CAAC;EAAA,CACf,CAAC;AAEL","ignoreList":[]}
@@ -13,10 +13,10 @@ var _blockEditor = require("@wordpress/block-editor");
13
13
  /**
14
14
  * Component check if there are any headings (core/heading blocks) present in the document.
15
15
  *
16
- * @param {Object} props Props.
17
- * @param {React.ReactElement} props.children Children to be rendered.
16
+ * @param {Object} props Props.
17
+ * @param {React.ReactNode} props.children Children to be rendered.
18
18
  *
19
- * @return {React.ReactElement} The component to be rendered or null if there are headings.
19
+ * @return {React.ReactNode} The component to be rendered or null if there are headings.
20
20
  */
21
21
  function DocumentOutlineCheck({
22
22
  children
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_blockEditor","DocumentOutlineCheck","children","hasHeadings","useSelect","select","getGlobalBlockCount","blockEditorStore"],"sources":["@wordpress/editor/src/components/document-outline/check.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Component check if there are any headings (core/heading blocks) present in the document.\n *\n * @param {Object} props Props.\n * @param {React.ReactElement} props.children Children to be rendered.\n *\n * @return {React.ReactElement} The component to be rendered or null if there are headings.\n */\nexport default function DocumentOutlineCheck( { children } ) {\n\tconst hasHeadings = useSelect( ( select ) => {\n\t\tconst { getGlobalBlockCount } = select( blockEditorStore );\n\n\t\treturn getGlobalBlockCount( 'core/heading' ) > 0;\n\t} );\n\n\tif ( ! hasHeadings ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,oBAAoBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EAC5D,MAAMC,WAAW,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC5C,MAAM;MAAEC;IAAoB,CAAC,GAAGD,MAAM,CAAEE,kBAAiB,CAAC;IAE1D,OAAOD,mBAAmB,CAAE,cAAe,CAAC,GAAG,CAAC;EACjD,CAAE,CAAC;EAEH,IAAK,CAAEH,WAAW,EAAG;IACpB,OAAO,IAAI;EACZ;EAEA,OAAOD,QAAQ;AAChB","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_blockEditor","DocumentOutlineCheck","children","hasHeadings","useSelect","select","getGlobalBlockCount","blockEditorStore"],"sources":["@wordpress/editor/src/components/document-outline/check.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Component check if there are any headings (core/heading blocks) present in the document.\n *\n * @param {Object} props Props.\n * @param {React.ReactNode} props.children Children to be rendered.\n *\n * @return {React.ReactNode} The component to be rendered or null if there are headings.\n */\nexport default function DocumentOutlineCheck( { children } ) {\n\tconst hasHeadings = useSelect( ( select ) => {\n\t\tconst { getGlobalBlockCount } = select( blockEditorStore );\n\n\t\treturn getGlobalBlockCount( 'core/heading' ) > 0;\n\t} );\n\n\tif ( ! hasHeadings ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,oBAAoBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EAC5D,MAAMC,WAAW,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC5C,MAAM;MAAEC;IAAoB,CAAC,GAAGD,MAAM,CAAEE,kBAAiB,CAAC;IAE1D,OAAOD,mBAAmB,CAAE,cAAe,CAAC,GAAG,CAAC;EACjD,CAAE,CAAC;EAEH,IAAK,CAAEH,WAAW,EAAG;IACpB,OAAO,IAAI;EACZ;EAEA,OAAOD,QAAQ;AAChB","ignoreList":[]}
@@ -208,7 +208,7 @@ function DocumentOutline({
208
208
  href: `#${titleNode.id}`,
209
209
  isDisabled: hasOutlineItemsDisabled,
210
210
  children: title
211
- }), headings.map((item, index) => {
211
+ }), headings.map(item => {
212
212
  // Headings remain the same, go up by one, or down by any amount.
213
213
  // Otherwise there are missing levels.
214
214
  const isIncorrectLevel = item.level > prevHeadingLevelRef.current + 1;
@@ -226,7 +226,7 @@ function DocumentOutline({
226
226
  children: [item.isEmpty ? emptyHeadingContent : (0, _richText.getTextContent)((0, _richText.create)({
227
227
  html: item.attributes.content
228
228
  })), isIncorrectLevel && incorrectLevelContent, item.level === 1 && hasMultipleH1 && multipleH1Headings, hasTitle && item.level === 1 && !hasMultipleH1 && singleH1Headings]
229
- }, index);
229
+ }, item.clientId);
230
230
  })]
231
231
  })
232
232
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_data","_element","_richText","_blockEditor","_coreData","_components","_item","_interopRequireDefault","_store","_jsxRuntime","emptyHeadingContent","jsx","children","__","incorrectLevelContent","singleH1Headings","multipleH1Headings","EmptyOutlineIllustration","jsxs","SVG","width","height","viewBox","fill","xmlns","Rect","rx","Line","x1","y1","x2","y2","stroke","x","y","Path","d","computeOutlineHeadings","blocks","flatMap","block","name","level","attributes","isEmpty","isEmptyHeading","innerBlocks","heading","content","trim","length","DocumentOutline","onSelect","hasOutlineItemsDisabled","selectBlock","useDispatch","blockEditorStore","title","isTitleSupported","useSelect","select","_postType$supports$ti","getBlocks","getEditedPostAttribute","editorStore","getPostType","coreStore","postType","supports","prevHeadingLevelRef","useRef","headings","className","titleNode","document","querySelector","hasTitle","countByLevel","reduce","acc","hasMultipleH1","default","isValid","href","id","isDisabled","map","item","index","isIncorrectLevel","current","clientId","getTextContent","create","html"],"sources":["@wordpress/editor/src/components/document-outline/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { create, getTextContent } from '@wordpress/rich-text';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { Path, SVG, Line, Rect } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport DocumentOutlineItem from './item';\nimport { store as editorStore } from '../../store';\n\n/**\n * Module constants\n */\nconst emptyHeadingContent = <em>{ __( '(Empty heading)' ) }</em>;\nconst incorrectLevelContent = [\n\t<br key=\"incorrect-break\" />,\n\t<em key=\"incorrect-message\">{ __( '(Incorrect heading level)' ) }</em>,\n];\nconst singleH1Headings = [\n\t<br key=\"incorrect-break-h1\" />,\n\t<em key=\"incorrect-message-h1\">\n\t\t{ __( '(Your theme may already use a H1 for the post title)' ) }\n\t</em>,\n];\nconst multipleH1Headings = [\n\t<br key=\"incorrect-break-multiple-h1\" />,\n\t<em key=\"incorrect-message-multiple-h1\">\n\t\t{ __( '(Multiple H1 headings are not recommended)' ) }\n\t</em>,\n];\nfunction EmptyOutlineIllustration() {\n\treturn (\n\t\t<SVG\n\t\t\twidth=\"138\"\n\t\t\theight=\"148\"\n\t\t\tviewBox=\"0 0 138 148\"\n\t\t\tfill=\"none\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t>\n\t\t\t<Rect width=\"138\" height=\"148\" rx=\"4\" fill=\"#F0F6FC\" />\n\t\t\t<Line x1=\"44\" y1=\"28\" x2=\"24\" y2=\"28\" stroke=\"#DDDDDD\" />\n\t\t\t<Rect x=\"48\" y=\"16\" width=\"27\" height=\"23\" rx=\"4\" fill=\"#DDDDDD\" />\n\t\t\t<Path\n\t\t\t\td=\"M54.7585 32V23.2727H56.6037V26.8736H60.3494V23.2727H62.1903V32H60.3494V28.3949H56.6037V32H54.7585ZM67.4574 23.2727V32H65.6122V25.0241H65.5611L63.5625 26.277V24.6406L65.723 23.2727H67.4574Z\"\n\t\t\t\tfill=\"black\"\n\t\t\t/>\n\t\t\t<Line x1=\"55\" y1=\"59\" x2=\"24\" y2=\"59\" stroke=\"#DDDDDD\" />\n\t\t\t<Rect x=\"59\" y=\"47\" width=\"29\" height=\"23\" rx=\"4\" fill=\"#DDDDDD\" />\n\t\t\t<Path\n\t\t\t\td=\"M65.7585 63V54.2727H67.6037V57.8736H71.3494V54.2727H73.1903V63H71.3494V59.3949H67.6037V63H65.7585ZM74.6605 63V61.6705L77.767 58.794C78.0313 58.5384 78.2528 58.3082 78.4318 58.1037C78.6136 57.8991 78.7514 57.6989 78.8452 57.5028C78.9389 57.304 78.9858 57.0895 78.9858 56.8594C78.9858 56.6037 78.9276 56.3835 78.8111 56.1989C78.6946 56.0114 78.5355 55.8679 78.3338 55.7685C78.1321 55.6662 77.9034 55.6151 77.6477 55.6151C77.3807 55.6151 77.1477 55.669 76.9489 55.777C76.75 55.8849 76.5966 56.0398 76.4886 56.2415C76.3807 56.4432 76.3267 56.6832 76.3267 56.9616H74.5753C74.5753 56.3906 74.7045 55.8949 74.9631 55.4744C75.2216 55.054 75.5838 54.7287 76.0497 54.4986C76.5156 54.2685 77.0526 54.1534 77.6605 54.1534C78.2855 54.1534 78.8295 54.2642 79.2926 54.4858C79.7585 54.7045 80.1207 55.0085 80.3793 55.3977C80.6378 55.7869 80.767 56.233 80.767 56.7358C80.767 57.0653 80.7017 57.3906 80.571 57.7116C80.4432 58.0327 80.2145 58.3892 79.8849 58.7812C79.5554 59.1705 79.0909 59.6378 78.4915 60.1832L77.2173 61.4318V61.4915H80.8821V63H74.6605Z\"\n\t\t\t\tfill=\"black\"\n\t\t\t/>\n\t\t\t<Line x1=\"80\" y1=\"90\" x2=\"24\" y2=\"90\" stroke=\"#DDDDDD\" />\n\t\t\t<Rect x=\"84\" y=\"78\" width=\"30\" height=\"23\" rx=\"4\" fill=\"#F0B849\" />\n\t\t\t<Path\n\t\t\t\td=\"M90.7585 94V85.2727H92.6037V88.8736H96.3494V85.2727H98.1903V94H96.3494V90.3949H92.6037V94H90.7585ZM99.5284 92.4659V91.0128L103.172 85.2727H104.425V87.2841H103.683L101.386 90.919V90.9872H106.564V92.4659H99.5284ZM103.717 94V92.0227L103.751 91.3793V85.2727H105.482V94H103.717Z\"\n\t\t\t\tfill=\"black\"\n\t\t\t/>\n\t\t\t<Line x1=\"66\" y1=\"121\" x2=\"24\" y2=\"121\" stroke=\"#DDDDDD\" />\n\t\t\t<Rect x=\"70\" y=\"109\" width=\"29\" height=\"23\" rx=\"4\" fill=\"#DDDDDD\" />\n\t\t\t<Path\n\t\t\t\td=\"M76.7585 125V116.273H78.6037V119.874H82.3494V116.273H84.1903V125H82.3494V121.395H78.6037V125H76.7585ZM88.8864 125.119C88.25 125.119 87.6832 125.01 87.1861 124.791C86.6918 124.57 86.3011 124.266 86.0142 123.879C85.7301 123.49 85.5838 123.041 85.5753 122.533H87.4332C87.4446 122.746 87.5142 122.933 87.642 123.095C87.7727 123.254 87.946 123.378 88.1619 123.466C88.3778 123.554 88.6207 123.598 88.8906 123.598C89.1719 123.598 89.4205 123.548 89.6364 123.449C89.8523 123.349 90.0213 123.212 90.1435 123.036C90.2656 122.859 90.3267 122.656 90.3267 122.426C90.3267 122.193 90.2614 121.987 90.1307 121.808C90.0028 121.626 89.8182 121.484 89.5767 121.382C89.3381 121.28 89.054 121.229 88.7244 121.229H87.9105V119.874H88.7244C89.0028 119.874 89.2486 119.825 89.4616 119.729C89.6776 119.632 89.8452 119.499 89.9645 119.328C90.0838 119.155 90.1435 118.953 90.1435 118.723C90.1435 118.504 90.0909 118.312 89.9858 118.148C89.8835 117.98 89.7386 117.849 89.5511 117.756C89.3665 117.662 89.1506 117.615 88.9034 117.615C88.6534 117.615 88.4247 117.661 88.2173 117.751C88.0099 117.839 87.8438 117.966 87.7188 118.131C87.5938 118.295 87.527 118.489 87.5185 118.71H85.75C85.7585 118.207 85.902 117.764 86.1804 117.381C86.4588 116.997 86.8338 116.697 87.3054 116.482C87.7798 116.263 88.3153 116.153 88.9119 116.153C89.5142 116.153 90.0412 116.263 90.4929 116.482C90.9446 116.7 91.2955 116.996 91.5455 117.368C91.7983 117.737 91.9233 118.152 91.9205 118.612C91.9233 119.101 91.7713 119.509 91.4645 119.835C91.1605 120.162 90.7642 120.369 90.2756 120.457V120.526C90.9176 120.608 91.4063 120.831 91.7415 121.195C92.0795 121.555 92.2472 122.007 92.2443 122.55C92.2472 123.047 92.1037 123.489 91.8139 123.875C91.527 124.261 91.1307 124.565 90.625 124.787C90.1193 125.009 89.5398 125.119 88.8864 125.119Z\"\n\t\t\t\tfill=\"black\"\n\t\t\t/>\n\t\t</SVG>\n\t);\n}\n\n/**\n * Returns an array of heading blocks enhanced with the following properties:\n * level - An integer with the heading level.\n * isEmpty - Flag indicating if the heading has no content.\n *\n * @param {?Array} blocks An array of blocks.\n *\n * @return {Array} An array of heading blocks enhanced with the properties described above.\n */\nconst computeOutlineHeadings = ( blocks = [] ) => {\n\treturn blocks.flatMap( ( block = {} ) => {\n\t\tif ( block.name === 'core/heading' ) {\n\t\t\treturn {\n\t\t\t\t...block,\n\t\t\t\tlevel: block.attributes.level,\n\t\t\t\tisEmpty: isEmptyHeading( block ),\n\t\t\t};\n\t\t}\n\t\treturn computeOutlineHeadings( block.innerBlocks );\n\t} );\n};\n\nconst isEmptyHeading = ( heading ) =>\n\t! heading.attributes.content ||\n\theading.attributes.content.trim().length === 0;\n\n/**\n * Renders a document outline component.\n *\n * @param {Object} props Props.\n * @param {Function} props.onSelect Function to be called when an outline item is selected\n * @param {boolean} props.hasOutlineItemsDisabled Indicates whether the outline items are disabled.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function DocumentOutline( {\n\tonSelect,\n\thasOutlineItemsDisabled,\n} ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst { blocks, title, isTitleSupported } = useSelect( ( select ) => {\n\t\tconst { getBlocks } = select( blockEditorStore );\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn {\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\tblocks: getBlocks(),\n\t\t\tisTitleSupported: postType?.supports?.title ?? false,\n\t\t};\n\t} );\n\n\tconst prevHeadingLevelRef = useRef( 1 );\n\n\tconst headings = computeOutlineHeadings( blocks );\n\tif ( headings.length < 1 ) {\n\t\treturn (\n\t\t\t<div className=\"editor-document-outline has-no-headings\">\n\t\t\t\t<EmptyOutlineIllustration />\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Navigate the structure of your document and address issues like empty or incorrect heading levels.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Not great but it's the simplest way to locate the title right now.\n\tconst titleNode = document.querySelector( '.editor-post-title__input' );\n\tconst hasTitle = isTitleSupported && title && titleNode;\n\tconst countByLevel = headings.reduce(\n\t\t( acc, heading ) => ( {\n\t\t\t...acc,\n\t\t\t[ heading.level ]: ( acc[ heading.level ] || 0 ) + 1,\n\t\t} ),\n\t\t{}\n\t);\n\tconst hasMultipleH1 = countByLevel[ 1 ] > 1;\n\n\treturn (\n\t\t<div className=\"document-outline\">\n\t\t\t<ul>\n\t\t\t\t{ hasTitle && (\n\t\t\t\t\t<DocumentOutlineItem\n\t\t\t\t\t\tlevel={ __( 'Title' ) }\n\t\t\t\t\t\tisValid\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\thref={ `#${ titleNode.id }` }\n\t\t\t\t\t\tisDisabled={ hasOutlineItemsDisabled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</DocumentOutlineItem>\n\t\t\t\t) }\n\t\t\t\t{ headings.map( ( item, index ) => {\n\t\t\t\t\t// Headings remain the same, go up by one, or down by any amount.\n\t\t\t\t\t// Otherwise there are missing levels.\n\t\t\t\t\tconst isIncorrectLevel =\n\t\t\t\t\t\titem.level > prevHeadingLevelRef.current + 1;\n\n\t\t\t\t\tconst isValid =\n\t\t\t\t\t\t! item.isEmpty &&\n\t\t\t\t\t\t! isIncorrectLevel &&\n\t\t\t\t\t\t!! item.level &&\n\t\t\t\t\t\t( item.level !== 1 ||\n\t\t\t\t\t\t\t( ! hasMultipleH1 && ! hasTitle ) );\n\t\t\t\t\tprevHeadingLevelRef.current = item.level;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<DocumentOutlineItem\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\tlevel={ `H${ item.level }` }\n\t\t\t\t\t\t\tisValid={ isValid }\n\t\t\t\t\t\t\tisDisabled={ hasOutlineItemsDisabled }\n\t\t\t\t\t\t\thref={ `#block-${ item.clientId }` }\n\t\t\t\t\t\t\tonSelect={ () => {\n\t\t\t\t\t\t\t\tselectBlock( item.clientId );\n\t\t\t\t\t\t\t\tonSelect?.();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ item.isEmpty\n\t\t\t\t\t\t\t\t? emptyHeadingContent\n\t\t\t\t\t\t\t\t: getTextContent(\n\t\t\t\t\t\t\t\t\t\tcreate( {\n\t\t\t\t\t\t\t\t\t\t\thtml: item.attributes.content,\n\t\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{ isIncorrectLevel && incorrectLevelContent }\n\t\t\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KAAM;YAChBE,WAAW,CAAEiC,IAAI,CAACI,QAAS,CAAC;YAC5BvC,QAAQ,GAAG,CAAC;UACb,CAAG;UAAAxC,QAAA,GAED2E,IAAI,CAAC3C,OAAO,GACXlC,mBAAmB,GACnB,IAAAkF,wBAAc,EACd,IAAAC,gBAAM,EAAE;YACPC,IAAI,EAAEP,IAAI,CAAC5C,UAAU,CAACK;UACvB,CAAE,CACF,CAAC,EACFyC,gBAAgB,IAAI3E,qBAAqB,EACzCyE,IAAI,CAAC7C,KAAK,KAAK,CAAC,IACjBsC,aAAa,IACbhE,kBAAkB,EACjB4D,QAAQ,IACTW,IAAI,CAAC7C,KAAK,KAAK,CAAC,IAChB,CAAEsC,aAAa,IACfjE,gBAAgB;QAAA,GAxBXyE,KAyBc,CAAC;MAExB,CAAE,CAAC;IAAA,CACA;EAAC,CACD,CAAC;AAER","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_data","_element","_richText","_blockEditor","_coreData","_components","_item","_interopRequireDefault","_store","_jsxRuntime","emptyHeadingContent","jsx","children","__","incorrectLevelContent","singleH1Headings","multipleH1Headings","EmptyOutlineIllustration","jsxs","SVG","width","height","viewBox","fill","xmlns","Rect","rx","Line","x1","y1","x2","y2","stroke","x","y","Path","d","computeOutlineHeadings","blocks","flatMap","block","name","level","attributes","isEmpty","isEmptyHeading","innerBlocks","heading","content","trim","length","DocumentOutline","onSelect","hasOutlineItemsDisabled","selectBlock","useDispatch","blockEditorStore","title","isTitleSupported","useSelect","select","_postType$supports$ti","getBlocks","getEditedPostAttribute","editorStore","getPostType","coreStore","postType","supports","prevHeadingLevelRef","useRef","headings","className","titleNode","document","querySelector","hasTitle","countByLevel","reduce","acc","hasMultipleH1","default","isValid","href","id","isDisabled","map","item","isIncorrectLevel","current","clientId","getTextContent","create","html"],"sources":["@wordpress/editor/src/components/document-outline/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { create, getTextContent } from '@wordpress/rich-text';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { Path, SVG, Line, Rect } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport DocumentOutlineItem from './item';\nimport { store as editorStore } from '../../store';\n\n/**\n * Module constants\n */\nconst emptyHeadingContent = <em>{ __( '(Empty heading)' ) }</em>;\nconst incorrectLevelContent = [\n\t<br key=\"incorrect-break\" />,\n\t<em key=\"incorrect-message\">{ __( '(Incorrect heading level)' ) }</em>,\n];\nconst singleH1Headings = [\n\t<br key=\"incorrect-break-h1\" />,\n\t<em key=\"incorrect-message-h1\">\n\t\t{ __( '(Your theme may already use a H1 for the post title)' ) }\n\t</em>,\n];\nconst multipleH1Headings = [\n\t<br key=\"incorrect-break-multiple-h1\" />,\n\t<em key=\"incorrect-message-multiple-h1\">\n\t\t{ __( '(Multiple H1 headings are not recommended)' ) }\n\t</em>,\n];\nfunction EmptyOutlineIllustration() {\n\treturn (\n\t\t<SVG\n\t\t\twidth=\"138\"\n\t\t\theight=\"148\"\n\t\t\tviewBox=\"0 0 138 148\"\n\t\t\tfill=\"none\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t>\n\t\t\t<Rect width=\"138\" height=\"148\" rx=\"4\" fill=\"#F0F6FC\" />\n\t\t\t<Line x1=\"44\" y1=\"28\" x2=\"24\" y2=\"28\" stroke=\"#DDDDDD\" />\n\t\t\t<Rect x=\"48\" y=\"16\" width=\"27\" height=\"23\" rx=\"4\" fill=\"#DDDDDD\" />\n\t\t\t<Path\n\t\t\t\td=\"M54.7585 32V23.2727H56.6037V26.8736H60.3494V23.2727H62.1903V32H60.3494V28.3949H56.6037V32H54.7585ZM67.4574 23.2727V32H65.6122V25.0241H65.5611L63.5625 26.277V24.6406L65.723 23.2727H67.4574Z\"\n\t\t\t\tfill=\"black\"\n\t\t\t/>\n\t\t\t<Line x1=\"55\" y1=\"59\" x2=\"24\" y2=\"59\" stroke=\"#DDDDDD\" />\n\t\t\t<Rect x=\"59\" y=\"47\" width=\"29\" height=\"23\" rx=\"4\" fill=\"#DDDDDD\" />\n\t\t\t<Path\n\t\t\t\td=\"M65.7585 63V54.2727H67.6037V57.8736H71.3494V54.2727H73.1903V63H71.3494V59.3949H67.6037V63H65.7585ZM74.6605 63V61.6705L77.767 58.794C78.0313 58.5384 78.2528 58.3082 78.4318 58.1037C78.6136 57.8991 78.7514 57.6989 78.8452 57.5028C78.9389 57.304 78.9858 57.0895 78.9858 56.8594C78.9858 56.6037 78.9276 56.3835 78.8111 56.1989C78.6946 56.0114 78.5355 55.8679 78.3338 55.7685C78.1321 55.6662 77.9034 55.6151 77.6477 55.6151C77.3807 55.6151 77.1477 55.669 76.9489 55.777C76.75 55.8849 76.5966 56.0398 76.4886 56.2415C76.3807 56.4432 76.3267 56.6832 76.3267 56.9616H74.5753C74.5753 56.3906 74.7045 55.8949 74.9631 55.4744C75.2216 55.054 75.5838 54.7287 76.0497 54.4986C76.5156 54.2685 77.0526 54.1534 77.6605 54.1534C78.2855 54.1534 78.8295 54.2642 79.2926 54.4858C79.7585 54.7045 80.1207 55.0085 80.3793 55.3977C80.6378 55.7869 80.767 56.233 80.767 56.7358C80.767 57.0653 80.7017 57.3906 80.571 57.7116C80.4432 58.0327 80.2145 58.3892 79.8849 58.7812C79.5554 59.1705 79.0909 59.6378 78.4915 60.1832L77.2173 61.4318V61.4915H80.8821V63H74.6605Z\"\n\t\t\t\tfill=\"black\"\n\t\t\t/>\n\t\t\t<Line x1=\"80\" y1=\"90\" x2=\"24\" y2=\"90\" stroke=\"#DDDDDD\" />\n\t\t\t<Rect x=\"84\" y=\"78\" width=\"30\" height=\"23\" rx=\"4\" fill=\"#F0B849\" />\n\t\t\t<Path\n\t\t\t\td=\"M90.7585 94V85.2727H92.6037V88.8736H96.3494V85.2727H98.1903V94H96.3494V90.3949H92.6037V94H90.7585ZM99.5284 92.4659V91.0128L103.172 85.2727H104.425V87.2841H103.683L101.386 90.919V90.9872H106.564V92.4659H99.5284ZM103.717 94V92.0227L103.751 91.3793V85.2727H105.482V94H103.717Z\"\n\t\t\t\tfill=\"black\"\n\t\t\t/>\n\t\t\t<Line x1=\"66\" y1=\"121\" x2=\"24\" y2=\"121\" stroke=\"#DDDDDD\" />\n\t\t\t<Rect x=\"70\" y=\"109\" width=\"29\" height=\"23\" rx=\"4\" fill=\"#DDDDDD\" />\n\t\t\t<Path\n\t\t\t\td=\"M76.7585 125V116.273H78.6037V119.874H82.3494V116.273H84.1903V125H82.3494V121.395H78.6037V125H76.7585ZM88.8864 125.119C88.25 125.119 87.6832 125.01 87.1861 124.791C86.6918 124.57 86.3011 124.266 86.0142 123.879C85.7301 123.49 85.5838 123.041 85.5753 122.533H87.4332C87.4446 122.746 87.5142 122.933 87.642 123.095C87.7727 123.254 87.946 123.378 88.1619 123.466C88.3778 123.554 88.6207 123.598 88.8906 123.598C89.1719 123.598 89.4205 123.548 89.6364 123.449C89.8523 123.349 90.0213 123.212 90.1435 123.036C90.2656 122.859 90.3267 122.656 90.3267 122.426C90.3267 122.193 90.2614 121.987 90.1307 121.808C90.0028 121.626 89.8182 121.484 89.5767 121.382C89.3381 121.28 89.054 121.229 88.7244 121.229H87.9105V119.874H88.7244C89.0028 119.874 89.2486 119.825 89.4616 119.729C89.6776 119.632 89.8452 119.499 89.9645 119.328C90.0838 119.155 90.1435 118.953 90.1435 118.723C90.1435 118.504 90.0909 118.312 89.9858 118.148C89.8835 117.98 89.7386 117.849 89.5511 117.756C89.3665 117.662 89.1506 117.615 88.9034 117.615C88.6534 117.615 88.4247 117.661 88.2173 117.751C88.0099 117.839 87.8438 117.966 87.7188 118.131C87.5938 118.295 87.527 118.489 87.5185 118.71H85.75C85.7585 118.207 85.902 117.764 86.1804 117.381C86.4588 116.997 86.8338 116.697 87.3054 116.482C87.7798 116.263 88.3153 116.153 88.9119 116.153C89.5142 116.153 90.0412 116.263 90.4929 116.482C90.9446 116.7 91.2955 116.996 91.5455 117.368C91.7983 117.737 91.9233 118.152 91.9205 118.612C91.9233 119.101 91.7713 119.509 91.4645 119.835C91.1605 120.162 90.7642 120.369 90.2756 120.457V120.526C90.9176 120.608 91.4063 120.831 91.7415 121.195C92.0795 121.555 92.2472 122.007 92.2443 122.55C92.2472 123.047 92.1037 123.489 91.8139 123.875C91.527 124.261 91.1307 124.565 90.625 124.787C90.1193 125.009 89.5398 125.119 88.8864 125.119Z\"\n\t\t\t\tfill=\"black\"\n\t\t\t/>\n\t\t</SVG>\n\t);\n}\n\n/**\n * Returns an array of heading blocks enhanced with the following properties:\n * level - An integer with the heading level.\n * isEmpty - Flag indicating if the heading has no content.\n *\n * @param {?Array} blocks An array of blocks.\n *\n * @return {Array} An array of heading blocks enhanced with the properties described above.\n */\nconst computeOutlineHeadings = ( blocks = [] ) => {\n\treturn blocks.flatMap( ( block = {} ) => {\n\t\tif ( block.name === 'core/heading' ) {\n\t\t\treturn {\n\t\t\t\t...block,\n\t\t\t\tlevel: block.attributes.level,\n\t\t\t\tisEmpty: isEmptyHeading( block ),\n\t\t\t};\n\t\t}\n\t\treturn computeOutlineHeadings( block.innerBlocks );\n\t} );\n};\n\nconst isEmptyHeading = ( heading ) =>\n\t! heading.attributes.content ||\n\theading.attributes.content.trim().length === 0;\n\n/**\n * Renders a document outline component.\n *\n * @param {Object} props Props.\n * @param {Function} props.onSelect Function to be called when an outline item is selected\n * @param {boolean} props.hasOutlineItemsDisabled Indicates whether the outline items are disabled.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function DocumentOutline( {\n\tonSelect,\n\thasOutlineItemsDisabled,\n} ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst { blocks, title, isTitleSupported } = useSelect( ( select ) => {\n\t\tconst { getBlocks } = select( blockEditorStore );\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn {\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\tblocks: getBlocks(),\n\t\t\tisTitleSupported: postType?.supports?.title ?? false,\n\t\t};\n\t} );\n\n\tconst prevHeadingLevelRef = useRef( 1 );\n\n\tconst headings = computeOutlineHeadings( blocks );\n\tif ( headings.length < 1 ) {\n\t\treturn (\n\t\t\t<div className=\"editor-document-outline has-no-headings\">\n\t\t\t\t<EmptyOutlineIllustration />\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Navigate the structure of your document and address issues like empty or incorrect heading levels.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Not great but it's the simplest way to locate the title right now.\n\tconst titleNode = document.querySelector( '.editor-post-title__input' );\n\tconst hasTitle = isTitleSupported && title && titleNode;\n\tconst countByLevel = headings.reduce(\n\t\t( acc, heading ) => ( {\n\t\t\t...acc,\n\t\t\t[ heading.level ]: ( acc[ heading.level ] || 0 ) + 1,\n\t\t} ),\n\t\t{}\n\t);\n\tconst hasMultipleH1 = countByLevel[ 1 ] > 1;\n\n\treturn (\n\t\t<div className=\"document-outline\">\n\t\t\t<ul>\n\t\t\t\t{ hasTitle && (\n\t\t\t\t\t<DocumentOutlineItem\n\t\t\t\t\t\tlevel={ __( 'Title' ) }\n\t\t\t\t\t\tisValid\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\thref={ `#${ titleNode.id }` }\n\t\t\t\t\t\tisDisabled={ hasOutlineItemsDisabled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</DocumentOutlineItem>\n\t\t\t\t) }\n\t\t\t\t{ headings.map( ( item ) => {\n\t\t\t\t\t// Headings remain the same, go up by one, or down by any amount.\n\t\t\t\t\t// Otherwise there are missing levels.\n\t\t\t\t\tconst isIncorrectLevel =\n\t\t\t\t\t\titem.level > prevHeadingLevelRef.current + 1;\n\n\t\t\t\t\tconst isValid =\n\t\t\t\t\t\t! item.isEmpty &&\n\t\t\t\t\t\t! isIncorrectLevel &&\n\t\t\t\t\t\t!! item.level &&\n\t\t\t\t\t\t( item.level !== 1 ||\n\t\t\t\t\t\t\t( ! hasMultipleH1 && ! hasTitle ) );\n\t\t\t\t\tprevHeadingLevelRef.current = item.level;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<DocumentOutlineItem\n\t\t\t\t\t\t\tkey={ item.clientId }\n\t\t\t\t\t\t\tlevel={ `H${ item.level }` }\n\t\t\t\t\t\t\tisValid={ isValid }\n\t\t\t\t\t\t\tisDisabled={ hasOutlineItemsDisabled }\n\t\t\t\t\t\t\thref={ `#block-${ item.clientId }` }\n\t\t\t\t\t\t\tonSelect={ () => {\n\t\t\t\t\t\t\t\tselectBlock( item.clientId );\n\t\t\t\t\t\t\t\tonSelect?.();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ item.isEmpty\n\t\t\t\t\t\t\t\t? emptyHeadingContent\n\t\t\t\t\t\t\t\t: getTextContent(\n\t\t\t\t\t\t\t\t\t\tcreate( {\n\t\t\t\t\t\t\t\t\t\t\thtml: item.attributes.content,\n\t\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{ isIncorrectLevel && incorrectLevelContent }\n\t\t\t\t\t\t\t{ item.level === 1 &&\n\t\t\t\t\t\t\t\thasMultipleH1 &&\n\t\t\t\t\t\t\t\tmultipleH1Headings }\n\t\t\t\t\t\t\t{ hasTitle &&\n\t\t\t\t\t\t\t\titem.level === 1 &&\n\t\t\t\t\t\t\t\t! hasMultipleH1 &&\n\t\t\t\t\t\t\t\tsingleH1Headings }\n\t\t\t\t\t\t</DocumentOutlineItem>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</ul>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAA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ACTW,IAAI,CAAC7C,KAAK,KAAK,CAAC,IAChB,CAAEsC,aAAa,IACfjE,gBAAgB;QAAA,GAxBXwE,IAAI,CAACG,QAyBS,CAAC;MAExB,CAAE,CAAC;IAAA,CACA;EAAC,CACD,CAAC;AAER","ignoreList":[]}
@@ -38,6 +38,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
38
38
  * Internal dependencies
39
39
  */
40
40
 
41
+ const isBlockCommentExperimentEnabled = window?.__experimentalEnableBlockComment;
41
42
  const toolbarVariations = {
42
43
  distractionFreeDisabled: {
43
44
  y: '-50px'
@@ -88,7 +89,8 @@ function Header({
88
89
  isPublishSidebarOpened,
89
90
  showIconLabels,
90
91
  hasFixedToolbar,
91
- hasBlockSelection
92
+ hasBlockSelection,
93
+ hasSectionRootClientId
92
94
  } = (0, _data.useSelect)(select => {
93
95
  const {
94
96
  get: getPreference
@@ -98,24 +100,28 @@ function Header({
98
100
  getCurrentPostType,
99
101
  isPublishSidebarOpened: _isPublishSidebarOpened
100
102
  } = select(_store.store);
103
+ const {
104
+ getBlockSelectionStart,
105
+ getSectionRootClientId
106
+ } = (0, _lockUnlock.unlock)(select(_blockEditor.store));
101
107
  return {
102
108
  postType: getCurrentPostType(),
103
109
  isTextEditor: getEditorMode() === 'text',
104
110
  isPublishSidebarOpened: _isPublishSidebarOpened(),
105
111
  showIconLabels: getPreference('core', 'showIconLabels'),
106
112
  hasFixedToolbar: getPreference('core', 'fixedToolbar'),
107
- hasBlockSelection: !!select(_blockEditor.store).getBlockSelectionStart()
113
+ hasBlockSelection: !!getBlockSelectionStart(),
114
+ hasSectionRootClientId: !!getSectionRootClientId()
108
115
  };
109
116
  }, []);
110
- const canBeZoomedOut = ['post', 'page', 'wp_template'].includes(postType);
111
- const disablePreviewOption = [_constants.NAVIGATION_POST_TYPE, _constants.TEMPLATE_PART_POST_TYPE, _constants.PATTERN_POST_TYPE].includes(postType);
117
+ const canBeZoomedOut = ['post', 'page', 'wp_template'].includes(postType) && hasSectionRootClientId;
118
+ const disablePreviewOption = [_constants.NAVIGATION_POST_TYPE, _constants.TEMPLATE_PART_POST_TYPE, _constants.PATTERN_POST_TYPE].includes(postType) || forceDisableBlockTools;
112
119
  const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = (0, _element.useState)(true);
113
120
  const hasCenter = !isTooNarrowForDocumentBar && (!hasFixedToolbar || hasFixedToolbar && (!hasBlockSelection || isBlockToolsCollapsed));
114
121
  const hasBackButton = (0, _backButton.useHasBackButton)();
115
- const hasSectionRootClientId = (0, _data.useSelect)(select => !!(0, _lockUnlock.unlock)(select(_blockEditor.store)).getSectionRootClientId(), []);
116
122
 
117
123
  /*
118
- * The edit-post-header classname is only kept for backward compatability
124
+ * The edit-post-header classname is only kept for backward compatibility
119
125
  * as some plugins might be relying on its presence.
120
126
  */
121
127
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
@@ -171,14 +177,14 @@ function Header({
171
177
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_postPreviewButton.default, {
172
178
  className: "editor-header__post-preview-button",
173
179
  forceIsAutosaveable: forceIsDirty
174
- }), canBeZoomedOut && isWideViewport && hasSectionRootClientId && /*#__PURE__*/(0, _jsxRuntime.jsx)(_zoomOutToggle.default, {
180
+ }), isWideViewport && canBeZoomedOut && /*#__PURE__*/(0, _jsxRuntime.jsx)(_zoomOutToggle.default, {
175
181
  disabled: forceDisableBlockTools
176
182
  }), (isWideViewport || !showIconLabels) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_interface.PinnedItems.Slot, {
177
183
  scope: "core"
178
184
  }), !customSaveButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(_postPublishButtonOrToggle.default, {
179
185
  forceIsDirty: forceIsDirty,
180
186
  setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
181
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_collabSidebar.default, {}), customSaveButton, /*#__PURE__*/(0, _jsxRuntime.jsx)(_moreMenu.default, {})]
187
+ }), isBlockCommentExperimentEnabled ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_collabSidebar.default, {}) : undefined, customSaveButton, /*#__PURE__*/(0, _jsxRuntime.jsx)(_moreMenu.default, {})]
182
188
  })]
183
189
  });
184
190
  }