@wordpress/block-editor 11.3.6 → 11.5.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 (357) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/build/components/block-lock/modal.js +1 -0
  3. package/build/components/block-lock/modal.js.map +1 -1
  4. package/build/components/block-popover/inbetween.js +10 -33
  5. package/build/components/block-popover/inbetween.js.map +1 -1
  6. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
  7. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  8. package/build/components/block-styles/index.js +2 -1
  9. package/build/components/block-styles/index.js.map +1 -1
  10. package/build/components/block-types-list/index.native.js +2 -0
  11. package/build/components/block-types-list/index.native.js.map +1 -1
  12. package/build/components/child-layout-control/index.js +107 -0
  13. package/build/components/child-layout-control/index.js.map +1 -0
  14. package/build/components/colors-gradients/control.js +6 -3
  15. package/build/components/colors-gradients/control.js.map +1 -1
  16. package/build/components/date-format-picker/index.js +3 -3
  17. package/build/components/date-format-picker/index.js.map +1 -1
  18. package/build/components/font-appearance-control/index.js +0 -3
  19. package/build/components/font-appearance-control/index.js.map +1 -1
  20. package/build/components/global-styles/dimensions-panel.js +594 -0
  21. package/build/components/global-styles/dimensions-panel.js.map +1 -0
  22. package/build/components/global-styles/hooks.js +142 -45
  23. package/build/components/global-styles/hooks.js.map +1 -1
  24. package/build/components/global-styles/index.js +38 -0
  25. package/build/components/global-styles/index.js.map +1 -1
  26. package/build/components/global-styles/typography-panel.js +434 -0
  27. package/build/components/global-styles/typography-panel.js.map +1 -0
  28. package/build/components/global-styles/use-global-styles-output.js +7 -3
  29. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  30. package/build/components/global-styles/utils.js +2 -0
  31. package/build/components/global-styles/utils.js.map +1 -1
  32. package/build/components/iframe/index.js +17 -11
  33. package/build/components/iframe/index.js.map +1 -1
  34. package/build/components/image-editor/aspect-ratio-dropdown.js +2 -1
  35. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  36. package/build/components/image-size-control/index.js +6 -11
  37. package/build/components/image-size-control/index.js.map +1 -1
  38. package/build/components/index.native.js +23 -0
  39. package/build/components/index.native.js.map +1 -1
  40. package/build/components/inserter/block-patterns-tab.js +9 -15
  41. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  42. package/build/components/inserter/block-types-tab.native.js +4 -1
  43. package/build/components/inserter/block-types-tab.native.js.map +1 -1
  44. package/build/components/inserter/reusable-blocks-tab.native.js +4 -1
  45. package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  46. package/build/components/inserter/search-results.native.js +4 -1
  47. package/build/components/inserter/search-results.native.js.map +1 -1
  48. package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
  49. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  50. package/build/components/inspector-controls/fill.js +38 -9
  51. package/build/components/inspector-controls/fill.js.map +1 -1
  52. package/build/components/link-control/index.js +55 -28
  53. package/build/components/link-control/index.js.map +1 -1
  54. package/build/components/link-control/settings-drawer.js +72 -30
  55. package/build/components/link-control/settings-drawer.js.map +1 -1
  56. package/build/components/link-control/settings.js +53 -0
  57. package/build/components/link-control/settings.js.map +1 -0
  58. package/build/components/list-view/block.js +4 -2
  59. package/build/components/list-view/block.js.map +1 -1
  60. package/build/components/list-view/expander.js +2 -1
  61. package/build/components/list-view/expander.js.map +1 -1
  62. package/build/components/list-view/index.js +6 -1
  63. package/build/components/list-view/index.js.map +1 -1
  64. package/build/components/off-canvas-editor/appender.js +5 -10
  65. package/build/components/off-canvas-editor/appender.js.map +1 -1
  66. package/build/components/off-canvas-editor/block-contents.js +3 -2
  67. package/build/components/off-canvas-editor/block-contents.js.map +1 -1
  68. package/build/components/off-canvas-editor/branch.js +1 -0
  69. package/build/components/off-canvas-editor/branch.js.map +1 -1
  70. package/build/components/off-canvas-editor/index.js +7 -3
  71. package/build/components/off-canvas-editor/index.js.map +1 -1
  72. package/build/components/off-canvas-editor/leaf-more-menu.js +24 -4
  73. package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  74. package/build/components/off-canvas-editor/link-ui.js +2 -0
  75. package/build/components/off-canvas-editor/link-ui.js.map +1 -1
  76. package/build/components/responsive-block-control/index.js +1 -0
  77. package/build/components/responsive-block-control/index.js.map +1 -1
  78. package/build/components/rich-text/index.js +9 -45
  79. package/build/components/rich-text/index.js.map +1 -1
  80. package/build/components/rich-text/use-delete.js +73 -0
  81. package/build/components/rich-text/use-delete.js.map +1 -0
  82. package/build/components/rich-text/use-input-rules.js +14 -6
  83. package/build/components/rich-text/use-input-rules.js.map +1 -1
  84. package/build/components/url-input/index.js +2 -2
  85. package/build/components/url-input/index.js.map +1 -1
  86. package/build/components/writing-flow/use-selection-observer.js +4 -1
  87. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  88. package/build/hooks/align.js +3 -1
  89. package/build/hooks/align.js.map +1 -1
  90. package/build/hooks/dimensions.js +78 -190
  91. package/build/hooks/dimensions.js.map +1 -1
  92. package/build/hooks/duotone.js +94 -25
  93. package/build/hooks/duotone.js.map +1 -1
  94. package/build/hooks/font-family.js +2 -76
  95. package/build/hooks/font-family.js.map +1 -1
  96. package/build/hooks/font-size.js +3 -51
  97. package/build/hooks/font-size.js.map +1 -1
  98. package/build/hooks/gap.js +0 -201
  99. package/build/hooks/gap.js.map +1 -1
  100. package/build/hooks/index.js +2 -0
  101. package/build/hooks/index.js.map +1 -1
  102. package/build/hooks/layout.js +14 -5
  103. package/build/hooks/layout.js.map +1 -1
  104. package/build/hooks/line-height.js +0 -42
  105. package/build/hooks/line-height.js.map +1 -1
  106. package/build/hooks/margin.js +7 -163
  107. package/build/hooks/margin.js.map +1 -1
  108. package/build/hooks/padding.js +7 -163
  109. package/build/hooks/padding.js.map +1 -1
  110. package/build/hooks/typography.js +98 -128
  111. package/build/hooks/typography.js.map +1 -1
  112. package/build/hooks/utils.js +75 -0
  113. package/build/hooks/utils.js.map +1 -1
  114. package/build/layouts/flex.js +1 -0
  115. package/build/layouts/flex.js.map +1 -1
  116. package/build/store/actions.js +24 -12
  117. package/build/store/actions.js.map +1 -1
  118. package/build/store/reducer.js +53 -47
  119. package/build/store/reducer.js.map +1 -1
  120. package/build/store/selectors.js +22 -1
  121. package/build/store/selectors.js.map +1 -1
  122. package/build/utils/parse-css-unit-to-px.js +36 -3
  123. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  124. package/build-module/components/block-lock/modal.js +1 -0
  125. package/build-module/components/block-lock/modal.js.map +1 -1
  126. package/build-module/components/block-popover/inbetween.js +10 -33
  127. package/build-module/components/block-popover/inbetween.js.map +1 -1
  128. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
  129. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  130. package/build-module/components/block-styles/index.js +2 -1
  131. package/build-module/components/block-styles/index.js.map +1 -1
  132. package/build-module/components/block-types-list/index.native.js +2 -0
  133. package/build-module/components/block-types-list/index.native.js.map +1 -1
  134. package/build-module/components/child-layout-control/index.js +98 -0
  135. package/build-module/components/child-layout-control/index.js.map +1 -0
  136. package/build-module/components/colors-gradients/control.js +6 -3
  137. package/build-module/components/colors-gradients/control.js.map +1 -1
  138. package/build-module/components/date-format-picker/index.js +4 -4
  139. package/build-module/components/date-format-picker/index.js.map +1 -1
  140. package/build-module/components/font-appearance-control/index.js +2 -1
  141. package/build-module/components/font-appearance-control/index.js.map +1 -1
  142. package/build-module/components/global-styles/dimensions-panel.js +574 -0
  143. package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
  144. package/build-module/components/global-styles/hooks.js +138 -46
  145. package/build-module/components/global-styles/hooks.js.map +1 -1
  146. package/build-module/components/global-styles/index.js +3 -1
  147. package/build-module/components/global-styles/index.js.map +1 -1
  148. package/build-module/components/global-styles/typography-panel.js +415 -0
  149. package/build-module/components/global-styles/typography-panel.js.map +1 -0
  150. package/build-module/components/global-styles/use-global-styles-output.js +7 -3
  151. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  152. package/build-module/components/global-styles/utils.js +2 -0
  153. package/build-module/components/global-styles/utils.js.map +1 -1
  154. package/build-module/components/iframe/index.js +17 -11
  155. package/build-module/components/iframe/index.js.map +1 -1
  156. package/build-module/components/image-editor/aspect-ratio-dropdown.js +2 -1
  157. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  158. package/build-module/components/image-size-control/index.js +7 -12
  159. package/build-module/components/image-size-control/index.js.map +1 -1
  160. package/build-module/components/index.native.js +2 -1
  161. package/build-module/components/index.native.js.map +1 -1
  162. package/build-module/components/inserter/block-patterns-tab.js +9 -15
  163. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  164. package/build-module/components/inserter/block-types-tab.native.js +3 -1
  165. package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
  166. package/build-module/components/inserter/reusable-blocks-tab.native.js +3 -1
  167. package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  168. package/build-module/components/inserter/search-results.native.js +3 -1
  169. package/build-module/components/inserter/search-results.native.js.map +1 -1
  170. package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
  171. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  172. package/build-module/components/inspector-controls/fill.js +39 -9
  173. package/build-module/components/inspector-controls/fill.js.map +1 -1
  174. package/build-module/components/link-control/index.js +56 -28
  175. package/build-module/components/link-control/index.js.map +1 -1
  176. package/build-module/components/link-control/settings-drawer.js +68 -30
  177. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  178. package/build-module/components/link-control/settings.js +44 -0
  179. package/build-module/components/link-control/settings.js.map +1 -0
  180. package/build-module/components/list-view/block.js +4 -2
  181. package/build-module/components/list-view/block.js.map +1 -1
  182. package/build-module/components/list-view/expander.js +2 -1
  183. package/build-module/components/list-view/expander.js.map +1 -1
  184. package/build-module/components/list-view/index.js +6 -1
  185. package/build-module/components/list-view/index.js.map +1 -1
  186. package/build-module/components/off-canvas-editor/appender.js +5 -10
  187. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  188. package/build-module/components/off-canvas-editor/block-contents.js +3 -2
  189. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
  190. package/build-module/components/off-canvas-editor/branch.js +1 -0
  191. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  192. package/build-module/components/off-canvas-editor/index.js +7 -3
  193. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  194. package/build-module/components/off-canvas-editor/leaf-more-menu.js +27 -7
  195. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  196. package/build-module/components/off-canvas-editor/link-ui.js +2 -0
  197. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
  198. package/build-module/components/responsive-block-control/index.js +1 -0
  199. package/build-module/components/responsive-block-control/index.js.map +1 -1
  200. package/build-module/components/rich-text/index.js +9 -45
  201. package/build-module/components/rich-text/index.js.map +1 -1
  202. package/build-module/components/rich-text/use-delete.js +62 -0
  203. package/build-module/components/rich-text/use-delete.js.map +1 -0
  204. package/build-module/components/rich-text/use-input-rules.js +14 -6
  205. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  206. package/build-module/components/url-input/index.js +2 -2
  207. package/build-module/components/url-input/index.js.map +1 -1
  208. package/build-module/components/writing-flow/use-selection-observer.js +4 -1
  209. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  210. package/build-module/hooks/align.js +3 -1
  211. package/build-module/hooks/align.js.map +1 -1
  212. package/build-module/hooks/dimensions.js +81 -187
  213. package/build-module/hooks/dimensions.js.map +1 -1
  214. package/build-module/hooks/duotone.js +86 -24
  215. package/build-module/hooks/duotone.js.map +1 -1
  216. package/build-module/hooks/font-family.js +3 -69
  217. package/build-module/hooks/font-family.js.map +1 -1
  218. package/build-module/hooks/font-size.js +6 -47
  219. package/build-module/hooks/font-size.js.map +1 -1
  220. package/build-module/hooks/gap.js +0 -182
  221. package/build-module/hooks/gap.js.map +1 -1
  222. package/build-module/hooks/index.js +1 -0
  223. package/build-module/hooks/index.js.map +1 -1
  224. package/build-module/hooks/layout.js +14 -5
  225. package/build-module/hooks/layout.js.map +1 -1
  226. package/build-module/hooks/line-height.js +0 -38
  227. package/build-module/hooks/line-height.js.map +1 -1
  228. package/build-module/hooks/margin.js +4 -143
  229. package/build-module/hooks/margin.js.map +1 -1
  230. package/build-module/hooks/padding.js +4 -143
  231. package/build-module/hooks/padding.js.map +1 -1
  232. package/build-module/hooks/typography.js +97 -123
  233. package/build-module/hooks/typography.js.map +1 -1
  234. package/build-module/hooks/utils.js +70 -0
  235. package/build-module/hooks/utils.js.map +1 -1
  236. package/build-module/layouts/flex.js +1 -0
  237. package/build-module/layouts/flex.js.map +1 -1
  238. package/build-module/store/actions.js +24 -12
  239. package/build-module/store/actions.js.map +1 -1
  240. package/build-module/store/reducer.js +53 -45
  241. package/build-module/store/reducer.js.map +1 -1
  242. package/build-module/store/selectors.js +22 -1
  243. package/build-module/store/selectors.js.map +1 -1
  244. package/build-module/utils/parse-css-unit-to-px.js +36 -3
  245. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  246. package/build-style/style-rtl.css +54 -64
  247. package/build-style/style.css +54 -64
  248. package/package.json +31 -31
  249. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
  250. package/src/components/block-lock/modal.js +1 -0
  251. package/src/components/block-lock/style.scss +0 -9
  252. package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
  253. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +15 -15
  254. package/src/components/block-popover/inbetween.js +21 -53
  255. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
  256. package/src/components/block-styles/index.js +5 -1
  257. package/src/components/block-types-list/index.native.js +2 -0
  258. package/src/components/child-layout-control/index.js +106 -0
  259. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  260. package/src/components/colors-gradients/control.js +3 -0
  261. package/src/components/date-format-picker/index.js +6 -8
  262. package/src/components/date-format-picker/style.scss +0 -5
  263. package/src/components/font-appearance-control/index.js +1 -1
  264. package/src/components/global-styles/dimensions-panel.js +627 -0
  265. package/src/components/global-styles/hooks.js +229 -66
  266. package/src/components/global-styles/index.js +9 -0
  267. package/src/components/global-styles/typography-panel.js +428 -0
  268. package/src/components/global-styles/use-global-styles-output.js +10 -5
  269. package/src/components/global-styles/utils.js +2 -0
  270. package/src/components/iframe/index.js +20 -18
  271. package/src/components/image-editor/aspect-ratio-dropdown.js +1 -0
  272. package/src/components/image-size-control/index.js +10 -12
  273. package/src/components/image-size-control/style.scss +3 -21
  274. package/src/components/index.native.js +5 -0
  275. package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
  276. package/src/components/inserter/block-patterns-tab.js +9 -23
  277. package/src/components/inserter/block-types-tab.native.js +2 -0
  278. package/src/components/inserter/reusable-blocks-tab.native.js +2 -0
  279. package/src/components/inserter/search-results.native.js +2 -0
  280. package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
  281. package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
  282. package/src/components/inspector-controls/fill.js +32 -8
  283. package/src/components/link-control/index.js +69 -34
  284. package/src/components/link-control/settings-drawer.js +85 -29
  285. package/src/components/link-control/settings.js +42 -0
  286. package/src/components/link-control/style.scss +63 -37
  287. package/src/components/link-control/test/index.js +347 -9
  288. package/src/components/list-view/block.js +7 -1
  289. package/src/components/list-view/expander.js +1 -0
  290. package/src/components/list-view/index.js +5 -0
  291. package/src/components/media-replace-flow/style.scss +7 -9
  292. package/src/components/media-replace-flow/test/index.js +1 -1
  293. package/src/components/off-canvas-editor/appender.js +13 -16
  294. package/src/components/off-canvas-editor/block-contents.js +2 -1
  295. package/src/components/off-canvas-editor/branch.js +1 -0
  296. package/src/components/off-canvas-editor/index.js +8 -2
  297. package/src/components/off-canvas-editor/leaf-more-menu.js +52 -15
  298. package/src/components/off-canvas-editor/link-ui.js +2 -0
  299. package/src/components/responsive-block-control/index.js +1 -0
  300. package/src/components/rich-text/index.js +8 -46
  301. package/src/components/rich-text/use-delete.js +59 -0
  302. package/src/components/rich-text/use-input-rules.js +13 -5
  303. package/src/components/url-input/index.js +3 -2
  304. package/src/components/url-popover/stories/index.js +1 -0
  305. package/src/components/writing-flow/use-selection-observer.js +5 -1
  306. package/src/hooks/align.js +1 -1
  307. package/src/hooks/dimensions.js +97 -269
  308. package/src/hooks/duotone.js +100 -30
  309. package/src/hooks/font-family.js +0 -58
  310. package/src/hooks/font-size.js +1 -36
  311. package/src/hooks/gap.js +0 -201
  312. package/src/hooks/index.js +1 -0
  313. package/src/hooks/layout.js +19 -6
  314. package/src/hooks/line-height.js +0 -33
  315. package/src/hooks/margin.js +1 -164
  316. package/src/hooks/padding.js +1 -163
  317. package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
  318. package/src/hooks/test/duotone.js +102 -0
  319. package/src/hooks/typography.js +112 -213
  320. package/src/hooks/utils.js +90 -0
  321. package/src/layouts/flex.js +1 -0
  322. package/src/store/actions.js +12 -4
  323. package/src/store/reducer.js +68 -43
  324. package/src/store/selectors.js +20 -1
  325. package/src/store/test/actions.js +4 -2
  326. package/src/utils/parse-css-unit-to-px.js +35 -5
  327. package/src/utils/test/parse-css-unit-to-px.js +12 -0
  328. package/build/hooks/child-layout.js +0 -213
  329. package/build/hooks/child-layout.js.map +0 -1
  330. package/build/hooks/font-appearance.js +0 -188
  331. package/build/hooks/font-appearance.js.map +0 -1
  332. package/build/hooks/letter-spacing.js +0 -129
  333. package/build/hooks/letter-spacing.js.map +0 -1
  334. package/build/hooks/min-height.js +0 -139
  335. package/build/hooks/min-height.js.map +0 -1
  336. package/build/hooks/text-decoration.js +0 -130
  337. package/build/hooks/text-decoration.js.map +0 -1
  338. package/build/hooks/text-transform.js +0 -130
  339. package/build/hooks/text-transform.js.map +0 -1
  340. package/build-module/hooks/child-layout.js +0 -193
  341. package/build-module/hooks/child-layout.js.map +0 -1
  342. package/build-module/hooks/font-appearance.js +0 -161
  343. package/build-module/hooks/font-appearance.js.map +0 -1
  344. package/build-module/hooks/letter-spacing.js +0 -107
  345. package/build-module/hooks/letter-spacing.js.map +0 -1
  346. package/build-module/hooks/min-height.js +0 -116
  347. package/build-module/hooks/min-height.js.map +0 -1
  348. package/build-module/hooks/text-decoration.js +0 -108
  349. package/build-module/hooks/text-decoration.js.map +0 -1
  350. package/build-module/hooks/text-transform.js +0 -108
  351. package/build-module/hooks/text-transform.js.map +0 -1
  352. package/src/hooks/child-layout.js +0 -195
  353. package/src/hooks/font-appearance.js +0 -146
  354. package/src/hooks/letter-spacing.js +0 -101
  355. package/src/hooks/min-height.js +0 -104
  356. package/src/hooks/text-decoration.js +0 -102
  357. package/src/hooks/text-transform.js +0 -101
