@wordpress/editor 14.42.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 (199) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/collaborators-overlay/cursor-registry.cjs +86 -0
  3. package/build/components/collaborators-overlay/cursor-registry.cjs.map +7 -0
  4. package/build/components/collaborators-overlay/index.cjs +7 -2
  5. package/build/components/collaborators-overlay/index.cjs.map +2 -2
  6. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +1 -1
  7. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +2 -2
  8. package/build/components/collaborators-overlay/overlay.cjs +31 -1
  9. package/build/components/collaborators-overlay/overlay.cjs.map +2 -2
  10. package/build/components/collaborators-presence/index.cjs +14 -4
  11. package/build/components/collaborators-presence/index.cjs.map +2 -2
  12. package/build/components/collaborators-presence/list.cjs +20 -4
  13. package/build/components/collaborators-presence/list.cjs.map +2 -2
  14. package/build/components/post-card-panel/index.cjs +4 -15
  15. package/build/components/post-card-panel/index.cjs.map +2 -2
  16. package/build/components/post-content-information/index.cjs +10 -13
  17. package/build/components/post-content-information/index.cjs.map +2 -2
  18. package/build/components/post-revisions-panel/index.cjs +164 -0
  19. package/build/components/post-revisions-panel/index.cjs.map +7 -0
  20. package/build/components/post-revisions-preview/revisions-slider.cjs +24 -5
  21. package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
  22. package/build/components/post-template/create-new-template-modal.cjs +39 -46
  23. package/build/components/post-template/create-new-template-modal.cjs.map +2 -2
  24. package/build/components/post-template/hooks.cjs +52 -6
  25. package/build/components/post-template/hooks.cjs.map +2 -2
  26. package/build/components/post-template/swap-template-button.cjs +31 -20
  27. package/build/components/post-template/swap-template-button.cjs.map +2 -2
  28. package/build/components/preferences-modal/index.cjs +35 -27
  29. package/build/components/preferences-modal/index.cjs.map +2 -2
  30. package/build/components/revision-block-diff/index.cjs +9 -32
  31. package/build/components/revision-block-diff/index.cjs.map +3 -3
  32. package/build/components/revision-diff-panel/index.cjs +68 -0
  33. package/build/components/revision-diff-panel/index.cjs.map +7 -0
  34. package/build/components/revision-fields-diff/index.cjs +96 -0
  35. package/build/components/revision-fields-diff/index.cjs.map +7 -0
  36. package/build/components/sidebar/dataform-post-summary.cjs +8 -53
  37. package/build/components/sidebar/dataform-post-summary.cjs.map +2 -2
  38. package/build/components/sidebar/index.cjs +25 -22
  39. package/build/components/sidebar/index.cjs.map +3 -3
  40. package/build/components/sidebar/post-revision-summary.cjs +74 -0
  41. package/build/components/sidebar/post-revision-summary.cjs.map +7 -0
  42. package/build/components/sidebar/post-summary.cjs +35 -42
  43. package/build/components/sidebar/post-summary.cjs.map +3 -3
  44. package/build/components/style-book/index.cjs +4 -3
  45. package/build/components/style-book/index.cjs.map +2 -2
  46. package/build/components/sync-connection-error-modal/index.cjs +2 -2
  47. package/build/components/sync-connection-error-modal/index.cjs.map +1 -1
  48. package/build/components/template-actions-panel/block-theme-content.cjs +188 -0
  49. package/build/components/template-actions-panel/block-theme-content.cjs.map +7 -0
  50. package/build/components/template-actions-panel/classic-theme-content.cjs +159 -0
  51. package/build/components/template-actions-panel/classic-theme-content.cjs.map +7 -0
  52. package/build/components/template-actions-panel/index.cjs +59 -0
  53. package/build/components/template-actions-panel/index.cjs.map +7 -0
  54. package/build/dataviews/store/private-actions.cjs +2 -0
  55. package/build/dataviews/store/private-actions.cjs.map +2 -2
  56. package/build/store/private-actions.cjs +21 -2
  57. package/build/store/private-actions.cjs.map +2 -2
  58. package/build/store/private-selectors.cjs +40 -15
  59. package/build/store/private-selectors.cjs.map +2 -2
  60. package/build-module/components/collaborators-overlay/cursor-registry.mjs +61 -0
  61. package/build-module/components/collaborators-overlay/cursor-registry.mjs.map +7 -0
  62. package/build-module/components/collaborators-overlay/index.mjs +7 -2
  63. package/build-module/components/collaborators-overlay/index.mjs.map +2 -2
  64. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +1 -1
  65. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +2 -2
  66. package/build-module/components/collaborators-overlay/overlay.mjs +32 -2
  67. package/build-module/components/collaborators-overlay/overlay.mjs.map +2 -2
  68. package/build-module/components/collaborators-presence/index.mjs +14 -4
  69. package/build-module/components/collaborators-presence/index.mjs.map +2 -2
  70. package/build-module/components/collaborators-presence/list.mjs +20 -4
  71. package/build-module/components/collaborators-presence/list.mjs.map +2 -2
  72. package/build-module/components/post-card-panel/index.mjs +6 -17
  73. package/build-module/components/post-card-panel/index.mjs.map +2 -2
  74. package/build-module/components/post-content-information/index.mjs +6 -13
  75. package/build-module/components/post-content-information/index.mjs.map +2 -2
  76. package/build-module/components/post-revisions-panel/index.mjs +139 -0
  77. package/build-module/components/post-revisions-panel/index.mjs.map +7 -0
  78. package/build-module/components/post-revisions-preview/revisions-slider.mjs +24 -5
  79. package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
  80. package/build-module/components/post-template/create-new-template-modal.mjs +39 -46
  81. package/build-module/components/post-template/create-new-template-modal.mjs.map +2 -2
  82. package/build-module/components/post-template/hooks.mjs +53 -7
  83. package/build-module/components/post-template/hooks.mjs.map +2 -2
  84. package/build-module/components/post-template/swap-template-button.mjs +27 -20
  85. package/build-module/components/post-template/swap-template-button.mjs.map +2 -2
  86. package/build-module/components/preferences-modal/index.mjs +35 -27
  87. package/build-module/components/preferences-modal/index.mjs.map +2 -2
  88. package/build-module/components/revision-block-diff/index.mjs +9 -32
  89. package/build-module/components/revision-block-diff/index.mjs.map +2 -2
  90. package/build-module/components/revision-diff-panel/index.mjs +37 -0
  91. package/build-module/components/revision-diff-panel/index.mjs.map +7 -0
  92. package/build-module/components/revision-fields-diff/index.mjs +65 -0
  93. package/build-module/components/revision-fields-diff/index.mjs.map +7 -0
  94. package/build-module/components/sidebar/dataform-post-summary.mjs +8 -53
  95. package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
  96. package/build-module/components/sidebar/index.mjs +25 -22
  97. package/build-module/components/sidebar/index.mjs.map +2 -2
  98. package/build-module/components/sidebar/post-revision-summary.mjs +43 -0
  99. package/build-module/components/sidebar/post-revision-summary.mjs.map +7 -0
  100. package/build-module/components/sidebar/post-summary.mjs +31 -42
  101. package/build-module/components/sidebar/post-summary.mjs.map +2 -2
  102. package/build-module/components/style-book/index.mjs +4 -3
  103. package/build-module/components/style-book/index.mjs.map +2 -2
  104. package/build-module/components/sync-connection-error-modal/index.mjs +2 -2
  105. package/build-module/components/sync-connection-error-modal/index.mjs.map +1 -1
  106. package/build-module/components/template-actions-panel/block-theme-content.mjs +167 -0
  107. package/build-module/components/template-actions-panel/block-theme-content.mjs.map +7 -0
  108. package/build-module/components/template-actions-panel/classic-theme-content.mjs +138 -0
  109. package/build-module/components/template-actions-panel/classic-theme-content.mjs.map +7 -0
  110. package/build-module/components/template-actions-panel/index.mjs +28 -0
  111. package/build-module/components/template-actions-panel/index.mjs.map +7 -0
  112. package/build-module/dataviews/store/private-actions.mjs +5 -1
  113. package/build-module/dataviews/store/private-actions.mjs.map +2 -2
  114. package/build-module/store/private-actions.mjs +21 -2
  115. package/build-module/store/private-actions.mjs.map +2 -2
  116. package/build-module/store/private-selectors.mjs +40 -15
  117. package/build-module/store/private-selectors.mjs.map +2 -2
  118. package/build-style/style-rtl.css +111 -42
  119. package/build-style/style.css +111 -42
  120. package/build-types/components/collaborators-overlay/cursor-registry.d.ts +36 -0
  121. package/build-types/components/collaborators-overlay/cursor-registry.d.ts.map +1 -0
  122. package/build-types/components/collaborators-overlay/index.d.ts +7 -4
  123. package/build-types/components/collaborators-overlay/index.d.ts.map +1 -1
  124. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts +1 -1
  125. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts.map +1 -1
  126. package/build-types/components/collaborators-overlay/overlay.d.ts +4 -1
  127. package/build-types/components/collaborators-overlay/overlay.d.ts.map +1 -1
  128. package/build-types/components/collaborators-presence/index.d.ts.map +1 -1
  129. package/build-types/components/collaborators-presence/list.d.ts +4 -1
  130. package/build-types/components/collaborators-presence/list.d.ts.map +1 -1
  131. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  132. package/build-types/components/post-content-information/index.d.ts +4 -1
  133. package/build-types/components/post-content-information/index.d.ts.map +1 -1
  134. package/build-types/components/post-revisions-panel/index.d.ts +2 -0
  135. package/build-types/components/post-revisions-panel/index.d.ts.map +1 -0
  136. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  137. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  138. package/build-types/components/post-template/hooks.d.ts +1 -1
  139. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  140. package/build-types/components/post-template/swap-template-button.d.ts +4 -0
  141. package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
  142. package/build-types/components/revision-block-diff/index.d.ts.map +1 -1
  143. package/build-types/components/revision-diff-panel/index.d.ts +14 -0
  144. package/build-types/components/revision-diff-panel/index.d.ts.map +1 -0
  145. package/build-types/components/revision-fields-diff/index.d.ts +6 -0
  146. package/build-types/components/revision-fields-diff/index.d.ts.map +1 -0
  147. package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
  148. package/build-types/components/sidebar/index.d.ts.map +1 -1
  149. package/build-types/components/sidebar/post-revision-summary.d.ts +2 -0
  150. package/build-types/components/sidebar/post-revision-summary.d.ts.map +1 -0
  151. package/build-types/components/sidebar/post-summary.d.ts +3 -0
  152. package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
  153. package/build-types/components/style-book/index.d.ts +2 -1
  154. package/build-types/components/style-book/index.d.ts.map +1 -1
  155. package/build-types/components/template-actions-panel/block-theme-content.d.ts +2 -0
  156. package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -0
  157. package/build-types/components/template-actions-panel/classic-theme-content.d.ts +2 -0
  158. package/build-types/components/template-actions-panel/classic-theme-content.d.ts.map +1 -0
  159. package/build-types/components/template-actions-panel/index.d.ts +2 -0
  160. package/build-types/components/template-actions-panel/index.d.ts.map +1 -0
  161. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  162. package/build-types/store/private-actions.d.ts.map +1 -1
  163. package/build-types/store/private-selectors.d.ts.map +1 -1
  164. package/package.json +45 -44
  165. package/src/components/collaborators-overlay/cursor-registry.ts +96 -0
  166. package/src/components/collaborators-overlay/index.tsx +12 -4
  167. package/src/components/collaborators-overlay/overlay-iframe-styles.ts +1 -1
  168. package/src/components/collaborators-overlay/overlay.tsx +45 -1
  169. package/src/components/collaborators-presence/index.tsx +9 -1
  170. package/src/components/collaborators-presence/list.tsx +25 -1
  171. package/src/components/post-card-panel/index.js +7 -21
  172. package/src/components/post-content-information/index.js +5 -16
  173. package/src/components/post-revisions-panel/index.js +151 -0
  174. package/src/components/post-revisions-panel/style.scss +16 -0
  175. package/src/components/post-revisions-preview/revisions-slider.js +29 -7
  176. package/src/components/post-template/create-new-template-modal.js +1 -4
  177. package/src/components/post-template/hooks.js +65 -9
  178. package/src/components/post-template/style.scss +0 -6
  179. package/src/components/post-template/swap-template-button.js +30 -21
  180. package/src/components/preferences-modal/index.js +37 -25
  181. package/src/components/revision-block-diff/index.js +8 -43
  182. package/src/components/revision-diff-panel/index.js +59 -0
  183. package/src/components/revision-fields-diff/index.js +91 -0
  184. package/src/components/sidebar/dataform-post-summary.js +8 -55
  185. package/src/components/sidebar/index.js +33 -22
  186. package/src/components/sidebar/post-revision-summary.js +50 -0
  187. package/src/components/sidebar/post-summary.js +22 -40
  188. package/src/components/sidebar/style.scss +7 -0
  189. package/src/components/style-book/index.js +4 -2
  190. package/src/components/sync-connection-error-modal/index.tsx +2 -2
  191. package/src/components/template-actions-panel/block-theme-content.js +196 -0
  192. package/src/components/template-actions-panel/classic-theme-content.js +170 -0
  193. package/src/components/template-actions-panel/index.js +32 -0
  194. package/src/components/template-actions-panel/style.scss +39 -0
  195. package/src/dataviews/store/private-actions.ts +6 -0
  196. package/src/store/private-actions.js +24 -3
  197. package/src/store/private-selectors.js +46 -16
  198. package/src/style.scss +3 -1
  199. /package/src/components/{revision-block-diff → revision-diff-panel}/style.scss +0 -0
