@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/provider/use-block-sync.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useContext, useEffect, useRef } from '@wordpress/element';\nimport { useRegistry } from '@wordpress/data';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { SelectionContext } from './selection-context';\n\nconst noop = () => {};\n\n/**\n * Clones a block and its inner blocks, building a bidirectional mapping\n * between external (original) and internal (cloned) client IDs.\n *\n * This allows the block editor to use unique internal IDs while preserving\n * stable external IDs for features like real-time collaboration.\n *\n * @param {Object} block The block to clone.\n * @param {Object} mapping The mapping object with externalToInternal and internalToExternal Maps.\n * @return {Object} The cloned block with a new clientId.\n */\nfunction cloneBlockWithMapping( block, mapping ) {\n\tconst clonedBlock = cloneBlock( block );\n\n\t// Build bidirectional mapping\n\tmapping.externalToInternal.set( block.clientId, clonedBlock.clientId );\n\tmapping.internalToExternal.set( clonedBlock.clientId, block.clientId );\n\n\t// Recursively map inner blocks\n\tif ( block.innerBlocks?.length ) {\n\t\tclonedBlock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\tconst clonedInner = cloneBlockWithMapping( innerBlock, mapping );\n\t\t\t// The clonedBlock already has cloned inner blocks from cloneBlock(),\n\t\t\t// but we need to use our mapped versions to maintain the mapping.\n\t\t\treturn clonedInner;\n\t\t} );\n\t}\n\n\treturn clonedBlock;\n}\n\n/**\n * Restores external (original) client IDs on blocks before passing them\n * to onChange/onInput callbacks.\n *\n * @param {Object[]} blocks The blocks with internal client IDs.\n * @param {Object} mapping The mapping object with internalToExternal Map.\n * @return {Object[]} Blocks with external client IDs restored.\n */\nfunction restoreExternalIds( blocks, mapping ) {\n\treturn blocks.map( ( block ) => {\n\t\tconst externalId = mapping.internalToExternal.get( block.clientId );\n\t\treturn {\n\t\t\t...block,\n\t\t\t// Use external ID if available, otherwise keep internal ID (for new blocks)\n\t\t\tclientId: externalId ?? block.clientId,\n\t\t\tinnerBlocks: restoreExternalIds( block.innerBlocks, mapping ),\n\t\t};\n\t} );\n}\n\n/**\n * Restores external client IDs in selection state.\n *\n * @param {Object} selectionState The selection state with internal client IDs.\n * @param {Object} mapping The mapping object with internalToExternal Map.\n * @return {Object} Selection state with external client IDs.\n */\nfunction restoreSelectionIds( selectionState, mapping ) {\n\tconst { selectionStart, selectionEnd, initialPosition } = selectionState;\n\n\tconst restoreClientId = ( sel ) => {\n\t\tif ( ! sel?.clientId ) {\n\t\t\treturn sel;\n\t\t}\n\t\tconst externalId = mapping.internalToExternal.get( sel.clientId );\n\t\treturn {\n\t\t\t...sel,\n\t\t\tclientId: externalId ?? sel.clientId,\n\t\t};\n\t};\n\n\treturn {\n\t\tselectionStart: restoreClientId( selectionStart ),\n\t\tselectionEnd: restoreClientId( selectionEnd ),\n\t\tinitialPosition,\n\t};\n}\n\n/**\n * A function to call when the block value has been updated in the block-editor\n * store.\n *\n * @callback onBlockUpdate\n * @param {Object[]} blocks The updated blocks.\n * @param {Object} options The updated block options, such as selectionStart\n * and selectionEnd.\n */\n\n/**\n * useBlockSync is a side effect which handles bidirectional sync between the\n * block-editor store and a controlling data source which provides blocks. This\n * is most commonly used by the BlockEditorProvider to synchronize the contents\n * of the block-editor store with the root entity, like a post.\n *\n * Another example would be the template part block, which provides blocks from\n * a separate entity data source than a root entity. This hook syncs edits to\n * the template part in the block editor back to the entity and vice-versa.\n *\n * Here are some of its basic functions:\n * - Initializes the block-editor store for the given clientID to the blocks\n * given via props.\n * - Adds incoming changes (like undo) to the block-editor store.\n * - Adds outgoing changes (like editing content) to the controlling entity,\n * determining if a change should be considered persistent or not.\n * - Handles edge cases and race conditions which occur in those operations.\n * - Ignores changes which happen to other entities (like nested inner block\n * controllers.\n * - Passes selection state from the block-editor store to the controlling entity.\n *\n * @param {Object} props Props for the block sync hook\n * @param {string} props.clientId The client ID of the inner block controller.\n * If none is passed, then it is assumed to be a\n * root controller rather than an inner block\n * controller.\n * @param {Object[]} props.value The control value for the blocks. This value\n * is used to initialize the block-editor store\n * and for resetting the blocks to incoming\n * changes like undo.\n * @param {onBlockUpdate} props.onChange Function to call when a persistent\n * change has been made in the block-editor blocks\n * for the given clientId. For example, after\n * this function is called, an entity is marked\n * dirty because it has changes to save.\n * @param {onBlockUpdate} props.onInput Function to call when a non-persistent\n * change has been made in the block-editor blocks\n * for the given clientId. When this is called,\n * controlling sources do not become dirty.\n */\nexport default function useBlockSync( {\n\tclientId = null,\n\tvalue: controlledBlocks,\n\tonChange = noop,\n\tonInput = noop,\n} ) {\n\tconst registry = useRegistry();\n\tconst { getSelection, onChangeSelection } = useContext( SelectionContext );\n\n\tconst {\n\t\tresetBlocks,\n\t\tresetSelection,\n\t\treplaceInnerBlocks,\n\t\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst { getBlockName, getBlocks, getSelectionStart, getSelectionEnd } =\n\t\tregistry.select( blockEditorStore );\n\n\tconst pendingChangesRef = useRef( { incoming: null, outgoing: [] } );\n\tconst subscribedRef = useRef( false );\n\n\t// Mapping between external (original) and internal (cloned) client IDs.\n\t// This allows stable external IDs while using unique internal IDs.\n\tconst idMappingRef = useRef( {\n\t\texternalToInternal: new Map(),\n\t\tinternalToExternal: new Map(),\n\t} );\n\n\t// Tracks which context selection has already been applied, to avoid\n\t// duplicate restoration.\n\tconst appliedSelectionRef = useRef( null );\n\t// Flag to prevent the subscription from re-reporting a selection\n\t// change that was just restored from context (which would loop).\n\tconst isRestoringSelectionRef = useRef( false );\n\n\t// Restores selection from the SelectionContext using the current\n\t// idMapping. Called after blocks are (re-)cloned so that the\n\t// mapping is guaranteed to be fresh.\n\tconst restoreSelection = () => {\n\t\tconst selection = getSelection();\n\t\tif (\n\t\t\t! selection?.selectionStart?.clientId ||\n\t\t\tselection === appliedSelectionRef.current\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst startClientId = selection.selectionStart.clientId;\n\n\t\t// Check if this selection belongs to this controller.\n\t\t// Inner block controllers (clientId is set) own the block if\n\t\t// the external ID appears in their clone mapping.\n\t\t// The root controller (no clientId) owns it if the block\n\t\t// exists directly in the store.\n\t\tconst isOurs = clientId\n\t\t\t? idMappingRef.current.externalToInternal.has( startClientId )\n\t\t\t: !! getBlockName( startClientId );\n\n\t\tif ( isOurs ) {\n\t\t\tappliedSelectionRef.current = selection;\n\t\t\t// Inner block controllers need to convert external\u2192internal\n\t\t\t// IDs via the clone mapping; the root controller uses\n\t\t\t// external IDs directly (no mapping needed).\n\t\t\tconst convert = ( sel ) => {\n\t\t\t\tif ( ! sel?.clientId || ! clientId ) {\n\t\t\t\t\treturn sel;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\t...sel,\n\t\t\t\t\tclientId:\n\t\t\t\t\t\tidMappingRef.current.externalToInternal.get(\n\t\t\t\t\t\t\tsel.clientId\n\t\t\t\t\t\t) ?? sel.clientId,\n\t\t\t\t};\n\t\t\t};\n\t\t\t// Flag prevents the subscription from re-reporting this\n\t\t\t// selection change back to the entity (which would cause\n\t\t\t// an infinite update loop).\n\t\t\tisRestoringSelectionRef.current = true;\n\t\t\tresetSelection(\n\t\t\t\tconvert( selection.selectionStart ),\n\t\t\t\tconvert( selection.selectionEnd ),\n\t\t\t\tselection.initialPosition\n\t\t\t);\n\t\t\tisRestoringSelectionRef.current = false;\n\t\t}\n\t};\n\n\tconst setControlledBlocks = () => {\n\t\tif ( ! controlledBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't need to persist this change because we only replace\n\t\t// controlled inner blocks when the change was caused by an entity,\n\t\t// and so it would already be persisted.\n\t\tif ( clientId ) {\n\t\t\t// Batch so that the controlled flag and block replacement\n\t\t\t// are applied atomically \u2014 subscribers see a consistent state.\n\t\t\tregistry.batch( () => {\n\t\t\t\t// Clear previous mappings and build new ones during cloning.\n\t\t\t\t// This ensures the mapping stays in sync with the current blocks.\n\t\t\t\tidMappingRef.current.externalToInternal.clear();\n\t\t\t\tidMappingRef.current.internalToExternal.clear();\n\n\t\t\t\tconst storeBlocks = controlledBlocks.map( ( block ) =>\n\t\t\t\t\tcloneBlockWithMapping( block, idMappingRef.current )\n\t\t\t\t);\n\n\t\t\t\tsetHasControlledInnerBlocks( clientId, true );\n\n\t\t\t\tif ( subscribedRef.current ) {\n\t\t\t\t\tpendingChangesRef.current.incoming = storeBlocks;\n\t\t\t\t}\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceInnerBlocks( clientId, storeBlocks );\n\n\t\t\t\t// Invalidate the applied-selection ref so that\n\t\t\t\t// restoreSelection() at the end of the\n\t\t\t\t// controlledBlocks effect re-applies with the\n\t\t\t\t// freshly-built mapping (new internal IDs).\n\t\t\t\tappliedSelectionRef.current = null;\n\t\t\t} );\n\t\t} else {\n\t\t\tif ( subscribedRef.current ) {\n\t\t\t\tpendingChangesRef.current.incoming = controlledBlocks;\n\t\t\t}\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tresetBlocks( controlledBlocks );\n\t\t}\n\t};\n\n\t// Clean up the changes made by setControlledBlocks() when the component\n\t// containing useBlockSync() unmounts.\n\tconst unsetControlledBlocks = () => {\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\tsetHasControlledInnerBlocks( clientId, false );\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\treplaceInnerBlocks( clientId, [] );\n\t\t} else {\n\t\t\tresetBlocks( [] );\n\t\t}\n\t};\n\n\t// Add a subscription to the block-editor registry to detect when changes\n\t// have been made. This lets us inform the data source of changes. This\n\t// is an effect so that the subscriber can run synchronously without\n\t// waiting for React renders for changes.\n\tconst onInputRef = useRef( onInput );\n\tconst onChangeRef = useRef( onChange );\n\tuseEffect( () => {\n\t\tonInputRef.current = onInput;\n\t\tonChangeRef.current = onChange;\n\t}, [ onInput, onChange ] );\n\n\t// Determine if blocks need to be reset when they change.\n\t// Also restores selection from context after blocks are set.\n\tuseEffect( () => {\n\t\tconst isOutgoing =\n\t\t\tpendingChangesRef.current.outgoing.includes( controlledBlocks );\n\t\tconst storeMatch = getBlocks( clientId ) === controlledBlocks;\n\n\t\tif ( isOutgoing ) {\n\t\t\t// Skip block reset if the value matches expected outbound sync\n\t\t\t// triggered by this component by a preceding change detection.\n\t\t\t// Only skip if the value matches expectation, since a reset should\n\t\t\t// still occur if the value is modified (not equal by reference),\n\t\t\t// to allow that the consumer may apply modifications to reflect\n\t\t\t// back on the editor.\n\t\t\tif (\n\t\t\t\tpendingChangesRef.current.outgoing[\n\t\t\t\t\tpendingChangesRef.current.outgoing.length - 1\n\t\t\t\t] === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChangesRef.current.outgoing = [];\n\t\t\t}\n\t\t} else if ( ! storeMatch ) {\n\t\t\t// Reset changing value in all other cases than the sync described\n\t\t\t// above. Since this can be reached in an update following an out-\n\t\t\t// bound sync, unset the outbound value to avoid considering it in\n\t\t\t// subsequent renders.\n\t\t\tpendingChangesRef.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\n\t\t\t// Restore selection from context if it targets our scope.\n\t\t\t// Only done when blocks were reset from an external source\n\t\t\t// (undo/redo, entity navigation) \u2014 NOT for outgoing changes,\n\t\t\t// because dispatching resetSelection between keystrokes breaks\n\t\t\t// the isUpdatingSameBlockAttribute chain and creates per-\n\t\t\t// character undo levels.\n\t\t\trestoreSelection();\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tuseEffect( () => {\n\t\tconst {\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t\tisLastBlockChangePersistent,\n\t\t\t__unstableGetLastBlockChangeHistoryMode,\n\t\t\t__unstableIsLastBlockChangeIgnored,\n\t\t\tareInnerBlocksControlled,\n\t\t\tgetBlockParents,\n\t\t} = registry.select( blockEditorStore );\n\n\t\tlet blocks = getBlocks( clientId );\n\t\tlet isPersistent = isLastBlockChangePersistent();\n\t\tlet blockHistoryMode = __unstableGetLastBlockChangeHistoryMode();\n\t\tlet previousAreBlocksDifferent = false;\n\t\tlet prevSelectionStart = getSelectionStart();\n\t\tlet prevSelectionEnd = getSelectionEnd();\n\n\t\tsubscribedRef.current = true;\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Sometimes, when changing block lists, lingering subscriptions\n\t\t\t// might trigger before they are cleaned up. If the block for which\n\t\t\t// the subscription runs is no longer in the store, this would clear\n\t\t\t// its parent entity's block list. To avoid this, we bail out if\n\t\t\t// the subscription is triggering for a block (`clientId !== null`)\n\t\t\t// and its block name can't be found because it's not on the list.\n\t\t\t// (`getBlockName( clientId ) === null`).\n\t\t\tif ( clientId !== null && getBlockName( clientId ) === null ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newIsPersistent = isLastBlockChangePersistent();\n\t\t\tconst newBlockHistoryMode =\n\t\t\t\t__unstableGetLastBlockChangeHistoryMode();\n\t\t\tconst newBlocks = getBlocks( clientId );\n\t\t\tconst areBlocksDifferent = newBlocks !== blocks;\n\t\t\tblocks = newBlocks;\n\t\t\tif (\n\t\t\t\tareBlocksDifferent &&\n\t\t\t\t( pendingChangesRef.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChangesRef.current.incoming = null;\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\tblockHistoryMode = newBlockHistoryMode;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Since we often dispatch an action to mark the previous action as\n\t\t\t// persistent, we need to make sure that the blocks changed on the\n\t\t\t// previous action before committing the change.\n\t\t\tconst didPersistenceChange =\n\t\t\t\tpreviousAreBlocksDifferent &&\n\t\t\t\t! areBlocksDifferent &&\n\t\t\t\tnewIsPersistent &&\n\t\t\t\t! isPersistent;\n\n\t\t\tconst blocksChanged = areBlocksDifferent || didPersistenceChange;\n\n\t\t\t// Check if selection changed.\n\t\t\tconst newSelectionStart = getSelectionStart();\n\t\t\tconst newSelectionEnd = getSelectionEnd();\n\t\t\tconst selectionChanged =\n\t\t\t\tnewSelectionStart !== prevSelectionStart ||\n\t\t\t\tnewSelectionEnd !== prevSelectionEnd;\n\n\t\t\tif ( selectionChanged ) {\n\t\t\t\tprevSelectionStart = newSelectionStart;\n\t\t\t\tprevSelectionEnd = newSelectionEnd;\n\t\t\t}\n\n\t\t\tif ( blocksChanged || selectionChanged ) {\n\t\t\t\t// Batch block and selection updates so the entity\n\t\t\t\t// receives both changes atomically.\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tif ( blocksChanged ) {\n\t\t\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\t\t\tblockHistoryMode = newBlockHistoryMode;\n\n\t\t\t\t\t\t// For inner block controllers (clientId is set), restore external IDs\n\t\t\t\t\t\t// before passing blocks to the parent.\n\t\t\t\t\t\tconst blocksForParent = clientId\n\t\t\t\t\t\t\t? restoreExternalIds( blocks, idMappingRef.current )\n\t\t\t\t\t\t\t: blocks;\n\n\t\t\t\t\t\t// Build selection state for the undo level.\n\t\t\t\t\t\tconst selectionInfo = {\n\t\t\t\t\t\t\tselectionStart: newSelectionStart,\n\t\t\t\t\t\t\tselectionEnd: newSelectionEnd,\n\t\t\t\t\t\t\tinitialPosition:\n\t\t\t\t\t\t\t\tgetSelectedBlocksInitialCaretPosition(),\n\t\t\t\t\t\t};\n\t\t\t\t\t\t// Restore external IDs in selection for inner block controllers.\n\t\t\t\t\t\tconst selectionForParent = clientId\n\t\t\t\t\t\t\t? restoreSelectionIds(\n\t\t\t\t\t\t\t\t\tselectionInfo,\n\t\t\t\t\t\t\t\t\tidMappingRef.current\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: selectionInfo;\n\n\t\t\t\t\t\tpendingChangesRef.current.outgoing.push(\n\t\t\t\t\t\t\tblocksForParent\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst updateParent = isPersistent\n\t\t\t\t\t\t\t? onChangeRef.current\n\t\t\t\t\t\t\t: onInputRef.current;\n\t\t\t\t\t\tconst updateOptions = {\n\t\t\t\t\t\t\tselection: selectionForParent,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif ( blockHistoryMode === 'ignore' ) {\n\t\t\t\t\t\t\tupdateOptions.undoIgnore = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tupdateParent( blocksForParent, updateOptions );\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectionChanged &&\n\t\t\t\t\t\t! blocksChanged &&\n\t\t\t\t\t\tnewSelectionStart?.clientId &&\n\t\t\t\t\t\t! isRestoringSelectionRef.current\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Report selection via onChangeSelection.\n\t\t\t\t\t\t// Each useBlockSync only reports if the selected block\n\t\t\t\t\t\t// is within its own scope.\n\t\t\t\t\t\t// Inner block controllers own the block if the internal\n\t\t\t\t\t\t// ID appears in their clone mapping.\n\t\t\t\t\t\t// The root controller owns it if the block is not inside\n\t\t\t\t\t\t// any controlled inner block.\n\t\t\t\t\t\tconst isOurs = clientId\n\t\t\t\t\t\t\t? idMappingRef.current.internalToExternal.has(\n\t\t\t\t\t\t\t\t\tnewSelectionStart.clientId\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: ! getBlockParents(\n\t\t\t\t\t\t\t\t\tnewSelectionStart.clientId\n\t\t\t\t\t\t\t ).some( ( parentId ) =>\n\t\t\t\t\t\t\t\t\tareInnerBlocksControlled( parentId )\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\t\tif ( isOurs ) {\n\t\t\t\t\t\t\tconst selectionInfo = {\n\t\t\t\t\t\t\t\tselectionStart: newSelectionStart,\n\t\t\t\t\t\t\t\tselectionEnd: newSelectionEnd,\n\t\t\t\t\t\t\t\tinitialPosition:\n\t\t\t\t\t\t\t\t\tgetSelectedBlocksInitialCaretPosition(),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tonChangeSelection(\n\t\t\t\t\t\t\t\tclientId\n\t\t\t\t\t\t\t\t\t? restoreSelectionIds(\n\t\t\t\t\t\t\t\t\t\t\tselectionInfo,\n\t\t\t\t\t\t\t\t\t\t\tidMappingRef.current\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: selectionInfo\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\t\t\tpreviousAreBlocksDifferent = areBlocksDifferent;\n\t\t}, blockEditorStore );\n\n\t\treturn () => {\n\t\t\tsubscribedRef.current = false;\n\t\t\tunsubscribe();\n\t\t};\n\t}, [ registry, clientId ] );\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tunsetControlledBlocks();\n\t\t};\n\t}, [] );\n}\n"],
5
- "mappings": ";AAGA,SAAS,YAAY,WAAW,cAAc;AAC9C,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAK3B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,wBAAwB;AAEjC,IAAM,OAAO,MAAM;AAAC;AAapB,SAAS,sBAAuB,OAAO,SAAU;AAChD,QAAM,cAAc,WAAY,KAAM;AAGtC,UAAQ,mBAAmB,IAAK,MAAM,UAAU,YAAY,QAAS;AACrE,UAAQ,mBAAmB,IAAK,YAAY,UAAU,MAAM,QAAS;AAGrE,MAAK,MAAM,aAAa,QAAS;AAChC,gBAAY,cAAc,MAAM,YAAY,IAAK,CAAE,eAAgB;AAClE,YAAM,cAAc,sBAAuB,YAAY,OAAQ;AAG/D,aAAO;AAAA,IACR,CAAE;AAAA,EACH;AAEA,SAAO;AACR;AAUA,SAAS,mBAAoB,QAAQ,SAAU;AAC9C,SAAO,OAAO,IAAK,CAAE,UAAW;AAC/B,UAAM,aAAa,QAAQ,mBAAmB,IAAK,MAAM,QAAS;AAClE,WAAO;AAAA,MACN,GAAG;AAAA;AAAA,MAEH,UAAU,cAAc,MAAM;AAAA,MAC9B,aAAa,mBAAoB,MAAM,aAAa,OAAQ;AAAA,IAC7D;AAAA,EACD,CAAE;AACH;AASA,SAAS,oBAAqB,gBAAgB,SAAU;AACvD,QAAM,EAAE,gBAAgB,cAAc,gBAAgB,IAAI;AAE1D,QAAM,kBAAkB,CAAE,QAAS;AAClC,QAAK,CAAE,KAAK,UAAW;AACtB,aAAO;AAAA,IACR;AACA,UAAM,aAAa,QAAQ,mBAAmB,IAAK,IAAI,QAAS;AAChE,WAAO;AAAA,MACN,GAAG;AAAA,MACH,UAA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AS,CAAE;AAE1B,YAAW,MAAM;AAChB,WAAO,MAAM;AACZ,4BAAsB;AAAA,IACvB;AAAA,EACD,GAAG,CAAC,CAAE;AACP;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useContext, useEffect, useRef } from '@wordpress/element';\nimport { useRegistry } from '@wordpress/data';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { SelectionContext } from './selection-context';\n\nconst noop = () => {};\n\n/**\n * Clones a block and its inner blocks, building a bidirectional mapping\n * between external (original) and internal (cloned) client IDs.\n *\n * This allows the block editor to use unique internal IDs while preserving\n * stable external IDs for features like real-time collaboration.\n *\n * @param {Object} block The block to clone.\n * @param {Object} mapping The mapping object with externalToInternal and internalToExternal Maps.\n * @return {Object} The cloned block with a new clientId.\n */\nfunction cloneBlockWithMapping( block, mapping ) {\n\tconst clonedBlock = cloneBlock( block );\n\n\t// Build bidirectional mapping\n\tmapping.externalToInternal.set( block.clientId, clonedBlock.clientId );\n\tmapping.internalToExternal.set( clonedBlock.clientId, block.clientId );\n\n\t// Recursively map inner blocks\n\tif ( block.innerBlocks?.length ) {\n\t\tclonedBlock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\tconst clonedInner = cloneBlockWithMapping( innerBlock, mapping );\n\t\t\t// The clonedBlock already has cloned inner blocks from cloneBlock(),\n\t\t\t// but we need to use our mapped versions to maintain the mapping.\n\t\t\treturn clonedInner;\n\t\t} );\n\t}\n\n\treturn clonedBlock;\n}\n\n/**\n * Restores external (original) client IDs on blocks before passing them\n * to onChange/onInput callbacks.\n *\n * @param {Object[]} blocks The blocks with internal client IDs.\n * @param {Object} mapping The mapping object with internalToExternal Map.\n * @return {Object[]} Blocks with external client IDs restored.\n */\nfunction restoreExternalIds( blocks, mapping ) {\n\treturn blocks.map( ( block ) => {\n\t\tconst externalId = mapping.internalToExternal.get( block.clientId );\n\t\treturn {\n\t\t\t...block,\n\t\t\t// Use external ID if available, otherwise keep internal ID (for new blocks)\n\t\t\tclientId: externalId ?? block.clientId,\n\t\t\tinnerBlocks: restoreExternalIds( block.innerBlocks, mapping ),\n\t\t};\n\t} );\n}\n\n/**\n * Restores external client IDs in selection state.\n *\n * @param {Object} selectionState The selection state with internal client IDs.\n * @param {Object} mapping The mapping object with internalToExternal Map.\n * @return {Object} Selection state with external client IDs.\n */\nfunction restoreSelectionIds( selectionState, mapping ) {\n\tconst { selectionStart, selectionEnd, initialPosition } = selectionState;\n\n\tconst restoreClientId = ( sel ) => {\n\t\tif ( ! sel?.clientId ) {\n\t\t\treturn sel;\n\t\t}\n\t\tconst externalId = mapping.internalToExternal.get( sel.clientId );\n\t\treturn {\n\t\t\t...sel,\n\t\t\tclientId: externalId ?? sel.clientId,\n\t\t};\n\t};\n\n\treturn {\n\t\tselectionStart: restoreClientId( selectionStart ),\n\t\tselectionEnd: restoreClientId( selectionEnd ),\n\t\tinitialPosition,\n\t};\n}\n\n/**\n * A function to call when the block value has been updated in the block-editor\n * store.\n *\n * @callback onBlockUpdate\n * @param {Object[]} blocks The updated blocks.\n * @param {Object} options The updated block options, such as selectionStart\n * and selectionEnd.\n */\n\n/**\n * useBlockSync is a side effect which handles bidirectional sync between the\n * block-editor store and a controlling data source which provides blocks. This\n * is most commonly used by the BlockEditorProvider to synchronize the contents\n * of the block-editor store with the root entity, like a post.\n *\n * Another example would be the template part block, which provides blocks from\n * a separate entity data source than a root entity. This hook syncs edits to\n * the template part in the block editor back to the entity and vice-versa.\n *\n * Here are some of its basic functions:\n * - Initializes the block-editor store for the given clientID to the blocks\n * given via props.\n * - Adds incoming changes (like undo) to the block-editor store.\n * - Adds outgoing changes (like editing content) to the controlling entity,\n * determining if a change should be considered persistent or not.\n * - Handles edge cases and race conditions which occur in those operations.\n * - Ignores changes which happen to other entities (like nested inner block\n * controllers.\n * - Passes selection state from the block-editor store to the controlling entity.\n *\n * @param {Object} props Props for the block sync hook\n * @param {string} props.clientId The client ID of the inner block controller.\n * If none is passed, then it is assumed to be a\n * root controller rather than an inner block\n * controller.\n * @param {Object[]} props.value The control value for the blocks. This value\n * is used to initialize the block-editor store\n * and for resetting the blocks to incoming\n * changes like undo.\n * @param {onBlockUpdate} props.onChange Function to call when a persistent\n * change has been made in the block-editor blocks\n * for the given clientId. For example, after\n * this function is called, an entity is marked\n * dirty because it has changes to save.\n * @param {onBlockUpdate} props.onInput Function to call when a non-persistent\n * change has been made in the block-editor blocks\n * for the given clientId. When this is called,\n * controlling sources do not become dirty.\n */\nexport default function useBlockSync( {\n\tclientId = null,\n\tvalue: controlledBlocks,\n\tonChange = noop,\n\tonInput = noop,\n} ) {\n\tconst registry = useRegistry();\n\tconst { getSelection, onChangeSelection } = useContext( SelectionContext );\n\n\tconst {\n\t\tresetBlocks,\n\t\tresetSelection,\n\t\treplaceInnerBlocks,\n\t\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst { getBlockName, getBlocks, getSelectionStart, getSelectionEnd } =\n\t\tregistry.select( blockEditorStore );\n\n\tconst pendingChangesRef = useRef( { incoming: null, outgoing: [] } );\n\tconst subscribedRef = useRef( false );\n\n\t// Mapping between external (original) and internal (cloned) client IDs.\n\t// This allows stable external IDs while using unique internal IDs.\n\tconst idMappingRef = useRef( {\n\t\texternalToInternal: new Map(),\n\t\tinternalToExternal: new Map(),\n\t} );\n\n\t// Tracks which context selection has already been applied, to avoid\n\t// duplicate restoration.\n\tconst appliedSelectionRef = useRef( null );\n\t// Flag to prevent the subscription from re-reporting a selection\n\t// change that was just restored from context (which would loop).\n\tconst isRestoringSelectionRef = useRef( false );\n\n\t// Restores selection from the SelectionContext using the current\n\t// idMapping. Called after blocks are (re-)cloned so that the\n\t// mapping is guaranteed to be fresh.\n\tconst restoreSelection = () => {\n\t\tconst selection = getSelection();\n\t\tif (\n\t\t\t! selection?.selectionStart?.clientId ||\n\t\t\tselection === appliedSelectionRef.current\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst startClientId = selection.selectionStart.clientId;\n\n\t\t// Check if this selection belongs to this controller.\n\t\t// Inner block controllers (clientId is set) own the block if\n\t\t// the external ID appears in their clone mapping.\n\t\t// The root controller (no clientId) owns it if the block\n\t\t// exists directly in the store.\n\t\tconst isOurs = clientId\n\t\t\t? idMappingRef.current.externalToInternal.has( startClientId )\n\t\t\t: !! getBlockName( startClientId );\n\n\t\tif ( isOurs ) {\n\t\t\tappliedSelectionRef.current = selection;\n\t\t\t// Inner block controllers need to convert external→internal\n\t\t\t// IDs via the clone mapping; the root controller uses\n\t\t\t// external IDs directly (no mapping needed).\n\t\t\tconst convert = ( sel ) => {\n\t\t\t\tif ( ! sel?.clientId || ! clientId ) {\n\t\t\t\t\treturn sel;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\t...sel,\n\t\t\t\t\tclientId:\n\t\t\t\t\t\tidMappingRef.current.externalToInternal.get(\n\t\t\t\t\t\t\tsel.clientId\n\t\t\t\t\t\t) ?? sel.clientId,\n\t\t\t\t};\n\t\t\t};\n\t\t\t// Flag prevents the subscription from re-reporting this\n\t\t\t// selection change back to the entity (which would cause\n\t\t\t// an infinite update loop).\n\t\t\tisRestoringSelectionRef.current = true;\n\t\t\tresetSelection(\n\t\t\t\tconvert( selection.selectionStart ),\n\t\t\t\tconvert( selection.selectionEnd ),\n\t\t\t\tselection.initialPosition\n\t\t\t);\n\t\t\tisRestoringSelectionRef.current = false;\n\t\t}\n\t};\n\n\tconst setControlledBlocks = () => {\n\t\tif ( ! controlledBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't need to persist this change because we only replace\n\t\t// controlled inner blocks when the change was caused by an entity,\n\t\t// and so it would already be persisted.\n\t\tif ( clientId ) {\n\t\t\t// Batch so that the controlled flag and block replacement\n\t\t\t// are applied atomically — subscribers see a consistent state.\n\t\t\tregistry.batch( () => {\n\t\t\t\t// Clear previous mappings and build new ones during cloning.\n\t\t\t\t// This ensures the mapping stays in sync with the current blocks.\n\t\t\t\tidMappingRef.current.externalToInternal.clear();\n\t\t\t\tidMappingRef.current.internalToExternal.clear();\n\n\t\t\t\tconst storeBlocks = controlledBlocks.map( ( block ) =>\n\t\t\t\t\tcloneBlockWithMapping( block, idMappingRef.current )\n\t\t\t\t);\n\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetHasControlledInnerBlocks( clientId, true );\n\n\t\t\t\tif ( subscribedRef.current ) {\n\t\t\t\t\tpendingChangesRef.current.incoming = storeBlocks;\n\t\t\t\t}\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceInnerBlocks( clientId, storeBlocks );\n\n\t\t\t\t// Invalidate the applied-selection ref so that\n\t\t\t\t// restoreSelection() at the end of the\n\t\t\t\t// controlledBlocks effect re-applies with the\n\t\t\t\t// freshly-built mapping (new internal IDs).\n\t\t\t\tappliedSelectionRef.current = null;\n\t\t\t} );\n\t\t} else {\n\t\t\tif ( subscribedRef.current ) {\n\t\t\t\tpendingChangesRef.current.incoming = controlledBlocks;\n\t\t\t}\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tresetBlocks( controlledBlocks );\n\t\t}\n\t};\n\n\t// Clean up the changes made by setControlledBlocks() when the component\n\t// containing useBlockSync() unmounts.\n\tconst unsetControlledBlocks = () => {\n\t\tif ( clientId ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetHasControlledInnerBlocks( clientId, false );\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\treplaceInnerBlocks( clientId, [] );\n\t\t} else {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tresetBlocks( [] );\n\t\t}\n\t};\n\n\t// Add a subscription to the block-editor registry to detect when changes\n\t// have been made. This lets us inform the data source of changes. This\n\t// is an effect so that the subscriber can run synchronously without\n\t// waiting for React renders for changes.\n\tconst onInputRef = useRef( onInput );\n\tconst onChangeRef = useRef( onChange );\n\tuseEffect( () => {\n\t\tonInputRef.current = onInput;\n\t\tonChangeRef.current = onChange;\n\t}, [ onInput, onChange ] );\n\n\t// Determine if blocks need to be reset when they change.\n\t// Also restores selection from context after blocks are set.\n\tuseEffect( () => {\n\t\tconst isOutgoing =\n\t\t\tpendingChangesRef.current.outgoing.includes( controlledBlocks );\n\t\tconst storeMatch = getBlocks( clientId ) === controlledBlocks;\n\n\t\tif ( isOutgoing ) {\n\t\t\t// Skip block reset if the value matches expected outbound sync\n\t\t\t// triggered by this component by a preceding change detection.\n\t\t\t// Only skip if the value matches expectation, since a reset should\n\t\t\t// still occur if the value is modified (not equal by reference),\n\t\t\t// to allow that the consumer may apply modifications to reflect\n\t\t\t// back on the editor.\n\t\t\tif (\n\t\t\t\tpendingChangesRef.current.outgoing[\n\t\t\t\t\tpendingChangesRef.current.outgoing.length - 1\n\t\t\t\t] === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChangesRef.current.outgoing = [];\n\t\t\t}\n\t\t} else if ( ! storeMatch ) {\n\t\t\t// Reset changing value in all other cases than the sync described\n\t\t\t// above. Since this can be reached in an update following an out-\n\t\t\t// bound sync, unset the outbound value to avoid considering it in\n\t\t\t// subsequent renders.\n\t\t\tpendingChangesRef.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\n\t\t\t// Restore selection from context if it targets our scope.\n\t\t\t// Only done when blocks were reset from an external source\n\t\t\t// (undo/redo, entity navigation) — NOT for outgoing changes,\n\t\t\t// because dispatching resetSelection between keystrokes breaks\n\t\t\t// the isUpdatingSameBlockAttribute chain and creates per-\n\t\t\t// character undo levels.\n\t\t\trestoreSelection();\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tuseEffect( () => {\n\t\tconst {\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t\tisLastBlockChangePersistent,\n\t\t\t__unstableGetLastBlockChangeHistoryMode,\n\t\t\t__unstableIsLastBlockChangeIgnored,\n\t\t\tareInnerBlocksControlled,\n\t\t\tgetBlockParents,\n\t\t} = registry.select( blockEditorStore );\n\n\t\tlet blocks = getBlocks( clientId );\n\t\tlet isPersistent = isLastBlockChangePersistent();\n\t\tlet blockHistoryMode = __unstableGetLastBlockChangeHistoryMode();\n\t\tlet previousAreBlocksDifferent = false;\n\t\tlet prevSelectionStart = getSelectionStart();\n\t\tlet prevSelectionEnd = getSelectionEnd();\n\n\t\tsubscribedRef.current = true;\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Sometimes, when changing block lists, lingering subscriptions\n\t\t\t// might trigger before they are cleaned up. If the block for which\n\t\t\t// the subscription runs is no longer in the store, this would clear\n\t\t\t// its parent entity's block list. To avoid this, we bail out if\n\t\t\t// the subscription is triggering for a block (`clientId !== null`)\n\t\t\t// and its block name can't be found because it's not on the list.\n\t\t\t// (`getBlockName( clientId ) === null`).\n\t\t\tif ( clientId !== null && getBlockName( clientId ) === null ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newIsPersistent = isLastBlockChangePersistent();\n\t\t\tconst newBlockHistoryMode =\n\t\t\t\t__unstableGetLastBlockChangeHistoryMode();\n\t\t\tconst newBlocks = getBlocks( clientId );\n\t\t\tconst areBlocksDifferent = newBlocks !== blocks;\n\t\t\tblocks = newBlocks;\n\t\t\tif (\n\t\t\t\tareBlocksDifferent &&\n\t\t\t\t( pendingChangesRef.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChangesRef.current.incoming = null;\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\tblockHistoryMode = newBlockHistoryMode;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Since we often dispatch an action to mark the previous action as\n\t\t\t// persistent, we need to make sure that the blocks changed on the\n\t\t\t// previous action before committing the change.\n\t\t\tconst didPersistenceChange =\n\t\t\t\tpreviousAreBlocksDifferent &&\n\t\t\t\t! areBlocksDifferent &&\n\t\t\t\tnewIsPersistent &&\n\t\t\t\t! isPersistent;\n\n\t\t\tconst blocksChanged = areBlocksDifferent || didPersistenceChange;\n\n\t\t\t// Check if selection changed.\n\t\t\tconst newSelectionStart = getSelectionStart();\n\t\t\tconst newSelectionEnd = getSelectionEnd();\n\t\t\tconst selectionChanged =\n\t\t\t\tnewSelectionStart !== prevSelectionStart ||\n\t\t\t\tnewSelectionEnd !== prevSelectionEnd;\n\n\t\t\tif ( selectionChanged ) {\n\t\t\t\tprevSelectionStart = newSelectionStart;\n\t\t\t\tprevSelectionEnd = newSelectionEnd;\n\t\t\t}\n\n\t\t\tif ( blocksChanged || selectionChanged ) {\n\t\t\t\t// Batch block and selection updates so the entity\n\t\t\t\t// receives both changes atomically.\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tif ( blocksChanged ) {\n\t\t\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\t\t\tblockHistoryMode = newBlockHistoryMode;\n\n\t\t\t\t\t\t// For inner block controllers (clientId is set), restore external IDs\n\t\t\t\t\t\t// before passing blocks to the parent.\n\t\t\t\t\t\tconst blocksForParent = clientId\n\t\t\t\t\t\t\t? restoreExternalIds( blocks, idMappingRef.current )\n\t\t\t\t\t\t\t: blocks;\n\n\t\t\t\t\t\t// Build selection state for the undo level.\n\t\t\t\t\t\tconst selectionInfo = {\n\t\t\t\t\t\t\tselectionStart: newSelectionStart,\n\t\t\t\t\t\t\tselectionEnd: newSelectionEnd,\n\t\t\t\t\t\t\tinitialPosition:\n\t\t\t\t\t\t\t\tgetSelectedBlocksInitialCaretPosition(),\n\t\t\t\t\t\t};\n\t\t\t\t\t\t// Restore external IDs in selection for inner block controllers.\n\t\t\t\t\t\tconst selectionForParent = clientId\n\t\t\t\t\t\t\t? restoreSelectionIds(\n\t\t\t\t\t\t\t\t\tselectionInfo,\n\t\t\t\t\t\t\t\t\tidMappingRef.current\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: selectionInfo;\n\n\t\t\t\t\t\tpendingChangesRef.current.outgoing.push(\n\t\t\t\t\t\t\tblocksForParent\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst updateParent = isPersistent\n\t\t\t\t\t\t\t? onChangeRef.current\n\t\t\t\t\t\t\t: onInputRef.current;\n\t\t\t\t\t\tconst updateOptions = {\n\t\t\t\t\t\t\tselection: selectionForParent,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif ( blockHistoryMode === 'ignore' ) {\n\t\t\t\t\t\t\tupdateOptions.undoIgnore = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tupdateParent( blocksForParent, updateOptions );\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectionChanged &&\n\t\t\t\t\t\t! blocksChanged &&\n\t\t\t\t\t\tnewSelectionStart?.clientId &&\n\t\t\t\t\t\t! isRestoringSelectionRef.current\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Report selection via onChangeSelection.\n\t\t\t\t\t\t// Each useBlockSync only reports if the selected block\n\t\t\t\t\t\t// is within its own scope.\n\t\t\t\t\t\t// Inner block controllers own the block if the internal\n\t\t\t\t\t\t// ID appears in their clone mapping.\n\t\t\t\t\t\t// The root controller owns it if the block is not inside\n\t\t\t\t\t\t// any controlled inner block.\n\t\t\t\t\t\tconst isOurs = clientId\n\t\t\t\t\t\t\t? idMappingRef.current.internalToExternal.has(\n\t\t\t\t\t\t\t\t\tnewSelectionStart.clientId\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: ! getBlockParents(\n\t\t\t\t\t\t\t\t\tnewSelectionStart.clientId\n\t\t\t\t\t\t\t ).some( ( parentId ) =>\n\t\t\t\t\t\t\t\t\tareInnerBlocksControlled( parentId )\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\t\tif ( isOurs ) {\n\t\t\t\t\t\t\tconst selectionInfo = {\n\t\t\t\t\t\t\t\tselectionStart: newSelectionStart,\n\t\t\t\t\t\t\t\tselectionEnd: newSelectionEnd,\n\t\t\t\t\t\t\t\tinitialPosition:\n\t\t\t\t\t\t\t\t\tgetSelectedBlocksInitialCaretPosition(),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tonChangeSelection(\n\t\t\t\t\t\t\t\tclientId\n\t\t\t\t\t\t\t\t\t? restoreSelectionIds(\n\t\t\t\t\t\t\t\t\t\t\tselectionInfo,\n\t\t\t\t\t\t\t\t\t\t\tidMappingRef.current\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: selectionInfo\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\t\t\tpreviousAreBlocksDifferent = areBlocksDifferent;\n\t\t}, blockEditorStore );\n\n\t\treturn () => {\n\t\t\tsubscribedRef.current = false;\n\t\t\tunsubscribe();\n\t\t};\n\t}, [ registry, clientId ] );\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tunsetControlledBlocks();\n\t\t};\n\t}, [] );\n}\n"],
5
+ "mappings": ";AAGA,SAAS,YAAY,WAAW,cAAc;AAC9C,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAK3B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,wBAAwB;AAEjC,IAAM,OAAO,MAAM;AAAC;AAapB,SAAS,sBAAuB,OAAO,SAAU;AAChD,QAAM,cAAc,WAAY,KAAM;AAGtC,UAAQ,mBAAmB,IAAK,MAAM,UAAU,YAAY,QAAS;AACrE,UAAQ,mBAAmB,IAAK,YAAY,UAAU,MAAM,QAAS;AAGrE,MAAK,MAAM,aAAa,QAAS;AAChC,gBAAY,cAAc,MAAM,YAAY,IAAK,CAAE,eAAgB;AAClE,YAAM,cAAc,sBAAuB,YAAY,OAAQ;AAG/D,aAAO;AAAA,IACR,CAAE;AAAA,EACH;AAEA,SAAO;AACR;AAUA,SAAS,mBAAoB,QAAQ,SAAU;AAC9C,SAAO,OAAO,IAAK,CAAE,UAAW;AAC/B,UAAM,aAAa,QAAQ,mBA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kBAAkB;AAAA,YAClB,EAAE;AAAA,cAAM,CAAE,aACV,yBAA0B,QAAS;AAAA,YACnC;AAEH,gBAAK,QAAS;AACb,oBAAM,gBAAgB;AAAA,gBACrB,gBAAgB;AAAA,gBAChB,cAAc;AAAA,gBACd,iBACC,sCAAsC;AAAA,cACxC;AACA;AAAA,gBACC,WACG;AAAA,kBACA;AAAA,kBACA,aAAa;AAAA,gBACb,IACA;AAAA,cACJ;AAAA,YACD;AAAA,UACD;AAAA,QACD,CAAE;AAAA,MACH;AACA,mCAA6B;AAAA,IAC9B,GAAG,gBAAiB;AAEpB,WAAO,MAAM;AACZ,oBAAc,UAAU;AACxB,kBAAY;AAAA,IACb;AAAA,EACD,GAAG,CAAE,UAAU,QAAS,CAAE;AAE1B,YAAW,MAAM;AAChB,WAAO,MAAM;AACZ,4BAAsB;AAAA,IACvB;AAAA,EACD,GAAG,CAAC,CAAE;AACP;",
6
6
  "names": []
