@wordpress/block-editor 8.0.12-next.33ec3857e2.0 → 8.0.15

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 (399) hide show
  1. package/README.md +0 -4
  2. package/build/components/block-caption/index.native.js +3 -14
  3. package/build/components/block-caption/index.native.js.map +1 -1
  4. package/build/components/block-inspector/index.js +33 -12
  5. package/build/components/block-inspector/index.js.map +1 -1
  6. package/build/components/block-list/block.js +1 -1
  7. package/build/components/block-list/block.js.map +1 -1
  8. package/build/components/block-list/block.native.js +2 -3
  9. package/build/components/block-list/block.native.js.map +1 -1
  10. package/build/components/block-list/use-block-props/index.js +1 -3
  11. package/build/components/block-list/use-block-props/index.js.map +1 -1
  12. package/build/components/block-list/use-in-between-inserter.js +1 -1
  13. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  14. package/build/components/block-list-appender/index.js +11 -3
  15. package/build/components/block-list-appender/index.js.map +1 -1
  16. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +2 -2
  17. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  18. package/build/components/block-mover/button.js +2 -2
  19. package/build/components/block-mover/button.js.map +1 -1
  20. package/build/components/block-mover/index.js +2 -2
  21. package/build/components/block-mover/index.js.map +1 -1
  22. package/build/components/block-mover/index.native.js +2 -2
  23. package/build/components/block-mover/index.native.js.map +1 -1
  24. package/build/components/block-preview/auto.js +2 -10
  25. package/build/components/block-preview/auto.js.map +1 -1
  26. package/build/components/block-settings/container.native.js +1 -2
  27. package/build/components/block-settings/container.native.js.map +1 -1
  28. package/build/components/block-styles/index.js +134 -110
  29. package/build/components/block-styles/index.js.map +1 -1
  30. package/build/components/block-styles/utils.js +0 -39
  31. package/build/components/block-styles/utils.js.map +1 -1
  32. package/build/components/block-switcher/block-styles-menu.js +23 -3
  33. package/build/components/block-switcher/block-styles-menu.js.map +1 -1
  34. package/build/components/block-tools/back-compat.js +1 -2
  35. package/build/components/block-tools/back-compat.js.map +1 -1
  36. package/build/components/block-tools/block-selection-button.js +3 -3
  37. package/build/components/block-tools/block-selection-button.js.map +1 -1
  38. package/build/components/block-tools/index.js +9 -0
  39. package/build/components/block-tools/index.js.map +1 -1
  40. package/build/components/block-tools/insertion-point.js +1 -11
  41. package/build/components/block-tools/insertion-point.js.map +1 -1
  42. package/build/components/button-block-appender/index.js +1 -2
  43. package/build/components/button-block-appender/index.js.map +1 -1
  44. package/build/components/colors-gradients/panel-color-gradient-settings.js +10 -51
  45. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  46. package/build/components/default-block-appender/index.js +19 -16
  47. package/build/components/default-block-appender/index.js.map +1 -1
  48. package/build/components/default-style-picker/index.js +3 -18
  49. package/build/components/default-style-picker/index.js.map +1 -1
  50. package/build/components/font-appearance-control/index.js +11 -11
  51. package/build/components/font-appearance-control/index.js.map +1 -1
  52. package/build/components/gradients/use-gradient.js +4 -4
  53. package/build/components/gradients/use-gradient.js.map +1 -1
  54. package/build/components/iframe/index.js +6 -7
  55. package/build/components/iframe/index.js.map +1 -1
  56. package/build/components/index.js +9 -9
  57. package/build/components/index.js.map +1 -1
  58. package/build/components/inner-blocks/default-block-appender.js +4 -2
  59. package/build/components/inner-blocks/default-block-appender.js.map +1 -1
  60. package/build/components/inserter/hooks/use-insertion-point.js +2 -2
  61. package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
  62. package/build/components/inserter/index.js +2 -2
  63. package/build/components/inserter/index.js.map +1 -1
  64. package/build/components/inserter/index.native.js +3 -3
  65. package/build/components/inserter/index.native.js.map +1 -1
  66. package/build/components/inserter/quick-inserter.js +1 -1
  67. package/build/components/inserter/quick-inserter.js.map +1 -1
  68. package/build/components/inserter/tabs.native.js +4 -7
  69. package/build/components/inserter/tabs.native.js.map +1 -1
  70. package/build/components/inspector-controls/block-support-slot-container.js +1 -2
  71. package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
  72. package/build/components/inspector-controls/block-support-tools-panel.js +50 -22
  73. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  74. package/build/components/inspector-controls/fill.native.js +5 -3
  75. package/build/components/inspector-controls/fill.native.js.map +1 -1
  76. package/build/components/inspector-controls/groups.js +0 -2
  77. package/build/components/inspector-controls/groups.js.map +1 -1
  78. package/build/components/inspector-controls/slot.js +3 -1
  79. package/build/components/inspector-controls/slot.js.map +1 -1
  80. package/build/components/letter-spacing-control/index.js +6 -6
  81. package/build/components/letter-spacing-control/index.js.map +1 -1
  82. package/build/components/list-view/block-select-button.js +3 -23
  83. package/build/components/list-view/block-select-button.js.map +1 -1
  84. package/build/components/list-view/use-list-view-drop-zone.js +1 -1
  85. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  86. package/build/components/media-placeholder/index.js +0 -2
  87. package/build/components/media-placeholder/index.js.map +1 -1
  88. package/build/components/media-replace-flow/index.js +0 -2
  89. package/build/components/media-replace-flow/index.js.map +1 -1
  90. package/build/components/provider/use-block-sync.js +37 -10
  91. package/build/components/provider/use-block-sync.js.map +1 -1
  92. package/build/components/rich-text/file-paste-handler.js +1 -1
  93. package/build/components/rich-text/file-paste-handler.js.map +1 -1
  94. package/build/components/rich-text/use-input-rules.js +1 -3
  95. package/build/components/rich-text/use-input-rules.js.map +1 -1
  96. package/build/components/selection-scroll-into-view/index.js +1 -2
  97. package/build/components/selection-scroll-into-view/index.js.map +1 -1
  98. package/build/components/use-canvas-click-redirect/index.js +66 -0
  99. package/build/components/use-canvas-click-redirect/index.js.map +1 -0
  100. package/build/components/use-on-block-drop/index.js +4 -8
  101. package/build/components/use-on-block-drop/index.js.map +1 -1
  102. package/build/components/use-setting/index.js +7 -0
  103. package/build/components/use-setting/index.js.map +1 -1
  104. package/build/components/writing-flow/use-multi-selection.js +1 -3
  105. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  106. package/build/hooks/border-color.js +5 -63
  107. package/build/hooks/border-color.js.map +1 -1
  108. package/build/hooks/border-radius.js +0 -47
  109. package/build/hooks/border-radius.js.map +1 -1
  110. package/build/hooks/border-style.js +0 -41
  111. package/build/hooks/border-style.js.map +1 -1
  112. package/build/hooks/border-width.js +31 -70
  113. package/build/hooks/border-width.js.map +1 -1
  114. package/build/hooks/border.js +11 -81
  115. package/build/hooks/border.js.map +1 -1
  116. package/build/hooks/color.js +6 -5
  117. package/build/hooks/color.js.map +1 -1
  118. package/build/hooks/layout.js +2 -1
  119. package/build/hooks/layout.js.map +1 -1
  120. package/build/hooks/letter-spacing.js +1 -1
  121. package/build/hooks/letter-spacing.js.map +1 -1
  122. package/build/hooks/style.js +2 -1
  123. package/build/hooks/style.js.map +1 -1
  124. package/build/hooks/typography.js +1 -1
  125. package/build/hooks/typography.js.map +1 -1
  126. package/build/layouts/flex.js +9 -29
  127. package/build/layouts/flex.js.map +1 -1
  128. package/build/layouts/flow.js +10 -6
  129. package/build/layouts/flow.js.map +1 -1
  130. package/build/store/actions.js +5 -4
  131. package/build/store/actions.js.map +1 -1
  132. package/build/store/defaults.js +1 -5
  133. package/build/store/defaults.js.map +1 -1
  134. package/build/store/reducer.js +24 -1
  135. package/build/store/reducer.js.map +1 -1
  136. package/build/store/selectors.js +2 -2
  137. package/build/store/selectors.js.map +1 -1
  138. package/build/utils/get-paste-event-data.js +1 -1
  139. package/build/utils/get-paste-event-data.js.map +1 -1
  140. package/build/utils/parse-css-unit-to-px.js +1 -1
  141. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  142. package/build-module/components/block-caption/index.native.js +3 -13
  143. package/build-module/components/block-caption/index.native.js.map +1 -1
  144. package/build-module/components/block-inspector/index.js +33 -12
  145. package/build-module/components/block-inspector/index.js.map +1 -1
  146. package/build-module/components/block-list/block.js +1 -1
  147. package/build-module/components/block-list/block.js.map +1 -1
  148. package/build-module/components/block-list/block.native.js +2 -3
  149. package/build-module/components/block-list/block.native.js.map +1 -1
  150. package/build-module/components/block-list/use-block-props/index.js +1 -3
  151. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  152. package/build-module/components/block-list/use-in-between-inserter.js +1 -1
  153. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  154. package/build-module/components/block-list-appender/index.js +10 -3
  155. package/build-module/components/block-list-appender/index.js.map +1 -1
  156. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +2 -2
  157. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  158. package/build-module/components/block-mover/button.js +2 -2
  159. package/build-module/components/block-mover/button.js.map +1 -1
  160. package/build-module/components/block-mover/index.js +2 -2
  161. package/build-module/components/block-mover/index.js.map +1 -1
  162. package/build-module/components/block-mover/index.native.js +2 -2
  163. package/build-module/components/block-mover/index.native.js.map +1 -1
  164. package/build-module/components/block-preview/auto.js +2 -10
  165. package/build-module/components/block-preview/auto.js.map +1 -1
  166. package/build-module/components/block-settings/container.native.js +1 -2
  167. package/build-module/components/block-settings/container.native.js.map +1 -1
  168. package/build-module/components/block-styles/index.js +133 -112
  169. package/build-module/components/block-styles/index.js.map +1 -1
  170. package/build-module/components/block-styles/utils.js +0 -34
  171. package/build-module/components/block-styles/utils.js.map +1 -1
  172. package/build-module/components/block-switcher/block-styles-menu.js +21 -3
  173. package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
  174. package/build-module/components/block-tools/back-compat.js +1 -2
  175. package/build-module/components/block-tools/back-compat.js.map +1 -1
  176. package/build-module/components/block-tools/block-selection-button.js +3 -3
  177. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  178. package/build-module/components/block-tools/index.js +9 -0
  179. package/build-module/components/block-tools/index.js.map +1 -1
  180. package/build-module/components/block-tools/insertion-point.js +1 -11
  181. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  182. package/build-module/components/button-block-appender/index.js +1 -2
  183. package/build-module/components/button-block-appender/index.js.map +1 -1
  184. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +13 -54
  185. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  186. package/build-module/components/default-block-appender/index.js +18 -15
  187. package/build-module/components/default-block-appender/index.js.map +1 -1
  188. package/build-module/components/default-style-picker/index.js +3 -17
  189. package/build-module/components/default-style-picker/index.js.map +1 -1
  190. package/build-module/components/font-appearance-control/index.js +12 -12
  191. package/build-module/components/font-appearance-control/index.js.map +1 -1
  192. package/build-module/components/gradients/use-gradient.js +4 -3
  193. package/build-module/components/gradients/use-gradient.js.map +1 -1
  194. package/build-module/components/iframe/index.js +6 -7
  195. package/build-module/components/iframe/index.js.map +1 -1
  196. package/build-module/components/index.js +1 -1
  197. package/build-module/components/index.js.map +1 -1
  198. package/build-module/components/inner-blocks/default-block-appender.js +4 -2
  199. package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
  200. package/build-module/components/inserter/hooks/use-insertion-point.js +2 -2
  201. package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
  202. package/build-module/components/inserter/index.js +2 -2
  203. package/build-module/components/inserter/index.js.map +1 -1
  204. package/build-module/components/inserter/index.native.js +4 -4
  205. package/build-module/components/inserter/index.native.js.map +1 -1
  206. package/build-module/components/inserter/quick-inserter.js +1 -1
  207. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  208. package/build-module/components/inserter/tabs.native.js +4 -7
  209. package/build-module/components/inserter/tabs.native.js.map +1 -1
  210. package/build-module/components/inspector-controls/block-support-slot-container.js +1 -2
  211. package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
  212. package/build-module/components/inspector-controls/block-support-tools-panel.js +50 -22
  213. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  214. package/build-module/components/inspector-controls/fill.native.js +5 -3
  215. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  216. package/build-module/components/inspector-controls/groups.js +0 -2
  217. package/build-module/components/inspector-controls/groups.js.map +1 -1
  218. package/build-module/components/inspector-controls/slot.js +3 -1
  219. package/build-module/components/inspector-controls/slot.js.map +1 -1
  220. package/build-module/components/letter-spacing-control/index.js +6 -6
  221. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  222. package/build-module/components/list-view/block-select-button.js +3 -22
  223. package/build-module/components/list-view/block-select-button.js.map +1 -1
  224. package/build-module/components/list-view/use-list-view-drop-zone.js +1 -1
  225. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  226. package/build-module/components/media-placeholder/index.js +0 -2
  227. package/build-module/components/media-placeholder/index.js.map +1 -1
  228. package/build-module/components/media-replace-flow/index.js +0 -2
  229. package/build-module/components/media-replace-flow/index.js.map +1 -1
  230. package/build-module/components/provider/use-block-sync.js +41 -14
  231. package/build-module/components/provider/use-block-sync.js.map +1 -1
  232. package/build-module/components/rich-text/file-paste-handler.js +1 -1
  233. package/build-module/components/rich-text/file-paste-handler.js.map +1 -1
  234. package/build-module/components/rich-text/use-input-rules.js +1 -2
  235. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  236. package/build-module/components/selection-scroll-into-view/index.js +1 -2
  237. package/build-module/components/selection-scroll-into-view/index.js.map +1 -1
  238. package/build-module/components/use-canvas-click-redirect/index.js +54 -0
  239. package/build-module/components/use-canvas-click-redirect/index.js.map +1 -0
  240. package/build-module/components/use-on-block-drop/index.js +4 -8
  241. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  242. package/build-module/components/use-setting/index.js +7 -0
  243. package/build-module/components/use-setting/index.js.map +1 -1
  244. package/build-module/components/writing-flow/use-multi-selection.js +4 -3
  245. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  246. package/build-module/hooks/border-color.js +7 -61
  247. package/build-module/hooks/border-color.js.map +1 -1
  248. package/build-module/hooks/border-radius.js +0 -42
  249. package/build-module/hooks/border-radius.js.map +1 -1
  250. package/build-module/hooks/border-style.js +0 -36
  251. package/build-module/hooks/border-style.js.map +1 -1
  252. package/build-module/hooks/border-width.js +32 -66
  253. package/build-module/hooks/border-width.js.map +1 -1
  254. package/build-module/hooks/border.js +12 -80
  255. package/build-module/hooks/border.js.map +1 -1
  256. package/build-module/hooks/color.js +6 -5
  257. package/build-module/hooks/color.js.map +1 -1
  258. package/build-module/hooks/layout.js +2 -1
  259. package/build-module/hooks/layout.js.map +1 -1
  260. package/build-module/hooks/letter-spacing.js +1 -1
  261. package/build-module/hooks/letter-spacing.js.map +1 -1
  262. package/build-module/hooks/style.js +2 -1
  263. package/build-module/hooks/style.js.map +1 -1
  264. package/build-module/hooks/typography.js +1 -1
  265. package/build-module/hooks/typography.js.map +1 -1
  266. package/build-module/layouts/flex.js +9 -29
  267. package/build-module/layouts/flex.js.map +1 -1
  268. package/build-module/layouts/flow.js +10 -6
  269. package/build-module/layouts/flow.js.map +1 -1
  270. package/build-module/store/actions.js +5 -4
  271. package/build-module/store/actions.js.map +1 -1
  272. package/build-module/store/defaults.js +1 -5
  273. package/build-module/store/defaults.js.map +1 -1
  274. package/build-module/store/reducer.js +24 -1
  275. package/build-module/store/reducer.js.map +1 -1
  276. package/build-module/store/selectors.js +2 -2
  277. package/build-module/store/selectors.js.map +1 -1
  278. package/build-module/utils/get-paste-event-data.js +1 -1
  279. package/build-module/utils/get-paste-event-data.js.map +1 -1
  280. package/build-module/utils/parse-css-unit-to-px.js +1 -1
  281. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  282. package/build-style/style-rtl.css +180 -212
  283. package/build-style/style.css +180 -212
  284. package/package.json +27 -27
  285. package/src/components/block-caption/index.native.js +4 -22
  286. package/src/components/block-inspector/index.js +32 -13
  287. package/src/components/block-list/block.js +1 -1
  288. package/src/components/block-list/block.native.js +2 -2
  289. package/src/components/block-list/use-block-props/index.js +1 -3
  290. package/src/components/block-list/use-in-between-inserter.js +1 -1
  291. package/src/components/block-list-appender/index.js +21 -5
  292. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +2 -5
  293. package/src/components/block-mover/button.js +2 -6
  294. package/src/components/block-mover/index.js +2 -5
  295. package/src/components/block-mover/index.native.js +2 -5
  296. package/src/components/block-preview/auto.js +2 -7
  297. package/src/components/block-settings/container.native.js +0 -1
  298. package/src/components/block-styles/index.js +145 -125
  299. package/src/components/block-styles/style.scss +51 -59
  300. package/src/components/block-styles/test/{utils.js → index.js} +1 -60
  301. package/src/components/block-styles/utils.js +0 -39
  302. package/src/components/block-switcher/block-styles-menu.js +38 -3
  303. package/src/components/block-tools/back-compat.js +0 -1
  304. package/src/components/block-tools/block-selection-button.js +3 -9
  305. package/src/components/block-tools/index.js +11 -0
  306. package/src/components/block-tools/insertion-point.js +1 -10
  307. package/src/components/border-style-control/style.scss +1 -0
  308. package/src/components/button-block-appender/index.js +0 -1
  309. package/src/components/colors-gradients/panel-color-gradient-settings.js +19 -75
  310. package/src/components/colors-gradients/style.scss +5 -42
  311. package/src/components/default-block-appender/index.js +24 -17
  312. package/src/components/default-block-appender/style.scss +0 -4
  313. package/src/components/default-block-appender/test/__snapshots__/index.js.snap +24 -12
  314. package/src/components/default-block-appender/test/index.js +14 -4
  315. package/src/components/default-style-picker/index.js +6 -18
  316. package/src/components/font-appearance-control/index.js +12 -12
  317. package/src/components/gradients/use-gradient.js +7 -7
  318. package/src/components/iframe/index.js +6 -13
  319. package/src/components/index.js +1 -1
  320. package/src/components/inner-blocks/README.md +0 -2
  321. package/src/components/inner-blocks/default-block-appender.js +7 -2
  322. package/src/components/inserter/hooks/use-insertion-point.js +2 -9
  323. package/src/components/inserter/index.js +2 -2
  324. package/src/components/inserter/index.native.js +4 -7
  325. package/src/components/inserter/quick-inserter.js +1 -1
  326. package/src/components/inserter/tabs.native.js +4 -5
  327. package/src/components/inspector-controls/block-support-slot-container.js +1 -3
  328. package/src/components/inspector-controls/block-support-tools-panel.js +57 -21
  329. package/src/components/inspector-controls/fill.native.js +3 -4
  330. package/src/components/inspector-controls/groups.js +0 -2
  331. package/src/components/inspector-controls/slot.js +7 -2
  332. package/src/components/letter-spacing-control/index.js +6 -6
  333. package/src/components/link-control/README.md +1 -1
  334. package/src/components/link-control/test/index.js +0 -2
  335. package/src/components/list-view/block-select-button.js +1 -20
  336. package/src/components/list-view/use-list-view-drop-zone.js +1 -1
  337. package/src/components/media-placeholder/index.js +0 -2
  338. package/src/components/media-replace-flow/index.js +0 -2
  339. package/src/components/provider/use-block-sync.js +45 -11
  340. package/src/components/rich-text/file-paste-handler.js +1 -3
  341. package/src/components/rich-text/use-input-rules.js +1 -2
  342. package/src/components/selection-scroll-into-view/index.js +0 -1
  343. package/src/components/url-input/README.md +0 -5
  344. package/src/components/use-canvas-click-redirect/index.js +57 -0
  345. package/src/components/use-on-block-drop/index.js +4 -11
  346. package/src/components/use-setting/index.js +9 -0
  347. package/src/components/writing-flow/use-multi-selection.js +9 -12
  348. package/src/hooks/border-color.js +3 -55
  349. package/src/hooks/border-radius.js +0 -32
  350. package/src/hooks/border-style.js +0 -26
  351. package/src/hooks/border-width.js +32 -56
  352. package/src/hooks/border.js +20 -115
  353. package/src/hooks/border.scss +17 -3
  354. package/src/hooks/color.js +13 -14
  355. package/src/hooks/layout.js +1 -0
  356. package/src/hooks/letter-spacing.js +1 -1
  357. package/src/hooks/style.js +2 -1
  358. package/src/hooks/test/style.js +0 -2
  359. package/src/hooks/typography.js +1 -1
  360. package/src/layouts/flex.js +8 -31
  361. package/src/layouts/flow.js +8 -6
  362. package/src/store/actions.js +5 -5
  363. package/src/store/defaults.js +0 -2
  364. package/src/store/reducer.js +23 -1
  365. package/src/store/selectors.js +2 -2
  366. package/src/store/test/reducer.js +35 -0
  367. package/src/store/test/selectors.js +1 -1
  368. package/src/style.scss +3 -4
  369. package/src/utils/get-paste-event-data.js +1 -1
  370. package/src/utils/parse-css-unit-to-px.js +1 -1
  371. package/src/utils/test/parse-css-unit-to-px.js +0 -1
  372. package/tsconfig.tsbuildinfo +1 -1
  373. package/build/components/block-styles/menu-items.js +0 -63
  374. package/build/components/block-styles/menu-items.js.map +0 -1
  375. package/build/components/block-styles/preview-panel.js +0 -45
  376. package/build/components/block-styles/preview-panel.js.map +0 -1
  377. package/build/components/block-styles/use-styles-for-block.js +0 -119
  378. package/build/components/block-styles/use-styles-for-block.js.map +0 -1
  379. package/build/components/rich-text/prevent-event-discovery.js +0 -33
  380. package/build/components/rich-text/prevent-event-discovery.js.map +0 -1
  381. package/build/components/use-display-block-controls/index.native.js +0 -45
  382. package/build/components/use-display-block-controls/index.native.js.map +0 -1
  383. package/build-module/components/block-styles/menu-items.js +0 -50
  384. package/build-module/components/block-styles/menu-items.js.map +0 -1
  385. package/build-module/components/block-styles/preview-panel.js +0 -35
  386. package/build-module/components/block-styles/preview-panel.js.map +0 -1
  387. package/build-module/components/block-styles/use-styles-for-block.js +0 -107
  388. package/build-module/components/block-styles/use-styles-for-block.js.map +0 -1
  389. package/build-module/components/rich-text/prevent-event-discovery.js +0 -25
  390. package/build-module/components/rich-text/prevent-event-discovery.js.map +0 -1
  391. package/build-module/components/use-display-block-controls/index.native.js +0 -34
  392. package/build-module/components/use-display-block-controls/index.native.js.map +0 -1
  393. package/src/components/block-styles/menu-items.js +0 -49
  394. package/src/components/block-styles/preview-panel.js +0 -36
  395. package/src/components/block-styles/use-styles-for-block.js +0 -99
  396. package/src/components/rich-text/prevent-event-discovery.js +0 -23
  397. package/src/components/use-display-block-controls/index.native.js +0 -38
  398. package/src/components/writing-flow/test/use-multi-selection.js +0 -36
  399. package/src/hooks/dimensions.scss +0 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/provider/use-block-sync.js"],"names":["last","noop","useEffect","useRef","useRegistry","cloneBlock","store","blockEditorStore","useBlockSync","clientId","value","controlledBlocks","selection","controlledSelection","onChange","onInput","registry","resetBlocks","resetSelection","replaceInnerBlocks","setHasControlledInnerBlocks","__unstableMarkNextChangeAsNotPersistent","dispatch","getBlockName","getBlocks","select","pendingChanges","incoming","outgoing","subscribed","setControlledBlocks","storeBlocks","map","block","current","onInputRef","onChangeRef","includes","selectionStart","selectionEnd","initialPosition","getSelectionStart","getSelectionEnd","getSelectedBlocksInitialCaretPosition","isLastBlockChangePersistent","__unstableIsLastBlockChangeIgnored","blocks","isPersistent","previousAreBlocksDifferent","unsubscribe","subscribe","newIsPersistent","newBlocks","areBlocksDifferent","didPersistenceChange","push","updateParent"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,IAAf,QAA2B,QAA3B;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,UAAT,QAA2B,mBAA3B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,YAAT,OAMX;AAAA,MANkC;AACrCC,IAAAA,QAAQ,GAAG,IAD0B;AAErCC,IAAAA,KAAK,EAAEC,gBAF8B;AAGrCC,IAAAA,SAAS,EAAEC,mBAH0B;AAIrCC,IAAAA,QAAQ,GAAGb,IAJ0B;AAKrCc,IAAAA,OAAO,GAAGd;AAL2B,GAMlC;AACH,QAAMe,QAAQ,GAAGZ,WAAW,EAA5B;AAEA,QAAM;AACLa,IAAAA,WADK;AAELC,IAAAA,cAFK;AAGLC,IAAAA,kBAHK;AAILC,IAAAA,2BAJK;AAKLC,IAAAA;AALK,MAMFL,QAAQ,CAACM,QAAT,CAAmBf,gBAAnB,CANJ;AAOA,QAAM;AAAEgB,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAA8BR,QAAQ,CAACS,MAAT,CAAiBlB,gBAAjB,CAApC;AAEA,QAAMmB,cAAc,GAAGvB,MAAM,CAAE;AAAEwB,IAAAA,QAAQ,EAAE,IAAZ;AAAkBC,IAAAA,QAAQ,EAAE;AAA5B,GAAF,CAA7B;A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3B;AACA,YAAM4C,kBAAkB,GAAGD,SAAS,KAAKN,MAAzC;AACAA,MAAAA,MAAM,GAAGM,SAAT;;AAEA,UACCC,kBAAkB,KAChB3B,cAAc,CAACQ,OAAf,CAAuBP,QAAvB,IACDkB,kCAAkC,EAFjB,CADnB,EAIE;AACDnB,QAAAA,cAAc,CAACQ,OAAf,CAAuBP,QAAvB,GAAkC,IAAlC;AACAoB,QAAAA,YAAY,GAAGI,eAAf;AACA;AACA,OAzB4C,CA2B7C;AACA;AACA;;;AACA,YAAMG,oBAAoB,GACzBN,0BAA0B,IAC1B,CAAEK,kBADF,IAEAF,eAFA,IAGA,CAAEJ,YAJH;;AAMA,UAAKM,kBAAkB,IAAIC,oBAA3B,EAAkD;AACjDP,QAAAA,YAAY,GAAGI,eAAf,CADiD,CAEjD;AACA;AACA;AACA;;AACAzB,QAAAA,cAAc,CAACQ,OAAf,CAAuBN,QAAvB,CAAgC2B,IAAhC,CAAsCT,MAAtC,EANiD,CAQjD;AACA;;AACA,cAAMU,YAAY,GAAGT,YAAY,GAC9BX,WAAW,CAACF,OADkB,GAE9BC,UAAU,CAACD,OAFd;AAGAsB,QAAAA,YAAY,CAAEV,MAAF,EAAU;AACrBlC,UAAAA,SAAS,EAAE;AACV0B,YAAAA,cAAc,EAAEG,iBAAiB,EADvB;AAEVF,YAAAA,YAAY,EAAEG,eAAe,EAFnB;AAGVF,YAAAA,eAAe,EAAEG,qCAAqC;AAH5C;AADU,SAAV,CAAZ;AAOA;;AACDK,MAAAA,0BAA0B,GAAGK,kBAA7B;AACA,KA1DmB,CAApB;AA4DA,WAAO,MAAMJ,WAAW,EAAxB;AACA,GA3EQ,EA2EN,CAAEjC,QAAF,EAAYP,QAAZ,CA3EM,CAAT;AA4EA","sourcesContent":["/**\n * External dependencies\n */\nimport { last, noop } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useRegistry } from '@wordpress/data';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * A function to call when the block value has been updated in the block-editor\n * store.\n *\n * @callback onBlockUpdate\n * @param {Object[]} blocks The updated blocks.\n * @param {Object} options The updated block options, such as selectionStart\n * and selectionEnd.\n */\n\n/**\n * useBlockSync is a side effect which handles bidirectional sync between the\n * block-editor store and a controlling data source which provides blocks. This\n * is most commonly used by the BlockEditorProvider to synchronize the contents\n * of the block-editor store with the root entity, like a post.\n *\n * Another example would be the template part block, which provides blocks from\n * a separate entity data source than a root entity. This hook syncs edits to\n * the template part in the block editor back to the entity and vice-versa.\n *\n * Here are some of its basic functions:\n * - Initalizes the block-editor store for the given clientID to the blocks\n * given via props.\n * - Adds incoming changes (like undo) to the block-editor store.\n * - Adds outgoing changes (like editing content) to the controlling entity,\n * determining if a change should be considered persistent or not.\n * - Handles edge cases and race conditions which occur in those operations.\n * - Ignores changes which happen to other entities (like nested inner block\n * controllers.\n * - Passes selection state from the block-editor store to the controlling entity.\n *\n * @param {Object} props Props for the block sync hook\n * @param {string} props.clientId The client ID of the inner block controller.\n * If none is passed, then it is assumed to be a\n * root controller rather than an inner block\n * controller.\n * @param {Object[]} props.value The control value for the blocks. This value\n * is used to initalize the block-editor store\n * and for resetting the blocks to incoming\n * changes like undo.\n * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.\n * @param {onBlockUpdate} props.onChange Function to call when a persistent\n * change has been made in the block-editor blocks\n * for the given clientId. For example, after\n * this function is called, an entity is marked\n * dirty because it has changes to save.\n * @param {onBlockUpdate} props.onInput Function to call when a non-persistent\n * change has been made in the block-editor blocks\n * for the given clientId. When this is called,\n * controlling sources do not become dirty.\n */\nexport default function useBlockSync( {\n\tclientId = null,\n\tvalue: controlledBlocks,\n\tselection: controlledSelection,\n\tonChange = noop,\n\tonInput = noop,\n} ) {\n\tconst registry = useRegistry();\n\n\tconst {\n\t\tresetBlocks,\n\t\tresetSelection,\n\t\treplaceInnerBlocks,\n\t\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst { getBlockName, getBlocks } = registry.select( blockEditorStore );\n\n\tconst pendingChanges = useRef( { incoming: null, outgoing: [] } );\n\tconst subscribed = useRef( false );\n\n\tconst setControlledBlocks = () => {\n\t\tif ( ! controlledBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't need to persist this change because we only replace\n\t\t// controlled inner blocks when the change was caused by an entity,\n\t\t// and so it would already be persisted.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\tsetHasControlledInnerBlocks( clientId, true );\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tconst storeBlocks = controlledBlocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tif ( subscribed.current ) {\n\t\t\t\tpendingChanges.current.incoming = storeBlocks;\n\t\t\t}\n\t\t\treplaceInnerBlocks( clientId, storeBlocks );\n\t\t} else {\n\t\t\tif ( subscribed.current ) {\n\t\t\t\tpendingChanges.current.incoming = controlledBlocks;\n\t\t\t}\n\t\t\tresetBlocks( controlledBlocks );\n\t\t}\n\t};\n\n\t// Add a subscription to the block-editor registry to detect when changes\n\t// have been made. This lets us inform the data source of changes. This\n\t// is an effect so that the subscriber can run synchronously without\n\t// waiting for React renders for changes.\n\tconst onInputRef = useRef( onInput );\n\tconst onChangeRef = useRef( onChange );\n\tuseEffect( () => {\n\t\tonInputRef.current = onInput;\n\t\tonChangeRef.current = onChange;\n\t}, [ onInput, onChange ] );\n\n\t// Determine if blocks need to be reset when they change.\n\tuseEffect( () => {\n\t\tif ( pendingChanges.current.outgoing.includes( controlledBlocks ) ) {\n\t\t\t// Skip block reset if the value matches expected outbound sync\n\t\t\t// triggered by this component by a preceding change detection.\n\t\t\t// Only skip if the value matches expectation, since a reset should\n\t\t\t// still occur if the value is modified (not equal by reference),\n\t\t\t// to allow that the consumer may apply modifications to reflect\n\t\t\t// back on the editor.\n\t\t\tif (\n\t\t\t\tlast( pendingChanges.current.outgoing ) === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChanges.current.outgoing = [];\n\t\t\t}\n\t\t} else if ( getBlocks( clientId ) !== controlledBlocks ) {\n\t\t\t// Reset changing value in all other cases than the sync described\n\t\t\t// above. Since this can be reached in an update following an out-\n\t\t\t// bound sync, unset the outbound value to avoid considering it in\n\t\t\t// subsequent renders.\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\n\t\t\tif ( controlledSelection ) {\n\t\t\t\tresetSelection(\n\t\t\t\t\tcontrolledSelection.selectionStart,\n\t\t\t\t\tcontrolledSelection.selectionEnd,\n\t\t\t\t\tcontrolledSelection.initialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tuseEffect( () => {\n\t\tconst {\n\t\t\tgetSelectionStart,\n\t\t\tgetSelectionEnd,\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t\tisLastBlockChangePersistent,\n\t\t\t__unstableIsLastBlockChangeIgnored,\n\t\t} = registry.select( blockEditorStore );\n\n\t\tlet blocks = getBlocks( clientId );\n\t\tlet isPersistent = isLastBlockChangePersistent();\n\t\tlet previousAreBlocksDifferent = false;\n\n\t\tsubscribed.current = true;\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Sometimes, when changing block lists, lingering subscriptions\n\t\t\t// might trigger before they are cleaned up. If the block for which\n\t\t\t// the subscription runs is no longer in the store, this would clear\n\t\t\t// its parent entity's block list. To avoid this, we bail out if\n\t\t\t// the subscription is triggering for a block (`clientId !== null`)\n\t\t\t// and its block name can't be found because it's not on the list.\n\t\t\t// (`getBlockName( clientId ) === null`).\n\t\t\tif ( clientId !== null && getBlockName( clientId ) === null )\n\t\t\t\treturn;\n\n\t\t\tconst newIsPersistent = isLastBlockChangePersistent();\n\n\t\t\tconst newBlocks = getBlocks( clientId );\n\t\t\tconst areBlocksDifferent = newBlocks !== blocks;\n\t\t\tblocks = newBlocks;\n\n\t\t\tif (\n\t\t\t\tareBlocksDifferent &&\n\t\t\t\t( pendingChanges.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChanges.current.incoming = null;\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Since we often dispatch an action to mark the previous action as\n\t\t\t// persistent, we need to make sure that the blocks changed on the\n\t\t\t// previous action before committing the change.\n\t\t\tconst didPersistenceChange =\n\t\t\t\tpreviousAreBlocksDifferent &&\n\t\t\t\t! areBlocksDifferent &&\n\t\t\t\tnewIsPersistent &&\n\t\t\t\t! isPersistent;\n\n\t\t\tif ( areBlocksDifferent || didPersistenceChange ) {\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\t// We know that onChange/onInput will update controlledBlocks.\n\t\t\t\t// We need to be aware that it was caused by an outgoing change\n\t\t\t\t// so that we do not treat it as an incoming change later on,\n\t\t\t\t// which would cause a block reset.\n\t\t\t\tpendingChanges.current.outgoing.push( blocks );\n\n\t\t\t\t// Inform the controlling entity that changes have been made to\n\t\t\t\t// the block-editor store they should be aware about.\n\t\t\t\tconst updateParent = isPersistent\n\t\t\t\t\t? onChangeRef.current\n\t\t\t\t\t: onInputRef.current;\n\t\t\t\tupdateParent( blocks, {\n\t\t\t\t\tselection: {\n\t\t\t\t\t\tselectionStart: getSelectionStart(),\n\t\t\t\t\t\tselectionEnd: getSelectionEnd(),\n\t\t\t\t\t\tinitialPosition: getSelectedBlocksInitialCaretPosition(),\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\tpreviousAreBlocksDifferent = areBlocksDifferent;\n\t\t} );\n\n\t\treturn () => unsubscribe();\n\t}, [ registry, clientId ] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/provider/use-block-sync.js"],"names":["last","noop","useEffect","useRef","useRegistry","useSelect","cloneBlock","store","blockEditorStore","useBlockSync","clientId","value","controlledBlocks","selection","controlledSelection","onChange","onInput","registry","resetBlocks","resetSelection","replaceInnerBlocks","setHasControlledInnerBlocks","__unstableMarkNextChangeAsNotPersistent","dispatch","getBlockName","getBlocks","select","isControlled","areInnerBlocksControlled","pendingChanges","incoming","outgoing","subscribed","setControlledBlocks","batch","storeBlocks","map","block","current","onInputRef","onChangeRef","includes","selectionStart","selectionEnd","initialPosition","getSelectionStart","getSelectionEnd","getSelectedBlocksInitialCaretPosition","isLastBlockChangePersistent","__unstableIsLastBlockChangeIgnored","blocks","isPersistent","previousAreBlocksDifferent","unsubscribe","subscribe","isStillControlled","newIsPersistent","newBlocks","areBlocksDifferent","didPersistenceChange","push","updateParent"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,IAAf,QAA2B,QAA3B;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,UAAT,QAA2B,mBAA3B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,YAAT,OAMX;AAAA,MANkC;AACrCC,IAAAA,QAAQ,GAAG,IAD0B;AAErCC,IAAAA,KAAK,EAAEC,gBAF8B;AAGrCC,IAAAA,SAAS,EAAEC,mBAH0B;AAIrCC,IAAAA,QAAQ,GAAGd,IAJ0B;AAKrCe,IAAAA,OAAO,GAAG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ACS,OAAf,CAAuBR,QAAvB,IACDmB,kCAAkC,EAFjB,CADnB,EAIE;AACDpB,QAAAA,cAAc,CAACS,OAAf,CAAuBR,QAAvB,GAAkC,IAAlC;AACAqB,QAAAA,YAAY,GAAGK,eAAf;AACA;AACA,OAlC4C,CAoC7C;AACA;AACA;;;AACA,YAAMG,oBAAoB,GACzBP,0BAA0B,IAC1B,CAAEM,kBADF,IAEAF,eAFA,IAGA,CAAEL,YAJH;;AAMA,UAAKO,kBAAkB,IAAIC,oBAA3B,EAAkD;AACjDR,QAAAA,YAAY,GAAGK,eAAf,CADiD,CAEjD;AACA;AACA;AACA;;AACA3B,QAAAA,cAAc,CAACS,OAAf,CAAuBP,QAAvB,CAAgC6B,IAAhC,CAAsCV,MAAtC,EANiD,CAQjD;AACA;;AACA,cAAMW,YAAY,GAAGV,YAAY,GAC9BX,WAAW,CAACF,OADkB,GAE9BC,UAAU,CAACD,OAFd;AAGAuB,QAAAA,YAAY,CAAEX,MAAF,EAAU;AACrBrC,UAAAA,SAAS,EAAE;AACV6B,YAAAA,cAAc,EAAEG,iBAAiB,EADvB;AAEVF,YAAAA,YAAY,EAAEG,eAAe,EAFnB;AAGVF,YAAAA,eAAe,EAAEG,qCAAqC;AAH5C;AADU,SAAV,CAAZ;AAOA;;AACDK,MAAAA,0BAA0B,GAAGM,kBAA7B;AACA,KAnEmB,CAApB;AAqEA,WAAO,MAAML,WAAW,EAAxB;AACA,GArFQ,EAqFN,CAAEpC,QAAF,EAAYP,QAAZ,CArFM,CAAT;AAsFA","sourcesContent":["/**\n * External dependencies\n */\nimport { last, noop } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * A function to call when the block value has been updated in the block-editor\n * store.\n *\n * @callback onBlockUpdate\n * @param {Object[]} blocks The updated blocks.\n * @param {Object} options The updated block options, such as selectionStart\n * and selectionEnd.\n */\n\n/**\n * useBlockSync is a side effect which handles bidirectional sync between the\n * block-editor store and a controlling data source which provides blocks. This\n * is most commonly used by the BlockEditorProvider to synchronize the contents\n * of the block-editor store with the root entity, like a post.\n *\n * Another example would be the template part block, which provides blocks from\n * a separate entity data source than a root entity. This hook syncs edits to\n * the template part in the block editor back to the entity and vice-versa.\n *\n * Here are some of its basic functions:\n * - Initalizes the block-editor store for the given clientID to the blocks\n * given via props.\n * - Adds incoming changes (like undo) to the block-editor store.\n * - Adds outgoing changes (like editing content) to the controlling entity,\n * determining if a change should be considered persistent or not.\n * - Handles edge cases and race conditions which occur in those operations.\n * - Ignores changes which happen to other entities (like nested inner block\n * controllers.\n * - Passes selection state from the block-editor store to the controlling entity.\n *\n * @param {Object} props Props for the block sync hook\n * @param {string} props.clientId The client ID of the inner block controller.\n * If none is passed, then it is assumed to be a\n * root controller rather than an inner block\n * controller.\n * @param {Object[]} props.value The control value for the blocks. This value\n * is used to initalize the block-editor store\n * and for resetting the blocks to incoming\n * changes like undo.\n * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.\n * @param {onBlockUpdate} props.onChange Function to call when a persistent\n * change has been made in the block-editor blocks\n * for the given clientId. For example, after\n * this function is called, an entity is marked\n * dirty because it has changes to save.\n * @param {onBlockUpdate} props.onInput Function to call when a non-persistent\n * change has been made in the block-editor blocks\n * for the given clientId. When this is called,\n * controlling sources do not become dirty.\n */\nexport default function useBlockSync( {\n\tclientId = null,\n\tvalue: controlledBlocks,\n\tselection: controlledSelection,\n\tonChange = noop,\n\tonInput = noop,\n} ) {\n\tconst registry = useRegistry();\n\n\tconst {\n\t\tresetBlocks,\n\t\tresetSelection,\n\t\treplaceInnerBlocks,\n\t\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst { getBlockName, getBlocks } = registry.select( blockEditorStore );\n\tconst isControlled = useSelect(\n\t\t( select ) => {\n\t\t\treturn (\n\t\t\t\t! clientId ||\n\t\t\t\tselect( blockEditorStore ).areInnerBlocksControlled( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst pendingChanges = useRef( { incoming: null, outgoing: [] } );\n\tconst subscribed = useRef( false );\n\n\tconst setControlledBlocks = () => {\n\t\tif ( ! controlledBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't need to persist this change because we only replace\n\t\t// controlled inner blocks when the change was caused by an entity,\n\t\t// and so it would already be persisted.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\t// It is important to batch here because otherwise,\n\t\t\t// as soon as `setHasControlledInnerBlocks` is called\n\t\t\t// the effect to restore might be triggered\n\t\t\t// before the actual blocks get set properly in state.\n\t\t\tregistry.batch( () => {\n\t\t\t\tsetHasControlledInnerBlocks( clientId, true );\n\t\t\t\tconst storeBlocks = controlledBlocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock( block )\n\t\t\t\t);\n\t\t\t\tif ( subscribed.current ) {\n\t\t\t\t\tpendingChanges.current.incoming = storeBlocks;\n\t\t\t\t}\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceInnerBlocks( clientId, storeBlocks );\n\t\t\t} );\n\t\t} else {\n\t\t\tif ( subscribed.current ) {\n\t\t\t\tpendingChanges.current.incoming = controlledBlocks;\n\t\t\t}\n\t\t\tresetBlocks( controlledBlocks );\n\t\t}\n\t};\n\n\t// Add a subscription to the block-editor registry to detect when changes\n\t// have been made. This lets us inform the data source of changes. This\n\t// is an effect so that the subscriber can run synchronously without\n\t// waiting for React renders for changes.\n\tconst onInputRef = useRef( onInput );\n\tconst onChangeRef = useRef( onChange );\n\tuseEffect( () => {\n\t\tonInputRef.current = onInput;\n\t\tonChangeRef.current = onChange;\n\t}, [ onInput, onChange ] );\n\n\t// Determine if blocks need to be reset when they change.\n\tuseEffect( () => {\n\t\tif ( pendingChanges.current.outgoing.includes( controlledBlocks ) ) {\n\t\t\t// Skip block reset if the value matches expected outbound sync\n\t\t\t// triggered by this component by a preceding change detection.\n\t\t\t// Only skip if the value matches expectation, since a reset should\n\t\t\t// still occur if the value is modified (not equal by reference),\n\t\t\t// to allow that the consumer may apply modifications to reflect\n\t\t\t// back on the editor.\n\t\t\tif (\n\t\t\t\tlast( pendingChanges.current.outgoing ) === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChanges.current.outgoing = [];\n\t\t\t}\n\t\t} else if ( getBlocks( clientId ) !== controlledBlocks ) {\n\t\t\t// Reset changing value in all other cases than the sync described\n\t\t\t// above. Since this can be reached in an update following an out-\n\t\t\t// bound sync, unset the outbound value to avoid considering it in\n\t\t\t// subsequent renders.\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\n\t\t\tif ( controlledSelection ) {\n\t\t\t\tresetSelection(\n\t\t\t\t\tcontrolledSelection.selectionStart,\n\t\t\t\t\tcontrolledSelection.selectionEnd,\n\t\t\t\t\tcontrolledSelection.initialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tuseEffect( () => {\n\t\t// When the block becomes uncontrolled, it means its inner state has been reset\n\t\t// we need to take the blocks again from the external value property.\n\t\tif ( ! isControlled ) {\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\t\t}\n\t}, [ isControlled ] );\n\n\tuseEffect( () => {\n\t\tconst {\n\t\t\tgetSelectionStart,\n\t\t\tgetSelectionEnd,\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t\tisLastBlockChangePersistent,\n\t\t\t__unstableIsLastBlockChangeIgnored,\n\t\t\tareInnerBlocksControlled,\n\t\t} = registry.select( blockEditorStore );\n\n\t\tlet blocks = getBlocks( clientId );\n\t\tlet isPersistent = isLastBlockChangePersistent();\n\t\tlet previousAreBlocksDifferent = false;\n\n\t\tsubscribed.current = true;\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Sometimes, when changing block lists, lingering subscriptions\n\t\t\t// might trigger before they are cleaned up. If the block for which\n\t\t\t// the subscription runs is no longer in the store, this would clear\n\t\t\t// its parent entity's block list. To avoid this, we bail out if\n\t\t\t// the subscription is triggering for a block (`clientId !== null`)\n\t\t\t// and its block name can't be found because it's not on the list.\n\t\t\t// (`getBlockName( clientId ) === null`).\n\t\t\tif ( clientId !== null && getBlockName( clientId ) === null )\n\t\t\t\treturn;\n\n\t\t\t// When RESET_BLOCKS on parent blocks get called, the controlled blocks\n\t\t\t// can reset to uncontrolled, in these situations, it means we need to populate\n\t\t\t// the blocks again from the external blocks (the value property here)\n\t\t\t// and we should stop triggering onChange\n\t\t\tconst isStillControlled =\n\t\t\t\t! clientId || areInnerBlocksControlled( clientId );\n\t\t\tif ( ! isStillControlled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newIsPersistent = isLastBlockChangePersistent();\n\t\t\tconst newBlocks = getBlocks( clientId );\n\t\t\tconst areBlocksDifferent = newBlocks !== blocks;\n\t\t\tblocks = newBlocks;\n\n\t\t\tif (\n\t\t\t\tareBlocksDifferent &&\n\t\t\t\t( pendingChanges.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChanges.current.incoming = null;\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Since we often dispatch an action to mark the previous action as\n\t\t\t// persistent, we need to make sure that the blocks changed on the\n\t\t\t// previous action before committing the change.\n\t\t\tconst didPersistenceChange =\n\t\t\t\tpreviousAreBlocksDifferent &&\n\t\t\t\t! areBlocksDifferent &&\n\t\t\t\tnewIsPersistent &&\n\t\t\t\t! isPersistent;\n\n\t\t\tif ( areBlocksDifferent || didPersistenceChange ) {\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\t// We know that onChange/onInput will update controlledBlocks.\n\t\t\t\t// We need to be aware that it was caused by an outgoing change\n\t\t\t\t// so that we do not treat it as an incoming change later on,\n\t\t\t\t// which would cause a block reset.\n\t\t\t\tpendingChanges.current.outgoing.push( blocks );\n\n\t\t\t\t// Inform the controlling entity that changes have been made to\n\t\t\t\t// the block-editor store they should be aware about.\n\t\t\t\tconst updateParent = isPersistent\n\t\t\t\t\t? onChangeRef.current\n\t\t\t\t\t: onInputRef.current;\n\t\t\t\tupdateParent( blocks, {\n\t\t\t\t\tselection: {\n\t\t\t\t\t\tselectionStart: getSelectionStart(),\n\t\t\t\t\t\tselectionEnd: getSelectionEnd(),\n\t\t\t\t\t\tinitialPosition: getSelectedBlocksInitialCaretPosition(),\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\tpreviousAreBlocksDifferent = areBlocksDifferent;\n\t\t} );\n\n\t\treturn () => unsubscribe();\n\t}, [ registry, clientId ] );\n}\n"]}
@@ -7,7 +7,7 @@ export function filePasteHandler(files) {
7
7
  let {
8
8
  type
9
9
  } = _ref;
10
- return /^image\/(?:jpe?g|png|gif|webp)$/.test(type);
10
+ return /^image\/(?:jpe?g|png|gif)$/.test(type);
11
11
  }).map(file => `<img src="${createBlobURL(file)}">`).join('');
12
12
  }
13
13
  //# sourceMappingURL=file-paste-handler.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/file-paste-handler.js"],"names":["createBlobURL","filePasteHandler","files","filter","type","test","map","file","join"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,iBAA9B;AAEA,OAAO,SAASC,gBAAT,CAA2BC,KAA3B,EAAmC;AACzC,SAAOA,KAAK,CACVC,MADK,CACG;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WACR,kCAAkCC,IAAlC,CAAwCD,IAAxC,CADQ;AAAA,GADH,EAILE,GAJK,CAIEC,IAAF,IAAa,aAAaP,aAAa,CAAEO,IAAF,CAAU,IAJjD,EAKLC,IALK,CAKC,EALD,CAAP;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlobURL } from '@wordpress/blob';\n\nexport function filePasteHandler( files ) {\n\treturn files\n\t\t.filter( ( { type } ) =>\n\t\t\t/^image\\/(?:jpe?g|png|gif|webp)$/.test( type )\n\t\t)\n\t\t.map( ( file ) => `<img src=\"${ createBlobURL( file ) }\">` )\n\t\t.join( '' );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/file-paste-handler.js"],"names":["createBlobURL","filePasteHandler","files","filter","type","test","map","file","join"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,iBAA9B;AAEA,OAAO,SAASC,gBAAT,CAA2BC,KAA3B,EAAmC;AACzC,SAAOA,KAAK,CACVC,MADK,CACG;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WAAgB,6BAA6BC,IAA7B,CAAmCD,IAAnC,CAAhB;AAAA,GADH,EAELE,GAFK,CAEEC,IAAF,IAAa,aAAaP,aAAa,CAAEO,IAAF,CAAU,IAFjD,EAGLC,IAHK,CAGC,EAHD,CAAP;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlobURL } from '@wordpress/blob';\n\nexport function filePasteHandler( files ) {\n\treturn files\n\t\t.filter( ( { type } ) => /^image\\/(?:jpe?g|png|gif)$/.test( type ) )\n\t\t.map( ( file ) => `<img src=\"${ createBlobURL( file ) }\">` )\n\t\t.join( '' );\n}\n"]}
@@ -11,7 +11,6 @@ import { useDispatch } from '@wordpress/data';
11
11
  */
12
12
 
13
13
  import { store as blockEditorStore } from '../../store';
14
- import { preventEventDiscovery } from './prevent-event-discovery';
15
14
  export function useInputRules(props) {
16
15
  const {
17
16
  __unstableMarkLastChangeAsPersistent,
@@ -97,7 +96,7 @@ export function useInputRules(props) {
97
96
  }
98
97
 
99
98
  return accumlator;
100
- }, preventEventDiscovery(value));
99
+ }, value);
101
100
 
102
101
  if (transformed !== value) {
103
102
  __unstableMarkLastChangeAsPersistent();
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-input-rules.js"],"names":["useRef","useRefEffect","slice","toHTMLString","getBlockTransforms","findTransform","useDispatch","store","blockEditorStore","preventEventDiscovery","useInputRules","props","__unstableMarkLastChangeAsPersistent","__unstableMarkAutomaticChange","propsRef","current","element","inputRule","value","onReplace","start","text","characterBefore","trimmedTextBefore","trim","prefixTransforms","filter","type","transformation","prefix","content","length","block","transform","onInput","event","inputType","onChange","__unstableAllowPrefixTransformations","formatTypes","transformed","reduce","accumlator","__unstableInputRule","activeFormats","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,oBAAvB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,KAAT,EAAgBC,YAAhB,QAAoC,sBAApC;AACA,SAASC,kBAAT,EAA6BC,aAA7B,QAAkD,mBAAlD;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,qBAAT,QAAsC,2BAAtC;AAEA,OAAO,SAASC,aAAT,CAAwBC,KAAxB,EAAgC;AACtC,QAAM;AACLC,IAAAA,oCADK;AAELC,IAAAA;AAFK,MAGFP,WAAW,CAAEE,gBAAF,CAHf;AAIA,QAAMM,QAAQ,GAAGd,MAAM,CAAEW,KAAF,CAAvB;AACAG,EAAAA,QAAQ,CAACC,OAAT,GAAmBJ,KAAnB;AACA,SAAOV,YAAY,CAAIe,OAAF,IAAe;AACnC,aAASC,SAAT,GAAqB;AACpB,YAAM;AAAEC,QAAAA,KAAF;AAASC,QAAAA;AAAT,UAAuBL,QAAQ,CAACC,OAAtC;;AAEA,UAAK,CAAEI,SAAP,EAAmB;AAClB;AACA;;AAED,YAAM;AAAEC,QAAAA,KAAF;AAASC,QAAAA;AAAT,UAAkBH,KAAxB;AACA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;AAC9D;AACA;;AAED,UAAKW,oCAAoC,IAAIrB,SAA7C,EAAyD;AACxDA,QAAAA,SAAS;AACT;;AAED,YAAMuB,WAAW,GAAGD,WAAW,CAACE,MAAZ,CACnB,CAAEC,UAAF,YAA2C;AAAA,YAA7B;AAAEC,UAAAA;AAAF,SAA6B;;AAC1C,YAAKA,mBAAL,EAA2B;AAC1BD,UAAAA,UAAU,GAAGC,mBAAmB,CAAED,UAAF,CAAhC;AACA;;AAED,eAAOA,UAAP;AACA,OAPkB,EAQnBjC,qBAAqB,CAAES,KAAF,CARF,CAApB;;AAWA,UAAKsB,WAAW,KAAKtB,KAArB,EAA6B;AAC5BN,QAAAA,oCAAoC;;AACpCyB,QAAAA,QAAQ,CAAE,EACT,GAAGG,WADM;AAETI,UAAAA,aAAa,EAAE1B,KAAK,CAAC0B;AAFZ,SAAF,CAAR;;AAIA/B,QAAAA,6BAA6B;AAC7B;AACD;;AAEDG,IAAAA,OAAO,CAAC6B,gBAAR,CAA0B,OAA1B,EAAmCX,OAAnC;AACAlB,IAAAA,OAAO,CAAC6B,gBAAR,CAA0B,gBAA1B,EAA4CX,OAA5C;AACA,WAAO,MAAM;AACZlB,MAAAA,OAAO,CAAC8B,mBAAR,CAA6B,OAA7B,EAAsCZ,OAAtC;AACAlB,MAAAA,OAAO,CAAC8B,mBAAR,CAA6B,gBAA7B,EAA+CZ,OAA/C;AACA,KAHD;AAIA,GArFkB,EAqFhB,EArFgB,CAAnB;AAsFA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { slice, toHTMLString } 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 { preventEventDiscovery } from './prevent-event-discovery';\n\nexport function useInputRules( 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 inputRule() {\n\t\t\tconst { value, onReplace } = propsRef.current;\n\n\t\t\tif ( ! onReplace ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { start, text } = value;\n\t\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t\t// The character right before the caret must be a plain space.\n\t\t\tif ( characterBefore !== ' ' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst trimmedTextBefore = text.slice( 0, start ).trim();\n\t\t\tconst prefixTransforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t( { type } ) => type === 'prefix'\n\t\t\t);\n\t\t\tconst transformation = findTransform(\n\t\t\t\tprefixTransforms,\n\t\t\t\t( { prefix } ) => {\n\t\t\t\t\treturn trimmedTextBefore === prefix;\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( ! transformation ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst content = toHTMLString( {\n\t\t\t\tvalue: slice( value, start, text.length ),\n\t\t\t} );\n\t\t\tconst block = transformation.transform( content );\n\n\t\t\tonReplace( [ block ] );\n\t\t\t__unstableMarkAutomaticChange();\n\t\t}\n\n\t\tfunction onInput( event ) {\n\t\t\tconst { inputType, type } = event;\n\t\t\tconst {\n\t\t\t\tvalue,\n\t\t\t\tonChange,\n\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\tformatTypes,\n\t\t\t} = propsRef.current;\n\n\t\t\t// Only run input rules when inserting text.\n\t\t\tif ( inputType !== 'insertText' && type !== 'compositionend' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( __unstableAllowPrefixTransformations && inputRule ) {\n\t\t\t\tinputRule();\n\t\t\t}\n\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumlator, { __unstableInputRule } ) => {\n\t\t\t\t\tif ( __unstableInputRule ) {\n\t\t\t\t\t\taccumlator = __unstableInputRule( accumlator );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumlator;\n\t\t\t\t},\n\t\t\t\tpreventEventDiscovery( value )\n\t\t\t);\n\n\t\t\tif ( transformed !== value ) {\n\t\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\t\tonChange( {\n\t\t\t\t\t...transformed,\n\t\t\t\t\tactiveFormats: value.activeFormats,\n\t\t\t\t} );\n\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'input', onInput );\n\t\telement.addEventListener( 'compositionend', onInput );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'input', onInput );\n\t\t\telement.removeEventListener( 'compositionend', onInput );\n\t\t};\n\t}, [] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-input-rules.js"],"names":["useRef","useRefEffect","slice","toHTMLString","getBlockTransforms","findTransform","useDispatch","store","blockEditorStore","useInputRules","props","__unstableMarkLastChangeAsPersistent","__unstableMarkAutomaticChange","propsRef","current","element","inputRule","value","onReplace","start","text","characterBefore","trimmedTextBefore","trim","prefixTransforms","filter","type","transformation","prefix","content","length","block","transform","onInput","event","inputType","onChange","__unstableAllowPrefixTransformations","formatTypes","transformed","reduce","accumlator","__unstableInputRule","activeFormats","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,oBAAvB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,KAAT,EAAgBC,YAAhB,QAAoC,sBAApC;AACA,SAASC,kBAAT,EAA6BC,aAA7B,QAAkD,mBAAlD;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,OAAO,SAASC,aAAT,CAAwBC,KAAxB,EAAgC;AACtC,QAAM;AACLC,IAAAA,oCADK;AAELC,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B,EAA+CZ,OAA/C;AACA,KAHD;AAIA,GArFkB,EAqFhB,EArFgB,CAAnB;AAsFA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { slice, toHTMLString } 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';\n\nexport function useInputRules( 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 inputRule() {\n\t\t\tconst { value, onReplace } = propsRef.current;\n\n\t\t\tif ( ! onReplace ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { start, text } = value;\n\t\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t\t// The character right before the caret must be a plain space.\n\t\t\tif ( characterBefore !== ' ' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst trimmedTextBefore = text.slice( 0, start ).trim();\n\t\t\tconst prefixTransforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t( { type } ) => type === 'prefix'\n\t\t\t);\n\t\t\tconst transformation = findTransform(\n\t\t\t\tprefixTransforms,\n\t\t\t\t( { prefix } ) => {\n\t\t\t\t\treturn trimmedTextBefore === prefix;\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( ! transformation ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst content = toHTMLString( {\n\t\t\t\tvalue: slice( value, start, text.length ),\n\t\t\t} );\n\t\t\tconst block = transformation.transform( content );\n\n\t\t\tonReplace( [ block ] );\n\t\t\t__unstableMarkAutomaticChange();\n\t\t}\n\n\t\tfunction onInput( event ) {\n\t\t\tconst { inputType, type } = event;\n\t\t\tconst {\n\t\t\t\tvalue,\n\t\t\t\tonChange,\n\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\tformatTypes,\n\t\t\t} = propsRef.current;\n\n\t\t\t// Only run input rules when inserting text.\n\t\t\tif ( inputType !== 'insertText' && type !== 'compositionend' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( __unstableAllowPrefixTransformations && inputRule ) {\n\t\t\t\tinputRule();\n\t\t\t}\n\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumlator, { __unstableInputRule } ) => {\n\t\t\t\t\tif ( __unstableInputRule ) {\n\t\t\t\t\t\taccumlator = __unstableInputRule( accumlator );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumlator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\n\t\t\tif ( transformed !== value ) {\n\t\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\t\tonChange( {\n\t\t\t\t\t...transformed,\n\t\t\t\t\tactiveFormats: value.activeFormats,\n\t\t\t\t} );\n\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'input', onInput );\n\t\telement.addEventListener( 'compositionend', onInput );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'input', onInput );\n\t\t\telement.removeEventListener( 'compositionend', onInput );\n\t\t};\n\t}, [] );\n}\n"]}
@@ -11,8 +11,7 @@ import deprecated from '@wordpress/deprecated';
11
11
 
12
12
  export function MultiSelectScrollIntoView() {
13
13
  deprecated('wp.blockEditor.MultiSelectScrollIntoView', {
14
- hint: 'This behaviour is now built-in.',
15
- since: '5.8'
14
+ hint: 'This behaviour is now built-in.'
16
15
  });
17
16
  return null;
18
17
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/selection-scroll-into-view/index.js"],"names":["deprecated","MultiSelectScrollIntoView","hint","since"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,yBAAT,GAAqC;AAC3CD,EAAAA,UAAU,CAAE,0CAAF,EAA8C;AACvDE,IAAAA,IAAI,EAAE,iCADiD;AAEvDC,IAAAA,KAAK,EAAE;AAFgD,GAA9C,CAAV;AAIA,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Scrolls the multi block selection end into view if not in view already. This\n * is important to do after selection by keyboard.\n *\n * @deprecated\n */\nexport function MultiSelectScrollIntoView() {\n\tdeprecated( 'wp.blockEditor.MultiSelectScrollIntoView', {\n\t\thint: 'This behaviour is now built-in.',\n\t\tsince: '5.8',\n\t} );\n\treturn null;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/selection-scroll-into-view/index.js"],"names":["deprecated","MultiSelectScrollIntoView","hint"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,yBAAT,GAAqC;AAC3CD,EAAAA,UAAU,CAAE,0CAAF,EAA8C;AACvDE,IAAAA,IAAI,EAAE;AADiD,GAA9C,CAAV;AAGA,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Scrolls the multi block selection end into view if not in view already. This\n * is important to do after selection by keyboard.\n *\n * @deprecated\n */\nexport function MultiSelectScrollIntoView() {\n\tdeprecated( 'wp.blockEditor.MultiSelectScrollIntoView', {\n\t\thint: 'This behaviour is now built-in.',\n\t} );\n\treturn null;\n}\n"]}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { overEvery, findLast } from 'lodash';
5
+ /**
6
+ * WordPress dependencies
7
+ */
8
+
9
+ import { useRefEffect } from '@wordpress/compose';
10
+ import { focus, isTextField, placeCaretAtHorizontalEdge } from '@wordpress/dom';
11
+ /**
12
+ * Given an element, returns true if the element is a tabbable text field, or
13
+ * false otherwise.
14
+ *
15
+ * @param {Element} element Element to test.
16
+ *
17
+ * @return {boolean} Whether element is a tabbable text field.
18
+ */
19
+
20
+ const isTabbableTextField = overEvery([isTextField, focus.tabbable.isTabbableIndex]);
21
+ export function useCanvasClickRedirect() {
22
+ return useRefEffect(node => {
23
+ function onMouseDown(event) {
24
+ // Only handle clicks on the canvas, not the content.
25
+ if (event.target !== node) {
26
+ return;
27
+ }
28
+
29
+ const focusableNodes = focus.focusable.find(node);
30
+ const target = findLast(focusableNodes, isTabbableTextField);
31
+
32
+ if (!target) {
33
+ return;
34
+ }
35
+
36
+ const {
37
+ bottom
38
+ } = target.getBoundingClientRect(); // Ensure the click is below the last block.
39
+
40
+ if (event.clientY < bottom) {
41
+ return;
42
+ }
43
+
44
+ placeCaretAtHorizontalEdge(target, true);
45
+ event.preventDefault();
46
+ }
47
+
48
+ node.addEventListener('mousedown', onMouseDown);
49
+ return () => {
50
+ node.addEventListener('mousedown', onMouseDown);
51
+ };
52
+ }, []);
53
+ }
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-canvas-click-redirect/index.js"],"names":["overEvery","findLast","useRefEffect","focus","isTextField","placeCaretAtHorizontalEdge","isTabbableTextField","tabbable","isTabbableIndex","useCanvasClickRedirect","node","onMouseDown","event","target","focusableNodes","focusable","find","bottom","getBoundingClientRect","clientY","preventDefault","addEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,QAApB,QAAoC,QAApC;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,KAAT,EAAgBC,WAAhB,EAA6BC,0BAA7B,QAA+D,gBAA/D;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,mBAAmB,GAAGN,SAAS,CAAE,CACtCI,WADsC,EAEtCD,KAAK,CAACI,QAAN,CAAeC,eAFuB,CAAF,CAArC;AAKA,OAAO,SAASC,sBAAT,GAAkC;AACxC,SAAOP,YAAY,CAAIQ,IAAF,IAAY;AAChC,aAASC,WAAT,CAAsBC,KAAtB,EAA8B;AAC7B;AACA,UAAKA,KAAK,CAACC,MAAN,KAAiBH,IAAtB,EAA6B;AAC5B;AACA;;AAED,YAAMI,cAAc,GAAGX,KAAK,CAACY,SAAN,CAAgBC,IAAhB,CAAsBN,IAAtB,CAAvB;AACA,YAAMG,MAAM,GAAGZ,QAAQ,CAAEa,cAAF,EAAkBR,mBAAlB,CAAvB;;AAEA,UAAK,CAAEO,MAAP,EAAgB;AACf;AACA;;AAED,YAAM;AAAEI,QAAAA;AAAF,UAAaJ,MAAM,CAACK,qBAAP,EAAnB,CAb6B,CAe7B;;AACA,UAAKN,KAAK,CAACO,OAAN,GAAgBF,MAArB,EAA8B;AAC7B;AACA;;AAEDZ,MAAAA,0BAA0B,CAAEQ,MAAF,EAAU,IAAV,CAA1B;AACAD,MAAAA,KAAK,CAACQ,cAAN;AACA;;AAEDV,IAAAA,IAAI,CAACW,gBAAL,CAAuB,WAAvB,EAAoCV,WAApC;AAEA,WAAO,MAAM;AACZD,MAAAA,IAAI,CAACW,gBAAL,CAAuB,WAAvB,EAAoCV,WAApC;AACA,KAFD;AAGA,GA9BkB,EA8BhB,EA9BgB,CAAnB;AA+BA","sourcesContent":["/**\n * External dependencies\n */\nimport { overEvery, findLast } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { focus, isTextField, placeCaretAtHorizontalEdge } from '@wordpress/dom';\n\n/**\n * Given an element, returns true if the element is a tabbable text field, or\n * false otherwise.\n *\n * @param {Element} element Element to test.\n *\n * @return {boolean} Whether element is a tabbable text field.\n */\nconst isTabbableTextField = overEvery( [\n\tisTextField,\n\tfocus.tabbable.isTabbableIndex,\n] );\n\nexport function useCanvasClickRedirect() {\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onMouseDown( event ) {\n\t\t\t// Only handle clicks on the canvas, not the content.\n\t\t\tif ( event.target !== node ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst focusableNodes = focus.focusable.find( node );\n\t\t\tconst target = findLast( focusableNodes, isTabbableTextField );\n\n\t\t\tif ( ! target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { bottom } = target.getBoundingClientRect();\n\n\t\t\t// Ensure the click is below the last block.\n\t\t\tif ( event.clientY < bottom ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tplaceCaretAtHorizontalEdge( target, true );\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\n\t\treturn () => {\n\t\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\t\t};\n\t}, [] );\n}\n"]}
@@ -70,7 +70,7 @@ export function onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex,
70
70
 
71
71
 
72
72
  if (dropType === 'block') {
73
- const sourceBlockIndex = getBlockIndex(sourceClientIds[0], sourceRootClientId); // If the user is dropping to the same position, return early.
73
+ const sourceBlockIndex = getBlockIndex(sourceClientIds[0]); // If the user is dropping to the same position, return early.
74
74
 
75
75
  if (sourceRootClientId === targetRootClientId && sourceBlockIndex === targetBlockIndex) {
76
76
  return;
@@ -174,15 +174,11 @@ export default function useOnBlockDrop(targetRootClientId, targetBlockIndex) {
174
174
  return event => {
175
175
  const files = getFilesFromDataTransfer(event.dataTransfer);
176
176
  const html = event.dataTransfer.getData('text/html');
177
- /**
178
- * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.
179
- * The order of the checks is important to recognise the HTML drop.
180
- */
181
177
 
182
- if (html) {
183
- _onHTMLDrop(html);
184
- } else if (files.length) {
178
+ if (files.length) {
185
179
  _onFilesDrop(files);
180
+ } else if (html) {
181
+ _onHTMLDrop(html);
186
182
  } else {
187
183
  _onDrop(event);
188
184
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-on-block-drop/index.js"],"names":["cloneBlock","findTransform","getBlockTransforms","pasteHandler","useDispatch","useSelect","getFilesFromDataTransfer","store","blockEditorStore","parseDropEvent","event","result","srcRootClientId","srcClientIds","srcIndex","type","blocks","dataTransfer","Object","assign","JSON","parse","getData","err","onBlockDrop","targetRootClientId","targetBlockIndex","getBlockIndex","getClientIdsOfDescendants","moveBlocksToPosition","insertBlocks","clearSelectedBlock","sourceRootClientId","sourceClientIds","dropType","blocksToInsert","map","block","sourceBlockIndex","includes","some","id","isAtSameLevel","draggedBlockCount","length","insertIndex","onFilesDrop","hasUploadPermissions","updateBlockAttributes","canInsertBlockType","files","transformation","transform","blockName","isMatch","onHTMLDrop","HTML","mode","useOnBlockDrop","select","getSettings","mediaUpload","_onDrop","_onFilesDrop","_onHTMLDrop","html"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,UADD,EAECC,aAFD,EAGCC,kBAHD,EAICC,YAJD,QAKO,mBALP;AAMA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,wBAAT,QAAyC,gBAAzC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,cAAT,CAAyBC,KAAzB,EAAiC;AACvC,MAAIC,MAAM,GAAG;AACZC,IAAAA,eAAe,EAAE,IADL;AAEZC,IAAAA,YAAY,EAAE,IAFF;AAGZC,IAAAA,QAAQ,EAAE,IAHE;AAIZC,IAAAA,IAAI,EAAE,IAJM;AAKZC,IAAAA,MAAM,EAAE;AALI,GAAb;;AAQA,MAAK,CAAEN,KAAK,CAACO,YAAb,EAA4B;AAC3B,WAAON,MAAP;AACA;;AAED,MAAI;AACHA,IAAAA,MAAM,GAAGO,MAAM,CAACC,MAAP,CACRR,MADQ,EAERS,IAAI,CAACC,KAAL,CAAYX,KAAK,CAACO,YAAN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,CAAb;AAEA;AACF;AACA;AACA;;AACE,QAAK2C,IAAL,EAAY;AACXD,MAAAA,WAAW,CAAEC,IAAF,CAAX;AACA,KAFD,MAEO,IAAKf,KAAK,CAACN,MAAX,EAAoB;AAC1BmB,MAAAA,YAAY,CAAEb,KAAF,CAAZ;AACA,KAFM,MAEA;AACNY,MAAAA,OAAO,CAAEpD,KAAF,CAAP;AACA;AACD,GAfD;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcloneBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {WPSyntheticEvent} event The drop event.\n *\n * @return {Object} An object with block drag and drop data.\n */\nexport function parseDropEvent( event ) {\n\tlet result = {\n\t\tsrcRootClientId: null,\n\t\tsrcClientIds: null,\n\t\tsrcIndex: null,\n\t\ttype: null,\n\t\tblocks: null,\n\t};\n\n\tif ( ! event.dataTransfer ) {\n\t\treturn result;\n\t}\n\n\ttry {\n\t\tresult = Object.assign(\n\t\t\tresult,\n\t\t\tJSON.parse( event.dataTransfer.getData( 'wp-blocks' ) )\n\t\t);\n\t} catch ( err ) {\n\t\treturn result;\n\t}\n\n\treturn result;\n}\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocksToPosition A function that moves blocks.\n * @param {Function} insertBlocks A function that inserts blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocksToPosition,\n\tinsertBlocks,\n\tclearSelectedBlock\n) {\n\treturn ( event ) => {\n\t\tconst {\n\t\t\tsrcRootClientId: sourceRootClientId,\n\t\t\tsrcClientIds: sourceClientIds,\n\t\t\ttype: dropType,\n\t\t\tblocks,\n\t\t} = parseDropEvent( event );\n\n\t\t// If the user is inserting a block\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertBlocks(\n\t\t\t\tblocksToInsert,\n\t\t\t\ttargetBlockIndex,\n\t\t\t\ttargetRootClientId,\n\t\t\t\ttrue,\n\t\t\t\tnull\n\t\t\t);\n\t\t}\n\n\t\t// If the user is moving a block\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex(\n\t\t\t\tsourceClientIds[ 0 ],\n\t\t\t\tsourceRootClientId\n\t\t\t);\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocksToPosition(\n\t\t\t\tsourceClientIds,\n\t\t\t\tsourceRootClientId,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tinsertIndex\n\t\t\t);\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related file drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {boolean} hasUploadPermissions Whether the user has upload permissions.\n * @param {Function} updateBlockAttributes A function that updates a block's attributes.\n * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.\n * @param {Function} insertBlocks A function that inserts blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\thasUploadPermissions,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! hasUploadPermissions ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformation = findTransform(\n\t\t\tgetBlockTransforms( 'from' ),\n\t\t\t( transform ) =>\n\t\t\t\ttransform.type === 'files' &&\n\t\t\t\tcanInsertBlockType( transform.blockName, targetRootClientId ) &&\n\t\t\t\ttransform.isMatch( files )\n\t\t);\n\n\t\tif ( transformation ) {\n\t\t\tconst blocks = transformation.transform(\n\t\t\t\tfiles,\n\t\t\t\tupdateBlockAttributes\n\t\t\t);\n\t\t\tinsertBlocks( blocks, targetBlockIndex, targetRootClientId );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related HTML drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} insertBlocks A function that inserts blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tinsertBlocks\n) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertBlocks( blocks, targetBlockIndex, targetRootClientId );\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n *\n * @return {Object} An object that contains the event handlers `onDrop`, `onFilesDrop` and `onHTMLDrop`.\n */\nexport default function useOnBlockDrop( targetRootClientId, targetBlockIndex ) {\n\tconst hasUploadPermissions = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().mediaUpload,\n\t\t[]\n\t);\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t} = useDispatch( blockEditorStore );\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocksToPosition,\n\t\tinsertBlocks,\n\t\tclearSelectedBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\thasUploadPermissions,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tinsertBlocks\n\t);\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\t/**\n\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t */\n\t\tif ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else if ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-on-block-drop/index.js"],"names":["cloneBlock","findTransform","getBlockTransforms","pasteHandler","useDispatch","useSelect","getFilesFromDataTransfer","store","blockEditorStore","parseDropEvent","event","result","srcRootClientId","srcClientIds","srcIndex","type","blocks","dataTransfer","Object","assign","JSON","parse","getData","err","onBlockDrop","targetRootClientId","targetBlockIndex","getBlockIndex","getClientIdsOfDescendants","moveBlocksToPosition","insertBlocks","clearSelectedBlock","sourceRootClientId","sourceClientIds","dropType","blocksToInsert","map","block","sourceBlockIndex","includes","some","id","isAtSameLevel","draggedBlockCount","length","insertIndex","onFilesDrop","hasUploadPermissions","updateBlockAttributes","canInsertBlockType","files","transformation","transform","blockName","isMatch","onHTMLDrop","HTML","mode","useOnBlockDrop","select","getSettings","mediaUpload","_onDrop","_onFilesDrop","_onHTMLDrop","html"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,UADD,EAECC,aAFD,EAGCC,kBAHD,EAICC,YAJD,QAKO,mBALP;AAMA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,wBAAT,QAAyC,gBAAzC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,cAAT,CAAyBC,KAAzB,EAAiC;AACvC,MAAIC,MAAM,GAAG;AACZC,IAAAA,eAAe,EAAE,IADL;AAEZC,IAAAA,YAAY,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EAM/BnB,YAN+B,CAAhC;;AAQA,QAAMkC,WAAW,GAAGT,UAAU,CAC7B9B,kBAD6B,EAE7BC,gBAF6B,EAG7BI,YAH6B,CAA9B;;AAMA,SAASpB,KAAF,IAAa;AACnB,UAAMwC,KAAK,GAAG5C,wBAAwB,CAAEI,KAAK,CAACO,YAAR,CAAtC;AACA,UAAMgD,IAAI,GAAGvD,KAAK,CAACO,YAAN,CAAmBK,OAAnB,CAA4B,WAA5B,CAAb;;AAEA,QAAK4B,KAAK,CAACN,MAAX,EAAoB;AACnBmB,MAAAA,YAAY,CAAEb,KAAF,CAAZ;AACA,KAFD,MAEO,IAAKe,IAAL,EAAY;AAClBD,MAAAA,WAAW,CAAEC,IAAF,CAAX;AACA,KAFM,MAEA;AACNH,MAAAA,OAAO,CAAEpD,KAAF,CAAP;AACA;AACD,GAXD;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcloneBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {WPSyntheticEvent} event The drop event.\n *\n * @return {Object} An object with block drag and drop data.\n */\nexport function parseDropEvent( event ) {\n\tlet result = {\n\t\tsrcRootClientId: null,\n\t\tsrcClientIds: null,\n\t\tsrcIndex: null,\n\t\ttype: null,\n\t\tblocks: null,\n\t};\n\n\tif ( ! event.dataTransfer ) {\n\t\treturn result;\n\t}\n\n\ttry {\n\t\tresult = Object.assign(\n\t\t\tresult,\n\t\t\tJSON.parse( event.dataTransfer.getData( 'wp-blocks' ) )\n\t\t);\n\t} catch ( err ) {\n\t\treturn result;\n\t}\n\n\treturn result;\n}\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocksToPosition A function that moves blocks.\n * @param {Function} insertBlocks A function that inserts blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocksToPosition,\n\tinsertBlocks,\n\tclearSelectedBlock\n) {\n\treturn ( event ) => {\n\t\tconst {\n\t\t\tsrcRootClientId: sourceRootClientId,\n\t\t\tsrcClientIds: sourceClientIds,\n\t\t\ttype: dropType,\n\t\t\tblocks,\n\t\t} = parseDropEvent( event );\n\n\t\t// If the user is inserting a block\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertBlocks(\n\t\t\t\tblocksToInsert,\n\t\t\t\ttargetBlockIndex,\n\t\t\t\ttargetRootClientId,\n\t\t\t\ttrue,\n\t\t\t\tnull\n\t\t\t);\n\t\t}\n\n\t\t// If the user is moving a block\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocksToPosition(\n\t\t\t\tsourceClientIds,\n\t\t\t\tsourceRootClientId,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tinsertIndex\n\t\t\t);\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related file drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {boolean} hasUploadPermissions Whether the user has upload permissions.\n * @param {Function} updateBlockAttributes A function that updates a block's attributes.\n * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.\n * @param {Function} insertBlocks A function that inserts blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\thasUploadPermissions,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! hasUploadPermissions ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformation = findTransform(\n\t\t\tgetBlockTransforms( 'from' ),\n\t\t\t( transform ) =>\n\t\t\t\ttransform.type === 'files' &&\n\t\t\t\tcanInsertBlockType( transform.blockName, targetRootClientId ) &&\n\t\t\t\ttransform.isMatch( files )\n\t\t);\n\n\t\tif ( transformation ) {\n\t\t\tconst blocks = transformation.transform(\n\t\t\t\tfiles,\n\t\t\t\tupdateBlockAttributes\n\t\t\t);\n\t\t\tinsertBlocks( blocks, targetBlockIndex, targetRootClientId );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related HTML drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} insertBlocks A function that inserts blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tinsertBlocks\n) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertBlocks( blocks, targetBlockIndex, targetRootClientId );\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n *\n * @return {Object} An object that contains the event handlers `onDrop`, `onFilesDrop` and `onHTMLDrop`.\n */\nexport default function useOnBlockDrop( targetRootClientId, targetBlockIndex ) {\n\tconst hasUploadPermissions = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().mediaUpload,\n\t\t[]\n\t);\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t} = useDispatch( blockEditorStore );\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocksToPosition,\n\t\tinsertBlocks,\n\t\tclearSelectedBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\thasUploadPermissions,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tinsertBlocks\n\t);\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\tif ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else if ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"]}
@@ -14,6 +14,7 @@ import { __EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE } from '@wordpress/
14
14
 
15
15
  import { useBlockEditContext } from '../block-edit';
16
16
  import { store as blockEditorStore } from '../../store';
17
+ const blockedPaths = ['color', 'border', 'typography', 'spacing'];
17
18
  const deprecatedFlags = {
18
19
  'color.palette': settings => settings.colors === undefined ? undefined : settings.colors,
19
20
  'color.gradients': settings => settings.gradients === undefined ? undefined : settings.gradients,
@@ -94,6 +95,12 @@ export default function useSetting(path) {
94
95
  const setting = useSelect(select => {
95
96
  var _get;
96
97
 
98
+ if (blockedPaths.includes(path)) {
99
+ // eslint-disable-next-line no-console
100
+ console.warn('Top level useSetting paths are disabled. Please use a subpath to query the information needed.');
101
+ return undefined;
102
+ }
103
+
97
104
  const settings = select(blockEditorStore).getSettings(); // 1 - Use __experimental features, if available.
98
105
  // We cascade to the all value if the block one is not available.
99
106
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-setting/index.js"],"names":["get","useSelect","__EXPERIMENTAL_PATHS_WITH_MERGE","PATHS_WITH_MERGE","useBlockEditContext","store","blockEditorStore","deprecatedFlags","settings","colors","undefined","gradients","disableCustomColors","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","useSetting","name","blockName","setting","select","getSettings","normalizedPath","defaultsPath","blockPath","experimentalFeaturesResult","custom","theme","default","deprecatedSettingsValue"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,+BAA+B,IAAIC,gBAA5C,QAAoE,mBAApE;AAEA;AACA;AACA;;AACA,SAASC,mBAAT,QAAoC,eAApC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,MAAMC,eAAe,GAAG;AACvB,mBAAmBC,QAAF,IAChBA,QAAQ,CAACC,MAAT,KAAoBC,SAApB,GAAgCA,SAAhC,GAA4CF,QAAQ,CAACC,MAF/B;AAGvB,qBAAqBD,QAAF,IAClBA,QAAQ,CAACG,SAAT,KAAuBD,SAAvB,GAAmCA,SAAnC,GAA+CF,QAAQ,CAACG,SAJlC;AAKvB,kBAAkBH,QAAF,IACfA,QAAQ,CAACI,mBAAT,KAAiCF,SAAjC,GACGA,SADH,GAEG,CAAEF,QAAQ,CAACI,mBARQ;AASvB,0BAA0BJ,QAAF,IACvBA,QAAQ,CAACK,sBAAT,KAAoCH,SAApC,GACGA,SADH,GAEG,CAAEF,QAAQ,CAACK,sBAZQ;AAavB,0BAA0BL,QAAF,IACvBA,QAAQ,CAACM,SAAT,KAAuBJ,SAAvB,GAAmCA,SAAnC,GAA+CF,QAAQ,CAACM,SAdlC;AAevB,+BAA+BN,QAAF,IAC5BA,QAAQ,CAACO,sBAAT,KAAoCL,SAApC,GACGA,SADH,GAEG,CAAEF,QAAQ,CAACO,sBAlBQ;AAmBvB,2BAA2BP,QAAF,IAAgBA,QAAQ,CAACQ,sBAnB3B;AAoBvB,mBAAmBR,QAAF,IAAgB;AAChC,QAAKA,QAAQ,CAACS,iBAAT,KAA+BP,SAApC,EAAgD;AAC/C;AACA;;AAED,QAAKF,QAAQ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IAAII,cAAgB,EAAnF;AACA,UAAMG,0BAA0B,WAC/B/B,GAAG,CAAEQ,QAAF,EAAYsB,SAAZ,CAD4B,uCACD9B,GAAG,CAAEQ,QAAF,EAAYqB,YAAZ,CADlC;;AAGA,QAAKE,0BAA0B,KAAKrB,SAApC,EAAgD;AAC/C,UAAKP,gBAAgB,CAAEyB,cAAF,CAArB,EAA0C;AAAA;;AACzC,gDACCG,0BAA0B,CAACC,MAD5B,yEAECD,0BAA0B,CAACE,KAF5B,uCAGCF,0BAA0B,CAACG,OAH5B;AAKA;;AACD,aAAOH,0BAAP;AACA,KApBY,CAsBb;;;AACA,UAAMI,uBAAuB,GAAG5B,eAAe,CAAEqB,cAAF,CAAf,GAC7BrB,eAAe,CAAEqB,cAAF,CAAf,CAAmCpB,QAAnC,CAD6B,GAE7BE,SAFH;;AAGA,QAAKyB,uBAAuB,KAAKzB,SAAjC,EAA6C;AAC5C,aAAOyB,uBAAP;AACA,KA5BY,CA8Bb;AACA;AACA;AACA;;;AACA,WAAOP,cAAc,KAAK,oBAAnB,GAA0C,IAA1C,GAAiDlB,SAAxD;AACA,GApCuB,EAqCxB,CAAEc,SAAF,EAAaH,IAAb,CArCwB,CAAzB;AAwCA,SAAOI,OAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { store as blockEditorStore } from '../../store';\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) =>\n\t\tsettings.colors === undefined ? undefined : settings.colors,\n\t'color.gradients': ( settings ) =>\n\t\tsettings.gradients === undefined ? undefined : settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) =>\n\t\tsettings.fontSizes === undefined ? undefined : settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.padding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst prefixedFlags = {\n\t/*\n\t * These were only available in the plugin\n\t * and can be removed when the minimum WordPress version\n\t * for the plugin is 5.9.\n\t */\n\t'border.customColor': 'border.color',\n\t'border.customStyle': 'border.style',\n\t'border.customWidth': 'border.width',\n\t'typography.customFontStyle': 'typography.fontStyle',\n\t'typography.customFontWeight': 'typography.fontWeight',\n\t'typography.customLetterSpacing': 'typography.letterSpacing',\n\t'typography.customTextDecorations': 'typography.textDecoration',\n\t'typography.customTextTransforms': 'typography.textTransform',\n\t/*\n\t * These were part of WordPress 5.8 and we need to keep them.\n\t */\n\t'border.customRadius': 'border.radius',\n\t'spacing.customMargin': 'spacing.margin',\n\t'spacing.customPadding': 'spacing.padding',\n\t'typography.customLineHeight': 'typography.lineHeight',\n};\n\n/**\n * Remove `custom` prefixes for flags that did not land in 5.8.\n *\n * This provides continued support for `custom` prefixed properties. It will\n * be removed once third party devs have had sufficient time to update themes,\n * plugins, etc.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34485\n *\n * @param {string} path Path to desired value in settings.\n * @return {string} The value for defined setting.\n */\nconst removeCustomPrefixes = ( path ) => {\n\treturn prefixedFlags[ path ] || path;\n};\n\n/**\n * Hook that retrieves the editor setting.\n * It works with nested objects using by finding the value at path.\n *\n * @param {string} path The path to the setting.\n * @return {any} Returns the value defined for the setting.\n * @example\n * ```js\n * const isEnabled = useSetting( 'typography.dropCap' );\n * ```\n */\nexport default function useSetting( path ) {\n\tconst { name: blockName } = useBlockEditContext();\n\n\tconst setting = useSelect(\n\t\t( select ) => {\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\n\t\t\t// 1 - Use __experimental features, if available.\n\t\t\t// We cascade to the all value if the block one is not available.\n\t\t\tconst normalizedPath = removeCustomPrefixes( path );\n\t\t\tconst defaultsPath = `__experimentalFeatures.${ normalizedPath }`;\n\t\t\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;\n\t\t\tconst experimentalFeaturesResult =\n\t\t\t\tget( settings, blockPath ) ?? get( settings, defaultsPath );\n\n\t\t\tif ( experimentalFeaturesResult !== undefined ) {\n\t\t\t\tif ( PATHS_WITH_MERGE[ normalizedPath ] ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\texperimentalFeaturesResult.custom ??\n\t\t\t\t\t\texperimentalFeaturesResult.theme ??\n\t\t\t\t\t\texperimentalFeaturesResult.default\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn experimentalFeaturesResult;\n\t\t\t}\n\n\t\t\t// 2 - Use deprecated settings, otherwise.\n\t\t\tconst deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]\n\t\t\t\t? deprecatedFlags[ normalizedPath ]( settings )\n\t\t\t\t: undefined;\n\t\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\t\treturn deprecatedSettingsValue;\n\t\t\t}\n\n\t\t\t// 3 - Fall back for typography.dropCap:\n\t\t\t// This is only necessary to support typography.dropCap.\n\t\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t\t// To remove when __experimentalFeatures are ported to core.\n\t\t\treturn normalizedPath === 'typography.dropCap' ? true : undefined;\n\t\t},\n\t\t[ blockName, path ]\n\t);\n\n\treturn setting;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-setting/index.js"],"names":["get","useSelect","__EXPERIMENTAL_PATHS_WITH_MERGE","PATHS_WITH_MERGE","useBlockEditContext","store","blockEditorStore","blockedPaths","deprecatedFlags","settings","colors","undefined","gradients","disableCustomColors","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","useSetting","name","blockName","setting","select","includes","console","warn","getSettings","normalizedPath","defaultsPath","blockPath","experimentalFeaturesResult","custom","theme","default","deprecatedSettingsValue"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,+BAA+B,IAAIC,gBAA5C,QAAoE,mBAApE;AAEA;AACA;AACA;;AACA,SAASC,mBAAT,QAAoC,eAApC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,MAAMC,YAAY,GAAG,CAAE,OAAF,EAAW,QAAX,EAAqB,YAArB,EAAmC,SAAnC,CAArB;AAEA,MAAMC,eAAe,GAAG;AACvB,mBAAmBC,QAAF,IAChBA,QAAQ,CAACC,MAAT,KAAoBC,SAApB,GAAgCA,SAAhC,GAA4CF,QAAQ,CAACC,MAF/B;AAGvB,qBAAqBD,QAAF,IAClBA,QAAQ,CAACG,SAAT,KAAuBD,SAAvB,GAAmCA,SAAnC,GAA+CF,QAAQ,CAACG,SAJlC;AAKvB,kBAAkBH,QAAF,IACfA,QAAQ,CAACI,mBAAT,KAAiCF,SAAjC,GACGA,SADH,GAEG,CAAEF,QAAQ,CAACI,mBARQ;AASvB,0BAA0BJ,QAAF,IACvBA,QAAQ,CAACK,sBAAT,KAAoCH,SAApC,GACGA,SADH,GAEG,CAAEF,QAAQ,CAACK,sBAZQ;AAavB,0B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c,SAAF,EAAaH,IAAb,CA5CwB,CAAzB;AA+CA,SAAOI,OAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { store as blockEditorStore } from '../../store';\n\nconst blockedPaths = [ 'color', 'border', 'typography', 'spacing' ];\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) =>\n\t\tsettings.colors === undefined ? undefined : settings.colors,\n\t'color.gradients': ( settings ) =>\n\t\tsettings.gradients === undefined ? undefined : settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) =>\n\t\tsettings.fontSizes === undefined ? undefined : settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.padding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst prefixedFlags = {\n\t/*\n\t * These were only available in the plugin\n\t * and can be removed when the minimum WordPress version\n\t * for the plugin is 5.9.\n\t */\n\t'border.customColor': 'border.color',\n\t'border.customStyle': 'border.style',\n\t'border.customWidth': 'border.width',\n\t'typography.customFontStyle': 'typography.fontStyle',\n\t'typography.customFontWeight': 'typography.fontWeight',\n\t'typography.customLetterSpacing': 'typography.letterSpacing',\n\t'typography.customTextDecorations': 'typography.textDecoration',\n\t'typography.customTextTransforms': 'typography.textTransform',\n\t/*\n\t * These were part of WordPress 5.8 and we need to keep them.\n\t */\n\t'border.customRadius': 'border.radius',\n\t'spacing.customMargin': 'spacing.margin',\n\t'spacing.customPadding': 'spacing.padding',\n\t'typography.customLineHeight': 'typography.lineHeight',\n};\n\n/**\n * Remove `custom` prefixes for flags that did not land in 5.8.\n *\n * This provides continued support for `custom` prefixed properties. It will\n * be removed once third party devs have had sufficient time to update themes,\n * plugins, etc.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34485\n *\n * @param {string} path Path to desired value in settings.\n * @return {string} The value for defined setting.\n */\nconst removeCustomPrefixes = ( path ) => {\n\treturn prefixedFlags[ path ] || path;\n};\n\n/**\n * Hook that retrieves the editor setting.\n * It works with nested objects using by finding the value at path.\n *\n * @param {string} path The path to the setting.\n * @return {any} Returns the value defined for the setting.\n * @example\n * ```js\n * const isEnabled = useSetting( 'typography.dropCap' );\n * ```\n */\nexport default function useSetting( path ) {\n\tconst { name: blockName } = useBlockEditContext();\n\n\tconst setting = useSelect(\n\t\t( select ) => {\n\t\t\tif ( blockedPaths.includes( path ) ) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'Top level useSetting paths are disabled. Please use a subpath to query the information needed.'\n\t\t\t\t);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\n\t\t\t// 1 - Use __experimental features, if available.\n\t\t\t// We cascade to the all value if the block one is not available.\n\t\t\tconst normalizedPath = removeCustomPrefixes( path );\n\t\t\tconst defaultsPath = `__experimentalFeatures.${ normalizedPath }`;\n\t\t\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;\n\t\t\tconst experimentalFeaturesResult =\n\t\t\t\tget( settings, blockPath ) ?? get( settings, defaultsPath );\n\n\t\t\tif ( experimentalFeaturesResult !== undefined ) {\n\t\t\t\tif ( PATHS_WITH_MERGE[ normalizedPath ] ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\texperimentalFeaturesResult.custom ??\n\t\t\t\t\t\texperimentalFeaturesResult.theme ??\n\t\t\t\t\t\texperimentalFeaturesResult.default\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn experimentalFeaturesResult;\n\t\t\t}\n\n\t\t\t// 2 - Use deprecated settings, otherwise.\n\t\t\tconst deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]\n\t\t\t\t? deprecatedFlags[ normalizedPath ]( settings )\n\t\t\t\t: undefined;\n\t\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\t\treturn deprecatedSettingsValue;\n\t\t\t}\n\n\t\t\t// 3 - Fall back for typography.dropCap:\n\t\t\t// This is only necessary to support typography.dropCap.\n\t\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t\t// To remove when __experimentalFeatures are ported to core.\n\t\t\treturn normalizedPath === 'typography.dropCap' ? true : undefined;\n\t\t},\n\t\t[ blockName, path ]\n\t);\n\n\treturn setting;\n}\n"]}
@@ -14,9 +14,9 @@ import { useSelect } from '@wordpress/data';
14
14
 
15
15
  import { store as blockEditorStore } from '../../store';
16
16
  import { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';
17
- export function toggleRichText(container, toggle) {
18
- Array.from(container.querySelectorAll( // Exclude the Post Title from multi-select disable.
19
- '.rich-text:not( .editor-post-title__input )')).forEach(node => {
17
+
18
+ function toggleRichText(container, toggle) {
19
+ Array.from(container.querySelectorAll('.rich-text')).forEach(node => {
20
20
  if (toggle) {
21
21
  node.setAttribute('contenteditable', true);
22
22
  } else {
@@ -32,6 +32,7 @@ export function toggleRichText(container, toggle) {
32
32
  * @param {string} type 'start' or 'end'.
33
33
  */
34
34
 
35
+
35
36
  function getDeepestNode(node, type) {
36
37
  const child = type === 'start' ? 'firstChild' : 'lastChild';
37
38
  const sibling = type === 'start' ? 'nextSibling' : 'previousSibling';
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-multi-selection.js"],"names":["first","last","useRefEffect","useSelect","store","blockEditorStore","__unstableUseBlockRef","useBlockRef","toggleRichText","container","toggle","Array","from","querySelectorAll","forEach","node","setAttribute","removeAttribute","getDeepestNode","type","child","sibling","nodeType","TEXT_NODE","test","data","selector","select","isMultiSelecting","getMultiSelectedBlockClientIds","hasMultiSelection","getSelectedBlockClientId","multiSelectedBlockClientIds","selectedBlockClientId","useMultiSelection","selectedRef","startRef","endRef","ownerDocument","defaultView","selection","getSelection","rangeCount","isCollapsed","blockNode","current","startContainer","endContainer","getRangeAt","contains","removeAllRanges","length","focus","range","createRange","startNode","endNode","setStartBefore","setEndAfter","addRange"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,EAAgBC,IAAhB,QAA4B,QAA5B;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,qBAAqB,IAAIC,WAAlC,QAAqD,8CAArD;AAEA,OAAO,SAASC,cAAT,CAAyBC,SAAzB,EAAoCC,MAApC,EAA6C;AACnDC,EAAAA,KAAK,CAACC,IAAN,CACCH,SAAS,CAACI,gBAAV,EACC;AACA,+CAFD,CADD,EAKEC,OALF,CAKaC,IAAF,IAAY;AACtB,QAAKL,MAAL,EAAc;AACbK,MAAAA,IAAI,CAACC,YAAL,CAAmB,iBAAnB,EAAsC,IAAtC;AACA,KAFD,MAEO;AACND,MAAAA,IAAI,CAACE,eAAL,CAAsB,iBAAtB;AACA;AACD,GAXD;AAYA;AAED;AACA;AACA;AACA;AACA;AACA;A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GrC,cAAc,CAAEkB,QAAQ,CAACS,OAAX,EAAoB,OAApB,CAAhC;AACA,UAAMW,OAAO,GAAGtC,cAAc,CAAEmB,MAAM,CAACQ,OAAT,EAAkB,KAAlB,CAA9B,CArDW,CAuDX;AACA;AACA;;AACArC,IAAAA,cAAc,CAAEO,IAAF,EAAQ,KAAR,CAAd;AAEAsC,IAAAA,KAAK,CAACI,cAAN,CAAsBF,SAAtB;AACAF,IAAAA,KAAK,CAACK,WAAN,CAAmBF,OAAnB;AAEAhB,IAAAA,SAAS,CAACU,eAAV;AACAV,IAAAA,SAAS,CAACmB,QAAV,CAAoBN,KAApB;AACA,GAlEiB,EAmElB,CACCvB,iBADD,EAECF,gBAFD,EAGCI,2BAHD,EAICC,qBAJD,CAnEkB,CAAnB;AA0EA","sourcesContent":["/**\n * External dependencies\n */\nimport { first, last } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';\n\nexport function toggleRichText( container, toggle ) {\n\tArray.from(\n\t\tcontainer.querySelectorAll(\n\t\t\t// Exclude the Post Title from multi-select disable.\n\t\t\t'.rich-text:not( .editor-post-title__input )'\n\t\t)\n\t).forEach( ( node ) => {\n\t\tif ( toggle ) {\n\t\t\tnode.setAttribute( 'contenteditable', true );\n\t\t} else {\n\t\t\tnode.removeAttribute( 'contenteditable' );\n\t\t}\n\t} );\n}\n\n/**\n * Returns for the deepest node at the start or end of a container node. Ignores\n * any text nodes that only contain HTML formatting whitespace.\n *\n * @param {Element} node Container to search.\n * @param {string} type 'start' or 'end'.\n */\nfunction getDeepestNode( node, type ) {\n\tconst child = type === 'start' ? 'firstChild' : 'lastChild';\n\tconst sibling = type === 'start' ? 'nextSibling' : 'previousSibling';\n\n\twhile ( node[ child ] ) {\n\t\tnode = node[ child ];\n\n\t\twhile (\n\t\t\tnode.nodeType === node.TEXT_NODE &&\n\t\t\t/^[ \\t\\n]*$/.test( node.data ) &&\n\t\t\tnode[ sibling ]\n\t\t) {\n\t\t\tnode = node[ sibling ];\n\t\t}\n\t}\n\n\treturn node;\n}\n\nfunction selector( select ) {\n\tconst {\n\t\tisMultiSelecting,\n\t\tgetMultiSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\n\treturn {\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tmultiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),\n\t\thasMultiSelection: hasMultiSelection(),\n\t\tselectedBlockClientId: getSelectedBlockClientId(),\n\t};\n}\n\nexport default function useMultiSelection() {\n\tconst {\n\t\tisMultiSelecting,\n\t\tmultiSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tselectedBlockClientId,\n\t} = useSelect( selector, [] );\n\tconst selectedRef = useBlockRef( selectedBlockClientId );\n\t// These must be in the right DOM order.\n\tconst startRef = useBlockRef( first( multiSelectedBlockClientIds ) );\n\tconst endRef = useBlockRef( last( multiSelectedBlockClientIds ) );\n\n\t/**\n\t * When the component updates, and there is multi selection, we need to\n\t * select the entire block contents.\n\t */\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tif ( ! hasMultiSelection || isMultiSelecting ) {\n\t\t\t\tif ( ! selectedBlockClientId || isMultiSelecting ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( selection.rangeCount && ! selection.isCollapsed ) {\n\t\t\t\t\tconst blockNode = selectedRef.current;\n\t\t\t\t\tconst {\n\t\t\t\t\t\tstartContainer,\n\t\t\t\t\t\tendContainer,\n\t\t\t\t\t} = selection.getRangeAt( 0 );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t!! blockNode &&\n\t\t\t\t\t\t( ! blockNode.contains( startContainer ) ||\n\t\t\t\t\t\t\t! blockNode.contains( endContainer ) )\n\t\t\t\t\t) {\n\t\t\t\t\t\tselection.removeAllRanges();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { length } = multiSelectedBlockClientIds;\n\n\t\t\tif ( length < 2 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// The block refs might not be immediately available\n\t\t\t// when dragging blocks into another block.\n\t\t\tif ( ! startRef.current || ! endRef.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// For some browsers, like Safari, it is important that focus happens\n\t\t\t// BEFORE selection.\n\t\t\tnode.focus();\n\n\t\t\tconst selection = defaultView.getSelection();\n\t\t\tconst range = ownerDocument.createRange();\n\n\t\t\t// These must be in the right DOM order.\n\t\t\t// The most stable way to select the whole block contents is to start\n\t\t\t// and end at the deepest points.\n\t\t\tconst startNode = getDeepestNode( startRef.current, 'start' );\n\t\t\tconst endNode = getDeepestNode( endRef.current, 'end' );\n\n\t\t\t// While rich text will be disabled with a delay when there is a multi\n\t\t\t// selection, we must do it immediately because it's not possible to set\n\t\t\t// selection across editable hosts.\n\t\t\ttoggleRichText( node, false );\n\n\t\t\trange.setStartBefore( startNode );\n\t\t\trange.setEndAfter( endNode );\n\n\t\t\tselection.removeAllRanges();\n\t\t\tselection.addRange( range );\n\t\t},\n\t\t[\n\t\t\thasMultiSelection,\n\t\t\tisMultiSelecting,\n\t\t\tmultiSelectedBlockClientIds,\n\t\t\tselectedBlockClientId,\n\t\t]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-multi-selection.js"],"names":["first","last","useRefEffect","useSelect","store","blockEditorStore","__unstableUseBlockRef","useBlockRef","toggleRichText","container","toggle","Array","from","querySelectorAll","forEach","node","setAttribute","removeAttribute","getDeepestNode","type","child","sibling","nodeType","TEXT_NODE","test","data","selector","select","isMultiSelecting","getMultiSelectedBlockClientIds","hasMultiSelection","getSelectedBlockClientId","multiSelectedBlockClientIds","selectedBlockClientId","useMultiSelection","selectedRef","startRef","endRef","ownerDocument","defaultView","selection","getSelection","rangeCount","isCollapsed","blockNode","current","startContainer","endContainer","getRangeAt","contains","removeAllRanges","length","focus","range","createRange","startNode","endNode","setStartBefore","setEndAfter","addRange"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,EAAgBC,IAAhB,QAA4B,QAA5B;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,qBAAqB,IAAIC,WAAlC,QAAqD,8CAArD;;AAEA,SAASC,cAAT,CAAyBC,SAAzB,EAAoCC,MAApC,EAA6C;AAC5CC,EAAAA,KAAK,CAACC,IAAN,CAAYH,SAAS,CAACI,gBAAV,CAA4B,YAA5B,CAAZ,EAAyDC,OAAzD,CACGC,IAAF,IAAY;AACX,QAAKL,MAAL,EAAc;AACbK,MAAAA,IAAI,CAACC,YAAL,CAAmB,iBAAnB,EAAsC,IAAtC;AACA,KAFD,MAEO;AACND,MAAAA,IAAI,CAACE,eAAL,CAAsB,iBAAtB;AACA;AACD,GAPF;AASA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,cAAT,CAAyBH,IAAzB,EAA+BI,IAA/B,EAAsC;AACrC,QAAMC,KAAK,GAAGD,IAAI,KAAK,OAAT,GAAmB,YAAnB,GAAkC,WAAhD;AACA,QAAME,OAAO,GAAGF,IAAI,KAAK,OAAT,GAAmB,aAAnB,GAAmC,iBAAnD;;AAEA,SAAQJ,IAAI,CAAEK,KAAF,CAAZ,EAAwB;AACvBL,IAAAA,IAAI,GAAGA,IAAI,CAAEK,KAAF,CAAX;;AAEA,WACCL,IAAI,CAACO,QAAL,KAAkBP,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ACAV,IAAAA,SAAS,CAACmB,QAAV,CAAoBN,KAApB;AACA,GAlEiB,EAmElB,CACCvB,iBADD,EAECF,gBAFD,EAGCI,2BAHD,EAICC,qBAJD,CAnEkB,CAAnB;AA0EA","sourcesContent":["/**\n * External dependencies\n */\nimport { first, last } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';\n\nfunction toggleRichText( container, toggle ) {\n\tArray.from( container.querySelectorAll( '.rich-text' ) ).forEach(\n\t\t( node ) => {\n\t\t\tif ( toggle ) {\n\t\t\t\tnode.setAttribute( 'contenteditable', true );\n\t\t\t} else {\n\t\t\t\tnode.removeAttribute( 'contenteditable' );\n\t\t\t}\n\t\t}\n\t);\n}\n\n/**\n * Returns for the deepest node at the start or end of a container node. Ignores\n * any text nodes that only contain HTML formatting whitespace.\n *\n * @param {Element} node Container to search.\n * @param {string} type 'start' or 'end'.\n */\nfunction getDeepestNode( node, type ) {\n\tconst child = type === 'start' ? 'firstChild' : 'lastChild';\n\tconst sibling = type === 'start' ? 'nextSibling' : 'previousSibling';\n\n\twhile ( node[ child ] ) {\n\t\tnode = node[ child ];\n\n\t\twhile (\n\t\t\tnode.nodeType === node.TEXT_NODE &&\n\t\t\t/^[ \\t\\n]*$/.test( node.data ) &&\n\t\t\tnode[ sibling ]\n\t\t) {\n\t\t\tnode = node[ sibling ];\n\t\t}\n\t}\n\n\treturn node;\n}\n\nfunction selector( select ) {\n\tconst {\n\t\tisMultiSelecting,\n\t\tgetMultiSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\n\treturn {\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tmultiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),\n\t\thasMultiSelection: hasMultiSelection(),\n\t\tselectedBlockClientId: getSelectedBlockClientId(),\n\t};\n}\n\nexport default function useMultiSelection() {\n\tconst {\n\t\tisMultiSelecting,\n\t\tmultiSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tselectedBlockClientId,\n\t} = useSelect( selector, [] );\n\tconst selectedRef = useBlockRef( selectedBlockClientId );\n\t// These must be in the right DOM order.\n\tconst startRef = useBlockRef( first( multiSelectedBlockClientIds ) );\n\tconst endRef = useBlockRef( last( multiSelectedBlockClientIds ) );\n\n\t/**\n\t * When the component updates, and there is multi selection, we need to\n\t * select the entire block contents.\n\t */\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tif ( ! hasMultiSelection || isMultiSelecting ) {\n\t\t\t\tif ( ! selectedBlockClientId || isMultiSelecting ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( selection.rangeCount && ! selection.isCollapsed ) {\n\t\t\t\t\tconst blockNode = selectedRef.current;\n\t\t\t\t\tconst {\n\t\t\t\t\t\tstartContainer,\n\t\t\t\t\t\tendContainer,\n\t\t\t\t\t} = selection.getRangeAt( 0 );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t!! blockNode &&\n\t\t\t\t\t\t( ! blockNode.contains( startContainer ) ||\n\t\t\t\t\t\t\t! blockNode.contains( endContainer ) )\n\t\t\t\t\t) {\n\t\t\t\t\t\tselection.removeAllRanges();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { length } = multiSelectedBlockClientIds;\n\n\t\t\tif ( length < 2 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// The block refs might not be immediately available\n\t\t\t// when dragging blocks into another block.\n\t\t\tif ( ! startRef.current || ! endRef.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// For some browsers, like Safari, it is important that focus happens\n\t\t\t// BEFORE selection.\n\t\t\tnode.focus();\n\n\t\t\tconst selection = defaultView.getSelection();\n\t\t\tconst range = ownerDocument.createRange();\n\n\t\t\t// These must be in the right DOM order.\n\t\t\t// The most stable way to select the whole block contents is to start\n\t\t\t// and end at the deepest points.\n\t\t\tconst startNode = getDeepestNode( startRef.current, 'start' );\n\t\t\tconst endNode = getDeepestNode( endRef.current, 'end' );\n\n\t\t\t// While rich text will be disabled with a delay when there is a multi\n\t\t\t// selection, we must do it immediately because it's not possible to set\n\t\t\t// selection across editable hosts.\n\t\t\ttoggleRichText( node, false );\n\n\t\t\trange.setStartBefore( startNode );\n\t\t\trange.setEndAfter( endNode );\n\n\t\t\tselection.removeAllRanges();\n\t\t\tselection.addRange( range );\n\t\t},\n\t\t[\n\t\t\thasMultiSelection,\n\t\t\tisMultiSelecting,\n\t\t\tmultiSelectedBlockClientIds,\n\t\t\tselectedBlockClientId,\n\t\t]\n\t);\n}\n"]}
@@ -12,7 +12,7 @@ import classnames from 'classnames';
12
12
  import { addFilter } from '@wordpress/hooks';
13
13
  import { __ } from '@wordpress/i18n';
14
14
  import { createHigherOrderComponent } from '@wordpress/compose';
15
- import { useEffect, useState } from '@wordpress/element';
15
+ import { useState } from '@wordpress/element';
16
16
  /**
17
17
  * Internal dependencies
18
18
  */
@@ -21,7 +21,7 @@ import ColorGradientControl from '../components/colors-gradients/control';
21
21
  import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
22
22
  import { getColorClassName, getColorObjectByColorValue, getColorObjectByAttributeValues } from '../components/colors';
23
23
  import useSetting from '../components/use-setting';
24
- import { hasBorderSupport, removeBorderAttribute, shouldSkipSerialization } from './border';
24
+ import { hasBorderSupport, shouldSkipSerialization } from './border';
25
25
  import { cleanEmptyObject } from './utils'; // Defining empty array here instead of inline avoids unnecessary re-renders of
26
26
  // color control.
27
27
 
@@ -50,23 +50,11 @@ export function BorderColorEdit(props) {
50
50
  } = props;
51
51
  const colorGradientSettings = useMultipleOriginColorsAndGradients();
52
52
  const availableColors = colorGradientSettings.colors.reduce((colors, origin) => colors.concat(origin.colors), []);
53
- const {
54
- color: customBorderColor
55
- } = (style === null || style === void 0 ? void 0 : style.border) || {};
56
53
  const [colorValue, setColorValue] = useState(() => {
57
- var _getColorObjectByAttr;
58
-
59
- return (_getColorObjectByAttr = getColorObjectByAttributeValues(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color;
60
- }); // Detect changes in the color attributes and update the colorValue to keep the
61
- // UI in sync. This is necessary for situations when border controls interact with
62
- // eachother: eg, setting the border width to zero causes the color and style
63
- // selections to be cleared.
54
+ var _getColorObjectByAttr, _style$border;
64
55
 
65
- useEffect(() => {
66
- var _getColorObjectByAttr2;
67
-
68
- setColorValue((_getColorObjectByAttr2 = getColorObjectByAttributeValues(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color);
69
- }, [borderColor, customBorderColor, availableColors]);
56
+ return (_getColorObjectByAttr = getColorObjectByAttributeValues(availableColors, borderColor, style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.color)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color;
57
+ });
70
58
 
71
59
  const onChangeColor = value => {
72
60
  setColorValue(value);
@@ -93,48 +81,6 @@ export function BorderColorEdit(props) {
93
81
  __experimentalIsRenderedInSidebar: true
94
82
  }, colorGradientSettings));
95
83
  }
96
- /**
97
- * Checks if there is a current value in the border color block support
98
- * attributes.
99
- *
100
- * @param {Object} props Block props.
101
- * @return {boolean} Whether or not the block has a border color value set.
102
- */
103
-
104
- export function hasBorderColorValue(props) {
105
- var _style$border;
106
-
107
- const {
108
- attributes: {
109
- borderColor,
110
- style
111
- }
112
- } = props;
113
- return !!borderColor || !!(style !== null && style !== void 0 && (_style$border = style.border) !== null && _style$border !== void 0 && _style$border.color);
114
- }
115
- /**
116
- * Resets the border color block support attributes. This can be used when
117
- * disabling the border color support controls for a block via a progressive
118
- * discovery panel.
119
- *
120
- * @param {Object} props Block props.
121
- * @param {Object} props.attributes Block's attributes.
122
- * @param {Object} props.setAttributes Function to set block's attributes.
123
- */
124
-
125
- export function resetBorderColor(_ref) {
126
- let {
127
- attributes = {},
128
- setAttributes
129
- } = _ref;
130
- const {
131
- style
132
- } = attributes;
133
- setAttributes({
134
- borderColor: undefined,
135
- style: removeBorderAttribute(style, 'color')
136
- });
137
- }
138
84
  /**
139
85
  * Filters registered block settings, extending attributes to include
140
86
  * `borderColor` if needed.
@@ -235,7 +181,7 @@ function addEditProps(settings) {
235
181
 
236
182
 
237
183
  export const withBorderColorPaletteStyles = createHigherOrderComponent(BlockListBlock => props => {
238
- var _getColorObjectByAttr3, _props$wrapperProps;
184
+ var _getColorObjectByAttr2, _props$wrapperProps;
239
185
 
240
186
  const {
241
187
  name,
@@ -251,7 +197,7 @@ export const withBorderColorPaletteStyles = createHigherOrderComponent(BlockList
251
197
  }
252
198
 
253
199
  const extraStyles = {
254
- borderColor: borderColor ? (_getColorObjectByAttr3 = getColorObjectByAttributeValues(colors, borderColor)) === null || _getColorObjectByAttr3 === void 0 ? void 0 : _getColorObjectByAttr3.color : undefined
200
+ borderColor: borderColor ? (_getColorObjectByAttr2 = getColorObjectByAttributeValues(colors, borderColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color : undefined
255
201
  };
256
202
  let wrapperProps = props.wrapperProps;
257
203
  wrapperProps = { ...props.wrapperProps,