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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (294) hide show
  1. package/README.md +4 -0
  2. package/build/components/block-caption/index.native.js +14 -3
  3. package/build/components/block-caption/index.native.js.map +1 -1
  4. package/build/components/block-inspector/index.js +12 -23
  5. package/build/components/block-inspector/index.js.map +1 -1
  6. package/build/components/block-list-appender/index.js +3 -11
  7. package/build/components/block-list-appender/index.js.map +1 -1
  8. package/build/components/block-preview/auto.js +10 -2
  9. package/build/components/block-preview/auto.js.map +1 -1
  10. package/build/components/block-preview/index.js +51 -0
  11. package/build/components/block-preview/index.js.map +1 -1
  12. package/build/components/block-settings/container.native.js +2 -1
  13. package/build/components/block-settings/container.native.js.map +1 -1
  14. package/build/components/block-styles/index.js +110 -134
  15. package/build/components/block-styles/index.js.map +1 -1
  16. package/build/components/block-styles/menu-items.js +63 -0
  17. package/build/components/block-styles/menu-items.js.map +1 -0
  18. package/build/components/block-styles/preview-panel.js +45 -0
  19. package/build/components/block-styles/preview-panel.js.map +1 -0
  20. package/build/components/block-styles/use-styles-for-block.js +119 -0
  21. package/build/components/block-styles/use-styles-for-block.js.map +1 -0
  22. package/build/components/block-styles/utils.js +39 -0
  23. package/build/components/block-styles/utils.js.map +1 -1
  24. package/build/components/block-switcher/block-styles-menu.js +3 -23
  25. package/build/components/block-switcher/block-styles-menu.js.map +1 -1
  26. package/build/components/block-tools/back-compat.js +2 -1
  27. package/build/components/block-tools/back-compat.js.map +1 -1
  28. package/build/components/block-tools/insertion-point.js +11 -1
  29. package/build/components/block-tools/insertion-point.js.map +1 -1
  30. package/build/components/button-block-appender/index.js +2 -1
  31. package/build/components/button-block-appender/index.js.map +1 -1
  32. package/build/components/colors-gradients/control.js +1 -0
  33. package/build/components/colors-gradients/control.js.map +1 -1
  34. package/build/components/colors-gradients/panel-color-gradient-settings.js +51 -10
  35. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  36. package/build/components/default-block-appender/index.js +16 -19
  37. package/build/components/default-block-appender/index.js.map +1 -1
  38. package/build/components/default-style-picker/index.js +18 -3
  39. package/build/components/default-style-picker/index.js.map +1 -1
  40. package/build/components/iframe/index.js +3 -4
  41. package/build/components/iframe/index.js.map +1 -1
  42. package/build/components/index.js +17 -10
  43. package/build/components/index.js.map +1 -1
  44. package/build/components/inner-blocks/default-block-appender.js +2 -4
  45. package/build/components/inner-blocks/default-block-appender.js.map +1 -1
  46. package/build/components/inserter/index.native.js +1 -1
  47. package/build/components/inserter/index.native.js.map +1 -1
  48. package/build/components/inserter/tabs.native.js +7 -4
  49. package/build/components/inserter/tabs.native.js.map +1 -1
  50. package/build/components/inspector-controls/block-support-slot-container.js +2 -1
  51. package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
  52. package/build/components/inspector-controls/fill.native.js +3 -5
  53. package/build/components/inspector-controls/fill.native.js.map +1 -1
  54. package/build/components/inspector-controls/groups.js +2 -0
  55. package/build/components/inspector-controls/groups.js.map +1 -1
  56. package/build/components/inspector-controls/slot.js +1 -3
  57. package/build/components/inspector-controls/slot.js.map +1 -1
  58. package/build/components/letter-spacing-control/index.js +6 -6
  59. package/build/components/letter-spacing-control/index.js.map +1 -1
  60. package/build/components/list-view/block-select-button.js +23 -3
  61. package/build/components/list-view/block-select-button.js.map +1 -1
  62. package/build/components/media-placeholder/index.js +2 -0
  63. package/build/components/media-placeholder/index.js.map +1 -1
  64. package/build/components/media-replace-flow/index.js +2 -0
  65. package/build/components/media-replace-flow/index.js.map +1 -1
  66. package/build/components/rich-text/file-paste-handler.js +1 -1
  67. package/build/components/rich-text/file-paste-handler.js.map +1 -1
  68. package/build/components/rich-text/prevent-event-discovery.js +33 -0
  69. package/build/components/rich-text/prevent-event-discovery.js.map +1 -0
  70. package/build/components/rich-text/use-input-rules.js +3 -1
  71. package/build/components/rich-text/use-input-rules.js.map +1 -1
  72. package/build/components/selection-scroll-into-view/index.js +2 -1
  73. package/build/components/selection-scroll-into-view/index.js.map +1 -1
  74. package/build/components/use-display-block-controls/index.native.js +45 -0
  75. package/build/components/use-display-block-controls/index.native.js.map +1 -0
  76. package/build/components/use-on-block-drop/index.js +7 -3
  77. package/build/components/use-on-block-drop/index.js.map +1 -1
  78. package/build/components/writing-flow/use-multi-selection.js +3 -1
  79. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  80. package/build/hooks/border-color.js +63 -5
  81. package/build/hooks/border-color.js.map +1 -1
  82. package/build/hooks/border-radius.js +47 -0
  83. package/build/hooks/border-radius.js.map +1 -1
  84. package/build/hooks/border-style.js +41 -0
  85. package/build/hooks/border-style.js.map +1 -1
  86. package/build/hooks/border-width.js +70 -31
  87. package/build/hooks/border-width.js.map +1 -1
  88. package/build/hooks/border.js +81 -11
  89. package/build/hooks/border.js.map +1 -1
  90. package/build/hooks/letter-spacing.js +1 -1
  91. package/build/hooks/letter-spacing.js.map +1 -1
  92. package/build/hooks/typography.js +1 -1
  93. package/build/hooks/typography.js.map +1 -1
  94. package/build/store/actions.js +1 -2
  95. package/build/store/actions.js.map +1 -1
  96. package/build/store/defaults.js +5 -1
  97. package/build/store/defaults.js.map +1 -1
  98. package/build/store/reducer.js +10 -82
  99. package/build/store/reducer.js.map +1 -1
  100. package/build/store/selectors.js +25 -7
  101. package/build/store/selectors.js.map +1 -1
  102. package/build/utils/get-paste-event-data.js +1 -1
  103. package/build/utils/get-paste-event-data.js.map +1 -1
  104. package/build/utils/parse-css-unit-to-px.js +1 -1
  105. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  106. package/build/utils/transform-styles/index.js +2 -3
  107. package/build/utils/transform-styles/index.js.map +1 -1
  108. package/build-module/components/block-caption/index.native.js +13 -3
  109. package/build-module/components/block-caption/index.native.js.map +1 -1
  110. package/build-module/components/block-inspector/index.js +12 -23
  111. package/build-module/components/block-inspector/index.js.map +1 -1
  112. package/build-module/components/block-list-appender/index.js +3 -10
  113. package/build-module/components/block-list-appender/index.js.map +1 -1
  114. package/build-module/components/block-preview/auto.js +10 -2
  115. package/build-module/components/block-preview/auto.js.map +1 -1
  116. package/build-module/components/block-preview/index.js +46 -0
  117. package/build-module/components/block-preview/index.js.map +1 -1
  118. package/build-module/components/block-settings/container.native.js +2 -1
  119. package/build-module/components/block-settings/container.native.js.map +1 -1
  120. package/build-module/components/block-styles/index.js +112 -133
  121. package/build-module/components/block-styles/index.js.map +1 -1
  122. package/build-module/components/block-styles/menu-items.js +50 -0
  123. package/build-module/components/block-styles/menu-items.js.map +1 -0
  124. package/build-module/components/block-styles/preview-panel.js +35 -0
  125. package/build-module/components/block-styles/preview-panel.js.map +1 -0
  126. package/build-module/components/block-styles/use-styles-for-block.js +107 -0
  127. package/build-module/components/block-styles/use-styles-for-block.js.map +1 -0
  128. package/build-module/components/block-styles/utils.js +34 -0
  129. package/build-module/components/block-styles/utils.js.map +1 -1
  130. package/build-module/components/block-switcher/block-styles-menu.js +3 -21
  131. package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
  132. package/build-module/components/block-tools/back-compat.js +2 -1
  133. package/build-module/components/block-tools/back-compat.js.map +1 -1
  134. package/build-module/components/block-tools/insertion-point.js +11 -1
  135. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  136. package/build-module/components/button-block-appender/index.js +2 -1
  137. package/build-module/components/button-block-appender/index.js.map +1 -1
  138. package/build-module/components/colors-gradients/control.js +1 -0
  139. package/build-module/components/colors-gradients/control.js.map +1 -1
  140. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +54 -13
  141. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  142. package/build-module/components/default-block-appender/index.js +15 -18
  143. package/build-module/components/default-block-appender/index.js.map +1 -1
  144. package/build-module/components/default-style-picker/index.js +17 -3
  145. package/build-module/components/default-style-picker/index.js.map +1 -1
  146. package/build-module/components/iframe/index.js +3 -4
  147. package/build-module/components/iframe/index.js.map +1 -1
  148. package/build-module/components/index.js +2 -2
  149. package/build-module/components/index.js.map +1 -1
  150. package/build-module/components/inner-blocks/default-block-appender.js +2 -4
  151. package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
  152. package/build-module/components/inserter/index.native.js +2 -2
  153. package/build-module/components/inserter/index.native.js.map +1 -1
  154. package/build-module/components/inserter/tabs.native.js +7 -4
  155. package/build-module/components/inserter/tabs.native.js.map +1 -1
  156. package/build-module/components/inspector-controls/block-support-slot-container.js +2 -1
  157. package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
  158. package/build-module/components/inspector-controls/fill.native.js +3 -5
  159. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  160. package/build-module/components/inspector-controls/groups.js +2 -0
  161. package/build-module/components/inspector-controls/groups.js.map +1 -1
  162. package/build-module/components/inspector-controls/slot.js +1 -3
  163. package/build-module/components/inspector-controls/slot.js.map +1 -1
  164. package/build-module/components/letter-spacing-control/index.js +6 -6
  165. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  166. package/build-module/components/list-view/block-select-button.js +22 -3
  167. package/build-module/components/list-view/block-select-button.js.map +1 -1
  168. package/build-module/components/media-placeholder/index.js +2 -0
  169. package/build-module/components/media-placeholder/index.js.map +1 -1
  170. package/build-module/components/media-replace-flow/index.js +2 -0
  171. package/build-module/components/media-replace-flow/index.js.map +1 -1
  172. package/build-module/components/rich-text/file-paste-handler.js +1 -1
  173. package/build-module/components/rich-text/file-paste-handler.js.map +1 -1
  174. package/build-module/components/rich-text/prevent-event-discovery.js +25 -0
  175. package/build-module/components/rich-text/prevent-event-discovery.js.map +1 -0
  176. package/build-module/components/rich-text/use-input-rules.js +2 -1
  177. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  178. package/build-module/components/selection-scroll-into-view/index.js +2 -1
  179. package/build-module/components/selection-scroll-into-view/index.js.map +1 -1
  180. package/build-module/components/use-display-block-controls/index.native.js +34 -0
  181. package/build-module/components/use-display-block-controls/index.native.js.map +1 -0
  182. package/build-module/components/use-on-block-drop/index.js +7 -3
  183. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  184. package/build-module/components/writing-flow/use-multi-selection.js +3 -4
  185. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  186. package/build-module/hooks/border-color.js +61 -7
  187. package/build-module/hooks/border-color.js.map +1 -1
  188. package/build-module/hooks/border-radius.js +42 -0
  189. package/build-module/hooks/border-radius.js.map +1 -1
  190. package/build-module/hooks/border-style.js +36 -0
  191. package/build-module/hooks/border-style.js.map +1 -1
  192. package/build-module/hooks/border-width.js +66 -32
  193. package/build-module/hooks/border-width.js.map +1 -1
  194. package/build-module/hooks/border.js +80 -12
  195. package/build-module/hooks/border.js.map +1 -1
  196. package/build-module/hooks/letter-spacing.js +1 -1
  197. package/build-module/hooks/letter-spacing.js.map +1 -1
  198. package/build-module/hooks/typography.js +1 -1
  199. package/build-module/hooks/typography.js.map +1 -1
  200. package/build-module/store/actions.js +1 -2
  201. package/build-module/store/actions.js.map +1 -1
  202. package/build-module/store/defaults.js +5 -1
  203. package/build-module/store/defaults.js.map +1 -1
  204. package/build-module/store/reducer.js +11 -83
  205. package/build-module/store/reducer.js.map +1 -1
  206. package/build-module/store/selectors.js +24 -7
  207. package/build-module/store/selectors.js.map +1 -1
  208. package/build-module/utils/get-paste-event-data.js +1 -1
  209. package/build-module/utils/get-paste-event-data.js.map +1 -1
  210. package/build-module/utils/parse-css-unit-to-px.js +1 -1
  211. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  212. package/build-module/utils/transform-styles/index.js +2 -3
  213. package/build-module/utils/transform-styles/index.js.map +1 -1
  214. package/build-style/style-rtl.css +229 -182
  215. package/build-style/style.css +229 -182
  216. package/package.json +27 -27
  217. package/src/components/block-caption/index.native.js +22 -4
  218. package/src/components/block-inspector/index.js +14 -17
  219. package/src/components/block-list-appender/index.js +5 -21
  220. package/src/components/block-preview/auto.js +7 -2
  221. package/src/components/block-preview/index.js +60 -0
  222. package/src/components/block-preview/style.scss +23 -0
  223. package/src/components/block-preview/test/index.js +114 -0
  224. package/src/components/block-settings/container.native.js +1 -0
  225. package/src/components/block-styles/index.js +125 -145
  226. package/src/components/block-styles/menu-items.js +49 -0
  227. package/src/components/block-styles/preview-panel.js +36 -0
  228. package/src/components/block-styles/style.scss +59 -51
  229. package/src/components/block-styles/test/{index.js → utils.js} +60 -1
  230. package/src/components/block-styles/use-styles-for-block.js +99 -0
  231. package/src/components/block-styles/utils.js +39 -0
  232. package/src/components/block-switcher/block-styles-menu.js +3 -38
  233. package/src/components/block-tools/back-compat.js +1 -0
  234. package/src/components/block-tools/insertion-point.js +10 -1
  235. package/src/components/border-style-control/style.scss +3 -3
  236. package/src/components/button-block-appender/index.js +1 -0
  237. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -0
  238. package/src/components/colors-gradients/control.js +3 -0
  239. package/src/components/colors-gradients/panel-color-gradient-settings.js +75 -19
  240. package/src/components/colors-gradients/style.scss +42 -5
  241. package/src/components/default-block-appender/index.js +17 -24
  242. package/src/components/default-block-appender/style.scss +4 -0
  243. package/src/components/default-block-appender/test/__snapshots__/index.js.snap +12 -24
  244. package/src/components/default-block-appender/test/index.js +4 -14
  245. package/src/components/default-style-picker/index.js +18 -6
  246. package/src/components/iframe/index.js +6 -3
  247. package/src/components/index.js +5 -2
  248. package/src/components/inner-blocks/README.md +2 -0
  249. package/src/components/inner-blocks/default-block-appender.js +2 -7
  250. package/src/components/inserter/index.native.js +2 -2
  251. package/src/components/inserter/tabs.native.js +5 -4
  252. package/src/components/inspector-controls/block-support-slot-container.js +3 -1
  253. package/src/components/inspector-controls/fill.native.js +4 -3
  254. package/src/components/inspector-controls/groups.js +2 -0
  255. package/src/components/inspector-controls/slot.js +2 -7
  256. package/src/components/letter-spacing-control/index.js +6 -6
  257. package/src/components/link-control/README.md +1 -1
  258. package/src/components/link-control/test/index.js +2 -0
  259. package/src/components/list-view/block-select-button.js +20 -1
  260. package/src/components/media-placeholder/index.js +2 -0
  261. package/src/components/media-replace-flow/index.js +2 -0
  262. package/src/components/rich-text/file-paste-handler.js +3 -1
  263. package/src/components/rich-text/prevent-event-discovery.js +23 -0
  264. package/src/components/rich-text/use-input-rules.js +2 -1
  265. package/src/components/selection-scroll-into-view/index.js +1 -0
  266. package/src/components/url-input/README.md +5 -0
  267. package/src/components/use-display-block-controls/index.native.js +38 -0
  268. package/src/components/use-on-block-drop/index.js +7 -3
  269. package/src/components/writing-flow/test/use-multi-selection.js +36 -0
  270. package/src/components/writing-flow/use-multi-selection.js +12 -9
  271. package/src/hooks/border-color.js +55 -3
  272. package/src/hooks/border-radius.js +32 -0
  273. package/src/hooks/border-style.js +26 -0
  274. package/src/hooks/border-width.js +56 -32
  275. package/src/hooks/border.js +115 -20
  276. package/src/hooks/border.scss +3 -17
  277. package/src/hooks/dimensions.scss +5 -0
  278. package/src/hooks/letter-spacing.js +1 -1
  279. package/src/hooks/typography.js +1 -1
  280. package/src/store/actions.js +1 -2
  281. package/src/store/defaults.js +2 -0
  282. package/src/store/reducer.js +13 -104
  283. package/src/store/selectors.js +37 -7
  284. package/src/style.scss +4 -3
  285. package/src/utils/get-paste-event-data.js +1 -1
  286. package/src/utils/parse-css-unit-to-px.js +1 -1
  287. package/src/utils/test/parse-css-unit-to-px.js +1 -0
  288. package/src/utils/transform-styles/index.js +13 -16
  289. package/tsconfig.tsbuildinfo +1 -1
  290. package/build/components/use-canvas-click-redirect/index.js +0 -66
  291. package/build/components/use-canvas-click-redirect/index.js.map +0 -1
  292. package/build-module/components/use-canvas-click-redirect/index.js +0 -54
  293. package/build-module/components/use-canvas-click-redirect/index.js.map +0 -1
  294. package/src/components/use-canvas-click-redirect/index.js +0 -57
