@wordpress/block-editor 8.6.0 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (466) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +5 -2
  3. package/build/components/block-alignment-control/constants.js +48 -0
  4. package/build/components/block-alignment-control/constants.js.map +1 -0
  5. package/build/components/block-alignment-control/ui.js +9 -40
  6. package/build/components/block-alignment-control/ui.js.map +1 -1
  7. package/build/components/block-alignment-control/ui.native.js +92 -0
  8. package/build/components/block-alignment-control/ui.native.js.map +1 -0
  9. package/build/components/block-alignment-matrix-control/index.js +1 -6
  10. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  11. package/build/components/block-content-overlay/index.js +4 -82
  12. package/build/components/block-content-overlay/index.js.map +1 -1
  13. package/build/components/block-draggable/draggable-chip.native.js +65 -0
  14. package/build/components/block-draggable/draggable-chip.native.js.map +1 -0
  15. package/build/components/block-draggable/dropping-insertion-point.native.js +157 -0
  16. package/build/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
  17. package/build/components/block-draggable/index.native.js +488 -0
  18. package/build/components/block-draggable/index.native.js.map +1 -0
  19. package/build/components/block-draggable/use-scroll-when-dragging.native.js +130 -0
  20. package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
  21. package/build/components/block-list/block-list-context.native.js +195 -0
  22. package/build/components/block-list/block-list-context.native.js.map +1 -0
  23. package/build/components/block-list/block-list-item-cell.native.js +67 -0
  24. package/build/components/block-list/block-list-item-cell.native.js.map +1 -0
  25. package/build/components/block-list/block-list-item.native.js +12 -9
  26. package/build/components/block-list/block-list-item.native.js.map +1 -1
  27. package/build/components/block-list/block.native.js +27 -5
  28. package/build/components/block-list/block.native.js.map +1 -1
  29. package/build/components/block-list/index.js +34 -32
  30. package/build/components/block-list/index.js.map +1 -1
  31. package/build/components/block-list/index.native.js +75 -23
  32. package/build/components/block-list/index.native.js.map +1 -1
  33. package/build/components/block-list/use-block-props/index.js +8 -4
  34. package/build/components/block-list/use-block-props/index.js.map +1 -1
  35. package/build/components/block-list/use-block-props/use-block-class-names.js +1 -7
  36. package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  37. package/build/components/block-list/use-in-between-inserter.js +1 -1
  38. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  39. package/build/components/block-mobile-toolbar/index.native.js +10 -3
  40. package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
  41. package/build/components/block-mover/index.native.js +17 -4
  42. package/build/components/block-mover/index.native.js.map +1 -1
  43. package/build/components/block-navigation/dropdown.js +11 -5
  44. package/build/components/block-navigation/dropdown.js.map +1 -1
  45. package/build/components/block-popover/inbetween.js +19 -8
  46. package/build/components/block-popover/inbetween.js.map +1 -1
  47. package/build/components/block-popover/index.js +20 -16
  48. package/build/components/block-popover/index.js.map +1 -1
  49. package/build/components/block-preview/index.js +1 -1
  50. package/build/components/block-preview/index.js.map +1 -1
  51. package/build/components/block-tools/block-selection-button.js +1 -0
  52. package/build/components/block-tools/block-selection-button.js.map +1 -1
  53. package/build/components/block-tools/selected-block-popover.js +1 -29
  54. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  55. package/build/components/block-variation-transforms/index.js +16 -2
  56. package/build/components/block-variation-transforms/index.js.map +1 -1
  57. package/build/components/border-radius-control/input-controls.js +10 -3
  58. package/build/components/border-radius-control/input-controls.js.map +1 -1
  59. package/build/components/color-style-selector/index.js +9 -0
  60. package/build/components/color-style-selector/index.js.map +1 -1
  61. package/build/components/colors-gradients/dropdown.js +122 -41
  62. package/build/components/colors-gradients/dropdown.js.map +1 -1
  63. package/build/components/colors-gradients/panel-color-gradient-settings.js +35 -60
  64. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  65. package/build/components/convert-to-group-buttons/toolbar.js +22 -5
  66. package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
  67. package/build/components/iframe/index.js +51 -50
  68. package/build/components/iframe/index.js.map +1 -1
  69. package/build/components/image-editor/use-save-image.js +3 -1
  70. package/build/components/image-editor/use-save-image.js.map +1 -1
  71. package/build/components/index.js +14 -23
  72. package/build/components/index.js.map +1 -1
  73. package/build/components/inserter/index.js +21 -7
  74. package/build/components/inserter/index.js.map +1 -1
  75. package/build/components/inserter/index.native.js +2 -2
  76. package/build/components/inserter/index.native.js.map +1 -1
  77. package/build/components/inserter/quick-inserter.js +4 -5
  78. package/build/components/inserter/quick-inserter.js.map +1 -1
  79. package/build/components/link-control/constants.js +11 -1
  80. package/build/components/link-control/constants.js.map +1 -1
  81. package/build/components/link-control/search-results.js +4 -3
  82. package/build/components/link-control/search-results.js.map +1 -1
  83. package/build/components/link-control/use-search-handler.js +4 -4
  84. package/build/components/link-control/use-search-handler.js.map +1 -1
  85. package/build/components/list-view/block.js +15 -15
  86. package/build/components/list-view/block.js.map +1 -1
  87. package/build/components/list-view/branch.js +9 -13
  88. package/build/components/list-view/branch.js.map +1 -1
  89. package/build/components/list-view/context.js +1 -4
  90. package/build/components/list-view/context.js.map +1 -1
  91. package/build/components/list-view/drop-indicator.js +0 -1
  92. package/build/components/list-view/drop-indicator.js.map +1 -1
  93. package/build/components/list-view/index.js +15 -32
  94. package/build/components/list-view/index.js.map +1 -1
  95. package/build/components/media-placeholder/index.js +0 -2
  96. package/build/components/media-placeholder/index.js.map +1 -1
  97. package/build/components/media-replace-flow/index.js +0 -2
  98. package/build/components/media-replace-flow/index.js.map +1 -1
  99. package/build/components/media-upload/index.native.js +10 -4
  100. package/build/components/media-upload/index.native.js.map +1 -1
  101. package/build/components/navigable-toolbar/index.js +12 -2
  102. package/build/components/navigable-toolbar/index.js.map +1 -1
  103. package/build/components/plain-text/index.native.js +62 -7
  104. package/build/components/plain-text/index.native.js.map +1 -1
  105. package/build/components/publish-date-time-picker/index.js +55 -0
  106. package/build/components/publish-date-time-picker/index.js.map +1 -0
  107. package/build/components/rich-text/format-toolbar-container.js +0 -1
  108. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  109. package/build/components/rich-text/index.js +2 -2
  110. package/build/components/rich-text/index.js.map +1 -1
  111. package/build/components/rich-text/index.native.js +5 -1
  112. package/build/components/rich-text/index.native.js.map +1 -1
  113. package/build/components/url-input/index.js +11 -4
  114. package/build/components/url-input/index.js.map +1 -1
  115. package/build/components/use-block-drop-zone/index.native.js +167 -0
  116. package/build/components/use-block-drop-zone/index.native.js.map +1 -0
  117. package/build/components/use-on-block-drop/index.native.js +95 -0
  118. package/build/components/use-on-block-drop/index.native.js.map +1 -0
  119. package/build/components/use-setting/index.js +42 -18
  120. package/build/components/use-setting/index.js.map +1 -1
  121. package/build/components/warning/index.js +6 -1
  122. package/build/components/warning/index.js.map +1 -1
  123. package/build/components/writing-flow/use-click-selection.js +1 -3
  124. package/build/components/writing-flow/use-click-selection.js.map +1 -1
  125. package/build/components/writing-flow/use-input.js +15 -0
  126. package/build/components/writing-flow/use-input.js.map +1 -1
  127. package/build/components/writing-flow/use-selection-observer.js +49 -8
  128. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  129. package/build/elements/index.js +9 -0
  130. package/build/elements/index.js.map +1 -0
  131. package/build/hooks/anchor.js.map +1 -1
  132. package/build/hooks/border.js +2 -7
  133. package/build/hooks/border.js.map +1 -1
  134. package/build/hooks/color-panel.js +14 -7
  135. package/build/hooks/color-panel.js.map +1 -1
  136. package/build/hooks/color.js +8 -88
  137. package/build/hooks/color.js.map +1 -1
  138. package/build/hooks/dimensions.js +16 -6
  139. package/build/hooks/dimensions.js.map +1 -1
  140. package/build/hooks/index.js +2 -0
  141. package/build/hooks/index.js.map +1 -1
  142. package/build/hooks/margin.js +64 -12
  143. package/build/hooks/margin.js.map +1 -1
  144. package/build/hooks/padding.js +60 -12
  145. package/build/hooks/padding.js.map +1 -1
  146. package/build/hooks/settings.js +32 -0
  147. package/build/hooks/settings.js.map +1 -0
  148. package/build/hooks/style.js +14 -13
  149. package/build/hooks/style.js.map +1 -1
  150. package/build/hooks/typography.js +6 -2
  151. package/build/hooks/typography.js.map +1 -1
  152. package/build/index.js +14 -0
  153. package/build/index.js.map +1 -1
  154. package/build/layouts/flex.js +5 -2
  155. package/build/layouts/flex.js.map +1 -1
  156. package/build/store/actions.js +14 -0
  157. package/build/store/actions.js.map +1 -1
  158. package/build/store/defaults.js +0 -1
  159. package/build/store/defaults.js.map +1 -1
  160. package/build/store/reducer.js +17 -2
  161. package/build/store/reducer.js.map +1 -1
  162. package/build/store/selectors.js +43 -13
  163. package/build/store/selectors.js.map +1 -1
  164. package/build-module/components/block-alignment-control/constants.js +36 -0
  165. package/build-module/components/block-alignment-control/constants.js.map +1 -0
  166. package/build-module/components/block-alignment-control/ui.js +4 -35
  167. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  168. package/build-module/components/block-alignment-control/ui.native.js +78 -0
  169. package/build-module/components/block-alignment-control/ui.native.js.map +1 -0
  170. package/build-module/components/block-alignment-matrix-control/index.js +1 -6
  171. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  172. package/build-module/components/block-content-overlay/index.js +3 -78
  173. package/build-module/components/block-content-overlay/index.js.map +1 -1
  174. package/build-module/components/block-draggable/draggable-chip.native.js +51 -0
  175. package/build-module/components/block-draggable/draggable-chip.native.js.map +1 -0
  176. package/build-module/components/block-draggable/dropping-insertion-point.native.js +137 -0
  177. package/build-module/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
  178. package/build-module/components/block-draggable/index.native.js +453 -0
  179. package/build-module/components/block-draggable/index.native.js.map +1 -0
  180. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +120 -0
  181. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
  182. package/build-module/components/block-list/block-list-context.native.js +179 -0
  183. package/build-module/components/block-list/block-list-context.native.js.map +1 -0
  184. package/build-module/components/block-list/block-list-item-cell.native.js +59 -0
  185. package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -0
  186. package/build-module/components/block-list/block-list-item.native.js +12 -9
  187. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  188. package/build-module/components/block-list/block.native.js +26 -5
  189. package/build-module/components/block-list/block.native.js.map +1 -1
  190. package/build-module/components/block-list/index.js +35 -33
  191. package/build-module/components/block-list/index.js.map +1 -1
  192. package/build-module/components/block-list/index.native.js +72 -23
  193. package/build-module/components/block-list/index.native.js.map +1 -1
  194. package/build-module/components/block-list/use-block-props/index.js +9 -5
  195. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  196. package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -7
  197. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  198. package/build-module/components/block-list/use-in-between-inserter.js +1 -1
  199. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  200. package/build-module/components/block-mobile-toolbar/index.native.js +9 -3
  201. package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
  202. package/build-module/components/block-mover/index.native.js +18 -5
  203. package/build-module/components/block-mover/index.native.js.map +1 -1
  204. package/build-module/components/block-navigation/dropdown.js +10 -5
  205. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  206. package/build-module/components/block-popover/inbetween.js +19 -8
  207. package/build-module/components/block-popover/inbetween.js.map +1 -1
  208. package/build-module/components/block-popover/index.js +21 -15
  209. package/build-module/components/block-popover/index.js.map +1 -1
  210. package/build-module/components/block-preview/index.js +1 -1
  211. package/build-module/components/block-preview/index.js.map +1 -1
  212. package/build-module/components/block-tools/block-selection-button.js +1 -0
  213. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  214. package/build-module/components/block-tools/selected-block-popover.js +2 -29
  215. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  216. package/build-module/components/block-variation-transforms/index.js +13 -2
  217. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  218. package/build-module/components/border-radius-control/input-controls.js +11 -4
  219. package/build-module/components/border-radius-control/input-controls.js.map +1 -1
  220. package/build-module/components/color-style-selector/index.js +6 -0
  221. package/build-module/components/color-style-selector/index.js.map +1 -1
  222. package/build-module/components/colors-gradients/dropdown.js +124 -43
  223. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  224. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +36 -64
  225. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  226. package/build-module/components/convert-to-group-buttons/toolbar.js +23 -6
  227. package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
  228. package/build-module/components/iframe/index.js +52 -51
  229. package/build-module/components/iframe/index.js.map +1 -1
  230. package/build-module/components/image-editor/use-save-image.js +2 -1
  231. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  232. package/build-module/components/index.js +2 -3
  233. package/build-module/components/index.js.map +1 -1
  234. package/build-module/components/inserter/index.js +21 -7
  235. package/build-module/components/inserter/index.js.map +1 -1
  236. package/build-module/components/inserter/index.native.js +2 -2
  237. package/build-module/components/inserter/index.native.js.map +1 -1
  238. package/build-module/components/inserter/quick-inserter.js +4 -5
  239. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  240. package/build-module/components/link-control/constants.js +5 -0
  241. package/build-module/components/link-control/constants.js.map +1 -1
  242. package/build-module/components/link-control/search-results.js +3 -4
  243. package/build-module/components/link-control/search-results.js.map +1 -1
  244. package/build-module/components/link-control/use-search-handler.js +5 -5
  245. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  246. package/build-module/components/list-view/block.js +15 -16
  247. package/build-module/components/list-view/block.js.map +1 -1
  248. package/build-module/components/list-view/branch.js +9 -13
  249. package/build-module/components/list-view/branch.js.map +1 -1
  250. package/build-module/components/list-view/context.js +1 -4
  251. package/build-module/components/list-view/context.js.map +1 -1
  252. package/build-module/components/list-view/drop-indicator.js +0 -1
  253. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  254. package/build-module/components/list-view/index.js +15 -31
  255. package/build-module/components/list-view/index.js.map +1 -1
  256. package/build-module/components/media-placeholder/index.js +0 -2
  257. package/build-module/components/media-placeholder/index.js.map +1 -1
  258. package/build-module/components/media-replace-flow/index.js +0 -2
  259. package/build-module/components/media-replace-flow/index.js.map +1 -1
  260. package/build-module/components/media-upload/index.native.js +8 -3
  261. package/build-module/components/media-upload/index.native.js.map +1 -1
  262. package/build-module/components/navigable-toolbar/index.js +12 -2
  263. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  264. package/build-module/components/plain-text/index.native.js +63 -8
  265. package/build-module/components/plain-text/index.native.js.map +1 -1
  266. package/build-module/components/publish-date-time-picker/index.js +42 -0
  267. package/build-module/components/publish-date-time-picker/index.js.map +1 -0
  268. package/build-module/components/rich-text/format-toolbar-container.js +0 -1
  269. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  270. package/build-module/components/rich-text/index.js +2 -2
  271. package/build-module/components/rich-text/index.js.map +1 -1
  272. package/build-module/components/rich-text/index.native.js +5 -1
  273. package/build-module/components/rich-text/index.native.js.map +1 -1
  274. package/build-module/components/url-input/index.js +11 -4
  275. package/build-module/components/url-input/index.js.map +1 -1
  276. package/build-module/components/use-block-drop-zone/index.native.js +148 -0
  277. package/build-module/components/use-block-drop-zone/index.native.js.map +1 -0
  278. package/build-module/components/use-on-block-drop/index.native.js +83 -0
  279. package/build-module/components/use-on-block-drop/index.native.js.map +1 -0
  280. package/build-module/components/use-setting/index.js +43 -19
  281. package/build-module/components/use-setting/index.js.map +1 -1
  282. package/build-module/components/warning/index.js +6 -1
  283. package/build-module/components/warning/index.js.map +1 -1
  284. package/build-module/components/writing-flow/use-click-selection.js +1 -3
  285. package/build-module/components/writing-flow/use-click-selection.js.map +1 -1
  286. package/build-module/components/writing-flow/use-input.js +15 -0
  287. package/build-module/components/writing-flow/use-input.js.map +1 -1
  288. package/build-module/components/writing-flow/use-selection-observer.js +49 -8
  289. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  290. package/build-module/elements/index.js +2 -0
  291. package/build-module/elements/index.js.map +1 -0
  292. package/build-module/hooks/anchor.js.map +1 -1
  293. package/build-module/hooks/border.js +2 -7
  294. package/build-module/hooks/border.js.map +1 -1
  295. package/build-module/hooks/color-panel.js +11 -6
  296. package/build-module/hooks/color-panel.js.map +1 -1
  297. package/build-module/hooks/color.js +8 -88
  298. package/build-module/hooks/color.js.map +1 -1
  299. package/build-module/hooks/dimensions.js +19 -9
  300. package/build-module/hooks/dimensions.js.map +1 -1
  301. package/build-module/hooks/index.js +1 -0
  302. package/build-module/hooks/index.js.map +1 -1
  303. package/build-module/hooks/margin.js +61 -13
  304. package/build-module/hooks/margin.js.map +1 -1
  305. package/build-module/hooks/padding.js +57 -13
  306. package/build-module/hooks/padding.js.map +1 -1
  307. package/build-module/hooks/settings.js +29 -0
  308. package/build-module/hooks/settings.js.map +1 -0
  309. package/build-module/hooks/style.js +15 -14
  310. package/build-module/hooks/style.js.map +1 -1
  311. package/build-module/hooks/typography.js +6 -2
  312. package/build-module/hooks/typography.js.map +1 -1
  313. package/build-module/index.js +1 -0
  314. package/build-module/index.js.map +1 -1
  315. package/build-module/layouts/flex.js +4 -2
  316. package/build-module/layouts/flex.js.map +1 -1
  317. package/build-module/store/actions.js +12 -0
  318. package/build-module/store/actions.js.map +1 -1
  319. package/build-module/store/defaults.js +0 -1
  320. package/build-module/store/defaults.js.map +1 -1
  321. package/build-module/store/reducer.js +17 -2
  322. package/build-module/store/reducer.js.map +1 -1
  323. package/build-module/store/selectors.js +37 -12
  324. package/build-module/store/selectors.js.map +1 -1
  325. package/build-style/style-rtl.css +100 -225
  326. package/build-style/style.css +100 -225
  327. package/package.json +30 -30
  328. package/src/components/block-alignment-control/constants.js +45 -0
  329. package/src/components/block-alignment-control/ui.js +69 -109
  330. package/src/components/block-alignment-control/ui.native.js +86 -0
  331. package/src/components/block-alignment-matrix-control/index.js +1 -5
  332. package/src/components/block-content-overlay/index.js +8 -95
  333. package/src/components/block-content-overlay/style.scss +2 -12
  334. package/src/components/block-draggable/draggable-chip.native.js +49 -0
  335. package/src/components/block-draggable/dropping-insertion-point.native.js +181 -0
  336. package/src/components/block-draggable/dropping-insertion-point.native.scss +8 -0
  337. package/src/components/block-draggable/index.native.js +462 -0
  338. package/src/components/block-draggable/style.native.scss +19 -0
  339. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +73 -0
  340. package/src/components/block-draggable/test/helpers.native.js +183 -0
  341. package/src/components/block-draggable/test/index.native.js +496 -0
  342. package/src/components/block-draggable/use-scroll-when-dragging.native.js +135 -0
  343. package/src/components/block-list/block-list-context.native.js +175 -0
  344. package/src/components/block-list/block-list-item-cell.native.js +49 -0
  345. package/src/components/block-list/block-list-item.native.js +7 -11
  346. package/src/components/block-list/block.native.js +37 -8
  347. package/src/components/block-list/index.js +44 -44
  348. package/src/components/block-list/index.native.js +54 -13
  349. package/src/components/block-list/style.scss +7 -18
  350. package/src/components/block-list/test/block-list-context.native.js +253 -0
  351. package/src/components/block-list/test/fixtures/block-list-context.native.js +79 -0
  352. package/src/components/block-list/use-block-props/index.js +10 -5
  353. package/src/components/block-list/use-block-props/use-block-class-names.js +1 -11
  354. package/src/components/block-list/use-in-between-inserter.js +1 -1
  355. package/src/components/block-mobile-toolbar/index.native.js +9 -1
  356. package/src/components/block-mover/index.native.js +22 -6
  357. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +10 -0
  358. package/src/components/block-navigation/dropdown.js +12 -8
  359. package/src/components/block-popover/inbetween.js +21 -8
  360. package/src/components/block-popover/index.js +18 -15
  361. package/src/components/block-popover/style.scss +4 -0
  362. package/src/components/block-preview/index.js +1 -4
  363. package/src/components/block-switcher/style.scss +2 -39
  364. package/src/components/block-tools/block-selection-button.js +1 -0
  365. package/src/components/block-tools/selected-block-popover.js +1 -36
  366. package/src/components/block-tools/style.scss +1 -12
  367. package/src/components/block-variation-transforms/index.js +6 -2
  368. package/src/components/border-radius-control/input-controls.js +16 -8
  369. package/src/components/border-radius-control/style.scss +3 -2
  370. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  371. package/src/components/color-style-selector/index.js +18 -9
  372. package/src/components/colors-gradients/dropdown.js +130 -62
  373. package/src/components/colors-gradients/panel-color-gradient-settings.js +30 -76
  374. package/src/components/colors-gradients/style.scss +52 -50
  375. package/src/components/convert-to-group-buttons/toolbar.js +30 -13
  376. package/src/components/duotone-control/style.scss +1 -7
  377. package/src/components/iframe/index.js +62 -54
  378. package/src/components/image-editor/use-save-image.js +2 -1
  379. package/src/components/image-size-control/README.md +1 -1
  380. package/src/components/index.js +2 -3
  381. package/src/components/inserter/index.js +20 -0
  382. package/src/components/inserter/index.native.js +2 -2
  383. package/src/components/inserter/quick-inserter.js +3 -11
  384. package/src/components/inserter/style.native.scss +1 -0
  385. package/src/components/inserter/style.scss +2 -1
  386. package/src/components/link-control/constants.js +11 -0
  387. package/src/components/link-control/search-results.js +4 -5
  388. package/src/components/link-control/use-search-handler.js +11 -5
  389. package/src/components/list-view/block.js +24 -34
  390. package/src/components/list-view/branch.js +10 -20
  391. package/src/components/list-view/context.js +1 -4
  392. package/src/components/list-view/drop-indicator.js +0 -1
  393. package/src/components/list-view/index.js +11 -41
  394. package/src/components/list-view/style.scss +2 -1
  395. package/src/components/media-placeholder/index.js +0 -2
  396. package/src/components/media-replace-flow/index.js +0 -2
  397. package/src/components/media-upload/index.native.js +6 -2
  398. package/src/components/media-upload/test/index.native.js +31 -6
  399. package/src/components/navigable-toolbar/index.js +12 -2
  400. package/src/components/plain-text/index.native.js +64 -8
  401. package/src/components/preview-options/style.scss +0 -4
  402. package/src/components/publish-date-time-picker/README.md +52 -0
  403. package/src/components/publish-date-time-picker/index.js +50 -0
  404. package/src/components/publish-date-time-picker/style.scss +20 -0
  405. package/src/components/rich-text/format-toolbar-container.js +0 -1
  406. package/src/components/rich-text/index.js +3 -1
  407. package/src/components/rich-text/index.native.js +4 -0
  408. package/src/components/rich-text/style.scss +2 -8
  409. package/src/components/url-input/index.js +9 -4
  410. package/src/components/use-block-drop-zone/index.native.js +173 -0
  411. package/src/components/use-on-block-drop/index.native.js +119 -0
  412. package/src/components/use-setting/index.js +57 -21
  413. package/src/components/warning/index.js +47 -42
  414. package/src/components/warning/test/__snapshots__/index.js.snap +15 -6
  415. package/src/components/warning/test/index.js +1 -1
  416. package/src/components/writing-flow/use-click-selection.js +1 -4
  417. package/src/components/writing-flow/use-input.js +12 -0
  418. package/src/components/writing-flow/use-selection-observer.js +55 -10
  419. package/src/elements/index.js +1 -0
  420. package/src/hooks/anchor.js +1 -1
  421. package/src/hooks/border.js +2 -11
  422. package/src/hooks/border.scss +0 -48
  423. package/src/hooks/color-panel.js +13 -9
  424. package/src/hooks/color.js +5 -74
  425. package/src/hooks/color.scss +5 -58
  426. package/src/hooks/dimensions.js +55 -41
  427. package/src/hooks/index.js +1 -0
  428. package/src/hooks/margin.js +64 -15
  429. package/src/hooks/padding.js +60 -15
  430. package/src/hooks/padding.scss +12 -0
  431. package/src/hooks/settings.js +32 -0
  432. package/src/hooks/style.js +25 -39
  433. package/src/hooks/test/settings.js +48 -0
  434. package/src/hooks/typography.js +2 -0
  435. package/src/index.js +1 -0
  436. package/src/layouts/flex.js +11 -3
  437. package/src/store/actions.js +12 -0
  438. package/src/store/defaults.js +0 -1
  439. package/src/store/reducer.js +14 -1
  440. package/src/store/selectors.js +42 -12
  441. package/src/store/test/reducer.js +5 -0
  442. package/src/store/test/selectors.js +17 -0
  443. package/src/style.scss +2 -2
  444. package/tsconfig.tsbuildinfo +1 -1
  445. package/build/components/border-style-control/index.js +0 -60
  446. package/build/components/border-style-control/index.js.map +0 -1
  447. package/build/components/colors/color-panel.js +0 -82
  448. package/build/components/colors/color-panel.js.map +0 -1
  449. package/build/components/colors/color-panel.native.js +0 -11
  450. package/build/components/colors/color-panel.native.js.map +0 -1
  451. package/build/components/colors-gradients/tools-panel-color-dropdown.js +0 -89
  452. package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
  453. package/build-module/components/border-style-control/index.js +0 -50
  454. package/build-module/components/border-style-control/index.js.map +0 -1
  455. package/build-module/components/colors/color-panel.js +0 -70
  456. package/build-module/components/colors/color-panel.js.map +0 -1
  457. package/build-module/components/colors/color-panel.native.js +0 -4
  458. package/build-module/components/colors/color-panel.native.js.map +0 -1
  459. package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +0 -75
  460. package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
  461. package/src/components/block-alignment-matrix-control/style.scss +0 -10
  462. package/src/components/border-style-control/index.js +0 -47
  463. package/src/components/border-style-control/style.scss +0 -18
  464. package/src/components/colors/color-panel.js +0 -91
  465. package/src/components/colors/color-panel.native.js +0 -3
  466. package/src/components/colors-gradients/tools-panel-color-dropdown.js +0 -85
