@wordpress/block-editor 12.17.0 → 12.18.1

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 (421) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +32 -0
  3. package/build/components/block-draggable/index.js +11 -3
  4. package/build/components/block-draggable/index.js.map +1 -1
  5. package/build/components/block-edit/context.js +3 -1
  6. package/build/components/block-edit/context.js.map +1 -1
  7. package/build/components/block-edit/index.js +4 -2
  8. package/build/components/block-edit/index.js.map +1 -1
  9. package/build/components/block-editing-mode/index.js +6 -3
  10. package/build/components/block-editing-mode/index.js.map +1 -1
  11. package/build/components/block-inspector/index.js +5 -2
  12. package/build/components/block-inspector/index.js.map +1 -1
  13. package/build/components/block-list/block.js +4 -3
  14. package/build/components/block-list/block.js.map +1 -1
  15. package/build/components/block-list/block.native.js +9 -5
  16. package/build/components/block-list/block.native.js.map +1 -1
  17. package/build/components/block-list/index.js +30 -4
  18. package/build/components/block-list/index.js.map +1 -1
  19. package/build/components/block-list/private-block-context.js +1 -1
  20. package/build/components/block-list/private-block-context.js.map +1 -1
  21. package/build/components/block-list/use-in-between-inserter.js +1 -1
  22. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  23. package/build/components/block-lock/toolbar.js +8 -2
  24. package/build/components/block-lock/toolbar.js.map +1 -1
  25. package/build/components/block-popover/inbetween.js +15 -3
  26. package/build/components/block-popover/inbetween.js.map +1 -1
  27. package/build/components/block-preview/auto.js +1 -1
  28. package/build/components/block-preview/auto.js.map +1 -1
  29. package/build/components/block-removal-warning-modal/index.js +3 -2
  30. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  31. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -4
  32. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  33. package/build/components/block-switcher/block-transformations-menu.js +12 -1
  34. package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
  35. package/build/components/block-switcher/index.js +119 -90
  36. package/build/components/block-switcher/index.js.map +1 -1
  37. package/build/components/block-tools/insertion-point.js +10 -3
  38. package/build/components/block-tools/insertion-point.js.map +1 -1
  39. package/build/components/dimensions-tool/aspect-ratio-tool.js +2 -1
  40. package/build/components/dimensions-tool/aspect-ratio-tool.js.map +1 -1
  41. package/build/components/font-sizes/fluid-utils.js +7 -1
  42. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  43. package/build/components/global-styles/border-panel.js +5 -14
  44. package/build/components/global-styles/border-panel.js.map +1 -1
  45. package/build/components/global-styles/dimensions-panel.js +30 -5
  46. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  47. package/build/components/global-styles/effects-panel.js +7 -1
  48. package/build/components/global-styles/effects-panel.js.map +1 -1
  49. package/build/components/global-styles/hooks.js +11 -8
  50. package/build/components/global-styles/hooks.js.map +1 -1
  51. package/build/components/global-styles/typography-panel.js +31 -14
  52. package/build/components/global-styles/typography-panel.js.map +1 -1
  53. package/build/components/global-styles/use-global-styles-output.js +6 -0
  54. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  55. package/build/components/iframe/get-compatibility-styles.js +99 -0
  56. package/build/components/iframe/get-compatibility-styles.js.map +1 -0
  57. package/build/components/iframe/index.js +2 -3
  58. package/build/components/iframe/index.js.map +1 -1
  59. package/build/components/index.js +16 -2
  60. package/build/components/index.js.map +1 -1
  61. package/build/components/index.native.js +16 -2
  62. package/build/components/index.native.js.map +1 -1
  63. package/build/components/inspector-controls/groups.js +2 -0
  64. package/build/components/inspector-controls/groups.js.map +1 -1
  65. package/build/components/inspector-controls-tabs/styles-tab.js +3 -0
  66. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  67. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -2
  68. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  69. package/build/components/link-control/link-preview.js +30 -26
  70. package/build/components/link-control/link-preview.js.map +1 -1
  71. package/build/components/link-control/search-input.js +1 -9
  72. package/build/components/link-control/search-input.js.map +1 -1
  73. package/build/components/list-view/block-contents.js +3 -1
  74. package/build/components/list-view/block-contents.js.map +1 -1
  75. package/build/components/list-view/block.js +10 -1
  76. package/build/components/list-view/block.js.map +1 -1
  77. package/build/components/list-view/branch.js +29 -8
  78. package/build/components/list-view/branch.js.map +1 -1
  79. package/build/components/list-view/drop-indicator.js +100 -32
  80. package/build/components/list-view/drop-indicator.js.map +1 -1
  81. package/build/components/list-view/index.js +52 -4
  82. package/build/components/list-view/index.js.map +1 -1
  83. package/build/components/list-view/leaf.js +2 -2
  84. package/build/components/list-view/leaf.js.map +1 -1
  85. package/build/components/list-view/use-list-view-block-indexes.js +30 -0
  86. package/build/components/list-view/use-list-view-block-indexes.js.map +1 -0
  87. package/build/components/list-view/use-list-view-drop-zone.js +56 -5
  88. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  89. package/build/components/list-view/utils.js +92 -0
  90. package/build/components/list-view/utils.js.map +1 -1
  91. package/build/components/provider/index.js +1 -1
  92. package/build/components/provider/index.js.map +1 -1
  93. package/build/components/recursion-provider/index.js +21 -0
  94. package/build/components/recursion-provider/index.js.map +1 -1
  95. package/build/components/rich-text/index.js +30 -6
  96. package/build/components/rich-text/index.js.map +1 -1
  97. package/build/components/rich-text/native/index.native.js +9 -9
  98. package/build/components/rich-text/native/index.native.js.map +1 -1
  99. package/build/components/use-block-drop-zone/index.js +30 -7
  100. package/build/components/use-block-drop-zone/index.js.map +1 -1
  101. package/build/components/use-on-block-drop/index.js +50 -8
  102. package/build/components/use-on-block-drop/index.js.map +1 -1
  103. package/build/hooks/block-hooks.js +5 -14
  104. package/build/hooks/block-hooks.js.map +1 -1
  105. package/build/hooks/content-lock-ui.js +17 -42
  106. package/build/hooks/content-lock-ui.js.map +1 -1
  107. package/build/hooks/dimensions.js +71 -1
  108. package/build/hooks/dimensions.js.map +1 -1
  109. package/build/hooks/effects.js +66 -0
  110. package/build/hooks/effects.js.map +1 -0
  111. package/build/hooks/index.js +17 -4
  112. package/build/hooks/index.js.map +1 -1
  113. package/build/hooks/index.native.js +13 -0
  114. package/build/hooks/index.native.js.map +1 -1
  115. package/build/hooks/style.js +9 -2
  116. package/build/hooks/style.js.map +1 -1
  117. package/build/hooks/supports.js +2 -1
  118. package/build/hooks/supports.js.map +1 -1
  119. package/build/hooks/typography.native.js +2 -2
  120. package/build/hooks/typography.native.js.map +1 -1
  121. package/build/hooks/use-bindings-attributes.js +115 -0
  122. package/build/hooks/use-bindings-attributes.js.map +1 -0
  123. package/build/hooks/use-shadow-props.js +46 -0
  124. package/build/hooks/use-shadow-props.js.map +1 -0
  125. package/build/hooks/utils.js +12 -7
  126. package/build/hooks/utils.js.map +1 -1
  127. package/build/index.js +14 -0
  128. package/build/index.js.map +1 -1
  129. package/build/store/actions.js +10 -6
  130. package/build/store/actions.js.map +1 -1
  131. package/build/store/index.js +2 -0
  132. package/build/store/index.js.map +1 -1
  133. package/build/store/private-actions.js +37 -0
  134. package/build/store/private-actions.js.map +1 -1
  135. package/build/store/private-selectors.js +60 -9
  136. package/build/store/private-selectors.js.map +1 -1
  137. package/build/store/reducer.js +44 -3
  138. package/build/store/reducer.js.map +1 -1
  139. package/build/store/resolvers.js +27 -0
  140. package/build/store/resolvers.js.map +1 -0
  141. package/build/store/selectors.js +94 -56
  142. package/build/store/selectors.js.map +1 -1
  143. package/build/store/utils.js +5 -26
  144. package/build/store/utils.js.map +1 -1
  145. package/build/utils/index.js +0 -16
  146. package/build/utils/index.js.map +1 -1
  147. package/build/utils/math.js +13 -0
  148. package/build/utils/math.js.map +1 -1
  149. package/build/utils/object.js +17 -0
  150. package/build/utils/object.js.map +1 -1
  151. package/build/utils/transform-styles/index.js +37 -27
  152. package/build/utils/transform-styles/index.js.map +1 -1
  153. package/build-module/components/block-draggable/index.js +11 -3
  154. package/build-module/components/block-draggable/index.js.map +1 -1
  155. package/build-module/components/block-edit/context.js +1 -0
  156. package/build-module/components/block-edit/context.js.map +1 -1
  157. package/build-module/components/block-edit/index.js +5 -3
  158. package/build-module/components/block-edit/index.js.map +1 -1
  159. package/build-module/components/block-editing-mode/index.js +7 -4
  160. package/build-module/components/block-editing-mode/index.js.map +1 -1
  161. package/build-module/components/block-inspector/index.js +5 -2
  162. package/build-module/components/block-inspector/index.js.map +1 -1
  163. package/build-module/components/block-list/block.js +6 -5
  164. package/build-module/components/block-list/block.js.map +1 -1
  165. package/build-module/components/block-list/block.native.js +11 -7
  166. package/build-module/components/block-list/block.native.js.map +1 -1
  167. package/build-module/components/block-list/index.js +31 -5
  168. package/build-module/components/block-list/index.js.map +1 -1
  169. package/build-module/components/block-list/private-block-context.js +1 -1
  170. package/build-module/components/block-list/private-block-context.js.map +1 -1
  171. package/build-module/components/block-list/use-in-between-inserter.js +1 -1
  172. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  173. package/build-module/components/block-lock/toolbar.js +8 -2
  174. package/build-module/components/block-lock/toolbar.js.map +1 -1
  175. package/build-module/components/block-popover/inbetween.js +15 -3
  176. package/build-module/components/block-popover/inbetween.js.map +1 -1
  177. package/build-module/components/block-preview/auto.js +3 -3
  178. package/build-module/components/block-preview/auto.js.map +1 -1
  179. package/build-module/components/block-removal-warning-modal/index.js +3 -2
  180. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  181. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -4
  182. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  183. package/build-module/components/block-switcher/block-transformations-menu.js +12 -1
  184. package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
  185. package/build-module/components/block-switcher/index.js +116 -86
  186. package/build-module/components/block-switcher/index.js.map +1 -1
  187. package/build-module/components/block-tools/insertion-point.js +10 -3
  188. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  189. package/build-module/components/dimensions-tool/aspect-ratio-tool.js +2 -1
  190. package/build-module/components/dimensions-tool/aspect-ratio-tool.js.map +1 -1
  191. package/build-module/components/font-sizes/fluid-utils.js +7 -1
  192. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  193. package/build-module/components/global-styles/border-panel.js +5 -14
  194. package/build-module/components/global-styles/border-panel.js.map +1 -1
  195. package/build-module/components/global-styles/dimensions-panel.js +30 -5
  196. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  197. package/build-module/components/global-styles/effects-panel.js +7 -1
  198. package/build-module/components/global-styles/effects-panel.js.map +1 -1
  199. package/build-module/components/global-styles/hooks.js +11 -8
  200. package/build-module/components/global-styles/hooks.js.map +1 -1
  201. package/build-module/components/global-styles/typography-panel.js +32 -15
  202. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  203. package/build-module/components/global-styles/use-global-styles-output.js +6 -0
  204. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  205. package/build-module/components/iframe/get-compatibility-styles.js +93 -0
  206. package/build-module/components/iframe/get-compatibility-styles.js.map +1 -0
  207. package/build-module/components/iframe/index.js +2 -3
  208. package/build-module/components/iframe/index.js.map +1 -1
  209. package/build-module/components/index.js +1 -1
  210. package/build-module/components/index.js.map +1 -1
  211. package/build-module/components/index.native.js +1 -1
  212. package/build-module/components/index.native.js.map +1 -1
  213. package/build-module/components/inspector-controls/groups.js +2 -0
  214. package/build-module/components/inspector-controls/groups.js.map +1 -1
  215. package/build-module/components/inspector-controls-tabs/styles-tab.js +3 -0
  216. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  217. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -2
  218. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  219. package/build-module/components/link-control/link-preview.js +32 -28
  220. package/build-module/components/link-control/link-preview.js.map +1 -1
  221. package/build-module/components/link-control/search-input.js +1 -8
  222. package/build-module/components/link-control/search-input.js.map +1 -1
  223. package/build-module/components/list-view/block-contents.js +3 -1
  224. package/build-module/components/list-view/block-contents.js.map +1 -1
  225. package/build-module/components/list-view/block.js +10 -1
  226. package/build-module/components/list-view/block.js.map +1 -1
  227. package/build-module/components/list-view/branch.js +30 -9
  228. package/build-module/components/list-view/branch.js.map +1 -1
  229. package/build-module/components/list-view/drop-indicator.js +99 -32
  230. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  231. package/build-module/components/list-view/index.js +54 -6
  232. package/build-module/components/list-view/index.js.map +1 -1
  233. package/build-module/components/list-view/leaf.js +2 -2
  234. package/build-module/components/list-view/leaf.js.map +1 -1
  235. package/build-module/components/list-view/use-list-view-block-indexes.js +23 -0
  236. package/build-module/components/list-view/use-list-view-block-indexes.js.map +1 -0
  237. package/build-module/components/list-view/use-list-view-drop-zone.js +58 -7
  238. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  239. package/build-module/components/list-view/utils.js +91 -0
  240. package/build-module/components/list-view/utils.js.map +1 -1
  241. package/build-module/components/provider/index.js +1 -1
  242. package/build-module/components/provider/index.js.map +1 -1
  243. package/build-module/components/recursion-provider/index.js +17 -0
  244. package/build-module/components/recursion-provider/index.js.map +1 -1
  245. package/build-module/components/rich-text/index.js +30 -6
  246. package/build-module/components/rich-text/index.js.map +1 -1
  247. package/build-module/components/rich-text/native/index.native.js +9 -9
  248. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  249. package/build-module/components/use-block-drop-zone/index.js +31 -8
  250. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  251. package/build-module/components/use-on-block-drop/index.js +51 -9
  252. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  253. package/build-module/hooks/block-hooks.js +5 -14
  254. package/build-module/hooks/block-hooks.js.map +1 -1
  255. package/build-module/hooks/content-lock-ui.js +19 -43
  256. package/build-module/hooks/content-lock-ui.js.map +1 -1
  257. package/build-module/hooks/dimensions.js +70 -2
  258. package/build-module/hooks/dimensions.js.map +1 -1
  259. package/build-module/hooks/effects.js +51 -0
  260. package/build-module/hooks/effects.js.map +1 -0
  261. package/build-module/hooks/index.js +5 -3
  262. package/build-module/hooks/index.js.map +1 -1
  263. package/build-module/hooks/index.native.js +1 -0
  264. package/build-module/hooks/index.native.js.map +1 -1
  265. package/build-module/hooks/style.js +9 -2
  266. package/build-module/hooks/style.js.map +1 -1
  267. package/build-module/hooks/supports.js +2 -1
  268. package/build-module/hooks/supports.js.map +1 -1
  269. package/build-module/hooks/typography.native.js +2 -2
  270. package/build-module/hooks/typography.native.js.map +1 -1
  271. package/build-module/hooks/use-bindings-attributes.js +112 -0
  272. package/build-module/hooks/use-bindings-attributes.js.map +1 -0
  273. package/build-module/hooks/use-shadow-props.js +39 -0
  274. package/build-module/hooks/use-shadow-props.js.map +1 -0
  275. package/build-module/hooks/utils.js +14 -9
  276. package/build-module/hooks/utils.js.map +1 -1
  277. package/build-module/index.js +1 -1
  278. package/build-module/index.js.map +1 -1
  279. package/build-module/store/actions.js +10 -6
  280. package/build-module/store/actions.js.map +1 -1
  281. package/build-module/store/index.js +2 -0
  282. package/build-module/store/index.js.map +1 -1
  283. package/build-module/store/private-actions.js +35 -0
  284. package/build-module/store/private-actions.js.map +1 -1
  285. package/build-module/store/private-selectors.js +53 -8
  286. package/build-module/store/private-selectors.js.map +1 -1
  287. package/build-module/store/reducer.js +43 -3
  288. package/build-module/store/reducer.js.map +1 -1
  289. package/build-module/store/resolvers.js +20 -0
  290. package/build-module/store/resolvers.js.map +1 -0
  291. package/build-module/store/selectors.js +89 -52
  292. package/build-module/store/selectors.js.map +1 -1
  293. package/build-module/store/utils.js +3 -23
  294. package/build-module/store/utils.js.map +1 -1
  295. package/build-module/utils/index.js +0 -1
  296. package/build-module/utils/index.js.map +1 -1
  297. package/build-module/utils/math.js +12 -0
  298. package/build-module/utils/math.js.map +1 -1
  299. package/build-module/utils/object.js +16 -0
  300. package/build-module/utils/object.js.map +1 -1
  301. package/build-module/utils/transform-styles/index.js +36 -27
  302. package/build-module/utils/transform-styles/index.js.map +1 -1
  303. package/build-style/content-rtl.css +33 -16
  304. package/build-style/content.css +33 -16
  305. package/build-style/default-editor-styles-rtl.css +1 -1
  306. package/build-style/default-editor-styles.css +1 -1
  307. package/build-style/style-rtl.css +169 -114
  308. package/build-style/style.css +169 -114
  309. package/package.json +31 -31
  310. package/src/components/block-canvas/style.scss +8 -1
  311. package/src/components/block-draggable/index.js +16 -5
  312. package/src/components/block-edit/context.js +1 -0
  313. package/src/components/block-edit/index.js +4 -0
  314. package/src/components/block-editing-mode/index.js +12 -7
  315. package/src/components/block-inspector/index.js +5 -2
  316. package/src/components/block-list/block.js +5 -4
  317. package/src/components/block-list/block.native.js +13 -3
  318. package/src/components/block-list/content.scss +34 -5
  319. package/src/components/block-list/index.js +52 -16
  320. package/src/components/block-list/private-block-context.js +1 -1
  321. package/src/components/block-list/use-in-between-inserter.js +1 -2
  322. package/src/components/block-lock/toolbar.js +10 -2
  323. package/src/components/block-popover/inbetween.js +22 -2
  324. package/src/components/block-preview/auto.js +3 -3
  325. package/src/components/block-removal-warning-modal/index.js +3 -2
  326. package/src/components/block-settings-menu/block-settings-dropdown.js +2 -7
  327. package/src/components/block-switcher/block-transformations-menu.js +18 -1
  328. package/src/components/block-switcher/index.js +133 -111
  329. package/src/components/block-switcher/style.scss +6 -4
  330. package/src/components/block-switcher/test/index.js +113 -230
  331. package/src/components/block-toolbar/style.scss +22 -18
  332. package/src/components/block-tools/insertion-point.js +15 -2
  333. package/src/components/block-tools/style.scss +8 -7
  334. package/src/components/dimensions-tool/aspect-ratio-tool.js +4 -1
  335. package/src/components/font-sizes/fluid-utils.js +8 -2
  336. package/src/components/font-sizes/test/fluid-utils.js +9 -0
  337. package/src/components/global-styles/border-panel.js +7 -17
  338. package/src/components/global-styles/dimensions-panel.js +50 -1
  339. package/src/components/global-styles/effects-panel.js +16 -1
  340. package/src/components/global-styles/hooks.js +11 -6
  341. package/src/components/global-styles/typography-panel.js +45 -13
  342. package/src/components/global-styles/use-global-styles-output.js +6 -0
  343. package/src/components/iframe/get-compatibility-styles.js +120 -0
  344. package/src/components/iframe/index.js +2 -3
  345. package/src/components/index.js +4 -2
  346. package/src/components/index.native.js +4 -2
  347. package/src/components/inspector-controls/groups.js +2 -0
  348. package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
  349. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -0
  350. package/src/components/link-control/link-preview.js +31 -55
  351. package/src/components/link-control/search-input.js +1 -9
  352. package/src/components/link-control/style.scss +31 -85
  353. package/src/components/link-control/test/index.js +2 -1
  354. package/src/components/list-view/block-contents.js +5 -1
  355. package/src/components/list-view/block.js +9 -0
  356. package/src/components/list-view/branch.js +30 -10
  357. package/src/components/list-view/drop-indicator.js +139 -46
  358. package/src/components/list-view/index.js +74 -3
  359. package/src/components/list-view/leaf.js +2 -2
  360. package/src/components/list-view/style.scss +102 -13
  361. package/src/components/list-view/test/use-list-view-drop-zone.js +4 -0
  362. package/src/components/list-view/test/utils.js +218 -1
  363. package/src/components/list-view/use-list-view-block-indexes.js +29 -0
  364. package/src/components/list-view/use-list-view-drop-zone.js +78 -6
  365. package/src/components/list-view/utils.js +116 -0
  366. package/src/components/provider/index.js +3 -1
  367. package/src/components/recursion-provider/README.md +2 -2
  368. package/src/components/recursion-provider/index.js +17 -0
  369. package/src/components/rich-text/index.js +48 -10
  370. package/src/components/rich-text/native/index.native.js +10 -10
  371. package/src/components/use-block-drop-zone/index.js +60 -19
  372. package/src/components/use-block-drop-zone/test/index.js +32 -61
  373. package/src/components/use-on-block-drop/index.js +92 -11
  374. package/src/hooks/block-hooks.js +5 -17
  375. package/src/hooks/content-lock-ui.js +15 -55
  376. package/src/hooks/dimensions.js +74 -3
  377. package/src/hooks/effects.js +57 -0
  378. package/src/hooks/index.js +4 -2
  379. package/src/hooks/index.native.js +1 -0
  380. package/src/hooks/style.js +12 -0
  381. package/src/hooks/supports.js +2 -0
  382. package/src/hooks/test/effects.js +39 -0
  383. package/src/hooks/typography.native.js +2 -2
  384. package/src/hooks/use-bindings-attributes.js +148 -0
  385. package/src/hooks/use-shadow-props.js +37 -0
  386. package/src/hooks/utils.js +30 -10
  387. package/src/index.js +2 -0
  388. package/src/store/actions.js +9 -4
  389. package/src/store/index.js +2 -0
  390. package/src/store/private-actions.js +32 -0
  391. package/src/store/private-selectors.js +78 -21
  392. package/src/store/reducer.js +49 -2
  393. package/src/store/resolvers.js +17 -0
  394. package/src/store/selectors.js +169 -161
  395. package/src/store/test/registry-selectors.js +431 -0
  396. package/src/store/test/selectors.js +14 -400
  397. package/src/store/utils.js +10 -33
  398. package/src/style.scss +0 -1
  399. package/src/utils/index.js +0 -1
  400. package/src/utils/math.js +12 -0
  401. package/src/utils/object.js +16 -0
  402. package/src/utils/transform-styles/index.js +52 -37
  403. package/tsconfig.tsbuildinfo +1 -1
  404. package/build/components/iframe/use-compatibility-styles.js +0 -100
  405. package/build/components/iframe/use-compatibility-styles.js.map +0 -1
  406. package/build/hooks/custom-fields.js +0 -106
  407. package/build/hooks/custom-fields.js.map +0 -1
  408. package/build/utils/block-variation-transforms.js +0 -42
  409. package/build/utils/block-variation-transforms.js.map +0 -1
  410. package/build-module/components/iframe/use-compatibility-styles.js +0 -94
  411. package/build-module/components/iframe/use-compatibility-styles.js.map +0 -1
  412. package/build-module/hooks/custom-fields.js +0 -99
  413. package/build-module/hooks/custom-fields.js.map +0 -1
  414. package/build-module/utils/block-variation-transforms.js +0 -35
  415. package/build-module/utils/block-variation-transforms.js.map +0 -1
  416. package/src/components/block-switcher/test/__snapshots__/index.js.snap +0 -116
  417. package/src/components/contrast-checker/style.scss +0 -3
  418. package/src/components/iframe/use-compatibility-styles.js +0 -122
  419. package/src/hooks/custom-fields.js +0 -115
  420. package/src/utils/block-variation-transforms.js +0 -38
  421. package/src/utils/test/block-variation-transforms.js +0 -94
