@wordpress/block-editor 12.13.0 → 12.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (528) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +1 -1
  3. package/build/components/block-heading-level-dropdown/index.js +1 -1
  4. package/build/components/block-heading-level-dropdown/index.js.map +1 -1
  5. package/build/components/block-list/block.native.js +2 -0
  6. package/build/components/block-list/block.native.js.map +1 -1
  7. package/build/components/block-list/index.js +2 -9
  8. package/build/components/block-list/index.js.map +1 -1
  9. package/build/components/block-list-appender/index.js +16 -3
  10. package/build/components/block-list-appender/index.js.map +1 -1
  11. package/build/components/block-parent-selector/index.js +1 -1
  12. package/build/components/block-parent-selector/index.js.map +1 -1
  13. package/build/components/block-pattern-setup/index.js +25 -16
  14. package/build/components/block-pattern-setup/index.js.map +1 -1
  15. package/build/components/block-pattern-setup/setup-toolbar.js +4 -2
  16. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  17. package/build/components/block-patterns-list/index.js +36 -19
  18. package/build/components/block-patterns-list/index.js.map +1 -1
  19. package/build/components/block-quick-navigation/index.js +6 -4
  20. package/build/components/block-quick-navigation/index.js.map +1 -1
  21. package/build/components/block-rename/index.js +28 -0
  22. package/build/components/block-rename/index.js.map +1 -0
  23. package/build/components/block-rename/is-empty-string.js +10 -0
  24. package/build/components/block-rename/is-empty-string.js.map +1 -0
  25. package/build/components/block-rename/modal.js +87 -0
  26. package/build/components/block-rename/modal.js.map +1 -0
  27. package/build/components/block-rename/rename-control.js +74 -0
  28. package/build/components/block-rename/rename-control.js.map +1 -0
  29. package/build/components/block-rename/use-block-rename.js +17 -0
  30. package/build/components/block-rename/use-block-rename.js.map +1 -0
  31. package/build/components/block-settings-menu/block-settings-dropdown.js +33 -20
  32. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  33. package/build/components/block-settings-menu-controls/index.js +7 -0
  34. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  35. package/build/components/block-styles/index.js +0 -8
  36. package/build/components/block-styles/index.js.map +1 -1
  37. package/build/components/block-switcher/pattern-transformations-menu.js +18 -14
  38. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  39. package/build/components/block-toolbar/block-toolbar-menu.native.js +1 -1
  40. package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  41. package/build/components/block-tools/back-compat.js +2 -2
  42. package/build/components/block-tools/back-compat.js.map +1 -1
  43. package/build/components/block-tools/block-contextual-toolbar.js +11 -81
  44. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  45. package/build/components/block-tools/empty-block-inserter.js +56 -0
  46. package/build/components/block-tools/empty-block-inserter.js.map +1 -0
  47. package/build/components/block-tools/index.js +48 -9
  48. package/build/components/block-tools/index.js.map +1 -1
  49. package/build/components/block-tools/selected-block-tools.js +113 -0
  50. package/build/components/block-tools/selected-block-tools.js.map +1 -0
  51. package/build/components/block-tools/use-selected-block-tool-props.js +56 -0
  52. package/build/components/block-tools/use-selected-block-tool-props.js.map +1 -0
  53. package/build/components/block-types-list/index.js +6 -2
  54. package/build/components/block-types-list/index.js.map +1 -1
  55. package/build/components/date-format-picker/index.js +8 -1
  56. package/build/components/date-format-picker/index.js.map +1 -1
  57. package/build/components/editable-text/index.js +1 -2
  58. package/build/components/editable-text/index.js.map +1 -1
  59. package/build/components/global-styles/advanced-panel.js +1 -1
  60. package/build/components/global-styles/advanced-panel.js.map +1 -1
  61. package/build/components/iframe/index.js +4 -3
  62. package/build/components/iframe/index.js.map +1 -1
  63. package/build/components/image-size-control/index.js +0 -5
  64. package/build/components/image-size-control/index.js.map +1 -1
  65. package/build/components/inner-blocks/index.js +3 -1
  66. package/build/components/inner-blocks/index.js.map +1 -1
  67. package/build/components/inner-blocks/warning-max-depth-exceeded.native.js +29 -31
  68. package/build/components/inner-blocks/warning-max-depth-exceeded.native.js.map +1 -1
  69. package/build/components/inserter/block-patterns-explorer/{explorer.js → index.js} +7 -7
  70. package/build/components/inserter/block-patterns-explorer/index.js.map +1 -0
  71. package/build/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
  72. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
  73. package/build/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -4
  74. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
  75. package/build/components/inserter/block-patterns-tab/index.js +75 -0
  76. package/build/components/inserter/block-patterns-tab/index.js.map +1 -0
  77. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
  78. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
  79. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +108 -0
  80. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
  81. package/build/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +18 -34
  82. package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
  83. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +55 -0
  84. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
  85. package/build/components/inserter/block-patterns-tab/utils.js +69 -0
  86. package/build/components/inserter/block-patterns-tab/utils.js.map +1 -0
  87. package/build/components/inserter/hooks/use-patterns-state.js +2 -1
  88. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  89. package/build/components/inserter/media-tab/media-list.js +9 -5
  90. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  91. package/build/components/inserter/media-tab/media-preview.js +15 -12
  92. package/build/components/inserter/media-tab/media-preview.js.map +1 -1
  93. package/build/components/inserter/menu.js +3 -4
  94. package/build/components/inserter/menu.js.map +1 -1
  95. package/build/components/inserter-listbox/index.js +11 -6
  96. package/build/components/inserter-listbox/index.js.map +1 -1
  97. package/build/components/inserter-listbox/item.js +24 -23
  98. package/build/components/inserter-listbox/item.js.map +1 -1
  99. package/build/components/inserter-listbox/row.js +5 -5
  100. package/build/components/inserter-listbox/row.js.map +1 -1
  101. package/build/components/link-control/index.js +6 -5
  102. package/build/components/link-control/index.js.map +1 -1
  103. package/build/components/list-view/block-select-button.js +39 -0
  104. package/build/components/list-view/block-select-button.js.map +1 -1
  105. package/build/components/list-view/block.js +16 -3
  106. package/build/components/list-view/block.js.map +1 -1
  107. package/build/components/list-view/index.js +3 -2
  108. package/build/components/list-view/index.js.map +1 -1
  109. package/build/components/list-view/use-list-view-expand-selected-item.js +2 -3
  110. package/build/components/list-view/use-list-view-expand-selected-item.js.map +1 -1
  111. package/build/components/navigable-toolbar/index.js +69 -18
  112. package/build/components/navigable-toolbar/index.js.map +1 -1
  113. package/build/components/preview-options/index.js +4 -2
  114. package/build/components/preview-options/index.js.map +1 -1
  115. package/build/components/provider/use-block-sync.js +1 -14
  116. package/build/components/provider/use-block-sync.js.map +1 -1
  117. package/build/components/rich-text/index.js +0 -1
  118. package/build/components/rich-text/index.js.map +1 -1
  119. package/build/components/rich-text/index.native.js +4 -2
  120. package/build/components/rich-text/index.native.js.map +1 -1
  121. package/build/components/rich-text/native/format-edit.js +45 -0
  122. package/build/components/rich-text/native/format-edit.js.map +1 -0
  123. package/build/components/rich-text/native/get-format-colors.native.js +41 -0
  124. package/build/components/rich-text/native/get-format-colors.native.js.map +1 -0
  125. package/build/components/rich-text/native/index.js +9 -0
  126. package/build/components/rich-text/native/index.js.map +1 -0
  127. package/build/components/rich-text/native/index.native.js +1189 -0
  128. package/build/components/rich-text/native/index.native.js.map +1 -0
  129. package/build/components/rich-text/native/toolbar-button-with-options.native.js +58 -0
  130. package/build/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
  131. package/build/components/rich-text/native/use-format-types.js +111 -0
  132. package/build/components/rich-text/native/use-format-types.js.map +1 -0
  133. package/build/components/rich-text/use-input-rules.js +30 -1
  134. package/build/components/rich-text/use-input-rules.js.map +1 -1
  135. package/build/components/rich-text/use-paste-handler.js +2 -5
  136. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  137. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  138. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  139. package/build/components/url-popover/image-url-input-ui.js +2 -1
  140. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  141. package/build/components/use-block-drop-zone/index.js +4 -1
  142. package/build/components/use-block-drop-zone/index.js.map +1 -1
  143. package/build/components/use-moving-animation/index.js +2 -1
  144. package/build/components/use-moving-animation/index.js.map +1 -1
  145. package/build/components/use-settings/index.js +2 -2
  146. package/build/components/use-settings/index.js.map +1 -1
  147. package/build/components/writing-flow/use-tab-nav.js +7 -3
  148. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  149. package/build/hooks/align.js +10 -10
  150. package/build/hooks/align.js.map +1 -1
  151. package/build/hooks/align.native.js +2 -2
  152. package/build/hooks/align.native.js.map +1 -1
  153. package/build/hooks/anchor.js +7 -6
  154. package/build/hooks/anchor.js.map +1 -1
  155. package/build/hooks/background.js +16 -4
  156. package/build/hooks/background.js.map +1 -1
  157. package/build/hooks/block-hooks.js +7 -8
  158. package/build/hooks/block-hooks.js.map +1 -1
  159. package/build/hooks/block-renaming.js +42 -0
  160. package/build/hooks/block-renaming.js.map +1 -1
  161. package/build/hooks/content-lock-ui.js +5 -5
  162. package/build/hooks/content-lock-ui.js.map +1 -1
  163. package/build/hooks/custom-class-name.js +8 -7
  164. package/build/hooks/custom-class-name.js.map +1 -1
  165. package/build/hooks/custom-fields.js +57 -52
  166. package/build/hooks/custom-fields.js.map +1 -1
  167. package/build/hooks/duotone.js +9 -20
  168. package/build/hooks/duotone.js.map +1 -1
  169. package/build/hooks/index.js +0 -1
  170. package/build/hooks/index.js.map +1 -1
  171. package/build/hooks/layout.js +103 -93
  172. package/build/hooks/layout.js.map +1 -1
  173. package/build/hooks/position.js +10 -9
  174. package/build/hooks/position.js.map +1 -1
  175. package/build/hooks/style.js +10 -13
  176. package/build/hooks/style.js.map +1 -1
  177. package/build/hooks/utils.js +30 -0
  178. package/build/hooks/utils.js.map +1 -1
  179. package/build/layouts/constrained.js +4 -3
  180. package/build/layouts/constrained.js.map +1 -1
  181. package/build/private-apis.js +3 -0
  182. package/build/private-apis.js.map +1 -1
  183. package/build/store/actions.js +30 -37
  184. package/build/store/actions.js.map +1 -1
  185. package/build/store/reducer.js +18 -0
  186. package/build/store/reducer.js.map +1 -1
  187. package/build/store/selectors.js +18 -13
  188. package/build/store/selectors.js.map +1 -1
  189. package/build/utils/transform-styles/index.js +26 -6
  190. package/build/utils/transform-styles/index.js.map +1 -1
  191. package/build-module/components/block-heading-level-dropdown/index.js +1 -1
  192. package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
  193. package/build-module/components/block-list/block.native.js +2 -0
  194. package/build-module/components/block-list/block.native.js.map +1 -1
  195. package/build-module/components/block-list/index.js +3 -10
  196. package/build-module/components/block-list/index.js.map +1 -1
  197. package/build-module/components/block-list-appender/index.js +16 -3
  198. package/build-module/components/block-list-appender/index.js.map +1 -1
  199. package/build-module/components/block-parent-selector/index.js +1 -1
  200. package/build-module/components/block-parent-selector/index.js.map +1 -1
  201. package/build-module/components/block-pattern-setup/index.js +24 -15
  202. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  203. package/build-module/components/block-pattern-setup/setup-toolbar.js +4 -2
  204. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  205. package/build-module/components/block-patterns-list/index.js +36 -19
  206. package/build-module/components/block-patterns-list/index.js.map +1 -1
  207. package/build-module/components/block-quick-navigation/index.js +7 -5
  208. package/build-module/components/block-quick-navigation/index.js.map +1 -1
  209. package/build-module/components/block-rename/index.js +4 -0
  210. package/build-module/components/block-rename/index.js.map +1 -0
  211. package/build-module/components/block-rename/is-empty-string.js +4 -0
  212. package/build-module/components/block-rename/is-empty-string.js.map +1 -0
  213. package/build-module/components/block-rename/modal.js +79 -0
  214. package/build-module/components/block-rename/modal.js.map +1 -0
  215. package/build-module/components/block-rename/rename-control.js +66 -0
  216. package/build-module/components/block-rename/rename-control.js.map +1 -0
  217. package/build-module/components/block-rename/use-block-rename.js +10 -0
  218. package/build-module/components/block-rename/use-block-rename.js.map +1 -0
  219. package/build-module/components/block-settings-menu/block-settings-dropdown.js +34 -21
  220. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  221. package/build-module/components/block-settings-menu-controls/index.js +7 -0
  222. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  223. package/build-module/components/block-styles/index.js +0 -8
  224. package/build-module/components/block-styles/index.js.map +1 -1
  225. package/build-module/components/block-switcher/pattern-transformations-menu.js +17 -13
  226. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  227. package/build-module/components/block-toolbar/block-toolbar-menu.native.js +1 -1
  228. package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  229. package/build-module/components/block-tools/back-compat.js +1 -1
  230. package/build-module/components/block-tools/back-compat.js.map +1 -1
  231. package/build-module/components/block-tools/block-contextual-toolbar.js +11 -80
  232. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  233. package/build-module/components/block-tools/empty-block-inserter.js +48 -0
  234. package/build-module/components/block-tools/empty-block-inserter.js.map +1 -0
  235. package/build-module/components/block-tools/index.js +48 -9
  236. package/build-module/components/block-tools/index.js.map +1 -1
  237. package/build-module/components/block-tools/selected-block-tools.js +105 -0
  238. package/build-module/components/block-tools/selected-block-tools.js.map +1 -0
  239. package/build-module/components/block-tools/use-selected-block-tool-props.js +50 -0
  240. package/build-module/components/block-tools/use-selected-block-tool-props.js.map +1 -0
  241. package/build-module/components/block-types-list/index.js +6 -2
  242. package/build-module/components/block-types-list/index.js.map +1 -1
  243. package/build-module/components/date-format-picker/index.js +8 -1
  244. package/build-module/components/date-format-picker/index.js.map +1 -1
  245. package/build-module/components/editable-text/index.js +1 -2
  246. package/build-module/components/editable-text/index.js.map +1 -1
  247. package/build-module/components/global-styles/advanced-panel.js +1 -1
  248. package/build-module/components/global-styles/advanced-panel.js.map +1 -1
  249. package/build-module/components/iframe/index.js +4 -3
  250. package/build-module/components/iframe/index.js.map +1 -1
  251. package/build-module/components/image-size-control/index.js +0 -5
  252. package/build-module/components/image-size-control/index.js.map +1 -1
  253. package/build-module/components/inner-blocks/index.js +3 -1
  254. package/build-module/components/inner-blocks/index.js.map +1 -1
  255. package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js +30 -32
  256. package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js.map +1 -1
  257. package/build-module/components/inserter/block-patterns-explorer/{explorer.js → index.js} +5 -5
  258. package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -0
  259. package/build-module/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
  260. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
  261. package/build-module/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +3 -3
  262. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
  263. package/build-module/components/inserter/block-patterns-tab/index.js +66 -0
  264. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -0
  265. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +42 -0
  266. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
  267. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +100 -0
  268. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
  269. package/build-module/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +7 -20
  270. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
  271. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +47 -0
  272. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
  273. package/build-module/components/inserter/block-patterns-tab/utils.js +57 -0
  274. package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -0
  275. package/build-module/components/inserter/hooks/use-patterns-state.js +2 -1
  276. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  277. package/build-module/components/inserter/media-tab/media-list.js +9 -5
  278. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  279. package/build-module/components/inserter/media-tab/media-preview.js +15 -12
  280. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
  281. package/build-module/components/inserter/menu.js +4 -3
  282. package/build-module/components/inserter/menu.js.map +1 -1
  283. package/build-module/components/inserter-listbox/index.js +13 -8
  284. package/build-module/components/inserter-listbox/index.js.map +1 -1
  285. package/build-module/components/inserter-listbox/item.js +25 -23
  286. package/build-module/components/inserter-listbox/item.js.map +1 -1
  287. package/build-module/components/inserter-listbox/row.js +6 -5
  288. package/build-module/components/inserter-listbox/row.js.map +1 -1
  289. package/build-module/components/link-control/index.js +7 -6
  290. package/build-module/components/link-control/index.js.map +1 -1
  291. package/build-module/components/list-view/block-select-button.js +39 -0
  292. package/build-module/components/list-view/block-select-button.js.map +1 -1
  293. package/build-module/components/list-view/block.js +16 -3
  294. package/build-module/components/list-view/block.js.map +1 -1
  295. package/build-module/components/list-view/index.js +3 -2
  296. package/build-module/components/list-view/index.js.map +1 -1
  297. package/build-module/components/list-view/use-list-view-expand-selected-item.js +2 -3
  298. package/build-module/components/list-view/use-list-view-expand-selected-item.js.map +1 -1
  299. package/build-module/components/navigable-toolbar/index.js +69 -17
  300. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  301. package/build-module/components/preview-options/index.js +4 -2
  302. package/build-module/components/preview-options/index.js.map +1 -1
  303. package/build-module/components/provider/use-block-sync.js +1 -14
  304. package/build-module/components/provider/use-block-sync.js.map +1 -1
  305. package/build-module/components/rich-text/index.js +0 -1
  306. package/build-module/components/rich-text/index.js.map +1 -1
  307. package/build-module/components/rich-text/index.native.js +4 -2
  308. package/build-module/components/rich-text/index.native.js.map +1 -1
  309. package/build-module/components/rich-text/native/format-edit.js +38 -0
  310. package/build-module/components/rich-text/native/format-edit.js.map +1 -0
  311. package/build-module/components/rich-text/native/get-format-colors.native.js +34 -0
  312. package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -0
  313. package/build-module/components/rich-text/native/index.js +2 -0
  314. package/build-module/components/rich-text/native/index.js.map +1 -0
  315. package/build-module/components/rich-text/native/index.native.js +1179 -0
  316. package/build-module/components/rich-text/native/index.native.js.map +1 -0
  317. package/build-module/components/rich-text/native/toolbar-button-with-options.native.js +51 -0
  318. package/build-module/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
  319. package/build-module/components/rich-text/native/use-format-types.js +104 -0
  320. package/build-module/components/rich-text/native/use-format-types.js.map +1 -0
  321. package/build-module/components/rich-text/use-input-rules.js +31 -2
  322. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  323. package/build-module/components/rich-text/use-paste-handler.js +2 -5
  324. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  325. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  326. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  327. package/build-module/components/url-popover/image-url-input-ui.js +2 -1
  328. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  329. package/build-module/components/use-block-drop-zone/index.js +4 -1
  330. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  331. package/build-module/components/use-moving-animation/index.js +2 -1
  332. package/build-module/components/use-moving-animation/index.js.map +1 -1
  333. package/build-module/components/use-settings/index.js +2 -2
  334. package/build-module/components/use-settings/index.js.map +1 -1
  335. package/build-module/components/writing-flow/use-tab-nav.js +7 -3
  336. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  337. package/build-module/hooks/align.js +8 -8
  338. package/build-module/hooks/align.js.map +1 -1
  339. package/build-module/hooks/align.native.js +2 -2
  340. package/build-module/hooks/align.native.js.map +1 -1
  341. package/build-module/hooks/anchor.js +5 -4
  342. package/build-module/hooks/anchor.js.map +1 -1
  343. package/build-module/hooks/background.js +17 -5
  344. package/build-module/hooks/background.js.map +1 -1
  345. package/build-module/hooks/block-hooks.js +5 -6
  346. package/build-module/hooks/block-hooks.js.map +1 -1
  347. package/build-module/hooks/block-renaming.js +40 -0
  348. package/build-module/hooks/block-renaming.js.map +1 -1
  349. package/build-module/hooks/content-lock-ui.js +3 -3
  350. package/build-module/hooks/content-lock-ui.js.map +1 -1
  351. package/build-module/hooks/custom-class-name.js +6 -5
  352. package/build-module/hooks/custom-class-name.js.map +1 -1
  353. package/build-module/hooks/custom-fields.js +57 -52
  354. package/build-module/hooks/custom-fields.js.map +1 -1
  355. package/build-module/hooks/duotone.js +10 -21
  356. package/build-module/hooks/duotone.js.map +1 -1
  357. package/build-module/hooks/index.js +0 -1
  358. package/build-module/hooks/index.js.map +1 -1
  359. package/build-module/hooks/layout.js +103 -93
  360. package/build-module/hooks/layout.js.map +1 -1
  361. package/build-module/hooks/position.js +11 -10
  362. package/build-module/hooks/position.js.map +1 -1
  363. package/build-module/hooks/style.js +10 -13
  364. package/build-module/hooks/style.js.map +1 -1
  365. package/build-module/hooks/utils.js +30 -1
  366. package/build-module/hooks/utils.js.map +1 -1
  367. package/build-module/layouts/constrained.js +4 -3
  368. package/build-module/layouts/constrained.js.map +1 -1
  369. package/build-module/private-apis.js +4 -1
  370. package/build-module/private-apis.js.map +1 -1
  371. package/build-module/store/actions.js +29 -37
  372. package/build-module/store/actions.js.map +1 -1
  373. package/build-module/store/reducer.js +17 -0
  374. package/build-module/store/reducer.js.map +1 -1
  375. package/build-module/store/selectors.js +17 -13
  376. package/build-module/store/selectors.js.map +1 -1
  377. package/build-module/utils/transform-styles/index.js +24 -7
  378. package/build-module/utils/transform-styles/index.js.map +1 -1
  379. package/build-style/content-rtl.css +6 -6
  380. package/build-style/content.css +6 -6
  381. package/build-style/style-rtl.css +26 -20
  382. package/build-style/style.css +26 -20
  383. package/package.json +31 -31
  384. package/src/components/block-heading-level-dropdown/index.js +1 -1
  385. package/src/components/block-list/block.native.js +2 -0
  386. package/src/components/block-list/index.js +4 -18
  387. package/src/components/block-list-appender/index.js +20 -4
  388. package/src/components/block-parent-selector/index.js +1 -1
  389. package/src/components/block-pattern-setup/index.js +38 -22
  390. package/src/components/block-pattern-setup/setup-toolbar.js +2 -0
  391. package/src/components/block-pattern-setup/style.scss +4 -1
  392. package/src/components/block-patterns-list/README.md +4 -4
  393. package/src/components/block-patterns-list/index.js +60 -34
  394. package/src/components/block-patterns-list/style.scss +7 -0
  395. package/src/components/block-quick-navigation/index.js +11 -5
  396. package/src/components/block-rename/index.js +3 -0
  397. package/src/components/block-rename/is-empty-string.js +3 -0
  398. package/src/components/block-rename/modal.js +115 -0
  399. package/src/components/block-rename/rename-control.js +80 -0
  400. package/src/components/block-rename/use-block-rename.js +10 -0
  401. package/src/components/block-settings-menu/block-settings-dropdown.js +38 -34
  402. package/src/components/block-settings-menu-controls/index.js +9 -0
  403. package/src/components/block-styles/index.js +0 -10
  404. package/src/components/block-switcher/pattern-transformations-menu.js +20 -14
  405. package/src/components/block-toolbar/block-toolbar-menu.native.js +1 -4
  406. package/src/components/block-toolbar/style.scss +8 -0
  407. package/src/components/block-tools/back-compat.js +1 -1
  408. package/src/components/block-tools/block-contextual-toolbar.js +11 -134
  409. package/src/components/block-tools/empty-block-inserter.js +56 -0
  410. package/src/components/block-tools/index.js +72 -16
  411. package/src/components/block-tools/selected-block-tools.js +127 -0
  412. package/src/components/block-tools/style.scss +0 -10
  413. package/src/components/block-tools/use-selected-block-tool-props.js +66 -0
  414. package/src/components/block-types-list/index.js +5 -4
  415. package/src/components/button-block-appender/content.scss +2 -2
  416. package/src/components/date-format-picker/index.js +7 -0
  417. package/src/components/editable-text/README.md +0 -36
  418. package/src/components/editable-text/index.js +1 -8
  419. package/src/components/global-styles/advanced-panel.js +1 -1
  420. package/src/components/iframe/index.js +4 -3
  421. package/src/components/image-size-control/index.js +0 -6
  422. package/src/components/inner-blocks/index.js +6 -2
  423. package/src/components/inner-blocks/warning-max-depth-exceeded.native.js +57 -33
  424. package/src/components/inserter/block-patterns-explorer/{explorer.js → index.js} +4 -4
  425. package/src/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +9 -2
  426. package/src/components/inserter/block-patterns-tab/index.js +118 -0
  427. package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
  428. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +179 -0
  429. package/src/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +15 -21
  430. package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +101 -0
  431. package/src/components/inserter/block-patterns-tab/utils.js +78 -0
  432. package/src/components/inserter/hooks/use-patterns-state.js +3 -1
  433. package/src/components/inserter/media-tab/media-list.js +7 -7
  434. package/src/components/inserter/media-tab/media-preview.js +27 -22
  435. package/src/components/inserter/menu.js +4 -5
  436. package/src/components/inserter-listbox/index.js +11 -7
  437. package/src/components/inserter-listbox/item.js +11 -12
  438. package/src/components/inserter-listbox/row.js +6 -12
  439. package/src/components/link-control/README.md +2 -2
  440. package/src/components/link-control/index.js +15 -6
  441. package/src/components/link-control/style.scss +8 -5
  442. package/src/components/list-view/block-select-button.js +44 -1
  443. package/src/components/list-view/block.js +11 -11
  444. package/src/components/list-view/index.js +2 -0
  445. package/src/components/list-view/use-list-view-expand-selected-item.js +7 -8
  446. package/src/components/media-replace-flow/style.scss +2 -2
  447. package/src/components/navigable-toolbar/index.js +71 -25
  448. package/src/components/plain-text/README.md +2 -30
  449. package/src/components/preview-options/index.js +2 -0
  450. package/src/components/provider/use-block-sync.js +2 -21
  451. package/src/components/rich-text/README.md +6 -63
  452. package/src/components/rich-text/index.js +0 -1
  453. package/src/components/rich-text/index.native.js +4 -2
  454. package/src/components/rich-text/native/format-edit.js +44 -0
  455. package/src/components/rich-text/native/get-format-colors.native.js +54 -0
  456. package/src/components/rich-text/native/index.js +1 -0
  457. package/src/components/rich-text/native/index.native.js +1406 -0
  458. package/src/components/rich-text/native/style.native.scss +28 -0
  459. package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +79 -0
  460. package/src/components/rich-text/native/test/index.native.js +278 -0
  461. package/src/components/rich-text/native/test/performance/rich-text.native.js +44 -0
  462. package/src/components/rich-text/native/toolbar-button-with-options.native.js +61 -0
  463. package/src/components/rich-text/native/use-format-types.js +146 -0
  464. package/src/components/rich-text/use-input-rules.js +30 -2
  465. package/src/components/rich-text/use-paste-handler.js +1 -6
  466. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
  467. package/src/components/url-input/README.md +1 -74
  468. package/src/components/url-popover/image-url-input-ui.js +1 -0
  469. package/src/components/use-block-drop-zone/index.js +4 -1
  470. package/src/components/use-moving-animation/index.js +1 -1
  471. package/src/components/use-settings/index.js +2 -2
  472. package/src/components/use-settings/test/index.js +1 -1
  473. package/src/components/writing-flow/use-tab-nav.js +8 -3
  474. package/src/hooks/align.js +8 -8
  475. package/src/hooks/align.native.js +2 -2
  476. package/src/hooks/anchor.js +21 -23
  477. package/src/hooks/background.js +28 -6
  478. package/src/hooks/block-hooks.js +20 -16
  479. package/src/hooks/block-renaming.js +47 -0
  480. package/src/hooks/content-lock-ui.js +3 -3
  481. package/src/hooks/custom-class-name.js +7 -6
  482. package/src/hooks/custom-fields.js +73 -70
  483. package/src/hooks/duotone.js +23 -33
  484. package/src/hooks/index.js +0 -1
  485. package/src/hooks/layout.js +126 -113
  486. package/src/hooks/position.js +8 -21
  487. package/src/hooks/style.js +17 -31
  488. package/src/hooks/test/__snapshots__/align.native.js.snap +5 -5
  489. package/src/hooks/test/align.js +4 -4
  490. package/src/hooks/utils.js +33 -1
  491. package/src/layouts/constrained.js +57 -50
  492. package/src/private-apis.js +4 -1
  493. package/src/store/actions.js +26 -72
  494. package/src/store/reducer.js +19 -0
  495. package/src/store/selectors.js +15 -19
  496. package/src/style.scss +1 -1
  497. package/src/utils/test/transform-styles.js +49 -0
  498. package/src/utils/transform-styles/index.js +39 -13
  499. package/build/components/block-tools/selected-block-popover.js +0 -221
  500. package/build/components/block-tools/selected-block-popover.js.map +0 -1
  501. package/build/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
  502. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
  503. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
  504. package/build/components/inserter/block-patterns-filter.js.map +0 -1
  505. package/build/components/inserter/block-patterns-tab.js +0 -270
  506. package/build/components/inserter/block-patterns-tab.js.map +0 -1
  507. package/build/hooks/block-rename-ui.js +0 -165
  508. package/build/hooks/block-rename-ui.js.map +0 -1
  509. package/build/store/utils.js +0 -22
  510. package/build/store/utils.js.map +0 -1
  511. package/build-module/components/block-tools/selected-block-popover.js +0 -213
  512. package/build-module/components/block-tools/selected-block-popover.js.map +0 -1
  513. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
  514. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
  515. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
  516. package/build-module/components/inserter/block-patterns-filter.js.map +0 -1
  517. package/build-module/components/inserter/block-patterns-tab.js +0 -254
  518. package/build-module/components/inserter/block-patterns-tab.js.map +0 -1
  519. package/build-module/hooks/block-rename-ui.js +0 -157
  520. package/build-module/hooks/block-rename-ui.js.map +0 -1
  521. package/build-module/store/utils.js +0 -16
  522. package/build-module/store/utils.js.map +0 -1
  523. package/src/components/block-tools/selected-block-popover.js +0 -265
  524. package/src/components/inserter/block-patterns-tab.js +0 -448
  525. package/src/hooks/block-rename-ui.js +0 -226
  526. package/src/store/utils.js +0 -12
  527. /package/src/{hooks/block-rename-ui.scss → components/block-rename/style.scss} +0 -0
  528. /package/src/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +0 -0
