@wordpress/block-editor 14.10.1 → 14.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/build/components/background-image-control/index.js +0 -1
  3. package/build/components/background-image-control/index.js.map +1 -1
  4. package/build/components/block-actions/index.js +0 -3
  5. package/build/components/block-actions/index.js.map +1 -1
  6. package/build/components/block-inspector/index.js +6 -11
  7. package/build/components/block-inspector/index.js.map +1 -1
  8. package/build/components/block-list/use-block-props/use-focus-handler.js +1 -1
  9. package/build/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  10. package/build/components/block-rename/modal.js +36 -11
  11. package/build/components/block-rename/modal.js.map +1 -1
  12. package/build/components/block-rename/rename-control.js +2 -43
  13. package/build/components/block-rename/rename-control.js.map +1 -1
  14. package/build/components/block-settings-menu/block-settings-dropdown.js +12 -3
  15. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  16. package/build/components/block-styles/preview.native.js +1 -1
  17. package/build/components/block-styles/preview.native.js.map +1 -1
  18. package/build/components/block-switcher/block-transformations-menu.js +7 -7
  19. package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
  20. package/build/components/block-switcher/block-variation-transformations.js +2 -2
  21. package/build/components/block-switcher/block-variation-transformations.js.map +1 -1
  22. package/build/components/block-switcher/index.js +1 -1
  23. package/build/components/block-switcher/index.js.map +1 -1
  24. package/build/components/block-switcher/use-transformed-patterns.js +1 -1
  25. package/build/components/block-switcher/use-transformed-patterns.js.map +1 -1
  26. package/build/components/block-toolbar/index.native.js +2 -2
  27. package/build/components/block-toolbar/index.native.js.map +1 -1
  28. package/build/components/date-format-picker/index.js +1 -1
  29. package/build/components/date-format-picker/index.js.map +1 -1
  30. package/build/components/global-styles/filters-panel.js +2 -2
  31. package/build/components/global-styles/filters-panel.js.map +1 -1
  32. package/build/components/global-styles/image-settings-panel.js +2 -2
  33. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  34. package/build/components/global-styles/use-global-styles-output.js +3 -3
  35. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  36. package/build/components/grid/grid-visualizer.js +11 -19
  37. package/build/components/grid/grid-visualizer.js.map +1 -1
  38. package/build/components/grid/utils.js +6 -4
  39. package/build/components/grid/utils.js.map +1 -1
  40. package/build/components/iframe/get-compatibility-styles.js +1 -1
  41. package/build/components/iframe/get-compatibility-styles.js.map +1 -1
  42. package/build/components/iframe/index.js +1 -1
  43. package/build/components/iframe/index.js.map +1 -1
  44. package/build/components/image-size-control/index.js +2 -1
  45. package/build/components/image-size-control/index.js.map +1 -1
  46. package/build/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
  47. package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  48. package/build/components/inserter/menu.js +13 -2
  49. package/build/components/inserter/menu.js.map +1 -1
  50. package/build/components/inserter/reusable-blocks-tab.native.js +1 -1
  51. package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  52. package/build/components/inspector-controls-tabs/position-controls-panel.js +49 -21
  53. package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  54. package/build/components/line-height-control/index.native.js +1 -1
  55. package/build/components/line-height-control/index.native.js.map +1 -1
  56. package/build/components/link-control/index.js +1 -1
  57. package/build/components/link-control/index.js.map +1 -1
  58. package/build/components/link-control/use-search-handler.js +1 -1
  59. package/build/components/link-control/use-search-handler.js.map +1 -1
  60. package/build/components/list-view/block-select-button.js +5 -2
  61. package/build/components/list-view/block-select-button.js.map +1 -1
  62. package/build/components/media-placeholder/index.js +1 -0
  63. package/build/components/media-placeholder/index.js.map +1 -1
  64. package/build/components/observe-typing/index.js +1 -1
  65. package/build/components/observe-typing/index.js.map +1 -1
  66. package/build/components/provider/index.js +0 -2
  67. package/build/components/provider/index.js.map +1 -1
  68. package/build/components/provider/use-block-sync.js +2 -2
  69. package/build/components/provider/use-block-sync.js.map +1 -1
  70. package/build/components/rich-text/event-listeners/input-rules.js +3 -3
  71. package/build/components/rich-text/event-listeners/input-rules.js.map +1 -1
  72. package/build/components/rich-text/native/use-format-types.js +1 -1
  73. package/build/components/rich-text/native/use-format-types.js.map +1 -1
  74. package/build/components/rich-text/use-format-types.js +1 -1
  75. package/build/components/rich-text/use-format-types.js.map +1 -1
  76. package/build/components/spacing-sizes-control/index.js +44 -2
  77. package/build/components/spacing-sizes-control/index.js.map +1 -1
  78. package/build/components/spacing-sizes-control/linked-button.js +6 -9
  79. package/build/components/spacing-sizes-control/linked-button.js.map +1 -1
  80. package/build/components/spacing-sizes-control/utils.js +0 -108
  81. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  82. package/build/components/tabbed-sidebar/index.js +39 -0
  83. package/build/components/tabbed-sidebar/index.js.map +1 -1
  84. package/build/components/typewriter/index.js +1 -1
  85. package/build/components/typewriter/index.js.map +1 -1
  86. package/build/components/url-popover/image-url-input-ui.js +3 -3
  87. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  88. package/build/components/use-block-commands/index.js +1 -1
  89. package/build/components/use-block-commands/index.js.map +1 -1
  90. package/build/components/use-moving-animation/index.js +1 -1
  91. package/build/components/use-moving-animation/index.js.map +1 -1
  92. package/build/hooks/contrast-checker.js +41 -22
  93. package/build/hooks/contrast-checker.js.map +1 -1
  94. package/build/hooks/custom-class-name.js +2 -1
  95. package/build/hooks/custom-class-name.js.map +1 -1
  96. package/build/store/actions.js +1 -1
  97. package/build/store/actions.js.map +1 -1
  98. package/build/store/selectors.js +18 -7
  99. package/build/store/selectors.js.map +1 -1
  100. package/build/utils/transform-styles/index.js +1 -1
  101. package/build/utils/transform-styles/index.js.map +1 -1
  102. package/build/utils/use-notify-copy.js +19 -11
  103. package/build/utils/use-notify-copy.js.map +1 -1
  104. package/build-module/components/background-image-control/index.js +0 -1
  105. package/build-module/components/background-image-control/index.js.map +1 -1
  106. package/build-module/components/block-actions/index.js +0 -3
  107. package/build-module/components/block-actions/index.js.map +1 -1
  108. package/build-module/components/block-inspector/index.js +6 -11
  109. package/build-module/components/block-inspector/index.js.map +1 -1
  110. package/build-module/components/block-list/use-block-props/use-focus-handler.js +1 -1
  111. package/build-module/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  112. package/build-module/components/block-rename/modal.js +36 -11
  113. package/build-module/components/block-rename/modal.js.map +1 -1
  114. package/build-module/components/block-rename/rename-control.js +2 -43
  115. package/build-module/components/block-rename/rename-control.js.map +1 -1
  116. package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -3
  117. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  118. package/build-module/components/block-styles/preview.native.js +1 -1
  119. package/build-module/components/block-styles/preview.native.js.map +1 -1
  120. package/build-module/components/block-switcher/block-transformations-menu.js +7 -7
  121. package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
  122. package/build-module/components/block-switcher/block-variation-transformations.js +2 -2
  123. package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -1
  124. package/build-module/components/block-switcher/index.js +1 -1
  125. package/build-module/components/block-switcher/index.js.map +1 -1
  126. package/build-module/components/block-switcher/use-transformed-patterns.js +1 -1
  127. package/build-module/components/block-switcher/use-transformed-patterns.js.map +1 -1
  128. package/build-module/components/block-toolbar/index.native.js +2 -2
  129. package/build-module/components/block-toolbar/index.native.js.map +1 -1
  130. package/build-module/components/date-format-picker/index.js +1 -1
  131. package/build-module/components/date-format-picker/index.js.map +1 -1
  132. package/build-module/components/global-styles/filters-panel.js +2 -2
  133. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  134. package/build-module/components/global-styles/image-settings-panel.js +2 -2
  135. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  136. package/build-module/components/global-styles/use-global-styles-output.js +3 -3
  137. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  138. package/build-module/components/grid/grid-visualizer.js +11 -19
  139. package/build-module/components/grid/grid-visualizer.js.map +1 -1
  140. package/build-module/components/grid/utils.js +6 -4
  141. package/build-module/components/grid/utils.js.map +1 -1
  142. package/build-module/components/iframe/get-compatibility-styles.js +1 -1
  143. package/build-module/components/iframe/get-compatibility-styles.js.map +1 -1
  144. package/build-module/components/iframe/index.js +1 -1
  145. package/build-module/components/iframe/index.js.map +1 -1
  146. package/build-module/components/image-size-control/index.js +3 -2
  147. package/build-module/components/image-size-control/index.js.map +1 -1
  148. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
  149. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  150. package/build-module/components/inserter/menu.js +13 -2
  151. package/build-module/components/inserter/menu.js.map +1 -1
  152. package/build-module/components/inserter/reusable-blocks-tab.native.js +1 -1
  153. package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  154. package/build-module/components/inspector-controls-tabs/position-controls-panel.js +51 -23
  155. package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  156. package/build-module/components/line-height-control/index.native.js +1 -1
  157. package/build-module/components/line-height-control/index.native.js.map +1 -1
  158. package/build-module/components/link-control/index.js +1 -1
  159. package/build-module/components/link-control/index.js.map +1 -1
  160. package/build-module/components/link-control/use-search-handler.js +1 -1
  161. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  162. package/build-module/components/list-view/block-select-button.js +6 -3
  163. package/build-module/components/list-view/block-select-button.js.map +1 -1
  164. package/build-module/components/media-placeholder/index.js +1 -0
  165. package/build-module/components/media-placeholder/index.js.map +1 -1
  166. package/build-module/components/observe-typing/index.js +1 -1
  167. package/build-module/components/observe-typing/index.js.map +1 -1
  168. package/build-module/components/provider/index.js +0 -1
  169. package/build-module/components/provider/index.js.map +1 -1
  170. package/build-module/components/provider/use-block-sync.js +2 -2
  171. package/build-module/components/provider/use-block-sync.js.map +1 -1
  172. package/build-module/components/rich-text/event-listeners/input-rules.js +3 -3
  173. package/build-module/components/rich-text/event-listeners/input-rules.js.map +1 -1
  174. package/build-module/components/rich-text/native/use-format-types.js +1 -1
  175. package/build-module/components/rich-text/native/use-format-types.js.map +1 -1
  176. package/build-module/components/rich-text/use-format-types.js +1 -1
  177. package/build-module/components/rich-text/use-format-types.js.map +1 -1
  178. package/build-module/components/spacing-sizes-control/index.js +45 -1
  179. package/build-module/components/spacing-sizes-control/index.js.map +1 -1
  180. package/build-module/components/spacing-sizes-control/linked-button.js +7 -10
  181. package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -1
  182. package/build-module/components/spacing-sizes-control/utils.js +0 -104
  183. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  184. package/build-module/components/tabbed-sidebar/index.js +39 -0
  185. package/build-module/components/tabbed-sidebar/index.js.map +1 -1
  186. package/build-module/components/typewriter/index.js +1 -1
  187. package/build-module/components/typewriter/index.js.map +1 -1
  188. package/build-module/components/url-popover/image-url-input-ui.js +3 -3
  189. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  190. package/build-module/components/use-block-commands/index.js +1 -1
  191. package/build-module/components/use-block-commands/index.js.map +1 -1
  192. package/build-module/components/use-moving-animation/index.js +1 -1
  193. package/build-module/components/use-moving-animation/index.js.map +1 -1
  194. package/build-module/hooks/contrast-checker.js +42 -23
  195. package/build-module/hooks/contrast-checker.js.map +1 -1
  196. package/build-module/hooks/custom-class-name.js +2 -1
  197. package/build-module/hooks/custom-class-name.js.map +1 -1
  198. package/build-module/store/actions.js +1 -1
  199. package/build-module/store/actions.js.map +1 -1
  200. package/build-module/store/selectors.js +18 -7
  201. package/build-module/store/selectors.js.map +1 -1
  202. package/build-module/utils/transform-styles/index.js +1 -1
  203. package/build-module/utils/transform-styles/index.js.map +1 -1
  204. package/build-module/utils/use-notify-copy.js +19 -11
  205. package/build-module/utils/use-notify-copy.js.map +1 -1
  206. package/build-style/content-rtl.css +0 -9
  207. package/build-style/content.css +0 -9
  208. package/build-style/style-rtl.css +19 -21
  209. package/build-style/style.css +19 -21
  210. package/package.json +34 -33
  211. package/src/components/background-image-control/index.js +0 -1
  212. package/src/components/block-actions/index.js +0 -3
  213. package/src/components/block-icon/content.scss +1 -1
  214. package/src/components/{block-card → block-icon}/stories/index.story.js +16 -26
  215. package/src/components/block-icon/style.scss +1 -1
  216. package/src/components/block-inspector/index.js +7 -10
  217. package/src/components/block-list/use-block-props/use-focus-handler.js +1 -1
  218. package/src/components/block-preview/style.scss +1 -1
  219. package/src/components/block-rename/modal.js +40 -12
  220. package/src/components/block-rename/rename-control.js +1 -53
  221. package/src/components/block-settings-menu/block-settings-dropdown.js +16 -2
  222. package/src/components/block-styles/preview.native.js +1 -1
  223. package/src/components/block-switcher/block-transformations-menu.js +9 -9
  224. package/src/components/block-switcher/block-variation-transformations.js +2 -2
  225. package/src/components/block-switcher/index.js +1 -1
  226. package/src/components/block-switcher/use-transformed-patterns.js +1 -1
  227. package/src/components/block-toolbar/index.native.js +2 -2
  228. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  229. package/src/components/colors-gradients/style.scss +1 -0
  230. package/src/components/colors-gradients/test/control.js +2 -2
  231. package/src/components/date-format-picker/index.js +1 -1
  232. package/src/components/duotone-control/style.scss +2 -2
  233. package/src/components/global-styles/filters-panel.js +4 -2
  234. package/src/components/global-styles/image-settings-panel.js +2 -2
  235. package/src/components/global-styles/test/typography-utils.js +1 -1
  236. package/src/components/global-styles/use-global-styles-output.js +3 -3
  237. package/src/components/grid/grid-visualizer.js +10 -21
  238. package/src/components/grid/style.scss +1 -0
  239. package/src/components/grid/utils.js +6 -4
  240. package/src/components/iframe/get-compatibility-styles.js +1 -1
  241. package/src/components/iframe/index.js +1 -1
  242. package/src/components/image-size-control/index.js +6 -2
  243. package/src/components/inner-blocks/README.md +1 -1
  244. package/src/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
  245. package/src/components/inserter/menu.js +11 -9
  246. package/src/components/inserter/reusable-blocks-tab.native.js +1 -1
  247. package/src/components/inspector-controls-tabs/position-controls-panel.js +62 -27
  248. package/src/components/line-height-control/index.native.js +1 -1
  249. package/src/components/link-control/README.md +2 -2
  250. package/src/components/link-control/index.js +1 -1
  251. package/src/components/link-control/test/index.js +3 -3
  252. package/src/components/link-control/use-search-handler.js +1 -1
  253. package/src/components/list-view/README.md +1 -1
  254. package/src/components/list-view/block-select-button.js +5 -5
  255. package/src/components/list-view/style.scss +3 -7
  256. package/src/components/media-placeholder/content.scss +0 -8
  257. package/src/components/media-placeholder/index.js +1 -0
  258. package/src/components/media-placeholder/style.scss +7 -0
  259. package/src/components/observe-typing/index.js +1 -1
  260. package/src/components/provider/index.js +0 -1
  261. package/src/components/provider/use-block-sync.js +2 -2
  262. package/src/components/resolution-tool/stories/index.story.js +52 -2
  263. package/src/components/rich-text/README.md +1 -1
  264. package/src/components/rich-text/event-listeners/input-rules.js +3 -3
  265. package/src/components/rich-text/native/use-format-types.js +1 -1
  266. package/src/components/rich-text/use-format-types.js +1 -1
  267. package/src/components/spacing-sizes-control/README.md +93 -0
  268. package/src/components/spacing-sizes-control/index.js +44 -1
  269. package/src/components/spacing-sizes-control/linked-button.js +8 -10
  270. package/src/components/spacing-sizes-control/test/utils.js +0 -151
  271. package/src/components/spacing-sizes-control/utils.js +0 -106
  272. package/src/components/tabbed-sidebar/README.md +24 -13
  273. package/src/components/tabbed-sidebar/index.js +38 -0
  274. package/src/components/tabbed-sidebar/stories/index.story.js +104 -0
  275. package/src/components/typewriter/index.js +1 -1
  276. package/src/components/unit-control/README.md +1 -1
  277. package/src/components/unit-control/stories/index.story.js +124 -0
  278. package/src/components/url-popover/image-url-input-ui.js +3 -3
  279. package/src/components/use-block-commands/index.js +1 -1
  280. package/src/components/use-moving-animation/index.js +1 -1
  281. package/src/components/use-settings/README.md +1 -1
  282. package/src/components/warning/content.scss +1 -1
  283. package/src/components/writing-flow/test/index.js +1 -1
  284. package/src/hooks/color.scss +0 -7
  285. package/src/hooks/contrast-checker.js +64 -30
  286. package/src/hooks/custom-class-name.js +2 -1
  287. package/src/store/actions.js +1 -1
  288. package/src/store/selectors.js +20 -12
  289. package/src/store/test/private-selectors.js +1 -1
  290. package/src/store/test/selectors.js +3 -3
  291. package/src/style.scss +1 -0
  292. package/src/utils/test/sorting.js +1 -1
  293. package/src/utils/transform-styles/index.js +1 -1
  294. package/src/utils/use-notify-copy.js +51 -43
  295. package/tsconfig.json +1 -0
