@wordpress/editor 14.48.0 → 14.48.2-next.v.202606191442.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -1
- package/build/bindings/pattern-overrides.cjs +1 -1
- package/build/bindings/pattern-overrides.cjs.map +2 -2
- package/build/components/block-removal-warnings/index.cjs +0 -3
- package/build/components/block-removal-warnings/index.cjs.map +2 -2
- package/build/components/collab-sidebar/note-byline.cjs +1 -1
- package/build/components/collab-sidebar/note-byline.cjs.map +2 -2
- package/build/components/collab-sidebar/note-indicator-toolbar.cjs +49 -43
- package/build/components/collab-sidebar/note-indicator-toolbar.cjs.map +3 -3
- package/build/components/collab-sidebar/note.cjs +49 -17
- package/build/components/collab-sidebar/note.cjs.map +3 -3
- package/build/components/collab-sidebar/notes.cjs.map +1 -1
- package/build/components/collab-sidebar/utils.cjs +1 -1
- package/build/components/collab-sidebar/utils.cjs.map +2 -2
- package/build/components/collaborators-overlay/avatar-iframe-styles.cjs.map +1 -1
- package/build/components/collaborators-overlay/collaborator-styles.cjs.map +1 -1
- package/build/components/collaborators-overlay/compute-selection.cjs.map +1 -1
- package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +1 -1
- package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +1 -1
- package/build/components/collaborators-overlay/use-block-highlighting.cjs +1 -8
- package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +3 -3
- package/build/components/collaborators-overlay/use-render-cursors.cjs +1 -7
- package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
- package/build/components/collaborators-presence/avatar/component.cjs.map +2 -2
- package/build/components/collaborators-presence/avatar/use-image-loading-status.cjs.map +1 -1
- package/build/components/document-bar/index.cjs +7 -5
- package/build/components/document-bar/index.cjs.map +2 -2
- package/build/components/global-keyboard-shortcuts/index.cjs +3 -2
- package/build/components/global-keyboard-shortcuts/index.cjs.map +2 -2
- package/build/components/global-styles-sidebar/welcome-guide.cjs +3 -3
- package/build/components/global-styles-sidebar/welcome-guide.cjs.map +1 -1
- package/build/components/local-autosave-monitor/index.cjs +14 -15
- package/build/components/local-autosave-monitor/index.cjs.map +2 -2
- package/build/components/more-menu/view-more-menu-group.cjs +1 -2
- package/build/components/more-menu/view-more-menu-group.cjs.map +2 -2
- package/build/components/page-attributes/parent.cjs +2 -1
- package/build/components/page-attributes/parent.cjs.map +2 -2
- package/build/components/post-card-panel/index.cjs +1 -1
- package/build/components/post-card-panel/index.cjs.map +2 -2
- package/build/components/post-excerpt/panel.cjs +1 -1
- package/build/components/post-excerpt/panel.cjs.map +2 -2
- package/build/components/post-locked-modal/index.cjs +3 -3
- package/build/components/post-locked-modal/index.cjs.map +1 -1
- package/build/components/post-preview-button/index.cjs +2 -2
- package/build/components/post-preview-button/index.cjs.map +2 -2
- package/build/components/post-publish-button/index.cjs +115 -157
- package/build/components/post-publish-button/index.cjs.map +3 -3
- package/build/components/post-publish-button/label.cjs +2 -2
- package/build/components/post-publish-button/label.cjs.map +2 -2
- package/build/components/post-publish-panel/index.cjs.map +1 -1
- package/build/components/post-publish-panel/postpublish.cjs +1 -1
- package/build/components/post-publish-panel/postpublish.cjs.map +2 -2
- package/build/components/post-revisions-preview/block-diff.cjs +21 -9
- package/build/components/post-revisions-preview/block-diff.cjs.map +2 -2
- package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
- package/build/components/post-revisions-preview/preserve-client-ids.cjs +2 -2
- package/build/components/post-revisions-preview/preserve-client-ids.cjs.map +2 -2
- package/build/components/post-revisions-preview/revisions-slider.cjs +1 -1
- package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
- package/build/components/post-revisions-timeline/index.cjs +173 -0
- package/build/components/post-revisions-timeline/index.cjs.map +7 -0
- package/build/components/post-saved-state/index.cjs +17 -26
- package/build/components/post-saved-state/index.cjs.map +2 -2
- package/build/components/post-schedule/label.cjs +5 -5
- package/build/components/post-schedule/label.cjs.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.cjs +2 -1
- package/build/components/post-taxonomies/flat-term-selector.cjs.map +3 -3
- package/build/components/post-taxonomies/hierarchical-term-selector.cjs +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.cjs.map +2 -2
- package/build/components/post-text-editor/index.cjs +51 -0
- package/build/components/post-text-editor/index.cjs.map +2 -2
- package/build/components/post-text-editor/utils.cjs +150 -0
- package/build/components/post-text-editor/utils.cjs.map +7 -0
- package/build/components/post-url/index.cjs +1 -1
- package/build/components/post-url/index.cjs.map +2 -2
- package/build/components/post-view-link/index.cjs +1 -1
- package/build/components/post-view-link/index.cjs.map +2 -2
- package/build/components/provider/disable-non-page-content-blocks.cjs.map +1 -1
- package/build/components/provider/index.cjs +3 -1
- package/build/components/provider/index.cjs.map +3 -3
- package/build/components/provider/use-network-reconnect.cjs +51 -0
- package/build/components/provider/use-network-reconnect.cjs.map +7 -0
- package/build/components/resizable-editor/resize-handle.cjs.map +2 -2
- package/build/components/revision-diff-panel/index.cjs +7 -2
- package/build/components/revision-diff-panel/index.cjs.map +2 -2
- package/build/components/revision-fields-diff/index.cjs +8 -4
- package/build/components/revision-fields-diff/index.cjs.map +2 -2
- package/build/components/sidebar/dataform-post-summary.cjs +125 -20
- package/build/components/sidebar/dataform-post-summary.cjs.map +3 -3
- package/build/components/sidebar/index.cjs +2 -15
- package/build/components/sidebar/index.cjs.map +3 -3
- package/build/components/sidebar/post-revision-summary.cjs +11 -17
- package/build/components/sidebar/post-revision-summary.cjs.map +3 -3
- package/build/components/sidebar/post-summary.cjs +1 -1
- package/build/components/sidebar/post-summary.cjs.map +2 -2
- package/build/components/style-book/examples.cjs +1 -1
- package/build/components/style-book/examples.cjs.map +1 -1
- package/build/components/style-book/index.cjs +1 -1
- package/build/components/style-book/index.cjs.map +2 -2
- package/build/components/sync-connection-error-modal/index.cjs +3 -3
- package/build/components/sync-connection-error-modal/index.cjs.map +1 -1
- package/build/components/template-actions-panel/block-theme-content.cjs +7 -1
- package/build/components/template-actions-panel/block-theme-content.cjs.map +2 -2
- package/build/components/template-actions-panel/index.cjs +0 -9
- package/build/components/template-actions-panel/index.cjs.map +3 -3
- package/build/components/template-validation-notice/index.cjs +1 -1
- package/build/components/template-validation-notice/index.cjs.map +1 -1
- package/build/components/upload-progress-snackbar/index.cjs +161 -0
- package/build/components/upload-progress-snackbar/index.cjs.map +7 -0
- package/build/components/upload-progress-snackbar/tracker.cjs +90 -0
- package/build/components/upload-progress-snackbar/tracker.cjs.map +7 -0
- package/build/components/visual-editor/edit-template-blocks-notification.cjs +1 -1
- package/build/components/visual-editor/edit-template-blocks-notification.cjs.map +1 -1
- package/build/{components/revision-author-panel → dataviews/fields/revisions}/index.cjs +18 -26
- package/build/dataviews/fields/revisions/index.cjs.map +7 -0
- package/build/dataviews/fields/revisions/revisions-view.cjs +74 -0
- package/build/dataviews/fields/revisions/revisions-view.cjs.map +7 -0
- package/build/dataviews/store/private-actions.cjs +14 -4
- package/build/dataviews/store/private-actions.cjs.map +3 -3
- package/build/hooks/push-changes-to-global-styles/index.cjs +1 -1
- package/build/hooks/push-changes-to-global-styles/index.cjs.map +1 -1
- package/build/private-apis.cjs +2 -0
- package/build/private-apis.cjs.map +3 -3
- package/build/store/actions.cjs +1 -1
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +6 -1
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/selectors.cjs +1 -2
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/media-upload/index.cjs +16 -0
- package/build/utils/media-upload/index.cjs.map +3 -3
- package/build/utils/set-nested-value.cjs.map +1 -1
- package/build-module/bindings/pattern-overrides.mjs +1 -1
- package/build-module/bindings/pattern-overrides.mjs.map +2 -2
- package/build-module/components/block-removal-warnings/index.mjs +0 -3
- package/build-module/components/block-removal-warnings/index.mjs.map +2 -2
- package/build-module/components/collab-sidebar/note-byline.mjs +1 -1
- package/build-module/components/collab-sidebar/note-byline.mjs.map +2 -2
- package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs +53 -44
- package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs.map +2 -2
- package/build-module/components/collab-sidebar/note.mjs +50 -18
- package/build-module/components/collab-sidebar/note.mjs.map +2 -2
- package/build-module/components/collab-sidebar/notes.mjs.map +1 -1
- package/build-module/components/collab-sidebar/utils.mjs +1 -1
- package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs.map +1 -1
- package/build-module/components/collaborators-overlay/collaborator-styles.mjs.map +1 -1
- package/build-module/components/collaborators-overlay/compute-selection.mjs.map +1 -1
- package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +1 -1
- package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +1 -1
- package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +1 -8
- package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs +1 -7
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
- package/build-module/components/collaborators-presence/avatar/component.mjs.map +2 -2
- package/build-module/components/collaborators-presence/avatar/use-image-loading-status.mjs.map +1 -1
- package/build-module/components/document-bar/index.mjs +7 -5
- package/build-module/components/document-bar/index.mjs.map +2 -2
- package/build-module/components/global-keyboard-shortcuts/index.mjs +3 -2
- package/build-module/components/global-keyboard-shortcuts/index.mjs.map +2 -2
- package/build-module/components/global-styles-sidebar/welcome-guide.mjs +3 -3
- package/build-module/components/global-styles-sidebar/welcome-guide.mjs.map +1 -1
- package/build-module/components/local-autosave-monitor/index.mjs +15 -16
- package/build-module/components/local-autosave-monitor/index.mjs.map +2 -2
- package/build-module/components/more-menu/view-more-menu-group.mjs +1 -2
- package/build-module/components/more-menu/view-more-menu-group.mjs.map +2 -2
- package/build-module/components/page-attributes/parent.mjs +2 -1
- package/build-module/components/page-attributes/parent.mjs.map +2 -2
- package/build-module/components/post-card-panel/index.mjs +1 -1
- package/build-module/components/post-card-panel/index.mjs.map +2 -2
- package/build-module/components/post-excerpt/panel.mjs +1 -1
- package/build-module/components/post-excerpt/panel.mjs.map +2 -2
- package/build-module/components/post-locked-modal/index.mjs +3 -3
- package/build-module/components/post-locked-modal/index.mjs.map +1 -1
- package/build-module/components/post-preview-button/index.mjs +2 -2
- package/build-module/components/post-preview-button/index.mjs.map +2 -2
- package/build-module/components/post-publish-button/index.mjs +117 -159
- package/build-module/components/post-publish-button/index.mjs.map +2 -2
- package/build-module/components/post-publish-button/label.mjs +2 -2
- package/build-module/components/post-publish-button/label.mjs.map +2 -2
- package/build-module/components/post-publish-panel/index.mjs.map +1 -1
- package/build-module/components/post-publish-panel/postpublish.mjs +1 -1
- package/build-module/components/post-publish-panel/postpublish.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/block-diff.mjs +20 -8
- package/build-module/components/post-revisions-preview/block-diff.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/preserve-client-ids.mjs +1 -1
- package/build-module/components/post-revisions-preview/preserve-client-ids.mjs.map +1 -1
- package/build-module/components/post-revisions-preview/revisions-slider.mjs +1 -1
- package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
- package/build-module/components/post-revisions-timeline/index.mjs +152 -0
- package/build-module/components/post-revisions-timeline/index.mjs.map +7 -0
- package/build-module/components/post-saved-state/index.mjs +17 -26
- package/build-module/components/post-saved-state/index.mjs.map +2 -2
- package/build-module/components/post-schedule/label.mjs +5 -5
- package/build-module/components/post-schedule/label.mjs.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.mjs +3 -6
- package/build-module/components/post-taxonomies/flat-term-selector.mjs.map +2 -2
- package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs.map +2 -2
- package/build-module/components/post-text-editor/index.mjs +51 -0
- package/build-module/components/post-text-editor/index.mjs.map +2 -2
- package/build-module/components/post-text-editor/utils.mjs +123 -0
- package/build-module/components/post-text-editor/utils.mjs.map +7 -0
- package/build-module/components/post-url/index.mjs +1 -1
- package/build-module/components/post-url/index.mjs.map +2 -2
- package/build-module/components/post-view-link/index.mjs +1 -1
- package/build-module/components/post-view-link/index.mjs.map +2 -2
- package/build-module/components/provider/disable-non-page-content-blocks.mjs.map +1 -1
- package/build-module/components/provider/index.mjs +3 -1
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-network-reconnect.mjs +30 -0
- package/build-module/components/provider/use-network-reconnect.mjs.map +7 -0
- package/build-module/components/resizable-editor/resize-handle.mjs.map +2 -2
- package/build-module/components/revision-diff-panel/index.mjs +7 -2
- package/build-module/components/revision-diff-panel/index.mjs.map +2 -2
- package/build-module/components/revision-fields-diff/index.mjs +8 -4
- package/build-module/components/revision-fields-diff/index.mjs.map +2 -2
- package/build-module/components/sidebar/dataform-post-summary.mjs +125 -20
- package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs +3 -22
- package/build-module/components/sidebar/index.mjs.map +2 -2
- package/build-module/components/sidebar/post-revision-summary.mjs +11 -17
- package/build-module/components/sidebar/post-revision-summary.mjs.map +2 -2
- package/build-module/components/sidebar/post-summary.mjs +1 -1
- package/build-module/components/sidebar/post-summary.mjs.map +2 -2
- package/build-module/components/style-book/examples.mjs +1 -1
- package/build-module/components/style-book/examples.mjs.map +1 -1
- package/build-module/components/style-book/index.mjs +1 -1
- package/build-module/components/style-book/index.mjs.map +2 -2
- package/build-module/components/sync-connection-error-modal/index.mjs +3 -3
- package/build-module/components/sync-connection-error-modal/index.mjs.map +1 -1
- package/build-module/components/template-actions-panel/block-theme-content.mjs +7 -1
- package/build-module/components/template-actions-panel/block-theme-content.mjs.map +2 -2
- package/build-module/components/template-actions-panel/index.mjs +0 -9
- package/build-module/components/template-actions-panel/index.mjs.map +2 -2
- package/build-module/components/template-validation-notice/index.mjs +1 -1
- package/build-module/components/template-validation-notice/index.mjs.map +1 -1
- package/build-module/components/upload-progress-snackbar/index.mjs +135 -0
- package/build-module/components/upload-progress-snackbar/index.mjs.map +7 -0
- package/build-module/components/upload-progress-snackbar/tracker.mjs +61 -0
- package/build-module/components/upload-progress-snackbar/tracker.mjs.map +7 -0
- package/build-module/components/visual-editor/edit-template-blocks-notification.mjs +1 -1
- package/build-module/components/visual-editor/edit-template-blocks-notification.mjs.map +1 -1
- package/build-module/dataviews/fields/revisions/index.mjs +20 -0
- package/build-module/dataviews/fields/revisions/index.mjs.map +7 -0
- package/build-module/dataviews/fields/revisions/revisions-view.mjs +53 -0
- package/build-module/dataviews/fields/revisions/revisions-view.mjs.map +7 -0
- package/build-module/dataviews/store/private-actions.mjs +23 -7
- package/build-module/dataviews/store/private-actions.mjs.map +2 -2
- package/build-module/hooks/push-changes-to-global-styles/index.mjs +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.mjs.map +1 -1
- package/build-module/private-apis.mjs +2 -0
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +1 -1
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +7 -1
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/selectors.mjs +1 -2
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/media-upload/index.mjs +19 -0
- package/build-module/utils/media-upload/index.mjs.map +2 -2
- package/build-module/utils/set-nested-value.mjs.map +1 -1
- package/build-style/style-rtl.css +707 -270
- package/build-style/style.css +707 -270
- package/build-types/components/block-removal-warnings/index.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/note-byline.d.ts +0 -3
- package/build-types/components/collab-sidebar/note-byline.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/note.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts +0 -3
- package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
- package/build-types/components/collaborators-presence/avatar/component.d.ts.map +1 -1
- package/build-types/components/document-bar/index.d.ts.map +1 -1
- package/build-types/components/global-keyboard-shortcuts/index.d.ts.map +1 -1
- package/build-types/components/local-autosave-monitor/index.d.ts.map +1 -1
- package/build-types/components/more-menu/view-more-menu-group.d.ts.map +1 -1
- package/build-types/components/page-attributes/parent.d.ts.map +1 -1
- package/build-types/components/post-publish-button/index.d.ts +9 -9
- package/build-types/components/post-publish-button/index.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/block-diff.d.ts +3 -0
- package/build-types/components/post-revisions-preview/block-diff.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/diff-markers.d.ts.map +1 -1
- package/build-types/components/post-revisions-timeline/index.d.ts +2 -0
- package/build-types/components/post-revisions-timeline/index.d.ts.map +1 -0
- package/build-types/components/post-saved-state/index.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
- package/build-types/components/post-text-editor/index.d.ts.map +1 -1
- package/build-types/components/post-text-editor/utils.d.ts +29 -0
- package/build-types/components/post-text-editor/utils.d.ts.map +1 -0
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/provider/use-network-reconnect.d.ts +8 -0
- package/build-types/components/provider/use-network-reconnect.d.ts.map +1 -0
- package/build-types/components/resizable-editor/resize-handle.d.ts.map +1 -1
- package/build-types/components/revision-diff-panel/index.d.ts +3 -1
- package/build-types/components/revision-diff-panel/index.d.ts.map +1 -1
- package/build-types/components/revision-fields-diff/index.d.ts +3 -0
- package/build-types/components/revision-fields-diff/index.d.ts.map +1 -1
- package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/components/sidebar/post-revision-summary.d.ts.map +1 -1
- package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -1
- package/build-types/components/template-actions-panel/index.d.ts.map +1 -1
- package/build-types/components/upload-progress-snackbar/index.d.ts +19 -0
- package/build-types/components/upload-progress-snackbar/index.d.ts.map +1 -0
- package/build-types/components/upload-progress-snackbar/stories/index.story.d.ts +28 -0
- package/build-types/components/upload-progress-snackbar/stories/index.story.d.ts.map +1 -0
- package/build-types/components/upload-progress-snackbar/tracker.d.ts +41 -0
- package/build-types/components/upload-progress-snackbar/tracker.d.ts.map +1 -0
- package/build-types/dataviews/fields/revisions/index.d.ts +8 -0
- package/build-types/dataviews/fields/revisions/index.d.ts.map +1 -0
- package/build-types/dataviews/fields/revisions/revisions-view.d.ts +2 -0
- package/build-types/dataviews/fields/revisions/revisions-view.d.ts.map +1 -0
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +1 -1
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +1 -1
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
- package/build-types/utils/media-upload/index.d.ts.map +1 -1
- package/package.json +59 -50
- package/src/bindings/pattern-overrides.js +1 -1
- package/src/bindings/test/pattern-overrides.js +65 -0
- package/src/components/README.md +1 -1
- package/src/components/block-removal-warnings/index.js +0 -7
- package/src/components/collab-sidebar/note-byline.js +0 -1
- package/src/components/collab-sidebar/note-indicator-toolbar.js +73 -60
- package/src/components/collab-sidebar/note.js +64 -29
- package/src/components/collab-sidebar/style.scss +20 -0
- package/src/components/collaborators-overlay/use-block-highlighting.ts +0 -9
- package/src/components/collaborators-overlay/use-render-cursors.ts +0 -8
- package/src/components/collaborators-presence/avatar/component.tsx +0 -1
- package/src/components/collaborators-presence/avatar/test/index.tsx +8 -4
- package/src/components/document-bar/index.js +8 -3
- package/src/components/document-bar/style.scss +4 -2
- package/src/components/global-keyboard-shortcuts/index.js +2 -1
- package/src/components/local-autosave-monitor/index.js +23 -21
- package/src/components/more-menu/view-more-menu-group.js +1 -2
- package/src/components/page-attributes/parent.js +1 -0
- package/src/components/post-card-panel/index.js +1 -1
- package/src/components/post-publish-button/index.js +146 -192
- package/src/components/post-publish-button/test/index.js +149 -113
- package/src/components/post-revisions-preview/block-diff.js +63 -19
- package/src/components/post-revisions-preview/diff-markers.js +0 -1
- package/src/components/post-revisions-preview/preserve-client-ids.js +1 -1
- package/src/components/post-revisions-preview/test/block-diff.js +109 -6
- package/src/components/post-revisions-timeline/index.js +186 -0
- package/src/components/post-revisions-timeline/style.scss +43 -0
- package/src/components/post-saved-state/index.js +23 -26
- package/src/components/post-saved-state/test/index.js +18 -0
- package/src/components/post-taxonomies/flat-term-selector.js +4 -7
- package/src/components/post-text-editor/index.js +65 -0
- package/src/components/post-text-editor/test/utils.js +210 -0
- package/src/components/post-text-editor/utils.js +204 -0
- package/src/components/post-type-support-check/test/index.js +11 -0
- package/src/components/post-url/index.js +1 -1
- package/src/components/post-view-link/index.js +1 -1
- package/src/components/post-view-link/test/index.js +71 -0
- package/src/components/provider/index.js +6 -1
- package/src/components/provider/test/use-network-reconnect.js +137 -0
- package/src/components/provider/use-network-reconnect.js +44 -0
- package/src/components/resizable-editor/resize-handle.js +0 -1
- package/src/components/revision-diff-panel/index.js +8 -2
- package/src/components/revision-fields-diff/index.js +19 -3
- package/src/components/sidebar/dataform-post-summary.js +196 -25
- package/src/components/sidebar/index.js +4 -23
- package/src/components/sidebar/post-revision-summary.js +8 -15
- package/src/components/sidebar/post-summary.js +1 -1
- package/src/components/style-book/index.js +1 -1
- package/src/components/template-actions-panel/block-theme-content.js +10 -2
- package/src/components/template-actions-panel/index.js +0 -15
- package/src/components/upload-progress-snackbar/README.md +26 -0
- package/src/components/upload-progress-snackbar/index.js +216 -0
- package/src/components/upload-progress-snackbar/stories/index.story.tsx +85 -0
- package/src/components/upload-progress-snackbar/style.scss +30 -0
- package/src/components/upload-progress-snackbar/test/index.js +199 -0
- package/src/components/upload-progress-snackbar/tracker.js +105 -0
- package/src/dataviews/fields/revisions/index.tsx +28 -0
- package/src/dataviews/fields/revisions/revisions-view.tsx +59 -0
- package/src/dataviews/store/private-actions.ts +27 -6
- package/src/private-apis.js +2 -0
- package/src/store/private-selectors.js +11 -1
- package/src/store/selectors.js +1 -3
- package/src/store/test/private-selectors.js +69 -0
- package/src/style.scss +2 -1
- package/src/utils/media-upload/index.js +27 -0
- package/build/components/post-revisions-panel/index.cjs +0 -173
- package/build/components/post-revisions-panel/index.cjs.map +0 -7
- package/build/components/revision-author-panel/index.cjs.map +0 -7
- package/build/components/revision-created-panel/index.cjs +0 -47
- package/build/components/revision-created-panel/index.cjs.map +0 -7
- package/build-module/components/post-revisions-panel/index.mjs +0 -148
- package/build-module/components/post-revisions-panel/index.mjs.map +0 -7
- package/build-module/components/revision-author-panel/index.mjs +0 -28
- package/build-module/components/revision-author-panel/index.mjs.map +0 -7
- package/build-module/components/revision-created-panel/index.mjs +0 -26
- package/build-module/components/revision-created-panel/index.mjs.map +0 -7
- package/build-types/components/post-revisions-panel/index.d.ts +0 -2
- package/build-types/components/post-revisions-panel/index.d.ts.map +0 -1
- package/build-types/components/revision-author-panel/index.d.ts +0 -2
- package/build-types/components/revision-author-panel/index.d.ts.map +0 -1
- package/build-types/components/revision-created-panel/index.d.ts +0 -2
- package/build-types/components/revision-created-panel/index.d.ts.map +0 -1
- package/src/components/commands/index.native.js +0 -2
- package/src/components/deprecated.native.js +0 -47
- package/src/components/editor-help/add-blocks.native.js +0 -40
- package/src/components/editor-help/customize-blocks.native.js +0 -40
- package/src/components/editor-help/help-detail-navigation-screen.native.js +0 -67
- package/src/components/editor-help/help-get-support-button.native.js +0 -38
- package/src/components/editor-help/help-section-title.native.js +0 -29
- package/src/components/editor-help/help-topic-row.native.js +0 -33
- package/src/components/editor-help/icon-move-blocks.native.js +0 -10
- package/src/components/editor-help/images/add-dark.png +0 -0
- package/src/components/editor-help/images/add-dark@2x.png +0 -0
- package/src/components/editor-help/images/add-dark@3x.png +0 -0
- package/src/components/editor-help/images/add-light.png +0 -0
- package/src/components/editor-help/images/add-light@2x.png +0 -0
- package/src/components/editor-help/images/add-light@3x.png +0 -0
- package/src/components/editor-help/images/block-layout-collage.png +0 -0
- package/src/components/editor-help/images/block-layout-collage@2x.png +0 -0
- package/src/components/editor-help/images/block-layout-collage@3x.png +0 -0
- package/src/components/editor-help/images/build-layouts-dark.png +0 -0
- package/src/components/editor-help/images/build-layouts-dark@2x.png +0 -0
- package/src/components/editor-help/images/build-layouts-dark@3x.png +0 -0
- package/src/components/editor-help/images/build-layouts-light.png +0 -0
- package/src/components/editor-help/images/build-layouts-light@2x.png +0 -0
- package/src/components/editor-help/images/build-layouts-light@3x.png +0 -0
- package/src/components/editor-help/images/drag-and-drop-dark.png +0 -0
- package/src/components/editor-help/images/drag-and-drop-dark@2x.png +0 -0
- package/src/components/editor-help/images/drag-and-drop-dark@3x.png +0 -0
- package/src/components/editor-help/images/drag-and-drop-light.png +0 -0
- package/src/components/editor-help/images/drag-and-drop-light@2x.png +0 -0
- package/src/components/editor-help/images/drag-and-drop-light@3x.png +0 -0
- package/src/components/editor-help/images/edit-media-dark.png +0 -0
- package/src/components/editor-help/images/edit-media-dark@2x.png +0 -0
- package/src/components/editor-help/images/edit-media-dark@3x.png +0 -0
- package/src/components/editor-help/images/edit-media-light.png +0 -0
- package/src/components/editor-help/images/edit-media-light@2x.png +0 -0
- package/src/components/editor-help/images/edit-media-light@3x.png +0 -0
- package/src/components/editor-help/images/embed-media-dark.png +0 -0
- package/src/components/editor-help/images/embed-media-dark@2x.png +0 -0
- package/src/components/editor-help/images/embed-media-dark@3x.png +0 -0
- package/src/components/editor-help/images/embed-media-light.png +0 -0
- package/src/components/editor-help/images/embed-media-light@2x.png +0 -0
- package/src/components/editor-help/images/embed-media-light@3x.png +0 -0
- package/src/components/editor-help/images/move-dark.png +0 -0
- package/src/components/editor-help/images/move-dark@2x.png +0 -0
- package/src/components/editor-help/images/move-dark@3x.png +0 -0
- package/src/components/editor-help/images/move-light.png +0 -0
- package/src/components/editor-help/images/move-light@2x.png +0 -0
- package/src/components/editor-help/images/move-light@3x.png +0 -0
- package/src/components/editor-help/images/options-dark.png +0 -0
- package/src/components/editor-help/images/options-dark@2x.png +0 -0
- package/src/components/editor-help/images/options-dark@3x.png +0 -0
- package/src/components/editor-help/images/options-light.png +0 -0
- package/src/components/editor-help/images/options-light@2x.png +0 -0
- package/src/components/editor-help/images/options-light@3x.png +0 -0
- package/src/components/editor-help/images/rich-text-dark.png +0 -0
- package/src/components/editor-help/images/rich-text-dark@2x.png +0 -0
- package/src/components/editor-help/images/rich-text-dark@3x.png +0 -0
- package/src/components/editor-help/images/rich-text-light.png +0 -0
- package/src/components/editor-help/images/rich-text-light@2x.png +0 -0
- package/src/components/editor-help/images/rich-text-light@3x.png +0 -0
- package/src/components/editor-help/images/settings-dark.png +0 -0
- package/src/components/editor-help/images/settings-dark@2x.png +0 -0
- package/src/components/editor-help/images/settings-dark@3x.png +0 -0
- package/src/components/editor-help/images/settings-light.png +0 -0
- package/src/components/editor-help/images/settings-light@2x.png +0 -0
- package/src/components/editor-help/images/settings-light@3x.png +0 -0
- package/src/components/editor-help/index.native.js +0 -208
- package/src/components/editor-help/intro-to-blocks.native.js +0 -91
- package/src/components/editor-help/move-blocks.native.js +0 -55
- package/src/components/editor-help/remove-blocks.native.js +0 -35
- package/src/components/editor-help/style.android.scss +0 -6
- package/src/components/editor-help/style.ios.scss +0 -6
- package/src/components/editor-help/style.scss +0 -123
- package/src/components/editor-help/test/index.native.js +0 -81
- package/src/components/editor-help/view-sections.native.js +0 -79
- package/src/components/error-boundary/index.native.js +0 -192
- package/src/components/error-boundary/style.native.scss +0 -116
- package/src/components/index.native.js +0 -15
- package/src/components/offline-status/index.native.js +0 -99
- package/src/components/offline-status/style.native.scss +0 -28
- package/src/components/offline-status/test/index.native.js +0 -108
- package/src/components/post-revisions-panel/index.js +0 -161
- package/src/components/post-revisions-panel/style.scss +0 -16
- package/src/components/post-title/index.native.js +0 -282
- package/src/components/post-title/style.native.scss +0 -13
- package/src/components/post-title/test/__snapshots__/index.native.js.snap +0 -25
- package/src/components/post-title/test/index.native.js +0 -78
- package/src/components/provider/index.native.js +0 -497
- package/src/components/provider/use-block-editor-settings.native.js +0 -48
- package/src/components/revision-author-panel/index.js +0 -36
- package/src/components/revision-created-panel/index.js +0 -36
- package/src/components/template-part-menu-items/index.native.js +0 -3
- package/src/hooks/index.native.js +0 -0
- package/src/index.native.js +0 -16
- package/src/private-apis.native.js +0 -33
- package/src/store/actions.native.js +0 -27
- package/src/store/reducer.native.js +0 -94
- package/src/store/selectors.native.js +0 -57
- package/src/store/test/actions.native.js +0 -16
- package/src/store/test/reducer.native.js +0 -36
- package/src/store/test/selectors.native.js +0 -28
- package/src/utils/index.native.js +0 -6
- package/src/utils/media-sideload/index.native.js +0 -1
- package/src/utils/media-upload/index.native.js +0 -1
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/sync-connection-error-modal/index.tsx"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, select } from '@wordpress/data';\nimport { useCopyToClipboard } from '@wordpress/compose';\n// @ts-ignore No exported types.\nimport { serialize } from '@wordpress/blocks';\nimport {\n\tstore as coreDataStore,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\n// @ts-expect-error - No type declarations available for @wordpress/block-editor\n// prettier-ignore\nimport { privateApis, store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { applyFilters } from '@wordpress/hooks';\nimport { useState, useEffect } from '@wordpress/element';\nimport { __, sprintf, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetSyncErrorMessages,\n\tPROTOCOL_MISMATCH,\n} from '../../utils/sync-error-messages';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useRetryCountdown } from './use-retry-countdown';\n\nconst { BlockCanvasCover } = unlock( privateApis );\nconst { retrySyncConnection } = unlock( coreDataPrivateApis );\n\n// Debounce time for initial disconnected status to allow connection to establish.\nconst INITIAL_DISCONNECTED_DEBOUNCE_MS = 20000;\n\n/**\n * Sync connection modal that displays when any entity reports a disconnection.\n * Uses BlockCanvasCover.Fill to render in the block canvas.\n *\n * @return The modal component or null if not disconnected.\n */\nexport function SyncConnectionErrorModal() {\n\tconst [ hasInitialized, setHasInitialized ] = useState( false );\n\tconst [ showModal, setShowModal ] = useState( false );\n\tconst [ isManualRetryAvailable, setIsManualRetryAvailable ] =\n\t\tuseState( false );\n\n\tconst { connectionStatus, isCollaborationEnabled, postType } = useSelect(\n\t\t( selectFn ) => {\n\t\t\tconst { getSyncConnectionStatus, getPostType } = unlock(\n\t\t\t\tselectFn( coreDataStore )\n\t\t\t);\n\t\t\tconst { getCurrentPostType, isCollaborationEnabledForCurrentPost } =\n\t\t\t\tunlock( selectFn( editorStore ) );\n\t\t\tconst currentPostType = getCurrentPostType();\n\t\t\treturn {\n\t\t\t\tconnectionStatus: getSyncConnectionStatus() || null,\n\t\t\t\tisCollaborationEnabled: isCollaborationEnabledForCurrentPost(),\n\t\t\t\tpostType: currentPostType\n\t\t\t\t\t? getPostType( currentPostType )\n\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { onManualRetry, secondsRemaining } =\n\t\tuseRetryCountdown( connectionStatus );\n\n\tconst copyButtonRef = useCopyToClipboard( () => {\n\t\tconst blocks = select( blockEditorStore ).getBlocks();\n\t\treturn serialize( blocks );\n\t} );\n\n\t// Set hasInitialized after a debounce to give extra time on initial load.\n\tuseEffect( () => {\n\t\tconst timeout = setTimeout( () => {\n\t\t\tsetHasInitialized( true );\n\t\t}, INITIAL_DISCONNECTED_DEBOUNCE_MS );\n\n\t\treturn () => clearTimeout( timeout );\n\t}, [] );\n\n\t// Track retry availability separately from the raw connection status.\n\t// The polling manager briefly emits `{ status: 'connecting' }` without\n\t// `canManuallyRetry` when a retry is kicked off, which would otherwise\n\t// unmount the Retry button briefly.\n\tuseEffect( () => {\n\t\tif ( 'connecting' === connectionStatus?.status ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsManualRetryAvailable(\n\t\t\tconnectionStatus !== null &&\n\t\t\t\t'canManuallyRetry' in connectionStatus &&\n\t\t\t\tconnectionStatus.canManuallyRetry === true\n\t\t);\n\t}, [ connectionStatus ] );\n\n\t// Show the modal when disconnected and either retries are exhausted or\n\t// no retry is available (unrecoverable error). Hide on reconnect.\n\t// The 'connecting' state is ignored so the modal preserves its current\n\t// visibility during active retry attempts.\n\tconst canRetry =\n\t\tconnectionStatus &&\n\t\t'disconnected' === connectionStatus.status &&\n\t\t( connectionStatus.canManuallyRetry ||\n\t\t\tconnectionStatus.willAutoRetryInMs );\n\n\tuseEffect( () => {\n\t\tif ( 'connected' === connectionStatus?.status ) {\n\t\t\tsetShowModal( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tconnectionStatus?.status &&\n\t\t\t'connecting' !== connectionStatus.status &&\n\t\t\t( ! canRetry || connectionStatus.backgroundRetriesFailed )\n\t\t) {\n\t\t\tsetShowModal( true );\n\t\t}\n\t}, [ connectionStatus, canRetry ] );\n\n\t// Protocol mismatch is unrecoverable and has no in-flight connection\n\t// attempt to wait on, so delaying the modal serves no purpose.\n\tconst isProtocolMismatch =\n\t\tconnectionStatus?.status === 'disconnected' &&\n\t\t'error' in connectionStatus &&\n\t\tconnectionStatus.error?.code === PROTOCOL_MISMATCH;\n\n\tif (\n\t\t! isCollaborationEnabled ||\n\t\t( ! hasInitialized && ! isProtocolMismatch ) ||\n\t\t! showModal\n\t) {\n\t\treturn null;\n\t}\n\n\tconst error =\n\t\tconnectionStatus && 'error' in connectionStatus\n\t\t\t? connectionStatus?.error\n\t\t\t: undefined;\n\n\t// For unrecoverable errors (no retry available), allow plugins to handle\n\t// the error themselves. If a plugin returns a value other than false, it\n\t// signals that it has taken over error display and the default modal is\n\t// suppressed.\n\t//\n\t// @example\n\t// ```js\n\t// wp.hooks.addFilter(\n\t// 'editor.isSyncConnectionErrorHandled',\n\t// 'my-plugin/handle-sync-error',\n\t// ( isHandled, errorCode ) => {\n\t// if ( errorCode === 'connection-limit-exceeded' ) {\n\t// return true; // Plugin handles this error via its own UI.\n\t// }\n\t// return isHandled;\n\t// }\n\t// );\n\t// ```\n\tif (\n\t\t! canRetry &&\n\t\tapplyFilters(\n\t\t\t'editor.isSyncConnectionErrorHandled',\n\t\t\tfalse,\n\t\t\terror?.code\n\t\t) !== false\n\t) {\n\t\treturn null;\n\t}\n\n\tconst manualRetry = isManualRetryAvailable\n\t\t? () => {\n\t\t\t\tonManualRetry();\n\t\t\t\tretrySyncConnection();\n\t\t }\n\t\t: undefined;\n\n\tconst messages = getSyncErrorMessages( error );\n\n\tlet retryCountdownText: string = '';\n\tlet isRetrying = false;\n\tif ( secondsRemaining && secondsRemaining > 0 ) {\n\t\tretryCountdownText = sprintf(\n\t\t\t/* translators: %d: number of seconds until retry */\n\t\t\t_n(\n\t\t\t\t'Retrying connection in %d second\\u2026',\n\t\t\t\t'Retrying connection in %d seconds\\u2026',\n\t\t\t\tsecondsRemaining\n\t\t\t),\n\t\t\tsecondsRemaining\n\t\t);\n\t} else if ( 0 === secondsRemaining ) {\n\t\tisRetrying = true;\n\t\tretryCountdownText = __( 'Retrying\\u2026' );\n\t}\n\n\tlet editPostHref = 'edit.php';\n\tif ( postType?.slug ) {\n\t\teditPostHref = `edit.php?post_type=${ postType.slug }`;\n\t}\n\n\treturn (\n\t\t<BlockCanvasCover.Fill>\n\t\t\t<Modal\n\t\t\t\toverlayClassName=\"editor-sync-connection-error-modal\"\n\t\t\t\tisDismissible={ false }\n\t\t\t\tonRequestClose={ () => {} }\n\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t\tshouldCloseOnEsc={ false }\n\t\t\t\tsize=\"medium\"\n\t\t\t\ttitle={ messages.title }\n\t\t\t>\n\t\t\t\t<VStack spacing={ 6 }>\n\t\t\t\t\t<p>{ messages.description }</p>\n\t\t\t\t\t{ retryCountdownText && (\n\t\t\t\t\t\t<p className=\"editor-sync-connection-error-modal__retry-countdown\">\n\t\t\t\t\t\t\t{ retryCountdownText }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) }\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\thref={ editPostHref }\n\t\t\t\t\t\t\tisDestructive\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: Post type name (e.g., \"Posts\", \"Pages\"). */\n\t\t\t\t\t\t\t\t__( 'Back to %s' ),\n\t\t\t\t\t\t\t\tpostType?.labels?.name ?? __( 'Posts' )\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tref={ copyButtonRef }\n\t\t\t\t\t\t\tvariant={ manualRetry ? 'secondary' : 'primary' }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Copy Post Content' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t{ manualRetry && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t\taria-disabled={ isRetrying }\n\t\t\t\t\t\t\t\tdisabled={ isRetrying }\n\t\t\t\t\t\t\t\tisBusy={ isRetrying }\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tonClick={ manualRetry }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{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A,UACA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,KAAM;AAAA,cACN,SAAU,cAAc,cAAc;AAAA,cAEpC,aAAI,mBAAoB;AAAA;AAAA,UAC3B;AAAA,UACE,eACD;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,wBAAsB;AAAA,cACtB,iBAAgB;AAAA,cAChB,UAAW;AAAA,cACX,QAAS;AAAA,cACT,SAAQ;AAAA,cACR,SAAU;AAAA,cAER,aAAI,OAAQ;AAAA;AAAA,UACf;AAAA,WAEF;AAAA,SACD;AAAA;AAAA,EACD,GACD;AAEF;",
|
|
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
|
-
|
|
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 {
|
|
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,SAAS,oBAAoB;AACtC,SAAS,SAAS,wBAAwB;
|
|
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';\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;AAC1C,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,QAAM,qBAAqB,sBAAsB;AACjD,QAAM,iBAAiB,CAAC,CAAE,oBAAoB;AAE9C,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,UAAW,C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AAA,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
|
}
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
// packages/editor/src/components/template-actions-panel/index.js
|
|
2
|
-
import { useSelect } from "@wordpress/data";
|
|
3
|
-
import { store as editorStore } from "../../store/index.mjs";
|
|
4
2
|
import { usePostTemplatePanelMode } from "../post-template/hooks.mjs";
|
|
5
3
|
import BlockThemeContent from "./block-theme-content.mjs";
|
|
6
4
|
import ClassicThemeContent from "./classic-theme-content.mjs";
|
|
7
5
|
import { jsx } from "react/jsx-runtime";
|
|
8
6
|
function TemplateActionsPanel() {
|
|
9
|
-
const postType = useSelect(
|
|
10
|
-
(select) => select(editorStore).getCurrentPostType(),
|
|
11
|
-
[]
|
|
12
|
-
);
|
|
13
7
|
const mode = usePostTemplatePanelMode();
|
|
14
|
-
if (!["page", "post"].includes(postType)) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
8
|
if (mode === "classic") {
|
|
18
9
|
return /* @__PURE__ */ jsx(ClassicThemeContent, {});
|
|
19
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/template-actions-panel/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n *
|
|
5
|
-
"mappings": ";AAGA,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { usePostTemplatePanelMode } from '../post-template/hooks';\nimport BlockThemeContent from './block-theme-content';\nimport ClassicThemeContent from './classic-theme-content';\n\nexport default function TemplateActionsPanel() {\n\tconst mode = usePostTemplatePanelMode();\n\tif ( mode === 'classic' ) {\n\t\treturn <ClassicThemeContent />;\n\t}\n\tif ( mode === 'block-theme' ) {\n\t\treturn <BlockThemeContent />;\n\t}\n\treturn null;\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,gCAAgC;AACzC,OAAO,uBAAuB;AAC9B,OAAO,yBAAyB;AAKvB;AAHM,SAAR,uBAAwC;AAC9C,QAAM,OAAO,yBAAyB;AACtC,MAAK,SAAS,WAAY;AACzB,WAAO,oBAAC,uBAAoB;AAAA,EAC7B;AACA,MAAK,SAAS,eAAgB;AAC7B,WAAO,oBAAC,qBAAkB;AAAA,EAC3B;AACA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/template-validation-notice/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tNotice,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nexport default function TemplateValidationNotice() {\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\tconst isValid = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).isValidTemplate();\n\t}, [] );\n\tconst { setTemplateValidity, synchronizeTemplate } =\n\t\tuseDispatch( blockEditorStore );\n\n\tif ( isValid ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Notice\n\t\t\t\tclassName=\"editor-template-validation-notice\"\n\t\t\t\tisDismissible={ false }\n\t\t\t\tstatus=\"warning\"\n\t\t\t\tactions={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Keep it as is' ),\n\t\t\t\t\t\tonClick: () => setTemplateValidity( true ),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Reset the template' ),\n\t\t\t\t\t\tonClick: () => setShowConfirmDialog( true ),\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'The content of your post doesn
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tNotice,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nexport default function TemplateValidationNotice() {\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\tconst isValid = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).isValidTemplate();\n\t}, [] );\n\tconst { setTemplateValidity, synchronizeTemplate } =\n\t\tuseDispatch( blockEditorStore );\n\n\tif ( isValid ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Notice\n\t\t\t\tclassName=\"editor-template-validation-notice\"\n\t\t\t\tisDismissible={ false }\n\t\t\t\tstatus=\"warning\"\n\t\t\t\tactions={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Keep it as is' ),\n\t\t\t\t\t\tonClick: () => setTemplateValidity( true ),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Reset the template' ),\n\t\t\t\t\t\tonClick: () => setShowConfirmDialog( true ),\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'The content of your post doesn’t match the template assigned to your post type.'\n\t\t\t\t) }\n\t\t\t</Notice>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\tconfirmButtonText={ __( 'Reset' ) }\n\t\t\t\tonConfirm={ () => {\n\t\t\t\t\tsetShowConfirmDialog( false );\n\t\t\t\t\tsynchronizeTemplate();\n\t\t\t\t} }\n\t\t\t\tonCancel={ () => setShowConfirmDialog( false ) }\n\t\t\t\tsize=\"medium\"\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Resetting the template may result in loss of content, do you want to continue?'\n\t\t\t\t) }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n"],
|
|
5
5
|
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA,+BAA+B;AAAA,OACzB;AACP,SAAS,UAAU;AACnB,SAAS,aAAa,iBAAiB;AACvC,SAAS,gBAAgB;AACzB,SAAS,SAAS,wBAAwB;AAexC,mBACC,KADD;AAba,SAAR,2BAA4C;AAClD,QAAM,CAAE,mBAAmB,oBAAqB,IAAI,SAAU,KAAM;AACpE,QAAM,UAAU,UAAW,CAAE,WAAY;AACxC,WAAO,OAAQ,gBAAiB,EAAE,gBAAgB;AAAA,EACnD,GAAG,CAAC,CAAE;AACN,QAAM,EAAE,qBAAqB,oBAAoB,IAChD,YAAa,gBAAiB;AAE/B,MAAK,SAAU;AACd,WAAO;AAAA,EACR;AAEA,SACC,iCACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,eAAgB;AAAA,QAChB,QAAO;AAAA,QACP,SAAU;AAAA,UACT;AAAA,YACC,OAAO,GAAI,eAAgB;AAAA,YAC3B,SAAS,MAAM,oBAAqB,IAAK;AAAA,UAC1C;AAAA,UACA;AAAA,YACC,OAAO,GAAI,oBAAqB;AAAA,YAChC,SAAS,MAAM,qBAAsB,IAAK;AAAA,UAC3C;AAAA,QACD;AAAA,QAEE;AAAA,UACD;AAAA,QACD;AAAA;AAAA,IACD;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,QAAS;AAAA,QACT,mBAAoB,GAAI,OAAQ;AAAA,QAChC,WAAY,MAAM;AACjB,+BAAsB,KAAM;AAC5B,8BAAoB;AAAA,QACrB;AAAA,QACA,UAAW,MAAM,qBAAsB,KAAM;AAAA,QAC7C,MAAK;AAAA,QAEH;AAAA,UACD;AAAA,QACD;AAAA;AAAA,IACD;AAAA,KACD;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 = "…";
|
|
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 — %s"),
|
|
108
|
+
filename
|
|
109
|
+
) : sprintf(
|
|
110
|
+
/* translators: 1: current upload number, 2: total uploads, 3: filename. */
|
|
111
|
+
__("Uploading %1$d of %2$d — %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 = '…';\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 — 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 — 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 — %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 — %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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AQ,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,gBAAiB;AAAA,MACrB;AAAA,IACA,IACA;AAAA;AAAA,MAEA,GAAI,+BAAgC;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
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/upload-progress-snackbar/tracker.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSyncExternalStore } from '@wordpress/element';\n\n/**\n * A minimal in-memory tracker for in-flight media uploads that happen outside\n * the `@wordpress/upload-media` store (i.e. the traditional / non-CSM upload\n * path). The editor's `mediaUpload` wrapper writes to it; the\n * `UploadProgressSnackbar` reads from it.\n *\n * State shape: { total, completed, pending: string[] }\n * - `total`: total files registered in the current session.\n * - `completed`: files that have finished (succeeded OR errored).\n * - `pending`: remaining filenames in submission order.\n *\n * The tracker holds at most one \"session\" at a time — if a new batch starts\n * while one is in progress, its files are appended to the existing session.\n */\n\nlet state = null;\nconst listeners = new Set();\n\nfunction notify() {\n\tlisteners.forEach( ( listener ) => listener() );\n}\n\n/**\n * Registers a new batch of files that have started uploading.\n *\n * @param {string[]} filenames Filenames in submission order.\n */\nexport function addFiles( filenames ) {\n\tif ( ! filenames.length ) {\n\t\treturn;\n\t}\n\tif ( ! state ) {\n\t\tstate = { total: 0, completed: 0, pending: [] };\n\t}\n\tstate = {\n\t\ttotal: state.total + filenames.length,\n\t\tcompleted: state.completed,\n\t\tpending: [ ...state.pending, ...filenames ],\n\t};\n\tnotify();\n}\n\n/**\n * Advances the tracker by a number of finished files (success or error).\n *\n * @param {number} count Number of files that finished since the last call.\n */\nexport function advance( count ) {\n\tif ( ! state || count <= 0 ) {\n\t\treturn;\n\t}\n\tconst completed = Math.min( state.total, state.completed + count );\n\tconst pending = state.pending.slice( count );\n\tif ( completed >= state.total ) {\n\t\tstate = null;\n\t} else {\n\t\tstate = { total: state.total, completed, pending };\n\t}\n\tnotify();\n}\n\n/**\n * Resets the tracker to its empty state.\n *\n * Test-only helper: `state` is a module-level singleton, so tests call this in\n * `beforeEach` to isolate cases from one another. Not used in production -\n * `advance` clears the state on its own once every file in a batch finishes.\n */\nexport function reset() {\n\tif ( state === null ) {\n\t\treturn;\n\t}\n\tstate = null;\n\tnotify();\n}\n\n/**\n * Returns the current tracker state, or `null` when idle.\n *\n * @return {?{total: number, completed: number, pending: string[]}} Tracker state.\n */\nexport function getState() {\n\treturn state;\n}\n\nfunction subscribe( listener ) {\n\tlisteners.add( listener );\n\treturn () => {\n\t\tlisteners.delete( listener );\n\t};\n}\n\n/**\n * React hook that subscribes to the tracker.\n *\n * @return {?{total: number, completed: number, pending: string[]}} Tracker state.\n */\nexport function useTracker() {\n\treturn useSyncExternalStore( subscribe, getState, getState );\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,4BAA4B;AAiBrC,IAAI,QAAQ;AACZ,IAAM,YAAY,oBAAI,IAAI;AAE1B,SAAS,SAAS;AACjB,YAAU,QAAS,CAAE,aAAc,SAAS,CAAE;AAC/C;AAOO,SAAS,SAAU,WAAY;AACrC,MAAK,CAAE,UAAU,QAAS;AACzB;AAAA,EACD;AACA,MAAK,CAAE,OAAQ;AACd,YAAQ,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAAC,EAAE;AAAA,EAC/C;AACA,UAAQ;AAAA,IACP,OAAO,MAAM,QAAQ,UAAU;AAAA,IAC/B,WAAW,MAAM;AAAA,IACjB,SAAS,CAAE,GAAG,MAAM,SAAS,GAAG,SAAU;AAAA,EAC3C;AACA,SAAO;AACR;AAOO,SAAS,QAAS,OAAQ;AAChC,MAAK,CAAE,SAAS,SAAS,GAAI;AAC5B;AAAA,EACD;AACA,QAAM,YAAY,KAAK,IAAK,MAAM,OAAO,MAAM,YAAY,KAAM;AACjE,QAAM,UAAU,MAAM,QAAQ,MAAO,KAAM;AAC3C,MAAK,aAAa,MAAM,OAAQ;AAC/B,YAAQ;AAAA,EACT,OAAO;AACN,YAAQ,EAAE,OAAO,MAAM,OAAO,WAAW,QAAQ;AAAA,EAClD;AACA,SAAO;AACR;AASO,SAAS,QAAQ;AACvB,MAAK,UAAU,MAAO;AACrB;AAAA,EACD;AACA,UAAQ;AACR,SAAO;AACR;AAOO,SAAS,WAAW;AAC1B,SAAO;AACR;AAEA,SAAS,UAAW,UAAW;AAC9B,YAAU,IAAK,QAAS;AACxB,SAAO,MAAM;AACZ,cAAU,OAAQ,QAAS;AAAA,EAC5B;AACD;AAOO,SAAS,aAAa;AAC5B,SAAO,qBAAsB,WAAW,UAAU,QAAS;AAC5D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -59,7 +59,7 @@ function EditTemplateBlocksNotification({ contentRef }) {
|
|
|
59
59
|
onCancel: () => setIsDialogOpen(false),
|
|
60
60
|
size: "medium",
|
|
61
61
|
children: __(
|
|
62
|
-
"You
|
|
62
|
+
"You’ve tried to select a block that is part of a template that may be used elsewhere on your site. Would you like to edit the template?"
|
|
63
63
|
)
|
|
64
64
|
}
|
|
65
65
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/visual-editor/edit-template-blocks-notification.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Component that:\n *\n * - Displays a 'Edit your template to edit this block' notification when the\n * user is focusing on editing page content and clicks on a disabled template\n * block.\n * - Displays a 'Edit your template to edit this block' dialog when the user\n * is focusing on editing page content and double clicks on a disabled\n * template block.\n *\n * @param {Object} props\n * @param {React.RefObject<HTMLElement>} props.contentRef Ref to the block\n * editor iframe canvas.\n */\nexport default function EditTemplateBlocksNotification( { contentRef } ) {\n\tconst { onNavigateToEntityRecord, templateId } = useSelect( ( select ) => {\n\t\tconst { getEditorSettings, getCurrentTemplateId } =\n\t\t\tselect( editorStore );\n\n\t\treturn {\n\t\t\tonNavigateToEntityRecord:\n\t\t\t\tgetEditorSettings().onNavigateToEntityRecord,\n\t\t\ttemplateId: getCurrentTemplateId(),\n\t\t};\n\t}, [] );\n\n\tconst canEditTemplate = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t[]\n\t);\n\n\tconst [ isDialogOpen, setIsDialogOpen ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst handleDblClick = ( event ) => {\n\t\t\tif ( ! canEditTemplate ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t! event.target.classList.contains( 'is-root-container' ) ||\n\t\t\t\tevent.target.dataset?.type === 'core/template-part'\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! event.defaultPrevented ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetIsDialogOpen( true );\n\t\t\t}\n\t\t};\n\n\t\tconst canvas = contentRef.current;\n\t\tcanvas?.addEventListener( 'dblclick', handleDblClick );\n\t\treturn () => {\n\t\t\tcanvas?.removeEventListener( 'dblclick', handleDblClick );\n\t\t};\n\t}, [ contentRef, canEditTemplate ] );\n\n\tif ( ! canEditTemplate ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ConfirmDialog\n\t\t\tisOpen={ isDialogOpen }\n\t\t\tconfirmButtonText={ __( 'Edit template' ) }\n\t\t\tonConfirm={ () => {\n\t\t\t\tsetIsDialogOpen( false );\n\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\tpostId: templateId,\n\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonCancel={ () => setIsDialogOpen( false ) }\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t{ __(\n\t\t\t\t'You
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Component that:\n *\n * - Displays a 'Edit your template to edit this block' notification when the\n * user is focusing on editing page content and clicks on a disabled template\n * block.\n * - Displays a 'Edit your template to edit this block' dialog when the user\n * is focusing on editing page content and double clicks on a disabled\n * template block.\n *\n * @param {Object} props\n * @param {React.RefObject<HTMLElement>} props.contentRef Ref to the block\n * editor iframe canvas.\n */\nexport default function EditTemplateBlocksNotification( { contentRef } ) {\n\tconst { onNavigateToEntityRecord, templateId } = useSelect( ( select ) => {\n\t\tconst { getEditorSettings, getCurrentTemplateId } =\n\t\t\tselect( editorStore );\n\n\t\treturn {\n\t\t\tonNavigateToEntityRecord:\n\t\t\t\tgetEditorSettings().onNavigateToEntityRecord,\n\t\t\ttemplateId: getCurrentTemplateId(),\n\t\t};\n\t}, [] );\n\n\tconst canEditTemplate = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t[]\n\t);\n\n\tconst [ isDialogOpen, setIsDialogOpen ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst handleDblClick = ( event ) => {\n\t\t\tif ( ! canEditTemplate ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t! event.target.classList.contains( 'is-root-container' ) ||\n\t\t\t\tevent.target.dataset?.type === 'core/template-part'\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! event.defaultPrevented ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetIsDialogOpen( true );\n\t\t\t}\n\t\t};\n\n\t\tconst canvas = contentRef.current;\n\t\tcanvas?.addEventListener( 'dblclick', handleDblClick );\n\t\treturn () => {\n\t\t\tcanvas?.removeEventListener( 'dblclick', handleDblClick );\n\t\t};\n\t}, [ contentRef, canEditTemplate ] );\n\n\tif ( ! canEditTemplate ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ConfirmDialog\n\t\t\tisOpen={ isDialogOpen }\n\t\t\tconfirmButtonText={ __( 'Edit template' ) }\n\t\t\tonConfirm={ () => {\n\t\t\t\tsetIsDialogOpen( false );\n\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\tpostId: templateId,\n\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonCancel={ () => setIsDialogOpen( false ) }\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t{ __(\n\t\t\t\t'You’ve tried to select a block that is part of a template that may be used elsewhere on your site. Would you like to edit the template?'\n\t\t\t) }\n\t\t</ConfirmDialog>\n\t);\n}\n"],
|
|
5
5
|
"mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AACnC,SAAS,WAAW,gBAAgB;AACpC,SAAS,UAAU;AACnB,SAAS,+BAA+B,qBAAqB;AAK7D,SAAS,SAAS,mBAAmB;AAsEnC;AAtDa,SAAR,+BAAiD,EAAE,WAAW,GAAI;AACxE,QAAM,EAAE,0BAA0B,WAAW,IAAI,UAAW,CAAE,WAAY;AACzE,UAAM,EAAE,mBAAmB,qBAAqB,IAC/C,OAAQ,WAAY;AAErB,WAAO;AAAA,MACN,0BACC,kBAAkB,EAAE;AAAA,MACrB,YAAY,qBAAqB;AAAA,IAClC;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,kBAAkB;AAAA,IACvB,CAAE,WACD,CAAC,CAAE,OAAQ,SAAU,EAAE,QAAS,UAAU;AAAA,MACzC,MAAM;AAAA,MACN,MAAM;AAAA,IACP,CAAE;AAAA,IACH,CAAC;AAAA,EACF;AAEA,QAAM,CAAE,cAAc,eAAgB,IAAI,SAAU,KAAM;AAE1D,YAAW,MAAM;AAChB,UAAM,iBAAiB,CAAE,UAAW;AACnC,UAAK,CAAE,iBAAkB;AACxB;AAAA,MACD;AAEA,UACC,CAAE,MAAM,OAAO,UAAU,SAAU,mBAAoB,KACvD,MAAM,OAAO,SAAS,SAAS,sBAC9B;AACD;AAAA,MACD;AAEA,UAAK,CAAE,MAAM,kBAAmB;AAC/B,cAAM,eAAe;AACrB,wBAAiB,IAAK;AAAA,MACvB;AAAA,IACD;AAEA,UAAM,SAAS,WAAW;AAC1B,YAAQ,iBAAkB,YAAY,cAAe;AACrD,WAAO,MAAM;AACZ,cAAQ,oBAAqB,YAAY,cAAe;AAAA,IACzD;AAAA,EACD,GAAG,CAAE,YAAY,eAAgB,CAAE;AAEnC,MAAK,CAAE,iBAAkB;AACxB,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,QAAS;AAAA,MACT,mBAAoB,GAAI,eAAgB;AAAA,MACxC,WAAY,MAAM;AACjB,wBAAiB,KAAM;AACvB,iCAA0B;AAAA,UACzB,QAAQ;AAAA,UACR,UAAU;AAAA,QACX,CAAE;AAAA,MACH;AAAA,MACA,UAAW,MAAM,gBAAiB,KAAM;AAAA,MACxC,MAAK;AAAA,MAEH;AAAA,QACD;AAAA,MACD;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// packages/editor/src/dataviews/fields/revisions/index.tsx
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import RevisionsView from "./revisions-view.mjs";
|
|
4
|
+
var revisionsField = {
|
|
5
|
+
id: "revisions",
|
|
6
|
+
label: __("Revisions"),
|
|
7
|
+
readOnly: true,
|
|
8
|
+
enableSorting: false,
|
|
9
|
+
render: RevisionsView,
|
|
10
|
+
isVisible: (item) => {
|
|
11
|
+
const revisionsCount = item._links?.["version-history"]?.[0]?.count ?? 0;
|
|
12
|
+
const lastRevisionId = item._links?.["predecessor-version"]?.[0]?.id ?? null;
|
|
13
|
+
return !!lastRevisionId && revisionsCount >= 2;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var revisions_default = revisionsField;
|
|
17
|
+
export {
|
|
18
|
+
revisions_default as default
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/dataviews/fields/revisions/index.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport type { BasePost } from '@wordpress/fields';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport RevisionsView from './revisions-view';\n\nconst revisionsField: Field< BasePost > = {\n\tid: 'revisions',\n\tlabel: __( 'Revisions' ),\n\treadOnly: true,\n\tenableSorting: false,\n\trender: RevisionsView,\n\tisVisible: ( item ) => {\n\t\tconst revisionsCount =\n\t\t\titem._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\t\tconst lastRevisionId =\n\t\t\titem._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;\n\t\treturn !! lastRevisionId && revisionsCount >= 2;\n\t},\n};\n\nexport default revisionsField;\n"],
|
|
5
|
+
"mappings": ";AAKA,SAAS,UAAU;AAKnB,OAAO,mBAAmB;AAE1B,IAAM,iBAAoC;AAAA,EACzC,IAAI;AAAA,EACJ,OAAO,GAAI,WAAY;AAAA,EACvB,UAAU;AAAA,EACV,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,WAAW,CAAE,SAAU;AACtB,UAAM,iBACL,KAAK,SAAU,iBAAkB,IAAK,CAAE,GAAG,SAAS;AACrD,UAAM,iBACL,KAAK,SAAU,qBAAsB,IAAK,CAAE,GAAG,MAAM;AACtD,WAAO,CAAC,CAAE,kBAAkB,kBAAkB;AAAA,EAC/C;AACD;AAEA,IAAO,oBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// packages/editor/src/dataviews/fields/revisions/revisions-view.tsx
|
|
2
|
+
import { Button } from "@wordpress/components";
|
|
3
|
+
import { useDispatch, useSelect } from "@wordpress/data";
|
|
4
|
+
import { _n, sprintf } from "@wordpress/i18n";
|
|
5
|
+
import { addQueryArgs } from "@wordpress/url";
|
|
6
|
+
import { store as editorStore } from "../../../store/index.mjs";
|
|
7
|
+
import { unlock } from "../../../lock-unlock.mjs";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
function RevisionsView() {
|
|
10
|
+
const { lastRevisionId, revisionsCount, disableVisualRevisions } = useSelect((select) => {
|
|
11
|
+
const {
|
|
12
|
+
getCurrentPostLastRevisionId,
|
|
13
|
+
getCurrentPostRevisionsCount,
|
|
14
|
+
getEditorSettings
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
} = select(editorStore);
|
|
17
|
+
return {
|
|
18
|
+
lastRevisionId: getCurrentPostLastRevisionId(),
|
|
19
|
+
revisionsCount: getCurrentPostRevisionsCount(),
|
|
20
|
+
disableVisualRevisions: (
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
!!getEditorSettings().disableVisualRevisions
|
|
23
|
+
)
|
|
24
|
+
};
|
|
25
|
+
}, []);
|
|
26
|
+
const { setCurrentRevisionId } = unlock(useDispatch(editorStore));
|
|
27
|
+
const buttonProps = disableVisualRevisions ? {
|
|
28
|
+
href: addQueryArgs("revision.php", {
|
|
29
|
+
revision: lastRevisionId
|
|
30
|
+
})
|
|
31
|
+
} : { onClick: () => setCurrentRevisionId(lastRevisionId) };
|
|
32
|
+
return /* @__PURE__ */ jsx(
|
|
33
|
+
Button,
|
|
34
|
+
{
|
|
35
|
+
...buttonProps,
|
|
36
|
+
variant: "link",
|
|
37
|
+
text: String(revisionsCount),
|
|
38
|
+
"aria-label": sprintf(
|
|
39
|
+
/* translators: %d: number of revisions. */
|
|
40
|
+
_n(
|
|
41
|
+
"Open revisions screen: %d revision",
|
|
42
|
+
"Open revisions screen: %d revisions",
|
|
43
|
+
revisionsCount
|
|
44
|
+
),
|
|
45
|
+
revisionsCount
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
RevisionsView as default
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=revisions-view.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/dataviews/fields/revisions/revisions-view.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\n// @ts-ignore\nimport { store as editorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nexport default function RevisionsView() {\n\tconst { lastRevisionId, revisionsCount, disableVisualRevisions } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetCurrentPostLastRevisionId,\n\t\t\t\tgetCurrentPostRevisionsCount,\n\t\t\t\tgetEditorSettings,\n\t\t\t\t// @ts-ignore\n\t\t\t} = select( editorStore );\n\t\t\treturn {\n\t\t\t\tlastRevisionId: getCurrentPostLastRevisionId(),\n\t\t\t\trevisionsCount: getCurrentPostRevisionsCount(),\n\t\t\t\tdisableVisualRevisions:\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t!! getEditorSettings().disableVisualRevisions,\n\t\t\t};\n\t\t}, [] );\n\tconst { setCurrentRevisionId } = unlock( useDispatch( editorStore ) );\n\n\tconst buttonProps = disableVisualRevisions\n\t\t? {\n\t\t\t\thref: addQueryArgs( 'revision.php', {\n\t\t\t\t\trevision: lastRevisionId,\n\t\t\t\t} ),\n\t\t }\n\t\t: { onClick: () => setCurrentRevisionId( lastRevisionId ) };\n\n\treturn (\n\t\t<Button\n\t\t\t{ ...buttonProps }\n\t\t\tvariant=\"link\"\n\t\t\ttext={ String( revisionsCount ) }\n\t\t\taria-label={ sprintf(\n\t\t\t\t/* translators: %d: number of revisions. */\n\t\t\t\t_n(\n\t\t\t\t\t'Open revisions screen: %d revision',\n\t\t\t\t\t'Open revisions screen: %d revisions',\n\t\t\t\t\trevisionsCount\n\t\t\t\t),\n\t\t\t\trevisionsCount\n\t\t\t) }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,cAAc;AACvB,SAAS,aAAa,iBAAiB;AACvC,SAAS,IAAI,eAAe;AAC5B,SAAS,oBAAoB;AAM7B,SAAS,SAAS,mBAAmB;AACrC,SAAS,cAAc;AA8BrB;AA5Ba,SAAR,gBAAiC;AACvC,QAAM,EAAE,gBAAgB,gBAAgB,uBAAuB,IAC9D,UAAW,CAAE,WAAY;AACxB,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA;AAAA,IAED,IAAI,OAAQ,WAAY;AACxB,WAAO;AAAA,MACN,gBAAgB,6BAA6B;AAAA,MAC7C,gBAAgB,6BAA6B;AAAA,MAC7C;AAAA;AAAA,QAEC,CAAC,CAAE,kBAAkB,EAAE;AAAA;AAAA,IACzB;AAAA,EACD,GAAG,CAAC,CAAE;AACP,QAAM,EAAE,qBAAqB,IAAI,OAAQ,YAAa,WAAY,CAAE;AAEpE,QAAM,cAAc,yBACjB;AAAA,IACA,MAAM,aAAc,gBAAgB;AAAA,MACnC,UAAU;AAAA,IACX,CAAE;AAAA,EACF,IACA,EAAE,SAAS,MAAM,qBAAsB,cAAe,EAAE;AAE3D,SACC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACL,SAAQ;AAAA,MACR,MAAO,OAAQ,cAAe;AAAA,MAC9B,cAAa;AAAA;AAAA,QAEZ;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,QACD;AAAA,QACA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|