@wordpress/block-editor 15.20.0 → 15.21.1

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 (430) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/build/components/block-compare/index.cjs +2 -2
  3. package/build/components/block-compare/index.cjs.map +2 -2
  4. package/build/components/block-list/use-block-props/index.cjs +1 -1
  5. package/build/components/block-list/use-block-props/index.cjs.map +2 -2
  6. package/build/components/block-patterns-list/index.cjs +1 -1
  7. package/build/components/block-patterns-list/index.cjs.map +2 -2
  8. package/build/components/block-switcher/block-transformations-menu.cjs +16 -15
  9. package/build/components/block-switcher/block-transformations-menu.cjs.map +2 -2
  10. package/build/components/block-switcher/index.cjs +4 -4
  11. package/build/components/block-switcher/index.cjs.map +2 -2
  12. package/build/components/child-layout-control/index.cjs +10 -5
  13. package/build/components/child-layout-control/index.cjs.map +2 -2
  14. package/build/components/global-styles/advanced-panel.cjs +23 -15
  15. package/build/components/global-styles/advanced-panel.cjs.map +2 -2
  16. package/build/components/global-styles/background-panel.cjs +2 -2
  17. package/build/components/global-styles/background-panel.cjs.map +2 -2
  18. package/build/components/global-styles/border-panel.cjs +2 -0
  19. package/build/components/global-styles/border-panel.cjs.map +2 -2
  20. package/build/components/global-styles/dimensions-panel.cjs +5 -4
  21. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  22. package/build/components/iframe/index.cjs +3 -0
  23. package/build/components/iframe/index.cjs.map +2 -2
  24. package/build/components/inner-blocks/use-inner-block-template-sync.cjs +3 -1
  25. package/build/components/inner-blocks/use-inner-block-template-sync.cjs.map +2 -2
  26. package/build/components/inserter/hooks/use-patterns-state.cjs +1 -1
  27. package/build/components/inserter/hooks/use-patterns-state.cjs.map +2 -2
  28. package/build/components/inserter/index.cjs +179 -220
  29. package/build/components/inserter/index.cjs.map +3 -3
  30. package/build/components/inserter/media-tab/utils.cjs +1 -1
  31. package/build/components/inserter/media-tab/utils.cjs.map +2 -2
  32. package/build/components/inserter/search-results.cjs +1 -1
  33. package/build/components/inserter/search-results.cjs.map +2 -2
  34. package/build/components/list-view/block-select-button.cjs +10 -12
  35. package/build/components/list-view/block-select-button.cjs.map +2 -2
  36. package/build/components/list-view/block.cjs +2 -1
  37. package/build/components/list-view/block.cjs.map +2 -2
  38. package/build/components/provider/use-block-sync.cjs +11 -2
  39. package/build/components/provider/use-block-sync.cjs.map +2 -2
  40. package/build/components/rich-text/event-listeners/before-input-rules.cjs +4 -4
  41. package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +3 -3
  42. package/build/components/rich-text/event-listeners/delete.cjs +4 -4
  43. package/build/components/rich-text/event-listeners/delete.cjs.map +3 -3
  44. package/build/components/rich-text/event-listeners/enter.cjs +7 -2
  45. package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
  46. package/build/components/rich-text/event-listeners/input-events.cjs +4 -4
  47. package/build/components/rich-text/event-listeners/input-events.cjs.map +3 -3
  48. package/build/components/rich-text/event-listeners/input-rules.cjs +17 -4
  49. package/build/components/rich-text/event-listeners/input-rules.cjs.map +3 -3
  50. package/build/components/rich-text/event-listeners/insert-replacement-text.cjs +4 -4
  51. package/build/components/rich-text/event-listeners/insert-replacement-text.cjs.map +3 -3
  52. package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs +4 -4
  53. package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs.map +3 -3
  54. package/build/components/rich-text/event-listeners/shortcuts.cjs +4 -4
  55. package/build/components/rich-text/event-listeners/shortcuts.cjs.map +3 -3
  56. package/build/components/rich-text/event-listeners/undo-automatic-change.cjs +4 -4
  57. package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +3 -3
  58. package/build/components/rich-text/index.cjs +1 -23
  59. package/build/components/rich-text/index.cjs.map +2 -2
  60. package/build/components/use-block-commands/index.cjs +5 -5
  61. package/build/components/use-block-commands/index.cjs.map +2 -2
  62. package/build/hooks/anchor.cjs +11 -15
  63. package/build/hooks/anchor.cjs.map +2 -2
  64. package/build/hooks/border.cjs +0 -3
  65. package/build/hooks/border.cjs.map +2 -2
  66. package/build/hooks/color.cjs +1 -4
  67. package/build/hooks/color.cjs.map +2 -2
  68. package/build/hooks/dimensions.cjs +0 -3
  69. package/build/hooks/dimensions.cjs.map +2 -2
  70. package/build/hooks/fit-text.cjs +11 -0
  71. package/build/hooks/fit-text.cjs.map +2 -2
  72. package/build/hooks/position.cjs +19 -22
  73. package/build/hooks/position.cjs.map +2 -2
  74. package/build/hooks/supports.cjs +0 -7
  75. package/build/hooks/supports.cjs.map +2 -2
  76. package/build/store/actions.cjs +7 -3
  77. package/build/store/actions.cjs.map +2 -2
  78. package/build/store/private-actions.cjs +1 -2
  79. package/build/store/private-actions.cjs.map +2 -2
  80. package/build/store/private-selectors.cjs +29 -0
  81. package/build/store/private-selectors.cjs.map +2 -2
  82. package/build/store/reducer.cjs +14 -6
  83. package/build/store/reducer.cjs.map +2 -2
  84. package/build/store/selectors.cjs +60 -41
  85. package/build/store/selectors.cjs.map +2 -2
  86. package/build-module/components/block-compare/index.mjs +1 -1
  87. package/build-module/components/block-compare/index.mjs.map +2 -2
  88. package/build-module/components/block-list/use-block-props/index.mjs +1 -1
  89. package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
  90. package/build-module/components/block-patterns-list/index.mjs +1 -1
  91. package/build-module/components/block-patterns-list/index.mjs.map +2 -2
  92. package/build-module/components/block-switcher/block-transformations-menu.mjs +16 -15
  93. package/build-module/components/block-switcher/block-transformations-menu.mjs.map +2 -2
  94. package/build-module/components/block-switcher/index.mjs +4 -4
  95. package/build-module/components/block-switcher/index.mjs.map +2 -2
  96. package/build-module/components/child-layout-control/index.mjs +10 -5
  97. package/build-module/components/child-layout-control/index.mjs.map +2 -2
  98. package/build-module/components/global-styles/advanced-panel.mjs +23 -15
  99. package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
  100. package/build-module/components/global-styles/background-panel.mjs +3 -3
  101. package/build-module/components/global-styles/background-panel.mjs.map +2 -2
  102. package/build-module/components/global-styles/border-panel.mjs +2 -0
  103. package/build-module/components/global-styles/border-panel.mjs.map +2 -2
  104. package/build-module/components/global-styles/dimensions-panel.mjs +9 -6
  105. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  106. package/build-module/components/iframe/index.mjs +3 -0
  107. package/build-module/components/iframe/index.mjs.map +2 -2
  108. package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs +3 -1
  109. package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs.map +2 -2
  110. package/build-module/components/inserter/hooks/use-patterns-state.mjs +1 -1
  111. package/build-module/components/inserter/hooks/use-patterns-state.mjs.map +2 -2
  112. package/build-module/components/inserter/index.mjs +185 -222
  113. package/build-module/components/inserter/index.mjs.map +3 -3
  114. package/build-module/components/inserter/media-tab/utils.mjs +1 -1
  115. package/build-module/components/inserter/media-tab/utils.mjs.map +2 -2
  116. package/build-module/components/inserter/search-results.mjs +1 -1
  117. package/build-module/components/inserter/search-results.mjs.map +2 -2
  118. package/build-module/components/list-view/block-select-button.mjs +10 -12
  119. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  120. package/build-module/components/list-view/block.mjs +2 -1
  121. package/build-module/components/list-view/block.mjs.map +2 -2
  122. package/build-module/components/provider/use-block-sync.mjs +11 -2
  123. package/build-module/components/provider/use-block-sync.mjs.map +2 -2
  124. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +4 -4
  125. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
  126. package/build-module/components/rich-text/event-listeners/delete.mjs +4 -4
  127. package/build-module/components/rich-text/event-listeners/delete.mjs.map +2 -2
  128. package/build-module/components/rich-text/event-listeners/enter.mjs +7 -2
  129. package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
  130. package/build-module/components/rich-text/event-listeners/input-events.mjs +4 -4
  131. package/build-module/components/rich-text/event-listeners/input-events.mjs.map +2 -2
  132. package/build-module/components/rich-text/event-listeners/input-rules.mjs +17 -4
  133. package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
  134. package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs +4 -4
  135. package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs.map +2 -2
  136. package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs +4 -4
  137. package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs.map +2 -2
  138. package/build-module/components/rich-text/event-listeners/shortcuts.mjs +4 -4
  139. package/build-module/components/rich-text/event-listeners/shortcuts.mjs.map +2 -2
  140. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +4 -4
  141. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +2 -2
  142. package/build-module/components/rich-text/index.mjs +1 -23
  143. package/build-module/components/rich-text/index.mjs.map +2 -2
  144. package/build-module/components/use-block-commands/index.mjs +5 -5
  145. package/build-module/components/use-block-commands/index.mjs.map +2 -2
  146. package/build-module/hooks/anchor.mjs +11 -15
  147. package/build-module/hooks/anchor.mjs.map +2 -2
  148. package/build-module/hooks/border.mjs +1 -4
  149. package/build-module/hooks/border.mjs.map +2 -2
  150. package/build-module/hooks/color.mjs +2 -5
  151. package/build-module/hooks/color.mjs.map +2 -2
  152. package/build-module/hooks/dimensions.mjs +1 -4
  153. package/build-module/hooks/dimensions.mjs.map +2 -2
  154. package/build-module/hooks/fit-text.mjs +11 -0
  155. package/build-module/hooks/fit-text.mjs.map +2 -2
  156. package/build-module/hooks/position.mjs +20 -23
  157. package/build-module/hooks/position.mjs.map +2 -2
  158. package/build-module/hooks/supports.mjs +0 -7
  159. package/build-module/hooks/supports.mjs.map +2 -2
  160. package/build-module/store/actions.mjs +7 -3
  161. package/build-module/store/actions.mjs.map +2 -2
  162. package/build-module/store/private-actions.mjs +1 -2
  163. package/build-module/store/private-actions.mjs.map +2 -2
  164. package/build-module/store/private-selectors.mjs +26 -0
  165. package/build-module/store/private-selectors.mjs.map +2 -2
  166. package/build-module/store/reducer.mjs +14 -6
  167. package/build-module/store/reducer.mjs.map +2 -2
  168. package/build-module/store/selectors.mjs +62 -42
  169. package/build-module/store/selectors.mjs.map +2 -2
  170. package/build-style/content-rtl.css +12 -0
  171. package/build-style/content.css +12 -0
  172. package/build-style/style-rtl.css +26 -8
  173. package/build-style/style.css +26 -8
  174. package/package.json +51 -48
  175. package/src/components/block-breadcrumb/README.md +2 -2
  176. package/src/components/block-compare/README.md +6 -6
  177. package/src/components/block-compare/index.js +1 -3
  178. package/src/components/block-list/use-block-props/index.js +1 -1
  179. package/src/components/block-patterns-list/index.js +1 -1
  180. package/src/components/block-preview/README.md +1 -1
  181. package/src/components/block-switcher/block-transformations-menu.js +16 -18
  182. package/src/components/block-switcher/index.js +4 -4
  183. package/src/components/block-types-list/README.md +0 -19
  184. package/src/components/child-layout-control/index.js +15 -8
  185. package/src/components/child-layout-control/test/index.js +126 -0
  186. package/src/components/colors/test/with-colors.js +1 -1
  187. package/src/components/global-styles/advanced-panel.js +5 -1
  188. package/src/components/global-styles/background-panel.js +3 -3
  189. package/src/components/global-styles/border-panel.js +2 -0
  190. package/src/components/global-styles/dimensions-panel.js +23 -16
  191. package/src/components/iframe/index.js +3 -0
  192. package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -1
  193. package/src/components/inserter/hooks/use-patterns-state.js +1 -1
  194. package/src/components/inserter/index.js +257 -288
  195. package/src/components/inserter/media-tab/utils.js +1 -1
  196. package/src/components/inserter/search-results.js +1 -3
  197. package/src/components/justify-content-control/README.md +1 -1
  198. package/src/components/list-view/block-select-button.js +9 -13
  199. package/src/components/list-view/block.js +1 -0
  200. package/src/components/media-placeholder/README.md +1 -29
  201. package/src/components/media-upload/README.md +0 -19
  202. package/src/components/provider/test/use-block-sync.js +40 -0
  203. package/src/components/provider/use-block-sync.js +12 -2
  204. package/src/components/rich-text/event-listeners/before-input-rules.js +5 -4
  205. package/src/components/rich-text/event-listeners/delete.js +9 -4
  206. package/src/components/rich-text/event-listeners/enter.js +9 -2
  207. package/src/components/rich-text/event-listeners/input-events.js +13 -4
  208. package/src/components/rich-text/event-listeners/input-rules.js +20 -4
  209. package/src/components/rich-text/event-listeners/insert-replacement-text.js +9 -4
  210. package/src/components/rich-text/event-listeners/remove-browser-shortcuts.js +9 -4
  211. package/src/components/rich-text/event-listeners/shortcuts.js +13 -4
  212. package/src/components/rich-text/event-listeners/undo-automatic-change.js +5 -4
  213. package/src/components/rich-text/index.js +1 -33
  214. package/src/components/unit-control/README.md +1 -1
  215. package/src/components/url-popover/README.md +1 -1
  216. package/src/components/use-block-commands/index.js +5 -5
  217. package/src/hooks/anchor.js +9 -17
  218. package/src/hooks/border.js +1 -5
  219. package/src/hooks/color.js +1 -6
  220. package/src/hooks/dimensions.js +1 -5
  221. package/src/hooks/fit-text.js +16 -0
  222. package/src/hooks/position.js +23 -27
  223. package/src/hooks/supports.js +0 -9
  224. package/src/store/actions.js +13 -3
  225. package/src/store/private-actions.js +1 -4
  226. package/src/store/private-selectors.js +59 -0
  227. package/src/store/reducer.js +19 -7
  228. package/src/store/selectors.js +91 -53
  229. package/src/store/test/actions.js +21 -0
  230. package/src/store/test/private-selectors.js +53 -0
  231. package/src/store/test/reducer.js +46 -0
  232. package/src/store/test/selectors.js +77 -0
  233. package/build/components/media-upload-progress/constants.cjs +0 -46
  234. package/build/components/media-upload-progress/constants.cjs.map +0 -7
  235. package/build/components/rich-text/native/format-edit.cjs +0 -60
  236. package/build/components/rich-text/native/format-edit.cjs.map +0 -7
  237. package/build/components/rich-text/native/index.cjs +0 -28
  238. package/build/components/rich-text/native/index.cjs.map +0 -7
  239. package/build/components/rich-text/native/use-format-types.cjs +0 -139
  240. package/build/components/rich-text/native/use-format-types.cjs.map +0 -7
  241. package/build-module/components/media-upload-progress/constants.mjs +0 -16
  242. package/build-module/components/media-upload-progress/constants.mjs.map +0 -7
  243. package/build-module/components/rich-text/native/format-edit.mjs +0 -39
  244. package/build-module/components/rich-text/native/format-edit.mjs.map +0 -7
  245. package/build-module/components/rich-text/native/index.mjs +0 -7
  246. package/build-module/components/rich-text/native/index.mjs.map +0 -7
  247. package/build-module/components/rich-text/native/use-format-types.mjs +0 -114
  248. package/build-module/components/rich-text/native/use-format-types.mjs.map +0 -7
  249. package/src/components/audio-player/audio-url-parser.native.js +0 -20
  250. package/src/components/audio-player/index.native.js +0 -225
  251. package/src/components/audio-player/styles.native.scss +0 -114
  252. package/src/components/audio-player/test/audio-url-parser.native.js +0 -53
  253. package/src/components/block-alignment-control/test/index.native.js +0 -37
  254. package/src/components/block-alignment-control/ui.native.js +0 -86
  255. package/src/components/block-caption/README.md +0 -104
  256. package/src/components/block-caption/index.native.js +0 -89
  257. package/src/components/block-caption/styles.native.scss +0 -7
  258. package/src/components/block-controls/slot.native.js +0 -33
  259. package/src/components/block-draggable/draggable-chip.native.js +0 -49
  260. package/src/components/block-draggable/dropping-insertion-point.native.js +0 -181
  261. package/src/components/block-draggable/dropping-insertion-point.native.scss +0 -8
  262. package/src/components/block-draggable/index.native.js +0 -467
  263. package/src/components/block-draggable/style.native.scss +0 -19
  264. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +0 -73
  265. package/src/components/block-draggable/test/helpers.native.js +0 -182
  266. package/src/components/block-draggable/test/index.native.js +0 -419
  267. package/src/components/block-draggable/use-scroll-when-dragging.native.js +0 -135
  268. package/src/components/block-edit/edit.native.js +0 -49
  269. package/src/components/block-edit/test/edit.native.js +0 -65
  270. package/src/components/block-heading-level-dropdown/index.native.js +0 -68
  271. package/src/components/block-icon/index.native.js +0 -47
  272. package/src/components/block-icon/style.native.scss +0 -7
  273. package/src/components/block-list/block-crash-boundary.native.js +0 -43
  274. package/src/components/block-list/block-crash-warning.native.js +0 -21
  275. package/src/components/block-list/block-invalid-warning.native.js +0 -70
  276. package/src/components/block-list/block-list-context.native.js +0 -172
  277. package/src/components/block-list/block-list-item-cell.native.js +0 -62
  278. package/src/components/block-list/block-list-item.native.js +0 -209
  279. package/src/components/block-list/block-list-item.native.scss +0 -16
  280. package/src/components/block-list/block-outline.native.js +0 -77
  281. package/src/components/block-list/block-selection-button.native.js +0 -100
  282. package/src/components/block-list/block-selection-button.native.scss +0 -34
  283. package/src/components/block-list/block.native.js +0 -716
  284. package/src/components/block-list/block.native.scss +0 -62
  285. package/src/components/block-list/grid-item.native.js +0 -58
  286. package/src/components/block-list/index.native.js +0 -437
  287. package/src/components/block-list/insertion-point.native.js +0 -36
  288. package/src/components/block-list/style.native.scss +0 -117
  289. package/src/components/block-list/test/block-invalid-warning.native.js +0 -62
  290. package/src/components/block-list/test/block-list-context.native.js +0 -243
  291. package/src/components/block-list/test/block-outline.native.js +0 -255
  292. package/src/components/block-list/test/fixtures/block-list-context.native.js +0 -79
  293. package/src/components/block-list/test/index.native.js +0 -205
  294. package/src/components/block-list/use-block-props/index.native.js +0 -10
  295. package/src/components/block-list/use-scroll-upon-insertion.native.js +0 -52
  296. package/src/components/block-list-appender/index.native.js +0 -70
  297. package/src/components/block-list-appender/style.native.scss +0 -8
  298. package/src/components/block-media-update-progress/README.md +0 -100
  299. package/src/components/block-media-update-progress/index.native.js +0 -299
  300. package/src/components/block-media-update-progress/styles.native.scss +0 -9
  301. package/src/components/block-media-update-progress/test/index.native.js +0 -543
  302. package/src/components/block-mover/index.native.js +0 -193
  303. package/src/components/block-mover/mover-description.native.js +0 -155
  304. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -218
  305. package/src/components/block-mover/test/index.native.js +0 -186
  306. package/src/components/block-settings/button.native.js +0 -41
  307. package/src/components/block-settings/container.native.js +0 -91
  308. package/src/components/block-settings/container.native.scss +0 -4
  309. package/src/components/block-settings/index.native.js +0 -5
  310. package/src/components/block-styles/index.native.js +0 -94
  311. package/src/components/block-styles/preview.native.js +0 -109
  312. package/src/components/block-styles/style.native.scss +0 -64
  313. package/src/components/block-switcher/block-transformations-menu.native.js +0 -91
  314. package/src/components/block-toolbar/block-toolbar-menu.native.js +0 -477
  315. package/src/components/block-toolbar/index.native.js +0 -126
  316. package/src/components/block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap +0 -125
  317. package/src/components/block-toolbar/test/block-toolbar-menu.native.js +0 -405
  318. package/src/components/block-toolbar/test/index.native.js +0 -36
  319. package/src/components/block-types-list/index.native.js +0 -175
  320. package/src/components/block-types-list/style.native.scss +0 -25
  321. package/src/components/block-variation-picker/index.native.js +0 -107
  322. package/src/components/block-variation-picker/style.native.scss +0 -32
  323. package/src/components/button-block-appender/index.native.js +0 -92
  324. package/src/components/button-block-appender/styles.native.scss +0 -43
  325. package/src/components/caption/README.md +0 -44
  326. package/src/components/caption/index.native.js +0 -61
  327. package/src/components/colors-gradients/panel-color-gradient-settings.native.js +0 -59
  328. package/src/components/contrast-checker/index.native.js +0 -113
  329. package/src/components/contrast-checker/style.native.scss +0 -26
  330. package/src/components/convert-to-group-buttons/index.native.js +0 -79
  331. package/src/components/default-block-appender/index.native.js +0 -113
  332. package/src/components/default-block-appender/style.native.scss +0 -18
  333. package/src/components/floating-toolbar/floatingToolbar.android.scss +0 -4
  334. package/src/components/floating-toolbar/floatingToolbar.ios.scss +0 -3
  335. package/src/components/floating-toolbar/index.native.js +0 -141
  336. package/src/components/floating-toolbar/styles.native.scss +0 -43
  337. package/src/components/font-sizes/index.native.js +0 -7
  338. package/src/components/global-styles/color-panel.native.js +0 -207
  339. package/src/components/global-styles/test/use-global-styles-context.native.js +0 -435
  340. package/src/components/global-styles/use-global-styles-context.native.js +0 -592
  341. package/src/components/gradients/index.native.js +0 -2
  342. package/src/components/image-link-destinations/index.native.js +0 -152
  343. package/src/components/image-link-destinations/style.native.scss +0 -16
  344. package/src/components/index.native.js +0 -108
  345. package/src/components/inner-blocks/constants.native.js +0 -5
  346. package/src/components/inner-blocks/index.native.js +0 -221
  347. package/src/components/inner-blocks/warning-max-depth-exceeded.native.js +0 -124
  348. package/src/components/inserter/block-types-tab.native.js +0 -76
  349. package/src/components/inserter/hooks/use-block-type-impressions.native.js +0 -47
  350. package/src/components/inserter/hooks/use-clipboard-block.native.js +0 -40
  351. package/src/components/inserter/index.native.js +0 -424
  352. package/src/components/inserter/menu.native.js +0 -237
  353. package/src/components/inserter/no-results.native.js +0 -49
  354. package/src/components/inserter/reusable-blocks-tab.native.js +0 -45
  355. package/src/components/inserter/search-results.native.js +0 -67
  356. package/src/components/inserter/style.native.scss +0 -83
  357. package/src/components/inserter/tabs.native.js +0 -152
  358. package/src/components/inserter/test/__snapshots__/index.native.js.snap +0 -117
  359. package/src/components/inserter/test/fixtures/index.native.js +0 -12
  360. package/src/components/inserter/test/index.native.js +0 -273
  361. package/src/components/inserter/test/reusable-blocks-tab.native.js +0 -62
  362. package/src/components/inserter/test/utils.native.js +0 -37
  363. package/src/components/inserter/utils.native.js +0 -46
  364. package/src/components/inserter-button/index.native.js +0 -108
  365. package/src/components/inserter-button/style.native.scss +0 -72
  366. package/src/components/inspector-controls/fill.native.js +0 -62
  367. package/src/components/inspector-controls/slot.native.js +0 -35
  368. package/src/components/inspector-controls-tabs/advanced-controls-panel.native.js +0 -31
  369. package/src/components/line-height-control/index.native.js +0 -28
  370. package/src/components/media-placeholder/index.native.js +0 -258
  371. package/src/components/media-placeholder/styles.native.scss +0 -108
  372. package/src/components/media-replace-flow/index.native.js +0 -12
  373. package/src/components/media-upload/constants.native.js +0 -14
  374. package/src/components/media-upload/index.native.js +0 -356
  375. package/src/components/media-upload/style.native.scss +0 -4
  376. package/src/components/media-upload/test/index.native.js +0 -172
  377. package/src/components/media-upload-progress/README.md +0 -100
  378. package/src/components/media-upload-progress/constants.js +0 -6
  379. package/src/components/media-upload-progress/index.native.js +0 -233
  380. package/src/components/media-upload-progress/styles.native.scss +0 -15
  381. package/src/components/media-upload-progress/test/index.native.js +0 -220
  382. package/src/components/plain-text/index.native.js +0 -164
  383. package/src/components/plain-text/style.native.scss +0 -10
  384. package/src/components/provider/index.native.js +0 -32
  385. package/src/components/rich-text/embed-handler-picker.native.js +0 -65
  386. package/src/components/rich-text/file-paste-handler.native.js +0 -3
  387. package/src/components/rich-text/format-toolbar/index.native.js +0 -21
  388. package/src/components/rich-text/format-toolbar-container.native.js +0 -16
  389. package/src/components/rich-text/index.native.js +0 -701
  390. package/src/components/rich-text/input-event.native.js +0 -10
  391. package/src/components/rich-text/native/format-edit.js +0 -44
  392. package/src/components/rich-text/native/get-format-colors.native.js +0 -47
  393. package/src/components/rich-text/native/index.js +0 -1
  394. package/src/components/rich-text/native/index.native.js +0 -1389
  395. package/src/components/rich-text/native/style.native.scss +0 -28
  396. package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +0 -79
  397. package/src/components/rich-text/native/test/index.native.js +0 -345
  398. package/src/components/rich-text/native/test/performance/rich-text.native.js +0 -44
  399. package/src/components/rich-text/native/toolbar-button-with-options.native.js +0 -61
  400. package/src/components/rich-text/native/use-format-types.js +0 -146
  401. package/src/components/rich-text/remove-browser-shortcuts.native.js +0 -1
  402. package/src/components/rich-text/shortcut.native.js +0 -10
  403. package/src/components/ungroup-button/README.md +0 -23
  404. package/src/components/ungroup-button/index.native.js +0 -77
  405. package/src/components/unsupported-block-details/index.native.js +0 -187
  406. package/src/components/unsupported-block-details/style.native.scss +0 -56
  407. package/src/components/url-input/index.native.js +0 -33
  408. package/src/components/use-block-drop-zone/index.native.js +0 -207
  409. package/src/components/use-on-block-drop/index.native.js +0 -115
  410. package/src/components/use-unsupported-block-editor/index.native.js +0 -59
  411. package/src/components/video-player/gridicon-play.native.js +0 -13
  412. package/src/components/video-player/index.native.js +0 -133
  413. package/src/components/video-player/styles.native.scss +0 -29
  414. package/src/components/warning/index.native.js +0 -64
  415. package/src/components/warning/style.native.scss +0 -47
  416. package/src/hooks/align.native.js +0 -49
  417. package/src/hooks/custom-class-name.native.js +0 -70
  418. package/src/hooks/index.native.js +0 -36
  419. package/src/hooks/layout.native.js +0 -23
  420. package/src/hooks/test/__snapshots__/align.native.js.snap +0 -73
  421. package/src/hooks/test/__snapshots__/anchor.native.js.snap +0 -7
  422. package/src/hooks/test/align.native.js +0 -134
  423. package/src/hooks/test/anchor.native.js +0 -32
  424. package/src/hooks/test/use-editor-wrapper-styles.native.js +0 -282
  425. package/src/hooks/typography.native.js +0 -60
  426. package/src/hooks/use-editor-wrapper-styles.native.js +0 -250
  427. package/src/hooks/use-editor-wrapper-styles.native.scss +0 -12
  428. package/src/index.native.js +0 -6
  429. package/src/private-apis.native.js +0 -21
  430. package/src/store/defaults.native.js +0 -23
