@wordpress/block-editor 15.21.0 → 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 (836) hide show
  1. package/CHANGELOG.md +23 -1
  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-compare/index.cjs +2 -2
  6. package/build/components/block-compare/index.cjs.map +2 -2
  7. package/build/components/block-editing-mode/index.cjs +13 -7
  8. package/build/components/block-editing-mode/index.cjs.map +2 -2
  9. package/build/components/block-inspector/index.cjs +35 -20
  10. package/build/components/block-inspector/index.cjs.map +2 -2
  11. package/build/components/block-mover/mover-description.cjs +6 -6
  12. package/build/components/block-mover/mover-description.cjs.map +1 -1
  13. package/build/components/block-patterns-list/index.cjs +1 -1
  14. package/build/components/block-patterns-list/index.cjs.map +2 -2
  15. package/build/components/block-patterns-paging/index.cjs +4 -4
  16. package/build/components/block-patterns-paging/index.cjs.map +2 -2
  17. package/build/components/block-popover/use-popover-scroll.cjs.map +1 -1
  18. package/build/components/block-quick-navigation/index.cjs +7 -5
  19. package/build/components/block-quick-navigation/index.cjs.map +2 -2
  20. package/build/components/block-rename/modal.cjs +0 -1
  21. package/build/components/block-rename/modal.cjs.map +2 -2
  22. package/build/components/block-switcher/block-transformations-menu.cjs +16 -15
  23. package/build/components/block-switcher/block-transformations-menu.cjs.map +2 -2
  24. package/build/components/block-switcher/index.cjs +4 -4
  25. package/build/components/block-switcher/index.cjs.map +2 -2
  26. package/build/components/block-toolbar/block-toolbar-icon.cjs +14 -6
  27. package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
  28. package/build/components/block-toolbar/edit-section-button.cjs.map +1 -1
  29. package/build/components/block-tools/use-block-toolbar-popover-props.cjs +10 -4
  30. package/build/components/block-tools/use-block-toolbar-popover-props.cjs.map +2 -2
  31. package/build/components/child-layout-control/index.cjs +51 -19
  32. package/build/components/child-layout-control/index.cjs.map +2 -2
  33. package/build/components/colors-gradients/control.cjs +25 -14
  34. package/build/components/colors-gradients/control.cjs.map +2 -2
  35. package/build/components/colors-gradients/dropdown.cjs +4 -1
  36. package/build/components/colors-gradients/dropdown.cjs.map +3 -3
  37. package/build/components/contrast-checker/index.cjs +22 -4
  38. package/build/components/contrast-checker/index.cjs.map +2 -2
  39. package/build/components/date-format-picker/index.cjs +0 -1
  40. package/build/components/date-format-picker/index.cjs.map +2 -2
  41. package/build/components/dimensions-tool/index.cjs +4 -5
  42. package/build/components/dimensions-tool/index.cjs.map +2 -2
  43. package/build/components/dimensions-tool/scale-tool.cjs +1 -1
  44. package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
  45. package/build/components/global-styles/advanced-panel.cjs +23 -15
  46. package/build/components/global-styles/advanced-panel.cjs.map +2 -2
  47. package/build/components/global-styles/background-panel.cjs +154 -26
  48. package/build/components/global-styles/background-panel.cjs.map +3 -3
  49. package/build/components/global-styles/border-panel.cjs +2 -0
  50. package/build/components/global-styles/border-panel.cjs.map +2 -2
  51. package/build/components/global-styles/color-gradient-dropdown-item.cjs +227 -0
  52. package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +7 -0
  53. package/build/components/global-styles/color-panel.cjs +98 -375
  54. package/build/components/global-styles/color-panel.cjs.map +3 -3
  55. package/build/components/global-styles/dimensions-panel.cjs +2 -5
  56. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  57. package/build/components/global-styles/hooks.cjs +34 -0
  58. package/build/components/global-styles/hooks.cjs.map +2 -2
  59. package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
  60. package/build/components/global-styles/typography-panel.cjs +82 -10
  61. package/build/components/global-styles/typography-panel.cjs.map +3 -3
  62. package/build/components/grid/grid-item-resizer.cjs.map +1 -1
  63. package/build/components/grid/grid-visualizer.cjs.map +1 -1
  64. package/build/components/iframe/index.cjs +6 -3
  65. package/build/components/iframe/index.cjs.map +3 -3
  66. package/build/components/image-editor/use-transform-image.cjs.map +1 -1
  67. package/build/components/inner-blocks/use-inner-block-template-sync.cjs +3 -1
  68. package/build/components/inner-blocks/use-inner-block-template-sync.cjs.map +2 -2
  69. package/build/components/inserter/get-appender-label.cjs.map +1 -1
  70. package/build/components/inserter/hooks/use-patterns-state.cjs +1 -1
  71. package/build/components/inserter/hooks/use-patterns-state.cjs.map +2 -2
  72. package/build/components/inserter/index.cjs +179 -220
  73. package/build/components/inserter/index.cjs.map +3 -3
  74. package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
  75. package/build/components/inserter/search-items.cjs.map +1 -1
  76. package/build/components/inserter/search-results.cjs +1 -1
  77. package/build/components/inserter/search-results.cjs.map +2 -2
  78. package/build/components/inspector-controls/fill.cjs +1 -3
  79. package/build/components/inspector-controls/fill.cjs.map +2 -2
  80. package/build/components/inspector-controls/groups.cjs +2 -0
  81. package/build/components/inspector-controls/groups.cjs.map +2 -2
  82. package/build/components/inspector-controls-tabs/index.cjs.map +2 -2
  83. package/build/components/inspector-controls-tabs/styles-tab.cjs +76 -32
  84. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  85. package/build/components/keyboard-shortcuts/index.cjs.map +1 -1
  86. package/build/components/line-height-control/index.cjs.map +1 -1
  87. package/build/components/link-control/index.cjs +2 -3
  88. package/build/components/link-control/index.cjs.map +2 -2
  89. package/build/components/link-control/normalize-url.cjs.map +1 -1
  90. package/build/components/list-view/block-select-button.cjs +9 -20
  91. package/build/components/list-view/block-select-button.cjs.map +3 -3
  92. package/build/components/list-view/block.cjs +2 -1
  93. package/build/components/list-view/block.cjs.map +2 -2
  94. package/build/components/list-view/utils.cjs.map +1 -1
  95. package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
  96. package/build/components/provider/index.cjs.map +1 -1
  97. package/build/components/provider/use-block-sync.cjs +14 -3
  98. package/build/components/provider/use-block-sync.cjs.map +2 -2
  99. package/build/components/rich-text/event-listeners/before-input-rules.cjs +5 -5
  100. package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +3 -3
  101. package/build/components/rich-text/event-listeners/delete.cjs +4 -4
  102. package/build/components/rich-text/event-listeners/delete.cjs.map +3 -3
  103. package/build/components/rich-text/event-listeners/enter.cjs +7 -2
  104. package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
  105. package/build/components/rich-text/event-listeners/input-events.cjs +4 -4
  106. package/build/components/rich-text/event-listeners/input-events.cjs.map +3 -3
  107. package/build/components/rich-text/event-listeners/input-rules.cjs +17 -4
  108. package/build/components/rich-text/event-listeners/input-rules.cjs.map +3 -3
  109. package/build/components/rich-text/event-listeners/insert-replacement-text.cjs +4 -4
  110. package/build/components/rich-text/event-listeners/insert-replacement-text.cjs.map +3 -3
  111. package/build/components/rich-text/event-listeners/paste-handler.cjs.map +1 -1
  112. package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs +4 -4
  113. package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs.map +3 -3
  114. package/build/components/rich-text/event-listeners/shortcuts.cjs +4 -4
  115. package/build/components/rich-text/event-listeners/shortcuts.cjs.map +3 -3
  116. package/build/components/rich-text/event-listeners/undo-automatic-change.cjs +4 -4
  117. package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +3 -3
  118. package/build/components/rich-text/index.cjs +1 -23
  119. package/build/components/rich-text/index.cjs.map +2 -2
  120. package/build/components/rich-text/prevent-event-discovery.cjs +1 -1
  121. package/build/components/rich-text/prevent-event-discovery.cjs.map +1 -1
  122. package/build/components/url-popover/image-url-input-ui.cjs +0 -2
  123. package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
  124. package/build/components/use-block-commands/index.cjs +5 -5
  125. package/build/components/use-block-commands/index.cjs.map +2 -2
  126. package/build/components/use-block-display-information/index.cjs +10 -3
  127. package/build/components/use-block-display-information/index.cjs.map +2 -2
  128. package/build/components/writing-flow/use-tab-nav.cjs.map +1 -1
  129. package/build/hooks/anchor.cjs +12 -17
  130. package/build/hooks/anchor.cjs.map +2 -2
  131. package/build/hooks/background.cjs +124 -75
  132. package/build/hooks/background.cjs.map +3 -3
  133. package/build/hooks/block-fields/index.cjs +13 -2
  134. package/build/hooks/block-fields/index.cjs.map +2 -2
  135. package/build/hooks/border.cjs +0 -3
  136. package/build/hooks/border.cjs.map +2 -2
  137. package/build/hooks/color.cjs +0 -165
  138. package/build/hooks/color.cjs.map +3 -3
  139. package/build/hooks/contrast-checker.cjs +31 -28
  140. package/build/hooks/contrast-checker.cjs.map +3 -3
  141. package/build/hooks/custom-class-name.cjs +0 -1
  142. package/build/hooks/custom-class-name.cjs.map +2 -2
  143. package/build/hooks/dimensions.cjs +13 -5
  144. package/build/hooks/dimensions.cjs.map +2 -2
  145. package/build/hooks/elements.cjs +142 -0
  146. package/build/hooks/elements.cjs.map +7 -0
  147. package/build/hooks/fit-text.cjs +11 -0
  148. package/build/hooks/fit-text.cjs.map +2 -2
  149. package/build/hooks/grid-visualizer.cjs +21 -11
  150. package/build/hooks/grid-visualizer.cjs.map +2 -2
  151. package/build/hooks/layout-child.cjs +65 -10
  152. package/build/hooks/layout-child.cjs.map +2 -2
  153. package/build/hooks/layout.cjs +6 -3
  154. package/build/hooks/layout.cjs.map +2 -2
  155. package/build/hooks/list-view.cjs +10 -7
  156. package/build/hooks/list-view.cjs.map +2 -2
  157. package/build/hooks/position.cjs +19 -22
  158. package/build/hooks/position.cjs.map +2 -2
  159. package/build/hooks/spacing-visualizer.cjs.map +1 -1
  160. package/build/hooks/state-utils.cjs.map +1 -1
  161. package/build/hooks/states.cjs +2 -2
  162. package/build/hooks/states.cjs.map +2 -2
  163. package/build/hooks/style.cjs +50 -6
  164. package/build/hooks/style.cjs.map +2 -2
  165. package/build/hooks/supports.cjs +0 -7
  166. package/build/hooks/supports.cjs.map +2 -2
  167. package/build/hooks/typography.cjs +62 -10
  168. package/build/hooks/typography.cjs.map +3 -3
  169. package/build/layouts/flex.cjs +99 -6
  170. package/build/layouts/flex.cjs.map +2 -2
  171. package/build/private-apis.cjs +4 -0
  172. package/build/private-apis.cjs.map +2 -2
  173. package/build/store/actions.cjs +7 -3
  174. package/build/store/actions.cjs.map +2 -2
  175. package/build/store/private-actions.cjs +1 -2
  176. package/build/store/private-actions.cjs.map +2 -2
  177. package/build/store/private-selectors.cjs +42 -2
  178. package/build/store/private-selectors.cjs.map +2 -2
  179. package/build/store/reducer.cjs +14 -6
  180. package/build/store/reducer.cjs.map +2 -2
  181. package/build/store/selectors.cjs +60 -41
  182. package/build/store/selectors.cjs.map +2 -2
  183. package/build/utils/block-bindings.cjs +9 -9
  184. package/build/utils/block-bindings.cjs.map +3 -3
  185. package/build/utils/color-values.cjs +10 -1
  186. package/build/utils/color-values.cjs.map +3 -3
  187. package/build/utils/dom.cjs +2 -5
  188. package/build/utils/dom.cjs.map +3 -3
  189. package/build/utils/fit-text-frontend.cjs +6 -2
  190. package/build/utils/fit-text-frontend.cjs.map +3 -3
  191. package/build/utils/fit-text-utils.cjs +1 -1
  192. package/build/utils/fit-text-utils.cjs.map +3 -3
  193. package/build/utils/format-font-style.cjs +1 -1
  194. package/build/utils/format-font-style.cjs.map +3 -3
  195. package/build/utils/format-font-weight.cjs +1 -1
  196. package/build/utils/format-font-weight.cjs.map +3 -3
  197. package/build/utils/get-editor-region.cjs +4 -2
  198. package/build/utils/get-editor-region.cjs.map +3 -3
  199. package/build/utils/get-font-styles-and-weights.cjs +8 -12
  200. package/build/utils/get-font-styles-and-weights.cjs.map +3 -3
  201. package/build/utils/get-px-from-css-unit.cjs +1 -1
  202. package/build/utils/get-px-from-css-unit.cjs.map +1 -1
  203. package/build/utils/index.cjs +1 -1
  204. package/build/utils/index.cjs.map +1 -1
  205. package/build/utils/math.cjs +1 -1
  206. package/build/utils/math.cjs.map +3 -3
  207. package/build/utils/object.cjs +8 -8
  208. package/build/utils/object.cjs.map +3 -3
  209. package/build/utils/order-inserter-block-items.cjs +1 -1
  210. package/build/utils/order-inserter-block-items.cjs.map +3 -3
  211. package/build/utils/pasting.cjs +4 -2
  212. package/build/utils/pasting.cjs.map +3 -3
  213. package/build/utils/selection.cjs +3 -2
  214. package/build/utils/selection.cjs.map +3 -3
  215. package/build/utils/sorting.cjs +9 -3
  216. package/build/utils/sorting.cjs.map +3 -3
  217. package/build/utils/transform-styles/index.cjs +3 -2
  218. package/build/utils/transform-styles/index.cjs.map +3 -3
  219. package/build/utils/transform-styles/postcss-urlrebase.d.cjs +2 -0
  220. package/build/utils/transform-styles/postcss-urlrebase.d.cjs.map +7 -0
  221. package/build/{components/rich-text/native/index.cjs → utils/transform-styles/types.cjs} +4 -13
  222. package/build/utils/transform-styles/types.cjs.map +7 -0
  223. package/build/utils/types.cjs +19 -0
  224. package/build/utils/types.cjs.map +7 -0
  225. package/build-module/components/block-card/index.mjs +5 -6
  226. package/build-module/components/block-card/index.mjs.map +2 -2
  227. package/build-module/components/block-compare/index.mjs +1 -1
  228. package/build-module/components/block-compare/index.mjs.map +2 -2
  229. package/build-module/components/block-editing-mode/index.mjs +14 -8
  230. package/build-module/components/block-editing-mode/index.mjs.map +2 -2
  231. package/build-module/components/block-inspector/index.mjs +35 -21
  232. package/build-module/components/block-inspector/index.mjs.map +2 -2
  233. package/build-module/components/block-mover/mover-description.mjs +6 -6
  234. package/build-module/components/block-mover/mover-description.mjs.map +1 -1
  235. package/build-module/components/block-patterns-list/index.mjs +1 -1
  236. package/build-module/components/block-patterns-list/index.mjs.map +2 -2
  237. package/build-module/components/block-patterns-paging/index.mjs +4 -4
  238. package/build-module/components/block-patterns-paging/index.mjs.map +2 -2
  239. package/build-module/components/block-popover/use-popover-scroll.mjs.map +1 -1
  240. package/build-module/components/block-quick-navigation/index.mjs +8 -6
  241. package/build-module/components/block-quick-navigation/index.mjs.map +2 -2
  242. package/build-module/components/block-rename/modal.mjs +0 -1
  243. package/build-module/components/block-rename/modal.mjs.map +2 -2
  244. package/build-module/components/block-switcher/block-transformations-menu.mjs +16 -15
  245. package/build-module/components/block-switcher/block-transformations-menu.mjs.map +2 -2
  246. package/build-module/components/block-switcher/index.mjs +4 -4
  247. package/build-module/components/block-switcher/index.mjs.map +2 -2
  248. package/build-module/components/block-toolbar/block-toolbar-icon.mjs +14 -6
  249. package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
  250. package/build-module/components/block-toolbar/edit-section-button.mjs.map +1 -1
  251. package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs +10 -4
  252. package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs.map +2 -2
  253. package/build-module/components/child-layout-control/index.mjs +51 -19
  254. package/build-module/components/child-layout-control/index.mjs.map +2 -2
  255. package/build-module/components/colors-gradients/control.mjs +27 -15
  256. package/build-module/components/colors-gradients/control.mjs.map +2 -2
  257. package/build-module/components/colors-gradients/dropdown.mjs +4 -1
  258. package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
  259. package/build-module/components/contrast-checker/index.mjs +18 -4
  260. package/build-module/components/contrast-checker/index.mjs.map +2 -2
  261. package/build-module/components/date-format-picker/index.mjs +0 -1
  262. package/build-module/components/date-format-picker/index.mjs.map +2 -2
  263. package/build-module/components/dimensions-tool/index.mjs +4 -5
  264. package/build-module/components/dimensions-tool/index.mjs.map +2 -2
  265. package/build-module/components/dimensions-tool/scale-tool.mjs +1 -1
  266. package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
  267. package/build-module/components/global-styles/advanced-panel.mjs +23 -15
  268. package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
  269. package/build-module/components/global-styles/background-panel.mjs +157 -29
  270. package/build-module/components/global-styles/background-panel.mjs.map +2 -2
  271. package/build-module/components/global-styles/border-panel.mjs +2 -0
  272. package/build-module/components/global-styles/border-panel.mjs.map +2 -2
  273. package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +207 -0
  274. package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +7 -0
  275. package/build-module/components/global-styles/color-panel.mjs +106 -387
  276. package/build-module/components/global-styles/color-panel.mjs.map +3 -3
  277. package/build-module/components/global-styles/dimensions-panel.mjs +3 -7
  278. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  279. package/build-module/components/global-styles/hooks.mjs +33 -0
  280. package/build-module/components/global-styles/hooks.mjs.map +2 -2
  281. package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
  282. package/build-module/components/global-styles/typography-panel.mjs +84 -10
  283. package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
  284. package/build-module/components/grid/grid-item-resizer.mjs.map +1 -1
  285. package/build-module/components/grid/grid-visualizer.mjs.map +1 -1
  286. package/build-module/components/iframe/index.mjs +6 -3
  287. package/build-module/components/iframe/index.mjs.map +2 -2
  288. package/build-module/components/image-editor/use-transform-image.mjs.map +1 -1
  289. package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs +3 -1
  290. package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs.map +2 -2
  291. package/build-module/components/inserter/get-appender-label.mjs.map +1 -1
  292. package/build-module/components/inserter/hooks/use-patterns-state.mjs +1 -1
  293. package/build-module/components/inserter/hooks/use-patterns-state.mjs.map +2 -2
  294. package/build-module/components/inserter/index.mjs +185 -222
  295. package/build-module/components/inserter/index.mjs.map +3 -3
  296. package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
  297. package/build-module/components/inserter/search-items.mjs.map +1 -1
  298. package/build-module/components/inserter/search-results.mjs +1 -1
  299. package/build-module/components/inserter/search-results.mjs.map +2 -2
  300. package/build-module/components/inspector-controls/fill.mjs +1 -3
  301. package/build-module/components/inspector-controls/fill.mjs.map +2 -2
  302. package/build-module/components/inspector-controls/groups.mjs +2 -0
  303. package/build-module/components/inspector-controls/groups.mjs.map +2 -2
  304. package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
  305. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +76 -32
  306. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  307. package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -1
  308. package/build-module/components/line-height-control/index.mjs.map +1 -1
  309. package/build-module/components/link-control/index.mjs +2 -3
  310. package/build-module/components/link-control/index.mjs.map +2 -2
  311. package/build-module/components/link-control/normalize-url.mjs.map +1 -1
  312. package/build-module/components/list-view/block-select-button.mjs +10 -27
  313. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  314. package/build-module/components/list-view/block.mjs +2 -1
  315. package/build-module/components/list-view/block.mjs.map +2 -2
  316. package/build-module/components/list-view/utils.mjs.map +1 -1
  317. package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
  318. package/build-module/components/provider/index.mjs.map +1 -1
  319. package/build-module/components/provider/use-block-sync.mjs +14 -3
  320. package/build-module/components/provider/use-block-sync.mjs.map +2 -2
  321. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +5 -5
  322. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
  323. package/build-module/components/rich-text/event-listeners/delete.mjs +4 -4
  324. package/build-module/components/rich-text/event-listeners/delete.mjs.map +2 -2
  325. package/build-module/components/rich-text/event-listeners/enter.mjs +7 -2
  326. package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
  327. package/build-module/components/rich-text/event-listeners/input-events.mjs +4 -4
  328. package/build-module/components/rich-text/event-listeners/input-events.mjs.map +2 -2
  329. package/build-module/components/rich-text/event-listeners/input-rules.mjs +17 -4
  330. package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
  331. package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs +4 -4
  332. package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs.map +2 -2
  333. package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +1 -1
  334. package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs +4 -4
  335. package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs.map +2 -2
  336. package/build-module/components/rich-text/event-listeners/shortcuts.mjs +4 -4
  337. package/build-module/components/rich-text/event-listeners/shortcuts.mjs.map +2 -2
  338. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +4 -4
  339. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +2 -2
  340. package/build-module/components/rich-text/index.mjs +1 -23
  341. package/build-module/components/rich-text/index.mjs.map +2 -2
  342. package/build-module/components/rich-text/prevent-event-discovery.mjs +1 -1
  343. package/build-module/components/rich-text/prevent-event-discovery.mjs.map +1 -1
  344. package/build-module/components/url-popover/image-url-input-ui.mjs +0 -2
  345. package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
  346. package/build-module/components/use-block-commands/index.mjs +5 -5
  347. package/build-module/components/use-block-commands/index.mjs.map +2 -2
  348. package/build-module/components/use-block-display-information/index.mjs +10 -3
  349. package/build-module/components/use-block-display-information/index.mjs.map +2 -2
  350. package/build-module/components/writing-flow/use-tab-nav.mjs.map +1 -1
  351. package/build-module/hooks/anchor.mjs +12 -17
  352. package/build-module/hooks/anchor.mjs.map +2 -2
  353. package/build-module/hooks/background.mjs +123 -75
  354. package/build-module/hooks/background.mjs.map +2 -2
  355. package/build-module/hooks/block-fields/index.mjs +13 -2
  356. package/build-module/hooks/block-fields/index.mjs.map +2 -2
  357. package/build-module/hooks/border.mjs +1 -4
  358. package/build-module/hooks/border.mjs.map +2 -2
  359. package/build-module/hooks/color.mjs +2 -178
  360. package/build-module/hooks/color.mjs.map +2 -2
  361. package/build-module/hooks/contrast-checker.mjs +32 -19
  362. package/build-module/hooks/contrast-checker.mjs.map +2 -2
  363. package/build-module/hooks/custom-class-name.mjs +0 -1
  364. package/build-module/hooks/custom-class-name.mjs.map +2 -2
  365. package/build-module/hooks/dimensions.mjs +13 -6
  366. package/build-module/hooks/dimensions.mjs.map +2 -2
  367. package/build-module/hooks/elements.mjs +115 -0
  368. package/build-module/hooks/elements.mjs.map +7 -0
  369. package/build-module/hooks/fit-text.mjs +11 -0
  370. package/build-module/hooks/fit-text.mjs.map +2 -2
  371. package/build-module/hooks/grid-visualizer.mjs +21 -11
  372. package/build-module/hooks/grid-visualizer.mjs.map +2 -2
  373. package/build-module/hooks/layout-child.mjs +68 -10
  374. package/build-module/hooks/layout-child.mjs.map +2 -2
  375. package/build-module/hooks/layout.mjs +6 -3
  376. package/build-module/hooks/layout.mjs.map +2 -2
  377. package/build-module/hooks/list-view.mjs +10 -7
  378. package/build-module/hooks/list-view.mjs.map +2 -2
  379. package/build-module/hooks/position.mjs +20 -23
  380. package/build-module/hooks/position.mjs.map +2 -2
  381. package/build-module/hooks/spacing-visualizer.mjs.map +1 -1
  382. package/build-module/hooks/state-utils.mjs.map +1 -1
  383. package/build-module/hooks/states.mjs +2 -2
  384. package/build-module/hooks/states.mjs.map +2 -2
  385. package/build-module/hooks/style.mjs +53 -8
  386. package/build-module/hooks/style.mjs.map +2 -2
  387. package/build-module/hooks/supports.mjs +0 -7
  388. package/build-module/hooks/supports.mjs.map +2 -2
  389. package/build-module/hooks/typography.mjs +62 -10
  390. package/build-module/hooks/typography.mjs.map +2 -2
  391. package/build-module/layouts/flex.mjs +105 -7
  392. package/build-module/layouts/flex.mjs.map +2 -2
  393. package/build-module/private-apis.mjs +8 -0
  394. package/build-module/private-apis.mjs.map +2 -2
  395. package/build-module/store/actions.mjs +7 -3
  396. package/build-module/store/actions.mjs.map +2 -2
  397. package/build-module/store/private-actions.mjs +1 -2
  398. package/build-module/store/private-actions.mjs.map +2 -2
  399. package/build-module/store/private-selectors.mjs +39 -1
  400. package/build-module/store/private-selectors.mjs.map +2 -2
  401. package/build-module/store/reducer.mjs +14 -6
  402. package/build-module/store/reducer.mjs.map +2 -2
  403. package/build-module/store/selectors.mjs +62 -42
  404. package/build-module/store/selectors.mjs.map +2 -2
  405. package/build-module/utils/block-bindings.mjs +9 -9
  406. package/build-module/utils/block-bindings.mjs.map +3 -3
  407. package/build-module/utils/color-values.mjs +9 -1
  408. package/build-module/utils/color-values.mjs.map +3 -3
  409. package/build-module/utils/dom.mjs +2 -5
  410. package/build-module/utils/dom.mjs.map +3 -3
  411. package/build-module/utils/fit-text-frontend.mjs +6 -2
  412. package/build-module/utils/fit-text-frontend.mjs.map +3 -3
  413. package/build-module/utils/fit-text-utils.mjs +1 -1
  414. package/build-module/utils/fit-text-utils.mjs.map +3 -3
  415. package/build-module/utils/format-font-style.mjs +1 -1
  416. package/build-module/utils/format-font-style.mjs.map +3 -3
  417. package/build-module/utils/format-font-weight.mjs +1 -1
  418. package/build-module/utils/format-font-weight.mjs.map +3 -3
  419. package/build-module/utils/get-editor-region.mjs +4 -2
  420. package/build-module/utils/get-editor-region.mjs.map +3 -3
  421. package/build-module/utils/get-font-styles-and-weights.mjs +8 -12
  422. package/build-module/utils/get-font-styles-and-weights.mjs.map +3 -3
  423. package/build-module/utils/get-px-from-css-unit.mjs +1 -1
  424. package/build-module/utils/get-px-from-css-unit.mjs.map +1 -1
  425. package/build-module/utils/index.mjs +1 -1
  426. package/build-module/utils/index.mjs.map +1 -1
  427. package/build-module/utils/math.mjs +1 -1
  428. package/build-module/utils/math.mjs.map +3 -3
  429. package/build-module/utils/object.mjs +8 -8
  430. package/build-module/utils/object.mjs.map +3 -3
  431. package/build-module/utils/order-inserter-block-items.mjs +1 -1
  432. package/build-module/utils/order-inserter-block-items.mjs.map +3 -3
  433. package/build-module/utils/pasting.mjs +4 -2
  434. package/build-module/utils/pasting.mjs.map +3 -3
  435. package/build-module/utils/selection.mjs +3 -2
  436. package/build-module/utils/selection.mjs.map +3 -3
  437. package/build-module/utils/sorting.mjs +9 -3
  438. package/build-module/utils/sorting.mjs.map +3 -3
  439. package/build-module/utils/transform-styles/index.mjs +3 -2
  440. package/build-module/utils/transform-styles/index.mjs.map +3 -3
  441. package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs +1 -0
  442. package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs.map +7 -0
  443. package/build-module/utils/transform-styles/types.mjs +1 -0
  444. package/build-module/utils/transform-styles/types.mjs.map +7 -0
  445. package/build-module/utils/types.mjs +1 -0
  446. package/build-module/utils/types.mjs.map +7 -0
  447. package/build-style/content-rtl.css +14 -0
  448. package/build-style/content.css +14 -0
  449. package/build-style/style-rtl.css +60 -49
  450. package/build-style/style.css +60 -49
  451. package/build-types/utils/block-bindings.d.ts +27 -0
  452. package/build-types/utils/block-bindings.d.ts.map +1 -0
  453. package/build-types/utils/color-values.d.ts +40 -0
  454. package/build-types/utils/color-values.d.ts.map +1 -0
  455. package/build-types/utils/dom.d.ts +19 -19
  456. package/build-types/utils/dom.d.ts.map +1 -1
  457. package/build-types/utils/fit-text-frontend.d.ts +7 -0
  458. package/build-types/utils/fit-text-frontend.d.ts.map +1 -0
  459. package/build-types/utils/fit-text-utils.d.ts +15 -0
  460. package/build-types/utils/fit-text-utils.d.ts.map +1 -0
  461. package/build-types/utils/format-font-style.d.ts +12 -0
  462. package/build-types/utils/format-font-style.d.ts.map +1 -0
  463. package/build-types/utils/format-font-weight.d.ts +12 -0
  464. package/build-types/utils/format-font-weight.d.ts.map +1 -0
  465. package/build-types/utils/get-editor-region.d.ts +9 -0
  466. package/build-types/utils/get-editor-region.d.ts.map +1 -0
  467. package/build-types/utils/get-font-styles-and-weights.d.ts +16 -0
  468. package/build-types/utils/get-font-styles-and-weights.d.ts.map +1 -0
  469. package/build-types/utils/get-px-from-css-unit.d.ts +10 -0
  470. package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -0
  471. package/build-types/utils/index.d.ts +3 -0
  472. package/build-types/utils/index.d.ts.map +1 -0
  473. package/build-types/utils/math.d.ts +61 -0
  474. package/build-types/utils/math.d.ts.map +1 -0
  475. package/build-types/utils/object.d.ts +39 -0
  476. package/build-types/utils/object.d.ts.map +1 -0
  477. package/build-types/utils/order-inserter-block-items.d.ts +13 -0
  478. package/build-types/utils/order-inserter-block-items.d.ts.map +1 -0
  479. package/build-types/utils/pasting.d.ts +28 -0
  480. package/build-types/utils/pasting.d.ts.map +1 -0
  481. package/build-types/utils/selection.d.ts +21 -0
  482. package/build-types/utils/selection.d.ts.map +1 -0
  483. package/build-types/utils/sorting.d.ts +17 -0
  484. package/build-types/utils/sorting.d.ts.map +1 -0
  485. package/build-types/utils/transform-styles/index.d.ts +15 -0
  486. package/build-types/utils/transform-styles/index.d.ts.map +1 -0
  487. package/build-types/utils/transform-styles/types.d.ts +13 -0
  488. package/build-types/utils/transform-styles/types.d.ts.map +1 -0
  489. package/build-types/utils/types.d.ts +28 -0
  490. package/build-types/utils/types.d.ts.map +1 -0
  491. package/package.json +55 -46
  492. package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -0
  493. package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -0
  494. package/src/components/block-breadcrumb/README.md +2 -2
  495. package/src/components/block-card/index.js +7 -13
  496. package/src/components/block-compare/README.md +6 -6
  497. package/src/components/block-compare/index.js +1 -3
  498. package/src/components/block-editing-mode/index.js +17 -9
  499. package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -0
  500. package/src/components/block-inspector/index.js +22 -20
  501. package/src/components/block-patterns-list/index.js +1 -2
  502. package/src/components/block-preview/README.md +1 -1
  503. package/src/components/block-quick-navigation/index.js +7 -7
  504. package/src/components/block-rename/modal.js +0 -1
  505. package/src/components/block-switcher/block-transformations-menu.js +16 -18
  506. package/src/components/block-switcher/index.js +4 -4
  507. package/src/components/block-toolbar/block-toolbar-icon.js +22 -6
  508. package/src/components/block-toolbar/test/block-toolbar-icon.js +99 -0
  509. package/src/components/block-tools/use-block-toolbar-popover-props.js +10 -4
  510. package/src/components/block-types-list/README.md +0 -19
  511. package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -0
  512. package/src/components/child-layout-control/index.js +65 -20
  513. package/src/components/child-layout-control/test/index.js +64 -0
  514. package/src/components/colors-gradients/control.js +29 -12
  515. package/src/components/colors-gradients/dropdown.js +4 -1
  516. package/src/components/colors-gradients/style.scss +39 -2
  517. package/src/components/contrast-checker/README.md +9 -0
  518. package/src/components/contrast-checker/index.js +42 -3
  519. package/src/components/date-format-picker/index.js +0 -1
  520. package/src/components/default-block-appender/content.scss +3 -0
  521. package/src/components/dimensions-tool/index.js +4 -9
  522. package/src/components/dimensions-tool/scale-tool.js +1 -2
  523. package/src/components/dimensions-tool/test/index.js +89 -11
  524. package/src/components/global-styles/advanced-panel.js +5 -1
  525. package/src/components/global-styles/background-panel.js +203 -36
  526. package/src/components/global-styles/border-panel.js +2 -0
  527. package/src/components/global-styles/color-gradient-dropdown-item.js +258 -0
  528. package/src/components/global-styles/color-panel.js +125 -487
  529. package/src/components/global-styles/dimensions-panel.js +13 -18
  530. package/src/components/global-styles/hooks.js +45 -0
  531. package/src/components/global-styles/shadow-panel-components.js +0 -1
  532. package/src/components/global-styles/test/background-panel.js +56 -0
  533. package/src/components/global-styles/test/color-panel.js +172 -118
  534. package/src/components/global-styles/test/typography-panel.js +167 -0
  535. package/src/components/global-styles/typography-panel.js +100 -11
  536. package/src/components/iframe/index.js +8 -3
  537. package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -1
  538. package/src/components/inserter/hooks/use-patterns-state.js +1 -1
  539. package/src/components/inserter/index.js +257 -288
  540. package/src/components/inserter/media-tab/media-preview.js +0 -1
  541. package/src/components/inserter/search-results.js +1 -3
  542. package/src/components/inspector-controls/README.md +0 -2
  543. package/src/components/inspector-controls/fill.js +6 -8
  544. package/src/components/inspector-controls/groups.js +2 -0
  545. package/src/components/inspector-controls-tabs/index.js +0 -1
  546. package/src/components/inspector-controls-tabs/styles-tab.js +78 -28
  547. package/src/components/justify-content-control/README.md +1 -1
  548. package/src/components/link-control/index.js +0 -1
  549. package/src/components/link-control/test/index.js +2 -3
  550. package/src/components/list-view/block-select-button.js +9 -29
  551. package/src/components/list-view/block.js +1 -0
  552. package/src/components/media-placeholder/README.md +1 -29
  553. package/src/components/media-upload/README.md +0 -19
  554. package/src/components/preset-input-control/custom-value-controls.js +0 -1
  555. package/src/components/provider/test/use-block-sync.js +40 -0
  556. package/src/components/provider/use-block-sync.js +15 -3
  557. package/src/components/rich-text/content.scss +2 -0
  558. package/src/components/rich-text/event-listeners/before-input-rules.js +5 -4
  559. package/src/components/rich-text/event-listeners/delete.js +9 -4
  560. package/src/components/rich-text/event-listeners/enter.js +9 -2
  561. package/src/components/rich-text/event-listeners/input-events.js +13 -4
  562. package/src/components/rich-text/event-listeners/input-rules.js +20 -4
  563. package/src/components/rich-text/event-listeners/insert-replacement-text.js +9 -4
  564. package/src/components/rich-text/event-listeners/remove-browser-shortcuts.js +9 -4
  565. package/src/components/rich-text/event-listeners/shortcuts.js +13 -4
  566. package/src/components/rich-text/event-listeners/undo-automatic-change.js +5 -4
  567. package/src/components/rich-text/index.js +1 -33
  568. package/src/components/unit-control/README.md +1 -1
  569. package/src/components/url-popover/README.md +1 -1
  570. package/src/components/url-popover/image-url-input-ui.js +0 -2
  571. package/src/components/use-block-commands/index.js +5 -5
  572. package/src/components/use-block-display-information/index.js +15 -2
  573. package/src/components/use-block-display-information/test/index.js +140 -0
  574. package/src/hooks/anchor.js +9 -18
  575. package/src/hooks/background.js +210 -133
  576. package/src/hooks/background.scss +0 -35
  577. package/src/hooks/block-fields/index.js +27 -2
  578. package/src/hooks/border.js +1 -5
  579. package/src/hooks/color.js +2 -210
  580. package/src/hooks/color.scss +3 -9
  581. package/src/hooks/contrast-checker.js +60 -17
  582. package/src/hooks/custom-class-name.js +0 -1
  583. package/src/hooks/dimensions.js +15 -8
  584. package/src/hooks/elements.js +140 -0
  585. package/src/hooks/elements.scss +8 -0
  586. package/src/hooks/fit-text.js +16 -0
  587. package/src/hooks/grid-visualizer.js +59 -45
  588. package/src/hooks/layout-child.js +92 -14
  589. package/src/hooks/layout.js +6 -3
  590. package/src/hooks/list-view.js +10 -11
  591. package/src/hooks/position.js +23 -27
  592. package/src/hooks/states.js +2 -2
  593. package/src/hooks/style.js +91 -9
  594. package/src/hooks/supports.js +0 -9
  595. package/src/hooks/test/background.js +59 -0
  596. package/src/hooks/test/block-style-state.js +14 -14
  597. package/src/hooks/test/dimensions.js +71 -0
  598. package/src/hooks/test/layout-child.js +165 -0
  599. package/src/hooks/test/layout.js +6 -6
  600. package/src/hooks/test/style.js +133 -11
  601. package/src/hooks/typography.js +70 -6
  602. package/src/layouts/flex.js +118 -15
  603. package/src/private-apis.js +8 -0
  604. package/src/store/actions.js +13 -3
  605. package/src/store/private-actions.js +1 -4
  606. package/src/store/private-selectors.js +89 -0
  607. package/src/store/reducer.js +19 -7
  608. package/src/store/selectors.js +91 -53
  609. package/src/store/test/actions.js +21 -0
  610. package/src/store/test/private-selectors.js +166 -7
  611. package/src/store/test/reducer.js +107 -10
  612. package/src/store/test/selectors.js +77 -0
  613. package/src/style.scss +1 -0
  614. package/src/utils/block-bindings.ts +51 -0
  615. package/src/utils/color-values.ts +63 -0
  616. package/src/utils/{dom.js → dom.ts} +27 -27
  617. package/src/utils/{fit-text-frontend.js → fit-text-frontend.ts} +12 -4
  618. package/src/utils/{fit-text-utils.js → fit-text-utils.ts} +15 -7
  619. package/src/utils/{format-font-style.js → format-font-style.ts} +10 -3
  620. package/src/utils/{format-font-weight.js → format-font-weight.ts} +10 -3
  621. package/src/utils/{get-editor-region.js → get-editor-region.ts} +10 -6
  622. package/src/utils/{get-font-styles-and-weights.js → get-font-styles-and-weights.ts} +21 -17
  623. package/src/utils/{math.js → math.ts} +37 -30
  624. package/src/utils/object.ts +89 -0
  625. package/src/utils/{order-inserter-block-items.js → order-inserter-block-items.ts} +8 -5
  626. package/src/utils/{pasting.js → pasting.ts} +18 -11
  627. package/src/utils/{selection.js → selection.ts} +11 -4
  628. package/src/utils/sorting.ts +81 -0
  629. package/src/utils/test/color-values.js +44 -1
  630. package/src/utils/transform-styles/{index.js → index.ts} +25 -25
  631. package/src/utils/transform-styles/postcss-urlrebase.d.ts +15 -0
  632. package/src/utils/transform-styles/types.ts +13 -0
  633. package/src/utils/types.ts +29 -0
  634. package/build/components/media-upload-progress/constants.cjs +0 -46
  635. package/build/components/media-upload-progress/constants.cjs.map +0 -7
  636. package/build/components/rich-text/native/format-edit.cjs +0 -60
  637. package/build/components/rich-text/native/format-edit.cjs.map +0 -7
  638. package/build/components/rich-text/native/index.cjs.map +0 -7
  639. package/build/components/rich-text/native/use-format-types.cjs +0 -139
  640. package/build/components/rich-text/native/use-format-types.cjs.map +0 -7
  641. package/build-module/components/media-upload-progress/constants.mjs +0 -16
  642. package/build-module/components/media-upload-progress/constants.mjs.map +0 -7
  643. package/build-module/components/rich-text/native/format-edit.mjs +0 -39
  644. package/build-module/components/rich-text/native/format-edit.mjs.map +0 -7
  645. package/build-module/components/rich-text/native/index.mjs +0 -7
  646. package/build-module/components/rich-text/native/index.mjs.map +0 -7
  647. package/build-module/components/rich-text/native/use-format-types.mjs +0 -114
  648. package/build-module/components/rich-text/native/use-format-types.mjs.map +0 -7
  649. package/src/components/audio-player/audio-url-parser.native.js +0 -20
  650. package/src/components/audio-player/index.native.js +0 -225
  651. package/src/components/audio-player/styles.native.scss +0 -114
  652. package/src/components/audio-player/test/audio-url-parser.native.js +0 -53
  653. package/src/components/block-alignment-control/test/index.native.js +0 -37
  654. package/src/components/block-alignment-control/ui.native.js +0 -86
  655. package/src/components/block-caption/README.md +0 -104
  656. package/src/components/block-caption/index.native.js +0 -89
  657. package/src/components/block-caption/styles.native.scss +0 -7
  658. package/src/components/block-controls/slot.native.js +0 -33
  659. package/src/components/block-draggable/draggable-chip.native.js +0 -49
  660. package/src/components/block-draggable/dropping-insertion-point.native.js +0 -181
  661. package/src/components/block-draggable/dropping-insertion-point.native.scss +0 -8
  662. package/src/components/block-draggable/index.native.js +0 -467
  663. package/src/components/block-draggable/style.native.scss +0 -19
  664. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +0 -73
  665. package/src/components/block-draggable/test/helpers.native.js +0 -182
  666. package/src/components/block-draggable/test/index.native.js +0 -419
  667. package/src/components/block-draggable/use-scroll-when-dragging.native.js +0 -135
  668. package/src/components/block-edit/edit.native.js +0 -49
  669. package/src/components/block-edit/test/edit.native.js +0 -65
  670. package/src/components/block-heading-level-dropdown/index.native.js +0 -68
  671. package/src/components/block-icon/index.native.js +0 -47
  672. package/src/components/block-icon/style.native.scss +0 -7
  673. package/src/components/block-list/block-crash-boundary.native.js +0 -43
  674. package/src/components/block-list/block-crash-warning.native.js +0 -21
  675. package/src/components/block-list/block-invalid-warning.native.js +0 -70
  676. package/src/components/block-list/block-list-context.native.js +0 -172
  677. package/src/components/block-list/block-list-item-cell.native.js +0 -62
  678. package/src/components/block-list/block-list-item.native.js +0 -209
  679. package/src/components/block-list/block-list-item.native.scss +0 -16
  680. package/src/components/block-list/block-outline.native.js +0 -77
  681. package/src/components/block-list/block-selection-button.native.js +0 -100
  682. package/src/components/block-list/block-selection-button.native.scss +0 -34
  683. package/src/components/block-list/block.native.js +0 -716
  684. package/src/components/block-list/block.native.scss +0 -62
  685. package/src/components/block-list/grid-item.native.js +0 -58
  686. package/src/components/block-list/index.native.js +0 -437
  687. package/src/components/block-list/insertion-point.native.js +0 -36
  688. package/src/components/block-list/style.native.scss +0 -117
  689. package/src/components/block-list/test/block-invalid-warning.native.js +0 -62
  690. package/src/components/block-list/test/block-list-context.native.js +0 -243
  691. package/src/components/block-list/test/block-outline.native.js +0 -255
  692. package/src/components/block-list/test/fixtures/block-list-context.native.js +0 -79
  693. package/src/components/block-list/test/index.native.js +0 -205
  694. package/src/components/block-list/use-block-props/index.native.js +0 -10
  695. package/src/components/block-list/use-scroll-upon-insertion.native.js +0 -52
  696. package/src/components/block-list-appender/index.native.js +0 -70
  697. package/src/components/block-list-appender/style.native.scss +0 -8
  698. package/src/components/block-media-update-progress/README.md +0 -100
  699. package/src/components/block-media-update-progress/index.native.js +0 -299
  700. package/src/components/block-media-update-progress/styles.native.scss +0 -9
  701. package/src/components/block-media-update-progress/test/index.native.js +0 -543
  702. package/src/components/block-mover/index.native.js +0 -193
  703. package/src/components/block-mover/mover-description.native.js +0 -155
  704. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -218
  705. package/src/components/block-mover/test/index.native.js +0 -186
  706. package/src/components/block-settings/button.native.js +0 -41
  707. package/src/components/block-settings/container.native.js +0 -91
  708. package/src/components/block-settings/container.native.scss +0 -4
  709. package/src/components/block-settings/index.native.js +0 -5
  710. package/src/components/block-styles/index.native.js +0 -94
  711. package/src/components/block-styles/preview.native.js +0 -109
  712. package/src/components/block-styles/style.native.scss +0 -64
  713. package/src/components/block-switcher/block-transformations-menu.native.js +0 -91
  714. package/src/components/block-toolbar/block-toolbar-menu.native.js +0 -477
  715. package/src/components/block-toolbar/index.native.js +0 -126
  716. package/src/components/block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap +0 -125
  717. package/src/components/block-toolbar/test/block-toolbar-menu.native.js +0 -405
  718. package/src/components/block-toolbar/test/index.native.js +0 -36
  719. package/src/components/block-types-list/index.native.js +0 -175
  720. package/src/components/block-types-list/style.native.scss +0 -25
  721. package/src/components/block-variation-picker/index.native.js +0 -107
  722. package/src/components/block-variation-picker/style.native.scss +0 -32
  723. package/src/components/button-block-appender/index.native.js +0 -92
  724. package/src/components/button-block-appender/styles.native.scss +0 -43
  725. package/src/components/caption/README.md +0 -44
  726. package/src/components/caption/index.native.js +0 -61
  727. package/src/components/colors-gradients/panel-color-gradient-settings.native.js +0 -59
  728. package/src/components/contrast-checker/index.native.js +0 -113
  729. package/src/components/contrast-checker/style.native.scss +0 -26
  730. package/src/components/convert-to-group-buttons/index.native.js +0 -79
  731. package/src/components/default-block-appender/index.native.js +0 -113
  732. package/src/components/default-block-appender/style.native.scss +0 -18
  733. package/src/components/floating-toolbar/floatingToolbar.android.scss +0 -4
  734. package/src/components/floating-toolbar/floatingToolbar.ios.scss +0 -3
  735. package/src/components/floating-toolbar/index.native.js +0 -141
  736. package/src/components/floating-toolbar/styles.native.scss +0 -43
  737. package/src/components/font-sizes/index.native.js +0 -7
  738. package/src/components/global-styles/color-panel.native.js +0 -207
  739. package/src/components/global-styles/test/use-global-styles-context.native.js +0 -435
  740. package/src/components/global-styles/use-global-styles-context.native.js +0 -592
  741. package/src/components/gradients/index.native.js +0 -2
  742. package/src/components/image-link-destinations/index.native.js +0 -152
  743. package/src/components/image-link-destinations/style.native.scss +0 -16
  744. package/src/components/index.native.js +0 -108
  745. package/src/components/inner-blocks/constants.native.js +0 -5
  746. package/src/components/inner-blocks/index.native.js +0 -221
  747. package/src/components/inner-blocks/warning-max-depth-exceeded.native.js +0 -124
  748. package/src/components/inserter/block-types-tab.native.js +0 -76
  749. package/src/components/inserter/hooks/use-block-type-impressions.native.js +0 -47
  750. package/src/components/inserter/hooks/use-clipboard-block.native.js +0 -40
  751. package/src/components/inserter/index.native.js +0 -424
  752. package/src/components/inserter/menu.native.js +0 -237
  753. package/src/components/inserter/no-results.native.js +0 -49
  754. package/src/components/inserter/reusable-blocks-tab.native.js +0 -45
  755. package/src/components/inserter/search-results.native.js +0 -67
  756. package/src/components/inserter/style.native.scss +0 -83
  757. package/src/components/inserter/tabs.native.js +0 -152
  758. package/src/components/inserter/test/__snapshots__/index.native.js.snap +0 -117
  759. package/src/components/inserter/test/fixtures/index.native.js +0 -12
  760. package/src/components/inserter/test/index.native.js +0 -273
  761. package/src/components/inserter/test/reusable-blocks-tab.native.js +0 -62
  762. package/src/components/inserter/test/utils.native.js +0 -37
  763. package/src/components/inserter/utils.native.js +0 -46
  764. package/src/components/inserter-button/index.native.js +0 -108
  765. package/src/components/inserter-button/style.native.scss +0 -72
  766. package/src/components/inspector-controls/fill.native.js +0 -62
  767. package/src/components/inspector-controls/slot.native.js +0 -35
  768. package/src/components/inspector-controls-tabs/advanced-controls-panel.native.js +0 -31
  769. package/src/components/line-height-control/index.native.js +0 -28
  770. package/src/components/media-placeholder/index.native.js +0 -258
  771. package/src/components/media-placeholder/styles.native.scss +0 -108
  772. package/src/components/media-replace-flow/index.native.js +0 -12
  773. package/src/components/media-upload/constants.native.js +0 -14
  774. package/src/components/media-upload/index.native.js +0 -356
  775. package/src/components/media-upload/style.native.scss +0 -4
  776. package/src/components/media-upload/test/index.native.js +0 -172
  777. package/src/components/media-upload-progress/README.md +0 -100
  778. package/src/components/media-upload-progress/constants.js +0 -6
  779. package/src/components/media-upload-progress/index.native.js +0 -233
  780. package/src/components/media-upload-progress/styles.native.scss +0 -15
  781. package/src/components/media-upload-progress/test/index.native.js +0 -220
  782. package/src/components/plain-text/index.native.js +0 -164
  783. package/src/components/plain-text/style.native.scss +0 -10
  784. package/src/components/provider/index.native.js +0 -32
  785. package/src/components/rich-text/embed-handler-picker.native.js +0 -65
  786. package/src/components/rich-text/file-paste-handler.native.js +0 -3
  787. package/src/components/rich-text/format-toolbar/index.native.js +0 -21
  788. package/src/components/rich-text/format-toolbar-container.native.js +0 -16
  789. package/src/components/rich-text/index.native.js +0 -701
  790. package/src/components/rich-text/input-event.native.js +0 -10
  791. package/src/components/rich-text/native/format-edit.js +0 -44
  792. package/src/components/rich-text/native/get-format-colors.native.js +0 -47
  793. package/src/components/rich-text/native/index.js +0 -1
  794. package/src/components/rich-text/native/index.native.js +0 -1389
  795. package/src/components/rich-text/native/style.native.scss +0 -28
  796. package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +0 -79
  797. package/src/components/rich-text/native/test/index.native.js +0 -345
  798. package/src/components/rich-text/native/test/performance/rich-text.native.js +0 -44
  799. package/src/components/rich-text/native/toolbar-button-with-options.native.js +0 -61
  800. package/src/components/rich-text/native/use-format-types.js +0 -146
  801. package/src/components/rich-text/remove-browser-shortcuts.native.js +0 -1
  802. package/src/components/rich-text/shortcut.native.js +0 -10
  803. package/src/components/ungroup-button/README.md +0 -23
  804. package/src/components/ungroup-button/index.native.js +0 -77
  805. package/src/components/unsupported-block-details/index.native.js +0 -187
  806. package/src/components/unsupported-block-details/style.native.scss +0 -56
  807. package/src/components/url-input/index.native.js +0 -33
  808. package/src/components/use-block-drop-zone/index.native.js +0 -207
  809. package/src/components/use-on-block-drop/index.native.js +0 -115
  810. package/src/components/use-unsupported-block-editor/index.native.js +0 -59
  811. package/src/components/video-player/gridicon-play.native.js +0 -13
  812. package/src/components/video-player/index.native.js +0 -133
  813. package/src/components/video-player/styles.native.scss +0 -29
  814. package/src/components/warning/index.native.js +0 -64
  815. package/src/components/warning/style.native.scss +0 -47
  816. package/src/hooks/align.native.js +0 -49
  817. package/src/hooks/custom-class-name.native.js +0 -70
  818. package/src/hooks/index.native.js +0 -36
  819. package/src/hooks/layout.native.js +0 -23
  820. package/src/hooks/test/__snapshots__/align.native.js.snap +0 -73
  821. package/src/hooks/test/__snapshots__/anchor.native.js.snap +0 -7
  822. package/src/hooks/test/align.native.js +0 -134
  823. package/src/hooks/test/anchor.native.js +0 -32
  824. package/src/hooks/test/use-editor-wrapper-styles.native.js +0 -282
  825. package/src/hooks/typography.native.js +0 -60
  826. package/src/hooks/use-editor-wrapper-styles.native.js +0 -250
  827. package/src/hooks/use-editor-wrapper-styles.native.scss +0 -12
  828. package/src/index.native.js +0 -6
  829. package/src/private-apis.native.js +0 -21
  830. package/src/store/defaults.native.js +0 -23
  831. package/src/utils/block-bindings.js +0 -46
  832. package/src/utils/color-values.js +0 -28
  833. package/src/utils/object.js +0 -67
  834. package/src/utils/sorting.js +0 -54
  835. /package/src/utils/{get-px-from-css-unit.js → get-px-from-css-unit.ts} +0 -0
  836. /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__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 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 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\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\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\tupdateParent( blocksForParent, {\n\t\t\t\t\t\t\tselection: selectionForParent,\n\t\t\t\t\t\t} );\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,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BAAM,SAAS,WACZ,aAAa,QAAQ,mBAAmB;AAAA,cACxC,kBAAkB;AAAA,YAClB,IACA,CAAE;AAAA,cACF,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;",
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,mBAA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AAA,cACrB,gBAAgB;AAAA,cAChB,cAAc;AAAA,cACd,iBACC,sCAAsC;AAAA,YACxC;AAEA,kBAAM,qBAAqB,WACxB;AAAA,cACA;AAAA,cACA,aAAa;AAAA,YACb,IACA;AAEH,8BAAkB,QAAQ,SAAS;AAAA,cAClC;AAAA,YACD;AAEA,kBAAM,eAAe,eAClB,YAAY,UACZ,WAAW;AACd,kBAAM,gBAAgB;AAAA,cACrB,WAAW;AAAA,YACZ;AACA,gBAAK,qBAAqB,UAAW;AACpC,4BAAc,aAAa;AAAA,YAC5B;AACA,yBAAc,iBAAiB,aAAc;AAAA,UAC9C;AAEA,cACC,oBACA,CAAE,iBACF,mBAAmB,YACnB,CAAE,wBAAwB,SACzB;AAQD,kBAAM,SAAS,WACZ,aAAa,QAAQ,mBAAmB;AAAA,cACxC,kBAAkB;AAAA,YAClB,IACA,CAAE;AAAA,cACF,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
  }
