@wordpress/block-editor 12.9.1-next.5a1d1283.0 → 12.10.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 (453) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +33 -3
  3. package/build/components/block-canvas/index.js +107 -0
  4. package/build/components/block-canvas/index.js.map +1 -0
  5. package/build/components/block-inspector/index.js +4 -1
  6. package/build/components/block-inspector/index.js.map +1 -1
  7. package/build/components/block-patterns-list/index.js +19 -4
  8. package/build/components/block-patterns-list/index.js.map +1 -1
  9. package/build/components/block-patterns-paging/index.js +66 -0
  10. package/build/components/block-patterns-paging/index.js.map +1 -0
  11. package/build/components/block-settings-menu/block-settings-dropdown.js +28 -0
  12. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  13. package/build/components/block-settings-menu-controls/index.js +4 -7
  14. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  15. package/build/components/block-styles/index.js +1 -0
  16. package/build/components/block-styles/index.js.map +1 -1
  17. package/build/components/block-toolbar/block-toolbar-menu.native.js +3 -7
  18. package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  19. package/build/components/block-tools/block-contextual-toolbar.js +18 -7
  20. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  21. package/build/components/block-tools/block-selection-button.js +5 -1
  22. package/build/components/block-tools/block-selection-button.js.map +1 -1
  23. package/build/components/border-radius-control/input-controls.js +1 -1
  24. package/build/components/border-radius-control/input-controls.js.map +1 -1
  25. package/build/components/border-radius-control/linked-button.js +2 -4
  26. package/build/components/border-radius-control/linked-button.js.map +1 -1
  27. package/build/components/colors/with-colors.js.map +1 -1
  28. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -21
  29. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  30. package/build/components/default-block-appender/index.native.js +20 -1
  31. package/build/components/default-block-appender/index.native.js.map +1 -1
  32. package/build/components/duotone/utils.js +68 -0
  33. package/build/components/duotone/utils.js.map +1 -1
  34. package/build/components/editor-styles/index.js +28 -9
  35. package/build/components/editor-styles/index.js.map +1 -1
  36. package/build/components/global-styles/hooks.js +2 -101
  37. package/build/components/global-styles/hooks.js.map +1 -1
  38. package/build/components/global-styles/image-settings-panel.js +61 -0
  39. package/build/components/global-styles/image-settings-panel.js.map +1 -0
  40. package/build/components/global-styles/index.js +11 -17
  41. package/build/components/global-styles/index.js.map +1 -1
  42. package/build/components/global-styles/use-global-styles-output.js +19 -15
  43. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  44. package/build/components/global-styles/utils.js +1 -1
  45. package/build/components/global-styles/utils.js.map +1 -1
  46. package/build/components/iframe/index.js +67 -33
  47. package/build/components/iframe/index.js.map +1 -1
  48. package/build/components/image-editor/use-save-image.js +2 -5
  49. package/build/components/image-editor/use-save-image.js.map +1 -1
  50. package/build/components/image-editor/use-transform-image.js +9 -9
  51. package/build/components/image-editor/use-transform-image.js.map +1 -1
  52. package/build/components/index.js +8 -12
  53. package/build/components/index.js.map +1 -1
  54. package/build/components/index.native.js +6 -5
  55. package/build/components/index.native.js.map +1 -1
  56. package/build/components/inner-blocks/use-nested-settings-update.js +13 -7
  57. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  58. package/build/components/inserter/block-patterns-explorer/explorer.js +12 -6
  59. package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
  60. package/build/components/inserter/block-patterns-explorer/patterns-list.js +57 -23
  61. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
  62. package/build/components/inserter/block-patterns-explorer/sidebar.js +24 -9
  63. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  64. package/build/components/inserter/block-patterns-source-filter.js +54 -0
  65. package/build/components/inserter/block-patterns-source-filter.js.map +1 -0
  66. package/build/components/inserter/block-patterns-sync-filter.js +46 -0
  67. package/build/components/inserter/block-patterns-sync-filter.js.map +1 -0
  68. package/build/components/inserter/block-patterns-tab.js +91 -45
  69. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  70. package/build/components/inserter/hooks/use-patterns-paging.js +57 -0
  71. package/build/components/inserter/hooks/use-patterns-paging.js.map +1 -0
  72. package/build/components/inserter/hooks/use-patterns-state.js +21 -10
  73. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  74. package/build/components/inserter/menu.js +13 -11
  75. package/build/components/inserter/menu.js.map +1 -1
  76. package/build/components/inserter/search-results.js +4 -3
  77. package/build/components/inserter/search-results.js.map +1 -1
  78. package/build/components/inserter/tabs.js +1 -12
  79. package/build/components/inserter/tabs.js.map +1 -1
  80. package/build/components/inspector-controls/block-support-slot-container.js +12 -1
  81. package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
  82. package/build/components/inspector-controls/fill.js +24 -13
  83. package/build/components/inspector-controls/fill.js.map +1 -1
  84. package/build/components/inspector-controls/groups.js +5 -3
  85. package/build/components/inspector-controls/groups.js.map +1 -1
  86. package/build/components/inspector-controls/slot.js +13 -0
  87. package/build/components/inspector-controls/slot.js.map +1 -1
  88. package/build/components/inspector-controls-tabs/styles-tab.js +3 -0
  89. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  90. package/build/components/link-control/index.js +12 -2
  91. package/build/components/link-control/index.js.map +1 -1
  92. package/build/components/list-view/block-select-button.js +1 -3
  93. package/build/components/list-view/block-select-button.js.map +1 -1
  94. package/build/components/list-view/block.js +13 -1
  95. package/build/components/list-view/block.js.map +1 -1
  96. package/build/components/list-view/use-block-selection.js +29 -24
  97. package/build/components/list-view/use-block-selection.js.map +1 -1
  98. package/build/components/media-placeholder/index.js +2 -2
  99. package/build/components/media-placeholder/index.js.map +1 -1
  100. package/build/components/media-placeholder/index.native.js +11 -11
  101. package/build/components/media-placeholder/index.native.js.map +1 -1
  102. package/build/components/media-replace-flow/index.js +2 -3
  103. package/build/components/media-replace-flow/index.js.map +1 -1
  104. package/build/components/media-upload/constants.js +30 -0
  105. package/build/components/media-upload/constants.js.map +1 -0
  106. package/build/components/media-upload/index.native.js +63 -53
  107. package/build/components/media-upload/index.native.js.map +1 -1
  108. package/build/components/preview-options/index.js +1 -1
  109. package/build/components/preview-options/index.js.map +1 -1
  110. package/build/components/rich-text/index.js +34 -35
  111. package/build/components/rich-text/index.js.map +1 -1
  112. package/build/components/rich-text/index.native.js +14 -32
  113. package/build/components/rich-text/index.native.js.map +1 -1
  114. package/build/components/rich-text/multiline.js +95 -0
  115. package/build/components/rich-text/multiline.js.map +1 -0
  116. package/build/components/rich-text/split-value.js +10 -16
  117. package/build/components/rich-text/split-value.js.map +1 -1
  118. package/build/components/rich-text/use-enter.js +31 -40
  119. package/build/components/rich-text/use-enter.js.map +1 -1
  120. package/build/components/rich-text/use-paste-handler.js +18 -33
  121. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  122. package/build/components/spacing-sizes-control/utils.js +1 -1
  123. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  124. package/build/components/use-block-commands/index.js +30 -18
  125. package/build/components/use-block-commands/index.js.map +1 -1
  126. package/build/components/use-block-display-information/index.js +5 -2
  127. package/build/components/use-block-display-information/index.js.map +1 -1
  128. package/build/hooks/background.js +258 -0
  129. package/build/hooks/background.js.map +1 -0
  130. package/build/hooks/block-hooks.js +188 -0
  131. package/build/hooks/block-hooks.js.map +1 -0
  132. package/build/hooks/block-rename-ui.js +160 -0
  133. package/build/hooks/block-rename-ui.js.map +1 -0
  134. package/build/hooks/duotone.js +29 -42
  135. package/build/hooks/duotone.js.map +1 -1
  136. package/build/hooks/index.js +2 -2
  137. package/build/hooks/index.js.map +1 -1
  138. package/build/hooks/layout.js +31 -14
  139. package/build/hooks/layout.js.map +1 -1
  140. package/build/hooks/position.js +4 -2
  141. package/build/hooks/position.js.map +1 -1
  142. package/build/hooks/style.js +10 -3
  143. package/build/hooks/style.js.map +1 -1
  144. package/build/private-apis.js +2 -0
  145. package/build/private-apis.js.map +1 -1
  146. package/build/store/actions.js +33 -10
  147. package/build/store/actions.js.map +1 -1
  148. package/build/store/private-actions.js +42 -8
  149. package/build/store/private-actions.js.map +1 -1
  150. package/build/store/private-selectors.js +23 -0
  151. package/build/store/private-selectors.js.map +1 -1
  152. package/build/store/reducer.js +43 -1
  153. package/build/store/reducer.js.map +1 -1
  154. package/build/store/selectors.js +84 -23
  155. package/build/store/selectors.js.map +1 -1
  156. package/build/store/utils.js +0 -4
  157. package/build/store/utils.js.map +1 -1
  158. package/build-module/components/block-canvas/index.js +97 -0
  159. package/build-module/components/block-canvas/index.js.map +1 -0
  160. package/build-module/components/block-inspector/index.js +4 -1
  161. package/build-module/components/block-inspector/index.js.map +1 -1
  162. package/build-module/components/block-patterns-list/index.js +20 -5
  163. package/build-module/components/block-patterns-list/index.js.map +1 -1
  164. package/build-module/components/block-patterns-paging/index.js +59 -0
  165. package/build-module/components/block-patterns-paging/index.js.map +1 -0
  166. package/build-module/components/block-settings-menu/block-settings-dropdown.js +28 -0
  167. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  168. package/build-module/components/block-settings-menu-controls/index.js +4 -7
  169. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  170. package/build-module/components/block-styles/index.js +1 -0
  171. package/build-module/components/block-styles/index.js.map +1 -1
  172. package/build-module/components/block-toolbar/block-toolbar-menu.native.js +3 -7
  173. package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  174. package/build-module/components/block-tools/block-contextual-toolbar.js +18 -7
  175. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  176. package/build-module/components/block-tools/block-selection-button.js +5 -1
  177. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  178. package/build-module/components/border-radius-control/input-controls.js +1 -1
  179. package/build-module/components/border-radius-control/input-controls.js.map +1 -1
  180. package/build-module/components/border-radius-control/linked-button.js +2 -4
  181. package/build-module/components/border-radius-control/linked-button.js.map +1 -1
  182. package/build-module/components/colors/with-colors.js.map +1 -1
  183. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -21
  184. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  185. package/build-module/components/default-block-appender/index.native.js +20 -1
  186. package/build-module/components/default-block-appender/index.native.js.map +1 -1
  187. package/build-module/components/duotone/utils.js +65 -0
  188. package/build-module/components/duotone/utils.js.map +1 -1
  189. package/build-module/components/editor-styles/index.js +28 -9
  190. package/build-module/components/editor-styles/index.js.map +1 -1
  191. package/build-module/components/global-styles/hooks.js +3 -100
  192. package/build-module/components/global-styles/hooks.js.map +1 -1
  193. package/build-module/components/global-styles/image-settings-panel.js +53 -0
  194. package/build-module/components/global-styles/image-settings-panel.js.map +1 -0
  195. package/build-module/components/global-styles/index.js +2 -2
  196. package/build-module/components/global-styles/index.js.map +1 -1
  197. package/build-module/components/global-styles/use-global-styles-output.js +18 -16
  198. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  199. package/build-module/components/global-styles/utils.js +1 -1
  200. package/build-module/components/global-styles/utils.js.map +1 -1
  201. package/build-module/components/iframe/index.js +66 -33
  202. package/build-module/components/iframe/index.js.map +1 -1
  203. package/build-module/components/image-editor/use-save-image.js +2 -5
  204. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  205. package/build-module/components/image-editor/use-transform-image.js +9 -9
  206. package/build-module/components/image-editor/use-transform-image.js.map +1 -1
  207. package/build-module/components/index.js +1 -1
  208. package/build-module/components/index.js.map +1 -1
  209. package/build-module/components/index.native.js +2 -1
  210. package/build-module/components/index.native.js.map +1 -1
  211. package/build-module/components/inner-blocks/use-nested-settings-update.js +14 -8
  212. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  213. package/build-module/components/inserter/block-patterns-explorer/explorer.js +12 -6
  214. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
  215. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +59 -25
  216. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
  217. package/build-module/components/inserter/block-patterns-explorer/sidebar.js +23 -9
  218. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  219. package/build-module/components/inserter/block-patterns-source-filter.js +44 -0
  220. package/build-module/components/inserter/block-patterns-source-filter.js.map +1 -0
  221. package/build-module/components/inserter/block-patterns-sync-filter.js +38 -0
  222. package/build-module/components/inserter/block-patterns-sync-filter.js.map +1 -0
  223. package/build-module/components/inserter/block-patterns-tab.js +87 -46
  224. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  225. package/build-module/components/inserter/hooks/use-patterns-paging.js +50 -0
  226. package/build-module/components/inserter/hooks/use-patterns-paging.js.map +1 -0
  227. package/build-module/components/inserter/hooks/use-patterns-state.js +22 -10
  228. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  229. package/build-module/components/inserter/menu.js +13 -11
  230. package/build-module/components/inserter/menu.js.map +1 -1
  231. package/build-module/components/inserter/search-results.js +4 -3
  232. package/build-module/components/inserter/search-results.js.map +1 -1
  233. package/build-module/components/inserter/tabs.js +1 -12
  234. package/build-module/components/inserter/tabs.js.map +1 -1
  235. package/build-module/components/inspector-controls/block-support-slot-container.js +13 -2
  236. package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
  237. package/build-module/components/inspector-controls/fill.js +25 -14
  238. package/build-module/components/inspector-controls/fill.js.map +1 -1
  239. package/build-module/components/inspector-controls/groups.js +5 -3
  240. package/build-module/components/inspector-controls/groups.js.map +1 -1
  241. package/build-module/components/inspector-controls/slot.js +15 -1
  242. package/build-module/components/inspector-controls/slot.js.map +1 -1
  243. package/build-module/components/inspector-controls-tabs/styles-tab.js +3 -0
  244. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  245. package/build-module/components/link-control/index.js +12 -2
  246. package/build-module/components/link-control/index.js.map +1 -1
  247. package/build-module/components/list-view/block-select-button.js +1 -3
  248. package/build-module/components/list-view/block-select-button.js.map +1 -1
  249. package/build-module/components/list-view/block.js +13 -1
  250. package/build-module/components/list-view/block.js.map +1 -1
  251. package/build-module/components/list-view/use-block-selection.js +30 -25
  252. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  253. package/build-module/components/media-placeholder/index.js +2 -2
  254. package/build-module/components/media-placeholder/index.js.map +1 -1
  255. package/build-module/components/media-placeholder/index.native.js +7 -7
  256. package/build-module/components/media-placeholder/index.native.js.map +1 -1
  257. package/build-module/components/media-replace-flow/index.js +2 -3
  258. package/build-module/components/media-replace-flow/index.js.map +1 -1
  259. package/build-module/components/media-upload/constants.js +14 -0
  260. package/build-module/components/media-upload/constants.js.map +1 -0
  261. package/build-module/components/media-upload/index.native.js +53 -34
  262. package/build-module/components/media-upload/index.native.js.map +1 -1
  263. package/build-module/components/preview-options/index.js +1 -1
  264. package/build-module/components/preview-options/index.js.map +1 -1
  265. package/build-module/components/rich-text/index.js +35 -37
  266. package/build-module/components/rich-text/index.js.map +1 -1
  267. package/build-module/components/rich-text/index.native.js +15 -33
  268. package/build-module/components/rich-text/index.native.js.map +1 -1
  269. package/build-module/components/rich-text/multiline.js +87 -0
  270. package/build-module/components/rich-text/multiline.js.map +1 -0
  271. package/build-module/components/rich-text/split-value.js +10 -16
  272. package/build-module/components/rich-text/split-value.js.map +1 -1
  273. package/build-module/components/rich-text/use-enter.js +33 -42
  274. package/build-module/components/rich-text/use-enter.js.map +1 -1
  275. package/build-module/components/rich-text/use-paste-handler.js +19 -34
  276. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  277. package/build-module/components/spacing-sizes-control/utils.js +2 -2
  278. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  279. package/build-module/components/use-block-commands/index.js +28 -16
  280. package/build-module/components/use-block-commands/index.js.map +1 -1
  281. package/build-module/components/use-block-display-information/index.js +5 -2
  282. package/build-module/components/use-block-display-information/index.js.map +1 -1
  283. package/build-module/hooks/background.js +244 -0
  284. package/build-module/hooks/background.js.map +1 -0
  285. package/build-module/hooks/block-hooks.js +181 -0
  286. package/build-module/hooks/block-hooks.js.map +1 -0
  287. package/build-module/hooks/block-rename-ui.js +153 -0
  288. package/build-module/hooks/block-rename-ui.js.map +1 -0
  289. package/build-module/hooks/duotone.js +26 -39
  290. package/build-module/hooks/duotone.js.map +1 -1
  291. package/build-module/hooks/index.js +2 -2
  292. package/build-module/hooks/index.js.map +1 -1
  293. package/build-module/hooks/layout.js +33 -16
  294. package/build-module/hooks/layout.js.map +1 -1
  295. package/build-module/hooks/position.js +4 -2
  296. package/build-module/hooks/position.js.map +1 -1
  297. package/build-module/hooks/style.js +10 -3
  298. package/build-module/hooks/style.js.map +1 -1
  299. package/build-module/private-apis.js +2 -0
  300. package/build-module/private-apis.js.map +1 -1
  301. package/build-module/store/actions.js +33 -10
  302. package/build-module/store/actions.js.map +1 -1
  303. package/build-module/store/private-actions.js +39 -8
  304. package/build-module/store/private-actions.js.map +1 -1
  305. package/build-module/store/private-selectors.js +21 -0
  306. package/build-module/store/private-selectors.js.map +1 -1
  307. package/build-module/store/reducer.js +41 -1
  308. package/build-module/store/reducer.js.map +1 -1
  309. package/build-module/store/selectors.js +78 -22
  310. package/build-module/store/selectors.js.map +1 -1
  311. package/build-module/store/utils.js +0 -4
  312. package/build-module/store/utils.js.map +1 -1
  313. package/build-style/content-rtl.css +0 -1
  314. package/build-style/content.css +0 -1
  315. package/build-style/style-rtl.css +170 -127
  316. package/build-style/style.css +170 -127
  317. package/package.json +32 -32
  318. package/src/components/block-canvas/index.js +108 -0
  319. package/src/components/block-inspector/index.js +5 -1
  320. package/src/components/block-list/content.scss +0 -1
  321. package/src/components/block-patterns-list/index.js +32 -7
  322. package/src/components/block-patterns-list/style.scss +26 -9
  323. package/src/components/block-patterns-paging/index.js +92 -0
  324. package/src/components/block-patterns-paging/style.scss +42 -0
  325. package/src/components/block-settings-menu/block-settings-dropdown.js +44 -0
  326. package/src/components/block-settings-menu-controls/index.js +4 -9
  327. package/src/components/block-styles/index.js +1 -0
  328. package/src/components/block-styles/style.scss +3 -3
  329. package/src/components/block-toolbar/block-toolbar-menu.native.js +1 -6
  330. package/src/components/block-tools/block-contextual-toolbar.js +16 -5
  331. package/src/components/block-tools/block-selection-button.js +9 -1
  332. package/src/components/block-tools/style.scss +0 -98
  333. package/src/components/border-radius-control/input-controls.js +1 -1
  334. package/src/components/border-radius-control/linked-button.js +8 -11
  335. package/src/components/color-palette/test/__snapshots__/control.js.snap +34 -21
  336. package/src/components/colors/with-colors.js +3 -2
  337. package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -35
  338. package/src/components/default-block-appender/index.native.js +26 -3
  339. package/src/components/duotone/utils.js +65 -0
  340. package/src/components/editor-styles/index.js +32 -23
  341. package/src/components/global-styles/hooks.js +4 -112
  342. package/src/components/global-styles/image-settings-panel.js +71 -0
  343. package/src/components/global-styles/index.js +4 -3
  344. package/src/components/global-styles/use-global-styles-output.js +25 -16
  345. package/src/components/global-styles/utils.js +1 -2
  346. package/src/components/iframe/index.js +72 -33
  347. package/src/components/image-editor/use-save-image.js +2 -9
  348. package/src/components/image-editor/use-transform-image.js +9 -9
  349. package/src/components/index.js +1 -1
  350. package/src/components/index.native.js +2 -2
  351. package/src/components/inner-blocks/use-nested-settings-update.js +15 -10
  352. package/src/components/inserter/block-patterns-explorer/explorer.js +17 -5
  353. package/src/components/inserter/block-patterns-explorer/patterns-list.js +109 -40
  354. package/src/components/inserter/block-patterns-explorer/sidebar.js +23 -8
  355. package/src/components/inserter/block-patterns-source-filter.js +40 -0
  356. package/src/components/inserter/block-patterns-sync-filter.js +35 -0
  357. package/src/components/inserter/block-patterns-tab.js +168 -57
  358. package/src/components/inserter/hooks/use-patterns-paging.js +65 -0
  359. package/src/components/inserter/hooks/use-patterns-state.js +27 -16
  360. package/src/components/inserter/menu.js +15 -17
  361. package/src/components/inserter/search-results.js +6 -4
  362. package/src/components/inserter/style.scss +23 -2
  363. package/src/components/inserter/tabs.js +2 -12
  364. package/src/components/inserter/test/index.native.js +8 -12
  365. package/src/components/inspector-controls/block-support-slot-container.js +19 -3
  366. package/src/components/inspector-controls/fill.js +28 -14
  367. package/src/components/inspector-controls/groups.js +6 -2
  368. package/src/components/inspector-controls/slot.js +28 -3
  369. package/src/components/inspector-controls-tabs/styles-tab.js +4 -0
  370. package/src/components/link-control/index.js +13 -0
  371. package/src/components/link-control/style.scss +23 -2
  372. package/src/components/link-control/test/index.js +88 -6
  373. package/src/components/list-view/block-select-button.js +1 -3
  374. package/src/components/list-view/block.js +19 -1
  375. package/src/components/list-view/style.scss +1 -2
  376. package/src/components/list-view/use-block-selection.js +38 -32
  377. package/src/components/media-placeholder/README.md +2 -2
  378. package/src/components/media-placeholder/index.js +2 -2
  379. package/src/components/media-placeholder/index.native.js +11 -12
  380. package/src/components/media-replace-flow/index.js +2 -2
  381. package/src/components/media-replace-flow/test/index.js +5 -23
  382. package/src/components/media-upload/README.md +3 -2
  383. package/src/components/media-upload/constants.js +15 -0
  384. package/src/components/media-upload/index.native.js +66 -40
  385. package/src/components/media-upload/style.native.scss +4 -0
  386. package/src/components/media-upload/test/index.native.js +2 -2
  387. package/src/components/preview-options/README.md +7 -0
  388. package/src/components/preview-options/index.js +1 -1
  389. package/src/components/rich-text/index.js +48 -44
  390. package/src/components/rich-text/index.native.js +14 -42
  391. package/src/components/rich-text/multiline.js +121 -0
  392. package/src/components/rich-text/split-value.js +10 -35
  393. package/src/components/rich-text/use-enter.js +32 -42
  394. package/src/components/rich-text/use-paste-handler.js +16 -40
  395. package/src/components/spacing-sizes-control/style.scss +5 -7
  396. package/src/components/spacing-sizes-control/utils.js +1 -2
  397. package/src/components/use-block-commands/index.js +28 -20
  398. package/src/components/use-block-display-information/index.js +3 -0
  399. package/src/hooks/background.js +288 -0
  400. package/src/hooks/background.scss +57 -0
  401. package/src/hooks/block-hooks.js +257 -0
  402. package/src/hooks/block-hooks.scss +16 -0
  403. package/src/hooks/block-rename-ui.js +230 -0
  404. package/src/hooks/block-rename-ui.scss +3 -0
  405. package/src/hooks/duotone.js +42 -43
  406. package/src/hooks/index.js +2 -2
  407. package/src/hooks/layout.js +31 -33
  408. package/src/hooks/position.js +4 -3
  409. package/src/hooks/style.js +11 -2
  410. package/src/hooks/test/align.native.js +4 -3
  411. package/src/private-apis.js +2 -0
  412. package/src/store/actions.js +52 -10
  413. package/src/store/private-actions.js +37 -6
  414. package/src/store/private-selectors.js +21 -0
  415. package/src/store/reducer.js +38 -0
  416. package/src/store/selectors.js +107 -26
  417. package/src/store/test/actions.js +19 -8
  418. package/src/store/test/private-actions.js +17 -0
  419. package/src/store/test/reducer.js +25 -0
  420. package/src/store/test/selectors.js +130 -123
  421. package/src/store/utils.js +3 -10
  422. package/src/style.scss +4 -0
  423. package/build/components/duotone/components.js +0 -135
  424. package/build/components/duotone/components.js.map +0 -1
  425. package/build/components/duotone/index.js +0 -38
  426. package/build/components/duotone/index.js.map +0 -1
  427. package/build/components/global-styles/behaviors-panel.js +0 -64
  428. package/build/components/global-styles/behaviors-panel.js.map +0 -1
  429. package/build/components/inserter/reusable-blocks-tab.js +0 -85
  430. package/build/components/inserter/reusable-blocks-tab.js.map +0 -1
  431. package/build/hooks/auto-inserting-blocks.js +0 -174
  432. package/build/hooks/auto-inserting-blocks.js.map +0 -1
  433. package/build/hooks/behaviors.js +0 -173
  434. package/build/hooks/behaviors.js.map +0 -1
  435. package/build-module/components/duotone/components.js +0 -126
  436. package/build-module/components/duotone/components.js.map +0 -1
  437. package/build-module/components/duotone/index.js +0 -3
  438. package/build-module/components/duotone/index.js.map +0 -1
  439. package/build-module/components/global-styles/behaviors-panel.js +0 -57
  440. package/build-module/components/global-styles/behaviors-panel.js.map +0 -1
  441. package/build-module/components/inserter/reusable-blocks-tab.js +0 -76
  442. package/build-module/components/inserter/reusable-blocks-tab.js.map +0 -1
  443. package/build-module/hooks/auto-inserting-blocks.js +0 -167
  444. package/build-module/hooks/auto-inserting-blocks.js.map +0 -1
  445. package/build-module/hooks/behaviors.js +0 -166
  446. package/build-module/hooks/behaviors.js.map +0 -1
  447. package/src/components/duotone/components.js +0 -133
  448. package/src/components/duotone/index.js +0 -7
  449. package/src/components/global-styles/behaviors-panel.js +0 -71
  450. package/src/components/inserter/reusable-blocks-tab.js +0 -84
  451. package/src/components/inserter/test/reusable-blocks-tab.js +0 -73
  452. package/src/hooks/auto-inserting-blocks.js +0 -232
  453. package/src/hooks/behaviors.js +0 -206
