@wordpress/editor 14.33.3 → 14.34.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 (301) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/collab-sidebar/comment-author-info.js +26 -14
  3. package/build/components/collab-sidebar/comment-author-info.js.map +2 -2
  4. package/build/components/document-bar/index.js +16 -3
  5. package/build/components/document-bar/index.js.map +2 -2
  6. package/build/components/editor/index.js +23 -4
  7. package/build/components/editor/index.js.map +3 -3
  8. package/build/components/editor-interface/index.js +15 -10
  9. package/build/components/editor-interface/index.js.map +3 -3
  10. package/build/components/entities-saved-states/entity-type-list.js +19 -15
  11. package/build/components/entities-saved-states/entity-type-list.js.map +3 -3
  12. package/build/components/global-styles/block-link.js +70 -0
  13. package/build/components/global-styles/block-link.js.map +7 -0
  14. package/build/components/global-styles/header.js +54 -0
  15. package/build/components/global-styles/header.js.map +7 -0
  16. package/build/components/global-styles/hooks.js +176 -0
  17. package/build/components/global-styles/hooks.js.map +7 -0
  18. package/build/components/global-styles/index.js +138 -0
  19. package/build/components/global-styles/index.js.map +7 -0
  20. package/build/components/global-styles/menu.js +95 -0
  21. package/build/components/global-styles/menu.js.map +7 -0
  22. package/build/components/global-styles-provider/index.js +3 -49
  23. package/build/components/global-styles-provider/index.js.map +3 -3
  24. package/build/components/global-styles-renderer/index.js +55 -0
  25. package/build/components/global-styles-renderer/index.js.map +7 -0
  26. package/build/components/global-styles-sidebar/default-sidebar.js +66 -0
  27. package/build/components/global-styles-sidebar/default-sidebar.js.map +7 -0
  28. package/build/components/global-styles-sidebar/index.js +182 -0
  29. package/build/components/global-styles-sidebar/index.js.map +7 -0
  30. package/build/components/global-styles-sidebar/welcome-guide-image.js +37 -0
  31. package/build/components/global-styles-sidebar/welcome-guide-image.js.map +7 -0
  32. package/build/components/global-styles-sidebar/welcome-guide.js +143 -0
  33. package/build/components/global-styles-sidebar/welcome-guide.js.map +7 -0
  34. package/build/components/header/index.js +12 -9
  35. package/build/components/header/index.js.map +2 -2
  36. package/build/components/post-featured-image/index.js +32 -1
  37. package/build/components/post-featured-image/index.js.map +3 -3
  38. package/build/components/provider/index.js +0 -2
  39. package/build/components/provider/index.js.map +3 -3
  40. package/build/components/style-book/categories.js +86 -0
  41. package/build/components/style-book/categories.js.map +7 -0
  42. package/build/components/style-book/color-examples.js +64 -0
  43. package/build/components/style-book/color-examples.js.map +7 -0
  44. package/build/components/style-book/constants.js +319 -0
  45. package/build/components/style-book/constants.js.map +7 -0
  46. package/build/components/style-book/duotone-examples.js +68 -0
  47. package/build/components/style-book/duotone-examples.js.map +7 -0
  48. package/build/components/style-book/examples.js +237 -0
  49. package/build/components/style-book/examples.js.map +7 -0
  50. package/build/components/style-book/index.js +627 -0
  51. package/build/components/style-book/index.js.map +7 -0
  52. package/build/components/style-book/types.js +17 -0
  53. package/build/components/style-book/types.js.map +7 -0
  54. package/build/components/styles-canvas/index.js +138 -0
  55. package/build/components/styles-canvas/index.js.map +7 -0
  56. package/build/components/styles-canvas/revisions.js +121 -0
  57. package/build/components/styles-canvas/revisions.js.map +7 -0
  58. package/build/components/styles-canvas/style-book.js +68 -0
  59. package/build/components/styles-canvas/style-book.js.map +7 -0
  60. package/build/components/visual-editor/index.js +4 -3
  61. package/build/components/visual-editor/index.js.map +2 -2
  62. package/build/dataviews/fields/content-preview/content-preview-view.js.map +2 -2
  63. package/build/hooks/index.js +1 -0
  64. package/build/hooks/index.js.map +2 -2
  65. package/build/hooks/media-upload.js +15 -4
  66. package/build/hooks/media-upload.js.map +3 -3
  67. package/build/hooks/push-changes-to-global-styles/index.js +322 -0
  68. package/build/hooks/push-changes-to-global-styles/index.js.map +7 -0
  69. package/build/hooks/use-global-styles-output.js +74 -0
  70. package/build/hooks/use-global-styles-output.js.map +7 -0
  71. package/build/private-apis.js +10 -5
  72. package/build/private-apis.js.map +3 -3
  73. package/build/store/private-actions.js +23 -0
  74. package/build/store/private-actions.js.map +2 -2
  75. package/build/store/private-selectors.js +10 -0
  76. package/build/store/private-selectors.js.map +2 -2
  77. package/build/store/reducer.js +24 -0
  78. package/build/store/reducer.js.map +2 -2
  79. package/build/{components/editor-interface/content-slot-fill.js → utils/set-nested-value.js} +24 -10
  80. package/build/utils/set-nested-value.js.map +7 -0
  81. package/build-module/components/collab-sidebar/comment-author-info.js +26 -14
  82. package/build-module/components/collab-sidebar/comment-author-info.js.map +2 -2
  83. package/build-module/components/document-bar/index.js +16 -3
  84. package/build-module/components/document-bar/index.js.map +2 -2
  85. package/build-module/components/editor/index.js +23 -4
  86. package/build-module/components/editor/index.js.map +2 -2
  87. package/build-module/components/editor-interface/index.js +15 -10
  88. package/build-module/components/editor-interface/index.js.map +2 -2
  89. package/build-module/components/entities-saved-states/entity-type-list.js +18 -14
  90. package/build-module/components/entities-saved-states/entity-type-list.js.map +2 -2
  91. package/build-module/components/global-styles/block-link.js +46 -0
  92. package/build-module/components/global-styles/block-link.js.map +7 -0
  93. package/build-module/components/global-styles/header.js +41 -0
  94. package/build-module/components/global-styles/header.js.map +7 -0
  95. package/build-module/components/global-styles/hooks.js +154 -0
  96. package/build-module/components/global-styles/hooks.js.map +7 -0
  97. package/build-module/components/global-styles/index.js +112 -0
  98. package/build-module/components/global-styles/index.js.map +7 -0
  99. package/build-module/components/global-styles/menu.js +71 -0
  100. package/build-module/components/global-styles/menu.js.map +7 -0
  101. package/build-module/components/global-styles-provider/index.js +3 -37
  102. package/build-module/components/global-styles-provider/index.js.map +2 -2
  103. package/build-module/components/global-styles-renderer/index.js +31 -0
  104. package/build-module/components/global-styles-renderer/index.js.map +7 -0
  105. package/build-module/components/global-styles-sidebar/default-sidebar.js +49 -0
  106. package/build-module/components/global-styles-sidebar/default-sidebar.js.map +7 -0
  107. package/build-module/components/global-styles-sidebar/index.js +152 -0
  108. package/build-module/components/global-styles-sidebar/index.js.map +7 -0
  109. package/build-module/components/global-styles-sidebar/welcome-guide-image.js +17 -0
  110. package/build-module/components/global-styles-sidebar/welcome-guide-image.js.map +7 -0
  111. package/build-module/components/global-styles-sidebar/welcome-guide.js +113 -0
  112. package/build-module/components/global-styles-sidebar/welcome-guide.js.map +7 -0
  113. package/build-module/components/header/index.js +12 -9
  114. package/build-module/components/header/index.js.map +2 -2
  115. package/build-module/components/post-featured-image/index.js +35 -3
  116. package/build-module/components/post-featured-image/index.js.map +2 -2
  117. package/build-module/components/provider/index.js +0 -2
  118. package/build-module/components/provider/index.js.map +2 -2
  119. package/build-module/components/style-book/categories.js +64 -0
  120. package/build-module/components/style-book/categories.js.map +7 -0
  121. package/build-module/components/style-book/color-examples.js +37 -0
  122. package/build-module/components/style-book/color-examples.js.map +7 -0
  123. package/build-module/components/style-book/constants.js +290 -0
  124. package/build-module/components/style-book/constants.js.map +7 -0
  125. package/build-module/components/style-book/duotone-examples.js +48 -0
  126. package/build-module/components/style-book/duotone-examples.js.map +7 -0
  127. package/build-module/components/style-book/examples.js +208 -0
  128. package/build-module/components/style-book/examples.js.map +7 -0
  129. package/build-module/components/style-book/index.js +618 -0
  130. package/build-module/components/style-book/index.js.map +7 -0
  131. package/build-module/components/style-book/types.js +1 -0
  132. package/build-module/components/style-book/types.js.map +7 -0
  133. package/build-module/components/styles-canvas/index.js +104 -0
  134. package/build-module/components/styles-canvas/index.js.map +7 -0
  135. package/build-module/components/styles-canvas/revisions.js +107 -0
  136. package/build-module/components/styles-canvas/revisions.js.map +7 -0
  137. package/build-module/components/styles-canvas/style-book.js +38 -0
  138. package/build-module/components/styles-canvas/style-book.js.map +7 -0
  139. package/build-module/components/visual-editor/index.js +4 -3
  140. package/build-module/components/visual-editor/index.js.map +2 -2
  141. package/build-module/dataviews/fields/content-preview/content-preview-view.js.map +2 -2
  142. package/build-module/hooks/index.js +1 -0
  143. package/build-module/hooks/index.js.map +2 -2
  144. package/build-module/hooks/media-upload.js +19 -5
  145. package/build-module/hooks/media-upload.js.map +2 -2
  146. package/build-module/hooks/push-changes-to-global-styles/index.js +309 -0
  147. package/build-module/hooks/push-changes-to-global-styles/index.js.map +7 -0
  148. package/build-module/hooks/use-global-styles-output.js +49 -0
  149. package/build-module/hooks/use-global-styles-output.js.map +7 -0
  150. package/build-module/private-apis.js +10 -8
  151. package/build-module/private-apis.js.map +2 -2
  152. package/build-module/store/private-actions.js +20 -0
  153. package/build-module/store/private-actions.js.map +2 -2
  154. package/build-module/store/private-selectors.js +8 -0
  155. package/build-module/store/private-selectors.js.map +2 -2
  156. package/build-module/store/reducer.js +22 -0
  157. package/build-module/store/reducer.js.map +2 -2
  158. package/build-module/utils/set-nested-value.js +23 -0
  159. package/build-module/utils/set-nested-value.js.map +7 -0
  160. package/build-style/style-rtl.css +3017 -11
  161. package/build-style/style.css +3018 -11
  162. package/build-types/components/collab-sidebar/comment-author-info.d.ts +5 -16
  163. package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -1
  164. package/build-types/components/document-bar/index.d.ts +2 -2
  165. package/build-types/components/document-bar/index.d.ts.map +1 -1
  166. package/build-types/components/editor/index.d.ts.map +1 -1
  167. package/build-types/components/editor-interface/index.d.ts +1 -3
  168. package/build-types/components/editor-interface/index.d.ts.map +1 -1
  169. package/build-types/components/entities-saved-states/entity-type-list.d.ts.map +1 -1
  170. package/build-types/components/global-styles/block-link.d.ts +12 -0
  171. package/build-types/components/global-styles/block-link.d.ts.map +1 -0
  172. package/build-types/components/global-styles/header.d.ts +7 -0
  173. package/build-types/components/global-styles/header.d.ts.map +1 -0
  174. package/build-types/components/global-styles/hooks.d.ts +24 -0
  175. package/build-types/components/global-styles/hooks.d.ts.map +1 -0
  176. package/build-types/components/global-styles/index.d.ts +6 -0
  177. package/build-types/components/global-styles/index.d.ts.map +1 -0
  178. package/build-types/components/global-styles/menu.d.ts +13 -0
  179. package/build-types/components/global-styles/menu.d.ts.map +1 -0
  180. package/build-types/components/global-styles-provider/index.d.ts +1 -5
  181. package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
  182. package/build-types/components/global-styles-renderer/index.d.ts +4 -0
  183. package/build-types/components/global-styles-renderer/index.d.ts.map +1 -0
  184. package/build-types/components/global-styles-sidebar/default-sidebar.d.ts +13 -0
  185. package/build-types/components/global-styles-sidebar/default-sidebar.d.ts.map +1 -0
  186. package/build-types/components/global-styles-sidebar/index.d.ts +2 -0
  187. package/build-types/components/global-styles-sidebar/index.d.ts.map +1 -0
  188. package/build-types/components/global-styles-sidebar/welcome-guide-image.d.ts +5 -0
  189. package/build-types/components/global-styles-sidebar/welcome-guide-image.d.ts.map +1 -0
  190. package/build-types/components/global-styles-sidebar/welcome-guide.d.ts +2 -0
  191. package/build-types/components/global-styles-sidebar/welcome-guide.d.ts.map +1 -0
  192. package/build-types/components/header/index.d.ts +1 -3
  193. package/build-types/components/header/index.d.ts.map +1 -1
  194. package/build-types/components/provider/index.d.ts.map +1 -1
  195. package/build-types/components/style-book/categories.d.ts +18 -0
  196. package/build-types/components/style-book/categories.d.ts.map +1 -0
  197. package/build-types/components/style-book/color-examples.d.ts +7 -0
  198. package/build-types/components/style-book/color-examples.d.ts.map +1 -0
  199. package/build-types/components/style-book/constants.d.ts +11 -0
  200. package/build-types/components/style-book/constants.d.ts.map +1 -0
  201. package/build-types/components/style-book/duotone-examples.d.ts +9 -0
  202. package/build-types/components/style-book/duotone-examples.d.ts.map +1 -0
  203. package/build-types/components/style-book/examples.d.ts +12 -0
  204. package/build-types/components/style-book/examples.d.ts.map +1 -0
  205. package/build-types/components/style-book/index.d.ts +31 -0
  206. package/build-types/components/style-book/index.d.ts.map +1 -0
  207. package/build-types/components/style-book/types.d.ts +72 -0
  208. package/build-types/components/style-book/types.d.ts.map +1 -0
  209. package/build-types/components/styles-canvas/index.d.ts +16 -0
  210. package/build-types/components/styles-canvas/index.d.ts.map +1 -0
  211. package/build-types/components/styles-canvas/revisions.d.ts +5 -0
  212. package/build-types/components/styles-canvas/revisions.d.ts.map +1 -0
  213. package/build-types/components/styles-canvas/style-book.d.ts +6 -0
  214. package/build-types/components/styles-canvas/style-book.d.ts.map +1 -0
  215. package/build-types/components/visual-editor/index.d.ts +1 -2
  216. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  217. package/build-types/dataviews/fields/content-preview/content-preview-view.d.ts.map +1 -1
  218. package/build-types/hooks/push-changes-to-global-styles/index.d.ts +2 -0
  219. package/build-types/hooks/push-changes-to-global-styles/index.d.ts.map +1 -0
  220. package/build-types/hooks/use-global-styles-output.d.ts +18 -0
  221. package/build-types/hooks/use-global-styles-output.d.ts.map +1 -0
  222. package/build-types/private-apis.d.ts.map +1 -1
  223. package/build-types/store/private-actions.d.ts +20 -0
  224. package/build-types/store/private-actions.d.ts.map +1 -1
  225. package/build-types/store/private-selectors.d.ts +14 -0
  226. package/build-types/store/private-selectors.d.ts.map +1 -1
  227. package/build-types/store/reducer.d.ts +20 -0
  228. package/build-types/store/reducer.d.ts.map +1 -1
  229. package/build-types/utils/set-nested-value.d.ts +20 -0
  230. package/build-types/utils/set-nested-value.d.ts.map +1 -0
  231. package/package.json +40 -40
  232. package/src/components/collab-sidebar/comment-author-info.js +32 -25
  233. package/src/components/collab-sidebar/style.scss +1 -1
  234. package/src/components/document-bar/index.js +18 -3
  235. package/src/components/editor/index.js +25 -1
  236. package/src/components/editor-help/style.scss +1 -1
  237. package/src/components/editor-interface/index.js +40 -39
  238. package/src/components/entities-saved-states/entity-type-list.js +19 -17
  239. package/src/components/global-styles/block-link.js +65 -0
  240. package/src/components/global-styles/header.js +48 -0
  241. package/src/components/global-styles/hooks.js +216 -0
  242. package/src/components/global-styles/index.js +125 -0
  243. package/src/components/global-styles/menu.js +101 -0
  244. package/src/components/global-styles/style.scss +11 -0
  245. package/src/components/global-styles-provider/index.js +3 -45
  246. package/src/components/global-styles-renderer/index.js +39 -0
  247. package/src/components/global-styles-sidebar/default-sidebar.js +46 -0
  248. package/src/components/global-styles-sidebar/index.js +177 -0
  249. package/src/components/global-styles-sidebar/style.scss +119 -0
  250. package/src/components/global-styles-sidebar/welcome-guide-image.js +11 -0
  251. package/src/components/global-styles-sidebar/welcome-guide.js +136 -0
  252. package/src/components/header/index.js +11 -6
  253. package/src/components/post-featured-image/index.js +44 -1
  254. package/src/components/post-last-revision/style.scss +1 -1
  255. package/src/components/post-panel-row/style.scss +1 -0
  256. package/src/components/post-publish-panel/style.scss +1 -1
  257. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
  258. package/src/components/provider/index.js +0 -2
  259. package/src/components/style-book/categories.ts +97 -0
  260. package/src/components/style-book/color-examples.tsx +56 -0
  261. package/src/components/style-book/constants.ts +308 -0
  262. package/src/components/style-book/duotone-examples.tsx +56 -0
  263. package/src/components/style-book/examples.tsx +273 -0
  264. package/src/components/style-book/index.js +794 -0
  265. package/src/components/style-book/style.scss +44 -0
  266. package/src/components/style-book/test/categories.js +166 -0
  267. package/src/components/style-book/types.ts +80 -0
  268. package/src/components/styles-canvas/index.js +126 -0
  269. package/src/components/styles-canvas/revisions.js +144 -0
  270. package/src/components/styles-canvas/style-book.js +57 -0
  271. package/src/components/styles-canvas/style.scss +40 -0
  272. package/src/components/visual-editor/index.js +2 -1
  273. package/src/dataviews/fields/content-preview/content-preview-view.tsx +2 -0
  274. package/src/hooks/index.js +1 -0
  275. package/src/hooks/media-upload.js +25 -5
  276. package/src/hooks/push-changes-to-global-styles/index.js +391 -0
  277. package/src/hooks/push-changes-to-global-styles/style.scss +4 -0
  278. package/src/hooks/use-global-styles-output.js +76 -0
  279. package/src/private-apis.js +10 -8
  280. package/src/store/private-actions.js +37 -0
  281. package/src/store/private-selectors.js +20 -0
  282. package/src/store/reducer.js +36 -0
  283. package/src/style.scss +7 -1
  284. package/src/utils/set-nested-value.js +39 -0
  285. package/tsconfig.json +3 -0
  286. package/tsconfig.tsbuildinfo +1 -1
  287. package/build/components/block-settings-menu/content-only-settings-menu.js +0 -186
  288. package/build/components/block-settings-menu/content-only-settings-menu.js.map +0 -7
  289. package/build/components/editor-interface/content-slot-fill.js.map +0 -7
  290. package/build-module/components/block-settings-menu/content-only-settings-menu.js +0 -161
  291. package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +0 -7
  292. package/build-module/components/editor-interface/content-slot-fill.js +0 -9
  293. package/build-module/components/editor-interface/content-slot-fill.js.map +0 -7
  294. package/build-types/components/block-settings-menu/content-only-settings-menu.d.ts +0 -2
  295. package/build-types/components/block-settings-menu/content-only-settings-menu.d.ts.map +0 -1
  296. package/build-types/components/editor-interface/content-slot-fill.d.ts +0 -14
  297. package/build-types/components/editor-interface/content-slot-fill.d.ts.map +0 -1
  298. package/src/components/block-settings-menu/content-only-settings-menu.js +0 -185
  299. package/src/components/block-settings-menu/content-only-settings-menu.native.js +0 -4
  300. package/src/components/block-settings-menu/style.scss +0 -6
  301. package/src/components/editor-interface/content-slot-fill.js +0 -10