@@ -28,7 +28,7 @@ import BlockPatternList from '../block-patterns-list';
28
28
  import PatternsExplorerModal from './block-patterns-explorer/explorer';
29
29
  import MobileTabNavigation from './mobile-tab-navigation';
30
30
 
31
- // Preffered order of pattern categories. Any other categories should
31
+ // Preferred order of pattern categories. Any other categories should
32
32
  // be at the bottom without any re-ordering.
33
33
  const patternCategoriesOrder = [
34
34
  'featured',
@@ -68,28 +68,14 @@ function usePatternsCategories( rootClientId ) {
68
68
  pattern.categories?.includes( category.name )
69
69
  )
70
70
  )
71
- .sort( ( { name: currentName }, { name: nextName } ) => {
72
- // The pattern categories should be ordered as follows:
73
- // 1. The categories from `patternCategoriesOrder` in that specific order should be at the top.
74
- // 2. The rest categories should be at the bottom without any re-ordering.
75
- if (
76
- ! [ currentName, nextName ].some( ( categoryName ) =>
77
- patternCategoriesOrder.includes( categoryName )
78
- )
79
- ) {
80
- return 0;
81
- }
82
- if (
83
- [ currentName, nextName ].every( ( categoryName ) =>
84
- patternCategoriesOrder.includes( categoryName )
85
- )
86
- ) {
87
- return (
88
- patternCategoriesOrder.indexOf( currentName ) -
89
- patternCategoriesOrder.indexOf( nextName )
90
- );
91
- }
92
- return patternCategoriesOrder.includes( currentName ) ? -1 : 1;
71
+ .sort( ( { name: aName }, { name: bName } ) => {
72
+ // Sort categories according to `patternCategoriesOrder`.
73
+ let aIndex = patternCategoriesOrder.indexOf( aName );
74
+ let bIndex = patternCategoriesOrder.indexOf( bName );
75
+ // All other categories should come after that.
76
+ if ( aIndex < 0 ) aIndex = patternCategoriesOrder.length;
77
+ if ( bIndex < 0 ) bIndex = patternCategoriesOrder.length;
78
+ return aIndex - bIndex;
93
79
  } );
94
80
 
95
81
  if (
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useMemo } from '@wordpress/element';
5
+ import { __ } from '@wordpress/i18n';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -66,6 +67,7 @@ function BlockTypesTab( { onSelect, rootClientId, listProps } ) {
66
67
  sections={ sections }
67
68
  onSelect={ handleSelect }
68
69
  listProps={ listProps }
70
+ label={ __( 'Blocks menu' ) }
69
71
  />
70
72
  );
71
73
  }
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useSelect } from '@wordpress/data';
5
+ import { __ } from '@wordpress/i18n';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -31,6 +32,7 @@ function ReusableBlocksTab( { onSelect, rootClientId, listProps } ) {
31
32
  sections={ sections }
32
33
  onSelect={ onSelect }
33
34
  listProps={ listProps }
35
+ label={ __( 'Reusable blocks' ) }
34
36
  />
35
37
  );
