@wordpress/block-editor 12.13.0 → 12.14.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 (344) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-heading-level-dropdown/index.js +1 -1
  3. package/build/components/block-heading-level-dropdown/index.js.map +1 -1
  4. package/build/components/block-list/index.js +2 -9
  5. package/build/components/block-list/index.js.map +1 -1
  6. package/build/components/block-list-appender/index.js +16 -3
  7. package/build/components/block-list-appender/index.js.map +1 -1
  8. package/build/components/block-quick-navigation/index.js +6 -4
  9. package/build/components/block-quick-navigation/index.js.map +1 -1
  10. package/build/components/block-styles/index.js +0 -8
  11. package/build/components/block-styles/index.js.map +1 -1
  12. package/build/components/block-switcher/pattern-transformations-menu.js +18 -14
  13. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  14. package/build/components/block-tools/back-compat.js +2 -2
  15. package/build/components/block-tools/back-compat.js.map +1 -1
  16. package/build/components/block-tools/block-contextual-toolbar.js +11 -81
  17. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  18. package/build/components/block-tools/empty-block-inserter.js +56 -0
  19. package/build/components/block-tools/empty-block-inserter.js.map +1 -0
  20. package/build/components/block-tools/index.js +48 -9
  21. package/build/components/block-tools/index.js.map +1 -1
  22. package/build/components/block-tools/selected-block-tools.js +113 -0
  23. package/build/components/block-tools/selected-block-tools.js.map +1 -0
  24. package/build/components/block-tools/use-selected-block-tool-props.js +56 -0
  25. package/build/components/block-tools/use-selected-block-tool-props.js.map +1 -0
  26. package/build/components/editable-text/index.js +1 -2
  27. package/build/components/editable-text/index.js.map +1 -1
  28. package/build/components/iframe/index.js +4 -3
  29. package/build/components/iframe/index.js.map +1 -1
  30. package/build/components/inserter/block-patterns-explorer/{explorer.js → index.js} +7 -7
  31. package/build/components/inserter/block-patterns-explorer/index.js.map +1 -0
  32. package/build/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
  33. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
  34. package/build/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -4
  35. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
  36. package/build/components/inserter/block-patterns-tab/index.js +75 -0
  37. package/build/components/inserter/block-patterns-tab/index.js.map +1 -0
  38. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
  39. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
  40. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +108 -0
  41. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
  42. package/build/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +18 -34
  43. package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
  44. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +55 -0
  45. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
  46. package/build/components/inserter/block-patterns-tab/utils.js +70 -0
  47. package/build/components/inserter/block-patterns-tab/utils.js.map +1 -0
  48. package/build/components/inserter/media-tab/media-list.js +9 -5
  49. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  50. package/build/components/inserter/media-tab/media-preview.js +15 -12
  51. package/build/components/inserter/media-tab/media-preview.js.map +1 -1
  52. package/build/components/inserter/menu.js +3 -4
  53. package/build/components/inserter/menu.js.map +1 -1
  54. package/build/components/link-control/index.js +6 -5
  55. package/build/components/link-control/index.js.map +1 -1
  56. package/build/components/list-view/block-select-button.js +39 -0
  57. package/build/components/list-view/block-select-button.js.map +1 -1
  58. package/build/components/list-view/block.js +16 -3
  59. package/build/components/list-view/block.js.map +1 -1
  60. package/build/components/list-view/index.js +3 -2
  61. package/build/components/list-view/index.js.map +1 -1
  62. package/build/components/navigable-toolbar/index.js +69 -18
  63. package/build/components/navigable-toolbar/index.js.map +1 -1
  64. package/build/components/provider/use-block-sync.js +1 -14
  65. package/build/components/provider/use-block-sync.js.map +1 -1
  66. package/build/components/rich-text/index.js +0 -1
  67. package/build/components/rich-text/index.js.map +1 -1
  68. package/build/components/rich-text/index.native.js +3 -1
  69. package/build/components/rich-text/index.native.js.map +1 -1
  70. package/build/components/rich-text/native/format-edit.js +45 -0
  71. package/build/components/rich-text/native/format-edit.js.map +1 -0
  72. package/build/components/rich-text/native/get-format-colors.native.js +41 -0
  73. package/build/components/rich-text/native/get-format-colors.native.js.map +1 -0
  74. package/build/components/rich-text/native/index.js +9 -0
  75. package/build/components/rich-text/native/index.js.map +1 -0
  76. package/build/components/rich-text/native/index.native.js +1158 -0
  77. package/build/components/rich-text/native/index.native.js.map +1 -0
  78. package/build/components/rich-text/native/toolbar-button-with-options.native.js +58 -0
  79. package/build/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
  80. package/build/components/rich-text/native/use-format-types.js +111 -0
  81. package/build/components/rich-text/native/use-format-types.js.map +1 -0
  82. package/build/components/rich-text/use-paste-handler.js +2 -5
  83. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  84. package/build/components/url-popover/image-url-input-ui.js +2 -1
  85. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  86. package/build/components/writing-flow/use-tab-nav.js +7 -3
  87. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  88. package/build/hooks/align.js +10 -10
  89. package/build/hooks/align.js.map +1 -1
  90. package/build/hooks/align.native.js +2 -2
  91. package/build/hooks/align.native.js.map +1 -1
  92. package/build/hooks/anchor.js +7 -6
  93. package/build/hooks/anchor.js.map +1 -1
  94. package/build/hooks/background.js +16 -4
  95. package/build/hooks/background.js.map +1 -1
  96. package/build/hooks/block-hooks.js +7 -8
  97. package/build/hooks/block-hooks.js.map +1 -1
  98. package/build/hooks/block-rename-ui.js +7 -5
  99. package/build/hooks/block-rename-ui.js.map +1 -1
  100. package/build/hooks/content-lock-ui.js +5 -5
  101. package/build/hooks/content-lock-ui.js.map +1 -1
  102. package/build/hooks/custom-class-name.js +8 -7
  103. package/build/hooks/custom-class-name.js.map +1 -1
  104. package/build/hooks/custom-fields.js +4 -4
  105. package/build/hooks/custom-fields.js.map +1 -1
  106. package/build/hooks/duotone.js +9 -20
  107. package/build/hooks/duotone.js.map +1 -1
  108. package/build/hooks/layout.js +90 -86
  109. package/build/hooks/layout.js.map +1 -1
  110. package/build/hooks/position.js +10 -9
  111. package/build/hooks/position.js.map +1 -1
  112. package/build/hooks/style.js +10 -13
  113. package/build/hooks/style.js.map +1 -1
  114. package/build/hooks/utils.js +30 -0
  115. package/build/hooks/utils.js.map +1 -1
  116. package/build/private-apis.js +3 -0
  117. package/build/private-apis.js.map +1 -1
  118. package/build/store/actions.js +30 -37
  119. package/build/store/actions.js.map +1 -1
  120. package/build/store/reducer.js +18 -0
  121. package/build/store/reducer.js.map +1 -1
  122. package/build/store/selectors.js +16 -13
  123. package/build/store/selectors.js.map +1 -1
  124. package/build-module/components/block-heading-level-dropdown/index.js +1 -1
  125. package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
  126. package/build-module/components/block-list/index.js +3 -10
  127. package/build-module/components/block-list/index.js.map +1 -1
  128. package/build-module/components/block-list-appender/index.js +16 -3
  129. package/build-module/components/block-list-appender/index.js.map +1 -1
  130. package/build-module/components/block-quick-navigation/index.js +7 -5
  131. package/build-module/components/block-quick-navigation/index.js.map +1 -1
  132. package/build-module/components/block-styles/index.js +0 -8
  133. package/build-module/components/block-styles/index.js.map +1 -1
  134. package/build-module/components/block-switcher/pattern-transformations-menu.js +17 -13
  135. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  136. package/build-module/components/block-tools/back-compat.js +1 -1
  137. package/build-module/components/block-tools/back-compat.js.map +1 -1
  138. package/build-module/components/block-tools/block-contextual-toolbar.js +11 -80
  139. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  140. package/build-module/components/block-tools/empty-block-inserter.js +48 -0
  141. package/build-module/components/block-tools/empty-block-inserter.js.map +1 -0
  142. package/build-module/components/block-tools/index.js +48 -9
  143. package/build-module/components/block-tools/index.js.map +1 -1
  144. package/build-module/components/block-tools/selected-block-tools.js +105 -0
  145. package/build-module/components/block-tools/selected-block-tools.js.map +1 -0
  146. package/build-module/components/block-tools/use-selected-block-tool-props.js +50 -0
  147. package/build-module/components/block-tools/use-selected-block-tool-props.js.map +1 -0
  148. package/build-module/components/editable-text/index.js +1 -2
  149. package/build-module/components/editable-text/index.js.map +1 -1
  150. package/build-module/components/iframe/index.js +4 -3
  151. package/build-module/components/iframe/index.js.map +1 -1
  152. package/build-module/components/inserter/block-patterns-explorer/{explorer.js → index.js} +5 -5
  153. package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -0
  154. package/build-module/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
  155. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
  156. package/build-module/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +2 -2
  157. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
  158. package/build-module/components/inserter/block-patterns-tab/index.js +66 -0
  159. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -0
  160. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +42 -0
  161. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
  162. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +100 -0
  163. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
  164. package/build-module/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +7 -20
  165. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
  166. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +47 -0
  167. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
  168. package/build-module/components/inserter/block-patterns-tab/utils.js +58 -0
  169. package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -0
  170. package/build-module/components/inserter/media-tab/media-list.js +9 -5
  171. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  172. package/build-module/components/inserter/media-tab/media-preview.js +15 -12
  173. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
  174. package/build-module/components/inserter/menu.js +4 -3
  175. package/build-module/components/inserter/menu.js.map +1 -1
  176. package/build-module/components/link-control/index.js +7 -6
  177. package/build-module/components/link-control/index.js.map +1 -1
  178. package/build-module/components/list-view/block-select-button.js +39 -0
  179. package/build-module/components/list-view/block-select-button.js.map +1 -1
  180. package/build-module/components/list-view/block.js +16 -3
  181. package/build-module/components/list-view/block.js.map +1 -1
  182. package/build-module/components/list-view/index.js +3 -2
  183. package/build-module/components/list-view/index.js.map +1 -1
  184. package/build-module/components/navigable-toolbar/index.js +69 -17
  185. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  186. package/build-module/components/provider/use-block-sync.js +1 -14
  187. package/build-module/components/provider/use-block-sync.js.map +1 -1
  188. package/build-module/components/rich-text/index.js +0 -1
  189. package/build-module/components/rich-text/index.js.map +1 -1
  190. package/build-module/components/rich-text/index.native.js +3 -1
  191. package/build-module/components/rich-text/index.native.js.map +1 -1
  192. package/build-module/components/rich-text/native/format-edit.js +38 -0
  193. package/build-module/components/rich-text/native/format-edit.js.map +1 -0
  194. package/build-module/components/rich-text/native/get-format-colors.native.js +34 -0
  195. package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -0
  196. package/build-module/components/rich-text/native/index.js +2 -0
  197. package/build-module/components/rich-text/native/index.js.map +1 -0
  198. package/build-module/components/rich-text/native/index.native.js +1148 -0
  199. package/build-module/components/rich-text/native/index.native.js.map +1 -0
  200. package/build-module/components/rich-text/native/toolbar-button-with-options.native.js +51 -0
  201. package/build-module/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
  202. package/build-module/components/rich-text/native/use-format-types.js +104 -0
  203. package/build-module/components/rich-text/native/use-format-types.js.map +1 -0
  204. package/build-module/components/rich-text/use-paste-handler.js +2 -5
  205. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  206. package/build-module/components/url-popover/image-url-input-ui.js +2 -1
  207. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  208. package/build-module/components/writing-flow/use-tab-nav.js +7 -3
  209. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  210. package/build-module/hooks/align.js +8 -8
  211. package/build-module/hooks/align.js.map +1 -1
  212. package/build-module/hooks/align.native.js +2 -2
  213. package/build-module/hooks/align.native.js.map +1 -1
  214. package/build-module/hooks/anchor.js +5 -4
  215. package/build-module/hooks/anchor.js.map +1 -1
  216. package/build-module/hooks/background.js +17 -5
  217. package/build-module/hooks/background.js.map +1 -1
  218. package/build-module/hooks/block-hooks.js +5 -6
  219. package/build-module/hooks/block-hooks.js.map +1 -1
  220. package/build-module/hooks/block-rename-ui.js +5 -3
  221. package/build-module/hooks/block-rename-ui.js.map +1 -1
  222. package/build-module/hooks/content-lock-ui.js +3 -3
  223. package/build-module/hooks/content-lock-ui.js.map +1 -1
  224. package/build-module/hooks/custom-class-name.js +6 -5
  225. package/build-module/hooks/custom-class-name.js.map +1 -1
  226. package/build-module/hooks/custom-fields.js +4 -4
  227. package/build-module/hooks/custom-fields.js.map +1 -1
  228. package/build-module/hooks/duotone.js +10 -21
  229. package/build-module/hooks/duotone.js.map +1 -1
  230. package/build-module/hooks/layout.js +90 -86
  231. package/build-module/hooks/layout.js.map +1 -1
  232. package/build-module/hooks/position.js +11 -10
  233. package/build-module/hooks/position.js.map +1 -1
  234. package/build-module/hooks/style.js +10 -13
  235. package/build-module/hooks/style.js.map +1 -1
  236. package/build-module/hooks/utils.js +30 -1
  237. package/build-module/hooks/utils.js.map +1 -1
  238. package/build-module/private-apis.js +4 -1
  239. package/build-module/private-apis.js.map +1 -1
  240. package/build-module/store/actions.js +29 -37
  241. package/build-module/store/actions.js.map +1 -1
  242. package/build-module/store/reducer.js +17 -0
  243. package/build-module/store/reducer.js.map +1 -1
  244. package/build-module/store/selectors.js +15 -13
  245. package/build-module/store/selectors.js.map +1 -1
  246. package/build-style/style-rtl.css +16 -15
  247. package/build-style/style.css +16 -15
  248. package/package.json +31 -31
  249. package/src/components/block-heading-level-dropdown/index.js +1 -1
  250. package/src/components/block-list/index.js +4 -18
  251. package/src/components/block-list-appender/index.js +20 -4
  252. package/src/components/block-quick-navigation/index.js +11 -5
  253. package/src/components/block-styles/index.js +0 -10
  254. package/src/components/block-switcher/pattern-transformations-menu.js +20 -14
  255. package/src/components/block-toolbar/style.scss +8 -0
  256. package/src/components/block-tools/back-compat.js +1 -1
  257. package/src/components/block-tools/block-contextual-toolbar.js +11 -134
  258. package/src/components/block-tools/empty-block-inserter.js +56 -0
  259. package/src/components/block-tools/index.js +72 -16
  260. package/src/components/block-tools/selected-block-tools.js +127 -0
  261. package/src/components/block-tools/style.scss +0 -10
  262. package/src/components/block-tools/use-selected-block-tool-props.js +66 -0
  263. package/src/components/editable-text/index.js +1 -8
  264. package/src/components/iframe/index.js +4 -3
  265. package/src/components/inserter/block-patterns-explorer/{explorer.js → index.js} +4 -4
  266. package/src/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -1
  267. package/src/components/inserter/block-patterns-tab/index.js +118 -0
  268. package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
  269. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +175 -0
  270. package/src/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +15 -21
  271. package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +96 -0
  272. package/src/components/inserter/block-patterns-tab/utils.js +76 -0
  273. package/src/components/inserter/media-tab/media-list.js +7 -7
  274. package/src/components/inserter/media-tab/media-preview.js +27 -22
  275. package/src/components/inserter/menu.js +4 -5
  276. package/src/components/link-control/README.md +2 -2
  277. package/src/components/link-control/index.js +15 -6
  278. package/src/components/link-control/style.scss +8 -5
  279. package/src/components/list-view/block-select-button.js +44 -1
  280. package/src/components/list-view/block.js +11 -11
  281. package/src/components/list-view/index.js +2 -0
  282. package/src/components/media-replace-flow/style.scss +2 -2
  283. package/src/components/navigable-toolbar/index.js +71 -25
  284. package/src/components/plain-text/README.md +3 -3
  285. package/src/components/provider/use-block-sync.js +2 -21
  286. package/src/components/rich-text/README.md +9 -8
  287. package/src/components/rich-text/index.js +0 -1
  288. package/src/components/rich-text/index.native.js +3 -1
  289. package/src/components/rich-text/native/format-edit.js +44 -0
  290. package/src/components/rich-text/native/get-format-colors.native.js +54 -0
  291. package/src/components/rich-text/native/index.js +1 -0
  292. package/src/components/rich-text/native/index.native.js +1363 -0
  293. package/src/components/rich-text/native/style.native.scss +28 -0
  294. package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +79 -0
  295. package/src/components/rich-text/native/test/index.native.js +278 -0
  296. package/src/components/rich-text/native/test/performance/rich-text.native.js +44 -0
  297. package/src/components/rich-text/native/toolbar-button-with-options.native.js +61 -0
  298. package/src/components/rich-text/native/use-format-types.js +146 -0
  299. package/src/components/rich-text/use-paste-handler.js +1 -6
  300. package/src/components/url-popover/image-url-input-ui.js +1 -0
  301. package/src/components/writing-flow/use-tab-nav.js +8 -3
  302. package/src/hooks/align.js +8 -8
  303. package/src/hooks/align.native.js +2 -2
  304. package/src/hooks/anchor.js +21 -23
  305. package/src/hooks/background.js +28 -6
  306. package/src/hooks/block-hooks.js +20 -16
  307. package/src/hooks/block-rename-ui.js +6 -4
  308. package/src/hooks/content-lock-ui.js +3 -3
  309. package/src/hooks/custom-class-name.js +7 -6
  310. package/src/hooks/custom-fields.js +5 -5
  311. package/src/hooks/duotone.js +23 -33
  312. package/src/hooks/layout.js +114 -105
  313. package/src/hooks/position.js +8 -21
  314. package/src/hooks/style.js +17 -31
  315. package/src/hooks/test/align.js +4 -4
  316. package/src/hooks/utils.js +33 -1
  317. package/src/private-apis.js +4 -1
  318. package/src/store/actions.js +26 -72
  319. package/src/store/reducer.js +19 -0
  320. package/src/store/selectors.js +13 -19
  321. package/build/components/block-tools/selected-block-popover.js +0 -221
  322. package/build/components/block-tools/selected-block-popover.js.map +0 -1
  323. package/build/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
  324. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
  325. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
  326. package/build/components/inserter/block-patterns-filter.js.map +0 -1
  327. package/build/components/inserter/block-patterns-tab.js +0 -270
  328. package/build/components/inserter/block-patterns-tab.js.map +0 -1
  329. package/build/store/utils.js +0 -22
  330. package/build/store/utils.js.map +0 -1
  331. package/build-module/components/block-tools/selected-block-popover.js +0 -213
  332. package/build-module/components/block-tools/selected-block-popover.js.map +0 -1
  333. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
  334. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
  335. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
  336. package/build-module/components/inserter/block-patterns-filter.js.map +0 -1
  337. package/build-module/components/inserter/block-patterns-tab.js +0 -254
  338. package/build-module/components/inserter/block-patterns-tab.js.map +0 -1
  339. package/build-module/store/utils.js +0 -16
  340. package/build-module/store/utils.js.map +0 -1
  341. package/src/components/block-tools/selected-block-popover.js +0 -265
  342. package/src/components/inserter/block-patterns-tab.js +0 -448
  343. package/src/store/utils.js +0 -12
  344. /package/src/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +0 -0