@@ -23,8 +23,8 @@ import { useRetryCountdown } from "./use-retry-countdown.mjs";
23
23
  import { jsx, jsxs } from "react/jsx-runtime";
24
24
  var { BlockCanvasCover } = unlock(privateApis);
25
25
  var { retrySyncConnection } = unlock(coreDataPrivateApis);
26
- var INITIAL_DISCONNECTED_DEBOUNCE_MS = 5e3;
27
- var DISCONNECTED_DEBOUNCE_MS = 2e3;
26
+ var INITIAL_DISCONNECTED_DEBOUNCE_MS = 2e4;
27
+ var DISCONNECTED_DEBOUNCE_MS = 8e3;
28
28
  function DefaultSyncConnectionErrorModal(props) {
29
29
  const {
30
30
  description,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/sync-connection-error-modal/index.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, select } from '@wordpress/data';\nimport { useCopyToClipboard } from '@wordpress/compose';\n// @ts-ignore No exported types.\nimport { serialize } from '@wordpress/blocks';\nimport {\n\tstore as coreDataStore,\n\tprivateApis as coreDataPrivateApis,\n\ttype ConnectionError,\n} from '@wordpress/core-data';\n// @ts-expect-error - No type declarations available for @wordpress/block-editor\n// prettier-ignore\nimport { privateApis, store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tModal,\n\twithFilters,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport { __, sprintf, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getSyncErrorMessages } from '../../utils/sync-error-messages';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useRetryCountdown } from './use-retry-countdown';\n\nconst { BlockCanvasCover } = unlock( privateApis );\nconst { retrySyncConnection } = unlock( coreDataPrivateApis );\n\n// Debounce time for initial disconnected status to allow connection to establish.\nconst INITIAL_DISCONNECTED_DEBOUNCE_MS = 5000;\n\n// Debounce time for showing the disconnect dialog after the intial connection,\n// allowing brief network interruptions to resolve.\nconst DISCONNECTED_DEBOUNCE_MS = 2000;\n\nexport interface SyncConnectionErrorModalProps {\n\tdescription: string; // Modal description.\n\terror?: ConnectionError; // Error object with a `code` property.\n\tmanualRetry?: () => void; // Callback for when the retry button is clicked.\n\tpostType?: { slug?: string; labels?: { name?: string } } | null; // Current post type object.\n\tsecondsRemainingUntilAutoRetry?: number; // Seconds remaining until the next automatic retry attempt, if applicable.\n\ttitle: string; // Modal title.\n}\n\n/**\n * Default sync connection modal component.\n *\n * Can be replaced or wrapped via the `editor.SyncConnectionErrorModal` filter.\n *\n * @param props - SyncConnectionErrorModalProps.\n */\nfunction DefaultSyncConnectionErrorModal(\n\tprops: SyncConnectionErrorModalProps\n) {\n\tconst {\n\t\tdescription,\n\t\tmanualRetry,\n\t\tpostType,\n\t\tsecondsRemainingUntilAutoRetry,\n\t\ttitle,\n\t} = props;\n\tconst copyButtonRef = useCopyToClipboard( () => {\n\t\tconst blocks = select( blockEditorStore ).getBlocks();\n\t\treturn serialize( blocks );\n\t} );\n\n\tlet retryCountdownText: string = '';\n\tlet isRetrying = false;\n\tif (\n\t\tsecondsRemainingUntilAutoRetry &&\n\t\tsecondsRemainingUntilAutoRetry > 0\n\t) {\n\t\tretryCountdownText = sprintf(\n\t\t\t/* translators: %d: number of seconds until retry */\n\t\t\t_n(\n\t\t\t\t'Retrying connection in %d second\\u2026',\n\t\t\t\t'Retrying connection in %d seconds\\u2026',\n\t\t\t\tsecondsRemainingUntilAutoRetry\n\t\t\t),\n\t\t\tsecondsRemainingUntilAutoRetry\n\t\t);\n\t} else if ( 0 === secondsRemainingUntilAutoRetry ) {\n\t\tisRetrying = true;\n\t\tretryCountdownText = __( 'Retrying\\u2026' );\n\t}\n\n\tlet editPostHref = 'edit.php';\n\tif ( postType?.slug ) {\n\t\teditPostHref = `edit.php?post_type=${ postType.slug }`;\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\toverlayClassName=\"editor-sync-connection-error-modal\"\n\t\t\tisDismissible={ false }\n\t\t\tonRequestClose={ () => {} }\n\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\tshouldCloseOnEsc={ false }\n\t\t\tsize=\"medium\"\n\t\t\ttitle={ title }\n\t\t>\n\t\t\t<VStack spacing={ 6 }>\n\t\t\t\t<p>{ description }</p>\n\t\t\t\t{ retryCountdownText && (\n\t\t\t\t\t<p className=\"editor-sync-connection-error-modal__retry-countdown\">\n\t\t\t\t\t\t{ retryCountdownText }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\thref={ editPostHref }\n\t\t\t\t\t\tisDestructive\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Post type name (e.g., \"Posts\", \"Pages\"). */\n\t\t\t\t\t\t\t__( 'Back to %s' ),\n\t\t\t\t\t\t\tpostType?.labels?.name ?? __( 'Posts' )\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tref={ copyButtonRef }\n\t\t\t\t\t\tvariant={ manualRetry ? 'secondary' : 'primary' }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Copy Post Content' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t{ manualRetry && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\taria-disabled={ isRetrying }\n\t\t\t\t\t\t\tdisabled={ isRetrying }\n\t\t\t\t\t\t\tisBusy={ isRetrying }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tonClick={ manualRetry }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Retry' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</Modal>\n\t);\n}\n\n/**\n * Filtered version of the sync connection modal, allowing third-party\n * plugins to replace the default modal via:\n *\n * ```js\n * wp.hooks.addFilter(\n * 'editor.SyncConnectionErrorModal',\n * 'my-plugin/custom-sync-connection-error-modal',\n * ( OriginalComponent ) => ( props ) => {\n * // Return a custom component or wrap the original.\n * return <OriginalComponent { ...props } />;\n * }\n * );\n * ```\n */\n// @ts-ignore\nconst FilteredSyncConnectionErrorModal = globalThis.IS_GUTENBERG_PLUGIN\n\t? withFilters( 'editor.SyncConnectionErrorModal' )(\n\t\t\tDefaultSyncConnectionErrorModal\n\t )\n\t: DefaultSyncConnectionErrorModal;\n\n/**\n * Sync connection modal that displays when any entity reports a disconnection.\n * Uses BlockCanvasCover.Fill to render in the block canvas.\n *\n * @return The modal component or null if not disconnected.\n */\nexport function SyncConnectionErrorModal() {\n\tconst [ hasInitialized, setHasInitialized ] = useState( false );\n\tconst [ showModal, setShowModal ] = useState( false );\n\n\tconst { connectionStatus, isCollaborationEnabled, postType } = useSelect(\n\t\t( selectFn ) => {\n\t\t\tconst currentPostType =\n\t\t\t\tselectFn( editorStore ).getCurrentPostType();\n\t\t\treturn {\n\t\t\t\tconnectionStatus:\n\t\t\t\t\tselectFn( coreDataStore ).getSyncConnectionStatus() || null,\n\t\t\t\tisCollaborationEnabled:\n\t\t\t\t\tselectFn(\n\t\t\t\t\t\teditorStore\n\t\t\t\t\t).isCollaborationEnabledForCurrentPost(),\n\t\t\t\tpostType: currentPostType\n\t\t\t\t\t? selectFn( coreDataStore ).getPostType( currentPostType )\n\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { onManualRetry, secondsRemaining } =\n\t\tuseRetryCountdown( connectionStatus );\n\n\tconst isConnected = 'connected' === connectionStatus?.status;\n\n\t// Set hasInitialized after a debounce to give extra time on initial load.\n\tuseEffect( () => {\n\t\tconst timeout = setTimeout( () => {\n\t\t\tsetHasInitialized( true );\n\t\t}, INITIAL_DISCONNECTED_DEBOUNCE_MS );\n\n\t\treturn () => clearTimeout( timeout );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( isConnected ) {\n\t\t\tsetShowModal( false );\n\t\t\treturn;\n\t\t}\n\n\t\tconst timeout = setTimeout( () => {\n\t\t\tsetShowModal( true );\n\t\t}, DISCONNECTED_DEBOUNCE_MS );\n\n\t\treturn () => clearTimeout( timeout );\n\t}, [ isConnected ] );\n\n\tif ( ! isCollaborationEnabled || ! hasInitialized || ! showModal ) {\n\t\treturn null;\n\t}\n\n\tconst error =\n\t\tconnectionStatus && 'error' in connectionStatus\n\t\t\t? connectionStatus?.error\n\t\t\t: undefined;\n\tconst manualRetry =\n\t\tconnectionStatus &&\n\t\t'canManuallyRetry' in connectionStatus &&\n\t\tconnectionStatus.canManuallyRetry\n\t\t\t? () => {\n\t\t\t\t\tonManualRetry();\n\t\t\t\t\tretrySyncConnection();\n\t\t\t }\n\t\t\t: undefined;\n\tconst messages = getSyncErrorMessages( error );\n\n\treturn (\n\t\t<BlockCanvasCover.Fill>\n\t\t\t<FilteredSyncConnectionErrorModal\n\t\t\t\tdescription={ messages.description }\n\t\t\t\terror={ error }\n\t\t\t\tmanualRetry={ manualRetry }\n\t\t\t\tpostType={ postType }\n\t\t\t\tsecondsRemainingUntilAutoRetry={ secondsRemaining }\n\t\t\t\ttitle={ messages.title }\n\t\t\t/>\n\t\t</BlockCanvasCover.Fill>\n\t);\n}\n"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, select } from '@wordpress/data';\nimport { useCopyToClipboard } from '@wordpress/compose';\n// @ts-ignore No exported types.\nimport { serialize } from '@wordpress/blocks';\nimport {\n\tstore as coreDataStore,\n\tprivateApis as coreDataPrivateApis,\n\ttype ConnectionError,\n} from '@wordpress/core-data';\n// @ts-expect-error - No type declarations available for @wordpress/block-editor\n// prettier-ignore\nimport { privateApis, store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tModal,\n\twithFilters,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport { __, sprintf, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getSyncErrorMessages } from '../../utils/sync-error-messages';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useRetryCountdown } from './use-retry-countdown';\n\nconst { BlockCanvasCover } = unlock( privateApis );\nconst { retrySyncConnection } = unlock( coreDataPrivateApis );\n\n// Debounce time for initial disconnected status to allow connection to establish.\nconst INITIAL_DISCONNECTED_DEBOUNCE_MS = 20000;\n\n// Debounce time for showing the disconnect dialog after the intial connection,\n// allowing brief network interruptions to resolve.\nconst DISCONNECTED_DEBOUNCE_MS = 8000;\n\nexport interface SyncConnectionErrorModalProps {\n\tdescription: string; // Modal description.\n\terror?: ConnectionError; // Error object with a `code` property.\n\tmanualRetry?: () => void; // Callback for when the retry button is clicked.\n\tpostType?: { slug?: string; labels?: { name?: string } } | null; // Current post type object.\n\tsecondsRemainingUntilAutoRetry?: number; // Seconds remaining until the next automatic retry attempt, if applicable.\n\ttitle: string; // Modal title.\n}\n\n/**\n * Default sync connection modal component.\n *\n * Can be replaced or wrapped via the `editor.SyncConnectionErrorModal` filter.\n *\n * @param props - SyncConnectionErrorModalProps.\n */\nfunction DefaultSyncConnectionErrorModal(\n\tprops: SyncConnectionErrorModalProps\n) {\n\tconst {\n\t\tdescription,\n\t\tmanualRetry,\n\t\tpostType,\n\t\tsecondsRemainingUntilAutoRetry,\n\t\ttitle,\n\t} = props;\n\tconst copyButtonRef = useCopyToClipboard( () => {\n\t\tconst blocks = select( blockEditorStore ).getBlocks();\n\t\treturn serialize( blocks );\n\t} );\n\n\tlet retryCountdownText: string = '';\n\tlet isRetrying = false;\n\tif (\n\t\tsecondsRemainingUntilAutoRetry &&\n\t\tsecondsRemainingUntilAutoRetry > 0\n\t) {\n\t\tretryCountdownText = sprintf(\n\t\t\t/* translators: %d: number of seconds until retry */\n\t\t\t_n(\n\t\t\t\t'Retrying connection in %d second\\u2026',\n\t\t\t\t'Retrying connection in %d seconds\\u2026',\n\t\t\t\tsecondsRemainingUntilAutoRetry\n\t\t\t),\n\t\t\tsecondsRemainingUntilAutoRetry\n\t\t);\n\t} else if ( 0 === secondsRemainingUntilAutoRetry ) {\n\t\tisRetrying = true;\n\t\tretryCountdownText = __( 'Retrying\\u2026' );\n\t}\n\n\tlet editPostHref = 'edit.php';\n\tif ( postType?.slug ) {\n\t\teditPostHref = `edit.php?post_type=${ postType.slug }`;\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\toverlayClassName=\"editor-sync-connection-error-modal\"\n\t\t\tisDismissible={ false }\n\t\t\tonRequestClose={ () => {} }\n\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\tshouldCloseOnEsc={ false }\n\t\t\tsize=\"medium\"\n\t\t\ttitle={ title }\n\t\t>\n\t\t\t<VStack spacing={ 6 }>\n\t\t\t\t<p>{ description }</p>\n\t\t\t\t{ retryCountdownText && (\n\t\t\t\t\t<p className=\"editor-sync-connection-error-modal__retry-countdown\">\n\t\t\t\t\t\t{ retryCountdownText }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\thref={ editPostHref }\n\t\t\t\t\t\tisDestructive\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Post type name (e.g., \"Posts\", \"Pages\"). */\n\t\t\t\t\t\t\t__( 'Back to %s' ),\n\t\t\t\t\t\t\tpostType?.labels?.name ?? __( 'Posts' )\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tref={ copyButtonRef }\n\t\t\t\t\t\tvariant={ manualRetry ? 'secondary' : 'primary' }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Copy Post Content' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t{ manualRetry && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\taria-disabled={ isRetrying }\n\t\t\t\t\t\t\tdisabled={ isRetrying }\n\t\t\t\t\t\t\tisBusy={ isRetrying }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tonClick={ manualRetry }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Retry' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</Modal>\n\t);\n}\n\n/**\n * Filtered version of the sync connection modal, allowing third-party\n * plugins to replace the default modal via:\n *\n * ```js\n * wp.hooks.addFilter(\n * 'editor.SyncConnectionErrorModal',\n * 'my-plugin/custom-sync-connection-error-modal',\n * ( OriginalComponent ) => ( props ) => {\n * // Return a custom component or wrap the original.\n * return <OriginalComponent { ...props } />;\n * }\n * );\n * ```\n */\n// @ts-ignore\nconst FilteredSyncConnectionErrorModal = globalThis.IS_GUTENBERG_PLUGIN\n\t? withFilters( 'editor.SyncConnectionErrorModal' )(\n\t\t\tDefaultSyncConnectionErrorModal\n\t )\n\t: DefaultSyncConnectionErrorModal;\n\n/**\n * Sync connection modal that displays when any entity reports a disconnection.\n * Uses BlockCanvasCover.Fill to render in the block canvas.\n *\n * @return The modal component or null if not disconnected.\n */\nexport function SyncConnectionErrorModal() {\n\tconst [ hasInitialized, setHasInitialized ] = useState( false );\n\tconst [ showModal, setShowModal ] = useState( false );\n\n\tconst { connectionStatus, isCollaborationEnabled, postType } = useSelect(\n\t\t( selectFn ) => {\n\t\t\tconst currentPostType =\n\t\t\t\tselectFn( editorStore ).getCurrentPostType();\n\t\t\treturn {\n\t\t\t\tconnectionStatus:\n\t\t\t\t\tselectFn( coreDataStore ).getSyncConnectionStatus() || null,\n\t\t\t\tisCollaborationEnabled:\n\t\t\t\t\tselectFn(\n\t\t\t\t\t\teditorStore\n\t\t\t\t\t).isCollaborationEnabledForCurrentPost(),\n\t\t\t\tpostType: currentPostType\n\t\t\t\t\t? selectFn( coreDataStore ).getPostType( currentPostType )\n\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { onManualRetry, secondsRemaining } =\n\t\tuseRetryCountdown( connectionStatus );\n\n\tconst isConnected = 'connected' === connectionStatus?.status;\n\n\t// Set hasInitialized after a debounce to give extra time on initial load.\n\tuseEffect( () => {\n\t\tconst timeout = setTimeout( () => {\n\t\t\tsetHasInitialized( true );\n\t\t}, INITIAL_DISCONNECTED_DEBOUNCE_MS );\n\n\t\treturn () => clearTimeout( timeout );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( isConnected ) {\n\t\t\tsetShowModal( false );\n\t\t\treturn;\n\t\t}\n\n\t\tconst timeout = setTimeout( () => {\n\t\t\tsetShowModal( true );\n\t\t}, DISCONNECTED_DEBOUNCE_MS );\n\n\t\treturn () => clearTimeout( timeout );\n\t}, [ isConnected ] );\n\n\tif ( ! isCollaborationEnabled || ! hasInitialized || ! showModal ) {\n\t\treturn null;\n\t}\n\n\tconst error =\n\t\tconnectionStatus && 'error' in connectionStatus\n\t\t\t? connectionStatus?.error\n\t\t\t: undefined;\n\tconst manualRetry =\n\t\tconnectionStatus &&\n\t\t'canManuallyRetry' in connectionStatus &&\n\t\tconnectionStatus.canManuallyRetry\n\t\t\t? () => {\n\t\t\t\t\tonManualRetry();\n\t\t\t\t\tretrySyncConnection();\n\t\t\t }\n\t\t\t: undefined;\n\tconst messages = getSyncErrorMessages( error );\n\n\treturn (\n\t\t<BlockCanvasCover.Fill>\n\t\t\t<FilteredSyncConnectionErrorModal\n\t\t\t\tdescription={ messages.description }\n\t\t\t\terror={ error }\n\t\t\t\tmanualRetry={ manualRetry }\n\t\t\t\tpostType={ postType }\n\t\t\t\tsecondsRemainingUntilAutoRetry={ secondsRemaining }\n\t\t\t\ttitle={ messages.title }\n\t\t\t/>\n\t\t</BlockCanvasCover.Fill>\n\t);\n}\n"],
5
5
  "mappings": ";AAGA,SAAS,WAAW,cAAc;AAClC,SAAS,0BAA0B;AAEnC,SAAS,iBAAiB;AAC1B;AAAA,EACC,SAAS;AAAA,EACT,eAAe;AAAA,OAET;AAGP,SAAS,aAAa,SAAS,wBAAwB;AACvD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP,SAAS,UAAU,iBAAiB;AACpC,SAAS,IAAI,SAAS,UAAU;AAKhC,SAAS,4BAA4B;AACrC,SAAS,SAAS,mBAAmB;AACrC,SAAS,cAAc;AACvB,SAAS,yBAAyB;AA+E9B,cAMA,YANA;AA7EJ,IAAM,EAAE,iBAAiB,IAAI,OAAQ,WAAY;AACjD,IAAM,EAAE,oBAAoB,IAAI,OAAQ,mBAAoB;AAG5D,IAAM,mCAAmC;AAIzC,IAAM,2BAA2B;AAkBjC,SAAS,gCACR,OACC;AACD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AACJ,QAAM,gBAAgB,mBAAoB,MAAM;AAC/C,UAAM,SAAS,OAAQ,gBAAiB,EAAE,UAAU;AACpD,WAAO,UAAW,MAAO;AAAA,EAC1B,CAAE;AAEF,MAAI,qBAA6B;AACjC,MAAI,aAAa;AACjB,MACC,kCACA,iCAAiC,GAChC;AACD,yBAAqB;AAAA;A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C,oBAAC,iBAAiB,MAAjB,EACA;AAAA,IAAC;AAAA;AAAA,MACA,aAAc,SAAS;AAAA,MACvB;AAAA,MACA;AAAA,MACA;AAAA,MACA,gCAAiC;AAAA,MACjC,OAAQ,SAAS;AAAA;AAAA,EAClB,GACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,167 @@
1
+ // packages/editor/src/components/template-actions-panel/block-theme-content.js
2
+ import { useSelect, useDispatch } from "@wordpress/data";
3
+ import {
4
+ useEntityRecord,
5
+ useEntityBlockEditor,
6
+ store as coreStore
7
+ } from "@wordpress/core-data";
8
+ import { BlockPreview } from "@wordpress/block-editor";
9
+ import {
10
+ PanelBody,
11
+ Button,
12
+ Tooltip,
13
+ __experimentalHStack as HStack,
14
+ __experimentalVStack as VStack
15
+ } from "@wordpress/components";
16
+ import { useState } from "@wordpress/element";
17
+ import { __, sprintf } from "@wordpress/i18n";
18
+ import { decodeEntities } from "@wordpress/html-entities";
19
+ import { store as noticesStore } from "@wordpress/notices";
20
+ import { store as preferencesStore } from "@wordpress/preferences";
21
+ import { store as editorStore } from "../../store/index.mjs";
22
+ import CreateNewTemplateModal from "../post-template/create-new-template-modal.mjs";
23
+ import { SwapTemplateModal } from "../post-template/swap-template-button.mjs";
24
+ import { useAvailableTemplates } from "../post-template/hooks.mjs";
25
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
26
+ function TemplateActionsPanelContent() {
27
+ const templateId = useSelect(
28
+ (select) => select(editorStore).getCurrentTemplateId(),
29
+ []
30
+ );
31
+ const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
32
+ const [isSwapModalOpen, setIsSwapModalOpen] = useState(false);
33
+ const availableTemplates = useAvailableTemplates();
34
+ const hasSwapTargets = !!availableTemplates?.length;
35
+ const {
36
+ onNavigateToEntityRecord,
37
+ canCreateTemplate,
38
+ hasGoBack,
39
+ getEditorSettings
40
+ } = useSelect((select) => {
41
+ const { getEditorSettings: _getEditorSettings } = select(editorStore);
42
+ const editorSettings = _getEditorSettings();
43
+ return {
44
+ onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
45
+ canCreateTemplate: !!select(coreStore).canUser("create", {
46
+ kind: "postType",
47
+ name: "wp_template"
48
+ }),
49
+ hasGoBack: editorSettings.hasOwnProperty(
50
+ "onNavigateToPreviousEntityRecord"
51
+ ),
52
+ getEditorSettings: _getEditorSettings
53
+ };
54
+ }, []);
55
+ const { get: getPreference } = useSelect(preferencesStore);
56
+ const { createSuccessNotice } = useDispatch(noticesStore);
57
+ const { editedRecord: template, hasResolved } = useEntityRecord(
58
+ "postType",
59
+ "wp_template",
60
+ templateId
61
+ );
62
+ const [blocks] = useEntityBlockEditor("postType", "wp_template", {
63
+ id: templateId
64
+ });
65
+ if (!hasResolved) {
66
+ return null;
67
+ }
68
+ const notificationAction = hasGoBack ? [
69
+ {
70
+ label: __("Go back"),
71
+ onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord()
72
+ }
73
+ ] : void 0;
74
+ const mayShowTemplateEditNotice = () => {
75
+ if (!getPreference("core/edit-site", "welcomeGuideTemplate")) {
76
+ createSuccessNotice(
77
+ __(
78
+ "Editing template. Changes made here affect all posts and pages that use the template."
79
+ ),
80
+ { type: "snackbar", actions: notificationAction }
81
+ );
82
+ }
83
+ };
84
+ const templateName = decodeEntities(template.title);
85
+ const previewContent = !!blocks?.length && /* @__PURE__ */ jsx(BlockPreview.Async, { children: /* @__PURE__ */ jsx(BlockPreview, { blocks }) });
86
+ const renderPreview = () => {
87
+ if (!previewContent) {
88
+ return null;
89
+ }
90
+ if (hasSwapTargets) {
91
+ const tooltipText = __("Change template");
92
+ return /* @__PURE__ */ jsx(Tooltip, { text: tooltipText, children: /* @__PURE__ */ jsx(
93
+ "div",
94
+ {
95
+ className: "editor-template-actions-panel__preview",
96
+ role: "button",
97
+ tabIndex: 0,
98
+ "aria-label": tooltipText,
99
+ onClick: () => setIsSwapModalOpen(true),
100
+ onKeyPress: () => setIsSwapModalOpen(true),
101
+ children: previewContent
102
+ }
103
+ ) });
104
+ }
105
+ return /* @__PURE__ */ jsx("div", { className: "editor-template-actions-panel__preview", children: previewContent });
106
+ };
107
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
108
+ /* @__PURE__ */ jsx(
109
+ PanelBody,
110
+ {
111
+ title: sprintf(
112
+ /* translators: %s: template name */
113
+ __("Template: %s"),
114
+ templateName
115
+ ),
116
+ initialOpen: false,
117
+ children: /* @__PURE__ */ jsxs(VStack, { children: [
118
+ renderPreview(),
119
+ /* @__PURE__ */ jsxs(HStack, { children: [
120
+ onNavigateToEntityRecord && /* @__PURE__ */ jsx(
121
+ Button,
122
+ {
123
+ className: "editor-template-actions-panel__action",
124
+ __next40pxDefaultSize: true,
125
+ variant: "secondary",
126
+ onClick: () => {
127
+ onNavigateToEntityRecord({
128
+ postId: template.id,
129
+ postType: "wp_template"
130
+ });
131
+ mayShowTemplateEditNotice();
132
+ },
133
+ children: __("Edit")
134
+ }
135
+ ),
136
+ canCreateTemplate && /* @__PURE__ */ jsx(
137
+ Button,
138
+ {
139
+ className: "editor-template-actions-panel__action",
140
+ __next40pxDefaultSize: true,
141
+ variant: "secondary",
142
+ onClick: () => setIsCreateModalOpen(true),
143
+ children: __("Create new")
144
+ }
145
+ )
146
+ ] })
147
+ ] })
148
+ }
149
+ ),
150
+ isCreateModalOpen && /* @__PURE__ */ jsx(
151
+ CreateNewTemplateModal,
152
+ {
153
+ onClose: () => setIsCreateModalOpen(false)
154
+ }
155
+ ),
156
+ isSwapModalOpen && /* @__PURE__ */ jsx(
157
+ SwapTemplateModal,
158
+ {
159
+ onRequestClose: () => setIsSwapModalOpen(false)
160
+ }
161
+ )
162
+ ] });
163
+ }
164
+ export {
165
+ TemplateActionsPanelContent as default
166
+ };
167
+ //# sourceMappingURL=block-theme-content.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/template-actions-panel/block-theme-content.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseEntityRecord,\n\tuseEntityBlockEditor,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { BlockPreview } from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\tButton,\n\tTooltip,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport CreateNewTemplateModal from '../post-template/create-new-template-modal';\nimport { SwapTemplateModal } from '../post-template/swap-template-button';\nimport { useAvailableTemplates } from '../post-template/hooks';\n\nexport default function TemplateActionsPanelContent() {\n\tconst templateId = useSelect(\n\t\t( select ) => select( editorStore ).getCurrentTemplateId(),\n\t\t[]\n\t);\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\tconst [ isSwapModalOpen, setIsSwapModalOpen ] = useState( false );\n\n\tconst availableTemplates = useAvailableTemplates();\n\tconst hasSwapTargets = !! availableTemplates?.length;\n\n\tconst {\n\t\tonNavigateToEntityRecord,\n\t\tcanCreateTemplate,\n\t\thasGoBack,\n\t\tgetEditorSettings,\n\t} = useSelect( ( select ) => {\n\t\tconst { getEditorSettings: _getEditorSettings } = select( editorStore );\n\t\tconst editorSettings = _getEditorSettings();\n\t\treturn {\n\t\t\tonNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,\n\t\t\tcanCreateTemplate: !! select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t\thasGoBack: editorSettings.hasOwnProperty(\n\t\t\t\t'onNavigateToPreviousEntityRecord'\n\t\t\t),\n\t\t\tgetEditorSettings: _getEditorSettings,\n\t\t};\n\t}, [] );\n\n\tconst { get: getPreference } = useSelect( preferencesStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst { editedRecord: template, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplateId\n\t);\n\n\tconst [ blocks ] = useEntityBlockEditor( 'postType', 'wp_template', {\n\t\tid: templateId,\n\t} );\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\n\t// The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing\n\t// and assigns its own backlink to focusMode pages.\n\tconst notificationAction = hasGoBack\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t},\n\t\t ]\n\t\t: undefined;\n\n\tconst mayShowTemplateEditNotice = () => {\n\t\tif ( ! getPreference( 'core/edit-site', 'welcomeGuideTemplate' ) ) {\n\t\t\tcreateSuccessNotice(\n\t\t\t\t__(\n\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar', actions: notificationAction }\n\t\t\t);\n\t\t}\n\t};\n\n\tconst templateName = decodeEntities( template.title );\n\n\tconst previewContent = !! blocks?.length && (\n\t\t<BlockPreview.Async>\n\t\t\t<BlockPreview blocks={ blocks } />\n\t\t</BlockPreview.Async>\n\t);\n\n\tconst renderPreview = () => {\n\t\tif ( ! previewContent ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( hasSwapTargets ) {\n\t\t\tconst tooltipText = __( 'Change template' );\n\t\t\treturn (\n\t\t\t\t<Tooltip text={ tooltipText }>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"editor-template-actions-panel__preview\"\n\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\ttabIndex={ 0 }\n\t\t\t\t\t\taria-label={ tooltipText }\n\t\t\t\t\t\tonClick={ () => setIsSwapModalOpen( true ) }\n\t\t\t\t\t\tonKeyPress={ () => setIsSwapModalOpen( true ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ previewContent }\n\t\t\t\t\t</div>\n\t\t\t\t</Tooltip>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<div className=\"editor-template-actions-panel__preview\">\n\t\t\t\t{ previewContent }\n\t\t\t</div>\n\t\t);\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<PanelBody\n\t\t\t\ttitle={ sprintf(\n\t\t\t\t\t/* translators: %s: template name */\n\t\t\t\t\t__( 'Template: %s' ),\n\t\t\t\t\ttemplateName\n\t\t\t\t) }\n\t\t\t\tinitialOpen={ false }\n\t\t\t>\n\t\t\t\t<VStack>\n\t\t\t\t\t{ renderPreview() }\n\t\t\t\t\t<HStack>\n\t\t\t\t\t\t{ onNavigateToEntityRecord && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tclassName=\"editor-template-actions-panel__action\"\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\tmayShowTemplateEditNotice();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tclassName=\"editor-template-actions-panel__action\"\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\tonClick={ () => setIsCreateModalOpen( true ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Create new' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</PanelBody>\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\t{ isSwapModalOpen && (\n\t\t\t\t<SwapTemplateModal\n\t\t\t\t\tonRequestClose={ () => setIsSwapModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP,SAAS,gBAAgB;AACzB,SAAS,IAAI,eAAe;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,SAAS,oBAAoB;AACtC,SAAS,SAAS,wBAAwB;AAK1C,SAAS,SAAS,mBAAmB;AACrC,OAAO,4BAA4B;AACnC,SAAS,yBAAyB;AAClC,SAAS,6BAA6B;AA8EnC,SAmCD,UAnCC,KA8CE,YA9CF;AA5EY,SAAR,8BAA+C;AACrD,QAAM,aAAa;AAAA,IAClB,CAAE,WAAY,OAAQ,WAAY,EAAE,qBAAqB;AAAA,IACzD,CAAC;AAAA,EACF;AACA,QAAM,CAAE,mBAAmB,oBAAqB,IAAI,SAAU,KAAM;AACpE,QAAM,CAAE,iBAAiB,kBAAmB,IAAI,SAAU,KAAM;AAEhE,QAAM,qBAAqB,sBAAsB;AACjD,QAAM,iBAAiB,CAAC,CAAE,oBAAoB;AAE9C,QAAM;AAAA,IACL;A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;AAAA,IAClD;AAAA,KAEF;AAEF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,138 @@
1
+ // packages/editor/src/components/template-actions-panel/classic-theme-content.js
2
+ import { useSelect, useDispatch } from "@wordpress/data";
3
+ import {
4
+ useEntityRecord,
5
+ useEntityBlockEditor,
6
+ store as coreStore
7
+ } from "@wordpress/core-data";
8
+ import { BlockPreview } from "@wordpress/block-editor";
9
+ import {
10
+ PanelBody,
11
+ Button,
12
+ __experimentalText as Text,
13
+ __experimentalHStack as HStack,
14
+ __experimentalVStack as VStack
15
+ } from "@wordpress/components";
16
+ import { useState } from "@wordpress/element";
17
+ import { __, sprintf } from "@wordpress/i18n";
18
+ import { decodeEntities } from "@wordpress/html-entities";
19
+ import { store as noticesStore } from "@wordpress/notices";
20
+ import { store as preferencesStore } from "@wordpress/preferences";
21
+ import { store as editorStore } from "../../store/index.mjs";
22
+ import CreateNewTemplateModal from "../post-template/create-new-template-modal.mjs";
23
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
24
+ function ClassicThemeContent() {
25
+ const templateId = useSelect(
26
+ (select) => select(editorStore).getCurrentTemplateId(),
27
+ []
28
+ );
29
+ const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
30
+ const {
31
+ onNavigateToEntityRecord,
32
+ canCreateTemplate,
33
+ hasGoBack,
34
+ getEditorSettings
35
+ } = useSelect((select) => {
36
+ const { getEditorSettings: _getEditorSettings } = select(editorStore);
37
+ const editorSettings = _getEditorSettings();
38
+ return {
39
+ onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
40
+ canCreateTemplate: !!select(coreStore).canUser("create", {
41
+ kind: "postType",
42
+ name: "wp_template"
43
+ }) && editorSettings.supportsTemplateMode,
44
+ hasGoBack: editorSettings.hasOwnProperty(
45
+ "onNavigateToPreviousEntityRecord"
46
+ ),
47
+ getEditorSettings: _getEditorSettings
48
+ };
49
+ }, []);
50
+ const { get: getPreference } = useSelect(preferencesStore);
51
+ const { createSuccessNotice } = useDispatch(noticesStore);
52
+ const { editedRecord: template } = useEntityRecord(
53
+ "postType",
54
+ "wp_template",
55
+ templateId
56
+ );
57
+ const [blocks] = useEntityBlockEditor("postType", "wp_template", {
58
+ id: templateId
59
+ });
60
+ if (!templateId && !canCreateTemplate) {
61
+ return null;
62
+ }
63
+ const notificationAction = hasGoBack ? [
64
+ {
65
+ label: __("Go back"),
66
+ onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord()
67
+ }
68
+ ] : void 0;
69
+ const mayShowTemplateEditNotice = () => {
70
+ if (!getPreference("core/edit-site", "welcomeGuideTemplate")) {
71
+ createSuccessNotice(
72
+ __(
73
+ "Editing template. Changes made here affect all posts and pages that use the template."
74
+ ),
75
+ { type: "snackbar", actions: notificationAction }
76
+ );
77
+ }
78
+ };
79
+ const templateName = template ? decodeEntities(template.title) : void 0;
80
+ const previewContent = !!blocks?.length && /* @__PURE__ */ jsx(BlockPreview.Async, { children: /* @__PURE__ */ jsx(BlockPreview, { blocks }) });
81
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
82
+ /* @__PURE__ */ jsx(
83
+ PanelBody,
84
+ {
85
+ title: template ? sprintf(
86
+ /* translators: %s: template name */
87
+ __("Template: %s"),
88
+ templateName
89
+ ) : __("Template"),
90
+ initialOpen: false,
91
+ children: /* @__PURE__ */ jsxs(VStack, { children: [
92
+ !templateId && /* @__PURE__ */ jsx(Text, { children: __(
93
+ "This page uses a classic template. To edit this template with blocks, create a block template."
94
+ ) }),
95
+ template && previewContent && /* @__PURE__ */ jsx("div", { className: "editor-template-actions-panel__preview", children: previewContent }),
96
+ /* @__PURE__ */ jsxs(HStack, { children: [
97
+ template && onNavigateToEntityRecord && /* @__PURE__ */ jsx(
98
+ Button,
99
+ {
100
+ className: "editor-template-actions-panel__action",
101
+ __next40pxDefaultSize: true,
102
+ variant: "secondary",
103
+ onClick: () => {
104
+ onNavigateToEntityRecord({
105
+ postId: template.id,
106
+ postType: "wp_template"
107
+ });
108
+ mayShowTemplateEditNotice();
109
+ },
110
+ children: __("Edit")
111
+ }
112
+ ),
113
+ canCreateTemplate && /* @__PURE__ */ jsx(
114
+ Button,
115
+ {
116
+ className: "editor-template-actions-panel__action",
117
+ __next40pxDefaultSize: true,
118
+ variant: "secondary",
119
+ onClick: () => setIsCreateModalOpen(true),
120
+ children: !templateId ? __("Create block template") : __("Create new")
121
+ }
122
+ )
123
+ ] })
124
+ ] })
125
+ }
126
+ ),
127
+ isCreateModalOpen && /* @__PURE__ */ jsx(
128
+ CreateNewTemplateModal,
129
+ {
130
+ onClose: () => setIsCreateModalOpen(false)
131
+ }
132
+ )
133
+ ] });
134
+ }
135
+ export {
136
+ ClassicThemeContent as default
137
+ };
138
+ //# sourceMappingURL=classic-theme-content.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/template-actions-panel/classic-theme-content.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseEntityRecord,\n\tuseEntityBlockEditor,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { BlockPreview } from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport CreateNewTemplateModal from '../post-template/create-new-template-modal';\n\nexport default function ClassicThemeContent() {\n\tconst templateId = useSelect(\n\t\t( select ) => select( editorStore ).getCurrentTemplateId(),\n\t\t[]\n\t);\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\tconst {\n\t\tonNavigateToEntityRecord,\n\t\tcanCreateTemplate,\n\t\thasGoBack,\n\t\tgetEditorSettings,\n\t} = useSelect( ( select ) => {\n\t\tconst { getEditorSettings: _getEditorSettings } = select( editorStore );\n\t\tconst editorSettings = _getEditorSettings();\n\t\treturn {\n\t\t\tonNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,\n\t\t\tcanCreateTemplate:\n\t\t\t\t!! select( coreStore ).canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template',\n\t\t\t\t} ) && editorSettings.supportsTemplateMode,\n\t\t\thasGoBack: editorSettings.hasOwnProperty(\n\t\t\t\t'onNavigateToPreviousEntityRecord'\n\t\t\t),\n\t\t\tgetEditorSettings: _getEditorSettings,\n\t\t};\n\t}, [] );\n\tconst { get: getPreference } = useSelect( preferencesStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { editedRecord: template } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplateId\n\t);\n\tconst [ blocks ] = useEntityBlockEditor( 'postType', 'wp_template', {\n\t\tid: templateId,\n\t} );\n\n\t// Path A: No block template and cannot create templates.\n\tif ( ! templateId && ! canCreateTemplate ) {\n\t\treturn null;\n\t}\n\n\tconst notificationAction = hasGoBack\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t},\n\t\t ]\n\t\t: undefined;\n\n\tconst mayShowTemplateEditNotice = () => {\n\t\tif ( ! getPreference( 'core/edit-site', 'welcomeGuideTemplate' ) ) {\n\t\t\tcreateSuccessNotice(\n\t\t\t\t__(\n\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar', actions: notificationAction }\n\t\t\t);\n\t\t}\n\t};\n\n\tconst templateName = template\n\t\t? decodeEntities( template.title )\n\t\t: undefined;\n\n\tconst previewContent = !! blocks?.length && (\n\t\t<BlockPreview.Async>\n\t\t\t<BlockPreview blocks={ blocks } />\n\t\t</BlockPreview.Async>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<PanelBody\n\t\t\t\ttitle={\n\t\t\t\t\ttemplate\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: template name */\n\t\t\t\t\t\t\t\t__( 'Template: %s' ),\n\t\t\t\t\t\t\t\ttemplateName\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Template' )\n\t\t\t\t}\n\t\t\t\tinitialOpen={ false }\n\t\t\t>\n\t\t\t\t<VStack>\n\t\t\t\t\t{ ! templateId && (\n\t\t\t\t\t\t<Text>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'This page uses a classic template. To edit this template with blocks, create a block template.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t) }\n\t\t\t\t\t{ template && previewContent && (\n\t\t\t\t\t\t<div className=\"editor-template-actions-panel__preview\">\n\t\t\t\t\t\t\t{ previewContent }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t\t<HStack>\n\t\t\t\t\t\t{ template && onNavigateToEntityRecord && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tclassName=\"editor-template-actions-panel__action\"\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\tmayShowTemplateEditNotice();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ canCreateTemplate && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tclassName=\"editor-template-actions-panel__action\"\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\tonClick={ () => setIsCreateModalOpen( true ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ ! templateId\n\t\t\t\t\t\t\t\t\t? __( 'Create block template' )\n\t\t\t\t\t\t\t\t\t: __( 'Create new' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</PanelBody>\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</>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,EACA,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP,SAAS,gBAAgB;AACzB,SAAS,IAAI,eAAe;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,SAAS,oBAAoB;AACtC,SAAS,SAAS,wBAAwB;AAK1C,SAAS,SAAS,mBAAmB;AACrC,OAAO,4BAA4B;AAwEhC,SAKD,UALC,KA+BE,YA/BF;AAtEY,SAAR,sBAAuC;AAC7C,QAAM,aAAa;AAAA,IAClB,CAAE,WAAY,OAAQ,WAAY,EAAE,qBAAqB;AAAA,IACzD,CAAC;AAAA,EACF;AACA,QAAM,CAAE,mBAAmB,oBAAqB,IAAI,SAAU,KAAM;AACpE,QAAM;AAAA,IACL;AAA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ACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,OACC,WACG;AAAA;AAAA,UAEA,GAAI,cAAe;AAAA,UACnB;AAAA,QACA,IACA,GAAI,UAAW;AAAA,QAEnB,aAAc;AAAA,QAEd,+BAAC,UACE;AAAA,WAAE,cACH,oBAAC,QACE;AAAA,YACD;AAAA,UACD,GACD;AAAA,UAEC,YAAY,kBACb,oBAAC,SAAI,WAAU,0CACZ,0BACH;AAAA,UAED,qBAAC,UACE;AAAA,wBAAY,4BACb;AAAA,cAAC;AAAA;AAAA,gBACA,WAAU;AAAA,gBACV,uBAAqB;AAAA,gBACrB,SAAQ;AAAA,gBACR,SAAU,MAAM;AACf,2CAA0B;AAAA,oBACzB,QAAQ,SAAS;AAAA,oBACjB,UAAU;AAAA,kBACX,CAAE;AACF,4CAA0B;AAAA,gBAC3B;AAAA,gBAEE,aAAI,MAAO;AAAA;AAAA,YACd;AAAA,YAEC,qBACD;AAAA,cAAC;AAAA;AAAA,gBACA,WAAU;AAAA,gBACV,uBAAqB;AAAA,gBACrB,SAAQ;AAAA,gBACR,SAAU,MAAM,qBAAsB,IAAK;AAAA,gBAEzC,WAAE,aACD,GAAI,uBAAwB,IAC5B,GAAI,YAAa;AAAA;AAAA,YACrB;AAAA,aAEF;AAAA,WACD;AAAA;AAAA,IACD;AAAA,IACE,qBACD;AAAA,MAAC;AAAA;AAAA,QACA,SAAU,MAAM,qBAAsB,KAAM;AAAA;AAAA,IAC7C;AAAA,KAEF;AAEF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,28 @@
1
+ // packages/editor/src/components/template-actions-panel/index.js
2
+ import { useSelect } from "@wordpress/data";
3
+ import { store as editorStore } from "../../store/index.mjs";
4
+ import { usePostTemplatePanelMode } from "../post-template/hooks.mjs";
5
+ import BlockThemeContent from "./block-theme-content.mjs";
6
+ import ClassicThemeContent from "./classic-theme-content.mjs";
7
+ import { jsx } from "react/jsx-runtime";
8
+ function TemplateActionsPanel() {
9
+ const postType = useSelect(
10
+ (select) => select(editorStore).getCurrentPostType(),
11
+ []
12
+ );
13
+ const mode = usePostTemplatePanelMode();
14
+ if (!["page", "post"].includes(postType)) {
15
+ return null;
16
+ }
17
+ if (mode === "classic") {
18
+ return /* @__PURE__ */ jsx(ClassicThemeContent, {});
19
+ }
20
+ if (mode === "block-theme") {
21
+ return /* @__PURE__ */ jsx(BlockThemeContent, {});
22
+ }
23
+ return null;
24
+ }
25
+ export {
26
+ TemplateActionsPanel as default
27
+ };
28
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/template-actions-panel/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { usePostTemplatePanelMode } from '../post-template/hooks';\nimport BlockThemeContent from './block-theme-content';\nimport ClassicThemeContent from './classic-theme-content';\n\nexport default function TemplateActionsPanel() {\n\tconst postType = useSelect(\n\t\t( select ) => select( editorStore ).getCurrentPostType(),\n\t\t[]\n\t);\n\tconst mode = usePostTemplatePanelMode();\n\t// This check is because the experiment is gated for these post\n\t// types for now. Later we should use `postType.viewable`.\n\tif ( ! [ 'page', 'post' ].includes( postType ) ) {\n\t\treturn null;\n\t}\n\tif ( mode === 'classic' ) {\n\t\treturn <ClassicThemeContent />;\n\t}\n\tif ( mode === 'block-theme' ) {\n\t\treturn <BlockThemeContent />;\n\t}\n\treturn null;\n}\n"],
5
+ "mappings": ";AAGA,SAAS,iBAAiB;AAK1B,SAAS,SAAS,mBAAmB;AACrC,SAAS,gCAAgC;AACzC,OAAO,uBAAuB;AAC9B,OAAO,yBAAyB;AAcvB;AAZM,SAAR,uBAAwC;AAC9C,QAAM,WAAW;AAAA,IAChB,CAAE,WAAY,OAAQ,WAAY,EAAE,mBAAmB;AAAA,IACvD,CAAC;AAAA,EACF;AACA,QAAM,OAAO,yBAAyB;AAGtC,MAAK,CAAE,CAAE,QAAQ,MAAO,EAAE,SAAU,QAAS,GAAI;AAChD,WAAO;AAAA,EACR;AACA,MAAK,SAAS,WAAY;AACzB,WAAO,oBAAC,uBAAoB;AAAA,EAC7B;AACA,MAAK,SAAS,eAAgB;AAC7B,WAAO,oBAAC,qBAAkB;AAAA,EAC3B;AACA,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -15,6 +15,7 @@ import {
15
15
  resetPost,
16
16
  deletePost,
17
17
  duplicateTemplatePart,
18
+ excerptField,
18
19
  featuredImageField,
19
20
  dateField,
20
21
  parentField,
@@ -33,7 +34,8 @@ import {
33
34
  notesField,
34
35
  scheduledDateField,
35
36
  formatField,
36
- postContentInfoField
37
+ postContentInfoField,
38
+ stickyField
37
39
  } from "@wordpress/fields";
38
40
  import {
39
41
  altTextField,
@@ -169,6 +171,7 @@ var registerPostTypeSchema = (postType) => async ({ registry }) => {
169
171
  !DESIGN_POST_TYPES.includes(postTypeConfig.slug) && dateField,
170
172
  !DESIGN_POST_TYPES.includes(postTypeConfig.slug) && scheduledDateField,
171
173
  slugField,
174
+ !DESIGN_POST_TYPES.includes(postTypeConfig.slug) && postTypeConfig.supports?.excerpt && excerptField,
172
175
  postTypeConfig.supports?.["page-attributes"] && parentField,
173
176
  postTypeConfig.supports?.comments && commentStatusField,
174
177
  postTypeConfig.supports?.trackbacks && pingStatusField,
@@ -177,6 +180,7 @@ var registerPostTypeSchema = (postType) => async ({ registry }) => {
177
180
  postTypeConfig.supports?.["post-formats"] && !disablePostFormats && formatField,
178
181
  !DESIGN_POST_TYPES.includes(postTypeConfig.slug) && postTypeConfig.supports?.editor && postContentInfoField,
179
182
  passwordField,
183
+ postTypeConfig.slug === "post" && stickyField,
180
184
  postTypeConfig.supports?.editor && postTypeConfig.viewable && postPreviewField,
181
185
  hasEditorNotesSupport(postTypeConfig.supports) && notesField
182
186
  ].filter(Boolean);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/dataviews/store/private-actions.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { Action, Field } from '@wordpress/dataviews';\nimport { doAction } from '@wordpress/hooks';\nimport type { PostType } from '@wordpress/fields';\nimport {\n\tviewPost,\n\tviewPostRevisions,\n\tduplicatePost,\n\tduplicatePattern,\n\treorderPage,\n\texportPattern,\n\tpermanentlyDeletePost,\n\trestorePost,\n\ttrashPost,\n\trenamePost,\n\tresetPost,\n\tdeletePost,\n\tduplicateTemplatePart,\n\tfeaturedImageField,\n\tdateField,\n\tparentField,\n\tpasswordField,\n\tcommentStatusField,\n\tpingStatusField,\n\tdiscussionField,\n\tslugField,\n\tstatusField,\n\tauthorField,\n\ttitleField,\n\ttemplateField,\n\ttemplateTitleField,\n\tpageTitleField,\n\tpatternTitleField,\n\tnotesField,\n\tscheduledDateField,\n\tformatField,\n\tpostContentInfoField,\n} from '@wordpress/fields';\nimport {\n\taltTextField,\n\tattachedToField,\n\tauthorField as mediaAuthorField,\n\tcaptionField,\n\tdateAddedField,\n\tdescriptionField,\n\tfilenameField,\n\tfilesizeField,\n\tmediaDimensionsField,\n\tmimeTypeField,\n} from '@wordpress/media-fields';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { ATTACHMENT_POST_TYPE, DESIGN_POST_TYPES } from '../../store/constants';\nimport postPreviewField from '../fields/content-preview';\nimport { unlock } from '../../lock-unlock';\n\ndeclare global {\n\tinterface Window {\n\t\t__experimentalTemplateActivate?: boolean;\n\t\t__experimentalMediaEditor?: boolean;\n\t}\n}\n\n/**\n * Check if a post type supports editor notes.\n *\n * @param supports The post type supports object.\n * @return Whether editor notes are supported.\n */\nfunction hasEditorNotesSupport( supports?: PostType[ 'supports' ] ): boolean {\n\tconst editor = supports?.editor;\n\tif ( Array.isArray( editor ) ) {\n\t\treturn !! editor[ 0 ]?.notes;\n\t}\n\treturn false;\n}\n\nexport function registerEntityAction< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Action< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityAction(\n\tkind: string,\n\tname: string,\n\tactionId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tactionId,\n\t};\n}\n\nexport function registerEntityField< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Field< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_FIELD' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityField(\n\tkind: string,\n\tname: string,\n\tfieldId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_FIELD' as const,\n\t\tkind,\n\t\tname,\n\t\tfieldId,\n\t};\n}\n\nexport function setIsReady( kind: string, name: string ) {\n\treturn {\n\t\ttype: 'SET_IS_READY' as const,\n\t\tkind,\n\t\tname,\n\t};\n}\n\n/*\n * Media fields for the attachment post type.\n *\n * Field order follows a logical grouping:\n * 1. Metadata fields in panels (date, author, file info)\n * 2. Core editable fields (title, alt text, caption, description)\n *\n * Note: media_thumbnail is not included as it's shown in the canvas preview\n */\nconst ORDERED_MEDIA_FIELDS = [\n\t// Metadata in panels (collapsed by default).\n\tdateAddedField,\n\tmediaAuthorField,\n\tfilenameField,\n\tmimeTypeField,\n\tfilesizeField,\n\tmediaDimensionsField,\n\tattachedToField,\n\t// Regular layout fields (always visible).\n\ttitleField,\n\taltTextField,\n\tcaptionField,\n\tdescriptionField,\n];\n\nexport const registerPostTypeSchema =\n\t( postType: string ) =>\n\tasync ( { registry }: { registry: any } ) => {\n\t\tconst isReady = unlock( registry.select( editorStore ) ).isEntityReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tif ( isReady ) {\n\t\t\treturn;\n\t\t}\n\n\t\tunlock( registry.dispatch( editorStore ) ).setIsReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\n\t\tconst postTypeConfig = ( await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getPostType( postType ) ) as PostType;\n\n\t\tconst canCreate = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: postType,\n\t\t\t} );\n\t\tconst currentTheme = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getCurrentTheme();\n\t\tconst { disablePostFormats } = registry\n\t\t\t.select( editorStore )\n\t\t\t.getEditorSettings();\n\n\t\tlet canDuplicate =\n\t\t\t! [ 'wp_block', 'wp_template_part' ].includes(\n\t\t\t\tpostTypeConfig.slug\n\t\t\t) &&\n\t\t\tcanCreate &&\n\t\t\tduplicatePost;\n\n\t\t// @ts-ignore\n\t\tif ( ! globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t\t// Outside Gutenberg, disable duplication except for wp_template.\n\t\t\tif ( 'wp_template' !== postTypeConfig.slug ) {\n\t\t\t\tcanDuplicate = undefined;\n\t\t\t}\n\t\t}\n\n\t\t// When template activation experiment is disabled, templates cannot be duplicated.\n\t\t// @ts-ignore\n\t\tif (\n\t\t\tpostTypeConfig.slug === 'wp_template' &&\n\t\t\t! window?.__experimentalTemplateActivate\n\t\t) {\n\t\t\tcanDuplicate = undefined;\n\t\t}\n\n\t\tconst actions = [\n\t\t\tpostTypeConfig.viewable ? viewPost : undefined,\n\t\t\t!! postTypeConfig.supports?.revisions\n\t\t\t\t? viewPostRevisions\n\t\t\t\t: undefined,\n\t\t\t// @ts-ignore\n\t\t\tcanDuplicate,\n\t\t\tpostTypeConfig.slug === 'wp_template_part' &&\n\t\t\tcanCreate &&\n\t\t\tcurrentTheme?.is_block_theme\n\t\t\t\t? duplicateTemplatePart\n\t\t\t\t: undefined,\n\t\t\tcanCreate && postTypeConfig.slug === 'wp_block'\n\t\t\t\t? duplicatePattern\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.supports?.title ? renamePost : undefined,\n\t\t\tpostTypeConfig.supports?.[ 'page-attributes' ]\n\t\t\t\t? reorderPage\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.slug === 'wp_block' ? exportPattern : undefined,\n\t\t\trestorePost,\n\t\t\tresetPost,\n\t\t\tdeletePost,\n\t\t\ttrashPost,\n\t\t\tpermanentlyDeletePost,\n\t\t].filter( Boolean );\n\n\t\t// Handle attachment post type separately with media-specific fields\n\t\tlet fields;\n\n\t\tif ( postType === ATTACHMENT_POST_TYPE ) {\n\t\t\tfields = ORDERED_MEDIA_FIELDS;\n\t\t} else {\n\t\t\tfields = [\n\t\t\t\tpostTypeConfig.supports?.thumbnail &&\n\t\t\t\t\tcurrentTheme?.theme_supports?.[ 'post-thumbnails' ] &&\n\t\t\t\t\tfeaturedImageField,\n\t\t\t\tpostTypeConfig.supports?.author && authorField,\n\t\t\t\tstatusField,\n\t\t\t\t! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&\n\t\t\t\t\tdateField,\n\t\t\t\t! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&\n\t\t\t\t\tscheduledDateField,\n\t\t\t\tslugField,\n\t\t\t\tpostTypeConfig.supports?.[ 'page-attributes' ] && parentField,\n\t\t\t\tpostTypeConfig.supports?.comments && commentStatusField,\n\t\t\t\tpostTypeConfig.supports?.trackbacks && pingStatusField,\n\t\t\t\t( postTypeConfig.supports?.comments ||\n\t\t\t\t\tpostTypeConfig.supports?.trackbacks ) &&\n\t\t\t\t\tdiscussionField,\n\t\t\t\ttemplateField,\n\t\t\t\tpostTypeConfig.supports?.[ 'post-formats' ] &&\n\t\t\t\t\t! disablePostFormats &&\n\t\t\t\t\tformatField,\n\t\t\t\t! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&\n\t\t\t\t\tpostTypeConfig.supports?.editor &&\n\t\t\t\t\tpostContentInfoField,\n\t\t\t\tpasswordField,\n\t\t\t\tpostTypeConfig.supports?.editor &&\n\t\t\t\t\tpostTypeConfig.viewable &&\n\t\t\t\t\tpostPreviewField,\n\t\t\t\thasEditorNotesSupport( postTypeConfig.supports ) && notesField,\n\t\t\t].filter( Boolean );\n\t\t\tif ( postTypeConfig.supports?.title ) {\n\t\t\t\tlet _titleField;\n\t\t\t\tif ( postType === 'page' ) {\n\t\t\t\t\t_titleField = pageTitleField;\n\t\t\t\t} else if ( postType === 'wp_template' ) {\n\t\t\t\t\t_titleField = templateTitleField;\n\t\t\t\t} else if ( postType === 'wp_block' ) {\n\t\t\t\t\t_titleField = patternTitleField;\n\t\t\t\t} else {\n\t\t\t\t\t_titleField = titleField;\n\t\t\t\t}\n\t\t\t\tfields.push( _titleField );\n\t\t\t}\n\t\t}\n\n\t\tregistry.batch( () => {\n\t\t\tactions.forEach( ( action ) => {\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityAction(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\taction\n\t\t\t\t);\n\t\t\t} );\n\t\t\tfields.forEach( ( field ) => {\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityField(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tfield\n\t\t\t\t);\n\t\t\t} );\n\t\t} );\n\n\t\tdoAction( 'core.registerPostTypeSchema', postType );\n\t};\n"],
5
- "mappings": ";AAGA,SAAS,SAAS,iBAAiB;AAEnC,SAAS,gBAAgB;AAEzB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { Action, Field } from '@wordpress/dataviews';\nimport { doAction } from '@wordpress/hooks';\nimport type { PostType } from '@wordpress/fields';\nimport {\n\tviewPost,\n\tviewPostRevisions,\n\tduplicatePost,\n\tduplicatePattern,\n\treorderPage,\n\texportPattern,\n\tpermanentlyDeletePost,\n\trestorePost,\n\ttrashPost,\n\trenamePost,\n\tresetPost,\n\tdeletePost,\n\tduplicateTemplatePart,\n\texcerptField,\n\tfeaturedImageField,\n\tdateField,\n\tparentField,\n\tpasswordField,\n\tcommentStatusField,\n\tpingStatusField,\n\tdiscussionField,\n\tslugField,\n\tstatusField,\n\tauthorField,\n\ttitleField,\n\ttemplateField,\n\ttemplateTitleField,\n\tpageTitleField,\n\tpatternTitleField,\n\tnotesField,\n\tscheduledDateField,\n\tformatField,\n\tpostContentInfoField,\n\tstickyField,\n} from '@wordpress/fields';\nimport {\n\taltTextField,\n\tattachedToField,\n\tauthorField as mediaAuthorField,\n\tcaptionField,\n\tdateAddedField,\n\tdescriptionField,\n\tfilenameField,\n\tfilesizeField,\n\tmediaDimensionsField,\n\tmimeTypeField,\n} from '@wordpress/media-fields';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { ATTACHMENT_POST_TYPE, DESIGN_POST_TYPES } from '../../store/constants';\nimport postPreviewField from '../fields/content-preview';\nimport { unlock } from '../../lock-unlock';\n\ndeclare global {\n\tinterface Window {\n\t\t__experimentalTemplateActivate?: boolean;\n\t\t__experimentalMediaEditor?: boolean;\n\t}\n}\n\n/**\n * Check if a post type supports editor notes.\n *\n * @param supports The post type supports object.\n * @return Whether editor notes are supported.\n */\nfunction hasEditorNotesSupport( supports?: PostType[ 'supports' ] ): boolean {\n\tconst editor = supports?.editor;\n\tif ( Array.isArray( editor ) ) {\n\t\treturn !! editor[ 0 ]?.notes;\n\t}\n\treturn false;\n}\n\nexport function registerEntityAction< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Action< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityAction(\n\tkind: string,\n\tname: string,\n\tactionId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tactionId,\n\t};\n}\n\nexport function registerEntityField< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Field< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_FIELD' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityField(\n\tkind: string,\n\tname: string,\n\tfieldId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_FIELD' as const,\n\t\tkind,\n\t\tname,\n\t\tfieldId,\n\t};\n}\n\nexport function setIsReady( kind: string, name: string ) {\n\treturn {\n\t\ttype: 'SET_IS_READY' as const,\n\t\tkind,\n\t\tname,\n\t};\n}\n\n/*\n * Media fields for the attachment post type.\n *\n * Field order follows a logical grouping:\n * 1. Metadata fields in panels (date, author, file info)\n * 2. Core editable fields (title, alt text, caption, description)\n *\n * Note: media_thumbnail is not included as it's shown in the canvas preview\n */\nconst ORDERED_MEDIA_FIELDS = [\n\t// Metadata in panels (collapsed by default).\n\tdateAddedField,\n\tmediaAuthorField,\n\tfilenameField,\n\tmimeTypeField,\n\tfilesizeField,\n\tmediaDimensionsField,\n\tattachedToField,\n\t// Regular layout fields (always visible).\n\ttitleField,\n\taltTextField,\n\tcaptionField,\n\tdescriptionField,\n];\n\nexport const registerPostTypeSchema =\n\t( postType: string ) =>\n\tasync ( { registry }: { registry: any } ) => {\n\t\tconst isReady = unlock( registry.select( editorStore ) ).isEntityReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tif ( isReady ) {\n\t\t\treturn;\n\t\t}\n\n\t\tunlock( registry.dispatch( editorStore ) ).setIsReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\n\t\tconst postTypeConfig = ( await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getPostType( postType ) ) as PostType;\n\n\t\tconst canCreate = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: postType,\n\t\t\t} );\n\t\tconst currentTheme = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getCurrentTheme();\n\t\tconst { disablePostFormats } = registry\n\t\t\t.select( editorStore )\n\t\t\t.getEditorSettings();\n\n\t\tlet canDuplicate =\n\t\t\t! [ 'wp_block', 'wp_template_part' ].includes(\n\t\t\t\tpostTypeConfig.slug\n\t\t\t) &&\n\t\t\tcanCreate &&\n\t\t\tduplicatePost;\n\n\t\t// @ts-ignore\n\t\tif ( ! globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t\t// Outside Gutenberg, disable duplication except for wp_template.\n\t\t\tif ( 'wp_template' !== postTypeConfig.slug ) {\n\t\t\t\tcanDuplicate = undefined;\n\t\t\t}\n\t\t}\n\n\t\t// When template activation experiment is disabled, templates cannot be duplicated.\n\t\t// @ts-ignore\n\t\tif (\n\t\t\tpostTypeConfig.slug === 'wp_template' &&\n\t\t\t! window?.__experimentalTemplateActivate\n\t\t) {\n\t\t\tcanDuplicate = undefined;\n\t\t}\n\n\t\tconst actions = [\n\t\t\tpostTypeConfig.viewable ? viewPost : undefined,\n\t\t\t!! postTypeConfig.supports?.revisions\n\t\t\t\t? viewPostRevisions\n\t\t\t\t: undefined,\n\t\t\t// @ts-ignore\n\t\t\tcanDuplicate,\n\t\t\tpostTypeConfig.slug === 'wp_template_part' &&\n\t\t\tcanCreate &&\n\t\t\tcurrentTheme?.is_block_theme\n\t\t\t\t? duplicateTemplatePart\n\t\t\t\t: undefined,\n\t\t\tcanCreate && postTypeConfig.slug === 'wp_block'\n\t\t\t\t? duplicatePattern\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.supports?.title ? renamePost : undefined,\n\t\t\tpostTypeConfig.supports?.[ 'page-attributes' ]\n\t\t\t\t? reorderPage\n\t\t\t\t: undefined,\n\t\t\tpostTypeConfig.slug === 'wp_block' ? exportPattern : undefined,\n\t\t\trestorePost,\n\t\t\tresetPost,\n\t\t\tdeletePost,\n\t\t\ttrashPost,\n\t\t\tpermanentlyDeletePost,\n\t\t].filter( Boolean );\n\n\t\t// Handle attachment post type separately with media-specific fields\n\t\tlet fields;\n\n\t\tif ( postType === ATTACHMENT_POST_TYPE ) {\n\t\t\tfields = ORDERED_MEDIA_FIELDS;\n\t\t} else {\n\t\t\tfields = [\n\t\t\t\tpostTypeConfig.supports?.thumbnail &&\n\t\t\t\t\tcurrentTheme?.theme_supports?.[ 'post-thumbnails' ] &&\n\t\t\t\t\tfeaturedImageField,\n\t\t\t\tpostTypeConfig.supports?.author && authorField,\n\t\t\t\tstatusField,\n\t\t\t\t! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&\n\t\t\t\t\tdateField,\n\t\t\t\t! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&\n\t\t\t\t\tscheduledDateField,\n\t\t\t\tslugField,\n\t\t\t\t! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&\n\t\t\t\t\tpostTypeConfig.supports?.excerpt &&\n\t\t\t\t\texcerptField,\n\t\t\t\tpostTypeConfig.supports?.[ 'page-attributes' ] && parentField,\n\t\t\t\tpostTypeConfig.supports?.comments && commentStatusField,\n\t\t\t\tpostTypeConfig.supports?.trackbacks && pingStatusField,\n\t\t\t\t( postTypeConfig.supports?.comments ||\n\t\t\t\t\tpostTypeConfig.supports?.trackbacks ) &&\n\t\t\t\t\tdiscussionField,\n\t\t\t\ttemplateField,\n\t\t\t\tpostTypeConfig.supports?.[ 'post-formats' ] &&\n\t\t\t\t\t! disablePostFormats &&\n\t\t\t\t\tformatField,\n\t\t\t\t! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&\n\t\t\t\t\tpostTypeConfig.supports?.editor &&\n\t\t\t\t\tpostContentInfoField,\n\t\t\t\tpasswordField,\n\t\t\t\tpostTypeConfig.slug === 'post' && stickyField,\n\t\t\t\tpostTypeConfig.supports?.editor &&\n\t\t\t\t\tpostTypeConfig.viewable &&\n\t\t\t\t\tpostPreviewField,\n\t\t\t\thasEditorNotesSupport( postTypeConfig.supports ) && notesField,\n\t\t\t].filter( Boolean );\n\t\t\tif ( postTypeConfig.supports?.title ) {\n\t\t\t\tlet _titleField;\n\t\t\t\tif ( postType === 'page' ) {\n\t\t\t\t\t_titleField = pageTitleField;\n\t\t\t\t} else if ( postType === 'wp_template' ) {\n\t\t\t\t\t_titleField = templateTitleField;\n\t\t\t\t} else if ( postType === 'wp_block' ) {\n\t\t\t\t\t_titleField = patternTitleField;\n\t\t\t\t} else {\n\t\t\t\t\t_titleField = titleField;\n\t\t\t\t}\n\t\t\t\tfields.push( _titleField );\n\t\t\t}\n\t\t}\n\n\t\tregistry.batch( () => {\n\t\t\tactions.forEach( ( action ) => {\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityAction(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\taction\n\t\t\t\t);\n\t\t\t} );\n\t\t\tfields.forEach( ( field ) => {\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityField(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tfield\n\t\t\t\t);\n\t\t\t} );\n\t\t} );\n\n\t\tdoAction( 'core.registerPostTypeSchema', postType );\n\t};\n"],
5
+ "mappings": ";AAGA,SAAS,SAAS,iBAAiB;AAEnC,SAAS,gBAAgB;AAEzB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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IACD,CAAE;AACF,WAAO,QAAS,CAAE,UAAW;AAC5B,aAAQ,SAAS,SAAU,WAAY,CAAE,EAAE;AAAA,QAC1C;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD,CAAE;AAAA,EACH,CAAE;AAEF,WAAU,+BAA+B,QAAS;AACnD;",
6
6
  "names": []
