@wordpress/editor 14.42.0 → 14.43.1-next.v.202604091042.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 (276) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +8 -0
  3. package/build/components/autocompleters/index.cjs +3 -0
  4. package/build/components/autocompleters/index.cjs.map +2 -2
  5. package/build/components/autocompleters/link.cjs +71 -0
  6. package/build/components/autocompleters/link.cjs.map +7 -0
  7. package/build/components/collaborators-overlay/cursor-dom-utils.cjs +1 -1
  8. package/build/components/collaborators-overlay/cursor-dom-utils.cjs.map +2 -2
  9. package/build/components/collaborators-overlay/cursor-registry.cjs +86 -0
  10. package/build/components/collaborators-overlay/cursor-registry.cjs.map +7 -0
  11. package/build/components/collaborators-overlay/index.cjs +7 -2
  12. package/build/components/collaborators-overlay/index.cjs.map +2 -2
  13. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +1 -1
  14. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +2 -2
  15. package/build/components/collaborators-overlay/overlay.cjs +31 -1
  16. package/build/components/collaborators-overlay/overlay.cjs.map +2 -2
  17. package/build/components/collaborators-overlay/timing-utils.cjs +1 -1
  18. package/build/components/collaborators-overlay/timing-utils.cjs.map +2 -2
  19. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +2 -2
  20. package/build/components/collaborators-presence/index.cjs +14 -4
  21. package/build/components/collaborators-presence/index.cjs.map +2 -2
  22. package/build/components/collaborators-presence/list.cjs +20 -4
  23. package/build/components/collaborators-presence/list.cjs.map +2 -2
  24. package/build/components/error-boundary/index.cjs +1 -1
  25. package/build/components/error-boundary/index.cjs.map +2 -2
  26. package/build/components/post-card-panel/index.cjs +4 -15
  27. package/build/components/post-card-panel/index.cjs.map +2 -2
  28. package/build/components/post-content-information/index.cjs +10 -13
  29. package/build/components/post-content-information/index.cjs.map +2 -2
  30. package/build/components/post-revisions-panel/index.cjs +164 -0
  31. package/build/components/post-revisions-panel/index.cjs.map +7 -0
  32. package/build/components/post-revisions-preview/revisions-slider.cjs +23 -12
  33. package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
  34. package/build/components/post-template/create-new-template-modal.cjs +39 -46
  35. package/build/components/post-template/create-new-template-modal.cjs.map +2 -2
  36. package/build/components/post-template/hooks.cjs +52 -6
  37. package/build/components/post-template/hooks.cjs.map +2 -2
  38. package/build/components/post-template/swap-template-button.cjs +31 -20
  39. package/build/components/post-template/swap-template-button.cjs.map +2 -2
  40. package/build/components/post-title/index.cjs +2 -2
  41. package/build/components/post-title/index.cjs.map +2 -2
  42. package/build/components/preferences-modal/index.cjs +35 -27
  43. package/build/components/preferences-modal/index.cjs.map +2 -2
  44. package/build/components/revision-block-diff/index.cjs +9 -32
  45. package/build/components/revision-block-diff/index.cjs.map +3 -3
  46. package/build/components/revision-diff-panel/index.cjs +68 -0
  47. package/build/components/revision-diff-panel/index.cjs.map +7 -0
  48. package/build/components/revision-fields-diff/index.cjs +96 -0
  49. package/build/components/revision-fields-diff/index.cjs.map +7 -0
  50. package/build/components/sidebar/dataform-post-summary.cjs +8 -53
  51. package/build/components/sidebar/dataform-post-summary.cjs.map +2 -2
  52. package/build/components/sidebar/index.cjs +25 -22
  53. package/build/components/sidebar/index.cjs.map +3 -3
  54. package/build/components/sidebar/post-revision-summary.cjs +74 -0
  55. package/build/components/sidebar/post-revision-summary.cjs.map +7 -0
  56. package/build/components/sidebar/post-summary.cjs +35 -42
  57. package/build/components/sidebar/post-summary.cjs.map +3 -3
  58. package/build/components/style-book/index.cjs +4 -3
  59. package/build/components/style-book/index.cjs.map +2 -2
  60. package/build/components/styles-canvas/revisions.cjs +2 -2
  61. package/build/components/styles-canvas/revisions.cjs.map +1 -1
  62. package/build/components/sync-connection-error-modal/index.cjs +58 -75
  63. package/build/components/sync-connection-error-modal/index.cjs.map +3 -3
  64. package/build/components/sync-connection-error-modal/use-retry-countdown.cjs +32 -9
  65. package/build/components/sync-connection-error-modal/use-retry-countdown.cjs.map +2 -2
  66. package/build/components/template-actions-panel/block-theme-content.cjs +188 -0
  67. package/build/components/template-actions-panel/block-theme-content.cjs.map +7 -0
  68. package/build/components/template-actions-panel/classic-theme-content.cjs +159 -0
  69. package/build/components/template-actions-panel/classic-theme-content.cjs.map +7 -0
  70. package/build/components/template-actions-panel/index.cjs +59 -0
  71. package/build/components/template-actions-panel/index.cjs.map +7 -0
  72. package/build/dataviews/store/private-actions.cjs +2 -0
  73. package/build/dataviews/store/private-actions.cjs.map +2 -2
  74. package/build/hooks/default-autocompleters.cjs +1 -1
  75. package/build/hooks/default-autocompleters.cjs.map +2 -2
  76. package/build/store/private-actions.cjs +15 -1
  77. package/build/store/private-actions.cjs.map +2 -2
  78. package/build/store/private-selectors.cjs +42 -19
  79. package/build/store/private-selectors.cjs.map +2 -2
  80. package/build/store/reducer.cjs +1 -1
  81. package/build/store/reducer.cjs.map +2 -2
  82. package/build-module/components/autocompleters/index.mjs +4 -2
  83. package/build-module/components/autocompleters/index.mjs.map +2 -2
  84. package/build-module/components/autocompleters/link.mjs +40 -0
  85. package/build-module/components/autocompleters/link.mjs.map +7 -0
  86. package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs +1 -1
  87. package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs.map +2 -2
  88. package/build-module/components/collaborators-overlay/cursor-registry.mjs +61 -0
  89. package/build-module/components/collaborators-overlay/cursor-registry.mjs.map +7 -0
  90. package/build-module/components/collaborators-overlay/index.mjs +7 -2
  91. package/build-module/components/collaborators-overlay/index.mjs.map +2 -2
  92. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +1 -1
  93. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +2 -2
  94. package/build-module/components/collaborators-overlay/overlay.mjs +32 -2
  95. package/build-module/components/collaborators-overlay/overlay.mjs.map +2 -2
  96. package/build-module/components/collaborators-overlay/timing-utils.mjs +1 -1
  97. package/build-module/components/collaborators-overlay/timing-utils.mjs.map +2 -2
  98. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  99. package/build-module/components/collaborators-presence/index.mjs +14 -4
  100. package/build-module/components/collaborators-presence/index.mjs.map +2 -2
  101. package/build-module/components/collaborators-presence/list.mjs +20 -4
  102. package/build-module/components/collaborators-presence/list.mjs.map +2 -2
  103. package/build-module/components/error-boundary/index.mjs +1 -1
  104. package/build-module/components/error-boundary/index.mjs.map +2 -2
  105. package/build-module/components/post-card-panel/index.mjs +6 -17
  106. package/build-module/components/post-card-panel/index.mjs.map +2 -2
  107. package/build-module/components/post-content-information/index.mjs +6 -13
  108. package/build-module/components/post-content-information/index.mjs.map +2 -2
  109. package/build-module/components/post-revisions-panel/index.mjs +139 -0
  110. package/build-module/components/post-revisions-panel/index.mjs.map +7 -0
  111. package/build-module/components/post-revisions-preview/revisions-slider.mjs +23 -12
  112. package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
  113. package/build-module/components/post-template/create-new-template-modal.mjs +39 -46
  114. package/build-module/components/post-template/create-new-template-modal.mjs.map +2 -2
  115. package/build-module/components/post-template/hooks.mjs +53 -7
  116. package/build-module/components/post-template/hooks.mjs.map +2 -2
  117. package/build-module/components/post-template/swap-template-button.mjs +27 -20
  118. package/build-module/components/post-template/swap-template-button.mjs.map +2 -2
  119. package/build-module/components/post-title/index.mjs +2 -2
  120. package/build-module/components/post-title/index.mjs.map +2 -2
  121. package/build-module/components/preferences-modal/index.mjs +35 -27
  122. package/build-module/components/preferences-modal/index.mjs.map +2 -2
  123. package/build-module/components/revision-block-diff/index.mjs +9 -32
  124. package/build-module/components/revision-block-diff/index.mjs.map +2 -2
  125. package/build-module/components/revision-diff-panel/index.mjs +37 -0
  126. package/build-module/components/revision-diff-panel/index.mjs.map +7 -0
  127. package/build-module/components/revision-fields-diff/index.mjs +65 -0
  128. package/build-module/components/revision-fields-diff/index.mjs.map +7 -0
  129. package/build-module/components/sidebar/dataform-post-summary.mjs +8 -53
  130. package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
  131. package/build-module/components/sidebar/index.mjs +25 -22
  132. package/build-module/components/sidebar/index.mjs.map +2 -2
  133. package/build-module/components/sidebar/post-revision-summary.mjs +43 -0
  134. package/build-module/components/sidebar/post-revision-summary.mjs.map +7 -0
  135. package/build-module/components/sidebar/post-summary.mjs +31 -42
  136. package/build-module/components/sidebar/post-summary.mjs.map +2 -2
  137. package/build-module/components/style-book/index.mjs +4 -3
  138. package/build-module/components/style-book/index.mjs.map +2 -2
  139. package/build-module/components/styles-canvas/revisions.mjs +2 -2
  140. package/build-module/components/styles-canvas/revisions.mjs.map +1 -1
  141. package/build-module/components/sync-connection-error-modal/index.mjs +58 -76
  142. package/build-module/components/sync-connection-error-modal/index.mjs.map +2 -2
  143. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs +33 -10
  144. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs.map +2 -2
  145. package/build-module/components/template-actions-panel/block-theme-content.mjs +167 -0
  146. package/build-module/components/template-actions-panel/block-theme-content.mjs.map +7 -0
  147. package/build-module/components/template-actions-panel/classic-theme-content.mjs +138 -0
  148. package/build-module/components/template-actions-panel/classic-theme-content.mjs.map +7 -0
  149. package/build-module/components/template-actions-panel/index.mjs +28 -0
  150. package/build-module/components/template-actions-panel/index.mjs.map +7 -0
  151. package/build-module/dataviews/store/private-actions.mjs +5 -1
  152. package/build-module/dataviews/store/private-actions.mjs.map +2 -2
  153. package/build-module/hooks/default-autocompleters.mjs +2 -2
  154. package/build-module/hooks/default-autocompleters.mjs.map +2 -2
  155. package/build-module/store/private-actions.mjs +15 -1
  156. package/build-module/store/private-actions.mjs.map +2 -2
  157. package/build-module/store/private-selectors.mjs +42 -19
  158. package/build-module/store/private-selectors.mjs.map +2 -2
  159. package/build-module/store/reducer.mjs +1 -1
  160. package/build-module/store/reducer.mjs.map +2 -2
  161. package/build-style/style-rtl.css +124 -44
  162. package/build-style/style.css +124 -44
  163. package/build-types/bindings/post-data.d.ts +3 -3
  164. package/build-types/bindings/term-data.d.ts +14 -14
  165. package/build-types/components/autocompleters/index.d.ts +1 -0
  166. package/build-types/components/autocompleters/link.d.ts +12 -0
  167. package/build-types/components/autocompleters/link.d.ts.map +1 -0
  168. package/build-types/components/collaborators-overlay/cursor-registry.d.ts +36 -0
  169. package/build-types/components/collaborators-overlay/cursor-registry.d.ts.map +1 -0
  170. package/build-types/components/collaborators-overlay/index.d.ts +7 -4
  171. package/build-types/components/collaborators-overlay/index.d.ts.map +1 -1
  172. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts +1 -1
  173. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts.map +1 -1
  174. package/build-types/components/collaborators-overlay/overlay.d.ts +4 -1
  175. package/build-types/components/collaborators-overlay/overlay.d.ts.map +1 -1
  176. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
  177. package/build-types/components/collaborators-presence/index.d.ts.map +1 -1
  178. package/build-types/components/collaborators-presence/list.d.ts +4 -1
  179. package/build-types/components/collaborators-presence/list.d.ts.map +1 -1
  180. package/build-types/components/keyboard-shortcut-help-modal/config.d.ts +11 -11
  181. package/build-types/components/post-actions/set-as-homepage.d.ts +1 -1
  182. package/build-types/components/post-actions/set-as-posts-page.d.ts +1 -1
  183. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  184. package/build-types/components/post-content-information/index.d.ts +4 -1
  185. package/build-types/components/post-content-information/index.d.ts.map +1 -1
  186. package/build-types/components/post-format/index.d.ts +10 -10
  187. package/build-types/components/post-locked-modal/index.d.ts +2 -2
  188. package/build-types/components/post-revisions-panel/index.d.ts +2 -0
  189. package/build-types/components/post-revisions-panel/index.d.ts.map +1 -0
  190. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  191. package/build-types/components/post-status/index.d.ts +10 -10
  192. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  193. package/build-types/components/post-template/hooks.d.ts +1 -1
  194. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  195. package/build-types/components/post-template/swap-template-button.d.ts +4 -0
  196. package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
  197. package/build-types/components/post-visibility/utils.d.ts +6 -6
  198. package/build-types/components/revision-block-diff/index.d.ts.map +1 -1
  199. package/build-types/components/revision-diff-panel/index.d.ts +14 -0
  200. package/build-types/components/revision-diff-panel/index.d.ts.map +1 -0
  201. package/build-types/components/revision-fields-diff/index.d.ts +6 -0
  202. package/build-types/components/revision-fields-diff/index.d.ts.map +1 -0
  203. package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
  204. package/build-types/components/sidebar/index.d.ts.map +1 -1
  205. package/build-types/components/sidebar/post-revision-summary.d.ts +2 -0
  206. package/build-types/components/sidebar/post-revision-summary.d.ts.map +1 -0
  207. package/build-types/components/sidebar/post-summary.d.ts +3 -0
  208. package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
  209. package/build-types/components/style-book/index.d.ts +2 -1
  210. package/build-types/components/style-book/index.d.ts.map +1 -1
  211. package/build-types/components/sync-connection-error-modal/index.d.ts +0 -14
  212. package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -1
  213. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts.map +1 -1
  214. package/build-types/components/template-actions-panel/block-theme-content.d.ts +2 -0
  215. package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -0
  216. package/build-types/components/template-actions-panel/classic-theme-content.d.ts +2 -0
  217. package/build-types/components/template-actions-panel/classic-theme-content.d.ts.map +1 -0
  218. package/build-types/components/template-actions-panel/index.d.ts +2 -0
  219. package/build-types/components/template-actions-panel/index.d.ts.map +1 -0
  220. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  221. package/build-types/store/private-actions.d.ts.map +1 -1
  222. package/build-types/store/private-selectors.d.ts.map +1 -1
  223. package/build-types/store/reducer.d.ts +10 -10
  224. package/build-types/store/reducer.d.ts.map +1 -1
  225. package/build-types/utils/pageTypeBadge.d.ts +1 -1
  226. package/build-types/utils/pageTypeBadge.d.ts.map +1 -1
  227. package/package.json +45 -44
  228. package/src/components/autocompleters/index.js +1 -0
  229. package/src/components/autocompleters/link.js +47 -0
  230. package/src/components/autocompleters/style.scss +6 -0
  231. package/src/components/collaborators-overlay/cursor-dom-utils.ts +1 -1
  232. package/src/components/collaborators-overlay/cursor-registry.ts +96 -0
  233. package/src/components/collaborators-overlay/index.tsx +12 -4
  234. package/src/components/collaborators-overlay/overlay-iframe-styles.ts +1 -1
  235. package/src/components/collaborators-overlay/overlay.tsx +45 -1
  236. package/src/components/collaborators-overlay/timing-utils.ts +1 -1
  237. package/src/components/collaborators-overlay/use-render-cursors.ts +4 -2
  238. package/src/components/collaborators-presence/index.tsx +9 -1
  239. package/src/components/collaborators-presence/list.tsx +25 -1
  240. package/src/components/error-boundary/index.js +1 -1
  241. package/src/components/error-boundary/index.native.js +1 -1
  242. package/src/components/post-card-panel/index.js +7 -21
  243. package/src/components/post-content-information/index.js +5 -16
  244. package/src/components/post-revisions-panel/index.js +151 -0
  245. package/src/components/post-revisions-panel/style.scss +16 -0
  246. package/src/components/post-revisions-preview/revisions-slider.js +23 -19
  247. package/src/components/post-template/create-new-template-modal.js +1 -4
  248. package/src/components/post-template/hooks.js +65 -9
  249. package/src/components/post-template/style.scss +0 -6
  250. package/src/components/post-template/swap-template-button.js +30 -21
  251. package/src/components/post-title/index.js +3 -3
  252. package/src/components/preferences-modal/index.js +37 -25
  253. package/src/components/revision-block-diff/index.js +8 -43
  254. package/src/components/revision-diff-panel/index.js +59 -0
  255. package/src/components/revision-fields-diff/index.js +91 -0
  256. package/src/components/sidebar/dataform-post-summary.js +8 -55
  257. package/src/components/sidebar/index.js +33 -22
  258. package/src/components/sidebar/post-revision-summary.js +50 -0
  259. package/src/components/sidebar/post-summary.js +22 -40
  260. package/src/components/sidebar/style.scss +7 -0
  261. package/src/components/style-book/index.js +4 -2
  262. package/src/components/styles-canvas/revisions.js +2 -2
  263. package/src/components/sync-connection-error-modal/index.tsx +128 -155
  264. package/src/components/sync-connection-error-modal/use-retry-countdown.ts +46 -10
  265. package/src/components/template-actions-panel/block-theme-content.js +196 -0
  266. package/src/components/template-actions-panel/classic-theme-content.js +170 -0
  267. package/src/components/template-actions-panel/index.js +32 -0
  268. package/src/components/template-actions-panel/style.scss +39 -0
  269. package/src/dataviews/store/private-actions.ts +6 -0
  270. package/src/hooks/default-autocompleters.js +2 -2
  271. package/src/hooks/test/default-autocompleters.js +2 -2
  272. package/src/store/private-actions.js +18 -2
  273. package/src/store/private-selectors.js +43 -22
  274. package/src/store/reducer.js +9 -8
  275. package/src/style.scss +3 -1
  276. /package/src/components/{revision-block-diff → revision-diff-panel}/style.scss +0 -0