7
7
  }
@@ -5,7 +5,7 @@ import { privateApis as composePrivateApis } from "@wordpress/compose";
5
5
  import { store as blockEditorStore } from "../../../store/index.mjs";
6
6
  import { unlock } from "../../../lock-unlock.mjs";
7
7
  var { subscribeDelegatedListener } = unlock(composePrivateApis);
8
- var wrapSelectionSettings = ["`", '"', "'", "\u201C\u201D", "\u2018\u2019"];
8
+ var wrapSelectionSettings = ["`", '"', "'", "“”", "‘’"];
9
9
  var before_input_rules_default = (props) => (element) => {
10
10
  function onInput(event) {
11
11
  const { inputType, data } = event;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/rich-text/event-listeners/before-input-rules.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { insert, isCollapsed } from '@wordpress/rich-text';\nimport { applyFilters } from '@wordpress/hooks';\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\n/**\n * When typing over a selection, the selection will we wrapped by a matching\n * character pair. The second character is optional, it defaults to the first\n * character.\n *\n * @type {string[]} Array of character pairs.\n */\nconst wrapSelectionSettings = [ '`', '\"', \"'\", '\u201C\u201D', '\u2018\u2019' ];\n\nexport default ( props ) => ( element ) => {\n\tfunction onInput( event ) {\n\t\tconst { inputType, data } = event;\n\t\tconst { value, onChange, registry } = props.current;\n\n\t\t// Only run the rules when inserting text.\n\t\tif ( inputType !== 'insertText' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isCollapsed( value ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst pair = applyFilters(\n\t\t\t'blockEditor.wrapSelectionSettings',\n\t\t\twrapSelectionSettings\n\t\t).find(\n\t\t\t( [ startChar, endChar ] ) => startChar === data || endChar === data\n\t\t);\n\n\t\tif ( ! pair ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ startChar, endChar = startChar ] = pair;\n\t\tconst start = value.start;\n\t\tconst end = value.end + startChar.length;\n\n\t\tlet newValue = insert( value, startChar, start, start );\n\t\tnewValue = insert( newValue, endChar, end, end );\n\n\t\tconst {\n\t\t\t__unstableMarkLastChangeAsPersistent,\n\t\t\t__unstableMarkAutomaticChange,\n\t\t} = registry.dispatch( blockEditorStore );\n\n\t\t__unstableMarkLastChangeAsPersistent();\n\t\tonChange( newValue );\n\t\t__unstableMarkAutomaticChange();\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tinit.data = endChar;\n\n\t\tconst { ownerDocument } = element;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst newEvent = new defaultView.InputEvent( 'input', init );\n\n\t\t// Dispatch an `input` event with the new data. This will trigger the\n\t\t// input rules.\n\t\t// Postpone the `input` to the next event loop tick so that the dispatch\n\t\t// doesn't happen synchronously in the middle of `beforeinput` dispatch.\n\t\t// This is closer to how native `input` event would be timed, and also\n\t\t// makes sure that the `input` event is dispatched only after the `onChange`\n\t\t// call few lines above has fully updated the data store state and rerendered\n\t\t// all affected components.\n\t\twindow.queueMicrotask( () => {\n\t\t\tevent.target.dispatchEvent( newEvent );\n\t\t} );\n\t\tevent.preventDefault();\n\t}\n\n\treturn subscribeDelegatedListener( element, 'beforeinput', onInput, true );\n};\n"],
5
- "mappings": ";AAGA,SAAS,QAAQ,mBAAmB;AACpC,SAAS,oBAAoB;AAC7B,SAAS,eAAe,0BAA0B;AAKlD,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AAEvB,IAAM,EAAE,2BAA2B,IAAI,OAAQ,kBAAmB;AASlE,IAAM,wBAAwB,CAAE,KAAK,KAAK,KAAK,gBAAM,cAAK;AAE1D,IAAO,6BAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,QAAS,OAAQ;AACzB,UAAM,EAAE,WAAW,KAAK,IAAI;AAC5B,UAAM,EAAE,OAAO,UAAU,SAAS,IAAI,MAAM;AAG5C,QAAK,cAAc,cAAe;AACjC;AAAA,IACD;AAEA,QAAK,YAAa,KAAM,GAAI;AAC3B;AAAA,IACD;AAEA,UAAM,OAAO;AAAA,MACZ;AAAA,MACA;AAAA,IACD,EAAE;AAAA,MACD,CAAE,CAAEA,YAAWC,QAAQ,MAAOD,eAAc,QAAQC,aAAY;AAAA,IACjE;AAEA,QAAK,CAAE,MAAO;AACb;AAAA,IACD;AAEA,UAAM,CAAE,WAAW,UAAU,SAAU,IAAI;AAC3C,UAAM,QAAQ,MAAM;AACpB,UAAM,MAAM,MAAM,MAAM,UAAU;AAElC,QAAI,WAAW,OAAQ,OAAO,WAAW,OAAO,KAAM;AACtD,eAAW,OAAQ,UAAU,SAAS,KAAK,GAAI;AAE/C,UAAM;AAAA,MACL;AAAA,MACA;AAAA,IACD,IAAI,SAAS,SAAU,gBAAiB;AAExC,yCAAqC;AACrC,aAAU,QAAS;AACnB,kCAA8B;AAE9B,UAAM,OAAO,CAAC;AAEd,eAAY,OAAO,OAAQ;AAC1B,WAAM,GAAI,IAAI,MAAO,GAAI;AAAA,IAC1B;AAEA,SAAK,OAAO;AAEZ,UAAM,EAAE,cAAc,IAAI;AAC1B,UAAM,EAAE,YAAY,IAAI;AACxB,UAAM,WAAW,IAAI,YAAY,WAAY,SAAS,IAAK;AAU3D,WAAO,eAAgB,MAAM;AAC5B,YAAM,OAAO,cAAe,QAAS;AAAA,IACtC,CAAE;AACF,UAAM,eAAe;AAAA,EACtB;AAEA,SAAO,2BAA4B,SAAS,eAAe,SAAS,IAAK;AAC1E;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { insert, isCollapsed } from '@wordpress/rich-text';\nimport { applyFilters } from '@wordpress/hooks';\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\n/**\n * When typing over a selection, the selection will we wrapped by a matching\n * character pair. The second character is optional, it defaults to the first\n * character.\n *\n * @type {string[]} Array of character pairs.\n */\nconst wrapSelectionSettings = [ '`', '\"', \"'\", '“”', '‘’' ];\n\nexport default ( props ) => ( element ) => {\n\tfunction onInput( event ) {\n\t\tconst { inputType, data } = event;\n\t\tconst { value, onChange, registry } = props.current;\n\n\t\t// Only run the rules when inserting text.\n\t\tif ( inputType !== 'insertText' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isCollapsed( value ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst pair = applyFilters(\n\t\t\t'blockEditor.wrapSelectionSettings',\n\t\t\twrapSelectionSettings\n\t\t).find(\n\t\t\t( [ startChar, endChar ] ) => startChar === data || endChar === data\n\t\t);\n\n\t\tif ( ! pair ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ startChar, endChar = startChar ] = pair;\n\t\tconst start = value.start;\n\t\tconst end = value.end + startChar.length;\n\n\t\tlet newValue = insert( value, startChar, start, start );\n\t\tnewValue = insert( newValue, endChar, end, end );\n\n\t\tconst {\n\t\t\t__unstableMarkLastChangeAsPersistent,\n\t\t\t__unstableMarkAutomaticChange,\n\t\t} = registry.dispatch( blockEditorStore );\n\n\t\t__unstableMarkLastChangeAsPersistent();\n\t\tonChange( newValue );\n\t\t__unstableMarkAutomaticChange();\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tinit.data = endChar;\n\n\t\tconst { ownerDocument } = element;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst newEvent = new defaultView.InputEvent( 'input', init );\n\n\t\t// Dispatch an `input` event with the new data. This will trigger the\n\t\t// input rules.\n\t\t// Postpone the `input` to the next event loop tick so that the dispatch\n\t\t// doesn't happen synchronously in the middle of `beforeinput` dispatch.\n\t\t// This is closer to how native `input` event would be timed, and also\n\t\t// makes sure that the `input` event is dispatched only after the `onChange`\n\t\t// call few lines above has fully updated the data store state and rerendered\n\t\t// all affected components.\n\t\twindow.queueMicrotask( () => {\n\t\t\tevent.target.dispatchEvent( newEvent );\n\t\t} );\n\t\tevent.preventDefault();\n\t}\n\n\treturn subscribeDelegatedListener( element, 'beforeinput', onInput, true );\n};\n"],
5
+ "mappings": ";AAGA,SAAS,QAAQ,mBAAmB;AACpC,SAAS,oBAAoB;AAC7B,SAAS,eAAe,0BAA0B;AAKlD,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AAEvB,IAAM,EAAE,2BAA2B,IAAI,OAAQ,kBAAmB;AASlE,IAAM,wBAAwB,CAAE,KAAK,KAAK,KAAK,MAAM,IAAK;AAE1D,IAAO,6BAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,QAAS,OAAQ;AACzB,UAAM,EAAE,WAAW,KAAK,IAAI;AAC5B,UAAM,EAAE,OAAO,UAAU,SAAS,IAAI,MAAM;AAG5C,QAAK,cAAc,cAAe;AACjC;AAAA,IACD;AAEA,QAAK,YAAa,KAAM,GAAI;AAC3B;AAAA,IACD;AAEA,UAAM,OAAO;AAAA,MACZ;AAAA,MACA;AAAA,IACD,EAAE;AAAA,MACD,CAAE,CAAEA,YAAWC,QAAQ,MAAOD,eAAc,QAAQC,aAAY;AAAA,IACjE;AAEA,QAAK,CAAE,MAAO;AACb;AAAA,IACD;AAEA,UAAM,CAAE,WAAW,UAAU,SAAU,IAAI;AAC3C,UAAM,QAAQ,MAAM;AACpB,UAAM,MAAM,MAAM,MAAM,UAAU;AAElC,QAAI,WAAW,OAAQ,OAAO,WAAW,OAAO,KAAM;AACtD,eAAW,OAAQ,UAAU,SAAS,KAAK,GAAI;AAE/C,UAAM;AAAA,MACL;AAAA,MACA;AAAA,IACD,IAAI,SAAS,SAAU,gBAAiB;AAExC,yCAAqC;AACrC,aAAU,QAAS;AACnB,kCAA8B;AAE9B,UAAM,OAAO,CAAC;AAEd,eAAY,OAAO,OAAQ;AAC1B,WAAM,GAAI,IAAI,MAAO,GAAI;AAAA,IAC1B;AAEA,SAAK,OAAO;AAEZ,UAAM,EAAE,cAAc,IAAI;AAC1B,UAAM,EAAE,YAAY,IAAI;AACxB,UAAM,WAAW,IAAI,YAAY,WAAY,SAAS,IAAK;AAU3D,WAAO,eAAgB,MAAM;AAC5B,YAAM,OAAO,cAAe,QAAS;AAAA,IACtC,CAAE;AACF,UAAM,eAAe;AAAA,EACtB;AAEA,SAAO,2BAA4B,SAAS,eAAe,SAAS,IAAK;AAC1E;",
6
6
  "names": ["startChar", "endChar"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/rich-text/event-listeners/paste-handler.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { pasteHandler } from '@wordpress/blocks';\nimport { isEmpty, insert, create } from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { addActiveFormats } from '../utils';\nimport { getPasteEventData } from '../../../utils/pasting';\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\nexport default ( props ) => ( element ) => {\n\tfunction _onPaste( event ) {\n\t\tconst {\n\t\t\tdisableFormats,\n\t\t\tonChange,\n\t\t\tvalue,\n\t\t\tformatTypes,\n\t\t\ttagName,\n\t\t\tonReplace,\n\t\t\t__unstableEmbedURLOnPaste,\n\t\t\tpreserveWhiteSpace,\n\t\t\tpastePlainText,\n\t\t\tregistry,\n\t\t} = props.current;\n\n\t\t// The event listener is attached to the window, so we need to check if\n\t\t// the target is the element or inside the element.\n\t\tif ( ! element.contains( event.target ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { plainText, html } = getPasteEventData( event );\n\n\t\tevent.preventDefault();\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\t// `pasteHandler` also logs this, but we're not using `pasteHandler` in\n\t\t// every case.\n\t\twindow.console.log( 'Received HTML (RichText):\\n\\n', html );\n\t\twindow.console.log( 'Received plain text (RichText):\\n\\n', plainText );\n\n\t\tif ( disableFormats ) {\n\t\t\tonChange( insert( value, plainText ) );\n\t\t\treturn;\n\t\t}\n\n\t\tconst isInternal =\n\t\t\tevent.clipboardData.getData( 'rich-text' ) === 'true';\n\n\t\tfunction pasteInline( content ) {\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumulator, { __unstablePasteRule } ) => {\n\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\tif ( __unstablePasteRule && accumulator === value ) {\n\t\t\t\t\t\taccumulator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\t\t\tif ( transformed !== value ) {\n\t\t\t\tonChange( transformed );\n\t\t\t} else {\n\t\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t}\n\t\t}\n\n\t\t// If the data comes from a rich text instance, we can directly use it\n\t\t// without filtering the data. The filters are only meant for externally\n\t\t// pasted content and remove inline styles.\n\t\tif ( isInternal ) {\n\t\t\tpasteInline( html );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( pastePlainText ) {\n\t\t\tonChange( insert( value, create( { text: plainText } ) ) );\n\t\t\treturn;\n\t\t}\n\n\t\tlet mode = 'INLINE';\n\n\t\tconst trimmedPlainText = plainText.trim();\n\n\t\tif (\n\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\tisEmpty( value ) &&\n\t\t\tisURL( trimmedPlainText ) &&\n\t\t\t// For the link pasting feature, allow only http(s) protocols.\n\t\t\t/^https?:/.test( trimmedPlainText )\n\t\t) {\n\t\t\tmode = 'BLOCKS';\n\t\t}\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode,\n\t\t\ttagName,\n\t\t\tpreserveWhiteSpace,\n\t\t} );\n\n\t\tif ( typeof content === 'string' ) {\n\t\t\tpasteInline( content );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! content.length || ! onReplace || ! isEmpty( value ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Record an intermediate paragraph-with-URL state so a single undo\n\t\t// after the URL \u2192 block transformation restores the pasted link.\n\t\tif ( mode === 'BLOCKS' ) {\n\t\t\tpasteInline( html );\n\t\t\tregistry\n\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\t}\n\n\t\tonReplace( content, content.length - 1, -1 );\n\t}\n\n\tconst { defaultView } = element.ownerDocument;\n\n\t// Attach the listener to the window so parent elements have the chance to\n\t// prevent the default behavior.\n\treturn subscribeDelegatedListener( defaultView, 'paste', _onPaste );\n};\n"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { pasteHandler } from '@wordpress/blocks';\nimport { isEmpty, insert, create } from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { addActiveFormats } from '../utils';\nimport { getPasteEventData } from '../../../utils/pasting';\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\nexport default ( props ) => ( element ) => {\n\tfunction _onPaste( event ) {\n\t\tconst {\n\t\t\tdisableFormats,\n\t\t\tonChange,\n\t\t\tvalue,\n\t\t\tformatTypes,\n\t\t\ttagName,\n\t\t\tonReplace,\n\t\t\t__unstableEmbedURLOnPaste,\n\t\t\tpreserveWhiteSpace,\n\t\t\tpastePlainText,\n\t\t\tregistry,\n\t\t} = props.current;\n\n\t\t// The event listener is attached to the window, so we need to check if\n\t\t// the target is the element or inside the element.\n\t\tif ( ! element.contains( event.target ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { plainText, html } = getPasteEventData( event );\n\n\t\tevent.preventDefault();\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\t// `pasteHandler` also logs this, but we're not using `pasteHandler` in\n\t\t// every case.\n\t\twindow.console.log( 'Received HTML (RichText):\\n\\n', html );\n\t\twindow.console.log( 'Received plain text (RichText):\\n\\n', plainText );\n\n\t\tif ( disableFormats ) {\n\t\t\tonChange( insert( value, plainText ) );\n\t\t\treturn;\n\t\t}\n\n\t\tconst isInternal =\n\t\t\tevent.clipboardData.getData( 'rich-text' ) === 'true';\n\n\t\tfunction pasteInline( content ) {\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumulator, { __unstablePasteRule } ) => {\n\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\tif ( __unstablePasteRule && accumulator === value ) {\n\t\t\t\t\t\taccumulator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\t\t\tif ( transformed !== value ) {\n\t\t\t\tonChange( transformed );\n\t\t\t} else {\n\t\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t}\n\t\t}\n\n\t\t// If the data comes from a rich text instance, we can directly use it\n\t\t// without filtering the data. The filters are only meant for externally\n\t\t// pasted content and remove inline styles.\n\t\tif ( isInternal ) {\n\t\t\tpasteInline( html );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( pastePlainText ) {\n\t\t\tonChange( insert( value, create( { text: plainText } ) ) );\n\t\t\treturn;\n\t\t}\n\n\t\tlet mode = 'INLINE';\n\n\t\tconst trimmedPlainText = plainText.trim();\n\n\t\tif (\n\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\tisEmpty( value ) &&\n\t\t\tisURL( trimmedPlainText ) &&\n\t\t\t// For the link pasting feature, allow only http(s) protocols.\n\t\t\t/^https?:/.test( trimmedPlainText )\n\t\t) {\n\t\t\tmode = 'BLOCKS';\n\t\t}\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode,\n\t\t\ttagName,\n\t\t\tpreserveWhiteSpace,\n\t\t} );\n\n\t\tif ( typeof content === 'string' ) {\n\t\t\tpasteInline( content );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! content.length || ! onReplace || ! isEmpty( value ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Record an intermediate paragraph-with-URL state so a single undo\n\t\t// after the URL block transformation restores the pasted link.\n\t\tif ( mode === 'BLOCKS' ) {\n\t\t\tpasteInline( html );\n\t\t\tregistry\n\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\t}\n\n\t\tonReplace( content, content.length - 1, -1 );\n\t}\n\n\tconst { defaultView } = element.ownerDocument;\n\n\t// Attach the listener to the window so parent elements have the chance to\n\t// prevent the default behavior.\n\treturn subscribeDelegatedListener( defaultView, 'paste', _onPaste );\n};\n"],
5
5
  "mappings": ";AAGA,SAAS,oBAAoB;AAC7B,SAAS,SAAS,QAAQ,cAAc;AACxC,SAAS,aAAa;AACtB,SAAS,eAAe,0BAA0B;AAKlD,SAAS,SAAS,wBAAwB;AAC1C,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,cAAc;AAEvB,IAAM,EAAE,2BAA2B,IAAI,OAAQ,kBAAmB;AAIlE,IAAO,wBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,SAAU,OAAQ;AAC1B,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,IAAI,MAAM;AAIV,QAAK,CAAE,QAAQ,SAAU,MAAM,MAAO,GAAI;AACzC;AAAA,IACD;AAEA,QAAK,MAAM,kBAAmB;AAC7B;AAAA,IACD;AAEA,UAAM,EAAE,WAAW,KAAK,IAAI,kBAAmB,KAAM;AAErD,UAAM,eAAe;AAKrB,WAAO,QAAQ,IAAK,iCAAiC,IAAK;AAC1D,WAAO,QAAQ,IAAK,uCAAuC,SAAU;AAErE,QAAK,gBAAiB;AACrB,eAAU,OAAQ,OAAO,SAAU,CAAE;AACrC;AAAA,IACD;AAEA,UAAM,aACL,MAAM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AAM,EAAE,YAAY,IAAI,QAAQ;AAIhC,SAAO,2BAA4B,aAAa,SAAS,QAAS;AACnE;",
6
6
  "names": ["content"]
7
7
  }
@@ -2,7 +2,7 @@
2
2
  import { insert } from "@wordpress/rich-text";
3
3
  function preventEventDiscovery(value) {
4
4
  const searchText = "tales of gutenberg";
5
- const addText = " \u{1F421}\u{1F422}\u{1F980}\u{1F424}\u{1F98B}\u{1F418}\u{1F427}\u{1F439}\u{1F981}\u{1F984}\u{1F98D}\u{1F43C}\u{1F43F}\u{1F383}\u{1F434}\u{1F41D}\u{1F406}\u{1F995}\u{1F994}\u{1F331}\u{1F347}\u03C0\u{1F34C}\u{1F409}\u{1F4A7}\u{1F968}\u{1F30C}\u{1F342}\u{1F360}\u{1F966}\u{1F95A}\u{1F95D}\u{1F39F}\u{1F965}\u{1F952}\u{1F6F5}\u{1F956}\u{1F352}\u{1F36F}\u{1F3BE}\u{1F3B2}\u{1F43A}\u{1F41A}\u{1F42E}\u231B\uFE0F";
5
+ const addText = " 🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️";
6
6
  const { start, text } = value;
7
7
  if (start < searchText.length) {
8
8
  return value;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/rich-text/prevent-event-discovery.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { insert } from '@wordpress/rich-text';\n\nexport function preventEventDiscovery( value ) {\n\tconst searchText = 'tales of gutenberg';\n\tconst addText =\n\t\t' \uD83D\uDC21\uD83D\uDC22\uD83E\uDD80\uD83D\uDC24\uD83E\uDD8B\uD83D\uDC18\uD83D\uDC27\uD83D\uDC39\uD83E\uDD81\uD83E\uDD84\uD83E\uDD8D\uD83D\uDC3C\uD83D\uDC3F\uD83C\uDF83\uD83D\uDC34\uD83D\uDC1D\uD83D\uDC06\uD83E\uDD95\uD83E\uDD94\uD83C\uDF31\uD83C\uDF47\u03C0\uD83C\uDF4C\uD83D\uDC09\uD83D\uDCA7\uD83E\uDD68\uD83C\uDF0C\uD83C\uDF42\uD83C\uDF60\uD83E\uDD66\uD83E\uDD5A\uD83E\uDD5D\uD83C\uDF9F\uD83E\uDD65\uD83E\uDD52\uD83D\uDEF5\uD83E\uDD56\uD83C\uDF52\uD83C\uDF6F\uD83C\uDFBE\uD83C\uDFB2\uD83D\uDC3A\uD83D\uDC1A\uD83D\uDC2E\u231B\uFE0F';\n\tconst { start, text } = value;\n\n\tif ( start < searchText.length ) {\n\t\treturn value;\n\t}\n\n\tconst charactersBefore = text.slice( start - searchText.length, start );\n\n\tif ( charactersBefore.toLowerCase() !== searchText ) {\n\t\treturn value;\n\t}\n\n\treturn insert( value, addText );\n}\n"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { insert } from '@wordpress/rich-text';\n\nexport function preventEventDiscovery( value ) {\n\tconst searchText = 'tales of gutenberg';\n\tconst addText =\n\t\t' 🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️';\n\tconst { start, text } = value;\n\n\tif ( start < searchText.length ) {\n\t\treturn value;\n\t}\n\n\tconst charactersBefore = text.slice( start - searchText.length, start );\n\n\tif ( charactersBefore.toLowerCase() !== searchText ) {\n\t\treturn value;\n\t}\n\n\treturn insert( value, addText );\n}\n"],
5
5
  "mappings": ";AAGA,SAAS,cAAc;AAEhB,SAAS,sBAAuB,OAAQ;AAC9C,QAAM,aAAa;AACnB,QAAM,UACL;AACD,QAAM,EAAE,OAAO,KAAK,IAAI;AAExB,MAAK,QAAQ,WAAW,QAAS;AAChC,WAAO;AAAA,EACR;AAEA,QAAM,mBAAmB,KAAK,MAAO,QAAQ,WAAW,QAAQ,KAAM;AAEtE,MAAK,iBAAiB,YAAY,MAAM,YAAa;AACpD,WAAO;AAAA,EACR;AAEA,SAAO,OAAQ,OAAO,OAAQ;AAC/B;",
6
6
  "names": []
7
7
  }
@@ -190,7 +190,6 @@ var ImageURLInputUI = ({
190
190
  /* @__PURE__ */ jsx(
191
191
  TextControl,
192
192
  {
193
- __next40pxDefaultSize: true,
194
193
  label: __("Link relation"),
195
194
  value: rel ?? "",
196
195
  onChange: onSetLinkRel,
@@ -207,7 +206,6 @@ var ImageURLInputUI = ({
207
206
  /* @__PURE__ */ jsx(
208
207
  TextControl,
209
208
  {
210
- __next40pxDefaultSize: true,
211
209
  label: __("Link CSS class"),
212
210
  value: linkClass || "",
213
211
  onChange: onSetLinkClass
@@ -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": ";AAGA,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa;AACtB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,oBAAoB;AAK7B,OAAO,gBAAgB;AAkMrB,SAgFE,UA/ED,KADD;AAhMF,IAAM,wBAAwB;AAC9B,IAAM,0BAA0B;AAChC,IAAM,yBAAyB;AAC/B,IA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A,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": ";AAGA,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa;AACtB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,oBAAoB;AAK7B,OAAO,gBAAgB;AAkMrB,SA8EE,UA7ED,KADD;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,IAAI,SAAU,KAAM;AAG9C,QAAM,CAAE,eAAe,gBAAiB,IAAI,SAAU,IAAK;AAC3D,QAAM,aAAa,MAAM;AACxB,cAAW,IAAK;AAAA,EACjB;AAEA,QAAM,CAAE,eAAe,gBAAiB,IAAI,SAAU,KAAM;AAC5D,QAAM,CAAE,UAAU,WAAY,IAAI,SAAU,IAAK;AAEjD,QAAM,kBAAkB,OAAQ,IAAK;AACrC,QAAM,aAAa,OAAO;AAE1B,YAAW,MAAM;AAChB,QAAK,CAAE,WAAW,SAAU;AAC3B;AAAA,IACD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A,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,MAAO;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,aAAI,kBAAmB;AAAA;AAAA,YAlBrB;AAAA,UAmBL;AAAA,WAEF;AAAA,QAGF,QAAS;AAAA,QAEP,0BAAgB;AAAA;AAAA,IACnB;AAAA,KAEF;AAEF;",
6
6
  "names": []
7
7
  }
@@ -9,6 +9,8 @@ import {
9
9
  import { __ } from "@wordpress/i18n";
10
10
  import { symbol } from "@wordpress/icons";
11
11
  import { store as blockEditorStore } from "../../store/index.mjs";
12
+ import { unlock } from "../../lock-unlock.mjs";
13
+ import { isIsolatedEditorKey } from "../../store/private-keys.mjs";
12
14
  function getPositionTypeLabel(attributes) {
13
15
  const positionType = attributes?.style?.position?.type;
14
16
  if (positionType === "sticky") {
@@ -25,11 +27,13 @@ function useBlockDisplayInformation(clientId) {
25
27
  if (!clientId) {
26
28
  return null;
27
29
  }
30
+ const blockEditorSelect = select(blockEditorStore);
28
31
  const {
29
32
  getBlockName,
30
33
  getBlockAttributes,
31
- __experimentalGetParsedPattern
32
- } = select(blockEditorStore);
34
+ __experimentalGetParsedPattern,
35
+ getSettings
36
+ } = blockEditorSelect;
33
37
  const { getBlockType, getActiveBlockVariation } = select(blocksStore);
34
38
  const blockName = getBlockName(clientId);
35
39
  const blockType = getBlockType(blockName);
@@ -37,8 +41,11 @@ function useBlockDisplayInformation(clientId) {
37
41
  return null;
38
42
  }
39
43
  const attributes = getBlockAttributes(clientId);
44
+ const { isWithinEditedContentOnlySection } = unlock(blockEditorSelect);
45
+ const isIsolatedEditor = !!getSettings()?.[isIsolatedEditorKey];
40
46
  const patternName = attributes?.metadata?.patternName;
41
- if (patternName) {
47
+ const isEditedContentOnlySection = isWithinEditedContentOnlySection(clientId);
48
+ if (patternName && !isEditedContentOnlySection && !isIsolatedEditor) {
42
49
  const pattern = __experimentalGetParsedPattern(patternName);
43
50
  const positionLabel2 = getPositionTypeLabel(attributes);
44
51
  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": ";AAGA,SAAS,iBAAiB;AAC1B;AAAA,EACC,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,+BAA+B;AAAA,OACzB;AACP,SAAS,UAAU;AACnB,SAAS,cAAc;AAKvB,SAAS,SAAS,wBAAwB;AAuB1C,SAAS,qBAAsB,YAAa;AAC3C,QAAM,eAAe,YAAY,OAAO,UAAU;AAElD,MAAK,iBAAiB,UAAW;AAChC,WAAO,GAAI,QAAS;AAAA,EACrB;AAEA,MAAK,iBAAiB,SAAU;AAC/B,WAAO,GAAI,OAAQ;AAAA,EACpB;AAEA,SAAO;AACR;AAiBe,SAAR,2BAA6C,UAAW;AAC9D,SAAO;AAAA,IACN,CAAE,WAAY;AACb,UAAK,CAAE,UAAW;AACjB,eAAO;AAAA,MACR;AACA,YAAM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AU;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": ";AAGA,SAAS,iBAAiB;AAC1B;AAAA,EACC,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,+BAA+B;AAAA,OACzB;AACP,SAAS,UAAU;AACnB,SAAS,cAAc;AAKvB,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AACvB,SAAS,2BAA2B;AAuBpC,SAAS,qBAAsB,YAAa;AAC3C,QAAM,eAAe,YAAY,OAAO,UAAU;AAElD,MAAK,iBAAiB,UAAW;AAChC,WAAO,GAAI,QAAS;AAAA,EACrB;AAEA,MAAK,iBAAiB,SAAU;AAC/B,WAAO,GAAI,OAAQ;AAAA,EACpB;AAEA,SAAO;AACR;AAiBe,SAA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AU;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": ["positionLabel"]
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": ";AAGA,SAAS,OAAO,qBAAqB;AACrC,SAAS,WAAW;AACpB,SAAS,WAAW,mBAAmB;AACvC,SAAS,cAAc,oBAAoB;AAC3C,SAAS,cAAc;AAKvB,SAAS,SAAS,wBAAwB;AAC1C,SAAS,eAAe,yBAAyB;AACjD,SAAS,cAAc;AAiFrB;AA/Ea,SAAR,YAA6B;AACnC,QAAM;AAAA;AAAA,IAA2D,OAAS;AAAA;AAC1E,QAAM,wBAAwB,OAAO;AACrC,QAAM,uBAAuB,OAAO;AAEpC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD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AAM,QAAS;AAC5C;AAAA,MACD;AAEA,YAAM,UAAU,MAAM;AACtB,YAAM,YAAY,UAAU,iBAAiB;AAC7C,YAAM,SAAS,MAAM,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,aAAa,aAAc,CAAE,cAAc,GAAI,CAAE;AAEvD,SAAO,CAAE,QAAQ,YAAY,KAAM;AACpC;",
6
6
  "names": ["ownerDocument"]
7
7
  }
@@ -29,12 +29,11 @@ function BlockEditAnchorControlPure({ anchor, setAttributes }) {
29
29
  return /* @__PURE__ */ jsx(InspectorControls, { group: "advanced", children: /* @__PURE__ */ jsx(
30
30
  TextControl,
31
31
  {
32
- __next40pxDefaultSize: true,
33
32
  className: "html-anchor-control",
34
33
  label: __("HTML anchor"),
35
34
  help: /* @__PURE__ */ jsxs(Fragment, { children: [
36
35
  __(
37
- "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."
36
+ "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."
38
37
  ),
39
38
  " ",
40
39
  /* @__PURE__ */ 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": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,aAAa,oBAAoB;AAC1C,SAAS,UAAU;AACnB,SAAS,uBAAuB;AAKhC,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AAiD/B,mBAIC,KAJD;AA1CL,IAAM,eAAe;AAUd,SAAS,aAAc,UAAW;AAExC,MAAK,W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4B,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": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,aAAa,oBAAoB;AAC1C,SAAS,UAAU;AACnB,SAAS,uBAAuB;AAKhC,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AAgD/B,mBAIC,KAJD;AAzCL,IAAM,eAAe;AAUd,SAAS,aAAc,UAAW;AAExC,MAAK,WAAY,SAAS,YAAY,UAAU,CAAC,IAAM;AACtD,WAAO;AAAA,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