@wordpress/editor 14.3.0 → 14.5.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 (537) hide show
  1. package/CHANGELOG.md +8 -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 +35 -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 +7 -3
  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/commands/index.js +8 -2
  16. package/build/components/commands/index.js.map +1 -1
  17. package/build/components/document-bar/index.js +1 -1
  18. package/build/components/document-bar/index.js.map +1 -1
  19. package/build/components/global-styles-provider/index.js +15 -3
  20. package/build/components/global-styles-provider/index.js.map +1 -1
  21. package/build/components/header/back-button.js +7 -8
  22. package/build/components/header/back-button.js.map +1 -1
  23. package/build/components/header/index.js +21 -20
  24. package/build/components/header/index.js.map +1 -1
  25. package/build/components/page-attributes/order.js +1 -67
  26. package/build/components/page-attributes/order.js.map +1 -1
  27. package/build/components/page-attributes/panel.js +1 -4
  28. package/build/components/page-attributes/panel.js.map +1 -1
  29. package/build/components/page-attributes/parent.js +6 -2
  30. package/build/components/page-attributes/parent.js.map +1 -1
  31. package/build/components/post-actions/actions.js +131 -344
  32. package/build/components/post-actions/actions.js.map +1 -1
  33. package/build/components/post-actions/index.js +16 -6
  34. package/build/components/post-actions/index.js.map +1 -1
  35. package/build/components/post-author/hook.js +10 -3
  36. package/build/components/post-author/hook.js.map +1 -1
  37. package/build/components/post-author/panel.js +2 -1
  38. package/build/components/post-author/panel.js.map +1 -1
  39. package/build/components/post-card-panel/index.js +9 -3
  40. package/build/components/post-card-panel/index.js.map +1 -1
  41. package/build/components/post-comments/index.js +6 -20
  42. package/build/components/post-comments/index.js.map +1 -1
  43. package/build/components/post-content-information/index.js +7 -1
  44. package/build/components/post-content-information/index.js.map +1 -1
  45. package/build/components/post-discussion/panel.js +2 -2
  46. package/build/components/post-discussion/panel.js.map +1 -1
  47. package/build/components/post-excerpt/panel.js +1 -1
  48. package/build/components/post-excerpt/panel.js.map +1 -1
  49. package/build/components/post-featured-image/index.js +3 -1
  50. package/build/components/post-featured-image/index.js.map +1 -1
  51. package/build/components/post-last-revision/index.js +2 -1
  52. package/build/components/post-last-revision/index.js.map +1 -1
  53. package/build/components/post-publish-button/index.js +4 -11
  54. package/build/components/post-publish-button/index.js.map +1 -1
  55. package/build/components/post-publish-panel/maybe-category-panel.js +4 -1
  56. package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  57. package/build/components/post-publish-panel/maybe-tags-panel.js +2 -1
  58. package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  59. package/build/components/post-status/index.js +47 -51
  60. package/build/components/post-status/index.js.map +1 -1
  61. package/build/components/post-taxonomies/flat-term-selector.js +17 -6
  62. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  63. package/build/components/post-taxonomies/index.js +7 -1
  64. package/build/components/post-taxonomies/index.js.map +1 -1
  65. package/build/components/post-template/block-theme.js +4 -4
  66. package/build/components/post-template/block-theme.js.map +1 -1
  67. package/build/components/post-template/classic-theme.js +8 -2
  68. package/build/components/post-template/classic-theme.js.map +1 -1
  69. package/build/components/post-template/create-new-template-modal.js +3 -0
  70. package/build/components/post-template/create-new-template-modal.js.map +1 -1
  71. package/build/components/post-template/create-new-template.js +4 -1
  72. package/build/components/post-template/create-new-template.js.map +1 -1
  73. package/build/components/post-template/hooks.js +5 -1
  74. package/build/components/post-template/hooks.js.map +1 -1
  75. package/build/components/post-template/panel.js +8 -2
  76. package/build/components/post-template/panel.js.map +1 -1
  77. package/build/components/post-trash/check.js +6 -4
  78. package/build/components/post-trash/check.js.map +1 -1
  79. package/build/components/post-url/panel.js +9 -4
  80. package/build/components/post-url/panel.js.map +1 -1
  81. package/build/components/posts-per-page/index.js +6 -2
  82. package/build/components/posts-per-page/index.js.map +1 -1
  83. package/build/components/preview-dropdown/index.js +82 -17
  84. package/build/components/preview-dropdown/index.js.map +1 -1
  85. package/build/components/provider/disable-non-page-content-blocks.js +14 -18
  86. package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
  87. package/build/components/provider/use-block-editor-settings.js +15 -6
  88. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  89. package/build/components/save-publish-panels/index.js +1 -2
  90. package/build/components/save-publish-panels/index.js.map +1 -1
  91. package/build/components/sidebar/index.js +3 -9
  92. package/build/components/sidebar/index.js.map +1 -1
  93. package/build/components/site-discussion/index.js +12 -22
  94. package/build/components/site-discussion/index.js.map +1 -1
  95. package/build/components/template-content-panel/index.js +17 -15
  96. package/build/components/template-content-panel/index.js.map +1 -1
  97. package/build/components/visual-editor/edit-template-blocks-notification.js +4 -4
  98. package/build/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  99. package/build/components/visual-editor/index.js +7 -3
  100. package/build/components/visual-editor/index.js.map +1 -1
  101. package/build/{hooks → components/visual-editor}/use-select-nearest-editable-block.js +1 -1
  102. package/build/components/visual-editor/use-select-nearest-editable-block.js.map +1 -0
  103. package/build/dataviews/actions/delete-post.js +2 -0
  104. package/build/dataviews/actions/delete-post.js.map +1 -1
  105. package/build/dataviews/actions/export-pattern.native.js +9 -0
  106. package/build/dataviews/actions/export-pattern.native.js.map +1 -0
  107. package/build/dataviews/actions/permanently-delete-post.js +107 -0
  108. package/build/dataviews/actions/permanently-delete-post.js.map +1 -0
  109. package/build/dataviews/actions/restore-post.js +112 -0
  110. package/build/dataviews/actions/restore-post.js.map +1 -0
  111. package/build/dataviews/actions/trash-post.js +142 -0
  112. package/build/dataviews/actions/trash-post.js.map +1 -0
  113. package/build/dataviews/store/private-actions.js +45 -0
  114. package/build/dataviews/store/private-actions.js.map +1 -1
  115. package/build/dataviews/store/private-selectors.js +10 -10
  116. package/build/dataviews/store/private-selectors.js.map +1 -1
  117. package/build/dataviews/store/reducer.js +15 -1
  118. package/build/dataviews/store/reducer.js.map +1 -1
  119. package/build/dataviews/types.js.map +1 -1
  120. package/build/hooks/pattern-overrides.js +1 -1
  121. package/build/hooks/pattern-overrides.js.map +1 -1
  122. package/build/index.js +0 -1
  123. package/build/index.js.map +1 -1
  124. package/build/private-apis.js +3 -2
  125. package/build/private-apis.js.map +1 -1
  126. package/build/store/actions.js +16 -2
  127. package/build/store/actions.js.map +1 -1
  128. package/build/store/private-actions.js +8 -1
  129. package/build/store/private-actions.js.map +1 -1
  130. package/build/store/private-selectors.js +33 -2
  131. package/build/store/private-selectors.js.map +1 -1
  132. package/build/utils/media-upload/index.js +35 -2
  133. package/build/utils/media-upload/index.js.map +1 -1
  134. package/build-module/bindings/api.js +57 -0
  135. package/build-module/bindings/api.js.map +1 -0
  136. package/build-module/bindings/pattern-overrides.js +23 -13
  137. package/build-module/bindings/pattern-overrides.js.map +1 -1
  138. package/build-module/bindings/post-meta.js +35 -12
  139. package/build-module/bindings/post-meta.js.map +1 -1
  140. package/build-module/components/block-settings-menu/content-only-settings-menu.js +4 -1
  141. package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
  142. package/build-module/components/blog-title/index.js +7 -3
  143. package/build-module/components/blog-title/index.js.map +1 -1
  144. package/build-module/components/collapsible-block-toolbar/index.js +1 -2
  145. package/build-module/components/collapsible-block-toolbar/index.js.map +1 -1
  146. package/build-module/components/commands/index.js +8 -2
  147. package/build-module/components/commands/index.js.map +1 -1
  148. package/build-module/components/document-bar/index.js +1 -1
  149. package/build-module/components/document-bar/index.js.map +1 -1
  150. package/build-module/components/global-styles-provider/index.js +15 -3
  151. package/build-module/components/global-styles-provider/index.js.map +1 -1
  152. package/build-module/components/header/back-button.js +5 -7
  153. package/build-module/components/header/back-button.js.map +1 -1
  154. package/build-module/components/header/index.js +21 -22
  155. package/build-module/components/header/index.js.map +1 -1
  156. package/build-module/components/page-attributes/order.js +4 -70
  157. package/build-module/components/page-attributes/order.js.map +1 -1
  158. package/build-module/components/page-attributes/panel.js +1 -6
  159. package/build-module/components/page-attributes/panel.js.map +1 -1
  160. package/build-module/components/page-attributes/parent.js +7 -3
  161. package/build-module/components/page-attributes/parent.js.map +1 -1
  162. package/build-module/components/post-actions/actions.js +137 -350
  163. package/build-module/components/post-actions/actions.js.map +1 -1
  164. package/build-module/components/post-actions/index.js +16 -6
  165. package/build-module/components/post-actions/index.js.map +1 -1
  166. package/build-module/components/post-author/hook.js +10 -3
  167. package/build-module/components/post-author/hook.js.map +1 -1
  168. package/build-module/components/post-author/panel.js +2 -1
  169. package/build-module/components/post-author/panel.js.map +1 -1
  170. package/build-module/components/post-card-panel/index.js +9 -3
  171. package/build-module/components/post-card-panel/index.js.map +1 -1
  172. package/build-module/components/post-comments/index.js +8 -24
  173. package/build-module/components/post-comments/index.js.map +1 -1
  174. package/build-module/components/post-content-information/index.js +7 -1
  175. package/build-module/components/post-content-information/index.js.map +1 -1
  176. package/build-module/components/post-discussion/panel.js +3 -3
  177. package/build-module/components/post-discussion/panel.js.map +1 -1
  178. package/build-module/components/post-excerpt/panel.js +1 -1
  179. package/build-module/components/post-excerpt/panel.js.map +1 -1
  180. package/build-module/components/post-featured-image/index.js +3 -1
  181. package/build-module/components/post-featured-image/index.js.map +1 -1
  182. package/build-module/components/post-last-revision/index.js +2 -1
  183. package/build-module/components/post-last-revision/index.js.map +1 -1
  184. package/build-module/components/post-publish-button/index.js +4 -11
  185. package/build-module/components/post-publish-button/index.js.map +1 -1
  186. package/build-module/components/post-publish-panel/maybe-category-panel.js +4 -1
  187. package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  188. package/build-module/components/post-publish-panel/maybe-tags-panel.js +2 -1
  189. package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  190. package/build-module/components/post-status/index.js +49 -53
  191. package/build-module/components/post-status/index.js.map +1 -1
  192. package/build-module/components/post-taxonomies/flat-term-selector.js +17 -6
  193. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  194. package/build-module/components/post-taxonomies/index.js +7 -1
  195. package/build-module/components/post-taxonomies/index.js.map +1 -1
  196. package/build-module/components/post-template/block-theme.js +4 -4
  197. package/build-module/components/post-template/block-theme.js.map +1 -1
  198. package/build-module/components/post-template/classic-theme.js +8 -2
  199. package/build-module/components/post-template/classic-theme.js.map +1 -1
  200. package/build-module/components/post-template/create-new-template-modal.js +3 -0
  201. package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
  202. package/build-module/components/post-template/create-new-template.js +4 -1
  203. package/build-module/components/post-template/create-new-template.js.map +1 -1
  204. package/build-module/components/post-template/hooks.js +5 -1
  205. package/build-module/components/post-template/hooks.js.map +1 -1
  206. package/build-module/components/post-template/panel.js +8 -2
  207. package/build-module/components/post-template/panel.js.map +1 -1
  208. package/build-module/components/post-trash/check.js +6 -4
  209. package/build-module/components/post-trash/check.js.map +1 -1
  210. package/build-module/components/post-url/panel.js +10 -7
  211. package/build-module/components/post-url/panel.js.map +1 -1
  212. package/build-module/components/posts-per-page/index.js +6 -2
  213. package/build-module/components/posts-per-page/index.js.map +1 -1
  214. package/build-module/components/preview-dropdown/index.js +84 -19
  215. package/build-module/components/preview-dropdown/index.js.map +1 -1
  216. package/build-module/components/provider/disable-non-page-content-blocks.js +15 -19
  217. package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
  218. package/build-module/components/provider/use-block-editor-settings.js +15 -6
  219. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  220. package/build-module/components/save-publish-panels/index.js +1 -2
  221. package/build-module/components/save-publish-panels/index.js.map +1 -1
  222. package/build-module/components/sidebar/index.js +3 -9
  223. package/build-module/components/sidebar/index.js.map +1 -1
  224. package/build-module/components/site-discussion/index.js +14 -24
  225. package/build-module/components/site-discussion/index.js.map +1 -1
  226. package/build-module/components/template-content-panel/index.js +18 -16
  227. package/build-module/components/template-content-panel/index.js.map +1 -1
  228. package/build-module/components/visual-editor/edit-template-blocks-notification.js +4 -4
  229. package/build-module/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  230. package/build-module/components/visual-editor/index.js +7 -3
  231. package/build-module/components/visual-editor/index.js.map +1 -1
  232. package/build-module/{hooks → components/visual-editor}/use-select-nearest-editable-block.js +1 -1
  233. package/build-module/components/visual-editor/use-select-nearest-editable-block.js.map +1 -0
  234. package/build-module/dataviews/actions/delete-post.js +2 -0
  235. package/build-module/dataviews/actions/delete-post.js.map +1 -1
  236. package/build-module/dataviews/actions/export-pattern.native.js +3 -0
  237. package/build-module/dataviews/actions/export-pattern.native.js.map +1 -0
  238. package/build-module/dataviews/actions/permanently-delete-post.js +99 -0
  239. package/build-module/dataviews/actions/permanently-delete-post.js.map +1 -0
  240. package/build-module/dataviews/actions/restore-post.js +104 -0
  241. package/build-module/dataviews/actions/restore-post.js.map +1 -0
  242. package/build-module/dataviews/actions/trash-post.js +135 -0
  243. package/build-module/dataviews/actions/trash-post.js.map +1 -0
  244. package/build-module/dataviews/store/private-actions.js +40 -0
  245. package/build-module/dataviews/store/private-actions.js.map +1 -1
  246. package/build-module/dataviews/store/private-selectors.js +8 -9
  247. package/build-module/dataviews/store/private-selectors.js.map +1 -1
  248. package/build-module/dataviews/store/reducer.js +15 -1
  249. package/build-module/dataviews/store/reducer.js.map +1 -1
  250. package/build-module/dataviews/types.js.map +1 -1
  251. package/build-module/hooks/pattern-overrides.js +1 -1
  252. package/build-module/hooks/pattern-overrides.js.map +1 -1
  253. package/build-module/index.js +0 -1
  254. package/build-module/index.js.map +1 -1
  255. package/build-module/private-apis.js +3 -2
  256. package/build-module/private-apis.js.map +1 -1
  257. package/build-module/store/actions.js +16 -2
  258. package/build-module/store/actions.js.map +1 -1
  259. package/build-module/store/private-actions.js +8 -1
  260. package/build-module/store/private-actions.js.map +1 -1
  261. package/build-module/store/private-selectors.js +32 -2
  262. package/build-module/store/private-selectors.js.map +1 -1
  263. package/build-module/utils/media-upload/index.js +36 -3
  264. package/build-module/utils/media-upload/index.js.map +1 -1
  265. package/build-style/style-rtl.css +97 -45
  266. package/build-style/style.css +97 -45
  267. package/build-types/bindings/api.d.ts +25 -0
  268. package/build-types/bindings/api.d.ts.map +1 -0
  269. package/build-types/bindings/pattern-overrides.d.ts +5 -6
  270. package/build-types/bindings/pattern-overrides.d.ts.map +1 -1
  271. package/build-types/bindings/post-meta.d.ts +11 -7
  272. package/build-types/bindings/post-meta.d.ts.map +1 -1
  273. package/build-types/components/autocompleters/user.d.ts +2 -2
  274. package/build-types/components/autocompleters/user.d.ts.map +1 -1
  275. package/build-types/components/block-settings-menu/plugin-block-settings-menu-item.d.ts.map +1 -1
  276. package/build-types/components/blog-title/index.d.ts.map +1 -1
  277. package/build-types/components/collapsible-block-toolbar/index.d.ts +1 -2
  278. package/build-types/components/collapsible-block-toolbar/index.d.ts.map +1 -1
  279. package/build-types/components/commands/index.d.ts.map +1 -1
  280. package/build-types/components/document-bar/index.d.ts.map +1 -1
  281. package/build-types/components/document-outline/check.d.ts.map +1 -1
  282. package/build-types/components/document-outline/index.d.ts.map +1 -1
  283. package/build-types/components/editor-history/redo.d.ts +1 -1
  284. package/build-types/components/editor-history/undo.d.ts +1 -1
  285. package/build-types/components/editor-notices/index.d.ts.map +1 -1
  286. package/build-types/components/editor-snackbars/index.d.ts.map +1 -1
  287. package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
  288. package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
  289. package/build-types/components/header/back-button.d.ts +1 -0
  290. package/build-types/components/header/back-button.d.ts.map +1 -1
  291. package/build-types/components/header/index.d.ts.map +1 -1
  292. package/build-types/components/local-autosave-monitor/index.d.ts.map +1 -1
  293. package/build-types/components/media-categories/index.d.ts.map +1 -1
  294. package/build-types/components/more-menu/tools-more-menu-group.d.ts.map +1 -1
  295. package/build-types/components/more-menu/view-more-menu-group.d.ts.map +1 -1
  296. package/build-types/components/page-attributes/check.d.ts.map +1 -1
  297. package/build-types/components/page-attributes/order.d.ts +1 -1
  298. package/build-types/components/page-attributes/order.d.ts.map +1 -1
  299. package/build-types/components/page-attributes/panel.d.ts.map +1 -1
  300. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  301. package/build-types/components/plugin-document-setting-panel/index.d.ts.map +1 -1
  302. package/build-types/components/plugin-post-publish-panel/index.d.ts.map +1 -1
  303. package/build-types/components/plugin-post-status-info/index.d.ts.map +1 -1
  304. package/build-types/components/plugin-pre-publish-panel/index.d.ts.map +1 -1
  305. package/build-types/components/plugin-sidebar/index.d.ts.map +1 -1
  306. package/build-types/components/plugin-sidebar-more-menu-item/index.d.ts.map +1 -1
  307. package/build-types/components/post-actions/actions.d.ts.map +1 -1
  308. package/build-types/components/post-actions/index.d.ts.map +1 -1
  309. package/build-types/components/post-author/check.d.ts.map +1 -1
  310. package/build-types/components/post-author/hook.d.ts +1 -1
  311. package/build-types/components/post-author/hook.d.ts.map +1 -1
  312. package/build-types/components/post-author/index.d.ts.map +1 -1
  313. package/build-types/components/post-author/panel.d.ts.map +1 -1
  314. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  315. package/build-types/components/post-comments/index.d.ts.map +1 -1
  316. package/build-types/components/post-content-information/index.d.ts.map +1 -1
  317. package/build-types/components/post-discussion/panel.d.ts.map +1 -1
  318. package/build-types/components/post-excerpt/check.d.ts.map +1 -1
  319. package/build-types/components/post-excerpt/index.d.ts.map +1 -1
  320. package/build-types/components/post-excerpt/panel.d.ts.map +1 -1
  321. package/build-types/components/post-excerpt/plugin.d.ts.map +1 -1
  322. package/build-types/components/post-featured-image/check.d.ts.map +1 -1
  323. package/build-types/components/post-featured-image/panel.d.ts.map +1 -1
  324. package/build-types/components/post-format/index.d.ts.map +1 -1
  325. package/build-types/components/post-format/panel.d.ts.map +1 -1
  326. package/build-types/components/post-last-revision/check.d.ts.map +1 -1
  327. package/build-types/components/post-last-revision/index.d.ts.map +1 -1
  328. package/build-types/components/post-last-revision/panel.d.ts.map +1 -1
  329. package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
  330. package/build-types/components/post-pending-status/check.d.ts.map +1 -1
  331. package/build-types/components/post-pending-status/index.d.ts.map +1 -1
  332. package/build-types/components/post-preview-button/index.d.ts.map +1 -1
  333. package/build-types/components/post-publish-button/index.d.ts.map +1 -1
  334. package/build-types/components/post-publish-panel/maybe-category-panel.d.ts.map +1 -1
  335. package/build-types/components/post-saved-state/index.d.ts +1 -1
  336. package/build-types/components/post-saved-state/index.d.ts.map +1 -1
  337. package/build-types/components/post-schedule/check.d.ts.map +1 -1
  338. package/build-types/components/post-schedule/index.d.ts.map +1 -1
  339. package/build-types/components/post-schedule/label.d.ts.map +1 -1
  340. package/build-types/components/post-schedule/panel.d.ts.map +1 -1
  341. package/build-types/components/post-slug/check.d.ts.map +1 -1
  342. package/build-types/components/post-slug/index.d.ts.map +1 -1
  343. package/build-types/components/post-status/index.d.ts +2 -1
  344. package/build-types/components/post-status/index.d.ts.map +1 -1
  345. package/build-types/components/post-sticky/check.d.ts.map +1 -1
  346. package/build-types/components/post-sticky/index.d.ts.map +1 -1
  347. package/build-types/components/post-switch-to-draft-button/index.d.ts.map +1 -1
  348. package/build-types/components/post-sync-status/index.d.ts.map +1 -1
  349. package/build-types/components/post-taxonomies/check.d.ts.map +1 -1
  350. package/build-types/components/post-taxonomies/flat-term-selector.d.ts +9 -7
  351. package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
  352. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +13 -11
  353. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
  354. package/build-types/components/post-taxonomies/index.d.ts.map +1 -1
  355. package/build-types/components/post-template/block-theme.d.ts.map +1 -1
  356. package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
  357. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  358. package/build-types/components/post-template/create-new-template.d.ts.map +1 -1
  359. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  360. package/build-types/components/post-template/panel.d.ts.map +1 -1
  361. package/build-types/components/post-text-editor/index.d.ts.map +1 -1
  362. package/build-types/components/post-trash/check.d.ts.map +1 -1
  363. package/build-types/components/post-trash/index.d.ts.map +1 -1
  364. package/build-types/components/post-type-support-check/index.d.ts.map +1 -1
  365. package/build-types/components/post-url/check.d.ts.map +1 -1
  366. package/build-types/components/post-url/index.d.ts.map +1 -1
  367. package/build-types/components/post-url/label.d.ts.map +1 -1
  368. package/build-types/components/post-url/panel.d.ts.map +1 -1
  369. package/build-types/components/post-visibility/check.d.ts.map +1 -1
  370. package/build-types/components/post-visibility/index.d.ts.map +1 -1
  371. package/build-types/components/posts-per-page/index.d.ts.map +1 -1
  372. package/build-types/components/preferences-modal/enable-plugin-document-setting-panel.d.ts.map +1 -1
  373. package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
  374. package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
  375. package/build-types/components/provider/index.d.ts.map +1 -1
  376. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  377. package/build-types/components/save-publish-panels/index.d.ts.map +1 -1
  378. package/build-types/components/sidebar/index.d.ts.map +1 -1
  379. package/build-types/components/site-discussion/index.d.ts.map +1 -1
  380. package/build-types/components/template-content-panel/index.d.ts +1 -3
  381. package/build-types/components/template-content-panel/index.d.ts.map +1 -1
  382. package/build-types/components/theme-support-check/index.d.ts.map +1 -1
  383. package/build-types/components/time-to-read/index.d.ts.map +1 -1
  384. package/build-types/components/unsaved-changes-warning/index.d.ts.map +1 -1
  385. package/build-types/components/visual-editor/edit-template-blocks-notification.d.ts +1 -1
  386. package/build-types/components/visual-editor/edit-template-blocks-notification.d.ts.map +1 -1
  387. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  388. package/build-types/components/visual-editor/use-select-nearest-editable-block.d.ts.map +1 -0
  389. package/build-types/components/word-count/index.d.ts.map +1 -1
  390. package/build-types/dataviews/actions/delete-post.d.ts.map +1 -1
  391. package/build-types/dataviews/actions/export-pattern.native.d.ts +3 -0
  392. package/build-types/dataviews/actions/export-pattern.native.d.ts.map +1 -0
  393. package/build-types/dataviews/actions/permanently-delete-post.d.ts +5 -0
  394. package/build-types/dataviews/actions/permanently-delete-post.d.ts.map +1 -0
  395. package/build-types/dataviews/actions/restore-post.d.ts +5 -0
  396. package/build-types/dataviews/actions/restore-post.d.ts.map +1 -0
  397. package/build-types/dataviews/actions/trash-post.d.ts +5 -0
  398. package/build-types/dataviews/actions/trash-post.d.ts.map +1 -0
  399. package/build-types/dataviews/api.d.ts +1 -1
  400. package/build-types/dataviews/api.d.ts.map +1 -1
  401. package/build-types/dataviews/store/private-actions.d.ts +8 -3
  402. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  403. package/build-types/dataviews/store/private-selectors.d.ts +2 -2
  404. package/build-types/dataviews/store/private-selectors.d.ts.map +1 -1
  405. package/build-types/dataviews/store/reducer.d.ts +4 -1
  406. package/build-types/dataviews/store/reducer.d.ts.map +1 -1
  407. package/build-types/dataviews/types.d.ts +9 -0
  408. package/build-types/dataviews/types.d.ts.map +1 -1
  409. package/build-types/hooks/custom-sources-backwards-compatibility.d.ts +1 -1
  410. package/build-types/hooks/custom-sources-backwards-compatibility.d.ts.map +1 -1
  411. package/build-types/hooks/pattern-overrides.d.ts.map +1 -1
  412. package/build-types/private-apis.d.ts.map +1 -1
  413. package/build-types/store/actions.d.ts.map +1 -1
  414. package/build-types/store/private-actions.d.ts.map +1 -1
  415. package/build-types/store/private-selectors.d.ts +11 -0
  416. package/build-types/store/private-selectors.d.ts.map +1 -1
  417. package/build-types/store/reducer.d.ts +1 -0
  418. package/build-types/store/reducer.d.ts.map +1 -1
  419. package/build-types/store/selectors.d.ts +0 -1
  420. package/build-types/store/selectors.d.ts.map +1 -1
  421. package/build-types/utils/media-upload/index.d.ts.map +1 -1
  422. package/package.json +38 -37
  423. package/src/bindings/api.js +57 -0
  424. package/src/bindings/pattern-overrides.js +28 -17
  425. package/src/bindings/post-meta.js +39 -14
  426. package/src/components/block-settings-menu/content-only-settings-menu.js +4 -4
  427. package/src/components/blog-title/index.js +8 -3
  428. package/src/components/collapsible-block-toolbar/index.js +1 -3
  429. package/src/components/collapsible-block-toolbar/style.scss +0 -3
  430. package/src/components/commands/index.js +4 -2
  431. package/src/components/document-bar/index.js +1 -1
  432. package/src/components/document-bar/style.scss +2 -6
  433. package/src/components/document-tools/style.scss +4 -4
  434. package/src/components/editor-interface/style.scss +9 -0
  435. package/src/components/global-styles-provider/index.js +22 -11
  436. package/src/components/header/back-button.js +6 -6
  437. package/src/components/header/index.js +27 -27
  438. package/src/components/header/style.scss +64 -21
  439. package/src/components/inserter-sidebar/style.scss +1 -6
  440. package/src/components/list-view-sidebar/style.scss +4 -0
  441. package/src/components/page-attributes/order.js +3 -77
  442. package/src/components/page-attributes/panel.js +1 -7
  443. package/src/components/page-attributes/parent.js +25 -7
  444. package/src/components/post-actions/actions.js +158 -463
  445. package/src/components/post-actions/index.js +19 -7
  446. package/src/components/post-author/hook.js +11 -3
  447. package/src/components/post-author/panel.js +3 -1
  448. package/src/components/post-card-panel/index.js +9 -3
  449. package/src/components/post-comments/index.js +8 -21
  450. package/src/components/post-content-information/index.js +7 -1
  451. package/src/components/post-discussion/panel.js +5 -3
  452. package/src/components/post-excerpt/panel.js +2 -1
  453. package/src/components/post-featured-image/index.js +5 -1
  454. package/src/components/post-last-revision/index.js +1 -0
  455. package/src/components/post-panel-row/style.scss +0 -1
  456. package/src/components/post-publish-button/index.js +4 -17
  457. package/src/components/post-publish-panel/maybe-category-panel.js +4 -1
  458. package/src/components/post-publish-panel/maybe-tags-panel.js +1 -1
  459. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
  460. package/src/components/post-status/index.js +29 -51
  461. package/src/components/post-taxonomies/flat-term-selector.js +19 -5
  462. package/src/components/post-taxonomies/index.js +8 -1
  463. package/src/components/post-template/block-theme.js +5 -1
  464. package/src/components/post-template/classic-theme.js +8 -3
  465. package/src/components/post-template/create-new-template-modal.js +7 -1
  466. package/src/components/post-template/create-new-template.js +4 -1
  467. package/src/components/post-template/hooks.js +8 -2
  468. package/src/components/post-template/panel.js +10 -2
  469. package/src/components/post-trash/check.js +9 -5
  470. package/src/components/post-url/panel.js +15 -4
  471. package/src/components/posts-per-page/index.js +7 -2
  472. package/src/components/preview-dropdown/index.js +113 -35
  473. package/src/components/preview-dropdown/style.scss +5 -0
  474. package/src/components/provider/disable-non-page-content-blocks.js +27 -24
  475. package/src/components/provider/use-block-editor-settings.js +15 -6
  476. package/src/components/save-publish-panels/index.js +1 -4
  477. package/src/components/sidebar/index.js +2 -5
  478. package/src/components/site-discussion/index.js +15 -22
  479. package/src/components/template-content-panel/index.js +37 -21
  480. package/src/components/visual-editor/edit-template-blocks-notification.js +5 -1
  481. package/src/components/visual-editor/index.js +13 -8
  482. package/src/components/visual-editor/style.scss +1 -4
  483. package/src/{hooks → components/visual-editor}/use-select-nearest-editable-block.js +1 -1
  484. package/src/dataviews/actions/delete-post.tsx +2 -0
  485. package/src/dataviews/actions/export-pattern.native.tsx +3 -0
  486. package/src/dataviews/actions/permanently-delete-post.tsx +116 -0
  487. package/src/dataviews/actions/restore-post.tsx +134 -0
  488. package/src/dataviews/actions/trash-post.tsx +196 -0
  489. package/src/dataviews/store/private-actions.ts +68 -0
  490. package/src/dataviews/store/private-selectors.ts +9 -17
  491. package/src/dataviews/store/reducer.ts +20 -1
  492. package/src/dataviews/types.ts +11 -0
  493. package/src/hooks/pattern-overrides.js +1 -1
  494. package/src/index.js +0 -1
  495. package/src/private-apis.js +6 -2
  496. package/src/store/actions.js +36 -13
  497. package/src/store/private-actions.js +8 -4
  498. package/src/store/private-selectors.js +45 -2
  499. package/src/store/test/actions.js +9 -3
  500. package/src/store/test/private-selectors.js +78 -0
  501. package/src/utils/media-upload/index.js +38 -3
  502. package/tsconfig.tsbuildinfo +1 -1
  503. package/build/bindings/index.js +0 -22
  504. package/build/bindings/index.js.map +0 -1
  505. package/build/dataviews/actions/index.js +0 -32
  506. package/build/dataviews/actions/index.js.map +0 -1
  507. package/build/hooks/use-select-nearest-editable-block.js.map +0 -1
  508. package/build/store/utils/get-filtered-template-parts.js +0 -71
  509. package/build/store/utils/get-filtered-template-parts.js.map +0 -1
  510. package/build/utils/set-nested-value.js +0 -44
  511. package/build/utils/set-nested-value.js.map +0 -1
  512. package/build-module/bindings/index.js +0 -17
  513. package/build-module/bindings/index.js.map +0 -1
  514. package/build-module/dataviews/actions/index.js +0 -24
  515. package/build-module/dataviews/actions/index.js.map +0 -1
  516. package/build-module/hooks/use-select-nearest-editable-block.js.map +0 -1
  517. package/build-module/store/utils/get-filtered-template-parts.js +0 -64
  518. package/build-module/store/utils/get-filtered-template-parts.js.map +0 -1
  519. package/build-module/utils/set-nested-value.js +0 -38
  520. package/build-module/utils/set-nested-value.js.map +0 -1
  521. package/build-types/bindings/index.d.ts +0 -2
  522. package/build-types/bindings/index.d.ts.map +0 -1
  523. package/build-types/dataviews/actions/index.d.ts +0 -2
  524. package/build-types/dataviews/actions/index.d.ts.map +0 -1
  525. package/build-types/hooks/use-select-nearest-editable-block.d.ts.map +0 -1
  526. package/build-types/store/utils/get-filtered-template-parts.d.ts +0 -3
  527. package/build-types/store/utils/get-filtered-template-parts.d.ts.map +0 -1
  528. package/build-types/utils/set-nested-value.d.ts +0 -20
  529. package/build-types/utils/set-nested-value.d.ts.map +0 -1
  530. package/src/bindings/index.js +0 -15
  531. package/src/components/document-outline/test/__snapshots__/index.js.snap +0 -111
  532. package/src/components/document-outline/test/index.js +0 -185
  533. package/src/dataviews/actions/index.ts +0 -25
  534. package/src/store/utils/get-filtered-template-parts.js +0 -69
  535. package/src/store/utils/test/get-filtered-template-parts.js +0 -189
  536. package/src/utils/set-nested-value.js +0 -39
  537. /package/build-types/{hooks → components/visual-editor}/use-select-nearest-editable-block.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"names":["__","SelectControl","Dropdown","Button","Notice","useSelect","useDispatch","store","coreStore","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","useState","useMemo","addTemplate","noticesStore","editorStore","CreateNewTemplateModal","useAllowSwitchingTemplates","jsx","_jsx","jsxs","_jsxs","POPOVER_PROPS","className","placement","PostTemplateToggle","isOpen","onClick","templateTitle","select","templateSlug","getEditedPostAttribute","supportsTemplateMode","availableTemplates","getEditorSettings","template","canUser","getCurrentTemplateId","title","slug","__next40pxDefaultSize","variant","children","PostTemplateDropdownContent","onClose","_options$find","_selectedOption$value","allowSwitchingTemplate","fetchedTemplates","selectedTemplateSlug","canCreate","canEdit","currentTemplateId","onNavigateToEntityRecord","getEntityRecords","editorSettings","canCreateTemplates","_currentTemplateId","post_type","getCurrentPostType","per_page","undefined","options","Object","entries","fromEntries","map","rendered","value","label","selectedOption","find","option","editPost","createSuccessNotice","isCreateModalOpen","setIsCreateModalOpen","help","actions","icon","status","isDismissible","__nextHasNoMarginBottom","hideLabelFromVision","onChange","postId","postType","type","onNavigateToPreviousEntityRecord","ClassicThemeControl","popoverProps","focusOnMount","renderToggle","onToggle","renderContent"],"sources":["@wordpress/editor/src/components/post-template/classic-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { SelectControl, Dropdown, Button, Notice } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { addTemplate } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nfunction PostTemplateToggle( { isOpen, onClick } ) {\n\tconst templateTitle = useSelect( ( select ) => {\n\t\tconst templateSlug =\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' );\n\n\t\tconst { supportsTemplateMode, availableTemplates } =\n\t\t\tselect( editorStore ).getEditorSettings();\n\t\tif ( ! supportsTemplateMode && availableTemplates[ templateSlug ] ) {\n\t\t\treturn availableTemplates[ templateSlug ];\n\t\t}\n\t\tconst template =\n\t\t\tselect( coreStore ).canUser( 'create', 'templates' ) &&\n\t\t\tselect( editorStore ).getCurrentTemplateId();\n\t\treturn (\n\t\t\ttemplate?.title ||\n\t\t\ttemplate?.slug ||\n\t\t\tavailableTemplates?.[ templateSlug ]\n\t\t);\n\t}, [] );\n\n\treturn (\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={ __( 'Template options' ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ templateTitle ?? __( 'Default template' ) }\n\t\t</Button>\n\t);\n}\n\n/**\n * Renders the dropdown content for selecting a post template.\n *\n * @param {Object} props The component props.\n * @param {Function} props.onClose The function to close the dropdown.\n *\n * @return {JSX.Element} The rendered dropdown content.\n */\nfunction PostTemplateDropdownContent( { onClose } ) {\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst {\n\t\tavailableTemplates,\n\t\tfetchedTemplates,\n\t\tselectedTemplateSlug,\n\t\tcanCreate,\n\t\tcanEdit,\n\t\tcurrentTemplateId,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecords } = select( coreStore );\n\t\t\tconst editorSettings = select( editorStore ).getEditorSettings();\n\t\t\tconst canCreateTemplates = canUser( 'create', 'templates' );\n\t\t\tconst _currentTemplateId =\n\t\t\t\tselect( editorStore ).getCurrentTemplateId();\n\t\t\treturn {\n\t\t\t\tavailableTemplates: editorSettings.availableTemplates,\n\t\t\t\tfetchedTemplates: canCreateTemplates\n\t\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\t\tpost_type:\n\t\t\t\t\t\t\t\tselect( editorStore ).getCurrentPostType(),\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined,\n\t\t\t\tselectedTemplateSlug:\n\t\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' ),\n\t\t\t\tcanCreate:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode,\n\t\t\t\tcanEdit:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode &&\n\t\t\t\t\t!! _currentTemplateId,\n\t\t\t\tcurrentTemplateId: _currentTemplateId,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\teditorSettings.onNavigateToEntityRecord,\n\t\t\t\tgetEditorSettings: select( editorStore ).getEditorSettings,\n\t\t\t};\n\t\t},\n\t\t[ allowSwitchingTemplate ]\n\t);\n\n\tconst options = useMemo(\n\t\t() =>\n\t\t\tObject.entries( {\n\t\t\t\t...availableTemplates,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\ttitle.rendered,\n\t\t\t\t\t] )\n\t\t\t\t),\n\t\t\t} ).map( ( [ slug, title ] ) => ( { value: slug, label: title } ) ),\n\t\t[ availableTemplates, fetchedTemplates ]\n\t);\n\n\tconst selectedOption =\n\t\toptions.find( ( option ) => option.value === selectedTemplateSlug ) ??\n\t\toptions.find( ( option ) => ! option.value ); // The default option has '' value.\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\n\treturn (\n\t\t<div className=\"editor-post-template__classic-theme-dropdown\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Template' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Templates define the way content is displayed when viewing your site.'\n\t\t\t\t) }\n\t\t\t\tactions={\n\t\t\t\t\tcanCreate\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ticon: addTemplate,\n\t\t\t\t\t\t\t\t\tlabel: __( 'Add template' ),\n\t\t\t\t\t\t\t\t\tonClick: () => setIsCreateModalOpen( true ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: []\n\t\t\t\t}\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t{ ! allowSwitchingTemplate ? (\n\t\t\t\t<Notice status=\"warning\" isDismissible={ false }>\n\t\t\t\t\t{ __( 'The posts page template cannot be changed.' ) }\n\t\t\t\t</Notice>\n\t\t\t) : (\n\t\t\t\t<SelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Template' ) }\n\t\t\t\t\tvalue={ selectedOption?.value ?? '' }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( slug ) =>\n\t\t\t\t\t\teditPost( { template: slug || '' } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canEdit && onNavigateToEntityRecord && (\n\t\t\t\t<p>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\tpostId: currentTemplateId,\n\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => setIsCreateModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction ClassicThemeControl() {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<PostTemplateToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<PostTemplateDropdownContent onClose={ onClose } />\n\t\t\t) }\n\t\t/>\n\t);\n}\n\n/**\n * Provides a dropdown menu for selecting and managing post templates.\n *\n * The dropdown menu includes a button for toggling the menu, a list of available templates, and options for creating and editing templates.\n *\n * @return {JSX.Element} The r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;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe6C,mBAAmB","ignoreList":[]}
