@wordpress/block-editor 12.14.0 → 12.16.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 (664) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +10 -5
  3. package/build/components/block-canvas/index.js +22 -6
  4. package/build/components/block-canvas/index.js.map +1 -1
  5. package/build/components/block-card/index.js +1 -1
  6. package/build/components/block-card/index.js.map +1 -1
  7. package/build/components/block-controls/hook.js +3 -23
  8. package/build/components/block-controls/hook.js.map +1 -1
  9. package/build/components/block-edit/context.js +5 -1
  10. package/build/components/block-edit/context.js.map +1 -1
  11. package/build/components/block-edit/index.js +18 -9
  12. package/build/components/block-edit/index.js.map +1 -1
  13. package/build/components/block-info-slot-fill/index.js +3 -4
  14. package/build/components/block-info-slot-fill/index.js.map +1 -1
  15. package/build/components/block-list/block.js +28 -9
  16. package/build/components/block-list/block.js.map +1 -1
  17. package/build/components/block-list/block.native.js +16 -5
  18. package/build/components/block-list/block.native.js.map +1 -1
  19. package/build/components/block-list/use-block-props/index.js +61 -18
  20. package/build/components/block-list/use-block-props/index.js.map +1 -1
  21. package/build/components/block-list/use-block-props/use-focus-first-element.js +4 -29
  22. package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  23. package/build/components/block-list/use-block-props/use-is-hovered.js +4 -14
  24. package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
  25. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
  26. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  27. package/build/components/block-parent-selector/index.js +1 -1
  28. package/build/components/block-parent-selector/index.js.map +1 -1
  29. package/build/components/block-pattern-setup/index.js +25 -16
  30. package/build/components/block-pattern-setup/index.js.map +1 -1
  31. package/build/components/block-pattern-setup/setup-toolbar.js +4 -2
  32. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  33. package/build/components/block-patterns-list/index.js +37 -20
  34. package/build/components/block-patterns-list/index.js.map +1 -1
  35. package/build/components/block-removal-warning-modal/index.js +2 -9
  36. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  37. package/build/components/block-rename/index.js +28 -0
  38. package/build/components/block-rename/index.js.map +1 -0
  39. package/build/components/block-rename/is-empty-string.js +10 -0
  40. package/build/components/block-rename/is-empty-string.js.map +1 -0
  41. package/build/components/block-rename/modal.js +90 -0
  42. package/build/components/block-rename/modal.js.map +1 -0
  43. package/build/components/block-rename/rename-control.js +74 -0
  44. package/build/components/block-rename/rename-control.js.map +1 -0
  45. package/build/components/block-rename/use-block-rename.js +17 -0
  46. package/build/components/block-rename/use-block-rename.js.map +1 -0
  47. package/build/components/block-settings/container.native.js +6 -4
  48. package/build/components/block-settings/container.native.js.map +1 -1
  49. package/build/components/block-settings-menu/block-settings-dropdown.js +33 -20
  50. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  51. package/build/components/block-settings-menu-controls/index.js +7 -0
  52. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  53. package/build/components/block-styles/index.js +1 -1
  54. package/build/components/block-styles/index.js.map +1 -1
  55. package/build/components/block-styles/index.native.js +3 -2
  56. package/build/components/block-styles/index.native.js.map +1 -1
  57. package/build/components/block-toolbar/block-toolbar-menu.native.js +1 -1
  58. package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  59. package/build/components/block-toolbar/index.js +89 -27
  60. package/build/components/block-toolbar/index.js.map +1 -1
  61. package/build/components/block-tools/block-toolbar-breadcrumb.js +49 -0
  62. package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
  63. package/build/components/block-tools/block-toolbar-popover.js +86 -0
  64. package/build/components/block-tools/block-toolbar-popover.js.map +1 -0
  65. package/build/components/block-tools/index.js +27 -24
  66. package/build/components/block-tools/index.js.map +1 -1
  67. package/build/components/block-types-list/index.js +6 -2
  68. package/build/components/block-types-list/index.js.map +1 -1
  69. package/build/components/block-types-list/index.native.js +4 -3
  70. package/build/components/block-types-list/index.native.js.map +1 -1
  71. package/build/components/block-variation-picker/index.native.js +2 -1
  72. package/build/components/block-variation-picker/index.native.js.map +1 -1
  73. package/build/components/colors-gradients/control.js +28 -17
  74. package/build/components/colors-gradients/control.js.map +1 -1
  75. package/build/components/date-format-picker/index.js +8 -1
  76. package/build/components/date-format-picker/index.js.map +1 -1
  77. package/build/components/duotone-control/index.js +1 -4
  78. package/build/components/duotone-control/index.js.map +1 -1
  79. package/build/components/global-styles/advanced-panel.js +1 -1
  80. package/build/components/global-styles/advanced-panel.js.map +1 -1
  81. package/build/components/global-styles/color-panel.js +22 -20
  82. package/build/components/global-styles/color-panel.js.map +1 -1
  83. package/build/components/global-styles/filters-panel.js +9 -3
  84. package/build/components/global-styles/filters-panel.js.map +1 -1
  85. package/build/components/global-styles/typography-panel.js +20 -31
  86. package/build/components/global-styles/typography-panel.js.map +1 -1
  87. package/build/components/image-link-destinations/index.native.js +118 -0
  88. package/build/components/image-link-destinations/index.native.js.map +1 -0
  89. package/build/components/image-size-control/index.js +0 -5
  90. package/build/components/image-size-control/index.js.map +1 -1
  91. package/build/components/index.native.js +8 -0
  92. package/build/components/index.native.js.map +1 -1
  93. package/build/components/inner-blocks/index.js +3 -1
  94. package/build/components/inner-blocks/index.js.map +1 -1
  95. package/build/components/inner-blocks/warning-max-depth-exceeded.native.js +29 -31
  96. package/build/components/inner-blocks/warning-max-depth-exceeded.native.js.map +1 -1
  97. package/build/components/inserter/block-patterns-explorer/pattern-list.js +1 -1
  98. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  99. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +1 -1
  100. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  101. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +1 -1
  102. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
  103. package/build/components/inserter/block-patterns-tab/utils.js +3 -4
  104. package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
  105. package/build/components/inserter/hooks/use-patterns-state.js +2 -1
  106. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  107. package/build/components/inserter/media-tab/media-panel.js +2 -2
  108. package/build/components/inserter/media-tab/media-panel.js.map +1 -1
  109. package/build/components/inserter/menu.js +14 -7
  110. package/build/components/inserter/menu.js.map +1 -1
  111. package/build/components/inserter/preview-panel.js +2 -2
  112. package/build/components/inserter/preview-panel.js.map +1 -1
  113. package/build/components/inserter-button/index.native.js +98 -0
  114. package/build/components/inserter-button/index.native.js.map +1 -0
  115. package/build/components/inserter-button/sparkles.js +23 -0
  116. package/build/components/inserter-button/sparkles.js.map +1 -0
  117. package/build/components/inserter-draggable-blocks/index.js +8 -4
  118. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  119. package/build/components/inserter-listbox/index.js +11 -6
  120. package/build/components/inserter-listbox/index.js.map +1 -1
  121. package/build/components/inserter-listbox/item.js +24 -23
  122. package/build/components/inserter-listbox/item.js.map +1 -1
  123. package/build/components/inserter-listbox/row.js +5 -5
  124. package/build/components/inserter-listbox/row.js.map +1 -1
  125. package/build/components/inspector-controls/fill.js +3 -3
  126. package/build/components/inspector-controls/fill.js.map +1 -1
  127. package/build/components/inspector-controls/fill.native.js +3 -3
  128. package/build/components/inspector-controls/fill.native.js.map +1 -1
  129. package/build/components/list-view/use-list-view-expand-selected-item.js +2 -3
  130. package/build/components/list-view/use-list-view-expand-selected-item.js.map +1 -1
  131. package/build/components/navigable-toolbar/index.js +2 -2
  132. package/build/components/navigable-toolbar/index.js.map +1 -1
  133. package/build/components/preview-options/index.js +6 -60
  134. package/build/components/preview-options/index.js.map +1 -1
  135. package/build/components/rich-text/content.js +26 -23
  136. package/build/components/rich-text/content.js.map +1 -1
  137. package/build/components/rich-text/get-rich-text-values.js +2 -1
  138. package/build/components/rich-text/get-rich-text-values.js.map +1 -1
  139. package/build/components/rich-text/index.js +2 -30
  140. package/build/components/rich-text/index.js.map +1 -1
  141. package/build/components/rich-text/index.native.js +10 -17
  142. package/build/components/rich-text/index.native.js.map +1 -1
  143. package/build/components/rich-text/native/get-format-colors.native.js +22 -24
  144. package/build/components/rich-text/native/get-format-colors.native.js.map +1 -1
  145. package/build/components/rich-text/native/index.native.js +41 -37
  146. package/build/components/rich-text/native/index.native.js.map +1 -1
  147. package/build/components/rich-text/use-input-rules.js +35 -2
  148. package/build/components/rich-text/use-input-rules.js.map +1 -1
  149. package/build/components/rich-text/with-deprecations.js +50 -0
  150. package/build/components/rich-text/with-deprecations.js.map +1 -0
  151. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  152. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  153. package/build/components/use-block-drop-zone/index.js +74 -9
  154. package/build/components/use-block-drop-zone/index.js.map +1 -1
  155. package/build/components/use-moving-animation/index.js +2 -1
  156. package/build/components/use-moving-animation/index.js.map +1 -1
  157. package/build/components/use-on-block-drop/index.js +1 -1
  158. package/build/components/use-on-block-drop/index.js.map +1 -1
  159. package/build/components/use-resize-canvas/index.js +4 -1
  160. package/build/components/use-resize-canvas/index.js.map +1 -1
  161. package/build/components/use-settings/index.js +16 -2
  162. package/build/components/use-settings/index.js.map +1 -1
  163. package/build/hooks/align.js +20 -68
  164. package/build/hooks/align.js.map +1 -1
  165. package/build/hooks/align.native.js +11 -1
  166. package/build/hooks/align.native.js.map +1 -1
  167. package/build/hooks/anchor.js +13 -29
  168. package/build/hooks/anchor.js.map +1 -1
  169. package/build/hooks/background.js +28 -31
  170. package/build/hooks/background.js.map +1 -1
  171. package/build/hooks/block-hooks.js +24 -32
  172. package/build/hooks/block-hooks.js.map +1 -1
  173. package/build/hooks/block-renaming.js +38 -0
  174. package/build/hooks/block-renaming.js.map +1 -1
  175. package/build/hooks/border.js +58 -80
  176. package/build/hooks/border.js.map +1 -1
  177. package/build/hooks/color.js +76 -89
  178. package/build/hooks/color.js.map +1 -1
  179. package/build/hooks/content-lock-ui.js +29 -29
  180. package/build/hooks/content-lock-ui.js.map +1 -1
  181. package/build/hooks/custom-class-name.js +12 -29
  182. package/build/hooks/custom-class-name.js.map +1 -1
  183. package/build/hooks/custom-fields.js +64 -73
  184. package/build/hooks/custom-fields.js.map +1 -1
  185. package/build/hooks/dimensions.js +21 -17
  186. package/build/hooks/dimensions.js.map +1 -1
  187. package/build/hooks/duotone.js +31 -61
  188. package/build/hooks/duotone.js.map +1 -1
  189. package/build/hooks/font-family.js +16 -25
  190. package/build/hooks/font-family.js.map +1 -1
  191. package/build/hooks/font-size.js +51 -119
  192. package/build/hooks/font-size.js.map +1 -1
  193. package/build/hooks/index.js +25 -15
  194. package/build/hooks/index.js.map +1 -1
  195. package/build/hooks/index.native.js +10 -3
  196. package/build/hooks/index.native.js.map +1 -1
  197. package/build/hooks/layout-child.js +68 -0
  198. package/build/hooks/layout-child.js.map +1 -0
  199. package/build/hooks/layout.js +29 -108
  200. package/build/hooks/layout.js.map +1 -1
  201. package/build/hooks/padding.js +2 -2
  202. package/build/hooks/padding.js.map +1 -1
  203. package/build/hooks/position.js +40 -62
  204. package/build/hooks/position.js.map +1 -1
  205. package/build/hooks/style.js +51 -88
  206. package/build/hooks/style.js.map +1 -1
  207. package/build/hooks/typography.js +34 -14
  208. package/build/hooks/typography.js.map +1 -1
  209. package/build/hooks/utils.js +154 -7
  210. package/build/hooks/utils.js.map +1 -1
  211. package/build/layouts/constrained.js +4 -3
  212. package/build/layouts/constrained.js.map +1 -1
  213. package/build/private-apis.js +0 -2
  214. package/build/private-apis.js.map +1 -1
  215. package/build/store/private-actions.js +8 -0
  216. package/build/store/private-actions.js.map +1 -1
  217. package/build/store/private-selectors.js +34 -0
  218. package/build/store/private-selectors.js.map +1 -1
  219. package/build/store/reducer.js +8 -0
  220. package/build/store/reducer.js.map +1 -1
  221. package/build/store/selectors.js +10 -58
  222. package/build/store/selectors.js.map +1 -1
  223. package/build/store/utils.js +66 -0
  224. package/build/store/utils.js.map +1 -0
  225. package/build/utils/object.js +21 -61
  226. package/build/utils/object.js.map +1 -1
  227. package/build/utils/selection.js +9 -1
  228. package/build/utils/selection.js.map +1 -1
  229. package/build/utils/transform-styles/index.js +26 -6
  230. package/build/utils/transform-styles/index.js.map +1 -1
  231. package/build-module/components/block-canvas/index.js +23 -7
  232. package/build-module/components/block-canvas/index.js.map +1 -1
  233. package/build-module/components/block-card/index.js +1 -1
  234. package/build-module/components/block-card/index.js.map +1 -1
  235. package/build-module/components/block-controls/hook.js +4 -24
  236. package/build-module/components/block-controls/hook.js.map +1 -1
  237. package/build-module/components/block-edit/context.js +2 -0
  238. package/build-module/components/block-edit/context.js.map +1 -1
  239. package/build-module/components/block-edit/index.js +19 -10
  240. package/build-module/components/block-edit/index.js.map +1 -1
  241. package/build-module/components/block-info-slot-fill/index.js +3 -3
  242. package/build-module/components/block-info-slot-fill/index.js.map +1 -1
  243. package/build-module/components/block-list/block.js +29 -10
  244. package/build-module/components/block-list/block.js.map +1 -1
  245. package/build-module/components/block-list/block.native.js +16 -5
  246. package/build-module/components/block-list/block.native.js.map +1 -1
  247. package/build-module/components/block-list/use-block-props/index.js +62 -19
  248. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  249. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +4 -29
  250. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  251. package/build-module/components/block-list/use-block-props/use-is-hovered.js +4 -14
  252. package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
  253. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
  254. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  255. package/build-module/components/block-parent-selector/index.js +1 -1
  256. package/build-module/components/block-parent-selector/index.js.map +1 -1
  257. package/build-module/components/block-pattern-setup/index.js +24 -15
  258. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  259. package/build-module/components/block-pattern-setup/setup-toolbar.js +4 -2
  260. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  261. package/build-module/components/block-patterns-list/index.js +37 -20
  262. package/build-module/components/block-patterns-list/index.js.map +1 -1
  263. package/build-module/components/block-removal-warning-modal/index.js +3 -10
  264. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  265. package/build-module/components/block-rename/index.js +4 -0
  266. package/build-module/components/block-rename/index.js.map +1 -0
  267. package/build-module/components/block-rename/is-empty-string.js +4 -0
  268. package/build-module/components/block-rename/is-empty-string.js.map +1 -0
  269. package/build-module/components/block-rename/modal.js +82 -0
  270. package/build-module/components/block-rename/modal.js.map +1 -0
  271. package/build-module/components/block-rename/rename-control.js +66 -0
  272. package/build-module/components/block-rename/rename-control.js.map +1 -0
  273. package/build-module/components/block-rename/use-block-rename.js +10 -0
  274. package/build-module/components/block-rename/use-block-rename.js.map +1 -0
  275. package/build-module/components/block-settings/container.native.js +4 -2
  276. package/build-module/components/block-settings/container.native.js.map +1 -1
  277. package/build-module/components/block-settings-menu/block-settings-dropdown.js +34 -21
  278. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  279. package/build-module/components/block-settings-menu-controls/index.js +7 -0
  280. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  281. package/build-module/components/block-styles/index.js +1 -1
  282. package/build-module/components/block-styles/index.js.map +1 -1
  283. package/build-module/components/block-styles/index.native.js +3 -2
  284. package/build-module/components/block-styles/index.native.js.map +1 -1
  285. package/build-module/components/block-toolbar/block-toolbar-menu.native.js +1 -1
  286. package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  287. package/build-module/components/block-toolbar/index.js +88 -25
  288. package/build-module/components/block-toolbar/index.js.map +1 -1
  289. package/build-module/components/block-tools/block-toolbar-breadcrumb.js +41 -0
  290. package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
  291. package/build-module/components/block-tools/block-toolbar-popover.js +76 -0
  292. package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -0
  293. package/build-module/components/block-tools/index.js +27 -24
  294. package/build-module/components/block-tools/index.js.map +1 -1
  295. package/build-module/components/block-types-list/index.js +6 -2
  296. package/build-module/components/block-types-list/index.js.map +1 -1
  297. package/build-module/components/block-types-list/index.native.js +2 -1
  298. package/build-module/components/block-types-list/index.native.js.map +1 -1
  299. package/build-module/components/block-variation-picker/index.native.js +2 -1
  300. package/build-module/components/block-variation-picker/index.native.js.map +1 -1
  301. package/build-module/components/colors-gradients/control.js +29 -18
  302. package/build-module/components/colors-gradients/control.js.map +1 -1
  303. package/build-module/components/date-format-picker/index.js +8 -1
  304. package/build-module/components/date-format-picker/index.js.map +1 -1
  305. package/build-module/components/duotone-control/index.js +1 -4
  306. package/build-module/components/duotone-control/index.js.map +1 -1
  307. package/build-module/components/global-styles/advanced-panel.js +1 -1
  308. package/build-module/components/global-styles/advanced-panel.js.map +1 -1
  309. package/build-module/components/global-styles/color-panel.js +23 -21
  310. package/build-module/components/global-styles/color-panel.js.map +1 -1
  311. package/build-module/components/global-styles/filters-panel.js +10 -4
  312. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  313. package/build-module/components/global-styles/typography-panel.js +20 -31
  314. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  315. package/build-module/components/image-link-destinations/index.native.js +109 -0
  316. package/build-module/components/image-link-destinations/index.native.js.map +1 -0
  317. package/build-module/components/image-size-control/index.js +0 -5
  318. package/build-module/components/image-size-control/index.js.map +1 -1
  319. package/build-module/components/index.native.js +1 -0
  320. package/build-module/components/index.native.js.map +1 -1
  321. package/build-module/components/inner-blocks/index.js +3 -1
  322. package/build-module/components/inner-blocks/index.js.map +1 -1
  323. package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js +30 -32
  324. package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js.map +1 -1
  325. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
  326. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  327. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -4
  328. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  329. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +2 -2
  330. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
  331. package/build-module/components/inserter/block-patterns-tab/utils.js +3 -4
  332. package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
  333. package/build-module/components/inserter/hooks/use-patterns-state.js +2 -1
  334. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  335. package/build-module/components/inserter/media-tab/media-panel.js +1 -1
  336. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
  337. package/build-module/components/inserter/menu.js +14 -7
  338. package/build-module/components/inserter/menu.js.map +1 -1
  339. package/build-module/components/inserter/preview-panel.js +2 -2
  340. package/build-module/components/inserter/preview-panel.js.map +1 -1
  341. package/build-module/components/inserter-button/index.native.js +89 -0
  342. package/build-module/components/inserter-button/index.native.js.map +1 -0
  343. package/build-module/components/inserter-button/sparkles.js +15 -0
  344. package/build-module/components/inserter-button/sparkles.js.map +1 -0
  345. package/build-module/components/inserter-draggable-blocks/index.js +9 -5
  346. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  347. package/build-module/components/inserter-listbox/index.js +13 -8
  348. package/build-module/components/inserter-listbox/index.js.map +1 -1
  349. package/build-module/components/inserter-listbox/item.js +25 -23
  350. package/build-module/components/inserter-listbox/item.js.map +1 -1
  351. package/build-module/components/inserter-listbox/row.js +6 -5
  352. package/build-module/components/inserter-listbox/row.js.map +1 -1
  353. package/build-module/components/inspector-controls/fill.js +3 -3
  354. package/build-module/components/inspector-controls/fill.js.map +1 -1
  355. package/build-module/components/inspector-controls/fill.native.js +3 -3
  356. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  357. package/build-module/components/list-view/use-list-view-expand-selected-item.js +2 -3
  358. package/build-module/components/list-view/use-list-view-expand-selected-item.js.map +1 -1
  359. package/build-module/components/navigable-toolbar/index.js +2 -2
  360. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  361. package/build-module/components/preview-options/index.js +6 -60
  362. package/build-module/components/preview-options/index.js.map +1 -1
  363. package/build-module/components/rich-text/content.js +25 -21
  364. package/build-module/components/rich-text/content.js.map +1 -1
  365. package/build-module/components/rich-text/get-rich-text-values.js +2 -1
  366. package/build-module/components/rich-text/get-rich-text-values.js.map +1 -1
  367. package/build-module/components/rich-text/index.js +4 -32
  368. package/build-module/components/rich-text/index.js.map +1 -1
  369. package/build-module/components/rich-text/index.native.js +11 -19
  370. package/build-module/components/rich-text/index.native.js.map +1 -1
  371. package/build-module/components/rich-text/native/get-format-colors.native.js +22 -24
  372. package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -1
  373. package/build-module/components/rich-text/native/index.native.js +41 -37
  374. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  375. package/build-module/components/rich-text/use-input-rules.js +36 -3
  376. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  377. package/build-module/components/rich-text/with-deprecations.js +42 -0
  378. package/build-module/components/rich-text/with-deprecations.js.map +1 -0
  379. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  380. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  381. package/build-module/components/use-block-drop-zone/index.js +73 -9
  382. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  383. package/build-module/components/use-moving-animation/index.js +2 -1
  384. package/build-module/components/use-moving-animation/index.js.map +1 -1
  385. package/build-module/components/use-on-block-drop/index.js +1 -1
  386. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  387. package/build-module/components/use-resize-canvas/index.js +4 -1
  388. package/build-module/components/use-resize-canvas/index.js.map +1 -1
  389. package/build-module/components/use-settings/index.js +15 -3
  390. package/build-module/components/use-settings/index.js.map +1 -1
  391. package/build-module/hooks/align.js +19 -66
  392. package/build-module/hooks/align.js.map +1 -1
  393. package/build-module/hooks/align.native.js +1 -0
  394. package/build-module/hooks/align.native.js.map +1 -1
  395. package/build-module/hooks/anchor.js +11 -26
  396. package/build-module/hooks/anchor.js.map +1 -1
  397. package/build-module/hooks/background.js +26 -28
  398. package/build-module/hooks/background.js.map +1 -1
  399. package/build-module/hooks/block-hooks.js +22 -30
  400. package/build-module/hooks/block-hooks.js.map +1 -1
  401. package/build-module/hooks/block-renaming.js +36 -0
  402. package/build-module/hooks/block-renaming.js.map +1 -1
  403. package/build-module/hooks/border.js +57 -78
  404. package/build-module/hooks/border.js.map +1 -1
  405. package/build-module/hooks/color.js +74 -86
  406. package/build-module/hooks/color.js.map +1 -1
  407. package/build-module/hooks/content-lock-ui.js +27 -27
  408. package/build-module/hooks/content-lock-ui.js.map +1 -1
  409. package/build-module/hooks/custom-class-name.js +11 -27
  410. package/build-module/hooks/custom-class-name.js.map +1 -1
  411. package/build-module/hooks/custom-fields.js +60 -74
  412. package/build-module/hooks/custom-fields.js.map +1 -1
  413. package/build-module/hooks/dimensions.js +21 -16
  414. package/build-module/hooks/dimensions.js.map +1 -1
  415. package/build-module/hooks/duotone.js +30 -61
  416. package/build-module/hooks/duotone.js.map +1 -1
  417. package/build-module/hooks/font-family.js +14 -23
  418. package/build-module/hooks/font-family.js.map +1 -1
  419. package/build-module/hooks/font-size.js +49 -119
  420. package/build-module/hooks/font-size.js.map +1 -1
  421. package/build-module/hooks/index.js +18 -15
  422. package/build-module/hooks/index.js.map +1 -1
  423. package/build-module/hooks/index.native.js +5 -3
  424. package/build-module/hooks/index.native.js.map +1 -1
  425. package/build-module/hooks/layout-child.js +60 -0
  426. package/build-module/hooks/layout-child.js.map +1 -0
  427. package/build-module/hooks/layout.js +26 -105
  428. package/build-module/hooks/layout.js.map +1 -1
  429. package/build-module/hooks/padding.js +2 -2
  430. package/build-module/hooks/padding.js.map +1 -1
  431. package/build-module/hooks/position.js +38 -59
  432. package/build-module/hooks/position.js.map +1 -1
  433. package/build-module/hooks/style.js +51 -84
  434. package/build-module/hooks/style.js.map +1 -1
  435. package/build-module/hooks/typography.js +33 -12
  436. package/build-module/hooks/typography.js.map +1 -1
  437. package/build-module/hooks/utils.js +149 -6
  438. package/build-module/hooks/utils.js.map +1 -1
  439. package/build-module/layouts/constrained.js +4 -3
  440. package/build-module/layouts/constrained.js.map +1 -1
  441. package/build-module/private-apis.js +0 -2
  442. package/build-module/private-apis.js.map +1 -1
  443. package/build-module/store/private-actions.js +7 -0
  444. package/build-module/store/private-actions.js.map +1 -1
  445. package/build-module/store/private-selectors.js +33 -1
  446. package/build-module/store/private-selectors.js.map +1 -1
  447. package/build-module/store/reducer.js +8 -0
  448. package/build-module/store/reducer.js.map +1 -1
  449. package/build-module/store/selectors.js +3 -51
  450. package/build-module/store/selectors.js.map +1 -1
  451. package/build-module/store/utils.js +56 -0
  452. package/build-module/store/utils.js.map +1 -0
  453. package/build-module/utils/object.js +21 -60
  454. package/build-module/utils/object.js.map +1 -1
  455. package/build-module/utils/selection.js +9 -1
  456. package/build-module/utils/selection.js.map +1 -1
  457. package/build-module/utils/transform-styles/index.js +24 -7
  458. package/build-module/utils/transform-styles/index.js.map +1 -1
  459. package/build-style/content-rtl.css +6 -6
  460. package/build-style/content.css +6 -6
  461. package/build-style/style-rtl.css +123 -298
  462. package/build-style/style.css +123 -298
  463. package/package.json +31 -31
  464. package/src/components/block-canvas/index.js +31 -17
  465. package/src/components/block-caption/README.md +2 -2
  466. package/src/components/block-card/index.js +5 -3
  467. package/src/components/block-card/style.scss +7 -3
  468. package/src/components/block-controls/hook.js +8 -30
  469. package/src/components/block-controls/test/index.js +3 -3
  470. package/src/components/block-edit/context.js +3 -0
  471. package/src/components/block-edit/index.js +36 -10
  472. package/src/components/block-info-slot-fill/index.js +6 -3
  473. package/src/components/block-inspector/style.scss +0 -4
  474. package/src/components/block-list/block.js +39 -5
  475. package/src/components/block-list/block.native.js +20 -4
  476. package/src/components/block-list/use-block-props/index.js +74 -21
  477. package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -34
  478. package/src/components/block-list/use-block-props/use-is-hovered.js +2 -13
  479. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +1 -5
  480. package/src/components/block-parent-selector/index.js +1 -1
  481. package/src/components/block-pattern-setup/index.js +38 -22
  482. package/src/components/block-pattern-setup/setup-toolbar.js +2 -0
  483. package/src/components/block-pattern-setup/style.scss +4 -1
  484. package/src/components/block-patterns-list/README.md +4 -4
  485. package/src/components/block-patterns-list/index.js +61 -35
  486. package/src/components/block-patterns-list/style.scss +7 -0
  487. package/src/components/block-removal-warning-modal/index.js +7 -14
  488. package/src/components/block-rename/index.js +3 -0
  489. package/src/components/block-rename/is-empty-string.js +3 -0
  490. package/src/components/block-rename/modal.js +121 -0
  491. package/src/components/block-rename/rename-control.js +80 -0
  492. package/src/components/block-rename/use-block-rename.js +10 -0
  493. package/src/components/block-settings/container.native.js +3 -5
  494. package/src/components/block-settings-menu/block-settings-dropdown.js +38 -34
  495. package/src/components/block-settings-menu-controls/index.js +9 -0
  496. package/src/components/block-styles/index.js +1 -1
  497. package/src/components/block-styles/index.native.js +4 -2
  498. package/src/components/block-styles/style.scss +0 -11
  499. package/src/components/block-switcher/test/__snapshots__/index.js.snap +3 -1
  500. package/src/components/block-toolbar/block-toolbar-menu.native.js +1 -4
  501. package/src/components/block-toolbar/index.js +180 -95
  502. package/src/components/block-toolbar/style.scss +50 -66
  503. package/src/components/block-tools/block-toolbar-breadcrumb.js +46 -0
  504. package/src/components/block-tools/block-toolbar-popover.js +90 -0
  505. package/src/components/block-tools/index.js +42 -29
  506. package/src/components/block-tools/style.scss +60 -172
  507. package/src/components/block-types-list/index.js +5 -4
  508. package/src/components/block-types-list/index.native.js +2 -1
  509. package/src/components/block-variation-picker/index.native.js +1 -1
  510. package/src/components/button-block-appender/content.scss +2 -2
  511. package/src/components/colors-gradients/control.js +49 -30
  512. package/src/components/colors-gradients/style.scss +0 -7
  513. package/src/components/date-format-picker/index.js +7 -0
  514. package/src/components/duotone-control/index.js +2 -5
  515. package/src/components/duotone-control/style.scss +1 -6
  516. package/src/components/editable-text/README.md +0 -36
  517. package/src/components/global-styles/advanced-panel.js +1 -1
  518. package/src/components/global-styles/color-panel.js +34 -25
  519. package/src/components/global-styles/filters-panel.js +8 -4
  520. package/src/components/global-styles/typography-panel.js +23 -43
  521. package/src/components/image-link-destinations/index.native.js +152 -0
  522. package/src/components/image-link-destinations/style.native.scss +16 -0
  523. package/src/components/image-size-control/index.js +0 -6
  524. package/src/components/index.native.js +1 -0
  525. package/src/components/inner-blocks/README.md +13 -2
  526. package/src/components/inner-blocks/index.js +6 -2
  527. package/src/components/inner-blocks/warning-max-depth-exceeded.native.js +57 -33
  528. package/src/components/inserter/block-patterns-explorer/pattern-list.js +5 -1
  529. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +7 -3
  530. package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +6 -1
  531. package/src/components/inserter/block-patterns-tab/utils.js +6 -4
  532. package/src/components/inserter/hooks/use-patterns-state.js +3 -1
  533. package/src/components/inserter/media-tab/media-panel.js +1 -1
  534. package/src/components/inserter/menu.js +16 -8
  535. package/src/components/inserter/preview-panel.js +2 -2
  536. package/src/components/inserter/style.scss +15 -17
  537. package/src/components/inserter-button/README.md +62 -0
  538. package/src/components/inserter-button/index.native.js +116 -0
  539. package/src/components/inserter-button/sparkles.js +15 -0
  540. package/src/components/inserter-button/style.native.scss +72 -0
  541. package/src/components/inserter-draggable-blocks/index.js +18 -5
  542. package/src/components/inserter-listbox/index.js +11 -7
  543. package/src/components/inserter-listbox/item.js +11 -12
  544. package/src/components/inserter-listbox/row.js +6 -12
  545. package/src/components/inspector-controls/fill.js +6 -3
  546. package/src/components/inspector-controls/fill.native.js +6 -3
  547. package/src/components/link-control/style.scss +1 -1
  548. package/src/components/link-control/test/index.js +1 -1
  549. package/src/components/list-view/use-list-view-expand-selected-item.js +7 -8
  550. package/src/components/navigable-toolbar/README.md +2 -0
  551. package/src/components/navigable-toolbar/index.js +2 -2
  552. package/src/components/plain-text/README.md +0 -28
  553. package/src/components/preview-options/index.js +6 -84
  554. package/src/components/rich-text/README.md +0 -58
  555. package/src/components/rich-text/content.js +27 -20
  556. package/src/components/rich-text/get-rich-text-values.js +6 -1
  557. package/src/components/rich-text/index.js +5 -46
  558. package/src/components/rich-text/index.native.js +9 -26
  559. package/src/components/rich-text/native/get-format-colors.native.js +33 -40
  560. package/src/components/rich-text/native/index.native.js +52 -50
  561. package/src/components/rich-text/use-input-rules.js +36 -3
  562. package/src/components/rich-text/with-deprecations.js +51 -0
  563. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  564. package/src/components/url-input/README.md +1 -74
  565. package/src/components/use-block-drop-zone/index.js +118 -15
  566. package/src/components/use-moving-animation/index.js +1 -1
  567. package/src/components/use-on-block-drop/index.js +2 -1
  568. package/src/components/use-resize-canvas/README.md +3 -3
  569. package/src/components/use-resize-canvas/index.js +4 -1
  570. package/src/components/use-settings/index.js +17 -3
  571. package/src/components/use-settings/test/index.js +1 -1
  572. package/src/hooks/align.js +15 -76
  573. package/src/hooks/align.native.js +1 -0
  574. package/src/hooks/anchor.js +13 -33
  575. package/src/hooks/background.js +28 -23
  576. package/src/hooks/block-hooks.js +22 -51
  577. package/src/hooks/block-renaming.js +33 -0
  578. package/src/hooks/border.js +67 -118
  579. package/src/hooks/color.js +100 -132
  580. package/src/hooks/content-lock-ui.js +110 -122
  581. package/src/hooks/custom-class-name.js +8 -40
  582. package/src/hooks/custom-fields.js +70 -94
  583. package/src/hooks/dimensions.js +20 -16
  584. package/src/hooks/duotone.js +70 -127
  585. package/src/hooks/font-family.js +10 -29
  586. package/src/hooks/font-size.js +66 -162
  587. package/src/hooks/index.js +42 -15
  588. package/src/hooks/index.native.js +6 -3
  589. package/src/hooks/layout-child.js +53 -0
  590. package/src/hooks/layout.js +25 -110
  591. package/src/hooks/padding.js +2 -2
  592. package/src/hooks/position.js +50 -90
  593. package/src/hooks/style.js +117 -187
  594. package/src/hooks/test/__snapshots__/align.native.js.snap +5 -5
  595. package/src/hooks/test/align.js +1 -178
  596. package/src/hooks/typography.js +20 -16
  597. package/src/hooks/utils.js +187 -6
  598. package/src/layouts/constrained.js +57 -50
  599. package/src/private-apis.js +0 -2
  600. package/src/store/private-actions.js +8 -0
  601. package/src/store/private-selectors.js +45 -0
  602. package/src/store/reducer.js +8 -0
  603. package/src/store/selectors.js +5 -67
  604. package/src/store/utils.js +74 -0
  605. package/src/style.scss +1 -3
  606. package/src/utils/object.js +18 -69
  607. package/src/utils/selection.js +9 -2
  608. package/src/utils/test/transform-styles.js +49 -0
  609. package/src/utils/transform-styles/index.js +39 -13
  610. package/build/components/block-list/use-block-props/use-block-class-names.js +0 -67
  611. package/build/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
  612. package/build/components/block-list/use-block-props/use-block-custom-class-name.js +0 -46
  613. package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
  614. package/build/components/block-list/use-block-props/use-block-default-class-name.js +0 -37
  615. package/build/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
  616. package/build/components/block-tools/back-compat.js +0 -45
  617. package/build/components/block-tools/back-compat.js.map +0 -1
  618. package/build/components/block-tools/block-contextual-toolbar.js +0 -91
  619. package/build/components/block-tools/block-contextual-toolbar.js.map +0 -1
  620. package/build/components/block-tools/selected-block-tools.js +0 -113
  621. package/build/components/block-tools/selected-block-tools.js.map +0 -1
  622. package/build/components/inserter/hooks/use-debounced-input.js +0 -22
  623. package/build/components/inserter/hooks/use-debounced-input.js.map +0 -1
  624. package/build/components/use-display-block-controls/index.js +0 -39
  625. package/build/components/use-display-block-controls/index.js.map +0 -1
  626. package/build/components/use-display-block-controls/index.native.js +0 -39
  627. package/build/components/use-display-block-controls/index.native.js.map +0 -1
  628. package/build/hooks/block-rename-ui.js +0 -167
  629. package/build/hooks/block-rename-ui.js.map +0 -1
  630. package/build-module/components/block-list/use-block-props/use-block-class-names.js +0 -60
  631. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
  632. package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js +0 -40
  633. package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
  634. package/build-module/components/block-list/use-block-props/use-block-default-class-name.js +0 -31
  635. package/build-module/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
  636. package/build-module/components/block-tools/back-compat.js +0 -35
  637. package/build-module/components/block-tools/back-compat.js.map +0 -1
  638. package/build-module/components/block-tools/block-contextual-toolbar.js +0 -83
  639. package/build-module/components/block-tools/block-contextual-toolbar.js.map +0 -1
  640. package/build-module/components/block-tools/selected-block-tools.js +0 -105
  641. package/build-module/components/block-tools/selected-block-tools.js.map +0 -1
  642. package/build-module/components/inserter/hooks/use-debounced-input.js +0 -15
  643. package/build-module/components/inserter/hooks/use-debounced-input.js.map +0 -1
  644. package/build-module/components/use-display-block-controls/index.js +0 -32
  645. package/build-module/components/use-display-block-controls/index.js.map +0 -1
  646. package/build-module/components/use-display-block-controls/index.native.js +0 -32
  647. package/build-module/components/use-display-block-controls/index.native.js.map +0 -1
  648. package/build-module/hooks/block-rename-ui.js +0 -159
  649. package/build-module/hooks/block-rename-ui.js.map +0 -1
  650. package/src/components/block-list/use-block-props/use-block-class-names.js +0 -66
  651. package/src/components/block-list/use-block-props/use-block-custom-class-name.js +0 -44
  652. package/src/components/block-list/use-block-props/use-block-default-class-name.js +0 -35
  653. package/src/components/block-parent-selector/style.scss +0 -11
  654. package/src/components/block-tools/back-compat.js +0 -35
  655. package/src/components/block-tools/block-contextual-toolbar.js +0 -100
  656. package/src/components/block-tools/selected-block-tools.js +0 -127
  657. package/src/components/inserter/hooks/use-debounced-input.js +0 -18
  658. package/src/components/preview-options/README.md +0 -94
  659. package/src/components/preview-options/style.scss +0 -64
  660. package/src/components/use-display-block-controls/index.js +0 -36
  661. package/src/components/use-display-block-controls/index.native.js +0 -37
  662. package/src/hooks/block-rename-ui.js +0 -228
  663. package/src/hooks/test/color.js +0 -112
  664. /package/src/{hooks/block-rename-ui.scss → components/block-rename/style.scss} +0 -0
