@wordpress/block-library 7.0.1 → 7.0.2

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 (230) hide show
  1. package/README.md +16 -0
  2. package/build/button/edit.native.js +2 -2
  3. package/build/button/edit.native.js.map +1 -1
  4. package/build/columns/index.js +12 -0
  5. package/build/columns/index.js.map +1 -1
  6. package/build/comment-author-avatar/edit.js +17 -4
  7. package/build/comment-author-avatar/edit.js.map +1 -1
  8. package/build/comment-template/edit.js +94 -36
  9. package/build/comment-template/edit.js.map +1 -1
  10. package/build/comment-template/hooks.js +175 -0
  11. package/build/comment-template/hooks.js.map +1 -0
  12. package/build/comment-template/index.js +1 -1
  13. package/build/comment-template/util.js.map +1 -1
  14. package/build/comments-pagination-next/index.js +1 -1
  15. package/build/comments-pagination-numbers/index.js +1 -1
  16. package/build/comments-query-loop/edit/comments-inspector-controls.js +20 -9
  17. package/build/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
  18. package/build/comments-query-loop/edit.js +1 -19
  19. package/build/comments-query-loop/edit.js.map +1 -1
  20. package/build/comments-query-loop/index.js +5 -0
  21. package/build/comments-query-loop/index.js.map +1 -1
  22. package/build/cover/edit.js +21 -22
  23. package/build/cover/edit.js.map +1 -1
  24. package/build/cover/edit.native.js +7 -5
  25. package/build/cover/edit.native.js.map +1 -1
  26. package/build/cover/overlay-color-settings.native.js +4 -3
  27. package/build/cover/overlay-color-settings.native.js.map +1 -1
  28. package/build/cover/transforms.js +4 -2
  29. package/build/cover/transforms.js.map +1 -1
  30. package/build/group/index.js +1 -0
  31. package/build/group/index.js.map +1 -1
  32. package/build/heading/edit.js +14 -2
  33. package/build/heading/edit.js.map +1 -1
  34. package/build/image/deprecated.js +89 -5
  35. package/build/image/deprecated.js.map +1 -1
  36. package/build/image/save.js +0 -7
  37. package/build/image/save.js.map +1 -1
  38. package/build/latest-posts/edit.js +1 -0
  39. package/build/latest-posts/edit.js.map +1 -1
  40. package/build/navigation/edit/index.js +17 -15
  41. package/build/navigation/edit/index.js.map +1 -1
  42. package/build/navigation/edit/navigation-menu-selector.js +44 -27
  43. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  44. package/build/navigation/edit/placeholder/index.js +8 -22
  45. package/build/navigation/edit/placeholder/index.js.map +1 -1
  46. package/build/navigation/use-navigation-menu.js +6 -6
  47. package/build/navigation/use-navigation-menu.js.map +1 -1
  48. package/build/navigation-submenu/edit.js +41 -9
  49. package/build/navigation-submenu/edit.js.map +1 -1
  50. package/build/page-list/edit.js +11 -17
  51. package/build/page-list/edit.js.map +1 -1
  52. package/build/social-links/deprecated.js +1 -62
  53. package/build/social-links/deprecated.js.map +1 -1
  54. package/build/template-part/edit/index.js +36 -64
  55. package/build/template-part/edit/index.js.map +1 -1
  56. package/build/template-part/edit/placeholder.js +64 -0
  57. package/build/template-part/edit/placeholder.js.map +1 -0
  58. package/build/template-part/edit/selection-modal.js +103 -0
  59. package/build/template-part/edit/selection-modal.js.map +1 -0
  60. package/build/template-part/edit/title-modal.js +54 -0
  61. package/build/template-part/edit/title-modal.js.map +1 -0
  62. package/build/template-part/edit/utils/hooks.js +156 -0
  63. package/build/template-part/edit/utils/hooks.js.map +1 -0
  64. package/build/template-part/index.js +3 -1
  65. package/build/template-part/index.js.map +1 -1
  66. package/build-module/button/edit.native.js +4 -4
  67. package/build-module/button/edit.native.js.map +1 -1
  68. package/build-module/columns/index.js +12 -0
  69. package/build-module/columns/index.js.map +1 -1
  70. package/build-module/comment-author-avatar/edit.js +18 -6
  71. package/build-module/comment-author-avatar/edit.js.map +1 -1
  72. package/build-module/comment-template/edit.js +95 -37
  73. package/build-module/comment-template/edit.js.map +1 -1
  74. package/build-module/comment-template/hooks.js +156 -0
  75. package/build-module/comment-template/hooks.js.map +1 -0
  76. package/build-module/comment-template/index.js +1 -1
  77. package/build-module/comment-template/util.js.map +1 -1
  78. package/build-module/comments-pagination-next/index.js +1 -1
  79. package/build-module/comments-pagination-numbers/index.js +1 -1
  80. package/build-module/comments-query-loop/edit/comments-inspector-controls.js +20 -9
  81. package/build-module/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
  82. package/build-module/comments-query-loop/edit.js +2 -19
  83. package/build-module/comments-query-loop/edit.js.map +1 -1
  84. package/build-module/comments-query-loop/index.js +5 -0
  85. package/build-module/comments-query-loop/index.js.map +1 -1
  86. package/build-module/cover/edit.js +23 -24
  87. package/build-module/cover/edit.js.map +1 -1
  88. package/build-module/cover/edit.native.js +10 -8
  89. package/build-module/cover/edit.native.js.map +1 -1
  90. package/build-module/cover/overlay-color-settings.native.js +4 -4
  91. package/build-module/cover/overlay-color-settings.native.js.map +1 -1
  92. package/build-module/cover/transforms.js +4 -2
  93. package/build-module/cover/transforms.js.map +1 -1
  94. package/build-module/group/index.js +1 -0
  95. package/build-module/group/index.js.map +1 -1
  96. package/build-module/heading/edit.js +15 -3
  97. package/build-module/heading/edit.js.map +1 -1
  98. package/build-module/image/deprecated.js +90 -7
  99. package/build-module/image/deprecated.js.map +1 -1
  100. package/build-module/image/save.js +0 -7
  101. package/build-module/image/save.js.map +1 -1
  102. package/build-module/latest-posts/edit.js +1 -0
  103. package/build-module/latest-posts/edit.js.map +1 -1
  104. package/build-module/navigation/edit/index.js +17 -15
  105. package/build-module/navigation/edit/index.js.map +1 -1
  106. package/build-module/navigation/edit/navigation-menu-selector.js +45 -27
  107. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  108. package/build-module/navigation/edit/placeholder/index.js +8 -21
  109. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  110. package/build-module/navigation/use-navigation-menu.js +6 -6
  111. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  112. package/build-module/navigation-submenu/edit.js +41 -10
  113. package/build-module/navigation-submenu/edit.js.map +1 -1
  114. package/build-module/page-list/edit.js +12 -18
  115. package/build-module/page-list/edit.js.map +1 -1
  116. package/build-module/social-links/deprecated.js +1 -62
  117. package/build-module/social-links/deprecated.js.map +1 -1
  118. package/build-module/template-part/edit/index.js +37 -65
  119. package/build-module/template-part/edit/index.js.map +1 -1
  120. package/build-module/template-part/edit/placeholder.js +52 -0
  121. package/build-module/template-part/edit/placeholder.js.map +1 -0
  122. package/build-module/template-part/edit/selection-modal.js +89 -0
  123. package/build-module/template-part/edit/selection-modal.js.map +1 -0
  124. package/build-module/template-part/edit/title-modal.js +46 -0
  125. package/build-module/template-part/edit/title-modal.js.map +1 -0
  126. package/build-module/template-part/edit/utils/hooks.js +135 -0
  127. package/build-module/template-part/edit/utils/hooks.js.map +1 -0
  128. package/build-module/template-part/index.js +2 -1
  129. package/build-module/template-part/index.js.map +1 -1
  130. package/build-style/comment-author-avatar/editor-rtl.css +83 -0
  131. package/build-style/comment-author-avatar/editor.css +83 -0
  132. package/build-style/cover/style-rtl.css +4 -0
  133. package/build-style/cover/style.css +4 -0
  134. package/build-style/editor-rtl.css +27 -81
  135. package/build-style/editor.css +27 -81
  136. package/build-style/image/editor-rtl.css +0 -16
  137. package/build-style/image/editor.css +0 -16
  138. package/build-style/image/style-rtl.css +2 -0
  139. package/build-style/image/style.css +2 -0
  140. package/build-style/navigation/style-rtl.css +14 -3
  141. package/build-style/navigation/style.css +14 -3
  142. package/build-style/page-list/editor-rtl.css +0 -9
  143. package/build-style/page-list/editor.css +0 -9
  144. package/build-style/style-rtl.css +20 -3
  145. package/build-style/style.css +20 -3
  146. package/build-style/template-part/editor-rtl.css +19 -56
  147. package/build-style/template-part/editor.css +19 -56
  148. package/package.json +15 -15
  149. package/src/archives/index.php +1 -1
  150. package/src/button/edit.native.js +3 -3
  151. package/src/columns/block.json +12 -0
  152. package/src/comment-author-avatar/edit.js +13 -8
  153. package/src/comment-author-avatar/editor.scss +7 -0
  154. package/src/comment-template/block.json +7 -1
  155. package/src/comment-template/edit.js +102 -40
  156. package/src/comment-template/hooks.js +151 -0
  157. package/src/comment-template/index.php +8 -0
  158. package/src/comment-template/util.js +1 -0
  159. package/src/comments-pagination-next/block.json +8 -1
  160. package/src/comments-pagination-next/index.php +6 -8
  161. package/src/comments-pagination-numbers/block.json +7 -1
  162. package/src/comments-pagination-numbers/index.php +3 -10
  163. package/src/comments-query-loop/block.json +5 -0
  164. package/src/comments-query-loop/edit/comments-inspector-controls.js +22 -4
  165. package/src/comments-query-loop/edit.js +1 -16
  166. package/src/cover/edit.js +15 -28
  167. package/src/cover/edit.native.js +15 -7
  168. package/src/cover/overlay-color-settings.native.js +3 -4
  169. package/src/cover/style.scss +4 -0
  170. package/src/cover/transforms.js +2 -0
  171. package/src/editor.scss +1 -0
  172. package/src/gallery/index.php +1 -8
  173. package/src/group/block.json +1 -0
  174. package/src/heading/edit.js +18 -5
  175. package/src/home-link/index.php +1 -19
  176. package/src/image/deprecated.js +105 -1
  177. package/src/image/editor.scss +0 -18
  178. package/src/image/save.js +0 -8
  179. package/src/image/style.scss +3 -0
  180. package/src/image/test/edit.native.js +0 -10
  181. package/src/latest-posts/edit.js +1 -0
  182. package/src/latest-posts/index.php +1 -1
  183. package/src/navigation/edit/index.js +25 -26
  184. package/src/navigation/edit/navigation-menu-selector.js +73 -28
  185. package/src/navigation/edit/placeholder/index.js +8 -32
  186. package/src/navigation/index.php +4 -4
  187. package/src/navigation/style.scss +22 -3
  188. package/src/navigation/use-navigation-menu.js +6 -6
  189. package/src/navigation-link/index.php +3 -22
  190. package/src/navigation-submenu/edit.js +50 -12
  191. package/src/navigation-submenu/index.php +3 -21
  192. package/src/page-list/edit.js +21 -25
  193. package/src/page-list/editor.scss +0 -10
  194. package/src/page-list/index.php +4 -4
  195. package/src/post-navigation-link/index.php +3 -3
  196. package/src/search/index.php +6 -3
  197. package/src/site-logo/index.php +1 -1
  198. package/src/social-links/deprecated.js +0 -59
  199. package/src/template-part/edit/index.js +61 -71
  200. package/src/template-part/edit/placeholder.js +78 -0
  201. package/src/template-part/edit/selection-modal.js +115 -0
  202. package/src/template-part/edit/title-modal.js +59 -0
  203. package/src/template-part/edit/utils/hooks.js +158 -0
  204. package/src/template-part/editor.scss +16 -74
  205. package/src/template-part/index.js +4 -1
  206. package/build/navigation/edit/existing-menus-options.js +0 -62
  207. package/build/navigation/edit/existing-menus-options.js.map +0 -1
  208. package/build/template-part/edit/placeholder/index.js +0 -141
  209. package/build/template-part/edit/placeholder/index.js.map +0 -1
  210. package/build/template-part/edit/placeholder/patterns-setup.js +0 -100
  211. package/build/template-part/edit/placeholder/patterns-setup.js.map +0 -1
  212. package/build/template-part/edit/selection/index.js +0 -45
  213. package/build/template-part/edit/selection/index.js.map +0 -1
  214. package/build/template-part/edit/selection/template-part-previews.js +0 -317
  215. package/build/template-part/edit/selection/template-part-previews.js.map +0 -1
  216. package/build-module/navigation/edit/existing-menus-options.js +0 -53
  217. package/build-module/navigation/edit/existing-menus-options.js.map +0 -1
  218. package/build-module/template-part/edit/placeholder/index.js +0 -124
  219. package/build-module/template-part/edit/placeholder/index.js.map +0 -1
  220. package/build-module/template-part/edit/placeholder/patterns-setup.js +0 -91
  221. package/build-module/template-part/edit/placeholder/patterns-setup.js.map +0 -1
  222. package/build-module/template-part/edit/selection/index.js +0 -35
  223. package/build-module/template-part/edit/selection/index.js.map +0 -1
  224. package/build-module/template-part/edit/selection/template-part-previews.js +0 -298
  225. package/build-module/template-part/edit/selection/template-part-previews.js.map +0 -1
  226. package/src/navigation/edit/existing-menus-options.js +0 -70
  227. package/src/template-part/edit/placeholder/index.js +0 -172
  228. package/src/template-part/edit/placeholder/patterns-setup.js +0 -124
  229. package/src/template-part/edit/selection/index.js +0 -37
  230. package/src/template-part/edit/selection/template-part-previews.js +0 -372