@@ -4,17 +4,24 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = void 0;
7
+ exports.default = NavigableToolbar;
8
8
  var _react = require("react");
9
9
  var _components = require("@wordpress/components");
10
10
  var _element = require("@wordpress/element");
11
+ var _data = require("@wordpress/data");
11
12
  var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
12
13
  var _dom = require("@wordpress/dom");
13
14
  var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
15
+ var _keycodes = require("@wordpress/keycodes");
16
+ var _store = require("../../store");
14
17
  /**
15
18
  * WordPress dependencies
16
19
  */
17
20
 
21
+ /**
22
+ * Internal dependencies
23
+ */
24
+
18
25
  function hasOnlyToolbarItem(elements) {
19
26
  const dataProp = 'toolbarItem';
20
27
  return !elements.some(element => !(dataProp in element.dataset));
@@ -36,7 +43,7 @@ function focusFirstTabbableIn(container) {
36
43
  });
37
44
  }
38
45
  }
39
- function useIsAccessibleToolbar(ref) {
46
+ function useIsAccessibleToolbar(toolbarRef) {
40
47
  /*
41
48
  * By default, we'll assume the starting accessible state of the Toolbar
42
49
  * is true, as it seems to be the most common case.
@@ -57,7 +64,7 @@ function useIsAccessibleToolbar(ref) {
57
64
  // component.
58
65
  const [isAccessibleToolbar, setIsAccessibleToolbar] = (0, _element.useState)(initialAccessibleToolbarState);
59
66
  const determineIsAccessibleToolbar = (0, _element.useCallback)(() => {
60
- const tabbables = _dom.focus.tabbable.find(ref.current);
67
+ const tabbables = _dom.focus.tabbable.find(toolbarRef.current);
61
68
  const onlyToolbarItem = hasOnlyToolbarItem(tabbables);
62
69
  if (!onlyToolbarItem) {
63
70
  (0, _deprecated.default)('Using custom components as toolbar controls', {
@@ -67,26 +74,34 @@ function useIsAccessibleToolbar(ref) {
67
74
  });
68
75
  }
69
76
  setIsAccessibleToolbar(onlyToolbarItem);
70
- }, []);
77
+ }, [toolbarRef]);
71
78
  (0, _element.useLayoutEffect)(() => {
72
79
  // Toolbar buttons may be rendered asynchronously, so we use
73
80
  // MutationObserver to check if the toolbar subtree has been modified.
74
81
  const observer = new window.MutationObserver(determineIsAccessibleToolbar);
75
- observer.observe(ref.current, {
82
+ observer.observe(toolbarRef.current, {
76
83
  childList: true,
77
84
  subtree: true
78
85
  });
79
86
  return () => observer.disconnect();
80
- }, [isAccessibleToolbar]);
87
+ }, [determineIsAccessibleToolbar, isAccessibleToolbar, toolbarRef]);
81
88
  return isAccessibleToolbar;
82
89
  }
83
- function useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, defaultIndex, onIndexChange, shouldUseKeyboardFocusShortcut) {
90
+ function useToolbarFocus({
91
+ toolbarRef,
92
+ focusOnMount,
93
+ isAccessibleToolbar,
94
+ defaultIndex,
95
+ onIndexChange,
96
+ shouldUseKeyboardFocusShortcut,
97
+ focusEditorOnEscape
98
+ }) {
84
99
  // Make sure we don't use modified versions of this prop.
85
100
  const [initialFocusOnMount] = (0, _element.useState)(focusOnMount);
86
101
  const [initialIndex] = (0, _element.useState)(defaultIndex);
87
102
  const focusToolbar = (0, _element.useCallback)(() => {
88
- focusFirstTabbableIn(ref.current);
89
- }, []);
103
+ focusFirstTabbableIn(toolbarRef.current);
104
+ }, [toolbarRef]);
90
105
  const focusToolbarViaShortcut = () => {
91
106
  if (shouldUseKeyboardFocusShortcut) {
92
107
  focusToolbar();
@@ -102,7 +117,7 @@ function useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, defaultIndex, o
102
117
  }, [isAccessibleToolbar, initialFocusOnMount, focusToolbar]);
103
118
  (0, _element.useEffect)(() => {
104
119
  // Store ref so we have access on useEffect cleanup: https://legacy.reactjs.org/blog/2020/08/10/react-v17-rc.html#effect-cleanup-timing
105
- const navigableToolbarRef = ref.current;
120
+ const navigableToolbarRef = toolbarRef.current;
106
121
  // If initialIndex is passed, we focus on that toolbar item when the
107
122
  // toolbar gets mounted and initial focus is not forced.
108
123
  // We have to wait for the next browser paint because block controls aren't
@@ -131,33 +146,69 @@ function useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, defaultIndex, o
131
146
  const index = items.findIndex(item => item.tabIndex === 0);
132
147
  onIndexChange(index);
133
148
  };
134
- }, [initialIndex, initialFocusOnMount]);
149
+ }, [initialIndex, initialFocusOnMount, toolbarRef]);
150
+ const {
151
+ lastFocus
152
+ } = (0, _data.useSelect)(select => {
153
+ const {
154
+ getLastFocus
155
+ } = select(_store.store);
156
+ return {
157
+ lastFocus: getLastFocus()
158
+ };
159
+ }, []);
160
+ /**
161
+ * Handles returning focus to the block editor canvas when pressing escape.
162
+ */
163
+ (0, _element.useEffect)(() => {
164
+ const navigableToolbarRef = toolbarRef.current;
165
+ if (focusEditorOnEscape) {
166
+ const handleKeyDown = event => {
167
+ if (event.keyCode === _keycodes.ESCAPE && lastFocus?.current) {
168
+ // Focus the last focused element when pressing escape.
169
+ event.preventDefault();
170
+ lastFocus.current.focus();
171
+ }
172
+ };
173
+ navigableToolbarRef.addEventListener('keydown', handleKeyDown);
174
+ return () => {
175
+ navigableToolbarRef.removeEventListener('keydown', handleKeyDown);
176
+ };
177
+ }
178
+ }, [focusEditorOnEscape, lastFocus, toolbarRef]);
135
179
  }
136
180
  function NavigableToolbar({
137
181
  children,
138
182
  focusOnMount,
183
+ focusEditorOnEscape = false,
139
184
  shouldUseKeyboardFocusShortcut = true,
140
185
  __experimentalInitialIndex: initialIndex,
141
186
  __experimentalOnIndexChange: onIndexChange,
142
187
  ...props
143
188
  }) {
144
- const ref = (0, _element.useRef)();
145
- const isAccessibleToolbar = useIsAccessibleToolbar(ref);
146
- useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, initialIndex, onIndexChange, shouldUseKeyboardFocusShortcut);
189
+ const toolbarRef = (0, _element.useRef)();
190
+ const isAccessibleToolbar = useIsAccessibleToolbar(toolbarRef);
191
+ useToolbarFocus({
192
+ toolbarRef,
193
+ focusOnMount,
194
+ isAccessibleToolbar,
195
+ defaultIndex: initialIndex,
196
+ onIndexChange,
197
+ shouldUseKeyboardFocusShortcut,
198
+ focusEditorOnEscape
199
+ });
147
200
  if (isAccessibleToolbar) {
148
201
  return (0, _react.createElement)(_components.Toolbar, {
149
202
  label: props['aria-label'],
150
- ref: ref,
203
+ ref: toolbarRef,
151
204
  ...props
152
205
  }, children);
153
206
  }
154
207
  return (0, _react.createElement)(_components.NavigableMenu, {
155
208
  orientation: "horizontal",
156
209
  role: "toolbar",
157
- ref: ref,
210
+ ref: toolbarRef,
158
211
  ...props
159
212
  }, children);
160
213
  }
