@wordpress/editor 13.24.1 → 13.26.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 (307) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +1 -1
  3. package/build/components/document-bar/index.js +164 -0
  4. package/build/components/document-bar/index.js.map +1 -0
  5. package/build/components/document-outline/index.js +82 -1
  6. package/build/components/document-outline/index.js.map +1 -1
  7. package/build/components/document-tools/index.js +160 -0
  8. package/build/components/document-tools/index.js.map +1 -0
  9. package/build/components/editor-canvas/edit-template-blocks-notification.js +106 -0
  10. package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -0
  11. package/build/components/editor-canvas/index.js +298 -0
  12. package/build/components/editor-canvas/index.js.map +1 -0
  13. package/build/components/entities-saved-states/index.js +3 -1
  14. package/build/components/entities-saved-states/index.js.map +1 -1
  15. package/build/components/global-keyboard-shortcuts/index.js +12 -2
  16. package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
  17. package/build/components/global-keyboard-shortcuts/register-shortcuts.js +9 -0
  18. package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  19. package/build/components/index.js +72 -8
  20. package/build/components/index.js.map +1 -1
  21. package/build/components/index.native.js +9 -1
  22. package/build/components/index.native.js.map +1 -1
  23. package/build/components/inserter-sidebar/index.js +77 -0
  24. package/build/components/inserter-sidebar/index.js.map +1 -0
  25. package/build/components/list-view-sidebar/index.js +150 -0
  26. package/build/components/list-view-sidebar/index.js.map +1 -0
  27. package/build/components/list-view-sidebar/list-view-outline.js +28 -0
  28. package/build/components/list-view-sidebar/list-view-outline.js.map +1 -0
  29. package/build/components/offline-status/index.native.js +85 -0
  30. package/build/components/offline-status/index.native.js.map +1 -0
  31. package/build/components/page-attributes/panel.js +63 -0
  32. package/build/components/page-attributes/panel.js.map +1 -0
  33. package/build/components/post-discussion/panel.js +59 -0
  34. package/build/components/post-discussion/panel.js.map +1 -0
  35. package/build/components/post-excerpt/check.js +19 -0
  36. package/build/components/post-excerpt/check.js.map +1 -1
  37. package/build/components/post-excerpt/panel.js +55 -0
  38. package/build/components/post-excerpt/panel.js.map +1 -0
  39. package/build/components/post-excerpt/plugin.js +72 -0
  40. package/build/components/post-excerpt/plugin.js.map +1 -0
  41. package/build/components/post-featured-image/index.js +5 -8
  42. package/build/components/post-featured-image/index.js.map +1 -1
  43. package/build/components/post-featured-image/panel.js +60 -0
  44. package/build/components/post-featured-image/panel.js.map +1 -0
  45. package/build/components/post-last-revision/panel.js +27 -0
  46. package/build/components/post-last-revision/panel.js.map +1 -0
  47. package/build/components/post-publish-button/index.js +1 -0
  48. package/build/components/post-publish-button/index.js.map +1 -1
  49. package/build/components/post-publish-panel/maybe-upload-media.js +2 -4
  50. package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  51. package/build/components/post-saved-state/index.js +13 -8
  52. package/build/components/post-saved-state/index.js.map +1 -1
  53. package/build/components/post-schedule/panel.js +1 -1
  54. package/build/components/post-schedule/panel.js.map +1 -1
  55. package/build/components/post-taxonomies/panel.js +68 -0
  56. package/build/components/post-taxonomies/panel.js.map +1 -0
  57. package/build/components/post-template/block-theme.js +100 -0
  58. package/build/components/post-template/block-theme.js.map +1 -0
  59. package/build/components/post-template/classic-theme.js +171 -0
  60. package/build/components/post-template/classic-theme.js.map +1 -0
  61. package/build/components/post-template/create-new-template-modal.js +98 -0
  62. package/build/components/post-template/create-new-template-modal.js.map +1 -0
  63. package/build/components/post-template/create-new-template.js +55 -0
  64. package/build/components/post-template/create-new-template.js.map +1 -0
  65. package/build/components/post-template/hooks.js +88 -0
  66. package/build/components/post-template/hooks.js.map +1 -0
  67. package/build/components/post-template/panel.js +70 -0
  68. package/build/components/post-template/panel.js.map +1 -0
  69. package/build/components/post-template/reset-default-template.js +48 -0
  70. package/build/components/post-template/reset-default-template.js.map +1 -0
  71. package/build/components/post-template/swap-template-button.js +86 -0
  72. package/build/components/post-template/swap-template-button.js.map +1 -0
  73. package/build/components/post-title/index.native.js +25 -15
  74. package/build/components/post-title/index.native.js.map +1 -1
  75. package/build/components/post-view-link/index.js +58 -0
  76. package/build/components/post-view-link/index.js.map +1 -0
  77. package/build/components/post-visibility/check.js +5 -17
  78. package/build/components/post-visibility/check.js.map +1 -1
  79. package/build/components/preview-dropdown/index.js +118 -0
  80. package/build/components/preview-dropdown/index.js.map +1 -0
  81. package/build/components/provider/index.js +24 -82
  82. package/build/components/provider/index.js.map +1 -1
  83. package/build/components/provider/index.native.js +36 -8
  84. package/build/components/provider/index.native.js.map +1 -1
  85. package/build/components/provider/navigation-block-editing-mode.js +40 -0
  86. package/build/components/provider/navigation-block-editing-mode.js.map +1 -0
  87. package/build/components/provider/use-block-editor-settings.js +38 -15
  88. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  89. package/build/hooks/index.js +1 -0
  90. package/build/hooks/index.js.map +1 -1
  91. package/build/hooks/pattern-partial-syncing.js +49 -0
  92. package/build/hooks/pattern-partial-syncing.js.map +1 -0
  93. package/build/private-apis.js +14 -0
  94. package/build/private-apis.js.map +1 -1
  95. package/build/store/actions.js +161 -13
  96. package/build/store/actions.js.map +1 -1
  97. package/build/store/defaults.js +2 -1
  98. package/build/store/defaults.js.map +1 -1
  99. package/build/store/index.js +5 -0
  100. package/build/store/index.js.map +1 -1
  101. package/build/store/private-actions.js +52 -0
  102. package/build/store/private-actions.js.map +1 -0
  103. package/build/store/private-selectors.js +52 -0
  104. package/build/store/private-selectors.js.map +1 -0
  105. package/build/store/reducer.js +109 -27
  106. package/build/store/reducer.js.map +1 -1
  107. package/build/store/reducer.native.js +0 -1
  108. package/build/store/reducer.native.js.map +1 -1
  109. package/build/store/selectors.js +104 -9
  110. package/build/store/selectors.js.map +1 -1
  111. package/build/utils/media-upload/index.js +8 -2
  112. package/build/utils/media-upload/index.js.map +1 -1
  113. package/build-module/components/document-bar/index.js +156 -0
  114. package/build-module/components/document-bar/index.js.map +1 -0
  115. package/build-module/components/document-outline/index.js +82 -1
  116. package/build-module/components/document-outline/index.js.map +1 -1
  117. package/build-module/components/document-tools/index.js +151 -0
  118. package/build-module/components/document-tools/index.js.map +1 -0
  119. package/build-module/components/editor-canvas/edit-template-blocks-notification.js +100 -0
  120. package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -0
  121. package/build-module/components/editor-canvas/index.js +289 -0
  122. package/build-module/components/editor-canvas/index.js.map +1 -0
  123. package/build-module/components/entities-saved-states/index.js +3 -1
  124. package/build-module/components/entities-saved-states/index.js.map +1 -1
  125. package/build-module/components/global-keyboard-shortcuts/index.js +12 -2
  126. package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
  127. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +9 -0
  128. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  129. package/build-module/components/index.js +9 -1
  130. package/build-module/components/index.js.map +1 -1
  131. package/build-module/components/index.native.js +1 -0
  132. package/build-module/components/index.native.js.map +1 -1
  133. package/build-module/components/inserter-sidebar/index.js +70 -0
  134. package/build-module/components/inserter-sidebar/index.js.map +1 -0
  135. package/build-module/components/list-view-sidebar/index.js +142 -0
  136. package/build-module/components/list-view-sidebar/index.js.map +1 -0
  137. package/build-module/components/list-view-sidebar/list-view-outline.js +20 -0
  138. package/build-module/components/list-view-sidebar/list-view-outline.js.map +1 -0
  139. package/build-module/components/offline-status/index.native.js +77 -0
  140. package/build-module/components/offline-status/index.native.js.map +1 -0
  141. package/build-module/components/page-attributes/panel.js +53 -0
  142. package/build-module/components/page-attributes/panel.js.map +1 -0
  143. package/build-module/components/post-discussion/panel.js +50 -0
  144. package/build-module/components/post-discussion/panel.js.map +1 -0
  145. package/build-module/components/post-excerpt/check.js +19 -0
  146. package/build-module/components/post-excerpt/check.js.map +1 -1
  147. package/build-module/components/post-excerpt/panel.js +48 -0
  148. package/build-module/components/post-excerpt/panel.js.map +1 -0
  149. package/build-module/components/post-excerpt/plugin.js +64 -0
  150. package/build-module/components/post-excerpt/plugin.js.map +1 -0
  151. package/build-module/components/post-featured-image/index.js +5 -8
  152. package/build-module/components/post-featured-image/index.js.map +1 -1
  153. package/build-module/components/post-featured-image/panel.js +51 -0
  154. package/build-module/components/post-featured-image/panel.js.map +1 -0
  155. package/build-module/components/post-last-revision/panel.js +18 -0
  156. package/build-module/components/post-last-revision/panel.js.map +1 -0
  157. package/build-module/components/post-publish-button/index.js +1 -0
  158. package/build-module/components/post-publish-button/index.js.map +1 -1
  159. package/build-module/components/post-publish-panel/maybe-upload-media.js +2 -4
  160. package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  161. package/build-module/components/post-saved-state/index.js +13 -8
  162. package/build-module/components/post-saved-state/index.js.map +1 -1
  163. package/build-module/components/post-schedule/panel.js +1 -1
  164. package/build-module/components/post-schedule/panel.js.map +1 -1
  165. package/build-module/components/post-taxonomies/panel.js +59 -0
  166. package/build-module/components/post-taxonomies/panel.js.map +1 -0
  167. package/build-module/components/post-template/block-theme.js +92 -0
  168. package/build-module/components/post-template/block-theme.js.map +1 -0
  169. package/build-module/components/post-template/classic-theme.js +162 -0
  170. package/build-module/components/post-template/classic-theme.js.map +1 -0
  171. package/build-module/components/post-template/create-new-template-modal.js +91 -0
  172. package/build-module/components/post-template/create-new-template-modal.js.map +1 -0
  173. package/build-module/components/post-template/create-new-template.js +47 -0
  174. package/build-module/components/post-template/create-new-template.js.map +1 -0
  175. package/build-module/components/post-template/hooks.js +78 -0
  176. package/build-module/components/post-template/hooks.js.map +1 -0
  177. package/build-module/components/post-template/panel.js +62 -0
  178. package/build-module/components/post-template/panel.js.map +1 -0
  179. package/build-module/components/post-template/reset-default-template.js +41 -0
  180. package/build-module/components/post-template/reset-default-template.js.map +1 -0
  181. package/build-module/components/post-template/swap-template-button.js +79 -0
  182. package/build-module/components/post-template/swap-template-button.js.map +1 -0
  183. package/build-module/components/post-title/index.native.js +26 -16
  184. package/build-module/components/post-title/index.native.js.map +1 -1
  185. package/build-module/components/post-view-link/index.js +51 -0
  186. package/build-module/components/post-view-link/index.js.map +1 -0
  187. package/build-module/components/post-visibility/check.js +6 -16
  188. package/build-module/components/post-visibility/check.js.map +1 -1
  189. package/build-module/components/preview-dropdown/index.js +110 -0
  190. package/build-module/components/preview-dropdown/index.js.map +1 -0
  191. package/build-module/components/provider/index.js +25 -83
  192. package/build-module/components/provider/index.js.map +1 -1
  193. package/build-module/components/provider/index.native.js +37 -9
  194. package/build-module/components/provider/index.native.js.map +1 -1
  195. package/build-module/components/provider/navigation-block-editing-mode.js +34 -0
  196. package/build-module/components/provider/navigation-block-editing-mode.js.map +1 -0
  197. package/build-module/components/provider/use-block-editor-settings.js +38 -15
  198. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  199. package/build-module/hooks/index.js +1 -0
  200. package/build-module/hooks/index.js.map +1 -1
  201. package/build-module/hooks/pattern-partial-syncing.js +46 -0
  202. package/build-module/hooks/pattern-partial-syncing.js.map +1 -0
  203. package/build-module/private-apis.js +14 -0
  204. package/build-module/private-apis.js.map +1 -1
  205. package/build-module/store/actions.js +147 -9
  206. package/build-module/store/actions.js.map +1 -1
  207. package/build-module/store/defaults.js +2 -1
  208. package/build-module/store/defaults.js.map +1 -1
  209. package/build-module/store/index.js +5 -0
  210. package/build-module/store/index.js.map +1 -1
  211. package/build-module/store/private-actions.js +44 -0
  212. package/build-module/store/private-actions.js.map +1 -0
  213. package/build-module/store/private-selectors.js +43 -0
  214. package/build-module/store/private-selectors.js.map +1 -0
  215. package/build-module/store/reducer.js +103 -26
  216. package/build-module/store/reducer.js.map +1 -1
  217. package/build-module/store/reducer.native.js +1 -2
  218. package/build-module/store/reducer.native.js.map +1 -1
  219. package/build-module/store/selectors.js +93 -6
  220. package/build-module/store/selectors.js.map +1 -1
  221. package/build-module/utils/media-upload/index.js +8 -2
  222. package/build-module/utils/media-upload/index.js.map +1 -1
  223. package/build-style/style-rtl.css +433 -0
  224. package/build-style/style.css +433 -0
  225. package/package.json +32 -31
  226. package/src/components/document-bar/index.js +193 -0
  227. package/src/components/document-bar/style.scss +130 -0
  228. package/src/components/document-outline/index.js +48 -1
  229. package/src/components/document-outline/style.scss +12 -0
  230. package/src/components/document-tools/index.js +177 -0
  231. package/src/components/document-tools/style.scss +98 -0
  232. package/src/components/editor-canvas/edit-template-blocks-notification.js +108 -0
  233. package/src/components/editor-canvas/index.js +386 -0
  234. package/src/components/editor-canvas/style.scss +5 -0
  235. package/src/components/entities-saved-states/index.js +3 -1
  236. package/src/components/entities-saved-states/style.scss +4 -0
  237. package/src/components/global-keyboard-shortcuts/index.js +12 -2
  238. package/src/components/global-keyboard-shortcuts/register-shortcuts.js +10 -0
  239. package/src/components/index.js +9 -1
  240. package/src/components/index.native.js +1 -0
  241. package/src/components/inserter-sidebar/index.js +73 -0
  242. package/src/components/inserter-sidebar/style.scss +22 -0
  243. package/src/components/list-view-sidebar/index.js +169 -0
  244. package/src/components/list-view-sidebar/list-view-outline.js +37 -0
  245. package/src/components/list-view-sidebar/style.scss +84 -0
  246. package/src/components/offline-status/index.native.js +101 -0
  247. package/src/components/offline-status/style.native.scss +28 -0
  248. package/src/components/offline-status/test/index.native.js +108 -0
  249. package/src/components/page-attributes/panel.js +62 -0
  250. package/src/components/post-discussion/panel.js +57 -0
  251. package/src/components/post-excerpt/check.js +18 -0
  252. package/src/components/post-excerpt/panel.js +57 -0
  253. package/src/components/post-excerpt/plugin.js +61 -0
  254. package/src/components/post-excerpt/test/plugin.js +36 -0
  255. package/src/components/post-featured-image/index.js +3 -7
  256. package/src/components/post-featured-image/panel.js +55 -0
  257. package/src/components/post-last-revision/panel.js +22 -0
  258. package/src/components/post-last-revision/style.scss +10 -0
  259. package/src/components/post-publish-button/index.js +1 -0
  260. package/src/components/post-publish-panel/maybe-upload-media.js +3 -8
  261. package/src/components/post-saved-state/index.js +9 -8
  262. package/src/components/post-saved-state/test/__snapshots__/index.js.snap +2 -2
  263. package/src/components/post-schedule/panel.js +1 -1
  264. package/src/components/post-taxonomies/panel.js +66 -0
  265. package/src/components/post-template/block-theme.js +110 -0
  266. package/src/components/post-template/classic-theme.js +213 -0
  267. package/src/components/post-template/create-new-template-modal.js +139 -0
  268. package/src/components/post-template/create-new-template.js +50 -0
  269. package/src/components/post-template/hooks.js +95 -0
  270. package/src/components/post-template/panel.js +66 -0
  271. package/src/components/post-template/reset-default-template.js +43 -0
  272. package/src/components/post-template/style.scss +52 -0
  273. package/src/components/post-template/swap-template-button.js +86 -0
  274. package/src/components/post-title/index.native.js +32 -18
  275. package/src/components/post-title/style.scss +1 -0
  276. package/src/components/post-title/test/__snapshots__/index.native.js.snap +25 -0
  277. package/src/components/post-title/test/index.native.js +78 -0
  278. package/src/components/post-view-link/index.js +47 -0
  279. package/src/components/post-visibility/check.js +10 -15
  280. package/src/components/post-visibility/test/check.js +24 -13
  281. package/src/components/preview-dropdown/index.js +133 -0
  282. package/src/components/preview-dropdown/style.scss +5 -0
  283. package/src/components/provider/index.js +28 -118
  284. package/src/components/provider/index.native.js +55 -14
  285. package/src/components/provider/navigation-block-editing-mode.js +37 -0
  286. package/src/components/provider/use-block-editor-settings.js +42 -17
  287. package/src/hooks/index.js +1 -0
  288. package/src/hooks/pattern-partial-syncing.js +73 -0
  289. package/src/private-apis.js +14 -0
  290. package/src/store/actions.js +160 -9
  291. package/src/store/defaults.js +1 -0
  292. package/src/store/index.js +5 -0
  293. package/src/store/private-actions.js +61 -0
  294. package/src/store/private-selectors.js +51 -0
  295. package/src/store/reducer.js +103 -26
  296. package/src/store/reducer.native.js +0 -2
  297. package/src/store/selectors.js +144 -42
  298. package/src/store/test/actions.js +56 -0
  299. package/src/store/test/reducer.js +98 -0
  300. package/src/store/test/selectors.js +137 -147
  301. package/src/style.scss +7 -0
  302. package/src/utils/media-upload/index.js +9 -2
  303. package/build/components/post-template/index.js +0 -66
  304. package/build/components/post-template/index.js.map +0 -1
  305. package/build-module/components/post-template/index.js +0 -57
  306. package/build-module/components/post-template/index.js.map +0 -1
  307. package/src/components/post-template/index.js +0 -64
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_data","require","_htmlEntities","_components","_i18n","_coreData","_icons","_notices","_store","_swapTemplateButton","_interopRequireDefault","_resetDefaultTemplate","_lockUnlock","_createNewTemplate","POPOVER_PROPS","className","placement","BlockThemeControl","id","isTemplateHidden","useSelect","select","getRenderingMode","unlock","editorStore","editedRecord","template","hasResolved","useEntityRecord","getEditorSettings","createSuccessNotice","useDispatch","noticesStore","setRenderingMode","_react","createElement","DropdownMenu","popoverProps","focusOnMount","toggleProps","variant","label","__","text","decodeEntities","title","icon","onClose","Fragment","MenuGroup","MenuItem","onClick","type","actions","defaultRenderingMode","default","check","undefined","isSelected","role"],"sources":["@wordpress/editor/src/components/post-template/block-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecord } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport SwapTemplateButton from './swap-template-button';\nimport ResetDefaultTemplate from './reset-default-template';\nimport { unlock } from '../../lock-unlock';\nimport CreateNewTemplate from './create-new-template';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nexport default function BlockThemeControl( { id } ) {\n\tconst { isTemplateHidden } = useSelect( ( select ) => {\n\t\tconst { getRenderingMode } = unlock( select( editorStore ) );\n\t\treturn {\n\t\t\tisTemplateHidden: getRenderingMode() === 'post-only',\n\t\t};\n\t}, [] );\n\tconst { editedRecord: template, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\tid\n\t);\n\tconst { getEditorSettings } = useSelect( editorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\ttoggleProps={ {\n\t\t\t\tvariant: 'tertiary',\n\t\t\t} }\n\t\t\tlabel={ __( 'Template options' ) }\n\t\t\ttext={ decodeEntities( template.title ) }\n\t\t\ticon={ null }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenderingMode( 'template-only' );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\t\t\t\tsetRenderingMode(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tgetEditorSettings()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.defaultRenderingMode\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<SwapTemplateButton onClick={ onClose } />\n\t\t\t\t\t\t<ResetDefaultTemplate onClick={ onClose } />\n\t\t\t\t\t\t<CreateNewTemplate onClick={ onClose } />\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ ! isTemplateHidden ? check : undefined }\n\t\t\t\t\t\t\tisSelected={ ! isTemplateHidden }\n\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenderingMode(\n\t\t\t\t\t\t\t\t\tisTemplateHidden\n\t\t\t\t\t\t\t\t\t\t? 'template-locked'\n\t\t\t\t\t\t\t\t\t\t: 'post-only'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Template preview' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAKA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,mBAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,qBAAA,GAAAD,sBAAA,CAAAT,OAAA;AACA,IAAAW,WAAA,GAAAX,OAAA;AACA,IAAAY,kBAAA,GAAAH,sBAAA,CAAAT,OAAA;AAlBA;AACA;AACA;;AASA;AACA;AACA;;AAOA,MAAMa,aAAa,GAAG;EACrBC,SAAS,EAAE,gCAAgC;EAC3CC,SAAS,EAAE;AACZ,C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.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = require("react");
9
+ var _i18n = require("@wordpress/i18n");
10
+ var _components = require("@wordpress/components");
11
+ var _data = require("@wordpress/data");
12
+ var _coreData = require("@wordpress/core-data");
13
+ var _blockEditor = require("@wordpress/block-editor");
14
+ var _element = require("@wordpress/element");
15
+ var _icons = require("@wordpress/icons");
16
+ var _notices = require("@wordpress/notices");
17
+ var _store = require("../../store");
18
+ var _createNewTemplateModal = _interopRequireDefault(require("./create-new-template-modal"));
19
+ var _hooks = require("./hooks");
20
+ /**
21
+ * WordPress dependencies
22
+ */
23
+
24
+ /**
25
+ * Internal dependencies
26
+ */
27
+
28
+ const POPOVER_PROPS = {
29
+ className: 'editor-post-template__dropdown',
30
+ placement: 'bottom-start'
31
+ };
32
+ function PostTemplateToggle({
33
+ isOpen,
34
+ onClick
35
+ }) {
36
+ const templateTitle = (0, _data.useSelect)(select => {
37
+ const templateSlug = select(_store.store).getEditedPostAttribute('template');
38
+ const {
39
+ supportsTemplateMode,
40
+ availableTemplates
41
+ } = select(_store.store).getEditorSettings();
42
+ if (!supportsTemplateMode && availableTemplates[templateSlug]) {
43
+ return availableTemplates[templateSlug];
44
+ }
45
+ const template = select(_coreData.store).canUser('create', 'templates') && select(_store.store).getCurrentTemplateId();
46
+ return template?.title || template?.slug || availableTemplates?.[templateSlug];
47
+ }, []);
48
+ return (0, _react.createElement)(_components.Button, {
49
+ className: "edit-post-post-template__toggle",
50
+ variant: "tertiary",
51
+ "aria-expanded": isOpen,
52
+ "aria-label": (0, _i18n.__)('Template options'),
53
+ onClick: onClick
54
+ }, templateTitle !== null && templateTitle !== void 0 ? templateTitle : (0, _i18n.__)('Default template'));
55
+ }
56
+ function PostTemplateDropdownContent({
57
+ onClose
58
+ }) {
59
+ var _options$find, _selectedOption$value;
60
+ const allowSwitchingTemplate = (0, _hooks.useAllowSwitchingTemplates)();
61
+ const {
62
+ availableTemplates,
63
+ fetchedTemplates,
64
+ selectedTemplateSlug,
65
+ canCreate,
66
+ canEdit
67
+ } = (0, _data.useSelect)(select => {
68
+ const {
69
+ canUser,
70
+ getEntityRecords
71
+ } = select(_coreData.store);
72
+ const editorSettings = select(_store.store).getEditorSettings();
73
+ const canCreateTemplates = canUser('create', 'templates');
74
+ return {
75
+ availableTemplates: editorSettings.availableTemplates,
76
+ fetchedTemplates: canCreateTemplates ? getEntityRecords('postType', 'wp_template', {
77
+ post_type: select(_store.store).getCurrentPostType(),
78
+ per_page: -1
79
+ }) : undefined,
80
+ selectedTemplateSlug: select(_store.store).getEditedPostAttribute('template'),
81
+ canCreate: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode,
82
+ canEdit: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode && !!select(_store.store).getCurrentTemplateId()
83
+ };
84
+ }, [allowSwitchingTemplate]);
85
+ const options = (0, _element.useMemo)(() => Object.entries({
86
+ ...availableTemplates,
87
+ ...Object.fromEntries((fetchedTemplates !== null && fetchedTemplates !== void 0 ? fetchedTemplates : []).map(({
88
+ slug,
89
+ title
90
+ }) => [slug, title.rendered]))
91
+ }).map(([slug, title]) => ({
92
+ value: slug,
93
+ label: title
94
+ })), [availableTemplates, fetchedTemplates]);
95
+ const selectedOption = (_options$find = options.find(option => option.value === selectedTemplateSlug)) !== null && _options$find !== void 0 ? _options$find : options.find(option => !option.value); // The default option has '' value.
96
+
97
+ const {
98
+ editPost
99
+ } = (0, _data.useDispatch)(_store.store);
100
+ const {
101
+ getEditorSettings
102
+ } = (0, _data.useSelect)(_store.store);
103
+ const {
104
+ createSuccessNotice
105
+ } = (0, _data.useDispatch)(_notices.store);
106
+ const {
107
+ setRenderingMode
108
+ } = (0, _data.useDispatch)(_store.store);
109
+ const [isCreateModalOpen, setIsCreateModalOpen] = (0, _element.useState)(false);
110
+ return (0, _react.createElement)("div", {
111
+ className: "editor-post-template__classic-theme-dropdown"
112
+ }, (0, _react.createElement)(_blockEditor.__experimentalInspectorPopoverHeader, {
113
+ title: (0, _i18n.__)('Template'),
114
+ help: (0, _i18n.__)('Templates define the way content is displayed when viewing your site.'),
115
+ actions: canCreate ? [{
116
+ icon: _icons.addTemplate,
117
+ label: (0, _i18n.__)('Add template'),
118
+ onClick: () => setIsCreateModalOpen(true)
119
+ }] : [],
120
+ onClose: onClose
121
+ }), !allowSwitchingTemplate ? (0, _react.createElement)(_components.Notice, {
122
+ status: "warning",
123
+ isDismissible: false
124
+ }, (0, _i18n.__)('The posts page template cannot be changed.')) : (0, _react.createElement)(_components.SelectControl, {
125
+ __next40pxDefaultSize: true,
126
+ __nextHasNoMarginBottom: true,
127
+ hideLabelFromVision: true,
128
+ label: (0, _i18n.__)('Template'),
129
+ value: (_selectedOption$value = selectedOption?.value) !== null && _selectedOption$value !== void 0 ? _selectedOption$value : '',
130
+ options: options,
131
+ onChange: slug => editPost({
132
+ template: slug || ''
133
+ })
134
+ }), canEdit && (0, _react.createElement)("p", null, (0, _react.createElement)(_components.Button, {
135
+ variant: "link",
136
+ onClick: () => {
137
+ setRenderingMode('template-only');
138
+ onClose();
139
+ createSuccessNotice((0, _i18n.__)('Editing template. Changes made here affect all posts and pages that use the template.'), {
140
+ type: 'snackbar',
141
+ actions: [{
142
+ label: (0, _i18n.__)('Go back'),
143
+ onClick: () => setRenderingMode(getEditorSettings().defaultRenderingMode)
144
+ }]
145
+ });
146
+ }
147
+ }, (0, _i18n.__)('Edit template'))), isCreateModalOpen && (0, _react.createElement)(_createNewTemplateModal.default, {
148
+ onClose: () => setIsCreateModalOpen(false)
149
+ }));
150
+ }
151
+ function ClassicThemeControl() {
152
+ return (0, _react.createElement)(_components.Dropdown, {
153
+ popoverProps: POPOVER_PROPS,
154
+ focusOnMount: true,
155
+ renderToggle: ({
156
+ isOpen,
157
+ onToggle
158
+ }) => (0, _react.createElement)(PostTemplateToggle, {
159
+ isOpen: isOpen,
160
+ onClick: onToggle
161
+ }),
162
+ renderContent: ({
163
+ onClose
164
+ }) => (0, _react.createElement)(PostTemplateDropdownContent, {
165
+ onClose: onClose
166
+ })
167
+ });
168
+ }
169
+ var _default = ClassicThemeControl;
170
+ exports.default = _default;
171
+ //# sourceMappingURL=classic-theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_i18n","require","_components","_data","_coreData","_blockEditor","_element","_icons","_notices","_store","_createNewTemplateModal","_interopRequireDefault","_hooks","POPOVER_PROPS","className","placement","PostTemplateToggle","isOpen","onClick","templateTitle","useSelect","select","templateSlug","editorStore","getEditedPostAttribute","supportsTemplateMode","availableTemplates","getEditorSettings","template","coreStore","canUser","getCurrentTemplateId","title","slug","_react","createElement","Button","variant","__","PostTemplateDropdownContent","onClose","_options$find","_selectedOption$value","allowSwitchingTemplate","useAllowSwitchingTemplates","fetchedTemplates","selectedTemplateSlug","canCreate","canEdit","getEntityRecords","editorSettings","canCreateTemplates","post_type","getCurrentPostType","per_page","undefined","options","useMemo","Object","entries","fromEntries","map","rendered","value","label","selectedOption","find","option","editPost","useDispatch","createSuccessNotice","noticesStore","setRenderingMode","isCreateModalOpen","setIsCreateModalOpen","useState","__experimentalInspectorPopoverHeader","help","actions","icon","addTemplate","Notice","status","isDismissible","SelectControl","__next40pxDefaultSize","__nextHasNoMarginBottom","hideLabelFromVision","onChange","type","defaultRenderingMode","default","ClassicThemeControl","Dropdown","popoverProps","focusOnMount","renderToggle","onToggle","renderContent","_default","exports"],"sources":["@wordpress/editor/src/components/post-template/classic-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { SelectControl, Dropdown, Button, Notice } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { addTemplate } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nfunction PostTemplateToggle( { isOpen, onClick } ) {\n\tconst templateTitle = useSelect( ( select ) => {\n\t\tconst templateSlug =\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' );\n\n\t\tconst { supportsTemplateMode, availableTemplates } =\n\t\t\tselect( editorStore ).getEditorSettings();\n\t\tif ( ! supportsTemplateMode && availableTemplates[ templateSlug ] ) {\n\t\t\treturn availableTemplates[ templateSlug ];\n\t\t}\n\t\tconst template =\n\t\t\tselect( coreStore ).canUser( 'create', 'templates' ) &&\n\t\t\tselect( editorStore ).getCurrentTemplateId();\n\t\treturn (\n\t\t\ttemplate?.title ||\n\t\t\ttemplate?.slug ||\n\t\t\tavailableTemplates?.[ templateSlug ]\n\t\t);\n\t}, [] );\n\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"edit-post-post-template__toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={ __( 'Template options' ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ templateTitle ?? __( 'Default template' ) }\n\t\t</Button>\n\t);\n}\n\nfunction PostTemplateDropdownContent( { onClose } ) {\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst {\n\t\tavailableTemplates,\n\t\tfetchedTemplates,\n\t\tselectedTemplateSlug,\n\t\tcanCreate,\n\t\tcanEdit,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecords } = select( coreStore );\n\t\t\tconst editorSettings = select( editorStore ).getEditorSettings();\n\t\t\tconst canCreateTemplates = canUser( 'create', 'templates' );\n\n\t\t\treturn {\n\t\t\t\tavailableTemplates: editorSettings.availableTemplates,\n\t\t\t\tfetchedTemplates: canCreateTemplates\n\t\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\t\tpost_type:\n\t\t\t\t\t\t\t\tselect( editorStore ).getCurrentPostType(),\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined,\n\t\t\t\tselectedTemplateSlug:\n\t\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' ),\n\t\t\t\tcanCreate:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode,\n\t\t\t\tcanEdit:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode &&\n\t\t\t\t\t!! select( editorStore ).getCurrentTemplateId(),\n\t\t\t};\n\t\t},\n\t\t[ allowSwitchingTemplate ]\n\t);\n\n\tconst options = useMemo(\n\t\t() =>\n\t\t\tObject.entries( {\n\t\t\t\t...availableTemplates,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\ttitle.rendered,\n\t\t\t\t\t] )\n\t\t\t\t),\n\t\t\t} ).map( ( [ slug, title ] ) => ( { value: slug, label: title } ) ),\n\t\t[ availableTemplates, fetchedTemplates ]\n\t);\n\n\tconst selectedOption =\n\t\toptions.find( ( option ) => option.value === selectedTemplateSlug ) ??\n\t\toptions.find( ( option ) => ! option.value ); // The default option has '' value.\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { getEditorSettings } = useSelect( editorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\n\treturn (\n\t\t<div className=\"editor-post-template__classic-theme-dropdown\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Template' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Templates define the way content is displayed when viewing your site.'\n\t\t\t\t) }\n\t\t\t\tactions={\n\t\t\t\t\tcanCreate\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ticon: addTemplate,\n\t\t\t\t\t\t\t\t\tlabel: __( 'Add template' ),\n\t\t\t\t\t\t\t\t\tonClick: () => setIsCreateModalOpen( true ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: []\n\t\t\t\t}\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t{ ! allowSwitchingTemplate ? (\n\t\t\t\t<Notice status=\"warning\" isDismissible={ false }>\n\t\t\t\t\t{ __( 'The posts page template cannot be changed.' ) }\n\t\t\t\t</Notice>\n\t\t\t) : (\n\t\t\t\t<SelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Template' ) }\n\t\t\t\t\tvalue={ selectedOption?.value ?? '' }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( slug ) =>\n\t\t\t\t\t\teditPost( { template: slug || '' } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canEdit && (\n\t\t\t\t<p>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetRenderingMode( 'template-only' );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\t\t\tsetRenderingMode(\n\t\t\t\t\t\t\t\t\t\t\t\t\tgetEditorSettings()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t.defaultRenderingMode\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => setIsCreateModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction ClassicThemeControl() {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<PostTemplateToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<PostTemplateDropdownContent onClose={ onClose } />\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default ClassicThemeControl;\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAKA,IAAAQ,MAA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AE,SAAU,CAAC;UACtBpB,OAAO,EAAEA,CAAA,KACRsD,gBAAgB,CACf7C,iBAAiB,CAAC,CAAC,CACjB+D,oBACH;QACF,CAAC;MAEH,CACD,CAAC;IACF;EAAG,GAED,IAAApD,QAAE,EAAE,eAAgB,CACf,CACN,CACH,EACCmC,iBAAiB,IAClB,IAAAvC,MAAA,CAAAC,aAAA,EAACzB,uBAAA,CAAAiF,OAAsB;IACtBnD,OAAO,EAAGA,CAAA,KAAMkC,oBAAoB,CAAE,KAAM;EAAG,CAC/C,CAEE,CAAC;AAER;AAEA,SAASkB,mBAAmBA,CAAA,EAAG;EAC9B,OACC,IAAA1D,MAAA,CAAAC,aAAA,EAACjC,WAAA,CAAA2F,QAAQ;IACRC,YAAY,EAAGjF,aAAe;IAC9BkF,YAAY;IACZC,YAAY,EAAGA,CAAE;MAAE/E,MAAM;MAAEgF;IAAS,CAAC,KACpC,IAAA/D,MAAA,CAAAC,aAAA,EAACnB,kBAAkB;MAACC,MAAM,EAAGA,MAAQ;MAACC,OAAO,EAAG+E;IAAU,CAAE,CAC1D;IACHC,aAAa,EAAGA,CAAE;MAAE1D;IAAQ,CAAC,KAC5B,IAAAN,MAAA,CAAAC,aAAA,EAACI,2BAA2B;MAACC,OAAO,EAAGA;IAAS,CAAE;EAChD,CACH,CAAC;AAEJ;AAAC,IAAA2D,QAAA,GAEcP,mBAAmB;AAAAQ,OAAA,CAAAT,OAAA,GAAAQ,QAAA"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = CreateNewTemplateModal;
7
+ var _react = require("react");
8
+ var _data = require("@wordpress/data");
9
+ var _element = require("@wordpress/element");
10
+ var _blocks = require("@wordpress/blocks");
11
+ var _components = require("@wordpress/components");
12
+ var _i18n = require("@wordpress/i18n");
13
+ var _url = require("@wordpress/url");
14
+ var _lockUnlock = require("../../lock-unlock");
15
+ var _store = require("../../store");
16
+ /**
17
+ * WordPress dependencies
18
+ */
19
+
20
+ /**
21
+ * Internal dependencies
22
+ */
23
+
24
+ const DEFAULT_TITLE = (0, _i18n.__)('Custom Template');
25
+ function CreateNewTemplateModal({
26
+ onClose
27
+ }) {
28
+ const defaultBlockTemplate = (0, _data.useSelect)(select => select(_store.store).getEditorSettings().defaultBlockTemplate, []);
29
+ const {
30
+ createTemplate,
31
+ setRenderingMode
32
+ } = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
33
+ const [title, setTitle] = (0, _element.useState)('');
34
+ const [isBusy, setIsBusy] = (0, _element.useState)(false);
35
+ const cancel = () => {
36
+ setTitle('');
37
+ onClose();
38
+ };
39
+ const submit = async event => {
40
+ event.preventDefault();
41
+ if (isBusy) {
42
+ return;
43
+ }
44
+ setIsBusy(true);
45
+ const newTemplateContent = defaultBlockTemplate !== null && defaultBlockTemplate !== void 0 ? defaultBlockTemplate : (0, _blocks.serialize)([(0, _blocks.createBlock)('core/group', {
46
+ tagName: 'header',
47
+ layout: {
48
+ inherit: true
49
+ }
50
+ }, [(0, _blocks.createBlock)('core/site-title'), (0, _blocks.createBlock)('core/site-tagline')]), (0, _blocks.createBlock)('core/separator'), (0, _blocks.createBlock)('core/group', {
51
+ tagName: 'main'
52
+ }, [(0, _blocks.createBlock)('core/group', {
53
+ layout: {
54
+ inherit: true
55
+ }
56
+ }, [(0, _blocks.createBlock)('core/post-title')]), (0, _blocks.createBlock)('core/post-content', {
57
+ layout: {
58
+ inherit: true
59
+ }
60
+ })])]);
61
+ await createTemplate({
62
+ slug: (0, _url.cleanForSlug)(title || DEFAULT_TITLE),
63
+ content: newTemplateContent,
64
+ title: title || DEFAULT_TITLE
65
+ });
66
+ setIsBusy(false);
67
+ cancel();
68
+ setRenderingMode('template-only');
69
+ };
70
+ return (0, _react.createElement)(_components.Modal, {
71
+ title: (0, _i18n.__)('Create custom template'),
72
+ onRequestClose: cancel
73
+ }, (0, _react.createElement)("form", {
74
+ className: "editor-post-template__create-form",
75
+ onSubmit: submit
76
+ }, (0, _react.createElement)(_components.__experimentalVStack, {
77
+ spacing: "3"
78
+ }, (0, _react.createElement)(_components.TextControl, {
79
+ __nextHasNoMarginBottom: true,
80
+ label: (0, _i18n.__)('Name'),
81
+ value: title,
82
+ onChange: setTitle,
83
+ placeholder: DEFAULT_TITLE,
84
+ disabled: isBusy,
85
+ help: (0, _i18n.__)('Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.')
86
+ }), (0, _react.createElement)(_components.__experimentalHStack, {
87
+ justify: "right"
88
+ }, (0, _react.createElement)(_components.Button, {
89
+ variant: "tertiary",
90
+ onClick: cancel
91
+ }, (0, _i18n.__)('Cancel')), (0, _react.createElement)(_components.Button, {
92
+ variant: "primary",
93
+ type: "submit",
94
+ isBusy: isBusy,
95
+ "aria-disabled": isBusy
96
+ }, (0, _i18n.__)('Create'))))));
97
+ }
98
+ //# sourceMappingURL=create-new-template-modal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_data","require","_element","_blocks","_components","_i18n","_url","_lockUnlock","_store","DEFAULT_TITLE","__","CreateNewTemplateModal","onClose","defaultBlockTemplate","useSelect","select","editorStore","getEditorSettings","createTemplate","setRenderingMode","unlock","useDispatch","title","setTitle","useState","isBusy","setIsBusy","cancel","submit","event","preventDefault","newTemplateContent","serialize","createBlock","tagName","layout","inherit","slug","cleanForSlug","content","_react","createElement","Modal","onRequestClose","className","onSubmit","__experimentalVStack","spacing","TextControl","__nextHasNoMarginBottom","label","value","onChange","placeholder","disabled","help","__experimentalHStack","justify","Button","variant","onClick","type"],"sources":["@wordpress/editor/src/components/post-template/create-new-template-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { serialize, createBlock } from '@wordpress/blocks';\nimport {\n\tModal,\n\tTextControl,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cleanForSlug } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst DEFAULT_TITLE = __( 'Custom Template' );\n\nexport default function CreateNewTemplateModal( { onClose } ) {\n\tconst defaultBlockTemplate = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).getEditorSettings().defaultBlockTemplate,\n\t\t[]\n\t);\n\n\tconst { createTemplate, setRenderingMode } = unlock(\n\t\tuseDispatch( editorStore )\n\t);\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\tawait createTemplate( {\n\t\t\tslug: cleanForSlug( title || DEFAULT_TITLE ),\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || DEFAULT_TITLE,\n\t\t} );\n\n\t\tsetIsBusy( false );\n\t\tcancel();\n\t\tsetRenderingMode( 'template-only' );\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create custom template' ) }\n\t\t\tonRequestClose={ cancel }\n\t\t>\n\t\t\t<form\n\t\t\t\tclassName=\"editor-post-template__create-form\"\n\t\t\t\tonSubmit={ submit }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ DEFAULT_TITLE }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Describe the template, e.g. \"Post with sidebar\". A custom template can be manually applied to any post or page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ cancel }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\t\taria-disabled={ isBusy }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>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AAAP,MAAA,CAAAC,aAAA,EAACrC,WAAA,CAAA4C,WAAW;IACXC,uBAAuB;IACvBC,KAAK,EAAG,IAAAxC,QAAE,EAAE,MAAO,CAAG;IACtByC,KAAK,EAAG7B,KAAO;IACf8B,QAAQ,EAAG7B,QAAU;IACrB8B,WAAW,EAAG5C,aAAe;IAC7B6C,QAAQ,EAAG7B,MAAQ;IACnB8B,IAAI,EAAG,IAAA7C,QAAE,EACR,iHACD;EAAG,CACH,CAAC,EACF,IAAA8B,MAAA,CAAAC,aAAA,EAACrC,WAAA,CAAAoD,oBAAM;IAACC,OAAO,EAAC;EAAO,GACtB,IAAAjB,MAAA,CAAAC,aAAA,EAACrC,WAAA,CAAAsD,MAAM;IAACC,OAAO,EAAC,UAAU;IAACC,OAAO,EAAGjC;EAAQ,GAC1C,IAAAjB,QAAE,EAAE,QAAS,CACR,CAAC,EAET,IAAA8B,MAAA,CAAAC,aAAA,EAACrC,WAAA,CAAAsD,MAAM;IACNC,OAAO,EAAC,SAAS;IACjBE,IAAI,EAAC,QAAQ;IACbpC,MAAM,EAAGA,MAAQ;IACjB,iBAAgBA;EAAQ,GAEtB,IAAAf,QAAE,EAAE,QAAS,CACR,CACD,CACD,CACH,CACA,CAAC;AAEV"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = CreateNewTemplate;
8
+ var _react = require("react");
9
+ var _components = require("@wordpress/components");
10
+ var _i18n = require("@wordpress/i18n");
11
+ var _data = require("@wordpress/data");
12
+ var _coreData = require("@wordpress/core-data");
13
+ var _element = require("@wordpress/element");
14
+ var _createNewTemplateModal = _interopRequireDefault(require("./create-new-template-modal"));
15
+ var _hooks = require("./hooks");
16
+ /**
17
+ * WordPress dependencies
18
+ */
19
+
20
+ /**
21
+ * Internal dependencies
22
+ */
23
+
24
+ function CreateNewTemplate({
25
+ onClick
26
+ }) {
27
+ const {
28
+ canCreateTemplates
29
+ } = (0, _data.useSelect)(select => {
30
+ const {
31
+ canUser
32
+ } = select(_coreData.store);
33
+ return {
34
+ canCreateTemplates: canUser('create', 'templates')
35
+ };
36
+ }, []);
37
+ const [isCreateModalOpen, setIsCreateModalOpen] = (0, _element.useState)(false);
38
+ const allowSwitchingTemplate = (0, _hooks.useAllowSwitchingTemplates)();
39
+
40
+ // The default template in a post is indicated by an empty string.
41
+ if (!canCreateTemplates || !allowSwitchingTemplate) {
42
+ return null;
43
+ }
44
+ return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_components.MenuItem, {
45
+ onClick: () => {
46
+ setIsCreateModalOpen(true);
47
+ }
48
+ }, (0, _i18n.__)('Create new template')), isCreateModalOpen && (0, _react.createElement)(_createNewTemplateModal.default, {
49
+ onClose: () => {
50
+ setIsCreateModalOpen(false);
51
+ onClick();
52
+ }
53
+ }));
54
+ }
55
+ //# sourceMappingURL=create-new-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_components","require","_i18n","_data","_coreData","_element","_createNewTemplateModal","_interopRequireDefault","_hooks","CreateNewTemplate","onClick","canCreateTemplates","useSelect","select","canUser","coreStore","isCreateModalOpen","setIsCreateModalOpen","useState","allowSwitchingTemplate","useAllowSwitchingTemplates","_react","createElement","Fragment","MenuItem","__","default","onClose"],"sources":["@wordpress/editor/src/components/post-template/create-new-template.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nexport default function CreateNewTemplate( { onClick } ) {\n\tconst { canCreateTemplates } = useSelect( ( select ) => {\n\t\tconst { canUser } = select( coreStore );\n\t\treturn {\n\t\t\tcanCreateTemplates: canUser( 'create', 'templates' ),\n\t\t};\n\t}, [] );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\n\t// The default template in a post is indicated by an empty string.\n\tif ( ! canCreateTemplates || ! allowSwitchingTemplate ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsCreateModalOpen( true );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Create new template' ) }\n\t\t\t</MenuItem>\n\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsCreateModalOpen( false );\n\t\t\t\t\t\tonClick();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,uBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIe,SAASQ,iBAAiBA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EACxD,MAAM;IAAEC;EAAmB,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACvD,MAAM;MAAEC;IAAQ,CAAC,GAAGD,MAAM,CAAEE,eAAU,CAAC;IACvC,OAAO;MACNJ,kBAAkB,EAAEG,OAAO,CAAE,QAAQ,EAAE,WAAY;IACpD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,MAAM,CAAEE,iBAAiB,EAAEC,oBAAoB,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EACrE,MAAMC,sBAAsB,GAAG,IAAAC,iCAA0B,EAAC,CAAC;;EAE3D;EACA,IAAK,CAAET,kBAAkB,IAAI,CAAEQ,sBAAsB,EAAG;IACvD,OAAO,IAAI;EACZ;EACA,OACC,IAAAE,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAE,QAAA,QACC,IAAAF,MAAA,CAAAC,aAAA,EAACtB,WAAA,CAAAwB,QAAQ;IACRd,OAAO,EAAGA,CAAA,KAAM;MACfO,oBAAoB,CAAE,IAAK,CAAC;IAC7B;EAAG,GAED,IAAAQ,QAAE,EAAE,qBAAsB,CACnB,CAAC,EAETT,iBAAiB,IAClB,IAAAK,MAAA,CAAAC,aAAA,EAAChB,uBAAA,CAAAoB,OAAsB;IACtBC,OAAO,EAAGA,CAAA,KAAM;MACfV,oBAAoB,CAAE,KAAM,CAAC;MAC7BP,OAAO,CAAC,CAAC;IACV;EAAG,CACH,CAED,CAAC;AAEL"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useAllowSwitchingTemplates = useAllowSwitchingTemplates;
7
+ exports.useAvailableTemplates = useAvailableTemplates;
8
+ exports.useCurrentTemplateSlug = useCurrentTemplateSlug;
9
+ exports.useEditedPostContext = useEditedPostContext;
10
+ var _data = require("@wordpress/data");
11
+ var _element = require("@wordpress/element");
12
+ var _coreData = require("@wordpress/core-data");
13
+ var _store = require("../../store");
14
+ /**
15
+ * WordPress dependencies
16
+ */
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+
22
+ function useEditedPostContext() {
23
+ return (0, _data.useSelect)(select => {
24
+ const {
25
+ getCurrentPostId,
26
+ getCurrentPostType
27
+ } = select(_store.store);
28
+ return {
29
+ postId: getCurrentPostId(),
30
+ postType: getCurrentPostType()
31
+ };
32
+ }, []);
33
+ }
34
+ function useAllowSwitchingTemplates() {
35
+ const {
36
+ postType,
37
+ postId
38
+ } = useEditedPostContext();
39
+ return (0, _data.useSelect)(select => {
40
+ const {
41
+ getEntityRecord,
42
+ getEntityRecords
43
+ } = select(_coreData.store);
44
+ const siteSettings = getEntityRecord('root', 'site');
45
+ const templates = getEntityRecords('postType', 'wp_template', {
46
+ per_page: -1
47
+ });
48
+ const isPostsPage = +postId === siteSettings?.page_for_posts;
49
+ // If current page is set front page or posts page, we also need
50
+ // to check if the current theme has a template for it. If not
51
+ const isFrontPage = postType === 'page' && +postId === siteSettings?.page_on_front && templates?.some(({
52
+ slug
53
+ }) => slug === 'front-page');
54
+ return !isPostsPage && !isFrontPage;
55
+ }, [postId, postType]);
56
+ }
57
+ function useTemplates(postType) {
58
+ return (0, _data.useSelect)(select => select(_coreData.store).getEntityRecords('postType', 'wp_template', {
59
+ per_page: -1,
60
+ post_type: postType
61
+ }), [postType]);
62
+ }
63
+ function useAvailableTemplates(postType) {
64
+ const currentTemplateSlug = useCurrentTemplateSlug();
65
+ const allowSwitchingTemplate = useAllowSwitchingTemplates();
66
+ const templates = useTemplates(postType);
67
+ return (0, _element.useMemo)(() => allowSwitchingTemplate && templates?.filter(template => template.is_custom && template.slug !== currentTemplateSlug && !!template.content.raw // Skip empty templates.
68
+ ), [templates, currentTemplateSlug, allowSwitchingTemplate]);
69
+ }
70
+ function useCurrentTemplateSlug() {
71
+ const {
72
+ postType,
73
+ postId
74
+ } = useEditedPostContext();
75
+ const templates = useTemplates(postType);
76
+ const entityTemplate = (0, _data.useSelect)(select => {
77
+ const post = select(_coreData.store).getEditedEntityRecord('postType', postType, postId);
78
+ return post?.template;
79
+ }, [postType, postId]);
80
+ if (!entityTemplate) {
81
+ return;
82
+ }
83
+ // If a page has a `template` set and is not included in the list
84
+ // of the theme's templates, do not return it, in order to resolve
85
+ // to the current theme's default template.
86
+ return templates?.find(template => template.slug === entityTemplate)?.slug;
87
+ }
88
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_data","require","_element","_coreData","_store","useEditedPostContext","useSelect","select","getCurrentPostId","getCurrentPostType","editorStore","postId","postType","useAllowSwitchingTemplates","getEntityRecord","getEntityRecords","coreStore","siteSettings","templates","per_page","isPostsPage","page_for_posts","isFrontPage","page_on_front","some","slug","useTemplates","post_type","useAvailableTemplates","currentTemplateSlug","useCurrentTemplateSlug","allowSwitchingTemplate","useMemo","filter","template","is_custom","content","raw","entityTemplate","post","getEditedEntityRecord","find"],"sources":["@wordpress/editor/src/components/post-template/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function useEditedPostContext() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n}\nexport function useAllowSwitchingTemplates() {\n\tconst { postType, postId } = useEditedPostContext();\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getEntityRecords } = select( coreStore );\n\t\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\t\tconst templates = getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t} );\n\t\t\tconst isPostsPage = +postId === siteSettings?.page_for_posts;\n\t\t\t// If current page is set front page or posts page, we also need\n\t\t\t// to check if the current theme has a template for it. If not\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' &&\n\t\t\t\t+postId === siteSettings?.page_on_front &&\n\t\t\t\ttemplates?.some( ( { slug } ) => slug === 'front-page' );\n\t\t\treturn ! isPostsPage && ! isFrontPage;\n\t\t},\n\t\t[ postId, postType ]\n\t);\n}\n\nfunction useTemplates( postType ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t\tpost_type: postType,\n\t\t\t} ),\n\t\t[ postType ]\n\t);\n}\n\nexport function useAvailableTemplates( postType ) {\n\tconst currentTemplateSlug = useCurrentTemplateSlug();\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst templates = useTemplates( postType );\n\treturn useMemo(\n\t\t() =>\n\t\t\tallowSwitchingTemplate &&\n\t\t\ttemplates?.filter(\n\t\t\t\t( template ) =>\n\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\ttemplate.slug !== currentTemplateSlug &&\n\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t),\n\t\t[ templates, currentTemplateSlug, allowSwitchingTemplate ]\n\t);\n}\n\nexport function useCurrentTemplateSlug() {\n\tconst { postType, postId } = useEditedPostContext();\n\tconst templates = useTemplates( postType );\n\tconst entityTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\treturn post?.template;\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tif ( ! entityTemplate ) {\n\t\treturn;\n\t}\n\t// If a page has a `template` set and is not included in the list\n\t// of the theme's templates, do not return it, in order to resolve\n\t// to the current theme's default template.\n\treturn templates?.find( ( template ) => template.slug === entityTemplate )\n\t\t?.slug;\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAKA;AACA;AACA;;AAGO,SAASI,oBAAoBA,CAAA,EAAG;EACtC,OAAO,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC/B,MAAM;MAAEC,gBAAgB;MAAEC;IAAmB,CAAC,GAAGF,MA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mBAAmB,GAAGC,sBAAsB,CAAC,CAAC;EACpD,MAAMC,sBAAsB,GAAGlB,0BAA0B,CAAC,CAAC;EAC3D,MAAMK,SAAS,GAAGQ,YAAY,CAAEd,QAAS,CAAC;EAC1C,OAAO,IAAAoB,gBAAO,EACb,MACCD,sBAAsB,IACtBb,SAAS,EAAEe,MAAM,CACdC,QAAQ,IACTA,QAAQ,CAACC,SAAS,IAClBD,QAAQ,CAACT,IAAI,KAAKI,mBAAmB,IACrC,CAAC,CAAEK,QAAQ,CAACE,OAAO,CAACC,GAAG,CAAC;EAC1B,CAAC,EACF,CAAEnB,SAAS,EAAEW,mBAAmB,EAAEE,sBAAsB,CACzD,CAAC;AACF;AAEO,SAASD,sBAAsBA,CAAA,EAAG;EACxC,MAAM;IAAElB,QAAQ;IAAED;EAAO,CAAC,GAAGN,oBAAoB,CAAC,CAAC;EACnD,MAAMa,SAAS,GAAGQ,YAAY,CAAEd,QAAS,CAAC;EAC1C,MAAM0B,cAAc,GAAG,IAAAhC,eAAS,EAC7BC,MAAM,IAAM;IACb,MAAMgC,IAAI,GAAGhC,MAAM,CAAES,eAAU,CAAC,CAACwB,qBAAqB,CACrD,UAAU,EACV5B,QAAQ,EACRD,MACD,CAAC;IACD,OAAO4B,IAAI,EAAEL,QAAQ;EACtB,CAAC,EACD,CAAEtB,QAAQ,EAAED,MAAM,CACnB,CAAC;EAED,IAAK,CAAE2B,cAAc,EAAG;IACvB;EACD;EACA;EACA;EACA;EACA,OAAOpB,SAAS,EAAEuB,IAAI,CAAIP,QAAQ,IAAMA,QAAQ,CAACT,IAAI,KAAKa,cAAe,CAAC,EACvEb,IAAI;AACR"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = PostTemplatePanel;
8
+ var _react = require("react");
9
+ var _data = require("@wordpress/data");
10
+ var _i18n = require("@wordpress/i18n");
11
+ var _coreData = require("@wordpress/core-data");
12
+ var _store = require("../../store");
13
+ var _classicTheme = _interopRequireDefault(require("./classic-theme"));
14
+ var _blockTheme = _interopRequireDefault(require("./block-theme"));
15
+ var _postPanelRow = _interopRequireDefault(require("../post-panel-row"));
16
+ /**
17
+ * WordPress dependencies
18
+ */
19
+
20
+ /**
21
+ * Internal dependencies
22
+ */
23
+
24
+ function PostTemplatePanel() {
25
+ const {
26
+ templateId,
27
+ isBlockTheme
28
+ } = (0, _data.useSelect)(select => {
29
+ const {
30
+ getCurrentTemplateId,
31
+ getEditorSettings
32
+ } = select(_store.store);
33
+ return {
34
+ templateId: getCurrentTemplateId(),
35
+ isBlockTheme: getEditorSettings().__unstableIsBlockBasedTheme
36
+ };
37
+ }, []);
38
+ const isVisible = (0, _data.useSelect)(select => {
39
+ var _select$canUser;
40
+ const postTypeSlug = select(_store.store).getCurrentPostType();
41
+ const postType = select(_coreData.store).getPostType(postTypeSlug);
42
+ if (!postType?.viewable) {
43
+ return false;
44
+ }
45
+ const settings = select(_store.store).getEditorSettings();
46
+ const hasTemplates = !!settings.availableTemplates && Object.keys(settings.availableTemplates).length > 0;
47
+ if (hasTemplates) {
48
+ return true;
49
+ }
50
+ if (!settings.supportsTemplateMode) {
51
+ return false;
52
+ }
53
+ const canCreateTemplates = (_select$canUser = select(_coreData.store).canUser('create', 'templates')) !== null && _select$canUser !== void 0 ? _select$canUser : false;
54
+ return canCreateTemplates;
55
+ }, []);
56
+ if (!isBlockTheme && isVisible) {
57
+ return (0, _react.createElement)(_postPanelRow.default, {
58
+ label: (0, _i18n.__)('Template')
59
+ }, (0, _react.createElement)(_classicTheme.default, null));
60
+ }
61
+ if (isBlockTheme && !!templateId) {
62
+ return (0, _react.createElement)(_postPanelRow.default, {
63
+ label: (0, _i18n.__)('Template')
64
+ }, (0, _react.createElement)(_blockTheme.default, {
65
+ id: templateId
66
+ }));
67
+ }
68
+ return null;
69
+ }
70
+ //# sourceMappingURL=panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_data","require","_i18n","_coreData","_store","_classicTheme","_interopRequireDefault","_blockTheme","_postPanelRow","PostTemplatePanel","templateId","isBlockTheme","useSelect","select","getCurrentTemplateId","getEditorSettings","editorStore","__unstableIsBlockBasedTheme","isVisible","_select$canUser","postTypeSlug","getCurrentPostType","postType","coreStore","getPostType","viewable","settings","hasTemplates","availableTemplates","Object","keys","length","supportsTemplateMode","canCreateTemplates","canUser","_react","createElement","default","label","__","id"],"sources":["@wordpress/editor/src/components/post-template/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport ClassicThemeControl from './classic-theme';\nimport BlockThemeControl from './block-theme';\nimport PostPanelRow from '../post-panel-row';\n\nexport default function PostTemplatePanel() {\n\tconst { templateId, isBlockTheme } = useSelect( ( select ) => {\n\t\tconst { getCurrentTemplateId, getEditorSettings } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\ttemplateId: getCurrentTemplateId(),\n\t\t\tisBlockTheme: getEditorSettings().__unstableIsBlockBasedTheme,\n\t\t};\n\t}, [] );\n\n\tconst isVisible = useSelect( ( select ) => {\n\t\tconst postTypeSlug = select( editorStore ).getCurrentPostType();\n\t\tconst postType = select( coreStore ).getPostType( postTypeSlug );\n\t\tif ( ! postType?.viewable ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst settings = select( editorStore ).getEditorSettings();\n\t\tconst hasTemplates =\n\t\t\t!! settings.availableTemplates &&\n\t\t\tObject.keys( settings.availableTemplates ).length > 0;\n\t\tif ( hasTemplates ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( ! settings.supportsTemplateMode ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst canCreateTemplates =\n\t\t\tselect( coreStore ).canUser( 'create', 'templates' ) ?? false;\n\t\treturn canCreateTemplates;\n\t}, [] );\n\n\tif ( ! isBlockTheme && isVisible ) {\n\t\treturn (\n\t\t\t<PostPanelRow label={ __( 'Template' ) }>\n\t\t\t\t<ClassicThemeControl />\n\t\t\t</PostPanelRow>\n\t\t);\n\t}\n\n\tif ( isBlockTheme && !! templateId ) {\n\t\treturn (\n\t\t\t<PostPanelRow label={ __( 'Template' ) }>\n\t\t\t\t<BlockThemeControl id={ templateId } />\n\t\t\t</PostPanelRow>\n\t\t);\n\t}\n\treturn null;\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,WAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,aAAA,GAAAF,sBAAA,CAAAL,OAAA;AAbA;AACA;AACA;;AAKA;AACA;AACA;;AAMe,SAASQ,iBAAiBA,CAAA,EAAG;EAC3C,MAAM;IAAEC,UAAU;IAAEC;EAAa,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC7D,MAAM;MAAEC,oBAAoB;MAAEC;IAAkB,CAAC,GAChDF,MAAM,CAAEG,YAAY,CAAC;IACtB,OAAO;MACNN,UAAU,EAAEI,oBAAoB,CAAC,CAAC;MAClCH,YAAY,EAAEI,iBAAiB,CAAC,CAAC,CAACE;IACnC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMC,SAAS,GAAG,IAAAN,eAAS,EAAIC,MAAM,IAAM;IAAA,IAAAM,eAAA;IAC1C,MAAMC,YAAY,GAAGP,MAAM,CAAEG,YAAY,CAAC,CAACK,kBAAkB,CAAC,CAAC;IAC/D,MAAMC,QAAQ,GAAGT,MAAM,CAAEU,eAAU,CAAC,CAACC,WAAW,CAAEJ,YAAa,C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ty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = ResetDefaultTemplate;
7
+ var _react = require("react");
8
+ var _components = require("@wordpress/components");
9
+ var _i18n = require("@wordpress/i18n");
10
+ var _data = require("@wordpress/data");
11
+ var _coreData = require("@wordpress/core-data");
12
+ var _hooks = require("./hooks");
13
+ /**
14
+ * WordPress dependencies
15
+ */
16
+
17
+ /**
18
+ * Internal dependencies
19
+ */
20
+
21
+ function ResetDefaultTemplate({
22
+ onClick
23
+ }) {
24
+ const currentTemplateSlug = (0, _hooks.useCurrentTemplateSlug)();
25
+ const allowSwitchingTemplate = (0, _hooks.useAllowSwitchingTemplates)();
26
+ const {
27
+ postType,
28
+ postId
29
+ } = (0, _hooks.useEditedPostContext)();
30
+ const {
31
+ editEntityRecord
32
+ } = (0, _data.useDispatch)(_coreData.store);
33
+ // The default template in a post is indicated by an empty string.
34
+ if (!currentTemplateSlug || !allowSwitchingTemplate) {
35
+ return null;
36
+ }
37
+ return (0, _react.createElement)(_components.MenuItem, {
38
+ onClick: () => {
39
+ editEntityRecord('postType', postType, postId, {
40
+ template: ''
41
+ }, {
42
+ undoIgnore: true
43
+ });
44
+ onClick();
45
+ }
46
+ }, (0, _i18n.__)('Use default template'));
47
+ }
48
+ //# sourceMappingURL=reset-default-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_components","require","_i18n","_data","_coreData","_hooks","ResetDefaultTemplate","onClick","currentTemplateSlug","useCurrentTemplateSlug","allowSwitchingTemplate","useAllowSwitchingTemplates","postType","postId","useEditedPostContext","editEntityRecord","useDispatch","coreStore","_react","createElement","MenuItem","template","undoIgnore","__"],"sources":["@wordpress/editor/src/components/post-template/reset-default-template.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseAllowSwitchingTemplates,\n\tuseCurrentTemplateSlug,\n\tuseEditedPostContext,\n} from './hooks';\n\nexport default function ResetDefaultTemplate( { onClick } ) {\n\tconst currentTemplateSlug = useCurrentTemplateSlug();\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst { postType, postId } = useEditedPostContext();\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\t// The default template in a post is indicated by an empty string.\n\tif ( ! currentTemplateSlug || ! allowSwitchingTemplate ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId,\n\t\t\t\t\t{ template: '' },\n\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t);\n\t\t\t\tonClick();\n\t\t\t} }\n\t\t>\n\t\t\t{ __( 'Use default template' ) }\n\t\t</MenuItem>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AAXA;AACA;AACA;;AAMA;AACA;AACA;;AAOe,SAASK,oBAAoBA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EAC3D,MAAMC,mBAAmB,GAAG,IAAAC,6BAAsB,EAAC,CAAC;EACpD,MAAMC,sBAAsB,GAAG,IAAAC,iCAA0B,EAAC,CAAC;EAC3D,MAAM;IAAEC,QAAQ;IAAEC;EAAO,CAAC,GAAG,IAAAC,2BAAoB,EAAC,CAAC;EACnD,MAAM;IAAEC;EAAiB,CAAC,GAAG,IAAAC,iBAAW,EAAEC,eAAU,CAAC;EACrD;EACA,IAAK,CAAET,mBAAmB,IAAI,CAAEE,sBAAsB,EAAG;IACxD,OAAO,IAAI;EACZ;EACA,OACC,IAAAQ,MAAA,CAAAC,aAAA,EAACnB,WAAA,CAAAoB,QAAQ;IACRb,OAAO,EAAGA,CAAA,KAAM;MACfQ,gBAAgB,CACf,UAAU,EACVH,QAAQ,EACRC,MAAM,EACN;QAAEQ,QAAQ,EAAE;MAAG,CAAC,EAChB;QAAEC,UAAU,EAAE;MAAK,CACpB,CAAC;MACDf,OAAO,CAAC,CAAC;IACV;EAAG,GAED,IAAAgB,QAAE,EAAE,sBAAuB,CACpB,CAAC;AAEb"}