@wordpress/block-editor 11.1.0 → 11.3.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 (765) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +28 -4
  4. package/build/components/alignment-control/ui.js +1 -1
  5. package/build/components/alignment-control/ui.js.map +1 -1
  6. package/build/components/autocomplete/index.js +2 -7
  7. package/build/components/autocomplete/index.js.map +1 -1
  8. package/build/components/block-actions/index.js +9 -0
  9. package/build/components/block-actions/index.js.map +1 -1
  10. package/build/components/block-alignment-matrix-control/index.js +2 -2
  11. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  12. package/build/components/block-card/index.js +2 -4
  13. package/build/components/block-card/index.js.map +1 -1
  14. package/build/components/block-edit/index.js +8 -0
  15. package/build/components/block-edit/index.js.map +1 -1
  16. package/build/components/block-inspector/index.js +18 -15
  17. package/build/components/block-inspector/index.js.map +1 -1
  18. package/build/components/block-list/use-in-between-inserter.js +5 -0
  19. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  20. package/build/components/block-lock/modal.js +0 -1
  21. package/build/components/block-lock/modal.js.map +1 -1
  22. package/build/components/block-mover/mover-description.js +2 -2
  23. package/build/components/block-mover/mover-description.js.map +1 -1
  24. package/build/components/block-navigation/dropdown.js +3 -1
  25. package/build/components/block-navigation/dropdown.js.map +1 -1
  26. package/build/components/block-pattern-setup/index.js +1 -1
  27. package/build/components/block-pattern-setup/index.js.map +1 -1
  28. package/build/components/block-pattern-setup/use-patterns-setup.js +2 -2
  29. package/build/components/block-pattern-setup/use-patterns-setup.js.map +1 -1
  30. package/build/components/block-patterns-list/index.js +31 -3
  31. package/build/components/block-patterns-list/index.js.map +1 -1
  32. package/build/components/block-preview/auto.js +9 -14
  33. package/build/components/block-preview/auto.js.map +1 -1
  34. package/build/components/block-preview/index.js +32 -8
  35. package/build/components/block-preview/index.js.map +1 -1
  36. package/build/components/block-selection-clearer/index.js +1 -1
  37. package/build/components/block-selection-clearer/index.js.map +1 -1
  38. package/build/components/block-settings/container.native.js +7 -33
  39. package/build/components/block-settings/container.native.js.map +1 -1
  40. package/build/components/block-settings-menu/block-settings-dropdown.js +12 -3
  41. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  42. package/build/components/block-settings-menu-controls/index.js +2 -8
  43. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  44. package/build/components/block-styles/index.js +3 -1
  45. package/build/components/block-styles/index.js.map +1 -1
  46. package/build/components/block-switcher/utils.js +1 -1
  47. package/build/components/block-switcher/utils.js.map +1 -1
  48. package/build/components/block-tools/selected-block-popover.js +55 -47
  49. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  50. package/build/components/block-tools/use-block-toolbar-popover-props.js +43 -10
  51. package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  52. package/build/components/block-vertical-alignment-control/icons.js +15 -1
  53. package/build/components/block-vertical-alignment-control/icons.js.map +1 -1
  54. package/build/components/block-vertical-alignment-control/ui.js +9 -4
  55. package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
  56. package/build/components/color-style-selector/index.js +3 -1
  57. package/build/components/color-style-selector/index.js.map +1 -1
  58. package/build/components/date-format-picker/index.js +3 -4
  59. package/build/components/date-format-picker/index.js.map +1 -1
  60. package/build/components/default-style-picker/index.js +1 -0
  61. package/build/components/default-style-picker/index.js.map +1 -1
  62. package/build/components/font-family/index.js +1 -7
  63. package/build/components/font-family/index.js.map +1 -1
  64. package/build/components/font-sizes/fluid-utils.js +1 -1
  65. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  66. package/build/components/font-sizes/utils.js +1 -1
  67. package/build/components/font-sizes/utils.js.map +1 -1
  68. package/build/components/font-sizes/with-font-sizes.js +5 -8
  69. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  70. package/build/components/global-styles/context.js +22 -0
  71. package/build/components/global-styles/context.js.map +1 -0
  72. package/build/components/global-styles/hooks.js +142 -0
  73. package/build/components/global-styles/hooks.js.map +1 -0
  74. package/build/components/global-styles/index.js +42 -0
  75. package/build/components/global-styles/index.js.map +1 -0
  76. package/build/components/global-styles/typography-utils.js +92 -0
  77. package/build/components/global-styles/typography-utils.js.map +1 -0
  78. package/build/components/global-styles/use-global-styles-output.js +974 -0
  79. package/build/components/global-styles/use-global-styles-output.js.map +1 -0
  80. package/build/components/global-styles/utils.js +340 -0
  81. package/build/components/global-styles/utils.js.map +1 -0
  82. package/build/components/height-control/index.js +13 -1
  83. package/build/components/height-control/index.js.map +1 -1
  84. package/build/components/iframe/index.js +37 -8
  85. package/build/components/iframe/index.js.map +1 -1
  86. package/build/components/iframe/use-compatibility-styles.js +6 -1
  87. package/build/components/iframe/use-compatibility-styles.js.map +1 -1
  88. package/build/components/image-editor/constants.js +1 -1
  89. package/build/components/image-editor/constants.js.map +1 -1
  90. package/build/components/image-editor/context.js +1 -2
  91. package/build/components/image-editor/context.js.map +1 -1
  92. package/build/components/image-editor/cropper.js +3 -1
  93. package/build/components/image-editor/cropper.js.map +1 -1
  94. package/build/components/image-editor/index.js +13 -9
  95. package/build/components/image-editor/index.js.map +1 -1
  96. package/build/components/image-editor/use-transform-image.js +11 -35
  97. package/build/components/image-editor/use-transform-image.js.map +1 -1
  98. package/build/components/image-size-control/index.js +2 -7
  99. package/build/components/image-size-control/index.js.map +1 -1
  100. package/build/components/index.js +8 -24
  101. package/build/components/index.js.map +1 -1
  102. package/build/components/inner-blocks/index.js +22 -32
  103. package/build/components/inner-blocks/index.js.map +1 -1
  104. package/build/components/inner-blocks/index.native.js +8 -23
  105. package/build/components/inner-blocks/index.native.js.map +1 -1
  106. package/build/components/inner-blocks/use-block-context.js +53 -0
  107. package/build/components/inner-blocks/use-block-context.js.map +1 -0
  108. package/build/components/inserter/block-patterns-explorer/explorer.js +0 -1
  109. package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
  110. package/build/components/inserter/block-patterns-tab.js +11 -5
  111. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  112. package/build/components/inserter/block-types-tab.js +2 -2
  113. package/build/components/inserter/block-types-tab.js.map +1 -1
  114. package/build/components/inserter/hooks/use-patterns-state.js +1 -7
  115. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  116. package/build/components/inserter/index.js +8 -6
  117. package/build/components/inserter/index.js.map +1 -1
  118. package/build/components/inserter/media-tab/hooks.js +142 -56
  119. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  120. package/build/components/inserter/media-tab/media-list.js +74 -21
  121. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  122. package/build/components/inserter/media-tab/media-panel.js +11 -13
  123. package/build/components/inserter/media-tab/media-panel.js.map +1 -1
  124. package/build/components/inserter/media-tab/media-tab.js +6 -3
  125. package/build/components/inserter/media-tab/media-tab.js.map +1 -1
  126. package/build/components/inserter/media-tab/utils.js +26 -15
  127. package/build/components/inserter/media-tab/utils.js.map +1 -1
  128. package/build/components/inserter/menu.js +12 -5
  129. package/build/components/inserter/menu.js.map +1 -1
  130. package/build/components/inserter/preview-panel.js +5 -3
  131. package/build/components/inserter/preview-panel.js.map +1 -1
  132. package/build/components/inserter/search-results.js +2 -7
  133. package/build/components/inserter/search-results.js.map +1 -1
  134. package/build/components/inserter-list-item/index.js +1 -9
  135. package/build/components/inserter-list-item/index.js.map +1 -1
  136. package/build/components/inspector-controls/fill.js +15 -2
  137. package/build/components/inspector-controls/fill.js.map +1 -1
  138. package/build/components/inspector-controls/fill.native.js +14 -1
  139. package/build/components/inspector-controls/fill.native.js.map +1 -1
  140. package/build/components/inspector-controls/groups.js +7 -1
  141. package/build/components/inspector-controls/groups.js.map +1 -1
  142. package/build/components/inspector-controls/index.js +2 -2
  143. package/build/components/inspector-controls/index.js.map +1 -1
  144. package/build/components/inspector-controls/slot.js +14 -1
  145. package/build/components/inspector-controls/slot.js.map +1 -1
  146. package/build/components/inspector-controls/slot.native.js +14 -1
  147. package/build/components/inspector-controls/slot.native.js.map +1 -1
  148. package/build/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
  149. package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -1
  150. package/build/components/inspector-controls-tabs/index.js +2 -2
  151. package/build/components/inspector-controls-tabs/index.js.map +1 -1
  152. package/build/components/inspector-controls-tabs/position-controls-panel.js +46 -0
  153. package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
  154. package/build/components/inspector-controls-tabs/settings-tab.js +3 -1
  155. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  156. package/build/components/inspector-controls-tabs/styles-tab.js +6 -4
  157. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  158. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +20 -22
  159. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  160. package/build/components/justify-content-control/ui.js +8 -1
  161. package/build/components/justify-content-control/ui.js.map +1 -1
  162. package/build/components/link-control/index.js +45 -17
  163. package/build/components/link-control/index.js.map +1 -1
  164. package/build/components/link-control/search-input.js +1 -0
  165. package/build/components/link-control/search-input.js.map +1 -1
  166. package/build/components/list-view/block.js +1 -1
  167. package/build/components/list-view/block.js.map +1 -1
  168. package/build/components/list-view/use-list-view-drop-zone.js +1 -1
  169. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  170. package/build/components/media-upload/index.native.js +4 -1
  171. package/build/components/media-upload/index.native.js.map +1 -1
  172. package/build/components/off-canvas-editor/appender.js +49 -38
  173. package/build/components/off-canvas-editor/appender.js.map +1 -1
  174. package/build/components/off-canvas-editor/block-contents.js +38 -5
  175. package/build/components/off-canvas-editor/block-contents.js.map +1 -1
  176. package/build/components/off-canvas-editor/block-select-button.js +10 -4
  177. package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
  178. package/build/components/off-canvas-editor/block.js +13 -52
  179. package/build/components/off-canvas-editor/block.js.map +1 -1
  180. package/build/components/off-canvas-editor/branch.js +25 -10
  181. package/build/components/off-canvas-editor/branch.js.map +1 -1
  182. package/build/components/off-canvas-editor/index.js +15 -17
  183. package/build/components/off-canvas-editor/index.js.map +1 -1
  184. package/build/components/off-canvas-editor/link-ui.js +2 -2
  185. package/build/components/off-canvas-editor/link-ui.js.map +1 -1
  186. package/build/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
  187. package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -1
  188. package/build/components/provider/index.js +22 -8
  189. package/build/components/provider/index.js.map +1 -1
  190. package/build/components/provider/index.native.js +5 -6
  191. package/build/components/provider/index.native.js.map +1 -1
  192. package/build/components/rich-text/use-before-input-rules.js +11 -3
  193. package/build/components/rich-text/use-before-input-rules.js.map +1 -1
  194. package/build/components/rich-text/use-enter.js +4 -5
  195. package/build/components/rich-text/use-enter.js.map +1 -1
  196. package/build/components/rich-text/utils.js +1 -1
  197. package/build/components/rich-text/utils.js.map +1 -1
  198. package/build/components/spacing-sizes-control/utils.js +2 -8
  199. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  200. package/build/components/tool-selector/index.js +3 -1
  201. package/build/components/tool-selector/index.js.map +1 -1
  202. package/build/components/url-input/button.js +1 -0
  203. package/build/components/url-input/button.js.map +1 -1
  204. package/build/components/url-input/index.js +15 -1
  205. package/build/components/url-input/index.js.map +1 -1
  206. package/build/components/url-popover/image-url-input-ui.js +7 -8
  207. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  208. package/build/components/url-popover/link-editor.js +1 -0
  209. package/build/components/url-popover/link-editor.js.map +1 -1
  210. package/build/components/use-block-display-information/index.js +1 -1
  211. package/build/components/use-block-display-information/index.js.map +1 -1
  212. package/build/components/use-paste-styles/index.js +188 -0
  213. package/build/components/use-paste-styles/index.js.map +1 -0
  214. package/build/components/writing-flow/use-arrow-nav.js +22 -29
  215. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  216. package/build/experiments.js +45 -0
  217. package/build/experiments.js.map +1 -0
  218. package/build/experiments.native.js +40 -0
  219. package/build/experiments.native.js.map +1 -0
  220. package/build/hooks/anchor.js +2 -1
  221. package/build/hooks/anchor.js.map +1 -1
  222. package/build/hooks/border.js +1 -1
  223. package/build/hooks/border.js.map +1 -1
  224. package/build/hooks/child-layout.js +5 -1
  225. package/build/hooks/child-layout.js.map +1 -1
  226. package/build/hooks/color-panel.js +1 -1
  227. package/build/hooks/color-panel.js.map +1 -1
  228. package/build/hooks/color.js +3 -3
  229. package/build/hooks/color.js.map +1 -1
  230. package/build/hooks/custom-class-name.js +2 -1
  231. package/build/hooks/custom-class-name.js.map +1 -1
  232. package/build/hooks/dimensions.js +7 -5
  233. package/build/hooks/dimensions.js.map +1 -1
  234. package/build/hooks/index.js +2 -0
  235. package/build/hooks/index.js.map +1 -1
  236. package/build/hooks/margin.js +1 -0
  237. package/build/hooks/margin.js.map +1 -1
  238. package/build/hooks/metadata.js +1 -1
  239. package/build/hooks/metadata.js.map +1 -1
  240. package/build/hooks/padding.js +1 -0
  241. package/build/hooks/padding.js.map +1 -1
  242. package/build/hooks/position.js +395 -0
  243. package/build/hooks/position.js.map +1 -0
  244. package/build/hooks/supports.js +328 -0
  245. package/build/hooks/supports.js.map +1 -0
  246. package/build/hooks/typography.js +1 -1
  247. package/build/hooks/typography.js.map +1 -1
  248. package/build/hooks/use-color-props.js +3 -3
  249. package/build/hooks/use-color-props.js.map +1 -1
  250. package/build/hooks/utils.js +69 -3
  251. package/build/hooks/utils.js.map +1 -1
  252. package/build/index.js +10 -1
  253. package/build/index.js.map +1 -1
  254. package/build/layouts/constrained.js +3 -0
  255. package/build/layouts/constrained.js.map +1 -1
  256. package/build/layouts/flex.js +59 -9
  257. package/build/layouts/flex.js.map +1 -1
  258. package/build/layouts/flow.js +0 -18
  259. package/build/layouts/flow.js.map +1 -1
  260. package/build/store/actions.js +3 -30
  261. package/build/store/actions.js.map +1 -1
  262. package/build/store/defaults.js +5 -2
  263. package/build/store/defaults.js.map +1 -1
  264. package/build/store/index.js +11 -2
  265. package/build/store/index.js.map +1 -1
  266. package/build/store/private-actions.js +78 -0
  267. package/build/store/private-actions.js.map +1 -0
  268. package/build/store/private-selectors.js +18 -0
  269. package/build/store/private-selectors.js.map +1 -0
  270. package/build/store/reducer.js +7 -3
  271. package/build/store/reducer.js.map +1 -1
  272. package/build/store/selectors.js +68 -40
  273. package/build/store/selectors.js.map +1 -1
  274. package/build/utils/block-variation-transforms.js +1 -1
  275. package/build/utils/block-variation-transforms.js.map +1 -1
  276. package/build/utils/parse-css-unit-to-px.js +1 -1
  277. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  278. package/build/utils/transform-styles/index.js +1 -7
  279. package/build/utils/transform-styles/index.js.map +1 -1
  280. package/build-module/components/alignment-control/ui.js +1 -1
  281. package/build-module/components/alignment-control/ui.js.map +1 -1
  282. package/build-module/components/autocomplete/index.js +2 -6
  283. package/build-module/components/autocomplete/index.js.map +1 -1
  284. package/build-module/components/block-actions/index.js +6 -0
  285. package/build-module/components/block-actions/index.js.map +1 -1
  286. package/build-module/components/block-alignment-matrix-control/index.js +2 -2
  287. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  288. package/build-module/components/block-card/index.js +2 -4
  289. package/build-module/components/block-card/index.js.map +1 -1
  290. package/build-module/components/block-edit/index.js +7 -0
  291. package/build-module/components/block-edit/index.js.map +1 -1
  292. package/build-module/components/block-inspector/index.js +17 -15
  293. package/build-module/components/block-inspector/index.js.map +1 -1
  294. package/build-module/components/block-list/use-in-between-inserter.js +5 -0
  295. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  296. package/build-module/components/block-lock/modal.js +0 -1
  297. package/build-module/components/block-lock/modal.js.map +1 -1
  298. package/build-module/components/block-mover/mover-description.js +2 -2
  299. package/build-module/components/block-mover/mover-description.js.map +1 -1
  300. package/build-module/components/block-navigation/dropdown.js +3 -1
  301. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  302. package/build-module/components/block-pattern-setup/index.js +1 -1
  303. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  304. package/build-module/components/block-pattern-setup/use-patterns-setup.js +2 -2
  305. package/build-module/components/block-pattern-setup/use-patterns-setup.js.map +1 -1
  306. package/build-module/components/block-patterns-list/index.js +32 -3
  307. package/build-module/components/block-patterns-list/index.js.map +1 -1
  308. package/build-module/components/block-preview/auto.js +9 -14
  309. package/build-module/components/block-preview/auto.js.map +1 -1
  310. package/build-module/components/block-preview/index.js +31 -8
  311. package/build-module/components/block-preview/index.js.map +1 -1
  312. package/build-module/components/block-selection-clearer/index.js +1 -1
  313. package/build-module/components/block-selection-clearer/index.js.map +1 -1
  314. package/build-module/components/block-settings/container.native.js +6 -30
  315. package/build-module/components/block-settings/container.native.js.map +1 -1
  316. package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -3
  317. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  318. package/build-module/components/block-settings-menu-controls/index.js +2 -7
  319. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  320. package/build-module/components/block-styles/index.js +2 -1
  321. package/build-module/components/block-styles/index.js.map +1 -1
  322. package/build-module/components/block-switcher/utils.js +1 -1
  323. package/build-module/components/block-switcher/utils.js.map +1 -1
  324. package/build-module/components/block-tools/selected-block-popover.js +55 -48
  325. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  326. package/build-module/components/block-tools/use-block-toolbar-popover-props.js +42 -11
  327. package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  328. package/build-module/components/block-vertical-alignment-control/icons.js +12 -0
  329. package/build-module/components/block-vertical-alignment-control/icons.js.map +1 -1
  330. package/build-module/components/block-vertical-alignment-control/ui.js +10 -5
  331. package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
  332. package/build-module/components/color-style-selector/index.js +3 -1
  333. package/build-module/components/color-style-selector/index.js.map +1 -1
  334. package/build-module/components/date-format-picker/index.js +4 -5
  335. package/build-module/components/date-format-picker/index.js.map +1 -1
  336. package/build-module/components/default-style-picker/index.js +1 -0
  337. package/build-module/components/default-style-picker/index.js.map +1 -1
  338. package/build-module/components/font-family/index.js +1 -6
  339. package/build-module/components/font-family/index.js.map +1 -1
  340. package/build-module/components/font-sizes/fluid-utils.js +1 -1
  341. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  342. package/build-module/components/font-sizes/utils.js +1 -1
  343. package/build-module/components/font-sizes/utils.js.map +1 -1
  344. package/build-module/components/font-sizes/with-font-sizes.js +5 -7
  345. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  346. package/build-module/components/global-styles/context.js +12 -0
  347. package/build-module/components/global-styles/context.js.map +1 -0
  348. package/build-module/components/global-styles/hooks.js +121 -0
  349. package/build-module/components/global-styles/hooks.js.map +1 -0
  350. package/build-module/components/global-styles/index.js +4 -0
  351. package/build-module/components/global-styles/index.js.map +1 -0
  352. package/build-module/components/global-styles/typography-utils.js +84 -0
  353. package/build-module/components/global-styles/typography-utils.js.map +1 -0
  354. package/build-module/components/global-styles/use-global-styles-output.js +930 -0
  355. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -0
  356. package/build-module/components/global-styles/utils.js +321 -0
  357. package/build-module/components/global-styles/utils.js.map +1 -0
  358. package/build-module/components/height-control/index.js +14 -1
  359. package/build-module/components/height-control/index.js.map +1 -1
  360. package/build-module/components/iframe/index.js +36 -9
  361. package/build-module/components/iframe/index.js.map +1 -1
  362. package/build-module/components/iframe/use-compatibility-styles.js +6 -1
  363. package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
  364. package/build-module/components/image-editor/constants.js +1 -1
  365. package/build-module/components/image-editor/constants.js.map +1 -1
  366. package/build-module/components/image-editor/context.js +1 -2
  367. package/build-module/components/image-editor/context.js.map +1 -1
  368. package/build-module/components/image-editor/cropper.js +3 -1
  369. package/build-module/components/image-editor/cropper.js.map +1 -1
  370. package/build-module/components/image-editor/index.js +13 -3
  371. package/build-module/components/image-editor/index.js.map +1 -1
  372. package/build-module/components/image-editor/use-transform-image.js +12 -37
  373. package/build-module/components/image-editor/use-transform-image.js.map +1 -1
  374. package/build-module/components/image-size-control/index.js +2 -6
  375. package/build-module/components/image-size-control/index.js.map +1 -1
  376. package/build-module/components/index.js +2 -3
  377. package/build-module/components/index.js.map +1 -1
  378. package/build-module/components/inner-blocks/index.js +21 -32
  379. package/build-module/components/inner-blocks/index.js.map +1 -1
  380. package/build-module/components/inner-blocks/index.native.js +9 -22
  381. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  382. package/build-module/components/inner-blocks/use-block-context.js +43 -0
  383. package/build-module/components/inner-blocks/use-block-context.js.map +1 -0
  384. package/build-module/components/inserter/block-patterns-explorer/explorer.js +0 -1
  385. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
  386. package/build-module/components/inserter/block-patterns-tab.js +11 -5
  387. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  388. package/build-module/components/inserter/block-types-tab.js +3 -3
  389. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  390. package/build-module/components/inserter/hooks/use-patterns-state.js +1 -6
  391. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  392. package/build-module/components/inserter/index.js +8 -6
  393. package/build-module/components/inserter/index.js.map +1 -1
  394. package/build-module/components/inserter/media-tab/hooks.js +145 -56
  395. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  396. package/build-module/components/inserter/media-tab/media-list.js +74 -24
  397. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  398. package/build-module/components/inserter/media-tab/media-panel.js +14 -14
  399. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
  400. package/build-module/components/inserter/media-tab/media-tab.js +7 -4
  401. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
  402. package/build-module/components/inserter/media-tab/utils.js +27 -15
  403. package/build-module/components/inserter/media-tab/utils.js.map +1 -1
  404. package/build-module/components/inserter/menu.js +12 -5
  405. package/build-module/components/inserter/menu.js.map +1 -1
  406. package/build-module/components/inserter/preview-panel.js +5 -3
  407. package/build-module/components/inserter/preview-panel.js.map +1 -1
  408. package/build-module/components/inserter/search-results.js +2 -6
  409. package/build-module/components/inserter/search-results.js.map +1 -1
  410. package/build-module/components/inserter-list-item/index.js +1 -9
  411. package/build-module/components/inserter-list-item/index.js.map +1 -1
  412. package/build-module/components/inspector-controls/fill.js +14 -2
  413. package/build-module/components/inspector-controls/fill.js.map +1 -1
  414. package/build-module/components/inspector-controls/fill.native.js +13 -1
  415. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  416. package/build-module/components/inspector-controls/groups.js +7 -1
  417. package/build-module/components/inspector-controls/groups.js.map +1 -1
  418. package/build-module/components/inspector-controls/index.js +2 -2
  419. package/build-module/components/inspector-controls/index.js.map +1 -1
  420. package/build-module/components/inspector-controls/slot.js +13 -1
  421. package/build-module/components/inspector-controls/slot.js.map +1 -1
  422. package/build-module/components/inspector-controls/slot.native.js +13 -1
  423. package/build-module/components/inspector-controls/slot.native.js.map +1 -1
  424. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
  425. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -1
  426. package/build-module/components/inspector-controls-tabs/index.js +2 -2
  427. package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
  428. package/build-module/components/inspector-controls-tabs/position-controls-panel.js +33 -0
  429. package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
  430. package/build-module/components/inspector-controls-tabs/settings-tab.js +2 -1
  431. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  432. package/build-module/components/inspector-controls-tabs/styles-tab.js +6 -4
  433. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  434. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +20 -22
  435. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  436. package/build-module/components/justify-content-control/ui.js +9 -2
  437. package/build-module/components/justify-content-control/ui.js.map +1 -1
  438. package/build-module/components/link-control/index.js +45 -16
  439. package/build-module/components/link-control/index.js.map +1 -1
  440. package/build-module/components/link-control/search-input.js +1 -0
  441. package/build-module/components/link-control/search-input.js.map +1 -1
  442. package/build-module/components/list-view/block.js +1 -1
  443. package/build-module/components/list-view/block.js.map +1 -1
  444. package/build-module/components/list-view/use-list-view-drop-zone.js +1 -1
  445. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  446. package/build-module/components/media-upload/index.native.js +4 -1
  447. package/build-module/components/media-upload/index.native.js.map +1 -1
  448. package/build-module/components/off-canvas-editor/appender.js +46 -36
  449. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  450. package/build-module/components/off-canvas-editor/block-contents.js +37 -7
  451. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
  452. package/build-module/components/off-canvas-editor/block-select-button.js +9 -4
  453. package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
  454. package/build-module/components/off-canvas-editor/block.js +15 -52
  455. package/build-module/components/off-canvas-editor/block.js.map +1 -1
  456. package/build-module/components/off-canvas-editor/branch.js +23 -11
  457. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  458. package/build-module/components/off-canvas-editor/index.js +15 -16
  459. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  460. package/build-module/components/off-canvas-editor/link-ui.js +2 -2
  461. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
  462. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
  463. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -1
  464. package/build-module/components/provider/index.js +17 -8
  465. package/build-module/components/provider/index.js.map +1 -1
  466. package/build-module/components/provider/index.native.js +4 -4
  467. package/build-module/components/provider/index.native.js.map +1 -1
  468. package/build-module/components/rich-text/use-before-input-rules.js +10 -2
  469. package/build-module/components/rich-text/use-before-input-rules.js.map +1 -1
  470. package/build-module/components/rich-text/use-enter.js +4 -5
  471. package/build-module/components/rich-text/use-enter.js.map +1 -1
  472. package/build-module/components/rich-text/utils.js +1 -1
  473. package/build-module/components/rich-text/utils.js.map +1 -1
  474. package/build-module/components/spacing-sizes-control/utils.js +2 -7
  475. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  476. package/build-module/components/tool-selector/index.js +3 -1
  477. package/build-module/components/tool-selector/index.js.map +1 -1
  478. package/build-module/components/url-input/button.js +1 -0
  479. package/build-module/components/url-input/button.js.map +1 -1
  480. package/build-module/components/url-input/index.js +14 -1
  481. package/build-module/components/url-input/index.js.map +1 -1
  482. package/build-module/components/url-popover/image-url-input-ui.js +8 -8
  483. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  484. package/build-module/components/url-popover/link-editor.js +1 -0
  485. package/build-module/components/url-popover/link-editor.js.map +1 -1
  486. package/build-module/components/use-block-display-information/index.js +1 -1
  487. package/build-module/components/use-block-display-information/index.js.map +1 -1
  488. package/build-module/components/use-paste-styles/index.js +174 -0
  489. package/build-module/components/use-paste-styles/index.js.map +1 -0
  490. package/build-module/components/writing-flow/use-arrow-nav.js +22 -29
  491. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  492. package/build-module/experiments.js +25 -0
  493. package/build-module/experiments.js.map +1 -0
  494. package/build-module/experiments.native.js +23 -0
  495. package/build-module/experiments.native.js.map +1 -0
  496. package/build-module/hooks/anchor.js +2 -1
  497. package/build-module/hooks/anchor.js.map +1 -1
  498. package/build-module/hooks/border.js +1 -1
  499. package/build-module/hooks/border.js.map +1 -1
  500. package/build-module/hooks/child-layout.js +5 -1
  501. package/build-module/hooks/child-layout.js.map +1 -1
  502. package/build-module/hooks/color-panel.js +1 -1
  503. package/build-module/hooks/color-panel.js.map +1 -1
  504. package/build-module/hooks/color.js +3 -3
  505. package/build-module/hooks/color.js.map +1 -1
  506. package/build-module/hooks/custom-class-name.js +2 -1
  507. package/build-module/hooks/custom-class-name.js.map +1 -1
  508. package/build-module/hooks/dimensions.js +6 -5
  509. package/build-module/hooks/dimensions.js.map +1 -1
  510. package/build-module/hooks/index.js +1 -0
  511. package/build-module/hooks/index.js.map +1 -1
  512. package/build-module/hooks/margin.js +1 -0
  513. package/build-module/hooks/margin.js.map +1 -1
  514. package/build-module/hooks/metadata.js +1 -1
  515. package/build-module/hooks/metadata.js.map +1 -1
  516. package/build-module/hooks/padding.js +1 -0
  517. package/build-module/hooks/padding.js.map +1 -1
  518. package/build-module/hooks/position.js +354 -0
  519. package/build-module/hooks/position.js.map +1 -0
  520. package/build-module/hooks/supports.js +257 -0
  521. package/build-module/hooks/supports.js.map +1 -0
  522. package/build-module/hooks/typography.js +1 -1
  523. package/build-module/hooks/typography.js.map +1 -1
  524. package/build-module/hooks/use-color-props.js +3 -3
  525. package/build-module/hooks/use-color-props.js.map +1 -1
  526. package/build-module/hooks/utils.js +70 -4
  527. package/build-module/hooks/utils.js.map +1 -1
  528. package/build-module/index.js +1 -0
  529. package/build-module/index.js.map +1 -1
  530. package/build-module/layouts/constrained.js +3 -0
  531. package/build-module/layouts/constrained.js.map +1 -1
  532. package/build-module/layouts/flex.js +60 -10
  533. package/build-module/layouts/flex.js.map +1 -1
  534. package/build-module/layouts/flow.js +0 -18
  535. package/build-module/layouts/flow.js.map +1 -1
  536. package/build-module/store/actions.js +2 -26
  537. package/build-module/store/actions.js.map +1 -1
  538. package/build-module/store/defaults.js +5 -2
  539. package/build-module/store/defaults.js.map +1 -1
  540. package/build-module/store/index.js +8 -2
  541. package/build-module/store/index.js.map +1 -1
  542. package/build-module/store/private-actions.js +66 -0
  543. package/build-module/store/private-actions.js.map +1 -0
  544. package/build-module/store/private-selectors.js +11 -0
  545. package/build-module/store/private-selectors.js.map +1 -0
  546. package/build-module/store/reducer.js +7 -3
  547. package/build-module/store/reducer.js.map +1 -1
  548. package/build-module/store/selectors.js +55 -30
  549. package/build-module/store/selectors.js.map +1 -1
  550. package/build-module/utils/block-variation-transforms.js +1 -1
  551. package/build-module/utils/block-variation-transforms.js.map +1 -1
  552. package/build-module/utils/parse-css-unit-to-px.js +1 -1
  553. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  554. package/build-module/utils/transform-styles/index.js +1 -6
  555. package/build-module/utils/transform-styles/index.js.map +1 -1
  556. package/build-style/content-rtl.css +340 -3
  557. package/build-style/content.css +340 -3
  558. package/build-style/style-rtl.css +125 -272
  559. package/build-style/style.css +125 -272
  560. package/package.json +30 -29
  561. package/src/components/alignment-control/test/__snapshots__/index.js.snap +3 -3
  562. package/src/components/alignment-control/test/index.js +5 -15
  563. package/src/components/alignment-control/ui.js +1 -1
  564. package/src/components/autocomplete/index.js +3 -6
  565. package/src/components/block-actions/index.js +5 -0
  566. package/src/components/block-alignment-control/test/index.js +3 -11
  567. package/src/components/block-alignment-matrix-control/index.js +1 -2
  568. package/src/components/block-card/index.js +1 -4
  569. package/src/components/block-content-overlay/content.scss +4 -4
  570. package/src/components/block-edit/index.js +15 -1
  571. package/src/components/block-icon/content.scss +31 -0
  572. package/src/components/block-inspector/index.js +15 -17
  573. package/src/components/block-list/use-in-between-inserter.js +5 -0
  574. package/src/components/block-lock/modal.js +0 -1
  575. package/src/components/block-mover/mover-description.js +2 -2
  576. package/src/components/block-mover/stories/index.js +3 -3
  577. package/src/components/block-navigation/dropdown.js +1 -1
  578. package/src/components/block-pattern-setup/index.js +1 -4
  579. package/src/components/block-pattern-setup/use-patterns-setup.js +2 -5
  580. package/src/components/block-patterns-list/index.js +29 -3
  581. package/src/components/block-preview/README.md +9 -9
  582. package/src/components/block-preview/auto.js +10 -14
  583. package/src/components/block-preview/content.scss +23 -0
  584. package/src/components/block-preview/index.js +40 -10
  585. package/src/components/block-preview/style.scss +0 -23
  586. package/src/components/block-selection-clearer/index.js +1 -1
  587. package/src/components/block-selection-clearer/test/index.js +6 -6
  588. package/src/components/block-settings/container.native.js +7 -26
  589. package/src/components/block-settings-menu/block-settings-dropdown.js +14 -2
  590. package/src/components/block-settings-menu-controls/index.js +2 -10
  591. package/src/components/block-styles/index.js +4 -1
  592. package/src/components/block-switcher/test/index.js +43 -44
  593. package/src/components/block-switcher/utils.js +1 -1
  594. package/src/components/block-tools/selected-block-popover.js +77 -80
  595. package/src/components/block-tools/style.scss +0 -1
  596. package/src/components/block-tools/use-block-toolbar-popover-props.js +68 -12
  597. package/src/components/block-variation-picker/{style.scss → content.scss} +0 -0
  598. package/src/components/block-vertical-alignment-control/icons.js +12 -0
  599. package/src/components/block-vertical-alignment-control/test/index.js +3 -11
  600. package/src/components/block-vertical-alignment-control/ui.js +16 -6
  601. package/src/components/button-block-appender/{style.scss → content.scss} +0 -0
  602. package/src/components/color-style-selector/index.js +1 -1
  603. package/src/components/colors/test/with-colors.js +2 -8
  604. package/src/components/date-format-picker/index.js +23 -24
  605. package/src/components/date-format-picker/style.scss +0 -6
  606. package/src/components/default-block-appender/content.scss +18 -0
  607. package/src/components/default-block-appender/test/index.js +2 -8
  608. package/src/components/default-style-picker/index.js +1 -0
  609. package/src/components/font-family/index.js +1 -6
  610. package/src/components/font-sizes/fluid-utils.js +1 -1
  611. package/src/components/font-sizes/utils.js +1 -1
  612. package/src/components/font-sizes/with-font-sizes.js +33 -33
  613. package/src/components/global-styles/README.md +77 -0
  614. package/src/components/global-styles/context.js +15 -0
  615. package/src/components/global-styles/hooks.js +145 -0
  616. package/src/components/global-styles/index.js +7 -0
  617. package/src/components/global-styles/test/typography-utils.js +393 -0
  618. package/src/components/global-styles/test/use-global-styles-output.js +814 -0
  619. package/src/components/global-styles/test/utils.js +206 -0
  620. package/src/components/global-styles/typography-utils.js +87 -0
  621. package/src/components/global-styles/use-global-styles-output.js +1088 -0
  622. package/src/components/global-styles/utils.js +373 -0
  623. package/src/components/height-control/README.md +55 -0
  624. package/src/components/height-control/index.js +13 -1
  625. package/src/components/iframe/index.js +52 -19
  626. package/src/components/iframe/use-compatibility-styles.js +6 -0
  627. package/src/components/image-editor/constants.js +1 -1
  628. package/src/components/image-editor/context.js +5 -9
  629. package/src/components/image-editor/cropper.js +3 -1
  630. package/src/components/image-editor/index.js +13 -4
  631. package/src/components/image-editor/use-transform-image.js +14 -55
  632. package/src/components/image-size-control/index.js +2 -6
  633. package/src/components/index.js +2 -6
  634. package/src/components/inner-blocks/index.js +29 -33
  635. package/src/components/inner-blocks/index.native.js +27 -47
  636. package/src/components/inner-blocks/use-block-context.js +47 -0
  637. package/src/components/inserter/block-patterns-explorer/explorer.js +0 -1
  638. package/src/components/inserter/block-patterns-tab.js +14 -4
  639. package/src/components/inserter/block-types-tab.js +3 -4
  640. package/src/components/inserter/hooks/use-patterns-state.js +1 -6
  641. package/src/components/inserter/index.js +46 -42
  642. package/src/components/inserter/media-tab/hooks.js +167 -65
  643. package/src/components/inserter/media-tab/media-list.js +94 -26
  644. package/src/components/inserter/media-tab/media-panel.js +9 -20
  645. package/src/components/inserter/media-tab/media-tab.js +12 -4
  646. package/src/components/inserter/media-tab/utils.js +20 -10
  647. package/src/components/inserter/menu.js +9 -4
  648. package/src/components/inserter/preview-panel.js +4 -2
  649. package/src/components/inserter/search-results.js +2 -6
  650. package/src/components/inserter/stories/index.js +9 -9
  651. package/src/components/inserter/style.scss +58 -11
  652. package/src/components/inserter/test/__snapshots__/index.native.js.snap +117 -0
  653. package/src/components/inserter/test/index.native.js +255 -1
  654. package/src/components/inserter-list-item/index.js +0 -7
  655. package/src/components/inspector-controls/README.md +3 -7
  656. package/src/components/inspector-controls/fill.js +15 -1
  657. package/src/components/inspector-controls/fill.native.js +14 -1
  658. package/src/components/inspector-controls/groups.js +5 -0
  659. package/src/components/inspector-controls/index.js +2 -6
  660. package/src/components/inspector-controls/slot.js +14 -1
  661. package/src/components/inspector-controls/slot.native.js +14 -1
  662. package/src/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
  663. package/src/components/inspector-controls-tabs/index.js +2 -4
  664. package/src/components/inspector-controls-tabs/position-controls-panel.js +37 -0
  665. package/src/components/inspector-controls-tabs/settings-tab.js +2 -0
  666. package/src/components/inspector-controls-tabs/style.scss +15 -0
  667. package/src/components/inspector-controls-tabs/styles-tab.js +5 -7
  668. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +24 -18
  669. package/src/components/justify-content-control/ui.js +9 -0
  670. package/src/components/link-control/index.js +59 -23
  671. package/src/components/link-control/search-input.js +1 -0
  672. package/src/components/link-control/style.scss +8 -24
  673. package/src/components/link-control/test/index.js +134 -5
  674. package/src/components/list-view/block.js +1 -1
  675. package/src/components/list-view/style.scss +13 -3
  676. package/src/components/list-view/use-list-view-drop-zone.js +1 -1
  677. package/src/components/media-replace-flow/test/index.js +4 -12
  678. package/src/components/media-upload/index.native.js +2 -2
  679. package/src/components/off-canvas-editor/README.md +2 -2
  680. package/src/components/off-canvas-editor/appender.js +82 -76
  681. package/src/components/off-canvas-editor/block-contents.js +84 -23
  682. package/src/components/off-canvas-editor/block-select-button.js +12 -1
  683. package/src/components/off-canvas-editor/block.js +31 -102
  684. package/src/components/off-canvas-editor/branch.js +32 -5
  685. package/src/components/off-canvas-editor/index.js +19 -24
  686. package/src/components/off-canvas-editor/link-ui.js +2 -2
  687. package/src/components/off-canvas-editor/style.scss +5 -1
  688. package/src/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
  689. package/src/components/provider/index.js +33 -11
  690. package/src/components/provider/index.native.js +4 -3
  691. package/src/components/provider/test/experimental-provider.js +94 -0
  692. package/src/components/provider/test/use-block-sync.js +10 -0
  693. package/src/components/responsive-block-control/test/index.js +1 -5
  694. package/src/components/rich-text/use-before-input-rules.js +10 -2
  695. package/src/components/rich-text/use-enter.js +4 -4
  696. package/src/components/rich-text/utils.js +1 -1
  697. package/src/components/spacing-sizes-control/utils.js +2 -7
  698. package/src/components/tool-selector/index.js +1 -1
  699. package/src/components/url-input/README.md +5 -0
  700. package/src/components/url-input/button.js +1 -0
  701. package/src/components/url-input/index.js +15 -1
  702. package/src/components/url-input/test/button.js +24 -24
  703. package/src/components/url-popover/image-url-input-ui.js +7 -8
  704. package/src/components/url-popover/link-editor.js +1 -0
  705. package/src/components/url-popover/style.scss +0 -10
  706. package/src/components/use-block-display-information/index.js +1 -1
  707. package/src/components/use-paste-styles/index.js +230 -0
  708. package/src/components/warning/{style.scss → content.scss} +0 -0
  709. package/src/components/warning/test/index.js +1 -5
  710. package/src/components/writing-flow/use-arrow-nav.js +20 -28
  711. package/src/content.scss +8 -0
  712. package/src/experiments.js +27 -0
  713. package/src/experiments.native.js +25 -0
  714. package/src/hooks/anchor.js +2 -1
  715. package/src/hooks/border.js +1 -1
  716. package/src/hooks/child-layout.js +6 -1
  717. package/src/hooks/color-panel.js +1 -1
  718. package/src/hooks/color.js +3 -3
  719. package/src/hooks/custom-class-name.js +2 -1
  720. package/src/hooks/dimensions.js +6 -6
  721. package/src/hooks/index.js +1 -0
  722. package/src/hooks/layout.scss +4 -0
  723. package/src/hooks/margin.js +1 -0
  724. package/src/hooks/metadata.js +1 -2
  725. package/src/hooks/padding.js +1 -0
  726. package/src/hooks/position.js +391 -0
  727. package/src/hooks/position.scss +18 -0
  728. package/src/hooks/supports.js +302 -0
  729. package/src/hooks/test/__snapshots__/align.native.js.snap +73 -0
  730. package/src/hooks/test/align.native.js +133 -0
  731. package/src/hooks/test/utils.js +104 -0
  732. package/src/hooks/typography.js +1 -1
  733. package/src/hooks/use-color-props.js +3 -3
  734. package/src/hooks/utils.js +68 -2
  735. package/src/index.js +1 -0
  736. package/src/layouts/constrained.js +3 -0
  737. package/src/layouts/flex.js +66 -14
  738. package/src/layouts/flow.js +0 -9
  739. package/src/store/actions.js +2 -26
  740. package/src/store/defaults.js +7 -2
  741. package/src/store/index.js +8 -2
  742. package/src/store/private-actions.js +65 -0
  743. package/src/store/private-selectors.js +10 -0
  744. package/src/store/reducer.js +8 -3
  745. package/src/store/selectors.js +108 -57
  746. package/src/store/test/actions.js +0 -18
  747. package/src/store/test/private-actions.js +22 -0
  748. package/src/store/test/private-selectors.js +24 -0
  749. package/src/store/test/reducer.js +45 -3
  750. package/src/store/test/selectors.js +64 -39
  751. package/src/style.scss +5 -6
  752. package/src/utils/block-variation-transforms.js +1 -1
  753. package/src/utils/parse-css-unit-to-px.js +3 -1
  754. package/src/utils/test/parse-css-unit-to-px.js +16 -24
  755. package/src/utils/transform-styles/index.js +1 -6
  756. package/build/components/inner-blocks/get-block-context.js +0 -45
  757. package/build/components/inner-blocks/get-block-context.js.map +0 -1
  758. package/build/components/off-canvas-editor/block-edit-button.js +0 -50
  759. package/build/components/off-canvas-editor/block-edit-button.js.map +0 -1
  760. package/build-module/components/inner-blocks/get-block-context.js +0 -37
  761. package/build-module/components/inner-blocks/get-block-context.js.map +0 -1
  762. package/build-module/components/off-canvas-editor/block-edit-button.js +0 -35
  763. package/build-module/components/off-canvas-editor/block-edit-button.js.map +0 -1
  764. package/src/components/inner-blocks/get-block-context.js +0 -39
  765. package/src/components/off-canvas-editor/block-edit-button.js +0 -27
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/index.js"],"names":["useMergeRefs","__experimentalUseFixedWindowList","useFixedWindowList","__experimentalTreeGrid","TreeGrid","__experimentalTreeGridRow","TreeGridRow","__experimentalTreeGridCell","TreeGridCell","AsyncModeProvider","useSelect","useCallback","useEffect","useMemo","useRef","useReducer","forwardRef","__","ListViewBranch","ListViewContext","ListViewDropIndicator","useBlockSelection","useListViewClientIds","useListViewDropZone","useListViewExpandSelectedItem","store","blockEditorStore","Appender","expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","__ExperimentalOffCanvasEditor","ref","blocks","showBlockMovers","isExpanded","selectBlockInCanvas","clientIdsTree","draggedClientIds","selectedClientIds","visibleBlockCount","shouldShowInnerBlocks","select","getGlobalBlockCount","getClientIdsOfDescendants","__unstableGetEditorMode","draggedBlockCount","length","updateBlockSelection","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","isMounted","setSelectedTreeId","firstSelectedBlockClientId","selectEditorBlock","event","blockClientId","current","fixedListWindow","useWindowing","windowOverscan","expand","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","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,CADD,CALD,CADD;AAsDA;;AAED,eAAeD,UAAU,CAAEuB,6BAAF,CAAzB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport {\n\t__experimentalTreeGrid as TreeGrid,\n\t__experimentalTreeGridRow as TreeGridRow,\n\t__experimentalTreeGridCell as TreeGridCell,\n} from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport useListViewExpandSelectedItem from './use-list-view-expand-selected-item';\nimport { store as blockEditorStore } from '../../store';\nimport { Appender } from './appender';\n\nconst expanded = ( state, action ) => {\n\tif ( Array.isArray( action.clientIds ) ) {\n\t\treturn {\n\t\t\t...state,\n\t\t\t...action.clientIds.reduce(\n\t\t\t\t( newState, id ) => ( {\n\t\t\t\t\t...newState,\n\t\t\t\t\t[ id ]: action.type === 'expand',\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t};\n\t}\n\treturn state;\n};\n\nexport const BLOCK_LIST_ITEM_HEIGHT = 36;\n\n/**\n * Show a hierarchical list of blocks.\n *\n * @param {Object} props Components props.\n * @param {string} props.id An HTML element id for the root element of ListView.\n * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {boolean} props.showBlockMovers Flag to enable block movers\n * @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.\n * @param {boolean} props.selectBlockInCanvas Flag to determine whether the list view should be a block selection mechanism,.\n * @param {Object} ref Forwarded ref\n */\nfunction __ExperimentalOffCanvasEditor(\n\t{\n\t\tid,\n\t\tblocks,\n\t\tshowBlockMovers = false,\n\t\tisExpanded = false,\n\t\tselectBlockInCanvas = true,\n\t},\n\tref\n) {\n\tconst { clientIdsTree, draggedClientIds, selectedClientIds } =\n\t\tuseListViewClientIds( blocks );\n\n\tconst { visibleBlockCount, shouldShowInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t\tshouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out',\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone();\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst isMounted = useRef( false );\n\tconst { setSelectedTreeId } = useListViewExpandSelectedItem( {\n\t\tfirstSelectedBlockClientId: selectedClientIds[ 0 ],\n\t\tsetExpandedState,\n\t} );\n\tconst selectEditorBlock = useCallback(\n\t\t( event, blockClientId ) => {\n\t\t\tupdateBlockSelection( event, blockClientId );\n\t\t\tsetSelectedTreeId( blockClientId );\n\t\t},\n\t\t[ setSelectedTreeId, updateBlockSelection ]\n\t);\n\tuseEffect( () => {\n\t\tisMounted.current = true;\n\t}, [] );\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\tBLOCK_LIST_ITEM_HEIGHT,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\tuseWindowing: true,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\tconst expand = useCallback(\n\t\t( blockClientId ) => {\n\t\t\tif ( ! blockClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( {\n\t\t\t\ttype: 'expand',\n\t\t\t\tclientIds: [ blockClientId ],\n\t\t\t} );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( blockClientId ) => {\n\t\t\tif ( ! blockClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( {\n\t\t\t\ttype: 'collapse',\n\t\t\t\tclientIds: [ blockClientId ],\n\t\t\t} );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\tconst focusRow = useCallback(\n\t\t( event, startRow, endRow ) => {\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tupdateBlockSelection(\n\t\t\t\t\tevent,\n\t\t\t\t\tstartRow?.dataset?.block,\n\t\t\t\t\tendRow?.dataset?.block\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ updateBlockSelection ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tisTreeGridMounted: isMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t} ),\n\t\t[ isMounted.current, draggedClientIds, expandedState, expand, collapse ]\n\t);\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t<div className=\"offcanvas-editor-list-view-tree-wrapper\">\n\t\t\t\t<TreeGrid\n\t\t\t\t\tid={ id }\n\t\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\t\tref={ treeGridRef }\n\t\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\t\tonFocusRow={ focusRow }\n\t\t\t\t\tapplicationAriaLabel={ __( 'Block navigation structure' ) }\n\t\t\t\t>\n\t\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\tshouldShowInnerBlocks={ shouldShowInnerBlocks }\n\t\t\t\t\t\t\tselectBlockInCanvas={ selectBlockInCanvas }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<TreeGridRow\n\t\t\t\t\t\t\tlevel={ 1 }\n\t\t\t\t\t\t\tsetSize={ 1 }\n\t\t\t\t\t\t\tpositionInSet={ 1 }\n\t\t\t\t\t\t\tisExpanded={ true }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<TreeGridCell>\n\t\t\t\t\t\t\t\t{ ( treeGridCellProps ) => (\n\t\t\t\t\t\t\t\t\t<Appender { ...treeGridCellProps } />\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</TreeGridCell>\n\t\t\t\t\t\t\t{ ! clientIdsTree.length && (\n\t\t\t\t\t\t\t\t<TreeGridCell withoutGridItem>\n\t\t\t\t\t\t\t\t\t<div className=\"offcanvas-editor-list-view-is-empty\">\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'Your menu is currently empty. Add your first menu item to get started.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</TreeGridCell>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridRow>\n\t\t\t\t\t</ListViewContext.Provider>\n\t\t\t\t</TreeGrid>\n\t\t\t</div>\n\t\t</AsyncModeProvider>\n\t);\n}\n\nexport default forwardRef( __ExperimentalOffCanvasEditor );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/index.js"],"names":["useMergeRefs","__experimentalUseFixedWindowList","useFixedWindowList","__experimentalTreeGrid","TreeGrid","__experimentalTreeGridRow","TreeGridRow","__experimentalTreeGridCell","TreeGridCell","AsyncModeProvider","useSelect","useCallback","useEffect","useMemo","useRef","useReducer","forwardRef","__","ListViewBranch","ListViewContext","ListViewDropIndicator","useBlockSelection","useListViewClientIds","useListViewDropZone","useListViewExpandSelectedItem","store","blockEditorStore","expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","OffCanvasEditor","ref","blocks","showBlockMovers","isExpanded","LeafMoreMenu","clientIdsTree","draggedClientIds","selectedClientIds","visibleBlockCount","shouldShowInnerBlocks","select","getGlobalBlockCount","getClientIdsOfDescendants","__unstableGetEditorMode","draggedBlockCount","length","updateBlockSelection","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","isMounted","setSelectedTreeId","firstSelectedBlockClientId","selectEditorBlock","event","blockClientId","current","fixedListWindow","useWindowing","windowOverscan","expand","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","shiftKey","contextValue","isTreeGridMounted"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,YADD,EAECC,gCAAgC,IAAIC,kBAFrC,QAGO,oBAHP;AAIA,SACCC,sBAAsB,IAAIC,QAD3B,EAECC,yBAAyB,IAAIC,WAF9B,EAGCC,0BAA0B,IAAIC,YAH/B,QAIO,uBAJP;AAKA,SAASC,iBAAT,EAA4BC,SAA5B,QAA6C,iBAA7C;AACA,SACCC,WADD,EAECC,SAFD,EAGCC,OAHD,EAICC,MAJD,EAKCC,UALD,EAMCC,UAND,QAOO,oBAPP;AAQA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,UAA3B;AACA,SAASC,eAAT,QAAgC,WAAhC;AACA,OAAOC,qBAAP,MAAkC,kBAAlC;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,OAAOC,oBAAP,MAAiC,4BAAjC;AACA,OAAOC,mBAAP,MAAgC,2BAAhC;AACA,OAAOC,6BAAP,MAA0C,sCAA1C;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;;AAEA,MAAMC,QAAQ,GAAG,CAAEC,KAAF,EAASC,MAAT,KAAqB;AACrC,MAAKC,KAAK,CAACC,OAAN,CAAeF,MAAM,CAACG,SAAtB,CAAL,EAAyC;AACxC,WAAO,EACN,GAAGJ,KADG;AAEN,SAAGC,MAAM,CAACG,SAAP,CAAiBC,MAAjB,CACF,CAAEC,QAAF,EAAYC,EAAZ,MAAsB,EACrB,GAAGD,QADkB;AAErB,SAAEC,EAAF,GAAQN,MAAM,CAACO,IAAP,KAAgB;AAFH,OAAtB,CADE,EAKF,EALE;AAFG,KAAP;AAUA;;AACD,SAAOR,KAAP;AACA,CAdD;;AAgBA,OAAO,MAAMS,sBAAsB,GAAG,EAA/B;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,eAAT,OAECC,GAFD,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imentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport {\n\t__experimentalTreeGrid as TreeGrid,\n\t__experimentalTreeGridRow as TreeGridRow,\n\t__experimentalTreeGridCell as TreeGridCell,\n} from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport useListViewExpandSelectedItem from './use-list-view-expand-selected-item';\nimport { store as blockEditorStore } from '../../store';\n\nconst expanded = ( state, action ) => {\n\tif ( Array.isArray( action.clientIds ) ) {\n\t\treturn {\n\t\t\t...state,\n\t\t\t...action.clientIds.reduce(\n\t\t\t\t( newState, id ) => ( {\n\t\t\t\t\t...newState,\n\t\t\t\t\t[ id ]: action.type === 'expand',\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t};\n\t}\n\treturn state;\n};\n\nexport const BLOCK_LIST_ITEM_HEIGHT = 36;\n\n/**\n * Show a hierarchical list of blocks.\n *\n * @param {Object} props Components props.\n * @param {string} props.id An HTML element id for the root element of ListView.\n * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {boolean} props.showBlockMovers Flag to enable block movers\n * @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.\n * @param {Object} props.LeafMoreMenu Optional more menu substitution.\n * @param {Object} ref Forwarded ref\n */\nfunction OffCanvasEditor(\n\t{ id, blocks, showBlockMovers = false, isExpanded = false, LeafMoreMenu },\n\tref\n) {\n\tconst { clientIdsTree, draggedClientIds, selectedClientIds } =\n\t\tuseListViewClientIds( blocks );\n\n\tconst { visibleBlockCount, shouldShowInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t\tshouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out',\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone();\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst isMounted = useRef( false );\n\tconst { setSelectedTreeId } = useListViewExpandSelectedItem( {\n\t\tfirstSelectedBlockClientId: selectedClientIds[ 0 ],\n\t\tsetExpandedState,\n\t} );\n\tconst selectEditorBlock = useCallback(\n\t\t( event, blockClientId ) => {\n\t\t\tupdateBlockSelection( event, blockClientId );\n\t\t\tsetSelectedTreeId( blockClientId );\n\t\t},\n\t\t[ setSelectedTreeId, updateBlockSelection ]\n\t);\n\tuseEffect( () => {\n\t\tisMounted.current = true;\n\t}, [] );\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\tBLOCK_LIST_ITEM_HEIGHT,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\tuseWindowing: true,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\tconst expand = useCallback(\n\t\t( blockClientId ) => {\n\t\t\tif ( ! blockClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( {\n\t\t\t\ttype: 'expand',\n\t\t\t\tclientIds: [ blockClientId ],\n\t\t\t} );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( blockClientId ) => {\n\t\t\tif ( ! blockClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( {\n\t\t\t\ttype: 'collapse',\n\t\t\t\tclientIds: [ blockClientId ],\n\t\t\t} );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\tconst focusRow = useCallback(\n\t\t( event, startRow, endRow ) => {\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tupdateBlockSelection(\n\t\t\t\t\tevent,\n\t\t\t\t\tstartRow?.dataset?.block,\n\t\t\t\t\tendRow?.dataset?.block\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ updateBlockSelection ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tisTreeGridMounted: isMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tLeafMoreMenu,\n\t\t} ),\n\t\t[\n\t\t\tisMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tLeafMoreMenu,\n\t\t]\n\t);\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t<div className=\"offcanvas-editor-list-view-tree-wrapper\">\n\t\t\t\t<TreeGrid\n\t\t\t\t\tid={ id }\n\t\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\t\tref={ treeGridRef }\n\t\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\t\tonFocusRow={ focusRow }\n\t\t\t\t\tapplicationAriaLabel={ __( 'Block navigation structure' ) }\n\t\t\t\t>\n\t\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\tshouldShowInnerBlocks={ shouldShowInnerBlocks }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<TreeGridRow\n\t\t\t\t\t\t\tlevel={ 1 }\n\t\t\t\t\t\t\tsetSize={ 1 }\n\t\t\t\t\t\t\tpositionInSet={ 1 }\n\t\t\t\t\t\t\tisExpanded={ true }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ! clientIdsTree.length && (\n\t\t\t\t\t\t\t\t<TreeGridCell withoutGridItem>\n\t\t\t\t\t\t\t\t\t<div className=\"offcanvas-editor-list-view-is-empty\">\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'Your menu is currently empty. Add your first menu item to get started.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</TreeGridCell>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridRow>\n\t\t\t\t\t</ListViewContext.Provider>\n\t\t\t\t</TreeGrid>\n\t\t\t</div>\n\t\t</AsyncModeProvider>\n\t);\n}\n\nexport default forwardRef( OffCanvasEditor );\n"]}
@@ -116,9 +116,9 @@ function LinkControlTransforms(_ref) {
116
116
  className: "link-control-transform__subheading"
117
117
  }, __('Transform')), createElement("div", {
118
118
  className: "link-control-transform__items"
119
- }, transforms.map((item, index) => {
119
+ }, transforms.map(item => {
120
120
  return createElement(Button, {
121
- key: `transform-${index}`,
121
+ key: `transform-${item.name}`,
122
122
  onClick: () => replaceBlock(clientId, switchToBlockType(getBlock(clientId), item.name)),
123
123
  className: "link-control-transform__item"
124
124
  }, createElement(BlockIcon, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/link-ui.js"],"names":["__unstableStripHTML","stripHTML","Popover","Button","__","switchToBlockType","useSelect","useDispatch","store","blockEditorStore","LinkControl","BlockIcon","getSuggestionsQuery","type","kind","subtype","LinkControlTransforms","clientId","getBlock","blockTransforms","select","_getBlock","getBlockRootClientId","getBlockTransformItems","replaceBlock","featuredBlocks","transforms","filter","item","includes","name","length","map","index","icon","title","LinkUI","props","label","url","opensInNewTab","link","onClose","anchor","className","hasCreateSuggestion","onChange","onRemove"],"mappings":";AAAA;;AAEA;AACA;AACA;AACA,SAASA,mBAAmB,IAAIC,SAAhC,QAAiD,gBAAjD;AACA,SAASC,OAAT,EAAkBC,MAAlB,QAAgC,uBAAhC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,iBAAT,QAAkC,mBAAlC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,SAAP,MAAsB,eAAtB;AAEA;AACA;AACA;AACA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AcC,IAAAA,aAAd;AAA6B3B,IAAAA,IAA7B;AAAmCC,IAAAA;AAAnC,MAA4CuB,KAAK,CAACI,IAAxD;AACA,QAAMA,IAAI,GAAG;AACZF,IAAAA,GADY;AAEZC,IAAAA,aAFY;AAGZL,IAAAA,KAAK,EAAEG,KAAK,IAAIrC,SAAS,CAAEqC,KAAF;AAHb,GAAb;AAMA,SACC,cAAC,OAAD;AACC,IAAA,SAAS,EAAC,QADX;AAEC,IAAA,OAAO,EAAGD,KAAK,CAACK,OAFjB;AAGC,IAAA,MAAM,EAAGL,KAAK,CAACM,MAHhB;AAIC,IAAA,KAAK;AAJN,KAMC,cAAC,WAAD;AACC,IAAA,cAAc,MADf;AAEC,IAAA,eAAe,MAFhB;AAGC,IAAA,SAAS,EAAGN,KAAK,CAACO,SAHnB;AAIC,IAAA,KAAK,EAAGH,IAJT;AAKC,IAAA,sBAAsB,EAAG,IAL1B;AAMC,IAAA,oBAAoB,EAAGJ,KAAK,CAACQ,mBAN9B;AAOC,IAAA,aAAa,EAAG,CAAC,CAAEhC,IAPpB;AAQC,IAAA,eAAe,EAAG,CAAC,CAAEA,IARtB;AASC,IAAA,gBAAgB,EAAGD,mBAAmB,CAAEC,IAAF,EAAQC,IAAR,CATvC;AAUC,IAAA,QAAQ,EAAGuB,KAAK,CAACS,QAVlB;AAWC,IAAA,QAAQ,EAAGT,KAAK,CAACU,QAXlB;AAYC,IAAA,mBAAmB,EAClB,CAAER,GAAF,GACG,MACA,cAAC,qBAAD;AACC,MAAA,QAAQ,EAAGF,KAAK,CAACpB;AADlB,MAFH,GAMG;AAnBL,IAND,CADD;AA+BA","sourcesContent":["// Note: this file is copied directly from packages/block-library/src/navigation-link/link-ui.js\n\n/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { Popover, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { switchToBlockType } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport LinkControl from '../link-control';\nimport BlockIcon from '../block-icon';\n\n/**\n * Given the Link block's type attribute, return the query params to give to\n * /wp/v2/search.\n *\n * @param {string} type Link block's type attribute.\n * @param {string} kind Link block's entity of kind (post-type|taxonomy)\n * @return {{ type?: string, subtype?: string }} Search query params.\n */\nexport function getSuggestionsQuery( type, kind ) {\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\tcase 'page':\n\t\t\treturn { type: 'post', subtype: type };\n\t\tcase 'category':\n\t\t\treturn { type: 'term', subtype: 'category' };\n\t\tcase 'tag':\n\t\t\treturn { type: 'term', subtype: 'post_tag' };\n\t\tcase 'post_format':\n\t\t\treturn { type: 'post-format' };\n\t\tdefault:\n\t\t\tif ( kind === 'taxonomy' ) {\n\t\t\t\treturn { type: 'term', subtype: type };\n\t\t\t}\n\t\t\tif ( kind === 'post-type' ) {\n\t\t\t\treturn { type: 'post', subtype: type };\n\t\t\t}\n\t\t\treturn {};\n\t}\n}\n\n/**\n * Add transforms to Link Control\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId Block client ID.\n */\nfunction LinkControlTransforms( { clientId } ) {\n\tconst { getBlock, blockTransforms } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlock: _getBlock,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockTransformItems,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tgetBlock: _getBlock,\n\t\t\t\tblockTransforms: getBlockTransformItems(\n\t\t\t\t\t_getBlock( clientId ),\n\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\n\tconst featuredBlocks = [\n\t\t'core/page-list',\n\t\t'core/site-logo',\n\t\t'core/social-links',\n\t\t'core/search',\n\t];\n\n\tconst transforms = blockTransforms.filter( ( item ) => {\n\t\treturn featuredBlocks.includes( item.name );\n\t} );\n\n\tif ( ! transforms?.length ) {\n\t\treturn null;\n\t}\n\n\tif ( ! clientId ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"link-control-transform\">\n\t\t\t<h3 className=\"link-control-transform__subheading\">\n\t\t\t\t{ __( 'Transform' ) }\n\t\t\t</h3>\n\t\t\t<div className=\"link-control-transform__items\">\n\t\t\t\t{ transforms.map( ( item, index ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ `transform-${ index }` }\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\treplaceBlock(\n\t\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\t\tswitchToBlockType(\n\t\t\t\t\t\t\t\t\t\tgetBlock( clientId ),\n\t\t\t\t\t\t\t\t\t\titem.name\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclassName=\"link-control-transform__item\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockIcon icon={ item.icon } />\n\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport function LinkUI( props ) {\n\tconst { label, url, opensInNewTab, type, kind } = props.link;\n\tconst link = {\n\t\turl,\n\t\topensInNewTab,\n\t\ttitle: label && stripHTML( label ),\n\t};\n\n\treturn (\n\t\t<Popover\n\t\t\tplacement=\"bottom\"\n\t\t\tonClose={ props.onClose }\n\t\t\tanchor={ props.anchor }\n\t\t\tshift\n\t\t>\n\t\t\t<LinkControl\n\t\t\t\thasTextControl\n\t\t\t\thasRichPreviews\n\t\t\t\tclassName={ props.className }\n\t\t\t\tvalue={ link }\n\t\t\t\tshowInitialSuggestions={ true }\n\t\t\t\twithCreateSuggestion={ props.hasCreateSuggestion }\n\t\t\t\tnoDirectEntry={ !! type }\n\t\t\t\tnoURLSuggestion={ !! type }\n\t\t\t\tsuggestionsQuery={ getSuggestionsQuery( type, kind ) }\n\t\t\t\tonChange={ props.onChange }\n\t\t\t\tonRemove={ props.onRemove }\n\t\t\t\trenderControlBottom={\n\t\t\t\t\t! url\n\t\t\t\t\t\t? () => (\n\t\t\t\t\t\t\t\t<LinkControlTransforms\n\t\t\t\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: null\n\t\t\t\t}\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/link-ui.js"],"names":["__unstableStripHTML","stripHTML","Popover","Button","__","switchToBlockType","useSelect","useDispatch","store","blockEditorStore","LinkControl","BlockIcon","getSuggestionsQuery","type","kind","subtype","LinkControlTransforms","clientId","getBlock","blockTransforms","select","_getBlock","getBlockRootClientId","getBlockTransformItems","replaceBlock","featuredBlocks","transforms","filter","item","includes","name","length","map","icon","title","LinkUI","props","label","url","opensInNewTab","link","onClose","anchor","className","hasCreateSuggestion","onChange","onRemove"],"mappings":";AAAA;;AAEA;AACA;AACA;AACA,SAASA,mBAAmB,IAAIC,SAAhC,QAAiD,gBAAjD;AACA,SAASC,OAAT,EAAkBC,MAAlB,QAAgC,uBAAhC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,iBAAT,QAAkC,mBAAlC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,SAAP,MAAsB,eAAtB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,mBAAT,CAA8BC,IAA9B,EAAoCC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AK,CAACI,IAAxD;AACA,QAAMA,IAAI,GAAG;AACZF,IAAAA,GADY;AAEZC,IAAAA,aAFY;AAGZL,IAAAA,KAAK,EAAEG,KAAK,IAAIpC,SAAS,CAAEoC,KAAF;AAHb,GAAb;AAMA,SACC,cAAC,OAAD;AACC,IAAA,SAAS,EAAC,QADX;AAEC,IAAA,OAAO,EAAGD,KAAK,CAACK,OAFjB;AAGC,IAAA,MAAM,EAAGL,KAAK,CAACM,MAHhB;AAIC,IAAA,KAAK;AAJN,KAMC,cAAC,WAAD;AACC,IAAA,cAAc,MADf;AAEC,IAAA,eAAe,MAFhB;AAGC,IAAA,SAAS,EAAGN,KAAK,CAACO,SAHnB;AAIC,IAAA,KAAK,EAAGH,IAJT;AAKC,IAAA,sBAAsB,EAAG,IAL1B;AAMC,IAAA,oBAAoB,EAAGJ,KAAK,CAACQ,mBAN9B;AAOC,IAAA,aAAa,EAAG,CAAC,CAAE/B,IAPpB;AAQC,IAAA,eAAe,EAAG,CAAC,CAAEA,IARtB;AASC,IAAA,gBAAgB,EAAGD,mBAAmB,CAAEC,IAAF,EAAQC,IAAR,CATvC;AAUC,IAAA,QAAQ,EAAGsB,KAAK,CAACS,QAVlB;AAWC,IAAA,QAAQ,EAAGT,KAAK,CAACU,QAXlB;AAYC,IAAA,mBAAmB,EAClB,CAAER,GAAF,GACG,MACA,cAAC,qBAAD;AACC,MAAA,QAAQ,EAAGF,KAAK,CAACnB;AADlB,MAFH,GAMG;AAnBL,IAND,CADD;AA+BA","sourcesContent":["// Note: this file is copied directly from packages/block-library/src/navigation-link/link-ui.js\n\n/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { Popover, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { switchToBlockType } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport LinkControl from '../link-control';\nimport BlockIcon from '../block-icon';\n\n/**\n * Given the Link block's type attribute, return the query params to give to\n * /wp/v2/search.\n *\n * @param {string} type Link block's type attribute.\n * @param {string} kind Link block's entity of kind (post-type|taxonomy)\n * @return {{ type?: string, subtype?: string }} Search query params.\n */\nexport function getSuggestionsQuery( type, kind ) {\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\tcase 'page':\n\t\t\treturn { type: 'post', subtype: type };\n\t\tcase 'category':\n\t\t\treturn { type: 'term', subtype: 'category' };\n\t\tcase 'tag':\n\t\t\treturn { type: 'term', subtype: 'post_tag' };\n\t\tcase 'post_format':\n\t\t\treturn { type: 'post-format' };\n\t\tdefault:\n\t\t\tif ( kind === 'taxonomy' ) {\n\t\t\t\treturn { type: 'term', subtype: type };\n\t\t\t}\n\t\t\tif ( kind === 'post-type' ) {\n\t\t\t\treturn { type: 'post', subtype: type };\n\t\t\t}\n\t\t\treturn {};\n\t}\n}\n\n/**\n * Add transforms to Link Control\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId Block client ID.\n */\nfunction LinkControlTransforms( { clientId } ) {\n\tconst { getBlock, blockTransforms } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlock: _getBlock,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockTransformItems,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tgetBlock: _getBlock,\n\t\t\t\tblockTransforms: getBlockTransformItems(\n\t\t\t\t\t_getBlock( clientId ),\n\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\n\tconst featuredBlocks = [\n\t\t'core/page-list',\n\t\t'core/site-logo',\n\t\t'core/social-links',\n\t\t'core/search',\n\t];\n\n\tconst transforms = blockTransforms.filter( ( item ) => {\n\t\treturn featuredBlocks.includes( item.name );\n\t} );\n\n\tif ( ! transforms?.length ) {\n\t\treturn null;\n\t}\n\n\tif ( ! clientId ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"link-control-transform\">\n\t\t\t<h3 className=\"link-control-transform__subheading\">\n\t\t\t\t{ __( 'Transform' ) }\n\t\t\t</h3>\n\t\t\t<div className=\"link-control-transform__items\">\n\t\t\t\t{ transforms.map( ( item ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ `transform-${ item.name }` }\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\treplaceBlock(\n\t\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\t\tswitchToBlockType(\n\t\t\t\t\t\t\t\t\t\tgetBlock( clientId ),\n\t\t\t\t\t\t\t\t\t\titem.name\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclassName=\"link-control-transform__item\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockIcon icon={ item.icon } />\n\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport function LinkUI( props ) {\n\tconst { label, url, opensInNewTab, type, kind } = props.link;\n\tconst link = {\n\t\turl,\n\t\topensInNewTab,\n\t\ttitle: label && stripHTML( label ),\n\t};\n\n\treturn (\n\t\t<Popover\n\t\t\tplacement=\"bottom\"\n\t\t\tonClose={ props.onClose }\n\t\t\tanchor={ props.anchor }\n\t\t\tshift\n\t\t>\n\t\t\t<LinkControl\n\t\t\t\thasTextControl\n\t\t\t\thasRichPreviews\n\t\t\t\tclassName={ props.className }\n\t\t\t\tvalue={ link }\n\t\t\t\tshowInitialSuggestions={ true }\n\t\t\t\twithCreateSuggestion={ props.hasCreateSuggestion }\n\t\t\t\tnoDirectEntry={ !! type }\n\t\t\t\tnoURLSuggestion={ !! type }\n\t\t\t\tsuggestionsQuery={ getSuggestionsQuery( type, kind ) }\n\t\t\t\tonChange={ props.onChange }\n\t\t\t\tonRemove={ props.onRemove }\n\t\t\t\trenderControlBottom={\n\t\t\t\t\t! url\n\t\t\t\t\t\t? () => (\n\t\t\t\t\t\t\t\t<LinkControlTransforms\n\t\t\t\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: null\n\t\t\t\t}\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n"]}
@@ -69,7 +69,7 @@ const ALLOWED_DROP_EDGES = ['top', 'bottom'];
69
69
  * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.
70
70
  * @param {WPPoint} position The point representing the cursor position when dragging.
71
71
  *
72
- * @return {WPListViewDropZoneTarget} An object containing data about the drop target.
72
+ * @return {WPListViewDropZoneTarget | undefined} An object containing data about the drop target.
73
73
  */
74
74
 
75
75
  function getListViewDropTarget(blocksData, position) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/use-list-view-drop-zone.js"],"names":["useSelect","useState","useCallback","useThrottle","__experimentalUseDropZone","useDropZone","getDistanceToNearestEdge","isPointContainedByRect","useOnBlockDrop","store","blockEditorStore","isNestingGesture","point","rect","blockCenterX","left","width","x","ALLOWED_DROP_EDGES","getListViewDropTarget","blocksData","position","candidateEdge","candidateBlockData","candidateDistance","candidateRect","blockData","isDraggedBlock","element","getBoundingClientRect","distance","edge","isCursorWithinBlock","undefined","index","indexOf","previousBlockData","rootClientId","isDraggingBelow","canInsertDraggedBlocksAsChild","innerBlockCount","clientId","blockIndex","dropPosition","canInsertDraggedBlocksAsSibling","offset","useListViewDropZone","getBlockRootClientId","getBlockIndex","getBlockCount","getDraggedBlockClientIds","canInsertBlocks","target","setTarget","targetRootClientId","targetBlockIndex","onBlockDrop","draggedBlockClientIds","throttled","event","currentTarget","clientX","y","clientY","isBlockDrag","length","blockElements","Array","from","querySelectorAll","map","blockElement","dataset","block","includes","newTarget","ref","onDrop","onDragOver","onDragEnd","cancel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,QAAT,EAAmBC,WAAnB,QAAsC,oBAAtC;AACA,SACCC,WADD,EAECC,yBAAyB,IAAIC,WAF9B,QAGO,oBAHP;AAKA;AACA;AACA;;AACA,SACCC,wBADD,EAECC,sBAFD,QAGO,kBAHP;AAIA,OAAOC,cAAP,MAA2B,sBAA3B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,gBAAT,CAA2BC,KAA3B,EAAkCC,IAAlC,EAAyC;AACxC,QAAMC,YAAY,GAAGD,IAAI,CAACE,IAAL,GAAYF,IAAI,CAACG,KAAL,GAAa,CAA9C;AACA,SAAOJ,KAAK,CAACK,CAAN,GAAUH,YAAjB;AACA,C,CAED;AACA;;;AACA,MAAMI,kBAAkB,GAAG,CAAE,KAAF,EAAS,QAAT,CAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,qBAAT,CAAgCC,UAAhC,EAA4CC,QAA5C,EAAuD;AACtD,MAAIC,aAAJ;AACA,MAAIC,kBAAJ;AACA,MAAIC,iBAAJ;AACA,MAAIC,aAAJ;;AAEA,OAAM,MAAMC,SAAZ,IAAyBN,UAAzB,EAAsC;AACrC,QAAKM,SAAS,CAACC,cAAf,EAAgC;AAC/B;AACA;;AAED,UAAMd,IAAI,GAAGa,SAAS,CAACE,OAAV,CAAkBC,qBAAlB,EAAb;AACA,UAAM,CAAEC,QAAF,EAAYC,I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AAK,CAACC,aAAf,CAAT;AACA,KAPuB;;AAQxBmB,IAAAA,SAAS,GAAG;AACXrB,MAAAA,SAAS,CAACsB,MAAV;AACA3B,MAAAA,SAAS,CAAE,IAAF,CAAT;AACA;;AAXuB,GAAF,CAAvB;AAcA,SAAO;AAAEuB,IAAAA,GAAF;AAAOxB,IAAAA;AAAP,GAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useState, useCallback } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n} from '../../utils/math';\nimport useOnBlockDrop from '../use-on-block-drop';\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n\n/**\n * The type of a drag event.\n *\n * @typedef {'default'|'file'|'html'} WPDragEventType\n */\n\n/**\n * An array representing data for blocks in the DOM used by drag and drop.\n *\n * @typedef {Object} WPListViewDropZoneBlocks\n * @property {string} clientId The client id for the block.\n * @property {string} rootClientId The root client id for the block.\n * @property {number} blockIndex The block's index.\n * @property {Element} element The DOM element representing the block.\n * @property {number} innerBlockCount The number of inner blocks the block has.\n * @property {boolean} isDraggedBlock Whether the block is currently being dragged.\n * @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block.\n * @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.\n */\n\n/**\n * An object containing details of a drop target.\n *\n * @typedef {Object} WPListViewDropZoneTarget\n * @property {string} blockIndex The insertion index.\n * @property {string} rootClientId The root client id for the block.\n * @property {string|undefined} clientId The client id for the block.\n * @property {'top'|'bottom'|'inside'} dropPosition The position relative to the block that the user is dropping to.\n * 'inside' refers to nesting as an inner block.\n */\n\n/**\n * Determines whether the user positioning the dragged block to nest as an\n * inner block.\n *\n * Presently this is determined by whether the cursor is on the right hand side\n * of the block.\n *\n * @param {WPPoint} point The point representing the cursor position when dragging.\n * @param {DOMRect} rect The rectangle.\n */\nfunction isNestingGesture( point, rect ) {\n\tconst blockCenterX = rect.left + rect.width / 2;\n\treturn point.x > blockCenterX;\n}\n\n// Block navigation is always a vertical list, so only allow dropping\n// to the above or below a block.\nconst ALLOWED_DROP_EDGES = [ 'top', 'bottom' ];\n\n/**\n * Given blocks data and the cursor position, compute the drop target.\n *\n * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.\n * @param {WPPoint} position The point representing the cursor position when dragging.\n *\n * @return {WPListViewDropZoneTarget} An object containing data about the drop target.\n */\nfunction getListViewDropTarget( blocksData, position ) {\n\tlet candidateEdge;\n\tlet candidateBlockData;\n\tlet candidateDistance;\n\tlet candidateRect;\n\n\tfor ( const blockData of blocksData ) {\n\t\tif ( blockData.isDraggedBlock ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst rect = blockData.element.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\tposition,\n\t\t\trect,\n\t\t\tALLOWED_DROP_EDGES\n\t\t);\n\n\t\tconst isCursorWithinBlock = isPointContainedByRect( position, rect );\n\t\tif (\n\t\t\tcandidateDistance === undefined ||\n\t\t\tdistance < candidateDistance ||\n\t\t\tisCursorWithinBlock\n\t\t) {\n\t\t\tcandidateDistance = distance;\n\n\t\t\tconst index = blocksData.indexOf( blockData );\n\t\t\tconst previousBlockData = blocksData[ index - 1 ];\n\n\t\t\t// If dragging near the top of a block and the preceding block\n\t\t\t// is at the same level, use the preceding block as the candidate\n\t\t\t// instead, as later it makes determining a nesting drop easier.\n\t\t\tif (\n\t\t\t\tedge === 'top' &&\n\t\t\t\tpreviousBlockData &&\n\t\t\t\tpreviousBlockData.rootClientId === blockData.rootClientId &&\n\t\t\t\t! previousBlockData.isDraggedBlock\n\t\t\t) {\n\t\t\t\tcandidateBlockData = previousBlockData;\n\t\t\t\tcandidateEdge = 'bottom';\n\t\t\t\tcandidateRect =\n\t\t\t\t\tpreviousBlockData.element.getBoundingClientRect();\n\t\t\t} else {\n\t\t\t\tcandidateBlockData = blockData;\n\t\t\t\tcandidateEdge = edge;\n\t\t\t\tcandidateRect = rect;\n\t\t\t}\n\n\t\t\t// If the mouse position is within the block, break early\n\t\t\t// as the user would intend to drop either before or after\n\t\t\t// this block.\n\t\t\t//\n\t\t\t// This solves an issue where some rows in the list view\n\t\t\t// tree overlap slightly due to sub-pixel rendering.\n\t\t\tif ( isCursorWithinBlock ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( ! candidateBlockData ) {\n\t\treturn;\n\t}\n\n\tconst isDraggingBelow = candidateEdge === 'bottom';\n\n\t// If the user is dragging towards the bottom of the block check whether\n\t// they might be trying to nest the block as a child.\n\t// If the block already has inner blocks, this should always be treated\n\t// as nesting since the next block in the tree will be the first child.\n\tif (\n\t\tisDraggingBelow &&\n\t\tcandidateBlockData.canInsertDraggedBlocksAsChild &&\n\t\t( candidateBlockData.innerBlockCount > 0 ||\n\t\t\tisNestingGesture( position, candidateRect ) )\n\t) {\n\t\treturn {\n\t\t\trootClientId: candidateBlockData.clientId,\n\t\t\tblockIndex: 0,\n\t\t\tdropPosition: 'inside',\n\t\t};\n\t}\n\n\t// If dropping as a sibling, but block cannot be inserted in\n\t// this context, return early.\n\tif ( ! candidateBlockData.canInsertDraggedBlocksAsSibling ) {\n\t\treturn;\n\t}\n\n\tconst offset = isDraggingBelow ? 1 : 0;\n\treturn {\n\t\trootClientId: candidateBlockData.rootClientId,\n\t\tclientId: candidateBlockData.clientId,\n\t\tblockIndex: candidateBlockData.blockIndex + offset,\n\t\tdropPosition: candidateEdge,\n\t};\n}\n\n/**\n * A react hook for implementing a drop zone in list view.\n *\n * @return {WPListViewDropZoneTarget} The drop target.\n */\nexport default function useListViewDropZone() {\n\tconst {\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t\tgetBlockCount,\n\t\tgetDraggedBlockClientIds,\n\t\tcanInsertBlocks,\n\t} = useSelect( blockEditorStore );\n\tconst [ target, setTarget ] = useState();\n\tconst { rootClientId: targetRootClientId, blockIndex: targetBlockIndex } =\n\t\ttarget || {};\n\n\tconst onBlockDrop = useOnBlockDrop( targetRootClientId, targetBlockIndex );\n\n\tconst draggedBlockClientIds = getDraggedBlockClientIds();\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, currentTarget ) => {\n\t\t\t\tconst position = { x: event.clientX, y: event.clientY };\n\t\t\t\tconst isBlockDrag = !! draggedBlockClientIds?.length;\n\n\t\t\t\tconst blockElements = Array.from(\n\t\t\t\t\tcurrentTarget.querySelectorAll( '[data-block]' )\n\t\t\t\t);\n\n\t\t\t\tconst blocksData = blockElements.map( ( blockElement ) => {\n\t\t\t\t\tconst clientId = blockElement.dataset.block;\n\t\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t\telement: blockElement,\n\t\t\t\t\t\tisDraggedBlock: isBlockDrag\n\t\t\t\t\t\t\t? draggedBlockClientIds.includes( clientId )\n\t\t\t\t\t\t\t: false,\n\t\t\t\t\t\tinnerBlockCount: getBlockCount( clientId ),\n\t\t\t\t\t\tcanInsertDraggedBlocksAsSibling: isBlockDrag\n\t\t\t\t\t\t\t? canInsertBlocks(\n\t\t\t\t\t\t\t\t\tdraggedBlockClientIds,\n\t\t\t\t\t\t\t\t\trootClientId\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: true,\n\t\t\t\t\t\tcanInsertDraggedBlocksAsChild: isBlockDrag\n\t\t\t\t\t\t\t? canInsertBlocks( draggedBlockClientIds, clientId )\n\t\t\t\t\t\t\t: true,\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst newTarget = getListViewDropTarget( blocksData, position );\n\n\t\t\t\tif ( newTarget ) {\n\t\t\t\t\tsetTarget( newTarget );\n\t\t\t\t}\n\t\t\t},\n\t\t\t[ draggedBlockClientIds ]\n\t\t),\n\t\t200\n\t);\n\n\tconst ref = useDropZone( {\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget );\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\tsetTarget( null );\n\t\t},\n\t} );\n\n\treturn { ref, target };\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/use-list-view-drop-zone.js"],"names":["useSelect","useState","useCallback","useThrottle","__experimentalUseDropZone","useDropZone","getDistanceToNearestEdge","isPointContainedByRect","useOnBlockDrop","store","blockEditorStore","isNestingGesture","point","rect","blockCenterX","left","width","x","ALLOWED_DROP_EDGES","getListViewDropTarget","blocksData","position","candidateEdge","candidateBlockData","candidateDistance","candidateRect","blockData","isDraggedBlock","element","getBoundingClientRect","distance","edge","isCursorWithinBlock","undefined","index","indexOf","previousBlockData","rootClientId","isDraggingBelow","canInsertDraggedBlocksAsChild","innerBlockCount","clientId","blockIndex","dropPosition","canInsertDraggedBlocksAsSibling","offset","useListViewDropZone","getBlockRootClientId","getBlockIndex","getBlockCount","getDraggedBlockClientIds","canInsertBlocks","target","setTarget","targetRootClientId","targetBlockIndex","onBlockDrop","draggedBlockClientIds","throttled","event","currentTarget","clientX","y","clientY","isBlockDrag","length","blockElements","Array","from","querySelectorAll","map","blockElement","dataset","block","includes","newTarget","ref","onDrop","onDragOver","onDragEnd","cancel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,QAAT,EAAmBC,WAAnB,QAAsC,oBAAtC;AACA,SACCC,WADD,EAECC,y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AAP,GAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useState, useCallback } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n} from '../../utils/math';\nimport useOnBlockDrop from '../use-on-block-drop';\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n\n/**\n * The type of a drag event.\n *\n * @typedef {'default'|'file'|'html'} WPDragEventType\n */\n\n/**\n * An array representing data for blocks in the DOM used by drag and drop.\n *\n * @typedef {Object} WPListViewDropZoneBlocks\n * @property {string} clientId The client id for the block.\n * @property {string} rootClientId The root client id for the block.\n * @property {number} blockIndex The block's index.\n * @property {Element} element The DOM element representing the block.\n * @property {number} innerBlockCount The number of inner blocks the block has.\n * @property {boolean} isDraggedBlock Whether the block is currently being dragged.\n * @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block.\n * @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.\n */\n\n/**\n * An object containing details of a drop target.\n *\n * @typedef {Object} WPListViewDropZoneTarget\n * @property {string} blockIndex The insertion index.\n * @property {string} rootClientId The root client id for the block.\n * @property {string|undefined} clientId The client id for the block.\n * @property {'top'|'bottom'|'inside'} dropPosition The position relative to the block that the user is dropping to.\n * 'inside' refers to nesting as an inner block.\n */\n\n/**\n * Determines whether the user positioning the dragged block to nest as an\n * inner block.\n *\n * Presently this is determined by whether the cursor is on the right hand side\n * of the block.\n *\n * @param {WPPoint} point The point representing the cursor position when dragging.\n * @param {DOMRect} rect The rectangle.\n */\nfunction isNestingGesture( point, rect ) {\n\tconst blockCenterX = rect.left + rect.width / 2;\n\treturn point.x > blockCenterX;\n}\n\n// Block navigation is always a vertical list, so only allow dropping\n// to the above or below a block.\nconst ALLOWED_DROP_EDGES = [ 'top', 'bottom' ];\n\n/**\n * Given blocks data and the cursor position, compute the drop target.\n *\n * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.\n * @param {WPPoint} position The point representing the cursor position when dragging.\n *\n * @return {WPListViewDropZoneTarget | undefined} An object containing data about the drop target.\n */\nfunction getListViewDropTarget( blocksData, position ) {\n\tlet candidateEdge;\n\tlet candidateBlockData;\n\tlet candidateDistance;\n\tlet candidateRect;\n\n\tfor ( const blockData of blocksData ) {\n\t\tif ( blockData.isDraggedBlock ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst rect = blockData.element.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\tposition,\n\t\t\trect,\n\t\t\tALLOWED_DROP_EDGES\n\t\t);\n\n\t\tconst isCursorWithinBlock = isPointContainedByRect( position, rect );\n\t\tif (\n\t\t\tcandidateDistance === undefined ||\n\t\t\tdistance < candidateDistance ||\n\t\t\tisCursorWithinBlock\n\t\t) {\n\t\t\tcandidateDistance = distance;\n\n\t\t\tconst index = blocksData.indexOf( blockData );\n\t\t\tconst previousBlockData = blocksData[ index - 1 ];\n\n\t\t\t// If dragging near the top of a block and the preceding block\n\t\t\t// is at the same level, use the preceding block as the candidate\n\t\t\t// instead, as later it makes determining a nesting drop easier.\n\t\t\tif (\n\t\t\t\tedge === 'top' &&\n\t\t\t\tpreviousBlockData &&\n\t\t\t\tpreviousBlockData.rootClientId === blockData.rootClientId &&\n\t\t\t\t! previousBlockData.isDraggedBlock\n\t\t\t) {\n\t\t\t\tcandidateBlockData = previousBlockData;\n\t\t\t\tcandidateEdge = 'bottom';\n\t\t\t\tcandidateRect =\n\t\t\t\t\tpreviousBlockData.element.getBoundingClientRect();\n\t\t\t} else {\n\t\t\t\tcandidateBlockData = blockData;\n\t\t\t\tcandidateEdge = edge;\n\t\t\t\tcandidateRect = rect;\n\t\t\t}\n\n\t\t\t// If the mouse position is within the block, break early\n\t\t\t// as the user would intend to drop either before or after\n\t\t\t// this block.\n\t\t\t//\n\t\t\t// This solves an issue where some rows in the list view\n\t\t\t// tree overlap slightly due to sub-pixel rendering.\n\t\t\tif ( isCursorWithinBlock ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( ! candidateBlockData ) {\n\t\treturn;\n\t}\n\n\tconst isDraggingBelow = candidateEdge === 'bottom';\n\n\t// If the user is dragging towards the bottom of the block check whether\n\t// they might be trying to nest the block as a child.\n\t// If the block already has inner blocks, this should always be treated\n\t// as nesting since the next block in the tree will be the first child.\n\tif (\n\t\tisDraggingBelow &&\n\t\tcandidateBlockData.canInsertDraggedBlocksAsChild &&\n\t\t( candidateBlockData.innerBlockCount > 0 ||\n\t\t\tisNestingGesture( position, candidateRect ) )\n\t) {\n\t\treturn {\n\t\t\trootClientId: candidateBlockData.clientId,\n\t\t\tblockIndex: 0,\n\t\t\tdropPosition: 'inside',\n\t\t};\n\t}\n\n\t// If dropping as a sibling, but block cannot be inserted in\n\t// this context, return early.\n\tif ( ! candidateBlockData.canInsertDraggedBlocksAsSibling ) {\n\t\treturn;\n\t}\n\n\tconst offset = isDraggingBelow ? 1 : 0;\n\treturn {\n\t\trootClientId: candidateBlockData.rootClientId,\n\t\tclientId: candidateBlockData.clientId,\n\t\tblockIndex: candidateBlockData.blockIndex + offset,\n\t\tdropPosition: candidateEdge,\n\t};\n}\n\n/**\n * A react hook for implementing a drop zone in list view.\n *\n * @return {WPListViewDropZoneTarget} The drop target.\n */\nexport default function useListViewDropZone() {\n\tconst {\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t\tgetBlockCount,\n\t\tgetDraggedBlockClientIds,\n\t\tcanInsertBlocks,\n\t} = useSelect( blockEditorStore );\n\tconst [ target, setTarget ] = useState();\n\tconst { rootClientId: targetRootClientId, blockIndex: targetBlockIndex } =\n\t\ttarget || {};\n\n\tconst onBlockDrop = useOnBlockDrop( targetRootClientId, targetBlockIndex );\n\n\tconst draggedBlockClientIds = getDraggedBlockClientIds();\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, currentTarget ) => {\n\t\t\t\tconst position = { x: event.clientX, y: event.clientY };\n\t\t\t\tconst isBlockDrag = !! draggedBlockClientIds?.length;\n\n\t\t\t\tconst blockElements = Array.from(\n\t\t\t\t\tcurrentTarget.querySelectorAll( '[data-block]' )\n\t\t\t\t);\n\n\t\t\t\tconst blocksData = blockElements.map( ( blockElement ) => {\n\t\t\t\t\tconst clientId = blockElement.dataset.block;\n\t\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t\telement: blockElement,\n\t\t\t\t\t\tisDraggedBlock: isBlockDrag\n\t\t\t\t\t\t\t? draggedBlockClientIds.includes( clientId )\n\t\t\t\t\t\t\t: false,\n\t\t\t\t\t\tinnerBlockCount: getBlockCount( clientId ),\n\t\t\t\t\t\tcanInsertDraggedBlocksAsSibling: isBlockDrag\n\t\t\t\t\t\t\t? canInsertBlocks(\n\t\t\t\t\t\t\t\t\tdraggedBlockClientIds,\n\t\t\t\t\t\t\t\t\trootClientId\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: true,\n\t\t\t\t\t\tcanInsertDraggedBlocksAsChild: isBlockDrag\n\t\t\t\t\t\t\t? canInsertBlocks( draggedBlockClientIds, clientId )\n\t\t\t\t\t\t\t: true,\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst newTarget = getListViewDropTarget( blocksData, position );\n\n\t\t\t\tif ( newTarget ) {\n\t\t\t\t\tsetTarget( newTarget );\n\t\t\t\t}\n\t\t\t},\n\t\t\t[ draggedBlockClientIds ]\n\t\t),\n\t\t200\n\t);\n\n\tconst ref = useDropZone( {\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget );\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\tsetTarget( null );\n\t\t},\n\t} );\n\n\treturn { ref, target };\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import { createElement } from "@wordpress/element";
2
3
 
3
4
  /**
@@ -13,23 +14,31 @@ import withRegistryProvider from './with-registry-provider';
13
14
  import useBlockSync from './use-block-sync';
14
15
  import { store as blockEditorStore } from '../../store';
15
16
  import { BlockRefsProvider } from './block-refs-provider';
17
+ import { unlock } from '../../experiments';
16
18
  /** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */
17
19
 
18
- function BlockEditorProvider(props) {
20
+ export const ExperimentalBlockEditorProvider = withRegistryProvider(props => {
19
21
  const {
20
22
  children,
21
- settings
23
+ settings,
24
+ stripExperimentalSettings = false
22
25
  } = props;
23
26
  const {
24
- updateSettings
25
- } = useDispatch(blockEditorStore);
27
+ __experimentalUpdateSettings
28
+ } = unlock(useDispatch(blockEditorStore));
26
29
  useEffect(() => {
27
- updateSettings(settings);
30
+ __experimentalUpdateSettings({ ...settings,
31
+ __internalIsInitialized: true
32
+ }, stripExperimentalSettings);
28
33
  }, [settings]); // Syncs the entity provider with changes in the block-editor store.
29
34
 
30
35
  useBlockSync(props);
31
36
  return createElement(BlockRefsProvider, null, children);
32
- }
33
-
34
- export default withRegistryProvider(BlockEditorProvider);
37
+ });
38
+ export const BlockEditorProvider = props => {
39
+ return createElement(ExperimentalBlockEditorProvider, _extends({}, props, {
40
+ stripExperimentalSettings: true
41
+ }), props.children);
42
+ };
43
+ export default BlockEditorProvider;
35
44
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/provider/index.js"],"names":["useDispatch","useEffect","withRegistryProvider","useBlockSync","store","blockEditorStore","BlockRefsProvider","BlockEditorProvider","props","children","settings","updateSettings"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,iBAA5B;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,iBAAT,QAAkC,uBAAlC;AAEA;;AAEA,SAASC,mBAAT,CAA8BC,KAA9B,EAAsC;AACrC,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAyBF,KAA/B;AAEA,QAAM;AAAEG,IAAAA;AAAF,MAAqBX,WAAW,CAAEK,gBAAF,CAAtC;AACAJ,EAAAA,SAAS,CAAE,MAAM;AAChBU,IAAAA,cAAc,CAAED,QAAF,CAAd;AACA,GAFQ,EAEN,CAAEA,QAAF,CAFM,CAAT,CAJqC,CAQrC;;AACAP,EAAAA,YAAY,CAAEK,KAAF,CAAZ;AAEA,SAAO,cAAC,iBAAD,QAAqBC,QAArB,CAAP;AACA;;AAED,eAAeP,oBAAoB,CAAEK,mBAAF,CAAnC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport useBlockSync from './use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockRefsProvider } from './block-refs-provider';\n\n/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */\n\nfunction BlockEditorProvider( props ) {\n\tconst { children, settings } = props;\n\n\tconst { updateSettings } = useDispatch( blockEditorStore );\n\tuseEffect( () => {\n\t\tupdateSettings( settings );\n\t}, [ settings ] );\n\n\t// Syncs the entity provider with changes in the block-editor store.\n\tuseBlockSync( props );\n\n\treturn <BlockRefsProvider>{ children }</BlockRefsProvider>;\n}\n\nexport default withRegistryProvider( BlockEditorProvider );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/provider/index.js"],"names":["useDispatch","useEffect","withRegistryProvider","useBlockSync","store","blockEditorStore","BlockRefsProvider","unlock","ExperimentalBlockEditorProvider","props","children","settings","stripExperimentalSettings","__experimentalUpdateSettings","__internalIsInitialized","BlockEditorProvider"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,iBAA5B;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,iBAAT,QAAkC,uBAAlC;AACA,SAASC,MAAT,QAAuB,mBAAvB;AAEA;;AAEA,OAAO,MAAMC,+BAA+B,GAAGN,oBAAoB,CAChEO,KAAF,IAAa;AACZ,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,QAAZ;AAAsBC,IAAAA,yBAAyB,GAAG;AAAlD,MAA4DH,KAAlE;AAEA,QAAM;AAAEI,IAAAA;AAAF,MAAmCN,MAAM,CAC9CP,WAAW,CAAEK,gBAAF,CADmC,CAA/C;AAGAJ,EAAAA,SAAS,CAAE,MAAM;AAChBY,IAAAA,4BAA4B,CAC3B,EACC,GAAGF,QADJ;AAECG,MAAAA,uBAAuB,EAAE;AAF1B,KAD2B,EAK3BF,yBAL2B,CAA5B;AAOA,GARQ,EAQN,CAAED,QAAF,CARM,CAAT,CANY,CAgBZ;;AACAR,EAAAA,YAAY,CAAEM,KAAF,CAAZ;AAEA,SAAO,cAAC,iBAAD,QAAqBC,QAArB,CAAP;AACA,CArBiE,CAA5D;AAwBP,OAAO,MAAMK,mBAAmB,GAAKN,KAAF,IAAa;AAC/C,SACC,cAAC,+BAAD,eACMA,KADN;AAEC,IAAA,yBAAyB,EAAG;AAF7B,MAIGA,KAAK,CAACC,QAJT,CADD;AAQA,CATM;AAWP,eAAeK,mBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport useBlockSync from './use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockRefsProvider } from './block-refs-provider';\nimport { unlock } from '../../experiments';\n\n/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */\n\nexport const ExperimentalBlockEditorProvider = withRegistryProvider(\n\t( props ) => {\n\t\tconst { children, settings, stripExperimentalSettings = false } = props;\n\n\t\tconst { __experimentalUpdateSettings } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\t\tuseEffect( () => {\n\t\t\t__experimentalUpdateSettings(\n\t\t\t\t{\n\t\t\t\t\t...settings,\n\t\t\t\t\t__internalIsInitialized: true,\n\t\t\t\t},\n\t\t\t\tstripExperimentalSettings\n\t\t\t);\n\t\t}, [ settings ] );\n\n\t\t// Syncs the entity provider with changes in the block-editor store.\n\t\tuseBlockSync( props );\n\n\t\treturn <BlockRefsProvider>{ children }</BlockRefsProvider>;\n\t}\n);\n\nexport const BlockEditorProvider = ( props ) => {\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\t{ ...props }\n\t\t\tstripExperimentalSettings={ true }\n\t\t>\n\t\t\t{ props.children }\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n};\n\nexport default BlockEditorProvider;\n"]}
@@ -15,7 +15,7 @@ import { store as blockEditorStore } from '../../store';
15
15
  import { BlockRefsProvider } from './block-refs-provider';
16
16
  /** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */
17
17
 
18
- function BlockEditorProvider(props) {
18
+ const BlockEditorProvider = withRegistryProvider(function (props) {
19
19
  const {
20
20
  children,
21
21
  settings
@@ -29,7 +29,7 @@ function BlockEditorProvider(props) {
29
29
 
30
30
  useBlockSync(props);
31
31
  return createElement(BlockRefsProvider, null, children);
32
- }
33
-
34
- export default withRegistryProvider(BlockEditorProvider);
32
+ });
33
+ export default BlockEditorProvider;
34
+ export { BlockEditorProvider as ExperimentalBlockEditorProvider };
35
35
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/provider/index.native.js"],"names":["useDispatch","useEffect","withRegistryProvider","useBlockSync","store","blockEditorStore","BlockRefsProvider","BlockEditorProvider","props","children","settings","updateSettings"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,iBAA5B;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,iBAAT,QAAkC,uBAAlC;AAEA;;AAEA,SAASC,mBAAT,CAA8BC,KAA9B,EAAsC;AACrC,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAyBF,KAA/B;AAEA,QAAM;AAAEG,IAAAA;AAAF,MAAqBX,WAAW,CAAEK,gBAAF,CAAtC;AACAJ,EAAAA,SAAS,CAAE,MAAM;AAChBU,IAAAA,cAAc,CAAED,QAAF,CAAd;AACA,GAFQ,EAEN,CAAEA,QAAF,CAFM,CAAT,CAJqC,CAQrC;;AACAP,EAAAA,YAAY,CAAEK,KAAF,CAAZ;AAEA,SAAO,cAAC,iBAAD,QAAqBC,QAArB,CAAP;AACA;;AAED,eAAeP,oBAAoB,CAAEK,mBAAF,CAAnC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport useBlockSync from './use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockRefsProvider } from './block-refs-provider';\n\n/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */\n\nfunction BlockEditorProvider( props ) {\n\tconst { children, settings } = props;\n\n\tconst { updateSettings } = useDispatch( blockEditorStore );\n\tuseEffect( () => {\n\t\tupdateSettings( settings );\n\t}, [ settings ] );\n\n\t// Syncs the entity provider with changes in the block-editor store.\n\tuseBlockSync( props );\n\n\treturn <BlockRefsProvider>{ children }</BlockRefsProvider>;\n}\n\nexport default withRegistryProvider( BlockEditorProvider );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/provider/index.native.js"],"names":["useDispatch","useEffect","withRegistryProvider","useBlockSync","store","blockEditorStore","BlockRefsProvider","BlockEditorProvider","props","children","settings","updateSettings","ExperimentalBlockEditorProvider"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,iBAA5B;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,iBAAT,QAAkC,uBAAlC;AAEA;;AAEA,MAAMC,mBAAmB,GAAGL,oBAAoB,CAAE,UAAWM,KAAX,EAAmB;AACpE,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAyBF,KAA/B;AAEA,QAAM;AAAEG,IAAAA;AAAF,MAAqBX,WAAW,CAAEK,gBAAF,CAAtC;AACAJ,EAAAA,SAAS,CAAE,MAAM;AAChBU,IAAAA,cAAc,CAAED,QAAF,CAAd;AACA,GAFQ,EAEN,CAAEA,QAAF,CAFM,CAAT,CAJoE,CAQpE;;AACAP,EAAAA,YAAY,CAAEK,KAAF,CAAZ;AAEA,SAAO,cAAC,iBAAD,QAAqBC,QAArB,CAAP;AACA,CAZ+C,CAAhD;AAcA,eAAeF,mBAAf;AACA,SAASA,mBAAmB,IAAIK,+BAAhC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport useBlockSync from './use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockRefsProvider } from './block-refs-provider';\n\n/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */\n\nconst BlockEditorProvider = withRegistryProvider( function ( props ) {\n\tconst { children, settings } = props;\n\n\tconst { updateSettings } = useDispatch( blockEditorStore );\n\tuseEffect( () => {\n\t\tupdateSettings( settings );\n\t}, [ settings ] );\n\n\t// Syncs the entity provider with changes in the block-editor store.\n\tuseBlockSync( props );\n\n\treturn <BlockRefsProvider>{ children }</BlockRefsProvider>;\n} );\n\nexport default BlockEditorProvider;\nexport { BlockEditorProvider as ExperimentalBlockEditorProvider };\n"]}
@@ -80,10 +80,18 @@ export function useBeforeInputRules(props) {
80
80
  const {
81
81
  defaultView
82
82
  } = ownerDocument;
83
- const newEvent = new defaultView.InputEvent('input', init); // Dispatch an input event with the new data. This will trigger the
83
+ const newEvent = new defaultView.InputEvent('input', init); // Dispatch an `input` event with the new data. This will trigger the
84
84
  // input rules.
85
+ // Postpone the `input` to the next event loop tick so that the dispatch
86
+ // doesn't happen synchronously in the middle of `beforeinput` dispatch.
87
+ // This is closer to how native `input` event would be timed, and also
88
+ // makes sure that the `input` event is dispatched only after the `onChange`
89
+ // call few lines above has fully updated the data store state and rerendered
90
+ // all affected components.
85
91
 
86
- event.target.dispatchEvent(newEvent);
92
+ window.queueMicrotask(() => {
93
+ event.target.dispatchEvent(newEvent);
94
+ });
87
95
  event.preventDefault();
88
96
  }
89
97
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-before-input-rules.js"],"names":["useRef","useRefEffect","insert","isCollapsed","useDispatch","applyFilters","store","blockEditorStore","wrapSelectionSettings","useBeforeInputRules","props","__unstableMarkLastChangeAsPersistent","__unstableMarkAutomaticChange","propsRef","current","element","onInput","event","inputType","data","value","onChange","pair","find","startChar","endChar","start","end","length","newValue","init","key","ownerDocument","defaultView","newEvent","InputEvent","target","dispatchEvent","preventDefault","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,oBAAvB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,MAAT,EAAiBC,WAAjB,QAAoC,sBAApC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,YAAT,QAA6B,kBAA7B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,qBAAqB,GAAG,CAAE,GAAF,EAAO,GAAP,EAAY,GAAZ,EAAiB,IAAjB,EAAuB,IAAvB,CAA9B;AAEA,OAAO,SAASC,mBAAT,CAA8BC,KAA9B,EAAsC;AAC5C,QAAM;AACLC,IAAAA,oCADK;AAELC,IAAAA;AAFK,MAGFR,WAAW,CAAEG,gBAAF,CAHf;AAIA,QAAMM,QAAQ,GAAGb,MAAM,CAAEU,KAAF,CAAvB;AACAG,EAAAA,QAAQ,CAACC,OAAT,GAAmBJ,KAAnB;AACA,SAAOT,YAAY,CAAIc,OAAF,IAAe;AACnC,aAASC,OAAT,CAAkBC,KAAlB,EAA0B;AACzB,YAAM;AAAEC,QAAAA,SAAF;AAAaC,QAAAA;AAAb,UAAsBF,KAA5B;AACA,YAAM;AAAEG,QAAAA,KAAF;AAASC,QAAAA;AAAT,UAAsBR,QAAQ,CAACC,OAArC,CAFyB,CAIzB;;AACA,UAAKI,SAAS,KAAK,YAAnB,EAAkC;AACjC;AACA;;AAED,UAAKf,WAAW,CAAEiB,KAAF,CAAhB,EAA4B;AAC3B;AACA;;AAED,YAAME,IAAI,GAAGjB,YAAY,CACxB,mCADwB,EAExBG,qBAFwB,CAAZ,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AAyCvB,OAAzC;AACA,WAAO,MAAM;AACZD,MAAAA,OAAO,CAACyB,mBAAR,CAA6B,aAA7B,EAA4CxB,OAA5C;AACA,KAFD;AAGA,GA3DkB,EA2DhB,EA3DgB,CAAnB;AA4DA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { insert, isCollapsed } from '@wordpress/rich-text';\nimport { useDispatch } from '@wordpress/data';\nimport { applyFilters } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * When typing over a selection, the selection will we wrapped by a matching\n * character pair. The second character is optional, it defaults to the first\n * character.\n *\n * @type {string[]} Array of character pairs.\n */\nconst wrapSelectionSettings = [ '`', '\"', \"'\", '“”', '‘’' ];\n\nexport function useBeforeInputRules( props ) {\n\tconst {\n\t\t__unstableMarkLastChangeAsPersistent,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction onInput( event ) {\n\t\t\tconst { inputType, data } = event;\n\t\t\tconst { value, onChange } = propsRef.current;\n\n\t\t\t// Only run the rules when inserting text.\n\t\t\tif ( inputType !== 'insertText' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( isCollapsed( value ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst pair = applyFilters(\n\t\t\t\t'blockEditor.wrapSelectionSettings',\n\t\t\t\twrapSelectionSettings\n\t\t\t).find(\n\t\t\t\t( [ startChar, endChar ] ) =>\n\t\t\t\t\tstartChar === data || endChar === data\n\t\t\t);\n\n\t\t\tif ( ! pair ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst [ startChar, endChar = startChar ] = pair;\n\t\t\tconst start = value.start;\n\t\t\tconst end = value.end + startChar.length;\n\n\t\t\tlet newValue = insert( value, startChar, start, start );\n\t\t\tnewValue = insert( newValue, endChar, end, end );\n\n\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\tonChange( newValue );\n\t\t\t__unstableMarkAutomaticChange();\n\n\t\t\tconst init = {};\n\n\t\t\tfor ( const key in event ) {\n\t\t\t\tinit[ key ] = event[ key ];\n\t\t\t}\n\n\t\t\tinit.data = endChar;\n\n\t\t\tconst { ownerDocument } = element;\n\t\t\tconst { defaultView } = ownerDocument;\n\t\t\tconst newEvent = new defaultView.InputEvent( 'input', init );\n\n\t\t\t// Dispatch an input event with the new data. This will trigger the\n\t\t\t// input rules.\n\t\t\tevent.target.dispatchEvent( newEvent );\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\telement.addEventListener( 'beforeinput', onInput );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'beforeinput', onInput );\n\t\t};\n\t}, [] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-before-input-rules.js"],"names":["useRef","useRefEffect","insert","isCollapsed","useDispatch","applyFilters","store","blockEditorStore","wrapSelectionSettings","useBeforeInputRules","props","__unstableMarkLastChangeAsPersistent","__unstableMarkAutomaticChange","propsRef","current","element","onInput","event","inputType","data","value","onChange","pair","find","startChar","endChar","start","end","length","newValue","init","key","ownerDocument","defaultView","newEvent","InputEvent","window","queueMicrotask","target","dispatchEvent","preventDefault","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,oBAAvB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,MAAT,EAAiBC,WAAjB,QAAoC,sBAApC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,YAAT,QAA6B,kBAA7B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,qBAAqB,GAAG,CAAE,GAAF,EAAO,GAAP,EAAY,GAAZ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AArB,EAA0BA,GAA1B,CAAjB;;AAEAhB,MAAAA,oCAAoC;;AACpCU,MAAAA,QAAQ,CAAEQ,QAAF,CAAR;;AACAjB,MAAAA,6BAA6B;;AAE7B,YAAMkB,IAAI,GAAG,EAAb;;AAEA,WAAM,MAAMC,GAAZ,IAAmBd,KAAnB,EAA2B;AAC1Ba,QAAAA,IAAI,CAAEC,GAAF,CAAJ,GAAcd,KAAK,CAAEc,GAAF,CAAnB;AACA;;AAEDD,MAAAA,IAAI,CAACX,IAAL,GAAYM,OAAZ;AAEA,YAAM;AAAEO,QAAAA;AAAF,UAAoBjB,OAA1B;AACA,YAAM;AAAEkB,QAAAA;AAAF,UAAkBD,aAAxB;AACA,YAAME,QAAQ,GAAG,IAAID,WAAW,CAACE,UAAhB,CAA4B,OAA5B,EAAqCL,IAArC,CAAjB,CA9CyB,CAgDzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAM,MAAAA,MAAM,CAACC,cAAP,CAAuB,MAAM;AAC5BpB,QAAAA,KAAK,CAACqB,MAAN,CAAaC,aAAb,CAA4BL,QAA5B;AACA,OAFD;AAGAjB,MAAAA,KAAK,CAACuB,cAAN;AACA;;AAEDzB,IAAAA,OAAO,CAAC0B,gBAAR,CAA0B,aAA1B,EAAyCzB,OAAzC;AACA,WAAO,MAAM;AACZD,MAAAA,OAAO,CAAC2B,mBAAR,CAA6B,aAA7B,EAA4C1B,OAA5C;AACA,KAFD;AAGA,GAnEkB,EAmEhB,EAnEgB,CAAnB;AAoEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { insert, isCollapsed } from '@wordpress/rich-text';\nimport { useDispatch } from '@wordpress/data';\nimport { applyFilters } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * When typing over a selection, the selection will we wrapped by a matching\n * character pair. The second character is optional, it defaults to the first\n * character.\n *\n * @type {string[]} Array of character pairs.\n */\nconst wrapSelectionSettings = [ '`', '\"', \"'\", '“”', '‘’' ];\n\nexport function useBeforeInputRules( props ) {\n\tconst {\n\t\t__unstableMarkLastChangeAsPersistent,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction onInput( event ) {\n\t\t\tconst { inputType, data } = event;\n\t\t\tconst { value, onChange } = propsRef.current;\n\n\t\t\t// Only run the rules when inserting text.\n\t\t\tif ( inputType !== 'insertText' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( isCollapsed( value ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst pair = applyFilters(\n\t\t\t\t'blockEditor.wrapSelectionSettings',\n\t\t\t\twrapSelectionSettings\n\t\t\t).find(\n\t\t\t\t( [ startChar, endChar ] ) =>\n\t\t\t\t\tstartChar === data || endChar === data\n\t\t\t);\n\n\t\t\tif ( ! pair ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst [ startChar, endChar = startChar ] = pair;\n\t\t\tconst start = value.start;\n\t\t\tconst end = value.end + startChar.length;\n\n\t\t\tlet newValue = insert( value, startChar, start, start );\n\t\t\tnewValue = insert( newValue, endChar, end, end );\n\n\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\tonChange( newValue );\n\t\t\t__unstableMarkAutomaticChange();\n\n\t\t\tconst init = {};\n\n\t\t\tfor ( const key in event ) {\n\t\t\t\tinit[ key ] = event[ key ];\n\t\t\t}\n\n\t\t\tinit.data = endChar;\n\n\t\t\tconst { ownerDocument } = element;\n\t\t\tconst { defaultView } = ownerDocument;\n\t\t\tconst newEvent = new defaultView.InputEvent( 'input', init );\n\n\t\t\t// Dispatch an `input` event with the new data. This will trigger the\n\t\t\t// input rules.\n\t\t\t// Postpone the `input` to the next event loop tick so that the dispatch\n\t\t\t// doesn't happen synchronously in the middle of `beforeinput` dispatch.\n\t\t\t// This is closer to how native `input` event would be timed, and also\n\t\t\t// makes sure that the `input` event is dispatched only after the `onChange`\n\t\t\t// call few lines above has fully updated the data store state and rerendered\n\t\t\t// all affected components.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tevent.target.dispatchEvent( newEvent );\n\t\t\t} );\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\telement.addEventListener( 'beforeinput', onInput );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'beforeinput', onInput );\n\t\t};\n\t}, [] );\n}\n"]}
@@ -25,6 +25,10 @@ export function useEnter(props) {
25
25
  return;
26
26
  }
27
27
 
28
+ if (event.keyCode !== ENTER) {
29
+ return;
30
+ }
31
+
28
32
  const {
29
33
  removeEditorOnlyFormats,
30
34
  value,
@@ -36,11 +40,6 @@ export function useEnter(props) {
36
40
  disableLineBreaks,
37
41
  onSplitAtEnd
38
42
  } = propsRef.current;
39
-
40
- if (event.keyCode !== ENTER) {
41
- return;
42
- }
43
-
44
43
  event.preventDefault();
45
44
  const _value = { ...value
46
45
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-enter.js"],"names":["useRef","useRefEffect","ENTER","insert","__unstableIsEmptyLine","isEmptyLine","__unstableInsertLineSeparator","insertLineSeparator","getBlockTransforms","findTransform","useDispatch","store","blockEditorStore","splitValue","useEnter","props","__unstableMarkAutomaticChange","propsRef","current","element","onKeyDown","event","defaultPrevented","removeEditorOnlyFormats","value","onReplace","onSplit","onSplitMiddle","multilineTag","onChange","disableLineBreaks","onSplitAtEnd","keyCode","preventDefault","_value","formats","canSplit","transforms","filter","type","transformation","item","regExp","test","text","transform","content","shiftKey","start","end","canSplitAtEnd","length","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,oBAAvB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,KAAT,QAAsB,qBAAtB;AACA,SACCC,MADD,E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AA2B;AAC1BD,YAAAA,QAAQ,CAAE1B,MAAM,CAAE+B,MAAF,EAAU,IAAV,CAAR,CAAR;AACA;AACD,SAJD,MAIO,IAAK,CAAEE,QAAF,IAAcc,aAAnB,EAAmC;AACzCnB,UAAAA,YAAY;AACZ,SAFM,MAEA,IAAKK,QAAL,EAAgB;AACtBvB,UAAAA,UAAU,CAAE;AACXW,YAAAA,KAAK,EAAEU,MADI;AAEXT,YAAAA,SAFW;AAGXC,YAAAA,OAHW;AAIXC,YAAAA,aAJW;AAKXC,YAAAA;AALW,WAAF,CAAV;AAOA;AACD;AACD;;AAEDT,IAAAA,OAAO,CAACiC,gBAAR,CAA0B,SAA1B,EAAqChC,SAArC;AACA,WAAO,MAAM;AACZD,MAAAA,OAAO,CAACkC,mBAAR,CAA6B,SAA7B,EAAwCjC,SAAxC;AACA,KAFD;AAGA,GAzFkB,EAyFhB,EAzFgB,CAAnB;AA0FA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER } from '@wordpress/keycodes';\nimport {\n\tinsert,\n\t__unstableIsEmptyLine as isEmptyLine,\n\t__unstableInsertLineSeparator as insertLineSeparator,\n} from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { splitValue } from './split-value';\n\nexport function useEnter( props ) {\n\tconst { __unstableMarkAutomaticChange } = useDispatch( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\tvalue,\n\t\t\t\tonReplace,\n\t\t\t\tonSplit,\n\t\t\t\tonSplitMiddle,\n\t\t\t\tmultilineTag,\n\t\t\t\tonChange,\n\t\t\t\tdisableLineBreaks,\n\t\t\t\tonSplitAtEnd,\n\t\t\t} = propsRef.current;\n\n\t\t\tif ( event.keyCode !== ENTER ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\n\t\t\tconst _value = { ...value };\n\t\t\t_value.formats = removeEditorOnlyFormats( value );\n\t\t\tconst canSplit = onReplace && onSplit;\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t);\n\t\t\t\tconst transformation = findTransform( transforms, ( item ) => {\n\t\t\t\t\treturn item.regExp.test( _value.text );\n\t\t\t\t} );\n\n\t\t\t\tif ( transformation ) {\n\t\t\t\t\tonReplace( [\n\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\tcontent: _value.text,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t] );\n\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( multilineTag ) {\n\t\t\t\tif ( event.shiftKey ) {\n\t\t\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\t\t\tonChange( insert( _value, '\\n' ) );\n\t\t\t\t\t}\n\t\t\t\t} else if ( canSplit && isEmptyLine( _value ) ) {\n\t\t\t\t\tsplitValue( {\n\t\t\t\t\t\tvalue: _value,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tonChange( insertLineSeparator( _value ) );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst { text, start, end } = _value;\n\t\t\t\tconst canSplitAtEnd =\n\t\t\t\t\tonSplitAtEnd && start === end && end === text.length;\n\n\t\t\t\tif ( event.shiftKey || ( ! canSplit && ! canSplitAtEnd ) ) {\n\t\t\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\t\t\tonChange( insert( _value, '\\n' ) );\n\t\t\t\t\t}\n\t\t\t\t} else if ( ! canSplit && canSplitAtEnd ) {\n\t\t\t\t\tonSplitAtEnd();\n\t\t\t\t} else if ( canSplit ) {\n\t\t\t\t\tsplitValue( {\n\t\t\t\t\t\tvalue: _value,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-enter.js"],"names":["useRef","useRefEffect","ENTER","insert","__unstableIsEmptyLine","isEmptyLine","__unstableInsertLineSeparator","insertLineSeparator","getBlockTransforms","findTransform","useDispatch","store","blockEditorStore","splitValue","useEnter","props","__unstableMarkAutomaticChange","propsRef","current","element","onKeyDown","event","defaultPrevented","keyCode","removeEditorOnlyFormats","value","onReplace","onSplit","onSplitMiddle","multilineTag","onChange","disableLineBreaks","onSplitAtEnd","preventDefault","_value","formats","canSplit","transforms","filter","type","transformation","item","regExp","test","text","transform","content","shiftKey","start","end","canSplitAtEnd","length","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,oBAAvB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,KAAT,QAAsB,qBAAtB;AACA,SACCC,MADD,EAECC,qBAAqB,IAAIC,WAF1B,EAGCC,6BAA6B,IAAIC,mBAHlC,QAIO,sBAJP;AAKA,SAASC,kBAAT,EAA6BC,aAA7B,QAAkD,mBAAlD;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA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A,IAAKI,QAAL,EAAgB;AACtBvB,UAAAA,UAAU,CAAE;AACXY,YAAAA,KAAK,EAAES,MADI;AAEXR,YAAAA,SAFW;AAGXC,YAAAA,OAHW;AAIXC,YAAAA,aAJW;AAKXC,YAAAA;AALW,WAAF,CAAV;AAOA;AACD;AACD;;AAEDV,IAAAA,OAAO,CAACiC,gBAAR,CAA0B,SAA1B,EAAqChC,SAArC;AACA,WAAO,MAAM;AACZD,MAAAA,OAAO,CAACkC,mBAAR,CAA6B,SAA7B,EAAwCjC,SAAxC;AACA,KAFD;AAGA,GAzFkB,EAyFhB,EAzFgB,CAAnB;AA0FA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER } from '@wordpress/keycodes';\nimport {\n\tinsert,\n\t__unstableIsEmptyLine as isEmptyLine,\n\t__unstableInsertLineSeparator as insertLineSeparator,\n} from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { splitValue } from './split-value';\n\nexport function useEnter( props ) {\n\tconst { __unstableMarkAutomaticChange } = useDispatch( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode !== ENTER ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\tvalue,\n\t\t\t\tonReplace,\n\t\t\t\tonSplit,\n\t\t\t\tonSplitMiddle,\n\t\t\t\tmultilineTag,\n\t\t\t\tonChange,\n\t\t\t\tdisableLineBreaks,\n\t\t\t\tonSplitAtEnd,\n\t\t\t} = propsRef.current;\n\n\t\t\tevent.preventDefault();\n\n\t\t\tconst _value = { ...value };\n\t\t\t_value.formats = removeEditorOnlyFormats( value );\n\t\t\tconst canSplit = onReplace && onSplit;\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t);\n\t\t\t\tconst transformation = findTransform( transforms, ( item ) => {\n\t\t\t\t\treturn item.regExp.test( _value.text );\n\t\t\t\t} );\n\n\t\t\t\tif ( transformation ) {\n\t\t\t\t\tonReplace( [\n\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\tcontent: _value.text,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t] );\n\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( multilineTag ) {\n\t\t\t\tif ( event.shiftKey ) {\n\t\t\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\t\t\tonChange( insert( _value, '\\n' ) );\n\t\t\t\t\t}\n\t\t\t\t} else if ( canSplit && isEmptyLine( _value ) ) {\n\t\t\t\t\tsplitValue( {\n\t\t\t\t\t\tvalue: _value,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tonChange( insertLineSeparator( _value ) );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst { text, start, end } = _value;\n\t\t\t\tconst canSplitAtEnd =\n\t\t\t\t\tonSplitAtEnd && start === end && end === text.length;\n\n\t\t\t\tif ( event.shiftKey || ( ! canSplit && ! canSplitAtEnd ) ) {\n\t\t\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\t\t\tonChange( insert( _value, '\\n' ) );\n\t\t\t\t\t}\n\t\t\t\t} else if ( ! canSplit && canSplitAtEnd ) {\n\t\t\t\t\tonSplitAtEnd();\n\t\t\t\t} else if ( canSplit ) {\n\t\t\t\t\tsplitValue( {\n\t\t\t\t\t\tvalue: _value,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"]}
@@ -20,7 +20,7 @@ export function addActiveFormats(value, activeFormats) {
20
20
  *
21
21
  * @param {?(string|boolean)} multiline The multiline prop.
22
22
  *
23
- * @return {?string} The multiline tag.
23
+ * @return {string | undefined} The multiline tag.
24
24
  */
25
25
 
26
26
  export function getMultilineTag(multiline) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/utils.js"],"names":["regexp","renderToString","createBlock","addActiveFormats","value","activeFormats","length","index","formats","getMultilineTag","multiline","getAllowedFormats","allowedFormats","disableFormats","EMPTY_ARRAY","isShortcode","text","test","createLinkInParagraph","url","onReplace","link","content"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,sBAAvB;AACA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SAASC,WAAT,QAA4B,mBAA5B;AAEA,OAAO,SAASC,gBAAT,CAA2BC,KAA3B,EAAkCC,aAAlC,EAAkD;AACxD,MAAKA,aAAL,aAAKA,aAAL,eAAKA,aAAa,CAAEC,MAApB,EAA6B;AAC5B,QAAIC,KAAK,GAAGH,KAAK,CAACI,OAAN,CAAcF,MAA1B;;AAEA,WAAQC,KAAK,EAAb,EAAkB;AACjBH,MAAAA,KAAK,CAACI,OAAN,CAAeD,KAAf,IAAyB,CACxB,GAAGF,aADqB,EAExB,IAAKD,KAAK,CAACI,OAAN,CAAeD,KAAf,KAA0B,EAA/B,CAFwB,CAAzB;AAIA;AACD;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,eAAT,CAA0BC,SAA1B,EAAsC;AAC5C,MAAKA,SAAS,KAAK,IAAd,IAAsBA,SAAS,KAAK,GAApC,IAA2CA,SAAS,KAAK,IAA9D,EAAqE;AACpE;AACA;;AAED,SAAOA,SAAS,KAAK,IAAd,GAAqB,GAArB,GAA2BA,SAAlC;AACA;AAED,OAAO,SAASC,iBAAT,OAAiE;AAAA,MAArC;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,GAAqC;;AACvE,MAAKA,cAAL,EAAsB;AACrB,WAAOF,iBAAiB,CAACG,WAAzB;AACA;;AAED,SAAOF,cAAP;AACA;AAEDD,iBAAiB,CAACG,WAAlB,GAAgC,EAAhC;AAEA,OAAO,MAAMC,WAAW,GAAKC,IAAF,IAAYhB,MAAM,CAAE,IAAF,CAAN,CAAeiB,IAAf,CAAqBD,IAArB,CAAhC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,qBAAT,CAAgCC,GAAhC,EAAqCC,SAArC,EAAiD;AACvD,QAAMC,IAAI,GAAG;AAAG,IAAA,IAAI,EAAGF;AAAV,KAAkBA,GAAlB,CAAb;AACAC,EAAAA,SAAS,CACRlB,WAAW,CAAE,gBAAF,EAAoB;AAAEoB,IAAAA,OAAO,EAAErB,cAAc,CAAEoB,IAAF;AAAzB,GAApB,CADH,CAAT;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { regexp } from '@wordpress/shortcode';\nimport { renderToString } from '@wordpress/element';\nimport { createBlock } from '@wordpress/blocks';\n\nexport function addActiveFormats( value, activeFormats ) {\n\tif ( activeFormats?.length ) {\n\t\tlet index = value.formats.length;\n\n\t\twhile ( index-- ) {\n\t\t\tvalue.formats[ index ] = [\n\t\t\t\t...activeFormats,\n\t\t\t\t...( value.formats[ index ] || [] ),\n\t\t\t];\n\t\t}\n\t}\n}\n\n/**\n * Get the multiline tag based on the multiline prop.\n *\n * @param {?(string|boolean)} multiline The multiline prop.\n *\n * @return {?string} The multiline tag.\n */\nexport function getMultilineTag( multiline ) {\n\tif ( multiline !== true && multiline !== 'p' && multiline !== 'li' ) {\n\t\treturn;\n\t}\n\n\treturn multiline === true ? 'p' : multiline;\n}\n\nexport function getAllowedFormats( { allowedFormats, disableFormats } ) {\n\tif ( disableFormats ) {\n\t\treturn getAllowedFormats.EMPTY_ARRAY;\n\t}\n\n\treturn allowedFormats;\n}\n\ngetAllowedFormats.EMPTY_ARRAY = [];\n\nexport const isShortcode = ( text ) => regexp( '.*' ).test( text );\n\n/**\n * Creates a link from pasted URL.\n * Creates a paragraph block containing a link to the URL, and calls `onReplace`.\n *\n * @param {string} url The URL that could not be embedded.\n * @param {Function} onReplace Function to call with the created fallback block.\n */\nexport function createLinkInParagraph( url, onReplace ) {\n\tconst link = <a href={ url }>{ url }</a>;\n\tonReplace(\n\t\tcreateBlock( 'core/paragraph', { content: renderToString( link ) } )\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/utils.js"],"names":["regexp","renderToString","createBlock","addActiveFormats","value","activeFormats","length","index","formats","getMultilineTag","multiline","getAllowedFormats","allowedFormats","disableFormats","EMPTY_ARRAY","isShortcode","text","test","createLinkInParagraph","url","onReplace","link","content"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,sBAAvB;AACA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SAASC,WAAT,QAA4B,mBAA5B;AAEA,OAAO,SAASC,gBAAT,CAA2BC,KAA3B,EAAkCC,aAAlC,EAAkD;AACxD,MAAKA,aAAL,aAAKA,aAAL,eAAKA,aAAa,CAAEC,MAApB,EAA6B;AAC5B,QAAIC,KAAK,GAAGH,KAAK,CAACI,OAAN,CAAcF,MAA1B;;AAEA,WAAQC,KAAK,EAAb,EAAkB;AACjBH,MAAAA,KAAK,CAACI,OAAN,CAAeD,KAAf,IAAyB,CACxB,GAAGF,aADqB,EAExB,IAAKD,KAAK,CAACI,OAAN,CAAeD,KAAf,KAA0B,EAA/B,CAFwB,CAAzB;AAIA;AACD;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,eAAT,CAA0BC,SAA1B,EAAsC;AAC5C,MAAKA,SAAS,KAAK,IAAd,IAAsBA,SAAS,KAAK,GAApC,IAA2CA,SAAS,KAAK,IAA9D,EAAqE;AACpE;AACA;;AAED,SAAOA,SAAS,KAAK,IAAd,GAAqB,GAArB,GAA2BA,SAAlC;AACA;AAED,OAAO,SAASC,iBAAT,OAAiE;AAAA,MAArC;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,GAAqC;;AACvE,MAAKA,cAAL,EAAsB;AACrB,WAAOF,iBAAiB,CAACG,WAAzB;AACA;;AAED,SAAOF,cAAP;AACA;AAEDD,iBAAiB,CAACG,WAAlB,GAAgC,EAAhC;AAEA,OAAO,MAAMC,WAAW,GAAKC,IAAF,IAAYhB,MAAM,CAAE,IAAF,CAAN,CAAeiB,IAAf,CAAqBD,IAArB,CAAhC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,qBAAT,CAAgCC,GAAhC,EAAqCC,SAArC,EAAiD;AACvD,QAAMC,IAAI,GAAG;AAAG,IAAA,IAAI,EAAGF;AAAV,KAAkBA,GAAlB,CAAb;AACAC,EAAAA,SAAS,CACRlB,WAAW,CAAE,gBAAF,EAAoB;AAAEoB,IAAAA,OAAO,EAAErB,cAAc,CAAEoB,IAAF;AAAzB,GAApB,CADH,CAAT;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { regexp } from '@wordpress/shortcode';\nimport { renderToString } from '@wordpress/element';\nimport { createBlock } from '@wordpress/blocks';\n\nexport function addActiveFormats( value, activeFormats ) {\n\tif ( activeFormats?.length ) {\n\t\tlet index = value.formats.length;\n\n\t\twhile ( index-- ) {\n\t\t\tvalue.formats[ index ] = [\n\t\t\t\t...activeFormats,\n\t\t\t\t...( value.formats[ index ] || [] ),\n\t\t\t];\n\t\t}\n\t}\n}\n\n/**\n * Get the multiline tag based on the multiline prop.\n *\n * @param {?(string|boolean)} multiline The multiline prop.\n *\n * @return {string | undefined} The multiline tag.\n */\nexport function getMultilineTag( multiline ) {\n\tif ( multiline !== true && multiline !== 'p' && multiline !== 'li' ) {\n\t\treturn;\n\t}\n\n\treturn multiline === true ? 'p' : multiline;\n}\n\nexport function getAllowedFormats( { allowedFormats, disableFormats } ) {\n\tif ( disableFormats ) {\n\t\treturn getAllowedFormats.EMPTY_ARRAY;\n\t}\n\n\treturn allowedFormats;\n}\n\ngetAllowedFormats.EMPTY_ARRAY = [];\n\nexport const isShortcode = ( text ) => regexp( '.*' ).test( text );\n\n/**\n * Creates a link from pasted URL.\n * Creates a paragraph block containing a link to the URL, and calls `onReplace`.\n *\n * @param {string} url The URL that could not be embedded.\n * @param {Function} onReplace Function to call with the created fallback block.\n */\nexport function createLinkInParagraph( url, onReplace ) {\n\tconst link = <a href={ url }>{ url }</a>;\n\tonReplace(\n\t\tcreateBlock( 'core/paragraph', { content: renderToString( link ) } )\n\t);\n}\n"]}
@@ -1,11 +1,6 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { isEmpty } from 'lodash';
5
1
  /**
6
2
  * WordPress dependencies
7
3
  */
8
-
9
4
  import { __ } from '@wordpress/i18n';
10
5
  /**
11
6
  * Checks is given value is a spacing preset.
@@ -70,7 +65,7 @@ export function getPresetValueFromCustomValue(value, spacingSizes) {
70
65
  *
71
66
  * @param {string} value Value to convert.
72
67
  *
73
- * @return {string} CSS var string for given spacing preset value.
68
+ * @return {string | undefined} CSS var string for given spacing preset value.
74
69
  */
75
70
 
76
71
  export function getSpacingPresetCssVar(value) {
@@ -195,6 +190,6 @@ export function isValuesDefined(values) {
195
190
  return false;
196
191
  }
197
192
 
198
- return !isEmpty(Object.values(values).filter(value => !!value));
193
+ return Object.values(values).filter(value => !!value).length > 0;
199
194
  }
200
195
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/utils.js"],"names":["isEmpty","__","isValueSpacingPreset","value","includes","getCustomValueFromPreset","spacingSizes","slug","getSpacingPresetSlug","spacingSize","find","size","String","getPresetValueFromCustomValue","spacingMatch","getSpacingPresetCssVar","match","undefined","getSliderValueFromPreset","presetValue","parseFloat","sliderValue","findIndex","NaN","LABELS","all","top","bottom","left","right","mixed","vertical","horizontal","DEFAULT_VALUES","ALL_SIDES","mode","arr","sort","a","b","filter","v","length","pop","getAllRawValue","values","Object","isValuesMixed","sides","Set","isValuesDefined"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,oBAAT,CAA+BC,KAA/B,EAAuC;AAC7C,MAAK,EAAEA,KAAF,aAAEA,KAAF,eAAEA,KAAK,CAAEC,QAAT,CAAL,EAAyB;AACxB,WAAO,KAAP;AACA;;AACD,SAAOD,KAAK,KAAK,GAAV,IAAiBA,KAAK,CAACC,QAAN,CAAgB,qBAAhB,CAAxB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,wBAAT,CAAmCF,KAAnC,EAA0CG,YAA1C,EAAyD;AAC/D,MAAK,CAAEJ,oBAAoB,CAAEC,KAAF,CAA3B,EAAuC;AACtC,WAAOA,KAAP;AACA;;AAED,QAAMI,IAAI,GAAGC,oBAAoB,CAAEL,KAAF,CAAjC;AACA,QAAMM,WAAW,GAAGH,YAAY,CAACI,IAAb,CACjBC,IAAF,IAAYC,MAAM,CAAED,IAAI,CAACJ,IAAP,CAAN,KAAwBA,IADjB,CAApB;AAIA,SAAOE,WAAP,aAAOA,WAAP,uBAAOA,WAAW,CAAEE,IAApB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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L,CAAEC,CAAF,EAAKC,CAAL,KACCH,GAAG,CAACI,MAAJ,CAAcC,CAAF,IAASA,CAAC,KAAKH,CAA3B,EAA+BI,MAA/B,GACAN,GAAG,CAACI,MAAJ,CAAcC,CAAF,IAASA,CAAC,KAAKF,CAA3B,EAA+BG,MAJ3B,EAMLC,GANK,EAAP;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASC,cAAT,GAAuC;AAAA,MAAdC,MAAc,uEAAL,EAAK;AAC7C,SAAOV,IAAI,CAAEW,MAAM,CAACD,MAAP,CAAeA,MAAf,CAAF,CAAX;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,aAAT,GAAyD;AAAA,MAAjCF,MAAiC,uEAAxB,EAAwB;AAAA,MAApBG,KAAoB,uEAAZd,SAAY;AAC/D,SACGY,MAAM,CAACD,MAAP,CAAeA,MAAf,EAAwBH,MAAxB,IAAkC,CAAlC,IACDI,MAAM,CAACD,MAAP,CAAeA,MAAf,EAAwBH,MAAxB,GAAiCM,KAAK,CAACN,MADxC,IAEA,IAAIO,GAAJ,CAASH,MAAM,CAACD,MAAP,CAAeA,MAAf,CAAT,EAAmClC,IAAnC,GAA0C,CAH3C;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASuC,eAAT,CAA0BL,MAA1B,EAAmC;AACzC,MAAKA,MAAM,KAAK5B,SAAX,IAAwB4B,MAAM,KAAK,IAAxC,EAA+C;AAC9C,WAAO,KAAP;AACA;;AACD,SAAO,CAAE7C,OAAO,CAAE8C,MAAM,CAACD,MAAP,CAAeA,MAAf,EAAwBL,MAAxB,CAAkCrC,KAAF,IAAa,CAAC,CAAEA,KAAhD,CAAF,CAAhB;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Checks is given value is a spacing preset.\n *\n * @param {string} value Value to check\n *\n * @return {boolean} Return true if value is string in format var:preset|spacing|.\n */\nexport function isValueSpacingPreset( value ) {\n\tif ( ! value?.includes ) {\n\t\treturn false;\n\t}\n\treturn value === '0' || value.includes( 'var:preset|spacing|' );\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} Mapping of the spacing preset to its equivalent custom value.\n */\nexport function getCustomValueFromPreset( value, spacingSizes ) {\n\tif ( ! isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst slug = getSpacingPresetSlug( value );\n\tconst spacingSize = spacingSizes.find(\n\t\t( size ) => String( size.slug ) === slug\n\t);\n\n\treturn spacingSize?.size;\n}\n\n/**\n * Converts a custom value to preset value if one can be found.\n *\n * Returns value as-is if no match is found.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} The preset value if it can be found.\n */\nexport function getPresetValueFromCustomValue( value, spacingSizes ) {\n\t// Return value as-is if it is already a preset;\n\tif ( isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst spacingMatch = spacingSizes.find(\n\t\t( size ) => String( size.size ) === String( value )\n\t);\n\n\tif ( spacingMatch?.slug ) {\n\t\treturn `var:preset|spacing|${ spacingMatch.slug }`;\n\t}\n\n\treturn value;\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert.\n *\n * @return {string} CSS var string for given spacing preset value.\n */\nexport function getSpacingPresetCssVar( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\tif ( ! slug ) {\n\t\treturn value;\n\t}\n\n\treturn `var(--wp--preset--spacing--${ slug[ 1 ] })`;\n}\n\n/**\n * Returns the slug section of the given spacing preset string.\n *\n * @param {string} value Value to extract slug from.\n *\n * @return {string|undefined} The int value of the slug from given spacing preset.\n */\nexport function getSpacingPresetSlug( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tif ( value === '0' || value === 'default' ) {\n\t\treturn value;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\treturn slug ? slug[ 1 ] : undefined;\n}\n\n/**\n * Converts spacing preset value into a Range component value .\n *\n * @param {string} presetValue Value to convert to Range value.\n * @param {Array} spacingSizes Array of current spacing preset value objects.\n *\n * @return {number} The int value for use in Range control.\n */\nexport function getSliderValueFromPreset( presetValue, spacingSizes ) {\n\tif ( presetValue === undefined ) {\n\t\treturn 0;\n\t}\n\tconst slug =\n\t\tparseFloat( presetValue, 10 ) === 0\n\t\t\t? '0'\n\t\t\t: getSpacingPresetSlug( presetValue );\n\tconst sliderValue = spacingSizes.findIndex( ( spacingSize ) => {\n\t\treturn String( spacingSize.slug ) === slug;\n\t} );\n\n\t// Returning NaN rather than undefined as undefined makes range control thumb sit in center\n\treturn sliderValue !== -1 ? sliderValue : NaN;\n}\n\nexport const LABELS = {\n\tall: __( 'All sides' ),\n\ttop: __( 'Top' ),\n\tbottom: __( 'Bottom' ),\n\tleft: __( 'Left' ),\n\tright: __( 'Right' ),\n\tmixed: __( 'Mixed' ),\n\tvertical: __( 'Vertical' ),\n\thorizontal: __( 'Horizontal' ),\n};\n\nexport const DEFAULT_VALUES = {\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\n\n/**\n * Gets an items with the most occurrence within an array\n * https://stackoverflow.com/a/20762713\n *\n * @param {Array<any>} arr Array of items to check.\n * @return {any} The item with the most occurrences.\n */\nfunction mode( arr ) {\n\treturn arr\n\t\t.sort(\n\t\t\t( a, b ) =>\n\t\t\t\tarr.filter( ( v ) => v === a ).length -\n\t\t\t\tarr.filter( ( v ) => v === b ).length\n\t\t)\n\t\t.pop();\n}\n\n/**\n * Gets the 'all' input value from values data.\n *\n * @param {Object} values Box spacing values\n *\n * @return {string} The most common value from all sides of box.\n */\nexport function getAllRawValue( values = {} ) {\n\treturn mode( Object.values( values ) );\n}\n\n/**\n * Checks to determine if values are mixed.\n *\n * @param {Object} values Box values.\n * @param {Array} sides Sides that values relate to.\n *\n * @return {boolean} Whether values are mixed.\n */\nexport function isValuesMixed( values = {}, sides = ALL_SIDES ) {\n\treturn (\n\t\t( Object.values( values ).length >= 1 &&\n\t\t\tObject.values( values ).length < sides.length ) ||\n\t\tnew Set( Object.values( values ) ).size > 1\n\t);\n}\n\n/**\n * Checks to determine if values are defined.\n *\n * @param {Object} values Box values.\n *\n * @return {boolean} Whether values are defined.\n */\nexport function isValuesDefined( values ) {\n\tif ( values === undefined || values === null ) {\n\t\treturn false;\n\t}\n\treturn ! isEmpty( Object.values( values ).filter( ( value ) => !! value ) );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/utils.js"],"names":["__","isValueSpacingPreset","value","includes","getCustomValueFromPreset","spacingSizes","slug","getSpacingPresetSlug","spacingSize","find","size","String","getPresetValueFromCustomValue","spacingMatch","getSpacingPresetCssVar","match","undefined","getSliderValueFromPreset","presetValue","parseFloat","sliderValue","findIndex","NaN","LABELS","all","top","bottom","left","right","mixed","vertical","horizontal","DEFAULT_VALUES","ALL_SIDES","mode","arr","sort","a","b","filter","v","length","pop","getAllRawValue","values","Object","isValuesMixed","sides","Set","isValuesDefined"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,oBAAT,CAA+BC,KAA/B,EAAuC;AAC7C,MAAK,EAAEA,KAAF,aAAEA,KAAF,eAAEA,KAAK,CAAEC,QAAT,CAAL,EAAyB;AACxB,WAAO,KAAP;AACA;;AACD,SAAOD,KAAK,KAAK,GAAV,IAAiBA,KAAK,CAACC,QAAN,CAAgB,qBAAhB,CAAxB;AACA;AAED;AAC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A0C,CAH3C;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASuC,eAAT,CAA0BL,MAA1B,EAAmC;AACzC,MAAKA,MAAM,KAAK5B,SAAX,IAAwB4B,MAAM,KAAK,IAAxC,EAA+C;AAC9C,WAAO,KAAP;AACA;;AACD,SAAOC,MAAM,CAACD,MAAP,CAAeA,MAAf,EAAwBL,MAAxB,CAAkCrC,KAAF,IAAa,CAAC,CAAEA,KAAhD,EAAwDuC,MAAxD,GAAiE,CAAxE;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Checks is given value is a spacing preset.\n *\n * @param {string} value Value to check\n *\n * @return {boolean} Return true if value is string in format var:preset|spacing|.\n */\nexport function isValueSpacingPreset( value ) {\n\tif ( ! value?.includes ) {\n\t\treturn false;\n\t}\n\treturn value === '0' || value.includes( 'var:preset|spacing|' );\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} Mapping of the spacing preset to its equivalent custom value.\n */\nexport function getCustomValueFromPreset( value, spacingSizes ) {\n\tif ( ! isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst slug = getSpacingPresetSlug( value );\n\tconst spacingSize = spacingSizes.find(\n\t\t( size ) => String( size.slug ) === slug\n\t);\n\n\treturn spacingSize?.size;\n}\n\n/**\n * Converts a custom value to preset value if one can be found.\n *\n * Returns value as-is if no match is found.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} The preset value if it can be found.\n */\nexport function getPresetValueFromCustomValue( value, spacingSizes ) {\n\t// Return value as-is if it is already a preset;\n\tif ( isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst spacingMatch = spacingSizes.find(\n\t\t( size ) => String( size.size ) === String( value )\n\t);\n\n\tif ( spacingMatch?.slug ) {\n\t\treturn `var:preset|spacing|${ spacingMatch.slug }`;\n\t}\n\n\treturn value;\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert.\n *\n * @return {string | undefined} CSS var string for given spacing preset value.\n */\nexport function getSpacingPresetCssVar( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\tif ( ! slug ) {\n\t\treturn value;\n\t}\n\n\treturn `var(--wp--preset--spacing--${ slug[ 1 ] })`;\n}\n\n/**\n * Returns the slug section of the given spacing preset string.\n *\n * @param {string} value Value to extract slug from.\n *\n * @return {string|undefined} The int value of the slug from given spacing preset.\n */\nexport function getSpacingPresetSlug( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tif ( value === '0' || value === 'default' ) {\n\t\treturn value;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\treturn slug ? slug[ 1 ] : undefined;\n}\n\n/**\n * Converts spacing preset value into a Range component value .\n *\n * @param {string} presetValue Value to convert to Range value.\n * @param {Array} spacingSizes Array of current spacing preset value objects.\n *\n * @return {number} The int value for use in Range control.\n */\nexport function getSliderValueFromPreset( presetValue, spacingSizes ) {\n\tif ( presetValue === undefined ) {\n\t\treturn 0;\n\t}\n\tconst slug =\n\t\tparseFloat( presetValue, 10 ) === 0\n\t\t\t? '0'\n\t\t\t: getSpacingPresetSlug( presetValue );\n\tconst sliderValue = spacingSizes.findIndex( ( spacingSize ) => {\n\t\treturn String( spacingSize.slug ) === slug;\n\t} );\n\n\t// Returning NaN rather than undefined as undefined makes range control thumb sit in center\n\treturn sliderValue !== -1 ? sliderValue : NaN;\n}\n\nexport const LABELS = {\n\tall: __( 'All sides' ),\n\ttop: __( 'Top' ),\n\tbottom: __( 'Bottom' ),\n\tleft: __( 'Left' ),\n\tright: __( 'Right' ),\n\tmixed: __( 'Mixed' ),\n\tvertical: __( 'Vertical' ),\n\thorizontal: __( 'Horizontal' ),\n};\n\nexport const DEFAULT_VALUES = {\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\n\n/**\n * Gets an items with the most occurrence within an array\n * https://stackoverflow.com/a/20762713\n *\n * @param {Array<any>} arr Array of items to check.\n * @return {any} The item with the most occurrences.\n */\nfunction mode( arr ) {\n\treturn arr\n\t\t.sort(\n\t\t\t( a, b ) =>\n\t\t\t\tarr.filter( ( v ) => v === a ).length -\n\t\t\t\tarr.filter( ( v ) => v === b ).length\n\t\t)\n\t\t.pop();\n}\n\n/**\n * Gets the 'all' input value from values data.\n *\n * @param {Object} values Box spacing values\n *\n * @return {string} The most common value from all sides of box.\n */\nexport function getAllRawValue( values = {} ) {\n\treturn mode( Object.values( values ) );\n}\n\n/**\n * Checks to determine if values are mixed.\n *\n * @param {Object} values Box values.\n * @param {Array} sides Sides that values relate to.\n *\n * @return {boolean} Whether values are mixed.\n */\nexport function isValuesMixed( values = {}, sides = ALL_SIDES ) {\n\treturn (\n\t\t( Object.values( values ).length >= 1 &&\n\t\t\tObject.values( values ).length < sides.length ) ||\n\t\tnew Set( Object.values( values ) ).size > 1\n\t);\n}\n\n/**\n * Checks to determine if values are defined.\n *\n * @param {Object} values Box values.\n *\n * @return {boolean} Whether values are defined.\n */\nexport function isValuesDefined( values ) {\n\tif ( values === undefined || values === null ) {\n\t\treturn false;\n\t}\n\treturn Object.values( values ).filter( ( value ) => !! value ).length > 0;\n}\n"]}
@@ -45,7 +45,9 @@ function ToolSelector(props, ref) {
45
45
  label: __('Tools')
46
46
  }));
47
47
  },
48
- position: "bottom right",
48
+ popoverProps: {
49
+ placement: 'bottom-start'
50
+ },
49
51
  renderContent: () => createElement(Fragment, null, createElement(NavigableMenu, {
50
52
  role: "menu",
51
53
  "aria-label": __('Tools')
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/tool-selector/index.js"],"names":["Dropdown","Button","MenuItemsChoice","SVG","Path","NavigableMenu","__","useSelect","useDispatch","forwardRef","Icon","edit","editIcon","store","blockEditorStore","selectIcon","ToolSelector","props","ref","mode","select","__unstableGetEditorMode","__unstableSetEditorMode","isOpen","onToggle","value","label"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,QADD,EAECC,MAFD,EAGCC,eAHD,EAICC,GAJD,EAKCC,IALD,EAMCC,aAND,QAOO,uBAPP;AAQA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,UAAT,QAA2B,oBAA3B;AACA,SAASC,IAAT,EAAeC,IAAI,IAAIC,QAAvB,QAAuC,kBAAvC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,MAAMC,UAAU,GACf,cAAC,GAAD;AACC,EAAA,KAAK,EAAC,4BADP;AAEC,EAAA,KAAK,EAAC,IAFP;AAGC,EAAA,MAAM,EAAC,IAHR;AAIC,EAAA,OAAO,EAAC;AAJT,GAMC,cAAC,IAAD;AAAM,EAAA,CAAC,EAAC;AAAR,EAND,CADD;;AAWA,SAASC,YAAT,CAAuBC,KAAvB,EAA8BC,GAA9B,EAAoC;AACnC,QAAMC,IAAI,GAAGZ,SAAS,CACnBa,MAAF,IAAcA,MAAM,CAAEN,gBAAF,CAAN,CAA2BO,uBAA3B,EADO,EAErB,EAFqB,CAAtB;AAIA,QAAM;AAAEC,IAAAA;AAAF,MAA8Bd,WAAW,CAAEM,gBAAF,CAA/C;AAEA,SACC,cAAC,QAAD;AACC,IAAA,YAAY,EAAG;AAAA,UAAE;AAAES,QAAAA,MAAF;AAAUC,QAAAA;AAAV,OAAF;AAAA,aACd,cAAC,MAAD,eACMP,KADN;AAEC,QAAA,GAAG,EAAGC,GAFP;AAGC,QAAA,IAAI,EAAGC,IAAI,KAAK,YAAT,GAAwBJ,UAAxB,GAAqCH,QAH7C;AAIC,yBAAgBW,MAJjB;AAKC,yBAAc,MALf;AAMC,QAAA,OAAO,EAAGC;AACV;AAPD;AAQC,QAAA,KAAK,EAAGlB,EAAE,CAAE,OAAF;AARX,SADc;AAAA,KADhB;AAaC,IAAA,QAAQ,EAAC,cAbV;AAcC,IAAA,aAAa,EAAG,MACf,8BACC,cAAC,aAAD;AAAe,MAAA,IAAI,EAAC,MAApB;AAA2B,oBAAaA,EAAE,CAAE,OAAF;AAA1C,OACC,cAAC,eAAD;AACC,MAAA,KAAK,EACJa,IAAI,KAAK,YAAT,GAAwB,YAAxB,GAAuC,MAFzC;AAIC,MAAA,QAAQ,EAAGG,uBAJZ;AAKC,MAAA,OAAO,EAAG,CACT;AACCG,QAAAA,KAAK,EAAE,MADR;AAECC,QAAAA,KAAK,EACJ,8BACC,cAAC,IAAD;AAAM,UAAA,IAAI,EAAGd;AAAb,UADD,EAEGN,EAAE,CAAE,MAAF,CAFL;AAHF,OADS,EAUT;AACCmB,QAAAA,KAAK,EAAE,YADR;AAECC,QAAAA,KAAK,EACJ,8BACGX,UADH,EAEGT,EAAE,CAAE,QAAF,CAFL;AAHF,OAVS;AALX,MADD,CADD,EA6BC;AAAK,MAAA,SAAS,EAAC;AAAf,OACGA,EAAE,CACH,kJADG,CADL,CA7BD;AAfF,IADD;AAsDA;;AAED,eAAeG,UAAU,CAAEO,YAAF,CAAzB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tDropdown,\n\tButton,\n\tMenuItemsChoice,\n\tSVG,\n\tPath,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, edit as editIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst selectIcon = (\n\t<SVG\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\twidth=\"24\"\n\t\theight=\"24\"\n\t\tviewBox=\"0 0 24 24\"\n\t>\n\t\t<Path d=\"M9.4 20.5L5.2 3.8l14.6 9-2 .3c-.2 0-.4.1-.7.1-.9.2-1.6.3-2.2.5-.8.3-1.4.5-1.8.8-.4.3-.8.8-1.3 1.5-.4.5-.8 1.2-1.2 2l-.3.6-.9 1.9zM7.6 7.1l2.4 9.3c.2-.4.5-.8.7-1.1.6-.8 1.1-1.4 1.6-1.8.5-.4 1.3-.8 2.2-1.1l1.2-.3-8.1-5z\" />\n\t</SVG>\n);\n\nfunction ToolSelector( props, ref ) {\n\tconst mode = useSelect(\n\t\t( select ) => select( blockEditorStore ).__unstableGetEditorMode(),\n\t\t[]\n\t);\n\tconst { __unstableSetEditorMode } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<Dropdown\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tref={ ref }\n\t\t\t\t\ticon={ mode === 'navigation' ? selectIcon : editIcon }\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\tlabel={ __( 'Tools' ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\tposition=\"bottom right\"\n\t\t\trenderContent={ () => (\n\t\t\t\t<>\n\t\t\t\t\t<NavigableMenu role=\"menu\" aria-label={ __( 'Tools' ) }>\n\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\tvalue={\n\t\t\t\t\t\t\t\tmode === 'navigation' ? 'navigation' : 'edit'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonSelect={ __unstableSetEditorMode }\n\t\t\t\t\t\t\tchoices={ [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tvalue: 'edit',\n\t\t\t\t\t\t\t\t\tlabel: (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ editIcon } />\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tvalue: 'navigation',\n\t\t\t\t\t\t\t\t\tlabel: (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t{ selectIcon }\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Select' ) }\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t<div className=\"block-editor-tool-selector__help\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Tools provide different interactions for selecting, navigating, and editing blocks. Toggle between select and edit by pressing Escape and Enter.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t</>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( ToolSelector );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/tool-selector/index.js"],"names":["Dropdown","Button","MenuItemsChoice","SVG","Path","NavigableMenu","__","useSelect","useDispatch","forwardRef","Icon","edit","editIcon","store","blockEditorStore","selectIcon","ToolSelector","props","ref","mode","select","__unstableGetEditorMode","__unstableSetEditorMode","isOpen","onToggle","placement","value","label"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,QADD,EAECC,MAFD,EAGCC,eAHD,EAICC,GAJD,EAKCC,IALD,EAMCC,aAND,QAOO,uBAPP;AAQA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,UAAT,QAA2B,oBAA3B;AACA,SAASC,IAAT,EAAeC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,QAAQ,EAAGG,uBAJZ;AAKC,MAAA,OAAO,EAAG,CACT;AACCI,QAAAA,KAAK,EAAE,MADR;AAECC,QAAAA,KAAK,EACJ,8BACC,cAAC,IAAD;AAAM,UAAA,IAAI,EAAGf;AAAb,UADD,EAEGN,EAAE,CAAE,MAAF,CAFL;AAHF,OADS,EAUT;AACCoB,QAAAA,KAAK,EAAE,YADR;AAECC,QAAAA,KAAK,EACJ,8BACGZ,UADH,EAEGT,EAAE,CAAE,QAAF,CAFL;AAHF,OAVS;AALX,MADD,CADD,EA6BC;AAAK,MAAA,SAAS,EAAC;AAAf,OACGA,EAAE,CACH,kJADG,CADL,CA7BD;AAfF,IADD;AAsDA;;AAED,eAAeG,UAAU,CAAEO,YAAF,CAAzB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tDropdown,\n\tButton,\n\tMenuItemsChoice,\n\tSVG,\n\tPath,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, edit as editIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst selectIcon = (\n\t<SVG\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\twidth=\"24\"\n\t\theight=\"24\"\n\t\tviewBox=\"0 0 24 24\"\n\t>\n\t\t<Path d=\"M9.4 20.5L5.2 3.8l14.6 9-2 .3c-.2 0-.4.1-.7.1-.9.2-1.6.3-2.2.5-.8.3-1.4.5-1.8.8-.4.3-.8.8-1.3 1.5-.4.5-.8 1.2-1.2 2l-.3.6-.9 1.9zM7.6 7.1l2.4 9.3c.2-.4.5-.8.7-1.1.6-.8 1.1-1.4 1.6-1.8.5-.4 1.3-.8 2.2-1.1l1.2-.3-8.1-5z\" />\n\t</SVG>\n);\n\nfunction ToolSelector( props, ref ) {\n\tconst mode = useSelect(\n\t\t( select ) => select( blockEditorStore ).__unstableGetEditorMode(),\n\t\t[]\n\t);\n\tconst { __unstableSetEditorMode } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<Dropdown\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tref={ ref }\n\t\t\t\t\ticon={ mode === 'navigation' ? selectIcon : editIcon }\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\tlabel={ __( 'Tools' ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\tpopoverProps={ { placement: 'bottom-start' } }\n\t\t\trenderContent={ () => (\n\t\t\t\t<>\n\t\t\t\t\t<NavigableMenu role=\"menu\" aria-label={ __( 'Tools' ) }>\n\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\tvalue={\n\t\t\t\t\t\t\t\tmode === 'navigation' ? 'navigation' : 'edit'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonSelect={ __unstableSetEditorMode }\n\t\t\t\t\t\t\tchoices={ [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tvalue: 'edit',\n\t\t\t\t\t\t\t\t\tlabel: (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ editIcon } />\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tvalue: 'navigation',\n\t\t\t\t\t\t\t\t\tlabel: (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t{ selectIcon }\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Select' ) }\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t<div className=\"block-editor-tool-selector__help\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Tools provide different interactions for selecting, navigating, and editing blocks. Toggle between select and edit by pressing Escape and Enter.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t</>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( ToolSelector );\n"]}