@wordpress/block-editor 8.0.8 → 8.0.12-next.33ec3857e2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (294) hide show
  1. package/README.md +4 -0
  2. package/build/components/block-caption/index.native.js +14 -3
  3. package/build/components/block-caption/index.native.js.map +1 -1
  4. package/build/components/block-inspector/index.js +12 -23
  5. package/build/components/block-inspector/index.js.map +1 -1
  6. package/build/components/block-list-appender/index.js +3 -11
  7. package/build/components/block-list-appender/index.js.map +1 -1
  8. package/build/components/block-preview/auto.js +10 -2
  9. package/build/components/block-preview/auto.js.map +1 -1
  10. package/build/components/block-preview/index.js +51 -0
  11. package/build/components/block-preview/index.js.map +1 -1
  12. package/build/components/block-settings/container.native.js +2 -1
  13. package/build/components/block-settings/container.native.js.map +1 -1
  14. package/build/components/block-styles/index.js +110 -134
  15. package/build/components/block-styles/index.js.map +1 -1
  16. package/build/components/block-styles/menu-items.js +63 -0
  17. package/build/components/block-styles/menu-items.js.map +1 -0
  18. package/build/components/block-styles/preview-panel.js +45 -0
  19. package/build/components/block-styles/preview-panel.js.map +1 -0
  20. package/build/components/block-styles/use-styles-for-block.js +119 -0
  21. package/build/components/block-styles/use-styles-for-block.js.map +1 -0
  22. package/build/components/block-styles/utils.js +39 -0
  23. package/build/components/block-styles/utils.js.map +1 -1
  24. package/build/components/block-switcher/block-styles-menu.js +3 -23
  25. package/build/components/block-switcher/block-styles-menu.js.map +1 -1
  26. package/build/components/block-tools/back-compat.js +2 -1
  27. package/build/components/block-tools/back-compat.js.map +1 -1
  28. package/build/components/block-tools/insertion-point.js +11 -1
  29. package/build/components/block-tools/insertion-point.js.map +1 -1
  30. package/build/components/button-block-appender/index.js +2 -1
  31. package/build/components/button-block-appender/index.js.map +1 -1
  32. package/build/components/colors-gradients/control.js +1 -0
  33. package/build/components/colors-gradients/control.js.map +1 -1
  34. package/build/components/colors-gradients/panel-color-gradient-settings.js +51 -10
  35. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  36. package/build/components/default-block-appender/index.js +16 -19
  37. package/build/components/default-block-appender/index.js.map +1 -1
  38. package/build/components/default-style-picker/index.js +18 -3
  39. package/build/components/default-style-picker/index.js.map +1 -1
  40. package/build/components/iframe/index.js +3 -4
  41. package/build/components/iframe/index.js.map +1 -1
  42. package/build/components/index.js +17 -10
  43. package/build/components/index.js.map +1 -1
  44. package/build/components/inner-blocks/default-block-appender.js +2 -4
  45. package/build/components/inner-blocks/default-block-appender.js.map +1 -1
  46. package/build/components/inserter/index.native.js +1 -1
  47. package/build/components/inserter/index.native.js.map +1 -1
  48. package/build/components/inserter/tabs.native.js +7 -4
  49. package/build/components/inserter/tabs.native.js.map +1 -1
  50. package/build/components/inspector-controls/block-support-slot-container.js +2 -1
  51. package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
  52. package/build/components/inspector-controls/fill.native.js +3 -5
  53. package/build/components/inspector-controls/fill.native.js.map +1 -1
  54. package/build/components/inspector-controls/groups.js +2 -0
  55. package/build/components/inspector-controls/groups.js.map +1 -1
  56. package/build/components/inspector-controls/slot.js +1 -3
  57. package/build/components/inspector-controls/slot.js.map +1 -1
  58. package/build/components/letter-spacing-control/index.js +6 -6
  59. package/build/components/letter-spacing-control/index.js.map +1 -1
  60. package/build/components/list-view/block-select-button.js +23 -3
  61. package/build/components/list-view/block-select-button.js.map +1 -1
  62. package/build/components/media-placeholder/index.js +2 -0
  63. package/build/components/media-placeholder/index.js.map +1 -1
  64. package/build/components/media-replace-flow/index.js +2 -0
  65. package/build/components/media-replace-flow/index.js.map +1 -1
  66. package/build/components/rich-text/file-paste-handler.js +1 -1
  67. package/build/components/rich-text/file-paste-handler.js.map +1 -1
  68. package/build/components/rich-text/prevent-event-discovery.js +33 -0
  69. package/build/components/rich-text/prevent-event-discovery.js.map +1 -0
  70. package/build/components/rich-text/use-input-rules.js +3 -1
  71. package/build/components/rich-text/use-input-rules.js.map +1 -1
  72. package/build/components/selection-scroll-into-view/index.js +2 -1
  73. package/build/components/selection-scroll-into-view/index.js.map +1 -1
  74. package/build/components/use-display-block-controls/index.native.js +45 -0
  75. package/build/components/use-display-block-controls/index.native.js.map +1 -0
  76. package/build/components/use-on-block-drop/index.js +7 -3
  77. package/build/components/use-on-block-drop/index.js.map +1 -1
  78. package/build/components/writing-flow/use-multi-selection.js +3 -1
  79. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  80. package/build/hooks/border-color.js +63 -5
  81. package/build/hooks/border-color.js.map +1 -1
  82. package/build/hooks/border-radius.js +47 -0
  83. package/build/hooks/border-radius.js.map +1 -1
  84. package/build/hooks/border-style.js +41 -0
  85. package/build/hooks/border-style.js.map +1 -1
  86. package/build/hooks/border-width.js +70 -31
  87. package/build/hooks/border-width.js.map +1 -1
  88. package/build/hooks/border.js +81 -11
  89. package/build/hooks/border.js.map +1 -1
  90. package/build/hooks/letter-spacing.js +1 -1
  91. package/build/hooks/letter-spacing.js.map +1 -1
  92. package/build/hooks/typography.js +1 -1
  93. package/build/hooks/typography.js.map +1 -1
  94. package/build/store/actions.js +1 -2
  95. package/build/store/actions.js.map +1 -1
  96. package/build/store/defaults.js +5 -1
  97. package/build/store/defaults.js.map +1 -1
  98. package/build/store/reducer.js +10 -82
  99. package/build/store/reducer.js.map +1 -1
  100. package/build/store/selectors.js +25 -7
  101. package/build/store/selectors.js.map +1 -1
  102. package/build/utils/get-paste-event-data.js +1 -1
  103. package/build/utils/get-paste-event-data.js.map +1 -1
  104. package/build/utils/parse-css-unit-to-px.js +1 -1
  105. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  106. package/build/utils/transform-styles/index.js +2 -3
  107. package/build/utils/transform-styles/index.js.map +1 -1
  108. package/build-module/components/block-caption/index.native.js +13 -3
  109. package/build-module/components/block-caption/index.native.js.map +1 -1
  110. package/build-module/components/block-inspector/index.js +12 -23
  111. package/build-module/components/block-inspector/index.js.map +1 -1
  112. package/build-module/components/block-list-appender/index.js +3 -10
  113. package/build-module/components/block-list-appender/index.js.map +1 -1
  114. package/build-module/components/block-preview/auto.js +10 -2
  115. package/build-module/components/block-preview/auto.js.map +1 -1
  116. package/build-module/components/block-preview/index.js +46 -0
  117. package/build-module/components/block-preview/index.js.map +1 -1
  118. package/build-module/components/block-settings/container.native.js +2 -1
  119. package/build-module/components/block-settings/container.native.js.map +1 -1
  120. package/build-module/components/block-styles/index.js +112 -133
  121. package/build-module/components/block-styles/index.js.map +1 -1
  122. package/build-module/components/block-styles/menu-items.js +50 -0
  123. package/build-module/components/block-styles/menu-items.js.map +1 -0
  124. package/build-module/components/block-styles/preview-panel.js +35 -0
  125. package/build-module/components/block-styles/preview-panel.js.map +1 -0
  126. package/build-module/components/block-styles/use-styles-for-block.js +107 -0
  127. package/build-module/components/block-styles/use-styles-for-block.js.map +1 -0
  128. package/build-module/components/block-styles/utils.js +34 -0
  129. package/build-module/components/block-styles/utils.js.map +1 -1
  130. package/build-module/components/block-switcher/block-styles-menu.js +3 -21
  131. package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
  132. package/build-module/components/block-tools/back-compat.js +2 -1
  133. package/build-module/components/block-tools/back-compat.js.map +1 -1
  134. package/build-module/components/block-tools/insertion-point.js +11 -1
  135. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  136. package/build-module/components/button-block-appender/index.js +2 -1
  137. package/build-module/components/button-block-appender/index.js.map +1 -1
  138. package/build-module/components/colors-gradients/control.js +1 -0
  139. package/build-module/components/colors-gradients/control.js.map +1 -1
  140. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +54 -13
  141. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  142. package/build-module/components/default-block-appender/index.js +15 -18
  143. package/build-module/components/default-block-appender/index.js.map +1 -1
  144. package/build-module/components/default-style-picker/index.js +17 -3
  145. package/build-module/components/default-style-picker/index.js.map +1 -1
  146. package/build-module/components/iframe/index.js +3 -4
  147. package/build-module/components/iframe/index.js.map +1 -1
  148. package/build-module/components/index.js +2 -2
  149. package/build-module/components/index.js.map +1 -1
  150. package/build-module/components/inner-blocks/default-block-appender.js +2 -4
  151. package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
  152. package/build-module/components/inserter/index.native.js +2 -2
  153. package/build-module/components/inserter/index.native.js.map +1 -1
  154. package/build-module/components/inserter/tabs.native.js +7 -4
  155. package/build-module/components/inserter/tabs.native.js.map +1 -1
  156. package/build-module/components/inspector-controls/block-support-slot-container.js +2 -1
  157. package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
  158. package/build-module/components/inspector-controls/fill.native.js +3 -5
  159. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  160. package/build-module/components/inspector-controls/groups.js +2 -0
  161. package/build-module/components/inspector-controls/groups.js.map +1 -1
  162. package/build-module/components/inspector-controls/slot.js +1 -3
  163. package/build-module/components/inspector-controls/slot.js.map +1 -1
  164. package/build-module/components/letter-spacing-control/index.js +6 -6
  165. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  166. package/build-module/components/list-view/block-select-button.js +22 -3
  167. package/build-module/components/list-view/block-select-button.js.map +1 -1
  168. package/build-module/components/media-placeholder/index.js +2 -0
  169. package/build-module/components/media-placeholder/index.js.map +1 -1
  170. package/build-module/components/media-replace-flow/index.js +2 -0
  171. package/build-module/components/media-replace-flow/index.js.map +1 -1
  172. package/build-module/components/rich-text/file-paste-handler.js +1 -1
  173. package/build-module/components/rich-text/file-paste-handler.js.map +1 -1
  174. package/build-module/components/rich-text/prevent-event-discovery.js +25 -0
  175. package/build-module/components/rich-text/prevent-event-discovery.js.map +1 -0
  176. package/build-module/components/rich-text/use-input-rules.js +2 -1
  177. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  178. package/build-module/components/selection-scroll-into-view/index.js +2 -1
  179. package/build-module/components/selection-scroll-into-view/index.js.map +1 -1
  180. package/build-module/components/use-display-block-controls/index.native.js +34 -0
  181. package/build-module/components/use-display-block-controls/index.native.js.map +1 -0
  182. package/build-module/components/use-on-block-drop/index.js +7 -3
  183. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  184. package/build-module/components/writing-flow/use-multi-selection.js +3 -4
  185. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  186. package/build-module/hooks/border-color.js +61 -7
  187. package/build-module/hooks/border-color.js.map +1 -1
  188. package/build-module/hooks/border-radius.js +42 -0
  189. package/build-module/hooks/border-radius.js.map +1 -1
  190. package/build-module/hooks/border-style.js +36 -0
  191. package/build-module/hooks/border-style.js.map +1 -1
  192. package/build-module/hooks/border-width.js +66 -32
  193. package/build-module/hooks/border-width.js.map +1 -1
  194. package/build-module/hooks/border.js +80 -12
  195. package/build-module/hooks/border.js.map +1 -1
  196. package/build-module/hooks/letter-spacing.js +1 -1
  197. package/build-module/hooks/letter-spacing.js.map +1 -1
  198. package/build-module/hooks/typography.js +1 -1
  199. package/build-module/hooks/typography.js.map +1 -1
  200. package/build-module/store/actions.js +1 -2
  201. package/build-module/store/actions.js.map +1 -1
  202. package/build-module/store/defaults.js +5 -1
  203. package/build-module/store/defaults.js.map +1 -1
  204. package/build-module/store/reducer.js +11 -83
  205. package/build-module/store/reducer.js.map +1 -1
  206. package/build-module/store/selectors.js +24 -7
  207. package/build-module/store/selectors.js.map +1 -1
  208. package/build-module/utils/get-paste-event-data.js +1 -1
  209. package/build-module/utils/get-paste-event-data.js.map +1 -1
  210. package/build-module/utils/parse-css-unit-to-px.js +1 -1
  211. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  212. package/build-module/utils/transform-styles/index.js +2 -3
  213. package/build-module/utils/transform-styles/index.js.map +1 -1
  214. package/build-style/style-rtl.css +229 -182
  215. package/build-style/style.css +229 -182
  216. package/package.json +27 -27
  217. package/src/components/block-caption/index.native.js +22 -4
  218. package/src/components/block-inspector/index.js +14 -17
  219. package/src/components/block-list-appender/index.js +5 -21
  220. package/src/components/block-preview/auto.js +7 -2
  221. package/src/components/block-preview/index.js +60 -0
  222. package/src/components/block-preview/style.scss +23 -0
  223. package/src/components/block-preview/test/index.js +114 -0
  224. package/src/components/block-settings/container.native.js +1 -0
  225. package/src/components/block-styles/index.js +125 -145
  226. package/src/components/block-styles/menu-items.js +49 -0
  227. package/src/components/block-styles/preview-panel.js +36 -0
  228. package/src/components/block-styles/style.scss +59 -51
  229. package/src/components/block-styles/test/{index.js → utils.js} +60 -1
  230. package/src/components/block-styles/use-styles-for-block.js +99 -0
  231. package/src/components/block-styles/utils.js +39 -0
  232. package/src/components/block-switcher/block-styles-menu.js +3 -38
  233. package/src/components/block-tools/back-compat.js +1 -0
  234. package/src/components/block-tools/insertion-point.js +10 -1
  235. package/src/components/border-style-control/style.scss +3 -3
  236. package/src/components/button-block-appender/index.js +1 -0
  237. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -0
  238. package/src/components/colors-gradients/control.js +3 -0
  239. package/src/components/colors-gradients/panel-color-gradient-settings.js +75 -19
  240. package/src/components/colors-gradients/style.scss +42 -5
  241. package/src/components/default-block-appender/index.js +17 -24
  242. package/src/components/default-block-appender/style.scss +4 -0
  243. package/src/components/default-block-appender/test/__snapshots__/index.js.snap +12 -24
  244. package/src/components/default-block-appender/test/index.js +4 -14
  245. package/src/components/default-style-picker/index.js +18 -6
  246. package/src/components/iframe/index.js +6 -3
  247. package/src/components/index.js +5 -2
  248. package/src/components/inner-blocks/README.md +2 -0
  249. package/src/components/inner-blocks/default-block-appender.js +2 -7
  250. package/src/components/inserter/index.native.js +2 -2
  251. package/src/components/inserter/tabs.native.js +5 -4
  252. package/src/components/inspector-controls/block-support-slot-container.js +3 -1
  253. package/src/components/inspector-controls/fill.native.js +4 -3
  254. package/src/components/inspector-controls/groups.js +2 -0
  255. package/src/components/inspector-controls/slot.js +2 -7
  256. package/src/components/letter-spacing-control/index.js +6 -6
  257. package/src/components/link-control/README.md +1 -1
  258. package/src/components/link-control/test/index.js +2 -0
  259. package/src/components/list-view/block-select-button.js +20 -1
  260. package/src/components/media-placeholder/index.js +2 -0
  261. package/src/components/media-replace-flow/index.js +2 -0
  262. package/src/components/rich-text/file-paste-handler.js +3 -1
  263. package/src/components/rich-text/prevent-event-discovery.js +23 -0
  264. package/src/components/rich-text/use-input-rules.js +2 -1
  265. package/src/components/selection-scroll-into-view/index.js +1 -0
  266. package/src/components/url-input/README.md +5 -0
  267. package/src/components/use-display-block-controls/index.native.js +38 -0
  268. package/src/components/use-on-block-drop/index.js +7 -3
  269. package/src/components/writing-flow/test/use-multi-selection.js +36 -0
  270. package/src/components/writing-flow/use-multi-selection.js +12 -9
  271. package/src/hooks/border-color.js +55 -3
  272. package/src/hooks/border-radius.js +32 -0
  273. package/src/hooks/border-style.js +26 -0
  274. package/src/hooks/border-width.js +56 -32
  275. package/src/hooks/border.js +115 -20
  276. package/src/hooks/border.scss +3 -17
  277. package/src/hooks/dimensions.scss +5 -0
  278. package/src/hooks/letter-spacing.js +1 -1
  279. package/src/hooks/typography.js +1 -1
  280. package/src/store/actions.js +1 -2
  281. package/src/store/defaults.js +2 -0
  282. package/src/store/reducer.js +13 -104
  283. package/src/store/selectors.js +37 -7
  284. package/src/style.scss +4 -3
  285. package/src/utils/get-paste-event-data.js +1 -1
  286. package/src/utils/parse-css-unit-to-px.js +1 -1
  287. package/src/utils/test/parse-css-unit-to-px.js +1 -0
  288. package/src/utils/transform-styles/index.js +13 -16
  289. package/tsconfig.tsbuildinfo +1 -1
  290. package/build/components/use-canvas-click-redirect/index.js +0 -66
  291. package/build/components/use-canvas-click-redirect/index.js.map +0 -1
  292. package/build-module/components/use-canvas-click-redirect/index.js +0 -54
  293. package/build-module/components/use-canvas-click-redirect/index.js.map +0 -1
  294. package/src/components/use-canvas-click-redirect/index.js +0 -57