@@ -6,7 +6,6 @@ import { count as wordCount } from "@wordpress/wordcount";
6
6
  import { useMemo } from "@wordpress/element";
7
7
  import { store as coreStore } from "@wordpress/core-data";
8
8
  import { store as editorStore } from "../../store/index.mjs";
9
- import { unlock } from "../../lock-unlock.mjs";
10
9
  import {
11
10
  TEMPLATE_POST_TYPE,
12
11
  TEMPLATE_PART_POST_TYPE
@@ -14,16 +13,8 @@ import {
14
13
  import { jsx } from "react/jsx-runtime";
15
14
  var AVERAGE_READING_RATE = 189;
16
15
  function PostContentInformation() {
17
- const { postContent } = useSelect((select) => {
16
+ const postContent = useSelect((select) => {
18
17
  const { getEditedPostAttribute, getCurrentPostType, getCurrentPostId } = select(editorStore);
19
- const { getCurrentRevision, isRevisionsMode } = unlock(
20
- select(editorStore)
21
- );
22
- if (isRevisionsMode()) {
23
- return {
24
- postContent: getCurrentRevision()?.content?.raw
25
- };
26
- }
27
18
  const { canUser } = select(coreStore);
28
19
  const { getEntityRecord } = select(coreStore);
29
20
  const siteSettings = canUser("read", {
@@ -36,10 +27,11 @@ function PostContentInformation() {
36
27
  const showPostContentInfo = !isPostsPage && ![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(
37
28
  postType
38
29
  );
39
- return {
40
- postContent: showPostContentInfo && getEditedPostAttribute("content")
41
- };
30
+ return showPostContentInfo && getEditedPostAttribute("content");
42
31
  }, []);
32
+ return /* @__PURE__ */ jsx(PostContentInformationUI, { postContent });
33
+ }
34
+ function PostContentInformationUI({ postContent }) {
43
35
  const wordCountType = _x("words", "Word count type. Do not translate!");
44
36
  const wordsCounted = useMemo(
45
37
  () => postContent ? wordCount(postContent, wordCountType) : 0,
@@ -67,6 +59,7 @@ function PostContentInformation() {
67
59
  ) }) });
68
60
  }
69
61
  export {
62
+ PostContentInformationUI,
70
63
  PostContentInformation as default
71
64
  };
72
65
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/post-content-information/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __experimentalText as Text } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __, _x, _n, sprintf } from '@wordpress/i18n';\nimport { count as wordCount } from '@wordpress/wordcount';\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';\nimport { unlock } from '../../lock-unlock';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../store/constants';\n\n// Taken from packages/editor/src/components/time-to-read/index.js.\nconst AVERAGE_READING_RATE = 189;\n\n// This component renders the wordcount and reading time for the post.\nexport default function PostContentInformation() {\n\tconst { postContent } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute, getCurrentPostType, getCurrentPostId } =\n\t\t\tselect( editorStore );\n\t\tconst { getCurrentRevision, isRevisionsMode } = unlock(\n\t\t\tselect( editorStore )\n\t\t);\n\n\t\tif ( isRevisionsMode() ) {\n\t\t\treturn {\n\t\t\t\tpostContent: getCurrentRevision()?.content?.raw,\n\t\t\t};\n\t\t}\n\n\t\tconst { canUser } = select( coreStore );\n\t\tconst { getEntityRecord } = 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? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\tconst postType = getCurrentPostType();\n\t\tconst _id = getCurrentPostId();\n\t\tconst isPostsPage = +_id === siteSettings?.page_for_posts;\n\t\tconst showPostContentInfo =\n\t\t\t! isPostsPage &&\n\t\t\t! [ TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE ].includes(\n\t\t\t\tpostType\n\t\t\t);\n\t\treturn {\n\t\t\tpostContent:\n\t\t\t\tshowPostContentInfo && getEditedPostAttribute( 'content' ),\n\t\t};\n\t}, [] );\n\n\t/*\n\t * translators: If your word count is based on single characters (e.g. East Asian characters),\n\t * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.\n\t * Do not translate into your own language.\n\t */\n\tconst wordCountType = _x( 'words', 'Word count type. Do not translate!' );\n\tconst wordsCounted = useMemo(\n\t\t() => ( postContent ? wordCount( postContent, wordCountType ) : 0 ),\n\t\t[ postContent, wordCountType ]\n\t);\n\tif ( ! wordsCounted ) {\n\t\treturn null;\n\t}\n\tconst readingTime = Math.round( wordsCounted / AVERAGE_READING_RATE );\n\tconst wordsCountText = sprintf(\n\t\t// translators: %s: the number of words in the post.\n\t\t_n( '%s word', '%s words', wordsCounted ),\n\t\twordsCounted.toLocaleString()\n\t);\n\tconst minutesText =\n\t\treadingTime <= 1\n\t\t\t? __( '1 minute' )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: %s: the number of minutes to read the post. */\n\t\t\t\t\t_n( '%s minute', '%s minutes', readingTime ),\n\t\t\t\t\treadingTime.toLocaleString()\n\t\t\t );\n\treturn (\n\t\t<div className=\"editor-post-content-information\">\n\t\t\t<Text>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t/* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */\n\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AqC;AACxE,QAAM,eAAe;AAAA,IACpB,MAAQ,cAAc,UAAW,aAAa,aAAc,IAAI;AAAA,IAChE,CAAE,aAAa,aAAc;AAAA,EAC9B;AACA,MAAK,CAAE,cAAe;AACrB,WAAO;AAAA,EACR;AACA,QAAM,cAAc,KAAK,MAAO,eAAe,oBAAqB;AACpE,QAAM,iBAAiB;AAAA;AAAA,IAEtB,GAAI,WAAW,YAAY,YAAa;AAAA,IACxC,aAAa,eAAe;AAAA,EAC7B;AACA,QAAM,cACL,eAAe,IACZ,GAAI,UAAW,IACf;AAAA;AAAA,IAEA,GAAI,aAAa,cAAc,WAAY;AAAA,IAC3C,YAAY,eAAe;AAAA,EAC3B;AACJ,SACC,oBAAC,SAAI,WAAU,mCACd,8BAAC,QACE;AAAA;AAAA,IAED,GAAI,uBAAwB;AAAA,IAC5B;AAAA,IACA;AAAA,EACD,GACD,GACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __experimentalText as Text } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __, _x, _n, sprintf } from '@wordpress/i18n';\nimport { count as wordCount } from '@wordpress/wordcount';\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';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../store/constants';\n\n// Taken from packages/editor/src/components/time-to-read/index.js.\nconst AVERAGE_READING_RATE = 189;\n\n// This component renders the wordcount and reading time for the post.\nexport default function PostContentInformation() {\n\tconst postContent = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute, getCurrentPostType, getCurrentPostId } =\n\t\t\tselect( editorStore );\n\t\tconst { canUser } = select( coreStore );\n\t\tconst { getEntityRecord } = 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? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\tconst postType = getCurrentPostType();\n\t\tconst _id = getCurrentPostId();\n\t\tconst isPostsPage = +_id === siteSettings?.page_for_posts;\n\t\tconst showPostContentInfo =\n\t\t\t! isPostsPage &&\n\t\t\t! [ TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE ].includes(\n\t\t\t\tpostType\n\t\t\t);\n\t\treturn showPostContentInfo && getEditedPostAttribute( 'content' );\n\t}, [] );\n\treturn <PostContentInformationUI postContent={ postContent } />;\n}\n\nexport function PostContentInformationUI( { postContent } ) {\n\t/*\n\t * translators: If your word count is based on single characters (e.g. East Asian characters),\n\t * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.\n\t * Do not translate into your own language.\n\t */\n\tconst wordCountType = _x( 'words', 'Word count type. Do not translate!' );\n\tconst wordsCounted = useMemo(\n\t\t() => ( postContent ? wordCount( postContent, wordCountType ) : 0 ),\n\t\t[ postContent, wordCountType ]\n\t);\n\tif ( ! wordsCounted ) {\n\t\treturn null;\n\t}\n\tconst readingTime = Math.round( wordsCounted / AVERAGE_READING_RATE );\n\tconst wordsCountText = sprintf(\n\t\t// translators: %s: the number of words in the post.\n\t\t_n( '%s word', '%s words', wordsCounted ),\n\t\twordsCounted.toLocaleString()\n\t);\n\tconst minutesText =\n\t\treadingTime <= 1\n\t\t\t? __( '1 minute' )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: %s: the number of minutes to read the post. */\n\t\t\t\t\t_n( '%s minute', '%s minutes', readingTime ),\n\t\t\t\t\treadingTime.toLocaleString()\n\t\t\t );\n\treturn (\n\t\t<div className=\"editor-post-content-information\">\n\t\t\t<Text>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t/* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */\n\t\t\t\t\t__( '%1$s, %2$s read time.' ),\n\t\t\t\t\twordsCountText,\n\t\t\t\t\tminutesText\n\t\t\t\t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AEtB,GAAI,WAAW,YAAY,YAAa;AAAA,IACxC,aAAa,eAAe;AAAA,EAC7B;AACA,QAAM,cACL,eAAe,IACZ,GAAI,UAAW,IACf;AAAA;AAAA,IAEA,GAAI,aAAa,cAAc,WAAY;AAAA,IAC3C,YAAY,eAAe;AAAA,EAC3B;AACJ,SACC,oBAAC,SAAI,WAAU,mCACd,8BAAC,QACE;AAAA;AAAA,IAED,GAAI,uBAAwB;AAAA,IAC5B;AAAA,IACA;AAAA,EACD,GACD,GACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,139 @@
1
+ // packages/editor/src/components/post-revisions-panel/index.js
2
+ import {
3
+ PanelBody,
4
+ Button,
5
+ __experimentalHStack as HStack,
6
+ __experimentalVStack as VStack,
7
+ privateApis as componentsPrivateApis
8
+ } from "@wordpress/components";
9
+ import { store as coreStore } from "@wordpress/core-data";
10
+ import { DataViews } from "@wordpress/dataviews";
11
+ import { dateI18n, getDate, humanTimeDiff, getSettings } from "@wordpress/date";
12
+ import { useSelect, useDispatch } from "@wordpress/data";
13
+ import { __ } from "@wordpress/i18n";
14
+ import { authorField } from "@wordpress/fields";
15
+ import PostLastRevisionCheck from "../post-last-revision/check.mjs";
16
+ import { store as editorStore } from "../../store/index.mjs";
17
+ import { unlock } from "../../lock-unlock.mjs";
18
+ import { jsx, jsxs } from "react/jsx-runtime";
19
+ var { Badge } = unlock(componentsPrivateApis);
20
+ var DAY_IN_MILLISECONDS = 864e5;
21
+ var EMPTY_ARRAY = [];
22
+ var REVISIONS_QUERY = {
23
+ per_page: 3,
24
+ orderby: "date",
25
+ order: "desc",
26
+ context: "embed",
27
+ _fields: "id,date,author"
28
+ };
29
+ var defaultLayouts = { activity: {} };
30
+ var view = {
31
+ type: "activity",
32
+ titleField: "date",
33
+ fields: ["author"],
34
+ layout: {
35
+ density: "compact"
36
+ }
37
+ };
38
+ var fields = [
39
+ {
40
+ id: "date",
41
+ label: __("Date"),
42
+ render: ({ item }) => {
43
+ const dateNowInMs = getDate(null).getTime();
44
+ const date = getDate(item.date ?? null);
45
+ const displayDate = dateNowInMs - date.getTime() > DAY_IN_MILLISECONDS ? dateI18n(
46
+ getSettings().formats.datetimeAbbreviated,
47
+ date
48
+ ) : humanTimeDiff(date);
49
+ return /* @__PURE__ */ jsx(
50
+ "time",
51
+ {
52
+ className: "editor-post-revisions-panel__revision-date",
53
+ dateTime: item.date,
54
+ children: displayDate
55
+ }
56
+ );
57
+ },
58
+ enableSorting: false,
59
+ enableHiding: false
60
+ },
61
+ authorField
62
+ ];
63
+ var noop = () => {
64
+ };
65
+ var paginationInfo = {};
66
+ function PostRevisionsPanelContent() {
67
+ const { setCurrentRevisionId } = unlock(useDispatch(editorStore));
68
+ const { revisionsCount, revisions, isLoading, lastRevisionId } = useSelect(
69
+ (select) => {
70
+ const { getCurrentPostId, getCurrentPostType } = select(editorStore);
71
+ const {
72
+ getCurrentPostRevisionsCount,
73
+ getCurrentPostLastRevisionId
74
+ } = select(editorStore);
75
+ const { getRevisions, isResolving } = select(coreStore);
76
+ const query = [
77
+ "postType",
78
+ getCurrentPostType(),
79
+ getCurrentPostId(),
80
+ REVISIONS_QUERY
81
+ ];
82
+ const _revisions = getRevisions(...query);
83
+ return {
84
+ revisionsCount: getCurrentPostRevisionsCount(),
85
+ lastRevisionId: getCurrentPostLastRevisionId(),
86
+ revisions: _revisions,
87
+ isLoading: isResolving("getRevisions", query)
88
+ };
89
+ },
90
+ []
91
+ );
92
+ return /* @__PURE__ */ jsx(
93
+ PanelBody,
94
+ {
95
+ title: /* @__PURE__ */ jsxs(HStack, { justify: "space-between", align: "center", as: "span", children: [
96
+ /* @__PURE__ */ jsx("span", { children: __("Revisions") }),
97
+ /* @__PURE__ */ jsx(Badge, { className: "editor-post-revisions-panel__revisions-count", children: revisionsCount })
98
+ ] }),
99
+ initialOpen: false,
100
+ children: /* @__PURE__ */ jsxs(VStack, { className: "editor-post-revisions-panel", children: [
101
+ /* @__PURE__ */ jsx(
102
+ DataViews,
103
+ {
104
+ view,
105
+ onChangeView: noop,
106
+ fields,
107
+ data: revisions || EMPTY_ARRAY,
108
+ isLoading,
109
+ paginationInfo,
110
+ defaultLayouts,
111
+ getItemId: (item) => item.id,
112
+ isItemClickable: () => true,
113
+ onClickItem: (item) => {
114
+ setCurrentRevisionId(item.id);
115
+ },
116
+ children: /* @__PURE__ */ jsx(DataViews.Layout, {})
117
+ }
118
+ ),
119
+ /* @__PURE__ */ jsx(
120
+ Button,
121
+ {
122
+ className: "editor-post-revisions-panel__view-all",
123
+ __next40pxDefaultSize: true,
124
+ variant: "secondary",
125
+ onClick: () => setCurrentRevisionId(lastRevisionId),
126
+ children: __("View all revisions")
127
+ }
128
+ )
129
+ ] })
130
+ }
131
+ );
132
+ }
133
+ function PostRevisionsPanel() {
134
+ return /* @__PURE__ */ jsx(PostLastRevisionCheck, { children: /* @__PURE__ */ jsx(PostRevisionsPanelContent, {}) });
135
+ }
136
+ export {
137
+ PostRevisionsPanel as default
138
+ };
139
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/post-revisions-panel/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { DataViews } from '@wordpress/dataviews';\nimport { dateI18n, getDate, humanTimeDiff, getSettings } from '@wordpress/date';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { authorField } from '@wordpress/fields';\n\n/**\n * Internal dependencies\n */\nimport PostLastRevisionCheck from '../post-last-revision/check';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { Badge } = unlock( componentsPrivateApis );\nconst DAY_IN_MILLISECONDS = 86400000;\nconst EMPTY_ARRAY = [];\n\nconst REVISIONS_QUERY = {\n\tper_page: 3,\n\torderby: 'date',\n\torder: 'desc',\n\tcontext: 'embed',\n\t_fields: 'id,date,author',\n};\nconst defaultLayouts = { activity: {} };\nconst view = {\n\ttype: 'activity',\n\ttitleField: 'date',\n\tfields: [ 'author' ],\n\tlayout: {\n\t\tdensity: 'compact',\n\t},\n};\nconst fields = [\n\t{\n\t\tid: 'date',\n\t\tlabel: __( 'Date' ),\n\t\trender: ( { item } ) => {\n\t\t\tconst dateNowInMs = getDate( null ).getTime();\n\t\t\tconst date = getDate( item.date ?? null );\n\t\t\tconst displayDate =\n\t\t\t\tdateNowInMs - date.getTime() > DAY_IN_MILLISECONDS\n\t\t\t\t\t? dateI18n(\n\t\t\t\t\t\t\tgetSettings().formats.datetimeAbbreviated,\n\t\t\t\t\t\t\tdate\n\t\t\t\t\t )\n\t\t\t\t\t: humanTimeDiff( date );\n\t\t\treturn (\n\t\t\t\t<time\n\t\t\t\t\tclassName=\"editor-post-revisions-panel__revision-date\"\n\t\t\t\t\tdateTime={ item.date }\n\t\t\t\t>\n\t\t\t\t\t{ displayDate }\n\t\t\t\t</time>\n\t\t\t);\n\t\t},\n\t\tenableSorting: false,\n\t\tenableHiding: false,\n\t},\n\tauthorField,\n];\nconst noop = () => {};\nconst paginationInfo = {};\n\nfunction PostRevisionsPanelContent() {\n\tconst { setCurrentRevisionId } = unlock( useDispatch( editorStore ) );\n\tconst { revisionsCount, revisions, isLoading, lastRevisionId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPostId, getCurrentPostType } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst {\n\t\t\t\tgetCurrentPostRevisionsCount,\n\t\t\t\tgetCurrentPostLastRevisionId,\n\t\t\t} = select( editorStore );\n\t\t\tconst { getRevisions, isResolving } = select( coreStore );\n\t\t\tconst query = [\n\t\t\t\t'postType',\n\t\t\t\tgetCurrentPostType(),\n\t\t\t\tgetCurrentPostId(),\n\t\t\t\tREVISIONS_QUERY,\n\t\t\t];\n\t\t\tconst _revisions = getRevisions( ...query );\n\t\t\treturn {\n\t\t\t\trevisionsCount: getCurrentPostRevisionsCount(),\n\t\t\t\tlastRevisionId: getCurrentPostLastRevisionId(),\n\t\t\t\trevisions: _revisions,\n\t\t\t\tisLoading: isResolving( 'getRevisions', query ),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={\n\t\t\t\t<HStack justify=\"space-between\" align=\"center\" as=\"span\">\n\t\t\t\t\t<span>{ __( 'Revisions' ) }</span>\n\t\t\t\t\t<Badge className=\"editor-post-revisions-panel__revisions-count\">\n\t\t\t\t\t\t{ revisionsCount }\n\t\t\t\t\t</Badge>\n\t\t\t\t</HStack>\n\t\t\t}\n\t\t\tinitialOpen={ false }\n\t\t>\n\t\t\t<VStack className=\"editor-post-revisions-panel\">\n\t\t\t\t<DataViews\n\t\t\t\t\tview={ view }\n\t\t\t\t\tonChangeView={ noop }\n\t\t\t\t\tfields={ fields }\n\t\t\t\t\tdata={ revisions || EMPTY_ARRAY }\n\t\t\t\t\tisLoading={ isLoading }\n\t\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t\t\tgetItemId={ ( item ) => item.id }\n\t\t\t\t\tisItemClickable={ () => true }\n\t\t\t\t\tonClickItem={ ( item ) => {\n\t\t\t\t\t\tsetCurrentRevisionId( item.id );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<DataViews.Layout />\n\t\t\t\t</DataViews>\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"editor-post-revisions-panel__view-all\"\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => setCurrentRevisionId( lastRevisionId ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'View all revisions' ) }\n\t\t\t\t</Button>\n\t\t\t</VStack>\n\t\t</PanelBody>\n\t);\n}\n\nexport default function PostRevisionsPanel() {\n\treturn (\n\t\t<PostLastRevisionCheck>\n\t\t\t<PostRevisionsPanelContent />\n\t\t</PostLastRevisionCheck>\n\t);\n}\n"],
5
+ "mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,eAAe;AAAA,OACT;AACP,SAAS,SAAS,iBAAiB;AACnC,SAAS,iBAAiB;AAC1B,SAAS,UAAU,SAAS,eAAe,mBAAmB;AAC9D,SAAS,WAAW,mBAAmB;AACvC,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAK5B,OAAO,2BAA2B;AAClC,SAAS,SAAS,mBAAmB;AACrC,SAAS,cAAc;AAqCnB,cA8CA,YA9CA;AAnCJ,IAAM,EAAE,MAAM,IAAI,OAAQ,qBAAsB;AAChD,IAAM,sBAAsB;AAC5B,IAAM,cAAc,CAAC;AAErB,IAAM,kBAAkB;AAAA,EACvB,UAAU;AAAA,EACV,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AACV;AACA,IAAM,iBAAiB,EAAE,UAAU,CAAC,EAAE;AACtC,IAAM,OAAO;AAAA,EACZ,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,QAAQ,CAAE,QAAS;AAAA,EACnB,QAAQ;AAAA,IACP,SAAS;AAAA,EACV;AACD;AACA,IAAM,SAAS;AAAA,EACd;AAAA,IACC,IAAI;AAAA,IACJ,OAAO,GAAI,MAAO;AAAA,IAClB,QAAQ,CAAE,EAAE,KAAK,MAAO;AACvB,YAAM,cAAc,QAAS,IAAK,EAAE,QAAQ;AAC5C,YAAM,OAAO,QAAS,KAAK,QAAQ,IAAK;AACxC,YAAM,cACL,cAAc,KAAK,QAAQ,IAAI,sBAC5B;AAAA,QACA,YAAY,EAAE,QAAQ;AAAA,QACtB;AAAA,MACA,IACA,cAAe,IAAK;AACxB,aACC;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;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AAAA,YACxB,aAAc,CAAE,SAAU;AACzB,mCAAsB,KAAK,EAAG;AAAA,YAC/B;AAAA,YAEA,8BAAC,UAAU,QAAV,EAAiB;AAAA;AAAA,QACnB;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,uBAAqB;AAAA,YACrB,SAAQ;AAAA,YACR,SAAU,MAAM,qBAAsB,cAAe;AAAA,YAEnD,aAAI,oBAAqB;AAAA;AAAA,QAC5B;AAAA,SACD;AAAA;AAAA,EACD;AAEF;AAEe,SAAR,qBAAsC;AAC5C,SACC,oBAAC,yBACA,8BAAC,6BAA0B,GAC5B;AAEF;",
6
+ "names": []
7
+ }
@@ -1,5 +1,4 @@
1
1
  // packages/editor/src/components/post-revisions-preview/revisions-slider.js
2
- import { useMemo } from "@wordpress/element";
3
2
  import { useSelect, useDispatch } from "@wordpress/data";
4
3
  import { RangeControl, Spinner } from "@wordpress/components";
5
4
  import { store as coreStore } from "@wordpress/core-data";
@@ -19,10 +18,25 @@ function RevisionsSlider() {
19
18
  return {};
20
19
  }
21
20
  const entityConfig = getEntityConfig("postType", postType);
21
+ const _revisionKey = entityConfig?.revisionKey || "id";
22
22
  const query = {
23
23
  per_page: -1,
24
24
  context: "edit",
25
- _fields: "id,date,author,meta,title.raw,excerpt.raw,content.raw"
25
+ orderby: "date",
26
+ order: "asc",
27
+ _fields: [
28
+ .../* @__PURE__ */ new Set([
29
+ "id",
30
+ "date",
31
+ "modified",
32
+ "author",
33
+ "meta",
34
+ "title.raw",
35
+ "excerpt.raw",
36
+ "content.raw",
37
+ _revisionKey
38
+ ])
39
+ ].join()
26
40
  };
27
41
  return {
28
42
  revisions: getRevisions("postType", postType, postId, query),
@@ -35,27 +49,24 @@ function RevisionsSlider() {
35
49
  currentRevisionId: unlock(
36
50
  select(editorStore)
37
51
  ).getCurrentRevisionId(),
38
- revisionKey: entityConfig?.revisionKey || "id"
52
+ revisionKey: _revisionKey
39
53
  };
40
54
  },
41
55
  []
42
56
  );
43
57
  const { setCurrentRevisionId } = unlock(useDispatch(editorStore));
44
- const sortedRevisions = useMemo(() => {
45
- return revisions?.slice().sort((a, b) => new Date(a.date) - new Date(b.date)) ?? [];
46
- }, [revisions]);
47
- const selectedIndex = sortedRevisions.findIndex(
58
+ const selectedIndex = revisions?.findIndex(
48
59
  (r) => r[revisionKey] === currentRevisionId
49
60
  );
50
61
  const handleSliderChange = (index) => {
51
- const revision = sortedRevisions[index];
62
+ const revision = revisions?.[index];
52
63
  if (revision) {
53
64
  setCurrentRevisionId(revision[revisionKey]);
54
65
  }
55
66
  };
56
67
  const dateSettings = getDateSettings();
57
68
  const renderTooltipContent = (index) => {
58
- const revision = sortedRevisions[index];
69
+ const revision = revisions?.[index];
59
70
  if (!revision) {
60
71
  return index;
61
72
  }
@@ -64,10 +75,10 @@ function RevisionsSlider() {
64
75
  if (isLoading) {
65
76
  return /* @__PURE__ */ jsx(Spinner, {});
66
77
  }
67
- if (!sortedRevisions.length) {
78
+ if (!revisions?.length) {
68
79
  return /* @__PURE__ */ jsx("span", { className: "editor-revisions-header__no-revisions", children: __("No revisions found.") });
69
80
  }
70
- if (sortedRevisions.length === 1) {
81
+ if (revisions?.length === 1) {
71
82
  return /* @__PURE__ */ jsx("span", { className: "editor-revisions-header__no-revisions", children: __("Only one revision found.") });
72
83
  }
73
84
  return /* @__PURE__ */ jsx(
@@ -77,7 +88,7 @@ function RevisionsSlider() {
77
88
  className: "editor-revisions-header__slider",
78
89
  hideLabelFromVision: true,
79
90
  label: __("Revision"),
80
- max: sortedRevisions.length - 1,
91
+ max: revisions?.length - 1,
81
92
  min: 0,
82
93
  marks: true,
83
94
  onChange: handleSliderChange,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/post-revisions-preview/revisions-slider.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { RangeControl, Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { dateI18n, getSettings as getDateSettings } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Slider component for navigating revisions.\n *\n * @return {React.JSX.Element} The revisions slider component.\n */\nfunction RevisionsSlider() {\n\tconst { revisions, isLoading, currentRevisionId, revisionKey } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPostId, getCurrentPostType } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getRevisions, isResolving, getEntityConfig } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst postId = getCurrentPostId();\n\t\t\tconst postType = getCurrentPostType();\n\n\t\t\tif ( ! postId || ! postType ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst entityConfig = getEntityConfig( 'postType', postType );\n\t\t\tconst query = {\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'edit',\n\t\t\t\t_fields:\n\t\t\t\t\t'id,date,author,meta,title.raw,excerpt.raw,content.raw',\n\t\t\t};\n\t\t\treturn {\n\t\t\t\trevisions: getRevisions( 'postType', postType, postId, query ),\n\t\t\t\tisLoading: isResolving( 'getRevisions', [\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t\tcurrentRevisionId: unlock(\n\t\t\t\t\tselect( editorStore )\n\t\t\t\t).getCurrentRevisionId(),\n\t\t\t\trevisionKey: entityConfig?.revisionKey || 'id',\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { setCurrentRevisionId } = unlock( useDispatch( editorStore ) );\n\n\tconst sortedRevisions = useMemo( () => {\n\t\treturn (\n\t\t\trevisions\n\t\t\t\t?.slice()\n\t\t\t\t.sort( ( a, b ) => new Date( a.date ) - new Date( b.date ) ) ??\n\t\t\t[]\n\t\t);\n\t}, [ revisions ] );\n\n\tconst selectedIndex = sortedRevisions.findIndex(\n\t\t( r ) => r[ revisionKey ] === currentRevisionId\n\t);\n\n\tconst handleSliderChange = ( index ) => {\n\t\tconst revision = sortedRevisions[ index ];\n\t\tif ( revision ) {\n\t\t\tsetCurrentRevisionId( revision[ revisionKey ] );\n\t\t}\n\t};\n\n\t// Format date for tooltip.\n\tconst dateSettings = getDateSettings();\n\tconst renderTooltipContent = ( index ) => {\n\t\tconst revision = sortedRevisions[ index ];\n\t\tif ( ! revision ) {\n\t\t\treturn index;\n\t\t}\n\t\treturn dateI18n( dateSettings.formats.datetime, revision.date );\n\t};\n\n\tif ( isLoading ) {\n\t\treturn <Spinner />;\n\t}\n\n\tif ( ! sortedRevisions.length ) {\n\t\treturn (\n\t\t\t<span className=\"editor-revisions-header__no-revisions\">\n\t\t\t\t{ __( 'No revisions found.' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\tif ( sortedRevisions.length === 1 ) {\n\t\treturn (\n\t\t\t<span className=\"editor-revisions-header__no-revisions\">\n\t\t\t\t{ __( 'Only one revision found.' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RangeControl\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"editor-revisions-header__slider\"\n\t\t\thideLabelFromVision\n\t\t\tlabel={ __( 'Revision' ) }\n\t\t\tmax={ sortedRevisions.length - 1 }\n\t\t\tmin={ 0 }\n\t\t\tmarks\n\t\t\tonChange={ handleSliderChange }\n\t\t\trenderTooltipContent={ renderTooltipContent }\n\t\t\tvalue={ selectedIndex }\n\t\t\twithInputField={ false }\n\t\t/>\n\t);\n}\n\nexport default RevisionsSlider;\n"],
5
- "mappings": ";AAGA,SAAS,eAAe;AACxB,SAAS,WAAW,mBAAmB;AACvC,SAAS,cAAc,eAAe;AACtC,SAAS,SAAS,iBAAiB;AACnC,SAAS,UAAU;AACnB,SAAS,UAAU,eAAe,uBAAuB;AAKz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AAsB,SAAU,WAAY,CAAE;AAAA,IAC/C;AAAA,EACD;AAGA,QAAM,eAAe,gBAAgB;AACrC,QAAM,uBAAuB,CAAE,UAAW;AACzC,UAAM,WAAW,gBAAiB,KAAM;AACxC,QAAK,CAAE,UAAW;AACjB,aAAO;AAAA,IACR;AACA,WAAO,SAAU,aAAa,QAAQ,UAAU,SAAS,IAAK;AAAA,EAC/D;AAEA,MAAK,WAAY;AAChB,WAAO,oBAAC,WAAQ;AAAA,EACjB;AAEA,MAAK,CAAE,gBAAgB,QAAS;AAC/B,WACC,oBAAC,UAAK,WAAU,yCACb,aAAI,qBAAsB,GAC7B;AAAA,EAEF;AAEA,MAAK,gBAAgB,WAAW,GAAI;AACnC,WACC,oBAAC,UAAK,WAAU,yCACb,aAAI,0BAA2B,GAClC;AAAA,EAEF;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,uBAAqB;AAAA,MACrB,WAAU;AAAA,MACV,qBAAmB;AAAA,MACnB,OAAQ,GAAI,UAAW;AAAA,MACvB,KAAM,gBAAgB,SAAS;AAAA,MAC/B,KAAM;AAAA,MACN,OAAK;AAAA,MACL,UAAW;AAAA,MACX;AAAA,MACA,OAAQ;AAAA,MACR,gBAAiB;AAAA;AAAA,EAClB;AAEF;AAEA,IAAO,2BAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { RangeControl, Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { dateI18n, getSettings as getDateSettings } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Slider component for navigating revisions.\n *\n * @return {React.JSX.Element} The revisions slider component.\n */\nfunction RevisionsSlider() {\n\tconst { revisions, isLoading, currentRevisionId, revisionKey } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPostId, getCurrentPostType } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getRevisions, isResolving, getEntityConfig } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst postId = getCurrentPostId();\n\t\t\tconst postType = getCurrentPostType();\n\n\t\t\tif ( ! postId || ! postType ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst entityConfig = getEntityConfig( 'postType', postType );\n\t\t\tconst _revisionKey = entityConfig?.revisionKey || 'id';\n\t\t\tconst query = {\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'edit',\n\t\t\t\torderby: 'date',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: [\n\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t'id',\n\t\t\t\t\t\t'date',\n\t\t\t\t\t\t'modified',\n\t\t\t\t\t\t'author',\n\t\t\t\t\t\t'meta',\n\t\t\t\t\t\t'title.raw',\n\t\t\t\t\t\t'excerpt.raw',\n\t\t\t\t\t\t'content.raw',\n\t\t\t\t\t\t_revisionKey,\n\t\t\t\t\t] ),\n\t\t\t\t].join(),\n\t\t\t};\n\t\t\treturn {\n\t\t\t\trevisions: getRevisions( 'postType', postType, postId, query ),\n\t\t\t\tisLoading: isResolving( 'getRevisions', [\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t\tcurrentRevisionId: unlock(\n\t\t\t\t\tselect( editorStore )\n\t\t\t\t).getCurrentRevisionId(),\n\t\t\t\trevisionKey: _revisionKey,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { setCurrentRevisionId } = unlock( useDispatch( editorStore ) );\n\n\tconst selectedIndex = revisions?.findIndex(\n\t\t( r ) => r[ revisionKey ] === currentRevisionId\n\t);\n\n\tconst handleSliderChange = ( index ) => {\n\t\tconst revision = revisions?.[ index ];\n\t\tif ( revision ) {\n\t\t\tsetCurrentRevisionId( revision[ revisionKey ] );\n\t\t}\n\t};\n\n\t// Format date for tooltip.\n\tconst dateSettings = getDateSettings();\n\tconst renderTooltipContent = ( index ) => {\n\t\tconst revision = revisions?.[ index ];\n\t\tif ( ! revision ) {\n\t\t\treturn index;\n\t\t}\n\t\treturn dateI18n( dateSettings.formats.datetime, revision.date );\n\t};\n\n\tif ( isLoading ) {\n\t\treturn <Spinner />;\n\t}\n\n\tif ( ! revisions?.length ) {\n\t\treturn (\n\t\t\t<span className=\"editor-revisions-header__no-revisions\">\n\t\t\t\t{ __( 'No revisions found.' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\tif ( revisions?.length === 1 ) {\n\t\treturn (\n\t\t\t<span className=\"editor-revisions-header__no-revisions\">\n\t\t\t\t{ __( 'Only one revision found.' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RangeControl\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"editor-revisions-header__slider\"\n\t\t\thideLabelFromVision\n\t\t\tlabel={ __( 'Revision' ) }\n\t\t\tmax={ revisions?.length - 1 }\n\t\t\tmin={ 0 }\n\t\t\tmarks\n\t\t\tonChange={ handleSliderChange }\n\t\t\trenderTooltipContent={ renderTooltipContent }\n\t\t\tvalue={ selectedIndex }\n\t\t\twithInputField={ false }\n\t\t/>\n\t);\n}\n\nexport default RevisionsSlider;\n"],
5
+ "mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,cAAc,eAAe;AACtC,SAAS,SAAS,iBAAiB;AACnC,SAAS,UAAU;AACnB,SAAS,UAAU,eAAe,uBAAuB;AAKzD,SAAS,SAAS,mBAAmB;AACrC,SAAS,cAAc;AAoFd;AA7ET,SAAS,kBAAkB;AAC1B,QAAM,EAAE,WAAW,WAAW,mBAAmB,YAAY,IAAI;AAAA,IAChE,CAAE,WAAY;AACb,YAAM,EAAE,kBAAkB,mBAAmB,IAC5C,OAAQ,WAAY;AACrB,YAAM,EAAE,cAAc,aAAa,gBAAgB,IAClD,OAAQ,SAAU;AAE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/D;AAEA,MAAK,WAAY;AAChB,WAAO,oBAAC,WAAQ;AAAA,EACjB;AAEA,MAAK,CAAE,WAAW,QAAS;AAC1B,WACC,oBAAC,UAAK,WAAU,yCACb,aAAI,qBAAsB,GAC7B;AAAA,EAEF;AAEA,MAAK,WAAW,WAAW,GAAI;AAC9B,WACC,oBAAC,UAAK,WAAU,yCACb,aAAI,0BAA2B,GAClC;AAAA,EAEF;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,uBAAqB;AAAA,MACrB,WAAU;AAAA,MACV,qBAAmB;AAAA,MACnB,OAAQ,GAAI,UAAW;AAAA,MACvB,KAAM,WAAW,SAAS;AAAA,MAC1B,KAAM;AAAA,MACN,OAAK;AAAA,MACL,UAAW;AAAA,MACX;AAAA,MACA,OAAQ;AAAA,MACR,gBAAiB;AAAA;AAAA,EAClB;AAEF;AAEA,IAAO,2BAAQ;",
6
6
  "names": []
7
7
  }
@@ -92,52 +92,45 @@ function CreateNewTemplateModal({ onClose }) {
92
92
  focusOnMount: "firstContentElement",
93
93
  size: "small",
94
94
  overlayClassName: "editor-post-template__create-template-modal",
95
- children: /* @__PURE__ */ jsx(
96
- "form",
97
- {
98
- className: "editor-post-template__create-form",
99
- onSubmit: submit,
100
- children: /* @__PURE__ */ jsxs(VStack, { spacing: "3", children: [
101
- /* @__PURE__ */ jsx(
102
- TextControl,
103
- {
104
- __next40pxDefaultSize: true,
105
- label: __("Name"),
106
- value: title,
107
- onChange: setTitle,
108
- placeholder: DEFAULT_TITLE,
109
- disabled: isBusy,
110
- help: __(
111
- // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
112
- 'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.'
113
- )
114
- }
115
- ),
116
- /* @__PURE__ */ jsxs(HStack, { justify: "right", children: [
117
- /* @__PURE__ */ jsx(
118
- Button,
119
- {
120
- __next40pxDefaultSize: true,
121
- variant: "tertiary",
122
- onClick: cancel,
123
- children: __("Cancel")
124
- }
125
- ),
126
- /* @__PURE__ */ jsx(
127
- Button,
128
- {
129
- __next40pxDefaultSize: true,
130
- variant: "primary",
131
- type: "submit",
132
- isBusy,
133
- "aria-disabled": isBusy,
134
- children: __("Create")
135
- }
136
- )
137
- ] })
138
- ] })
139
- }
140
- )
95
+ children: /* @__PURE__ */ jsx("form", { onSubmit: submit, children: /* @__PURE__ */ jsxs(VStack, { spacing: "3", children: [
96
+ /* @__PURE__ */ jsx(
97
+ TextControl,
98
+ {
99
+ __next40pxDefaultSize: true,
100
+ label: __("Name"),
101
+ value: title,
102
+ onChange: setTitle,
103
+ placeholder: DEFAULT_TITLE,
104
+ disabled: isBusy,
105
+ help: __(
106
+ // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
107
+ 'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.'
108
+ )
109
+ }
110
+ ),
111
+ /* @__PURE__ */ jsxs(HStack, { justify: "right", children: [
112
+ /* @__PURE__ */ jsx(
113
+ Button,
114
+ {
115
+ __next40pxDefaultSize: true,
116
+ variant: "tertiary",
117
+ onClick: cancel,
118
+ children: __("Cancel")
119
+ }
120
+ ),
121
+ /* @__PURE__ */ jsx(
122
+ Button,
123
+ {
124
+ __next40pxDefaultSize: true,
125
+ variant: "primary",
126
+ type: "submit",
127
+ isBusy,
128
+ "aria-disabled": isBusy,
129
+ children: __("Create")
130
+ }
131
+ )
132
+ ] })
133
+ ] }) })
141
134
  }
142
135
  );
143
136
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/post-template/create-new-template-modal.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\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';\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: kebabCase( title || DEFAULT_TITLE ) || 'wp-custom-template',\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || DEFAULT_TITLE,\n\t\t\tstatus: 'publish',\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\toverlayClassName=\"editor-post-template__create-template-modal\"\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\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// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts\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\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\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"],
5
- "mappings": ";AAGA,SAAS,aAAa,iBAAiB;AAKvC,SAAS,WAAW,mBAAmB;AACvC,SAAS,gBAAgB;AACzB,SAAS,WAAW,mBAAmB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP,SAAS,UAAU;AAKnB,SAAS,cAAc;AACvB,SAAS,SAAS,mBAAmB;AAqGhC,cAYA,YAZA;AAnGL,IAAM,gBAAgB,GAAI,iBAAkB;AAE7B,SAAR,uBAAyC,EAAE,QAAQ,GAAI;AAC7D,QAAM,EAAE,sBAAsB,yBAAyB,IAAI;AAAA,IAC1D,CAAE,WAAY;AACb,YAAM,EAAE,mBAAmB,qBAAqB,IAC/C,OAAQ,WAAY;AACrB,aAAO;AAAA,QACN,sBAAsB,kBAAkB,EAAE;AAAA,QAC1C,0BACC,kBAAkB,EAAE;AAAA,QACrB,eAAe;AAAA,MAChB;AAAA,IACD;AAAA,EACD;AA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AAA,MACjB,cAAa;AAAA,MACb,MAAK;AAAA,MACL,kBAAiB;AAAA,MAEjB;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,UAAW;AAAA,UAEX,+BAAC,UAAO,SAAQ,KACf;AAAA;AAAA,cAAC;AAAA;AAAA,gBACA,uBAAqB;AAAA,gBACrB,OAAQ,GAAI,MAAO;AAAA,gBACnB,OAAQ;AAAA,gBACR,UAAW;AAAA,gBACX,aAAc;AAAA,gBACd,UAAW;AAAA,gBACX,MAAO;AAAA;AAAA,kBAEN;AAAA,gBACD;AAAA;AAAA,YACD;AAAA,YACA,qBAAC,UAAO,SAAQ,SACf;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACA,uBAAqB;AAAA,kBACrB,SAAQ;AAAA,kBACR,SAAU;AAAA,kBAER,aAAI,QAAS;AAAA;AAAA,cAChB;AAAA,cAEA;AAAA,gBAAC;AAAA;AAAA,kBACA,uBAAqB;AAAA,kBACrB,SAAQ;AAAA,kBACR,MAAK;AAAA,kBACL;AAAA,kBACA,iBAAgB;AAAA,kBAEd,aAAI,QAAS;AAAA;AAAA,cAChB;AAAA,eACD;AAAA,aACD;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\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';\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: kebabCase( title || DEFAULT_TITLE ) || 'wp-custom-template',\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || DEFAULT_TITLE,\n\t\t\tstatus: 'publish',\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\toverlayClassName=\"editor-post-template__create-template-modal\"\n\t\t>\n\t\t\t<form onSubmit={ submit }>\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\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// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts\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\t\t\t\t<Button\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A,YACD;AAAA;AAAA,QACD;AAAA,QACA,qBAAC,UAAO,SAAQ,SACf;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,SAAU;AAAA,cAER,aAAI,QAAS;AAAA;AAAA,UAChB;AAAA,UAEA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,MAAK;AAAA,cACL;AAAA,cACA,iBAAgB;AAAA,cAEd,aAAI,QAAS;AAAA;AAAA,UAChB;AAAA,WACD;AAAA,SACD,GACD;AAAA;AAAA,EACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,8 @@
1
1
  // packages/editor/src/components/post-template/hooks.js
2
2
  import { useSelect } from "@wordpress/data";
3
3
  import { useMemo } from "@wordpress/element";
4
- import { store as coreStore } from "@wordpress/core-data";
4
+ import { useEntityProp, store as coreStore } from "@wordpress/core-data";
5
+ import { __, sprintf } from "@wordpress/i18n";
5
6
  import { store as editorStore } from "../../store/index.mjs";
6
7
  function useEditedPostContext() {
7
8
  return useSelect((select) => {
@@ -43,16 +44,61 @@ function useTemplates(postType) {
43
44
  [postType]
44
45
  );
45
46
  }
46
- function useAvailableTemplates(postType) {
47
+ function useAvailableTemplates() {
48
+ const { postType, postId } = useEditedPostContext();
49
+ const [postSlug] = useEntityProp("postType", postType, "slug", postId);
47
50
  const currentTemplateSlug = useCurrentTemplateSlug();
48
51
  const allowSwitchingTemplate = useAllowSwitchingTemplates();
49
52
  const templates = useTemplates(postType);
53
+ const defaultTemplate = useSelect(
54
+ (select) => {
55
+ if (!window?.__experimentalDataFormInspector) {
56
+ return null;
57
+ }
58
+ if (!currentTemplateSlug) {
59
+ return null;
60
+ }
61
+ const { getDefaultTemplateId, getEntityRecord } = select(coreStore);
62
+ let slug;
63
+ if (postSlug) {
64
+ slug = postType === "page" ? `${postType}-${postSlug}` : `single-${postType}-${postSlug}`;
65
+ } else {
66
+ slug = postType === "page" ? "page" : `single-${postType}`;
67
+ }
68
+ const templateId = getDefaultTemplateId({ slug });
69
+ if (!templateId) {
70
+ return null;
71
+ }
72
+ return getEntityRecord("postType", "wp_template", templateId);
73
+ },
74
+ [currentTemplateSlug, postSlug, postType]
75
+ );
50
76
  return useMemo(
51
- () => allowSwitchingTemplate && templates?.filter(
52
- (template) => template.is_custom && template.slug !== currentTemplateSlug && !!template.content.raw
53
- // Skip empty templates.
54
- ),
55
- [templates, currentTemplateSlug, allowSwitchingTemplate]
77
+ () => allowSwitchingTemplate && [
78
+ ...(templates || []).filter(
79
+ (template) => template.is_custom && template.slug !== currentTemplateSlug && !!template.content.raw
80
+ // Skip empty templates.
81
+ ),
82
+ defaultTemplate && {
83
+ ...defaultTemplate,
84
+ title: {
85
+ rendered: sprintf(
86
+ // translators: %s: Template name
87
+ __("%s (default)"),
88
+ defaultTemplate.title.rendered
89
+ )
90
+ },
91
+ // That's extra custom prop in order to update to an empty template
92
+ // when we select the default template.
93
+ isDefault: true
94
+ }
95
+ ].filter(Boolean),
96
+ [
97
+ templates,
98
+ defaultTemplate,
99
+ currentTemplateSlug,
100
+ allowSwitchingTemplate
101
+ ]
56
102
  );
57
103
  }
58
104
  function usePostTemplatePanelMode() {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/post-template/hooks.js"],
4
- "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\n\t\t\tconst isPostsPage = +postId === siteSettings?.page_for_posts;\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' && +postId === siteSettings?.page_on_front;\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 templates = isFrontPage\n\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t } )\n\t\t\t\t: [];\n\t\t\tconst hasFrontPage =\n\t\t\t\tisFrontPage &&\n\t\t\t\t!! templates?.some( ( { slug } ) => slug === 'front-page' );\n\t\t\treturn ! isPostsPage && ! hasFrontPage;\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\t// We look at the combined templates for now (old endpoint)\n\t\t\t\t// because posts only accept slugs for templates, not IDs.\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 usePostTemplatePanelMode() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getEditorSettings, getCurrentTemplateId, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst { getPostType, canUser } = select( coreStore );\n\t\tconst postTypeSlug = getCurrentPostType();\n\t\tconst postType = getPostType( postTypeSlug );\n\t\tconst settings = getEditorSettings();\n\t\tconst isBlockTheme = settings.__unstableIsBlockBasedTheme;\n\t\tconst hasTemplates =\n\t\t\t!! settings.availableTemplates &&\n\t\t\tObject.keys( settings.availableTemplates ).length > 0;\n\t\tlet isVisible;\n\t\tif ( ! postType?.viewable ) {\n\t\t\tisVisible = false;\n\t\t} else if ( hasTemplates ) {\n\t\t\tisVisible = true;\n\t\t} else if ( ! settings.supportsTemplateMode ) {\n\t\t\tisVisible = false;\n\t\t} else {\n\t\t\tisVisible =\n\t\t\t\tcanUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template',\n\t\t\t\t} ) ?? false;\n\t\t}\n\t\tconst canViewTemplates = isVisible\n\t\t\t? !! canUser( 'read', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template',\n\t\t\t } )\n\t\t\t: false;\n\t\tif ( ( ! isBlockTheme || ! canViewTemplates ) && isVisible ) {\n\t\t\treturn 'classic';\n\t\t}\n\t\tif ( isBlockTheme && !! getCurrentTemplateId() ) {\n\t\t\treturn 'block-theme';\n\t\t}\n\t\treturn null;\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"],
5
- "mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,SAAS,iBAAiB;AAKnC,SAAS,SAAS,mBAAmB;AAE9B,SAAS,uBAAuB;AACtC,SAAO,UAAW,CAAE,WAAY;AAC/B,UAAM,EAAE,kBAAkB,mBAAmB,IAAI,OAAQ,WAAY;AACrE,WAAO;AAAA,MACN,QAAQ,iBAAiB;AAAA,MACzB,UAAU,mBAAmB;AAAA,IAC9B;AAAA,EACD,GAAG,CAAC,CAAE;AACP;AACO,SAAS,6BAA6B;AAC5C,QAAM,EAAE,UAAU,OAAO,IAAI,qBAAqB;AAClD,SAAO;AAAA,IACN,CAAE,WAAY;AACb,YAAM,EAAE,SAAS,iBAAiB,iBAAiB,IAClD,OAAQ,SAAU;AACnB,YAAM,eAAe,QAAS,QAAQ;AAAA,QACrC,MAAM;AAAA,QACN,MAAM;AAAA,MACP,CAAE,IACC,gBAAiB,QAAQ,MAAO,IAChC;AAEH,YAAM,cAAc,CAAC,WAAW,cAAc;AAC9C,YAAM,cACL,aAAa,UAAU,CAAC,WAAW,cAAc;AAGlD,YAAM,YAAY,cACf,iBAAkB,YAAY,eAAe;AAAA,QAC7C,UAAU;AAAA,MACV,CAAE,IACF,CAAC;AACJ,YAAM,eACL,eACA,CAAC,CAAE,WAAW,KAAM,CAAE,EAAE,KAAK,MAAO,SAAS,YAAa;AAC3D,aAAO,CAAE,eAAe,CAAE;AAAA,IAC3B;AAAA,IACA,CAAE,QAAQ,QAAS;AAAA,EACpB;AACD;AAEA,SAAS,aAAc,UAAW;AACjC,SAAO;AAAA,IACN,CAAE,WACD,OAAQ,SAAU,EAAE,iBAAkB,YAAY,eAAe;AAAA,MAChE,UAAU;AAAA,MACV,W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A,IACR;AACA,WAAO;AAAA,EACR,GAAG,CAAC,CAAE;AACP;AAEO,SAAS,yBAAyB;AACxC,QAAM,EAAE,UAAU,OAAO,IAAI,qBAAqB;AAClD,QAAM,YAAY,aAAc,QAAS;AACzC,QAAM,iBAAiB;AAAA,IACtB,CAAE,WAAY;AACb,YAAM,OAAO,OAAQ,SAAU,EAAE;AAAA,QAChC;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,aAAO,MAAM;AAAA,IACd;AAAA,IACA,CAAE,UAAU,MAAO;AAAA,EACpB;AAEA,MAAK,CAAE,gBAAiB;AACvB;AAAA,EACD;AAIA,SAAO,WAAW,KAAM,CAAE,aAAc,SAAS,SAAS,cAAe,GACtE;AACJ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\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\n\t\t\tconst isPostsPage = +postId === siteSettings?.page_for_posts;\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' && +postId === siteSettings?.page_on_front;\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 templates = isFrontPage\n\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t } )\n\t\t\t\t: [];\n\t\t\tconst hasFrontPage =\n\t\t\t\tisFrontPage &&\n\t\t\t\t!! templates?.some( ( { slug } ) => slug === 'front-page' );\n\t\t\treturn ! isPostsPage && ! hasFrontPage;\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\t// We look at the combined templates for now (old endpoint)\n\t\t\t\t// because posts only accept slugs for templates, not IDs.\n\t\t\t} ),\n\t\t[ postType ]\n\t);\n}\n\nexport function useAvailableTemplates() {\n\tconst { postType, postId } = useEditedPostContext();\n\tconst [ postSlug ] = useEntityProp( 'postType', postType, 'slug', postId );\n\tconst currentTemplateSlug = useCurrentTemplateSlug();\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst templates = useTemplates( postType );\n\t// Add the default template to the available ones. We don't care about\n\t// possible assignment to postspage/homepage because it's guarded by\n\t// `allowSwitchingTemplate` above.\n\tconst defaultTemplate = useSelect(\n\t\t( select ) => {\n\t\t\t// Only append the default template if the experiment is enabled.\n\t\t\tif ( ! window?.__experimentalDataFormInspector ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t// If the default template is already assigned, no need\n\t\t\t// to add it to the available templates.\n\t\t\tif ( ! currentTemplateSlug ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst { getDefaultTemplateId, getEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tlet slug;\n\t\t\tif ( postSlug ) {\n\t\t\t\tslug =\n\t\t\t\t\tpostType === 'page'\n\t\t\t\t\t\t? `${ postType }-${ postSlug }`\n\t\t\t\t\t\t: `single-${ postType }-${ postSlug }`;\n\t\t\t} else {\n\t\t\t\tslug = postType === 'page' ? 'page' : `single-${ postType }`;\n\t\t\t}\n\t\t\tconst templateId = getDefaultTemplateId( { slug } );\n\t\t\tif ( ! templateId ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn getEntityRecord( 'postType', 'wp_template', templateId );\n\t\t},\n\t\t[ currentTemplateSlug, postSlug, postType ]\n\t);\n\treturn useMemo(\n\t\t() =>\n\t\t\tallowSwitchingTemplate &&\n\t\t\t[\n\t\t\t\t...( templates || [] ).filter(\n\t\t\t\t\t( template ) =>\n\t\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\t\ttemplate.slug !== currentTemplateSlug &&\n\t\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t\t),\n\t\t\t\tdefaultTemplate && {\n\t\t\t\t\t...defaultTemplate,\n\t\t\t\t\ttitle: {\n\t\t\t\t\t\trendered: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Template name\n\t\t\t\t\t\t\t__( '%s (default)' ),\n\t\t\t\t\t\t\tdefaultTemplate.title.rendered\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t\t// That's extra custom prop in order to update to an empty template\n\t\t\t\t\t// when we select the default template.\n\t\t\t\t\tisDefault: true,\n\t\t\t\t},\n\t\t\t].filter( Boolean ),\n\t\t[\n\t\t\ttemplates,\n\t\t\tdefaultTemplate,\n\t\t\tcurrentTemplateSlug,\n\t\t\tallowSwitchingTemplate,\n\t\t]\n\t);\n}\n\nexport function usePostTemplatePanelMode() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getEditorSettings, getCurrentTemplateId, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst { getPostType, canUser } = select( coreStore );\n\t\tconst postTypeSlug = getCurrentPostType();\n\t\tconst postType = getPostType( postTypeSlug );\n\t\tconst settings = getEditorSettings();\n\t\tconst isBlockTheme = settings.__unstableIsBlockBasedTheme;\n\t\tconst hasTemplates =\n\t\t\t!! settings.availableTemplates &&\n\t\t\tObject.keys( settings.availableTemplates ).length > 0;\n\t\tlet isVisible;\n\t\tif ( ! postType?.viewable ) {\n\t\t\tisVisible = false;\n\t\t} else if ( hasTemplates ) {\n\t\t\tisVisible = true;\n\t\t} else if ( ! settings.supportsTemplateMode ) {\n\t\t\tisVisible = false;\n\t\t} else {\n\t\t\tisVisible =\n\t\t\t\tcanUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template',\n\t\t\t\t} ) ?? false;\n\t\t}\n\t\tconst canViewTemplates = isVisible\n\t\t\t? !! canUser( 'read', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template',\n\t\t\t } )\n\t\t\t: false;\n\t\tif ( ( ! isBlockTheme || ! canViewTemplates ) && isVisible ) {\n\t\t\treturn 'classic';\n\t\t}\n\t\tif ( isBlockTheme && !! getCurrentTemplateId() ) {\n\t\t\treturn 'block-theme';\n\t\t}\n\t\treturn null;\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"],
5
+ "mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,eAAe,SAAS,iBAAiB;AAClD,SAAS,IAAI,eAAe;AAK5B,SAAS,SAAS,mBAAmB;AAE9B,SAAS,u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