@wordpress/editor 14.41.1-next.v.202603102151.0 → 14.42.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 +6 -0
- package/build/components/collaborators-overlay/avatar-iframe-styles.cjs +12 -4
- package/build/components/collaborators-overlay/avatar-iframe-styles.cjs.map +2 -2
- package/build/components/collaborators-overlay/compute-selection.cjs +181 -0
- package/build/components/collaborators-overlay/compute-selection.cjs.map +7 -0
- package/build/components/collaborators-overlay/cursor-dom-utils.cjs +243 -0
- package/build/components/collaborators-overlay/cursor-dom-utils.cjs.map +7 -0
- package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +6 -0
- package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +2 -2
- package/build/components/collaborators-overlay/overlay.cjs +61 -37
- 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-block-highlighting.cjs +5 -6
- package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +2 -2
- package/build/components/collaborators-overlay/use-render-cursors.cjs +50 -140
- package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
- package/build/components/collaborators-presence/index.cjs +38 -12
- package/build/components/collaborators-presence/index.cjs.map +2 -2
- package/build/components/collaborators-presence/list.cjs +27 -24
- package/build/components/collaborators-presence/list.cjs.map +2 -2
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs +79 -107
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +3 -3
- package/build/components/editor-interface/index.cjs +9 -6
- package/build/components/editor-interface/index.cjs.map +2 -2
- package/build/components/inserter-sidebar/index.cjs +2 -1
- package/build/components/inserter-sidebar/index.cjs.map +2 -2
- package/build/components/page-attributes/parent.cjs +1 -1
- package/build/components/page-attributes/parent.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-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 +12 -75
- package/build/components/post-revisions-preview/revisions-canvas.cjs.map +3 -3
- package/build/components/post-revisions-preview/revisions-slider.cjs +5 -1
- 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/hooks.cjs +39 -2
- 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/preferences-modal/index.cjs +24 -0
- package/build/components/preferences-modal/index.cjs.map +2 -2
- package/build/components/provider/disable-non-page-content-blocks.cjs +31 -28
- package/build/components/provider/disable-non-page-content-blocks.cjs.map +3 -3
- package/build/components/provider/index.cjs +17 -5
- package/build/components/provider/index.cjs.map +2 -2
- package/build/components/provider/use-block-editor-settings.cjs +19 -5
- package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
- package/build/components/provider/{use-post-content-blocks.cjs → use-post-content-block-types.cjs} +8 -19
- package/build/components/provider/use-post-content-block-types.cjs.map +7 -0
- package/build/components/provider/use-revision-blocks.cjs +106 -0
- package/build/components/provider/use-revision-blocks.cjs.map +7 -0
- package/build/components/revision-block-diff/index.cjs +84 -0
- package/build/components/revision-block-diff/index.cjs.map +7 -0
- package/build/components/sidebar/dataform-post-summary.cjs +36 -6
- package/build/components/sidebar/dataform-post-summary.cjs.map +2 -2
- package/build/components/sidebar/header.cjs +1 -1
- package/build/components/sidebar/header.cjs.map +2 -2
- package/build/components/sidebar/index.cjs +5 -1
- package/build/components/sidebar/index.cjs.map +3 -3
- package/build/components/{sync-connection-modal → sync-connection-error-modal}/index.cjs +90 -78
- 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-content-panel/index.cjs +35 -31
- package/build/components/template-content-panel/index.cjs.map +3 -3
- package/build/components/visual-editor/index.cjs +2 -2
- package/build/components/visual-editor/index.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 +11 -2
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +52 -13
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +12 -0
- package/build/store/reducer.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/avatar-iframe-styles.mjs +12 -4
- package/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/compute-selection.mjs +162 -0
- package/build-module/components/collaborators-overlay/compute-selection.mjs.map +7 -0
- package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs +213 -0
- package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs.map +7 -0
- package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +6 -0
- package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/overlay.mjs +61 -37
- 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-block-highlighting.mjs +5 -6
- package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs +50 -140
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
- package/build-module/components/collaborators-presence/index.mjs +39 -13
- package/build-module/components/collaborators-presence/index.mjs.map +2 -2
- package/build-module/components/collaborators-presence/list.mjs +27 -24
- package/build-module/components/collaborators-presence/list.mjs.map +2 -2
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +80 -108
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +2 -2
- package/build-module/components/editor-interface/index.mjs +10 -7
- package/build-module/components/editor-interface/index.mjs.map +2 -2
- package/build-module/components/inserter-sidebar/index.mjs +2 -1
- package/build-module/components/inserter-sidebar/index.mjs.map +2 -2
- package/build-module/components/page-attributes/parent.mjs +1 -1
- package/build-module/components/page-attributes/parent.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-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 +14 -80
- package/build-module/components/post-revisions-preview/revisions-canvas.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/revisions-slider.mjs +5 -1
- 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/hooks.mjs +37 -1
- 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/preferences-modal/index.mjs +24 -0
- package/build-module/components/preferences-modal/index.mjs.map +2 -2
- package/build-module/components/provider/disable-non-page-content-blocks.mjs +31 -28
- package/build-module/components/provider/disable-non-page-content-blocks.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +17 -5
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-editor-settings.mjs +19 -5
- package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
- package/build-module/components/provider/use-post-content-block-types.mjs +23 -0
- package/build-module/components/provider/use-post-content-block-types.mjs.map +7 -0
- package/build-module/components/provider/use-revision-blocks.mjs +81 -0
- package/build-module/components/provider/use-revision-blocks.mjs.map +7 -0
- package/build-module/components/revision-block-diff/index.mjs +53 -0
- package/build-module/components/revision-block-diff/index.mjs.map +7 -0
- package/build-module/components/sidebar/dataform-post-summary.mjs +36 -6
- package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
- package/build-module/components/sidebar/header.mjs +1 -1
- package/build-module/components/sidebar/header.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs +5 -1
- package/build-module/components/sidebar/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-content-panel/index.mjs +25 -31
- package/build-module/components/template-content-panel/index.mjs.map +2 -2
- package/build-module/components/visual-editor/index.mjs +2 -2
- package/build-module/components/visual-editor/index.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 +10 -2
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +50 -12
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +11 -0
- package/build-module/store/reducer.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 +95 -16
- package/build-style/style.css +95 -16
- package/build-types/components/collaborators-overlay/avatar-iframe-styles.d.ts +1 -1
- package/build-types/components/collaborators-overlay/avatar-iframe-styles.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/compute-selection.d.ts +24 -0
- package/build-types/components/collaborators-overlay/compute-selection.d.ts.map +1 -0
- package/build-types/components/collaborators-overlay/cursor-dom-utils.d.ts +72 -0
- package/build-types/components/collaborators-overlay/cursor-dom-utils.d.ts.map +1 -0
- 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.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-overlay/use-block-highlighting.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/use-render-cursors.d.ts +4 -0
- package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
- package/build-types/components/collaborators-presence/index.d.ts.map +1 -1
- package/build-types/components/collaborators-presence/list.d.ts +2 -1
- package/build-types/components/collaborators-presence/list.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/inserter-sidebar/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-preview/block-diff.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/revisions-canvas.d.ts +2 -5
- package/build-types/components/post-revisions-preview/revisions-canvas.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/hooks.d.ts +1 -0
- 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/provider/disable-non-page-content-blocks.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/provider/use-post-content-block-types.d.ts +9 -0
- package/build-types/components/provider/use-post-content-block-types.d.ts.map +1 -0
- package/build-types/components/provider/use-revision-blocks.d.ts +10 -0
- package/build-types/components/provider/use-revision-blocks.d.ts.map +1 -0
- 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/sidebar/dataform-post-summary.d.ts.map +1 -1
- package/build-types/components/sidebar/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-content-panel/index.d.ts.map +1 -1
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts +7 -0
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +7 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +14 -3
- package/build-types/store/reducer.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 +44 -44
- package/src/components/collaborators-overlay/avatar-iframe-styles.ts +12 -4
- package/src/components/collaborators-overlay/compute-selection.ts +307 -0
- package/src/components/collaborators-overlay/cursor-dom-utils.ts +382 -0
- package/src/components/collaborators-overlay/overlay-iframe-styles.ts +6 -0
- package/src/components/collaborators-overlay/overlay.tsx +59 -27
- package/src/components/collaborators-overlay/timing-utils.ts +30 -0
- package/src/components/collaborators-overlay/use-block-highlighting.ts +11 -10
- package/src/components/collaborators-overlay/use-render-cursors.ts +70 -242
- package/src/components/collaborators-presence/avatar/styles.scss +20 -4
- package/src/components/collaborators-presence/index.tsx +30 -5
- package/src/components/collaborators-presence/list.tsx +38 -24
- package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +188 -246
- package/src/components/collaborators-presence/use-collaborator-notifications.ts +109 -166
- package/src/components/document-bar/style.scss +1 -1
- package/src/components/editor-interface/index.js +8 -6
- package/src/components/inserter-sidebar/index.js +4 -1
- package/src/components/page-attributes/parent.js +1 -1
- package/src/components/post-locked-modal/index.js +21 -3
- 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 +20 -98
- package/src/components/post-revisions-preview/revisions-slider.js +6 -1
- 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/hooks.js +42 -0
- package/src/components/post-template/panel.js +5 -59
- package/src/components/preferences-modal/index.js +18 -0
- package/src/components/provider/disable-non-page-content-blocks.js +42 -40
- package/src/components/provider/index.js +20 -2
- package/src/components/provider/use-block-editor-settings.js +21 -8
- package/src/components/provider/use-post-content-block-types.js +30 -0
- package/src/components/provider/use-revision-blocks.js +105 -0
- package/src/components/revision-block-diff/index.js +74 -0
- package/src/components/revision-block-diff/style.scss +13 -0
- package/src/components/sidebar/dataform-post-summary.js +61 -16
- package/src/components/sidebar/header.js +1 -1
- package/src/components/sidebar/index.js +2 -0
- 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-content-panel/index.js +30 -38
- package/src/components/visual-editor/index.js +2 -2
- package/src/store/actions.js +1 -4
- package/src/store/private-actions.js +21 -2
- package/src/store/private-selectors.js +75 -10
- package/src/store/reducer.js +19 -0
- package/src/style.scss +2 -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/provider/use-post-content-blocks.cjs.map +0 -7
- 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/provider/use-post-content-blocks.mjs +0 -34
- package/build-module/components/provider/use-post-content-blocks.mjs.map +0 -7
- package/build-module/components/sync-connection-modal/index.mjs +0 -167
- 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/provider/use-post-content-blocks.d.ts +0 -2
- package/build-types/components/provider/use-post-content-blocks.d.ts.map +0 -1
- 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/provider/use-post-content-blocks.js +0 -42
- package/src/components/sync-connection-modal/index.js +0 -200
- package/src/components/sync-connection-modal/style.scss +0 -9
- package/src/components/sync-connection-modal/use-retry-countdown.js +0 -70
- package/src/utils/sync-error-messages.js +0 -58
|
@@ -8,21 +8,33 @@ import { useEffect } from '@wordpress/element';
|
|
|
8
8
|
/**
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
|
-
import
|
|
11
|
+
import { store as editorStore } from '../../store';
|
|
12
|
+
import { unlock } from '../../lock-unlock';
|
|
13
|
+
import usePostContentBlockTypes from './use-post-content-block-types';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Component that when rendered, makes it so that the site editor allows only
|
|
15
17
|
* page content to be edited.
|
|
16
18
|
*/
|
|
17
19
|
export default function DisableNonPageContentBlocks() {
|
|
18
|
-
const
|
|
19
|
-
const { templateParts } = useSelect(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
const postContentBlockTypes = usePostContentBlockTypes();
|
|
21
|
+
const { contentOnlyIds, templateParts } = useSelect(
|
|
22
|
+
( select ) => {
|
|
23
|
+
const { getPostBlocksByName } = unlock( select( editorStore ) );
|
|
24
|
+
const { getBlocksByName } = select( blockEditorStore );
|
|
25
|
+
return {
|
|
26
|
+
contentOnlyIds: getPostBlocksByName( postContentBlockTypes ),
|
|
27
|
+
templateParts: getBlocksByName( 'core/template-part' ),
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
[ postContentBlockTypes ]
|
|
31
|
+
);
|
|
32
|
+
// This is a separate `useSelect` because `templatePartChildren` is
|
|
33
|
+
// derived via flatMap, which always produces a new array. Combining it
|
|
34
|
+
// with the above subscription causes an infinite render loop: the new
|
|
35
|
+
// array fails useSelect's shallow equality check → re-render → effect
|
|
36
|
+
// fires setBlockEditingMode → store changes → useSelect re-runs → …
|
|
37
|
+
const templatePartChildren = useSelect(
|
|
26
38
|
( select ) => {
|
|
27
39
|
const { getBlockOrder } = select( blockEditorStore );
|
|
28
40
|
return templateParts.flatMap( ( clientId ) =>
|
|
@@ -34,14 +46,11 @@ export default function DisableNonPageContentBlocks() {
|
|
|
34
46
|
|
|
35
47
|
const registry = useRegistry();
|
|
36
48
|
|
|
37
|
-
// The
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
// It's also unlikely that these different types of blocks are being inserted
|
|
44
|
-
// or removed at the same time, so using different effects reflects that.
|
|
49
|
+
// The effects below are split so that changes to one group of blocks
|
|
50
|
+
// don't cause unnecessary set/unset cycles for the others. For example,
|
|
51
|
+
// the root block ('') editing mode only needs to be set once.
|
|
52
|
+
// Child blocks of templates and templateParts are also loaded separately,
|
|
53
|
+
// so these are kept in separate effects.
|
|
45
54
|
useEffect( () => {
|
|
46
55
|
const { setBlockEditingMode, unsetBlockEditingMode } =
|
|
47
56
|
registry.dispatch( blockEditorStore );
|
|
@@ -53,25 +62,6 @@ export default function DisableNonPageContentBlocks() {
|
|
|
53
62
|
};
|
|
54
63
|
}, [ registry ] );
|
|
55
64
|
|
|
56
|
-
useEffect( () => {
|
|
57
|
-
const { setBlockEditingMode, unsetBlockEditingMode } =
|
|
58
|
-
registry.dispatch( blockEditorStore );
|
|
59
|
-
|
|
60
|
-
registry.batch( () => {
|
|
61
|
-
for ( const clientId of contentOnlyIds ) {
|
|
62
|
-
setBlockEditingMode( clientId, 'contentOnly' );
|
|
63
|
-
}
|
|
64
|
-
} );
|
|
65
|
-
|
|
66
|
-
return () => {
|
|
67
|
-
registry.batch( () => {
|
|
68
|
-
for ( const clientId of contentOnlyIds ) {
|
|
69
|
-
unsetBlockEditingMode( clientId );
|
|
70
|
-
}
|
|
71
|
-
} );
|
|
72
|
-
};
|
|
73
|
-
}, [ contentOnlyIds, registry ] );
|
|
74
|
-
|
|
75
65
|
useEffect( () => {
|
|
76
66
|
const { setBlockEditingMode, unsetBlockEditingMode } =
|
|
77
67
|
registry.dispatch( blockEditorStore );
|
|
@@ -95,20 +85,32 @@ export default function DisableNonPageContentBlocks() {
|
|
|
95
85
|
const { setBlockEditingMode, unsetBlockEditingMode } =
|
|
96
86
|
registry.dispatch( blockEditorStore );
|
|
97
87
|
|
|
88
|
+
const contentOnlySet = new Set( contentOnlyIds );
|
|
89
|
+
|
|
98
90
|
registry.batch( () => {
|
|
99
|
-
for ( const clientId of
|
|
100
|
-
setBlockEditingMode( clientId, '
|
|
91
|
+
for ( const clientId of contentOnlyIds ) {
|
|
92
|
+
setBlockEditingMode( clientId, 'contentOnly' );
|
|
93
|
+
}
|
|
94
|
+
for ( const clientId of templatePartChildren ) {
|
|
95
|
+
if ( ! contentOnlySet.has( clientId ) ) {
|
|
96
|
+
setBlockEditingMode( clientId, 'disabled' );
|
|
97
|
+
}
|
|
101
98
|
}
|
|
102
99
|
} );
|
|
103
100
|
|
|
104
101
|
return () => {
|
|
105
102
|
registry.batch( () => {
|
|
106
|
-
for ( const clientId of
|
|
103
|
+
for ( const clientId of contentOnlyIds ) {
|
|
107
104
|
unsetBlockEditingMode( clientId );
|
|
108
105
|
}
|
|
106
|
+
for ( const clientId of templatePartChildren ) {
|
|
107
|
+
if ( ! contentOnlySet.has( clientId ) ) {
|
|
108
|
+
unsetBlockEditingMode( clientId );
|
|
109
|
+
}
|
|
110
|
+
}
|
|
109
111
|
} );
|
|
110
112
|
};
|
|
111
|
-
}, [
|
|
113
|
+
}, [ contentOnlyIds, templatePartChildren, registry ] );
|
|
112
114
|
|
|
113
115
|
return null;
|
|
114
116
|
}
|
|
@@ -34,6 +34,7 @@ import { unlock } from '../../lock-unlock';
|
|
|
34
34
|
import DisableNonPageContentBlocks from './disable-non-page-content-blocks';
|
|
35
35
|
import NavigationBlockEditingMode from './navigation-block-editing-mode';
|
|
36
36
|
import { useHideBlocksFromInserter } from './use-hide-blocks-from-inserter';
|
|
37
|
+
import { useRevisionBlocks } from './use-revision-blocks';
|
|
37
38
|
import useCommands from '../commands';
|
|
38
39
|
import useUploadSaveLock from './use-upload-save-lock';
|
|
39
40
|
import BlockRemovalWarnings from '../block-removal-warnings';
|
|
@@ -78,6 +79,7 @@ const NON_CONTEXTUAL_POST_TYPES = [
|
|
|
78
79
|
* @return {Array} Block editor props.
|
|
79
80
|
*/
|
|
80
81
|
function useBlockEditorProps( post, template, mode ) {
|
|
82
|
+
const revisionBlocks = useRevisionBlocks();
|
|
81
83
|
const rootLevelPost = mode === 'template-locked' ? 'template' : 'post';
|
|
82
84
|
const [ postBlocks, onInput, onChange ] = useEntityBlockEditor(
|
|
83
85
|
'postType',
|
|
@@ -116,6 +118,11 @@ function useBlockEditorProps( post, template, mode ) {
|
|
|
116
118
|
return postBlocks;
|
|
117
119
|
}, [ maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks ] );
|
|
118
120
|
|
|
121
|
+
// In revisions mode, use the revision blocks and disable editing.
|
|
122
|
+
if ( revisionBlocks !== null ) {
|
|
123
|
+
return [ revisionBlocks, noop, noop ];
|
|
124
|
+
}
|
|
125
|
+
|
|
119
126
|
// Handle fallback to postBlocks outside of the above useMemo, to ensure
|
|
120
127
|
// that constructed block templates that call `createBlock` are not generated
|
|
121
128
|
// too frequently. This ensures that clientIds are stable.
|
|
@@ -177,6 +184,8 @@ export const ExperimentalEditorProvider = withRegistryProvider(
|
|
|
177
184
|
mode,
|
|
178
185
|
defaultMode,
|
|
179
186
|
postTypeEntities,
|
|
187
|
+
isInRevisionsMode,
|
|
188
|
+
currentRevisionId,
|
|
180
189
|
} = useSelect(
|
|
181
190
|
( select ) => {
|
|
182
191
|
const {
|
|
@@ -184,6 +193,8 @@ export const ExperimentalEditorProvider = withRegistryProvider(
|
|
|
184
193
|
getRenderingMode,
|
|
185
194
|
__unstableIsEditorReady,
|
|
186
195
|
getDefaultRenderingMode,
|
|
196
|
+
isRevisionsMode: _isRevisionsMode,
|
|
197
|
+
getCurrentRevisionId: _getCurrentRevisionId,
|
|
187
198
|
} = unlock( select( editorStore ) );
|
|
188
199
|
const { getEntitiesConfig, getEntityRecordEdits } =
|
|
189
200
|
select( coreStore );
|
|
@@ -224,6 +235,8 @@ export const ExperimentalEditorProvider = withRegistryProvider(
|
|
|
224
235
|
post.type === 'wp_template'
|
|
225
236
|
? getEntitiesConfig( 'postType' )
|
|
226
237
|
: null,
|
|
238
|
+
isInRevisionsMode: _isRevisionsMode(),
|
|
239
|
+
currentRevisionId: _getCurrentRevisionId(),
|
|
227
240
|
};
|
|
228
241
|
},
|
|
229
242
|
[ post.type, post.id, hasTemplate ]
|
|
@@ -418,14 +431,19 @@ export const ExperimentalEditorProvider = withRegistryProvider(
|
|
|
418
431
|
kind="postType"
|
|
419
432
|
type={ post.type }
|
|
420
433
|
id={ post.id }
|
|
434
|
+
revisionId={ currentRevisionId ?? undefined }
|
|
421
435
|
>
|
|
422
436
|
<BlockContextProvider value={ defaultBlockContext }>
|
|
423
437
|
<BlockEditorProviderComponent
|
|
424
438
|
value={ blocks }
|
|
425
439
|
onChange={ onChange }
|
|
426
440
|
onInput={ onInput }
|
|
427
|
-
selection={
|
|
428
|
-
|
|
441
|
+
selection={
|
|
442
|
+
isInRevisionsMode ? undefined : selection
|
|
443
|
+
}
|
|
444
|
+
onChangeSelection={
|
|
445
|
+
isInRevisionsMode ? noop : onChangeSelection
|
|
446
|
+
}
|
|
429
447
|
settings={ blockEditorSettings }
|
|
430
448
|
useSubRegistry={ false }
|
|
431
449
|
>
|
|
@@ -25,6 +25,7 @@ import inserterMediaCategories from '../media-categories';
|
|
|
25
25
|
import { mediaUpload } from '../../utils';
|
|
26
26
|
import mediaUploadOnSuccess from '../../utils/media-upload/on-success';
|
|
27
27
|
import { default as mediaSideload } from '../../utils/media-sideload';
|
|
28
|
+
import { default as mediaFinalize } from '../../utils/media-finalize';
|
|
28
29
|
import { store as editorStore } from '../../store';
|
|
29
30
|
import { unlock } from '../../lock-unlock';
|
|
30
31
|
import { useGlobalStylesContext } from '../global-styles-provider';
|
|
@@ -104,6 +105,7 @@ const {
|
|
|
104
105
|
isIsolatedEditorKey,
|
|
105
106
|
deviceTypeKey,
|
|
106
107
|
isNavigationOverlayContextKey,
|
|
108
|
+
isNavigationPostEditorKey,
|
|
107
109
|
mediaUploadOnSuccessKey,
|
|
108
110
|
} = unlock( privateApis );
|
|
109
111
|
|
|
@@ -139,6 +141,7 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
|
|
|
139
141
|
sectionRootClientId,
|
|
140
142
|
deviceType,
|
|
141
143
|
isNavigationOverlayContext,
|
|
144
|
+
isRevisionsMode,
|
|
142
145
|
} = useSelect(
|
|
143
146
|
( select ) => {
|
|
144
147
|
const {
|
|
@@ -150,7 +153,9 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
|
|
|
150
153
|
} = select( coreStore );
|
|
151
154
|
const { get } = select( preferencesStore );
|
|
152
155
|
const { getBlockTypes } = select( blocksStore );
|
|
153
|
-
const { getDeviceType } = unlock(
|
|
156
|
+
const { getDeviceType, isRevisionsMode: _isRevisionsMode } = unlock(
|
|
157
|
+
select( editorStore )
|
|
158
|
+
);
|
|
154
159
|
const { getBlocksByName, getBlockAttributes } =
|
|
155
160
|
select( blockEditorStore );
|
|
156
161
|
const siteSettings = canUser( 'read', {
|
|
@@ -218,6 +223,7 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
|
|
|
218
223
|
postId
|
|
219
224
|
)?.area === 'navigation-overlay'
|
|
220
225
|
: false,
|
|
226
|
+
isRevisionsMode: _isRevisionsMode(),
|
|
221
227
|
};
|
|
222
228
|
},
|
|
223
229
|
[ postType, postId, isLargeViewport, renderingMode ]
|
|
@@ -309,12 +315,9 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
|
|
|
309
315
|
return useMemo( () => {
|
|
310
316
|
const blockEditorSettings = {
|
|
311
317
|
...Object.fromEntries(
|
|
312
|
-
Object.entries( settings )
|
|
313
|
-
.
|
|
314
|
-
|
|
315
|
-
)
|
|
316
|
-
// Exclude onNavigateToEntityRecord since we're wrapping it
|
|
317
|
-
.filter( ( [ key ] ) => key !== 'onNavigateToEntityRecord' )
|
|
318
|
+
Object.entries( settings ).filter( ( [ key ] ) =>
|
|
319
|
+
BLOCK_EDITOR_SETTINGS.includes( key )
|
|
320
|
+
)
|
|
318
321
|
),
|
|
319
322
|
[ globalStylesDataKey ]: globalStylesData,
|
|
320
323
|
[ globalStylesLinksDataKey ]: globalStylesLinksData,
|
|
@@ -326,7 +329,6 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
|
|
|
326
329
|
hasFixedToolbar,
|
|
327
330
|
isDistractionFree,
|
|
328
331
|
keepCaretInsideBlock,
|
|
329
|
-
onNavigateToEntityRecord: settings.onNavigateToEntityRecord,
|
|
330
332
|
[ getMediaSelectKey ]: ( select, attachmentId ) => {
|
|
331
333
|
return select( coreStore ).getEntityRecord(
|
|
332
334
|
'postType',
|
|
@@ -342,6 +344,7 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
|
|
|
342
344
|
? mediaUploadOnSuccess
|
|
343
345
|
: undefined,
|
|
344
346
|
mediaSideload: hasUploadPermissions ? mediaSideload : undefined,
|
|
347
|
+
mediaFinalize: hasUploadPermissions ? mediaFinalize : undefined,
|
|
345
348
|
__experimentalBlockPatterns: blockPatterns,
|
|
346
349
|
[ selectBlockPatternsKey ]: ( select ) => {
|
|
347
350
|
const { hasFinishedResolution, getBlockPatternsForPostType } =
|
|
@@ -391,12 +394,22 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
|
|
|
391
394
|
'wp_block',
|
|
392
395
|
'wp_navigation',
|
|
393
396
|
].includes( postType ),
|
|
397
|
+
[ isNavigationPostEditorKey ]: postType === 'wp_navigation',
|
|
398
|
+
// When in template-locked mode (e.g., "Show Template" in the post editor),
|
|
399
|
+
// don't treat template parts as contentOnly sections.
|
|
400
|
+
disableContentOnlyForTemplateParts:
|
|
401
|
+
renderingMode === 'template-locked',
|
|
394
402
|
...( deviceType ? { [ deviceTypeKey ]: deviceType } : {} ),
|
|
395
403
|
[ isNavigationOverlayContextKey ]: isNavigationOverlayContext,
|
|
396
404
|
};
|
|
397
405
|
|
|
406
|
+
if ( isRevisionsMode ) {
|
|
407
|
+
blockEditorSettings.isPreviewMode = true;
|
|
408
|
+
}
|
|
409
|
+
|
|
398
410
|
return blockEditorSettings;
|
|
399
411
|
}, [
|
|
412
|
+
isRevisionsMode,
|
|
400
413
|
allowedBlockTypes,
|
|
401
414
|
allowRightClickOverrides,
|
|
402
415
|
focusMode,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useMemo } from '@wordpress/element';
|
|
5
|
+
import { applyFilters } from '@wordpress/hooks';
|
|
6
|
+
|
|
7
|
+
const POST_CONTENT_BLOCK_TYPES = [
|
|
8
|
+
'core/post-title',
|
|
9
|
+
'core/post-featured-image',
|
|
10
|
+
'core/post-content',
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Returns the list of post content block types, including any added via the
|
|
15
|
+
* `editor.postContentBlockTypes` filter. The result is memoized so it can be
|
|
16
|
+
* used as a stable dependency in `useSelect` calls.
|
|
17
|
+
*
|
|
18
|
+
* @return {string[]} Block type names considered post content.
|
|
19
|
+
*/
|
|
20
|
+
export default function usePostContentBlockTypes() {
|
|
21
|
+
return useMemo(
|
|
22
|
+
() => [
|
|
23
|
+
...applyFilters(
|
|
24
|
+
'editor.postContentBlockTypes',
|
|
25
|
+
POST_CONTENT_BLOCK_TYPES
|
|
26
|
+
),
|
|
27
|
+
],
|
|
28
|
+
[]
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { useMemo, useRef } from '@wordpress/element';
|
|
6
|
+
import { createBlock, parse } from '@wordpress/blocks';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { store as editorStore } from '../../store';
|
|
12
|
+
import { unlock } from '../../lock-unlock';
|
|
13
|
+
import { diffRevisionContent } from '../post-revisions-preview/block-diff';
|
|
14
|
+
import { preserveClientIds } from '../post-revisions-preview/preserve-client-ids';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Hook that computes revision blocks when in revisions mode.
|
|
18
|
+
*
|
|
19
|
+
* Returns `null` when not in revisions mode, `[]` when loading,
|
|
20
|
+
* or the computed blocks array when ready.
|
|
21
|
+
*
|
|
22
|
+
* @return {Array|null} The revision blocks, or null if not in revisions mode.
|
|
23
|
+
*/
|
|
24
|
+
export function useRevisionBlocks() {
|
|
25
|
+
const {
|
|
26
|
+
isInRevisionsMode,
|
|
27
|
+
showDiff,
|
|
28
|
+
revision,
|
|
29
|
+
previousRevision,
|
|
30
|
+
postType,
|
|
31
|
+
} = useSelect( ( select ) => {
|
|
32
|
+
const {
|
|
33
|
+
isRevisionsMode,
|
|
34
|
+
isShowingRevisionDiff,
|
|
35
|
+
getCurrentRevision,
|
|
36
|
+
getPreviousRevision,
|
|
37
|
+
} = unlock( select( editorStore ) );
|
|
38
|
+
const { getCurrentPostType } = select( editorStore );
|
|
39
|
+
|
|
40
|
+
const inRevisions = isRevisionsMode();
|
|
41
|
+
return {
|
|
42
|
+
isInRevisionsMode: inRevisions,
|
|
43
|
+
showDiff: isShowingRevisionDiff(),
|
|
44
|
+
revision: inRevisions ? getCurrentRevision() : undefined,
|
|
45
|
+
previousRevision: inRevisions ? getPreviousRevision() : undefined,
|
|
46
|
+
postType: getCurrentPostType(),
|
|
47
|
+
};
|
|
48
|
+
}, [] );
|
|
49
|
+
|
|
50
|
+
// Track previously rendered blocks to preserve clientIds between renders.
|
|
51
|
+
const previousBlocksRef = useRef( [] );
|
|
52
|
+
|
|
53
|
+
const blocks = useMemo( () => {
|
|
54
|
+
if ( ! isInRevisionsMode ) {
|
|
55
|
+
// Clear the ref when exiting revisions mode.
|
|
56
|
+
previousBlocksRef.current = [];
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Revision not loaded yet.
|
|
61
|
+
if ( ! revision ) {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const currentContent = revision?.content?.raw ?? '';
|
|
66
|
+
|
|
67
|
+
let parsedBlocks;
|
|
68
|
+
if ( showDiff ) {
|
|
69
|
+
const previousContent = previousRevision?.content?.raw || '';
|
|
70
|
+
parsedBlocks = diffRevisionContent(
|
|
71
|
+
currentContent,
|
|
72
|
+
previousContent
|
|
73
|
+
);
|
|
74
|
+
} else {
|
|
75
|
+
parsedBlocks = parse( currentContent );
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if ( postType === 'wp_navigation' ) {
|
|
79
|
+
parsedBlocks = [
|
|
80
|
+
createBlock(
|
|
81
|
+
'core/navigation',
|
|
82
|
+
{ templateLock: false },
|
|
83
|
+
parsedBlocks
|
|
84
|
+
),
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const blocksWithStableIds = preserveClientIds(
|
|
89
|
+
parsedBlocks,
|
|
90
|
+
previousBlocksRef.current
|
|
91
|
+
);
|
|
92
|
+
previousBlocksRef.current = blocksWithStableIds;
|
|
93
|
+
|
|
94
|
+
return blocksWithStableIds;
|
|
95
|
+
}, [
|
|
96
|
+
isInRevisionsMode,
|
|
97
|
+
revision,
|
|
98
|
+
revision?.content?.raw,
|
|
99
|
+
previousRevision?.content?.raw,
|
|
100
|
+
postType,
|
|
101
|
+
showDiff,
|
|
102
|
+
] );
|
|
103
|
+
|
|
104
|
+
return blocks;
|
|
105
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { PanelBody } from '@wordpress/components';
|
|
5
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
6
|
+
import { useSelect } from '@wordpress/data';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import PostPanelRow from '../post-panel-row';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Panel that shows changed block attributes for the selected block
|
|
16
|
+
* when viewing revisions.
|
|
17
|
+
*/
|
|
18
|
+
export default function RevisionBlockDiffPanel() {
|
|
19
|
+
const { block } = useSelect( ( select ) => {
|
|
20
|
+
const { getSelectedBlock } = select( blockEditorStore );
|
|
21
|
+
return {
|
|
22
|
+
block: getSelectedBlock(),
|
|
23
|
+
};
|
|
24
|
+
}, [] );
|
|
25
|
+
|
|
26
|
+
if ( ! block ) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const diffInfo = block.attributes?.__revisionDiffStatus;
|
|
31
|
+
const changedAttributes = diffInfo?.changedAttributes;
|
|
32
|
+
|
|
33
|
+
if ( ! changedAttributes ) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const fields = Object.entries( changedAttributes ).map(
|
|
38
|
+
( [ key, parts ] ) => (
|
|
39
|
+
<PostPanelRow key={ key } label={ key }>
|
|
40
|
+
<span className="editor-revision-fields-diff__value">
|
|
41
|
+
{ parts.map( ( part, index ) => {
|
|
42
|
+
if ( part.added ) {
|
|
43
|
+
return (
|
|
44
|
+
<ins
|
|
45
|
+
key={ index }
|
|
46
|
+
className="editor-revision-fields-diff__added"
|
|
47
|
+
>
|
|
48
|
+
{ part.value }
|
|
49
|
+
</ins>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
if ( part.removed ) {
|
|
53
|
+
return (
|
|
54
|
+
<del
|
|
55
|
+
key={ index }
|
|
56
|
+
className="editor-revision-fields-diff__removed"
|
|
57
|
+
>
|
|
58
|
+
{ part.value }
|
|
59
|
+
</del>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return <span key={ index }>{ part.value }</span>;
|
|
63
|
+
} ) }
|
|
64
|
+
</span>
|
|
65
|
+
</PostPanelRow>
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<PanelBody title={ __( 'Changed attributes' ) } initialOpen>
|
|
71
|
+
{ fields }
|
|
72
|
+
</PanelBody>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
.editor-revision-fields-diff__value {
|
|
2
|
+
word-break: break-word;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.editor-revision-fields-diff__added {
|
|
6
|
+
background-color: color-mix(in srgb, currentColor 5%, #00a32a 15%);
|
|
7
|
+
text-decoration: none;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.editor-revision-fields-diff__removed {
|
|
11
|
+
text-decoration: line-through;
|
|
12
|
+
color: #d63638;
|
|
13
|
+
}
|
|
@@ -17,6 +17,7 @@ import { store as editorStore } from '../../store';
|
|
|
17
17
|
import PostTrash from '../post-trash';
|
|
18
18
|
import usePostFields from '../post-fields';
|
|
19
19
|
import { unlock } from '../../lock-unlock';
|
|
20
|
+
import { usePostTemplatePanelMode } from '../post-template/hooks';
|
|
20
21
|
|
|
21
22
|
const form = {
|
|
22
23
|
layout: {
|
|
@@ -48,10 +49,10 @@ const form = {
|
|
|
48
49
|
'password',
|
|
49
50
|
],
|
|
50
51
|
},
|
|
51
|
-
'author',
|
|
52
52
|
'date',
|
|
53
53
|
'slug',
|
|
54
|
-
'
|
|
54
|
+
'author',
|
|
55
|
+
'template',
|
|
55
56
|
{
|
|
56
57
|
id: 'discussion',
|
|
57
58
|
label: __( 'Discussion' ),
|
|
@@ -63,7 +64,7 @@ const form = {
|
|
|
63
64
|
'ping_status',
|
|
64
65
|
],
|
|
65
66
|
},
|
|
66
|
-
'
|
|
67
|
+
'parent',
|
|
67
68
|
'format',
|
|
68
69
|
],
|
|
69
70
|
};
|
|
@@ -93,23 +94,67 @@ export default function DataFormPostSummary( { onActionPerformed } ) {
|
|
|
93
94
|
[ postType, postId ]
|
|
94
95
|
);
|
|
95
96
|
|
|
97
|
+
const templatePanelMode = usePostTemplatePanelMode();
|
|
98
|
+
|
|
99
|
+
const availableTemplates = useSelect( ( select ) => {
|
|
100
|
+
if ( select( coreDataStore ).getCurrentTheme()?.is_block_theme ) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
return (
|
|
104
|
+
select( editorStore ).getEditorSettings().availableTemplates ?? {}
|
|
105
|
+
);
|
|
106
|
+
}, [] );
|
|
107
|
+
|
|
108
|
+
// Augment record only when needed(not a block theme with available templates).
|
|
109
|
+
const augmentedRecord = useMemo( () => {
|
|
110
|
+
if ( ! record || ! availableTemplates ) {
|
|
111
|
+
return record;
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
...record,
|
|
115
|
+
available_templates: availableTemplates,
|
|
116
|
+
};
|
|
117
|
+
}, [ record, availableTemplates ] );
|
|
118
|
+
|
|
96
119
|
const { editEntityRecord } = useDispatch( coreDataStore );
|
|
97
120
|
|
|
98
121
|
const _fields = usePostFields( { postType } );
|
|
99
122
|
const fields = useMemo(
|
|
100
123
|
() =>
|
|
101
|
-
_fields
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
124
|
+
_fields
|
|
125
|
+
?.map( ( field ) => {
|
|
126
|
+
if ( field.id === 'status' ) {
|
|
127
|
+
return {
|
|
128
|
+
...field,
|
|
129
|
+
elements: field.elements.filter(
|
|
130
|
+
( element ) => element.value !== 'trash'
|
|
131
|
+
),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
if ( field.id === 'template' ) {
|
|
135
|
+
// `usePostTemplatePanelMode` is reused in the Post Template panel to match
|
|
136
|
+
// the existing behavior. If the panel rendered nothing we should exclude the
|
|
137
|
+
// template field from the form.
|
|
138
|
+
if ( ! templatePanelMode ) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
// In classic themes without available templates we need to make the field read-only.
|
|
142
|
+
if (
|
|
143
|
+
templatePanelMode === 'classic' &&
|
|
144
|
+
Object.keys( availableTemplates ?? {} ).length === 0
|
|
145
|
+
) {
|
|
146
|
+
return {
|
|
147
|
+
...field,
|
|
148
|
+
readOnly: true,
|
|
149
|
+
render: () => __( 'Default template' ),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
return field;
|
|
153
|
+
}
|
|
154
|
+
return field;
|
|
155
|
+
} )
|
|
156
|
+
.filter( Boolean ),
|
|
157
|
+
[ _fields, templatePanelMode, availableTemplates ]
|
|
113
158
|
);
|
|
114
159
|
|
|
115
160
|
const onChange = ( edits ) => {
|
|
@@ -137,7 +182,7 @@ export default function DataFormPostSummary( { onActionPerformed } ) {
|
|
|
137
182
|
onActionPerformed={ onActionPerformed }
|
|
138
183
|
/>
|
|
139
184
|
<DataForm
|
|
140
|
-
data={
|
|
185
|
+
data={ augmentedRecord }
|
|
141
186
|
fields={ fields }
|
|
142
187
|
form={ form }
|
|
143
188
|
onChange={ onChange }
|
|
@@ -32,6 +32,7 @@ import SidebarHeader from './header';
|
|
|
32
32
|
import TemplateContentPanel from '../template-content-panel';
|
|
33
33
|
import TemplatePartContentPanel from '../template-part-content-panel';
|
|
34
34
|
import { MediaMetadataPanel } from '../media';
|
|
35
|
+
import RevisionBlockDiffPanel from '../revision-block-diff';
|
|
35
36
|
import useAutoSwitchEditorSidebars from '../provider/use-auto-switch-editor-sidebars';
|
|
36
37
|
import { sidebars } from './constants';
|
|
37
38
|
import { unlock } from '../../lock-unlock';
|
|
@@ -144,6 +145,7 @@ const SidebarContent = ( {
|
|
|
144
145
|
{ ! isAttachment && (
|
|
145
146
|
<Tabs.TabPanel tabId={ sidebars.block } focusable={ false }>
|
|
146
147
|
<BlockInspector />
|
|
148
|
+
{ isRevisionsMode && <RevisionBlockDiffPanel /> }
|
|
147
149
|
</Tabs.TabPanel>
|
|
148
150
|
) }
|
|
149
151
|
</Tabs.Context.Provider>
|