@wordpress/edit-post 7.20.1 → 7.21.1-next.f8d8eceb.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/build/components/header/header-toolbar/index.js +2 -1
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/layout/index.js +18 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/sidebar/plugin-post-excerpt/index.js +72 -0
- package/build/components/sidebar/plugin-post-excerpt/index.js.map +1 -0
- package/build/components/sidebar/post-excerpt/index.js +23 -20
- package/build/components/sidebar/post-excerpt/index.js.map +1 -1
- package/build/components/visual-editor/index.js +1 -1
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/editor.js +0 -7
- package/build/editor.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.js +2 -1
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/layout/index.js +18 -2
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/sidebar/plugin-post-excerpt/index.js +64 -0
- package/build-module/components/sidebar/plugin-post-excerpt/index.js.map +1 -0
- package/build-module/components/sidebar/post-excerpt/index.js +23 -20
- package/build-module/components/sidebar/post-excerpt/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +2 -2
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/editor.js +0 -7
- package/build-module/editor.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-style/style-rtl.css +3 -4
- package/build-style/style.css +3 -4
- package/package.json +32 -32
- package/src/components/block-manager/style.scss +2 -2
- package/src/components/header/header-toolbar/index.js +1 -0
- package/src/components/header/header-toolbar/style.scss +0 -1
- package/src/components/layout/index.js +19 -0
- package/src/components/sidebar/last-revision/style.scss +2 -1
- package/src/components/sidebar/plugin-post-excerpt/index.js +61 -0
- package/src/components/sidebar/plugin-post-excerpt/test/index.js +36 -0
- package/src/components/sidebar/post-excerpt/index.js +25 -22
- package/src/components/visual-editor/index.js +2 -2
- package/src/editor.js +0 -5
- package/src/index.js +1 -0
- package/src/lock-unlock.js +1 -1
|
@@ -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 '../';
|
|
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
|
+
} );
|
|
@@ -7,20 +7,33 @@ import {
|
|
|
7
7
|
PostExcerpt as PostExcerptForm,
|
|
8
8
|
PostExcerptCheck,
|
|
9
9
|
} from '@wordpress/editor';
|
|
10
|
-
import {
|
|
11
|
-
import { withSelect, withDispatch } from '@wordpress/data';
|
|
10
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Internal dependencies
|
|
15
14
|
*/
|
|
16
15
|
import { store as editPostStore } from '../../../store';
|
|
16
|
+
import PluginPostExcerpt from '../plugin-post-excerpt';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Module Constants
|
|
20
20
|
*/
|
|
21
21
|
const PANEL_NAME = 'post-excerpt';
|
|
22
22
|
|
|
23
|
-
function PostExcerpt(
|
|
23
|
+
export default function PostExcerpt() {
|
|
24
|
+
const { isOpened, isEnabled } = useSelect( ( select ) => {
|
|
25
|
+
const { isEditorPanelOpened, isEditorPanelEnabled } =
|
|
26
|
+
select( editPostStore );
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
isOpened: isEditorPanelOpened( PANEL_NAME ),
|
|
30
|
+
isEnabled: isEditorPanelEnabled( PANEL_NAME ),
|
|
31
|
+
};
|
|
32
|
+
}, [] );
|
|
33
|
+
|
|
34
|
+
const { toggleEditorPanelOpened } = useDispatch( editPostStore );
|
|
35
|
+
const toggleExcerptPanel = () => toggleEditorPanelOpened( PANEL_NAME );
|
|
36
|
+
|
|
24
37
|
if ( ! isEnabled ) {
|
|
25
38
|
return null;
|
|
26
39
|
}
|
|
@@ -30,27 +43,17 @@ function PostExcerpt( { isEnabled, isOpened, onTogglePanel } ) {
|
|
|
30
43
|
<PanelBody
|
|
31
44
|
title={ __( 'Excerpt' ) }
|
|
32
45
|
opened={ isOpened }
|
|
33
|
-
onToggle={
|
|
46
|
+
onToggle={ toggleExcerptPanel }
|
|
34
47
|
>
|
|
35
|
-
<
|
|
48
|
+
<PluginPostExcerpt.Slot>
|
|
49
|
+
{ ( fills ) => (
|
|
50
|
+
<>
|
|
51
|
+
<PostExcerptForm />
|
|
52
|
+
{ fills }
|
|
53
|
+
</>
|
|
54
|
+
) }
|
|
55
|
+
</PluginPostExcerpt.Slot>
|
|
36
56
|
</PanelBody>
|
|
37
57
|
</PostExcerptCheck>
|
|
38
58
|
);
|
|
39
59
|
}
|
|
40
|
-
|
|
41
|
-
export default compose( [
|
|
42
|
-
withSelect( ( select ) => {
|
|
43
|
-
return {
|
|
44
|
-
isEnabled:
|
|
45
|
-
select( editPostStore ).isEditorPanelEnabled( PANEL_NAME ),
|
|
46
|
-
isOpened: select( editPostStore ).isEditorPanelOpened( PANEL_NAME ),
|
|
47
|
-
};
|
|
48
|
-
} ),
|
|
49
|
-
withDispatch( ( dispatch ) => ( {
|
|
50
|
-
onTogglePanel() {
|
|
51
|
-
return dispatch( editPostStore ).toggleEditorPanelOpened(
|
|
52
|
-
PANEL_NAME
|
|
53
|
-
);
|
|
54
|
-
},
|
|
55
|
-
} ) ),
|
|
56
|
-
] )( PostExcerpt );
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
__unstableUseTypewriter as useTypewriter,
|
|
15
15
|
__unstableUseTypingObserver as useTypingObserver,
|
|
16
16
|
__experimentalUseResizeCanvas as useResizeCanvas,
|
|
17
|
-
|
|
17
|
+
useSettings,
|
|
18
18
|
__experimentalRecursionProvider as RecursionProvider,
|
|
19
19
|
privateApis as blockEditorPrivateApis,
|
|
20
20
|
} from '@wordpress/block-editor';
|
|
@@ -171,7 +171,7 @@ export default function VisualEditor( { styles } ) {
|
|
|
171
171
|
borderBottom: 0,
|
|
172
172
|
};
|
|
173
173
|
const resizedCanvasStyles = useResizeCanvas( deviceType, isTemplateMode );
|
|
174
|
-
const globalLayoutSettings =
|
|
174
|
+
const [ globalLayoutSettings ] = useSettings( 'layout' );
|
|
175
175
|
const previewMode = 'is-' + deviceType.toLowerCase() + '-preview';
|
|
176
176
|
|
|
177
177
|
let animatedStyles = isTemplateMode
|
package/src/editor.js
CHANGED
|
@@ -14,7 +14,6 @@ import { SlotFillProvider } from '@wordpress/components';
|
|
|
14
14
|
import { store as coreStore } from '@wordpress/core-data';
|
|
15
15
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
16
16
|
import { CommandMenu } from '@wordpress/commands';
|
|
17
|
-
import { privateApis as coreCommandsPrivateApis } from '@wordpress/core-commands';
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* Internal dependencies
|
|
@@ -23,14 +22,10 @@ import Layout from './components/layout';
|
|
|
23
22
|
import EditorInitialization from './components/editor-initialization';
|
|
24
23
|
import { store as editPostStore } from './store';
|
|
25
24
|
import { unlock } from './lock-unlock';
|
|
26
|
-
import useCommonCommands from './hooks/commands/use-common-commands';
|
|
27
25
|
|
|
28
26
|
const { ExperimentalEditorProvider } = unlock( editorPrivateApis );
|
|
29
|
-
const { useCommands } = unlock( coreCommandsPrivateApis );
|
|
30
27
|
|
|
31
28
|
function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
32
|
-
useCommands();
|
|
33
|
-
useCommonCommands();
|
|
34
29
|
const {
|
|
35
30
|
hasFixedToolbar,
|
|
36
31
|
focusMode,
|
package/src/index.js
CHANGED
|
@@ -206,4 +206,5 @@ export { default as PluginSidebar } from './components/sidebar/plugin-sidebar';
|
|
|
206
206
|
export { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';
|
|
207
207
|
export { default as __experimentalFullscreenModeClose } from './components/header/fullscreen-mode-close';
|
|
208
208
|
export { default as __experimentalMainDashboardButton } from './components/header/main-dashboard-button';
|
|
209
|
+
export { default as __experimentalPluginPostExcerpt } from './components/sidebar/plugin-post-excerpt';
|
|
209
210
|
export { store } from './store';
|
package/src/lock-unlock.js
CHANGED
|
@@ -5,6 +5,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri
|
|
|
5
5
|
|
|
6
6
|
export const { lock, unlock } =
|
|
7
7
|
__dangerousOptInToUnstableAPIsOnlyForCoreModules(
|
|
8
|
-
'I know using unstable features means my
|
|
8
|
+
'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',
|
|
9
9
|
'@wordpress/edit-post'
|
|
10
10
|
);
|