@@ -0,0 +1,83 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { cloneBlock } from '@wordpress/blocks';
5
+ import { useDispatch, useSelect } from '@wordpress/data';
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+
10
+ import { store as blockEditorStore } from '../../store';
11
+ /**
12
+ * A function that returns an event handler function for block drop events.
13
+ *
14
+ * @param {Function} getBlockIndex A function that gets the index of a block.
15
+ * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.
16
+ * @param {Function} moveBlocksToPosition A function that moves blocks.
17
+ * @param {Function} insertBlocks A function that inserts blocks.
18
+ * @param {Function} clearSelectedBlock A function that clears block selection.
19
+ * @return {Function} The event handler for a block drop event.
20
+ */
21
+
22
+ export function onBlockDrop(getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock) {
23
+ return _ref => {
24
+ let {
25
+ blocks,
26
+ srcClientIds: sourceClientIds,
27
+ srcRootClientId: sourceRootClientId,
28
+ targetBlockIndex,
29
+ targetRootClientId,
30
+ type: dropType
31
+ } = _ref;
32
+
33
+ // If the user is inserting a block.
34
+ if (dropType === 'inserter') {
35
+ clearSelectedBlock();
36
+ const blocksToInsert = blocks.map(block => cloneBlock(block));
37
+ insertBlocks(blocksToInsert, targetBlockIndex, targetRootClientId, true, null);
38
+ } // If the user is moving a block.
39
+
40
+
41
+ if (dropType === 'block') {
42
+ const sourceBlockIndex = getBlockIndex(sourceClientIds[0]); // If the user is dropping to the same position, return early.
43
+
44
+ if (sourceRootClientId === targetRootClientId && sourceBlockIndex === targetBlockIndex) {
45
+ return;
46
+ } // If the user is attempting to drop a block within its own
47
+ // nested blocks, return early as this would create infinite
48
+ // recursion.
49
+
50
+
51
+ if (sourceClientIds.includes(targetRootClientId) || getClientIdsOfDescendants(sourceClientIds).some(id => id === targetRootClientId)) {
52
+ return;
53
+ }
54
+
55
+ const isAtSameLevel = sourceRootClientId === targetRootClientId;
56
+ const draggedBlockCount = sourceClientIds.length; // If the block is kept at the same level and moved downwards,
57
+ // subtract to take into account that the blocks being dragged
58
+ // were removed from the block list above the insertion point.
59
+
60
+ const insertIndex = isAtSameLevel && sourceBlockIndex < targetBlockIndex ? targetBlockIndex - draggedBlockCount : targetBlockIndex;
61
+ moveBlocksToPosition(sourceClientIds, sourceRootClientId, targetRootClientId, insertIndex);
62
+ }
63
+ };
64
+ }
65
+ /**
66
+ * A React hook for handling block drop events.
67
+ *
68
+ * @return {Function} The event handler for a block drop event.
69
+ */
70
+
71
+ export default function useOnBlockDrop() {
72
+ const {
73
+ getBlockIndex,
74
+ getClientIdsOfDescendants
75
+ } = useSelect(blockEditorStore);
76
+ const {
77
+ insertBlocks,
78
+ moveBlocksToPosition,
79
+ clearSelectedBlock
80
+ } = useDispatch(blockEditorStore);
81
+ return onBlockDrop(getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock);
82
+ }
83
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-on-block-drop/index.native.js"],"names":["cloneBlock","useDispatch","useSelect","store","blockEditorStore","onBlockDrop","getBlockIndex","getClientIdsOfDescendants","moveBlocksToPosition","insertBlocks","clearSelectedBlock","blocks","srcClientIds","sourceClientIds","srcRootClientId","sourceRootClientId","targetBlockIndex","targetRootClientId","type","dropType","blocksToInsert","map","block","sourceBlockIndex","includes","some","id","isAtSameLevel","draggedBlockCount","length","insertIndex","useOnBlockDrop"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,mBAA3B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,CACNC,aADM,EAENC,yBAFM,EAGNC,oBAHM,EAINC,YAJM,EAKNC,kBALM,EAML;AACD,SAAO,QAOA;AAAA,QAPE;AACRC,MAAAA,MADQ;AAERC,MAAAA,YAAY,EAAEC,eAFN;AAGRC,MAAAA,eAAe,EAAEC,kBAHT;AAIRC,MAAAA,gBAJQ;AAKRC,MAAAA,kBALQ;AAMRC,MAAAA,IAAI,EAAEC;AANE,KAOF;;AACN;AACA,QAAKA,QAAQ,KAAK,UAAlB,EAA+B;AAC9BT,MAAAA,kBAAkB;AAClB,YAAMU,cAAc,GAAGT,MAAM,CAACU,GAAP,CAAcC,KAAF,IAClCtB,UAAU,CAAEsB,KAAF,CADY,CAAvB;AAGAb,MAAAA,YAAY,CACXW,cADW,EAEXJ,gBAFW,EAGXC,kBAHW,EAIX,IAJW,EAKX,IALW,CAAZ;AAOA,KAdK,CAgBN;;;AACA,QAAKE,QAAQ,KAAK,OAAlB,EAA4B;AAC3B,YAAMI,gBAAgB,GAAGjB,aAAa,CAAEO,eAAe,CAAE,CAAF,CAAjB,CAAtC,CAD2B,CAG3B;;AACA,UACCE,kBAAkB,KAAKE,kBAAvB,IACAM,gBAAgB,KAAKP,gBAFtB,EAGE;AACD;AACA,OAT0B,CAW3B;AACA;AACA;;;AACA,UACCH,eAAe,CAACW,QAAhB,CAA0BP,kBAA1B,KACAV,yBAAyB,CAAEM,eAAF,CAAzB,CAA6CY,IAA7C,CACGC,EAAF,IAAUA,EAAE,KAAKT,kBADlB,CAFD,EAKE;AACD;AACA;;AAED,YAAMU,aAAa,GAAGZ,kBAAkB,KAAKE,kBAA7C;AACA,YAAMW,iBAAiB,GAAGf,eAAe,CAACgB,MAA1C,CAxB2B,CA0B3B;AACA;AACA;;AACA,YAAMC,WAAW,GAChBH,aAAa,IAAIJ,gBAAgB,GAAGP,gBAApC,GACGA,gBAAgB,GAAGY,iBADtB,GAEGZ,gBAHJ;AAKAR,MAAAA,oBAAoB,CACnBK,eADmB,EAEnBE,kBAFmB,EAGnBE,kBAHmB,EAInBa,WAJmB,CAApB;AAMA;AACD,GAjED;AAkEA;AAED;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,cAAT,GAA0B;AACxC,QAAM;AAAEzB,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,MAA+CL,SAAS,CAC7DE,gBAD6D,CAA9D;AAGA,QAAM;AACLK,IAAAA,YADK;AAELD,IAAAA,oBAFK;AAGLE,IAAAA;AAHK,MAIFT,WAAW,CAAEG,gBAAF,CAJf;AAMA,SAAOC,WAAW,CACjBC,aADiB,EAEjBC,yBAFiB,EAGjBC,oBAHiB,EAIjBC,YAJiB,EAKjBC,kBALiB,CAAlB;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * A function that returns an event handler function for block drop events.\n *\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\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocksToPosition,\n\tinsertBlocks,\n\tclearSelectedBlock\n) {\n\treturn ( {\n\t\tblocks,\n\t\tsrcClientIds: sourceClientIds,\n\t\tsrcRootClientId: sourceRootClientId,\n\t\ttargetBlockIndex,\n\t\ttargetRootClientId,\n\t\ttype: dropType,\n\t} ) => {\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 React hook for handling block drop events.\n *\n * @return {Function} The event handler for a block drop event.\n */\nexport default function useOnBlockDrop() {\n\tconst { getBlockIndex, getClientIdsOfDescendants } = useSelect(\n\t\tblockEditorStore\n\t);\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tclearSelectedBlock,\n\t} = useDispatch( blockEditorStore );\n\n\treturn onBlockDrop(\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocksToPosition,\n\t\tinsertBlocks,\n\t\tclearSelectedBlock\n\t);\n}\n"]}
@@ -7,7 +7,7 @@ import { get } from 'lodash';
7
7
  */
