@wordpress/edit-post 5.0.27 → 6.0.1-next.f435e9e01b.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 +12 -0
- package/LICENSE.md +1 -1
- package/README.md +10 -4
- package/build/components/block-manager/category.js +42 -47
- package/build/components/block-manager/category.js.map +1 -1
- package/build/components/block-manager/index.js +18 -1
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/header/index.native.js +4 -6
- package/build/components/header/index.native.js.map +1 -1
- package/build/components/header/plugin-more-menu-item/index.js +1 -1
- package/build/components/header/plugin-more-menu-item/index.js.map +1 -1
- package/build/components/layout/index.js +17 -2
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js +3 -3
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/preferences-modal/index.js +27 -9
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +13 -3
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +7 -5
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/post-author/index.js +3 -1
- package/build/components/sidebar/post-author/index.js.map +1 -1
- package/build/components/sidebar/template/actions.js +5 -2
- package/build/components/sidebar/template/actions.js.map +1 -1
- package/build/components/sidebar/template/index.js +23 -12
- package/build/components/sidebar/template/index.js.map +1 -1
- package/build/components/visual-editor/index.js +14 -6
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/components/welcome-guide/template.js +1 -1
- package/build/components/welcome-guide/template.js.map +1 -1
- package/build/editor.js +6 -11
- package/build/editor.js.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/index.native.js +3 -9
- package/build/index.native.js.map +1 -1
- package/build-module/components/block-manager/category.js +44 -48
- package/build-module/components/block-manager/category.js.map +1 -1
- package/build-module/components/block-manager/index.js +17 -2
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/header/index.native.js +4 -4
- package/build-module/components/header/index.native.js.map +1 -1
- package/build-module/components/header/plugin-more-menu-item/index.js +1 -1
- package/build-module/components/header/plugin-more-menu-item/index.js.map +1 -1
- package/build-module/components/layout/index.js +18 -4
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js +4 -2
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +27 -9
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +14 -4
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +7 -5
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/post-author/index.js +3 -1
- package/build-module/components/sidebar/post-author/index.js.map +1 -1
- package/build-module/components/sidebar/template/actions.js +5 -2
- package/build-module/components/sidebar/template/actions.js.map +1 -1
- package/build-module/components/sidebar/template/index.js +24 -13
- package/build-module/components/sidebar/template/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +15 -7
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/components/welcome-guide/template.js +1 -1
- package/build-module/components/welcome-guide/template.js.map +1 -1
- package/build-module/editor.js +7 -10
- package/build-module/editor.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +2 -9
- package/build-module/index.native.js.map +1 -1
- package/build-style/style-rtl.css +25 -16
- package/build-style/style.css +25 -16
- package/package.json +26 -29
- package/src/components/block-manager/category.js +41 -48
- package/src/components/block-manager/index.js +18 -1
- package/src/components/header/index.native.js +10 -4
- package/src/components/header/plugin-more-menu-item/index.js +1 -1
- package/src/components/header/template-title/style.scss +1 -1
- package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +2 -2
- package/src/components/layout/index.js +18 -3
- package/src/components/layout/index.native.js +2 -5
- package/src/components/preferences-modal/index.js +23 -12
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +7 -13
- package/src/components/secondary-sidebar/inserter-sidebar.js +14 -3
- package/src/components/secondary-sidebar/list-view-sidebar.js +12 -5
- package/src/components/secondary-sidebar/style.scss +0 -4
- package/src/components/sidebar/plugin-post-publish-panel/test/__snapshots__/index.js.snap +1 -1
- package/src/components/sidebar/plugin-pre-publish-panel/test/__snapshots__/index.js.snap +1 -1
- package/src/components/sidebar/post-author/index.js +1 -1
- package/src/components/sidebar/template/actions.js +12 -7
- package/src/components/sidebar/template/index.js +55 -31
- package/src/components/sidebar/template/style.scss +8 -0
- package/src/components/visual-editor/index.js +16 -6
- package/src/components/visual-editor/style.scss +1 -0
- package/src/components/welcome-guide/style.scss +8 -1
- package/src/components/welcome-guide/template.js +1 -1
- package/src/editor.js +22 -26
- package/src/index.js +1 -1
- package/src/index.native.js +1 -10
- package/src/style.scss +1 -2
- package/src/test/editor.native.js +4 -4
- package/build/components/edit-post-settings/index.js +0 -16
- package/build/components/edit-post-settings/index.js.map +0 -1
- package/build/prevent-event-discovery.js +0 -24
- package/build/prevent-event-discovery.js.map +0 -1
- package/build-module/components/edit-post-settings/index.js +0 -7
- package/build-module/components/edit-post-settings/index.js.map +0 -1
- package/build-module/prevent-event-discovery.js +0 -17
- package/build-module/prevent-event-discovery.js.map +0 -1
- package/src/components/edit-post-settings/index.js +0 -7
- package/src/prevent-event-discovery.js +0 -21
|
@@ -55,21 +55,34 @@ import BlockManager from '../block-manager';
|
|
|
55
55
|
const MODAL_NAME = 'edit-post/preferences';
|
|
56
56
|
const PREFERENCES_MENU = 'preferences-menu';
|
|
57
57
|
|
|
58
|
-
function NavigationButton( {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
58
|
+
function NavigationButton( { as: Tag = Button, path, ...props } ) {
|
|
59
|
+
const { goTo } = useNavigator();
|
|
60
|
+
|
|
61
|
+
const dataAttrName = 'data-navigator-focusable-id';
|
|
62
|
+
const dataAttrValue = path;
|
|
63
|
+
|
|
64
|
+
const dataAttrCssSelector = `[${ dataAttrName }="${ dataAttrValue }"]`;
|
|
65
|
+
|
|
66
|
+
const tagProps = {
|
|
67
|
+
...props,
|
|
68
|
+
[ dataAttrName ]: dataAttrValue,
|
|
69
|
+
};
|
|
70
|
+
|
|
65
71
|
return (
|
|
66
72
|
<Tag
|
|
67
|
-
onClick={ () =>
|
|
68
|
-
|
|
73
|
+
onClick={ () =>
|
|
74
|
+
goTo( path, { focusTargetSelector: dataAttrCssSelector } )
|
|
75
|
+
}
|
|
76
|
+
{ ...tagProps }
|
|
69
77
|
/>
|
|
70
78
|
);
|
|
71
79
|
}
|
|
72
80
|
|
|
81
|
+
function NavigationBackButton( { as: Tag = Button, ...props } ) {
|
|
82
|
+
const { goBack } = useNavigator();
|
|
83
|
+
return <Tag onClick={ goBack } { ...props } />;
|
|
84
|
+
}
|
|
85
|
+
|
|
73
86
|
export default function PreferencesModal() {
|
|
74
87
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
75
88
|
const { closeModal } = useDispatch( editPostStore );
|
|
@@ -376,12 +389,10 @@ export default function PreferencesModal() {
|
|
|
376
389
|
size="small"
|
|
377
390
|
gap="6"
|
|
378
391
|
>
|
|
379
|
-
<
|
|
380
|
-
path="/"
|
|
392
|
+
<NavigationBackButton
|
|
381
393
|
icon={
|
|
382
394
|
isRTL() ? chevronRight : chevronLeft
|
|
383
395
|
}
|
|
384
|
-
isBack
|
|
385
396
|
aria-label={ __(
|
|
386
397
|
'Navigate to the previous view'
|
|
387
398
|
) }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`PreferencesModal should match snapshot when the modal is active large viewports 1`] = `
|
|
4
|
-
<Modal
|
|
4
|
+
<ForwardRef(Modal)
|
|
5
5
|
className="edit-post-preferences-modal"
|
|
6
6
|
closeLabel="Close"
|
|
7
7
|
onRequestClose={[Function]}
|
|
@@ -30,11 +30,11 @@ exports[`PreferencesModal should match snapshot when the modal is active large v
|
|
|
30
30
|
>
|
|
31
31
|
<Component />
|
|
32
32
|
</TabPanel>
|
|
33
|
-
</Modal>
|
|
33
|
+
</ForwardRef(Modal)>
|
|
34
34
|
`;
|
|
35
35
|
|
|
36
36
|
exports[`PreferencesModal should match snapshot when the modal is active small viewports 1`] = `
|
|
37
|
-
<Modal
|
|
37
|
+
<ForwardRef(Modal)
|
|
38
38
|
className="edit-post-preferences-modal"
|
|
39
39
|
closeLabel="Close"
|
|
40
40
|
onRequestClose={[Function]}
|
|
@@ -187,7 +187,7 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
187
187
|
justify="left"
|
|
188
188
|
size="small"
|
|
189
189
|
>
|
|
190
|
-
<
|
|
190
|
+
<NavigationBackButton
|
|
191
191
|
aria-label="Navigate to the previous view"
|
|
192
192
|
icon={
|
|
193
193
|
<SVG
|
|
@@ -199,8 +199,6 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
199
199
|
/>
|
|
200
200
|
</SVG>
|
|
201
201
|
}
|
|
202
|
-
isBack={true}
|
|
203
|
-
path="/"
|
|
204
202
|
/>
|
|
205
203
|
<Text
|
|
206
204
|
size="16"
|
|
@@ -256,7 +254,7 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
256
254
|
justify="left"
|
|
257
255
|
size="small"
|
|
258
256
|
>
|
|
259
|
-
<
|
|
257
|
+
<NavigationBackButton
|
|
260
258
|
aria-label="Navigate to the previous view"
|
|
261
259
|
icon={
|
|
262
260
|
<SVG
|
|
@@ -268,8 +266,6 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
268
266
|
/>
|
|
269
267
|
</SVG>
|
|
270
268
|
}
|
|
271
|
-
isBack={true}
|
|
272
|
-
path="/"
|
|
273
269
|
/>
|
|
274
270
|
<Text
|
|
275
271
|
size="16"
|
|
@@ -316,7 +312,7 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
316
312
|
justify="left"
|
|
317
313
|
size="small"
|
|
318
314
|
>
|
|
319
|
-
<
|
|
315
|
+
<NavigationBackButton
|
|
320
316
|
aria-label="Navigate to the previous view"
|
|
321
317
|
icon={
|
|
322
318
|
<SVG
|
|
@@ -328,8 +324,6 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
328
324
|
/>
|
|
329
325
|
</SVG>
|
|
330
326
|
}
|
|
331
|
-
isBack={true}
|
|
332
|
-
path="/"
|
|
333
327
|
/>
|
|
334
328
|
<Text
|
|
335
329
|
size="16"
|
|
@@ -386,5 +380,5 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
|
|
|
386
380
|
</Card>
|
|
387
381
|
</NavigatorScreen>
|
|
388
382
|
</NavigatorProvider>
|
|
389
|
-
</Modal>
|
|
383
|
+
</ForwardRef(Modal)>
|
|
390
384
|
`;
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
5
|
-
import { Button } from '@wordpress/components';
|
|
5
|
+
import { Button, VisuallyHidden } from '@wordpress/components';
|
|
6
6
|
import { __experimentalLibrary as Library } from '@wordpress/block-editor';
|
|
7
7
|
import { close } from '@wordpress/icons';
|
|
8
8
|
import {
|
|
9
9
|
useViewportMatch,
|
|
10
10
|
__experimentalUseDialog as useDialog,
|
|
11
11
|
} from '@wordpress/compose';
|
|
12
|
+
import { __ } from '@wordpress/i18n';
|
|
13
|
+
import { useEffect, useRef } from '@wordpress/element';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Internal dependencies
|
|
@@ -28,22 +30,30 @@ export default function InserterSidebar() {
|
|
|
28
30
|
const { setIsInserterOpened } = useDispatch( editPostStore );
|
|
29
31
|
|
|
30
32
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
33
|
+
const TagName = ! isMobileViewport ? VisuallyHidden : 'div';
|
|
31
34
|
const [ inserterDialogRef, inserterDialogProps ] = useDialog( {
|
|
32
35
|
onClose: () => setIsInserterOpened( false ),
|
|
36
|
+
focusOnMount: null,
|
|
33
37
|
} );
|
|
34
38
|
|
|
39
|
+
const libraryRef = useRef();
|
|
40
|
+
useEffect( () => {
|
|
41
|
+
libraryRef.current.focusSearch();
|
|
42
|
+
}, [] );
|
|
43
|
+
|
|
35
44
|
return (
|
|
36
45
|
<div
|
|
37
46
|
ref={ inserterDialogRef }
|
|
38
47
|
{ ...inserterDialogProps }
|
|
39
48
|
className="edit-post-editor__inserter-panel"
|
|
40
49
|
>
|
|
41
|
-
<
|
|
50
|
+
<TagName className="edit-post-editor__inserter-panel-header">
|
|
42
51
|
<Button
|
|
43
52
|
icon={ close }
|
|
53
|
+
label={ __( 'Close block inserter' ) }
|
|
44
54
|
onClick={ () => setIsInserterOpened( false ) }
|
|
45
55
|
/>
|
|
46
|
-
</
|
|
56
|
+
</TagName>
|
|
47
57
|
<div className="edit-post-editor__inserter-panel-content">
|
|
48
58
|
<Library
|
|
49
59
|
showMostUsedBlocks={ showMostUsedBlocks }
|
|
@@ -54,6 +64,7 @@ export default function InserterSidebar() {
|
|
|
54
64
|
insertionPoint.insertionIndex
|
|
55
65
|
}
|
|
56
66
|
__experimentalFilterValue={ insertionPoint.filterValue }
|
|
67
|
+
ref={ libraryRef }
|
|
57
68
|
/>
|
|
58
69
|
</div>
|
|
59
70
|
</div>
|
|
@@ -32,7 +32,8 @@ export default function ListViewSidebar() {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const focusOnMountRef = useFocusOnMount( 'firstElement' );
|
|
35
|
-
const
|
|
35
|
+
const headerFocusReturnRef = useFocusReturn();
|
|
36
|
+
const contentFocusReturnRef = useFocusReturn();
|
|
36
37
|
function closeOnEscape( event ) {
|
|
37
38
|
if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
|
|
38
39
|
event.preventDefault();
|
|
@@ -50,17 +51,23 @@ export default function ListViewSidebar() {
|
|
|
50
51
|
className="edit-post-editor__list-view-panel"
|
|
51
52
|
onKeyDown={ closeOnEscape }
|
|
52
53
|
>
|
|
53
|
-
<div
|
|
54
|
-
|
|
54
|
+
<div
|
|
55
|
+
className="edit-post-editor__list-view-panel-header"
|
|
56
|
+
ref={ headerFocusReturnRef }
|
|
57
|
+
>
|
|
58
|
+
<strong id={ labelId }>{ __( 'List View' ) }</strong>
|
|
55
59
|
<Button
|
|
56
60
|
icon={ closeSmall }
|
|
57
|
-
label={ __( 'Close
|
|
61
|
+
label={ __( 'Close List View Sidebar' ) }
|
|
58
62
|
onClick={ () => setIsListViewOpened( false ) }
|
|
59
63
|
/>
|
|
60
64
|
</div>
|
|
61
65
|
<div
|
|
62
66
|
className="edit-post-editor__list-view-panel-content"
|
|
63
|
-
ref={ useMergeRefs( [
|
|
67
|
+
ref={ useMergeRefs( [
|
|
68
|
+
contentFocusReturnRef,
|
|
69
|
+
focusOnMountRef,
|
|
70
|
+
] ) }
|
|
64
71
|
>
|
|
65
72
|
<ListView
|
|
66
73
|
onSelect={ selectEditorBlock }
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`PluginPostPublishPanel renders fill properly 1`] = `"<div class=\\"components-panel__body my-plugin-post-publish-panel is-opened\\"><h2 class=\\"components-panel__body-title\\"><button type=\\"button\\" aria-expanded=\\"true\\" class=\\"components-button components-panel__body-toggle\\"><span aria-hidden=\\"true\\"><svg width=\\"24\\" height=\\"24\\" viewBox=\\"0 0 24 24\\" xmlns=\\"http://www.w3.org/2000/svg\\" class=\\"components-panel__arrow\\"
|
|
3
|
+
exports[`PluginPostPublishPanel renders fill properly 1`] = `"<div class=\\"components-panel__body my-plugin-post-publish-panel is-opened\\"><h2 class=\\"components-panel__body-title\\"><button type=\\"button\\" aria-expanded=\\"true\\" class=\\"components-button components-panel__body-toggle\\"><span aria-hidden=\\"true\\"><svg width=\\"24\\" height=\\"24\\" viewBox=\\"0 0 24 24\\" xmlns=\\"http://www.w3.org/2000/svg\\" class=\\"components-panel__arrow\\" aria-hidden=\\"true\\" focusable=\\"false\\"><path d=\\"M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z\\"></path></svg></span>My panel title</button></h2>My panel content</div>"`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`PluginPrePublishPanel renders fill properly 1`] = `"<div class=\\"components-panel__body my-plugin-pre-publish-panel is-opened\\"><h2 class=\\"components-panel__body-title\\"><button type=\\"button\\" aria-expanded=\\"true\\" class=\\"components-button components-panel__body-toggle\\"><span aria-hidden=\\"true\\"><svg width=\\"24\\" height=\\"24\\" viewBox=\\"0 0 24 24\\" xmlns=\\"http://www.w3.org/2000/svg\\" class=\\"components-panel__arrow\\"
|
|
3
|
+
exports[`PluginPrePublishPanel renders fill properly 1`] = `"<div class=\\"components-panel__body my-plugin-pre-publish-panel is-opened\\"><h2 class=\\"components-panel__body-title\\"><button type=\\"button\\" aria-expanded=\\"true\\" class=\\"components-button components-panel__body-toggle\\"><span aria-hidden=\\"true\\"><svg width=\\"24\\" height=\\"24\\" viewBox=\\"0 0 24 24\\" xmlns=\\"http://www.w3.org/2000/svg\\" class=\\"components-panel__arrow\\" aria-hidden=\\"true\\" focusable=\\"false\\"><path d=\\"M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z\\"></path></svg></span>My panel title</button></h2>My panel content</div>"`;
|
|
4
4
|
q
|
|
@@ -25,7 +25,7 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
25
25
|
import { store as editPostStore } from '../../../store';
|
|
26
26
|
import { createBlock, serialize } from '@wordpress/blocks';
|
|
27
27
|
|
|
28
|
-
function PostTemplateActions() {
|
|
28
|
+
function PostTemplateActions( { isPostsPage } ) {
|
|
29
29
|
const [ isModalOpen, setIsModalOpen ] = useState( false );
|
|
30
30
|
const [ isBusy, setIsBusy ] = useState( false );
|
|
31
31
|
const [ title, setTitle ] = useState( '' );
|
|
@@ -128,12 +128,17 @@ function PostTemplateActions() {
|
|
|
128
128
|
{ __( 'Edit' ) }
|
|
129
129
|
</Button>
|
|
130
130
|
) }
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
{ ! isPostsPage && (
|
|
132
|
+
<Button
|
|
133
|
+
variant="link"
|
|
134
|
+
onClick={ () => setIsModalOpen( true ) }
|
|
135
|
+
>
|
|
136
|
+
{
|
|
137
|
+
/* translators: button to create a new template */
|
|
138
|
+
_x( 'New', 'action' )
|
|
139
|
+
}
|
|
140
|
+
</Button>
|
|
141
|
+
) }
|
|
137
142
|
</div>
|
|
138
143
|
{ isModalOpen && (
|
|
139
144
|
<Modal
|
|
@@ -8,7 +8,7 @@ import { partial, isEmpty, map, fromPairs } from 'lodash';
|
|
|
8
8
|
*/
|
|
9
9
|
import { __, sprintf } from '@wordpress/i18n';
|
|
10
10
|
import { useMemo } from '@wordpress/element';
|
|
11
|
-
import { PanelBody, SelectControl } from '@wordpress/components';
|
|
11
|
+
import { Notice, PanelBody, SelectControl } from '@wordpress/components';
|
|
12
12
|
import { store as editorStore } from '@wordpress/editor';
|
|
13
13
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
14
14
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -28,6 +28,7 @@ export function TemplatePanel() {
|
|
|
28
28
|
const {
|
|
29
29
|
isEnabled,
|
|
30
30
|
isOpened,
|
|
31
|
+
isPostsPage,
|
|
31
32
|
selectedTemplate,
|
|
32
33
|
availableTemplates,
|
|
33
34
|
fetchedTemplates,
|
|
@@ -44,33 +45,36 @@ export function TemplatePanel() {
|
|
|
44
45
|
const {
|
|
45
46
|
getEditedPostAttribute,
|
|
46
47
|
getEditorSettings,
|
|
48
|
+
getCurrentPostId,
|
|
47
49
|
getCurrentPostType,
|
|
48
50
|
} = select( editorStore );
|
|
49
|
-
const {
|
|
51
|
+
const {
|
|
52
|
+
getPostType,
|
|
53
|
+
getEntityRecord,
|
|
54
|
+
getEntityRecords,
|
|
55
|
+
canUser,
|
|
56
|
+
} = select( coreStore );
|
|
57
|
+
|
|
58
|
+
const currentPostId = getCurrentPostId();
|
|
50
59
|
const currentPostType = getCurrentPostType();
|
|
60
|
+
const settings = getEntityRecord( 'root', 'site' );
|
|
51
61
|
const _isViewable = getPostType( currentPostType )?.viewable ?? false;
|
|
52
62
|
const _supportsTemplateMode =
|
|
53
63
|
select( editorStore ).getEditorSettings().supportsTemplateMode &&
|
|
54
64
|
_isViewable;
|
|
55
65
|
|
|
56
|
-
const
|
|
66
|
+
const templateRecords = getEntityRecords( 'postType', 'wp_template', {
|
|
57
67
|
post_type: currentPostType,
|
|
58
68
|
per_page: -1,
|
|
59
69
|
} );
|
|
60
70
|
|
|
61
|
-
const newAvailableTemplates = fromPairs(
|
|
62
|
-
( wpTemplates || [] ).map( ( { slug, title } ) => [
|
|
63
|
-
slug,
|
|
64
|
-
title.rendered,
|
|
65
|
-
] )
|
|
66
|
-
);
|
|
67
|
-
|
|
68
71
|
return {
|
|
69
72
|
isEnabled: isEditorPanelEnabled( PANEL_NAME ),
|
|
70
73
|
isOpened: isEditorPanelOpened( PANEL_NAME ),
|
|
74
|
+
isPostsPage: currentPostId === settings?.page_for_posts,
|
|
71
75
|
selectedTemplate: getEditedPostAttribute( 'template' ),
|
|
72
76
|
availableTemplates: getEditorSettings().availableTemplates,
|
|
73
|
-
fetchedTemplates:
|
|
77
|
+
fetchedTemplates: templateRecords,
|
|
74
78
|
template: _supportsTemplateMode && getEditedPostTemplate(),
|
|
75
79
|
isViewable: _isViewable,
|
|
76
80
|
supportsTemplateMode: _supportsTemplateMode,
|
|
@@ -81,7 +85,12 @@ export function TemplatePanel() {
|
|
|
81
85
|
const templates = useMemo( () => {
|
|
82
86
|
return {
|
|
83
87
|
...availableTemplates,
|
|
84
|
-
...
|
|
88
|
+
...fromPairs(
|
|
89
|
+
( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [
|
|
90
|
+
slug,
|
|
91
|
+
title.rendered,
|
|
92
|
+
] )
|
|
93
|
+
),
|
|
85
94
|
};
|
|
86
95
|
}, [ availableTemplates, fetchedTemplates ] );
|
|
87
96
|
|
|
@@ -114,25 +123,40 @@ export function TemplatePanel() {
|
|
|
114
123
|
opened={ isOpened }
|
|
115
124
|
onToggle={ onTogglePanel }
|
|
116
125
|
>
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
126
|
+
{ isPostsPage ? (
|
|
127
|
+
<Notice
|
|
128
|
+
className="edit-post-template__notice"
|
|
129
|
+
status="warning"
|
|
130
|
+
isDismissible={ false }
|
|
131
|
+
>
|
|
132
|
+
{ __( 'The posts page template cannot be changed.' ) }
|
|
133
|
+
</Notice>
|
|
134
|
+
) : (
|
|
135
|
+
<SelectControl
|
|
136
|
+
hideLabelFromVision
|
|
137
|
+
label={ __( 'Template:' ) }
|
|
138
|
+
value={
|
|
139
|
+
Object.keys( templates ).includes( selectedTemplate )
|
|
140
|
+
? selectedTemplate
|
|
141
|
+
: ''
|
|
142
|
+
}
|
|
143
|
+
onChange={ ( templateSlug ) => {
|
|
144
|
+
editPost( {
|
|
145
|
+
template: templateSlug || '',
|
|
146
|
+
} );
|
|
147
|
+
} }
|
|
148
|
+
options={ map(
|
|
149
|
+
templates,
|
|
150
|
+
( templateName, templateSlug ) => ( {
|
|
151
|
+
value: templateSlug,
|
|
152
|
+
label: templateName,
|
|
153
|
+
} )
|
|
154
|
+
) }
|
|
155
|
+
/>
|
|
156
|
+
) }
|
|
157
|
+
{ canUserCreate && (
|
|
158
|
+
<PostTemplateActions isPostsPage={ isPostsPage } />
|
|
159
|
+
) }
|
|
136
160
|
</PanelBody>
|
|
137
161
|
);
|
|
138
162
|
}
|
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
__unstableUseTypingObserver as useTypingObserver,
|
|
23
23
|
__unstableBlockSettingsMenuFirstItem,
|
|
24
24
|
__experimentalUseResizeCanvas as useResizeCanvas,
|
|
25
|
-
__unstableUseCanvasClickRedirect as useCanvasClickRedirect,
|
|
26
25
|
__unstableEditorStyles as EditorStyles,
|
|
27
26
|
useSetting,
|
|
28
27
|
__experimentalLayoutStyle as LayoutStyle,
|
|
@@ -43,7 +42,14 @@ import { __ } from '@wordpress/i18n';
|
|
|
43
42
|
import BlockInspectorButton from './block-inspector-button';
|
|
44
43
|
import { store as editPostStore } from '../../store';
|
|
45
44
|
|
|
46
|
-
function MaybeIframe( {
|
|
45
|
+
function MaybeIframe( {
|
|
46
|
+
children,
|
|
47
|
+
contentRef,
|
|
48
|
+
shouldIframe,
|
|
49
|
+
styles,
|
|
50
|
+
assets,
|
|
51
|
+
style,
|
|
52
|
+
} ) {
|
|
47
53
|
const ref = useMouseMoveTypingReset();
|
|
48
54
|
|
|
49
55
|
if ( ! shouldIframe ) {
|
|
@@ -65,6 +71,7 @@ function MaybeIframe( { children, contentRef, shouldIframe, styles, style } ) {
|
|
|
65
71
|
return (
|
|
66
72
|
<Iframe
|
|
67
73
|
head={ <EditorStyles styles={ styles } /> }
|
|
74
|
+
assets={ assets }
|
|
68
75
|
ref={ ref }
|
|
69
76
|
contentRef={ contentRef }
|
|
70
77
|
style={ { width: '100%', height: '100%', display: 'block' } }
|
|
@@ -107,9 +114,12 @@ export default function VisualEditor( { styles } ) {
|
|
|
107
114
|
( select ) => select( editPostStore ).hasMetaBoxes(),
|
|
108
115
|
[]
|
|
109
116
|
);
|
|
110
|
-
const themeSupportsLayout = useSelect( ( select ) => {
|
|
111
|
-
const
|
|
112
|
-
return
|
|
117
|
+
const { themeSupportsLayout, assets } = useSelect( ( select ) => {
|
|
118
|
+
const _settings = select( blockEditorStore ).getSettings();
|
|
119
|
+
return {
|
|
120
|
+
themeSupportsLayout: _settings.supportsLayout,
|
|
121
|
+
assets: _settings.__unstableResolvedAssets,
|
|
122
|
+
};
|
|
113
123
|
}, [] );
|
|
114
124
|
const { clearSelectedBlock } = useDispatch( blockEditorStore );
|
|
115
125
|
const { setIsEditingTemplate } = useDispatch( editPostStore );
|
|
@@ -153,7 +163,6 @@ export default function VisualEditor( { styles } ) {
|
|
|
153
163
|
const contentRef = useMergeRefs( [
|
|
154
164
|
ref,
|
|
155
165
|
useClipboardHandler(),
|
|
156
|
-
useCanvasClickRedirect(),
|
|
157
166
|
useTypewriter(),
|
|
158
167
|
useTypingObserver(),
|
|
159
168
|
useBlockSelectionClearer(),
|
|
@@ -218,6 +227,7 @@ export default function VisualEditor( { styles } ) {
|
|
|
218
227
|
}
|
|
219
228
|
contentRef={ contentRef }
|
|
220
229
|
styles={ styles }
|
|
230
|
+
assets={ assets }
|
|
221
231
|
style={ { paddingBottom } }
|
|
222
232
|
>
|
|
223
233
|
{ themeSupportsLayout && ! isTemplateMode && (
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
.edit-post-welcome-guide
|
|
1
|
+
.edit-post-welcome-guide,
|
|
2
|
+
.edit-template-welcome-guide {
|
|
2
3
|
width: 312px;
|
|
3
4
|
|
|
4
5
|
&__image {
|
|
@@ -31,3 +32,9 @@
|
|
|
31
32
|
vertical-align: text-top;
|
|
32
33
|
}
|
|
33
34
|
}
|
|
35
|
+
|
|
36
|
+
.edit-template-welcome-guide {
|
|
37
|
+
.components-button svg {
|
|
38
|
+
fill: $white;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -16,7 +16,7 @@ export default function WelcomeGuideTemplate() {
|
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
18
|
<Guide
|
|
19
|
-
className="edit-
|
|
19
|
+
className="edit-template-welcome-guide"
|
|
20
20
|
contentLabel={ __( 'Welcome to the template editor' ) }
|
|
21
21
|
finishButtonText={ __( 'Get started' ) }
|
|
22
22
|
onFinish={ () => toggleFeature( 'welcomeGuideTemplate' ) }
|
package/src/editor.js
CHANGED
|
@@ -15,17 +15,15 @@ import {
|
|
|
15
15
|
store as editorStore,
|
|
16
16
|
} from '@wordpress/editor';
|
|
17
17
|
import { StrictMode, useMemo } from '@wordpress/element';
|
|
18
|
-
import {
|
|
18
|
+
import { SlotFillProvider } from '@wordpress/components';
|
|
19
19
|
import { store as coreStore } from '@wordpress/core-data';
|
|
20
20
|
import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Internal dependencies
|
|
24
24
|
*/
|
|
25
|
-
import preventEventDiscovery from './prevent-event-discovery';
|
|
26
25
|
import Layout from './components/layout';
|
|
27
26
|
import EditorInitialization from './components/editor-initialization';
|
|
28
|
-
import EditPostSettings from './components/edit-post-settings';
|
|
29
27
|
import { store as editPostStore } from './store';
|
|
30
28
|
|
|
31
29
|
function Editor( {
|
|
@@ -127,6 +125,9 @@ function Editor( {
|
|
|
127
125
|
// This is marked as experimental to give time for the quick inserter to mature.
|
|
128
126
|
__experimentalSetIsInserterOpened: setIsInserterOpened,
|
|
129
127
|
keepCaretInsideBlock,
|
|
128
|
+
// Keep a reference of the `allowedBlockTypes` from the server to handle use cases
|
|
129
|
+
// where we need to differentiate if a block is disabled by the user or some plugin.
|
|
130
|
+
defaultAllowedBlockTypes: settings.allowedBlockTypes,
|
|
130
131
|
};
|
|
131
132
|
|
|
132
133
|
// Omit hidden block types if exists and non-empty.
|
|
@@ -186,29 +187,24 @@ function Editor( {
|
|
|
186
187
|
return (
|
|
187
188
|
<StrictMode>
|
|
188
189
|
<ShortcutProvider>
|
|
189
|
-
<
|
|
190
|
-
<
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
>
|
|
201
|
-
<
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
</ErrorBoundary>
|
|
208
|
-
<PostLockedModal />
|
|
209
|
-
</EditorProvider>
|
|
210
|
-
</SlotFillProvider>
|
|
211
|
-
</EditPostSettings.Provider>
|
|
190
|
+
<SlotFillProvider>
|
|
191
|
+
<EditorProvider
|
|
192
|
+
settings={ editorSettings }
|
|
193
|
+
post={ post }
|
|
194
|
+
initialEdits={ initialEdits }
|
|
195
|
+
useSubRegistry={ false }
|
|
196
|
+
__unstableTemplate={
|
|
197
|
+
isTemplateMode ? template : undefined
|
|
198
|
+
}
|
|
199
|
+
{ ...props }
|
|
200
|
+
>
|
|
201
|
+
<ErrorBoundary onError={ onError }>
|
|
202
|
+
<EditorInitialization postId={ postId } />
|
|
203
|
+
<Layout styles={ styles } />
|
|
204
|
+
</ErrorBoundary>
|
|
205
|
+
<PostLockedModal />
|
|
206
|
+
</EditorProvider>
|
|
207
|
+
</SlotFillProvider>
|
|
212
208
|
</ShortcutProvider>
|
|
213
209
|
</StrictMode>
|
|
214
210
|
);
|
package/src/index.js
CHANGED
|
@@ -118,7 +118,7 @@ export function initializeEditor(
|
|
|
118
118
|
|
|
119
119
|
dispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();
|
|
120
120
|
registerCoreBlocks();
|
|
121
|
-
if ( process.env.
|
|
121
|
+
if ( process.env.IS_GUTENBERG_PLUGIN ) {
|
|
122
122
|
__experimentalRegisterExperimentalCoreBlocks( {
|
|
123
123
|
enableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks,
|
|
124
124
|
} );
|