@@ -1,8 +1,11 @@
1
1
  // packages/block-editor/src/components/rich-text/event-listeners/before-input-rules.js
2
2
  import { insert, isCollapsed } from "@wordpress/rich-text";
3
3
  import { applyFilters } from "@wordpress/hooks";
4
+ import { privateApis as composePrivateApis } from "@wordpress/compose";
4
5
  import { store as blockEditorStore } from "../../../store/index.mjs";
5
- var wrapSelectionSettings = ["`", '"', "'", "\u201C\u201D", "\u2018\u2019"];
6
+ import { unlock } from "../../../lock-unlock.mjs";
7
+ var { subscribeDelegatedListener } = unlock(composePrivateApis);
8
+ var wrapSelectionSettings = ["`", '"', "'", "“”", "‘’"];
6
9
  var before_input_rules_default = (props) => (element) => {
7
10
  function onInput(event) {
8
11
  const { inputType, data } = event;
@@ -47,10 +50,7 @@ var before_input_rules_default = (props) => (element) => {
47
50
  });
48
51
  event.preventDefault();
49
52
  }
50
- element.addEventListener("beforeinput", onInput);
51
- return () => {
52
- element.removeEventListener("beforeinput", onInput);
53
- };
53
+ return subscribeDelegatedListener(element, "beforeinput", onInput, true);
54
54
  };