7
7
  }
@@ -377,9 +377,23 @@ function setShowRevisionDiff(showDiff) {
377
377
  var restoreRevision = (revisionId) => async ({ select, dispatch, registry }) => {
378
378
  const postType = select.getCurrentPostType();
379
379
  const postId = select.getCurrentPostId();
380
+ const entityConfig = registry.select(coreStore).getEntityConfig("postType", postType);
381
+ const revisionKey = entityConfig?.revisionKey || "id";
380
382
  const revision = await registry.resolveSelect(coreStore).getRevision("postType", postType, postId, revisionId, {
381
383
  context: "edit",
382
- _fields: "id,date,author,meta,title.raw,excerpt.raw,content.raw"
384
+ _fields: [
385
+ .../* @__PURE__ */ new Set([
386
+ "id",
387
+ "date",
388
+ "modified",
389
+ "author",
390
+ "meta",
391
+ "title.raw",
392
+ "excerpt.raw",
393
+ "content.raw",
394
+ revisionKey
395
+ ])
396
+ ].join()
383
397
  });
384
398
  if (!revision) {
385
399
  return;
@@ -404,7 +418,12 @@ var restoreRevision = (revisionId) => async ({ select, dispatch, registry }) =>
404
418
  sprintf(
405
419
  /* translators: %s: Date and time of the revision. */
406
420
  __("Restored to revision from %s."),
407
- dateI18n(getDateSettings().formats.datetime, revision.date)
421
+ dateI18n(
422
+ getDateSettings().formats.datetime,
423
+ // Template revisions use the template REST API format, which
424
+ // exposes 'modified' instead of 'date'.
425
+ revisionKey === "wp_id" ? revision.modified : revision.date
426
+ )
408
427
  ),
409
428
  {
410
429
  type: "snackbar",