@@ -283,6 +283,7 @@ const withBlockTree =
283
283
  false
284
284
  );
285
285
  break;
286
+ case 'SYNC_DERIVED_BLOCK_ATTRIBUTES':
286
287
  case 'UPDATE_BLOCK_ATTRIBUTES': {
287
288
  newState.tree = new Map( newState.tree );
288
289
  action.clientIds.forEach( ( clientId ) => {
@@ -456,6 +457,12 @@ function withPersistentBlockChange( reducer ) {
456
457
  return ( state, action ) => {
457
458
  let nextState = reducer( state, action );
458
459
 
460
+ if ( action.type === 'SYNC_DERIVED_BLOCK_ATTRIBUTES' ) {
461
+ return nextState.isPersistentChange
462
+ ? { ...nextState, isPersistentChange: false }
463
+ : nextState;
464
+ }
465
+
459
466
  const isExplicitPersistentChange =
460
467
  action.type === 'MARK_LAST_CHANGE_AS_PERSISTENT' ||
461
468
  markNextChangeAsNotPersistent;
@@ -860,6 +867,7 @@ export const blocks = pipe(
860
867
  return newState;
861
868
  }
862
869
 
870
+ case 'SYNC_DERIVED_BLOCK_ATTRIBUTES':
863
871
  case 'UPDATE_BLOCK_ATTRIBUTES': {
864
872
  // Avoid a state change if none of the block IDs are known.
865
873
  if ( action.clientIds.every( ( id ) => ! state.get( id ) ) ) {
@@ -26,6 +26,11 @@ import { createRegistrySelector } from '@wordpress/data';
26
26
  /**
27
27
  * Internal dependencies
28
28
  */
29
+ import {
30
+ getUserPatterns,
31
+ checkAllowListRecursive,
32
+ checkAllowList,
33
+ } from './utils';
29
34
  import { orderBy } from '../utils/sorting';
30
35
 
31
36
  /**
@@ -1480,22 +1485,6 @@ export function getTemplateLock( state, rootClientId ) {
1480
1485
  return getBlockListSettings( state, rootClientId )?.templateLock ?? false;
1481
1486
  }
1482
1487
 
1483
- const checkAllowList = ( list, item, defaultResult = null ) => {
1484
- if ( typeof list === 'boolean' ) {
1485
- return list;
1486
- }
1487
- if ( Array.isArray( list ) ) {
1488
- // TODO: when there is a canonical way to detect that we are editing a post
1489
- // the following check should be changed to something like:
1490
- // if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )
1491
- if ( list.includes( 'core/post-content' ) && item === null ) {
1492
- return true;
1493
- }
1494
- return list.includes( item );
1495
- }
1496
- return defaultResult;
1497
- };
1498
-
1499
1488
  /**
1500
1489
  * Determines if the given block type is allowed to be inserted into the block list.
1501
1490
  * This function is not exported and not memoized because using a memoized selector
@@ -2248,57 +2237,6 @@ export const __experimentalGetDirectInsertBlock = createSelector(
2248
2237
  ]
2249
2238
  );
2250
2239
 
2251
- const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {
2252
- if ( typeof allowedBlockTypes === 'boolean' ) {
2253
- return allowedBlockTypes;
2254
- }
2255
-
2256
- const blocksQueue = [ ...blocks ];
2257
- while ( blocksQueue.length > 0 ) {
2258
- const block = blocksQueue.shift();
2259
-
2260
- const isAllowed = checkAllowList(
2261
- allowedBlockTypes,
2262
- block.name || block.blockName,
2263
- true
2264
- );
2265
- if ( ! isAllowed ) {
2266
- return false;
2267
- }
2268
-
2269
- block.innerBlocks?.forEach( ( innerBlock ) => {
2270
- blocksQueue.push( innerBlock );
2271
- } );
2272
- }
2273
-
2274
- return true;
2275
- };
2276
-
2277
- function getUserPatterns( state ) {
2278
- const userPatterns =
2279
- state?.settings?.__experimentalReusableBlocks ?? EMPTY_ARRAY;
2280
- const userPatternCategories =
2281
- state?.settings?.__experimentalUserPatternCategories ?? [];
2282
- const categories = new Map();
2283
- userPatternCategories.forEach( ( userCategory ) =>
2284
- categories.set( userCategory.id, userCategory )
2285
- );
2286
- return userPatterns.map( ( userPattern ) => {
2287
- return {
2288
- name: `core/block/${ userPattern.id }`,
2289
- id: userPattern.id,
2290
- title: userPattern.title.raw,
2291
- categories: userPattern.wp_pattern_category.map( ( catId ) =>
2292
- categories && categories.get( catId )
2293
- ? categories.get( catId ).slug
2294
- : catId
2295
- ),
2296
- content: userPattern.content.raw,
2297
- syncStatus: userPattern.wp_pattern_sync_status,
2298
- };
2299
- } );
2300
- }
2301
-
2302
2240
  export const __experimentalUserPatternCategories = createSelector(
2303
2241
  ( state ) => {
2304
2242
  return state?.settings?.__experimentalUserPatternCategories;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { PATTERN_TYPES } from '../components/inserter/block-patterns-tab/utils';
5
+
6
+ const EMPTY_ARRAY = [];
7
+
8
+ export function getUserPatterns( state ) {
9
+ const userPatterns =
10
+ state?.settings?.__experimentalReusableBlocks ?? EMPTY_ARRAY;
11
+ const userPatternCategories =
12
+ state?.settings?.__experimentalUserPatternCategories ?? [];
13
+ const categories = new Map();
14
+ userPatternCategories.forEach( ( userCategory ) =>
15
+ categories.set( userCategory.id, userCategory )
16
+ );
17
+ return userPatterns.map( ( userPattern ) => {
18
+ return {
19
+ name: `core/block/${ userPattern.id }`,
20
+ id: userPattern.id,
21
+ type: PATTERN_TYPES.user,
22
+ title: userPattern.title.raw,
23
+ categories: userPattern.wp_pattern_category.map( ( catId ) =>
24
+ categories && categories.get( catId )
25
+ ? categories.get( catId ).slug
26
+ : catId
27
+ ),
28
+ content: userPattern.content.raw,
29
+ syncStatus: userPattern.wp_pattern_sync_status,
30
+ };
31
+ } );
32
+ }
33
+
34
+ export const checkAllowList = ( list, item, defaultResult = null ) => {
35
+ if ( typeof list === 'boolean' ) {
36
+ return list;
37
+ }
38
+ if ( Array.isArray( list ) ) {
39
+ // TODO: when there is a canonical way to detect that we are editing a post
40
+ // the following check should be changed to something like:
41
+ // if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )
42
+ if ( list.includes( 'core/post-content' ) && item === null ) {
43
+ return true;
44
+ }
45
+ return list.includes( item );
46
+ }
47
+ return defaultResult;
48
+ };
49
+
50
+ export const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {
51
+ if ( typeof allowedBlockTypes === 'boolean' ) {
52
+ return allowedBlockTypes;
53
+ }
54
+
55
+ const blocksQueue = [ ...blocks ];
56
+ while ( blocksQueue.length > 0 ) {
57
+ const block = blocksQueue.shift();
58
+
59
+ const isAllowed = checkAllowList(
60
+ allowedBlockTypes,
61
+ block.name || block.blockName,
62
+ true
63
+ );
64
+ if ( ! isAllowed ) {
65
+ return false;
66
+ }
67
+
68
+ block.innerBlocks?.forEach( ( innerBlock ) => {
69
+ blocksQueue.push( innerBlock );
70
+ } );
71
+ }
72
+
73
+ return true;
74
+ };
package/src/style.scss CHANGED
@@ -10,11 +10,11 @@
10
10
  @import "./components/block-draggable/style.scss";
11
11
  @import "./components/block-mover/style.scss";
12
12
  @import "./components/block-navigation/style.scss";
13
- @import "./components/block-parent-selector/style.scss";
14
13
  @import "./components/block-patterns-list/style.scss";
15
14
  @import "./components/block-patterns-paging/style.scss";
16
15
  @import "./components/block-popover/style.scss";
17
16
  @import "./components/block-preview/style.scss";
17
+ @import "./components/block-rename/style.scss";
18
18
  @import "./components/block-settings-menu/style.scss";
19
19
  @import "./components/block-styles/style.scss";
20
20
  @import "./components/block-switcher/style.scss";
@@ -56,11 +56,9 @@
56
56
  @import "./hooks/padding.scss";
57
57
  @import "./hooks/position.scss";
58
58
  @import "./hooks/typography.scss";
59
- @import "./hooks/block-rename-ui.scss";
60
59
 
61
60
  @import "./components/block-toolbar/style.scss";
62
61
  @import "./components/inserter/style.scss";
63
- @import "./components/preview-options/style.scss";
64
62
  @import "./components/spacing-sizes-control/style.scss";
65
63
 
66
64
  @include wordpress-admin-schemes();
@@ -2,28 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { paramCase } from 'change-case';
5
- import memoize from 'memize';
6
-
7
- /**
8
- * Converts a path to an array of its fragments.
9
- * Supports strings, numbers and arrays:
10
- *
11
- * 'foo' => [ 'foo' ]
12
- * 2 => [ '2' ]
13
- * [ 'foo', 'bar' ] => [ 'foo', 'bar' ]
14
- *
15
- * @param {string|number|Array} path Path
16
- * @return {Array} Normalized path.
17
- */
18
- function normalizePath( path ) {
19
- if ( Array.isArray( path ) ) {
20
- return path;
21
- } else if ( typeof path === 'number' ) {
22
- return [ path.toString() ];
23
- }
24
-
25
- return [ path ];
26
- }
27
5
 
28
6
  /**
29
7
  * Converts any string to kebab case.
@@ -55,33 +33,6 @@ export function kebabCase( str ) {
55
33
  } );
56
34
  }
57
35
 
58
- /**
59
- * Clones an object.
60
- * Arrays are also cloned as arrays.
61
- * Non-object values are returned unchanged.
62
- *
63
- * @param {*} object Object to clone.
64
- * @return {*} Cloned object, or original literal non-object value.
65
- */
66
- function cloneObject( object ) {
67
- if ( Array.isArray( object ) ) {
68
- return object.map( cloneObject );
69
- }
70
-
71
- if ( object && typeof object === 'object' ) {
72
- return {
73
- ...Object.fromEntries(
74
- Object.entries( object ).map( ( [ key, value ] ) => [
75
- key,
76
- cloneObject( value ),
77
- ] )
78
- ),
79
- };
80
- }
81
-
82
- return object;
83
- }
84
-
85
36
  /**
86
37
  * Immutably sets a value inside an object. Like `lodash#set`, but returning a
87
38
  * new object. Treats nullish initial values as empty objects. Clones any
@@ -93,27 +44,25 @@ function cloneObject( object ) {
93
44
  * @return {Object} Cloned object with the new value set.
94
45
  */
95
46
  export function setImmutably( object, path, value ) {
96
- const normalizedPath = normalizePath( path );
97
- const newObject = object ? cloneObject( object ) : {};
47
+ // Normalize path
48
+ path = Array.isArray( path ) ? [ ...path ] : [ path ];
98
49
 
99
- normalizedPath.reduce( ( acc, key, i ) => {
100
- if ( acc[ key ] === undefined ) {
101
- if ( Number.isInteger( path[ i + 1 ] ) ) {
102
- acc[ key ] = [];
103
- } else {
104
- acc[ key ] = {};
105
- }
106
- }
107
- if ( i === normalizedPath.length - 1 ) {
108
- acc[ key ] = value;
109
- }
110
- return acc[ key ];
111
- }, newObject );
50
+ // Shallowly clone the base of the object
51
+ object = Array.isArray( object ) ? [ ...object ] : { ...object };
112
52
 
113
- return newObject;
114
- }
53
+ const leaf = path.pop();
54
+
55
+ // Traverse object from root to leaf, shallowly cloning at each level
56
+ let prev = object;
57
+ for ( const key of path ) {
58
+ const lvl = prev[ key ];
59
+ prev = prev[ key ] = Array.isArray( lvl ) ? [ ...lvl ] : { ...lvl };
60
+ }
115
61
 
116
- const stringToPath = memoize( ( path ) => path.split( '.' ) );
62
+ prev[ leaf ] = value;
63
+
64
+ return object;
65
+ }
117
66
 
118
67
  /**
119
68
  * Helper util to return a value from a certain path of the object.
@@ -128,9 +77,9 @@ const stringToPath = memoize( ( path ) => path.split( '.' ) );
128
77
  * @return {*} Value of the object property at the specified path.
129
78
  */
130
79
  export const getValueFromObjectPath = ( object, path, defaultValue ) => {
131
- const normalizedPath = Array.isArray( path ) ? path : stringToPath( path );
80
+ const arrayPath = Array.isArray( path ) ? path : path.split( '.' );
132
81
  let value = object;
133
- normalizedPath.forEach( ( fieldName ) => {
82
+ arrayPath.forEach( ( fieldName ) => {
134
83
  value = value?.[ fieldName ];
135
84
  } );
136
85
  return value ?? defaultValue;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { RichTextData } from '@wordpress/rich-text';
5
+
1
6
  /**
2
7
  * A robust way to retain selection position through various
3
8
  * transforms is to insert a special character at the position and
@@ -19,8 +24,10 @@ export function retrieveSelectedAttribute( blockAttributes ) {
19
24
  return Object.keys( blockAttributes ).find( ( name ) => {
20
25
  const value = blockAttributes[ name ];
21
26
  return (
22
- typeof value === 'string' &&
23
- value.indexOf( START_OF_SELECTED_AREA ) !== -1
27
+ ( typeof value === 'string' || value instanceof RichTextData ) &&
28
+ // To do: refactor this to use rich text's selection instead, so we
29
+ // no longer have to use on this hack inserting a special character.
30
+ value.toString().indexOf( START_OF_SELECTED_AREA ) !== -1
24
31
  );
25
32
  } );
26
33
  }
@@ -4,6 +4,55 @@
4
4
  import transformStyles from '../transform-styles';
5
5
 
6
6
  describe( 'transformStyles', () => {
7
+ describe( 'error handling', () => {
8
+ beforeEach( () => {
9
+ // Intentionally suppress the expected console errors and warnings to reduce
10
+ // noise in the test output.
11
+ jest.spyOn( console, 'warn' ).mockImplementation( jest.fn() );
12
+ } );
13
+
14
+ it( 'should not throw error in case of invalid css', () => {
15
+ const run = () =>
16
+ transformStyles(
17
+ [
18
+ {
19
+ css: 'h1 { color: red;', // invalid CSS
20
+ },
21
+ ],
22
+ '.my-namespace'
23
+ );
24
+
25
+ expect( run ).not.toThrow();
26
+ expect( console ).toHaveWarned();
27
+ } );
28
+
29
+ it( 'should warn invalid css in the console', () => {
30
+ const run = () =>
31
+ transformStyles(
32
+ [
33
+ {
34
+ css: 'h1 { color: red; }', // valid CSS
35
+ },
36
+ {
37
+ css: 'h1 { color: red;', // invalid CSS
38
+ },
39
+ ],
40
+ '.my-namespace'
41
+ );
42
+
43
+ const [ validCSS, invalidCSS ] = run();
44
+
45
+ expect( validCSS ).toBe( '.my-namespace h1 { color: red; }' );
46
+ expect( invalidCSS ).toBe( null );
47
+
48
+ expect( console ).toHaveWarnedWith(
49
+ 'wp.blockEditor.transformStyles Failed to transform CSS.',
50
+ '<css input>:1:1: Unclosed block\n> 1 | h1 { color: red;\n | ^'
51
+ // ^^^^ In PostCSS, a tab is equal four spaces
52
+ );
53
+ } );
54
+ } );
55
+
7
56
  describe( 'selector wrap', () => {
8
57
  it( 'should wrap regular selectors', () => {
9
58
  const input = `h1 { color: red; }`;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import postcss from 'postcss';
4
+ import postcss, { CssSyntaxError } from 'postcss';
5
5
  import wrap from 'postcss-prefixwrap';
6
6
  import rebaseUrl from 'postcss-urlrebase';
7
7
 
@@ -19,18 +19,44 @@ import rebaseUrl from 'postcss-urlrebase';
19
19
  */
20
20
  const transformStyles = ( styles, wrapperSelector = '' ) => {
21
21
  return styles.map( ( { css, ignoredSelectors = [], baseURL } ) => {
22
- return postcss(
23
- [
24
- wrapperSelector &&
25
- wrap( wrapperSelector, {
26
- ignoredSelectors: [
27
- ...ignoredSelectors,
28
- wrapperSelector,
29
- ],
30
- } ),
31
- baseURL && rebaseUrl( { rootUrl: baseURL } ),
32
- ].filter( Boolean )
33
- ).process( css, {} ).css; // use sync PostCSS API
22
+ // When there is no wrapper selector or base URL, there is no need
23
+ // to transform the CSS. This is most cases because in the default
24
+ // iframed editor, no wrapping is needed, and not many styles
25
+ // provide a base URL.
26
+ if ( ! wrapperSelector && ! baseURL ) {
27
+ return css;
28
+ }
29
+
30
+ try {
31
+ return postcss(
32
+ [
33
+ wrapperSelector &&
34
+ wrap( wrapperSelector, {
35
+ ignoredSelectors: [
36
+ ...ignoredSelectors,
37
+ wrapperSelector,
38
+ ],
39
+ } ),
40
+ baseURL && rebaseUrl( { rootUrl: baseURL } ),
41
+ ].filter( Boolean )
42
+ ).process( css, {} ).css; // use sync PostCSS API
43
+ } catch ( error ) {
44
+ if ( error instanceof CssSyntaxError ) {
45
+ // eslint-disable-next-line no-console
46
+ console.warn(
47
+ 'wp.blockEditor.transformStyles Failed to transform CSS.',
48
+ error.message + '\n' + error.showSourceCode( false )
49
+ );
50
+ } else {
51
+ // eslint-disable-next-line no-console
52
+ console.warn(
53
+ 'wp.blockEditor.transformStyles Failed to transform CSS.',
54
+ error
55
+ );
56
+ }
57
+
58
+ return null;
59
+ }
34
60
  } );
35
61
  };
36
62
 
@@ -1,67 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.useBlockClassNames = useBlockClassNames;
8
- var _classnames = _interopRequireDefault(require("classnames"));
9
- var _data = require("@wordpress/data");
10
- var _blocks = require("@wordpress/blocks");
11
- var _store = require("../../../store");
12
- /**
13
- * External dependencies
14
- */
15
-
16
- /**
17
- * WordPress dependencies
18
- */
19
-
20
- /**
21
- * Internal dependencies
22
- */
23
-
24
- /**
25
- * Returns the class names used for the different states of the block.
26
- *
27
- * @param {string} clientId The block client ID.
28
- *
29
- * @return {string} The class names.
30
- */
31
- function useBlockClassNames(clientId) {
32
- return (0, _data.useSelect)(select => {
33
- const {
34
- isBlockBeingDragged,
35
- isBlockHighlighted,
36
- isBlockSelected,
37
- isBlockMultiSelected,
38
- getBlockName,
39
- getSettings,
40
- hasSelectedInnerBlock,
41
- isTyping,
42
- __unstableIsFullySelected,
43
- __unstableSelectionHasUnmergeableBlock
44
- } = select(_store.store);
45
- const {
46
- outlineMode
47
- } = getSettings();
48
- const isDragging = isBlockBeingDragged(clientId);
49
- const isSelected = isBlockSelected(clientId);
50
- const name = getBlockName(clientId);
51
- const checkDeep = true;
52
- // "ancestor" is the more appropriate label due to "deep" check.
53
- const isAncestorOfSelectedBlock = hasSelectedInnerBlock(clientId, checkDeep);
54
- const isMultiSelected = isBlockMultiSelected(clientId);
55
- return (0, _classnames.default)({
56
- 'is-selected': isSelected,
57
- 'is-highlighted': isBlockHighlighted(clientId),
58
- 'is-multi-selected': isMultiSelected,
59
- 'is-partially-selected': isMultiSelected && !__unstableIsFullySelected() && !__unstableSelectionHasUnmergeableBlock(),
60
- 'is-reusable': (0, _blocks.isReusableBlock)((0, _blocks.getBlockType)(name)),
61
- 'is-dragging': isDragging,
62
- 'has-child-selected': isAncestorOfSelectedBlock,
63
- 'remove-outline': isSelected && outlineMode && isTyping()
64
- });
65
- }, [clientId]);
66
- }
67
- //# sourceMappingURL=use-block-class-names.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_data","_blocks","_store","useBlockClassNames","clientId","useSelect","select","isBlockBeingDragged","isBlockHighlighted","isBlockSelected","isBlockMultiSelected","getBlockName","getSettings","hasSelectedInnerBlock","isTyping","__unstableIsFullySelected","__unstableSelectionHasUnmergeableBlock","blockEditorStore","outlineMode","isDragging","isSelected","name","checkDeep","isAncestorOfSelectedBlock","isMultiSelected","classnames","isReusableBlock","getBlockType"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-block-class-names.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { isReusableBlock, getBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * Returns the class names used for the different states of the block.\n *\n * @param {string} clientId The block client ID.\n *\n * @return {string} The class names.\n */\nexport function useBlockClassNames( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockBeingDragged,\n\t\t\t\tisBlockHighlighted,\n\t\t\t\tisBlockSelected,\n\t\t\t\tisBlockMultiSelected,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetSettings,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tisTyping,\n\t\t\t\t__unstableIsFullySelected,\n\t\t\t\t__unstableSelectionHasUnmergeableBlock,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { outlineMode } = getSettings();\n\t\t\tconst isDragging = isBlockBeingDragged( clientId );\n\t\t\tconst isSelected = isBlockSelected( clientId );\n\t\t\tconst name = getBlockName( clientId );\n\t\t\tconst checkDeep = true;\n\t\t\t// \"ancestor\" is the more appropriate label due to \"deep\" check.\n\t\t\tconst isAncestorOfSelectedBlock = hasSelectedInnerBlock(\n\t\t\t\tclientId,\n\t\t\t\tcheckDeep\n\t\t\t);\n\t\t\tconst isMultiSelected = isBlockMultiSelected( clientId );\n\t\t\treturn classnames( {\n\t\t\t\t'is-selected': isSelected,\n\t\t\t\t'is-highlighted': isBlockHighlighted( clientId ),\n\t\t\t\t'is-multi-selected': isMultiSelected,\n\t\t\t\t'is-partially-selected':\n\t\t\t\t\tisMultiSelected &&\n\t\t\t\t\t! __unstableIsFullySelected() &&\n\t\t\t\t\t! __unstableSelectionHasUnmergeableBlock(),\n\t\t\t\t'is-reusable': isReusableBlock( getBlockType( name ) ),\n\t\t\t\t'is-dragging': isDragging,\n\t\t\t\t'has-child-selected': isAncestorOfSelectedBlock,\n\t\t\t\t'remove-outline': isSelected && outlineMode && isTyping(),\n\t\t\t} );\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,kBAAkBA,CAAEC,QAAQ,EAAG;EAC9C,OAAO,IAAAC,eAAS,EACbC,MAAM,IAAM;IACb,MAAM;MACLC,mBAAmB;MACnBC,kBAAkB;MAClBC,eAAe;MACfC,oBAAoB;MACpBC,YAAY;MACZC,WAAW;MACXC,qBAAqB;MACrBC,QAAQ;MACRC,yBAAyB;MACzBC;IACD,CAAC,GAAGV,MAAM,CAAEW,YAAiB,CAAC;IAC9B,MAAM;MAAEC;IAAY,CAAC,GAAGN,WAAW,CAAC,CAAC;IACrC,MAAMO,UAAU,GAAGZ,mBAAmB,CAAEH,QAAS,CAAC;IAClD,MAAMgB,UAAU,GAAGX,eAAe,CAAEL,QAAS,CAAC;IAC9C,MAAMiB,IAAI,GAAGV,YAAY,CAAEP,QAAS,CAAC;IACrC,MAAMkB,SAAS,GAAG,IAAI;IACtB;IACA,MAAMC,yBAAyB,GAAGV,qBAAqB,CACtDT,QAAQ,EACRkB,SACD,CAAC;IACD,MAAME,eAAe,GAAGd,oBAAoB,CAAEN,QAAS,CAAC;IACxD,OAAO,IAAAqB,mBAAU,EAAE;MAClB,aAAa,EAAEL,UAAU;MACzB,gBAAgB,EAAEZ,kBAAkB,CAAEJ,QAAS,CAAC;MAChD,mBAAmB,EAAEoB,eAAe;MACpC,uBAAuB,EACtBA,eAAe,IACf,CAAET,yBAAyB,CAAC,CAAC,IAC7B,CAAEC,sCAAsC,CAAC,CAAC;MAC3C,aAAa,EAAE,IAAAU,uBAAe,EAAE,IAAAC,oBAAY,EAAEN,IAAK,CAAE,CAAC;MACtD,aAAa,EAAEF,UAAU;MACzB,oBAAoB,EAAEI,yBAAyB;MAC/C,gBAAgB,EAAEH,UAAU,IAAIF,WAAW,IAAIJ,QAAQ,CAAC;IACzD,CAAE,CAAC;EACJ,CAAC,EACD,CAAEV,QAAQ,CACX,CAAC;AACF"}
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useBlockCustomClassName = useBlockCustomClassName;
7
- var _data = require("@wordpress/data");
8
- var _blocks = require("@wordpress/blocks");
9
- var _store = require("../../../store");
10
- /**
11
- * WordPress dependencies
12
- */
13
-
14
- /**
15
- * Internal dependencies
16
- */
17
-
18
- /**
19
- * Returns the custom class name if the block is a light block.
20
- *
21
- * @param {string} clientId The block client ID.
22
- *
23
- * @return {string} The custom class name.
24
- */
25
- function useBlockCustomClassName(clientId) {
26
- // It's good for this to be a separate selector because it will be executed
27
- // on every attribute change, while the other selectors are not re-evaluated
28
- // as much.
29
- return (0, _data.useSelect)(select => {
30
- const {
31
- getBlockName,
32
- getBlockAttributes
33
- } = select(_store.store);
34
- const attributes = getBlockAttributes(clientId);
35
- if (!attributes?.className) {
36
- return;
37
- }
38
- const blockType = (0, _blocks.getBlockType)(getBlockName(clientId));
39
- const hasLightBlockWrapper = blockType?.apiVersion > 1;
40
- if (!hasLightBlockWrapper) {
41
- return;
42
- }
43
- return attributes.className;
44
- }, [clientId]);
45
- }
46
- //# sourceMappingURL=use-block-custom-class-name.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_data","require","_blocks","_store","useBlockCustomClassName","clientId","useSelect","select","getBlockName","getBlockAttributes","blockEditorStore","attributes","className","blockType","getBlockType","hasLightBlockWrapper","apiVersion"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-block-custom-class-name.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { getBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * Returns the custom class name if the block is a light block.\n *\n * @param {string} clientId The block client ID.\n *\n * @return {string} The custom class name.\n */\nexport function useBlockCustomClassName( clientId ) {\n\t// It's good for this to be a separate selector because it will be executed\n\t// on every attribute change, while the other selectors are not re-evaluated\n\t// as much.\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\n\t\t\tif ( ! attributes?.className ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst blockType = getBlockType( getBlockName( clientId ) );\n\t\t\tconst hasLightBlockWrapper = blockType?.apiVersion > 1;\n\n\t\t\tif ( ! hasLightBlockWrapper ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn attributes.className;\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,uBAAuBA,CAAEC,QAAQ,EAAG;EACnD;EACA;EACA;EACA,OAAO,IAAAC,eAAS,EACbC,MAAM,IAAM;IACb,MAAM;MAAEC,YAAY;MAAEC;IAAmB,CAAC,GACzCF,MAAM,CAAEG,YAAiB,CAAC;IAC3B,MAAMC,UAAU,GAAGF,kBAAkB,CAAEJ,QAAS,CAAC;IAEjD,IAAK,CAAEM,UAAU,EAAEC,SAAS,EAAG;MAC9B;IACD;IAEA,MAAMC,SAAS,GAAG,IAAAC,oBAAY,EAAEN,YAAY,CAAEH,QAAS,CAAE,CAAC;IAC1D,MAAMU,oBAAoB,GAAGF,SAAS,EAAEG,UAAU,GAAG,CAAC;IAEtD,IAAK,CAAED,oBAAoB,EAAG;MAC7B;IACD;IAEA,OAAOJ,UAAU,CAACC,SAAS;EAC5B,CAAC,EACD,CAAEP,QAAQ,CACX,CAAC;AACF"}
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useBlockDefaultClassName = useBlockDefaultClassName;
7
- var _data = require("@wordpress/data");
8
- var _blocks = require("@wordpress/blocks");
9
- var _store = require("../../../store");
10
- /**
11
- * WordPress dependencies
12
- */
13
-
14
- /**
15
- * Internal dependencies
16
- */
17
-
18
- /**
19
- * Returns the default class name if the block is a light block and it supports
20
- * `className`.
21
- *
22
- * @param {string} clientId The block client ID.
23
- *
24
- * @return {string} The class name, e.g. `wp-block-paragraph`.
25
- */
26
- function useBlockDefaultClassName(clientId) {
27
- return (0, _data.useSelect)(select => {
28
- const name = select(_store.store).getBlockName(clientId);
29
- const blockType = (0, _blocks.getBlockType)(name);
30
- const hasLightBlockWrapper = blockType?.apiVersion > 1;
31
- if (!hasLightBlockWrapper) {
32
- return;
33
- }
34
- return (0, _blocks.getBlockDefaultClassName)(name);
35
- }, [clientId]);
36
- }
37
- //# sourceMappingURL=use-block-default-class-name.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_data","require","_blocks","_store","useBlockDefaultClassName","clientId","useSelect","select","name","blockEditorStore","getBlockName","blockType","getBlockType","hasLightBlockWrapper","apiVersion","getBlockDefaultClassName"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-block-default-class-name.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { getBlockType, getBlockDefaultClassName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * Returns the default class name if the block is a light block and it supports\n * `className`.\n *\n * @param {string} clientId The block client ID.\n *\n * @return {string} The class name, e.g. `wp-block-paragraph`.\n */\nexport function useBlockDefaultClassName( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst name = select( blockEditorStore ).getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( name );\n\t\t\tconst hasLightBlockWrapper = blockType?.apiVersion > 1;\n\n\t\t\tif ( ! hasLightBlockWrapper ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn getBlockDefaultClassName( name );\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,wBAAwBA,CAAEC,QAAQ,EAAG;EACpD,OAAO,IAAAC,eAAS,EACbC,MAAM,IAAM;IACb,MAAMC,IAAI,GAAGD,MAAM,CAAEE,YAAiB,CAAC,CAACC,YAAY,CAAEL,QAAS,CAAC;IAChE,MAAMM,SAAS,GAAG,IAAAC,oBAAY,EAAEJ,IAAK,CAAC;IACtC,MAAMK,oBAAoB,GAAGF,SAAS,EAAEG,UAAU,GAAG,CAAC;IAEtD,IAAK,CAAED,oBAAoB,EAAG;MAC7B;IACD;IAEA,OAAO,IAAAE,gCAAwB,EAAEP,IAAK,CAAC;EACxC,CAAC,EACD,CAAEH,QAAQ,CACX,CAAC;AACF"}