8
8
 
9
9
  import { useSelect } from '@wordpress/data';
10
- import { __EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE } from '@wordpress/blocks';
10
+ import { __EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE, hasBlockSupport } from '@wordpress/blocks';
11
11
  /**
12
12
  * Internal dependencies
13
13
  */
@@ -76,8 +76,10 @@ const removeCustomPrefixes = path => {
76
76
  return prefixedFlags[path] || path;
77
77
  };
78
78
  /**
79
- * Hook that retrieves the editor setting.
80
- * It works with nested objects using by finding the value at path.
79
+ * Hook that retrieves the given setting for the block instance in use.
80
+ *
81
+ * It looks up the settings first in the block instance hierarchy.
82
+ * If none is found, it'll look it up in the block editor store.
81
83
  *
82
84
  * @param {string} path The path to the setting.
83
85
  * @return {any} Returns the value defined for the setting.
@@ -90,48 +92,70 @@ const removeCustomPrefixes = path => {
90
92
 
91
93
  export default function useSetting(path) {
92
94
  const {
93
- name: blockName
95
+ name: blockName,
96
+ clientId
94
97
  } = useBlockEditContext();
95
98
  const setting = useSelect(select => {
96
- var _get;
97
-
98
99
  if (blockedPaths.includes(path)) {
99
100
  // eslint-disable-next-line no-console
100
101
  console.warn('Top level useSetting paths are disabled. Please use a subpath to query the information needed.');
101
102
  return undefined;
102
103
  }
103
104
 
104
- const settings = select(blockEditorStore).getSettings(); // 1 - Use __experimental features, if available.
105
- // We cascade to the all value if the block one is not available.
105
+ let result;
106
+ const normalizedPath = removeCustomPrefixes(path); // 1. Take settings from the block instance or its ancestors.
107
+
108
+ const candidates = [...select(blockEditorStore).getBlockParents(clientId), clientId // The current block is added last, so it overwrites any ancestor.
109
+ ];
110
+ candidates.forEach(candidateClientId => {
111
+ const candidateBlockName = select(blockEditorStore).getBlockName(candidateClientId);
112
+
113
+ if (hasBlockSupport(candidateBlockName, '__experimentalSettings', false)) {
114
+ var _get;
115
+
116
+ const candidateAtts = select(blockEditorStore).getBlockAttributes(candidateClientId);
117
+ const candidateResult = (_get = get(candidateAtts, `settings.blocks.${blockName}.${normalizedPath}`)) !== null && _get !== void 0 ? _get : get(candidateAtts, `settings.${normalizedPath}`);
118
+
119
+ if (candidateResult !== undefined) {
120
+ result = candidateResult;
121
+ }
122
+ }
123
+ }); // 2. Fall back to the settings from the block editor store (__experimentalFeatures).
124
+
125
+ const settings = select(blockEditorStore).getSettings();
126
+
127
+ if (result === undefined) {
128
+ var _get2;
129
+
130
+ const defaultsPath = `__experimentalFeatures.${normalizedPath}`;
131
+ const blockPath = `__experimentalFeatures.blocks.${blockName}.${normalizedPath}`;
132
+ result = (_get2 = get(settings, blockPath)) !== null && _get2 !== void 0 ? _get2 : get(settings, defaultsPath);
133
+ } // Return if the setting was found in either the block instance or the store.
106
134
 
107
- const normalizedPath = removeCustomPrefixes(path);
108
- const defaultsPath = `__experimentalFeatures.${normalizedPath}`;
109
- const blockPath = `__experimentalFeatures.blocks.${blockName}.${normalizedPath}`;
110
- const experimentalFeaturesResult = (_get = get(settings, blockPath)) !== null && _get !== void 0 ? _get : get(settings, defaultsPath);
111
135
 
112
- if (experimentalFeaturesResult !== undefined) {
136
+ if (result !== undefined) {
113
137
  if (PATHS_WITH_MERGE[normalizedPath]) {
114
- var _ref, _experimentalFeatures;
138
+ var _ref, _result$custom;
115
139
 
116
- return (_ref = (_experimentalFeatures = experimentalFeaturesResult.custom) !== null && _experimentalFeatures !== void 0 ? _experimentalFeatures : experimentalFeaturesResult.theme) !== null && _ref !== void 0 ? _ref : experimentalFeaturesResult.default;
140
+ return (_ref = (_result$custom = result.custom) !== null && _result$custom !== void 0 ? _result$custom : result.theme) !== null && _ref !== void 0 ? _ref : result.default;
117
141
  }
118
142
 
119
- return experimentalFeaturesResult;
120
- } // 2 - Use deprecated settings, otherwise.
143
+ return result;
144
+ } // 3. Otherwise, use deprecated settings.
121
145
 
122
146
 
123
147
  const deprecatedSettingsValue = deprecatedFlags[normalizedPath] ? deprecatedFlags[normalizedPath](settings) : undefined;
124
148
 
125
149
  if (deprecatedSettingsValue !== undefined) {
126
150
  return deprecatedSettingsValue;
127
- } // 3 - Fall back for typography.dropCap:
151
+ } // 4. Fallback for typography.dropCap:
128
152
  // This is only necessary to support typography.dropCap.
129
153
  // when __experimentalFeatures are not present (core without plugin).
130
154
  // To remove when __experimentalFeatures are ported to core.
131
155
 
132
156
 
133
157
  return normalizedPath === 'typography.dropCap' ? true : undefined;
134
- }, [blockName, path]);
158
+ }, [blockName, clientId, path]);
135
159
  return setting;
136
160
  }
137
161
  //# sourceMappingURL=index.js.map
@@ -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","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"],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;AACA,UAAMW,YAAY,GAAI,0BAA0BD,cAAgB,EAAhE;AACA,UAAME,SAAS,GAAI,iCAAiCT,SAAW,IAAIO,cAAgB,EAAnF;AACA,UAAMG,0BAA0B,WAC/BnC,GAAG,CAAES,QAAF,EAAYyB,SAAZ,CAD4B,uCACDlC,GAAG,CAAES,QAAF,EAAYwB,YAAZ,CADlC;;AAGA,QAAKE,0BAA0B,KAAKxB,SAApC,EAAgD;AAC/C,UAAKR,gBAAgB,CAAE6B,cAAF,CAArB,EAA0C;AAAA;;AACzC,gDACCG,0BAA0B,CAACC,MAD5B,yEAECD,0BAA0B,CAACE,KAF5B,uCAGCF,0BAA0B,CAACG,OAH5B;AAKA;;AACD,aAAOH,0BAAP;AACA,KA3BY,CA6Bb;;;AACA,UAAMI,uBAAuB,GAAG/B,eAAe,CAAEwB,cAAF,CAAf,GAC7BxB,eAAe,CAAEwB,cAAF,CAAf,CAAmCvB,QAAnC,CAD6B,GAE7BE,SAFH;;AAGA,QAAK4B,uBAAuB,KAAK5B,SAAjC,EAA6C;AAC5C,aAAO4B,uBAAP;AACA,KAnCY,CAqCb;AACA;AACA;AACA;;;AACA,WAAOP,cAAc,KAAK,oBAAnB,GAA0C,IAA1C,GAAiDrB,SAAxD;AACA,GA3CuB,EA4CxB,CAAEc,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"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-setting/index.js"],"names":["get","useSelect","__EXPERIMENTAL_PATHS_WITH_MERGE","PATHS_WITH_MERGE","hasBlockSupport","useBlockEditContext","store","blockEditorStore","blockedPaths","deprecatedFlags","settings","colors","undefined","gradients","disableCustomColors","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","useSetting","name","blockName","clientId","setting","select","includes","console","warn","result","normalizedPath","candidates","getBlockParents","forEach","candidateClientId","candidateBlockName","getBlockName","candidateAtts","getBlockAttributes","candidateResult","getSettings","defaultsPath","blockPath","custom","theme","default","deprecatedSettingsValue"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,+BAA+B,IAAIC,gBADpC,EAECC,eAFD,QAGO,mBAHP;AAKA;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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B,EA2ExB,CAAEc,SAAF,EAAaC,QAAb,EAAuBJ,IAAvB,CA3EwB,CAAzB;AA8EA,SAAOK,OAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,\n\thasBlockSupport,\n} 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 given setting for the block instance in use.\n *\n * It looks up the settings first in the block instance hierarchy.\n * If none is found, it'll look it up in the block editor store.\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, clientId } = 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\n\t\t\tlet result;\n\t\t\tconst normalizedPath = removeCustomPrefixes( path );\n\n\t\t\t// 1. Take settings from the block instance or its ancestors.\n\t\t\tconst candidates = [\n\t\t\t\t...select( blockEditorStore ).getBlockParents( clientId ),\n\t\t\t\tclientId, // The current block is added last, so it overwrites any ancestor.\n\t\t\t];\n\t\t\tcandidates.forEach( ( candidateClientId ) => {\n\t\t\t\tconst candidateBlockName = select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).getBlockName( candidateClientId );\n\t\t\t\tif (\n\t\t\t\t\thasBlockSupport(\n\t\t\t\t\t\tcandidateBlockName,\n\t\t\t\t\t\t'__experimentalSettings',\n\t\t\t\t\t\tfalse\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tconst candidateAtts = select(\n\t\t\t\t\t\tblockEditorStore\n\t\t\t\t\t).getBlockAttributes( candidateClientId );\n\t\t\t\t\tconst candidateResult =\n\t\t\t\t\t\tget(\n\t\t\t\t\t\t\tcandidateAtts,\n\t\t\t\t\t\t\t`settings.blocks.${ blockName }.${ normalizedPath }`\n\t\t\t\t\t\t) ??\n\t\t\t\t\t\tget( candidateAtts, `settings.${ normalizedPath }` );\n\t\t\t\t\tif ( candidateResult !== undefined ) {\n\t\t\t\t\t\tresult = candidateResult;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t// 2. Fall back to the settings from the block editor store (__experimentalFeatures).\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\t\tif ( result === undefined ) {\n\t\t\t\tconst defaultsPath = `__experimentalFeatures.${ normalizedPath }`;\n\t\t\t\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;\n\t\t\t\tresult =\n\t\t\t\t\tget( settings, blockPath ) ?? get( settings, defaultsPath );\n\t\t\t}\n\n\t\t\t// Return if the setting was found in either the block instance or the store.\n\t\t\tif ( result !== undefined ) {\n\t\t\t\tif ( PATHS_WITH_MERGE[ normalizedPath ] ) {\n\t\t\t\t\treturn result.custom ?? result.theme ?? result.default;\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\t// 3. Otherwise, use deprecated settings.\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// 4. Fallback 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, clientId, path ]\n\t);\n\n\treturn setting;\n}\n"]}
@@ -21,6 +21,11 @@ function Warning(_ref) {
21
21
  secondaryActions
22
22
  } = _ref;
23
23
  return createElement("div", {
24
+ style: {
25
+ display: 'contents',
26
+ all: 'initial'
27
+ }
28
+ }, createElement("div", {
24
29
  className: classnames(className, 'block-editor-warning')
25
30
  }, createElement("div", {
26
31
  className: "block-editor-warning__contents"
@@ -43,7 +48,7 @@ function Warning(_ref) {
43
48
  }, () => createElement(MenuGroup, null, secondaryActions.map((item, pos) => createElement(MenuItem, {
44
49
  onClick: item.onClick,
45
50
  key: pos
46
- }, item.title)))))));
51
+ }, item.title))))))));
47
52
  }
48
53
  /**
49
54
  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/warning/index.js"],"names":["classnames","Children","DropdownMenu","MenuGroup","MenuItem","__","moreHorizontal","Warning","className","actions","children","secondaryActions","count","map","action","i","position","item","pos","onClick","title"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,YAAT,EAAuBC,SAAvB,EAAkCC,QAAlC,QAAkD,uBAAlD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,cAAT,QAA+B,kBA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dependencies\n */\nimport { Children } from '@wordpress/element';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { moreHorizontal } from '@wordpress/icons';\n\nfunction Warning( { className, actions, children, secondaryActions } ) {\n\treturn (\n\t\t<div className={ classnames( className, 'block-editor-warning' ) }>\n\t\t\t<div className=\"block-editor-warning__contents\">\n\t\t\t\t<p className=\"block-editor-warning__message\">{ children }</p>\n\n\t\t\t\t{ ( Children.count( actions ) > 0 || secondaryActions ) && (\n\t\t\t\t\t<div className=\"block-editor-warning__actions\">\n\t\t\t\t\t\t{ Children.count( actions ) > 0 &&\n\t\t\t\t\t\t\tChildren.map( actions, ( action, i ) => (\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__action\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ action }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t{ secondaryActions && (\n\t\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__secondary\"\n\t\t\t\t\t\t\t\ticon={ moreHorizontal }\n\t\t\t\t\t\t\t\tlabel={ __( 'More options' ) }\n\t\t\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\t\t\tposition: 'bottom left',\n\t\t\t\t\t\t\t\t\tclassName: 'block-editor-warning__dropdown',\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tnoIcons\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t\t\t{ secondaryActions.map(\n\t\t\t\t\t\t\t\t\t\t\t( item, pos ) => (\n\t\t\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ item.onClick }\n\t\t\t\t\t\t\t\t\t\t\t\t\tkey={ pos }\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</DropdownMenu>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md\n */\nexport default Warning;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/warning/index.js"],"names":["classnames","Children","DropdownMenu","MenuGroup","MenuItem","__","moreHorizontal","Warning","className","actions","children","secondaryActions","display","all","count","map","action","i","position","item","pos","onClick","title"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,YAAT,EAAuBC,SAAvB,EAAkCC,QAAlC,QAAkD,uBAAlD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,cAAT,QAA+B,kBAA/B;;AAEA,SAASC,OAAT,OAAuE;AAAA,MAArD;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,OAAb;AAAsBC,IAAAA,QAAtB;AAAgCC,IAAAA;AAAhC,GAAqD;AACtE,SACC;AAAK,IAAA,KAAK,EAAG;AAAEC,MAAAA,OAAO,EAAE,UAAX;AAAuBC,MAAAA,GAAG,EAAE;AAA5B;AAAb,KACC;AAAK,IAAA,SAAS,EAAGb,UAAU,CAAEQ,SAAF,EAAa,sBAAb;AAA3B,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAG,IAAA,SAAS,EAAC;AAAb,KACGE,QADH,CADD,EAKG,CAAET,QAAQ,CAACa,KAAT,CAAgBL,OAAhB,IAA4B,CAA5B,IAAiCE,gBAAnC,KACD;AAAK,IAAA,SAAS,EAAC;AAAf,KACGV,QAAQ,CAACa,KAAT,CAAgBL,OAAhB,IAA4B,CAA5B,IACDR,QAAQ,CAACc,GAAT,CAAcN,OAAd,EAAuB,CAAEO,MAAF,EAAUC,CAAV,KACtB;AACC,IAAA,GAAG,EAAGA,CADP;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGD,MAJH,CADD,CAFF,EAUGL,gBAAgB,IACjB,cAAC,YAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,IAAI,EAAGL,cAFR;AAGC,IAAA,KAAK,EAAGD,EAAE,CAAE,cAAF,CAHX;AAIC,IAAA,YAAY,EAAG;AACda,MAAAA,QAAQ,EAAE,aADI;AAEdV,MAAAA,SAAS,EACR;AAHa,KAJhB;AASC,IAAA,OAAO;AATR,KAWG,MACD,cAAC,SAAD,QACGG,gBAAgB,CAACI,GAAjB,CACD,CAAEI,IAAF,EAAQC,GAAR,KACC,cAAC,QAAD;AACC,IAAA,OAAO,EAAGD,IAAI,CAACE,OADhB;AAEC,IAAA,GAAG,EAAGD;AAFP,KAIGD,IAAI,CAACG,KAJR,CAFA,CADH,CAZF,CAXF,CANF,CADD,CADD,CADD;AAqDA;AAED;AACA;AACA;;;AACA,eAAef,OAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Children } from '@wordpress/element';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { moreHorizontal } from '@wordpress/icons';\n\nfunction Warning( { className, actions, children, secondaryActions } ) {\n\treturn (\n\t\t<div style={ { display: 'contents', all: 'initial' } }>\n\t\t\t<div className={ classnames( className, 'block-editor-warning' ) }>\n\t\t\t\t<div className=\"block-editor-warning__contents\">\n\t\t\t\t\t<p className=\"block-editor-warning__message\">\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</p>\n\n\t\t\t\t\t{ ( Children.count( actions ) > 0 || secondaryActions ) && (\n\t\t\t\t\t\t<div className=\"block-editor-warning__actions\">\n\t\t\t\t\t\t\t{ Children.count( actions ) > 0 &&\n\t\t\t\t\t\t\t\tChildren.map( actions, ( action, i ) => (\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__action\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ action }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t{ secondaryActions && (\n\t\t\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__secondary\"\n\t\t\t\t\t\t\t\t\ticon={ moreHorizontal }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'More options' ) }\n\t\t\t\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\t\t\t\tposition: 'bottom left',\n\t\t\t\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-warning__dropdown',\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tnoIcons\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t\t\t\t{ secondaryActions.map(\n\t\t\t\t\t\t\t\t\t\t\t\t( item, pos ) => (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ item.onClick }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey={ pos }\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</DropdownMenu>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md\n */\nexport default Warning;\n"]}
@@ -11,12 +11,10 @@ import { store as blockEditorStore } from '../../store';
11
11
  import { getBlockClientId } from '../../utils/dom';
12
12
  export default function useClickSelection() {
13
13
  const {
14
- multiSelect,
15
14
  selectBlock
16
15
  } = useDispatch(blockEditorStore);
17
16
  const {
18
17
  isSelectionEnabled,
19
- getBlockParents,
20
18
  getBlockSelectionStart,
21
19
  hasMultiSelection
22
20
  } = useSelect(blockEditorStore);
@@ -52,6 +50,6 @@ export default function useClickSelection() {
52
50
  return () => {
53
51
  node.removeEventListener('mousedown', onMouseDown);
54
52
  };
55
- }, [multiSelect, selectBlock, isSelectionEnabled, getBlockParents, getBlockSelectionStart, hasMultiSelection]);
53
+ }, [selectBlock, isSelectionEnabled, getBlockSelectionStart, hasMultiSelection]);
56
54
  }
