@wordpress/editor 14.41.2-next.v.202603161435.0 → 14.43.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 (311) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/build/components/collaborators-overlay/compute-selection.cjs +10 -10
  3. package/build/components/collaborators-overlay/compute-selection.cjs.map +2 -2
  4. package/build/components/collaborators-overlay/cursor-registry.cjs +86 -0
  5. package/build/components/collaborators-overlay/cursor-registry.cjs.map +7 -0
  6. package/build/components/collaborators-overlay/index.cjs +7 -2
  7. package/build/components/collaborators-overlay/index.cjs.map +2 -2
  8. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +1 -1
  9. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +2 -2
  10. package/build/components/collaborators-overlay/overlay.cjs +42 -1
  11. package/build/components/collaborators-overlay/overlay.cjs.map +2 -2
  12. package/build/components/collaborators-overlay/timing-utils.cjs +46 -0
  13. package/build/components/collaborators-overlay/timing-utils.cjs.map +7 -0
  14. package/build/components/collaborators-overlay/use-render-cursors.cjs +1 -1
  15. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +2 -2
  16. package/build/components/collaborators-presence/index.cjs +14 -4
  17. package/build/components/collaborators-presence/index.cjs.map +2 -2
  18. package/build/components/collaborators-presence/list.cjs +20 -4
  19. package/build/components/collaborators-presence/list.cjs.map +2 -2
  20. package/build/components/post-card-panel/index.cjs +4 -15
  21. package/build/components/post-card-panel/index.cjs.map +2 -2
  22. package/build/components/post-content-information/index.cjs +10 -13
  23. package/build/components/post-content-information/index.cjs.map +2 -2
  24. package/build/components/post-locked-modal/index.cjs +16 -3
  25. package/build/components/post-locked-modal/index.cjs.map +2 -2
  26. package/build/components/post-revisions-panel/index.cjs +164 -0
  27. package/build/components/post-revisions-panel/index.cjs.map +7 -0
  28. package/build/components/post-revisions-preview/block-diff.cjs +39 -11
  29. package/build/components/post-revisions-preview/block-diff.cjs.map +2 -2
  30. package/build/components/post-revisions-preview/diff-markers.cjs +2 -2
  31. package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
  32. package/build/components/post-revisions-preview/revisions-canvas.cjs +1 -1
  33. package/build/components/post-revisions-preview/revisions-canvas.cjs.map +2 -2
  34. package/build/components/post-revisions-preview/revisions-slider.cjs +24 -5
  35. package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
  36. package/build/components/post-template/block-theme.cjs +7 -4
  37. package/build/components/post-template/block-theme.cjs.map +2 -2
  38. package/build/components/post-template/create-new-template-modal.cjs +39 -46
  39. package/build/components/post-template/create-new-template-modal.cjs.map +2 -2
  40. package/build/components/post-template/hooks.cjs +91 -8
  41. package/build/components/post-template/hooks.cjs.map +2 -2
  42. package/build/components/post-template/panel.cjs +5 -42
  43. package/build/components/post-template/panel.cjs.map +3 -3
  44. package/build/components/post-template/swap-template-button.cjs +31 -20
  45. package/build/components/post-template/swap-template-button.cjs.map +2 -2
  46. package/build/components/preferences-modal/index.cjs +35 -27
  47. package/build/components/preferences-modal/index.cjs.map +2 -2
  48. package/build/components/provider/use-block-editor-settings.cjs +2 -0
  49. package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
  50. package/build/components/revision-block-diff/index.cjs +61 -0
  51. package/build/components/revision-block-diff/index.cjs.map +7 -0
  52. package/build/components/revision-diff-panel/index.cjs +68 -0
  53. package/build/components/revision-diff-panel/index.cjs.map +7 -0
  54. package/build/components/revision-fields-diff/index.cjs +96 -0
  55. package/build/components/revision-fields-diff/index.cjs.map +7 -0
  56. package/build/components/sidebar/dataform-post-summary.cjs +25 -55
  57. package/build/components/sidebar/dataform-post-summary.cjs.map +2 -2
  58. package/build/components/sidebar/index.cjs +30 -23
  59. package/build/components/sidebar/index.cjs.map +3 -3
  60. package/build/components/sidebar/post-revision-summary.cjs +74 -0
  61. package/build/components/sidebar/post-revision-summary.cjs.map +7 -0
  62. package/build/components/sidebar/post-summary.cjs +35 -42
  63. package/build/components/sidebar/post-summary.cjs.map +3 -3
  64. package/build/components/style-book/index.cjs +4 -3
  65. package/build/components/style-book/index.cjs.map +2 -2
  66. package/build/components/{sync-connection-modal → sync-connection-error-modal}/index.cjs +89 -80
  67. package/build/components/sync-connection-error-modal/index.cjs.map +7 -0
  68. package/build/components/{sync-connection-modal → sync-connection-error-modal}/use-retry-countdown.cjs +14 -27
  69. package/build/components/sync-connection-error-modal/use-retry-countdown.cjs.map +7 -0
  70. package/build/components/template-actions-panel/block-theme-content.cjs +188 -0
  71. package/build/components/template-actions-panel/block-theme-content.cjs.map +7 -0
  72. package/build/components/template-actions-panel/classic-theme-content.cjs +159 -0
  73. package/build/components/template-actions-panel/classic-theme-content.cjs.map +7 -0
  74. package/build/components/template-actions-panel/index.cjs +59 -0
  75. package/build/components/template-actions-panel/index.cjs.map +7 -0
  76. package/build/components/visual-editor/index.cjs +2 -2
  77. package/build/components/visual-editor/index.cjs.map +2 -2
  78. package/build/dataviews/store/private-actions.cjs +2 -0
  79. package/build/dataviews/store/private-actions.cjs.map +2 -2
  80. package/build/store/actions.cjs +1 -3
  81. package/build/store/actions.cjs.map +2 -2
  82. package/build/store/private-actions.cjs +21 -2
  83. package/build/store/private-actions.cjs.map +2 -2
  84. package/build/store/private-selectors.cjs +40 -15
  85. package/build/store/private-selectors.cjs.map +2 -2
  86. package/build/utils/media-finalize/index.cjs +43 -0
  87. package/build/utils/media-finalize/index.cjs.map +7 -0
  88. package/build/utils/sync-error-messages.cjs +29 -16
  89. package/build/utils/sync-error-messages.cjs.map +3 -3
  90. package/build-module/components/collaborators-overlay/compute-selection.mjs +10 -10
  91. package/build-module/components/collaborators-overlay/compute-selection.mjs.map +2 -2
  92. package/build-module/components/collaborators-overlay/cursor-registry.mjs +61 -0
  93. package/build-module/components/collaborators-overlay/cursor-registry.mjs.map +7 -0
  94. package/build-module/components/collaborators-overlay/index.mjs +7 -2
  95. package/build-module/components/collaborators-overlay/index.mjs.map +2 -2
  96. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +1 -1
  97. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +2 -2
  98. package/build-module/components/collaborators-overlay/overlay.mjs +43 -2
  99. package/build-module/components/collaborators-overlay/overlay.mjs.map +2 -2
  100. package/build-module/components/collaborators-overlay/timing-utils.mjs +21 -0
  101. package/build-module/components/collaborators-overlay/timing-utils.mjs.map +7 -0
  102. package/build-module/components/collaborators-overlay/use-render-cursors.mjs +1 -1
  103. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  104. package/build-module/components/collaborators-presence/index.mjs +14 -4
  105. package/build-module/components/collaborators-presence/index.mjs.map +2 -2
  106. package/build-module/components/collaborators-presence/list.mjs +20 -4
  107. package/build-module/components/collaborators-presence/list.mjs.map +2 -2
  108. package/build-module/components/post-card-panel/index.mjs +6 -17
  109. package/build-module/components/post-card-panel/index.mjs.map +2 -2
  110. package/build-module/components/post-content-information/index.mjs +6 -13
  111. package/build-module/components/post-content-information/index.mjs.map +2 -2
  112. package/build-module/components/post-locked-modal/index.mjs +16 -3
  113. package/build-module/components/post-locked-modal/index.mjs.map +2 -2
  114. package/build-module/components/post-revisions-panel/index.mjs +139 -0
  115. package/build-module/components/post-revisions-panel/index.mjs.map +7 -0
  116. package/build-module/components/post-revisions-preview/block-diff.mjs +39 -11
  117. package/build-module/components/post-revisions-preview/block-diff.mjs.map +2 -2
  118. package/build-module/components/post-revisions-preview/diff-markers.mjs +2 -2
  119. package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
  120. package/build-module/components/post-revisions-preview/revisions-canvas.mjs +1 -1
  121. package/build-module/components/post-revisions-preview/revisions-canvas.mjs.map +2 -2
  122. package/build-module/components/post-revisions-preview/revisions-slider.mjs +24 -5
  123. package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
  124. package/build-module/components/post-template/block-theme.mjs +7 -4
  125. package/build-module/components/post-template/block-theme.mjs.map +2 -2
  126. package/build-module/components/post-template/create-new-template-modal.mjs +39 -46
  127. package/build-module/components/post-template/create-new-template-modal.mjs.map +2 -2
  128. package/build-module/components/post-template/hooks.mjs +90 -8
  129. package/build-module/components/post-template/hooks.mjs.map +2 -2
  130. package/build-module/components/post-template/panel.mjs +5 -42
  131. package/build-module/components/post-template/panel.mjs.map +2 -2
  132. package/build-module/components/post-template/swap-template-button.mjs +27 -20
  133. package/build-module/components/post-template/swap-template-button.mjs.map +2 -2
  134. package/build-module/components/preferences-modal/index.mjs +35 -27
  135. package/build-module/components/preferences-modal/index.mjs.map +2 -2
  136. package/build-module/components/provider/use-block-editor-settings.mjs +2 -0
  137. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  138. package/build-module/components/revision-block-diff/index.mjs +30 -0
  139. package/build-module/components/revision-block-diff/index.mjs.map +7 -0
  140. package/build-module/components/revision-diff-panel/index.mjs +37 -0
  141. package/build-module/components/revision-diff-panel/index.mjs.map +7 -0
  142. package/build-module/components/revision-fields-diff/index.mjs +65 -0
  143. package/build-module/components/revision-fields-diff/index.mjs.map +7 -0
  144. package/build-module/components/sidebar/dataform-post-summary.mjs +25 -55
  145. package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
  146. package/build-module/components/sidebar/index.mjs +30 -23
  147. package/build-module/components/sidebar/index.mjs.map +2 -2
  148. package/build-module/components/sidebar/post-revision-summary.mjs +43 -0
  149. package/build-module/components/sidebar/post-revision-summary.mjs.map +7 -0
  150. package/build-module/components/sidebar/post-summary.mjs +31 -42
  151. package/build-module/components/sidebar/post-summary.mjs.map +2 -2
  152. package/build-module/components/style-book/index.mjs +4 -3
  153. package/build-module/components/style-book/index.mjs.map +2 -2
  154. package/build-module/components/sync-connection-error-modal/index.mjs +177 -0
  155. package/build-module/components/sync-connection-error-modal/index.mjs.map +7 -0
  156. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs +36 -0
  157. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs.map +7 -0
  158. package/build-module/components/template-actions-panel/block-theme-content.mjs +167 -0
  159. package/build-module/components/template-actions-panel/block-theme-content.mjs.map +7 -0
  160. package/build-module/components/template-actions-panel/classic-theme-content.mjs +138 -0
  161. package/build-module/components/template-actions-panel/classic-theme-content.mjs.map +7 -0
  162. package/build-module/components/template-actions-panel/index.mjs +28 -0
  163. package/build-module/components/template-actions-panel/index.mjs.map +7 -0
  164. package/build-module/components/visual-editor/index.mjs +2 -2
  165. package/build-module/components/visual-editor/index.mjs.map +2 -2
  166. package/build-module/dataviews/store/private-actions.mjs +5 -1
  167. package/build-module/dataviews/store/private-actions.mjs.map +2 -2
  168. package/build-module/store/actions.mjs +1 -3
  169. package/build-module/store/actions.mjs.map +2 -2
  170. package/build-module/store/private-actions.mjs +21 -2
  171. package/build-module/store/private-actions.mjs.map +2 -2
  172. package/build-module/store/private-selectors.mjs +40 -15
  173. package/build-module/store/private-selectors.mjs.map +2 -2
  174. package/build-module/utils/media-finalize/index.mjs +12 -0
  175. package/build-module/utils/media-finalize/index.mjs.map +7 -0
  176. package/build-module/utils/sync-error-messages.mjs +24 -16
  177. package/build-module/utils/sync-error-messages.mjs.map +3 -3
  178. package/build-style/style-rtl.css +135 -50
  179. package/build-style/style.css +135 -50
  180. package/build-types/components/collaborators-overlay/cursor-registry.d.ts +36 -0
  181. package/build-types/components/collaborators-overlay/cursor-registry.d.ts.map +1 -0
  182. package/build-types/components/collaborators-overlay/index.d.ts +7 -4
  183. package/build-types/components/collaborators-overlay/index.d.ts.map +1 -1
  184. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts +1 -1
  185. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts.map +1 -1
  186. package/build-types/components/collaborators-overlay/overlay.d.ts +4 -1
  187. package/build-types/components/collaborators-overlay/overlay.d.ts.map +1 -1
  188. package/build-types/components/collaborators-overlay/timing-utils.d.ts +11 -0
  189. package/build-types/components/collaborators-overlay/timing-utils.d.ts.map +1 -0
  190. package/build-types/components/collaborators-presence/index.d.ts.map +1 -1
  191. package/build-types/components/collaborators-presence/list.d.ts +4 -1
  192. package/build-types/components/collaborators-presence/list.d.ts.map +1 -1
  193. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  194. package/build-types/components/post-content-information/index.d.ts +4 -1
  195. package/build-types/components/post-content-information/index.d.ts.map +1 -1
  196. package/build-types/components/post-locked-modal/index.d.ts +2 -2
  197. package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
  198. package/build-types/components/post-revisions-panel/index.d.ts +2 -0
  199. package/build-types/components/post-revisions-panel/index.d.ts.map +1 -0
  200. package/build-types/components/post-revisions-preview/block-diff.d.ts.map +1 -1
  201. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  202. package/build-types/components/post-template/block-theme.d.ts +1 -3
  203. package/build-types/components/post-template/block-theme.d.ts.map +1 -1
  204. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  205. package/build-types/components/post-template/hooks.d.ts +2 -1
  206. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  207. package/build-types/components/post-template/panel.d.ts.map +1 -1
  208. package/build-types/components/post-template/swap-template-button.d.ts +4 -0
  209. package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
  210. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  211. package/build-types/components/revision-block-diff/index.d.ts +6 -0
  212. package/build-types/components/revision-block-diff/index.d.ts.map +1 -0
  213. package/build-types/components/revision-diff-panel/index.d.ts +14 -0
  214. package/build-types/components/revision-diff-panel/index.d.ts.map +1 -0
  215. package/build-types/components/revision-fields-diff/index.d.ts +6 -0
  216. package/build-types/components/revision-fields-diff/index.d.ts.map +1 -0
  217. package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
  218. package/build-types/components/sidebar/index.d.ts.map +1 -1
  219. package/build-types/components/sidebar/post-revision-summary.d.ts +2 -0
  220. package/build-types/components/sidebar/post-revision-summary.d.ts.map +1 -0
  221. package/build-types/components/sidebar/post-summary.d.ts +3 -0
  222. package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
  223. package/build-types/components/style-book/index.d.ts +2 -1
  224. package/build-types/components/style-book/index.d.ts.map +1 -1
  225. package/build-types/components/sync-connection-error-modal/index.d.ts +22 -0
  226. package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -0
  227. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts +11 -0
  228. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts.map +1 -0
  229. package/build-types/components/template-actions-panel/block-theme-content.d.ts +2 -0
  230. package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -0
  231. package/build-types/components/template-actions-panel/classic-theme-content.d.ts +2 -0
  232. package/build-types/components/template-actions-panel/classic-theme-content.d.ts.map +1 -0
  233. package/build-types/components/template-actions-panel/index.d.ts +2 -0
  234. package/build-types/components/template-actions-panel/index.d.ts.map +1 -0
  235. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  236. package/build-types/store/actions.d.ts.map +1 -1
  237. package/build-types/store/private-actions.d.ts.map +1 -1
  238. package/build-types/store/private-selectors.d.ts.map +1 -1
  239. package/build-types/utils/media-finalize/index.d.ts +2 -0
  240. package/build-types/utils/media-finalize/index.d.ts.map +1 -0
  241. package/build-types/utils/sync-error-messages.d.ts +17 -3
  242. package/build-types/utils/sync-error-messages.d.ts.map +1 -1
  243. package/package.json +45 -44
  244. package/src/components/collaborators-overlay/compute-selection.ts +13 -13
  245. package/src/components/collaborators-overlay/cursor-registry.ts +96 -0
  246. package/src/components/collaborators-overlay/index.tsx +12 -4
  247. package/src/components/collaborators-overlay/overlay-iframe-styles.ts +1 -1
  248. package/src/components/collaborators-overlay/overlay.tsx +64 -1
  249. package/src/components/collaborators-overlay/timing-utils.ts +30 -0
  250. package/src/components/collaborators-overlay/use-render-cursors.ts +1 -1
  251. package/src/components/collaborators-presence/index.tsx +9 -1
  252. package/src/components/collaborators-presence/list.tsx +25 -1
  253. package/src/components/post-card-panel/index.js +7 -21
  254. package/src/components/post-content-information/index.js +5 -16
  255. package/src/components/post-locked-modal/index.js +21 -3
  256. package/src/components/post-revisions-panel/index.js +151 -0
  257. package/src/components/post-revisions-panel/style.scss +16 -0
  258. package/src/components/post-revisions-preview/block-diff.js +59 -20
  259. package/src/components/post-revisions-preview/diff-markers.js +2 -2
  260. package/src/components/post-revisions-preview/revisions-canvas.js +1 -1
  261. package/src/components/post-revisions-preview/revisions-slider.js +29 -7
  262. package/src/components/post-revisions-preview/test/block-diff.js +69 -31
  263. package/src/components/post-template/block-theme.js +4 -1
  264. package/src/components/post-template/create-new-template-modal.js +1 -4
  265. package/src/components/post-template/hooks.js +107 -9
  266. package/src/components/post-template/panel.js +5 -59
  267. package/src/components/post-template/style.scss +0 -6
  268. package/src/components/post-template/swap-template-button.js +30 -21
  269. package/src/components/preferences-modal/index.js +37 -25
  270. package/src/components/provider/use-block-editor-settings.js +2 -0
  271. package/src/components/revision-block-diff/index.js +39 -0
  272. package/src/components/revision-diff-panel/index.js +59 -0
  273. package/src/components/revision-diff-panel/style.scss +13 -0
  274. package/src/components/revision-fields-diff/index.js +91 -0
  275. package/src/components/sidebar/dataform-post-summary.js +45 -68
  276. package/src/components/sidebar/index.js +35 -22
  277. package/src/components/sidebar/post-revision-summary.js +50 -0
  278. package/src/components/sidebar/post-summary.js +22 -40
  279. package/src/components/sidebar/style.scss +7 -0
  280. package/src/components/style-book/index.js +4 -2
  281. package/src/components/sync-connection-error-modal/index.tsx +265 -0
  282. package/src/components/sync-connection-error-modal/style.scss +14 -0
  283. package/src/components/sync-connection-error-modal/use-retry-countdown.ts +57 -0
  284. package/src/components/template-actions-panel/block-theme-content.js +196 -0
  285. package/src/components/template-actions-panel/classic-theme-content.js +170 -0
  286. package/src/components/template-actions-panel/index.js +32 -0
  287. package/src/components/template-actions-panel/style.scss +39 -0
  288. package/src/components/visual-editor/index.js +2 -2
  289. package/src/dataviews/store/private-actions.ts +6 -0
  290. package/src/store/actions.js +1 -4
  291. package/src/store/private-actions.js +24 -3
  292. package/src/store/private-selectors.js +46 -16
  293. package/src/style.scss +4 -1
  294. package/src/utils/media-finalize/index.js +11 -0
  295. package/src/utils/media-finalize/test/index.js +34 -0
  296. package/src/utils/sync-error-messages.ts +72 -0
  297. package/src/utils/test/sync-error-messages.js +9 -32
  298. package/build/components/sync-connection-modal/index.cjs.map +0 -7
  299. package/build/components/sync-connection-modal/use-retry-countdown.cjs.map +0 -7
  300. package/build-module/components/sync-connection-modal/index.mjs +0 -170
  301. package/build-module/components/sync-connection-modal/index.mjs.map +0 -7
  302. package/build-module/components/sync-connection-modal/use-retry-countdown.mjs +0 -49
  303. package/build-module/components/sync-connection-modal/use-retry-countdown.mjs.map +0 -7
  304. package/build-types/components/sync-connection-modal/index.d.ts +0 -8
  305. package/build-types/components/sync-connection-modal/index.d.ts.map +0 -1
  306. package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts +0 -9
  307. package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts.map +0 -1
  308. package/src/components/sync-connection-modal/index.js +0 -206
  309. package/src/components/sync-connection-modal/style.scss +0 -14
  310. package/src/components/sync-connection-modal/use-retry-countdown.js +0 -70
  311. package/src/utils/sync-error-messages.js +0 -58
