@wordpress/block-editor 12.15.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 (500) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +9 -4
  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 +14 -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-patterns-list/index.js +1 -1
  28. package/build/components/block-patterns-list/index.js.map +1 -1
  29. package/build/components/block-removal-warning-modal/index.js +2 -9
  30. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  31. package/build/components/block-rename/modal.js +3 -0
  32. package/build/components/block-rename/modal.js.map +1 -1
  33. package/build/components/block-settings/container.native.js +6 -4
  34. package/build/components/block-settings/container.native.js.map +1 -1
  35. package/build/components/block-styles/index.js +1 -1
  36. package/build/components/block-styles/index.js.map +1 -1
  37. package/build/components/block-styles/index.native.js +3 -2
  38. package/build/components/block-styles/index.native.js.map +1 -1
  39. package/build/components/block-toolbar/index.js +89 -27
  40. package/build/components/block-toolbar/index.js.map +1 -1
  41. package/build/components/block-tools/block-toolbar-breadcrumb.js +49 -0
  42. package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
  43. package/build/components/block-tools/block-toolbar-popover.js +86 -0
  44. package/build/components/block-tools/block-toolbar-popover.js.map +1 -0
  45. package/build/components/block-tools/index.js +27 -24
  46. package/build/components/block-tools/index.js.map +1 -1
  47. package/build/components/block-types-list/index.native.js +4 -3
  48. package/build/components/block-types-list/index.native.js.map +1 -1
  49. package/build/components/block-variation-picker/index.native.js +2 -1
  50. package/build/components/block-variation-picker/index.native.js.map +1 -1
  51. package/build/components/colors-gradients/control.js +28 -17
  52. package/build/components/colors-gradients/control.js.map +1 -1
  53. package/build/components/duotone-control/index.js +1 -4
  54. package/build/components/duotone-control/index.js.map +1 -1
  55. package/build/components/global-styles/color-panel.js +22 -20
  56. package/build/components/global-styles/color-panel.js.map +1 -1
  57. package/build/components/global-styles/filters-panel.js +9 -3
  58. package/build/components/global-styles/filters-panel.js.map +1 -1
  59. package/build/components/global-styles/typography-panel.js +20 -31
  60. package/build/components/global-styles/typography-panel.js.map +1 -1
  61. package/build/components/image-link-destinations/index.native.js +118 -0
  62. package/build/components/image-link-destinations/index.native.js.map +1 -0
  63. package/build/components/index.native.js +8 -0
  64. package/build/components/index.native.js.map +1 -1
  65. package/build/components/inserter/media-tab/media-panel.js +2 -2
  66. package/build/components/inserter/media-tab/media-panel.js.map +1 -1
  67. package/build/components/inserter/menu.js +14 -7
  68. package/build/components/inserter/menu.js.map +1 -1
  69. package/build/components/inserter/preview-panel.js +2 -2
  70. package/build/components/inserter/preview-panel.js.map +1 -1
  71. package/build/components/inserter-button/index.native.js +98 -0
  72. package/build/components/inserter-button/index.native.js.map +1 -0
  73. package/build/components/inserter-button/sparkles.js +23 -0
  74. package/build/components/inserter-button/sparkles.js.map +1 -0
  75. package/build/components/inserter-draggable-blocks/index.js +8 -4
  76. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  77. package/build/components/inspector-controls/fill.js +3 -3
  78. package/build/components/inspector-controls/fill.js.map +1 -1
  79. package/build/components/inspector-controls/fill.native.js +3 -3
  80. package/build/components/inspector-controls/fill.native.js.map +1 -1
  81. package/build/components/navigable-toolbar/index.js +2 -2
  82. package/build/components/navigable-toolbar/index.js.map +1 -1
  83. package/build/components/preview-options/index.js +6 -62
  84. package/build/components/preview-options/index.js.map +1 -1
  85. package/build/components/rich-text/content.js +26 -23
  86. package/build/components/rich-text/content.js.map +1 -1
  87. package/build/components/rich-text/get-rich-text-values.js +2 -1
  88. package/build/components/rich-text/get-rich-text-values.js.map +1 -1
  89. package/build/components/rich-text/index.js +2 -30
  90. package/build/components/rich-text/index.js.map +1 -1
  91. package/build/components/rich-text/index.native.js +9 -16
  92. package/build/components/rich-text/index.native.js.map +1 -1
  93. package/build/components/rich-text/native/get-format-colors.native.js +22 -24
  94. package/build/components/rich-text/native/get-format-colors.native.js.map +1 -1
  95. package/build/components/rich-text/native/index.native.js +7 -34
  96. package/build/components/rich-text/native/index.native.js.map +1 -1
  97. package/build/components/rich-text/use-input-rules.js +5 -1
  98. package/build/components/rich-text/use-input-rules.js.map +1 -1
  99. package/build/components/rich-text/with-deprecations.js +50 -0
  100. package/build/components/rich-text/with-deprecations.js.map +1 -0
  101. package/build/components/use-block-drop-zone/index.js +70 -8
  102. package/build/components/use-block-drop-zone/index.js.map +1 -1
  103. package/build/components/use-on-block-drop/index.js +1 -1
  104. package/build/components/use-on-block-drop/index.js.map +1 -1
  105. package/build/components/use-resize-canvas/index.js +4 -1
  106. package/build/components/use-resize-canvas/index.js.map +1 -1
  107. package/build/components/use-settings/index.js +14 -0
  108. package/build/components/use-settings/index.js.map +1 -1
  109. package/build/hooks/align.js +20 -68
  110. package/build/hooks/align.js.map +1 -1
  111. package/build/hooks/align.native.js +11 -1
  112. package/build/hooks/align.native.js.map +1 -1
  113. package/build/hooks/anchor.js +13 -29
  114. package/build/hooks/anchor.js.map +1 -1
  115. package/build/hooks/background.js +28 -31
  116. package/build/hooks/background.js.map +1 -1
  117. package/build/hooks/block-hooks.js +24 -32
  118. package/build/hooks/block-hooks.js.map +1 -1
  119. package/build/hooks/block-renaming.js +18 -22
  120. package/build/hooks/block-renaming.js.map +1 -1
  121. package/build/hooks/border.js +58 -80
  122. package/build/hooks/border.js.map +1 -1
  123. package/build/hooks/color.js +76 -89
  124. package/build/hooks/color.js.map +1 -1
  125. package/build/hooks/content-lock-ui.js +29 -29
  126. package/build/hooks/content-lock-ui.js.map +1 -1
  127. package/build/hooks/custom-class-name.js +12 -29
  128. package/build/hooks/custom-class-name.js.map +1 -1
  129. package/build/hooks/custom-fields.js +24 -38
  130. package/build/hooks/custom-fields.js.map +1 -1
  131. package/build/hooks/dimensions.js +21 -17
  132. package/build/hooks/dimensions.js.map +1 -1
  133. package/build/hooks/duotone.js +31 -61
  134. package/build/hooks/duotone.js.map +1 -1
  135. package/build/hooks/font-family.js +16 -25
  136. package/build/hooks/font-family.js.map +1 -1
  137. package/build/hooks/font-size.js +51 -119
  138. package/build/hooks/font-size.js.map +1 -1
  139. package/build/hooks/index.js +25 -14
  140. package/build/hooks/index.js.map +1 -1
  141. package/build/hooks/index.native.js +10 -3
  142. package/build/hooks/index.native.js.map +1 -1
  143. package/build/hooks/layout-child.js +68 -0
  144. package/build/hooks/layout-child.js.map +1 -0
  145. package/build/hooks/layout.js +16 -101
  146. package/build/hooks/layout.js.map +1 -1
  147. package/build/hooks/padding.js +2 -2
  148. package/build/hooks/padding.js.map +1 -1
  149. package/build/hooks/position.js +40 -62
  150. package/build/hooks/position.js.map +1 -1
  151. package/build/hooks/style.js +51 -88
  152. package/build/hooks/style.js.map +1 -1
  153. package/build/hooks/typography.js +34 -14
  154. package/build/hooks/typography.js.map +1 -1
  155. package/build/hooks/utils.js +154 -7
  156. package/build/hooks/utils.js.map +1 -1
  157. package/build/private-apis.js +0 -2
  158. package/build/private-apis.js.map +1 -1
  159. package/build/store/private-actions.js +8 -0
  160. package/build/store/private-actions.js.map +1 -1
  161. package/build/store/private-selectors.js +34 -0
  162. package/build/store/private-selectors.js.map +1 -1
  163. package/build/store/reducer.js +8 -0
  164. package/build/store/reducer.js.map +1 -1
  165. package/build/store/selectors.js +10 -60
  166. package/build/store/selectors.js.map +1 -1
  167. package/build/store/utils.js +66 -0
  168. package/build/store/utils.js.map +1 -0
  169. package/build/utils/object.js +21 -61
  170. package/build/utils/object.js.map +1 -1
  171. package/build/utils/selection.js +9 -1
  172. package/build/utils/selection.js.map +1 -1
  173. package/build-module/components/block-canvas/index.js +23 -7
  174. package/build-module/components/block-canvas/index.js.map +1 -1
  175. package/build-module/components/block-card/index.js +1 -1
  176. package/build-module/components/block-card/index.js.map +1 -1
  177. package/build-module/components/block-controls/hook.js +4 -24
  178. package/build-module/components/block-controls/hook.js.map +1 -1
  179. package/build-module/components/block-edit/context.js +2 -0
  180. package/build-module/components/block-edit/context.js.map +1 -1
  181. package/build-module/components/block-edit/index.js +19 -10
  182. package/build-module/components/block-edit/index.js.map +1 -1
  183. package/build-module/components/block-info-slot-fill/index.js +3 -3
  184. package/build-module/components/block-info-slot-fill/index.js.map +1 -1
  185. package/build-module/components/block-list/block.js +29 -10
  186. package/build-module/components/block-list/block.js.map +1 -1
  187. package/build-module/components/block-list/block.native.js +14 -5
  188. package/build-module/components/block-list/block.native.js.map +1 -1
  189. package/build-module/components/block-list/use-block-props/index.js +62 -19
  190. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  191. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +4 -29
  192. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  193. package/build-module/components/block-list/use-block-props/use-is-hovered.js +4 -14
  194. package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
  195. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
  196. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  197. package/build-module/components/block-patterns-list/index.js +1 -1
  198. package/build-module/components/block-patterns-list/index.js.map +1 -1
  199. package/build-module/components/block-removal-warning-modal/index.js +3 -10
  200. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  201. package/build-module/components/block-rename/modal.js +3 -0
  202. package/build-module/components/block-rename/modal.js.map +1 -1
  203. package/build-module/components/block-settings/container.native.js +4 -2
  204. package/build-module/components/block-settings/container.native.js.map +1 -1
  205. package/build-module/components/block-styles/index.js +1 -1
  206. package/build-module/components/block-styles/index.js.map +1 -1
  207. package/build-module/components/block-styles/index.native.js +3 -2
  208. package/build-module/components/block-styles/index.native.js.map +1 -1
  209. package/build-module/components/block-toolbar/index.js +88 -25
  210. package/build-module/components/block-toolbar/index.js.map +1 -1
  211. package/build-module/components/block-tools/block-toolbar-breadcrumb.js +41 -0
  212. package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
  213. package/build-module/components/block-tools/block-toolbar-popover.js +76 -0
  214. package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -0
  215. package/build-module/components/block-tools/index.js +27 -24
  216. package/build-module/components/block-tools/index.js.map +1 -1
  217. package/build-module/components/block-types-list/index.native.js +2 -1
  218. package/build-module/components/block-types-list/index.native.js.map +1 -1
  219. package/build-module/components/block-variation-picker/index.native.js +2 -1
  220. package/build-module/components/block-variation-picker/index.native.js.map +1 -1
  221. package/build-module/components/colors-gradients/control.js +29 -18
  222. package/build-module/components/colors-gradients/control.js.map +1 -1
  223. package/build-module/components/duotone-control/index.js +1 -4
  224. package/build-module/components/duotone-control/index.js.map +1 -1
  225. package/build-module/components/global-styles/color-panel.js +23 -21
  226. package/build-module/components/global-styles/color-panel.js.map +1 -1
  227. package/build-module/components/global-styles/filters-panel.js +10 -4
  228. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  229. package/build-module/components/global-styles/typography-panel.js +20 -31
  230. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  231. package/build-module/components/image-link-destinations/index.native.js +109 -0
  232. package/build-module/components/image-link-destinations/index.native.js.map +1 -0
  233. package/build-module/components/index.native.js +1 -0
  234. package/build-module/components/index.native.js.map +1 -1
  235. package/build-module/components/inserter/media-tab/media-panel.js +1 -1
  236. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
  237. package/build-module/components/inserter/menu.js +14 -7
  238. package/build-module/components/inserter/menu.js.map +1 -1
  239. package/build-module/components/inserter/preview-panel.js +2 -2
  240. package/build-module/components/inserter/preview-panel.js.map +1 -1
  241. package/build-module/components/inserter-button/index.native.js +89 -0
  242. package/build-module/components/inserter-button/index.native.js.map +1 -0
  243. package/build-module/components/inserter-button/sparkles.js +15 -0
  244. package/build-module/components/inserter-button/sparkles.js.map +1 -0
  245. package/build-module/components/inserter-draggable-blocks/index.js +9 -5
  246. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  247. package/build-module/components/inspector-controls/fill.js +3 -3
  248. package/build-module/components/inspector-controls/fill.js.map +1 -1
  249. package/build-module/components/inspector-controls/fill.native.js +3 -3
  250. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  251. package/build-module/components/navigable-toolbar/index.js +2 -2
  252. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  253. package/build-module/components/preview-options/index.js +6 -62
  254. package/build-module/components/preview-options/index.js.map +1 -1
  255. package/build-module/components/rich-text/content.js +25 -21
  256. package/build-module/components/rich-text/content.js.map +1 -1
  257. package/build-module/components/rich-text/get-rich-text-values.js +2 -1
  258. package/build-module/components/rich-text/get-rich-text-values.js.map +1 -1
  259. package/build-module/components/rich-text/index.js +4 -32
  260. package/build-module/components/rich-text/index.js.map +1 -1
  261. package/build-module/components/rich-text/index.native.js +10 -18
  262. package/build-module/components/rich-text/index.native.js.map +1 -1
  263. package/build-module/components/rich-text/native/get-format-colors.native.js +22 -24
  264. package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -1
  265. package/build-module/components/rich-text/native/index.native.js +7 -34
  266. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  267. package/build-module/components/rich-text/use-input-rules.js +5 -1
  268. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  269. package/build-module/components/rich-text/with-deprecations.js +42 -0
  270. package/build-module/components/rich-text/with-deprecations.js.map +1 -0
  271. package/build-module/components/use-block-drop-zone/index.js +69 -8
  272. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  273. package/build-module/components/use-on-block-drop/index.js +1 -1
  274. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  275. package/build-module/components/use-resize-canvas/index.js +4 -1
  276. package/build-module/components/use-resize-canvas/index.js.map +1 -1
  277. package/build-module/components/use-settings/index.js +13 -1
  278. package/build-module/components/use-settings/index.js.map +1 -1
  279. package/build-module/hooks/align.js +19 -66
  280. package/build-module/hooks/align.js.map +1 -1
  281. package/build-module/hooks/align.native.js +1 -0
  282. package/build-module/hooks/align.native.js.map +1 -1
  283. package/build-module/hooks/anchor.js +11 -26
  284. package/build-module/hooks/anchor.js.map +1 -1
  285. package/build-module/hooks/background.js +26 -28
  286. package/build-module/hooks/background.js.map +1 -1
  287. package/build-module/hooks/block-hooks.js +22 -30
  288. package/build-module/hooks/block-hooks.js.map +1 -1
  289. package/build-module/hooks/block-renaming.js +17 -21
  290. package/build-module/hooks/block-renaming.js.map +1 -1
  291. package/build-module/hooks/border.js +57 -78
  292. package/build-module/hooks/border.js.map +1 -1
  293. package/build-module/hooks/color.js +74 -86
  294. package/build-module/hooks/color.js.map +1 -1
  295. package/build-module/hooks/content-lock-ui.js +27 -27
  296. package/build-module/hooks/content-lock-ui.js.map +1 -1
  297. package/build-module/hooks/custom-class-name.js +11 -27
  298. package/build-module/hooks/custom-class-name.js.map +1 -1
  299. package/build-module/hooks/custom-fields.js +20 -39
  300. package/build-module/hooks/custom-fields.js.map +1 -1
  301. package/build-module/hooks/dimensions.js +21 -16
  302. package/build-module/hooks/dimensions.js.map +1 -1
  303. package/build-module/hooks/duotone.js +30 -61
  304. package/build-module/hooks/duotone.js.map +1 -1
  305. package/build-module/hooks/font-family.js +14 -23
  306. package/build-module/hooks/font-family.js.map +1 -1
  307. package/build-module/hooks/font-size.js +49 -119
  308. package/build-module/hooks/font-size.js.map +1 -1
  309. package/build-module/hooks/index.js +18 -14
  310. package/build-module/hooks/index.js.map +1 -1
  311. package/build-module/hooks/index.native.js +5 -3
  312. package/build-module/hooks/index.native.js.map +1 -1
  313. package/build-module/hooks/layout-child.js +60 -0
  314. package/build-module/hooks/layout-child.js.map +1 -0
  315. package/build-module/hooks/layout.js +13 -98
  316. package/build-module/hooks/layout.js.map +1 -1
  317. package/build-module/hooks/padding.js +2 -2
  318. package/build-module/hooks/padding.js.map +1 -1
  319. package/build-module/hooks/position.js +38 -59
  320. package/build-module/hooks/position.js.map +1 -1
  321. package/build-module/hooks/style.js +51 -84
  322. package/build-module/hooks/style.js.map +1 -1
  323. package/build-module/hooks/typography.js +33 -12
  324. package/build-module/hooks/typography.js.map +1 -1
  325. package/build-module/hooks/utils.js +149 -6
  326. package/build-module/hooks/utils.js.map +1 -1
  327. package/build-module/private-apis.js +0 -2
  328. package/build-module/private-apis.js.map +1 -1
  329. package/build-module/store/private-actions.js +7 -0
  330. package/build-module/store/private-actions.js.map +1 -1
  331. package/build-module/store/private-selectors.js +33 -1
  332. package/build-module/store/private-selectors.js.map +1 -1
  333. package/build-module/store/reducer.js +8 -0
  334. package/build-module/store/reducer.js.map +1 -1
  335. package/build-module/store/selectors.js +3 -53
  336. package/build-module/store/selectors.js.map +1 -1
  337. package/build-module/store/utils.js +56 -0
  338. package/build-module/store/utils.js.map +1 -0
  339. package/build-module/utils/object.js +21 -60
  340. package/build-module/utils/object.js.map +1 -1
  341. package/build-module/utils/selection.js +9 -1
  342. package/build-module/utils/selection.js.map +1 -1
  343. package/build-style/style-rtl.css +113 -293
  344. package/build-style/style.css +113 -293
  345. package/package.json +31 -31
  346. package/src/components/block-canvas/index.js +31 -17
  347. package/src/components/block-caption/README.md +2 -2
  348. package/src/components/block-card/index.js +5 -3
  349. package/src/components/block-card/style.scss +7 -3
  350. package/src/components/block-controls/hook.js +8 -30
  351. package/src/components/block-controls/test/index.js +3 -3
  352. package/src/components/block-edit/context.js +3 -0
  353. package/src/components/block-edit/index.js +36 -10
  354. package/src/components/block-info-slot-fill/index.js +6 -3
  355. package/src/components/block-inspector/style.scss +0 -4
  356. package/src/components/block-list/block.js +39 -5
  357. package/src/components/block-list/block.native.js +18 -4
  358. package/src/components/block-list/use-block-props/index.js +74 -21
  359. package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -34
  360. package/src/components/block-list/use-block-props/use-is-hovered.js +2 -13
  361. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +1 -5
  362. package/src/components/block-patterns-list/index.js +1 -1
  363. package/src/components/block-removal-warning-modal/index.js +7 -14
  364. package/src/components/block-rename/modal.js +7 -1
  365. package/src/components/block-settings/container.native.js +3 -5
  366. package/src/components/block-styles/index.js +1 -1
  367. package/src/components/block-styles/index.native.js +4 -2
  368. package/src/components/block-styles/style.scss +0 -11
  369. package/src/components/block-switcher/test/__snapshots__/index.js.snap +3 -1
  370. package/src/components/block-toolbar/index.js +180 -95
  371. package/src/components/block-toolbar/style.scss +50 -66
  372. package/src/components/block-tools/block-toolbar-breadcrumb.js +46 -0
  373. package/src/components/block-tools/block-toolbar-popover.js +90 -0
  374. package/src/components/block-tools/index.js +42 -29
  375. package/src/components/block-tools/style.scss +60 -172
  376. package/src/components/block-types-list/index.native.js +2 -1
  377. package/src/components/block-variation-picker/index.native.js +1 -1
  378. package/src/components/colors-gradients/control.js +49 -30
  379. package/src/components/colors-gradients/style.scss +0 -7
  380. package/src/components/duotone-control/index.js +2 -5
  381. package/src/components/duotone-control/style.scss +1 -6
  382. package/src/components/global-styles/color-panel.js +34 -25
  383. package/src/components/global-styles/filters-panel.js +8 -4
  384. package/src/components/global-styles/typography-panel.js +23 -43
  385. package/src/components/image-link-destinations/index.native.js +152 -0
  386. package/src/components/image-link-destinations/style.native.scss +16 -0
  387. package/src/components/index.native.js +1 -0
  388. package/src/components/inner-blocks/README.md +13 -2
  389. package/src/components/inserter/media-tab/media-panel.js +1 -1
  390. package/src/components/inserter/menu.js +16 -8
  391. package/src/components/inserter/preview-panel.js +2 -2
  392. package/src/components/inserter/style.scss +15 -17
  393. package/src/components/inserter-button/README.md +62 -0
  394. package/src/components/inserter-button/index.native.js +116 -0
  395. package/src/components/inserter-button/sparkles.js +15 -0
  396. package/src/components/inserter-button/style.native.scss +72 -0
  397. package/src/components/inserter-draggable-blocks/index.js +18 -5
  398. package/src/components/inspector-controls/fill.js +6 -3
  399. package/src/components/inspector-controls/fill.native.js +6 -3
  400. package/src/components/link-control/style.scss +1 -1
  401. package/src/components/link-control/test/index.js +1 -1
  402. package/src/components/navigable-toolbar/README.md +2 -0
  403. package/src/components/navigable-toolbar/index.js +2 -2
  404. package/src/components/preview-options/index.js +6 -86
  405. package/src/components/rich-text/content.js +27 -20
  406. package/src/components/rich-text/get-rich-text-values.js +6 -1
  407. package/src/components/rich-text/index.js +5 -46
  408. package/src/components/rich-text/index.native.js +8 -25
  409. package/src/components/rich-text/native/get-format-colors.native.js +33 -40
  410. package/src/components/rich-text/native/index.native.js +7 -48
  411. package/src/components/rich-text/use-input-rules.js +6 -1
  412. package/src/components/rich-text/with-deprecations.js +51 -0
  413. package/src/components/use-block-drop-zone/index.js +114 -14
  414. package/src/components/use-on-block-drop/index.js +2 -1
  415. package/src/components/use-resize-canvas/README.md +3 -3
  416. package/src/components/use-resize-canvas/index.js +4 -1
  417. package/src/components/use-settings/index.js +15 -1
  418. package/src/hooks/align.js +15 -76
  419. package/src/hooks/align.native.js +1 -0
  420. package/src/hooks/anchor.js +13 -33
  421. package/src/hooks/background.js +28 -23
  422. package/src/hooks/block-hooks.js +22 -51
  423. package/src/hooks/block-renaming.js +23 -37
  424. package/src/hooks/border.js +67 -118
  425. package/src/hooks/color.js +100 -132
  426. package/src/hooks/content-lock-ui.js +110 -122
  427. package/src/hooks/custom-class-name.js +8 -40
  428. package/src/hooks/custom-fields.js +20 -47
  429. package/src/hooks/dimensions.js +20 -16
  430. package/src/hooks/duotone.js +70 -127
  431. package/src/hooks/font-family.js +10 -29
  432. package/src/hooks/font-size.js +66 -162
  433. package/src/hooks/index.js +42 -14
  434. package/src/hooks/index.native.js +6 -3
  435. package/src/hooks/layout-child.js +53 -0
  436. package/src/hooks/layout.js +13 -102
  437. package/src/hooks/padding.js +2 -2
  438. package/src/hooks/position.js +50 -90
  439. package/src/hooks/style.js +117 -187
  440. package/src/hooks/test/align.js +1 -178
  441. package/src/hooks/typography.js +20 -16
  442. package/src/hooks/utils.js +187 -6
  443. package/src/private-apis.js +0 -2
  444. package/src/store/private-actions.js +8 -0
  445. package/src/store/private-selectors.js +45 -0
  446. package/src/store/reducer.js +8 -0
  447. package/src/store/selectors.js +5 -69
  448. package/src/store/utils.js +74 -0
  449. package/src/style.scss +0 -2
  450. package/src/utils/object.js +18 -69
  451. package/src/utils/selection.js +9 -2
  452. package/build/components/block-list/use-block-props/use-block-class-names.js +0 -67
  453. package/build/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
  454. package/build/components/block-list/use-block-props/use-block-custom-class-name.js +0 -46
  455. package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
  456. package/build/components/block-list/use-block-props/use-block-default-class-name.js +0 -37
  457. package/build/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
  458. package/build/components/block-tools/back-compat.js +0 -45
  459. package/build/components/block-tools/back-compat.js.map +0 -1
  460. package/build/components/block-tools/block-contextual-toolbar.js +0 -91
  461. package/build/components/block-tools/block-contextual-toolbar.js.map +0 -1
  462. package/build/components/block-tools/selected-block-tools.js +0 -113
  463. package/build/components/block-tools/selected-block-tools.js.map +0 -1
  464. package/build/components/inserter/hooks/use-debounced-input.js +0 -22
  465. package/build/components/inserter/hooks/use-debounced-input.js.map +0 -1
  466. package/build/components/use-display-block-controls/index.js +0 -39
  467. package/build/components/use-display-block-controls/index.js.map +0 -1
  468. package/build/components/use-display-block-controls/index.native.js +0 -39
  469. package/build/components/use-display-block-controls/index.native.js.map +0 -1
  470. package/build-module/components/block-list/use-block-props/use-block-class-names.js +0 -60
  471. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
  472. package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js +0 -40
  473. package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
  474. package/build-module/components/block-list/use-block-props/use-block-default-class-name.js +0 -31
  475. package/build-module/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
  476. package/build-module/components/block-tools/back-compat.js +0 -35
  477. package/build-module/components/block-tools/back-compat.js.map +0 -1
  478. package/build-module/components/block-tools/block-contextual-toolbar.js +0 -83
  479. package/build-module/components/block-tools/block-contextual-toolbar.js.map +0 -1
  480. package/build-module/components/block-tools/selected-block-tools.js +0 -105
  481. package/build-module/components/block-tools/selected-block-tools.js.map +0 -1
  482. package/build-module/components/inserter/hooks/use-debounced-input.js +0 -15
  483. package/build-module/components/inserter/hooks/use-debounced-input.js.map +0 -1
  484. package/build-module/components/use-display-block-controls/index.js +0 -32
  485. package/build-module/components/use-display-block-controls/index.js.map +0 -1
  486. package/build-module/components/use-display-block-controls/index.native.js +0 -32
  487. package/build-module/components/use-display-block-controls/index.native.js.map +0 -1
  488. package/src/components/block-list/use-block-props/use-block-class-names.js +0 -66
  489. package/src/components/block-list/use-block-props/use-block-custom-class-name.js +0 -44
  490. package/src/components/block-list/use-block-props/use-block-default-class-name.js +0 -35
  491. package/src/components/block-parent-selector/style.scss +0 -11
  492. package/src/components/block-tools/back-compat.js +0 -35
  493. package/src/components/block-tools/block-contextual-toolbar.js +0 -100
  494. package/src/components/block-tools/selected-block-tools.js +0 -127
  495. package/src/components/inserter/hooks/use-debounced-input.js +0 -18
  496. package/src/components/preview-options/README.md +0 -94
  497. package/src/components/preview-options/style.scss +0 -64
  498. package/src/components/use-display-block-controls/index.js +0 -36
  499. package/src/components/use-display-block-controls/index.native.js +0 -37
  500. package/src/hooks/test/color.js +0 -112
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.checkAllowListRecursive = exports.checkAllowList = void 0;
7
+ exports.getUserPatterns = getUserPatterns;
8
+ var _utils = require("../components/inserter/block-patterns-tab/utils");
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+
13
+ const EMPTY_ARRAY = [];
14
+ function getUserPatterns(state) {
15
+ var _state$settings$__exp, _state$settings$__exp2;
16
+ const userPatterns = (_state$settings$__exp = state?.settings?.__experimentalReusableBlocks) !== null && _state$settings$__exp !== void 0 ? _state$settings$__exp : EMPTY_ARRAY;
17
+ const userPatternCategories = (_state$settings$__exp2 = state?.settings?.__experimentalUserPatternCategories) !== null && _state$settings$__exp2 !== void 0 ? _state$settings$__exp2 : [];
18
+ const categories = new Map();
19
+ userPatternCategories.forEach(userCategory => categories.set(userCategory.id, userCategory));
20
+ return userPatterns.map(userPattern => {
21
+ return {
22
+ name: `core/block/${userPattern.id}`,
23
+ id: userPattern.id,
24
+ type: _utils.PATTERN_TYPES.user,
25
+ title: userPattern.title.raw,
26
+ categories: userPattern.wp_pattern_category.map(catId => categories && categories.get(catId) ? categories.get(catId).slug : catId),
27
+ content: userPattern.content.raw,
28
+ syncStatus: userPattern.wp_pattern_sync_status
29
+ };
30
+ });
31
+ }
32
+ const checkAllowList = (list, item, defaultResult = null) => {
33
+ if (typeof list === 'boolean') {
34
+ return list;
35
+ }
36
+ if (Array.isArray(list)) {
37
+ // TODO: when there is a canonical way to detect that we are editing a post
38
+ // the following check should be changed to something like:
39
+ // if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )
40
+ if (list.includes('core/post-content') && item === null) {
41
+ return true;
42
+ }
43
+ return list.includes(item);
44
+ }
45
+ return defaultResult;
46
+ };
47
+ exports.checkAllowList = checkAllowList;
48
+ const checkAllowListRecursive = (blocks, allowedBlockTypes) => {
49
+ if (typeof allowedBlockTypes === 'boolean') {
50
+ return allowedBlockTypes;
51
+ }
52
+ const blocksQueue = [...blocks];
53
+ while (blocksQueue.length > 0) {
54
+ const block = blocksQueue.shift();
55
+ const isAllowed = checkAllowList(allowedBlockTypes, block.name || block.blockName, true);
56
+ if (!isAllowed) {
57
+ return false;
58
+ }
59
+ block.innerBlocks?.forEach(innerBlock => {
60
+ blocksQueue.push(innerBlock);
61
+ });
62
+ }
63
+ return true;
64
+ };
65
+ exports.checkAllowListRecursive = checkAllowListRecursive;
66
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_utils","require","EMPTY_ARRAY","getUserPatterns","state","_state$settings$__exp","_state$settings$__exp2","userPatterns","settings","__experimentalReusableBlocks","userPatternCategories","__experimentalUserPatternCategories","categories","Map","forEach","userCategory","set","id","map","userPattern","name","type","PATTERN_TYPES","user","title","raw","wp_pattern_category","catId","get","slug","content","syncStatus","wp_pattern_sync_status","checkAllowList","list","item","defaultResult","Array","isArray","includes","exports","checkAllowListRecursive","blocks","allowedBlockTypes","blocksQueue","length","block","shift","isAllowed","blockName","innerBlocks","innerBlock","push"],"sources":["@wordpress/block-editor/src/store/utils.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { PATTERN_TYPES } from '../components/inserter/block-patterns-tab/utils';\n\nconst EMPTY_ARRAY = [];\n\nexport function getUserPatterns( state ) {\n\tconst userPatterns =\n\t\tstate?.settings?.__experimentalReusableBlocks ?? EMPTY_ARRAY;\n\tconst userPatternCategories =\n\t\tstate?.settings?.__experimentalUserPatternCategories ?? [];\n\tconst categories = new Map();\n\tuserPatternCategories.forEach( ( userCategory ) =>\n\t\tcategories.set( userCategory.id, userCategory )\n\t);\n\treturn userPatterns.map( ( userPattern ) => {\n\t\treturn {\n\t\t\tname: `core/block/${ userPattern.id }`,\n\t\t\tid: userPattern.id,\n\t\t\ttype: PATTERN_TYPES.user,\n\t\t\ttitle: userPattern.title.raw,\n\t\t\tcategories: userPattern.wp_pattern_category.map( ( catId ) =>\n\t\t\t\tcategories && categories.get( catId )\n\t\t\t\t\t? categories.get( catId ).slug\n\t\t\t\t\t: catId\n\t\t\t),\n\t\t\tcontent: userPattern.content.raw,\n\t\t\tsyncStatus: userPattern.wp_pattern_sync_status,\n\t\t};\n\t} );\n}\n\nexport const checkAllowList = ( list, item, defaultResult = null ) => {\n\tif ( typeof list === 'boolean' ) {\n\t\treturn list;\n\t}\n\tif ( Array.isArray( list ) ) {\n\t\t// TODO: when there is a canonical way to detect that we are editing a post\n\t\t// the following check should be changed to something like:\n\t\t// if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )\n\t\tif ( list.includes( 'core/post-content' ) && item === null ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn list.includes( item );\n\t}\n\treturn defaultResult;\n};\n\nexport const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {\n\tif ( typeof allowedBlockTypes === 'boolean' ) {\n\t\treturn allowedBlockTypes;\n\t}\n\n\tconst blocksQueue = [ ...blocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\n\t\tconst isAllowed = checkAllowList(\n\t\t\tallowedBlockTypes,\n\t\t\tblock.name || block.blockName,\n\t\t\ttrue\n\t\t);\n\t\tif ( ! isAllowed ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\n\treturn true;\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,MAAMC,WAAW,GAAG,EAAE;AAEf,SAASC,eAAeA,CAAEC,KAAK,EAAG;EAAA,IAAAC,qBA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A,IAAI,CAACK,QAAQ,CAAE,mBAAoB,CAAC,IAAIJ,IAAI,KAAK,IAAI,EAAG;MAC5D,OAAO,IAAI;IACZ;IACA,OAAOD,IAAI,CAACK,QAAQ,CAAEJ,IAAK,CAAC;EAC7B;EACA,OAAOC,aAAa;AACrB,CAAC;AAACI,OAAA,CAAAP,cAAA,GAAAA,cAAA;AAEK,MAAMQ,uBAAuB,GAAGA,CAAEC,MAAM,EAAEC,iBAAiB,KAAM;EACvE,IAAK,OAAOA,iBAAiB,KAAK,SAAS,EAAG;IAC7C,OAAOA,iBAAiB;EACzB;EAEA,MAAMC,WAAW,GAAG,CAAE,GAAGF,MAAM,CAAE;EACjC,OAAQE,WAAW,CAACC,MAAM,GAAG,CAAC,EAAG;IAChC,MAAMC,KAAK,GAAGF,WAAW,CAACG,KAAK,CAAC,CAAC;IAEjC,MAAMC,SAAS,GAAGf,cAAc,CAC/BU,iBAAiB,EACjBG,KAAK,CAAC1B,IAAI,IAAI0B,KAAK,CAACG,SAAS,EAC7B,IACD,CAAC;IACD,IAAK,CAAED,SAAS,EAAG;MAClB,OAAO,KAAK;IACb;IAEAF,KAAK,CAACI,WAAW,EAAEpC,OAAO,CAAIqC,UAAU,IAAM;MAC7CP,WAAW,CAACQ,IAAI,CAAED,UAAW,CAAC;IAC/B,CAAE,CAAC;EACJ;EAEA,OAAO,IAAI;AACZ,CAAC;AAACX,OAAA,CAAAC,uBAAA,GAAAA,uBAAA"}
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
@@ -8,31 +7,10 @@ exports.getValueFromObjectPath = void 0;
8
7
  exports.kebabCase = kebabCase;
9
8
  exports.setImmutably = setImmutably;
10
9
  var _changeCase = require("change-case");
11
- var _memize = _interopRequireDefault(require("memize"));
12
10
  /**
13
11
  * External dependencies
14
12
  */
15
13
 
16
- /**
17
- * Converts a path to an array of its fragments.
18
- * Supports strings, numbers and arrays:
19
- *
20
- * 'foo' => [ 'foo' ]
21
- * 2 => [ '2' ]
22
- * [ 'foo', 'bar' ] => [ 'foo', 'bar' ]
23
- *
24
- * @param {string|number|Array} path Path
25
- * @return {Array} Normalized path.
26
- */
27
- function normalizePath(path) {
28
- if (Array.isArray(path)) {
29
- return path;
30
- } else if (typeof path === 'number') {
31
- return [path.toString()];
32
- }
33
- return [path];
34
- }
35
-
36
14
  /**
37
15
  * Converts any string to kebab case.
38
16
  * Backwards compatible with Lodash's `_.kebabCase()`.
@@ -65,26 +43,6 @@ function kebabCase(str) {
65
43
  });
66
44
  }
67
45
 
68
- /**
69
- * Clones an object.
70
- * Arrays are also cloned as arrays.
71
- * Non-object values are returned unchanged.
72
- *
73
- * @param {*} object Object to clone.
74
- * @return {*} Cloned object, or original literal non-object value.
75
- */
76
- function cloneObject(object) {
77
- if (Array.isArray(object)) {
78
- return object.map(cloneObject);
79
- }
80
- if (object && typeof object === 'object') {
81
- return {
82
- ...Object.fromEntries(Object.entries(object).map(([key, value]) => [key, cloneObject(value)]))
83
- };
84
- }
85
- return object;
86
- }
87
-
88
46
  /**
89
47
  * Immutably sets a value inside an object. Like `lodash#set`, but returning a
90
48
  * new object. Treats nullish initial values as empty objects. Clones any
@@ -96,24 +54,26 @@ function cloneObject(object) {
96
54
  * @return {Object} Cloned object with the new value set.
97
55
  */
98
56
  function setImmutably(object, path, value) {
99
- const normalizedPath = normalizePath(path);
100
- const newObject = object ? cloneObject(object) : {};
101
- normalizedPath.reduce((acc, key, i) => {
102
- if (acc[key] === undefined) {
103
- if (Number.isInteger(path[i + 1])) {
104
- acc[key] = [];
105
- } else {
106
- acc[key] = {};
107
- }
108
- }
109
- if (i === normalizedPath.length - 1) {
110
- acc[key] = value;
111
- }
112
- return acc[key];
113
- }, newObject);
114
- return newObject;
57
+ // Normalize path
58
+ path = Array.isArray(path) ? [...path] : [path];
59
+
60
+ // Shallowly clone the base of the object
61
+ object = Array.isArray(object) ? [...object] : {
62
+ ...object
63
+ };
64
+ const leaf = path.pop();
65
+
66
+ // Traverse object from root to leaf, shallowly cloning at each level
67
+ let prev = object;
68
+ for (const key of path) {
69
+ const lvl = prev[key];
70
+ prev = prev[key] = Array.isArray(lvl) ? [...lvl] : {
71
+ ...lvl
72
+ };
73
+ }
74
+ prev[leaf] = value;
75
+ return object;
115
76
  }
116
- const stringToPath = (0, _memize.default)(path => path.split('.'));
117
77
 
118
78
  /**
119
79
  * Helper util to return a value from a certain path of the object.
@@ -129,9 +89,9 @@ const stringToPath = (0, _memize.default)(path => path.split('.'));
129
89
  */
130
90
  const getValueFromObjectPath = (object, path, defaultValue) => {
131
91
  var _value;
132
- const normalizedPath = Array.isArray(path) ? path : stringToPath(path);
92
+ const arrayPath = Array.isArray(path) ? path : path.split('.');
133
93
  let value = object;
134
- normalizedPath.forEach(fieldName => {
94
+ arrayPath.forEach(fieldName => {
135
95
  value = value?.[fieldName];
136
96
  });
137
97
  return (_value = value) !== null && _value !== void 0 ? _value : defaultValue;
@@ -1 +1 @@
1
- {"version":3,"names":["_changeCase","require","_memize","_interopRequireDefault","normalizePath","path","Array","isArray","toString","kebabCase","str","input","_str$toString","replace","paramCase","splitRegexp","cloneObject","object","map","Object","fromEntries","entries","key","value","setImmutably","normalizedPath","newObject","reduce","acc","i","undefined","Number","isInteger","length","stringToPath","memoize","split","getValueFromObjectPath","defaultValue","_value","forEach","fieldName","exports"],"sources":["@wordpress/block-editor/src/utils/object.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase } from 'change-case';\nimport memoize from 'memize';\n\n/**\n * Converts a path to an array of its fragments.\n * Supports strings, numbers and arrays:\n *\n * 'foo' => [ 'foo' ]\n * 2 => [ '2' ]\n * [ 'foo', 'bar' ] => [ 'foo', 'bar' ]\n *\n * @param {string|number|Array} path Path\n * @return {Array} Normalized path.\n */\nfunction normalizePath( path ) {\n\tif ( Array.isArray( path ) ) {\n\t\treturn path;\n\t} else if ( typeof path === 'number' ) {\n\t\treturn [ path.toString() ];\n\t}\n\n\treturn [ path ];\n}\n\n/**\n * Converts any string to kebab case.\n * Backwards compatible with Lodash's `_.kebabCase()`.\n * Backwards compatible with `_wp_to_kebab_case()`.\n *\n * @see https://lodash.com/docs/4.17.15#kebabCase\n * @see https://developer.wordpress.org/reference/functions/_wp_to_kebab_case/\n *\n * @param {string} str String to convert.\n * @return {string} Kebab-cased string\n */\nexport function kebabCase( str ) {\n\tlet input = str;\n\tif ( typeof str !== 'string' ) {\n\t\tinput = str?.toString?.() ?? '';\n\t}\n\n\t// See https://github.com/lodash/lodash/blob/b185fcee26b2133bd071f4aaca14b455c2ed1008/lodash.js#L4970\n\tinput = input.replace( /['\\u2019]/, '' );\n\n\treturn paramCase( input, {\n\t\tsplitRegexp: [\n\t\t\t/(?!(?:1ST|2ND|3RD|[4-9]TH)(?![a-z]))([a-z0-9])([A-Z])/g, // fooBar => foo-bar, 3Bar => 3-bar\n\t\t\t/(?!(?:1st|2nd|3rd|[4-9]th)(?![a-z]))([0-9])([a-z])/g, // 3bar => 3-bar\n\t\t\t/([A-Za-z])([0-9])/g, // Foo3 => foo-3, foo3 => foo-3\n\t\t\t/([A-Z])([A-Z][a-z])/g, // FOOBar => foo-bar\n\t\t],\n\t} );\n}\n\n/**\n * Clones an object.\n * Arrays are also cloned as arrays.\n * Non-object values are returned unchanged.\n *\n * @param {*} object Object to clone.\n * @return {*} Cloned object, or original literal non-object value.\n */\nfunction cloneObject( object ) {\n\tif ( Array.isArray( object ) ) {\n\t\treturn object.map( cloneObject );\n\t}\n\n\tif ( object && typeof object === 'object' ) {\n\t\treturn {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( object ).map( ( [ key, value ] ) => [\n\t\t\t\t\tkey,\n\t\t\t\t\tcloneObject( value ),\n\t\t\t\t] )\n\t\t\t),\n\t\t};\n\t}\n\n\treturn object;\n}\n\n/**\n * Immutably sets a value inside an object. Like `lodash#set`, but returning a\n * new object. Treats nullish initial values as empty objects. Clones any\n * nested objects. Supports arrays, too.\n *\n * @param {Object} object Object to set a value in.\n * @param {number|string|Array} path Path in the object to modify.\n * @param {*} value New value to set.\n * @return {Object} Cloned object with the new value set.\n */\nexport function setImmutably( object, path, value ) {\n\tconst normalizedPath = normalizePath( path );\n\tconst newObject = object ? cloneObject( object ) : {};\n\n\tnormalizedPath.reduce( ( acc, key, i ) => {\n\t\tif ( acc[ key ] === undefined ) {\n\t\t\tif ( Number.isInteger( path[ i + 1 ] ) ) {\n\t\t\t\tacc[ key ] = [];\n\t\t\t} else {\n\t\t\t\tacc[ key ] = {};\n\t\t\t}\n\t\t}\n\t\tif ( i === normalizedPath.length - 1 ) {\n\t\t\tacc[ key ] = value;\n\t\t}\n\t\treturn acc[ key ];\n\t}, newObject );\n\n\treturn newObject;\n}\n\nconst stringToPath = memoize( ( path ) => path.split( '.' ) );\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as either:\n * - a string of properties, separated by dots, for example: \"x.y\".\n * - an array of properties, for example `[ 'x', 'y' ]`.\n * You can also specify a default value in case the result is nullish.\n *\n * @param {Object} object Input object.\n * @param {string|Array} path Path to the object property.\n * @param {*} defaultValue Default value if the value at the specified path is nullish.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path, defaultValue ) => {\n\tconst normalizedPath = Array.isArray( path ) ? path : stringToPath( path );\n\tlet value = object;\n\tnormalizedPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value ?? defaultValue;\n};\n"],"mappings":";;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,aAAaA,CAAEC,IAAI,EAAG;EAC9B,IAAKC,KAAK,CAACC,OAAO,CAAEF,IAAK,CAAC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BQ,cAAc,CAACe,OAAO,CAAIC,SAAS,IAAM;IACxClB,KAAK,GAAGA,KAAK,GAAIkB,SAAS,CAAE;EAC7B,CAAE,CAAC;EACH,QAAAF,MAAA,GAAOhB,KAAK,cAAAgB,MAAA,cAAAA,MAAA,GAAID,YAAY;AAC7B,CAAC;AAACI,OAAA,CAAAL,sBAAA,GAAAA,sBAAA"}
1
+ {"version":3,"names":["_changeCase","require","kebabCase","str","input","_str$toString","toString","replace","paramCase","splitRegexp","setImmutably","object","path","value","Array","isArray","leaf","pop","prev","key","lvl","getValueFromObjectPath","defaultValue","_value","arrayPath","split","forEach","fieldName","exports"],"sources":["@wordpress/block-editor/src/utils/object.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase } from 'change-case';\n\n/**\n * Converts any string to kebab case.\n * Backwards compatible with Lodash's `_.kebabCase()`.\n * Backwards compatible with `_wp_to_kebab_case()`.\n *\n * @see https://lodash.com/docs/4.17.15#kebabCase\n * @see https://developer.wordpress.org/reference/functions/_wp_to_kebab_case/\n *\n * @param {string} str String to convert.\n * @return {string} Kebab-cased string\n */\nexport function kebabCase( str ) {\n\tlet input = str;\n\tif ( typeof str !== 'string' ) {\n\t\tinput = str?.toString?.() ?? '';\n\t}\n\n\t// See https://github.com/lodash/lodash/blob/b185fcee26b2133bd071f4aaca14b455c2ed1008/lodash.js#L4970\n\tinput = input.replace( /['\\u2019]/, '' );\n\n\treturn paramCase( input, {\n\t\tsplitRegexp: [\n\t\t\t/(?!(?:1ST|2ND|3RD|[4-9]TH)(?![a-z]))([a-z0-9])([A-Z])/g, // fooBar => foo-bar, 3Bar => 3-bar\n\t\t\t/(?!(?:1st|2nd|3rd|[4-9]th)(?![a-z]))([0-9])([a-z])/g, // 3bar => 3-bar\n\t\t\t/([A-Za-z])([0-9])/g, // Foo3 => foo-3, foo3 => foo-3\n\t\t\t/([A-Z])([A-Z][a-z])/g, // FOOBar => foo-bar\n\t\t],\n\t} );\n}\n\n/**\n * Immutably sets a value inside an object. Like `lodash#set`, but returning a\n * new object. Treats nullish initial values as empty objects. Clones any\n * nested objects. Supports arrays, too.\n *\n * @param {Object} object Object to set a value in.\n * @param {number|string|Array} path Path in the object to modify.\n * @param {*} value New value to set.\n * @return {Object} Cloned object with the new value set.\n */\nexport function setImmutably( object, path, value ) {\n\t// Normalize path\n\tpath = Array.isArray( path ) ? [ ...path ] : [ path ];\n\n\t// Shallowly clone the base of the object\n\tobject = Array.isArray( object ) ? [ ...object ] : { ...object };\n\n\tconst leaf = path.pop();\n\n\t// Traverse object from root to leaf, shallowly cloning at each level\n\tlet prev = object;\n\tfor ( const key of path ) {\n\t\tconst lvl = prev[ key ];\n\t\tprev = prev[ key ] = Array.isArray( lvl ) ? [ ...lvl ] : { ...lvl };\n\t}\n\n\tprev[ leaf ] = value;\n\n\treturn object;\n}\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as either:\n * - a string of properties, separated by dots, for example: \"x.y\".\n * - an array of properties, for example `[ 'x', 'y' ]`.\n * You can also specify a default value in case the result is nullish.\n *\n * @param {Object} object Input object.\n * @param {string|Array} path Path to the object property.\n * @param {*} defaultValue Default value if the value at the specified path is nullish.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path, defaultValue ) => {\n\tconst arrayPath = Array.isArray( path ) ? path : path.split( '.' );\n\tlet value = object;\n\tarrayPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value ?? defaultValue;\n};\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAAEC,GAAG,EAAG;EAChC,IAAIC,KAAK,GAAGD,GAAG;EACf,IAAK,OAAOA,GAAG,KAAK,QAAQ,EAAG;IAAA,IAAAE,aAAA;IAC9BD,KAAK,IAAAC,aAAA,GAAGF,GAAG,EAAEG,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Y,KAAM;EAAA,IAAAC,MAAA;EACvE,MAAMC,SAAS,GAAGV,KAAK,CAACC,OAAO,CAAEH,IAAK,CAAC,GAAGA,IAAI,GAAGA,IAAI,CAACa,KAAK,CAAE,GAAI,CAAC;EAClE,IAAIZ,KAAK,GAAGF,MAAM;EAClBa,SAAS,CAACE,OAAO,CAAIC,SAAS,IAAM;IACnCd,KAAK,GAAGA,KAAK,GAAIc,SAAS,CAAE;EAC7B,CAAE,CAAC;EACH,QAAAJ,MAAA,GAAOV,KAAK,cAAAU,MAAA,cAAAA,MAAA,GAAID,YAAY;AAC7B,CAAC;AAACM,OAAA,CAAAP,sBAAA,GAAAA,sBAAA"}
@@ -5,6 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.START_OF_SELECTED_AREA = void 0;
7
7
  exports.retrieveSelectedAttribute = retrieveSelectedAttribute;
8
+ var _richText = require("@wordpress/rich-text");
9
+ /**
10
+ * WordPress dependencies
11
+ */
12
+
8
13
  /**
9
14
  * A robust way to retain selection position through various
10
15
  * transforms is to insert a special character at the position and
@@ -25,7 +30,10 @@ function retrieveSelectedAttribute(blockAttributes) {
25
30
  }
26
31
  return Object.keys(blockAttributes).find(name => {
27
32
  const value = blockAttributes[name];
28
- return typeof value === 'string' && value.indexOf(START_OF_SELECTED_AREA) !== -1;
33
+ return (typeof value === 'string' || value instanceof _richText.RichTextData) &&
34
+ // To do: refactor this to use rich text's selection instead, so we
35
+ // no longer have to use on this hack inserting a special character.
36
+ value.toString().indexOf(START_OF_SELECTED_AREA) !== -1;
29
37
  });
30
38
  }
31
39
  //# sourceMappingURL=selection.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["START_OF_SELECTED_AREA","exports","retrieveSelectedAttribute","blockAttributes","Object","keys","find","name","value","indexOf"],"sources":["@wordpress/block-editor/src/utils/selection.js"],"sourcesContent":["/**\n * A robust way to retain selection position through various\n * transforms is to insert a special character at the position and\n * then recover it.\n */\nexport const START_OF_SELECTED_AREA = '\\u0086';\n\n/**\n * Retrieve the block attribute that contains the selection position.\n *\n * @param {Object} blockAttributes Block attributes.\n * @return {string|void} The name of the block attribute that was previously selected.\n */\nexport function retrieveSelectedAttribute( blockAttributes ) {\n\tif ( ! blockAttributes ) {\n\t\treturn;\n\t}\n\n\treturn Object.keys( blockAttributes ).find( ( name ) => {\n\t\tconst value = blockAttributes[ name ];\n\t\treturn (\n\t\t\ttypeof value === 'string' &&\n\t\t\tvalue.indexOf( START_OF_SELECTED_AREA ) !== -1\n\t\t);\n\t} );\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACO,MAAMA,sBAAsB,GAAG,QAAQ;;AAE9C;AACA;AACA;AACA;AACA;AACA;AALAC,OAAA,CAAAD,sBAAA,GAAAA,sBAAA;AAMO,SAASE,yBAAyBA,CAAEC,eAAe,EAAG;EAC5D,IAAK,CAAEA,eAAe,EAAG;IACxB;EACD;EAEA,OAAOC,MAAM,CAACC,IAAI,CAAEF,eAAgB,CAAC,CAACG,IAAI,CAAIC,IAAI,IAAM;IACvD,MAAMC,KAAK,GAAGL,eAAe,CAAEI,IAAI,CAAE;IACrC,OACC,OAAOC,KAAK,KAAK,QAAQ,IACzBA,KAAK,CAACC,OAAO,CAAET,sBAAuB,CAAC,KAAK,CAAC,CAAC;EAEhD,CAAE,CAAC;AACJ"}
1
+ {"version":3,"names":["_richText","require","START_OF_SELECTED_AREA","exports","retrieveSelectedAttribute","blockAttributes","Object","keys","find","name","value","RichTextData","toString","indexOf"],"sources":["@wordpress/block-editor/src/utils/selection.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { RichTextData } from '@wordpress/rich-text';\n\n/**\n * A robust way to retain selection position through various\n * transforms is to insert a special character at the position and\n * then recover it.\n */\nexport const START_OF_SELECTED_AREA = '\\u0086';\n\n/**\n * Retrieve the block attribute that contains the selection position.\n *\n * @param {Object} blockAttributes Block attributes.\n * @return {string|void} The name of the block attribute that was previously selected.\n */\nexport function retrieveSelectedAttribute( blockAttributes ) {\n\tif ( ! blockAttributes ) {\n\t\treturn;\n\t}\n\n\treturn Object.keys( blockAttributes ).find( ( name ) => {\n\t\tconst value = blockAttributes[ name ];\n\t\treturn (\n\t\t\t( typeof value === 'string' || value instanceof RichTextData ) &&\n\t\t\t// To do: refactor this to use rich text's selection instead, so we\n\t\t\t// no longer have to use on this hack inserting a special character.\n\t\t\tvalue.toString().indexOf( START_OF_SELECTED_AREA ) !== -1\n\t\t);\n\t} );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACO,MAAMC,sBAAsB,GAAG,QAAQ;;AAE9C;AACA;AACA;AACA;AACA;AACA;AALAC,OAAA,CAAAD,sBAAA,GAAAA,sBAAA;AAMO,SAASE,yBAAyBA,CAAEC,eAAe,EAAG;EAC5D,IAAK,CAAEA,eAAe,EAAG;IACxB;EACD;EAEA,OAAOC,MAAM,CAACC,IAAI,CAAEF,eAAgB,CAAC,CAACG,IAAI,CAAIC,IAAI,IAAM;IACvD,MAAMC,KAAK,GAAGL,eAAe,CAAEI,IAAI,CAAE;IACrC,OACC,CAAE,OAAOC,KAAK,KAAK,QAAQ,IAAIA,KAAK,YAAYC,sBAAY;IAC5D;IACA;IACAD,KAAK,CAACE,QAAQ,CAAC,CAAC,CAACC,OAAO,CAAEX,sBAAuB,CAAC,KAAK,CAAC,CAAC;EAE3D,CAAE,CAAC;AACJ"}
@@ -1,13 +1,15 @@
1
- import { createElement, Fragment } from "react";
1
+ import { createElement } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
5
5
  import { useMergeRefs } from '@wordpress/compose';
6
+ import { useRef } from '@wordpress/element';
6
7
 
7
8
  /**
8
9
  * Internal dependencies
9
10
  */
10
11
  import BlockList from '../block-list';
12
+ import BlockTools from '../block-tools';
11
13
  import EditorStyles from '../editor-styles';
12
14
  import Iframe from '../iframe';
13
15
  import WritingFlow from '../writing-flow';
@@ -23,9 +25,16 @@ export function ExperimentalBlockCanvas({
23
25
  }) {
24
26
  const resetTypingRef = useMouseMoveTypingReset();
25
27
  const clearerRef = useBlockSelectionClearer();
26
- const contentRef = useMergeRefs([contentRefProp, clearerRef]);
28
+ const localRef = useRef();
29
+ const contentRef = useMergeRefs([contentRefProp, clearerRef, localRef]);
27
30
  if (!shouldIframe) {
28
- return createElement(Fragment, null, createElement(EditorStyles, {
31
+ return createElement(BlockTools, {
32
+ __unstableContentRef: localRef,
33
+ style: {
34
+ height,
35
+ display: 'flex'
36
+ }
37
+ }, createElement(EditorStyles, {
29
38
  styles: styles,
30
39
  scope: ".editor-styles-wrapper"
31
40
  }), createElement(WritingFlow, {
@@ -33,23 +42,30 @@ export function ExperimentalBlockCanvas({
33
42
  className: "editor-styles-wrapper",
34
43
  tabIndex: -1,
35
44
  style: {
36
- height
45
+ height: '100%',
46
+ width: '100%'
37
47
  }
38
48
  }, children));
39
49
  }
40
- return createElement(Iframe, {
50
+ return createElement(BlockTools, {
51
+ __unstableContentRef: localRef,
52
+ style: {
53
+ height,
54
+ display: 'flex'
55
+ }
56
+ }, createElement(Iframe, {
41
57
  ...iframeProps,
42
58
  ref: resetTypingRef,
43
59
  contentRef: contentRef,
44
60
  style: {
45
61
  width: '100%',
46
- height,
62
+ height: '100%',
47
63
  ...iframeProps?.style
48
64
  },
49
65
  name: "editor-canvas"
50
66
  }, createElement(EditorStyles, {
51
67
  styles: styles
52
- }), children);
68
+ }), children));
53
69
  }
54
70
 
55
71
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["useMergeRefs","BlockList","EditorStyles","Iframe","WritingFlow","useMouseMoveTypingReset","useBlockSelectionClearer","ExperimentalBlockCanvas","shouldIframe","height","children","createElement","styles","contentRef","contentRefProp","iframeProps","resetTypingRef","clearerRef","Fragment","scope","ref","className","tabIndex","style","width","name","BlockCanvas"],"sources":["@wordpress/block-editor/src/components/block-canvas/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../block-list';\nimport EditorStyles from '../editor-styles';\nimport Iframe from '../iframe';\nimport WritingFlow from '../writing-flow';\nimport { useMouseMoveTypingReset } from '../observe-typing';\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\n\nexport function ExperimentalBlockCanvas( {\n\tshouldIframe = true,\n\theight = '300px',\n\tchildren = <BlockList />,\n\tstyles,\n\tcontentRef: contentRefProp,\n\tiframeProps,\n} ) {\n\tconst resetTypingRef = useMouseMoveTypingReset();\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst contentRef = useMergeRefs( [ contentRefProp, clearerRef ] );\n\n\tif ( ! shouldIframe ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<EditorStyles\n\t\t\t\t\tstyles={ styles }\n\t\t\t\t\tscope=\".editor-styles-wrapper\"\n\t\t\t\t/>\n\t\t\t\t<WritingFlow\n\t\t\t\t\tref={ contentRef }\n\t\t\t\t\tclassName=\"editor-styles-wrapper\"\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\tstyle={ { height } }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</WritingFlow>\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Iframe\n\t\t\t{ ...iframeProps }\n\t\t\tref={ resetTypingRef }\n\t\t\tcontentRef={ contentRef }\n\t\t\tstyle={ {\n\t\t\t\twidth: '100%',\n\t\t\t\theight,\n\t\t\t\t...iframeProps?.style,\n\t\t\t} }\n\t\t\tname=\"editor-canvas\"\n\t\t>\n\t\t\t<EditorStyles styles={ styles } />\n\t\t\t{ children }\n\t\t</Iframe>\n\t);\n}\n\n/**\n * BlockCanvas component is a component used to display the canvas of the block editor.\n * What we call the canvas is an iframe containing the block list that you can manipulate.\n * The component is also responsible of wiring up all the necessary hooks to enable\n * the keyboard navigation across blocks in the editor and inject content styles into the iframe.\n *\n * @example\n *\n * ```jsx\n * function MyBlockEditor() {\n * const [ blocks, updateBlocks ] = useState([]);\n * return (\n * <BlockEditorProvider\n * value={ blocks }\n * onInput={ updateBlocks }\n * onChange={ persistBlocks }\n * >\n * <BlockCanvas height=\"400px\" />\n * </BlockEditorProvider>\n * );\n * }\n * ```\n *\n * @param {Object} props Component props.\n * @param {string} props.height Canvas height, defaults to 300px.\n * @param {Array} props.styles Content styles to inject into the iframe.\n * @param {Element} props.children Content of the canvas, defaults to the BlockList component.\n * @return {Element} Block Breadcrumb.\n */\nfunction BlockCanvas( { children, height, styles } ) {\n\treturn (\n\t\t<ExperimentalBlockCanvas height={ height } styles={ styles }>\n\t\t\t{ children }\n\t\t</ExperimentalBlockCanvas>\n\t);\n}\n\nexport default BlockCanvas;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,OAAOC,SAAS,MAAM,eAAe;AACrC,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,MAAM,MAAM,WAAW;AAC9B,OAAOC,WAAW,MAAM,iBAAiB;AACzC,SAASC,uBAAuB,QAAQ,mBAAmB;AAC3D,SAASC,wBAAwB,QAAQ,4BAA4B;AAErE,OAAO,SAASC,uBAAuBA,CAAE;EACxCC,YAAY,GAAG,IAAI;EACnBC,MAAM,GAAG,OAAO;EAChBC,QAAQ,GAAGC,aAAA,CAACV,SAAS,MAAE,CAAC;EACxBW,MAAM;EACNC,UAAU,EAAEC,cAAc;EAC1BC;AACD,CAAC,EAAG;EACH,MAAMC,cAAc,GAAGX,uBAAuB,CAAC,CAAC;EAChD,MAAMY,UAAU,GAAGX,wBAAwB,CAAC,CAAC;EAC7C,MAAMO,UAAU,GAAGb,YAAY,CAAE,CAAEc,cAAc,EAAEG,UAAU,CAAG,CAAC;EAEjE,IAAK,CAAET,YAAY,EAAG;IACrB,OACCG,aAAA,CAAAO,QAAA,QACCP,aAAA,CAACT,YAAY;MACZU,MAAM,EAAGA,MAAQ;MACjBO,KAAK,EAAC;IAAwB,CAC9B,CAAC,EACFR,aAAA,CAACP,WAAW;MACXgB,GAAG,EAAGP,UAAY;MAClBQ,SAAS,EAAC,uBAAuB;MACjCC,QAAQ,EAAG,CAAC,CAAG;MACfC,KAAK,EAAG;QAAEd;MAAO;IAAG,GAElBC,QACU,CACZ,CAAC;EAEL;EAEA,OACCC,aAAA,CAACR,MAAM;IAAA,GACDY,WAAW;IAChBK,GAAG,EAAGJ,cAAgB;IACtBH,UAAU,EAAGA,UAAY;IACzBU,KAAK,EAAG;MACPC,KAAK,EAAE,MAAM;MACbf,MAAM;MACN,GAAGM,WAAW,EAAEQ;IACjB,CAAG;IACHE,IAAI,EAAC;EAAe,GAEpBd,aAAA,CAACT,YAAY;IAACU,MAAM,EAAGA;EAAQ,CAAE,CAAC,EAChCF,QACK,CAAC;AAEX;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASgB,WAAWA,CAAE;EAAEhB,QAAQ;EAAED,MAAM;EAAEG;AAAO,CAAC,EAAG;EACpD,OACCD,aAAA,CAACJ,uBAAuB;IAACE,MAAM,EAAGA,MAAQ;IAACG,MAAM,EAAGA;EAAQ,GACzDF,QACsB,CAAC;AAE5B;AAEA,eAAegB,WAAW"}
1
+ {"version":3,"names":["useMergeRefs","useRef","BlockList","BlockTools","EditorStyles","Iframe","WritingFlow","useMouseMoveTypingReset","useBlockSelectionClearer","ExperimentalBlockCanvas","shouldIframe","height","children","createElement","styles","contentRef","contentRefProp","iframeProps","resetTypingRef","clearerRef","localRef","__unstableContentRef","style","display","scope","ref","className","tabIndex","width","name","BlockCanvas"],"sources":["@wordpress/block-editor/src/components/block-canvas/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../block-list';\nimport BlockTools from '../block-tools';\nimport EditorStyles from '../editor-styles';\nimport Iframe from '../iframe';\nimport WritingFlow from '../writing-flow';\nimport { useMouseMoveTypingReset } from '../observe-typing';\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\n\nexport function ExperimentalBlockCanvas( {\n\tshouldIframe = true,\n\theight = '300px',\n\tchildren = <BlockList />,\n\tstyles,\n\tcontentRef: contentRefProp,\n\tiframeProps,\n} ) {\n\tconst resetTypingRef = useMouseMoveTypingReset();\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst localRef = useRef();\n\tconst contentRef = useMergeRefs( [ contentRefProp, clearerRef, localRef ] );\n\n\tif ( ! shouldIframe ) {\n\t\treturn (\n\t\t\t<BlockTools\n\t\t\t\t__unstableContentRef={ localRef }\n\t\t\t\tstyle={ { height, display: 'flex' } }\n\t\t\t>\n\t\t\t\t<EditorStyles\n\t\t\t\t\tstyles={ styles }\n\t\t\t\t\tscope=\".editor-styles-wrapper\"\n\t\t\t\t/>\n\t\t\t\t<WritingFlow\n\t\t\t\t\tref={ contentRef }\n\t\t\t\t\tclassName=\"editor-styles-wrapper\"\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</WritingFlow>\n\t\t\t</BlockTools>\n\t\t);\n\t}\n\n\treturn (\n\t\t<BlockTools\n\t\t\t__unstableContentRef={ localRef }\n\t\t\tstyle={ { height, display: 'flex' } }\n\t\t>\n\t\t\t<Iframe\n\t\t\t\t{ ...iframeProps }\n\t\t\t\tref={ resetTypingRef }\n\t\t\t\tcontentRef={ contentRef }\n\t\t\t\tstyle={ {\n\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '100%',\n\t\t\t\t\t...iframeProps?.style,\n\t\t\t\t} }\n\t\t\t\tname=\"editor-canvas\"\n\t\t\t>\n\t\t\t\t<EditorStyles styles={ styles } />\n\t\t\t\t{ children }\n\t\t\t</Iframe>\n\t\t</BlockTools>\n\t);\n}\n\n/**\n * BlockCanvas component is a component used to display the canvas of the block editor.\n * What we call the canvas is an iframe containing the block list that you can manipulate.\n * The component is also responsible of wiring up all the necessary hooks to enable\n * the keyboard navigation across blocks in the editor and inject content styles into the iframe.\n *\n * @example\n *\n * ```jsx\n * function MyBlockEditor() {\n * const [ blocks, updateBlocks ] = useState([]);\n * return (\n * <BlockEditorProvider\n * value={ blocks }\n * onInput={ updateBlocks }\n * onChange={ persistBlocks }\n * >\n * <BlockCanvas height=\"400px\" />\n * </BlockEditorProvider>\n * );\n * }\n * ```\n *\n * @param {Object} props Component props.\n * @param {string} props.height Canvas height, defaults to 300px.\n * @param {Array} props.styles Content styles to inject into the iframe.\n * @param {Element} props.children Content of the canvas, defaults to the BlockList component.\n * @return {Element} Block Breadcrumb.\n */\nfunction BlockCanvas( { children, height, styles } ) {\n\treturn (\n\t\t<ExperimentalBlockCanvas height={ height } styles={ styles }>\n\t\t\t{ children }\n\t\t</ExperimentalBlockCanvas>\n\t);\n}\n\nexport default BlockCanvas;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,oBAAoB;AACjD,SAASC,MAAM,QAAQ,oBAAoB;;AAE3C;AACA;AACA;AACA,OAAOC,SAAS,MAAM,eAAe;AACrC,OAAOC,UAAU,MAAM,gBAAgB;AACvC,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,MAAM,MAAM,WAAW;AAC9B,OAAOC,WAAW,MAAM,iBAAiB;AACzC,SAASC,uBAAuB,QAAQ,mBAAmB;AAC3D,SAASC,wBAAwB,QAAQ,4BAA4B;AAErE,OAAO,SAASC,uBAAuBA,CAAE;EACxCC,YAAY,GAAG,IAAI;EACnBC,MAAM,GAAG,OAAO;EAChBC,QAAQ,GAAGC,aAAA,CAACX,SAAS,MAAE,CAAC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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASkB,WAAWA,CAAE;EAAElB,QAAQ;EAAED,MAAM;EAAEG;AAAO,CAAC,EAAG;EACpD,OACCD,aAAA,CAACJ,uBAAuB;IAACE,MAAM,EAAGA,MAAQ;IAACG,MAAM,EAAGA;EAAQ,GACzDF,QACsB,CAAC;AAE5B;AAEA,eAAekB,WAAW"}
@@ -74,7 +74,7 @@ function BlockCard({
74
74
  className: "block-editor-block-card__content"
75
75
  }, createElement("h2", {
76
76
  className: "block-editor-block-card__title"
77
- }, title), createElement("span", {
77
+ }, title), description && createElement("span", {
78
78
  className: "block-editor-block-card__description"
79
79
  }, description)));
80
80
  }
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","deprecated","Button","chevronLeft","chevronRight","__","isRTL","useSelect","useDispatch","BlockIcon","store","blockEditorStore","BlockCard","title","icon","description","blockType","className","since","alternative","parentNavBlockClientId","select","getSelectedBlockClientId","getBlockParentsByBlockName","_selectedBlockClientId","selectBlock","createElement","onClick","label","style","minWidth","padding","isSmall","showColors"],"sources":["@wordpress/block-editor/src/components/block-card/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { Button } from '@wordpress/components';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport { store as blockEditorStore } from '../../store';\n\nfunction BlockCard( { title, icon, description, blockType, className } ) {\n\tif ( blockType ) {\n\t\tdeprecated( '`blockType` property in `BlockCard component`', {\n\t\t\tsince: '5.7',\n\t\t\talternative: '`title, icon and description` properties',\n\t\t} );\n\t\t( { title, icon, description } = blockType );\n\t}\n\n\tconst { parentNavBlockClientId } = useSelect( ( select ) => {\n\t\tconst { getSelectedBlockClientId, getBlockParentsByBlockName } =\n\t\t\tselect( blockEditorStore );\n\n\t\tconst _selectedBlockClientId = getSelectedBlockClientId();\n\n\t\treturn {\n\t\t\tparentNavBlockClientId: getBlockParentsByBlockName(\n\t\t\t\t_selectedBlockClientId,\n\t\t\t\t'core/navigation',\n\t\t\t\ttrue\n\t\t\t)[ 0 ],\n\t\t};\n\t}, [] );\n\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<div className={ classnames( 'block-editor-block-card', className ) }>\n\t\t\t{ parentNavBlockClientId && ( // This is only used by the Navigation block for now. It's not ideal having Navigation block specific code here.\n\t\t\t\t<Button\n\t\t\t\t\tonClick={ () => selectBlock( parentNavBlockClientId ) }\n\t\t\t\t\tlabel={ __( 'Go to parent Navigation block' ) }\n\t\t\t\t\tstyle={\n\t\t\t\t\t\t// TODO: This style override is also used in ToolsPanelHeader.\n\t\t\t\t\t\t// It should be supported out-of-the-box by Button.\n\t\t\t\t\t\t{ minWidth: 24, padding: 0 }\n\t\t\t\t\t}\n\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\tisSmall\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<BlockIcon icon={ icon } showColors />\n\t\t\t<div className=\"block-editor-block-card__content\">\n\t\t\t\t<h2 className=\"block-editor-block-card__title\">{ title }</h2>\n\t\t\t\t<span className=\"block-editor-block-card__description\">\n\t\t\t\t\t{ description }\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport default BlockCard;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,OAAOC,UAAU,MAAM,uBAAuB;AAC9C,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,WAAW,EAAEC,YAAY,QAAQ,kBAAkB;AAC5D,SAASC,EAAE,EAA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KAAK,CAAC,CAAC,GAAGF,YAAY,GAAGD,WAAa;IAC7C6B,OAAO;EAAA,CACP,CACD,EACDN,aAAA,CAACjB,SAAS;IAACK,IAAI,EAAGA,IAAM;IAACmB,UAAU;EAAA,CAAE,CAAC,EACtCP,aAAA;IAAKT,SAAS,EAAC;EAAkC,GAChDS,aAAA;IAAIT,SAAS,EAAC;EAAgC,GAAGJ,KAAW,CAAC,EAC7Da,aAAA;IAAMT,SAAS,EAAC;EAAsC,GACnDF,WACG,CACF,CACD,CAAC;AAER;AAEA,eAAeH,SAAS"}
1
+ {"version":3,"names":["classnames","deprecated","Button","chevronLeft","chevronRight","__","isRTL","useSelect","useDispatch","BlockIcon","store","blockEditorStore","BlockCard","title","icon","description","blockType","className","since","alternative","parentNavBlockClientId","select","getSelectedBlockClientId","getBlockParentsByBlockName","_selectedBlockClientId","selectBlock","createElement","onClick","label","style","minWidth","padding","isSmall","showColors"],"sources":["@wordpress/block-editor/src/components/block-card/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { Button } from '@wordpress/components';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport { store as blockEditorStore } from '../../store';\n\nfunction BlockCard( { title, icon, description, blockType, className } ) {\n\tif ( blockType ) {\n\t\tdeprecated( '`blockType` property in `BlockCard component`', {\n\t\t\tsince: '5.7',\n\t\t\talternative: '`title, icon and description` properties',\n\t\t} );\n\t\t( { title, icon, description } = blockType );\n\t}\n\n\tconst { parentNavBlockClientId } = useSelect( ( select ) => {\n\t\tconst { getSelectedBlockClientId, getBlockParentsByBlockName } =\n\t\t\tselect( blockEditorStore );\n\n\t\tconst _selectedBlockClientId = getSelectedBlockClientId();\n\n\t\treturn {\n\t\t\tparentNavBlockClientId: getBlockParentsByBlockName(\n\t\t\t\t_selectedBlockClientId,\n\t\t\t\t'core/navigation',\n\t\t\t\ttrue\n\t\t\t)[ 0 ],\n\t\t};\n\t}, [] );\n\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<div className={ classnames( 'block-editor-block-card', className ) }>\n\t\t\t{ parentNavBlockClientId && ( // This is only used by the Navigation block for now. It's not ideal having Navigation block specific code here.\n\t\t\t\t<Button\n\t\t\t\t\tonClick={ () => selectBlock( parentNavBlockClientId ) }\n\t\t\t\t\tlabel={ __( 'Go to parent Navigation block' ) }\n\t\t\t\t\tstyle={\n\t\t\t\t\t\t// TODO: This style override is also used in ToolsPanelHeader.\n\t\t\t\t\t\t// It should be supported out-of-the-box by Button.\n\t\t\t\t\t\t{ minWidth: 24, padding: 0 }\n\t\t\t\t\t}\n\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\tisSmall\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<BlockIcon icon={ icon } showColors />\n\t\t\t<div className=\"block-editor-block-card__content\">\n\t\t\t\t<h2 className=\"block-editor-block-card__title\">{ title }</h2>\n\t\t\t\t{ description && (\n\t\t\t\t\t<span className=\"block-editor-block-card__description\">\n\t\t\t\t\t\t{ description }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport default BlockCard;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,OAAOC,UAAU,MAAM,uBAAuB;AAC9C,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,WAAW,EAAEC,YAAY,QAAQ,kBAAkB;AAC5D,SAASC,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,OAAOC,SAAS,MAAM,eAAe;AACrC,SA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ACmB,UAAU;EAAA,CAAE,CAAC,EACtCP,aAAA;IAAKT,SAAS,EAAC;EAAkC,GAChDS,aAAA;IAAIT,SAAS,EAAC;EAAgC,GAAGJ,KAAW,CAAC,EAC3DE,WAAW,IACZW,aAAA;IAAMT,SAAS,EAAC;EAAsC,GACnDF,WACG,CAEH,CACD,CAAC;AAER;AAEA,eAAeH,SAAS"}
@@ -1,38 +1,18 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { store as blocksStore } from '@wordpress/blocks';
5
- import { useSelect } from '@wordpress/data';
6
4
 
7
5
  /**
8
6
  * Internal dependencies
9
7
  */
10
8
  import groups from './groups';
11
- import { store as blockEditorStore } from '../../store';
12
- import { useBlockEditContext } from '../block-edit/context';
13
- import useDisplayBlockControls from '../use-display-block-controls';
9
+ import { useBlockEditContext, mayDisplayControlsKey, mayDisplayParentControlsKey } from '../block-edit/context';
14
10
  export default function useBlockControlsFill(group, shareWithChildBlocks) {
15
- const isDisplayed = useDisplayBlockControls();
16
- const {
17
- clientId
18
- } = useBlockEditContext();
19
- const isParentDisplayed = useSelect(select => {
20
- if (!shareWithChildBlocks) {
21
- return false;
22
- }
23
- const {
24
- getBlockName,
25
- hasSelectedInnerBlock
26
- } = select(blockEditorStore);
27
- const {
28
- hasBlockSupport
29
- } = select(blocksStore);
30
- return hasBlockSupport(getBlockName(clientId), '__experimentalExposeControlsToChildren', false) && hasSelectedInnerBlock(clientId);
31
- }, [shareWithChildBlocks, clientId]);
32
- if (isDisplayed) {
11
+ const context = useBlockEditContext();
12
+ if (context[mayDisplayControlsKey]) {
33
13
  return groups[group]?.Fill;
34
14
  }
35
- if (isParentDisplayed) {
15
+ if (context[mayDisplayParentControlsKey] && shareWithChildBlocks) {
36
16
  return groups.parent.Fill;
37
17
  }
38
18
  return null;
@@ -1 +1 @@
1
- {"version":3,"names":["store","blocksStore","useSelect","groups","blockEditorStore","useBlockEditContext","useDisplayBlockControls","useBlockControlsFill","group","shareWithChildBlocks","isDisplayed","clientId","isParentDisplayed","select","getBlockName","hasSelectedInnerBlock","hasBlockSupport","Fill","parent"],"sources":["@wordpress/block-editor/src/components/block-controls/hook.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport groups from './groups';\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useDisplayBlockControls from '../use-display-block-controls';\n\nexport default function useBlockControlsFill( group, shareWithChildBlocks ) {\n\tconst isDisplayed = useDisplayBlockControls();\n\tconst { clientId } = useBlockEditContext();\n\tconst isParentDisplayed = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! shareWithChildBlocks ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst { getBlockName, hasSelectedInnerBlock } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { hasBlockSupport } = select( blocksStore );\n\n\t\t\treturn (\n\t\t\t\thasBlockSupport(\n\t\t\t\t\tgetBlockName( clientId ),\n\t\t\t\t\t'__experimentalExposeControlsToChildren',\n\t\t\t\t\tfalse\n\t\t\t\t) && hasSelectedInnerBlock( clientId )\n\t\t\t);\n\t\t},\n\t\t[ shareWithChildBlocks, clientId ]\n\t);\n\n\tif ( isDisplayed ) {\n\t\treturn groups[ group ]?.Fill;\n\t}\n\tif ( isParentDisplayed ) {\n\t\treturn groups.parent.Fill;\n\t}\n\treturn null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASH,KAAK,IAAII,gBAAgB,QAAQ,aAAa;AACvD,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,OAAOC,uBAAuB,MAAM,+BAA+B;AAEnE,eAAe,SAASC,oBAAoBA,CAAEC,KAAK,EAAEC,oBAAoB,EAAG;EAC3E,MAAMC,WAAW,GAAGJ,uBAAuB,CAAC,CAAC;EAC7C,MAAM;IAAEK;EAAS,CAAC,GAAGN,mBAAmB,CAAC,CAAC;EAC1C,MAAMO,iBAAiB,GAAGV,SAAS,CAChCW,MAAM,IAAM;IACb,IAAK,CAAEJ,oBAAoB,EAAG;MAC7B,OAAO,KAAK;IACb;IAEA,MAAM;MAAEK,YAAY;MAAEC;IAAsB,CAAC,GAC5CF,MAAM,CAAET,gBAAiB,CAAC;IAC3B,MAAM;MAAEY;IAAgB,CAAC,GAAGH,MAAM,CAAEZ,WAAY,CAAC;IAEjD,OACCe,eAAe,CACdF,YAAY,CAAEH,QAAS,CAAC,EACxB,wCAAwC,EACxC,KACD,CAAC,IAAII,qBAAqB,CAAEJ,QAAS,CAAC;EAExC,CAAC,EACD,CAAEF,oBAAoB,EAAEE,QAAQ,CACjC,CAAC;EAED,IAAKD,WAAW,EAAG;IAClB,OAAOP,MAAM,CAAEK,KAAK,CAAE,EAAES,IAAI;EAC7B;EACA,IAAKL,iBAAiB,EAAG;IACxB,OAAOT,MAAM,CAACe,MAAM,CAACD,IAAI;EAC1B;EACA,OAAO,IAAI;AACZ"}
1
+ {"version":3,"names":["groups","useBlockEditContext","mayDisplayControlsKey","mayDisplayParentControlsKey","useBlockControlsFill","group","shareWithChildBlocks","context","Fill","parent"],"sources":["@wordpress/block-editor/src/components/block-controls/hook.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\n\n/**\n * Internal dependencies\n */\nimport groups from './groups';\nimport {\n\tuseBlockEditContext,\n\tmayDisplayControlsKey,\n\tmayDisplayParentControlsKey,\n} from '../block-edit/context';\n\nexport default function useBlockControlsFill( group, shareWithChildBlocks ) {\n\tconst context = useBlockEditContext();\n\tif ( context[ mayDisplayControlsKey ] ) {\n\t\treturn groups[ group ]?.Fill;\n\t}\n\tif ( context[ mayDisplayParentControlsKey ] && shareWithChildBlocks ) {\n\t\treturn groups.parent.Fill;\n\t}\n\treturn null;\n}\n"],"mappings":"AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,UAAU;AAC7B,SACCC,mBAAmB,EACnBC,qBAAqB,EACrBC,2BAA2B,QACrB,uBAAuB;AAE9B,eAAe,SAASC,oBAAoBA,CAAEC,KAAK,EAAEC,oBAAoB,EAAG;EAC3E,MAAMC,OAAO,GAAGN,mBAAmB,CAAC,CAAC;EACrC,IAAKM,OAAO,CAAEL,qBAAqB,CAAE,EAAG;IACvC,OAAOF,MAAM,CAAEK,KAAK,CAAE,EAAEG,IAAI;EAC7B;EACA,IAAKD,OAAO,CAAEJ,2BAA2B,CAAE,IAAIG,oBAAoB,EAAG;IACrE,OAAON,MAAM,CAACS,MAAM,CAACD,IAAI;EAC1B;EACA,OAAO,IAAI;AACZ"}
@@ -2,6 +2,8 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { createContext, useContext } from '@wordpress/element';
5
+ export const mayDisplayControlsKey = Symbol('mayDisplayControls');
6
+ export const mayDisplayParentControlsKey = Symbol('mayDisplayParentControls');
5
7
  export const DEFAULT_BLOCK_EDIT_CONTEXT = {
6
8
  name: '',
7
9
  isSelected: false
@@ -1 +1 @@
1
- {"version":3,"names":["createContext","useContext","DEFAULT_BLOCK_EDIT_CONTEXT","name","isSelected","Context","Provider","BlockEditContextProvider","useBlockEditContext"],"sources":["@wordpress/block-editor/src/components/block-edit/context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\nexport const DEFAULT_BLOCK_EDIT_CONTEXT = {\n\tname: '',\n\tisSelected: false,\n};\n\nconst Context = createContext( DEFAULT_BLOCK_EDIT_CONTEXT );\nconst { Provider } = Context;\n\nexport { Provider as BlockEditContextProvider };\n\n/**\n * A hook that returns the block edit context.\n *\n * @return {Object} Block edit context\n */\nexport function useBlockEditContext() {\n\treturn useContext( Context );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,oBAAoB;AAE9D,OAAO,MAAMC,0BAA0B,GAAG;EACzCC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACb,CAAC;AAED,MAAMC,OAAO,GAAGL,aAAa,CAAEE,0BAA2B,CAAC;AAC3D,MAAM;EAAEI;AAAS,CAAC,GAAGD,OAAO;AAE5B,SAASC,QAAQ,IAAIC,wBAAwB;;AAE7C;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAA,EAAG;EACrC,OAAOP,UAAU,CAAEI,OAAQ,CAAC;AAC7B"}
1
+ {"version":3,"names":["createContext","useContext","mayDisplayControlsKey","Symbol","mayDisplayParentControlsKey","DEFAULT_BLOCK_EDIT_CONTEXT","name","isSelected","Context","Provider","BlockEditContextProvider","useBlockEditContext"],"sources":["@wordpress/block-editor/src/components/block-edit/context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\nexport const mayDisplayControlsKey = Symbol( 'mayDisplayControls' );\nexport const mayDisplayParentControlsKey = Symbol( 'mayDisplayParentControls' );\n\nexport const DEFAULT_BLOCK_EDIT_CONTEXT = {\n\tname: '',\n\tisSelected: false,\n};\n\nconst Context = createContext( DEFAULT_BLOCK_EDIT_CONTEXT );\nconst { Provider } = Context;\n\nexport { Provider as BlockEditContextProvider };\n\n/**\n * A hook that returns the block edit context.\n *\n * @return {Object} Block edit context\n */\nexport function useBlockEditContext() {\n\treturn useContext( Context );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,oBAAoB;AAE9D,OAAO,MAAMC,qBAAqB,GAAGC,MAAM,CAAE,oBAAqB,CAAC;AACnE,OAAO,MAAMC,2BAA2B,GAAGD,MAAM,CAAE,0BAA2B,CAAC;AAE/E,OAAO,MAAME,0BAA0B,GAAG;EACzCC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACb,CAAC;AAED,MAAMC,OAAO,GAAGR,aAAa,CAAEK,0BAA2B,CAAC;AAC3D,MAAM;EAAEI;AAAS,CAAC,GAAGD,OAAO;AAE5B,SAASC,QAAQ,IAAIC,wBAAwB;;AAE7C;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAA,EAAG;EACrC,OAAOV,UAAU,CAAEO,OAAQ,CAAC;AAC7B"}
@@ -8,7 +8,7 @@ import { hasBlockSupport } from '@wordpress/blocks';
8
8
  * Internal dependencies
9
9
  */
10
10
  import Edit from './edit';
11
- import { BlockEditContextProvider, useBlockEditContext } from './context';
11
+ import { BlockEditContextProvider, useBlockEditContext, mayDisplayControlsKey, mayDisplayParentControlsKey } from './context';
12
12
 
13
13
  /**
14
14
  * The `useBlockEditContext` hook provides information about the block this hook is being used in.
@@ -19,7 +19,13 @@ import { BlockEditContextProvider, useBlockEditContext } from './context';
19
19
  * @return {Object} Block edit context
20
20
  */
21
21
  export { useBlockEditContext };
22
- export default function BlockEdit(props) {
22
+ export default function BlockEdit({
23
+ mayDisplayControls,
24
+ mayDisplayParentControls,
25
+ // The remaining props are passed through the BlockEdit filters and are thus
26
+ // public API!
27
+ ...props
28
+ }) {
23
29
  const {
24
30
  name,
25
31
  isSelected,
@@ -31,19 +37,22 @@ export default function BlockEdit(props) {
31
37
  layout = null
32
38
  } = attributes;
33
39
  const layoutSupport = hasBlockSupport(name, 'layout', false) || hasBlockSupport(name, '__experimentalLayout', false);
34
- const context = {
35
- name,
36
- isSelected,
37
- clientId,
38
- layout: layoutSupport ? layout : null,
39
- __unstableLayoutClassNames
40
- };
41
40
  return createElement(BlockEditContextProvider
42
41
  // It is important to return the same object if props haven't
43
42
  // changed to avoid unnecessary rerenders.
44
43
  // See https://reactjs.org/docs/context.html#caveats.
45
44
  , {
46
- value: useMemo(() => context, Object.values(context))
45
+ value: useMemo(() => ({
46
+ name,
47
+ isSelected,
48
+ clientId,
49
+ layout: layoutSupport ? layout : null,
50
+ __unstableLayoutClassNames,
51
+ // We use symbols in favour of an __unstable prefix to avoid
52
+ // usage outside of the package (this context is exposed).
53
+ [mayDisplayControlsKey]: mayDisplayControls,
54
+ [mayDisplayParentControlsKey]: mayDisplayParentControls
55
+ }), [name, isSelected, clientId, layoutSupport, layout, __unstableLayoutClassNames, mayDisplayControls, mayDisplayParentControls])
47
56
  }, createElement(Edit, {
48
57
  ...props
49
58
  }));
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","hasBlockSupport","Edit","BlockEditContextProvider","useBlockEditContext","BlockEdit","props","name","isSelected","clientId","attributes","__unstableLayoutClassNames","layout","layoutSupport","context","createElement","value","Object","values"],"sources":["@wordpress/block-editor/src/components/block-edit/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\nimport { hasBlockSupport } from '@wordpress/blocks';\n/**\n * Internal dependencies\n */\nimport Edit from './edit';\nimport { BlockEditContextProvider, useBlockEditContext } from './context';\n\n/**\n * The `useBlockEditContext` hook provides information about the block this hook is being used in.\n * It returns an object with the `name`, `isSelected` state, and the `clientId` of the block.\n * It is useful if you want to create custom hooks that need access to the current blocks clientId\n * but don't want to rely on the data getting passed in as a parameter.\n *\n * @return {Object} Block edit context\n */\nexport { useBlockEditContext };\n\nexport default function BlockEdit( props ) {\n\tconst {\n\t\tname,\n\t\tisSelected,\n\t\tclientId,\n\t\tattributes = {},\n\t\t__unstableLayoutClassNames,\n\t} = props;\n\tconst { layout = null } = attributes;\n\tconst layoutSupport =\n\t\thasBlockSupport( name, 'layout', false ) ||\n\t\thasBlockSupport( name, '__experimentalLayout', false );\n\tconst context = {\n\t\tname,\n\t\tisSelected,\n\t\tclientId,\n\t\tlayout: layoutSupport ? layout : null,\n\t\t__unstableLayoutClassNames,\n\t};\n\treturn (\n\t\t<BlockEditContextProvider\n\t\t\t// It is important to return the same object if props haven't\n\t\t\t// changed to avoid unnecessary rerenders.\n\t\t\t// See https://reactjs.org/docs/context.html#caveats.\n\t\t\tvalue={ useMemo( () => context, Object.values( context ) ) }\n\t\t>\n\t\t\t<Edit { ...props } />\n\t\t</BlockEditContextProvider>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAE5C,SAASC,eAAe,QAAQ,mBAAmB;AACnD;AACA;AACA;AACA,OAAOC,IAAI,MAAM,QAAQ;AACzB,SAASC,wBAAwB,EAAEC,mBAAmB,QAAQ,WAAW;;AAEzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,mBAAmB;AAE5B,eAAe,SAASC,SAASA,CAAEC,KAAK,EAAG;EAC1C,MAAM;IACLC,IAAI;IACJC,UAAU;IACVC,QAAQ;IACRC,UAAU,GAAG,CAAC,CAAC;IACfC;EACD,CAAC,GAAGL,KAAK;EACT,MAAM;IAAEM,MAAM,GAAG;EAAK,CAAC,GAAGF,UAAU;EACpC,MAAMG,aAAa,GAClBZ,eAAe,CAAEM,IAAI,EAAE,QAAQ,EAAE,KAAM,CAAC,IACxCN,eAAe,CAAEM,IAAI,EAAE,sBAAsB,EAAE,KAAM,CAAC;EACvD,MAAMO,OAAO,GAAG;IACfP,IAAI;IACJC,UAAU;IACVC,QAAQ;IACRG,MAAM,EAAEC,aAAa,GAAGD,MAAM,GAAG,IAAI;IACrCD;EACD,CAAC;EACD,OACCI,aAAA,CAACZ;EACA;EACA;EACA;EAAA;IACAa,KAAK,EAAGhB,OAAO,CAAE,MAAMc,OAAO,EAAEG,MAAM,CAACC,MAAM,CAAEJ,OAAQ,CAAE;EAAG,GAE5DC,aAAA,CAACb,IAAI;IAAA,GAAMI;EAAK,CAAI,CACK,CAAC;AAE7B"}
1
+ {"version":3,"names":["useMemo","hasBlockSupport","Edit","BlockEditContextProvider","useBlockEditContext","mayDisplayControlsKey","mayDisplayParentControlsKey","BlockEdit","mayDisplayControls","mayDisplayParentControls","props","name","isSelected","clientId","attributes","__unstableLayoutClassNames","layout","layoutSupport","createElement","value"],"sources":["@wordpress/block-editor/src/components/block-edit/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\nimport { hasBlockSupport } from '@wordpress/blocks';\n/**\n * Internal dependencies\n */\nimport Edit from './edit';\nimport {\n\tBlockEditContextProvider,\n\tuseBlockEditContext,\n\tmayDisplayControlsKey,\n\tmayDisplayParentControlsKey,\n} from './context';\n\n/**\n * The `useBlockEditContext` hook provides information about the block this hook is being used in.\n * It returns an object with the `name`, `isSelected` state, and the `clientId` of the block.\n * It is useful if you want to create custom hooks that need access to the current blocks clientId\n * but don't want to rely on the data getting passed in as a parameter.\n *\n * @return {Object} Block edit context\n */\nexport { useBlockEditContext };\n\nexport default function BlockEdit( {\n\tmayDisplayControls,\n\tmayDisplayParentControls,\n\t// The remaining props are passed through the BlockEdit filters and are thus\n\t// public API!\n\t...props\n} ) {\n\tconst {\n\t\tname,\n\t\tisSelected,\n\t\tclientId,\n\t\tattributes = {},\n\t\t__unstableLayoutClassNames,\n\t} = props;\n\tconst { layout = null } = attributes;\n\tconst layoutSupport =\n\t\thasBlockSupport( name, 'layout', false ) ||\n\t\thasBlockSupport( name, '__experimentalLayout', false );\n\treturn (\n\t\t<BlockEditContextProvider\n\t\t\t// It is important to return the same object if props haven't\n\t\t\t// changed to avoid unnecessary rerenders.\n\t\t\t// See https://reactjs.org/docs/context.html#caveats.\n\t\t\tvalue={ useMemo(\n\t\t\t\t() => ( {\n\t\t\t\t\tname,\n\t\t\t\t\tisSelected,\n\t\t\t\t\tclientId,\n\t\t\t\t\tlayout: layoutSupport ? layout : null,\n\t\t\t\t\t__unstableLayoutClassNames,\n\t\t\t\t\t// We use symbols in favour of an __unstable prefix to avoid\n\t\t\t\t\t// usage outside of the package (this context is exposed).\n\t\t\t\t\t[ mayDisplayControlsKey ]: mayDisplayControls,\n\t\t\t\t\t[ mayDisplayParentControlsKey ]: mayDisplayParentControls,\n\t\t\t\t} ),\n\t\t\t\t[\n\t\t\t\t\tname,\n\t\t\t\t\tisSelected,\n\t\t\t\t\tclientId,\n\t\t\t\t\tlayoutSupport,\n\t\t\t\t\tlayout,\n\t\t\t\t\t__unstableLayoutClassNames,\n\t\t\t\t\tmayDisplayControls,\n\t\t\t\t\tmayDisplayParentControls,\n\t\t\t\t]\n\t\t\t) }\n\t\t>\n\t\t\t<Edit { ...props } />\n\t\t</BlockEditContextProvider>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAE5C,SAASC,eAAe,QAAQ,mBAAmB;AACnD;AACA;AACA;AACA,OAAOC,IAAI,MAAM,QAAQ;AACzB,SACCC,wBAAwB,EACxBC,mBAAmB,EACnBC,qBAAqB,EACrBC,2BAA2B,QACrB,WAAW;;AAElB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASF,mBAAmB;AAE5B,eAAe,SAASG,SAASA,CAAE;EAClCC,kBAAkB;EAClBC,wBAAwB;EACxB;EACA;EACA,GAAGC;AACJ,CAAC,EAAG;EACH,MAAM;IACLC,IAAI;IACJC,UAAU;IACVC,QAAQ;IACRC,UAAU,GAAG,CAAC,CAAC;IACfC;EACD,CAAC,GAAGL,KAAK;EACT,MAAM;IAAEM,MAAM,GAAG;EAAK,CAAC,GAAGF,UAAU;EACpC,MAAMG,aAAa,GAClBhB,eAAe,CAAEU,IAAI,EAAE,QAAQ,EAAE,KAAM,CAAC,IACxCV,eAAe,CAAEU,IAAI,EAAE,sBAAsB,EAAE,KAAM,CAAC;EACvD,OACCO,aAAA,CAACf;EACA;EACA;EACA;EAAA;IACAgB,KAAK,EAAGnB,OAAO,CACd,OAAQ;MACPW,IAAI;MACJC,UAAU;MACVC,QAAQ;MACRG,MAAM,EAAEC,aAAa,GAAGD,MAAM,GAAG,IAAI;MACrCD,0BAA0B;MAC1B;MACA;MACA,CAAEV,qBAAqB,GAAIG,kBAAkB;MAC7C,CAAEF,2BAA2B,GAAIG;IAClC,CAAC,CAAE,EACH,CACCE,IAAI,EACJC,UAAU,EACVC,QAAQ,EACRI,aAAa,EACbD,MAAM,EACND,0BAA0B,EAC1BP,kBAAkB,EAClBC,wBAAwB,CAE1B;EAAG,GAEHS,aAAA,CAAChB,IAAI;IAAA,GAAMQ;EAAK,CAAI,CACK,CAAC;AAE7B"}
@@ -8,7 +8,7 @@ import { privateApis as componentsPrivateApis } from '@wordpress/components';
8
8
  * Internal dependencies
9
9
  */
10
10
  import { unlock } from '../../lock-unlock';
11
- import useDisplayBlockControls from '../use-display-block-controls';
11
+ import { useBlockEditContext, mayDisplayControlsKey } from '../block-edit/context';
12
12
  const {
13
13
  createPrivateSlotFill
14
14
  } = unlock(componentsPrivateApis);
@@ -17,8 +17,8 @@ const {
17
17
  Slot
18
18
  } = createPrivateSlotFill('BlockInformation');
19
19
  const BlockInfo = props => {
20
- const isDisplayed = useDisplayBlockControls();
21
- if (!isDisplayed) {
20
+ const context = useBlockEditContext();
21
+ if (!context[mayDisplayControlsKey]) {
22
22
  return null;
23
23
  }
24
24
  return createElement(Fill, {
@@ -1 +1 @@
1
- {"version":3,"names":["privateApis","componentsPrivateApis","unlock","useDisplayBlockControls","createPrivateSlotFill","Fill","Slot","BlockInfo","props","isDisplayed","createElement"],"sources":["@wordpress/block-editor/src/components/block-info-slot-fill/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport useDisplayBlockControls from '../use-display-block-controls';\n\nconst { createPrivateSlotFill } = unlock( componentsPrivateApis );\nconst { Fill, Slot } = createPrivateSlotFill( 'BlockInformation' );\n\nconst BlockInfo = ( props ) => {\n\tconst isDisplayed = useDisplayBlockControls();\n\tif ( ! isDisplayed ) {\n\t\treturn null;\n\t}\n\treturn <Fill { ...props } />;\n};\nBlockInfo.Slot = ( props ) => <Slot { ...props } />;\n\nexport default BlockInfo;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,qBAAqB,QAAQ,uBAAuB;;AAE5E;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,uBAAuB,MAAM,+BAA+B;AAEnE,MAAM;EAAEC;AAAsB,CAAC,GAAGF,MAAM,CAAED,qBAAsB,CAAC;AACjE,MAAM;EAAEI,IAAI;EAAEC;AAAK,CAAC,GAAGF,qBAAqB,CAAE,kBAAmB,CAAC;AAElE,MAAMG,SAAS,GAAKC,KAAK,IAAM;EAC9B,MAAMC,WAAW,GAAGN,uBAAuB,CAAC,CAAC;EAC7C,IAAK,CAAEM,WAAW,EAAG;IACpB,OAAO,IAAI;EACZ;EACA,OAAOC,aAAA,CAACL,IAAI;IAAA,GAAMG;EAAK,CAAI,CAAC;AAC7B,CAAC;AACDD,SAAS,CAACD,IAAI,GAAKE,KAAK,IAAME,aAAA,CAACJ,IAAI;EAAA,GAAME;AAAK,CAAI,CAAC;AAEnD,eAAeD,SAAS"}
1
+ {"version":3,"names":["privateApis","componentsPrivateApis","unlock","useBlockEditContext","mayDisplayControlsKey","createPrivateSlotFill","Fill","Slot","BlockInfo","props","context","createElement"],"sources":["@wordpress/block-editor/src/components/block-info-slot-fill/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport {\n\tuseBlockEditContext,\n\tmayDisplayControlsKey,\n} from '../block-edit/context';\n\nconst { createPrivateSlotFill } = unlock( componentsPrivateApis );\nconst { Fill, Slot } = createPrivateSlotFill( 'BlockInformation' );\n\nconst BlockInfo = ( props ) => {\n\tconst context = useBlockEditContext();\n\tif ( ! context[ mayDisplayControlsKey ] ) {\n\t\treturn null;\n\t}\n\treturn <Fill { ...props } />;\n};\nBlockInfo.Slot = ( props ) => <Slot { ...props } />;\n\nexport default BlockInfo;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,qBAAqB,QAAQ,uBAAuB;;AAE5E;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SACCC,mBAAmB,EACnBC,qBAAqB,QACf,uBAAuB;AAE9B,MAAM;EAAEC;AAAsB,CAAC,GAAGH,MAAM,CAAED,qBAAsB,CAAC;AACjE,MAAM;EAAEK,IAAI;EAAEC;AAAK,CAAC,GAAGF,qBAAqB,CAAE,kBAAmB,CAAC;AAElE,MAAMG,SAAS,GAAKC,KAAK,IAAM;EAC9B,MAAMC,OAAO,GAAGP,mBAAmB,CAAC,CAAC;EACrC,IAAK,CAAEO,OAAO,CAAEN,qBAAqB,CAAE,EAAG;IACzC,OAAO,IAAI;EACZ;EACA,OAAOO,aAAA,CAACL,IAAI;IAAA,GAAMG;EAAK,CAAI,CAAC;AAC7B,CAAC;AACDD,SAAS,CAACD,IAAI,GAAKE,KAAK,IAAME,aAAA,CAACJ,IAAI;EAAA,GAAME;AAAK,CAAI,CAAC;AAEnD,eAAeD,SAAS"}