@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
@@ -0,0 +1,627 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var style_book_exports = {};
30
+ __export(style_book_exports, {
31
+ StyleBookBody: () => StyleBookBody,
32
+ StyleBookPreview: () => StyleBookPreview,
33
+ default: () => style_book_default,
34
+ getExamplesForSinglePageUse: () => getExamplesForSinglePageUse
35
+ });
36
+ module.exports = __toCommonJS(style_book_exports);
37
+ var import_jsx_runtime = require("react/jsx-runtime");
38
+ var import_clsx = __toESM(require("clsx"));
39
+ var import_components = require("@wordpress/components");
40
+ var import_i18n = require("@wordpress/i18n");
41
+ var import_block_editor = require("@wordpress/block-editor");
42
+ var import_data = require("@wordpress/data");
43
+ var import_global_styles_engine = require("@wordpress/global-styles-engine");
44
+ var import_element = require("@wordpress/element");
45
+ var import_keycodes = require("@wordpress/keycodes");
46
+ var import_media_utils = require("@wordpress/media-utils");
47
+ var import_core_data = require("@wordpress/core-data");
48
+ var import_lock_unlock = require("../../lock-unlock");
49
+ var import_constants = require("./constants");
50
+ var import_categories = require("./categories");
51
+ var import_examples = require("./examples");
52
+ var import_global_styles_renderer = require("../global-styles-renderer");
53
+ var import_constants2 = require("../style-book/constants");
54
+ var import_use_global_styles_output = require("../../hooks/use-global-styles-output");
55
+ var import_global_styles = require("../global-styles");
56
+ var import_store = require("../../store");
57
+ const { ExperimentalBlockEditorProvider } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
58
+ const { Tabs } = (0, import_lock_unlock.unlock)(import_components.privateApis);
59
+ function isObjectEmpty(object) {
60
+ return !object || Object.keys(object).length === 0;
61
+ }
62
+ const scrollToSection = (anchorId, iframe) => {
63
+ if (!anchorId || !iframe || !iframe?.contentDocument) {
64
+ return;
65
+ }
66
+ const element = anchorId === "top" ? iframe.contentDocument.body : iframe.contentDocument.getElementById(anchorId);
67
+ if (element) {
68
+ element.scrollIntoView({
69
+ behavior: "smooth"
70
+ });
71
+ }
72
+ };
73
+ const getStyleBookNavigationFromPath = (path) => {
74
+ if (path && typeof path === "string") {
75
+ if (path === "/" || path.startsWith("/typography") || path.startsWith("/colors") || path.startsWith("/blocks")) {
76
+ return {
77
+ top: true
78
+ };
79
+ }
80
+ }
81
+ return null;
82
+ };
83
+ function useMultiOriginPalettes() {
84
+ const { colors, gradients } = (0, import_block_editor.__experimentalUseMultipleOriginColorsAndGradients)();
85
+ const [
86
+ shouldDisplayDefaultDuotones,
87
+ customDuotones,
88
+ themeDuotones,
89
+ defaultDuotones
90
+ ] = (0, import_block_editor.useSettings)(
91
+ "color.defaultDuotone",
92
+ "color.duotone.custom",
93
+ "color.duotone.theme",
94
+ "color.duotone.default"
95
+ );
96
+ const palettes = (0, import_element.useMemo)(() => {
97
+ const result = { colors, gradients, duotones: [] };
98
+ if (themeDuotones && themeDuotones.length) {
99
+ result.duotones.push({
100
+ name: (0, import_i18n._x)(
101
+ "Theme",
102
+ "Indicates these duotone filters come from the theme."
103
+ ),
104
+ slug: "theme",
105
+ duotones: themeDuotones
106
+ });
107
+ }
108
+ if (shouldDisplayDefaultDuotones && defaultDuotones && defaultDuotones.length) {
109
+ result.duotones.push({
110
+ name: (0, import_i18n._x)(
111
+ "Default",
112
+ "Indicates these duotone filters come from WordPress."
113
+ ),
114
+ slug: "default",
115
+ duotones: defaultDuotones
116
+ });
117
+ }
118
+ if (customDuotones && customDuotones.length) {
119
+ result.duotones.push({
120
+ name: (0, import_i18n._x)(
121
+ "Custom",
122
+ "Indicates these doutone filters are created by the user."
123
+ ),
124
+ slug: "custom",
125
+ duotones: customDuotones
126
+ });
127
+ }
128
+ return result;
129
+ }, [
130
+ colors,
131
+ gradients,
132
+ customDuotones,
133
+ themeDuotones,
134
+ defaultDuotones,
135
+ shouldDisplayDefaultDuotones
136
+ ]);
137
+ return palettes;
138
+ }
139
+ function getExamplesForSinglePageUse(examples) {
140
+ const examplesForSinglePageUse = [];
141
+ const overviewCategoryExamples = (0, import_categories.getExamplesByCategory)(
142
+ { slug: "overview" },
143
+ examples
144
+ );
145
+ examplesForSinglePageUse.push(...overviewCategoryExamples.examples);
146
+ const otherExamples = examples.filter((example) => {
147
+ return example.category !== "overview" && !overviewCategoryExamples.examples.find(
148
+ (overviewExample) => overviewExample.name === example.name
149
+ );
150
+ });
151
+ examplesForSinglePageUse.push(...otherExamples);
152
+ return examplesForSinglePageUse;
153
+ }
154
+ function applyBlockVariationsToExamples(examples, variation) {
155
+ if (!variation) {
156
+ return examples;
157
+ }
158
+ return examples.map((example) => {
159
+ return {
160
+ ...example,
161
+ variation,
162
+ blocks: Array.isArray(example.blocks) ? example.blocks.map((block) => ({
163
+ ...block,
164
+ attributes: {
165
+ ...block.attributes,
166
+ style: void 0,
167
+ className: `is-style-${variation}`
168
+ }
169
+ })) : {
170
+ ...example.blocks,
171
+ attributes: {
172
+ ...example.blocks.attributes,
173
+ style: void 0,
174
+ className: `is-style-${variation}`
175
+ }
176
+ }
177
+ };
178
+ });
179
+ }
180
+ function StyleBook({
181
+ isSelected,
182
+ onClick,
183
+ onSelect,
184
+ showTabs = true,
185
+ userConfig = {},
186
+ path = ""
187
+ }, ref) {
188
+ const textColor = (0, import_global_styles.useStyle)("color.text");
189
+ const backgroundColor = (0, import_global_styles.useStyle)("color.background");
190
+ const colors = useMultiOriginPalettes();
191
+ const examples = (0, import_element.useMemo)(() => (0, import_examples.getExamples)(colors), [colors]);
192
+ const tabs = (0, import_element.useMemo)(
193
+ () => (0, import_categories.getTopLevelStyleBookCategories)().filter(
194
+ (category) => examples.some(
195
+ (example) => example.category === category.slug
196
+ )
197
+ ),
198
+ [examples]
199
+ );
200
+ const examplesForSinglePageUse = getExamplesForSinglePageUse(examples);
201
+ const { base: baseConfig } = (0, import_global_styles.useGlobalStyles)();
202
+ const goTo = getStyleBookNavigationFromPath(path);
203
+ const mergedConfig = (0, import_element.useMemo)(() => {
204
+ if (!isObjectEmpty(userConfig) && !isObjectEmpty(baseConfig)) {
205
+ return (0, import_global_styles_engine.mergeGlobalStyles)(baseConfig, userConfig);
206
+ }
207
+ return {};
208
+ }, [baseConfig, userConfig]);
209
+ const originalSettings = (0, import_data.useSelect)(
210
+ (select) => select(import_block_editor.store).getSettings(),
211
+ []
212
+ );
213
+ const [globalStyles] = (0, import_use_global_styles_output.useGlobalStylesOutputWithConfig)(mergedConfig);
214
+ const settings = (0, import_element.useMemo)(
215
+ () => ({
216
+ ...originalSettings,
217
+ styles: !isObjectEmpty(globalStyles) && !isObjectEmpty(userConfig) ? globalStyles : originalSettings.styles,
218
+ isPreviewMode: true
219
+ }),
220
+ [globalStyles, originalSettings, userConfig]
221
+ );
222
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
223
+ "div",
224
+ {
225
+ ref,
226
+ className: (0, import_clsx.default)("editor-style-book", {
227
+ "is-button": !!onClick
228
+ }),
229
+ style: {
230
+ color: textColor,
231
+ background: backgroundColor
232
+ },
233
+ children: showTabs ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tabs, { children: [
234
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-style-book__tablist-container", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.TabList, { children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.Tab, { tabId: tab.slug, children: tab.title }, tab.slug)) }) }),
235
+ tabs.map((tab) => {
236
+ const categoryDefinition = tab.slug ? (0, import_categories.getTopLevelStyleBookCategories)().find(
237
+ (_category) => _category.slug === tab.slug
238
+ ) : null;
239
+ const filteredExamples = categoryDefinition ? (0, import_categories.getExamplesByCategory)(
240
+ categoryDefinition,
241
+ examples
242
+ ) : { examples };
243
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
244
+ Tabs.TabPanel,
245
+ {
246
+ tabId: tab.slug,
247
+ focusable: false,
248
+ className: "editor-style-book__tabpanel",
249
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
250
+ StyleBookBody,
251
+ {
252
+ category: tab.slug,
253
+ examples: filteredExamples,
254
+ isSelected,
255
+ onSelect,
256
+ settings,
257
+ title: tab.title,
258
+ goTo
259
+ }
260
+ )
261
+ },
262
+ tab.slug
263
+ );
264
+ })
265
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
266
+ StyleBookBody,
267
+ {
268
+ examples: { examples: examplesForSinglePageUse },
269
+ isSelected,
270
+ onClick,
271
+ onSelect,
272
+ settings,
273
+ goTo
274
+ }
275
+ )
276
+ }
277
+ );
278
+ }
279
+ const StyleBookPreview = ({
280
+ userConfig = {},
281
+ isStatic = false,
282
+ path,
283
+ onPathChange
284
+ }) => {
285
+ const editorSettings = (0, import_data.useSelect)(
286
+ (select) => select(import_store.store).getEditorSettings(),
287
+ []
288
+ );
289
+ const canUserUploadMedia = (0, import_data.useSelect)(
290
+ (select) => select(import_core_data.store).canUser("create", {
291
+ kind: "postType",
292
+ name: "attachment"
293
+ }),
294
+ []
295
+ );
296
+ (0, import_element.useEffect)(() => {
297
+ (0, import_data.dispatch)(import_block_editor.store).updateSettings({
298
+ ...editorSettings,
299
+ mediaUpload: canUserUploadMedia ? import_media_utils.uploadMedia : void 0
300
+ });
301
+ }, [editorSettings, canUserUploadMedia]);
302
+ const [internalPath, setInternalPath] = (0, import_element.useState)("/");
303
+ const section = path ?? internalPath;
304
+ const onChangeSection = onPathChange ?? setInternalPath;
305
+ const isSelected = (blockName) => {
306
+ return section === `/blocks/${encodeURIComponent(blockName)}` || section.startsWith(
307
+ `/blocks/${encodeURIComponent(blockName)}/`
308
+ );
309
+ };
310
+ const onSelect = (blockName, isBlockVariation = false) => {
311
+ if (import_constants2.STYLE_BOOK_COLOR_GROUPS.find(
312
+ (group) => group.slug === blockName
313
+ )) {
314
+ onChangeSection("/colors/palette");
315
+ return;
316
+ }
317
+ if (blockName === "typography") {
318
+ onChangeSection("/typography");
319
+ return;
320
+ }
321
+ if (isBlockVariation) {
322
+ return;
323
+ }
324
+ onChangeSection(`/blocks/${encodeURIComponent(blockName)}`);
325
+ };
326
+ const colors = useMultiOriginPalettes();
327
+ const examples = (0, import_examples.getExamples)(colors);
328
+ const examplesForSinglePageUse = getExamplesForSinglePageUse(examples);
329
+ let previewCategory = null;
330
+ let blockVariation = null;
331
+ if (section.includes("/colors")) {
332
+ previewCategory = "colors";
333
+ } else if (section.includes("/typography")) {
334
+ previewCategory = "text";
335
+ } else if (section.includes("/blocks")) {
336
+ previewCategory = "blocks";
337
+ let blockName = decodeURIComponent(section).split("/blocks/")[1];
338
+ if (blockName?.includes("/variations")) {
339
+ [blockName, blockVariation] = blockName.split("/variations/");
340
+ }
341
+ if (blockName && examples.find((example) => example.name === blockName)) {
342
+ previewCategory = blockName;
343
+ }
344
+ } else if (!isStatic) {
345
+ previewCategory = "overview";
346
+ }
347
+ const categoryDefinition = import_constants2.STYLE_BOOK_PREVIEW_CATEGORIES.find(
348
+ (category) => category.slug === previewCategory
349
+ );
350
+ const filteredExamples = (0, import_element.useMemo)(() => {
351
+ if (!categoryDefinition) {
352
+ return {
353
+ examples: [
354
+ examples.find(
355
+ (example) => example.name === previewCategory
356
+ )
357
+ ]
358
+ };
359
+ }
360
+ return (0, import_categories.getExamplesByCategory)(categoryDefinition, examples);
361
+ }, [categoryDefinition, examples, previewCategory]);
362
+ const displayedExamples = (0, import_element.useMemo)(() => {
363
+ if (!previewCategory) {
364
+ return { examples: examplesForSinglePageUse };
365
+ }
366
+ if (blockVariation) {
367
+ return {
368
+ examples: applyBlockVariationsToExamples(
369
+ filteredExamples.examples,
370
+ blockVariation
371
+ )
372
+ };
373
+ }
374
+ return filteredExamples;
375
+ }, [
376
+ previewCategory,
377
+ examplesForSinglePageUse,
378
+ blockVariation,
379
+ filteredExamples
380
+ ]);
381
+ const { base: baseConfig } = (0, import_global_styles.useGlobalStyles)();
382
+ const goTo = getStyleBookNavigationFromPath(section);
383
+ const mergedConfig = (0, import_element.useMemo)(() => {
384
+ if (!isObjectEmpty(userConfig) && !isObjectEmpty(baseConfig)) {
385
+ return (0, import_global_styles_engine.mergeGlobalStyles)(baseConfig, userConfig);
386
+ }
387
+ return {};
388
+ }, [baseConfig, userConfig]);
389
+ const [globalStyles] = (0, import_use_global_styles_output.useGlobalStylesOutputWithConfig)(mergedConfig);
390
+ const settings = (0, import_element.useMemo)(
391
+ () => ({
392
+ ...editorSettings,
393
+ styles: !isObjectEmpty(globalStyles) && !isObjectEmpty(userConfig) ? globalStyles : editorSettings.styles,
394
+ isPreviewMode: true
395
+ }),
396
+ [globalStyles, editorSettings, userConfig]
397
+ );
398
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-style-book", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_block_editor.BlockEditorProvider, { settings, children: [
399
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_global_styles_renderer.GlobalStylesRenderer, { disableRootPadding: true }),
400
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
401
+ StyleBookBody,
402
+ {
403
+ examples: displayedExamples,
404
+ settings,
405
+ goTo,
406
+ isSelected: !isStatic ? isSelected : null,
407
+ onSelect: !isStatic ? onSelect : null
408
+ }
409
+ )
410
+ ] }) });
411
+ };
412
+ const StyleBookBody = ({
413
+ examples,
414
+ isSelected,
415
+ onClick,
416
+ onSelect,
417
+ settings,
418
+ title,
419
+ goTo
420
+ }) => {
421
+ const [isFocused, setIsFocused] = (0, import_element.useState)(false);
422
+ const [hasIframeLoaded, setHasIframeLoaded] = (0, import_element.useState)(false);
423
+ const iframeRef = (0, import_element.useRef)(null);
424
+ const buttonModeProps = {
425
+ role: "button",
426
+ onFocus: () => setIsFocused(true),
427
+ onBlur: () => setIsFocused(false),
428
+ onKeyDown: (event) => {
429
+ if (event.defaultPrevented) {
430
+ return;
431
+ }
432
+ const { keyCode } = event;
433
+ if (onClick && (keyCode === import_keycodes.ENTER || keyCode === import_keycodes.SPACE)) {
434
+ event.preventDefault();
435
+ onClick(event);
436
+ }
437
+ },
438
+ onClick: (event) => {
439
+ if (event.defaultPrevented) {
440
+ return;
441
+ }
442
+ if (onClick) {
443
+ event.preventDefault();
444
+ onClick(event);
445
+ }
446
+ },
447
+ readonly: true
448
+ };
449
+ const handleLoad = () => setHasIframeLoaded(true);
450
+ (0, import_element.useLayoutEffect)(() => {
451
+ if (hasIframeLoaded && iframeRef?.current) {
452
+ if (goTo?.top) {
453
+ scrollToSection("top", iframeRef?.current);
454
+ }
455
+ }
456
+ }, [iframeRef?.current, goTo, scrollToSection, hasIframeLoaded]);
457
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
458
+ import_block_editor.__unstableIframe,
459
+ {
460
+ onLoad: handleLoad,
461
+ ref: iframeRef,
462
+ className: (0, import_clsx.default)("editor-style-book__iframe", {
463
+ "is-focused": isFocused && !!onClick,
464
+ "is-button": !!onClick
465
+ }),
466
+ name: "style-book-canvas",
467
+ tabIndex: 0,
468
+ ...onClick ? buttonModeProps : {},
469
+ children: [
470
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.__unstableEditorStyles, { styles: settings.styles }),
471
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("style", { children: [
472
+ import_constants.STYLE_BOOK_IFRAME_STYLES,
473
+ !!onClick && "body { cursor: pointer; } body * { pointer-events: none; }"
474
+ ] }),
475
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
476
+ Examples,
477
+ {
478
+ className: "editor-style-book__examples",
479
+ filteredExamples: examples,
480
+ label: title ? (0, import_i18n.sprintf)(
481
+ // translators: %s: Category of blocks, e.g. Text.
482
+ (0, import_i18n.__)("Examples of blocks in the %s category"),
483
+ title
484
+ ) : (0, import_i18n.__)("Examples of blocks"),
485
+ isSelected,
486
+ onSelect
487
+ },
488
+ title
489
+ )
490
+ ]
491
+ }
492
+ );
493
+ };
494
+ const Examples = (0, import_element.memo)(
495
+ ({ className, filteredExamples, label, isSelected, onSelect }) => {
496
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
497
+ import_components.Composite,
498
+ {
499
+ orientation: "vertical",
500
+ className,
501
+ "aria-label": label,
502
+ role: "grid",
503
+ children: [
504
+ !!filteredExamples?.examples?.length && filteredExamples.examples.map((example) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
505
+ Example,
506
+ {
507
+ id: `example-${example.name}`,
508
+ title: example.title,
509
+ content: example.content,
510
+ blocks: example.blocks,
511
+ isSelected: isSelected?.(example.name),
512
+ onClick: !!onSelect ? () => onSelect(
513
+ example.name,
514
+ !!example.variation
515
+ ) : null
516
+ },
517
+ example.name
518
+ )),
519
+ !!filteredExamples?.subcategories?.length && filteredExamples.subcategories.map((subcategory) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
520
+ import_components.Composite.Group,
521
+ {
522
+ className: "editor-style-book__subcategory",
523
+ children: [
524
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Composite.GroupLabel, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "editor-style-book__subcategory-title", children: subcategory.title }) }),
525
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
526
+ Subcategory,
527
+ {
528
+ examples: subcategory.examples,
529
+ isSelected,
530
+ onSelect
531
+ }
532
+ )
533
+ ]
534
+ },
535
+ `subcategory-${subcategory.slug}`
536
+ ))
537
+ ]
538
+ }
539
+ );
540
+ }
541
+ );
542
+ const Subcategory = ({ examples, isSelected, onSelect }) => {
543
+ return !!examples?.length && examples.map((example) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
544
+ Example,
545
+ {
546
+ id: `example-${example.name}`,
547
+ title: example.title,
548
+ content: example.content,
549
+ blocks: example.blocks,
550
+ isSelected: isSelected?.(example.name),
551
+ onClick: !!onSelect ? () => onSelect(example.name) : null
552
+ },
553
+ example.name
554
+ ));
555
+ };
556
+ const disabledExamples = ["example-duotones"];
557
+ const Example = ({ id, title, blocks, isSelected, onClick, content }) => {
558
+ const originalSettings = (0, import_data.useSelect)(
559
+ (select) => select(import_block_editor.store).getSettings(),
560
+ []
561
+ );
562
+ const settings = (0, import_element.useMemo)(
563
+ () => ({
564
+ ...originalSettings,
565
+ focusMode: false,
566
+ // Disable "Spotlight mode".
567
+ isPreviewMode: true
568
+ }),
569
+ [originalSettings]
570
+ );
571
+ const renderedBlocks = (0, import_element.useMemo)(
572
+ () => Array.isArray(blocks) ? blocks : [blocks],
573
+ [blocks]
574
+ );
575
+ const disabledProps = disabledExamples.includes(id) || !onClick ? {
576
+ disabled: true,
577
+ accessibleWhenDisabled: !!onClick
578
+ } : {};
579
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { role: "row", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
580
+ import_components.Composite.Item,
581
+ {
582
+ className: (0, import_clsx.default)("editor-style-book__example", {
583
+ "is-selected": isSelected,
584
+ "is-disabled-example": !!disabledProps?.disabled
585
+ }),
586
+ id,
587
+ "aria-label": !!onClick ? (0, import_i18n.sprintf)(
588
+ // translators: %s: Title of a block, e.g. Heading.
589
+ (0, import_i18n.__)("Open %s styles in Styles panel"),
590
+ title
591
+ ) : void 0,
592
+ render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {}),
593
+ role: !!onClick ? "button" : null,
594
+ onClick,
595
+ ...disabledProps,
596
+ children: [
597
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "editor-style-book__example-title", children: title }),
598
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
599
+ "div",
600
+ {
601
+ className: "editor-style-book__example-preview",
602
+ "aria-hidden": true,
603
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Disabled, { className: "editor-style-book__example-preview__content", children: content ? content : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
604
+ ExperimentalBlockEditorProvider,
605
+ {
606
+ value: renderedBlocks,
607
+ settings,
608
+ children: [
609
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.__unstableEditorStyles, {}),
610
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockList, { renderAppender: false })
611
+ ]
612
+ }
613
+ ) })
614
+ }
615
+ )
616
+ ]
617
+ }
618
+ ) }) });
619
+ };
620
+ var style_book_default = (0, import_element.forwardRef)(StyleBook);
621
+ // Annotate the CommonJS export names for ESM import in node:
622
+ 0 && (module.exports = {
623
+ StyleBookBody,
624
+ StyleBookPreview,
625
+ getExamplesForSinglePageUse
626
+ });
627
+ //# sourceMappingURL=index.js.map