@@ -110,52 +110,45 @@ function CreateNewTemplateModal({ onClose }) {
110
110
  focusOnMount: "firstContentElement",
111
111
  size: "small",
112
112
  overlayClassName: "editor-post-template__create-template-modal",
113
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
114
- "form",
115
- {
116
- className: "editor-post-template__create-form",
117
- onSubmit: submit,
118
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalVStack, { spacing: "3", children: [
119
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
120
- import_components.TextControl,
121
- {
122
- __next40pxDefaultSize: true,
123
- label: (0, import_i18n.__)("Name"),
124
- value: title,
125
- onChange: setTitle,
126
- placeholder: DEFAULT_TITLE,
127
- disabled: isBusy,
128
- help: (0, import_i18n.__)(
129
- // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
130
- 'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.'
131
- )
132
- }
133
- ),
134
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { justify: "right", children: [
135
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
136
- import_components.Button,
137
- {
138
- __next40pxDefaultSize: true,
139
- variant: "tertiary",
140
- onClick: cancel,
141
- children: (0, import_i18n.__)("Cancel")
142
- }
143
- ),
144
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
145
- import_components.Button,
146
- {
147
- __next40pxDefaultSize: true,
148
- variant: "primary",
149
- type: "submit",
150
- isBusy,
151
- "aria-disabled": isBusy,
152
- children: (0, import_i18n.__)("Create")
153
- }
154
- )
155
- ] })
156
- ] })
157
- }
158
- )
113
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("form", { onSubmit: submit, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalVStack, { spacing: "3", children: [
114
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
115
+ import_components.TextControl,
116
+ {
117
+ __next40pxDefaultSize: true,
118
+ label: (0, import_i18n.__)("Name"),
119
+ value: title,
120
+ onChange: setTitle,
121
+ placeholder: DEFAULT_TITLE,
122
+ disabled: isBusy,
123
+ help: (0, import_i18n.__)(
124
+ // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
125
+ 'Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.'
126
+ )
127
+ }
128
+ ),
129
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { justify: "right", children: [
130
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
131
+ import_components.Button,
132
+ {
133
+ __next40pxDefaultSize: true,
134
+ variant: "tertiary",
135
+ onClick: cancel,
136
+ children: (0, import_i18n.__)("Cancel")
137
+ }
138
+ ),
139
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
140
+ import_components.Button,
141
+ {
142
+ __next40pxDefaultSize: true,
143
+ variant: "primary",
144
+ type: "submit",
145
+ isBusy,
146
+ "aria-disabled": isBusy,
147
+ children: (0, import_i18n.__)("Create")
148
+ }
149
+ )
150
+ ] })
151
+ ] }) })
159
152
  }