57
55
  //# sourceMappingURL=use-click-selection.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-click-selection.js"],"names":["useSelect","useDispatch","useRefEffect","store","blockEditorStore","getBlockClientId","useClickSelection","multiSelect","selectBlock","isSelectionEnabled","getBlockParents","getBlockSelectionStart","hasMultiSelection","node","onMouseDown","event","button","startClientId","clickedClientId","target","shiftKey","contentEditable","focus","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,i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AnCkB,CAAnB;AA4CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\n\nexport default function useClickSelection() {\n\tconst { multiSelect, selectBlock } = useDispatch( blockEditorStore );\n\tconst {\n\t\tisSelectionEnabled,\n\t\tgetBlockParents,\n\t\tgetBlockSelectionStart,\n\t\thasMultiSelection,\n\t} = useSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tfunction onMouseDown( event ) {\n\t\t\t\t// The main button.\n\t\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button\n\t\t\t\tif ( ! isSelectionEnabled() || event.button !== 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst startClientId = getBlockSelectionStart();\n\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\n\t\t\t\tif ( event.shiftKey ) {\n\t\t\t\t\tif ( startClientId !== clickedClientId ) {\n\t\t\t\t\t\tnode.contentEditable = true;\n\t\t\t\t\t\t// Firefox doesn't automatically move focus.\n\t\t\t\t\t\tnode.focus();\n\t\t\t\t\t}\n\t\t\t\t} else if ( hasMultiSelection() ) {\n\t\t\t\t\t// Allow user to escape out of a multi-selection to a\n\t\t\t\t\t// singular selection of a block via click. This is handled\n\t\t\t\t\t// here since focus handling excludes blocks when there is\n\t\t\t\t\t// multiselection, as focus can be incurred by starting a\n\t\t\t\t\t// multiselection (focus moved to first block's multi-\n\t\t\t\t\t// controls).\n\t\t\t\t\tselectBlock( clickedClientId );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tmultiSelect,\n\t\t\tselectBlock,\n\t\t\tisSelectionEnabled,\n\t\t\tgetBlockParents,\n\t\t\tgetBlockSelectionStart,\n\t\t\thasMultiSelection,\n\t\t]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-click-selection.js"],"names":["useSelect","useDispatch","useRefEffect","store","blockEditorStore","getBlockClientId","useClickSelection","selectBlock","isSelectionEnabled","getBlockSelectionStart","hasMultiSelection","node","onMouseDown","event","button","startClientId","clickedClientId","target","shiftKey","contentEditable","focus","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,gBAAT,QAAiC,iBAAjC;AAEA,eAAe,SAASC,iBAAT,GAA6B;AAC3C,QAAM;AAAEC,IAAAA;AAAF,MAAkBN,WAAW,CAAEG,gBAAF,CAAnC;AACA,QAAM;AACLI,IAAAA,kBADK;AAELC,IAAAA,sBAFK;AAGLC,IAAAA;AAHK,MAIFV,SAAS,CAAEI,gBAAF,CAJb;AAKA,SAAOF,YAAY,CAChBS,IAAF,IAAY;AACX,aAASC,WAAT,CAAsBC,KAAtB,EAA8B;AAC7B;AACA;AACA,UAAK,CAAEL,kBAAkB,EAApB,IAA0BK,KAAK,CAACC,MAAN,KAAiB,CAAhD,EAAoD;AACnD;AACA;;AAED,YAAMC,aAAa,GAAGN,sBAAsB,EAA5C;AACA,YAAMO,eAAe,GAAGX,gBAAgB,CAAEQ,KAAK,CAACI,MAAR,CAAxC;;AAEA,UAAKJ,KAAK,CAACK,QAAX,EAAsB;AACrB,YAAKH,aAAa,KAAKC,eAAvB,EAAyC;AACxCL,UAAAA,IAAI,CAACQ,eAAL,GAAuB,IAAvB,CADwC,CAExC;;AACAR,UAAAA,IAAI,CAACS,KAAL;AACA;AACD,OAND,MAMO,IAAKV,iBAAiB,EAAtB,EAA2B;AACjC;AACA;AACA;AACA;AACA;AACA;AACAH,QAAAA,WAAW,CAAES,eAAF,CAAX;AACA;AACD;;AAEDL,IAAAA,IAAI,CAACU,gBAAL,CAAuB,WAAvB,EAAoCT,WAApC;AAEA,WAAO,MAAM;AACZD,MAAAA,IAAI,CAACW,mBAAL,CAA0B,WAA1B,EAAuCV,WAAvC;AACA,KAFD;AAGA,GAlCiB,EAmClB,CACCL,WADD,EAECC,kBAFD,EAGCC,sBAHD,EAICC,iBAJD,CAnCkB,CAAnB;AA0CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\n\nexport default function useClickSelection() {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst {\n\t\tisSelectionEnabled,\n\t\tgetBlockSelectionStart,\n\t\thasMultiSelection,\n\t} = useSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tfunction onMouseDown( event ) {\n\t\t\t\t// The main button.\n\t\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button\n\t\t\t\tif ( ! isSelectionEnabled() || event.button !== 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst startClientId = getBlockSelectionStart();\n\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\n\t\t\t\tif ( event.shiftKey ) {\n\t\t\t\t\tif ( startClientId !== clickedClientId ) {\n\t\t\t\t\t\tnode.contentEditable = true;\n\t\t\t\t\t\t// Firefox doesn't automatically move focus.\n\t\t\t\t\t\tnode.focus();\n\t\t\t\t\t}\n\t\t\t\t} else if ( hasMultiSelection() ) {\n\t\t\t\t\t// Allow user to escape out of a multi-selection to a\n\t\t\t\t\t// singular selection of a block via click. This is handled\n\t\t\t\t\t// here since focus handling excludes blocks when there is\n\t\t\t\t\t// multiselection, as focus can be incurred by starting a\n\t\t\t\t\t// multiselection (focus moved to first block's multi-\n\t\t\t\t\t// controls).\n\t\t\t\t\tselectBlock( clickedClientId );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tselectBlock,\n\t\t\tisSelectionEnabled,\n\t\t\tgetBlockSelectionStart,\n\t\t\thasMultiSelection,\n\t\t]\n\t);\n}\n"]}
