@wordpress/block-editor 8.5.4 → 9.0.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 (299) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +4 -2
  3. package/build/components/block-alignment-control/constants.js +48 -0
  4. package/build/components/block-alignment-control/constants.js.map +1 -0
  5. package/build/components/block-alignment-control/ui.js +9 -40
  6. package/build/components/block-alignment-control/ui.js.map +1 -1
  7. package/build/components/block-alignment-control/ui.native.js +92 -0
  8. package/build/components/block-alignment-control/ui.native.js.map +1 -0
  9. package/build/components/block-content-overlay/index.js +13 -4
  10. package/build/components/block-content-overlay/index.js.map +1 -1
  11. package/build/components/block-list/block.native.js +3 -1
  12. package/build/components/block-list/block.native.js.map +1 -1
  13. package/build/components/block-list/use-block-props/use-block-class-names.js +1 -7
  14. package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  15. package/build/components/block-lock/modal.js +34 -4
  16. package/build/components/block-lock/modal.js.map +1 -1
  17. package/build/components/block-lock/toolbar.js +2 -1
  18. package/build/components/block-lock/toolbar.js.map +1 -1
  19. package/build/components/block-lock/use-block-lock.js +4 -1
  20. package/build/components/block-lock/use-block-lock.js.map +1 -1
  21. package/build/components/block-mover/button.js +4 -4
  22. package/build/components/block-mover/button.js.map +1 -1
  23. package/build/components/block-mover/index.js +39 -65
  24. package/build/components/block-mover/index.js.map +1 -1
  25. package/build/components/block-navigation/dropdown.js +11 -5
  26. package/build/components/block-navigation/dropdown.js.map +1 -1
  27. package/build/components/block-popover/inbetween.js +183 -0
  28. package/build/components/block-popover/inbetween.js.map +1 -0
  29. package/build/components/block-popover/index.js +97 -0
  30. package/build/components/block-popover/index.js.map +1 -0
  31. package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
  32. package/build/components/block-popover/use-popover-scroll.js.map +1 -0
  33. package/build/components/block-styles/index.js +1 -10
  34. package/build/components/block-styles/index.js.map +1 -1
  35. package/build/components/block-tools/back-compat.js +2 -2
  36. package/build/components/block-tools/back-compat.js.map +1 -1
  37. package/build/components/block-tools/block-selection-button.js +4 -2
  38. package/build/components/block-tools/block-selection-button.js.map +1 -1
  39. package/build/components/block-tools/index.js +5 -5
  40. package/build/components/block-tools/index.js.map +1 -1
  41. package/build/components/block-tools/insertion-point.js +14 -121
  42. package/build/components/block-tools/insertion-point.js.map +1 -1
  43. package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
  44. package/build/components/block-tools/selected-block-popover.js.map +1 -0
  45. package/build/components/color-style-selector/index.js +9 -0
  46. package/build/components/color-style-selector/index.js.map +1 -1
  47. package/build/components/duotone-control/index.js +5 -1
  48. package/build/components/duotone-control/index.js.map +1 -1
  49. package/build/components/index.js +0 -9
  50. package/build/components/index.js.map +1 -1
  51. package/build/components/inserter/index.native.js +30 -8
  52. package/build/components/inserter/index.native.js.map +1 -1
  53. package/build/components/list-view/block.js +15 -15
  54. package/build/components/list-view/block.js.map +1 -1
  55. package/build/components/list-view/branch.js +9 -13
  56. package/build/components/list-view/branch.js.map +1 -1
  57. package/build/components/list-view/context.js +1 -4
  58. package/build/components/list-view/context.js.map +1 -1
  59. package/build/components/list-view/index.js +15 -32
  60. package/build/components/list-view/index.js.map +1 -1
  61. package/build/components/rich-text/index.js +0 -5
  62. package/build/components/rich-text/index.js.map +1 -1
  63. package/build/components/rich-text/index.native.js +0 -4
  64. package/build/components/rich-text/index.native.js.map +1 -1
  65. package/build/components/url-input/index.js +7 -3
  66. package/build/components/url-input/index.js.map +1 -1
  67. package/build/components/use-block-display-information/index.js +3 -1
  68. package/build/components/use-block-display-information/index.js.map +1 -1
  69. package/build/components/use-setting/index.js +42 -18
  70. package/build/components/use-setting/index.js.map +1 -1
  71. package/build/hooks/border.js +468 -44
  72. package/build/hooks/border.js.map +1 -1
  73. package/build/hooks/dimensions.js +2 -2
  74. package/build/hooks/dimensions.js.map +1 -1
  75. package/build/hooks/index.js +3 -1
  76. package/build/hooks/index.js.map +1 -1
  77. package/build/hooks/margin.js +64 -12
  78. package/build/hooks/margin.js.map +1 -1
  79. package/build/hooks/padding.js +60 -12
  80. package/build/hooks/padding.js.map +1 -1
  81. package/build/hooks/settings.js +32 -0
  82. package/build/hooks/settings.js.map +1 -0
  83. package/build/hooks/use-border-props.js +22 -32
  84. package/build/hooks/use-border-props.js.map +1 -1
  85. package/build/store/actions.js +14 -2
  86. package/build/store/actions.js.map +1 -1
  87. package/build/store/defaults.js +0 -1
  88. package/build/store/defaults.js.map +1 -1
  89. package/build/store/reducer.js +0 -26
  90. package/build/store/reducer.js.map +1 -1
  91. package/build/store/selectors.js +47 -15
  92. package/build/store/selectors.js.map +1 -1
  93. package/build-module/components/block-alignment-control/constants.js +36 -0
  94. package/build-module/components/block-alignment-control/constants.js.map +1 -0
  95. package/build-module/components/block-alignment-control/ui.js +4 -35
  96. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  97. package/build-module/components/block-alignment-control/ui.native.js +78 -0
  98. package/build-module/components/block-alignment-control/ui.native.js.map +1 -0
  99. package/build-module/components/block-content-overlay/index.js +13 -4
  100. package/build-module/components/block-content-overlay/index.js.map +1 -1
  101. package/build-module/components/block-list/block.native.js +3 -1
  102. package/build-module/components/block-list/block.native.js.map +1 -1
  103. package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -7
  104. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  105. package/build-module/components/block-lock/modal.js +34 -5
  106. package/build-module/components/block-lock/modal.js.map +1 -1
  107. package/build-module/components/block-lock/toolbar.js +2 -1
  108. package/build-module/components/block-lock/toolbar.js.map +1 -1
  109. package/build-module/components/block-lock/use-block-lock.js +4 -1
  110. package/build-module/components/block-lock/use-block-lock.js.map +1 -1
  111. package/build-module/components/block-mover/button.js +5 -5
  112. package/build-module/components/block-mover/button.js.map +1 -1
  113. package/build-module/components/block-mover/index.js +38 -63
  114. package/build-module/components/block-mover/index.js.map +1 -1
  115. package/build-module/components/block-navigation/dropdown.js +10 -5
  116. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  117. package/build-module/components/block-popover/inbetween.js +165 -0
  118. package/build-module/components/block-popover/inbetween.js.map +1 -0
  119. package/build-module/components/block-popover/index.js +83 -0
  120. package/build-module/components/block-popover/index.js.map +1 -0
  121. package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  122. package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
  123. package/build-module/components/block-styles/index.js +1 -9
  124. package/build-module/components/block-styles/index.js.map +1 -1
  125. package/build-module/components/block-tools/back-compat.js +1 -1
  126. package/build-module/components/block-tools/back-compat.js.map +1 -1
  127. package/build-module/components/block-tools/block-selection-button.js +3 -2
  128. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  129. package/build-module/components/block-tools/index.js +3 -3
  130. package/build-module/components/block-tools/index.js.map +1 -1
  131. package/build-module/components/block-tools/insertion-point.js +16 -121
  132. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  133. package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
  134. package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
  135. package/build-module/components/color-style-selector/index.js +6 -0
  136. package/build-module/components/color-style-selector/index.js.map +1 -1
  137. package/build-module/components/duotone-control/index.js +4 -1
  138. package/build-module/components/duotone-control/index.js.map +1 -1
  139. package/build-module/components/index.js +0 -1
  140. package/build-module/components/index.js.map +1 -1
  141. package/build-module/components/inserter/index.native.js +31 -10
  142. package/build-module/components/inserter/index.native.js.map +1 -1
  143. package/build-module/components/list-view/block.js +15 -16
  144. package/build-module/components/list-view/block.js.map +1 -1
  145. package/build-module/components/list-view/branch.js +9 -13
  146. package/build-module/components/list-view/branch.js.map +1 -1
  147. package/build-module/components/list-view/context.js +1 -4
  148. package/build-module/components/list-view/context.js.map +1 -1
  149. package/build-module/components/list-view/index.js +15 -31
  150. package/build-module/components/list-view/index.js.map +1 -1
  151. package/build-module/components/rich-text/index.js +0 -4
  152. package/build-module/components/rich-text/index.js.map +1 -1
  153. package/build-module/components/rich-text/index.native.js +0 -4
  154. package/build-module/components/rich-text/index.native.js.map +1 -1
  155. package/build-module/components/url-input/index.js +7 -3
  156. package/build-module/components/url-input/index.js.map +1 -1
  157. package/build-module/components/use-block-display-information/index.js +3 -1
  158. package/build-module/components/use-block-display-information/index.js.map +1 -1
  159. package/build-module/components/use-setting/index.js +43 -19
  160. package/build-module/components/use-setting/index.js.map +1 -1
  161. package/build-module/hooks/border.js +458 -44
  162. package/build-module/hooks/border.js.map +1 -1
  163. package/build-module/hooks/dimensions.js +5 -5
  164. package/build-module/hooks/dimensions.js.map +1 -1
  165. package/build-module/hooks/index.js +2 -1
  166. package/build-module/hooks/index.js.map +1 -1
  167. package/build-module/hooks/margin.js +61 -13
  168. package/build-module/hooks/margin.js.map +1 -1
  169. package/build-module/hooks/padding.js +57 -13
  170. package/build-module/hooks/padding.js.map +1 -1
  171. package/build-module/hooks/settings.js +29 -0
  172. package/build-module/hooks/settings.js.map +1 -0
  173. package/build-module/hooks/use-border-props.js +21 -30
  174. package/build-module/hooks/use-border-props.js.map +1 -1
  175. package/build-module/store/actions.js +14 -2
  176. package/build-module/store/actions.js.map +1 -1
  177. package/build-module/store/defaults.js +0 -1
  178. package/build-module/store/defaults.js.map +1 -1
  179. package/build-module/store/reducer.js +0 -24
  180. package/build-module/store/reducer.js.map +1 -1
  181. package/build-module/store/selectors.js +44 -15
  182. package/build-module/store/selectors.js.map +1 -1
  183. package/build-style/style-rtl.css +128 -276
  184. package/build-style/style.css +128 -276
  185. package/package.json +28 -28
  186. package/src/components/block-alignment-control/constants.js +45 -0
  187. package/src/components/block-alignment-control/ui.js +69 -109
  188. package/src/components/block-alignment-control/ui.native.js +86 -0
  189. package/src/components/block-content-overlay/index.js +19 -2
  190. package/src/components/block-list/block.native.js +2 -0
  191. package/src/components/block-list/style.scss +7 -18
  192. package/src/components/block-list/use-block-props/use-block-class-names.js +1 -11
  193. package/src/components/block-lock/modal.js +42 -3
  194. package/src/components/block-lock/toolbar.js +2 -2
  195. package/src/components/block-lock/use-block-lock.js +4 -1
  196. package/src/components/block-mover/button.js +5 -7
  197. package/src/components/block-mover/index.js +37 -60
  198. package/src/components/block-mover/stories/index.js +110 -0
  199. package/src/components/block-mover/style.scss +48 -138
  200. package/src/components/block-navigation/dropdown.js +12 -8
  201. package/src/components/block-popover/README.md +41 -0
  202. package/src/components/block-popover/inbetween.js +180 -0
  203. package/src/components/block-popover/index.js +90 -0
  204. package/src/components/block-popover/style.scss +27 -0
  205. package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  206. package/src/components/block-styles/index.js +1 -12
  207. package/src/components/block-switcher/style.scss +0 -4
  208. package/src/components/block-toolbar/style.scss +0 -12
  209. package/src/components/block-tools/back-compat.js +1 -1
  210. package/src/components/block-tools/block-selection-button.js +3 -1
  211. package/src/components/block-tools/index.js +6 -4
  212. package/src/components/block-tools/insertion-point.js +19 -152
  213. package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
  214. package/src/components/block-tools/style.scss +11 -123
  215. package/src/components/border-radius-control/style.scss +5 -2
  216. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  217. package/src/components/color-style-selector/index.js +18 -9
  218. package/src/components/default-block-appender/style.scss +1 -2
  219. package/src/components/duotone-control/index.js +8 -1
  220. package/src/components/gradients/README.md +29 -0
  221. package/src/components/image-size-control/README.md +1 -1
  222. package/src/components/index.js +0 -1
  223. package/src/components/inserter/index.native.js +60 -25
  224. package/src/components/inserter/style.native.scss +25 -3
  225. package/src/components/list-view/block.js +24 -34
  226. package/src/components/list-view/branch.js +10 -20
  227. package/src/components/list-view/context.js +1 -4
  228. package/src/components/list-view/index.js +11 -41
  229. package/src/components/navigable-toolbar/README.md +16 -0
  230. package/src/components/rich-text/index.js +0 -2
  231. package/src/components/rich-text/index.native.js +0 -4
  232. package/src/components/url-input/index.js +6 -3
  233. package/src/components/use-block-display-information/index.js +2 -0
  234. package/src/components/use-setting/index.js +57 -21
  235. package/src/hooks/border.js +438 -72
  236. package/src/hooks/border.scss +48 -0
  237. package/src/hooks/dimensions.js +44 -38
  238. package/src/hooks/index.js +2 -1
  239. package/src/hooks/margin.js +64 -15
  240. package/src/hooks/padding.js +60 -15
  241. package/src/hooks/padding.scss +12 -0
  242. package/src/hooks/settings.js +32 -0
  243. package/src/hooks/test/settings.js +48 -0
  244. package/src/hooks/use-border-props.js +15 -32
  245. package/src/store/actions.js +14 -2
  246. package/src/store/defaults.js +0 -1
  247. package/src/store/reducer.js +0 -21
  248. package/src/store/selectors.js +46 -15
  249. package/src/store/test/actions.js +0 -18
  250. package/src/store/test/reducer.js +0 -19
  251. package/src/store/test/selectors.js +17 -19
  252. package/src/style.scss +2 -2
  253. package/tsconfig.tsbuildinfo +1 -1
  254. package/build/components/block-mobile-toolbar/index.js +0 -42
  255. package/build/components/block-mobile-toolbar/index.js.map +0 -1
  256. package/build/components/block-tools/block-popover.js.map +0 -1
  257. package/build/components/block-tools/use-popover-scroll.js.map +0 -1
  258. package/build/components/border-style-control/index.js +0 -60
  259. package/build/components/border-style-control/index.js.map +0 -1
  260. package/build/components/list-view/appender.js +0 -93
  261. package/build/components/list-view/appender.js.map +0 -1
  262. package/build/components/list-view/list-item.js +0 -62
  263. package/build/components/list-view/list-item.js.map +0 -1
  264. package/build/components/rich-text/use-caret-in-format.js +0 -43
  265. package/build/components/rich-text/use-caret-in-format.js.map +0 -1
  266. package/build/hooks/border-color.js +0 -302
  267. package/build/hooks/border-color.js.map +0 -1
  268. package/build/hooks/border-style.js +0 -96
  269. package/build/hooks/border-style.js.map +0 -1
  270. package/build/hooks/border-width.js +0 -162
  271. package/build/hooks/border-width.js.map +0 -1
  272. package/build-module/components/block-mobile-toolbar/index.js +0 -31
  273. package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
  274. package/build-module/components/block-tools/block-popover.js.map +0 -1
  275. package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
  276. package/build-module/components/border-style-control/index.js +0 -50
  277. package/build-module/components/border-style-control/index.js.map +0 -1
  278. package/build-module/components/list-view/appender.js +0 -76
  279. package/build-module/components/list-view/appender.js.map +0 -1
  280. package/build-module/components/list-view/list-item.js +0 -47
  281. package/build-module/components/list-view/list-item.js.map +0 -1
  282. package/build-module/components/rich-text/use-caret-in-format.js +0 -33
  283. package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
  284. package/build-module/hooks/border-color.js +0 -276
  285. package/build-module/hooks/border-color.js.map +0 -1
  286. package/build-module/hooks/border-style.js +0 -78
  287. package/build-module/hooks/border-style.js.map +0 -1
  288. package/build-module/hooks/border-width.js +0 -143
  289. package/build-module/hooks/border-width.js.map +0 -1
  290. package/src/components/block-mobile-toolbar/index.js +0 -24
  291. package/src/components/block-mobile-toolbar/style.scss +0 -29
  292. package/src/components/border-style-control/index.js +0 -47
  293. package/src/components/border-style-control/style.scss +0 -18
  294. package/src/components/list-view/appender.js +0 -82
  295. package/src/components/list-view/list-item.js +0 -59
  296. package/src/components/rich-text/use-caret-in-format.js +0 -28
  297. package/src/hooks/border-color.js +0 -315
  298. package/src/hooks/border-style.js +0 -64
  299. package/src/hooks/border-width.js +0 -139
