@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
|
@@ -7,14 +7,9 @@ import clsx from 'clsx';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { Spinner } from '@wordpress/components';
|
|
10
|
-
import {
|
|
11
|
-
privateApis as blockEditorPrivateApis,
|
|
12
|
-
store as blockEditorStore,
|
|
13
|
-
} from '@wordpress/block-editor';
|
|
14
|
-
import { createBlock, parse } from '@wordpress/blocks';
|
|
15
|
-
import { EntityProvider } from '@wordpress/core-data';
|
|
10
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
16
11
|
import { useSelect } from '@wordpress/data';
|
|
17
|
-
import { useEffect
|
|
12
|
+
import { useEffect } from '@wordpress/element';
|
|
18
13
|
import { addFilter } from '@wordpress/hooks';
|
|
19
14
|
|
|
20
15
|
/**
|
|
@@ -28,12 +23,8 @@ import {
|
|
|
28
23
|
unregisterDiffFormatTypes,
|
|
29
24
|
} from './diff-format-types';
|
|
30
25
|
import { useDiffMarkers } from './diff-markers';
|
|
31
|
-
import { preserveClientIds } from './preserve-client-ids';
|
|
32
|
-
import { diffRevisionContent } from './block-diff';
|
|
33
26
|
|
|
34
|
-
const {
|
|
35
|
-
blockEditorPrivateApis
|
|
36
|
-
);
|
|
27
|
+
const { usePrivateStyleOverride } = unlock( blockEditorPrivateApis );
|
|
37
28
|
|
|
38
29
|
// SVG filter for removed blocks: grayscale + red tint
|
|
39
30
|
const REVISION_REMOVED_FILTER_SVG = `
|
|
@@ -104,7 +95,7 @@ const REVISION_DIFF_STYLES = `
|
|
|
104
95
|
function withRevisionDiffClasses( BlockListBlock ) {
|
|
105
96
|
return ( props ) => {
|
|
106
97
|
const { block, className } = props;
|
|
107
|
-
const diffStatus = block?.__revisionDiffStatus;
|
|
98
|
+
const diffStatus = block?.__revisionDiffStatus?.status;
|
|
108
99
|
|
|
109
100
|
const enhancedClassName = clsx( className, {
|
|
110
101
|
'is-revision-added': diffStatus === 'added',
|
|
@@ -151,12 +142,11 @@ function CanvasContent( { showDiff } ) {
|
|
|
151
142
|
|
|
152
143
|
/**
|
|
153
144
|
* Canvas component that renders a post revision in read-only mode.
|
|
145
|
+
* Block preparation and settings are handled by the parent EditorProvider.
|
|
154
146
|
*
|
|
155
|
-
* @param {Object} props Component props.
|
|
156
|
-
* @param {boolean} props.showDiff Whether to show diff highlighting.
|
|
157
147
|
* @return {React.JSX.Element} The revisions canvas component.
|
|
158
148
|
*/
|
|
159
|
-
export default function RevisionsCanvas(
|
|
149
|
+
export default function RevisionsCanvas() {
|
|
160
150
|
useEffect( () => {
|
|
161
151
|
registerDiffFormatTypes();
|
|
162
152
|
return () => {
|
|
@@ -164,91 +154,23 @@ export default function RevisionsCanvas( { showDiff } ) {
|
|
|
164
154
|
};
|
|
165
155
|
}, [] );
|
|
166
156
|
|
|
167
|
-
const { revision,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
getCurrentRevision,
|
|
171
|
-
getPreviousRevision,
|
|
172
|
-
getCurrentPostType,
|
|
173
|
-
} = unlock( select( editorStore ) );
|
|
174
|
-
return {
|
|
175
|
-
revision: getCurrentRevision(),
|
|
176
|
-
previousRevision: getPreviousRevision(),
|
|
177
|
-
postType: getCurrentPostType(),
|
|
178
|
-
blockEditorSettings: select( blockEditorStore ).getSettings(),
|
|
179
|
-
};
|
|
180
|
-
}, [] );
|
|
181
|
-
|
|
182
|
-
// Track previously rendered blocks to preserve clientIds between renders.
|
|
183
|
-
const previousBlocksRef = useRef( [] );
|
|
184
|
-
|
|
185
|
-
const blocks = useMemo( () => {
|
|
186
|
-
const currentContent = revision?.content?.raw ?? '';
|
|
187
|
-
|
|
188
|
-
let parsedBlocks;
|
|
189
|
-
if ( showDiff ) {
|
|
190
|
-
const previousContent = previousRevision?.content?.raw || '';
|
|
191
|
-
// diffRevisionContent handles both normal diffing and the case
|
|
192
|
-
// where there's no previous revision (oldest revision shows all as added).
|
|
193
|
-
parsedBlocks = diffRevisionContent(
|
|
194
|
-
currentContent,
|
|
195
|
-
previousContent
|
|
196
|
-
);
|
|
197
|
-
} else {
|
|
198
|
-
// When diff is disabled, just parse the current revision content.
|
|
199
|
-
parsedBlocks = parse( currentContent );
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if ( postType === 'wp_navigation' ) {
|
|
203
|
-
parsedBlocks = [
|
|
204
|
-
createBlock(
|
|
205
|
-
'core/navigation',
|
|
206
|
-
{ templateLock: false },
|
|
207
|
-
parsedBlocks
|
|
208
|
-
),
|
|
209
|
-
];
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// Preserve clientIds from previous render to prevent React unmount/remount.
|
|
213
|
-
const blocksWithStableIds = preserveClientIds(
|
|
214
|
-
parsedBlocks,
|
|
215
|
-
previousBlocksRef.current
|
|
157
|
+
const { revision, showDiff } = useSelect( ( select ) => {
|
|
158
|
+
const { getCurrentRevision, isShowingRevisionDiff } = unlock(
|
|
159
|
+
select( editorStore )
|
|
216
160
|
);
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}, [
|
|
223
|
-
revision?.content?.raw,
|
|
224
|
-
previousRevision?.content?.raw,
|
|
225
|
-
postType,
|
|
226
|
-
showDiff,
|
|
227
|
-
] );
|
|
228
|
-
|
|
229
|
-
const settings = useMemo(
|
|
230
|
-
() => ( {
|
|
231
|
-
...blockEditorSettings,
|
|
232
|
-
isPreviewMode: true,
|
|
233
|
-
} ),
|
|
234
|
-
[ blockEditorSettings ]
|
|
235
|
-
);
|
|
161
|
+
return {
|
|
162
|
+
revision: getCurrentRevision(),
|
|
163
|
+
showDiff: isShowingRevisionDiff(),
|
|
164
|
+
};
|
|
165
|
+
}, [] );
|
|
236
166
|
|
|
237
167
|
return revision ? (
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
settings={ settings }
|
|
245
|
-
>
|
|
246
|
-
<DiffStyleOverrides showDiff={ showDiff } />
|
|
247
|
-
<div className="editor-revisions-canvas__content">
|
|
248
|
-
<CanvasContent showDiff={ showDiff } />
|
|
249
|
-
</div>
|
|
250
|
-
</ExperimentalBlockEditorProvider>
|
|
251
|
-
</EntityProvider>
|
|
168
|
+
<>
|
|
169
|
+
<DiffStyleOverrides showDiff={ showDiff } />
|
|
170
|
+
<div className="editor-revisions-canvas__content">
|
|
171
|
+
<CanvasContent showDiff={ showDiff } />
|
|
172
|
+
</div>
|
|
173
|
+
</>
|
|
252
174
|
) : (
|
|
253
175
|
<div className="editor-revisions-canvas__loading">
|
|
254
176
|
<Spinner />
|
|
@@ -35,7 +35,12 @@ function RevisionsSlider() {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const entityConfig = getEntityConfig( 'postType', postType );
|
|
38
|
-
const query = {
|
|
38
|
+
const query = {
|
|
39
|
+
per_page: -1,
|
|
40
|
+
context: 'edit',
|
|
41
|
+
_fields:
|
|
42
|
+
'id,date,author,meta,title.raw,excerpt.raw,content.raw',
|
|
43
|
+
};
|
|
39
44
|
return {
|
|
40
45
|
revisions: getRevisions( 'postType', postType, postId, query ),
|
|
41
46
|
isLoading: isResolving( 'getRevisions', [
|
|
@@ -91,7 +91,7 @@ describe( 'diffRevisionContent', () => {
|
|
|
91
91
|
name: 'core/paragraph',
|
|
92
92
|
attributes: {
|
|
93
93
|
content: 'Hello',
|
|
94
|
-
__revisionDiffStatus: 'added',
|
|
94
|
+
__revisionDiffStatus: { status: 'added' },
|
|
95
95
|
},
|
|
96
96
|
},
|
|
97
97
|
] );
|
|
@@ -108,7 +108,7 @@ describe( 'diffRevisionContent', () => {
|
|
|
108
108
|
name: 'core/paragraph',
|
|
109
109
|
attributes: {
|
|
110
110
|
content: 'Hello',
|
|
111
|
-
__revisionDiffStatus: 'removed',
|
|
111
|
+
__revisionDiffStatus: { status: 'removed' },
|
|
112
112
|
},
|
|
113
113
|
},
|
|
114
114
|
] );
|
|
@@ -144,7 +144,9 @@ describe( 'diffRevisionContent', () => {
|
|
|
144
144
|
{
|
|
145
145
|
name: 'core/paragraph',
|
|
146
146
|
attributes: {
|
|
147
|
-
__revisionDiffStatus:
|
|
147
|
+
__revisionDiffStatus: {
|
|
148
|
+
status: 'modified',
|
|
149
|
+
},
|
|
148
150
|
},
|
|
149
151
|
},
|
|
150
152
|
] );
|
|
@@ -167,7 +169,7 @@ describe( 'diffRevisionContent', () => {
|
|
|
167
169
|
name: 'core/paragraph',
|
|
168
170
|
attributes: {
|
|
169
171
|
content: 'NEW',
|
|
170
|
-
__revisionDiffStatus: 'added',
|
|
172
|
+
__revisionDiffStatus: { status: 'added' },
|
|
171
173
|
},
|
|
172
174
|
},
|
|
173
175
|
{
|
|
@@ -211,14 +213,14 @@ describe( 'diffRevisionContent', () => {
|
|
|
211
213
|
name: 'core/paragraph',
|
|
212
214
|
attributes: {
|
|
213
215
|
content: 'First new block',
|
|
214
|
-
__revisionDiffStatus: 'added',
|
|
216
|
+
__revisionDiffStatus: { status: 'added' },
|
|
215
217
|
},
|
|
216
218
|
},
|
|
217
219
|
{
|
|
218
220
|
name: 'core/paragraph',
|
|
219
221
|
attributes: {
|
|
220
222
|
content: 'Second new block',
|
|
221
|
-
__revisionDiffStatus: 'added',
|
|
223
|
+
__revisionDiffStatus: { status: 'added' },
|
|
222
224
|
},
|
|
223
225
|
},
|
|
224
226
|
{
|
|
@@ -227,7 +229,9 @@ describe( 'diffRevisionContent', () => {
|
|
|
227
229
|
// Inline diff: "existing" → "modified"
|
|
228
230
|
content:
|
|
229
231
|
'This is some <del title="Removed" class="revision-diff-removed">existing</del><ins title="Added" class="revision-diff-added">modified</ins> content',
|
|
230
|
-
__revisionDiffStatus:
|
|
232
|
+
__revisionDiffStatus: {
|
|
233
|
+
status: 'modified',
|
|
234
|
+
},
|
|
231
235
|
},
|
|
232
236
|
},
|
|
233
237
|
] );
|
|
@@ -265,7 +269,7 @@ describe( 'diffRevisionContent', () => {
|
|
|
265
269
|
name: 'core/paragraph',
|
|
266
270
|
attributes: {
|
|
267
271
|
content: 'B',
|
|
268
|
-
__revisionDiffStatus: 'added',
|
|
272
|
+
__revisionDiffStatus: { status: 'added' },
|
|
269
273
|
},
|
|
270
274
|
},
|
|
271
275
|
],
|
|
@@ -305,7 +309,7 @@ describe( 'diffRevisionContent', () => {
|
|
|
305
309
|
name: 'core/paragraph',
|
|
306
310
|
attributes: {
|
|
307
311
|
content: 'B',
|
|
308
|
-
__revisionDiffStatus: 'removed',
|
|
312
|
+
__revisionDiffStatus: { status: 'removed' },
|
|
309
313
|
},
|
|
310
314
|
},
|
|
311
315
|
],
|
|
@@ -342,7 +346,7 @@ describe( 'diffRevisionContent', () => {
|
|
|
342
346
|
name: 'core/paragraph',
|
|
343
347
|
attributes: {
|
|
344
348
|
content: 'Second block content',
|
|
345
|
-
__revisionDiffStatus: 'added',
|
|
349
|
+
__revisionDiffStatus: { status: 'added' },
|
|
346
350
|
},
|
|
347
351
|
},
|
|
348
352
|
{
|
|
@@ -356,7 +360,7 @@ describe( 'diffRevisionContent', () => {
|
|
|
356
360
|
name: 'core/paragraph',
|
|
357
361
|
attributes: {
|
|
358
362
|
content: 'Second block content',
|
|
359
|
-
__revisionDiffStatus: 'removed',
|
|
363
|
+
__revisionDiffStatus: { status: 'removed' },
|
|
360
364
|
},
|
|
361
365
|
},
|
|
362
366
|
] );
|
|
@@ -381,7 +385,17 @@ describe( 'diffRevisionContent', () => {
|
|
|
381
385
|
attributes: {
|
|
382
386
|
content: 'Same content',
|
|
383
387
|
className: 'new-class',
|
|
384
|
-
__revisionDiffStatus:
|
|
388
|
+
__revisionDiffStatus: {
|
|
389
|
+
status: 'modified',
|
|
390
|
+
changedAttributes: {
|
|
391
|
+
className: [
|
|
392
|
+
{
|
|
393
|
+
added: true,
|
|
394
|
+
value: 'new-class',
|
|
395
|
+
},
|
|
396
|
+
],
|
|
397
|
+
},
|
|
398
|
+
},
|
|
385
399
|
},
|
|
386
400
|
},
|
|
387
401
|
] );
|
|
@@ -410,7 +424,9 @@ describe( 'diffRevisionContent', () => {
|
|
|
410
424
|
attributes: {
|
|
411
425
|
content:
|
|
412
426
|
'Second block content<ins title="Added" class="revision-diff-added"> modified</ins>',
|
|
413
|
-
__revisionDiffStatus:
|
|
427
|
+
__revisionDiffStatus: {
|
|
428
|
+
status: 'modified',
|
|
429
|
+
},
|
|
414
430
|
},
|
|
415
431
|
},
|
|
416
432
|
{
|
|
@@ -466,7 +482,9 @@ describe( 'diffRevisionContent', () => {
|
|
|
466
482
|
name: 'core/paragraph',
|
|
467
483
|
attributes: {
|
|
468
484
|
content: 'New',
|
|
469
|
-
__revisionDiffStatus:
|
|
485
|
+
__revisionDiffStatus: {
|
|
486
|
+
status: 'added',
|
|
487
|
+
},
|
|
470
488
|
},
|
|
471
489
|
},
|
|
472
490
|
],
|
|
@@ -490,7 +508,7 @@ describe( 'diffRevisionContent', () => {
|
|
|
490
508
|
{
|
|
491
509
|
name: 'core/group',
|
|
492
510
|
attributes: {
|
|
493
|
-
__revisionDiffStatus: 'added',
|
|
511
|
+
__revisionDiffStatus: { status: 'added' },
|
|
494
512
|
},
|
|
495
513
|
innerBlocks: [
|
|
496
514
|
{
|
|
@@ -526,7 +544,7 @@ describe( 'diffRevisionContent', () => {
|
|
|
526
544
|
{
|
|
527
545
|
name: 'core/group',
|
|
528
546
|
attributes: {
|
|
529
|
-
__revisionDiffStatus: 'removed',
|
|
547
|
+
__revisionDiffStatus: { status: 'removed' },
|
|
530
548
|
},
|
|
531
549
|
innerBlocks: [
|
|
532
550
|
{
|
|
@@ -577,7 +595,7 @@ describe( 'diffRevisionContent', () => {
|
|
|
577
595
|
name: 'core/paragraph',
|
|
578
596
|
attributes: {
|
|
579
597
|
content: 'NEW',
|
|
580
|
-
__revisionDiffStatus: 'added',
|
|
598
|
+
__revisionDiffStatus: { status: 'added' },
|
|
581
599
|
},
|
|
582
600
|
},
|
|
583
601
|
{
|
|
@@ -629,7 +647,9 @@ describe( 'diffRevisionContent', () => {
|
|
|
629
647
|
{
|
|
630
648
|
name: 'core/paragraph',
|
|
631
649
|
attributes: {
|
|
632
|
-
__revisionDiffStatus:
|
|
650
|
+
__revisionDiffStatus: {
|
|
651
|
+
status: 'modified',
|
|
652
|
+
},
|
|
633
653
|
},
|
|
634
654
|
},
|
|
635
655
|
],
|
|
@@ -673,7 +693,7 @@ describe( 'diffRevisionContent', () => {
|
|
|
673
693
|
name: 'core/paragraph',
|
|
674
694
|
attributes: {
|
|
675
695
|
content: 'C',
|
|
676
|
-
__revisionDiffStatus: 'removed',
|
|
696
|
+
__revisionDiffStatus: { status: 'removed' },
|
|
677
697
|
},
|
|
678
698
|
},
|
|
679
699
|
{
|
|
@@ -682,7 +702,9 @@ describe( 'diffRevisionContent', () => {
|
|
|
682
702
|
// B→D modification with inline diff
|
|
683
703
|
content:
|
|
684
704
|
'<del title="Removed" class="revision-diff-removed">B</del><ins title="Added" class="revision-diff-added">D</ins>',
|
|
685
|
-
__revisionDiffStatus:
|
|
705
|
+
__revisionDiffStatus: {
|
|
706
|
+
status: 'modified',
|
|
707
|
+
},
|
|
686
708
|
},
|
|
687
709
|
},
|
|
688
710
|
],
|
|
@@ -739,7 +761,7 @@ describe( 'diffRevisionContent', () => {
|
|
|
739
761
|
attributes: {
|
|
740
762
|
content:
|
|
741
763
|
'The quick brown fox jumps over the lazy dog near the riverbank',
|
|
742
|
-
__revisionDiffStatus: 'removed',
|
|
764
|
+
__revisionDiffStatus: { status: 'removed' },
|
|
743
765
|
},
|
|
744
766
|
},
|
|
745
767
|
{
|
|
@@ -747,7 +769,7 @@ describe( 'diffRevisionContent', () => {
|
|
|
747
769
|
attributes: {
|
|
748
770
|
content:
|
|
749
771
|
'Third paragraph also removed from this post',
|
|
750
|
-
__revisionDiffStatus: 'removed',
|
|
772
|
+
__revisionDiffStatus: { status: 'removed' },
|
|
751
773
|
},
|
|
752
774
|
},
|
|
753
775
|
{
|
|
@@ -755,7 +777,7 @@ describe( 'diffRevisionContent', () => {
|
|
|
755
777
|
attributes: {
|
|
756
778
|
content:
|
|
757
779
|
'Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod',
|
|
758
|
-
__revisionDiffStatus: 'added',
|
|
780
|
+
__revisionDiffStatus: { status: 'added' },
|
|
759
781
|
},
|
|
760
782
|
},
|
|
761
783
|
],
|
|
@@ -803,7 +825,9 @@ describe( 'diffRevisionContent', () => {
|
|
|
803
825
|
attributes: {
|
|
804
826
|
content:
|
|
805
827
|
'Hello <strong><span title="1 format added" class="revision-diff-format-added">world</span></strong>',
|
|
806
|
-
__revisionDiffStatus:
|
|
828
|
+
__revisionDiffStatus: {
|
|
829
|
+
status: 'modified',
|
|
830
|
+
},
|
|
807
831
|
},
|
|
808
832
|
},
|
|
809
833
|
] );
|
|
@@ -829,7 +853,9 @@ describe( 'diffRevisionContent', () => {
|
|
|
829
853
|
attributes: {
|
|
830
854
|
content:
|
|
831
855
|
'Hello <strong><del title="Removed" class="revision-diff-removed">world</del><ins title="Added" class="revision-diff-added">everyone</ins></strong>',
|
|
832
|
-
__revisionDiffStatus:
|
|
856
|
+
__revisionDiffStatus: {
|
|
857
|
+
status: 'modified',
|
|
858
|
+
},
|
|
833
859
|
},
|
|
834
860
|
},
|
|
835
861
|
] );
|
|
@@ -879,7 +905,9 @@ describe( 'diffRevisionContent', () => {
|
|
|
879
905
|
attributes: {
|
|
880
906
|
content:
|
|
881
907
|
'Visit <a href="https://new-site.com"><span title="1 format changed" class="revision-diff-format-changed">our site</span></a> today',
|
|
882
|
-
__revisionDiffStatus:
|
|
908
|
+
__revisionDiffStatus: {
|
|
909
|
+
status: 'modified',
|
|
910
|
+
},
|
|
883
911
|
},
|
|
884
912
|
},
|
|
885
913
|
] );
|
|
@@ -907,7 +935,9 @@ describe( 'diffRevisionContent', () => {
|
|
|
907
935
|
attributes: {
|
|
908
936
|
content:
|
|
909
937
|
'Visit <a href="https://example.com"><del title="Removed" class="revision-diff-removed">our</del><ins title="Added" class="revision-diff-added">the</ins> <del title="Removed" class="revision-diff-removed">site</del><ins title="Added" class="revision-diff-added">website</ins></a> today',
|
|
910
|
-
__revisionDiffStatus:
|
|
938
|
+
__revisionDiffStatus: {
|
|
939
|
+
status: 'modified',
|
|
940
|
+
},
|
|
911
941
|
},
|
|
912
942
|
},
|
|
913
943
|
] );
|
|
@@ -955,7 +985,9 @@ describe( 'diffRevisionContent', () => {
|
|
|
955
985
|
attributes: {
|
|
956
986
|
content:
|
|
957
987
|
'<span title="1 format removed" class="revision-diff-format-removed">Bold</span> and <span title="1 format removed" class="revision-diff-format-removed">italic</span> text',
|
|
958
|
-
__revisionDiffStatus:
|
|
988
|
+
__revisionDiffStatus: {
|
|
989
|
+
status: 'modified',
|
|
990
|
+
},
|
|
959
991
|
},
|
|
960
992
|
},
|
|
961
993
|
] );
|
|
@@ -981,7 +1013,9 @@ describe( 'diffRevisionContent', () => {
|
|
|
981
1013
|
attributes: {
|
|
982
1014
|
content:
|
|
983
1015
|
'Hello <em><span title="1 format added, 1 format removed" class="revision-diff-format-changed">world</span></em>',
|
|
984
|
-
__revisionDiffStatus:
|
|
1016
|
+
__revisionDiffStatus: {
|
|
1017
|
+
status: 'modified',
|
|
1018
|
+
},
|
|
985
1019
|
},
|
|
986
1020
|
},
|
|
987
1021
|
] );
|
|
@@ -1026,7 +1060,9 @@ describe( 'diffRevisionContent', () => {
|
|
|
1026
1060
|
attributes: {
|
|
1027
1061
|
content:
|
|
1028
1062
|
'<del title="Removed" class="revision-diff-removed">Hello</del><ins title="Added" class="revision-diff-added">Goodbye</ins> <strong>world</strong>!',
|
|
1029
|
-
__revisionDiffStatus:
|
|
1063
|
+
__revisionDiffStatus: {
|
|
1064
|
+
status: 'modified',
|
|
1065
|
+
},
|
|
1030
1066
|
},
|
|
1031
1067
|
},
|
|
1032
1068
|
] );
|
|
@@ -1062,7 +1098,9 @@ describe( 'diffRevisionContent', () => {
|
|
|
1062
1098
|
attributes: {
|
|
1063
1099
|
content:
|
|
1064
1100
|
'<del title="Removed" class="revision-diff-removed">Hello</del><ins title="Added" class="revision-diff-added">Goodbye</ins> <strong><del title="Removed" class="revision-diff-removed">world</del><ins title="Added" class="revision-diff-added">everyone</ins></strong>',
|
|
1065
|
-
__revisionDiffStatus:
|
|
1101
|
+
__revisionDiffStatus: {
|
|
1102
|
+
status: 'modified',
|
|
1103
|
+
},
|
|
1066
1104
|
},
|
|
1067
1105
|
},
|
|
1068
1106
|
],
|
|
@@ -25,18 +25,20 @@ import ResetDefaultTemplate from './reset-default-template';
|
|
|
25
25
|
import { unlock } from '../../lock-unlock';
|
|
26
26
|
import CreateNewTemplate from './create-new-template';
|
|
27
27
|
|
|
28
|
-
export default function BlockThemeControl(
|
|
28
|
+
export default function BlockThemeControl() {
|
|
29
29
|
const {
|
|
30
30
|
isTemplateHidden,
|
|
31
31
|
onNavigateToEntityRecord,
|
|
32
32
|
getEditorSettings,
|
|
33
33
|
hasGoBack,
|
|
34
34
|
hasSpecificTemplate,
|
|
35
|
+
id,
|
|
35
36
|
} = useSelect( ( select ) => {
|
|
36
37
|
const {
|
|
37
38
|
getRenderingMode,
|
|
38
39
|
getEditorSettings: _getEditorSettings,
|
|
39
40
|
getCurrentPost,
|
|
41
|
+
getCurrentTemplateId,
|
|
40
42
|
} = unlock( select( editorStore ) );
|
|
41
43
|
const editorSettings = _getEditorSettings();
|
|
42
44
|
const currentPost = getCurrentPost();
|
|
@@ -48,6 +50,7 @@ export default function BlockThemeControl( { id } ) {
|
|
|
48
50
|
'onNavigateToPreviousEntityRecord'
|
|
49
51
|
),
|
|
50
52
|
hasSpecificTemplate: !! currentPost.template,
|
|
53
|
+
id: getCurrentTemplateId(),
|
|
51
54
|
};
|
|
52
55
|
}, [] );
|
|
53
56
|
|
|
@@ -81,6 +81,48 @@ export function useAvailableTemplates( postType ) {
|
|
|
81
81
|
);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
export function usePostTemplatePanelMode() {
|
|
85
|
+
return useSelect( ( select ) => {
|
|
86
|
+
const { getEditorSettings, getCurrentTemplateId, getCurrentPostType } =
|
|
87
|
+
select( editorStore );
|
|
88
|
+
const { getPostType, canUser } = select( coreStore );
|
|
89
|
+
const postTypeSlug = getCurrentPostType();
|
|
90
|
+
const postType = getPostType( postTypeSlug );
|
|
91
|
+
const settings = getEditorSettings();
|
|
92
|
+
const isBlockTheme = settings.__unstableIsBlockBasedTheme;
|
|
93
|
+
const hasTemplates =
|
|
94
|
+
!! settings.availableTemplates &&
|
|
95
|
+
Object.keys( settings.availableTemplates ).length > 0;
|
|
96
|
+
let isVisible;
|
|
97
|
+
if ( ! postType?.viewable ) {
|
|
98
|
+
isVisible = false;
|
|
99
|
+
} else if ( hasTemplates ) {
|
|
100
|
+
isVisible = true;
|
|
101
|
+
} else if ( ! settings.supportsTemplateMode ) {
|
|
102
|
+
isVisible = false;
|
|
103
|
+
} else {
|
|
104
|
+
isVisible =
|
|
105
|
+
canUser( 'create', {
|
|
106
|
+
kind: 'postType',
|
|
107
|
+
name: 'wp_template',
|
|
108
|
+
} ) ?? false;
|
|
109
|
+
}
|
|
110
|
+
const canViewTemplates = isVisible
|
|
111
|
+
? !! canUser( 'read', {
|
|
112
|
+
kind: 'postType',
|
|
113
|
+
name: 'wp_template',
|
|
114
|
+
} )
|
|
115
|
+
: false;
|
|
116
|
+
if ( ( ! isBlockTheme || ! canViewTemplates ) && isVisible ) {
|
|
117
|
+
return 'classic';
|
|
118
|
+
}
|
|
119
|
+
if ( isBlockTheme && !! getCurrentTemplateId() ) {
|
|
120
|
+
return 'block-theme';
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}, [] );
|
|
124
|
+
}
|
|
125
|
+
|
|
84
126
|
export function useCurrentTemplateSlug() {
|
|
85
127
|
const { postType, postId } = useEditedPostContext();
|
|
86
128
|
const templates = useTemplates( postType );
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
-
|
|
7
1
|
/**
|
|
8
2
|
* Internal dependencies
|
|
9
3
|
*/
|
|
10
|
-
import {
|
|
4
|
+
import { usePostTemplatePanelMode } from './hooks';
|
|
11
5
|
import ClassicThemeControl from './classic-theme';
|
|
12
6
|
import BlockThemeControl from './block-theme';
|
|
13
7
|
|
|
@@ -17,60 +11,12 @@ import BlockThemeControl from './block-theme';
|
|
|
17
11
|
* @return {React.ReactNode} The rendered PostTemplatePanel component.
|
|
18
12
|
*/
|
|
19
13
|
export default function PostTemplatePanel() {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
select( editorStore );
|
|
23
|
-
return {
|
|
24
|
-
templateId: getCurrentTemplateId(),
|
|
25
|
-
isBlockTheme: getEditorSettings().__unstableIsBlockBasedTheme,
|
|
26
|
-
};
|
|
27
|
-
}, [] );
|
|
28
|
-
|
|
29
|
-
const isVisible = useSelect( ( select ) => {
|
|
30
|
-
const postTypeSlug = select( editorStore ).getCurrentPostType();
|
|
31
|
-
const postType = select( coreStore ).getPostType( postTypeSlug );
|
|
32
|
-
if ( ! postType?.viewable ) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const settings = select( editorStore ).getEditorSettings();
|
|
37
|
-
const hasTemplates =
|
|
38
|
-
!! settings.availableTemplates &&
|
|
39
|
-
Object.keys( settings.availableTemplates ).length > 0;
|
|
40
|
-
if ( hasTemplates ) {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if ( ! settings.supportsTemplateMode ) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const canCreateTemplates =
|
|
49
|
-
select( coreStore ).canUser( 'create', {
|
|
50
|
-
kind: 'postType',
|
|
51
|
-
name: 'wp_template',
|
|
52
|
-
} ) ?? false;
|
|
53
|
-
return canCreateTemplates;
|
|
54
|
-
}, [] );
|
|
55
|
-
|
|
56
|
-
const canViewTemplates = useSelect(
|
|
57
|
-
( select ) => {
|
|
58
|
-
return isVisible
|
|
59
|
-
? select( coreStore ).canUser( 'read', {
|
|
60
|
-
kind: 'postType',
|
|
61
|
-
name: 'wp_template',
|
|
62
|
-
} )
|
|
63
|
-
: false;
|
|
64
|
-
},
|
|
65
|
-
[ isVisible ]
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
if ( ( ! isBlockTheme || ! canViewTemplates ) && isVisible ) {
|
|
14
|
+
const mode = usePostTemplatePanelMode();
|
|
15
|
+
if ( mode === 'classic' ) {
|
|
69
16
|
return <ClassicThemeControl />;
|
|
70
17
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return <BlockThemeControl id={ templateId } />;
|
|
18
|
+
if ( mode === 'block-theme' ) {
|
|
19
|
+
return <BlockThemeControl />;
|
|
74
20
|
}
|
|
75
21
|
return null;
|
|
76
22
|
}
|
|
@@ -120,6 +120,24 @@ function PreferencesModalContents( { extraSections = {} } ) {
|
|
|
120
120
|
) }
|
|
121
121
|
label={ __( 'Show starter patterns' ) }
|
|
122
122
|
/>
|
|
123
|
+
<PreferenceToggleControl
|
|
124
|
+
scope="core"
|
|
125
|
+
featureName="showCollaborationCursor"
|
|
126
|
+
help={ __(
|
|
127
|
+
'Show your own avatar inside blocks during collaborative editing sessions.'
|
|
128
|
+
) }
|
|
129
|
+
label={ __( 'Show avatar in blocks' ) }
|
|
130
|
+
/>
|
|
131
|
+
<PreferenceToggleControl
|
|
132
|
+
scope="core"
|
|
133
|
+
featureName="showCollaborationNotifications"
|
|
134
|
+
help={ __(
|
|
135
|
+
'Show notifications when collaborators join, leave, or save the post.'
|
|
136
|
+
) }
|
|
137
|
+
label={ __(
|
|
138
|
+
'Show collaboration notifications'
|
|
139
|
+
) }
|
|
140
|
+
/>
|
|
123
141
|
</PreferencesModalSection>
|
|
124
142
|
<PreferencesModalSection
|
|
125
143
|
title={ __( 'Document settings' ) }
|