@wordpress/block-editor 8.3.0 → 8.5.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 (443) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +56 -18
  3. package/build/components/alignment-control/index.js +13 -6
  4. package/build/components/alignment-control/index.js.map +1 -1
  5. package/build/components/block-alignment-control/index.js +13 -6
  6. package/build/components/block-alignment-control/index.js.map +1 -1
  7. package/build/components/block-draggable/index.js +2 -3
  8. package/build/components/block-draggable/index.js.map +1 -1
  9. package/build/components/block-icon/index.js +4 -0
  10. package/build/components/block-icon/index.js.map +1 -1
  11. package/build/components/block-inspector/index.js +6 -1
  12. package/build/components/block-inspector/index.js.map +1 -1
  13. package/build/components/block-list/block-html.js +4 -1
  14. package/build/components/block-list/block-html.js.map +1 -1
  15. package/build/components/block-list/block.js +4 -1
  16. package/build/components/block-list/block.js.map +1 -1
  17. package/build/components/block-list/use-block-props/index.js +1 -6
  18. package/build/components/block-list/use-block-props/index.js.map +1 -1
  19. package/build/components/block-list/use-block-props/use-focus-first-element.js +22 -6
  20. package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  21. package/build/components/block-list/use-block-props/use-focus-handler.js +7 -1
  22. package/build/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  23. package/build/components/block-list-appender/index.js +6 -1
  24. package/build/components/block-list-appender/index.js.map +1 -1
  25. package/build/components/block-lock/index.js +32 -0
  26. package/build/components/block-lock/index.js.map +1 -0
  27. package/build/components/block-lock/menu-item.js +67 -0
  28. package/build/components/block-lock/menu-item.js.map +1 -0
  29. package/build/components/block-lock/modal.js +134 -0
  30. package/build/components/block-lock/modal.js.map +1 -0
  31. package/build/components/block-lock/toolbar.js +78 -0
  32. package/build/components/block-lock/toolbar.js.map +1 -0
  33. package/build/components/block-mover/index.js +4 -0
  34. package/build/components/block-mover/index.js.map +1 -1
  35. package/build/components/block-settings-menu/block-settings-dropdown.js +75 -10
  36. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  37. package/build/components/block-settings-menu-controls/index.js +19 -9
  38. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  39. package/build/components/block-switcher/index.js +1 -1
  40. package/build/components/block-switcher/index.js.map +1 -1
  41. package/build/components/block-title/index.js +2 -2
  42. package/build/components/block-title/index.js.map +1 -1
  43. package/build/components/block-title/use-block-display-title.js +8 -6
  44. package/build/components/block-title/use-block-display-title.js.map +1 -1
  45. package/build/components/block-toolbar/block-name-context.js +17 -0
  46. package/build/components/block-toolbar/block-name-context.js.map +1 -0
  47. package/build/components/block-toolbar/block-toolbar-last-item.js +20 -0
  48. package/build/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
  49. package/build/components/block-toolbar/index.js +24 -5
  50. package/build/components/block-toolbar/index.js.map +1 -1
  51. package/build/components/block-tools/index.js +0 -16
  52. package/build/components/block-tools/index.js.map +1 -1
  53. package/build/components/block-variation-transforms/index.js +92 -47
  54. package/build/components/block-variation-transforms/index.js.map +1 -1
  55. package/build/components/block-vertical-alignment-control/index.js +13 -6
  56. package/build/components/block-vertical-alignment-control/index.js.map +1 -1
  57. package/build/components/border-radius-control/index.js +0 -1
  58. package/build/components/border-radius-control/index.js.map +1 -1
  59. package/build/components/border-radius-control/utils.js +1 -1
  60. package/build/components/border-radius-control/utils.js.map +1 -1
  61. package/build/components/colors-gradients/control.js +3 -1
  62. package/build/components/colors-gradients/control.js.map +1 -1
  63. package/build/components/contrast-checker/index.js +4 -0
  64. package/build/components/contrast-checker/index.js.map +1 -1
  65. package/build/components/convert-to-group-buttons/index.js +8 -0
  66. package/build/components/convert-to-group-buttons/index.js.map +1 -1
  67. package/build/components/convert-to-group-buttons/toolbar.js +105 -0
  68. package/build/components/convert-to-group-buttons/toolbar.js.map +1 -0
  69. package/build/components/copy-handler/index.js +4 -0
  70. package/build/components/copy-handler/index.js.map +1 -1
  71. package/build/components/date-format-picker/index.js +132 -0
  72. package/build/components/date-format-picker/index.js.map +1 -0
  73. package/build/components/font-sizes/font-size-picker.js +4 -0
  74. package/build/components/font-sizes/font-size-picker.js.map +1 -1
  75. package/build/components/iframe/index.js +6 -9
  76. package/build/components/iframe/index.js.map +1 -1
  77. package/build/components/index.js +27 -0
  78. package/build/components/index.js.map +1 -1
  79. package/build/components/justify-content-control/index.js +13 -6
  80. package/build/components/justify-content-control/index.js.map +1 -1
  81. package/build/components/keyboard-shortcuts/index.js +1 -1
  82. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  83. package/build/components/line-height-control/index.js +15 -6
  84. package/build/components/line-height-control/index.js.map +1 -1
  85. package/build/components/list-view/block-select-button.js +24 -23
  86. package/build/components/list-view/block-select-button.js.map +1 -1
  87. package/build/components/list-view/block.js +38 -13
  88. package/build/components/list-view/block.js.map +1 -1
  89. package/build/components/list-view/branch.js +16 -13
  90. package/build/components/list-view/branch.js.map +1 -1
  91. package/build/components/list-view/index.js +7 -1
  92. package/build/components/list-view/index.js.map +1 -1
  93. package/build/components/list-view/use-block-selection.js +9 -2
  94. package/build/components/list-view/use-block-selection.js.map +1 -1
  95. package/build/components/media-replace-flow/index.js +4 -0
  96. package/build/components/media-replace-flow/index.js.map +1 -1
  97. package/build/components/multi-selection-inspector/index.js +1 -1
  98. package/build/components/multi-selection-inspector/index.js.map +1 -1
  99. package/build/components/rich-text/index.js +27 -5
  100. package/build/components/rich-text/index.js.map +1 -1
  101. package/build/components/rich-text/index.native.js +13 -9
  102. package/build/components/rich-text/index.native.js.map +1 -1
  103. package/build/components/rich-text/split-value.js +12 -2
  104. package/build/components/rich-text/split-value.js.map +1 -1
  105. package/build/components/rich-text/use-firefox-compat.js +49 -0
  106. package/build/components/rich-text/use-firefox-compat.js.map +1 -0
  107. package/build/components/rich-text/use-input-rules.js +34 -2
  108. package/build/components/rich-text/use-input-rules.js.map +1 -1
  109. package/build/components/skip-to-selected-block/index.js +4 -0
  110. package/build/components/skip-to-selected-block/index.js.map +1 -1
  111. package/build/components/url-popover/image-url-input-ui.js +11 -27
  112. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  113. package/build/components/writing-flow/index.js +9 -1
  114. package/build/components/writing-flow/index.js.map +1 -1
  115. package/build/components/writing-flow/use-arrow-nav.js +3 -44
  116. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  117. package/build/components/writing-flow/use-click-selection.js +68 -0
  118. package/build/components/writing-flow/use-click-selection.js.map +1 -0
  119. package/build/components/writing-flow/use-drag-selection.js +134 -0
  120. package/build/components/writing-flow/use-drag-selection.js.map +1 -0
  121. package/build/components/writing-flow/use-input.js +116 -0
  122. package/build/components/writing-flow/use-input.js.map +1 -0
  123. package/build/components/writing-flow/use-multi-selection.js +18 -38
  124. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  125. package/build/components/writing-flow/use-selection-observer.js +161 -0
  126. package/build/components/writing-flow/use-selection-observer.js.map +1 -0
  127. package/build/components/writing-flow/use-tab-nav.js +1 -8
  128. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  129. package/build/hooks/anchor.js +7 -6
  130. package/build/hooks/anchor.js.map +1 -1
  131. package/build/hooks/border-color.js +3 -3
  132. package/build/hooks/border-color.js.map +1 -1
  133. package/build/hooks/border.js +0 -14
  134. package/build/hooks/border.js.map +1 -1
  135. package/build/hooks/color.js +20 -17
  136. package/build/hooks/color.js.map +1 -1
  137. package/build/hooks/font-family.js +5 -1
  138. package/build/hooks/font-family.js.map +1 -1
  139. package/build/hooks/font-size.js +4 -2
  140. package/build/hooks/font-size.js.map +1 -1
  141. package/build/hooks/gap.js +77 -5
  142. package/build/hooks/gap.js.map +1 -1
  143. package/build/hooks/layout.js +7 -2
  144. package/build/hooks/layout.js.map +1 -1
  145. package/build/hooks/style.js +34 -3
  146. package/build/hooks/style.js.map +1 -1
  147. package/build/hooks/utils.js +29 -0
  148. package/build/hooks/utils.js.map +1 -1
  149. package/build/layouts/flex.js +82 -15
  150. package/build/layouts/flex.js.map +1 -1
  151. package/build/layouts/flow.js +22 -13
  152. package/build/layouts/flow.js.map +1 -1
  153. package/build/store/actions.js +297 -51
  154. package/build/store/actions.js.map +1 -1
  155. package/build/store/defaults.js +5 -1
  156. package/build/store/defaults.js.map +1 -1
  157. package/build/store/reducer.js +25 -13
  158. package/build/store/reducer.js.map +1 -1
  159. package/build/store/selectors.js +171 -21
  160. package/build/store/selectors.js.map +1 -1
  161. package/build/utils/dom.js +2 -1
  162. package/build/utils/dom.js.map +1 -1
  163. package/build-module/components/alignment-control/index.js +12 -4
  164. package/build-module/components/alignment-control/index.js.map +1 -1
  165. package/build-module/components/block-alignment-control/index.js +12 -4
  166. package/build-module/components/block-alignment-control/index.js.map +1 -1
  167. package/build-module/components/block-draggable/index.js +2 -3
  168. package/build-module/components/block-draggable/index.js.map +1 -1
  169. package/build-module/components/block-icon/index.js +4 -0
  170. package/build-module/components/block-icon/index.js.map +1 -1
  171. package/build-module/components/block-inspector/index.js +6 -1
  172. package/build-module/components/block-inspector/index.js.map +1 -1
  173. package/build-module/components/block-list/block-html.js +5 -2
  174. package/build-module/components/block-list/block-html.js.map +1 -1
  175. package/build-module/components/block-list/block.js +5 -2
  176. package/build-module/components/block-list/block.js.map +1 -1
  177. package/build-module/components/block-list/use-block-props/index.js +1 -4
  178. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  179. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +22 -6
  180. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  181. package/build-module/components/block-list/use-block-props/use-focus-handler.js +7 -1
  182. package/build-module/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  183. package/build-module/components/block-list-appender/index.js +6 -1
  184. package/build-module/components/block-list-appender/index.js.map +1 -1
  185. package/build-module/components/block-lock/index.js +4 -0
  186. package/build-module/components/block-lock/index.js.map +1 -0
  187. package/build-module/components/block-lock/menu-item.js +53 -0
  188. package/build-module/components/block-lock/menu-item.js.map +1 -0
  189. package/build-module/components/block-lock/modal.js +119 -0
  190. package/build-module/components/block-lock/modal.js.map +1 -0
  191. package/build-module/components/block-lock/toolbar.js +63 -0
  192. package/build-module/components/block-lock/toolbar.js.map +1 -0
  193. package/build-module/components/block-mover/index.js +4 -0
  194. package/build-module/components/block-mover/index.js.map +1 -1
  195. package/build-module/components/block-settings-menu/block-settings-dropdown.js +75 -12
  196. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  197. package/build-module/components/block-settings-menu-controls/index.js +18 -9
  198. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  199. package/build-module/components/block-switcher/index.js +2 -2
  200. package/build-module/components/block-switcher/index.js.map +1 -1
  201. package/build-module/components/block-title/index.js +2 -2
  202. package/build-module/components/block-title/index.js.map +1 -1
  203. package/build-module/components/block-title/use-block-display-title.js +8 -6
  204. package/build-module/components/block-title/use-block-display-title.js.map +1 -1
  205. package/build-module/components/block-toolbar/block-name-context.js +9 -0
  206. package/build-module/components/block-toolbar/block-name-context.js.map +1 -0
  207. package/build-module/components/block-toolbar/block-toolbar-last-item.js +11 -0
  208. package/build-module/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
  209. package/build-module/components/block-toolbar/index.js +19 -4
  210. package/build-module/components/block-toolbar/index.js.map +1 -1
  211. package/build-module/components/block-tools/index.js +0 -16
  212. package/build-module/components/block-tools/index.js.map +1 -1
  213. package/build-module/components/block-variation-transforms/index.js +95 -49
  214. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  215. package/build-module/components/block-vertical-alignment-control/index.js +12 -4
  216. package/build-module/components/block-vertical-alignment-control/index.js.map +1 -1
  217. package/build-module/components/border-radius-control/index.js +0 -1
  218. package/build-module/components/border-radius-control/index.js.map +1 -1
  219. package/build-module/components/border-radius-control/utils.js +1 -1
  220. package/build-module/components/border-radius-control/utils.js.map +1 -1
  221. package/build-module/components/colors-gradients/control.js +3 -1
  222. package/build-module/components/colors-gradients/control.js.map +1 -1
  223. package/build-module/components/contrast-checker/index.js +4 -0
  224. package/build-module/components/contrast-checker/index.js.map +1 -1
  225. package/build-module/components/convert-to-group-buttons/index.js +2 -1
  226. package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
  227. package/build-module/components/convert-to-group-buttons/toolbar.js +90 -0
  228. package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -0
  229. package/build-module/components/copy-handler/index.js +4 -0
  230. package/build-module/components/copy-handler/index.js.map +1 -1
  231. package/build-module/components/date-format-picker/index.js +122 -0
  232. package/build-module/components/date-format-picker/index.js.map +1 -0
  233. package/build-module/components/font-sizes/font-size-picker.js +4 -0
  234. package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
  235. package/build-module/components/iframe/index.js +6 -9
  236. package/build-module/components/iframe/index.js.map +1 -1
  237. package/build-module/components/index.js +3 -0
  238. package/build-module/components/index.js.map +1 -1
  239. package/build-module/components/justify-content-control/index.js +12 -4
  240. package/build-module/components/justify-content-control/index.js.map +1 -1
  241. package/build-module/components/keyboard-shortcuts/index.js +1 -1
  242. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  243. package/build-module/components/line-height-control/index.js +14 -5
  244. package/build-module/components/line-height-control/index.js.map +1 -1
  245. package/build-module/components/list-view/block-select-button.js +24 -23
  246. package/build-module/components/list-view/block-select-button.js.map +1 -1
  247. package/build-module/components/list-view/block.js +36 -13
  248. package/build-module/components/list-view/block.js.map +1 -1
  249. package/build-module/components/list-view/branch.js +16 -13
  250. package/build-module/components/list-view/branch.js.map +1 -1
  251. package/build-module/components/list-view/index.js +7 -1
  252. package/build-module/components/list-view/index.js.map +1 -1
  253. package/build-module/components/list-view/use-block-selection.js +10 -3
  254. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  255. package/build-module/components/media-replace-flow/index.js +4 -0
  256. package/build-module/components/media-replace-flow/index.js.map +1 -1
  257. package/build-module/components/multi-selection-inspector/index.js +2 -2
  258. package/build-module/components/multi-selection-inspector/index.js.map +1 -1
  259. package/build-module/components/rich-text/index.js +26 -5
  260. package/build-module/components/rich-text/index.js.map +1 -1
  261. package/build-module/components/rich-text/index.native.js +13 -9
  262. package/build-module/components/rich-text/index.native.js.map +1 -1
  263. package/build-module/components/rich-text/split-value.js +12 -2
  264. package/build-module/components/rich-text/split-value.js.map +1 -1
  265. package/build-module/components/rich-text/use-firefox-compat.js +39 -0
  266. package/build-module/components/rich-text/use-firefox-compat.js.map +1 -0
  267. package/build-module/components/rich-text/use-input-rules.js +35 -4
  268. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  269. package/build-module/components/skip-to-selected-block/index.js +4 -0
  270. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  271. package/build-module/components/url-popover/image-url-input-ui.js +12 -28
  272. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  273. package/build-module/components/writing-flow/index.js +5 -1
  274. package/build-module/components/writing-flow/index.js.map +1 -1
  275. package/build-module/components/writing-flow/use-arrow-nav.js +4 -45
  276. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  277. package/build-module/components/writing-flow/use-click-selection.js +57 -0
  278. package/build-module/components/writing-flow/use-click-selection.js.map +1 -0
  279. package/build-module/components/writing-flow/use-drag-selection.js +124 -0
  280. package/build-module/components/writing-flow/use-drag-selection.js.map +1 -0
  281. package/build-module/components/writing-flow/use-input.js +104 -0
  282. package/build-module/components/writing-flow/use-input.js.map +1 -0
  283. package/build-module/components/writing-flow/use-multi-selection.js +18 -37
  284. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  285. package/build-module/components/writing-flow/use-selection-observer.js +150 -0
  286. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -0
  287. package/build-module/components/writing-flow/use-tab-nav.js +1 -9
  288. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  289. package/build-module/hooks/anchor.js +7 -6
  290. package/build-module/hooks/anchor.js.map +1 -1
  291. package/build-module/hooks/border-color.js +5 -5
  292. package/build-module/hooks/border-color.js.map +1 -1
  293. package/build-module/hooks/border.js +0 -12
  294. package/build-module/hooks/border.js.map +1 -1
  295. package/build-module/hooks/color.js +19 -18
  296. package/build-module/hooks/color.js.map +1 -1
  297. package/build-module/hooks/font-family.js +3 -1
  298. package/build-module/hooks/font-family.js.map +1 -1
  299. package/build-module/hooks/font-size.js +4 -3
  300. package/build-module/hooks/font-size.js.map +1 -1
  301. package/build-module/hooks/gap.js +75 -7
  302. package/build-module/hooks/gap.js.map +1 -1
  303. package/build-module/hooks/layout.js +7 -2
  304. package/build-module/hooks/layout.js.map +1 -1
  305. package/build-module/hooks/style.js +33 -3
  306. package/build-module/hooks/style.js.map +1 -1
  307. package/build-module/hooks/utils.js +26 -0
  308. package/build-module/hooks/utils.js.map +1 -1
  309. package/build-module/layouts/flex.js +81 -16
  310. package/build-module/layouts/flex.js.map +1 -1
  311. package/build-module/layouts/flow.js +20 -13
  312. package/build-module/layouts/flow.js.map +1 -1
  313. package/build-module/store/actions.js +286 -49
  314. package/build-module/store/actions.js.map +1 -1
  315. package/build-module/store/defaults.js +5 -1
  316. package/build-module/store/defaults.js.map +1 -1
  317. package/build-module/store/reducer.js +25 -13
  318. package/build-module/store/reducer.js.map +1 -1
  319. package/build-module/store/selectors.js +162 -20
  320. package/build-module/store/selectors.js.map +1 -1
  321. package/build-module/utils/dom.js +2 -1
  322. package/build-module/utils/dom.js.map +1 -1
  323. package/build-style/style-rtl.css +214 -24
  324. package/build-style/style.css +214 -24
  325. package/build-types/utils/dom.d.ts.map +1 -1
  326. package/package.json +28 -27
  327. package/src/components/alignment-control/index.js +9 -4
  328. package/src/components/block-alignment-control/index.js +9 -4
  329. package/src/components/block-draggable/index.js +2 -5
  330. package/src/components/block-icon/index.js +3 -0
  331. package/src/components/block-inspector/index.js +4 -0
  332. package/src/components/block-list/block-html.js +8 -4
  333. package/src/components/block-list/block.js +5 -1
  334. package/src/components/block-list/style.scss +4 -5
  335. package/src/components/block-list/use-block-props/index.js +0 -5
  336. package/src/components/block-list/use-block-props/use-focus-first-element.js +27 -6
  337. package/src/components/block-list/use-block-props/use-focus-handler.js +8 -0
  338. package/src/components/block-list-appender/index.js +5 -0
  339. package/src/components/block-lock/index.js +3 -0
  340. package/src/components/block-lock/menu-item.js +59 -0
  341. package/src/components/block-lock/modal.js +170 -0
  342. package/src/components/block-lock/style.scss +70 -0
  343. package/src/components/block-lock/toolbar.js +68 -0
  344. package/src/components/block-mover/index.js +3 -0
  345. package/src/components/block-mover/style.scss +4 -0
  346. package/src/components/block-settings-menu/block-settings-dropdown.js +109 -9
  347. package/src/components/block-settings-menu-controls/index.js +33 -12
  348. package/src/components/block-switcher/index.js +2 -2
  349. package/src/components/block-switcher/style.scss +8 -1
  350. package/src/components/block-switcher/test/index.js +2 -2
  351. package/src/components/block-title/README.md +6 -1
  352. package/src/components/block-title/index.js +2 -2
  353. package/src/components/block-title/test/index.js +43 -1
  354. package/src/components/block-title/use-block-display-title.js +10 -7
  355. package/src/components/block-toolbar/block-name-context.js +8 -0
  356. package/src/components/block-toolbar/block-toolbar-last-item.js +12 -0
  357. package/src/components/block-toolbar/index.js +24 -2
  358. package/src/components/block-toolbar/style.scss +10 -0
  359. package/src/components/block-tools/index.js +0 -19
  360. package/src/components/block-tools/style.scss +27 -0
  361. package/src/components/block-variation-transforms/index.js +105 -36
  362. package/src/components/block-variation-transforms/style.scss +1 -1
  363. package/src/components/block-vertical-alignment-control/index.js +9 -4
  364. package/src/components/border-radius-control/index.js +0 -1
  365. package/src/components/border-radius-control/test/utils.js +4 -0
  366. package/src/components/border-radius-control/utils.js +2 -1
  367. package/src/components/button-block-appender/style.scss +5 -1
  368. package/src/components/color-palette/test/__snapshots__/control.js.snap +70 -4
  369. package/src/components/colors-gradients/control.js +1 -1
  370. package/src/components/colors-gradients/style.scss +6 -0
  371. package/src/components/contrast-checker/index.js +3 -0
  372. package/src/components/convert-to-group-buttons/index.js +6 -1
  373. package/src/components/convert-to-group-buttons/toolbar.js +87 -0
  374. package/src/components/copy-handler/index.js +3 -0
  375. package/src/components/date-format-picker/README.md +58 -0
  376. package/src/components/date-format-picker/index.js +161 -0
  377. package/src/components/date-format-picker/style.scss +31 -0
  378. package/src/components/font-sizes/font-size-picker.js +3 -0
  379. package/src/components/iframe/index.js +5 -7
  380. package/src/components/index.js +3 -0
  381. package/src/components/justify-content-control/index.js +9 -4
  382. package/src/components/keyboard-shortcuts/index.js +1 -1
  383. package/src/components/line-height-control/index.js +11 -6
  384. package/src/components/link-control/README.md +1 -1
  385. package/src/components/list-view/block-select-button.js +21 -30
  386. package/src/components/list-view/block.js +55 -13
  387. package/src/components/list-view/branch.js +37 -15
  388. package/src/components/list-view/index.js +6 -0
  389. package/src/components/list-view/style.scss +56 -14
  390. package/src/components/list-view/use-block-selection.js +15 -2
  391. package/src/components/media-placeholder/README.md +8 -0
  392. package/src/components/media-replace-flow/index.js +3 -0
  393. package/src/components/multi-selection-inspector/index.js +2 -2
  394. package/src/components/rich-text/index.js +25 -2
  395. package/src/components/rich-text/index.native.js +24 -8
  396. package/src/components/rich-text/split-value.js +5 -1
  397. package/src/components/rich-text/use-firefox-compat.js +39 -0
  398. package/src/components/rich-text/use-input-rules.js +40 -3
  399. package/src/components/skip-to-selected-block/index.js +3 -0
  400. package/src/components/url-input/style.scss +3 -2
  401. package/src/components/url-popover/image-url-input-ui.js +16 -29
  402. package/src/components/writing-flow/index.js +8 -0
  403. package/src/components/writing-flow/readme.md +28 -0
  404. package/src/components/writing-flow/use-arrow-nav.js +4 -53
  405. package/src/components/writing-flow/use-click-selection.js +65 -0
  406. package/src/components/writing-flow/use-drag-selection.js +126 -0
  407. package/src/components/writing-flow/use-input.js +112 -0
  408. package/src/components/writing-flow/use-multi-selection.js +13 -36
  409. package/src/components/writing-flow/use-selection-observer.js +153 -0
  410. package/src/components/writing-flow/use-tab-nav.js +1 -11
  411. package/src/hooks/anchor.js +8 -6
  412. package/src/hooks/border-color.js +5 -5
  413. package/src/hooks/border.js +0 -13
  414. package/src/hooks/color.js +51 -24
  415. package/src/hooks/font-family.js +5 -2
  416. package/src/hooks/font-size.js +10 -7
  417. package/src/hooks/gap.js +91 -12
  418. package/src/hooks/layout.js +11 -1
  419. package/src/hooks/style.js +40 -4
  420. package/src/hooks/test/gap.js +66 -0
  421. package/src/hooks/test/style.js +94 -0
  422. package/src/hooks/test/utils.js +1 -1
  423. package/src/hooks/utils.js +26 -0
  424. package/src/layouts/flex.js +93 -6
  425. package/src/layouts/flow.js +28 -12
  426. package/src/store/actions.js +349 -32
  427. package/src/store/defaults.js +7 -1
  428. package/src/store/reducer.js +25 -10
  429. package/src/store/selectors.js +207 -25
  430. package/src/store/test/selectors.js +305 -5
  431. package/src/style.scss +2 -0
  432. package/src/utils/dom.js +2 -1
  433. package/tsconfig.tsbuildinfo +1 -1
  434. package/build/components/block-list/use-block-props/use-multi-selection.js +0 -205
  435. package/build/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
  436. package/build/components/block-list/use-block-props/use-scroll-into-view.js +0 -77
  437. package/build/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
  438. package/build-module/components/block-list/use-block-props/use-multi-selection.js +0 -192
  439. package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
  440. package/build-module/components/block-list/use-block-props/use-scroll-into-view.js +0 -63
  441. package/build-module/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
  442. package/src/components/block-list/use-block-props/use-multi-selection.js +0 -227
  443. package/src/components/block-list/use-block-props/use-scroll-into-view.js +0 -73
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/index.js"],"names":["BLOCK_ANIMATION_THRESHOLD","useBlockProps","props","__unstableIsHtml","clientId","className","wrapperProps","isAligned","BlockListBlockContext","index","mode","name","blockApiVersion","blockTitle","isPartOfSelection","adjustScrolling","enableAnimation","select","getBlockIndex","getBlockMode","getBlockName","isTyping","getGlobalBlockCount","isBlockSelected","isBlockMultiSelected","isAncestorMultiSelected","isFirstMultiSelectedBlock","blockEditorStore","isSelected","isPartOfMultiSelection","blockName","blockType","apiVersion","title","blockLabel","htmlSuffix","mergedRefs","ref","triggerAnimationOnChange","blockEditContext","id","tabIndex","role","style","save","getBlockProps"],"mappings":"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","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__unstableGetBlockProps as getBlockProps,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../../use-moving-animation';\nimport { BlockListBlockContext } from '../block';\nimport { useFocusFirstElement } from './use-focus-first-element';\nimport { useIsHovered } from './use-is-hovered';\nimport { useBlockEditContext } from '../../block-edit/context';\nimport { useBlockClassNames } from './use-block-class-names';\nimport { useBlockDefaultClassName } from './use-block-default-class-name';\nimport { useBlockCustomClassName } from './use-block-custom-class-name';\nimport { useBlockMovingModeClassNames } from './use-block-moving-mode-class-names';\nimport { useFocusHandler } from './use-focus-handler';\nimport { useEventHandlers } from './use-selected-block-event-handlers';\nimport { useNavModeExit } from './use-nav-mode-exit';\nimport { useScrollIntoView } from './use-scroll-into-view';\nimport { useBlockRefProvider } from './use-block-refs';\nimport { useMultiSelection } from './use-multi-selection';\nimport { useIntersectionObserver } from './use-intersection-observer';\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * If the block count exceeds the threshold, we disable the reordering animation\n * to avoid laginess.\n */\nconst BLOCK_ANIMATION_THRESHOLD = 200;\n\n/**\n * This hook is used to lightly mark an element as a block element. The element\n * should be the outermost element of a block. Call this hook and pass the\n * returned props to the element to mark as a block. If you define a ref for the\n * element, it is important to pass the ref to this hook, which the hook in turn\n * will pass to the component through the props it returns. Optionally, you can\n * also pass any other props through this hook, and they will be merged and\n * returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Options for internal use only.\n * @param {boolean} options.__unstableIsHtml\n *\n * @return {Object} Props to pass to the element to mark as a block.\n */\nexport function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {\n\tconst { clientId, className, wrapperProps = {}, isAligned } = useContext(\n\t\tBlockListBlockContext\n\t);\n\tconst {\n\t\tindex,\n\t\tmode,\n\t\tname,\n\t\tblockApiVersion,\n\t\tblockTitle,\n\t\tisPartOfSelection,\n\t\tadjustScrolling,\n\t\tenableAnimation,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockMode,\n\t\t\t\tgetBlockName,\n\t\t\t\tisTyping,\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tisBlockSelected,\n\t\t\t\tisBlockMultiSelected,\n\t\t\t\tisAncestorMultiSelected,\n\t\t\t\tisFirstMultiSelectedBlock,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst isSelected = isBlockSelected( clientId );\n\t\t\tconst isPartOfMultiSelection =\n\t\t\t\tisBlockMultiSelected( clientId ) ||\n\t\t\t\tisAncestorMultiSelected( clientId );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\n\t\t\treturn {\n\t\t\t\tindex: getBlockIndex( clientId ),\n\t\t\t\tmode: getBlockMode( clientId ),\n\t\t\t\tname: blockName,\n\t\t\t\tblockApiVersion: blockType?.apiVersion || 1,\n\t\t\t\tblockTitle: blockType?.title,\n\t\t\t\tisPartOfSelection: isSelected || isPartOfMultiSelection,\n\t\t\t\tadjustScrolling:\n\t\t\t\t\tisSelected || isFirstMultiSelectedBlock( clientId ),\n\t\t\t\tenableAnimation:\n\t\t\t\t\t! isTyping() &&\n\t\t\t\t\tgetGlobalBlockCount() <= BLOCK_ANIMATION_THRESHOLD,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// translators: %s: Type of block (i.e. Text, Image etc)\n\tconst blockLabel = sprintf( __( 'Block: %s' ), blockTitle );\n\tconst htmlSuffix = mode === 'html' && ! __unstableIsHtml ? '-visual' : '';\n\tconst mergedRefs = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseFocusFirstElement( clientId ),\n\t\t// Must happen after focus because we check for focus in the block.\n\t\tuseScrollIntoView( clientId ),\n\t\tuseBlockRefProvider( clientId ),\n\t\tuseFocusHandler( clientId ),\n\t\tuseMultiSelection( clientId ),\n\t\tuseEventHandlers( clientId ),\n\t\tuseNavModeExit( clientId ),\n\t\tuseIsHovered(),\n\t\tuseIntersectionObserver(),\n\t\tuseMovingAnimation( {\n\t\t\tisSelected: isPartOfSelection,\n\t\t\tadjustScrolling,\n\t\t\tenableAnimation,\n\t\t\ttriggerAnimationOnChange: index,\n\t\t} ),\n\t] );\n\n\tconst blockEditContext = useBlockEditContext();\n\t// Ensures it warns only inside the `edit` implementation for the block.\n\tif ( blockApiVersion < 2 && clientId === blockEditContext.clientId ) {\n\t\twarning(\n\t\t\t`Block type \"${ name }\" must support API version 2 or higher to work correctly with \"useBlockProps\" method.`\n\t\t);\n\t}\n\n\treturn {\n\t\t...wrapperProps,\n\t\t...props,\n\t\tref: mergedRefs,\n\t\tid: `block-${ clientId }${ htmlSuffix }`,\n\t\ttabIndex: 0,\n\t\trole: 'document',\n\t\t'aria-label': blockLabel,\n\t\t'data-block': clientId,\n\t\t'data-type': name,\n\t\t'data-title': blockTitle,\n\t\tclassName: classnames(\n\t\t\t// The wp-block className is important for editor styles.\n\t\t\tclassnames( 'block-editor-block-list__block', {\n\t\t\t\t'wp-block': ! isAligned,\n\t\t\t} ),\n\t\t\tclassName,\n\t\t\tprops.className,\n\t\t\twrapperProps.className,\n\t\t\tuseBlockClassNames( clientId ),\n\t\t\tuseBlockDefaultClassName( clientId ),\n\t\t\tuseBlockCustomClassName( clientId ),\n\t\t\tuseBlockMovingModeClassNames( clientId )\n\t\t),\n\t\tstyle: { ...wrapperProps.style, ...props.style },\n\t};\n}\n\n/**\n * Call within a save function to get the props for the block wrapper.\n *\n * @param {Object} props Optional. Props to pass to the element.\n */\nuseBlockProps.save = getBlockProps;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/index.js"],"names":["BLOCK_ANIMATION_THRESHOLD","useBlockProps","props","__unstableIsHtml","clientId","className","wrapperProps","isAligned","BlockListBlockContext","index","mode","name","blockApiVersion","blockTitle","isPartOfSelection","adjustScrolling","enableAnimation","select","getBlockIndex","getBlockMode","getBlockName","isTyping","getGlobalBlockCount","isBlockSelected","isBlockMultiSelected","isAncestorMultiSelected","isFirstMultiSelectedBlock","blockEditorStore","isSelected","isPartOfMultiSelection","blockName","blockType","apiVersion","title","blockLabel","htmlSuffix","mergedRefs","ref","triggerAnimationOnChange","blockEditContext","id","tabIndex","role","style","save","getBlockProps"],"mappings":"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","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__unstableGetBlockProps as getBlockProps,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../../use-moving-animation';\nimport { BlockListBlockContext } from '../block';\nimport { useFocusFirstElement } from './use-focus-first-element';\nimport { useIsHovered } from './use-is-hovered';\nimport { useBlockEditContext } from '../../block-edit/context';\nimport { useBlockClassNames } from './use-block-class-names';\nimport { useBlockDefaultClassName } from './use-block-default-class-name';\nimport { useBlockCustomClassName } from './use-block-custom-class-name';\nimport { useBlockMovingModeClassNames } from './use-block-moving-mode-class-names';\nimport { useFocusHandler } from './use-focus-handler';\nimport { useEventHandlers } from './use-selected-block-event-handlers';\nimport { useNavModeExit } from './use-nav-mode-exit';\nimport { useBlockRefProvider } from './use-block-refs';\nimport { useIntersectionObserver } from './use-intersection-observer';\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * If the block count exceeds the threshold, we disable the reordering animation\n * to avoid laginess.\n */\nconst BLOCK_ANIMATION_THRESHOLD = 200;\n\n/**\n * This hook is used to lightly mark an element as a block element. The element\n * should be the outermost element of a block. Call this hook and pass the\n * returned props to the element to mark as a block. If you define a ref for the\n * element, it is important to pass the ref to this hook, which the hook in turn\n * will pass to the component through the props it returns. Optionally, you can\n * also pass any other props through this hook, and they will be merged and\n * returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Options for internal use only.\n * @param {boolean} options.__unstableIsHtml\n *\n * @return {Object} Props to pass to the element to mark as a block.\n */\nexport function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {\n\tconst { clientId, className, wrapperProps = {}, isAligned } = useContext(\n\t\tBlockListBlockContext\n\t);\n\tconst {\n\t\tindex,\n\t\tmode,\n\t\tname,\n\t\tblockApiVersion,\n\t\tblockTitle,\n\t\tisPartOfSelection,\n\t\tadjustScrolling,\n\t\tenableAnimation,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockMode,\n\t\t\t\tgetBlockName,\n\t\t\t\tisTyping,\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tisBlockSelected,\n\t\t\t\tisBlockMultiSelected,\n\t\t\t\tisAncestorMultiSelected,\n\t\t\t\tisFirstMultiSelectedBlock,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst isSelected = isBlockSelected( clientId );\n\t\t\tconst isPartOfMultiSelection =\n\t\t\t\tisBlockMultiSelected( clientId ) ||\n\t\t\t\tisAncestorMultiSelected( clientId );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\n\t\t\treturn {\n\t\t\t\tindex: getBlockIndex( clientId ),\n\t\t\t\tmode: getBlockMode( clientId ),\n\t\t\t\tname: blockName,\n\t\t\t\tblockApiVersion: blockType?.apiVersion || 1,\n\t\t\t\tblockTitle: blockType?.title,\n\t\t\t\tisPartOfSelection: isSelected || isPartOfMultiSelection,\n\t\t\t\tadjustScrolling:\n\t\t\t\t\tisSelected || isFirstMultiSelectedBlock( clientId ),\n\t\t\t\tenableAnimation:\n\t\t\t\t\t! isTyping() &&\n\t\t\t\t\tgetGlobalBlockCount() <= BLOCK_ANIMATION_THRESHOLD,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// translators: %s: Type of block (i.e. Text, Image etc)\n\tconst blockLabel = sprintf( __( 'Block: %s' ), blockTitle );\n\tconst htmlSuffix = mode === 'html' && ! __unstableIsHtml ? '-visual' : '';\n\tconst mergedRefs = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseFocusFirstElement( clientId ),\n\t\tuseBlockRefProvider( clientId ),\n\t\tuseFocusHandler( clientId ),\n\t\tuseEventHandlers( clientId ),\n\t\tuseNavModeExit( clientId ),\n\t\tuseIsHovered(),\n\t\tuseIntersectionObserver(),\n\t\tuseMovingAnimation( {\n\t\t\tisSelected: isPartOfSelection,\n\t\t\tadjustScrolling,\n\t\t\tenableAnimation,\n\t\t\ttriggerAnimationOnChange: index,\n\t\t} ),\n\t] );\n\n\tconst blockEditContext = useBlockEditContext();\n\t// Ensures it warns only inside the `edit` implementation for the block.\n\tif ( blockApiVersion < 2 && clientId === blockEditContext.clientId ) {\n\t\twarning(\n\t\t\t`Block type \"${ name }\" must support API version 2 or higher to work correctly with \"useBlockProps\" method.`\n\t\t);\n\t}\n\n\treturn {\n\t\t...wrapperProps,\n\t\t...props,\n\t\tref: mergedRefs,\n\t\tid: `block-${ clientId }${ htmlSuffix }`,\n\t\ttabIndex: 0,\n\t\trole: 'document',\n\t\t'aria-label': blockLabel,\n\t\t'data-block': clientId,\n\t\t'data-type': name,\n\t\t'data-title': blockTitle,\n\t\tclassName: classnames(\n\t\t\t// The wp-block className is important for editor styles.\n\t\t\tclassnames( 'block-editor-block-list__block', {\n\t\t\t\t'wp-block': ! isAligned,\n\t\t\t} ),\n\t\t\tclassName,\n\t\t\tprops.className,\n\t\t\twrapperProps.className,\n\t\t\tuseBlockClassNames( clientId ),\n\t\t\tuseBlockDefaultClassName( clientId ),\n\t\t\tuseBlockCustomClassName( clientId ),\n\t\t\tuseBlockMovingModeClassNames( clientId )\n\t\t),\n\t\tstyle: { ...wrapperProps.style, ...props.style },\n\t};\n}\n\n/**\n * Call within a save function to get the props for the block wrapper.\n *\n * @param {Object} props Optional. Props to pass to the element.\n */\nuseBlockProps.save = getBlockProps;\n"]}
@@ -17,8 +17,6 @@ var _dom2 = require("../../../utils/dom");
17
17
 
18
18
  var _store = require("../../../store");
19
19
 
20
- var _useMultiSelection = require("./use-multi-selection");
21
-
22
20
  /**
23
21
  * External dependencies
24
22
  */
@@ -45,7 +43,6 @@ function useInitialPosition(clientId) {
45
43
  return (0, _data.useSelect)(select => {
46
44
  const {
47
45
  getSelectedBlocksInitialCaretPosition,
48
- isMultiSelecting,
49
46
  isNavigationMode,
50
47
  isBlockSelected
51
48
  } = select(_store.store);
@@ -54,7 +51,7 @@ function useInitialPosition(clientId) {
54
51
  return;
55
52
  }
56
53
 
57
- if (isMultiSelecting() || isNavigationMode()) {
54
+ if (isNavigationMode()) {
58
55
  return;
59
56
  } // If there's no initial position, return 0 to focus the start.
60
57
 
@@ -75,7 +72,16 @@ function useInitialPosition(clientId) {
75
72
  function useFocusFirstElement(clientId) {
76
73
  const ref = (0, _element.useRef)();
77
74
  const initialPosition = useInitialPosition(clientId);
75
+ const {
76
+ isBlockSelected,
77
+ isMultiSelecting
78
+ } = (0, _data.useSelect)(_store.store);
78
79
  (0, _element.useEffect)(() => {
80
+ // Check if the block is still selected at the time this effect runs.
81
+ if (!isBlockSelected(clientId) || isMultiSelecting()) {
82
+ return;
83
+ }
84
+
79
85
  if (initialPosition === undefined || initialPosition === null) {
80
86
  return;
81
87
  }
@@ -103,11 +109,21 @@ function useFocusFirstElement(clientId) {
103
109
  if (!(0, _dom2.isInsideRootBlock)(ref.current, target)) {
104
110
  ref.current.focus();
105
111
  return;
112
+ } // Check to see if element is focussable before a generic caret insert.
113
+
114
+
115
+ if (!ref.current.getAttribute('contenteditable')) {
116
+ const focusElement = _dom.focus.tabbable.findNext(ref.current); // Make sure focusElement is valid, contained in the same block, and a form field.
117
+
118
+
119
+ if (focusElement && (0, _dom2.isInsideRootBlock)(ref.current, focusElement) && (0, _dom.isFormElement)(focusElement)) {
120
+ focusElement.focus();
121
+ return;
122
+ }
106
123
  }
107
124
 
108
- (0, _useMultiSelection.setContentEditableWrapper)(ref.current, false);
109
125
  (0, _dom.placeCaretAtHorizontalEdge)(target, isReverse);
110
- }, [initialPosition]);
126
+ }, [initialPosition, clientId]);
111
127
  return ref;
112
128
  }
113
129
  //# sourceMappingURL=use-focus-first-element.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-focus-first-element.js"],"names":["useInitialPosition","clientId","select","getSelectedBlocksInitialCaretPosition","isMultiSelecting","isNavigationMode","isBlockSelected","blockEditorStore","useFocusFirstElement","ref","initialPosition","undefined","current","ownerDocument","contains","activeElement","textInputs","focus","tabbable","find","filter","node","isReverse","target","last","first"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAKA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,kBAAT,CAA6BC,QAA7B,EAAwC;AACvC,SAAO,qBACJC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,qCADK;AAELC,MAAAA,gBAFK;AAGLC,MAAAA,gBAHK;AAILC,MAAAA;AAJK,QAKFJ,MAAM,CAAEK,YAAF,CALV;;AAOA,QAAK,CAAED,eAAe,CAAEL,QAAF,CAAtB,EAAqC;AACpC;AACA;;AAED,QAAKG,gBAAgB,MAAMC,gBAAgB,EAA3C,EAAgD;AAC/C;AACA,KAdY,CAgBb;;;AACA,WAAOF,qCAAqC,EAA5C;AACA,GAnBK,EAoBN,CAAEF,QAAF,CApBM,CAAP;AAsBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASO,oBAAT,CAA+BP,QAA/B,EAA0C;AAChD,QAAMQ,GAAG,GAAG,sBAAZ;AACA,QAAMC,eAAe,GAAGV,kBAAkB,CAAEC,QAAF,CAA1C;AAEA,0BAAW,MAAM;AAChB,QAAKS,eAAe,KAAKC,SAApB,IAAiCD,eAAe,KAAK,IAA1D,EAAiE;AAChE;AACA;;AAED,QAAK,CAAED,GAAG,CAACG,OAAX,EAAqB;AACpB;AACA;;AAED,UAAM;AAAEC,MAAAA;AAAF,QAAoBJ,GAAG,CAACG,OAA9B,CATgB,CAWhB;;AACA,QAAKH,GAAG,CAACG,OAAJ,CAAYE,QAAZ,CAAsBD,aAAa,CAACE,aAApC,CAAL,EAA2D;AAC1D;AACA,KAde,CAgBhB;;;AACA,UAAMC,UAAU,GAAGC,WAAMC,QAAN,CACjBC,IADiB,CACXV,GAAG,CAACG,OADO,EAEjBQ,MAFiB,CAEPC,IAAF,IAAY,sBAAaA,IAAb,CAFH,CAAnB,CAjBgB,CAqBhB;AACA;;;AACA,UAAMC,SAAS,GAAG,CAAC,CAAD,KAAOZ,eAAzB;AACA,UAAMa,MAAM,GACX,CAAED,SAAS,GAAGE,YAAH,GAAUC,aAArB,EAA8BT,UAA9B,KAA8CP,GAAG,CAACG,OADnD;;AAGA,QAAK,CAAE,6BAAmBH,GAAG,CAACG,OAAvB,EAAgCW,MAAhC,CAAP,EAAkD;AACjDd,MAAAA,GAAG,CAACG,OAAJ,CAAYK,KAAZ;AACA;AACA;;AAED,sDAA2BR,GAAG,CAACG,OAA/B,EAAwC,KAAxC;AAEA,yCAA4BW,MAA5B,EAAoCD,SAApC;AACA,GAnCD,EAmCG,CAAEZ,eAAF,CAnCH;AAqCA,SAAOD,GAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { first, last } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { focus, isTextField, placeCaretAtHorizontalEdge } from '@wordpress/dom';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { isInsideRootBlock } from '../../../utils/dom';\nimport { store as blockEditorStore } from '../../../store';\nimport { setContentEditableWrapper } from './use-multi-selection';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\n/**\n * Returns the initial position if the block needs to be focussed, `undefined`\n * otherwise. The initial position is either 0 (start) or -1 (end).\n *\n * @param {string} clientId Block client ID.\n *\n * @return {number} The initial position, either 0 (start) or -1 (end).\n */\nfunction useInitialPosition( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t\t\tisMultiSelecting,\n\t\t\t\tisNavigationMode,\n\t\t\t\tisBlockSelected,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockSelected( clientId ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( isMultiSelecting() || isNavigationMode() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If there's no initial position, return 0 to focus the start.\n\t\t\treturn getSelectedBlocksInitialCaretPosition();\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n\n/**\n * Transitions focus to the block or inner tabbable when the block becomes\n * selected and an initial position is set.\n *\n * @param {string} clientId Block client ID.\n *\n * @return {RefObject} React ref with the block element.\n */\nexport function useFocusFirstElement( clientId ) {\n\tconst ref = useRef();\n\tconst initialPosition = useInitialPosition( clientId );\n\n\tuseEffect( () => {\n\t\tif ( initialPosition === undefined || initialPosition === null ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerDocument } = ref.current;\n\n\t\t// Do not focus the block if it already contains the active element.\n\t\tif ( ref.current.contains( ownerDocument.activeElement ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Find all tabbables within node.\n\t\tconst textInputs = focus.tabbable\n\t\t\t.find( ref.current )\n\t\t\t.filter( ( node ) => isTextField( node ) );\n\n\t\t// If reversed (e.g. merge via backspace), use the last in the set of\n\t\t// tabbables.\n\t\tconst isReverse = -1 === initialPosition;\n\t\tconst target =\n\t\t\t( isReverse ? last : first )( textInputs ) || ref.current;\n\n\t\tif ( ! isInsideRootBlock( ref.current, target ) ) {\n\t\t\tref.current.focus();\n\t\t\treturn;\n\t\t}\n\n\t\tsetContentEditableWrapper( ref.current, false );\n\n\t\tplaceCaretAtHorizontalEdge( target, isReverse );\n\t}, [ initialPosition ] );\n\n\treturn ref;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-focus-first-element.js"],"names":["useInitialPosition","clientId","select","getSelectedBlocksInitialCaretPosition","isNavigationMode","isBlockSelected","blockEditorStore","useFocusFirstElement","ref","initialPosition","isMultiSelecting","undefined","current","ownerDocument","contains","activeElement","textInputs","focus","tabbable","find","filter","node","isReverse","target","last","first","getAttribute","focusElement","findNext"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AAMA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,kBAAT,CAA6BC,QAA7B,EAAwC;AACvC,SAAO,qBACJC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,qCADK;AAELC,MAAAA,gBAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEI,YAAF,CAJV;;AAMA,QAAK,CAAED,eAAe,CAAEJ,QAAF,CAAtB,EAAqC;AACpC;AACA;;AAED,QAAKG,gBAAgB,EAArB,EAA0B;AACzB;AACA,KAbY,CAeb;;;AACA,WAAOD,qCAAqC,EAA5C;AACA,GAlBK,EAmBN,CAAEF,QAAF,CAnBM,CAAP;AAqBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASM,oBAAT,CAA+BN,QAA/B,EAA0C;AAChD,QAAMO,GAAG,GAAG,sBAAZ;AACA,QAAMC,eAAe,GAAGT,kBAAkB,CAAEC,QAAF,CAA1C;AACA,QAAM;AAAEI,IAAAA,eAAF;AAAmBK,IAAAA;AAAnB,MAAwC,qBAAWJ,YAAX,CAA9C;AAEA,0BAAW,MAAM;AAChB;AACA,QAAK,CAAED,eAAe,CAAEJ,QAAF,CAAjB,IAAiCS,gBAAgB,EAAtD,EAA2D;AAC1D;AACA;;AAED,QAAKD,eAAe,KAAKE,SAApB,IAAiCF,eAAe,KAAK,IAA1D,EAAiE;AAChE;AACA;;AAED,QAAK,CAAED,GAAG,CAACI,OAAX,EAAqB;AACpB;AACA;;AAED,UAAM;AAAEC,MAAAA;AAAF,QAAoBL,GAAG,CAACI,OAA9B,CAdgB,CAgBhB;;AACA,QAAKJ,GAAG,CAACI,OAAJ,CAAYE,QAAZ,CAAsBD,aAAa,CAACE,aAApC,CAAL,EAA2D;AAC1D;AACA,KAnBe,CAqBhB;;;AACA,UAAMC,UAAU,GAAGC,WAAMC,QAAN,CACjBC,IADiB,CACXX,GAAG,CAACI,OADO,EAEjBQ,MAFiB,CAEPC,IAAF,IAAY,sBAAaA,IAAb,CAFH,CAAnB,CAtBgB,CA0BhB;AACA;;;AACA,UAAMC,SAAS,GAAG,CAAC,CAAD,KAAOb,eAAzB;AACA,UAAMc,MAAM,GACX,CAAED,SAAS,GAAGE,YAAH,GAAUC,aAArB,EAA8BT,UAA9B,KAA8CR,GAAG,CAACI,OADnD;;AAGA,QAAK,CAAE,6BAAmBJ,GAAG,CAACI,OAAvB,EAAgCW,MAAhC,CAAP,EAAkD;AACjDf,MAAAA,GAAG,CAACI,OAAJ,CAAYK,KAAZ;AACA;AACA,KAnCe,CAqChB;;;AACA,QAAK,CAAET,GAAG,CAACI,OAAJ,CAAYc,YAAZ,CAA0B,iBAA1B,CAAP,EAAuD;AACtD,YAAMC,YAAY,GAAGV,WAAMC,QAAN,CAAeU,QAAf,CAAyBpB,GAAG,CAACI,OAA7B,CAArB,CADsD,CAEtD;;;AACA,UACCe,YAAY,IACZ,6BAAmBnB,GAAG,CAACI,OAAvB,EAAgCe,YAAhC,CADA,IAEA,wBAAeA,YAAf,CAHD,EAIE;AACDA,QAAAA,YAAY,CAACV,KAAb;AACA;AACA;AACD;;AAED,yCAA4BM,MAA5B,EAAoCD,SAApC;AACA,GApDD,EAoDG,CAAEb,eAAF,EAAmBR,QAAnB,CApDH;AAsDA,SAAOO,GAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { first, last } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport {\n\tfocus,\n\tisFormElement,\n\tisTextField,\n\tplaceCaretAtHorizontalEdge,\n} from '@wordpress/dom';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { isInsideRootBlock } from '../../../utils/dom';\nimport { store as blockEditorStore } from '../../../store';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\n/**\n * Returns the initial position if the block needs to be focussed, `undefined`\n * otherwise. The initial position is either 0 (start) or -1 (end).\n *\n * @param {string} clientId Block client ID.\n *\n * @return {number} The initial position, either 0 (start) or -1 (end).\n */\nfunction useInitialPosition( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t\t\tisNavigationMode,\n\t\t\t\tisBlockSelected,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockSelected( clientId ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( isNavigationMode() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If there's no initial position, return 0 to focus the start.\n\t\t\treturn getSelectedBlocksInitialCaretPosition();\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n\n/**\n * Transitions focus to the block or inner tabbable when the block becomes\n * selected and an initial position is set.\n *\n * @param {string} clientId Block client ID.\n *\n * @return {RefObject} React ref with the block element.\n */\nexport function useFocusFirstElement( clientId ) {\n\tconst ref = useRef();\n\tconst initialPosition = useInitialPosition( clientId );\n\tconst { isBlockSelected, isMultiSelecting } = useSelect( blockEditorStore );\n\n\tuseEffect( () => {\n\t\t// Check if the block is still selected at the time this effect runs.\n\t\tif ( ! isBlockSelected( clientId ) || isMultiSelecting() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( initialPosition === undefined || initialPosition === null ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerDocument } = ref.current;\n\n\t\t// Do not focus the block if it already contains the active element.\n\t\tif ( ref.current.contains( ownerDocument.activeElement ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Find all tabbables within node.\n\t\tconst textInputs = focus.tabbable\n\t\t\t.find( ref.current )\n\t\t\t.filter( ( node ) => isTextField( node ) );\n\n\t\t// If reversed (e.g. merge via backspace), use the last in the set of\n\t\t// tabbables.\n\t\tconst isReverse = -1 === initialPosition;\n\t\tconst target =\n\t\t\t( isReverse ? last : first )( textInputs ) || ref.current;\n\n\t\tif ( ! isInsideRootBlock( ref.current, target ) ) {\n\t\t\tref.current.focus();\n\t\t\treturn;\n\t\t}\n\n\t\t// Check to see if element is focussable before a generic caret insert.\n\t\tif ( ! ref.current.getAttribute( 'contenteditable' ) ) {\n\t\t\tconst focusElement = focus.tabbable.findNext( ref.current );\n\t\t\t// Make sure focusElement is valid, contained in the same block, and a form field.\n\t\t\tif (\n\t\t\t\tfocusElement &&\n\t\t\t\tisInsideRootBlock( ref.current, focusElement ) &&\n\t\t\t\tisFormElement( focusElement )\n\t\t\t) {\n\t\t\t\tfocusElement.focus();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tplaceCaretAtHorizontalEdge( target, isReverse );\n\t}, [ initialPosition, clientId ] );\n\n\treturn ref;\n}\n"]}
@@ -44,8 +44,14 @@ function useFocusHandler(clientId) {
44
44
  * @param {FocusEvent} event Focus event.
45
45
  */
46
46
  function onFocus(event) {
47
- // Check synchronously because a non-selected block might be
47
+ // When the whole editor is editable, let writing flow handle
48
+ // selection.
49
+ if (node.parentElement.closest('[contenteditable="true"]')) {
50
+ return;
51
+ } // Check synchronously because a non-selected block might be
48
52
  // getting data through `useSelect` asynchronously.
53
+
54
+
49
55
  if (isBlockSelected(clientId)) {
50
56
  // Potentially change selection away from rich text.
51
57
  if (!event.target.isContentEditable) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-focus-handler.js"],"names":["useFocusHandler","clientId","isBlockSelected","blockEditorStore","selectBlock","selectionChange","node","onFocus","event","target","isContentEditable","addEventListener","removeEventListener"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,CAA0BC,QAA1B,EAAqC;AAC3C,QAAM;AAAEC,IAAAA;AAAF,MAAsB,qBAAWC,YAAX,CAA5B;AACA,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAAmC,uBAAaF,YAAb,CAAzC;AAEA,SAAO,2BACJG,IAAF,IAAY;AACX;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACG,aAASC,OAAT,CAAkBC,KAAlB,EAA0B;AACzB;AACA;AACA,UAAKN,eAAe,CAAED,QAAF,CAApB,EAAmC;AAClC;AACA,YAAK,CAAEO,KAAK,CAACC,MAAN,CAAaC,iBAApB,EAAwC;AACvCL,UAAAA,eAAe,CAAEJ,QAAF,CAAf;AACA;;AACD;AACA,OATwB,CAWzB;AACA;;;AACA,UAAK,CAAE,4BAAmBK,IAAnB,EAAyBE,KAAK,CAACC,MAA/B,CAAP,EAAiD;AAChD;AACA;;AAEDL,MAAAA,WAAW,CAAEH,QAAF,CAAX;AACA;;AAEDK,IAAAA,IAAI,CAACK,gBAAL,CAAuB,SAAvB,EAAkCJ,OAAlC;AAEA,WAAO,MAAM;AACZD,MAAAA,IAAI,CAACM,mBAAL,CAA0B,SAA1B,EAAqCL,OAArC;AACA,KAFD;AAGA,GAnCK,EAoCN,CAAEL,eAAF,EAAmBE,WAAnB,CApCM,CAAP;AAsCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { isInsideRootBlock } from '../../../utils/dom';\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * Selects the block if it receives focus.\n *\n * @param {string} clientId Block client ID.\n */\nexport function useFocusHandler( clientId ) {\n\tconst { isBlockSelected } = useSelect( blockEditorStore );\n\tconst { selectBlock, selectionChange } = useDispatch( blockEditorStore );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\t/**\n\t\t\t * Marks the block as selected when focused and not already\n\t\t\t * selected. This specifically handles the case where block does not\n\t\t\t * set focus on its own (via `setFocus`), typically if there is no\n\t\t\t * focusable input in the block.\n\t\t\t *\n\t\t\t * @param {FocusEvent} event Focus event.\n\t\t\t */\n\t\t\tfunction onFocus( event ) {\n\t\t\t\t// Check synchronously because a non-selected block might be\n\t\t\t\t// getting data through `useSelect` asynchronously.\n\t\t\t\tif ( isBlockSelected( clientId ) ) {\n\t\t\t\t\t// Potentially change selection away from rich text.\n\t\t\t\t\tif ( ! event.target.isContentEditable ) {\n\t\t\t\t\t\tselectionChange( clientId );\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If an inner block is focussed, that block is resposible for\n\t\t\t\t// setting the selected block.\n\t\t\t\tif ( ! isInsideRootBlock( node, event.target ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselectBlock( clientId );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'focusin', onFocus );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'focusin', onFocus );\n\t\t\t};\n\t\t},\n\t\t[ isBlockSelected, selectBlock ]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-focus-handler.js"],"names":["useFocusHandler","clientId","isBlockSelected","blockEditorStore","selectBlock","selectionChange","node","onFocus","event","parentElement","closest","target","isContentEditable","addEventListener","removeEventListener"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,CAA0BC,QAA1B,EAAqC;AAC3C,QAAM;AAAEC,IAAAA;AAAF,MAAsB,qBAAWC,YAAX,CAA5B;AACA,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAAmC,uBAAaF,YAAb,CAAzC;AAEA,SAAO,2BACJG,IAAF,IAAY;AACX;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACG,aAASC,OAAT,CAAkBC,KAAlB,EAA0B;AACzB;AACA;AACA,UACCF,IAAI,CAACG,aAAL,CAAmBC,OAAnB,CAA4B,0BAA5B,CADD,EAEE;AACD;AACA,OAPwB,CASzB;AACA;;;AACA,UAAKR,eAAe,CAAED,QAAF,CAApB,EAAmC;AAClC;AACA,YAAK,CAAEO,KAAK,CAACG,MAAN,CAAaC,iBAApB,EAAwC;AACvCP,UAAAA,eAAe,CAAEJ,QAAF,CAAf;AACA;;AACD;AACA,OAjBwB,CAmBzB;AACA;;;AACA,UAAK,CAAE,4BAAmBK,IAAnB,EAAyBE,KAAK,CAACG,MAA/B,CAAP,EAAiD;AAChD;AACA;;AAEDP,MAAAA,WAAW,CAAEH,QAAF,CAAX;AACA;;AAEDK,IAAAA,IAAI,CAACO,gBAAL,CAAuB,SAAvB,EAAkCN,OAAlC;AAEA,WAAO,MAAM;AACZD,MAAAA,IAAI,CAACQ,mBAAL,CAA0B,SAA1B,EAAqCP,OAArC;AACA,KAFD;AAGA,GA3CK,EA4CN,CAAEL,eAAF,EAAmBE,WAAnB,CA5CM,CAAP;AA8CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { isInsideRootBlock } from '../../../utils/dom';\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * Selects the block if it receives focus.\n *\n * @param {string} clientId Block client ID.\n */\nexport function useFocusHandler( clientId ) {\n\tconst { isBlockSelected } = useSelect( blockEditorStore );\n\tconst { selectBlock, selectionChange } = useDispatch( blockEditorStore );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\t/**\n\t\t\t * Marks the block as selected when focused and not already\n\t\t\t * selected. This specifically handles the case where block does not\n\t\t\t * set focus on its own (via `setFocus`), typically if there is no\n\t\t\t * focusable input in the block.\n\t\t\t *\n\t\t\t * @param {FocusEvent} event Focus event.\n\t\t\t */\n\t\t\tfunction onFocus( event ) {\n\t\t\t\t// When the whole editor is editable, let writing flow handle\n\t\t\t\t// selection.\n\t\t\t\tif (\n\t\t\t\t\tnode.parentElement.closest( '[contenteditable=\"true\"]' )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Check synchronously because a non-selected block might be\n\t\t\t\t// getting data through `useSelect` asynchronously.\n\t\t\t\tif ( isBlockSelected( clientId ) ) {\n\t\t\t\t\t// Potentially change selection away from rich text.\n\t\t\t\t\tif ( ! event.target.isContentEditable ) {\n\t\t\t\t\t\tselectionChange( clientId );\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If an inner block is focussed, that block is resposible for\n\t\t\t\t// setting the selected block.\n\t\t\t\tif ( ! isInsideRootBlock( node, event.target ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselectBlock( clientId );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'focusin', onFocus );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'focusin', onFocus );\n\t\t\t};\n\t\t},\n\t\t[ isBlockSelected, selectBlock ]\n\t);\n}\n"]}
@@ -85,7 +85,12 @@ function BlockListAppender(_ref) {
85
85
  // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
86
86
  , {
87
87
  tabIndex: -1,
88
- className: (0, _classnames.default)('block-list-appender wp-block', className) // The appender exists to let you add the first Paragraph before
88
+ className: (0, _classnames.default)('block-list-appender wp-block', className) // Needed in case the whole editor is content editable (for multi
89
+ // selection). It fixes an edge case where ArrowDown and ArrowRight
90
+ // should collapse the selection to the end of that selection and
91
+ // not into the appender.
92
+ ,
93
+ contentEditable: false // The appender exists to let you add the first Paragraph before
89
94
  // any is inserted. To that end, this appender should visually be
90
95
  // presented as a block. That means theme CSS should style it as if
91
96
  // it were an empty paragraph block. That means a `wp-block` class to
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-list-appender/index.js"],"names":["BlockListAppender","rootClientId","canInsertDefaultBlock","isLocked","renderAppender","CustomAppender","className","selectedBlockClientId","tagName","TagName","appender","isParentSelected","select","canInsertBlockType","getTemplateLock","getSelectedBlockClientId","blockEditorStore"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAKA,SAASA,iBAAT,OAQI;AAAA,MARwB;AAC3BC,IAAAA,YAD2B;AAE3BC,IAAAA,qBAF2B;AAG3BC,IAAAA,QAH2B;AAI3BC,IAAAA,cAAc,EAAEC,cAJW;AAK3BC,IAAAA,SAL2B;AAM3BC,IAAAA,qBAN2B;AAO3BC,IAAAA,OAAO,EAAEC,OAAO,GAAG;AAPQ,GAQxB;;AACH,MAAKN,QAAQ,IAAIE,cAAc,KAAK,KAApC,EAA4C;AAC3C,WAAO,IAAP;AACA;;AAED,MAAIK,QAAJ;;AACA,MAAKL,cAAL,EAAsB;AACrB;AACAK,IAAAA,QAAQ,GAAG,4BAAC,cAAD,OAAX;AACA,GAHD,MAGO;AACN,UAAMC,gBAAgB,GACrBJ,qBAAqB,KAAKN,YAA1B,IACE,CAAEA,YAAF,IAAkB,CAAEM,qBAFvB;;AAIA,QAAK,CAAEI,gBAAP,EAA0B;AACzB,aAAO,IAAP;AACA;;AAED,QAAKT,qBAAL,EAA6B;AAC5B;AACA;AACAQ,MAAAA,QAAQ,GAAG,4BAAC,6BAAD;AAAsB,QAAA,YAAY,EAAGT;AAArC,QAAX;AACA,KAJD,MAIO;AACN;AACA;AACAS,MAAAA,QAAQ,GACP,4BAAC,4BAAD;AACC,QAAA,YAAY,EAAGT,YADhB;AAEC,QAAA,SAAS,EAAC;AAFX,QADD;AAMA;AACD;;AAED,SACC,4BAAC,OAAD,CACC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARD;AASC,IAAA,QAAQ,EAAG,CAAC,CATb;AAUC,IAAA,SAAS,EAAG,yBACX,8BADW,EAEXK,SAFW,CAVb,CAcC;AACA;AACA;AACA;AACA;AACA;AACA;AApBD;AAqBC;AArBD,KAuBGI,QAvBH,CADD;AA2BA;;eAEc,sBAAY,CAAEE,MAAF,YAAgC;AAAA,MAAtB;AAAEX,IAAAA;AAAF,GAAsB;AAC1D,QAAM;AACLY,IAAAA,kBADK;AAELC,IAAAA,eAFK;AAGLC,IAAAA;AAHK,MAIFH,MAAM,CAAEI,YAAF,CAJV;AAMA,SAAO;AACNb,IAAAA,QAAQ,EAAE,CAAC,CAAEW,eAAe,CAAEb,YAAF,CADtB;AAENC,IAAAA,qBAAqB,EAAEW,kBAAkB,CACxC,kCADwC,EAExCZ,YAFwC,CAFnC;AAMNM,IAAAA,qBAAqB,EAAEQ,wBAAwB;AANzC,GAAP;AAQA,CAfc,EAeVf,iBAfU,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { withSelect } from '@wordpress/data';\nimport { getDefaultBlockName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport DefaultBlockAppender from '../default-block-appender';\nimport ButtonBlockAppender from '../button-block-appender';\nimport { store as blockEditorStore } from '../../store';\n\nfunction BlockListAppender( {\n\trootClientId,\n\tcanInsertDefaultBlock,\n\tisLocked,\n\trenderAppender: CustomAppender,\n\tclassName,\n\tselectedBlockClientId,\n\ttagName: TagName = 'div',\n} ) {\n\tif ( isLocked || CustomAppender === false ) {\n\t\treturn null;\n\t}\n\n\tlet appender;\n\tif ( CustomAppender ) {\n\t\t// Prefer custom render prop if provided.\n\t\tappender = <CustomAppender />;\n\t} else {\n\t\tconst isParentSelected =\n\t\t\tselectedBlockClientId === rootClientId ||\n\t\t\t( ! rootClientId && ! selectedBlockClientId );\n\n\t\tif ( ! isParentSelected ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( canInsertDefaultBlock ) {\n\t\t\t// Render the default block appender when renderAppender has not been\n\t\t\t// provided and the context supports use of the default appender.\n\t\t\tappender = <DefaultBlockAppender rootClientId={ rootClientId } />;\n\t\t} else {\n\t\t\t// Fallback in the case no renderAppender has been provided and the\n\t\t\t// default block can't be inserted.\n\t\t\tappender = (\n\t\t\t\t<ButtonBlockAppender\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclassName=\"block-list-appender__toggle\"\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\t}\n\n\treturn (\n\t\t<TagName\n\t\t\t// A `tabIndex` is used on the wrapping `div` element in order to\n\t\t\t// force a focus event to occur when an appender `button` element\n\t\t\t// is clicked. In some browsers (Firefox, Safari), button clicks do\n\t\t\t// not emit a focus event, which could cause this event to propagate\n\t\t\t// unexpectedly. The `tabIndex` ensures that the interaction is\n\t\t\t// captured as a focus, without also adding an extra tab stop.\n\t\t\t//\n\t\t\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\t\t\ttabIndex={ -1 }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-list-appender wp-block',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\t// The appender exists to let you add the first Paragraph before\n\t\t\t// any is inserted. To that end, this appender should visually be\n\t\t\t// presented as a block. That means theme CSS should style it as if\n\t\t\t// it were an empty paragraph block. That means a `wp-block` class to\n\t\t\t// ensure the width is correct, and a [data-block] attribute to ensure\n\t\t\t// the correct margin is applied, especially for classic themes which\n\t\t\t// have commonly targeted that attribute for margins.\n\t\t\tdata-block\n\t\t>\n\t\t\t{ appender }\n\t\t</TagName>\n\t);\n}\n\nexport default withSelect( ( select, { rootClientId } ) => {\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetTemplateLock,\n\t\tgetSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\n\treturn {\n\t\tisLocked: !! getTemplateLock( rootClientId ),\n\t\tcanInsertDefaultBlock: canInsertBlockType(\n\t\t\tgetDefaultBlockName(),\n\t\t\trootClientId\n\t\t),\n\t\tselectedBlockClientId: getSelectedBlockClientId(),\n\t};\n} )( BlockListAppender );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-list-appender/index.js"],"names":["BlockListAppender","rootClientId","canInsertDefaultBlock","isLocked","renderAppender","CustomAppender","className","selectedBlockClientId","tagName","TagName","appender","isParentSelected","select","canInsertBlockType","getTemplateLock","getSelectedBlockClientId","blockEditorStore"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAKA,SAASA,iBAAT,OAQI;AAAA,MARwB;AAC3BC,IAAAA,YAD2B;AAE3BC,IAAAA,qBAF2B;AAG3BC,IAAAA,QAH2B;AAI3BC,IAAAA,cAAc,EAAEC,cAJW;AAK3BC,IAAAA,SAL2B;AAM3BC,IAAAA,qBAN2B;AAO3BC,IAAAA,OAAO,EAAEC,OAAO,GAAG;AAPQ,GAQxB;;AACH,MAAKN,QAAQ,IAAIE,cAAc,KAAK,KAApC,EAA4C;AAC3C,WAAO,IAAP;AACA;;AAED,MAAIK,QAAJ;;AACA,MAAKL,cAAL,EAAsB;AACrB;AACAK,IAAAA,QAAQ,GAAG,4BAAC,cAAD,OAAX;AACA,GAHD,MAGO;AACN,UAAMC,gBAAgB,GACrBJ,qBAAqB,KAAKN,YAA1B,IACE,CAAEA,YAAF,IAAkB,CAAEM,qBAFvB;;AAIA,QAAK,CAAEI,gBAAP,EAA0B;AACzB,aAAO,IAAP;AACA;;AAED,QAAKT,qBAAL,EAA6B;AAC5B;AACA;AACAQ,MAAAA,QAAQ,GAAG,4BAAC,6BAAD;AAAsB,QAAA,YAAY,EAAGT;AAArC,QAAX;AACA,KAJD,MAIO;AACN;AACA;AACAS,MAAAA,QAAQ,GACP,4BAAC,4BAAD;AACC,QAAA,YAAY,EAAGT,YADhB;AAEC,QAAA,SAAS,EAAC;AAFX,QADD;AAMA;AACD;;AAED,SACC,4BAAC,OAAD,CACC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARD;AASC,IAAA,QAAQ,EAAG,CAAC,CATb;AAUC,IAAA,SAAS,EAAG,yBACX,8BADW,EAEXK,SAFW,CAVb,CAcC;AACA;AACA;AACA;AAjBD;AAkBC,IAAA,eAAe,EAAG,KAlBnB,CAmBC;AACA;AACA;AACA;AACA;AACA;AACA;AAzBD;AA0BC;AA1BD,KA4BGI,QA5BH,CADD;AAgCA;;eAEc,sBAAY,CAAEE,MAAF,YAAgC;AAAA,MAAtB;AAAEX,IAAAA;AAAF,GAAsB;AAC1D,QAAM;AACLY,IAAAA,kBADK;AAELC,IAAAA,eAFK;AAGLC,IAAAA;AAHK,MAIFH,MAAM,CAAEI,YAAF,CAJV;AAMA,SAAO;AACNb,IAAAA,QAAQ,EAAE,CAAC,CAAEW,eAAe,CAAEb,YAAF,CADtB;AAENC,IAAAA,qBAAqB,EAAEW,kBAAkB,CACxC,kCADwC,EAExCZ,YAFwC,CAFnC;AAMNM,IAAAA,qBAAqB,EAAEQ,wBAAwB;AANzC,GAAP;AAQA,CAfc,EAeVf,iBAfU,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { withSelect } from '@wordpress/data';\nimport { getDefaultBlockName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport DefaultBlockAppender from '../default-block-appender';\nimport ButtonBlockAppender from '../button-block-appender';\nimport { store as blockEditorStore } from '../../store';\n\nfunction BlockListAppender( {\n\trootClientId,\n\tcanInsertDefaultBlock,\n\tisLocked,\n\trenderAppender: CustomAppender,\n\tclassName,\n\tselectedBlockClientId,\n\ttagName: TagName = 'div',\n} ) {\n\tif ( isLocked || CustomAppender === false ) {\n\t\treturn null;\n\t}\n\n\tlet appender;\n\tif ( CustomAppender ) {\n\t\t// Prefer custom render prop if provided.\n\t\tappender = <CustomAppender />;\n\t} else {\n\t\tconst isParentSelected =\n\t\t\tselectedBlockClientId === rootClientId ||\n\t\t\t( ! rootClientId && ! selectedBlockClientId );\n\n\t\tif ( ! isParentSelected ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( canInsertDefaultBlock ) {\n\t\t\t// Render the default block appender when renderAppender has not been\n\t\t\t// provided and the context supports use of the default appender.\n\t\t\tappender = <DefaultBlockAppender rootClientId={ rootClientId } />;\n\t\t} else {\n\t\t\t// Fallback in the case no renderAppender has been provided and the\n\t\t\t// default block can't be inserted.\n\t\t\tappender = (\n\t\t\t\t<ButtonBlockAppender\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclassName=\"block-list-appender__toggle\"\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\t}\n\n\treturn (\n\t\t<TagName\n\t\t\t// A `tabIndex` is used on the wrapping `div` element in order to\n\t\t\t// force a focus event to occur when an appender `button` element\n\t\t\t// is clicked. In some browsers (Firefox, Safari), button clicks do\n\t\t\t// not emit a focus event, which could cause this event to propagate\n\t\t\t// unexpectedly. The `tabIndex` ensures that the interaction is\n\t\t\t// captured as a focus, without also adding an extra tab stop.\n\t\t\t//\n\t\t\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\t\t\ttabIndex={ -1 }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-list-appender wp-block',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\t// Needed in case the whole editor is content editable (for multi\n\t\t\t// selection). It fixes an edge case where ArrowDown and ArrowRight\n\t\t\t// should collapse the selection to the end of that selection and\n\t\t\t// not into the appender.\n\t\t\tcontentEditable={ false }\n\t\t\t// The appender exists to let you add the first Paragraph before\n\t\t\t// any is inserted. To that end, this appender should visually be\n\t\t\t// presented as a block. That means theme CSS should style it as if\n\t\t\t// it were an empty paragraph block. That means a `wp-block` class to\n\t\t\t// ensure the width is correct, and a [data-block] attribute to ensure\n\t\t\t// the correct margin is applied, especially for classic themes which\n\t\t\t// have commonly targeted that attribute for margins.\n\t\t\tdata-block\n\t\t>\n\t\t\t{ appender }\n\t\t</TagName>\n\t);\n}\n\nexport default withSelect( ( select, { rootClientId } ) => {\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetTemplateLock,\n\t\tgetSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\n\treturn {\n\t\tisLocked: !! getTemplateLock( rootClientId ),\n\t\tcanInsertDefaultBlock: canInsertBlockType(\n\t\t\tgetDefaultBlockName(),\n\t\t\trootClientId\n\t\t),\n\t\tselectedBlockClientId: getSelectedBlockClientId(),\n\t};\n} )( BlockListAppender );\n"]}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ Object.defineProperty(exports, "BlockLockMenuItem", {
9
+ enumerable: true,
10
+ get: function () {
11
+ return _menuItem.default;
12
+ }
13
+ });
14
+ Object.defineProperty(exports, "BlockLockModal", {
15
+ enumerable: true,
16
+ get: function () {
17
+ return _modal.default;
18
+ }
19
+ });
20
+ Object.defineProperty(exports, "BlockLockToolbar", {
21
+ enumerable: true,
22
+ get: function () {
23
+ return _toolbar.default;
24
+ }
25
+ });
26
+
27
+ var _menuItem = _interopRequireDefault(require("./menu-item"));
28
+
29
+ var _modal = _interopRequireDefault(require("./modal"));
30
+
31
+ var _toolbar = _interopRequireDefault(require("./toolbar"));
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA","sourcesContent":["export { default as BlockLockMenuItem } from './menu-item';\nexport { default as BlockLockModal } from './modal';\nexport { default as BlockLockToolbar } from './toolbar';\n"]}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = BlockLockMenuItem;
9
+
10
+ var _element = require("@wordpress/element");
11
+
12
+ var _i18n = require("@wordpress/i18n");
13
+
14
+ var _components = require("@wordpress/components");
15
+
16
+ var _data = require("@wordpress/data");
17
+
18
+ var _icons = require("@wordpress/icons");
19
+
20
+ var _modal = _interopRequireDefault(require("./modal"));
21
+
22
+ var _store = require("../../store");
23
+
24
+ /**
25
+ * WordPress dependencies
26
+ */
27
+
28
+ /**
29
+ * Internal dependencies
30
+ */
31
+ function BlockLockMenuItem(_ref) {
32
+ let {
33
+ clientId
34
+ } = _ref;
35
+ const {
36
+ canLockBlock,
37
+ isLocked
38
+ } = (0, _data.useSelect)(select => {
39
+ const {
40
+ canMoveBlock,
41
+ canRemoveBlock,
42
+ canLockBlockType,
43
+ getBlockName,
44
+ getBlockRootClientId
45
+ } = select(_store.store);
46
+ const rootClientId = getBlockRootClientId(clientId);
47
+ return {
48
+ canLockBlock: canLockBlockType(getBlockName(clientId)),
49
+ isLocked: !canMoveBlock(clientId, rootClientId) || !canRemoveBlock(clientId, rootClientId)
50
+ };
51
+ }, [clientId]);
52
+ const [isModalOpen, toggleModal] = (0, _element.useReducer)(isActive => !isActive, false);
53
+
54
+ if (!canLockBlock) {
55
+ return null;
56
+ }
57
+
58
+ const label = isLocked ? (0, _i18n.__)('Unlock') : (0, _i18n.__)('Lock');
59
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.MenuItem, {
60
+ icon: isLocked ? _icons.unlock : _icons.lock,
61
+ onClick: toggleModal
62
+ }, label), isModalOpen && (0, _element.createElement)(_modal.default, {
63
+ clientId: clientId,
64
+ onClose: toggleModal
65
+ }));
66
+ }
67
+ //# sourceMappingURL=menu-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/menu-item.js"],"names":["BlockLockMenuItem","clientId","canLockBlock","isLocked","select","canMoveBlock","canRemoveBlock","canLockBlockType","getBlockName","getBlockRootClientId","blockEditorStore","rootClientId","isModalOpen","toggleModal","isActive","label","unlock","lock"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AAbA;AACA;AACA;;AAOA;AACA;AACA;AAIe,SAASA,iBAAT,OAA2C;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACzD,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAA6B,qBAChCC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,YADK;AAELC,MAAAA,cAFK;AAGLC,MAAAA,gBAHK;AAILC,MAAAA,YAJK;AAKLC,MAAAA;AALK,QAMFL,MAAM,CAAEM,YAAF,CANV;AAOA,UAAMC,YAAY,GAAGF,oBAAoB,CAAER,QAAF,CAAzC;AAEA,WAAO;AACNC,MAAAA,YAAY,EAAEK,gBAAgB,CAAEC,YAAY,CAAEP,QAAF,CAAd,CADxB;AAENE,MAAAA,QAAQ,EACP,CAAEE,YAAY,CAAEJ,QAAF,EAAYU,YAAZ,CAAd,IACA,CAAEL,cAAc,CAAEL,QAAF,EAAYU,YAAZ;AAJX,KAAP;AAMA,GAjBiC,EAkBlC,CAAEV,QAAF,CAlBkC,CAAnC;AAqBA,QAAM,CAAEW,WAAF,EAAeC,WAAf,IAA+B,yBAClCC,QAAF,IAAgB,CAAEA,QADkB,EAEpC,KAFoC,CAArC;;AAKA,MAAK,CAAEZ,YAAP,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,QAAMa,KAAK,GAAGZ,QAAQ,GAAG,cAAI,QAAJ,CAAH,GAAoB,cAAI,MAAJ,CAA1C;AAEA,SACC,qDACC,4BAAC,oBAAD;AAAU,IAAA,IAAI,EAAGA,QAAQ,GAAGa,aAAH,GAAYC,WAArC;AAA4C,IAAA,OAAO,EAAGJ;AAAtD,KACGE,KADH,CADD,EAIGH,WAAW,IACZ,4BAAC,cAAD;AAAgB,IAAA,QAAQ,EAAGX,QAA3B;AAAsC,IAAA,OAAO,EAAGY;AAAhD,IALF,CADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useReducer } from '@wordpress/element';\nimport { MenuItem } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { lock, unlock } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BlockLockModal from './modal';\nimport { store as blockEditorStore } from '../../store';\n\nexport default function BlockLockMenuItem( { clientId } ) {\n\tconst { canLockBlock, isLocked } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanMoveBlock,\n\t\t\t\tcanRemoveBlock,\n\t\t\t\tcanLockBlockType,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn {\n\t\t\t\tcanLockBlock: canLockBlockType( getBlockName( clientId ) ),\n\t\t\t\tisLocked:\n\t\t\t\t\t! canMoveBlock( clientId, rootClientId ) ||\n\t\t\t\t\t! canRemoveBlock( clientId, rootClientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst [ isModalOpen, toggleModal ] = useReducer(\n\t\t( isActive ) => ! isActive,\n\t\tfalse\n\t);\n\n\tif ( ! canLockBlock ) {\n\t\treturn null;\n\t}\n\n\tconst label = isLocked ? __( 'Unlock' ) : __( 'Lock' );\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem icon={ isLocked ? unlock : lock } onClick={ toggleModal }>\n\t\t\t\t{ label }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<BlockLockModal clientId={ clientId } onClose={ toggleModal } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = BlockLockModal;
9
+
10
+ var _element = require("@wordpress/element");
11
+
12
+ var _i18n = require("@wordpress/i18n");
13
+
14
+ var _components = require("@wordpress/components");
15
+
16
+ var _icons = require("@wordpress/icons");
17
+
18
+ var _compose = require("@wordpress/compose");
19
+
20
+ var _data = require("@wordpress/data");
21
+
22
+ var _useBlockDisplayInformation = _interopRequireDefault(require("../use-block-display-information"));
23
+
24
+ var _store = require("../../store");
25
+
26
+ /**
27
+ * WordPress dependencies
28
+ */
29
+
30
+ /**
31
+ * Internal dependencies
32
+ */
33
+ function BlockLockModal(_ref) {
34
+ let {
35
+ clientId,
36
+ onClose
37
+ } = _ref;
38
+ const [lock, setLock] = (0, _element.useState)({
39
+ move: false,
40
+ remove: false
41
+ });
42
+ const {
43
+ canMove,
44
+ canRemove
45
+ } = (0, _data.useSelect)(select => {
46
+ const {
47
+ canMoveBlock,
48
+ canRemoveBlock,
49
+ getBlockRootClientId
50
+ } = select(_store.store);
51
+ const rootClientId = getBlockRootClientId(clientId);
52
+ return {
53
+ canMove: canMoveBlock(clientId, rootClientId),
54
+ canRemove: canRemoveBlock(clientId, rootClientId)
55
+ };
56
+ }, [clientId]);
57
+ const {
58
+ updateBlockAttributes
59
+ } = (0, _data.useDispatch)(_store.store);
60
+ const blockInformation = (0, _useBlockDisplayInformation.default)(clientId);
61
+ const instanceId = (0, _compose.useInstanceId)(BlockLockModal, 'block-editor-block-lock-modal__options-title');
62
+ (0, _element.useEffect)(() => {
63
+ setLock({
64
+ move: !canMove,
65
+ remove: !canRemove
66
+ });
67
+ }, [canMove, canRemove]);
68
+ const isAllChecked = Object.values(lock).every(Boolean);
69
+ const isIndeterminate = Object.values(lock).some(Boolean) && !isAllChecked;
70
+ return (0, _element.createElement)(_components.Modal, {
71
+ title: (0, _i18n.sprintf)(
72
+ /* translators: %s: Name of the block. */
73
+ (0, _i18n.__)('Lock %s'), blockInformation.title),
74
+ overlayClassName: "block-editor-block-lock-modal",
75
+ closeLabel: (0, _i18n.__)('Close'),
76
+ onRequestClose: onClose
77
+ }, (0, _element.createElement)("form", {
78
+ onSubmit: event => {
79
+ event.preventDefault();
80
+ updateBlockAttributes([clientId], {
81
+ lock
82
+ });
83
+ onClose();
84
+ }
85
+ }, (0, _element.createElement)("p", null, (0, _i18n.__)('Choose specific attributes to restrict or lock all available options.')), (0, _element.createElement)("div", {
86
+ role: "group",
87
+ "aria-labelledby": instanceId,
88
+ className: "block-editor-block-lock-modal__options"
89
+ }, (0, _element.createElement)(_components.CheckboxControl, {
90
+ className: "block-editor-block-lock-modal__options-title",
91
+ label: (0, _element.createElement)("span", {
92
+ id: instanceId
93
+ }, (0, _i18n.__)('Lock all')),
94
+ checked: isAllChecked,
95
+ indeterminate: isIndeterminate,
96
+ onChange: newValue => setLock({
97
+ move: newValue,
98
+ remove: newValue
99
+ })
100
+ }), (0, _element.createElement)("ul", {
101
+ className: "block-editor-block-lock-modal__checklist"
102
+ }, (0, _element.createElement)("li", {
103
+ className: "block-editor-block-lock-modal__checklist-item"
104
+ }, (0, _element.createElement)(_components.CheckboxControl, {
105
+ label: (0, _element.createElement)(_element.Fragment, null, (0, _i18n.__)('Disable movement'), (0, _element.createElement)(_components.Icon, {
106
+ icon: lock.move ? _icons.lock : _icons.unlock
107
+ })),
108
+ checked: lock.move,
109
+ onChange: move => setLock(prevLock => ({ ...prevLock,
110
+ move
111
+ }))
112
+ })), (0, _element.createElement)("li", {
113
+ className: "block-editor-block-lock-modal__checklist-item"
114
+ }, (0, _element.createElement)(_components.CheckboxControl, {
115
+ label: (0, _element.createElement)(_element.Fragment, null, (0, _i18n.__)('Prevent removal'), (0, _element.createElement)(_components.Icon, {
116
+ icon: lock.remove ? _icons.lock : _icons.unlock
117
+ })),
118
+ checked: lock.remove,
119
+ onChange: remove => setLock(prevLock => ({ ...prevLock,
120
+ remove
121
+ }))
122
+ })))), (0, _element.createElement)(_components.Flex, {
123
+ className: "block-editor-block-lock-modal__actions",
124
+ justify: "flex-end",
125
+ expanded: false
126
+ }, (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.Button, {
127
+ variant: "tertiary",
128
+ onClick: onClose
129
+ }, (0, _i18n.__)('Cancel'))), (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.Button, {
130
+ variant: "primary",
131
+ type: "submit"
132
+ }, (0, _i18n.__)('Apply'))))));
133
+ }
134
+ //# sourceMappingURL=modal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/modal.js"],"names":["BlockLockModal","clientId","onClose","lock","setLock","move","remove","canMove","canRemove","select","canMoveBlock","canRemoveBlock","getBlockRootClientId","blockEditorStore","rootClientId","updateBlockAttributes","blockInformation","instanceId","isAllChecked","Object","values","every","Boolean","isIndeterminate","some","title","event","preventDefault","newValue","lockIcon","unlockIcon","prevLock"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useEffect, useState } from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tFlex,\n\tFlexItem,\n\tIcon,\n\tModal,\n} from '@wordpress/components';\nimport { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { store as blockEditorStore } from '../../store';\n\nexport default function BlockLockModal( { clientId, onClose } ) {\n\tconst [ lock, setLock ] = useState( { move: false, remove: false } );\n\tconst { canMove, canRemove } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanMoveBlock,\n\t\t\t\tcanRemoveBlock,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn {\n\t\t\t\tcanMove: canMoveBlock( clientId, rootClientId ),\n\t\t\t\tcanRemove: canRemoveBlock( clientId, rootClientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst instanceId = useInstanceId(\n\t\tBlockLockModal,\n\t\t'block-editor-block-lock-modal__options-title'\n\t);\n\n\tuseEffect( () => {\n\t\tsetLock( {\n\t\t\tmove: ! canMove,\n\t\t\tremove: ! canRemove,\n\t\t} );\n\t}, [ canMove, canRemove ] );\n\n\tconst isAllChecked = Object.values( lock ).every( Boolean );\n\tconst isIndeterminate =\n\t\tObject.values( lock ).some( Boolean ) && ! isAllChecked;\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ sprintf(\n\t\t\t\t/* translators: %s: Name of the block. */\n\t\t\t\t__( 'Lock %s' ),\n\t\t\t\tblockInformation.title\n\t\t\t) }\n\t\t\toverlayClassName=\"block-editor-block-lock-modal\"\n\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tupdateBlockAttributes( [ clientId ], { lock } );\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Choose specific attributes to restrict or lock all available options.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t\t<div\n\t\t\t\t\trole=\"group\"\n\t\t\t\t\taria-labelledby={ instanceId }\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options\"\n\t\t\t\t>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options-title\"\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t<span id={ instanceId }>{ __( 'Lock all' ) }</span>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchecked={ isAllChecked }\n\t\t\t\t\t\tindeterminate={ isIndeterminate }\n\t\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\t\tsetLock( {\n\t\t\t\t\t\t\t\tmove: newValue,\n\t\t\t\t\t\t\t\tremove: newValue,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<ul className=\"block-editor-block-lock-modal__checklist\">\n\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Disable movement' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tlock.move\n\t\t\t\t\t\t\t\t\t\t\t\t\t? lockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t: unlockIcon\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</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ lock.move }\n\t\t\t\t\t\t\t\tonChange={ ( move ) =>\n\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\tmove,\n\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Prevent removal' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tlock.remove\n\t\t\t\t\t\t\t\t\t\t\t\t\t? lockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t: unlockIcon\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</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ lock.remove }\n\t\t\t\t\t\t\t\tonChange={ ( remove ) =>\n\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\tremove,\n\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t</div>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = BlockLockToolbar;
9
+
10
+ var _element = require("@wordpress/element");
11
+
12
+ var _i18n = require("@wordpress/i18n");
13
+
14
+ var _components = require("@wordpress/components");
15
+
16
+ var _icons = require("@wordpress/icons");
17
+
18
+ var _data = require("@wordpress/data");
19
+
20
+ var _modal = _interopRequireDefault(require("./modal"));
21
+
22
+ var _useBlockDisplayInformation = _interopRequireDefault(require("../use-block-display-information"));
23
+
24
+ var _store = require("../../store");
25
+
26
+ /**
27
+ * WordPress dependencies
28
+ */
29
+
30
+ /**
31
+ * Internal dependencies
32
+ */
33
+ function BlockLockToolbar(_ref) {
34
+ let {
35
+ clientId
36
+ } = _ref;
37
+ const blockInformation = (0, _useBlockDisplayInformation.default)(clientId);
38
+ const {
39
+ canMove,
40
+ canRemove,
41
+ canLockBlock
42
+ } = (0, _data.useSelect)(select => {
43
+ const {
44
+ canMoveBlock,
45
+ canRemoveBlock,
46
+ canLockBlockType,
47
+ getBlockName
48
+ } = select(_store.store);
49
+ return {
50
+ canMove: canMoveBlock(clientId),
51
+ canRemove: canRemoveBlock(clientId),
52
+ canLockBlock: canLockBlockType(getBlockName(clientId))
53
+ };
54
+ }, [clientId]);
55
+ const [isModalOpen, toggleModal] = (0, _element.useReducer)(isActive => !isActive, false);
56
+
57
+ if (!canLockBlock) {
58
+ return null;
59
+ }
60
+
61
+ if (canMove && canRemove) {
62
+ return null;
63
+ }
64
+
65
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.ToolbarGroup, {
66
+ className: "block-editor-block-lock-toolbar"
67
+ }, (0, _element.createElement)(_components.ToolbarButton, {
68
+ icon: _icons.lock,
69
+ label: (0, _i18n.sprintf)(
70
+ /* translators: %s: block name */
71
+ (0, _i18n.__)('Unlock %s'), blockInformation.title),
72
+ onClick: toggleModal
73
+ })), isModalOpen && (0, _element.createElement)(_modal.default, {
74
+ clientId: clientId,
75
+ onClose: toggleModal
76
+ }));
77
+ }
78
+ //# sourceMappingURL=toolbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/toolbar.js"],"names":["BlockLockToolbar","clientId","blockInformation","canMove","canRemove","canLockBlock","select","canMoveBlock","canRemoveBlock","canLockBlockType","getBlockName","blockEditorStore","isModalOpen","toggleModal","isActive","lock","title"],"mappings":";;;;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AAdA;AACA;AACA;;AAOA;AACA;AACA;AAKe,SAASA,gBAAT,OAA0C;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACxD,QAAMC,gBAAgB,GAAG,yCAA4BD,QAA5B,CAAzB;AACA,QAAM;AAAEE,IAAAA,OAAF;AAAWC,IAAAA,SAAX;AAAsBC,IAAAA;AAAtB,MAAuC,qBAC1CC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,YADK;AAELC,MAAAA,cAFK;AAGLC,MAAAA,gBAHK;AAILC,MAAAA;AAJK,QAKFJ,MAAM,CAAEK,YAAF,CALV;AAOA,WAAO;AACNR,MAAAA,OAAO,EAAEI,YAAY,CAAEN,QAAF,CADf;AAENG,MAAAA,SAAS,EAAEI,cAAc,CAAEP,QAAF,CAFnB;AAGNI,MAAAA,YAAY,EAAEI,gBAAgB,CAAEC,YAAY,CAAET,QAAF,CAAd;AAHxB,KAAP;AAKA,GAd2C,EAe5C,CAAEA,QAAF,CAf4C,CAA7C;AAkBA,QAAM,CAAEW,WAAF,EAAeC,WAAf,IAA+B,yBAClCC,QAAF,IAAgB,CAAEA,QADkB,EAEpC,KAFoC,CAArC;;AAKA,MAAK,CAAET,YAAP,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,MAAKF,OAAO,IAAIC,SAAhB,EAA4B;AAC3B,WAAO,IAAP;AACA;;AAED,SACC,qDACC,4BAAC,wBAAD;AAAc,IAAA,SAAS,EAAC;AAAxB,KACC,4BAAC,yBAAD;AACC,IAAA,IAAI,EAAGW,WADR;AAEC,IAAA,KAAK,EAAG;AACP;AACA,kBAAI,WAAJ,CAFO,EAGPb,gBAAgB,CAACc,KAHV,CAFT;AAOC,IAAA,OAAO,EAAGH;AAPX,IADD,CADD,EAYGD,WAAW,IACZ,4BAAC,cAAD;AAAgB,IAAA,QAAQ,EAAGX,QAA3B;AAAsC,IAAA,OAAO,EAAGY;AAAhD,IAbF,CADD;AAkBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { useReducer } from '@wordpress/element';\nimport { lock } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockLockModal from './modal';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { store as blockEditorStore } from '../../store';\n\nexport default function BlockLockToolbar( { clientId } ) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst { canMove, canRemove, canLockBlock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanMoveBlock,\n\t\t\t\tcanRemoveBlock,\n\t\t\t\tcanLockBlockType,\n\t\t\t\tgetBlockName,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tcanMove: canMoveBlock( clientId ),\n\t\t\t\tcanRemove: canRemoveBlock( clientId ),\n\t\t\t\tcanLockBlock: canLockBlockType( getBlockName( clientId ) ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst [ isModalOpen, toggleModal ] = useReducer(\n\t\t( isActive ) => ! isActive,\n\t\tfalse\n\t);\n\n\tif ( ! canLockBlock ) {\n\t\treturn null;\n\t}\n\n\tif ( canMove && canRemove ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarGroup className=\"block-editor-block-lock-toolbar\">\n\t\t\t\t<ToolbarButton\n\t\t\t\t\ticon={ lock }\n\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t/* translators: %s: block name */\n\t\t\t\t\t\t__( 'Unlock %s' ),\n\t\t\t\t\t\tblockInformation.title\n\t\t\t\t\t) }\n\t\t\t\t\tonClick={ toggleModal }\n\t\t\t\t/>\n\t\t\t</ToolbarGroup>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<BlockLockModal clientId={ clientId } onClose={ toggleModal } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
@@ -98,6 +98,10 @@ function BlockMover(_ref) {
98
98
  clientIds: clientIds
99
99
  }, itemProps)))));
100
100
  }
101
+ /**
102
+ * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-mover/README.md
103
+ */
104
+
101
105
 
102
106
  var _default = (0, _data.withSelect)((select, _ref2) => {
103
107
  var _getBlockListSettings;