@@ -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,UAAU,MAAM,QAAS;AAGrE,MAAK,MAAM,aAAa,QAAS;AAChC,gBAAY,cAAc,MAAM,YAAY,IAAK,CAAE,eAAgB;AAClE,YAAM,cAAc,sBAAuB,YAAY,OAAQ;AAG/D,aAAO;AAAA,IACR,CAAE;AAAA,EACH;AAEA,SAAO;AACR;AAUA,SAAS,mBAAoB,QAAQ,SAAU;AAC9C,SAAO,OAAO,IAAK,CAAE,UAAW;AAC/B,UAAM,aAAa,QAAQ,mBAAmB,IAAK,MAAM,QAAS;AAClE,WAAO;AAAA,MACN,GAAG;AAAA;AAAA,MAEH,UAAU,cAAc,MAAM;AAAA,MAC9B,aAAa,mBAAoB,MAAM,aAAa,OAAQ;AAAA,IAC7D;AAAA,EACD,CAAE;AACH;AASA,SAAS,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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\u2192internal\n\t\t\t// IDs via the clone mapping; the root controller uses\n\t\t\t// external IDs directly (no mapping needed).\n\t\t\tconst convert = ( sel ) => {\n\t\t\t\tif ( ! sel?.clientId || ! clientId ) {\n\t\t\t\t\treturn sel;\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\t...sel,\n\t\t\t\t\tclientId:\n\t\t\t\t\t\tidMappingRef.current.externalToInternal.get(\n\t\t\t\t\t\t\tsel.clientId\n\t\t\t\t\t\t) ?? sel.clientId,\n\t\t\t\t};\n\t\t\t};\n\t\t\t// Flag prevents the subscription from re-reporting this\n\t\t\t// selection change back to the entity (which would cause\n\t\t\t// an infinite update loop).\n\t\t\tisRestoringSelectionRef.current = true;\n\t\t\tresetSelection(\n\t\t\t\tconvert( selection.selectionStart ),\n\t\t\t\tconvert( selection.selectionEnd ),\n\t\t\t\tselection.initialPosition\n\t\t\t);\n\t\t\tisRestoringSelectionRef.current = false;\n\t\t}\n\t};\n\n\tconst setControlledBlocks = () => {\n\t\tif ( ! controlledBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't need to persist this change because we only replace\n\t\t// controlled inner blocks when the change was caused by an entity,\n\t\t// and so it would already be persisted.\n\t\tif ( clientId ) {\n\t\t\t// Batch so that the controlled flag and block replacement\n\t\t\t// are applied atomically \u2014 subscribers see a consistent state.\n\t\t\tregistry.batch( () => {\n\t\t\t\t// Clear previous mappings and build new ones during cloning.\n\t\t\t\t// This ensures the mapping stays in sync with the current blocks.\n\t\t\t\tidMappingRef.current.externalToInternal.clear();\n\t\t\t\tidMappingRef.current.internalToExternal.clear();\n\n\t\t\t\tconst storeBlocks = controlledBlocks.map( ( block ) =>\n\t\t\t\t\tcloneBlockWithMapping( block, idMappingRef.current )\n\t\t\t\t);\n\n\t\t\t\tsetHasControlledInnerBlocks( clientId, true );\n\n\t\t\t\tif ( subscribedRef.current ) {\n\t\t\t\t\tpendingChangesRef.current.incoming = storeBlocks;\n\t\t\t\t}\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceInnerBlocks( clientId, storeBlocks );\n\n\t\t\t\t// Invalidate the applied-selection ref so that\n\t\t\t\t// restoreSelection() at the end of the\n\t\t\t\t// controlledBlocks effect re-applies with the\n\t\t\t\t// freshly-built mapping (new internal IDs).\n\t\t\t\tappliedSelectionRef.current = null;\n\t\t\t} );\n\t\t} else {\n\t\t\tif ( subscribedRef.current ) {\n\t\t\t\tpendingChangesRef.current.incoming = controlledBlocks;\n\t\t\t}\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tresetBlocks( controlledBlocks );\n\t\t}\n\t};\n\n\t// Clean up the changes made by setControlledBlocks() when the component\n\t// containing useBlockSync() unmounts.\n\tconst unsetControlledBlocks = () => {\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\tsetHasControlledInnerBlocks( clientId, false );\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\treplaceInnerBlocks( clientId, [] );\n\t\t} else {\n\t\t\tresetBlocks( [] );\n\t\t}\n\t};\n\n\t// Add a subscription to the block-editor registry to detect when changes\n\t// have been made. This lets us inform the data source of changes. This\n\t// is an effect so that the subscriber can run synchronously without\n\t// waiting for React renders for changes.\n\tconst onInputRef = useRef( onInput );\n\tconst onChangeRef = useRef( onChange );\n\tuseEffect( () => {\n\t\tonInputRef.current = onInput;\n\t\tonChangeRef.current = onChange;\n\t}, [ onInput, onChange ] );\n\n\t// Determine if blocks need to be reset when they change.\n\t// Also restores selection from context after blocks are set.\n\tuseEffect( () => {\n\t\tconst isOutgoing =\n\t\t\tpendingChangesRef.current.outgoing.includes( controlledBlocks );\n\t\tconst storeMatch = getBlocks( clientId ) === controlledBlocks;\n\n\t\tif ( isOutgoing ) {\n\t\t\t// Skip block reset if the value matches expected outbound sync\n\t\t\t// triggered by this component by a preceding change detection.\n\t\t\t// Only skip if the value matches expectation, since a reset should\n\t\t\t// still occur if the value is modified (not equal by reference),\n\t\t\t// to allow that the consumer may apply modifications to reflect\n\t\t\t// back on the editor.\n\t\t\tif (\n\t\t\t\tpendingChangesRef.current.outgoing[\n\t\t\t\t\tpendingChangesRef.current.outgoing.length - 1\n\t\t\t\t] === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChangesRef.current.outgoing = [];\n\t\t\t}\n\t\t} else if ( ! storeMatch ) {\n\t\t\t// Reset changing value in all other cases than the sync described\n\t\t\t// above. Since this can be reached in an update following an out-\n\t\t\t// bound sync, unset the outbound value to avoid considering it in\n\t\t\t// subsequent renders.\n\t\t\tpendingChangesRef.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\n\t\t\t// Restore selection from context if it targets our scope.\n\t\t\t// Only done when blocks were reset from an external source\n\t\t\t// (undo/redo, entity navigation) \u2014 NOT for outgoing changes,\n\t\t\t// because dispatching resetSelection between keystrokes breaks\n\t\t\t// the isUpdatingSameBlockAttribute chain and creates per-\n\t\t\t// character undo levels.\n\t\t\trestoreSelection();\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tuseEffect( () => {\n\t\tconst {\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t\tisLastBlockChangePersistent,\n\t\t\t__unstableGetLastBlockChangeHistoryMode,\n\t\t\t__unstableIsLastBlockChangeIgnored,\n\t\t\tareInnerBlocksControlled,\n\t\t\tgetBlockParents,\n\t\t} = registry.select( blockEditorStore );\n\n\t\tlet blocks = getBlocks( clientId );\n\t\tlet isPersistent = isLastBlockChangePersistent();\n\t\tlet blockHistoryMode = __unstableGetLastBlockChangeHistoryMode();\n\t\tlet previousAreBlocksDifferent = false;\n\t\tlet prevSelectionStart = getSelectionStart();\n\t\tlet prevSelectionEnd = getSelectionEnd();\n\n\t\tsubscribedRef.current = true;\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Sometimes, when changing block lists, lingering subscriptions\n\t\t\t// might trigger before they are cleaned up. If the block for which\n\t\t\t// the subscription runs is no longer in the store, this would clear\n\t\t\t// its parent entity's block list. To avoid this, we bail out if\n\t\t\t// the subscription is triggering for a block (`clientId !== null`)\n\t\t\t// and its block name can't be found because it's not on the list.\n\t\t\t// (`getBlockName( clientId ) === null`).\n\t\t\tif ( clientId !== null && getBlockName( clientId ) === null ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newIsPersistent = isLastBlockChangePersistent();\n\t\t\tconst newBlockHistoryMode =\n\t\t\t\t__unstableGetLastBlockChangeHistoryMode();\n\t\t\tconst newBlocks = getBlocks( clientId );\n\t\t\tconst areBlocksDifferent = newBlocks !== blocks;\n\t\t\tblocks = newBlocks;\n\t\t\tif (\n\t\t\t\tareBlocksDifferent &&\n\t\t\t\t( pendingChangesRef.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChangesRef.current.incoming = null;\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\tblockHistoryMode = newBlockHistoryMode;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Since we often dispatch an action to mark the previous action as\n\t\t\t// persistent, we need to make sure that the blocks changed on the\n\t\t\t// previous action before committing the change.\n\t\t\tconst didPersistenceChange =\n\t\t\t\tpreviousAreBlocksDifferent &&\n\t\t\t\t! areBlocksDifferent &&\n\t\t\t\tnewIsPersistent &&\n\t\t\t\t! isPersistent;\n\n\t\t\tconst blocksChanged = areBlocksDifferent || didPersistenceChange;\n\n\t\t\t// Check if selection changed.\n\t\t\tconst newSelectionStart = getSelectionStart();\n\t\t\tconst newSelectionEnd = getSelectionEnd();\n\t\t\tconst selectionChanged =\n\t\t\t\tnewSelectionStart !== prevSelectionStart ||\n\t\t\t\tnewSelectionEnd !== prevSelectionEnd;\n\n\t\t\tif ( selectionChanged ) {\n\t\t\t\tprevSelectionStart = newSelectionStart;\n\t\t\t\tprevSelectionEnd = newSelectionEnd;\n\t\t\t}\n\n\t\t\tif ( blocksChanged || selectionChanged ) {\n\t\t\t\t// Batch block and selection updates so the entity\n\t\t\t\t// receives both changes atomically.\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tif ( blocksChanged ) {\n\t\t\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\t\t\tblockHistoryMode = newBlockHistoryMode;\n\n\t\t\t\t\t\t// For inner block controllers (clientId is set), restore external IDs\n\t\t\t\t\t\t// before passing blocks to the parent.\n\t\t\t\t\t\tconst blocksForParent = clientId\n\t\t\t\t\t\t\t? restoreExternalIds( blocks, idMappingRef.current )\n\t\t\t\t\t\t\t: blocks;\n\n\t\t\t\t\t\t// Build selection state for the undo level.\n\t\t\t\t\t\tconst selectionInfo = {\n\t\t\t\t\t\t\tselectionStart: newSelectionStart,\n\t\t\t\t\t\t\tselectionEnd: newSelectionEnd,\n\t\t\t\t\t\t\tinitialPosition:\n\t\t\t\t\t\t\t\tgetSelectedBlocksInitialCaretPosition(),\n\t\t\t\t\t\t};\n\t\t\t\t\t\t// Restore external IDs in selection for inner block controllers.\n\t\t\t\t\t\tconst selectionForParent = clientId\n\t\t\t\t\t\t\t? restoreSelectionIds(\n\t\t\t\t\t\t\t\t\tselectionInfo,\n\t\t\t\t\t\t\t\t\tidMappingRef.current\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: selectionInfo;\n\n\t\t\t\t\t\tpendingChangesRef.current.outgoing.push(\n\t\t\t\t\t\t\tblocksForParent\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst updateParent = isPersistent\n\t\t\t\t\t\t\t? onChangeRef.current\n\t\t\t\t\t\t\t: onInputRef.current;\n\t\t\t\t\t\tconst updateOptions = {\n\t\t\t\t\t\t\tselection: selectionForParent,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif ( blockHistoryMode === 'ignore' ) {\n\t\t\t\t\t\t\tupdateOptions.undoIgnore = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tupdateParent( blocksForParent, updateOptions );\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectionChanged &&\n\t\t\t\t\t\t! blocksChanged &&\n\t\t\t\t\t\tnewSelectionStart?.clientId &&\n\t\t\t\t\t\t! isRestoringSelectionRef.current\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Report selection via onChangeSelection.\n\t\t\t\t\t\t// Each useBlockSync only reports if the selected block\n\t\t\t\t\t\t// is within its own scope.\n\t\t\t\t\t\t// Inner block controllers own the block if the internal\n\t\t\t\t\t\t// ID appears in their clone mapping.\n\t\t\t\t\t\t// The root controller owns it if the block is not inside\n\t\t\t\t\t\t// any controlled inner block.\n\t\t\t\t\t\tconst isOurs = clientId\n\t\t\t\t\t\t\t? idMappingRef.current.internalToExternal.has(\n\t\t\t\t\t\t\t\t\tnewSelectionStart.clientId\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: ! getBlockParents(\n\t\t\t\t\t\t\t\t\tnewSelectionStart.clientId\n\t\t\t\t\t\t\t ).some( ( parentId ) =>\n\t\t\t\t\t\t\t\t\tareInnerBlocksControlled( parentId )\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\t\tif ( isOurs ) {\n\t\t\t\t\t\t\tconst selectionInfo = {\n\t\t\t\t\t\t\t\tselectionStart: newSelectionStart,\n\t\t\t\t\t\t\t\tselectionEnd: newSelectionEnd,\n\t\t\t\t\t\t\t\tinitialPosition:\n\t\t\t\t\t\t\t\t\tgetSelectedBlocksInitialCaretPosition(),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tonChangeSelection(\n\t\t\t\t\t\t\t\tclientId\n\t\t\t\t\t\t\t\t\t? restoreSelectionIds(\n\t\t\t\t\t\t\t\t\t\t\tselectionInfo,\n\t\t\t\t\t\t\t\t\t\t\tidMappingRef.current\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: selectionInfo\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\t\t\tpreviousAreBlocksDifferent = areBlocksDifferent;\n\t\t}, blockEditorStore );\n\n\t\treturn () => {\n\t\t\tsubscribedRef.current = false;\n\t\t\tunsubscribe();\n\t\t};\n\t}, [ registry, clientId ] );\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tunsetControlledBlocks();\n\t\t};\n\t}, [] );\n}\n"],
5
+ "mappings": ";AAGA,SAAS,YAAY,WAAW,cAAc;AAC9C,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAK3B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,wBAAwB;AAEjC,IAAM,OAAO,MAAM;AAAC;AAapB,SAAS,sBAAuB,OAAO,SAAU;AAChD,QAAM,cAAc,WAAY,KAAM;AAGtC,UAAQ,mBAAmB,IAAK,MAAM,UAAU,YAAY,QAAS;AACrE,UAAQ,mBAAmB,IAAK,YAAY,UAAU,MAAM,QAAS;AAGrE,MAAK,MAAM,aAAa,QAAS;AAChC,gBAAY,cAAc,MAAM,YAAY,IAAK,CAAE,eAAgB;AAClE,YAAM,cAAc,sBAAuB,YAAY,OAAQ;AAG/D,aAAO;AAAA,IACR,CAAE;AAAA,EACH;AAEA,SAAO;AACR;AAUA,SAAS,mBAAoB,QAAQ,SAAU;AAC9C,SAAO,OAAO,IAAK,CAAE,UAAW;AAC/B,UAAM,aAA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AClB,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,7 +1,10 @@
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";
6
+ import { unlock } from "../../../lock-unlock.mjs";
7
+ var { subscribeDelegatedListener } = unlock(composePrivateApis);
5
8
  var wrapSelectionSettings = ["`", '"', "'", "\u201C\u201D", "\u2018\u2019"];
