@wordpress/block-editor 15.8.1-next.16d95556a.0 → 15.9.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 (302) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-inspector/edit-contents.js +19 -23
  3. package/build/components/block-inspector/edit-contents.js.map +3 -3
  4. package/build/components/block-inspector/index.js +7 -1
  5. package/build/components/block-inspector/index.js.map +2 -2
  6. package/build/components/block-list/block.js +4 -0
  7. package/build/components/block-list/block.js.map +2 -2
  8. package/build/components/block-list/index.js +2 -1
  9. package/build/components/block-list/index.js.map +2 -2
  10. package/build/components/block-list/use-block-props/index.js +3 -1
  11. package/build/components/block-list/use-block-props/index.js.map +2 -2
  12. package/build/components/block-list/use-block-props/use-is-hovered.js +16 -10
  13. package/build/components/block-list/use-block-props/use-is-hovered.js.map +2 -2
  14. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
  15. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
  16. package/build/components/block-lock/modal.js +5 -5
  17. package/build/components/block-lock/modal.js.map +2 -2
  18. package/build/components/block-lock/use-block-lock.js +10 -13
  19. package/build/components/block-lock/use-block-lock.js.map +2 -2
  20. package/build/components/block-settings-menu-controls/edit-section-menu-item.js +64 -0
  21. package/build/components/block-settings-menu-controls/edit-section-menu-item.js.map +7 -0
  22. package/build/components/block-settings-menu-controls/index.js +9 -1
  23. package/build/components/block-settings-menu-controls/index.js.map +2 -2
  24. package/build/components/block-toolbar/block-toolbar-icon.js +9 -9
  25. package/build/components/block-toolbar/block-toolbar-icon.js.map +2 -2
  26. package/build/components/block-tools/index.js +56 -45
  27. package/build/components/block-tools/index.js.map +3 -3
  28. package/build/components/block-variation-transforms/index.js +32 -5
  29. package/build/components/block-variation-transforms/index.js.map +2 -2
  30. package/build/components/block-visibility/toolbar.js +1 -1
  31. package/build/components/block-visibility/toolbar.js.map +1 -1
  32. package/build/components/border-radius-control/single-input-control.js +1 -0
  33. package/build/components/border-radius-control/single-input-control.js.map +2 -2
  34. package/build/components/content-only-controls/fields-dropdown-menu.js +66 -0
  35. package/build/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
  36. package/build/components/content-only-controls/index.js +444 -0
  37. package/build/components/content-only-controls/index.js.map +7 -0
  38. package/build/components/content-only-controls/link/index.js +193 -0
  39. package/build/components/content-only-controls/link/index.js.map +7 -0
  40. package/build/components/content-only-controls/media/index.js +264 -0
  41. package/build/components/content-only-controls/media/index.js.map +7 -0
  42. package/build/components/content-only-controls/rich-text/index.js +188 -0
  43. package/build/components/content-only-controls/rich-text/index.js.map +7 -0
  44. package/build/components/content-only-controls/use-inspector-popover-placement.js +41 -0
  45. package/build/components/content-only-controls/use-inspector-popover-placement.js.map +7 -0
  46. package/build/components/font-family/index.js +1 -15
  47. package/build/components/font-family/index.js.map +2 -2
  48. package/build/components/global-styles/dimensions-panel.js +35 -2
  49. package/build/components/global-styles/dimensions-panel.js.map +2 -2
  50. package/build/components/global-styles/hooks.js +1 -1
  51. package/build/components/global-styles/hooks.js.map +2 -2
  52. package/build/components/global-styles/typography-panel.js +1 -2
  53. package/build/components/global-styles/typography-panel.js.map +2 -2
  54. package/build/components/inserter/media-tab/media-tab.js +1 -33
  55. package/build/components/inserter/media-tab/media-tab.js.map +3 -3
  56. package/build/components/inspector-controls-tabs/content-tab.js +6 -2
  57. package/build/components/inspector-controls-tabs/content-tab.js.map +3 -3
  58. package/build/components/inspector-controls-tabs/index.js +7 -1
  59. package/build/components/inspector-controls-tabs/index.js.map +2 -2
  60. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
  61. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
  62. package/build/components/link-control/index.js +15 -7
  63. package/build/components/link-control/index.js.map +2 -2
  64. package/build/components/list-view/block-select-button.js +7 -8
  65. package/build/components/list-view/block-select-button.js.map +2 -2
  66. package/build/components/list-view/block.js +9 -7
  67. package/build/components/list-view/block.js.map +2 -2
  68. package/build/components/media-placeholder/index.js +18 -35
  69. package/build/components/media-placeholder/index.js.map +3 -3
  70. package/build/components/media-placeholder/utils.js +60 -0
  71. package/build/components/media-placeholder/utils.js.map +7 -0
  72. package/build/components/media-replace-flow/index.js +24 -33
  73. package/build/components/media-replace-flow/index.js.map +3 -3
  74. package/build/components/use-block-commands/index.js +1 -1
  75. package/build/components/use-block-commands/index.js.map +2 -2
  76. package/build/components/use-block-display-information/index.js +21 -1
  77. package/build/components/use-block-display-information/index.js.map +3 -3
  78. package/build/components/use-block-drop-zone/index.js +1 -5
  79. package/build/components/use-block-drop-zone/index.js.map +2 -2
  80. package/build/hooks/block-bindings.js +52 -61
  81. package/build/hooks/block-bindings.js.map +3 -3
  82. package/build/hooks/dimensions.js +3 -3
  83. package/build/hooks/dimensions.js.map +2 -2
  84. package/build/hooks/metadata.js +1 -1
  85. package/build/hooks/metadata.js.map +2 -2
  86. package/build/hooks/use-content-only-section-edit.js +67 -0
  87. package/build/hooks/use-content-only-section-edit.js.map +7 -0
  88. package/build/hooks/utils.js +5 -1
  89. package/build/hooks/utils.js.map +2 -2
  90. package/build/layouts/constrained.js +2 -2
  91. package/build/layouts/constrained.js.map +2 -2
  92. package/build/private-apis.js +2 -3
  93. package/build/private-apis.js.map +3 -3
  94. package/build/store/private-keys.js +3 -0
  95. package/build/store/private-keys.js.map +2 -2
  96. package/build/store/private-selectors.js +41 -2
  97. package/build/store/private-selectors.js.map +2 -2
  98. package/build/store/selectors.js +6 -4
  99. package/build/store/selectors.js.map +2 -2
  100. package/build/utils/fit-text-utils.js +9 -1
  101. package/build/utils/fit-text-utils.js.map +2 -2
  102. package/build-module/components/block-inspector/edit-contents.js +9 -23
  103. package/build-module/components/block-inspector/edit-contents.js.map +2 -2
  104. package/build-module/components/block-inspector/index.js +7 -1
  105. package/build-module/components/block-inspector/index.js.map +2 -2
  106. package/build-module/components/block-list/block.js +4 -0
  107. package/build-module/components/block-list/block.js.map +2 -2
  108. package/build-module/components/block-list/index.js +2 -1
  109. package/build-module/components/block-list/index.js.map +2 -2
  110. package/build-module/components/block-list/use-block-props/index.js +3 -1
  111. package/build-module/components/block-list/use-block-props/index.js.map +2 -2
  112. package/build-module/components/block-list/use-block-props/use-is-hovered.js +16 -10
  113. package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +2 -2
  114. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
  115. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
  116. package/build-module/components/block-lock/modal.js +5 -5
  117. package/build-module/components/block-lock/modal.js.map +2 -2
  118. package/build-module/components/block-lock/use-block-lock.js +10 -13
  119. package/build-module/components/block-lock/use-block-lock.js.map +2 -2
  120. package/build-module/components/block-settings-menu-controls/edit-section-menu-item.js +29 -0
  121. package/build-module/components/block-settings-menu-controls/edit-section-menu-item.js.map +7 -0
  122. package/build-module/components/block-settings-menu-controls/index.js +9 -1
  123. package/build-module/components/block-settings-menu-controls/index.js.map +2 -2
  124. package/build-module/components/block-toolbar/block-toolbar-icon.js +10 -10
  125. package/build-module/components/block-toolbar/block-toolbar-icon.js.map +2 -2
  126. package/build-module/components/block-tools/index.js +56 -45
  127. package/build-module/components/block-tools/index.js.map +2 -2
  128. package/build-module/components/block-variation-transforms/index.js +32 -5
  129. package/build-module/components/block-variation-transforms/index.js.map +2 -2
  130. package/build-module/components/block-visibility/toolbar.js +1 -1
  131. package/build-module/components/block-visibility/toolbar.js.map +1 -1
  132. package/build-module/components/border-radius-control/single-input-control.js +1 -0
  133. package/build-module/components/border-radius-control/single-input-control.js.map +2 -2
  134. package/build-module/components/content-only-controls/fields-dropdown-menu.js +45 -0
  135. package/build-module/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
  136. package/build-module/components/content-only-controls/index.js +420 -0
  137. package/build-module/components/content-only-controls/index.js.map +7 -0
  138. package/build-module/components/content-only-controls/link/index.js +160 -0
  139. package/build-module/components/content-only-controls/link/index.js.map +7 -0
  140. package/build-module/components/content-only-controls/media/index.js +242 -0
  141. package/build-module/components/content-only-controls/media/index.js.map +7 -0
  142. package/build-module/components/content-only-controls/rich-text/index.js +160 -0
  143. package/build-module/components/content-only-controls/rich-text/index.js.map +7 -0
  144. package/build-module/components/content-only-controls/use-inspector-popover-placement.js +16 -0
  145. package/build-module/components/content-only-controls/use-inspector-popover-placement.js.map +7 -0
  146. package/build-module/components/font-family/index.js +1 -15
  147. package/build-module/components/font-family/index.js.map +2 -2
  148. package/build-module/components/global-styles/dimensions-panel.js +35 -2
  149. package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
  150. package/build-module/components/global-styles/hooks.js +1 -1
  151. package/build-module/components/global-styles/hooks.js.map +2 -2
  152. package/build-module/components/global-styles/typography-panel.js +1 -2
  153. package/build-module/components/global-styles/typography-panel.js.map +2 -2
  154. package/build-module/components/inserter/media-tab/media-tab.js +2 -34
  155. package/build-module/components/inserter/media-tab/media-tab.js.map +2 -2
  156. package/build-module/components/inspector-controls-tabs/content-tab.js +7 -3
  157. package/build-module/components/inspector-controls-tabs/content-tab.js.map +2 -2
  158. package/build-module/components/inspector-controls-tabs/index.js +7 -1
  159. package/build-module/components/inspector-controls-tabs/index.js.map +2 -2
  160. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
  161. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
  162. package/build-module/components/link-control/index.js +16 -8
  163. package/build-module/components/link-control/index.js.map +2 -2
  164. package/build-module/components/list-view/block-select-button.js +14 -9
  165. package/build-module/components/list-view/block-select-button.js.map +2 -2
  166. package/build-module/components/list-view/block.js +9 -7
  167. package/build-module/components/list-view/block.js.map +2 -2
  168. package/build-module/components/media-placeholder/index.js +19 -36
  169. package/build-module/components/media-placeholder/index.js.map +2 -2
  170. package/build-module/components/media-placeholder/utils.js +35 -0
  171. package/build-module/components/media-placeholder/utils.js.map +7 -0
  172. package/build-module/components/media-replace-flow/index.js +24 -33
  173. package/build-module/components/media-replace-flow/index.js.map +2 -2
  174. package/build-module/components/use-block-commands/index.js +1 -1
  175. package/build-module/components/use-block-commands/index.js.map +2 -2
  176. package/build-module/components/use-block-display-information/index.js +21 -1
  177. package/build-module/components/use-block-display-information/index.js.map +3 -3
  178. package/build-module/components/use-block-drop-zone/index.js +1 -5
  179. package/build-module/components/use-block-drop-zone/index.js.map +2 -2
  180. package/build-module/hooks/block-bindings.js +57 -62
  181. package/build-module/hooks/block-bindings.js.map +2 -2
  182. package/build-module/hooks/dimensions.js +3 -3
  183. package/build-module/hooks/dimensions.js.map +2 -2
  184. package/build-module/hooks/metadata.js +1 -1
  185. package/build-module/hooks/metadata.js.map +2 -2
  186. package/build-module/hooks/use-content-only-section-edit.js +46 -0
  187. package/build-module/hooks/use-content-only-section-edit.js.map +7 -0
  188. package/build-module/hooks/utils.js +5 -1
  189. package/build-module/hooks/utils.js.map +2 -2
  190. package/build-module/layouts/constrained.js +2 -2
  191. package/build-module/layouts/constrained.js.map +2 -2
  192. package/build-module/private-apis.js +3 -3
  193. package/build-module/private-apis.js.map +2 -2
  194. package/build-module/store/private-keys.js +2 -0
  195. package/build-module/store/private-keys.js.map +2 -2
  196. package/build-module/store/private-selectors.js +37 -2
  197. package/build-module/store/private-selectors.js.map +2 -2
  198. package/build-module/store/selectors.js +6 -4
  199. package/build-module/store/selectors.js.map +2 -2
  200. package/build-module/utils/fit-text-utils.js +9 -1
  201. package/build-module/utils/fit-text-utils.js.map +2 -2
  202. package/build-style/content-rtl.css +3 -0
  203. package/build-style/content.css +3 -0
  204. package/build-style/style-rtl.css +145 -4
  205. package/build-style/style.css +145 -4
  206. package/package.json +38 -37
  207. package/src/components/block-inspector/edit-contents.js +10 -29
  208. package/src/components/block-inspector/index.js +4 -2
  209. package/src/components/block-list/block.js +6 -0
  210. package/src/components/block-list/content.scss +5 -0
  211. package/src/components/block-list/index.js +3 -1
  212. package/src/components/block-list/use-block-props/index.js +3 -1
  213. package/src/components/block-list/use-block-props/use-is-hovered.js +24 -12
  214. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +34 -3
  215. package/src/components/block-lock/modal.js +6 -5
  216. package/src/components/block-lock/use-block-lock.js +10 -14
  217. package/src/components/block-patterns-list/stories/{index.story.js → index.story.jsx} +3 -1
  218. package/src/components/block-settings-menu-controls/edit-section-menu-item.js +39 -0
  219. package/src/components/block-settings-menu-controls/index.js +8 -1
  220. package/src/components/block-toolbar/block-toolbar-icon.js +14 -10
  221. package/src/components/block-tools/index.js +15 -2
  222. package/src/components/block-tools/style.scss +4 -0
  223. package/src/components/block-variation-transforms/index.js +96 -35
  224. package/src/components/block-visibility/toolbar.js +1 -1
  225. package/src/components/border-radius-control/single-input-control.js +1 -0
  226. package/src/components/content-only-controls/fields-dropdown-menu.js +53 -0
  227. package/src/components/content-only-controls/index.js +560 -0
  228. package/src/components/content-only-controls/link/index.js +200 -0
  229. package/src/components/content-only-controls/link/styles.scss +23 -0
  230. package/src/components/content-only-controls/media/index.js +306 -0
  231. package/src/components/content-only-controls/media/styles.scss +47 -0
  232. package/src/components/content-only-controls/rich-text/index.js +179 -0
  233. package/src/components/content-only-controls/rich-text/styles.scss +24 -0
  234. package/src/components/content-only-controls/styles.scss +44 -0
  235. package/src/components/content-only-controls/use-inspector-popover-placement.js +19 -0
  236. package/src/components/font-family/README.md +0 -9
  237. package/src/components/font-family/index.js +1 -16
  238. package/src/components/font-family/stories/{index.story.js → index.story.jsx} +0 -1
  239. package/src/components/global-styles/dimensions-panel.js +36 -0
  240. package/src/components/global-styles/hooks.js +1 -1
  241. package/src/components/global-styles/typography-panel.js +0 -1
  242. package/src/components/inserter/media-tab/media-tab.js +2 -44
  243. package/src/components/inspector-controls-tabs/content-tab.js +12 -4
  244. package/src/components/inspector-controls-tabs/index.js +4 -1
  245. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -5
  246. package/src/components/link-control/index.js +36 -12
  247. package/src/components/list-view/block-select-button.js +15 -10
  248. package/src/components/list-view/block.js +9 -7
  249. package/src/components/media-placeholder/index.js +21 -46
  250. package/src/components/media-placeholder/test/get-computed-accept-attribute.js +164 -0
  251. package/src/components/media-placeholder/utils.js +65 -0
  252. package/src/components/media-replace-flow/index.js +25 -42
  253. package/src/components/use-block-commands/index.js +1 -1
  254. package/src/components/use-block-display-information/index.js +30 -2
  255. package/src/components/use-block-drop-zone/index.js +1 -5
  256. package/src/hooks/block-bindings.js +71 -82
  257. package/src/hooks/dimensions.js +8 -3
  258. package/src/hooks/metadata.js +1 -1
  259. package/src/hooks/test/metadata.js +1 -1
  260. package/src/hooks/use-content-only-section-edit.js +63 -0
  261. package/src/hooks/utils.js +4 -0
  262. package/src/layouts/constrained.js +8 -2
  263. package/src/private-apis.js +2 -2
  264. package/src/store/private-keys.js +1 -0
  265. package/src/store/private-selectors.js +121 -5
  266. package/src/store/selectors.js +6 -4
  267. package/src/store/test/private-selectors.js +242 -0
  268. package/src/style.scss +1 -1
  269. package/src/utils/fit-text-utils.js +19 -1
  270. package/tsconfig.json +1 -0
  271. package/build/components/media-upload-modal/index.js +0 -29
  272. package/build/components/media-upload-modal/index.js.map +0 -7
  273. package/build-module/components/media-upload-modal/index.js +0 -8
  274. package/build-module/components/media-upload-modal/index.js.map +0 -7
  275. package/src/components/font-family/style.scss +0 -7
  276. package/src/components/media-upload-modal/index.js +0 -18
  277. /package/src/components/alignment-control/stories/{aliginment-toolbar.story.js → aliginment-toolbar.story.jsx} +0 -0
  278. /package/src/components/alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
  279. /package/src/components/block-alignment-matrix-control/stories/{index.story.js → index.story.jsx} +0 -0
  280. /package/src/components/block-draggable/stories/{index.story.js → index.story.jsx} +0 -0
  281. /package/src/components/block-heading-level-dropdown/stories/{index.story.js → index.story.jsx} +0 -0
  282. /package/src/components/block-mover/stories/{index.story.js → index.story.jsx} +0 -0
  283. /package/src/components/block-title/stories/{index.story.js → index.story.jsx} +0 -0
  284. /package/src/components/border-radius-control/stories/{index.story.js → index.story.jsx} +0 -0
  285. /package/src/components/date-format-picker/stories/{index.story.js → index.story.jsx} +0 -0
  286. /package/src/components/dimensions-tool/stories/{aspect-ratio-tool.story.js → aspect-ratio-tool.story.jsx} +0 -0
  287. /package/src/components/dimensions-tool/stories/{index.story.js → index.story.jsx} +0 -0
  288. /package/src/components/dimensions-tool/stories/{scale-tool.story.js → scale-tool.story.jsx} +0 -0
  289. /package/src/components/dimensions-tool/stories/{width-height-tool.story.js → width-height-tool.story.jsx} +0 -0
  290. /package/src/components/height-control/stories/{index.story.js → index.story.jsx} +0 -0
  291. /package/src/components/inserter/stories/{index.story.js → index.story.jsx} +0 -0
  292. /package/src/components/line-height-control/stories/{index.story.js → index.story.jsx} +0 -0
  293. /package/src/components/plain-text/stories/{index.story.js → index.story.jsx} +0 -0
  294. /package/src/components/resolution-tool/stories/{index.story.js → index.story.jsx} +0 -0
  295. /package/src/components/tabbed-sidebar/stories/{index.story.js → index.story.jsx} +0 -0
  296. /package/src/components/text-alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
  297. /package/src/components/text-decoration-control/stories/{index.story.js → index.story.jsx} +0 -0
  298. /package/src/components/text-transform-control/stories/{index.story.js → index.story.jsx} +0 -0
  299. /package/src/components/unit-control/stories/{index.story.js → index.story.jsx} +0 -0
  300. /package/src/components/url-popover/stories/{index.story.js → index.story.jsx} +0 -0
  301. /package/src/components/warning/stories/{index.story.js → index.story.jsx} +0 -0
  302. /package/src/components/writing-mode-control/stories/{index.story.js → index.story.jsx} +0 -0