160
153
  );
161
154
  }
@@ -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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yBAAuC;AAKvC,kBAAuC;AACvC,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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\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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yBAAuC;AAKvC,kBAAuC;AACvC,qBAAyB;AACzB,oBAAuC;AACvC,wBAMO;AACP,kBAAmB;AAKnB,yBAAuB;AACvB,mBAAqC;AAkGhC;AAhGL,IAAM,oBAAgB,gBAAI,iBAAkB;AAE7B,SAAR,uBAAyC,EAAE,QAAQ,GAAI;AAC7D,QAAM,EAAE,sBAAsB,yBAAyB,QAAI;AAAA,IAC1D,CAAE,WAAY;AACb,YAAM,EAAE,mBAAmB,qBAAqB,IAC/C,OAAQ,aAAAA,KAAY;AACrB,aAAO;AAAA,QACN,sBAAsB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pB,UAAU;AAAA,IACX,CAAE;AACF,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAQ,gBAAI,wBAAyB;AAAA,MACrC,gBAAiB;AAAA,MACjB,cAAa;AAAA,MACb,MAAK;AAAA,MACL,kBAAiB;AAAA,MAEjB,sDAAC,UAAK,UAAW,QAChB,uDAAC,kBAAAC,sBAAA,EAAO,SAAQ,KACf;AAAA;AAAA,UAAC;AAAA;AAAA,YACA,uBAAqB;AAAA,YACrB,WAAQ,gBAAI,MAAO;AAAA,YACnB,OAAQ;AAAA,YACR,UAAW;AAAA,YACX,aAAc;AAAA,YACd,UAAW;AAAA,YACX,UAAO;AAAA;AAAA,cAEN;AAAA,YACD;AAAA;AAAA,QACD;AAAA,QACA,6CAAC,kBAAAC,sBAAA,EAAO,SAAQ,SACf;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,SAAU;AAAA,cAER,8BAAI,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,8BAAI,QAAS;AAAA;AAAA,UAChB;AAAA,WACD;AAAA,SACD,GACD;AAAA;AAAA,EACD;AAEF;",
6
6
  "names": ["editorStore", "kebabCase", "VStack", "HStack"]
