@wordpress/editor 14.3.0 → 14.4.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 (400) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -1
  3. package/build/bindings/api.js +65 -0
  4. package/build/bindings/api.js.map +1 -0
  5. package/build/bindings/pattern-overrides.js +23 -13
  6. package/build/bindings/pattern-overrides.js.map +1 -1
  7. package/build/bindings/post-meta.js +23 -12
  8. package/build/bindings/post-meta.js.map +1 -1
  9. package/build/components/block-settings-menu/content-only-settings-menu.js +4 -1
  10. package/build/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
  11. package/build/components/blog-title/index.js +6 -2
  12. package/build/components/blog-title/index.js.map +1 -1
  13. package/build/components/collapsible-block-toolbar/index.js +2 -3
  14. package/build/components/collapsible-block-toolbar/index.js.map +1 -1
  15. package/build/components/global-styles-provider/index.js +15 -3
  16. package/build/components/global-styles-provider/index.js.map +1 -1
  17. package/build/components/header/back-button.js +7 -8
  18. package/build/components/header/back-button.js.map +1 -1
  19. package/build/components/header/index.js +19 -17
  20. package/build/components/header/index.js.map +1 -1
  21. package/build/components/page-attributes/order.js +1 -67
  22. package/build/components/page-attributes/order.js.map +1 -1
  23. package/build/components/page-attributes/panel.js +1 -4
  24. package/build/components/page-attributes/panel.js.map +1 -1
  25. package/build/components/post-actions/actions.js +126 -33
  26. package/build/components/post-actions/actions.js.map +1 -1
  27. package/build/components/post-card-panel/index.js +8 -2
  28. package/build/components/post-card-panel/index.js.map +1 -1
  29. package/build/components/post-comments/index.js +1 -1
  30. package/build/components/post-comments/index.js.map +1 -1
  31. package/build/components/post-content-information/index.js +7 -1
  32. package/build/components/post-content-information/index.js.map +1 -1
  33. package/build/components/post-discussion/panel.js +2 -2
  34. package/build/components/post-discussion/panel.js.map +1 -1
  35. package/build/components/post-excerpt/panel.js +1 -1
  36. package/build/components/post-excerpt/panel.js.map +1 -1
  37. package/build/components/post-featured-image/index.js +3 -1
  38. package/build/components/post-featured-image/index.js.map +1 -1
  39. package/build/components/post-last-revision/index.js +2 -1
  40. package/build/components/post-last-revision/index.js.map +1 -1
  41. package/build/components/post-publish-button/index.js +4 -11
  42. package/build/components/post-publish-button/index.js.map +1 -1
  43. package/build/components/post-publish-panel/maybe-category-panel.js +4 -1
  44. package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  45. package/build/components/post-publish-panel/maybe-tags-panel.js +2 -1
  46. package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  47. package/build/components/post-status/index.js +30 -10
  48. package/build/components/post-status/index.js.map +1 -1
  49. package/build/components/post-taxonomies/flat-term-selector.js +17 -6
  50. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  51. package/build/components/post-taxonomies/index.js +7 -1
  52. package/build/components/post-taxonomies/index.js.map +1 -1
  53. package/build/components/post-template/block-theme.js +4 -4
  54. package/build/components/post-template/block-theme.js.map +1 -1
  55. package/build/components/post-template/classic-theme.js +8 -2
  56. package/build/components/post-template/classic-theme.js.map +1 -1
  57. package/build/components/post-template/create-new-template.js +4 -1
  58. package/build/components/post-template/create-new-template.js.map +1 -1
  59. package/build/components/post-template/hooks.js +5 -1
  60. package/build/components/post-template/hooks.js.map +1 -1
  61. package/build/components/post-template/panel.js +8 -2
  62. package/build/components/post-template/panel.js.map +1 -1
  63. package/build/components/post-trash/check.js +6 -4
  64. package/build/components/post-trash/check.js.map +1 -1
  65. package/build/components/post-url/panel.js +6 -2
  66. package/build/components/post-url/panel.js.map +1 -1
  67. package/build/components/posts-per-page/index.js +6 -2
  68. package/build/components/posts-per-page/index.js.map +1 -1
  69. package/build/components/provider/use-block-editor-settings.js +15 -6
  70. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  71. package/build/components/save-publish-panels/index.js +1 -2
  72. package/build/components/save-publish-panels/index.js.map +1 -1
  73. package/build/components/sidebar/index.js +3 -9
  74. package/build/components/sidebar/index.js.map +1 -1
  75. package/build/components/site-discussion/index.js +7 -3
  76. package/build/components/site-discussion/index.js.map +1 -1
  77. package/build/components/template-content-panel/index.js +5 -5
  78. package/build/components/template-content-panel/index.js.map +1 -1
  79. package/build/components/visual-editor/edit-template-blocks-notification.js +4 -4
  80. package/build/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  81. package/build/components/visual-editor/index.js +5 -2
  82. package/build/components/visual-editor/index.js.map +1 -1
  83. package/build/{hooks → components/visual-editor}/use-select-nearest-editable-block.js +1 -1
  84. package/build/components/visual-editor/use-select-nearest-editable-block.js.map +1 -0
  85. package/build/dataviews/actions/delete-post.js +2 -0
  86. package/build/dataviews/actions/delete-post.js.map +1 -1
  87. package/build/hooks/pattern-overrides.js +1 -1
  88. package/build/hooks/pattern-overrides.js.map +1 -1
  89. package/build/index.js +0 -1
  90. package/build/index.js.map +1 -1
  91. package/build/private-apis.js +3 -0
  92. package/build/private-apis.js.map +1 -1
  93. package/build/utils/media-upload/index.js +35 -2
  94. package/build/utils/media-upload/index.js.map +1 -1
  95. package/build-module/bindings/api.js +57 -0
  96. package/build-module/bindings/api.js.map +1 -0
  97. package/build-module/bindings/pattern-overrides.js +23 -13
  98. package/build-module/bindings/pattern-overrides.js.map +1 -1
  99. package/build-module/bindings/post-meta.js +23 -12
  100. package/build-module/bindings/post-meta.js.map +1 -1
  101. package/build-module/components/block-settings-menu/content-only-settings-menu.js +4 -1
  102. package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
  103. package/build-module/components/blog-title/index.js +6 -2
  104. package/build-module/components/blog-title/index.js.map +1 -1
  105. package/build-module/components/collapsible-block-toolbar/index.js +1 -2
  106. package/build-module/components/collapsible-block-toolbar/index.js.map +1 -1
  107. package/build-module/components/global-styles-provider/index.js +15 -3
  108. package/build-module/components/global-styles-provider/index.js.map +1 -1
  109. package/build-module/components/header/back-button.js +5 -7
  110. package/build-module/components/header/back-button.js.map +1 -1
  111. package/build-module/components/header/index.js +19 -19
  112. package/build-module/components/header/index.js.map +1 -1
  113. package/build-module/components/page-attributes/order.js +4 -70
  114. package/build-module/components/page-attributes/order.js.map +1 -1
  115. package/build-module/components/page-attributes/panel.js +1 -6
  116. package/build-module/components/page-attributes/panel.js.map +1 -1
  117. package/build-module/components/post-actions/actions.js +127 -34
  118. package/build-module/components/post-actions/actions.js.map +1 -1
  119. package/build-module/components/post-card-panel/index.js +8 -2
  120. package/build-module/components/post-card-panel/index.js.map +1 -1
  121. package/build-module/components/post-comments/index.js +2 -2
  122. package/build-module/components/post-comments/index.js.map +1 -1
  123. package/build-module/components/post-content-information/index.js +7 -1
  124. package/build-module/components/post-content-information/index.js.map +1 -1
  125. package/build-module/components/post-discussion/panel.js +3 -3
  126. package/build-module/components/post-discussion/panel.js.map +1 -1
  127. package/build-module/components/post-excerpt/panel.js +1 -1
  128. package/build-module/components/post-excerpt/panel.js.map +1 -1
  129. package/build-module/components/post-featured-image/index.js +3 -1
  130. package/build-module/components/post-featured-image/index.js.map +1 -1
  131. package/build-module/components/post-last-revision/index.js +2 -1
  132. package/build-module/components/post-last-revision/index.js.map +1 -1
  133. package/build-module/components/post-publish-button/index.js +4 -11
  134. package/build-module/components/post-publish-button/index.js.map +1 -1
  135. package/build-module/components/post-publish-panel/maybe-category-panel.js +4 -1
  136. package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  137. package/build-module/components/post-publish-panel/maybe-tags-panel.js +2 -1
  138. package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  139. package/build-module/components/post-status/index.js +30 -10
  140. package/build-module/components/post-status/index.js.map +1 -1
  141. package/build-module/components/post-taxonomies/flat-term-selector.js +17 -6
  142. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  143. package/build-module/components/post-taxonomies/index.js +7 -1
  144. package/build-module/components/post-taxonomies/index.js.map +1 -1
  145. package/build-module/components/post-template/block-theme.js +4 -4
  146. package/build-module/components/post-template/block-theme.js.map +1 -1
  147. package/build-module/components/post-template/classic-theme.js +8 -2
  148. package/build-module/components/post-template/classic-theme.js.map +1 -1
  149. package/build-module/components/post-template/create-new-template.js +4 -1
  150. package/build-module/components/post-template/create-new-template.js.map +1 -1
  151. package/build-module/components/post-template/hooks.js +5 -1
  152. package/build-module/components/post-template/hooks.js.map +1 -1
  153. package/build-module/components/post-template/panel.js +8 -2
  154. package/build-module/components/post-template/panel.js.map +1 -1
  155. package/build-module/components/post-trash/check.js +6 -4
  156. package/build-module/components/post-trash/check.js.map +1 -1
  157. package/build-module/components/post-url/panel.js +6 -2
  158. package/build-module/components/post-url/panel.js.map +1 -1
  159. package/build-module/components/posts-per-page/index.js +6 -2
  160. package/build-module/components/posts-per-page/index.js.map +1 -1
  161. package/build-module/components/provider/use-block-editor-settings.js +15 -6
  162. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  163. package/build-module/components/save-publish-panels/index.js +1 -2
  164. package/build-module/components/save-publish-panels/index.js.map +1 -1
  165. package/build-module/components/sidebar/index.js +3 -9
  166. package/build-module/components/sidebar/index.js.map +1 -1
  167. package/build-module/components/site-discussion/index.js +8 -4
  168. package/build-module/components/site-discussion/index.js.map +1 -1
  169. package/build-module/components/template-content-panel/index.js +5 -5
  170. package/build-module/components/template-content-panel/index.js.map +1 -1
  171. package/build-module/components/visual-editor/edit-template-blocks-notification.js +4 -4
  172. package/build-module/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  173. package/build-module/components/visual-editor/index.js +5 -2
  174. package/build-module/components/visual-editor/index.js.map +1 -1
  175. package/build-module/{hooks → components/visual-editor}/use-select-nearest-editable-block.js +1 -1
  176. package/build-module/components/visual-editor/use-select-nearest-editable-block.js.map +1 -0
  177. package/build-module/dataviews/actions/delete-post.js +2 -0
  178. package/build-module/dataviews/actions/delete-post.js.map +1 -1
  179. package/build-module/hooks/pattern-overrides.js +1 -1
  180. package/build-module/hooks/pattern-overrides.js.map +1 -1
  181. package/build-module/index.js +0 -1
  182. package/build-module/index.js.map +1 -1
  183. package/build-module/private-apis.js +3 -0
  184. package/build-module/private-apis.js.map +1 -1
  185. package/build-module/utils/media-upload/index.js +36 -3
  186. package/build-module/utils/media-upload/index.js.map +1 -1
  187. package/build-style/style-rtl.css +78 -42
  188. package/build-style/style.css +78 -42
  189. package/build-types/bindings/api.d.ts +25 -0
  190. package/build-types/bindings/api.d.ts.map +1 -0
  191. package/build-types/bindings/pattern-overrides.d.ts +5 -6
  192. package/build-types/bindings/pattern-overrides.d.ts.map +1 -1
  193. package/build-types/bindings/post-meta.d.ts +5 -7
  194. package/build-types/bindings/post-meta.d.ts.map +1 -1
  195. package/build-types/components/autocompleters/user.d.ts +2 -2
  196. package/build-types/components/autocompleters/user.d.ts.map +1 -1
  197. package/build-types/components/block-settings-menu/plugin-block-settings-menu-item.d.ts.map +1 -1
  198. package/build-types/components/blog-title/index.d.ts.map +1 -1
  199. package/build-types/components/collapsible-block-toolbar/index.d.ts +1 -2
  200. package/build-types/components/collapsible-block-toolbar/index.d.ts.map +1 -1
  201. package/build-types/components/document-bar/index.d.ts.map +1 -1
  202. package/build-types/components/document-outline/check.d.ts.map +1 -1
  203. package/build-types/components/document-outline/index.d.ts.map +1 -1
  204. package/build-types/components/editor-history/redo.d.ts +1 -1
  205. package/build-types/components/editor-history/undo.d.ts +1 -1
  206. package/build-types/components/editor-notices/index.d.ts.map +1 -1
  207. package/build-types/components/editor-snackbars/index.d.ts.map +1 -1
  208. package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
  209. package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
  210. package/build-types/components/header/back-button.d.ts +1 -0
  211. package/build-types/components/header/back-button.d.ts.map +1 -1
  212. package/build-types/components/header/index.d.ts.map +1 -1
  213. package/build-types/components/local-autosave-monitor/index.d.ts.map +1 -1
  214. package/build-types/components/media-categories/index.d.ts.map +1 -1
  215. package/build-types/components/more-menu/tools-more-menu-group.d.ts.map +1 -1
  216. package/build-types/components/more-menu/view-more-menu-group.d.ts.map +1 -1
  217. package/build-types/components/page-attributes/check.d.ts.map +1 -1
  218. package/build-types/components/page-attributes/order.d.ts +1 -1
  219. package/build-types/components/page-attributes/order.d.ts.map +1 -1
  220. package/build-types/components/page-attributes/panel.d.ts.map +1 -1
  221. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  222. package/build-types/components/plugin-document-setting-panel/index.d.ts.map +1 -1
  223. package/build-types/components/plugin-post-publish-panel/index.d.ts.map +1 -1
  224. package/build-types/components/plugin-post-status-info/index.d.ts.map +1 -1
  225. package/build-types/components/plugin-pre-publish-panel/index.d.ts.map +1 -1
  226. package/build-types/components/plugin-sidebar/index.d.ts.map +1 -1
  227. package/build-types/components/plugin-sidebar-more-menu-item/index.d.ts.map +1 -1
  228. package/build-types/components/post-actions/actions.d.ts.map +1 -1
  229. package/build-types/components/post-author/check.d.ts.map +1 -1
  230. package/build-types/components/post-author/index.d.ts.map +1 -1
  231. package/build-types/components/post-author/panel.d.ts.map +1 -1
  232. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  233. package/build-types/components/post-content-information/index.d.ts.map +1 -1
  234. package/build-types/components/post-discussion/panel.d.ts.map +1 -1
  235. package/build-types/components/post-excerpt/check.d.ts.map +1 -1
  236. package/build-types/components/post-excerpt/index.d.ts.map +1 -1
  237. package/build-types/components/post-excerpt/panel.d.ts.map +1 -1
  238. package/build-types/components/post-excerpt/plugin.d.ts.map +1 -1
  239. package/build-types/components/post-featured-image/check.d.ts.map +1 -1
  240. package/build-types/components/post-featured-image/panel.d.ts.map +1 -1
  241. package/build-types/components/post-format/index.d.ts.map +1 -1
  242. package/build-types/components/post-format/panel.d.ts.map +1 -1
  243. package/build-types/components/post-last-revision/check.d.ts.map +1 -1
  244. package/build-types/components/post-last-revision/index.d.ts.map +1 -1
  245. package/build-types/components/post-last-revision/panel.d.ts.map +1 -1
  246. package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
  247. package/build-types/components/post-pending-status/check.d.ts.map +1 -1
  248. package/build-types/components/post-pending-status/index.d.ts.map +1 -1
  249. package/build-types/components/post-preview-button/index.d.ts.map +1 -1
  250. package/build-types/components/post-publish-button/index.d.ts.map +1 -1
  251. package/build-types/components/post-publish-panel/maybe-category-panel.d.ts.map +1 -1
  252. package/build-types/components/post-saved-state/index.d.ts +1 -1
  253. package/build-types/components/post-saved-state/index.d.ts.map +1 -1
  254. package/build-types/components/post-schedule/check.d.ts.map +1 -1
  255. package/build-types/components/post-schedule/index.d.ts.map +1 -1
  256. package/build-types/components/post-schedule/label.d.ts.map +1 -1
  257. package/build-types/components/post-schedule/panel.d.ts.map +1 -1
  258. package/build-types/components/post-slug/check.d.ts.map +1 -1
  259. package/build-types/components/post-slug/index.d.ts.map +1 -1
  260. package/build-types/components/post-status/index.d.ts.map +1 -1
  261. package/build-types/components/post-sticky/check.d.ts.map +1 -1
  262. package/build-types/components/post-sticky/index.d.ts.map +1 -1
  263. package/build-types/components/post-switch-to-draft-button/index.d.ts.map +1 -1
  264. package/build-types/components/post-sync-status/index.d.ts.map +1 -1
  265. package/build-types/components/post-taxonomies/check.d.ts.map +1 -1
  266. package/build-types/components/post-taxonomies/flat-term-selector.d.ts +9 -7
  267. package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
  268. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +13 -11
  269. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
  270. package/build-types/components/post-taxonomies/index.d.ts.map +1 -1
  271. package/build-types/components/post-template/block-theme.d.ts.map +1 -1
  272. package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
  273. package/build-types/components/post-template/create-new-template.d.ts.map +1 -1
  274. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  275. package/build-types/components/post-template/panel.d.ts.map +1 -1
  276. package/build-types/components/post-text-editor/index.d.ts.map +1 -1
  277. package/build-types/components/post-trash/check.d.ts.map +1 -1
  278. package/build-types/components/post-trash/index.d.ts.map +1 -1
  279. package/build-types/components/post-type-support-check/index.d.ts.map +1 -1
  280. package/build-types/components/post-url/check.d.ts.map +1 -1
  281. package/build-types/components/post-url/index.d.ts.map +1 -1
  282. package/build-types/components/post-url/label.d.ts.map +1 -1
  283. package/build-types/components/post-url/panel.d.ts.map +1 -1
  284. package/build-types/components/post-visibility/check.d.ts.map +1 -1
  285. package/build-types/components/post-visibility/index.d.ts.map +1 -1
  286. package/build-types/components/posts-per-page/index.d.ts.map +1 -1
  287. package/build-types/components/preferences-modal/enable-plugin-document-setting-panel.d.ts.map +1 -1
  288. package/build-types/components/provider/index.d.ts.map +1 -1
  289. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  290. package/build-types/components/save-publish-panels/index.d.ts.map +1 -1
  291. package/build-types/components/sidebar/index.d.ts.map +1 -1
  292. package/build-types/components/site-discussion/index.d.ts.map +1 -1
  293. package/build-types/components/template-content-panel/index.d.ts +1 -3
  294. package/build-types/components/template-content-panel/index.d.ts.map +1 -1
  295. package/build-types/components/theme-support-check/index.d.ts.map +1 -1
  296. package/build-types/components/time-to-read/index.d.ts.map +1 -1
  297. package/build-types/components/unsaved-changes-warning/index.d.ts.map +1 -1
  298. package/build-types/components/visual-editor/edit-template-blocks-notification.d.ts +1 -1
  299. package/build-types/components/visual-editor/edit-template-blocks-notification.d.ts.map +1 -1
  300. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  301. package/build-types/components/visual-editor/use-select-nearest-editable-block.d.ts.map +1 -0
  302. package/build-types/components/word-count/index.d.ts.map +1 -1
  303. package/build-types/dataviews/actions/delete-post.d.ts.map +1 -1
  304. package/build-types/dataviews/api.d.ts +1 -1
  305. package/build-types/dataviews/api.d.ts.map +1 -1
  306. package/build-types/dataviews/store/private-selectors.d.ts +0 -1
  307. package/build-types/dataviews/store/private-selectors.d.ts.map +1 -1
  308. package/build-types/hooks/custom-sources-backwards-compatibility.d.ts +1 -1
  309. package/build-types/hooks/custom-sources-backwards-compatibility.d.ts.map +1 -1
  310. package/build-types/hooks/pattern-overrides.d.ts.map +1 -1
  311. package/build-types/private-apis.d.ts.map +1 -1
  312. package/build-types/store/actions.d.ts.map +1 -1
  313. package/build-types/store/private-actions.d.ts.map +1 -1
  314. package/build-types/store/reducer.d.ts.map +1 -1
  315. package/build-types/store/selectors.d.ts +0 -1
  316. package/build-types/store/selectors.d.ts.map +1 -1
  317. package/build-types/utils/media-upload/index.d.ts.map +1 -1
  318. package/package.json +38 -37
  319. package/src/bindings/api.js +57 -0
  320. package/src/bindings/pattern-overrides.js +28 -17
  321. package/src/bindings/post-meta.js +19 -14
  322. package/src/components/block-settings-menu/content-only-settings-menu.js +4 -4
  323. package/src/components/blog-title/index.js +7 -2
  324. package/src/components/collapsible-block-toolbar/index.js +1 -3
  325. package/src/components/collapsible-block-toolbar/style.scss +0 -3
  326. package/src/components/document-bar/style.scss +1 -5
  327. package/src/components/document-tools/style.scss +4 -4
  328. package/src/components/editor-interface/style.scss +4 -0
  329. package/src/components/global-styles-provider/index.js +22 -11
  330. package/src/components/header/back-button.js +6 -6
  331. package/src/components/header/index.js +26 -25
  332. package/src/components/header/style.scss +64 -21
  333. package/src/components/inserter-sidebar/style.scss +1 -6
  334. package/src/components/page-attributes/order.js +3 -77
  335. package/src/components/page-attributes/panel.js +1 -7
  336. package/src/components/post-actions/actions.js +150 -32
  337. package/src/components/post-card-panel/index.js +8 -2
  338. package/src/components/post-comments/index.js +2 -2
  339. package/src/components/post-content-information/index.js +7 -1
  340. package/src/components/post-discussion/panel.js +5 -3
  341. package/src/components/post-excerpt/panel.js +2 -1
  342. package/src/components/post-featured-image/index.js +5 -1
  343. package/src/components/post-last-revision/index.js +1 -0
  344. package/src/components/post-panel-row/style.scss +0 -1
  345. package/src/components/post-publish-button/index.js +4 -17
  346. package/src/components/post-publish-panel/maybe-category-panel.js +4 -1
  347. package/src/components/post-publish-panel/maybe-tags-panel.js +1 -1
  348. package/src/components/post-status/index.js +18 -10
  349. package/src/components/post-taxonomies/flat-term-selector.js +19 -5
  350. package/src/components/post-taxonomies/index.js +8 -1
  351. package/src/components/post-template/block-theme.js +5 -1
  352. package/src/components/post-template/classic-theme.js +8 -3
  353. package/src/components/post-template/create-new-template.js +4 -1
  354. package/src/components/post-template/hooks.js +8 -2
  355. package/src/components/post-template/panel.js +10 -2
  356. package/src/components/post-trash/check.js +9 -5
  357. package/src/components/post-url/panel.js +7 -2
  358. package/src/components/posts-per-page/index.js +7 -2
  359. package/src/components/provider/use-block-editor-settings.js +15 -6
  360. package/src/components/save-publish-panels/index.js +1 -4
  361. package/src/components/sidebar/index.js +2 -5
  362. package/src/components/site-discussion/index.js +9 -4
  363. package/src/components/template-content-panel/index.js +3 -2
  364. package/src/components/visual-editor/edit-template-blocks-notification.js +5 -1
  365. package/src/components/visual-editor/index.js +5 -2
  366. package/src/components/visual-editor/style.scss +0 -1
  367. package/src/{hooks → components/visual-editor}/use-select-nearest-editable-block.js +1 -1
  368. package/src/dataviews/actions/delete-post.tsx +2 -0
  369. package/src/hooks/pattern-overrides.js +1 -1
  370. package/src/index.js +0 -1
  371. package/src/private-apis.js +6 -0
  372. package/src/store/test/actions.js +9 -3
  373. package/src/utils/media-upload/index.js +38 -3
  374. package/tsconfig.tsbuildinfo +1 -1
  375. package/build/bindings/index.js +0 -22
  376. package/build/bindings/index.js.map +0 -1
  377. package/build/hooks/use-select-nearest-editable-block.js.map +0 -1
  378. package/build/store/utils/get-filtered-template-parts.js +0 -71
  379. package/build/store/utils/get-filtered-template-parts.js.map +0 -1
  380. package/build/utils/set-nested-value.js +0 -44
  381. package/build/utils/set-nested-value.js.map +0 -1
  382. package/build-module/bindings/index.js +0 -17
  383. package/build-module/bindings/index.js.map +0 -1
  384. package/build-module/hooks/use-select-nearest-editable-block.js.map +0 -1
  385. package/build-module/store/utils/get-filtered-template-parts.js +0 -64
  386. package/build-module/store/utils/get-filtered-template-parts.js.map +0 -1
  387. package/build-module/utils/set-nested-value.js +0 -38
  388. package/build-module/utils/set-nested-value.js.map +0 -1
  389. package/build-types/bindings/index.d.ts +0 -2
  390. package/build-types/bindings/index.d.ts.map +0 -1
  391. package/build-types/hooks/use-select-nearest-editable-block.d.ts.map +0 -1
  392. package/build-types/store/utils/get-filtered-template-parts.d.ts +0 -3
  393. package/build-types/store/utils/get-filtered-template-parts.d.ts.map +0 -1
  394. package/build-types/utils/set-nested-value.d.ts +0 -20
  395. package/build-types/utils/set-nested-value.d.ts.map +0 -1
  396. package/src/bindings/index.js +0 -15
  397. package/src/store/utils/get-filtered-template-parts.js +0 -69
  398. package/src/store/utils/test/get-filtered-template-parts.js +0 -189
  399. package/src/utils/set-nested-value.js +0 -39
  400. /package/build-types/{hooks → components/visual-editor}/use-select-nearest-editable-block.d.ts +0 -0