@@ -6,6 +6,7 @@ import { find } from 'lodash';
6
6
  * WordPress dependencies
7
7
  */
8
8
  import TokenList from '@wordpress/token-list';
9
+ import { _x } from '@wordpress/i18n';
9
10
 
10
11
  /**
11
12
  * Returns the active style from the given className.
@@ -51,3 +52,41 @@ export function replaceActiveStyle( className, activeStyle, newStyle ) {
51
52
 
52
53
  return list.value;
53
54
  }
55
+
56
+ /**
57
+ * Returns a collection of styles that can be represented on the frontend.
58
+ * The function checks a style collection for a default style. If none is found, it adds one to
59
+ * act as a fallback for when there is no active style applied to a block. The default item also serves
60
+ * as a switch on the frontend to deactivate non-default styles.
61
+ *
62
+ * @param {Array} styles Block style variations.
63
+ *
64
+ * @return {Array<Object?>} The style collection.
65
+ */
66
+ export function getRenderedStyles( styles ) {
67
+ if ( ! styles || styles.length === 0 ) {
68
+ return [];
69
+ }
70
+
71
+ return getDefaultStyle( styles )
72
+ ? styles
73
+ : [
74
+ {
75
+ name: 'default',
76
+ label: _x( 'Default', 'block style' ),
77
+ isDefault: true,
78
+ },
79
+ ...styles,
80
+ ];
81
+ }
82
+
83
+ /**
84
+ * Returns a style object from a collection of styles where that style object is the default block style.
85
+ *
86
+ * @param {Array} styles Block style variations.
87
+ *
88
+ * @return {Object?} The default style object, if found.
89
+ */
90
+ export function getDefaultStyle( styles ) {
91
+ return find( styles, 'isDefault' );
92
+ }
@@ -3,56 +3,21 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { MenuGroup } from '@wordpress/components';
6
- import { useState } from '@wordpress/element';
7
- import { useSelect } from '@wordpress/data';
8
- import {
9
- cloneBlock,
10
- getBlockFromExample,
11
- store as blocksStore,
12
- } from '@wordpress/blocks';
13
6
 