161
- var _default = NavigableToolbar;
162
- exports.default = _default;
163
214
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_element","_deprecated","_interopRequireDefault","_dom","_keyboardShortcuts","hasOnlyToolbarItem","elements","dataProp","some","element","dataset","getAllToolbarItemsIn","container","Array","from","querySelectorAll","hasFocusWithin","contains","ownerDocument","activeElement","focusFirstTabbableIn","firstTabbable","focus","tabbable","find","preventScroll","useIsAccessibleToolbar","ref","initialAccessibleToolbarState","isAccessibleToolbar","setIsAccessibleToolbar","useState","determineIsAccessibleToolbar","useCallback","tabbables","current","onlyToolbarItem","deprecated","since","alternative","link","useLayoutEffect","observer","window","MutationObserver","observe","childList","subtree","disconnect","useToolbarFocus","focusOnMount","defaultIndex","onIndexChange","shouldUseKeyboardFocusShortcut","initialFocusOnMount","initialIndex","focusToolbar","focusToolbarViaShortcut","useShortcut","useEffect","navigableToolbarRef","raf","requestAnimationFrame","items","index","cancelAnimationFrame","findIndex","item","tabIndex","NavigableToolbar","children","__experimentalInitialIndex","__experimentalOnIndexChange","props","useRef","_react","createElement","Toolbar","label","NavigableMenu","orientation","role","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/navigable-toolbar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { NavigableMenu, Toolbar } from '@wordpress/components';\nimport {\n\tuseState,\n\tuseRef,\n\tuseLayoutEffect,\n\tuseEffect,\n\tuseCallback,\n} from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\nimport { focus } from '@wordpress/dom';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\n\nfunction hasOnlyToolbarItem( elements ) {\n\tconst dataProp = 'toolbarItem';\n\treturn ! elements.some( ( element ) => ! ( dataProp in element.dataset ) );\n}\n\nfunction getAllToolbarItemsIn( container ) {\n\treturn Array.from( container.querySelectorAll( '[data-toolbar-item]' ) );\n}\n\nfunction hasFocusWithin( container ) {\n\treturn container.contains( container.ownerDocument.activeElement );\n}\n\nfunction focusFirstTabbableIn( container ) {\n\tconst [ firstTabbable ] = focus.tabbable.find( container );\n\tif ( firstTabbable ) {\n\t\tfirstTabbable.focus( {\n\t\t\t// When focusing newly mounted toolbars,\n\t\t\t// the position of the popover is often not right on the first render\n\t\t\t// This prevents the layout shifts when focusing the dialogs.\n\t\t\tpreventScroll: true,\n\t\t} );\n\t}\n}\n\nfunction useIsAccessibleToolbar( ref ) {\n\t/*\n\t * By default, we'll assume the starting accessible state of the Toolbar\n\t * is true, as it seems to be the most common case.\n\t *\n\t * Transitioning from an (initial) false to true state causes the\n\t * <Toolbar /> component to mount twice, which is causing undesired\n\t * side-effects. These side-effects appear to only affect certain\n\t * E2E tests.\n\t *\n\t * This was initial discovered in this pull-request:\n\t * https://github.com/WordPress/gutenberg/pull/23425\n\t */\n\tconst initialAccessibleToolbarState = true;\n\n\t// By default, it's gonna render NavigableMenu. If all the tabbable elements\n\t// inside the toolbar are ToolbarItem components (or derived components like\n\t// ToolbarButton), then we can wrap them with the accessible Toolbar\n\t// component.\n\tconst [ isAccessibleToolbar, setIsAccessibleToolbar ] = useState(\n\t\tinitialAccessibleToolbarState\n\t);\n\n\tconst determineIsAccessibleToolbar = useCallback( () => {\n\t\tconst tabbables = focus.tabbable.find( ref.current );\n\t\tconst onlyToolbarItem = hasOnlyToolbarItem( tabbables );\n\t\tif ( ! onlyToolbarItem ) {\n\t\t\tdeprecated( 'Using custom components as toolbar controls', {\n\t\t\t\tsince: '5.6',\n\t\t\t\talternative:\n\t\t\t\t\t'ToolbarItem, ToolbarButton or ToolbarDropdownMenu components',\n\t\t\t\tlink: 'https://developer.wordpress.org/block-editor/components/toolbar-button/#inside-blockcontrols',\n\t\t\t} );\n\t\t}\n\t\tsetIsAccessibleToolbar( onlyToolbarItem );\n\t}, [] );\n\n\tuseLayoutEffect( () => {\n\t\t// Toolbar buttons may be rendered asynchronously, so we use\n\t\t// MutationObserver to check if the toolbar subtree has been modified.\n\t\tconst observer = new window.MutationObserver(\n\t\t\tdetermineIsAccessibleToolbar\n\t\t);\n\t\tobserver.observe( ref.current, { childList: true, subtree: true } );\n\t\treturn () => observer.disconnect();\n\t}, [ isAccessibleToolbar ] );\n\n\treturn isAccessibleToolbar;\n}\n\nfunction useToolbarFocus(\n\tref,\n\tfocusOnMount,\n\tisAccessibleToolbar,\n\tdefaultIndex,\n\tonIndexChange,\n\tshouldUseKeyboardFocusShortcut\n) {\n\t// Make sure we don't use modified versions of this prop.\n\tconst [ initialFocusOnMount ] = useState( focusOnMount );\n\tconst [ initialIndex ] = useState( defaultIndex );\n\n\tconst focusToolbar = useCallback( () => {\n\t\tfocusFirstTabbableIn( ref.current );\n\t}, [] );\n\n\tconst focusToolbarViaShortcut = () => {\n\t\tif ( shouldUseKeyboardFocusShortcut ) {\n\t\t\tfocusToolbar();\n\t\t}\n\t};\n\n\t// Focus on toolbar when pressing alt+F10 when the toolbar is visible.\n\tuseShortcut( 'core/block-editor/focus-toolbar', focusToolbarViaShortcut );\n\n\tuseEffect( () => {\n\t\tif ( initialFocusOnMount ) {\n\t\t\tfocusToolbar();\n\t\t}\n\t}, [ isAccessibleToolbar, initialFocusOnMount, focusToolbar ] );\n\n\tuseEffect( () => {\n\t\t// Store ref so we have access on useEffect cleanup: https://legacy.reactjs.org/blog/2020/08/10/react-v17-rc.html#effect-cleanup-timing\n\t\tconst navigableToolbarRef = ref.current;\n\t\t// If initialIndex is passed, we focus on that toolbar item when the\n\t\t// toolbar gets mounted and initial focus is not forced.\n\t\t// We have to wait for the next browser paint because block controls aren't\n\t\t// rendered right away when the toolbar gets mounted.\n\t\tlet raf = 0;\n\t\tif ( ! initialFocusOnMount ) {\n\t\t\traf = window.requestAnimationFrame( () => {\n\t\t\t\tconst items = getAllToolbarItemsIn( navigableToolbarRef );\n\t\t\t\tconst index = initialIndex || 0;\n\t\t\t\tif ( items[ index ] && hasFocusWithin( navigableToolbarRef ) ) {\n\t\t\t\t\titems[ index ].focus( {\n\t\t\t\t\t\t// When focusing newly mounted toolbars,\n\t\t\t\t\t\t// the position of the popover is often not right on the first render\n\t\t\t\t\t\t// This prevents the layout shifts when focusing the dialogs.\n\t\t\t\t\t\tpreventScroll: true,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t\treturn () => {\n\t\t\twindow.cancelAnimationFrame( raf );\n\t\t\tif ( ! onIndexChange || ! navigableToolbarRef ) return;\n\t\t\t// When the toolbar element is unmounted and onIndexChange is passed, we\n\t\t\t// pass the focused toolbar item index so it can be hydrated later.\n\t\t\tconst items = getAllToolbarItemsIn( navigableToolbarRef );\n\t\t\tconst index = items.findIndex( ( item ) => item.tabIndex === 0 );\n\t\t\tonIndexChange( index );\n\t\t};\n\t}, [ initialIndex, initialFocusOnMount ] );\n}\n\nfunction NavigableToolbar( {\n\tchildren,\n\tfocusOnMount,\n\tshouldUseKeyboardFocusShortcut = true,\n\t__experimentalInitialIndex: initialIndex,\n\t__experimentalOnIndexChange: onIndexChange,\n\t...props\n} ) {\n\tconst ref = useRef();\n\tconst isAccessibleToolbar = useIsAccessibleToolbar( ref );\n\n\tuseToolbarFocus(\n\t\tref,\n\t\tfocusOnMount,\n\t\tisAccessibleToolbar,\n\t\tinitialIndex,\n\t\tonIndexChange,\n\t\tshouldUseKeyboardFocusShortcut\n\t);\n\n\tif ( isAccessibleToolbar ) {\n\t\treturn (\n\t\t\t<Toolbar label={ props[ 'aria-label' ] } ref={ ref } { ...props }>\n\t\t\t\t{ children }\n\t\t\t</Toolbar>\n\t\t);\n\t}\n\n\treturn (\n\t\t<NavigableMenu\n\t\t\torientation=\"horizontal\"\n\t\t\trole=\"toolbar\"\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t</NavigableMenu>\n\t);\n}\n\nexport default NavigableToolbar;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAOA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AACA,IAAAK,kBAAA,GAAAL,OAAA;AAbA;AACA;AACA;;AAaA,SAASM,kBAAkBA,CAAEC,QAAQ,EAAG;EACvC,MAAMC,QAAQ,GAAG,aAAa;EAC9B,OAAO,CAAED,QAAQ,CAACE,IAAI,CAAIC,OAAO,IAAM,EAAIF,QAAQ,IAAIE,OAAO,CAACC,OAAO,CAAG,CAAC;AAC3E;AAEA,SAASC,oBAAoBA,CAAEC,SAAS,EAAG;EAC1C,OAAOC,KAAK,CAACC,IAAI,CAAEF,SAAS,CAACG,gBAAgB,CAAE,qBAAsB,CAAE,CAAC;AACzE;AAEA,SAASC,cAAcA,CAAEJ,SAAS,EAAG;EACpC,OAAOA,SAAS,CAACK,QAAQ,CAAEL,SAAS,CAACM,aAAa,CAACC,aAAc,CAAC;AACnE;AAEA,SAASC,oBAAoBA,CAAER,SAAS,EAAG;EAC1C,MAAM,CAAES,aAAa,CAAE,GAAGC,UAAK,CAACC,QAAQ,CAACC,IAAI,CAAEZ,SAAU,CAAC;EAC1D,IAAKS,aAAa,EAAG;IACpBA,aAAa,CAACC,KAAK,CAAE;MACpB;MACA;MACA;MACAG,aAAa,EAAE;IAChB,CAAE,CAAC;EACJ;AACD;AAEA,SAASC,sBAAsBA,CAAEC,GAAG,EAAG;EACtC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMC,6BAA6B,GAAG,IAAI;;EAE1C;EACA;EACA;EACA;EACA,MAAM,CAAEC,mBAAmB,EAAEC,sBAAsB,CAAE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,CAAC;EACF,CAAC,EAAE,CAAET,YAAY,EAAED,mBAAmB,CAAG,CAAC;AAC3C;AAEA,SAASe,gBAAgBA,CAAE;EAC1BC,QAAQ;EACRpB,YAAY;EACZG,8BAA8B,GAAG,IAAI;EACrCkB,0BAA0B,EAAEhB,YAAY;EACxCiB,2BAA2B,EAAEpB,aAAa;EAC1C,GAAGqB;AACJ,CAAC,EAAG;EACH,MAAM9C,GAAG,GAAG,IAAA+C,eAAM,EAAC,CAAC;EACpB,MAAM7C,mBAAmB,GAAGH,sBAAsB,CAAEC,GAAI,CAAC;EAEzDsB,eAAe,CACdtB,GAAG,EACHuB,YAAY,EACZrB,mBAAmB,EACnB0B,YAAY,EACZH,aAAa,EACbC,8BACD,CAAC;EAED,IAAKxB,mBAAmB,EAAG;IAC1B,OACC,IAAA8C,MAAA,CAAAC,aAAA,EAAC9E,WAAA,CAAA+E,OAAO;MAACC,KAAK,EAAGL,KAAK,CAAE,YAAY,CAAI;MAAC9C,GAAG,EAAGA,GAAK;MAAA,GAAM8C;IAAK,GAC5DH,QACM,CAAC;EAEZ;EAEA,OACC,IAAAK,MAAA,CAAAC,aAAA,EAAC9E,WAAA,CAAAiF,aAAa;IACbC,WAAW,EAAC,YAAY;IACxBC,IAAI,EAAC,SAAS;IACdtD,GAAG,EAAGA,GAAK;IAAA,GACN8C;EAAK,GAERH,QACY,CAAC;AAElB;AAAC,IAAAY,QAAA,GAEcb,gBAAgB;AAAAc,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_components","require","_element","_data","_deprecated","_interopRequireDefault","_dom","_keyboardShortcuts","_keycodes","_store","hasOnlyToolbarItem","elements","dataProp","some","element","dataset","getAllToolbarItemsIn","container","Array","from","querySelectorAll","hasFocusWithin","contains","ownerDocument","activeElement","focusFirstTabbableIn","firstTabbable","focus","tabbable","find","preventScroll","useIsAccessibleToolbar","toolbarRef","initialAccessibleToolbarState","isAccessibleToolbar","setIsAccessibleToolbar","useState","determineIsAccessibleToolbar","useCallback","tabbables","current","onlyToolbarItem","deprecated","since","alternative","link","useLayoutEffect","observer","window","MutationObserver","observe","childList","subtree","disconnect","useToolbarFocus","focusOnMount","defaultIndex","onIndexChange","shouldUseKeyboardFocusShortcut","focusEditorOnEscape","initialFocusOnMount","initialIndex","focusToolbar","focusToolbarViaShortcut","useShortcut","useEffect","navigableToolbarRef","raf","requestAnimationFrame","items","index","cancelAnimationFrame","findIndex","item","tabIndex","lastFocus","useSelect","select","getLastFocus","blockEditorStore","handleKeyDown","event","keyCode","ESCAPE","preventDefault","addEventListener","removeEventListener","NavigableToolbar","children","__experimentalInitialIndex","__experimentalOnIndexChange","props","useRef","_react","createElement","Toolbar","label","ref","NavigableMenu","orientation","role"],"sources":["@wordpress/block-editor/src/components/navigable-toolbar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { NavigableMenu, Toolbar } from '@wordpress/components';\nimport {\n\tuseState,\n\tuseRef,\n\tuseLayoutEffect,\n\tuseEffect,\n\tuseCallback,\n} from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { focus } from '@wordpress/dom';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nfunction hasOnlyToolbarItem( elements ) {\n\tconst dataProp = 'toolbarItem';\n\treturn ! elements.some( ( element ) => ! ( dataProp in element.dataset ) );\n}\n\nfunction getAllToolbarItemsIn( container ) {\n\treturn Array.from( container.querySelectorAll( '[data-toolbar-item]' ) );\n}\n\nfunction hasFocusWithin( container ) {\n\treturn container.contains( container.ownerDocument.activeElement );\n}\n\nfunction focusFirstTabbableIn( container ) {\n\tconst [ firstTabbable ] = focus.tabbable.find( container );\n\n\tif ( firstTabbable ) {\n\t\tfirstTabbable.focus( {\n\t\t\t// When focusing newly mounted toolbars,\n\t\t\t// the position of the popover is often not right on the first render\n\t\t\t// This prevents the layout shifts when focusing the dialogs.\n\t\t\tpreventScroll: true,\n\t\t} );\n\t}\n}\n\nfunction useIsAccessibleToolbar( toolbarRef ) {\n\t/*\n\t * By default, we'll assume the starting accessible state of the Toolbar\n\t * is true, as it seems to be the most common case.\n\t *\n\t * Transitioning from an (initial) false to true state causes the\n\t * <Toolbar /> component to mount twice, which is causing undesired\n\t * side-effects. These side-effects appear to only affect certain\n\t * E2E tests.\n\t *\n\t * This was initial discovered in this pull-request:\n\t * https://github.com/WordPress/gutenberg/pull/23425\n\t */\n\tconst initialAccessibleToolbarState = true;\n\n\t// By default, it's gonna render NavigableMenu. If all the tabbable elements\n\t// inside the toolbar are ToolbarItem components (or derived components like\n\t// ToolbarButton), then we can wrap them with the accessible Toolbar\n\t// component.\n\tconst [ isAccessibleToolbar, setIsAccessibleToolbar ] = useState(\n\t\tinitialAccessibleToolbarState\n\t);\n\n\tconst determineIsAccessibleToolbar = useCallback( () => {\n\t\tconst tabbables = focus.tabbable.find( toolbarRef.current );\n\t\tconst onlyToolbarItem = hasOnlyToolbarItem( tabbables );\n\t\tif ( ! onlyToolbarItem ) {\n\t\t\tdeprecated( 'Using custom components as toolbar controls', {\n\t\t\t\tsince: '5.6',\n\t\t\t\talternative:\n\t\t\t\t\t'ToolbarItem, ToolbarButton or ToolbarDropdownMenu components',\n\t\t\t\tlink: 'https://developer.wordpress.org/block-editor/components/toolbar-button/#inside-blockcontrols',\n\t\t\t} );\n\t\t}\n\t\tsetIsAccessibleToolbar( onlyToolbarItem );\n\t}, [ toolbarRef ] );\n\n\tuseLayoutEffect( () => {\n\t\t// Toolbar buttons may be rendered asynchronously, so we use\n\t\t// MutationObserver to check if the toolbar subtree has been modified.\n\t\tconst observer = new window.MutationObserver(\n\t\t\tdetermineIsAccessibleToolbar\n\t\t);\n\t\tobserver.observe( toolbarRef.current, {\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t} );\n\t\treturn () => observer.disconnect();\n\t}, [ determineIsAccessibleToolbar, isAccessibleToolbar, toolbarRef ] );\n\n\treturn isAccessibleToolbar;\n}\n\nfunction useToolbarFocus( {\n\ttoolbarRef,\n\tfocusOnMount,\n\tisAccessibleToolbar,\n\tdefaultIndex,\n\tonIndexChange,\n\tshouldUseKeyboardFocusShortcut,\n\tfocusEditorOnEscape,\n} ) {\n\t// Make sure we don't use modified versions of this prop.\n\tconst [ initialFocusOnMount ] = useState( focusOnMount );\n\tconst [ initialIndex ] = useState( defaultIndex );\n\n\tconst focusToolbar = useCallback( () => {\n\t\tfocusFirstTabbableIn( toolbarRef.current );\n\t}, [ toolbarRef ] );\n\n\tconst focusToolbarViaShortcut = () => {\n\t\tif ( shouldUseKeyboardFocusShortcut ) {\n\t\t\tfocusToolbar();\n\t\t}\n\t};\n\n\t// Focus on toolbar when pressing alt+F10 when the toolbar is visible.\n\tuseShortcut( 'core/block-editor/focus-toolbar', focusToolbarViaShortcut );\n\n\tuseEffect( () => {\n\t\tif ( initialFocusOnMount ) {\n\t\t\tfocusToolbar();\n\t\t}\n\t}, [ isAccessibleToolbar, initialFocusOnMount, focusToolbar ] );\n\n\tuseEffect( () => {\n\t\t// Store ref so we have access on useEffect cleanup: https://legacy.reactjs.org/blog/2020/08/10/react-v17-rc.html#effect-cleanup-timing\n\t\tconst navigableToolbarRef = toolbarRef.current;\n\t\t// If initialIndex is passed, we focus on that toolbar item when the\n\t\t// toolbar gets mounted and initial focus is not forced.\n\t\t// We have to wait for the next browser paint because block controls aren't\n\t\t// rendered right away when the toolbar gets mounted.\n\t\tlet raf = 0;\n\t\tif ( ! initialFocusOnMount ) {\n\t\t\traf = window.requestAnimationFrame( () => {\n\t\t\t\tconst items = getAllToolbarItemsIn( navigableToolbarRef );\n\t\t\t\tconst index = initialIndex || 0;\n\t\t\t\tif ( items[ index ] && hasFocusWithin( navigableToolbarRef ) ) {\n\t\t\t\t\titems[ index ].focus( {\n\t\t\t\t\t\t// When focusing newly mounted toolbars,\n\t\t\t\t\t\t// the position of the popover is often not right on the first render\n\t\t\t\t\t\t// This prevents the layout shifts when focusing the dialogs.\n\t\t\t\t\t\tpreventScroll: true,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t\treturn () => {\n\t\t\twindow.cancelAnimationFrame( raf );\n\t\t\tif ( ! onIndexChange || ! navigableToolbarRef ) return;\n\t\t\t// When the toolbar element is unmounted and onIndexChange is passed, we\n\t\t\t// pass the focused toolbar item index so it can be hydrated later.\n\t\t\tconst items = getAllToolbarItemsIn( navigableToolbarRef );\n\t\t\tconst index = items.findIndex( ( item ) => item.tabIndex === 0 );\n\t\t\tonIndexChange( index );\n\t\t};\n\t}, [ initialIndex, initialFocusOnMount, toolbarRef ] );\n\n\tconst { lastFocus } = useSelect( ( select ) => {\n\t\tconst { getLastFocus } = select( blockEditorStore );\n\t\treturn {\n\t\t\tlastFocus: getLastFocus(),\n\t\t};\n\t}, [] );\n\t/**\n\t * Handles returning focus to the block editor canvas when pressing escape.\n\t */\n\tuseEffect( () => {\n\t\tconst navigableToolbarRef = toolbarRef.current;\n\n\t\tif ( focusEditorOnEscape ) {\n\t\t\tconst handleKeyDown = ( event ) => {\n\t\t\t\tif ( event.keyCode === ESCAPE && lastFocus?.current ) {\n\t\t\t\t\t// Focus the last focused element when pressing escape.\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tlastFocus.current.focus();\n\t\t\t\t}\n\t\t\t};\n\t\t\tnavigableToolbarRef.addEventListener( 'keydown', handleKeyDown );\n\t\t\treturn () => {\n\t\t\t\tnavigableToolbarRef.removeEventListener(\n\t\t\t\t\t'keydown',\n\t\t\t\t\thandleKeyDown\n\t\t\t\t);\n\t\t\t};\n\t\t}\n\t}, [ focusEditorOnEscape, lastFocus, toolbarRef ] );\n}\n\nexport default function NavigableToolbar( {\n\tchildren,\n\tfocusOnMount,\n\tfocusEditorOnEscape = false,\n\tshouldUseKeyboardFocusShortcut = true,\n\t__experimentalInitialIndex: initialIndex,\n\t__experimentalOnIndexChange: onIndexChange,\n\t...props\n} ) {\n\tconst toolbarRef = useRef();\n\tconst isAccessibleToolbar = useIsAccessibleToolbar( toolbarRef );\n\n\tuseToolbarFocus( {\n\t\ttoolbarRef,\n\t\tfocusOnMount,\n\t\tisAccessibleToolbar,\n\t\tdefaultIndex: initialIndex,\n\t\tonIndexChange,\n\t\tshouldUseKeyboardFocusShortcut,\n\t\tfocusEditorOnEscape,\n\t} );\n\n\tif ( isAccessibleToolbar ) {\n\t\treturn (\n\t\t\t<Toolbar\n\t\t\t\tlabel={ props[ 'aria-label' ] }\n\t\t\t\tref={ toolbarRef }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</Toolbar>\n\t\t);\n\t}\n\n\treturn (\n\t\t<NavigableMenu\n\t\t\torientation=\"horizontal\"\n\t\t\trole=\"toolbar\"\n\t\t\tref={ toolbarRef }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t</NavigableMenu>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAOA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,kBAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AApBA;AACA;AACA;;AAeA;AACA;AACA;;AAGA,SAASS,kBAAkBA,CAAEC,QAAQ,EAAG;EACvC,MAAMC,QAAQ,GAAG,aAAa;EAC9B,OAAO,CAAED,QAAQ,CAACE,IAAI,CAAIC,OAAO,IAAM,EAAIF,QAAQ,IAAIE,OAAO,CAACC,OAAO,CAAG,CAAC;AAC3E;AAEA,SAASC,oBAAoBA,CAAEC,SAAS,EAAG;EAC1C,OAAOC,KAAK,CAACC,IAAI,CAAEF,SAAS,CAACG,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,8 @@ function PreviewOptions({
26
26
  isEnabled = true,
27
27
  deviceType,
28
28
  setDeviceType,
29
- label
29
+ label,
30
+ showIconLabels
30
31
  }) {
31
32
  const isMobile = (0, _compose.useViewportMatch)('small', '<');
32
33
  if (isMobile) return null;
@@ -38,7 +39,8 @@ function PreviewOptions({
38
39
  className: 'block-editor-post-preview__button-toggle',
39
40
  disabled: !isEnabled,
40
41
  __experimentalIsFocusable: !isEnabled,
41
- children: viewLabel
42
+ children: viewLabel,
43
+ showTooltip: !showIconLabels
42
44
  };
43
45
  const menuProps = {
44
46
  'aria-label': (0, _i18n.__)('View options')
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_compose","_components","_i18n","_icons","PreviewOptions","children","viewLabel","className","isEnabled","deviceType","setDeviceType","label","isMobile","useViewportMatch","popoverProps","classnames","placement","toggleProps","disabled","__experimentalIsFocusable","menuProps","__","deviceIcons","mobile","tablet","desktop","_react","createElement","DropdownMenu","icon","toLowerCase","disableOpenOnArrowDown","renderProps","Fragment","MenuGroup","MenuItem","onClick","check"],"sources":["@wordpress/block-editor/src/components/preview-options/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { check, desktop, mobile, tablet } from '@wordpress/icons';\n\nexport default function PreviewOptions( {\n\tchildren,\n\tviewLabel,\n\tclassName,\n\tisEnabled = true,\n\tdeviceType,\n\tsetDeviceType,\n\tlabel,\n} ) {\n\tconst isMobile = useViewportMatch( 'small', '<' );\n\tif ( isMobile ) return null;\n\n\tconst popoverProps = {\n\t\tclassName: classnames(\n\t\t\tclassName,\n\t\t\t'block-editor-post-preview__dropdown-content'\n\t\t),\n\t\tplacement: 'bottom-end',\n\t};\n\tconst toggleProps = {\n\t\tclassName: 'block-editor-post-preview__button-toggle',\n\t\tdisabled: ! isEnabled,\n\t\t__experimentalIsFocusable: ! isEnabled,\n\t\tchildren: viewLabel,\n\t};\n\tconst menuProps = {\n\t\t'aria-label': __( 'View options' ),\n\t};\n\n\tconst deviceIcons = {\n\t\tmobile,\n\t\ttablet,\n\t\tdesktop,\n\t};\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"block-editor-post-preview__dropdown\"\n\t\t\tpopoverProps={ popoverProps }\n\t\t\ttoggleProps={ toggleProps }\n\t\t\tmenuProps={ menuProps }\n\t\t\ticon={ deviceIcons[ deviceType.toLowerCase() ] }\n\t\t\tlabel={ label || __( 'Preview' ) }\n\t\t\tdisableOpenOnArrowDown={ ! isEnabled }\n\t\t>\n\t\t\t{ ( renderProps ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Desktop' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Desktop' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Desktop' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Tablet' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Tablet' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Tablet' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Mobile' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Mobile' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Mobile' ) }\n\t\t\t\t\t\t</MenuItem>\n\t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AW,CAAEb,UAAU,CAACqB,WAAW,CAAC,CAAC,CAAI;IAChDnB,KAAK,EAAGA,KAAK,IAAI,IAAAU,QAAE,EAAE,SAAU,CAAG;IAClCU,sBAAsB,EAAG,CAAEvB;EAAW,GAElCwB,WAAW,IACd,IAAAN,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAO,QAAA,QACC,IAAAP,MAAA,CAAAC,aAAA,EAAC1B,WAAA,CAAAiC,SAAS,QACT,IAAAR,MAAA,CAAAC,aAAA,EAAC1B,WAAA,CAAAkC,QAAQ;IACR5B,SAAS,EAAC,0CAA0C;IACpD6B,OAAO,EAAGA,CAAA,KAAM1B,aAAa,CAAE,SAAU,CAAG;IAC5CmB,IAAI,EAAGpB,UAAU,KAAK,SAAS,IAAI4B;EAAO,GAExC,IAAAhB,QAAE,EAAE,SAAU,CACP,CAAC,EACX,IAAAK,MAAA,CAAAC,aAAA,EAAC1B,WAAA,CAAAkC,QAAQ;IACR5B,SAAS,EAAC,0CAA0C;IACpD6B,OAAO,EAAGA,CAAA,KAAM1B,aAAa,CAAE,QAAS,CAAG;IAC3CmB,IAAI,EAAGpB,UAAU,KAAK,QAAQ,IAAI4B;EAAO,GAEvC,IAAAhB,QAAE,EAAE,QAAS,CACN,CAAC,EACX,IAAAK,MAAA,CAAAC,aAAA,EAAC1B,WAAA,CAAAkC,QAAQ;IACR5B,SAAS,EAAC,0CAA0C;IACpD6B,OAAO,EAAGA,CAAA,KAAM1B,aAAa,CAAE,QAAS,CAAG;IAC3CmB,IAAI,EAAGpB,UAAU,KAAK,QAAQ,IAAI4B;EAAO,GAEvC,IAAAhB,QAAE,EAAE,QAAS,CACN,CACA,CAAC,EACVhB,QAAQ,GAAI2B,WAAY,CACzB,CAEU,CAAC;AAEjB"}
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_compose","_components","_i18n","_icons","PreviewOptions","children","viewLabel","className","isEnabled","deviceType","setDeviceType","label","showIconLabels","isMobile","useViewportMatch","popoverProps","classnames","placement","toggleProps","disabled","__experimentalIsFocusable","showTooltip","menuProps","__","deviceIcons","mobile","tablet","desktop","_react","createElement","DropdownMenu","icon","toLowerCase","disableOpenOnArrowDown","renderProps","Fragment","MenuGroup","MenuItem","onClick","check"],"sources":["@wordpress/block-editor/src/components/preview-options/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { check, desktop, mobile, tablet } from '@wordpress/icons';\n\nexport default function PreviewOptions( {\n\tchildren,\n\tviewLabel,\n\tclassName,\n\tisEnabled = true,\n\tdeviceType,\n\tsetDeviceType,\n\tlabel,\n\tshowIconLabels,\n} ) {\n\tconst isMobile = useViewportMatch( 'small', '<' );\n\tif ( isMobile ) return null;\n\n\tconst popoverProps = {\n\t\tclassName: classnames(\n\t\t\tclassName,\n\t\t\t'block-editor-post-preview__dropdown-content'\n\t\t),\n\t\tplacement: 'bottom-end',\n\t};\n\tconst toggleProps = {\n\t\tclassName: 'block-editor-post-preview__button-toggle',\n\t\tdisabled: ! isEnabled,\n\t\t__experimentalIsFocusable: ! isEnabled,\n\t\tchildren: viewLabel,\n\t\tshowTooltip: ! showIconLabels,\n\t};\n\tconst menuProps = {\n\t\t'aria-label': __( 'View options' ),\n\t};\n\n\tconst deviceIcons = {\n\t\tmobile,\n\t\ttablet,\n\t\tdesktop,\n\t};\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"block-editor-post-preview__dropdown\"\n\t\t\tpopoverProps={ popoverProps }\n\t\t\ttoggleProps={ toggleProps }\n\t\t\tmenuProps={ menuProps }\n\t\t\ticon={ deviceIcons[ deviceType.toLowerCase() ] }\n\t\t\tlabel={ label || __( 'Preview' ) }\n\t\t\tdisableOpenOnArrowDown={ ! isEnabled }\n\t\t>\n\t\t\t{ ( renderProps ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Desktop' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Desktop' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Desktop' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Tablet' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Tablet' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Tablet' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Mobile' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Mobile' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Mobile' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t{ children?.( renderProps ) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAXA;AACA;AACA;;AAGA;AACA;AACA;;AAMe,SAASK,cAAcA,CAAE;EACvCC,QAAQ;EACRC,SAAS;EACTC,SAAS;EACTC,SAAS,GAAG,IAAI;EAChBC,UAAU;EACVC,aAAa;EACbC,KAAK;EACLC;AACD,CAAC,E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;IAC5CqB,IAAI,EAAGtB,UAAU,KAAK,SAAS,IAAI8B;EAAO,GAExC,IAAAhB,QAAE,EAAE,SAAU,CACP,CAAC,EACX,IAAAK,MAAA,CAAAC,aAAA,EAAC5B,WAAA,CAAAoC,QAAQ;IACR9B,SAAS,EAAC,0CAA0C;IACpD+B,OAAO,EAAGA,CAAA,KAAM5B,aAAa,CAAE,QAAS,CAAG;IAC3CqB,IAAI,EAAGtB,UAAU,KAAK,QAAQ,IAAI8B;EAAO,GAEvC,IAAAhB,QAAE,EAAE,QAAS,CACN,CAAC,EACX,IAAAK,MAAA,CAAAC,aAAA,EAAC5B,WAAA,CAAAoC,QAAQ;IACR9B,SAAS,EAAC,0CAA0C;IACpD+B,OAAO,EAAGA,CAAA,KAAM5B,aAAa,CAAE,QAAS,CAAG;IAC3CqB,IAAI,EAAGtB,UAAU,KAAK,QAAQ,IAAI8B;EAAO,GAEvC,IAAAhB,QAAE,EAAE,QAAS,CACN,CACA,CAAC,EACVlB,QAAQ,GAAI6B,WAAY,CACzB,CAEU,CAAC;AAEjB"}
@@ -81,17 +81,14 @@ function useBlockSync({
81
81
  resetBlocks,
82
82
  resetSelection,
83
83
  replaceInnerBlocks,
84
- selectBlock,
85
84
  setHasControlledInnerBlocks,
86
85
  __unstableMarkNextChangeAsNotPersistent
87
86
  } = registry.dispatch(_store.store);
88
87
  const {
89
- hasSelectedBlock,
90
88
  getBlockName,
91
89
  getBlocks,
92
90
  getSelectionStart,
93
- getSelectionEnd,
94
- getBlock
91
+ getSelectionEnd
95
92
  } = registry.select(_store.store);
96
93
  const isControlled = (0, _data.useSelect)(select => {
97
94
  return !clientId || select(_store.store).areInnerBlocksControlled(clientId);
@@ -174,19 +171,9 @@ function useBlockSync({
174
171
  // bound sync, unset the outbound value to avoid considering it in
175
172
  // subsequent renders.
176
173
  pendingChanges.current.outgoing = [];
177
- const hadSelection = hasSelectedBlock();
178
- const selectionAnchor = getSelectionStart();
179
- const selectionFocus = getSelectionEnd();
180
174
  setControlledBlocks();
181
175
  if (controlledSelection) {
182
176
  resetSelection(controlledSelection.selectionStart, controlledSelection.selectionEnd, controlledSelection.initialPosition);
183
- } else {
184
- const selectionStillExists = getBlock(selectionAnchor.clientId);
185
- if (hadSelection && !selectionStillExists) {
186
- selectBlock(clientId);
187
- } else {
188
- resetSelection(selectionAnchor, selectionFocus);
189
- }
190
177
  }
191
178
  }
192
179
  }, [controlledBlocks, clientId]);
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_data","_blocks","_store","noop","useBlockSync","clientId","value","controlledBlocks","selection","controlledSelection","onChange","onInput","registry","useRegistry","resetBlocks","resetSelection","replaceInnerBlocks","selectBlock","setHasControlledInnerBlocks","__unstableMarkNextChangeAsNotPersistent","dispatch","blockEditorStore","hasSelectedBlock","getBlockName","getBlocks","getSelectionStart","getSelectionEnd","getBlock","select","isControlled","useSelect","areInnerBlocksControlled","pendingChanges","useRef","incoming","outgoing","subscribed","setControlledBlocks","batch","storeBlocks","map","block","cloneBlock","current","unsetControlledBlocks","onInputRef","onChangeRef","useEffect","includes","length","hadSelection","selectionAnchor","selectionFocus","selectionStart","selectionEnd","initialPosition","selectionStillExists","getSelectedBlocksInitialCaretPosition","isLastBlockChangePersistent","__unstableIsLastBlockChangeIgnored","blocks","isPersistent","previousAreBlocksDifferent","unsubscribe","subscribe","isStillControlled","newIsPersistent","newBlocks","areBlocksDifferent","didPersistenceChange","push","updateParent"],"sources":["@wordpress/block-editor/src/components/provider/use-block-sync.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\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 * - Initalizes 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 initalize the block-editor store\n * and for resetting the blocks to incoming\n * changes like undo.\n * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.\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\tselection: controlledSelection,\n\tonChange = noop,\n\tonInput = noop,\n} ) {\n\tconst registry = useRegistry();\n\n\tconst {\n\t\tresetBlocks,\n\t\tresetSelection,\n\t\treplaceInnerBlocks,\n\t\tselectBlock,\n\t\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst {\n\t\thasSelectedBlock,\n\t\tgetBlockName,\n\t\tgetBlocks,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlock,\n\t} = registry.select( blockEditorStore );\n\tconst isControlled = useSelect(\n\t\t( select ) => {\n\t\t\treturn (\n\t\t\t\t! clientId ||\n\t\t\t\tselect( blockEditorStore ).areInnerBlocksControlled( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst pendingChanges = useRef( { incoming: null, outgoing: [] } );\n\tconst subscribed = useRef( false );\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\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\t// It is important to batch here because otherwise,\n\t\t\t// as soon as `setHasControlledInnerBlocks` is called\n\t\t\t// the effect to restore might be triggered\n\t\t\t// before the actual blocks get set properly in state.\n\t\t\tregistry.batch( () => {\n\t\t\t\tsetHasControlledInnerBlocks( clientId, true );\n\t\t\t\tconst storeBlocks = controlledBlocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock( block )\n\t\t\t\t);\n\t\t\t\tif ( subscribed.current ) {\n\t\t\t\t\tpendingChanges.current.incoming = storeBlocks;\n\t\t\t\t}\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceInnerBlocks( clientId, storeBlocks );\n\t\t\t} );\n\t\t} else {\n\t\t\tif ( subscribed.current ) {\n\t\t\t\tpendingChanges.current.incoming = controlledBlocks;\n\t\t\t}\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\tuseEffect( () => {\n\t\tif ( pendingChanges.current.outgoing.includes( controlledBlocks ) ) {\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\tpendingChanges.current.outgoing[\n\t\t\t\t\tpendingChanges.current.outgoing.length - 1\n\t\t\t\t] === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChanges.current.outgoing = [];\n\t\t\t}\n\t\t} else if ( getBlocks( clientId ) !== controlledBlocks ) {\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\tpendingChanges.current.outgoing = [];\n\t\t\tconst hadSelection = hasSelectedBlock();\n\t\t\tconst selectionAnchor = getSelectionStart();\n\t\t\tconst selectionFocus = getSelectionEnd();\n\t\t\tsetControlledBlocks();\n\n\t\t\tif ( controlledSelection ) {\n\t\t\t\tresetSelection(\n\t\t\t\t\tcontrolledSelection.selectionStart,\n\t\t\t\t\tcontrolledSelection.selectionEnd,\n\t\t\t\t\tcontrolledSelection.initialPosition\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst selectionStillExists = getBlock(\n\t\t\t\t\tselectionAnchor.clientId\n\t\t\t\t);\n\t\t\t\tif ( hadSelection && ! selectionStillExists ) {\n\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t} else {\n\t\t\t\t\tresetSelection( selectionAnchor, selectionFocus );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tuseEffect( () => {\n\t\t// When the block becomes uncontrolled, it means its inner state has been reset\n\t\t// we need to take the blocks again from the external value property.\n\t\tif ( ! isControlled ) {\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\t\t}\n\t}, [ isControlled ] );\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} = registry.select( blockEditorStore );\n\n\t\tlet blocks = getBlocks( clientId );\n\t\tlet isPersistent = isLastBlockChangePersistent();\n\t\tlet previousAreBlocksDifferent = false;\n\n\t\tsubscribed.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\n\t\t\t// When RESET_BLOCKS on parent blocks get called, the controlled blocks\n\t\t\t// can reset to uncontrolled, in these situations, it means we need to populate\n\t\t\t// the blocks again from the external blocks (the value property here)\n\t\t\t// and we should stop triggering onChange\n\t\t\tconst isStillControlled =\n\t\t\t\t! clientId || areInnerBlocksControlled( clientId );\n\t\t\tif ( ! isStillControlled ) {\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( pendingChanges.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChanges.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\tif ( areBlocksDifferent || didPersistenceChange ) {\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\t// We know that onChange/onInput will update controlledBlocks.\n\t\t\t\t// We need to be aware that it was caused by an outgoing change\n\t\t\t\t// so that we do not treat it as an incoming change later on,\n\t\t\t\t// which would cause a block reset.\n\t\t\t\tpendingChanges.current.outgoing.push( blocks );\n\n\t\t\t\t// Inform the controlling entity that changes have been made to\n\t\t\t\t// the block-editor store they should be aware about.\n\t\t\t\tconst updateParent = isPersistent\n\t\t\t\t\t? onChangeRef.current\n\t\t\t\t\t: onInputRef.current;\n\t\t\t\tupdateParent( blocks, {\n\t\t\t\t\tselection: {\n\t\t\t\t\t\tselectionStart: getSelectionStart(),\n\t\t\t\t\t\tselectionEnd: getSelectionEnd(),\n\t\t\t\t\t\tinitialPosition:\n\t\t\t\t\t\t\tgetSelectedBlocksInitialCaretPosition(),\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\tsubscribed.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"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAKA;AACA;AACA;;AAGA,MAAMI,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,YAAYA,CAAE;EACrCC,QAAQ,GAAG,IAAI;EACfC,KAAK,EAAEC,gBAAgB;EACvBC,SAAS,EAAEC,mBAAmB;EAC9BC,QAAQ,GAAGP,IAAI;EACfQ,OAAO,GAAGR;AACX,CAAC,EAAG;EACH,MAAMS,QAAQ,GAAG,IAAAC,iBAAW,EAAC,CAAC;EAE9B,MAAM;IACLC,WAAW;IACXC,cAAc;IACdC,kBAAkB;IAClBC,WAAW;IACXC,2BAA2B;IAC3BC;EACD,CAAC,GAAGP,QAAQ,CAACQ,QAAQ,CAAEC,YAAiB,CAAC;EACzC,MAAM;IACLC,gBAAgB;IAChBC,YAAY;IACZC,SAAS;IACTC,iBAAiB;IACjBC,eAAe;IACfC;EACD,CAAC,GAAGf,QAAQ,CAACgB,MAAM,CAAEP,YAAiB,CAAC;EACvC,MAAMQ,YAAY,GAAG,IAAAC,eAAS,EAC3BF,MAAM,IAAM;IACb,OACC,CAAEvB,QAAQ,IACVuB,MA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Sync","clientId","value","controlledBlocks","selection","controlledSelection","onChange","onInput","registry","useRegistry","resetBlocks","resetSelection","replaceInnerBlocks","setHasControlledInnerBlocks","__unstableMarkNextChangeAsNotPersistent","dispatch","blockEditorStore","getBlockName","getBlocks","getSelectionStart","getSelectionEnd","select","isControlled","useSelect","areInnerBlocksControlled","pendingChanges","useRef","incoming","outgoing","subscribed","setControlledBlocks","batch","storeBlocks","map","block","cloneBlock","current","unsetControlledBlocks","onInputRef","onChangeRef","useEffect","includes","length","selectionStart","selectionEnd","initialPosition","getSelectedBlocksInitialCaretPosition","isLastBlockChangePersistent","__unstableIsLastBlockChangeIgnored","blocks","isPersistent","previousAreBlocksDifferent","unsubscribe","subscribe","isStillControlled","newIsPersistent","newBlocks","areBlocksDifferent","didPersistenceChange","push","updateParent"],"sources":["@wordpress/block-editor/src/components/provider/use-block-sync.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\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 * - Initalizes 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 initalize the block-editor store\n * and for resetting the blocks to incoming\n * changes like undo.\n * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.\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\tselection: controlledSelection,\n\tonChange = noop,\n\tonInput = noop,\n} ) {\n\tconst registry = useRegistry();\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\tconst isControlled = useSelect(\n\t\t( select ) => {\n\t\t\treturn (\n\t\t\t\t! clientId ||\n\t\t\t\tselect( blockEditorStore ).areInnerBlocksControlled( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst pendingChanges = useRef( { incoming: null, outgoing: [] } );\n\tconst subscribed = useRef( false );\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\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\t// It is important to batch here because otherwise,\n\t\t\t// as soon as `setHasControlledInnerBlocks` is called\n\t\t\t// the effect to restore might be triggered\n\t\t\t// before the actual blocks get set properly in state.\n\t\t\tregistry.batch( () => {\n\t\t\t\tsetHasControlledInnerBlocks( clientId, true );\n\t\t\t\tconst storeBlocks = controlledBlocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock( block )\n\t\t\t\t);\n\t\t\t\tif ( subscribed.current ) {\n\t\t\t\t\tpendingChanges.current.incoming = storeBlocks;\n\t\t\t\t}\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceInnerBlocks( clientId, storeBlocks );\n\t\t\t} );\n\t\t} else {\n\t\t\tif ( subscribed.current ) {\n\t\t\t\tpendingChanges.current.incoming = controlledBlocks;\n\t\t\t}\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\tuseEffect( () => {\n\t\tif ( pendingChanges.current.outgoing.includes( controlledBlocks ) ) {\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\tpendingChanges.current.outgoing[\n\t\t\t\t\tpendingChanges.current.outgoing.length - 1\n\t\t\t\t] === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChanges.current.outgoing = [];\n\t\t\t}\n\t\t} else if ( getBlocks( clientId ) !== controlledBlocks ) {\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\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\n\t\t\tif ( controlledSelection ) {\n\t\t\t\tresetSelection(\n\t\t\t\t\tcontrolledSelection.selectionStart,\n\t\t\t\t\tcontrolledSelection.selectionEnd,\n\t\t\t\t\tcontrolledSelection.initialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tuseEffect( () => {\n\t\t// When the block becomes uncontrolled, it means its inner state has been reset\n\t\t// we need to take the blocks again from the external value property.\n\t\tif ( ! isControlled ) {\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\t\t}\n\t}, [ isControlled ] );\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} = registry.select( blockEditorStore );\n\n\t\tlet blocks = getBlocks( clientId );\n\t\tlet isPersistent = isLastBlockChangePersistent();\n\t\tlet previousAreBlocksDifferent = false;\n\n\t\tsubscribed.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\n\t\t\t// When RESET_BLOCKS on parent blocks get called, the controlled blocks\n\t\t\t// can reset to uncontrolled, in these situations, it means we need to populate\n\t\t\t// the blocks again from the external blocks (the value property here)\n\t\t\t// and we should stop triggering onChange\n\t\t\tconst isStillControlled =\n\t\t\t\t! clientId || areInnerBlocksControlled( clientId );\n\t\t\tif ( ! isStillControlled ) {\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( pendingChanges.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChanges.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\tif ( areBlocksDifferent || didPersistenceChange ) {\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\t// We know that onChange/onInput will update controlledBlocks.\n\t\t\t\t// We need to be aware that it was caused by an outgoing change\n\t\t\t\t// so that we do not treat it as an incoming change later on,\n\t\t\t\t// which would cause a block reset.\n\t\t\t\tpendingChanges.current.outgoing.push( blocks );\n\n\t\t\t\t// Inform the controlling entity that changes have been made to\n\t\t\t\t// the block-editor store they should be aware about.\n\t\t\t\tconst updateParent = isPersistent\n\t\t\t\t\t? onChangeRef.current\n\t\t\t\t\t: onInputRef.current;\n\t\t\t\tupdateParent( blocks, {\n\t\t\t\t\tselection: {\n\t\t\t\t\t\tselectionStart: getSelectionStart(),\n\t\t\t\t\t\tselectionEnd: getSelectionEnd(),\n\t\t\t\t\t\tinitialPosition:\n\t\t\t\t\t\t\tgetSelectedBlocksInitialCaretPosition(),\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\tsubscribed.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"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAKA;AACA;AACA;;AAGA,MAAMI,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,YAAYA,CAAE;EACrCC,QAAQ,GAAG,IAAI;EACfC,KAAK,EAAEC,gBAAgB;EACvBC,SAAS,EAAEC,mBAAmB;EAC9BC,QAAQ,GAAGP,IAAI;EACfQ,OAAO,GAAGR;AACX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@@ function RichTextWrapper({
325
325
  onReplace,
326
326
  onSplit,
327
327
  __unstableEmbedURLOnPaste,
328
- preserveWhiteSpace,
329
328
  pastePlainText
330
329
  }), (0, _useDelete.useDelete)({
331
330
  value,
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_element","_data","_blocks","_compose","_richText","_deprecated","_components","_autocomplete","_blockEdit","_formatToolbarContainer","_store","_useUndoAutomaticChange","_useMarkPersistent","_usePasteHandler","_useBeforeInputRules","_useInputRules","_useDelete","_useEnter","_useFormatTypes","_useRemoveBrowserShortcuts","_useShortcuts","_useInputEvents","_useInsertReplacementText","_useFirefoxCompat","_formatEdit","_utils","_content","_multiline","_shortcut","_toolbarButton","_inputEvent","keyboardShortcutContext","createContext","exports","inputEventContext","removeNativeProps","props","__unstableMobileNoFocusOnMount","deleteEnter","placeholderTextColor","textAlign","selectionColor","tagsToEliminate","disableEditingMenu","fontSize","fontFamily","fontWeight","fontStyle","minWidth","maxWidth","setRef","disableSuggestions","disableAutocorrection","restProps","RichTextWrapper","children","tagName","value","adjustedValue","onChange","adjustedOnChange","isSelected","originalIsSelected","multiline","inlineToolbar","wrapperClassName","autocompleters","onReplace","placeholder","allowedFormats","withoutInteractiveFormatting","onRemove","onMerge","onSplit","__unstableOnSplitAtEnd","onSplitAtEnd","__unstableOnSplitAtDoubleLineEnd","onSplitAtDoubleLineEnd","identifier","preserveWhiteSpace","__unstablePastePlainText","pastePlainText","__unstableEmbedURLOnPaste","__unstableDisableFormats","disableFormats","disableLineBreaks","__unstableAllowPrefixTransformations","forwardedRef","anchorRef","useRef","clientId","useBlockEditContext","selector","select","getSelectionStart","getSelectionEnd","blockEditorStore","selectionStart","selectionEnd","undefined","attributeKey","offset","useSelect","getBlockRootClientId","selectionChange","useDispatch","adjustedAllowedFormats","getAllowedFormats","hasFormats","length","onSelectionChange","useCallback","start","end","selection","unset","formatTypes","prepareHandlers","valueHandlers","changeHandlers","dependencies","useFormatTypes","addEditorOnlyFormats","reduce","accumulator","fn","text","formats","removeEditorOnlyFormats","forEach","formatType","__experimentalCreatePrepareEditableTree","removeFormat","name","addInvisibleFormats","getValue","ref","richTextRef","useRichText","html","__unstableFormats","__unstableText","Object","values","changeHandler","__unstableIsSelected","__unstableDependencies","__unstableAfterParse","__unstableBeforeSerialize","__unstableAddInvisibleFormats","autocompleteProps","useBlockEditorAutocompleteProps","completers","record","useMarkPersistent","keyboardShortcuts","Set","inputEvents","onFocus","current","focus","TagName","_react","createElement","Fragment","Provider","Popover","__unstableSlotNameProvider","default","inline","editableContentElement","role","useMergeRefs","useBeforeInputRules","useInputRules","useInsertReplacementText","useRemoveBrowserShortcuts","useShortcuts","useInputEvents","useUndoAutomaticChange","usePasteHandler","useDelete","useEnter","useFirefoxCompat","contentEditable","suppressContentEditableWarning","className","classnames","tabIndex","ForwardedRichTextWrapper","forwardRef","RichTextSwitcher","Array","isArray","deprecated","since","version","alternative","link","childrenSource","toHTML","newValue","fromDOM","__unstableCreateElement","document","childNodes","Component","RichTextMultiline","instanceId","useInstanceId","ForwardedRichTextContainer","Content","isEmpty","_default"],"sources":["@wordpress/block-editor/src/components/rich-text/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseCallback,\n\tforwardRef,\n\tcreateContext,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { children as childrenSource } from '@wordpress/blocks';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport {\n\t__unstableUseRichText as useRichText,\n\t__unstableCreateElement,\n\tremoveFormat,\n} from '@wordpress/rich-text';\nimport deprecated from '@wordpress/deprecated';\nimport { Popover } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditorAutocompleteProps } from '../autocomplete';\nimport { useBlockEditContext } from '../block-edit';\nimport FormatToolbarContainer from './format-toolbar-container';\nimport { store as blockEditorStore } from '../../store';\nimport { useUndoAutomaticChange } from './use-undo-automatic-change';\nimport { useMarkPersistent } from './use-mark-persistent';\nimport { usePasteHandler } from './use-paste-handler';\nimport { useBeforeInputRules } from './use-before-input-rules';\nimport { useInputRules } from './use-input-rules';\nimport { useDelete } from './use-delete';\nimport { useEnter } from './use-enter';\nimport { useFormatTypes } from './use-format-types';\nimport { useRemoveBrowserShortcuts } from './use-remove-browser-shortcuts';\nimport { useShortcuts } from './use-shortcuts';\nimport { useInputEvents } from './use-input-events';\nimport { useInsertReplacementText } from './use-insert-replacement-text';\nimport { useFirefoxCompat } from './use-firefox-compat';\nimport FormatEdit from './format-edit';\nimport { getAllowedFormats } from './utils';\nimport { Content } from './content';\nimport RichTextMultiline from './multiline';\n\nexport const keyboardShortcutContext = createContext();\nexport const inputEventContext = createContext();\n\n/**\n * Removes props used for the native version of RichText so that they are not\n * passed to the DOM element and log warnings.\n *\n * @param {Object} props Props to filter.\n *\n * @return {Object} Filtered props.\n */\nfunction removeNativeProps( props ) {\n\tconst {\n\t\t__unstableMobileNoFocusOnMount,\n\t\tdeleteEnter,\n\t\tplaceholderTextColor,\n\t\ttextAlign,\n\t\tselectionColor,\n\t\ttagsToEliminate,\n\t\tdisableEditingMenu,\n\t\tfontSize,\n\t\tfontFamily,\n\t\tfontWeight,\n\t\tfontStyle,\n\t\tminWidth,\n\t\tmaxWidth,\n\t\tsetRef,\n\t\tdisableSuggestions,\n\t\tdisableAutocorrection,\n\t\t...restProps\n\t} = props;\n\treturn restProps;\n}\n\nexport function RichTextWrapper(\n\t{\n\t\tchildren,\n\t\ttagName = 'div',\n\t\tvalue: adjustedValue = '',\n\t\tonChange: adjustedOnChange,\n\t\tisSelected: originalIsSelected,\n\t\tmultiline,\n\t\tinlineToolbar,\n\t\twrapperClassName,\n\t\tautocompleters,\n\t\tonReplace,\n\t\tplaceholder,\n\t\tallowedFormats,\n\t\twithoutInteractiveFormatting,\n\t\tonRemove,\n\t\tonMerge,\n\t\tonSplit,\n\t\t__unstableOnSplitAtEnd: onSplitAtEnd,\n\t\t__unstableOnSplitAtDoubleLineEnd: onSplitAtDoubleLineEnd,\n\t\tidentifier,\n\t\tpreserveWhiteSpace,\n\t\t__unstablePastePlainText: pastePlainText,\n\t\t__unstableEmbedURLOnPaste,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tdisableLineBreaks,\n\t\t__unstableAllowPrefixTransformations,\n\t\t...props\n\t},\n\tforwardedRef\n) {\n\tprops = removeNativeProps( props );\n\n\tconst anchorRef = useRef();\n\tconst { clientId } = useBlockEditContext();\n\tconst selector = ( select ) => {\n\t\tconst { getSelectionStart, getSelectionEnd } =\n\t\t\tselect( blockEditorStore );\n\t\tconst selectionStart = getSelectionStart();\n\t\tconst selectionEnd = getSelectionEnd();\n\n\t\tlet isSelected;\n\n\t\tif ( originalIsSelected === undefined ) {\n\t\t\tisSelected =\n\t\t\t\tselectionStart.clientId === clientId &&\n\t\t\t\tselectionEnd.clientId === clientId &&\n\t\t\t\tselectionStart.attributeKey === identifier;\n\t\t} else if ( originalIsSelected ) {\n\t\t\tisSelected = selectionStart.clientId === clientId;\n\t\t}\n\n\t\treturn {\n\t\t\tselectionStart: isSelected ? selectionStart.offset : undefined,\n\t\t\tselectionEnd: isSelected ? selectionEnd.offset : undefined,\n\t\t\tisSelected,\n\t\t};\n\t};\n\t// This selector must run on every render so the right selection state is\n\t// retrieved from the store on merge.\n\t// To do: fix this somehow.\n\tconst { selectionStart, selectionEnd, isSelected } = useSelect( selector );\n\tconst { getSelectionStart, getSelectionEnd, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst { selectionChange } = useDispatch( blockEditorStore );\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats,\n\t\tdisableFormats,\n\t} );\n\tconst hasFormats =\n\t\t! adjustedAllowedFormats || adjustedAllowedFormats.length > 0;\n\n\tconst onSelectionChange = useCallback(\n\t\t( start, end ) => {\n\t\t\tconst selection = {};\n\t\t\tconst unset = start === undefined && end === undefined;\n\n\t\t\tif ( typeof start === 'number' || unset ) {\n\t\t\t\t// If we are only setting the start (or the end below), which\n\t\t\t\t// means a partial selection, and we're not updating a selection\n\t\t\t\t// with the same client ID, abort. This means the selected block\n\t\t\t\t// is a parent block.\n\t\t\t\tif (\n\t\t\t\t\tend === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionEnd().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.start = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: start,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( typeof end === 'number' || unset ) {\n\t\t\t\tif (\n\t\t\t\t\tstart === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionStart().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.end = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: end,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tselectionChange( selection );\n\t\t},\n\t\t[ clientId, identifier ]\n\t);\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier,\n\t\twithoutInteractiveFormatting,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tconst {\n\t\tvalue,\n\t\tgetValue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: adjustedValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tadjustedOnChange( html );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart,\n\t\tselectionEnd,\n\t\tonSelectionChange,\n\t\tplaceholder,\n\t\t__unstableIsSelected: isSelected,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tpreserveWhiteSpace,\n\t\t__unstableDependencies: [ ...dependencies, tagName ],\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\tconst autocompleteProps = useBlockEditorAutocompleteProps( {\n\t\tonReplace,\n\t\tcompleters: autocompleters,\n\t\trecord: value,\n\t\tonChange,\n\t} );\n\n\tuseMarkPersistent( { html: adjustedValue, value } );\n\n\tconst keyboardShortcuts = useRef( new Set() );\n\tconst inputEvents = useRef( new Set() );\n\n\tfunction onFocus() {\n\t\tanchorRef.current?.focus();\n\t}\n\n\tconst TagName = tagName;\n\treturn (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<Popover.__unstableSlotNameProvider value=\"__unstable-block-tools-after\">\n\t\t\t\t\t\t\t{ children &&\n\t\t\t\t\t\t\t\tchildren( { value, onChange, onFocus } ) }\n\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Popover.__unstableSlotNameProvider>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t{ isSelected && hasFormats && (\n\t\t\t\t<FormatToolbarContainer\n\t\t\t\t\tinline={ inlineToolbar }\n\t\t\t\t\teditableContentElement={ anchorRef.current }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<TagName\n\t\t\t\t// Overridable props.\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline={ ! disableLineBreaks }\n\t\t\t\taria-label={ placeholder }\n\t\t\t\t{ ...props }\n\t\t\t\t{ ...autocompleteProps }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tforwardedRef,\n\t\t\t\t\tautocompleteProps.ref,\n\t\t\t\t\tprops.ref,\n\t\t\t\t\trichTextRef,\n\t\t\t\t\tuseBeforeInputRules( { value, onChange } ),\n\t\t\t\t\tuseInputRules( {\n\t\t\t\t\t\tgetValue,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tselectionChange,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseInsertReplacementText(),\n\t\t\t\t\tuseRemoveBrowserShortcuts(),\n\t\t\t\t\tuseShortcuts( keyboardShortcuts ),\n\t\t\t\t\tuseInputEvents( inputEvents ),\n\t\t\t\t\tuseUndoAutomaticChange(),\n\t\t\t\t\tusePasteHandler( {\n\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\tdisableFormats,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\ttagName,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t\t\tpastePlainText,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseDelete( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonMerge,\n\t\t\t\t\t\tonRemove,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseEnter( {\n\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tdisableLineBreaks,\n\t\t\t\t\t\tonSplitAtEnd,\n\t\t\t\t\t\tonSplitAtDoubleLineEnd,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseFirefoxCompat(),\n\t\t\t\t\tanchorRef,\n\t\t\t\t] ) }\n\t\t\t\tcontentEditable={ true }\n\t\t\t\tsuppressContentEditableWarning={ true }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-rich-text__editable',\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'rich-text'\n\t\t\t\t) }\n\t\t\t\t// Setting tabIndex to 0 is unnecessary, the element is already\n\t\t\t\t// focusable because it's contentEditable. This also fixes a\n\t\t\t\t// Safari bug where it's not possible to Shift+Click multi\n\t\t\t\t// select blocks when Shift Clicking into an element with\n\t\t\t\t// tabIndex because Safari will focus the element. However,\n\t\t\t\t// Safari will correctly ignore nested contentEditable elements.\n\t\t\t\ttabIndex={ props.tabIndex === 0 ? null : props.tabIndex }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nconst ForwardedRichTextWrapper = forwardRef( RichTextWrapper );\n\nfunction RichTextSwitcher( props, ref ) {\n\tlet value = props.value;\n\tlet onChange = props.onChange;\n\n\t// Handle deprecated format.\n\tif ( Array.isArray( value ) ) {\n\t\tdeprecated( 'wp.blockEditor.RichText value prop as children type', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: 'value prop as string',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/',\n\t\t} );\n\n\t\tvalue = childrenSource.toHTML( props.value );\n\t\tonChange = ( newValue ) =>\n\t\t\tprops.onChange(\n\t\t\t\tchildrenSource.fromDOM(\n\t\t\t\t\t__unstableCreateElement( document, newValue ).childNodes\n\t\t\t\t)\n\t\t\t);\n\t}\n\n\tconst Component = props.multiline\n\t\t? RichTextMultiline\n\t\t: ForwardedRichTextWrapper;\n\tconst instanceId = useInstanceId( RichTextSwitcher );\n\n\treturn (\n\t\t<Component\n\t\t\t{ ...props }\n\t\t\tidentifier={ props.identifier || instanceId }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tref={ ref }\n\t\t/>\n\t);\n}\n\nconst ForwardedRichTextContainer = forwardRef( RichTextSwitcher );\n\nForwardedRichTextContainer.Content = Content;\nForwardedRichTextContainer.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md\n */\nexport default ForwardedRichTextContainer;\nexport { RichTextShortcut } from './shortcut';\nexport { RichTextToolbarButton } from './toolbar-button';\nexport { __unstableRichTextInputEvent } from './input-event';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;A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EAAG1C,KAAK,CAAC0C,UAAU,IAAIkI,UAAY;IAC7CvJ,KAAK,EAAGA,KAAO;IACfE,QAAQ,EAAGA,QAAU;IACrB6E,GAAG,EAAGA;EAAK,CACX,CAAC;AAEJ;AAEA,MAAM0E,0BAA0B,GAAG,IAAApB,mBAAU,EAAEC,gBAAiB,CAAC;AAEjEmB,0BAA0B,CAACC,OAAO,GAAGA,gBAAO;AAC5CD,0BAA0B,CAACE,OAAO,GAAK3J,KAAK,IAAM;EACjD,OAAO,CAAEA,KAAK,IAAIA,KAAK,CAACoD,MAAM,KAAK,CAAC;AACrC,CAAC;;AAED;AACA;AACA;AAFA,IAAAwG,QAAA,GAGeH,0BAA0B;AAAAjL,OAAA,CAAAuI,OAAA,GAAA6C,QAAA"}
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_element","_data","_blocks","_compose","_richText","_deprecated","_components","_autocomplete","_blockEdit","_formatToolbarContainer","_store","_useUndoAutomaticChange","_useMarkPersistent","_usePasteHandler","_useBeforeInputRules","_useInputRules","_useDelete","_useEnter","_useFormatTypes","_useRemoveBrowserShortcuts","_useShortcuts","_useInputEvents","_useInsertReplacementText","_useFirefoxCompat","_formatEdit","_utils","_content","_multiline","_shortcut","_toolbarButton","_inputEvent","keyboardShortcutContext","createContext","exports","inputEventContext","removeNativeProps","props","__unstableMobileNoFocusOnMount","deleteEnter","placeholderTextColor","textAlign","selectionColor","tagsToEliminate","disableEditingMenu","fontSize","fontFamily","fontWeight","fontStyle","minWidth","maxWidth","setRef","disableSuggestions","disableAutocorrection","restProps","RichTextWrapper","children","tagName","value","adjustedValue","onChange","adjustedOnChange","isSelected","originalIsSelected","multiline","inlineToolbar","wrapperClassName","autocompleters","onReplace","placeholder","allowedFormats","withoutInteractiveFormatting","onRemove","onMerge","onSplit","__unstableOnSplitAtEnd","onSplitAtEnd","__unstableOnSplitAtDoubleLineEnd","onSplitAtDoubleLineEnd","identifier","preserveWhiteSpace","__unstablePastePlainText","pastePlainText","__unstableEmbedURLOnPaste","__unstableDisableFormats","disableFormats","disableLineBreaks","__unstableAllowPrefixTransformations","forwardedRef","anchorRef","useRef","clientId","useBlockEditContext","selector","select","getSelectionStart","getSelectionEnd","blockEditorStore","selectionStart","selectionEnd","undefined","attributeKey","offset","useSelect","getBlockRootClientId","selectionChange","useDispatch","adjustedAllowedFormats","getAllowedFormats","hasFormats","length","onSelectionChange","useCallback","start","end","selection","unset","formatTypes","prepareHandlers","valueHandlers","changeHandlers","dependencies","useFormatTypes","addEditorOnlyFormats","reduce","accumulator","fn","text","formats","removeEditorOnlyFormats","forEach","formatType","__experimentalCreatePrepareEditableTree","removeFormat","name","addInvisibleFormats","getValue","ref","richTextRef","useRichText","html","__unstableFormats","__unstableText","Object","values","changeHandler","__unstableIsSelected","__unstableDependencies","__unstableAfterParse","__unstableBeforeSerialize","__unstableAddInvisibleFormats","autocompleteProps","useBlockEditorAutocompleteProps","completers","record","useMarkPersistent","keyboardShortcuts","Set","inputEvents","onFocus","current","focus","TagName","_react","createElement","Fragment","Provider","Popover","__unstableSlotNameProvider","default","inline","editableContentElement","role","useMergeRefs","useBeforeInputRules","useInputRules","useInsertReplacementText","useRemoveBrowserShortcuts","useShortcuts","useInputEvents","useUndoAutomaticChange","usePasteHandler","useDelete","useEnter","useFirefoxCompat","contentEditable","suppressContentEditableWarning","className","classnames","tabIndex","ForwardedRichTextWrapper","forwardRef","RichTextSwitcher","Array","isArray","deprecated","since","version","alternative","link","childrenSource","toHTML","newValue","fromDOM","__unstableCreateElement","document","childNodes","Component","RichTextMultiline","instanceId","useInstanceId","ForwardedRichTextContainer","Content","isEmpty","_default"],"sources":["@wordpress/block-editor/src/components/rich-text/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseCallback,\n\tforwardRef,\n\tcreateContext,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { children as childrenSource } from '@wordpress/blocks';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport {\n\t__unstableUseRichText as useRichText,\n\t__unstableCreateElement,\n\tremoveFormat,\n} from '@wordpress/rich-text';\nimport deprecated from '@wordpress/deprecated';\nimport { Popover } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditorAutocompleteProps } from '../autocomplete';\nimport { useBlockEditContext } from '../block-edit';\nimport FormatToolbarContainer from './format-toolbar-container';\nimport { store as blockEditorStore } from '../../store';\nimport { useUndoAutomaticChange } from './use-undo-automatic-change';\nimport { useMarkPersistent } from './use-mark-persistent';\nimport { usePasteHandler } from './use-paste-handler';\nimport { useBeforeInputRules } from './use-before-input-rules';\nimport { useInputRules } from './use-input-rules';\nimport { useDelete } from './use-delete';\nimport { useEnter } from './use-enter';\nimport { useFormatTypes } from './use-format-types';\nimport { useRemoveBrowserShortcuts } from './use-remove-browser-shortcuts';\nimport { useShortcuts } from './use-shortcuts';\nimport { useInputEvents } from './use-input-events';\nimport { useInsertReplacementText } from './use-insert-replacement-text';\nimport { useFirefoxCompat } from './use-firefox-compat';\nimport FormatEdit from './format-edit';\nimport { getAllowedFormats } from './utils';\nimport { Content } from './content';\nimport RichTextMultiline from './multiline';\n\nexport const keyboardShortcutContext = createContext();\nexport const inputEventContext = createContext();\n\n/**\n * Removes props used for the native version of RichText so that they are not\n * passed to the DOM element and log warnings.\n *\n * @param {Object} props Props to filter.\n *\n * @return {Object} Filtered props.\n */\nfunction removeNativeProps( props ) {\n\tconst {\n\t\t__unstableMobileNoFocusOnMount,\n\t\tdeleteEnter,\n\t\tplaceholderTextColor,\n\t\ttextAlign,\n\t\tselectionColor,\n\t\ttagsToEliminate,\n\t\tdisableEditingMenu,\n\t\tfontSize,\n\t\tfontFamily,\n\t\tfontWeight,\n\t\tfontStyle,\n\t\tminWidth,\n\t\tmaxWidth,\n\t\tsetRef,\n\t\tdisableSuggestions,\n\t\tdisableAutocorrection,\n\t\t...restProps\n\t} = props;\n\treturn restProps;\n}\n\nexport function RichTextWrapper(\n\t{\n\t\tchildren,\n\t\ttagName = 'div',\n\t\tvalue: adjustedValue = '',\n\t\tonChange: adjustedOnChange,\n\t\tisSelected: originalIsSelected,\n\t\tmultiline,\n\t\tinlineToolbar,\n\t\twrapperClassName,\n\t\tautocompleters,\n\t\tonReplace,\n\t\tplaceholder,\n\t\tallowedFormats,\n\t\twithoutInteractiveFormatting,\n\t\tonRemove,\n\t\tonMerge,\n\t\tonSplit,\n\t\t__unstableOnSplitAtEnd: onSplitAtEnd,\n\t\t__unstableOnSplitAtDoubleLineEnd: onSplitAtDoubleLineEnd,\n\t\tidentifier,\n\t\tpreserveWhiteSpace,\n\t\t__unstablePastePlainText: pastePlainText,\n\t\t__unstableEmbedURLOnPaste,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tdisableLineBreaks,\n\t\t__unstableAllowPrefixTransformations,\n\t\t...props\n\t},\n\tforwardedRef\n) {\n\tprops = removeNativeProps( props );\n\n\tconst anchorRef = useRef();\n\tconst { clientId } = useBlockEditContext();\n\tconst selector = ( select ) => {\n\t\tconst { getSelectionStart, getSelectionEnd } =\n\t\t\tselect( blockEditorStore );\n\t\tconst selectionStart = getSelectionStart();\n\t\tconst selectionEnd = getSelectionEnd();\n\n\t\tlet isSelected;\n\n\t\tif ( originalIsSelected === undefined ) {\n\t\t\tisSelected =\n\t\t\t\tselectionStart.clientId === clientId &&\n\t\t\t\tselectionEnd.clientId === clientId &&\n\t\t\t\tselectionStart.attributeKey === identifier;\n\t\t} else if ( originalIsSelected ) {\n\t\t\tisSelected = selectionStart.clientId === clientId;\n\t\t}\n\n\t\treturn {\n\t\t\tselectionStart: isSelected ? selectionStart.offset : undefined,\n\t\t\tselectionEnd: isSelected ? selectionEnd.offset : undefined,\n\t\t\tisSelected,\n\t\t};\n\t};\n\t// This selector must run on every render so the right selection state is\n\t// retrieved from the store on merge.\n\t// To do: fix this somehow.\n\tconst { selectionStart, selectionEnd, isSelected } = useSelect( selector );\n\tconst { getSelectionStart, getSelectionEnd, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst { selectionChange } = useDispatch( blockEditorStore );\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats,\n\t\tdisableFormats,\n\t} );\n\tconst hasFormats =\n\t\t! adjustedAllowedFormats || adjustedAllowedFormats.length > 0;\n\n\tconst onSelectionChange = useCallback(\n\t\t( start, end ) => {\n\t\t\tconst selection = {};\n\t\t\tconst unset = start === undefined && end === undefined;\n\n\t\t\tif ( typeof start === 'number' || unset ) {\n\t\t\t\t// If we are only setting the start (or the end below), which\n\t\t\t\t// means a partial selection, and we're not updating a selection\n\t\t\t\t// with the same client ID, abort. This means the selected block\n\t\t\t\t// is a parent block.\n\t\t\t\tif (\n\t\t\t\t\tend === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionEnd().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.start = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: start,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( typeof end === 'number' || unset ) {\n\t\t\t\tif (\n\t\t\t\t\tstart === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionStart().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.end = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: end,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tselectionChange( selection );\n\t\t},\n\t\t[ clientId, identifier ]\n\t);\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier,\n\t\twithoutInteractiveFormatting,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tconst {\n\t\tvalue,\n\t\tgetValue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: adjustedValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tadjustedOnChange( html );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart,\n\t\tselectionEnd,\n\t\tonSelectionChange,\n\t\tplaceholder,\n\t\t__unstableIsSelected: isSelected,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tpreserveWhiteSpace,\n\t\t__unstableDependencies: [ ...dependencies, tagName ],\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\tconst autocompleteProps = useBlockEditorAutocompleteProps( {\n\t\tonReplace,\n\t\tcompleters: autocompleters,\n\t\trecord: value,\n\t\tonChange,\n\t} );\n\n\tuseMarkPersistent( { html: adjustedValue, value } );\n\n\tconst keyboardShortcuts = useRef( new Set() );\n\tconst inputEvents = useRef( new Set() );\n\n\tfunction onFocus() {\n\t\tanchorRef.current?.focus();\n\t}\n\n\tconst TagName = tagName;\n\treturn (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<Popover.__unstableSlotNameProvider value=\"__unstable-block-tools-after\">\n\t\t\t\t\t\t\t{ children &&\n\t\t\t\t\t\t\t\tchildren( { value, onChange, onFocus } ) }\n\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Popover.__unstableSlotNameProvider>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t{ isSelected && hasFormats && (\n\t\t\t\t<FormatToolbarContainer\n\t\t\t\t\tinline={ inlineToolbar }\n\t\t\t\t\teditableContentElement={ anchorRef.current }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<TagName\n\t\t\t\t// Overridable props.\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline={ ! disableLineBreaks }\n\t\t\t\taria-label={ placeholder }\n\t\t\t\t{ ...props }\n\t\t\t\t{ ...autocompleteProps }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tforwardedRef,\n\t\t\t\t\tautocompleteProps.ref,\n\t\t\t\t\tprops.ref,\n\t\t\t\t\trichTextRef,\n\t\t\t\t\tuseBeforeInputRules( { value, onChange } ),\n\t\t\t\t\tuseInputRules( {\n\t\t\t\t\t\tgetValue,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tselectionChange,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseInsertReplacementText(),\n\t\t\t\t\tuseRemoveBrowserShortcuts(),\n\t\t\t\t\tuseShortcuts( keyboardShortcuts ),\n\t\t\t\t\tuseInputEvents( inputEvents ),\n\t\t\t\t\tuseUndoAutomaticChange(),\n\t\t\t\t\tusePasteHandler( {\n\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\tdisableFormats,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\ttagName,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\t\t\tpastePlainText,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseDelete( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonMerge,\n\t\t\t\t\t\tonRemove,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseEnter( {\n\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tdisableLineBreaks,\n\t\t\t\t\t\tonSplitAtEnd,\n\t\t\t\t\t\tonSplitAtDoubleLineEnd,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseFirefoxCompat(),\n\t\t\t\t\tanchorRef,\n\t\t\t\t] ) }\n\t\t\t\tcontentEditable={ true }\n\t\t\t\tsuppressContentEditableWarning={ true }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-rich-text__editable',\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'rich-text'\n\t\t\t\t) }\n\t\t\t\t// Setting tabIndex to 0 is unnecessary, the element is already\n\t\t\t\t// focusable because it's contentEditable. This also fixes a\n\t\t\t\t// Safari bug where it's not possible to Shift+Click multi\n\t\t\t\t// select blocks when Shift Clicking into an element with\n\t\t\t\t// tabIndex because Safari will focus the element. However,\n\t\t\t\t// Safari will correctly ignore nested contentEditable elements.\n\t\t\t\ttabIndex={ props.tabIndex === 0 ? null : props.tabIndex }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nconst ForwardedRichTextWrapper = forwardRef( RichTextWrapper );\n\nfunction RichTextSwitcher( props, ref ) {\n\tlet value = props.value;\n\tlet onChange = props.onChange;\n\n\t// Handle deprecated format.\n\tif ( Array.isArray( value ) ) {\n\t\tdeprecated( 'wp.blockEditor.RichText value prop as children type', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: 'value prop as string',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/',\n\t\t} );\n\n\t\tvalue = childrenSource.toHTML( props.value );\n\t\tonChange = ( newValue ) =>\n\t\t\tprops.onChange(\n\t\t\t\tchildrenSource.fromDOM(\n\t\t\t\t\t__unstableCreateElement( document, newValue ).childNodes\n\t\t\t\t)\n\t\t\t);\n\t}\n\n\tconst Component = props.multiline\n\t\t? RichTextMultiline\n\t\t: ForwardedRichTextWrapper;\n\tconst instanceId = useInstanceId( RichTextSwitcher );\n\n\treturn (\n\t\t<Component\n\t\t\t{ ...props }\n\t\t\tidentifier={ props.identifier || instanceId }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tref={ ref }\n\t\t/>\n\t);\n}\n\nconst ForwardedRichTextContainer = forwardRef( RichTextSwitcher );\n\nForwardedRichTextContainer.Content = Content;\nForwardedRichTextContainer.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md\n */\nexport default ForwardedRichTextContainer;\nexport { RichTextShortcut } from './shortcut';\nexport { RichTextToolbarButton } from './toolbar-button';\nexport { __unstableRichTextInputEvent } from './input-event';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAMA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAKA,IAAAM,WAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAKA,IAAAQ,aAAA,GAAAR,OAAA;AACA,IAAAS,UAAA,GAAAT,OAAA;AACA,IAAAU,uBAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,uBAAA,GAAAZ,OAAA;AACA,IAAAa,kBAAA,GAAAb,OAAA;AACA,IAAAc,gBAAA,GAAAd,OAAA;AACA,IAAAe,oBAAA,GAAAf,OAAA;AACA,IAAAgB,cAAA,GAAAhB,OAAA;AACA,IAAAiB,UAAA,GAAAjB,OAAA;AACA,IAAAkB,SAAA,GAAAlB,OAAA;AACA,IAAAmB,eAAA,GAAAnB,OAAA;AACA,IAAAoB,0BAAA,GAAApB,OAAA;AACA,IAAAqB,aAAA,GAAArB,OAAA;AACA,IAAAsB,eAAA,GAAAtB,OAAA;AACA,IAAAuB,yBAAA,GAAAvB,OAAA;AACA,IAAAwB,iBAAA,GAAAxB,OAAA;AACA,IAAAyB,WAAA,GAAA1B,sBAAA,CAAAC,OAAA;AACA,IAAA0B,MAAA,GAAA1B,OAAA;AACA,IAAA2B,QAAA,GAAA3B,OAAA;AACA,IAAA4B,UAAA,GAAA7B,sBAAA,CAAA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,QAAS,CAAC,CAACI,UAC/C,CACD,CAAC;EACH;EAEA,MAAMC,SAAS,GAAG1K,KAAK,CAAC2B,SAAS,GAC9BgJ,kBAAiB,GACjBlB,wBAAwB;EAC3B,MAAMmB,UAAU,GAAG,IAAAC,sBAAa,EAAElB,gBAAiB,CAAC;EAEpD,OACC,IAAA7B,MAAA,CAAAC,aAAA,EAAC2C,SAAS;IAAA,GACJ1K,KAAK;IACV0C,UAAU,EAAG1C,KAAK,CAAC0C,UAAU,IAAIkI,UAAY;IAC7CvJ,KAAK,EAAGA,KAAO;IACfE,QAAQ,EAAGA,QAAU;IACrB6E,GAAG,EAAGA;EAAK,CACX,CAAC;AAEJ;AAEA,MAAM0E,0BAA0B,GAAG,IAAApB,mBAAU,EAAEC,gBAAiB,CAAC;AAEjEmB,0BAA0B,CAACC,OAAO,GAAGA,gBAAO;AAC5CD,0BAA0B,CAACE,OAAO,GAAK3J,KAAK,IAAM;EACjD,OAAO,CAAEA,KAAK,IAAIA,KAAK,CAACoD,MAAM,KAAK,CAAC;AACrC,CAAC;;AAED;AACA;AACA;AAFA,IAAAwG,QAAA,GAGeH,0BAA0B;AAAAjL,OAAA,CAAAuI,OAAA,GAAA6C,QAAA"}
@@ -40,6 +40,7 @@ var _store = require("../../store");
40
40
  var _utils = require("./utils");
41
41
  var _embedHandlerPicker = _interopRequireDefault(require("./embed-handler-picker"));
42
42
  var _content = require("./content");
43
+ var _native = _interopRequireDefault(require("./native"));
43
44
  var _shortcut = require("./shortcut");
44
45
  var _toolbarButton = require("./toolbar-button");
45
46
  var _inputEvent = require("./input-event");
@@ -209,7 +210,7 @@ function RichTextWrapper({
209
210
  // an intentional user interaction distinguishing between Backspace and
210
211
  // Delete to remove the empty field, but also to avoid merge & remove
211
212
  // causing destruction of two fields (merge, then removed merged).
212
- if (onRemove && (0, _richText.isEmpty)(value) && isReverse) {
213
+ else if (onRemove && (0, _richText.isEmpty)(value) && isReverse) {
213
214
  onRemove(!isReverse);
214
215
  }
215
216
  }, [onMerge, onRemove]);
@@ -455,7 +456,7 @@ function RichTextWrapper({
455
456
  __unstableMarkAutomaticChange();
456
457
  }, [onReplace, __unstableMarkAutomaticChange]);
457
458
  const mergedRef = (0, _compose.useMergeRefs)([forwardedRef, fallbackRef]);
458
- return (0, _react.createElement)(_richText.__experimentalRichText, {
459
+ return (0, _react.createElement)(_native.default, {
459
460
  clientId: clientId,
460
461
  identifier: identifier,
461
462
  ref: mergedRef,
@@ -569,6 +570,7 @@ ForwardedRichTextContainer.Content.defaultProps = {
569
570
  format: 'string',
570
571
  value: ''
571
572
  };
573
+ ForwardedRichTextContainer.Raw = _native.default;
572
574
 
573
575
  /**
574
576
  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md