@wordpress/editor 14.48.0 → 14.48.1

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 (205) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/build/components/block-removal-warnings/index.cjs +0 -3
  3. package/build/components/block-removal-warnings/index.cjs.map +2 -2
  4. package/build/components/collab-sidebar/note-indicator-toolbar.cjs +49 -43
  5. package/build/components/collab-sidebar/note-indicator-toolbar.cjs.map +3 -3
  6. package/build/components/collaborators-overlay/use-block-highlighting.cjs +1 -8
  7. package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +3 -3
  8. package/build/components/collaborators-overlay/use-render-cursors.cjs +1 -7
  9. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
  10. package/build/components/more-menu/view-more-menu-group.cjs +1 -2
  11. package/build/components/more-menu/view-more-menu-group.cjs.map +2 -2
  12. package/build/components/page-attributes/parent.cjs +1 -0
  13. package/build/components/page-attributes/parent.cjs.map +2 -2
  14. package/build/components/post-publish-button/index.cjs +114 -157
  15. package/build/components/post-publish-button/index.cjs.map +3 -3
  16. package/build/components/post-revisions-preview/block-diff.cjs +21 -9
  17. package/build/components/post-revisions-preview/block-diff.cjs.map +2 -2
  18. package/build/components/post-revisions-preview/preserve-client-ids.cjs +2 -2
  19. package/build/components/post-revisions-preview/preserve-client-ids.cjs.map +2 -2
  20. package/build/components/provider/index.cjs +2 -0
  21. package/build/components/provider/index.cjs.map +3 -3
  22. package/build/components/provider/use-network-reconnect.cjs +51 -0
  23. package/build/components/provider/use-network-reconnect.cjs.map +7 -0
  24. package/build/components/revision-fields-diff/index.cjs +2 -2
  25. package/build/components/revision-fields-diff/index.cjs.map +2 -2
  26. package/build/components/sidebar/index.cjs +1 -4
  27. package/build/components/sidebar/index.cjs.map +2 -2
  28. package/build/components/template-actions-panel/block-theme-content.cjs +7 -1
  29. package/build/components/template-actions-panel/block-theme-content.cjs.map +2 -2
  30. package/build/components/upload-progress-snackbar/index.cjs +161 -0
  31. package/build/components/upload-progress-snackbar/index.cjs.map +7 -0
  32. package/build/components/upload-progress-snackbar/tracker.cjs +90 -0
  33. package/build/components/upload-progress-snackbar/tracker.cjs.map +7 -0
  34. package/build/private-apis.cjs +2 -0
  35. package/build/private-apis.cjs.map +3 -3
  36. package/build/store/selectors.cjs +1 -2
  37. package/build/store/selectors.cjs.map +2 -2
  38. package/build/utils/media-upload/index.cjs +16 -0
  39. package/build/utils/media-upload/index.cjs.map +3 -3
  40. package/build-module/components/block-removal-warnings/index.mjs +0 -3
  41. package/build-module/components/block-removal-warnings/index.mjs.map +2 -2
  42. package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs +53 -44
  43. package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs.map +2 -2
  44. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +1 -8
  45. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
  46. package/build-module/components/collaborators-overlay/use-render-cursors.mjs +1 -7
  47. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  48. package/build-module/components/more-menu/view-more-menu-group.mjs +1 -2
  49. package/build-module/components/more-menu/view-more-menu-group.mjs.map +2 -2
  50. package/build-module/components/page-attributes/parent.mjs +1 -0
  51. package/build-module/components/page-attributes/parent.mjs.map +2 -2
  52. package/build-module/components/post-publish-button/index.mjs +116 -159
  53. package/build-module/components/post-publish-button/index.mjs.map +2 -2
  54. package/build-module/components/post-revisions-preview/block-diff.mjs +20 -8
  55. package/build-module/components/post-revisions-preview/block-diff.mjs.map +2 -2
  56. package/build-module/components/post-revisions-preview/preserve-client-ids.mjs +1 -1
  57. package/build-module/components/post-revisions-preview/preserve-client-ids.mjs.map +1 -1
  58. package/build-module/components/provider/index.mjs +2 -0
  59. package/build-module/components/provider/index.mjs.map +2 -2
  60. package/build-module/components/provider/use-network-reconnect.mjs +30 -0
  61. package/build-module/components/provider/use-network-reconnect.mjs.map +7 -0
  62. package/build-module/components/revision-fields-diff/index.mjs +2 -2
  63. package/build-module/components/revision-fields-diff/index.mjs.map +2 -2
  64. package/build-module/components/sidebar/index.mjs +2 -11
  65. package/build-module/components/sidebar/index.mjs.map +2 -2
  66. package/build-module/components/template-actions-panel/block-theme-content.mjs +7 -1
  67. package/build-module/components/template-actions-panel/block-theme-content.mjs.map +2 -2
  68. package/build-module/components/upload-progress-snackbar/index.mjs +135 -0
  69. package/build-module/components/upload-progress-snackbar/index.mjs.map +7 -0
  70. package/build-module/components/upload-progress-snackbar/tracker.mjs +61 -0
  71. package/build-module/components/upload-progress-snackbar/tracker.mjs.map +7 -0
  72. package/build-module/private-apis.mjs +2 -0
  73. package/build-module/private-apis.mjs.map +2 -2
  74. package/build-module/store/selectors.mjs +1 -2
  75. package/build-module/store/selectors.mjs.map +2 -2
  76. package/build-module/utils/media-upload/index.mjs +19 -0
  77. package/build-module/utils/media-upload/index.mjs.map +2 -2
  78. package/build-style/style-rtl.css +454 -81
  79. package/build-style/style.css +454 -81
  80. package/build-types/components/block-removal-warnings/index.d.ts.map +1 -1
  81. package/build-types/components/collab-sidebar/add-comment.d.ts +6 -0
  82. package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -0
  83. package/build-types/components/collab-sidebar/comment-author-info.d.ts +8 -0
  84. package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -0
  85. package/build-types/components/collab-sidebar/comment-form.d.ts +9 -0
  86. package/build-types/components/collab-sidebar/comment-form.d.ts.map +1 -0
  87. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts +6 -0
  88. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +1 -0
  89. package/build-types/components/collab-sidebar/comment-menu-item.d.ts +6 -0
  90. package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +1 -0
  91. package/build-types/components/collab-sidebar/comments.d.ts +10 -0
  92. package/build-types/components/collab-sidebar/comments.d.ts.map +1 -0
  93. package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts.map +1 -1
  94. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts +0 -3
  95. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts.map +1 -1
  96. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
  97. package/build-types/components/document-bar/index.d.ts +2 -2
  98. package/build-types/components/document-bar/index.d.ts.map +1 -1
  99. package/build-types/components/global-styles-provider/index.d.ts +16 -0
  100. package/build-types/components/global-styles-provider/index.d.ts.map +1 -0
  101. package/build-types/components/media/index.d.ts +3 -0
  102. package/build-types/components/media/index.d.ts.map +1 -0
  103. package/build-types/components/media/metadata-panel.d.ts +12 -0
  104. package/build-types/components/media/metadata-panel.d.ts.map +1 -0
  105. package/build-types/components/media/preview.d.ts +9 -0
  106. package/build-types/components/media/preview.d.ts.map +1 -0
  107. package/build-types/components/more-menu/view-more-menu-group.d.ts.map +1 -1
  108. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  109. package/build-types/components/post-publish-button/index.d.ts +9 -9
  110. package/build-types/components/post-publish-button/index.d.ts.map +1 -1
  111. package/build-types/components/post-revisions-preview/block-diff.d.ts +3 -0
  112. package/build-types/components/post-revisions-preview/block-diff.d.ts.map +1 -1
  113. package/build-types/components/post-text-editor/index.d.ts +1 -1
  114. package/build-types/components/post-text-editor/index.d.ts.map +1 -1
  115. package/build-types/components/post-text-editor/utils.d.ts +29 -0
  116. package/build-types/components/post-text-editor/utils.d.ts.map +1 -0
  117. package/build-types/components/provider/index.d.ts.map +1 -1
  118. package/build-types/components/provider/use-network-reconnect.d.ts +8 -0
  119. package/build-types/components/provider/use-network-reconnect.d.ts.map +1 -0
  120. package/build-types/components/revision-fields-diff/index.d.ts +3 -0
  121. package/build-types/components/revision-fields-diff/index.d.ts.map +1 -1
  122. package/build-types/components/sidebar/index.d.ts.map +1 -1
  123. package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -1
  124. package/build-types/components/upload-progress-snackbar/index.d.ts +19 -0
  125. package/build-types/components/upload-progress-snackbar/index.d.ts.map +1 -0
  126. package/build-types/components/upload-progress-snackbar/stories/index.story.d.ts +28 -0
  127. package/build-types/components/upload-progress-snackbar/stories/index.story.d.ts.map +1 -0
  128. package/build-types/components/upload-progress-snackbar/tracker.d.ts +41 -0
  129. package/build-types/components/upload-progress-snackbar/tracker.d.ts.map +1 -0
  130. package/build-types/private-apis.d.ts.map +1 -1
  131. package/build-types/store/selectors.d.ts.map +1 -1
  132. package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
  133. package/build-types/utils/media-upload/index.d.ts.map +1 -1
  134. package/package.json +53 -50
  135. package/src/components/README.md +1 -1
  136. package/src/components/block-removal-warnings/index.js +0 -7
  137. package/src/components/collab-sidebar/note-indicator-toolbar.js +73 -60
  138. package/src/components/collaborators-overlay/use-block-highlighting.ts +0 -9
  139. package/src/components/collaborators-overlay/use-render-cursors.ts +0 -8
  140. package/src/components/collaborators-presence/avatar/test/index.tsx +8 -3
  141. package/src/components/more-menu/view-more-menu-group.js +1 -2
  142. package/src/components/page-attributes/parent.js +1 -0
  143. package/src/components/post-publish-button/index.js +143 -192
  144. package/src/components/post-publish-button/test/index.js +137 -114
  145. package/src/components/post-revisions-preview/block-diff.js +63 -19
  146. package/src/components/post-revisions-preview/preserve-client-ids.js +1 -1
  147. package/src/components/post-revisions-preview/test/block-diff.js +109 -6
  148. package/src/components/provider/index.js +4 -0
  149. package/src/components/provider/test/use-network-reconnect.js +137 -0
  150. package/src/components/provider/use-network-reconnect.js +44 -0
  151. package/src/components/revision-fields-diff/index.js +7 -2
  152. package/src/components/sidebar/index.js +2 -11
  153. package/src/components/template-actions-panel/block-theme-content.js +10 -1
  154. package/src/components/upload-progress-snackbar/README.md +26 -0
  155. package/src/components/upload-progress-snackbar/index.js +216 -0
  156. package/src/components/upload-progress-snackbar/stories/index.story.tsx +85 -0
  157. package/src/components/upload-progress-snackbar/style.scss +30 -0
  158. package/src/components/upload-progress-snackbar/test/index.js +199 -0
  159. package/src/components/upload-progress-snackbar/tracker.js +105 -0
  160. package/src/private-apis.js +2 -0
  161. package/src/store/selectors.js +1 -3
  162. package/src/style.scss +1 -0
  163. package/src/utils/media-upload/index.js +27 -0
  164. package/src/components/commands/index.native.js +0 -2
  165. package/src/components/deprecated.native.js +0 -47
  166. package/src/components/editor-help/add-blocks.native.js +0 -40
  167. package/src/components/editor-help/customize-blocks.native.js +0 -40
  168. package/src/components/editor-help/help-detail-navigation-screen.native.js +0 -67
  169. package/src/components/editor-help/help-get-support-button.native.js +0 -38
  170. package/src/components/editor-help/help-section-title.native.js +0 -29
  171. package/src/components/editor-help/help-topic-row.native.js +0 -33
  172. package/src/components/editor-help/icon-move-blocks.native.js +0 -10
  173. package/src/components/editor-help/index.native.js +0 -208
  174. package/src/components/editor-help/intro-to-blocks.native.js +0 -91
  175. package/src/components/editor-help/move-blocks.native.js +0 -55
  176. package/src/components/editor-help/remove-blocks.native.js +0 -35
  177. package/src/components/editor-help/style.android.scss +0 -6
  178. package/src/components/editor-help/style.ios.scss +0 -6
  179. package/src/components/editor-help/test/index.native.js +0 -81
  180. package/src/components/editor-help/view-sections.native.js +0 -79
  181. package/src/components/error-boundary/index.native.js +0 -192
  182. package/src/components/error-boundary/style.native.scss +0 -116
  183. package/src/components/index.native.js +0 -15
  184. package/src/components/offline-status/index.native.js +0 -99
  185. package/src/components/offline-status/style.native.scss +0 -28
  186. package/src/components/offline-status/test/index.native.js +0 -108
  187. package/src/components/post-title/index.native.js +0 -282
  188. package/src/components/post-title/style.native.scss +0 -13
  189. package/src/components/post-title/test/__snapshots__/index.native.js.snap +0 -25
  190. package/src/components/post-title/test/index.native.js +0 -78
  191. package/src/components/provider/index.native.js +0 -497
  192. package/src/components/provider/use-block-editor-settings.native.js +0 -48
  193. package/src/components/template-part-menu-items/index.native.js +0 -3
  194. package/src/hooks/index.native.js +0 -0
  195. package/src/index.native.js +0 -16
  196. package/src/private-apis.native.js +0 -33
  197. package/src/store/actions.native.js +0 -27
  198. package/src/store/reducer.native.js +0 -94
  199. package/src/store/selectors.native.js +0 -57
  200. package/src/store/test/actions.native.js +0 -16
  201. package/src/store/test/reducer.native.js +0 -36
  202. package/src/store/test/selectors.native.js +0 -28
  203. package/src/utils/index.native.js +0 -6
  204. package/src/utils/media-sideload/index.native.js +0 -1
  205. package/src/utils/media-upload/index.native.js +0 -1
@@ -30,6 +30,7 @@ import { useHideBlocksFromInserter } from "./use-hide-blocks-from-inserter.mjs";
30
30
  import { useRevisionBlocks } from "./use-revision-blocks.mjs";
31
31
  import useCommands from "../commands/index.mjs";