36
38
  }
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useSelect } from '@wordpress/data';
5
+ import { __ } from '@wordpress/i18n';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -54,6 +55,7 @@ function InserterSearchResults( {
54
55
  sections={ [ createInserterSection( { key: 'search', items } ) ] }
55
56
  onSelect={ handleSelect }
56
57
  listProps={ listProps }
58
+ label={ __( 'Blocks' ) }
57
59
  />
58
60
  );
59
61
  }
@@ -2,21 +2,21 @@
2
2
 
3
3
  exports[`Inserter can add blocks adds new block at the end of post 1`] = `
4
4
  "<!-- wp:spacer -->
5
- <div style=\\"height:100px\\" aria-hidden=\\"true\\" class=\\"wp-block-spacer\\"></div>
5
+ <div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
6
6
  <!-- /wp:spacer -->
7
7
 
8
8
  <!-- wp:heading -->
9
- <h2 class=\\"wp-block-heading\\"></h2>
9
+ <h2 class="wp-block-heading"></h2>
10
10
  <!-- /wp:heading -->"
11
11
  `;
12
12
 
13
13
  exports[`Inserter can add blocks after another block 1`] = `
14
14
  "<!-- wp:spacer -->
15
- <div style=\\"height:100px\\" aria-hidden=\\"true\\" class=\\"wp-block-spacer\\"></div>
15
+ <div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
16
16
  <!-- /wp:spacer -->
17
17
 
18
18
  <!-- wp:heading -->
19
- <h2 class=\\"wp-block-heading\\"></h2>
19
+ <h2 class="wp-block-heading"></h2>
20
20
  <!-- /wp:heading -->
21
21
 
22
22
  <!-- wp:more -->
@@ -30,7 +30,7 @@ exports[`Inserter can add blocks after another block 1`] = `
30
30
 
