@wordpress/block-editor 12.9.1-next.5a1d1283.0 → 12.10.1

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 (448) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +33 -3
  3. package/build/components/block-canvas/index.js +107 -0
  4. package/build/components/block-canvas/index.js.map +1 -0
  5. package/build/components/block-inspector/index.js +4 -1
  6. package/build/components/block-inspector/index.js.map +1 -1
  7. package/build/components/block-patterns-list/index.js +28 -8
  8. package/build/components/block-patterns-list/index.js.map +1 -1
  9. package/build/components/block-patterns-paging/index.js +68 -0
  10. package/build/components/block-patterns-paging/index.js.map +1 -0
  11. package/build/components/block-settings-menu/block-settings-dropdown.js +28 -0
  12. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  13. package/build/components/block-settings-menu-controls/index.js +4 -7
  14. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  15. package/build/components/block-styles/index.js +1 -0
  16. package/build/components/block-styles/index.js.map +1 -1
  17. package/build/components/block-toolbar/block-toolbar-menu.native.js +3 -7
  18. package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  19. package/build/components/block-tools/block-contextual-toolbar.js +18 -7
  20. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  21. package/build/components/block-tools/block-selection-button.js +5 -1
  22. package/build/components/block-tools/block-selection-button.js.map +1 -1
  23. package/build/components/border-radius-control/input-controls.js +1 -1
  24. package/build/components/border-radius-control/input-controls.js.map +1 -1
  25. package/build/components/border-radius-control/linked-button.js +2 -4
  26. package/build/components/border-radius-control/linked-button.js.map +1 -1
  27. package/build/components/colors/with-colors.js.map +1 -1
  28. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -21
  29. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  30. package/build/components/default-block-appender/index.native.js +20 -1
  31. package/build/components/default-block-appender/index.native.js.map +1 -1
  32. package/build/components/duotone/utils.js +68 -0
  33. package/build/components/duotone/utils.js.map +1 -1
  34. package/build/components/editor-styles/index.js +28 -9
  35. package/build/components/editor-styles/index.js.map +1 -1
  36. package/build/components/global-styles/hooks.js +2 -101
  37. package/build/components/global-styles/hooks.js.map +1 -1
  38. package/build/components/global-styles/image-settings-panel.js +61 -0
  39. package/build/components/global-styles/image-settings-panel.js.map +1 -0
  40. package/build/components/global-styles/index.js +11 -17
  41. package/build/components/global-styles/index.js.map +1 -1
  42. package/build/components/global-styles/use-global-styles-output.js +19 -15
  43. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  44. package/build/components/global-styles/utils.js +1 -1
  45. package/build/components/global-styles/utils.js.map +1 -1
  46. package/build/components/iframe/index.js +67 -33
  47. package/build/components/iframe/index.js.map +1 -1
  48. package/build/components/image-editor/use-save-image.js +2 -5
  49. package/build/components/image-editor/use-save-image.js.map +1 -1
  50. package/build/components/image-editor/use-transform-image.js +9 -9
  51. package/build/components/image-editor/use-transform-image.js.map +1 -1
  52. package/build/components/index.js +8 -12
  53. package/build/components/index.js.map +1 -1
  54. package/build/components/index.native.js +6 -5
  55. package/build/components/index.native.js.map +1 -1
  56. package/build/components/inner-blocks/use-nested-settings-update.js +13 -7
  57. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  58. package/build/components/inserter/block-patterns-explorer/explorer.js +12 -6
  59. package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
  60. package/build/components/inserter/block-patterns-explorer/patterns-list.js +45 -22
  61. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
  62. package/build/components/inserter/block-patterns-explorer/sidebar.js +9 -9
  63. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  64. package/build/components/inserter/block-patterns-filter.js +137 -0
  65. package/build/components/inserter/block-patterns-filter.js.map +1 -0
  66. package/build/components/inserter/block-patterns-tab.js +128 -42
  67. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  68. package/build/components/inserter/hooks/use-patterns-paging.js +61 -0
  69. package/build/components/inserter/hooks/use-patterns-paging.js.map +1 -0
  70. package/build/components/inserter/hooks/use-patterns-state.js +21 -10
  71. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  72. package/build/components/inserter/menu.js +13 -11
  73. package/build/components/inserter/menu.js.map +1 -1
  74. package/build/components/inserter/search-results.js +4 -3
  75. package/build/components/inserter/search-results.js.map +1 -1
  76. package/build/components/inserter/tabs.js +1 -12
  77. package/build/components/inserter/tabs.js.map +1 -1
  78. package/build/components/inspector-controls/block-support-slot-container.js +12 -1
  79. package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
  80. package/build/components/inspector-controls/fill.js +24 -13
  81. package/build/components/inspector-controls/fill.js.map +1 -1
  82. package/build/components/inspector-controls/groups.js +5 -3
  83. package/build/components/inspector-controls/groups.js.map +1 -1
  84. package/build/components/inspector-controls/slot.js +13 -0
  85. package/build/components/inspector-controls/slot.js.map +1 -1
  86. package/build/components/inspector-controls-tabs/styles-tab.js +3 -0
  87. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  88. package/build/components/link-control/index.js +12 -2
  89. package/build/components/link-control/index.js.map +1 -1
  90. package/build/components/list-view/block-select-button.js +1 -3
  91. package/build/components/list-view/block-select-button.js.map +1 -1
  92. package/build/components/list-view/block.js +13 -1
  93. package/build/components/list-view/block.js.map +1 -1
  94. package/build/components/list-view/use-block-selection.js +29 -24
  95. package/build/components/list-view/use-block-selection.js.map +1 -1
  96. package/build/components/media-placeholder/index.js +2 -2
  97. package/build/components/media-placeholder/index.js.map +1 -1
  98. package/build/components/media-placeholder/index.native.js +11 -11
  99. package/build/components/media-placeholder/index.native.js.map +1 -1
  100. package/build/components/media-replace-flow/index.js +2 -3
  101. package/build/components/media-replace-flow/index.js.map +1 -1
  102. package/build/components/media-upload/constants.js +30 -0
  103. package/build/components/media-upload/constants.js.map +1 -0
  104. package/build/components/media-upload/index.native.js +63 -53
  105. package/build/components/media-upload/index.native.js.map +1 -1
  106. package/build/components/preview-options/index.js +1 -1
  107. package/build/components/preview-options/index.js.map +1 -1
  108. package/build/components/rich-text/index.js +34 -35
  109. package/build/components/rich-text/index.js.map +1 -1
  110. package/build/components/rich-text/index.native.js +14 -32
  111. package/build/components/rich-text/index.native.js.map +1 -1
  112. package/build/components/rich-text/multiline.js +95 -0
  113. package/build/components/rich-text/multiline.js.map +1 -0
  114. package/build/components/rich-text/split-value.js +10 -16
  115. package/build/components/rich-text/split-value.js.map +1 -1
  116. package/build/components/rich-text/use-enter.js +31 -40
  117. package/build/components/rich-text/use-enter.js.map +1 -1
  118. package/build/components/rich-text/use-paste-handler.js +18 -33
  119. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  120. package/build/components/spacing-sizes-control/utils.js +1 -1
  121. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  122. package/build/components/use-block-commands/index.js +30 -18
  123. package/build/components/use-block-commands/index.js.map +1 -1
  124. package/build/components/use-block-display-information/index.js +5 -2
  125. package/build/components/use-block-display-information/index.js.map +1 -1
  126. package/build/hooks/background.js +263 -0
  127. package/build/hooks/background.js.map +1 -0
  128. package/build/hooks/block-hooks.js +188 -0
  129. package/build/hooks/block-hooks.js.map +1 -0
  130. package/build/hooks/block-rename-ui.js +161 -0
  131. package/build/hooks/block-rename-ui.js.map +1 -0
  132. package/build/hooks/duotone.js +29 -42
  133. package/build/hooks/duotone.js.map +1 -1
  134. package/build/hooks/index.js +2 -2
  135. package/build/hooks/index.js.map +1 -1
  136. package/build/hooks/layout.js +31 -14
  137. package/build/hooks/layout.js.map +1 -1
  138. package/build/hooks/position.js +4 -2
  139. package/build/hooks/position.js.map +1 -1
  140. package/build/hooks/style.js +10 -3
  141. package/build/hooks/style.js.map +1 -1
  142. package/build/private-apis.js +2 -0
  143. package/build/private-apis.js.map +1 -1
  144. package/build/store/actions.js +33 -10
  145. package/build/store/actions.js.map +1 -1
  146. package/build/store/private-actions.js +42 -8
  147. package/build/store/private-actions.js.map +1 -1
  148. package/build/store/private-selectors.js +25 -3
  149. package/build/store/private-selectors.js.map +1 -1
  150. package/build/store/reducer.js +43 -1
  151. package/build/store/reducer.js.map +1 -1
  152. package/build/store/selectors.js +84 -23
  153. package/build/store/selectors.js.map +1 -1
  154. package/build/store/utils.js +0 -4
  155. package/build/store/utils.js.map +1 -1
  156. package/build-module/components/block-canvas/index.js +97 -0
  157. package/build-module/components/block-canvas/index.js.map +1 -0
  158. package/build-module/components/block-inspector/index.js +4 -1
  159. package/build-module/components/block-inspector/index.js.map +1 -1
  160. package/build-module/components/block-patterns-list/index.js +30 -10
  161. package/build-module/components/block-patterns-list/index.js.map +1 -1
  162. package/build-module/components/block-patterns-paging/index.js +61 -0
  163. package/build-module/components/block-patterns-paging/index.js.map +1 -0
  164. package/build-module/components/block-settings-menu/block-settings-dropdown.js +28 -0
  165. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  166. package/build-module/components/block-settings-menu-controls/index.js +4 -7
  167. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  168. package/build-module/components/block-styles/index.js +1 -0
  169. package/build-module/components/block-styles/index.js.map +1 -1
  170. package/build-module/components/block-toolbar/block-toolbar-menu.native.js +3 -7
  171. package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
  172. package/build-module/components/block-tools/block-contextual-toolbar.js +18 -7
  173. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  174. package/build-module/components/block-tools/block-selection-button.js +5 -1
  175. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  176. package/build-module/components/border-radius-control/input-controls.js +1 -1
  177. package/build-module/components/border-radius-control/input-controls.js.map +1 -1
  178. package/build-module/components/border-radius-control/linked-button.js +2 -4
  179. package/build-module/components/border-radius-control/linked-button.js.map +1 -1
  180. package/build-module/components/colors/with-colors.js.map +1 -1
  181. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -21
  182. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  183. package/build-module/components/default-block-appender/index.native.js +20 -1
  184. package/build-module/components/default-block-appender/index.native.js.map +1 -1
  185. package/build-module/components/duotone/utils.js +65 -0
  186. package/build-module/components/duotone/utils.js.map +1 -1
  187. package/build-module/components/editor-styles/index.js +28 -9
  188. package/build-module/components/editor-styles/index.js.map +1 -1
  189. package/build-module/components/global-styles/hooks.js +3 -100
  190. package/build-module/components/global-styles/hooks.js.map +1 -1
  191. package/build-module/components/global-styles/image-settings-panel.js +53 -0
  192. package/build-module/components/global-styles/image-settings-panel.js.map +1 -0
  193. package/build-module/components/global-styles/index.js +2 -2
  194. package/build-module/components/global-styles/index.js.map +1 -1
  195. package/build-module/components/global-styles/use-global-styles-output.js +18 -16
  196. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  197. package/build-module/components/global-styles/utils.js +1 -1
  198. package/build-module/components/global-styles/utils.js.map +1 -1
  199. package/build-module/components/iframe/index.js +66 -33
  200. package/build-module/components/iframe/index.js.map +1 -1
  201. package/build-module/components/image-editor/use-save-image.js +2 -5
  202. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  203. package/build-module/components/image-editor/use-transform-image.js +9 -9
  204. package/build-module/components/image-editor/use-transform-image.js.map +1 -1
  205. package/build-module/components/index.js +1 -1
  206. package/build-module/components/index.js.map +1 -1
  207. package/build-module/components/index.native.js +2 -1
  208. package/build-module/components/index.native.js.map +1 -1
  209. package/build-module/components/inner-blocks/use-nested-settings-update.js +14 -8
  210. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  211. package/build-module/components/inserter/block-patterns-explorer/explorer.js +12 -6
  212. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
  213. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +47 -24
  214. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
  215. package/build-module/components/inserter/block-patterns-explorer/sidebar.js +9 -9
  216. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  217. package/build-module/components/inserter/block-patterns-filter.js +128 -0
  218. package/build-module/components/inserter/block-patterns-filter.js.map +1 -0
  219. package/build-module/components/inserter/block-patterns-tab.js +125 -44
  220. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  221. package/build-module/components/inserter/hooks/use-patterns-paging.js +54 -0
  222. package/build-module/components/inserter/hooks/use-patterns-paging.js.map +1 -0
  223. package/build-module/components/inserter/hooks/use-patterns-state.js +22 -10
  224. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  225. package/build-module/components/inserter/menu.js +13 -11
  226. package/build-module/components/inserter/menu.js.map +1 -1
  227. package/build-module/components/inserter/search-results.js +4 -3
  228. package/build-module/components/inserter/search-results.js.map +1 -1
  229. package/build-module/components/inserter/tabs.js +1 -12
  230. package/build-module/components/inserter/tabs.js.map +1 -1
  231. package/build-module/components/inspector-controls/block-support-slot-container.js +13 -2
  232. package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
  233. package/build-module/components/inspector-controls/fill.js +25 -14
  234. package/build-module/components/inspector-controls/fill.js.map +1 -1
  235. package/build-module/components/inspector-controls/groups.js +5 -3
  236. package/build-module/components/inspector-controls/groups.js.map +1 -1
  237. package/build-module/components/inspector-controls/slot.js +15 -1
  238. package/build-module/components/inspector-controls/slot.js.map +1 -1
  239. package/build-module/components/inspector-controls-tabs/styles-tab.js +3 -0
  240. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  241. package/build-module/components/link-control/index.js +12 -2
  242. package/build-module/components/link-control/index.js.map +1 -1
  243. package/build-module/components/list-view/block-select-button.js +1 -3
  244. package/build-module/components/list-view/block-select-button.js.map +1 -1
  245. package/build-module/components/list-view/block.js +13 -1
  246. package/build-module/components/list-view/block.js.map +1 -1
  247. package/build-module/components/list-view/use-block-selection.js +30 -25
  248. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  249. package/build-module/components/media-placeholder/index.js +2 -2
  250. package/build-module/components/media-placeholder/index.js.map +1 -1
  251. package/build-module/components/media-placeholder/index.native.js +7 -7
  252. package/build-module/components/media-placeholder/index.native.js.map +1 -1
  253. package/build-module/components/media-replace-flow/index.js +2 -3
  254. package/build-module/components/media-replace-flow/index.js.map +1 -1
  255. package/build-module/components/media-upload/constants.js +14 -0
  256. package/build-module/components/media-upload/constants.js.map +1 -0
  257. package/build-module/components/media-upload/index.native.js +53 -34
  258. package/build-module/components/media-upload/index.native.js.map +1 -1
  259. package/build-module/components/preview-options/index.js +1 -1
  260. package/build-module/components/preview-options/index.js.map +1 -1
  261. package/build-module/components/rich-text/index.js +35 -37
  262. package/build-module/components/rich-text/index.js.map +1 -1
  263. package/build-module/components/rich-text/index.native.js +15 -33
  264. package/build-module/components/rich-text/index.native.js.map +1 -1
  265. package/build-module/components/rich-text/multiline.js +87 -0
  266. package/build-module/components/rich-text/multiline.js.map +1 -0
  267. package/build-module/components/rich-text/split-value.js +10 -16
  268. package/build-module/components/rich-text/split-value.js.map +1 -1
  269. package/build-module/components/rich-text/use-enter.js +33 -42
  270. package/build-module/components/rich-text/use-enter.js.map +1 -1
  271. package/build-module/components/rich-text/use-paste-handler.js +19 -34
  272. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  273. package/build-module/components/spacing-sizes-control/utils.js +2 -2
  274. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  275. package/build-module/components/use-block-commands/index.js +28 -16
  276. package/build-module/components/use-block-commands/index.js.map +1 -1
  277. package/build-module/components/use-block-display-information/index.js +5 -2
  278. package/build-module/components/use-block-display-information/index.js.map +1 -1
  279. package/build-module/hooks/background.js +249 -0
  280. package/build-module/hooks/background.js.map +1 -0
  281. package/build-module/hooks/block-hooks.js +181 -0
  282. package/build-module/hooks/block-hooks.js.map +1 -0
  283. package/build-module/hooks/block-rename-ui.js +154 -0
  284. package/build-module/hooks/block-rename-ui.js.map +1 -0
  285. package/build-module/hooks/duotone.js +26 -39
  286. package/build-module/hooks/duotone.js.map +1 -1
  287. package/build-module/hooks/index.js +2 -2
  288. package/build-module/hooks/index.js.map +1 -1
  289. package/build-module/hooks/layout.js +33 -16
  290. package/build-module/hooks/layout.js.map +1 -1
  291. package/build-module/hooks/position.js +4 -2
  292. package/build-module/hooks/position.js.map +1 -1
  293. package/build-module/hooks/style.js +10 -3
  294. package/build-module/hooks/style.js.map +1 -1
  295. package/build-module/private-apis.js +2 -0
  296. package/build-module/private-apis.js.map +1 -1
  297. package/build-module/store/actions.js +33 -10
  298. package/build-module/store/actions.js.map +1 -1
  299. package/build-module/store/private-actions.js +39 -8
  300. package/build-module/store/private-actions.js.map +1 -1
  301. package/build-module/store/private-selectors.js +23 -3
  302. package/build-module/store/private-selectors.js.map +1 -1
  303. package/build-module/store/reducer.js +41 -1
  304. package/build-module/store/reducer.js.map +1 -1
  305. package/build-module/store/selectors.js +78 -22
  306. package/build-module/store/selectors.js.map +1 -1
  307. package/build-module/store/utils.js +0 -4
  308. package/build-module/store/utils.js.map +1 -1
  309. package/build-style/content-rtl.css +0 -1
  310. package/build-style/content.css +0 -1
  311. package/build-style/style-rtl.css +201 -131
  312. package/build-style/style.css +201 -131
  313. package/package.json +32 -32
  314. package/src/components/block-canvas/index.js +108 -0
  315. package/src/components/block-inspector/index.js +5 -1
  316. package/src/components/block-list/content.scss +0 -1
  317. package/src/components/block-patterns-list/index.js +53 -19
  318. package/src/components/block-patterns-list/style.scss +26 -9
  319. package/src/components/block-patterns-paging/index.js +92 -0
  320. package/src/components/block-patterns-paging/style.scss +45 -0
  321. package/src/components/block-settings-menu/block-settings-dropdown.js +44 -0
  322. package/src/components/block-settings-menu-controls/index.js +4 -9
  323. package/src/components/block-styles/index.js +1 -0
  324. package/src/components/block-styles/style.scss +3 -3
  325. package/src/components/block-toolbar/block-toolbar-menu.native.js +1 -6
  326. package/src/components/block-tools/block-contextual-toolbar.js +16 -5
  327. package/src/components/block-tools/block-selection-button.js +9 -1
  328. package/src/components/block-tools/style.scss +0 -98
  329. package/src/components/border-radius-control/input-controls.js +1 -1
  330. package/src/components/border-radius-control/linked-button.js +8 -11
  331. package/src/components/color-palette/test/__snapshots__/control.js.snap +34 -21
  332. package/src/components/colors/with-colors.js +3 -2
  333. package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -35
  334. package/src/components/default-block-appender/index.native.js +26 -3
  335. package/src/components/duotone/utils.js +65 -0
  336. package/src/components/editor-styles/index.js +32 -23
  337. package/src/components/global-styles/hooks.js +4 -112
  338. package/src/components/global-styles/image-settings-panel.js +71 -0
  339. package/src/components/global-styles/index.js +4 -3
  340. package/src/components/global-styles/use-global-styles-output.js +25 -16
  341. package/src/components/global-styles/utils.js +1 -2
  342. package/src/components/iframe/index.js +72 -33
  343. package/src/components/image-editor/use-save-image.js +2 -9
  344. package/src/components/image-editor/use-transform-image.js +9 -9
  345. package/src/components/index.js +1 -1
  346. package/src/components/index.native.js +2 -2
  347. package/src/components/inner-blocks/use-nested-settings-update.js +15 -10
  348. package/src/components/inserter/block-patterns-explorer/explorer.js +17 -5
  349. package/src/components/inserter/block-patterns-explorer/patterns-list.js +68 -43
  350. package/src/components/inserter/block-patterns-explorer/sidebar.js +8 -8
  351. package/src/components/inserter/block-patterns-filter.js +183 -0
  352. package/src/components/inserter/block-patterns-tab.js +217 -58
  353. package/src/components/inserter/hooks/use-patterns-paging.js +76 -0
  354. package/src/components/inserter/hooks/use-patterns-state.js +27 -16
  355. package/src/components/inserter/menu.js +15 -17
  356. package/src/components/inserter/search-results.js +6 -4
  357. package/src/components/inserter/style.scss +36 -7
  358. package/src/components/inserter/tabs.js +2 -12
  359. package/src/components/inserter/test/index.native.js +8 -12
  360. package/src/components/inspector-controls/block-support-slot-container.js +19 -3
  361. package/src/components/inspector-controls/fill.js +28 -14
  362. package/src/components/inspector-controls/groups.js +6 -2
  363. package/src/components/inspector-controls/slot.js +28 -3
  364. package/src/components/inspector-controls-tabs/styles-tab.js +4 -0
  365. package/src/components/link-control/index.js +13 -0
  366. package/src/components/link-control/style.scss +23 -2
  367. package/src/components/link-control/test/index.js +88 -6
  368. package/src/components/list-view/block-select-button.js +1 -3
  369. package/src/components/list-view/block.js +19 -1
  370. package/src/components/list-view/style.scss +1 -2
  371. package/src/components/list-view/use-block-selection.js +38 -32
  372. package/src/components/media-placeholder/README.md +2 -2
  373. package/src/components/media-placeholder/index.js +2 -2
  374. package/src/components/media-placeholder/index.native.js +11 -12
  375. package/src/components/media-replace-flow/index.js +2 -2
  376. package/src/components/media-replace-flow/test/index.js +5 -23
  377. package/src/components/media-upload/README.md +3 -2
  378. package/src/components/media-upload/constants.js +15 -0
  379. package/src/components/media-upload/index.native.js +66 -40
  380. package/src/components/media-upload/style.native.scss +4 -0
  381. package/src/components/media-upload/test/index.native.js +2 -2
  382. package/src/components/preview-options/README.md +7 -0
  383. package/src/components/preview-options/index.js +1 -1
  384. package/src/components/rich-text/index.js +48 -44
  385. package/src/components/rich-text/index.native.js +14 -42
  386. package/src/components/rich-text/multiline.js +121 -0
  387. package/src/components/rich-text/split-value.js +10 -35
  388. package/src/components/rich-text/use-enter.js +32 -42
  389. package/src/components/rich-text/use-paste-handler.js +16 -40
  390. package/src/components/spacing-sizes-control/style.scss +5 -7
  391. package/src/components/spacing-sizes-control/utils.js +1 -2
  392. package/src/components/use-block-commands/index.js +28 -20
  393. package/src/components/use-block-display-information/index.js +3 -0
  394. package/src/hooks/background.js +299 -0
  395. package/src/hooks/background.scss +75 -0
  396. package/src/hooks/block-hooks.js +257 -0
  397. package/src/hooks/block-hooks.scss +16 -0
  398. package/src/hooks/block-rename-ui.js +231 -0
  399. package/src/hooks/block-rename-ui.scss +3 -0
  400. package/src/hooks/duotone.js +42 -43
  401. package/src/hooks/index.js +2 -2
  402. package/src/hooks/layout.js +31 -33
  403. package/src/hooks/position.js +4 -3
  404. package/src/hooks/style.js +11 -2
  405. package/src/hooks/test/align.native.js +4 -3
  406. package/src/private-apis.js +2 -0
  407. package/src/store/actions.js +52 -10
  408. package/src/store/private-actions.js +37 -6
  409. package/src/store/private-selectors.js +28 -3
  410. package/src/store/reducer.js +38 -0
  411. package/src/store/selectors.js +107 -26
  412. package/src/store/test/actions.js +19 -8
  413. package/src/store/test/private-actions.js +17 -0
  414. package/src/store/test/reducer.js +25 -0
  415. package/src/store/test/selectors.js +130 -123
  416. package/src/store/utils.js +3 -10
  417. package/src/style.scss +4 -0
  418. package/build/components/duotone/components.js +0 -135
  419. package/build/components/duotone/components.js.map +0 -1
  420. package/build/components/duotone/index.js +0 -38
  421. package/build/components/duotone/index.js.map +0 -1
  422. package/build/components/global-styles/behaviors-panel.js +0 -64
  423. package/build/components/global-styles/behaviors-panel.js.map +0 -1
  424. package/build/components/inserter/reusable-blocks-tab.js +0 -85
  425. package/build/components/inserter/reusable-blocks-tab.js.map +0 -1
  426. package/build/hooks/auto-inserting-blocks.js +0 -174
  427. package/build/hooks/auto-inserting-blocks.js.map +0 -1
  428. package/build/hooks/behaviors.js +0 -173
  429. package/build/hooks/behaviors.js.map +0 -1
  430. package/build-module/components/duotone/components.js +0 -126
  431. package/build-module/components/duotone/components.js.map +0 -1
  432. package/build-module/components/duotone/index.js +0 -3
  433. package/build-module/components/duotone/index.js.map +0 -1
  434. package/build-module/components/global-styles/behaviors-panel.js +0 -57
  435. package/build-module/components/global-styles/behaviors-panel.js.map +0 -1
  436. package/build-module/components/inserter/reusable-blocks-tab.js +0 -76
  437. package/build-module/components/inserter/reusable-blocks-tab.js.map +0 -1
  438. package/build-module/hooks/auto-inserting-blocks.js +0 -167
  439. package/build-module/hooks/auto-inserting-blocks.js.map +0 -1
  440. package/build-module/hooks/behaviors.js +0 -166
  441. package/build-module/hooks/behaviors.js.map +0 -1
  442. package/src/components/duotone/components.js +0 -133
  443. package/src/components/duotone/index.js +0 -7
  444. package/src/components/global-styles/behaviors-panel.js +0 -71
  445. package/src/components/inserter/reusable-blocks-tab.js +0 -84
  446. package/src/components/inserter/test/reusable-blocks-tab.js +0 -73
  447. package/src/hooks/auto-inserting-blocks.js +0 -232
  448. package/src/hooks/behaviors.js +0 -206
