@wordpress/edit-site 5.2.0 → 5.3.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 (409) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/add-new-template/add-custom-generic-template-modal.js +8 -10
  3. package/build/components/add-new-template/add-custom-generic-template-modal.js.map +1 -1
  4. package/build/components/add-new-template/add-custom-template-modal.js +0 -1
  5. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  6. package/build/components/add-new-template/new-template-part.js +9 -32
  7. package/build/components/add-new-template/new-template-part.js.map +1 -1
  8. package/build/components/add-new-template/new-template.js +5 -4
  9. package/build/components/add-new-template/new-template.js.map +1 -1
  10. package/build/components/add-new-template/utils.js +1 -9
  11. package/build/components/add-new-template/utils.js.map +1 -1
  12. package/build/components/app/index.js +2 -7
  13. package/build/components/app/index.js.map +1 -1
  14. package/build/components/block-editor/editor-canvas.js +13 -2
  15. package/build/components/block-editor/editor-canvas.js.map +1 -1
  16. package/build/components/block-editor/index.js +16 -14
  17. package/build/components/block-editor/index.js.map +1 -1
  18. package/build/components/block-editor/inserter-media-categories.js +237 -0
  19. package/build/components/block-editor/inserter-media-categories.js.map +1 -0
  20. package/build/components/canvas-spinner/index.js +20 -0
  21. package/build/components/canvas-spinner/index.js.map +1 -0
  22. package/build/components/create-template-part-modal/index.js +4 -2
  23. package/build/components/create-template-part-modal/index.js.map +1 -1
  24. package/build/components/editor/index.js +9 -5
  25. package/build/components/editor/index.js.map +1 -1
  26. package/build/components/error-boundary/index.js +2 -12
  27. package/build/components/error-boundary/index.js.map +1 -1
  28. package/build/components/error-boundary/warning.js +5 -28
  29. package/build/components/error-boundary/warning.js.map +1 -1
  30. package/build/components/global-styles/block-preview-panel.js +2 -2
  31. package/build/components/global-styles/block-preview-panel.js.map +1 -1
  32. package/build/components/global-styles/border-panel.js +17 -9
  33. package/build/components/global-styles/border-panel.js.map +1 -1
  34. package/build/components/global-styles/color-palette-panel.js +13 -7
  35. package/build/components/global-styles/color-palette-panel.js.map +1 -1
  36. package/build/components/global-styles/context-menu.js +39 -4
  37. package/build/components/global-styles/context-menu.js.map +1 -1
  38. package/build/components/global-styles/custom-css.js +65 -14
  39. package/build/components/global-styles/custom-css.js.map +1 -1
  40. package/build/components/global-styles/dimensions-panel.js +49 -31
  41. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  42. package/build/components/global-styles/global-styles-provider.js +13 -3
  43. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  44. package/build/components/global-styles/gradients-palette-panel.js +17 -11
  45. package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
  46. package/build/components/global-styles/hooks.js +21 -142
  47. package/build/components/global-styles/hooks.js.map +1 -1
  48. package/build/components/global-styles/index.js +0 -28
  49. package/build/components/global-styles/index.js.map +1 -1
  50. package/build/components/global-styles/palette.js +11 -4
  51. package/build/components/global-styles/palette.js.map +1 -1
  52. package/build/components/global-styles/preview.js +18 -15
  53. package/build/components/global-styles/preview.js.map +1 -1
  54. package/build/components/global-styles/screen-background-color.js +27 -13
  55. package/build/components/global-styles/screen-background-color.js.map +1 -1
  56. package/build/components/global-styles/screen-border.js +10 -4
  57. package/build/components/global-styles/screen-border.js.map +1 -1
  58. package/build/components/global-styles/screen-button-color.js +16 -9
  59. package/build/components/global-styles/screen-button-color.js.map +1 -1
  60. package/build/components/global-styles/screen-colors.js +43 -34
  61. package/build/components/global-styles/screen-colors.js.map +1 -1
  62. package/build/components/global-styles/screen-css.js +20 -8
  63. package/build/components/global-styles/screen-css.js.map +1 -1
  64. package/build/components/global-styles/screen-heading-color.js +23 -16
  65. package/build/components/global-styles/screen-heading-color.js.map +1 -1
  66. package/build/components/global-styles/screen-layout.js +3 -3
  67. package/build/components/global-styles/screen-layout.js.map +1 -1
  68. package/build/components/global-styles/screen-link-color.js +18 -11
  69. package/build/components/global-styles/screen-link-color.js.map +1 -1
  70. package/build/components/global-styles/screen-root.js +25 -9
  71. package/build/components/global-styles/screen-root.js.map +1 -1
  72. package/build/components/global-styles/screen-style-variations.js +8 -4
  73. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  74. package/build/components/global-styles/screen-text-color.js +14 -7
  75. package/build/components/global-styles/screen-text-color.js.map +1 -1
  76. package/build/components/global-styles/screen-typography.js +18 -12
  77. package/build/components/global-styles/screen-typography.js.map +1 -1
  78. package/build/components/global-styles/shadow-panel.js +196 -0
  79. package/build/components/global-styles/shadow-panel.js.map +1 -0
  80. package/build/components/global-styles/typography-panel.js +43 -29
  81. package/build/components/global-styles/typography-panel.js.map +1 -1
  82. package/build/components/global-styles/typography-preview.js +19 -9
  83. package/build/components/global-styles/typography-preview.js.map +1 -1
  84. package/build/components/global-styles/ui.js +104 -34
  85. package/build/components/global-styles/ui.js.map +1 -1
  86. package/build/components/global-styles/utils.js +5 -334
  87. package/build/components/global-styles/utils.js.map +1 -1
  88. package/build/components/global-styles-renderer/index.js +7 -5
  89. package/build/components/global-styles-renderer/index.js.map +1 -1
  90. package/build/components/header-edit-mode/document-actions/index.js +2 -2
  91. package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
  92. package/build/components/keyboard-shortcut-help-modal/index.js +0 -1
  93. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  94. package/build/components/layout/index.js +11 -11
  95. package/build/components/layout/index.js.map +1 -1
  96. package/build/components/list/actions/rename-menu-item.js +8 -11
  97. package/build/components/list/actions/rename-menu-item.js.map +1 -1
  98. package/build/components/{sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js → navigation-inspector/index.js} +9 -6
  99. package/build/components/navigation-inspector/index.js.map +1 -0
  100. package/build/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/navigation-menu.js +14 -14
  101. package/build/components/navigation-inspector/navigation-menu.js.map +1 -0
  102. package/build/components/sidebar/index.js +3 -1
  103. package/build/components/sidebar/index.js.map +1 -1
  104. package/build/components/sidebar-edit-mode/global-styles-sidebar.js +3 -18
  105. package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  106. package/build/components/sidebar-edit-mode/index.js +1 -14
  107. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  108. package/build/components/sidebar-navigation-screen/index.js +3 -2
  109. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  110. package/build/components/sidebar-navigation-screen-main/index.js +23 -1
  111. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  112. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +52 -0
  113. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -0
  114. package/build/components/sidebar-navigation-screen-templates/index.js +3 -8
  115. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  116. package/build/components/site-hub/index.js +11 -10
  117. package/build/components/site-hub/index.js.map +1 -1
  118. package/build/components/site-icon/index.js +1 -1
  119. package/build/components/site-icon/index.js.map +1 -1
  120. package/build/components/style-book/index.js +7 -4
  121. package/build/components/style-book/index.js.map +1 -1
  122. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +6 -4
  123. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  124. package/build/components/template-part-converter/convert-to-template-part.js +5 -9
  125. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  126. package/build/experiments.js +19 -0
  127. package/build/experiments.js.map +1 -0
  128. package/build/hooks/push-changes-to-global-styles/index.js +65 -6
  129. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  130. package/build/index.js +53 -60
  131. package/build/index.js.map +1 -1
  132. package/build/store/actions.js +1 -27
  133. package/build/store/actions.js.map +1 -1
  134. package/build/store/index.js +8 -0
  135. package/build/store/index.js.map +1 -1
  136. package/build/store/private-actions.js +40 -0
  137. package/build/store/private-actions.js.map +1 -0
  138. package/build/store/private-selectors.js +18 -0
  139. package/build/store/private-selectors.js.map +1 -0
  140. package/build/store/selectors.js +7 -40
  141. package/build/store/selectors.js.map +1 -1
  142. package/build/store/utils.js +77 -0
  143. package/build/store/utils.js.map +1 -0
  144. package/build/utils/template-part-create.js +71 -0
  145. package/build/utils/template-part-create.js.map +1 -0
  146. package/build-module/components/add-new-template/add-custom-generic-template-modal.js +9 -11
  147. package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +1 -1
  148. package/build-module/components/add-new-template/add-custom-template-modal.js +0 -1
  149. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  150. package/build-module/components/add-new-template/new-template-part.js +8 -31
  151. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  152. package/build-module/components/add-new-template/new-template.js +4 -4
  153. package/build-module/components/add-new-template/new-template.js.map +1 -1
  154. package/build-module/components/add-new-template/utils.js +0 -5
  155. package/build-module/components/add-new-template/utils.js.map +1 -1
  156. package/build-module/components/app/index.js +2 -7
  157. package/build-module/components/app/index.js.map +1 -1
  158. package/build-module/components/block-editor/editor-canvas.js +13 -3
  159. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  160. package/build-module/components/block-editor/index.js +17 -15
  161. package/build-module/components/block-editor/index.js.map +1 -1
  162. package/build-module/components/block-editor/inserter-media-categories.js +225 -0
  163. package/build-module/components/block-editor/inserter-media-categories.js.map +1 -0
  164. package/build-module/components/canvas-spinner/index.js +12 -0
  165. package/build-module/components/canvas-spinner/index.js.map +1 -0
  166. package/build-module/components/create-template-part-modal/index.js +5 -3
  167. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  168. package/build-module/components/editor/index.js +7 -5
  169. package/build-module/components/editor/index.js.map +1 -1
  170. package/build-module/components/error-boundary/index.js +2 -12
  171. package/build-module/components/error-boundary/index.js.map +1 -1
  172. package/build-module/components/error-boundary/warning.js +5 -28
  173. package/build-module/components/error-boundary/warning.js.map +1 -1
  174. package/build-module/components/global-styles/block-preview-panel.js +2 -2
  175. package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
  176. package/build-module/components/global-styles/border-panel.js +17 -11
  177. package/build-module/components/global-styles/border-panel.js.map +1 -1
  178. package/build-module/components/global-styles/color-palette-panel.js +11 -7
  179. package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
  180. package/build-module/components/global-styles/context-menu.js +40 -8
  181. package/build-module/components/global-styles/context-menu.js.map +1 -1
  182. package/build-module/components/global-styles/custom-css.js +61 -15
  183. package/build-module/components/global-styles/custom-css.js.map +1 -1
  184. package/build-module/components/global-styles/dimensions-panel.js +49 -32
  185. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  186. package/build-module/components/global-styles/global-styles-provider.js +7 -2
  187. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  188. package/build-module/components/global-styles/gradients-palette-panel.js +15 -11
  189. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
  190. package/build-module/components/global-styles/hooks.js +23 -134
  191. package/build-module/components/global-styles/hooks.js.map +1 -1
  192. package/build-module/components/global-styles/index.js +0 -2
  193. package/build-module/components/global-styles/index.js.map +1 -1
  194. package/build-module/components/global-styles/palette.js +10 -5
  195. package/build-module/components/global-styles/palette.js.map +1 -1
  196. package/build-module/components/global-styles/preview.js +18 -14
  197. package/build-module/components/global-styles/preview.js.map +1 -1
  198. package/build-module/components/global-styles/screen-background-color.js +26 -15
  199. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  200. package/build-module/components/global-styles/screen-border.js +10 -5
  201. package/build-module/components/global-styles/screen-border.js.map +1 -1
  202. package/build-module/components/global-styles/screen-button-color.js +16 -11
  203. package/build-module/components/global-styles/screen-button-color.js.map +1 -1
  204. package/build-module/components/global-styles/screen-colors.js +43 -37
  205. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  206. package/build-module/components/global-styles/screen-css.js +21 -9
  207. package/build-module/components/global-styles/screen-css.js.map +1 -1
  208. package/build-module/components/global-styles/screen-heading-color.js +23 -18
  209. package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
  210. package/build-module/components/global-styles/screen-layout.js +4 -4
  211. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  212. package/build-module/components/global-styles/screen-link-color.js +18 -13
  213. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  214. package/build-module/components/global-styles/screen-root.js +23 -9
  215. package/build-module/components/global-styles/screen-root.js.map +1 -1
  216. package/build-module/components/global-styles/screen-style-variations.js +5 -2
  217. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  218. package/build-module/components/global-styles/screen-text-color.js +14 -9
  219. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  220. package/build-module/components/global-styles/screen-typography.js +16 -12
  221. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  222. package/build-module/components/global-styles/shadow-panel.js +177 -0
  223. package/build-module/components/global-styles/shadow-panel.js.map +1 -0
  224. package/build-module/components/global-styles/typography-panel.js +43 -31
  225. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  226. package/build-module/components/global-styles/typography-preview.js +17 -9
  227. package/build-module/components/global-styles/typography-preview.js.map +1 -1
  228. package/build-module/components/global-styles/ui.js +98 -35
  229. package/build-module/components/global-styles/ui.js.map +1 -1
  230. package/build-module/components/global-styles/utils.js +4 -319
  231. package/build-module/components/global-styles/utils.js.map +1 -1
  232. package/build-module/components/global-styles-renderer/index.js +5 -5
  233. package/build-module/components/global-styles-renderer/index.js.map +1 -1
  234. package/build-module/components/header-edit-mode/document-actions/index.js +2 -2
  235. package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
  236. package/build-module/components/keyboard-shortcut-help-modal/index.js +0 -1
  237. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  238. package/build-module/components/layout/index.js +10 -11
  239. package/build-module/components/layout/index.js.map +1 -1
  240. package/build-module/components/list/actions/rename-menu-item.js +9 -12
  241. package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
  242. package/build-module/components/{sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js → navigation-inspector/index.js} +9 -6
  243. package/build-module/components/navigation-inspector/index.js.map +1 -0
  244. package/build-module/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/navigation-menu.js +14 -15
  245. package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -0
  246. package/build-module/components/sidebar/index.js +2 -1
  247. package/build-module/components/sidebar/index.js.map +1 -1
  248. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +6 -21
  249. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  250. package/build-module/components/sidebar-edit-mode/index.js +1 -13
  251. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  252. package/build-module/components/sidebar-navigation-screen/index.js +3 -2
  253. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  254. package/build-module/components/sidebar-navigation-screen-main/index.js +22 -2
  255. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  256. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +40 -0
  257. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -0
  258. package/build-module/components/sidebar-navigation-screen-templates/index.js +4 -9
  259. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  260. package/build-module/components/site-hub/index.js +10 -10
  261. package/build-module/components/site-hub/index.js.map +1 -1
  262. package/build-module/components/site-icon/index.js +1 -1
  263. package/build-module/components/site-icon/index.js.map +1 -1
  264. package/build-module/components/style-book/index.js +8 -5
  265. package/build-module/components/style-book/index.js.map +1 -1
  266. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +5 -4
  267. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  268. package/build-module/components/template-part-converter/convert-to-template-part.js +5 -9
  269. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  270. package/build-module/experiments.js +9 -0
  271. package/build-module/experiments.js.map +1 -0
  272. package/build-module/hooks/push-changes-to-global-styles/index.js +62 -3
  273. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  274. package/build-module/index.js +52 -60
  275. package/build-module/index.js.map +1 -1
  276. package/build-module/store/actions.js +0 -23
  277. package/build-module/store/actions.js.map +1 -1
  278. package/build-module/store/index.js +5 -0
  279. package/build-module/store/index.js.map +1 -1
  280. package/build-module/store/private-actions.js +29 -0
  281. package/build-module/store/private-actions.js.map +1 -0
  282. package/build-module/store/private-selectors.js +11 -0
  283. package/build-module/store/private-selectors.js.map +1 -0
  284. package/build-module/store/selectors.js +6 -37
  285. package/build-module/store/selectors.js.map +1 -1
  286. package/build-module/store/utils.js +66 -0
  287. package/build-module/store/utils.js.map +1 -0
  288. package/build-module/utils/template-part-create.js +53 -0
  289. package/build-module/utils/template-part-create.js.map +1 -0
  290. package/build-style/style-rtl.css +314 -216
  291. package/build-style/style.css +314 -216
  292. package/package.json +32 -30
  293. package/src/components/add-new-template/add-custom-generic-template-modal.js +20 -28
  294. package/src/components/add-new-template/add-custom-template-modal.js +0 -1
  295. package/src/components/add-new-template/new-template-part.js +14 -34
  296. package/src/components/add-new-template/new-template.js +5 -3
  297. package/src/components/add-new-template/style.scss +0 -4
  298. package/src/components/add-new-template/utils.js +0 -14
  299. package/src/components/app/index.js +2 -2
  300. package/src/components/block-editor/editor-canvas.js +12 -2
  301. package/src/components/block-editor/index.js +16 -28
  302. package/src/components/block-editor/inserter-media-categories.js +247 -0
  303. package/src/components/block-editor/style.scss +20 -7
  304. package/src/components/canvas-spinner/index.js +12 -0
  305. package/src/components/canvas-spinner/style.scss +7 -0
  306. package/src/components/create-template-part-modal/index.js +75 -67
  307. package/src/components/create-template-part-modal/style.scss +0 -10
  308. package/src/components/editor/index.js +8 -5
  309. package/src/components/error-boundary/index.js +2 -10
  310. package/src/components/error-boundary/warning.js +6 -35
  311. package/src/components/global-styles/README.md +1 -75
  312. package/src/components/global-styles/block-preview-panel.js +2 -2
  313. package/src/components/global-styles/border-panel.js +19 -17
  314. package/src/components/global-styles/color-palette-panel.js +10 -7
  315. package/src/components/global-styles/context-menu.js +114 -44
  316. package/src/components/global-styles/custom-css.js +76 -19
  317. package/src/components/global-styles/dimensions-panel.js +46 -36
  318. package/src/components/global-styles/global-styles-provider.js +6 -2
  319. package/src/components/global-styles/gradients-palette-panel.js +17 -11
  320. package/src/components/global-styles/hooks.js +31 -155
  321. package/src/components/global-styles/index.js +0 -2
  322. package/src/components/global-styles/palette.js +9 -5
  323. package/src/components/global-styles/preview.js +19 -13
  324. package/src/components/global-styles/screen-background-color.js +37 -21
  325. package/src/components/global-styles/screen-border.js +10 -5
  326. package/src/components/global-styles/screen-button-color.js +21 -19
  327. package/src/components/global-styles/screen-colors.js +48 -65
  328. package/src/components/global-styles/screen-css.js +30 -14
  329. package/src/components/global-styles/screen-heading-color.js +32 -27
  330. package/src/components/global-styles/screen-layout.js +4 -7
  331. package/src/components/global-styles/screen-link-color.js +26 -26
  332. package/src/components/global-styles/screen-root.js +24 -9
  333. package/src/components/global-styles/screen-style-variations.js +7 -2
  334. package/src/components/global-styles/screen-text-color.js +15 -19
  335. package/src/components/global-styles/screen-typography.js +27 -12
  336. package/src/components/global-styles/shadow-panel.js +174 -0
  337. package/src/components/global-styles/style.scss +85 -1
  338. package/src/components/global-styles/typography-panel.js +60 -48
  339. package/src/components/global-styles/typography-preview.js +28 -9
  340. package/src/components/global-styles/ui.js +97 -53
  341. package/src/components/global-styles/utils.js +4 -371
  342. package/src/components/global-styles-renderer/index.js +3 -4
  343. package/src/components/header-edit-mode/document-actions/index.js +1 -1
  344. package/src/components/keyboard-shortcut-help-modal/index.js +0 -1
  345. package/src/components/layout/index.js +12 -4
  346. package/src/components/layout/style.scss +4 -5
  347. package/src/components/list/actions/rename-menu-item.js +14 -23
  348. package/src/components/list/style.scss +0 -4
  349. package/src/components/{sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js → navigation-inspector/index.js} +2 -2
  350. package/src/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/navigation-menu.js +10 -12
  351. package/src/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/style.scss +0 -17
  352. package/src/components/sidebar/index.js +2 -0
  353. package/src/components/sidebar-edit-mode/global-styles-sidebar.js +8 -32
  354. package/src/components/sidebar-edit-mode/index.js +0 -11
  355. package/src/components/sidebar-edit-mode/settings-header/style.scss +8 -0
  356. package/src/components/sidebar-navigation-item/style.scss +28 -3
  357. package/src/components/sidebar-navigation-screen/index.js +4 -3
  358. package/src/components/sidebar-navigation-screen/style.scss +2 -0
  359. package/src/components/sidebar-navigation-screen-main/index.js +23 -1
  360. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +45 -0
  361. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +12 -0
  362. package/src/components/sidebar-navigation-screen-templates/index.js +12 -19
  363. package/src/components/site-hub/index.js +8 -10
  364. package/src/components/site-hub/style.scss +7 -1
  365. package/src/components/site-icon/index.js +1 -1
  366. package/src/components/site-icon/style.scss +2 -2
  367. package/src/components/style-book/index.js +10 -5
  368. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +4 -3
  369. package/src/components/template-part-converter/convert-to-template-part.js +12 -10
  370. package/src/experiments.js +10 -0
  371. package/src/hooks/push-changes-to-global-styles/index.js +63 -5
  372. package/src/index.js +51 -59
  373. package/src/store/actions.js +0 -24
  374. package/src/store/index.js +5 -0
  375. package/src/store/private-actions.js +29 -0
  376. package/src/store/private-selectors.js +10 -0
  377. package/src/store/selectors.js +6 -37
  378. package/src/store/test/utils.js +181 -0
  379. package/src/store/utils.js +69 -0
  380. package/src/style.scss +4 -2
  381. package/src/utils/template-part-create.js +62 -0
  382. package/src/utils/test/template-part-create.js +63 -0
  383. package/build/components/global-styles/context.js +0 -22
  384. package/build/components/global-styles/context.js.map +0 -1
  385. package/build/components/global-styles/typography-utils.js +0 -92
  386. package/build/components/global-styles/typography-utils.js.map +0 -1
  387. package/build/components/global-styles/use-global-styles-output.js +0 -943
  388. package/build/components/global-styles/use-global-styles-output.js.map +0 -1
  389. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/index.js +0 -42
  390. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/index.js.map +0 -1
  391. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +0 -1
  392. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +0 -1
  393. package/build-module/components/global-styles/context.js +0 -12
  394. package/build-module/components/global-styles/context.js.map +0 -1
  395. package/build-module/components/global-styles/typography-utils.js +0 -84
  396. package/build-module/components/global-styles/typography-utils.js.map +0 -1
  397. package/build-module/components/global-styles/use-global-styles-output.js +0 -901
  398. package/build-module/components/global-styles/use-global-styles-output.js.map +0 -1
  399. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/index.js +0 -28
  400. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/index.js.map +0 -1
  401. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +0 -1
  402. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +0 -1
  403. package/src/components/global-styles/context.js +0 -15
  404. package/src/components/global-styles/test/typography-utils.js +0 -393
  405. package/src/components/global-styles/test/use-global-styles-output.js +0 -814
  406. package/src/components/global-styles/test/utils.js +0 -206
  407. package/src/components/global-styles/typography-utils.js +0 -87
  408. package/src/components/global-styles/use-global-styles-output.js +0 -1059
  409. package/src/components/sidebar-edit-mode/navigation-menu-sidebar/index.js +0 -37