@@ -16,13 +16,8 @@ import BaseDefaultBlockAppender from '../default-block-appender';
16
16
  import withClientId from './with-client-id';
17
17
  import { store as blockEditorStore } from '../../store';
18
18
 
19
- export const DefaultBlockAppender = ( { clientId, lastBlockClientId } ) => {
20
- return (
21
- <BaseDefaultBlockAppender
22
- rootClientId={ clientId }
23
- lastBlockClientId={ lastBlockClientId }
24
- />
25
- );
19
+ export const DefaultBlockAppender = ( { clientId } ) => {
20
+ return <BaseDefaultBlockAppender rootClientId={ clientId } />;
26
21
  };
27
22
 
28
23
  export default compose( [
@@ -7,7 +7,7 @@ import { delay } from 'lodash';
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
- import { __ } from '@wordpress/i18n';
10
+ import { __, _x } from '@wordpress/i18n';
11
11
  import { Dropdown, ToolbarButton, Picker } from '@wordpress/components';
12
12
  import { Component } from '@wordpress/element';
13
13
  import { withDispatch, withSelect } from '@wordpress/data';
@@ -34,7 +34,7 @@ const VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;
34
34
 
35
35
  const defaultRenderToggle = ( { onToggle, disabled, style, onLongPress } ) => (
36
36
  <ToolbarButton
37
- title={ __( 'Add block' ) }
37
+ title={ _x( 'Add block', 'Generic label for block inserter button' ) }
38
38
  icon={
39
39
  <Icon
40
40
  icon={ plusCircleFilled }
@@ -63,7 +63,7 @@ function InserterTabs( {
63
63
  }, [ tabIndex ] );
64
64
 
65
65
  const { tabs, tabKeys } = useMemo( () => {
66
- const filteredTabs = InserterTabs.TABS.filter(
66
+ const filteredTabs = InserterTabs.getTabs().filter(
67
67
  ( { name } ) => showReusableBlocks || name !== 'reusable'
68
68
  );
69
69
  return {
@@ -114,8 +114,9 @@ function InserterTabs( {
114
114
  }
115
115
 
116
116
  function TabsControl( { onChangeTab, showReusableBlocks } ) {
117
+ const tabs = InserterTabs.getTabs();
117
118
  const segments = useMemo( () => {
118
- const filteredTabs = InserterTabs.TABS.filter(
119
+ const filteredTabs = tabs.filter(
119
120
  ( { name } ) => showReusableBlocks || name !== 'reusable'
120
121
  );
121
122
  return filteredTabs.map( ( { title } ) => title );
@@ -123,7 +124,7 @@ function TabsControl( { onChangeTab, showReusableBlocks } ) {
123
124
 
124
125
  const segmentHandler = useCallback(
125
126
  ( selectedTab ) => {
126
- const tabTitles = InserterTabs.TABS.map( ( { title } ) => title );
127
+ const tabTitles = tabs.map( ( { title } ) => title );
127
128
  onChangeTab( tabTitles.indexOf( selectedTab ) );
128
129
  },
129
130
  [ onChangeTab ]
@@ -139,7 +140,7 @@ function TabsControl( { onChangeTab, showReusableBlocks } ) {
139
140
 
140
141
  InserterTabs.Control = TabsControl;
141
142
 
142
- InserterTabs.TABS = [
143
+ InserterTabs.getTabs = () => [
143
144
  { name: 'blocks', title: __( 'Blocks' ), component: BlockTypesTab },
144
145
  { name: 'reusable', title: __( 'Reusable' ), component: ReusableBlocksTab },
145
146
  ];
@@ -6,5 +6,7 @@ import { useContext } from '@wordpress/element';
6
6
 
7
7
  export default function BlockSupportSlotContainer( { Slot, ...props } ) {
8
8
  const toolsPanelContext = useContext( ToolsPanelContext );
9
- return <Slot { ...props } fillProps={ toolsPanelContext } />;
9
+ return (
10
+ <Slot { ...props } fillProps={ toolsPanelContext } bubblesVirtually />
11
+ );
10
12
  }
@@ -14,7 +14,7 @@ import warning from '@wordpress/warning';
14
14
  * Internal dependencies
15
15
  */
16
16
  import groups from './groups';
17
- import { useBlockEditContext } from '../block-edit/context';
17
+ import useDisplayBlockControls from '../use-display-block-controls';
18
18
  import { BlockSettingsButton } from '../block-settings';
19
19
 
20
20
  export default function InspectorControlsFill( {
@@ -22,13 +22,14 @@ export default function InspectorControlsFill( {
22
22
  __experimentalGroup: group = 'default',
23
23
  ...props
24
24
  } ) {
25
- const { isSelected } = useBlockEditContext();
25
+ const isDisplayed = useDisplayBlockControls();
26
+
26
27
  const Fill = groups[ group ]?.Fill;
27
28
  if ( ! Fill ) {
28
29
  warning( `Unknown InspectorControl group "${ group }" provided.` );
29
30
  return null;
30
31
  }
31
- if ( ! isSelected ) {
32
+ if ( ! isDisplayed ) {
32
33
  return null;
33
34
  }
34
35
 
@@ -5,6 +5,7 @@ import { createSlotFill } from '@wordpress/components';
5
5
 
6
6
  const InspectorControlsDefault = createSlotFill( 'InspectorControls' );
7
7
  const InspectorControlsAdvanced = createSlotFill( 'InspectorAdvancedControls' );
8
+ const InspectorControlsBorder = createSlotFill( 'InspectorControlsBorder' );
8
9
  const InspectorControlsDimensions = createSlotFill(
9
10
  'InspectorControlsDimensions'
10
11
  );
@@ -15,6 +16,7 @@ const InspectorControlsTypography = createSlotFill(
15
16
  const groups = {
16
17
  default: InspectorControlsDefault,
17
18
  advanced: InspectorControlsAdvanced,
19
+ border: InspectorControlsBorder,
18
20
  dimensions: InspectorControlsDimensions,
19
21
  typography: InspectorControlsTypography,
20
22
  };
@@ -13,7 +13,6 @@ import groups from './groups';
13
13
 
14
14
  export default function InspectorControlsSlot( {
15
15
  __experimentalGroup: group = 'default',
16
- bubblesVirtually = true,
17
16
  label,
18
17
  ...props
19
18
  } ) {
@@ -32,14 +31,10 @@ export default function InspectorControlsSlot( {
32
31
  if ( label ) {
33
32
  return (
34
33
  <BlockSupportToolsPanel group={ group } label={ label }>
35
- <BlockSupportSlotContainer
36
- { ...props }
37
- bubblesVirtually={ bubblesVirtually }
38
- Slot={ Slot }
39
- />
34
+ <BlockSupportSlotContainer { ...props } Slot={ Slot } />
40
35
  </BlockSupportToolsPanel>
41
36
  );
42
37
  }
43
38
 
44
- return <Slot { ...props } bubblesVirtually={ bubblesVirtually } />;
39
+ return <Slot { ...props } bubblesVirtually />;
45
40
  }
@@ -15,12 +15,12 @@ import useSetting from '../../components/use-setting';
15
15
  /**
16
16
  * Control for letter-spacing.
17
17
  *
18
- * @param {Object} props Component props.
19
- * @param {string} props.value Currently selected letter-spacing.
20
- * @param {Function} props.onChange Handles change in letter-spacing selection.
21
- * @param {boolean} props.__unstableInputWidth Input width to pass through to inner UnitControl.
18
+ * @param {Object} props Component props.
19
+ * @param {string} props.value Currently selected letter-spacing.
20
+ * @param {Function} props.onChange Handles change in letter-spacing selection.
21
+ * @param {string|number|undefined} props.__unstableInputWidth Input width to pass through to inner UnitControl. Should be a valid CSS value.
22
22
  *
23
- * @return {WPElement} Letter-spacing control.
23
+ * @return {WPElement} Letter-spacing control.
24
24
  */
25
25
  export default function LetterSpacingControl( {
26
26
  value,
@@ -33,7 +33,7 @@ export default function LetterSpacingControl( {
33
33
  } );
34
34
  return (
35
35
  <UnitControl
36
- label={ __( 'Letter-spacing' ) }
36
+ label={ __( 'Letter spacing' ) }
37
37
  value={ value }
38
38
  __unstableInputWidth={ __unstableInputWidth }
39
39
  units={ units }
@@ -114,7 +114,7 @@ Controls the query parameters used to search for suggestions. For example, to li
114
114
 
115
115
  ```jsx
116
116
  <LinkControl
117
- suggestionQuery={ {
117
+ suggestionsQuery={ {
118
118
  type: 'post',
119
119
  subtype: 'page',
120
120
  } }
@@ -1634,6 +1634,7 @@ describe( 'Selecting links', () => {
1634
1634
  );
1635
1635
 
1636
1636
  // We should have highlighted the first item using the keyboard
1637
+ // eslint-disable-next-line jest/no-conditional-expect
1637
1638
  expect( selectedSearchResultElement ).toEqual(
1638
1639
  secondSearchSuggestion
1639
1640
  );
@@ -1648,6 +1649,7 @@ describe( 'Selecting links', () => {
1648
1649
  );
1649
1650
 
1650
1651
  // We should be back to highlighting the first search result again
1652
+ // eslint-disable-next-line jest/no-conditional-expect
1651
1653
  expect( selectedSearchResultElement ).toEqual(
1652
1654
  firstSearchSuggestion
1653
1655
  );
@@ -19,6 +19,7 @@ import useBlockDisplayInformation from '../use-block-display-information';
19
19
  import { getBlockPositionDescription } from './utils';
20
20
  import BlockTitle from '../block-title';
21
21
  import ListViewExpander from './expander';
22
+ import { SPACE, ENTER } from '@wordpress/keycodes';
22
23
 
23
24
  function ListViewBlockSelectButton(
24
25
  {
@@ -47,6 +48,22 @@ function ListViewBlockSelectButton(
47
48
  level
48
49
  );
49
50
 
51
+ // The `href` attribute triggers the browser's native HTML drag operations.
52
+ // When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.
53
+ // We need to clear any HTML drag data to prevent `pasteHandler` from firing
54
+ // inside the `useOnBlockDrop` hook.
55
+ const onDragStartHandler = ( event ) => {
56
+ event.dataTransfer.clearData();
57
+ onDragStart( event );
58
+ };
59
+
60
+ function onKeyDownHandler( event ) {
61
+ if ( event.keyCode === ENTER || event.keyCode === SPACE ) {
62
+ event.preventDefault();
63
+ onClick( event );
64
+ }
65
+ }
66
+
50
67
  return (
51
68
  <>
52
69
  <Button
@@ -55,13 +72,15 @@ function ListViewBlockSelectButton(
55
72
  className
56
73
  ) }
57
74
  onClick={ onClick }
75
+ onKeyDown={ onKeyDownHandler }
58
76
  aria-describedby={ descriptionId }
59
77
  ref={ ref }
60
78
  tabIndex={ tabIndex }
61
79
  onFocus={ onFocus }
62
- onDragStart={ onDragStart }
80
+ onDragStart={ onDragStartHandler }
63
81
  onDragEnd={ onDragEnd }
64
82
  draggable={ draggable }
83
+ href={ `#block-${ clientId }` }
65
84
  >
66
85
  <ListViewExpander onClick={ onToggleExpanded } />
67
86
  <BlockIcon icon={ blockInformation?.icon } showColors />
@@ -75,6 +75,7 @@ export function MediaPlaceholder( {
75
75
  onDoubleClick,
76
76
  onFilesPreUpload = noop,
77
77
  onHTMLDrop = noop,
78
+ onClose = noop,
78
79
  children,
79
80
  mediaLibraryButton,
80
81
  placeholder,
@@ -328,6 +329,7 @@ export function MediaPlaceholder( {
328
329
  gallery={ multiple && onlyAllowsImages() }
329
330
  multiple={ multiple }
330
331
  onSelect={ onSelect }
332
+ onClose={ onClose }
331
333
  allowedTypes={ allowedTypes }
332
334
  value={
333
335
  Array.isArray( value )
@@ -39,6 +39,7 @@ const MediaReplaceFlow = ( {
39
39
  onSelect,
40
40
  onSelectURL,
41
41
  onFilesUpload = noop,
42
+ onCloseModal = noop,
42
43
  name = __( 'Replace' ),
43
44
  createNotice,
44
45
  removeNotice,
@@ -136,6 +137,7 @@ const MediaReplaceFlow = ( {
136
137
  value={ mediaId }
137
138
  onSelect={ ( media ) => selectMedia( media ) }
138
139
  allowedTypes={ allowedTypes }
140
+ onClose={ onCloseModal }
139
141
  render={ ( { open } ) => (
140
142
  <MenuItem icon={ mediaIcon } onClick={ open }>
141
143
  { __( 'Open Media Library' ) }
@@ -5,7 +5,9 @@ import { createBlobURL } from '@wordpress/blob';
5
5
 
6
6
  export function filePasteHandler( files ) {
7
7
  return files
8
- .filter( ( { type } ) => /^image\/(?:jpe?g|png|gif)$/.test( type ) )
8
+ .filter( ( { type } ) =>
9
+ /^image\/(?:jpe?g|png|gif|webp)$/.test( type )
10
+ )
9
11
  .map( ( file ) => `<img src="${ createBlobURL( file ) }">` )
10
12
  .join( '' );
11
13
  }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { insert } from '@wordpress/rich-text';
5
+
6
+ export function preventEventDiscovery( value ) {
7
+ const searchText = 'tales of gutenberg';
8
+ const addText =
9
+ ' 🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️';
10
+ const { start, text } = value;
11
+
12
+ if ( start < searchText.length ) {
13
+ return value;
14
+ }
15
+
16
+ const charactersBefore = text.slice( start - searchText.length, start );
17
+
18
+ if ( charactersBefore.toLowerCase() !== searchText ) {
19
+ return value;
20
+ }
21
+
22
+ return insert( value, addText );
23
+ }
@@ -11,6 +11,7 @@ import { useDispatch } from '@wordpress/data';
11
11
  * Internal dependencies
12
12
  */
13
13
  import { store as blockEditorStore } from '../../store';
14
+ import { preventEventDiscovery } from './prevent-event-discovery';
14
15
 
15
16
  export function useInputRules( props ) {
16
17
  const {
@@ -85,7 +86,7 @@ export function useInputRules( props ) {
85
86
 
86
87
  return accumlator;
87
88
  },
88
- value
89
+ preventEventDiscovery( value )
89
90
  );
90
91
 
91
92
  if ( transformed !== value ) {
@@ -12,6 +12,7 @@ import deprecated from '@wordpress/deprecated';
12
12
  export function MultiSelectScrollIntoView() {
13
13
  deprecated( 'wp.blockEditor.MultiSelectScrollIntoView', {
14
14
  hint: 'This behaviour is now built-in.',
15
+ since: '5.8',
15
16
  } );
16
17
  return null;
17
18
  }
@@ -147,6 +147,11 @@ _Optional._ If this property is added, a label will be generated using label pro
147
147
 
148
148
  _Optional._ Adds and optional class to the parent `div` that wraps the URLInput field and popover
149
149
 
150
+ ### `placeholder: String`
151
+
152
+ _Optional._ Placeholder text to show when the field is empty, similar to the
153
+ [`input` and `textarea` attribute of the same name](https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/HTML5_updates#The_placeholder_attribute).
154
+
150
155
  ### `disableSuggestions: Boolean`
151
156
 
152
157
  _Optional._ Provides additional control over whether suggestions are disabled.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect } from '@wordpress/data';
5
+ import { hasBlockSupport } from '@wordpress/blocks';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { useBlockEditContext } from '../block-edit/context';
11
+ import { store as blockEditorStore } from '../../store';
12
+
13
+ export default function useDisplayBlockControls() {
14
+ const { isSelected, clientId, name } = useBlockEditContext();
15
+ return useSelect(
16
+ ( select ) => {
17
+ const { getBlockName, getBlockRootClientId } = select(
18
+ blockEditorStore
19
+ );
20
+
21
+ const parentId = getBlockRootClientId( clientId );
22
+ const parentBlockName = getBlockName( parentId );
23
+
24
+ const hideControls = hasBlockSupport(
25
+ parentBlockName,
26
+ '__experimentalHideChildBlockControls',
27
+ false
28
+ );
29
+
30
+ if ( ! hideControls && isSelected ) {
31
+ return true;
32
+ }
33
+
34
+ return false;
35
+ },
36
+ [ clientId, isSelected, name ]
37
+ );
38
+ }
@@ -259,10 +259,14 @@ export default function useOnBlockDrop( targetRootClientId, targetBlockIndex ) {
259
259
  const files = getFilesFromDataTransfer( event.dataTransfer );
260
260
  const html = event.dataTransfer.getData( 'text/html' );
261
261
 
262
- if ( files.length ) {
263
- _onFilesDrop( files );
264
- } else if ( html ) {
262
+ /**
263
+ * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.
264
+ * The order of the checks is important to recognise the HTML drop.
265
+ */
266
+ if ( html ) {
265
267
  _onHTMLDrop( html );
268
+ } else if ( files.length ) {
269
+ _onFilesDrop( files );
266
270
  } else {
267
271
  _onDrop( event );
268
272
  }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { toggleRichText } from '../use-multi-selection';
5
+
6
+ describe( 'toggleRichText', () => {
7
+ function getContainer( isContentEditible ) {
8
+ const container = document.createDocumentFragment();
9
+ [
10
+ 'rich-text',
11
+ 'rich-text editor-post-title__input',
12
+ 'some-other-class',
13
+ ].forEach( ( className ) => {
14
+ const element = document.createElement( 'div' );
15
+ element.setAttribute( 'class', className );
16
+ if ( isContentEditible ) {
17
+ element.setAttribute( 'contenteditable', true );
18
+ }
19
+ container.appendChild( element );
20
+ } );
21
+ return container;
22
+ }
23
+
24
+ it( 'should set the `contenteditable` attribute on eligible rich text nodes', () => {
25
+ const container = getContainer();
26
+ toggleRichText( container, true );
27
+ let nodes = container.querySelectorAll( '[contenteditable=true]' );
28
+
29
+ expect( nodes ).toHaveLength( 1 );
30
+ expect( nodes[ 0 ].className ).toBe( 'rich-text' );
31
+
32
+ toggleRichText( container, false );
33
+ nodes = container.querySelectorAll( '[contenteditable=true]' );
34
+ expect( nodes ).toHaveLength( 0 );
35
+ } );
36
+ } );
@@ -15,16 +15,19 @@ import { useSelect } from '@wordpress/data';
15
15
  import { store as blockEditorStore } from '../../store';
16
16
  import { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';
17
17
 
18
- function toggleRichText( container, toggle ) {
19
- Array.from( container.querySelectorAll( '.rich-text' ) ).forEach(
20
- ( node ) => {
21
- if ( toggle ) {
22
- node.setAttribute( 'contenteditable', true );
23
- } else {
24
- node.removeAttribute( 'contenteditable' );
25
- }
18
+ export function toggleRichText( container, toggle ) {
19
+ Array.from(
20
+ container.querySelectorAll(
21
+ // Exclude the Post Title from multi-select disable.
22
+ '.rich-text:not( .editor-post-title__input )'
23
+ )
24
+ ).forEach( ( node ) => {
25
+ if ( toggle ) {
26
+ node.setAttribute( 'contenteditable', true );
27
+ } else {
28
+ node.removeAttribute( 'contenteditable' );
26
29
  }
27
- );
30
+ } );
28
31
  }
29
32
 
30
33
  /**
@@ -9,7 +9,7 @@ import classnames from 'classnames';
9
9
  import { addFilter } from '@wordpress/hooks';
10
10
  import { __ } from '@wordpress/i18n';
11
11
  import { createHigherOrderComponent } from '@wordpress/compose';
12
- import { useState } from '@wordpress/element';
12
+ import { useEffect, useState } from '@wordpress/element';
13
13
 
14
14
  /**
15
15
  * Internal dependencies
@@ -22,7 +22,11 @@ import {
22
22
  getColorObjectByAttributeValues,
23
23
  } from '../components/colors';
24
24
  import useSetting from '../components/use-setting';
25
- import { hasBorderSupport, shouldSkipSerialization } from './border';
25
+ import {
26
+ hasBorderSupport,
27
+ removeBorderAttribute,
28
+ shouldSkipSerialization,
29
+ } from './border';
26
30
  import { cleanEmptyObject } from './utils';
27
31
 
28
32
  // Defining empty array here instead of inline avoids unnecessary re-renders of
@@ -52,15 +56,30 @@ export function BorderColorEdit( props ) {
52
56
  ( colors, origin ) => colors.concat( origin.colors ),
53
57
  []
54
58
  );
59
+ const { color: customBorderColor } = style?.border || {};
55
60
  const [ colorValue, setColorValue ] = useState(
56
61
  () =>
57
62
  getColorObjectByAttributeValues(
58
63
  availableColors,
59
64
  borderColor,
60
- style?.border?.color
65
+ customBorderColor
61
66
  )?.color
62
67
  );
63
68
 
69
+ // Detect changes in the color attributes and update the colorValue to keep the
70
+ // UI in sync. This is necessary for situations when border controls interact with
71
+ // eachother: eg, setting the border width to zero causes the color and style
72
+ // selections to be cleared.
73
+ useEffect( () => {
74
+ setColorValue(
75
+ getColorObjectByAttributeValues(
76
+ availableColors,
77
+ borderColor,
78
+ customBorderColor
79
+ )?.color
80
+ );
81
+ }, [ borderColor, customBorderColor, availableColors ] );
82
+
64
83
  const onChangeColor = ( value ) => {
65
84
  setColorValue( value );
66
85
 
@@ -98,6 +117,39 @@ export function BorderColorEdit( props ) {
98
117
  );
99
118
  }
100
119
 
120
+ /**
121
+ * Checks if there is a current value in the border color block support
122
+ * attributes.
123
+ *
124
+ * @param {Object} props Block props.
125
+ * @return {boolean} Whether or not the block has a border color value set.
126
+ */
127
+ export function hasBorderColorValue( props ) {
128
+ const {
129
+ attributes: { borderColor, style },
130
+ } = props;
131
+
132
+ return !! borderColor || !! style?.border?.color;
133
+ }
134
+
135
+ /**
136
+ * Resets the border color block support attributes. This can be used when
137
+ * disabling the border color support controls for a block via a progressive
138
+ * discovery panel.
139
+ *
140
+ * @param {Object} props Block props.
141
+ * @param {Object} props.attributes Block's attributes.
142
+ * @param {Object} props.setAttributes Function to set block's attributes.
143
+ */
144
+ export function resetBorderColor( { attributes = {}, setAttributes } ) {
145
+ const { style } = attributes;
146
+
147
+ setAttributes( {
148
+ borderColor: undefined,
149
+ style: removeBorderAttribute( style, 'color' ),
150
+ } );
151
+ }
152
+
101
153
  /**
102
154
  * Filters registered block settings, extending attributes to include
103
155
  * `borderColor` if needed.
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import BorderRadiusControl from '../components/border-radius-control';
5
5
  import { cleanEmptyObject } from './utils';
6
+ import { removeBorderAttribute } from './border';
6
7
 
7
8
  /**
8
9
  * Inspector control panel containing the border radius related configuration.
@@ -40,3 +41,34 @@ export function BorderRadiusEdit( props ) {
40
41
  />
41
42
  );
42
43
  }
44
+
45
+ /**
46
+ * Checks if there is a current value in the border radius block support
47
+ * attributes.
48
+ *
49
+ * @param {Object} props Block props.
50
+ * @return {boolean} Whether or not the block has a border radius value set.
51
+ */
52
+ export function hasBorderRadiusValue( props ) {
53
+ const borderRadius = props.attributes.style?.border?.radius;
54
+
55
+ if ( typeof borderRadius === 'object' ) {
56
+ return Object.entries( borderRadius ).some( Boolean );
57
+ }
58
+
59
+ return !! borderRadius;
60
+ }
61
+
62
+ /**
63
+ * Resets the border radius block support attributes. This can be used when
64
+ * disabling the border radius support controls for a block via a progressive
65
+ * discovery panel.
66
+ *
67
+ * @param {Object} props Block props.
68
+ * @param {Object} props.attributes Block's attributes.
69
+ * @param {Object} props.setAttributes Function to set block's attributes.
70
+ */
71
+ export function resetBorderRadius( { attributes = {}, setAttributes } ) {
72
+ const { style } = attributes;
73
+ setAttributes( { style: removeBorderAttribute( style, 'radius' ) } );
74
+ }
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import BorderStyleControl from '../components/border-style-control';
5
5
  import { cleanEmptyObject } from './utils';
6
+ import { removeBorderAttribute } from './border';
6
7
 
7
8
  /**
8
9
  * Inspector control for configuring border style property.
@@ -36,3 +37,28 @@ export const BorderStyleEdit = ( props ) => {
36
37
  />
37
38
  );
38
39
  };
40
+
41
+ /**
42
+ * Checks if there is a current value in the border style block support
43
+ * attributes.
44
+ *
45
+ * @param {Object} props Block props.
46
+ * @return {boolean} Whether or not the block has a border style value set.
47
+ */
48
+ export function hasBorderStyleValue( props ) {
49
+ return !! props.attributes.style?.border?.style;
50
+ }
51
+
52
+ /**
53
+ * Resets the border style block support attribute. This can be used when
54
+ * disabling the border style support control for a block via a progressive
55
+ * discovery panel.
56
+ *
57
+ * @param {Object} props Block props.
58
+ * @param {Object} props.attributes Block's attributes.
59
+ * @param {Object} props.setAttributes Function to set block's attributes.
60
+ */
61
+ export function resetBorderStyle( { attributes = {}, setAttributes } ) {
62
+ const { style } = attributes;
63
+ setAttributes( { style: removeBorderAttribute( style, 'style' ) } );
64
+ }