@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
@@ -1,8 +1,22 @@
1
1
  import { addFilter } from "@wordpress/hooks";
2
- import { MediaUpload } from "@wordpress/media-utils";
3
- addFilter(
4
- "editor.MediaUpload",
5
- "core/editor/components/media-upload",
6
- () => MediaUpload
2
+ import {
3
+ MediaUpload,
4
+ privateApis as mediaUtilsPrivateApis
5
+ } from "@wordpress/media-utils";
6
+ import { unlock } from "../lock-unlock";
7
+ const { MediaUploadModal: MediaUploadModalComponent } = unlock(
8
+ mediaUtilsPrivateApis
7
9
  );
10
+ if (window.__experimentalDataViewsMediaModal) {
11
+ addFilter(
12
+ "editor.MediaUploadModal",
13
+ "core/editor/components/media-upload-modal",
14
+ () => {
15
+ return MediaUploadModalComponent;
16
+ }
17
+ );
18
+ }
19
+ addFilter("editor.MediaUpload", "core/editor/components/media-upload", () => {
20
+ return MediaUpload;
21
+ });
8
22
  //# sourceMappingURL=media-upload.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/media-upload.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { MediaUpload } from '@wordpress/media-utils';\n\naddFilter(\n\t'editor.MediaUpload',\n\t'core/editor/components/media-upload',\n\t() => MediaUpload\n);\n"],
5
- "mappings": "AAGA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAE5B;AAAA,EACC;AAAA,EACA;AAAA,EACA,MAAM;AACP;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tMediaUpload,\n\tprivateApis as mediaUtilsPrivateApis,\n} from '@wordpress/media-utils';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { MediaUploadModal: MediaUploadModalComponent } = unlock(\n\tmediaUtilsPrivateApis\n);\n\nif ( window.__experimentalDataViewsMediaModal ) {\n\t// Create a new filter for the MediaUploadModal component\n\taddFilter(\n\t\t'editor.MediaUploadModal',\n\t\t'core/editor/components/media-upload-modal',\n\t\t() => {\n\t\t\treturn MediaUploadModalComponent;\n\t\t}\n\t);\n}\naddFilter( 'editor.MediaUpload', 'core/editor/components/media-upload', () => {\n\treturn MediaUpload;\n} );\n"],
5
+ "mappings": "AAGA,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA,eAAe;AAAA,OACT;AAKP,SAAS,cAAc;AAEvB,MAAM,EAAE,kBAAkB,0BAA0B,IAAI;AAAA,EACvD;AACD;AAEA,IAAK,OAAO,mCAAoC;AAE/C;AAAA,IACC;AAAA,IACA;AAAA,IACA,MAAM;AACL,aAAO;AAAA,IACR;AAAA,EACD;AACD;AACA,UAAW,sBAAsB,uCAAuC,MAAM;AAC7E,SAAO;AACR,CAAE;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,309 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { addFilter } from "@wordpress/hooks";
3
+ import { createHigherOrderComponent } from "@wordpress/compose";
4
+ import {
5
+ InspectorAdvancedControls,
6
+ store as blockEditorStore,
7
+ privateApis as blockEditorPrivateApis,
8
+ useBlockEditingMode
9
+ } from "@wordpress/block-editor";
10
+ import { BaseControl, Button } from "@wordpress/components";
11
+ import { __, sprintf } from "@wordpress/i18n";
12
+ import {
13
+ __EXPERIMENTAL_STYLE_PROPERTY,
14
+ getBlockType,
15
+ hasBlockSupport,
16
+ store as blocksStore
17
+ } from "@wordpress/blocks";
18
+ import { useMemo, useCallback } from "@wordpress/element";
19
+ import { useDispatch, useSelect } from "@wordpress/data";
20
+ import { store as noticesStore } from "@wordpress/notices";
21
+ import { store as coreStore } from "@wordpress/core-data";
22
+ import { unlock } from "../../lock-unlock";
23
+ import setNestedValue from "../../utils/set-nested-value";
24
+ import { useGlobalStyles } from "../../components/global-styles/hooks";
25
+ const { cleanEmptyObject } = unlock(blockEditorPrivateApis);
26
+ const STYLE_PROPERTY = {
27
+ ...__EXPERIMENTAL_STYLE_PROPERTY,
28
+ blockGap: { value: ["spacing", "blockGap"] }
29
+ };
30
+ const STYLE_PATH_TO_CSS_VAR_INFIX = {
31
+ "border.color": "color",
32
+ "color.background": "color",
33
+ "color.text": "color",
34
+ "elements.link.color.text": "color",
35
+ "elements.link.:hover.color.text": "color",
36
+ "elements.link.typography.fontFamily": "font-family",
37
+ "elements.link.typography.fontSize": "font-size",
38
+ "elements.button.color.text": "color",
39
+ "elements.button.color.background": "color",
40
+ "elements.button.typography.fontFamily": "font-family",
41
+ "elements.button.typography.fontSize": "font-size",
42
+ "elements.caption.color.text": "color",
43
+ "elements.heading.color": "color",
44
+ "elements.heading.color.background": "color",
45
+ "elements.heading.typography.fontFamily": "font-family",
46
+ "elements.heading.gradient": "gradient",
47
+ "elements.heading.color.gradient": "gradient",
48
+ "elements.h1.color": "color",
49
+ "elements.h1.color.background": "color",
50
+ "elements.h1.typography.fontFamily": "font-family",
51
+ "elements.h1.color.gradient": "gradient",
52
+ "elements.h2.color": "color",
53
+ "elements.h2.color.background": "color",
54
+ "elements.h2.typography.fontFamily": "font-family",
55
+ "elements.h2.color.gradient": "gradient",
56
+ "elements.h3.color": "color",
57
+ "elements.h3.color.background": "color",
58
+ "elements.h3.typography.fontFamily": "font-family",
59
+ "elements.h3.color.gradient": "gradient",
60
+ "elements.h4.color": "color",
61
+ "elements.h4.color.background": "color",
62
+ "elements.h4.typography.fontFamily": "font-family",
63
+ "elements.h4.color.gradient": "gradient",
64
+ "elements.h5.color": "color",
65
+ "elements.h5.color.background": "color",
66
+ "elements.h5.typography.fontFamily": "font-family",
67
+ "elements.h5.color.gradient": "gradient",
68
+ "elements.h6.color": "color",
69
+ "elements.h6.color.background": "color",
70
+ "elements.h6.typography.fontFamily": "font-family",
71
+ "elements.h6.color.gradient": "gradient",
72
+ "color.gradient": "gradient",
73
+ blockGap: "spacing",
74
+ "typography.fontSize": "font-size",
75
+ "typography.fontFamily": "font-family"
76
+ };
77
+ const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
78
+ "border.color": "borderColor",
79
+ "color.background": "backgroundColor",
80
+ "color.text": "textColor",
81
+ "color.gradient": "gradient",
82
+ "typography.fontSize": "fontSize",
83
+ "typography.fontFamily": "fontFamily"
84
+ };
85
+ const SUPPORTED_STYLES = ["border", "color", "spacing", "typography"];
86
+ const getValueFromObjectPath = (object, path) => {
87
+ let value = object;
88
+ path.forEach((fieldName) => {
89
+ value = value?.[fieldName];
90
+ });
91
+ return value;
92
+ };
93
+ const flatBorderProperties = ["borderColor", "borderWidth", "borderStyle"];
94
+ const sides = ["top", "right", "bottom", "left"];
95
+ function getBorderStyleChanges(border, presetColor, userStyle) {
96
+ if (!border && !presetColor) {
97
+ return [];
98
+ }
99
+ const changes = [
100
+ ...getFallbackBorderStyleChange("top", border, userStyle),
101
+ ...getFallbackBorderStyleChange("right", border, userStyle),
102
+ ...getFallbackBorderStyleChange("bottom", border, userStyle),
103
+ ...getFallbackBorderStyleChange("left", border, userStyle)
104
+ ];
105
+ const { color: customColor, style, width } = border || {};
106
+ const hasColorOrWidth = presetColor || customColor || width;
107
+ if (hasColorOrWidth && !style) {
108
+ sides.forEach((side) => {
109
+ if (!userStyle?.[side]?.style) {
110
+ changes.push({
111
+ path: ["border", side, "style"],
112
+ value: "solid"
113
+ });
114
+ }
115
+ });
116
+ }
117
+ return changes;
118
+ }
119
+ function getFallbackBorderStyleChange(side, border, globalBorderStyle) {
120
+ if (!border?.[side] || globalBorderStyle?.[side]?.style) {
121
+ return [];
122
+ }
123
+ const { color, style, width } = border[side];
124
+ const hasColorOrWidth = color || width;
125
+ if (!hasColorOrWidth || style) {
126
+ return [];
127
+ }
128
+ return [{ path: ["border", side, "style"], value: "solid" }];
129
+ }
130
+ function useChangesToPush(name, attributes, userConfig) {
131
+ const supports = useSelect(
132
+ (select) => {
133
+ return unlock(select(blocksStore)).getSupportedStyles(name);
134
+ },
135
+ [name]
136
+ );
137
+ const blockUserConfig = userConfig?.styles?.blocks?.[name];
138
+ return useMemo(() => {
139
+ const changes = supports.flatMap((key) => {
140
+ if (!STYLE_PROPERTY[key]) {
141
+ return [];
142
+ }
143
+ const { value: path } = STYLE_PROPERTY[key];
144
+ const presetAttributeKey = path.join(".");
145
+ const presetAttributeValue = attributes[STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[presetAttributeKey]];
146
+ const value = presetAttributeValue ? `var:preset|${STYLE_PATH_TO_CSS_VAR_INFIX[presetAttributeKey]}|${presetAttributeValue}` : getValueFromObjectPath(attributes.style, path);
147
+ if (key === "linkColor") {
148
+ const linkChanges = value ? [{ path, value }] : [];
149
+ const hoverPath = [
150
+ "elements",
151
+ "link",
152
+ ":hover",
153
+ "color",
154
+ "text"
155
+ ];
156
+ const hoverValue = getValueFromObjectPath(
157
+ attributes.style,
158
+ hoverPath
159
+ );
160
+ if (hoverValue) {
161
+ linkChanges.push({ path: hoverPath, value: hoverValue });
162
+ }
163
+ return linkChanges;
164
+ }
165
+ if (flatBorderProperties.includes(key) && value) {
166
+ const borderChanges = [{ path, value }];
167
+ sides.forEach((side) => {
168
+ const currentPath = [...path];
169
+ currentPath.splice(-1, 0, side);
170
+ borderChanges.push({ path: currentPath, value });
171
+ });
172
+ return borderChanges;
173
+ }
174
+ return value ? [{ path, value }] : [];
175
+ });
176
+ getBorderStyleChanges(
177
+ attributes.style?.border,
178
+ attributes.borderColor,
179
+ blockUserConfig?.border
180
+ ).forEach((change) => changes.push(change));
181
+ return changes;
182
+ }, [supports, attributes, blockUserConfig]);
183
+ }
184
+ function PushChangesToGlobalStylesControl({
185
+ name,
186
+ attributes,
187
+ setAttributes
188
+ }) {
189
+ const { user: userConfig, setUser: setUserConfig } = useGlobalStyles();
190
+ const changes = useChangesToPush(name, attributes, userConfig);
191
+ const { __unstableMarkNextChangeAsNotPersistent } = useDispatch(blockEditorStore);
192
+ const { createSuccessNotice } = useDispatch(noticesStore);
193
+ const pushChanges = useCallback(() => {
194
+ if (changes.length === 0) {
195
+ return;
196
+ }
197
+ if (changes.length > 0) {
198
+ const { style: blockStyles } = attributes;
199
+ const newBlockStyles = structuredClone(blockStyles);
200
+ const newUserConfig = structuredClone(userConfig);
201
+ for (const { path, value } of changes) {
202
+ setNestedValue(newBlockStyles, path, void 0);
203
+ setNestedValue(
204
+ newUserConfig,
205
+ ["styles", "blocks", name, ...path],
206
+ value
207
+ );
208
+ }
209
+ const newBlockAttributes = {
210
+ borderColor: void 0,
211
+ backgroundColor: void 0,
212
+ textColor: void 0,
213
+ gradient: void 0,
214
+ fontSize: void 0,
215
+ fontFamily: void 0,
216
+ style: cleanEmptyObject(newBlockStyles)
217
+ };
218
+ __unstableMarkNextChangeAsNotPersistent();
219
+ setAttributes(newBlockAttributes);
220
+ setUserConfig(newUserConfig, { undoIgnore: true });
221
+ createSuccessNotice(
222
+ sprintf(
223
+ // translators: %s: Title of the block e.g. 'Heading'.
224
+ __("%s styles applied."),
225
+ getBlockType(name).title
226
+ ),
227
+ {
228
+ type: "snackbar",
229
+ actions: [
230
+ {
231
+ label: __("Undo"),
232
+ onClick() {
233
+ __unstableMarkNextChangeAsNotPersistent();
234
+ setAttributes(attributes);
235
+ setUserConfig(userConfig, {
236
+ undoIgnore: true
237
+ });
238
+ }
239
+ }
240
+ ]
241
+ }
242
+ );
243
+ }
244
+ }, [
245
+ __unstableMarkNextChangeAsNotPersistent,
246
+ attributes,
247
+ changes,
248
+ createSuccessNotice,
249
+ name,
250
+ setAttributes,
251
+ setUserConfig,
252
+ userConfig
253
+ ]);
254
+ return /* @__PURE__ */ jsxs(
255
+ BaseControl,
256
+ {
257
+ __nextHasNoMarginBottom: true,
258
+ className: "editor-push-changes-to-global-styles-control",
259
+ help: sprintf(
260
+ // translators: %s: Title of the block e.g. 'Heading'.
261
+ __(
262
+ "Apply this block\u2019s typography, spacing, dimensions, and color styles to all %s blocks."
263
+ ),
264
+ getBlockType(name).title
265
+ ),
266
+ children: [
267
+ /* @__PURE__ */ jsx(BaseControl.VisualLabel, { children: __("Styles") }),
268
+ /* @__PURE__ */ jsx(
269
+ Button,
270
+ {
271
+ __next40pxDefaultSize: true,
272
+ variant: "secondary",
273
+ accessibleWhenDisabled: true,
274
+ disabled: changes.length === 0,
275
+ onClick: pushChanges,
276
+ children: __("Apply globally")
277
+ }
278
+ )
279
+ ]
280
+ }
281
+ );
282
+ }
283
+ function PushChangesToGlobalStyles(props) {
284
+ const blockEditingMode = useBlockEditingMode();
285
+ const isBlockBasedTheme = useSelect(
286
+ (select) => select(coreStore).getCurrentTheme()?.is_block_theme,
287
+ []
288
+ );
289
+ const supportsStyles = SUPPORTED_STYLES.some(
290
+ (feature) => hasBlockSupport(props.name, feature)
291
+ );
292
+ const isDisplayed = blockEditingMode === "default" && supportsStyles && isBlockBasedTheme;
293
+ if (!isDisplayed) {
294
+ return null;
295
+ }
296
+ return /* @__PURE__ */ jsx(InspectorAdvancedControls, { children: /* @__PURE__ */ jsx(PushChangesToGlobalStylesControl, { ...props }) });
297
+ }
298
+ const withPushChangesToGlobalStyles = createHigherOrderComponent(
299
+ (BlockEdit) => (props) => /* @__PURE__ */ jsxs(Fragment, { children: [
300
+ /* @__PURE__ */ jsx(BlockEdit, { ...props }, "edit"),
301
+ props.isSelected && /* @__PURE__ */ jsx(PushChangesToGlobalStyles, { ...props })
302
+ ] })
303
+ );
304
+ addFilter(
305
+ "editor.BlockEdit",
306
+ "core/editor/push-changes-to-global-styles",
307
+ withPushChangesToGlobalStyles
308
+ );
309
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/hooks/push-changes-to-global-styles/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport {\n\tInspectorAdvancedControls,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { BaseControl, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__EXPERIMENTAL_STYLE_PROPERTY,\n\tgetBlockType,\n\thasBlockSupport,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport setNestedValue from '../../utils/set-nested-value';\nimport { useGlobalStyles } from '../../components/global-styles/hooks';\n\nconst { cleanEmptyObject } = unlock( blockEditorPrivateApis );\n\n// Block Gap is a special case and isn't defined within the blocks\n// style properties config. We'll add it here to allow it to be pushed\n// to global styles as well.\nconst STYLE_PROPERTY = {\n\t...__EXPERIMENTAL_STYLE_PROPERTY,\n\tblockGap: { value: [ 'spacing', 'blockGap' ] },\n};\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_CSS_VAR_INFIX = {\n\t'border.color': 'color',\n\t'color.background': 'color',\n\t'color.text': 'color',\n\t'elements.link.color.text': 'color',\n\t'elements.link.:hover.color.text': 'color',\n\t'elements.link.typography.fontFamily': 'font-family',\n\t'elements.link.typography.fontSize': 'font-size',\n\t'elements.button.color.text': 'color',\n\t'elements.button.color.background': 'color',\n\t'elements.button.typography.fontFamily': 'font-family',\n\t'elements.button.typography.fontSize': 'font-size',\n\t'elements.caption.color.text': 'color',\n\t'elements.heading.color': 'color',\n\t'elements.heading.color.background': 'color',\n\t'elements.heading.typography.fontFamily': 'font-family',\n\t'elements.heading.gradient': 'gradient',\n\t'elements.heading.color.gradient': 'gradient',\n\t'elements.h1.color': 'color',\n\t'elements.h1.color.background': 'color',\n\t'elements.h1.typography.fontFamily': 'font-family',\n\t'elements.h1.color.gradient': 'gradient',\n\t'elements.h2.color': 'color',\n\t'elements.h2.color.background': 'color',\n\t'elements.h2.typography.fontFamily': 'font-family',\n\t'elements.h2.color.gradient': 'gradient',\n\t'elements.h3.color': 'color',\n\t'elements.h3.color.background': 'color',\n\t'elements.h3.typography.fontFamily': 'font-family',\n\t'elements.h3.color.gradient': 'gradient',\n\t'elements.h4.color': 'color',\n\t'elements.h4.color.background': 'color',\n\t'elements.h4.typography.fontFamily': 'font-family',\n\t'elements.h4.color.gradient': 'gradient',\n\t'elements.h5.color': 'color',\n\t'elements.h5.color.background': 'color',\n\t'elements.h5.typography.fontFamily': 'font-family',\n\t'elements.h5.color.gradient': 'gradient',\n\t'elements.h6.color': 'color',\n\t'elements.h6.color.background': 'color',\n\t'elements.h6.typography.fontFamily': 'font-family',\n\t'elements.h6.color.gradient': 'gradient',\n\t'color.gradient': 'gradient',\n\tblockGap: 'spacing',\n\t'typography.fontSize': 'font-size',\n\t'typography.fontFamily': 'font-family',\n};\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {\n\t'border.color': 'borderColor',\n\t'color.background': 'backgroundColor',\n\t'color.text': 'textColor',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'fontSize',\n\t'typography.fontFamily': 'fontFamily',\n};\n\nconst SUPPORTED_STYLES = [ 'border', 'color', 'spacing', 'typography' ];\n\nconst getValueFromObjectPath = ( object, path ) => {\n\tlet value = object;\n\tpath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\nconst flatBorderProperties = [ 'borderColor', 'borderWidth', 'borderStyle' ];\nconst sides = [ 'top', 'right', 'bottom', 'left' ];\n\nfunction getBorderStyleChanges( border, presetColor, userStyle ) {\n\tif ( ! border && ! presetColor ) {\n\t\treturn [];\n\t}\n\n\tconst changes = [\n\t\t...getFallbackBorderStyleChange( 'top', border, userStyle ),\n\t\t...getFallbackBorderStyleChange( 'right', border, userStyle ),\n\t\t...getFallbackBorderStyleChange( 'bottom', border, userStyle ),\n\t\t...getFallbackBorderStyleChange( 'left', border, userStyle ),\n\t];\n\n\t// Handle a flat border i.e. all sides the same, CSS shorthand.\n\tconst { color: customColor, style, width } = border || {};\n\tconst hasColorOrWidth = presetColor || customColor || width;\n\n\tif ( hasColorOrWidth && ! style ) {\n\t\t// Global Styles need individual side configurations to overcome\n\t\t// theme.json configurations which are per side as well.\n\t\tsides.forEach( ( side ) => {\n\t\t\t// Only add fallback border-style if global styles don't already\n\t\t\t// have something set.\n\t\t\tif ( ! userStyle?.[ side ]?.style ) {\n\t\t\t\tchanges.push( {\n\t\t\t\t\tpath: [ 'border', side, 'style' ],\n\t\t\t\t\tvalue: 'solid',\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}\n\n\treturn changes;\n}\n\nfunction getFallbackBorderStyleChange( side, border, globalBorderStyle ) {\n\tif ( ! border?.[ side ] || globalBorderStyle?.[ side ]?.style ) {\n\t\treturn [];\n\t}\n\n\tconst { color, style, width } = border[ side ];\n\tconst hasColorOrWidth = color || width;\n\n\tif ( ! hasColorOrWidth || style ) {\n\t\treturn [];\n\t}\n\n\treturn [ { path: [ 'border', side, 'style' ], value: 'solid' } ];\n}\n\nfunction useChangesToPush( name, attributes, userConfig ) {\n\tconst supports = useSelect(\n\t\t( select ) => {\n\t\t\treturn unlock( select( blocksStore ) ).getSupportedStyles( name );\n\t\t},\n\t\t[ name ]\n\t);\n\tconst blockUserConfig = userConfig?.styles?.blocks?.[ name ];\n\n\treturn useMemo( () => {\n\t\tconst changes = supports.flatMap( ( key ) => {\n\t\t\tif ( ! STYLE_PROPERTY[ key ] ) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst { value: path } = STYLE_PROPERTY[ key ];\n\t\t\tconst presetAttributeKey = path.join( '.' );\n\t\t\tconst presetAttributeValue =\n\t\t\t\tattributes[\n\t\t\t\t\tSTYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[ presetAttributeKey ]\n\t\t\t\t];\n\t\t\tconst value = presetAttributeValue\n\t\t\t\t? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`\n\t\t\t\t: getValueFromObjectPath( attributes.style, path );\n\n\t\t\t// Links only have a single support entry but have two element\n\t\t\t// style properties, color and hover color. The following check\n\t\t\t// will add the hover color to the changes if required.\n\t\t\tif ( key === 'linkColor' ) {\n\t\t\t\tconst linkChanges = value ? [ { path, value } ] : [];\n\t\t\t\tconst hoverPath = [\n\t\t\t\t\t'elements',\n\t\t\t\t\t'link',\n\t\t\t\t\t':hover',\n\t\t\t\t\t'color',\n\t\t\t\t\t'text',\n\t\t\t\t];\n\t\t\t\tconst hoverValue = getValueFromObjectPath(\n\t\t\t\t\tattributes.style,\n\t\t\t\t\thoverPath\n\t\t\t\t);\n\n\t\t\t\tif ( hoverValue ) {\n\t\t\t\t\tlinkChanges.push( { path: hoverPath, value: hoverValue } );\n\t\t\t\t}\n\n\t\t\t\treturn linkChanges;\n\t\t\t}\n\n\t\t\t// The shorthand border styles can't be mapped directly as global\n\t\t\t// styles requires longhand config.\n\t\t\tif ( flatBorderProperties.includes( key ) && value ) {\n\t\t\t\t// The shorthand config path is included to clear the block attribute.\n\t\t\t\tconst borderChanges = [ { path, value } ];\n\t\t\t\tsides.forEach( ( side ) => {\n\t\t\t\t\tconst currentPath = [ ...path ];\n\t\t\t\t\tcurrentPath.splice( -1, 0, side );\n\t\t\t\t\tborderChanges.push( { path: currentPath, value } );\n\t\t\t\t} );\n\t\t\t\treturn borderChanges;\n\t\t\t}\n\n\t\t\treturn value ? [ { path, value } ] : [];\n\t\t} );\n\n\t\t// To ensure display of a visible border, global styles require a\n\t\t// default border style if a border color or width is present.\n\t\tgetBorderStyleChanges(\n\t\t\tattributes.style?.border,\n\t\t\tattributes.borderColor,\n\t\t\tblockUserConfig?.border\n\t\t).forEach( ( change ) => changes.push( change ) );\n\n\t\treturn changes;\n\t}, [ supports, attributes, blockUserConfig ] );\n}\n\nfunction PushChangesToGlobalStylesControl( {\n\tname,\n\tattributes,\n\tsetAttributes,\n} ) {\n\tconst { user: userConfig, setUser: setUserConfig } = useGlobalStyles();\n\n\tconst changes = useChangesToPush( name, attributes, userConfig );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst pushChanges = useCallback( () => {\n\t\tif ( changes.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( changes.length > 0 ) {\n\t\t\tconst { style: blockStyles } = attributes;\n\n\t\t\tconst newBlockStyles = structuredClone( blockStyles );\n\t\t\tconst newUserConfig = structuredClone( userConfig );\n\n\t\t\tfor ( const { path, value } of changes ) {\n\t\t\t\tsetNestedValue( newBlockStyles, path, undefined );\n\t\t\t\tsetNestedValue(\n\t\t\t\t\tnewUserConfig,\n\t\t\t\t\t[ 'styles', 'blocks', name, ...path ],\n\t\t\t\t\tvalue\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst newBlockAttributes = {\n\t\t\t\tborderColor: undefined,\n\t\t\t\tbackgroundColor: undefined,\n\t\t\t\ttextColor: undefined,\n\t\t\t\tgradient: undefined,\n\t\t\t\tfontSize: undefined,\n\t\t\t\tfontFamily: undefined,\n\t\t\t\tstyle: cleanEmptyObject( newBlockStyles ),\n\t\t\t};\n\n\t\t\t// @wordpress/core-data doesn't support editing multiple entity types in\n\t\t\t// a single undo level. So for now, we disable @wordpress/core-data undo\n\t\t\t// tracking and implement our own Undo button in the snackbar\n\t\t\t// notification.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( newBlockAttributes );\n\t\t\tsetUserConfig( newUserConfig, { undoIgnore: true } );\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t\t__( '%s styles applied.' ),\n\t\t\t\t\tgetBlockType( name ).title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\t\tsetAttributes( attributes );\n\t\t\t\t\t\t\t\tsetUserConfig( userConfig, {\n\t\t\t\t\t\t\t\t\tundoIgnore: true,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}, [\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tattributes,\n\t\tchanges,\n\t\tcreateSuccessNotice,\n\t\tname,\n\t\tsetAttributes,\n\t\tsetUserConfig,\n\t\tuserConfig,\n\t] );\n\n\treturn (\n\t\t<BaseControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"editor-push-changes-to-global-styles-control\"\n\t\t\thelp={ sprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__(\n\t\t\t\t\t'Apply this block\u2019s typography, spacing, dimensions, and color styles to all %s blocks.'\n\t\t\t\t),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t) }\n\t\t>\n\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t{ __( 'Styles' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tdisabled={ changes.length === 0 }\n\t\t\t\tonClick={ pushChanges }\n\t\t\t>\n\t\t\t\t{ __( 'Apply globally' ) }\n\t\t\t</Button>\n\t\t</BaseControl>\n\t);\n}\n\nfunction PushChangesToGlobalStyles( props ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst isBlockBasedTheme = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t[]\n\t);\n\tconst supportsStyles = SUPPORTED_STYLES.some( ( feature ) =>\n\t\thasBlockSupport( props.name, feature )\n\t);\n\tconst isDisplayed =\n\t\tblockEditingMode === 'default' && supportsStyles && isBlockBasedTheme;\n\n\tif ( ! isDisplayed ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorAdvancedControls>\n\t\t\t<PushChangesToGlobalStylesControl { ...props } />\n\t\t</InspectorAdvancedControls>\n\t);\n}\n\nconst withPushChangesToGlobalStyles = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => (\n\t\t<>\n\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t{ props.isSelected && <PushChangesToGlobalStyles { ...props } /> }\n\t\t</>\n\t)\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/push-changes-to-global-styles',\n\twithPushChangesToGlobalStyles\n);\n"],
5
+ "mappings": "AAuUE,SAoDA,UAzCC,KAXD;AApUF,SAAS,iBAAiB;AAC1B,SAAS,kCAAkC;AAC3C;AAAA,EACC;AAAA,EACA,SAAS;AAAA,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B,SAAU;AAAA,YAER,aAAI,gBAAiB;AAAA;AAAA,QACxB;AAAA;AAAA;AAAA,EACD;AAEF;AAEA,SAAS,0BAA2B,OAAQ;AAC3C,QAAM,mBAAmB,oBAAoB;AAC7C,QAAM,oBAAoB;AAAA,IACzB,CAAE,WAAY,OAAQ,SAAU,EAAE,gBAAgB,GAAG;AAAA,IACrD,CAAC;AAAA,EACF;AACA,QAAM,iBAAiB,iBAAiB;AAAA,IAAM,CAAE,YAC/C,gBAAiB,MAAM,MAAM,OAAQ;AAAA,EACtC;AACA,QAAM,cACL,qBAAqB,aAAa,kBAAkB;AAErD,MAAK,CAAE,aAAc;AACpB,WAAO;AAAA,EACR;AAEA,SACC,oBAAC,6BACA,8BAAC,oCAAmC,GAAG,OAAQ,GAChD;AAEF;AAEA,MAAM,gCAAgC;AAAA,EACrC,CAAE,cAAe,CAAE,UAClB,iCACC;AAAA,wBAAC,aAAuB,GAAG,SAAZ,MAAoB;AAAA,IACjC,MAAM,cAAc,oBAAC,6BAA4B,GAAG,OAAQ;AAAA,KAC/D;AAEF;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,49 @@
1
+ import { getBlockTypes, store as blocksStore } from "@wordpress/blocks";
2
+ import { useSelect } from "@wordpress/data";
3
+ import { useMemo } from "@wordpress/element";
4
+ import { generateGlobalStyles } from "@wordpress/global-styles-engine";
5
+ import { store as editorStore } from "../store";
6
+ import { useSetting, useGlobalStyles } from "../components/global-styles";
7
+ function useGlobalStylesOutputWithConfig(mergedConfig = {}, disableRootPadding = false) {
8
+ const blockGap = useSetting("spacing.blockGap");
9
+ const hasBlockGapSupport = blockGap !== null;
10
+ const hasFallbackGapSupport = !hasBlockGapSupport;
11
+ const { disableLayoutStyles, getBlockStyles } = useSelect((select) => {
12
+ const { getEditorSettings } = select(editorStore);
13
+ const { getBlockStyles: getBlockStylesSelector } = select(blocksStore);
14
+ const settings = getEditorSettings();
15
+ return {
16
+ disableLayoutStyles: !!settings?.disableLayoutStyles,
17
+ getBlockStyles: getBlockStylesSelector
18
+ };
19
+ }, []);
20
+ return useMemo(() => {
21
+ if (!mergedConfig?.styles || !mergedConfig?.settings) {
22
+ return [[], {}];
23
+ }
24
+ const blockTypes = getBlockTypes();
25
+ return generateGlobalStyles(mergedConfig, blockTypes, {
26
+ hasBlockGapSupport,
27
+ hasFallbackGapSupport,
28
+ disableLayoutStyles,
29
+ disableRootPadding,
30
+ getBlockStyles
31
+ });
32
+ }, [
33
+ hasBlockGapSupport,
34
+ hasFallbackGapSupport,
35
+ mergedConfig,
36
+ disableLayoutStyles,
37
+ disableRootPadding,
38
+ getBlockStyles
39
+ ]);
40
+ }
41
+ function useGlobalStylesOutput(disableRootPadding = false) {
42
+ const { merged: mergedConfig } = useGlobalStyles();
43
+ return useGlobalStylesOutputWithConfig(mergedConfig, disableRootPadding);
44
+ }
45
+ export {
46
+ useGlobalStylesOutput,
47
+ useGlobalStylesOutputWithConfig
48
+ };
49
+ //# sourceMappingURL=use-global-styles-output.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/hooks/use-global-styles-output.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockTypes, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { generateGlobalStyles } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { useSetting, useGlobalStyles } from '../components/global-styles';\n\n/**\n * Returns the global styles output based on the provided global styles config.\n *\n * @param {Object} mergedConfig The merged global styles config.\n * @param {boolean} disableRootPadding Disable root padding styles.\n *\n * @return {Array} Array of stylesheets and settings.\n */\nexport function useGlobalStylesOutputWithConfig(\n\tmergedConfig = {},\n\tdisableRootPadding = false\n) {\n\tconst blockGap = useSetting( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGap !== null;\n\tconst hasFallbackGapSupport = ! hasBlockGapSupport;\n\n\tconst { disableLayoutStyles, getBlockStyles } = useSelect( ( select ) => {\n\t\tconst { getEditorSettings } = select( editorStore );\n\t\tconst { getBlockStyles: getBlockStylesSelector } =\n\t\t\tselect( blocksStore );\n\t\tconst settings = getEditorSettings();\n\t\treturn {\n\t\t\tdisableLayoutStyles: !! settings?.disableLayoutStyles,\n\t\t\tgetBlockStyles: getBlockStylesSelector,\n\t\t};\n\t}, [] );\n\n\treturn useMemo( () => {\n\t\tif ( ! mergedConfig?.styles || ! mergedConfig?.settings ) {\n\t\t\treturn [ [], {} ];\n\t\t}\n\n\t\tconst blockTypes = getBlockTypes();\n\n\t\treturn generateGlobalStyles( mergedConfig, blockTypes, {\n\t\t\thasBlockGapSupport,\n\t\t\thasFallbackGapSupport,\n\t\t\tdisableLayoutStyles,\n\t\t\tdisableRootPadding,\n\t\t\tgetBlockStyles,\n\t\t} );\n\t}, [\n\t\thasBlockGapSupport,\n\t\thasFallbackGapSupport,\n\t\tmergedConfig,\n\t\tdisableLayoutStyles,\n\t\tdisableRootPadding,\n\t\tgetBlockStyles,\n\t] );\n}\n\n/**\n * Returns the global styles output based on the current state of global styles config loaded in the editor context.\n *\n * @param {boolean} disableRootPadding Disable root padding styles.\n *\n * @return {Array} Array of stylesheets and settings.\n */\nexport function useGlobalStylesOutput( disableRootPadding = false ) {\n\tconst { merged: mergedConfig } = useGlobalStyles();\n\treturn useGlobalStylesOutputWithConfig( mergedConfig, disableRootPadding );\n}\n"],
5
+ "mappings": "AAGA,SAAS,eAAe,SAAS,mBAAmB;AACpD,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,4BAA4B;AAKrC,SAAS,SAAS,mBAAmB;AACrC,SAAS,YAAY,uBAAuB;AAUrC,SAAS,gCACf,eAAe,CAAC,GAChB,qBAAqB,OACpB;AACD,QAAM,WAAW,WAAY,kBAAmB;AAChD,QAAM,qBAAqB,aAAa;AACxC,QAAM,wBAAwB,CAAE;AAEhC,QAAM,EAAE,qBAAqB,eAAe,IAAI,UAAW,CAAE,WAAY;AACxE,UAAM,EAAE,kBAAkB,IAAI,OAAQ,WAAY;AAClD,UAAM,EAAE,gBAAgB,uBAAuB,IAC9C,OAAQ,WAAY;AACrB,UAAM,WAAW,kBAAkB;AACnC,WAAO;AAAA,MACN,qBAAqB,CAAC,CAAE,UAAU;AAAA,MAClC,gBAAgB;AAAA,IACjB;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,SAAO,QAAS,MAAM;AACrB,QAAK,CAAE,cAAc,UAAU,CAAE,cAAc,UAAW;AACzD,aAAO,CAAE,CAAC,GAAG,CAAC,CAAE;AAAA,IACjB;AAEA,UAAM,aAAa,cAAc;AAEjC,WAAO,qBAAsB,cAAc,YAAY;AAAA,MACtD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAE;AAAA,EACH,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;AASO,SAAS,sBAAuB,qBAAqB,OAAQ;AACnE,QAAM,EAAE,QAAQ,aAAa,IAAI,gBAAgB;AACjD,SAAO,gCAAiC,cAAc,kBAAmB;AAC1E;",
6
+ "names": []
7
+ }
@@ -1,7 +1,6 @@
1
1
  import * as interfaceApis from "@wordpress/interface";
2
2
  import { lock } from "./lock-unlock";
3
3
  import { EntitiesSavedStatesExtensible } from "./components/entities-saved-states";
4
- import EditorContentSlotFill from "./components/editor-interface/content-slot-fill";
5
4
  import BackButton from "./components/header/back-button";
6
5
  import Editor from "./components/editor";
7
6
  import PluginPostExcerpt from "./components/post-excerpt/plugin";
@@ -12,10 +11,6 @@ import usePostFields from "./components/post-fields";
12
11
  import ToolsMoreMenuGroup from "./components/more-menu/tools-more-menu-group";
13
12
  import ViewMoreMenuGroup from "./components/more-menu/view-more-menu-group";
14
13
  import ResizableEditor from "./components/resizable-editor";
15
- import {
16
- mergeBaseAndUserConfigs,
17
- GlobalStylesProvider
18
- } from "./components/global-styles-provider";
19
14
  import {
20
15
  CreateTemplatePartModal,
21
16
  patternTitleField,
@@ -23,6 +18,10 @@ import {
23
18
  } from "@wordpress/fields";
24
19
  import { registerCoreBlockBindingsSources } from "./bindings/api";
25
20
  import { getTemplateInfo } from "./utils/get-template-info";
21
+ import GlobalStylesUIWrapper from "./components/global-styles";
22
+ import { StyleBookPreview } from "./components/style-book";
23
+ import { useGlobalStyles, useStyle } from "./components/global-styles/hooks";
24
+ import { GlobalStylesActionMenu } from "./components/global-styles/menu";
26
25
  const { store: interfaceStore, ...remainingInterfaceApis } = interfaceApis;
27
26
  const privateApis = {};
28
27
  lock(privateApis, {
@@ -32,9 +31,6 @@ lock(privateApis, {
32
31
  BackButton,
33
32
  EntitiesSavedStatesExtensible,
34
33
  Editor,
35
- EditorContentSlotFill,
36
- GlobalStylesProvider,
37
- mergeBaseAndUserConfigs,
38
34
  PluginPostExcerpt,
39
35
  PostCardPanel,
40
36
  PreferencesModal,
@@ -45,6 +41,12 @@ lock(privateApis, {
45
41
  ResizableEditor,
46
42
  registerCoreBlockBindingsSources,
47
43
  getTemplateInfo,
44
+ // Global Styles
45
+ GlobalStylesUIWrapper,
46
+ GlobalStylesActionMenu,
47
+ StyleBookPreview,
48
+ useGlobalStyles,
49
+ useStyle,
48
50
  // This is a temporary private API while we're updating the site editor to use EditorProvider.
49
51
  interfaceStore,
50
52
  ...remainingInterfaceApis
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/private-apis.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport * as interfaceApis from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { lock } from './lock-unlock';\nimport { EntitiesSavedStatesExtensible } from './components/entities-saved-states';\nimport EditorContentSlotFill from './components/editor-interface/content-slot-fill';\nimport BackButton from './components/header/back-button';\nimport Editor from './components/editor';\nimport PluginPostExcerpt from './components/post-excerpt/plugin';\nimport PostCardPanel from './components/post-card-panel';\nimport PreferencesModal from './components/preferences-modal';\nimport { usePostActions } from './components/post-actions/actions';\nimport usePostFields from './components/post-fields';\nimport ToolsMoreMenuGroup from './components/more-menu/tools-more-menu-group';\nimport ViewMoreMenuGroup from './components/more-menu/view-more-menu-group';\nimport ResizableEditor from './components/resizable-editor';\nimport {\n\tmergeBaseAndUserConfigs,\n\tGlobalStylesProvider,\n} from './components/global-styles-provider';\nimport {\n\tCreateTemplatePartModal,\n\tpatternTitleField,\n\ttemplateTitleField,\n} from '@wordpress/fields';\nimport { registerCoreBlockBindingsSources } from './bindings/api';\nimport { getTemplateInfo } from './utils/get-template-info';\n\nconst { store: interfaceStore, ...remainingInterfaceApis } = interfaceApis;\n\nexport const privateApis = {};\nlock( privateApis, {\n\tCreateTemplatePartModal,\n\tpatternTitleField,\n\ttemplateTitleField,\n\tBackButton,\n\tEntitiesSavedStatesExtensible,\n\tEditor,\n\tEditorContentSlotFill,\n\tGlobalStylesProvider,\n\tmergeBaseAndUserConfigs,\n\tPluginPostExcerpt,\n\tPostCardPanel,\n\tPreferencesModal,\n\tusePostActions,\n\tusePostFields,\n\tToolsMoreMenuGroup,\n\tViewMoreMenuGroup,\n\tResizableEditor,\n\tregisterCoreBlockBindingsSources,\n\tgetTemplateInfo,\n\t// This is a temporary private API while we're updating the site editor to use EditorProvider.\n\tinterfaceStore,\n\t...remainingInterfaceApis,\n} );\n"],
5
- "mappings": "AAGA,YAAY,mBAAmB;AAK/B,SAAS,YAAY;AACrB,SAAS,qCAAqC;AAC9C,OAAO,2BAA2B;AAClC,OAAO,gBAAgB;AACvB,OAAO,YAAY;AACnB,OAAO,uBAAuB;AAC9B,OAAO,mBAAmB;AAC1B,OAAO,sBAAsB;AAC7B,SAAS,sBAAsB;AAC/B,OAAO,mBAAmB;AAC1B,OAAO,wBAAwB;AAC/B,OAAO,uBAAuB;AAC9B,OAAO,qBAAqB;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,wCAAwC;AACjD,SAAS,uBAAuB;AAEhC,MAAM,EAAE,OAAO,gBAAgB,GAAG,uBAAuB,IAAI;AAEtD,MAAM,cAAc,CAAC;AAC5B,KAAM,aAAa;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA,GAAG;AACJ,CAAE;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport * as interfaceApis from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { lock } from './lock-unlock';\nimport { EntitiesSavedStatesExtensible } from './components/entities-saved-states';\nimport BackButton from './components/header/back-button';\nimport Editor from './components/editor';\nimport PluginPostExcerpt from './components/post-excerpt/plugin';\nimport PostCardPanel from './components/post-card-panel';\nimport PreferencesModal from './components/preferences-modal';\nimport { usePostActions } from './components/post-actions/actions';\nimport usePostFields from './components/post-fields';\nimport ToolsMoreMenuGroup from './components/more-menu/tools-more-menu-group';\nimport ViewMoreMenuGroup from './components/more-menu/view-more-menu-group';\nimport ResizableEditor from './components/resizable-editor';\nimport {\n\tCreateTemplatePartModal,\n\tpatternTitleField,\n\ttemplateTitleField,\n} from '@wordpress/fields';\nimport { registerCoreBlockBindingsSources } from './bindings/api';\nimport { getTemplateInfo } from './utils/get-template-info';\nimport GlobalStylesUIWrapper from './components/global-styles';\nimport { StyleBookPreview } from './components/style-book';\nimport { useGlobalStyles, useStyle } from './components/global-styles/hooks';\nimport { GlobalStylesActionMenu } from './components/global-styles/menu';\n\nconst { store: interfaceStore, ...remainingInterfaceApis } = interfaceApis;\n\nexport const privateApis = {};\nlock( privateApis, {\n\tCreateTemplatePartModal,\n\tpatternTitleField,\n\ttemplateTitleField,\n\tBackButton,\n\tEntitiesSavedStatesExtensible,\n\tEditor,\n\tPluginPostExcerpt,\n\tPostCardPanel,\n\tPreferencesModal,\n\tusePostActions,\n\tusePostFields,\n\tToolsMoreMenuGroup,\n\tViewMoreMenuGroup,\n\tResizableEditor,\n\tregisterCoreBlockBindingsSources,\n\tgetTemplateInfo,\n\t// Global Styles\n\tGlobalStylesUIWrapper,\n\tGlobalStylesActionMenu,\n\tStyleBookPreview,\n\tuseGlobalStyles,\n\tuseStyle,\n\t// This is a temporary private API while we're updating the site editor to use EditorProvider.\n\tinterfaceStore,\n\t...remainingInterfaceApis,\n} );\n"],
5
+ "mappings": "AAGA,YAAY,mBAAmB;AAK/B,SAAS,YAAY;AACrB,SAAS,qCAAqC;AAC9C,OAAO,gBAAgB;AACvB,OAAO,YAAY;AACnB,OAAO,uBAAuB;AAC9B,OAAO,mBAAmB;AAC1B,OAAO,sBAAsB;AAC7B,SAAS,sBAAsB;AAC/B,OAAO,mBAAmB;AAC1B,OAAO,wBAAwB;AAC/B,OAAO,uBAAuB;AAC9B,OAAO,qBAAqB;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,wCAAwC;AACjD,SAAS,uBAAuB;AAChC,OAAO,2BAA2B;AAClC,SAAS,wBAAwB;AACjC,SAAS,iBAAiB,gBAAgB;AAC1C,SAAS,8BAA8B;AAEvC,MAAM,EAAE,OAAO,gBAAgB,GAAG,uBAAuB,IAAI;AAEtD,MAAM,cAAc,CAAC;AAC5B,KAAM,aAAa;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA,GAAG;AACJ,CAAE;",
6
6
  "names": []
7
7
  }
@@ -328,14 +328,34 @@ const setDefaultRenderingMode = (mode) => ({ select, registry }) => {
328
328
  };
329
329
  registry.dispatch(preferencesStore).set("core", "renderingModes", newModes);
330
330
  };
331
+ function setStylesPath(path) {
332
+ return {
333
+ type: "SET_STYLES_PATH",
334
+ path
335
+ };
336
+ }
337
+ function setShowStylebook(show) {
338
+ return {
339
+ type: "SET_SHOW_STYLEBOOK",
340
+ show
341
+ };
342
+ }
343
+ function resetStylesNavigation() {
344
+ return {
345
+ type: "RESET_STYLES_NAVIGATION"
346
+ };
347
+ }
331
348
  export {
332
349
  createTemplate,
333
350
  hideBlockTypes,
334
351
  removeTemplates,
352
+ resetStylesNavigation,
335
353
  revertTemplate,
336
354
  saveDirtyEntities,
337
355
  setCurrentTemplateId,
338
356
  setDefaultRenderingMode,
357
+ setShowStylebook,
358
+ setStylesPath,
339
359
  showBlockTypes
340
360
  };
341
361
  //# sourceMappingURL=private-actions.js.map