@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,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { PanelBody } from '@wordpress/components';
|
|
6
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import PostExcerptForm from './index';
|
|
12
|
+
import PostExcerptCheck from './check';
|
|
13
|
+
import PluginPostExcerpt from './plugin';
|
|
14
|
+
import { store as editorStore } from '../../store';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Module Constants
|
|
18
|
+
*/
|
|
19
|
+
const PANEL_NAME = 'post-excerpt';
|
|
20
|
+
|
|
21
|
+
export default function PostExcerptPanel() {
|
|
22
|
+
const { isOpened, isEnabled } = useSelect( ( select ) => {
|
|
23
|
+
const { isEditorPanelOpened, isEditorPanelEnabled } =
|
|
24
|
+
select( editorStore );
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
isOpened: isEditorPanelOpened( PANEL_NAME ),
|
|
28
|
+
isEnabled: isEditorPanelEnabled( PANEL_NAME ),
|
|
29
|
+
};
|
|
30
|
+
}, [] );
|
|
31
|
+
|
|
32
|
+
const { toggleEditorPanelOpened } = useDispatch( editorStore );
|
|
33
|
+
const toggleExcerptPanel = () => toggleEditorPanelOpened( PANEL_NAME );
|
|
34
|
+
|
|
35
|
+
if ( ! isEnabled ) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<PostExcerptCheck>
|
|
41
|
+
<PanelBody
|
|
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>
|
|
55
|
+
</PostExcerptCheck>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines as extensibility slot for the Excerpt panel.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* WordPress dependencies
|
|
7
|
+
*/
|
|
8
|
+
import { createSlotFill, PanelRow } from '@wordpress/components';
|
|
9
|
+
|
|
10
|
+
const { Fill, Slot } = createSlotFill( 'PluginPostExcerpt' );
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Renders a post excerpt panel in the post sidebar.
|
|
14
|
+
*
|
|
15
|
+
* @param {Object} props Component properties.
|
|
16
|
+
* @param {string} [props.className] An optional class name added to the row.
|
|
17
|
+
* @param {Element} props.children Children to be rendered.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```js
|
|
21
|
+
* // Using ES5 syntax
|
|
22
|
+
* var __ = wp.i18n.__;
|
|
23
|
+
* var PluginPostExcerpt = wp.editPost.PluginPostExcerpt;
|
|
24
|
+
*
|
|
25
|
+
* function MyPluginPostExcerpt() {
|
|
26
|
+
* return React.createElement(
|
|
27
|
+
* PluginPostExcerpt,
|
|
28
|
+
* {
|
|
29
|
+
* className: 'my-plugin-post-excerpt',
|
|
30
|
+
* },
|
|
31
|
+
* __( 'Post excerpt custom content' )
|
|
32
|
+
* )
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```jsx
|
|
38
|
+
* // Using ESNext syntax
|
|
39
|
+
* import { __ } from '@wordpress/i18n';
|
|
40
|
+
* import { PluginPostExcerpt } from '@wordpress/edit-post';
|
|
41
|
+
*
|
|
42
|
+
* const MyPluginPostExcerpt = () => (
|
|
43
|
+
* <PluginPostExcerpt className="my-plugin-post-excerpt">
|
|
44
|
+
* { __( 'Post excerpt custom content' ) }
|
|
45
|
+
* </PluginPostExcerpt>
|
|
46
|
+
* );
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @return {Component} The component to be rendered.
|
|
50
|
+
*/
|
|
51
|
+
const PluginPostExcerpt = ( { children, className } ) => {
|
|
52
|
+
return (
|
|
53
|
+
<Fill>
|
|
54
|
+
<PanelRow className={ className }>{ children }</PanelRow>
|
|
55
|
+
</Fill>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
PluginPostExcerpt.Slot = Slot;
|
|
60
|
+
|
|
61
|
+
export default PluginPostExcerpt;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { SlotFillProvider } from '@wordpress/components';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import PluginPostExcerptPanel from '../plugin';
|
|
15
|
+
|
|
16
|
+
describe( 'PluginPostExcerptPanel', () => {
|
|
17
|
+
test( 'renders fill properly', () => {
|
|
18
|
+
render(
|
|
19
|
+
<SlotFillProvider>
|
|
20
|
+
<PluginPostExcerptPanel className="my-plugin-post-excerpt-custom-content">
|
|
21
|
+
Post Excerpt - Custom content
|
|
22
|
+
</PluginPostExcerptPanel>
|
|
23
|
+
<div role="tabpanel">
|
|
24
|
+
<PluginPostExcerptPanel.Slot />
|
|
25
|
+
</div>
|
|
26
|
+
</SlotFillProvider>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
expect( screen.getByRole( 'tabpanel' ) ).toHaveTextContent(
|
|
30
|
+
'Post Excerpt - Custom content'
|
|
31
|
+
);
|
|
32
|
+
expect(
|
|
33
|
+
screen.getByText( 'Post Excerpt - Custom content' )
|
|
34
|
+
).toHaveClass( 'my-plugin-post-excerpt-custom-content' );
|
|
35
|
+
} );
|
|
36
|
+
} );
|
|
@@ -98,17 +98,15 @@ function PostFeaturedImage( {
|
|
|
98
98
|
} ) {
|
|
99
99
|
const toggleRef = useRef();
|
|
100
100
|
const [ isLoading, setIsLoading ] = useState( false );
|
|
101
|
-
const
|
|
102
|
-
return select( blockEditorStore ).getSettings().mediaUpload;
|
|
103
|
-
}, [] );
|
|
101
|
+
const { getSettings } = useSelect( blockEditorStore );
|
|
104
102
|
const { mediaWidth, mediaHeight, mediaSourceUrl } = getMediaDetails(
|
|
105
103
|
media,
|
|
106
104
|
currentPostId
|
|
107
105
|
);
|
|
108
106
|
|
|
109
107
|
function onDropFiles( filesList ) {
|
|
110
|
-
mediaUpload( {
|
|
111
|
-
allowedTypes:
|
|
108
|
+
getSettings().mediaUpload( {
|
|
109
|
+
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
112
110
|
filesList,
|
|
113
111
|
onFileChange( [ image ] ) {
|
|
114
112
|
if ( isBlobURL( image?.url ) ) {
|
|
@@ -208,8 +206,6 @@ function PostFeaturedImage( {
|
|
|
208
206
|
<Button
|
|
209
207
|
className="editor-post-featured-image__action"
|
|
210
208
|
onClick={ open }
|
|
211
|
-
// Prefer that screen readers use the .editor-post-featured-image__preview button.
|
|
212
|
-
aria-hidden="true"
|
|
213
209
|
>
|
|
214
210
|
{ __( 'Replace' ) }
|
|
215
211
|
</Button>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { PanelBody } from '@wordpress/components';
|
|
6
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { store as editorStore } from '../../store';
|
|
13
|
+
import PostFeaturedImage from './index';
|
|
14
|
+
import PostFeaturedImageCheck from './check';
|
|
15
|
+
|
|
16
|
+
const PANEL_NAME = 'featured-image';
|
|
17
|
+
|
|
18
|
+
function FeaturedImage() {
|
|
19
|
+
const { postType, isEnabled, isOpened } = useSelect( ( select ) => {
|
|
20
|
+
const {
|
|
21
|
+
getEditedPostAttribute,
|
|
22
|
+
isEditorPanelEnabled,
|
|
23
|
+
isEditorPanelOpened,
|
|
24
|
+
} = select( editorStore );
|
|
25
|
+
const { getPostType } = select( coreStore );
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
postType: getPostType( getEditedPostAttribute( 'type' ) ),
|
|
29
|
+
isEnabled: isEditorPanelEnabled( PANEL_NAME ),
|
|
30
|
+
isOpened: isEditorPanelOpened( PANEL_NAME ),
|
|
31
|
+
};
|
|
32
|
+
}, [] );
|
|
33
|
+
|
|
34
|
+
const { toggleEditorPanelOpened } = useDispatch( editorStore );
|
|
35
|
+
|
|
36
|
+
if ( ! isEnabled ) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<PostFeaturedImageCheck>
|
|
42
|
+
<PanelBody
|
|
43
|
+
title={
|
|
44
|
+
postType?.labels?.featured_image ?? __( 'Featured image' )
|
|
45
|
+
}
|
|
46
|
+
opened={ isOpened }
|
|
47
|
+
onToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) }
|
|
48
|
+
>
|
|
49
|
+
<PostFeaturedImage />
|
|
50
|
+
</PanelBody>
|
|
51
|
+
</PostFeaturedImageCheck>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default FeaturedImage;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { PanelBody } from '@wordpress/components';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import PostLastRevision from './';
|
|
10
|
+
import PostLastRevisionCheck from './check';
|
|
11
|
+
|
|
12
|
+
function PostLastRevisionPanel() {
|
|
13
|
+
return (
|
|
14
|
+
<PostLastRevisionCheck>
|
|
15
|
+
<PanelBody className="editor-post-last-revision__panel">
|
|
16
|
+
<PostLastRevision />
|
|
17
|
+
</PanelBody>
|
|
18
|
+
</PostLastRevisionCheck>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default PostLastRevisionPanel;
|
|
@@ -21,3 +21,13 @@
|
|
|
21
21
|
border-radius: 0;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
// Needs specificity, because this panel is just a button
|
|
26
|
+
.components-panel__body.is-opened.editor-post-last-revision__panel {
|
|
27
|
+
padding: 0;
|
|
28
|
+
height: $grid-unit-60;
|
|
29
|
+
|
|
30
|
+
.editor-post-last-revision__title.components-button.components-button {
|
|
31
|
+
padding: $grid-unit-20;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
} from '@wordpress/components';
|
|
11
11
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
12
12
|
import { __ } from '@wordpress/i18n';
|
|
13
|
-
import { upload } from '@wordpress/icons';
|
|
14
13
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
15
14
|
import { useState } from '@wordpress/element';
|
|
16
15
|
import { isBlobURL } from '@wordpress/blob';
|
|
@@ -135,7 +134,7 @@ export default function PostFormatPanel() {
|
|
|
135
134
|
<PanelBody initialOpen={ true } title={ panelBodyTitle }>
|
|
136
135
|
<p>
|
|
137
136
|
{ __(
|
|
138
|
-
'
|
|
137
|
+
'Upload external images to the Media Library. Images from different domains may load slowly, display incorrectly, or be removed unexpectedly.'
|
|
139
138
|
) }
|
|
140
139
|
</p>
|
|
141
140
|
<div
|
|
@@ -153,12 +152,8 @@ export default function PostFormatPanel() {
|
|
|
153
152
|
{ isUploading ? (
|
|
154
153
|
<Spinner />
|
|
155
154
|
) : (
|
|
156
|
-
<Button
|
|
157
|
-
|
|
158
|
-
variant="primary"
|
|
159
|
-
onClick={ uploadImages }
|
|
160
|
-
>
|
|
161
|
-
{ __( 'Upload all' ) }
|
|
155
|
+
<Button variant="primary" onClick={ uploadImages }>
|
|
156
|
+
{ __( 'Upload' ) }
|
|
162
157
|
</Button>
|
|
163
158
|
) }
|
|
164
159
|
</div>
|
|
@@ -17,6 +17,7 @@ import { useEffect, useState } from '@wordpress/element';
|
|
|
17
17
|
import { __ } from '@wordpress/i18n';
|
|
18
18
|
import { Icon, check, cloud, cloudUpload } from '@wordpress/icons';
|
|
19
19
|
import { displayShortcut } from '@wordpress/keycodes';
|
|
20
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Internal dependencies
|
|
@@ -27,16 +28,12 @@ import { store as editorStore } from '../../store';
|
|
|
27
28
|
* Component showing whether the post is saved or not and providing save
|
|
28
29
|
* buttons.
|
|
29
30
|
*
|
|
30
|
-
* @param {Object} props
|
|
31
|
-
* @param {?boolean} props.forceIsDirty
|
|
32
|
-
*
|
|
33
|
-
* @param {?boolean} props.showIconLabels Whether interface buttons show labels instead of icons
|
|
31
|
+
* @param {Object} props Component props.
|
|
32
|
+
* @param {?boolean} props.forceIsDirty Whether to force the post to be marked
|
|
33
|
+
* as dirty.
|
|
34
34
|
* @return {import('react').ComponentType} The component.
|
|
35
35
|
*/
|
|
36
|
-
export default function PostSavedState( {
|
|
37
|
-
forceIsDirty,
|
|
38
|
-
showIconLabels = false,
|
|
39
|
-
} ) {
|
|
36
|
+
export default function PostSavedState( { forceIsDirty } ) {
|
|
40
37
|
const [ forceSavedMessage, setForceSavedMessage ] = useState( false );
|
|
41
38
|
const isLargeViewport = useViewportMatch( 'small' );
|
|
42
39
|
|
|
@@ -50,6 +47,7 @@ export default function PostSavedState( {
|
|
|
50
47
|
isSaving,
|
|
51
48
|
isScheduled,
|
|
52
49
|
hasPublishAction,
|
|
50
|
+
showIconLabels,
|
|
53
51
|
} = useSelect(
|
|
54
52
|
( select ) => {
|
|
55
53
|
const {
|
|
@@ -63,6 +61,7 @@ export default function PostSavedState( {
|
|
|
63
61
|
isAutosavingPost,
|
|
64
62
|
getEditedPostAttribute,
|
|
65
63
|
} = select( editorStore );
|
|
64
|
+
const { get } = select( preferencesStore );
|
|
66
65
|
|
|
67
66
|
return {
|
|
68
67
|
isAutosaving: isAutosavingPost(),
|
|
@@ -75,6 +74,7 @@ export default function PostSavedState( {
|
|
|
75
74
|
isScheduled: isCurrentPostScheduled(),
|
|
76
75
|
hasPublishAction:
|
|
77
76
|
getCurrentPost()?._links?.[ 'wp:action-publish' ] ?? false,
|
|
77
|
+
showIconLabels: get( 'core', 'showIconLabels' ),
|
|
78
78
|
};
|
|
79
79
|
},
|
|
80
80
|
[ forceIsDirty ]
|
|
@@ -168,6 +168,7 @@ export default function PostSavedState( {
|
|
|
168
168
|
}
|
|
169
169
|
onClick={ isDisabled ? undefined : () => savePost() }
|
|
170
170
|
variant="tertiary"
|
|
171
|
+
size="compact"
|
|
171
172
|
icon={ isLargeViewport ? undefined : cloudUpload }
|
|
172
173
|
// Make sure the aria-label has always a value, as the default `text` is undefined on small screens.
|
|
173
174
|
aria-label={ buttonAccessibleLabel }
|
|
@@ -4,7 +4,7 @@ exports[`PostSavedState returns a disabled button if the post is not saveable 1`
|
|
|
4
4
|
<button
|
|
5
5
|
aria-disabled="true"
|
|
6
6
|
aria-label="Save draft"
|
|
7
|
-
class="components-button is-tertiary has-icon"
|
|
7
|
+
class="components-button is-compact is-tertiary has-icon"
|
|
8
8
|
type="button"
|
|
9
9
|
>
|
|
10
10
|
<svg
|
|
@@ -26,7 +26,7 @@ exports[`PostSavedState should return Save button if edits to be saved 1`] = `
|
|
|
26
26
|
<button
|
|
27
27
|
aria-disabled="false"
|
|
28
28
|
aria-label="Save draft"
|
|
29
|
-
class="components-button editor-post-save-draft is-tertiary"
|
|
29
|
+
class="components-button editor-post-save-draft is-compact is-tertiary"
|
|
30
30
|
type="button"
|
|
31
31
|
>
|
|
32
32
|
Save draft
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { PanelBody } from '@wordpress/components';
|
|
5
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { store as editorStore } from '../../store';
|
|
11
|
+
import PostTaxonomiesForm from './index';
|
|
12
|
+
import PostTaxonomiesCheck from './check';
|
|
13
|
+
|
|
14
|
+
function TaxonomyPanel( { taxonomy, children } ) {
|
|
15
|
+
const slug = taxonomy?.slug;
|
|
16
|
+
const panelName = slug ? `taxonomy-panel-${ slug }` : '';
|
|
17
|
+
const { isEnabled, isOpened } = useSelect(
|
|
18
|
+
( select ) => {
|
|
19
|
+
const { isEditorPanelEnabled, isEditorPanelOpened } =
|
|
20
|
+
select( editorStore );
|
|
21
|
+
return {
|
|
22
|
+
isEnabled: slug ? isEditorPanelEnabled( panelName ) : false,
|
|
23
|
+
isOpened: slug ? isEditorPanelOpened( panelName ) : false,
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
[ panelName, slug ]
|
|
27
|
+
);
|
|
28
|
+
const { toggleEditorPanelOpened } = useDispatch( editorStore );
|
|
29
|
+
|
|
30
|
+
if ( ! isEnabled ) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const taxonomyMenuName = taxonomy?.labels?.menu_name;
|
|
35
|
+
if ( ! taxonomyMenuName ) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<PanelBody
|
|
41
|
+
title={ taxonomyMenuName }
|
|
42
|
+
opened={ isOpened }
|
|
43
|
+
onToggle={ () => toggleEditorPanelOpened( panelName ) }
|
|
44
|
+
>
|
|
45
|
+
{ children }
|
|
46
|
+
</PanelBody>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function PostTaxonomies() {
|
|
51
|
+
return (
|
|
52
|
+
<PostTaxonomiesCheck>
|
|
53
|
+
<PostTaxonomiesForm
|
|
54
|
+
taxonomyWrapper={ ( content, taxonomy ) => {
|
|
55
|
+
return (
|
|
56
|
+
<TaxonomyPanel taxonomy={ taxonomy }>
|
|
57
|
+
{ content }
|
|
58
|
+
</TaxonomyPanel>
|
|
59
|
+
);
|
|
60
|
+
} }
|
|
61
|
+
/>
|
|
62
|
+
</PostTaxonomiesCheck>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default PostTaxonomies;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
6
|
+
import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
import { useEntityRecord } from '@wordpress/core-data';
|
|
9
|
+
import { check } from '@wordpress/icons';
|
|
10
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import { store as editorStore } from '../../store';
|
|
16
|
+
import SwapTemplateButton from './swap-template-button';
|
|
17
|
+
import ResetDefaultTemplate from './reset-default-template';
|
|
18
|
+
import { unlock } from '../../lock-unlock';
|
|
19
|
+
import CreateNewTemplate from './create-new-template';
|
|
20
|
+
|
|
21
|
+
const POPOVER_PROPS = {
|
|
22
|
+
className: 'editor-post-template__dropdown',
|
|
23
|
+
placement: 'bottom-start',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default function BlockThemeControl( { id } ) {
|
|
27
|
+
const { isTemplateHidden } = useSelect( ( select ) => {
|
|
28
|
+
const { getRenderingMode } = unlock( select( editorStore ) );
|
|
29
|
+
return {
|
|
30
|
+
isTemplateHidden: getRenderingMode() === 'post-only',
|
|
31
|
+
};
|
|
32
|
+
}, [] );
|
|
33
|
+
const { editedRecord: template, hasResolved } = useEntityRecord(
|
|
34
|
+
'postType',
|
|
35
|
+
'wp_template',
|
|
36
|
+
id
|
|
37
|
+
);
|
|
38
|
+
const { getEditorSettings } = useSelect( editorStore );
|
|
39
|
+
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
40
|
+
const { setRenderingMode } = useDispatch( editorStore );
|
|
41
|
+
|
|
42
|
+
if ( ! hasResolved ) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<DropdownMenu
|
|
48
|
+
popoverProps={ POPOVER_PROPS }
|
|
49
|
+
focusOnMount
|
|
50
|
+
toggleProps={ {
|
|
51
|
+
variant: 'tertiary',
|
|
52
|
+
} }
|
|
53
|
+
label={ __( 'Template options' ) }
|
|
54
|
+
text={ decodeEntities( template.title ) }
|
|
55
|
+
icon={ null }
|
|
56
|
+
>
|
|
57
|
+
{ ( { onClose } ) => (
|
|
58
|
+
<>
|
|
59
|
+
<MenuGroup>
|
|
60
|
+
<MenuItem
|
|
61
|
+
onClick={ () => {
|
|
62
|
+
setRenderingMode( 'template-only' );
|
|
63
|
+
onClose();
|
|
64
|
+
createSuccessNotice(
|
|
65
|
+
__(
|
|
66
|
+
'Editing template. Changes made here affect all posts and pages that use the template.'
|
|
67
|
+
),
|
|
68
|
+
{
|
|
69
|
+
type: 'snackbar',
|
|
70
|
+
actions: [
|
|
71
|
+
{
|
|
72
|
+
label: __( 'Go back' ),
|
|
73
|
+
onClick: () =>
|
|
74
|
+
setRenderingMode(
|
|
75
|
+
getEditorSettings()
|
|
76
|
+
.defaultRenderingMode
|
|
77
|
+
),
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
} }
|
|
83
|
+
>
|
|
84
|
+
{ __( 'Edit template' ) }
|
|
85
|
+
</MenuItem>
|
|
86
|
+
<SwapTemplateButton onClick={ onClose } />
|
|
87
|
+
<ResetDefaultTemplate onClick={ onClose } />
|
|
88
|
+
<CreateNewTemplate onClick={ onClose } />
|
|
89
|
+
</MenuGroup>
|
|
90
|
+
<MenuGroup>
|
|
91
|
+
<MenuItem
|
|
92
|
+
icon={ ! isTemplateHidden ? check : undefined }
|
|
93
|
+
isSelected={ ! isTemplateHidden }
|
|
94
|
+
role="menuitemcheckbox"
|
|
95
|
+
onClick={ () => {
|
|
96
|
+
setRenderingMode(
|
|
97
|
+
isTemplateHidden
|
|
98
|
+
? 'template-locked'
|
|
99
|
+
: 'post-only'
|
|
100
|
+
);
|
|
101
|
+
} }
|
|
102
|
+
>
|
|
103
|
+
{ __( 'Template preview' ) }
|
|
104
|
+
</MenuItem>
|
|
105
|
+
</MenuGroup>
|
|
106
|
+
</>
|
|
107
|
+
) }
|
|
108
|
+
</DropdownMenu>
|
|
109
|
+
);
|
|
110
|
+
}
|