@@ -4,9 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = mediaUpload;
7
+ var _uuid = require("uuid");
7
8
  var _data = require("@wordpress/data");
8
9
  var _mediaUtils = require("@wordpress/media-utils");
9
10
  var _store = require("../../store");
11
+ /**
12
+ * External dependencies
13
+ */
14
+
10
15
  /**
11
16
  * WordPress dependencies
12
17
  */
@@ -41,18 +46,43 @@ function mediaUpload({
41
46
  getCurrentPost,
42
47
  getEditorSettings
43
48
  } = (0, _data.select)(_store.store);
49
+ const {
50
+ lockPostAutosaving,
51
+ unlockPostAutosaving,
52
+ lockPostSaving,
53
+ unlockPostSaving
54
+ } = (0, _data.dispatch)(_store.store);
44
55
  const wpAllowedMimeTypes = getEditorSettings().allowedMimeTypes;
56
+ const lockKey = `image-upload-${(0, _uuid.v4)()}`;
57
+ let imageIsUploading = false;
45
58
  maxUploadFileSize = maxUploadFileSize || getEditorSettings().maxUploadFileSize;
46
59
  const currentPost = getCurrentPost();
47
60
  // Templates and template parts' numerical ID is stored in `wp_id`.
48
61
  const currentPostId = typeof currentPost?.id === 'number' ? currentPost.id : currentPost?.wp_id;
62
+ const setSaveLock = () => {
63
+ lockPostSaving(lockKey);
64
+ lockPostAutosaving(lockKey);
65
+ imageIsUploading = true;
66
+ };
49
67
  const postData = currentPostId ? {
50
68
  post: currentPostId
51
69
  } : {};
70
+ const clearSaveLock = () => {
71
+ unlockPostSaving(lockKey);
72
+ unlockPostAutosaving(lockKey);
73
+ imageIsUploading = false;
74
+ };
52
75
  (0, _mediaUtils.uploadMedia)({
53
76
  allowedTypes,
54
77
  filesList,
55
- onFileChange,
78
+ onFileChange: file => {
79
+ if (!imageIsUploading) {
80
+ setSaveLock();
81
+ } else {
82
+ clearSaveLock();
83
+ }
84
+ onFileChange(file);
85
+ },
56
86
  additionalData: {
57
87
  ...postData,
58
88
  ...additionalData
@@ -60,7 +90,10 @@ function mediaUpload({
60
90
  maxUploadFileSize,
61
91
  onError: ({
62
92
  message
63
- }) => onError(message),
93
+ }) => {
94
+ clearSaveLock();
95
+ onError(message);
96
+ },
64
97
  wpAllowedMimeTypes
65
98
  });
66
99
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_mediaUtils","_store","noop","mediaUpload","additionalData","allowedTypes","filesList","maxUploadFileSize","onError","onFileChange","getCurrentPost","getEditorSettings","select","editorStore","wpAllowedMimeTypes","allowedMimeTypes","currentPost","currentPostId","id","wp_id","postData","post","uploadMedia","message"],"sources":["@wordpress/editor/src/utils/media-upload/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { select } from '@wordpress/data';\nimport { uploadMedia } from '@wordpress/media-utils';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nconst noop = () => {};\n\n/**\n * Upload a media file when the file upload button is activated.\n * Wrapper around mediaUpload() that injects the current post ID.\n *\n * @param {Object} $0 Parameters object passed to the function.\n * @param {?Object} $0.additionalData Additional data to include in the request.\n * @param {string} $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.\n * @param {Array} $0.filesList List of files.\n * @param {?number} $0.maxUploadFileSize Maximum upload size in bytes allowed for the site.\n * @param {Function} $0.onError Function called when an error happens.\n * @param {Function} $0.onFileChange Function called each time a file or a temporary representation of the file is available.\n */\nexport default function mediaUpload( {\n\tadditionalData = {},\n\tallowedTypes,\n\tfilesList,\n\tmaxUploadFileSize,\n\tonError = noop,\n\tonFileChange,\n} ) {\n\tconst { getCurrentPost, getEditorSettings } = select( editorStore );\n\tconst wpAllowedMimeTypes = getEditorSettings().allowedMimeTypes;\n\tmaxUploadFileSize =\n\t\tmaxUploadFileSize || getEditorSettings().maxUploadFileSize;\n\tconst currentPost = getCurrentPost();\n\t// Templates and template parts' numerical ID is stored in `wp_id`.\n\tconst currentPostId =\n\t\ttypeof currentPost?.id === 'number'\n\t\t\t? currentPost.id\n\t\t\t: currentPost?.wp_id;\n\tconst postData = currentPostId ? { post: currentPostId } : {};\n\n\tuploadMedia( {\n\t\tallowedTypes,\n\t\tfilesList,\n\t\tonFileChange,\n\t\tadditionalData: {\n\t\t\t...postData,\n\t\t\t...additionalData,\n\t\t},\n\t\tmaxUploadFileSize,\n\t\tonError: ( { message } ) => onError( message ),\n\t\twpAllowedMimeTypes,\n\t} );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA,MAAMG,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,WAAWA,CAAE;EACpCC,cAAc,GAAG,CAAC,CAAC;EACnBC,YAAY;EACZC,SAAS;EACTC,iBAAiB;EACjBC,OAAO,GAAGN,IAAI;EACdO;AACD,CAAC,EAAG;EACH,MAAM;IAAEC,cAAc;IAAEC;EAAkB,CAAC,GAAG,IAAAC,YAAM,EAAEC,YAAY,CAAC;EACnE,MAAMC,kBAAkB,GAAGH,iBAAiB,CAAC,CAAC,CAACI,gBAAgB;EAC/DR,iBAAiB,GAChBA,iBAAiB,IAAII,iBAAiB,CAAC,CAAC,CAACJ,iBAAiB;EAC3D,MAAMS,WAAW,GAAGN,cAAc,CAAC,CAAC;EACpC;EACA,MAAMO,aAAa,GAClB,OAAOD,WAAW,EAAEE,EAAE,KAAK,QAAQ,GAChCF,WAAW,CAACE,EAAE,GACdF,WAAW,EAAEG,KAAK;EACtB,MAAMC,QAAQ,GAAGH,aAAa,GAAG;IAAEI,IAAI,EAAEJ;EAAc,CAAC,GAAG,CAAC,CAAC;EAE7D,IAAAK,uBAAW,EAAE;IACZjB,YAAY;IACZC,SAAS;IACTG,YAAY;IACZL,cAAc,EAAE;MACf,GAAGgB,QAAQ;MACX,GAAGhB;IACJ,CAAC;IACDG,iBAAiB;IACjBC,OAAO,EAAEA,CAAE;MAAEe;IAAQ,CAAC,KAAMf,OAAO,CAAEe,OAAQ,CAAC;IAC9CT;EACD,CAAE,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["_uuid","require","_data","_mediaUtils","_store","noop","mediaUpload","additionalData","allowedTypes","filesList","maxUploadFileSize","onError","onFileChange","getCurrentPost","getEditorSettings","select","editorStore","lockPostAutosaving","unlockPostAutosaving","lockPostSaving","unlockPostSaving","dispatch","wpAllowedMimeTypes","allowedMimeTypes","lockKey","uuid","imageIsUploading","currentPost","currentPostId","id","wp_id","setSaveLock","postData","post","clearSaveLock","uploadMedia","file","message"],"sources":["@wordpress/editor/src/utils/media-upload/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { v4 as uuid } from 'uuid';\n\n/**\n * WordPress dependencies\n */\nimport { select, dispatch } from '@wordpress/data';\nimport { uploadMedia } from '@wordpress/media-utils';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nconst noop = () => {};\n\n/**\n * Upload a media file when the file upload button is activated.\n * Wrapper around mediaUpload() that injects the current post ID.\n *\n * @param {Object} $0 Parameters object passed to the function.\n * @param {?Object} $0.additionalData Additional data to include in the request.\n * @param {string} $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.\n * @param {Array} $0.filesList List of files.\n * @param {?number} $0.maxUploadFileSize Maximum upload size in bytes allowed for the site.\n * @param {Function} $0.onError Function called when an error happens.\n * @param {Function} $0.onFileChange Function called each time a file or a temporary representation of the file is available.\n */\nexport default function mediaUpload( {\n\tadditionalData = {},\n\tallowedTypes,\n\tfilesList,\n\tmaxUploadFileSize,\n\tonError = noop,\n\tonFileChange,\n} ) {\n\tconst { getCurrentPost, getEditorSettings } = select( editorStore );\n\tconst {\n\t\tlockPostAutosaving,\n\t\tunlockPostAutosaving,\n\t\tlockPostSaving,\n\t\tunlockPostSaving,\n\t} = dispatch( editorStore );\n\n\tconst wpAllowedMimeTypes = getEditorSettings().allowedMimeTypes;\n\tconst lockKey = `image-upload-${ uuid() }`;\n\tlet imageIsUploading = false;\n\tmaxUploadFileSize =\n\t\tmaxUploadFileSize || getEditorSettings().maxUploadFileSize;\n\tconst currentPost = getCurrentPost();\n\t// Templates and template parts' numerical ID is stored in `wp_id`.\n\tconst currentPostId =\n\t\ttypeof currentPost?.id === 'number'\n\t\t\t? currentPost.id\n\t\t\t: currentPost?.wp_id;\n\tconst setSaveLock = () => {\n\t\tlockPostSaving( lockKey );\n\t\tlockPostAutosaving( lockKey );\n\t\timageIsUploading = true;\n\t};\n\n\tconst postData = currentPostId ? { post: currentPostId } : {};\n\tconst clearSaveLock = () => {\n\t\tunlockPostSaving( lockKey );\n\t\tunlockPostAutosaving( lockKey );\n\t\timageIsUploading = false;\n\t};\n\n\tuploadMedia( {\n\t\tallowedTypes,\n\t\tfilesList,\n\t\tonFileChange: ( file ) => {\n\t\t\tif ( ! imageIsUploading ) {\n\t\t\t\tsetSaveLock();\n\t\t\t} else {\n\t\t\t\tclearSaveLock();\n\t\t\t}\n\t\t\tonFileChange( file );\n\t\t},\n\t\tadditionalData: {\n\t\t\t...postData,\n\t\t\t...additionalData,\n\t\t},\n\t\tmaxUploadFileSize,\n\t\tonError: ( { message } ) => {\n\t\t\tclearSaveLock();\n\t\t\tonError( message );\n\t\t},\n\t\twpAllowedMimeTypes,\n\t} );\n}\n"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AAa,GAAG;IAAEK,IAAI,EAAEL;EAAc,CAAC,GAAG,CAAC,CAAC;EAC7D,MAAMM,aAAa,GAAGA,CAAA,KAAM;IAC3Bd,gBAAgB,CAAEI,OAAQ,CAAC;IAC3BN,oBAAoB,CAAEM,OAAQ,CAAC;IAC/BE,gBAAgB,GAAG,KAAK;EACzB,CAAC;EAED,IAAAS,uBAAW,EAAE;IACZ3B,YAAY;IACZC,SAAS;IACTG,YAAY,EAAIwB,IAAI,IAAM;MACzB,IAAK,CAAEV,gBAAgB,EAAG;QACzBK,WAAW,CAAC,CAAC;MACd,CAAC,MAAM;QACNG,aAAa,CAAC,CAAC;MAChB;MACAtB,YAAY,CAAEwB,IAAK,CAAC;IACrB,CAAC;IACD7B,cAAc,EAAE;MACf,GAAGyB,QAAQ;MACX,GAAGzB;IACJ,CAAC;IACDG,iBAAiB;IACjBC,OAAO,EAAEA,CAAE;MAAE0B;IAAQ,CAAC,KAAM;MAC3BH,aAAa,CAAC,CAAC;MACfvB,OAAO,CAAE0B,OAAQ,CAAC;IACnB,CAAC;IACDf;EACD,CAAE,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { privateApis as blocksPrivateApis, store as blocksStore } from '@wordpress/blocks';
5
+ import { dispatch } from '@wordpress/data';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import patternOverrides from './pattern-overrides';
11
+ import postMeta from './post-meta';
12
+ import { unlock } from '../lock-unlock';
13
+
14
+ /**
15
+ * Function to register core block bindings sources provided by the editor.
16
+ *
17
+ * @example
18
+ * ```js
19
+ * import { registerCoreBlockBindingsSources } from '@wordpress/editor';
20
+ *
21
+ * registerCoreBlockBindingsSources();
22
+ * ```
23
+ */
24
+ export function registerCoreBlockBindingsSources() {
25
+ const {
26
+ registerBlockBindingsSource
27
+ } = unlock(blocksPrivateApis);
28
+ registerBlockBindingsSource(patternOverrides);
29
+ registerBlockBindingsSource(postMeta);
30
+ }
31
+
32
+ /**
33
+ * Function to bootstrap core block bindings sources defined in the server.
34
+ *
35
+ * @param {Object} sources Object containing the sources to bootstrap.
36
+ *
37
+ * @example
38
+ * ```js
39
+ * import { bootstrapBlockBindingsSourcesFromServer } from '@wordpress/editor';
40
+ *
41
+ * bootstrapBlockBindingsSourcesFromServer( sources );
42
+ * ```
43
+ */
44
+ export function bootstrapBlockBindingsSourcesFromServer(sources) {
45
+ if (sources) {
46
+ const {
47
+ addBootstrappedBlockBindingsSource
48
+ } = unlock(dispatch(blocksStore));
49
+ for (const [name, args] of Object.entries(sources)) {
50
+ addBootstrappedBlockBindingsSource({
51
+ name,
52
+ ...args
53
+ });
54
+ }
55
+ }
56
+ }
57
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["privateApis","blocksPrivateApis","store","blocksStore","dispatch","patternOverrides","postMeta","unlock","registerCoreBlockBindingsSources","registerBlockBindingsSource","bootstrapBlockBindingsSourcesFromServer","sources","addBootstrappedBlockBindingsSource","name","args","Object","entries"],"sources":["@wordpress/editor/src/bindings/api.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as blocksPrivateApis,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport patternOverrides from './pattern-overrides';\nimport postMeta from './post-meta';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Function to register core block bindings sources provided by the editor.\n *\n * @example\n * ```js\n * import { registerCoreBlockBindingsSources } from '@wordpress/editor';\n *\n * registerCoreBlockBindingsSources();\n * ```\n */\nexport function registerCoreBlockBindingsSources() {\n\tconst { registerBlockBindingsSource } = unlock( blocksPrivateApis );\n\tregisterBlockBindingsSource( patternOverrides );\n\tregisterBlockBindingsSource( postMeta );\n}\n\n/**\n * Function to bootstrap core block bindings sources defined in the server.\n *\n * @param {Object} sources Object containing the sources to bootstrap.\n *\n * @example\n * ```js\n * import { bootstrapBlockBindingsSourcesFromServer } from '@wordpress/editor';\n *\n * bootstrapBlockBindingsSourcesFromServer( sources );\n * ```\n */\nexport function bootstrapBlockBindingsSourcesFromServer( sources ) {\n\tif ( sources ) {\n\t\tconst { addBootstrappedBlockBindingsSource } = unlock(\n\t\t\tdispatch( blocksStore )\n\t\t);\n\t\tfor ( const [ name, args ] of Object.entries( sources ) ) {\n\t\t\taddBootstrappedBlockBindingsSource( {\n\t\t\t\tname,\n\t\t\t\t...args,\n\t\t\t} );\n\t\t}\n\t}\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,WAAW,IAAIC,iBAAiB,EAChCC,KAAK,IAAIC,WAAW,QACd,mBAAmB;AAC1B,SAASC,QAAQ,QAAQ,iBAAiB;;AAE1C;AACA;AACA;AACA,OAAOC,gBAAgB,MAAM,qBAAqB;AAClD,OAAOC,QAAQ,MAAM,aAAa;AAClC,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gCAAgCA,CAAA,EAAG;EAClD,MAAM;IAAEC;EAA4B,CAAC,GAAGF,MAAM,CAAEN,iBAAkB,CAAC;EACnEQ,2BAA2B,CAAEJ,gBAAiB,CAAC;EAC/CI,2BAA2B,CAAEH,QAAS,CAAC;AACxC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,uCAAuCA,CAAEC,OAAO,EAAG;EAClE,IAAKA,OAAO,EAAG;IACd,MAAM;MAAEC;IAAmC,CAAC,GAAGL,MAAM,CACpDH,QAAQ,CAAED,WAAY,CACvB,CAAC;IACD,KAAM,MAAM,CAAEU,IAAI,EAAEC,IAAI,CAAE,IAAIC,MAAM,CAACC,OAAO,CAAEL,OAAQ,CAAC,EAAG;MACzDC,kCAAkC,CAAE;QACnCC,IAAI;QACJ,GAAGC;MACJ,CAAE,CAAC;IACJ;EACD;AACD","ignoreList":[]}
@@ -1,38 +1,40 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { _x } from '@wordpress/i18n';
5
4
  import { store as blockEditorStore } from '@wordpress/block-editor';
6
5
  const CONTENT = 'content';
7
6
  export default {
8
7
  name: 'core/pattern-overrides',
9
- label: _x('Pattern Overrides', 'block bindings source'),
10
- getValue({
8
+ getValues({
11
9
  registry,
12
10
  clientId,
13
11
  context,
14
- attributeName
12
+ bindings
15
13
  }) {
16
14
  const patternOverridesContent = context['pattern/overrides'];
17
15
  const {
18
16
  getBlockAttributes
19
17
  } = registry.select(blockEditorStore);
20
18
  const currentBlockAttributes = getBlockAttributes(clientId);
21
- if (!patternOverridesContent) {
22
- return currentBlockAttributes[attributeName];
23
- }
24
- const overridableValue = patternOverridesContent?.[currentBlockAttributes?.metadata?.name]?.[attributeName];
19
+ const overridesValues = {};
20
+ for (const attributeName of Object.keys(bindings)) {
21
+ const overridableValue = patternOverridesContent?.[currentBlockAttributes?.metadata?.name]?.[attributeName];
25
22
 
26
- // If there is no pattern client ID, or it is not overwritten, return the default value.
27
- if (overridableValue === undefined) {
28
- return currentBlockAttributes[attributeName];
23
+ // If it has not been overriden, return the original value.
24
+ // Check undefined because empty string is a valid value.
25
+ if (overridableValue === undefined) {
26
+ overridesValues[attributeName] = currentBlockAttributes[attributeName];
27
+ continue;
28
+ } else {
29
+ overridesValues[attributeName] = overridableValue === '' ? undefined : overridableValue;
30
+ }
29
31
  }
30
- return overridableValue === '' ? undefined : overridableValue;
32
+ return overridesValues;
31
33
  },
32
34
  setValues({
33
35
  registry,
34
36
  clientId,
35
- attributes
37
+ bindings
36
38
  }) {
37
39
  const {
38
40
  getBlockAttributes,
@@ -46,6 +48,14 @@ export default {
46
48
  }
47
49
  const [patternClientId] = getBlockParentsByBlockName(clientId, 'core/block', true);
48
50
 
51
+ // Extract the updated attributes from the source bindings.
52
+ const attributes = Object.entries(bindings).reduce((attrs, [key, {
53
+ newValue
54
+ }]) => {
55
+ attrs[key] = newValue;
56
+ return attrs;
57
+ }, {});
58
+
49
59
  // If there is no pattern client ID, sync blocks with the same name and same attributes.
50
60
  if (!patternClientId) {
51
61
  const syncBlocksWithSameName = blocks => {
@@ -1 +1 @@
1
- {"version":3,"names":["_x","store","blockEditorStore","CONTENT","name","label","getValue","registry","clientId","context","attributeName","patternOverridesContent","getBlockAttributes","select","currentBlockAttributes","overridableValue","metadata","undefined","setValues","attributes","getBlockParentsByBlockName","getBlocks","blockName","patternClientId","syncBlocksWithSameName","blocks","block","dispatch","updateBlockAttributes","innerBlocks","currentBindingValue","Object","entries","reduce","acc","key","value","canUserEditValue"],"sources":["@wordpress/editor/src/bindings/pattern-overrides.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nconst CONTENT = 'content';\n\nexport default {\n\tname: 'core/pattern-overrides',\n\tlabel: _x( 'Pattern Overrides', 'block bindings source' ),\n\tgetValue( { registry, clientId, context, attributeName } ) {\n\t\tconst patternOverridesContent = context[ 'pattern/overrides' ];\n\t\tconst { getBlockAttributes } = registry.select( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\n\t\tif ( ! patternOverridesContent ) {\n\t\t\treturn currentBlockAttributes[ attributeName ];\n\t\t}\n\n\t\tconst overridableValue =\n\t\t\tpatternOverridesContent?.[\n\t\t\t\tcurrentBlockAttributes?.metadata?.name\n\t\t\t]?.[ attributeName ];\n\n\t\t// If there is no pattern client ID, or it is not overwritten, return the default value.\n\t\tif ( overridableValue === undefined ) {\n\t\t\treturn currentBlockAttributes[ attributeName ];\n\t\t}\n\n\t\treturn overridableValue === '' ? undefined : overridableValue;\n\t},\n\tsetValues( { registry, clientId, attributes } ) {\n\t\tconst { getBlockAttributes, getBlockParentsByBlockName, getBlocks } =\n\t\t\tregistry.select( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\t\tconst blockName = currentBlockAttributes?.metadata?.name;\n\t\tif ( ! blockName ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\tclientId,\n\t\t\t'core/block',\n\t\t\ttrue\n\t\t);\n\n\t\t// If there is no pattern client ID, sync blocks with the same name and same attributes.\n\t\tif ( ! patternClientId ) {\n\t\t\tconst syncBlocksWithSameName = ( blocks ) => {\n\t\t\t\tfor ( const block of blocks ) {\n\t\t\t\t\tif ( block.attributes?.metadata?.name === blockName ) {\n\t\t\t\t\t\tregistry\n\t\t\t\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t\t\t\t.updateBlockAttributes(\n\t\t\t\t\t\t\t\tblock.clientId,\n\t\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tsyncBlocksWithSameName( block.innerBlocks );\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tsyncBlocksWithSameName( getBlocks() );\n\t\t\treturn;\n\t\t}\n\t\tconst currentBindingValue =\n\t\t\tgetBlockAttributes( patternClientId )?.[ CONTENT ];\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.updateBlockAttributes( patternClientId, {\n\t\t\t\t[ CONTENT ]: {\n\t\t\t\t\t...currentBindingValue,\n\t\t\t\t\t[ blockName ]: {\n\t\t\t\t\t\t...currentBindingValue?.[ blockName ],\n\t\t\t\t\t\t...Object.entries( attributes ).reduce(\n\t\t\t\t\t\t\t( acc, [ key, value ] ) => {\n\t\t\t\t\t\t\t\t// TODO: We need a way to represent `undefined` in the serialized overrides.\n\t\t\t\t\t\t\t\t// Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871\n\t\t\t\t\t\t\t\t// We use an empty string to represent undefined for now until\n\t\t\t\t\t\t\t\t// we support a richer format for overrides and the block bindings API.\n\t\t\t\t\t\t\t\tacc[ key ] = value === undefined ? '' : value;\n\t\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t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D;IACD,CAAE,CAAC;EACL,CAAC;EACDG,gBAAgB,EAAEA,CAAA,KAAM;AACzB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["store","blockEditorStore","CONTENT","name","getValues","registry","clientId","context","bindings","patternOverridesContent","getBlockAttributes","select","currentBlockAttributes","overridesValues","attributeName","Object","keys","overridableValue","metadata","undefined","setValues","getBlockParentsByBlockName","getBlocks","blockName","patternClientId","attributes","entries","reduce","attrs","key","newValue","syncBlocksWithSameName","blocks","block","dispatch","updateBlockAttributes","innerBlocks","currentBindingValue","acc","value","canUserEditValue"],"sources":["@wordpress/editor/src/bindings/pattern-overrides.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nconst CONTENT = 'content';\n\nexport default {\n\tname: 'core/pattern-overrides',\n\tgetValues( { registry, clientId, context, bindings } ) {\n\t\tconst patternOverridesContent = context[ 'pattern/overrides' ];\n\t\tconst { getBlockAttributes } = registry.select( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\n\t\tconst overridesValues = {};\n\t\tfor ( const attributeName of Object.keys( bindings ) ) {\n\t\t\tconst overridableValue =\n\t\t\t\tpatternOverridesContent?.[\n\t\t\t\t\tcurrentBlockAttributes?.metadata?.name\n\t\t\t\t]?.[ attributeName ];\n\n\t\t\t// If it has not been overriden, return the original value.\n\t\t\t// Check undefined because empty string is a valid value.\n\t\t\tif ( overridableValue === undefined ) {\n\t\t\t\toverridesValues[ attributeName ] =\n\t\t\t\t\tcurrentBlockAttributes[ attributeName ];\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\toverridesValues[ attributeName ] =\n\t\t\t\t\toverridableValue === '' ? undefined : overridableValue;\n\t\t\t}\n\t\t}\n\t\treturn overridesValues;\n\t},\n\tsetValues( { registry, clientId, bindings } ) {\n\t\tconst { getBlockAttributes, getBlockParentsByBlockName, getBlocks } =\n\t\t\tregistry.select( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\t\tconst blockName = currentBlockAttributes?.metadata?.name;\n\t\tif ( ! blockName ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\tclientId,\n\t\t\t'core/block',\n\t\t\ttrue\n\t\t);\n\n\t\t// Extract the updated attributes from the source bindings.\n\t\tconst attributes = Object.entries( bindings ).reduce(\n\t\t\t( attrs, [ key, { newValue } ] ) => {\n\t\t\t\tattrs[ key ] = newValue;\n\t\t\t\treturn attrs;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\t// If there is no pattern client ID, sync blocks with the same name and same attributes.\n\t\tif ( ! patternClientId ) {\n\t\t\tconst syncBlocksWithSameName = ( blocks ) => {\n\t\t\t\tfor ( const block of blocks ) {\n\t\t\t\t\tif ( block.attributes?.metadata?.name === blockName ) {\n\t\t\t\t\t\tregistry\n\t\t\t\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t\t\t\t.updateBlockAttributes(\n\t\t\t\t\t\t\t\tblock.clientId,\n\t\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tsyncBlocksWithSameName( block.innerBlocks );\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tsyncBlocksWithSameName( getBlocks() );\n\t\t\treturn;\n\t\t}\n\t\tconst currentBindingValue =\n\t\t\tgetBlockAttributes( patternClientId )?.[ CONTENT ];\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.updateBlockAttributes( patternClientId, {\n\t\t\t\t[ CONTENT ]: {\n\t\t\t\t\t...currentBindingValue,\n\t\t\t\t\t[ blockName ]: {\n\t\t\t\t\t\t...currentBindingValue?.[ blockName ],\n\t\t\t\t\t\t...Object.entries( attributes ).reduce(\n\t\t\t\t\t\t\t( acc, [ key, value ] ) => {\n\t\t\t\t\t\t\t\t// TODO: We need a way to represent `undefined` in the serialized overrides.\n\t\t\t\t\t\t\t\t// Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871\n\t\t\t\t\t\t\t\t// We use an empty string to represent undefined for now until\n\t\t\t\t\t\t\t\t// we support a richer format for overrides and the block bindings API.\n\t\t\t\t\t\t\t\tacc[ key ] = value === undefined ? '' : value;\n\t\t\t\t\t\t\t\treturn acc;\n\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},\n\tcanUserEditValue: () => true,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AAEnE,MAAMC,OAAO,GAAG,SAAS;AAEzB,eAAe;EACdC,IAAI,EAAE,wBAAwB;EAC9BC,SAASA,CAAE;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC,OAAO;IAAEC;EAAS,CAAC,EAAG;IACtD,MAAMC,uBAAuB,GAAGF,OAAO,CAAE,mBAAmB,CAAE;IAC9D,MAAM;MAAEG;IAAmB,CAAC,GAAGL,QAAQ,CAACM,MAAM,CAAEV,gBAAiB,CAAC;IAClE,MAAMW,sBAAsB,GAAGF,kBAAkB,CAAEJ,QAAS,CAAC;IAE7D,MAAMO,eAAe,GAAG,CAAC,CAAC;IAC1B,KAAM,MAAMC,aAAa,IAAIC,MAAM,CAACC,IAAI,CAAER,QAAS,CAAC,EAAG;MACtD,MAAMS,gBAAgB,GACrBR,uBAAuB,GACtBG,sBAAsB,EAAEM,QAAQ,EAAEf,IAAI,CACtC,GAAIW,aAAa,CAAE;;MAErB;MACA;MACA,IAAKG,gBAAgB,KAAKE,SAAS,EAAG;QACrCN,eAAe,CAAEC,aAAa,CAAE,GAC/BF,sBAAsB,CAAEE,aAAa,CAAE;QACxC;MACD,CAAC,MAAM;QACND,eAAe,CAAEC,aAAa,CAAE,GAC/BG,gBAAgB,KAAK,EAAE,GAAGE,SAAS,GAAGF,gBAAgB;MACxD;IACD;IACA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AItB,OAAO,CAAE;IACnDG,QAAQ,CACN6B,QAAQ,CAAEjC,gBAAiB,CAAC,CAC5BkC,qBAAqB,CAAEX,eAAe,EAAE;MACxC,CAAEtB,OAAO,GAAI;QACZ,GAAGmC,mBAAmB;QACtB,CAAEd,SAAS,GAAI;UACd,GAAGc,mBAAmB,GAAId,SAAS,CAAE;UACrC,GAAGR,MAAM,CAACW,OAAO,CAAED,UAAW,CAAC,CAACE,MAAM,CACrC,CAAEW,GAAG,EAAE,CAAET,GAAG,EAAEU,KAAK,CAAE,KAAM;YAC1B;YACA;YACA;YACA;YACAD,GAAG,CAAET,GAAG,CAAE,GAAGU,KAAK,KAAKpB,SAAS,GAAG,EAAE,GAAGoB,KAAK;YAC7C,OAAOD,GAAG;UACX,CAAC,EACD,CAAC,CACF;QACD;MACD;IACD,CAAE,CAAC;EACL,CAAC;EACDE,gBAAgB,EAAEA,CAAA,KAAM;AACzB,CAAC","ignoreList":[]}
@@ -2,7 +2,6 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { store as coreDataStore } from '@wordpress/core-data';
5
- import { _x } from '@wordpress/i18n';
6
5
 
7
6
  /**
8
7
  * Internal dependencies
@@ -10,29 +9,37 @@ import { _x } from '@wordpress/i18n';
10
9
  import { store as editorStore } from '../store';
11
10
  export default {
12
11
  name: 'core/post-meta',
13
- label: _x('Post Meta', 'block bindings source'),
14
12
  getPlaceholder({
15
13
  args
16
14
  }) {
17
15
  return args.key;
18
16
  },
19
- getValue({
17
+ getValues({
20
18
  registry,
21
19
  context,
22
- args
20
+ bindings
23
21
  }) {
24
- return registry.select(coreDataStore).getEditedEntityRecord('postType', context?.postType, context?.postId).meta?.[args.key];
22
+ const meta = registry.select(coreDataStore).getEditedEntityRecord('postType', context?.postType, context?.postId)?.meta;
23
+ const newValues = {};
24
+ for (const [attributeName, source] of Object.entries(bindings)) {
25
+ newValues[attributeName] = meta?.[source.args.key];
26
+ }
27
+ return newValues;
25
28
  },
26
- setValue({
29
+ setValues({
27
30
  registry,
28
31
  context,
29
- args,
30
- value
32
+ bindings
31
33
  }) {
34
+ const newMeta = {};
35
+ Object.values(bindings).forEach(({
36
+ args,
37
+ newValue
38
+ }) => {
39
+ newMeta[args.key] = newValue;
40
+ });
32
41
  registry.dispatch(coreDataStore).editEntityRecord('postType', context?.postType, context?.postId, {
33
- meta: {
34
- [args.key]: value
35
- }
42
+ meta: newMeta
36
43
  });
37
44
  },
38
45
  canUserEditValue({
@@ -58,7 +65,11 @@ export default {
58
65
  }
59
66
 
60
67
  // Check that the user has the capability to edit post meta.
61
- const canUserEdit = select(coreDataStore).canUserEditEntityRecord('postType', context?.postType, context?.postId);
68
+ const canUserEdit = select(coreDataStore).canUser('update', {
69
+ kind: 'postType',
70
+ name: context?.postType,
71
+ id: context?.postId
72
+ });
62
73
  if (!canUserEdit) {
63
74
  return false;
64
75
  }
@@ -1 +1 @@
1
- {"version":3,"names":["store","coreDataStore","_x","editorStore","name","label","getPlaceholder","args","key","getValue","registry","context","select","getEditedEntityRecord","postType","postId","meta","setValue","value","dispatch","editEntityRecord","canUserEditValue","query","queryId","getCurrentPostType","isFieldExposed","getEntityRecord","canUserEdit","canUserEditEntityRecord"],"sources":["@wordpress/editor/src/bindings/post-meta.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\n\nexport default {\n\tname: 'core/post-meta',\n\tlabel: _x( 'Post Meta', 'block bindings source' ),\n\tgetPlaceholder( { args } ) {\n\t\treturn args.key;\n\t},\n\tgetValue( { registry, context, args } ) {\n\t\treturn registry\n\t\t\t.select( coreDataStore )\n\t\t\t.getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tcontext?.postType,\n\t\t\t\tcontext?.postId\n\t\t\t).meta?.[ args.key ];\n\t},\n\tsetValue( { registry, context, args, value } ) {\n\t\tregistry\n\t\t\t.dispatch( coreDataStore )\n\t\t\t.editEntityRecord( 'postType', context?.postType, context?.postId, {\n\t\t\t\tmeta: {\n\t\t\t\t\t[ args.key ]: value,\n\t\t\t\t},\n\t\t\t} );\n\t},\n\tcanUserEditValue( { select, context, args } ) {\n\t\t// Lock editing in query loop.\n\t\tif ( context?.query || context?.queryId ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst postType =\n\t\t\tcontext?.postType || select( editorStore ).getCurrentPostType();\n\n\t\t// Check that editing is happening in the post editor and not a template.\n\t\tif ( postType === 'wp_template' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check that the custom field is not protected and available in the REST API.\n\t\tconst isFieldExposed = !! select( coreDataStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tcontext?.postId\n\t\t)?.meta?.[ args.key ];\n\n\t\tif ( ! isFieldExposed ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check that the user has the capability to edit post meta.\n\t\tconst canUserEdit = select( coreDataStore ).canUserEditEntityRecord(\n\t\t\t'postType',\n\t\t\tcontext?.postType,\n\t\t\tcontext?.postId\n\t\t);\n\t\tif ( ! canUserEdit ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t},\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,aAAa,QAAQ,sBAAsB;AAC7D,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASF,KAAK,IAAIG,WAAW,QAAQ,UAAU;AAE/C,eAAe;EACdC,IAAI,EAAE,gBAAgB;EACtBC,KAAK,EAAEH,EAAE,CAAE,WAAW,EAAE,uBAAwB,CAAC;EACjDI,cAAcA,CAAE;IAAEC;EAAK,CAAC,EAAG;IAC1B,OAAOA,IAAI,CAACC,GAAG;EAChB,CAAC;EACDC,QAAQA,CAAE;IAAEC,QAAQ;IAAEC,OAAO;IAAEJ;EAAK,CAAC,EAAG;IACvC,OAAOG,QAAQ,CACbE,MAAM,C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AO,KAAK;IACb;IAEA,OAAO,IAAI;EACZ;AACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["store","coreDataStore","editorStore","name","getPlaceholder","args","key","getValues","registry","context","bindings","meta","select","getEditedEntityRecord","postType","postId","newValues","attributeName","source","Object","entries","setValues","newMeta","values","forEach","newValue","dispatch","editEntityRecord","canUserEditValue","query","queryId","getCurrentPostType","isFieldExposed","getEntityRecord","canUserEdit","canUser","kind","id"],"sources":["@wordpress/editor/src/bindings/post-meta.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\n\nexport default {\n\tname: 'core/post-meta',\n\tgetPlaceholder( { args } ) {\n\t\treturn args.key;\n\t},\n\tgetValues( { registry, context, bindings } ) {\n\t\tconst meta = registry\n\t\t\t.select( coreDataStore )\n\t\t\t.getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tcontext?.postType,\n\t\t\t\tcontext?.postId\n\t\t\t)?.meta;\n\t\tconst newValues = {};\n\t\tfor ( const [ attributeName, source ] of Object.entries( bindings ) ) {\n\t\t\tnewValues[ attributeName ] = meta?.[ source.args.key ];\n\t\t}\n\t\treturn newValues;\n\t},\n\tsetValues( { registry, context, bindings } ) {\n\t\tconst newMeta = {};\n\t\tObject.values( bindings ).forEach( ( { args, newValue } ) => {\n\t\t\tnewMeta[ args.key ] = newValue;\n\t\t} );\n\t\tregistry\n\t\t\t.dispatch( coreDataStore )\n\t\t\t.editEntityRecord( 'postType', context?.postType, context?.postId, {\n\t\t\t\tmeta: newMeta,\n\t\t\t} );\n\t},\n\tcanUserEditValue( { select, context, args } ) {\n\t\t// Lock editing in query loop.\n\t\tif ( context?.query || context?.queryId ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst postType =\n\t\t\tcontext?.postType || select( editorStore ).getCurrentPostType();\n\n\t\t// Check that editing is happening in the post editor and not a template.\n\t\tif ( postType === 'wp_template' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check that the custom field is not protected and available in the REST API.\n\t\tconst isFieldExposed = !! select( coreDataStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tcontext?.postId\n\t\t)?.meta?.[ args.key ];\n\n\t\tif ( ! isFieldExposed ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check that the user has the capability to edit post meta.\n\t\tconst canUserEdit = select( coreDataStore ).canUser( 'update', {\n\t\t\tkind: 'postType',\n\t\t\tname: context?.postType,\n\t\t\tid: context?.postId,\n\t\t} );\n\t\tif ( ! canUserEdit ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t},\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,aAAa,QAAQ,sBAAsB;;AAE7D;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,UAAU;AAE/C,eAAe;EACdC,IAAI,EAAE,gBAAgB;EACtBC,cAAcA,CAAE;IAAEC;EAAK,CAAC,EAAG;IAC1B,OAAOA,IAAI,CAACC,GAAG;EAChB,CAAC;EACDC,SAASA,CAAE;IAAEC,QAAQ;IAAEC,OAAO;IAAEC;EAAS,CAAC,EAAG;IAC5C,MAAMC,IAAI,GAAGH,QAAQ,CACnBI,MAAM,CAAEX,aAAc,CAAC,CACvBY,qBAAqB,CACrB,UAAU,EACVJ,OAAO,EAAEK,QAAQ,EACjBL,OAAO,EAAEM,MACV,CAAC,EAAEJ,IAAI;IACR,MAAMK,SAAS,GAAG,CAAC,CAAC;IACpB,KAAM,MAAM,CAAEC,aAAa,EAAEC,MAAM,CAAE,IAAIC,MAAM,CAACC,OAAO,CAAEV,QAAS,CAAC,EAAG;MACrEM,SAAS,CAAEC,aAAa,CAAE,GAAGN,IAAI,GAAIO,MAAM,CAACb,IAAI,CAACC,GAAG,CAAE;IACvD;IACA,OAAOU,SAAS;EACjB,CAAC;EACDK,SAASA,CAAE;IAAEb,QA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AE5B,OAAO,EAAEM;IACd,CAAE,CAAC;IACH,IAAK,CAAEmB,WAAW,EAAG;MACpB,OAAO,KAAK;IACb;IAEA,OAAO,IAAI;EACZ;AACD,CAAC","ignoreList":[]}
@@ -50,7 +50,10 @@ function ContentOnlySettingsMenuItems({
50
50
  record = select(coreStore).getEntityRecord('postType', 'wp_template', templateId);
51
51
  }
52
52
  }
53
- const _canEditTemplates = select(coreStore).canUser('create', 'templates');
53
+ const _canEditTemplates = select(coreStore).canUser('create', {
54
+ kind: 'postType',
55
+ name: 'wp_template'
56
+ });
54
57
  return {
55
58
  canEditTemplates: _canEditTemplates,
56
59
  entity: record,
@@ -1 +1 @@
1
- {"version":3,"names":["BlockSettingsMenuControls","__unstableBlockSettingsMenuFirstItem","BlockSettingsMenuFirstItem","store","blockEditorStore","useBlockDisplayInformation","coreStore","__experimentalText","Text","MenuItem","useSelect","useDispatch","__","editorStore","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ContentOnlySettingsMenuItems","clientId","onClose","entity","onNavigateToEntityRecord","canEditTemplates","select","getBlockEditingMode","getBlockParentsByBlockName","getSettings","getBlockAttributes","contentOnly","patternParent","record","getEntityRecord","ref","getCurrentTemplateId","templateId","getContentLockingParent","_canEditTemplates","canUser","TemplateLockContentOnlyMenuItems","isPattern","type","helpText","children","onClick","postId","id","postType","disabled","variant","as","className","contentLockingParent","blockDisplayInformation","modifyContentLockBlock","selectBlock","title","ContentOnlySettingsMenu","selectedClientIds","length"],"sources":["@wordpress/editor/src/components/block-settings-menu/content-only-settings-menu.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\t__unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,\n\tstore as blockEditorStore,\n\tuseBlockDisplayInformation,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalText as Text, MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nfunction ContentOnlySettingsMenuItems( { clientId, onClose } ) {\n\tconst { entity, onNavigateToEntityRecord, canEditTemplates } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockAttributes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst contentOnly =\n\t\t\t\tgetBlockEditingMode( clientId ) === 'contentOnly';\n\t\t\tif ( ! contentOnly ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst patternParent = getBlockParentsByBlockName(\n\t\t\t\tclientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t)[ 0 ];\n\n\t\t\tlet record;\n\t\t\tif ( patternParent ) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tgetBlockAttributes( patternParent ).ref\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst { getCurrentTemplateId } = select( editorStore );\n\t\t\t\tconst templateId = getCurrentTemplateId();\n\t\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\t\tselect( blockEditorStore )\n\t\t\t\t);\n\t\t\t\tif ( ! getContentLockingParent( clientId ) && templateId ) {\n\t\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_template',\n\t\t\t\t\t\ttemplateId\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst _canEditTemplates = select( coreStore ).canUser(\n\t\t\t\t'create',\n\t\t\t\t'templates'\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcanEditTemplates: _canEditTemplates,\n\t\t\t\tentity: record,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetSettings().onNavigateToEntityRecord,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( ! entity ) {\n\t\treturn (\n\t\t\t<TemplateLockContentOnlyMenuItems\n\t\t\t\tclientId={ clientId }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst isPattern = entity.type === 'wp_block';\n\tlet helpText = isPattern\n\t\t? __(\n\t\t\t\t'Edit the pattern to move, delete, or make further changes to this block.'\n\t\t )\n\t\t: __(\n\t\t\t\t'Edit the template to move, delete, or make further changes to this block.'\n\t\t );\n\n\tif ( ! canEditTemplates ) {\n\t\thelpText = __(\n\t\t\t'Only users with permissions to edit the template can move or delete this block'\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\tpostId: entity.id,\n\t\t\t\t\t\t\tpostType: entity.type,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdisabled={ ! canEditTemplates }\n\t\t\t\t>\n\t\t\t\t\t{ isPattern ? __( 'Edit pattern' ) : __( 'Edit template' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ helpText }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nfunction TemplateLockContentOnlyMenuItems( { clientId, onClose } ) {\n\tconst { contentLockingParent } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcontentLockingParent: getContentLockingParent( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst blockDisplayInformation =\n\t\tuseBlockDisplayInformation( contentLockingParent );\n\t// Disable reason: We're using a hook here so it has to be on top-level.\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { modifyContentLockBlock, selectBlock } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\tif ( ! blockDisplayInformation?.title ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tselectBlock( contentLockingParent );\n\t\t\t\t\t\tmodifyContentLockBlock( contentLockingParent );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Unlock' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Temporarily unlock the parent block to edit, delete or make further changes to this block.'\n\t\t\t\t) }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nexport default function ContentOnlySettingsMenu() {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) =>\n\t\t\t\tselectedClientIds.length === 1 && (\n\t\t\t\t\t<ContentOnlySettingsMenuItems\n\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,yBAAyB,EACzBC,oCAAoC,IAAIC,0BAA0B,EAClEC,KAAK,IAAIC,gBAAgB,EACzBC,0BAA0B,QACpB,yBAAyB;AAChC,SAASF,KAAK,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S,EAAC,gDAAgD;MAAAR,QAAA,EAExDlC,EAAE,CACH,4FACD;IAAC,CACI,CAAC;EAAA,CACN,CAAC;AAEL;AAEA,eAAe,SAASgD,uBAAuBA,CAAA,EAAG;EACjD,oBACC5C,IAAA,CAAChB,yBAAyB;IAAA8C,QAAA,EACvBA,CAAE;MAAEe,iBAAiB;MAAEtC;IAAQ,CAAC,KACjCsC,iBAAiB,CAACC,MAAM,KAAK,CAAC,iBAC7B9C,IAAA,CAACK,4BAA4B;MAC5BC,QAAQ,EAAGuC,iBAAiB,CAAE,CAAC,CAAI;MACnCtC,OAAO,EAAGA;IAAS,CACnB;EACD,CAEwB,CAAC;AAE9B","ignoreList":[]}
1
+ {"version":3,"names":["BlockSettingsMenuControls","__unstableBlockSettingsMenuFirstItem","BlockSettingsMenuFirstItem","store","blockEditorStore","useBlockDisplayInformation","coreStore","__experimentalText","Text","MenuItem","useSelect","useDispatch","__","editorStore","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ContentOnlySettingsMenuItems","clientId","onClose","entity","onNavigateToEntityRecord","canEditTemplates","select","getBlockEditingMode","getBlockParentsByBlockName","getSettings","getBlockAttributes","contentOnly","patternParent","record","getEntityRecord","ref","getCurrentTemplateId","templateId","getContentLockingParent","_canEditTemplates","canUser","kind","name","TemplateLockContentOnlyMenuItems","isPattern","type","helpText","children","onClick","postId","id","postType","disabled","variant","as","className","contentLockingParent","blockDisplayInformation","modifyContentLockBlock","selectBlock","title","ContentOnlySettingsMenu","selectedClientIds","length"],"sources":["@wordpress/editor/src/components/block-settings-menu/content-only-settings-menu.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\t__unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,\n\tstore as blockEditorStore,\n\tuseBlockDisplayInformation,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalText as Text, MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nfunction ContentOnlySettingsMenuItems( { clientId, onClose } ) {\n\tconst { entity, onNavigateToEntityRecord, canEditTemplates } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockAttributes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst contentOnly =\n\t\t\t\tgetBlockEditingMode( clientId ) === 'contentOnly';\n\t\t\tif ( ! contentOnly ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst patternParent = getBlockParentsByBlockName(\n\t\t\t\tclientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t)[ 0 ];\n\n\t\t\tlet record;\n\t\t\tif ( patternParent ) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tgetBlockAttributes( patternParent ).ref\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst { getCurrentTemplateId } = select( editorStore );\n\t\t\t\tconst templateId = getCurrentTemplateId();\n\t\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\t\tselect( blockEditorStore )\n\t\t\t\t);\n\t\t\t\tif ( ! getContentLockingParent( clientId ) && templateId ) {\n\t\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_template',\n\t\t\t\t\t\ttemplateId\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst _canEditTemplates = select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\treturn {\n\t\t\t\tcanEditTemplates: _canEditTemplates,\n\t\t\t\tentity: record,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetSettings().onNavigateToEntityRecord,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( ! entity ) {\n\t\treturn (\n\t\t\t<TemplateLockContentOnlyMenuItems\n\t\t\t\tclientId={ clientId }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst isPattern = entity.type === 'wp_block';\n\tlet helpText = isPattern\n\t\t? __(\n\t\t\t\t'Edit the pattern to move, delete, or make further changes to this block.'\n\t\t )\n\t\t: __(\n\t\t\t\t'Edit the template to move, delete, or make further changes to this block.'\n\t\t );\n\n\tif ( ! canEditTemplates ) {\n\t\thelpText = __(\n\t\t\t'Only users with permissions to edit the template can move or delete this block'\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\tpostId: entity.id,\n\t\t\t\t\t\t\tpostType: entity.type,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdisabled={ ! canEditTemplates }\n\t\t\t\t>\n\t\t\t\t\t{ isPattern ? __( 'Edit pattern' ) : __( 'Edit template' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ helpText }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nfunction TemplateLockContentOnlyMenuItems( { clientId, onClose } ) {\n\tconst { contentLockingParent } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcontentLockingParent: getContentLockingParent( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst blockDisplayInformation =\n\t\tuseBlockDisplayInformation( contentLockingParent );\n\t// Disable reason: We're using a hook here so it has to be on top-level.\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { modifyContentLockBlock, selectBlock } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\tif ( ! blockDisplayInformation?.title ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tselectBlock( contentLockingParent );\n\t\t\t\t\t\tmodifyContentLockBlock( contentLockingParent );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Unlock' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Temporarily unlock the parent block to edit, delete or make further changes to this block.'\n\t\t\t\t) }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nexport default function ContentOnlySettingsMenu() {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) =>\n\t\t\t\tselectedClientIds.length === 1 && (\n\t\t\t\t\t<ContentOnlySettingsMenuItems\n\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,yBAAyB,EACzBC,oCAAoC,IAAIC,0BAA0B,EAClEC,KAAK,IAAIC,gBAAgB,EACzBC,0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AAC,eAC7BI,IAAA,CAACR,IAAI;MACJ8C,OAAO,EAAC,OAAO;MACfC,EAAE,EAAC,GAAG;MACNC,SAAS,EAAC,gDAAgD;MAAAR,QAAA,EAExDpC,EAAE,CACH,4FACD;IAAC,CACI,CAAC;EAAA,CACN,CAAC;AAEL;AAEA,eAAe,SAASkD,uBAAuBA,CAAA,EAAG;EACjD,oBACC9C,IAAA,CAAChB,yBAAyB;IAAAgD,QAAA,EACvBA,CAAE;MAAEe,iBAAiB;MAAExC;IAAQ,CAAC,KACjCwC,iBAAiB,CAACC,MAAM,KAAK,CAAC,iBAC7BhD,IAAA,CAACK,4BAA4B;MAC5BC,QAAQ,EAAGyC,iBAAiB,CAAE,CAAC,CAAI;MACnCxC,OAAO,EAAGA;IAAS,CACnB;EACD,CAEwB,CAAC;AAE9B","ignoreList":[]}
@@ -32,9 +32,13 @@ export default function BlogTitle() {
32
32
  } = useSelect(select => {
33
33
  const {
34
34
  getEntityRecord,
35
- getEditedEntityRecord
35
+ getEditedEntityRecord,
36
+ canUser
36
37
  } = select(coreStore);
37
- const siteSettings = getEntityRecord('root', 'site');
38
+ const siteSettings = canUser('read', {
39
+ kind: 'root',
40
+ name: 'site'
41
+ }) ? getEntityRecord('root', 'site') : undefined;
38
42
  const _postsPageRecord = siteSettings?.page_for_posts ? getEditedEntityRecord('postType', 'page', siteSettings?.page_for_posts) : EMPTY_OBJECT;
39
43
  const {
40
44
  getEditedPostAttribute,
@@ -1 +1 @@
1
- {"version":3,"names":["__","sprintf","debounce","useSelect","useDispatch","store","coreStore","decodeEntities","Button","Dropdown","__experimentalInputControl","InputControl","useState","useMemo","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","TEMPLATE_POST_TYPE","PostPanelRow","editorStore","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","EMPTY_OBJECT","BlogTitle","editEntityRecord","postsPageTitle","postsPageId","isTemplate","postSlug","select","getEntityRecord","getEditedEntityRecord","siteSettings","_postsPageRecord","page_for_posts","getEditedPostAttribute","getCurrentPostType","id","title","popoverAnchor","setPopoverAnchor","popoverProps","anchor","placement","offset","shift","includes","setPostsPageTitle","newValue","decodedTitle","label","ref","children","contentClassName","focusOnMount","renderToggle","isOpen","onToggle","size","variant","onClick","renderContent","onClose","placeholder","value","onChange","help","hideLabelFromVision"],"sources":["@wordpress/editor/src/components/blog-title/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { debounce } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport {\n\tButton,\n\tDropdown,\n\t__experimentalInputControl as InputControl,\n} from '@wordpress/components';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_POST_TYPE } from '../../store/constants';\nimport PostPanelRow from '../post-panel-row';\nimport { store as editorStore } from '../../store';\n\nconst EMPTY_OBJECT = {};\n\nexport default function BlogTitle() {\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { postsPageTitle, postsPageId, isTemplate, postSlug } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getEditedEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\t\tconst _postsPageRecord = siteSettings?.page_for_posts\n\t\t\t\t? getEditedEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'page',\n\t\t\t\t\t\tsiteSettings?.page_for_posts\n\t\t\t\t )\n\t\t\t\t: EMPTY_OBJECT;\n\t\t\tconst { getEditedPostAttribute, getCurrentPostType } =\n\t\t\t\tselect( editorStore );\n\t\t\treturn {\n\t\t\t\tpostsPageId: _postsPageRecord?.id,\n\t\t\t\tpostsPageTitle: _postsPageRecord?.title,\n\t\t\t\tisTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,\n\t\t\t\tpostSlug: getEditedPostAttribute( 'slug' ),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tif (\n\t\t! isTemplate ||\n\t\t! [ 'home', 'index' ].includes( postSlug ) ||\n\t\t! postsPageId\n\t) {\n\t\treturn null;\n\t}\n\n\tconst setPostsPageTitle = ( newValue ) => {\n\t\teditEntityRecord( 'postType', 'page', postsPageId, {\n\t\t\ttitle: newValue,\n\t\t} );\n\t};\n\tconst decodedTitle = decodeEntities( postsPageTitle );\n\treturn (\n\t\t<PostPanelRow label={ __( 'Blog title' ) } ref={ setPopoverAnchor }>\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tcontentClassName=\"editor-blog-title-dropdown__content\"\n\t\t\t\tfocusOnMount\n\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t// translators: %s: Current post link.\n\t\t\t\t\t\t\t__( 'Change blog title: %s' ),\n\t\t\t\t\t\t\tdecodedTitle\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ decodedTitle }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\ttitle={ __( 'Blog title' ) }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<InputControl\n\t\t\t\t\t\t\tplaceholder={ __( 'No Title' ) }\n\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t\tvalue={ postsPageTitle }\n\t\t\t\t\t\t\tonChange={ debounce( setPostsPageTitle, 300 ) }\n\t\t\t\t\t\t\tlabel={ __( 'Blog title' ) }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Set the Posts Page title. Appears in search results, and when the page is shared on social media.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\thideLabelFromVision\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</PostPanelRow>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SACCC,MAAM,EACNC,QAAQ,EACRC,0BAA0B,IAAIC,YAAY,QACpC,uBAAuB;AAC9B,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,oCAAoC,IAAIC,sBAAsB,QAAQ,yBAAyB;;AAExG;AACA;AACA;AACA,SAASC,kBAAkB,QAAQ,uBAAuB;AAC1D,OAAOC,YAAY,MAAM,mBAAmB;AAC5C,SAASZ,KAAK,IAAIa,WAAW,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC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/CG,KAAK,EAAGrD,EAAE,CAAE,YAAa,CAAG;UAC5BqE,IAAI,EAAGrE,EAAE,CACR,mGACD,CAAG;UACHsE,mBAAmB;QAAA,CACnB,CAAC;MAAA,CACD;IACA,CACH;EAAC,CACW,CAAC;AAEjB","ignoreList":[]}
1
+ {"version":3,"names":["__","sprintf","debounce","useSelect","useDispatch","store","coreStore","decodeEntities","Button","Dropdown","__experimentalInputControl","InputControl","useState","useMemo","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","TEMPLATE_POST_TYPE","PostPanelRow","editorStore","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","EMPTY_OBJECT","BlogTitle","editEntityRecord","postsPageTitle","postsPageId","isTemplate","postSlug","select","getEntityRecord","getEditedEntityRecord","canUser","siteSettings","kind","name","undefined","_postsPageRecord","page_for_posts","getEditedPostAttribute","getCurrentPostType","id","title","popoverAnchor","setPopoverAnchor","popoverProps","anchor","placement","offset","shift","includes","setPostsPageTitle","newValue","decodedTitle","label","ref","children","contentClassName","focusOnMount","renderToggle","isOpen","onToggle","size","variant","onClick","renderContent","onClose","placeholder","value","onChange","help","hideLabelFromVision"],"sources":["@wordpress/editor/src/components/blog-title/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { debounce } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport {\n\tButton,\n\tDropdown,\n\t__experimentalInputControl as InputControl,\n} from '@wordpress/components';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_POST_TYPE } from '../../store/constants';\nimport PostPanelRow from '../post-panel-row';\nimport { store as editorStore } from '../../store';\n\nconst EMPTY_OBJECT = {};\n\nexport default function BlogTitle() {\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { postsPageTitle, postsPageId, isTemplate, postSlug } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getEditedEntityRecord, canUser } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\t\t\tconst _postsPageRecord = siteSettings?.page_for_posts\n\t\t\t\t? getEditedEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'page',\n\t\t\t\t\t\tsiteSettings?.page_for_posts\n\t\t\t\t )\n\t\t\t\t: EMPTY_OBJECT;\n\t\t\tconst { getEditedPostAttribute, getCurrentPostType } =\n\t\t\t\tselect( editorStore );\n\t\t\treturn {\n\t\t\t\tpostsPageId: _postsPageRecord?.id,\n\t\t\t\tpostsPageTitle: _postsPageRecord?.title,\n\t\t\t\tisTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,\n\t\t\t\tpostSlug: getEditedPostAttribute( 'slug' ),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tif (\n\t\t! isTemplate ||\n\t\t! [ 'home', 'index' ].includes( postSlug ) ||\n\t\t! postsPageId\n\t) {\n\t\treturn null;\n\t}\n\n\tconst setPostsPageTitle = ( newValue ) => {\n\t\teditEntityRecord( 'postType', 'page', postsPageId, {\n\t\t\ttitle: newValue,\n\t\t} );\n\t};\n\tconst decodedTitle = decodeEntities( postsPageTitle );\n\treturn (\n\t\t<PostPanelRow label={ __( 'Blog title' ) } ref={ setPopoverAnchor }>\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tcontentClassName=\"editor-blog-title-dropdown__content\"\n\t\t\t\tfocusOnMount\n\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t// translators: %s: Current post link.\n\t\t\t\t\t\t\t__( 'Change blog title: %s' ),\n\t\t\t\t\t\t\tdecodedTitle\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ decodedTitle }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\ttitle={ __( 'Blog title' ) }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<InputControl\n\t\t\t\t\t\t\tplaceholder={ __( 'No Title' ) }\n\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t\tvalue={ postsPageTitle }\n\t\t\t\t\t\t\tonChange={ debounce( setPostsPageTitle, 300 ) }\n\t\t\t\t\t\t\tlabel={ __( 'Blog title' ) }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Set the Posts Page title. Appears in search results, and when the page is shared on social media.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t/>\n\t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gB,EAAC,qCAAqC;MACtDC,YAAY;MACZC,YAAY,EAAGA,CAAE;QAAEC,MAAM;QAAEC;MAAS,CAAC,kBACpC5C,IAAA,CAACZ,MAAM;QACNyD,IAAI,EAAC,SAAS;QACdC,OAAO,EAAC,UAAU;QAClB,iBAAgBH,MAAQ;QACxB,cAAa9D,OAAO;QACnB;QACAD,EAAE,CAAE,uBAAwB,CAAC,EAC7BwD,YACD,CAAG;QACHW,OAAO,EAAGH,QAAU;QAAAL,QAAA,EAElBH;MAAY,CACP,CACN;MACHY,aAAa,EAAGA,CAAE;QAAEC;MAAQ,CAAC,kBAC5B7C,KAAA,CAAAF,SAAA;QAAAqC,QAAA,gBACCvC,IAAA,CAACL,sBAAsB;UACtB8B,KAAK,EAAG7C,EAAE,CAAE,YAAa,CAAG;UAC5BqE,OAAO,EAAGA;QAAS,CACnB,CAAC,eACFjD,IAAA,CAACT,YAAY;UACZ2D,WAAW,EAAGtE,EAAE,CAAE,UAAW,CAAG;UAChCiE,IAAI,EAAC,kBAAkB;UACvBM,KAAK,EAAG3C,cAAgB;UACxB4C,QAAQ,EAAGtE,QAAQ,CAAEoD,iBAAiB,EAAE,GAAI,CAAG;UAC/CG,KAAK,EAAGzD,EAAE,CAAE,YAAa,CAAG;UAC5ByE,IAAI,EAAGzE,EAAE,CACR,mGACD,CAAG;UACH0E,mBAAmB;QAAA,CACnB,CAAC;MAAA,CACD;IACA,CACH;EAAC,CACW,CAAC;AAEjB","ignoreList":[]}
@@ -23,7 +23,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
23
23
  const {
24
24
  useHasBlockToolbar
25
25
  } = unlock(blockEditorPrivateApis);
26
- function CollapsableBlockToolbar({
26
+ export default function CollapsibleBlockToolbar({
27
27
  isCollapsed,
28
28
  onToggle
29
29
  }) {
@@ -66,5 +66,4 @@ function CollapsableBlockToolbar({
66
66
  })]
67
67
  });
68
68
  }
69
- export default CollapsableBlockToolbar;
70
69
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","BlockToolbar","store","blockEditorStore","privateApis","blockEditorPrivateApis","useEffect","Button","Popover","__","next","previous","useSelect","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","useHasBlockToolbar","CollapsableBlockToolbar","isCollapsed","onToggle","blockSelectionStart","select","getBlockSelectionStart","hasBlockToolbar","hasBlockSelection","children","className","hideDragHandle","Slot","name","icon","onClick","label","size"],"sources":["@wordpress/editor/src/components/collapsible-block-toolbar/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockToolbar,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { Button, Popover } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { next, previous } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useHasBlockToolbar } = unlock( blockEditorPrivateApis );\n\nfunction CollapsableBlockToolbar( { isCollapsed, onToggle } ) {\n\tconst { blockSelectionStart } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tblockSelectionStart:\n\t\t\t\tselect( blockEditorStore ).getBlockSelectionStart(),\n\t\t};\n\t}, [] );\n\tconst hasBlockToolbar = useHasBlockToolbar();\n\n\tconst hasBlockSelection = !! blockSelectionStart;\n\n\tuseEffect( () => {\n\t\t// If we have a new block selection, show the block tools\n\t\tif ( blockSelectionStart ) {\n\t\t\tonToggle( false );\n\t\t}\n\t}, [ blockSelectionStart, onToggle ] );\n\n\tif ( ! hasBlockToolbar ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tclassName={ clsx( 'editor-collapsible-block-toolbar', {\n\t\t\t\t\t'is-collapsed': isCollapsed || ! hasBlockSelection,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<BlockToolbar hideDragHandle />\n\t\t\t</div>\n\t\t\t<Popover.Slot name=\"block-toolbar\" />\n\n\t\t\t<Button\n\t\t\t\tclassName=\"editor-collapsible-block-toolbar__toggle\"\n\t\t\t\ticon={ isCollapsed ? next : previous }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tonToggle( ! isCollapsed );\n\t\t\t\t} }\n\t\t\t\tlabel={\n\t\t\t\t\tisCollapsed\n\t\t\t\t\t\t? __( 'Show block tools' )\n\t\t\t\t\t\t: __( 'Hide block tools' )\n\t\t\t\t}\n\t\t\t\tsize=\"compact\"\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default CollapsableBlockToolbar;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SACCC,YAAY,EACZC,KAAK,IAAIC,gBAAgB,EACzBC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,MAAM,EAAEC,OAAO,QAAQ,uBAAuB;AACvD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,EAAEC,QAAQ,QAAQ,kBAAkB;AACjD,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAE3C,MAAM;EAAEC;AAAmB,CAAC,GAAGP,MAAM,CAAER,sBAAuB,CAAC;AAE/D,SAASgB,uBAAuBA,CAAE;EAAEC,WAAW;EAAEC;AAAS,CAAC,EAAG;EAC7D,MAAM;IAAEC;EAAoB,CAAC,GAAGZ,SAAS,CAAIa,MAAM,IAAM;IACxD,OAAO;MACND,mBAAmB,EAClBC,MAAM,CAAEtB,gBAAiB,CAAC,CAACuB,sBAAsB,CAAC;IACpD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,MAAMC,eAAe,GAAGP,kBAAkB,CAAC,CAAC;EAE5C,MAAMQ,iBAAiB,GAAG,CAAC,CAAEJ,mBAAmB;EAEhDlB,SAAS,CAAE,MAAM;IAChB;IACA,IAAKkB,mBAAmB,EAAG;MAC1BD,QAAQ,CAAE,KAAM,CAAC;IAClB;EACD,CAAC,EAAE,CAAEC,mBAAmB,EAAED,QAAQ,CAAG,CAAC;EAEtC,IAAK,CAAEI,eAAe,EAAG;IACxB,OAAO,IAAI;EACZ;EAEA,oBACCR,KAAA,CAAAF,SAAA;IAAAY,QAAA,gBACCd,IAAA;MACCe,SAAS,EAAG9B,IAAI,CAAE,kCAAkC,EAAE;QACrD,cAAc,EAAEsB,WAAW,IAAI,CAAEM;MAClC,CAAE,CAAG;MAAAC,QAAA,eAELd,IAAA,CAACd,YAAY;QAAC8B,cAAc;MAAA,CAAE;IAAC,CAC3B,CAAC,eACNhB,IAAA,CAACP,OAAO,CAACwB,IAAI;MAACC,IAAI,EAAC;IAAe,CAAE,CAAC,eAErClB,IAAA,CAACR,MAAM;MACNuB,SAAS,EAAC,0CAA0C;MACpDI,IAAI,EAAGZ,WAAW,GAAGZ,IAAI,GAAGC,QAAU;MACtCwB,OAAO,EAAGA,CAAA,KAAM;QACfZ,QAAQ,CAAE,CAAED,WAAY,CAAC;MAC1B,CAAG;MACHc,KAAK,EACJd,WAAW,GACRb,EAAE,CAAE,kBAAmB,CAAC,GACxBA,EAAE,CAAE,kBAAmB,CAC1B;MACD4B,IAAI,EAAC;IAAS,CACd,CAAC;EAAA,CACD,CAAC;AAEL;AAEA,eAAehB,uBAAuB","ignoreList":[]}
1
+ {"version":3,"names":["clsx","BlockToolbar","store","blockEditorStore","privateApis","blockEditorPrivateApis","useEffect","Button","Popover","__","next","previous","useSelect","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","useHasBlockToolbar","CollapsibleBlockToolbar","isCollapsed","onToggle","blockSelectionStart","select","getBlockSelectionStart","hasBlockToolbar","hasBlockSelection","children","className","hideDragHandle","Slot","name","icon","onClick","label","size"],"sources":["@wordpress/editor/src/components/collapsible-block-toolbar/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockToolbar,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { Button, Popover } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { next, previous } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useHasBlockToolbar } = unlock( blockEditorPrivateApis );\n\nexport default function CollapsibleBlockToolbar( { isCollapsed, onToggle } ) {\n\tconst { blockSelectionStart } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tblockSelectionStart:\n\t\t\t\tselect( blockEditorStore ).getBlockSelectionStart(),\n\t\t};\n\t}, [] );\n\tconst hasBlockToolbar = useHasBlockToolbar();\n\n\tconst hasBlockSelection = !! blockSelectionStart;\n\n\tuseEffect( () => {\n\t\t// If we have a new block selection, show the block tools\n\t\tif ( blockSelectionStart ) {\n\t\t\tonToggle( false );\n\t\t}\n\t}, [ blockSelectionStart, onToggle ] );\n\n\tif ( ! hasBlockToolbar ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tclassName={ clsx( 'editor-collapsible-block-toolbar', {\n\t\t\t\t\t'is-collapsed': isCollapsed || ! hasBlockSelection,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<BlockToolbar hideDragHandle />\n\t\t\t</div>\n\t\t\t<Popover.Slot name=\"block-toolbar\" />\n\n\t\t\t<Button\n\t\t\t\tclassName=\"editor-collapsible-block-toolbar__toggle\"\n\t\t\t\ticon={ isCollapsed ? next : previous }\n\t\t\t\tonCl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D,QAAQ,CAAE,KAAM,CAAC;IAClB;EACD,CAAC,EAAE,CAAEC,mBAAmB,EAAED,QAAQ,CAAG,CAAC;EAEtC,IAAK,CAAEI,eAAe,EAAG;IACxB,OAAO,IAAI;EACZ;EAEA,oBACCR,KAAA,CAAAF,SAAA;IAAAY,QAAA,gBACCd,IAAA;MACCe,SAAS,EAAG9B,IAAI,CAAE,kCAAkC,EAAE;QACrD,cAAc,EAAEsB,WAAW,IAAI,CAAEM;MAClC,CAAE,CAAG;MAAAC,QAAA,eAELd,IAAA,CAACd,YAAY;QAAC8B,cAAc;MAAA,CAAE;IAAC,CAC3B,CAAC,eACNhB,IAAA,CAACP,OAAO,CAACwB,IAAI;MAACC,IAAI,EAAC;IAAe,CAAE,CAAC,eAErClB,IAAA,CAACR,MAAM;MACNuB,SAAS,EAAC,0CAA0C;MACpDI,IAAI,EAAGZ,WAAW,GAAGZ,IAAI,GAAGC,QAAU;MACtCwB,OAAO,EAAGA,CAAA,KAAM;QACfZ,QAAQ,CAAE,CAAED,WAAY,CAAC;MAC1B,CAAG;MACHc,KAAK,EACJd,WAAW,GACRb,EAAE,CAAE,kBAAmB,CAAC,GACxBA,EAAE,CAAE,kBAAmB,CAC1B;MACD4B,IAAI,EAAC;IAAS,CACd,CAAC;EAAA,CACD,CAAC;AAEL","ignoreList":[]}
@@ -39,10 +39,15 @@ function useGlobalStylesUserConfig() {
39
39
  } = useSelect(select => {
40
40
  const {
41
41
  getEditedEntityRecord,
42
- hasFinishedResolution
42
+ hasFinishedResolution,
43
+ canUser
43
44
  } = select(coreStore);
44
45
  const _globalStylesId = select(coreStore).__experimentalGetCurrentGlobalStylesId();
45
- const record = _globalStylesId ? getEditedEntityRecord('root', 'globalStyles', _globalStylesId) : undefined;
46
+ const record = _globalStylesId && canUser('read', {
47
+ kind: 'root',
48
+ name: 'globalStyles',
49
+ id: _globalStylesId
50
+ }) ? getEditedEntityRecord('root', 'globalStyles', _globalStylesId) : undefined;
46
51
  let hasResolved = false;
47
52
  if (hasFinishedResolution('__experimentalGetCurrentGlobalStylesId')) {
48
53
  hasResolved = _globalStylesId ? hasFinishedResolution('getEditedEntityRecord', ['root', 'globalStyles', _globalStylesId]) : true;
@@ -94,7 +99,14 @@ function useGlobalStylesUserConfig() {
94
99
  }
95
100
  function useGlobalStylesBaseConfig() {
96
101
  const baseConfig = useSelect(select => {
97
- return select(coreStore).__experimentalGetCurrentThemeBaseGlobalStyles();
102
+ const {
103
+ __experimentalGetCurrentThemeBaseGlobalStyles,
104
+ canUser
105
+ } = select(coreStore);
106
+ return canUser('read', {
107
+ kind: 'root',
108
+ name: 'theme'
109
+ }) && __experimentalGetCurrentThemeBaseGlobalStyles();
98
110
  }, []);
99
111
  return [!!baseConfig, baseConfig];
100
112
  }