@@ -2,11 +2,11 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import {
5
- PanelBody,
6
5
  __experimentalUseSlotFills as useSlotFills,
6
+ __experimentalToolsPanel as ToolsPanel,
7
+ __experimentalToolsPanelItem as ToolsPanelItem,
7
8
  } from '@wordpress/components';
8
- import { useSelect } from '@wordpress/data';
9
- import { useLayoutEffect, useState } from '@wordpress/element';
9
+ import { useDispatch, useSelect } from '@wordpress/data';
10
10
  import { __ } from '@wordpress/i18n';
11
11
 
12
12
  /**
@@ -15,40 +15,75 @@ import { __ } from '@wordpress/i18n';
15
15
  import InspectorControlsGroups from '../inspector-controls/groups';
16
16
  import { default as InspectorControls } from '../inspector-controls';
17
17
  import { store as blockEditorStore } from '../../store';
18
+ import { useToolsPanelDropdownMenuProps } from '../global-styles/utils';
19
+ import { cleanEmptyObject } from '../../hooks/utils';
18
20
 
19
21
  const PositionControlsPanel = () => {
20
- const [ initialOpen, setInitialOpen ] = useState();
22
+ const { selectedClientIds, selectedBlocks, hasPositionAttribute } =
23
+ useSelect( ( select ) => {
24
+ const { getBlocksByClientId, getSelectedBlockClientIds } =
25
+ select( blockEditorStore );
21
26
 
22
- // Determine whether the panel should be expanded.
23
- const { multiSelectedBlocks } = useSelect( ( select ) => {
24
- const { getBlocksByClientId, getSelectedBlockClientIds } =
25
- select( blockEditorStore );
26
- const clientIds = getSelectedBlockClientIds();
27
- return {
28
- multiSelectedBlocks: getBlocksByClientId( clientIds ),
29
- };
30
- }, [] );
27
+ const selectedBlockClientIds = getSelectedBlockClientIds();
28
+ const _selectedBlocks = getBlocksByClientId(
29
+ selectedBlockClientIds
30
+ );
31
31
 
32
- useLayoutEffect( () => {
33
- // If any selected block has a position set, open the panel by default.
34
- // The first block's value will still be used within the control though.
35
- if ( initialOpen === undefined ) {
36
- setInitialOpen(
37
- multiSelectedBlocks.some(
32
+ return {
33
+ selectedClientIds: selectedBlockClientIds,
34
+ selectedBlocks: _selectedBlocks,
35
+ hasPositionAttribute: _selectedBlocks?.some(
38
36
  ( { attributes } ) => !! attributes?.style?.position?.type
39
- )
40
- );
37
+ ),
38
+ };
39
+ }, [] );
40
+
41
+ const { updateBlockAttributes } = useDispatch( blockEditorStore );
42
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
43
+
44
+ function resetPosition() {
45
+ if ( ! selectedClientIds?.length || ! selectedBlocks?.length ) {
46
+ return;
41
47
  }
42
- }, [ initialOpen, multiSelectedBlocks, setInitialOpen ] );
48
+
49
+ const attributesByClientId = Object.fromEntries(
50
+ selectedBlocks?.map( ( { clientId, attributes } ) => [
51
+ clientId,
52
+ {
53
+ style: cleanEmptyObject( {
54
+ ...attributes?.style,
55
+ position: {
56
+ ...attributes?.style?.position,
57
+ type: undefined,
58
+ top: undefined,
59
+ right: undefined,
60
+ bottom: undefined,
61
+ left: undefined,
62
+ },
63
+ } ),
64
+ },
65
+ ] )
66
+ );
67
+
68
+ updateBlockAttributes( selectedClientIds, attributesByClientId, true );
69
+ }
43
70
 
44
71
  return (
45
- <PanelBody
72
+ <ToolsPanel
46
73
  className="block-editor-block-inspector__position"
47
- title={ __( 'Position' ) }
48
- initialOpen={ initialOpen ?? false }
74
+ label={ __( 'Position' ) }
75
+ resetAll={ resetPosition }
76
+ dropdownMenuProps={ dropdownMenuProps }
49
77
  >
50
- <InspectorControls.Slot group="position" />
51
- </PanelBody>
78
+ <ToolsPanelItem
79
+ isShownByDefault={ hasPositionAttribute }
80
+ label={ __( 'Position' ) }
81
+ hasValue={ () => hasPositionAttribute }
82
+ onDeselect={ resetPosition }
83
+ >
84
+ <InspectorControls.Slot group="position" />
85
+ </ToolsPanelItem>
86
+ </ToolsPanel>
52
87
  );
53
88
  };
54
89
 
@@ -14,7 +14,7 @@ export default function LineHeightControl( { value: lineHeight, onChange } ) {
14
14
  return (
15
15
  <UnitControl
16
16
  label={ __( 'Line Height' ) }
17
- // Set minimun value of 1 since lower values break on Android
17
+ // Set minimum value of 1 since lower values break on Android
18
18
  min={ 1 }
19
19
  max={ 5 }
20
20
  step={ STEP }
@@ -50,7 +50,7 @@ Consumers who which to take advantage of this functionality should ensure that t
50
50
  When creating links the `LinkControl` component will handle two kinds of input from users:
51
51
 
52
52
  1. Entity searches - the user may input free-text based search queries for entities retrieved from remote data sources (in the context of WordPress these are post-type entities). For example, a user might search for a `Page` they have just created by name (eg: About) and the UI will return a matching result if found.
53
- 2. Direct entry - the user may also enter any arbitrary URL-like text. This includes full URLs (https://), URL fragements (eg: `#myinternallink`), `tel` protocol links (eg: `tel: 0800 1234`) and `mailto` protocol links (eg: `mailto: hello@wordpress.org`).
53
+ 2. Direct entry - the user may also enter any arbitrary URL-like text. This includes full URLs (https://), URL fragments (eg: `#myinternallink`), `tel` protocol links (eg: `tel: 0800 1234`) and `mailto` protocol links (eg: `mailto: hello@wordpress.org`).
54
54
 
55
55
  In addition, `<LinkControl>` also allows for on the fly creation of links based on the **current content of the `<input>` element**. When enabled, a default "Create new" search suggestion is appended to all non-URL-like search results.
56
56
 
@@ -79,7 +79,7 @@ The resulting default properties of `value` include:
79
79
  - `title` (`string`, optional): Link title.
80
80
  - `opensInNewTab` (`boolean`, optional): Whether link should open in a new browser tab. This value is only assigned when not providing a custom `settings` prop.
81
81
 
82
- Note: `<LinkControl>` maintains an internal state tracking temporary user edits to the link `value` prior to submission. To avoid unwanted synchronization of this internal value, it is advised that the `value` prop is stablized (likely via memozation) before it is passed to the component. This will avoid unwanted loss of any changes users have may made whilst interacting with the control.
82
+ Note: `<LinkControl>` maintains an internal state tracking temporary user edits to the link `value` prior to submission. To avoid unwanted synchronization of this internal value, it is advised that the `value` prop is stabilized (likely via memozation) before it is passed to the component. This will avoid unwanted loss of any changes users have may made whilst interacting with the control.
83
83
 
84
84
  ```jsx
85
85
  const memoizedValue = useMemo(
@@ -265,7 +265,7 @@ function LinkControl( {
265
265
 
266
266
  const handleSelectSuggestion = ( updatedValue ) => {
267
267
  // Suggestions may contains "settings" values (e.g. `opensInNewTab`)
268
- // which should not overide any existing settings values set by the
268
+ // which should not override any existing settings values set by the
269
269
  // user. This filters out any settings values from the suggestion.
270
270
  const nonSettingsChanges = Object.keys( updatedValue ).reduce(
271
271
  ( acc, key ) => {
@@ -31,7 +31,7 @@ const mockFetchSearchSuggestions = jest.fn();
31
31
  /**
32
32
  * The call to the real method `fetchRichUrlData` is wrapped in a promise in order to make it cancellable.
33
33
  * Therefore if we pass any value as the mock of `fetchRichUrlData` then ALL of the tests will require
34
- * addition code to handle the async nature of `fetchRichUrlData`. This is unecessary. Instead we default
34
+ * addition code to handle the async nature of `fetchRichUrlData`. This is unnecessary. Instead we default
35
35
  * to an undefined value which will ensure that the code under test does not call `fetchRichUrlData`. Only
36
36
  * when we are testing the "rich previews" to we update this value with a true mock.
37
37
  */