7
7
  }
@@ -23,12 +23,14 @@ __export(hooks_exports, {
23
23
  useAllowSwitchingTemplates: () => useAllowSwitchingTemplates,
24
24
  useAvailableTemplates: () => useAvailableTemplates,
25
25
  useCurrentTemplateSlug: () => useCurrentTemplateSlug,
26
- useEditedPostContext: () => useEditedPostContext
26
+ useEditedPostContext: () => useEditedPostContext,
27
+ usePostTemplatePanelMode: () => usePostTemplatePanelMode
27
28
  });
28
29
  module.exports = __toCommonJS(hooks_exports);
29
30
  var import_data = require("@wordpress/data");
30
31
  var import_element = require("@wordpress/element");
31
32
  var import_core_data = require("@wordpress/core-data");
33
+ var import_i18n = require("@wordpress/i18n");
32
34
  var import_store = require("../../store/index.cjs");
33
35
  function useEditedPostContext() {
34
36
  return (0, import_data.useSelect)((select) => {
@@ -70,18 +72,98 @@ function useTemplates(postType) {
70
72
  [postType]
71
73
  );
72
74
  }
73
- function useAvailableTemplates(postType) {
75
+ function useAvailableTemplates() {
76
+ const { postType, postId } = useEditedPostContext();
77
+ const [postSlug] = (0, import_core_data.useEntityProp)("postType", postType, "slug", postId);
74
78
  const currentTemplateSlug = useCurrentTemplateSlug();
75
79
  const allowSwitchingTemplate = useAllowSwitchingTemplates();
76
80
  const templates = useTemplates(postType);
81
+ const defaultTemplate = (0, import_data.useSelect)(
82
+ (select) => {
83
+ if (!window?.__experimentalDataFormInspector) {
84
+ return null;
85
+ }
86
+ if (!currentTemplateSlug) {
87
+ return null;
88
+ }
89
+ const { getDefaultTemplateId, getEntityRecord } = select(import_core_data.store);
90
+ let slug;
91
+ if (postSlug) {
92
+ slug = postType === "page" ? `${postType}-${postSlug}` : `single-${postType}-${postSlug}`;
93
+ } else {
94
+ slug = postType === "page" ? "page" : `single-${postType}`;
95
+ }
96
+ const templateId = getDefaultTemplateId({ slug });
97
+ if (!templateId) {
98
+ return null;
99
+ }
100
+ return getEntityRecord("postType", "wp_template", templateId);
101
+ },
102
+ [currentTemplateSlug, postSlug, postType]
103
+ );
77
104
  return (0, import_element.useMemo)(
78
- () => allowSwitchingTemplate && templates?.filter(
79
- (template) => template.is_custom && template.slug !== currentTemplateSlug && !!template.content.raw
80
- // Skip empty templates.
81
- ),
82
- [templates, currentTemplateSlug, allowSwitchingTemplate]
105
+ () => allowSwitchingTemplate && [
106
+ ...(templates || []).filter(
107
+ (template) => template.is_custom && template.slug !== currentTemplateSlug && !!template.content.raw
108
+ // Skip empty templates.
109
+ ),
110
+ defaultTemplate && {
111
+ ...defaultTemplate,
112
+ title: {
113
+ rendered: (0, import_i18n.sprintf)(
114
+ // translators: %s: Template name
115
+ (0, import_i18n.__)("%s (default)"),
116
+ defaultTemplate.title.rendered
117
+ )
118
+ },
119
+ // That's extra custom prop in order to update to an empty template
120
+ // when we select the default template.
121
+ isDefault: true
122
+ }
123
+ ].filter(Boolean),
124
+ [
125
+ templates,
126
+ defaultTemplate,
127
+ currentTemplateSlug,
128
+ allowSwitchingTemplate
129
+ ]
83
130
  );
84
131
  }
132
+ function usePostTemplatePanelMode() {
133
+ return (0, import_data.useSelect)((select) => {
134
+ const { getEditorSettings, getCurrentTemplateId, getCurrentPostType } = select(import_store.store);
135
+ const { getPostType, canUser } = select(import_core_data.store);
136
+ const postTypeSlug = getCurrentPostType();
137
+ const postType = getPostType(postTypeSlug);
138
+ const settings = getEditorSettings();
139
+ const isBlockTheme = settings.__unstableIsBlockBasedTheme;
140
+ const hasTemplates = !!settings.availableTemplates && Object.keys(settings.availableTemplates).length > 0;
141
+ let isVisible;
142
+ if (!postType?.viewable) {
143
+ isVisible = false;
144
+ } else if (hasTemplates) {
145
+ isVisible = true;
146
+ } else if (!settings.supportsTemplateMode) {
147
+ isVisible = false;
148
+ } else {
149
+ isVisible = canUser("create", {
150
+ kind: "postType",
151
+ name: "wp_template"
152
+ }) ?? false;
153
+ }
154
+ const canViewTemplates = isVisible ? !!canUser("read", {
155
+ kind: "postType",
156
+ name: "wp_template"
157
+ }) : false;
158
+ if ((!isBlockTheme || !canViewTemplates) && isVisible) {
159
+ return "classic";
160
+ }
161
+ if (isBlockTheme && !!getCurrentTemplateId()) {
162
+ return "block-theme";
163
+ }
164
+ return null;
165
+ }, []);
166
+ }
85
167
  function useCurrentTemplateSlug() {
86
168
  const { postType, postId } = useEditedPostContext();
87
169
  const templates = useTemplates(postType);
@@ -106,6 +188,7 @@ function useCurrentTemplateSlug() {
106
188
  useAllowSwitchingTemplates,
107
189
  useAvailableTemplates,
108
190
  useCurrentTemplateSlug,
109
- useEditedPostContext
191
+ useEditedPostContext,
192
+ usePostTemplatePanelMode
110
193
  });
111
194
  //# sourceMappingURL=hooks.cjs.map
@@ -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 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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,qBAAwB;AACxB,uBAAmC;AAKnC,mBAAqC;AAE9B,SAAS,uBAAuB;AACtC,aAAO,uBAAW,CAAE,WAAY;AAC/B,UAAM,EAAE,kBAAkB,mBAAmB,IAAI,OAAQ,aAAAA,KAAY;AACrE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sBAAuB;AAAA,EAC1D;AACD;AAEO,SAAS,yBAAyB;AACxC,QAAM,EAAE,UAAU,OAAO,IAAI,qBAAqB;AAClD,QAAM,YAAY,aAAc,QAAS;AACzC,QAAM,qBAAiB;AAAA,IACtB,CAAE,WAAY;AACb,YAAM,OAAO,OAAQ,iBAAAA,KAAU,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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,qBAAwB;AACxB,uBAAkD;AAClD,kBAA4B;AAK5B,mBAAqC;AAE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
  }
@@ -33,54 +33,17 @@ __export(panel_exports, {
33
33
  default: () => PostTemplatePanel
34
34
  });
35
35
  module.exports = __toCommonJS(panel_exports);
36
- var import_data = require("@wordpress/data");
37
- var import_core_data = require("@wordpress/core-data");
38
- var import_store = require("../../store/index.cjs");
36
+ var import_hooks = require("./hooks.cjs");
39
37
  var import_classic_theme = __toESM(require("./classic-theme.cjs"));
40
38
  var import_block_theme = __toESM(require("./block-theme.cjs"));
41
39
  var import_jsx_runtime = require("react/jsx-runtime");
42
40
  function PostTemplatePanel() {
43
- const { templateId, isBlockTheme } = (0, import_data.useSelect)((select) => {
44
- const { getCurrentTemplateId, getEditorSettings } = select(import_store.store);
45
- return {
46
- templateId: getCurrentTemplateId(),
47
- isBlockTheme: getEditorSettings().__unstableIsBlockBasedTheme
48
- };
49
- }, []);
50
- const isVisible = (0, import_data.useSelect)((select) => {
51
- const postTypeSlug = select(import_store.store).getCurrentPostType();
52
- const postType = select(import_core_data.store).getPostType(postTypeSlug);
53
- if (!postType?.viewable) {
54
- return false;
55
- }
56
- const settings = select(import_store.store).getEditorSettings();
57
- const hasTemplates = !!settings.availableTemplates && Object.keys(settings.availableTemplates).length > 0;
58
- if (hasTemplates) {
59
- return true;
60
- }
61
- if (!settings.supportsTemplateMode) {
62
- return false;
63
- }
64
- const canCreateTemplates = select(import_core_data.store).canUser("create", {
65
- kind: "postType",
66
- name: "wp_template"
67
- }) ?? false;
68
- return canCreateTemplates;
69
- }, []);
70
- const canViewTemplates = (0, import_data.useSelect)(
71
- (select) => {
72
- return isVisible ? select(import_core_data.store).canUser("read", {
73
- kind: "postType",
74
- name: "wp_template"
75
- }) : false;
76
- },
77
- [isVisible]
78
- );
79
- if ((!isBlockTheme || !canViewTemplates) && isVisible) {
41
+ const mode = (0, import_hooks.usePostTemplatePanelMode)();
42
+ if (mode === "classic") {
80
43
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_classic_theme.default, {});
81
44
  }
82
- if (isBlockTheme && !!templateId) {
83
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_theme.default, { id: templateId });
45
+ if (mode === "block-theme") {
46
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_theme.default, {});
84
47
  }
85
48
  return null;
86
49
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/post-template/panel.js"],
4
- "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';\nimport ClassicThemeControl from './classic-theme';\nimport BlockThemeControl from './block-theme';\n\n/**\n * Displays the template controls based on the current editor settings and user permissions.\n *\n * @return {React.ReactNode} 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(\n\t\t( select ) => {\n\t\t\treturn isVisible\n\t\t\t\t? select( coreStore ).canUser( 'read', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t } )\n\t\t\t\t: false;\n\t\t},\n\t\t[ isVisible ]\n\t);\n\n\tif ( ( ! isBlockTheme || ! canViewTemplates ) && isVisible ) {\n\t\treturn <ClassicThemeControl />;\n\t}\n\n\tif ( isBlockTheme && !! templateId ) {\n\t\treturn <BlockThemeControl id={ templateId } />;\n\t}\n\treturn null;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,uBAAmC;AAKnC,mBAAqC;AACrC,2BAAgC;AAChC,yBAA8B;AAyDrB;AAlDM,SAAR,oBAAqC;AAC3C,QAAM,EAAE,YAAY,aAAa,QAAI,uBAAW,CAAE,WAAY;AAC7D,UAAM,EAAE,sBAAsB,kBAAkB,IAC/C,OAAQ,aAAAA,KAAY;AACrB,WAAO;AAAA,MACN,YAAY,qBAAqB;AAAA,MACjC,cAAc,kBAAkB,EAAE;AAAA,IACnC;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,gBAAY,uBAAW,CAAE,WAAY;AAC1C,UAAM,eAAe,OAAQ,aAAAA,KAAY,EAAE,mBAAmB;AAC9D,UAAM,WAAW,OAAQ,iBAAAC,KAAU,EAAE,YAAa,YAAa;AAC/D,QAAK,CAAE,UAAU,UAAW;AAC3B,aAAO;AAAA,IACR;AAEA,UAAM,WAAW,OAAQ,aAAAD,KAAY,EAAE,kBAAkB;AACzD,UAAM,eACL,CAAC,CAAE,SAAS,sBACZ,OAAO,KAAM,SAAS,kBAAmB,EAAE,SAAS;AACrD,QAAK,cAAe;AACnB,aAAO;AAAA,IACR;AAEA,QAAK,CAAE,SAAS,sBAAuB;AACtC,aAAO;AAAA,IACR;AAEA,UAAM,qBACL,OAAQ,iBAAAC,KAAU,EAAE,QAAS,UAAU;AAAA,MACtC,MAAM;AAAA,MACN,MAAM;AAAA,IACP,CAAE,KAAK;AACR,WAAO;AAAA,EACR,GAAG,CAAC,CAAE;AAEN,QAAM,uBAAmB;AAAA,IACxB,CAAE,WAAY;AACb,aAAO,YACJ,OAAQ,iBAAAA,KAAU,EAAE,QAAS,QAAQ;AAAA,QACrC,MAAM;AAAA,QACN,MAAM;AAAA,MACN,CAAE,IACF;AAAA,IACJ;AAAA,IACA,CAAE,SAAU;AAAA,EACb;AAEA,OAAO,CAAE,gBAAgB,CAAE,qBAAsB,WAAY;AAC5D,WAAO,4CAAC,qBAAAC,SAAA,EAAoB;AAAA,EAC7B;AAEA,MAAK,gBAAgB,CAAC,CAAE,YAAa;AACpC,WAAO,4CAAC,mBAAAC,SAAA,EAAkB,IAAK,YAAa;AAAA,EAC7C;AACA,SAAO;AACR;",
6
- "names": ["editorStore", "coreStore", "ClassicThemeControl", "BlockThemeControl"]
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { usePostTemplatePanelMode } from './hooks';\nimport ClassicThemeControl from './classic-theme';\nimport BlockThemeControl from './block-theme';\n\n/**\n * Displays the template controls based on the current editor settings and user permissions.\n *\n * @return {React.ReactNode} The rendered PostTemplatePanel component.\n */\nexport default function PostTemplatePanel() {\n\tconst mode = usePostTemplatePanelMode();\n\tif ( mode === 'classic' ) {\n\t\treturn <ClassicThemeControl />;\n\t}\n\tif ( mode === 'block-theme' ) {\n\t\treturn <BlockThemeControl />;\n\t}\n\treturn null;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAyC;AACzC,2BAAgC;AAChC,yBAA8B;AAUrB;AAHM,SAAR,oBAAqC;AAC3C,QAAM,WAAO,uCAAyB;AACtC,MAAK,SAAS,WAAY;AACzB,WAAO,4CAAC,qBAAAA,SAAA,EAAoB;AAAA,EAC7B;AACA,MAAK,SAAS,eAAgB;AAC7B,WAAO,4CAAC,mBAAAC,SAAA,EAAkB;AAAA,EAC3B;AACA,SAAO;AACR;",
6
+ "names": ["ClassicThemeControl", "BlockThemeControl"]
7
7
  }
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // packages/editor/src/components/post-template/swap-template-button.js
21
21
  var swap_template_button_exports = {};
22
22
  __export(swap_template_button_exports, {
23
+ SwapTemplateModal: () => SwapTemplateModal,
23
24
  default: () => SwapTemplateButton
24
25
  });
25
26
  module.exports = __toCommonJS(swap_template_button_exports);
@@ -34,22 +35,36 @@ var import_blocks = require("@wordpress/blocks");
34
35
  var import_hooks = require("./hooks.cjs");
35
36
  var import_search_templates = require("../../utils/search-templates.cjs");
36
37
  var import_jsx_runtime = require("react/jsx-runtime");
37
- function SwapTemplateButton({ onClick }) {
38
- const [showModal, setShowModal] = (0, import_element.useState)(false);
38
+ function SwapTemplateModal({ onRequestClose, onSelect }) {
39
39
  const { postType, postId } = (0, import_hooks.useEditedPostContext)();
40
- const availableTemplates = (0, import_hooks.useAvailableTemplates)(postType);
41
40
  const { editEntityRecord } = (0, import_data.useDispatch)(import_core_data.store);
42
41
  const onTemplateSelect = async (template) => {
43
42
  editEntityRecord(
44
43
  "postType",
45
44
  postType,
46
45
  postId,
47
- { template: template.name },
46
+ // Since we append the default template we need to properly
47
+ // update to an empty string.
48
+ { template: template.isDefault ? "" : template.name },
48
49
  { undoIgnore: true }
49
50
  );
50
- setShowModal(false);
51
- onClick();
51
+ onRequestClose();
52
+ onSelect?.();
52
53
  };
54
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
55
+ import_components.Modal,
56
+ {
57
+ title: (0, import_i18n.__)("Choose a template"),
58
+ onRequestClose,
59
+ overlayClassName: "editor-post-template__swap-template-modal",
60
+ isFullScreen: true,
61
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-post-template__swap-template-modal-content", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TemplatesList, { onSelect: onTemplateSelect }) })
62
+ }
63
+ );
64
+ }
65
+ function SwapTemplateButton({ onClick }) {
66
+ const [showModal, setShowModal] = (0, import_element.useState)(false);
67
+ const availableTemplates = (0, import_hooks.useAvailableTemplates)();
53
68
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
54
69
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
55
70
  import_components.MenuItem,
@@ -61,32 +76,24 @@ function SwapTemplateButton({ onClick }) {
61
76
  }
62
77
  ),
63
78
  showModal && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
64
- import_components.Modal,
79
+ SwapTemplateModal,
65
80
  {
66
- title: (0, import_i18n.__)("Choose a template"),
67
81
  onRequestClose: () => setShowModal(false),
68
- overlayClassName: "editor-post-template__swap-template-modal",
69
- isFullScreen: true,
70
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-post-template__swap-template-modal-content", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
71
- TemplatesList,
72
- {
73
- postType,
74
- onSelect: onTemplateSelect
75
- }
76
- ) })
82
+ onSelect: onClick
77
83
  }