55
55
  export {
56
56
  before_input_rules_default as default
@@ -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';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\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\telement.addEventListener( 'beforeinput', onInput );\n\treturn () => {\n\t\telement.removeEventListener( 'beforeinput', onInput );\n\t};\n};\n"],
5
- "mappings": ";AAGA,SAAS,QAAQ,mBAAmB;AACpC,SAAS,oBAAoB;AAK7B,SAAS,SAAS,wBAAwB;AAS1C,IAAM,wBAAwB,CAAE,KAAK,KAAK,KAAK,gBAAM,cAAK;AAE1D,IAAO,6BAAQ,CAAE,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ilters } 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,6 +1,9 @@
1
1
  // packages/block-editor/src/components/rich-text/event-listeners/delete.js
2
2
  import { DELETE, BACKSPACE } from "@wordpress/keycodes";
3
3
  import { isCollapsed, isEmpty } from "@wordpress/rich-text";
4
+ import { privateApis as composePrivateApis } from "@wordpress/compose";
5
+ import { unlock } from "../../../lock-unlock.mjs";
6
+ var { subscribeDelegatedListener } = unlock(composePrivateApis);
4
7
  var delete_default = (props) => (element) => {
5
8
  function onKeyDown(event) {
6
9
  const { keyCode } = event;
@@ -23,10 +26,7 @@ var delete_default = (props) => (element) => {
23
26
  event.preventDefault();
24
27
  }
25
28
  }
26
- element.addEventListener("keydown", onKeyDown);
27
- return () => {
28
- element.removeEventListener("keydown", onKeyDown);
29
- };
29
+ return subscribeDelegatedListener(element, "keydown", onKeyDown);
30
30
  };
31
31
  export {
32
32
  delete_default as default
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/rich-text/event-listeners/delete.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DELETE, BACKSPACE } from '@wordpress/keycodes';\nimport { isCollapsed, isEmpty } from '@wordpress/rich-text';\n\nexport default ( props ) => ( element ) => {\n\tfunction onKeyDown( event ) {\n\t\tconst { keyCode } = event;\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { value, onMerge, onRemove } = props.current;\n\n\t\tif ( keyCode === DELETE || keyCode === BACKSPACE ) {\n\t\t\tconst { start, end, text } = value;\n\t\t\tconst isReverse = keyCode === BACKSPACE;\n\t\t\tconst hasActiveFormats =\n\t\t\t\tvalue.activeFormats && !! value.activeFormats.length;\n\n\t\t\t// Only process delete if the key press occurs at an uncollapsed edge.\n\t\t\tif (\n\t\t\t\t! isCollapsed( value ) ||\n\t\t\t\thasActiveFormats ||\n\t\t\t\t( isReverse && start !== 0 ) ||\n\t\t\t\t( ! isReverse && end !== text.length )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( onMerge ) {\n\t\t\t\tonMerge( ! isReverse );\n\t\t\t}\n\n\t\t\t// Only handle remove on Backspace. This serves dual-purpose of being\n\t\t\t// an intentional user interaction distinguishing between Backspace and\n\t\t\t// Delete to remove the empty field, but also to avoid merge & remove\n\t\t\t// causing destruction of two fields (merge, then removed merged).\n\t\t\telse if ( onRemove && isEmpty( value ) && isReverse ) {\n\t\t\t\tonRemove( ! isReverse );\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\telement.addEventListener( 'keydown', onKeyDown );\n\treturn () => {\n\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t};\n};\n"],
5
- "mappings": ";AAGA,SAAS,QAAQ,iBAAiB;AAClC,SAAS,aAAa,eAAe;AAErC,IAAO,iBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,UAAW,OAAQ;AAC3B,UAAM,EAAE,QAAQ,IAAI;AAEpB,QAAK,MAAM,kBAAmB;AAC7B;AAAA,IACD;AAEA,UAAM,EAAE,OAAO,SAAS,SAAS,IAAI,MAAM;AAE3C,QAAK,YAAY,UAAU,YAAY,WAAY;AAClD,YAAM,EAAE,OAAO,KAAK,KAAK,IAAI;AAC7B,YAAM,YAAY,YAAY;AAC9B,YAAM,mBACL,MAAM,iBAAiB,CAAC,CAAE,MAAM,cAAc;AAG/C,UACC,CAAE,YAAa,KAAM,KACrB,oBACE,aAAa,UAAU,KACvB,CAAE,aAAa,QAAQ,KAAK,QAC7B;AACD;AAAA,MACD;AAEA,UAAK,SAAU;AACd,gBAAS,CAAE,SAAU;AAAA,MACtB,WAMU,YAAY,QAAS,KAAM,KAAK,WAAY;AACrD,iBAAU,CAAE,SAAU;AAAA,MACvB;AAEA,YAAM,eAAe;AAAA,IACtB;AAAA,EACD;AAEA,UAAQ,iBAAkB,WAAW,SAAU;AAC/C,SAAO,MAAM;AACZ,YAAQ,oBAAqB,WAAW,SAAU;AAAA,EACnD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DELETE, BACKSPACE } from '@wordpress/keycodes';\nimport { isCollapsed, isEmpty } from '@wordpress/rich-text';\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\nexport default ( props ) => ( element ) => {\n\tfunction onKeyDown( event ) {\n\t\tconst { keyCode } = event;\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { value, onMerge, onRemove } = props.current;\n\n\t\tif ( keyCode === DELETE || keyCode === BACKSPACE ) {\n\t\t\tconst { start, end, text } = value;\n\t\t\tconst isReverse = keyCode === BACKSPACE;\n\t\t\tconst hasActiveFormats =\n\t\t\t\tvalue.activeFormats && !! value.activeFormats.length;\n\n\t\t\t// Only process delete if the key press occurs at an uncollapsed edge.\n\t\t\tif (\n\t\t\t\t! isCollapsed( value ) ||\n\t\t\t\thasActiveFormats ||\n\t\t\t\t( isReverse && start !== 0 ) ||\n\t\t\t\t( ! isReverse && end !== text.length )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( onMerge ) {\n\t\t\t\tonMerge( ! isReverse );\n\t\t\t}\n\n\t\t\t// Only handle remove on Backspace. This serves dual-purpose of being\n\t\t\t// an intentional user interaction distinguishing between Backspace and\n\t\t\t// Delete to remove the empty field, but also to avoid merge & remove\n\t\t\t// causing destruction of two fields (merge, then removed merged).\n\t\t\telse if ( onRemove && isEmpty( value ) && isReverse ) {\n\t\t\t\tonRemove( ! isReverse );\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\treturn subscribeDelegatedListener( element, 'keydown', onKeyDown );\n};\n"],
5
+ "mappings": ";AAGA,SAAS,QAAQ,iBAAiB;AAClC,SAAS,aAAa,eAAe;AACrC,SAAS,eAAe,0BAA0B;AAKlD,SAAS,cAAc;AAEvB,IAAM,EAAE,2BAA2B,IAAI,OAAQ,kBAAmB;AAElE,IAAO,iBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,UAAW,OAAQ;AAC3B,UAAM,EAAE,QAAQ,IAAI;AAEpB,QAAK,MAAM,kBAAmB;AAC7B;AAAA,IACD;AAEA,UAAM,EAAE,OAAO,SAAS,SAAS,IAAI,MAAM;AAE3C,QAAK,YAAY,UAAU,YAAY,WAAY;AAClD,YAAM,EAAE,OAAO,KAAK,KAAK,IAAI;AAC7B,YAAM,YAAY,YAAY;AAC9B,YAAM,mBACL,MAAM,iBAAiB,CAAC,CAAE,MAAM,cAAc;AAG/C,UACC,CAAE,YAAa,KAAM,KACrB,oBACE,aAAa,UAAU,KACvB,CAAE,aAAa,QAAQ,KAAK,QAC7B;AACD;AAAA,MACD;AAEA,UAAK,SAAU;AACd,gBAAS,CAAE,SAAU;AAAA,MACtB,WAMU,YAAY,QAAS,KAAM,KAAK,WAAY;AACrD,iBAAU,CAAE,SAAU;AAAA,MACvB;AAEA,YAAM,eAAe;AAAA,IACtB;AAAA,EACD;AAEA,SAAO,2BAA4B,SAAS,WAAW,SAAU;AAClE;",
6
6
  "names": []
7
7
  }
@@ -62,10 +62,15 @@ var enter_default = (props) => (element) => {
62
62
  "keydown",
63
63
  onKeyDown
64
64
  );
65
- element.addEventListener("keydown", onKeyDownDeprecated);
65
+ const unsubscribeKeyDownDeprecated = subscribeDelegatedListener(
66
+ element,
67
+ "keydown",
68
+ onKeyDownDeprecated,
69
+ true
70
+ );
66
71
  return () => {
67
72
  unsubscribeKeyDown();
68
- element.removeEventListener("keydown", onKeyDownDeprecated);
73
+ unsubscribeKeyDownDeprecated();
69
74
  };
70
75
  };
71
76
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/rich-text/event-listeners/enter.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { ENTER } from '@wordpress/keycodes';\nimport { insert, remove } from '@wordpress/rich-text';\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\nexport default ( props ) => ( element ) => {\n\tfunction onKeyDownDeprecated( event ) {\n\t\tif ( event.keyCode !== ENTER ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { onReplace, onSplit } = props.current;\n\n\t\tif ( onReplace && onSplit ) {\n\t\t\tevent.__deprecatedOnSplit = true;\n\t\t}\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\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.\n\t\tif ( event.target !== element ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( event.keyCode !== ENTER ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst {\n\t\t\tvalue,\n\t\t\tonChange,\n\t\t\tdisableLineBreaks,\n\t\t\tonSplitAtEnd,\n\t\t\tonSplitAtDoubleLineEnd,\n\t\t\tregistry,\n\t\t} = props.current;\n\n\t\tevent.preventDefault();\n\n\t\tconst { text, start, end } = value;\n\n\t\tif ( event.shiftKey ) {\n\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\tonChange( insert( value, '\\n' ) );\n\t\t\t}\n\t\t} else if ( onSplitAtEnd && start === end && end === text.length ) {\n\t\t\tonSplitAtEnd();\n\t\t} else if (\n\t\t\t// For some blocks it's desirable to split at the end of the\n\t\t\t// block when there are two line breaks at the end of the\n\t\t\t// block, so triple Enter exits the block.\n\t\t\tonSplitAtDoubleLineEnd &&\n\t\t\tstart === end &&\n\t\t\tend === text.length &&\n\t\t\ttext.slice( -2 ) === '\\n\\n'\n\t\t) {\n\t\t\tregistry.batch( () => {\n\t\t\t\tconst _value = { ...value };\n\t\t\t\t_value.start = _value.end - 2;\n\t\t\t\tonChange( remove( _value ) );\n\t\t\t\tonSplitAtDoubleLineEnd();\n\t\t\t} );\n\t\t} else if ( ! disableLineBreaks ) {\n\t\t\tonChange( insert( value, '\\n' ) );\n\t\t}\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\tconst unsubscribeKeyDown = subscribeDelegatedListener(\n\t\tdefaultView,\n\t\t'keydown',\n\t\tonKeyDown\n\t);\n\telement.addEventListener( 'keydown', onKeyDownDeprecated );\n\treturn () => {\n\t\tunsubscribeKeyDown();\n\t\telement.removeEventListener( 'keydown', onKeyDownDeprecated );\n\t};\n};\n"],
5
- "mappings": ";AAGA,SAAS,aAAa;AACtB,SAAS,QAAQ,cAAc;AAC/B,SAAS,eAAe,0BAA0B;AAKlD,SAAS,cAAc;AAEvB,IAAM,EAAE,2BAA2B,IAAI,OAAQ,kBAAmB;AAElE,IAAO,gBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,oBAAqB,OAAQ;AACrC,QAAK,MAAM,YAAY,OAAQ;AAC9B;AAAA,IACD;AAEA,UAAM,EAAE,WAAW,QAAQ,IAAI,MAAM;A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ert, remove } from '@wordpress/rich-text';\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\nexport default ( props ) => ( element ) => {\n\tfunction onKeyDownDeprecated( event ) {\n\t\tif ( event.keyCode !== ENTER ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { onReplace, onSplit } = props.current;\n\n\t\tif ( onReplace && onSplit ) {\n\t\t\tevent.__deprecatedOnSplit = true;\n\t\t}\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\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.\n\t\tif ( event.target !== element ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( event.keyCode !== ENTER ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst {\n\t\t\tvalue,\n\t\t\tonChange,\n\t\t\tdisableLineBreaks,\n\t\t\tonSplitAtEnd,\n\t\t\tonSplitAtDoubleLineEnd,\n\t\t\tregistry,\n\t\t} = props.current;\n\n\t\tevent.preventDefault();\n\n\t\tconst { text, start, end } = value;\n\n\t\tif ( event.shiftKey ) {\n\t\t\tif ( ! disableLineBreaks ) {\n\t\t\t\tonChange( insert( value, '\\n' ) );\n\t\t\t}\n\t\t} else if ( onSplitAtEnd && start === end && end === text.length ) {\n\t\t\tonSplitAtEnd();\n\t\t} else if (\n\t\t\t// For some blocks it's desirable to split at the end of the\n\t\t\t// block when there are two line breaks at the end of the\n\t\t\t// block, so triple Enter exits the block.\n\t\t\tonSplitAtDoubleLineEnd &&\n\t\t\tstart === end &&\n\t\t\tend === text.length &&\n\t\t\ttext.slice( -2 ) === '\\n\\n'\n\t\t) {\n\t\t\tregistry.batch( () => {\n\t\t\t\tconst _value = { ...value };\n\t\t\t\t_value.start = _value.end - 2;\n\t\t\t\tonChange( remove( _value ) );\n\t\t\t\tonSplitAtDoubleLineEnd();\n\t\t\t} );\n\t\t} else if ( ! disableLineBreaks ) {\n\t\t\tonChange( insert( value, '\\n' ) );\n\t\t}\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\tconst unsubscribeKeyDown = subscribeDelegatedListener(\n\t\tdefaultView,\n\t\t'keydown',\n\t\tonKeyDown\n\t);\n\t// Capture phase so this runs before ancestor (writing flow) bubble\n\t// handlers, matching the timing of the previous raw element listener.\n\tconst unsubscribeKeyDownDeprecated = subscribeDelegatedListener(\n\t\telement,\n\t\t'keydown',\n\t\tonKeyDownDeprecated,\n\t\ttrue\n\t);\n\treturn () => {\n\t\tunsubscribeKeyDown();\n\t\tunsubscribeKeyDownDeprecated();\n\t};\n};\n"],
5
+ "mappings": ";AAGA,SAAS,aAAa;AACtB,SAAS,QAAQ,cAAc;AAC/B,SAAS,eAAe,0BAA0B;AAKlD,SAAS,cAAc;AAEvB,IAAM,EAAE,2BAA2B,IAAI,OAAQ,kBAAmB;AAElE,IAAO,gBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,oBAAqB,OAAQ;AACrC,QAAK,MAAM,YAAY,OAAQ;AAC9B;AAAA,IACD;AAEA,UAAM,EAAE,WAAW,QAAQ,IAAI,MAAM;AAErC,QAAK,aAAa,SAAU;AAC3B,YAAM,sBAAsB;AAAA,IAC7B;AAAA,EACD;AAEA,WAAS,UAAW,OAAQ;AAC3B,QAAK,MAAM,kBAAmB;AAC7B;AAAA,IACD;AAIA,QAAK,MAAM,WAAW,SAAU;AAC/B;AAAA,IACD;AAEA,QAAK,MAAM,YAAY,OAAQ;AAC9B;AAAA,IACD;AAEA,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,IAAI,MAAM;AAEV,UAAM,eAAe;AAErB,UAAM,EAAE,MAAM,OAAO,IAAI,IAAI;AAE7B,QAAK,MAAM,UAAW;AACrB,UAAK,CAAE,mBAAoB;AAC1B,iBAAU,OAAQ,OAAO,IAAK,CAAE;AAAA,MACjC;AAAA,IACD,WAAY,gBAAgB,UAAU,OAAO,QAAQ,KAAK,QAAS;AAClE,mBAAa;AAAA,IACd;AAAA;AAAA;AAAA;AAAA,MAIC,0BACA,UAAU,OACV,QAAQ,KAAK,UACb,KAAK,MAAO,EAAG,MAAM;AAAA,MACpB;AACD,eAAS,MAAO,MAAM;AACrB,cAAM,SAAS,EAAE,GAAG,MAAM;AAC1B,eAAO,QAAQ,OAAO,MAAM;AAC5B,iBAAU,OAAQ,MAAO,CAAE;AAC3B,+BAAuB;AAAA,MACxB,CAAE;AAAA,IACH,WAAY,CAAE,mBAAoB;AACjC,eAAU,OAAQ,OAAO,IAAK,CAAE;AAAA,IACjC;AAAA,EACD;AAEA,QAAM,EAAE,YAAY,IAAI,QAAQ;AAIhC,QAAM,qBAAqB;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAGA,QAAM,+BAA+B;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,SAAO,MAAM;AACZ,uBAAmB;AACnB,iCAA6B;AAAA,EAC9B;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,7 @@
1
1
  // packages/block-editor/src/components/rich-text/event-listeners/input-events.js
2
+ import { privateApis as composePrivateApis } from "@wordpress/compose";
3
+ import { unlock } from "../../../lock-unlock.mjs";
4
+ var { subscribeDelegatedListener } = unlock(composePrivateApis);
2
5
  var input_events_default = (props) => (element) => {
3
6
  const { inputEvents } = props.current;
4
7
  function onInput(event) {
@@ -6,10 +9,7 @@ var input_events_default = (props) => (element) => {
6
9
  keyboardShortcut(event);
7
10
  }
8
11
  }
9
- element.addEventListener("input", onInput);
10
- return () => {
11
- element.removeEventListener("input", onInput);
12
- };
12
+ return subscribeDelegatedListener(element, "input", onInput);
13
13
  };
14
14
  export {
15
15
  input_events_default as default
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/rich-text/event-listeners/input-events.js"],
4
- "sourcesContent": ["export default ( props ) => ( element ) => {\n\tconst { inputEvents } = props.current;\n\tfunction onInput( event ) {\n\t\tfor ( const keyboardShortcut of inputEvents.current ) {\n\t\t\tkeyboardShortcut( event );\n\t\t}\n\t}\n\n\telement.addEventListener( 'input', onInput );\n\treturn () => {\n\t\telement.removeEventListener( 'input', onInput );\n\t};\n};\n"],
5
- "mappings": ";AAAA,IAAO,uBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,QAAM,EAAE,YAAY,IAAI,MAAM;AAC9B,WAAS,QAAS,OAAQ;AACzB,eAAY,oBAAoB,YAAY,SAAU;AACrD,uBAAkB,KAAM;AAAA,IACzB;AAAA,EACD;AAEA,UAAQ,iBAAkB,SAAS,OAAQ;AAC3C,SAAO,MAAM;AACZ,YAAQ,oBAAqB,SAAS,OAAQ;AAAA,EAC/C;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\nexport default ( props ) => ( element ) => {\n\tconst { inputEvents } = props.current;\n\tfunction onInput( event ) {\n\t\tfor ( const keyboardShortcut of inputEvents.current ) {\n\t\t\tkeyboardShortcut( event );\n\t\t}\n\t}\n\n\treturn subscribeDelegatedListener( element, 'input', onInput );\n};\n"],
5
+ "mappings": ";AAGA,SAAS,eAAe,0BAA0B;AAKlD,SAAS,cAAc;AAEvB,IAAM,EAAE,2BAA2B,IAAI,OAAQ,kBAAmB;AAElE,IAAO,uBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,QAAM,EAAE,YAAY,IAAI,MAAM;AAC9B,WAAS,QAAS,OAAQ;AACzB,eAAY,oBAAoB,YAAY,SAAU;AACrD,uBAAkB,KAAM;AAAA,IACzB;AAAA,EACD;AAEA,SAAO,2BAA4B,SAAS,SAAS,OAAQ;AAC9D;",
6
6
  "names": []
7
7
  }
@@ -1,12 +1,15 @@
1
1
  // packages/block-editor/src/components/rich-text/event-listeners/input-rules.js
2
2
  import { insert, toHTMLString } from "@wordpress/rich-text";
3
3
  import { getBlockTransforms, findTransform } from "@wordpress/blocks";
4
+ import { privateApis as composePrivateApis } from "@wordpress/compose";
4
5
  import { store as blockEditorStore } from "../../../store/index.mjs";
5
6
  import { preventEventDiscovery } from "../prevent-event-discovery.mjs";
6
7
  import {
7
8
  retrieveSelectedAttribute,
8
9
  START_OF_SELECTED_AREA
9
10
  } from "../../../utils/selection.mjs";
11
+ import { unlock } from "../../../lock-unlock.mjs";
12
+ var { subscribeDelegatedListener } = unlock(composePrivateApis);
10
13
  function findSelection(blocks) {
11
14
  let i = blocks.length;
12
15
  while (i--) {
@@ -108,11 +111,21 @@ var input_rules_default = (props) => (element) => {
108
111
  __unstableMarkAutomaticChange();
109
112
  }
110
113
  }
111
- element.addEventListener("input", onInput);
112
- element.addEventListener("compositionend", onInput);
114
+ const unsubscribeInput = subscribeDelegatedListener(
115
+ element,
116
+ "input",
117
+ onInput,
118
+ true
119
+ );
120
+ const unsubscribeCompositionEnd = subscribeDelegatedListener(
121
+ element,
122
+ "compositionend",
123
+ onInput,
124
+ true
125
+ );
113
126
  return () => {
114
- element.removeEventListener("input", onInput);
115
- element.removeEventListener("compositionend", onInput);
127
+ unsubscribeInput();
128
+ unsubscribeCompositionEnd();
116
129
  };
117
130
  };
118
131
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/rich-text/event-listeners/input-rules.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { insert, toHTMLString } from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { preventEventDiscovery } from '../prevent-event-discovery';\nimport {\n\tretrieveSelectedAttribute,\n\tSTART_OF_SELECTED_AREA,\n} from '../../../utils/selection';\n\nexport function findSelection( blocks ) {\n\tlet i = blocks.length;\n\n\twhile ( i-- ) {\n\t\tconst attributeKey = retrieveSelectedAttribute(\n\t\t\tblocks[ i ].attributes\n\t\t);\n\n\t\tif ( attributeKey ) {\n\t\t\tblocks[ i ].attributes[ attributeKey ] = blocks[ i ].attributes[\n\t\t\t\tattributeKey\n\t\t\t]\n\t\t\t\t// To do: refactor this to use rich text's selection instead, so\n\t\t\t\t// we no longer have to use on this hack inserting a special\n\t\t\t\t// character.\n\t\t\t\t.toString()\n\t\t\t\t.replace( START_OF_SELECTED_AREA, '' );\n\t\t\treturn [ blocks[ i ].clientId, attributeKey, 0, 0 ];\n\t\t}\n\n\t\tconst nestedSelection = findSelection( blocks[ i ].innerBlocks );\n\n\t\tif ( nestedSelection ) {\n\t\t\treturn nestedSelection;\n\t\t}\n\t}\n\n\treturn [];\n}\n\nexport default ( props ) => ( element ) => {\n\tfunction inputRule() {\n\t\tconst { getValue, onReplace, selectionChange, registry } =\n\t\t\tprops.current;\n\n\t\tif ( ! onReplace ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We must use getValue() here because value may be update\n\t\t// asynchronously.\n\t\tconst value = getValue();\n\t\tconst { start, text } = value;\n\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t// The character right before the caret must be a plain space.\n\t\tif ( characterBefore !== ' ' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst trimmedTextBefore = text.slice( 0, start ).trim();\n\t\tconst prefixTransforms = getBlockTransforms( 'from' ).filter(\n\t\t\t( { type } ) => type === 'prefix'\n\t\t);\n\t\tconst transformation = findTransform(\n\t\t\tprefixTransforms,\n\t\t\t( { prefix } ) => {\n\t\t\t\treturn trimmedTextBefore === prefix;\n\t\t\t}\n\t\t);\n\n\t\tif ( ! transformation ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst content = toHTMLString( {\n\t\t\tvalue: insert( value, START_OF_SELECTED_AREA, 0, start ),\n\t\t} );\n\t\tconst block = transformation.transform( content );\n\n\t\tselectionChange( ...findSelection( [ block ] ) );\n\t\tonReplace( [ block ] );\n\t\tregistry.dispatch( blockEditorStore ).__unstableMarkAutomaticChange();\n\n\t\treturn true;\n\t}\n\n\tfunction onInput( event ) {\n\t\tconst { inputType, type } = event;\n\t\tconst {\n\t\t\tgetValue,\n\t\t\tonChange,\n\t\t\t__unstableAllowPrefixTransformations,\n\t\t\tformatTypes,\n\t\t\tregistry,\n\t\t\tonReplace,\n\t\t} = props.current;\n\n\t\t// Only run input rules when inserting text.\n\t\tif ( inputType !== 'insertText' && type !== 'compositionend' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( __unstableAllowPrefixTransformations && inputRule() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst value = getValue();\n\n\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t( transform ) => transform.type === 'input'\n\t\t);\n\t\tconst transformation = findTransform( transforms, ( item ) => {\n\t\t\treturn item.regExp.test( value.text );\n\t\t} );\n\n\t\tif ( transformation ) {\n\t\t\tonReplace( transformation.transform() );\n\t\t\tregistry\n\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t.__unstableMarkAutomaticChange();\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformed = formatTypes.reduce(\n\t\t\t( accumulator, { __unstableInputRule } ) => {\n\t\t\t\tif ( __unstableInputRule ) {\n\t\t\t\t\taccumulator = __unstableInputRule( accumulator );\n\t\t\t\t}\n\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\tpreventEventDiscovery( value )\n\t\t);\n\n\t\tconst {\n\t\t\t__unstableMarkLastChangeAsPersistent,\n\t\t\t__unstableMarkAutomaticChange,\n\t\t} = registry.dispatch( blockEditorStore );\n\n\t\tif ( transformed !== value ) {\n\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\tonChange( {\n\t\t\t\t...transformed,\n\t\t\t\tactiveFormats: value.activeFormats,\n\t\t\t} );\n\t\t\t__unstableMarkAutomaticChange();\n\t\t}\n\t}\n\n\telement.addEventListener( 'input', onInput );\n\telement.addEventListener( 'compositionend', onInput );\n\treturn () => {\n\t\telement.removeEventListener( 'input', onInput );\n\t\telement.removeEventListener( 'compositionend', onInput );\n\t};\n};\n"],
5
- "mappings": ";AAGA,SAAS,QAAQ,oBAAoB;AACrC,SAAS,oBAAoB,qBAAqB;AAKlD,SAAS,SAAS,wBAAwB;AAC1C,SAAS,6BAA6B;AACtC;AAAA,EACC;AAAA,EACA;AAAA,OACM;AAEA,SAAS,cAAe,QAAS;AACvC,MAAI,IAAI,OAAO;AAEf,SAAQ,KAAM;AACb,UAAM,eAAe;AAAA,MACpB,OAAQ,CAAE,EAAE;AAAA,IACb;AAEA,QAAK,cAAe;AACnB,aAAQ,CAAE,EAAE,WAAY,YAAa,IAAI,OAAQ,CAAE,EAAE,WACpD,YACD,EAIE,SAAS,EACT,QAAS,wBAAwB,EAAG;AACtC,aAAO,CAAE,OAAQ,CAAE,EAAE,UAAU,cAAc,GAAG,CAAE;AAAA,IACnD;AAEA,UAAM,kBAAkB,cAAe,OAAQ,CAAE,EAAE,WAAY;AAE/D,QAAK,iBAAkB;AACtB,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO,CAAC;AACT;AAEA,IAAO,sBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,YAAY;AACpB,UAAM,EAAE,UAAU,WAAW,iBAAiB,SAAS,IACtD,MAAM;AAEP,QAAK,CAAE,WAAY;AAClB;AAAA,IACD;AAIA,UAAM,QAAQ,SAAS;AACvB,UAAM,EAAE,OAAO,KAAK,IAAI;AACxB,UAAM,kBAAkB,KAAK,MAAO,QAAQ,GAAG,KAAM;AAGrD,QAAK,oBAAoB,KAAM;AAC9B;AAAA,IACD;AAEA,UAAM,oBAAoB,KAAK,MAAO,GAAG,KAAM,EAAE,KAAK;AACtD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oBAAqB,WAAY;AAAA,QAChD;AAEA,eAAO;AAAA,MACR;AAAA,MACA,sBAAuB,KAAM;AAAA,IAC9B;AAEA,UAAM;AAAA,MACL;AAAA,MACA;AAAA,IACD,IAAI,SAAS,SAAU,gBAAiB;AAExC,QAAK,gBAAgB,OAAQ;AAC5B,2CAAqC;AACrC,eAAU;AAAA,QACT,GAAG;AAAA,QACH,eAAe,MAAM;AAAA,MACtB,CAAE;AACF,oCAA8B;AAAA,IAC/B;AAAA,EACD;AAEA,UAAQ,iBAAkB,SAAS,OAAQ;AAC3C,UAAQ,iBAAkB,kBAAkB,OAAQ;AACpD,SAAO,MAAM;AACZ,YAAQ,oBAAqB,SAAS,OAAQ;AAC9C,YAAQ,oBAAqB,kBAAkB,OAAQ;AAAA,EACxD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { insert, toHTMLString } from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { preventEventDiscovery } from '../prevent-event-discovery';\nimport {\n\tretrieveSelectedAttribute,\n\tSTART_OF_SELECTED_AREA,\n} from '../../../utils/selection';\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\nexport function findSelection( blocks ) {\n\tlet i = blocks.length;\n\n\twhile ( i-- ) {\n\t\tconst attributeKey = retrieveSelectedAttribute(\n\t\t\tblocks[ i ].attributes\n\t\t);\n\n\t\tif ( attributeKey ) {\n\t\t\tblocks[ i ].attributes[ attributeKey ] = blocks[ i ].attributes[\n\t\t\t\tattributeKey\n\t\t\t]\n\t\t\t\t// To do: refactor this to use rich text's selection instead, so\n\t\t\t\t// we no longer have to use on this hack inserting a special\n\t\t\t\t// character.\n\t\t\t\t.toString()\n\t\t\t\t.replace( START_OF_SELECTED_AREA, '' );\n\t\t\treturn [ blocks[ i ].clientId, attributeKey, 0, 0 ];\n\t\t}\n\n\t\tconst nestedSelection = findSelection( blocks[ i ].innerBlocks );\n\n\t\tif ( nestedSelection ) {\n\t\t\treturn nestedSelection;\n\t\t}\n\t}\n\n\treturn [];\n}\n\nexport default ( props ) => ( element ) => {\n\tfunction inputRule() {\n\t\tconst { getValue, onReplace, selectionChange, registry } =\n\t\t\tprops.current;\n\n\t\tif ( ! onReplace ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We must use getValue() here because value may be update\n\t\t// asynchronously.\n\t\tconst value = getValue();\n\t\tconst { start, text } = value;\n\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t// The character right before the caret must be a plain space.\n\t\tif ( characterBefore !== ' ' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst trimmedTextBefore = text.slice( 0, start ).trim();\n\t\tconst prefixTransforms = getBlockTransforms( 'from' ).filter(\n\t\t\t( { type } ) => type === 'prefix'\n\t\t);\n\t\tconst transformation = findTransform(\n\t\t\tprefixTransforms,\n\t\t\t( { prefix } ) => {\n\t\t\t\treturn trimmedTextBefore === prefix;\n\t\t\t}\n\t\t);\n\n\t\tif ( ! transformation ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst content = toHTMLString( {\n\t\t\tvalue: insert( value, START_OF_SELECTED_AREA, 0, start ),\n\t\t} );\n\t\tconst block = transformation.transform( content );\n\n\t\tselectionChange( ...findSelection( [ block ] ) );\n\t\tonReplace( [ block ] );\n\t\tregistry.dispatch( blockEditorStore ).__unstableMarkAutomaticChange();\n\n\t\treturn true;\n\t}\n\n\tfunction onInput( event ) {\n\t\tconst { inputType, type } = event;\n\t\tconst {\n\t\t\tgetValue,\n\t\t\tonChange,\n\t\t\t__unstableAllowPrefixTransformations,\n\t\t\tformatTypes,\n\t\t\tregistry,\n\t\t\tonReplace,\n\t\t} = props.current;\n\n\t\t// Only run input rules when inserting text.\n\t\tif ( inputType !== 'insertText' && type !== 'compositionend' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( __unstableAllowPrefixTransformations && inputRule() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst value = getValue();\n\n\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t( transform ) => transform.type === 'input'\n\t\t);\n\t\tconst transformation = findTransform( transforms, ( item ) => {\n\t\t\treturn item.regExp.test( value.text );\n\t\t} );\n\n\t\tif ( transformation ) {\n\t\t\tonReplace( transformation.transform() );\n\t\t\tregistry\n\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t.__unstableMarkAutomaticChange();\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformed = formatTypes.reduce(\n\t\t\t( accumulator, { __unstableInputRule } ) => {\n\t\t\t\tif ( __unstableInputRule ) {\n\t\t\t\t\taccumulator = __unstableInputRule( accumulator );\n\t\t\t\t}\n\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\tpreventEventDiscovery( value )\n\t\t);\n\n\t\tconst {\n\t\t\t__unstableMarkLastChangeAsPersistent,\n\t\t\t__unstableMarkAutomaticChange,\n\t\t} = registry.dispatch( blockEditorStore );\n\n\t\tif ( transformed !== value ) {\n\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\tonChange( {\n\t\t\t\t...transformed,\n\t\t\t\tactiveFormats: value.activeFormats,\n\t\t\t} );\n\t\t\t__unstableMarkAutomaticChange();\n\t\t}\n\t}\n\n\t// Capture phase so these run before ancestor (writing flow) bubble\n\t// handlers, matching the timing of the previous raw element listeners.\n\tconst unsubscribeInput = subscribeDelegatedListener(\n\t\telement,\n\t\t'input',\n\t\tonInput,\n\t\ttrue\n\t);\n\tconst unsubscribeCompositionEnd = subscribeDelegatedListener(\n\t\telement,\n\t\t'compositionend',\n\t\tonInput,\n\t\ttrue\n\t);\n\treturn () => {\n\t\tunsubscribeInput();\n\t\tunsubscribeCompositionEnd();\n\t};\n};\n"],
5
+ "mappings": ";AAGA,SAAS,QAAQ,oBAAoB;AACrC,SAAS,oBAAoB,qBAAq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eAAU;AAAA,QACT,GAAG;AAAA,QACH,eAAe,MAAM;AAAA,MACtB,CAAE;AACF,oCAA8B;AAAA,IAC/B;AAAA,EACD;AAIA,QAAM,mBAAmB;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,QAAM,4BAA4B;AAAA,IACjC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,SAAO,MAAM;AACZ,qBAAiB;AACjB,8BAA0B;AAAA,EAC3B;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,8 @@
1
1
  // packages/block-editor/src/components/rich-text/event-listeners/insert-replacement-text.js
2
+ import { privateApis as composePrivateApis } from "@wordpress/compose";
2
3
  import { store as blockEditorStore } from "../../../store/index.mjs";
4
+ import { unlock } from "../../../lock-unlock.mjs";
5
+ var { subscribeDelegatedListener } = unlock(composePrivateApis);
3
6
  var insert_replacement_text_default = (props) => (element) => {
4
7
  function onInput(event) {
5
8
  if (event.inputType !== "insertReplacementText") {
@@ -8,10 +11,7 @@ var insert_replacement_text_default = (props) => (element) => {
8
11
  const { registry } = props.current;
9
12
  registry.dispatch(blockEditorStore).__unstableMarkLastChangeAsPersistent();
10
13
  }
11
- element.addEventListener("beforeinput", onInput);
12
- return () => {
13
- element.removeEventListener("beforeinput", onInput);
14
- };
14
+ return subscribeDelegatedListener(element, "beforeinput", onInput);
15
15
  };
16
16
  export {
17
17
  insert_replacement_text_default as default
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/rich-text/event-listeners/insert-replacement-text.js"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * When the browser is about to auto correct, add an undo level so the user can\n * revert the change.\n *\n * @param {Object} props\n */\nexport default ( props ) => ( element ) => {\n\tfunction onInput( event ) {\n\t\tif ( event.inputType !== 'insertReplacementText' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { registry } = props.current;\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t}\n\n\telement.addEventListener( 'beforeinput', onInput );\n\treturn () => {\n\t\telement.removeEventListener( 'beforeinput', onInput );\n\t};\n};\n"],
5
- "mappings": ";AAGA,SAAS,SAAS,wBAAwB;AAQ1C,IAAO,kCAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,QAAS,OAAQ;AACzB,QAAK,MAAM,cAAc,yBAA0B;AAClD;AAAA,IACD;AAEA,UAAM,EAAE,SAAS,IAAI,MAAM;AAC3B,aACE,SAAU,gBAAiB,EAC3B,qCAAqC;AAAA,EACxC;AAEA,UAAQ,iBAAkB,eAAe,OAAQ;AACjD,SAAO,MAAM;AACZ,YAAQ,oBAAqB,eAAe,OAAQ;AAAA,EACrD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\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 the browser is about to auto correct, add an undo level so the user can\n * revert the change.\n *\n * @param {Object} props\n */\nexport default ( props ) => ( element ) => {\n\tfunction onInput( event ) {\n\t\tif ( event.inputType !== 'insertReplacementText' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { registry } = props.current;\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t}\n\n\treturn subscribeDelegatedListener( element, 'beforeinput', onInput );\n};\n"],
5
+ "mappings": ";AAGA,SAAS,eAAe,0BAA0B;AAKlD,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AAEvB,IAAM,EAAE,2BAA2B,IAAI,OAAQ,kBAAmB;AAQlE,IAAO,kCAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,QAAS,OAAQ;AACzB,QAAK,MAAM,cAAc,yBAA0B;AAClD;AAAA,IACD;AAEA,UAAM,EAAE,SAAS,IAAI,MAAM;AAC3B,aACE,SAAU,gBAAiB,EAC3B,qCAAqC;AAAA,EACxC;AAEA,SAAO,2BAA4B,SAAS,eAAe,OAAQ;AACpE;",
6
6
  "names": []
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;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;AAAA,IAExB,WAAW,KAAM,gBAAiB,GACjC;AACD,aAAO;AAAA,IACR;AAEA,UAAM,UAAU,aAAc;AAAA,MAC7B,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAE;AAEF,QAAK,OAAO,YAAY,UAAW;AAClC,kBAAa,OAAQ;AACrB;AAAA,IACD;AAEA,QAAK,CAAE,QAAQ,UAAU,CAAE,aAAa,CAAE,QAAS,KAAM,GAAI;AAC5D;AAAA,IACD;AAIA,QAAK,SAAS,UAAW;AACxB,kBAAa,IAAK;AAClB,eACE,SAAU,gBAAiB,EAC3B,qCAAqC;AAAA,IACxC;AAEA,cAAW,SAAS,QAAQ,SAAS,GAAG,EAAG;AAAA,EAC5C;AAEA,QAAM,EAAE,YAAY,IAAI,QAAQ;AAIhC,SAAO,2BAA4B,aAAa,SAAS,QAAS;AACnE;",
6
6
  "names": ["content"]
7
7
  }
@@ -1,15 +1,15 @@
1
1
  // packages/block-editor/src/components/rich-text/event-listeners/remove-browser-shortcuts.js
2
2
  import { isKeyboardEvent } from "@wordpress/keycodes";
3
+ import { privateApis as composePrivateApis } from "@wordpress/compose";
4
+ import { unlock } from "../../../lock-unlock.mjs";
5
+ var { subscribeDelegatedListener } = unlock(composePrivateApis);
3
6
  var remove_browser_shortcuts_default = () => (node) => {
4
7
  function onKeydown(event) {
5
8
  if (isKeyboardEvent.primary(event, "z") || isKeyboardEvent.primary(event, "y") || isKeyboardEvent.primaryShift(event, "z")) {
6
9
  event.preventDefault();
7
10
  }
8
11
  }
9
- node.addEventListener("keydown", onKeydown);
10
- return () => {
11
- node.removeEventListener("keydown", onKeydown);
12
- };
12
+ return subscribeDelegatedListener(node, "keydown", onKeydown, true);
13
13
  };
14
14
  export {
15
15
  remove_browser_shortcuts_default as default
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/rich-text/event-listeners/remove-browser-shortcuts.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { isKeyboardEvent } from '@wordpress/keycodes';\n\n/**\n * Hook to prevent default behaviors for key combinations otherwise handled\n * internally by RichText.\n */\nexport default () => ( node ) => {\n\tfunction onKeydown( event ) {\n\t\tif (\n\t\t\tisKeyboardEvent.primary( event, 'z' ) ||\n\t\t\tisKeyboardEvent.primary( event, 'y' ) ||\n\t\t\tisKeyboardEvent.primaryShift( event, 'z' )\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\tnode.addEventListener( 'keydown', onKeydown );\n\treturn () => {\n\t\tnode.removeEventListener( 'keydown', onKeydown );\n\t};\n};\n"],
5
- "mappings": ";AAGA,SAAS,uBAAuB;AAMhC,IAAO,mCAAQ,MAAM,CAAE,SAAU;AAChC,WAAS,UAAW,OAAQ;AAC3B,QACC,gBAAgB,QAAS,OAAO,GAAI,KACpC,gBAAgB,QAAS,OAAO,GAAI,KACpC,gBAAgB,aAAc,OAAO,GAAI,GACxC;AACD,YAAM,eAAe;AAAA,IACtB;AAAA,EACD;AACA,OAAK,iBAAkB,WAAW,SAAU;AAC5C,SAAO,MAAM;AACZ,SAAK,oBAAqB,WAAW,SAAU;AAAA,EAChD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { isKeyboardEvent } from '@wordpress/keycodes';\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\n/**\n * Hook to prevent default behaviors for key combinations otherwise handled\n * internally by RichText.\n */\nexport default () => ( node ) => {\n\tfunction onKeydown( event ) {\n\t\tif (\n\t\t\tisKeyboardEvent.primary( event, 'z' ) ||\n\t\t\tisKeyboardEvent.primary( event, 'y' ) ||\n\t\t\tisKeyboardEvent.primaryShift( event, 'z' )\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\treturn subscribeDelegatedListener( node, 'keydown', onKeydown, true );\n};\n"],
5
+ "mappings": ";AAGA,SAAS,uBAAuB;AAChC,SAAS,eAAe,0BAA0B;AAKlD,SAAS,cAAc;AAEvB,IAAM,EAAE,2BAA2B,IAAI,OAAQ,kBAAmB;AAMlE,IAAO,mCAAQ,MAAM,CAAE,SAAU;AAChC,WAAS,UAAW,OAAQ;AAC3B,QACC,gBAAgB,QAAS,OAAO,GAAI,KACpC,gBAAgB,QAAS,OAAO,GAAI,KACpC,gBAAgB,aAAc,OAAO,GAAI,GACxC;AACD,YAAM,eAAe;AAAA,IACtB;AAAA,EACD;AACA,SAAO,2BAA4B,MAAM,WAAW,WAAW,IAAK;AACrE;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,7 @@
1
1
  // packages/block-editor/src/components/rich-text/event-listeners/shortcuts.js
2
+ import { privateApis as composePrivateApis } from "@wordpress/compose";
3
+ import { unlock } from "../../../lock-unlock.mjs";
4
+ var { subscribeDelegatedListener } = unlock(composePrivateApis);
2
5
  var shortcuts_default = (props) => (element) => {
3
6
  const { keyboardShortcuts } = props.current;
4
7
  function onKeyDown(event) {
@@ -6,10 +9,7 @@ var shortcuts_default = (props) => (element) => {
6
9
  keyboardShortcut(event);
7
10
  }
8
11
  }
9
- element.addEventListener("keydown", onKeyDown);
10
- return () => {
11
- element.removeEventListener("keydown", onKeyDown);
12
- };
12
+ return subscribeDelegatedListener(element, "keydown", onKeyDown, true);
13
13
  };
14
14
  export {
15
15
  shortcuts_default as default
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/rich-text/event-listeners/shortcuts.js"],
4
- "sourcesContent": ["export default ( props ) => ( element ) => {\n\tconst { keyboardShortcuts } = props.current;\n\tfunction onKeyDown( event ) {\n\t\tfor ( const keyboardShortcut of keyboardShortcuts.current ) {\n\t\t\tkeyboardShortcut( event );\n\t\t}\n\t}\n\n\telement.addEventListener( 'keydown', onKeyDown );\n\treturn () => {\n\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t};\n};\n"],
5
- "mappings": ";AAAA,IAAO,oBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,QAAM,EAAE,kBAAkB,IAAI,MAAM;AACpC,WAAS,UAAW,OAAQ;AAC3B,eAAY,oBAAoB,kBAAkB,SAAU;AAC3D,uBAAkB,KAAM;AAAA,IACzB;AAAA,EACD;AAEA,UAAQ,iBAAkB,WAAW,SAAU;AAC/C,SAAO,MAAM;AACZ,YAAQ,oBAAqB,WAAW,SAAU;AAAA,EACnD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\nexport default ( props ) => ( element ) => {\n\tconst { keyboardShortcuts } = props.current;\n\tfunction onKeyDown( event ) {\n\t\tfor ( const keyboardShortcut of keyboardShortcuts.current ) {\n\t\t\tkeyboardShortcut( event );\n\t\t}\n\t}\n\n\treturn subscribeDelegatedListener( element, 'keydown', onKeyDown, true );\n};\n"],
5
+ "mappings": ";AAGA,SAAS,eAAe,0BAA0B;AAKlD,SAAS,cAAc;AAEvB,IAAM,EAAE,2BAA2B,IAAI,OAAQ,kBAAmB;AAElE,IAAO,oBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,QAAM,EAAE,kBAAkB,IAAI,MAAM;AACpC,WAAS,UAAW,OAAQ;AAC3B,eAAY,oBAAoB,kBAAkB,SAAU;AAC3D,uBAAkB,KAAM;AAAA,IACzB;AAAA,EACD;AAEA,SAAO,2BAA4B,SAAS,WAAW,WAAW,IAAK;AACxE;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,9 @@
1
1
  // packages/block-editor/src/components/rich-text/event-listeners/undo-automatic-change.js
2
2
  import { BACKSPACE, ESCAPE } from "@wordpress/keycodes";
3
+ import { privateApis as composePrivateApis } from "@wordpress/compose";
3
4
  import { store as blockEditorStore } from "../../../store/index.mjs";
5
+ import { unlock } from "../../../lock-unlock.mjs";
6
+ var { subscribeDelegatedListener } = unlock(composePrivateApis);
4
7
  var undo_automatic_change_default = (props) => (element) => {
5
8
  function onKeyDown(event) {
6
9
  const { keyCode } = event;
@@ -22,10 +25,7 @@ var undo_automatic_change_default = (props) => (element) => {
22
25
  event.preventDefault();
23
26
  __experimentalUndo();
24
27
  }
25
- element.addEventListener("keydown", onKeyDown);
26
- return () => {
27
- element.removeEventListener("keydown", onKeyDown);
28
- };
28
+ return subscribeDelegatedListener(element, "keydown", onKeyDown);
29
29
  };
30
30
  export {
31
31
  undo_automatic_change_default as default
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/rich-text/event-listeners/undo-automatic-change.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { BACKSPACE, ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\nexport default ( props ) => ( element ) => {\n\tfunction onKeyDown( event ) {\n\t\tconst { keyCode } = event;\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( keyCode !== BACKSPACE && keyCode !== ESCAPE ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { registry } = props.current;\n\t\tconst { didAutomaticChange, getSettings } =\n\t\t\tregistry.select( blockEditorStore );\n\n\t\tconst { __experimentalUndo } = getSettings();\n\n\t\tif ( ! __experimentalUndo ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! didAutomaticChange() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tevent.preventDefault();\n\t\t__experimentalUndo();\n\t}\n\n\telement.addEventListener( 'keydown', onKeyDown );\n\treturn () => {\n\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t};\n};\n"],
5
- "mappings": ";AAGA,SAAS,WAAW,cAAc;AAKlC,SAAS,SAAS,wBAAwB;AAE1C,IAAO,gCAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,UAAW,OAAQ;AAC3B,UAAM,EAAE,QAAQ,IAAI;AAEpB,QAAK,MAAM,kBAAmB;AAC7B;AAAA,IACD;AAEA,QAAK,YAAY,aAAa,YAAY,QAAS;AAClD;AAAA,IACD;AAEA,UAAM,EAAE,SAAS,IAAI,MAAM;AAC3B,UAAM,EAAE,oBAAoB,YAAY,IACvC,SAAS,OAAQ,gBAAiB;AAEnC,UAAM,EAAE,mBAAmB,IAAI,YAAY;AAE3C,QAAK,CAAE,oBAAqB;AAC3B;AAAA,IACD;AAEA,QAAK,CAAE,mBAAmB,GAAI;AAC7B;AAAA,IACD;AAEA,UAAM,eAAe;AACrB,uBAAmB;AAAA,EACpB;AAEA,UAAQ,iBAAkB,WAAW,SAAU;AAC/C,SAAO,MAAM;AACZ,YAAQ,oBAAqB,WAAW,SAAU;AAAA,EACnD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { BACKSPACE, ESCAPE } from '@wordpress/keycodes';\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\nexport default ( props ) => ( element ) => {\n\tfunction onKeyDown( event ) {\n\t\tconst { keyCode } = event;\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( keyCode !== BACKSPACE && keyCode !== ESCAPE ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { registry } = props.current;\n\t\tconst { didAutomaticChange, getSettings } =\n\t\t\tregistry.select( blockEditorStore );\n\n\t\tconst { __experimentalUndo } = getSettings();\n\n\t\tif ( ! __experimentalUndo ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! didAutomaticChange() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tevent.preventDefault();\n\t\t__experimentalUndo();\n\t}\n\n\treturn subscribeDelegatedListener( element, 'keydown', onKeyDown );\n};\n"],
5
+ "mappings": ";AAGA,SAAS,WAAW,cAAc;AAClC,SAAS,eAAe,0BAA0B;AAKlD,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AAEvB,IAAM,EAAE,2BAA2B,IAAI,OAAQ,kBAAmB;AAElE,IAAO,gCAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,UAAW,OAAQ;AAC3B,UAAM,EAAE,QAAQ,IAAI;AAEpB,QAAK,MAAM,kBAAmB;AAC7B;AAAA,IACD;AAEA,QAAK,YAAY,aAAa,YAAY,QAAS;AAClD;AAAA,IACD;AAEA,UAAM,EAAE,SAAS,IAAI,MAAM;AAC3B,UAAM,EAAE,oBAAoB,YAAY,IACvC,SAAS,OAAQ,gBAAiB;AAEnC,UAAM,EAAE,mBAAmB,IAAI,YAAY;AAE3C,QAAK,CAAE,oBAAqB;AAC3B;AAAA,IACD;AAEA,QAAK,CAAE,mBAAmB,GAAI;AAC7B;AAAA,IACD;AAEA,UAAM,eAAe;AACrB,uBAAmB;AAAA,EACpB;AAEA,SAAO,2BAA4B,SAAS,WAAW,SAAU;AAClE;",
6
6
  "names": []
7
7
  }