32
32
  import useUploadSaveLock from "./use-upload-save-lock.mjs";
33
+ import useNetworkReconnect from "./use-network-reconnect.mjs";
33
34
  import BlockRemovalWarnings from "../block-removal-warnings/index.mjs";
34
35
  import StartPageOptions from "../start-page-options/index.mjs";
35
36
  import KeyboardShortcutHelpModal from "../keyboard-shortcut-help-modal/index.mjs";
@@ -264,6 +265,7 @@ var ExperimentalEditorProvider = withRegistryProvider(
264
265
  useHideBlocksFromInserter(post.type, mode);
265
266
  useCommands();
266
267
  useUploadSaveLock();
268
+ useNetworkReconnect();
267
269
  if (!isReady || !mode) {
268
270
  return null;
269
271
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/provider/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tEntityProvider,\n\tuseEntityBlockEditor,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport {\n\tBlockEditorProvider,\n\tBlockContextProvider,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport { store as editorStore } from '../../store';\nimport useBlockEditorSettings from './use-block-editor-settings';\nimport { unlock } from '../../lock-unlock';\nimport DisableNonPageContentBlocks from './disable-non-page-content-blocks';\nimport NavigationBlockEditingMode from './navigation-block-editing-mode';\nimport { useHideBlocksFromInserter } from './use-hide-blocks-from-inserter';\nimport { useRevisionBlocks } from './use-revision-blocks';\nimport useCommands from '../commands';\nimport useUploadSaveLock from './use-upload-save-lock';\nimport BlockRemovalWarnings from '../block-removal-warnings';\nimport StartPageOptions from '../start-page-options';\nimport KeyboardShortcutHelpModal from '../keyboard-shortcut-help-modal';\nimport StartTemplateOptions from '../start-template-options';\nimport EditorKeyboardShortcuts from '../global-keyboard-shortcuts';\nimport PatternRenameModal from '../pattern-rename-modal';\nimport PatternDuplicateModal from '../pattern-duplicate-modal';\nimport TemplatePartMenuItems from '../template-part-menu-items';\nimport MediaEditorModalMount from '../media/media-editor-modal';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst noop = () => {};\n\n/**\n * These are global entities that are only there to split blocks into logical units\n * They don't provide a \"context\" for the current post/page being rendered.\n * So we should not use their ids as post context. This is important to allow post blocks\n * (post content, post title) to be used within them without issues.\n */\nconst NON_CONTEXTUAL_POST_TYPES = [\n\t'wp_block',\n\t'wp_navigation',\n\t'wp_template_part',\n];\n\n/**\n * Depending on the post, template and template mode,\n * returns the appropriate blocks and change handlers for the block editor provider.\n *\n * @param {Array} post Block list.\n * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.\n * @param {string} mode Rendering mode.\n *\n * @example\n * ```jsx\n * const [ blocks, onInput, onChange ] = useBlockEditorProps( post, template, mode );\n * ```\n *\n * @return {Array} Block editor props.\n */\nfunction useBlockEditorProps( post, template, mode ) {\n\tconst revisionBlocks = useRevisionBlocks();\n\tconst rootLevelPost = mode === 'template-locked' ? 'template' : 'post';\n\tconst [ postBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpost.type,\n\t\t{ id: post.id }\n\t);\n\tconst [ templateBlocks, onInputTemplate, onChangeTemplate ] =\n\t\tuseEntityBlockEditor( 'postType', template?.type, {\n\t\t\tid: template?.id,\n\t\t} );\n\tconst maybeNavigationBlocks = useMemo( () => {\n\t\tif ( post.type === 'wp_navigation' ) {\n\t\t\treturn [\n\t\t\t\tcreateBlock( 'core/navigation', {\n\t\t\t\t\tref: post.id,\n\t\t\t\t\t// As the parent editor is locked with `templateLock`, the template locking\n\t\t\t\t\t// must be explicitly \"unset\" on the block itself to allow the user to modify\n\t\t\t\t\t// the block's content.\n\t\t\t\t\ttemplateLock: false,\n\t\t\t\t} ),\n\t\t\t];\n\t\t}\n\t}, [ post.type, post.id ] );\n\n\t// It is important that we don't create a new instance of blocks on every change\n\t// We should only create a new instance if the blocks them selves change, not a dependency of them.\n\tconst blocks = useMemo( () => {\n\t\tif ( maybeNavigationBlocks ) {\n\t\t\treturn maybeNavigationBlocks;\n\t\t}\n\n\t\tif ( rootLevelPost === 'template' ) {\n\t\t\treturn templateBlocks;\n\t\t}\n\n\t\treturn postBlocks;\n\t}, [ maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks ] );\n\n\t// In revisions mode, use the revision blocks and disable editing.\n\tif ( revisionBlocks !== null ) {\n\t\treturn [ revisionBlocks, noop, noop ];\n\t}\n\n\t// Handle fallback to postBlocks outside of the above useMemo, to ensure\n\t// that constructed block templates that call `createBlock` are not generated\n\t// too frequently. This ensures that clientIds are stable.\n\tconst disableRootLevelChanges =\n\t\t( !! template && mode === 'template-locked' ) ||\n\t\tpost.type === 'wp_navigation';\n\tif ( disableRootLevelChanges ) {\n\t\treturn [ blocks, noop, noop ];\n\t}\n\n\treturn [\n\t\tblocks,\n\t\trootLevelPost === 'post' ? onInput : onInputTemplate,\n\t\trootLevelPost === 'post' ? onChange : onChangeTemplate,\n\t];\n}\n\n/**\n * This component provides the editor context and manages the state of the block editor.\n *\n * @param {Object} props The component props.\n * @param {Object} props.post The post object.\n * @param {Object} props.settings The editor settings.\n * @param {boolean} props.recovery Indicates if the editor is in recovery mode.\n * @param {Array} props.initialEdits The initial edits for the editor.\n * @param {Object} props.children The child components.\n * @param {Object} [props.BlockEditorProviderComponent] The block editor provider component to use. Defaults to ExperimentalBlockEditorProvider.\n * @param {Object} [props.__unstableTemplate] The template object.\n *\n * @example\n * ```jsx\n * <ExperimentalEditorProvider\n * post={ post }\n * settings={ settings }\n * recovery={ recovery }\n * initialEdits={ initialEdits }\n * __unstableTemplate={ template }\n * >\n * { children }\n * </ExperimentalEditorProvider>\n *\n * @return {Object} The rendered ExperimentalEditorProvider component.\n */\nexport const ExperimentalEditorProvider = withRegistryProvider(\n\t( {\n\t\tpost,\n\t\tsettings,\n\t\trecovery,\n\t\tinitialEdits,\n\t\tchildren,\n\t\tBlockEditorProviderComponent = ExperimentalBlockEditorProvider,\n\t\t__unstableTemplate: template,\n\t} ) => {\n\t\tconst hasTemplate = !! template;\n\t\tconst {\n\t\t\teditorSettings,\n\t\t\tselection,\n\t\t\tisReady,\n\t\t\tmode,\n\t\t\tdefaultMode,\n\t\t\tpostTypeEntities,\n\t\t\tisInRevisionsMode,\n\t\t\tcurrentRevisionId,\n\t\t} = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEditorSettings,\n\t\t\t\t\tgetRenderingMode,\n\t\t\t\t\t__unstableIsEditorReady,\n\t\t\t\t\tgetDefaultRenderingMode,\n\t\t\t\t\tisRevisionsMode: _isRevisionsMode,\n\t\t\t\t\tgetCurrentRevisionId: _getCurrentRevisionId,\n\t\t\t\t} = unlock( select( editorStore ) );\n\t\t\t\tconst { getEntitiesConfig, getEntityRecordEdits } =\n\t\t\t\t\tselect( coreStore );\n\n\t\t\t\tconst _mode = getRenderingMode();\n\t\t\t\tconst _defaultMode = getDefaultRenderingMode( post.type );\n\t\t\t\t/**\n\t\t\t\t * To avoid content \"flash\", wait until rendering mode has been resolved.\n\t\t\t\t * This is important for the initial render of the editor.\n\t\t\t\t *\n\t\t\t\t * - Wait for template to be resolved if the default mode is 'template-locked'.\n\t\t\t\t * - Wait for default mode to be resolved otherwise.\n\t\t\t\t */\n\t\t\t\tconst hasResolvedDefaultMode =\n\t\t\t\t\t_defaultMode === 'template-locked'\n\t\t\t\t\t\t? hasTemplate\n\t\t\t\t\t\t: _defaultMode !== undefined;\n\t\t\t\t// Wait until the default mode is retrieved and start rendering canvas.\n\t\t\t\tconst isRenderingModeReady = _defaultMode !== undefined;\n\n\t\t\t\t// Read selection directly from entity edits using the post prop,\n\t\t\t\t// bypassing getCurrentPostId() which lags behind in useEffect.\n\t\t\t\tconst entityEdits = getEntityRecordEdits(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpost.type,\n\t\t\t\t\tpost.id\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\teditorSettings: getEditorSettings(),\n\t\t\t\t\tisReady: __unstableIsEditorReady(),\n\t\t\t\t\tmode: isRenderingModeReady ? _mode : undefined,\n\t\t\t\t\tdefaultMode: hasResolvedDefaultMode\n\t\t\t\t\t\t? _defaultMode\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tselection: entityEdits?.selection,\n\t\t\t\t\tpostTypeEntities:\n\t\t\t\t\t\tpost.type === 'wp_template'\n\t\t\t\t\t\t\t? getEntitiesConfig( 'postType' )\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\tisInRevisionsMode: _isRevisionsMode(),\n\t\t\t\t\tcurrentRevisionId: _getCurrentRevisionId(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ post.type, post.id, hasTemplate ]\n\t\t);\n\n\t\tconst shouldRenderTemplate = hasTemplate && mode !== 'post-only';\n\t\tconst rootLevelPost = shouldRenderTemplate ? template : post;\n\t\tconst defaultBlockContext = useMemo( () => {\n\t\t\tconst postContext = {};\n\t\t\t// If it is a template, try to inherit the post type from the name.\n\t\t\tif ( post.type === 'wp_template' ) {\n\t\t\t\tif ( post.slug === 'page' ) {\n\t\t\t\t\tpostContext.postType = 'page';\n\t\t\t\t} else if ( post.slug === 'single' ) {\n\t\t\t\t\tpostContext.postType = 'post';\n\t\t\t\t} else if ( post.slug.split( '-' )[ 0 ] === 'single' ) {\n\t\t\t\t\t// If the slug is single-{postType}, infer the post type from the name.\n\t\t\t\t\tconst postTypeNames =\n\t\t\t\t\t\tpostTypeEntities?.map( ( entity ) => entity.name ) ||\n\t\t\t\t\t\t[];\n\t\t\t\t\tconst match = post.slug.match(\n\t\t\t\t\t\t`^single-(${ postTypeNames.join( '|' ) })(?:-.+)?$`\n\t\t\t\t\t);\n\t\t\t\t\tif ( match ) {\n\t\t\t\t\t\tpostContext.postType = match[ 1 ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t! NON_CONTEXTUAL_POST_TYPES.includes( rootLevelPost.type ) ||\n\t\t\t\tshouldRenderTemplate\n\t\t\t) {\n\t\t\t\tpostContext.postId = post.id;\n\t\t\t\tpostContext.postType = post.type;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...postContext,\n\t\t\t\ttemplateSlug:\n\t\t\t\t\trootLevelPost.type === 'wp_template'\n\t\t\t\t\t\t? rootLevelPost.slug\n\t\t\t\t\t\t: undefined,\n\t\t\t};\n\t\t}, [\n\t\t\tshouldRenderTemplate,\n\t\t\tpost.id,\n\t\t\tpost.type,\n\t\t\tpost.slug,\n\t\t\trootLevelPost.type,\n\t\t\trootLevelPost.slug,\n\t\t\tpostTypeEntities,\n\t\t] );\n\t\tconst { id, type } = rootLevelPost;\n\t\tconst blockEditorSettings = useBlockEditorSettings(\n\t\t\teditorSettings,\n\t\t\ttype,\n\t\t\tid,\n\t\t\tmode\n\t\t);\n\t\tconst [ blocks, onInput, onChange ] = useBlockEditorProps(\n\t\t\tpost,\n\t\t\ttemplate,\n\t\t\tmode\n\t\t);\n\n\t\tconst {\n\t\t\tupdatePostLock,\n\t\t\tsetupEditor,\n\t\t\tupdateEditorSettings,\n\t\t\tsetCurrentTemplateId,\n\t\t\tsetEditedPost,\n\t\t\tsetRenderingMode,\n\t\t} = unlock( useDispatch( editorStore ) );\n\t\tconst { editEntityRecord } = useDispatch( coreStore );\n\t\tconst registry = useRegistry();\n\n\t\tconst onChangeSelection = useCallback(\n\t\t\t( newSelection ) => {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpost.type,\n\t\t\t\t\tpost.id,\n\t\t\t\t\t{ selection: newSelection },\n\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ editEntityRecord, post.type, post.id ]\n\t\t);\n\t\tconst { createWarningNotice, removeNotice } =\n\t\t\tuseDispatch( noticesStore );\n\n\t\t// Ideally this should be synced on each change and not just something you do once.\n\t\tuseLayoutEffect( () => {\n\t\t\t// Assume that we don't need to initialize in the case of an error recovery.\n\t\t\tif ( recovery ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdatePostLock( settings.postLock );\n\t\t\t// `setupEditor` may already have been dispatched by the\n\t\t\t// editor's pre-mount kickoff (see edit-post's\n\t\t\t// `initializeEditor`). Skip the redundant dispatch \u2014 it\n\t\t\t// would otherwise re-parse + reset blocks for new posts.\n\t\t\tif ( ! registry.select( editorStore ).__unstableIsEditorReady() ) {\n\t\t\t\tsetupEditor( post, initialEdits, settings.template );\n\t\t\t}\n\t\t\tif ( settings.autosave ) {\n\t\t\t\tcreateWarningNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'There is an autosave of this post that is more recent than the version below.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: 'autosave-exists',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View the autosave' ),\n\t\t\t\t\t\t\t\turl: settings.autosave.editLink,\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);\n\t\t\t}\n\n\t\t\t// The dependencies of the hook are omitted deliberately\n\t\t\t// We only want to run setupEditor (with initialEdits) only once per post.\n\t\t\t// A better solution in the future would be to split this effect into multiple ones.\n\t\t}, [] );\n\n\t\t// Synchronizes the active post with the state\n\t\tuseEffect( () => {\n\t\t\tsetEditedPost( post.type, post.id );\n\t\t\tif (\n\t\t\t\ttypeof window !== 'undefined' &&\n\t\t\t\twindow.__experimentalTemplateActivate\n\t\t\t) {\n\t\t\t\t// Clear any notices dependent on the post context.\n\t\t\t\tremoveNotice( 'template-activate-notice' );\n\t\t\t}\n\n\t\t\treturn () => setEditedPost( null, null );\n\t\t}, [ post.type, post.id, setEditedPost, removeNotice ] );\n\n\t\t// Synchronize the editor settings as they change.\n\t\tuseEffect( () => {\n\t\t\tupdateEditorSettings( settings );\n\t\t}, [ settings, updateEditorSettings ] );\n\n\t\t// Synchronizes the active template with the state.\n\t\tuseEffect( () => {\n\t\t\tsetCurrentTemplateId( template?.id );\n\t\t}, [ template?.id, setCurrentTemplateId ] );\n\n\t\t// Sets the right rendering mode when loading the editor.\n\t\tuseEffect( () => {\n\t\t\tif ( defaultMode ) {\n\t\t\t\tsetRenderingMode( defaultMode );\n\t\t\t}\n\t\t}, [ defaultMode, setRenderingMode ] );\n\n\t\tuseHideBlocksFromInserter( post.type, mode );\n\n\t\t// Register the editor commands.\n\t\tuseCommands();\n\n\t\t// Lock post saving when media uploads are in progress (experimental feature).\n\t\tuseUploadSaveLock();\n\n\t\tif ( ! isReady || ! mode ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ post.type }\n\t\t\t\t\tid={ post.id }\n\t\t\t\t\trevisionId={ currentRevisionId ?? undefined }\n\t\t\t\t>\n\t\t\t\t\t<BlockContextProvider value={ defaultBlockContext }>\n\t\t\t\t\t\t<BlockEditorProviderComponent\n\t\t\t\t\t\t\tvalue={ blocks }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tonInput={ onInput }\n\t\t\t\t\t\t\tselection={\n\t\t\t\t\t\t\t\tisInRevisionsMode ? undefined : selection\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonChangeSelection={\n\t\t\t\t\t\t\t\tisInRevisionsMode ? noop : onChangeSelection\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsettings={ blockEditorSettings }\n\t\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t{ ! settings.isPreviewMode && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<PatternsMenuItems />\n\t\t\t\t\t\t\t\t\t<TemplatePartMenuItems />\n\t\t\t\t\t\t\t\t\t{ mode === 'template-locked' && (\n\t\t\t\t\t\t\t\t\t\t<DisableNonPageContentBlocks />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ type === 'wp_navigation' && (\n\t\t\t\t\t\t\t\t\t\t<NavigationBlockEditingMode />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<EditorKeyboardShortcuts />\n\t\t\t\t\t\t\t\t\t<KeyboardShortcutHelpModal />\n\t\t\t\t\t\t\t\t\t<BlockRemovalWarnings />\n\t\t\t\t\t\t\t\t\t<StartPageOptions />\n\t\t\t\t\t\t\t\t\t<StartTemplateOptions />\n\t\t\t\t\t\t\t\t\t<PatternRenameModal />\n\t\t\t\t\t\t\t\t\t<PatternDuplicateModal />\n\t\t\t\t\t\t\t\t\t<MediaEditorModalMount />\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</BlockEditorProviderComponent>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t);\n\t}\n);\n\n/**\n * This component establishes a new post editing context, and serves as the entry point for a new post editor (or post with template editor).\n *\n * It supports a large number of post types, including post, page, templates,\n * custom post types, patterns, template parts.\n *\n * All modification and changes are performed to the `@wordpress/core-data` store.\n *\n * @param {Object} props The component props.\n * @param {Object} [props.post] The post object to edit. This is required.\n * @param {Object} [props.__unstableTemplate] The template object wrapper the edited post.\n * This is optional and can only be used when the post type supports templates (like posts and pages).\n * @param {Object} [props.settings] The settings object to use for the editor.\n * This is optional and can be used to override the default settings.\n * @param {React.ReactNode} [props.children] Children elements for which the BlockEditorProvider context should apply.\n * This is optional.\n *\n * @example\n * ```jsx\n * <EditorProvider\n * post={ post }\n * settings={ settings }\n * __unstableTemplate={ template }\n * >\n * { children }\n * </EditorProvider>\n * ```\n *\n * @return {React.ReactNode} The rendered EditorProvider component.\n */\nexport function EditorProvider( props ) {\n\treturn (\n\t\t<ExperimentalEditorProvider\n\t\t\t{ ...props }\n\t\t\tBlockEditorProviderComponent={ BlockEditorProvider }\n\t\t>\n\t\t\t{ props.children }\n\t\t</ExperimentalEditorProvider>\n\t);\n}\n\nexport default EditorProvider;\n"],
5
- "mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa,WAAW,mBAAmB;AACpD,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,SAAS,oBAAoB;AACtC,SAAS,eAAe,+BAA+B;AACvD,SAAS,mBAAmB;AAK5B,OAAO,0BAA0B;AACjC,SAAS,SAAS,mBAAmB;AACrC,OAAO,4BAA4B;AACnC,SAAS,cAAc;AACvB,OAAO,iCAAiC;AACxC,OAAO,gCAAgC;AACvC,SAAS,iCAAiC;AAC1C,SAAS,yBAAyB;AA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D,GACD;AAAA,EAEF;AACD;AAgCO,SAAS,eAAgB,OAAQ;AACvC,SACC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACL,8BAA+B;AAAA,MAE7B,gBAAM;AAAA;AAAA,EACT;AAEF;AAEA,IAAO,mBAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tEntityProvider,\n\tuseEntityBlockEditor,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport {\n\tBlockEditorProvider,\n\tBlockContextProvider,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport { store as editorStore } from '../../store';\nimport useBlockEditorSettings from './use-block-editor-settings';\nimport { unlock } from '../../lock-unlock';\nimport DisableNonPageContentBlocks from './disable-non-page-content-blocks';\nimport NavigationBlockEditingMode from './navigation-block-editing-mode';\nimport { useHideBlocksFromInserter } from './use-hide-blocks-from-inserter';\nimport { useRevisionBlocks } from './use-revision-blocks';\nimport useCommands from '../commands';\nimport useUploadSaveLock from './use-upload-save-lock';\nimport useNetworkReconnect from './use-network-reconnect';\nimport BlockRemovalWarnings from '../block-removal-warnings';\nimport StartPageOptions from '../start-page-options';\nimport KeyboardShortcutHelpModal from '../keyboard-shortcut-help-modal';\nimport StartTemplateOptions from '../start-template-options';\nimport EditorKeyboardShortcuts from '../global-keyboard-shortcuts';\nimport PatternRenameModal from '../pattern-rename-modal';\nimport PatternDuplicateModal from '../pattern-duplicate-modal';\nimport TemplatePartMenuItems from '../template-part-menu-items';\nimport MediaEditorModalMount from '../media/media-editor-modal';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst noop = () => {};\n\n/**\n * These are global entities that are only there to split blocks into logical units\n * They don't provide a \"context\" for the current post/page being rendered.\n * So we should not use their ids as post context. This is important to allow post blocks\n * (post content, post title) to be used within them without issues.\n */\nconst NON_CONTEXTUAL_POST_TYPES = [\n\t'wp_block',\n\t'wp_navigation',\n\t'wp_template_part',\n];\n\n/**\n * Depending on the post, template and template mode,\n * returns the appropriate blocks and change handlers for the block editor provider.\n *\n * @param {Array} post Block list.\n * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.\n * @param {string} mode Rendering mode.\n *\n * @example\n * ```jsx\n * const [ blocks, onInput, onChange ] = useBlockEditorProps( post, template, mode );\n * ```\n *\n * @return {Array} Block editor props.\n */\nfunction useBlockEditorProps( post, template, mode ) {\n\tconst revisionBlocks = useRevisionBlocks();\n\tconst rootLevelPost = mode === 'template-locked' ? 'template' : 'post';\n\tconst [ postBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpost.type,\n\t\t{ id: post.id }\n\t);\n\tconst [ templateBlocks, onInputTemplate, onChangeTemplate ] =\n\t\tuseEntityBlockEditor( 'postType', template?.type, {\n\t\t\tid: template?.id,\n\t\t} );\n\tconst maybeNavigationBlocks = useMemo( () => {\n\t\tif ( post.type === 'wp_navigation' ) {\n\t\t\treturn [\n\t\t\t\tcreateBlock( 'core/navigation', {\n\t\t\t\t\tref: post.id,\n\t\t\t\t\t// As the parent editor is locked with `templateLock`, the template locking\n\t\t\t\t\t// must be explicitly \"unset\" on the block itself to allow the user to modify\n\t\t\t\t\t// the block's content.\n\t\t\t\t\ttemplateLock: false,\n\t\t\t\t} ),\n\t\t\t];\n\t\t}\n\t}, [ post.type, post.id ] );\n\n\t// It is important that we don't create a new instance of blocks on every change\n\t// We should only create a new instance if the blocks them selves change, not a dependency of them.\n\tconst blocks = useMemo( () => {\n\t\tif ( maybeNavigationBlocks ) {\n\t\t\treturn maybeNavigationBlocks;\n\t\t}\n\n\t\tif ( rootLevelPost === 'template' ) {\n\t\t\treturn templateBlocks;\n\t\t}\n\n\t\treturn postBlocks;\n\t}, [ maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks ] );\n\n\t// In revisions mode, use the revision blocks and disable editing.\n\tif ( revisionBlocks !== null ) {\n\t\treturn [ revisionBlocks, noop, noop ];\n\t}\n\n\t// Handle fallback to postBlocks outside of the above useMemo, to ensure\n\t// that constructed block templates that call `createBlock` are not generated\n\t// too frequently. This ensures that clientIds are stable.\n\tconst disableRootLevelChanges =\n\t\t( !! template && mode === 'template-locked' ) ||\n\t\tpost.type === 'wp_navigation';\n\tif ( disableRootLevelChanges ) {\n\t\treturn [ blocks, noop, noop ];\n\t}\n\n\treturn [\n\t\tblocks,\n\t\trootLevelPost === 'post' ? onInput : onInputTemplate,\n\t\trootLevelPost === 'post' ? onChange : onChangeTemplate,\n\t];\n}\n\n/**\n * This component provides the editor context and manages the state of the block editor.\n *\n * @param {Object} props The component props.\n * @param {Object} props.post The post object.\n * @param {Object} props.settings The editor settings.\n * @param {boolean} props.recovery Indicates if the editor is in recovery mode.\n * @param {Array} props.initialEdits The initial edits for the editor.\n * @param {Object} props.children The child components.\n * @param {Object} [props.BlockEditorProviderComponent] The block editor provider component to use. Defaults to ExperimentalBlockEditorProvider.\n * @param {Object} [props.__unstableTemplate] The template object.\n *\n * @example\n * ```jsx\n * <ExperimentalEditorProvider\n * post={ post }\n * settings={ settings }\n * recovery={ recovery }\n * initialEdits={ initialEdits }\n * __unstableTemplate={ template }\n * >\n * { children }\n * </ExperimentalEditorProvider>\n *\n * @return {Object} The rendered ExperimentalEditorProvider component.\n */\nexport const ExperimentalEditorProvider = withRegistryProvider(\n\t( {\n\t\tpost,\n\t\tsettings,\n\t\trecovery,\n\t\tinitialEdits,\n\t\tchildren,\n\t\tBlockEditorProviderComponent = ExperimentalBlockEditorProvider,\n\t\t__unstableTemplate: template,\n\t} ) => {\n\t\tconst hasTemplate = !! template;\n\t\tconst {\n\t\t\teditorSettings,\n\t\t\tselection,\n\t\t\tisReady,\n\t\t\tmode,\n\t\t\tdefaultMode,\n\t\t\tpostTypeEntities,\n\t\t\tisInRevisionsMode,\n\t\t\tcurrentRevisionId,\n\t\t} = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEditorSettings,\n\t\t\t\t\tgetRenderingMode,\n\t\t\t\t\t__unstableIsEditorReady,\n\t\t\t\t\tgetDefaultRenderingMode,\n\t\t\t\t\tisRevisionsMode: _isRevisionsMode,\n\t\t\t\t\tgetCurrentRevisionId: _getCurrentRevisionId,\n\t\t\t\t} = unlock( select( editorStore ) );\n\t\t\t\tconst { getEntitiesConfig, getEntityRecordEdits } =\n\t\t\t\t\tselect( coreStore );\n\n\t\t\t\tconst _mode = getRenderingMode();\n\t\t\t\tconst _defaultMode = getDefaultRenderingMode( post.type );\n\t\t\t\t/**\n\t\t\t\t * To avoid content \"flash\", wait until rendering mode has been resolved.\n\t\t\t\t * This is important for the initial render of the editor.\n\t\t\t\t *\n\t\t\t\t * - Wait for template to be resolved if the default mode is 'template-locked'.\n\t\t\t\t * - Wait for default mode to be resolved otherwise.\n\t\t\t\t */\n\t\t\t\tconst hasResolvedDefaultMode =\n\t\t\t\t\t_defaultMode === 'template-locked'\n\t\t\t\t\t\t? hasTemplate\n\t\t\t\t\t\t: _defaultMode !== undefined;\n\t\t\t\t// Wait until the default mode is retrieved and start rendering canvas.\n\t\t\t\tconst isRenderingModeReady = _defaultMode !== undefined;\n\n\t\t\t\t// Read selection directly from entity edits using the post prop,\n\t\t\t\t// bypassing getCurrentPostId() which lags behind in useEffect.\n\t\t\t\tconst entityEdits = getEntityRecordEdits(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpost.type,\n\t\t\t\t\tpost.id\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\teditorSettings: getEditorSettings(),\n\t\t\t\t\tisReady: __unstableIsEditorReady(),\n\t\t\t\t\tmode: isRenderingModeReady ? _mode : undefined,\n\t\t\t\t\tdefaultMode: hasResolvedDefaultMode\n\t\t\t\t\t\t? _defaultMode\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tselection: entityEdits?.selection,\n\t\t\t\t\tpostTypeEntities:\n\t\t\t\t\t\tpost.type === 'wp_template'\n\t\t\t\t\t\t\t? getEntitiesConfig( 'postType' )\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\tisInRevisionsMode: _isRevisionsMode(),\n\t\t\t\t\tcurrentRevisionId: _getCurrentRevisionId(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ post.type, post.id, hasTemplate ]\n\t\t);\n\n\t\tconst shouldRenderTemplate = hasTemplate && mode !== 'post-only';\n\t\tconst rootLevelPost = shouldRenderTemplate ? template : post;\n\t\tconst defaultBlockContext = useMemo( () => {\n\t\t\tconst postContext = {};\n\t\t\t// If it is a template, try to inherit the post type from the name.\n\t\t\tif ( post.type === 'wp_template' ) {\n\t\t\t\tif ( post.slug === 'page' ) {\n\t\t\t\t\tpostContext.postType = 'page';\n\t\t\t\t} else if ( post.slug === 'single' ) {\n\t\t\t\t\tpostContext.postType = 'post';\n\t\t\t\t} else if ( post.slug.split( '-' )[ 0 ] === 'single' ) {\n\t\t\t\t\t// If the slug is single-{postType}, infer the post type from the name.\n\t\t\t\t\tconst postTypeNames =\n\t\t\t\t\t\tpostTypeEntities?.map( ( entity ) => entity.name ) ||\n\t\t\t\t\t\t[];\n\t\t\t\t\tconst match = post.slug.match(\n\t\t\t\t\t\t`^single-(${ postTypeNames.join( '|' ) })(?:-.+)?$`\n\t\t\t\t\t);\n\t\t\t\t\tif ( match ) {\n\t\t\t\t\t\tpostContext.postType = match[ 1 ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t! NON_CONTEXTUAL_POST_TYPES.includes( rootLevelPost.type ) ||\n\t\t\t\tshouldRenderTemplate\n\t\t\t) {\n\t\t\t\tpostContext.postId = post.id;\n\t\t\t\tpostContext.postType = post.type;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...postContext,\n\t\t\t\ttemplateSlug:\n\t\t\t\t\trootLevelPost.type === 'wp_template'\n\t\t\t\t\t\t? rootLevelPost.slug\n\t\t\t\t\t\t: undefined,\n\t\t\t};\n\t\t}, [\n\t\t\tshouldRenderTemplate,\n\t\t\tpost.id,\n\t\t\tpost.type,\n\t\t\tpost.slug,\n\t\t\trootLevelPost.type,\n\t\t\trootLevelPost.slug,\n\t\t\tpostTypeEntities,\n\t\t] );\n\t\tconst { id, type } = rootLevelPost;\n\t\tconst blockEditorSettings = useBlockEditorSettings(\n\t\t\teditorSettings,\n\t\t\ttype,\n\t\t\tid,\n\t\t\tmode\n\t\t);\n\t\tconst [ blocks, onInput, onChange ] = useBlockEditorProps(\n\t\t\tpost,\n\t\t\ttemplate,\n\t\t\tmode\n\t\t);\n\n\t\tconst {\n\t\t\tupdatePostLock,\n\t\t\tsetupEditor,\n\t\t\tupdateEditorSettings,\n\t\t\tsetCurrentTemplateId,\n\t\t\tsetEditedPost,\n\t\t\tsetRenderingMode,\n\t\t} = unlock( useDispatch( editorStore ) );\n\t\tconst { editEntityRecord } = useDispatch( coreStore );\n\t\tconst registry = useRegistry();\n\n\t\tconst onChangeSelection = useCallback(\n\t\t\t( newSelection ) => {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpost.type,\n\t\t\t\t\tpost.id,\n\t\t\t\t\t{ selection: newSelection },\n\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ editEntityRecord, post.type, post.id ]\n\t\t);\n\t\tconst { createWarningNotice, removeNotice } =\n\t\t\tuseDispatch( noticesStore );\n\n\t\t// Ideally this should be synced on each change and not just something you do once.\n\t\tuseLayoutEffect( () => {\n\t\t\t// Assume that we don't need to initialize in the case of an error recovery.\n\t\t\tif ( recovery ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdatePostLock( settings.postLock );\n\t\t\t// `setupEditor` may already have been dispatched by the\n\t\t\t// editor's pre-mount kickoff (see edit-post's\n\t\t\t// `initializeEditor`). Skip the redundant dispatch \u2014 it\n\t\t\t// would otherwise re-parse + reset blocks for new posts.\n\t\t\tif ( ! registry.select( editorStore ).__unstableIsEditorReady() ) {\n\t\t\t\tsetupEditor( post, initialEdits, settings.template );\n\t\t\t}\n\t\t\tif ( settings.autosave ) {\n\t\t\t\tcreateWarningNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'There is an autosave of this post that is more recent than the version below.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: 'autosave-exists',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View the autosave' ),\n\t\t\t\t\t\t\t\turl: settings.autosave.editLink,\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);\n\t\t\t}\n\n\t\t\t// The dependencies of the hook are omitted deliberately\n\t\t\t// We only want to run setupEditor (with initialEdits) only once per post.\n\t\t\t// A better solution in the future would be to split this effect into multiple ones.\n\t\t}, [] );\n\n\t\t// Synchronizes the active post with the state\n\t\tuseEffect( () => {\n\t\t\tsetEditedPost( post.type, post.id );\n\t\t\tif (\n\t\t\t\ttypeof window !== 'undefined' &&\n\t\t\t\twindow.__experimentalTemplateActivate\n\t\t\t) {\n\t\t\t\t// Clear any notices dependent on the post context.\n\t\t\t\tremoveNotice( 'template-activate-notice' );\n\t\t\t}\n\n\t\t\treturn () => setEditedPost( null, null );\n\t\t}, [ post.type, post.id, setEditedPost, removeNotice ] );\n\n\t\t// Synchronize the editor settings as they change.\n\t\tuseEffect( () => {\n\t\t\tupdateEditorSettings( settings );\n\t\t}, [ settings, updateEditorSettings ] );\n\n\t\t// Synchronizes the active template with the state.\n\t\tuseEffect( () => {\n\t\t\tsetCurrentTemplateId( template?.id );\n\t\t}, [ template?.id, setCurrentTemplateId ] );\n\n\t\t// Sets the right rendering mode when loading the editor.\n\t\tuseEffect( () => {\n\t\t\tif ( defaultMode ) {\n\t\t\t\tsetRenderingMode( defaultMode );\n\t\t\t}\n\t\t}, [ defaultMode, setRenderingMode ] );\n\n\t\tuseHideBlocksFromInserter( post.type, mode );\n\n\t\t// Register the editor commands.\n\t\tuseCommands();\n\n\t\t// Lock post saving when media uploads are in progress (experimental feature).\n\t\tuseUploadSaveLock();\n\n\t\t// Pause/resume media upload queue on network disconnect/reconnect.\n\t\tuseNetworkReconnect();\n\n\t\tif ( ! isReady || ! mode ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ post.type }\n\t\t\t\t\tid={ post.id }\n\t\t\t\t\trevisionId={ currentRevisionId ?? undefined }\n\t\t\t\t>\n\t\t\t\t\t<BlockContextProvider value={ defaultBlockContext }>\n\t\t\t\t\t\t<BlockEditorProviderComponent\n\t\t\t\t\t\t\tvalue={ blocks }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tonInput={ onInput }\n\t\t\t\t\t\t\tselection={\n\t\t\t\t\t\t\t\tisInRevisionsMode ? undefined : selection\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonChangeSelection={\n\t\t\t\t\t\t\t\tisInRevisionsMode ? noop : onChangeSelection\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsettings={ blockEditorSettings }\n\t\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t{ ! settings.isPreviewMode && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<PatternsMenuItems />\n\t\t\t\t\t\t\t\t\t<TemplatePartMenuItems />\n\t\t\t\t\t\t\t\t\t{ mode === 'template-locked' && (\n\t\t\t\t\t\t\t\t\t\t<DisableNonPageContentBlocks />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ type === 'wp_navigation' && (\n\t\t\t\t\t\t\t\t\t\t<NavigationBlockEditingMode />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<EditorKeyboardShortcuts />\n\t\t\t\t\t\t\t\t\t<KeyboardShortcutHelpModal />\n\t\t\t\t\t\t\t\t\t<BlockRemovalWarnings />\n\t\t\t\t\t\t\t\t\t<StartPageOptions />\n\t\t\t\t\t\t\t\t\t<StartTemplateOptions />\n\t\t\t\t\t\t\t\t\t<PatternRenameModal />\n\t\t\t\t\t\t\t\t\t<PatternDuplicateModal />\n\t\t\t\t\t\t\t\t\t<MediaEditorModalMount />\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</BlockEditorProviderComponent>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t);\n\t}\n);\n\n/**\n * This component establishes a new post editing context, and serves as the entry point for a new post editor (or post with template editor).\n *\n * It supports a large number of post types, including post, page, templates,\n * custom post types, patterns, template parts.\n *\n * All modification and changes are performed to the `@wordpress/core-data` store.\n *\n * @param {Object} props The component props.\n * @param {Object} [props.post] The post object to edit. This is required.\n * @param {Object} [props.__unstableTemplate] The template object wrapper the edited post.\n * This is optional and can only be used when the post type supports templates (like posts and pages).\n * @param {Object} [props.settings] The settings object to use for the editor.\n * This is optional and can be used to override the default settings.\n * @param {React.ReactNode} [props.children] Children elements for which the BlockEditorProvider context should apply.\n * This is optional.\n *\n * @example\n * ```jsx\n * <EditorProvider\n * post={ post }\n * settings={ settings }\n * __unstableTemplate={ template }\n * >\n * { children }\n * </EditorProvider>\n * ```\n *\n * @return {React.ReactNode} The rendered EditorProvider component.\n */\nexport function EditorProvider( props ) {\n\treturn (\n\t\t<ExperimentalEditorProvider\n\t\t\t{ ...props }\n\t\t\tBlockEditorProviderComponent={ BlockEditorProvider }\n\t\t>\n\t\t\t{ props.children }\n\t\t</ExperimentalEditorProvider>\n\t);\n}\n\nexport default EditorProvider;\n"],
5
+ "mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa,WAAW,mBAAmB;AACpD,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,SAAS,oBAAoB;AACtC,SAAS,eAAe,+BAA+B;AACvD,SAAS,mBAAmB;AAK5B,OAAO,0BAA0B;AACjC,SAAS,SAAS,mBAAmB;AACrC,OAAO,4BAA4B;AACnC,SAAS,cAAc;AACvB,OAAO,iCAAiC;AACxC,OAAO,gCAAgC;AACvC,SAAS,iCAAiC;AAC1C,SAAS,yBAAyB;AAClC,OAAO,iBAAiB;AACxB,OAAO,uBAAuB;AAC9B,OAAO,yBAAyB;AAChC,OAAO,0BAA0B;AACjC,OAAO,sBAAsB;AAC7B,OAAO,+BAA+B;AACtC,OAAO,0BAA0B;AACjC,OAAO,6BAA6B;AACpC,OAAO,wBAAwB;AAC/B,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAsY1B,mBACC,KADD;AApYR,IAAM,EAAE,gCAAgC,IAAI,OAAQ,sBAAuB;AAC3E,IAAM,EAAE,kBAAkB,IAAI,OAAQ,uBAAwB;AAE9D,IAAM,OAAO,MAAM;AAAC;AAQpB,IAAM,4BAA4B;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AACD;AAiBA,SAAS,oBAAqB,MAAM,UAAU,MAAO;AACpD,QAAM,iBAAiB,kBAAkB;AACzC,QAA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AAK;AAAA,QACZ,IAAK,KAAK;AAAA,QACV,YAAa,qBAAqB;AAAA,QAElC,8BAAC,wBAAqB,OAAQ,qBAC7B;AAAA,UAAC;AAAA;AAAA,YACA,OAAQ;AAAA,YACR;AAAA,YACA;AAAA,YACA,WACC,oBAAoB,SAAY;AAAA,YAEjC,mBACC,oBAAoB,OAAO;AAAA,YAE5B,UAAW;AAAA,YACX,gBAAiB;AAAA,YAEf;AAAA;AAAA,cACA,CAAE,SAAS,iBACZ,iCACC;AAAA,oCAAC,qBAAkB;AAAA,gBACnB,oBAAC,yBAAsB;AAAA,gBACrB,SAAS,qBACV,oBAAC,+BAA4B;AAAA,gBAE5B,SAAS,mBACV,oBAAC,8BAA2B;AAAA,gBAE7B,oBAAC,2BAAwB;AAAA,gBACzB,oBAAC,6BAA0B;AAAA,gBAC3B,oBAAC,wBAAqB;AAAA,gBACtB,oBAAC,oBAAiB;AAAA,gBAClB,oBAAC,wBAAqB;AAAA,gBACtB,oBAAC,sBAAmB;AAAA,gBACpB,oBAAC,yBAAsB;AAAA,gBACvB,oBAAC,yBAAsB;AAAA,iBACxB;AAAA;AAAA;AAAA,QAEF,GACD;AAAA;AAAA,IACD,GACD;AAAA,EAEF;AACD;AAgCO,SAAS,eAAgB,OAAQ;AACvC,SACC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACL,8BAA+B;AAAA,MAE7B,gBAAM;AAAA;AAAA,EACT;AAEF;AAEA,IAAO,mBAAQ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,30 @@
1
+ // packages/editor/src/components/provider/use-network-reconnect.js
2
+ import { useEffect } from "@wordpress/element";
3
+ import { useRegistry } from "@wordpress/data";
4
+ import { store as uploadStore } from "@wordpress/upload-media";
5
+ import { unlock } from "../../lock-unlock.mjs";
6
+ function useNetworkReconnect() {
7
+ const isEnabled = window.__clientSideMediaProcessing;
8
+ const registry = useRegistry();
9
+ useEffect(() => {
10
+ if (!isEnabled) {
11
+ return;
12
+ }
13
+ const handleOffline = () => {
14
+ unlock(registry.dispatch(uploadStore)).pauseQueue();
15
+ };
16
+ const handleOnline = () => {
17
+ unlock(registry.dispatch(uploadStore)).resumeQueue();
18
+ };
19
+ window.addEventListener("offline", handleOffline);
20
+ window.addEventListener("online", handleOnline);
21
+ return () => {
22
+ window.removeEventListener("offline", handleOffline);
23
+ window.removeEventListener("online", handleOnline);
24
+ };
25
+ }, [isEnabled, registry]);
26
+ }
27
+ export {
28
+ useNetworkReconnect as default
29
+ };
30
+ //# sourceMappingURL=use-network-reconnect.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/provider/use-network-reconnect.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useRegistry } from '@wordpress/data';\nimport { store as uploadStore } from '@wordpress/upload-media';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\n/**\n * A hook that pauses the media upload queue when the browser goes offline\n * and resumes it when connectivity is restored.\n *\n * Only active when client-side media processing is enabled.\n */\nexport default function useNetworkReconnect() {\n\tconst isEnabled = window.__clientSideMediaProcessing;\n\tconst registry = useRegistry();\n\n\tuseEffect( () => {\n\t\tif ( ! isEnabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst handleOffline = () => {\n\t\t\tunlock( registry.dispatch( uploadStore ) ).pauseQueue();\n\t\t};\n\n\t\tconst handleOnline = () => {\n\t\t\tunlock( registry.dispatch( uploadStore ) ).resumeQueue();\n\t\t};\n\n\t\twindow.addEventListener( 'offline', handleOffline );\n\t\twindow.addEventListener( 'online', handleOnline );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( 'offline', handleOffline );\n\t\t\twindow.removeEventListener( 'online', handleOnline );\n\t\t};\n\t}, [ isEnabled, registry ] );\n}\n"],
5
+ "mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,SAAS,mBAAmB;AAKrC,SAAS,cAAc;AAQR,SAAR,sBAAuC;AAC7C,QAAM,YAAY,OAAO;AACzB,QAAM,WAAW,YAAY;AAE7B,YAAW,MAAM;AAChB,QAAK,CAAE,WAAY;AAClB;AAAA,IACD;AAEA,UAAM,gBAAgB,MAAM;AAC3B,aAAQ,SAAS,SAAU,WAAY,CAAE,EAAE,WAAW;AAAA,IACvD;AAEA,UAAM,eAAe,MAAM;AAC1B,aAAQ,SAAS,SAAU,WAAY,CAAE,EAAE,YAAY;AAAA,IACxD;AAEA,WAAO,iBAAkB,WAAW,aAAc;AAClD,WAAO,iBAAkB,UAAU,YAAa;AAEhD,WAAO,MAAM;AACZ,aAAO,oBAAqB,WAAW,aAAc;AACrD,aAAO,oBAAqB,UAAU,YAAa;AAAA,IACpD;AAAA,EACD,GAAG,CAAE,WAAW,QAAS,CAAE;AAC5B;",
6
+ "names": []
7
+ }
@@ -1,5 +1,5 @@
1
1
  // packages/editor/src/components/revision-fields-diff/index.js
2
- import { diffWords } from "diff/lib/diff/word";
2
+ import { diffWordsWithSpace } from "diff";
3
3
  import { useSelect } from "@wordpress/data";
4
4
  import { useMemo } from "@wordpress/element";
5
5
  import { __ } from "@wordpress/i18n";
@@ -43,7 +43,7 @@ function RevisionFieldsDiffPanel() {
43
43
  if (!revStr && !prevStr) {
44
44
  continue;
45
45
  }
46
- result[key] = diffWords(prevStr, revStr);
46
+ result[key] = diffWordsWithSpace(prevStr, revStr);
47
47
  }
48
48
  if (Object.keys(result).length === 0) {
49
49
  return null;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/revision-fields-diff/index.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport { diffWords } from 'diff/lib/diff/word';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport RevisionDiffPanel from '../revision-diff-panel';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Safely stringifies a value for display and comparison.\n *\n * @param {*} value The value to stringify.\n * @return {string} The stringified value.\n */\nfunction stringifyValue( value ) {\n\tif ( value === null || value === undefined ) {\n\t\treturn '';\n\t}\n\tif ( typeof value === 'object' ) {\n\t\treturn JSON.stringify( value, null, 2 );\n\t}\n\treturn String( value );\n}\n\n/**\n * Panel that shows meta field diffs between the current revision and\n * the previous revision in the document sidebar during revision mode.\n */\nexport default function RevisionFieldsDiffPanel() {\n\tconst { revision, previousRevision } = useSelect( ( select ) => {\n\t\tconst { getCurrentRevision, getPreviousRevision } = unlock(\n\t\t\tselect( editorStore )\n\t\t);\n\n\t\treturn {\n\t\t\trevision: getCurrentRevision(),\n\t\t\tpreviousRevision: getPreviousRevision(),\n\t\t};\n\t}, [] );\n\n\tconst entries = useMemo( () => {\n\t\tif ( ! revision ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst revisionMeta = revision.meta ?? {};\n\t\tconst previousMeta = previousRevision?.meta ?? {};\n\t\tconst allMetaKeys = new Set( [\n\t\t\t...Object.keys( revisionMeta ),\n\t\t\t...Object.keys( previousMeta ),\n\t\t] );\n\n\t\tconst result = {};\n\n\t\tfor ( const key of allMetaKeys ) {\n\t\t\tconst revStr = stringifyValue( revisionMeta[ key ] );\n\t\t\tconst prevStr = stringifyValue( previousMeta[ key ] );\n\n\t\t\tif ( ! revStr && ! prevStr ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tresult[ key ] = diffWords( prevStr, revStr );\n\t\t}\n\n\t\tif ( Object.keys( result ).length === 0 ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn result;\n\t}, [ revision, previousRevision ] );\n\n\treturn (\n\t\t<RevisionDiffPanel\n\t\t\ttitle={ __( 'Meta' ) }\n\t\t\tentries={ entries }\n\t\t\tinitialOpen={ false }\n\t\t/>\n\t);\n}\n"],
5
- "mappings": ";AAGA,SAAS,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AAG,CAAE,UAAU,gBAAiB,CAAE;AAElC,SACC;AAAA,IAAC;AAAA;AAAA,MACA,OAAQ,GAAI,MAAO;AAAA,MACnB;AAAA,MACA,aAAc;AAAA;AAAA,EACf;AAEF;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\n/*\n * `diffWordsWithSpace` preserves the v4-style per-word output. v6+\n * stopped treating whitespace as a token in `diffWords`, which coalesces\n * adjacent word changes into a single removed/added pair.\n */\nimport { diffWordsWithSpace } from 'diff';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport RevisionDiffPanel from '../revision-diff-panel';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Safely stringifies a value for display and comparison.\n *\n * @param {*} value The value to stringify.\n * @return {string} The stringified value.\n */\nfunction stringifyValue( value ) {\n\tif ( value === null || value === undefined ) {\n\t\treturn '';\n\t}\n\tif ( typeof value === 'object' ) {\n\t\treturn JSON.stringify( value, null, 2 );\n\t}\n\treturn String( value );\n}\n\n/**\n * Panel that shows meta field diffs between the current revision and\n * the previous revision in the document sidebar during revision mode.\n */\nexport default function RevisionFieldsDiffPanel() {\n\tconst { revision, previousRevision } = useSelect( ( select ) => {\n\t\tconst { getCurrentRevision, getPreviousRevision } = unlock(\n\t\t\tselect( editorStore )\n\t\t);\n\n\t\treturn {\n\t\t\trevision: getCurrentRevision(),\n\t\t\tpreviousRevision: getPreviousRevision(),\n\t\t};\n\t}, [] );\n\n\tconst entries = useMemo( () => {\n\t\tif ( ! revision ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst revisionMeta = revision.meta ?? {};\n\t\tconst previousMeta = previousRevision?.meta ?? {};\n\t\tconst allMetaKeys = new Set( [\n\t\t\t...Object.keys( revisionMeta ),\n\t\t\t...Object.keys( previousMeta ),\n\t\t] );\n\n\t\tconst result = {};\n\n\t\tfor ( const key of allMetaKeys ) {\n\t\t\tconst revStr = stringifyValue( revisionMeta[ key ] );\n\t\t\tconst prevStr = stringifyValue( previousMeta[ key ] );\n\n\t\t\tif ( ! revStr && ! prevStr ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tresult[ key ] = diffWordsWithSpace( prevStr, revStr );\n\t\t}\n\n\t\tif ( Object.keys( result ).length === 0 ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn result;\n\t}, [ revision, previousRevision ] );\n\n\treturn (\n\t\t<RevisionDiffPanel\n\t\t\ttitle={ __( 'Meta' ) }\n\t\t\tentries={ entries }\n\t\t\tinitialOpen={ false }\n\t\t/>\n\t);\n}\n"],
5
+ "mappings": ";AAQA,SAAS,0BAA0B;AAKnC,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,UAAU;AAKnB,OAAO,uBAAuB;AAC9B,SAAS,SAAS,mBAAmB;AACrC,SAAS,cAAc;AAmErB;AA3DF,SAAS,eAAgB,OAAQ;AAChC,MAAK,UAAU,QAAQ,UAAU,QAAY;AAC5C,WAAO;AAAA,EACR;AACA,MAAK,OAAO,UAAU,UAAW;AAChC,WAAO,KAAK,UAAW,OAAO,MAAM,CAAE;AAAA,EACvC;AACA,SAAO,OAAQ,KAAM;AACtB;AAMe,SAAR,0BAA2C;AACjD,QAAM,EAAE,UAAU,iBAAiB,IAAI,UAAW,CAAE,WAAY;AAC/D,UAAM,EAAE,oBAAoB,oBAAoB,IAAI;AAAA,MACnD,OAAQ,WAAY;AAAA,IACrB;AAEA,WAAO;AAAA,MACN,UAAU,mBAAmB;AAAA,MAC7B,kBAAkB,oBAAoB;AAAA,IACvC;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,UAAU,QAAS,MAAM;AAC9B,QAAK,CAAE,UAAW;AACjB,aAAO;AAAA,IACR;AAEA,UAAM,eAAe,SAAS,QAAQ,CAAC;AACvC,UAAM,eAAe,kBAAkB,QAAQ,CAAC;AAChD,UAAM,cAAc,oBAAI,IAAK;AAAA,MAC5B,GAAG,OAAO,KAAM,YAAa;AAAA,MAC7B,GAAG,OAAO,KAAM,YAAa;AAAA,IAC9B,CAAE;AAEF,UAAM,SAAS,CAAC;AAEhB,eAAY,OAAO,aAAc;AAChC,YAAM,SAAS,eAAgB,aAAc,GAAI,CAAE;AACnD,YAAM,UAAU,eAAgB,aAAc,GAAI,CAAE;AAEpD,UAAK,CAAE,UAAU,CAAE,SAAU;AAC5B;AAAA,MACD;AAEA,aAAQ,GAAI,IAAI,mBAAoB,SAAS,MAAO;AAAA,IACrD;AAEA,QAAK,OAAO,KAAM,MAAO,EAAE,WAAW,GAAI;AACzC,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EACR,GAAG,CAAE,UAAU,gBAAiB,CAAE;AAElC,SACC;AAAA,IAAC;AAAA;AAAA,MACA,OAAQ,GAAI,MAAO;AAAA,MACnB;AAAA,MACA,aAAc;AAAA;AAAA,EACf;AAEF;",
6
6
  "names": []
7
7
  }
@@ -4,13 +4,7 @@ import {
4
4
  store as blockEditorStore
5
5
  } from "@wordpress/block-editor";
6
6
  import { useSelect, useDispatch } from "@wordpress/data";
7
- import {
8
- Platform,
9
- useCallback,
10
- useContext,
11
- useEffect,
12
- useRef
13
- } from "@wordpress/element";
7
+ import { useCallback, useContext, useEffect, useRef } from "@wordpress/element";
14
8
  import { isRTL, __, _x } from "@wordpress/i18n";
15
9
  import { drawerLeft, drawerRight } from "@wordpress/icons";
16
10
  import { store as keyboardShortcutsStore } from "@wordpress/keyboard-shortcuts";
@@ -40,10 +34,7 @@ import {
40
34
  } from "../../store/constants.mjs";
41
35
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
42
36
  var { Tabs } = unlock(componentsPrivateApis);
43
- var SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select({
44
- web: true,
45
- native: false
46
- });
37
+ var SIDEBAR_ACTIVE_BY_DEFAULT = true;
47
38
  var SidebarContent = ({
48
39
  tabName,
49
40
  keyboardShortcut,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/sidebar/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tPlatform,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseRef,\n} from '@wordpress/element';\nimport { isRTL, __, _x } from '@wordpress/i18n';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PatternOverridesPanel from '../pattern-overrides-panel';\nimport PluginDocumentSettingPanel from '../plugin-document-setting-panel';\nimport PluginSidebar from '../plugin-sidebar';\nimport PostSummary from './post-summary';\nimport PostRevisionSummary from './post-revision-summary';\nimport PostTaxonomiesPanel from '../post-taxonomies/panel';\nimport PostTransformPanel from '../post-transform-panel';\nimport SidebarHeader from './header';\nimport TemplateActionsPanel from '../template-actions-panel';\nimport TemplateContentPanel from '../template-content-panel';\nimport TemplatePartContentPanel from '../template-part-content-panel';\nimport PostRevisionsPanel from '../post-revisions-panel';\nimport RevisionBlockDiffPanel from '../revision-block-diff';\nimport useAutoSwitchEditorSidebars from '../provider/use-auto-switch-editor-sidebars';\nimport { sidebars } from './constants';\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\nimport {\n\tNAVIGATION_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tTEMPLATE_POST_TYPE,\n} from '../../store/constants';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {\n\tweb: true,\n\tnative: false,\n} );\n\nconst SidebarContent = ( {\n\ttabName,\n\tkeyboardShortcut,\n\tonActionPerformed,\n\textraPanels,\n\tpostType,\n} ) => {\n\tconst tabListRef = useRef( null );\n\t// Because `PluginSidebar` renders a `ComplementaryArea`, we\n\t// need to forward the `Tabs` context so it can be passed through the\n\t// underlying slot/fill.\n\tconst tabsContextValue = useContext( Tabs.Context );\n\tconst isRevisionsMode = useSelect( ( select ) => {\n\t\treturn unlock( select( editorStore ) ).isRevisionsMode();\n\t} );\n\n\t// This effect addresses a race condition caused by tabbing from the last\n\t// block in the editor into the settings sidebar. Without this effect, the\n\t// selected tab and browser focus can become separated in an unexpected way\n\t// (e.g the \"block\" tab is focused, but the \"post\" tab is selected).\n\tuseEffect( () => {\n\t\tconst tabsElements = Array.from(\n\t\t\ttabListRef.current?.querySelectorAll( '[role=\"tab\"]' ) || []\n\t\t);\n\t\tconst selectedTabElement = tabsElements.find(\n\t\t\t// We are purposefully using a custom `data-tab-id` attribute here\n\t\t\t// because we don't want rely on any assumptions about `Tabs`\n\t\t\t// component internals.\n\t\t\t( element ) => element.getAttribute( 'data-tab-id' ) === tabName\n\t\t);\n\t\tconst activeElement = selectedTabElement?.ownerDocument.activeElement;\n\t\tconst tabsHasFocus = tabsElements.some( ( element ) => {\n\t\t\treturn activeElement && activeElement.id === element.id;\n\t\t} );\n\t\tif (\n\t\t\ttabsHasFocus &&\n\t\t\tselectedTabElement &&\n\t\t\tselectedTabElement.id !== activeElement?.id\n\t\t) {\n\t\t\tselectedTabElement?.focus();\n\t\t}\n\t}, [ tabName ] );\n\n\tlet tabContent;\n\tif ( isRevisionsMode ) {\n\t\ttabContent = <PostRevisionSummary />;\n\t} else {\n\t\ttabContent = (\n\t\t\t<>\n\t\t\t\t<PostSummary onActionPerformed={ onActionPerformed } />\n\t\t\t\t<PluginDocumentSettingPanel.Slot />\n\t\t\t\t<TemplateContentPanel />\n\t\t\t\t{ window?.__experimentalDataFormInspector &&\n\t\t\t\t\t[\n\t\t\t\t\t\t'post',\n\t\t\t\t\t\t'page',\n\t\t\t\t\t\t'wp_template',\n\t\t\t\t\t\t'wp_template_part',\n\t\t\t\t\t\t'wp_block',\n\t\t\t\t\t].includes( postType ) && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<TemplateActionsPanel />\n\t\t\t\t\t\t\t<PostRevisionsPanel />\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t<TemplatePartContentPanel />\n\t\t\t\t<PostTransformPanel />\n\t\t\t\t<PostTaxonomiesPanel />\n\t\t\t\t<PatternOverridesPanel />\n\t\t\t\t{ extraPanels }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<PluginSidebar\n\t\t\tidentifier={ tabName }\n\t\t\theader={\n\t\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<SidebarHeader ref={ tabListRef } />\n\t\t\t\t</Tabs.Context.Provider>\n\t\t\t}\n\t\t\tcloseLabel={ __( 'Close Settings' ) }\n\t\t\t// This classname is added so we can apply a corrective negative\n\t\t\t// margin to the panel.\n\t\t\t// see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049\n\t\t\tclassName=\"editor-sidebar__panel\"\n\t\t\theaderClassName=\"editor-sidebar__panel-tabs\"\n\t\t\ttitle={\n\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t_x( 'Settings', 'panel button label' )\n\t\t\t}\n\t\t\ttoggleShortcut={ keyboardShortcut }\n\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t<Tabs.TabPanel tabId={ sidebars.document } focusable={ false }>\n\t\t\t\t\t{ tabContent }\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t<Tabs.TabPanel tabId={ sidebars.block } focusable={ false }>\n\t\t\t\t\t<BlockInspector />\n\t\t\t\t\t{ isRevisionsMode && <RevisionBlockDiffPanel /> }\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t</Tabs.Context.Provider>\n\t\t</PluginSidebar>\n\t);\n};\n\nconst Sidebar = ( { extraPanels, onActionPerformed } ) => {\n\tuseAutoSwitchEditorSidebars();\n\tconst { tabName, keyboardShortcut, showSummary, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst shortcut = select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/editor/toggle-sidebar' );\n\n\t\t\tconst sidebar =\n\t\t\t\tselect( interfaceStore ).getActiveComplementaryArea( 'core' );\n\t\t\tconst _isEditorSidebarOpened = [\n\t\t\t\tsidebars.block,\n\t\t\t\tsidebars.document,\n\t\t\t].includes( sidebar );\n\t\t\tlet _tabName = sidebar;\n\t\t\tif ( ! _isEditorSidebarOpened ) {\n\t\t\t\t_tabName = !! select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).getBlockSelectionStart()\n\t\t\t\t\t? sidebars.block\n\t\t\t\t\t: sidebars.document;\n\t\t\t}\n\n\t\t\tconst _postType = select( editorStore ).getCurrentPostType();\n\n\t\t\treturn {\n\t\t\t\ttabName: _tabName,\n\t\t\t\tkeyboardShortcut: shortcut,\n\t\t\t\tshowSummary: ! [\n\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t\t\tNAVIGATION_POST_TYPE,\n\t\t\t\t].includes( _postType ),\n\t\t\t\tpostType: _postType,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tconst onTabSelect = useCallback(\n\t\t( newSelectedTabId ) => {\n\t\t\tif ( !! newSelectedTabId ) {\n\t\t\t\tenableComplementaryArea( 'core', newSelectedTabId );\n\t\t\t}\n\t\t},\n\t\t[ enableComplementaryArea ]\n\t);\n\n\treturn (\n\t\t<Tabs\n\t\t\tselectedTabId={ tabName }\n\t\t\tonSelect={ onTabSelect }\n\t\t\tselectOnMove={ false }\n\t\t>\n\t\t\t<SidebarContent\n\t\t\t\ttabName={ tabName }\n\t\t\t\tkeyboardShortcut={ keyboardShortcut }\n\t\t\t\tshowSummary={ showSummary }\n\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\textraPanels={ extraPanels }\n\t\t\t\tpostType={ postType }\n\t\t\t/>\n\t\t</Tabs>\n\t);\n};\n\nexport default Sidebar;\n"],
5
- "mappings": ";AAGA;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,WAAW,mBAAmB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,OAAO,IAAI,UAAU;AAC9B,SAAS,YAAY,mBAAmB;AACxC,SAAS,SAAS,8BAA8B;AAChD,SAAS,eAAe,6BAA6B;AACrD,SAAS,SAAS,sBAAsB;AAKxC,OAAO,2BAA2B;AAClC,OAAO,gCAAgC;AACvC,OAAO,mBAAmB;AAC1B,OAAO,iBAAiB;AACxB,OAAO,yBAAyB;AAChC,OAAO,yBAAyB;AAChC,OAAO,wBAAwB;AAC/B,OAAO,mBAAmB;AAC1B,OAAO,0BAA0B;AACjC,OAAO,0BAA0B;AACjC,OAAO,8BAA8B;AACrC,OAAO,wBAAwB;AAC/B,OAAO,4BAA4B;AACnC,OAAO,iCAAiC;AACxC,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,SAAS,mBAAmB;AACrC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAsDQ,SAeT,UAfS,KAeT,YAfS;AApDf,IAAM,EAAE,KAAK,IAAI,OAAQ,qBAAsB;AAE/C,IAAM,4BAA4B,SAAS,OAAQ;AAAA,EAClD,KAAK;AAAA,EACL,QAAQ;AACT,CAAE;AAEF,IAAM,iBAAiB,CAAE;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,MAAO;AACN,QAAM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U,SAAU;AAAA,QACtB,UAAU;AAAA,MACX;AAAA,IACD;AAAA,IACA,CAAC;AAAA,EACF;AAEA,QAAM,EAAE,wBAAwB,IAAI,YAAa,cAAe;AAEhE,QAAM,cAAc;AAAA,IACnB,CAAE,qBAAsB;AACvB,UAAK,CAAC,CAAE,kBAAmB;AAC1B,gCAAyB,QAAQ,gBAAiB;AAAA,MACnD;AAAA,IACD;AAAA,IACA,CAAE,uBAAwB;AAAA,EAC3B;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,eAAgB;AAAA,MAChB,UAAW;AAAA,MACX,cAAe;AAAA,MAEf;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;AAEA,IAAO,kBAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback, useContext, useEffect, useRef } from '@wordpress/element';\nimport { isRTL, __, _x } from '@wordpress/i18n';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PatternOverridesPanel from '../pattern-overrides-panel';\nimport PluginDocumentSettingPanel from '../plugin-document-setting-panel';\nimport PluginSidebar from '../plugin-sidebar';\nimport PostSummary from './post-summary';\nimport PostRevisionSummary from './post-revision-summary';\nimport PostTaxonomiesPanel from '../post-taxonomies/panel';\nimport PostTransformPanel from '../post-transform-panel';\nimport SidebarHeader from './header';\nimport TemplateActionsPanel from '../template-actions-panel';\nimport TemplateContentPanel from '../template-content-panel';\nimport TemplatePartContentPanel from '../template-part-content-panel';\nimport PostRevisionsPanel from '../post-revisions-panel';\nimport RevisionBlockDiffPanel from '../revision-block-diff';\nimport useAutoSwitchEditorSidebars from '../provider/use-auto-switch-editor-sidebars';\nimport { sidebars } from './constants';\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\nimport {\n\tNAVIGATION_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tTEMPLATE_POST_TYPE,\n} from '../../store/constants';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst SIDEBAR_ACTIVE_BY_DEFAULT = true;\n\nconst SidebarContent = ( {\n\ttabName,\n\tkeyboardShortcut,\n\tonActionPerformed,\n\textraPanels,\n\tpostType,\n} ) => {\n\tconst tabListRef = useRef( null );\n\t// Because `PluginSidebar` renders a `ComplementaryArea`, we\n\t// need to forward the `Tabs` context so it can be passed through the\n\t// underlying slot/fill.\n\tconst tabsContextValue = useContext( Tabs.Context );\n\tconst isRevisionsMode = useSelect( ( select ) => {\n\t\treturn unlock( select( editorStore ) ).isRevisionsMode();\n\t} );\n\n\t// This effect addresses a race condition caused by tabbing from the last\n\t// block in the editor into the settings sidebar. Without this effect, the\n\t// selected tab and browser focus can become separated in an unexpected way\n\t// (e.g the \"block\" tab is focused, but the \"post\" tab is selected).\n\tuseEffect( () => {\n\t\tconst tabsElements = Array.from(\n\t\t\ttabListRef.current?.querySelectorAll( '[role=\"tab\"]' ) || []\n\t\t);\n\t\tconst selectedTabElement = tabsElements.find(\n\t\t\t// We are purposefully using a custom `data-tab-id` attribute here\n\t\t\t// because we don't want rely on any assumptions about `Tabs`\n\t\t\t// component internals.\n\t\t\t( element ) => element.getAttribute( 'data-tab-id' ) === tabName\n\t\t);\n\t\tconst activeElement = selectedTabElement?.ownerDocument.activeElement;\n\t\tconst tabsHasFocus = tabsElements.some( ( element ) => {\n\t\t\treturn activeElement && activeElement.id === element.id;\n\t\t} );\n\t\tif (\n\t\t\ttabsHasFocus &&\n\t\t\tselectedTabElement &&\n\t\t\tselectedTabElement.id !== activeElement?.id\n\t\t) {\n\t\t\tselectedTabElement?.focus();\n\t\t}\n\t}, [ tabName ] );\n\n\tlet tabContent;\n\tif ( isRevisionsMode ) {\n\t\ttabContent = <PostRevisionSummary />;\n\t} else {\n\t\ttabContent = (\n\t\t\t<>\n\t\t\t\t<PostSummary onActionPerformed={ onActionPerformed } />\n\t\t\t\t<PluginDocumentSettingPanel.Slot />\n\t\t\t\t<TemplateContentPanel />\n\t\t\t\t{ window?.__experimentalDataFormInspector &&\n\t\t\t\t\t[\n\t\t\t\t\t\t'post',\n\t\t\t\t\t\t'page',\n\t\t\t\t\t\t'wp_template',\n\t\t\t\t\t\t'wp_template_part',\n\t\t\t\t\t\t'wp_block',\n\t\t\t\t\t].includes( postType ) && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<TemplateActionsPanel />\n\t\t\t\t\t\t\t<PostRevisionsPanel />\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t<TemplatePartContentPanel />\n\t\t\t\t<PostTransformPanel />\n\t\t\t\t<PostTaxonomiesPanel />\n\t\t\t\t<PatternOverridesPanel />\n\t\t\t\t{ extraPanels }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<PluginSidebar\n\t\t\tidentifier={ tabName }\n\t\t\theader={\n\t\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<SidebarHeader ref={ tabListRef } />\n\t\t\t\t</Tabs.Context.Provider>\n\t\t\t}\n\t\t\tcloseLabel={ __( 'Close Settings' ) }\n\t\t\t// This classname is added so we can apply a corrective negative\n\t\t\t// margin to the panel.\n\t\t\t// see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049\n\t\t\tclassName=\"editor-sidebar__panel\"\n\t\t\theaderClassName=\"editor-sidebar__panel-tabs\"\n\t\t\ttitle={\n\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t_x( 'Settings', 'panel button label' )\n\t\t\t}\n\t\t\ttoggleShortcut={ keyboardShortcut }\n\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t<Tabs.TabPanel tabId={ sidebars.document } focusable={ false }>\n\t\t\t\t\t{ tabContent }\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t<Tabs.TabPanel tabId={ sidebars.block } focusable={ false }>\n\t\t\t\t\t<BlockInspector />\n\t\t\t\t\t{ isRevisionsMode && <RevisionBlockDiffPanel /> }\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t</Tabs.Context.Provider>\n\t\t</PluginSidebar>\n\t);\n};\n\nconst Sidebar = ( { extraPanels, onActionPerformed } ) => {\n\tuseAutoSwitchEditorSidebars();\n\tconst { tabName, keyboardShortcut, showSummary, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst shortcut = select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/editor/toggle-sidebar' );\n\n\t\t\tconst sidebar =\n\t\t\t\tselect( interfaceStore ).getActiveComplementaryArea( 'core' );\n\t\t\tconst _isEditorSidebarOpened = [\n\t\t\t\tsidebars.block,\n\t\t\t\tsidebars.document,\n\t\t\t].includes( sidebar );\n\t\t\tlet _tabName = sidebar;\n\t\t\tif ( ! _isEditorSidebarOpened ) {\n\t\t\t\t_tabName = !! select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).getBlockSelectionStart()\n\t\t\t\t\t? sidebars.block\n\t\t\t\t\t: sidebars.document;\n\t\t\t}\n\n\t\t\tconst _postType = select( editorStore ).getCurrentPostType();\n\n\t\t\treturn {\n\t\t\t\ttabName: _tabName,\n\t\t\t\tkeyboardShortcut: shortcut,\n\t\t\t\tshowSummary: ! [\n\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t\t\tNAVIGATION_POST_TYPE,\n\t\t\t\t].includes( _postType ),\n\t\t\t\tpostType: _postType,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tconst onTabSelect = useCallback(\n\t\t( newSelectedTabId ) => {\n\t\t\tif ( !! newSelectedTabId ) {\n\t\t\t\tenableComplementaryArea( 'core', newSelectedTabId );\n\t\t\t}\n\t\t},\n\t\t[ enableComplementaryArea ]\n\t);\n\n\treturn (\n\t\t<Tabs\n\t\t\tselectedTabId={ tabName }\n\t\t\tonSelect={ onTabSelect }\n\t\t\tselectOnMove={ false }\n\t\t>\n\t\t\t<SidebarContent\n\t\t\t\ttabName={ tabName }\n\t\t\t\tkeyboardShortcut={ keyboardShortcut }\n\t\t\t\tshowSummary={ showSummary }\n\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\textraPanels={ extraPanels }\n\t\t\t\tpostType={ postType }\n\t\t\t/>\n\t\t</Tabs>\n\t);\n};\n\nexport default Sidebar;\n"],
5
+ "mappings": ";AAGA;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,WAAW,mBAAmB;AACvC,SAAS,aAAa,YAAY,WAAW,cAAc;AAC3D,SAAS,OAAO,IAAI,UAAU;AAC9B,SAAS,YAAY,mBAAmB;AACxC,SAAS,SAAS,8BAA8B;AAChD,SAAS,eAAe,6BAA6B;AACrD,SAAS,SAAS,sBAAsB;AAKxC,OAAO,2BAA2B;AAClC,OAAO,gCAAgC;AACvC,OAAO,mBAAmB;AAC1B,OAAO,iBAAiB;AACxB,OAAO,yBAAyB;AAChC,OAAO,yBAAyB;AAChC,OAAO,wBAAwB;AAC/B,OAAO,mBAAmB;AAC1B,OAAO,0BAA0B;AACjC,OAAO,0BAA0B;AACjC,OAAO,8BAA8B;AACrC,OAAO,wBAAwB;AAC/B,OAAO,4BAA4B;AACnC,OAAO,iCAAiC;AACxC,SAAS,gBAAgB;AACzB,SAAS,cAAc;A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,wBAAyB;AAC/B,mBAAW,CAAC,CAAE;AAAA,UACb;AAAA,QACD,EAAE,uBAAuB,IACtB,SAAS,QACT,SAAS;AAAA,MACb;AAEA,YAAM,YAAY,OAAQ,WAAY,EAAE,mBAAmB;AAE3D,aAAO;AAAA,QACN,SAAS;AAAA,QACT,kBAAkB;AAAA,QAClB,aAAa,CAAE;AAAA,UACd;AAAA,UACA;AAAA,UACA;AAAA,QACD,EAAE,SAAU,SAAU;AAAA,QACtB,UAAU;AAAA,MACX;AAAA,IACD;AAAA,IACA,CAAC;AAAA,EACF;AAEA,QAAM,EAAE,wBAAwB,IAAI,YAAa,cAAe;AAEhE,QAAM,cAAc;AAAA,IACnB,CAAE,qBAAsB;AACvB,UAAK,CAAC,CAAE,kBAAmB;AAC1B,gCAAyB,QAAQ,gBAAiB;AAAA,MACnD;AAAA,IACD;AAAA,IACA,CAAE,uBAAwB;AAAA,EAC3B;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,eAAgB;AAAA,MAChB,UAAW;AAAA,MACX,cAAe;AAAA,MAEf;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;AAEA,IAAO,kBAAQ;",
6
6
  "names": []
7
7
  }
@@ -15,6 +15,7 @@ import {
15
15
  import { useState } from "@wordpress/element";
16
16
  import { __, sprintf } from "@wordpress/i18n";
17
17
  import { decodeEntities } from "@wordpress/html-entities";
18
+ import { ENTER, SPACE } from "@wordpress/keycodes";
18
19
  import { store as noticesStore } from "@wordpress/notices";
19
20
  import { store as preferencesStore } from "@wordpress/preferences";
20
21
  import { Tooltip } from "@wordpress/ui";
@@ -101,7 +102,12 @@ function TemplateActionsPanelContent() {
101
102
  tabIndex: 0,
102
103
  "aria-label": tooltipText,
103
104
  onClick: () => setIsSwapModalOpen(true),
104
- onKeyPress: () => setIsSwapModalOpen(true),
105
+ onKeyDown: (event) => {
106
+ if (event.keyCode === ENTER || event.keyCode === SPACE) {
107
+ event.preventDefault();
108
+ setIsSwapModalOpen(true);
109
+ }
110
+ },
105
111
  children: previewContent
106
112
  }
107
113
  )
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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\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// eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.\nimport { Tooltip } from '@wordpress/ui';\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.Root>\n\t\t\t\t\t<Tooltip.Trigger\n\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclassName=\"editor-template-actions-panel__preview\"\n\t\t\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\t\t\ttabIndex={ 0 }\n\t\t\t\t\t\t\t\taria-label={ tooltipText }\n\t\t\t\t\t\t\t\tonClick={ () => setIsSwapModalOpen( true ) }\n\t\t\t\t\t\t\t\tonKeyPress={ () => setIsSwapModalOpen( true ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ previewContent }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<Tooltip.Popup>{ tooltipText }</Tooltip.Popup>\n\t\t\t\t</Tooltip.Root>\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,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP,SAAS,gBAAgB;AACzB,SAAS,IAAI,eAAe;AAC5B,SAAS,s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AAC,UACE;AAAA,wCACD;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,aAAI,YAAa;AAAA;AAAA,YACpB;AAAA,aAEF;AAAA,WACD;AAAA;AAAA,IACD;AAAA,IACE,qBACD;AAAA,MAAC;AAAA;AAAA,QACA,SAAU,MAAM,qBAAsB,KAAM;AAAA;AAAA,IAC7C;AAAA,IAEC,mBACD;AAAA,MAAC;AAAA;AAAA,QACA,gBAAiB,MAAM,mBAAoB,KAAM;AAAA;AAAA,IAClD;AAAA,KAEF;AAEF;",
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__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 { ENTER, SPACE } from '@wordpress/keycodes';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as preferencesStore } from '@wordpress/preferences';\n// eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.\nimport { Tooltip } from '@wordpress/ui';\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.Root>\n\t\t\t\t\t<Tooltip.Trigger\n\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclassName=\"editor-template-actions-panel__preview\"\n\t\t\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\t\t\ttabIndex={ 0 }\n\t\t\t\t\t\t\t\taria-label={ tooltipText }\n\t\t\t\t\t\t\t\tonClick={ () => setIsSwapModalOpen( true ) }\n\t\t\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tevent.keyCode === ENTER ||\n\t\t\t\t\t\t\t\t\t\tevent.keyCode === SPACE\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t\tsetIsSwapModalOpen( true );\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\t\t{ previewContent }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<Tooltip.Popup>{ tooltipText }</Tooltip.Popup>\n\t\t\t\t</Tooltip.Root>\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,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP,SAAS,gBAAgB;AACzB,SAAS,IAAI,eAAe;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,OAAO,aAAa;AAC7B,SAAS,SAAS,oBAAoB;AACtC,SAAS,SAAS,wBAAwB;AAE1C,SAAS,eAAe;AAKxB,SAAS,SAAS,mBAAmB;AACrC,OAAO,4BAA4B;AACnC,SAAS,yBAAyB;AAClC,SAAS,6BAA6B;AA8EnC,SAgDD,UAhDC,KAYC,YAZD;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,QA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uBAAqB;AAAA,gBACrB,SAAQ;AAAA,gBACR,SAAU,MAAM,qBAAsB,IAAK;AAAA,gBAEzC,aAAI,YAAa;AAAA;AAAA,YACpB;AAAA,aAEF;AAAA,WACD;AAAA;AAAA,IACD;AAAA,IACE,qBACD;AAAA,MAAC;AAAA;AAAA,QACA,SAAU,MAAM,qBAAsB,KAAM;AAAA;AAAA,IAC7C;AAAA,IAEC,mBACD;AAAA,MAAC;AAAA;AAAA,QACA,gBAAiB,MAAM,mBAAoB,KAAM;AAAA;AAAA,IAClD;AAAA,KAEF;AAEF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,135 @@
1
+ // packages/editor/src/components/upload-progress-snackbar/index.js
2
+ import { useSelect, useDispatch } from "@wordpress/data";
3
+ import { useEffect, useMemo, useRef, useState } from "@wordpress/element";
4
+ import { __, sprintf } from "@wordpress/i18n";
5
+ import { speak } from "@wordpress/a11y";
6
+ import { store as uploadStore } from "@wordpress/upload-media";
7
+ import { store as noticesStore } from "@wordpress/notices";
8
+ import { Icon as WCIcon, Spinner } from "@wordpress/components";
9
+ import { check } from "@wordpress/icons";
10
+ import { useTracker } from "./tracker.mjs";
11
+ import { jsx } from "react/jsx-runtime";
12
+ var NOTICE_ID = "upload-progress";
13
+ var COMPLETION_DISPLAY_MS = 3e3;
14
+ var MAX_FILENAME_LENGTH = 40;
15
+ function truncateFilename(filename) {
16
+ if (filename.length <= MAX_FILENAME_LENGTH) {
17
+ return filename;
18
+ }
19
+ const ellipsis = "\u2026";
20
+ const visible = MAX_FILENAME_LENGTH - ellipsis.length;
21
+ const front = Math.ceil(visible / 2);
22
+ const back = Math.floor(visible / 2);
23
+ return filename.slice(0, front) + ellipsis + filename.slice(filename.length - back);
24
+ }
25
+ var UPLOAD_SPINNER = /* @__PURE__ */ jsx(
26
+ "span",
27
+ {
28
+ className: "editor-upload-progress-snackbar__spinner",
29
+ "aria-hidden": "true",
30
+ children: /* @__PURE__ */ jsx(Spinner, {})
31
+ }
32
+ );
33
+ var UPLOAD_DONE = /* @__PURE__ */ jsx("span", { className: "editor-upload-progress-snackbar__check", "aria-hidden": "true", children: /* @__PURE__ */ jsx(WCIcon, { icon: check }) });
34
+ function UploadProgressSnackbar() {
35
+ const items = useSelect(
36
+ (select) => select(uploadStore).getItems(),
37
+ []
38
+ );
39
+ const tracker = useTracker();
40
+ const csmOriginals = useMemo(
41
+ () => items.filter((item) => !item.parentId),
42
+ [items]
43
+ );
44
+ const csmRemaining = csmOriginals.length;
45
+ const trackedRemaining = tracker ? tracker.total - tracker.completed : 0;
46
+ const remaining = csmRemaining + trackedRemaining;
47
+ const [peak, setPeak] = useState(0);
48
+ const sessionTotal = csmRemaining + (tracker ? tracker.total : 0);
49
+ if (sessionTotal > peak) {
50
+ setPeak(sessionTotal);
51
+ }
52
+ const { createNotice, removeNotice } = useDispatch(noticesStore);
53
+ const dismissedRef = useRef(false);
54
+ const wasUploadingRef = useRef(false);
55
+ const completionTimeoutRef = useRef(null);
56
+ useEffect(() => {
57
+ return () => {
58
+ if (completionTimeoutRef.current) {
59
+ clearTimeout(completionTimeoutRef.current);
60
+ }
61
+ };
62
+ }, []);
63
+ useEffect(() => {
64
+ const isUploading = remaining > 0;
65
+ if (isUploading && !wasUploadingRef.current) {
66
+ dismissedRef.current = false;
67
+ speak(__("Media upload started"), "polite");
68
+ if (completionTimeoutRef.current) {
69
+ clearTimeout(completionTimeoutRef.current);
70
+ completionTimeoutRef.current = null;
71
+ setPeak(0);
72
+ }
73
+ } else if (!isUploading && wasUploadingRef.current) {
74
+ speak(__("Media upload complete"), "polite");
75
+ if (!dismissedRef.current) {
76
+ createNotice("info", __("Upload complete"), {
77
+ id: NOTICE_ID,
78
+ type: "snackbar",
79
+ isDismissible: false,
80
+ explicitDismiss: false,
81
+ speak: false,
82
+ icon: UPLOAD_DONE,
83
+ onDismiss: () => {
84
+ dismissedRef.current = true;
85
+ }
86
+ });
87
+ completionTimeoutRef.current = setTimeout(() => {
88
+ removeNotice(NOTICE_ID);
89
+ completionTimeoutRef.current = null;
90
+ setPeak(0);
91
+ }, COMPLETION_DISPLAY_MS);
92
+ } else {
93
+ setPeak(0);
94
+ }
95
+ }
96
+ wasUploadingRef.current = isUploading;
97
+ if (!isUploading || dismissedRef.current) {
98
+ return;
99
+ }
100
+ const total = peak;
101
+ const current = total - remaining + 1;
102
+ const filename = truncateFilename(
103
+ csmOriginals[0]?.sourceFile?.name || tracker?.pending[0] || __("Uploading")
104
+ );
105
+ const content = total === 1 ? sprintf(
106
+ /* translators: %s: filename. */
107
+ __("Uploading \u2014 %s"),
108
+ filename
109
+ ) : sprintf(
110
+ /* translators: 1: current upload number, 2: total uploads, 3: filename. */
111
+ __("Uploading %1$d of %2$d \u2014 %3$s"),
112
+ current,
113
+ total,
114
+ filename
115
+ );
116
+ createNotice("info", content, {
117
+ id: NOTICE_ID,
118
+ type: "snackbar",
119
+ isDismissible: false,
120
+ explicitDismiss: true,
121
+ speak: false,
122
+ icon: UPLOAD_SPINNER,
123
+ onDismiss: () => {
124
+ dismissedRef.current = true;
125
+ }
126
+ });
127
+ }, [remaining, peak, csmOriginals, tracker, createNotice, removeNotice]);
128
+ return null;
129
+ }
130
+ export {
131
+ UPLOAD_DONE,
132
+ UPLOAD_SPINNER,
133
+ UploadProgressSnackbar as default
134
+ };
135
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/upload-progress-snackbar/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useMemo, useRef, useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport { store as uploadStore } from '@wordpress/upload-media';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { Icon as WCIcon, Spinner } from '@wordpress/components';\nimport { check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useTracker } from './tracker';\n\nconst NOTICE_ID = 'upload-progress';\n\n// How long the completion checkmark is shown before the snackbar dismisses.\nconst COMPLETION_DISPLAY_MS = 3000;\n\n// Longest filename shown before it is middle-truncated. Long names (e.g. the\n// UUID-style names some sources produce) would otherwise stretch the snackbar.\nconst MAX_FILENAME_LENGTH = 40;\n\n/**\n * Middle-truncates a filename that exceeds `MAX_FILENAME_LENGTH`, keeping the\n * start and the end (so the file extension stays visible).\n *\n * @param {string} filename The filename to truncate.\n * @return {string} The original or middle-truncated filename.\n */\nfunction truncateFilename( filename ) {\n\tif ( filename.length <= MAX_FILENAME_LENGTH ) {\n\t\treturn filename;\n\t}\n\tconst ellipsis = '\u2026';\n\tconst visible = MAX_FILENAME_LENGTH - ellipsis.length;\n\tconst front = Math.ceil( visible / 2 );\n\tconst back = Math.floor( visible / 2 );\n\treturn (\n\t\tfilename.slice( 0, front ) +\n\t\tellipsis +\n\t\tfilename.slice( filename.length - back )\n\t);\n}\n\n// Exported so the Storybook story can render the exact icon markup the notice\n// uses, keeping the visual review faithful to what ships.\nexport const UPLOAD_SPINNER = (\n\t<span\n\t\tclassName=\"editor-upload-progress-snackbar__spinner\"\n\t\taria-hidden=\"true\"\n\t>\n\t\t<Spinner />\n\t</span>\n);\n\nexport const UPLOAD_DONE = (\n\t<span className=\"editor-upload-progress-snackbar__check\" aria-hidden=\"true\">\n\t\t<WCIcon icon={ check } />\n\t</span>\n);\n\n/**\n * Manages a snackbar notice that shows media upload progress while uploads are\n * in progress. It creates/updates a notice via the notices store so that it\n * positions and stacks with every other snackbar in the editor.\n *\n * Reads from two sources to cover both upload paths:\n * - `@wordpress/upload-media` store (client-side media processing path).\n * - An editor-local tracker populated by the traditional `mediaUpload`\n * wrapper (non-CSM path \u2014 e.g. Safari, or when a filter disables CSM).\n *\n * Only counts original user-uploaded files (items without a `parentId`),\n * ignoring generated subsizes/thumbnails.\n *\n * @return {null} This component renders nothing \u2014 it only manages a notice.\n */\nexport default function UploadProgressSnackbar() {\n\tconst items = useSelect(\n\t\t( select ) => select( uploadStore ).getItems(),\n\t\t[]\n\t);\n\tconst tracker = useTracker();\n\n\t// CSM path: originals in the upload-media queue (subsizes excluded). Memoized\n\t// so its reference is stable across renders where `items` is unchanged, since\n\t// it's a dependency of the effect below.\n\tconst csmOriginals = useMemo(\n\t\t() => items.filter( ( item ) => ! item.parentId ),\n\t\t[ items ]\n\t);\n\tconst csmRemaining = csmOriginals.length;\n\n\t// Non-CSM path: files tracked by the editor's mediaUpload wrapper.\n\tconst trackedRemaining = tracker ? tracker.total - tracker.completed : 0;\n\n\tconst remaining = csmRemaining + trackedRemaining;\n\n\t// Track peak total across sources during a session. The CSM queue removes\n\t// items on completion, and the tracker tops out at its recorded total, so\n\t// `total` has to be tracked as the high-water mark.\n\tconst [ peak, setPeak ] = useState( 0 );\n\tconst sessionTotal = csmRemaining + ( tracker ? tracker.total : 0 );\n\tif ( sessionTotal > peak ) {\n\t\tsetPeak( sessionTotal );\n\t}\n\n\tconst { createNotice, removeNotice } = useDispatch( noticesStore );\n\n\t// Track whether the user has dismissed the notice. If so, don't re-create\n\t// it until the current batch finishes and a new one starts.\n\tconst dismissedRef = useRef( false );\n\tconst wasUploadingRef = useRef( false );\n\n\t// Timeout that removes the completion-state (checkmark) notice after a\n\t// brief display. Held so a new upload can cancel it.\n\tconst completionTimeoutRef = useRef( null );\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( completionTimeoutRef.current ) {\n\t\t\t\tclearTimeout( completionTimeoutRef.current );\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tconst isUploading = remaining > 0;\n\n\t\tif ( isUploading && ! wasUploadingRef.current ) {\n\t\t\tdismissedRef.current = false;\n\t\t\tspeak( __( 'Media upload started' ), 'polite' );\n\t\t\t// A new batch started during the completion display: cancel the\n\t\t\t// pending dismissal so the snackbar transitions straight back\n\t\t\t// into the uploading state, and reset the peak so the new batch\n\t\t\t// counts from `1 of N` rather than resuming the previous total.\n\t\t\tif ( completionTimeoutRef.current ) {\n\t\t\t\tclearTimeout( completionTimeoutRef.current );\n\t\t\t\tcompletionTimeoutRef.current = null;\n\t\t\t\tsetPeak( 0 );\n\t\t\t}\n\t\t} else if ( ! isUploading && wasUploadingRef.current ) {\n\t\t\tspeak( __( 'Media upload complete' ), 'polite' );\n\n\t\t\tif ( ! dismissedRef.current ) {\n\t\t\t\tcreateNotice( 'info', __( 'Upload complete' ), {\n\t\t\t\t\tid: NOTICE_ID,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: false,\n\t\t\t\t\texplicitDismiss: false,\n\t\t\t\t\tspeak: false,\n\t\t\t\t\ticon: UPLOAD_DONE,\n\t\t\t\t\tonDismiss: () => {\n\t\t\t\t\t\tdismissedRef.current = true;\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tcompletionTimeoutRef.current = setTimeout( () => {\n\t\t\t\t\tremoveNotice( NOTICE_ID );\n\t\t\t\t\tcompletionTimeoutRef.current = null;\n\t\t\t\t\tsetPeak( 0 );\n\t\t\t\t}, COMPLETION_DISPLAY_MS );\n\t\t\t} else {\n\t\t\t\tsetPeak( 0 );\n\t\t\t}\n\t\t}\n\n\t\twasUploadingRef.current = isUploading;\n\n\t\tif ( ! isUploading || dismissedRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst total = peak;\n\t\tconst current = total - remaining + 1;\n\n\t\t// Prefer the CSM queue's first original filename, then fall back to\n\t\t// the tracker's first pending filename.\n\t\tconst filename = truncateFilename(\n\t\t\tcsmOriginals[ 0 ]?.sourceFile?.name ||\n\t\t\t\ttracker?.pending[ 0 ] ||\n\t\t\t\t__( 'Uploading' )\n\t\t);\n\n\t\tconst content =\n\t\t\ttotal === 1\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: filename. */\n\t\t\t\t\t\t__( 'Uploading \u2014 %s' ),\n\t\t\t\t\t\tfilename\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: 1: current upload number, 2: total uploads, 3: filename. */\n\t\t\t\t\t\t__( 'Uploading %1$d of %2$d \u2014 %3$s' ),\n\t\t\t\t\t\tcurrent,\n\t\t\t\t\t\ttotal,\n\t\t\t\t\t\tfilename\n\t\t\t\t );\n\n\t\tcreateNotice( 'info', content, {\n\t\t\tid: NOTICE_ID,\n\t\t\ttype: 'snackbar',\n\t\t\tisDismissible: false,\n\t\t\texplicitDismiss: true,\n\t\t\tspeak: false,\n\t\t\ticon: UPLOAD_SPINNER,\n\t\t\tonDismiss: () => {\n\t\t\t\tdismissedRef.current = true;\n\t\t\t},\n\t\t} );\n\t}, [ remaining, peak, csmOriginals, tracker, createNotice, removeNotice ] );\n\n\treturn null;\n}\n"],
5
+ "mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,WAAW,SAAS,QAAQ,gBAAgB;AACrD,SAAS,IAAI,eAAe;AAC5B,SAAS,aAAa;AACtB,SAAS,SAAS,mBAAmB;AACrC,SAAS,SAAS,oBAAoB;AACtC,SAAS,QAAQ,QAAQ,eAAe;AACxC,SAAS,aAAa;AAKtB,SAAS,kBAAkB;AAwCzB;AAtCF,IAAM,YAAY;AAGlB,IAAM,wBAAwB;AAI9B,IAAM,sBAAsB;AAS5B,SAAS,iBAAkB,UAAW;AACrC,MAAK,SAAS,UAAU,qBAAsB;AAC7C,WAAO;AAAA,EACR;AACA,QAAM,WAAW;AACjB,QAAM,UAAU,sBAAsB,SAAS;AAC/C,QAAM,QAAQ,KAAK,KAAM,UAAU,CAAE;AACrC,QAAM,OAAO,KAAK,MAAO,UAAU,CAAE;AACrC,SACC,SAAS,MAAO,GAAG,KAAM,IACzB,WACA,SAAS,MAAO,SAAS,SAAS,IAAK;AAEzC;AAIO,IAAM,iBACZ;AAAA,EAAC;AAAA;AAAA,IACA,WAAU;AAAA,IACV,eAAY;AAAA,IAEZ,8BAAC,WAAQ;AAAA;AACV;AAGM,IAAM,cACZ,oBAAC,UAAK,W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C7B,qBAAc,QAAQ,GAAI,iBAAkB,GAAG;AAAA,UAC9C,IAAI;AAAA,UACJ,MAAM;AAAA,UACN,eAAe;AAAA,UACf,iBAAiB;AAAA,UACjB,OAAO;AAAA,UACP,MAAM;AAAA,UACN,WAAW,MAAM;AAChB,yBAAa,UAAU;AAAA,UACxB;AAAA,QACD,CAAE;AAEF,6BAAqB,UAAU,WAAY,MAAM;AAChD,uBAAc,SAAU;AACxB,+BAAqB,UAAU;AAC/B,kBAAS,CAAE;AAAA,QACZ,GAAG,qBAAsB;AAAA,MAC1B,OAAO;AACN,gBAAS,CAAE;AAAA,MACZ;AAAA,IACD;AAEA,oBAAgB,UAAU;AAE1B,QAAK,CAAE,eAAe,aAAa,SAAU;AAC5C;AAAA,IACD;AAEA,UAAM,QAAQ;AACd,UAAM,UAAU,QAAQ,YAAY;AAIpC,UAAM,WAAW;AAAA,MAChB,aAAc,CAAE,GAAG,YAAY,QAC9B,SAAS,QAAS,CAAE,KACpB,GAAI,WAAY;AAAA,IAClB;AAEA,UAAM,UACL,UAAU,IACP;AAAA;AAAA,MAEA,GAAI,qBAAiB;AAAA,MACrB;AAAA,IACA,IACA;AAAA;AAAA,MAEA,GAAI,oCAAgC;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,IACA;AAEJ,iBAAc,QAAQ,SAAS;AAAA,MAC9B,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,eAAe;AAAA,MACf,iBAAiB;AAAA,MACjB,OAAO;AAAA,MACP,MAAM;AAAA,MACN,WAAW,MAAM;AAChB,qBAAa,UAAU;AAAA,MACxB;AAAA,IACD,CAAE;AAAA,EACH,GAAG,CAAE,WAAW,MAAM,cAAc,SAAS,cAAc,YAAa,CAAE;AAE1E,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -0,0 +1,61 @@
1
+ // packages/editor/src/components/upload-progress-snackbar/tracker.js
2
+ import { useSyncExternalStore } from "@wordpress/element";
3
+ var state = null;
4
+ var listeners = /* @__PURE__ */ new Set();
5
+ function notify() {
6
+ listeners.forEach((listener) => listener());
7
+ }
8
+ function addFiles(filenames) {
9
+ if (!filenames.length) {
10
+ return;
11
+ }
12
+ if (!state) {
13
+ state = { total: 0, completed: 0, pending: [] };
14
+ }
15
+ state = {
16
+ total: state.total + filenames.length,
17
+ completed: state.completed,
18
+ pending: [...state.pending, ...filenames]
19
+ };
20
+ notify();
21
+ }
22
+ function advance(count) {
23
+ if (!state || count <= 0) {
24
+ return;
25
+ }
26
+ const completed = Math.min(state.total, state.completed + count);
27
+ const pending = state.pending.slice(count);
28
+ if (completed >= state.total) {
29
+ state = null;
30
+ } else {
31
+ state = { total: state.total, completed, pending };
32
+ }
33
+ notify();
34
+ }
35
+ function reset() {
36
+ if (state === null) {
37
+ return;
38
+ }
39
+ state = null;
40
+ notify();
41
+ }
42
+ function getState() {
43
+ return state;
44
+ }
45
+ function subscribe(listener) {
46
+ listeners.add(listener);
47
+ return () => {
48
+ listeners.delete(listener);
49
+ };
50
+ }
51
+ function useTracker() {
52
+ return useSyncExternalStore(subscribe, getState, getState);
53
+ }
54
+ export {
55
+ addFiles,
56
+ advance,
57
+ getState,
58
+ reset,
59
+ useTracker
60
+ };
61
+ //# sourceMappingURL=tracker.mjs.map