@@ -6,60 +6,23 @@ import classNames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { __, _x } from '@wordpress/i18n';
9
+ import { __ } from '@wordpress/i18n';
10
10
  import {
11
11
  ToolbarDropdownMenu,
12
12
  ToolbarGroup,
13
13
  MenuGroup,
14
14
  MenuItem,
15
15
  } from '@wordpress/components';
16
- import {
17
- alignNone,
18
- positionCenter,
19
- positionLeft,
20
- positionRight,
21
- stretchFullWidth,
22
- stretchWide,
23
- } from '@wordpress/icons';
24
- import { Platform } from '@wordpress/element';
25
16
 
26
17
  /**
27
18
  * Internal dependencies
28
19
  */
29
20
  import useAvailableAlignments from './use-available-alignments';
30
-
31
- const BLOCK_ALIGNMENTS_CONTROLS = {
32
- none: {
33
- icon: alignNone,
34
- title: _x( 'None', 'Alignment option' ),
35
- },
36
- left: {
37
- icon: positionLeft,
38
- title: __( 'Align left' ),
39
- },
40
- center: {
41
- icon: positionCenter,
42
- title: __( 'Align center' ),
43
- },
44
- right: {
45
- icon: positionRight,
46
- title: __( 'Align right' ),
47
- },
48
- wide: {
49
- icon: stretchWide,
50
- title: __( 'Wide width' ),
51
- },
52
- full: {
53
- icon: stretchFullWidth,
54
- title: __( 'Full width' ),
55
- },
56
- };
57
-
58
- const DEFAULT_CONTROL = 'none';
59
-
60
- const POPOVER_PROPS = {
61
- isAlternate: true,
62
- };
21
+ import {
22
+ BLOCK_ALIGNMENTS_CONTROLS,
23
+ DEFAULT_CONTROL,
24
+ POPOVER_PROPS,
25
+ } from './constants';
63
26
 