31
31
  exports[`Inserter can add blocks before another block 1`] = `
32
32
  "<!-- wp:heading -->
33
- <h2 class=\\"wp-block-heading\\"></h2>
33
+ <h2 class="wp-block-heading"></h2>
34
34
  <!-- /wp:heading -->
35
35
 
36
36
  <!-- wp:paragraph -->
@@ -40,11 +40,11 @@ exports[`Inserter can add blocks before another block 1`] = `
40
40
 
41
41
  exports[`Inserter can add blocks creates a new Paragraph block tapping on the empty area below the last block 1`] = `
42
42
  "<!-- wp:spacer -->
43
- <div style=\\"height:100px\\" aria-hidden=\\"true\\" class=\\"wp-block-spacer\\"></div>
43
+ <div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
44
44
  <!-- /wp:spacer -->
45
45
 
46
46
  <!-- wp:heading -->
47
- <h2 class=\\"wp-block-heading\\"></h2>
47
+ <h2 class="wp-block-heading"></h2>
48
48
  <!-- /wp:heading -->
49
49
 
50
50
  <!-- wp:paragraph -->
@@ -54,7 +54,7 @@ exports[`Inserter can add blocks creates a new Paragraph block tapping on the em
54
54
 
55
55
  exports[`Inserter can add blocks inserts between 2 existing blocks 1`] = `
56
56
  "<!-- wp:spacer -->
57
- <div style=\\"height:100px\\" aria-hidden=\\"true\\" class=\\"wp-block-spacer\\"></div>
57
+ <div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
58
58
  <!-- /wp:spacer -->
59
59
 
60
60
  <!-- wp:more -->
@@ -62,17 +62,17 @@ exports[`Inserter can add blocks inserts between 2 existing blocks 1`] = `
62
62
  <!-- /wp:more -->
