@wordpress/editor 14.42.0 → 14.43.1-next.v.202604091042.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 +2 -0
- package/README.md +8 -0
- package/build/components/autocompleters/index.cjs +3 -0
- package/build/components/autocompleters/index.cjs.map +2 -2
- package/build/components/autocompleters/link.cjs +71 -0
- package/build/components/autocompleters/link.cjs.map +7 -0
- package/build/components/collaborators-overlay/cursor-dom-utils.cjs +1 -1
- package/build/components/collaborators-overlay/cursor-dom-utils.cjs.map +2 -2
- package/build/components/collaborators-overlay/cursor-registry.cjs +86 -0
- package/build/components/collaborators-overlay/cursor-registry.cjs.map +7 -0
- package/build/components/collaborators-overlay/index.cjs +7 -2
- package/build/components/collaborators-overlay/index.cjs.map +2 -2
- package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +1 -1
- package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +2 -2
- package/build/components/collaborators-overlay/overlay.cjs +31 -1
- package/build/components/collaborators-overlay/overlay.cjs.map +2 -2
- package/build/components/collaborators-overlay/timing-utils.cjs +1 -1
- package/build/components/collaborators-overlay/timing-utils.cjs.map +2 -2
- package/build/components/collaborators-overlay/use-render-cursors.cjs.map +2 -2
- package/build/components/collaborators-presence/index.cjs +14 -4
- package/build/components/collaborators-presence/index.cjs.map +2 -2
- package/build/components/collaborators-presence/list.cjs +20 -4
- package/build/components/collaborators-presence/list.cjs.map +2 -2
- package/build/components/error-boundary/index.cjs +1 -1
- package/build/components/error-boundary/index.cjs.map +2 -2
- package/build/components/post-card-panel/index.cjs +4 -15
- package/build/components/post-card-panel/index.cjs.map +2 -2
- package/build/components/post-content-information/index.cjs +10 -13
- package/build/components/post-content-information/index.cjs.map +2 -2
- package/build/components/post-revisions-panel/index.cjs +164 -0
- package/build/components/post-revisions-panel/index.cjs.map +7 -0
- package/build/components/post-revisions-preview/revisions-slider.cjs +23 -12
- package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
- package/build/components/post-template/create-new-template-modal.cjs +39 -46
- package/build/components/post-template/create-new-template-modal.cjs.map +2 -2
- package/build/components/post-template/hooks.cjs +52 -6
- package/build/components/post-template/hooks.cjs.map +2 -2
- package/build/components/post-template/swap-template-button.cjs +31 -20
- package/build/components/post-template/swap-template-button.cjs.map +2 -2
- package/build/components/post-title/index.cjs +2 -2
- package/build/components/post-title/index.cjs.map +2 -2
- package/build/components/preferences-modal/index.cjs +35 -27
- package/build/components/preferences-modal/index.cjs.map +2 -2
- package/build/components/revision-block-diff/index.cjs +9 -32
- package/build/components/revision-block-diff/index.cjs.map +3 -3
- package/build/components/revision-diff-panel/index.cjs +68 -0
- package/build/components/revision-diff-panel/index.cjs.map +7 -0
- package/build/components/revision-fields-diff/index.cjs +96 -0
- package/build/components/revision-fields-diff/index.cjs.map +7 -0
- package/build/components/sidebar/dataform-post-summary.cjs +8 -53
- package/build/components/sidebar/dataform-post-summary.cjs.map +2 -2
- package/build/components/sidebar/index.cjs +25 -22
- package/build/components/sidebar/index.cjs.map +3 -3
- package/build/components/sidebar/post-revision-summary.cjs +74 -0
- package/build/components/sidebar/post-revision-summary.cjs.map +7 -0
- package/build/components/sidebar/post-summary.cjs +35 -42
- package/build/components/sidebar/post-summary.cjs.map +3 -3
- package/build/components/style-book/index.cjs +4 -3
- package/build/components/style-book/index.cjs.map +2 -2
- package/build/components/styles-canvas/revisions.cjs +2 -2
- package/build/components/styles-canvas/revisions.cjs.map +1 -1
- package/build/components/sync-connection-error-modal/index.cjs +58 -75
- package/build/components/sync-connection-error-modal/index.cjs.map +3 -3
- package/build/components/sync-connection-error-modal/use-retry-countdown.cjs +32 -9
- package/build/components/sync-connection-error-modal/use-retry-countdown.cjs.map +2 -2
- package/build/components/template-actions-panel/block-theme-content.cjs +188 -0
- package/build/components/template-actions-panel/block-theme-content.cjs.map +7 -0
- package/build/components/template-actions-panel/classic-theme-content.cjs +159 -0
- package/build/components/template-actions-panel/classic-theme-content.cjs.map +7 -0
- package/build/components/template-actions-panel/index.cjs +59 -0
- package/build/components/template-actions-panel/index.cjs.map +7 -0
- package/build/dataviews/store/private-actions.cjs +2 -0
- package/build/dataviews/store/private-actions.cjs.map +2 -2
- package/build/hooks/default-autocompleters.cjs +1 -1
- package/build/hooks/default-autocompleters.cjs.map +2 -2
- package/build/store/private-actions.cjs +15 -1
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +42 -19
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +1 -1
- package/build/store/reducer.cjs.map +2 -2
- package/build-module/components/autocompleters/index.mjs +4 -2
- package/build-module/components/autocompleters/index.mjs.map +2 -2
- package/build-module/components/autocompleters/link.mjs +40 -0
- package/build-module/components/autocompleters/link.mjs.map +7 -0
- package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs +1 -1
- package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/cursor-registry.mjs +61 -0
- package/build-module/components/collaborators-overlay/cursor-registry.mjs.map +7 -0
- package/build-module/components/collaborators-overlay/index.mjs +7 -2
- package/build-module/components/collaborators-overlay/index.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +1 -1
- package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/overlay.mjs +32 -2
- package/build-module/components/collaborators-overlay/overlay.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/timing-utils.mjs +1 -1
- package/build-module/components/collaborators-overlay/timing-utils.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
- package/build-module/components/collaborators-presence/index.mjs +14 -4
- package/build-module/components/collaborators-presence/index.mjs.map +2 -2
- package/build-module/components/collaborators-presence/list.mjs +20 -4
- package/build-module/components/collaborators-presence/list.mjs.map +2 -2
- package/build-module/components/error-boundary/index.mjs +1 -1
- package/build-module/components/error-boundary/index.mjs.map +2 -2
- package/build-module/components/post-card-panel/index.mjs +6 -17
- package/build-module/components/post-card-panel/index.mjs.map +2 -2
- package/build-module/components/post-content-information/index.mjs +6 -13
- package/build-module/components/post-content-information/index.mjs.map +2 -2
- package/build-module/components/post-revisions-panel/index.mjs +139 -0
- package/build-module/components/post-revisions-panel/index.mjs.map +7 -0
- package/build-module/components/post-revisions-preview/revisions-slider.mjs +23 -12
- package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
- package/build-module/components/post-template/create-new-template-modal.mjs +39 -46
- package/build-module/components/post-template/create-new-template-modal.mjs.map +2 -2
- package/build-module/components/post-template/hooks.mjs +53 -7
- package/build-module/components/post-template/hooks.mjs.map +2 -2
- package/build-module/components/post-template/swap-template-button.mjs +27 -20
- package/build-module/components/post-template/swap-template-button.mjs.map +2 -2
- package/build-module/components/post-title/index.mjs +2 -2
- package/build-module/components/post-title/index.mjs.map +2 -2
- package/build-module/components/preferences-modal/index.mjs +35 -27
- package/build-module/components/preferences-modal/index.mjs.map +2 -2
- package/build-module/components/revision-block-diff/index.mjs +9 -32
- package/build-module/components/revision-block-diff/index.mjs.map +2 -2
- package/build-module/components/revision-diff-panel/index.mjs +37 -0
- package/build-module/components/revision-diff-panel/index.mjs.map +7 -0
- package/build-module/components/revision-fields-diff/index.mjs +65 -0
- package/build-module/components/revision-fields-diff/index.mjs.map +7 -0
- package/build-module/components/sidebar/dataform-post-summary.mjs +8 -53
- package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs +25 -22
- package/build-module/components/sidebar/index.mjs.map +2 -2
- package/build-module/components/sidebar/post-revision-summary.mjs +43 -0
- package/build-module/components/sidebar/post-revision-summary.mjs.map +7 -0
- package/build-module/components/sidebar/post-summary.mjs +31 -42
- package/build-module/components/sidebar/post-summary.mjs.map +2 -2
- package/build-module/components/style-book/index.mjs +4 -3
- package/build-module/components/style-book/index.mjs.map +2 -2
- package/build-module/components/styles-canvas/revisions.mjs +2 -2
- package/build-module/components/styles-canvas/revisions.mjs.map +1 -1
- package/build-module/components/sync-connection-error-modal/index.mjs +58 -76
- package/build-module/components/sync-connection-error-modal/index.mjs.map +2 -2
- package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs +33 -10
- package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs.map +2 -2
- package/build-module/components/template-actions-panel/block-theme-content.mjs +167 -0
- package/build-module/components/template-actions-panel/block-theme-content.mjs.map +7 -0
- package/build-module/components/template-actions-panel/classic-theme-content.mjs +138 -0
- package/build-module/components/template-actions-panel/classic-theme-content.mjs.map +7 -0
- package/build-module/components/template-actions-panel/index.mjs +28 -0
- package/build-module/components/template-actions-panel/index.mjs.map +7 -0
- package/build-module/dataviews/store/private-actions.mjs +5 -1
- package/build-module/dataviews/store/private-actions.mjs.map +2 -2
- package/build-module/hooks/default-autocompleters.mjs +2 -2
- package/build-module/hooks/default-autocompleters.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +15 -1
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +42 -19
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +1 -1
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-style/style-rtl.css +124 -44
- package/build-style/style.css +124 -44
- package/build-types/bindings/post-data.d.ts +3 -3
- package/build-types/bindings/term-data.d.ts +14 -14
- package/build-types/components/autocompleters/index.d.ts +1 -0
- package/build-types/components/autocompleters/link.d.ts +12 -0
- package/build-types/components/autocompleters/link.d.ts.map +1 -0
- package/build-types/components/collaborators-overlay/cursor-registry.d.ts +36 -0
- package/build-types/components/collaborators-overlay/cursor-registry.d.ts.map +1 -0
- package/build-types/components/collaborators-overlay/index.d.ts +7 -4
- package/build-types/components/collaborators-overlay/index.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts +1 -1
- package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/overlay.d.ts +4 -1
- package/build-types/components/collaborators-overlay/overlay.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/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 +4 -1
- package/build-types/components/collaborators-presence/list.d.ts.map +1 -1
- package/build-types/components/keyboard-shortcut-help-modal/config.d.ts +11 -11
- package/build-types/components/post-actions/set-as-homepage.d.ts +1 -1
- package/build-types/components/post-actions/set-as-posts-page.d.ts +1 -1
- package/build-types/components/post-card-panel/index.d.ts.map +1 -1
- package/build-types/components/post-content-information/index.d.ts +4 -1
- package/build-types/components/post-content-information/index.d.ts.map +1 -1
- package/build-types/components/post-format/index.d.ts +10 -10
- package/build-types/components/post-locked-modal/index.d.ts +2 -2
- package/build-types/components/post-revisions-panel/index.d.ts +2 -0
- package/build-types/components/post-revisions-panel/index.d.ts.map +1 -0
- package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
- package/build-types/components/post-status/index.d.ts +10 -10
- package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
- package/build-types/components/post-template/hooks.d.ts +1 -1
- package/build-types/components/post-template/hooks.d.ts.map +1 -1
- package/build-types/components/post-template/swap-template-button.d.ts +4 -0
- package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
- package/build-types/components/post-visibility/utils.d.ts +6 -6
- package/build-types/components/revision-block-diff/index.d.ts.map +1 -1
- package/build-types/components/revision-diff-panel/index.d.ts +14 -0
- package/build-types/components/revision-diff-panel/index.d.ts.map +1 -0
- package/build-types/components/revision-fields-diff/index.d.ts +6 -0
- package/build-types/components/revision-fields-diff/index.d.ts.map +1 -0
- package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/components/sidebar/post-revision-summary.d.ts +2 -0
- package/build-types/components/sidebar/post-revision-summary.d.ts.map +1 -0
- package/build-types/components/sidebar/post-summary.d.ts +3 -0
- package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
- package/build-types/components/style-book/index.d.ts +2 -1
- package/build-types/components/style-book/index.d.ts.map +1 -1
- package/build-types/components/sync-connection-error-modal/index.d.ts +0 -14
- package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -1
- package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts.map +1 -1
- package/build-types/components/template-actions-panel/block-theme-content.d.ts +2 -0
- package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -0
- package/build-types/components/template-actions-panel/classic-theme-content.d.ts +2 -0
- package/build-types/components/template-actions-panel/classic-theme-content.d.ts.map +1 -0
- package/build-types/components/template-actions-panel/index.d.ts +2 -0
- package/build-types/components/template-actions-panel/index.d.ts.map +1 -0
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +10 -10
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/utils/pageTypeBadge.d.ts +1 -1
- package/build-types/utils/pageTypeBadge.d.ts.map +1 -1
- package/package.json +45 -44
- package/src/components/autocompleters/index.js +1 -0
- package/src/components/autocompleters/link.js +47 -0
- package/src/components/autocompleters/style.scss +6 -0
- package/src/components/collaborators-overlay/cursor-dom-utils.ts +1 -1
- package/src/components/collaborators-overlay/cursor-registry.ts +96 -0
- package/src/components/collaborators-overlay/index.tsx +12 -4
- package/src/components/collaborators-overlay/overlay-iframe-styles.ts +1 -1
- package/src/components/collaborators-overlay/overlay.tsx +45 -1
- package/src/components/collaborators-overlay/timing-utils.ts +1 -1
- package/src/components/collaborators-overlay/use-render-cursors.ts +4 -2
- package/src/components/collaborators-presence/index.tsx +9 -1
- package/src/components/collaborators-presence/list.tsx +25 -1
- package/src/components/error-boundary/index.js +1 -1
- package/src/components/error-boundary/index.native.js +1 -1
- package/src/components/post-card-panel/index.js +7 -21
- package/src/components/post-content-information/index.js +5 -16
- package/src/components/post-revisions-panel/index.js +151 -0
- package/src/components/post-revisions-panel/style.scss +16 -0
- package/src/components/post-revisions-preview/revisions-slider.js +23 -19
- package/src/components/post-template/create-new-template-modal.js +1 -4
- package/src/components/post-template/hooks.js +65 -9
- package/src/components/post-template/style.scss +0 -6
- package/src/components/post-template/swap-template-button.js +30 -21
- package/src/components/post-title/index.js +3 -3
- package/src/components/preferences-modal/index.js +37 -25
- package/src/components/revision-block-diff/index.js +8 -43
- package/src/components/revision-diff-panel/index.js +59 -0
- package/src/components/revision-fields-diff/index.js +91 -0
- package/src/components/sidebar/dataform-post-summary.js +8 -55
- package/src/components/sidebar/index.js +33 -22
- package/src/components/sidebar/post-revision-summary.js +50 -0
- package/src/components/sidebar/post-summary.js +22 -40
- package/src/components/sidebar/style.scss +7 -0
- package/src/components/style-book/index.js +4 -2
- package/src/components/styles-canvas/revisions.js +2 -2
- package/src/components/sync-connection-error-modal/index.tsx +128 -155
- package/src/components/sync-connection-error-modal/use-retry-countdown.ts +46 -10
- package/src/components/template-actions-panel/block-theme-content.js +196 -0
- package/src/components/template-actions-panel/classic-theme-content.js +170 -0
- package/src/components/template-actions-panel/index.js +32 -0
- package/src/components/template-actions-panel/style.scss +39 -0
- package/src/dataviews/store/private-actions.ts +6 -0
- package/src/hooks/default-autocompleters.js +2 -2
- package/src/hooks/test/default-autocompleters.js +2 -2
- package/src/store/private-actions.js +18 -2
- package/src/store/private-selectors.js +43 -22
- package/src/store/reducer.js +9 -8
- package/src/style.scss +3 -1
- /package/src/components/{revision-block-diff → revision-diff-panel}/style.scss +0 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import {
|
|
6
|
+
useEntityRecord,
|
|
7
|
+
useEntityBlockEditor,
|
|
8
|
+
store as coreStore,
|
|
9
|
+
} from '@wordpress/core-data';
|
|
10
|
+
import { BlockPreview } from '@wordpress/block-editor';
|
|
11
|
+
import {
|
|
12
|
+
PanelBody,
|
|
13
|
+
Button,
|
|
14
|
+
__experimentalText as Text,
|
|
15
|
+
__experimentalHStack as HStack,
|
|
16
|
+
__experimentalVStack as VStack,
|
|
17
|
+
} from '@wordpress/components';
|
|
18
|
+
import { useState } from '@wordpress/element';
|
|
19
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
20
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
21
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
22
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Internal dependencies
|
|
26
|
+
*/
|
|
27
|
+
import { store as editorStore } from '../../store';
|
|
28
|
+
import CreateNewTemplateModal from '../post-template/create-new-template-modal';
|
|
29
|
+
|
|
30
|
+
export default function ClassicThemeContent() {
|
|
31
|
+
const templateId = useSelect(
|
|
32
|
+
( select ) => select( editorStore ).getCurrentTemplateId(),
|
|
33
|
+
[]
|
|
34
|
+
);
|
|
35
|
+
const [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );
|
|
36
|
+
const {
|
|
37
|
+
onNavigateToEntityRecord,
|
|
38
|
+
canCreateTemplate,
|
|
39
|
+
hasGoBack,
|
|
40
|
+
getEditorSettings,
|
|
41
|
+
} = useSelect( ( select ) => {
|
|
42
|
+
const { getEditorSettings: _getEditorSettings } = select( editorStore );
|
|
43
|
+
const editorSettings = _getEditorSettings();
|
|
44
|
+
return {
|
|
45
|
+
onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
|
|
46
|
+
canCreateTemplate:
|
|
47
|
+
!! select( coreStore ).canUser( 'create', {
|
|
48
|
+
kind: 'postType',
|
|
49
|
+
name: 'wp_template',
|
|
50
|
+
} ) && editorSettings.supportsTemplateMode,
|
|
51
|
+
hasGoBack: editorSettings.hasOwnProperty(
|
|
52
|
+
'onNavigateToPreviousEntityRecord'
|
|
53
|
+
),
|
|
54
|
+
getEditorSettings: _getEditorSettings,
|
|
55
|
+
};
|
|
56
|
+
}, [] );
|
|
57
|
+
const { get: getPreference } = useSelect( preferencesStore );
|
|
58
|
+
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
59
|
+
const { editedRecord: template } = useEntityRecord(
|
|
60
|
+
'postType',
|
|
61
|
+
'wp_template',
|
|
62
|
+
templateId
|
|
63
|
+
);
|
|
64
|
+
const [ blocks ] = useEntityBlockEditor( 'postType', 'wp_template', {
|
|
65
|
+
id: templateId,
|
|
66
|
+
} );
|
|
67
|
+
|
|
68
|
+
// Path A: No block template and cannot create templates.
|
|
69
|
+
if ( ! templateId && ! canCreateTemplate ) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const notificationAction = hasGoBack
|
|
74
|
+
? [
|
|
75
|
+
{
|
|
76
|
+
label: __( 'Go back' ),
|
|
77
|
+
onClick: () =>
|
|
78
|
+
getEditorSettings().onNavigateToPreviousEntityRecord(),
|
|
79
|
+
},
|
|
80
|
+
]
|
|
81
|
+
: undefined;
|
|
82
|
+
|
|
83
|
+
const mayShowTemplateEditNotice = () => {
|
|
84
|
+
if ( ! getPreference( 'core/edit-site', 'welcomeGuideTemplate' ) ) {
|
|
85
|
+
createSuccessNotice(
|
|
86
|
+
__(
|
|
87
|
+
'Editing template. Changes made here affect all posts and pages that use the template.'
|
|
88
|
+
),
|
|
89
|
+
{ type: 'snackbar', actions: notificationAction }
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const templateName = template
|
|
95
|
+
? decodeEntities( template.title )
|
|
96
|
+
: undefined;
|
|
97
|
+
|
|
98
|
+
const previewContent = !! blocks?.length && (
|
|
99
|
+
<BlockPreview.Async>
|
|
100
|
+
<BlockPreview blocks={ blocks } />
|
|
101
|
+
</BlockPreview.Async>
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<>
|
|
106
|
+
<PanelBody
|
|
107
|
+
title={
|
|
108
|
+
template
|
|
109
|
+
? sprintf(
|
|
110
|
+
/* translators: %s: template name */
|
|
111
|
+
__( 'Template: %s' ),
|
|
112
|
+
templateName
|
|
113
|
+
)
|
|
114
|
+
: __( 'Template' )
|
|
115
|
+
}
|
|
116
|
+
initialOpen={ false }
|
|
117
|
+
>
|
|
118
|
+
<VStack>
|
|
119
|
+
{ ! templateId && (
|
|
120
|
+
<Text>
|
|
121
|
+
{ __(
|
|
122
|
+
'This page uses a classic template. To edit this template with blocks, create a block template.'
|
|
123
|
+
) }
|
|
124
|
+
</Text>
|
|
125
|
+
) }
|
|
126
|
+
{ template && previewContent && (
|
|
127
|
+
<div className="editor-template-actions-panel__preview">
|
|
128
|
+
{ previewContent }
|
|
129
|
+
</div>
|
|
130
|
+
) }
|
|
131
|
+
<HStack>
|
|
132
|
+
{ template && onNavigateToEntityRecord && (
|
|
133
|
+
<Button
|
|
134
|
+
className="editor-template-actions-panel__action"
|
|
135
|
+
__next40pxDefaultSize
|
|
136
|
+
variant="secondary"
|
|
137
|
+
onClick={ () => {
|
|
138
|
+
onNavigateToEntityRecord( {
|
|
139
|
+
postId: template.id,
|
|
140
|
+
postType: 'wp_template',
|
|
141
|
+
} );
|
|
142
|
+
mayShowTemplateEditNotice();
|
|
143
|
+
} }
|
|
144
|
+
>
|
|
145
|
+
{ __( 'Edit' ) }
|
|
146
|
+
</Button>
|
|
147
|
+
) }
|
|
148
|
+
{ canCreateTemplate && (
|
|
149
|
+
<Button
|
|
150
|
+
className="editor-template-actions-panel__action"
|
|
151
|
+
__next40pxDefaultSize
|
|
152
|
+
variant="secondary"
|
|
153
|
+
onClick={ () => setIsCreateModalOpen( true ) }
|
|
154
|
+
>
|
|
155
|
+
{ ! templateId
|
|
156
|
+
? __( 'Create block template' )
|
|
157
|
+
: __( 'Create new' ) }
|
|
158
|
+
</Button>
|
|
159
|
+
) }
|
|
160
|
+
</HStack>
|
|
161
|
+
</VStack>
|
|
162
|
+
</PanelBody>
|
|
163
|
+
{ isCreateModalOpen && (
|
|
164
|
+
<CreateNewTemplateModal
|
|
165
|
+
onClose={ () => setIsCreateModalOpen( false ) }
|
|
166
|
+
/>
|
|
167
|
+
) }
|
|
168
|
+
</>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { store as editorStore } from '../../store';
|
|
10
|
+
import { usePostTemplatePanelMode } from '../post-template/hooks';
|
|
11
|
+
import BlockThemeContent from './block-theme-content';
|
|
12
|
+
import ClassicThemeContent from './classic-theme-content';
|
|
13
|
+
|
|
14
|
+
export default function TemplateActionsPanel() {
|
|
15
|
+
const postType = useSelect(
|
|
16
|
+
( select ) => select( editorStore ).getCurrentPostType(),
|
|
17
|
+
[]
|
|
18
|
+
);
|
|
19
|
+
const mode = usePostTemplatePanelMode();
|
|
20
|
+
// This check is because the experiment is gated for these post
|
|
21
|
+
// types for now. Later we should use `postType.viewable`.
|
|
22
|
+
if ( ! [ 'page', 'post' ].includes( postType ) ) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
if ( mode === 'classic' ) {
|
|
26
|
+
return <ClassicThemeContent />;
|
|
27
|
+
}
|
|
28
|
+
if ( mode === 'block-theme' ) {
|
|
29
|
+
return <BlockThemeContent />;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
@use "@wordpress/base-styles/variables" as *;
|
|
2
|
+
@use "@wordpress/base-styles/colors" as *;
|
|
3
|
+
|
|
4
|
+
.editor-template-actions-panel__preview {
|
|
5
|
+
.block-editor-block-preview__container {
|
|
6
|
+
display: flex;
|
|
7
|
+
aspect-ratio: 4/3;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
border-radius: $radius-medium;
|
|
10
|
+
|
|
11
|
+
&::after {
|
|
12
|
+
outline: $border-width solid rgba($black, 0.1);
|
|
13
|
+
outline-offset: -$border-width;
|
|
14
|
+
border-radius: $radius-medium;
|
|
15
|
+
@media not (prefers-reduced-motion) {
|
|
16
|
+
transition: outline 0.1s linear;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&[role="button"] {
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
|
|
24
|
+
&:hover .block-editor-block-preview__container::after {
|
|
25
|
+
outline-color: rgba($black, 0.3);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&:focus-visible .block-editor-block-preview__container::after {
|
|
29
|
+
outline-color: var(--wp-admin-theme-color);
|
|
30
|
+
outline-width: var(--wp-admin-border-width-focus);
|
|
31
|
+
outline-offset: calc(-1 * var(--wp-admin-border-width-focus));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.editor-template-actions-panel__action {
|
|
37
|
+
flex: 1;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
}
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
resetPost,
|
|
20
20
|
deletePost,
|
|
21
21
|
duplicateTemplatePart,
|
|
22
|
+
excerptField,
|
|
22
23
|
featuredImageField,
|
|
23
24
|
dateField,
|
|
24
25
|
parentField,
|
|
@@ -38,6 +39,7 @@ import {
|
|
|
38
39
|
scheduledDateField,
|
|
39
40
|
formatField,
|
|
40
41
|
postContentInfoField,
|
|
42
|
+
stickyField,
|
|
41
43
|
} from '@wordpress/fields';
|
|
42
44
|
import {
|
|
43
45
|
altTextField,
|
|
@@ -267,6 +269,9 @@ export const registerPostTypeSchema =
|
|
|
267
269
|
! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&
|
|
268
270
|
scheduledDateField,
|
|
269
271
|
slugField,
|
|
272
|
+
! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&
|
|
273
|
+
postTypeConfig.supports?.excerpt &&
|
|
274
|
+
excerptField,
|
|
270
275
|
postTypeConfig.supports?.[ 'page-attributes' ] && parentField,
|
|
271
276
|
postTypeConfig.supports?.comments && commentStatusField,
|
|
272
277
|
postTypeConfig.supports?.trackbacks && pingStatusField,
|
|
@@ -281,6 +286,7 @@ export const registerPostTypeSchema =
|
|
|
281
286
|
postTypeConfig.supports?.editor &&
|
|
282
287
|
postContentInfoField,
|
|
283
288
|
passwordField,
|
|
289
|
+
postTypeConfig.slug === 'post' && stickyField,
|
|
284
290
|
postTypeConfig.supports?.editor &&
|
|
285
291
|
postTypeConfig.viewable &&
|
|
286
292
|
postPreviewField,
|
|
@@ -6,11 +6,11 @@ import { addFilter } from '@wordpress/hooks';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { userAutocompleter } from '../components';
|
|
9
|
+
import { linkAutocompleter, userAutocompleter } from '../components';
|
|
10
10
|
|
|
11
11
|
function setDefaultCompleters( completers = [] ) {
|
|
12
12
|
// Provide copies so filters may directly modify them.
|
|
13
|
-
completers.push( { ...userAutocompleter } );
|
|
13
|
+
completers.push( { ...linkAutocompleter }, { ...userAutocompleter } );
|
|
14
14
|
|
|
15
15
|
return completers;
|
|
16
16
|
}
|
|
@@ -7,11 +7,11 @@ import { applyFilters } from '@wordpress/hooks';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import '../default-autocompleters';
|
|
10
|
-
import { userAutocompleter } from '../../components';
|
|
10
|
+
import { linkAutocompleter, userAutocompleter } from '../../components';
|
|
11
11
|
|
|
12
12
|
describe( 'default-autocompleters', () => {
|
|
13
13
|
const BLOCK_NAME = 'core/foo';
|
|
14
|
-
const defaultAutocompleters = [ userAutocompleter ];
|
|
14
|
+
const defaultAutocompleters = [ linkAutocompleter, userAutocompleter ];
|
|
15
15
|
|
|
16
16
|
it( 'provides default completers if none are provided', () => {
|
|
17
17
|
const result = applyFilters(
|
|
@@ -627,6 +627,11 @@ export const restoreRevision =
|
|
|
627
627
|
const postType = select.getCurrentPostType();
|
|
628
628
|
const postId = select.getCurrentPostId();
|
|
629
629
|
|
|
630
|
+
const entityConfig = registry
|
|
631
|
+
.select( coreStore )
|
|
632
|
+
.getEntityConfig( 'postType', postType );
|
|
633
|
+
const revisionKey = entityConfig?.revisionKey || 'id';
|
|
634
|
+
|
|
630
635
|
// Use resolveSelect to ensure the revision is fetched if not yet
|
|
631
636
|
// in the store. The _fields parameter matches the query used by
|
|
632
637
|
// getRevisions so the result is served from cache without an
|
|
@@ -635,8 +640,19 @@ export const restoreRevision =
|
|
|
635
640
|
.resolveSelect( coreStore )
|
|
636
641
|
.getRevision( 'postType', postType, postId, revisionId, {
|
|
637
642
|
context: 'edit',
|
|
638
|
-
_fields:
|
|
639
|
-
|
|
643
|
+
_fields: [
|
|
644
|
+
...new Set( [
|
|
645
|
+
'id',
|
|
646
|
+
'date',
|
|
647
|
+
'modified',
|
|
648
|
+
'author',
|
|
649
|
+
'meta',
|
|
650
|
+
'title.raw',
|
|
651
|
+
'excerpt.raw',
|
|
652
|
+
'content.raw',
|
|
653
|
+
revisionKey,
|
|
654
|
+
] ),
|
|
655
|
+
].join(),
|
|
640
656
|
} );
|
|
641
657
|
|
|
642
658
|
if ( ! revision ) {
|
|
@@ -390,6 +390,11 @@ export const getCurrentRevision = createRegistrySelector(
|
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
const { type: postType, id: postId } = getCurrentPost( state );
|
|
393
|
+
const entityConfig = select( coreStore ).getEntityConfig(
|
|
394
|
+
'postType',
|
|
395
|
+
postType
|
|
396
|
+
);
|
|
397
|
+
const revisionKey = entityConfig?.revisionKey || 'id';
|
|
393
398
|
// - Use getRevisions (plural) instead of getRevision (singular) to
|
|
394
399
|
// avoid a race condition where both API calls complete around the
|
|
395
400
|
// same time and the single revision fetch overwrites the list in the
|
|
@@ -404,19 +409,27 @@ export const getCurrentRevision = createRegistrySelector(
|
|
|
404
409
|
{
|
|
405
410
|
per_page: -1,
|
|
406
411
|
context: 'edit',
|
|
407
|
-
_fields:
|
|
408
|
-
|
|
412
|
+
_fields: [
|
|
413
|
+
...new Set( [
|
|
414
|
+
'id',
|
|
415
|
+
'date',
|
|
416
|
+
'modified',
|
|
417
|
+
'author',
|
|
418
|
+
'meta',
|
|
419
|
+
'title.raw',
|
|
420
|
+
'excerpt.raw',
|
|
421
|
+
'content.raw',
|
|
422
|
+
revisionKey,
|
|
423
|
+
] ),
|
|
424
|
+
].join(),
|
|
409
425
|
}
|
|
410
426
|
);
|
|
411
427
|
if ( ! revisions ) {
|
|
412
428
|
return null;
|
|
413
429
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
postType
|
|
430
|
+
return (
|
|
431
|
+
revisions.find( ( r ) => r[ revisionKey ] === revisionId ) ?? null
|
|
417
432
|
);
|
|
418
|
-
const revKey = entityConfig?.revisionKey || 'id';
|
|
419
|
-
return revisions.find( ( r ) => r[ revKey ] === revisionId ) ?? null;
|
|
420
433
|
}
|
|
421
434
|
);
|
|
422
435
|
|
|
@@ -457,6 +470,11 @@ export const getPreviousRevision = createRegistrySelector(
|
|
|
457
470
|
}
|
|
458
471
|
|
|
459
472
|
const { type: postType, id: postId } = getCurrentPost( state );
|
|
473
|
+
const entityConfig = select( coreStore ).getEntityConfig(
|
|
474
|
+
'postType',
|
|
475
|
+
postType
|
|
476
|
+
);
|
|
477
|
+
const revisionKey = entityConfig?.revisionKey || 'id';
|
|
460
478
|
const revisions = select( coreStore ).getRevisions(
|
|
461
479
|
'postType',
|
|
462
480
|
postType,
|
|
@@ -464,32 +482,35 @@ export const getPreviousRevision = createRegistrySelector(
|
|
|
464
482
|
{
|
|
465
483
|
per_page: -1,
|
|
466
484
|
context: 'edit',
|
|
467
|
-
|
|
468
|
-
|
|
485
|
+
orderby: 'date',
|
|
486
|
+
order: 'asc',
|
|
487
|
+
_fields: [
|
|
488
|
+
...new Set( [
|
|
489
|
+
'id',
|
|
490
|
+
'date',
|
|
491
|
+
'modified',
|
|
492
|
+
'author',
|
|
493
|
+
'meta',
|
|
494
|
+
'title.raw',
|
|
495
|
+
'excerpt.raw',
|
|
496
|
+
'content.raw',
|
|
497
|
+
revisionKey,
|
|
498
|
+
] ),
|
|
499
|
+
].join(),
|
|
469
500
|
}
|
|
470
501
|
);
|
|
471
502
|
if ( ! revisions ) {
|
|
472
503
|
return null;
|
|
473
504
|
}
|
|
474
505
|
|
|
475
|
-
// Sort by date ascending (oldest first).
|
|
476
|
-
const sortedRevisions = [ ...revisions ].sort(
|
|
477
|
-
( a, b ) => new Date( a.date ) - new Date( b.date )
|
|
478
|
-
);
|
|
479
|
-
|
|
480
506
|
// Find current revision index.
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
postType
|
|
484
|
-
);
|
|
485
|
-
const revKey = entityConfig?.revisionKey || 'id';
|
|
486
|
-
const currentIndex = sortedRevisions.findIndex(
|
|
487
|
-
( r ) => r[ revKey ] === currentRevisionId
|
|
507
|
+
const currentIndex = revisions.findIndex(
|
|
508
|
+
( r ) => r[ revisionKey ] === currentRevisionId
|
|
488
509
|
);
|
|
489
510
|
|
|
490
511
|
// Return the previous revision (older one) if it exists.
|
|
491
512
|
if ( currentIndex > 0 ) {
|
|
492
|
-
return
|
|
513
|
+
return revisions[ currentIndex - 1 ];
|
|
493
514
|
}
|
|
494
515
|
|
|
495
516
|
return null;
|
package/src/store/reducer.js
CHANGED
|
@@ -449,13 +449,6 @@ export function revisionId( state = null, action ) {
|
|
|
449
449
|
return state;
|
|
450
450
|
}
|
|
451
451
|
|
|
452
|
-
/**
|
|
453
|
-
* Reducer returning the currently selected note and its options.
|
|
454
|
-
*
|
|
455
|
-
* @param {Object} state Current state.
|
|
456
|
-
* @param {Object} action Dispatched action.
|
|
457
|
-
* @return {Object} Updated state.
|
|
458
|
-
*/
|
|
459
452
|
/**
|
|
460
453
|
* Reducer for whether the revision diff is shown.
|
|
461
454
|
* Resets to true when entering/exiting revisions mode.
|
|
@@ -469,11 +462,19 @@ export function showRevisionDiff( state = true, action ) {
|
|
|
469
462
|
case 'SET_SHOW_REVISION_DIFF':
|
|
470
463
|
return action.showDiff;
|
|
471
464
|
case 'SET_CURRENT_REVISION_ID':
|
|
472
|
-
|
|
465
|
+
// Reset during the exit.
|
|
466
|
+
return ! action.revisionId ? true : state;
|
|
473
467
|
}
|
|
474
468
|
return state;
|
|
475
469
|
}
|
|
476
470
|
|
|
471
|
+
/**
|
|
472
|
+
* Reducer returning the currently selected note and its options.
|
|
473
|
+
*
|
|
474
|
+
* @param {Object} state Current state.
|
|
475
|
+
* @param {Object} action Dispatched action.
|
|
476
|
+
* @return {Object} Updated state.
|
|
477
|
+
*/
|
|
477
478
|
export function selectedNote( state = {}, action ) {
|
|
478
479
|
switch ( action.type ) {
|
|
479
480
|
case 'SELECT_NOTE':
|
package/src/style.scss
CHANGED
|
@@ -38,8 +38,9 @@
|
|
|
38
38
|
@use "./components/post-panel-row/style.scss" as *;
|
|
39
39
|
@use "./components/post-panel-section/style.scss" as *;
|
|
40
40
|
@use "./components/post-publish-panel/style.scss" as *;
|
|
41
|
+
@use "./components/post-revisions-panel/style.scss" as *;
|
|
41
42
|
@use "./components/post-revisions-preview/style.scss" as *;
|
|
42
|
-
@use "./components/revision-
|
|
43
|
+
@use "./components/revision-diff-panel/style.scss" as *;
|
|
43
44
|
@use "./components/post-saved-state/style.scss" as *;
|
|
44
45
|
@use "./components/post-schedule/style.scss" as *;
|
|
45
46
|
@use "./components/post-status/style.scss" as *;
|
|
@@ -48,6 +49,7 @@
|
|
|
48
49
|
@use "./components/post-taxonomies/style.scss" as *;
|
|
49
50
|
@use "./components/sync-connection-error-modal/style.scss" as *;
|
|
50
51
|
@use "./components/post-template/style.scss" as *;
|
|
52
|
+
@use "./components/template-actions-panel/style.scss" as *;
|
|
51
53
|
@use "./components/post-text-editor/style.scss" as *;
|
|
52
54
|
@use "./components/post-title/style.scss" as *;
|
|
53
55
|
@use "./components/post-url/style.scss" as *;
|
|
File without changes
|