package/README.md CHANGED
@@ -96,4 +96,20 @@ This is an individual package that's part of the Gutenberg project. The project
96
96
 
97
97
  To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).
98
98
 
99
+ ### Adding new blocks
100
+
101
+ ⚠️ Adding new blocks to this package **requires** additional steps!
102
+
103
+ 1. Do not forget to register your new block in the [`index.js`](https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/index.js) file of this package. For example, if you were to add a new core block called `core/blinking-paragraph`, you would have to add something like:
104
+
105
+ ```js
106
+ // packages/block-library/src/index.js
107
+ import * as blinkingParagraph from './blinking-paragraph';
108
+
109
+ // Then add `blinkingParagraph` to either `__experimentalGetCoreBlocks()`
110
+ // or `__experimentalRegisterExperimentalCoreBlocks()`
111
+ ```
112
+
113
+ 2. Register your block in the `gutenberg_reregister_core_block_types()` function of the [`lib/blocks.php`](https://github.com/WordPress/gutenberg/blob/trunk/lib/blocks.php) file. Add it to the `block_folders` array if it's a [static block](https://developer.wordpress.org/block-editor/explanations/glossary/#static-block) or to the `block_names` array if it's a [dynamic block](https://developer.wordpress.org/block-editor/explanations/glossary/#dynamic-block).
114
+
99
115
  <br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
@@ -133,8 +133,8 @@ function ButtonEdit(props) {
133
133
  const [placeholderTextWidth, setPlaceholderTextWidth] = (0, _element.useState)(0);
134
134
  const [borderRadiusUnit, setBorderRadiusUnit] = (0, _element.useState)(valueUnit);
135
135
  const richTextRef = (0, _element.useRef)();
136
- const colors = (0, _blockEditor.useSetting)('color.palette') || [];
137
- const gradients = (0, _blockEditor.useSetting)('color.gradients') || [];
136
+ const colors = (0, _components.useMobileGlobalStylesColors)();
137
+ const gradients = (0, _components.useMobileGlobalStylesColors)('gradients');
138
138
  (0, _element.useEffect)(() => {
139
139
  if (isSelected) {
140
140
  onToggleButtonFocus(true);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/button/edit.native.js"],"names":["MIN_BORDER_RADIUS_VALUE","MAX_BORDER_RADIUS_VALUE","INITIAL_MAX_WIDTH","MIN_WIDTH","MIN_WIDTH_MARGINS","styles","button75","marginLeft","button50","button25","WidthPanel","selectedWidth","setAttributes","handleChange","newWidth","width","undefined","options","value","label","ButtonEdit","props","isSelected","parentWidth","initialBorderRadius","attributes","style","border","radius","valueUnit","editorSidebarOpened","numOfButtons","select","isEditorSidebarOpened","editPostStore","getBlockCount","getBlockRootClientId","blockEditorStore","parentId","clientId","blockCount","currentIsEditorSidebarOpened","closeGeneralSidebar","maxWidth","setMaxWidth","isLinkSheetVisible","setIsLinkSheetVisible","isButtonFocused","setIsButtonFocused","placeholderTextWidth","setPlaceholderTextWidth","borderRadiusUnit","setBorderRadiusUnit","richTextRef","colors","gradients","onToggleButtonFocus","onSetMaxWidth","Platform","OS","current","blur","AccessibilityInfo","isScreenReaderEnabled","then","enabled","focus","linkSettingsActions","onPress","onClearSettings","linkSettingsOptions","url","placeholder","autoFocus","autoFill","openInNewTab","linkRel","noFocusLinkSettingOptions","getBackgroundColor","backgroundColor","gradient","gradientValue","colorProps","colorObject","color","background","defaultButton","getTextColor","textColor","onChangeText","text","onChangeBorderRadius","newRadius","newStyle","getNewStyle","onChangeBorderRadiusUnit","newRadiusUnit","newBorderRadius","getBorderRadiusValue","radiusUnit","onShowLinkSettings","onHideLinkSettings","rel","linkTarget","onLayout","nativeEvent","layout","isParentWidthDidChange","marginRight","spacing","isParentWidthChanged","isWidthChanged","onRemove","onDeleteBlock","onReplace","onPlaceholderTextWidth","textWidth","lines","Math","min","onSetRef","ref","onUnstableOnFocus","onBlur","dismissSheet","getLinkSettings","isCompatibleWithSettings","getPlaceholderWidth","placeholderText","currentBorderRadius","defaultBorderRadius","valueAndUnit","Number","isInteger","parseInt","valueToConvert","parseFloat","mergeBlocks","buttonStyle","align","paddingTop","borderWidth","borderRadiusValue","borderRadius","buttonBorderRadiusValue","floor","outlineBorderRadius","minWidth","isFixedWidth","outLineStyles","outline","borderColor","textStyles","richTextStyle","richText","paddingLeft","paddingRight","placeholderTextColor","fontSize","link","CSS_UNITS"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAUA;;AAWA;;AACA;;AAKA;;AACA;;AACA;;;;AAEA,MAAMA,uBAAuB,GAAG,CAAhC;AACA,MA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AAA,KAAK,EAAG,cAAI,eAAJ;AAAnB,KACGiH,eAAe,CAAE,IAAF,CADlB,CApBD,CAZD,CAvCF,CADD;AAgFA;;eAEczG,U","sourcesContent":["/**\n * External dependencies\n */\nimport { View, AccessibilityInfo, Platform, Text } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useState, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tRichText,\n\tInspectorControls,\n\tBlockControls,\n\tstore as blockEditorStore,\n\tgetColorObjectByAttributeValues,\n\tgetGradientValueBySlug,\n\t__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,\n\tuseSetting,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\tToolbarGroup,\n\tToolbarButton,\n\tLinkSettingsNavigation,\n\tUnitControl,\n\tgetValueAndUnit,\n\tBottomSheetSelectControl,\n\tCSS_UNITS,\n\tfilterUnitsWithSettings,\n} from '@wordpress/components';\nimport { link } from '@wordpress/icons';\nimport { store as editPostStore } from '@wordpress/edit-post';\n\n/**\n * Internal dependencies\n */\nimport richTextStyle from './rich-text.scss';\nimport styles from './editor.scss';\nimport ColorBackground from './color-background';\n\nconst MIN_BORDER_RADIUS_VALUE = 0;\nconst MAX_BORDER_RADIUS_VALUE = 50;\nconst INITIAL_MAX_WIDTH = 108;\nconst MIN_WIDTH = 40;\n// Map of the percentage width to pixel subtraction that make the buttons fit nicely into columns.\nconst MIN_WIDTH_MARGINS = {\n\t100: 0,\n\t75: styles.button75?.marginLeft,\n\t50: styles.button50?.marginLeft,\n\t25: styles.button25?.marginLeft,\n};\n\nfunction WidthPanel( { selectedWidth, setAttributes } ) {\n\tfunction handleChange( newWidth ) {\n\t\t// Check if we are toggling the width off\n\t\tlet width = selectedWidth === newWidth ? undefined : newWidth;\n\t\tif ( newWidth === 'auto' ) {\n\t\t\twidth = undefined;\n\t\t}\n\t\t// Update attributes\n\t\tsetAttributes( { width } );\n\t}\n\n\tconst options = [\n\t\t{ value: 'auto', label: __( 'Auto' ) },\n\t\t{ value: 25, label: '25%' },\n\t\t{ value: 50, label: '50%' },\n\t\t{ value: 75, label: '75%' },\n\t\t{ value: 100, label: '100%' },\n\t];\n\n\tif ( ! selectedWidth ) {\n\t\tselectedWidth = 'auto';\n\t}\n\n\treturn (\n\t\t<PanelBody title={ __( 'Width Settings' ) }>\n\t\t\t<BottomSheetSelectControl\n\t\t\t\tlabel={ __( 'Button width' ) }\n\t\t\t\tvalue={ selectedWidth }\n\t\t\t\tonChange={ handleChange }\n\t\t\t\toptions={ options }\n\t\t\t/>\n\t\t</PanelBody>\n\t);\n}\n\nfunction ButtonEdit( props ) {\n\tconst { isSelected, parentWidth } = props;\n\tconst initialBorderRadius = props?.attributes?.style?.border?.radius;\n\tconst { valueUnit = 'px' } = getValueAndUnit( initialBorderRadius ) || {};\n\n\tconst { editorSidebarOpened, numOfButtons } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isEditorSidebarOpened } = select( editPostStore );\n\t\t\tconst { getBlockCount, getBlockRootClientId } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst parentId = getBlockRootClientId( clientId );\n\t\t\tconst blockCount = getBlockCount( parentId );\n\t\t\tconst currentIsEditorSidebarOpened = isEditorSidebarOpened();\n\n\t\t\treturn {\n\t\t\t\teditorSidebarOpened: isSelected && currentIsEditorSidebarOpened,\n\t\t\t\tnumOfButtons: blockCount,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isSelected ]\n\t);\n\n\tconst { closeGeneralSidebar } = useDispatch( editPostStore );\n\tconst [ maxWidth, setMaxWidth ] = useState( INITIAL_MAX_WIDTH );\n\tconst [ isLinkSheetVisible, setIsLinkSheetVisible ] = useState( false );\n\tconst [ isButtonFocused, setIsButtonFocused ] = useState( true );\n\tconst [ placeholderTextWidth, setPlaceholderTextWidth ] = useState( 0 );\n\tconst [ borderRadiusUnit, setBorderRadiusUnit ] = useState( valueUnit );\n\n\tconst richTextRef = useRef();\n\tconst colors = useSetting( 'color.palette' ) || [];\n\tconst gradients = useSetting( 'color.gradients' ) || [];\n\n\tuseEffect( () => {\n\t\tif ( isSelected ) {\n\t\t\tonToggleButtonFocus( true );\n\t\t}\n\t}, [ isSelected ] );\n\n\tuseEffect( () => {\n\t\tonSetMaxWidth( null, true );\n\t}, [ parentWidth ] );\n\n\tuseEffect( () => {\n\t\t// Blur `RichText` on Android when link settings sheet or button settings sheet is opened,\n\t\t// to avoid flashing caret after closing one of them\n\t\tif ( editorSidebarOpened || isLinkSheetVisible ) {\n\t\t\tif ( Platform.OS === 'android' && richTextRef?.current ) {\n\t\t\t\trichTextRef.current.blur();\n\t\t\t\tonToggleButtonFocus( false );\n\t\t\t}\n\t\t}\n\t}, [ editorSidebarOpened, isLinkSheetVisible ] );\n\n\tuseEffect( () => {\n\t\tif ( richTextRef?.current ) {\n\t\t\tif ( ! isSelected && isButtonFocused ) {\n\t\t\t\tonToggleButtonFocus( false );\n\t\t\t}\n\n\t\t\tif ( isSelected && ! isButtonFocused ) {\n\t\t\t\tAccessibilityInfo.isScreenReaderEnabled().then( ( enabled ) => {\n\t\t\t\t\tif ( enabled ) {\n\t\t\t\t\t\tonToggleButtonFocus( true );\n\t\t\t\t\t\trichTextRef?.current.focus();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}, [ isSelected, isButtonFocused ] );\n\n\tconst linkSettingsActions = [\n\t\t{\n\t\t\tlabel: __( 'Remove link' ),\n\t\t\tonPress: onClearSettings,\n\t\t},\n\t];\n\n\tconst linkSettingsOptions = {\n\t\turl: {\n\t\t\tlabel: __( 'Button Link URL' ),\n\t\t\tplaceholder: __( 'Add URL' ),\n\t\t\tautoFocus: true,\n\t\t\tautoFill: false,\n\t\t},\n\t\topenInNewTab: {\n\t\t\tlabel: __( 'Open in new tab' ),\n\t\t},\n\t\tlinkRel: {\n\t\t\tlabel: __( 'Link Rel' ),\n\t\t\tplaceholder: _x( 'None', 'Link rel attribute value placeholder' ),\n\t\t},\n\t};\n\n\tconst noFocusLinkSettingOptions = {\n\t\t...linkSettingsOptions,\n\t\turl: {\n\t\t\t...linkSettingsOptions.url,\n\t\t\tautoFocus: false,\n\t\t},\n\t};\n\n\tfunction getBackgroundColor() {\n\t\tconst { attributes, style } = props;\n\t\tconst { backgroundColor, gradient } = attributes;\n\n\t\t// Return named gradient value if available.\n\t\tconst gradientValue = getGradientValueBySlug( gradients, gradient );\n\n\t\tif ( gradientValue ) {\n\t\t\treturn gradientValue;\n\t\t}\n\n\t\tconst colorProps = getColorClassesAndStyles( attributes );\n\n\t\t// Retrieve named color object to force inline styles for themes that\n\t\t// do not load their color stylesheets in the editor.\n\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\tcolors,\n\t\t\tbackgroundColor\n\t\t);\n\n\t\treturn (\n\t\t\tcolorObject?.color ||\n\t\t\tcolorProps.style?.backgroundColor ||\n\t\t\tcolorProps.style?.background ||\n\t\t\tstyle?.backgroundColor ||\n\t\t\tstyles.defaultButton.backgroundColor\n\t\t);\n\t}\n\n\tfunction getTextColor() {\n\t\tconst { attributes, style } = props;\n\t\tconst colorProps = getColorClassesAndStyles( attributes );\n\n\t\t// Retrieve named color object to force inline styles for themes that\n\t\t// do not load their color stylesheets in the editor.\n\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\tcolors,\n\t\t\tattributes.textColor\n\t\t);\n\n\t\treturn (\n\t\t\tcolorObject?.color ||\n\t\t\tcolorProps.style?.color ||\n\t\t\tstyle?.color ||\n\t\t\tstyles.defaultButton.color\n\t\t);\n\t}\n\n\tfunction onChangeText( value ) {\n\t\tconst { setAttributes } = props;\n\t\tsetAttributes( { text: value } );\n\t}\n\n\tfunction onChangeBorderRadius( newRadius ) {\n\t\tconst { setAttributes, attributes } = props;\n\t\tconst { style } = attributes;\n\t\tconst newStyle = getNewStyle( style, newRadius, borderRadiusUnit );\n\n\t\tsetAttributes( { style: newStyle } );\n\t}\n\n\tfunction onChangeBorderRadiusUnit( newRadiusUnit ) {\n\t\tconst { setAttributes, attributes } = props;\n\t\tconst { style } = attributes;\n\t\tconst newBorderRadius = getBorderRadiusValue(\n\t\t\tattributes?.style?.border?.radius\n\t\t);\n\t\tconst newStyle = getNewStyle( style, newBorderRadius, newRadiusUnit );\n\t\tsetAttributes( { style: newStyle } );\n\t\tsetBorderRadiusUnit( newRadiusUnit );\n\t}\n\n\tfunction getNewStyle( style, radius, radiusUnit ) {\n\t\treturn {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tradius: `${ radius }${ radiusUnit }`, // Store the value with the unit so that it works as expected.\n\t\t\t},\n\t\t};\n\t}\n\n\tfunction onShowLinkSettings() {\n\t\tsetIsLinkSheetVisible( true );\n\t}\n\n\tfunction onHideLinkSettings() {\n\t\tsetIsLinkSheetVisible( false );\n\t}\n\n\tfunction onToggleButtonFocus( value ) {\n\t\tif ( value !== isButtonFocused ) {\n\t\t\tsetIsButtonFocused( value );\n\t\t}\n\t}\n\n\tfunction onClearSettings() {\n\t\tconst { setAttributes } = props;\n\n\t\tsetAttributes( {\n\t\t\turl: '',\n\t\t\trel: '',\n\t\t\tlinkTarget: '',\n\t\t} );\n\n\t\tonHideLinkSettings();\n\t}\n\n\tfunction onLayout( { nativeEvent } ) {\n\t\tconst { width } = nativeEvent.layout;\n\t\tonSetMaxWidth( width );\n\t}\n\n\tconst onSetMaxWidth = useCallback(\n\t\t( width, isParentWidthDidChange = false ) => {\n\t\t\tconst { marginRight: spacing } = styles.defaultButton;\n\n\t\t\tconst isParentWidthChanged = isParentWidthDidChange\n\t\t\t\t? isParentWidthDidChange\n\t\t\t\t: maxWidth !== parentWidth;\n\t\t\tconst isWidthChanged = maxWidth !== width;\n\n\t\t\tif ( parentWidth && ! width && isParentWidthChanged ) {\n\t\t\t\tsetMaxWidth( parentWidth - spacing );\n\t\t\t} else if ( ! parentWidth && width && isWidthChanged ) {\n\t\t\t\tsetMaxWidth( width - spacing );\n\t\t\t}\n\t\t},\n\t\t[ maxWidth, parentWidth ]\n\t);\n\n\tfunction onRemove() {\n\t\tconst { onDeleteBlock, onReplace } = props;\n\n\t\tif ( numOfButtons === 1 ) {\n\t\t\tonDeleteBlock();\n\t\t} else {\n\t\t\tonReplace( [] );\n\t\t}\n\t}\n\n\tfunction onPlaceholderTextWidth( { nativeEvent } ) {\n\t\tconst textWidth =\n\t\t\tnativeEvent.lines[ 0 ] && nativeEvent.lines[ 0 ].width;\n\n\t\tif ( textWidth && textWidth !== placeholderTextWidth ) {\n\t\t\tsetPlaceholderTextWidth( Math.min( textWidth, maxWidth ) );\n\t\t}\n\t}\n\n\tconst onSetRef = useCallback(\n\t\t( ref ) => {\n\t\t\trichTextRef.current = ref;\n\t\t},\n\t\t[ richTextRef ]\n\t);\n\n\tconst onUnstableOnFocus = useCallback( () => {\n\t\tonToggleButtonFocus( true );\n\t}, [] );\n\n\tconst onBlur = useCallback( () => {\n\t\tonSetMaxWidth();\n\t}, [] );\n\n\tfunction dismissSheet() {\n\t\tonHideLinkSettings();\n\t\tcloseGeneralSidebar();\n\t}\n\n\tfunction getLinkSettings( isCompatibleWithSettings ) {\n\t\tconst { attributes, setAttributes } = props;\n\t\treturn (\n\t\t\t<LinkSettingsNavigation\n\t\t\t\tisVisible={ isLinkSheetVisible }\n\t\t\t\turl={ attributes.url }\n\t\t\t\trel={ attributes.rel }\n\t\t\t\tlinkTarget={ attributes.linkTarget }\n\t\t\t\tonClose={ dismissSheet }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\twithBottomSheet={ ! isCompatibleWithSettings }\n\t\t\t\thasPicker\n\t\t\t\tactions={ linkSettingsActions }\n\t\t\t\toptions={\n\t\t\t\t\tisCompatibleWithSettings\n\t\t\t\t\t\t? linkSettingsOptions\n\t\t\t\t\t\t: noFocusLinkSettingOptions\n\t\t\t\t}\n\t\t\t\tshowIcon={ ! isCompatibleWithSettings }\n\t\t\t/>\n\t\t);\n\t}\n\n\t// Render `Text` with `placeholderText` styled as a placeholder\n\t// to calculate its width which then is set as a `minWidth`\n\tfunction getPlaceholderWidth( placeholderText ) {\n\t\treturn (\n\t\t\t<Text\n\t\t\t\tstyle={ styles.placeholder }\n\t\t\t\tonTextLayout={ onPlaceholderTextWidth }\n\t\t\t>\n\t\t\t\t{ placeholderText }\n\t\t\t</Text>\n\t\t);\n\t}\n\n\tfunction getBorderRadiusValue( currentBorderRadius, defaultBorderRadius ) {\n\t\tconst valueAndUnit = getValueAndUnit( currentBorderRadius );\n\t\tif ( Number.isInteger( parseInt( valueAndUnit?.valueToConvert ) ) ) {\n\t\t\treturn parseFloat( valueAndUnit.valueToConvert );\n\t\t}\n\t\treturn defaultBorderRadius;\n\t}\n\n\tconst {\n\t\tattributes,\n\t\tclientId,\n\t\tonReplace,\n\t\tmergeBlocks,\n\t\tsetAttributes,\n\t\tstyle,\n\t} = props;\n\tconst {\n\t\tplaceholder,\n\t\ttext,\n\t\tstyle: buttonStyle,\n\t\turl,\n\t\talign = 'center',\n\t\twidth,\n\t} = attributes;\n\tconst { paddingTop: spacing, borderWidth } = styles.defaultButton;\n\n\tif ( parentWidth === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst currentBorderRadius = buttonStyle?.border?.radius;\n\tconst borderRadiusValue = getBorderRadiusValue(\n\t\tcurrentBorderRadius,\n\t\tstyles.defaultButton.borderRadius\n\t);\n\n\tconst buttonBorderRadiusValue =\n\t\tborderRadiusUnit === 'px' || borderRadiusUnit === '%'\n\t\t\t? borderRadiusValue\n\t\t\t: Math.floor( 14 * borderRadiusValue ); // lets assume that the font size is set to 14px; TO get a nicer preview.\n\tconst outlineBorderRadius =\n\t\tbuttonBorderRadiusValue > 0\n\t\t\t? buttonBorderRadiusValue + spacing + borderWidth\n\t\t\t: 0;\n\n\t// To achieve proper expanding and shrinking `RichText` on iOS, there is a need to set a `minWidth`\n\t// value at least on 1 when `RichText` is focused or when is not focused, but `RichText` value is\n\t// different than empty string.\n\tlet minWidth =\n\t\tisButtonFocused || ( ! isButtonFocused && text && text !== '' )\n\t\t\t? MIN_WIDTH\n\t\t\t: placeholderTextWidth;\n\tif ( width ) {\n\t\t// Set the width of the button.\n\t\tminWidth = Math.floor(\n\t\t\tmaxWidth * ( width / 100 ) - MIN_WIDTH_MARGINS[ width ]\n\t\t);\n\t}\n\t// To achieve proper expanding and shrinking `RichText` on Android, there is a need to set\n\t// a `placeholder` as an empty string when `RichText` is focused,\n\t// because `AztecView` is calculating a `minWidth` based on placeholder text.\n\tconst placeholderText =\n\t\tisButtonFocused || ( ! isButtonFocused && text && text !== '' )\n\t\t\t? ''\n\t\t\t: placeholder || __( 'Add text…' );\n\n\tconst backgroundColor = getBackgroundColor();\n\tconst textColor = getTextColor();\n\tconst isFixedWidth = !! width;\n\tconst outLineStyles = [\n\t\tstyles.outline,\n\t\t{\n\t\t\tborderRadius: outlineBorderRadius,\n\t\t\tborderColor: backgroundColor,\n\t\t},\n\t];\n\tconst textStyles = {\n\t\t...richTextStyle.richText,\n\t\tpaddingLeft: isFixedWidth ? 0 : richTextStyle.richText.paddingLeft,\n\t\tpaddingRight: isFixedWidth ? 0 : richTextStyle.richText.paddingRight,\n\t\tcolor: textColor,\n\t};\n\n\treturn (\n\t\t<View onLayout={ onLayout }>\n\t\t\t{ getPlaceholderWidth( placeholderText ) }\n\t\t\t<ColorBackground\n\t\t\t\tborderRadiusValue={ buttonBorderRadiusValue }\n\t\t\t\tbackgroundColor={ backgroundColor }\n\t\t\t\tisSelected={ isSelected }\n\t\t\t>\n\t\t\t\t{ isSelected && (\n\t\t\t\t\t<View pointerEvents=\"none\" style={ outLineStyles } />\n\t\t\t\t) }\n\t\t\t\t<RichText\n\t\t\t\t\tsetRef={ onSetRef }\n\t\t\t\t\tplaceholder={ placeholderText }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tonChange={ onChangeText }\n\t\t\t\t\tstyle={ textStyles }\n\t\t\t\t\ttextAlign={ align }\n\t\t\t\t\tplaceholderTextColor={\n\t\t\t\t\t\tstyle?.color || styles.placeholderTextColor.color\n\t\t\t\t\t}\n\t\t\t\t\tidentifier=\"text\"\n\t\t\t\t\ttagName=\"p\"\n\t\t\t\t\tminWidth={ minWidth } // The minimum Button size.\n\t\t\t\t\tmaxWidth={ isFixedWidth ? minWidth : maxWidth } // The width of the screen.\n\t\t\t\t\tid={ clientId }\n\t\t\t\t\tisSelected={ isButtonFocused }\n\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\tunstableOnFocus={ onUnstableOnFocus }\n\t\t\t\t\t__unstableMobileNoFocusOnMount={ ! isSelected }\n\t\t\t\t\tselectionColor={ textColor }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\tfontSize={ style?.fontSize }\n\t\t\t\t/>\n\t\t\t</ColorBackground>\n\n\t\t\t{ isSelected && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\ttitle={ __( 'Edit link' ) }\n\t\t\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\t\t\tonClick={ onShowLinkSettings }\n\t\t\t\t\t\t\t\tisActive={ url }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t{ getLinkSettings( false ) }\n\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t<PanelBody title={ __( 'Border Settings' ) }>\n\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Border Radius' ) }\n\t\t\t\t\t\t\t\tmin={ MIN_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\t\t\tmax={ MAX_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\t\t\tvalue={ borderRadiusValue }\n\t\t\t\t\t\t\t\tonChange={ onChangeBorderRadius }\n\t\t\t\t\t\t\t\tonUnitChange={ onChangeBorderRadiusUnit }\n\t\t\t\t\t\t\t\tunit={ borderRadiusUnit }\n\t\t\t\t\t\t\t\tunits={ filterUnitsWithSettings(\n\t\t\t\t\t\t\t\t\t[ 'px', 'em', 'rem' ],\n\t\t\t\t\t\t\t\t\tCSS_UNITS\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t<WidthPanel\n\t\t\t\t\t\t\tselectedWidth={ width }\n\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<PanelBody title={ __( 'Link Settings' ) }>\n\t\t\t\t\t\t\t{ getLinkSettings( true ) }\n\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t</InspectorControls>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</View>\n\t);\n}\n\nexport default ButtonEdit;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/button/edit.native.js"],"names":["MIN_BORDER_RADIUS_VALUE","MAX_BORDER_RADIUS_VALUE","INITIAL_MAX_WIDTH","MIN_WIDTH","MIN_WIDTH_MARGINS","styles","button75","marginLeft","button50","button25","WidthPanel","selectedWidth","setAttributes","handleChange","newWidth","width","undefined","options","value","label","ButtonEdit","props","isSelected","parentWidth","initialBorderRadius","attributes","style","border","radius","valueUnit","editorSidebarOpened","numOfButtons","select","isEditorSidebarOpened","editPostStore","getBlockCount","getBlockRootClientId","blockEditorStore","parentId","clientId","blockCount","currentIsEditorSidebarOpened","closeGeneralSidebar","maxWidth","setMaxWidth","isLinkSheetVisible","setIsLinkSheetVisible","isButtonFocused","setIsButtonFocused","placeholderTextWidth","setPlaceholderTextWidth","borderRadiusUnit","setBorderRadiusUnit","richTextRef","colors","gradients","onToggleButtonFocus","onSetMaxWidth","Platform","OS","current","blur","AccessibilityInfo","isScreenReaderEnabled","then","enabled","focus","linkSettingsActions","onPress","onClearSettings","linkSettingsOptions","url","placeholder","autoFocus","autoFill","openInNewTab","linkRel","noFocusLinkSettingOptions","getBackgroundColor","backgroundColor","gradient","gradientValue","colorProps","colorObject","color","background","defaultButton","getTextColor","textColor","onChangeText","text","onChangeBorderRadius","newRadius","newStyle","getNewStyle","onChangeBorderRadiusUnit","newRadiusUnit","newBorderRadius","getBorderRadiusValue","radiusUnit","onShowLinkSettings","onHideLinkSettings","rel","linkTarget","onLayout","nativeEvent","layout","isParentWidthDidChange","marginRight","spacing","isParentWidthChanged","isWidthChanged","onRemove","onDeleteBlock","onReplace","onPlaceholderTextWidth","textWidth","lines","Math","min","onSetRef","ref","onUnstableOnFocus","onBlur","dismissSheet","getLinkSettings","isCompatibleWithSettings","getPlaceholderWidth","placeholderText","currentBorderRadius","defaultBorderRadius","valueAndUnit","Number","isInteger","parseInt","valueToConvert","parseFloat","mergeBlocks","buttonStyle","align","paddingTop","borderWidth","borderRadiusValue","borderRadius","buttonBorderRadiusValue","floor","outlineBorderRadius","minWidth","isFixedWidth","outLineStyles","outline","borderColor","textStyles","richTextStyle","richText","paddingLeft","paddingRight","placeholderTextColor","fontSize","link","CSS_UNITS"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AASA;;AAYA;;AACA;;AAKA;;AACA;;AACA;;;;AAEA,MAAMA,uBAAuB,GAAG,CAAhC;AACA,MAAMC,uBAAuB,GAAG,EAAhC;AACA,MAAMC,iBAAiB,GAAG,GAA1B;AACA,MAAMC,SAAS,GAAG,EAAlB,C,CACA;;AACA,MAAMC,iBAAiB,GAAG;AACzB,OAAK,CADoB;AAEzB,wBAAIC,gBAAOC,QAAX,mDAAI,eAAiBC,UAFI;AAGzB,yBAAIF,gBAAOG,QAAX,oDAAI,gBAAiBD,UAHI;AAIzB,yBAAIF,gBAAOI,QAAX,oDAAI,gBAAiBF;AAJI,CAA1B;;AAOA,SAASG,UAAT,OA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,KAAK,CAAEoI;AAxBnB,IARD,CAFD,EAsCGxI,UAAU,IACX,qDACC,4BAAC,0BAAD,QACC,4BAAC,wBAAD,QACC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,WAAJ,CADT;AAEC,IAAA,IAAI,EAAGyI,WAFR;AAGC,IAAA,OAAO,EAAG3D,kBAHX;AAIC,IAAA,QAAQ,EAAG7B;AAJZ,IADD,CADD,CADD,EAWGsD,eAAe,CAAE,KAAF,CAXlB,EAYC,4BAAC,8BAAD,QACC,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAG,cAAI,iBAAJ;AAAnB,KACC,4BAAC,uBAAD;AACC,IAAA,KAAK,EAAG,cAAI,eAAJ,CADT;AAEC,IAAA,GAAG,EAAG7H,uBAFP;AAGC,IAAA,GAAG,EAAGC,uBAHP;AAIC,IAAA,KAAK,EAAG6I,iBAJT;AAKC,IAAA,QAAQ,EAAGnD,oBALZ;AAMC,IAAA,YAAY,EAAGI,wBANhB;AAOC,IAAA,IAAI,EAAG5C,gBAPR;AAQC,IAAA,KAAK,EAAG,yCACP,CAAE,IAAF,EAAQ,IAAR,EAAc,KAAd,CADO,EAEP6G,qBAFO;AART,IADD,CADD,EAgBC,4BAAC,UAAD;AACC,IAAA,aAAa,EAAGjJ,KADjB;AAEC,IAAA,aAAa,EAAGH;AAFjB,IAhBD,EAoBC,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAG,cAAI,eAAJ;AAAnB,KACGiH,eAAe,CAAE,IAAF,CADlB,CApBD,CAZD,CAvCF,CADD;AAgFA;;eAEczG,U","sourcesContent":["/**\n * External dependencies\n */\nimport { View, AccessibilityInfo, Platform, Text } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useState, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tRichText,\n\tInspectorControls,\n\tBlockControls,\n\tstore as blockEditorStore,\n\tgetColorObjectByAttributeValues,\n\tgetGradientValueBySlug,\n\t__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\tToolbarGroup,\n\tToolbarButton,\n\tLinkSettingsNavigation,\n\tUnitControl,\n\tgetValueAndUnit,\n\tBottomSheetSelectControl,\n\tCSS_UNITS,\n\tfilterUnitsWithSettings,\n\tuseMobileGlobalStylesColors,\n} from '@wordpress/components';\nimport { link } from '@wordpress/icons';\nimport { store as editPostStore } from '@wordpress/edit-post';\n\n/**\n * Internal dependencies\n */\nimport richTextStyle from './rich-text.scss';\nimport styles from './editor.scss';\nimport ColorBackground from './color-background';\n\nconst MIN_BORDER_RADIUS_VALUE = 0;\nconst MAX_BORDER_RADIUS_VALUE = 50;\nconst INITIAL_MAX_WIDTH = 108;\nconst MIN_WIDTH = 40;\n// Map of the percentage width to pixel subtraction that make the buttons fit nicely into columns.\nconst MIN_WIDTH_MARGINS = {\n\t100: 0,\n\t75: styles.button75?.marginLeft,\n\t50: styles.button50?.marginLeft,\n\t25: styles.button25?.marginLeft,\n};\n\nfunction WidthPanel( { selectedWidth, setAttributes } ) {\n\tfunction handleChange( newWidth ) {\n\t\t// Check if we are toggling the width off\n\t\tlet width = selectedWidth === newWidth ? undefined : newWidth;\n\t\tif ( newWidth === 'auto' ) {\n\t\t\twidth = undefined;\n\t\t}\n\t\t// Update attributes\n\t\tsetAttributes( { width } );\n\t}\n\n\tconst options = [\n\t\t{ value: 'auto', label: __( 'Auto' ) },\n\t\t{ value: 25, label: '25%' },\n\t\t{ value: 50, label: '50%' },\n\t\t{ value: 75, label: '75%' },\n\t\t{ value: 100, label: '100%' },\n\t];\n\n\tif ( ! selectedWidth ) {\n\t\tselectedWidth = 'auto';\n\t}\n\n\treturn (\n\t\t<PanelBody title={ __( 'Width Settings' ) }>\n\t\t\t<BottomSheetSelectControl\n\t\t\t\tlabel={ __( 'Button width' ) }\n\t\t\t\tvalue={ selectedWidth }\n\t\t\t\tonChange={ handleChange }\n\t\t\t\toptions={ options }\n\t\t\t/>\n\t\t</PanelBody>\n\t);\n}\n\nfunction ButtonEdit( props ) {\n\tconst { isSelected, parentWidth } = props;\n\tconst initialBorderRadius = props?.attributes?.style?.border?.radius;\n\tconst { valueUnit = 'px' } = getValueAndUnit( initialBorderRadius ) || {};\n\n\tconst { editorSidebarOpened, numOfButtons } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isEditorSidebarOpened } = select( editPostStore );\n\t\t\tconst { getBlockCount, getBlockRootClientId } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst parentId = getBlockRootClientId( clientId );\n\t\t\tconst blockCount = getBlockCount( parentId );\n\t\t\tconst currentIsEditorSidebarOpened = isEditorSidebarOpened();\n\n\t\t\treturn {\n\t\t\t\teditorSidebarOpened: isSelected && currentIsEditorSidebarOpened,\n\t\t\t\tnumOfButtons: blockCount,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isSelected ]\n\t);\n\n\tconst { closeGeneralSidebar } = useDispatch( editPostStore );\n\tconst [ maxWidth, setMaxWidth ] = useState( INITIAL_MAX_WIDTH );\n\tconst [ isLinkSheetVisible, setIsLinkSheetVisible ] = useState( false );\n\tconst [ isButtonFocused, setIsButtonFocused ] = useState( true );\n\tconst [ placeholderTextWidth, setPlaceholderTextWidth ] = useState( 0 );\n\tconst [ borderRadiusUnit, setBorderRadiusUnit ] = useState( valueUnit );\n\n\tconst richTextRef = useRef();\n\tconst colors = useMobileGlobalStylesColors();\n\tconst gradients = useMobileGlobalStylesColors( 'gradients' );\n\n\tuseEffect( () => {\n\t\tif ( isSelected ) {\n\t\t\tonToggleButtonFocus( true );\n\t\t}\n\t}, [ isSelected ] );\n\n\tuseEffect( () => {\n\t\tonSetMaxWidth( null, true );\n\t}, [ parentWidth ] );\n\n\tuseEffect( () => {\n\t\t// Blur `RichText` on Android when link settings sheet or button settings sheet is opened,\n\t\t// to avoid flashing caret after closing one of them\n\t\tif ( editorSidebarOpened || isLinkSheetVisible ) {\n\t\t\tif ( Platform.OS === 'android' && richTextRef?.current ) {\n\t\t\t\trichTextRef.current.blur();\n\t\t\t\tonToggleButtonFocus( false );\n\t\t\t}\n\t\t}\n\t}, [ editorSidebarOpened, isLinkSheetVisible ] );\n\n\tuseEffect( () => {\n\t\tif ( richTextRef?.current ) {\n\t\t\tif ( ! isSelected && isButtonFocused ) {\n\t\t\t\tonToggleButtonFocus( false );\n\t\t\t}\n\n\t\t\tif ( isSelected && ! isButtonFocused ) {\n\t\t\t\tAccessibilityInfo.isScreenReaderEnabled().then( ( enabled ) => {\n\t\t\t\t\tif ( enabled ) {\n\t\t\t\t\t\tonToggleButtonFocus( true );\n\t\t\t\t\t\trichTextRef?.current.focus();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}, [ isSelected, isButtonFocused ] );\n\n\tconst linkSettingsActions = [\n\t\t{\n\t\t\tlabel: __( 'Remove link' ),\n\t\t\tonPress: onClearSettings,\n\t\t},\n\t];\n\n\tconst linkSettingsOptions = {\n\t\turl: {\n\t\t\tlabel: __( 'Button Link URL' ),\n\t\t\tplaceholder: __( 'Add URL' ),\n\t\t\tautoFocus: true,\n\t\t\tautoFill: false,\n\t\t},\n\t\topenInNewTab: {\n\t\t\tlabel: __( 'Open in new tab' ),\n\t\t},\n\t\tlinkRel: {\n\t\t\tlabel: __( 'Link Rel' ),\n\t\t\tplaceholder: _x( 'None', 'Link rel attribute value placeholder' ),\n\t\t},\n\t};\n\n\tconst noFocusLinkSettingOptions = {\n\t\t...linkSettingsOptions,\n\t\turl: {\n\t\t\t...linkSettingsOptions.url,\n\t\t\tautoFocus: false,\n\t\t},\n\t};\n\n\tfunction getBackgroundColor() {\n\t\tconst { attributes, style } = props;\n\t\tconst { backgroundColor, gradient } = attributes;\n\n\t\t// Return named gradient value if available.\n\t\tconst gradientValue = getGradientValueBySlug( gradients, gradient );\n\n\t\tif ( gradientValue ) {\n\t\t\treturn gradientValue;\n\t\t}\n\n\t\tconst colorProps = getColorClassesAndStyles( attributes );\n\n\t\t// Retrieve named color object to force inline styles for themes that\n\t\t// do not load their color stylesheets in the editor.\n\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\tcolors,\n\t\t\tbackgroundColor\n\t\t);\n\n\t\treturn (\n\t\t\tcolorObject?.color ||\n\t\t\tcolorProps.style?.backgroundColor ||\n\t\t\tcolorProps.style?.background ||\n\t\t\tstyle?.backgroundColor ||\n\t\t\tstyles.defaultButton.backgroundColor\n\t\t);\n\t}\n\n\tfunction getTextColor() {\n\t\tconst { attributes, style } = props;\n\t\tconst colorProps = getColorClassesAndStyles( attributes );\n\n\t\t// Retrieve named color object to force inline styles for themes that\n\t\t// do not load their color stylesheets in the editor.\n\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\tcolors,\n\t\t\tattributes.textColor\n\t\t);\n\n\t\treturn (\n\t\t\tcolorObject?.color ||\n\t\t\tcolorProps.style?.color ||\n\t\t\tstyle?.color ||\n\t\t\tstyles.defaultButton.color\n\t\t);\n\t}\n\n\tfunction onChangeText( value ) {\n\t\tconst { setAttributes } = props;\n\t\tsetAttributes( { text: value } );\n\t}\n\n\tfunction onChangeBorderRadius( newRadius ) {\n\t\tconst { setAttributes, attributes } = props;\n\t\tconst { style } = attributes;\n\t\tconst newStyle = getNewStyle( style, newRadius, borderRadiusUnit );\n\n\t\tsetAttributes( { style: newStyle } );\n\t}\n\n\tfunction onChangeBorderRadiusUnit( newRadiusUnit ) {\n\t\tconst { setAttributes, attributes } = props;\n\t\tconst { style } = attributes;\n\t\tconst newBorderRadius = getBorderRadiusValue(\n\t\t\tattributes?.style?.border?.radius\n\t\t);\n\t\tconst newStyle = getNewStyle( style, newBorderRadius, newRadiusUnit );\n\t\tsetAttributes( { style: newStyle } );\n\t\tsetBorderRadiusUnit( newRadiusUnit );\n\t}\n\n\tfunction getNewStyle( style, radius, radiusUnit ) {\n\t\treturn {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tradius: `${ radius }${ radiusUnit }`, // Store the value with the unit so that it works as expected.\n\t\t\t},\n\t\t};\n\t}\n\n\tfunction onShowLinkSettings() {\n\t\tsetIsLinkSheetVisible( true );\n\t}\n\n\tfunction onHideLinkSettings() {\n\t\tsetIsLinkSheetVisible( false );\n\t}\n\n\tfunction onToggleButtonFocus( value ) {\n\t\tif ( value !== isButtonFocused ) {\n\t\t\tsetIsButtonFocused( value );\n\t\t}\n\t}\n\n\tfunction onClearSettings() {\n\t\tconst { setAttributes } = props;\n\n\t\tsetAttributes( {\n\t\t\turl: '',\n\t\t\trel: '',\n\t\t\tlinkTarget: '',\n\t\t} );\n\n\t\tonHideLinkSettings();\n\t}\n\n\tfunction onLayout( { nativeEvent } ) {\n\t\tconst { width } = nativeEvent.layout;\n\t\tonSetMaxWidth( width );\n\t}\n\n\tconst onSetMaxWidth = useCallback(\n\t\t( width, isParentWidthDidChange = false ) => {\n\t\t\tconst { marginRight: spacing } = styles.defaultButton;\n\n\t\t\tconst isParentWidthChanged = isParentWidthDidChange\n\t\t\t\t? isParentWidthDidChange\n\t\t\t\t: maxWidth !== parentWidth;\n\t\t\tconst isWidthChanged = maxWidth !== width;\n\n\t\t\tif ( parentWidth && ! width && isParentWidthChanged ) {\n\t\t\t\tsetMaxWidth( parentWidth - spacing );\n\t\t\t} else if ( ! parentWidth && width && isWidthChanged ) {\n\t\t\t\tsetMaxWidth( width - spacing );\n\t\t\t}\n\t\t},\n\t\t[ maxWidth, parentWidth ]\n\t);\n\n\tfunction onRemove() {\n\t\tconst { onDeleteBlock, onReplace } = props;\n\n\t\tif ( numOfButtons === 1 ) {\n\t\t\tonDeleteBlock();\n\t\t} else {\n\t\t\tonReplace( [] );\n\t\t}\n\t}\n\n\tfunction onPlaceholderTextWidth( { nativeEvent } ) {\n\t\tconst textWidth =\n\t\t\tnativeEvent.lines[ 0 ] && nativeEvent.lines[ 0 ].width;\n\n\t\tif ( textWidth && textWidth !== placeholderTextWidth ) {\n\t\t\tsetPlaceholderTextWidth( Math.min( textWidth, maxWidth ) );\n\t\t}\n\t}\n\n\tconst onSetRef = useCallback(\n\t\t( ref ) => {\n\t\t\trichTextRef.current = ref;\n\t\t},\n\t\t[ richTextRef ]\n\t);\n\n\tconst onUnstableOnFocus = useCallback( () => {\n\t\tonToggleButtonFocus( true );\n\t}, [] );\n\n\tconst onBlur = useCallback( () => {\n\t\tonSetMaxWidth();\n\t}, [] );\n\n\tfunction dismissSheet() {\n\t\tonHideLinkSettings();\n\t\tcloseGeneralSidebar();\n\t}\n\n\tfunction getLinkSettings( isCompatibleWithSettings ) {\n\t\tconst { attributes, setAttributes } = props;\n\t\treturn (\n\t\t\t<LinkSettingsNavigation\n\t\t\t\tisVisible={ isLinkSheetVisible }\n\t\t\t\turl={ attributes.url }\n\t\t\t\trel={ attributes.rel }\n\t\t\t\tlinkTarget={ attributes.linkTarget }\n\t\t\t\tonClose={ dismissSheet }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\twithBottomSheet={ ! isCompatibleWithSettings }\n\t\t\t\thasPicker\n\t\t\t\tactions={ linkSettingsActions }\n\t\t\t\toptions={\n\t\t\t\t\tisCompatibleWithSettings\n\t\t\t\t\t\t? linkSettingsOptions\n\t\t\t\t\t\t: noFocusLinkSettingOptions\n\t\t\t\t}\n\t\t\t\tshowIcon={ ! isCompatibleWithSettings }\n\t\t\t/>\n\t\t);\n\t}\n\n\t// Render `Text` with `placeholderText` styled as a placeholder\n\t// to calculate its width which then is set as a `minWidth`\n\tfunction getPlaceholderWidth( placeholderText ) {\n\t\treturn (\n\t\t\t<Text\n\t\t\t\tstyle={ styles.placeholder }\n\t\t\t\tonTextLayout={ onPlaceholderTextWidth }\n\t\t\t>\n\t\t\t\t{ placeholderText }\n\t\t\t</Text>\n\t\t);\n\t}\n\n\tfunction getBorderRadiusValue( currentBorderRadius, defaultBorderRadius ) {\n\t\tconst valueAndUnit = getValueAndUnit( currentBorderRadius );\n\t\tif ( Number.isInteger( parseInt( valueAndUnit?.valueToConvert ) ) ) {\n\t\t\treturn parseFloat( valueAndUnit.valueToConvert );\n\t\t}\n\t\treturn defaultBorderRadius;\n\t}\n\n\tconst {\n\t\tattributes,\n\t\tclientId,\n\t\tonReplace,\n\t\tmergeBlocks,\n\t\tsetAttributes,\n\t\tstyle,\n\t} = props;\n\tconst {\n\t\tplaceholder,\n\t\ttext,\n\t\tstyle: buttonStyle,\n\t\turl,\n\t\talign = 'center',\n\t\twidth,\n\t} = attributes;\n\tconst { paddingTop: spacing, borderWidth } = styles.defaultButton;\n\n\tif ( parentWidth === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst currentBorderRadius = buttonStyle?.border?.radius;\n\tconst borderRadiusValue = getBorderRadiusValue(\n\t\tcurrentBorderRadius,\n\t\tstyles.defaultButton.borderRadius\n\t);\n\n\tconst buttonBorderRadiusValue =\n\t\tborderRadiusUnit === 'px' || borderRadiusUnit === '%'\n\t\t\t? borderRadiusValue\n\t\t\t: Math.floor( 14 * borderRadiusValue ); // lets assume that the font size is set to 14px; TO get a nicer preview.\n\tconst outlineBorderRadius =\n\t\tbuttonBorderRadiusValue > 0\n\t\t\t? buttonBorderRadiusValue + spacing + borderWidth\n\t\t\t: 0;\n\n\t// To achieve proper expanding and shrinking `RichText` on iOS, there is a need to set a `minWidth`\n\t// value at least on 1 when `RichText` is focused or when is not focused, but `RichText` value is\n\t// different than empty string.\n\tlet minWidth =\n\t\tisButtonFocused || ( ! isButtonFocused && text && text !== '' )\n\t\t\t? MIN_WIDTH\n\t\t\t: placeholderTextWidth;\n\tif ( width ) {\n\t\t// Set the width of the button.\n\t\tminWidth = Math.floor(\n\t\t\tmaxWidth * ( width / 100 ) - MIN_WIDTH_MARGINS[ width ]\n\t\t);\n\t}\n\t// To achieve proper expanding and shrinking `RichText` on Android, there is a need to set\n\t// a `placeholder` as an empty string when `RichText` is focused,\n\t// because `AztecView` is calculating a `minWidth` based on placeholder text.\n\tconst placeholderText =\n\t\tisButtonFocused || ( ! isButtonFocused && text && text !== '' )\n\t\t\t? ''\n\t\t\t: placeholder || __( 'Add text…' );\n\n\tconst backgroundColor = getBackgroundColor();\n\tconst textColor = getTextColor();\n\tconst isFixedWidth = !! width;\n\tconst outLineStyles = [\n\t\tstyles.outline,\n\t\t{\n\t\t\tborderRadius: outlineBorderRadius,\n\t\t\tborderColor: backgroundColor,\n\t\t},\n\t];\n\tconst textStyles = {\n\t\t...richTextStyle.richText,\n\t\tpaddingLeft: isFixedWidth ? 0 : richTextStyle.richText.paddingLeft,\n\t\tpaddingRight: isFixedWidth ? 0 : richTextStyle.richText.paddingRight,\n\t\tcolor: textColor,\n\t};\n\n\treturn (\n\t\t<View onLayout={ onLayout }>\n\t\t\t{ getPlaceholderWidth( placeholderText ) }\n\t\t\t<ColorBackground\n\t\t\t\tborderRadiusValue={ buttonBorderRadiusValue }\n\t\t\t\tbackgroundColor={ backgroundColor }\n\t\t\t\tisSelected={ isSelected }\n\t\t\t>\n\t\t\t\t{ isSelected && (\n\t\t\t\t\t<View pointerEvents=\"none\" style={ outLineStyles } />\n\t\t\t\t) }\n\t\t\t\t<RichText\n\t\t\t\t\tsetRef={ onSetRef }\n\t\t\t\t\tplaceholder={ placeholderText }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tonChange={ onChangeText }\n\t\t\t\t\tstyle={ textStyles }\n\t\t\t\t\ttextAlign={ align }\n\t\t\t\t\tplaceholderTextColor={\n\t\t\t\t\t\tstyle?.color || styles.placeholderTextColor.color\n\t\t\t\t\t}\n\t\t\t\t\tidentifier=\"text\"\n\t\t\t\t\ttagName=\"p\"\n\t\t\t\t\tminWidth={ minWidth } // The minimum Button size.\n\t\t\t\t\tmaxWidth={ isFixedWidth ? minWidth : maxWidth } // The width of the screen.\n\t\t\t\t\tid={ clientId }\n\t\t\t\t\tisSelected={ isButtonFocused }\n\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\tunstableOnFocus={ onUnstableOnFocus }\n\t\t\t\t\t__unstableMobileNoFocusOnMount={ ! isSelected }\n\t\t\t\t\tselectionColor={ textColor }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\tfontSize={ style?.fontSize }\n\t\t\t\t/>\n\t\t\t</ColorBackground>\n\n\t\t\t{ isSelected && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\ttitle={ __( 'Edit link' ) }\n\t\t\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\t\t\tonClick={ onShowLinkSettings }\n\t\t\t\t\t\t\t\tisActive={ url }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t{ getLinkSettings( false ) }\n\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t<PanelBody title={ __( 'Border Settings' ) }>\n\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Border Radius' ) }\n\t\t\t\t\t\t\t\tmin={ MIN_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\t\t\tmax={ MAX_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\t\t\tvalue={ borderRadiusValue }\n\t\t\t\t\t\t\t\tonChange={ onChangeBorderRadius }\n\t\t\t\t\t\t\t\tonUnitChange={ onChangeBorderRadiusUnit }\n\t\t\t\t\t\t\t\tunit={ borderRadiusUnit }\n\t\t\t\t\t\t\t\tunits={ filterUnitsWithSettings(\n\t\t\t\t\t\t\t\t\t[ 'px', 'em', 'rem' ],\n\t\t\t\t\t\t\t\t\tCSS_UNITS\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t<WidthPanel\n\t\t\t\t\t\t\tselectedWidth={ width }\n\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<PanelBody title={ __( 'Link Settings' ) }>\n\t\t\t\t\t\t\t{ getLinkSettings( true ) }\n\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t</InspectorControls>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</View>\n\t);\n}\n\nexport default ButtonEdit;\n"]}
@@ -73,6 +73,18 @@ const metadata = {
73
73
  type: "flex",
74
74
  flexWrap: "nowrap"
75
75
  }
76
+ },
77
+ __experimentalBorder: {
78
+ color: true,
79
+ radius: true,
80
+ style: true,
81
+ width: true,
82
+ __experimentalDefaultControls: {
83
+ color: true,
84
+ radius: true,
85
+ style: true,
86
+ width: true
87
+ }
76
88
  }
77
89
  },
78
90
  editorStyle: "wp-block-columns-editor",
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/columns/index.js"],"names":["name","metadata","settings","icon","variations","example","viewportWidth","innerBlocks","attributes","content","url","deprecated","edit","save","transforms"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAEA;;AACA;;AACA;;AAdA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,cADuB;AAEvBC,EAAAA,UAAU,EAAVA,mBAFuB;AAGvBC,EAAAA,OAAO,EAAE;AACRC,IAAAA,aAAa,EAAE,GADP;AACY;AACpBC,IAAAA,WAAW,EAAE,CACZ;AACCP,MAAAA,IAAI,EAAE,aADP;AAECO,MAAAA,WAAW,EAAE,CACZ;AACCP,QAAAA,IAAI,EAAE,gBADP;AAECQ,QAAAA,UAAU,EAAE;AACX;AACAC,UAAAA,OAAO,EAAE,cACR,qFADQ;AAFE;AAFb,OADY,EAUZ;AACCT,QAAAA,IAAI,EAAE,YADP;AAECQ,QAAAA,UAAU,EAAE;AACXE,UAAAA,GAAG,EACF;AAFU;AAFb,OAVY,EAiBZ;AACCV,QAAAA,IAAI,EAAE,gBADP;AAECQ,QAAAA,UAAU,EAAE;AACX;AACAC,UAAAA,OAAO,EAAE,cACR,6DADQ;AAFE;AAFb,OAjBY;AAFd,KADY,EA+BZ;AACCT,MAAAA,IAAI,EAAE,aADP;AAECO,MAAAA,WAAW,EAAE,CACZ;AACCP,QAAAA,IAAI,EAAE,gBADP;AAECQ,QAAAA,UAAU,EAAE;AACX;AACAC,UAAAA,OAAO,EAAE,cACR,+JADQ;AAFE;AAFb,OADY,EAUZ;AACCT,QAAAA,IAAI,EAAE,gBADP;AAECQ,QAAAA,UAAU,EAAE;AACX;AACAC,UAAAA,OAAO,EAAE,cACR,yGADQ;AAFE;AAFb,OAVY;AAFd,KA/BY;AAFL,GAHc;AA6DvBE,EAAAA,UAAU,EAAVA,mBA7DuB;AA8DvBC,EAAAA,IAAI,EAAJA,aA9DuB;AA+DvBC,EAAAA,IAAI,EAAJA,aA/DuB;AAgEvBC,EAAAA,UAAU,EAAVA;AAhEuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { columns as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport variations from './variations';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tvariations,\n\texample: {\n\t\tviewportWidth: 600, // Columns collapse \"@media (max-width: 599px)\".\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/column',\n\t\t\t\tinnerBlocks: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t/* translators: example text. */\n\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent et eros eu felis.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/image',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\turl:\n\t\t\t\t\t\t\t\t'https://s.w.org/images/core/5.3/Windbuchencom.jpg',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t/* translators: example text. */\n\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t'Suspendisse commodo neque lacus, a dictum orci interdum et.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/column',\n\t\t\t\tinnerBlocks: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t/* translators: example text. */\n\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t'Etiam et egestas lorem. Vivamus sagittis sit amet dolor quis lobortis. Integer sed fermentum arcu, id vulputate lacus. Etiam fermentum sem eu quam hendrerit.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t/* translators: example text. */\n\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t'Nam risus massa, ullamcorper consectetur eros fermentum, porta aliquet ligula. Sed vel mauris nec enim.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t},\n\tdeprecated,\n\tedit,\n\tsave,\n\ttransforms,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/columns/index.js"],"names":["name","metadata","settings","icon","variations","example","viewportWidth","innerBlocks","attributes","content","url","deprecated","edit","save","transforms"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAEA;;AACA;;AACA;;AAdA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,cADuB;AAEvBC,EAAAA,UAAU,EAAVA,mBAFuB;AAGvBC,EAAAA,OAAO,EAAE;AACRC,IAAAA,aAAa,EAAE,GADP;AACY;AACpBC,IAAAA,WAAW,EAAE,CACZ;AACCP,MAAAA,IAAI,EAAE,aADP;AAECO,MAAAA,WAAW,EAAE,CACZ;AACCP,QAAAA,IAAI,EAAE,gBADP;AAECQ,QAAAA,UAAU,EAAE;AACX;AACAC,UAAAA,OAAO,EAAE,cACR,qFADQ;AAFE;AAFb,OADY,EAUZ;AACCT,QAAAA,IAAI,EAAE,YADP;AAECQ,QAAAA,UAAU,EAAE;AACXE,UAAAA,GAAG,EACF;AAFU;AAFb,OAVY,EAiBZ;AACCV,QAAAA,IAAI,EAAE,gBADP;AAECQ,QAAAA,UAAU,EAAE;AACX;AACAC,UAAAA,OAAO,EAAE,cACR,6DADQ;AAFE;AAFb,OAjBY;AAFd,KADY,EA+BZ;AACCT,MAAAA,IAAI,EAAE,aADP;AAECO,MAAAA,WAAW,EAAE,CACZ;AACCP,QAAAA,IAAI,EAAE,gBADP;AAECQ,QAAAA,UAAU,EAAE;AACX;AACAC,UAAAA,OAAO,EAAE,cACR,+JADQ;AAFE;AAFb,OADY,EAUZ;AACCT,QAAAA,IAAI,EAAE,gBADP;AAECQ,QAAAA,UAAU,EAAE;AACX;AACAC,UAAAA,OAAO,EAAE,cACR,yGADQ;AAFE;AAFb,OAVY;AAFd,KA/BY;AAFL,GAHc;AA6DvBE,EAAAA,UAAU,EAAVA,mBA7DuB;AA8DvBC,EAAAA,IAAI,EAAJA,aA9DuB;AA+DvBC,EAAAA,IAAI,EAAJA,aA/DuB;AAgEvBC,EAAAA,UAAU,EAAVA;AAhEuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { columns as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport variations from './variations';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tvariations,\n\texample: {\n\t\tviewportWidth: 600, // Columns collapse \"@media (max-width: 599px)\".\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/column',\n\t\t\t\tinnerBlocks: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t/* translators: example text. */\n\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent et eros eu felis.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/image',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\turl:\n\t\t\t\t\t\t\t\t'https://s.w.org/images/core/5.3/Windbuchencom.jpg',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t/* translators: example text. */\n\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t'Suspendisse commodo neque lacus, a dictum orci interdum et.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/column',\n\t\t\t\tinnerBlocks: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t/* translators: example text. */\n\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t'Etiam et egestas lorem. Vivamus sagittis sit amet dolor quis lobortis. Integer sed fermentum arcu, id vulputate lacus. Etiam fermentum sem eu quam hendrerit.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'core/paragraph',\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t/* translators: example text. */\n\t\t\t\t\t\t\tcontent: __(\n\t\t\t\t\t\t\t\t'Nam risus massa, ullamcorper consectetur eros fermentum, porta aliquet ligula. Sed vel mauris nec enim.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t},\n\tdeprecated,\n\tedit,\n\tsave,\n\ttransforms,\n};\n"]}
@@ -17,6 +17,8 @@ var _components = require("@wordpress/components");
17
17
 
18
18
  var _coreData = require("@wordpress/core-data");
19
19
 
20
+ var _data = require("@wordpress/data");
21
+
20
22
  var _i18n = require("@wordpress/i18n");
21
23
 
22
24
  /**
@@ -44,6 +46,17 @@ function Edit(_ref) {
44
46
  const blockProps = (0, _blockEditor.useBlockProps)();
45
47
  const spacingProps = (0, _blockEditor.__experimentalGetSpacingClassesAndStyles)(attributes);
46
48
  const maxSizeBuffer = Math.floor(maxSize * 2.5);
49
+ const {
50
+ avatarURL
51
+ } = (0, _data.useSelect)(select => {
52
+ const {
53
+ getSettings
54
+ } = select(_blockEditor.store);
55
+ const {
56
+ __experimentalDiscussionSettings
57
+ } = getSettings();
58
+ return __experimentalDiscussionSettings;
59
+ });
47
60
  const inspectorControls = (0, _element.createElement)(_blockEditor.InspectorControls, null, (0, _element.createElement)(_components.PanelBody, {
48
61
  title: (0, _i18n.__)('Avatar Settings')
49
62
  }, (0, _element.createElement)(_components.RangeControl, {
@@ -57,7 +70,7 @@ function Edit(_ref) {
57
70
  initialPosition: width,
58
71
  value: width
59
72
  })));
60
- const displayAvatar = avatarUrls ? (0, _element.createElement)(_components.ResizableBox, {
73
+ const resizableAvatar = (0, _element.createElement)(_components.ResizableBox, {
61
74
  size: {
62
75
  width,
63
76
  height
@@ -79,9 +92,9 @@ function Edit(_ref) {
79
92
  minWidth: minSize,
80
93
  maxWidth: maxSizeBuffer
81
94
  }, (0, _element.createElement)("img", (0, _extends2.default)({
82
- src: avatarUrls[avatarUrls.length - 1],
95
+ src: avatarUrls ? avatarUrls[avatarUrls.length - 1] : avatarURL,
83
96
  alt: `${authorName} ${(0, _i18n.__)('Avatar')}`
84
- }, blockProps))) : (0, _element.createElement)("p", blockProps, (0, _i18n._x)('Comment Author Avatar', 'block title'));
85
- return (0, _element.createElement)(_element.Fragment, null, inspectorControls, (0, _element.createElement)("div", spacingProps, displayAvatar));
97
+ }, blockProps)));
98
+ return (0, _element.createElement)(_element.Fragment, null, inspectorControls, (0, _element.createElement)("div", spacingProps, resizableAvatar));
86
99
  }
87
100
  //# sourceMappingURL=edit.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comment-author-avatar/edit.js"],"names":["Edit","attributes","context","commentId","setAttributes","isSelected","height","width","avatars","authorName","avatarUrls","Object","values","sizes","keys","minSize","maxSize","length","blockProps","spacingProps","maxSizeBuffer","Math","floor","inspectorControls","newWidth","displayAvatar","event","direction","elt","delta","parseInt","top","right","bottom","left"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;AAUe,SAASA,IAAT,O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ress dependencies\n */\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\t__experimentalGetSpacingClassesAndStyles as useSpacingProps,\n} from '@wordpress/block-editor';\nimport { PanelBody, ResizableBox, RangeControl } from '@wordpress/components';\nimport { useEntityProp } from '@wordpress/core-data';\nimport { __, _x, isRTL } from '@wordpress/i18n';\n\nexport default function Edit( {\n\tattributes,\n\tcontext: { commentId },\n\tsetAttributes,\n\tisSelected,\n} ) {\n\tconst { height, width } = attributes;\n\n\tconst [ avatars ] = useEntityProp(\n\t\t'root',\n\t\t'comment',\n\t\t'author_avatar_urls',\n\t\tcommentId\n\t);\n\n\tconst [ authorName ] = useEntityProp(\n\t\t'root',\n\t\t'comment',\n\t\t'author_name',\n\t\tcommentId\n\t);\n\tconst avatarUrls = avatars ? Object.values( avatars ) : null;\n\tconst sizes = avatars ? Object.keys( avatars ) : null;\n\tconst minSize = sizes ? sizes[ 0 ] : 24;\n\tconst maxSize = sizes ? sizes[ sizes.length - 1 ] : 96;\n\tconst blockProps = useBlockProps();\n\tconst spacingProps = useSpacingProps( attributes );\n\tconst maxSizeBuffer = Math.floor( maxSize * 2.5 );\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Avatar Settings' ) }>\n\t\t\t\t<RangeControl\n\t\t\t\t\tlabel={ __( 'Image size' ) }\n\t\t\t\t\tonChange={ ( newWidth ) =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\twidth: newWidth,\n\t\t\t\t\t\t\theight: newWidth,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tmin={ minSize }\n\t\t\t\t\tmax={ maxSizeBuffer }\n\t\t\t\t\tinitialPosition={ width }\n\t\t\t\t\tvalue={ width }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\tconst displayAvatar = avatarUrls ? (\n\t\t<ResizableBox\n\t\t\tsize={ {\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t} }\n\t\t\tshowHandle={ isSelected }\n\t\t\tonResizeStop={ ( event, direction, elt, delta ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\theight: parseInt( height + delta.height, 10 ),\n\t\t\t\t\twidth: parseInt( width + delta.width, 10 ),\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tlockAspectRatio\n\t\t\tenable={ {\n\t\t\t\ttop: false,\n\t\t\t\tright: ! isRTL(),\n\t\t\t\tbottom: true,\n\t\t\t\tleft: isRTL(),\n\t\t\t} }\n\t\t\tminWidth={ minSize }\n\t\t\tmaxWidth={ maxSizeBuffer }\n\t\t>\n\t\t\t<img\n\t\t\t\tsrc={ avatarUrls[ avatarUrls.length - 1 ] }\n\t\t\t\talt={ `${ authorName } ${ __( 'Avatar' ) }` }\n\t\t\t\t{ ...blockProps }\n\t\t\t/>\n\t\t</ResizableBox>\n\t) : (\n\t\t<p { ...blockProps }>\n\t\t\t{ _x( 'Comment Author Avatar', 'block title' ) }\n\t\t</p>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ inspectorControls }\n\t\t\t<div { ...spacingProps }>{ displayAvatar }</div>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comment-author-avatar/edit.js"],"names":["Edit","attributes","context","commentId","setAttributes","isSelected","height","width","avatars","authorName","avatarUrls","Object","values","sizes","keys","minSize","maxSize","length","blockProps","spacingProps","maxSizeBuffer","Math","floor","avatarURL","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","inspectorControls","newWidth","resizableAvatar","event","direction","elt","delta","parseInt","top","right","bottom","left"],"mappings":";;;;;;;;;;;;;AAGA;;AAMA;;AACA;;AACA;;AACA;;AAZA;AACA;AACA;AAYe,SAASA,IAAT,OAKX;AAAA,MAL0B;AAC7BC,IAAAA,UAD6B;AAE7BC,IAAAA,OAAO,EAAE;AAAEC,MAAAA;AAAF,KAFoB;AAG7BC,IAAAA,aAH6B;AAI7BC,IAAAA;AA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ADD;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\t__experimentalGetSpacingClassesAndStyles as useSpacingProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { PanelBody, ResizableBox, RangeControl } from '@wordpress/components';\nimport { useEntityProp } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { __, isRTL } from '@wordpress/i18n';\n\nexport default function Edit( {\n\tattributes,\n\tcontext: { commentId },\n\tsetAttributes,\n\tisSelected,\n} ) {\n\tconst { height, width } = attributes;\n\n\tconst [ avatars ] = useEntityProp(\n\t\t'root',\n\t\t'comment',\n\t\t'author_avatar_urls',\n\t\tcommentId\n\t);\n\n\tconst [ authorName ] = useEntityProp(\n\t\t'root',\n\t\t'comment',\n\t\t'author_name',\n\t\tcommentId\n\t);\n\tconst avatarUrls = avatars ? Object.values( avatars ) : null;\n\tconst sizes = avatars ? Object.keys( avatars ) : null;\n\tconst minSize = sizes ? sizes[ 0 ] : 24;\n\tconst maxSize = sizes ? sizes[ sizes.length - 1 ] : 96;\n\tconst blockProps = useBlockProps();\n\tconst spacingProps = useSpacingProps( attributes );\n\tconst maxSizeBuffer = Math.floor( maxSize * 2.5 );\n\tconst { avatarURL } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\treturn __experimentalDiscussionSettings;\n\t} );\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Avatar Settings' ) }>\n\t\t\t\t<RangeControl\n\t\t\t\t\tlabel={ __( 'Image size' ) }\n\t\t\t\t\tonChange={ ( newWidth ) =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\twidth: newWidth,\n\t\t\t\t\t\t\theight: newWidth,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tmin={ minSize }\n\t\t\t\t\tmax={ maxSizeBuffer }\n\t\t\t\t\tinitialPosition={ width }\n\t\t\t\t\tvalue={ width }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\tconst resizableAvatar = (\n\t\t<ResizableBox\n\t\t\tsize={ {\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t} }\n\t\t\tshowHandle={ isSelected }\n\t\t\tonResizeStop={ ( event, direction, elt, delta ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\theight: parseInt( height + delta.height, 10 ),\n\t\t\t\t\twidth: parseInt( width + delta.width, 10 ),\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tlockAspectRatio\n\t\t\tenable={ {\n\t\t\t\ttop: false,\n\t\t\t\tright: ! isRTL(),\n\t\t\t\tbottom: true,\n\t\t\t\tleft: isRTL(),\n\t\t\t} }\n\t\t\tminWidth={ minSize }\n\t\t\tmaxWidth={ maxSizeBuffer }\n\t\t>\n\t\t\t<img\n\t\t\t\tsrc={\n\t\t\t\t\tavatarUrls ? avatarUrls[ avatarUrls.length - 1 ] : avatarURL\n\t\t\t\t}\n\t\t\t\talt={ `${ authorName } ${ __( 'Avatar' ) }` }\n\t\t\t\t{ ...blockProps }\n\t\t\t/>\n\t\t</ResizableBox>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ inspectorControls }\n\t\t\t<div { ...spacingProps }>{ resizableAvatar }</div>\n\t\t</>\n\t);\n}\n"]}
@@ -21,7 +21,7 @@ var _components = require("@wordpress/components");
21
21
 
22
22
  var _coreData = require("@wordpress/core-data");
23
23
 
24
- var _util = require("./util");
24
+ var _hooks = require("./hooks");
25
25
 
26
26
  /**
27
27
  * WordPress dependencies
@@ -31,6 +31,59 @@ var _util = require("./util");
31
31
  * Internal dependencies
32
32
  */
33
33
  const TEMPLATE = [['core/comment-author-avatar'], ['core/comment-author-name'], ['core/comment-date'], ['core/comment-content'], ['core/comment-reply-link'], ['core/comment-edit-link']];
34
+ /**
35
+ * Function that returns a comment structure that will be rendered with default placehoders.
36
+ *
37
+ * @param {Object} settings Discussion Settings.
38
+ * @param {number} [settings.perPage] - Comments per page setting or block attribute.
39
+ * @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.
40
+ * @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.
41
+ *
42
+ * @typedef {{id: null, children: EmptyComment[]}} EmptyComment
43
+ * @return {EmptyComment[]} Inner blocks of the Comment Template
44
+ */
45
+
46
+ const getCommentsPlaceholder = _ref => {
47
+ let {
48
+ perPage,
49
+ threadComments,
50
+ threadCommentsDepth
51
+ } = _ref;
52
+ // In case that `threadCommentsDepth` is falsy, we default to a somewhat
53
+ // arbitrary value of 3.
54
+ // In case that the value is set but larger than 3 we truncate it to 3.
55
+ const commentsDepth = Math.min(threadCommentsDepth || 3, 3); // We set a limit in order not to overload the editor of empty comments.
56
+
57
+ const defaultCommentsToShow = perPage <= commentsDepth ? perPage : commentsDepth;
58
+
59
+ if (!threadComments || defaultCommentsToShow === 1) {
60
+ // If displaying threaded comments is disabled, we only show one comment
61
+ return [{
62
+ commentId: null,
63
+ children: []
64
+ }];
65
+ } else if (defaultCommentsToShow === 2) {
66
+ return [{
67
+ commentId: null,
68
+ children: [{
69
+ commentId: null,
70
+ children: []
71
+ }]
72
+ }];
73
+ } // In case that the value is set but larger than 3 we truncate it to 3.
74
+
75
+
76
+ return [{
77
+ commentId: null,
78
+ children: [{
79
+ commentId: null,
80
+ children: [{
81
+ commentId: null,
82
+ children: []
83
+ }]
84
+ }]
85
+ }];
86
+ };
34
87
  /**
35
88
  * Component which renders the inner blocks of the Comment Template.
36
89
  *
@@ -44,7 +97,8 @@ const TEMPLATE = [['core/comment-author-avatar'], ['core/comment-author-name'],
44
97
  * @return {WPElement} Inner blocks of the Comment Template
45
98
  */
46
99
 
47
- function CommentTemplateInnerBlocks(_ref) {
100
+
101
+ function CommentTemplateInnerBlocks(_ref2) {
48
102
  var _comment$children;
49
103
 
50
104
  let {
@@ -53,7 +107,7 @@ function CommentTemplateInnerBlocks(_ref) {
53
107
  setActiveComment,
54
108
  firstComment,
55
109
  blocks
56
- } = _ref;
110
+ } = _ref2;
57
111
  const {
58
112
  children,
59
113
  ...innerBlocksProps
@@ -73,13 +127,13 @@ function CommentTemplateInnerBlocks(_ref) {
73
127
  }) : null);
74
128
  }
75
129
 
76
- const CommentTemplatePreview = _ref2 => {
130
+ const CommentTemplatePreview = _ref3 => {
77
131
  let {
78
132
  blocks,
79
133
  comment,
80
134
  setActiveComment,
81
135
  isHidden
82
- } = _ref2;
136
+ } = _ref3;
83
137
  const blockPreviewProps = (0, _blockEditor.__experimentalUseBlockPreview)({
84
138
  blocks
85
139
  });
@@ -119,16 +173,16 @@ const MemoizedCommentTemplatePreview = (0, _element.memo)(CommentTemplatePreview
119
173
  * @return {WPElement} List of comments.
120
174
  */
121
175
 
122
- const CommentsList = _ref3 => {
176
+ const CommentsList = _ref4 => {
123
177
  let {
124
178
  comments,
125
179
  blockProps,
126
180
  activeComment,
127
181
  setActiveComment,
128
182
  blocks
129
- } = _ref3;
130
- return (0, _element.createElement)("ol", blockProps, comments && comments.map(comment => (0, _element.createElement)(_blockEditor.BlockContextProvider, {
131
- key: comment.commentId,
183
+ } = _ref4;
184
+ return (0, _element.createElement)("ol", blockProps, comments && comments.map((comment, index) => (0, _element.createElement)(_blockEditor.BlockContextProvider, {
185
+ key: comment.commentId || index,
132
186
  value: comment
133
187
  }, (0, _element.createElement)(CommentTemplateInnerBlocks, {
134
188
  comment: comment,
@@ -139,28 +193,37 @@ const CommentsList = _ref3 => {
139
193
  }))));
140
194
  };
141
195
 
142
- function CommentTemplateEdit(_ref4) {
196
+ function CommentTemplateEdit(_ref5) {
143
197
  let {
144
198
  clientId,
145
199
  context: {
146
200
  postId,
147
201
  'comments/perPage': perPage,
148
- 'comments/order': order
202
+ 'comments/order': order,
203
+ 'comments/defaultPage': defaultPage,
204
+ 'comments/inherit': inherit
149
205
  }
150
- } = _ref4;
206
+ } = _ref5;
151
207
  const blockProps = (0, _blockEditor.useBlockProps)();
152
208
  const [activeComment, setActiveComment] = (0, _element.useState)();
153
209
  const {
154
210
  commentOrder,
155
- commentsPerPage
211
+ threadCommentsDepth,
212
+ threadComments
156
213
  } = (0, _data.useSelect)(select => {
157
214
  const {
158
215
  getSettings
159
216
  } = select(_blockEditor.store);
160
217
  return getSettings().__experimentalDiscussionSettings;
161
218
  });
219
+ const commentQuery = (0, _hooks.useCommentQueryArgs)({
220
+ postId,
221
+ perPage,
222
+ defaultPage,
223
+ inherit
224
+ });
162
225
  const {
163
- rawComments,
226
+ topLevelComments,
164
227
  blocks
165
228
  } = (0, _data.useSelect)(select => {
166
229
  const {
@@ -169,40 +232,35 @@ function CommentTemplateEdit(_ref4) {
169
232
  const {
170
233
  getBlocks
171
234
  } = select(_blockEditor.store);
172
- const commentQuery = {
173
- post: postId,
174
- status: 'approve',
175
- context: 'embed',
176
- order: order || commentOrder
177
- };
178
-
179
- if (order) {
180
- commentQuery.order = order;
181
- }
182
-
183
235
  return {
184
- rawComments: getEntityRecords('root', 'comment', commentQuery),
236
+ // Request only top-level comments. Replies are embedded.
237
+ topLevelComments: commentQuery ? getEntityRecords('root', 'comment', commentQuery) : null,
185
238
  blocks: getBlocks(clientId)
186
239
  };
187
- }, [postId, clientId, order]); // TODO: Replicate the logic used on the server.
240
+ }, [clientId, commentQuery]);
241
+ order = inherit || !order ? commentOrder : order; // Generate a tree structure of comment IDs.
188
242
 
189
- perPage = perPage || commentsPerPage; // We convert the flat list of comments to tree.
190
- // Then, we show only a maximum of `perPage` number of comments.
191
- // This is because passing `per_page` to `getEntityRecords()` does not
192
- // take into account nested comments.
243
+ let commentTree = (0, _hooks.useCommentTree)( // Reverse the order of top comments if needed.
244
+ order === 'desc' && topLevelComments ? [...topLevelComments].reverse() : topLevelComments);
193
245
 
194
- const comments = (0, _element.useMemo)(() => (0, _util.convertToTree)(rawComments).slice(0, perPage), [rawComments, perPage]);
195
-
196
- if (!rawComments) {
246
+ if (!topLevelComments) {
197
247
  return (0, _element.createElement)("p", blockProps, (0, _element.createElement)(_components.Spinner, null));
198
248
  }
199
249
 
200
- if (!comments.length) {
250
+ if (!postId) {
251
+ commentTree = getCommentsPlaceholder({
252
+ perPage,
253
+ threadComments,
254
+ threadCommentsDepth
255
+ });
256
+ }
257
+
258
+ if (!commentTree.length) {
201
259
  return (0, _element.createElement)("p", blockProps, " ", (0, _i18n.__)('No results found.'));
202
260
  }
203
261
 
204
262
  return (0, _element.createElement)(CommentsList, {
205
- comments: comments,
263
+ comments: commentTree,
206
264
  blockProps: blockProps,
207
265
  blocks: blocks,
208
266
  activeComment: activeComment,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comment-template/edit.js"],"names":["TEMPLATE","CommentTemplateInnerBlocks","comment","activeComment","setActiveComment","firstComment","blocks","children","innerBlocksProps","template","length","CommentTemplatePreview","isHidden","blockPreviewProps","handleOnClick","style","display","undefined","MemoizedCommentTemplatePreview","CommentsList","comments","blockProps","map","commentId","CommentTemplateEdit","clientId","context","postId","perPage","order","commentOrder","commentsPerPage","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","rawComments","getEntityRecords","coreStore","getBlocks","commentQuery","post","status","slice"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,CAChB,CAAE,4BAAF,CADgB,EAEhB,CAAE,0BAAF,CAFgB,EAGhB,CAAE,mBAAF,CAHgB,EAIhB,CAAE,sBAAF,CAJgB,EAKhB,CAAE,yBAAF,CALgB,EAMhB,CAAE,wBAAF,CANgB,CAAjB;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,0BAAT,OAMI;AAAA;;AAAA,MANiC;AACpCC,IAAAA,OADoC;AAEpCC,IAAAA,aAFoC;AAGpCC,IAAAA,gBAHoC;AAIpCC,IAA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A;;AAED,SACC,4BAAC,YAAD;AACC,IAAA,QAAQ,EAAGD,QADZ;AAEC,IAAA,UAAU,EAAGC,UAFd;AAGC,IAAA,MAAM,EAAGf,MAHV;AAIC,IAAA,aAAa,EAAGH,aAJjB;AAKC,IAAA,gBAAgB,EAAGC;AALpB,IADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useMemo, memo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBlockPreview as useBlockPreview,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { convertToTree } from './util';\n\nconst TEMPLATE = [\n\t[ 'core/comment-author-avatar' ],\n\t[ 'core/comment-author-name' ],\n\t[ 'core/comment-date' ],\n\t[ 'core/comment-content' ],\n\t[ 'core/comment-reply-link' ],\n\t[ 'core/comment-edit-link' ],\n];\n\n/**\n * Component which renders the inner blocks of the Comment Template.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comment] - A comment object.\n * @param {Array} [props.activeComment] - The block that is currently active.\n * @param {Array} [props.setActiveComment] - The setter for activeComment.\n * @param {Array} [props.firstComment] - First comment in the array.\n * @param {Array} [props.blocks] - Array of blocks returned from\n * getBlocks() in parent .\n * @return {WPElement} \t\tInner blocks of the Comment Template\n */\nfunction CommentTemplateInnerBlocks( {\n\tcomment,\n\tactiveComment,\n\tsetActiveComment,\n\tfirstComment,\n\tblocks,\n} ) {\n\tconst { children, ...innerBlocksProps } = useInnerBlocksProps(\n\t\t{},\n\t\t{ template: TEMPLATE }\n\t);\n\treturn (\n\t\t<li { ...innerBlocksProps }>\n\t\t\t{ comment === ( activeComment || firstComment ) ? children : null }\n\n\t\t\t{ /* To avoid flicker when switching active block contexts, a preview\n\t\t\tis ALWAYS rendered and the preview for the active block is hidden. \n\t\t\tThis ensures that when switching the active block, the component is not \n\t\t\tmounted again but rather it only toggles the `isHidden` prop.\n\t\t\t\n\t\t\tThe same strategy is used for preventing the flicker in the Post Template\n\t\t\tblock. */ }\n\t\t\t<MemoizedCommentTemplatePreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tcomment={ comment }\n\t\t\t\tsetActiveComment={ setActiveComment }\n\t\t\t\tisHidden={ comment === ( activeComment || firstComment ) }\n\t\t\t/>\n\n\t\t\t{ comment?.children?.length > 0 ? (\n\t\t\t\t<CommentsList\n\t\t\t\t\tcomments={ comment.children }\n\t\t\t\t\tactiveComment={ activeComment }\n\t\t\t\t\tsetActiveComment={ setActiveComment }\n\t\t\t\t\tblocks={ blocks }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t</li>\n\t);\n}\n\nconst CommentTemplatePreview = ( {\n\tblocks,\n\tcomment,\n\tsetActiveComment,\n\tisHidden,\n} ) => {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveComment( comment );\n\t};\n\n\t// We have to hide the preview block if the `comment` props points to\n\t// the curently active block!\n\n\t// Or, to put it differently, every preview block is visible unless it is the\n\t// currently active block - in this case we render its inner blocks.\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\tstyle={ style }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t/>\n\t);\n};\n\nconst MemoizedCommentTemplatePreview = memo( CommentTemplatePreview );\n\n/**\n * Component that renders a list of (nested) comments. It is called recursively.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comments] - Array of comment objects.\n * @param {Array} [props.blockProps] - Props from parent's `useBlockProps()`.\n * @param {Array} [props.activeComment] - The block that is currently active.\n * @param {Array} [props.setActiveComment] - The setter for activeComment.\n * @param {Array} [props.blocks] - Array of blocks returned from\n * getBlocks() in parent .\n * @return {WPElement} \t\tList of comments.\n */\nconst CommentsList = ( {\n\tcomments,\n\tblockProps,\n\tactiveComment,\n\tsetActiveComment,\n\tblocks,\n} ) => (\n\t<ol { ...blockProps }>\n\t\t{ comments &&\n\t\t\tcomments.map( ( comment ) => (\n\t\t\t\t<BlockContextProvider\n\t\t\t\t\tkey={ comment.commentId }\n\t\t\t\t\tvalue={ comment }\n\t\t\t\t>\n\t\t\t\t\t<CommentTemplateInnerBlocks\n\t\t\t\t\t\tcomment={ comment }\n\t\t\t\t\t\tactiveComment={ activeComment }\n\t\t\t\t\t\tsetActiveComment={ setActiveComment }\n\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\tfirstComment={ comments[ 0 ] }\n\t\t\t\t\t/>\n\t\t\t\t</BlockContextProvider>\n\t\t\t) ) }\n\t</ol>\n);\n\nexport default function CommentTemplateEdit( {\n\tclientId,\n\tcontext: { postId, 'comments/perPage': perPage, 'comments/order': order },\n} ) {\n\tconst blockProps = useBlockProps();\n\n\tconst [ activeComment, setActiveComment ] = useState();\n\tconst { commentOrder, commentsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalDiscussionSettings;\n\t} );\n\tconst { rawComments, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\tconst commentQuery = {\n\t\t\t\tpost: postId,\n\t\t\t\tstatus: 'approve',\n\t\t\t\tcontext: 'embed',\n\t\t\t\torder: order || commentOrder,\n\t\t\t};\n\n\t\t\tif ( order ) {\n\t\t\t\tcommentQuery.order = order;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\trawComments: getEntityRecords(\n\t\t\t\t\t'root',\n\t\t\t\t\t'comment',\n\t\t\t\t\tcommentQuery\n\t\t\t\t),\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ postId, clientId, order ]\n\t);\n\n\t// TODO: Replicate the logic used on the server.\n\tperPage = perPage || commentsPerPage;\n\t// We convert the flat list of comments to tree.\n\t// Then, we show only a maximum of `perPage` number of comments.\n\t// This is because passing `per_page` to `getEntityRecords()` does not\n\t// take into account nested comments.\n\tconst comments = useMemo(\n\t\t() => convertToTree( rawComments ).slice( 0, perPage ),\n\t\t[ rawComments, perPage ]\n\t);\n\n\tif ( ! rawComments ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! comments.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No results found.' ) }</p>;\n\t}\n\n\treturn (\n\t\t<CommentsList\n\t\t\tcomments={ comments }\n\t\t\tblockProps={ blockProps }\n\t\t\tblocks={ blocks }\n\t\t\tactiveComment={ activeComment }\n\t\t\tsetActiveComment={ setActiveComment }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comment-template/edit.js"],"names":["TEMPLATE","getCommentsPlaceholder","perPage","threadComments","threadCommentsDepth","commentsDepth","Math","min","defaultCommentsToShow","commentId","children","CommentTemplateInnerBlocks","comment","activeComment","setActiveComment","firstComment","blocks","innerBlocksProps","template","length","CommentTemplatePreview","isHidden","blockPreviewProps","handleOnClick","style","display","undefined","MemoizedCommentTemplatePreview","CommentsList","comments","blockProps","map","index","CommentTemplateEdit","clientId","context","postId","order","defaultPage","inherit","commentOrder","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","commentQuery","topLevelComments","getEntityRecords","coreStore","getBlocks","commentTree","reverse"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,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P,EAA0B;AACzB,WACC,iCAAQhB,UAAR,EACC,4BAAC,mBAAD,OADD,CADD;AAKA;;AAED,MAAK,CAAEM,MAAP,EAAgB;AACfc,IAAAA,WAAW,GAAGjD,sBAAsB,CAAE;AACrCC,MAAAA,OADqC;AAErCC,MAAAA,cAFqC;AAGrCC,MAAAA;AAHqC,KAAF,CAApC;AAKA;;AAED,MAAK,CAAE8C,WAAW,CAAC/B,MAAnB,EAA4B;AAC3B,WAAO,iCAAQW,UAAR,OAAwB,cAAI,mBAAJ,CAAxB,CAAP;AACA;;AAED,SACC,4BAAC,YAAD;AACC,IAAA,QAAQ,EAAGoB,WADZ;AAEC,IAAA,UAAU,EAAGpB,UAFd;AAGC,IAAA,MAAM,EAAGd,MAHV;AAIC,IAAA,aAAa,EAAGH,aAJjB;AAKC,IAAA,gBAAgB,EAAGC;AALpB,IADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, memo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBlockPreview as useBlockPreview,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCommentQueryArgs, useCommentTree } from './hooks';\n\nconst TEMPLATE = [\n\t[ 'core/comment-author-avatar' ],\n\t[ 'core/comment-author-name' ],\n\t[ 'core/comment-date' ],\n\t[ 'core/comment-content' ],\n\t[ 'core/comment-reply-link' ],\n\t[ 'core/comment-edit-link' ],\n];\n\n/**\n * Function that returns a comment structure that will be rendered with default placehoders.\n *\n * @param {Object} settings Discussion Settings.\n * @param {number} [settings.perPage] - Comments per page setting or block attribute.\n * @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.\n * @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.\n *\n * @typedef {{id: null, children: EmptyComment[]}} EmptyComment\n * @return {EmptyComment[]} \t\tInner blocks of the Comment Template\n */\nconst getCommentsPlaceholder = ( {\n\tperPage,\n\tthreadComments,\n\tthreadCommentsDepth,\n} ) => {\n\t// In case that `threadCommentsDepth` is falsy, we default to a somewhat\n\t// arbitrary value of 3.\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\tconst commentsDepth = Math.min( threadCommentsDepth || 3, 3 );\n\n\t// We set a limit in order not to overload the editor of empty comments.\n\tconst defaultCommentsToShow =\n\t\tperPage <= commentsDepth ? perPage : commentsDepth;\n\tif ( ! threadComments || defaultCommentsToShow === 1 ) {\n\t\t// If displaying threaded comments is disabled, we only show one comment\n\t\treturn [ { commentId: null, children: [] } ];\n\t} else if ( defaultCommentsToShow === 2 ) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tcommentId: null,\n\t\t\t\tchildren: [ { commentId: null, children: [] } ],\n\t\t\t},\n\t\t];\n\t}\n\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\treturn [\n\t\t{\n\t\t\tcommentId: null,\n\t\t\tchildren: [\n\t\t\t\t{\n\t\t\t\t\tcommentId: null,\n\t\t\t\t\tchildren: [ { commentId: null, children: [] } ],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t];\n};\n\n/**\n * Component which renders the inner blocks of the Comment Template.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comment] - A comment object.\n * @param {Array} [props.activeComment] - The block that is currently active.\n * @param {Array} [props.setActiveComment] - The setter for activeComment.\n * @param {Array} [props.firstComment] - First comment in the array.\n * @param {Array} [props.blocks] - Array of blocks returned from\n * getBlocks() in parent .\n * @return {WPElement} \t\tInner blocks of the Comment Template\n */\nfunction CommentTemplateInnerBlocks( {\n\tcomment,\n\tactiveComment,\n\tsetActiveComment,\n\tfirstComment,\n\tblocks,\n} ) {\n\tconst { children, ...innerBlocksProps } = useInnerBlocksProps(\n\t\t{},\n\t\t{ template: TEMPLATE }\n\t);\n\treturn (\n\t\t<li { ...innerBlocksProps }>\n\t\t\t{ comment === ( activeComment || firstComment ) ? children : null }\n\n\t\t\t{ /* To avoid flicker when switching active block contexts, a preview\n\t\t\tis ALWAYS rendered and the preview for the active block is hidden.\n\t\t\tThis ensures that when switching the active block, the component is not\n\t\t\tmounted again but rather it only toggles the `isHidden` prop.\n\n\t\t\tThe same strategy is used for preventing the flicker in the Post Template\n\t\t\tblock. */ }\n\t\t\t<MemoizedCommentTemplatePreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tcomment={ comment }\n\t\t\t\tsetActiveComment={ setActiveComment }\n\t\t\t\tisHidden={ comment === ( activeComment || firstComment ) }\n\t\t\t/>\n\n\t\t\t{ comment?.children?.length > 0 ? (\n\t\t\t\t<CommentsList\n\t\t\t\t\tcomments={ comment.children }\n\t\t\t\t\tactiveComment={ activeComment }\n\t\t\t\t\tsetActiveComment={ setActiveComment }\n\t\t\t\t\tblocks={ blocks }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t</li>\n\t);\n}\n\nconst CommentTemplatePreview = ( {\n\tblocks,\n\tcomment,\n\tsetActiveComment,\n\tisHidden,\n} ) => {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveComment( comment );\n\t};\n\n\t// We have to hide the preview block if the `comment` props points to\n\t// the curently active block!\n\n\t// Or, to put it differently, every preview block is visible unless it is the\n\t// currently active block - in this case we render its inner blocks.\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\tstyle={ style }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t/>\n\t);\n};\n\nconst MemoizedCommentTemplatePreview = memo( CommentTemplatePreview );\n\n/**\n * Component that renders a list of (nested) comments. It is called recursively.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comments] - Array of comment objects.\n * @param {Array} [props.blockProps] - Props from parent's `useBlockProps()`.\n * @param {Array} [props.activeComment] - The block that is currently active.\n * @param {Array} [props.setActiveComment] - The setter for activeComment.\n * @param {Array} [props.blocks] - Array of blocks returned from\n * getBlocks() in parent .\n * @return {WPElement} \t\tList of comments.\n */\nconst CommentsList = ( {\n\tcomments,\n\tblockProps,\n\tactiveComment,\n\tsetActiveComment,\n\tblocks,\n} ) => (\n\t<ol { ...blockProps }>\n\t\t{ comments &&\n\t\t\tcomments.map( ( comment, index ) => (\n\t\t\t\t<BlockContextProvider\n\t\t\t\t\tkey={ comment.commentId || index }\n\t\t\t\t\tvalue={ comment }\n\t\t\t\t>\n\t\t\t\t\t<CommentTemplateInnerBlocks\n\t\t\t\t\t\tcomment={ comment }\n\t\t\t\t\t\tactiveComment={ activeComment }\n\t\t\t\t\t\tsetActiveComment={ setActiveComment }\n\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\tfirstComment={ comments[ 0 ] }\n\t\t\t\t\t/>\n\t\t\t\t</BlockContextProvider>\n\t\t\t) ) }\n\t</ol>\n);\n\nexport default function CommentTemplateEdit( {\n\tclientId,\n\tcontext: {\n\t\tpostId,\n\t\t'comments/perPage': perPage,\n\t\t'comments/order': order,\n\t\t'comments/defaultPage': defaultPage,\n\t\t'comments/inherit': inherit,\n\t},\n} ) {\n\tconst blockProps = useBlockProps();\n\n\tconst [ activeComment, setActiveComment ] = useState();\n\tconst { commentOrder, threadCommentsDepth, threadComments } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn getSettings().__experimentalDiscussionSettings;\n\t\t}\n\t);\n\n\tconst commentQuery = useCommentQueryArgs( {\n\t\tpostId,\n\t\tperPage,\n\t\tdefaultPage,\n\t\tinherit,\n\t} );\n\n\tconst { topLevelComments, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\t// Request only top-level comments. Replies are embedded.\n\t\t\t\ttopLevelComments: commentQuery\n\t\t\t\t\t? getEntityRecords( 'root', 'comment', commentQuery )\n\t\t\t\t\t: null,\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId, commentQuery ]\n\t);\n\n\torder = inherit || ! order ? commentOrder : order;\n\n\t// Generate a tree structure of comment IDs.\n\tlet commentTree = useCommentTree(\n\t\t// Reverse the order of top comments if needed.\n\t\torder === 'desc' && topLevelComments\n\t\t\t? [ ...topLevelComments ].reverse()\n\t\t\t: topLevelComments\n\t);\n\n\tif ( ! topLevelComments ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! postId ) {\n\t\tcommentTree = getCommentsPlaceholder( {\n\t\t\tperPage,\n\t\t\tthreadComments,\n\t\t\tthreadCommentsDepth,\n\t\t} );\n\t}\n\n\tif ( ! commentTree.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No results found.' ) }</p>;\n\t}\n\n\treturn (\n\t\t<CommentsList\n\t\t\tcomments={ commentTree }\n\t\t\tblockProps={ blockProps }\n\t\t\tblocks={ blocks }\n\t\t\tactiveComment={ activeComment }\n\t\t\tsetActiveComment={ setActiveComment }\n\t\t/>\n\t);\n}\n"]}