@wordpress/editor 14.41.2-next.v.202603161435.0 → 14.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -1
- package/build/components/collaborators-overlay/compute-selection.cjs +10 -10
- package/build/components/collaborators-overlay/compute-selection.cjs.map +2 -2
- package/build/components/collaborators-overlay/cursor-registry.cjs +86 -0
- package/build/components/collaborators-overlay/cursor-registry.cjs.map +7 -0
- package/build/components/collaborators-overlay/index.cjs +7 -2
- package/build/components/collaborators-overlay/index.cjs.map +2 -2
- package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +1 -1
- package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +2 -2
- package/build/components/collaborators-overlay/overlay.cjs +42 -1
- package/build/components/collaborators-overlay/overlay.cjs.map +2 -2
- package/build/components/collaborators-overlay/timing-utils.cjs +46 -0
- package/build/components/collaborators-overlay/timing-utils.cjs.map +7 -0
- package/build/components/collaborators-overlay/use-render-cursors.cjs +1 -1
- package/build/components/collaborators-overlay/use-render-cursors.cjs.map +2 -2
- package/build/components/collaborators-presence/index.cjs +14 -4
- package/build/components/collaborators-presence/index.cjs.map +2 -2
- package/build/components/collaborators-presence/list.cjs +20 -4
- package/build/components/collaborators-presence/list.cjs.map +2 -2
- package/build/components/post-card-panel/index.cjs +4 -15
- package/build/components/post-card-panel/index.cjs.map +2 -2
- package/build/components/post-content-information/index.cjs +10 -13
- package/build/components/post-content-information/index.cjs.map +2 -2
- package/build/components/post-locked-modal/index.cjs +16 -3
- package/build/components/post-locked-modal/index.cjs.map +2 -2
- package/build/components/post-revisions-panel/index.cjs +164 -0
- package/build/components/post-revisions-panel/index.cjs.map +7 -0
- package/build/components/post-revisions-preview/block-diff.cjs +39 -11
- package/build/components/post-revisions-preview/block-diff.cjs.map +2 -2
- package/build/components/post-revisions-preview/diff-markers.cjs +2 -2
- package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
- package/build/components/post-revisions-preview/revisions-canvas.cjs +1 -1
- package/build/components/post-revisions-preview/revisions-canvas.cjs.map +2 -2
- package/build/components/post-revisions-preview/revisions-slider.cjs +24 -5
- package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
- package/build/components/post-template/block-theme.cjs +7 -4
- package/build/components/post-template/block-theme.cjs.map +2 -2
- package/build/components/post-template/create-new-template-modal.cjs +39 -46
- package/build/components/post-template/create-new-template-modal.cjs.map +2 -2
- package/build/components/post-template/hooks.cjs +91 -8
- package/build/components/post-template/hooks.cjs.map +2 -2
- package/build/components/post-template/panel.cjs +5 -42
- package/build/components/post-template/panel.cjs.map +3 -3
- package/build/components/post-template/swap-template-button.cjs +31 -20
- package/build/components/post-template/swap-template-button.cjs.map +2 -2
- package/build/components/preferences-modal/index.cjs +35 -27
- package/build/components/preferences-modal/index.cjs.map +2 -2
- package/build/components/provider/use-block-editor-settings.cjs +2 -0
- package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
- package/build/components/revision-block-diff/index.cjs +61 -0
- package/build/components/revision-block-diff/index.cjs.map +7 -0
- package/build/components/revision-diff-panel/index.cjs +68 -0
- package/build/components/revision-diff-panel/index.cjs.map +7 -0
- package/build/components/revision-fields-diff/index.cjs +96 -0
- package/build/components/revision-fields-diff/index.cjs.map +7 -0
- package/build/components/sidebar/dataform-post-summary.cjs +25 -55
- package/build/components/sidebar/dataform-post-summary.cjs.map +2 -2
- package/build/components/sidebar/index.cjs +30 -23
- package/build/components/sidebar/index.cjs.map +3 -3
- package/build/components/sidebar/post-revision-summary.cjs +74 -0
- package/build/components/sidebar/post-revision-summary.cjs.map +7 -0
- package/build/components/sidebar/post-summary.cjs +35 -42
- package/build/components/sidebar/post-summary.cjs.map +3 -3
- package/build/components/style-book/index.cjs +4 -3
- package/build/components/style-book/index.cjs.map +2 -2
- package/build/components/{sync-connection-modal → sync-connection-error-modal}/index.cjs +89 -80
- package/build/components/sync-connection-error-modal/index.cjs.map +7 -0
- package/build/components/{sync-connection-modal → sync-connection-error-modal}/use-retry-countdown.cjs +14 -27
- package/build/components/sync-connection-error-modal/use-retry-countdown.cjs.map +7 -0
- package/build/components/template-actions-panel/block-theme-content.cjs +188 -0
- package/build/components/template-actions-panel/block-theme-content.cjs.map +7 -0
- package/build/components/template-actions-panel/classic-theme-content.cjs +159 -0
- package/build/components/template-actions-panel/classic-theme-content.cjs.map +7 -0
- package/build/components/template-actions-panel/index.cjs +59 -0
- package/build/components/template-actions-panel/index.cjs.map +7 -0
- package/build/components/visual-editor/index.cjs +2 -2
- package/build/components/visual-editor/index.cjs.map +2 -2
- package/build/dataviews/store/private-actions.cjs +2 -0
- package/build/dataviews/store/private-actions.cjs.map +2 -2
- package/build/store/actions.cjs +1 -3
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-actions.cjs +21 -2
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +40 -15
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/utils/media-finalize/index.cjs +43 -0
- package/build/utils/media-finalize/index.cjs.map +7 -0
- package/build/utils/sync-error-messages.cjs +29 -16
- package/build/utils/sync-error-messages.cjs.map +3 -3
- package/build-module/components/collaborators-overlay/compute-selection.mjs +10 -10
- package/build-module/components/collaborators-overlay/compute-selection.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/cursor-registry.mjs +61 -0
- package/build-module/components/collaborators-overlay/cursor-registry.mjs.map +7 -0
- package/build-module/components/collaborators-overlay/index.mjs +7 -2
- package/build-module/components/collaborators-overlay/index.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +1 -1
- package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/overlay.mjs +43 -2
- package/build-module/components/collaborators-overlay/overlay.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/timing-utils.mjs +21 -0
- package/build-module/components/collaborators-overlay/timing-utils.mjs.map +7 -0
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs +1 -1
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
- package/build-module/components/collaborators-presence/index.mjs +14 -4
- package/build-module/components/collaborators-presence/index.mjs.map +2 -2
- package/build-module/components/collaborators-presence/list.mjs +20 -4
- package/build-module/components/collaborators-presence/list.mjs.map +2 -2
- package/build-module/components/post-card-panel/index.mjs +6 -17
- package/build-module/components/post-card-panel/index.mjs.map +2 -2
- package/build-module/components/post-content-information/index.mjs +6 -13
- package/build-module/components/post-content-information/index.mjs.map +2 -2
- package/build-module/components/post-locked-modal/index.mjs +16 -3
- package/build-module/components/post-locked-modal/index.mjs.map +2 -2
- package/build-module/components/post-revisions-panel/index.mjs +139 -0
- package/build-module/components/post-revisions-panel/index.mjs.map +7 -0
- package/build-module/components/post-revisions-preview/block-diff.mjs +39 -11
- package/build-module/components/post-revisions-preview/block-diff.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/diff-markers.mjs +2 -2
- package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/revisions-canvas.mjs +1 -1
- package/build-module/components/post-revisions-preview/revisions-canvas.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/revisions-slider.mjs +24 -5
- package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
- package/build-module/components/post-template/block-theme.mjs +7 -4
- package/build-module/components/post-template/block-theme.mjs.map +2 -2
- package/build-module/components/post-template/create-new-template-modal.mjs +39 -46
- package/build-module/components/post-template/create-new-template-modal.mjs.map +2 -2
- package/build-module/components/post-template/hooks.mjs +90 -8
- package/build-module/components/post-template/hooks.mjs.map +2 -2
- package/build-module/components/post-template/panel.mjs +5 -42
- package/build-module/components/post-template/panel.mjs.map +2 -2
- package/build-module/components/post-template/swap-template-button.mjs +27 -20
- package/build-module/components/post-template/swap-template-button.mjs.map +2 -2
- package/build-module/components/preferences-modal/index.mjs +35 -27
- package/build-module/components/preferences-modal/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-editor-settings.mjs +2 -0
- package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
- package/build-module/components/revision-block-diff/index.mjs +30 -0
- package/build-module/components/revision-block-diff/index.mjs.map +7 -0
- package/build-module/components/revision-diff-panel/index.mjs +37 -0
- package/build-module/components/revision-diff-panel/index.mjs.map +7 -0
- package/build-module/components/revision-fields-diff/index.mjs +65 -0
- package/build-module/components/revision-fields-diff/index.mjs.map +7 -0
- package/build-module/components/sidebar/dataform-post-summary.mjs +25 -55
- package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs +30 -23
- package/build-module/components/sidebar/index.mjs.map +2 -2
- package/build-module/components/sidebar/post-revision-summary.mjs +43 -0
- package/build-module/components/sidebar/post-revision-summary.mjs.map +7 -0
- package/build-module/components/sidebar/post-summary.mjs +31 -42
- package/build-module/components/sidebar/post-summary.mjs.map +2 -2
- package/build-module/components/style-book/index.mjs +4 -3
- package/build-module/components/style-book/index.mjs.map +2 -2
- package/build-module/components/sync-connection-error-modal/index.mjs +177 -0
- package/build-module/components/sync-connection-error-modal/index.mjs.map +7 -0
- package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs +36 -0
- package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs.map +7 -0
- package/build-module/components/template-actions-panel/block-theme-content.mjs +167 -0
- package/build-module/components/template-actions-panel/block-theme-content.mjs.map +7 -0
- package/build-module/components/template-actions-panel/classic-theme-content.mjs +138 -0
- package/build-module/components/template-actions-panel/classic-theme-content.mjs.map +7 -0
- package/build-module/components/template-actions-panel/index.mjs +28 -0
- package/build-module/components/template-actions-panel/index.mjs.map +7 -0
- package/build-module/components/visual-editor/index.mjs +2 -2
- package/build-module/components/visual-editor/index.mjs.map +2 -2
- package/build-module/dataviews/store/private-actions.mjs +5 -1
- package/build-module/dataviews/store/private-actions.mjs.map +2 -2
- package/build-module/store/actions.mjs +1 -3
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +21 -2
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +40 -15
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/utils/media-finalize/index.mjs +12 -0
- package/build-module/utils/media-finalize/index.mjs.map +7 -0
- package/build-module/utils/sync-error-messages.mjs +24 -16
- package/build-module/utils/sync-error-messages.mjs.map +3 -3
- package/build-style/style-rtl.css +135 -50
- package/build-style/style.css +135 -50
- package/build-types/components/collaborators-overlay/cursor-registry.d.ts +36 -0
- package/build-types/components/collaborators-overlay/cursor-registry.d.ts.map +1 -0
- package/build-types/components/collaborators-overlay/index.d.ts +7 -4
- package/build-types/components/collaborators-overlay/index.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts +1 -1
- package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/overlay.d.ts +4 -1
- package/build-types/components/collaborators-overlay/overlay.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/timing-utils.d.ts +11 -0
- package/build-types/components/collaborators-overlay/timing-utils.d.ts.map +1 -0
- package/build-types/components/collaborators-presence/index.d.ts.map +1 -1
- package/build-types/components/collaborators-presence/list.d.ts +4 -1
- package/build-types/components/collaborators-presence/list.d.ts.map +1 -1
- package/build-types/components/post-card-panel/index.d.ts.map +1 -1
- package/build-types/components/post-content-information/index.d.ts +4 -1
- package/build-types/components/post-content-information/index.d.ts.map +1 -1
- package/build-types/components/post-locked-modal/index.d.ts +2 -2
- package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
- package/build-types/components/post-revisions-panel/index.d.ts +2 -0
- package/build-types/components/post-revisions-panel/index.d.ts.map +1 -0
- package/build-types/components/post-revisions-preview/block-diff.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
- package/build-types/components/post-template/block-theme.d.ts +1 -3
- package/build-types/components/post-template/block-theme.d.ts.map +1 -1
- package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
- package/build-types/components/post-template/hooks.d.ts +2 -1
- package/build-types/components/post-template/hooks.d.ts.map +1 -1
- package/build-types/components/post-template/panel.d.ts.map +1 -1
- package/build-types/components/post-template/swap-template-button.d.ts +4 -0
- package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/revision-block-diff/index.d.ts +6 -0
- package/build-types/components/revision-block-diff/index.d.ts.map +1 -0
- package/build-types/components/revision-diff-panel/index.d.ts +14 -0
- package/build-types/components/revision-diff-panel/index.d.ts.map +1 -0
- package/build-types/components/revision-fields-diff/index.d.ts +6 -0
- package/build-types/components/revision-fields-diff/index.d.ts.map +1 -0
- 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 +2 -0
- package/build-types/components/sidebar/post-revision-summary.d.ts.map +1 -0
- package/build-types/components/sidebar/post-summary.d.ts +3 -0
- package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
- package/build-types/components/style-book/index.d.ts +2 -1
- package/build-types/components/style-book/index.d.ts.map +1 -1
- package/build-types/components/sync-connection-error-modal/index.d.ts +22 -0
- package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -0
- package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts +11 -0
- package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts.map +1 -0
- package/build-types/components/template-actions-panel/block-theme-content.d.ts +2 -0
- package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -0
- package/build-types/components/template-actions-panel/classic-theme-content.d.ts +2 -0
- package/build-types/components/template-actions-panel/classic-theme-content.d.ts.map +1 -0
- package/build-types/components/template-actions-panel/index.d.ts +2 -0
- package/build-types/components/template-actions-panel/index.d.ts.map +1 -0
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/utils/media-finalize/index.d.ts +2 -0
- package/build-types/utils/media-finalize/index.d.ts.map +1 -0
- package/build-types/utils/sync-error-messages.d.ts +17 -3
- package/build-types/utils/sync-error-messages.d.ts.map +1 -1
- package/package.json +45 -44
- package/src/components/collaborators-overlay/compute-selection.ts +13 -13
- package/src/components/collaborators-overlay/cursor-registry.ts +96 -0
- package/src/components/collaborators-overlay/index.tsx +12 -4
- package/src/components/collaborators-overlay/overlay-iframe-styles.ts +1 -1
- package/src/components/collaborators-overlay/overlay.tsx +64 -1
- package/src/components/collaborators-overlay/timing-utils.ts +30 -0
- package/src/components/collaborators-overlay/use-render-cursors.ts +1 -1
- package/src/components/collaborators-presence/index.tsx +9 -1
- package/src/components/collaborators-presence/list.tsx +25 -1
- package/src/components/post-card-panel/index.js +7 -21
- package/src/components/post-content-information/index.js +5 -16
- package/src/components/post-locked-modal/index.js +21 -3
- package/src/components/post-revisions-panel/index.js +151 -0
- package/src/components/post-revisions-panel/style.scss +16 -0
- package/src/components/post-revisions-preview/block-diff.js +59 -20
- package/src/components/post-revisions-preview/diff-markers.js +2 -2
- package/src/components/post-revisions-preview/revisions-canvas.js +1 -1
- package/src/components/post-revisions-preview/revisions-slider.js +29 -7
- package/src/components/post-revisions-preview/test/block-diff.js +69 -31
- package/src/components/post-template/block-theme.js +4 -1
- package/src/components/post-template/create-new-template-modal.js +1 -4
- package/src/components/post-template/hooks.js +107 -9
- package/src/components/post-template/panel.js +5 -59
- package/src/components/post-template/style.scss +0 -6
- package/src/components/post-template/swap-template-button.js +30 -21
- package/src/components/preferences-modal/index.js +37 -25
- package/src/components/provider/use-block-editor-settings.js +2 -0
- package/src/components/revision-block-diff/index.js +39 -0
- package/src/components/revision-diff-panel/index.js +59 -0
- package/src/components/revision-diff-panel/style.scss +13 -0
- package/src/components/revision-fields-diff/index.js +91 -0
- package/src/components/sidebar/dataform-post-summary.js +45 -68
- package/src/components/sidebar/index.js +35 -22
- package/src/components/sidebar/post-revision-summary.js +50 -0
- package/src/components/sidebar/post-summary.js +22 -40
- package/src/components/sidebar/style.scss +7 -0
- package/src/components/style-book/index.js +4 -2
- package/src/components/sync-connection-error-modal/index.tsx +265 -0
- package/src/components/sync-connection-error-modal/style.scss +14 -0
- package/src/components/sync-connection-error-modal/use-retry-countdown.ts +57 -0
- package/src/components/template-actions-panel/block-theme-content.js +196 -0
- package/src/components/template-actions-panel/classic-theme-content.js +170 -0
- package/src/components/template-actions-panel/index.js +32 -0
- package/src/components/template-actions-panel/style.scss +39 -0
- package/src/components/visual-editor/index.js +2 -2
- package/src/dataviews/store/private-actions.ts +6 -0
- package/src/store/actions.js +1 -4
- package/src/store/private-actions.js +24 -3
- package/src/store/private-selectors.js +46 -16
- package/src/style.scss +4 -1
- package/src/utils/media-finalize/index.js +11 -0
- package/src/utils/media-finalize/test/index.js +34 -0
- package/src/utils/sync-error-messages.ts +72 -0
- package/src/utils/test/sync-error-messages.js +9 -32
- package/build/components/sync-connection-modal/index.cjs.map +0 -7
- package/build/components/sync-connection-modal/use-retry-countdown.cjs.map +0 -7
- package/build-module/components/sync-connection-modal/index.mjs +0 -170
- package/build-module/components/sync-connection-modal/index.mjs.map +0 -7
- package/build-module/components/sync-connection-modal/use-retry-countdown.mjs +0 -49
- package/build-module/components/sync-connection-modal/use-retry-countdown.mjs.map +0 -7
- package/build-types/components/sync-connection-modal/index.d.ts +0 -8
- package/build-types/components/sync-connection-modal/index.d.ts.map +0 -1
- package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts +0 -9
- package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts.map +0 -1
- package/src/components/sync-connection-modal/index.js +0 -206
- package/src/components/sync-connection-modal/style.scss +0 -14
- package/src/components/sync-connection-modal/use-retry-countdown.js +0 -70
- package/src/utils/sync-error-messages.js +0 -58
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
@use "@wordpress/base-styles/colors" as *;
|
|
2
|
+
@use "@wordpress/base-styles/z-index" as *;
|
|
3
|
+
|
|
4
|
+
.editor-sync-connection-error-modal {
|
|
5
|
+
z-index: z-index(".editor-sync-connection-error-modal");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.editor-sync-connection-error-modal p {
|
|
9
|
+
margin: 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.editor-sync-connection-error-modal__retry-countdown {
|
|
13
|
+
color: $gray-700;
|
|
14
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ConnectionStatus } from '@wordpress/core-data';
|
|
5
|
+
import { useState, useEffect } from '@wordpress/element';
|
|
6
|
+
|
|
7
|
+
interface UseRetryCountdownResult {
|
|
8
|
+
onManualRetry: () => void;
|
|
9
|
+
secondsRemaining?: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function useRetryCountdown(
|
|
13
|
+
connectionStatus?: ConnectionStatus | null
|
|
14
|
+
): UseRetryCountdownResult {
|
|
15
|
+
const [ secondsRemaining, setSecondsRemaining ] = useState< number >();
|
|
16
|
+
|
|
17
|
+
useEffect( () => {
|
|
18
|
+
if ( ! connectionStatus ) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Only clear countdown when explicitly connected.
|
|
23
|
+
if ( 'connected' === connectionStatus.status ) {
|
|
24
|
+
setSecondsRemaining( undefined );
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// For transient states (e.g. 'connecting' during a retry attempt)
|
|
29
|
+
// or when retryInMs is not yet available, keep the previous
|
|
30
|
+
// countdown value to avoid a brief flash.
|
|
31
|
+
if (
|
|
32
|
+
'disconnected' !== connectionStatus.status ||
|
|
33
|
+
! connectionStatus.willAutoRetryInMs
|
|
34
|
+
) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const { willAutoRetryInMs: retryInMs } = connectionStatus;
|
|
39
|
+
const retryAt = Date.now() + retryInMs;
|
|
40
|
+
setSecondsRemaining( Math.ceil( retryInMs / 1000 ) );
|
|
41
|
+
|
|
42
|
+
const intervalId = setInterval( () => {
|
|
43
|
+
const remaining = Math.ceil( ( retryAt - Date.now() ) / 1000 );
|
|
44
|
+
setSecondsRemaining( Math.max( 0, remaining ) );
|
|
45
|
+
if ( remaining <= 0 ) {
|
|
46
|
+
clearInterval( intervalId );
|
|
47
|
+
}
|
|
48
|
+
}, 1000 );
|
|
49
|
+
|
|
50
|
+
return () => clearInterval( intervalId );
|
|
51
|
+
}, [ connectionStatus ] );
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
onManualRetry: () => setSecondsRemaining( 0 ),
|
|
55
|
+
secondsRemaining,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import {
|
|
6
|
+
useEntityRecord,
|
|
7
|
+
useEntityBlockEditor,
|
|
8
|
+
store as coreStore,
|
|
9
|
+
} from '@wordpress/core-data';
|
|
10
|
+
import { BlockPreview } from '@wordpress/block-editor';
|
|
11
|
+
import {
|
|
12
|
+
PanelBody,
|
|
13
|
+
Button,
|
|
14
|
+
Tooltip,
|
|
15
|
+
__experimentalHStack as HStack,
|
|
16
|
+
__experimentalVStack as VStack,
|
|
17
|
+
} from '@wordpress/components';
|
|
18
|
+
import { useState } from '@wordpress/element';
|
|
19
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
20
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
21
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
22
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Internal dependencies
|
|
26
|
+
*/
|
|
27
|
+
import { store as editorStore } from '../../store';
|
|
28
|
+
import CreateNewTemplateModal from '../post-template/create-new-template-modal';
|
|
29
|
+
import { SwapTemplateModal } from '../post-template/swap-template-button';
|
|
30
|
+
import { useAvailableTemplates } from '../post-template/hooks';
|
|
31
|
+
|
|
32
|
+
export default function TemplateActionsPanelContent() {
|
|
33
|
+
const templateId = useSelect(
|
|
34
|
+
( select ) => select( editorStore ).getCurrentTemplateId(),
|
|
35
|
+
[]
|
|
36
|
+
);
|
|
37
|
+
const [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );
|
|
38
|
+
const [ isSwapModalOpen, setIsSwapModalOpen ] = useState( false );
|
|
39
|
+
|
|
40
|
+
const availableTemplates = useAvailableTemplates();
|
|
41
|
+
const hasSwapTargets = !! availableTemplates?.length;
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
onNavigateToEntityRecord,
|
|
45
|
+
canCreateTemplate,
|
|
46
|
+
hasGoBack,
|
|
47
|
+
getEditorSettings,
|
|
48
|
+
} = useSelect( ( select ) => {
|
|
49
|
+
const { getEditorSettings: _getEditorSettings } = select( editorStore );
|
|
50
|
+
const editorSettings = _getEditorSettings();
|
|
51
|
+
return {
|
|
52
|
+
onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
|
|
53
|
+
canCreateTemplate: !! select( coreStore ).canUser( 'create', {
|
|
54
|
+
kind: 'postType',
|
|
55
|
+
name: 'wp_template',
|
|
56
|
+
} ),
|
|
57
|
+
hasGoBack: editorSettings.hasOwnProperty(
|
|
58
|
+
'onNavigateToPreviousEntityRecord'
|
|
59
|
+
),
|
|
60
|
+
getEditorSettings: _getEditorSettings,
|
|
61
|
+
};
|
|
62
|
+
}, [] );
|
|
63
|
+
|
|
64
|
+
const { get: getPreference } = useSelect( preferencesStore );
|
|
65
|
+
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
66
|
+
|
|
67
|
+
const { editedRecord: template, hasResolved } = useEntityRecord(
|
|
68
|
+
'postType',
|
|
69
|
+
'wp_template',
|
|
70
|
+
templateId
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const [ blocks ] = useEntityBlockEditor( 'postType', 'wp_template', {
|
|
74
|
+
id: templateId,
|
|
75
|
+
} );
|
|
76
|
+
|
|
77
|
+
if ( ! hasResolved ) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing
|
|
82
|
+
// and assigns its own backlink to focusMode pages.
|
|
83
|
+
const notificationAction = hasGoBack
|
|
84
|
+
? [
|
|
85
|
+
{
|
|
86
|
+
label: __( 'Go back' ),
|
|
87
|
+
onClick: () =>
|
|
88
|
+
getEditorSettings().onNavigateToPreviousEntityRecord(),
|
|
89
|
+
},
|
|
90
|
+
]
|
|
91
|
+
: undefined;
|
|
92
|
+
|
|
93
|
+
const mayShowTemplateEditNotice = () => {
|
|
94
|
+
if ( ! getPreference( 'core/edit-site', 'welcomeGuideTemplate' ) ) {
|
|
95
|
+
createSuccessNotice(
|
|
96
|
+
__(
|
|
97
|
+
'Editing template. Changes made here affect all posts and pages that use the template.'
|
|
98
|
+
),
|
|
99
|
+
{ type: 'snackbar', actions: notificationAction }
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const templateName = decodeEntities( template.title );
|
|
105
|
+
|
|
106
|
+
const previewContent = !! blocks?.length && (
|
|
107
|
+
<BlockPreview.Async>
|
|
108
|
+
<BlockPreview blocks={ blocks } />
|
|
109
|
+
</BlockPreview.Async>
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const renderPreview = () => {
|
|
113
|
+
if ( ! previewContent ) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if ( hasSwapTargets ) {
|
|
118
|
+
const tooltipText = __( 'Change template' );
|
|
119
|
+
return (
|
|
120
|
+
<Tooltip text={ tooltipText }>
|
|
121
|
+
<div
|
|
122
|
+
className="editor-template-actions-panel__preview"
|
|
123
|
+
role="button"
|
|
124
|
+
tabIndex={ 0 }
|
|
125
|
+
aria-label={ tooltipText }
|
|
126
|
+
onClick={ () => setIsSwapModalOpen( true ) }
|
|
127
|
+
onKeyPress={ () => setIsSwapModalOpen( true ) }
|
|
128
|
+
>
|
|
129
|
+
{ previewContent }
|
|
130
|
+
</div>
|
|
131
|
+
</Tooltip>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<div className="editor-template-actions-panel__preview">
|
|
137
|
+
{ previewContent }
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<>
|
|
144
|
+
<PanelBody
|
|
145
|
+
title={ sprintf(
|
|
146
|
+
/* translators: %s: template name */
|
|
147
|
+
__( 'Template: %s' ),
|
|
148
|
+
templateName
|
|
149
|
+
) }
|
|
150
|
+
initialOpen={ false }
|
|
151
|
+
>
|
|
152
|
+
<VStack>
|
|
153
|
+
{ renderPreview() }
|
|
154
|
+
<HStack>
|
|
155
|
+
{ onNavigateToEntityRecord && (
|
|
156
|
+
<Button
|
|
157
|
+
className="editor-template-actions-panel__action"
|
|
158
|
+
__next40pxDefaultSize
|
|
159
|
+
variant="secondary"
|
|
160
|
+
onClick={ () => {
|
|
161
|
+
onNavigateToEntityRecord( {
|
|
162
|
+
postId: template.id,
|
|
163
|
+
postType: 'wp_template',
|
|
164
|
+
} );
|
|
165
|
+
mayShowTemplateEditNotice();
|
|
166
|
+
} }
|
|
167
|
+
>
|
|
168
|
+
{ __( 'Edit' ) }
|
|
169
|
+
</Button>
|
|
170
|
+
) }
|
|
171
|
+
{ canCreateTemplate && (
|
|
172
|
+
<Button
|
|
173
|
+
className="editor-template-actions-panel__action"
|
|
174
|
+
__next40pxDefaultSize
|
|
175
|
+
variant="secondary"
|
|
176
|
+
onClick={ () => setIsCreateModalOpen( true ) }
|
|
177
|
+
>
|
|
178
|
+
{ __( 'Create new' ) }
|
|
179
|
+
</Button>
|
|
180
|
+
) }
|
|
181
|
+
</HStack>
|
|
182
|
+
</VStack>
|
|
183
|
+
</PanelBody>
|
|
184
|
+
{ isCreateModalOpen && (
|
|
185
|
+
<CreateNewTemplateModal
|
|
186
|
+
onClose={ () => setIsCreateModalOpen( false ) }
|
|
187
|
+
/>
|
|
188
|
+
) }
|
|
189
|
+
{ isSwapModalOpen && (
|
|
190
|
+
<SwapTemplateModal
|
|
191
|
+
onRequestClose={ () => setIsSwapModalOpen( false ) }
|
|
192
|
+
/>
|
|
193
|
+
) }
|
|
194
|
+
</>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import {
|
|
6
|
+
useEntityRecord,
|
|
7
|
+
useEntityBlockEditor,
|
|
8
|
+
store as coreStore,
|
|
9
|
+
} from '@wordpress/core-data';
|
|
10
|
+
import { BlockPreview } from '@wordpress/block-editor';
|
|
11
|
+
import {
|
|
12
|
+
PanelBody,
|
|
13
|
+
Button,
|
|
14
|
+
__experimentalText as Text,
|
|
15
|
+
__experimentalHStack as HStack,
|
|
16
|
+
__experimentalVStack as VStack,
|
|
17
|
+
} from '@wordpress/components';
|
|
18
|
+
import { useState } from '@wordpress/element';
|
|
19
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
20
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
21
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
22
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Internal dependencies
|
|
26
|
+
*/
|
|
27
|
+
import { store as editorStore } from '../../store';
|
|
28
|
+
import CreateNewTemplateModal from '../post-template/create-new-template-modal';
|
|
29
|
+
|
|
30
|
+
export default function ClassicThemeContent() {
|
|
31
|
+
const templateId = useSelect(
|
|
32
|
+
( select ) => select( editorStore ).getCurrentTemplateId(),
|
|
33
|
+
[]
|
|
34
|
+
);
|
|
35
|
+
const [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );
|
|
36
|
+
const {
|
|
37
|
+
onNavigateToEntityRecord,
|
|
38
|
+
canCreateTemplate,
|
|
39
|
+
hasGoBack,
|
|
40
|
+
getEditorSettings,
|
|
41
|
+
} = useSelect( ( select ) => {
|
|
42
|
+
const { getEditorSettings: _getEditorSettings } = select( editorStore );
|
|
43
|
+
const editorSettings = _getEditorSettings();
|
|
44
|
+
return {
|
|
45
|
+
onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
|
|
46
|
+
canCreateTemplate:
|
|
47
|
+
!! select( coreStore ).canUser( 'create', {
|
|
48
|
+
kind: 'postType',
|
|
49
|
+
name: 'wp_template',
|
|
50
|
+
} ) && editorSettings.supportsTemplateMode,
|
|
51
|
+
hasGoBack: editorSettings.hasOwnProperty(
|
|
52
|
+
'onNavigateToPreviousEntityRecord'
|
|
53
|
+
),
|
|
54
|
+
getEditorSettings: _getEditorSettings,
|
|
55
|
+
};
|
|
56
|
+
}, [] );
|
|
57
|
+
const { get: getPreference } = useSelect( preferencesStore );
|
|
58
|
+
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
59
|
+
const { editedRecord: template } = useEntityRecord(
|
|
60
|
+
'postType',
|
|
61
|
+
'wp_template',
|
|
62
|
+
templateId
|
|
63
|
+
);
|
|
64
|
+
const [ blocks ] = useEntityBlockEditor( 'postType', 'wp_template', {
|
|
65
|
+
id: templateId,
|
|
66
|
+
} );
|
|
67
|
+
|
|
68
|
+
// Path A: No block template and cannot create templates.
|
|
69
|
+
if ( ! templateId && ! canCreateTemplate ) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const notificationAction = hasGoBack
|
|
74
|
+
? [
|
|
75
|
+
{
|
|
76
|
+
label: __( 'Go back' ),
|
|
77
|
+
onClick: () =>
|
|
78
|
+
getEditorSettings().onNavigateToPreviousEntityRecord(),
|
|
79
|
+
},
|
|
80
|
+
]
|
|
81
|
+
: undefined;
|
|
82
|
+
|
|
83
|
+
const mayShowTemplateEditNotice = () => {
|
|
84
|
+
if ( ! getPreference( 'core/edit-site', 'welcomeGuideTemplate' ) ) {
|
|
85
|
+
createSuccessNotice(
|
|
86
|
+
__(
|
|
87
|
+
'Editing template. Changes made here affect all posts and pages that use the template.'
|
|
88
|
+
),
|
|
89
|
+
{ type: 'snackbar', actions: notificationAction }
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const templateName = template
|
|
95
|
+
? decodeEntities( template.title )
|
|
96
|
+
: undefined;
|
|
97
|
+
|
|
98
|
+
const previewContent = !! blocks?.length && (
|
|
99
|
+
<BlockPreview.Async>
|
|
100
|
+
<BlockPreview blocks={ blocks } />
|
|
101
|
+
</BlockPreview.Async>
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<>
|
|
106
|
+
<PanelBody
|
|
107
|
+
title={
|
|
108
|
+
template
|
|
109
|
+
? sprintf(
|
|
110
|
+
/* translators: %s: template name */
|
|
111
|
+
__( 'Template: %s' ),
|
|
112
|
+
templateName
|
|
113
|
+
)
|
|
114
|
+
: __( 'Template' )
|
|
115
|
+
}
|
|
116
|
+
initialOpen={ false }
|
|
117
|
+
>
|
|
118
|
+
<VStack>
|
|
119
|
+
{ ! templateId && (
|
|
120
|
+
<Text>
|
|
121
|
+
{ __(
|
|
122
|
+
'This page uses a classic template. To edit this template with blocks, create a block template.'
|
|
123
|
+
) }
|
|
124
|
+
</Text>
|
|
125
|
+
) }
|
|
126
|
+
{ template && previewContent && (
|
|
127
|
+
<div className="editor-template-actions-panel__preview">
|
|
128
|
+
{ previewContent }
|
|
129
|
+
</div>
|
|
130
|
+
) }
|
|
131
|
+
<HStack>
|
|
132
|
+
{ template && onNavigateToEntityRecord && (
|
|
133
|
+
<Button
|
|
134
|
+
className="editor-template-actions-panel__action"
|
|
135
|
+
__next40pxDefaultSize
|
|
136
|
+
variant="secondary"
|
|
137
|
+
onClick={ () => {
|
|
138
|
+
onNavigateToEntityRecord( {
|
|
139
|
+
postId: template.id,
|
|
140
|
+
postType: 'wp_template',
|
|
141
|
+
} );
|
|
142
|
+
mayShowTemplateEditNotice();
|
|
143
|
+
} }
|
|
144
|
+
>
|
|
145
|
+
{ __( 'Edit' ) }
|
|
146
|
+
</Button>
|
|
147
|
+
) }
|
|
148
|
+
{ canCreateTemplate && (
|
|
149
|
+
<Button
|
|
150
|
+
className="editor-template-actions-panel__action"
|
|
151
|
+
__next40pxDefaultSize
|
|
152
|
+
variant="secondary"
|
|
153
|
+
onClick={ () => setIsCreateModalOpen( true ) }
|
|
154
|
+
>
|
|
155
|
+
{ ! templateId
|
|
156
|
+
? __( 'Create block template' )
|
|
157
|
+
: __( 'Create new' ) }
|
|
158
|
+
</Button>
|
|
159
|
+
) }
|
|
160
|
+
</HStack>
|
|
161
|
+
</VStack>
|
|
162
|
+
</PanelBody>
|
|
163
|
+
{ isCreateModalOpen && (
|
|
164
|
+
<CreateNewTemplateModal
|
|
165
|
+
onClose={ () => setIsCreateModalOpen( false ) }
|
|
166
|
+
/>
|
|
167
|
+
) }
|
|
168
|
+
</>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { store as editorStore } from '../../store';
|
|
10
|
+
import { usePostTemplatePanelMode } from '../post-template/hooks';
|
|
11
|
+
import BlockThemeContent from './block-theme-content';
|
|
12
|
+
import ClassicThemeContent from './classic-theme-content';
|
|
13
|
+
|
|
14
|
+
export default function TemplateActionsPanel() {
|
|
15
|
+
const postType = useSelect(
|
|
16
|
+
( select ) => select( editorStore ).getCurrentPostType(),
|
|
17
|
+
[]
|
|
18
|
+
);
|
|
19
|
+
const mode = usePostTemplatePanelMode();
|
|
20
|
+
// This check is because the experiment is gated for these post
|
|
21
|
+
// types for now. Later we should use `postType.viewable`.
|
|
22
|
+
if ( ! [ 'page', 'post' ].includes( postType ) ) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
if ( mode === 'classic' ) {
|
|
26
|
+
return <ClassicThemeContent />;
|
|
27
|
+
}
|
|
28
|
+
if ( mode === 'block-theme' ) {
|
|
29
|
+
return <BlockThemeContent />;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
@use "@wordpress/base-styles/variables" as *;
|
|
2
|
+
@use "@wordpress/base-styles/colors" as *;
|
|
3
|
+
|
|
4
|
+
.editor-template-actions-panel__preview {
|
|
5
|
+
.block-editor-block-preview__container {
|
|
6
|
+
display: flex;
|
|
7
|
+
aspect-ratio: 4/3;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
border-radius: $radius-medium;
|
|
10
|
+
|
|
11
|
+
&::after {
|
|
12
|
+
outline: $border-width solid rgba($black, 0.1);
|
|
13
|
+
outline-offset: -$border-width;
|
|
14
|
+
border-radius: $radius-medium;
|
|
15
|
+
@media not (prefers-reduced-motion) {
|
|
16
|
+
transition: outline 0.1s linear;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&[role="button"] {
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
|
|
24
|
+
&:hover .block-editor-block-preview__container::after {
|
|
25
|
+
outline-color: rgba($black, 0.3);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&:focus-visible .block-editor-block-preview__container::after {
|
|
29
|
+
outline-color: var(--wp-admin-theme-color);
|
|
30
|
+
outline-width: var(--wp-admin-border-width-focus);
|
|
31
|
+
outline-offset: calc(-1 * var(--wp-admin-border-width-focus));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.editor-template-actions-panel__action {
|
|
37
|
+
flex: 1;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
}
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
import { useZoomOutModeExit } from './use-zoom-out-mode-exit';
|
|
42
42
|
import { usePaddingAppender } from './use-padding-appender';
|
|
43
43
|
import { useEditContentOnlySectionExit } from './use-edit-content-only-section-exit';
|
|
44
|
-
import {
|
|
44
|
+
import { SyncConnectionErrorModal } from '../sync-connection-error-modal';
|
|
45
45
|
|
|
46
46
|
const {
|
|
47
47
|
LayoutStyle,
|
|
@@ -427,7 +427,7 @@ function VisualEditor( {
|
|
|
427
427
|
}
|
|
428
428
|
) }
|
|
429
429
|
>
|
|
430
|
-
<
|
|
430
|
+
<SyncConnectionErrorModal />
|
|
431
431
|
<ResizableEditor enableResizing={ enableResizing } height="100%">
|
|
432
432
|
<BlockCanvas
|
|
433
433
|
shouldIframe={ ! disableIframe }
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
resetPost,
|
|
20
20
|
deletePost,
|
|
21
21
|
duplicateTemplatePart,
|
|
22
|
+
excerptField,
|
|
22
23
|
featuredImageField,
|
|
23
24
|
dateField,
|
|
24
25
|
parentField,
|
|
@@ -38,6 +39,7 @@ import {
|
|
|
38
39
|
scheduledDateField,
|
|
39
40
|
formatField,
|
|
40
41
|
postContentInfoField,
|
|
42
|
+
stickyField,
|
|
41
43
|
} from '@wordpress/fields';
|
|
42
44
|
import {
|
|
43
45
|
altTextField,
|
|
@@ -267,6 +269,9 @@ export const registerPostTypeSchema =
|
|
|
267
269
|
! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&
|
|
268
270
|
scheduledDateField,
|
|
269
271
|
slugField,
|
|
272
|
+
! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&
|
|
273
|
+
postTypeConfig.supports?.excerpt &&
|
|
274
|
+
excerptField,
|
|
270
275
|
postTypeConfig.supports?.[ 'page-attributes' ] && parentField,
|
|
271
276
|
postTypeConfig.supports?.comments && commentStatusField,
|
|
272
277
|
postTypeConfig.supports?.trackbacks && pingStatusField,
|
|
@@ -281,6 +286,7 @@ export const registerPostTypeSchema =
|
|
|
281
286
|
postTypeConfig.supports?.editor &&
|
|
282
287
|
postContentInfoField,
|
|
283
288
|
passwordField,
|
|
289
|
+
postTypeConfig.slug === 'post' && stickyField,
|
|
284
290
|
postTypeConfig.supports?.editor &&
|
|
285
291
|
postTypeConfig.viewable &&
|
|
286
292
|
postPreviewField,
|
package/src/store/actions.js
CHANGED
|
@@ -189,10 +189,7 @@ export const savePost =
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
const content = select.getEditedPostContent();
|
|
192
|
-
|
|
193
|
-
if ( ! options.isAutosave ) {
|
|
194
|
-
dispatch.editPost( { content }, { undoIgnore: true } );
|
|
195
|
-
}
|
|
192
|
+
dispatch.editPost( { content }, { undoIgnore: true } );
|
|
196
193
|
|
|
197
194
|
const previousRecord = select.getCurrentPost();
|
|
198
195
|
let edits = {
|
|
@@ -627,6 +627,11 @@ export const restoreRevision =
|
|
|
627
627
|
const postType = select.getCurrentPostType();
|
|
628
628
|
const postId = select.getCurrentPostId();
|
|
629
629
|
|
|
630
|
+
const entityConfig = registry
|
|
631
|
+
.select( coreStore )
|
|
632
|
+
.getEntityConfig( 'postType', postType );
|
|
633
|
+
const revisionKey = entityConfig?.revisionKey || 'id';
|
|
634
|
+
|
|
630
635
|
// Use resolveSelect to ensure the revision is fetched if not yet
|
|
631
636
|
// in the store. The _fields parameter matches the query used by
|
|
632
637
|
// getRevisions so the result is served from cache without an
|
|
@@ -635,8 +640,19 @@ export const restoreRevision =
|
|
|
635
640
|
.resolveSelect( coreStore )
|
|
636
641
|
.getRevision( 'postType', postType, postId, revisionId, {
|
|
637
642
|
context: 'edit',
|
|
638
|
-
_fields:
|
|
639
|
-
|
|
643
|
+
_fields: [
|
|
644
|
+
...new Set( [
|
|
645
|
+
'id',
|
|
646
|
+
'date',
|
|
647
|
+
'modified',
|
|
648
|
+
'author',
|
|
649
|
+
'meta',
|
|
650
|
+
'title.raw',
|
|
651
|
+
'excerpt.raw',
|
|
652
|
+
'content.raw',
|
|
653
|
+
revisionKey,
|
|
654
|
+
] ),
|
|
655
|
+
].join(),
|
|
640
656
|
} );
|
|
641
657
|
|
|
642
658
|
if ( ! revision ) {
|
|
@@ -672,7 +688,12 @@ export const restoreRevision =
|
|
|
672
688
|
sprintf(
|
|
673
689
|
/* translators: %s: Date and time of the revision. */
|
|
674
690
|
__( 'Restored to revision from %s.' ),
|
|
675
|
-
dateI18n(
|
|
691
|
+
dateI18n(
|
|
692
|
+
getDateSettings().formats.datetime,
|
|
693
|
+
// Template revisions use the template REST API format, which
|
|
694
|
+
// exposes 'modified' instead of 'date'.
|
|
695
|
+
revisionKey === 'wp_id' ? revision.modified : revision.date
|
|
696
|
+
)
|
|
676
697
|
),
|
|
677
698
|
{
|
|
678
699
|
type: 'snackbar',
|