1
+ {"version":3,"names":["__","SelectControl","Dropdown","Button","Notice","useSelect","useDispatch","store","coreStore","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","useState","useMemo","addTemplate","noticesStore","editorStore","CreateNewTemplateModal","useAllowSwitchingTemplates","jsx","_jsx","jsxs","_jsxs","POPOVER_PROPS","className","placement","PostTemplateToggle","isOpen","onClick","templateTitle","select","templateSlug","getEditedPostAttribute","supportsTemplateMode","availableTemplates","getEditorSettings","template","canUser","kind","name","getCurrentTemplateId","title","slug","__next40pxDefaultSize","variant","children","PostTemplateDropdownContent","onClose","_options$find","_selectedOption$value","allowSwitchingTemplate","fetchedTemplates","selectedTemplateSlug","canCreate","canEdit","currentTemplateId","onNavigateToEntityRecord","getEntityRecords","editorSettings","canCreateTemplates","_currentTemplateId","post_type","getCurrentPostType","per_page","undefined","options","Object","entries","fromEntries","map","rendered","value","label","selectedOption","find","option","editPost","createSuccessNotice","isCreateModalOpen","setIsCreateModalOpen","help","actions","icon","status","isDismissible","__nextHasNoMarginBottom","hideLabelFromVision","onChange","postId","postType","type","onNavigateToPreviousEntityRecord","ClassicThemeControl","popoverProps","focusOnMount","renderToggle","onToggle","renderContent"],"sources":["@wordpress/editor/src/components/post-template/classic-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { SelectControl, Dropdown, Button, Notice } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { addTemplate } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nfunction PostTemplateToggle( { isOpen, onClick } ) {\n\tconst templateTitle = useSelect( ( select ) => {\n\t\tconst templateSlug =\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' );\n\n\t\tconst { supportsTemplateMode, availableTemplates } =\n\t\t\tselect( editorStore ).getEditorSettings();\n\t\tif ( ! supportsTemplateMode && availableTemplates[ templateSlug ] ) {\n\t\t\treturn availableTemplates[ templateSlug ];\n\t\t}\n\t\tconst template =\n\t\t\tselect( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ) && select( editorStore ).getCurrentTemplateId();\n\t\treturn (\n\t\t\ttemplate?.title ||\n\t\t\ttemplate?.slug ||\n\t\t\tavailableTemplates?.[ templateSlug ]\n\t\t);\n\t}, [] );\n\n\treturn (\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={ __( 'Template options' ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ templateTitle ?? __( 'Default template' ) }\n\t\t</Button>\n\t);\n}\n\n/**\n * Renders the dropdown content for selecting a post template.\n *\n * @param {Object} props The component props.\n * @param {Function} props.onClose The function to close the dropdown.\n *\n * @return {JSX.Element} The rendered dropdown content.\n */\nfunction PostTemplateDropdownContent( { onClose } ) {\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst {\n\t\tavailableTemplates,\n\t\tfetchedTemplates,\n\t\tselectedTemplateSlug,\n\t\tcanCreate,\n\t\tcanEdit,\n\t\tcurrentTemplateId,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecords } = select( coreStore );\n\t\t\tconst editorSettings = select( editorStore ).getEditorSettings();\n\t\t\tconst canCreateTemplates = canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\tconst _currentTemplateId =\n\t\t\t\tselect( editorStore ).getCurrentTemplateId();\n\t\t\treturn {\n\t\t\t\tavailableTemplates: editorSettings.availableTemplates,\n\t\t\t\tfetchedTemplates: canCreateTemplates\n\t\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\t\tpost_type:\n\t\t\t\t\t\t\t\tselect( editorStore ).getCurrentPostType(),\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined,\n\t\t\t\tselectedTemplateSlug:\n\t\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' ),\n\t\t\t\tcanCreate:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode,\n\t\t\t\tcanEdit:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode &&\n\t\t\t\t\t!! _currentTemplateId,\n\t\t\t\tcurrentTemplateId: _currentTemplateId,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\teditorSettings.onNavigateToEntityRecord,\n\t\t\t\tgetEditorSettings: select( editorStore ).getEditorSettings,\n\t\t\t};\n\t\t},\n\t\t[ allowSwitchingTemplate ]\n\t);\n\n\tconst options = useMemo(\n\t\t() =>\n\t\t\tObject.entries( {\n\t\t\t\t...availableTemplates,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\ttitle.rendered,\n\t\t\t\t\t] )\n\t\t\t\t),\n\t\t\t} ).map( ( [ slug, title ] ) => ( { value: slug, label: title } ) ),\n\t\t[ availableTemplates, fetchedTemplates ]\n\t);\n\n\tconst selectedOption =\n\t\toptions.find( ( option ) => option.value === selectedTemplateSlug ) ??\n\t\toptions.find( ( option ) => ! option.value ); // The default option has '' value.\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\n\treturn (\n\t\t<div className=\"editor-post-template__classic-theme-dropdown\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Template' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Templates define the way content is displayed when viewing your site.'\n\t\t\t\t) }\n\t\t\t\tactions={\n\t\t\t\t\tcanCreate\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ticon: addTemplate,\n\t\t\t\t\t\t\t\t\tlabel: __( 'Add template' ),\n\t\t\t\t\t\t\t\t\tonClick: () => setIsCreateModalOpen( true ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: []\n\t\t\t\t}\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t{ ! allowSwitchingTemplate ? (\n\t\t\t\t<Notice status=\"warning\" isDismissible={ false }>\n\t\t\t\t\t{ __( 'The posts page template cannot be changed.' ) }\n\t\t\t\t</Notice>\n\t\t\t) : (\n\t\t\t\t<SelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Template' ) }\n\t\t\t\t\tvalue={ selectedOption?.value ?? '' }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( slug ) =>\n\t\t\t\t\t\teditPost( { template: slug || '' } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canEdit && onNavigateToEntityRecord && (\n\t\t\t\t<p>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\tpostId: currentTemplateId,\n\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => setIsCreateModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction ClassicThemeControl() {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<PostTemplateToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<PostTemplateDropdownContent onClose={ onClose } />\n\t\t\t) }\n\t\t/>\n\t);\n}\n\n/**\n * Provides a dropdown menu for selecting and managing post templates.\n *\n * The dropdown menu includes a button for toggling the menu, a list of available templates, and options for creating and editing templates.\n *\n * @return {JSX.Element} The rendered ClassicThemeControl component.\n */\nexport default ClassicThemeControl;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,aAAa,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,MAAM,QAAQ,uBAAuB;AAC/E,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,oCAAoC,IAAIC,sBAAsB,QAAQ,yBAAyB;AACxG,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAASN,KAAK,IAAIO,YAAY,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA,SAASP,KAAK,IAAIQ,WAAW,QAAQ,aAAa;AAClD,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,SAASC,0BAA0B,QAAQ,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAErD,MAAMC,aAAa,GAAG;EACrBC,SAAS,EAAE,gCAAgC;EAC3CC,SAAS,EAAE;AACZ,CAAC;AAED,SAASC,kBAAkBA,CAAE;EAAEC,MAAM;EAAEC;AAAQ,CAAC,EAAG;EAClD,MAAMC,aAAa,GAAGvB,SAAS,CAAIwB,MAAM,IAAM;IAC9C,MAAMC,YAAY,GACjBD,MAAM,CAAEd,WAAY,CAAC,CAACgB,sBAAsB,CAAE,UAAW,CAAC;IAE3D,MAAM;MAAEC,oBAAoB;MAAEC;IAAmB,CAAC,GACjDJ,MAAM,CAAEd,WAAY,CAAC,CAACmB,iBAAiB,CAAC,CAAC;IAC1C,IAAK,CAAEF,oBAAoB,IAAIC,kBAAkB,CAAEH,YAAY,CAAE,EAAG;MACnE,OAAOG,kBAAkB,CAAE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M,EAAGA,MAAQ;MAACC,OAAO,EAAGoE;IAAU,CAAE,CAC1D;IACHC,aAAa,EAAGA,CAAE;MAAElD;IAAQ,CAAC,kBAC5B3B,IAAA,CAAC0B,2BAA2B;MAACC,OAAO,EAAGA;IAAS,CAAE;EAChD,CACH,CAAC;AAEJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe6C,mBAAmB","ignoreList":[]}
@@ -87,6 +87,7 @@ export default function CreateNewTemplateModal({
87
87
  children: /*#__PURE__*/_jsxs(VStack, {
88
88
  spacing: "3",
89
89
  children: [/*#__PURE__*/_jsx(TextControl, {
90
+ __next40pxDefaultSize: true,
90
91
  __nextHasNoMarginBottom: true,
91
92
  label: __('Name'),
92
93
  value: title,
@@ -97,10 +98,12 @@ export default function CreateNewTemplateModal({
97
98
  }), /*#__PURE__*/_jsxs(HStack, {
98
99
  justify: "right",
99
100
  children: [/*#__PURE__*/_jsx(Button, {
101
+ __next40pxDefaultSize: true,
100
102
  variant: "tertiary",
101
103
  onClick: cancel,
102
104
  children: __('Cancel')
103
105
  }), /*#__PURE__*/_jsx(Button, {
106
+ __next40pxDefaultSize: true,
104
107
  variant: "primary",
105
108
  type: "submit",
106
109
  isBusy: isBusy,
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useDispatch","useState","serialize","createBlock","Modal","TextControl","Button","__experimentalHStack","HStack","__experimentalVStack","VStack","__","cleanForSlug","unlock","store","editorStore","jsx","_jsx","jsxs","_jsxs","DEFAULT_TITLE","CreateNewTemplateModal","onClose","defaultBlockTemplate","onNavigateToEntityRecord","select","getEditorSettings","getCurrentTemplateId","getTemplateId","createTemplate","title","setTitle","isBusy","setIsBusy","cancel","submit","event","preventDefault","newTemplateContent","tagName","layout","inherit","newTemplate","slug","content","postId","id","postType","onRequestClose","focusOnMount","size","children","className","onSubmit","spacing","__nextHasNoMarginBottom","label","value","onChange","placeholder","disabled","help","justify","variant","onClick","type"],"sources":["@wordpress/editor/src/components/post-template/create-new-template-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { serialize, createBlock } from '@wordpress/blocks';\nimport {\n\tModal,\n\tTextControl,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cleanForSlug } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst DEFAULT_TITLE = __( 'Custom Template' );\n\nexport default function CreateNewTemplateModal( { onClose } ) {\n\tconst { defaultBlockTemplate, onNavigateToEntityRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditorSettings, getCurrentTemplateId } =\n\t\t\t\tselect( editorStore );\n\t\t\treturn {\n\t\t\t\tdefaultBlockTemplate: getEditorSettings().defaultBlockTemplate,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetEditorSettings().onNavigateToEntityRecord,\n\t\t\t\tgetTemplateId: getCurrentTemplateId,\n\t\t\t};\n\t\t}\n\t);\n\n\tconst { createTemplate } = unlock( useDispatch( editorStore ) );\n\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\tconst cancel = () => {\n\t\tsetTitle( '' );\n\t\tonClose();\n\t};\n\n\tconst submit = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsBusy( true );\n\n\t\tconst newTemplateContent =\n\t\t\tdefaultBlockTemplate ??\n\t\t\tserialize( [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'header',\n\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock( 'core/site-title' ),\n\t\t\t\t\t\tcreateBlock( 'core/site-tagline' ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t\tcreateBlock( 'core/separator' ),\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'main',\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t'core/group',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t[ createBlock( 'core/post-title' ) ]\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcreateBlock( 'core/post-content', {\n\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t} ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t] );\n\n\t\tconst newTemplate = await createTemplate( {\n\t\t\tslug: cleanForSlug( title || DEFAULT_TITLE ),\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || DEFAULT_TITLE,\n\t\t} );\n\n\t\tsetIsBusy( false );\n\t\tonNavigateToEntityRecord( {\n\t\t\tpostId: newTemplate.id,\n\t\t\tpostType: 'wp_template',\n\t\t} );\n\t\tcancel();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create custom template' ) }\n\t\t\tonRequestClose={ cancel }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"small\"\n\t\t>\n\t\t\t<form\n\t\t\t\tclassName=\"editor-post-template__create-form\"\n\t\t\t\tonSubmit={ submit }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ DEFAULT_TITLE }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Describe the template, e.g. \"Post with sidebar\". A custom template can be manually applied to any post or page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ cancel }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\t\taria-disabled={ isBusy }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,EAAEC,WAAW,QAAQ,mBAAmB;AAC1D,SACCC,KAAK,EACLC,WAAW,EACXC,MAAM,EACNC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,QAAQ,gBAAgB;;AAE7C;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEnD,MAAMC,aAAa,GAAGT,EAAE,CAAE,iBAAkB,CAAC;AAE7C,eAAe,SAASU,sBAAsBA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EAC7D,MAAM;IAAEC,oBAAoB;IAAEC;EAAyB,CAAC,GAAGzB,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MAAM;YAACyD,OAAO,EAAC,UAAU;YAACC,OAAO,EAAG9B,MAAQ;YAAAiB,QAAA,EAC1CxC,EAAE,CAAE,QAAS;UAAC,CACT,CAAC,eAETM,IAAA,CAACX,MAAM;YACNyD,OAAO,EAAC,SAAS;YACjBE,IAAI,EAAC,QAAQ;YACbjC,MAAM,EAAGA,MAAQ;YACjB,iBAAgBA,MAAQ;YAAAmB,QAAA,EAEtBxC,EAAE,CAAE,QAAS;UAAC,CACT,CAAC;QAAA,CACF,CAAC;MAAA,CACF;IAAC,CACJ;EAAC,CACD,CAAC;AAEV","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","useDispatch","useState","serialize","createBlock","Modal","TextControl","Button","__experimentalHStack","HStack","__experimentalVStack","VStack","__","cleanForSlug","unlock","store","editorStore","jsx","_jsx","jsxs","_jsxs","DEFAULT_TITLE","CreateNewTemplateModal","onClose","defaultBlockTemplate","onNavigateToEntityRecord","select","getEditorSettings","getCurrentTemplateId","getTemplateId","createTemplate","title","setTitle","isBusy","setIsBusy","cancel","submit","event","preventDefault","newTemplateContent","tagName","layout","inherit","newTemplate","slug","content","postId","id","postType","onRequestClose","focusOnMount","size","children","className","onSubmit","spacing","__next40pxDefaultSize","__nextHasNoMarginBottom","label","value","onChange","placeholder","disabled","help","justify","variant","onClick","type"],"sources":["@wordpress/editor/src/components/post-template/create-new-template-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { serialize, createBlock } from '@wordpress/blocks';\nimport {\n\tModal,\n\tTextControl,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cleanForSlug } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst DEFAULT_TITLE = __( 'Custom Template' );\n\nexport default function CreateNewTemplateModal( { onClose } ) {\n\tconst { defaultBlockTemplate, onNavigateToEntityRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditorSettings, getCurrentTemplateId } =\n\t\t\t\tselect( editorStore );\n\t\t\treturn {\n\t\t\t\tdefaultBlockTemplate: getEditorSettings().defaultBlockTemplate,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetEditorSettings().onNavigateToEntityRecord,\n\t\t\t\tgetTemplateId: getCurrentTemplateId,\n\t\t\t};\n\t\t}\n\t);\n\n\tconst { createTemplate } = unlock( useDispatch( editorStore ) );\n\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\tconst cancel = () => {\n\t\tsetTitle( '' );\n\t\tonClose();\n\t};\n\n\tconst submit = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsBusy( true );\n\n\t\tconst newTemplateContent =\n\t\t\tdefaultBlockTemplate ??\n\t\t\tserialize( [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'header',\n\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock( 'core/site-title' ),\n\t\t\t\t\t\tcreateBlock( 'core/site-tagline' ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t\tcreateBlock( 'core/separator' ),\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'main',\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t'core/group',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t[ createBlock( 'core/post-title' ) ]\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcreateBlock( 'core/post-content', {\n\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t} ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t] );\n\n\t\tconst newTemplate = await createTemplate( {\n\t\t\tslug: cleanForSlug( title || DEFAULT_TITLE ),\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || DEFAULT_TITLE,\n\t\t} );\n\n\t\tsetIsBusy( false );\n\t\tonNavigateToEntityRecord( {\n\t\t\tpostId: newTemplate.id,\n\t\t\tpostType: 'wp_template',\n\t\t} );\n\t\tcancel();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create custom template' ) }\n\t\t\tonRequestClose={ cancel }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"small\"\n\t\t>\n\t\t\t<form\n\t\t\t\tclassName=\"editor-post-template__create-form\"\n\t\t\t\tonSubmit={ submit }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ DEFAULT_TITLE }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Describe the template, e.g. \"Post with sidebar\". A custom template can be manually applied to any post or page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ cancel }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t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QAAQ;YACblC,MAAM,EAAGA,MAAQ;YACjB,iBAAgBA,MAAQ;YAAAmB,QAAA,EAEtBxC,EAAE,CAAE,QAAS;UAAC,CACT,CAAC;QAAA,CACF,CAAC;MAAA,CACF;IAAC,CACJ;EAAC,CACD,CAAC;AAEV","ignoreList":[]}
@@ -25,7 +25,10 @@ export default function CreateNewTemplate({
25
25
  canUser
26
26
  } = select(coreStore);
27
27
  return {
28
- canCreateTemplates: canUser('create', 'templates')
28
+ canCreateTemplates: canUser('create', {
29
+ kind: 'postType',
30
+ name: 'wp_template'
31
+ })
29
32
  };
30
33
  }, []);
31
34
  const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
@@ -1 +1 @@
1
- {"version":3,"names":["MenuItem","__","useSelect","store","coreStore","useState","CreateNewTemplateModal","useAllowSwitchingTemplates","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","CreateNewTemplate","onClick","canCreateTemplates","select","canUser","isCreateModalOpen","setIsCreateModalOpen","allowSwitchingTemplate","children","onClose"],"sources":["@wordpress/editor/src/components/post-template/create-new-template.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nexport default function CreateNewTemplate( { onClick } ) {\n\tconst { canCreateTemplates } = useSelect( ( select ) => {\n\t\tconst { canUser } = select( coreStore );\n\t\treturn {\n\t\t\tcanCreateTemplates: canUser( 'create', 'templates' ),\n\t\t};\n\t}, [] );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\n\t// The default template in a post is indicated by an empty string.\n\tif ( ! canCreateTemplates || ! allowSwitchingTemplate ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsCreateModalOpen( true );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Create new template' ) }\n\t\t\t</MenuItem>\n\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsCreateModalOpen( false );\n\t\t\t\t\t\tonClick();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,SAASC,0BAA0B,QAAQ,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAErD,eAAe,SAASC,iBAAiBA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EACxD,MAAM;IAAEC;EAAmB,CAAC,GAAGd,SAAS,CAAIe,MAAM,IAAM;IACvD,MAAM;MAAEC;IAAQ,CAAC,GAAGD,MAAM,CAAEb,SAAU,CAAC;IACvC,OAAO;MACNY,kBAAkB,EAAEE,OAAO,CAAE,QAAQ,EAAE,WAAY;IACpD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,MAAM,CAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,GAAGf,QAAQ,CAAE,KAAM,CAAC;EACrE,MAAMgB,sBAAsB,GAAGd,0BAA0B,CAAC,CAAC;;EAE3D;EACA,IAAK,CAAES,kBAAkB,IAAI,CAAEK,sBAAsB,EAAG;IACvD,OAAO,IAAI;EACZ;EACA,oBACCR,KAAA,CAAAF,SAAA;IAAAW,QAAA,gBACCb,IAAA,CAACT,QAAQ;MACRe,OAAO,EAAGA,CAAA,KAAM;QACfK,oBAAoB,CAAE,IAAK,CAAC;MAC7B,CAAG;MAAAE,QAAA,EAEDrB,EAAE,CAAE,qBAAsB;IAAC,CACpB,CAAC,EAETkB,iBAAiB,iBAClBV,IAAA,CAACH,sBAAsB;MACtBiB,OAAO,EAAGA,CAAA,KAAM;QACfH,oBAAoB,CAAE,KAAM,CAAC;QAC7BL,OAAO,CAAC,CAAC;MACV;IAAG,CACH,CACD;EAAA,CACA,CAAC;AAEL","ignoreList":[]}
1
+ {"version":3,"names":["MenuItem","__","useSelect","store","coreStore","useState","CreateNewTemplateModal","useAllowSwitchingTemplates","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","CreateNewTemplate","onClick","canCreateTemplates","select","canUser","kind","name","isCreateModalOpen","setIsCreateModalOpen","allowSwitchingTemplate","children","onClose"],"sources":["@wordpress/editor/src/components/post-template/create-new-template.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nexport default function CreateNewTemplate( { onClick } ) {\n\tconst { canCreateTemplates } = useSelect( ( select ) => {\n\t\tconst { canUser } = select( coreStore );\n\t\treturn {\n\t\t\tcanCreateTemplates: canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t};\n\t}, [] );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\n\t// The default template in a post is indicated by an empty string.\n\tif ( ! canCreateTemplates || ! allowSwitchingTemplate ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsCreateModalOpen( true );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Create new template' ) }\n\t\t\t</MenuItem>\n\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsCreateModalOpen( false );\n\t\t\t\t\t\tonClick();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,SAASC,0BAA0B,QAAQ,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAErD,eAAe,SAASC,iBAAiBA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EACxD,MAAM;IAAEC;EAAmB,CAAC,GAAGd,SAAS,CAAIe,MAAM,IAAM;IACvD,MAAM;MAAEC;IAAQ,CAAC,GAAGD,MAAM,CAAEb,SAAU,CAAC;IACvC,OAAO;MACNY,kBAAkB,EAAEE,OAAO,CAAE,QAAQ,EAAE;QACtCC,IAAI,EAAE,UAAU;QAChBC,IAAI,EAAE;MACP,CAAE;IACH,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,MAAM,CAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,GAAGjB,QAAQ,CAAE,KAAM,CAAC;EACrE,MAAMkB,sBAAsB,GAAGhB,0BAA0B,CAAC,CAAC;;EAE3D;EACA,IAAK,CAAES,kBAAkB,IAAI,CAAEO,sBAAsB,EAAG;IACvD,OAAO,IAAI;EACZ;EACA,oBACCV,KAAA,CAAAF,SAAA;IAAAa,QAAA,gBACCf,IAAA,CAACT,QAAQ;MACRe,OAAO,EAAGA,CAAA,KAAM;QACfO,oBAAoB,CAAE,IAAK,CAAC;MAC7B,CAAG;MAAAE,QAAA,EAEDvB,EAAE,CAAE,qBAAsB;IAAC,CACpB,CAAC,EAEToB,iBAAiB,iBAClBZ,IAAA,CAACH,sBAAsB;MACtBmB,OAAO,EAAGA,CAAA,KAAM;QACfH,oBAAoB,CAAE,KAAM,CAAC;QAC7BP,OAAO,CAAC,CAAC;MACV;IAAG,CACH,CACD;EAAA,CACA,CAAC;AAEL","ignoreList":[]}
@@ -28,10 +28,14 @@ export function useAllowSwitchingTemplates() {
28
28
  } = useEditedPostContext();
29
29
  return useSelect(select => {
30
30
  const {
31
+ canUser,
31
32
  getEntityRecord,
32
33
  getEntityRecords
33
34
  } = select(coreStore);
34
- const siteSettings = getEntityRecord('root', 'site');
35
+ const siteSettings = canUser('read', {
36
+ kind: 'root',
37
+ name: 'site'
38
+ }) ? getEntityRecord('root', 'site') : undefined;
35
39
  const templates = getEntityRecords('postType', 'wp_template', {
36
40
  per_page: -1
37
41
  });
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useMemo","store","coreStore","editorStore","useEditedPostContext","select","getCurrentPostId","getCurrentPostType","postId","postType","useAllowSwitchingTemplates","getEntityRecord","getEntityRecords","siteSettings","templates","per_page","isPostsPage","page_for_posts","isFrontPage","page_on_front","some","slug","useTemplates","post_type","useAvailableTemplates","currentTemplateSlug","useCurrentTemplateSlug","allowSwitchingTemplate","filter","template","is_custom","content","raw","entityTemplate","post","getEditedEntityRecord","find"],"sources":["@wordpress/editor/src/components/post-template/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function useEditedPostContext() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n}\nexport function useAllowSwitchingTemplates() {\n\tconst { postType, postId } = useEditedPostContext();\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getEntityRecords } = select( coreStore );\n\t\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\t\tconst templates = getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t} );\n\t\t\tconst isPostsPage = +postId === siteSettings?.page_for_posts;\n\t\t\t// If current page is set front page or posts page, we also need\n\t\t\t// to check if the current theme has a template for it. If not\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' &&\n\t\t\t\t+postId === siteSettings?.page_on_front &&\n\t\t\t\ttemplates?.some( ( { slug } ) => slug === 'front-page' );\n\t\t\treturn ! isPostsPage && ! isFrontPage;\n\t\t},\n\t\t[ postId, postType ]\n\t);\n}\n\nfunction useTemplates( postType ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t\tpost_type: postType,\n\t\t\t} ),\n\t\t[ postType ]\n\t);\n}\n\nexport function useAvailableTemplates( postType ) {\n\tconst currentTemplateSlug = useCurrentTemplateSlug();\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst templates = useTemplates( postType );\n\treturn useMemo(\n\t\t() =>\n\t\t\tallowSwitchingTemplate &&\n\t\t\ttemplates?.filter(\n\t\t\t\t( template ) =>\n\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\ttemplate.slug !== currentTemplateSlug &&\n\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t),\n\t\t[ templates, currentTemplateSlug, allowSwitchingTemplate ]\n\t);\n}\n\nexport function useCurrentTemplateSlug() {\n\tconst { postType, postId } = useEditedPostContext();\n\tconst templates = useTemplates( postType );\n\tconst entityTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\treturn post?.template;\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tif ( ! entityTemplate ) {\n\t\treturn;\n\t}\n\t// If a page has a `template` set and is not included in the list\n\t// of the theme's templates, do not return it, in order to resolve\n\t// to the current theme's default template.\n\treturn templates?.find( ( template ) => template.slug === entityTemplate )\n\t\t?.slug;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAElD,OAAO,SAASC,oBAAoBA,CAAA,EAAG;EACtC,OAAOL,SAAS,CAAIM,MAAM,IAAM;IAC/B,MAAM;MAAEC,gBAAgB;MAAEC;IAAmB,CAAC,GAAGF,MAAM,CAAEF,WAAY,CAAC;IACtE,OAAO;MACNK,MAAM,EAAEF,gBAAgB,CAAC,CAAC;MAC1BG,QAAQ,EAAEF,kBAAkB,CAAC;IAC9B,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR;AACA,OAAO,SAASG,0BAA0BA,CAAA,EAAG;EAC5C,MAAM;IAAED,QAAQ;IAAED;EAAO,CAAC,GAAGJ,oBAAoB,CAAC,CAAC;EACnD,OAAOL,SAAS,CACbM,MAAM,IAAM;IACb,MAAM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AACE,OAAO,CAACC,GAAG,CAAC;EAC1B,CAAC,EACF,CAAElB,SAAS,EAAEW,mBAAmB,EAAEE,sBAAsB,CACzD,CAAC;AACF;AAEA,OAAO,SAASD,sBAAsBA,CAAA,EAAG;EACxC,MAAM;IAAEjB,QAAQ;IAAED;EAAO,CAAC,GAAGJ,oBAAoB,CAAC,CAAC;EACnD,MAAMU,SAAS,GAAGQ,YAAY,CAAEb,QAAS,CAAC;EAC1C,MAAMwB,cAAc,GAAGlC,SAAS,CAC7BM,MAAM,IAAM;IACb,MAAM6B,IAAI,GAAG7B,MAAM,CAAEH,SAAU,CAAC,CAACiC,qBAAqB,CACrD,UAAU,EACV1B,QAAQ,EACRD,MACD,CAAC;IACD,OAAO0B,IAAI,EAAEL,QAAQ;EACtB,CAAC,EACD,CAAEpB,QAAQ,EAAED,MAAM,CACnB,CAAC;EAED,IAAK,CAAEyB,cAAc,EAAG;IACvB;EACD;EACA;EACA;EACA;EACA,OAAOnB,SAAS,EAAEsB,IAAI,CAAIP,QAAQ,IAAMA,QAAQ,CAACR,IAAI,KAAKY,cAAe,CAAC,EACvEZ,IAAI;AACR","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","useMemo","store","coreStore","editorStore","useEditedPostContext","select","getCurrentPostId","getCurrentPostType","postId","postType","useAllowSwitchingTemplates","canUser","getEntityRecord","getEntityRecords","siteSettings","kind","name","undefined","templates","per_page","isPostsPage","page_for_posts","isFrontPage","page_on_front","some","slug","useTemplates","post_type","useAvailableTemplates","currentTemplateSlug","useCurrentTemplateSlug","allowSwitchingTemplate","filter","template","is_custom","content","raw","entityTemplate","post","getEditedEntityRecord","find"],"sources":["@wordpress/editor/src/components/post-template/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function useEditedPostContext() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n}\nexport function useAllowSwitchingTemplates() {\n\tconst { postType, postId } = useEditedPostContext();\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecord, getEntityRecords } =\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 templates = getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t} );\n\t\t\tconst isPostsPage = +postId === siteSettings?.page_for_posts;\n\t\t\t// If current page is set front page or posts page, we also need\n\t\t\t// to check if the current theme has a template for it. If not\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' &&\n\t\t\t\t+postId === siteSettings?.page_on_front &&\n\t\t\t\ttemplates?.some( ( { slug } ) => slug === 'front-page' );\n\t\t\treturn ! isPostsPage && ! isFrontPage;\n\t\t},\n\t\t[ postId, postType ]\n\t);\n}\n\nfunction useTemplates( postType ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t\tpost_type: postType,\n\t\t\t} ),\n\t\t[ postType ]\n\t);\n}\n\nexport function useAvailableTemplates( postType ) {\n\tconst currentTemplateSlug = useCurrentTemplateSlug();\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst templates = useTemplates( postType );\n\treturn useMemo(\n\t\t() =>\n\t\t\tallowSwitchingTemplate &&\n\t\t\ttemplates?.filter(\n\t\t\t\t( template ) =>\n\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\ttemplate.slug !== currentTemplateSlug &&\n\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t),\n\t\t[ templates, currentTemplateSlug, allowSwitchingTemplate ]\n\t);\n}\n\nexport function useCurrentTemplateSlug() {\n\tconst { postType, postId } = useEditedPostContext();\n\tconst templates = useTemplates( postType );\n\tconst entityTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\treturn post?.template;\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tif ( ! entityTemplate ) {\n\t\treturn;\n\t}\n\t// If a page has a `template` set and is not included in the list\n\t// of the theme's templates, do not return it, in order to resolve\n\t// to the current theme's default template.\n\treturn templates?.find( ( template ) => template.slug === entityTemplate )\n\t\t?.slug;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAElD,OAAO,SAASC,oBAAoBA,CAAA,EAAG;EACtC,OAAOL,SAAS,CAAIM,MAAM,IAAM;IAC/B,MAAM;MAAEC,gBAAgB;MAAEC;IAAmB,CAAC,GAAGF,MAAM,CAAEF,WAAY,CAAC;IACtE,OAAO;MACNK,MAAM,EAAEF,gBAAgB,CAAC,CAAC;MAC1BG,QAAQ,EAAEF,kBAAkB,CAAC;IAC9B,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR;AACA,OAAO,SAASG,0BAA0BA,CAAA,EAAG;EAC5C,MAAM;IAAED,QAAQ;IAAED;EAAO,CAAC,GAAGJ,oBAAoB,CAAC,CAAC;EACnD,OAAOL,SAAS,CACbM,MAAM,IAAM;IACb,MAAM;MAAEM,OAAO;MAAEC,eAAe;MAAEC;IAAiB,CAAC,GAC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AAS,IAClBD,QAAQ,CAACR,IAAI,KAAKI,mBAAmB,IACrC,CAAC,CAAEI,QAAQ,CAACE,OAAO,CAACC,GAAG,CAAC;EAC1B,CAAC,EACF,CAAElB,SAAS,EAAEW,mBAAmB,EAAEE,sBAAsB,CACzD,CAAC;AACF;AAEA,OAAO,SAASD,sBAAsBA,CAAA,EAAG;EACxC,MAAM;IAAErB,QAAQ;IAAED;EAAO,CAAC,GAAGJ,oBAAoB,CAAC,CAAC;EACnD,MAAMc,SAAS,GAAGQ,YAAY,CAAEjB,QAAS,CAAC;EAC1C,MAAM4B,cAAc,GAAGtC,SAAS,CAC7BM,MAAM,IAAM;IACb,MAAMiC,IAAI,GAAGjC,MAAM,CAAEH,SAAU,CAAC,CAACqC,qBAAqB,CACrD,UAAU,EACV9B,QAAQ,EACRD,MACD,CAAC;IACD,OAAO8B,IAAI,EAAEL,QAAQ;EACtB,CAAC,EACD,CAAExB,QAAQ,EAAED,MAAM,CACnB,CAAC;EAED,IAAK,CAAE6B,cAAc,EAAG;IACvB;EACD;EACA;EACA;EACA;EACA,OAAOnB,SAAS,EAAEsB,IAAI,CAAIP,QAAQ,IAAMA,QAAQ,CAACR,IAAI,KAAKY,cAAe,CAAC,EACvEZ,IAAI;AACR","ignoreList":[]}
@@ -48,12 +48,18 @@ export default function PostTemplatePanel() {
48
48
  if (!settings.supportsTemplateMode) {
49
49
  return false;
50
50
  }
51
- const canCreateTemplates = (_select$canUser = select(coreStore).canUser('create', 'templates')) !== null && _select$canUser !== void 0 ? _select$canUser : false;
51
+ const canCreateTemplates = (_select$canUser = select(coreStore).canUser('create', {
52
+ kind: 'postType',
53
+ name: 'wp_template'
54
+ })) !== null && _select$canUser !== void 0 ? _select$canUser : false;
52
55
  return canCreateTemplates;
53
56
  }, []);
54
57
  const canViewTemplates = useSelect(select => {
55
58
  var _select$canUser2;
56
- return (_select$canUser2 = select(coreStore).canUser('read', 'templates')) !== null && _select$canUser2 !== void 0 ? _select$canUser2 : false;
59
+ return (_select$canUser2 = select(coreStore).canUser('read', {
60
+ kind: 'postType',
61
+ name: 'wp_template'
62
+ })) !== null && _select$canUser2 !== void 0 ? _select$canUser2 : false;
57
63
  }, []);
58
64
  if ((!isBlockTheme || !canViewTemplates) && isVisible) {
59
65
  return /*#__PURE__*/_jsx(PostPanelRow, {
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","__","store","coreStore","editorStore","ClassicThemeControl","BlockThemeControl","PostPanelRow","jsx","_jsx","PostTemplatePanel","templateId","isBlockTheme","select","getCurrentTemplateId","getEditorSettings","__unstableIsBlockBasedTheme","isVisible","_select$canUser","postTypeSlug","getCurrentPostType","postType","getPostType","viewable","settings","hasTemplates","availableTemplates","Object","keys","length","supportsTemplateMode","canCreateTemplates","canUser","canViewTemplates","_select$canUser2","label","children","id"],"sources":["@wordpress/editor/src/components/post-template/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport ClassicThemeControl from './classic-theme';\nimport BlockThemeControl from './block-theme';\nimport PostPanelRow from '../post-panel-row';\n\n/**\n * Displays the template controls based on the current editor settings and user permissions.\n *\n * @return {JSX.Element|null} The rendered PostTemplatePanel component.\n */\nexport default function PostTemplatePanel() {\n\tconst { templateId, isBlockTheme } = useSelect( ( select ) => {\n\t\tconst { getCurrentTemplateId, getEditorSettings } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\ttemplateId: getCurrentTemplateId(),\n\t\t\tisBlockTheme: getEditorSettings().__unstableIsBlockBasedTheme,\n\t\t};\n\t}, [] );\n\n\tconst isVisible = useSelect( ( select ) => {\n\t\tconst postTypeSlug = select( editorStore ).getCurrentPostType();\n\t\tconst postType = select( coreStore ).getPostType( postTypeSlug );\n\t\tif ( ! postType?.viewable ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst settings = select( editorStore ).getEditorSettings();\n\t\tconst hasTemplates =\n\t\t\t!! settings.availableTemplates &&\n\t\t\tObject.keys( settings.availableTemplates ).length > 0;\n\t\tif ( hasTemplates ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( ! settings.supportsTemplateMode ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst canCreateTemplates =\n\t\t\tselect( coreStore ).canUser( 'create', 'templates' ) ?? false;\n\t\treturn canCreateTemplates;\n\t}, [] );\n\n\tconst canViewTemplates = useSelect( ( select ) => {\n\t\treturn select( coreStore ).canUser( 'read', 'templates' ) ?? false;\n\t}, [] );\n\n\tif ( ( ! isBlockTheme || ! canViewTemplates ) && isVisible ) {\n\t\treturn (\n\t\t\t<PostPanelRow label={ __( 'Template' ) }>\n\t\t\t\t<ClassicThemeControl />\n\t\t\t</PostPanelRow>\n\t\t);\n\t}\n\n\tif ( isBlockTheme && !! templateId ) {\n\t\treturn (\n\t\t\t<PostPanelRow label={ __( 'Template' ) }>\n\t\t\t\t<BlockThemeControl id={ templateId } />\n\t\t\t</PostPanelRow>\n\t\t);\n\t}\n\treturn null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAClD,OAAOC,mBAAmB,MAAM,iBAAiB;AACjD,OAAOC,iBAAiB,MAAM,eAAe;AAC7C,OAAOC,YAAY,MAAM,mBAAmB;;AAE5C;AACA;AACA;AACA;AACA;AAJA,SAAAC,GAAA,IAAAC,IAAA;AAKA,eAAe,SAASC,iBAAiBA,CAAA,EAAG;EAC3C,MAAM;IAAEC,UAAU;IAAEC;EAAa,CAAC,GAAGZ,SAAS,CAAIa,MAAM,IAAM;IAC7D,MAAM;MAAEC,oBAAoB;MAAEC;IAAkB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,gBAAA,GAAI,KAAK;EACnE,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAE,CAAEtB,YAAY,IAAI,CAAEqB,gBAAgB,KAAMhB,SAAS,EAAG;IAC5D,oBACCR,IAAA,CAACF,YAAY;MAAC4B,KAAK,EAAGlC,EAAE,CAAE,UAAW,CAAG;MAAAmC,QAAA,eACvC3B,IAAA,CAACJ,mBAAmB,IAAE;IAAC,CACV,CAAC;EAEjB;EAEA,IAAKO,YAAY,IAAI,CAAC,CAAED,UAAU,EAAG;IACpC,oBACCF,IAAA,CAACF,YAAY;MAAC4B,KAAK,EAAGlC,EAAE,CAAE,UAAW,CAAG;MAAAmC,QAAA,eACvC3B,IAAA,CAACH,iBAAiB;QAAC+B,EAAE,EAAG1B;MAAY,CAAE;IAAC,CAC1B,CAAC;EAEjB;EACA,OAAO,IAAI;AACZ","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","__","store","coreStore","editorStore","ClassicThemeControl","BlockThemeControl","PostPanelRow","jsx","_jsx","PostTemplatePanel","templateId","isBlockTheme","select","getCurrentTemplateId","getEditorSettings","__unstableIsBlockBasedTheme","isVisible","_select$canUser","postTypeSlug","getCurrentPostType","postType","getPostType","viewable","settings","hasTemplates","availableTemplates","Object","keys","length","supportsTemplateMode","canCreateTemplates","canUser","kind","name","canViewTemplates","_select$canUser2","label","children","id"],"sources":["@wordpress/editor/src/components/post-template/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport ClassicThemeControl from './classic-theme';\nimport BlockThemeControl from './block-theme';\nimport PostPanelRow from '../post-panel-row';\n\n/**\n * Displays the template controls based on the current editor settings and user permissions.\n *\n * @return {JSX.Element|null} The rendered PostTemplatePanel component.\n */\nexport default function PostTemplatePanel() {\n\tconst { templateId, isBlockTheme } = useSelect( ( select ) => {\n\t\tconst { getCurrentTemplateId, getEditorSettings } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\ttemplateId: getCurrentTemplateId(),\n\t\t\tisBlockTheme: getEditorSettings().__unstableIsBlockBasedTheme,\n\t\t};\n\t}, [] );\n\n\tconst isVisible = useSelect( ( select ) => {\n\t\tconst postTypeSlug = select( editorStore ).getCurrentPostType();\n\t\tconst postType = select( coreStore ).getPostType( postTypeSlug );\n\t\tif ( ! postType?.viewable ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst settings = select( editorStore ).getEditorSettings();\n\t\tconst hasTemplates =\n\t\t\t!! settings.availableTemplates &&\n\t\t\tObject.keys( settings.availableTemplates ).length > 0;\n\t\tif ( hasTemplates ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( ! settings.supportsTemplateMode ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst canCreateTemplates =\n\t\t\tselect( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ) ?? false;\n\t\treturn canCreateTemplates;\n\t}, [] );\n\n\tconst canViewTemplates = useSelect( ( select ) => {\n\t\treturn (\n\t\t\tselect( coreStore ).canUser( 'read', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ) ?? false\n\t\t);\n\t}, [] );\n\n\tif ( ( ! isBlockTheme || ! canViewTemplates ) && isVisible ) {\n\t\treturn (\n\t\t\t<PostPanelRow label={ __( 'Template' ) }>\n\t\t\t\t<ClassicThemeControl />\n\t\t\t</PostPanelRow>\n\t\t);\n\t}\n\n\tif ( isBlockTheme && !! templateId ) {\n\t\treturn (\n\t\t\t<PostPanelRow label={ __( 'Template' ) }>\n\t\t\t\t<BlockThemeControl id={ templateId } />\n\t\t\t</PostPanelRow>\n\t\t);\n\t}\n\treturn null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SA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K,CAAED,QAAQ,CAACM,oBAAoB,EAAG;MACtC,OAAO,KAAK;IACb;IAEA,MAAMC,kBAAkB,IAAAb,eAAA,GACvBL,MAAM,CAAEV,SAAU,CAAC,CAAC6B,OAAO,CAAE,QAAQ,EAAE;MACtCC,IAAI,EAAE,UAAU;MAChBC,IAAI,EAAE;IACP,CAAE,CAAC,cAAAhB,eAAA,cAAAA,eAAA,GAAI,KAAK;IACb,OAAOa,kBAAkB;EAC1B,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMI,gBAAgB,GAAGnC,SAAS,CAAIa,MAAM,IAAM;IAAA,IAAAuB,gBAAA;IACjD,QAAAA,gBAAA,GACCvB,MAAM,CAAEV,SAAU,CAAC,CAAC6B,OAAO,CAAE,MAAM,EAAE;MACpCC,IAAI,EAAE,UAAU;MAChBC,IAAI,EAAE;IACP,CAAE,CAAC,cAAAE,gBAAA,cAAAA,gBAAA,GAAI,KAAK;EAEd,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAE,CAAExB,YAAY,IAAI,CAAEuB,gBAAgB,KAAMlB,SAAS,EAAG;IAC5D,oBACCR,IAAA,CAACF,YAAY;MAAC8B,KAAK,EAAGpC,EAAE,CAAE,UAAW,CAAG;MAAAqC,QAAA,eACvC7B,IAAA,CAACJ,mBAAmB,IAAE;IAAC,CACV,CAAC;EAEjB;EAEA,IAAKO,YAAY,IAAI,CAAC,CAAED,UAAU,EAAG;IACpC,oBACCF,IAAA,CAACF,YAAY;MAAC8B,KAAK,EAAGpC,EAAE,CAAE,UAAW,CAAG;MAAAqC,QAAA,eACvC7B,IAAA,CAACH,iBAAiB;QAACiC,EAAE,EAAG5B;MAAY,CAAE;IAAC,CAC1B,CAAC;EAEjB;EACA,OAAO,IAAI;AACZ","ignoreList":[]}
@@ -29,14 +29,16 @@ export default function PostTrashCheck({
29
29
  getCurrentPostType
30
30
  } = select(editorStore);
31
31
  const {
32
- getPostType,
33
32
  canUser
34
33
  } = select(coreStore);
35
- const postType = getPostType(getCurrentPostType());
34
+ const postType = getCurrentPostType();
36
35
  const postId = getCurrentPostId();
37
36
  const isNew = isEditedPostNew();
38
- const resource = postType?.rest_base || ''; // eslint-disable-line camelcase
39
- const canUserDelete = postId && resource ? canUser('delete', resource, postId) : false;
37
+ const canUserDelete = !!postId ? canUser('delete', {
38
+ kind: 'postType',
39
+ name: postType,
40
+ id: postId
41
+ }) : false;
40
42
  return {
41
43
  canTrashPost: (!isNew || postId) && canUserDelete
42
44
  };
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","store","coreStore","editorStore","PostTrashCheck","children","canTrashPost","select","isEditedPostNew","getCurrentPostId","getCurrentPostType","getPostType","canUser","postType","postId","isNew","resource","rest_base","canUserDelete"],"sources":["@wordpress/editor/src/components/post-trash/check.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Wrapper component that renders its children only if the post can trashed.\n *\n * @param {Object} props - The component props.\n * @param {Element} props.children - The child components to render.\n *\n * @return {Component|null} The rendered child components or null if the post can not trashed.\n */\nexport default function PostTrashCheck( { children } ) {\n\tconst { canTrashPost } = useSelect( ( select ) => {\n\t\tconst { isEditedPostNew, getCurrentPostId, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst { getPostType, canUser } = select( coreStore );\n\t\tconst postType = getPostType( getCurrentPostType() );\n\t\tconst postId = getCurrentPostId();\n\t\tconst isNew = isEditedPostNew();\n\t\tconst resource = postType?.rest_base || ''; // eslint-disable-line camelcase\n\t\tconst canUserDelete =\n\t\t\tpostId && resource ? canUser( 'delete', resource, postId ) : false;\n\n\t\treturn {\n\t\t\tcanTrashPost: ( ! isNew || postId ) && canUserDelete,\n\t\t};\n\t}, [] );\n\n\tif ( ! canTrashPost ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,cAAcA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACtD,MAAM;IAAEC;EAAa,CAAC,GAAGN,SAAS,CAAIO,MAAM,IAAM;IACjD,MAAM;MAAEC,eAAe;MAAEC,gBAAgB;MAAEC;IAAmB,CAAC,GAC9DH,MAAM,CAAEJ,WAAY,CAAC;IACtB,MAAM;MAAEQ,WAAW;MAAEC;IAAQ,CAAC,GAAGL,MAAM,CAAEL,SAAU,CAAC;IACpD,MAAMW,QAAQ,GAAGF,WAAW,CAAED,kBAAkB,CAAC,CAAE,CAAC;IACpD,MAAMI,MAAM,GAAGL,gBAAgB,CAAC,CAAC;IACjC,MAAMM,KAAK,GAAGP,eAAe,CAAC,CAAC;IAC/B,MAAMQ,QAAQ,GAAGH,QAAQ,EAAEI,SAAS,IAAI,EAAE,CAAC,CAAC;IAC5C,MAAMC,aAAa,GAClBJ,MAAM,IAAIE,QAAQ,GAAGJ,OAAO,CAAE,QAAQ,EAAEI,QAAQ,EAAEF,MAAO,CAAC,GAAG,KAAK;IAEnE,OAAO;MACNR,YAAY,EAAE,CAAE,CAAES,KAAK,IAAID,MAAM,KAAMI;IACxC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAEZ,YAAY,EAAG;IACrB,OAAO,IAAI;EACZ;EAEA,OAAOD,QAAQ;AAChB","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","store","coreStore","editorStore","PostTrashCheck","children","canTrashPost","select","isEditedPostNew","getCurrentPostId","getCurrentPostType","canUser","postType","postId","isNew","canUserDelete","kind","name","id"],"sources":["@wordpress/editor/src/components/post-trash/check.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Wrapper component that renders its children only if the post can trashed.\n *\n * @param {Object} props - The component props.\n * @param {Element} props.children - The child components to render.\n *\n * @return {Component|null} The rendered child components or null if the post can not trashed.\n */\nexport default function PostTrashCheck( { children } ) {\n\tconst { canTrashPost } = useSelect( ( select ) => {\n\t\tconst { isEditedPostNew, getCurrentPostId, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst { canUser } = select( coreStore );\n\t\tconst postType = getCurrentPostType();\n\t\tconst postId = getCurrentPostId();\n\t\tconst isNew = isEditedPostNew();\n\t\tconst canUserDelete = !! postId\n\t\t\t? canUser( 'delete', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: postType,\n\t\t\t\t\tid: postId,\n\t\t\t } )\n\t\t\t: false;\n\n\t\treturn {\n\t\t\tcanTrashPost: ( ! isNew || postId ) && canUserDelete,\n\t\t};\n\t}, [] );\n\n\tif ( ! canTrashPost ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,cAAcA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACtD,MAAM;IAAEC;EAAa,CAAC,GAAGN,SAAS,CAAIO,MAAM,IAAM;IACjD,MAAM;MAAEC,eAAe;MAAEC,gBAAgB;MAAEC;IAAmB,CAAC,GAC9DH,MAAM,CAAEJ,WAAY,CAAC;IACtB,MAAM;MAAEQ;IAAQ,CAAC,GAAGJ,MAAM,CAAEL,SAAU,CAAC;IACvC,MAAMU,QAAQ,GAAGF,kBAAkB,CAAC,CAAC;IACrC,MAAMG,MAAM,GAAGJ,gBAAgB,CAAC,CAAC;IACjC,MAAMK,KAAK,GAAGN,eAAe,CAAC,CAAC;IAC/B,MAAMO,aAAa,GAAG,CAAC,CAAEF,MAAM,GAC5BF,OAAO,CAAE,QAAQ,EAAE;MACnBK,IAAI,EAAE,UAAU;MAChBC,IAAI,EAAEL,QAAQ;MACdM,EAAE,EAAEL;IACJ,CAAE,CAAC,GACH,KAAK;IAER,OAAO;MACNP,YAAY,EAAE,CAAE,CAAEQ,KAAK,IAAID,MAAM,KAAME;IACxC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAET,YAAY,EAAG;IACrB,OAAO,IAAI;EACZ;EAEA,OAAOD,QAAQ;AAChB","ignoreList":[]}
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { useMemo, useState } from '@wordpress/element';
5
5
  import { useSelect } from '@wordpress/data';
6
- import { Dropdown, Button } from '@wordpress/components';
6
+ import { Dropdown, Button, __experimentalTruncate as Truncate } from '@wordpress/components';
7
7
  import { __, sprintf } from '@wordpress/i18n';
8
8
  import { safeDecodeURIComponent } from '@wordpress/url';
9
9
  import { store as coreStore } from '@wordpress/core-data';
@@ -22,8 +22,6 @@ import { store as editorStore } from '../../store';
22
22
  * @return {JSX.Element} The rendered PostURLPanel component.
23
23
  */
24
24
  import { jsx as _jsx } from "react/jsx-runtime";
25
- import { Fragment as _Fragment } from "react/jsx-runtime";
26
- import { jsxs as _jsxs } from "react/jsx-runtime";
27
25
  export default function PostURLPanel() {
28
26
  // Use internal state instead of a ref to make sure that the component
29
27
  // re-renders when the popover's anchor updates.
@@ -76,9 +74,13 @@ function PostURLToggle({
76
74
  getCurrentPost
77
75
  } = select(editorStore);
78
76
  const {
79
- getEditedEntityRecord
77
+ getEditedEntityRecord,
78
+ canUser
80
79
  } = select(coreStore);
81
- const siteSettings = getEditedEntityRecord('root', 'site');
80
+ const siteSettings = canUser('read', {
81
+ kind: 'root',
82
+ name: 'site'
83
+ }) ? getEditedEntityRecord('root', 'site') : undefined;
82
84
  const _id = getCurrentPostId();
83
85
  return {
84
86
  slug: select(editorStore).getEditedPostSlug(),
@@ -96,8 +98,9 @@ function PostURLToggle({
96
98
  ,
97
99
  "aria-label": sprintf(__('Change link: %s'), decodedSlug),
98
100
  onClick: onClick,
99
- children: isFrontPage ? postLink : /*#__PURE__*/_jsxs(_Fragment, {
100
- children: ["/", decodedSlug]
101
+ children: /*#__PURE__*/_jsx(Truncate, {
102
+ numberOfLines: 1,
103
+ children: isFrontPage ? postLink : `/${decodedSlug}`
101
104
  })
102
105
  });
103
106
  }
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","useState","useSelect","Dropdown","Button","__","sprintf","safeDecodeURIComponent","store","coreStore","PostURLCheck","PostURL","PostPanelRow","editorStore","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PostURLPanel","popoverAnchor","setPopoverAnchor","popoverProps","anchor","placement","offset","shift","children","label","ref","className","contentClassName","focusOnMount","renderToggle","isOpen","onToggle","PostURLToggle","onClick","renderContent","onClose","slug","isFrontPage","postLink","select","getCurrentPostId","getCurrentPost","getEditedEntityRecord","siteSettings","_id","getEditedPostSlug","page_on_front","link","decodedSlug","size","variant"],"sources":["@wordpress/editor/src/components/post-url/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { safeDecodeURIComponent } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostURLCheck from './check';\nimport PostURL from './index';\nimport PostPanelRow from '../post-panel-row';\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders the `PostURLPanel` component.\n *\n * @return {JSX.Element} The rendered PostURLPanel component.\n */\nexport default function PostURLPanel() {\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\treturn (\n\t\t<PostURLCheck>\n\t\t\t<PostPanelRow label={ __( 'Link' ) } ref={ setPopoverAnchor }>\n\t\t\t\t<Dropdown\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tclassName=\"editor-post-url__panel-dropdown\"\n\t\t\t\t\tcontentClassName=\"editor-post-url__panel-dialog\"\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<PostURLToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<PostURL onClose={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</PostPanelRow>\n\t\t</PostURLCheck>\n\t);\n}\n\nfunction PostURLToggle( { isOpen, onClick } ) {\n\tconst { slug, isFrontPage, postLink } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPost } = select( editorStore );\n\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\tconst siteSettings = getEditedEntityRecord( 'root', 'site' );\n\t\tconst _id = getCurrentPostId();\n\t\treturn {\n\t\t\tslug: select( editorStore ).getEditedPostSlug(),\n\t\t\tisFrontPage: siteSettings?.page_on_front === _id,\n\t\t\tpostLink: getCurrentPost()?.link,\n\t\t};\n\t}, [] );\n\tconst decodedSlug = safeDecodeURIComponent( slug );\n\treturn (\n\t\t<Button\n\t\t\tsize=\"compact\"\n\t\t\tclassName=\"editor-post-url__panel-toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\t// translators: %s: Current post link.\n\t\t\taria-label={ sprintf( __( 'Change link: %s' ), decodedSlug ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ isFrontPage ? postLink : <>/{ decodedSlug }</> }\n\t\t</Button>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,QAAQ,EAAEC,MAAM,QAAQ,uBAAuB;AACxD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,sBAAsB,QAAQ,gBAAgB;AACvD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,OAAOC,YAAY,MAAM,SAAS;AAClC,OAAOC,OAAO,MAAM,SAAS;AAC7B,OAAOC,YAAY,MAAM,mBAAmB;AAC5C,SAASJ,KAAK,IAAIK,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AAJA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAKA,eAAe,SAASC,YAAYA,CAAA,EAAG;EACtC;EACA;EACA,MAAM,CAAEC,aAAa,EAAEC,gBAAgB,CAAE,GAAGrB,QAAQ,CAAE,IAAK,CAAC;EAC5D;EACA,MAAMsB,YAAY,GAAGvB,OAAO,CAC3B,OAAQ;IACP;IACA;IACAwB,MAAM,EAAEH,aAAa;IACrBI,SAAS,EAAE,YAAY;IACvBC,MAAM,EAAE,EAAE;IACVC,KAAK,EAAE;EACR,CAAC,CAAE,EACH,CAAEN,aAAa,CAChB,CAAC;EAED,oBACCN,IAAA,CAACL,YAAY;IAAAkB,QAAA,eACZb,IAAA,CAACH,YAAY;MAACiB,KAAK,EA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AAA,CAACX,MAAM;IACNkD,IAAI,EAAC,SAAS;IACdvB,SAAS,EAAC,+BAA+B;IACzCwB,OAAO,EAAC,UAAU;IAClB,iBAAgBpB;IAChB;IAAA;IACA,cAAa7B,OAAO,CAAED,EAAE,CAAE,iBAAkB,CAAC,EAAEgD,WAAY,CAAG;IAC9Df,OAAO,EAAGA,OAAS;IAAAV,QAAA,EAEjBc,WAAW,GAAGC,QAAQ,gBAAGxB,KAAA,CAAAF,SAAA;MAAAW,QAAA,GAAE,GAAC,EAAEyB,WAAW;IAAA,CAAI;EAAC,CACzC,CAAC;AAEX","ignoreList":[]}
1
+ {"version":3,"names":["useMemo","useState","useSelect","Dropdown","Button","__experimentalTruncate","Truncate","__","sprintf","safeDecodeURIComponent","store","coreStore","PostURLCheck","PostURL","PostPanelRow","editorStore","jsx","_jsx","PostURLPanel","popoverAnchor","setPopoverAnchor","popoverProps","anchor","placement","offset","shift","children","label","ref","className","contentClassName","focusOnMount","renderToggle","isOpen","onToggle","PostURLToggle","onClick","renderContent","onClose","slug","isFrontPage","postLink","select","getCurrentPostId","getCurrentPost","getEditedEntityRecord","canUser","siteSettings","kind","name","undefined","_id","getEditedPostSlug","page_on_front","link","decodedSlug","size","variant","numberOfLines"],"sources":["@wordpress/editor/src/components/post-url/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tDropdown,\n\tButton,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { safeDecodeURIComponent } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostURLCheck from './check';\nimport PostURL from './index';\nimport PostPanelRow from '../post-panel-row';\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders the `PostURLPanel` component.\n *\n * @return {JSX.Element} The rendered PostURLPanel component.\n */\nexport default function PostURLPanel() {\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\treturn (\n\t\t<PostURLCheck>\n\t\t\t<PostPanelRow label={ __( 'Link' ) } ref={ setPopoverAnchor }>\n\t\t\t\t<Dropdown\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tclassName=\"editor-post-url__panel-dropdown\"\n\t\t\t\t\tcontentClassName=\"editor-post-url__panel-dialog\"\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<PostURLToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<PostURL onClose={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</PostPanelRow>\n\t\t</PostURLCheck>\n\t);\n}\n\nfunction PostURLToggle( { isOpen, onClick } ) {\n\tconst { slug, isFrontPage, postLink } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPost } = select( editorStore );\n\t\tconst { getEditedEntityRecord, canUser } = select( coreStore );\n\t\tconst siteSettings = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? getEditedEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\tconst _id = getCurrentPostId();\n\t\treturn {\n\t\t\tslug: select( editorStore ).getEditedPostSlug(),\n\t\t\tisFrontPage: siteSettings?.page_on_front === _id,\n\t\t\tpostLink: getCurrentPost()?.link,\n\t\t};\n\t}, [] );\n\tconst decodedSlug = safeDecodeURIComponent( slug );\n\treturn (\n\t\t<Button\n\t\t\tsize=\"compact\"\n\t\t\tclassName=\"editor-post-url__panel-toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\t// translators: %s: Current post link.\n\t\t\taria-label={ sprintf( __( 'Change link: %s' ), decodedSlug ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t{ isFrontPage ? postLink : `/${ decodedSlug }` }\n\t\t\t</Truncate>\n\t\t</Button>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,QAAQ,EACRC,MAAM,EACNC,sBAAsB,IAAIC,QAAQ,QAC5B,uBAAuB;AAC9B,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,sBAAsB,QAAQ,gBAAgB;AACvD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,OAAOC,YAAY,MAAM,SAAS;AAClC,OAAOC,OAAO,MAAM,SAAS;AAC7B,OAAOC,YAAY,MAAM,mBAAmB;AAC5C,SAASJ,KAAK,IAAIK,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AAJA,SAAAC,GAAA,IAAAC,IAAA;AAKA,eAAe,SAASC,YAAYA,CAAA,EAAG;EACtC;EACA;EACA,MAAM,CAAEC,aAAa,EAAEC,gBAAgB,CAAE,GAAGnB,QAAQ,CAAE,IAAK,CAAC;EAC5D;EACA,MAAMoB,YAAY,GAAGrB,OAAO,CAC3B,OAAQ;IACP;IACA;IACAsB,MAAM,EAAEH,aAAa;IACrBI,SAAS,EAAE,YAAY;IACvBC,MAAM,EAAE,EAAE;IACVC,KAAK,EAAE;EACR,C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CAACqC,iBAAiB,CAAC,CAAC;MAC/CZ,WAAW,EAAEO,YAAY,EAAEM,aAAa,KAAKF,GAAG;MAChDV,QAAQ,EAAEG,cAAc,CAAC,CAAC,EAAEU;IAC7B,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,MAAMC,WAAW,GAAG9C,sBAAsB,CAAE8B,IAAK,CAAC;EAClD,oBACCtB,IAAA,CAACb,MAAM;IACNoD,IAAI,EAAC,SAAS;IACd3B,SAAS,EAAC,+BAA+B;IACzC4B,OAAO,EAAC,UAAU;IAClB,iBAAgBxB;IAChB;IAAA;IACA,cAAazB,OAAO,CAAED,EAAE,CAAE,iBAAkB,CAAC,EAAEgD,WAAY,CAAG;IAC9DnB,OAAO,EAAGA,OAAS;IAAAV,QAAA,eAEnBT,IAAA,CAACX,QAAQ;MAACoD,aAAa,EAAG,CAAG;MAAAhC,QAAA,EAC1Bc,WAAW,GAAGC,QAAQ,GAAI,IAAIc,WAAa;IAAC,CACrC;EAAC,CACJ,CAAC;AAEX","ignoreList":[]}
@@ -31,9 +31,13 @@ export default function PostsPerPage() {
31
31
  getCurrentPostType
32
32
  } = select(editorStore);
33
33
  const {
34
- getEditedEntityRecord
34
+ getEditedEntityRecord,
35
+ canUser
35
36
  } = select(coreStore);
36
- const siteSettings = getEditedEntityRecord('root', 'site');
37
+ const siteSettings = canUser('read', {
38
+ kind: 'root',
39
+ name: 'site'
40
+ }) ? getEditedEntityRecord('root', 'site') : undefined;
37
41
  return {
38
42
  isTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,
39
43
  postSlug: getEditedPostAttribute('slug'),
@@ -1 +1 @@
1
- {"version":3,"names":["__","useSelect","useDispatch","store","coreStore","Button","Dropdown","__experimentalNumberControl","NumberControl","useState","useMemo","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","TEMPLATE_POST_TYPE","editorStore","PostPanelRow","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PostsPerPage","editEntityRecord","postsPerPage","isTemplate","postSlug","select","getEditedPostAttribute","getCurrentPostType","getEditedEntityRecord","siteSettings","posts_per_page","popoverAnchor","setPopoverAnchor","popoverProps","anchor","placement","offset","shift","includes","setPostsPerPage","newValue","undefined","label","ref","children","contentClassName","focusOnMount","renderToggle","isOpen","onToggle","size","variant","onClick","renderContent","onClose","title","placeholder","value","spinControls","step","min","onChange","help","hideLabelFromVision"],"sources":["@wordpress/editor/src/components/posts-per-page/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tButton,\n\tDropdown,\n\t__experimentalNumberControl as NumberControl,\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 { store as editorStore } from '../../store';\nimport PostPanelRow from '../post-panel-row';\n\nexport default function PostsPerPage() {\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { postsPerPage, isTemplate, postSlug } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\tconst siteSettings = getEditedEntityRecord( 'root', 'site' );\n\t\treturn {\n\t\t\tisTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,\n\t\t\tpostSlug: getEditedPostAttribute( 'slug' ),\n\t\t\tpostsPerPage: siteSettings?.posts_per_page || 1,\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 ( ! isTemplate || ! [ 'home', 'index' ].includes( postSlug ) ) {\n\t\treturn null;\n\t}\n\tconst setPostsPerPage = ( newValue ) => {\n\t\teditEntityRecord( 'root', 'site', undefined, {\n\t\t\tposts_per_page: newValue,\n\t\t} );\n\t};\n\treturn (\n\t\t<PostPanelRow label={ __( 'Posts per page' ) } ref={ setPopoverAnchor }>\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tcontentClassName=\"editor-posts-per-page-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={ __( 'Change posts per page' ) }\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ postsPerPage }\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={ __( 'Posts per page' ) }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<NumberControl\n\t\t\t\t\t\t\tplaceholder={ 0 }\n\t\t\t\t\t\t\tvalue={ postsPerPage }\n\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t\tspinControls=\"custom\"\n\t\t\t\t\t\t\tstep=\"1\"\n\t\t\t\t\t\t\tmin=\"1\"\n\t\t\t\t\t\t\tonChange={ setPostsPerPage }\n\t\t\t\t\t\t\tlabel={ __( 'Posts per page' ) }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Set the default number of posts to display on blog pages, including categories and tags. Some templates may override this setting.'\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,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SACCC,MAAM,EACNC,QAAQ,EACRC,2BAA2B,IAAIC,aAAa,QACtC,uBAAuB;AAC9B,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,oCAAoC,IAAIC,sBAAsB,QAAQ,yBAAyB;;AAExG;AACA;AACA;AACA,SAASC,kBAAkB,QAAQ,uBAAuB;AAC1D,SAASV,KAAK,IAAIW,WAAW,QAAQ,aAAa;AAClD,OAAOC,YAAY,MAAM,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAE7C,eAAe,SAASC,YAAYA,CAAA,EAAG;EACtC,MAAM;IAAEC;EAAiB,CAAC,GAAGrB,WAAW,CAAEE,SAAU,CAAC;EACrD,MAAM;IAAEoB,YAAY;IAAEC,UAAU;IAAEC;EAAS,CAAC,GAAGzB,SAAS,CAAI0B,MAAM,IAAM;IACvE,MAAM;MAAEC,sBAAsB;MAAEC;IAAmB,CAAC,GACnDF,MAAM,CAAEb,WAAY,CAAC;IACtB,MAAM;MAAEgB;IAAsB,CAAC,GAAGH,MAAM,CAAEvB,SAAU,CAAC;IACrD,MAAM2B,YAAY,GAAGD,qBAAqB,CAAE,MAAM,EAAE,MAAO,CAAC;IAC5D,OAAO;MACNL,UAAU,EAAEI,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,CACN;MACH+B,aAAa,EAAGA,CAAE;QAAEC;MAAQ,CAAC,kBAC5BnC,KAAA,CAAAF,SAAA;QAAA2B,QAAA,gBACC7B,IAAA,CAACL,sBAAsB;UACtB6C,KAAK,EAAGzD,EAAE,CAAE,gBAAiB,CAAG;UAChCwD,OAAO,EAAGA;QAAS,CACnB,CAAC,eACFvC,IAAA,CAACT,aAAa;UACbkD,WAAW,EAAG,CAAG;UACjBC,KAAK,EAAGnC,YAAc;UACtB4B,IAAI,EAAC,kBAAkB;UACvBQ,YAAY,EAAC,QAAQ;UACrBC,IAAI,EAAC,GAAG;UACRC,GAAG,EAAC,GAAG;UACPC,QAAQ,EAAGtB,eAAiB;UAC5BG,KAAK,EAAG5C,EAAE,CAAE,gBAAiB,CAAG;UAChCgE,IAAI,EAAGhE,EAAE,CACR,oIACD,CAAG;UACHiE,mBAAmB;QAAA,CACnB,CAAC;MAAA,CACD;IACA,CACH;EAAC,CACW,CAAC;AAEjB","ignoreList":[]}
1
+ {"version":3,"names":["__","useSelect","useDispatch","store","coreStore","Button","Dropdown","__experimentalNumberControl","NumberControl","useState","useMemo","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","TEMPLATE_POST_TYPE","editorStore","PostPanelRow","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PostsPerPage","editEntityRecord","postsPerPage","isTemplate","postSlug","select","getEditedPostAttribute","getCurrentPostType","getEditedEntityRecord","canUser","siteSettings","kind","name","undefined","posts_per_page","popoverAnchor","setPopoverAnchor","popoverProps","anchor","placement","offset","shift","includes","setPostsPerPage","newValue","label","ref","children","contentClassName","focusOnMount","renderToggle","isOpen","onToggle","size","variant","onClick","renderContent","onClose","title","placeholder","value","spinControls","step","min","onChange","help","hideLabelFromVision"],"sources":["@wordpress/editor/src/components/posts-per-page/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tButton,\n\tDropdown,\n\t__experimentalNumberControl as NumberControl,\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 { store as editorStore } from '../../store';\nimport PostPanelRow from '../post-panel-row';\n\nexport default function PostsPerPage() {\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { postsPerPage, isTemplate, postSlug } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst { getEditedEntityRecord, canUser } = select( coreStore );\n\t\tconst siteSettings = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? getEditedEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\tisTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,\n\t\t\tpostSlug: getEditedPostAttribute( 'slug' ),\n\t\t\tpostsPerPage: siteSettings?.posts_per_page || 1,\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 ( ! isTemplate || ! [ 'home', 'index' ].includes( postSlug ) ) {\n\t\treturn null;\n\t}\n\tconst setPostsPerPage = ( newValue ) => {\n\t\teditEntityRecord( 'root', 'site', undefined, {\n\t\t\tposts_per_page: newValue,\n\t\t} );\n\t};\n\treturn (\n\t\t<PostPanelRow label={ __( 'Posts per page' ) } ref={ setPopoverAnchor }>\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tcontentClassName=\"editor-posts-per-page-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={ __( 'Change posts per page' ) }\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ postsPerPage }\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={ __( 'Posts per page' ) }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<NumberControl\n\t\t\t\t\t\t\tplaceholder={ 0 }\n\t\t\t\t\t\t\tvalue={ postsPerPage }\n\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t\tspinControls=\"custom\"\n\t\t\t\t\t\t\tstep=\"1\"\n\t\t\t\t\t\t\tmin=\"1\"\n\t\t\t\t\t\t\tonChange={ setPostsPerPage }\n\t\t\t\t\t\t\tlabel={ __( 'Posts per page' ) }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Set the default number of posts to display on blog pages, including categories and tags. Some templates may override this setting.'\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,QAAQ,iBAAiB;AACpC,SAAS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