@@ -86,9 +86,15 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
86
86
  const isFullscreen =
87
87
  document.body.classList.contains( 'is-fullscreen-mode' );
88
88
 
89
+ /**
90
+ * The following code is a workaround to fix the width of the toolbar
91
+ * it should be removed when the toolbar will be rendered inline
92
+ * FIXME: remove this layout effect when the toolbar is no longer
93
+ * absolutely positioned
94
+ */
89
95
  useLayoutEffect( () => {
90
96
  // don't do anything if not fixed toolbar
91
- if ( ! isFixed || ! blockType ) {
97
+ if ( ! isFixed ) {
92
98
  return;
93
99
  }
94
100
 
@@ -100,6 +106,11 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
100
106
  return;
101
107
  }
102
108
 
109
+ if ( ! blockType ) {
110
+ blockToolbar.style.width = 'initial';
111
+ return;
112
+ }
113
+
103
114
  if ( ! isLargerThanTabletViewport ) {
104
115
  // set the width of the toolbar to auto
105
116
  blockToolbar.style = {};
@@ -112,11 +123,10 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
112
123
  return;
113
124
  }
114
125
 
115
- // get the width of the pinned items in the post editor
126
+ // get the width of the pinned items in the post editor or widget editor
116
127
  const pinnedItems = document.querySelector(
117
- '.edit-post-header__settings'
128
+ '.edit-post-header__settings, .edit-widgets-header__actions'
118
129
  );
119
-
120
130
  // get the width of the left header in the site editor
121
131
  const leftHeader = document.querySelector(
122
132
  '.edit-site-header-edit-mode__end'
@@ -132,7 +142,7 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
132
142
 
133
143
  const marginLeft = parseFloat( computedToolbarStyle.marginLeft );
134
144
  const pinnedItemsWidth = computedPinnedItemsStyle
135
- ? parseFloat( computedPinnedItemsStyle.width ) + 10 // 10 is the pinned items padding
145
+ ? parseFloat( computedPinnedItemsStyle.width )
136
146
  : 0;
137
147
  const leftHeaderWidth = computedLeftHeaderStyle
138
148
  ? parseFloat( computedLeftHeaderStyle.width )
@@ -143,6 +153,7 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
143
153
  leftHeaderWidth +
144
154
  pinnedItemsWidth +
145
155
  marginLeft +
156
+ ( pinnedItems || leftHeader ? 2 : 0 ) + // Prevents button focus border from being cut off
146
157
  ( isFullscreen ? 0 : 160 ) // the width of the admin sidebar expanded
147
158
  }px)`;
148
159
  }, [
@@ -165,7 +165,7 @@ function BlockSelectionButton( { clientId, rootClientId } ) {
165
165
  selectedBlockClientId;
166
166
  } else if ( navigateIn ) {
167
167
  focusedBlockUid =
168
- getClientIdsOfDescendants( [ selectedBlockClientId ] )[ 0 ] ??
168
+ getClientIdsOfDescendants( selectedBlockClientId )[ 0 ] ??
169
169
  selectedBlockClientId;
170
170
  }
171
171
  const startingBlockClientId = hasBlockMovingClientId();
@@ -193,6 +193,14 @@ function BlockSelectionButton( { clientId, rootClientId } ) {
193
193
  selectBlock( startingBlockClientId );
194
194
  setBlockMovingClientId( null );
195
195
  }
196
+ // Prevent the block from being moved into itself.
197
+ if (
198
+ startingBlockClientId &&
199
+ selectedBlockClientId === startingBlockClientId &&
200
+ navigateIn
201
+ ) {
202
+ return;
203
+ }
196
204
  if ( navigateDown || navigateUp || navigateOut || navigateIn ) {
197
205
  if ( focusedBlockUid ) {
198
206
  event.preventDefault();
@@ -89,9 +89,6 @@
89
89
  * Block Toolbar when contextual.
90
90
  */
91
91
 
92
- // Base left position for the toolbar when fixed.
93
- @include editor-left(".block-editor-block-contextual-toolbar.is-fixed");
94
-
95
92
  .block-editor-block-contextual-toolbar {
96
93
  // Block UI appearance.
97
94
  display: inline-flex;
@@ -105,11 +102,6 @@
105
102
  }
106
103
 
107
104
  &.is-fixed {
108
- position: sticky;
109
- top: 0;
110
- z-index: z-index(".block-editor-block-popover");
111
- display: block;
112
- width: 100%;
113
105
  overflow: hidden;
114
106
 
115
107
  .block-editor-block-toolbar {
@@ -137,51 +129,8 @@
137
129
  background: linear-gradient(to right, $white, transparent);
138
130
  }
139
131
 
140
- // on desktop and tablet viewports the toolbar is fixed
141
- // on top of interface header
142
- $toolbar-margin: $grid-unit-80 * 3 - 2 * $grid-unit + $grid-unit-05;
143
132
  @include break-medium() {
144
133
  &.is-fixed {
145
- // leave room for block inserter, undo and redo, list view
146
- margin-left: $toolbar-margin;
147
- // position on top of interface header
148
- position: fixed;
149
- top: $admin-bar-height;
150
- // Don't fill up when empty
151
- min-height: initial;
152
- // remove the border
153
- border-bottom: none;
154
- // has to be flex for collapse button to fit
155
- display: flex;
156
-
157
- // Mimic the height of the parent, vertically align center, and provide a max-height.
158
- height: $header-height;
159
- align-items: center;
160
-
161
- &.is-collapsed {
162
- width: initial;
163
- }
164
-
165
- &:empty {
166
- width: initial;
167
- }
168
-
169
- .is-fullscreen-mode & {
170
- // leave room for block inserter, undo and redo, list view
171
- // and some margin left
172
- margin-left: $grid-unit-80 * 4 - 2 * $grid-unit;
173
-
174
- top: 0;
175
-
176
- &.is-collapsed {
177
- width: initial;
178
- }
179
-
180
- &:empty {
181
- width: initial;
182
- }
183
- }
184
-
185
134
  & > .block-editor-block-toolbar {
186
135
  flex-grow: initial;
187
136
  width: initial;
@@ -264,13 +213,6 @@
264
213
  }
265
214
 
266
215
  .show-icon-labels & {
267
-
268
- margin-left: $grid-unit-80 + 2 * $grid-unit; // inserter and margin
269
-
270
- .is-fullscreen-mode & {
271
- margin-left: $grid-unit * 18; // site hub, inserter and margin
272
- }
273
-
274
216
  .block-editor-block-parent-selector .block-editor-block-parent-selector__button::after {
275
217
  left: 0;
276
218
  }
@@ -287,14 +229,6 @@
287
229
  }
288
230
  }
289
231
  }
290
-
291
- .blocks-widgets-container & {
292
- margin-left: $grid-unit-80 * 2.4;
293
-
294
- &.is-collapsed {
295
- margin-left: $grid-unit-80 * 4.2;
296
- }
297
- }
298
232
  }
299
233
 
300
234
  &.is-fixed .block-editor-block-parent-selector {
@@ -332,38 +266,6 @@
332
266
  }
333
267
  }
334
268
  }
335
-
336
- // on tablet viewports the toolbar is fixed
337
- // on top of interface header and covers the whole header
338
- // except for the inserter on the left
339
- @include break-medium() {
340
- &.is-fixed {
341
- width: calc(100% - #{$toolbar-margin});
342
-
343
- .show-icon-labels & {
344
- width: calc(100% + 40px - #{$toolbar-margin}); //there are no undo, redo and list view buttons
345
- }
346
-
347
- }
348
- }
349
-
350
- // on desktop viewports the toolbar is fixed
351
- // on top of interface header and leaves room
352
- // for the block inserter the publish button
353
- @include break-large() {
354
- &.is-fixed {
355
- width: auto;
356
- .show-icon-labels & {
357
- width: auto; //there are no undo, redo and list view buttons
358
- }
359
- }
360
- .is-fullscreen-mode &.is-fixed {
361
- // in full screen mode we need to account for
362
- // the combined with of the tools at the right of the header and the margin left
363
- // of the toolbar which includes four buttons
364
- width: calc(100% - 280px - #{4 * $grid-unit-80});
365
- }
366
- }
367
269
  }
368
270
 
369
271
  /**
@@ -68,7 +68,7 @@ export default function BoxInputControls( {
68
68
  : selectedUnits[ corner ] || selectedUnits.flat;
69
69
 
70
70
  return (
71
- <Tooltip text={ label } position="top" key={ corner }>
71
+ <Tooltip text={ label } placement="top" key={ corner }>
72
72
  <div className="components-border-radius-control__tooltip-wrapper">
73
73
  <UnitControl
74
74
  { ...props }
@@ -8,19 +8,16 @@ import { __ } from '@wordpress/i18n';
8
8
  export default function LinkedButton( { isLinked, ...props } ) {
9
9
  const label = isLinked ? __( 'Unlink radii' ) : __( 'Link radii' );
10
10
 
11
- // TODO: Remove span after merging https://github.com/WordPress/gutenberg/pull/44198
12
11
  return (
13
12
  <Tooltip text={ label }>
14
- <span>
15
- <Button
16
- { ...props }
17
- className="component-border-radius-control__linked-button"
18
- isSmall
19
- icon={ isLinked ? link : linkOff }
20
- iconSize={ 24 }
21
- aria-label={ label }
22
- />
23
- </span>
13
+ <Button
14
+ { ...props }
15
+ className="component-border-radius-control__linked-button"
16
+ isSmall
17
+ icon={ isLinked ? link : linkOff }
18
+ iconSize={ 24 }
19
+ aria-label={ label }
20
+ />
24
21
  </Tooltip>
25
22
  );
26
23
  }
@@ -202,31 +202,44 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
202
202
  class="components-circular-option-picker"
203
203
  >
204
204
  <div
205
- class="components-circular-option-picker__swatches"
205
+ aria-label="Custom color picker."
206
+ id="components-circular-option-picker-0"
207
+ role="listbox"
206
208
  >
207
209
  <div
208
- class="components-circular-option-picker__option-wrapper"
210
+ class="components-circular-option-picker__swatches"
209
211
  >
210
- <button
211
- aria-label="Color: red"
212
- aria-pressed="true"
213
- class="components-button components-circular-option-picker__option is-pressed"
214
- style="background-color: rgb(255, 0, 0); color: rgb(255, 0, 0);"
215
- type="button"
216
- />
217
- <svg
218
- aria-hidden="true"
219
- fill="#000"
220
- focusable="false"
221
- height="24"
222
- viewBox="0 0 24 24"
223
- width="24"
224
- xmlns="http://www.w3.org/2000/svg"
212
+ <div
213
+ class="components-circular-option-picker__option-group components-circular-option-picker__swatches"
225
214
  >
226
- <path
227
- d="M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
228
- />
229
- </svg>
215
+ <div
216
+ class="components-circular-option-picker__option-wrapper"
217
+ >
218
+ <button
219
+ aria-label="Color: red"
220
+ aria-selected="true"
221
+ class="components-button components-circular-option-picker__option is-pressed"
222
+ id="components-circular-option-picker-0-0"
223
+ role="option"
224
+ style="background-color: rgb(255, 0, 0); color: rgb(255, 0, 0);"
225
+ tabindex="0"
226
+ type="button"
227
+ />
228
+ <svg
229
+ aria-hidden="true"
230
+ fill="#000"
231
+ focusable="false"
232
+ height="24"
233
+ viewBox="0 0 24 24"
234
+ width="24"
235
+ xmlns="http://www.w3.org/2000/svg"
236
+ >
237
+ <path
238
+ d="M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
239
+ />
240
+ </svg>
241
+ </div>
242
+ </div>
230
243
  </div>
231
244
  </div>
232
245
  <div
@@ -36,8 +36,9 @@ const upperFirst = ( [ firstLetter, ...rest ] ) =>
36
36
  */
37
37
  const withCustomColorPalette = ( colorsArray ) =>
38
38
  createHigherOrderComponent(
39
- ( WrappedComponent ) => ( props ) =>
40
- <WrappedComponent { ...props } colors={ colorsArray } />,
39
+ ( WrappedComponent ) => ( props ) => (
40
+ <WrappedComponent { ...props } colors={ colorsArray } />
41
+ ),
41
42
  'withCustomColorPalette'
42
43
  );
43
44
 
@@ -34,55 +34,28 @@ export default function useConvertToGroupButtonProps( selectedClientIds ) {
34
34
  return useSelect(
35
35
  ( select ) => {
36
36
  const {
37
- getBlockRootClientId,
38
37
  getBlocksByClientId,
39
- canInsertBlockType,
40
38
  getSelectedBlockClientIds,
39
+ isUngroupable,
40
+ isGroupable,
41
41
  } = select( blockEditorStore );
42
42
  const { getGroupingBlockName, getBlockType } =
43
43
  select( blocksStore );
44
44
  const clientIds = selectedClientIds?.length
45
45
  ? selectedClientIds
46
46
  : getSelectedBlockClientIds();
47
- const groupingBlockName = getGroupingBlockName();
48
-
49
- const rootClientId = clientIds?.length
50
- ? getBlockRootClientId( clientIds[ 0 ] )
51
- : undefined;
52
-
53
- const groupingBlockAvailable = canInsertBlockType(
54
- groupingBlockName,
55
- rootClientId
56
- );
57
-
58
47
  const blocksSelection = getBlocksByClientId( clientIds );
59
- const isSingleBlockSelected = blocksSelection.length === 1;
60
48
  const [ firstSelectedBlock ] = blocksSelection;
61
- // A block is ungroupable if it is a single grouping block with inner blocks.
62
- // If a block has an `ungroup` transform, it is also ungroupable, without the
63
- // requirement of being the default grouping block.
64
- // Do we have a single grouping Block selected and does that group have inner blocks?
65
- const isUngroupable =
66
- isSingleBlockSelected &&
67
- ( firstSelectedBlock.name === groupingBlockName ||
68
- getBlockType( firstSelectedBlock.name )?.transforms
69
- ?.ungroup ) &&
70
- !! firstSelectedBlock.innerBlocks.length;
71
-
72
- // Do we have
73
- // 1. Grouping block available to be inserted?
74
- // 2. One or more blocks selected
75
- const isGroupable =
76
- groupingBlockAvailable && blocksSelection.length;
77
-
49
+ const _isUngroupable =
50
+ clientIds.length === 1 && isUngroupable( clientIds[ 0 ] );
78
51
  return {
79
52
  clientIds,
80
- isGroupable,
81
- isUngroupable,
53
+ isGroupable: isGroupable( clientIds ),
54
+ isUngroupable: _isUngroupable,
82
55
  blocksSelection,
83
- groupingBlockName,
56
+ groupingBlockName: getGroupingBlockName(),
84
57
  onUngroup:
85
- isUngroupable &&
58
+ _isUngroupable &&
86
59
  getBlockType( firstSelectedBlock.name )?.transforms
87
60
  ?.ungroup,
88
61
  };
@@ -24,6 +24,7 @@ const hitSlop = { top: 22, bottom: 22, left: 22, right: 22 };
24
24
  const noop = () => {};
25
25
 
26
26
  export function DefaultBlockAppender( {
27
+ baseGlobalStyles,
27
28
  isLocked,
28
29
  isVisible,
29
30
  onAppend,
@@ -34,6 +35,15 @@ export function DefaultBlockAppender( {
34
35
  if ( isLocked || ! isVisible ) {
35
36
  return null;
36
37
  }
38
+ const blockGlobalStyles = baseGlobalStyles?.blocks?.[ 'core/paragraph' ];
39
+ const { fontSize, lineHeight } = blockGlobalStyles?.typography || {};
40
+
41
+ const textStyles = blockGlobalStyles?.typography
42
+ ? {
43
+ ...( fontSize && { fontSize } ),
44
+ ...( lineHeight && { lineHeight } ),
45
+ }
46
+ : undefined;
37
47
 
38
48
  const value =
39
49
  typeof placeholder === 'string'
@@ -51,7 +61,12 @@ export function DefaultBlockAppender( {
51
61
  { showSeparator ? (
52
62
  <BlockInsertionPoint />
53
63
  ) : (
54
- <RichText placeholder={ value } onChange={ noop } />
64
+ <RichText
65
+ placeholder={ value }
66
+ onChange={ noop }
67
+ tagName="p"
68
+ style={ textStyles }
69
+ />
55
70
  ) }
56
71
  </View>
57
72
  </Pressable>
@@ -60,16 +75,24 @@ export function DefaultBlockAppender( {
60
75
 
61
76
  export default compose(
62
77
  withSelect( ( select, ownProps ) => {
63
- const { getBlockCount, getBlockName, isBlockValid, getTemplateLock } =
64
- select( blockEditorStore );
78
+ const {
79
+ getBlockCount,
80
+ getBlockName,
81
+ getSettings,
82
+ isBlockValid,
83
+ getTemplateLock,
84
+ } = select( blockEditorStore );
65
85
 
66
86
  const isEmpty = ! getBlockCount( ownProps.rootClientId );
67
87
  const isLastBlockDefault =
68
88
  getBlockName( ownProps.lastBlockClientId ) ===
69
89
  getDefaultBlockName();
70
90
  const isLastBlockValid = isBlockValid( ownProps.lastBlockClientId );
91
+ const globalStylesBaseStyles =
92
+ getSettings()?.__experimentalGlobalStylesBaseStyles;
71
93
 
72
94
  return {
95
+ baseGlobalStyles: globalStylesBaseStyles,
73
96
  isVisible: isEmpty || ! isLastBlockDefault || ! isLastBlockValid,
74
97
  isLocked: !! getTemplateLock( ownProps.rootClientId ),
75
98
  };
@@ -23,3 +23,68 @@ export function getValuesFromColors( colors = [] ) {
23
23
 
24
24
  return values;
25
25
  }
26
+
27
+ /**
28
+ * Stylesheet for disabling a global styles duotone filter.
29
+ *
30
+ * @param {string} selector Selector to disable the filter for.
31
+ *
32
+ * @return {string} Filter none style.
33
+ */
34
+ export function getDuotoneUnsetStylesheet( selector ) {
35
+ return `${ selector }{filter:none}`;
36
+ }
37
+
38
+ /**
39
+ * SVG and stylesheet needed for rendering the duotone filter.
40
+ *
41
+ * @param {string} selector Selector to apply the filter to.
42
+ * @param {string} id Unique id for this duotone filter.
43
+ *
44
+ * @return {string} Duotone filter style.
45
+ */
46
+ export function getDuotoneStylesheet( selector, id ) {
47
+ return `${ selector }{filter:url(#${ id })}`;
48
+ }
49
+
50
+ /**
51
+ * The SVG part of the duotone filter.
52
+ *
53
+ * @param {string} id Unique id for this duotone filter.
54
+ * @param {string[]} colors Color strings from dark to light.
55
+ *
56
+ * @return {string} Duotone SVG.
57
+ */
58
+ export function getDuotoneFilter( id, colors ) {
59
+ const values = getValuesFromColors( colors );
60
+ return `
61
+ <svg
62
+ xmlns:xlink="http://www.w3.org/1999/xlink"
63
+ viewBox="0 0 0 0"
64
+ width="0"
65
+ height="0"
66
+ focusable="false"
67
+ role="none"
68
+ aria-hidden="true"
69
+ style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;"
70
+ >
71
+ <defs>
72
+ <filter id="${ id }">
73
+ <!--
74
+ Use sRGB instead of linearRGB so transparency looks correct.
75
+ Use perceptual brightness to convert to grayscale.
76
+ -->
77
+ <feColorMatrix color-interpolation-filters="sRGB" type="matrix" values=" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "></feColorMatrix>
78
+ <!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->
79
+ <feComponentTransfer color-interpolation-filters="sRGB">
80
+ <feFuncR type="table" tableValues="${ values.r.join( ' ' ) }"></feFuncR>
81
+ <feFuncG type="table" tableValues="${ values.g.join( ' ' ) }"></feFuncG>
82
+ <feFuncB type="table" tableValues="${ values.b.join( ' ' ) }"></feFuncB>
83
+ <feFuncA type="table" tableValues="${ values.a.join( ' ' ) }"></feFuncA>
84
+ </feComponentTransfer>
85
+ <!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->
86
+ <feComposite in2="SourceGraphic" operator="in"></feComposite>
87
+ </filter>
88
+ </defs>
89
+ </svg>`;
90
+ }
@@ -10,16 +10,18 @@ import a11yPlugin from 'colord/plugins/a11y';
10
10
  */
11
11
  import { SVG } from '@wordpress/components';
12
12
  import { useCallback, useMemo } from '@wordpress/element';
13
+ import { useSelect } from '@wordpress/data';
13
14
 
14
15
  /**
15
16
  * Internal dependencies
16
17
  */
17
18
  import transformStyles from '../../utils/transform-styles';
19
+ import { store as blockEditorStore } from '../../store';
20
+ import { unlock } from '../../lock-unlock';
18
21
 
19
- const EDITOR_STYLES_SELECTOR = '.editor-styles-wrapper';
20
22
  extend( [ namesPlugin, a11yPlugin ] );
21
23
 
22
- function useDarkThemeBodyClassName( styles ) {
24
+ function useDarkThemeBodyClassName( styles, scope ) {
23
25
  return useCallback(
24
26
  ( node ) => {
25
27
  if ( ! node ) {
@@ -28,9 +30,7 @@ function useDarkThemeBodyClassName( styles ) {
28
30
 
29
31
  const { ownerDocument } = node;
30
32
  const { defaultView, body } = ownerDocument;
31
- const canvas = ownerDocument.querySelector(
32
- EDITOR_STYLES_SELECTOR
33
- );
33
+ const canvas = scope ? ownerDocument.querySelector( scope ) : body;
34
34
 
35
35
  let backgroundColor;
36
36
 
@@ -63,38 +63,47 @@ function useDarkThemeBodyClassName( styles ) {
63
63
  body.classList.add( 'is-dark-theme' );
64
64
  }
65
65
  },
66
- [ styles ]
66
+ [ styles, scope ]
67
67
  );
68
68
  }
69
69
 
70
- export default function EditorStyles( { styles } ) {
71
- const stylesArray = useMemo(
72
- () => Object.values( styles ?? [] ),
73
- [ styles ]
70
+ export default function EditorStyles( { styles, scope } ) {
71
+ const overrides = useSelect(
72
+ ( select ) => unlock( select( blockEditorStore ) ).getStyleOverrides(),
73
+ []
74
74
  );
75
- const transformedStyles = useMemo(
76
- () =>
75
+ const [ transformedStyles, transformedSvgs ] = useMemo( () => {
76
+ const _styles = Object.values( styles ?? [] );
77
+
78
+ for ( const [ id, override ] of overrides ) {
79
+ const index = _styles.findIndex( ( { id: _id } ) => id === _id );
80
+ const overrideWithId = { ...override, id };
81
+ if ( index === -1 ) {
82
+ _styles.push( overrideWithId );
83
+ } else {
84
+ _styles[ index ] = overrideWithId;
85
+ }
86
+ }
87
+
88
+ return [
77
89
  transformStyles(
78
- stylesArray.filter( ( style ) => style?.css ),
79
- EDITOR_STYLES_SELECTOR
90
+ _styles.filter( ( style ) => style?.css ),
91
+ scope
80
92
  ),
81
- [ stylesArray ]
82
- );
83
-
84
- const transformedSvgs = useMemo(
85
- () =>
86
- stylesArray
93
+ _styles
87
94
  .filter( ( style ) => style.__unstableType === 'svgs' )
88
95
  .map( ( style ) => style.assets )
89
96
  .join( '' ),
90
- [ stylesArray ]
91
- );
97
+ ];
98
+ }, [ styles, overrides, scope ] );
92
99
 
93
100
  return (
94
101
  <>
95
102
  { /* Use an empty style element to have a document reference,
96
103
  but this could be any element. */ }
97
- <style ref={ useDarkThemeBodyClassName( stylesArray ) } />
104
+ <style
105
+ ref={ useDarkThemeBodyClassName( transformedStyles, scope ) }
106
+ />
98
107
  { transformedStyles.map( ( css, index ) => (
99
108
  <style key={ index }>{ css }</style>
100
109
  ) ) }