64
27
  function BlockAlignmentUI( {
65
28
  value,
@@ -92,72 +55,69 @@ function BlockAlignmentUI( {
92
55
  label: __( 'Align' ),
93
56
  toggleProps: { describedBy: __( 'Change alignment' ) },
94
57
  };
95
- const extraProps =
96
- isToolbar || Platform.isNative
97
- ? {
98
- isCollapsed: isToolbar ? isCollapsed : undefined,
99
- controls: enabledControls.map(
100
- ( { name: controlName } ) => {
101
- return {
102
- ...BLOCK_ALIGNMENTS_CONTROLS[ controlName ],
103
- isActive:
104
- value === controlName ||
105
- ( ! value && controlName === 'none' ),
106
- role: isCollapsed ? 'menuitemradio' : undefined,
107
- onClick: () => onChangeAlignment( controlName ),
108
- };
109
- }
110
- ),
111
- }
112
- : {
113
- children: ( { onClose } ) => {
114
- return (
115
- <>
116
- <MenuGroup className="block-editor-block-alignment-control__menu-group">
117
- { enabledControls.map(
118
- ( { name: controlName, info } ) => {
119
- const {
120
- icon,
121
- title,
122
- } = BLOCK_ALIGNMENTS_CONTROLS[
123
- controlName
124
- ];
125
- // If no value is provided, mark as selected the `none` option.
126
- const isSelected =
127
- controlName === value ||
128
- ( ! value &&
129
- controlName === 'none' );
130
- return (
131
- <MenuItem
132
- key={ controlName }
133
- icon={ icon }
134
- iconPosition="left"
135
- className={ classNames(
136
- 'components-dropdown-menu__menu-item',
137
- {
138
- 'is-active': isSelected,
139
- }
140
- ) }
141
- isSelected={ isSelected }
142
- onClick={ () => {
143
- onChangeAlignment(
144
- controlName
145
- );
146
- onClose();
147
- } }
148
- role="menuitemradio"
149
- info={ info }
150
- >
151
- { title }
152
- </MenuItem>
153
- );
154
- }
155
- ) }
156
- </MenuGroup>
157
- </>
158
- );
159
- },
160
- };
58
+ const extraProps = isToolbar
59
+ ? {
60
+ isCollapsed,
61
+ controls: enabledControls.map( ( { name: controlName } ) => {
62
+ return {
63
+ ...BLOCK_ALIGNMENTS_CONTROLS[ controlName ],
64
+ isActive:
65
+ value === controlName ||
66
+ ( ! value && controlName === 'none' ),
67
+ role: isCollapsed ? 'menuitemradio' : undefined,
68
+ onClick: () => onChangeAlignment( controlName ),
69
+ };
70
+ } ),
71
+ }
72
+ : {
73
+ children: ( { onClose } ) => {
74
+ return (
75
+ <>
76
+ <MenuGroup className="block-editor-block-alignment-control__menu-group">
77
+ { enabledControls.map(
78
+ ( { name: controlName, info } ) => {
79
+ const {
80
+ icon,
81
+ title,
82
+ } = BLOCK_ALIGNMENTS_CONTROLS[
83
+ controlName
84
+ ];
85
+ // If no value is provided, mark as selected the `none` option.
86
+ const isSelected =
87
+ controlName === value ||
88
+ ( ! value &&
89
+ controlName === 'none' );
90
+ return (
91
+ <MenuItem
92
+ key={ controlName }
93
+ icon={ icon }
94
+ iconPosition="left"
95
+ className={ classNames(
96
+ 'components-dropdown-menu__menu-item',
97
+ {
98
+ 'is-active': isSelected,
99
+ }
100
+ ) }
101
+ isSelected={ isSelected }
102
+ onClick={ () => {
103
+ onChangeAlignment(
104
+ controlName
105
+ );
106
+ onClose();
107
+ } }
108
+ role="menuitemradio"
109
+ info={ info }
110
+ >
111
+ { title }
112
+ </MenuItem>
113
+ );
114
+ }
115
+ ) }
116
+ </MenuGroup>
117
+ </>
118
+ );
119
+ },
120
+ };
161
121
 
162
122
  return <UIComponent { ...commonProps } { ...extraProps } />;
163
123
  }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import {
6
+ ToolbarDropdownMenu,
7
+ ToolbarGroup,
8
+ BottomSheetSelectControl,
9
+ } from '@wordpress/components';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import useAvailableAlignments from './use-available-alignments';
15
+ import {
16
+ BLOCK_ALIGNMENTS_CONTROLS,
17
+ DEFAULT_CONTROL,
18
+ POPOVER_PROPS,
19
+ } from './constants';
20
+
21
+ function BlockAlignmentUI( {
22
+ value,
23
+ onChange,
24
+ controls,
25
+ isToolbar,
26
+ isCollapsed = true,
27
+ isBottomSheetControl = false,
28
+ } ) {
29
+ const enabledControls = useAvailableAlignments( controls );
30
+ const hasEnabledControls = !! enabledControls.length;
31
+
32
+ if ( ! hasEnabledControls ) {
33
+ return null;
34
+ }
35
+
36
+ function onChangeAlignment( align ) {
37
+ onChange( [ value, 'none' ].includes( align ) ? undefined : align );
38
+ }
39
+
40
+ const activeAlignmentControl = BLOCK_ALIGNMENTS_CONTROLS[ value ];
41
+ const defaultAlignmentControl =
42
+ BLOCK_ALIGNMENTS_CONTROLS[ DEFAULT_CONTROL ];
43
+
44
+ const toolbarUIComponent = isToolbar ? ToolbarGroup : ToolbarDropdownMenu;
45
+ const UIComponent = isBottomSheetControl
46
+ ? BottomSheetSelectControl
47
+ : toolbarUIComponent;
48
+
49
+ const commonProps = {
50
+ label: __( 'Align' ),
51
+ };
52
+ const extraProps = isBottomSheetControl
53
+ ? {
54
+ options: enabledControls.map( ( { name: controlName } ) => {
55
+ const control = BLOCK_ALIGNMENTS_CONTROLS[ controlName ];
56
+ return {
57
+ value: controlName,
58
+ label: control.title,
59
+ icon: control.icon,
60
+ };
61
+ } ),
62
+ value: activeAlignmentControl ? value : 'none',
63
+ onChange: ( align ) => onChangeAlignment( align ),
64
+ }
65
+ : {
66
+ icon: activeAlignmentControl
67
+ ? activeAlignmentControl.icon
68
+ : defaultAlignmentControl.icon,
69
+ isCollapsed: isToolbar ? isCollapsed : undefined,
70
+ controls: enabledControls.map( ( { name: controlName } ) => {
71
+ return {
72
+ ...BLOCK_ALIGNMENTS_CONTROLS[ controlName ],
73
+ isActive:
74
+ value === controlName ||
75
+ ( ! value && controlName === 'none' ),
76
+ onClick: () => onChangeAlignment( controlName ),
77
+ };
78
+ } ),
79
+ popoverProps: POPOVER_PROPS,
80
+ toggleProps: { describedBy: __( 'Change alignment' ) },
81
+ };
82
+
83
+ return <UIComponent { ...commonProps } { ...extraProps } />;
84
+ }
85
+
86
+ export default BlockAlignmentUI;
@@ -25,6 +25,7 @@ export default function BlockContentOverlay( {
25
25
  const [ isHovered, setIsHovered ] = useState( false );
26
26
 
27
27
  const {
28
+ canEdit,
28
29
  isParentSelected,
29
30
  hasChildSelected,
30
31
  isDraggingBlocks,
@@ -36,8 +37,10 @@ export default function BlockContentOverlay( {
36
37
  hasSelectedInnerBlock,
37
38
  isDraggingBlocks: _isDraggingBlocks,
38
39
  isBlockHighlighted,
40
+ canEditBlock,
39
41
  } = select( blockEditorStore );
40
42
  return {
43
+ canEdit: canEditBlock( clientId ),
41
44
  isParentSelected: isBlockSelected( clientId ),
42
45
  hasChildSelected: hasSelectedInnerBlock( clientId, true ),
43
46
  isDraggingBlocks: _isDraggingBlocks(),
@@ -59,6 +62,12 @@ export default function BlockContentOverlay( {
59
62
  );
60
63
 
61
64
  useEffect( () => {
65
+ // The overlay is always active when editing is locked.
66
+ if ( ! canEdit ) {
67
+ setIsOverlayActive( true );
68
+ return;
69
+ }
70
+
62
71
  // Reenable when blocks are not in use.
63
72
  if ( ! isParentSelected && ! hasChildSelected && ! isOverlayActive ) {
64
73
  setIsOverlayActive( true );
@@ -75,7 +84,13 @@ export default function BlockContentOverlay( {
75
84
  if ( hasChildSelected && isOverlayActive ) {
76
85
  setIsOverlayActive( false );
77
86
  }
78
- }, [ isParentSelected, hasChildSelected, isOverlayActive, isHovered ] );
87
+ }, [
88
+ isParentSelected,
89
+ hasChildSelected,
90
+ isOverlayActive,
91
+ isHovered,
92
+ canEdit,
93
+ ] );
79
94
 
80
95
  // Disabled because the overlay div doesn't actually have a role or functionality
81
96
  // as far as the a11y is concerned. We're just catching the first click so that
@@ -88,7 +103,9 @@ export default function BlockContentOverlay( {
88
103
  onMouseEnter={ () => setIsHovered( true ) }
89
104
  onMouseLeave={ () => setIsHovered( false ) }
90
105
  onMouseUp={
91
- isOverlayActive ? () => setIsOverlayActive( false ) : undefined
106
+ isOverlayActive && canEdit
107
+ ? () => setIsOverlayActive( false )
108
+ : undefined
92
109
  }
93
110
  >
94
111
  { wrapperProps?.children }
@@ -47,6 +47,7 @@ function BlockForType( {
47
47
  onDeleteBlock,
48
48
  onReplace,
49
49
  parentWidth,
50
+ parentBlockAlignment,
50
51
  wrapperProps,
51
52
  blockWidth,
52
53
  baseGlobalStyles,
@@ -95,6 +96,7 @@ function BlockForType( {
95
96
  contentStyle={ contentStyle }
96
97
  onDeleteBlock={ onDeleteBlock }
97
98
  blockWidth={ blockWidth }
99
+ parentBlockAlignment={ parentBlockAlignment }
98
100
  />
99
101
  <View onLayout={ getBlockWidth } />
100
102
  </GlobalStylesContext.Provider>
@@ -262,12 +262,17 @@
262
262
  right: $border-width;
263
263
  bottom: $border-width;
264
264
  box-shadow: 0 0 0 $border-width var(--wp-admin-theme-color);
265
- border-radius: $radius-block-ui - $border-width; // Border is outset, so subtract the width to achieve correct radius.
265
+ // Border is outset, so subtract the width to achieve correct radius.
266
+ border-radius: $radius-block-ui - $border-width;
266
267
  }
267
268
  }
268
269
 
269
270
  &.is-selected {
270
- cursor: unset;
271
+ cursor: default;
272
+
273
+ &.rich-text {
274
+ cursor: unset;
275
+ }
271
276
 
272
277
  &::after {
273
278
  box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); // Selected not focussed.
@@ -303,22 +308,6 @@
303
308
  }
304
309
  }
305
310
 
306
- // Active entity spotlight.
307
- // Disable if focus mode is active.
308
- .is-root-container:not(.is-focus-mode) .block-editor-block-list__block.has-active-entity {
309
- opacity: 0.5;
310
- transition: opacity 0.1s linear;
311
- @include reduce-motion("transition");
312
-
313
- &.is-active-entity,
314
- &.has-child-selected,
315
- &:not(.has-child-selected) .block-editor-block-list__block,
316
- &.is-active-entity .block-editor-block-list__block,
317
- .is-active-entity .block-editor-block-list__block {
318
- opacity: 1;
319
- }
320
- }
321
-
322
311
  .wp-block[data-align="left"] > *,
323
312
  .wp-block[data-align="right"] > *,
324
313
  .wp-block.alignleft,
@@ -33,12 +33,8 @@ export function useBlockClassNames( clientId ) {
33
33
  getSettings,
34
34
  hasSelectedInnerBlock,
35
35
  isTyping,
36
- __experimentalGetActiveBlockIdByBlockNames: getActiveBlockIdByBlockNames,
37
36
  } = select( blockEditorStore );
38
- const {
39
- __experimentalSpotlightEntityBlocks: spotlightEntityBlocks,
40
- outlineMode,
41
- } = getSettings();
37
+ const { outlineMode } = getSettings();
42
38
  const isDragging = isBlockBeingDragged( clientId );
43
39
  const isSelected = isBlockSelected( clientId );
44
40
  const name = getBlockName( clientId );
@@ -48,9 +44,6 @@ export function useBlockClassNames( clientId ) {
48
44
  clientId,
49
45
  checkDeep
50
46
  );
51
- const activeEntityBlockId = getActiveBlockIdByBlockNames(
52
- spotlightEntityBlocks
53
- );
54
47
  return classnames( {
55
48
  'is-selected': isSelected,
56
49
  'is-highlighted': isBlockHighlighted( clientId ),
@@ -58,9 +51,6 @@ export function useBlockClassNames( clientId ) {
58
51
  'is-reusable': isReusableBlock( getBlockType( name ) ),
59
52
  'is-dragging': isDragging,
60
53
  'has-child-selected': isAncestorOfSelectedBlock,
61
- 'has-active-entity': activeEntityBlockId,
62
- // Determine if there is an active entity area to spotlight.
63
- 'is-active-entity': activeEntityBlockId === clientId,
64
54
  'remove-outline': isSelected && outlineMode && isTyping(),
65
55
  } );
66
56
  },
@@ -13,7 +13,8 @@ import {
13
13
  } from '@wordpress/components';
14
14
  import { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons';
15
15
  import { useInstanceId } from '@wordpress/compose';
16
- import { useDispatch } from '@wordpress/data';
16
+ import { useDispatch, useSelect } from '@wordpress/data';
17
+ import { isReusableBlock, getBlockType } from '@wordpress/blocks';
17
18
 
18
19
  /**
19
20
  * Internal dependencies
@@ -24,7 +25,18 @@ import { store as blockEditorStore } from '../../store';
24
25
 
25
26
  export default function BlockLockModal( { clientId, onClose } ) {
26
27
  const [ lock, setLock ] = useState( { move: false, remove: false } );
27
- const { canMove, canRemove } = useBlockLock( clientId );
28
+ const { canEdit, canMove, canRemove } = useBlockLock( clientId );
29
+ const { isReusable } = useSelect(
30
+ ( select ) => {
31
+ const { getBlockName } = select( blockEditorStore );
32
+ const blockName = getBlockName( clientId );
33
+
34
+ return {
35
+ isReusable: isReusableBlock( getBlockType( blockName ) ),
36
+ };
37
+ },
38
+ [ clientId ]
39
+ );
28
40
  const { updateBlockAttributes } = useDispatch( blockEditorStore );
29
41
  const blockInformation = useBlockDisplayInformation( clientId );
30
42
  const instanceId = useInstanceId(
@@ -36,8 +48,9 @@ export default function BlockLockModal( { clientId, onClose } ) {
36
48
  setLock( {
37
49
  move: ! canMove,
38
50
  remove: ! canRemove,
51
+ ...( isReusable ? { edit: ! canEdit } : {} ),
39
52
  } );
40
- }, [ canMove, canRemove ] );
53
+ }, [ canEdit, canMove, canRemove, isReusable ] );
41
54
 
42
55
  const isAllChecked = Object.values( lock ).every( Boolean );
43
56
  const isMixed = Object.values( lock ).some( Boolean ) && ! isAllChecked;
@@ -81,10 +94,36 @@ export default function BlockLockModal( { clientId, onClose } ) {
81
94
  setLock( {
82
95
  move: newValue,
83
96
  remove: newValue,
97
+ ...( isReusable ? { edit: newValue } : {} ),
84
98
  } )
85
99
  }
86
100
  />
87
101
  <ul className="block-editor-block-lock-modal__checklist">
102
+ { isReusable && (
103
+ <li className="block-editor-block-lock-modal__checklist-item">
104
+ <CheckboxControl
105
+ label={
106
+ <>
107
+ { __( 'Restrict editing' ) }
108
+ <Icon
109
+ icon={
110
+ lock.edit
111
+ ? lockIcon
112
+ : unlockIcon
113
+ }
114
+ />
115
+ </>
116
+ }
117
+ checked={ !! lock.edit }
118
+ onChange={ ( edit ) =>
119
+ setLock( ( prevLock ) => ( {
120
+ ...prevLock,
121
+ edit,
122
+ } ) )
123
+ }
124
+ />
125
+ </li>
126
+ ) }
88
127
  <li className="block-editor-block-lock-modal__checklist-item">
89
128
  <CheckboxControl
90
129
  label={
@@ -15,7 +15,7 @@ import useBlockDisplayInformation from '../use-block-display-information';
15
15
 
16
16
  export default function BlockLockToolbar( { clientId } ) {
17
17
  const blockInformation = useBlockDisplayInformation( clientId );
18
- const { canMove, canRemove, canLock } = useBlockLock( clientId );
18
+ const { canEdit, canMove, canRemove, canLock } = useBlockLock( clientId );
19
19
 
20
20
  const [ isModalOpen, toggleModal ] = useReducer(
21
21
  ( isActive ) => ! isActive,
@@ -26,7 +26,7 @@ export default function BlockLockToolbar( { clientId } ) {
26
26
  return null;
27
27
  }
28
28
 
29
- if ( canMove && canRemove ) {
29
+ if ( canEdit && canMove && canRemove ) {
30
30
  return null;
31
31
  }
32
32
 
@@ -19,6 +19,7 @@ export default function useBlockLock( clientId ) {
19
19
  return useSelect(
20
20
  ( select ) => {
21
21
  const {
22
+ canEditBlock,
22
23
  canMoveBlock,
23
24
  canRemoveBlock,
24
25
  canLockBlockType,
@@ -27,14 +28,16 @@ export default function useBlockLock( clientId ) {
27
28
  } = select( blockEditorStore );
28
29
  const rootClientId = getBlockRootClientId( clientId );
29
30
 
31
+ const canEdit = canEditBlock( clientId );
30
32
  const canMove = canMoveBlock( clientId, rootClientId );
31
33
  const canRemove = canRemoveBlock( clientId, rootClientId );
32
34
 
33
35
  return {
36
+ canEdit,
34
37
  canMove,
35
38
  canRemove,
36
39
  canLock: canLockBlockType( getBlockName( clientId ) ),
37
- isLocked: ! canMove || ! canRemove,
40
+ isLocked: ! canEdit || ! canMove || ! canRemove,
38
41
  };
39
42
  },
40
43
  [ clientId ]
@@ -8,7 +8,7 @@ import { castArray, first, last } from 'lodash';
8
8
  * WordPress dependencies
9
9
  */
10
10
  import { getBlockType } from '@wordpress/blocks';
11
- import { Button } from '@wordpress/components';
11
+ import { Button, VisuallyHidden } from '@wordpress/components';
12
12
  import { useInstanceId } from '@wordpress/compose';
13
13
  import { useSelect, useDispatch } from '@wordpress/data';
14
14
  import { forwardRef } from '@wordpress/element';
@@ -139,12 +139,10 @@ const BlockMoverButton = forwardRef(
139
139
  aria-describedby={ descriptionId }
140
140
  { ...props }
141
141
  onClick={ isDisabled ? null : onClick }
142
- aria-disabled={ isDisabled }
142
+ disabled={ isDisabled }
143
+ __experimentalIsFocusable
143
144
  />
144
- <span
145
- id={ descriptionId }
146
- className="block-editor-block-mover-button__description"
147
- >
145
+ <VisuallyHidden id={ descriptionId }>
148
146
  { getBlockMoverDescription(
149
147
  blocksCount,
150
148
  blockType && blockType.title,
@@ -154,7 +152,7 @@ const BlockMoverButton = forwardRef(
154
152
  direction === 'up' ? -1 : 1,
155
153
  orientation
156
154
  ) }
157
- </span>
155
+ </VisuallyHidden>
158
156
  </>
159
157
  );
160
158
  }