78
84
  )
79
85
  ] });
80
86
  }
81
- function TemplatesList({ postType, onSelect }) {
87
+ function TemplatesList({ onSelect }) {
82
88
  const [searchValue, setSearchValue] = (0, import_element.useState)("");
83
- const availableTemplates = (0, import_hooks.useAvailableTemplates)(postType);
89
+ const availableTemplates = (0, import_hooks.useAvailableTemplates)();
84
90
  const templatesAsPatterns = (0, import_element.useMemo)(
85
91
  () => availableTemplates.map((template) => ({
86
92
  name: template.slug,
87
93
  blocks: (0, import_blocks.parse)(template.content.raw),
88
94
  title: (0, import_html_entities.decodeEntities)(template.title.rendered),
89
- id: template.id
95
+ id: template.id,
96
+ isDefault: template.isDefault
90
97
  })),
91
98
  [availableTemplates]
92
99
  );
@@ -114,4 +121,8 @@ function TemplatesList({ postType, onSelect }) {
114
121
  )
115
122
  ] });
116
123
  }
124
+ // Annotate the CommonJS export names for ESM import in node:
125
+ 0 && (module.exports = {
126
+ SwapTemplateModal
127
+ });
117
128
  //# sourceMappingURL=swap-template-button.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/post-template/swap-template-button.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { MenuItem, Modal, SearchControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useAvailableTemplates, useEditedPostContext } from './hooks';\nimport { searchTemplates } from '../../utils/search-templates';\n\nexport default function SwapTemplateButton( { onClick } ) {\n\tconst [ showModal, setShowModal ] = useState( false );\n\tconst { postType, postId } = useEditedPostContext();\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst onTemplateSelect = async ( template ) => {\n\t\teditEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{ template: template.name },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t\tsetShowModal( false ); // Close the template suggestions modal first.\n\t\tonClick();\n\t};\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tdisabled={ ! availableTemplates?.length }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => setShowModal( true ) }\n\t\t\t>\n\t\t\t\t{ __( 'Change template' ) }\n\t\t\t</MenuItem>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\t\t\tonRequestClose={ () => setShowModal( false ) }\n\t\t\t\t\toverlayClassName=\"editor-post-template__swap-template-modal\"\n\t\t\t\t\tisFullScreen\n\t\t\t\t>\n\t\t\t\t\t<div className=\"editor-post-template__swap-template-modal-content\">\n\t\t\t\t\t\t<TemplatesList\n\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\tonSelect={ onTemplateSelect }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction TemplatesList( { postType, onSelect } ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\n\tconst filteredBlockTemplates = useMemo( () => {\n\t\treturn searchTemplates( templatesAsPatterns, searchValue );\n\t}, [ templatesAsPatterns, searchValue ] );\n\n\treturn (\n\t\t<>\n\t\t\t<SearchControl\n\t\t\t\tonChange={ setSearchValue }\n\t\t\t\tvalue={ searchValue }\n\t\t\t\tlabel={ __( 'Search' ) }\n\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t\tclassName=\"editor-post-template__swap-template-search\"\n\t\t\t/>\n\t\t\t<BlockPatternsList\n\t\t\t\tlabel={ __( 'Templates' ) }\n\t\t\t\tblockPatterns={ filteredBlockTemplates }\n\t\t\t\tonClickPattern={ onSelect }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAkC;AAClC,2BAA+B;AAC/B,0BAAqE;AACrE,wBAA+C;AAC/C,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AAI;AAAA,MACpC,WAAO,qCAAgB,SAAS,MAAM,QAAS;AAAA,MAC/C,IAAI,SAAS;AAAA,IACd,EAAI;AAAA,IACL,CAAE,kBAAmB;AAAA,EACtB;AAEA,QAAM,6BAAyB,wBAAS,MAAM;AAC7C,eAAO,yCAAiB,qBAAqB,WAAY;AAAA,EAC1D,GAAG,CAAE,qBAAqB,WAAY,CAAE;AAExC,SACC,4EACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,UAAW;AAAA,QACX,OAAQ;AAAA,QACR,WAAQ,gBAAI,QAAS;AAAA,QACrB,iBAAc,gBAAI,QAAS;AAAA,QAC3B,WAAU;AAAA;AAAA,IACX;AAAA,IACA;AAAA,MAAC,oBAAAC;AAAA,MAAA;AAAA,QACA,WAAQ,gBAAI,WAAY;AAAA,QACxB,eAAgB;AAAA,QAChB,gBAAiB;AAAA;AAAA,IAClB;AAAA,KACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { MenuItem, Modal, SearchControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useAvailableTemplates, useEditedPostContext } from './hooks';\nimport { searchTemplates } from '../../utils/search-templates';\n\nexport function SwapTemplateModal( { onRequestClose, onSelect } ) {\n\tconst { postType, postId } = useEditedPostContext();\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst onTemplateSelect = async ( template ) => {\n\t\teditEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t// Since we append the default template we need to properly\n\t\t\t// update to an empty string.\n\t\t\t{ template: template.isDefault ? '' : template.name },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t\tonRequestClose();\n\t\tonSelect?.();\n\t};\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\tonRequestClose={ onRequestClose }\n\t\t\toverlayClassName=\"editor-post-template__swap-template-modal\"\n\t\t\tisFullScreen\n\t\t>\n\t\t\t<div className=\"editor-post-template__swap-template-modal-content\">\n\t\t\t\t<TemplatesList onSelect={ onTemplateSelect } />\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n\nexport default function SwapTemplateButton( { onClick } ) {\n\tconst [ showModal, setShowModal ] = useState( false );\n\tconst availableTemplates = useAvailableTemplates();\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tdisabled={ ! availableTemplates?.length }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => setShowModal( true ) }\n\t\t\t>\n\t\t\t\t{ __( 'Change template' ) }\n\t\t\t</MenuItem>\n\t\t\t{ showModal && (\n\t\t\t\t<SwapTemplateModal\n\t\t\t\t\tonRequestClose={ () => setShowModal( false ) }\n\t\t\t\t\tonSelect={ onClick }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction TemplatesList( { onSelect } ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst availableTemplates = useAvailableTemplates();\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t\tisDefault: template.isDefault,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\n\tconst filteredBlockTemplates = useMemo( () => {\n\t\treturn searchTemplates( templatesAsPatterns, searchValue );\n\t}, [ templatesAsPatterns, searchValue ] );\n\n\treturn (\n\t\t<>\n\t\t\t<SearchControl\n\t\t\t\tonChange={ setSearchValue }\n\t\t\t\tvalue={ searchValue }\n\t\t\t\tlabel={ __( 'Search' ) }\n\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t\tclassName=\"editor-post-template__swap-template-search\"\n\t\t\t/>\n\t\t\t<BlockPatternsList\n\t\t\t\tlabel={ __( 'Templates' ) }\n\t\t\t\tblockPatterns={ filteredBlockTemplates }\n\t\t\t\tonClickPattern={ onSelect }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAkC;AAClC,2BAA+B;AAC/B,0BAAqE;AACrE,wBAA+C;AAC/C,kBAAmB;AACnB,kBAA4B;AAC5B,uBAAmC;AACnC,oBAAsB;AAKtB,mBAA4D;AAC5D,8BAAgC;AA0B5B;AAxBG,SAAS,kBAAmB,EAAE,gBAAgB,SAAS,GAAI;AACjE,QAAM,EAAE,UAAU,OAAO,QAAI,mCAAqB;AAClD,QAAM,EAAE,iBAAiB,QAAI,yBAAa,iBAAAA,KAAU;AACpD,QAAM,mBAAmB,OAAQ,aAAc;AAC9C;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA;AAAA;AAAA,MAGA,EAAE,UAAU,SAAS,YAAY,KAAK,SAAS,KAAK;AAAA,MACpD,EAAE,YAAY,KAAK;AAAA,IACpB;AACA,mBAAe;AACf,eAAW;AAAA,EACZ;AACA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAQ,gBAAI,mBAAoB;AAAA,MAChC;AAAA,MACA,kBAAiB;AAAA,MACjB,cAAY;AAAA,MAEZ,sDAAC,SAAI,WAAU,qDACd,sDAAC,iBAAc,UAAW,kBAAmB,GAC9C;AAAA;AAAA,EACD;AAEF;AAEe,SAAR,mBAAqC,EAAE,QAAQ,GAAI;AACzD,QAAM,CAAE,WAAW,YAAa,QAAI,yBAAU,KAAM;AACpD,QAAM,yBAAqB,oCAAsB;AAEjD,SACC,4EACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,UAAW,CAAE,oBAAoB;AAAA,QACjC,wBAAsB;AAAA,QACtB,SAAU,MAAM,aAAc,IAAK;AAAA,QAEjC,8BAAI,iBAAkB;AAAA;AAAA,IACzB;AAAA,IACE,aACD;AAAA,MAAC;AAAA;AAAA,QACA,gBAAiB,MAAM,aAAc,KAAM;AAAA,QAC3C,UAAW;AAAA;AAAA,IACZ;AAAA,KAEF;AAEF;AAEA,SAAS,cAAe,EAAE,SAAS,GAAI;AACtC,QAAM,CAAE,aAAa,cAAe,QAAI,yBAAU,EAAG;AACrD,QAAM,yBAAqB,oCAAsB;AACjD,QAAM,0BAAsB;AAAA,IAC3B,MACC,mBAAmB,IAAK,CAAE,cAAgB;AAAA,MACzC,MAAM,SAAS;AAAA,MACf,YAAQ,qBAAO,SAAS,QAAQ,GAAI;AAAA,MACpC,WAAO,qCAAgB,SAAS,MAAM,QAAS;AAAA,MAC/C,IAAI,SAAS;AAAA,MACb,WAAW,SAAS;AAAA,IACrB,EAAI;AAAA,IACL,CAAE,kBAAmB;AAAA,EACtB;AAEA,QAAM,6BAAyB,wBAAS,MAAM;AAC7C,eAAO,yCAAiB,qBAAqB,WAAY;AAAA,EAC1D,GAAG,CAAE,qBAAqB,WAAY,CAAE;AAExC,SACC,4EACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,UAAW;AAAA,QACX,OAAQ;AAAA,QACR,WAAQ,gBAAI,QAAS;AAAA,QACrB,iBAAc,gBAAI,QAAS;AAAA,QAC3B,WAAU;AAAA;AAAA,IACX;AAAA,IACA;AAAA,MAAC,oBAAAC;AAAA,MAAA;AAAA,QACA,WAAQ,gBAAI,WAAY;AAAA,QACxB,eAAgB;AAAA,QAChB,gBAAiB;AAAA;AAAA,IAClB;AAAA,KACD;AAEF;",
