@wordpress/editor 14.45.2-next.v.202605131032.0 → 14.47.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 +12 -1
- package/build/components/collab-sidebar/add-note.cjs +6 -0
- package/build/components/collab-sidebar/add-note.cjs.map +2 -2
- package/build/components/collab-sidebar/hooks.cjs +36 -24
- package/build/components/collab-sidebar/hooks.cjs.map +2 -2
- package/build/components/collab-sidebar/index.cjs +19 -10
- package/build/components/collab-sidebar/index.cjs.map +2 -2
- package/build/components/collab-sidebar/note-byline.cjs +16 -9
- package/build/components/collab-sidebar/note-byline.cjs.map +2 -2
- package/build/components/collab-sidebar/notes.cjs +20 -11
- package/build/components/collab-sidebar/notes.cjs.map +2 -2
- package/build/components/collab-sidebar/utils.cjs +42 -2
- package/build/components/collab-sidebar/utils.cjs.map +2 -2
- package/build/components/collaborators-overlay/compute-selection.cjs +39 -15
- package/build/components/collaborators-overlay/compute-selection.cjs.map +3 -3
- package/build/components/collaborators-overlay/use-block-highlighting.cjs +10 -2
- package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +3 -3
- package/build/components/collaborators-overlay/use-render-cursors.cjs +15 -7
- package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
- package/build/components/collaborators-presence/avatar/component.cjs +5 -1
- package/build/components/collaborators-presence/avatar/component.cjs.map +3 -3
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs +6 -3
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +2 -2
- package/build/components/editor-interface/index.cjs +17 -16
- package/build/components/editor-interface/index.cjs.map +3 -3
- package/build/components/editor-notices/index.cjs +6 -1
- package/build/components/editor-notices/index.cjs.map +3 -3
- package/build/components/global-styles/hooks.cjs +12 -1
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/header/index.cjs +11 -6
- package/build/components/header/index.cjs.map +2 -2
- package/build/components/media/media-editor-modal.cjs +14 -1
- package/build/components/media/media-editor-modal.cjs.map +2 -2
- package/build/components/post-card-panel/index.cjs +7 -1
- package/build/components/post-card-panel/index.cjs.map +3 -3
- package/build/components/post-last-revision/index.cjs +28 -8
- package/build/components/post-last-revision/index.cjs.map +2 -2
- package/build/components/post-locked-modal/index.cjs +9 -6
- package/build/components/post-locked-modal/index.cjs.map +2 -2
- package/build/components/post-publish-button/label.cjs +0 -7
- package/build/components/post-publish-button/label.cjs.map +2 -2
- package/build/components/post-publish-panel/prepublish.cjs +8 -1
- package/build/components/post-publish-panel/prepublish.cjs.map +3 -3
- package/build/components/post-revisions-panel/index.cjs +7 -0
- package/build/components/post-revisions-panel/index.cjs.map +2 -2
- package/build/components/post-revisions-preview/diff-markers.cjs +21 -13
- package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
- package/build/components/post-revisions-preview/revisions-canvas.cjs +7 -1
- package/build/components/post-revisions-preview/revisions-canvas.cjs.map +2 -2
- package/build/components/post-taxonomies/check.cjs +1 -2
- package/build/components/post-taxonomies/check.cjs.map +2 -2
- package/build/components/post-taxonomies/index.cjs +1 -2
- package/build/components/post-taxonomies/index.cjs.map +2 -2
- package/build/components/preferences-modal/index.cjs +1 -1
- package/build/components/preferences-modal/index.cjs.map +2 -2
- package/build/components/preview-dropdown/index.cjs.map +3 -3
- package/build/components/provider/index.cjs +5 -21
- package/build/components/provider/index.cjs.map +3 -3
- package/build/components/provider/use-block-editor-settings.cjs +16 -9
- package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
- package/build/components/resizable-editor/resize-handle.cjs +24 -16
- package/build/components/resizable-editor/resize-handle.cjs.map +2 -2
- package/build/components/sidebar/header.cjs +16 -21
- package/build/components/sidebar/header.cjs.map +3 -3
- package/build/components/sidebar/index.cjs +2 -6
- package/build/components/sidebar/index.cjs.map +2 -2
- package/build/components/start-page-options/index.cjs +14 -4
- package/build/components/start-page-options/index.cjs.map +2 -2
- package/build/components/start-template-options/index.cjs +8 -6
- package/build/components/start-template-options/index.cjs.map +2 -2
- package/build/components/styles-canvas/style-book.cjs +59 -2
- package/build/components/styles-canvas/style-book.cjs.map +2 -2
- package/build/components/sync-connection-error-modal/index.cjs +10 -7
- package/build/components/sync-connection-error-modal/index.cjs.map +3 -3
- package/build/components/template-actions-panel/block-theme-content.cjs +21 -12
- package/build/components/template-actions-panel/block-theme-content.cjs.map +2 -2
- package/build/dataviews/store/private-actions.cjs.map +2 -2
- package/build/store/private-actions.cjs +17 -1
- package/build/store/private-actions.cjs.map +3 -3
- package/build/store/private-selectors.cjs +18 -0
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/selectors.cjs +0 -17
- package/build/store/selectors.cjs.map +2 -2
- package/build/{components/media → utils/media-delete}/index.cjs +12 -13
- package/build/utils/media-delete/index.cjs.map +7 -0
- package/build/utils/media-finalize/index.cjs +3 -1
- package/build/utils/media-finalize/index.cjs.map +2 -2
- package/build/utils/sync-error-messages.cjs +9 -0
- package/build/utils/sync-error-messages.cjs.map +2 -2
- package/build-module/components/collab-sidebar/add-note.mjs +6 -0
- package/build-module/components/collab-sidebar/add-note.mjs.map +2 -2
- package/build-module/components/collab-sidebar/hooks.mjs +42 -25
- package/build-module/components/collab-sidebar/hooks.mjs.map +2 -2
- package/build-module/components/collab-sidebar/index.mjs +19 -10
- package/build-module/components/collab-sidebar/index.mjs.map +2 -2
- package/build-module/components/collab-sidebar/note-byline.mjs +17 -10
- package/build-module/components/collab-sidebar/note-byline.mjs.map +2 -2
- package/build-module/components/collab-sidebar/notes.mjs +26 -13
- package/build-module/components/collab-sidebar/notes.mjs.map +2 -2
- package/build-module/components/collab-sidebar/utils.mjs +38 -2
- package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/compute-selection.mjs +36 -12
- package/build-module/components/collaborators-overlay/compute-selection.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +10 -3
- package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs +11 -6
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
- package/build-module/components/collaborators-presence/avatar/component.mjs +7 -3
- package/build-module/components/collaborators-presence/avatar/component.mjs.map +2 -2
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +6 -3
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +2 -2
- package/build-module/components/editor-interface/index.mjs +22 -17
- package/build-module/components/editor-interface/index.mjs.map +2 -2
- package/build-module/components/editor-notices/index.mjs +6 -1
- package/build-module/components/editor-notices/index.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +12 -1
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/header/index.mjs +11 -6
- package/build-module/components/header/index.mjs.map +2 -2
- package/build-module/components/media/media-editor-modal.mjs +14 -1
- package/build-module/components/media/media-editor-modal.mjs.map +2 -2
- package/build-module/components/post-card-panel/index.mjs +8 -2
- package/build-module/components/post-card-panel/index.mjs.map +2 -2
- package/build-module/components/post-last-revision/index.mjs +29 -9
- package/build-module/components/post-last-revision/index.mjs.map +2 -2
- package/build-module/components/post-locked-modal/index.mjs +9 -6
- package/build-module/components/post-locked-modal/index.mjs.map +2 -2
- package/build-module/components/post-publish-button/label.mjs +0 -7
- package/build-module/components/post-publish-button/label.mjs.map +2 -2
- package/build-module/components/post-publish-panel/prepublish.mjs +9 -2
- package/build-module/components/post-publish-panel/prepublish.mjs.map +2 -2
- package/build-module/components/post-revisions-panel/index.mjs +7 -0
- package/build-module/components/post-revisions-panel/index.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/diff-markers.mjs +22 -14
- package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/revisions-canvas.mjs +7 -1
- package/build-module/components/post-revisions-preview/revisions-canvas.mjs.map +2 -2
- package/build-module/components/post-taxonomies/check.mjs +1 -2
- package/build-module/components/post-taxonomies/check.mjs.map +2 -2
- package/build-module/components/post-taxonomies/index.mjs +1 -2
- package/build-module/components/post-taxonomies/index.mjs.map +2 -2
- package/build-module/components/preferences-modal/index.mjs +1 -1
- package/build-module/components/preferences-modal/index.mjs.map +2 -2
- package/build-module/components/preview-dropdown/index.mjs +2 -2
- package/build-module/components/preview-dropdown/index.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +6 -22
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-editor-settings.mjs +16 -9
- package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
- package/build-module/components/resizable-editor/resize-handle.mjs +26 -18
- package/build-module/components/resizable-editor/resize-handle.mjs.map +2 -2
- package/build-module/components/sidebar/header.mjs +11 -16
- package/build-module/components/sidebar/header.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs +2 -7
- package/build-module/components/sidebar/index.mjs.map +2 -2
- package/build-module/components/start-page-options/index.mjs +14 -4
- package/build-module/components/start-page-options/index.mjs.map +2 -2
- package/build-module/components/start-template-options/index.mjs +8 -6
- package/build-module/components/start-template-options/index.mjs.map +2 -2
- package/build-module/components/styles-canvas/style-book.mjs +60 -3
- package/build-module/components/styles-canvas/style-book.mjs.map +2 -2
- package/build-module/components/sync-connection-error-modal/index.mjs +14 -8
- package/build-module/components/sync-connection-error-modal/index.mjs.map +2 -2
- package/build-module/components/template-actions-panel/block-theme-content.mjs +21 -13
- package/build-module/components/template-actions-panel/block-theme-content.mjs.map +2 -2
- package/build-module/dataviews/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +16 -1
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +18 -0
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/selectors.mjs +0 -16
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/media-delete/index.mjs +12 -0
- package/build-module/utils/media-delete/index.mjs.map +7 -0
- package/build-module/utils/media-finalize/index.mjs +3 -1
- package/build-module/utils/media-finalize/index.mjs.map +2 -2
- package/build-module/utils/sync-error-messages.mjs +8 -0
- package/build-module/utils/sync-error-messages.mjs.map +2 -2
- package/build-style/style-rtl.css +462 -408
- package/build-style/style.css +462 -408
- package/build-types/components/collab-sidebar/add-note.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/note-byline.d.ts +3 -0
- package/build-types/components/collab-sidebar/note-byline.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/notes.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/utils.d.ts +33 -0
- package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/compute-selection.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts +3 -0
- 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/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -1
- package/build-types/components/editor-interface/index.d.ts.map +1 -1
- package/build-types/components/editor-notices/index.d.ts.map +1 -1
- package/build-types/components/global-styles/hooks.d.ts.map +1 -1
- package/build-types/components/media/media-editor-modal.d.ts +6 -2
- package/build-types/components/media/media-editor-modal.d.ts.map +1 -1
- package/build-types/components/post-card-panel/index.d.ts.map +1 -1
- package/build-types/components/post-last-revision/index.d.ts.map +1 -1
- package/build-types/components/post-locked-modal/index.d.ts +1 -6
- package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
- package/build-types/components/post-publish-button/label.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/prepublish.d.ts.map +1 -1
- package/build-types/components/post-revisions-panel/index.d.ts +1 -1
- package/build-types/components/post-revisions-panel/index.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-preview/revisions-canvas.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/check.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts +1 -6
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +1 -6
- package/build-types/components/post-taxonomies/index.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/resizable-editor/resize-handle.d.ts.map +1 -1
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/components/start-page-options/index.d.ts.map +1 -1
- package/build-types/components/start-template-options/index.d.ts.map +1 -1
- package/build-types/components/styles-canvas/style-book.d.ts.map +1 -1
- package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -1
- package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -1
- package/build-types/dataviews/store/private-actions.d.ts +0 -1
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts +15 -0
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +10 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +0 -10
- 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-delete/index.d.ts +2 -0
- package/build-types/utils/media-delete/index.d.ts.map +1 -0
- package/build-types/utils/media-finalize/index.d.ts +1 -1
- package/build-types/utils/media-finalize/index.d.ts.map +1 -1
- package/build-types/utils/sync-error-messages.d.ts +1 -0
- package/build-types/utils/sync-error-messages.d.ts.map +1 -1
- package/package.json +48 -48
- package/src/components/collab-sidebar/add-note.js +9 -0
- package/src/components/collab-sidebar/hooks.js +53 -29
- package/src/components/collab-sidebar/index.js +28 -14
- package/src/components/collab-sidebar/note-byline.js +15 -10
- package/src/components/collab-sidebar/notes.js +36 -14
- package/src/components/collab-sidebar/test/utils.js +375 -1
- package/src/components/collab-sidebar/utils.js +70 -1
- package/src/components/collaborators-overlay/compute-selection.ts +67 -19
- package/src/components/collaborators-overlay/use-block-highlighting.ts +14 -1
- package/src/components/collaborators-overlay/use-render-cursors.ts +15 -4
- package/src/components/collaborators-presence/avatar/component.tsx +10 -3
- package/src/components/collaborators-presence/avatar/test/index.tsx +50 -18
- package/src/components/collaborators-presence/styles/collaborators-presence.scss +4 -1
- package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +2 -1
- package/src/components/collaborators-presence/use-collaborator-notifications.ts +6 -4
- package/src/components/editor-help/help-topic-row.native.js +2 -2
- package/src/components/editor-interface/index.js +22 -23
- package/src/components/editor-interface/style.scss +4 -0
- package/src/components/editor-notices/index.js +7 -1
- package/src/components/error-boundary/index.native.js +2 -2
- package/src/components/global-styles/hooks.js +26 -0
- package/src/components/global-styles-sidebar/style.scss +0 -9
- package/src/components/header/index.js +12 -12
- package/src/components/media/media-editor-modal.js +20 -2
- package/src/components/offline-status/index.native.js +2 -2
- package/src/components/post-card-panel/index.js +5 -2
- package/src/components/post-last-revision/index.js +37 -9
- package/src/components/post-last-revision/style.scss +0 -3
- package/src/components/post-locked-modal/index.js +8 -5
- package/src/components/post-panel-row/style.scss +1 -0
- package/src/components/post-publish-button/label.js +0 -11
- package/src/components/post-publish-panel/prepublish.js +6 -2
- package/src/components/post-revisions-panel/index.js +8 -0
- package/src/components/post-revisions-preview/diff-markers.js +17 -11
- package/src/components/post-revisions-preview/revisions-canvas.js +7 -1
- package/src/components/post-revisions-preview/style.scss +4 -4
- package/src/components/post-taxonomies/check.js +1 -2
- package/src/components/post-taxonomies/index.js +1 -2
- package/src/components/preferences-modal/index.js +1 -1
- package/src/components/preview-dropdown/index.js +2 -2
- package/src/components/provider/index.js +10 -31
- package/src/components/provider/use-block-editor-settings.js +19 -12
- package/src/components/resizable-editor/resize-handle.js +22 -16
- package/src/components/sidebar/header.js +18 -28
- package/src/components/sidebar/index.js +5 -14
- package/src/components/start-page-options/index.js +19 -4
- package/src/components/start-template-options/index.js +13 -6
- package/src/components/styles-canvas/style-book.js +75 -13
- package/src/components/sync-connection-error-modal/index.tsx +25 -11
- package/src/components/template-actions-panel/block-theme-content.js +19 -13
- package/src/components/text-editor/style.scss +2 -2
- package/src/dataviews/store/private-actions.ts +0 -1
- package/src/store/private-actions.js +27 -0
- package/src/store/private-selectors.js +26 -0
- package/src/store/selectors.js +0 -24
- package/src/store/test/actions.js +34 -0
- package/src/utils/media-delete/index.js +11 -0
- package/src/utils/media-finalize/index.js +6 -1
- package/src/utils/media-finalize/test/index.js +32 -2
- package/src/utils/sync-error-messages.ts +8 -0
- package/src/utils/test/sync-error-messages.js +1 -0
- package/build/components/global-styles-provider/index.cjs +0 -181
- package/build/components/global-styles-provider/index.cjs.map +0 -7
- package/build/components/media/index.cjs.map +0 -7
- package/build/components/media/metadata-panel.cjs +0 -96
- package/build/components/media/metadata-panel.cjs.map +0 -7
- package/build/components/media/preview.cjs +0 -39
- package/build/components/media/preview.cjs.map +0 -7
- package/build-module/components/global-styles-provider/index.mjs +0 -156
- package/build-module/components/global-styles-provider/index.mjs.map +0 -7
- package/build-module/components/media/index.mjs +0 -8
- package/build-module/components/media/index.mjs.map +0 -7
- package/build-module/components/media/metadata-panel.mjs +0 -65
- package/build-module/components/media/metadata-panel.mjs.map +0 -7
- package/build-module/components/media/preview.mjs +0 -21
- package/build-module/components/media/preview.mjs.map +0 -7
- package/build-types/components/global-styles-provider/index.d.ts +0 -16
- package/build-types/components/global-styles-provider/index.d.ts.map +0 -1
- package/build-types/components/media/index.d.ts +0 -3
- package/build-types/components/media/index.d.ts.map +0 -1
- package/build-types/components/media/metadata-panel.d.ts +0 -12
- package/build-types/components/media/metadata-panel.d.ts.map +0 -1
- package/build-types/components/media/preview.d.ts +0 -9
- package/build-types/components/media/preview.d.ts.map +0 -1
- package/src/components/global-styles-provider/index.js +0 -207
- package/src/components/media/index.js +0 -2
- package/src/components/media/metadata-panel.js +0 -77
- package/src/components/media/preview.js +0 -35
|
@@ -144,9 +144,10 @@ function StartPageOptionsModal( { onClose } ) {
|
|
|
144
144
|
|
|
145
145
|
export default function StartPageOptions() {
|
|
146
146
|
const [ isOpen, setIsOpen ] = useState( false );
|
|
147
|
-
const {
|
|
147
|
+
const { isEditedPostEmpty } = useSelect( editorStore );
|
|
148
|
+
const { getEntityRecordNonTransientEdits } = useSelect( coreStore );
|
|
148
149
|
const { isModalActive } = useSelect( interfaceStore );
|
|
149
|
-
const { enabled, postId } = useSelect( ( select ) => {
|
|
150
|
+
const { enabled, postType, postId } = useSelect( ( select ) => {
|
|
150
151
|
const { getCurrentPostId, getCurrentPostType } = select( editorStore );
|
|
151
152
|
const choosePatternModalEnabled = select( preferencesStore ).get(
|
|
152
153
|
'core',
|
|
@@ -154,6 +155,7 @@ export default function StartPageOptions() {
|
|
|
154
155
|
);
|
|
155
156
|
const currentPostType = getCurrentPostType();
|
|
156
157
|
return {
|
|
158
|
+
postType: currentPostType,
|
|
157
159
|
postId: getCurrentPostId(),
|
|
158
160
|
enabled:
|
|
159
161
|
choosePatternModalEnabled &&
|
|
@@ -166,7 +168,19 @@ export default function StartPageOptions() {
|
|
|
166
168
|
// Note: The `postId` ensures the effect re-runs when pages are switched without remounting the component.
|
|
167
169
|
// Examples: changing pages in the List View, creating a new page via Command Palette.
|
|
168
170
|
useEffect( () => {
|
|
169
|
-
|
|
171
|
+
// Read non-transient edits directly. `isEditedPostDirty` /
|
|
172
|
+
// `hasEditsForEntityRecord` also return true while the CRDT
|
|
173
|
+
// sync manager's phantom save (fired off `receiveEntityRecords`
|
|
174
|
+
// at boot) is in flight, which would suppress the modal.
|
|
175
|
+
const hasEdits =
|
|
176
|
+
Object.keys(
|
|
177
|
+
getEntityRecordNonTransientEdits(
|
|
178
|
+
'postType',
|
|
179
|
+
postType,
|
|
180
|
+
postId
|
|
181
|
+
) ?? {}
|
|
182
|
+
).length > 0;
|
|
183
|
+
const isFreshPage = ! hasEdits && isEditedPostEmpty();
|
|
170
184
|
// Prevents immediately opening when features is enabled via preferences modal.
|
|
171
185
|
const isPreferencesModalActive = isModalActive( 'editor/preferences' );
|
|
172
186
|
if ( ! enabled || ! isFreshPage || isPreferencesModalActive ) {
|
|
@@ -177,8 +191,9 @@ export default function StartPageOptions() {
|
|
|
177
191
|
setIsOpen( true );
|
|
178
192
|
}, [
|
|
179
193
|
enabled,
|
|
194
|
+
postType,
|
|
180
195
|
postId,
|
|
181
|
-
|
|
196
|
+
getEntityRecordNonTransientEdits,
|
|
182
197
|
isEditedPostEmpty,
|
|
183
198
|
isModalActive,
|
|
184
199
|
] );
|
|
@@ -173,18 +173,25 @@ export default function StartTemplateOptions() {
|
|
|
173
173
|
select( editorStore );
|
|
174
174
|
const _postType = getCurrentPostType();
|
|
175
175
|
const _postId = getCurrentPostId();
|
|
176
|
-
const { getEditedEntityRecord,
|
|
176
|
+
const { getEditedEntityRecord, getEntityRecordNonTransientEdits } =
|
|
177
177
|
select( coreStore );
|
|
178
178
|
const templateRecord = getEditedEntityRecord(
|
|
179
179
|
'postType',
|
|
180
180
|
_postType,
|
|
181
181
|
_postId
|
|
182
182
|
);
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
183
|
+
// Read non-transient edits directly. `isEditedPostDirty` /
|
|
184
|
+
// `hasEditsForEntityRecord` also return true while the CRDT
|
|
185
|
+
// sync manager's phantom save (fired off `receiveEntityRecords`
|
|
186
|
+
// at boot) is in flight, which would suppress the modal.
|
|
187
|
+
const hasEdits =
|
|
188
|
+
Object.keys(
|
|
189
|
+
getEntityRecordNonTransientEdits(
|
|
190
|
+
'postType',
|
|
191
|
+
_postType,
|
|
192
|
+
_postId
|
|
193
|
+
) ?? {}
|
|
194
|
+
).length > 0;
|
|
188
195
|
|
|
189
196
|
return {
|
|
190
197
|
shouldOpenModal:
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { forwardRef } from '@wordpress/element';
|
|
4
|
+
import { useMemo, forwardRef } from '@wordpress/element';
|
|
5
|
+
import { useGlobalStylesRevisions } from '@wordpress/global-styles-ui';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
9
10
|
import StyleBook from '../style-book';
|
|
10
11
|
import { STYLE_BOOK_COLOR_GROUPS } from '../style-book/constants';
|
|
12
|
+
import { useGlobalStyles } from '../global-styles/hooks';
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* @param {Function} props.onPathChange Callback when the path changes.
|
|
19
|
-
* @param {React.ForwardedRef} ref Ref to the Style Book component.
|
|
20
|
-
* @return {React.JSX.Element} The Style Book component.
|
|
21
|
-
*/
|
|
22
|
-
function StylesCanvasStyleBook( { path, onPathChange }, ref ) {
|
|
14
|
+
function StyleBookWithNavigation( {
|
|
15
|
+
path,
|
|
16
|
+
onPathChange,
|
|
17
|
+
userConfig,
|
|
18
|
+
forwardedRef,
|
|
19
|
+
} ) {
|
|
23
20
|
return (
|
|
24
21
|
<StyleBook
|
|
25
|
-
ref={
|
|
22
|
+
ref={ forwardedRef }
|
|
23
|
+
path={ path }
|
|
24
|
+
userConfig={ userConfig }
|
|
26
25
|
isSelected={ ( blockName ) =>
|
|
27
26
|
// Match '/blocks/core%2Fbutton' and
|
|
28
27
|
// '/blocks/core%2Fbutton/typography', but not
|
|
@@ -54,4 +53,67 @@ function StylesCanvasStyleBook( { path, onPathChange }, ref ) {
|
|
|
54
53
|
/>
|
|
55
54
|
);
|
|
56
55
|
}
|
|
56
|
+
|
|
57
|
+
function StylesCanvasRevisionStyleBook( { path, onPathChange, forwardedRef } ) {
|
|
58
|
+
const { user: userConfig } = useGlobalStyles();
|
|
59
|
+
const { revisions, isLoading } = useGlobalStylesRevisions();
|
|
60
|
+
|
|
61
|
+
const revisionId = useMemo( () => {
|
|
62
|
+
const match = path?.match( /^\/revisions\/(.+)$/ );
|
|
63
|
+
return match ? match[ 1 ] : null;
|
|
64
|
+
}, [ path ] );
|
|
65
|
+
|
|
66
|
+
const selectedRevision = useMemo( () => {
|
|
67
|
+
if ( ! revisionId || ! revisions.length ) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return revisions.find(
|
|
71
|
+
( revision ) => String( revision.id ) === String( revisionId )
|
|
72
|
+
);
|
|
73
|
+
}, [ revisionId, revisions ] );
|
|
74
|
+
|
|
75
|
+
if ( isLoading ) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<StyleBookWithNavigation
|
|
81
|
+
forwardedRef={ forwardedRef }
|
|
82
|
+
path={ path }
|
|
83
|
+
onPathChange={ onPathChange }
|
|
84
|
+
userConfig={ selectedRevision || userConfig }
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Style Book content component for global styles.
|
|
91
|
+
* Provides the business logic for StyleBook behavior in the global styles context.
|
|
92
|
+
*
|
|
93
|
+
* @param {Object} props Component props.
|
|
94
|
+
* @param {string} props.path Current path in global styles.
|
|
95
|
+
* @param {Function} props.onPathChange Callback when the path changes.
|
|
96
|
+
* @param {React.ForwardedRef} ref Ref to the Style Book component.
|
|
97
|
+
* @return {React.JSX.Element} The Style Book component.
|
|
98
|
+
*/
|
|
99
|
+
function StylesCanvasStyleBook( { path, onPathChange }, ref ) {
|
|
100
|
+
if ( path?.startsWith( '/revisions' ) ) {
|
|
101
|
+
return (
|
|
102
|
+
<StylesCanvasRevisionStyleBook
|
|
103
|
+
forwardedRef={ ref }
|
|
104
|
+
path={ path }
|
|
105
|
+
onPathChange={ onPathChange }
|
|
106
|
+
/>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<StyleBookWithNavigation
|
|
112
|
+
forwardedRef={ ref }
|
|
113
|
+
path={ path }
|
|
114
|
+
onPathChange={ onPathChange }
|
|
115
|
+
/>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
57
119
|
export default forwardRef( StylesCanvasStyleBook );
|
|
@@ -25,7 +25,10 @@ import { __, sprintf, _n } from '@wordpress/i18n';
|
|
|
25
25
|
/**
|
|
26
26
|
* Internal dependencies
|
|
27
27
|
*/
|
|
28
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
getSyncErrorMessages,
|
|
30
|
+
PROTOCOL_MISMATCH,
|
|
31
|
+
} from '../../utils/sync-error-messages';
|
|
29
32
|
import { store as editorStore } from '../../store';
|
|
30
33
|
import { unlock } from '../../lock-unlock';
|
|
31
34
|
import { useRetryCountdown } from './use-retry-countdown';
|
|
@@ -50,17 +53,17 @@ export function SyncConnectionErrorModal() {
|
|
|
50
53
|
|
|
51
54
|
const { connectionStatus, isCollaborationEnabled, postType } = useSelect(
|
|
52
55
|
( selectFn ) => {
|
|
53
|
-
const
|
|
54
|
-
selectFn(
|
|
56
|
+
const { getSyncConnectionStatus, getPostType } = unlock(
|
|
57
|
+
selectFn( coreDataStore )
|
|
58
|
+
);
|
|
59
|
+
const { getCurrentPostType, isCollaborationEnabledForCurrentPost } =
|
|
60
|
+
unlock( selectFn( editorStore ) );
|
|
61
|
+
const currentPostType = getCurrentPostType();
|
|
55
62
|
return {
|
|
56
|
-
connectionStatus:
|
|
57
|
-
|
|
58
|
-
isCollaborationEnabled:
|
|
59
|
-
selectFn(
|
|
60
|
-
editorStore
|
|
61
|
-
).isCollaborationEnabledForCurrentPost(),
|
|
63
|
+
connectionStatus: getSyncConnectionStatus() || null,
|
|
64
|
+
isCollaborationEnabled: isCollaborationEnabledForCurrentPost(),
|
|
62
65
|
postType: currentPostType
|
|
63
|
-
?
|
|
66
|
+
? getPostType( currentPostType )
|
|
64
67
|
: null,
|
|
65
68
|
};
|
|
66
69
|
},
|
|
@@ -125,7 +128,18 @@ export function SyncConnectionErrorModal() {
|
|
|
125
128
|
}
|
|
126
129
|
}, [ connectionStatus, canRetry ] );
|
|
127
130
|
|
|
128
|
-
|
|
131
|
+
// Protocol mismatch is unrecoverable and has no in-flight connection
|
|
132
|
+
// attempt to wait on, so delaying the modal serves no purpose.
|
|
133
|
+
const isProtocolMismatch =
|
|
134
|
+
connectionStatus?.status === 'disconnected' &&
|
|
135
|
+
'error' in connectionStatus &&
|
|
136
|
+
connectionStatus.error?.code === PROTOCOL_MISMATCH;
|
|
137
|
+
|
|
138
|
+
if (
|
|
139
|
+
! isCollaborationEnabled ||
|
|
140
|
+
( ! hasInitialized && ! isProtocolMismatch ) ||
|
|
141
|
+
! showModal
|
|
142
|
+
) {
|
|
129
143
|
return null;
|
|
130
144
|
}
|
|
131
145
|
|
|
@@ -11,7 +11,6 @@ import { BlockPreview } from '@wordpress/block-editor';
|
|
|
11
11
|
import {
|
|
12
12
|
PanelBody,
|
|
13
13
|
Button,
|
|
14
|
-
Tooltip,
|
|
15
14
|
__experimentalHStack as HStack,
|
|
16
15
|
__experimentalVStack as VStack,
|
|
17
16
|
} from '@wordpress/components';
|
|
@@ -20,6 +19,8 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
20
19
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
21
20
|
import { store as noticesStore } from '@wordpress/notices';
|
|
22
21
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
22
|
+
// eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.
|
|
23
|
+
import { Tooltip } from '@wordpress/ui';
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Internal dependencies
|
|
@@ -117,18 +118,23 @@ export default function TemplateActionsPanelContent() {
|
|
|
117
118
|
if ( hasSwapTargets ) {
|
|
118
119
|
const tooltipText = __( 'Change template' );
|
|
119
120
|
return (
|
|
120
|
-
<Tooltip
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
121
|
+
<Tooltip.Root>
|
|
122
|
+
<Tooltip.Trigger
|
|
123
|
+
render={
|
|
124
|
+
<div
|
|
125
|
+
className="editor-template-actions-panel__preview"
|
|
126
|
+
role="button"
|
|
127
|
+
tabIndex={ 0 }
|
|
128
|
+
aria-label={ tooltipText }
|
|
129
|
+
onClick={ () => setIsSwapModalOpen( true ) }
|
|
130
|
+
onKeyPress={ () => setIsSwapModalOpen( true ) }
|
|
131
|
+
>
|
|
132
|
+
{ previewContent }
|
|
133
|
+
</div>
|
|
134
|
+
}
|
|
135
|
+
/>
|
|
136
|
+
<Tooltip.Popup>{ tooltipText }</Tooltip.Popup>
|
|
137
|
+
</Tooltip.Root>
|
|
132
138
|
);
|
|
133
139
|
}
|
|
134
140
|
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
@use "@wordpress/base-styles/colors" as *;
|
|
3
3
|
@use "@wordpress/base-styles/mixins" as *;
|
|
4
4
|
@use "@wordpress/base-styles/variables" as *;
|
|
5
|
-
@use "@wordpress/base-styles/z-index" as *;
|
|
6
5
|
|
|
7
6
|
.editor-text-editor {
|
|
8
7
|
@include reset;
|
|
9
8
|
position: relative;
|
|
9
|
+
isolation: isolate;
|
|
10
10
|
width: 100%;
|
|
11
11
|
background-color: $white;
|
|
12
12
|
flex-grow: 1;
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
// Exit code editor toolbar.
|
|
54
54
|
.editor-text-editor__toolbar {
|
|
55
55
|
position: sticky;
|
|
56
|
-
z-index:
|
|
56
|
+
z-index: 1;
|
|
57
57
|
top: 0;
|
|
58
58
|
left: 0;
|
|
59
59
|
right: 0;
|
|
@@ -17,8 +17,35 @@ import { dateI18n, getSettings as getDateSettings } from '@wordpress/date';
|
|
|
17
17
|
*/
|
|
18
18
|
import isTemplateRevertable from './utils/is-template-revertable';
|
|
19
19
|
import { buildRevisionsPageQuery } from './private-selectors';
|
|
20
|
+
import { unlock } from '../lock-unlock';
|
|
20
21
|
export * from '../dataviews/store/private-actions';
|
|
21
22
|
|
|
23
|
+
const DEVICE_TYPE_BY_VIEWPORT_STATE = {
|
|
24
|
+
mobile: 'Mobile',
|
|
25
|
+
tablet: 'Tablet',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Updates the editor preview device in response to a block-editor viewport
|
|
30
|
+
* state signal.
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} options Viewport state change options.
|
|
33
|
+
* @param {string} options.viewport Selected viewport state.
|
|
34
|
+
* @param {boolean} options.showStateOnCanvas Whether canvas preview is enabled.
|
|
35
|
+
*/
|
|
36
|
+
export const updateDeviceTypeForViewportState =
|
|
37
|
+
( { viewport = 'default', showStateOnCanvas = true } = {} ) =>
|
|
38
|
+
( { dispatch, registry } ) => {
|
|
39
|
+
if ( ! showStateOnCanvas ) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
dispatch.setDeviceType(
|
|
44
|
+
DEVICE_TYPE_BY_VIEWPORT_STATE[ viewport ] ?? 'Desktop'
|
|
45
|
+
);
|
|
46
|
+
unlock( registry.dispatch( blockEditorStore ) ).resetZoomLevel();
|
|
47
|
+
};
|
|
48
|
+
|
|
22
49
|
/**
|
|
23
50
|
* Returns an action object used to set which template is currently being used/edited.
|
|
24
51
|
*
|
|
@@ -24,6 +24,7 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
24
24
|
import {
|
|
25
25
|
getRenderingMode,
|
|
26
26
|
getCurrentPost,
|
|
27
|
+
getCurrentPostType,
|
|
27
28
|
getEditorSettings,
|
|
28
29
|
getCurrentPostRevisionsCount,
|
|
29
30
|
} from './selectors';
|
|
@@ -33,6 +34,7 @@ import {
|
|
|
33
34
|
isEntityReady as _isEntityReady,
|
|
34
35
|
} from '../dataviews/store/private-selectors';
|
|
35
36
|
import { getTemplatePartIcon } from '../utils';
|
|
37
|
+
import { unlock } from '../lock-unlock';
|
|
36
38
|
|
|
37
39
|
const EMPTY_INSERTION_POINT = {
|
|
38
40
|
rootClientId: undefined,
|
|
@@ -582,3 +584,27 @@ export const getPreviousRevision = createRegistrySelector(
|
|
|
582
584
|
return null;
|
|
583
585
|
}
|
|
584
586
|
);
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Returns whether the collaboration is enabled for the current post.
|
|
590
|
+
*
|
|
591
|
+
* @return {boolean} Whether collaboration is enabled.
|
|
592
|
+
*/
|
|
593
|
+
export const isCollaborationEnabledForCurrentPost = createRegistrySelector(
|
|
594
|
+
( select ) => ( state ) => {
|
|
595
|
+
// Return early, if collaboration is not supported.
|
|
596
|
+
if ( ! unlock( select( coreStore ) ).isCollaborationSupported() ) {
|
|
597
|
+
return false;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
const currentPostType = getCurrentPostType( state );
|
|
601
|
+
const entityConfig = select( coreStore ).getEntityConfig(
|
|
602
|
+
'postType',
|
|
603
|
+
currentPostType
|
|
604
|
+
);
|
|
605
|
+
|
|
606
|
+
return Boolean(
|
|
607
|
+
entityConfig?.syncConfig && window._wpCollaborationEnabled
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
);
|
package/src/store/selectors.js
CHANGED
|
@@ -1885,27 +1885,3 @@ export const getPostTypeLabel = createRegistrySelector(
|
|
|
1885
1885
|
export function isPublishSidebarOpened( state ) {
|
|
1886
1886
|
return state.publishSidebarActive;
|
|
1887
1887
|
}
|
|
1888
|
-
|
|
1889
|
-
/**
|
|
1890
|
-
* Returns whether the collaboration is enabled for the current post.
|
|
1891
|
-
*
|
|
1892
|
-
* @return {boolean} Whether collaboration is enabled.
|
|
1893
|
-
*/
|
|
1894
|
-
export const isCollaborationEnabledForCurrentPost = createRegistrySelector(
|
|
1895
|
-
( select ) => ( state ) => {
|
|
1896
|
-
// Return early, if collaboration is not supported.
|
|
1897
|
-
if ( ! unlock( select( coreStore ) ).isCollaborationSupported() ) {
|
|
1898
|
-
return false;
|
|
1899
|
-
}
|
|
1900
|
-
|
|
1901
|
-
const currentPostType = getCurrentPostType( state );
|
|
1902
|
-
const entityConfig = select( coreStore ).getEntityConfig(
|
|
1903
|
-
'postType',
|
|
1904
|
-
currentPostType
|
|
1905
|
-
);
|
|
1906
|
-
|
|
1907
|
-
return Boolean(
|
|
1908
|
-
entityConfig?.syncConfig && window._wpCollaborationEnabled
|
|
1909
|
-
);
|
|
1910
|
-
}
|
|
1911
|
-
);
|
|
@@ -14,6 +14,7 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
14
14
|
|
|
15
15
|
import * as actions from '../actions';
|
|
16
16
|
import { store as editorStore } from '..';
|
|
17
|
+
import { unlock } from '../../lock-unlock';
|
|
17
18
|
|
|
18
19
|
const postId = 44;
|
|
19
20
|
|
|
@@ -63,6 +64,39 @@ const getMethod = ( options ) =>
|
|
|
63
64
|
options.headers?.[ 'X-HTTP-Method-Override' ] || options.method || 'GET';
|
|
64
65
|
|
|
65
66
|
describe( 'Post actions', () => {
|
|
67
|
+
describe( 'updateDeviceTypeForViewportState', () => {
|
|
68
|
+
it( 'updates the editor device type for a viewport state', () => {
|
|
69
|
+
const registry = createRegistryWithStores();
|
|
70
|
+
|
|
71
|
+
unlock(
|
|
72
|
+
registry.dispatch( editorStore )
|
|
73
|
+
).updateDeviceTypeForViewportState( {
|
|
74
|
+
viewport: 'mobile',
|
|
75
|
+
showStateOnCanvas: true,
|
|
76
|
+
} );
|
|
77
|
+
|
|
78
|
+
expect( registry.select( editorStore ).getDeviceType() ).toBe(
|
|
79
|
+
'Mobile'
|
|
80
|
+
);
|
|
81
|
+
} );
|
|
82
|
+
|
|
83
|
+
it( 'keeps the editor device type when canvas preview is disabled', () => {
|
|
84
|
+
const registry = createRegistryWithStores();
|
|
85
|
+
registry.dispatch( editorStore ).setDeviceType( 'Tablet' );
|
|
86
|
+
|
|
87
|
+
unlock(
|
|
88
|
+
registry.dispatch( editorStore )
|
|
89
|
+
).updateDeviceTypeForViewportState( {
|
|
90
|
+
viewport: 'mobile',
|
|
91
|
+
showStateOnCanvas: false,
|
|
92
|
+
} );
|
|
93
|
+
|
|
94
|
+
expect( registry.select( editorStore ).getDeviceType() ).toBe(
|
|
95
|
+
'Tablet'
|
|
96
|
+
);
|
|
97
|
+
} );
|
|
98
|
+
} );
|
|
99
|
+
|
|
66
100
|
describe( 'savePost()', () => {
|
|
67
101
|
it( 'saves a modified post', async () => {
|
|
68
102
|
const post = {
|
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import apiFetch from '@wordpress/api-fetch';
|
|
5
|
+
import { transformAttachment } from '@wordpress/media-utils';
|
|
5
6
|
|
|
6
7
|
export default async function mediaFinalize( id, subSizes = [] ) {
|
|
7
|
-
await apiFetch( {
|
|
8
|
+
const response = await apiFetch( {
|
|
8
9
|
path: `/wp/v2/media/${ id }/finalize`,
|
|
9
10
|
method: 'POST',
|
|
10
11
|
data: { sub_sizes: subSizes },
|
|
11
12
|
} );
|
|
13
|
+
|
|
14
|
+
// Returning the post-finalize attachment lets callers refresh the block
|
|
15
|
+
// URL (via onChange) so it points at the scaled file and srcset matches.
|
|
16
|
+
return response ? transformAttachment( response ) : undefined;
|
|
12
17
|
}
|
|
@@ -10,13 +10,21 @@ import mediaFinalize from '..';
|
|
|
10
10
|
|
|
11
11
|
jest.mock( '@wordpress/api-fetch', () => jest.fn() );
|
|
12
12
|
|
|
13
|
+
const mockRestAttachment = {
|
|
14
|
+
id: 123,
|
|
15
|
+
alt_text: '',
|
|
16
|
+
caption: { raw: '' },
|
|
17
|
+
title: { raw: '' },
|
|
18
|
+
source_url: 'https://example.com/wp-content/uploads/image-scaled.jpg',
|
|
19
|
+
};
|
|
20
|
+
|
|
13
21
|
describe( 'mediaFinalize', () => {
|
|
14
22
|
beforeEach( () => {
|
|
15
23
|
jest.clearAllMocks();
|
|
16
24
|
} );
|
|
17
25
|
|
|
18
26
|
it( 'should call the finalize endpoint with the correct path, method, and sub_sizes', async () => {
|
|
19
|
-
apiFetch.mockResolvedValue(
|
|
27
|
+
apiFetch.mockResolvedValue( mockRestAttachment );
|
|
20
28
|
|
|
21
29
|
const subSizes = [
|
|
22
30
|
{
|
|
@@ -39,7 +47,7 @@ describe( 'mediaFinalize', () => {
|
|
|
39
47
|
} );
|
|
40
48
|
|
|
41
49
|
it( 'should send empty sub_sizes array by default', async () => {
|
|
42
|
-
apiFetch.mockResolvedValue(
|
|
50
|
+
apiFetch.mockResolvedValue( mockRestAttachment );
|
|
43
51
|
|
|
44
52
|
await mediaFinalize( 123 );
|
|
45
53
|
|
|
@@ -50,6 +58,28 @@ describe( 'mediaFinalize', () => {
|
|
|
50
58
|
} );
|
|
51
59
|
} );
|
|
52
60
|
|
|
61
|
+
it( 'should return the transformed attachment with the scaled URL so the block can pick up srcset', async () => {
|
|
62
|
+
apiFetch.mockResolvedValue( mockRestAttachment );
|
|
63
|
+
|
|
64
|
+
const result = await mediaFinalize( 123 );
|
|
65
|
+
|
|
66
|
+
// transformAttachment maps source_url -> url, which is the key the
|
|
67
|
+
// block stores. Without this mapping, the block keeps the original
|
|
68
|
+
// (pre-finalize) URL and wp_calculate_image_srcset() emits no srcset.
|
|
69
|
+
expect( result ).toMatchObject( {
|
|
70
|
+
id: 123,
|
|
71
|
+
url: 'https://example.com/wp-content/uploads/image-scaled.jpg',
|
|
72
|
+
} );
|
|
73
|
+
} );
|
|
74
|
+
|
|
75
|
+
it( 'should return undefined when the response is empty', async () => {
|
|
76
|
+
apiFetch.mockResolvedValue( undefined );
|
|
77
|
+
|
|
78
|
+
const result = await mediaFinalize( 123 );
|
|
79
|
+
|
|
80
|
+
expect( result ).toBeUndefined();
|
|
81
|
+
} );
|
|
82
|
+
|
|
53
83
|
it( 'should propagate errors from apiFetch', async () => {
|
|
54
84
|
apiFetch.mockRejectedValue( new Error( 'Network error' ) );
|
|
55
85
|
|
|
@@ -10,6 +10,7 @@ export const AUTHENTICATION_FAILED = 'authentication-failed';
|
|
|
10
10
|
export const CONNECTION_EXPIRED = 'connection-expired';
|
|
11
11
|
export const CONNECTION_LIMIT_EXCEEDED = 'connection-limit-exceeded';
|
|
12
12
|
export const DOCUMENT_SIZE_LIMIT_EXCEEDED = 'document-size-limit-exceeded';
|
|
13
|
+
export const PROTOCOL_MISMATCH = 'protocol-mismatch';
|
|
13
14
|
export const UNKNOWN_ERROR = 'unknown-error';
|
|
14
15
|
|
|
15
16
|
interface ConnectionErrorMessages {
|
|
@@ -42,6 +43,13 @@ const ERROR_MESSAGES: Record< string, ConnectionErrorMessages > = {
|
|
|
42
43
|
'Try again later or contact your site administrator.'
|
|
43
44
|
),
|
|
44
45
|
},
|
|
46
|
+
[ PROTOCOL_MISMATCH ]: {
|
|
47
|
+
title: __( 'Protocol update' ),
|
|
48
|
+
description: __(
|
|
49
|
+
'Real-time collaboration has been updated. ' +
|
|
50
|
+
'Please refresh the page to continue editing.'
|
|
51
|
+
),
|
|
52
|
+
},
|
|
45
53
|
// DOCUMENT_SIZE_LIMIT_EXCEEDED is not included here because it results in
|
|
46
54
|
// collaboration being disabled entirely.
|
|
47
55
|
[ UNKNOWN_ERROR ]: {
|
|
@@ -9,6 +9,7 @@ describe( 'getSyncErrorMessages', () => {
|
|
|
9
9
|
'connection-expired',
|
|
10
10
|
'connection-limit-exceeded',
|
|
11
11
|
'document-size-limit-exceeded',
|
|
12
|
+
'protocol-mismatch',
|
|
12
13
|
'unknown-error',
|
|
13
14
|
] )( 'should return title and description for "%s"', ( code ) => {
|
|
14
15
|
const result = getSyncErrorMessages( { code } );
|