6
9
  var before_input_rules_default = (props) => (element) => {
7
10
  function onInput(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,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,UAAQ,iBAAkB,eAAe,OAAQ;AACjD,SAAO,MAAM;AACZ,YAAQ,oBAAqB,eAAe,OAAQ;AAAA,EACrD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { insert, isCollapsed } from '@wordpress/rich-text';\nimport { applyFilters } from '@wordpress/hooks';\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\n/**\n * When typing over a selection, the selection will we wrapped by a matching\n * character pair. The second character is optional, it defaults to the first\n * character.\n *\n * @type {string[]} Array of character pairs.\n */\nconst wrapSelectionSettings = [ '`', '\"', \"'\", '\u201C\u201D', '\u2018\u2019' ];\n\nexport default ( props ) => ( element ) => {\n\tfunction onInput( event ) {\n\t\tconst { inputType, data } = event;\n\t\tconst { value, onChange, registry } = props.current;\n\n\t\t// Only run the rules when inserting text.\n\t\tif ( inputType !== 'insertText' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isCollapsed( value ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst pair = applyFilters(\n\t\t\t'blockEditor.wrapSelectionSettings',\n\t\t\twrapSelectionSettings\n\t\t).find(\n\t\t\t( [ startChar, endChar ] ) => startChar === data || endChar === data\n\t\t);\n\n\t\tif ( ! pair ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ startChar, endChar = startChar ] = pair;\n\t\tconst start = value.start;\n\t\tconst end = value.end + startChar.length;\n\n\t\tlet newValue = insert( value, startChar, start, start );\n\t\tnewValue = insert( newValue, endChar, end, end );\n\n\t\tconst {\n\t\t\t__unstableMarkLastChangeAsPersistent,\n\t\t\t__unstableMarkAutomaticChange,\n\t\t} = registry.dispatch( blockEditorStore );\n\n\t\t__unstableMarkLastChangeAsPersistent();\n\t\tonChange( newValue );\n\t\t__unstableMarkAutomaticChange();\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tinit.data = endChar;\n\n\t\tconst { ownerDocument } = element;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst newEvent = new defaultView.InputEvent( 'input', init );\n\n\t\t// Dispatch an `input` event with the new data. This will trigger the\n\t\t// input rules.\n\t\t// Postpone the `input` to the next event loop tick so that the dispatch\n\t\t// doesn't happen synchronously in the middle of `beforeinput` dispatch.\n\t\t// This is closer to how native `input` event would be timed, and also\n\t\t// makes sure that the `input` event is dispatched only after the `onChange`\n\t\t// call few lines above has fully updated the data store state and rerendered\n\t\t// all affected components.\n\t\twindow.queueMicrotask( () => {\n\t\t\tevent.target.dispatchEvent( newEvent );\n\t\t} );\n\t\tevent.preventDefault();\n\t}\n\n\treturn subscribeDelegatedListener( element, 'beforeinput', onInput, true );\n};\n"],
5
+ "mappings": ";AAGA,SAAS,QAAQ,mBAAmB;AACpC,SAAS,oBAAoB;AAC7B,SAAS,eAAe,0BAA0B;AAKlD,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AAEvB,IAAM,EAAE,2BAA2B,IAAI,OAAQ,kBAAmB;AASlE,IAAM,wBAAwB,CAAE,KAAK,KAAK,KAAK,gBAAM,cAAK;AAE1D,IAAO,6BAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,QAAS,OAAQ;AACzB,UAAM,EAAE,WAAW,KAAK,IAAI;AAC5B,UAAM,EAAE,OAAO,UAAU,SAAS,IAAI,MAAM;AAG5C,QAAK,cAAc,cAAe;AACjC;AAAA,IACD;AAEA,QAAK,YAAa,KAAM,GAAI;AAC3B;AAAA,IACD;AAEA,UAAM,OAAO;AAAA,MACZ;AAAA,MACA;AAAA,IACD,EAAE;AAAA,MACD,CAAE,CAAEA,YAAWC,QAAQ,MAAOD,eAAc,QAAQC,aAAY;AAAA,IACjE;AAEA,QAAK,CAAE,MAAO;AACb;AAAA,IACD;AAEA,UAAM,CAAE,WAAW,UAAU,SAAU,IAAI;AAC3C,UAAM,QAAQ,MAAM;AACpB,UAAM,MAAM,MAAM,MAAM,UAAU;AAElC,QAAI,WAAW,OAAQ,OAAO,WAAW,OAAO,KAAM;AACtD,eAAW,OAAQ,UAAU,SAAS,KAAK,GAAI;AAE/C,UAAM;AAAA,MACL;AAAA,MACA;AAAA,IACD,IAAI,SAAS,SAAU,gBAAiB;AAExC,yCAAqC;AACrC,aAAU,QAAS;AACnB,kCAA8B;AAE9B,UAAM,OAAO,CAAC;AAEd,eAAY,OAAO,OAAQ;AAC1B,WAAM,GAAI,IAAI,MAAO,GAAI;AAAA,IAC1B;AAEA,SAAK,OAAO;AAEZ,UAAM,EAAE,cAAc,IAAI;AAC1B,UAAM,EAAE,YAAY,IAAI;AACxB,UAAM,WAAW,IAAI,YAAY,WAAY,SAAS,IAAK;AAU3D,WAAO,eAAgB,MAAM;AAC5B,YAAM,OAAO,cAAe,QAAS;AAAA,IACtC,CAAE;AACF,UAAM,eAAe;AAAA,EACtB;AAEA,SAAO,2BAA4B,SAAS,eAAe,SAAS,IAAK;AAC1E;",
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;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;AACA,UAAQ,iBAAkB,WAAW,mBAAoB;AACzD,SAAO,MAAM;AACZ,uBAAmB;AACnB,YAAQ,oBAAqB,WAAW,mBAAoB;AAAA,EAC7D;AACD;",
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\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,IAA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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,S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MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,IAAI,MAAM;AAGV,QAAK,cAAc,gBAAgB,SAAS,kBAAmB;AAC9D;AAAA,IACD;AAEA,QAAK,wCAAwC,UAAU,GAAI;AAC1D;AAAA,IACD;AAEA,UAAM,QAAQ,SAAS;AAEvB,UAAM,aAAa,mBAAoB,MAAO,EAAE;AAAA,MAC/C,CAAE,cAAe,UAAU,SAAS;AAAA,IACrC;AACA,UAAM,iBAAiB,cAAe,YAAY,CAAE,SAAU;AAC7D,aAAO,KAAK,OAAO,KAAM,MAAM,IAAK;AAAA,IACrC,CAAE;AAEF,QAAK,gBAAiB;AACrB,gBAAW,eAAe,UAAU,CAAE;AACtC,eACE,SAAU,gBAAiB,EAC3B,8BAA8B;AAChC;AAAA,IACD;AAEA,UAAM,cAAc,YAAY;AAAA,MAC/B,CAAE,aAAa,EAAE,oBAAoB,MAAO;AAC3C,YAAK,qBAAsB;AAC1B,wBAAc,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,qBAAqB;AAClD,SAAS,eAAe,0BAA0B;AAKlD,SAAS,SAAS,wBAAwB;AAC1C,SAAS,6BAA6B;AACtC;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,SAAS,cAAc;AAEvB,IAAM,EAAE,2BAA2B,IAAI,OAAQ,kBAAmB;AAE3D,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,EAC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EvB,UAAM,aAAa,mBAAoB,MAAO,EAAE;AAAA,MAC/C,CAAE,cAAe,UAAU,SAAS;AAAA,IACrC;AACA,UAAM,iBAAiB,cAAe,YAAY,CAAE,SAAU;AAC7D,aAAO,KAAK,OAAO,KAAM,MAAM,IAAK;AAAA,IACrC,CAAE;AAEF,QAAK,gBAAiB;AACrB,gBAAW,eAAe,UAAU,CAAE;AACtC,eACE,SAAU,gBAAiB,EAC3B,8BAA8B;AAChC;AAAA,IACD;AAEA,UAAM,cAAc,YAAY;AAAA,MAC/B,CAAE,aAAa,EAAE,oBAAoB,MAAO;AAC3C,YAAK,qBAAsB;AAC1B,wBAAc,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;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,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
  }
@@ -40,27 +40,6 @@ keyboardShortcutContext.displayName = "keyboardShortcutContext";
40
40
  var inputEventContext = createContext();
41
41
  inputEventContext.displayName = "inputEventContext";
42
42
  var instanceIdKey = /* @__PURE__ */ Symbol("instanceId");
43
- function removeNativeProps(props) {
44
- const {
45
- __unstableMobileNoFocusOnMount,
46
- deleteEnter,
47
- placeholderTextColor,
48
- textAlign,
49
- selectionColor,
50
- tagsToEliminate,
51
- disableEditingMenu,
52
- fontSize,
53
- fontFamily,
54
- fontWeight,
55
- fontStyle,
56
- minWidth,
57
- maxWidth,
58
- disableSuggestions,
59
- disableAutocorrection,
60
- ...restProps
61
- } = props;
62
- return restProps;
63
- }
64
43
  function RichTextWrapper({
65
44
  children,
66
45
  tagName = "div",
@@ -90,7 +69,6 @@ function RichTextWrapper({
90
69
  readOnly,
91
70
  ...props
92
71
  }, forwardedRef) {
93
- props = removeNativeProps(props);
94
72
  if (onSplit) {
95
73
  deprecated("wp.blockEditor.RichText onSplit prop", {
96
74
  since: "6.4",
@@ -408,7 +386,7 @@ var PublicForwardedRichTextContainer = forwardRef((props, ref) => {
408
386
  __unstableAllowPrefixTransformations,
409
387
  readOnly,
410
388
  ...contentProps
411
- } = removeNativeProps(props);
389
+ } = props;
412
390
  return /* @__PURE__ */ jsx(
413
391
  Tag,
414
392
  {