14
7
  /**
15
8
  * Internal dependencies
16
9
  */
17
- import BlockStyles from '../block-styles';
18
- import PreviewBlockPopover from './preview-block-popover';
10
+ import BlockStylesMenuItems from '../block-styles/menu-items';
19
11
 
20
12
  export default function BlockStylesMenu( { hoveredBlock, onSwitch } ) {
21
- const { name, clientId } = hoveredBlock;
22
- const [ hoveredClassName, setHoveredClassName ] = useState();
23
- const blockType = useSelect(
24
- ( select ) => select( blocksStore ).getBlockType( name ),
25
- [ name ]
26
- );
13
+ const { clientId } = hoveredBlock;
27
14
 
28
15
  return (
29
16
  <MenuGroup
30
17
  label={ __( 'Styles' ) }
31
18
  className="block-editor-block-switcher__styles__menugroup"
32
19
  >
33
- { hoveredClassName && (
34
- <PreviewBlockPopover
35
- blocks={
36
- blockType && blockType.example
37
- ? getBlockFromExample( blockType.name, {
38
- attributes: {
39
- ...blockType.example.attributes,
40
- className: hoveredClassName,
41
- },
42
- innerBlocks: blockType.example.innerBlocks,
43
- } )
44
- : cloneBlock( hoveredBlock, {
45
- className: hoveredClassName,
46
- } )
47
- }
48
- />
49
- ) }
50
- <BlockStyles
51
- clientId={ clientId }
52
- onSwitch={ onSwitch }
53
- onHoverClassName={ setHoveredClassName }
54
- itemRole="menuitem"
55
- />
20
+ <BlockStylesMenuItems clientId={ clientId } onSwitch={ onSwitch } />
56
21
  </MenuGroup>
57
22
  );
58
23
  }