@@ -2,10 +2,30 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { addFilter } from '@wordpress/hooks';
5
- import { MediaUpload } from '@wordpress/media-utils';
5
+ import {
6
+ MediaUpload,
7
+ privateApis as mediaUtilsPrivateApis,
8
+ } from '@wordpress/media-utils';
6
9
 
7
- addFilter(
8
- 'editor.MediaUpload',
9
- 'core/editor/components/media-upload',
10
- () => MediaUpload
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ import { unlock } from '../lock-unlock';
14
+
15
+ const { MediaUploadModal: MediaUploadModalComponent } = unlock(
16
+ mediaUtilsPrivateApis
11
17
  );
18
+
19
+ if ( window.__experimentalDataViewsMediaModal ) {
20
+ // Create a new filter for the MediaUploadModal component
21
+ addFilter(
22
+ 'editor.MediaUploadModal',
23
+ 'core/editor/components/media-upload-modal',
24
+ () => {
25
+ return MediaUploadModalComponent;
26
+ }
27
+ );
28
+ }
29
+ addFilter( 'editor.MediaUpload', 'core/editor/components/media-upload', () => {
30
+ return MediaUpload;
31
+ } );
@@ -0,0 +1,391 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { addFilter } from '@wordpress/hooks';
5
+ import { createHigherOrderComponent } from '@wordpress/compose';
6
+ import {
7
+ InspectorAdvancedControls,
8
+ store as blockEditorStore,
9
+ privateApis as blockEditorPrivateApis,
10
+ useBlockEditingMode,
11
+ } from '@wordpress/block-editor';
12
+ import { BaseControl, Button } from '@wordpress/components';
13
+ import { __, sprintf } from '@wordpress/i18n';
14
+ import {
15
+ __EXPERIMENTAL_STYLE_PROPERTY,
16
+ getBlockType,
17
+ hasBlockSupport,
18
+ store as blocksStore,
19
+ } from '@wordpress/blocks';
20
+ import { useMemo, useCallback } from '@wordpress/element';
21
+ import { useDispatch, useSelect } from '@wordpress/data';
22
+ import { store as noticesStore } from '@wordpress/notices';
23
+ import { store as coreStore } from '@wordpress/core-data';
24
+
25
+ /**
26
+ * Internal dependencies
27
+ */
28
+ import { unlock } from '../../lock-unlock';
29
+ import setNestedValue from '../../utils/set-nested-value';
30
+ import { useGlobalStyles } from '../../components/global-styles/hooks';
31
+
32
+ const { cleanEmptyObject } = unlock( blockEditorPrivateApis );
33
+
34
+ // Block Gap is a special case and isn't defined within the blocks
35
+ // style properties config. We'll add it here to allow it to be pushed
36
+ // to global styles as well.
37
+ const STYLE_PROPERTY = {
38
+ ...__EXPERIMENTAL_STYLE_PROPERTY,
39
+ blockGap: { value: [ 'spacing', 'blockGap' ] },
40
+ };
41
+
42
+ // TODO: Temporary duplication of constant in @wordpress/block-editor. Can be
43
+ // removed by moving PushChangesToGlobalStylesControl to
44
+ // @wordpress/block-editor.
45
+ const STYLE_PATH_TO_CSS_VAR_INFIX = {
46
+ 'border.color': 'color',
47
+ 'color.background': 'color',
48
+ 'color.text': 'color',
49
+ 'elements.link.color.text': 'color',
50
+ 'elements.link.:hover.color.text': 'color',
51
+ 'elements.link.typography.fontFamily': 'font-family',
52
+ 'elements.link.typography.fontSize': 'font-size',
53
+ 'elements.button.color.text': 'color',
54
+ 'elements.button.color.background': 'color',
55
+ 'elements.button.typography.fontFamily': 'font-family',
56
+ 'elements.button.typography.fontSize': 'font-size',
57
+ 'elements.caption.color.text': 'color',
58
+ 'elements.heading.color': 'color',
59
+ 'elements.heading.color.background': 'color',
60
+ 'elements.heading.typography.fontFamily': 'font-family',
61
+ 'elements.heading.gradient': 'gradient',
62
+ 'elements.heading.color.gradient': 'gradient',
63
+ 'elements.h1.color': 'color',
64
+ 'elements.h1.color.background': 'color',
65
+ 'elements.h1.typography.fontFamily': 'font-family',
66
+ 'elements.h1.color.gradient': 'gradient',
67
+ 'elements.h2.color': 'color',
68
+ 'elements.h2.color.background': 'color',
69
+ 'elements.h2.typography.fontFamily': 'font-family',
70
+ 'elements.h2.color.gradient': 'gradient',
71
+ 'elements.h3.color': 'color',
72
+ 'elements.h3.color.background': 'color',
73
+ 'elements.h3.typography.fontFamily': 'font-family',
74
+ 'elements.h3.color.gradient': 'gradient',
75
+ 'elements.h4.color': 'color',
76
+ 'elements.h4.color.background': 'color',
77
+ 'elements.h4.typography.fontFamily': 'font-family',
78
+ 'elements.h4.color.gradient': 'gradient',
79
+ 'elements.h5.color': 'color',
80
+ 'elements.h5.color.background': 'color',
81
+ 'elements.h5.typography.fontFamily': 'font-family',
82
+ 'elements.h5.color.gradient': 'gradient',
83
+ 'elements.h6.color': 'color',
84
+ 'elements.h6.color.background': 'color',
85
+ 'elements.h6.typography.fontFamily': 'font-family',
86
+ 'elements.h6.color.gradient': 'gradient',
87
+ 'color.gradient': 'gradient',
88
+ blockGap: 'spacing',
89
+ 'typography.fontSize': 'font-size',
90
+ 'typography.fontFamily': 'font-family',
91
+ };
92
+
93
+ // TODO: Temporary duplication of constant in @wordpress/block-editor. Can be
94
+ // removed by moving PushChangesToGlobalStylesControl to
95
+ // @wordpress/block-editor.
96
+ const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
97
+ 'border.color': 'borderColor',
98
+ 'color.background': 'backgroundColor',
99
+ 'color.text': 'textColor',
100
+ 'color.gradient': 'gradient',
101
+ 'typography.fontSize': 'fontSize',
102
+ 'typography.fontFamily': 'fontFamily',
103
+ };
104
+
105
+ const SUPPORTED_STYLES = [ 'border', 'color', 'spacing', 'typography' ];
106
+
107
+ const getValueFromObjectPath = ( object, path ) => {
108
+ let value = object;
109
+ path.forEach( ( fieldName ) => {
110
+ value = value?.[ fieldName ];
111
+ } );
112
+ return value;
113
+ };
114
+
115
+ const flatBorderProperties = [ 'borderColor', 'borderWidth', 'borderStyle' ];
116
+ const sides = [ 'top', 'right', 'bottom', 'left' ];
117
+
118
+ function getBorderStyleChanges( border, presetColor, userStyle ) {
119
+ if ( ! border && ! presetColor ) {
120
+ return [];
121
+ }
122
+
123
+ const changes = [
124
+ ...getFallbackBorderStyleChange( 'top', border, userStyle ),
125
+ ...getFallbackBorderStyleChange( 'right', border, userStyle ),
126
+ ...getFallbackBorderStyleChange( 'bottom', border, userStyle ),
127
+ ...getFallbackBorderStyleChange( 'left', border, userStyle ),
128
+ ];
129
+
130
+ // Handle a flat border i.e. all sides the same, CSS shorthand.
131
+ const { color: customColor, style, width } = border || {};
132
+ const hasColorOrWidth = presetColor || customColor || width;
133
+
134
+ if ( hasColorOrWidth && ! style ) {
135
+ // Global Styles need individual side configurations to overcome
136
+ // theme.json configurations which are per side as well.
137
+ sides.forEach( ( side ) => {
138
+ // Only add fallback border-style if global styles don't already
139
+ // have something set.
140
+ if ( ! userStyle?.[ side ]?.style ) {
141
+ changes.push( {
142
+ path: [ 'border', side, 'style' ],
143
+ value: 'solid',
144
+ } );
145
+ }
146
+ } );
147
+ }
148
+
149
+ return changes;
150
+ }
151
+
152
+ function getFallbackBorderStyleChange( side, border, globalBorderStyle ) {
153
+ if ( ! border?.[ side ] || globalBorderStyle?.[ side ]?.style ) {
154
+ return [];
155
+ }
156
+
157
+ const { color, style, width } = border[ side ];
158
+ const hasColorOrWidth = color || width;
159
+
160
+ if ( ! hasColorOrWidth || style ) {
161
+ return [];
162
+ }
163
+
164
+ return [ { path: [ 'border', side, 'style' ], value: 'solid' } ];
165
+ }
166
+
167
+ function useChangesToPush( name, attributes, userConfig ) {
168
+ const supports = useSelect(
169
+ ( select ) => {
170
+ return unlock( select( blocksStore ) ).getSupportedStyles( name );
171
+ },
172
+ [ name ]
173
+ );
174
+ const blockUserConfig = userConfig?.styles?.blocks?.[ name ];
175
+
176
+ return useMemo( () => {
177
+ const changes = supports.flatMap( ( key ) => {
178
+ if ( ! STYLE_PROPERTY[ key ] ) {
179
+ return [];
180
+ }
181
+ const { value: path } = STYLE_PROPERTY[ key ];
182
+ const presetAttributeKey = path.join( '.' );
183
+ const presetAttributeValue =
184
+ attributes[
185
+ STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[ presetAttributeKey ]
186
+ ];
187
+ const value = presetAttributeValue
188
+ ? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`
189
+ : getValueFromObjectPath( attributes.style, path );
190
+
191
+ // Links only have a single support entry but have two element
192
+ // style properties, color and hover color. The following check
193
+ // will add the hover color to the changes if required.
194
+ if ( key === 'linkColor' ) {
195
+ const linkChanges = value ? [ { path, value } ] : [];
196
+ const hoverPath = [
197
+ 'elements',
198
+ 'link',
199
+ ':hover',
200
+ 'color',
201
+ 'text',
202
+ ];
203
+ const hoverValue = getValueFromObjectPath(
204
+ attributes.style,
205
+ hoverPath
206
+ );
207
+
208
+ if ( hoverValue ) {
209
+ linkChanges.push( { path: hoverPath, value: hoverValue } );
210
+ }
211
+
212
+ return linkChanges;
213
+ }
214
+
215
+ // The shorthand border styles can't be mapped directly as global
216
+ // styles requires longhand config.
217
+ if ( flatBorderProperties.includes( key ) && value ) {
218
+ // The shorthand config path is included to clear the block attribute.
219
+ const borderChanges = [ { path, value } ];
220
+ sides.forEach( ( side ) => {
221
+ const currentPath = [ ...path ];
222
+ currentPath.splice( -1, 0, side );
223
+ borderChanges.push( { path: currentPath, value } );
224
+ } );
225
+ return borderChanges;
226
+ }
227
+
228
+ return value ? [ { path, value } ] : [];
229
+ } );
230
+
231
+ // To ensure display of a visible border, global styles require a
232
+ // default border style if a border color or width is present.
233
+ getBorderStyleChanges(
234
+ attributes.style?.border,
235
+ attributes.borderColor,
236
+ blockUserConfig?.border
237
+ ).forEach( ( change ) => changes.push( change ) );
238
+
239
+ return changes;
240
+ }, [ supports, attributes, blockUserConfig ] );
241
+ }
242
+
243
+ function PushChangesToGlobalStylesControl( {
244
+ name,
245
+ attributes,
246
+ setAttributes,
247
+ } ) {
248
+ const { user: userConfig, setUser: setUserConfig } = useGlobalStyles();
249
+
250
+ const changes = useChangesToPush( name, attributes, userConfig );
251
+
252
+ const { __unstableMarkNextChangeAsNotPersistent } =
253
+ useDispatch( blockEditorStore );
254
+ const { createSuccessNotice } = useDispatch( noticesStore );
255
+
256
+ const pushChanges = useCallback( () => {
257
+ if ( changes.length === 0 ) {
258
+ return;
259
+ }
260
+
261
+ if ( changes.length > 0 ) {
262
+ const { style: blockStyles } = attributes;
263
+
264
+ const newBlockStyles = structuredClone( blockStyles );
265
+ const newUserConfig = structuredClone( userConfig );
266
+
267
+ for ( const { path, value } of changes ) {
268
+ setNestedValue( newBlockStyles, path, undefined );
269
+ setNestedValue(
270
+ newUserConfig,
271
+ [ 'styles', 'blocks', name, ...path ],
272
+ value
273
+ );
274
+ }
275
+
276
+ const newBlockAttributes = {
277
+ borderColor: undefined,
278
+ backgroundColor: undefined,
279
+ textColor: undefined,
280
+ gradient: undefined,
281
+ fontSize: undefined,
282
+ fontFamily: undefined,
283
+ style: cleanEmptyObject( newBlockStyles ),
284
+ };
285
+
286
+ // @wordpress/core-data doesn't support editing multiple entity types in
287
+ // a single undo level. So for now, we disable @wordpress/core-data undo
288
+ // tracking and implement our own Undo button in the snackbar
289
+ // notification.
290
+ __unstableMarkNextChangeAsNotPersistent();
291
+ setAttributes( newBlockAttributes );
292
+ setUserConfig( newUserConfig, { undoIgnore: true } );
293
+ createSuccessNotice(
294
+ sprintf(
295
+ // translators: %s: Title of the block e.g. 'Heading'.
296
+ __( '%s styles applied.' ),
297
+ getBlockType( name ).title
298
+ ),
299
+ {
300
+ type: 'snackbar',
301
+ actions: [
302
+ {
303
+ label: __( 'Undo' ),
304
+ onClick() {
305
+ __unstableMarkNextChangeAsNotPersistent();
306
+ setAttributes( attributes );
307
+ setUserConfig( userConfig, {
308
+ undoIgnore: true,
309
+ } );
310
+ },
311
+ },
312
+ ],
313
+ }
314
+ );
315
+ }
316
+ }, [
317
+ __unstableMarkNextChangeAsNotPersistent,
318
+ attributes,
319
+ changes,
320
+ createSuccessNotice,
321
+ name,
322
+ setAttributes,
323
+ setUserConfig,
324
+ userConfig,
325
+ ] );
326
+
327
+ return (
328
+ <BaseControl
329
+ __nextHasNoMarginBottom
330
+ className="editor-push-changes-to-global-styles-control"
331
+ help={ sprintf(
332
+ // translators: %s: Title of the block e.g. 'Heading'.
333
+ __(
334
+ 'Apply this block’s typography, spacing, dimensions, and color styles to all %s blocks.'
335
+ ),
336
+ getBlockType( name ).title
337
+ ) }
338
+ >
339
+ <BaseControl.VisualLabel>
340
+ { __( 'Styles' ) }
341
+ </BaseControl.VisualLabel>
342
+ <Button
343
+ __next40pxDefaultSize
344
+ variant="secondary"
345
+ accessibleWhenDisabled
346
+ disabled={ changes.length === 0 }
347
+ onClick={ pushChanges }
348
+ >
349
+ { __( 'Apply globally' ) }
350
+ </Button>
351
+ </BaseControl>
352
+ );
353
+ }
354
+
355
+ function PushChangesToGlobalStyles( props ) {
356
+ const blockEditingMode = useBlockEditingMode();
357
+ const isBlockBasedTheme = useSelect(
358
+ ( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme,
359
+ []
360
+ );
361
+ const supportsStyles = SUPPORTED_STYLES.some( ( feature ) =>
362
+ hasBlockSupport( props.name, feature )
363
+ );
364
+ const isDisplayed =
365
+ blockEditingMode === 'default' && supportsStyles && isBlockBasedTheme;
366
+
367
+ if ( ! isDisplayed ) {
368
+ return null;
369
+ }
370
+
371
+ return (
372
+ <InspectorAdvancedControls>
373
+ <PushChangesToGlobalStylesControl { ...props } />
374
+ </InspectorAdvancedControls>
375
+ );
376
+ }
377
+
378
+ const withPushChangesToGlobalStyles = createHigherOrderComponent(
379
+ ( BlockEdit ) => ( props ) => (
380
+ <>
381
+ <BlockEdit key="edit" { ...props } />
382
+ { props.isSelected && <PushChangesToGlobalStyles { ...props } /> }
383
+ </>
384
+ )
385
+ );
386
+
387
+ addFilter(
388
+ 'editor.BlockEdit',
389
+ 'core/editor/push-changes-to-global-styles',
390
+ withPushChangesToGlobalStyles
391
+ );
@@ -0,0 +1,4 @@
1
+ .editor-push-changes-to-global-styles-control .components-button {
2
+ justify-content: center;
3
+ width: 100%;
4
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { getBlockTypes, store as blocksStore } from '@wordpress/blocks';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { useMemo } from '@wordpress/element';
7
+ import { generateGlobalStyles } from '@wordpress/global-styles-engine';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import { store as editorStore } from '../store';
13
+ import { useSetting, useGlobalStyles } from '../components/global-styles';
14
+
15
+ /**
16
+ * Returns the global styles output based on the provided global styles config.
17
+ *
18
+ * @param {Object} mergedConfig The merged global styles config.
19
+ * @param {boolean} disableRootPadding Disable root padding styles.
20
+ *
21
+ * @return {Array} Array of stylesheets and settings.
22
+ */
23
+ export function useGlobalStylesOutputWithConfig(
24
+ mergedConfig = {},
25
+ disableRootPadding = false
26
+ ) {
27
+ const blockGap = useSetting( 'spacing.blockGap' );
28
+ const hasBlockGapSupport = blockGap !== null;
29
+ const hasFallbackGapSupport = ! hasBlockGapSupport;
30
+
31
+ const { disableLayoutStyles, getBlockStyles } = useSelect( ( select ) => {
32
+ const { getEditorSettings } = select( editorStore );
33
+ const { getBlockStyles: getBlockStylesSelector } =
34
+ select( blocksStore );
35
+ const settings = getEditorSettings();
36
+ return {
37
+ disableLayoutStyles: !! settings?.disableLayoutStyles,
38
+ getBlockStyles: getBlockStylesSelector,
39
+ };
40
+ }, [] );
41
+
42
+ return useMemo( () => {
43
+ if ( ! mergedConfig?.styles || ! mergedConfig?.settings ) {
44
+ return [ [], {} ];
45
+ }
46
+
47
+ const blockTypes = getBlockTypes();
48
+
49
+ return generateGlobalStyles( mergedConfig, blockTypes, {
50
+ hasBlockGapSupport,
51
+ hasFallbackGapSupport,
52
+ disableLayoutStyles,
53
+ disableRootPadding,
54
+ getBlockStyles,
55
+ } );
56
+ }, [
57
+ hasBlockGapSupport,
58
+ hasFallbackGapSupport,
59
+ mergedConfig,
60
+ disableLayoutStyles,
61
+ disableRootPadding,
62
+ getBlockStyles,
63
+ ] );
64
+ }
65
+
66
+ /**
67
+ * Returns the global styles output based on the current state of global styles config loaded in the editor context.
68
+ *
69
+ * @param {boolean} disableRootPadding Disable root padding styles.
70
+ *
71
+ * @return {Array} Array of stylesheets and settings.
72
+ */
73
+ export function useGlobalStylesOutput( disableRootPadding = false ) {
74
+ const { merged: mergedConfig } = useGlobalStyles();
75
+ return useGlobalStylesOutputWithConfig( mergedConfig, disableRootPadding );
76
+ }
@@ -8,7 +8,6 @@ import * as interfaceApis from '@wordpress/interface';
8
8
  */
9
9
  import { lock } from './lock-unlock';
10
10
  import { EntitiesSavedStatesExtensible } from './components/entities-saved-states';
11
- import EditorContentSlotFill from './components/editor-interface/content-slot-fill';
12
11
  import BackButton from './components/header/back-button';
13
12
  import Editor from './components/editor';
14
13
  import PluginPostExcerpt from './components/post-excerpt/plugin';
@@ -19,10 +18,6 @@ import usePostFields from './components/post-fields';
19
18
  import ToolsMoreMenuGroup from './components/more-menu/tools-more-menu-group';
20
19
  import ViewMoreMenuGroup from './components/more-menu/view-more-menu-group';
21
20
  import ResizableEditor from './components/resizable-editor';
22
- import {
23
- mergeBaseAndUserConfigs,
24
- GlobalStylesProvider,
25
- } from './components/global-styles-provider';
26
21
  import {
27
22
  CreateTemplatePartModal,
28
23
  patternTitleField,
@@ -30,6 +25,10 @@ import {
30
25
  } from '@wordpress/fields';
31
26
  import { registerCoreBlockBindingsSources } from './bindings/api';
32
27
  import { getTemplateInfo } from './utils/get-template-info';
28
+ import GlobalStylesUIWrapper from './components/global-styles';
29
+ import { StyleBookPreview } from './components/style-book';
30
+ import { useGlobalStyles, useStyle } from './components/global-styles/hooks';
31
+ import { GlobalStylesActionMenu } from './components/global-styles/menu';
33
32
 
34
33
  const { store: interfaceStore, ...remainingInterfaceApis } = interfaceApis;
35
34
 
@@ -41,9 +40,6 @@ lock( privateApis, {
41
40
  BackButton,
42
41
  EntitiesSavedStatesExtensible,
43
42
  Editor,
44
- EditorContentSlotFill,
45
- GlobalStylesProvider,
46
- mergeBaseAndUserConfigs,
47
43
  PluginPostExcerpt,
48
44
  PostCardPanel,
49
45
  PreferencesModal,
@@ -54,6 +50,12 @@ lock( privateApis, {
54
50
  ResizableEditor,
55
51
  registerCoreBlockBindingsSources,
56
52
  getTemplateInfo,
53
+ // Global Styles
54
+ GlobalStylesUIWrapper,
55
+ GlobalStylesActionMenu,
56
+ StyleBookPreview,
57
+ useGlobalStyles,
58
+ useStyle,
57
59
  // This is a temporary private API while we're updating the site editor to use EditorProvider.
58
60
  interfaceStore,
59
61
  ...remainingInterfaceApis,
@@ -526,3 +526,40 @@ export const setDefaultRenderingMode =
526
526
  .dispatch( preferencesStore )
527
527
  .set( 'core', 'renderingModes', newModes );
528
528
  };
529
+
530
+ /**
531
+ * Set the current global styles navigation path.
532
+ *
533
+ * @param {string} path The navigation path.
534
+ * @return {Object} Action object.
535
+ */
536
+ export function setStylesPath( path ) {
537
+ return {
538
+ type: 'SET_STYLES_PATH',
539
+ path,
540
+ };
541
+ }
542
+
543
+ /**
544
+ * Set whether the stylebook is visible.
545
+ *
546
+ * @param {boolean} show Whether to show the stylebook.
547
+ * @return {Object} Action object.
548
+ */
549
+ export function setShowStylebook( show ) {
550
+ return {
551
+ type: 'SET_SHOW_STYLEBOOK',
552
+ show,
553
+ };
554
+ }
555
+
556
+ /**
557
+ * Reset the global styles navigation to initial state.
558
+ *
559
+ * @return {Object} Action object.
560
+ */
561
+ export function resetStylesNavigation() {
562
+ return {
563
+ type: 'RESET_STYLES_NAVIGATION',
564
+ };
565
+ }
@@ -270,3 +270,23 @@ export const getDefaultRenderingMode = createRegistrySelector(
270
270
  return defaultMode;
271
271
  }
272
272
  );
273
+
274
+ /**
275
+ * Get the current global styles navigation path.
276
+ *
277
+ * @param {Object} state Global application state.
278
+ * @return {string} The current styles path.
279
+ */
280
+ export function getStylesPath( state ) {
281
+ return state.stylesPath ?? '/';
282
+ }
283
+
284
+ /**
285
+ * Get whether the stylebook is currently visible.
286
+ *
287
+ * @param {Object} state Global application state.
288
+ * @return {boolean} Whether the stylebook is visible.
289
+ */
290
+ export function getShowStylebook( state ) {
291
+ return state.showStylebook ?? false;
292
+ }
@@ -384,6 +384,40 @@ export function publishSidebarActive( state = false, action ) {
384
384
  return state;
385
385
  }
386
386
 
387
+ /**
388
+ * Reducer for the current global styles navigation path.
389
+ *
390
+ * @param {string} state Current state.
391
+ * @param {Object} action Dispatched action.
392
+ * @return {string} Updated state.
393
+ */
394
+ export function stylesPath( state = '/', action ) {
395
+ switch ( action.type ) {
396
+ case 'SET_STYLES_PATH':
397
+ return action.path;
398
+ case 'RESET_STYLES_NAVIGATION':
399
+ return '/';
400
+ }
401
+ return state;
402
+ }
403
+
404
+ /**
405
+ * Reducer for whether the stylebook is visible.
406
+ *
407
+ * @param {boolean} state Current state.
408
+ * @param {Object} action Dispatched action.
409
+ * @return {boolean} Updated state.
410
+ */
411
+ export function showStylebook( state = false, action ) {
412
+ switch ( action.type ) {
413
+ case 'SET_SHOW_STYLEBOOK':
414
+ return action.show;
415
+ case 'RESET_STYLES_NAVIGATION':
416
+ return false;
417
+ }
418
+ return state;
419
+ }
420
+
387
421
  export default combineReducers( {
388
422
  postId,
389
423
  postType,
@@ -403,5 +437,7 @@ export default combineReducers( {
403
437
  listViewPanel,
404
438
  listViewToggleRef,
405
439
  publishSidebarActive,
440
+ stylesPath,
441
+ showStylebook,
406
442
  dataviews: dataviewsReducer,
407
443
  } );