@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
@@ -1,448 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- useMemo,
6
- useState,
7
- useCallback,
8
- useRef,
9
- useEffect,
10
- } from '@wordpress/element';
11
- import { _x, __, _n, isRTL, sprintf } from '@wordpress/i18n';
12
- import { useViewportMatch } from '@wordpress/compose';
13
- import {
14
- __experimentalItemGroup as ItemGroup,
15
- __experimentalItem as Item,
16
- __experimentalHStack as HStack,
17
- __experimentalVStack as VStack,
18
- __experimentalHeading as Heading,
19
- __experimentalText as Text,
20
- FlexBlock,
21
- Button,
22
- } from '@wordpress/components';
23
- import { Icon, chevronRight, chevronLeft } from '@wordpress/icons';
24
- import { focus } from '@wordpress/dom';
25
- import { speak } from '@wordpress/a11y';
26
-
27
- /**
28
- * Internal dependencies
29
- */
30
- import usePatternsState from './hooks/use-patterns-state';
31
- import BlockPatternList from '../block-patterns-list';
32
- import PatternsExplorerModal from './block-patterns-explorer/explorer';
33
- import MobileTabNavigation from './mobile-tab-navigation';
34
- import usePatternsPaging from './hooks/use-patterns-paging';
35
- import {
36
- BlockPatternsSyncFilter,
37
- SYNC_TYPES,
38
- PATTERN_TYPES,
39
- } from './block-patterns-filter';
40
-
41
- const noop = () => {};
42
-
43
- export const allPatternsCategory = {
44
- name: 'allPatterns',
45
- label: __( 'All patterns' ),
46
- };
47
-
48
- export const myPatternsCategory = {
49
- name: 'myPatterns',
50
- label: __( 'My patterns' ),
51
- };
52
-
53
- export function isPatternFiltered( pattern, sourceFilter, syncFilter ) {
54
- const isUserPattern = pattern.name.startsWith( 'core/block' );
55
- const isDirectoryPattern =
56
- pattern.source === 'core' ||
57
- pattern.source?.startsWith( 'pattern-directory' );
58
-
59
- // If theme source selected, filter out user created patterns and those from
60
- // the core patterns directory.
61
- if (
62
- sourceFilter === PATTERN_TYPES.theme &&
63
- ( isUserPattern || isDirectoryPattern )
64
- ) {
65
- return true;
66
- }
67
-
68
- // If the directory source is selected, filter out user created patterns
69
- // and those bundled with the theme.
70
- if (
71
- sourceFilter === PATTERN_TYPES.directory &&
72
- ( isUserPattern || ! isDirectoryPattern )
73
- ) {
74
- return true;
75
- }
76
-
77
- // If user source selected, filter out theme patterns. Any pattern without
78
- // an id wasn't created by a user.
79
- if ( sourceFilter === PATTERN_TYPES.user && ! pattern.id ) {
80
- return true;
81
- }
82
-
83
- // Filter by sync status.
84
- if ( syncFilter === SYNC_TYPES.full && pattern.syncStatus !== '' ) {
85
- return true;
86
- }
87
-
88
- if (
89
- syncFilter === SYNC_TYPES.unsynced &&
90
- pattern.syncStatus !== 'unsynced' &&
91
- isUserPattern
92
- ) {
93
- return true;
94
- }
95
-
96
- return false;
97
- }
98
-
99
- export function usePatternsCategories( rootClientId, sourceFilter = 'all' ) {
100
- const [ patterns, allCategories ] = usePatternsState(
101
- undefined,
102
- rootClientId
103
- );
104
-
105
- const filteredPatterns = useMemo(
106
- () =>
107
- sourceFilter === 'all'
108
- ? patterns
109
- : patterns.filter(
110
- ( pattern ) =>
111
- ! isPatternFiltered( pattern, sourceFilter )
112
- ),
113
- [ sourceFilter, patterns ]
114
- );
115
-
116
- const hasRegisteredCategory = useCallback(
117
- ( pattern ) => {
118
- if ( ! pattern.categories || ! pattern.categories.length ) {
119
- return false;
120
- }
121
-
122
- return pattern.categories.some( ( cat ) =>
123
- allCategories.some( ( category ) => category.name === cat )
124
- );
125
- },
126
- [ allCategories ]
127
- );
128
-
129
- // Remove any empty categories.
130
- const populatedCategories = useMemo( () => {
131
- const categories = allCategories
132
- .filter( ( category ) =>
133
- filteredPatterns.some( ( pattern ) =>
134
- pattern.categories?.includes( category.name )
135
- )
136
- )
137
- .sort( ( a, b ) => a.label.localeCompare( b.label ) );
138
-
139
- if (
140
- filteredPatterns.some(
141
- ( pattern ) => ! hasRegisteredCategory( pattern )
142
- ) &&
143
- ! categories.find(
144
- ( category ) => category.name === 'uncategorized'
145
- )
146
- ) {
147
- categories.push( {
148
- name: 'uncategorized',
149
- label: _x( 'Uncategorized' ),
150
- } );
151
- }
152
- if ( filteredPatterns.some( ( pattern ) => pattern.id ) ) {
153
- categories.unshift( myPatternsCategory );
154
- }
155
- if ( filteredPatterns.length > 0 ) {
156
- categories.unshift( {
157
- name: allPatternsCategory.name,
158
- label: allPatternsCategory.label,
159
- } );
160
- }
161
- speak(
162
- sprintf(
163
- /* translators: %d: number of categories . */
164
- _n(
165
- '%d category button displayed.',
166
- '%d category buttons displayed.',
167
- categories.length
168
- ),
169
- categories.length
170
- )
171
- );
172
- return categories;
173
- }, [ allCategories, filteredPatterns, hasRegisteredCategory ] );
174
-
175
- return populatedCategories;
176
- }
177
-
178
- export function BlockPatternsCategoryDialog( {
179
- rootClientId,
180
- onInsert,
181
- onHover,
182
- category,
183
- showTitlesAsTooltip,
184
- patternFilter,
185
- } ) {
186
- const container = useRef();
187
-
188
- useEffect( () => {
189
- const timeout = setTimeout( () => {
190
- const [ firstTabbable ] = focus.tabbable.find( container.current );
191
- firstTabbable?.focus();
192
- } );
193
- return () => clearTimeout( timeout );
194
- }, [ category ] );
195
-
196
- return (
197
- <div
198
- ref={ container }
199
- className="block-editor-inserter__patterns-category-dialog"
200
- >
201
- <BlockPatternsCategoryPanel
202
- key={ category.name }
203
- rootClientId={ rootClientId }
204
- onInsert={ onInsert }
205
- onHover={ onHover }
206
- category={ category }
207
- showTitlesAsTooltip={ showTitlesAsTooltip }
208
- patternFilter={ patternFilter }
209
- />
210
- </div>
211
- );
212
- }
213
-
214
- export function BlockPatternsCategoryPanel( {
215
- rootClientId,
216
- onInsert,
217
- onHover = noop,
218
- category,
219
- showTitlesAsTooltip,
220
- } ) {
221
- const [ allPatterns, , onClickPattern ] = usePatternsState(
222
- onInsert,
223
- rootClientId
224
- );
225
- const [ patternSyncFilter, setPatternSyncFilter ] = useState( 'all' );
226
- const [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );
227
-
228
- const availableCategories = usePatternsCategories(
229
- rootClientId,
230
- patternSourceFilter
231
- );
232
- const scrollContainerRef = useRef();
233
- const currentCategoryPatterns = useMemo(
234
- () =>
235
- allPatterns.filter( ( pattern ) => {
236
- if (
237
- isPatternFiltered(
238
- pattern,
239
- patternSourceFilter,
240
- patternSyncFilter
241
- )
242
- ) {
243
- return false;
244
- }
245
-
246
- if ( category.name === allPatternsCategory.name ) {
247
- return true;
248
- }
249
- if ( category.name === myPatternsCategory.name && pattern.id ) {
250
- return true;
251
- }
252
- if ( category.name !== 'uncategorized' ) {
253
- return pattern.categories?.includes( category.name );
254
- }
255
-
256
- // The uncategorized category should show all the patterns without any category
257
- // or with no available category.
258
- const availablePatternCategories =
259
- pattern.categories?.filter( ( cat ) =>
260
- availableCategories.find(
261
- ( availableCategory ) =>
262
- availableCategory.name === cat
263
- )
264
- ) ?? [];
265
-
266
- return availablePatternCategories.length === 0;
267
- } ),
268
- [
269
- allPatterns,
270
- availableCategories,
271
- category.name,
272
- patternSourceFilter,
273
- patternSyncFilter,
274
- ]
275
- );
276
-
277
- const pagingProps = usePatternsPaging(
278
- currentCategoryPatterns,
279
- category,
280
- scrollContainerRef
281
- );
282
- const { changePage } = pagingProps;
283
-
284
- // Hide block pattern preview on unmount.
285
- // eslint-disable-next-line react-hooks/exhaustive-deps
286
- useEffect( () => () => onHover( null ), [] );
287
-
288
- const onSetPatternSyncFilter = useCallback(
289
- ( value ) => {
290
- setPatternSyncFilter( value );
291
- changePage( 1 );
292
- },
293
- [ setPatternSyncFilter, changePage ]
294
- );
295
- const onSetPatternSourceFilter = useCallback(
296
- ( value ) => {
297
- setPatternSourceFilter( value );
298
- changePage( 1 );
299
- },
300
- [ setPatternSourceFilter, changePage ]
301
- );
302
-
303
- return (
304
- <div className="block-editor-inserter__patterns-category-panel">
305
- <VStack
306
- spacing={ 2 }
307
- className="block-editor-inserter__patterns-category-panel-header"
308
- >
309
- <HStack>
310
- <FlexBlock>
311
- <Heading level={ 4 } as="div">
312
- { category.label }
313
- </Heading>
314
- </FlexBlock>
315
- <BlockPatternsSyncFilter
316
- patternSyncFilter={ patternSyncFilter }
317
- patternSourceFilter={ patternSourceFilter }
318
- setPatternSyncFilter={ onSetPatternSyncFilter }
319
- setPatternSourceFilter={ onSetPatternSourceFilter }
320
- scrollContainerRef={ scrollContainerRef }
321
- category={ category }
322
- />
323
- </HStack>
324
- { ! currentCategoryPatterns.length && (
325
- <Text
326
- variant="muted"
327
- className="block-editor-inserter__patterns-category-no-results"
328
- >
329
- { __( 'No results found' ) }
330
- </Text>
331
- ) }
332
- </VStack>
333
-
334
- { currentCategoryPatterns.length > 0 && (
335
- <BlockPatternList
336
- ref={ scrollContainerRef }
337
- shownPatterns={ pagingProps.categoryPatternsAsyncList }
338
- blockPatterns={ pagingProps.categoryPatterns }
339
- onClickPattern={ onClickPattern }
340
- onHover={ onHover }
341
- label={ category.label }
342
- orientation="vertical"
343
- category={ category.name }
344
- isDraggable
345
- showTitlesAsTooltip={ showTitlesAsTooltip }
346
- patternFilter={ patternSourceFilter }
347
- pagingProps={ pagingProps }
348
- />
349
- ) }
350
- </div>
351
- );
352
- }
353
-
354
- function BlockPatternsTabs( {
355
- onSelectCategory,
356
- selectedCategory,
357
- onInsert,
358
- rootClientId,
359
- } ) {
360
- const [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );
361
-
362
- const categories = usePatternsCategories( rootClientId );
363
-
364
- const initialCategory = selectedCategory || categories[ 0 ];
365
- const isMobile = useViewportMatch( 'medium', '<' );
366
- return (
367
- <>
368
- { ! isMobile && (
369
- <div className="block-editor-inserter__block-patterns-tabs-container">
370
- <nav
371
- aria-label={ __( 'Block pattern categories' ) }
372
- className="block-editor-inserter__block-patterns-tabs"
373
- >
374
- <ItemGroup role="list">
375
- { categories.map( ( category ) => (
376
- <Item
377
- role="listitem"
378
- key={ category.name }
379
- onClick={ () =>
380
- onSelectCategory( category )
381
- }
382
- className={
383
- category === selectedCategory
384
- ? 'block-editor-inserter__patterns-category block-editor-inserter__patterns-selected-category'
385
- : 'block-editor-inserter__patterns-category'
386
- }
387
- aria-label={ category.label }
388
- aria-current={
389
- category === selectedCategory
390
- ? 'true'
391
- : undefined
392
- }
393
- >
394
- <HStack>
395
- <FlexBlock>
396
- { category.label }
397
- </FlexBlock>
398
- <Icon
399
- icon={
400
- isRTL()
401
- ? chevronLeft
402
- : chevronRight
403
- }
404
- />
405
- </HStack>
406
- </Item>
407
- ) ) }
408
- <div role="listitem">
409
- <Button
410
- className="block-editor-inserter__patterns-explore-button"
411
- onClick={ () =>
412
- setShowPatternsExplorer( true )
413
- }
414
- variant="secondary"
415
- >
416
- { __( 'Explore all patterns' ) }
417
- </Button>
418
- </div>
419
- </ItemGroup>
420
- </nav>
421
- </div>
422
- ) }
423
- { isMobile && (
424
- <MobileTabNavigation categories={ categories }>
425
- { ( category ) => (
426
- <BlockPatternsCategoryPanel
427
- key={ category.name }
428
- onInsert={ onInsert }
429
- rootClientId={ rootClientId }
430
- category={ category }
431
- showTitlesAsTooltip={ false }
432
- />
433
- ) }
434
- </MobileTabNavigation>
435
- ) }
436
- { showPatternsExplorer && (
437
- <PatternsExplorerModal
438
- initialCategory={ initialCategory }
439
- patternCategories={ categories }
440
- onModalClose={ () => setShowPatternsExplorer( false ) }
441
- rootClientId={ rootClientId }
442
- />
443
- ) }
444
- </>
445
- );
446
- }
447
-
448
- export default BlockPatternsTabs;
@@ -1,226 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
5
- import { addFilter } from '@wordpress/hooks';
6
- import { __, sprintf } from '@wordpress/i18n';
7
- import { hasBlockSupport } from '@wordpress/blocks';
8
- import {
9
- MenuItem,
10
- __experimentalHStack as HStack,
11
- __experimentalVStack as VStack,
12
- Button,
13
- TextControl,
14
- Modal,
15
- } from '@wordpress/components';
16
- import { useState } from '@wordpress/element';
17
- import { speak } from '@wordpress/a11y';
18
-
19
- /**
20
- * Internal dependencies
21
- */
22
- import {
23
- BlockSettingsMenuControls,
24
- useBlockDisplayInformation,
25
- InspectorControls,
26
- } from '../components';
27
-
28
- const emptyString = ( testString ) => testString?.trim()?.length === 0;
29
-
30
- function RenameModal( { blockName, originalBlockName, onClose, onSave } ) {
31
- const [ editedBlockName, setEditedBlockName ] = useState( blockName );
32
-
33
- const nameHasChanged = editedBlockName !== blockName;
34
- const nameIsOriginal = editedBlockName === originalBlockName;
35
- const nameIsEmpty = emptyString( editedBlockName );
36
-
37
- const isNameValid = nameHasChanged || nameIsOriginal;
38
-
39
- const autoSelectInputText = ( event ) => event.target.select();
40
-
41
- const dialogDescription = useInstanceId(
42
- RenameModal,
43
- `block-editor-rename-modal__description`
44
- );
45
-
46
- const handleSubmit = () => {
47
- const message =
48
- nameIsOriginal || nameIsEmpty
49
- ? sprintf(
50
- /* translators: %s: new name/label for the block */
51
- __( 'Block name reset to: "%s".' ),
52
- editedBlockName
53
- )
54
- : sprintf(
55
- /* translators: %s: new name/label for the block */
56
- __( 'Block name changed to: "%s".' ),
57
- editedBlockName
58
- );
59
-
60
- // Must be assertive to immediately announce change.
61
- speak( message, 'assertive' );
62
- onSave( editedBlockName );
63
-
64
- // Immediate close avoids ability to hit save multiple times.
65
- onClose();
66
- };
67
-
68
- return (
69
- <Modal
70
- title={ __( 'Rename' ) }
71
- onRequestClose={ onClose }
72
- overlayClassName="block-editor-block-rename-modal"
73
- aria={ {
74
- describedby: dialogDescription,
75
- } }
76
- focusOnMount="firstContentElement"
77
- >
78
- <p id={ dialogDescription }>
79
- { __( 'Enter a custom name for this block.' ) }
80
- </p>
81
- <form
82
- onSubmit={ ( e ) => {
83
- e.preventDefault();
84
-
85
- if ( ! isNameValid ) {
86
- return;
87
- }
88
-
89
- handleSubmit();
90
- } }
91
- >
92
- <VStack spacing="3">
93
- <TextControl
94
- __nextHasNoMarginBottom
95
- value={ editedBlockName }
96
- label={ __( 'Block name' ) }
97
- hideLabelFromVision={ true }
98
- placeholder={ originalBlockName }
99
- onChange={ setEditedBlockName }
100
- onFocus={ autoSelectInputText }
101
- />
102
- <HStack justify="right">
103
- <Button variant="tertiary" onClick={ onClose }>
104
- { __( 'Cancel' ) }
105
- </Button>
106
-
107
- <Button
108
- aria-disabled={ ! isNameValid }
109
- variant="primary"
110
- type="submit"
111
- >
112
- { __( 'Save' ) }
113
- </Button>
114
- </HStack>
115
- </VStack>
116
- </form>
117
- </Modal>
118
- );
119
- }
120
-
121
- function BlockRenameControl( props ) {
122
- const [ renamingBlock, setRenamingBlock ] = useState( false );
123
-
124
- const { clientId, customName, onChange } = props;
125
-
126
- const blockInformation = useBlockDisplayInformation( clientId );
127
-
128
- return (
129
- <>
130
- <InspectorControls group="advanced">
131
- <TextControl
132
- __nextHasNoMarginBottom
133
- label={ __( 'Block name' ) }
134
- value={ customName || '' }
135
- onChange={ onChange }
136
- />
137
- </InspectorControls>
138
- <BlockSettingsMenuControls>
139
- { ( { selectedClientIds } ) => {
140
- // Only enabled for single selections.
141
- const canRename =
142
- selectedClientIds.length === 1 &&
143
- clientId === selectedClientIds[ 0 ];
144
-
145
- // This check ensures the `BlockSettingsMenuControls` fill
146
- // doesn't render multiple times and also that it renders for
147
- // the block from which the menu was triggered.
148
- if ( ! canRename ) {
149
- return null;
150
- }
151
-
152
- return (
153
- <MenuItem
154
- onClick={ () => {
155
- setRenamingBlock( true );
156
- } }
157
- aria-expanded={ renamingBlock }
158
- aria-haspopup="dialog"
159
- >
160
- { __( 'Rename' ) }
161
- </MenuItem>
162
- );
163
- } }
164
- </BlockSettingsMenuControls>
165
-
166
- { renamingBlock && (
167
- <RenameModal
168
- blockName={ customName || '' }
169
- originalBlockName={ blockInformation?.title }
170
- onClose={ () => setRenamingBlock( false ) }
171
- onSave={ ( newName ) => {
172
- // If the new value is the block's original name (e.g. `Group`)
173
- // or it is an empty string then assume the intent is to reset
174
- // the value. Therefore reset the metadata.
175
- if (
176
- newName === blockInformation?.title ||
177
- emptyString( newName )
178
- ) {
179
- newName = undefined;
180
- }
181
-
182
- onChange( newName );
183
- } }
184
- />
185
- ) }
186
- </>
187
- );
188
- }
189
-
190
- export const withBlockRenameControl = createHigherOrderComponent(
191
- ( BlockEdit ) => ( props ) => {
192
- const { clientId, name, attributes, setAttributes, isSelected } = props;
193
-
194
- const supportsBlockNaming = hasBlockSupport( name, 'renaming', true );
195
-
196
- return (
197
- <>
198
- { isSelected && supportsBlockNaming && (
199
- <>
200
- <BlockRenameControl
201
- clientId={ clientId }
202
- customName={ attributes?.metadata?.name }
203
- onChange={ ( newName ) => {
204
- setAttributes( {
205
- metadata: {
206
- ...attributes?.metadata,
207
- name: newName,
208
- },
209
- } );
210
- } }
211
- />
212
- </>
213
- ) }
214
-
215
- <BlockEdit key="edit" { ...props } />
216
- </>
217
- );
218
- },
219
- 'withToolbarControls'
220
- );
221
-
222
- addFilter(
223
- 'editor.BlockEdit',
224
- 'core/block-rename-ui/with-block-rename-control',
225
- withBlockRenameControl
226
- );
@@ -1,12 +0,0 @@
1
- /**
2
- * Helper function that maps attribute definition properties to the
3
- * ones used by RichText utils like `create, toHTMLString, etc..`.
4
- *
5
- * @param {Object} attributeDefinition A block's attribute definition object.
6
- * @return {Object} The mapped object.
7
- */
8
- export function mapRichTextSettings( attributeDefinition ) {
9
- const { __unstablePreserveWhiteSpace: preserveWhiteSpace } =
10
- attributeDefinition;
11
- return { preserveWhiteSpace };
12
- }