@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
@@ -19,6 +19,7 @@ import { SPACE, ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';
19
19
  import { useSelect, useDispatch } from '@wordpress/data';
20
20
  import { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';
21
21
  import { __, sprintf } from '@wordpress/i18n';
22
+ import isShallowEqual from '@wordpress/is-shallow-equal';
22
23
 
23
24
  /**
24
25
  * Internal dependencies
@@ -30,6 +31,7 @@ import ListViewExpander from './expander';
30
31
  import { useBlockLock } from '../block-lock';
31
32
  import { store as blockEditorStore } from '../../store';
32
33
  import useListViewImages from './use-list-view-images';
34
+ import { useListViewContext } from './context';
33
35
 
34
36
  function ListViewBlockSelectButton(
35
37
  {
@@ -64,10 +66,12 @@ function ListViewBlockSelectButton(
64
66
  getBlocksByClientId,
65
67
  canRemoveBlocks,
66
68
  } = useSelect( blockEditorStore );
67
- const { duplicateBlocks, removeBlocks } = useDispatch( blockEditorStore );
69
+ const { duplicateBlocks, multiSelect, removeBlocks } =
70
+ useDispatch( blockEditorStore );
68
71
  const isMatch = useShortcutEventMatch();
69
72
  const isSticky = blockInformation?.positionType === 'sticky';
70
73
  const images = useListViewImages( { clientId, isExpanded } );
74
+ const { rootClientId } = useListViewContext();
71
75
 
72
76
  const positionLabel = blockInformation?.positionLabel
73
77
  ? sprintf(
@@ -183,6 +187,45 @@ function ListViewBlockSelectButton(
183
187
  updateFocusAndSelection( updatedBlocks[ 0 ], false );
184
188
  }
185
189
  }
190
+ } else if ( isMatch( 'core/block-editor/select-all', event ) ) {
191
+ if ( event.defaultPrevented ) {
192
+ return;
193
+ }
194
+ event.preventDefault();
195
+
196
+ const { firstBlockRootClientId, selectedBlockClientIds } =
197
+ getBlocksToUpdate();
198
+ const blockClientIds = getBlockOrder( firstBlockRootClientId );
199
+ if ( ! blockClientIds.length ) {
200
+ return;
201
+ }
202
+
203
+ // If we have selected all sibling nested blocks, try selecting up a level.
204
+ // This is a similar implementation to that used by `useSelectAll`.
205
+ // `isShallowEqual` is used for the list view instead of a length check,
206
+ // as the array of siblings of the currently focused block may be a different
207
+ // set of blocks from the current block selection if the user is focused
208
+ // on a different part of the list view from the block selection.
209
+ if ( isShallowEqual( selectedBlockClientIds, blockClientIds ) ) {
210
+ // Only select up a level if the first block is not the root block.
211
+ // This ensures that the block selection can't break out of the root block
212
+ // used by the list view, if the list view is only showing a partial hierarchy.
213
+ if (
214
+ firstBlockRootClientId &&
215
+ firstBlockRootClientId !== rootClientId
216
+ ) {
217
+ updateFocusAndSelection( firstBlockRootClientId, true );
218
+ return;
219
+ }
220
+ }
221
+
222
+ // Select all while passing `null` to skip focusing to the editor canvas,
223
+ // and retain focus within the list view.
224
+ multiSelect(
225
+ blockClientIds[ 0 ],
226
+ blockClientIds[ blockClientIds.length - 1 ],
227
+ null
228
+ );
186
229
  }
187
230
  }
188
231
 
@@ -69,17 +69,17 @@ function ListViewBlock( {
69
69
  const blockTitle =
70
70
  blockInformation?.name || blockInformation?.title || __( 'Untitled' );
71
71
 
72
- const block = useSelect(
73
- ( select ) => select( blockEditorStore ).getBlock( clientId ),
74
- [ clientId ]
75
- );
76
- const blockName = useSelect(
77
- ( select ) => select( blockEditorStore ).getBlockName( clientId ),
78
- [ clientId ]
79
- );
80
- const blockEditingMode = useSelect(
81
- ( select ) =>
82
- select( blockEditorStore ).getBlockEditingMode( clientId ),
72
+ const { block, blockName, blockEditingMode } = useSelect(
73
+ ( select ) => {
74
+ const { getBlock, getBlockName, getBlockEditingMode } =
75
+ select( blockEditorStore );
76
+
77
+ return {
78
+ block: getBlock( clientId ),
79
+ blockName: getBlockName( clientId ),
80
+ blockEditingMode: getBlockEditingMode( clientId ),
81
+ };
82
+ },
83
83
  [ clientId ]
84
84
  );
85
85
 
@@ -222,6 +222,7 @@ function ListViewComponent(
222
222
  insertedBlock,
223
223
  setInsertedBlock,
224
224
  treeGridElementRef: elementRef,
225
+ rootClientId,
225
226
  } ),
226
227
  [
227
228
  draggedClientIds,
@@ -233,6 +234,7 @@ function ListViewComponent(
233
234
  AdditionalBlockContent,
234
235
  insertedBlock,
235
236
  setInsertedBlock,
237
+ rootClientId,
236
238
  ]
237
239
  );
238
240
 
@@ -17,6 +17,7 @@
17
17
  &.has-siblings {
18
18
  border-top: $border-width solid $gray-900;
19
19
  margin-top: $grid-unit-10;
20
+ padding-bottom: $grid-unit-10;
20
21
  }
21
22
 
22
23
  .block-editor-media-replace-flow__image-url-label {
@@ -55,8 +56,7 @@
55
56
  }
56
57
 
57
58
  .block-editor-link-control__search-actions {
58
- top: 0; // cancel default top positioning
59
- right: 4px;
59
+ padding: $grid-unit-10 0 0;
60
60
  }
61
61
  }
62
62
  }
@@ -9,9 +9,16 @@ import {
9
9
  useEffect,
10
10
  useCallback,
11
11
  } from '@wordpress/element';
12
+ import { useSelect } from '@wordpress/data';
12
13
  import deprecated from '@wordpress/deprecated';
13
14
  import { focus } from '@wordpress/dom';
14
15
  import { useShortcut } from '@wordpress/keyboard-shortcuts';
16
+ import { ESCAPE } from '@wordpress/keycodes';
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+ import { store as blockEditorStore } from '../../store';
15
22
 
16
23
  function hasOnlyToolbarItem( elements ) {
17
24
  const dataProp = 'toolbarItem';
@@ -28,6 +35,7 @@ function hasFocusWithin( container ) {
28
35
 
29
36
  function focusFirstTabbableIn( container ) {
30
37
  const [ firstTabbable ] = focus.tabbable.find( container );
38
+
31
39
  if ( firstTabbable ) {
32
40
  firstTabbable.focus( {
33
41
  // When focusing newly mounted toolbars,
@@ -38,7 +46,7 @@ function focusFirstTabbableIn( container ) {
38
46
  }
39
47
  }
40
48
 
41
- function useIsAccessibleToolbar( ref ) {
49
+ function useIsAccessibleToolbar( toolbarRef ) {
42
50
  /*
43
51
  * By default, we'll assume the starting accessible state of the Toolbar
44
52
  * is true, as it seems to be the most common case.
@@ -62,7 +70,7 @@ function useIsAccessibleToolbar( ref ) {
62
70
  );
63
71
 
64
72
  const determineIsAccessibleToolbar = useCallback( () => {
65
- const tabbables = focus.tabbable.find( ref.current );
73
+ const tabbables = focus.tabbable.find( toolbarRef.current );
66
74
  const onlyToolbarItem = hasOnlyToolbarItem( tabbables );
67
75
  if ( ! onlyToolbarItem ) {
68
76
  deprecated( 'Using custom components as toolbar controls', {
@@ -73,7 +81,7 @@ function useIsAccessibleToolbar( ref ) {
73
81
  } );
74
82
  }
75
83
  setIsAccessibleToolbar( onlyToolbarItem );
76
- }, [] );
84
+ }, [ toolbarRef ] );
77
85
 
78
86
  useLayoutEffect( () => {
79
87
  // Toolbar buttons may be rendered asynchronously, so we use
@@ -81,28 +89,32 @@ function useIsAccessibleToolbar( ref ) {
81
89
  const observer = new window.MutationObserver(
82
90
  determineIsAccessibleToolbar
83
91
  );
84
- observer.observe( ref.current, { childList: true, subtree: true } );
92
+ observer.observe( toolbarRef.current, {
93
+ childList: true,
94
+ subtree: true,
95
+ } );
85
96
  return () => observer.disconnect();
86
- }, [ isAccessibleToolbar ] );
97
+ }, [ determineIsAccessibleToolbar, isAccessibleToolbar, toolbarRef ] );
87
98
 
88
99
  return isAccessibleToolbar;
89
100
  }
90
101
 
91
- function useToolbarFocus(
92
- ref,
102
+ function useToolbarFocus( {
103
+ toolbarRef,
93
104
  focusOnMount,
94
105
  isAccessibleToolbar,
95
106
  defaultIndex,
96
107
  onIndexChange,
97
- shouldUseKeyboardFocusShortcut
98
- ) {
108
+ shouldUseKeyboardFocusShortcut,
109
+ focusEditorOnEscape,
110
+ } ) {
99
111
  // Make sure we don't use modified versions of this prop.
100
112
  const [ initialFocusOnMount ] = useState( focusOnMount );
101
113
  const [ initialIndex ] = useState( defaultIndex );
102
114
 
103
115
  const focusToolbar = useCallback( () => {
104
- focusFirstTabbableIn( ref.current );
105
- }, [] );
116
+ focusFirstTabbableIn( toolbarRef.current );
117
+ }, [ toolbarRef ] );
106
118
 
107
119
  const focusToolbarViaShortcut = () => {
108
120
  if ( shouldUseKeyboardFocusShortcut ) {
@@ -121,7 +133,7 @@ function useToolbarFocus(
121
133
 
122
134
  useEffect( () => {
123
135
  // Store ref so we have access on useEffect cleanup: https://legacy.reactjs.org/blog/2020/08/10/react-v17-rc.html#effect-cleanup-timing
124
- const navigableToolbarRef = ref.current;
136
+ const navigableToolbarRef = toolbarRef.current;
125
137
  // If initialIndex is passed, we focus on that toolbar item when the
126
138
  // toolbar gets mounted and initial focus is not forced.
127
139
  // We have to wait for the next browser paint because block controls aren't
@@ -150,32 +162,68 @@ function useToolbarFocus(
150
162
  const index = items.findIndex( ( item ) => item.tabIndex === 0 );
151
163
  onIndexChange( index );
152
164
  };
153
- }, [ initialIndex, initialFocusOnMount ] );
165
+ }, [ initialIndex, initialFocusOnMount, toolbarRef ] );
166
+
167
+ const { lastFocus } = useSelect( ( select ) => {
168
+ const { getLastFocus } = select( blockEditorStore );
169
+ return {
170
+ lastFocus: getLastFocus(),
171
+ };
172
+ }, [] );
173
+ /**
174
+ * Handles returning focus to the block editor canvas when pressing escape.
175
+ */
176
+ useEffect( () => {
177
+ const navigableToolbarRef = toolbarRef.current;
178
+
179
+ if ( focusEditorOnEscape ) {
180
+ const handleKeyDown = ( event ) => {
181
+ if ( event.keyCode === ESCAPE && lastFocus?.current ) {
182
+ // Focus the last focused element when pressing escape.
183
+ event.preventDefault();
184
+ lastFocus.current.focus();
185
+ }
186
+ };
187
+ navigableToolbarRef.addEventListener( 'keydown', handleKeyDown );
188
+ return () => {
189
+ navigableToolbarRef.removeEventListener(
190
+ 'keydown',
191
+ handleKeyDown
192
+ );
193
+ };
194
+ }
195
+ }, [ focusEditorOnEscape, lastFocus, toolbarRef ] );
154
196
  }
155
197
 
156
- function NavigableToolbar( {
198
+ export default function NavigableToolbar( {
157
199
  children,
158
200
  focusOnMount,
201
+ focusEditorOnEscape = false,
159
202
  shouldUseKeyboardFocusShortcut = true,
160
203
  __experimentalInitialIndex: initialIndex,
161
204
  __experimentalOnIndexChange: onIndexChange,
162
205
  ...props
163
206
  } ) {
164
- const ref = useRef();
165
- const isAccessibleToolbar = useIsAccessibleToolbar( ref );
207
+ const toolbarRef = useRef();
208
+ const isAccessibleToolbar = useIsAccessibleToolbar( toolbarRef );
166
209
 
167
- useToolbarFocus(
168
- ref,
210
+ useToolbarFocus( {
211
+ toolbarRef,
169
212
  focusOnMount,
170
213
  isAccessibleToolbar,
171
- initialIndex,
214
+ defaultIndex: initialIndex,
172
215
  onIndexChange,
173
- shouldUseKeyboardFocusShortcut
174
- );
216
+ shouldUseKeyboardFocusShortcut,
217
+ focusEditorOnEscape,
218
+ } );
175
219
 
176
220
  if ( isAccessibleToolbar ) {
177
221
  return (
178
- <Toolbar label={ props[ 'aria-label' ] } ref={ ref } { ...props }>
222
+ <Toolbar
223
+ label={ props[ 'aria-label' ] }
224
+ ref={ toolbarRef }
225
+ { ...props }
226
+ >
179
227
  { children }
180
228
  </Toolbar>
181
229
  );
@@ -185,12 +233,10 @@ function NavigableToolbar( {
185
233
  <NavigableMenu
186
234
  orientation="horizontal"
187
235
  role="toolbar"
188
- ref={ ref }
236
+ ref={ toolbarRef }
189
237
  { ...props }
190
238
  >
191
239
  { children }
192
240
  </NavigableMenu>
193
241
  );
194
242
  }
195
-
196
- export default NavigableToolbar;
@@ -34,7 +34,7 @@ wp.blocks.registerBlockType( /* ... */, {
34
34
  },
35
35
 
36
36
  edit: function( props ) {
37
- return React.createElement( wp.editor.PlainText, {
37
+ return React.createElement( wp.blockEditor.PlainText, {
38
38
  className: props.className,
39
39
  value: props.attributes.content,
40
40
  onChange: function( content ) {
@@ -48,8 +48,8 @@ wp.blocks.registerBlockType( /* ... */, {
48
48
  {% ESNext %}
49
49
 
50
50
  ```js
51
- const { registerBlockType } = wp.blocks;
52
- const { PlainText } = wp.editor;
51
+ import { registerBlockType } from '@wordpress/blocks';
52
+ import { PlainText } from '@wordpress/block-editor';
53
53
 
54
54
  registerBlockType( /* ... */, {
55
55
  // ...
@@ -76,18 +76,11 @@ export default function useBlockSync( {
76
76
  resetBlocks,
77
77
  resetSelection,
78
78
  replaceInnerBlocks,
79
- selectBlock,
80
79
  setHasControlledInnerBlocks,
81
80
  __unstableMarkNextChangeAsNotPersistent,
82
81
  } = registry.dispatch( blockEditorStore );
83
- const {
84
- hasSelectedBlock,
85
- getBlockName,
86
- getBlocks,
87
- getSelectionStart,
88
- getSelectionEnd,
89
- getBlock,
90
- } = registry.select( blockEditorStore );
82
+ const { getBlockName, getBlocks, getSelectionStart, getSelectionEnd } =
83
+ registry.select( blockEditorStore );
91
84
  const isControlled = useSelect(
92
85
  ( select ) => {
93
86
  return (
@@ -180,9 +173,6 @@ export default function useBlockSync( {
180
173
  // bound sync, unset the outbound value to avoid considering it in
181
174
  // subsequent renders.
182
175
  pendingChanges.current.outgoing = [];
183
- const hadSelection = hasSelectedBlock();
184
- const selectionAnchor = getSelectionStart();
185
- const selectionFocus = getSelectionEnd();
186
176
  setControlledBlocks();
187
177
 
188
178
  if ( controlledSelection ) {
@@ -191,15 +181,6 @@ export default function useBlockSync( {
191
181
  controlledSelection.selectionEnd,
192
182
  controlledSelection.initialPosition
193
183
  );
194
- } else {
195
- const selectionStillExists = getBlock(
196
- selectionAnchor.clientId
197
- );
198
- if ( hadSelection && ! selectionStillExists ) {
199
- selectBlock( clientId );
200
- } else {
201
- resetSelection( selectionAnchor, selectionFocus );
202
- }
203
184
  }
204
185
  }
205
186
  }, [ controlledBlocks, clientId ] );
@@ -71,7 +71,8 @@ _Optional._ A list of autocompleters to use instead of the default.
71
71
 
72
72
  ### `preserveWhiteSpace: Boolean`
73
73
 
74
- _Optional._ Whether or not to preserve white space characters in the `value`. Normally tab, newline and space characters are collapsed to a single space. If turned on, soft line breaks will be saved as newline characters, not as line break elements.
74
+ _Optional._ Whether or not to preserve white space characters in the `value`. Normally tab, newline and space characters are collapsed to a single space or
75
+ trimmed.
75
76
 
76
77
  ## RichText.Content
77
78
 
@@ -94,7 +95,7 @@ wp.blocks.registerBlockType( /* ... */, {
94
95
  },
95
96
 
96
97
  edit: function( props ) {
97
- return React.createElement( wp.editor.RichText, {
98
+ return React.createElement( wp.blockEditor.RichText, {
98
99
  tagName: 'h2',
99
100
  className: props.className,
100
101
  value: props.attributes.content,
@@ -105,7 +106,7 @@ wp.blocks.registerBlockType( /* ... */, {
105
106
  },
106
107
 
107
108
  save: function( props ) {
108
- return React.createElement( wp.editor.RichText.Content, {
109
+ return React.createElement( wp.blockEditor.RichText.Content, {
109
110
  tagName: 'h2', value: props.attributes.content
110
111
  } );
111
112
  }
@@ -115,8 +116,8 @@ wp.blocks.registerBlockType( /* ... */, {
115
116
  {% ESNext %}
116
117
 
117
118
  ```js
118
- const { registerBlockType } = wp.blocks;
119
- const { RichText } = wp.editor;
119
+ import { registerBlockType } from '@wordpress/blocks';
120
+ import { RichText } from '@wordpress/block-editor';
120
121
 
121
122
  registerBlockType( /* ... */, {
122
123
  // ...
@@ -161,7 +162,7 @@ wp.richText.registerFormatType( /* ... */, {
161
162
  /* ... */
162
163
  edit: function( props ) {
163
164
  return React.createElement(
164
- wp.editor.RichTextToolbarButton, {
165
+ wp.blockEditor.RichTextToolbarButton, {
165
166
  icon: 'editor-code',
166
167
  title: 'My formatting button',
167
168
  onClick: function() { /* ... */ }
@@ -175,8 +176,8 @@ wp.richText.registerFormatType( /* ... */, {
175
176
  {% ESNext %}
176
177
 
177
178
  ```js
178
- import { registerFormatType } from 'wp-rich-text';
179
- import { richTextToolbarButton } from 'wp-editor';
179
+ import { registerFormatType } from '@wordpress/rich-text';
180
+ import { RichTextToolbarButton } from '@wordpress/block-editor';
180
181
 
181
182
  registerFormatType( /* ... */, {
182
183
  /* ... */
@@ -348,7 +348,6 @@ export function RichTextWrapper(
348
348
  onReplace,
349
349
  onSplit,
350
350
  __unstableEmbedURLOnPaste,
351
- preserveWhiteSpace,
352
351
  pastePlainText,
353
352
  } ),
354
353
  useDelete( {
@@ -17,7 +17,6 @@ import {
17
17
  } from '@wordpress/blocks';
18
18
  import { useInstanceId, useMergeRefs } from '@wordpress/compose';
19
19
  import {
20
- __experimentalRichText as RichText,
21
20
  __unstableCreateElement,
22
21
  isEmpty,
23
22
  insert,
@@ -46,6 +45,7 @@ import {
46
45
  } from './utils';
47
46
  import EmbedHandlerPicker from './embed-handler-picker';
48
47
  import { Content } from './content';
48
+ import RichText from './native';
49
49
 
50
50
  const classes = 'block-editor-rich-text__editable';
51
51
 
@@ -688,6 +688,8 @@ ForwardedRichTextContainer.Content.defaultProps = {
688
688
  value: '',
689
689
  };
690
690
 
691
+ ForwardedRichTextContainer.Raw = RichText;
692
+
691
693
  /**
692
694
  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md
693
695
  */
@@ -0,0 +1,44 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { getActiveFormat, getActiveObject } from '@wordpress/rich-text';
5
+
6
+ export default function FormatEdit( {
7
+ formatTypes,
8
+ onChange,
9
+ onFocus,
10
+ value,
11
+ forwardedRef,
12
+ } ) {
13
+ return formatTypes.map( ( settings ) => {
14
+ const { name, edit: Edit } = settings;
15
+
16
+ if ( ! Edit ) {
17
+ return null;
18
+ }
19
+
20
+ const activeFormat = getActiveFormat( value, name );
21
+ const isActive = activeFormat !== undefined;
22
+ const activeObject = getActiveObject( value );
23
+ const isObjectActive =
24
+ activeObject !== undefined && activeObject.type === name;
25
+
26
+ return (
27
+ <Edit
28
+ key={ name }
29
+ isActive={ isActive }
30
+ activeAttributes={
31
+ isActive ? activeFormat.attributes || {} : {}
32
+ }
33
+ isObjectActive={ isObjectActive }
34
+ activeObjectAttributes={
35
+ isObjectActive ? activeObject.attributes || {} : {}
36
+ }
37
+ value={ value }
38
+ onChange={ onChange }
39
+ onFocus={ onFocus }
40
+ contentRef={ forwardedRef }
41
+ />
42
+ );
43
+ } );
44
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { getColorObjectByAttributeValues } from '../../../components/colors';
5
+
6
+ const FORMAT_TYPE = 'core/text-color';
7
+ const REGEX_TO_MATCH = /^has-(.*)-color$/;
8
+ const TAGS_TO_SEARCH = /\<mark/;
9
+
10
+ export function getFormatColors( value, formats, colors ) {
11
+ if ( value?.search( TAGS_TO_SEARCH ) !== -1 ) {
12
+ const newFormats = formats.slice();
13
+
14
+ newFormats.forEach( ( format ) => {
15
+ format.forEach( ( currentFormat ) => {
16
+ if ( currentFormat?.type === FORMAT_TYPE ) {
17
+ const className = currentFormat?.attributes?.class;
18
+ currentFormat.attributes.style =
19
+ currentFormat.attributes.style.replace( / /g, '' );
20
+
21
+ className?.split( ' ' ).forEach( ( currentClass ) => {
22
+ const match = currentClass.match( REGEX_TO_MATCH );
23
+ if ( match ) {
24
+ const [ , colorSlug ] =
25
+ currentClass.match( REGEX_TO_MATCH );
26
+ const colorObject = getColorObjectByAttributeValues(
27
+ colors,
28
+ colorSlug
29
+ );
30
+ const currentStyles =
31
+ currentFormat?.attributes?.style;
32
+ if (
33
+ colorObject &&
34
+ ( ! currentStyles ||
35
+ currentStyles?.indexOf(
36
+ colorObject.color
37
+ ) === -1 )
38
+ ) {
39
+ currentFormat.attributes.style = [
40
+ `color: ${ colorObject.color }`,
41
+ currentStyles,
42
+ ].join( ';' );
43
+ }
44
+ }
45
+ } );
46
+ }
47
+ } );
48
+ } );
49
+
50
+ return newFormats;
51
+ }
52
+
53
+ return formats;
54
+ }
@@ -0,0 +1 @@
1
+ export default () => {};