@wordpress/block-editor 12.16.1-next.79a6196f.0 → 12.18.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 (376) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +32 -0
  3. package/build/components/block-draggable/index.js +11 -3
  4. package/build/components/block-draggable/index.js.map +1 -1
  5. package/build/components/block-edit/context.js +3 -1
  6. package/build/components/block-edit/context.js.map +1 -1
  7. package/build/components/block-edit/index.js +4 -2
  8. package/build/components/block-edit/index.js.map +1 -1
  9. package/build/components/block-editing-mode/index.js +6 -3
  10. package/build/components/block-editing-mode/index.js.map +1 -1
  11. package/build/components/block-inspector/index.js +5 -2
  12. package/build/components/block-inspector/index.js.map +1 -1
  13. package/build/components/block-list/block.js +4 -3
  14. package/build/components/block-list/block.js.map +1 -1
  15. package/build/components/block-list/block.native.js +9 -5
  16. package/build/components/block-list/block.native.js.map +1 -1
  17. package/build/components/block-list/index.js +30 -4
  18. package/build/components/block-list/index.js.map +1 -1
  19. package/build/components/block-list/private-block-context.js +1 -1
  20. package/build/components/block-list/private-block-context.js.map +1 -1
  21. package/build/components/block-list/use-in-between-inserter.js +1 -1
  22. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  23. package/build/components/block-popover/inbetween.js +15 -3
  24. package/build/components/block-popover/inbetween.js.map +1 -1
  25. package/build/components/block-preview/auto.js +1 -1
  26. package/build/components/block-preview/auto.js.map +1 -1
  27. package/build/components/block-removal-warning-modal/index.js +3 -2
  28. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  29. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -4
  30. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  31. package/build/components/block-switcher/block-transformations-menu.js +12 -1
  32. package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
  33. package/build/components/block-switcher/index.js +119 -90
  34. package/build/components/block-switcher/index.js.map +1 -1
  35. package/build/components/block-tools/insertion-point.js +10 -3
  36. package/build/components/block-tools/insertion-point.js.map +1 -1
  37. package/build/components/font-sizes/fluid-utils.js +7 -1
  38. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  39. package/build/components/global-styles/border-panel.js +5 -14
  40. package/build/components/global-styles/border-panel.js.map +1 -1
  41. package/build/components/global-styles/effects-panel.js +7 -1
  42. package/build/components/global-styles/effects-panel.js.map +1 -1
  43. package/build/components/iframe/get-compatibility-styles.js +99 -0
  44. package/build/components/iframe/get-compatibility-styles.js.map +1 -0
  45. package/build/components/iframe/index.js +2 -3
  46. package/build/components/iframe/index.js.map +1 -1
  47. package/build/components/index.js +16 -2
  48. package/build/components/index.js.map +1 -1
  49. package/build/components/index.native.js +16 -2
  50. package/build/components/index.native.js.map +1 -1
  51. package/build/components/inspector-controls/groups.js +2 -0
  52. package/build/components/inspector-controls/groups.js.map +1 -1
  53. package/build/components/inspector-controls-tabs/styles-tab.js +3 -0
  54. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  55. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -2
  56. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  57. package/build/components/link-control/link-preview.js +30 -26
  58. package/build/components/link-control/link-preview.js.map +1 -1
  59. package/build/components/link-control/search-input.js +1 -9
  60. package/build/components/link-control/search-input.js.map +1 -1
  61. package/build/components/list-view/block-contents.js +3 -1
  62. package/build/components/list-view/block-contents.js.map +1 -1
  63. package/build/components/list-view/block.js +10 -1
  64. package/build/components/list-view/block.js.map +1 -1
  65. package/build/components/list-view/branch.js +29 -8
  66. package/build/components/list-view/branch.js.map +1 -1
  67. package/build/components/list-view/drop-indicator.js +100 -32
  68. package/build/components/list-view/drop-indicator.js.map +1 -1
  69. package/build/components/list-view/index.js +52 -4
  70. package/build/components/list-view/index.js.map +1 -1
  71. package/build/components/list-view/leaf.js +2 -2
  72. package/build/components/list-view/leaf.js.map +1 -1
  73. package/build/components/list-view/use-list-view-block-indexes.js +30 -0
  74. package/build/components/list-view/use-list-view-block-indexes.js.map +1 -0
  75. package/build/components/list-view/use-list-view-drop-zone.js +56 -5
  76. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  77. package/build/components/list-view/utils.js +92 -0
  78. package/build/components/list-view/utils.js.map +1 -1
  79. package/build/components/provider/index.js +1 -1
  80. package/build/components/provider/index.js.map +1 -1
  81. package/build/components/recursion-provider/index.js +21 -0
  82. package/build/components/recursion-provider/index.js.map +1 -1
  83. package/build/components/rich-text/index.js +30 -6
  84. package/build/components/rich-text/index.js.map +1 -1
  85. package/build/components/rich-text/native/index.native.js +9 -9
  86. package/build/components/rich-text/native/index.native.js.map +1 -1
  87. package/build/components/use-block-drop-zone/index.js +30 -7
  88. package/build/components/use-block-drop-zone/index.js.map +1 -1
  89. package/build/components/use-on-block-drop/index.js +50 -8
  90. package/build/components/use-on-block-drop/index.js.map +1 -1
  91. package/build/hooks/block-hooks.js +5 -14
  92. package/build/hooks/block-hooks.js.map +1 -1
  93. package/build/hooks/content-lock-ui.js +17 -42
  94. package/build/hooks/content-lock-ui.js.map +1 -1
  95. package/build/hooks/effects.js +66 -0
  96. package/build/hooks/effects.js.map +1 -0
  97. package/build/hooks/index.js +14 -0
  98. package/build/hooks/index.js.map +1 -1
  99. package/build/hooks/index.native.js +13 -0
  100. package/build/hooks/index.native.js.map +1 -1
  101. package/build/hooks/style.js +6 -2
  102. package/build/hooks/style.js.map +1 -1
  103. package/build/hooks/supports.js +2 -1
  104. package/build/hooks/supports.js.map +1 -1
  105. package/build/hooks/typography.native.js +2 -2
  106. package/build/hooks/typography.native.js.map +1 -1
  107. package/build/hooks/use-bindings-attributes.js +115 -0
  108. package/build/hooks/use-bindings-attributes.js.map +1 -0
  109. package/build/hooks/use-shadow-props.js +46 -0
  110. package/build/hooks/use-shadow-props.js.map +1 -0
  111. package/build/hooks/utils.js +7 -6
  112. package/build/hooks/utils.js.map +1 -1
  113. package/build/index.js +14 -0
  114. package/build/index.js.map +1 -1
  115. package/build/store/actions.js +10 -6
  116. package/build/store/actions.js.map +1 -1
  117. package/build/store/index.js +2 -0
  118. package/build/store/index.js.map +1 -1
  119. package/build/store/private-actions.js +37 -0
  120. package/build/store/private-actions.js.map +1 -1
  121. package/build/store/private-selectors.js +60 -9
  122. package/build/store/private-selectors.js.map +1 -1
  123. package/build/store/reducer.js +44 -3
  124. package/build/store/reducer.js.map +1 -1
  125. package/build/store/resolvers.js +27 -0
  126. package/build/store/resolvers.js.map +1 -0
  127. package/build/store/selectors.js +94 -56
  128. package/build/store/selectors.js.map +1 -1
  129. package/build/store/utils.js +5 -26
  130. package/build/store/utils.js.map +1 -1
  131. package/build/utils/index.js +0 -16
  132. package/build/utils/index.js.map +1 -1
  133. package/build/utils/math.js +13 -0
  134. package/build/utils/math.js.map +1 -1
  135. package/build/utils/transform-styles/index.js +37 -27
  136. package/build/utils/transform-styles/index.js.map +1 -1
  137. package/build-module/components/block-draggable/index.js +11 -3
  138. package/build-module/components/block-draggable/index.js.map +1 -1
  139. package/build-module/components/block-edit/context.js +1 -0
  140. package/build-module/components/block-edit/context.js.map +1 -1
  141. package/build-module/components/block-edit/index.js +5 -3
  142. package/build-module/components/block-edit/index.js.map +1 -1
  143. package/build-module/components/block-editing-mode/index.js +7 -4
  144. package/build-module/components/block-editing-mode/index.js.map +1 -1
  145. package/build-module/components/block-inspector/index.js +5 -2
  146. package/build-module/components/block-inspector/index.js.map +1 -1
  147. package/build-module/components/block-list/block.js +6 -5
  148. package/build-module/components/block-list/block.js.map +1 -1
  149. package/build-module/components/block-list/block.native.js +11 -7
  150. package/build-module/components/block-list/block.native.js.map +1 -1
  151. package/build-module/components/block-list/index.js +31 -5
  152. package/build-module/components/block-list/index.js.map +1 -1
  153. package/build-module/components/block-list/private-block-context.js +1 -1
  154. package/build-module/components/block-list/private-block-context.js.map +1 -1
  155. package/build-module/components/block-list/use-in-between-inserter.js +1 -1
  156. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  157. package/build-module/components/block-popover/inbetween.js +15 -3
  158. package/build-module/components/block-popover/inbetween.js.map +1 -1
  159. package/build-module/components/block-preview/auto.js +3 -3
  160. package/build-module/components/block-preview/auto.js.map +1 -1
  161. package/build-module/components/block-removal-warning-modal/index.js +3 -2
  162. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  163. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -4
  164. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  165. package/build-module/components/block-switcher/block-transformations-menu.js +12 -1
  166. package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
  167. package/build-module/components/block-switcher/index.js +116 -86
  168. package/build-module/components/block-switcher/index.js.map +1 -1
  169. package/build-module/components/block-tools/insertion-point.js +10 -3
  170. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  171. package/build-module/components/font-sizes/fluid-utils.js +7 -1
  172. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  173. package/build-module/components/global-styles/border-panel.js +5 -14
  174. package/build-module/components/global-styles/border-panel.js.map +1 -1
  175. package/build-module/components/global-styles/effects-panel.js +7 -1
  176. package/build-module/components/global-styles/effects-panel.js.map +1 -1
  177. package/build-module/components/iframe/get-compatibility-styles.js +93 -0
  178. package/build-module/components/iframe/get-compatibility-styles.js.map +1 -0
  179. package/build-module/components/iframe/index.js +2 -3
  180. package/build-module/components/iframe/index.js.map +1 -1
  181. package/build-module/components/index.js +1 -1
  182. package/build-module/components/index.js.map +1 -1
  183. package/build-module/components/index.native.js +1 -1
  184. package/build-module/components/index.native.js.map +1 -1
  185. package/build-module/components/inspector-controls/groups.js +2 -0
  186. package/build-module/components/inspector-controls/groups.js.map +1 -1
  187. package/build-module/components/inspector-controls-tabs/styles-tab.js +3 -0
  188. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  189. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -2
  190. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  191. package/build-module/components/link-control/link-preview.js +32 -28
  192. package/build-module/components/link-control/link-preview.js.map +1 -1
  193. package/build-module/components/link-control/search-input.js +1 -8
  194. package/build-module/components/link-control/search-input.js.map +1 -1
  195. package/build-module/components/list-view/block-contents.js +3 -1
  196. package/build-module/components/list-view/block-contents.js.map +1 -1
  197. package/build-module/components/list-view/block.js +10 -1
  198. package/build-module/components/list-view/block.js.map +1 -1
  199. package/build-module/components/list-view/branch.js +30 -9
  200. package/build-module/components/list-view/branch.js.map +1 -1
  201. package/build-module/components/list-view/drop-indicator.js +99 -32
  202. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  203. package/build-module/components/list-view/index.js +54 -6
  204. package/build-module/components/list-view/index.js.map +1 -1
  205. package/build-module/components/list-view/leaf.js +2 -2
  206. package/build-module/components/list-view/leaf.js.map +1 -1
  207. package/build-module/components/list-view/use-list-view-block-indexes.js +23 -0
  208. package/build-module/components/list-view/use-list-view-block-indexes.js.map +1 -0
  209. package/build-module/components/list-view/use-list-view-drop-zone.js +58 -7
  210. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  211. package/build-module/components/list-view/utils.js +91 -0
  212. package/build-module/components/list-view/utils.js.map +1 -1
  213. package/build-module/components/provider/index.js +1 -1
  214. package/build-module/components/provider/index.js.map +1 -1
  215. package/build-module/components/recursion-provider/index.js +17 -0
  216. package/build-module/components/recursion-provider/index.js.map +1 -1
  217. package/build-module/components/rich-text/index.js +30 -6
  218. package/build-module/components/rich-text/index.js.map +1 -1
  219. package/build-module/components/rich-text/native/index.native.js +9 -9
  220. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  221. package/build-module/components/use-block-drop-zone/index.js +31 -8
  222. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  223. package/build-module/components/use-on-block-drop/index.js +51 -9
  224. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  225. package/build-module/hooks/block-hooks.js +5 -14
  226. package/build-module/hooks/block-hooks.js.map +1 -1
  227. package/build-module/hooks/content-lock-ui.js +19 -43
  228. package/build-module/hooks/content-lock-ui.js.map +1 -1
  229. package/build-module/hooks/effects.js +51 -0
  230. package/build-module/hooks/effects.js.map +1 -0
  231. package/build-module/hooks/index.js +2 -0
  232. package/build-module/hooks/index.js.map +1 -1
  233. package/build-module/hooks/index.native.js +1 -0
  234. package/build-module/hooks/index.native.js.map +1 -1
  235. package/build-module/hooks/style.js +6 -2
  236. package/build-module/hooks/style.js.map +1 -1
  237. package/build-module/hooks/supports.js +2 -1
  238. package/build-module/hooks/supports.js.map +1 -1
  239. package/build-module/hooks/typography.native.js +2 -2
  240. package/build-module/hooks/typography.native.js.map +1 -1
  241. package/build-module/hooks/use-bindings-attributes.js +112 -0
  242. package/build-module/hooks/use-bindings-attributes.js.map +1 -0
  243. package/build-module/hooks/use-shadow-props.js +39 -0
  244. package/build-module/hooks/use-shadow-props.js.map +1 -0
  245. package/build-module/hooks/utils.js +9 -8
  246. package/build-module/hooks/utils.js.map +1 -1
  247. package/build-module/index.js +1 -1
  248. package/build-module/index.js.map +1 -1
  249. package/build-module/store/actions.js +10 -6
  250. package/build-module/store/actions.js.map +1 -1
  251. package/build-module/store/index.js +2 -0
  252. package/build-module/store/index.js.map +1 -1
  253. package/build-module/store/private-actions.js +35 -0
  254. package/build-module/store/private-actions.js.map +1 -1
  255. package/build-module/store/private-selectors.js +53 -8
  256. package/build-module/store/private-selectors.js.map +1 -1
  257. package/build-module/store/reducer.js +43 -3
  258. package/build-module/store/reducer.js.map +1 -1
  259. package/build-module/store/resolvers.js +20 -0
  260. package/build-module/store/resolvers.js.map +1 -0
  261. package/build-module/store/selectors.js +89 -52
  262. package/build-module/store/selectors.js.map +1 -1
  263. package/build-module/store/utils.js +3 -23
  264. package/build-module/store/utils.js.map +1 -1
  265. package/build-module/utils/index.js +0 -1
  266. package/build-module/utils/index.js.map +1 -1
  267. package/build-module/utils/math.js +12 -0
  268. package/build-module/utils/math.js.map +1 -1
  269. package/build-module/utils/transform-styles/index.js +36 -27
  270. package/build-module/utils/transform-styles/index.js.map +1 -1
  271. package/build-style/content-rtl.css +33 -16
  272. package/build-style/content.css +33 -16
  273. package/build-style/default-editor-styles-rtl.css +1 -1
  274. package/build-style/default-editor-styles.css +1 -1
  275. package/build-style/style-rtl.css +169 -114
  276. package/build-style/style.css +169 -114
  277. package/package.json +31 -31
  278. package/src/components/block-canvas/style.scss +8 -1
  279. package/src/components/block-draggable/index.js +16 -5
  280. package/src/components/block-edit/context.js +1 -0
  281. package/src/components/block-edit/index.js +4 -0
  282. package/src/components/block-editing-mode/index.js +12 -7
  283. package/src/components/block-inspector/index.js +5 -2
  284. package/src/components/block-list/block.js +5 -4
  285. package/src/components/block-list/block.native.js +13 -3
  286. package/src/components/block-list/content.scss +34 -5
  287. package/src/components/block-list/index.js +52 -16
  288. package/src/components/block-list/private-block-context.js +1 -1
  289. package/src/components/block-list/use-in-between-inserter.js +1 -2
  290. package/src/components/block-popover/inbetween.js +22 -2
  291. package/src/components/block-preview/auto.js +3 -3
  292. package/src/components/block-removal-warning-modal/index.js +3 -2
  293. package/src/components/block-settings-menu/block-settings-dropdown.js +2 -7
  294. package/src/components/block-switcher/block-transformations-menu.js +18 -1
  295. package/src/components/block-switcher/index.js +133 -111
  296. package/src/components/block-switcher/style.scss +6 -4
  297. package/src/components/block-switcher/test/index.js +113 -230
  298. package/src/components/block-toolbar/style.scss +22 -18
  299. package/src/components/block-tools/insertion-point.js +15 -2
  300. package/src/components/block-tools/style.scss +8 -7
  301. package/src/components/font-sizes/fluid-utils.js +8 -2
  302. package/src/components/font-sizes/test/fluid-utils.js +9 -0
  303. package/src/components/global-styles/border-panel.js +7 -17
  304. package/src/components/global-styles/effects-panel.js +16 -1
  305. package/src/components/iframe/get-compatibility-styles.js +120 -0
  306. package/src/components/iframe/index.js +2 -3
  307. package/src/components/index.js +4 -2
  308. package/src/components/index.native.js +4 -2
  309. package/src/components/inspector-controls/groups.js +2 -0
  310. package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
  311. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -0
  312. package/src/components/link-control/link-preview.js +31 -55
  313. package/src/components/link-control/search-input.js +1 -9
  314. package/src/components/link-control/style.scss +31 -85
  315. package/src/components/link-control/test/index.js +2 -1
  316. package/src/components/list-view/block-contents.js +5 -1
  317. package/src/components/list-view/block.js +9 -0
  318. package/src/components/list-view/branch.js +30 -10
  319. package/src/components/list-view/drop-indicator.js +139 -46
  320. package/src/components/list-view/index.js +74 -3
  321. package/src/components/list-view/leaf.js +2 -2
  322. package/src/components/list-view/style.scss +102 -13
  323. package/src/components/list-view/test/use-list-view-drop-zone.js +4 -0
  324. package/src/components/list-view/test/utils.js +218 -1
  325. package/src/components/list-view/use-list-view-block-indexes.js +29 -0
  326. package/src/components/list-view/use-list-view-drop-zone.js +78 -6
  327. package/src/components/list-view/utils.js +116 -0
  328. package/src/components/provider/index.js +3 -1
  329. package/src/components/recursion-provider/README.md +2 -2
  330. package/src/components/recursion-provider/index.js +17 -0
  331. package/src/components/rich-text/index.js +48 -10
  332. package/src/components/rich-text/native/index.native.js +10 -10
  333. package/src/components/use-block-drop-zone/index.js +60 -19
  334. package/src/components/use-block-drop-zone/test/index.js +32 -61
  335. package/src/components/use-on-block-drop/index.js +92 -11
  336. package/src/hooks/block-hooks.js +5 -17
  337. package/src/hooks/content-lock-ui.js +15 -55
  338. package/src/hooks/effects.js +57 -0
  339. package/src/hooks/index.js +2 -0
  340. package/src/hooks/index.native.js +1 -0
  341. package/src/hooks/style.js +8 -0
  342. package/src/hooks/supports.js +2 -0
  343. package/src/hooks/test/effects.js +39 -0
  344. package/src/hooks/typography.native.js +2 -2
  345. package/src/hooks/use-bindings-attributes.js +148 -0
  346. package/src/hooks/use-shadow-props.js +37 -0
  347. package/src/hooks/utils.js +10 -6
  348. package/src/index.js +2 -0
  349. package/src/store/actions.js +9 -4
  350. package/src/store/index.js +2 -0
  351. package/src/store/private-actions.js +32 -0
  352. package/src/store/private-selectors.js +78 -21
  353. package/src/store/reducer.js +49 -2
  354. package/src/store/resolvers.js +17 -0
  355. package/src/store/selectors.js +169 -161
  356. package/src/store/test/registry-selectors.js +431 -0
  357. package/src/store/test/selectors.js +14 -400
  358. package/src/store/utils.js +10 -33
  359. package/src/style.scss +0 -1
  360. package/src/utils/index.js +0 -1
  361. package/src/utils/math.js +12 -0
  362. package/src/utils/transform-styles/index.js +52 -37
  363. package/tsconfig.tsbuildinfo +1 -1
  364. package/build/components/iframe/use-compatibility-styles.js +0 -100
  365. package/build/components/iframe/use-compatibility-styles.js.map +0 -1
  366. package/build/utils/block-variation-transforms.js +0 -42
  367. package/build/utils/block-variation-transforms.js.map +0 -1
  368. package/build-module/components/iframe/use-compatibility-styles.js +0 -94
  369. package/build-module/components/iframe/use-compatibility-styles.js.map +0 -1
  370. package/build-module/utils/block-variation-transforms.js +0 -35
  371. package/build-module/utils/block-variation-transforms.js.map +0 -1
  372. package/src/components/block-switcher/test/__snapshots__/index.js.snap +0 -116
  373. package/src/components/contrast-checker/style.scss +0 -3
  374. package/src/components/iframe/use-compatibility-styles.js +0 -122
  375. package/src/utils/block-variation-transforms.js +0 -38
  376. package/src/utils/test/block-variation-transforms.js +0 -94