@@ -15,21 +15,33 @@ function listener( event ) {
15
15
  );
16
16
  }
17
17
 
18
- /*
18
+ /**
19
19
  * Adds `is-hovered` class when the block is hovered and in navigation or
20
20
  * outline mode.
21
+ *
22
+ * @param {Object} options Options object.
23
+ * @param {boolean} [options.isEnabled=true] Whether to enable hover detection.
24
+ *
25
+ * @return {Function} Ref callback.
21
26
  */
22
- export function useIsHovered() {
23
- return useRefEffect( ( node ) => {
24
- node.addEventListener( 'mouseout', listener );
25
- node.addEventListener( 'mouseover', listener );
27
+ export function useIsHovered( { isEnabled = true } = {} ) {
28
+ return useRefEffect(
29
+ ( node ) => {
30
+ if ( ! isEnabled ) {
31
+ return;
32
+ }
33
+
34
+ node.addEventListener( 'mouseout', listener );
35
+ node.addEventListener( 'mouseover', listener );
26
36
 
27
- return () => {
28
- node.removeEventListener( 'mouseout', listener );
29
- node.removeEventListener( 'mouseover', listener );
37
+ return () => {
38
+ node.removeEventListener( 'mouseout', listener );
39
+ node.removeEventListener( 'mouseover', listener );
30
40
 
31
- // Remove class in case it lingers.
32
- node.classList.remove( 'is-hovered' );
33
- };
34
- }, [] );
41
+ // Remove class in case it lingers.
42
+ node.classList.remove( 'is-hovered' );
43
+ };
44
+ },
45
+ [ isEnabled ]
46
+ );
35
47
  }
@@ -25,15 +25,20 @@ function isColorTransparent( color ) {
25
25
  * @param {string} clientId Block client ID.
26
26
  */
27
27
  export function useEventHandlers( { clientId, isSelected } ) {
28
- const { getBlockRootClientId, isZoomOut, hasMultiSelection } = unlock(
29
- useSelect( blockEditorStore )
30
- );
28
+ const {
29
+ getBlockRootClientId,
30
+ isZoomOut,
31
+ hasMultiSelection,
32
+ isSectionBlock,
33
+ editedContentOnlySection,
34
+ } = unlock( useSelect( blockEditorStore ) );
31
35
  const {
32
36
  insertAfterBlock,
33
37
  removeBlock,
34
38
  resetZoomLevel,
35
39
  startDraggingBlocks,
36
40
  stopDraggingBlocks,
41
+ editContentOnlySection,
37
42
  } = unlock( useDispatch( blockEditorStore ) );
38
43
 
39
44
  return useRefEffect(
@@ -282,9 +287,32 @@ export function useEventHandlers( { clientId, isSelected } ) {
282
287
  node.addEventListener( 'keydown', onKeyDown );
283
288
  node.addEventListener( 'dragstart', onDragStart );
284
289
 
290
+ /**
291
+ * Handles double-click events on section blocks to edit content only section.
292
+ *
293
+ * @param {MouseEvent} event Double-click event.
294
+ */
295
+ function onDoubleClick( event ) {
296
+ const isSection = isSectionBlock( clientId );
297
+ const isAlreadyEditing = editedContentOnlySection === clientId;
298
+
299
+ if ( isSection && ! isAlreadyEditing ) {
300
+ event.preventDefault();
301
+ editContentOnlySection( clientId );
302
+ }
303
+ }
304
+
305
+ // Only add double-click listener if experimental flag is enabled
306
+ if ( window?.__experimentalContentOnlyPatternInsertion ) {
307
+ node.addEventListener( 'dblclick', onDoubleClick );
308
+ }
309
+
285
310
  return () => {
286
311
  node.removeEventListener( 'keydown', onKeyDown );
287
312
  node.removeEventListener( 'dragstart', onDragStart );
313
+ if ( window?.__experimentalContentOnlyPatternInsertion ) {
314
+ node.removeEventListener( 'dblclick', onDoubleClick );
315
+ }
288
316
  };
289
317
  },
290
318
  [
@@ -298,6 +326,9 @@ export function useEventHandlers( { clientId, isSelected } ) {
298
326
  hasMultiSelection,
299
327
  startDraggingBlocks,
300
328
  stopDraggingBlocks,
329
+ isSectionBlock,
330
+ editedContentOnlySection,
331
+ editContentOnlySection,
301
332
  ]
302
333
  );
303
334
  }
@@ -42,7 +42,8 @@ function getTemplateLockValue( lock ) {
42
42
 
43
43
  export default function BlockLockModal( { clientId, onClose } ) {
44
44
  const [ lock, setLock ] = useState( { move: false, remove: false } );
45
- const { canEdit, canMove, canRemove } = useBlockLock( clientId );
45
+ const { isEditLocked, isMoveLocked, isRemoveLocked } =
46
+ useBlockLock( clientId );
46
47
  const { allowsEditLocking, templateLock, hasTemplateLock } = useSelect(
47
48
  ( select ) => {
48
49
  const { getBlockName, getBlockAttributes } =
@@ -66,11 +67,11 @@ export default function BlockLockModal( { clientId, onClose } ) {
66
67
 
67
68
  useEffect( () => {
68
69
  setLock( {
69
- move: ! canMove,
70
- remove: ! canRemove,
71
- ...( allowsEditLocking ? { edit: ! canEdit } : {} ),
70
+ move: isMoveLocked,
71
+ remove: isRemoveLocked,
72
+ ...( allowsEditLocking ? { edit: isEditLocked } : {} ),
72
73
  } );
73
- }, [ canEdit, canMove, canRemove, allowsEditLocking ] );
74
+ }, [ isEditLocked, isMoveLocked, isRemoveLocked, allowsEditLocking ] );
74
75
 
75
76
  const isAllChecked = Object.values( lock ).every( Boolean );
76
77
  const isMixed = Object.values( lock ).some( Boolean ) && ! isAllChecked;
@@ -7,6 +7,7 @@ import { useSelect } from '@wordpress/data';
7
7
  * Internal dependencies
8
8
  */
9
9
  import { store as blockEditorStore } from '../../store';
10
+ import { unlock } from '../../lock-unlock';
10
11
 
11
12
  /**
12
13
  * Return details about the block lock status.
@@ -19,25 +20,20 @@ export default function useBlockLock( clientId ) {
19
20
  return useSelect(
20
21
  ( select ) => {
21
22
  const {
22
- canEditBlock,
23
- canMoveBlock,
24
- canRemoveBlock,
25
23
  canLockBlockType,
26
24
  getBlockName,
27
- getTemplateLock,
28
- } = select( blockEditorStore );
29
-
30
- const canEdit = canEditBlock( clientId );
31
- const canMove = canMoveBlock( clientId );
32
- const canRemove = canRemoveBlock( clientId );
25
+ isEditLockedBlock,
26
+ isMoveLockedBlock,
27
+ isRemoveLockedBlock,
28
+ isLockedBlock,
29
+ } = unlock( select( blockEditorStore ) );
33
30
 
34
31
  return {
35
- canEdit,
36
- canMove,
37
- canRemove,
32
+ isEditLocked: isEditLockedBlock( clientId ),
33
+ isMoveLocked: isMoveLockedBlock( clientId ),
34
+ isRemoveLocked: isRemoveLockedBlock( clientId ),
38
35
  canLock: canLockBlockType( getBlockName( clientId ) ),
39
- isContentLocked: getTemplateLock( clientId ) === 'contentOnly',
40
- isLocked: ! canEdit || ! canMove || ! canRemove,
36
+ isLocked: isLockedBlock( clientId ),
41
37
  };
42
38
  },
43
39
  [ clientId ]
@@ -2,6 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import blockLibraryStyles from '!!raw-loader!../../../../../block-library/build-style/style.css';
5
+ import { fn } from '@storybook/test';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -32,6 +33,8 @@ export const Default = {
32
33
  isDraggable: false,
33
34
  label: 'Block patterns story',
34
35
  showTitlesAsTooltip: false,
36
+ onClickPattern: fn(),
37
+ onHover: fn(),
35
38
  },
36
39
  argTypes: {
37
40
  blockPatterns: { description: 'The patterns to render.' },
@@ -58,7 +61,6 @@ export const Default = {
58
61
  },
59
62
  },
60
63
  parameters: {
61
- actions: { argTypesRegex: '^on.*' },
62
64
  controls: { expanded: true },
63
65
  },
64
66
  };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { MenuItem } from '@wordpress/components';
5
+ import { _x } from '@wordpress/i18n';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import useContentOnlySectionEdit from '../../hooks/use-content-only-section-edit';
11
+
12
+ export function EditSectionMenuItem( { clientId, onClose } ) {
13
+ const {
14
+ isSectionBlock,
15
+ isEditingContentOnlySection,
16
+ editContentOnlySection,
17
+ } = useContentOnlySectionEdit( clientId );
18
+
19
+ // Only show when the experiment is enabled, the block is a section block,
20
+ // and we're not already editing it
21
+ if (
22
+ ! window?.__experimentalContentOnlyPatternInsertion ||
23
+ ! isSectionBlock ||
24
+ isEditingContentOnlySection
25
+ ) {
26
+ return null;
27
+ }
28
+
29
+ return (
30
+ <MenuItem
31
+ onClick={ () => {
32
+ editContentOnlySection( clientId );
33
+ onClose();
34
+ } }
35
+ >
36
+ { _x( 'Edit section', 'Editing a section in the Editor' ) }
37
+ </MenuItem>
38
+ );
39
+ }
@@ -22,6 +22,7 @@ import BlockModeToggle from '../block-settings-menu/block-mode-toggle';
22
22
  import { ModifyContentOnlySectionMenuItem } from '../content-lock';
23
23
  import { BlockRenameControl, useBlockRename } from '../block-rename';
24
24
  import { BlockVisibilityMenuItem } from '../block-visibility';
25
+ import { EditSectionMenuItem } from './edit-section-menu-item';
25
26
 
26
27
  const { Fill, Slot } = createSlotFill( 'BlockSettingsMenuControls' );
27
28
 
@@ -49,7 +50,7 @@ const BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {
49
50
  canToggleSelectedBlocksVisibility: getBlocksByClientId(
50
51
  ids
51
52
  ).every( ( block ) =>
52
- hasBlockSupport( block.name, 'blockVisibility', true )
53
+ hasBlockSupport( block.name, 'visibility', true )
53
54
  ),
54
55
  };
55
56
  },
@@ -98,6 +99,12 @@ const BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {
98
99
  onClose={ fillProps?.onClose }
99
100
  />
100
101
  ) }
102
+ { selectedClientIds.length === 1 && (
103
+ <EditSectionMenuItem
104
+ clientId={ selectedClientIds[ 0 ] }
105
+ onClose={ fillProps?.onClose }
106
+ />
107
+ ) }
101
108
  { showLockButton && (
102
109
  <BlockLockMenuItem
103
110
  clientId={ selectedClientIds[ 0 ] }
@@ -4,7 +4,7 @@
4
4
  import { ToolbarButton } from '@wordpress/components';
5
5
  import { __ } from '@wordpress/i18n';
6
6
  import { useSelect } from '@wordpress/data';
7
- import { copy } from '@wordpress/icons';
7
+ import { copy, symbol } from '@wordpress/icons';
8
8
  import { getBlockType, store as blocksStore } from '@wordpress/blocks';
9
9
  import { store as preferencesStore } from '@wordpress/preferences';
10
10
 
@@ -24,7 +24,6 @@ function getBlockIconVariant( { select, clientIds } ) {
24
24
  getBlockName,
25
25
  getBlockAttributes,
26
26
  getBlockParentsByBlockName,
27
- isSectionBlock,
28
27
  canRemoveBlocks,
29
28
  getTemplateLock,
30
29
  getBlockEditingMode,
@@ -40,8 +39,8 @@ function getBlockIconVariant( { select, clientIds } ) {
40
39
  const blockName = isSingleBlock && getBlockName( clientIds[ 0 ] );
41
40
  const hasBlockStyles =
42
41
  isSingleBlock && !! getBlockStyles( blockName )?.length;
43
- const isSectionInSelection = clientIds.some( ( id ) =>
44
- isSectionBlock( id )
42
+ const hasPatternNameInSelection = clientIds.some(
43
+ ( id ) => !! getBlockAttributes( id )?.metadata?.patternName
45
44
  );
46
45
  const hasPatternOverrides = clientIds.every( ( clientId ) =>
47
46
  hasPatternOverridesDefaultBinding(
@@ -59,7 +58,7 @@ function getBlockIconVariant( { select, clientIds } ) {
59
58
  getBlockEditingMode( clientIds[ 0 ] ) === 'default';
60
59
  const _hideTransformsForSections =
61
60
  window?.__experimentalContentOnlyPatternInsertion &&
62
- isSectionInSelection;
61
+ hasPatternNameInSelection;
63
62
  const _showBlockSwitcher =
64
63
  ! _hideTransformsForSections &&
65
64
  isDefaultEditingMode &&
@@ -81,19 +80,24 @@ function getBlockIcon( { select, clientIds } ) {
81
80
  const { getBlockName, getBlockAttributes } = unlock(
82
81
  select( blockEditorStore )
83
82
  );
84
- const { getActiveBlockVariation } = select( blocksStore );
85
83
 
86
84
  const _isSingleBlock = clientIds.length === 1;
87
85
  const firstClientId = clientIds[ 0 ];
86
+ const blockAttributes = getBlockAttributes( firstClientId );
87
+ if (
88
+ _isSingleBlock &&
89
+ blockAttributes?.metadata?.patternName &&
90
+ window?.__experimentalContentOnlyPatternInsertion
91
+ ) {
92
+ return symbol;
93
+ }
88
94
 
89
95
  const blockName = getBlockName( firstClientId );
90
96
  const blockType = getBlockType( blockName );
91
97
 
92
98
  if ( _isSingleBlock ) {
93
- const match = getActiveBlockVariation(
94
- blockName,
95
- getBlockAttributes( firstClientId )
96
- );
99
+ const { getActiveBlockVariation } = select( blocksStore );
100
+ const match = getActiveBlockVariation( blockName, blockAttributes );
97
101
  return match?.icon || blockType?.icon;
98
102
  }
99
103
 
@@ -1,3 +1,8 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import clsx from 'clsx';
5
+
1
6
  /**
2
7
  * WordPress dependencies
3
8
  */
@@ -219,7 +224,7 @@ export default function BlockTools( {
219
224
  const canToggleBlockVisibility = blocks.every( ( block ) =>
220
225
  hasBlockSupport(
221
226
  getBlockName( block.clientId ),
222
- 'blockVisibility',
227
+ 'visibility',
223
228
  true
224
229
  )
225
230
  );
@@ -262,7 +267,15 @@ export default function BlockTools( {
262
267
 
263
268
  return (
264
269
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
265
- <div { ...props } onKeyDown={ onKeyDown }>
270
+ <div
271
+ { ...props }
272
+ onKeyDown={ onKeyDown }
273
+ // Popover slots cannot be unmounted during dragging because the
274
+ // will just be rendered in a fallback popover slot instead.
275
+ className={ clsx( props.className, {
276
+ 'block-editor-block-tools--is-dragging': isDragging,
277
+ } ) }
278
+ >
266
279
  <InsertionPointOpenRef.Provider value={ useRef( false ) }>
267
280
  { ! isTyping && ! isZoomOutMode && (
268
281
  <InsertionPoint
@@ -206,3 +206,7 @@
206
206
  top: 50%;
207
207
  left: 50%;
208
208
  }
209
+
210
+ .block-editor-block-tools--is-dragging > .popover-slot {
211
+ display: none;
212
+ }
@@ -147,41 +147,102 @@ function VariationsToggleGroupControl( {
147
147
 
148
148
  function __experimentalBlockVariationTransforms( { blockClientId } ) {
149
149
  const { updateBlockAttributes } = useDispatch( blockEditorStore );
150
- const { activeBlockVariation, variations, isContentOnly, isSection } =
151
- useSelect(
152
- ( select ) => {
153
- const { getActiveBlockVariation, getBlockVariations } =
154
- select( blocksStore );
155
-
156
- const {
157
- getBlockName,
158
- getBlockAttributes,
159
- getBlockEditingMode,
160
- isSectionBlock,
161
- } = unlock( select( blockEditorStore ) );
162
-
163
- const name = blockClientId && getBlockName( blockClientId );
164
-
165
- const { hasContentRoleAttribute } = unlock(
166
- select( blocksStore )
167
- );
168
- const isContentBlock = hasContentRoleAttribute( name );
169
-
170
- return {
171
- activeBlockVariation: getActiveBlockVariation(
172
- name,
173
- getBlockAttributes( blockClientId ),
174
- 'transform'
175
- ),
176
- variations: name && getBlockVariations( name, 'transform' ),
177
- isContentOnly:
178
- getBlockEditingMode( blockClientId ) ===
179
- 'contentOnly' && ! isContentBlock,
180
- isSection: isSectionBlock( blockClientId ),
181
- };
182
- },
183
- [ blockClientId ]
184
- );
150
+ const {
151
+ activeBlockVariation,
152
+ unfilteredVariations,
153
+ blockName,
154
+ isContentOnly,
155
+ isSection,
156
+ } = useSelect(
157
+ ( select ) => {
158
+ const { getActiveBlockVariation, getBlockVariations } =
159
+ select( blocksStore );
160
+
161
+ const {
162
+ getBlockName,
163
+ getBlockAttributes,
164
+ getBlockEditingMode,
165
+ isSectionBlock,
166
+ } = unlock( select( blockEditorStore ) );
167
+
168
+ const name = blockClientId && getBlockName( blockClientId );
169
+
170
+ const { hasContentRoleAttribute } = unlock( select( blocksStore ) );
171
+ const isContentBlock = hasContentRoleAttribute( name );
172
+
173
+ return {
174
+ activeBlockVariation: getActiveBlockVariation(
175
+ name,
176
+ getBlockAttributes( blockClientId ),
177
+ 'transform'
178
+ ),
179
+ unfilteredVariations:
180
+ name && getBlockVariations( name, 'transform' ),
181
+ blockName: name,
182
+ isContentOnly:
183
+ getBlockEditingMode( blockClientId ) === 'contentOnly' &&
184
+ ! isContentBlock,
185
+ isSection: isSectionBlock( blockClientId ),
186
+ };
187
+ },
188
+ [ blockClientId ]
189
+ );
190
+
191
+ /*
192
+ * Hack for WordPress 6.9
193
+ *
194
+ * The Stretchy blocks shipped in 6.9 were ultimately
195
+ * implemented as block variations of the base types Paragraph
196
+ * and Heading. See #73056 for discussion and trade-offs.
197
+ *
198
+ * The main drawback of this choice is that the Variations API
199
+ * doesn't offer enough control over how prominent and how tied
200
+ * to the base type a variation should be.
201
+ *
202
+ * In order to ship these new "blocks" with an acceptable UX,
203
+ * we need two hacks until the Variations API is improved:
204
+ *
205
+ * - Don't show the variations switcher in the block inspector
206
+ * for Paragraph, Heading, Stretchy Paragraph and Stretchy
207
+ * Heading (implemented below). Transformations are still
208
+ * available in the block switcher.
209
+ *
210
+ * - Move the stretchy variations to the end of the core blocks
211
+ * list in the block inserter (implemented in
212
+ * getInserterItems in #73056).
213
+ */
214
+ const variations = useMemo( () => {
215
+ if ( blockName === 'core/paragraph' ) {
216
+ // Always hide options when active variation is stretchy, but
217
+ // ensure that there are no third-party variations before doing the
218
+ // same elsewhere.
219
+ if (
220
+ activeBlockVariation?.name === 'stretchy-paragraph' ||
221
+ unfilteredVariations.every( ( v ) =>
222
+ [ 'paragraph', 'stretchy-paragraph' ].includes( v.name )
223
+ )
224
+ ) {
225
+ return [];
226
+ }
227
+ // If there are other variations, only hide the stretchy one.
228
+ return unfilteredVariations.filter(
229
+ ( v ) => v.name !== 'stretchy-paragraph'
230
+ );
231
+ } else if ( blockName === 'core/heading' ) {
232
+ if (
233
+ activeBlockVariation?.name === 'stretchy-heading' ||
234
+ unfilteredVariations.every( ( v ) =>
235
+ [ 'heading', 'stretchy-heading' ].includes( v.name )
236
+ )
237
+ ) {
238
+ return [];
239
+ }
240
+ return unfilteredVariations.filter(
241
+ ( v ) => v.name !== 'stretchy-heading'
242
+ );
243
+ }
244
+ return unfilteredVariations;
245
+ }, [ activeBlockVariation?.name, blockName, unfilteredVariations ] );
185
246
 
186
247
  const selectedValue = activeBlockVariation?.name;
187
248
 
@@ -25,7 +25,7 @@ export default function BlockVisibilityToolbar( { clientIds } ) {
25
25
  canToggleBlockVisibility: _blocks.every( ( { clientId } ) =>
26
26
  hasBlockSupport(
27
27
  getBlockName( clientId ),
28
- 'blockVisibility',
28
+ 'visibility',
29
29
  true
30
30
  )
31
31
  ),
@@ -74,6 +74,7 @@ export default function SingleInputControl( {
74
74
  const onChangeUnit = ( next ) => {
75
75
  const newUnits = { ...selectedUnits };
76
76
  if ( corner === 'all' ) {
77
+ newUnits.flat = next;
77
78
  newUnits.topLeft = next;
78
79
  newUnits.topRight = next;
79
80
  newUnits.bottomLeft = next;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
5
+ import { moreVertical, check } from '@wordpress/icons';
6
+ import { __ } from '@wordpress/i18n';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import { useInspectorPopoverPlacement } from './use-inspector-popover-placement';
12
+
13
+ export default function FieldsDropdownMenu( {
14
+ fields,
15
+ visibleFields,
16
+ onToggleField,
17
+ } ) {
18
+ const { popoverProps } = useInspectorPopoverPlacement();
19
+
20
+ if ( ! fields || fields.length === 0 ) {
21
+ return null;
22
+ }
23
+
24
+ return (
25
+ <DropdownMenu
26
+ icon={ moreVertical }
27
+ label={ __( 'Options' ) }
28
+ popoverProps={ popoverProps }
29
+ >
30
+ { ( { onClose } ) => (
31
+ <MenuGroup label={ __( 'Show / Hide' ) }>
32
+ { fields.map( ( field ) => {
33
+ const isVisible = visibleFields.includes( field.id );
34
+ return (
35
+ <MenuItem
36
+ key={ field.id }
37
+ isSelected={ isVisible }
38
+ onClick={ () => {
39
+ onToggleField( field.id );
40
+ onClose();
41
+ } }
42
+ role="menuitemcheckbox"
43
+ icon={ isVisible ? check : null }
44
+ >
45
+ { field.label }
46
+ </MenuItem>
47
+ );
48
+ } ) }
49
+ </MenuGroup>
50
+ ) }
51
+ </DropdownMenu>
52
+ );
53
+ }