6
6
  "names": ["coreStore", "BlockPatternsList"]
7
7
  }
@@ -69,13 +69,16 @@ function EditorPreferencesModal({ extraSections = {} }) {
69
69
  }
70
70
  function PreferencesModalContents({ extraSections = {} }) {
71
71
  const isLargeViewport = (0, import_compose.useViewportMatch)("medium");
72
- const showBlockBreadcrumbsOption = (0, import_data.useSelect)(
72
+ const { showBlockBreadcrumbsOption, showCollaborationOptions } = (0, import_data.useSelect)(
73
73
  (select) => {
74
- const { getEditorSettings } = select(import_store.store);
74
+ const { getEditorSettings, isCollaborationEnabledForCurrentPost } = select(import_store.store);
75
75
  const { get } = select(import_preferences.store);
76
76
  const isRichEditingEnabled = getEditorSettings().richEditingEnabled;
77
77
  const isDistractionFreeEnabled = get("core", "distractionFree");
78
- return !isDistractionFreeEnabled && isLargeViewport && isRichEditingEnabled;
78
+ return {
79
+ showBlockBreadcrumbsOption: !isDistractionFreeEnabled && isLargeViewport && isRichEditingEnabled,
80
+ showCollaborationOptions: isCollaborationEnabledForCurrentPost()
81
+ };
79
82
  },
80
83
  [isLargeViewport]
81
84
  );
@@ -138,30 +141,34 @@ function PreferencesModalContents({ extraSections = {} }) {
138
141
  label: (0, import_i18n.__)("Show starter patterns")
139
142
  }
140
143
  ),
141
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
142
- PreferenceToggleControl,
143
- {
144
- scope: "core",
145
- featureName: "showCollaborationCursor",
146
- help: (0, import_i18n.__)(
147
- "Show your own avatar inside blocks during collaborative editing sessions."
148
- ),
149
- label: (0, import_i18n.__)("Show avatar in blocks")
150
- }
151
- ),
152
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
153
- PreferenceToggleControl,
154
- {
155
- scope: "core",
156
- featureName: "showCollaborationNotifications",
157
- help: (0, import_i18n.__)(
158
- "Show notifications when collaborators join, leave, or save the post."
159
- ),
160
- label: (0, import_i18n.__)(
161
- "Show collaboration notifications"
162
- )
163
- }
164
- )
144
+ showCollaborationOptions && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
145
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
146
+ PreferenceToggleControl,
147
+ {
148
+ scope: "core",
149
+ featureName: "showCollaborationCursor",
150
+ help: (0, import_i18n.__)(
151
+ "Show your own avatar inside blocks during collaborative editing sessions."
152
+ ),
153
+ label: (0, import_i18n.__)(
154
+ "Show avatar in blocks"
155
+ )
156
+ }
157
+ ),
158
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
159
+ PreferenceToggleControl,
160
+ {
161
+ scope: "core",
162
+ featureName: "showCollaborationNotifications",
163
+ help: (0, import_i18n.__)(
164
+ "Show notifications when collaborators join, leave, or save the post."
165
+ ),
166
+ label: (0, import_i18n.__)(
167
+ "Show collaboration notifications"
168
+ )
169
+ }
170
+ )
171
+ ] })
165
172
  ]
166
173
  }
167
174
  ),
@@ -418,6 +425,7 @@ function PreferencesModalContents({ extraSections = {} }) {
418
425
  ].filter(Boolean),
419
426
  [
420
427
  showBlockBreadcrumbsOption,
428
+ showCollaborationOptions,
421
429
  extraSections,
422
430
  setIsInserterOpened,
423
431
  setIsListViewOpened,