@@ -3,32 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
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.INSERTER_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
- }
6
+ exports.getAllPatternsDependants = exports.checkAllowListRecursive = exports.checkAllowList = void 0;
32
7
  const checkAllowList = (list, item, defaultResult = null) => {
33
8
  if (typeof list === 'boolean') {
34
9
  return list;
@@ -63,4 +38,8 @@ const checkAllowListRecursive = (blocks, allowedBlockTypes) => {
63
38
  return true;
64
39
  };
65
40
  exports.checkAllowListRecursive = checkAllowListRecursive;
41
+ const getAllPatternsDependants = state => {
42
+ return [state.settings.__experimentalBlockPatterns, state.settings.__experimentalUserPatternCategories, state.settings.__experimentalReusableBlocks, state.settings.__experimentalFetchBlockPatterns, state.blockPatterns];
43
+ };
44
+ exports.getAllPatternsDependants = getAllPatternsDependants;
66
45
  //# sourceMappingURL=utils.js.map
@@ -1 +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","INSERTER_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 { INSERTER_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: INSERTER_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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defaultResult","Array","isArray","includes","exports","checkAllowListRecursive","blocks","allowedBlockTypes","blocksQueue","length","block","shift","isAllowed","name","blockName","innerBlocks","forEach","innerBlock","push","getAllPatternsDependants","state","settings","__experimentalBlockPatterns","__experimentalUserPatternCategories","__experimentalReusableBlocks","__experimentalFetchBlockPatterns","blockPatterns"],"sources":["@wordpress/block-editor/src/store/utils.js"],"sourcesContent":["export 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\nexport const getAllPatternsDependants = ( state ) => {\n\treturn [\n\t\tstate.settings.__experimentalBlockPatterns,\n\t\tstate.settings.__experimentalUserPatternCategories,\n\t\tstate.settings.__experimentalReusableBlocks,\n\t\tstate.settings.__experimentalFetchBlockPatterns,\n\t\tstate.blockPatterns,\n\t];\n};\n"],"mappings":";;;;;;AAAO,MAAMA,cAAc,GAAGA,CAAEC,IAA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H,KAAK,CAACC,QAAQ,CAACG,4BAA4B,EAC3CJ,KAAK,CAACC,QAAQ,CAACI,gCAAgC,EAC/CL,KAAK,CAACM,aAAa,CACnB;AACF,CAAC;AAACtB,OAAA,CAAAe,wBAAA,GAAAA,wBAAA"}
@@ -4,10 +4,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- var _exportNames = {
8
- transformStyles: true,
9
- getPxFromCssUnit: true
10
- };
11
7
  Object.defineProperty(exports, "getPxFromCssUnit", {
12
8
  enumerable: true,
13
9
  get: function () {
@@ -21,17 +17,5 @@ Object.defineProperty(exports, "transformStyles", {
21
17
  }
22
18
  });
23
19
  var _transformStyles = _interopRequireDefault(require("./transform-styles"));
24
- var _blockVariationTransforms = require("./block-variation-transforms");
25
- Object.keys(_blockVariationTransforms).forEach(function (key) {
26
- if (key === "default" || key === "__esModule") return;
27
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
28
- if (key in exports && exports[key] === _blockVariationTransforms[key]) return;
29
- Object.defineProperty(exports, key, {
30
- enumerable: true,
31
- get: function () {
32
- return _blockVariationTransforms[key];
33
- }
34
- });
35
- });
36
20
  var _getPxFromCssUnit = _interopRequireDefault(require("./get-px-from-css-unit"));
37
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_transformStyles","_interopRequireDefault","require","_blockVariationTransforms","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_getPxFromCssUnit"],"sources":["@wordpress/block-editor/src/utils/index.js"],"sourcesContent":["export { default as transformStyles } from './transform-styles';\nexport * from './block-variation-transforms';\nexport { default as getPxFromCssUnit } from './get-px-from-css-unit';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,yBAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,yBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,yBAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,yBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,iBAAA,GAAAf,sBAAA,CAAAC,OAAA"}
1
+ {"version":3,"names":["_transformStyles","_interopRequireDefault","require","_getPxFromCssUnit"],"sources":["@wordpress/block-editor/src/utils/index.js"],"sourcesContent":["export { default as transformStyles } from './transform-styles';\nexport { default as getPxFromCssUnit } from './get-px-from-css-unit';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAF,sBAAA,CAAAC,OAAA"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getDistanceFromPointToEdge = getDistanceFromPointToEdge;
7
7
  exports.getDistanceToNearestEdge = getDistanceToNearestEdge;
8
8
  exports.isPointContainedByRect = isPointContainedByRect;
9
+ exports.isPointWithinTopAndBottomBoundariesOfRect = isPointWithinTopAndBottomBoundariesOfRect;
9
10
  /**
10
11
  * A string representing the name of an edge.
11
12
  *
@@ -98,4 +99,16 @@ function getDistanceToNearestEdge(point, rect, allowedEdges = ['top', 'bottom',
98
99
  function isPointContainedByRect(point, rect) {
99
100
  return rect.left <= point.x && rect.right >= point.x && rect.top <= point.y && rect.bottom >= point.y;
100
101
  }
102
+
103
+ /**
104
+ * Is the point within the top and bottom boundaries of the rectangle.
105
+ *
106
+ * @param {WPPoint} point The point.
107
+ * @param {DOMRect} rect The rectangle.
108
+ *
109
+ * @return {boolean} True if the point is within top and bottom of rectangle, false otherwise.
110
+ */
111
+ function isPointWithinTopAndBottomBoundariesOfRect(point, rect) {
112
+ return rect.top <= point.y && rect.bottom >= point.y;
113
+ }
101
114
  //# sourceMappingURL=math.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getDistanceFromPointToEdge","point","rect","edge","isHorizontal","x","y","pointLateralPosition","pointForwardPosition","edgeStart","left","top","edgeEnd","right","bottom","edgeForwardPosition","edgeLateralPosition","Math","sqrt","getDistanceToNearestEdge","allowedEdges","candidateDistance","candidateEdge","forEach","distance","undefined","isPointContainedByRect"],"sources":["@wordpress/block-editor/src/utils/math.js"],"sourcesContent":["/**\n * A string representing the name of an edge.\n *\n * @typedef {'top'|'right'|'bottom'|'left'} WPEdgeName\n */\n\n/**\n * @typedef {Object} WPPoint\n * @property {number} x The horizontal position.\n * @property {number} y The vertical position.\n */\n\n/**\n * Given a point, a DOMRect and the name of an edge, returns the distance to\n * that edge of the rect.\n *\n * This function works for edges that are horizontal or vertical (e.g. not\n * rotated), the following terms are used so that the function works in both\n * orientations:\n *\n * - Forward, meaning the axis running horizontally when an edge is vertical\n * and vertically when an edge is horizontal.\n * - Lateral, meaning the axis running vertically when an edge is vertical\n * and horizontally when an edge is horizontal.\n *\n * @param {WPPoint} point The point to measure distance from.\n * @param {DOMRect} rect A DOM Rect containing edge positions.\n * @param {WPEdgeName} edge The edge to measure to.\n */\nexport function getDistanceFromPointToEdge( point, rect, edge ) {\n\tconst isHorizontal = edge === 'top' || edge === 'bottom';\n\tconst { x, y } = point;\n\tconst pointLateralPosition = isHorizontal ? x : y;\n\tconst pointForwardPosition = isHorizontal ? y : x;\n\tconst edgeStart = isHorizontal ? rect.left : rect.top;\n\tconst edgeEnd = isHorizontal ? rect.right : rect.bottom;\n\tconst edgeForwardPosition = rect[ edge ];\n\n\t// Measure the straight line distance to the edge of the rect, when the\n\t// point is adjacent to the edge.\n\t// Else, if the point is positioned diagonally to the edge of the rect,\n\t// measure diagonally to the nearest corner that the edge meets.\n\tlet edgeLateralPosition;\n\tif (\n\t\tpointLateralPosition >= edgeStart &&\n\t\tpointLateralPosition <= edgeEnd\n\t) {\n\t\tedgeLateralPosition = pointLateralPosition;\n\t} else if ( pointLateralPosition < edgeEnd ) {\n\t\tedgeLateralPosition = edgeStart;\n\t} else {\n\t\tedgeLateralPosition = edgeEnd;\n\t}\n\n\treturn Math.sqrt(\n\t\t( pointLateralPosition - edgeLateralPosition ) ** 2 +\n\t\t\t( pointForwardPosition - edgeForwardPosition ) ** 2\n\t);\n}\n\n/**\n * Given a point, a DOMRect and a list of allowed edges returns the name of and\n * distance to the nearest edge.\n *\n * @param {WPPoint} point The point to measure distance from.\n * @param {DOMRect} rect A DOM Rect containing edge positions.\n * @param {WPEdgeName[]} allowedEdges A list of the edges included in the\n * calculation. Defaults to all edges.\n *\n * @return {[number, string]} An array where the first value is the distance\n * and a second is the edge name.\n */\nexport function getDistanceToNearestEdge(\n\tpoint,\n\trect,\n\tallowedEdges = [ 'top', 'bottom', 'left', 'right' ]\n) {\n\tlet candidateDistance;\n\tlet candidateEdge;\n\n\tallowedEdges.forEach( ( edge ) => {\n\t\tconst distance = getDistanceFromPointToEdge( point, rect, edge );\n\n\t\tif ( candidateDistance === undefined || distance < candidateDistance ) {\n\t\t\tcandidateDistance = distance;\n\t\t\tcandidateEdge = edge;\n\t\t}\n\t} );\n\n\treturn [ candidateDistance, candidateEdge ];\n}\n\n/**\n * Is the point contained by the rectangle.\n *\n * @param {WPPoint} point The point.\n * @param {DOMRect} rect The rectangle.\n *\n * @return {boolean} True if the point is contained by the rectangle, false otherwise.\n */\nexport function isPointContainedByRect( point, rect ) {\n\treturn (\n\t\trect.left <= point.x &&\n\t\trect.right >= point.x &&\n\t\trect.top <= point.y &&\n\t\trect.bottom >= point.y\n\t);\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;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AAM,EAAE,OAAO,CAAE,EAClD;EACD,IAAIC,iBAAiB;EACrB,IAAIC,aAAa;EAEjBF,YAAY,CAACG,OAAO,CAAIpB,IAAI,IAAM;IACjC,MAAMqB,QAAQ,GAAGxB,0BAA0B,CAAEC,KAAK,EAAEC,IAAI,EAAEC,IAAK,CAAC;IAEhE,IAAKkB,iBAAiB,KAAKI,SAAS,IAAID,QAAQ,GAAGH,iBAAiB,EAAG;MACtEA,iBAAiB,GAAGG,QAAQ;MAC5BF,aAAa,GAAGnB,IAAI;IACrB;EACD,CAAE,CAAC;EAEH,OAAO,CAAEkB,iBAAiB,EAAEC,aAAa,CAAE;AAC5C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,sBAAsBA,CAAEzB,KAAK,EAAEC,IAAI,EAAG;EACrD,OACCA,IAAI,CAACQ,IAAI,IAAIT,KAAK,CAACI,CAAC,IACpBH,IAAI,CAACW,KAAK,IAAIZ,KAAK,CAACI,CAAC,IACrBH,IAAI,CAACS,GAAG,IAAIV,KAAK,CAACK,CAAC,IACnBJ,IAAI,CAACY,MAAM,IAAIb,KAAK,CAACK,CAAC;AAExB"}
1
+ {"version":3,"names":["getDistanceFromPointToEdge","point","rect","edge","isHorizontal","x","y","pointLateralPosition","pointForwardPosition","edgeStart","left","top","edgeEnd","right","bottom","edgeForwardPosition","edgeLateralPosition","Math","sqrt","getDistanceToNearestEdge","allowedEdges","candidateDistance","candidateEdge","forEach","distance","undefined","isPointContainedByRect","isPointWithinTopAndBottomBoundariesOfRect"],"sources":["@wordpress/block-editor/src/utils/math.js"],"sourcesContent":["/**\n * A string representing the name of an edge.\n *\n * @typedef {'top'|'right'|'bottom'|'left'} WPEdgeName\n */\n\n/**\n * @typedef {Object} WPPoint\n * @property {number} x The horizontal position.\n * @property {number} y The vertical position.\n */\n\n/**\n * Given a point, a DOMRect and the name of an edge, returns the distance to\n * that edge of the rect.\n *\n * This function works for edges that are horizontal or vertical (e.g. not\n * rotated), the following terms are used so that the function works in both\n * orientations:\n *\n * - Forward, meaning the axis running horizontally when an edge is vertical\n * and vertically when an edge is horizontal.\n * - Lateral, meaning the axis running vertically when an edge is vertical\n * and horizontally when an edge is horizontal.\n *\n * @param {WPPoint} point The point to measure distance from.\n * @param {DOMRect} rect A DOM Rect containing edge positions.\n * @param {WPEdgeName} edge The edge to measure to.\n */\nexport function getDistanceFromPointToEdge( point, rect, edge ) {\n\tconst isHorizontal = edge === 'top' || edge === 'bottom';\n\tconst { x, y } = point;\n\tconst pointLateralPosition = isHorizontal ? x : y;\n\tconst pointForwardPosition = isHorizontal ? y : x;\n\tconst edgeStart = isHorizontal ? rect.left : rect.top;\n\tconst edgeEnd = isHorizontal ? rect.right : rect.bottom;\n\tconst edgeForwardPosition = rect[ edge ];\n\n\t// Measure the straight line distance to the edge of the rect, when the\n\t// point is adjacent to the edge.\n\t// Else, if the point is positioned diagonally to the edge of the rect,\n\t// measure diagonally to the nearest corner that the edge meets.\n\tlet edgeLateralPosition;\n\tif (\n\t\tpointLateralPosition >= edgeStart &&\n\t\tpointLateralPosition <= edgeEnd\n\t) {\n\t\tedgeLateralPosition = pointLateralPosition;\n\t} else if ( pointLateralPosition < edgeEnd ) {\n\t\tedgeLateralPosition = edgeStart;\n\t} else {\n\t\tedgeLateralPosition = edgeEnd;\n\t}\n\n\treturn Math.sqrt(\n\t\t( pointLateralPosition - edgeLateralPosition ) ** 2 +\n\t\t\t( pointForwardPosition - edgeForwardPosition ) ** 2\n\t);\n}\n\n/**\n * Given a point, a DOMRect and a list of allowed edges returns the name of and\n * distance to the nearest edge.\n *\n * @param {WPPoint} point The point to measure distance from.\n * @param {DOMRect} rect A DOM Rect containing edge positions.\n * @param {WPEdgeName[]} allowedEdges A list of the edges included in the\n * calculation. Defaults to all edges.\n *\n * @return {[number, string]} An array where the first value is the distance\n * and a second is the edge name.\n */\nexport function getDistanceToNearestEdge(\n\tpoint,\n\trect,\n\tallowedEdges = [ 'top', 'bottom', 'left', 'right' ]\n) {\n\tlet candidateDistance;\n\tlet candidateEdge;\n\n\tallowedEdges.forEach( ( edge ) => {\n\t\tconst distance = getDistanceFromPointToEdge( point, rect, edge );\n\n\t\tif ( candidateDistance === undefined || distance < candidateDistance ) {\n\t\t\tcandidateDistance = distance;\n\t\t\tcandidateEdge = edge;\n\t\t}\n\t} );\n\n\treturn [ candidateDistance, candidateEdge ];\n}\n\n/**\n * Is the point contained by the rectangle.\n *\n * @param {WPPoint} point The point.\n * @param {DOMRect} rect The rectangle.\n *\n * @return {boolean} True if the point is contained by the rectangle, false otherwise.\n */\nexport function isPointContainedByRect( point, rect ) {\n\treturn (\n\t\trect.left <= point.x &&\n\t\trect.right >= point.x &&\n\t\trect.top <= point.y &&\n\t\trect.bottom >= point.y\n\t);\n}\n\n/**\n * Is the point within the top and bottom boundaries of the rectangle.\n *\n * @param {WPPoint} point The point.\n * @param {DOMRect} rect The rectangle.\n *\n * @return {boolean} True if the point is within top and bottom of rectangle, false otherwise.\n */\nexport function isPointWithinTopAndBottomBoundariesOfRect( point, rect ) {\n\treturn rect.top <= point.y && rect.bottom >= point.y;\n}\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,0BAA0BA,CAAEC,KAAK,EAAEC,IAAI,EAAEC,IAAI,EAAG;EAC/D,MAAMC,YAAY,GAAGD,IAAI,KAAK,KAAK,IAAIA,IAAI,KAAK,QAAQ;EACxD,MAAM;IAAEE,CAAC;IAAEC;EAAE,CAAC,GAAGL,KAAK;EACtB,MAAMM,oBAAoB,GAAGH,YAAY,GAAGC,CAAC,GAAGC,CAAC;EACjD,MAAME,oBAAoB,GAAGJ,YAAY,GAAGE,CAAC,GAAGD,CAAC;EACjD,MAAMI,SAAS,GAAGL,YAAY,GAAGF,IAAI,CAACQ,IAAI,GAAG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EAAG;EACrD,OACCA,IAAI,CAACQ,IAAI,IAAIT,KAAK,CAACI,CAAC,IACpBH,IAAI,CAACW,KAAK,IAAIZ,KAAK,CAACI,CAAC,IACrBH,IAAI,CAACS,GAAG,IAAIV,KAAK,CAACK,CAAC,IACnBJ,IAAI,CAACY,MAAM,IAAIb,KAAK,CAACK,CAAC;AAExB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASqB,yCAAyCA,CAAE1B,KAAK,EAAEC,IAAI,EAAG;EACxE,OAAOA,IAAI,CAACS,GAAG,IAAIV,KAAK,CAACK,CAAC,IAAIJ,IAAI,CAACY,MAAM,IAAIb,KAAK,CAACK,CAAC;AACrD"}
@@ -14,6 +14,37 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
14
14
  * External dependencies
15
15
  */
16
16
 
17
+ const transformStylesCache = new WeakMap();
18
+ function transformStyle({
19
+ css,
20
+ ignoredSelectors = [],
21
+ baseURL
22
+ }, wrapperSelector = '') {
23
+ // When there is no wrapper selector or base URL, there is no need
24
+ // to transform the CSS. This is most cases because in the default
25
+ // iframed editor, no wrapping is needed, and not many styles
26
+ // provide a base URL.
27
+ if (!wrapperSelector && !baseURL) {
28
+ return css;
29
+ }
30
+ try {
31
+ return (0, _postcss.default)([wrapperSelector && (0, _postcssPrefixwrap.default)(wrapperSelector, {
32
+ ignoredSelectors: [...ignoredSelectors, wrapperSelector]
33
+ }), baseURL && (0, _postcssUrlrebase.default)({
34
+ rootUrl: baseURL
35
+ })].filter(Boolean)).process(css, {}).css; // use sync PostCSS API
36
+ } catch (error) {
37
+ if (error instanceof _postcss.CssSyntaxError) {
38
+ // eslint-disable-next-line no-console
39
+ console.warn('wp.blockEditor.transformStyles Failed to transform CSS.', error.message + '\n' + error.showSourceCode(false));
40
+ } else {
41
+ // eslint-disable-next-line no-console
42
+ console.warn('wp.blockEditor.transformStyles Failed to transform CSS.', error);
43
+ }
44
+ return null;
45
+ }
46
+ }
47
+
17
48
  /**
18
49
  * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.
19
50
  *
@@ -27,34 +58,13 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
27
58
  * @return {Array} converted rules.
28
59
  */
29
60
  const transformStyles = (styles, wrapperSelector = '') => {
30
- return styles.map(({
31
- css,
32
- ignoredSelectors = [],
33
- baseURL
34
- }) => {
35
- // When there is no wrapper selector or base URL, there is no need
36
- // to transform the CSS. This is most cases because in the default
37
- // iframed editor, no wrapping is needed, and not many styles
38
- // provide a base URL.
39
- if (!wrapperSelector && !baseURL) {
40
- return css;
41
- }
42
- try {
43
- return (0, _postcss.default)([wrapperSelector && (0, _postcssPrefixwrap.default)(wrapperSelector, {
44
- ignoredSelectors: [...ignoredSelectors, wrapperSelector]
45
- }), baseURL && (0, _postcssUrlrebase.default)({
46
- rootUrl: baseURL
47
- })].filter(Boolean)).process(css, {}).css; // use sync PostCSS API
48
- } catch (error) {
49
- if (error instanceof _postcss.CssSyntaxError) {
50
- // eslint-disable-next-line no-console
51
- console.warn('wp.blockEditor.transformStyles Failed to transform CSS.', error.message + '\n' + error.showSourceCode(false));
52
- } else {
53
- // eslint-disable-next-line no-console
54
- console.warn('wp.blockEditor.transformStyles Failed to transform CSS.', error);
55
- }
56
- return null;
61
+ return styles.map(style => {
62
+ if (transformStylesCache.has(style)) {
63
+ return transformStylesCache.get(style);
57
64
  }
65
+ const transformedStyle = transformStyle(style, wrapperSelector);
66
+ transformStylesCache.set(style, transformedStyle);
67
+ return transformedStyle;
58
68
  });
59
69
  };
60
70
  var _default = transformStyles;
@@ -1 +1 @@
1
- {"version":3,"names":["_postcss","_interopRequireWildcard","require","_postcssPrefixwrap","_interopRequireDefault","_postcssUrlrebase","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","transformStyles","styles","wrapperSelector","map","css","ignoredSelectors","baseURL","postcss","wrap","rebaseUrl","rootUrl","filter","Boolean","process","error","CssSyntaxError","console","warn","message","showSourceCode","_default","exports"],"sources":["@wordpress/block-editor/src/utils/transform-styles/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport postcss, { CssSyntaxError } from 'postcss';\nimport wrap from 'postcss-prefixwrap';\nimport rebaseUrl from 'postcss-urlrebase';\n\n/**\n * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.\n *\n * @typedef {Object} EditorStyle\n * @property {string} css the CSS block(s), as a single string.\n * @property {?string} baseURL the base URL to be used as the reference when rewritting urls.\n * @property {?string[]} ignoredSelectors the selectors not to wrap.\n *\n * @param {EditorStyle[]} styles CSS rules.\n * @param {string} wrapperSelector Wrapper selector.\n * @return {Array} converted rules.\n */\nconst transformStyles = ( styles, wrapperSelector = '' ) => {\n\treturn styles.map( ( { css, ignoredSelectors = [], baseURL } ) => {\n\t\t// When there is no wrapper selector or base URL, there is no need\n\t\t// to transform the CSS. This is most cases because in the default\n\t\t// iframed editor, no wrapping is needed, and not many styles\n\t\t// provide a base URL.\n\t\tif ( ! wrapperSelector && ! baseURL ) {\n\t\t\treturn css;\n\t\t}\n\n\t\ttry {\n\t\t\treturn postcss(\n\t\t\t\t[\n\t\t\t\t\twrapperSelector &&\n\t\t\t\t\t\twrap( wrapperSelector, {\n\t\t\t\t\t\t\tignoredSelectors: [\n\t\t\t\t\t\t\t\t...ignoredSelectors,\n\t\t\t\t\t\t\t\twrapperSelector,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t} ),\n\t\t\t\t\tbaseURL && rebaseUrl( { rootUrl: baseURL } ),\n\t\t\t\t].filter( Boolean )\n\t\t\t).process( css, {} ).css; // use sync PostCSS API\n\t\t} catch ( error ) {\n\t\t\tif ( error instanceof CssSyntaxError ) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'wp.blockEditor.transformStyles Failed to transform CSS.',\n\t\t\t\t\terror.message + '\\n' + error.showSourceCode( false )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'wp.blockEditor.transformStyles Failed to transform CSS.',\n\t\t\t\t\terror\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn null;\n\t\t}\n\t} );\n};\n\nexport default transformStyles;\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAD,sBAAA,CAAAF,OAAA;AAA0C,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAN,wBAAAU,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,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cAAc,CAAE,KAAM,CACpD,CAAC;MACF,CAAC,MAAM;QACN;QACAH,OAAO,CAACC,IAAI,CACX,yDAAyD,EACzDH,KACD,CAAC;MACF;MAEA,OAAO,IAAI;IACZ;EACD,CAAE,CAAC;AACJ,CAAC;AAAC,IAAAM,QAAA,GAEapB,eAAe;AAAAqB,OAAA,CAAApC,OAAA,GAAAmC,QAAA"}
1
+ {"version":3,"names":["_postcss","_interopRequireWildcard","require","_postcssPrefixwrap","_interopRequireDefault","_postcssUrlrebase","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","transformStylesCache","transformStyle","css","ignoredSelectors","baseURL","wrapperSelector","postcss","wrap","rebaseUrl","rootUrl","filter","Boolean","process","error","CssSyntaxError","console","warn","message","showSourceCode","transformStyles","styles","map","style","transformedStyle","_default","exports"],"sources":["@wordpress/block-editor/src/utils/transform-styles/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport postcss, { CssSyntaxError } from 'postcss';\nimport wrap from 'postcss-prefixwrap';\nimport rebaseUrl from 'postcss-urlrebase';\n\nconst transformStylesCache = new WeakMap();\n\nfunction transformStyle(\n\t{ css, ignoredSelectors = [], baseURL },\n\twrapperSelector = ''\n) {\n\t// When there is no wrapper selector or base URL, there is no need\n\t// to transform the CSS. This is most cases because in the default\n\t// iframed editor, no wrapping is needed, and not many styles\n\t// provide a base URL.\n\tif ( ! wrapperSelector && ! baseURL ) {\n\t\treturn css;\n\t}\n\n\ttry {\n\t\treturn postcss(\n\t\t\t[\n\t\t\t\twrapperSelector &&\n\t\t\t\t\twrap( wrapperSelector, {\n\t\t\t\t\t\tignoredSelectors: [\n\t\t\t\t\t\t\t...ignoredSelectors,\n\t\t\t\t\t\t\twrapperSelector,\n\t\t\t\t\t\t],\n\t\t\t\t\t} ),\n\t\t\t\tbaseURL && rebaseUrl( { rootUrl: baseURL } ),\n\t\t\t].filter( Boolean )\n\t\t).process( css, {} ).css; // use sync PostCSS API\n\t} catch ( error ) {\n\t\tif ( error instanceof CssSyntaxError ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t'wp.blockEditor.transformStyles Failed to transform CSS.',\n\t\t\t\terror.message + '\\n' + error.showSourceCode( false )\n\t\t\t);\n\t\t} else {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t'wp.blockEditor.transformStyles Failed to transform CSS.',\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t}\n}\n\n/**\n * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.\n *\n * @typedef {Object} EditorStyle\n * @property {string} css the CSS block(s), as a single string.\n * @property {?string} baseURL the base URL to be used as the reference when rewritting urls.\n * @property {?string[]} ignoredSelectors the selectors not to wrap.\n *\n * @param {EditorStyle[]} styles CSS rules.\n * @param {string} wrapperSelector Wrapper selector.\n * @return {Array} converted rules.\n */\nconst transformStyles = ( styles, wrapperSelector = '' ) => {\n\treturn styles.map( ( style ) => {\n\t\tif ( transformStylesCache.has( style ) ) {\n\t\t\treturn transformStylesCache.get( style );\n\t\t}\n\n\t\tconst transformedStyle = transformStyle( style, wrapperSelector );\n\t\ttransformStylesCache.set( style, transformedStyle );\n\t\treturn transformedStyle;\n\t} );\n};\n\nexport default transformStyles;\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAD,sBAAA,CAAAF,OAAA;AAA0C,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GA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AA,GAAAuC,QAAA"}
@@ -17,12 +17,15 @@ import { store as blockEditorStore } from '../../store';
17
17
  import { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';
18
18
  import { isDropTargetValid } from '../use-block-drop-zone';
19
19
  const BlockDraggable = ({
20
+ appendToOwnerDocument,
20
21
  children,
21
22
  clientIds,
22
23
  cloneClassname,
24
+ elementId,
23
25
  onDragStart,
24
26
  onDragEnd,
25
- fadeWhenDisabled = false
27
+ fadeWhenDisabled = false,
28
+ dragComponent
26
29
  }) => {
27
30
  const {
28
31
  srcRootClientId,
@@ -139,6 +142,7 @@ const BlockDraggable = ({
139
142
  srcRootClientId
140
143
  };
141
144
  return createElement(Draggable, {
145
+ appendToOwnerDocument: appendToOwnerDocument,
142
146
  cloneClassname: cloneClassname,
143
147
  __experimentalTransferDataType: "wp-blocks",
144
148
  transferData: transferData,
@@ -163,11 +167,15 @@ const BlockDraggable = ({
163
167
  onDragEnd();
164
168
  }
165
169
  },
166
- __experimentalDragComponent: createElement(BlockDraggableChip, {
170
+ __experimentalDragComponent:
171
+ // Check against `undefined` so that `null` can be used to disable
172
+ // the default drag component.
173
+ dragComponent !== undefined ? dragComponent : createElement(BlockDraggableChip, {
167
174
  count: clientIds.length,
168
175
  icon: icon,
169
176
  fadeWhenDisabled: true
170
- })
177
+ }),
178
+ elementId: elementId
171
179
  }, ({
172
180
  onDraggableStart,
173
181
  onDraggableEnd
@@ -1 +1 @@
1
- {"version":3,"names":["store","blocksStore","Draggable","useSelect","useDispatch","useEffect","useRef","throttle","BlockDraggableChip","useScrollWhenDragging","blockEditorStore","__unstableUseBlockRef","useBlockRef","isDropTargetValid","BlockDraggable","children","clientIds","cloneClassname","onDragStart","onDragEnd","fadeWhenDisabled","srcRootClientId","isDraggable","icon","visibleInserter","getBlockType","select","canMoveBlocks","getBlockRootClientId","getBlockName","getBlockAttributes","isBlockInsertionPointVisible","_getBlockType","getActiveBlockVariation","rootClientId","blockName","variation","isDragging","startScrolling","scrollOnDragOver","stopScrolling","getAllowedBlocks","getBlockNamesByClientId","startDraggingBlocks","stopDraggingBlocks","current","blockRef","editorRoot","closest","onDragOver","event","target","draggedBlockNames","targetClientId","getAttribute","allowedBlocks","targetBlockName","dropTargetValid","length","targetRootClientId","targetRootBlockName","rootAllowedBlocks","window","document","body","classList","add","remove","throttledOnDragOver","addEventListener","removeEventListener","draggable","transferData","type","srcClientIds","createElement","__experimentalTransferDataType","requestAnimationFrame","__experimentalDragComponent","count","onDraggableStart","onDraggableEnd"],"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { Draggable } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { throttle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from './draggable-chip';\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';\nimport { isDropTargetValid } from '../use-block-drop-zone';\n\nconst BlockDraggable = ( {\n\tchildren,\n\tclientIds,\n\tcloneClassname,\n\tonDragStart,\n\tonDragEnd,\n\tfadeWhenDisabled = false,\n} ) => {\n\tconst {\n\t\tsrcRootClientId,\n\t\tisDraggable,\n\t\ticon,\n\t\tvisibleInserter,\n\t\tgetBlockType,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanMoveBlocks,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType: _getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\tconst blockName = getBlockName( clientIds[ 0 ] );\n\t\t\tconst variation = getActiveBlockVariation(\n\t\t\t\tblockName,\n\t\t\t\tgetBlockAttributes( clientIds[ 0 ] )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tsrcRootClientId: rootClientId,\n\t\t\t\tisDraggable: canMoveBlocks( clientIds, rootClientId ),\n\t\t\t\ticon: variation?.icon || _getBlockType( blockName )?.icon,\n\t\t\t\tvisibleInserter: isBlockInsertionPointVisible(),\n\t\t\t\tgetBlockType: _getBlockType,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tconst isDragging = useRef( false );\n\tconst [ startScrolling, scrollOnDragOver, stopScrolling ] =\n\t\tuseScrollWhenDragging();\n\n\tconst { getAllowedBlocks, getBlockNamesByClientId, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst { startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.current ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\t// Find the root of the editor iframe.\n\tconst blockRef = useBlockRef( clientIds[ 0 ] );\n\tconst editorRoot = blockRef.current?.closest( 'body' );\n\n\t/*\n\t * Add a dragover event listener to the editor root to track the blocks being dragged over.\n\t * The listener has to be inside the editor iframe otherwise the target isn't accessible.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! editorRoot || ! fadeWhenDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onDragOver = ( event ) => {\n\t\t\tif ( ! event.target.closest( '[data-block]' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst draggedBlockNames = getBlockNamesByClientId( clientIds );\n\t\t\tconst targetClientId = event.target\n\t\t\t\t.closest( '[data-block]' )\n\t\t\t\t.getAttribute( 'data-block' );\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( targetClientId );\n\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\ttargetClientId,\n\t\t\t] )[ 0 ];\n\n\t\t\t/*\n\t\t\t * Check if the target is valid to drop in.\n\t\t\t * If the target's allowedBlocks is an empty array,\n\t\t\t * it isn't a container block, in which case we check\n\t\t\t * its parent's validity instead.\n\t\t\t */\n\t\t\tlet dropTargetValid;\n\t\t\tif ( allowedBlocks?.length === 0 ) {\n\t\t\t\tconst targetRootClientId =\n\t\t\t\t\tgetBlockRootClientId( targetClientId );\n\t\t\t\tconst targetRootBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\t\t\t\tconst rootAllowedBlocks =\n\t\t\t\t\tgetAllowedBlocks( targetRootClientId );\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\trootAllowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetRootBlockName\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Update the body class to reflect if drop target is valid.\n\t\t\t * This has to be done on the document body because the draggable\n\t\t\t * chip is rendered outside of the editor iframe.\n\t\t\t */\n\t\t\tif ( ! dropTargetValid && ! visibleInserter ) {\n\t\t\t\twindow?.document?.body?.classList?.add(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\twindow?.document?.body?.classList?.remove(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst throttledOnDragOver = throttle( onDragOver, 200 );\n\n\t\teditorRoot.addEventListener( 'dragover', throttledOnDragOver );\n\n\t\treturn () => {\n\t\t\teditorRoot.removeEventListener( 'dragover', throttledOnDragOver );\n\t\t};\n\t}, [\n\t\tclientIds,\n\t\teditorRoot,\n\t\tfadeWhenDisabled,\n\t\tgetAllowedBlocks,\n\t\tgetBlockNamesByClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlockType,\n\t\tvisibleInserter,\n\t] );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { draggable: false } );\n\t}\n\n\tconst transferData = {\n\t\ttype: 'block',\n\t\tsrcClientIds: clientIds,\n\t\tsrcRootClientId,\n\t};\n\n\treturn (\n\t\t<Draggable\n\t\t\tcloneClassname={ cloneClassname }\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t// Defer hiding the dragged source element to the next\n\t\t\t\t// frame to enable dragging.\n\t\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\t\tstartDraggingBlocks( clientIds );\n\t\t\t\t\tisDragging.current = true;\n\n\t\t\t\t\tstartScrolling( event );\n\n\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\tonDragStart();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonDragOver={ scrollOnDragOver }\n\t\t\tonDragEnd={ () => {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t\tisDragging.current = false;\n\n\t\t\t\tstopScrolling();\n\n\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\tonDragEnd();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t<BlockDraggableChip\n\t\t\t\t\tcount={ clientIds.length }\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tfadeWhenDisabled\n\t\t\t\t/>\n\t\t\t}\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: true,\n\t\t\t\t\tonDragStart: onDraggableStart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AgB;IAAEC;EAAe,CAAC,KAAM;IAC7C,OAAOlE,QAAQ,CAAE;MAChBwD,SAAS,EAAE,IAAI;MACfrD,WAAW,EAAE8D,gBAAgB;MAC7B7D,SAAS,EAAE8D;IACZ,CAAE,CAAC;EACJ,CACU,CAAC;AAEd,CAAC;AAED,eAAenE,cAAc"}
1
+ {"version":3,"names":["store","blocksStore","Draggable","useSelect","useDispatch","useEffect","useRef","throttle","BlockDraggableChip","useScrollWhenDragging","blockEditorStore","__unstableUseBlockRef","useBlockRef","isDropTargetValid","BlockDraggable","appendToOwnerDocument","children","clientIds","cloneClassname","elementId","onDragStart","onDragEnd","fadeWhenDisabled","dragComponent","srcRootClientId","isDraggable","icon","visibleInserter","getBlockType","select","canMoveBlocks","getBlockRootClientId","getBlockName","getBlockAttributes","isBlockInsertionPointVisible","_getBlockType","getActiveBlockVariation","rootClientId","blockName","variation","isDragging","startScrolling","scrollOnDragOver","stopScrolling","getAllowedBlocks","getBlockNamesByClientId","startDraggingBlocks","stopDraggingBlocks","current","blockRef","editorRoot","closest","onDragOver","event","target","draggedBlockNames","targetClientId","getAttribute","allowedBlocks","targetBlockName","dropTargetValid","length","targetRootClientId","targetRootBlockName","rootAllowedBlocks","window","document","body","classList","add","remove","throttledOnDragOver","addEventListener","removeEventListener","draggable","transferData","type","srcClientIds","createElement","__experimentalTransferDataType","requestAnimationFrame","__experimentalDragComponent","undefined","count","onDraggableStart","onDraggableEnd"],"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { Draggable } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { throttle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from './draggable-chip';\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';\nimport { isDropTargetValid } from '../use-block-drop-zone';\n\nconst BlockDraggable = ( {\n\tappendToOwnerDocument,\n\tchildren,\n\tclientIds,\n\tcloneClassname,\n\telementId,\n\tonDragStart,\n\tonDragEnd,\n\tfadeWhenDisabled = false,\n\tdragComponent,\n} ) => {\n\tconst {\n\t\tsrcRootClientId,\n\t\tisDraggable,\n\t\ticon,\n\t\tvisibleInserter,\n\t\tgetBlockType,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanMoveBlocks,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType: _getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\tconst blockName = getBlockName( clientIds[ 0 ] );\n\t\t\tconst variation = getActiveBlockVariation(\n\t\t\t\tblockName,\n\t\t\t\tgetBlockAttributes( clientIds[ 0 ] )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tsrcRootClientId: rootClientId,\n\t\t\t\tisDraggable: canMoveBlocks( clientIds, rootClientId ),\n\t\t\t\ticon: variation?.icon || _getBlockType( blockName )?.icon,\n\t\t\t\tvisibleInserter: isBlockInsertionPointVisible(),\n\t\t\t\tgetBlockType: _getBlockType,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tconst isDragging = useRef( false );\n\tconst [ startScrolling, scrollOnDragOver, stopScrolling ] =\n\t\tuseScrollWhenDragging();\n\n\tconst { getAllowedBlocks, getBlockNamesByClientId, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst { startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.current ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\t// Find the root of the editor iframe.\n\tconst blockRef = useBlockRef( clientIds[ 0 ] );\n\tconst editorRoot = blockRef.current?.closest( 'body' );\n\n\t/*\n\t * Add a dragover event listener to the editor root to track the blocks being dragged over.\n\t * The listener has to be inside the editor iframe otherwise the target isn't accessible.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! editorRoot || ! fadeWhenDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onDragOver = ( event ) => {\n\t\t\tif ( ! event.target.closest( '[data-block]' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst draggedBlockNames = getBlockNamesByClientId( clientIds );\n\t\t\tconst targetClientId = event.target\n\t\t\t\t.closest( '[data-block]' )\n\t\t\t\t.getAttribute( 'data-block' );\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( targetClientId );\n\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\ttargetClientId,\n\t\t\t] )[ 0 ];\n\n\t\t\t/*\n\t\t\t * Check if the target is valid to drop in.\n\t\t\t * If the target's allowedBlocks is an empty array,\n\t\t\t * it isn't a container block, in which case we check\n\t\t\t * its parent's validity instead.\n\t\t\t */\n\t\t\tlet dropTargetValid;\n\t\t\tif ( allowedBlocks?.length === 0 ) {\n\t\t\t\tconst targetRootClientId =\n\t\t\t\t\tgetBlockRootClientId( targetClientId );\n\t\t\t\tconst targetRootBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\t\t\t\tconst rootAllowedBlocks =\n\t\t\t\t\tgetAllowedBlocks( targetRootClientId );\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\trootAllowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetRootBlockName\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Update the body class to reflect if drop target is valid.\n\t\t\t * This has to be done on the document body because the draggable\n\t\t\t * chip is rendered outside of the editor iframe.\n\t\t\t */\n\t\t\tif ( ! dropTargetValid && ! visibleInserter ) {\n\t\t\t\twindow?.document?.body?.classList?.add(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\twindow?.document?.body?.classList?.remove(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst throttledOnDragOver = throttle( onDragOver, 200 );\n\n\t\teditorRoot.addEventListener( 'dragover', throttledOnDragOver );\n\n\t\treturn () => {\n\t\t\teditorRoot.removeEventListener( 'dragover', throttledOnDragOver );\n\t\t};\n\t}, [\n\t\tclientIds,\n\t\teditorRoot,\n\t\tfadeWhenDisabled,\n\t\tgetAllowedBlocks,\n\t\tgetBlockNamesByClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlockType,\n\t\tvisibleInserter,\n\t] );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { draggable: false } );\n\t}\n\n\tconst transferData = {\n\t\ttype: 'block',\n\t\tsrcClientIds: clientIds,\n\t\tsrcRootClientId,\n\t};\n\n\treturn (\n\t\t<Draggable\n\t\t\tappendToOwnerDocument={ appendToOwnerDocument }\n\t\t\tcloneClassname={ cloneClassname }\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t// Defer hiding the dragged source element to the next\n\t\t\t\t// frame to enable dragging.\n\t\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\t\tstartDraggingBlocks( clientIds );\n\t\t\t\t\tisDragging.current = true;\n\n\t\t\t\t\tstartScrolling( event );\n\n\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\tonDragStart();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonDragOver={ scrollOnDragOver }\n\t\t\tonDragEnd={ () => {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t\tisDragging.current = false;\n\n\t\t\t\tstopScrolling();\n\n\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\tonDragEnd();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t// Check against `undefined` so that `null` can be used to disable\n\t\t\t\t// the default drag component.\n\t\t\t\tdragComponent !== undefined ? (\n\t\t\t\t\tdragComponent\n\t\t\t\t) : (\n\t\t\t\t\t<BlockDraggableChip\n\t\t\t\t\t\tcount={ clientIds.length }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\tfadeWhenDisabled\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\telementId={ elementId }\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: true,\n\t\t\t\t\tonDragStart: onDraggableStart,\n\t\t\t\t\tonDragEnd: onDraggableEnd,\n\t\t\t\t} );\n\t\t\t} }\n\t\t</Draggable>\n\t);\n};\n\nexport default BlockDraggable;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;AACtD,SAASC,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,kBAAkB;AACjD,OAAOC,qBAAqB,MAAM,4BAA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DisplayControlsKey = Symbol('mayDisplayControls');
6
6
  export const mayDisplayParentControlsKey = Symbol('mayDisplayParentControls');
7
+ export const blockEditingModeKey = Symbol('blockEditingMode');
7
8
  export const DEFAULT_BLOCK_EDIT_CONTEXT = {
8
9
  name: '',
9
10
  isSelected: false
@@ -1 +1 @@
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"}
1
+ {"version":3,"names":["createContext","useContext","mayDisplayControlsKey","Symbol","mayDisplayParentControlsKey","blockEditingModeKey","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' );\nexport const blockEditingModeKey = Symbol( 'blockEditingMode' );\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;AAC/E,OAAO,MAAME,mBAAmB,GAAGF,MAAM,CAAE,kBAAmB,CAAC;AAE/D,OAAO,MAAMG,0BAA0B,GAAG;EACzCC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACb,CAAC;AAED,MAAMC,OAAO,GAAGT,aAAa,CAAEM,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,OAAOX,UAAU,CAAEQ,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, mayDisplayControlsKey, mayDisplayParentControlsKey } from './context';
11
+ import { BlockEditContextProvider, useBlockEditContext, mayDisplayControlsKey, mayDisplayParentControlsKey, blockEditingModeKey } from './context';
12
12
 
13
13
  /**
14
14
  * The `useBlockEditContext` hook provides information about the block this hook is being used in.
@@ -22,6 +22,7 @@ export { useBlockEditContext };
22
22
  export default function BlockEdit({
23
23
  mayDisplayControls,
24
24
  mayDisplayParentControls,
25
+ blockEditingMode,
25
26
  // The remaining props are passed through the BlockEdit filters and are thus
26
27
  // public API!
27
28
  ...props
@@ -51,8 +52,9 @@ export default function BlockEdit({
51
52
  // We use symbols in favour of an __unstable prefix to avoid
52
53
  // usage outside of the package (this context is exposed).
53
54
  [mayDisplayControlsKey]: mayDisplayControls,
54
- [mayDisplayParentControlsKey]: mayDisplayParentControls
55
- }), [name, isSelected, clientId, layoutSupport, layout, __unstableLayoutClassNames, mayDisplayControls, mayDisplayParentControls])
55
+ [mayDisplayParentControlsKey]: mayDisplayParentControls,
56
+ [blockEditingModeKey]: blockEditingMode
57
+ }), [name, isSelected, clientId, layoutSupport, layout, __unstableLayoutClassNames, mayDisplayControls, mayDisplayParentControls, blockEditingMode])
56
58
  }, createElement(Edit, {
57
59
  ...props
58
60
  }));
@@ -1 +1 @@
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"}
1
+ {"version":3,"names":["useMemo","hasBlockSupport","Edit","BlockEditContextProvider","useBlockEditContext","mayDisplayControlsKey","mayDisplayParentControlsKey","blockEditingModeKey","BlockEdit","mayDisplayControls","mayDisplayParentControls","blockEditingMode","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\tblockEditingModeKey,\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\tblockEditingMode,\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\t[ blockEditingModeKey ]: blockEditingMode,\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\tblockEditingMode,\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,EAC3BC,mBAAmB,QACb,WAAW;;AAElB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASH,mBAAmB;AAE5B,eAAe,SAASI,SAASA,CAAE;EAClCC,kBAAkB;EAClBC,wBAAwB;EACxBC,gBAAgB;EAChB;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,GAClBlB,eAAe,CAAEY,IAAI,EAAE,QAAQ,EAAE,KAAM,CAAC,IACxCZ,eAAe,CAAEY,IAAI,EAAE,sBAAsB,EAAE,KAAM,CAAC;EACvD,OACCO,aAAA,CAACjB;EACA;EACA;EACA;EAAA;IACAkB,KAAK,EAAGrB,OAAO,CACd,OAAQ;MACPa,IAAI;MACJC,UAAU;MACVC,QAAQ;MACRG,MAAM,EAAEC,aAAa,GAAGD,MAAM,GAAG,IAAI;MACrCD,0BAA0B;MAC1B;MACA;MACA,CAAEZ,qBAAqB,GAAII,kBAAkB;MAC7C,CAAEH,2BAA2B,GAAII,wBAAwB;MACzD,CAAEH,mBAAmB,GAAII;IAC1B,CAAC,CAAE,EACH,CACCE,IAAI,EACJC,UAAU,EACVC,QAAQ,EACRI,aAAa,EACbD,MAAM,EACND,0BAA0B,EAC1BR,kBAAkB,EAClBC,wBAAwB,EACxBC,gBAAgB,CAElB;EAAG,GAEHS,aAAA,CAAClB,IAAI;IAAA,GAAMU;EAAK,CAAI,CACK,CAAC;AAE7B"}
@@ -8,7 +8,7 @@ import { useEffect } from '@wordpress/element';
8
8
  * Internal dependencies
9
9
  */
10
10
  import { store as blockEditorStore } from '../../store';
11
- import { useBlockEditContext } from '../block-edit/context';
11
+ import { useBlockEditContext, blockEditingModeKey } from '../block-edit/context';
12
12
 
13
13
  /**
14
14
  * @typedef {'disabled'|'contentOnly'|'default'} BlockEditingMode
@@ -45,14 +45,17 @@ import { useBlockEditContext } from '../block-edit/context';
45
45
  * @return {BlockEditingMode} The current editing mode.
46
46
  */
47
47
  export function useBlockEditingMode(mode) {
48
+ const context = useBlockEditContext();
48
49
  const {
49
50
  clientId = ''
50
- } = useBlockEditContext();
51
- const blockEditingMode = useSelect(select => select(blockEditorStore).getBlockEditingMode(clientId), [clientId]);
51
+ } = context;
52
52
  const {
53
53
  setBlockEditingMode,
54
54
  unsetBlockEditingMode
55
55
  } = useDispatch(blockEditorStore);
56
+ const globalBlockEditingMode = useSelect(select =>
57
+ // Avoid adding the subscription if not needed!
58
+ clientId ? null : select(blockEditorStore).getBlockEditingMode(), [clientId]);
56
59
  useEffect(() => {
57
60
  if (mode) {
58
61
  setBlockEditingMode(clientId, mode);
@@ -63,6 +66,6 @@ export function useBlockEditingMode(mode) {
63
66
  }
64
67
  };
65
68
  }, [clientId, mode, setBlockEditingMode, unsetBlockEditingMode]);
66
- return blockEditingMode;
69
+ return clientId ? context[blockEditingModeKey] : globalBlockEditingMode;
67
70
  }
68
71
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useDispatch","useEffect","store","blockEditorStore","useBlockEditContext","useBlockEditingMode","mode","clientId","blockEditingMode","select","getBlockEditingMode","setBlockEditingMode","unsetBlockEditingMode"],"sources":["@wordpress/block-editor/src/components/block-editing-mode/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockEditContext } from '../block-edit/context';\n\n/**\n * @typedef {'disabled'|'contentOnly'|'default'} BlockEditingMode\n */\n\n/**\n * Allows a block to restrict the user interface that is displayed for editing\n * that block and its inner blocks.\n *\n * @example\n * ```js\n * function MyBlock( { attributes, setAttributes } ) {\n * useBlockEditingMode( 'disabled' );\n * return <div { ...useBlockProps() }></div>;\n * }\n * ```\n *\n * `mode` can be one of three options:\n *\n * - `'disabled'`: Prevents editing the block entirely, i.e. it cannot be\n * selected.\n * - `'contentOnly'`: Hides all non-content UI, e.g. auxiliary controls in the\n * toolbar, the block movers, block settings.\n * - `'default'`: Allows editing the block as normal.\n *\n * The mode is inherited by all of the block's inner blocks, unless they have\n * their own mode.\n *\n * If called outside of a block context, the mode is applied to all blocks.\n *\n * @param {?BlockEditingMode} mode The editing mode to apply. If undefined, the\n * current editing mode is not changed.\n *\n * @return {BlockEditingMode} The current editing mode.\n */\nexport function useBlockEditingMode( mode ) {\n\tconst { clientId = '' } = useBlockEditContext();\n\tconst blockEditingMode = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlockEditingMode( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { setBlockEditingMode, unsetBlockEditingMode } =\n\t\tuseDispatch( blockEditorStore );\n\tuseEffect( () => {\n\t\tif ( mode ) {\n\t\t\tsetBlockEditingMode( clientId, mode );\n\t\t}\n\t\treturn () => {\n\t\t\tif ( mode ) {\n\t\t\t\tunsetBlockEditingMode( clientId );\n\t\t\t}\n\t\t};\n\t}, [ clientId, mode, setBlockEditingMode, unsetBlockEditingMode ] );\n\treturn blockEditingMode;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,QAAQ,oBAAoB;;AAE9C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,mBAAmB,QAAQ,uBAAuB;;AAE3D;AACA;AACA;;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;AACA,OAAO,SAASC,mBAAmBA,CAAEC,IAAI,EAAG;EAC3C,MAAM;IAAEC,QAAQ,GAAG;EAAG,CAAC,GAAGH,mBAAmB,CAAC,CAAC;EAC/C,MAAMI,gBAAgB,GAAGT,SAAS,CAC/BU,MAAM,IACPA,MAAM,CAAEN,gBAAiB,CAAC,CAACO,mBAAmB,CAAEH,QAAS,CAAC,EAC3D,CAAEA,QAAQ,CACX,CAAC;EACD,MAAM;IAAEI,mBAAmB;IAAEC;EAAsB,CAAC,GACnDZ,WAAW,CAAEG,gBAAiB,CAAC;EAChCF,SAAS,CAAE,MAAM;IAChB,IAAKK,IAAI,EAAG;MACXK,mBAAmB,CAAEJ,QAAQ,EAAED,IAAK,CAAC;IACtC;IACA,OAAO,MAAM;MACZ,IAAKA,IAAI,EAAG;QACXM,qBAAqB,CAAEL,QAAS,CAAC;MAClC;IACD,CAAC;EACF,CAAC,EAAE,CAAEA,QAAQ,EAAED,IAAI,EAAEK,mBAAmB,EAAEC,qBAAqB,CAAG,CAAC;EACnE,OAAOJ,gBAAgB;AACxB"}
1
+ {"version":3,"names":["useSelect","useDispatch","useEffect","store","blockEditorStore","useBlockEditContext","blockEditingModeKey","useBlockEditingMode","mode","context","clientId","setBlockEditingMode","unsetBlockEditingMode","globalBlockEditingMode","select","getBlockEditingMode"],"sources":["@wordpress/block-editor/src/components/block-editing-mode/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport {\n\tuseBlockEditContext,\n\tblockEditingModeKey,\n} from '../block-edit/context';\n\n/**\n * @typedef {'disabled'|'contentOnly'|'default'} BlockEditingMode\n */\n\n/**\n * Allows a block to restrict the user interface that is displayed for editing\n * that block and its inner blocks.\n *\n * @example\n * ```js\n * function MyBlock( { attributes, setAttributes } ) {\n * useBlockEditingMode( 'disabled' );\n * return <div { ...useBlockProps() }></div>;\n * }\n * ```\n *\n * `mode` can be one of three options:\n *\n * - `'disabled'`: Prevents editing the block entirely, i.e. it cannot be\n * selected.\n * - `'contentOnly'`: Hides all non-content UI, e.g. auxiliary controls in the\n * toolbar, the block movers, block settings.\n * - `'default'`: Allows editing the block as normal.\n *\n * The mode is inherited by all of the block's inner blocks, unless they have\n * their own mode.\n *\n * If called outside of a block context, the mode is applied to all blocks.\n *\n * @param {?BlockEditingMode} mode The editing mode to apply. If undefined, the\n * current editing mode is not changed.\n *\n * @return {BlockEditingMode} The current editing mode.\n */\nexport function useBlockEditingMode( mode ) {\n\tconst context = useBlockEditContext();\n\tconst { clientId = '' } = context;\n\tconst { setBlockEditingMode, unsetBlockEditingMode } =\n\t\tuseDispatch( blockEditorStore );\n\tconst globalBlockEditingMode = useSelect(\n\t\t( select ) =>\n\t\t\t// Avoid adding the subscription if not needed!\n\t\t\tclientId ? null : select( blockEditorStore ).getBlockEditingMode(),\n\t\t[ clientId ]\n\t);\n\tuseEffect( () => {\n\t\tif ( mode ) {\n\t\t\tsetBlockEditingMode( clientId, mode );\n\t\t}\n\t\treturn () => {\n\t\t\tif ( mode ) {\n\t\t\t\tunsetBlockEditingMode( clientId );\n\t\t\t}\n\t\t};\n\t}, [ clientId, mode, setBlockEditingMode, unsetBlockEditingMode ] );\n\treturn clientId ? context[ blockEditingModeKey ] : globalBlockEditingMode;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,QAAQ,oBAAoB;;AAE9C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SACCC,mBAAmB,EACnBC,mBAAmB,QACb,uBAAuB;;AAE9B;AACA;AACA;;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;AACA,OAAO,SAASC,mBAAmBA,CAAEC,IAAI,EAAG;EAC3C,MAAMC,OAAO,GAAGJ,mBAAmB,CAAC,CAAC;EACrC,MAAM;IAAEK,QAAQ,GAAG;EAAG,CAAC,GAAGD,OAAO;EACjC,MAAM;IAAEE,mBAAmB;IAAEC;EAAsB,CAAC,GACnDX,WAAW,CAAEG,gBAAiB,CAAC;EAChC,MAAMS,sBAAsB,GAAGb,SAAS,CACrCc,MAAM;EACP;EACAJ,QAAQ,GAAG,IAAI,GAAGI,MAAM,CAAEV,gBAAiB,CAAC,CAACW,mBAAmB,CAAC,CAAC,EACnE,CAAEL,QAAQ,CACX,CAAC;EACDR,SAAS,CAAE,MAAM;IAChB,IAAKM,IAAI,EAAG;MACXG,mBAAmB,CAAED,QAAQ,EAAEF,IAAK,CAAC;IACtC;IACA,OAAO,MAAM;MACZ,IAAKA,IAAI,EAAG;QACXI,qBAAqB,CAAEF,QAAS,CAAC;MAClC;IACD,CAAC;EACF,CAAC,EAAE,CAAEA,QAAQ,EAAEF,IAAI,EAAEG,mBAAmB,EAAEC,qBAAqB,CAAG,CAAC;EACnE,OAAOF,QAAQ,GAAGD,OAAO,CAAEH,mBAAmB,CAAE,GAAGO,sBAAsB;AAC1E"}
@@ -76,7 +76,7 @@ const BlockInspector = ({
76
76
  selectedBlockClientId: _selectedBlockClientId,
77
77
  selectedBlockName: _selectedBlockName,
78
78
  blockType: _blockType,
79
- topLevelLockedBlock: __unstableGetContentLockingParent(_selectedBlockClientId) || (getTemplateLock(_selectedBlockClientId) === 'contentOnly' || _selectedBlockName === 'core/block' && window.__experimentalPatternPartialSyncing ? _selectedBlockClientId : undefined)
79
+ topLevelLockedBlock: __unstableGetContentLockingParent(_selectedBlockClientId) || (getTemplateLock(_selectedBlockClientId) === 'contentOnly' || _selectedBlockName === 'core/block' ? _selectedBlockClientId : undefined)
80
80
  };
81
81
  }, []);
82
82
  const availableTabs = useInspectorControlsTabs(blockType?.name);
@@ -222,7 +222,10 @@ const BlockInspectorSingleBlock = ({
222
222
  }), createElement(InspectorControls.Slot, {
223
223
  group: "background",
224
224
  label: __('Background')
225
- }), createElement(PositionControls, null), createElement("div", null, createElement(AdvancedControls, null))), createElement(SkipToSelectedBlock, {
225
+ }), createElement(PositionControls, null), createElement(InspectorControls.Slot, {
226
+ group: "effects",
227
+ label: __('Effects')
228
+ }), createElement("div", null, createElement(AdvancedControls, null))), createElement(SkipToSelectedBlock, {
226
229
  key: "back"
227
230
  }));
228
231
  };