63
63
 
64
64
  <!-- wp:heading -->
65
- <h2 class=\\"wp-block-heading\\"></h2>
65
+ <h2 class="wp-block-heading"></h2>
66
66
  <!-- /wp:heading -->"
67
67
  `;
68
68
 
69
69
  exports[`Inserter can add blocks inserts block at the end of post when no block is selected 1`] = `
70
70
  "<!-- wp:spacer -->
71
- <div style=\\"height:100px\\" aria-hidden=\\"true\\" class=\\"wp-block-spacer\\"></div>
71
+ <div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
72
72
  <!-- /wp:spacer -->
73
73
 
74
74
  <!-- wp:heading -->
75
- <h2 class=\\"wp-block-heading\\"></h2>
75
+ <h2 class="wp-block-heading"></h2>
76
76
  <!-- /wp:heading -->
77
77
 
78
78
  <!-- wp:more -->
@@ -86,11 +86,11 @@ exports[`Inserter can add blocks to the beginning 1`] = `
86
86
  <!-- /wp:more -->
87
87
 
88
88
  <!-- wp:spacer -->
89
- <div style=\\"height:100px\\" aria-hidden=\\"true\\" class=\\"wp-block-spacer\\"></div>
89
+ <div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
90
90
  <!-- /wp:spacer -->
91
91
 
92
92
  <!-- wp:heading -->
93
- <h2 class=\\"wp-block-heading\\"></h2>
93
+ <h2 class="wp-block-heading"></h2>
94
94
  <!-- /wp:heading -->
95
95
 
96
96
  <!-- wp:paragraph -->
@@ -100,11 +100,11 @@ exports[`Inserter can add blocks to the beginning 1`] = `
100
100
 