@@ -0,0 +1,28 @@
1
+
2
+ .richText {
3
+ font-family: $default-regular-font;
4
+ color: $gray-900;
5
+ text-decoration-color: $blue-500;
6
+ background-color: transparent;
7
+ }
8
+
9
+ .richTextDark {
10
+ color: $white;
11
+ text-decoration-color: $blue-30;
12
+ }
13
+
14
+ .richTextPlaceholder {
15
+ color: $gray-20;
16
+ }
17
+
18
+ .richTextPlaceholderDark {
19
+ color: $gray-50;
20
+ }
21
+
22
+ .rich-text-selection {
23
+ color: $black;
24
+ }
25
+
26
+ .rich-text-selection--dark {
27
+ color: $white;
28
+ }
@@ -0,0 +1,79 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`<RichText/> Font Size renders component with style and font size 1`] = `
4
+ "<!-- wp:paragraph {"style":{"color":{"text":"#fcb900"},"typography":{"fontSize":35.56}}} -->
5
+ <p class="has-text-color" style="color:#fcb900;font-size:35.56px">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet ut nibh vitae ornare. Sed auctor nec augue at blandit.</p>
6
+ <!-- /wp:paragraph -->"
7
+ `;
8
+
9
+ exports[`<RichText/> Font Size should update the font size when style prop with font size property is provided 1`] = `
10
+ <View
11
+ style={
12
+ [
13
+ undefined,
14
+ undefined,
15
+ ]
16
+ }
17
+ >
18
+ <TextInput
19
+ accessibilityLabel="Text input. Empty"
20
+ activeFormats={[]}
21
+ blockType={
22
+ {
23
+ "tag": "div",
24
+ }
25
+ }
26
+ disableEditingMenu={false}
27
+ fontFamily="serif"
28
+ fontSize={12}
29
+ isMultiline={false}
30
+ maxImagesWidth={200}
31
+ onBlur={[Function]}
32
+ onChange={[Function]}
33
+ onContentSizeChange={[Function]}
34
+ onFocus={[Function]}
35
+ onKeyDown={[Function]}
36
+ onPaste={[Function]}
37
+ onSelectionChange={[Function]}
38
+ placeholderTextColor="gray"
39
+ triggerKeyCodes={[]}
40
+ value=""
41
+ />
42
+ </View>
43
+ `;
44
+
45
+ exports[`<RichText/> Font Size should update the font size with decimals when style prop with font size property is provided 1`] = `
46
+ <View
47
+ style={
48
+ [
49
+ undefined,
50
+ undefined,
51
+ ]
52
+ }
53
+ >
54
+ <TextInput
55
+ accessibilityLabel="Text input. Empty"
56
+ activeFormats={[]}
57
+ blockType={
58
+ {
59
+ "tag": "div",
60
+ }
61
+ }
62
+ disableEditingMenu={false}
63
+ fontFamily="serif"
64
+ fontSize={13}
65
+ isMultiline={false}
66
+ maxImagesWidth={200}
67
+ onBlur={[Function]}
68
+ onChange={[Function]}
69
+ onContentSizeChange={[Function]}
70
+ onFocus={[Function]}
71
+ onKeyDown={[Function]}
72
+ onPaste={[Function]}
73
+ onSelectionChange={[Function]}
74
+ placeholderTextColor="gray"
75
+ triggerKeyCodes={[]}
76
+ value=""
77
+ />
78
+ </View>
79
+ `;
@@ -0,0 +1,278 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { Dimensions } from 'react-native';
5
+ import { getEditorHtml, render, initializeEditor } from 'test/helpers';
6
+
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+ import { select } from '@wordpress/data';
11
+ import { store as richTextStore } from '@wordpress/rich-text';
12
+ import { coreBlocks } from '@wordpress/block-library';
13
+ import {
14
+ getBlockTypes,
15
+ setDefaultBlockName,
16
+ unregisterBlockType,
17
+ } from '@wordpress/blocks';
18
+
19
+ /**
20
+ * Internal dependencies
21
+ */
22
+ import { store as blockEditorStore } from '../../../../store';
23
+ import RichText from '../index.native';
24
+
25
+ /**
26
+ * Mock `useSelect` with various global application settings, e.g., styles.
27
+ *
28
+ * @param {Object} settings the global application settings you would like to mock.
29
+ */
30
+ const mockGlobalSettings = (
31
+ settings = { fontSize: 'var(--wp--preset--font-size--normal)' }
32
+ ) => {
33
+ const { fontSize } = settings;
34
+ const DEFAULT_GLOBAL_STYLES = {
35
+ __experimentalGlobalStylesBaseStyles: { typography: { fontSize } },
36
+ };
37
+ jest.spyOn( select( blockEditorStore ), 'getSettings' ).mockReturnValue(
38
+ DEFAULT_GLOBAL_STYLES
39
+ );
40
+ jest.spyOn( select( richTextStore ), 'getFormatTypes' ).mockReturnValue(
41
+ []
42
+ );
43
+ };
44
+
45
+ describe( '<RichText/>', () => {
46
+ /**
47
+ * Capture initial `window` dimensions before our integration tests modify them to stage runtime fixtures.
48
+ * Reset to the initial `window` dimensions after each test is executed in case they were modified.
49
+ */
50
+ const window = Dimensions.get( 'window' );
51
+
52
+ const decimalUnitsData = [
53
+ [ '1.125rem', 18 ],
54
+ [ '10.52px', 11 ],
55
+ [ '2.3136em', 37 ],
56
+ [ '1.42vh', 19 ],
57
+ ];
58
+
59
+ beforeAll( () => {
60
+ // Register Paragraph block.
61
+ const paragraph = coreBlocks[ 'core/paragraph' ];
62
+ paragraph.init();
63
+ setDefaultBlockName( paragraph.name );
64
+ } );
65
+
66
+ beforeEach( () => {
67
+ mockGlobalSettings( {} );
68
+ } );
69
+
70
+ afterEach( () => {
71
+ Dimensions.set( { window } );
72
+ } );
73
+
74
+ afterAll( () => {
75
+ // Clean up registered blocks.
76
+ getBlockTypes().forEach( ( block ) => {
77
+ unregisterBlockType( block.name );
78
+ } );
79
+ } );
80
+
81
+ describe( 'Font Size', () => {
82
+ it( 'should display rich text at the DEFAULT font size.', () => {
83
+ // Arrange.
84
+ const expectedFontSize = 16;
85
+ // Act.
86
+ const { getByLabelText } = render(
87
+ <RichText accessibilityLabel={ 'editor' } />
88
+ );
89
+ // Assert.
90
+ const actualFontSize = getByLabelText( 'editor' ).props.fontSize;
91
+ expect( actualFontSize ).toBe( expectedFontSize );
92
+ } );
93
+
94
+ it( 'should display rich text at the PROVIDED font size computed from the LOCAL `fontSize` CSS.', () => {
95
+ // Arrange.
96
+ const expectedFontSize = 32;
97
+ // Act.
98
+ const { getByLabelText } = render(
99
+ <RichText
100
+ accessibilityLabel={ 'editor' }
101
+ fontSize={ 'min(2em, 3em)' }
102
+ />
103
+ );
104
+ // Assert.
105
+ const actualFontSize = getByLabelText( 'editor' ).props.fontSize;
106
+ expect( actualFontSize ).toBe( expectedFontSize );
107
+ } );
108
+
109
+ it( 'should display rich text at the PROVIDED font size computed from the LOCAL `style.fontSize` CSS.', () => {
110
+ // Arrange.
111
+ const expectedFontSize = 32;
112
+ // Act.
113
+ const { getByLabelText } = render(
114
+ <RichText
115
+ accessibilityLabel={ 'editor' }
116
+ style={ { fontSize: 'min(2em, 3em)' } }
117
+ />
118
+ );
119
+ // Assert.
120
+ const actualFontSize = getByLabelText( 'editor' ).props.fontSize;
121
+ expect( actualFontSize ).toBe( expectedFontSize );
122
+ } );
123
+
124
+ it( `should display rich text with the default editor font size value and not use the
125
+ \`default font size value from the global styles for a tag different than (p)`, () => {
126
+ // Arrange.
127
+ const defaultFontSize = 16;
128
+ mockGlobalSettings( { fontSize: 'min(2em, 3em)' } );
129
+ // Act.
130
+ const { getByLabelText } = render(
131
+ <RichText accessibilityLabel={ 'editor' } tagName="div" />
132
+ );
133
+ // Assert.
134
+ const actualFontSize = getByLabelText( 'editor' ).props.fontSize;
135
+ expect( actualFontSize ).toBe( defaultFontSize );
136
+ } );
137
+
138
+ it( `should display rich text at the PROVIDED font size computed from the selected GLOBAL
139
+ \`__experimentalGlobalStylesBaseStyles.typography.fontSize\` CSS.`, () => {
140
+ // Arrange.
141
+ const expectedFontSize = 32;
142
+ mockGlobalSettings( { fontSize: 'min(2em, 3em)' } );
143
+ // Act.
144
+ const { getByLabelText } = render(
145
+ <RichText accessibilityLabel={ 'editor' } tagName="p" />
146
+ );
147
+ // Assert.
148
+ const actualFontSize = getByLabelText( 'editor' ).props.fontSize;
149
+ expect( actualFontSize ).toBe( expectedFontSize );
150
+ } );
151
+
152
+ test.each( decimalUnitsData )(
153
+ `should display rich text at the PROVIDED font size computed from the selected GLOBAL
154
+ \`__experimentalGlobalStylesBaseStyles.typography.fontSize\` CSS with decimal value: %s`,
155
+ ( unit, expected ) => {
156
+ // Arrange.
157
+ mockGlobalSettings( { fontSize: unit } );
158
+ // Act.
159
+ const { getByLabelText } = render(
160
+ <RichText accessibilityLabel={ 'editor' } tagName="p" />
161
+ );
162
+ // Assert.
163
+ const actualFontSize =
164
+ getByLabelText( 'editor' ).props.fontSize;
165
+ expect( actualFontSize ).toBe( expected );
166
+ }
167
+ );
168
+
169
+ it( `should display rich text at the font size computed from the LOCAL \`style.fontSize\` CSS with HIGHEST PRIORITY
170
+ when CSS is provided ambiguously from ALL possible sources.`, () => {
171
+ // Arrange.
172
+ const expectedFontSize = 1;
173
+ mockGlobalSettings( { fontSize: '0' } );
174
+ // Act.
175
+ const { getByLabelText } = render(
176
+ <RichText
177
+ accessibilityLabel={ 'editor' }
178
+ style={ { fontSize: '1' } }
179
+ fontSize={ '2' }
180
+ tagName="p"
181
+ />
182
+ );
183
+ // Assert.
184
+ const actualFontSize = getByLabelText( 'editor' ).props.fontSize;
185
+ expect( actualFontSize ).toBe( expectedFontSize );
186
+ } );
187
+
188
+ it( `should display rich text at the font size computed from the LOCAL \`style.fontSize\` CSS with
189
+ NEXT PRIORITY when CSS is provided ambiguously from MULTIPLE possible sources EXCLUDING \`fontSize\`.`, () => {
190
+ // Arrange.
191
+ const expectedFontSize = 1;
192
+ mockGlobalSettings( { fontSize: '0' } );
193
+ // Act.
194
+ const { getByLabelText } = render(
195
+ <RichText
196
+ accessibilityLabel={ 'editor' }
197
+ style={ { fontSize: '1' } }
198
+ tagName="p"
199
+ />
200
+ );
201
+ // Assert.
202
+ const actualFontSize = getByLabelText( 'editor' ).props.fontSize;
203
+ expect( actualFontSize ).toBe( expectedFontSize );
204
+ } );
205
+
206
+ it( 'should display rich text at the font size computed from CSS relative to the VIEWPORT WIDTH.', () => {
207
+ // Arrange.
208
+ const expectedFontSize = 3;
209
+ Dimensions.set( { window: { ...window, width: 300 } } );
210
+ // Act.
211
+ const { getByLabelText } = render(
212
+ <RichText accessibilityLabel={ 'editor' } fontSize={ '1vw' } />
213
+ );
214
+ // Assert.
215
+ const actualFontSize = getByLabelText( 'editor' ).props.fontSize;
216
+ expect( actualFontSize ).toBe( expectedFontSize );
217
+ } );
218
+
219
+ it( 'should display rich text at the font size computed from CSS relative to the VIEWPORT HEIGHT.', () => {
220
+ // Arrange.
221
+ const expectedFontSize = 3;
222
+ Dimensions.set( { window: { ...window, height: 300 } } );
223
+ // Act.
224
+ const { getByLabelText } = render(
225
+ <RichText accessibilityLabel={ 'editor' } fontSize={ '1vh' } />
226
+ );
227
+ // Assert.
228
+ const actualFontSize = getByLabelText( 'editor' ).props.fontSize;
229
+ expect( actualFontSize ).toBe( expectedFontSize );
230
+ } );
231
+
232
+ it( 'should update the font size when style prop with font size property is provided', () => {
233
+ // Arrange.
234
+ const fontSize = '10';
235
+ const style = { fontSize: '12' };
236
+ // Act.
237
+ const screen = render( <RichText fontSize={ fontSize } /> );
238
+ screen.update( <RichText fontSize={ fontSize } style={ style } /> );
239
+ // Assert.
240
+ expect( screen.toJSON() ).toMatchSnapshot();
241
+ } );
242
+
243
+ it( 'renders component with style and font size', async () => {
244
+ // Arrange.
245
+ const initialHtml = `<!-- wp:paragraph {"style":{"color":{"text":"#fcb900"},"typography":{"fontSize":35.56}}} -->
246
+ <p class="has-text-color" style="color:#fcb900;font-size:35.56px">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet ut nibh vitae ornare. Sed auctor nec augue at blandit.</p>
247
+ <!-- /wp:paragraph -->`;
248
+ // Act.
249
+ await initializeEditor( { initialHtml } );
250
+ // Assert.
251
+ expect( getEditorHtml() ).toMatchSnapshot();
252
+ } );
253
+
254
+ it( 'should update the font size with decimals when style prop with font size property is provided', () => {
255
+ // Arrange.
256
+ const fontSize = '10';
257
+ const style = { fontSize: '12.56px' };
258
+ // Act.
259
+ const screen = render( <RichText fontSize={ fontSize } /> );
260
+ screen.update( <RichText fontSize={ fontSize } style={ style } /> );
261
+ // Assert.
262
+ expect( screen.toJSON() ).toMatchSnapshot();
263
+ } );
264
+
265
+ it( 'should set the default minimum line height value if the provided value from the styles is lower', () => {
266
+ // Arrange.
267
+ const expectedLineHeight = 1;
268
+ const style = { lineHeight: 0.2 };
269
+ // Act.
270
+ const { getByLabelText } = render(
271
+ <RichText accessibilityLabel={ 'editor' } style={ style } />
272
+ );
273
+ // Assert.
274
+ const actualFontSize = getByLabelText( 'editor' ).props.lineHeight;
275
+ expect( actualFontSize ).toBe( expectedLineHeight );
276
+ } );
277
+ } );
278
+ } );
@@ -0,0 +1,44 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import {
5
+ typeInRichText,
6
+ fireEvent,
7
+ measurePerformance,
8
+ screen,
9
+ } from 'test/helpers';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import RichText from '../../index.native';
15
+
16
+ describe( 'RichText Performance', () => {
17
+ const onCreateUndoLevel = jest.fn();
18
+ const onChange = jest.fn();
19
+ const onSelectionChange = jest.fn();
20
+
21
+ it( 'performance is stable when typing using Rich Text', async () => {
22
+ const scenario = async () => {
23
+ const richTextInput = screen.getByLabelText( 'Text input. Empty' );
24
+
25
+ fireEvent( richTextInput, 'focus' );
26
+
27
+ typeInRichText(
28
+ richTextInput,
29
+ '<strong>Bold</strong> <em>italic</em> <s>strikethrough</s> text'
30
+ );
31
+ };
32
+
33
+ await measurePerformance(
34
+ <RichText
35
+ onChange={ onChange }
36
+ __unstableOnCreateUndoLevel={ onCreateUndoLevel }
37
+ onSelectionChange={ onSelectionChange }
38
+ />,
39
+ {
40
+ scenario,
41
+ }
42
+ );
43
+ } );
44
+ } );
@@ -0,0 +1,61 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { Picker, ToolbarGroup, ToolbarButton } from '@wordpress/components';
5
+ import { useRef } from '@wordpress/element';
6
+ import { Icon } from '@wordpress/icons';
7
+
8
+ /**
9
+ * Toolbar button component that, upon a long press, opens a Picker
10
+ * to allow selecting from among multiple options.
11
+ *
12
+ * @param {Object} props Component props.
13
+ * @param {Object} props.options Options to pick from.
14
+ */
15
+ function ToolbarButtonWithOptions( { options } ) {
16
+ const picker = useRef();
17
+
18
+ function presentPicker() {
19
+ if ( picker.current ) {
20
+ picker.current.presentPicker();
21
+ }
22
+ }
23
+
24
+ function onValueSelected( selectedValue ) {
25
+ const selectedOption = options.find(
26
+ ( op ) => op.value === selectedValue
27
+ );
28
+ if ( selectedOption ) {
29
+ selectedOption.onClick();
30
+ }
31
+ }
32
+
33
+ if ( ! options || options.length === 0 ) {
34
+ return null;
35
+ }
36
+ const firstOption = options[ 0 ];
37
+ const enablePicker = options.length > 1;
38
+
39
+ return (
40
+ <>
41
+ <ToolbarGroup>
42
+ <ToolbarButton
43
+ title={ firstOption.title }
44
+ icon={ <Icon icon={ firstOption.icon } /> }
45
+ onClick={ firstOption.onClick }
46
+ onLongPress={ enablePicker ? presentPicker : undefined }
47
+ />
48
+ </ToolbarGroup>
49
+ { enablePicker && (
50
+ <Picker
51
+ ref={ picker }
52
+ options={ options }
53
+ onChange={ onValueSelected }
54
+ hideCancelButton
55
+ />
56
+ ) }
57
+ </>
58
+ );
59
+ }
60
+
61
+ export default ToolbarButtonWithOptions;
@@ -0,0 +1,146 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useMemo } from '@wordpress/element';
5
+ import { useSelect, useDispatch } from '@wordpress/data';
6
+ import { store as richTextStore } from '@wordpress/rich-text';
7
+
8
+ function formatTypesSelector( select ) {
9
+ return select( richTextStore ).getFormatTypes();
10
+ }
11
+
12
+ /**
13
+ * Set of all interactive content tags.
14
+ *
15
+ * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content
16
+ */
17
+ const interactiveContentTags = new Set( [
18
+ 'a',
19
+ 'audio',
20
+ 'button',
21
+ 'details',
22
+ 'embed',
23
+ 'iframe',
24
+ 'input',
25
+ 'label',
26
+ 'select',
27
+ 'textarea',
28
+ 'video',
29
+ ] );
30
+
31
+ /**
32
+ * This hook provides RichText with the `formatTypes` and its derived props from
33
+ * experimental format type settings.
34
+ *
35
+ * @param {Object} $0 Options
36
+ * @param {string} $0.clientId Block client ID.
37
+ * @param {string} $0.identifier Block attribute.
38
+ * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not.
39
+ * @param {Array} $0.allowedFormats Allowed formats
40
+ */
41
+ export function useFormatTypes( {
42
+ clientId,
43
+ identifier,
44
+ withoutInteractiveFormatting,
45
+ allowedFormats,
46
+ } ) {
47
+ const allFormatTypes = useSelect( formatTypesSelector, [] );
48
+ const formatTypes = useMemo( () => {
49
+ return allFormatTypes.filter( ( { name, tagName } ) => {
50
+ if ( allowedFormats && ! allowedFormats.includes( name ) ) {
51
+ return false;
52
+ }
53
+
54
+ if (
55
+ withoutInteractiveFormatting &&
56
+ interactiveContentTags.has( tagName )
57
+ ) {
58
+ return false;
59
+ }
60
+
61
+ return true;
62
+ } );
63
+ }, [ allFormatTypes, allowedFormats, interactiveContentTags ] );
64
+ const keyedSelected = useSelect(
65
+ ( select ) =>
66
+ formatTypes.reduce( ( accumulator, type ) => {
67
+ if ( type.__experimentalGetPropsForEditableTreePreparation ) {
68
+ accumulator[ type.name ] =
69
+ type.__experimentalGetPropsForEditableTreePreparation(
70
+ select,
71
+ {
72
+ richTextIdentifier: identifier,
73
+ blockClientId: clientId,
74
+ }
75
+ );
76
+ }
77
+
78
+ return accumulator;
79
+ }, {} ),
80
+ [ formatTypes, clientId, identifier ]
81
+ );
82
+ const dispatch = useDispatch();
83
+ const prepareHandlers = [];
84
+ const valueHandlers = [];
85
+ const changeHandlers = [];
86
+ const dependencies = [];
87
+
88
+ formatTypes.forEach( ( type ) => {
89
+ if ( type.__experimentalCreatePrepareEditableTree ) {
90
+ const selected = keyedSelected[ type.name ];
91
+ const handler = type.__experimentalCreatePrepareEditableTree(
92
+ selected,
93
+ {
94
+ richTextIdentifier: identifier,
95
+ blockClientId: clientId,
96
+ }
97
+ );
98
+
99
+ if ( type.__experimentalCreateOnChangeEditableValue ) {
100
+ valueHandlers.push( handler );
101
+ } else {
102
+ prepareHandlers.push( handler );
103
+ }
104
+
105
+ for ( const key in selected ) {
106
+ dependencies.push( selected[ key ] );
107
+ }
108
+ }
109
+
110
+ if ( type.__experimentalCreateOnChangeEditableValue ) {
111
+ let dispatchers = {};
112
+
113
+ if ( type.__experimentalGetPropsForEditableTreeChangeHandler ) {
114
+ dispatchers =
115
+ type.__experimentalGetPropsForEditableTreeChangeHandler(
116
+ dispatch,
117
+ {
118
+ richTextIdentifier: identifier,
119
+ blockClientId: clientId,
120
+ }
121
+ );
122
+ }
123
+
124
+ changeHandlers.push(
125
+ type.__experimentalCreateOnChangeEditableValue(
126
+ {
127
+ ...( keyedSelected[ type.name ] || {} ),
128
+ ...dispatchers,
129
+ },
130
+ {
131
+ richTextIdentifier: identifier,
132
+ blockClientId: clientId,
133
+ }
134
+ )
135
+ );
136
+ }
137
+ } );
138
+
139
+ return {
140
+ formatTypes,
141
+ prepareHandlers,
142
+ valueHandlers,
143
+ changeHandlers,
144
+ dependencies,
145
+ };
146
+ }
@@ -35,7 +35,6 @@ export function usePasteHandler( props ) {
35
35
  onReplace,
36
36
  onSplit,
37
37
  __unstableEmbedURLOnPaste,
38
- preserveWhiteSpace,
39
38
  pastePlainText,
40
39
  } = propsRef.current;