@@ -18,15 +18,19 @@ import {
18
18
  } from '@wordpress/components';
19
19
  import {
20
20
  __experimentalUseCustomSides as useCustomSides,
21
- __experimentalHeightControl as HeightControl,
21
+ HeightControl,
22
22
  __experimentalSpacingSizesControl as SpacingSizesControl,
23
+ experiments as blockEditorExperiments,
23
24
  } from '@wordpress/block-editor';
24
25
  import { Icon, positionCenter, stretchWide } from '@wordpress/icons';
25
26
 
26
27
  /**
27
28
  * Internal dependencies
28
29
  */
29
- import { getSupportedGlobalStylesPanels, useSetting, useStyle } from './hooks';
30
+ import { getSupportedGlobalStylesPanels } from './hooks';
31
+ import { unlock } from '../../experiments';
32
+
33
+ const { useGlobalSetting, useGlobalStyle } = unlock( blockEditorExperiments );
30
34
 
31
35
  const AXIAL_SIDES = [ 'horizontal', 'vertical' ];
32
36
 
@@ -50,50 +54,52 @@ export function useHasDimensionsPanel( name ) {
50
54
 
51
55
  function useHasContentSize( name ) {
52
56
  const supports = getSupportedGlobalStylesPanels( name );
53
- const [ settings ] = useSetting( 'layout.contentSize', name );
57
+ const [ settings ] = useGlobalSetting( 'layout.contentSize', name );
54
58
 
55
59
  return settings && supports.includes( 'contentSize' );
56
60
  }
57
61
 
58
62
  function useHasWideSize( name ) {
59
63
  const supports = getSupportedGlobalStylesPanels( name );
60
- const [ settings ] = useSetting( 'layout.wideSize', name );
64
+ const [ settings ] = useGlobalSetting( 'layout.wideSize', name );
61
65
 
62
66
  return settings && supports.includes( 'wideSize' );
63
67
  }
64
68
 
65
69
  function useHasPadding( name ) {
66
70
  const supports = getSupportedGlobalStylesPanels( name );
67
- const [ settings ] = useSetting( 'spacing.padding', name );
71
+ const [ settings ] = useGlobalSetting( 'spacing.padding', name );
68
72
 
69
73
  return settings && supports.includes( 'padding' );
70
74
  }
71
75
 
72
76
  function useHasMargin( name ) {
73
77
  const supports = getSupportedGlobalStylesPanels( name );
74
- const [ settings ] = useSetting( 'spacing.margin', name );
78
+ const [ settings ] = useGlobalSetting( 'spacing.margin', name );
75
79
 
76
80
  return settings && supports.includes( 'margin' );
77
81
  }
78
82
 
79
83
  function useHasGap( name ) {
80
84
  const supports = getSupportedGlobalStylesPanels( name );
81
- const [ settings ] = useSetting( 'spacing.blockGap', name );
85
+ const [ settings ] = useGlobalSetting( 'spacing.blockGap', name );
82
86
 
83
87
  return settings && supports.includes( 'blockGap' );
84
88
  }
85
89
 
86
90
  function useHasMinHeight( name ) {
87
91
  const supports = getSupportedGlobalStylesPanels( name );
88
- const [ settings ] = useSetting( 'dimensions.minHeight', name );
92
+ const [ settings ] = useGlobalSetting( 'dimensions.minHeight', name );
89
93
 
90
94
  return settings && supports.includes( 'minHeight' );
91
95
  }
92
96
 
93
97
  function useHasSpacingPresets() {
94
- const [ settings ] = useSetting( 'spacing.spacingSizes' );
98
+ const [ settings ] = useGlobalSetting( 'spacing.spacingSizes' );
99
+ const { custom, theme, default: defaultPresets } = settings || {};
100
+ const presets = custom ?? theme ?? defaultPresets ?? [];
95
101
 
96
- return settings && settings.length > 0;
102
+ return settings && presets.length > 0;
97
103
  }
98
104
 
99
105
  function filterValuesBySides( values, sides ) {
@@ -156,11 +162,11 @@ function splitGapValue( value ) {
156
162
 
157
163
  // Props for managing `layout.contentSize`.
158
164
  function useContentSizeProps( name ) {
159
- const [ contentSizeValue, setContentSizeValue ] = useSetting(
165
+ const [ contentSizeValue, setContentSizeValue ] = useGlobalSetting(
160
166
  'layout.contentSize',
161
167
  name
162
168
  );
163
- const [ userSetContentSizeValue ] = useSetting(
169
+ const [ userSetContentSizeValue ] = useGlobalSetting(
164
170
  'layout.contentSize',
165
171
  name,
166
172
  'user'
@@ -177,11 +183,11 @@ function useContentSizeProps( name ) {
177
183
 
178
184
  // Props for managing `layout.wideSize`.
179
185
  function useWideSizeProps( name ) {
180
- const [ wideSizeValue, setWideSizeValue ] = useSetting(
186
+ const [ wideSizeValue, setWideSizeValue ] = useGlobalSetting(
181
187
  'layout.wideSize',
182
188
  name
183
189
  );
184
- const [ userSetWideSizeValue ] = useSetting(
190
+ const [ userSetWideSizeValue ] = useGlobalSetting(
185
191
  'layout.wideSize',
186
192
  name,
187
193
  'user'
@@ -197,9 +203,10 @@ function useWideSizeProps( name ) {
197
203
  }
198
204
 
199
205
  // Props for managing `spacing.padding`.
200
- function usePaddingProps( name, variationPath = '' ) {
201
- const [ rawPadding, setRawPadding ] = useStyle(
202
- variationPath + 'spacing.padding',
206
+ function usePaddingProps( name, variation = '' ) {
207
+ const prefix = variation ? `variations.${ variation }.` : '';
208
+ const [ rawPadding, setRawPadding ] = useGlobalStyle(
209
+ prefix + 'spacing.padding',
203
210
  name
204
211
  );
205
212
  const paddingValues = splitStyleValue( rawPadding );
@@ -213,8 +220,8 @@ function usePaddingProps( name, variationPath = '' ) {
213
220
  setRawPadding( padding );
214
221
  };
215
222
  const resetPaddingValue = () => setPaddingValues( {} );
216
- const [ userSetPaddingValue ] = useStyle(
217
- variationPath + 'spacing.padding',
223
+ const [ userSetPaddingValue ] = useGlobalStyle(
224
+ prefix + 'spacing.padding',
218
225
  name,
219
226
  'user'
220
227
  );
@@ -232,9 +239,10 @@ function usePaddingProps( name, variationPath = '' ) {
232
239
  }
233
240
 
234
241
  // Props for managing `spacing.margin`.
235
- function useMarginProps( name, variationPath = '' ) {
236
- const [ rawMargin, setRawMargin ] = useStyle(
237
- variationPath + 'spacing.margin',
242
+ function useMarginProps( name, variation = '' ) {
243
+ const prefix = variation ? `variations.${ variation }.` : '';
244
+ const [ rawMargin, setRawMargin ] = useGlobalStyle(
245
+ prefix + 'spacing.margin',
238
246
  name
239
247
  );
240
248
  const marginValues = splitStyleValue( rawMargin );
@@ -262,9 +270,10 @@ function useMarginProps( name, variationPath = '' ) {
262
270
  }
263
271
 
264
272
  // Props for managing `spacing.blockGap`.
265
- function useBlockGapProps( name, variationPath = '' ) {
266
- const [ gapValue, setGapValue ] = useStyle(
267
- variationPath + 'spacing.blockGap',
273
+ function useBlockGapProps( name, variation = '' ) {
274
+ const prefix = variation ? `variations.${ variation }.` : '';
275
+ const [ gapValue, setGapValue ] = useGlobalStyle(
276
+ prefix + 'spacing.blockGap',
268
277
  name
269
278
  );
270
279
  const gapValues = splitGapValue( gapValue );
@@ -272,8 +281,8 @@ function useBlockGapProps( name, variationPath = '' ) {
272
281
  const isAxialGap =
273
282
  gapSides && gapSides.some( ( side ) => AXIAL_SIDES.includes( side ) );
274
283
  const resetGapValue = () => setGapValue( undefined );
275
- const [ userSetGapValue ] = useStyle(
276
- variationPath + 'spacing.blockGap',
284
+ const [ userSetGapValue ] = useGlobalStyle(
285
+ prefix + 'spacing.blockGap',
277
286
  name,
278
287
  'user'
279
288
  );
@@ -305,9 +314,10 @@ function useBlockGapProps( name, variationPath = '' ) {
305
314
  }
306
315
 
307
316
  // Props for managing `dimensions.minHeight`.
308
- function useMinHeightProps( name, variationPath = '' ) {
309
- const [ minHeightValue, setMinHeightValue ] = useStyle(
310
- variationPath + 'dimensions.minHeight',
317
+ function useMinHeightProps( name, variation = '' ) {
318
+ const prefix = variation ? `variations.${ variation }.` : '';
319
+ const [ minHeightValue, setMinHeightValue ] = useGlobalStyle(
320
+ prefix + 'dimensions.minHeight',
311
321
  name
312
322
  );
313
323
  const resetMinHeightValue = () => setMinHeightValue( undefined );
@@ -320,7 +330,7 @@ function useMinHeightProps( name, variationPath = '' ) {
320
330
  };
321
331
  }
322
332
 
323
- export default function DimensionsPanel( { name, variationPath = '' } ) {
333
+ export default function DimensionsPanel( { name, variation = '' } ) {
324
334
  const showContentSizeControl = useHasContentSize( name );
325
335
  const showWideSizeControl = useHasWideSize( name );
326
336
  const showPaddingControl = useHasPadding( name );
@@ -329,7 +339,7 @@ export default function DimensionsPanel( { name, variationPath = '' } ) {
329
339
  const showMinHeightControl = useHasMinHeight( name );
330
340
  const showSpacingPresetsControl = useHasSpacingPresets();
331
341
  const units = useCustomUnits( {
332
- availableUnits: useSetting( 'spacing.units', name )[ 0 ] || [
342
+ availableUnits: useGlobalSetting( 'spacing.units', name )[ 0 ] || [
333
343
  '%',
334
344
  'px',
335
345
  'em',
@@ -362,7 +372,7 @@ export default function DimensionsPanel( { name, variationPath = '' } ) {
362
372
  setPaddingValues,
363
373
  resetPaddingValue,
364
374
  hasPaddingValue,
365
- } = usePaddingProps( name, variationPath );
375
+ } = usePaddingProps( name, variation );
366
376
 
367
377
  // Props for managing `spacing.margin`.
368
378
  const {
@@ -372,7 +382,7 @@ export default function DimensionsPanel( { name, variationPath = '' } ) {
372
382
  setMarginValues,
373
383
  resetMarginValue,
374
384
  hasMarginValue,
375
- } = useMarginProps( name, variationPath );
385
+ } = useMarginProps( name, variation );
376
386
 
377
387
  // Props for managing `spacing.blockGap`.
378
388
  const {
@@ -384,7 +394,7 @@ export default function DimensionsPanel( { name, variationPath = '' } ) {
384
394
  setGapValues,
385
395
  resetGapValue,
386
396
  hasGapValue,
387
- } = useBlockGapProps( name, variationPath );
397
+ } = useBlockGapProps( name, variation );
388
398
 
389
399
  // Props for managing `dimensions.minHeight`.
390
400
  const {
@@ -392,7 +402,7 @@ export default function DimensionsPanel( { name, variationPath = '' } ) {
392
402
  setMinHeightValue,
393
403
  resetMinHeightValue,
394
404
  hasMinHeightValue,
395
- } = useMinHeightProps( name, variationPath );
405
+ } = useMinHeightProps( name, variation );
396
406
 
397
407
  const resetAll = () => {
398
408
  resetPaddingValue();
@@ -9,11 +9,15 @@ import { mergeWith, isEmpty, mapValues } from 'lodash';
9
9
  import { useMemo, useCallback } from '@wordpress/element';
10
10
  import { useSelect, useDispatch } from '@wordpress/data';
11
11
  import { store as coreStore } from '@wordpress/core-data';
12
+ import { experiments as blockEditorExperiments } from '@wordpress/block-editor';
12
13
 
13
14
  /**
14
15
  * Internal dependencies
15
16
  */
16
- import { GlobalStylesContext } from './context';
17
+ import CanvasSpinner from '../canvas-spinner';
18
+ import { unlock } from '../../experiments';
19
+
20
+ const { GlobalStylesContext } = unlock( blockEditorExperiments );
17
21
 
18
22
  function mergeTreesCustomizer( _, srcValue ) {
19
23
  // We only pass as arrays the presets,
@@ -165,7 +169,7 @@ function useGlobalStylesContext() {
165
169
  export function GlobalStylesProvider( { children } ) {
166
170
  const context = useGlobalStylesContext();
167
171
  if ( ! context.isReady ) {
168
- return null;
172
+ return <CanvasSpinner />;
169
173
  }
170
174
 
171
175
  return (
@@ -8,48 +8,54 @@ import {
8
8
  DuotonePicker,
9
9
  } from '@wordpress/components';
10
10
  import { __ } from '@wordpress/i18n';
11
+ import { experiments as blockEditorExperiments } from '@wordpress/block-editor';
11
12
 
12
13
  /**
13
14
  * Internal dependencies
14
15
  */
15
- import { useSetting } from './hooks';
16
16
  import Subtitle from './subtitle';
17
+ import { unlock } from '../../experiments';
18
+
19
+ const { useGlobalSetting } = unlock( blockEditorExperiments );
17
20
 
18
21
  const noop = () => {};
19
22
 
20
23
  export default function GradientPalettePanel( { name } ) {
21
- const [ themeGradients, setThemeGradients ] = useSetting(
24
+ const [ themeGradients, setThemeGradients ] = useGlobalSetting(
22
25
  'color.gradients.theme',
23
26
  name
24
27
  );
25
- const [ baseThemeGradients ] = useSetting(
28
+ const [ baseThemeGradients ] = useGlobalSetting(
26
29
  'color.gradients.theme',
27
30
  name,
28
31
  'base'
29
32
  );
30
- const [ defaultGradients, setDefaultGradients ] = useSetting(
33
+ const [ defaultGradients, setDefaultGradients ] = useGlobalSetting(
31
34
  'color.gradients.default',
32
35
  name
33
36
  );
34
- const [ baseDefaultGradients ] = useSetting(
37
+ const [ baseDefaultGradients ] = useGlobalSetting(
35
38
  'color.gradients.default',
36
39
  name,
37
40
  'base'
38
41
  );
39
- const [ customGradients, setCustomGradients ] = useSetting(
42
+ const [ customGradients, setCustomGradients ] = useGlobalSetting(
40
43
  'color.gradients.custom',
41
44
  name
42
45
  );
43
46
 
44
- const [ defaultPaletteEnabled ] = useSetting(
47
+ const [ defaultPaletteEnabled ] = useGlobalSetting(
45
48
  'color.defaultGradients',
46
49
  name
47
50
  );
48
51
 
49
- const [ customDuotone ] = useSetting( 'color.duotone.custom' ) || [];
50
- const [ defaultDuotone ] = useSetting( 'color.duotone.default' ) || [];
51
- const [ themeDuotone ] = useSetting( 'color.duotone.theme' ) || [];
52
- const [ defaultDuotoneEnabled ] = useSetting( 'color.defaultDuotone' );
52
+ const [ customDuotone ] = useGlobalSetting( 'color.duotone.custom' ) || [];
53
+ const [ defaultDuotone ] =
54
+ useGlobalSetting( 'color.duotone.default' ) || [];
55
+ const [ themeDuotone ] = useGlobalSetting( 'color.duotone.theme' ) || [];
56
+ const [ defaultDuotoneEnabled ] = useGlobalSetting(
57
+ 'color.defaultDuotone'
58
+ );
53
59
 
54
60
  const duotonePalette = [
55
61
  ...( customDuotone || [] ),
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import fastDeepEqual from 'fast-deep-equal/es6';
5
- import { get, set } from 'lodash';
4
+ import { get } from 'lodash';
6
5
  import { colord, extend } from 'colord';
7
6
  import a11yPlugin from 'colord/plugins/a11y';
8
7
 
@@ -10,162 +9,23 @@ import a11yPlugin from 'colord/plugins/a11y';
10
9
  * WordPress dependencies
11
10
  */
12
11
  import { _x } from '@wordpress/i18n';
13
- import { useContext, useCallback, useMemo } from '@wordpress/element';
12
+ import { useMemo } from '@wordpress/element';
14
13
  import {
15
14
  getBlockType,
16
- __EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,
17
15
  __EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,
18
16
  } from '@wordpress/blocks';
17
+ import { experiments as blockEditorExperiments } from '@wordpress/block-editor';
19
18
 
20
19
  /**
21
20
  * Internal dependencies
22
21
  */
23
- import { getValueFromVariable, getPresetVariableFromValue } from './utils';
24
- import { GlobalStylesContext } from './context';
22
+ import { unlock } from '../../experiments';
23
+
24
+ const { useGlobalSetting } = unlock( blockEditorExperiments );
25
25
 
26
26
  // Enable colord's a11y plugin.
27
27
  extend( [ a11yPlugin ] );
28
28
 
29
- const EMPTY_CONFIG = { settings: {}, styles: {} };
30
-
31
- export const useGlobalStylesReset = () => {
32
- const { user: config, setUserConfig } = useContext( GlobalStylesContext );
33
- const canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );
34
- return [
35
- canReset,
36
- useCallback(
37
- () => setUserConfig( () => EMPTY_CONFIG ),
38
- [ setUserConfig ]
39
- ),
40
- ];
41
- };
42
-
43
- export function useSetting( path, blockName, source = 'all' ) {
44
- const {
45
- merged: mergedConfig,
46
- base: baseConfig,
47
- user: userConfig,
48
- setUserConfig,
49
- } = useContext( GlobalStylesContext );
50
-
51
- const fullPath = ! blockName
52
- ? `settings.${ path }`
53
- : `settings.blocks.${ blockName }.${ path }`;
54
-
55
- const setSetting = ( newValue ) => {
56
- setUserConfig( ( currentConfig ) => {
57
- // Deep clone `currentConfig` to avoid mutating it later.
58
- const newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );
59
- const pathToSet = PATHS_WITH_MERGE[ path ]
60
- ? fullPath + '.custom'
61
- : fullPath;
62
- set( newUserConfig, pathToSet, newValue );
63
-
64
- return newUserConfig;
65
- } );
66
- };
67
-
68
- const getSettingValueForContext = ( name ) => {
69
- const currentPath = ! name
70
- ? `settings.${ path }`
71
- : `settings.blocks.${ name }.${ path }`;
72
-
73
- const getSettingValue = ( configToUse ) => {
74
- const result = get( configToUse, currentPath );
75
- if ( PATHS_WITH_MERGE[ path ] ) {
76
- return result?.custom ?? result?.theme ?? result?.default;
77
- }
78
- return result;
79
- };
80
-
81
- let result;
82
- switch ( source ) {
83
- case 'all':
84
- result = getSettingValue( mergedConfig );
85
- break;
86
- case 'user':
87
- result = getSettingValue( userConfig );
88
- break;
89
- case 'base':
90
- result = getSettingValue( baseConfig );
91
- break;
92
- default:
93
- throw 'Unsupported source';
94
- }
95
-
96
- return result;
97
- };
98
-
99
- // Unlike styles settings get inherited from top level settings.
100
- const resultWithFallback =
101
- getSettingValueForContext( blockName ) ?? getSettingValueForContext();
102
-
103
- return [ resultWithFallback, setSetting ];
104
- }
105
-
106
- export function useStyle( path, blockName, source = 'all' ) {
107
- const {
108
- merged: mergedConfig,
109
- base: baseConfig,
110
- user: userConfig,
111
- setUserConfig,
112
- } = useContext( GlobalStylesContext );
113
- const finalPath = ! blockName
114
- ? `styles.${ path }`
115
- : `styles.blocks.${ blockName }.${ path }`;
116
-
117
- const setStyle = ( newValue ) => {
118
- setUserConfig( ( currentConfig ) => {
119
- // Deep clone `currentConfig` to avoid mutating it later.
120
- const newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );
121
- set(
122
- newUserConfig,
123
- finalPath,
124
- getPresetVariableFromValue(
125
- mergedConfig.settings,
126
- blockName,
127
- path,
128
- newValue
129
- )
130
- );
131
- return newUserConfig;
132
- } );
133
- };
134
-
135
- let result;
136
- switch ( source ) {
137
- case 'all':
138
- result = getValueFromVariable(
139
- mergedConfig,
140
- blockName,
141
- // The stlyes.css path is allowed to be empty, so don't revert to base if undefined.
142
- finalPath === 'styles.css'
143
- ? get( userConfig, finalPath )
144
- : get( userConfig, finalPath ) ??
145
- get( baseConfig, finalPath )
146
- );
147
- break;
148
- case 'user':
149
- result = getValueFromVariable(
150
- mergedConfig,
151
- blockName,
152
- get( userConfig, finalPath )
153
- );
154
- break;
155
- case 'base':
156
- result = getValueFromVariable(
157
- baseConfig,
158
- blockName,
159
- get( baseConfig, finalPath )
160
- );
161
- break;
162
- default:
163
- throw 'Unsupported source';
164
- }
165
-
166
- return [ result, setStyle ];
167
- }
168
-
169
29
  const ROOT_BLOCK_SUPPORTS = [
170
30
  'background',
171
31
  'backgroundColor',
@@ -211,6 +71,11 @@ export function getSupportedGlobalStylesPanels( name ) {
211
71
  supportKeys.push( 'blockGap' );
212
72
  }
213
73
 
74
+ // check for shadow support
75
+ if ( blockType?.supports?.shadow ) {
76
+ supportKeys.push( 'shadow' );
77
+ }
78
+
214
79
  Object.keys( STYLE_PROPERTY ).forEach( ( styleName ) => {
215
80
  if ( ! STYLE_PROPERTY[ styleName ].support ) {
216
81
  return;
@@ -247,10 +112,12 @@ export function getSupportedGlobalStylesPanels( name ) {
247
112
  }
248
113
 
249
114
  export function useColorsPerOrigin( name ) {
250
- const [ customColors ] = useSetting( 'color.palette.custom', name );
251
- const [ themeColors ] = useSetting( 'color.palette.theme', name );
252
- const [ defaultColors ] = useSetting( 'color.palette.default', name );
253
- const [ shouldDisplayDefaultColors ] = useSetting( 'color.defaultPalette' );
115
+ const [ customColors ] = useGlobalSetting( 'color.palette.custom', name );
116
+ const [ themeColors ] = useGlobalSetting( 'color.palette.theme', name );
117
+ const [ defaultColors ] = useGlobalSetting( 'color.palette.default', name );
118
+ const [ shouldDisplayDefaultColors ] = useGlobalSetting(
119
+ 'color.defaultPalette'
120
+ );
254
121
 
255
122
  return useMemo( () => {
256
123
  const result = [];
@@ -290,10 +157,19 @@ export function useColorsPerOrigin( name ) {
290
157
  }
291
158
 
292
159
  export function useGradientsPerOrigin( name ) {
293
- const [ customGradients ] = useSetting( 'color.gradients.custom', name );
294
- const [ themeGradients ] = useSetting( 'color.gradients.theme', name );
295
- const [ defaultGradients ] = useSetting( 'color.gradients.default', name );
296
- const [ shouldDisplayDefaultGradients ] = useSetting(
160
+ const [ customGradients ] = useGlobalSetting(
161
+ 'color.gradients.custom',
162
+ name
163
+ );
164
+ const [ themeGradients ] = useGlobalSetting(
165
+ 'color.gradients.theme',
166
+ name
167
+ );
168
+ const [ defaultGradients ] = useGlobalSetting(
169
+ 'color.gradients.default',
170
+ name
171
+ );
172
+ const [ shouldDisplayDefaultGradients ] = useGlobalSetting(
297
173
  'color.defaultGradients'
298
174
  );
299
175
 
@@ -335,7 +211,7 @@ export function useGradientsPerOrigin( name ) {
335
211
  }
336
212
 
337
213
  export function useColorRandomizer( name ) {
338
- const [ themeColors, setThemeColors ] = useSetting(
214
+ const [ themeColors, setThemeColors ] = useGlobalSetting(
339
215
  'color.palette.theme',
340
216
  name
341
217
  );
@@ -1,3 +1 @@
1
1
  export { default as GlobalStylesUI } from './ui';
2
- export { useGlobalStylesReset, useStyle, useSetting } from './hooks';
3
- export { useGlobalStylesOutput } from './use-global-styles-output';
@@ -13,23 +13,27 @@ import {
13
13
  import { __, _n, sprintf } from '@wordpress/i18n';
14
14
  import { shuffle } from '@wordpress/icons';
15
15
  import { useMemo } from '@wordpress/element';
16
+ import { experiments as blockEditorExperiments } from '@wordpress/block-editor';
16
17
 
17
18
  /**
18
19
  * Internal dependencies
19
20
  */
20
21
  import Subtitle from './subtitle';
21
22
  import { NavigationButtonAsItem } from './navigation-button';
22
- import { useColorRandomizer, useSetting } from './hooks';
23
+ import { useColorRandomizer } from './hooks';
23
24
  import ColorIndicatorWrapper from './color-indicator-wrapper';
25
+ import { unlock } from '../../experiments';
26
+
27
+ const { useGlobalSetting } = unlock( blockEditorExperiments );
24
28
 
25
29
  const EMPTY_COLORS = [];
26
30
 
27
31
  function Palette( { name } ) {
28
- const [ customColors ] = useSetting( 'color.palette.custom' );
29
- const [ themeColors ] = useSetting( 'color.palette.theme' );
30
- const [ defaultColors ] = useSetting( 'color.palette.default' );
32
+ const [ customColors ] = useGlobalSetting( 'color.palette.custom' );
33
+ const [ themeColors ] = useGlobalSetting( 'color.palette.theme' );
34
+ const [ defaultColors ] = useGlobalSetting( 'color.palette.default' );
31
35
 
32
- const [ defaultPaletteEnabled ] = useSetting(
36
+ const [ defaultPaletteEnabled ] = useGlobalSetting(
33
37
  'color.defaultPalette',
34
38
  name
35
39
  );
@@ -4,6 +4,7 @@
4
4
  import {
5
5
  __unstableIframe as Iframe,
6
6
  __unstableEditorStyles as EditorStyles,
7
+ experiments as blockEditorExperiments,
7
8
  } from '@wordpress/block-editor';
8
9
  import {
9
10
  __unstableMotion as motion,
@@ -16,8 +17,11 @@ import { useState, useMemo } from '@wordpress/element';
16
17
  /**
17
18
  * Internal dependencies
18
19
  */
19
- import { useSetting, useStyle } from './hooks';
20
- import { useGlobalStylesOutput } from './use-global-styles-output';
20
+ import { unlock } from '../../experiments';
21
+
22
+ const { useGlobalSetting, useGlobalStyle, useGlobalStylesOutput } = unlock(
23
+ blockEditorExperiments
24
+ );
21
25
 
22
26
  const firstFrame = {
23
27
  start: {
@@ -56,23 +60,25 @@ const normalizedHeight = 152;
56
60
  const normalizedColorSwatchSize = 32;
57
61
 
58
62
  const StylesPreview = ( { label, isFocused, withHoverView } ) => {
59
- const [ fontWeight ] = useStyle( 'typography.fontWeight' );
60
- const [ fontFamily = 'serif' ] = useStyle( 'typography.fontFamily' );
61
- const [ headingFontFamily = fontFamily ] = useStyle(
63
+ const [ fontWeight ] = useGlobalStyle( 'typography.fontWeight' );
64
+ const [ fontFamily = 'serif' ] = useGlobalStyle( 'typography.fontFamily' );
65
+ const [ headingFontFamily = fontFamily ] = useGlobalStyle(
62
66
  'elements.h1.typography.fontFamily'
63
67
  );
64
- const [ headingFontWeight = fontWeight ] = useStyle(
68
+ const [ headingFontWeight = fontWeight ] = useGlobalStyle(
65
69
  'elements.h1.typography.fontWeight'
66
70
  );
67
- const [ textColor = 'black' ] = useStyle( 'color.text' );
68
- const [ headingColor = textColor ] = useStyle( 'elements.h1.color.text' );
69
- const [ backgroundColor = 'white' ] = useStyle( 'color.background' );
70
- const [ gradientValue ] = useStyle( 'color.gradient' );
71
+ const [ textColor = 'black' ] = useGlobalStyle( 'color.text' );
72
+ const [ headingColor = textColor ] = useGlobalStyle(
73
+ 'elements.h1.color.text'
74
+ );
75
+ const [ backgroundColor = 'white' ] = useGlobalStyle( 'color.background' );
76
+ const [ gradientValue ] = useGlobalStyle( 'color.gradient' );
71
77
  const [ styles ] = useGlobalStylesOutput();
72
78
  const disableMotion = useReducedMotion();
73
- const [ coreColors ] = useSetting( 'color.palette.core' );
74
- const [ themeColors ] = useSetting( 'color.palette.theme' );
75
- const [ customColors ] = useSetting( 'color.palette.custom' );
79
+ const [ coreColors ] = useGlobalSetting( 'color.palette.core' );
80
+ const [ themeColors ] = useGlobalSetting( 'color.palette.theme' );
81
+ const [ customColors ] = useGlobalSetting( 'color.palette.custom' );
76
82
  const [ isHovered, setIsHovered ] = useState( false );
77
83
  const [ containerResizeListener, { width } ] = useResizeObserver();
78
84
  const ratio = width ? width / normalizedWidth : 1;