@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
@@ -1,6 +1,6 @@
1
1
  // These rules ensure the preview scales smoothly regardless of the container size.
2
2
  .block-editor-block-preview__container {
3
- // In the component, a top padding is provided as an inline style to provid an aspect-ratio.
3
+ // In the component, a top padding is provided as an inline style to provide an aspect-ratio.
4
4
  // This positioning enables the content to sit on top of that padding to fit.
5
5
  position: relative;
6
6
 
@@ -11,24 +11,44 @@ import {
11
11
  import { __, sprintf } from '@wordpress/i18n';
12
12
  import { useState } from '@wordpress/element';
13
13
  import { speak } from '@wordpress/a11y';
14
+ import { useSelect, useDispatch } from '@wordpress/data';
14
15
 
15
16
  /**
16
17
  * Internal dependencies
17
18
  */
19
+ import { store as blockEditorStore } from '../../store';
20
+ import { useBlockDisplayInformation } from '..';
18
21
  import isEmptyString from './is-empty-string';
19
22
 
20
- export default function BlockRenameModal( {
21
- blockName,
22
- originalBlockName,
23
- onClose,
24
- onSave,
23
+ export default function BlockRenameModal( { clientId, onClose } ) {
24
+ const [ editedBlockName, setEditedBlockName ] = useState();
25
+
26
+ const blockInformation = useBlockDisplayInformation( clientId );
27
+ const { metadata } = useSelect(
28
+ ( select ) => {
29
+ const { getBlockAttributes } = select( blockEditorStore );
30
+
31
+ return {
32
+ metadata: getBlockAttributes( clientId )?.metadata,
33
+ };
34
+ },
35
+ [ clientId ]
36
+ );
37
+ const { updateBlockAttributes } = useDispatch( blockEditorStore );
38
+
39
+ const blockName = metadata?.name || '';
40
+ const originalBlockName = blockInformation?.title;
25
41
  // Pattern Overrides is a WordPress-only feature but it also uses the Block Binding API.
26
42
  // Ideally this should not be inside the block editor package, but we keep it here for simplicity.
27
- hasOverridesWarning,
28
- } ) {
29
- const [ editedBlockName, setEditedBlockName ] = useState( blockName );
43
+ const hasOverridesWarning =
44
+ !! blockName &&
45
+ !! metadata?.bindings &&
46
+ Object.values( metadata.bindings ).some(
47
+ ( binding ) => binding.source === 'core/pattern-overrides'
48
+ );
30
49
 
31
- const nameHasChanged = editedBlockName !== blockName;
50
+ const nameHasChanged =
51
+ editedBlockName !== undefined && editedBlockName !== blockName;
32
52
  const nameIsOriginal = editedBlockName === originalBlockName;
33
53
  const nameIsEmpty = isEmptyString( editedBlockName );
34
54
 
@@ -37,6 +57,8 @@ export default function BlockRenameModal( {
37
57
  const autoSelectInputText = ( event ) => event.target.select();
38
58
 
39
59
  const handleSubmit = () => {
60
+ const newName =
61
+ nameIsOriginal || nameIsEmpty ? undefined : editedBlockName;
40
62
  const message =
41
63
  nameIsOriginal || nameIsEmpty
42
64
  ? sprintf(
@@ -52,7 +74,12 @@ export default function BlockRenameModal( {
52
74
 
53
75
  // Must be assertive to immediately announce change.
54
76
  speak( message, 'assertive' );
55
- onSave( editedBlockName );
77
+ updateBlockAttributes( [ clientId ], {
78
+ metadata: {
79
+ ...metadata,
80
+ name: newName,
81
+ },
82
+ } );
56
83
 
57
84
  // Immediate close avoids ability to hit save multiple times.
58
85
  onClose();
@@ -81,7 +108,7 @@ export default function BlockRenameModal( {
81
108
  <TextControl
82
109
  __nextHasNoMarginBottom
83
110
  __next40pxDefaultSize
84
- value={ editedBlockName }
111
+ value={ editedBlockName ?? blockName }
85
112
  label={ __( 'Name' ) }
86
113
  help={
87
114
  hasOverridesWarning
@@ -105,7 +132,8 @@ export default function BlockRenameModal( {
105
132
 
106
133
  <Button
107
134
  __next40pxDefaultSize
108
- aria-disabled={ ! isNameValid }
135
+ accessibleWhenDisabled
136
+ disabled={ ! isNameValid }
109
137
  variant="primary"
110
138
  type="submit"
111
139
  >
@@ -2,54 +2,17 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { MenuItem } from '@wordpress/components';
5
- import { useSelect, useDispatch } from '@wordpress/data';
6
5
  import { __ } from '@wordpress/i18n';
7
6
  import { useState } from '@wordpress/element';
8
7
 
9
8
  /**
10
9
  * Internal dependencies
11
10
  */
12
- import { store as blockEditorStore } from '../../store';
13
- import { useBlockDisplayInformation } from '..';
14
- import isEmptyString from './is-empty-string';
15
11
  import BlockRenameModal from './modal';
16
12
 
17
13
  export default function BlockRenameControl( { clientId } ) {
18
14
  const [ renamingBlock, setRenamingBlock ] = useState( false );
19
15
 
20
- const { metadata } = useSelect(
21
- ( select ) => {
22
- const { getBlockAttributes } = select( blockEditorStore );
23
-
24
- const _metadata = getBlockAttributes( clientId )?.metadata;
25
- return {
26
- metadata: _metadata,
27
- };
28
- },
29
- [ clientId ]
30
- );
31
-
32
- const { updateBlockAttributes } = useDispatch( blockEditorStore );
33
-
34
- const customName = metadata?.name;
35
- const hasPatternOverrides =
36
- !! customName &&
37
- !! metadata?.bindings &&
38
- Object.values( metadata.bindings ).some(
39
- ( binding ) => binding.source === 'core/pattern-overrides'
40
- );
41
-
42
- function onChange( newName ) {
43
- updateBlockAttributes( [ clientId ], {
44
- metadata: {
45
- ...metadata,
46
- name: newName,
47
- },
48
- } );
49
- }
50
-
51
- const blockInformation = useBlockDisplayInformation( clientId );
52
-
53
16
  return (
54
17
  <>
55
18
  <MenuItem
@@ -63,23 +26,8 @@ export default function BlockRenameControl( { clientId } ) {
63
26
  </MenuItem>
64
27
  { renamingBlock && (
65
28
  <BlockRenameModal
66
- blockName={ customName || '' }
67
- originalBlockName={ blockInformation?.title }
68
- hasOverridesWarning={ hasPatternOverrides }
29
+ clientId={ clientId }
69
30
  onClose={ () => setRenamingBlock( false ) }
70
- onSave={ ( newName ) => {
71
- // If the new value is the block's original name (e.g. `Group`)
72
- // or it is an empty string then assume the intent is to reset
73
- // the value. Therefore reset the metadata.
74
- if (
75
- newName === blockInformation?.title ||
76
- isEmptyString( newName )
77
- ) {
78
- newName = undefined;
79
- }
80
-
81
- onChange( newName );
82
- } }
83
31
  />
84
32
  ) }
85
33
  </>
@@ -26,17 +26,30 @@ import BlockSettingsMenuControls from '../block-settings-menu-controls';
26
26
  import BlockParentSelectorMenuItem from './block-parent-selector-menu-item';
27
27
  import { store as blockEditorStore } from '../../store';
28
28
  import { unlock } from '../../lock-unlock';
29
+ import { useNotifyCopy } from '../../utils/use-notify-copy';
29
30
 
30
31
  const POPOVER_PROPS = {
31
32
  className: 'block-editor-block-settings-menu__popover',
32
33
  placement: 'bottom-start',
33
34
  };
34
35
 
35
- function CopyMenuItem( { clientIds, onCopy, label, shortcut } ) {
36
+ function CopyMenuItem( {
37
+ clientIds,
38
+ onCopy,
39
+ label,
40
+ shortcut,
41
+ eventType = 'copy',
42
+ } ) {
36
43
  const { getBlocksByClientId } = useSelect( blockEditorStore );
44
+ const notifyCopy = useNotifyCopy();
37
45
  const ref = useCopyToClipboard(
38
46
  () => serialize( getBlocksByClientId( clientIds ) ),
39
- onCopy
47
+ () => {
48
+ if ( onCopy && eventType === 'copy' ) {
49
+ onCopy();
50
+ }
51
+ notifyCopy( eventType, clientIds );
52
+ }
40
53
  );
41
54
  const copyMenuItemLabel = label ? label : __( 'Copy' );
42
55
  return (
@@ -305,6 +318,7 @@ export function BlockSettingsDropdown( {
305
318
  clientIds={ clientIds }
306
319
  onCopy={ onCopy }
307
320
  label={ __( 'Copy styles' ) }
321
+ eventType="copyStyles"
308
322
  />
309
323
  <MenuItem onClick={ onPasteStyles }>
310
324
  { __( 'Paste styles' ) }
@@ -33,7 +33,7 @@ function StylePreview( { onPress, isActive, style, url } ) {
33
33
 
34
34
  function onLayout() {
35
35
  const columnsNum =
36
- // To indicate scroll availabilty, there is a need to display additional half the column.
36
+ // To indicate scroll availability, there is a need to display additional half the column.
37
37
  Math.floor( BottomSheet.getWidth() / MAX_ITEM_WIDTH ) + HALF_COLUMN;
38
38
  setItemWidth( BottomSheet.getWidth() / columnsNum );
39
39
  }
@@ -27,20 +27,20 @@ import BlockVariationTransformations from './block-variation-transformations';
27
27
  * @return {Record<string, Object[]>} The grouped block transformations.
28
28
  */
29
29
  function useGroupedTransforms( possibleBlockTransformations ) {
30
- const priorityContentTranformationBlocks = {
30
+ const priorityContentTransformationBlocks = {
31
31
  'core/paragraph': 1,
32
32
  'core/heading': 2,
33
33
  'core/list': 3,
34
34
  'core/quote': 4,
35
35
  };
36
36
  const transformations = useMemo( () => {
37
- const priorityTextTranformsNames = Object.keys(
38
- priorityContentTranformationBlocks
37
+ const priorityTextTransformsNames = Object.keys(
38
+ priorityContentTransformationBlocks
39
39
  );
40
40
  const groupedPossibleTransforms = possibleBlockTransformations.reduce(
41
41
  ( accumulator, item ) => {
42
42
  const { name } = item;
43
- if ( priorityTextTranformsNames.includes( name ) ) {
43
+ if ( priorityTextTransformsNames.includes( name ) ) {
44
44
  accumulator.priorityTextTransformations.push( item );
45
45
  } else {
46
46
  accumulator.restTransformations.push( item );
@@ -71,8 +71,8 @@ function useGroupedTransforms( possibleBlockTransformations ) {
71
71
  // Order the priority text transformations.
72
72
  transformations.priorityTextTransformations.sort(
73
73
  ( { name: currentName }, { name: nextName } ) => {
74
- return priorityContentTranformationBlocks[ currentName ] <
75
- priorityContentTranformationBlocks[ nextName ]
74
+ return priorityContentTransformationBlocks[ currentName ] <
75
+ priorityContentTransformationBlocks[ nextName ]
76
76
  ? -1
77
77
  : 1;
78
78
  }
@@ -125,7 +125,7 @@ const BlockTransformationsMenu = ( {
125
125
  />
126
126
  ) }
127
127
  { priorityTextTransformations.map( ( item ) => (
128
- <BlockTranformationItem
128
+ <BlockTransformationItem
129
129
  key={ item.name }
130
130
  item={ item }
131
131
  onSelect={ onSelect }
@@ -151,7 +151,7 @@ function RestTransformationItems( {
151
151
  setHoveredTransformItemName,
152
152
  } ) {
153
153
  return restTransformations.map( ( item ) => (
154
- <BlockTranformationItem
154
+ <BlockTransformationItem
155
155
  key={ item.name }
156
156
  item={ item }
157
157
  onSelect={ onSelect }
@@ -160,7 +160,7 @@ function RestTransformationItems( {
160
160
  ) );
161
161
  }
162
162
 
163
- function BlockTranformationItem( {
163
+ function BlockTransformationItem( {
164
164
  item,
165
165
  onSelect,
166
166
  setHoveredTransformItemName,
@@ -74,7 +74,7 @@ const BlockVariationTransformations = ( {
74
74
  />
75
75
  ) }
76
76
  { transformations?.map( ( item ) => (
77
- <BlockVariationTranformationItem
77
+ <BlockVariationTransformationItem
78
78
  key={ item.name }
79
79
  item={ item }
80
80
  onSelect={ onSelect }
@@ -85,7 +85,7 @@ const BlockVariationTransformations = ( {
85
85
  );
86
86
  };
87
87
 
88
- function BlockVariationTranformationItem( {
88
+ function BlockVariationTransformationItem( {
89
89
  item,
90
90
  onSelect,
91
91
  setHoveredTransformItemName,
@@ -82,7 +82,7 @@ function BlockSwitcherDropdownMenuContents( {
82
82
  );
83
83
  }
84
84
  }
85
- // Simple block tranformation based on the `Block Transforms` API.
85
+ // Simple block transformation based on the `Block Transforms` API.
86
86
  function onBlockTransform( name ) {
87
87
  const newBlocks = switchToBlockType( blocks, name );
88
88
  replaceBlocks( clientIds, newBlocks );
@@ -72,7 +72,7 @@ export const getPatternTransformedBlocks = (
72
72
  // No need to loop through other pattern's blocks.
73
73
  break;
74
74
  }
75
- // Bail eary if a selected block has not been matched.
75
+ // Bail early if a selected block has not been matched.
76
76
  if ( ! isMatch ) {
77
77
  return;
78
78
  }
@@ -14,7 +14,7 @@ import UngroupButton from '../ungroup-button';
14
14
  import { BlockSettingsButton } from '../block-settings';
15
15
  import { store as blockEditorStore } from '../../store';
16
16
 
17
- const REMOVE_EMPY_PARENT_BLOCKS = [
17
+ const REMOVE_EMPTY_PARENT_BLOCKS = [
18
18
  'core/buttons',
19
19
  'core/columns',
20
20
  'core/social-links',
@@ -69,7 +69,7 @@ export default function BlockToolbar( { anchorNodeRef } ) {
69
69
  // have inner blocks, ideally we should match the behavior as in
70
70
  // the Web editor and show a placeholder instead of removing the parent.
71
71
  if (
72
- REMOVE_EMPY_PARENT_BLOCKS.includes( parentBlockName ) &&
72
+ REMOVE_EMPTY_PARENT_BLOCKS.includes( parentBlockName ) &&
73
73
  parentNumberOfInnerBlocks === 1
74
74
  ) {
75
75
  removeBlock( rootClientId );
@@ -217,7 +217,7 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
217
217
  class="components-circular-option-picker__option-wrapper"
218
218
  >
219
219
  <button
220
- aria-label="Color: red"
220
+ aria-label="red"
221
221
  aria-selected="true"
222
222
  class="components-button components-circular-option-picker__option is-next-40px-default-size"
223
223
  data-active-item="true"
@@ -111,6 +111,7 @@ $swatch-gap: 12px;
111
111
  white-space: nowrap;
112
112
  overflow: hidden;
113
113
  text-overflow: ellipsis;
114
+ max-width: calc(100% - ($button-size-next-default-40px + $grid-unit-05));
114
115
  }
115
116
  }
116
117
 
@@ -51,7 +51,7 @@ describe( 'ColorPaletteControl', () => {
51
51
  ).toBeInTheDocument();
52
52
 
53
53
  // Is showing the two predefined Colors.
54
- expect( screen.getAllByLabelText( /^Color:/ ) ).toHaveLength( 2 );
54
+ expect( screen.getAllByRole( 'option' ) ).toHaveLength( 2 );
55
55
  } );
56
56
 
57
57
  it( 'renders the color picker and does not render tabs if it is only possible to select a color', async () => {
@@ -80,7 +80,7 @@ describe( 'ColorPaletteControl', () => {
80
80
  ).not.toBeInTheDocument();
81
81
 
82
82
  // Is showing the two predefined Colors.
83
- expect( screen.getAllByLabelText( /^Color:/ ) ).toHaveLength( 2 );
83
+ expect( screen.getAllByRole( 'option' ) ).toHaveLength( 2 );
84
84
  } );
85
85
 
86
86
  it( 'renders the gradient picker and does not render tabs if it is only possible to select a gradient', async () => {
@@ -14,7 +14,7 @@ import {
14
14
  } from '@wordpress/components';
15
15
 
16
16
  // So that we illustrate the different formats in the dropdown properly, show a date that is
17
- // somwhat recent, has a day greater than 12, and a month with more than three letters.
17
+ // somewhat recent, has a day greater than 12, and a month with more than three letters.
18
18
  const exampleDate = new Date();
19
19
  exampleDate.setDate( 20 );
20
20
  exampleDate.setMonth( exampleDate.getMonth() - 3 );
@@ -4,11 +4,11 @@ $swatch-size: 28px;
4
4
  $swatch-gap: 12px;
5
5
 
6
6
  $popover-width: 260px;
7
- $popover-padding: $grid-unit-20;
7
+ $popover-padding: $grid-unit-10;
8
8
 
9
9
  $swatch-columns: math.floor(math.div($popover-width + $swatch-gap - 2 * $popover-padding, $swatch-size + $swatch-gap));
10
10
 
11
- .block-editor-duotone-control__popover {
11
+ .block-editor-duotone-control__popover.components-popover {
12
12
  > .components-popover__content {
13
13
  padding: $popover-padding;
14
14
  width: $popover-width;
@@ -144,10 +144,12 @@ export default function FiltersPanel( {
144
144
  const duotonePreset = duotonePalette.find( ( { colors } ) => {
145
145
  return colors === newValue;
146
146
  } );
147
- const settedValue = duotonePreset
147
+ const duotoneValue = duotonePreset
148
148
  ? `var:preset|duotone|${ duotonePreset.slug }`
149
149
  : newValue;
150
- onChange( setImmutably( value, [ 'filter', 'duotone' ], settedValue ) );
150
+ onChange(
151
+ setImmutably( value, [ 'filter', 'duotone' ], duotoneValue )
152
+ );
151
153
  };
152
154
  const hasDuotone = () => !! value?.filter?.duotone;
153
155
  const resetDuotone = () => setDuotone( undefined );
@@ -61,14 +61,14 @@ export default function ImageSettingsPanel( {
61
61
  // "RESET" button ONLY when the user has explicitly set a value in the
62
62
  // Global Styles.
63
63
  hasValue={ () => !! value?.lightbox }
64
- label={ __( 'Expand on click' ) }
64
+ label={ __( 'Enlarge on click' ) }
65
65
  onDeselect={ resetLightbox }
66
66
  isShownByDefault
67
67
  panelId={ panelId }
68
68
  >
69
69
  <ToggleControl
70
70
  __nextHasNoMarginBottom
71
- label={ __( 'Expand on click' ) }
71
+ label={ __( 'Enlarge on click' ) }
72
72
  checked={ lightboxChecked }
73
73
  onChange={ onChangeLightbox }
74
74
  />
@@ -585,7 +585,7 @@ describe( 'typography utils', () => {
585
585
  'clamp(14px, 0.875rem + ((1vw - 3.2px) * 0.078), 15px)',
586
586
  },
587
587
 
588
- // Equivalent custom config PHP unit tests in `test_should_covert_font_sizes_to_fluid_values()`.
588
+ // Equivalent custom config PHP unit tests in `test_should_convert_font_sizes_to_fluid_values()`.
589
589
  {
590
590
  message: 'should return clamp value using custom fluid config',
591
591
  preset: {
@@ -1337,12 +1337,12 @@ export function processCSSNesting( css, blockSelector ) {
1337
1337
  processedCSS += `:root :where(${ blockSelector }){${ part.trim() }}`;
1338
1338
  } else {
1339
1339
  // If the part contains braces, it's a nested CSS rule.
1340
- const splittedPart = part.replace( '}', '' ).split( '{' );
1341
- if ( splittedPart.length !== 2 ) {
1340
+ const splitPart = part.replace( '}', '' ).split( '{' );
1341
+ if ( splitPart.length !== 2 ) {
1342
1342
  return;
1343
1343
  }
1344
1344
 
1345
- const [ nestedSelector, cssValue ] = splittedPart;
1345
+ const [ nestedSelector, cssValue ] = splitPart;
1346
1346
 
1347
1347
  // Handle pseudo elements such as ::before, ::after, etc. Regex will also
1348
1348
  // capture any leading combinator such as >, +, or ~, as well as spaces.
@@ -54,29 +54,18 @@ const GridVisualizerGrid = forwardRef(
54
54
  const [ isDroppingAllowed, setIsDroppingAllowed ] = useState( false );
55
55
 
56
56
  useEffect( () => {
57
- const observers = [];
58
- for ( const element of [ gridElement, ...gridElement.children ] ) {
59
- const observer = new window.ResizeObserver( () => {
60
- setGridInfo( getGridInfo( gridElement ) );
61
- } );
62
- observer.observe( element );
63
- observers.push( observer );
64
- }
65
-
66
- const mutationObserver = new window.MutationObserver( () => {
57
+ const resizeCallback = () =>
67
58
  setGridInfo( getGridInfo( gridElement ) );
68
- } );
69
- mutationObserver.observe( gridElement, {
70
- attributeFilter: [ 'style', 'class' ],
71
- childList: true,
72
- subtree: true,
73
- } );
74
- observers.push( mutationObserver );
75
-
59
+ // Both border-box and content-box are observed as they may change
60
+ // independently. This requires two observers because a single one
61
+ // can’t be made to monitor both on the same element.
62
+ const borderBoxSpy = new window.ResizeObserver( resizeCallback );
63
+ borderBoxSpy.observe( gridElement, { box: 'border-box' } );
64
+ const contentBoxSpy = new window.ResizeObserver( resizeCallback );
65
+ contentBoxSpy.observe( gridElement );
76
66
  return () => {
77
- for ( const observer of observers ) {
78
- observer.disconnect();
79
- }
67
+ borderBoxSpy.disconnect();
68
+ contentBoxSpy.disconnect();
80
69
  };
81
70
  }, [ gridElement ] );
82
71
 
@@ -20,6 +20,7 @@
20
20
 
21
21
  .block-editor-grid-visualizer__grid {
22
22
  display: grid;
23
+ position: absolute;
23
24
  }
24
25
 
25
26
  .block-editor-grid-visualizer__cell {
@@ -187,10 +187,12 @@ export function getGridInfo( gridElement ) {
187
187
  gridTemplateColumns,
188
188
  gridTemplateRows,
189
189
  gap: getComputedCSS( gridElement, 'gap' ),
190
- paddingTop: `calc(${ paddingTop } + ${ borderTopWidth })`,
191
- paddingRight: `calc(${ paddingRight } + ${ borderRightWidth })`,
192
- paddingBottom: `calc(${ paddingBottom } + ${ borderBottomWidth })`,
193
- paddingLeft: `calc(${ paddingLeft } + ${ borderLeftWidth })`,
190
+ inset: `
191
+ calc(${ paddingTop } + ${ borderTopWidth })
192
+ calc(${ paddingRight } + ${ borderRightWidth })
193
+ calc(${ paddingBottom } + ${ borderBottomWidth })
194
+ calc(${ paddingLeft } + ${ borderLeftWidth })
195
+ `,
194
196
  },
195
197
  };
196
198
  }
@@ -2,7 +2,7 @@ let compatibilityStyles = null;
2
2
 
3
3
  /**
4
4
  * Returns a list of stylesheets that target the editor canvas. A stylesheet is
5
- * considered targetting the editor a canvas if it contains the
5
+ * considered targeting the editor a canvas if it contains the
6
6
  * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.
7
7
  *
8
8
  * Ideally, this hook should be removed in the future and styles should be added
@@ -330,7 +330,7 @@ function Iframe( {
330
330
  >
331
331
  { iframeDocument &&
332
332
  createPortal(
333
- // We want to prevent React events from bubbling throught the iframe
333
+ // We want to prevent React events from bubbling through the iframe
334
334
  // we bubble these manually.
335
335
  /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */
336
336
  <body
@@ -8,7 +8,7 @@ import {
8
8
  __experimentalToggleGroupControl as ToggleGroupControl,
9
9
  __experimentalToggleGroupControlOption as ToggleGroupControlOption,
10
10
  } from '@wordpress/components';
11
- import { __ } from '@wordpress/i18n';
11
+ import { __, sprintf } from '@wordpress/i18n';
12
12
 
13
13
  /**
14
14
  * Internal dependencies
@@ -137,7 +137,11 @@ export default function ImageSizeControl( {
137
137
  <ToggleGroupControlOption
138
138
  key={ scale }
139
139
  value={ scale }
140
- label={ `${ scale }%` }
140
+ label={ sprintf(
141
+ /* translators: Percentage value. */
142
+ __( '%d%%' ),
143
+ scale
144
+ ) }
141
145
  />
142
146
  );
143
147
  } ) }
@@ -125,7 +125,7 @@ Template locking of `InnerBlocks` is similar to [Custom Post Type templates lock
125
125
  Template locking allows locking the `InnerBlocks` area for the current template.
126
126
  _Options:_
127
127
 
128
- - `contentOnly` — prevents all operations. Additionally, the block types that don't have content are hidden from the list view and can't gain focus within the block list. Unlike the other lock types, this is not overrideable by children.
128
+ - `contentOnly` — prevents all operations. Additionally, the block types that don't have content are hidden from the list view and can't gain focus within the block list. Unlike the other lock types, this is not overridable by children.
129
129
  - `'all'` — prevents all operations. It is not possible to insert new blocks. Move existing blocks or delete them.
130
130
  - `'insert'` — prevents inserting or removing blocks, but allows moving existing ones.
131
131
  - `false` — prevents locking from being applied to an `InnerBlocks` area even if a parent block contains locking. ( Boolean )
@@ -57,7 +57,7 @@ export function PatternsFilter( {
57
57
  } ) {
58
58
  // If the category is `myPatterns` then we need to set the source filter to `user`, but
59
59
  // we do this by deriving from props rather than calling setPatternSourceFilter otherwise
60
- // the user may be confused when switching to another category if the haven't explicity set
60
+ // the user may be confused when switching to another category if the haven't explicitly set
61
61
  // this filter themselves.
62
62
  const currentPatternSourceFilter =
63
63
  category?.name === myPatternsCategory.name
@@ -54,15 +54,17 @@ function InserterMenu(
54
54
  },
55
55
  ref
56
56
  ) {
57
- const isZoomOutMode = useSelect(
58
- ( select ) => unlock( select( blockEditorStore ) ).isZoomOut(),
59
- []
60
- );
61
- const hasSectionRootClientId = useSelect(
62
- ( select ) =>
63
- !! unlock( select( blockEditorStore ) ).getSectionRootClientId(),
64
- []
65
- );
57
+ const { isZoomOutMode, hasSectionRootClientId } = useSelect( ( select ) => {
58
+ const { isZoomOut, getSectionRootClientId } = unlock(
59
+ select( blockEditorStore )
60
+ );
61
+
62
+ return {
63
+ isZoomOutMode: isZoomOut(),
64
+ hasSectionRootClientId: !! getSectionRootClientId(),
65
+ };
66
+ }, [] );
67
+
66
68
  const [ filterValue, setFilterValue, delayedFilterValue ] =
67
69
  useDebouncedInput( __experimentalFilterValue );
68
70
  const [ hoveredItem, setHoveredItem ] = useState( null );
@@ -29,7 +29,7 @@ function ReusableBlocksTab( { onSelect, rootClientId, listProps } ) {
29
29
  return filterInserterItems( inserterItems, { onlyReusable: true } );
30
30
  }, [ inserterItems ] );
31
31
 
32
- const sections = [ createInserterSection( { key: 'reuseable', items } ) ];
32
+ const sections = [ createInserterSection( { key: 'reusable', items } ) ];
33
33
 
34
34
  return (
35
35
  <BlockTypesList