@@ -22,6 +22,7 @@ export default function BlockToolsBackCompat( { children } ) {
22
22
 
23
23
  deprecated( 'wp.components.Popover.Slot name="block-toolbar"', {
24
24
  alternative: 'wp.blockEditor.BlockTools',
25
+ since: '5.8',
25
26
  } );
26
27
 
27
28
  return (
@@ -32,7 +32,7 @@ function InsertionPointPopover( {
32
32
  __unstablePopoverSlot,
33
33
  __unstableContentRef,
34
34
  } ) {
35
- const { selectBlock } = useDispatch( blockEditorStore );
35
+ const { selectBlock, hideInsertionPoint } = useDispatch( blockEditorStore );
36
36
  const openRef = useContext( InsertionPointOpenRef );
37
37
  const ref = useRef();
38
38
  const {
@@ -195,6 +195,14 @@ function InsertionPointPopover( {
195
195
  }
196
196
  }
197
197
 
198
+ function maybeHideInserterPoint( event ) {
199
+ // Only hide the inserter if it's triggered on the wrapper,
200
+ // and the inserter is not open.
201
+ if ( event.target === ref.current && ! openRef.current ) {
202
+ hideInsertionPoint();
203
+ }
204
+ }
205
+
198
206
  // Only show the in-between inserter between blocks, so when there's a
199
207
  // previous and a next element.
200
208
  const showInsertionPointInserter =
@@ -309,6 +317,7 @@ function InsertionPointPopover( {
309
317
  className={ classnames( className, {
310
318
  'is-with-inserter': showInsertionPointInserter,
311
319
  } ) }
320
+ onHoverEnd={ maybeHideInserterPoint }
312
321
  style={ style }
313
322
  >
314
323
  <motion.div
@@ -1,12 +1,12 @@
1
1
  .components-border-style-control {
2
2
  legend {
3
- line-height: 1.2;
4
- padding-bottom: $grid-unit-05;
3
+ line-height: 1.4;
4
+ margin-bottom: $grid-unit-10;
5
+ padding: 0;
5
6
  }
6
7
 
7
8
  .components-border-style-control__buttons {
8
9
  display: inline-flex;
9
- margin-bottom: $grid-unit-30;
10
10
 
11
11
  .components-button.has-icon {
12
12
  min-width: 30px;
@@ -90,6 +90,7 @@ function ButtonBlockAppender(
90
90
  export const ButtonBlockerAppender = forwardRef( ( props, ref ) => {
91
91
  deprecated( `wp.blockEditor.ButtonBlockerAppender`, {
92
92
  alternative: 'wp.blockEditor.ButtonBlockAppender',
93
+ since: '5.9',
93
94
  } );
94
95
 
95
96
  return ButtonBlockAppender( props, ref );
@@ -105,6 +105,7 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
105
105
  style={
106
106
  Object {
107
107
  "background": "#f00",
108
+ "color": "#000",
108
109
  }
109
110
  }
110
111
  >
@@ -132,6 +132,9 @@ function ColorGradientControlInner( {
132
132
  __experimentalHasMultipleOrigins={
133
133
  __experimentalHasMultipleOrigins
134
134
  }
135
+ __experimentalIsRenderedInSidebar={
136
+ __experimentalIsRenderedInSidebar
137
+ }
135
138
  clearable={ clearable }
136
139
  />
137
140
  ) }
@@ -7,8 +7,17 @@ import { every, isEmpty } from 'lodash';
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
- import { PanelBody, ColorIndicator } from '@wordpress/components';
11
- import { sprintf, __ } from '@wordpress/i18n';
10
+ import {
11
+ __experimentalItemGroup as ItemGroup,
12
+ __experimentalItem as Item,
13
+ __experimentalHStack as HStack,
14
+ __experimentalSpacer as Spacer,
15
+ FlexItem,
16
+ ColorIndicator,
17
+ PanelBody,
18
+ Dropdown,
19
+ } from '@wordpress/components';
20
+ import { sprintf, __, isRTL } from '@wordpress/i18n';
12
21
 
13
22
  /**
14
23
  * Internal dependencies
@@ -127,6 +136,13 @@ export const PanelColorGradientSettingsInner = ( {
127
136
  </span>
128
137
  );
129
138
 
139
+ let dropdownPosition;
140
+ let popoverProps;
141
+ if ( __experimentalIsRenderedInSidebar ) {
142
+ dropdownPosition = isRTL() ? 'bottom right' : 'bottom left';
143
+ popoverProps = { __unstableForcePosition: true };
144
+ }
145
+
130
146
  return (
131
147
  <PanelBody
132
148
  className={ classnames(
@@ -136,23 +152,63 @@ export const PanelColorGradientSettingsInner = ( {
136
152
  title={ showTitle ? titleElement : undefined }
137
153
  { ...props }
138
154
  >
139
- { settings.map( ( setting, index ) => (
140
- <ColorGradientControl
141
- showTitle={ showTitle }
142
- key={ index }
143
- { ...{
144
- colors,
145
- gradients,
146
- disableCustomColors,
147
- disableCustomGradients,
148
- __experimentalHasMultipleOrigins,
149
- __experimentalIsRenderedInSidebar,
150
- enableAlpha,
151
- ...setting,
152
- } }
153
- />
154
- ) ) }
155
- { children }
155
+ <ItemGroup
156
+ isBordered
157
+ isSeparated
158
+ className="block-editor-panel-color-gradient-settings__item-group"
159
+ >
160
+ { settings.map( ( setting, index ) => (
161
+ <Dropdown
162
+ position={ dropdownPosition }
163
+ popoverProps={ popoverProps }
164
+ className="block-editor-panel-color-gradient-settings__dropdown"
165
+ key={ index }
166
+ contentClassName="block-editor-panel-color-gradient-settings__dropdown-content"
167
+ renderToggle={ ( { isOpen, onToggle } ) => {
168
+ return (
169
+ <Item
170
+ onClick={ onToggle }
171
+ className={ classnames(
172
+ 'block-editor-panel-color-gradient-settings__item',
173
+ { 'is-open': isOpen }
174
+ ) }
175
+ >
176
+ <HStack justify="flex-start">
177
+ <ColorIndicator
178
+ className="block-editor-panel-color-gradient-settings__color-indicator"
179
+ colorValue={
180
+ setting.gradientValue ??
181
+ setting.colorValue
182
+ }
183
+ />
184
+ <FlexItem>{ setting.label }</FlexItem>
185
+ </HStack>
186
+ </Item>
187
+ );
188
+ } }
189
+ renderContent={ () => (
190
+ <ColorGradientControl
191
+ showTitle={ false }
192
+ { ...{
193
+ colors,
194
+ gradients,
195
+ disableCustomColors,
196
+ disableCustomGradients,
197
+ __experimentalHasMultipleOrigins,
198
+ __experimentalIsRenderedInSidebar,
199
+ enableAlpha,
200
+ ...setting,
201
+ } }
202
+ />
203
+ ) }
204
+ />
205
+ ) ) }
206
+ </ItemGroup>
207
+ { !! children && (
208
+ <>
209
+ <Spacer marginY={ 4 } /> { children }
210
+ </>
211
+ ) }
156
212
  </PanelBody>
157
213
  );
158
214
  };
@@ -5,13 +5,14 @@
5
5
  }
6
6
 
7
7
  .block-editor-panel-color-gradient-settings {
8
- .component-color-indicator {
9
- vertical-align: text-bottom;
10
- }
8
+ .block-editor-panel-color-gradient-settings__panel-title {
9
+ display: flex;
10
+ gap: $grid-unit-15;
11
11
 
12
- &__panel-title {
13
12
  .component-color-indicator {
14
- display: inline-block;
13
+ width: $grid-unit-15;
14
+ height: $grid-unit-15;
15
+ align-self: center;
15
16
  }
16
17
  }
17
18
 
@@ -37,4 +38,40 @@
37
38
  .block-editor-block-inspector & .components-base-control {
38
39
  margin-bottom: inherit;
39
40
  }
41
+
42
+ .block-editor-panel-color-gradient-settings__dropdown {
43
+ display: block;
44
+ }
45
+ }
46
+
47
+ .block-editor-panel-color-gradient-settings__dropdown-content .components-popover__content {
48
+ & > div {
49
+ width: $sidebar-width;
50
+ }
51
+ }
52
+
53
+ @include break-medium() {
54
+ .block-editor-panel-color-gradient-settings__dropdown-content .components-popover__content {
55
+ margin-right: #{ math.div($sidebar-width, 2) + $grid-unit-20 } !important;
56
+ margin-top: #{ -($grid-unit-60 + $grid-unit-15) } !important;
57
+ }
40
58
  }
59
+
60
+ .block-editor-panel-color-gradient-settings__dropdown:last-child > div {
61
+ border-bottom-width: 0;
62
+ }
63
+
64
+ .block-editor-panel-color-gradient-settings__item {
65
+ padding-top: $grid-unit-15 !important;
66
+ padding-bottom: $grid-unit-15 !important;
67
+ .block-editor-panel-color-gradient-settings__color-indicator {
68
+ // Show a diagonal line (crossed out) for empty swatches.
69
+ background: linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
70
+ }
71
+
72
+ &.is-open {
73
+ background: $gray-100;
74
+ color: var(--wp-admin-theme-color);
75
+ }
76
+ }
77
+
@@ -8,9 +8,9 @@ import classnames from 'classnames';
8
8
  */
9
9
  import { __ } from '@wordpress/i18n';
10
10
  import { compose } from '@wordpress/compose';
11
- import { getDefaultBlockName } from '@wordpress/blocks';
12
11
  import { decodeEntities } from '@wordpress/html-entities';
13
12
  import { withSelect, withDispatch } from '@wordpress/data';
13
+ import { ENTER, SPACE } from '@wordpress/keycodes';
14
14
 
15
15
  /**
16
16
  * Internal dependencies
@@ -26,13 +26,12 @@ export const ZWNBSP = '\ufeff';
26
26
 
27
27
  export function DefaultBlockAppender( {
28
28
  isLocked,
29
- isVisible,
30
29
  onAppend,
31
30
  showPrompt,
32
31
  placeholder,
33
32
  rootClientId,
34
33
  } ) {
35
- if ( isLocked || ! isVisible ) {
34
+ if ( isLocked ) {
36
35
  return null;
37
36
  }
38
37
 
@@ -48,20 +47,23 @@ export function DefaultBlockAppender( {
48
47
  >
49
48
  <p
50
49
  tabIndex="0"
51
- // Only necessary for `useCanvasClickRedirect` to consider it
52
- // as a target. Ideally it should consider any tabbable target,
53
- // but the inserter is rendered in place while it should be
54
- // rendered in a popover, just like it does for an empty
55
- // paragraph block.
56
- contentEditable
57
- suppressContentEditableWarning
58
50
  // We want this element to be styled as a paragraph by themes.
59
51
  // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
60
52
  role="button"
61
- aria-label={ __( 'Add block' ) }
53
+ aria-label={ __( 'Add default block' ) }
62
54
  // A wrapping container for this one already has the wp-block className.
63
55
  className="block-editor-default-block-appender__content"
64
- onFocus={ onAppend }
56
+ onKeyDown={ ( event ) => {
57
+ if ( ENTER === event.keyCode || SPACE === event.keyCode ) {
58
+ onAppend();
59
+ }
60
+ } }
61
+ onClick={ () => onAppend() }
62
+ onFocus={ () => {
63
+ if ( showPrompt ) {
64
+ onAppend();
65
+ }
66
+ } }
65
67
  >
66
68
  { showPrompt ? value : ZWNBSP }
67
69
  </p>
@@ -77,23 +79,14 @@ export function DefaultBlockAppender( {
77
79
 
78
80
  export default compose(
79
81
  withSelect( ( select, ownProps ) => {
80
- const {
81
- getBlockCount,
82
- getBlockName,
83
- isBlockValid,
84
- getSettings,
85
- getTemplateLock,
86
- } = select( blockEditorStore );
82
+ const { getBlockCount, getSettings, getTemplateLock } = select(
83
+ blockEditorStore
84
+ );
87
85
 
88
86
  const isEmpty = ! getBlockCount( ownProps.rootClientId );
89
- const isLastBlockDefault =
90
- getBlockName( ownProps.lastBlockClientId ) ===
91
- getDefaultBlockName();
92
- const isLastBlockValid = isBlockValid( ownProps.lastBlockClientId );
93
87
  const { bodyPlaceholder } = getSettings();
94
88
 
95
89
  return {
96
- isVisible: isEmpty || ! isLastBlockDefault || ! isLastBlockValid,
97
90
  showPrompt: isEmpty,
98
91
  isLocked: !! getTemplateLock( ownProps.rootClientId ),
99
92
  placeholder: bodyPlaceholder,
@@ -126,3 +126,7 @@
126
126
  display: flex;
127
127
  }
128
128
  }
129
+
130
+ .block-editor-default-block-appender__content {
131
+ cursor: text;
132
+ }
@@ -6,24 +6,12 @@ exports[`DefaultBlockAppender should append a default block when input focused 1
6
6
  data-root-client-id=""
7
7
  >
8
8
  <p
9
- aria-label="Add block"
9
+ aria-label="Add default block"
10
10
  className="block-editor-default-block-appender__content"
11
- contentEditable={true}
12
- onFocus={
13
- [MockFunction] {
14
- "calls": Array [
15
- Array [],
16
- ],
17
- "results": Array [
18
- Object {
19
- "type": "return",
20
- "value": undefined,
21
- },
22
- ],
23
- }
24
- }
11
+ onClick={[Function]}
12
+ onFocus={[Function]}
13
+ onKeyDown={[Function]}
25
14
  role="button"
26
- suppressContentEditableWarning={true}
27
15
  tabIndex="0"
28
16
  >
29
17
  Type / to choose a block
@@ -42,12 +30,12 @@ exports[`DefaultBlockAppender should match snapshot 1`] = `
42
30
  data-root-client-id=""
43
31
  >
44
32
  <p
45
- aria-label="Add block"
33
+ aria-label="Add default block"
46
34
  className="block-editor-default-block-appender__content"
47
- contentEditable={true}
48
- onFocus={[MockFunction]}
35
+ onClick={[Function]}
36
+ onFocus={[Function]}
37
+ onKeyDown={[Function]}
49
38
  role="button"
50
- suppressContentEditableWarning={true}
51
39
  tabIndex="0"
52
40
  >
53
41
  Type / to choose a block
@@ -66,12 +54,12 @@ exports[`DefaultBlockAppender should optionally show without prompt 1`] = `
66
54
  data-root-client-id=""
67
55
  >
68
56
  <p
69
- aria-label="Add block"
57
+ aria-label="Add default block"
70
58
  className="block-editor-default-block-appender__content"
71
- contentEditable={true}
72
- onFocus={[MockFunction]}
59
+ onClick={[Function]}
60
+ onFocus={[Function]}
61
+ onKeyDown={[Function]}
73
62
  role="button"
74
- suppressContentEditableWarning={true}
75
63
  tabIndex="0"
76
64
  >
77
65
  
@@ -14,16 +14,10 @@ describe( 'DefaultBlockAppender', () => {
14
14
  expect( onAppend ).toHaveBeenCalledWith();
15
15
  };
16
16
 
17
- it( 'should render nothing if not visible', () => {
18
- const wrapper = shallow( <DefaultBlockAppender /> );
19
-
20
- expect( wrapper.type() ).toBe( null );
21
- } );
22
-
23
17
  it( 'should match snapshot', () => {
24
18
  const onAppend = jest.fn();
25
19
  const wrapper = shallow(
26
- <DefaultBlockAppender isVisible onAppend={ onAppend } showPrompt />
20
+ <DefaultBlockAppender onAppend={ onAppend } showPrompt />
27
21
  );
28
22
 
29
23
  expect( wrapper ).toMatchSnapshot();
@@ -32,10 +26,10 @@ describe( 'DefaultBlockAppender', () => {
32
26
  it( 'should append a default block when input focused', () => {
33
27
  const onAppend = jest.fn();
34
28
  const wrapper = shallow(
35
- <DefaultBlockAppender isVisible onAppend={ onAppend } showPrompt />
29
+ <DefaultBlockAppender onAppend={ onAppend } showPrompt />
36
30
  );
37
31
 
38
- wrapper.find( 'p' ).simulate( 'focus' );
32
+ wrapper.find( 'p' ).simulate( 'click' );
39
33
 
40
34
  expect( wrapper ).toMatchSnapshot();
41
35
 
@@ -45,11 +39,7 @@ describe( 'DefaultBlockAppender', () => {
45
39
  it( 'should optionally show without prompt', () => {
46
40
  const onAppend = jest.fn();
47
41
  const wrapper = shallow(
48
- <DefaultBlockAppender
49
- isVisible
50
- onAppend={ onAppend }
51
- showPrompt={ false }
52
- />
42
+ <DefaultBlockAppender onAppend={ onAppend } showPrompt={ false } />
53
43
  );
54
44
  const input = wrapper.find( 'p' );
55
45
 
@@ -11,6 +11,7 @@ import { useSelect } from '@wordpress/data';
11
11
  * Internal dependencies
12
12
  */
13
13
  import { store as blockEditorStore } from '../../store';
14
+ import { getDefaultStyle } from '../block-styles/utils';
14
15
 
15
16
  export default function DefaultStylePicker( { blockName } ) {
16
17
  const {
@@ -38,6 +39,9 @@ export default function DefaultStylePicker( { blockName } ) {
38
39
  ],
39
40
  [ styles ]
40
41
  );
42
+ const defaultStyleName = useMemo( () => getDefaultStyle( styles )?.name, [
43
+ styles,
44
+ ] );
41
45
  const selectOnChange = useCallback(
42
46
  ( blockStyle ) => {
43
47
  onUpdatePreferredStyleVariations( blockName, blockStyle );
@@ -45,14 +49,22 @@ export default function DefaultStylePicker( { blockName } ) {
45
49
  [ blockName, onUpdatePreferredStyleVariations ]
46
50
  );
47
51
 
52
+ // Until the functionality is migrated to global styles,
53
+ // only show the default style picker if a non-default style has already been selected.
54
+ if ( ! preferredStyle || preferredStyle === defaultStyleName ) {
55
+ return null;
56
+ }
57
+
48
58
  return (
49
59
  onUpdatePreferredStyleVariations && (
50
- <SelectControl
51
- options={ selectOptions }
52
- value={ preferredStyle || '' }
53
- label={ __( 'Default Style' ) }
54
- onChange={ selectOnChange }
55
- />
60
+ <div className="default-style-picker__default-switcher">
61
+ <SelectControl
62
+ options={ selectOptions }
63
+ value={ preferredStyle || '' }
64
+ label={ __( 'Default Style' ) }
65
+ onChange={ selectOnChange }
66
+ />
67
+ </div>
56
68
  )
57
69
  );
58
70
  }
@@ -164,12 +164,15 @@ async function loadScript( head, { id, src } ) {
164
164
  } );
165
165
  }
166
166
 
167
- function Iframe( { contentRef, children, head, tabIndex = 0, ...props }, ref ) {
167
+ function Iframe(
168
+ { contentRef, children, head, tabIndex = 0, assets, ...props },
169
+ ref
170
+ ) {
168
171
  const [ , forceRender ] = useReducer( () => ( {} ) );
169
172
  const [ iframeDocument, setIframeDocument ] = useState();
170
173
  const [ bodyClasses, setBodyClasses ] = useState( [] );
171
- const styles = useParsedAssets( window.__editorAssets?.styles );
172
- const scripts = useParsedAssets( window.__editorAssets?.scripts );
174
+ const styles = useParsedAssets( assets?.styles );
175
+ const scripts = useParsedAssets( assets?.scripts );
173
176
  const clearerRef = useBlockSelectionClearer();
174
177
  const [ before, writingFlowRef, after ] = useWritingFlow();
175
178
  const setRef = useRefEffect( ( node ) => {
@@ -24,6 +24,7 @@ export { default as BlockColorsStyleSelector } from './color-style-selector';
24
24
  export { default as BlockEdit, useBlockEditContext } from './block-edit';
25
25
  export { default as BlockIcon } from './block-icon';
26
26
  export { default as BlockNavigationDropdown } from './block-navigation/dropdown';
27
+ export { default as BlockStyles } from './block-styles';
27
28
  export { default as __experimentalBlockVariationPicker } from './block-variation-picker';
28
29
  export { default as __experimentalBlockPatternSetup } from './block-pattern-setup';
29
30
  export { default as __experimentalBlockVariationTransforms } from './block-variation-transforms';
@@ -103,7 +104,10 @@ export { default as BlockList } from './block-list';
103
104
  export { useBlockProps } from './block-list/use-block-props';
104
105
  export { LayoutStyle as __experimentalLayoutStyle } from './block-list/layout';
105
106
  export { default as BlockMover } from './block-mover';
106
- export { default as BlockPreview } from './block-preview';
107
+ export {
108
+ default as BlockPreview,
109
+ useBlockPreview as __experimentalUseBlockPreview,
110
+ } from './block-preview';
107
111
  export {
108
112
  default as BlockSelectionClearer,
109
113
  useBlockSelectionClearer as __unstableUseBlockSelectionClearer,
@@ -137,7 +141,6 @@ export {
137
141
  } from './typewriter';
138
142
  export { default as Warning } from './warning';
139
143
  export { default as WritingFlow } from './writing-flow';
140
- export { useCanvasClickRedirect as __unstableUseCanvasClickRedirect } from './use-canvas-click-redirect';
141
144
  export { default as useBlockDisplayInformation } from './use-block-display-information';
142
145
  export { default as __unstableIframe } from './iframe';
143
146
  export { default as __experimentalUseNoRecursiveRenders } from './use-no-recursive-renders';
@@ -41,6 +41,8 @@ _Note:_ A block can render at most a single `InnerBlocks` and `InnerBlocks.Conte
41
41
 
42
42
  _Note:_ Because the save step will automatically apply props to the element returned by `save`, it is important to include the wrapping `div` in the above simple example even though we are applying no props of our own. In a real-world example, you may have your own attributes to apply to the saved markup, or sibling content adjacent to the rendered nested blocks.
43
43
 
44
+ _Note:_ Inner blocks, by default, are not visible inside a WordPress excerpt. If you wish your block to appear then it needs to be returned from the `excerpt_allowed_wrapper_blocks` filter. More details can be found on the [filter reference page](https://developer.wordpress.org/reference/hooks/excerpt_allowed_wrapper_blocks/) page, as well as the [excerpt_remove_blocks](https://developer.wordpress.org/reference/functions/excerpt_remove_blocks/) page.
45
+
44
46
  ## Props
45
47
 
46
48
  ### `allowedBlocks`