@@ -29,6 +29,19 @@ export default function useInput() {
29
29
  __unstableExpandSelection
30
30
  } = useDispatch(blockEditorStore);
31
31
  return useRefEffect(node => {
32
+ function onBeforeInput(event) {
33
+ var _event$inputType;
34
+
35
+ if (!hasMultiSelection()) {
36
+ return;
37
+ } // Prevent the browser to format something when we have multiselection.
38
+
39
+
40
+ if ((_event$inputType = event.inputType) !== null && _event$inputType !== void 0 && _event$inputType.startsWith('format')) {
41
+ event.preventDefault();
42
+ }
43
+ }
44
+
32
45
  function onKeyDown(event) {
33
46
  if (event.defaultPrevented) {
34
47
  return;
@@ -93,9 +106,11 @@ export default function useInput() {
93
106
  }
94
107
  }
95
108
 
109
+ node.addEventListener('beforeinput', onBeforeInput);
96
110
  node.addEventListener('keydown', onKeyDown);
97
111
  node.addEventListener('compositionstart', onCompositionStart);
98
112
  return () => {
113
+ node.removeEventListener('beforeinput', onBeforeInput);
99
114
  node.removeEventListener('keydown', onKeyDown);
100
115
  node.removeEventListener('compositionstart', onCompositionStart);
101
116
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-input.js"],"names":["useSelect","useDispatch","useRefEffect","ENTER","BACKSPACE","DELETE","createBlock","getDefaultBlockName","store","blockEditorStore","useInput","__unstableIsFullySelected","getSelectedBlockClientIds","__unstableIsSelectionMergeable","hasMultiSelection","replaceBlocks","__unstableSplitSelection","removeBlocks","__unstableDeleteSelection","__unstableExpandSelection","node","onKeyDown","event","defaultPrevented","keyCode","contentEditable","preventDefault","key","length","metaKey","ctrlKey","ownerDocument","defaultView","getSelection","removeAllRanges","onCompositionStart","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,KAAT,EAAgBC,SAAhB,EAA2BC,MAA3B,QAAyC,qBAAzC;AACA,SAASC,WAAT,EAAsBC,mBAAtB,QAAiD,mBAAjD;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;;AACA,eAAe,SAASC,QAAT,GAAoB;AAClC,QAAM;AACLC,IAAAA,yBADK;AAELC,IAAAA,yBAFK;AAGLC,IAAAA,8BAHK;AAILC,IAAAA;AAJK,MAKFd,SAAS,CAAES,gBAAF,CALb;AAMA,QAAM;AACLM,IAAAA,aADK;AAELC,IAAAA,wBAFK;AAGLC,IAAAA,YAHK;AAILC,IAAAA,yBAJK;AAKLC,IAAAA;AALK,MAMFlB,WAAW,CAAEQ,gBAAF,CANf;AAQA,SAAOP,YAAY,CAAIkB,IAAF,IAAY;AAChC,aAASC,SAAT,CAAoBC,KAApB,EAA4B;AAC3B,UAAKA,KAAK,CAACC,gBAAX,EAA8B;AAC7B;AACA;;AAED,UAAK,CAAET,iBAAiB,EAAxB,EAA6B;AAC5B;AACA;;AAED,UAAKQ,KAAK,CAACE,OAAN,KAAkBrB,KAAvB,EAA+B;AAC9BiB,QAAAA,IAAI,CAACK,eAAL,GAAuB,KAAvB;AACAH,QAAAA,KAAK,CAACI,cAAN;;AACA,YAAKf,yBAAyB,EAA9B,EAAmC;AAClCI,UAAAA,aAAa,CACZH,yBAAyB,EADb,EAEZN,WAAW,CAAEC,mBAAmB,EAArB,CAFC,CAAb;AAIA,SALD,MAK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aAAL,CAAmBC,WAAnB,CAA+BC,YAA/B,GAA8CC,eAA9C;AACA;AACD;;AAEDd,IAAAA,IAAI,CAACgB,gBAAL,CAAuB,SAAvB,EAAkCf,SAAlC;AACAD,IAAAA,IAAI,CAACgB,gBAAL,CAAuB,kBAAvB,EAA2CD,kBAA3C;AACA,WAAO,MAAM;AACZf,MAAAA,IAAI,CAACiB,mBAAL,CAA0B,SAA1B,EAAqChB,SAArC;AACAD,MAAAA,IAAI,CAACiB,mBAAL,CAA0B,kBAA1B,EAA8CF,kBAA9C;AACA,KAHD;AAIA,GA/EkB,EA+EhB,EA/EgB,CAAnB;AAgFA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Handles input for selections across blocks.\n */\nexport default function useInput() {\n\tconst {\n\t\t__unstableIsFullySelected,\n\t\tgetSelectedBlockClientIds,\n\t\t__unstableIsSelectionMergeable,\n\t\thasMultiSelection,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\treplaceBlocks,\n\t\t__unstableSplitSelection,\n\t\tremoveBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t} = useDispatch( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tgetSelectedBlockClientIds(),\n\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\t\tevent.keyCode === DELETE\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\tremoveBlocks( getSelectedBlockClientIds() );\n\t\t\t\t} else if ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t// If key.length is longer than 1, it's a control key that doesn't\n\t\t\t\t// input anything.\n\t\t\t\tevent.key.length === 1 &&\n\t\t\t\t! ( event.metaKey || event.ctrlKey )\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction onCompositionStart( event ) {\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tnode.contentEditable = false;\n\n\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t__unstableDeleteSelection();\n\t\t\t} else {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\tnode.ownerDocument.defaultView.getSelection().removeAllRanges();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'compositionstart', onCompositionStart );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'compositionstart', onCompositionStart );\n\t\t};\n\t}, [] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-input.js"],"names":["useSelect","useDispatch","useRefEffect","ENTER","BACKSPACE","DELETE","createBlock","getDefaultBlockName","store","blockEditorStore","useInput","__unstableIsFullySelected","getSelectedBlockClientIds","__unstableIsSelectionMergeable","hasMultiSelection","replaceBlocks","__unstableSplitSelection","removeBlocks","__unstableDeleteSelection","__unstableExpandSelection","node","onBeforeInput","event","inputType","startsWith","preventDefault","onKeyDown","defaultPrevented","keyCode","contentEditable","key","length","metaKey","ctrlKey","ownerDocument","defaultView","getSelection","removeAllRanges","onCompositionStart","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,KAAT,EAAgBC,SAAhB,EAA2BC,MAA3B,QAAyC,qBAAzC;AACA,SAASC,WAAT,EAAsBC,mBAAtB,QAAiD,mBAAjD;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;;AACA,eAAe,SAASC,QAAT,GAAoB;AAClC,QAAM;AACLC,IAAAA,yBADK;AAELC,IAAAA,yBAFK;AAGLC,IAAAA,8BAHK;AAILC,IAAAA;AAJK,MAKFd,SAAS,CAAES,gBAAF,CALb;AAMA,QAAM;AACLM,IAAAA,aADK;AAELC,IAAAA,wBAFK;AAGLC,IAAAA,YAHK;AA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1B,EAA8CF,kBAA9C;AACA,KAJD;AAKA,GA3FkB,EA2FhB,EA3FgB,CAAnB;AA4FA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Handles input for selections across blocks.\n */\nexport default function useInput() {\n\tconst {\n\t\t__unstableIsFullySelected,\n\t\tgetSelectedBlockClientIds,\n\t\t__unstableIsSelectionMergeable,\n\t\thasMultiSelection,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\treplaceBlocks,\n\t\t__unstableSplitSelection,\n\t\tremoveBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t} = useDispatch( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onBeforeInput( event ) {\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Prevent the browser to format something when we have multiselection.\n\t\t\tif ( event.inputType?.startsWith( 'format' ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tgetSelectedBlockClientIds(),\n\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\t\tevent.keyCode === DELETE\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\tremoveBlocks( getSelectedBlockClientIds() );\n\t\t\t\t} else if ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t// If key.length is longer than 1, it's a control key that doesn't\n\t\t\t\t// input anything.\n\t\t\t\tevent.key.length === 1 &&\n\t\t\t\t! ( event.metaKey || event.ctrlKey )\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction onCompositionStart( event ) {\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tnode.contentEditable = false;\n\n\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t__unstableDeleteSelection();\n\t\t\t} else {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\tnode.ownerDocument.defaultView.getSelection().removeAllRanges();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'beforeinput', onBeforeInput );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'compositionstart', onCompositionStart );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'beforeinput', onBeforeInput );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'compositionstart', onCompositionStart );\n\t\t};\n\t}, [] );\n}\n"]}
@@ -88,7 +88,8 @@ export default function useSelectionObserver() {
88
88
  selectionChange
89
89
  } = useDispatch(blockEditorStore);
90
90
  const {
91
- getBlockParents
91
+ getBlockParents,
92
+ getBlockSelectionStart
92
93
  } = useSelect(blockEditorStore);
93
94
  return useRefEffect(node => {
94
95
  const {
@@ -98,23 +99,63 @@ export default function useSelectionObserver() {
98
99
  defaultView
99
100
  } = ownerDocument;
100
101
 
101
- function onSelectionChange() {
102
+ function onSelectionChange(event) {
102
103
  const selection = defaultView.getSelection(); // If no selection is found, end multi selection and disable the
103
104
  // contentEditable wrapper.
104
105
 
105
- if (!selection.rangeCount || selection.isCollapsed) {
106
+ if (!selection.rangeCount) {
107
+ setContentEditableWrapper(node, false);
108
+ return;
109
+ } // If selection is collapsed and we haven't used `shift+click`,
110
+ // end multi selection and disable the contentEditable wrapper.
111
+ // We have to check about `shift+click` case because elements
112
+ // that don't support text selection might be involved, and we might
113
+ // update the clientIds to multi-select blocks.
114
+ // For now we check if the event is a `mouse` event.
115
+
116
+
117
+ const isClickShift = event.shiftKey && event.type === 'mouseup';
118
+
119
+ if (selection.isCollapsed && !isClickShift) {
120
+ setContentEditableWrapper(node, false);
121
+ return;
122
+ }
123
+
124
+ let startClientId = getBlockClientId(extractSelectionStartNode(selection));
125
+ let endClientId = getBlockClientId(extractSelectionEndNode(selection)); // If the selection has changed and we had pressed `shift+click`,
126
+ // we need to check if in an element that doesn't support
127
+ // text selection has been clicked.
128
+
129
+ if (isClickShift) {
130
+ const selectedClientId = getBlockSelectionStart();
131
+ const clickedClientId = getBlockClientId(event.target); // `endClientId` is not defined if we end the selection by clicking a non-selectable block.
132
+ // We need to check if there was already a selection with a non-selectable focusNode.
133
+
134
+ const focusNodeIsNonSelectable = clickedClientId !== endClientId;
135
+
136
+ if (startClientId === endClientId && selection.isCollapsed || !endClientId || focusNodeIsNonSelectable) {
137
+ endClientId = clickedClientId;
138
+ } // Handle the case when we have a non-selectable block
139
+ // selected and click another one.
140
+
141
+
142
+ if (startClientId !== selectedClientId) {
143
+ startClientId = selectedClientId;
144
+ }
145
+ } // If the selection did not involve a block, return.
146
+
147
+
148
+ if (startClientId === undefined && endClientId === undefined) {
106
149
  setContentEditableWrapper(node, false);
107
150
  return;
108
151
  }
109
152
 
110
- const clientId = getBlockClientId(extractSelectionStartNode(selection));
111
- const endClientId = getBlockClientId(extractSelectionEndNode(selection));
112
- const isSingularSelection = clientId === endClientId;
153
+ const isSingularSelection = startClientId === endClientId;
113
154
 
114
155
  if (isSingularSelection) {
115
- selectBlock(clientId);
156
+ selectBlock(startClientId);
116
157
  } else {
117
- const startPath = [...getBlockParents(clientId), clientId];
158
+ const startPath = [...getBlockParents(startClientId), startClientId];
118
159
  const endPath = [...getBlockParents(endClientId), endClientId];
119
160
  const depth = findDepth(startPath, endPath);
120
161
  multiSelect(startPath[depth], endPath[depth]);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-selection-observer.js"],"names":["useSelect","useDispatch","useRefEffect","store","blockEditorStore","getBlockClientId","extractSelectionStartNode","selection","anchorNode","anchorOffset","nodeType","TEXT_NODE","childNodes","extractSelectionEndNode","focusNode","focusOffset","findDepth","a","b","depth","setContentEditableWrapper","node","value","contentEditable","focus","useSelectionObserver","multiSelect","selectBlock","selectionChange","getBlockParents","ownerDocument","defaultView","onSelectionChange","getSelection","rangeCount","isCollapsed","clientId","endClientId","isSingularSelection","startPath","endPath","addListeners","addEventListener","removeListeners","removeEventListener","resetListeners"],"mappings":"AAAA;AACA;AACA;AACA,SAASA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AT,GAAwB;AACvBX,MAAAA,aAAa,CAACY,gBAAd,CACC,iBADD,EAECV,iBAFD;AAIAD,MAAAA,WAAW,CAACW,gBAAZ,CAA8B,SAA9B,EAAyCV,iBAAzC;AACA;;AAED,aAASW,eAAT,GAA2B;AAC1Bb,MAAAA,aAAa,CAACc,mBAAd,CACC,iBADD,EAECZ,iBAFD;AAIAD,MAAAA,WAAW,CAACa,mBAAZ,CAAiC,SAAjC,EAA4CZ,iBAA5C;AACA;;AAED,aAASa,cAAT,GAA0B;AACzBF,MAAAA,eAAe;AACfF,MAAAA,YAAY;AACZ;;AAEDA,IAAAA,YAAY,GA5DD,CA6DX;AACA;AACA;;AACApB,IAAAA,IAAI,CAACqB,gBAAL,CAAuB,SAAvB,EAAkCG,cAAlC;AACA,WAAO,MAAM;AACZF,MAAAA,eAAe;AACftB,MAAAA,IAAI,CAACuB,mBAAL,CAA0B,SAA1B,EAAqCC,cAArC;AACA,KAHD;AAIA,GAtEiB,EAuElB,CAAEnB,WAAF,EAAeC,WAAf,EAA4BC,eAA5B,EAA6CC,eAA7C,CAvEkB,CAAnB;AAyEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\n\n/**\n * Extract the selection start node from the selection. When the anchor node is\n * not a text node, the selection offset is the index of a child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionStartNode( selection ) {\n\tconst { anchorNode, anchorOffset } = selection;\n\n\tif ( anchorNode.nodeType === anchorNode.TEXT_NODE ) {\n\t\treturn anchorNode;\n\t}\n\n\treturn anchorNode.childNodes[ anchorOffset ];\n}\n\n/**\n * Extract the selection end node from the selection. When the focus node is not\n * a text node, the selection offset is the index of a child node. The selection\n * reaches up to but excluding that child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionEndNode( selection ) {\n\tconst { focusNode, focusOffset } = selection;\n\n\tif ( focusNode.nodeType === focusNode.TEXT_NODE ) {\n\t\treturn focusNode;\n\t}\n\n\treturn focusNode.childNodes[ focusOffset - 1 ];\n}\n\nfunction findDepth( a, b ) {\n\tlet depth = 0;\n\n\twhile ( a[ depth ] === b[ depth ] ) {\n\t\tdepth++;\n\t}\n\n\treturn depth;\n}\n\n/**\n * Sets the `contenteditable` wrapper element to `value`.\n *\n * @param {HTMLElement} node Block element.\n * @param {boolean} value `contentEditable` value (true or false)\n */\nfunction setContentEditableWrapper( node, value ) {\n\tnode.contentEditable = value;\n\t// Firefox doesn't automatically move focus.\n\tif ( value ) node.focus();\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useSelectionObserver() {\n\tconst { multiSelect, selectBlock, selectionChange } = useDispatch(\n\t\tblockEditorStore\n\t);\n\tconst { getBlockParents } = useSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tfunction onSelectionChange() {\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\t// If no selection is found, end multi selection and disable the\n\t\t\t\t// contentEditable wrapper.\n\t\t\t\tif ( ! selection.rangeCount || selection.isCollapsed ) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst clientId = getBlockClientId(\n\t\t\t\t\textractSelectionStartNode( selection )\n\t\t\t\t);\n\t\t\t\tconst endClientId = getBlockClientId(\n\t\t\t\t\textractSelectionEndNode( selection )\n\t\t\t\t);\n\t\t\t\tconst isSingularSelection = clientId === endClientId;\n\n\t\t\t\tif ( isSingularSelection ) {\n\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t} else {\n\t\t\t\t\tconst startPath = [\n\t\t\t\t\t\t...getBlockParents( clientId ),\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst endPath = [\n\t\t\t\t\t\t...getBlockParents( endClientId ),\n\t\t\t\t\t\tendClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst depth = findDepth( startPath, endPath );\n\n\t\t\t\t\tmultiSelect( startPath[ depth ], endPath[ depth ] );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction addListeners() {\n\t\t\t\townerDocument.addEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.addEventListener( 'mouseup', onSelectionChange );\n\t\t\t}\n\n\t\t\tfunction removeListeners() {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onSelectionChange );\n\t\t\t}\n\n\t\t\tfunction resetListeners() {\n\t\t\t\tremoveListeners();\n\t\t\t\taddListeners();\n\t\t\t}\n\n\t\t\taddListeners();\n\t\t\t// We must allow rich text to set selection first. This ensures that\n\t\t\t// our `selectionchange` listener is always reset to be called after\n\t\t\t// the rich text one.\n\t\t\tnode.addEventListener( 'focusin', resetListeners );\n\t\t\treturn () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tnode.removeEventListener( 'focusin', resetListeners );\n\t\t\t};\n\t\t},\n\t\t[ multiSelect, selectBlock, selectionChange, getBlockParents ]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-selection-observer.js"],"names":["useSelect","useDispatch","useRefEffect","store","blockEditorStore","getBlockClientId","extractSelectionStartNode","selection","anchorNode","anchorOffset","nodeType","TEXT_NODE","childNodes","extractSelectionEndNode","focusNode","focusOffset","findDepth","a","b","depth","setContentEditableWrapper","node","value","contentEditable","focus","useSelectionObserver","multiSelect","selectBlock","selectionChange","getBlockParents","getBlockSelectionStart","ownerDocument","defaultView","onSelectionChange","event","getSelection","rangeCount","isClickShift","shiftKey","type","isCollapsed","startClientId","endClientId","selectedClientId","clickedClientId","target","focusNodeIsNonSelectable","undefined","isSingularSelection","startPath","endPath","addListeners","addEventListener","removeListeners","removeEventListener","resetListeners"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,gBAAT,QAAiC,iBAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,yBAAT,CAAoCC,SAApC,EAAgD;AAC/C,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA+BF,SAArC;;AAEA,MAAKC,UAAU,CAACE,QAAX,KAAwBF,UAAU,CAACG,SAAxC,EAAoD;AACnD,WAAOH,UAAP;AACA;;AAED,SAAOA,UAAU,CAACI,UAAX,CAAuBH,YAAvB,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASI,uBAAT,CAAkCN,SAAlC,EAA8C;AAC7C,QAAM;AAAEO,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA6BR,SAAnC;;AAEA,MAAKO,SAAS,CAACJ,QAAV,KAAuBI,SAAS,CAACH,SAAtC,EAAkD;AACjD,WAAOG,SAAP;AACA;;AAED,SAAOA,SAAS,CAACF,UAAV,CAAsBG,WAAW,GAAG,CAApC,CAAP;AACA;;AAED,SAASC,SAAT,CAAoBC,CAApB,EAAuBC,CAAvB,EAA2B;AAC1B,MAAIC,KAAK,GAAG,CAAZ;;AAEA,SAAQF,CAAC,CAAEE,KAAF,CAAD,KAAeD,CAAC,CAAEC,KAAF,CAAxB,EAAoC;AACnCA,IAAAA,KAAK;AACL;;AAED,SAAOA,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA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iBAAzC;AACA;;AAED,aAASoB,eAAT,GAA2B;AAC1BtB,MAAAA,aAAa,CAACuB,mBAAd,CACC,iBADD,EAECrB,iBAFD;AAIAD,MAAAA,WAAW,CAACsB,mBAAZ,CAAiC,SAAjC,EAA4CrB,iBAA5C;AACA;;AAED,aAASsB,cAAT,GAA0B;AACzBF,MAAAA,eAAe;AACfF,MAAAA,YAAY;AACZ;;AAEDA,IAAAA,YAAY,GAvGD,CAwGX;AACA;AACA;;AACA9B,IAAAA,IAAI,CAAC+B,gBAAL,CAAuB,SAAvB,EAAkCG,cAAlC;AACA,WAAO,MAAM;AACZF,MAAAA,eAAe;AACfhC,MAAAA,IAAI,CAACiC,mBAAL,CAA0B,SAA1B,EAAqCC,cAArC;AACA,KAHD;AAIA,GAjHiB,EAkHlB,CAAE7B,WAAF,EAAeC,WAAf,EAA4BC,eAA5B,EAA6CC,eAA7C,CAlHkB,CAAnB;AAoHA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\n\n/**\n * Extract the selection start node from the selection. When the anchor node is\n * not a text node, the selection offset is the index of a child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionStartNode( selection ) {\n\tconst { anchorNode, anchorOffset } = selection;\n\n\tif ( anchorNode.nodeType === anchorNode.TEXT_NODE ) {\n\t\treturn anchorNode;\n\t}\n\n\treturn anchorNode.childNodes[ anchorOffset ];\n}\n\n/**\n * Extract the selection end node from the selection. When the focus node is not\n * a text node, the selection offset is the index of a child node. The selection\n * reaches up to but excluding that child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionEndNode( selection ) {\n\tconst { focusNode, focusOffset } = selection;\n\n\tif ( focusNode.nodeType === focusNode.TEXT_NODE ) {\n\t\treturn focusNode;\n\t}\n\n\treturn focusNode.childNodes[ focusOffset - 1 ];\n}\n\nfunction findDepth( a, b ) {\n\tlet depth = 0;\n\n\twhile ( a[ depth ] === b[ depth ] ) {\n\t\tdepth++;\n\t}\n\n\treturn depth;\n}\n\n/**\n * Sets the `contenteditable` wrapper element to `value`.\n *\n * @param {HTMLElement} node Block element.\n * @param {boolean} value `contentEditable` value (true or false)\n */\nfunction setContentEditableWrapper( node, value ) {\n\tnode.contentEditable = value;\n\t// Firefox doesn't automatically move focus.\n\tif ( value ) node.focus();\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useSelectionObserver() {\n\tconst { multiSelect, selectBlock, selectionChange } = useDispatch(\n\t\tblockEditorStore\n\t);\n\tconst { getBlockParents, getBlockSelectionStart } = useSelect(\n\t\tblockEditorStore\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\tfunction onSelectionChange( event ) {\n\t\t\t\tconst selection = defaultView.getSelection();\n\t\t\t\t// If no selection is found, end multi selection and disable the\n\t\t\t\t// contentEditable wrapper.\n\t\t\t\tif ( ! selection.rangeCount ) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// If selection is collapsed and we haven't used `shift+click`,\n\t\t\t\t// end multi selection and disable the contentEditable wrapper.\n\t\t\t\t// We have to check about `shift+click` case because elements\n\t\t\t\t// that don't support text selection might be involved, and we might\n\t\t\t\t// update the clientIds to multi-select blocks.\n\t\t\t\t// For now we check if the event is a `mouse` event.\n\t\t\t\tconst isClickShift = event.shiftKey && event.type === 'mouseup';\n\t\t\t\tif ( selection.isCollapsed && ! isClickShift ) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet startClientId = getBlockClientId(\n\t\t\t\t\textractSelectionStartNode( selection )\n\t\t\t\t);\n\t\t\t\tlet endClientId = getBlockClientId(\n\t\t\t\t\textractSelectionEndNode( selection )\n\t\t\t\t);\n\t\t\t\t// If the selection has changed and we had pressed `shift+click`,\n\t\t\t\t// we need to check if in an element that doesn't support\n\t\t\t\t// text selection has been clicked.\n\t\t\t\tif ( isClickShift ) {\n\t\t\t\t\tconst selectedClientId = getBlockSelectionStart();\n\t\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\t\t\t\t\t// `endClientId` is not defined if we end the selection by clicking a non-selectable block.\n\t\t\t\t\t// We need to check if there was already a selection with a non-selectable focusNode.\n\t\t\t\t\tconst focusNodeIsNonSelectable =\n\t\t\t\t\t\tclickedClientId !== endClientId;\n\t\t\t\t\tif (\n\t\t\t\t\t\t( startClientId === endClientId &&\n\t\t\t\t\t\t\tselection.isCollapsed ) ||\n\t\t\t\t\t\t! endClientId ||\n\t\t\t\t\t\tfocusNodeIsNonSelectable\n\t\t\t\t\t) {\n\t\t\t\t\t\tendClientId = clickedClientId;\n\t\t\t\t\t}\n\t\t\t\t\t// Handle the case when we have a non-selectable block\n\t\t\t\t\t// selected and click another one.\n\t\t\t\t\tif ( startClientId !== selectedClientId ) {\n\t\t\t\t\t\tstartClientId = selectedClientId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If the selection did not involve a block, return.\n\t\t\t\tif (\n\t\t\t\t\tstartClientId === undefined &&\n\t\t\t\t\tendClientId === undefined\n\t\t\t\t) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst isSingularSelection = startClientId === endClientId;\n\t\t\t\tif ( isSingularSelection ) {\n\t\t\t\t\tselectBlock( startClientId );\n\t\t\t\t} else {\n\t\t\t\t\tconst startPath = [\n\t\t\t\t\t\t...getBlockParents( startClientId ),\n\t\t\t\t\t\tstartClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst endPath = [\n\t\t\t\t\t\t...getBlockParents( endClientId ),\n\t\t\t\t\t\tendClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst depth = findDepth( startPath, endPath );\n\n\t\t\t\t\tmultiSelect( startPath[ depth ], endPath[ depth ] );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction addListeners() {\n\t\t\t\townerDocument.addEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.addEventListener( 'mouseup', onSelectionChange );\n\t\t\t}\n\n\t\t\tfunction removeListeners() {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onSelectionChange );\n\t\t\t}\n\n\t\t\tfunction resetListeners() {\n\t\t\t\tremoveListeners();\n\t\t\t\taddListeners();\n\t\t\t}\n\n\t\t\taddListeners();\n\t\t\t// We must allow rich text to set selection first. This ensures that\n\t\t\t// our `selectionchange` listener is always reset to be called after\n\t\t\t// the rich text one.\n\t\t\tnode.addEventListener( 'focusin', resetListeners );\n\t\t\treturn () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tnode.removeEventListener( 'focusin', resetListeners );\n\t\t\t};\n\t\t},\n\t\t[ multiSelect, selectBlock, selectionChange, getBlockParents ]\n\t);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export const __experimentalElementButtonClassName = 'wp-element-button';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/elements/index.js"],"names":["__experimentalElementButtonClassName"],"mappings":"AAAA,OAAO,MAAMA,oCAAoC,GAAG,mBAA7C","sourcesContent":["export const __experimentalElementButtonClassName = 'wp-element-button';\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"names":["has","addFilter","PanelBody","TextControl","ExternalLink","__","hasBlockSupport","createHigherOrderComponent","Platform","InspectorControls","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","attributes","anchor","withInspectorControl","BlockEdit","props","hasAnchor","name","isSelected","isWeb","OS","textControl","nextValue","replace","setAttributes","addSaveProps","extraProps","blockType","id"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,YAAjC,QAAqD,uBAArD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,QAAkC,eAAlC;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,YAAY,GAAG,QAArB;AAEA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,IAAI,EAAE,QADe;AAErBC,EAAAA,MAAM,EAAE,WAFa;AAGrBC,EAAAA,SAAS,EAAE,IAHU;AAIrBC,EAAAA,QAAQ,EAAE;AAJW,CAAtB;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,YAAT,CAAuBC,QAAvB,EAAkC;AACxC;AACA,MAAKjB,GAAG,CAAEiB,QAAQ,CAACC,UAAX,EAAuB,CAAE,QAAF,EAAY,MAAZ,CAAvB,CAAR,EAAwD;AACvD,WAAOD,QAAP;AACA;;AACD,MAAKX,eAAe,CAAEW,QAAF,EAAY,QAAZ,CAApB,EAA6C;AAC5C;AACAA,IAAAA,QAAQ,CAACC,UAAT,GAAsB,EACrB,GAAGD,QAAQ,CAACC,UADS;AAErBC,MAAAA,MAAM,EAAER;AAFa,KAAtB;AAIA;;AAED,SAAOM,QAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMG,oBAAoB,GAAGb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A,KAAK,EAAGnB,EAAE,CAAE,kBAAF;AAArB,SACGuB,WADH,CADD,CAdF,CADD;AAuBA;;AAED,WAAO,cAAC,SAAD,EAAgBN,KAAhB,CAAP;AACA,GAjED;AAkEA,CApE4D,EAqE7D,sBArE6D,CAAvD;AAwEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASU,YAAT,CAAuBC,UAAvB,EAAmCC,SAAnC,EAA8ChB,UAA9C,EAA2D;AACjE,MAAKZ,eAAe,CAAE4B,SAAF,EAAa,QAAb,CAApB,EAA8C;AAC7CD,IAAAA,UAAU,CAACE,EAAX,GAAgBjB,UAAU,CAACC,MAAX,KAAsB,EAAtB,GAA2B,IAA3B,GAAkCD,UAAU,CAACC,MAA7D;AACA;;AAED,SAAOc,UAAP;AACA;AAEDhC,SAAS,CAAE,0BAAF,EAA8B,uBAA9B,EAAuDe,YAAvD,CAAT;AACAf,SAAS,CACR,kBADQ,EAER,2CAFQ,EAGRmB,oBAHQ,CAAT;AAKAnB,SAAS,CACR,kCADQ,EAER,wBAFQ,EAGR+B,YAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport { has } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( has( settings.attributes, [ 'anchor', 'type' ] ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the anchor ID, if block supports anchor.\n *\n * @param {WPComponent} BlockEdit Original component.\n *\n * @return {WPComponent} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasAnchor = hasBlockSupport( props.name, 'anchor' );\n\n\t\t\tif ( hasAnchor && props.isSelected ) {\n\t\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\t\tconst textControl = (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/page-jumps/'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ props.attributes.anchor || '' }\n\t\t\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t\t\t\t * PanelBody title. https://git.io/Jtcov\n\t\t\t\t\t\t */ }\n\t\t\t\t\t\t{ ! isWeb && props.name === 'core/heading' && (\n\t\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/anchor/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/anchor/save-props',\n\taddSaveProps\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"names":["has","addFilter","PanelBody","TextControl","ExternalLink","__","hasBlockSupport","createHigherOrderComponent","Platform","InspectorControls","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","attributes","anchor","withInspectorControl","BlockEdit","props","hasAnchor","name","isSelected","isWeb","OS","textControl","nextValue","replace","setAttributes","addSaveProps","extraProps","blockType","id"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,YAAjC,QAAqD,uBAArD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,QAAkC,eAAlC;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,YAAY,GAAG,QAArB;AAEA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,IAAI,EAAE,QADe;AAErBC,EAAAA,MAAM,EAAE,WAFa;AAGrBC,EAAAA,SAAS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GR+B,YAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport { has } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( has( settings.attributes, [ 'anchor', 'type' ] ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the anchor ID, if block supports anchor.\n *\n * @param {WPComponent} BlockEdit Original component.\n *\n * @return {WPComponent} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasAnchor = hasBlockSupport( props.name, 'anchor' );\n\n\t\t\tif ( hasAnchor && props.isSelected ) {\n\t\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\t\tconst textControl = (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/page-jumps/'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ props.attributes.anchor || '' }\n\t\t\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t\t\t\t * PanelBody title. https://github.com/WordPress/gutenberg/issues/28363\n\t\t\t\t\t\t */ }\n\t\t\t\t\t\t{ ! isWeb && props.name === 'core/heading' && (\n\t\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/anchor/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/anchor/save-props',\n\taddSaveProps\n);\n"]}