@wordpress/editor 13.24.1 → 13.26.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 +8 -0
- package/LICENSE.md +1 -1
- package/build/components/document-bar/index.js +164 -0
- package/build/components/document-bar/index.js.map +1 -0
- package/build/components/document-outline/index.js +82 -1
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-tools/index.js +160 -0
- package/build/components/document-tools/index.js.map +1 -0
- package/build/components/editor-canvas/edit-template-blocks-notification.js +106 -0
- package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -0
- package/build/components/editor-canvas/index.js +298 -0
- package/build/components/editor-canvas/index.js.map +1 -0
- package/build/components/entities-saved-states/index.js +3 -1
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/index.js +12 -2
- package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +9 -0
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/index.js +72 -8
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +9 -1
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +77 -0
- package/build/components/inserter-sidebar/index.js.map +1 -0
- package/build/components/list-view-sidebar/index.js +150 -0
- package/build/components/list-view-sidebar/index.js.map +1 -0
- package/build/components/list-view-sidebar/list-view-outline.js +28 -0
- package/build/components/list-view-sidebar/list-view-outline.js.map +1 -0
- package/build/components/offline-status/index.native.js +85 -0
- package/build/components/offline-status/index.native.js.map +1 -0
- package/build/components/page-attributes/panel.js +63 -0
- package/build/components/page-attributes/panel.js.map +1 -0
- package/build/components/post-discussion/panel.js +59 -0
- package/build/components/post-discussion/panel.js.map +1 -0
- package/build/components/post-excerpt/check.js +19 -0
- package/build/components/post-excerpt/check.js.map +1 -1
- package/build/components/post-excerpt/panel.js +55 -0
- package/build/components/post-excerpt/panel.js.map +1 -0
- package/build/components/post-excerpt/plugin.js +72 -0
- package/build/components/post-excerpt/plugin.js.map +1 -0
- package/build/components/post-featured-image/index.js +5 -8
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-featured-image/panel.js +60 -0
- package/build/components/post-featured-image/panel.js.map +1 -0
- package/build/components/post-last-revision/panel.js +27 -0
- package/build/components/post-last-revision/panel.js.map +1 -0
- package/build/components/post-publish-button/index.js +1 -0
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.js +2 -4
- package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build/components/post-saved-state/index.js +13 -8
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-schedule/panel.js +1 -1
- package/build/components/post-schedule/panel.js.map +1 -1
- package/build/components/post-taxonomies/panel.js +68 -0
- package/build/components/post-taxonomies/panel.js.map +1 -0
- package/build/components/post-template/block-theme.js +100 -0
- package/build/components/post-template/block-theme.js.map +1 -0
- package/build/components/post-template/classic-theme.js +171 -0
- package/build/components/post-template/classic-theme.js.map +1 -0
- package/build/components/post-template/create-new-template-modal.js +98 -0
- package/build/components/post-template/create-new-template-modal.js.map +1 -0
- package/build/components/post-template/create-new-template.js +55 -0
- package/build/components/post-template/create-new-template.js.map +1 -0
- package/build/components/post-template/hooks.js +88 -0
- package/build/components/post-template/hooks.js.map +1 -0
- package/build/components/post-template/panel.js +70 -0
- package/build/components/post-template/panel.js.map +1 -0
- package/build/components/post-template/reset-default-template.js +48 -0
- package/build/components/post-template/reset-default-template.js.map +1 -0
- package/build/components/post-template/swap-template-button.js +86 -0
- package/build/components/post-template/swap-template-button.js.map +1 -0
- package/build/components/post-title/index.native.js +25 -15
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-view-link/index.js +58 -0
- package/build/components/post-view-link/index.js.map +1 -0
- package/build/components/post-visibility/check.js +5 -17
- package/build/components/post-visibility/check.js.map +1 -1
- package/build/components/preview-dropdown/index.js +118 -0
- package/build/components/preview-dropdown/index.js.map +1 -0
- package/build/components/provider/index.js +24 -82
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/index.native.js +36 -8
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/navigation-block-editing-mode.js +40 -0
- package/build/components/provider/navigation-block-editing-mode.js.map +1 -0
- package/build/components/provider/use-block-editor-settings.js +38 -15
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/hooks/index.js +1 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/pattern-partial-syncing.js +49 -0
- package/build/hooks/pattern-partial-syncing.js.map +1 -0
- package/build/private-apis.js +14 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +161 -13
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +2 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/index.js +5 -0
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +52 -0
- package/build/store/private-actions.js.map +1 -0
- package/build/store/private-selectors.js +52 -0
- package/build/store/private-selectors.js.map +1 -0
- package/build/store/reducer.js +109 -27
- package/build/store/reducer.js.map +1 -1
- package/build/store/reducer.native.js +0 -1
- package/build/store/reducer.native.js.map +1 -1
- package/build/store/selectors.js +104 -9
- package/build/store/selectors.js.map +1 -1
- package/build/utils/media-upload/index.js +8 -2
- package/build/utils/media-upload/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +156 -0
- package/build-module/components/document-bar/index.js.map +1 -0
- package/build-module/components/document-outline/index.js +82 -1
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/document-tools/index.js +151 -0
- package/build-module/components/document-tools/index.js.map +1 -0
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js +100 -0
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -0
- package/build-module/components/editor-canvas/index.js +289 -0
- package/build-module/components/editor-canvas/index.js.map +1 -0
- package/build-module/components/entities-saved-states/index.js +3 -1
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/index.js +12 -2
- package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +9 -0
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build-module/components/index.js +9 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +70 -0
- package/build-module/components/inserter-sidebar/index.js.map +1 -0
- package/build-module/components/list-view-sidebar/index.js +142 -0
- package/build-module/components/list-view-sidebar/index.js.map +1 -0
- package/build-module/components/list-view-sidebar/list-view-outline.js +20 -0
- package/build-module/components/list-view-sidebar/list-view-outline.js.map +1 -0
- package/build-module/components/offline-status/index.native.js +77 -0
- package/build-module/components/offline-status/index.native.js.map +1 -0
- package/build-module/components/page-attributes/panel.js +53 -0
- package/build-module/components/page-attributes/panel.js.map +1 -0
- package/build-module/components/post-discussion/panel.js +50 -0
- package/build-module/components/post-discussion/panel.js.map +1 -0
- package/build-module/components/post-excerpt/check.js +19 -0
- package/build-module/components/post-excerpt/check.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +48 -0
- package/build-module/components/post-excerpt/panel.js.map +1 -0
- package/build-module/components/post-excerpt/plugin.js +64 -0
- package/build-module/components/post-excerpt/plugin.js.map +1 -0
- package/build-module/components/post-featured-image/index.js +5 -8
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-featured-image/panel.js +51 -0
- package/build-module/components/post-featured-image/panel.js.map +1 -0
- package/build-module/components/post-last-revision/panel.js +18 -0
- package/build-module/components/post-last-revision/panel.js.map +1 -0
- package/build-module/components/post-publish-button/index.js +1 -0
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.js +2 -4
- package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +13 -8
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-schedule/panel.js +1 -1
- package/build-module/components/post-schedule/panel.js.map +1 -1
- package/build-module/components/post-taxonomies/panel.js +59 -0
- package/build-module/components/post-taxonomies/panel.js.map +1 -0
- package/build-module/components/post-template/block-theme.js +92 -0
- package/build-module/components/post-template/block-theme.js.map +1 -0
- package/build-module/components/post-template/classic-theme.js +162 -0
- package/build-module/components/post-template/classic-theme.js.map +1 -0
- package/build-module/components/post-template/create-new-template-modal.js +91 -0
- package/build-module/components/post-template/create-new-template-modal.js.map +1 -0
- package/build-module/components/post-template/create-new-template.js +47 -0
- package/build-module/components/post-template/create-new-template.js.map +1 -0
- package/build-module/components/post-template/hooks.js +78 -0
- package/build-module/components/post-template/hooks.js.map +1 -0
- package/build-module/components/post-template/panel.js +62 -0
- package/build-module/components/post-template/panel.js.map +1 -0
- package/build-module/components/post-template/reset-default-template.js +41 -0
- package/build-module/components/post-template/reset-default-template.js.map +1 -0
- package/build-module/components/post-template/swap-template-button.js +79 -0
- package/build-module/components/post-template/swap-template-button.js.map +1 -0
- package/build-module/components/post-title/index.native.js +26 -16
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/post-view-link/index.js +51 -0
- package/build-module/components/post-view-link/index.js.map +1 -0
- package/build-module/components/post-visibility/check.js +6 -16
- package/build-module/components/post-visibility/check.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +110 -0
- package/build-module/components/preview-dropdown/index.js.map +1 -0
- package/build-module/components/provider/index.js +25 -83
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +37 -9
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/navigation-block-editing-mode.js +34 -0
- package/build-module/components/provider/navigation-block-editing-mode.js.map +1 -0
- package/build-module/components/provider/use-block-editor-settings.js +38 -15
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/pattern-partial-syncing.js +46 -0
- package/build-module/hooks/pattern-partial-syncing.js.map +1 -0
- package/build-module/private-apis.js +14 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +147 -9
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +2 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/index.js +5 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +44 -0
- package/build-module/store/private-actions.js.map +1 -0
- package/build-module/store/private-selectors.js +43 -0
- package/build-module/store/private-selectors.js.map +1 -0
- package/build-module/store/reducer.js +103 -26
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/reducer.native.js +1 -2
- package/build-module/store/reducer.native.js.map +1 -1
- package/build-module/store/selectors.js +93 -6
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/media-upload/index.js +8 -2
- package/build-module/utils/media-upload/index.js.map +1 -1
- package/build-style/style-rtl.css +433 -0
- package/build-style/style.css +433 -0
- package/package.json +32 -31
- package/src/components/document-bar/index.js +193 -0
- package/src/components/document-bar/style.scss +130 -0
- package/src/components/document-outline/index.js +48 -1
- package/src/components/document-outline/style.scss +12 -0
- package/src/components/document-tools/index.js +177 -0
- package/src/components/document-tools/style.scss +98 -0
- package/src/components/editor-canvas/edit-template-blocks-notification.js +108 -0
- package/src/components/editor-canvas/index.js +386 -0
- package/src/components/editor-canvas/style.scss +5 -0
- package/src/components/entities-saved-states/index.js +3 -1
- package/src/components/entities-saved-states/style.scss +4 -0
- package/src/components/global-keyboard-shortcuts/index.js +12 -2
- package/src/components/global-keyboard-shortcuts/register-shortcuts.js +10 -0
- package/src/components/index.js +9 -1
- package/src/components/index.native.js +1 -0
- package/src/components/inserter-sidebar/index.js +73 -0
- package/src/components/inserter-sidebar/style.scss +22 -0
- package/src/components/list-view-sidebar/index.js +169 -0
- package/src/components/list-view-sidebar/list-view-outline.js +37 -0
- package/src/components/list-view-sidebar/style.scss +84 -0
- package/src/components/offline-status/index.native.js +101 -0
- package/src/components/offline-status/style.native.scss +28 -0
- package/src/components/offline-status/test/index.native.js +108 -0
- package/src/components/page-attributes/panel.js +62 -0
- package/src/components/post-discussion/panel.js +57 -0
- package/src/components/post-excerpt/check.js +18 -0
- package/src/components/post-excerpt/panel.js +57 -0
- package/src/components/post-excerpt/plugin.js +61 -0
- package/src/components/post-excerpt/test/plugin.js +36 -0
- package/src/components/post-featured-image/index.js +3 -7
- package/src/components/post-featured-image/panel.js +55 -0
- package/src/components/post-last-revision/panel.js +22 -0
- package/src/components/post-last-revision/style.scss +10 -0
- package/src/components/post-publish-button/index.js +1 -0
- package/src/components/post-publish-panel/maybe-upload-media.js +3 -8
- package/src/components/post-saved-state/index.js +9 -8
- package/src/components/post-saved-state/test/__snapshots__/index.js.snap +2 -2
- package/src/components/post-schedule/panel.js +1 -1
- package/src/components/post-taxonomies/panel.js +66 -0
- package/src/components/post-template/block-theme.js +110 -0
- package/src/components/post-template/classic-theme.js +213 -0
- package/src/components/post-template/create-new-template-modal.js +139 -0
- package/src/components/post-template/create-new-template.js +50 -0
- package/src/components/post-template/hooks.js +95 -0
- package/src/components/post-template/panel.js +66 -0
- package/src/components/post-template/reset-default-template.js +43 -0
- package/src/components/post-template/style.scss +52 -0
- package/src/components/post-template/swap-template-button.js +86 -0
- package/src/components/post-title/index.native.js +32 -18
- package/src/components/post-title/style.scss +1 -0
- package/src/components/post-title/test/__snapshots__/index.native.js.snap +25 -0
- package/src/components/post-title/test/index.native.js +78 -0
- package/src/components/post-view-link/index.js +47 -0
- package/src/components/post-visibility/check.js +10 -15
- package/src/components/post-visibility/test/check.js +24 -13
- package/src/components/preview-dropdown/index.js +133 -0
- package/src/components/preview-dropdown/style.scss +5 -0
- package/src/components/provider/index.js +28 -118
- package/src/components/provider/index.native.js +55 -14
- package/src/components/provider/navigation-block-editing-mode.js +37 -0
- package/src/components/provider/use-block-editor-settings.js +42 -17
- package/src/hooks/index.js +1 -0
- package/src/hooks/pattern-partial-syncing.js +73 -0
- package/src/private-apis.js +14 -0
- package/src/store/actions.js +160 -9
- package/src/store/defaults.js +1 -0
- package/src/store/index.js +5 -0
- package/src/store/private-actions.js +61 -0
- package/src/store/private-selectors.js +51 -0
- package/src/store/reducer.js +103 -26
- package/src/store/reducer.native.js +0 -2
- package/src/store/selectors.js +144 -42
- package/src/store/test/actions.js +56 -0
- package/src/store/test/reducer.js +98 -0
- package/src/store/test/selectors.js +137 -147
- package/src/style.scss +7 -0
- package/src/utils/media-upload/index.js +9 -2
- package/build/components/post-template/index.js +0 -66
- package/build/components/post-template/index.js.map +0 -1
- package/build-module/components/post-template/index.js +0 -57
- package/build-module/components/post-template/index.js.map +0 -1
- package/src/components/post-template/index.js +0 -64
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import { useEffect, useState, useRef } from '@wordpress/element';
|
|
6
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { store as editorStore } from '../../store';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Component that:
|
|
17
|
+
*
|
|
18
|
+
* - Displays a 'Edit your template to edit this block' notification when the
|
|
19
|
+
* user is focusing on editing page content and clicks on a disabled template
|
|
20
|
+
* block.
|
|
21
|
+
* - Displays a 'Edit your template to edit this block' dialog when the user
|
|
22
|
+
* is focusing on editing page conetnt and double clicks on a disabled
|
|
23
|
+
* template block.
|
|
24
|
+
*
|
|
25
|
+
* @param {Object} props
|
|
26
|
+
* @param {import('react').RefObject<HTMLElement>} props.contentRef Ref to the block
|
|
27
|
+
* editor iframe canvas.
|
|
28
|
+
*/
|
|
29
|
+
export default function EditTemplateBlocksNotification( { contentRef } ) {
|
|
30
|
+
const renderingMode = useSelect(
|
|
31
|
+
( select ) => select( editorStore ).getRenderingMode(),
|
|
32
|
+
[]
|
|
33
|
+
);
|
|
34
|
+
const { getNotices } = useSelect( noticesStore );
|
|
35
|
+
|
|
36
|
+
const { createInfoNotice, removeNotice } = useDispatch( noticesStore );
|
|
37
|
+
const { setRenderingMode } = useDispatch( editorStore );
|
|
38
|
+
|
|
39
|
+
const [ isDialogOpen, setIsDialogOpen ] = useState( false );
|
|
40
|
+
|
|
41
|
+
const lastNoticeId = useRef( 0 );
|
|
42
|
+
|
|
43
|
+
useEffect( () => {
|
|
44
|
+
const handleClick = async ( event ) => {
|
|
45
|
+
if ( renderingMode !== 'template-locked' ) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if ( ! event.target.classList.contains( 'is-root-container' ) ) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const isNoticeAlreadyShowing = getNotices().some(
|
|
52
|
+
( notice ) => notice.id === lastNoticeId.current
|
|
53
|
+
);
|
|
54
|
+
if ( isNoticeAlreadyShowing ) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const { notice } = await createInfoNotice(
|
|
58
|
+
__( 'Edit your template to edit this block.' ),
|
|
59
|
+
{
|
|
60
|
+
isDismissible: true,
|
|
61
|
+
type: 'snackbar',
|
|
62
|
+
actions: [
|
|
63
|
+
{
|
|
64
|
+
label: __( 'Edit template' ),
|
|
65
|
+
onClick: () => setRenderingMode( 'template-only' ),
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
lastNoticeId.current = notice.id;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const handleDblClick = ( event ) => {
|
|
74
|
+
if ( renderingMode !== 'template-locked' ) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if ( ! event.target.classList.contains( 'is-root-container' ) ) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if ( lastNoticeId.current ) {
|
|
81
|
+
removeNotice( lastNoticeId.current );
|
|
82
|
+
}
|
|
83
|
+
setIsDialogOpen( true );
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const canvas = contentRef.current;
|
|
87
|
+
canvas?.addEventListener( 'click', handleClick );
|
|
88
|
+
canvas?.addEventListener( 'dblclick', handleDblClick );
|
|
89
|
+
return () => {
|
|
90
|
+
canvas?.removeEventListener( 'click', handleClick );
|
|
91
|
+
canvas?.removeEventListener( 'dblclick', handleDblClick );
|
|
92
|
+
};
|
|
93
|
+
}, [ lastNoticeId, renderingMode, contentRef.current ] );
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<ConfirmDialog
|
|
97
|
+
isOpen={ isDialogOpen }
|
|
98
|
+
confirmButtonText={ __( 'Edit template' ) }
|
|
99
|
+
onConfirm={ () => {
|
|
100
|
+
setIsDialogOpen( false );
|
|
101
|
+
setRenderingMode( 'template-only' );
|
|
102
|
+
} }
|
|
103
|
+
onCancel={ () => setIsDialogOpen( false ) }
|
|
104
|
+
>
|
|
105
|
+
{ __( 'Edit your template to edit this block.' ) }
|
|
106
|
+
</ConfirmDialog>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import {
|
|
10
|
+
BlockList,
|
|
11
|
+
store as blockEditorStore,
|
|
12
|
+
__unstableUseTypewriter as useTypewriter,
|
|
13
|
+
__unstableUseTypingObserver as useTypingObserver,
|
|
14
|
+
useSettings,
|
|
15
|
+
__experimentalRecursionProvider as RecursionProvider,
|
|
16
|
+
privateApis as blockEditorPrivateApis,
|
|
17
|
+
__experimentalUseResizeCanvas as useResizeCanvas,
|
|
18
|
+
} from '@wordpress/block-editor';
|
|
19
|
+
import { useEffect, useRef, useMemo } from '@wordpress/element';
|
|
20
|
+
import { useSelect } from '@wordpress/data';
|
|
21
|
+
import { parse } from '@wordpress/blocks';
|
|
22
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
23
|
+
import { useMergeRefs } from '@wordpress/compose';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Internal dependencies
|
|
27
|
+
*/
|
|
28
|
+
import PostTitle from '../post-title';
|
|
29
|
+
import { store as editorStore } from '../../store';
|
|
30
|
+
import { unlock } from '../../lock-unlock';
|
|
31
|
+
import EditTemplateBlocksNotification from './edit-template-blocks-notification';
|
|
32
|
+
|
|
33
|
+
const {
|
|
34
|
+
LayoutStyle,
|
|
35
|
+
useLayoutClasses,
|
|
36
|
+
useLayoutStyles,
|
|
37
|
+
ExperimentalBlockCanvas: BlockCanvas,
|
|
38
|
+
} = unlock( blockEditorPrivateApis );
|
|
39
|
+
|
|
40
|
+
const noop = () => {};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Given an array of nested blocks, find the first Post Content
|
|
44
|
+
* block inside it, recursing through any nesting levels,
|
|
45
|
+
* and return its attributes.
|
|
46
|
+
*
|
|
47
|
+
* @param {Array} blocks A list of blocks.
|
|
48
|
+
*
|
|
49
|
+
* @return {Object | undefined} The Post Content block.
|
|
50
|
+
*/
|
|
51
|
+
function getPostContentAttributes( blocks ) {
|
|
52
|
+
for ( let i = 0; i < blocks.length; i++ ) {
|
|
53
|
+
if ( blocks[ i ].name === 'core/post-content' ) {
|
|
54
|
+
return blocks[ i ].attributes;
|
|
55
|
+
}
|
|
56
|
+
if ( blocks[ i ].innerBlocks.length ) {
|
|
57
|
+
const nestedPostContent = getPostContentAttributes(
|
|
58
|
+
blocks[ i ].innerBlocks
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
if ( nestedPostContent ) {
|
|
62
|
+
return nestedPostContent;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function checkForPostContentAtRootLevel( blocks ) {
|
|
69
|
+
for ( let i = 0; i < blocks.length; i++ ) {
|
|
70
|
+
if ( blocks[ i ].name === 'core/post-content' ) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function EditorCanvas( {
|
|
78
|
+
// Ideally as we unify post and site editors, we won't need these props.
|
|
79
|
+
autoFocus,
|
|
80
|
+
className,
|
|
81
|
+
renderAppender,
|
|
82
|
+
styles,
|
|
83
|
+
disableIframe = false,
|
|
84
|
+
iframeProps,
|
|
85
|
+
children,
|
|
86
|
+
} ) {
|
|
87
|
+
const {
|
|
88
|
+
renderingMode,
|
|
89
|
+
postContentAttributes,
|
|
90
|
+
editedPostTemplate = {},
|
|
91
|
+
wrapperBlockName,
|
|
92
|
+
wrapperUniqueId,
|
|
93
|
+
deviceType,
|
|
94
|
+
hasHistory,
|
|
95
|
+
} = useSelect( ( select ) => {
|
|
96
|
+
const {
|
|
97
|
+
getCurrentPostId,
|
|
98
|
+
getCurrentPostType,
|
|
99
|
+
getCurrentTemplateId,
|
|
100
|
+
getEditorSettings,
|
|
101
|
+
getRenderingMode,
|
|
102
|
+
getDeviceType,
|
|
103
|
+
} = select( editorStore );
|
|
104
|
+
const { getPostType, canUser, getEditedEntityRecord } =
|
|
105
|
+
select( coreStore );
|
|
106
|
+
const postTypeSlug = getCurrentPostType();
|
|
107
|
+
const _renderingMode = getRenderingMode();
|
|
108
|
+
let _wrapperBlockName;
|
|
109
|
+
|
|
110
|
+
if ( postTypeSlug === 'wp_block' ) {
|
|
111
|
+
_wrapperBlockName = 'core/block';
|
|
112
|
+
} else if ( ! _renderingMode === 'post-only' ) {
|
|
113
|
+
_wrapperBlockName = 'core/post-content';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const editorSettings = getEditorSettings();
|
|
117
|
+
const supportsTemplateMode = editorSettings.supportsTemplateMode;
|
|
118
|
+
const postType = getPostType( postTypeSlug );
|
|
119
|
+
const canEditTemplate = canUser( 'create', 'templates' );
|
|
120
|
+
const currentTemplateId = getCurrentTemplateId();
|
|
121
|
+
const template = currentTemplateId
|
|
122
|
+
? getEditedEntityRecord(
|
|
123
|
+
'postType',
|
|
124
|
+
'wp_template',
|
|
125
|
+
currentTemplateId
|
|
126
|
+
)
|
|
127
|
+
: undefined;
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
renderingMode: _renderingMode,
|
|
131
|
+
postContentAttributes: editorSettings.postContentAttributes,
|
|
132
|
+
// Post template fetch returns a 404 on classic themes, which
|
|
133
|
+
// messes with e2e tests, so check it's a block theme first.
|
|
134
|
+
editedPostTemplate:
|
|
135
|
+
postType?.viewable && supportsTemplateMode && canEditTemplate
|
|
136
|
+
? template
|
|
137
|
+
: undefined,
|
|
138
|
+
wrapperBlockName: _wrapperBlockName,
|
|
139
|
+
wrapperUniqueId: getCurrentPostId(),
|
|
140
|
+
deviceType: getDeviceType(),
|
|
141
|
+
hasHistory: !! editorSettings.goBack,
|
|
142
|
+
};
|
|
143
|
+
}, [] );
|
|
144
|
+
const { isCleanNewPost } = useSelect( editorStore );
|
|
145
|
+
const {
|
|
146
|
+
hasRootPaddingAwareAlignments,
|
|
147
|
+
themeHasDisabledLayoutStyles,
|
|
148
|
+
themeSupportsLayout,
|
|
149
|
+
} = useSelect( ( select ) => {
|
|
150
|
+
const _settings = select( blockEditorStore ).getSettings();
|
|
151
|
+
return {
|
|
152
|
+
themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
|
|
153
|
+
themeSupportsLayout: _settings.supportsLayout,
|
|
154
|
+
hasRootPaddingAwareAlignments:
|
|
155
|
+
_settings.__experimentalFeatures?.useRootPaddingAwareAlignments,
|
|
156
|
+
};
|
|
157
|
+
}, [] );
|
|
158
|
+
|
|
159
|
+
const deviceStyles = useResizeCanvas( deviceType );
|
|
160
|
+
const [ globalLayoutSettings ] = useSettings( 'layout' );
|
|
161
|
+
|
|
162
|
+
// fallbackLayout is used if there is no Post Content,
|
|
163
|
+
// and for Post Title.
|
|
164
|
+
const fallbackLayout = useMemo( () => {
|
|
165
|
+
if ( renderingMode !== 'post-only' ) {
|
|
166
|
+
return { type: 'default' };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if ( themeSupportsLayout ) {
|
|
170
|
+
// We need to ensure support for wide and full alignments,
|
|
171
|
+
// so we add the constrained type.
|
|
172
|
+
return { ...globalLayoutSettings, type: 'constrained' };
|
|
173
|
+
}
|
|
174
|
+
// Set default layout for classic themes so all alignments are supported.
|
|
175
|
+
return { type: 'default' };
|
|
176
|
+
}, [ renderingMode, themeSupportsLayout, globalLayoutSettings ] );
|
|
177
|
+
|
|
178
|
+
const newestPostContentAttributes = useMemo( () => {
|
|
179
|
+
if (
|
|
180
|
+
! editedPostTemplate?.content &&
|
|
181
|
+
! editedPostTemplate?.blocks &&
|
|
182
|
+
postContentAttributes
|
|
183
|
+
) {
|
|
184
|
+
return postContentAttributes;
|
|
185
|
+
}
|
|
186
|
+
// When in template editing mode, we can access the blocks directly.
|
|
187
|
+
if ( editedPostTemplate?.blocks ) {
|
|
188
|
+
return getPostContentAttributes( editedPostTemplate?.blocks );
|
|
189
|
+
}
|
|
190
|
+
// If there are no blocks, we have to parse the content string.
|
|
191
|
+
// Best double-check it's a string otherwise the parse function gets unhappy.
|
|
192
|
+
const parseableContent =
|
|
193
|
+
typeof editedPostTemplate?.content === 'string'
|
|
194
|
+
? editedPostTemplate?.content
|
|
195
|
+
: '';
|
|
196
|
+
|
|
197
|
+
return getPostContentAttributes( parse( parseableContent ) ) || {};
|
|
198
|
+
}, [
|
|
199
|
+
editedPostTemplate?.content,
|
|
200
|
+
editedPostTemplate?.blocks,
|
|
201
|
+
postContentAttributes,
|
|
202
|
+
] );
|
|
203
|
+
|
|
204
|
+
const hasPostContentAtRootLevel = useMemo( () => {
|
|
205
|
+
if ( ! editedPostTemplate?.content && ! editedPostTemplate?.blocks ) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
// When in template editing mode, we can access the blocks directly.
|
|
209
|
+
if ( editedPostTemplate?.blocks ) {
|
|
210
|
+
return checkForPostContentAtRootLevel( editedPostTemplate?.blocks );
|
|
211
|
+
}
|
|
212
|
+
// If there are no blocks, we have to parse the content string.
|
|
213
|
+
// Best double-check it's a string otherwise the parse function gets unhappy.
|
|
214
|
+
const parseableContent =
|
|
215
|
+
typeof editedPostTemplate?.content === 'string'
|
|
216
|
+
? editedPostTemplate?.content
|
|
217
|
+
: '';
|
|
218
|
+
|
|
219
|
+
return (
|
|
220
|
+
checkForPostContentAtRootLevel( parse( parseableContent ) ) || false
|
|
221
|
+
);
|
|
222
|
+
}, [ editedPostTemplate?.content, editedPostTemplate?.blocks ] );
|
|
223
|
+
|
|
224
|
+
const { layout = {}, align = '' } = newestPostContentAttributes || {};
|
|
225
|
+
|
|
226
|
+
const postContentLayoutClasses = useLayoutClasses(
|
|
227
|
+
newestPostContentAttributes,
|
|
228
|
+
'core/post-content'
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
const blockListLayoutClass = classnames(
|
|
232
|
+
{
|
|
233
|
+
'is-layout-flow': ! themeSupportsLayout,
|
|
234
|
+
},
|
|
235
|
+
themeSupportsLayout && postContentLayoutClasses,
|
|
236
|
+
align && `align${ align }`
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
const postContentLayoutStyles = useLayoutStyles(
|
|
240
|
+
newestPostContentAttributes,
|
|
241
|
+
'core/post-content',
|
|
242
|
+
'.block-editor-block-list__layout.is-root-container'
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
// Update type for blocks using legacy layouts.
|
|
246
|
+
const postContentLayout = useMemo( () => {
|
|
247
|
+
return layout &&
|
|
248
|
+
( layout?.type === 'constrained' ||
|
|
249
|
+
layout?.inherit ||
|
|
250
|
+
layout?.contentSize ||
|
|
251
|
+
layout?.wideSize )
|
|
252
|
+
? { ...globalLayoutSettings, ...layout, type: 'constrained' }
|
|
253
|
+
: { ...globalLayoutSettings, ...layout, type: 'default' };
|
|
254
|
+
}, [
|
|
255
|
+
layout?.type,
|
|
256
|
+
layout?.inherit,
|
|
257
|
+
layout?.contentSize,
|
|
258
|
+
layout?.wideSize,
|
|
259
|
+
globalLayoutSettings,
|
|
260
|
+
] );
|
|
261
|
+
|
|
262
|
+
// If there is a Post Content block we use its layout for the block list;
|
|
263
|
+
// if not, this must be a classic theme, in which case we use the fallback layout.
|
|
264
|
+
const blockListLayout = postContentAttributes
|
|
265
|
+
? postContentLayout
|
|
266
|
+
: fallbackLayout;
|
|
267
|
+
|
|
268
|
+
const postEditorLayout =
|
|
269
|
+
blockListLayout?.type === 'default' && ! hasPostContentAtRootLevel
|
|
270
|
+
? fallbackLayout
|
|
271
|
+
: blockListLayout;
|
|
272
|
+
|
|
273
|
+
const observeTypingRef = useTypingObserver();
|
|
274
|
+
const titleRef = useRef();
|
|
275
|
+
useEffect( () => {
|
|
276
|
+
if ( ! autoFocus || ! isCleanNewPost() ) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
titleRef?.current?.focus();
|
|
280
|
+
}, [ autoFocus, isCleanNewPost ] );
|
|
281
|
+
|
|
282
|
+
// Add some styles for alignwide/alignfull Post Content and its children.
|
|
283
|
+
const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}
|
|
284
|
+
.is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}
|
|
285
|
+
.is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}
|
|
286
|
+
.is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;
|
|
287
|
+
|
|
288
|
+
const localRef = useRef();
|
|
289
|
+
const typewriterRef = useTypewriter();
|
|
290
|
+
const contentRef = useMergeRefs( [
|
|
291
|
+
localRef,
|
|
292
|
+
renderingMode === 'post-only' ? typewriterRef : noop,
|
|
293
|
+
] );
|
|
294
|
+
|
|
295
|
+
return (
|
|
296
|
+
<BlockCanvas
|
|
297
|
+
shouldIframe={
|
|
298
|
+
! disableIframe || [ 'Tablet', 'Mobile' ].includes( deviceType )
|
|
299
|
+
}
|
|
300
|
+
contentRef={ contentRef }
|
|
301
|
+
styles={ styles }
|
|
302
|
+
height="100%"
|
|
303
|
+
iframeProps={ {
|
|
304
|
+
className: classnames( 'editor-canvas__iframe', {
|
|
305
|
+
'has-history': hasHistory,
|
|
306
|
+
} ),
|
|
307
|
+
...iframeProps,
|
|
308
|
+
style: {
|
|
309
|
+
...iframeProps?.style,
|
|
310
|
+
...deviceStyles,
|
|
311
|
+
},
|
|
312
|
+
} }
|
|
313
|
+
>
|
|
314
|
+
{ themeSupportsLayout &&
|
|
315
|
+
! themeHasDisabledLayoutStyles &&
|
|
316
|
+
renderingMode === 'post-only' && (
|
|
317
|
+
<>
|
|
318
|
+
<LayoutStyle
|
|
319
|
+
selector=".editor-editor-canvas__post-title-wrapper"
|
|
320
|
+
layout={ fallbackLayout }
|
|
321
|
+
/>
|
|
322
|
+
<LayoutStyle
|
|
323
|
+
selector=".block-editor-block-list__layout.is-root-container"
|
|
324
|
+
layout={ postEditorLayout }
|
|
325
|
+
/>
|
|
326
|
+
{ align && <LayoutStyle css={ alignCSS } /> }
|
|
327
|
+
{ postContentLayoutStyles && (
|
|
328
|
+
<LayoutStyle
|
|
329
|
+
layout={ postContentLayout }
|
|
330
|
+
css={ postContentLayoutStyles }
|
|
331
|
+
/>
|
|
332
|
+
) }
|
|
333
|
+
</>
|
|
334
|
+
) }
|
|
335
|
+
{ renderingMode === 'post-only' && (
|
|
336
|
+
<div
|
|
337
|
+
className={ classnames(
|
|
338
|
+
'editor-editor-canvas__post-title-wrapper',
|
|
339
|
+
// The following class is only here for backward comapatibility
|
|
340
|
+
// some themes might be using it to style the post title.
|
|
341
|
+
'edit-post-visual-editor__post-title-wrapper',
|
|
342
|
+
{
|
|
343
|
+
'has-global-padding': hasRootPaddingAwareAlignments,
|
|
344
|
+
}
|
|
345
|
+
) }
|
|
346
|
+
contentEditable={ false }
|
|
347
|
+
ref={ observeTypingRef }
|
|
348
|
+
style={ {
|
|
349
|
+
// This is using inline styles
|
|
350
|
+
// so it's applied for both iframed and non iframed editors.
|
|
351
|
+
marginTop: '4rem',
|
|
352
|
+
} }
|
|
353
|
+
>
|
|
354
|
+
<PostTitle ref={ titleRef } />
|
|
355
|
+
</div>
|
|
356
|
+
) }
|
|
357
|
+
<RecursionProvider
|
|
358
|
+
blockName={ wrapperBlockName }
|
|
359
|
+
uniqueId={ wrapperUniqueId }
|
|
360
|
+
>
|
|
361
|
+
<BlockList
|
|
362
|
+
className={ classnames(
|
|
363
|
+
className,
|
|
364
|
+
'is-' + deviceType.toLowerCase() + '-preview',
|
|
365
|
+
renderingMode !== 'post-only'
|
|
366
|
+
? 'wp-site-blocks'
|
|
367
|
+
: `${ blockListLayoutClass } wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.
|
|
368
|
+
) }
|
|
369
|
+
layout={ blockListLayout }
|
|
370
|
+
dropZoneElement={
|
|
371
|
+
// When iframed, pass in the html element of the iframe to
|
|
372
|
+
// ensure the drop zone extends to the edges of the iframe.
|
|
373
|
+
disableIframe
|
|
374
|
+
? localRef.current
|
|
375
|
+
: localRef.current?.parentNode
|
|
376
|
+
}
|
|
377
|
+
renderAppender={ renderAppender }
|
|
378
|
+
/>
|
|
379
|
+
<EditTemplateBlocksNotification contentRef={ localRef } />
|
|
380
|
+
</RecursionProvider>
|
|
381
|
+
{ children }
|
|
382
|
+
</BlockCanvas>
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export default EditorCanvas;
|
|
@@ -209,7 +209,9 @@ export function EntitiesSavedStatesExtensible( {
|
|
|
209
209
|
</Flex>
|
|
210
210
|
|
|
211
211
|
<div className="entities-saved-states__text-prompt">
|
|
212
|
-
<strong
|
|
212
|
+
<strong className="entities-saved-states__text-prompt--header">
|
|
213
|
+
{ __( 'Are you ready to save?' ) }
|
|
214
|
+
</strong>
|
|
213
215
|
{ additionalPrompt }
|
|
214
216
|
{ isDirty && (
|
|
215
217
|
<p>
|
|
@@ -10,8 +10,10 @@ import { useDispatch, useSelect } from '@wordpress/data';
|
|
|
10
10
|
import { store as editorStore } from '../../store';
|
|
11
11
|
|
|
12
12
|
export default function EditorKeyboardShortcuts() {
|
|
13
|
-
const { redo, undo, savePost } =
|
|
14
|
-
|
|
13
|
+
const { redo, undo, savePost, setIsListViewOpened } =
|
|
14
|
+
useDispatch( editorStore );
|
|
15
|
+
const { isEditedPostDirty, isPostSavingLocked, isListViewOpened } =
|
|
16
|
+
useSelect( editorStore );
|
|
15
17
|
|
|
16
18
|
useShortcut( 'core/editor/undo', ( event ) => {
|
|
17
19
|
undo();
|
|
@@ -45,5 +47,13 @@ export default function EditorKeyboardShortcuts() {
|
|
|
45
47
|
savePost();
|
|
46
48
|
} );
|
|
47
49
|
|
|
50
|
+
// Only opens the list view. Other functionality for this shortcut happens in the rendered sidebar.
|
|
51
|
+
useShortcut( 'core/editor/toggle-list-view', ( event ) => {
|
|
52
|
+
if ( ! isListViewOpened() ) {
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
setIsListViewOpened( true );
|
|
55
|
+
}
|
|
56
|
+
} );
|
|
57
|
+
|
|
48
58
|
return null;
|
|
49
59
|
}
|
|
@@ -53,6 +53,16 @@ function EditorKeyboardShortcutsRegister() {
|
|
|
53
53
|
},
|
|
54
54
|
],
|
|
55
55
|
} );
|
|
56
|
+
|
|
57
|
+
registerShortcut( {
|
|
58
|
+
name: 'core/editor/toggle-list-view',
|
|
59
|
+
category: 'global',
|
|
60
|
+
description: __( 'Open the block list view.' ),
|
|
61
|
+
keyCombination: {
|
|
62
|
+
modifier: 'access',
|
|
63
|
+
character: 'o',
|
|
64
|
+
},
|
|
65
|
+
} );
|
|
56
66
|
}, [ registerShortcut ] );
|
|
57
67
|
|
|
58
68
|
return <BlockEditorKeyboardShortcuts.Register />;
|
package/src/components/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export * from './autocompleters';
|
|
|
8
8
|
|
|
9
9
|
// Post Related Components.
|
|
10
10
|
export { default as AutosaveMonitor } from './autosave-monitor';
|
|
11
|
+
export { default as DocumentBar } from './document-bar';
|
|
11
12
|
export { default as DocumentOutline } from './document-outline';
|
|
12
13
|
export { default as DocumentOutlineCheck } from './document-outline/check';
|
|
13
14
|
export { EditorKeyboardShortcuts };
|
|
@@ -22,20 +23,26 @@ export { default as ErrorBoundary } from './error-boundary';
|
|
|
22
23
|
export { default as LocalAutosaveMonitor } from './local-autosave-monitor';
|
|
23
24
|
export { default as PageAttributesCheck } from './page-attributes/check';
|
|
24
25
|
export { default as PageAttributesOrder } from './page-attributes/order';
|
|
26
|
+
export { default as PageAttributesPanel } from './page-attributes/panel';
|
|
25
27
|
export { default as PageAttributesParent } from './page-attributes/parent';
|
|
26
|
-
export { default as PageTemplate } from './post-template';
|
|
28
|
+
export { default as PageTemplate } from './post-template/classic-theme';
|
|
29
|
+
export { default as PostTemplatePanel } from './post-template/panel';
|
|
27
30
|
export { default as PostAuthor } from './post-author';
|
|
28
31
|
export { default as PostAuthorCheck } from './post-author/check';
|
|
29
32
|
export { default as PostAuthorPanel } from './post-author/panel';
|
|
30
33
|
export { default as PostComments } from './post-comments';
|
|
34
|
+
export { default as PostDiscussionPanel } from './post-discussion/panel';
|
|
31
35
|
export { default as PostExcerpt } from './post-excerpt';
|
|
32
36
|
export { default as PostExcerptCheck } from './post-excerpt/check';
|
|
37
|
+
export { default as PostExcerptPanel } from './post-excerpt/panel';
|
|
33
38
|
export { default as PostFeaturedImage } from './post-featured-image';
|
|
34
39
|
export { default as PostFeaturedImageCheck } from './post-featured-image/check';
|
|
40
|
+
export { default as PostFeaturedImagePanel } from './post-featured-image/panel';
|
|
35
41
|
export { default as PostFormat } from './post-format';
|
|
36
42
|
export { default as PostFormatCheck } from './post-format/check';
|
|
37
43
|
export { default as PostLastRevision } from './post-last-revision';
|
|
38
44
|
export { default as PostLastRevisionCheck } from './post-last-revision/check';
|
|
45
|
+
export { default as PostLastRevisionPanel } from './post-last-revision/panel';
|
|
39
46
|
export { default as PostLockedModal } from './post-locked-modal';
|
|
40
47
|
export { default as PostPendingStatus } from './post-pending-status';
|
|
41
48
|
export { default as PostPendingStatusCheck } from './post-pending-status/check';
|
|
@@ -65,6 +72,7 @@ export { default as PostTaxonomies } from './post-taxonomies';
|
|
|
65
72
|
export { FlatTermSelector as PostTaxonomiesFlatTermSelector } from './post-taxonomies/flat-term-selector';
|
|
66
73
|
export { HierarchicalTermSelector as PostTaxonomiesHierarchicalTermSelector } from './post-taxonomies/hierarchical-term-selector';
|
|
67
74
|
export { default as PostTaxonomiesCheck } from './post-taxonomies/check';
|
|
75
|
+
export { default as PostTaxonomiesPanel } from './post-taxonomies/panel';
|
|
68
76
|
export { default as PostTextEditor } from './post-text-editor';
|
|
69
77
|
export { default as PostTitle } from './post-title';
|
|
70
78
|
export { default as PostTitleRaw } from './post-title/post-title-raw';
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
5
|
+
import { Button, VisuallyHidden } from '@wordpress/components';
|
|
6
|
+
import { __experimentalLibrary as Library } from '@wordpress/block-editor';
|
|
7
|
+
import { close } from '@wordpress/icons';
|
|
8
|
+
import {
|
|
9
|
+
useViewportMatch,
|
|
10
|
+
__experimentalUseDialog as useDialog,
|
|
11
|
+
} from '@wordpress/compose';
|
|
12
|
+
import { __ } from '@wordpress/i18n';
|
|
13
|
+
import { useEffect, useRef } from '@wordpress/element';
|
|
14
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
import { unlock } from '../../lock-unlock';
|
|
20
|
+
import { store as editorStore } from '../../store';
|
|
21
|
+
|
|
22
|
+
export default function InserterSidebar() {
|
|
23
|
+
const { insertionPoint, showMostUsedBlocks } = useSelect( ( select ) => {
|
|
24
|
+
const { getInsertionPoint } = unlock( select( editorStore ) );
|
|
25
|
+
const { get } = select( preferencesStore );
|
|
26
|
+
return {
|
|
27
|
+
insertionPoint: getInsertionPoint(),
|
|
28
|
+
showMostUsedBlocks: get( 'core', 'mostUsedBlocks' ),
|
|
29
|
+
};
|
|
30
|
+
}, [] );
|
|
31
|
+
const { setIsInserterOpened } = useDispatch( editorStore );
|
|
32
|
+
|
|
33
|
+
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
34
|
+
const TagName = ! isMobileViewport ? VisuallyHidden : 'div';
|
|
35
|
+
const [ inserterDialogRef, inserterDialogProps ] = useDialog( {
|
|
36
|
+
onClose: () => setIsInserterOpened( false ),
|
|
37
|
+
focusOnMount: null,
|
|
38
|
+
} );
|
|
39
|
+
|
|
40
|
+
const libraryRef = useRef();
|
|
41
|
+
useEffect( () => {
|
|
42
|
+
libraryRef.current.focusSearch();
|
|
43
|
+
}, [] );
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
ref={ inserterDialogRef }
|
|
48
|
+
{ ...inserterDialogProps }
|
|
49
|
+
className="editor-inserter-sidebar"
|
|
50
|
+
>
|
|
51
|
+
<TagName className="editor-inserter-sidebar__header">
|
|
52
|
+
<Button
|
|
53
|
+
icon={ close }
|
|
54
|
+
label={ __( 'Close block inserter' ) }
|
|
55
|
+
onClick={ () => setIsInserterOpened( false ) }
|
|
56
|
+
/>
|
|
57
|
+
</TagName>
|
|
58
|
+
<div className="editor-inserter-sidebar__content">
|
|
59
|
+
<Library
|
|
60
|
+
showMostUsedBlocks={ showMostUsedBlocks }
|
|
61
|
+
showInserterHelpPanel
|
|
62
|
+
shouldFocusBlock={ isMobileViewport }
|
|
63
|
+
rootClientId={ insertionPoint.rootClientId }
|
|
64
|
+
__experimentalInsertionIndex={
|
|
65
|
+
insertionPoint.insertionIndex
|
|
66
|
+
}
|
|
67
|
+
__experimentalFilterValue={ insertionPoint.filterValue }
|
|
68
|
+
ref={ libraryRef }
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|