@@ -22,13 +22,6 @@ const elementData = [
22
22
  bottom: 900,
23
23
  right: 400,
24
24
  },
25
- // Fourth block wraps to the next row/column.
26
- {
27
- top: 0,
28
- left: 400,
29
- bottom: 300,
30
- right: 800,
31
- },
32
25
  ];
33
26
 
34
27
  const mapElements =
@@ -73,7 +66,7 @@ describe( 'getDropTargetPosition', () => {
73
66
  const orientation = 'vertical';
74
67
 
75
68
  it( 'returns `0` when the position is nearest to the start of the first block', () => {
76
- const position = { x: 0, y: 0 };
69
+ const position = { x: 32, y: 0 };
77
70
 
78
71
  const result = getDropTargetPosition(
79
72
  verticalBlocksData,
@@ -85,7 +78,7 @@ describe( 'getDropTargetPosition', () => {
85
78
  } );
86
79
 
87
80
  it( 'returns `1` when the position is nearest to the end of the first block', () => {
88
- const position = { x: 0, y: 190 };
81
+ const position = { x: 32, y: 190 };
89
82
 
90
83
  const result = getDropTargetPosition(
91
84
  verticalBlocksData,
@@ -97,7 +90,7 @@ describe( 'getDropTargetPosition', () => {
97
90
  } );
98
91
 
99
92
  it( 'returns `1` when the position is nearest to the start of the second block', () => {
100
- const position = { x: 0, y: 210 };
93
+ const position = { x: 32, y: 210 };
101
94
 
102
95
  const result = getDropTargetPosition(
103
96
  verticalBlocksData,
@@ -109,7 +102,7 @@ describe( 'getDropTargetPosition', () => {
109
102
  } );
110
103
 
111
104
  it( 'returns `2` when the position is nearest to the end of the second block', () => {
112
- const position = { x: 0, y: 450 };
105
+ const position = { x: 32, y: 450 };
113
106
 
114
107
  const result = getDropTargetPosition(
115
108
  verticalBlocksData,
@@ -121,7 +114,7 @@ describe( 'getDropTargetPosition', () => {
121
114
  } );
122
115
 
123
116
  it( 'returns `2` when the position is nearest to the start of the third block', () => {
124
- const position = { x: 0, y: 510 };
117
+ const position = { x: 32, y: 510 };
125
118
 
126
119
  const result = getDropTargetPosition(
127
120
  verticalBlocksData,
@@ -133,7 +126,7 @@ describe( 'getDropTargetPosition', () => {
133
126
  } );
134
127
 
135
128
  it( 'returns `3` when the position is nearest to the end of the third block', () => {
136
- const position = { x: 0, y: 880 };
129
+ const position = { x: 32, y: 880 };
137
130
 
138
131
  const result = getDropTargetPosition(
139
132
  verticalBlocksData,
@@ -145,7 +138,7 @@ describe( 'getDropTargetPosition', () => {
145
138
  } );
146
139
 
147
140
  it( 'returns `3` when the position is past the end of the third block', () => {
148
- const position = { x: 0, y: 920 };
141
+ const position = { x: 32, y: 920 };
149
142
 
150
143
  const result = getDropTargetPosition(
151
144
  verticalBlocksData,
@@ -155,9 +148,8 @@ describe( 'getDropTargetPosition', () => {
155
148
 
156
149
  expect( result ).toEqual( [ 3, 'insert' ] );
157
150
  } );
158
-
159
- it( 'returns `4` when the position is nearest to the start of the fourth block', () => {
160
- const position = { x: 401, y: 0 };
151
+ it( 'returns group with index 0 when position is close to the right of the first block', () => {
152
+ const position = { x: 372, y: 0 };
161
153
 
162
154
  const result = getDropTargetPosition(
163
155
  verticalBlocksData,
@@ -165,11 +157,10 @@ describe( 'getDropTargetPosition', () => {
165
157
  orientation
166
158
  );
167
159
 
168
- expect( result ).toEqual( [ 3, 'insert' ] );
160
+ expect( result ).toEqual( [ 0, 'group', 'right' ] );
169
161
  } );
170
-
171
- it( 'returns `5` when the position is nearest to the end of the fourth block', () => {
172
- const position = { x: 401, y: 300 };
162
+ it( 'returns group with index 1 when position is close to the left of the second block', () => {
163
+ const position = { x: 12, y: 212 };
173
164
 
174
165
  const result = getDropTargetPosition(
175
166
  verticalBlocksData,
@@ -177,7 +168,7 @@ describe( 'getDropTargetPosition', () => {
177
168
  orientation
178
169
  );
179
170
 
180
- expect( result ).toEqual( [ 4, 'insert' ] );
171
+ expect( result ).toEqual( [ 1, 'group', 'left' ] );
181
172
  } );
182
173
  } );
183
174
 
@@ -267,30 +258,6 @@ describe( 'getDropTargetPosition', () => {
267
258
 
268
259
  expect( result ).toEqual( [ 3, 'insert' ] );
269
260
  } );
270
-
271
- it( 'returns `3` when the position is nearest to the start of the last block', () => {
272
- const position = { x: 0, y: 401 };
273
-
274
- const result = getDropTargetPosition(
275
- horizontalBlocksData,
276
- position,
277
- orientation
278
- );
279
-
280
- expect( result ).toEqual( [ 3, 'insert' ] );
281
- } );
282
-
283
- it( 'returns `4` when the position is nearest to the end of the last block', () => {
284
- const position = { x: 300, y: 401 };
285
-
286
- const result = getDropTargetPosition(
287
- horizontalBlocksData,
288
- position,
289
- orientation
290
- );
291
-
292
- expect( result ).toEqual( [ 4, 'insert' ] );
293
- } );
294
261
  } );
295
262
 
296
263
  describe( 'Unmodified default blocks', () => {
@@ -316,14 +283,18 @@ describe( 'getDropTargetPosition', () => {
316
283
 
317
284
  // Dropping above the first block.
318
285
  expect(
319
- getDropTargetPosition( blocksData, { x: 0, y: 0 }, orientation )
286
+ getDropTargetPosition(
287
+ blocksData,
288
+ { x: 32, y: 0 },
289
+ orientation
290
+ )
320
291
  ).toEqual( [ 0, 'replace' ] );
321
292
 
322
293
  // Dropping on the top half of the first block.
323
294
  expect(
324
295
  getDropTargetPosition(
325
296
  blocksData,
326
- { x: 0, y: 20 },
297
+ { x: 32, y: 20 },
327
298
  orientation
328
299
  )
329
300
  ).toEqual( [ 0, 'replace' ] );
@@ -332,7 +303,7 @@ describe( 'getDropTargetPosition', () => {
332
303
  expect(
333
304
  getDropTargetPosition(
334
305
  blocksData,
335
- { x: 0, y: 200 },
306
+ { x: 32, y: 200 },
336
307
  orientation
337
308
  )
338
309
  ).toEqual( [ 0, 'replace' ] );
@@ -341,7 +312,7 @@ describe( 'getDropTargetPosition', () => {
341
312
  expect(
342
313
  getDropTargetPosition(
343
314
  blocksData,
344
- { x: 0, y: 211 },
315
+ { x: 32, y: 211 },
345
316
  orientation
346
317
  )
347
318
  ).toEqual( [ 0, 'replace' ] );
@@ -350,7 +321,7 @@ describe( 'getDropTargetPosition', () => {
350
321
  expect(
351
322
  getDropTargetPosition(
352
323
  blocksData,
353
- { x: 0, y: 219 },
324
+ { x: 32, y: 219 },
354
325
  orientation
355
326
  )
356
327
  ).toEqual( [ 0, 'replace' ] );
@@ -359,7 +330,7 @@ describe( 'getDropTargetPosition', () => {
359
330
  expect(
360
331
  getDropTargetPosition(
361
332
  blocksData,
362
- { x: 0, y: 230 },
333
+ { x: 32, y: 230 },
363
334
  orientation
364
335
  )
365
336
  ).toEqual( [ 0, 'replace' ] );
@@ -368,7 +339,7 @@ describe( 'getDropTargetPosition', () => {
368
339
  expect(
369
340
  getDropTargetPosition(
370
341
  blocksData,
371
- { x: 0, y: 410 },
342
+ { x: 32, y: 410 },
372
343
  orientation
373
344
  )
374
345
  ).toEqual( [ 2, 'insert' ] );
@@ -377,7 +348,7 @@ describe( 'getDropTargetPosition', () => {
377
348
  expect(
378
349
  getDropTargetPosition(
379
350
  blocksData,
380
- { x: 0, y: 421 },
351
+ { x: 32, y: 421 },
381
352
  orientation
382
353
  )
383
354
  ).toEqual( [ 2, 'insert' ] );
@@ -410,7 +381,7 @@ describe( 'getDropTargetPosition', () => {
410
381
  expect(
411
382
  getDropTargetPosition(
412
383
  blocksData,
413
- { x: 0, y: 20 },
384
+ { x: 32, y: 20 },
414
385
  orientation
415
386
  )
416
387
  ).toEqual( [ 0, 'insert' ] );
@@ -419,7 +390,7 @@ describe( 'getDropTargetPosition', () => {
419
390
  expect(
420
391
  getDropTargetPosition(
421
392
  blocksData,
422
- { x: 0, y: 200 },
393
+ { x: 32, y: 200 },
423
394
  orientation
424
395
  )
425
396
  ).toEqual( [ 1, 'replace' ] );
@@ -428,7 +399,7 @@ describe( 'getDropTargetPosition', () => {
428
399
  expect(
429
400
  getDropTargetPosition(
430
401
  blocksData,
431
- { x: 0, y: 211 },
402
+ { x: 32, y: 211 },
432
403
  orientation
433
404
  )
434
405
  ).toEqual( [ 1, 'replace' ] );
@@ -437,7 +408,7 @@ describe( 'getDropTargetPosition', () => {
437
408
  expect(
438
409
  getDropTargetPosition(
439
410
  blocksData,
440
- { x: 0, y: 219 },
411
+ { x: 32, y: 219 },
441
412
  orientation
442
413
  )
443
414
  ).toEqual( [ 1, 'replace' ] );
@@ -446,7 +417,7 @@ describe( 'getDropTargetPosition', () => {
446
417
  expect(
447
418
  getDropTargetPosition(
448
419
  blocksData,
449
- { x: 0, y: 230 },
420
+ { x: 32, y: 230 },
450
421
  orientation
451
422
  )
452
423
  ).toEqual( [ 1, 'replace' ] );
@@ -455,7 +426,7 @@ describe( 'getDropTargetPosition', () => {
455
426
  expect(
456
427
  getDropTargetPosition(
457
428
  blocksData,
458
- { x: 0, y: 410 },
429
+ { x: 32, y: 410 },
459
430
  orientation
460
431
  )
461
432
  ).toEqual( [ 1, 'replace' ] );
@@ -464,7 +435,7 @@ describe( 'getDropTargetPosition', () => {
464
435
  expect(
465
436
  getDropTargetPosition(
466
437
  blocksData,
467
- { x: 0, y: 421 },
438
+ { x: 32, y: 421 },
468
439
  orientation
469
440
  )
470
441
  ).toEqual( [ 1, 'replace' ] );
@@ -4,9 +4,11 @@
4
4
  import { useCallback } from '@wordpress/element';
5
5
  import {
6
6
  cloneBlock,
7
+ createBlock,
7
8
  findTransform,
8
9
  getBlockTransforms,
9
10
  pasteHandler,
11
+ store as blocksStore,
10
12
  } from '@wordpress/blocks';
11
13
  import { useDispatch, useSelect, useRegistry } from '@wordpress/data';
12
14
  import { getFilesFromDataTransfer } from '@wordpress/dom';
@@ -61,6 +63,8 @@ export function parseDropEvent( event ) {
61
63
  * @param {Function} moveBlocks A function that moves blocks.
62
64
  * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.
63
65
  * @param {Function} clearSelectedBlock A function that clears block selection.
66
+ * @param {string} operation The type of operation to perform on drop. Could be `insert` or `replace` or `group`.
67
+ * @param {Function} getBlock A function that returns a block given its client id.
64
68
  * @return {Function} The event handler for a block drop event.
65
69
  */
66
70
  export function onBlockDrop(
@@ -70,7 +74,9 @@ export function onBlockDrop(
70
74
  getClientIdsOfDescendants,
71
75
  moveBlocks,
72
76
  insertOrReplaceBlocks,
73
- clearSelectedBlock
77
+ clearSelectedBlock,
78
+ operation,
79
+ getBlock
74
80
  ) {
75
81
  return ( event ) => {
76
82
  const {
@@ -113,6 +119,21 @@ export function onBlockDrop(
113
119
  return;
114
120
  }
115
121
 
122
+ // If the user is dropping a block over another block, replace both blocks
123
+ // with a group block containing them
124
+ if ( operation === 'group' ) {
125
+ const blocksToInsert = sourceClientIds.map( ( clientId ) =>
126
+ getBlock( clientId )
127
+ );
128
+ insertOrReplaceBlocks(
129
+ blocksToInsert,
130
+ true,
131
+ null,
132
+ sourceClientIds
133
+ );
134
+ return;
135
+ }
136
+
116
137
  const isAtSameLevel = sourceRootClientId === targetRootClientId;
117
138
  const draggedBlockCount = sourceClientIds.length;
118
139
 
@@ -202,7 +223,7 @@ export default function useOnBlockDrop(
202
223
  targetBlockIndex,
203
224
  options = {}
204
225
  ) {
205
- const { operation = 'insert' } = options;
226
+ const { operation = 'insert', nearestSide = 'right' } = options;
206
227
  const {
207
228
  canInsertBlockType,
208
229
  getBlockIndex,
@@ -210,7 +231,10 @@ export default function useOnBlockDrop(
210
231
  getBlockOrder,
211
232
  getBlocksByClientId,
212
233
  getSettings,
234
+ getBlock,
235
+ isGroupable,
213
236
  } = useSelect( blockEditorStore );
237
+ const { getBlockType, getGroupingBlockName } = useSelect( blocksStore );
214
238
  const {
215
239
  insertBlocks,
216
240
  moveBlocksToPosition,
@@ -222,12 +246,63 @@ export default function useOnBlockDrop(
222
246
  const registry = useRegistry();
223
247
 
224
248
  const insertOrReplaceBlocks = useCallback(
225
- ( blocks, updateSelection = true, initialPosition = 0 ) => {
249
+ (
250
+ blocks,
251
+ updateSelection = true,
252
+ initialPosition = 0,
253
+ clientIdsToReplace = []
254
+ ) => {
255
+ const clientIds = getBlockOrder( targetRootClientId );
256
+ const clientId = clientIds[ targetBlockIndex ];
257
+ const blocksClientIds = blocks.map( ( block ) => block.clientId );
258
+ const areGroupableBlocks = isGroupable( [
259
+ ...blocksClientIds,
260
+ clientId,
261
+ ] );
226
262
  if ( operation === 'replace' ) {
227
- const clientIds = getBlockOrder( targetRootClientId );
228
- const clientId = clientIds[ targetBlockIndex ];
229
-
230
263
  replaceBlocks( clientId, blocks, undefined, initialPosition );
264
+ } else if ( operation === 'group' && areGroupableBlocks ) {
265
+ const targetBlock = getBlock( clientId );
266
+ if ( nearestSide === 'left' ) {
267
+ blocks.push( targetBlock );
268
+ } else {
269
+ blocks.unshift( targetBlock );
270
+ }
271
+
272
+ const groupInnerBlocks = blocks.map( ( block ) => {
273
+ return createBlock(
274
+ block.name,
275
+ block.attributes,
276
+ block.innerBlocks
277
+ );
278
+ } );
279
+
280
+ const areAllImages = blocks.every( ( block ) => {
281
+ return block.name === 'core/image';
282
+ } );
283
+
284
+ const galleryBlock = !! getBlockType( 'core/gallery' );
285
+
286
+ const wrappedBlocks = createBlock(
287
+ areAllImages && galleryBlock
288
+ ? 'core/gallery'
289
+ : getGroupingBlockName(),
290
+ {
291
+ layout: {
292
+ type: 'flex',
293
+ flexWrap: areAllImages ? null : 'nowrap',
294
+ },
295
+ },
296
+ groupInnerBlocks
297
+ );
298
+ // Need to make sure both the target block and the block being dragged are replaced
299
+ // otherwise the dragged block will be duplicated.
300
+ replaceBlocks(
301
+ [ clientId, ...clientIdsToReplace ],
302
+ wrappedBlocks,
303
+ undefined,
304
+ initialPosition
305
+ );
231
306
  } else {
232
307
  insertBlocks(
233
308
  blocks,
@@ -239,12 +314,16 @@ export default function useOnBlockDrop(
239
314
  }
240
315
  },
241
316
  [
242
- operation,
243
317
  getBlockOrder,
244
- insertBlocks,
245
- replaceBlocks,
246
- targetBlockIndex,
247
318
  targetRootClientId,
319
+ targetBlockIndex,
320
+ operation,
321
+ replaceBlocks,
322
+ getBlock,
323
+ nearestSide,
324
+ getBlockType,
325
+ getGroupingBlockName,
326
+ insertBlocks,
248
327
  ]
249
328
  );
250
329
 
@@ -297,7 +376,9 @@ export default function useOnBlockDrop(
297
376
  getClientIdsOfDescendants,
298
377
  moveBlocks,
299
378
  insertOrReplaceBlocks,
300
- clearSelectedBlock
379
+ clearSelectedBlock,
380
+ operation,
381
+ getBlock
301
382
  );
302
383
  const _onFilesDrop = onFilesDrop(
303
384
  targetRootClientId,
@@ -55,8 +55,7 @@ function BlockHooksControlPure( { name, clientId } ) {
55
55
  const _hookedBlockClientIds = hookedBlocksForCurrentBlock.reduce(
56
56
  ( clientIds, block ) => {
57
57
  // If the block doesn't exist anywhere in the block tree,
58
- // we know that we have to display the toggle for it, and set
59
- // it to disabled.
58
+ // we know that we have to set the toggle to disabled.
60
59
  if ( getGlobalBlockCount( block.name ) === 0 ) {
61
60
  return clientIds;
62
61
  }
@@ -83,7 +82,7 @@ function BlockHooksControlPure( { name, clientId } ) {
83
82
  }
84
83
 
85
84
  const hookedBlock = candidates?.find(
86
- ( candidate ) => name === candidate.name
85
+ ( candidate ) => candidate.name === block.name
87
86
  );
88
87
 
89
88
  // If the block exists in the designated location, we consider it hooked
@@ -96,13 +95,8 @@ function BlockHooksControlPure( { name, clientId } ) {
96
95
  }
97
96
 
98
97
  // If no hooked block was found in any of its designated locations,
99
- // but it exists elsewhere in the block tree, we consider it manually inserted.
100
- // In this case, we take note and will remove the corresponding toggle from the
101
- // block inspector panel.
102
- return {
103
- ...clientIds,
104
- [ block.name ]: false,
105
- };
98
+ // we set the toggle to disabled.
99
+ return clientIds;
106
100
  },
107
101
  {}
108
102
  );
@@ -118,13 +112,7 @@ function BlockHooksControlPure( { name, clientId } ) {
118
112
 
119
113
  const { insertBlock, removeBlock } = useDispatch( blockEditorStore );
120
114
 
121
- // Remove toggle if block isn't present in the designated location but elsewhere in the block tree.
122
- const hookedBlocksForCurrentBlockIfNotPresentElsewhere =
123
- hookedBlocksForCurrentBlock?.filter(
124
- ( block ) => hookedBlockClientIds?.[ block.name ] !== false
125
- );
126
-
127
- if ( ! hookedBlocksForCurrentBlockIfNotPresentElsewhere.length ) {
115
+ if ( ! hookedBlocksForCurrentBlock.length ) {
128
116
  return null;
129
117
  }
130
118
 
@@ -4,40 +4,23 @@
4
4
  import { ToolbarButton, MenuItem } from '@wordpress/components';
5
5
  import { useDispatch, useSelect } from '@wordpress/data';
6
6
  import { __ } from '@wordpress/i18n';
7
- import { useEffect, useRef, useCallback } from '@wordpress/element';
7
+ import { useCallback } from '@wordpress/element';
8
8
 
9
9
  /**
10
10
  * Internal dependencies
11
11
  */
12
12
  import { store as blockEditorStore } from '../store';
13
13
  import { BlockControls, BlockSettingsMenuControls } from '../components';
14
+ import { unlock } from '../lock-unlock';
14
15
 
15
- function StopEditingAsBlocksOnOutsideSelect( {
16
- clientId,
17
- stopEditingAsBlock,
18
- } ) {
19
- const isBlockOrDescendantSelected = useSelect(
20
- ( select ) => {
21
- const { isBlockSelected, hasSelectedInnerBlock } =
22
- select( blockEditorStore );
23
- return (
24
- isBlockSelected( clientId ) ||
25
- hasSelectedInnerBlock( clientId, true )
26
- );
27
- },
28
- [ clientId ]
29
- );
30
- useEffect( () => {
31
- if ( ! isBlockOrDescendantSelected ) {
32
- stopEditingAsBlock();
33
- }
34
- }, [ isBlockOrDescendantSelected, stopEditingAsBlock ] );
35
- return null;
36
- }
16
+ // The implementation of content locking is mainly in this file, although the mechanism
17
+ // to stop temporarily editing as blocks when an outside block is selected is on component StopEditingAsBlocksOnOutsideSelect
18
+ // at block-editor/src/components/block-list/index.js.
19
+ // Besides the components on this file and the file referenced above the implementation
20
+ // also includes artifacts on the store (actions, reducers, and selector).
37
21
 
38
22
  function ContentLockControlsPure( { clientId, isSelected } ) {
39
23
  const { getBlockListSettings, getSettings } = useSelect( blockEditorStore );
40
- const focusModeToRevert = useRef();
41
24
  const { templateLock, isLockedByParent, isEditingAsBlocks } = useSelect(
42
25
  ( select ) => {
43
26
  const {
@@ -61,31 +44,15 @@ function ContentLockControlsPure( { clientId, isSelected } ) {
61
44
  updateBlockListSettings,
62
45
  __unstableSetTemporarilyEditingAsBlocks,
63
46
  } = useDispatch( blockEditorStore );
47
+ const { stopEditingAsBlocks } = unlock( useDispatch( blockEditorStore ) );
64
48
  const isContentLocked =
65
49
  ! isLockedByParent && templateLock === 'contentOnly';
66
50
  const { __unstableMarkNextChangeAsNotPersistent, updateBlockAttributes } =
67
51
  useDispatch( blockEditorStore );
68
52
 
69
- const stopEditingAsBlock = useCallback( () => {
70
- __unstableMarkNextChangeAsNotPersistent();
71
- updateBlockAttributes( clientId, {
72
- templateLock: 'contentOnly',
73
- } );
74
- updateBlockListSettings( clientId, {
75
- ...getBlockListSettings( clientId ),
76
- templateLock: 'contentOnly',
77
- } );
78
- updateSettings( { focusMode: focusModeToRevert.current } );
79
- __unstableSetTemporarilyEditingAsBlocks();
80
- }, [
81
- clientId,
82
- updateSettings,
83
- updateBlockListSettings,
84
- getBlockListSettings,
85
- __unstableMarkNextChangeAsNotPersistent,
86
- updateBlockAttributes,
87
- __unstableSetTemporarilyEditingAsBlocks,
88
- ] );
53
+ const stopEditingAsBlockCallback = useCallback( () => {
54
+ stopEditingAsBlocks( clientId );
55
+ }, [ clientId, stopEditingAsBlocks ] );
89
56
 
90
57
  if ( ! isContentLocked && ! isEditingAsBlocks ) {
91
58
  return null;
@@ -99,16 +66,8 @@ function ContentLockControlsPure( { clientId, isSelected } ) {
99
66
  <>
100
67
  { showStopEditingAsBlocks && (
101
68
  <>
102
- <StopEditingAsBlocksOnOutsideSelect
103
- clientId={ clientId }
104
- stopEditingAsBlock={ stopEditingAsBlock }
105
- />
106
69
  <BlockControls group="other">
107
- <ToolbarButton
108
- onClick={ () => {
109
- stopEditingAsBlock();
110
- } }
111
- >
70
+ <ToolbarButton onClick={ stopEditingAsBlockCallback }>
112
71
  { __( 'Done' ) }
113
72
  </ToolbarButton>
114
73
  </BlockControls>
@@ -127,11 +86,12 @@ function ContentLockControlsPure( { clientId, isSelected } ) {
127
86
  ...getBlockListSettings( clientId ),
128
87
  templateLock: false,
129
88
  } );
130
- focusModeToRevert.current =
89
+ const focusModeToRevert =
131
90
  getSettings().focusMode;
132
91
  updateSettings( { focusMode: true } );
133
92
  __unstableSetTemporarilyEditingAsBlocks(
134
- clientId
93
+ clientId,
94
+ focusModeToRevert
135
95
  );
136
96
  onClose();
137
97
  } }