@@ -1,71 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { SelectControl } from '@wordpress/components';
5
- import { __ } from '@wordpress/i18n';
6
-
7
- export default function ( { onChange, value, behaviors } ) {
8
- const defaultBehaviors = {
9
- default: {
10
- value: 'default',
11
- label: __( 'Default' ),
12
- },
13
- noBehaviors: {
14
- value: '',
15
- label: __( 'No behaviors' ),
16
- },
17
- };
18
-
19
- const behaviorsOptions = Object.entries( behaviors ).map(
20
- ( [ behaviorName ] ) => ( {
21
- value: behaviorName,
22
- // Capitalize the first letter of the behavior name.
23
- label: `${ behaviorName.charAt( 0 ).toUpperCase() }${ behaviorName
24
- .slice( 1 )
25
- .toLowerCase() }`,
26
- } )
27
- );
28
-
29
- const options = [
30
- ...Object.values( defaultBehaviors ),
31
- ...behaviorsOptions,
32
- ];
33
-
34
- const animations = [
35
- {
36
- value: 'zoom',
37
- label: __( 'Zoom' ),
38
- },
39
- {
40
- value: 'fade',
41
- label: __( 'Fade' ),
42
- },
43
- ];
44
- return (
45
- <div style={ { marginTop: '2rem' } }>
46
- <SelectControl
47
- label={ __( 'Behaviors' ) }
48
- // At the moment we are only supporting one behavior (Lightbox)
49
- value={ value }
50
- options={ options }
51
- onChange={ onChange }
52
- hideCancelButton={ true }
53
- size="__unstable-large"
54
- />
55
- { value === 'lightbox' && (
56
- <SelectControl
57
- label={ __( 'Animation' ) }
58
- value={
59
- behaviors?.lightbox.animation
60
- ? behaviors?.lightbox.animation
61
- : ''
62
- }
63
- options={ animations }
64
- onChange={ onChange }
65
- hideCancelButton={ false }
66
- size="__unstable-large"
67
- />
68
- ) }
69
- </div>
70
- );
71
- }
@@ -1,84 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useMemo } from '@wordpress/element';
5
- import { __ } from '@wordpress/i18n';
6
- import { addQueryArgs } from '@wordpress/url';
7
- import { Button } from '@wordpress/components';
8
-
9
- /**
10
- * Internal dependencies
11
- */
12
- import BlockTypesList from '../block-types-list';
13
- import InserterPanel from './panel';
14
- import InserterNoResults from './no-results';
15
- import useBlockTypesState from './hooks/use-block-types-state';
16
- import ReusableBlocksRenameHint from './reusable-block-rename-hint';
17
-
18
- function ReusableBlocksList( { onHover, onInsert, rootClientId } ) {
19
- const [ items, , , onSelectItem ] = useBlockTypesState(
20
- rootClientId,
21
- onInsert
22
- );
23
-
24
- const filteredItems = useMemo( () => {
25
- return items.filter(
26
- ( { category, syncStatus } ) =>
27
- category === 'reusable' && syncStatus !== 'unsynced'
28
- );
29
- }, [ items ] );
30
-
31
- if ( filteredItems.length === 0 ) {
32
- return <InserterNoResults />;
33
- }
34
-
35
- return (
36
- <InserterPanel title={ __( 'Synced patterns' ) }>
37
- <BlockTypesList
38
- items={ filteredItems }
39
- onSelect={ onSelectItem }
40
- onHover={ onHover }
41
- label={ __( 'Synced patterns' ) }
42
- />
43
- </InserterPanel>
44
- );
45
- }
46
-
47
- // The unwrapped component is only exported for use by unit tests.
48
- /**
49
- * List of reusable blocks shown in the "Reusable" tab of the inserter.
50
- *
51
- * @param {Object} props Component props.
52
- * @param {?string} props.rootClientId Client id of block to insert into.
53
- * @param {Function} props.onInsert Callback to run when item is inserted.
54
- * @param {Function} props.onHover Callback to run when item is hovered.
55
- *
56
- * @return {WPComponent} The component.
57
- */
58
- export function ReusableBlocksTab( { rootClientId, onInsert, onHover } ) {
59
- return (
60
- <>
61
- <div className="block-editor-inserter__hint">
62
- <ReusableBlocksRenameHint />
63
- </div>
64
- <ReusableBlocksList
65
- onHover={ onHover }
66
- onInsert={ onInsert }
67
- rootClientId={ rootClientId }
68
- />
69
- <div className="block-editor-inserter__manage-reusable-blocks-container">
70
- <Button
71
- className="block-editor-inserter__manage-reusable-blocks"
72
- variant="secondary"
73
- href={ addQueryArgs( 'edit.php', {
74
- post_type: 'wp_block',
75
- } ) }
76
- >
77
- { __( 'Manage my patterns' ) }
78
- </Button>
79
- </div>
80
- </>
81
- );
82
- }
83
-
84
- export default ReusableBlocksTab;
@@ -1,73 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { render, screen } from '@testing-library/react';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { registerBlockType, unregisterBlockType } from '@wordpress/blocks';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import { ReusableBlocksTab } from '../reusable-blocks-tab';
15
- import items, { categories, collections } from './fixtures';
16
- import useBlockTypesState from '../hooks/use-block-types-state';
17
-
18
- jest.mock( '../hooks/use-block-types-state', () => {
19
- // This allows us to tweak the returned value on each test.
20
- const mock = jest.fn();
21
- return mock;
22
- } );
23
-
24
- describe( 'InserterMenu', () => {
25
- beforeAll( () => {
26
- registerBlockType( 'core/block', {
27
- save: () => {},
28
- title: 'reusable block',
29
- edit: () => {},
30
- } );
31
- } );
32
-
33
- afterAll( () => {
34
- unregisterBlockType( 'core/block' );
35
- } );
36
-
37
- beforeEach( () => {
38
- useBlockTypesState.mockImplementation( () => [
39
- items,
40
- categories,
41
- collections,
42
- ] );
43
- } );
44
-
45
- it( 'should show nothing if there are no items', () => {
46
- const noItems = [];
47
- useBlockTypesState.mockImplementation( () => [
48
- noItems,
49
- categories,
50
- collections,
51
- ] );
52
-
53
- render( <ReusableBlocksTab filterValue="random" /> );
54
-
55
- expect( screen.queryByRole( 'option' ) ).not.toBeInTheDocument();
56
- } );
57
-
58
- it( 'should list reusable blocks', () => {
59
- render( <ReusableBlocksTab /> );
60
-
61
- expect(
62
- screen.getByRole( 'option', { name: 'My reusable block' } )
63
- ).toBeVisible();
64
- } );
65
-
66
- it( 'should trim whitespace of search terms', () => {
67
- render( <ReusableBlocksTab filterValue=" my reusable" /> );
68
-
69
- expect(
70
- screen.getByRole( 'option', { name: 'My reusable block' } )
71
- ).toBeVisible();
72
- } );
73
- } );
@@ -1,232 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
- import { addFilter } from '@wordpress/hooks';
6
- import { Fragment } from '@wordpress/element';
7
- import { PanelBody, ToggleControl } from '@wordpress/components';
8
- import { createHigherOrderComponent } from '@wordpress/compose';
9
- import { createBlock, store as blocksStore } from '@wordpress/blocks';
10
- import { useDispatch, useSelect } from '@wordpress/data';
11
-
12
- /**
13
- * Internal dependencies
14
- */
15
- import { InspectorControls } from '../components';
16
- import { store as blockEditorStore } from '../store';
17
-
18
- function AutoInsertingBlocksControl( props ) {
19
- const { autoInsertedBlocksForCurrentBlock, groupedAutoInsertedBlocks } =
20
- useSelect(
21
- ( select ) => {
22
- const { getBlockTypes } = select( blocksStore );
23
- const _autoInsertedBlocksForCurrentBlock =
24
- getBlockTypes()?.filter(
25
- ( { autoInsert } ) =>
26
- autoInsert && props.blockName in autoInsert
27
- );
28
-
29
- // Group by block namespace (i.e. prefix before the slash).
30
- const _groupedAutoInsertedBlocks =
31
- _autoInsertedBlocksForCurrentBlock?.reduce(
32
- ( groups, block ) => {
33
- const [ namespace ] = block.name.split( '/' );
34
- if ( ! groups[ namespace ] ) {
35
- groups[ namespace ] = [];
36
- }
37
- groups[ namespace ].push( block );
38
- return groups;
39
- },
40
- {}
41
- );
42
-
43
- return {
44
- autoInsertedBlocksForCurrentBlock:
45
- _autoInsertedBlocksForCurrentBlock,
46
- groupedAutoInsertedBlocks: _groupedAutoInsertedBlocks,
47
- };
48
- },
49
- [ props.blockName ]
50
- );
51
-
52
- const {
53
- autoInsertedBlockClientIds,
54
- blockIndex,
55
- rootClientId,
56
- innerBlocksLength,
57
- } = useSelect(
58
- ( select ) => {
59
- const { getBlock, getBlockIndex, getBlockRootClientId } =
60
- select( blockEditorStore );
61
- const _rootClientId = getBlockRootClientId( props.clientId );
62
-
63
- const _autoInsertedBlockClientIds =
64
- autoInsertedBlocksForCurrentBlock.reduce(
65
- ( clientIds, block ) => {
66
- const relativePosition =
67
- block?.autoInsert?.[ props.blockName ];
68
- let candidates;
69
-
70
- switch ( relativePosition ) {
71
- case 'before':
72
- case 'after':
73
- // Any of the current block's siblings (with the right block type) qualifies
74
- // as an auto-inserted block (inserted `before` or `after` the current one),
75
- // as the block might've been auto-inserted and then moved around a bit by the user.
76
- candidates =
77
- getBlock( _rootClientId )?.innerBlocks;
78
- break;
79
-
80
- case 'first_child':
81
- case 'last_child':
82
- // Any of the current block's child blocks (with the right block type) qualifies
83
- // as an auto-inserted first or last child block, as the block might've been
84
- // auto-inserted and then moved around a bit by the user.
85
- candidates = getBlock(
86
- props.clientId
87
- ).innerBlocks;
88
- break;
89
- }
90
-
91
- const autoInsertedBlock = candidates?.find(
92
- ( { name } ) => name === block.name
93
- );
94
-
95
- if ( autoInsertedBlock ) {
96
- clientIds[ block.name ] =
97
- autoInsertedBlock.clientId;
98
- }
99
-
100
- // TOOD: If no auto-inserted block was found in any of its designated locations,
101
- // we want to check if it's present elsewhere in the block tree.
102
- // If it is, we'd consider it manually inserted and would want to remove the
103
- // corresponding toggle from the block inspector panel.
104
-
105
- return clientIds;
106
- },
107
- {}
108
- );
109
-
110
- return {
111
- blockIndex: getBlockIndex( props.clientId ),
112
- innerBlocksLength: getBlock( props.clientId )?.innerBlocks
113
- ?.length,
114
- rootClientId: _rootClientId,
115
- autoInsertedBlockClientIds: _autoInsertedBlockClientIds,
116
- };
117
- },
118
- [ autoInsertedBlocksForCurrentBlock, props.blockName, props.clientId ]
119
- );
120
-
121
- const { insertBlock, removeBlock } = useDispatch( blockEditorStore );
122
-
123
- if ( ! autoInsertedBlocksForCurrentBlock.length ) {
124
- return null;
125
- }
126
-
127
- const insertBlockIntoDesignatedLocation = ( block, relativePosition ) => {
128
- switch ( relativePosition ) {
129
- case 'before':
130
- case 'after':
131
- insertBlock(
132
- block,
133
- relativePosition === 'after' ? blockIndex + 1 : blockIndex,
134
- rootClientId, // Insert as a child of the current block's parent
135
- false
136
- );
137
- break;
138
-
139
- case 'first_child':
140
- case 'last_child':
141
- insertBlock(
142
- block,
143
- // TODO: It'd be great if insertBlock() would accept negative indices for insertion.
144
- relativePosition === 'first_child' ? 0 : innerBlocksLength,
145
- props.clientId, // Insert as a child of the current block.
146
- false
147
- );
148
- break;
149
- }
150
- };
151
-
152
- return (
153
- <InspectorControls>
154
- <PanelBody title={ __( 'Plugins' ) } initialOpen={ true }>
155
- { Object.keys( groupedAutoInsertedBlocks ).map( ( vendor ) => {
156
- return (
157
- <Fragment key={ vendor }>
158
- <h3>{ vendor }</h3>
159
- { groupedAutoInsertedBlocks[ vendor ].map(
160
- ( block ) => {
161
- // TODO: Display block icon.
162
- // <BlockIcon icon={ block.icon } />
163
-
164
- const checked =
165
- block.name in
166
- autoInsertedBlockClientIds;
167
-
168
- return (
169
- <ToggleControl
170
- checked={ checked }
171
- key={ block.title }
172
- label={ block.title }
173
- onChange={ () => {
174
- if ( ! checked ) {
175
- // Create and insert block.
176
- const relativePosition =
177
- block.autoInsert[
178
- props.blockName
179
- ];
180
- insertBlockIntoDesignatedLocation(
181
- createBlock(
182
- block.name
183
- ),
184
- relativePosition
185
- );
186
- return;
187
- }
188
-
189
- // Remove block.
190
- const clientId =
191
- autoInsertedBlockClientIds[
192
- block.name
193
- ];
194
- removeBlock( clientId, false );
195
- } }
196
- />
197
- );
198
- }
199
- ) }
200
- </Fragment>
201
- );
202
- } ) }
203
- </PanelBody>
204
- </InspectorControls>
205
- );
206
- }
207
-
208
- export const withAutoInsertingBlocks = createHigherOrderComponent(
209
- ( BlockEdit ) => {
210
- return ( props ) => {
211
- const blockEdit = <BlockEdit key="edit" { ...props } />;
212
- return (
213
- <>
214
- { blockEdit }
215
- <AutoInsertingBlocksControl
216
- blockName={ props.name }
217
- clientId={ props.clientId }
218
- />
219
- </>
220
- );
221
- };
222
- },
223
- 'withAutoInsertingBlocks'
224
- );
225
-
226
- if ( window?.__experimentalAutoInsertingBlocks ) {
227
- addFilter(
228
- 'editor.BlockEdit',
229
- 'core/auto-inserting-blocks/with-inspector-control',
230
- withAutoInsertingBlocks
231
- );
232
- }
@@ -1,206 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { addFilter } from '@wordpress/hooks';
5
- import { SelectControl } from '@wordpress/components';
6
- import { __ } from '@wordpress/i18n';
7
- import { hasBlockSupport } from '@wordpress/blocks';
8
- import { createHigherOrderComponent } from '@wordpress/compose';
9
- import { useSelect } from '@wordpress/data';
10
- import { useMemo } from '@wordpress/element';
11
-
12
- /**
13
- * Internal dependencies
14
- */
15
- import { store as blockEditorStore } from '../store';
16
- import { InspectorControls } from '../components';
17
-
18
- function BehaviorsControl( {
19
- blockName,
20
- blockBehaviors,
21
- onChangeBehavior,
22
- onChangeAnimation,
23
- disabled = false,
24
- } ) {
25
- const { settings } = useSelect(
26
- ( select ) => {
27
- const { getSettings } = select( blockEditorStore );
28
- return {
29
- settings:
30
- getSettings()?.__experimentalFeatures?.blocks?.[ blockName ]
31
- ?.behaviors || {},
32
- };
33
- },
34
- [ blockName ]
35
- );
36
-
37
- const defaultBehaviors = {
38
- default: {
39
- value: 'default',
40
- label: __( 'Default' ),
41
- },
42
- noBehaviors: {
43
- value: '',
44
- label: __( 'No behaviors' ),
45
- },
46
- };
47
- const behaviorsOptions = Object.entries( settings )
48
- .filter(
49
- ( [ behaviorName, behaviorValue ] ) =>
50
- hasBlockSupport( blockName, `behaviors.${ behaviorName }` ) &&
51
- behaviorValue
52
- ) // Filter out behaviors that are disabled.
53
- .map( ( [ behaviorName ] ) => ( {
54
- value: behaviorName,
55
- // Capitalize the first letter of the behavior name.
56
- label: `${ behaviorName.charAt( 0 ).toUpperCase() }${ behaviorName
57
- .slice( 1 )
58
- .toLowerCase() }`,
59
- } ) );
60
- const options = [
61
- ...Object.values( defaultBehaviors ),
62
- ...behaviorsOptions,
63
- ];
64
-
65
- const { behaviors, behaviorsValue } = useMemo( () => {
66
- const mergedBehaviors = {
67
- ...( blockBehaviors || {} ),
68
- };
69
-
70
- let value = '';
71
- if ( blockBehaviors === undefined ) {
72
- value = 'default';
73
- }
74
- if ( blockBehaviors?.lightbox.enabled ) {
75
- value = 'lightbox';
76
- }
77
- return {
78
- behaviors: mergedBehaviors,
79
- behaviorsValue: value,
80
- };
81
- }, [ blockBehaviors ] );
82
-
83
- // If every behavior is disabled, do not show the behaviors inspector control.
84
- if ( behaviorsOptions.length === 0 ) {
85
- return null;
86
- }
87
-
88
- const helpText = disabled
89
- ? __( 'The lightbox behavior is disabled for linked images.' )
90
- : '';
91
-
92
- return (
93
- <InspectorControls group="advanced">
94
- <div>
95
- <SelectControl
96
- label={ __( 'Behaviors' ) }
97
- // At the moment we are only supporting one behavior (Lightbox)
98
- value={ behaviorsValue }
99
- options={ options }
100
- onChange={ onChangeBehavior }
101
- hideCancelButton={ true }
102
- help={ helpText }
103
- size="__unstable-large"
104
- disabled={ disabled }
105
- />
106
- { behaviorsValue === 'lightbox' && (
107
- <SelectControl
108
- label={ __( 'Animation' ) }
109
- // At the moment we are only supporting one behavior (Lightbox)
110
- value={
111
- behaviors?.lightbox.animation
112
- ? behaviors?.lightbox.animation
113
- : ''
114
- }
115
- options={ [
116
- {
117
- value: 'zoom',
118
- label: __( 'Zoom' ),
119
- },
120
- {
121
- value: 'fade',
122
- label: __( 'Fade' ),
123
- },
124
- ] }
125
- onChange={ onChangeAnimation }
126
- hideCancelButton={ false }
127
- size="__unstable-large"
128
- disabled={ disabled }
129
- />
130
- ) }
131
- </div>
132
- </InspectorControls>
133
- );
134
- }
135
-
136
- /**
137
- * Override the default edit UI to include a new block inspector control for
138
- * assigning behaviors to blocks if behaviors are enabled in the theme.json.
139
- *
140
- * Currently, only the `core/image` block is supported.
141
- *
142
- * @param {WPComponent} BlockEdit Original component.
143
- *
144
- * @return {WPComponent} Wrapped component.
145
- */
146
- export const withBehaviors = createHigherOrderComponent( ( BlockEdit ) => {
147
- return ( props ) => {
148
- const blockEdit = <BlockEdit key="edit" { ...props } />;
149
- // Only add behaviors to blocks with support.
150
- if ( ! hasBlockSupport( props.name, 'behaviors' ) ) {
151
- return blockEdit;
152
- }
153
- const blockHasLink =
154
- typeof props.attributes?.linkDestination !== 'undefined' &&
155
- props.attributes?.linkDestination !== 'none';
156
- return (
157
- <>
158
- { blockEdit }
159
- <BehaviorsControl
160
- blockName={ props.name }
161
- blockBehaviors={ props.attributes.behaviors }
162
- onChangeBehavior={ ( nextValue ) => {
163
- if ( nextValue === 'default' ) {
164
- props.setAttributes( {
165
- behaviors: undefined,
166
- } );
167
- } else {
168
- // If the user selects something, it means that they want to
169
- // change the default value (true) so we save it in the attributes.
170
- props.setAttributes( {
171
- behaviors: {
172
- lightbox: {
173
- enabled: nextValue === 'lightbox',
174
- animation:
175
- nextValue === 'lightbox'
176
- ? 'zoom'
177
- : '',
178
- },
179
- },
180
- } );
181
- }
182
- } }
183
- onChangeAnimation={ ( nextValue ) => {
184
- props.setAttributes( {
185
- behaviors: {
186
- lightbox: {
187
- enabled:
188
- props.attributes.behaviors.lightbox
189
- .enabled,
190
- animation: nextValue,
191
- },
192
- },
193
- } );
194
- } }
195
- disabled={ blockHasLink }
196
- />
197
- </>
198
- );
199
- };
200
- }, 'withBehaviors' );
201
-
202
- addFilter(
203
- 'editor.BlockEdit',
204
- 'core/behaviors/with-inspector-control',
205
- withBehaviors
206
- );