41
40
 
@@ -63,10 +62,7 @@ export function usePasteHandler( props ) {
63
62
  // without filtering the data. The filters are only meant for externally
64
63
  // pasted content and remove inline styles.
65
64
  if ( isInternal ) {
66
- const pastedValue = create( {
67
- html,
68
- preserveWhiteSpace,
69
- } );
65
+ const pastedValue = create( { html } );
70
66
  addActiveFormats( pastedValue, value.activeFormats );
71
67
  onChange( insert( value, pastedValue ) );
72
68
  return;
@@ -136,7 +132,6 @@ export function usePasteHandler( props ) {
136
132
  plainText,
137
133
  mode,
138
134
  tagName,
139
- preserveWhiteSpace,
140
135
  } );
141
136
 
142
137
  if ( typeof content === 'string' ) {
@@ -249,6 +249,7 @@ const ImageURLInputUI = ( {
249
249
  aria-expanded={ isOpen }
250
250
  onClick={ openLinkUI }
251
251
  ref={ setPopoverAnchor }
252
+ isActive={ !! url }
252
253
  />
253
254
  { isOpen && (
254
255
  <URLPopover
@@ -17,15 +17,20 @@ export default function useTabNav() {
17
17
  const container = useRef();
18
18
  const focusCaptureBeforeRef = useRef();
19
19
  const focusCaptureAfterRef = useRef();
20
- const lastFocus = useRef();
20
+
21
21
  const { hasMultiSelection, getSelectedBlockClientId, getBlockCount } =
22
22
  useSelect( blockEditorStore );
23
- const { setNavigationMode } = useDispatch( blockEditorStore );
23
+ const { setNavigationMode, setLastFocus } = useDispatch( blockEditorStore );
24
24
  const isNavigationMode = useSelect(
25
25
  ( select ) => select( blockEditorStore ).isNavigationMode(),
26
26
  []
27
27
  );
28
28
 
29
+ const lastFocus = useSelect(
30
+ ( select ) => select( blockEditorStore ).getLastFocus(),
31
+ []
32
+ );
33
+
29
34
  // Don't allow tabbing to this element in Navigation mode.
30
35
  const focusCaptureTabIndex = ! isNavigationMode ? '0' : undefined;
31
36
 
@@ -158,7 +163,7 @@ export default function useTabNav() {
158
163
  }
159
164
 
160
165
  function onFocusOut( event ) {
161
- lastFocus.current = event.target;
166
+ setLastFocus( { ...lastFocus, current: event.target } );
162
167
 
163
168
  const { ownerDocument } = node;
164
169