@@ -354,7 +354,7 @@ describe( 'Basic rendering', () => {
354
354
 
355
355
  it( 'should display human friendly error message if value URL prop is empty when component is forced into no-editing (preview) mode', async () => {
356
356
  // Why do we need this test?
357
- // Occasionally `forceIsEditingLink` is set explictly to `false` which causes the Link UI to render
357
+ // Occasionally `forceIsEditingLink` is set explicitly to `false` which causes the Link UI to render
358
358
  // it's preview even if the `value` has no URL.
359
359
  // for an example of this see the usage in the following file whereby forceIsEditingLink is used to start/stop editing mode:
360
360
  // https://github.com/WordPress/gutenberg/blob/fa5728771df7cdc86369f7157d6aa763649937a7/packages/format-library/src/link/inline.js#L151.
@@ -2422,7 +2422,7 @@ describe( 'Controlling link title text', () => {
2422
2422
 
2423
2423
  it.each( [
2424
2424
  [ '', 'Testing' ],
2425
- [ '(with leading and traling whitespace)', ' Testing ' ],
2425
+ [ '(with leading and trailing whitespace)', ' Testing ' ],
2426
2426
  [
2427
2427
  // Note: link control should always preserve the original value.
2428
2428
  // The consumer is responsible for filtering or otherwise handling the value.
@@ -94,7 +94,7 @@ const handleEntitySearch = async (
94
94
  return isURLLike( val ) || ! withCreateSuggestion
95
95
  ? results
96
96
  : results.concat( {
97
- // the `id` prop is intentionally ommitted here because it
97
+ // the `id` prop is intentionally omitted here because it
98
98
  // is never exposed as part of the component's public API.
99
99
  // see: https://github.com/WordPress/gutenberg/pull/19775#discussion_r378931316.
100
100
  title: val, // Must match the existing `<input>`s text value.
@@ -15,7 +15,7 @@ In addition to presenting the structure of the blocks in the editor, the ListVie
15
15
 
16
16
  ### Usage
17
17
 
18
- Renders a list view with default syles.
18
+ Renders a list view with default styles.
19
19
 
20
20
  ```jsx
21
21
  import { ListView } from '@wordpress/block-editor';
@@ -9,6 +9,7 @@ import clsx from 'clsx';
9
9
  import {
10
10
  __experimentalHStack as HStack,
11
11
  __experimentalTruncate as Truncate,
12
+ privateApis as componentsPrivateApis,
12
13
  } from '@wordpress/components';
13
14
  import { forwardRef } from '@wordpress/element';
14
15
  import { Icon, lockSmall as lock, pinSmall } from '@wordpress/icons';
@@ -25,6 +26,8 @@ import ListViewExpander from './expander';
25
26
  import { useBlockLock } from '../block-lock';
26
27
  import useListViewImages from './use-list-view-images';
27
28
  import { store as blockEditorStore } from '../../store';
29
+ import { unlock } from '../../lock-unlock';
30
+ const { Badge } = unlock( componentsPrivateApis );
28
31
 
29
32
  function ListViewBlockSelectButton(
30
33
  {
@@ -117,12 +120,9 @@ function ListViewBlockSelectButton(
117
120
  </span>
118
121
  { blockInformation?.anchor && (
119
122
  <span className="block-editor-list-view-block-select-button__anchor-wrapper">
120
- <Truncate
121
- className="block-editor-list-view-block-select-button__anchor"
122
- ellipsizeMode="auto"
123
- >
123
+ <Badge className="block-editor-list-view-block-select-button__anchor">
124
124
  { blockInformation.anchor }
125
- </Truncate>
125
+ </Badge>
126
126
  </span>
127
127
  ) }
128
128
  { isSticky && (
@@ -44,7 +44,7 @@
44
44
 
45
45
  svg {
46
46
  fill: currentColor;
47
- // Optimizate for high contrast modes.
47
+ // Optimize for high contrast modes.
48
48
  // See also https://blogs.windows.com/msedgedev/2020/09/17/styling-for-windows-high-contrast-with-new-standards-for-forced-colors/.
49
49
  @media (forced-colors: active) {
50
50
  fill: CanvasText;
@@ -408,15 +408,11 @@
408
408
  position: absolute;
409
409
  right: 0;
410
410
  transform: translateY(-50%);
411
- background: rgba($black, 0.1);
412
- border-radius: $radius-x-small;
413
- padding: 2px 6px;
414
- max-width: 100%;
415
- box-sizing: border-box;
416
411
  }
417
412
 
418
413
  &.is-selected .block-editor-list-view-block-select-button__anchor {
419
414
  background: rgba($black, 0.3);
415
+ color: $white;
420
416
  }
421
417
 
422
418
  .block-editor-list-view-block-select-button__lock,
@@ -484,7 +480,7 @@ $block-navigation-max-indent: 8;
484
480
  .block-editor-list-view-leaf[aria-level="#{ $i + 1 }"]
485
481
  .block-editor-list-view__expander {
486
482
  @if $i - 1 >= 0 {
487
- margin-left: ($grid-unit-30 * $i); // Effectivly centers the expander below the parent's icon.
483
+ margin-left: ($grid-unit-30 * $i); // Effectively centers the expander below the parent's icon.
488
484
  } @else {
489
485
  margin-left: 0;
490
486
  }
@@ -1,11 +1,3 @@
1
- .block-editor-media-placeholder__url-input-form {
2
- min-width: 260px;
3
-
4
- @include break-small() {
5
- width: 300px;
6
- }
7
- }
8
-
9
1
  .block-editor-media-placeholder__cancel-button.is-link {
10
2
  margin: 1em;
11
3
  display: block;
@@ -47,6 +47,7 @@ const InsertFromURLPopover = ( {
47
47
  <InputControl
48
48
  __next40pxDefaultSize
49
49
  label={ __( 'URL' ) }
50
+ type="url"
50
51
  hideLabelFromVision
51
52
  placeholder={ __( 'Paste or type URL' ) }
52
53
  onChange={ onChange }
@@ -0,0 +1,7 @@
1
+ .block-editor-media-placeholder__url-input-form {
2
+ min-width: 260px;
3
+
4
+ @include break-small() {
5
+ width: 300px;
6
+ }
7
+ }
@@ -111,7 +111,7 @@ export function useMouseMoveTypingReset() {
111
111
  * Sets and removes the `isTyping` flag based on user actions:
112
112
  *
113
113
  * - Sets the flag if the user types within the given element.
114
- * - Removes the flag when the user selects some text, focusses a non-text
114
+ * - Removes the flag when the user selects some text, focuses a non-text
115
115
  * field, presses ESC or TAB, or moves the mouse in the document.
116
116
  */
117
117
  export function useTypingObserver() {
@@ -4,7 +4,6 @@
4
4
  import { useDispatch } from '@wordpress/data';
5
5
  import { useEffect, useMemo } from '@wordpress/element';
6
6
  import { SlotFillProvider } from '@wordpress/components';
7
- //eslint-disable-next-line import/no-extraneous-dependencies -- Experimental package, not published.
8
7
  import {
9
8
  MediaUploadProvider,
10
9
  store as uploadStore,
@@ -33,7 +33,7 @@ const noop = () => {};
33
33
  * the template part in the block editor back to the entity and vice-versa.
34
34
  *
35
35
  * Here are some of its basic functions:
36
- * - Initalizes the block-editor store for the given clientID to the blocks
36
+ * - Initializes the block-editor store for the given clientID to the blocks
37
37
  * given via props.
38
38
  * - Adds incoming changes (like undo) to the block-editor store.
39
39
  * - Adds outgoing changes (like editing content) to the controlling entity,
@@ -49,7 +49,7 @@ const noop = () => {};
49
49
  * root controller rather than an inner block
50
50
  * controller.
51
51
  * @param {Object[]} props.value The control value for the blocks. This value
52
- * is used to initalize the block-editor store
52
+ * is used to initialize the block-editor store
53
53
  * and for resetting the blocks to incoming
54
54
  * changes like undo.
55
55
  * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.
@@ -16,9 +16,59 @@ export default {
16
16
  title: 'BlockEditor/ResolutionControl',
17
17
  component: ResolutionTool,
18
18
  tags: [ 'status-private' ],
19
+ parameters: {
20
+ docs: {
21
+ canvas: { sourceState: 'shown' },
22
+ description: {
23
+ component:
24
+ 'A control for selecting image resolution with preset size options.',
25
+ },
26
+ },
27
+ },
19
28
  argTypes: {
20
- panelId: { control: false },
21
- onChange: { action: 'changed' },
29
+ value: {
30
+ control: { type: null },
31
+ description: 'Currently selected resolution value.',
32
+ table: { type: { summary: 'string' } },
33
+ },
34
+ onChange: {
35
+ action: 'onChange',
36
+ control: { type: null },
37
+ description: 'Handles change in resolution selection.',
38
+ table: {
39
+ type: { summary: 'function' },
40
+ },
41
+ },
42
+ options: {
43
+ control: 'object',
44
+ description: 'Array of resolution options to display.',
45
+ table: {
46
+ type: { summary: 'array' },
47
+ },
48
+ },
49
+ defaultValue: {
50
+ control: 'radio',
51
+ options: [ 'thumbnail', 'medium', 'large', 'full' ],
52
+ description: 'Default resolution value.',
53
+ table: {
54
+ type: { summary: 'string' },
55
+ },
56
+ },
57
+ isShownByDefault: {
58
+ control: 'boolean',
59
+ description:
60
+ 'Whether the control is shown by default in the panel.',
61
+ table: {
62
+ type: { summary: 'boolean' },
63
+ },
64
+ },
65
+ panelId: {
66
+ control: { type: null },
67
+ description: 'ID of the parent tools panel.',
68
+ table: {
69
+ type: { summary: 'string' },
70
+ },
71
+ },
22
72
  },
23
73
  };
24
74
 
@@ -52,7 +52,7 @@ _Optional._ By default, all registered formats are allowed. This setting can be
52
52
  tagName="h2"
53
53
  identifier="content"
54
54
  value={ attributes.content }
55
- allowedFormats={ [ 'core/bold', 'core/italic' ] } // Allow the content to be made bold or italic, but do not allow othe formatting options
55
+ allowedFormats={ [ 'core/bold', 'core/italic' ] } // Allow the content to be made bold or italic, but do not allow other formatting options
56
56
  onChange={ ( content ) => setAttributes( { content } ) }
57
57
  placeholder={ __( 'Heading...' ) }
58
58
  />
@@ -112,12 +112,12 @@ export default ( props ) => ( element ) => {
112
112
 
113
113
  const value = getValue();
114
114
  const transformed = formatTypes.reduce(
115
- ( accumlator, { __unstableInputRule } ) => {
115
+ ( accumulator, { __unstableInputRule } ) => {
116
116
  if ( __unstableInputRule ) {
117
- accumlator = __unstableInputRule( accumlator );
117
+ accumulator = __unstableInputRule( accumulator );
118
118
  }
119
119
 
120
- return accumlator;
120
+ return accumulator;
121
121
  },
122
122
  preventEventDiscovery( value )
123
123
  );
@@ -35,7 +35,7 @@ const interactiveContentTags = new Set( [
35
35
  * @param {Object} $0 Options
36
36
  * @param {string} $0.clientId Block client ID.
37
37
  * @param {string} $0.identifier Block attribute.
38
- * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not.
38
+ * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formatting or not.
39
39
  * @param {Array} $0.allowedFormats Allowed formats
40
40
  */
41
41
  export function useFormatTypes( {
@@ -59,7 +59,7 @@ function getPrefixedSelectKeys( selected, prefix ) {
59
59
  * @param {Object} $0 Options
60
60
  * @param {string} $0.clientId Block client ID.
61
61
  * @param {string} $0.identifier Block attribute.
62
- * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not.
62
+ * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formatting or not.
63
63
  * @param {Array} $0.allowedFormats Allowed formats
64
64
  */
65
65
  export function useFormatTypes( {
@@ -0,0 +1,93 @@
1
+ # Spacing Sizes Control
2
+
3
+ The SpacingSizesControl component provides a flexible user interface for controlling spacing values in blocks, allowing users to modify values for different sides. It supports three viewing modes:
4
+
5
+ 1. Single: Control one side at a time.
6
+ 2. Axial: Control horizontal and vertical sides together.
7
+ 3. Custom: Control each side separately.
8
+
9
+ ## Usage
10
+
11
+ ```jsx
12
+ import { __experimentalSpacingSizesControl as SpacingSizesControl } from '@wordpress/block-editor';
13
+ import { useState } from '@wordpress/element';
14
+
15
+ function Example() {
16
+ const [ sides, setSides ] = useState( {
17
+ top: '0px',
18
+ right: '0px',
19
+ bottom: '0px',
20
+ left: '0px',
21
+ } );
22
+
23
+ return (
24
+ <SpacingSizesControl
25
+ values={ sides }
26
+ onChange={ setSides }
27
+ label="Sides"
28
+ />
29
+ );
30
+ }
31
+ ```
32
+
33
+ ## Props
34
+
35
+ ### `inputProps`
36
+
37
+ - Type: `Object`
38
+ - Required: No
39
+ - Description: Additional props to pass to the input controls.
40
+
41
+ ### `label`
42
+
43
+ - Type: `String`
44
+ - Required: Yes
45
+ - Description: Label for the control.
46
+
47
+ ### `minimumCustomValue`
48
+
49
+ - Type: `Number`
50
+ - Default: 0
51
+ - Description: Minimum value allowed for custom input.
52
+
53
+ ### `onChange`
54
+
55
+ - Type: `Function`
56
+ - Required: Yes
57
+ - Description: Callback function called when spacing values change. Receives an object containing the updated values.
58
+
59
+ ### `onMouseOut`
60
+
61
+ - Type: `Function`
62
+ - Required: No
63
+ - Description: Callback function called when mouse leaves the control.
64
+
65
+ ### `onMouseOver`
66
+
67
+ - Type: `Function`
68
+ - Required: No
69
+ - Description: Callback function called when mouse enters the control.
70
+
71
+ ### `showSideInLabel`
72
+
73
+ - Type: `Boolean`
74
+ - Default: true
75
+ - Description: Whether to show the side (top, right, etc.) in the control label.
76
+
77
+ ### `sides`
78
+
79
+ - Type: `Array`
80
+ - Default: ALL_SIDES (top, right, bottom, left)
81
+ - Description: Array of sides that can be controlled.
82
+
83
+ ### `useSelect`
84
+
85
+ - Type: `Boolean`
86
+ - Required: No
87
+ - Description: Whether to use a select control for predefined values.
88
+
89
+ ### `values`
90
+
91
+ - Type: `Object`
92
+ - Required: No
93
+ - Description: Object containing the current spacing values for each side.
@@ -12,11 +12,11 @@ import { _x, sprintf } from '@wordpress/i18n';
12
12
  /**
13
13
  * Internal dependencies
14
14
  */
15
+ import useSpacingSizes from './hooks/use-spacing-sizes';
15
16
  import AxialInputControls from './input-controls/axial';
16
17
  import SeparatedInputControls from './input-controls/separated';
17
18
  import SingleInputControl from './input-controls/single';
18
19
  import LinkedButton from './linked-button';
19
- import useSpacingSizes from './hooks/use-spacing-sizes';
20
20
  import {
21
21
  ALL_SIDES,
22
22
  DEFAULT_VALUES,
@@ -25,6 +25,49 @@ import {
25
25
  getInitialView,
26
26
  } from './utils';
27
27
 
28
+ /**
29
+ * A flexible control for managing spacing values in the block editor. Supports single, axial,
30
+ * and separated input controls for different spacing configurations with automatic view selection
31
+ * based on current values and available sides.
32
+ *
33
+ * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/spacing-sizes-control/README.md
34
+ *
35
+ * @example
36
+ * ```jsx
37
+ * import { __experimentalSpacingSizesControl as SpacingSizesControl } from '@wordpress/block-editor';
38
+ * import { useState } from '@wordpress/element';
39
+ *
40
+ * function Example() {
41
+ * const [ sides, setSides ] = useState( {
42
+ * top: '0px',
43
+ * right: '0px',
44
+ * bottom: '0px',
45
+ * left: '0px',
46
+ * } );
47
+ *
48
+ * return (
49
+ * <SpacingSizesControl
50
+ * values={ sides }
51
+ * onChange={ setSides }
52
+ * label="Sides"
53
+ * />
54
+ * );
55
+ * }
56
+ * ```
57
+ *
58
+ * @param {Object} props Component props.
59
+ * @param {Object} props.inputProps Additional props for input controls.
60
+ * @param {string} props.label Label for the control.
61
+ * @param {number} props.minimumCustomValue Minimum value for custom input.
62
+ * @param {Function} props.onChange Called when spacing values change.
63
+ * @param {Function} props.onMouseOut Called when mouse leaves the control.
64
+ * @param {Function} props.onMouseOver Called when mouse enters the control.
65
+ * @param {boolean} props.showSideInLabel Show side in control label.
66
+ * @param {Array} props.sides Available sides for control.
67
+ * @param {boolean} props.useSelect Use select control for predefined values.
68
+ * @param {Object} props.values Current spacing values.
69
+ * @return {Element} Spacing sizes control component.
70
+ */
28
71
  export default function SpacingSizesControl( {
29
72
  inputProps,
30
73
  label: labelProp,
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { Button, Tooltip } from '@wordpress/components';
4
+ import { Button } from '@wordpress/components';
5
5
  import { link, linkOff } from '@wordpress/icons';
6
6
  import { __ } from '@wordpress/i18n';
7
7
 
@@ -9,14 +9,12 @@ export default function LinkedButton( { isLinked, ...props } ) {
9
9
  const label = isLinked ? __( 'Unlink sides' ) : __( 'Link sides' );
10
10
 
11
11
  return (
12
- <Tooltip text={ label }>
13
- <Button
14
- { ...props }
15
- size="small"
16
- icon={ isLinked ? link : linkOff }
17
- iconSize={ 24 }
18
- aria-label={ label }
19
- />
20
- </Tooltip>
12
+ <Button
13
+ { ...props }
14
+ size="small"
15
+ icon={ isLinked ? link : linkOff }
16
+ iconSize={ 24 }
17
+ label={ label }
18
+ />
21
19
  );
22
20
  }