@wordpress/block-editor 15.21.1 → 15.22.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 (490) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -2
  3. package/build/components/block-card/index.cjs +4 -5
  4. package/build/components/block-card/index.cjs.map +2 -2
  5. package/build/components/block-editing-mode/index.cjs +13 -7
  6. package/build/components/block-editing-mode/index.cjs.map +2 -2
  7. package/build/components/block-inspector/index.cjs +35 -20
  8. package/build/components/block-inspector/index.cjs.map +2 -2
  9. package/build/components/block-mover/mover-description.cjs +6 -6
  10. package/build/components/block-mover/mover-description.cjs.map +1 -1
  11. package/build/components/block-patterns-list/index.cjs.map +2 -2
  12. package/build/components/block-patterns-paging/index.cjs +4 -4
  13. package/build/components/block-patterns-paging/index.cjs.map +2 -2
  14. package/build/components/block-popover/use-popover-scroll.cjs.map +1 -1
  15. package/build/components/block-quick-navigation/index.cjs +7 -5
  16. package/build/components/block-quick-navigation/index.cjs.map +2 -2
  17. package/build/components/block-rename/modal.cjs +0 -1
  18. package/build/components/block-rename/modal.cjs.map +2 -2
  19. package/build/components/block-toolbar/block-toolbar-icon.cjs +14 -6
  20. package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
  21. package/build/components/block-toolbar/edit-section-button.cjs.map +1 -1
  22. package/build/components/block-tools/use-block-toolbar-popover-props.cjs +10 -4
  23. package/build/components/block-tools/use-block-toolbar-popover-props.cjs.map +2 -2
  24. package/build/components/child-layout-control/index.cjs +51 -19
  25. package/build/components/child-layout-control/index.cjs.map +2 -2
  26. package/build/components/colors-gradients/control.cjs +25 -14
  27. package/build/components/colors-gradients/control.cjs.map +2 -2
  28. package/build/components/colors-gradients/dropdown.cjs +4 -1
  29. package/build/components/colors-gradients/dropdown.cjs.map +3 -3
  30. package/build/components/contrast-checker/index.cjs +22 -4
  31. package/build/components/contrast-checker/index.cjs.map +2 -2
  32. package/build/components/date-format-picker/index.cjs +0 -1
  33. package/build/components/date-format-picker/index.cjs.map +2 -2
  34. package/build/components/dimensions-tool/index.cjs +4 -5
  35. package/build/components/dimensions-tool/index.cjs.map +2 -2
  36. package/build/components/dimensions-tool/scale-tool.cjs +1 -1
  37. package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
  38. package/build/components/global-styles/background-panel.cjs +153 -25
  39. package/build/components/global-styles/background-panel.cjs.map +3 -3
  40. package/build/components/global-styles/color-gradient-dropdown-item.cjs +227 -0
  41. package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +7 -0
  42. package/build/components/global-styles/color-panel.cjs +98 -375
  43. package/build/components/global-styles/color-panel.cjs.map +3 -3
  44. package/build/components/global-styles/dimensions-panel.cjs +1 -4
  45. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  46. package/build/components/global-styles/hooks.cjs +34 -0
  47. package/build/components/global-styles/hooks.cjs.map +2 -2
  48. package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
  49. package/build/components/global-styles/typography-panel.cjs +82 -10
  50. package/build/components/global-styles/typography-panel.cjs.map +3 -3
  51. package/build/components/grid/grid-item-resizer.cjs.map +1 -1
  52. package/build/components/grid/grid-visualizer.cjs.map +1 -1
  53. package/build/components/iframe/index.cjs +6 -3
  54. package/build/components/iframe/index.cjs.map +3 -3
  55. package/build/components/image-editor/use-transform-image.cjs.map +1 -1
  56. package/build/components/inserter/get-appender-label.cjs.map +1 -1
  57. package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
  58. package/build/components/inserter/search-items.cjs.map +1 -1
  59. package/build/components/inspector-controls/fill.cjs +1 -3
  60. package/build/components/inspector-controls/fill.cjs.map +2 -2
  61. package/build/components/inspector-controls/groups.cjs +2 -0
  62. package/build/components/inspector-controls/groups.cjs.map +2 -2
  63. package/build/components/inspector-controls-tabs/index.cjs.map +2 -2
  64. package/build/components/inspector-controls-tabs/styles-tab.cjs +76 -32
  65. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  66. package/build/components/keyboard-shortcuts/index.cjs.map +1 -1
  67. package/build/components/line-height-control/index.cjs.map +1 -1
  68. package/build/components/link-control/index.cjs +2 -3
  69. package/build/components/link-control/index.cjs.map +2 -2
  70. package/build/components/link-control/normalize-url.cjs.map +1 -1
  71. package/build/components/list-view/block-select-button.cjs +1 -10
  72. package/build/components/list-view/block-select-button.cjs.map +3 -3
  73. package/build/components/list-view/utils.cjs.map +1 -1
  74. package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
  75. package/build/components/provider/index.cjs.map +1 -1
  76. package/build/components/provider/use-block-sync.cjs +3 -1
  77. package/build/components/provider/use-block-sync.cjs.map +2 -2
  78. package/build/components/rich-text/event-listeners/before-input-rules.cjs +1 -1
  79. package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +2 -2
  80. package/build/components/rich-text/event-listeners/paste-handler.cjs.map +1 -1
  81. package/build/components/rich-text/prevent-event-discovery.cjs +1 -1
  82. package/build/components/rich-text/prevent-event-discovery.cjs.map +1 -1
  83. package/build/components/url-popover/image-url-input-ui.cjs +0 -2
  84. package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
  85. package/build/components/use-block-display-information/index.cjs +10 -3
  86. package/build/components/use-block-display-information/index.cjs.map +2 -2
  87. package/build/components/writing-flow/use-tab-nav.cjs.map +1 -1
  88. package/build/hooks/anchor.cjs +1 -2
  89. package/build/hooks/anchor.cjs.map +2 -2
  90. package/build/hooks/background.cjs +124 -75
  91. package/build/hooks/background.cjs.map +3 -3
  92. package/build/hooks/block-fields/index.cjs +13 -2
  93. package/build/hooks/block-fields/index.cjs.map +2 -2
  94. package/build/hooks/color.cjs +0 -162
  95. package/build/hooks/color.cjs.map +3 -3
  96. package/build/hooks/contrast-checker.cjs +31 -28
  97. package/build/hooks/contrast-checker.cjs.map +3 -3
  98. package/build/hooks/custom-class-name.cjs +0 -1
  99. package/build/hooks/custom-class-name.cjs.map +2 -2
  100. package/build/hooks/dimensions.cjs +13 -2
  101. package/build/hooks/dimensions.cjs.map +2 -2
  102. package/build/hooks/elements.cjs +142 -0
  103. package/build/hooks/elements.cjs.map +7 -0
  104. package/build/hooks/grid-visualizer.cjs +21 -11
  105. package/build/hooks/grid-visualizer.cjs.map +2 -2
  106. package/build/hooks/layout-child.cjs +65 -10
  107. package/build/hooks/layout-child.cjs.map +2 -2
  108. package/build/hooks/layout.cjs +6 -3
  109. package/build/hooks/layout.cjs.map +2 -2
  110. package/build/hooks/list-view.cjs +10 -7
  111. package/build/hooks/list-view.cjs.map +2 -2
  112. package/build/hooks/spacing-visualizer.cjs.map +1 -1
  113. package/build/hooks/state-utils.cjs.map +1 -1
  114. package/build/hooks/states.cjs +2 -2
  115. package/build/hooks/states.cjs.map +2 -2
  116. package/build/hooks/style.cjs +50 -6
  117. package/build/hooks/style.cjs.map +2 -2
  118. package/build/hooks/typography.cjs +62 -10
  119. package/build/hooks/typography.cjs.map +3 -3
  120. package/build/layouts/flex.cjs +99 -6
  121. package/build/layouts/flex.cjs.map +2 -2
  122. package/build/private-apis.cjs +4 -0
  123. package/build/private-apis.cjs.map +2 -2
  124. package/build/store/actions.cjs.map +1 -1
  125. package/build/store/private-selectors.cjs +19 -2
  126. package/build/store/private-selectors.cjs.map +2 -2
  127. package/build/store/reducer.cjs.map +1 -1
  128. package/build/store/selectors.cjs.map +1 -1
  129. package/build/utils/block-bindings.cjs +9 -9
  130. package/build/utils/block-bindings.cjs.map +3 -3
  131. package/build/utils/color-values.cjs +10 -1
  132. package/build/utils/color-values.cjs.map +3 -3
  133. package/build/utils/dom.cjs +2 -5
  134. package/build/utils/dom.cjs.map +3 -3
  135. package/build/utils/fit-text-frontend.cjs +6 -2
  136. package/build/utils/fit-text-frontend.cjs.map +3 -3
  137. package/build/utils/fit-text-utils.cjs +1 -1
  138. package/build/utils/fit-text-utils.cjs.map +3 -3
  139. package/build/utils/format-font-style.cjs +1 -1
  140. package/build/utils/format-font-style.cjs.map +3 -3
  141. package/build/utils/format-font-weight.cjs +1 -1
  142. package/build/utils/format-font-weight.cjs.map +3 -3
  143. package/build/utils/get-editor-region.cjs +4 -2
  144. package/build/utils/get-editor-region.cjs.map +3 -3
  145. package/build/utils/get-font-styles-and-weights.cjs +8 -12
  146. package/build/utils/get-font-styles-and-weights.cjs.map +3 -3
  147. package/build/utils/get-px-from-css-unit.cjs +1 -1
  148. package/build/utils/get-px-from-css-unit.cjs.map +1 -1
  149. package/build/utils/index.cjs +1 -1
  150. package/build/utils/index.cjs.map +1 -1
  151. package/build/utils/math.cjs +1 -1
  152. package/build/utils/math.cjs.map +3 -3
  153. package/build/utils/object.cjs +8 -8
  154. package/build/utils/object.cjs.map +3 -3
  155. package/build/utils/order-inserter-block-items.cjs +1 -1
  156. package/build/utils/order-inserter-block-items.cjs.map +3 -3
  157. package/build/utils/pasting.cjs +4 -2
  158. package/build/utils/pasting.cjs.map +3 -3
  159. package/build/utils/selection.cjs +3 -2
  160. package/build/utils/selection.cjs.map +3 -3
  161. package/build/utils/sorting.cjs +9 -3
  162. package/build/utils/sorting.cjs.map +3 -3
  163. package/build/utils/transform-styles/index.cjs +3 -2
  164. package/build/utils/transform-styles/index.cjs.map +3 -3
  165. package/build/utils/transform-styles/postcss-urlrebase.d.cjs +2 -0
  166. package/build/utils/transform-styles/postcss-urlrebase.d.cjs.map +7 -0
  167. package/build/utils/transform-styles/types.cjs +19 -0
  168. package/build/utils/transform-styles/types.cjs.map +7 -0
  169. package/build/utils/types.cjs +19 -0
  170. package/build/utils/types.cjs.map +7 -0
  171. package/build-module/components/block-card/index.mjs +5 -6
  172. package/build-module/components/block-card/index.mjs.map +2 -2
  173. package/build-module/components/block-editing-mode/index.mjs +14 -8
  174. package/build-module/components/block-editing-mode/index.mjs.map +2 -2
  175. package/build-module/components/block-inspector/index.mjs +35 -21
  176. package/build-module/components/block-inspector/index.mjs.map +2 -2
  177. package/build-module/components/block-mover/mover-description.mjs +6 -6
  178. package/build-module/components/block-mover/mover-description.mjs.map +1 -1
  179. package/build-module/components/block-patterns-list/index.mjs.map +2 -2
  180. package/build-module/components/block-patterns-paging/index.mjs +4 -4
  181. package/build-module/components/block-patterns-paging/index.mjs.map +2 -2
  182. package/build-module/components/block-popover/use-popover-scroll.mjs.map +1 -1
  183. package/build-module/components/block-quick-navigation/index.mjs +8 -6
  184. package/build-module/components/block-quick-navigation/index.mjs.map +2 -2
  185. package/build-module/components/block-rename/modal.mjs +0 -1
  186. package/build-module/components/block-rename/modal.mjs.map +2 -2
  187. package/build-module/components/block-toolbar/block-toolbar-icon.mjs +14 -6
  188. package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
  189. package/build-module/components/block-toolbar/edit-section-button.mjs.map +1 -1
  190. package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs +10 -4
  191. package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs.map +2 -2
  192. package/build-module/components/child-layout-control/index.mjs +51 -19
  193. package/build-module/components/child-layout-control/index.mjs.map +2 -2
  194. package/build-module/components/colors-gradients/control.mjs +27 -15
  195. package/build-module/components/colors-gradients/control.mjs.map +2 -2
  196. package/build-module/components/colors-gradients/dropdown.mjs +4 -1
  197. package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
  198. package/build-module/components/contrast-checker/index.mjs +18 -4
  199. package/build-module/components/contrast-checker/index.mjs.map +2 -2
  200. package/build-module/components/date-format-picker/index.mjs +0 -1
  201. package/build-module/components/date-format-picker/index.mjs.map +2 -2
  202. package/build-module/components/dimensions-tool/index.mjs +4 -5
  203. package/build-module/components/dimensions-tool/index.mjs.map +2 -2
  204. package/build-module/components/dimensions-tool/scale-tool.mjs +1 -1
  205. package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
  206. package/build-module/components/global-styles/background-panel.mjs +155 -27
  207. package/build-module/components/global-styles/background-panel.mjs.map +2 -2
  208. package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +207 -0
  209. package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +7 -0
  210. package/build-module/components/global-styles/color-panel.mjs +106 -387
  211. package/build-module/components/global-styles/color-panel.mjs.map +3 -3
  212. package/build-module/components/global-styles/dimensions-panel.mjs +1 -5
  213. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  214. package/build-module/components/global-styles/hooks.mjs +33 -0
  215. package/build-module/components/global-styles/hooks.mjs.map +2 -2
  216. package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
  217. package/build-module/components/global-styles/typography-panel.mjs +84 -10
  218. package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
  219. package/build-module/components/grid/grid-item-resizer.mjs.map +1 -1
  220. package/build-module/components/grid/grid-visualizer.mjs.map +1 -1
  221. package/build-module/components/iframe/index.mjs +6 -3
  222. package/build-module/components/iframe/index.mjs.map +2 -2
  223. package/build-module/components/image-editor/use-transform-image.mjs.map +1 -1
  224. package/build-module/components/inserter/get-appender-label.mjs.map +1 -1
  225. package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
  226. package/build-module/components/inserter/search-items.mjs.map +1 -1
  227. package/build-module/components/inspector-controls/fill.mjs +1 -3
  228. package/build-module/components/inspector-controls/fill.mjs.map +2 -2
  229. package/build-module/components/inspector-controls/groups.mjs +2 -0
  230. package/build-module/components/inspector-controls/groups.mjs.map +2 -2
  231. package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
  232. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +76 -32
  233. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  234. package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -1
  235. package/build-module/components/line-height-control/index.mjs.map +1 -1
  236. package/build-module/components/link-control/index.mjs +2 -3
  237. package/build-module/components/link-control/index.mjs.map +2 -2
  238. package/build-module/components/link-control/normalize-url.mjs.map +1 -1
  239. package/build-module/components/list-view/block-select-button.mjs +2 -17
  240. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  241. package/build-module/components/list-view/utils.mjs.map +1 -1
  242. package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
  243. package/build-module/components/provider/index.mjs.map +1 -1
  244. package/build-module/components/provider/use-block-sync.mjs +3 -1
  245. package/build-module/components/provider/use-block-sync.mjs.map +2 -2
  246. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +1 -1
  247. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
  248. package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +1 -1
  249. package/build-module/components/rich-text/prevent-event-discovery.mjs +1 -1
  250. package/build-module/components/rich-text/prevent-event-discovery.mjs.map +1 -1
  251. package/build-module/components/url-popover/image-url-input-ui.mjs +0 -2
  252. package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
  253. package/build-module/components/use-block-display-information/index.mjs +10 -3
  254. package/build-module/components/use-block-display-information/index.mjs.map +2 -2
  255. package/build-module/components/writing-flow/use-tab-nav.mjs.map +1 -1
  256. package/build-module/hooks/anchor.mjs +1 -2
  257. package/build-module/hooks/anchor.mjs.map +2 -2
  258. package/build-module/hooks/background.mjs +123 -75
  259. package/build-module/hooks/background.mjs.map +2 -2
  260. package/build-module/hooks/block-fields/index.mjs +13 -2
  261. package/build-module/hooks/block-fields/index.mjs.map +2 -2
  262. package/build-module/hooks/color.mjs +2 -175
  263. package/build-module/hooks/color.mjs.map +2 -2
  264. package/build-module/hooks/contrast-checker.mjs +32 -19
  265. package/build-module/hooks/contrast-checker.mjs.map +2 -2
  266. package/build-module/hooks/custom-class-name.mjs +0 -1
  267. package/build-module/hooks/custom-class-name.mjs.map +2 -2
  268. package/build-module/hooks/dimensions.mjs +12 -2
  269. package/build-module/hooks/dimensions.mjs.map +2 -2
  270. package/build-module/hooks/elements.mjs +115 -0
  271. package/build-module/hooks/elements.mjs.map +7 -0
  272. package/build-module/hooks/grid-visualizer.mjs +21 -11
  273. package/build-module/hooks/grid-visualizer.mjs.map +2 -2
  274. package/build-module/hooks/layout-child.mjs +68 -10
  275. package/build-module/hooks/layout-child.mjs.map +2 -2
  276. package/build-module/hooks/layout.mjs +6 -3
  277. package/build-module/hooks/layout.mjs.map +2 -2
  278. package/build-module/hooks/list-view.mjs +10 -7
  279. package/build-module/hooks/list-view.mjs.map +2 -2
  280. package/build-module/hooks/spacing-visualizer.mjs.map +1 -1
  281. package/build-module/hooks/state-utils.mjs.map +1 -1
  282. package/build-module/hooks/states.mjs +2 -2
  283. package/build-module/hooks/states.mjs.map +2 -2
  284. package/build-module/hooks/style.mjs +53 -8
  285. package/build-module/hooks/style.mjs.map +2 -2
  286. package/build-module/hooks/typography.mjs +62 -10
  287. package/build-module/hooks/typography.mjs.map +2 -2
  288. package/build-module/layouts/flex.mjs +105 -7
  289. package/build-module/layouts/flex.mjs.map +2 -2
  290. package/build-module/private-apis.mjs +8 -0
  291. package/build-module/private-apis.mjs.map +2 -2
  292. package/build-module/store/actions.mjs.map +1 -1
  293. package/build-module/store/private-selectors.mjs +18 -1
  294. package/build-module/store/private-selectors.mjs.map +2 -2
  295. package/build-module/store/reducer.mjs.map +1 -1
  296. package/build-module/store/selectors.mjs.map +1 -1
  297. package/build-module/utils/block-bindings.mjs +9 -9
  298. package/build-module/utils/block-bindings.mjs.map +3 -3
  299. package/build-module/utils/color-values.mjs +9 -1
  300. package/build-module/utils/color-values.mjs.map +3 -3
  301. package/build-module/utils/dom.mjs +2 -5
  302. package/build-module/utils/dom.mjs.map +3 -3
  303. package/build-module/utils/fit-text-frontend.mjs +6 -2
  304. package/build-module/utils/fit-text-frontend.mjs.map +3 -3
  305. package/build-module/utils/fit-text-utils.mjs +1 -1
  306. package/build-module/utils/fit-text-utils.mjs.map +3 -3
  307. package/build-module/utils/format-font-style.mjs +1 -1
  308. package/build-module/utils/format-font-style.mjs.map +3 -3
  309. package/build-module/utils/format-font-weight.mjs +1 -1
  310. package/build-module/utils/format-font-weight.mjs.map +3 -3
  311. package/build-module/utils/get-editor-region.mjs +4 -2
  312. package/build-module/utils/get-editor-region.mjs.map +3 -3
  313. package/build-module/utils/get-font-styles-and-weights.mjs +8 -12
  314. package/build-module/utils/get-font-styles-and-weights.mjs.map +3 -3
  315. package/build-module/utils/get-px-from-css-unit.mjs +1 -1
  316. package/build-module/utils/get-px-from-css-unit.mjs.map +1 -1
  317. package/build-module/utils/index.mjs +1 -1
  318. package/build-module/utils/index.mjs.map +1 -1
  319. package/build-module/utils/math.mjs +1 -1
  320. package/build-module/utils/math.mjs.map +3 -3
  321. package/build-module/utils/object.mjs +8 -8
  322. package/build-module/utils/object.mjs.map +3 -3
  323. package/build-module/utils/order-inserter-block-items.mjs +1 -1
  324. package/build-module/utils/order-inserter-block-items.mjs.map +3 -3
  325. package/build-module/utils/pasting.mjs +4 -2
  326. package/build-module/utils/pasting.mjs.map +3 -3
  327. package/build-module/utils/selection.mjs +3 -2
  328. package/build-module/utils/selection.mjs.map +3 -3
  329. package/build-module/utils/sorting.mjs +9 -3
  330. package/build-module/utils/sorting.mjs.map +3 -3
  331. package/build-module/utils/transform-styles/index.mjs +3 -2
  332. package/build-module/utils/transform-styles/index.mjs.map +3 -3
  333. package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs +1 -0
  334. package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs.map +7 -0
  335. package/build-module/utils/transform-styles/types.mjs +1 -0
  336. package/build-module/utils/transform-styles/types.mjs.map +7 -0
  337. package/build-module/utils/types.mjs +1 -0
  338. package/build-module/utils/types.mjs.map +7 -0
  339. package/build-style/content-rtl.css +2 -0
  340. package/build-style/content.css +2 -0
  341. package/build-style/style-rtl.css +34 -41
  342. package/build-style/style.css +34 -41
  343. package/build-types/utils/block-bindings.d.ts +27 -0
  344. package/build-types/utils/block-bindings.d.ts.map +1 -0
  345. package/build-types/utils/color-values.d.ts +40 -0
  346. package/build-types/utils/color-values.d.ts.map +1 -0
  347. package/build-types/utils/dom.d.ts +19 -19
  348. package/build-types/utils/dom.d.ts.map +1 -1
  349. package/build-types/utils/fit-text-frontend.d.ts +7 -0
  350. package/build-types/utils/fit-text-frontend.d.ts.map +1 -0
  351. package/build-types/utils/fit-text-utils.d.ts +15 -0
  352. package/build-types/utils/fit-text-utils.d.ts.map +1 -0
  353. package/build-types/utils/format-font-style.d.ts +12 -0
  354. package/build-types/utils/format-font-style.d.ts.map +1 -0
  355. package/build-types/utils/format-font-weight.d.ts +12 -0
  356. package/build-types/utils/format-font-weight.d.ts.map +1 -0
  357. package/build-types/utils/get-editor-region.d.ts +9 -0
  358. package/build-types/utils/get-editor-region.d.ts.map +1 -0
  359. package/build-types/utils/get-font-styles-and-weights.d.ts +16 -0
  360. package/build-types/utils/get-font-styles-and-weights.d.ts.map +1 -0
  361. package/build-types/utils/get-px-from-css-unit.d.ts +10 -0
  362. package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -0
  363. package/build-types/utils/index.d.ts +3 -0
  364. package/build-types/utils/index.d.ts.map +1 -0
  365. package/build-types/utils/math.d.ts +61 -0
  366. package/build-types/utils/math.d.ts.map +1 -0
  367. package/build-types/utils/object.d.ts +39 -0
  368. package/build-types/utils/object.d.ts.map +1 -0
  369. package/build-types/utils/order-inserter-block-items.d.ts +13 -0
  370. package/build-types/utils/order-inserter-block-items.d.ts.map +1 -0
  371. package/build-types/utils/pasting.d.ts +28 -0
  372. package/build-types/utils/pasting.d.ts.map +1 -0
  373. package/build-types/utils/selection.d.ts +21 -0
  374. package/build-types/utils/selection.d.ts.map +1 -0
  375. package/build-types/utils/sorting.d.ts +17 -0
  376. package/build-types/utils/sorting.d.ts.map +1 -0
  377. package/build-types/utils/transform-styles/index.d.ts +15 -0
  378. package/build-types/utils/transform-styles/index.d.ts.map +1 -0
  379. package/build-types/utils/transform-styles/types.d.ts +13 -0
  380. package/build-types/utils/transform-styles/types.d.ts.map +1 -0
  381. package/build-types/utils/types.d.ts +28 -0
  382. package/build-types/utils/types.d.ts.map +1 -0
  383. package/package.json +46 -40
  384. package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -0
  385. package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -0
  386. package/src/components/block-card/index.js +7 -13
  387. package/src/components/block-editing-mode/index.js +17 -9
  388. package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -0
  389. package/src/components/block-inspector/index.js +22 -20
  390. package/src/components/block-patterns-list/index.js +0 -1
  391. package/src/components/block-quick-navigation/index.js +7 -7
  392. package/src/components/block-rename/modal.js +0 -1
  393. package/src/components/block-toolbar/block-toolbar-icon.js +22 -6
  394. package/src/components/block-toolbar/test/block-toolbar-icon.js +99 -0
  395. package/src/components/block-tools/use-block-toolbar-popover-props.js +10 -4
  396. package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -0
  397. package/src/components/child-layout-control/index.js +65 -20
  398. package/src/components/child-layout-control/test/index.js +64 -0
  399. package/src/components/colors-gradients/control.js +29 -12
  400. package/src/components/colors-gradients/dropdown.js +4 -1
  401. package/src/components/colors-gradients/style.scss +39 -2
  402. package/src/components/contrast-checker/README.md +9 -0
  403. package/src/components/contrast-checker/index.js +42 -3
  404. package/src/components/date-format-picker/index.js +0 -1
  405. package/src/components/default-block-appender/content.scss +3 -0
  406. package/src/components/dimensions-tool/index.js +4 -9
  407. package/src/components/dimensions-tool/scale-tool.js +1 -2
  408. package/src/components/dimensions-tool/test/index.js +89 -11
  409. package/src/components/global-styles/background-panel.js +201 -34
  410. package/src/components/global-styles/color-gradient-dropdown-item.js +258 -0
  411. package/src/components/global-styles/color-panel.js +125 -487
  412. package/src/components/global-styles/dimensions-panel.js +1 -5
  413. package/src/components/global-styles/hooks.js +45 -0
  414. package/src/components/global-styles/shadow-panel-components.js +0 -1
  415. package/src/components/global-styles/test/background-panel.js +56 -0
  416. package/src/components/global-styles/test/color-panel.js +172 -118
  417. package/src/components/global-styles/test/typography-panel.js +167 -0
  418. package/src/components/global-styles/typography-panel.js +100 -11
  419. package/src/components/iframe/index.js +8 -3
  420. package/src/components/inserter/media-tab/media-preview.js +0 -1
  421. package/src/components/inspector-controls/README.md +0 -2
  422. package/src/components/inspector-controls/fill.js +6 -8
  423. package/src/components/inspector-controls/groups.js +2 -0
  424. package/src/components/inspector-controls-tabs/index.js +0 -1
  425. package/src/components/inspector-controls-tabs/styles-tab.js +78 -28
  426. package/src/components/link-control/index.js +0 -1
  427. package/src/components/link-control/test/index.js +2 -3
  428. package/src/components/list-view/block-select-button.js +2 -18
  429. package/src/components/preset-input-control/custom-value-controls.js +0 -1
  430. package/src/components/provider/use-block-sync.js +3 -1
  431. package/src/components/rich-text/content.scss +2 -0
  432. package/src/components/url-popover/image-url-input-ui.js +0 -2
  433. package/src/components/use-block-display-information/index.js +15 -2
  434. package/src/components/use-block-display-information/test/index.js +140 -0
  435. package/src/hooks/anchor.js +0 -1
  436. package/src/hooks/background.js +210 -133
  437. package/src/hooks/background.scss +0 -35
  438. package/src/hooks/block-fields/index.js +27 -2
  439. package/src/hooks/color.js +2 -205
  440. package/src/hooks/color.scss +3 -9
  441. package/src/hooks/contrast-checker.js +60 -17
  442. package/src/hooks/custom-class-name.js +0 -1
  443. package/src/hooks/dimensions.js +14 -3
  444. package/src/hooks/elements.js +140 -0
  445. package/src/hooks/elements.scss +8 -0
  446. package/src/hooks/grid-visualizer.js +59 -45
  447. package/src/hooks/layout-child.js +92 -14
  448. package/src/hooks/layout.js +6 -3
  449. package/src/hooks/list-view.js +10 -11
  450. package/src/hooks/states.js +2 -2
  451. package/src/hooks/style.js +91 -9
  452. package/src/hooks/test/background.js +59 -0
  453. package/src/hooks/test/block-style-state.js +14 -14
  454. package/src/hooks/test/dimensions.js +71 -0
  455. package/src/hooks/test/layout-child.js +165 -0
  456. package/src/hooks/test/layout.js +6 -6
  457. package/src/hooks/test/style.js +133 -11
  458. package/src/hooks/typography.js +70 -6
  459. package/src/layouts/flex.js +118 -15
  460. package/src/private-apis.js +8 -0
  461. package/src/store/private-selectors.js +47 -0
  462. package/src/store/test/private-selectors.js +166 -7
  463. package/src/store/test/reducer.js +61 -10
  464. package/src/style.scss +1 -0
  465. package/src/utils/block-bindings.ts +51 -0
  466. package/src/utils/color-values.ts +63 -0
  467. package/src/utils/{dom.js → dom.ts} +27 -27
  468. package/src/utils/{fit-text-frontend.js → fit-text-frontend.ts} +12 -4
  469. package/src/utils/{fit-text-utils.js → fit-text-utils.ts} +15 -7
  470. package/src/utils/{format-font-style.js → format-font-style.ts} +10 -3
  471. package/src/utils/{format-font-weight.js → format-font-weight.ts} +10 -3
  472. package/src/utils/{get-editor-region.js → get-editor-region.ts} +10 -6
  473. package/src/utils/{get-font-styles-and-weights.js → get-font-styles-and-weights.ts} +21 -17
  474. package/src/utils/{math.js → math.ts} +37 -30
  475. package/src/utils/object.ts +89 -0
  476. package/src/utils/{order-inserter-block-items.js → order-inserter-block-items.ts} +8 -5
  477. package/src/utils/{pasting.js → pasting.ts} +18 -11
  478. package/src/utils/{selection.js → selection.ts} +11 -4
  479. package/src/utils/sorting.ts +81 -0
  480. package/src/utils/test/color-values.js +44 -1
  481. package/src/utils/transform-styles/{index.js → index.ts} +25 -25
  482. package/src/utils/transform-styles/postcss-urlrebase.d.ts +15 -0
  483. package/src/utils/transform-styles/types.ts +13 -0
  484. package/src/utils/types.ts +29 -0
  485. package/src/utils/block-bindings.js +0 -46
  486. package/src/utils/color-values.js +0 -28
  487. package/src/utils/object.js +0 -67
  488. package/src/utils/sorting.js +0 -54
  489. /package/src/utils/{get-px-from-css-unit.js → get-px-from-css-unit.ts} +0 -0
  490. /package/src/utils/{index.js → index.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/url-popover/image-url-input-ui.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseRef,\n\tuseEffect,\n\tuseState,\n\tcreateInterpolateElement,\n} from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport {\n\tToolbarButton,\n\tNavigableMenu,\n\tButton,\n\tMenuItem,\n\tToggleControl,\n\tTextControl,\n\t__experimentalVStack as VStack,\n\tExternalLink,\n} from '@wordpress/components';\nimport {\n\tIcon,\n\tlink as linkIcon,\n\timage,\n\tpage,\n\tfullscreen,\n\tlinkOff,\n} from '@wordpress/icons';\nimport { prependHTTPS } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport URLPopover from './index';\n\nconst LINK_DESTINATION_NONE = 'none';\nconst LINK_DESTINATION_CUSTOM = 'custom';\nconst LINK_DESTINATION_MEDIA = 'media';\nconst LINK_DESTINATION_ATTACHMENT = 'attachment';\nconst NEW_TAB_REL = [ 'noopener' ];\n\nconst ImageURLInputUI = ( {\n\tlinkDestination,\n\tonChangeUrl,\n\turl,\n\tmediaType = 'image',\n\tmediaUrl,\n\tmediaLink,\n\tlinkTarget,\n\tlinkClass,\n\trel,\n\tshowLightboxSetting,\n\tlightboxEnabled,\n\tonSetLightbox,\n\tresetLightbox,\n} ) => {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst openLinkUI = () => {\n\t\tsetIsOpen( true );\n\t};\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState( false );\n\tconst [ urlInput, setUrlInput ] = useState( null );\n\n\tconst autocompleteRef = useRef( null );\n\tconst wrapperRef = useRef();\n\n\tuseEffect( () => {\n\t\tif ( ! wrapperRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperRef.current )[ 0 ] ||\n\t\t\twrapperRef.current;\n\t\tnextFocusTarget.focus();\n\t}, [ isEditingLink, url, lightboxEnabled ] );\n\n\tconst startEditLink = () => {\n\t\tif (\n\t\t\tlinkDestination === LINK_DESTINATION_MEDIA ||\n\t\t\tlinkDestination === LINK_DESTINATION_ATTACHMENT\n\t\t) {\n\t\t\tsetUrlInput( '' );\n\t\t}\n\t\tsetIsEditingLink( true );\n\t};\n\n\tconst stopEditLink = () => {\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst closeLinkUI = () => {\n\t\tsetUrlInput( null );\n\t\tstopEditLink();\n\t\tsetIsOpen( false );\n\t};\n\n\tconst getUpdatedLinkTargetSettings = ( value ) => {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel;\n\t\tif ( newLinkTarget ) {\n\t\t\tconst rels = ( rel ?? '' ).split( ' ' );\n\t\t\tNEW_TAB_REL.forEach( ( relVal ) => {\n\t\t\t\tif ( ! rels.includes( relVal ) ) {\n\t\t\t\t\trels.push( relVal );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tupdatedRel = rels.join( ' ' );\n\t\t} else {\n\t\t\tconst rels = ( rel ?? '' )\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter(\n\t\t\t\t\t( relVal ) => NEW_TAB_REL.includes( relVal ) === false\n\t\t\t\t);\n\t\t\tupdatedRel = rels.length ? rels.join( ' ' ) : undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t};\n\t};\n\n\tconst onFocusOutside = () => {\n\t\treturn ( event ) => {\n\t\t\t// The autocomplete suggestions list renders in a separate popover (in a portal),\n\t\t\t// so onFocusOutside fails to detect that a click on a suggestion occurred in the\n\t\t\t// LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and\n\t\t\t// return to avoid the popover being closed.\n\t\t\tconst autocompleteElement = autocompleteRef.current;\n\t\t\tif (\n\t\t\t\tautocompleteElement &&\n\t\t\t\tautocompleteElement.contains( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetIsOpen( false );\n\t\t\tsetUrlInput( null );\n\t\t\tstopEditLink();\n\t\t};\n\t};\n\n\tconst onSubmitLinkChange = () => {\n\t\treturn ( event ) => {\n\t\t\tif ( urlInput ) {\n\t\t\t\t// It is possible the entered URL actually matches a named link destination.\n\t\t\t\t// This check will ensure our link destination is correct.\n\t\t\t\tconst selectedDestination =\n\t\t\t\t\tgetLinkDestinations().find(\n\t\t\t\t\t\t( destination ) => destination.url === urlInput\n\t\t\t\t\t)?.linkDestination || LINK_DESTINATION_CUSTOM;\n\n\t\t\t\tonChangeUrl( {\n\t\t\t\t\thref: prependHTTPS( urlInput ),\n\t\t\t\t\tlinkDestination: selectedDestination,\n\t\t\t\t\tlightbox: { enabled: false },\n\t\t\t\t} );\n\t\t\t}\n\t\t\tstopEditLink();\n\t\t\tsetUrlInput( null );\n\t\t\tevent.preventDefault();\n\t\t};\n\t};\n\n\tconst onLinkRemove = () => {\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: LINK_DESTINATION_NONE,\n\t\t\thref: '',\n\t\t} );\n\t};\n\n\tconst getLinkDestinations = () => {\n\t\tconst linkDestinations = [\n\t\t\t{\n\t\t\t\tlinkDestination: LINK_DESTINATION_MEDIA,\n\t\t\t\ttitle: __( 'Link to image file' ),\n\t\t\t\turl: mediaType === 'image' ? mediaUrl : undefined,\n\t\t\t\ticon: image,\n\t\t\t},\n\t\t];\n\t\tif ( mediaType === 'image' && mediaLink ) {\n\t\t\tlinkDestinations.push( {\n\t\t\t\tlinkDestination: LINK_DESTINATION_ATTACHMENT,\n\t\t\t\ttitle: __( 'Link to attachment page' ),\n\t\t\t\turl: mediaType === 'image' ? mediaLink : undefined,\n\t\t\t\ticon: page,\n\t\t\t} );\n\t\t}\n\t\treturn linkDestinations;\n\t};\n\n\tconst onSetHref = ( value ) => {\n\t\tconst linkDestinations = getLinkDestinations();\n\t\tlet linkDestinationInput;\n\t\tif ( ! value ) {\n\t\t\tlinkDestinationInput = LINK_DESTINATION_NONE;\n\t\t} else {\n\t\t\tlinkDestinationInput = (\n\t\t\t\tlinkDestinations.find( ( destination ) => {\n\t\t\t\t\treturn destination.url === value;\n\t\t\t\t} ) || { linkDestination: LINK_DESTINATION_CUSTOM }\n\t\t\t).linkDestination;\n\t\t}\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: linkDestinationInput,\n\t\t\thref: value,\n\t\t} );\n\t};\n\n\tconst onSetNewTab = ( value ) => {\n\t\tconst updatedLinkTarget = getUpdatedLinkTargetSettings( value );\n\t\tonChangeUrl( updatedLinkTarget );\n\t};\n\n\tconst onSetLinkRel = ( value ) => {\n\t\tonChangeUrl( { rel: value } );\n\t};\n\n\tconst onSetLinkClass = ( value ) => {\n\t\tonChangeUrl( { linkClass: value } );\n\t};\n\n\tconst advancedOptions = (\n\t\t<VStack spacing=\"3\">\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonChange={ onSetNewTab }\n\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'Link relation' ) }\n\t\t\t\tvalue={ rel ?? '' }\n\t\t\t\tonChange={ onSetLinkRel }\n\t\t\t\thelp={ createInterpolateElement(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The <a>Link Relation</a> attribute defines the relationship between a linked resource and the current document.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t<ExternalLink href=\"https://developer.mozilla.org/docs/Web/HTML/Attributes/rel\" />\n\t\t\t\t\t\t),\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'Link CSS class' ) }\n\t\t\t\tvalue={ linkClass || '' }\n\t\t\t\tonChange={ onSetLinkClass }\n\t\t\t/>\n\t\t</VStack>\n\t);\n\n\tconst linkEditorValue = urlInput !== null ? urlInput : url;\n\tconst hideLightboxPanel =\n\t\t! lightboxEnabled || ( lightboxEnabled && ! showLightboxSetting );\n\tconst showLinkEditor = ! linkEditorValue && hideLightboxPanel;\n\n\tconst urlLabel = (\n\t\tgetLinkDestinations().find(\n\t\t\t( destination ) => destination.linkDestination === linkDestination\n\t\t) || {}\n\t).title;\n\n\tconst PopoverChildren = () => {\n\t\tif (\n\t\t\tlightboxEnabled &&\n\t\t\tshowLightboxSetting &&\n\t\t\t! url &&\n\t\t\t! isEditingLink\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<div className=\"block-editor-url-popover__expand-on-click\">\n\t\t\t\t\t<Icon icon={ fullscreen } />\n\t\t\t\t\t<div className=\"text\">\n\t\t\t\t\t\t<p>{ __( 'Enlarge on click' ) }</p>\n\t\t\t\t\t\t<p className=\"description\">\n\t\t\t\t\t\t\t{ __( 'Scales the image with a lightbox effect' ) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Disable enlarge on click' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonSetLightbox?.( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t);\n\t\t} else if ( ! url || isEditingLink ) {\n\t\t\treturn (\n\t\t\t\t<URLPopover.LinkEditor\n\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\tvalue={ linkEditorValue }\n\t\t\t\t\tonChangeInputValue={ setUrlInput }\n\t\t\t\t\tonSubmit={ onSubmitLinkChange() }\n\t\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t\t/>\n\t\t\t);\n\t\t} else if ( url && ! isEditingLink ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<URLPopover.LinkViewer\n\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\tonEditLinkClick={ startEditLink }\n\t\t\t\t\t\turlLabel={ urlLabel }\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonLinkRemove();\n\t\t\t\t\t\t\tresetLightbox?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ linkIcon }\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\tonClick={ openLinkUI }\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t\tisActive={\n\t\t\t\t\t!! url || ( lightboxEnabled && showLightboxSetting )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ isOpen && (\n\t\t\t\t<URLPopover\n\t\t\t\t\tref={ wrapperRef }\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tonFocusOutside={ onFocusOutside() }\n\t\t\t\t\tonClose={ closeLinkUI }\n\t\t\t\t\trenderSettings={\n\t\t\t\t\t\thideLightboxPanel ? () => advancedOptions : null\n\t\t\t\t\t}\n\t\t\t\t\tadditionalControls={\n\t\t\t\t\t\tshowLinkEditor && (\n\t\t\t\t\t\t\t<NavigableMenu>\n\t\t\t\t\t\t\t\t{ getLinkDestinations().map( ( link ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey={ link.linkDestination }\n\t\t\t\t\t\t\t\t\t\ticon={ link.icon }\n\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonSetHref( link.url );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ link.title }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t\t{ showLightboxSetting && (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey=\"expand-on-click\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-url-popover__expand-on-click\"\n\t\t\t\t\t\t\t\t\t\ticon={ fullscreen }\n\t\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Scale the image with a lightbox effect.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonChangeUrl( {\n\t\t\t\t\t\t\t\t\t\t\t\tlinkDestination:\n\t\t\t\t\t\t\t\t\t\t\t\t\tLINK_DESTINATION_NONE,\n\t\t\t\t\t\t\t\t\t\t\t\thref: '',\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t\tonSetLightbox?.( true );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Enlarge on click' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\toffset={ 13 }\n\t\t\t\t>\n\t\t\t\t\t{ PopoverChildren() }\n\t\t\t\t</URLPopover>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport { ImageURLInputUI as __experimentalImageURLInputUI };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AA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,cACb,SAAU,MAAM;AACf,4BAAa,IAAK;AAClB,4BAAa;AAAA,kBACZ,iBACC;AAAA,kBACD,MAAM;AAAA,gBACP,CAAE;AACF,gCAAiB,IAAK;AACtB,6BAAa;AAAA,cACd;AAAA,cAEE,8BAAI,kBAAmB;AAAA;AAAA,YAlBrB;AAAA,UAmBL;AAAA,WAEF;AAAA,QAGF,QAAS;AAAA,QAEP,0BAAgB;AAAA;AAAA,IACnB;AAAA,KAEF;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseRef,\n\tuseEffect,\n\tuseState,\n\tcreateInterpolateElement,\n} from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport {\n\tToolbarButton,\n\tNavigableMenu,\n\tButton,\n\tMenuItem,\n\tToggleControl,\n\tTextControl,\n\t__experimentalVStack as VStack,\n\tExternalLink,\n} from '@wordpress/components';\nimport {\n\tIcon,\n\tlink as linkIcon,\n\timage,\n\tpage,\n\tfullscreen,\n\tlinkOff,\n} from '@wordpress/icons';\nimport { prependHTTPS } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport URLPopover from './index';\n\nconst LINK_DESTINATION_NONE = 'none';\nconst LINK_DESTINATION_CUSTOM = 'custom';\nconst LINK_DESTINATION_MEDIA = 'media';\nconst LINK_DESTINATION_ATTACHMENT = 'attachment';\nconst NEW_TAB_REL = [ 'noopener' ];\n\nconst ImageURLInputUI = ( {\n\tlinkDestination,\n\tonChangeUrl,\n\turl,\n\tmediaType = 'image',\n\tmediaUrl,\n\tmediaLink,\n\tlinkTarget,\n\tlinkClass,\n\trel,\n\tshowLightboxSetting,\n\tlightboxEnabled,\n\tonSetLightbox,\n\tresetLightbox,\n} ) => {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst openLinkUI = () => {\n\t\tsetIsOpen( true );\n\t};\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState( false );\n\tconst [ urlInput, setUrlInput ] = useState( null );\n\n\tconst autocompleteRef = useRef( null );\n\tconst wrapperRef = useRef();\n\n\tuseEffect( () => {\n\t\tif ( ! wrapperRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperRef.current )[ 0 ] ||\n\t\t\twrapperRef.current;\n\t\tnextFocusTarget.focus();\n\t}, [ isEditingLink, url, lightboxEnabled ] );\n\n\tconst startEditLink = () => {\n\t\tif (\n\t\t\tlinkDestination === LINK_DESTINATION_MEDIA ||\n\t\t\tlinkDestination === LINK_DESTINATION_ATTACHMENT\n\t\t) {\n\t\t\tsetUrlInput( '' );\n\t\t}\n\t\tsetIsEditingLink( true );\n\t};\n\n\tconst stopEditLink = () => {\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst closeLinkUI = () => {\n\t\tsetUrlInput( null );\n\t\tstopEditLink();\n\t\tsetIsOpen( false );\n\t};\n\n\tconst getUpdatedLinkTargetSettings = ( value ) => {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel;\n\t\tif ( newLinkTarget ) {\n\t\t\tconst rels = ( rel ?? '' ).split( ' ' );\n\t\t\tNEW_TAB_REL.forEach( ( relVal ) => {\n\t\t\t\tif ( ! rels.includes( relVal ) ) {\n\t\t\t\t\trels.push( relVal );\n\t\t\t\t}\n\t\t\t} );\n\t\t\tupdatedRel = rels.join( ' ' );\n\t\t} else {\n\t\t\tconst rels = ( rel ?? '' )\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter(\n\t\t\t\t\t( relVal ) => NEW_TAB_REL.includes( relVal ) === false\n\t\t\t\t);\n\t\t\tupdatedRel = rels.length ? rels.join( ' ' ) : undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t};\n\t};\n\n\tconst onFocusOutside = () => {\n\t\treturn ( event ) => {\n\t\t\t// The autocomplete suggestions list renders in a separate popover (in a portal),\n\t\t\t// so onFocusOutside fails to detect that a click on a suggestion occurred in the\n\t\t\t// LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and\n\t\t\t// return to avoid the popover being closed.\n\t\t\tconst autocompleteElement = autocompleteRef.current;\n\t\t\tif (\n\t\t\t\tautocompleteElement &&\n\t\t\t\tautocompleteElement.contains( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetIsOpen( false );\n\t\t\tsetUrlInput( null );\n\t\t\tstopEditLink();\n\t\t};\n\t};\n\n\tconst onSubmitLinkChange = () => {\n\t\treturn ( event ) => {\n\t\t\tif ( urlInput ) {\n\t\t\t\t// It is possible the entered URL actually matches a named link destination.\n\t\t\t\t// This check will ensure our link destination is correct.\n\t\t\t\tconst selectedDestination =\n\t\t\t\t\tgetLinkDestinations().find(\n\t\t\t\t\t\t( destination ) => destination.url === urlInput\n\t\t\t\t\t)?.linkDestination || LINK_DESTINATION_CUSTOM;\n\n\t\t\t\tonChangeUrl( {\n\t\t\t\t\thref: prependHTTPS( urlInput ),\n\t\t\t\t\tlinkDestination: selectedDestination,\n\t\t\t\t\tlightbox: { enabled: false },\n\t\t\t\t} );\n\t\t\t}\n\t\t\tstopEditLink();\n\t\t\tsetUrlInput( null );\n\t\t\tevent.preventDefault();\n\t\t};\n\t};\n\n\tconst onLinkRemove = () => {\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: LINK_DESTINATION_NONE,\n\t\t\thref: '',\n\t\t} );\n\t};\n\n\tconst getLinkDestinations = () => {\n\t\tconst linkDestinations = [\n\t\t\t{\n\t\t\t\tlinkDestination: LINK_DESTINATION_MEDIA,\n\t\t\t\ttitle: __( 'Link to image file' ),\n\t\t\t\turl: mediaType === 'image' ? mediaUrl : undefined,\n\t\t\t\ticon: image,\n\t\t\t},\n\t\t];\n\t\tif ( mediaType === 'image' && mediaLink ) {\n\t\t\tlinkDestinations.push( {\n\t\t\t\tlinkDestination: LINK_DESTINATION_ATTACHMENT,\n\t\t\t\ttitle: __( 'Link to attachment page' ),\n\t\t\t\turl: mediaType === 'image' ? mediaLink : undefined,\n\t\t\t\ticon: page,\n\t\t\t} );\n\t\t}\n\t\treturn linkDestinations;\n\t};\n\n\tconst onSetHref = ( value ) => {\n\t\tconst linkDestinations = getLinkDestinations();\n\t\tlet linkDestinationInput;\n\t\tif ( ! value ) {\n\t\t\tlinkDestinationInput = LINK_DESTINATION_NONE;\n\t\t} else {\n\t\t\tlinkDestinationInput = (\n\t\t\t\tlinkDestinations.find( ( destination ) => {\n\t\t\t\t\treturn destination.url === value;\n\t\t\t\t} ) || { linkDestination: LINK_DESTINATION_CUSTOM }\n\t\t\t).linkDestination;\n\t\t}\n\t\tonChangeUrl( {\n\t\t\tlinkDestination: linkDestinationInput,\n\t\t\thref: value,\n\t\t} );\n\t};\n\n\tconst onSetNewTab = ( value ) => {\n\t\tconst updatedLinkTarget = getUpdatedLinkTargetSettings( value );\n\t\tonChangeUrl( updatedLinkTarget );\n\t};\n\n\tconst onSetLinkRel = ( value ) => {\n\t\tonChangeUrl( { rel: value } );\n\t};\n\n\tconst onSetLinkClass = ( value ) => {\n\t\tonChangeUrl( { linkClass: value } );\n\t};\n\n\tconst advancedOptions = (\n\t\t<VStack spacing=\"3\">\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\tonChange={ onSetNewTab }\n\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\tlabel={ __( 'Link relation' ) }\n\t\t\t\tvalue={ rel ?? '' }\n\t\t\t\tonChange={ onSetLinkRel }\n\t\t\t\thelp={ createInterpolateElement(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The <a>Link Relation</a> attribute defines the relationship between a linked resource and the current document.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t<ExternalLink href=\"https://developer.mozilla.org/docs/Web/HTML/Attributes/rel\" />\n\t\t\t\t\t\t),\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\tlabel={ __( 'Link CSS class' ) }\n\t\t\t\tvalue={ linkClass || '' }\n\t\t\t\tonChange={ onSetLinkClass }\n\t\t\t/>\n\t\t</VStack>\n\t);\n\n\tconst linkEditorValue = urlInput !== null ? urlInput : url;\n\tconst hideLightboxPanel =\n\t\t! lightboxEnabled || ( lightboxEnabled && ! showLightboxSetting );\n\tconst showLinkEditor = ! linkEditorValue && hideLightboxPanel;\n\n\tconst urlLabel = (\n\t\tgetLinkDestinations().find(\n\t\t\t( destination ) => destination.linkDestination === linkDestination\n\t\t) || {}\n\t).title;\n\n\tconst PopoverChildren = () => {\n\t\tif (\n\t\t\tlightboxEnabled &&\n\t\t\tshowLightboxSetting &&\n\t\t\t! url &&\n\t\t\t! isEditingLink\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<div className=\"block-editor-url-popover__expand-on-click\">\n\t\t\t\t\t<Icon icon={ fullscreen } />\n\t\t\t\t\t<div className=\"text\">\n\t\t\t\t\t\t<p>{ __( 'Enlarge on click' ) }</p>\n\t\t\t\t\t\t<p className=\"description\">\n\t\t\t\t\t\t\t{ __( 'Scales the image with a lightbox effect' ) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Disable enlarge on click' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonSetLightbox?.( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t);\n\t\t} else if ( ! url || isEditingLink ) {\n\t\t\treturn (\n\t\t\t\t<URLPopover.LinkEditor\n\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\tvalue={ linkEditorValue }\n\t\t\t\t\tonChangeInputValue={ setUrlInput }\n\t\t\t\t\tonSubmit={ onSubmitLinkChange() }\n\t\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t\t/>\n\t\t\t);\n\t\t} else if ( url && ! isEditingLink ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<URLPopover.LinkViewer\n\t\t\t\t\t\tclassName=\"block-editor-format-toolbar__link-container-content\"\n\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\tonEditLinkClick={ startEditLink }\n\t\t\t\t\t\turlLabel={ urlLabel }\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonLinkRemove();\n\t\t\t\t\t\t\tresetLightbox?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ linkIcon }\n\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t\tonClick={ openLinkUI }\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t\tisActive={\n\t\t\t\t\t!! url || ( lightboxEnabled && showLightboxSetting )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ isOpen && (\n\t\t\t\t<URLPopover\n\t\t\t\t\tref={ wrapperRef }\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tonFocusOutside={ onFocusOutside() }\n\t\t\t\t\tonClose={ closeLinkUI }\n\t\t\t\t\trenderSettings={\n\t\t\t\t\t\thideLightboxPanel ? () => advancedOptions : null\n\t\t\t\t\t}\n\t\t\t\t\tadditionalControls={\n\t\t\t\t\t\tshowLinkEditor && (\n\t\t\t\t\t\t\t<NavigableMenu>\n\t\t\t\t\t\t\t\t{ getLinkDestinations().map( ( link ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey={ link.linkDestination }\n\t\t\t\t\t\t\t\t\t\ticon={ link.icon }\n\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonSetHref( link.url );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ link.title }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t\t{ showLightboxSetting && (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tkey=\"expand-on-click\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-url-popover__expand-on-click\"\n\t\t\t\t\t\t\t\t\t\ticon={ fullscreen }\n\t\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Scale the image with a lightbox effect.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetUrlInput( null );\n\t\t\t\t\t\t\t\t\t\t\tonChangeUrl( {\n\t\t\t\t\t\t\t\t\t\t\t\tlinkDestination:\n\t\t\t\t\t\t\t\t\t\t\t\t\tLINK_DESTINATION_NONE,\n\t\t\t\t\t\t\t\t\t\t\t\thref: '',\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t\tonSetLightbox?.( true );\n\t\t\t\t\t\t\t\t\t\t\tstopEditLink();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Enlarge on click' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\toffset={ 13 }\n\t\t\t\t>\n\t\t\t\t\t{ PopoverChildren() }\n\t\t\t\t</URLPopover>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport { ImageURLInputUI as __experimentalImageURLInputUI };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,qBAKO;AACP,iBAAsB;AACtB,wBASO;AACP,mBAOO;AACP,iBAA6B;AAK7B,mBAAuB;AAkMrB;AAhMF,IAAM,wBAAwB;AAC9B,IAAM,0BAA0B;AAChC,IAAM,yBAAyB;AAC/B,IAAM,8BAA8B;AACpC,IAAM,cAAc,CAAE,UAAW;AAEjC,IAAM,kBAAkB,CAAE;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,MAAO;AACN,QAAM,CAAE,QAAQ,SAAU,QAAI,yBAAU,KAAM;AAG9C,QAAM,CAAE,eAAe,gBAAiB,QAAI,yBAAU,IAAK;AAC3D,QAAM,aAAa,MAAM;AACxB,cAAW,IAAK;AAAA,EACjB;AAEA,QAAM,CAAE,eAAe,gBAAiB,QAAI,yBAAU,KAAM;AAC5D,QAAM,CAAE,UAAU,WAAY,QAAI,yBAAU,IAAK;AAEjD,QAAM,sBAAkB,uBAAQ,IAAK;AACrC,QAAM,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AU;AAAA,QACV,gBACC,oBAAoB,MAAM,kBAAkB;AAAA,QAE7C,oBACC,kBACC,6CAAC,mCACE;AAAA,8BAAoB,EAAE,IAAK,CAAE,SAC9B;AAAA,YAAC;AAAA;AAAA,cAEA,MAAO,KAAK;AAAA,cACZ,cAAa;AAAA,cACb,SAAU,MAAM;AACf,4BAAa,IAAK;AAClB,0BAAW,KAAK,GAAI;AACpB,6BAAa;AAAA,cACd;AAAA,cAEE,eAAK;AAAA;AAAA,YATD,KAAK;AAAA,UAUZ,CACC;AAAA,UACA,uBACD;AAAA,YAAC;AAAA;AAAA,cAEA,WAAU;AAAA,cACV,MAAO;AAAA,cACP,UAAO;AAAA,gBACN;AAAA,cACD;AAAA,cACA,cAAa;AAAA,cACb,SAAU,MAAM;AACf,4BAAa,IAAK;AAClB,4BAAa;AAAA,kBACZ,iBACC;AAAA,kBACD,MAAM;AAAA,gBACP,CAAE;AACF,gCAAiB,IAAK;AACtB,6BAAa;AAAA,cACd;AAAA,cAEE,8BAAI,kBAAmB;AAAA;AAAA,YAlBrB;AAAA,UAmBL;AAAA,WAEF;AAAA,QAGF,QAAS;AAAA,QAEP,0BAAgB;AAAA;AAAA,IACnB;AAAA,KAEF;AAEF;",
6
6
  "names": ["VStack", "URLPopover", "linkIcon"]
7
7
  }
@@ -28,6 +28,8 @@ var import_blocks = require("@wordpress/blocks");
28
28
  var import_i18n = require("@wordpress/i18n");
29
29
  var import_icons = require("@wordpress/icons");
30
30
  var import_store = require("../../store/index.cjs");
31
+ var import_lock_unlock = require("../../lock-unlock.cjs");
32
+ var import_private_keys = require("../../store/private-keys.cjs");
31
33
  function getPositionTypeLabel(attributes) {
32
34
  const positionType = attributes?.style?.position?.type;
33
35
  if (positionType === "sticky") {
@@ -44,11 +46,13 @@ function useBlockDisplayInformation(clientId) {
44
46
  if (!clientId) {
45
47
  return null;
46
48
  }
49
+ const blockEditorSelect = select(import_store.store);
47
50
  const {
48
51
  getBlockName,
49
52
  getBlockAttributes,
50
- __experimentalGetParsedPattern
51
- } = select(import_store.store);
53
+ __experimentalGetParsedPattern,
54
+ getSettings
55
+ } = blockEditorSelect;
52
56
  const { getBlockType, getActiveBlockVariation } = select(import_blocks.store);
53
57
  const blockName = getBlockName(clientId);
54
58
  const blockType = getBlockType(blockName);
@@ -56,8 +60,11 @@ function useBlockDisplayInformation(clientId) {
56
60
  return null;
57
61
  }
58
62
  const attributes = getBlockAttributes(clientId);
63
+ const { isWithinEditedContentOnlySection } = (0, import_lock_unlock.unlock)(blockEditorSelect);
64
+ const isIsolatedEditor = !!getSettings()?.[import_private_keys.isIsolatedEditorKey];
59
65
  const patternName = attributes?.metadata?.patternName;
60
- if (patternName) {
66
+ const isEditedContentOnlySection = isWithinEditedContentOnlySection(clientId);
67
+ if (patternName && !isEditedContentOnlySection && !isIsolatedEditor) {
61
68
  const pattern = __experimentalGetParsedPattern(patternName);
62
69
  const positionLabel2 = getPositionTypeLabel(attributes);
63
70
  return {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/use-block-display-information/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n\t__experimentalGetBlockLabel as getBlockLabel,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { symbol } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */\n\n/**\n * Contains basic block's information for display reasons.\n *\n * @typedef {Object} WPBlockDisplayInformation\n *\n * @property {boolean} isSynced True if is a reusable block or template part\n * @property {string} title Human-readable block type label.\n * @property {WPIcon} icon Block type icon.\n * @property {string} description A detailed block type description.\n * @property {string} anchor HTML anchor.\n * @property {name} name A custom, human readable name for the block.\n */\n\n/**\n * Get the display label for a block's position type.\n *\n * @param {Object} attributes Block attributes.\n * @return {string} The position type label.\n */\nfunction getPositionTypeLabel( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\n\tif ( positionType === 'sticky' ) {\n\t\treturn __( 'Sticky' );\n\t}\n\n\tif ( positionType === 'fixed' ) {\n\t\treturn __( 'Fixed' );\n\t}\n\n\treturn null;\n}\n\n/**\n * Hook used to try to find a matching block variation and return\n * the appropriate information for display reasons. In order to\n * to try to find a match we need to things:\n * 1. Block's client id to extract it's current attributes.\n * 2. A block variation should have set `isActive` prop to a proper function.\n *\n * If for any reason a block variation match cannot be found,\n * the returned information come from the Block Type.\n * If no blockType is found with the provided clientId, returns null.\n *\n * @param {string} clientId Block's client id.\n * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.\n */\n\nexport default function useBlockDisplayInformation( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\t__experimentalGetParsedPattern,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tif ( ! blockType ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\n\t\t\t// Check if this block is a pattern\n\t\t\tconst patternName = attributes?.metadata?.patternName;\n\n\t\t\tif ( patternName ) {\n\t\t\t\tconst pattern = __experimentalGetParsedPattern( patternName );\n\t\t\t\tconst positionLabel = getPositionTypeLabel( attributes );\n\t\t\t\treturn {\n\t\t\t\t\tisSynced: false,\n\t\t\t\t\ttitle: __( 'Pattern' ),\n\t\t\t\t\ticon: symbol,\n\t\t\t\t\tdescription:\n\t\t\t\t\t\tpattern?.description || __( 'A block pattern.' ),\n\t\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\t\tpositionLabel,\n\t\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\t\tname: pattern?.title || attributes?.metadata?.name,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst match = getActiveBlockVariation( blockName, attributes );\n\t\t\tconst isSynced =\n\t\t\t\tisReusableBlock( blockType ) || isTemplatePart( blockType );\n\t\t\tconst syncedTitle = isSynced\n\t\t\t\t? getBlockLabel( blockType, attributes )\n\t\t\t\t: undefined;\n\t\t\tconst title = syncedTitle || blockType.title;\n\t\t\tconst positionLabel = getPositionTypeLabel( attributes );\n\t\t\tconst blockTypeInfo = {\n\t\t\t\tisSynced,\n\t\t\t\ttitle,\n\t\t\t\ticon: blockType.icon,\n\t\t\t\tdescription: blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\tname: attributes?.metadata?.name,\n\t\t\t};\n\t\t\tif ( ! match ) {\n\t\t\t\treturn blockTypeInfo;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tisSynced,\n\t\t\t\ttitle: match.title || blockType.title,\n\t\t\t\ticon: match.icon || blockType.icon,\n\t\t\t\tdescription: match.description || blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\tname: attributes?.metadata?.name,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,oBAKO;AACP,kBAAmB;AACnB,mBAAuB;AAKvB,mBAA0C;AAuB1C,SAAS,qBAAsB,YAAa;AAC3C,QAAM,eAAe,YAAY,OAAO,UAAU;AAElD,MAAK,iBAAiB,UAAW;AAChC,eAAO,gBAAI,QAAS;AAAA,EACrB;AAEA,MAAK,iBAAiB,SAAU;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M,YAAY,UAAU;AAAA,MAC7B;AACA,UAAK,CAAE,OAAQ;AACd,eAAO;AAAA,MACR;AAEA,aAAO;AAAA,QACN;AAAA,QACA,OAAO,MAAM,SAAS,UAAU;AAAA,QAChC,MAAM,MAAM,QAAQ,UAAU;AAAA,QAC9B,aAAa,MAAM,eAAe,UAAU;AAAA,QAC5C,QAAQ,YAAY;AAAA,QACpB;AAAA,QACA,cAAc,YAAY,OAAO,UAAU;AAAA,QAC3C,MAAM,YAAY,UAAU;AAAA,MAC7B;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n\t__experimentalGetBlockLabel as getBlockLabel,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { symbol } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { isIsolatedEditorKey } from '../../store/private-keys';\n\n/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */\n\n/**\n * Contains basic block's information for display reasons.\n *\n * @typedef {Object} WPBlockDisplayInformation\n *\n * @property {boolean} isSynced True if is a reusable block or template part\n * @property {string} title Human-readable block type label.\n * @property {WPIcon} icon Block type icon.\n * @property {string} description A detailed block type description.\n * @property {string} anchor HTML anchor.\n * @property {name} name A custom, human readable name for the block.\n */\n\n/**\n * Get the display label for a block's position type.\n *\n * @param {Object} attributes Block attributes.\n * @return {string} The position type label.\n */\nfunction getPositionTypeLabel( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\n\tif ( positionType === 'sticky' ) {\n\t\treturn __( 'Sticky' );\n\t}\n\n\tif ( positionType === 'fixed' ) {\n\t\treturn __( 'Fixed' );\n\t}\n\n\treturn null;\n}\n\n/**\n * Hook used to try to find a matching block variation and return\n * the appropriate information for display reasons. In order to\n * to try to find a match we need to things:\n * 1. Block's client id to extract it's current attributes.\n * 2. A block variation should have set `isActive` prop to a proper function.\n *\n * If for any reason a block variation match cannot be found,\n * the returned information come from the Block Type.\n * If no blockType is found with the provided clientId, returns null.\n *\n * @param {string} clientId Block's client id.\n * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.\n */\n\nexport default function useBlockDisplayInformation( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst blockEditorSelect = select( blockEditorStore );\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\t__experimentalGetParsedPattern,\n\t\t\t\tgetSettings,\n\t\t\t} = blockEditorSelect;\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tif ( ! blockType ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst { isWithinEditedContentOnlySection } =\n\t\t\t\tunlock( blockEditorSelect );\n\t\t\tconst isIsolatedEditor = !! getSettings()?.[ isIsolatedEditorKey ];\n\n\t\t\t// Check if this block is a pattern\n\t\t\tconst patternName = attributes?.metadata?.patternName;\n\t\t\tconst isEditedContentOnlySection =\n\t\t\t\tisWithinEditedContentOnlySection( clientId );\n\n\t\t\tif (\n\t\t\t\tpatternName &&\n\t\t\t\t! isEditedContentOnlySection &&\n\t\t\t\t! isIsolatedEditor\n\t\t\t) {\n\t\t\t\tconst pattern = __experimentalGetParsedPattern( patternName );\n\t\t\t\tconst positionLabel = getPositionTypeLabel( attributes );\n\t\t\t\treturn {\n\t\t\t\t\tisSynced: false,\n\t\t\t\t\ttitle: __( 'Pattern' ),\n\t\t\t\t\ticon: symbol,\n\t\t\t\t\tdescription:\n\t\t\t\t\t\tpattern?.description || __( 'A block pattern.' ),\n\t\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\t\tpositionLabel,\n\t\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\t\tname: pattern?.title || attributes?.metadata?.name,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst match = getActiveBlockVariation( blockName, attributes );\n\t\t\tconst isSynced =\n\t\t\t\tisReusableBlock( blockType ) || isTemplatePart( blockType );\n\t\t\tconst syncedTitle = isSynced\n\t\t\t\t? getBlockLabel( blockType, attributes )\n\t\t\t\t: undefined;\n\t\t\tconst title = syncedTitle || blockType.title;\n\t\t\tconst positionLabel = getPositionTypeLabel( attributes );\n\t\t\tconst blockTypeInfo = {\n\t\t\t\tisSynced,\n\t\t\t\ttitle,\n\t\t\t\ticon: blockType.icon,\n\t\t\t\tdescription: blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\tname: attributes?.metadata?.name,\n\t\t\t};\n\t\t\tif ( ! match ) {\n\t\t\t\treturn blockTypeInfo;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tisSynced,\n\t\t\t\ttitle: match.title || blockType.title,\n\t\t\t\ticon: match.icon || blockType.icon,\n\t\t\t\tdescription: match.description || blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\tname: attributes?.metadata?.name,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,oBAKO;AACP,kBAAmB;AACnB,mBAAuB;AAKvB,mBAA0C;AAC1C,yBAAuB;AACvB,0BAAoC;AAuBpC,SAAS,qBAAsB,YAAa;AAC3C,QAAM,eAAe,YAAY,OAAO,UAA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jB,cAAAC,6BAAe,WAAW,UAAW,IACrC;AACH,YAAM,QAAQ,eAAe,UAAU;AACvC,YAAM,gBAAgB,qBAAsB,UAAW;AACvD,YAAM,gBAAgB;AAAA,QACrB;AAAA,QACA;AAAA,QACA,MAAM,UAAU;AAAA,QAChB,aAAa,UAAU;AAAA,QACvB,QAAQ,YAAY;AAAA,QACpB;AAAA,QACA,cAAc,YAAY,OAAO,UAAU;AAAA,QAC3C,MAAM,YAAY,UAAU;AAAA,MAC7B;AACA,UAAK,CAAE,OAAQ;AACd,eAAO;AAAA,MACR;AAEA,aAAO;AAAA,QACN;AAAA,QACA,OAAO,MAAM,SAAS,UAAU;AAAA,QAChC,MAAM,MAAM,QAAQ,UAAU;AAAA,QAC9B,aAAa,MAAM,eAAe,UAAU;AAAA,QAC5C,QAAQ,YAAY;AAAA,QACpB;AAAA,QACA,cAAc,YAAY,OAAO,UAAU;AAAA,QAC3C,MAAM,YAAY,UAAU;AAAA,MAC7B;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AACD;",
6
6
  "names": ["blockEditorStore", "blocksStore", "positionLabel", "getBlockLabel"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/writing-flow/use-tab-nav.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { focus, isFormElement } from '@wordpress/dom';\nimport { TAB } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { isInSameBlock, isInsideRootBlock } from '../../utils/dom';\nimport { unlock } from '../../lock-unlock';\n\nexport default function useTabNav() {\n\tconst containerRef = /** @type {typeof useRef<HTMLElement>} */ ( useRef )();\n\tconst focusCaptureBeforeRef = useRef();\n\tconst focusCaptureAfterRef = useRef();\n\n\tconst {\n\t\thasMultiSelection,\n\t\tgetSelectedBlockClientId,\n\t\tgetBlockCount,\n\t\tgetBlockOrder,\n\t\tgetLastFocus,\n\t\tgetSectionRootClientId,\n\t\tisZoomOut,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { setLastFocus } = unlock( useDispatch( blockEditorStore ) );\n\n\t// Reference that holds the a flag for enabling or disabling\n\t// capturing on the focus capture elements.\n\tconst noCaptureRef = useRef();\n\n\tfunction onFocusCapture( event ) {\n\t\tconst canvasElement =\n\t\t\tcontainerRef.current.ownerDocument === event.target.ownerDocument\n\t\t\t\t? containerRef.current\n\t\t\t\t: containerRef.current.ownerDocument.defaultView.frameElement;\n\n\t\t// Do not capture incoming focus if set by us in WritingFlow.\n\t\tif ( noCaptureRef.current ) {\n\t\t\tnoCaptureRef.current = null;\n\t\t} else if ( hasMultiSelection() ) {\n\t\t\tcontainerRef.current.focus();\n\t\t} else if ( getSelectedBlockClientId() ) {\n\t\t\tif ( getLastFocus()?.current ) {\n\t\t\t\tgetLastFocus().current.focus();\n\t\t\t} else {\n\t\t\t\t// Handles when the last focus has not been set yet, or has been cleared by new blocks being added via the inserter.\n\t\t\t\tcontainerRef.current\n\t\t\t\t\t.querySelector(\n\t\t\t\t\t\t`[data-block=\"${ getSelectedBlockClientId() }\"]`\n\t\t\t\t\t)\n\t\t\t\t\t.focus();\n\t\t\t}\n\t\t}\n\t\t// In \"compose\" mode without a selected ID, we want to place focus on the section root when tabbing to the canvas.\n\t\telse if ( isZoomOut() ) {\n\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\t\t\tconst sectionBlocks = getBlockOrder( sectionRootClientId );\n\n\t\t\t// If we have section within the section root, focus the first one.\n\t\t\tif ( sectionBlocks.length ) {\n\t\t\t\tcontainerRef.current\n\t\t\t\t\t.querySelector( `[data-block=\"${ sectionBlocks[ 0 ] }\"]` )\n\t\t\t\t\t.focus();\n\t\t\t}\n\t\t\t// If we don't have any section blocks, focus the section root.\n\t\t\telse if ( sectionRootClientId ) {\n\t\t\t\tcontainerRef.current\n\t\t\t\t\t.querySelector( `[data-block=\"${ sectionRootClientId }\"]` )\n\t\t\t\t\t.focus();\n\t\t\t} else {\n\t\t\t\t// If we don't have any section root, focus the canvas.\n\t\t\t\tcanvasElement.focus();\n\t\t\t}\n\t\t} else {\n\t\t\tconst isBefore =\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tevent.target.compareDocumentPosition( canvasElement ) &\n\t\t\t\tevent.target.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tconst tabbables = focus.tabbable.find( containerRef.current );\n\t\t\tif ( tabbables.length ) {\n\t\t\t\tconst next = isBefore\n\t\t\t\t\t? tabbables[ 0 ]\n\t\t\t\t\t: tabbables[ tabbables.length - 1 ];\n\t\t\t\tnext.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tconst before = (\n\t\t<div\n\t\t\tref={ focusCaptureBeforeRef }\n\t\t\ttabIndex=\"0\"\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst after = (\n\t\t<div\n\t\t\tref={ focusCaptureAfterRef }\n\t\t\ttabIndex=\"0\"\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst ref = useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In Edit mode, Tab should focus the first tabbable element after\n\t\t\t// the content, which is normally the sidebar (with block controls)\n\t\t\t// and Shift+Tab should focus the first tabbable element before the\n\t\t\t// content, which is normally the block toolbar.\n\t\t\t// Arrow keys can be used, and Tab and arrow keys can be used in\n\t\t\t// Navigation mode (press Esc), to navigate through blocks.\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t// Bails in case the focus capture elements aren\u2019t present. They\n\t\t\t\t// may be omitted to avoid silent tab stops in preview mode.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/59317\n\t\t\t\t! focusCaptureAfterRef.current ||\n\t\t\t\t! focusCaptureBeforeRef.current\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { target, shiftKey: isShift } = event;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst nextTabbable = focus.tabbable[ direction ]( target );\n\n\t\t\t// We want to constrain the tabbing to the block and its child blocks.\n\t\t\t// If the preceding form element is within a different block,\n\t\t\t// such as two sibling image blocks in the placeholder state,\n\t\t\t// we want shift + tab from the first form element to move to the image\n\t\t\t// block toolbar and not the previous image block's form element.\n\t\t\tconst currentBlock = target.closest( '[data-block]' );\n\t\t\tconst isElementPartOfSelectedBlock =\n\t\t\t\tcurrentBlock &&\n\t\t\t\tnextTabbable &&\n\t\t\t\t( isInSameBlock( currentBlock, nextTabbable ) ||\n\t\t\t\t\tisInsideRootBlock( currentBlock, nextTabbable ) );\n\n\t\t\t// Allow tabbing from the block wrapper to a form element,\n\t\t\t// and between form elements rendered in a block and its child blocks,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\tisFormElement( nextTabbable ) &&\n\t\t\t\tisElementPartOfSelectedBlock\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCaptureRef.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tsetLastFocus( { ...getLastFocus(), current: event.target } );\n\n\t\t\tconst { ownerDocument } = node;\n\n\t\t\t// If focus disappears due to there being no blocks, move focus to\n\t\t\t// the writing flow wrapper.\n\t\t\tif (\n\t\t\t\t! event.relatedTarget &&\n\t\t\t\tevent.target.hasAttribute( 'data-block' ) &&\n\t\t\t\townerDocument.activeElement === ownerDocument.body &&\n\t\t\t\tgetBlockCount() === 0\n\t\t\t) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( containerRef.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// Only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\t\tdefaultView.addEventListener( 'keydown', preventScrollOnTab );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'keydown', preventScrollOnTab );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n\n\tconst mergedRefs = useMergeRefs( [ containerRef, ref ] );\n\n\treturn [ before, mergedRefs, after ];\n}\n"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { focus, isFormElement } from '@wordpress/dom';\nimport { TAB } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { isInSameBlock, isInsideRootBlock } from '../../utils/dom';\nimport { unlock } from '../../lock-unlock';\n\nexport default function useTabNav() {\n\tconst containerRef = /** @type {typeof useRef<HTMLElement>} */ ( useRef )();\n\tconst focusCaptureBeforeRef = useRef();\n\tconst focusCaptureAfterRef = useRef();\n\n\tconst {\n\t\thasMultiSelection,\n\t\tgetSelectedBlockClientId,\n\t\tgetBlockCount,\n\t\tgetBlockOrder,\n\t\tgetLastFocus,\n\t\tgetSectionRootClientId,\n\t\tisZoomOut,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { setLastFocus } = unlock( useDispatch( blockEditorStore ) );\n\n\t// Reference that holds the a flag for enabling or disabling\n\t// capturing on the focus capture elements.\n\tconst noCaptureRef = useRef();\n\n\tfunction onFocusCapture( event ) {\n\t\tconst canvasElement =\n\t\t\tcontainerRef.current.ownerDocument === event.target.ownerDocument\n\t\t\t\t? containerRef.current\n\t\t\t\t: containerRef.current.ownerDocument.defaultView.frameElement;\n\n\t\t// Do not capture incoming focus if set by us in WritingFlow.\n\t\tif ( noCaptureRef.current ) {\n\t\t\tnoCaptureRef.current = null;\n\t\t} else if ( hasMultiSelection() ) {\n\t\t\tcontainerRef.current.focus();\n\t\t} else if ( getSelectedBlockClientId() ) {\n\t\t\tif ( getLastFocus()?.current ) {\n\t\t\t\tgetLastFocus().current.focus();\n\t\t\t} else {\n\t\t\t\t// Handles when the last focus has not been set yet, or has been cleared by new blocks being added via the inserter.\n\t\t\t\tcontainerRef.current\n\t\t\t\t\t.querySelector(\n\t\t\t\t\t\t`[data-block=\"${ getSelectedBlockClientId() }\"]`\n\t\t\t\t\t)\n\t\t\t\t\t.focus();\n\t\t\t}\n\t\t}\n\t\t// In \"compose\" mode without a selected ID, we want to place focus on the section root when tabbing to the canvas.\n\t\telse if ( isZoomOut() ) {\n\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\t\t\tconst sectionBlocks = getBlockOrder( sectionRootClientId );\n\n\t\t\t// If we have section within the section root, focus the first one.\n\t\t\tif ( sectionBlocks.length ) {\n\t\t\t\tcontainerRef.current\n\t\t\t\t\t.querySelector( `[data-block=\"${ sectionBlocks[ 0 ] }\"]` )\n\t\t\t\t\t.focus();\n\t\t\t}\n\t\t\t// If we don't have any section blocks, focus the section root.\n\t\t\telse if ( sectionRootClientId ) {\n\t\t\t\tcontainerRef.current\n\t\t\t\t\t.querySelector( `[data-block=\"${ sectionRootClientId }\"]` )\n\t\t\t\t\t.focus();\n\t\t\t} else {\n\t\t\t\t// If we don't have any section root, focus the canvas.\n\t\t\t\tcanvasElement.focus();\n\t\t\t}\n\t\t} else {\n\t\t\tconst isBefore =\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tevent.target.compareDocumentPosition( canvasElement ) &\n\t\t\t\tevent.target.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tconst tabbables = focus.tabbable.find( containerRef.current );\n\t\t\tif ( tabbables.length ) {\n\t\t\t\tconst next = isBefore\n\t\t\t\t\t? tabbables[ 0 ]\n\t\t\t\t\t: tabbables[ tabbables.length - 1 ];\n\t\t\t\tnext.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tconst before = (\n\t\t<div\n\t\t\tref={ focusCaptureBeforeRef }\n\t\t\ttabIndex=\"0\"\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst after = (\n\t\t<div\n\t\t\tref={ focusCaptureAfterRef }\n\t\t\ttabIndex=\"0\"\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst ref = useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In Edit mode, Tab should focus the first tabbable element after\n\t\t\t// the content, which is normally the sidebar (with block controls)\n\t\t\t// and Shift+Tab should focus the first tabbable element before the\n\t\t\t// content, which is normally the block toolbar.\n\t\t\t// Arrow keys can be used, and Tab and arrow keys can be used in\n\t\t\t// Navigation mode (press Esc), to navigate through blocks.\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t// Bails in case the focus capture elements aren’t present. They\n\t\t\t\t// may be omitted to avoid silent tab stops in preview mode.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/59317\n\t\t\t\t! focusCaptureAfterRef.current ||\n\t\t\t\t! focusCaptureBeforeRef.current\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { target, shiftKey: isShift } = event;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst nextTabbable = focus.tabbable[ direction ]( target );\n\n\t\t\t// We want to constrain the tabbing to the block and its child blocks.\n\t\t\t// If the preceding form element is within a different block,\n\t\t\t// such as two sibling image blocks in the placeholder state,\n\t\t\t// we want shift + tab from the first form element to move to the image\n\t\t\t// block toolbar and not the previous image block's form element.\n\t\t\tconst currentBlock = target.closest( '[data-block]' );\n\t\t\tconst isElementPartOfSelectedBlock =\n\t\t\t\tcurrentBlock &&\n\t\t\t\tnextTabbable &&\n\t\t\t\t( isInSameBlock( currentBlock, nextTabbable ) ||\n\t\t\t\t\tisInsideRootBlock( currentBlock, nextTabbable ) );\n\n\t\t\t// Allow tabbing from the block wrapper to a form element,\n\t\t\t// and between form elements rendered in a block and its child blocks,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\tisFormElement( nextTabbable ) &&\n\t\t\t\tisElementPartOfSelectedBlock\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCaptureRef.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tsetLastFocus( { ...getLastFocus(), current: event.target } );\n\n\t\t\tconst { ownerDocument } = node;\n\n\t\t\t// If focus disappears due to there being no blocks, move focus to\n\t\t\t// the writing flow wrapper.\n\t\t\tif (\n\t\t\t\t! event.relatedTarget &&\n\t\t\t\tevent.target.hasAttribute( 'data-block' ) &&\n\t\t\t\townerDocument.activeElement === ownerDocument.body &&\n\t\t\t\tgetBlockCount() === 0\n\t\t\t) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( containerRef.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// Only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\t\tdefaultView.addEventListener( 'keydown', preventScrollOnTab );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'keydown', preventScrollOnTab );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n\n\tconst mergedRefs = useMergeRefs( [ containerRef, ref ] );\n\n\treturn [ before, mergedRefs, after ];\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAqC;AACrC,sBAAoB;AACpB,kBAAuC;AACvC,qBAA2C;AAC3C,qBAAuB;AAKvB,mBAA0C;AAC1C,IAAAA,cAAiD;AACjD,yBAAuB;AAiFrB;AA/Ea,SAA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Ac,QAC9C,cAAc,MAAM,GACnB;AACD,aAAK,MAAM;AAAA,MACZ;AAAA,IACD;AAUA,aAAS,mBAAoB,OAAQ;AACpC,UAAK,MAAM,YAAY,qBAAM;AAC5B;AAAA,MACD;AAEA,UAAK,MAAM,QAAQ,aAAc,MAAO,MAAM,UAAW;AACxD;AAAA,MACD;AAEA,UAAK,aAAa,YAAY,MAAM,QAAS;AAC5C;AAAA,MACD;AAEA,YAAM,UAAU,MAAM;AACtB,YAAM,YAAY,UAAU,iBAAiB;AAC7C,YAAM,SAAS,iBAAM,SAAU,SAAU,EAAG,MAAM,MAAO;AAEzD,UACC,WAAW,sBAAsB,WACjC,WAAW,qBAAqB,SAC/B;AACD,cAAM,eAAe;AACrB,eAAO,MAAO,EAAE,eAAe,KAAK,CAAE;AAAA,MACvC;AAAA,IACD;AAEA,UAAM,EAAE,cAAc,IAAI;AAC1B,UAAM,EAAE,YAAY,IAAI;AACxB,gBAAY,iBAAkB,WAAW,kBAAmB;AAC5D,SAAK,iBAAkB,WAAW,SAAU;AAC5C,SAAK,iBAAkB,YAAY,UAAW;AAC9C,WAAO,MAAM;AACZ,kBAAY,oBAAqB,WAAW,kBAAmB;AAC/D,WAAK,oBAAqB,WAAW,SAAU;AAC/C,WAAK,oBAAqB,YAAY,UAAW;AAAA,IAClD;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,iBAAa,6BAAc,CAAE,cAAc,GAAI,CAAE;AAEvD,SAAO,CAAE,QAAQ,YAAY,KAAM;AACpC;",
6
6
  "names": ["import_dom", "blockEditorStore", "ownerDocument"]
7
7
  }
@@ -55,12 +55,11 @@ function BlockEditAnchorControlPure({ anchor, setAttributes }) {
55
55
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components2.InspectorControls, { group: "advanced", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
56
56
  import_components.TextControl,
57
57
  {
58
- __next40pxDefaultSize: true,
59
58
  className: "html-anchor-control",
60
59
  label: (0, import_i18n.__)("HTML anchor"),
61
60
  help: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
62
61
  (0, import_i18n.__)(
63
- "Enter a word or two\u2014without spaces\u2014to make a unique web address just for this block, called an \u201Canchor\u201D. Then, you\u2019ll be able to link directly to this section of your page."
62
+ "Enter a word or two—without spaces—to make a unique web address just for this block, called an “anchor”. Then, you’ll be able to link directly to this section of your page."
64
63
  ),
65
64
  " ",
66
65
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/anchor.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.anchor ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockEditAnchorControlPure( { anchor, setAttributes } ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<TextControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\thelp={\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Enter a word or two\u2014without spaces\u2014to make a unique web address just for this block, called an \u201Canchor\u201D. Then, you\u2019ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t) }{ ' ' }\n\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-jumps/'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\tvalue={ anchor || '' }\n\t\t\t\tplaceholder={ null }\n\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tanchor: nextValue !== '' ? nextValue : undefined,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\tautoComplete=\"off\"\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nexport default {\n\taddSaveProps,\n\tedit: BlockEditAnchorControlPure,\n\tattributeKeys: [ 'anchor' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'anchor' );\n\t},\n};\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA0B;AAC1B,wBAA0C;AAC1C,kBAAmB;AACnB,oBAAgC;AAKhC,IAAAA,qBAAkC;AAClC,gCAAoC;AAiD/B;AA1CL,IAAM,eAAe;AAUd,SAAS,aAAc,UAAW;AAExC,MAAK,WAAY,SAAS,YAAY,UAAU,CAAC,IAAM;AACtD,WAAO;AAAA,EACR;AACA,UAAK,+BAAiB,UAAU,QAAS,GAAI;AAE5C,aAAS,aAAa;AAAA,MACrB,GAAG,SAAS;AAAA,MACZ,QAAQ;AAAA,QACP,MAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;AAEA,SAAS,2BAA4B,EAAE,QAAQ,cAAc,GAAI;AAChE,QAAM,uBAAmB,+CAAoB;AAE7C,MAAK,qBAAqB,WAAY;AACrC,WAAO;AAAA,EACR;AAEA,SACC,4CAAC,wCAAkB,OAAM,YACxB;AAAA,IAAC;AAAA;AAAA,MACA,uBAAqB;AAAA,MACrB,WAAU;AAAA,MACV,WAAQ,gBAAI,aAAc;AAAA,MAC1B,MACC,4EACG;AAAA;AAAA,UACD;AAAA,QACD;AAAA,QAAK;AAAA,QACL;AAAA,UAAC;AAAA;AAAA,YACA,UAAO;AAAA,cACN;AAAA,YACD;AAAA,YAEE,8BAAI,0BAA2B;AAAA;AAAA,QAClC;AAAA,SACD;AAAA,MAED,OAAQ,UAAU;AAAA,MAClB,aAAc;AAAA,MACd,UAAW,CAAE,cAAe;AAC3B,oBAAY,UAAU,QAAS,cAAc,GAAI;AACjD,sBAAe;AAAA,UACd,QAAQ,cAAc,KAAK,YAAY;AAAA,QACxC,CAAE;AAAA,MACH;AAAA,MACA,gBAAe;AAAA,MACf,cAAa;AAAA;AAAA,EACd,GACD;AAEF;AAEA,IAAO,iBAAQ;AAAA,EACd;AAAA,EACA,MAAM;AAAA,EACN,eAAe,CAAE,QAAS;AAAA,EAC1B,WAAY,MAAO;AAClB,eAAO,+BAAiB,MAAM,QAAS;AAAA,EACxC;AACD;AAaO,SAAS,aAAc,YAAY,WAAW,YAAa;AACjE,UAAK,+BAAiB,WAAW,QAAS,GAAI;AAC7C,eAAW,KAAK,WAAW,WAAW,KAAK,OAAO,WAAW;AAAA,EAC9D;AAEA,SAAO;AACR;AAAA,IAEA,wBAAW,4BAA4B,yBAAyB,YAAa;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.anchor ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockEditAnchorControlPure( { anchor, setAttributes } ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<TextControl\n\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\thelp={\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Enter a word or two—without spaces—to make a unique web address just for this block, called an “anchor”. Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t) }{ ' ' }\n\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-jumps/'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\tvalue={ anchor || '' }\n\t\t\t\tplaceholder={ null }\n\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tanchor: nextValue !== '' ? nextValue : undefined,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\tautoComplete=\"off\"\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nexport default {\n\taddSaveProps,\n\tedit: BlockEditAnchorControlPure,\n\tattributeKeys: [ 'anchor' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'anchor' );\n\t},\n};\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA0B;AAC1B,wBAA0C;AAC1C,kBAAmB;AACnB,oBAAgC;AAKhC,IAAAA,qBAAkC;AAClC,gCAAoC;AAgD/B;AAzCL,IAAM,eAAe;AAUd,SAAS,aAAc,UAAW;AAExC,MAAK,WAAY,SAAS,YAAY,UAAU,CAAC,IAAM;AACtD,WAAO;AAAA,EACR;AACA,UAAK,+BAAiB,UAAU,QAAS,GAAI;AAE5C,aAAS,aAAa;AAAA,MACrB,GAAG,SAAS;AAAA,MACZ,QAAQ;AAAA,QACP,MAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;AAEA,SAAS,2BAA4B,EAAE,QAAQ,cAAc,GAAI;AAChE,QAAM,uBAAmB,+CAAoB;AAE7C,MAAK,qBAAqB,WAAY;AACrC,WAAO;AAAA,EACR;AAEA,SACC,4CAAC,wCAAkB,OAAM,YACxB;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,WAAQ,gBAAI,aAAc;AAAA,MAC1B,MACC,4EACG;AAAA;AAAA,UACD;AAAA,QACD;AAAA,QAAK;AAAA,QACL;AAAA,UAAC;AAAA;AAAA,YACA,UAAO;AAAA,cACN;AAAA,YACD;AAAA,YAEE,8BAAI,0BAA2B;AAAA;AAAA,QAClC;AAAA,SACD;AAAA,MAED,OAAQ,UAAU;AAAA,MAClB,aAAc;AAAA,MACd,UAAW,CAAE,cAAe;AAC3B,oBAAY,UAAU,QAAS,cAAc,GAAI;AACjD,sBAAe;AAAA,UACd,QAAQ,cAAc,KAAK,YAAY;AAAA,QACxC,CAAE;AAAA,MACH;AAAA,MACA,gBAAe;AAAA,MACf,cAAa;AAAA;AAAA,EACd,GACD;AAEF;AAEA,IAAO,iBAAQ;AAAA,EACd;AAAA,EACA,MAAM;AAAA,EACN,eAAe,CAAE,QAAS;AAAA,EAC1B,WAAY,MAAO;AAClB,eAAO,+BAAiB,MAAM,QAAS;AAAA,EACxC;AACD;AAaO,SAAS,aAAc,YAAY,WAAW,YAAa;AACjE,UAAK,+BAAiB,WAAW,QAAS,GAAI;AAC7C,eAAW,KAAK,WAAW,WAAW,KAAK,OAAO,WAAW;AAAA,EAC9D;AAEA,SAAO;AACR;AAAA,IAEA,wBAAW,4BAA4B,yBAAyB,YAAa;",
6
6
  "names": ["import_components"]
7
7
  }
@@ -33,6 +33,7 @@ __export(background_exports, {
33
33
  BACKGROUND_BLOCK_DEFAULT_VALUES: () => BACKGROUND_BLOCK_DEFAULT_VALUES,
34
34
  BACKGROUND_SUPPORT_KEY: () => BACKGROUND_SUPPORT_KEY,
35
35
  BackgroundImagePanel: () => BackgroundImagePanel,
36
+ backgroundResetAllFilter: () => backgroundResetAllFilter,
36
37
  default: () => background_default,
37
38
  getBackgroundImageClasses: () => getBackgroundImageClasses,
38
39
  hasBackgroundSupport: () => hasBackgroundSupport,
@@ -42,10 +43,12 @@ module.exports = __toCommonJS(background_exports);
42
43
  var import_clsx = __toESM(require("clsx"));
43
44
  var import_blocks = require("@wordpress/blocks");
44
45
  var import_data = require("@wordpress/data");
45
- var import_element = require("@wordpress/element");
46
+ var import_i18n = require("@wordpress/i18n");
46
47
  var import_inspector_controls = __toESM(require("../components/inspector-controls/index.cjs"));
47
48
  var import_utils = require("./utils.cjs");
49
+ var import_color_values = require("../utils/color-values.cjs");
48
50
  var import_store = require("../store/index.cjs");
51
+ var import_contrast_checker = __toESM(require("./contrast-checker.cjs"));
49
52
  var import_background_panel = __toESM(require("../components/global-styles/background-panel.cjs"));
50
53
  var import_private_keys = require("../store/private-keys.cjs");
51
54
  var import_block_style_state = require("./block-style-state.cjs");
@@ -100,40 +103,46 @@ function useBlockProps({ name, style }) {
100
103
  function getBackgroundImageClasses(style) {
101
104
  return (0, import_background_panel.hasBackgroundImageValue)(style) || (0, import_background_panel.hasBackgroundGradientValue)(style) ? "has-background" : "";
102
105
  }
103
- function BackgroundInspectorControl({
104
- children,
105
- backgroundGradientSupported = false
106
- }) {
107
- const resetAllFilter = (0, import_element.useCallback)(
108
- (attributes) => {
109
- const updatedClassName = attributes.className?.includes(
110
- "has-background"
111
- ) ? attributes.className.split(" ").filter((c) => c !== "has-background").join(" ") || void 0 : attributes.className;
112
- return {
113
- ...attributes,
114
- className: updatedClassName,
115
- style: (0, import_utils.cleanEmptyObject)({
116
- ...attributes.style,
117
- background: void 0,
118
- color: backgroundGradientSupported ? {
119
- ...attributes.style?.color,
120
- gradient: void 0
121
- } : attributes.style?.color
122
- })
123
- };
124
- },
125
- [backgroundGradientSupported]
106
+ function backgroundResetAllFilter(attributes) {
107
+ const updatedClassName = attributes.className?.includes("has-background") ? attributes.className.split(" ").filter((c) => c !== "has-background").join(" ") || void 0 : attributes.className;
108
+ return {
109
+ ...attributes,
110
+ className: updatedClassName,
111
+ backgroundColor: void 0,
112
+ gradient: void 0,
113
+ style: (0, import_utils.cleanEmptyObject)({
114
+ ...attributes.style,
115
+ background: void 0,
116
+ color: {
117
+ ...attributes.style?.color,
118
+ background: void 0,
119
+ gradient: void 0
120
+ }
121
+ })
122
+ };
123
+ }
124
+ function BackgroundInspectorControl({ children }) {
125
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
126
+ import_inspector_controls.default,
127
+ {
128
+ group: "background",
129
+ resetAllFilter: backgroundResetAllFilter,
130
+ children
131
+ }
126
132
  );
127
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_inspector_controls.default, { group: "background", resetAllFilter, children });
128
133
  }
129
134
  function BackgroundImagePanel({
130
135
  clientId,
131
136
  name,
132
137
  setAttributes,
133
- settings
138
+ settings,
139
+ // Allows rendering outside the `background` inspector group (e.g. section
140
+ // blocks direct-render this panel because their support fills are gated
141
+ // off by editing mode). Defaults to the slot-based wrapper.
142
+ asWrapper
134
143
  }) {
135
144
  const selectedState = (0, import_block_style_state.useBlockStyleState)();
136
- const { style, className, inheritedValue } = (0, import_data.useSelect)(
145
+ const { style, className, backgroundColor, gradient, inheritedValue } = (0, import_data.useSelect)(
137
146
  (select) => {
138
147
  const { getBlockAttributes, getSettings } = select(import_store.store);
139
148
  const _settings = getSettings();
@@ -141,13 +150,8 @@ function BackgroundImagePanel({
141
150
  return {
142
151
  style: blockAttributes?.style,
143
152
  className: blockAttributes?.className,
144
- /*
145
- * To ensure we pass down the right inherited values:
146
- * @TODO 1. Pass inherited value down to all block style controls,
147
- * See: packages/block-editor/src/hooks/style.js
148
- * @TODO 2. Add support for block style variations,
149
- * See implementation: packages/block-editor/src/hooks/block-style-variation.js
150
- */
153
+ backgroundColor: blockAttributes?.backgroundColor,
154
+ gradient: blockAttributes?.gradient,
151
155
  inheritedValue: _settings[import_private_keys.globalStylesDataKey]?.blocks?.[name]
152
156
  };
153
157
  },
@@ -157,54 +161,85 @@ function BackgroundImagePanel({
157
161
  name,
158
162
  "gradient"
159
163
  );
160
- const as = (0, import_element.useCallback)(
161
- ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
162
- BackgroundInspectorControl,
163
- {
164
- backgroundGradientSupported,
165
- children
164
+ const colorSupport = (0, import_blocks.getBlockSupport)(name, "color");
165
+ const hasColorBackgroundSupport = colorSupport && colorSupport.background !== false;
166
+ const hasColorGradientSupport = !!colorSupport?.gradients;
167
+ const isStateSelected = !(0, import_block_style_state.isDefaultBlockStyleState)(selectedState);
168
+ const styleValue = {
169
+ ...style,
170
+ color: {
171
+ ...style?.color,
172
+ background: backgroundColor ? "var:preset|color|" + backgroundColor : style?.color?.background,
173
+ gradient: !backgroundGradientSupported && gradient ? "var:preset|gradient|" + gradient : style?.color?.gradient
174
+ },
175
+ ...backgroundGradientSupported && {
176
+ background: {
177
+ ...style?.background,
178
+ gradient: gradient ? "var:preset|gradient|" + gradient : style?.background?.gradient ?? style?.color?.gradient
166
179
  }
167
- ),
168
- [backgroundGradientSupported]
169
- );
170
- if (!(0, import_background_panel.useHasBackgroundPanel)(settings) || !hasBackgroundSupport(name)) {
180
+ }
181
+ };
182
+ const enableContrastChecking = !isStateSelected && !styleValue?.color?.gradient && !styleValue?.background?.gradient && !!styleValue?.color?.background && (settings?.color?.text || settings?.color?.link) && false !== (0, import_blocks.getBlockSupport)(name, ["color", "enableContrastChecker"]);
183
+ const contrastWarning = (0, import_contrast_checker.default)({
184
+ clientId,
185
+ name,
186
+ enabled: !!enableContrastChecking,
187
+ messageOverride: (0, import_i18n.__)(
188
+ "This color combination has poor contrast. Consider increasing contrast between background and foreground."
189
+ )
190
+ });
191
+ if (!(0, import_background_panel.useHasBackgroundPanel)(settings) || !hasBackgroundSupport(name) && !hasColorBackgroundSupport && !hasColorGradientSupport) {
171
192
  return null;
172
193
  }
173
- const isStateSelected = !(0, import_block_style_state.isDefaultBlockStyleState)(selectedState);
174
- const onChange = isStateSelected ? (newStyle) => {
175
- setAttributes({
176
- style: (0, import_block_style_state.setStyleForState)(style, selectedState, newStyle)
177
- });
178
- } : (newStyle) => {
194
+ const onChange = (newStyle) => {
195
+ if (isStateSelected) {
196
+ setAttributes({
197
+ style: (0, import_block_style_state.setStyleForState)(style, selectedState, newStyle)
198
+ });
199
+ return;
200
+ }
201
+ const newBackgroundColorValue = newStyle?.color?.background;
202
+ const newBackgroundColorSlug = (0, import_color_values.extractPresetSlug)(
203
+ newBackgroundColorValue,
204
+ "color"
205
+ );
206
+ const newGradientValue = backgroundGradientSupported ? newStyle?.background?.gradient : newStyle?.color?.gradient;
207
+ const newGradientSlug = (0, import_color_values.extractPresetSlug)(
208
+ newGradientValue,
209
+ "gradient"
210
+ );
211
+ const cleanedColorGradient = newGradientSlug ? void 0 : newStyle?.color?.gradient;
212
+ const cleanedStyle = {
213
+ ...newStyle,
214
+ color: {
215
+ ...newStyle?.color,
216
+ background: newBackgroundColorSlug ? void 0 : newBackgroundColorValue,
217
+ gradient: backgroundGradientSupported ? void 0 : cleanedColorGradient
218
+ }
219
+ };
220
+ if (backgroundGradientSupported) {
221
+ cleanedStyle.background = {
222
+ ...cleanedStyle.background,
223
+ gradient: newStyle?.background?.gradient
224
+ };
225
+ }
179
226
  const isMigrating = backgroundGradientSupported && !!style?.color?.gradient;
180
227
  const newAttributes = {
181
- style: (0, import_utils.cleanEmptyObject)(
182
- backgroundGradientSupported ? {
183
- ...newStyle,
184
- color: {
185
- ...newStyle?.color,
186
- gradient: void 0
187
- }
188
- } : newStyle
189
- )
228
+ style: (0, import_utils.cleanEmptyObject)(cleanedStyle),
229
+ backgroundColor: newBackgroundColorSlug,
230
+ // The legacy `gradient` attribute is only used when the block does
231
+ // not support `background.gradient`; otherwise the gradient is
232
+ // stored in `style.background.gradient` above.
233
+ gradient: backgroundGradientSupported ? void 0 : newGradientSlug
190
234
  };
191
- if (isMigrating && !!newStyle?.background?.gradient) {
192
- newAttributes.className = (0, import_clsx.default)(
193
- className,
194
- "has-background"
195
- );
196
- } else if (!newStyle?.background?.gradient && className?.includes("has-background")) {
235
+ const hasNewGradient = !!newGradientSlug || !!newGradientValue;
236
+ if (isMigrating && hasNewGradient) {
237
+ newAttributes.className = (0, import_clsx.default)(className, "has-background");
238
+ } else if (!hasNewGradient && className?.includes("has-background")) {
197
239
  newAttributes.className = className.split(" ").filter((c) => c !== "has-background").join(" ") || void 0;
198
240
  }
199
241
  setAttributes(newAttributes);
200
242
  };
201
- const styleValue = backgroundGradientSupported && !style?.background?.gradient && style?.color?.gradient ? {
202
- ...style,
203
- background: {
204
- ...style?.background,
205
- gradient: style?.color?.gradient
206
- }
207
- } : style;
208
243
  const updatedSettings = {
209
244
  ...settings,
210
245
  background: {
@@ -212,21 +247,34 @@ function BackgroundImagePanel({
212
247
  backgroundSize: settings?.background?.backgroundSize && hasBackgroundSupport(name, "backgroundSize")
213
248
  }
214
249
  };
215
- const defaultControls = (0, import_blocks.getBlockSupport)(name, [
250
+ const backgroundDefaultControls = (0, import_blocks.getBlockSupport)(name, [
216
251
  BACKGROUND_SUPPORT_KEY,
217
252
  "__experimentalDefaultControls"
218
253
  ]);
254
+ const colorDefaultControls = (0, import_blocks.getBlockSupport)(name, [
255
+ "color",
256
+ "__experimentalDefaultControls"
257
+ ]);
258
+ const defaultControls = {
259
+ ...backgroundDefaultControls,
260
+ backgroundColor: colorDefaultControls?.background,
261
+ // Mirror the old combined control: show the gradient item by default
262
+ // when background color was shown by default.
263
+ gradient: backgroundDefaultControls?.gradient ?? colorDefaultControls?.background
264
+ };
265
+ const Wrapper = asWrapper || BackgroundInspectorControl;
219
266
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
220
267
  import_background_panel.default,
221
268
  {
222
269
  inheritedValue,
223
- as,
270
+ as: Wrapper,
224
271
  panelId: clientId,
225
272
  defaultValues: BACKGROUND_BLOCK_DEFAULT_VALUES,
226
273
  settings: updatedSettings,
227
274
  onChange,
228
275
  defaultControls,
229
- value: isStateSelected ? (0, import_block_style_state.getStyleForState)(style, selectedState) : styleValue
276
+ value: isStateSelected ? (0, import_block_style_state.getStyleForState)(style, selectedState) : styleValue,
277
+ contrastWarning
230
278
  }
231
279
  );
232
280
  }
@@ -240,6 +288,7 @@ var background_default = {
240
288
  BACKGROUND_BLOCK_DEFAULT_VALUES,
241
289
  BACKGROUND_SUPPORT_KEY,
242
290
  BackgroundImagePanel,
291
+ backgroundResetAllFilter,
243
292
  getBackgroundImageClasses,
244
293
  hasBackgroundSupport,
245
294
  setBackgroundStyleDefaults