@wordpress/editor 13.33.0 → 13.34.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 +132 -20
- package/build/components/autosave-monitor/index.js +15 -12
- package/build/components/autosave-monitor/index.js.map +1 -1
- package/build/components/character-count/index.js +5 -0
- package/build/components/character-count/index.js.map +1 -1
- package/build/components/collapsible-block-toolbar/index.js +73 -0
- package/build/components/collapsible-block-toolbar/index.js.map +1 -0
- package/build/components/document-outline/check.js +8 -0
- package/build/components/document-outline/check.js.map +1 -1
- package/build/components/document-outline/index.js +11 -0
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-tools/index.js +0 -7
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/editor-canvas/edit-template-blocks-notification.js +1 -1
- package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
- package/build/components/editor-history/redo.js +11 -0
- package/build/components/editor-history/redo.js.map +1 -1
- package/build/components/editor-history/undo.js +11 -0
- package/build/components/editor-history/undo.js.map +1 -1
- package/build/components/editor-snackbars/index.js +6 -0
- package/build/components/editor-snackbars/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/index.js +7 -0
- package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +34 -0
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +1 -4
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +4 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/list-view-sidebar/index.js +1 -1
- package/build/components/list-view-sidebar/index.js.map +1 -1
- package/build/components/more-menu/copy-content-menu-item.js +59 -0
- package/build/components/more-menu/copy-content-menu-item.js.map +1 -0
- package/build/components/more-menu/index.js +119 -0
- package/build/components/more-menu/index.js.map +1 -0
- package/build/components/more-menu/tools-more-menu-group.js +23 -0
- package/build/components/more-menu/tools-more-menu-group.js.map +1 -0
- package/build/components/more-menu/view-more-menu-group.js +24 -0
- package/build/components/more-menu/view-more-menu-group.js.map +1 -0
- package/build/components/page-attributes/check.js +8 -0
- package/build/components/page-attributes/check.js.map +1 -1
- package/build/components/page-attributes/order.js +7 -0
- package/build/components/page-attributes/order.js.map +1 -1
- package/build/components/page-attributes/panel.js +14 -8
- package/build/components/page-attributes/panel.js.map +1 -1
- package/build/components/page-attributes/parent.js +7 -0
- package/build/components/page-attributes/parent.js.map +1 -1
- package/build/components/plugin-post-publish-panel/index.js +1 -1
- package/build/components/plugin-post-publish-panel/index.js.map +1 -1
- package/build/components/plugin-pre-publish-panel/index.js +1 -1
- package/build/components/plugin-pre-publish-panel/index.js.map +1 -1
- package/build/components/plugin-sidebar/index.js +1 -1
- package/build/components/plugin-sidebar/index.js.map +1 -1
- package/build/components/post-actions/actions.js +100 -5
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-actions/index.js +30 -7
- package/build/components/post-actions/index.js.map +1 -1
- package/build/components/post-author/check.js +9 -0
- package/build/components/post-author/check.js.map +1 -1
- package/build/components/post-author/index.js +6 -0
- package/build/components/post-author/index.js.map +1 -1
- package/build/components/post-author/panel.js +5 -0
- package/build/components/post-author/panel.js.map +1 -1
- package/build/components/post-card-panel/index.js +14 -49
- package/build/components/post-card-panel/index.js.map +1 -1
- package/build/components/post-content-information/index.js +72 -0
- package/build/components/post-content-information/index.js.map +1 -0
- package/build/components/post-discussion/panel.js +9 -7
- package/build/components/post-discussion/panel.js.map +1 -1
- package/build/components/post-excerpt/check.js +0 -19
- package/build/components/post-excerpt/check.js.map +1 -1
- package/build/components/post-excerpt/index.js +52 -12
- package/build/components/post-excerpt/index.js.map +1 -1
- package/build/components/post-excerpt/panel.js +118 -7
- package/build/components/post-excerpt/panel.js.map +1 -1
- package/build/components/post-excerpt/plugin.js +2 -2
- package/build/components/post-excerpt/plugin.js.map +1 -1
- package/build/components/post-featured-image/index.js +1 -1
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-last-edited-panel/index.js +33 -0
- package/build/components/post-last-edited-panel/index.js.map +1 -0
- package/build/components/post-publish-button/post-publish-button-or-toggle.js +100 -0
- package/build/components/post-publish-button/post-publish-button-or-toggle.js.map +1 -0
- package/build/components/post-schedule/panel.js +1 -1
- package/build/components/post-schedule/panel.js.map +1 -1
- package/build/components/post-status/index.js +9 -9
- package/build/components/post-status/index.js.map +1 -1
- package/build/components/post-template/block-theme.js +2 -2
- package/build/components/post-template/block-theme.js.map +1 -1
- package/build/components/post-template/classic-theme.js +0 -1
- package/build/components/post-template/classic-theme.js.map +1 -1
- package/build/components/post-template/swap-template-button.js +2 -5
- package/build/components/post-template/swap-template-button.js.map +1 -1
- package/build/components/post-url/index.js +2 -1
- package/build/components/post-url/index.js.map +1 -1
- package/build/components/post-url/panel.js +1 -1
- package/build/components/post-url/panel.js.map +1 -1
- package/build/components/preferences-modal/enable-publish-sidebar.js +34 -0
- package/build/components/preferences-modal/enable-publish-sidebar.js.map +1 -0
- package/build/components/preferences-modal/index.js +8 -2
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preview-dropdown/index.js +3 -1
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build/components/provider/disable-non-page-content-blocks.js +23 -16
- package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/save-publish-panels/index.js +89 -0
- package/build/components/save-publish-panels/index.js.map +1 -0
- package/build/components/start-page-options/index.js +5 -1
- package/build/components/start-page-options/index.js.map +1 -1
- package/build/private-apis.js +18 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/selectors.js +3 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/autosave-monitor/index.js +15 -13
- package/build-module/components/autosave-monitor/index.js.map +1 -1
- package/build-module/components/character-count/index.js +6 -0
- package/build-module/components/character-count/index.js.map +1 -1
- package/build-module/components/collapsible-block-toolbar/index.js +65 -0
- package/build-module/components/collapsible-block-toolbar/index.js.map +1 -0
- package/build-module/components/document-outline/check.js +9 -0
- package/build-module/components/document-outline/check.js.map +1 -1
- package/build-module/components/document-outline/index.js +11 -0
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/document-tools/index.js +1 -8
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js +1 -1
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
- package/build-module/components/editor-history/redo.js +11 -0
- package/build-module/components/editor-history/redo.js.map +1 -1
- package/build-module/components/editor-history/undo.js +11 -0
- package/build-module/components/editor-history/undo.js.map +1 -1
- package/build-module/components/editor-snackbars/index.js +6 -0
- package/build-module/components/editor-snackbars/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/index.js +8 -0
- package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +35 -0
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +2 -5
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +4 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/list-view-sidebar/index.js +1 -1
- package/build-module/components/list-view-sidebar/index.js.map +1 -1
- package/build-module/components/more-menu/copy-content-menu-item.js +52 -0
- package/build-module/components/more-menu/copy-content-menu-item.js.map +1 -0
- package/build-module/components/more-menu/index.js +111 -0
- package/build-module/components/more-menu/index.js.map +1 -0
- package/build-module/components/more-menu/tools-more-menu-group.js +16 -0
- package/build-module/components/more-menu/tools-more-menu-group.js.map +1 -0
- package/build-module/components/more-menu/view-more-menu-group.js +17 -0
- package/build-module/components/more-menu/view-more-menu-group.js.map +1 -0
- package/build-module/components/page-attributes/check.js +9 -0
- package/build-module/components/page-attributes/check.js.map +1 -1
- package/build-module/components/page-attributes/order.js +7 -0
- package/build-module/components/page-attributes/order.js.map +1 -1
- package/build-module/components/page-attributes/panel.js +13 -6
- package/build-module/components/page-attributes/panel.js.map +1 -1
- package/build-module/components/page-attributes/parent.js +7 -0
- package/build-module/components/page-attributes/parent.js.map +1 -1
- package/build-module/components/plugin-post-publish-panel/index.js +1 -1
- package/build-module/components/plugin-post-publish-panel/index.js.map +1 -1
- package/build-module/components/plugin-pre-publish-panel/index.js +1 -1
- package/build-module/components/plugin-pre-publish-panel/index.js.map +1 -1
- package/build-module/components/plugin-sidebar/index.js +1 -1
- package/build-module/components/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/post-actions/actions.js +100 -6
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-actions/index.js +31 -8
- package/build-module/components/post-actions/index.js.map +1 -1
- package/build-module/components/post-author/check.js +10 -0
- package/build-module/components/post-author/check.js.map +1 -1
- package/build-module/components/post-author/index.js +6 -0
- package/build-module/components/post-author/index.js.map +1 -1
- package/build-module/components/post-author/panel.js +6 -0
- package/build-module/components/post-author/panel.js.map +1 -1
- package/build-module/components/post-card-panel/index.js +16 -51
- package/build-module/components/post-card-panel/index.js.map +1 -1
- package/build-module/components/post-content-information/index.js +66 -0
- package/build-module/components/post-content-information/index.js.map +1 -0
- package/build-module/components/post-discussion/panel.js +8 -6
- package/build-module/components/post-discussion/panel.js.map +1 -1
- package/build-module/components/post-excerpt/check.js +0 -19
- package/build-module/components/post-excerpt/check.js.map +1 -1
- package/build-module/components/post-excerpt/index.js +52 -11
- package/build-module/components/post-excerpt/index.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +118 -8
- package/build-module/components/post-excerpt/panel.js.map +1 -1
- package/build-module/components/post-excerpt/plugin.js +2 -2
- package/build-module/components/post-excerpt/plugin.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +1 -1
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-last-edited-panel/index.js +26 -0
- package/build-module/components/post-last-edited-panel/index.js.map +1 -0
- package/build-module/components/post-publish-button/post-publish-button-or-toggle.js +91 -0
- package/build-module/components/post-publish-button/post-publish-button-or-toggle.js.map +1 -0
- 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-status/index.js +9 -9
- package/build-module/components/post-status/index.js.map +1 -1
- package/build-module/components/post-template/block-theme.js +2 -2
- package/build-module/components/post-template/block-theme.js.map +1 -1
- package/build-module/components/post-template/classic-theme.js +0 -1
- package/build-module/components/post-template/classic-theme.js.map +1 -1
- package/build-module/components/post-template/swap-template-button.js +3 -6
- package/build-module/components/post-template/swap-template-button.js.map +1 -1
- package/build-module/components/post-url/index.js +2 -1
- package/build-module/components/post-url/index.js.map +1 -1
- package/build-module/components/post-url/panel.js +1 -1
- package/build-module/components/post-url/panel.js.map +1 -1
- package/build-module/components/preferences-modal/enable-publish-sidebar.js +27 -0
- package/build-module/components/preferences-modal/enable-publish-sidebar.js.map +1 -0
- package/build-module/components/preferences-modal/index.js +8 -2
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +3 -1
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/provider/disable-non-page-content-blocks.js +24 -17
- package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/save-publish-panels/index.js +80 -0
- package/build-module/components/save-publish-panels/index.js.map +1 -0
- package/build-module/components/start-page-options/index.js +5 -1
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/private-apis.js +18 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/selectors.js +3 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +207 -30
- package/build-style/style.css +207 -30
- package/package.json +35 -35
- package/src/components/autosave-monitor/index.js +15 -12
- package/src/components/character-count/index.js +5 -0
- package/src/components/collapsible-block-toolbar/index.js +77 -0
- package/src/components/collapsible-block-toolbar/style.scss +80 -0
- package/src/components/document-outline/check.js +8 -0
- package/src/components/document-outline/index.js +10 -0
- package/src/components/document-tools/index.js +0 -5
- package/src/components/editor-canvas/edit-template-blocks-notification.js +1 -1
- package/src/components/editor-history/redo.js +10 -0
- package/src/components/editor-history/undo.js +10 -0
- package/src/components/editor-snackbars/index.js +5 -0
- package/src/components/entities-saved-states/style.scss +7 -0
- package/src/components/global-keyboard-shortcuts/index.js +7 -0
- package/src/components/global-keyboard-shortcuts/register-shortcuts.js +41 -0
- package/src/components/inserter-sidebar/index.js +2 -5
- package/src/components/keyboard-shortcut-help-modal/config.js +10 -1
- package/src/components/list-view-sidebar/index.js +1 -1
- package/src/components/list-view-sidebar/style.scss +2 -2
- package/src/components/more-menu/copy-content-menu-item.js +51 -0
- package/src/components/more-menu/index.js +158 -0
- package/src/components/more-menu/tools-more-menu-group.js +11 -0
- package/src/components/more-menu/view-more-menu-group.js +13 -0
- package/src/components/page-attributes/check.js +8 -0
- package/src/components/page-attributes/order.js +6 -0
- package/src/components/page-attributes/panel.js +21 -17
- package/src/components/page-attributes/parent.js +6 -0
- package/src/components/plugin-post-publish-panel/index.js +1 -1
- package/src/components/plugin-pre-publish-panel/index.js +1 -1
- package/src/components/plugin-sidebar/index.js +1 -1
- package/src/components/post-actions/actions.js +120 -5
- package/src/components/post-actions/index.js +41 -7
- package/src/components/post-author/check.js +9 -0
- package/src/components/post-author/index.js +5 -0
- package/src/components/post-author/panel.js +5 -0
- package/src/components/post-card-panel/index.js +27 -82
- package/src/components/post-card-panel/style.scss +2 -6
- package/src/components/post-content-information/index.js +83 -0
- package/src/components/post-content-information/style.scss +6 -0
- package/src/components/post-discussion/panel.js +24 -20
- package/src/components/post-excerpt/check.js +0 -18
- package/src/components/post-excerpt/index.js +66 -15
- package/src/components/post-excerpt/panel.js +196 -19
- package/src/components/post-excerpt/plugin.js +2 -2
- package/src/components/post-excerpt/style.scss +24 -0
- package/src/components/post-featured-image/index.js +1 -1
- package/src/components/post-featured-image/style.scss +2 -8
- package/src/components/post-last-edited-panel/index.js +35 -0
- package/src/components/post-last-edited-panel/style.scss +6 -0
- package/src/components/post-panel-row/style.scss +3 -3
- package/src/components/post-publish-button/post-publish-button-or-toggle.js +102 -0
- package/src/components/post-publish-button/test/post-publish-button-or-toggle.js +63 -0
- package/src/components/post-publish-panel/style.scss +43 -0
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +225 -75
- package/src/components/post-schedule/panel.js +1 -1
- package/src/components/post-schedule/style.scss +2 -4
- package/src/components/post-status/index.js +84 -76
- package/src/components/post-status/style.scss +0 -1
- package/src/components/post-template/block-theme.js +2 -2
- package/src/components/post-template/classic-theme.js +0 -1
- package/src/components/post-template/swap-template-button.js +3 -6
- package/src/components/post-text-editor/style.scss +1 -1
- package/src/components/post-title/style.scss +1 -1
- package/src/components/post-url/index.js +1 -0
- package/src/components/post-url/panel.js +1 -1
- package/src/components/preferences-modal/enable-publish-sidebar.js +28 -0
- package/src/components/preferences-modal/index.js +14 -0
- package/src/components/preview-dropdown/index.js +3 -1
- package/src/components/provider/disable-non-page-content-blocks.js +23 -21
- package/src/components/save-publish-panels/index.js +96 -0
- package/src/components/save-publish-panels/style.scss +36 -0
- package/src/components/start-page-options/index.js +6 -1
- package/src/private-apis.js +18 -2
- package/src/store/selectors.js +3 -1
- package/src/style.scss +4 -0
|
@@ -15,7 +15,7 @@ import PostPingbacks from '../post-pingbacks';
|
|
|
15
15
|
|
|
16
16
|
const PANEL_NAME = 'discussion-panel';
|
|
17
17
|
|
|
18
|
-
function
|
|
18
|
+
function DiscussionPanel() {
|
|
19
19
|
const { isEnabled, isOpened } = useSelect( ( select ) => {
|
|
20
20
|
const { isEditorPanelEnabled, isEditorPanelOpened } =
|
|
21
21
|
select( editorStore );
|
|
@@ -31,27 +31,31 @@ function PostDiscussionPanel() {
|
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
return (
|
|
35
|
+
<PanelBody
|
|
36
|
+
title={ __( 'Discussion' ) }
|
|
37
|
+
opened={ isOpened }
|
|
38
|
+
onToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) }
|
|
39
|
+
>
|
|
40
|
+
<PostTypeSupportCheck supportKeys="comments">
|
|
41
|
+
<PanelRow>
|
|
42
|
+
<PostComments />
|
|
43
|
+
</PanelRow>
|
|
44
|
+
</PostTypeSupportCheck>
|
|
45
|
+
|
|
46
|
+
<PostTypeSupportCheck supportKeys="trackbacks">
|
|
47
|
+
<PanelRow>
|
|
48
|
+
<PostPingbacks />
|
|
49
|
+
</PanelRow>
|
|
50
|
+
</PostTypeSupportCheck>
|
|
51
|
+
</PanelBody>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default function PostDiscussionPanel() {
|
|
34
56
|
return (
|
|
35
57
|
<PostTypeSupportCheck supportKeys={ [ 'comments', 'trackbacks' ] }>
|
|
36
|
-
<
|
|
37
|
-
title={ __( 'Discussion' ) }
|
|
38
|
-
opened={ isOpened }
|
|
39
|
-
onToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) }
|
|
40
|
-
>
|
|
41
|
-
<PostTypeSupportCheck supportKeys="comments">
|
|
42
|
-
<PanelRow>
|
|
43
|
-
<PostComments />
|
|
44
|
-
</PanelRow>
|
|
45
|
-
</PostTypeSupportCheck>
|
|
46
|
-
|
|
47
|
-
<PostTypeSupportCheck supportKeys="trackbacks">
|
|
48
|
-
<PanelRow>
|
|
49
|
-
<PostPingbacks />
|
|
50
|
-
</PanelRow>
|
|
51
|
-
</PostTypeSupportCheck>
|
|
52
|
-
</PanelBody>
|
|
58
|
+
<DiscussionPanel />
|
|
53
59
|
</PostTypeSupportCheck>
|
|
54
60
|
);
|
|
55
61
|
}
|
|
56
|
-
|
|
57
|
-
export default PostDiscussionPanel;
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Internal dependencies
|
|
8
3
|
*/
|
|
9
4
|
import PostTypeSupportCheck from '../post-type-support-check';
|
|
10
|
-
import { store as editorStore } from '../../store';
|
|
11
5
|
|
|
12
6
|
/**
|
|
13
7
|
* Component for checking if the post type supports the excerpt field.
|
|
@@ -18,18 +12,6 @@ import { store as editorStore } from '../../store';
|
|
|
18
12
|
* @return {Component} The component to be rendered.
|
|
19
13
|
*/
|
|
20
14
|
function PostExcerptCheck( { children } ) {
|
|
21
|
-
const postType = useSelect( ( select ) => {
|
|
22
|
-
const { getEditedPostAttribute } = select( editorStore );
|
|
23
|
-
return getEditedPostAttribute( 'type' );
|
|
24
|
-
}, [] );
|
|
25
|
-
|
|
26
|
-
// This special case is unfortunate, but the REST API of wp_template and wp_template_part
|
|
27
|
-
// support the excerpt field throught the "description" field rather than "excerpt" which means
|
|
28
|
-
// the default ExcerptPanel won't work for these.
|
|
29
|
-
if ( [ 'wp_template', 'wp_template_part' ].includes( postType ) ) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
15
|
return (
|
|
34
16
|
<PostTypeSupportCheck supportKeys="excerpt">
|
|
35
17
|
{ children }
|
|
@@ -4,37 +4,88 @@
|
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { ExternalLink, TextareaControl } from '@wordpress/components';
|
|
6
6
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
7
|
+
import { useState } from '@wordpress/element';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Internal dependencies
|
|
10
11
|
*/
|
|
11
12
|
import { store as editorStore } from '../../store';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Renders an editable textarea for the post excerpt.
|
|
16
|
+
* Templates, template parts and patterns use the `excerpt` field as a description semantically.
|
|
17
|
+
* Additionally templates and template parts override the `excerpt` field as `description` in
|
|
18
|
+
* REST API. So this component handles proper labeling and updating the edited entity.
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} props - Component props.
|
|
21
|
+
* @param {boolean} [props.hideLabelFromVision=false] - Whether to visually hide the textarea's label.
|
|
22
|
+
* @param {boolean} [props.updateOnBlur=false] - Whether to update the post on change or use local state and update on blur.
|
|
23
|
+
*/
|
|
24
|
+
export default function PostExcerpt( {
|
|
25
|
+
hideLabelFromVision = false,
|
|
26
|
+
updateOnBlur = false,
|
|
27
|
+
} ) {
|
|
28
|
+
const { excerpt, shouldUseDescriptionLabel, usedAttribute } = useSelect(
|
|
29
|
+
( select ) => {
|
|
30
|
+
const { getCurrentPostType, getEditedPostAttribute } =
|
|
31
|
+
select( editorStore );
|
|
32
|
+
const postType = getCurrentPostType();
|
|
33
|
+
// This special case is unfortunate, but the REST API of wp_template and wp_template_part
|
|
34
|
+
// support the excerpt field throught the "description" field rather than "excerpt".
|
|
35
|
+
const _usedAttribute = [
|
|
36
|
+
'wp_template',
|
|
37
|
+
'wp_template_part',
|
|
38
|
+
].includes( postType )
|
|
39
|
+
? 'description'
|
|
40
|
+
: 'excerpt';
|
|
41
|
+
return {
|
|
42
|
+
excerpt: getEditedPostAttribute( _usedAttribute ),
|
|
43
|
+
// There are special cases where we want to label the excerpt as a description.
|
|
44
|
+
shouldUseDescriptionLabel: [
|
|
45
|
+
'wp_template',
|
|
46
|
+
'wp_template_part',
|
|
47
|
+
'wp_block',
|
|
48
|
+
].includes( postType ),
|
|
49
|
+
usedAttribute: _usedAttribute,
|
|
50
|
+
};
|
|
51
|
+
},
|
|
16
52
|
[]
|
|
17
53
|
);
|
|
18
54
|
const { editPost } = useDispatch( editorStore );
|
|
55
|
+
const [ localExcerpt, setLocalExcerpt ] = useState( excerpt );
|
|
56
|
+
const updatePost = ( value ) => {
|
|
57
|
+
editPost( { [ usedAttribute ]: value } );
|
|
58
|
+
};
|
|
59
|
+
const label = shouldUseDescriptionLabel
|
|
60
|
+
? __( 'Write a description (optional)' )
|
|
61
|
+
: __( 'Write an excerpt (optional)' );
|
|
19
62
|
|
|
20
63
|
return (
|
|
21
64
|
<div className="editor-post-excerpt">
|
|
22
65
|
<TextareaControl
|
|
23
66
|
__nextHasNoMarginBottom
|
|
24
|
-
label={
|
|
67
|
+
label={ label }
|
|
68
|
+
hideLabelFromVision={ hideLabelFromVision }
|
|
25
69
|
className="editor-post-excerpt__textarea"
|
|
26
|
-
onChange={
|
|
27
|
-
|
|
70
|
+
onChange={ updateOnBlur ? setLocalExcerpt : updatePost }
|
|
71
|
+
onBlur={
|
|
72
|
+
updateOnBlur ? () => updatePost( localExcerpt ) : undefined
|
|
73
|
+
}
|
|
74
|
+
value={ updateOnBlur ? localExcerpt : excerpt }
|
|
75
|
+
help={
|
|
76
|
+
! shouldUseDescriptionLabel ? (
|
|
77
|
+
<ExternalLink
|
|
78
|
+
href={ __(
|
|
79
|
+
'https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt'
|
|
80
|
+
) }
|
|
81
|
+
>
|
|
82
|
+
{ __( 'Learn more about manual excerpts' ) }
|
|
83
|
+
</ExternalLink>
|
|
84
|
+
) : (
|
|
85
|
+
__( 'Write a description' )
|
|
86
|
+
)
|
|
87
|
+
}
|
|
28
88
|
/>
|
|
29
|
-
<ExternalLink
|
|
30
|
-
href={ __(
|
|
31
|
-
'https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt'
|
|
32
|
-
) }
|
|
33
|
-
>
|
|
34
|
-
{ __( 'Learn more about manual excerpts' ) }
|
|
35
|
-
</ExternalLink>
|
|
36
89
|
</div>
|
|
37
90
|
);
|
|
38
91
|
}
|
|
39
|
-
|
|
40
|
-
export default PostExcerpt;
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
4
9
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
PanelBody,
|
|
12
|
+
__experimentalText as Text,
|
|
13
|
+
Dropdown,
|
|
14
|
+
Button,
|
|
15
|
+
__experimentalVStack as VStack,
|
|
16
|
+
} from '@wordpress/components';
|
|
6
17
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
18
|
+
import { useMemo, useState } from '@wordpress/element';
|
|
19
|
+
import { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';
|
|
20
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
7
21
|
|
|
8
22
|
/**
|
|
9
23
|
* Internal dependencies
|
|
@@ -11,6 +25,7 @@ import { useDispatch, useSelect } from '@wordpress/data';
|
|
|
11
25
|
import PostExcerptForm from './index';
|
|
12
26
|
import PostExcerptCheck from './check';
|
|
13
27
|
import PluginPostExcerpt from './plugin';
|
|
28
|
+
import { TEMPLATE_ORIGINS } from '../../store/constants';
|
|
14
29
|
import { store as editorStore } from '../../store';
|
|
15
30
|
|
|
16
31
|
/**
|
|
@@ -18,14 +33,18 @@ import { store as editorStore } from '../../store';
|
|
|
18
33
|
*/
|
|
19
34
|
const PANEL_NAME = 'post-excerpt';
|
|
20
35
|
|
|
21
|
-
|
|
22
|
-
const { isOpened, isEnabled } = useSelect( ( select ) => {
|
|
23
|
-
const {
|
|
24
|
-
|
|
36
|
+
function ExcerptPanel() {
|
|
37
|
+
const { isOpened, isEnabled, postType } = useSelect( ( select ) => {
|
|
38
|
+
const {
|
|
39
|
+
isEditorPanelOpened,
|
|
40
|
+
isEditorPanelEnabled,
|
|
41
|
+
getCurrentPostType,
|
|
42
|
+
} = select( editorStore );
|
|
25
43
|
|
|
26
44
|
return {
|
|
27
45
|
isOpened: isEditorPanelOpened( PANEL_NAME ),
|
|
28
46
|
isEnabled: isEditorPanelEnabled( PANEL_NAME ),
|
|
47
|
+
postType: getCurrentPostType(),
|
|
29
48
|
};
|
|
30
49
|
}, [] );
|
|
31
50
|
|
|
@@ -36,22 +55,180 @@ export default function PostExcerptPanel() {
|
|
|
36
55
|
return null;
|
|
37
56
|
}
|
|
38
57
|
|
|
58
|
+
// There are special cases where we want to label the excerpt as a description.
|
|
59
|
+
const shouldUseDescriptionLabel = [
|
|
60
|
+
'wp_template',
|
|
61
|
+
'wp_template_part',
|
|
62
|
+
'wp_block',
|
|
63
|
+
].includes( postType );
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<PanelBody
|
|
67
|
+
title={
|
|
68
|
+
shouldUseDescriptionLabel
|
|
69
|
+
? __( 'Description' )
|
|
70
|
+
: __( 'Excerpt' )
|
|
71
|
+
}
|
|
72
|
+
opened={ isOpened }
|
|
73
|
+
onToggle={ toggleExcerptPanel }
|
|
74
|
+
>
|
|
75
|
+
<PluginPostExcerpt.Slot>
|
|
76
|
+
{ ( fills ) => (
|
|
77
|
+
<>
|
|
78
|
+
<PostExcerptForm />
|
|
79
|
+
{ fills }
|
|
80
|
+
</>
|
|
81
|
+
) }
|
|
82
|
+
</PluginPostExcerpt.Slot>
|
|
83
|
+
</PanelBody>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default function PostExcerptPanel() {
|
|
39
88
|
return (
|
|
40
89
|
<PostExcerptCheck>
|
|
41
|
-
<
|
|
42
|
-
title={ __( 'Excerpt' ) }
|
|
43
|
-
opened={ isOpened }
|
|
44
|
-
onToggle={ toggleExcerptPanel }
|
|
45
|
-
>
|
|
46
|
-
<PluginPostExcerpt.Slot>
|
|
47
|
-
{ ( fills ) => (
|
|
48
|
-
<>
|
|
49
|
-
<PostExcerptForm />
|
|
50
|
-
{ fills }
|
|
51
|
-
</>
|
|
52
|
-
) }
|
|
53
|
-
</PluginPostExcerpt.Slot>
|
|
54
|
-
</PanelBody>
|
|
90
|
+
<ExcerptPanel />
|
|
55
91
|
</PostExcerptCheck>
|
|
56
92
|
);
|
|
57
93
|
}
|
|
94
|
+
|
|
95
|
+
export function PrivatePostExcerptPanel() {
|
|
96
|
+
return (
|
|
97
|
+
<PostExcerptCheck>
|
|
98
|
+
<PrivateExcerpt />
|
|
99
|
+
</PostExcerptCheck>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function PrivateExcerpt() {
|
|
104
|
+
const { shouldRender, excerpt, shouldBeUsedAsDescription, allowEditing } =
|
|
105
|
+
useSelect( ( select ) => {
|
|
106
|
+
const {
|
|
107
|
+
getCurrentPostType,
|
|
108
|
+
getCurrentPostId,
|
|
109
|
+
getEditedPostAttribute,
|
|
110
|
+
isEditorPanelEnabled,
|
|
111
|
+
} = select( editorStore );
|
|
112
|
+
const postType = getCurrentPostType();
|
|
113
|
+
const isTemplateOrTemplatePart = [
|
|
114
|
+
'wp_template',
|
|
115
|
+
'wp_template_part',
|
|
116
|
+
].includes( postType );
|
|
117
|
+
const isPattern = postType === 'wp_block';
|
|
118
|
+
// These post types use the `excerpt` field as a description semantically, so we need to
|
|
119
|
+
// handle proper labeling and some flows where we should always render them as text.
|
|
120
|
+
const _shouldBeUsedAsDescription =
|
|
121
|
+
isTemplateOrTemplatePart || isPattern;
|
|
122
|
+
const _usedAttribute = isTemplateOrTemplatePart
|
|
123
|
+
? 'description'
|
|
124
|
+
: 'excerpt';
|
|
125
|
+
// We need to fetch the entity in this case to check if we'll allow editing.
|
|
126
|
+
const template =
|
|
127
|
+
isTemplateOrTemplatePart &&
|
|
128
|
+
select( coreStore ).getEntityRecord(
|
|
129
|
+
'postType',
|
|
130
|
+
postType,
|
|
131
|
+
getCurrentPostId()
|
|
132
|
+
);
|
|
133
|
+
// For post types that use excerpt as description, we do not abide
|
|
134
|
+
// by the `isEnabled` panel flag in order to render them as text.
|
|
135
|
+
const _shouldRender =
|
|
136
|
+
isEditorPanelEnabled( PANEL_NAME ) ||
|
|
137
|
+
_shouldBeUsedAsDescription;
|
|
138
|
+
return {
|
|
139
|
+
excerpt: getEditedPostAttribute( _usedAttribute ),
|
|
140
|
+
shouldRender: _shouldRender,
|
|
141
|
+
shouldBeUsedAsDescription: _shouldBeUsedAsDescription,
|
|
142
|
+
// If we should render, allow editing for all post types that are not used as description.
|
|
143
|
+
// For the rest allow editing only for user generated entities.
|
|
144
|
+
allowEditing:
|
|
145
|
+
_shouldRender &&
|
|
146
|
+
( ! _shouldBeUsedAsDescription ||
|
|
147
|
+
isPattern ||
|
|
148
|
+
( template &&
|
|
149
|
+
template.source === TEMPLATE_ORIGINS.custom &&
|
|
150
|
+
! template.has_theme_file ) ),
|
|
151
|
+
};
|
|
152
|
+
}, [] );
|
|
153
|
+
const [ popoverAnchor, setPopoverAnchor ] = useState( null );
|
|
154
|
+
const label = shouldBeUsedAsDescription
|
|
155
|
+
? __( 'Description' )
|
|
156
|
+
: __( 'Excerpt' );
|
|
157
|
+
// Memoize popoverProps to avoid returning a new object every time.
|
|
158
|
+
const popoverProps = useMemo(
|
|
159
|
+
() => ( {
|
|
160
|
+
// Anchor the popover to the middle of the entire row so that it doesn't
|
|
161
|
+
// move around when the label changes.
|
|
162
|
+
anchor: popoverAnchor,
|
|
163
|
+
'aria-label': label,
|
|
164
|
+
headerTitle: label,
|
|
165
|
+
placement: 'left-start',
|
|
166
|
+
offset: 36,
|
|
167
|
+
shift: true,
|
|
168
|
+
} ),
|
|
169
|
+
[ popoverAnchor, label ]
|
|
170
|
+
);
|
|
171
|
+
if ( ! shouldRender ) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
const excerptText = !! excerpt && (
|
|
175
|
+
<Text align="left" numberOfLines={ 4 } truncate>
|
|
176
|
+
{ excerpt }
|
|
177
|
+
</Text>
|
|
178
|
+
);
|
|
179
|
+
if ( ! allowEditing ) {
|
|
180
|
+
return excerptText;
|
|
181
|
+
}
|
|
182
|
+
const excerptPlaceholder = shouldBeUsedAsDescription
|
|
183
|
+
? __( 'Add a description…' )
|
|
184
|
+
: __( 'Add an excerpt…' );
|
|
185
|
+
const triggerEditLabel = shouldBeUsedAsDescription
|
|
186
|
+
? __( 'Edit description' )
|
|
187
|
+
: __( 'Edit excerpt' );
|
|
188
|
+
return (
|
|
189
|
+
<Dropdown
|
|
190
|
+
className="editor-post-excerpt__dropdown"
|
|
191
|
+
contentClassName="editor-post-excerpt__dropdown__content"
|
|
192
|
+
popoverProps={ popoverProps }
|
|
193
|
+
focusOnMount
|
|
194
|
+
ref={ setPopoverAnchor }
|
|
195
|
+
renderToggle={ ( { onToggle } ) => (
|
|
196
|
+
<Button
|
|
197
|
+
className={ classnames(
|
|
198
|
+
'editor-post-excerpt__dropdown__trigger',
|
|
199
|
+
{ 'has-excerpt': !! excerpt }
|
|
200
|
+
) }
|
|
201
|
+
onClick={ onToggle }
|
|
202
|
+
label={
|
|
203
|
+
!! excerptText ? triggerEditLabel : excerptPlaceholder
|
|
204
|
+
}
|
|
205
|
+
showTooltip={ !! excerptText }
|
|
206
|
+
>
|
|
207
|
+
{ excerptText || excerptPlaceholder }
|
|
208
|
+
</Button>
|
|
209
|
+
) }
|
|
210
|
+
renderContent={ ( { onClose } ) => (
|
|
211
|
+
<>
|
|
212
|
+
<InspectorPopoverHeader
|
|
213
|
+
title={ label }
|
|
214
|
+
onClose={ onClose }
|
|
215
|
+
/>
|
|
216
|
+
|
|
217
|
+
<VStack spacing={ 4 }>
|
|
218
|
+
<PluginPostExcerpt.Slot>
|
|
219
|
+
{ ( fills ) => (
|
|
220
|
+
<>
|
|
221
|
+
<PostExcerptForm
|
|
222
|
+
hideLabelFromVision
|
|
223
|
+
updateOnBlur
|
|
224
|
+
/>
|
|
225
|
+
{ fills }
|
|
226
|
+
</>
|
|
227
|
+
) }
|
|
228
|
+
</PluginPostExcerpt.Slot>
|
|
229
|
+
</VStack>
|
|
230
|
+
</>
|
|
231
|
+
) }
|
|
232
|
+
/>
|
|
233
|
+
);
|
|
234
|
+
}
|
|
@@ -20,7 +20,7 @@ const { Fill, Slot } = createSlotFill( 'PluginPostExcerpt' );
|
|
|
20
20
|
* ```js
|
|
21
21
|
* // Using ES5 syntax
|
|
22
22
|
* var __ = wp.i18n.__;
|
|
23
|
-
* var PluginPostExcerpt = wp.editPost.
|
|
23
|
+
* var PluginPostExcerpt = wp.editPost.__experimentalPluginPostExcerpt;
|
|
24
24
|
*
|
|
25
25
|
* function MyPluginPostExcerpt() {
|
|
26
26
|
* return React.createElement(
|
|
@@ -37,7 +37,7 @@ const { Fill, Slot } = createSlotFill( 'PluginPostExcerpt' );
|
|
|
37
37
|
* ```jsx
|
|
38
38
|
* // Using ESNext syntax
|
|
39
39
|
* import { __ } from '@wordpress/i18n';
|
|
40
|
-
* import { PluginPostExcerpt } from '@wordpress/edit-post';
|
|
40
|
+
* import { __experimentalPluginPostExcerpt as PluginPostExcerpt } from '@wordpress/edit-post';
|
|
41
41
|
*
|
|
42
42
|
* const MyPluginPostExcerpt = () => (
|
|
43
43
|
* <PluginPostExcerpt className="my-plugin-post-excerpt">
|
|
@@ -2,3 +2,27 @@
|
|
|
2
2
|
width: 100%;
|
|
3
3
|
margin-bottom: 10px;
|
|
4
4
|
}
|
|
5
|
+
|
|
6
|
+
.editor-post-excerpt__dropdown__trigger {
|
|
7
|
+
height: auto;
|
|
8
|
+
padding: 0;
|
|
9
|
+
|
|
10
|
+
&:not(.has-excerpt) {
|
|
11
|
+
color: $gray-700;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&:hover {
|
|
15
|
+
color: $gray-900;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.editor-post-excerpt__dropdown {
|
|
20
|
+
display: block;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.editor-post-excerpt__dropdown__content {
|
|
24
|
+
.components-popover__content {
|
|
25
|
+
min-width: 320px;
|
|
26
|
+
padding: $grid-unit-20;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -32,7 +32,7 @@ const ALLOWED_MEDIA_TYPES = [ 'image' ];
|
|
|
32
32
|
|
|
33
33
|
// Used when labels from post type were not yet loaded or when they are not present.
|
|
34
34
|
const DEFAULT_FEATURE_IMAGE_LABEL = __( 'Featured image' );
|
|
35
|
-
const DEFAULT_SET_FEATURE_IMAGE_LABEL = __( '
|
|
35
|
+
const DEFAULT_SET_FEATURE_IMAGE_LABEL = __( 'Add a featured image' );
|
|
36
36
|
|
|
37
37
|
const instructions = (
|
|
38
38
|
<p>
|
|
@@ -31,8 +31,7 @@
|
|
|
31
31
|
box-shadow: 0 0 0 0 var(--wp-admin-theme-color);
|
|
32
32
|
overflow: hidden; // Ensure the focus style properly encapsulates the image.
|
|
33
33
|
outline-offset: -#{$border-width};
|
|
34
|
-
min-height: $grid-unit-50
|
|
35
|
-
margin-bottom: $grid-unit-20;
|
|
34
|
+
min-height: $grid-unit-50;
|
|
36
35
|
|
|
37
36
|
display: flex;
|
|
38
37
|
justify-content: center;
|
|
@@ -52,16 +51,11 @@
|
|
|
52
51
|
|
|
53
52
|
.editor-post-featured-image__toggle {
|
|
54
53
|
border-radius: $radius-block-ui;
|
|
55
|
-
background-color: $gray-100;
|
|
56
54
|
height: 100%;
|
|
57
55
|
line-height: 20px;
|
|
58
56
|
padding: $grid-unit-10 0;
|
|
59
57
|
text-align: center;
|
|
60
|
-
|
|
61
|
-
&:hover {
|
|
62
|
-
background: $gray-300;
|
|
63
|
-
color: $gray-900;
|
|
64
|
-
}
|
|
58
|
+
box-shadow: inset 0 0 0 $border-width $gray-400;
|
|
65
59
|
}
|
|
66
60
|
|
|
67
61
|
.editor-post-featured-image__actions {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __experimentalText as Text } from '@wordpress/components';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
7
|
+
import { humanTimeDiff } from '@wordpress/date';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { store as editorStore } from '../../store';
|
|
13
|
+
|
|
14
|
+
export default function PostLastEditedPanel() {
|
|
15
|
+
const modified = useSelect(
|
|
16
|
+
( select ) =>
|
|
17
|
+
select( editorStore ).getEditedPostAttribute( 'modified' ),
|
|
18
|
+
[]
|
|
19
|
+
);
|
|
20
|
+
const lastEditedText =
|
|
21
|
+
modified &&
|
|
22
|
+
sprintf(
|
|
23
|
+
// translators: %s: Human-readable time difference, e.g. "2 days ago".
|
|
24
|
+
__( 'Last edited %s.' ),
|
|
25
|
+
humanTimeDiff( modified )
|
|
26
|
+
);
|
|
27
|
+
if ( ! lastEditedText ) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return (
|
|
31
|
+
<div className="editor-post-last-edited-panel">
|
|
32
|
+
<Text>{ lastEditedText }</Text>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.editor-post-panel__row {
|
|
2
2
|
width: 100%;
|
|
3
|
-
min-height: $
|
|
3
|
+
min-height: $grid-unit-40;
|
|
4
4
|
justify-content: flex-start !important;
|
|
5
5
|
align-items: flex-start !important;
|
|
6
6
|
}
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
.editor-post-panel__row-label {
|
|
9
9
|
width: 30%;
|
|
10
10
|
flex-shrink: 0;
|
|
11
|
-
min-height: $
|
|
11
|
+
min-height: $grid-unit-40;
|
|
12
12
|
display: flex;
|
|
13
13
|
align-items: center;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
.editor-post-panel__row-control {
|
|
17
17
|
flex-grow: 1;
|
|
18
|
-
min-height: $
|
|
18
|
+
min-height: $grid-unit-40;
|
|
19
19
|
display: flex;
|
|
20
20
|
align-items: center;
|
|
21
21
|
}
|