101
101
  exports[`Inserter can add blocks to the end 1`] = `
102
102
  "<!-- wp:spacer -->
103
- <div style=\\"height:100px\\" aria-hidden=\\"true\\" class=\\"wp-block-spacer\\"></div>
103
+ <div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
104
104
  <!-- /wp:spacer -->
105
105
 
106
106
  <!-- wp:heading -->
107
- <h2 class=\\"wp-block-heading\\"></h2>
107
+ <h2 class="wp-block-heading"></h2>
108
108
  <!-- /wp:heading -->
109
109
 
110
110
  <!-- wp:paragraph -->
@@ -52,7 +52,6 @@ export default function BlockSupportToolsPanel( { children, group, label } ) {
52
52
  updateBlockAttributes( clientIds, newAttributes, true );
53
53
  },
54
54
  [
55
- cleanEmptyObject,
56
55
  getBlockAttributes,
57
56
  getMultiSelectedBlockClientIds,
58
57
  hasMultiSelection,
@@ -12,6 +12,7 @@ import {
12
12
  } from '@wordpress/components';
13
13
  import warning from '@wordpress/warning';
14
14
  import deprecated from '@wordpress/deprecated';
15
+ import { useEffect } from '@wordpress/element';
15
16
 
16
17
  /**
17
18
  * Internal dependencies
@@ -23,6 +24,7 @@ export default function InspectorControlsFill( {
23
24
  children,
24
25
  group = 'default',
25
26
  __experimentalGroup,
27
+ resetAllFilter,
26
28
  } ) {
27
29
  if ( __experimentalGroup ) {
28
30
  deprecated(
@@ -50,18 +52,40 @@ export default function InspectorControlsFill( {
50
52
  <StyleProvider document={ document }>
51
53
  <Fill>
52
54
  { ( fillProps ) => {
53
- // Children passed to InspectorControlsFill will not have
54
- // access to any React Context whose Provider is part of
55
- // the InspectorControlsSlot tree. So we re-create the
56
- // Provider in this subtree.
57
- const value = ! isEmpty( fillProps ) ? fillProps : null;
58
55
  return (
59
- <ToolsPanelContext.Provider value={ value }>
60
- { children }
61
- </ToolsPanelContext.Provider>
56
+ <ToolsPanelInspectorControl
57
+ fillProps={ fillProps }
58
+ children={ children }
59
+ resetAllFilter={ resetAllFilter }
60
+ />
62
61
  );
63
62
  } }
64
63
  </Fill>
65
64
  </StyleProvider>
66
65
  );
67
66
  }
67
+
68
+ function ToolsPanelInspectorControl( { children, resetAllFilter, fillProps } ) {
69
+ const { registerResetAllFilter, deregisterResetAllFilter } = fillProps;
70
+ useEffect( () => {
71
+ if ( resetAllFilter && registerResetAllFilter ) {
72
+ registerResetAllFilter( resetAllFilter );
73
+ }
74
+ return () => {
75
+ if ( resetAllFilter && deregisterResetAllFilter ) {
76
+ deregisterResetAllFilter( resetAllFilter );
77
+ }
78
+ };
79
+ }, [ resetAllFilter, registerResetAllFilter, deregisterResetAllFilter ] );
80
+
81
+ // Children passed to InspectorControlsFill will not have
82
+ // access to any React Context whose Provider is part of
83
+ // the InspectorControlsSlot tree. So we re-create the
84
+ // Provider in this subtree.
85
+ const value = ! isEmpty( fillProps ) ? fillProps : null;
86
+ return (
87
+ <ToolsPanelContext.Provider value={ value }>
88
+ { children }
89
+ </ToolsPanelContext.Provider>
90
+ );
91
+ }
@@ -6,8 +6,7 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { Button, Spinner, Notice, TextControl } from '@wordpress/components';
10
- import { keyboardReturn } from '@wordpress/icons';
9
+ import { Button, Spinner, Notice } from '@wordpress/components';
11
10
  import { __ } from '@wordpress/i18n';
12
11
  import { useRef, useState, useEffect } from '@wordpress/element';
13
12
  import { focus } from '@wordpress/dom';
@@ -113,6 +112,7 @@ function LinkControl( {
113
112
  settings = DEFAULT_LINK_SETTINGS,
114
113
  onChange = noop,
115
114
  onRemove,
115
+ onCancel,
116
116
  noDirectEntry = false,
117
117
  showSuggestions = true,
118
118
  showInitialSuggestions,
@@ -136,6 +136,8 @@ function LinkControl( {
136
136
  const textInputRef = useRef();
137
137
  const isEndingEditWithFocus = useRef( false );
138
138
 
139
+ const [ settingsOpen, setSettingsOpen ] = useState( false );
140
+
139
141
  const [ internalUrlInputValue, setInternalUrlInputValue ] =
140
142
  useInternalInputValue( value?.url || '' );
141
143
 
@@ -190,6 +192,8 @@ function LinkControl( {
190
192
  isEndingEditWithFocus.current = false;
191
193
  }, [ isEditingLink, isCreatingPage ] );
192
194
 
195
+ const hasLinkValue = value?.url?.trim()?.length > 0;
196
+
193
197
  /**
194
198
  * Cancels editing state and marks that focus may need to be restored after
195
199
  * the next render, if focus was within the wrapper when editing finished.
@@ -199,6 +203,7 @@ function LinkControl( {
199
203
  wrapperNode.current.ownerDocument.activeElement
200
204
  );
201
205
 
206
+ setSettingsOpen( false );
202
207
  setIsEditingLink( false );
203
208
  };
204
209
 
@@ -235,6 +240,29 @@ function LinkControl( {
235
240
  }
236
241
  };
237
242
 
243
+ const resetInternalValues = () => {
244
+ setInternalUrlInputValue( value?.url );
245
+ setInternalTextInputValue( value?.title );
246
+ };
247
+
248
+ const handleCancel = ( event ) => {
249
+ event.preventDefault();
250
+ event.stopPropagation();
251
+
252
+ // Ensure that any unsubmitted input changes are reset.
253
+ resetInternalValues();
254
+
255
+ if ( hasLinkValue ) {
256
+ // If there is a link then exist editing mode and show preview.
257
+ stopEditing();
258
+ } else {
259
+ // If there is no link value, then remove the link entirely.
260
+ onRemove?.();
261
+ }
262
+
263
+ onCancel?.();
264
+ };
265
+
238
266
  const currentUrlInputValue = propInputValue || internalUrlInputValue;
239
267
 
240
268
  const currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;
@@ -242,12 +270,14 @@ function LinkControl( {
242
270
  const shownUnlinkControl =
243
271
  onRemove && value && ! isEditingLink && ! isCreatingPage;
244
272
 
245
- const showSettingsDrawer = !! settings?.length;
273
+ const showSettings = !! settings?.length;
246
274
 
247
275
  // Only show text control once a URL value has been committed
248
276
  // and it isn't just empty whitespace.
249
277
  // See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.
250
- const showTextControl = value?.url?.trim()?.length > 0 && hasTextControl;
278
+ const showTextControl = hasLinkValue && hasTextControl;
279
+
280
+ const isEditing = ( isEditingLink || ! value ) && ! isCreatingPage;
251
281
 
252
282
  return (
253
283
  <div
@@ -261,7 +291,7 @@ function LinkControl( {
261
291
  </div>
262
292
  ) }
263
293
 
264
- { ( isEditingLink || ! value ) && ! isCreatingPage && (
294
+ { isEditing && (
265
295
  <>
266
296
  <div
267
297
  className={ classnames( {
@@ -269,18 +299,6 @@ function LinkControl( {
269
299
  'has-text-control': showTextControl,
270
300
  } ) }
271
301
  >
272
- { showTextControl && (
273
- <TextControl
274
- __nextHasNoMarginBottom
275
- ref={ textInputRef }
276
- className="block-editor-link-control__field block-editor-link-control__text-content"
277
- label="Text"
278
- value={ internalTextInputValue }
279
- onChange={ setInternalTextInputValue }
280
- onKeyDown={ handleSubmitWithEnter }
281
- />
282
- ) }
283
-
284
302
  <LinkControlSearchInput
285
303
  currentLink={ value }
286
304
  className="block-editor-link-control__field block-editor-link-control__search-input"
@@ -299,17 +317,7 @@ function LinkControl( {
299
317
  createSuggestionButtonText
300
318
  }
301
319
  useLabel={ showTextControl }
302
- >
303
- <div className="block-editor-link-control__search-actions">
304
- <Button
305
- onClick={ handleSubmit }
306
- label={ __( 'Submit' ) }
307
- icon={ keyboardReturn }
308
- className="block-editor-link-control__search-submit"
309
- disabled={ currentInputIsEmpty } // Disallow submitting empty values.
310
- />
311
- </div>
312
- </LinkControlSearchInput>
320
+ />
313
321
  </div>
314
322
  { errorMessage && (
315
323
  <Notice
@@ -334,15 +342,42 @@ function LinkControl( {
334
342
  />
335
343
  ) }
336
344
 
337
- { showSettingsDrawer && (
345
+ { isEditing && (
338
346
  <div className="block-editor-link-control__tools">
339
- <LinkControlSettingsDrawer
340
- value={ value }
341
- settings={ settings }
342
- onChange={ onChange }
343
- />
347
+ { ( showSettings || showTextControl ) && (
348
+ <LinkControlSettingsDrawer
349
+ settingsOpen={ settingsOpen }
350
+ setSettingsOpen={ setSettingsOpen }
351
+ showTextControl={ showTextControl }
352
+ showSettings={ showSettings }
353
+ textInputRef={ textInputRef }
354
+ internalTextInputValue={ internalTextInputValue }
355
+ setInternalTextInputValue={
356
+ setInternalTextInputValue
357
+ }
358
+ handleSubmitWithEnter={ handleSubmitWithEnter }
359
+ value={ value }
360
+ settings={ settings }
361
+ onChange={ onChange }
362
+ />
363
+ ) }
364
+
365
+ <div className="block-editor-link-control__search-actions">
366
+ <Button
367
+ variant="primary"
368
+ onClick={ handleSubmit }
369
+ className="xblock-editor-link-control__search-submit"
370
+ disabled={ currentInputIsEmpty } // Disallow submitting empty values.
371
+ >
372
+ { __( 'Apply' ) }
373
+ </Button>
374
+ <Button variant="tertiary" onClick={ handleCancel }>
375
+ { __( 'Cancel' ) }
376
+ </Button>
377
+ </div>
344
378
  </div>
345
379
  ) }
380
+
346
381
  { renderControlBottom && renderControlBottom() }
347
382
  </div>
348
383
  );
@@ -1,41 +1,97 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
+ import {
5
+ Button,
6
+ TextControl,
7
+ __unstableMotion as motion,
8
+ __unstableAnimatePresence as AnimatePresence,
9
+ } from '@wordpress/components';
10
+ import { settings as settingsIcon } from '@wordpress/icons';
11
+ import { useReducedMotion, useInstanceId } from '@wordpress/compose';
4
12
  import { __ } from '@wordpress/i18n';
5
- import { ToggleControl, VisuallyHidden } from '@wordpress/components';
13
+ import { Fragment } from '@wordpress/element';
6
14
 
7
- const noop = () => {};
15
+ /**
16
+ * Internal dependencies
17
+ */
18
+ import Settings from './settings';
8
19
 
9
- const LinkControlSettingsDrawer = ( { value, onChange = noop, settings } ) => {
10
- if ( ! settings || ! settings.length ) {
11
- return null;
12
- }
20
+ function LinkSettingsDrawer( {
21
+ settingsOpen,
22
+ setSettingsOpen,
23
+ showTextControl,
24
+ showSettings,
25
+ textInputRef,
26
+ internalTextInputValue,
27
+ setInternalTextInputValue,
28
+ handleSubmitWithEnter,
29
+ value,
30
+ settings,
31
+ onChange,
32
+ } ) {
33
+ const prefersReducedMotion = useReducedMotion();
34
+ const MaybeAnimatePresence = prefersReducedMotion
35
+ ? Fragment
36
+ : AnimatePresence;
37
+ const MaybeMotionDiv = prefersReducedMotion ? 'div' : motion.div;
13
38
 
14
- const handleSettingChange = ( setting ) => ( newValue ) => {
15
- onChange( {
16
- ...value,
17
- [ setting.id ]: newValue,
18
- } );
19
- };
39
+ const id = useInstanceId( LinkSettingsDrawer );
20
40
 
21
- const theSettings = settings.map( ( setting ) => (
22
- <ToggleControl
23
- className="block-editor-link-control__setting"
24
- key={ setting.id }
25
- label={ setting.title }
26
- onChange={ handleSettingChange( setting ) }
27
- checked={ value ? !! value[ setting.id ] : false }
28
- />
29
- ) );
41
+ const settingsDrawerId = `link-control-settings-drawer-${ id }`;
30
42
 
31
43
  return (
32
- <fieldset className="block-editor-link-control__settings">
33
- <VisuallyHidden as="legend">
34
- { __( 'Currently selected link settings' ) }
35
- </VisuallyHidden>
36
- { theSettings }
37
- </fieldset>
44
+ <>
45
+ <Button
46
+ className="block-editor-link-control__drawer-toggle"
47
+ aria-expanded={ settingsOpen }
48
+ onClick={ () => setSettingsOpen( ! settingsOpen ) }
49
+ icon={ settingsIcon }
50
+ label={ __( 'Link Settings' ) }
51
+ aria-controls={ settingsDrawerId }
52
+ />
53
+ <MaybeAnimatePresence>
54
+ { settingsOpen && (
55
+ <MaybeMotionDiv
56
+ className="block-editor-link-control__drawer"
57
+ hidden={ ! settingsOpen }
58
+ id={ settingsDrawerId }
59
+ initial="collapsed"
60
+ animate="open"
61
+ exit="collapsed"
62
+ variants={ {
63
+ open: { opacity: 1, height: 'auto' },
64
+ collapsed: { opacity: 0, height: 0 },
65
+ } }
66
+ transition={ {
67
+ duration: 0.1,
68
+ } }
69
+ >
70
+ <div className="block-editor-link-control__drawer-inner">
71
+ { showTextControl && (
72
+ <TextControl
73
+ __nextHasNoMarginBottom
74
+ ref={ textInputRef }
75
+ className="block-editor-link-control__setting block-editor-link-control__text-content"
76
+ label="Text"
77
+ value={ internalTextInputValue }
78
+ onChange={ setInternalTextInputValue }
79
+ onKeyDown={ handleSubmitWithEnter }
80
+ />
81
+ ) }
82
+ { showSettings && (
83
+ <Settings
84
+ value={ value }
85
+ settings={ settings }
86
+ onChange={ onChange }
87
+ />
88
+ ) }
89
+ </div>
90
+ </MaybeMotionDiv>
91
+ ) }
92
+ </MaybeAnimatePresence>
93
+ </>
38
94
  );
39
- };
95
+ }
40
96
 
41
- export default LinkControlSettingsDrawer;
97
+ export default LinkSettingsDrawer;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { ToggleControl, VisuallyHidden } from '@wordpress/components';
6
+
7
+ const noop = () => {};
8
+
9
+ const LinkControlSettings = ( { value, onChange = noop, settings } ) => {
10
+ if ( ! settings || ! settings.length ) {
11
+ return null;
12
+ }
13
+
14
+ const handleSettingChange = ( setting ) => ( newValue ) => {
15
+ onChange( {
16
+ ...value,
17
+ [ setting.id ]: newValue,
18
+ } );
19
+ };
20
+
21
+ const theSettings = settings.map( ( setting ) => (
22
+ <ToggleControl
23
+ __nextHasNoMarginBottom
24
+ className="block-editor-link-control__setting"
25
+ key={ setting.id }
26
+ label={ setting.title }
27
+ onChange={ handleSettingChange( setting ) }
28
+ checked={ value ? !! value[ setting.id ] : false }
29
+ />
30
+ ) );
31
+
32
+ return (
33
+ <fieldset className="block-editor-link-control__settings">
34
+ <VisuallyHidden as="legend">
35
+ { __( 'Currently selected link settings' ) }
36
+ </VisuallyHidden>
37
+ { theSettings }
38
+ </fieldset>
39
+ );
40
+ };
41
+
42
+ export default LinkControlSettings;