@wordpress/edit-post 7.2.0 → 7.3.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 +1 -11
- package/build/components/block-manager/category.js +12 -8
- package/build/components/block-manager/category.js.map +1 -1
- package/build/components/header/index.js +3 -2
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/template-title/edit-template-title.js +1 -0
- package/build/components/header/template-title/edit-template-title.js.map +1 -1
- package/build/components/header/template-title/index.js +3 -1
- package/build/components/header/template-title/index.js.map +1 -1
- package/build/components/layout/index.js +3 -2
- package/build/components/layout/index.js.map +1 -1
- package/build/components/meta-boxes/index.js +1 -7
- package/build/components/meta-boxes/index.js.map +1 -1
- package/build/components/preferences-modal/meta-boxes-section.js +1 -7
- package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build/components/sidebar/post-schedule/index.js +2 -2
- package/build/components/sidebar/post-schedule/index.js.map +1 -1
- package/build/components/sidebar/post-template/create-modal.js +8 -10
- package/build/components/sidebar/post-template/create-modal.js.map +1 -1
- package/build/components/sidebar/post-template/index.js +2 -2
- package/build/components/sidebar/post-template/index.js.map +1 -1
- package/build/components/sidebar/post-url/index.js +2 -2
- package/build/components/sidebar/post-url/index.js.map +1 -1
- package/build/components/sidebar/post-visibility/index.js +2 -2
- package/build/components/sidebar/post-visibility/index.js.map +1 -1
- package/build/components/start-page-options/index.js +2 -4
- package/build/components/start-page-options/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 +14 -12
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +6 -3
- package/build/editor.native.js.map +1 -1
- package/build/experiments.js +19 -0
- package/build/experiments.js.map +1 -0
- package/build/index.js +17 -31
- package/build/index.js.map +1 -1
- package/build-module/components/block-manager/category.js +12 -7
- package/build-module/components/block-manager/category.js.map +1 -1
- package/build-module/components/header/index.js +3 -2
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/template-title/edit-template-title.js +1 -0
- package/build-module/components/header/template-title/edit-template-title.js.map +1 -1
- package/build-module/components/header/template-title/index.js +3 -1
- package/build-module/components/header/template-title/index.js.map +1 -1
- package/build-module/components/layout/index.js +3 -2
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/meta-boxes/index.js +1 -6
- package/build-module/components/meta-boxes/index.js.map +1 -1
- package/build-module/components/preferences-modal/meta-boxes-section.js +1 -6
- package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build-module/components/sidebar/post-schedule/index.js +2 -2
- package/build-module/components/sidebar/post-schedule/index.js.map +1 -1
- package/build-module/components/sidebar/post-template/create-modal.js +9 -11
- package/build-module/components/sidebar/post-template/create-modal.js.map +1 -1
- package/build-module/components/sidebar/post-template/index.js +2 -2
- package/build-module/components/sidebar/post-template/index.js.map +1 -1
- package/build-module/components/sidebar/post-url/index.js +2 -2
- package/build-module/components/sidebar/post-url/index.js.map +1 -1
- package/build-module/components/sidebar/post-visibility/index.js +2 -2
- package/build-module/components/sidebar/post-visibility/index.js.map +1 -1
- package/build-module/components/start-page-options/index.js +2 -4
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +1 -1
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/editor.js +15 -14
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +6 -2
- package/build-module/editor.native.js.map +1 -1
- package/build-module/experiments.js +9 -0
- package/build-module/experiments.js.map +1 -0
- package/build-module/index.js +16 -31
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +4 -2
- package/build-style/style.css +4 -2
- package/package.json +29 -28
- package/src/components/block-manager/category.js +4 -9
- package/src/components/header/index.js +5 -4
- package/src/components/header/template-title/edit-template-title.js +1 -0
- package/src/components/header/template-title/index.js +1 -1
- package/src/components/header/template-title/style.scss +1 -4
- package/src/components/layout/index.js +5 -4
- package/src/components/meta-boxes/index.js +1 -6
- package/src/components/preferences-modal/meta-boxes-section.js +1 -6
- package/src/components/preferences-modal/options/test/enable-custom-fields.js +3 -11
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +2 -2
- package/src/components/sidebar/post-schedule/index.js +1 -2
- package/src/components/sidebar/post-template/create-modal.js +18 -24
- package/src/components/sidebar/post-template/index.js +1 -2
- package/src/components/sidebar/post-url/index.js +1 -2
- package/src/components/sidebar/post-visibility/index.js +1 -1
- package/src/components/sidebar/settings-header/style.scss +8 -0
- package/src/components/start-page-options/index.js +2 -7
- package/src/components/visual-editor/index.js +1 -1
- package/src/editor.js +25 -38
- package/src/editor.native.js +1 -2
- package/src/experiments.js +10 -0
- package/src/index.js +17 -56
|
@@ -12,8 +12,6 @@ import {
|
|
|
12
12
|
CustomFieldsConfirmation,
|
|
13
13
|
} from '../enable-custom-fields';
|
|
14
14
|
|
|
15
|
-
jest.useFakeTimers();
|
|
16
|
-
|
|
17
15
|
describe( 'EnableCustomFieldsOption', () => {
|
|
18
16
|
it( 'renders a checked checkbox when custom fields are enabled', () => {
|
|
19
17
|
const { container } = render(
|
|
@@ -32,9 +30,7 @@ describe( 'EnableCustomFieldsOption', () => {
|
|
|
32
30
|
} );
|
|
33
31
|
|
|
34
32
|
it( 'renders an unchecked checkbox and a confirmation message when toggled off', async () => {
|
|
35
|
-
const user = userEvent.setup(
|
|
36
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
37
|
-
} );
|
|
33
|
+
const user = userEvent.setup();
|
|
38
34
|
|
|
39
35
|
const { container } = render(
|
|
40
36
|
<EnableCustomFieldsOption areCustomFieldsEnabled />
|
|
@@ -46,9 +42,7 @@ describe( 'EnableCustomFieldsOption', () => {
|
|
|
46
42
|
} );
|
|
47
43
|
|
|
48
44
|
it( 'renders a checked checkbox and a confirmation message when toggled on', async () => {
|
|
49
|
-
const user = userEvent.setup(
|
|
50
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
51
|
-
} );
|
|
45
|
+
const user = userEvent.setup();
|
|
52
46
|
|
|
53
47
|
const { container } = render(
|
|
54
48
|
<EnableCustomFieldsOption areCustomFieldsEnabled={ false } />
|
|
@@ -62,9 +56,7 @@ describe( 'EnableCustomFieldsOption', () => {
|
|
|
62
56
|
|
|
63
57
|
describe( 'CustomFieldsConfirmation', () => {
|
|
64
58
|
it( 'submits the toggle-custom-fields-form', async () => {
|
|
65
|
-
const user = userEvent.setup(
|
|
66
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
67
|
-
} );
|
|
59
|
+
const user = userEvent.setup();
|
|
68
60
|
const submit = jest.fn();
|
|
69
61
|
const getElementById = jest
|
|
70
62
|
.spyOn( document, 'getElementById' )
|
|
@@ -84,7 +84,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
|
|
|
84
84
|
</h1>
|
|
85
85
|
</div>
|
|
86
86
|
<button
|
|
87
|
-
aria-label="Close
|
|
87
|
+
aria-label="Close"
|
|
88
88
|
class="components-button has-icon"
|
|
89
89
|
type="button"
|
|
90
90
|
>
|
|
@@ -703,7 +703,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
|
|
|
703
703
|
</h1>
|
|
704
704
|
</div>
|
|
705
705
|
<button
|
|
706
|
-
aria-label="Close
|
|
706
|
+
aria-label="Close"
|
|
707
707
|
class="components-button has-icon"
|
|
708
708
|
type="button"
|
|
709
709
|
>
|
|
@@ -16,7 +16,7 @@ export default function PostSchedule() {
|
|
|
16
16
|
const [ popoverAnchor, setPopoverAnchor ] = useState( null );
|
|
17
17
|
// Memoize popoverProps to avoid returning a new object every time.
|
|
18
18
|
const popoverProps = useMemo(
|
|
19
|
-
() => ( { anchor: popoverAnchor } ),
|
|
19
|
+
() => ( { anchor: popoverAnchor, placement: 'bottom-end' } ),
|
|
20
20
|
[ popoverAnchor ]
|
|
21
21
|
);
|
|
22
22
|
|
|
@@ -29,7 +29,6 @@ export default function PostSchedule() {
|
|
|
29
29
|
<span>{ __( 'Publish' ) }</span>
|
|
30
30
|
<Dropdown
|
|
31
31
|
popoverProps={ popoverProps }
|
|
32
|
-
position="bottom left"
|
|
33
32
|
contentClassName="edit-post-post-schedule__dialog"
|
|
34
33
|
focusOnMount
|
|
35
34
|
renderToggle={ ( { isOpen, onToggle } ) => (
|
|
@@ -7,10 +7,10 @@ import { useState } from '@wordpress/element';
|
|
|
7
7
|
import { serialize, createBlock } from '@wordpress/blocks';
|
|
8
8
|
import {
|
|
9
9
|
Modal,
|
|
10
|
-
Flex,
|
|
11
|
-
FlexItem,
|
|
12
10
|
TextControl,
|
|
13
11
|
Button,
|
|
12
|
+
__experimentalHStack as HStack,
|
|
13
|
+
__experimentalVStack as VStack,
|
|
14
14
|
} from '@wordpress/components';
|
|
15
15
|
import { __ } from '@wordpress/i18n';
|
|
16
16
|
import { cleanForSlug } from '@wordpress/url';
|
|
@@ -100,7 +100,6 @@ export default function PostTemplateCreateModal( { onClose } ) {
|
|
|
100
100
|
return (
|
|
101
101
|
<Modal
|
|
102
102
|
title={ __( 'Create custom template' ) }
|
|
103
|
-
closeLabel={ __( 'Close' ) }
|
|
104
103
|
onRequestClose={ cancel }
|
|
105
104
|
className="edit-post-post-template__create-modal"
|
|
106
105
|
>
|
|
@@ -108,28 +107,23 @@ export default function PostTemplateCreateModal( { onClose } ) {
|
|
|
108
107
|
className="edit-post-post-template__create-form"
|
|
109
108
|
onSubmit={ submit }
|
|
110
109
|
>
|
|
111
|
-
<
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
</Flex>
|
|
125
|
-
|
|
126
|
-
<Flex justify="flex-end" expanded={ false }>
|
|
127
|
-
<FlexItem>
|
|
110
|
+
<VStack spacing="3">
|
|
111
|
+
<TextControl
|
|
112
|
+
__nextHasNoMarginBottom
|
|
113
|
+
label={ __( 'Name' ) }
|
|
114
|
+
value={ title }
|
|
115
|
+
onChange={ setTitle }
|
|
116
|
+
placeholder={ DEFAULT_TITLE }
|
|
117
|
+
disabled={ isBusy }
|
|
118
|
+
help={ __(
|
|
119
|
+
'Describe the template, e.g. "Post with sidebar". Custom templates can be applied to any post or page.'
|
|
120
|
+
) }
|
|
121
|
+
/>
|
|
122
|
+
<HStack justify="right">
|
|
128
123
|
<Button variant="tertiary" onClick={ cancel }>
|
|
129
124
|
{ __( 'Cancel' ) }
|
|
130
125
|
</Button>
|
|
131
|
-
|
|
132
|
-
<FlexItem>
|
|
126
|
+
|
|
133
127
|
<Button
|
|
134
128
|
variant="primary"
|
|
135
129
|
type="submit"
|
|
@@ -138,8 +132,8 @@ export default function PostTemplateCreateModal( { onClose } ) {
|
|
|
138
132
|
>
|
|
139
133
|
{ __( 'Create' ) }
|
|
140
134
|
</Button>
|
|
141
|
-
</
|
|
142
|
-
</
|
|
135
|
+
</HStack>
|
|
136
|
+
</VStack>
|
|
143
137
|
</form>
|
|
144
138
|
</Modal>
|
|
145
139
|
);
|
|
@@ -20,7 +20,7 @@ export default function PostTemplate() {
|
|
|
20
20
|
const [ popoverAnchor, setPopoverAnchor ] = useState( null );
|
|
21
21
|
// Memoize popoverProps to avoid returning a new object every time.
|
|
22
22
|
const popoverProps = useMemo(
|
|
23
|
-
() => ( { anchor: popoverAnchor } ),
|
|
23
|
+
() => ( { anchor: popoverAnchor, placement: 'bottom-end' } ),
|
|
24
24
|
[ popoverAnchor ]
|
|
25
25
|
);
|
|
26
26
|
|
|
@@ -57,7 +57,6 @@ export default function PostTemplate() {
|
|
|
57
57
|
<span>{ __( 'Template' ) }</span>
|
|
58
58
|
<Dropdown
|
|
59
59
|
popoverProps={ popoverProps }
|
|
60
|
-
position="bottom left"
|
|
61
60
|
className="edit-post-post-template__dropdown"
|
|
62
61
|
contentClassName="edit-post-post-template__dialog"
|
|
63
62
|
focusOnMount
|
|
@@ -16,7 +16,7 @@ export default function PostURL() {
|
|
|
16
16
|
const [ popoverAnchor, setPopoverAnchor ] = useState( null );
|
|
17
17
|
// Memoize popoverProps to avoid returning a new object every time.
|
|
18
18
|
const popoverProps = useMemo(
|
|
19
|
-
() => ( { anchor: popoverAnchor } ),
|
|
19
|
+
() => ( { anchor: popoverAnchor, placement: 'bottom-end' } ),
|
|
20
20
|
[ popoverAnchor ]
|
|
21
21
|
);
|
|
22
22
|
|
|
@@ -26,7 +26,6 @@ export default function PostURL() {
|
|
|
26
26
|
<span>{ __( 'URL' ) }</span>
|
|
27
27
|
<Dropdown
|
|
28
28
|
popoverProps={ popoverProps }
|
|
29
|
-
position="bottom left"
|
|
30
29
|
className="edit-post-post-url__dropdown"
|
|
31
30
|
contentClassName="edit-post-post-url__dialog"
|
|
32
31
|
focusOnMount
|
|
@@ -21,6 +21,7 @@ export function PostVisibility() {
|
|
|
21
21
|
// Anchor the popover to the middle of the entire row so that it doesn't
|
|
22
22
|
// move around when the label changes.
|
|
23
23
|
anchor: popoverAnchor,
|
|
24
|
+
placement: 'bottom-end',
|
|
24
25
|
} ),
|
|
25
26
|
[ popoverAnchor ]
|
|
26
27
|
);
|
|
@@ -40,7 +41,6 @@ export function PostVisibility() {
|
|
|
40
41
|
) }
|
|
41
42
|
{ canEdit && (
|
|
42
43
|
<Dropdown
|
|
43
|
-
position="bottom left"
|
|
44
44
|
contentClassName="edit-post-post-visibility__dialog"
|
|
45
45
|
popoverProps={ popoverProps }
|
|
46
46
|
focusOnMount
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
&:focus:not(:disabled) {
|
|
16
16
|
position: relative;
|
|
17
17
|
box-shadow: none;
|
|
18
|
+
outline: none;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
// Tab indicator
|
|
@@ -39,6 +40,10 @@
|
|
|
39
40
|
// Active.
|
|
40
41
|
&.is-active::after {
|
|
41
42
|
height: calc(1 * var(--wp-admin-border-width-focus));
|
|
43
|
+
|
|
44
|
+
// Windows high contrast mode.
|
|
45
|
+
outline: 2px solid transparent;
|
|
46
|
+
outline-offset: -1px;
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
// Focus.
|
|
@@ -62,5 +67,8 @@
|
|
|
62
67
|
|
|
63
68
|
&:focus-visible::before {
|
|
64
69
|
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
70
|
+
|
|
71
|
+
// Windows high contrast mode.
|
|
72
|
+
outline: 2px solid transparent;
|
|
65
73
|
}
|
|
66
74
|
}
|
|
@@ -23,15 +23,11 @@ function useStartPatterns() {
|
|
|
23
23
|
// the current post type is part of the postTypes declared.
|
|
24
24
|
const { blockPatternsWithPostContentBlockType, postType } = useSelect(
|
|
25
25
|
( select ) => {
|
|
26
|
-
const {
|
|
27
|
-
select( blockEditorStore );
|
|
26
|
+
const { getPatternsByBlockTypes } = select( blockEditorStore );
|
|
28
27
|
const { getCurrentPostType } = select( editorStore );
|
|
29
28
|
return {
|
|
30
|
-
// get pa
|
|
31
29
|
blockPatternsWithPostContentBlockType:
|
|
32
|
-
|
|
33
|
-
'core/post-content'
|
|
34
|
-
),
|
|
30
|
+
getPatternsByBlockTypes( 'core/post-content' ),
|
|
35
31
|
postType: getCurrentPostType(),
|
|
36
32
|
};
|
|
37
33
|
},
|
|
@@ -117,7 +113,6 @@ export default function StartPageOptions() {
|
|
|
117
113
|
<Modal
|
|
118
114
|
className="edit-post-start-page-options__modal"
|
|
119
115
|
title={ __( 'Choose a pattern' ) }
|
|
120
|
-
closeLabel={ __( 'Cancel' ) }
|
|
121
116
|
onRequestClose={ () => {
|
|
122
117
|
setModalState( START_PAGE_MODAL_STATES.CLOSED );
|
|
123
118
|
} }
|
|
@@ -82,7 +82,7 @@ function MaybeIframe( { children, contentRef, shouldIframe, styles, style } ) {
|
|
|
82
82
|
*
|
|
83
83
|
* @param {Array} blocks A list of blocks.
|
|
84
84
|
*
|
|
85
|
-
* @return {Object} The Post Content block.
|
|
85
|
+
* @return {Object | undefined} The Post Content block.
|
|
86
86
|
*/
|
|
87
87
|
function findPostContent( blocks ) {
|
|
88
88
|
for ( let i = 0; i < blocks.length; i++ ) {
|
package/src/editor.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { map } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
9
4
|
import { store as blocksStore } from '@wordpress/blocks';
|
|
10
5
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
11
6
|
import {
|
|
12
|
-
EditorProvider,
|
|
13
7
|
ErrorBoundary,
|
|
14
8
|
PostLockedModal,
|
|
15
9
|
store as editorStore,
|
|
10
|
+
experiments as editorExperiments,
|
|
16
11
|
} from '@wordpress/editor';
|
|
17
|
-
import {
|
|
12
|
+
import { useMemo } from '@wordpress/element';
|
|
18
13
|
import { SlotFillProvider } from '@wordpress/components';
|
|
19
14
|
import { store as coreStore } from '@wordpress/core-data';
|
|
20
15
|
import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
|
|
@@ -26,15 +21,11 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
26
21
|
import Layout from './components/layout';
|
|
27
22
|
import EditorInitialization from './components/editor-initialization';
|
|
28
23
|
import { store as editPostStore } from './store';
|
|
24
|
+
import { unlock } from './experiments';
|
|
25
|
+
|
|
26
|
+
const { ExperimentalEditorProvider } = unlock( editorExperiments );
|
|
29
27
|
|
|
30
|
-
function Editor( {
|
|
31
|
-
postId,
|
|
32
|
-
postType,
|
|
33
|
-
settings,
|
|
34
|
-
initialEdits,
|
|
35
|
-
onError,
|
|
36
|
-
...props
|
|
37
|
-
} ) {
|
|
28
|
+
function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
38
29
|
const {
|
|
39
30
|
hasFixedToolbar,
|
|
40
31
|
focusMode,
|
|
@@ -136,7 +127,7 @@ function Editor( {
|
|
|
136
127
|
// all block types).
|
|
137
128
|
const defaultAllowedBlockTypes =
|
|
138
129
|
true === settings.allowedBlockTypes
|
|
139
|
-
? map(
|
|
130
|
+
? blockTypes.map( ( { name } ) => name )
|
|
140
131
|
: settings.allowedBlockTypes || [];
|
|
141
132
|
|
|
142
133
|
result.allowedBlockTypes = defaultAllowedBlockTypes.filter(
|
|
@@ -182,28 +173,24 @@ function Editor( {
|
|
|
182
173
|
}
|
|
183
174
|
|
|
184
175
|
return (
|
|
185
|
-
<
|
|
186
|
-
<
|
|
187
|
-
<
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
{
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
</EditorProvider>
|
|
204
|
-
</SlotFillProvider>
|
|
205
|
-
</ShortcutProvider>
|
|
206
|
-
</StrictMode>
|
|
176
|
+
<ShortcutProvider>
|
|
177
|
+
<SlotFillProvider>
|
|
178
|
+
<ExperimentalEditorProvider
|
|
179
|
+
settings={ editorSettings }
|
|
180
|
+
post={ post }
|
|
181
|
+
initialEdits={ initialEdits }
|
|
182
|
+
useSubRegistry={ false }
|
|
183
|
+
__unstableTemplate={ isTemplateMode ? template : undefined }
|
|
184
|
+
{ ...props }
|
|
185
|
+
>
|
|
186
|
+
<ErrorBoundary>
|
|
187
|
+
<EditorInitialization postId={ postId } />
|
|
188
|
+
<Layout styles={ styles } />
|
|
189
|
+
</ErrorBoundary>
|
|
190
|
+
<PostLockedModal />
|
|
191
|
+
</ExperimentalEditorProvider>
|
|
192
|
+
</SlotFillProvider>
|
|
193
|
+
</ShortcutProvider>
|
|
207
194
|
);
|
|
208
195
|
}
|
|
209
196
|
|
package/src/editor.native.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import memize from 'memize';
|
|
5
|
-
import { map } from 'lodash';
|
|
6
5
|
import { I18nManager } from 'react-native';
|
|
7
6
|
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
8
7
|
|
|
@@ -74,7 +73,7 @@ class Editor extends Component {
|
|
|
74
73
|
// all block types).
|
|
75
74
|
const defaultAllowedBlockTypes =
|
|
76
75
|
true === settings.allowedBlockTypes
|
|
77
|
-
? map(
|
|
76
|
+
? blockTypes.map( ( { name } ) => name )
|
|
78
77
|
: settings.allowedBlockTypes || [];
|
|
79
78
|
|
|
80
79
|
settings.allowedBlockTypes = defaultAllowedBlockTypes.filter(
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/experiments';
|
|
5
|
+
|
|
6
|
+
export const { lock, unlock } =
|
|
7
|
+
__dangerousOptInToUnstableAPIsOnlyForCoreModules(
|
|
8
|
+
'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',
|
|
9
|
+
'@wordpress/edit-post'
|
|
10
|
+
);
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
registerCoreBlocks,
|
|
7
7
|
__experimentalRegisterExperimentalCoreBlocks,
|
|
8
8
|
} from '@wordpress/block-library';
|
|
9
|
-
import
|
|
9
|
+
import deprecated from '@wordpress/deprecated';
|
|
10
|
+
import { createRoot } from '@wordpress/element';
|
|
10
11
|
import { dispatch, select } from '@wordpress/data';
|
|
11
12
|
import { addFilter } from '@wordpress/hooks';
|
|
12
13
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
@@ -20,49 +21,6 @@ import './plugins';
|
|
|
20
21
|
import Editor from './editor';
|
|
21
22
|
import { store as editPostStore } from './store';
|
|
22
23
|
|
|
23
|
-
/**
|
|
24
|
-
* Reinitializes the editor after the user chooses to reboot the editor after
|
|
25
|
-
* an unhandled error occurs, replacing previously mounted editor element using
|
|
26
|
-
* an initial state from prior to the crash.
|
|
27
|
-
*
|
|
28
|
-
* @param {Object} postType Post type of the post to edit.
|
|
29
|
-
* @param {Object} postId ID of the post to edit.
|
|
30
|
-
* @param {Element} target DOM node in which editor is rendered.
|
|
31
|
-
* @param {?Object} settings Editor settings object.
|
|
32
|
-
* @param {Object} initialEdits Programmatic edits to apply initially, to be
|
|
33
|
-
* considered as non-user-initiated (bypass for
|
|
34
|
-
* unsaved changes prompt).
|
|
35
|
-
*/
|
|
36
|
-
export function reinitializeEditor(
|
|
37
|
-
postType,
|
|
38
|
-
postId,
|
|
39
|
-
target,
|
|
40
|
-
settings,
|
|
41
|
-
initialEdits
|
|
42
|
-
) {
|
|
43
|
-
unmountComponentAtNode( target );
|
|
44
|
-
const reboot = reinitializeEditor.bind(
|
|
45
|
-
null,
|
|
46
|
-
postType,
|
|
47
|
-
postId,
|
|
48
|
-
target,
|
|
49
|
-
settings,
|
|
50
|
-
initialEdits
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
render(
|
|
54
|
-
<Editor
|
|
55
|
-
settings={ settings }
|
|
56
|
-
onError={ reboot }
|
|
57
|
-
postId={ postId }
|
|
58
|
-
postType={ postType }
|
|
59
|
-
initialEdits={ initialEdits }
|
|
60
|
-
recovery
|
|
61
|
-
/>,
|
|
62
|
-
target
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
24
|
/**
|
|
67
25
|
* Initializes and returns an instance of Editor.
|
|
68
26
|
*
|
|
@@ -82,14 +40,7 @@ export function initializeEditor(
|
|
|
82
40
|
initialEdits
|
|
83
41
|
) {
|
|
84
42
|
const target = document.getElementById( id );
|
|
85
|
-
const
|
|
86
|
-
null,
|
|
87
|
-
postType,
|
|
88
|
-
postId,
|
|
89
|
-
target,
|
|
90
|
-
settings,
|
|
91
|
-
initialEdits
|
|
92
|
-
);
|
|
43
|
+
const root = createRoot( target );
|
|
93
44
|
|
|
94
45
|
dispatch( preferencesStore ).setDefaults( 'core/edit-post', {
|
|
95
46
|
editorMode: 'visual',
|
|
@@ -187,16 +138,26 @@ export function initializeEditor(
|
|
|
187
138
|
window.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );
|
|
188
139
|
window.addEventListener( 'drop', ( e ) => e.preventDefault(), false );
|
|
189
140
|
|
|
190
|
-
render(
|
|
141
|
+
root.render(
|
|
191
142
|
<Editor
|
|
192
143
|
settings={ settings }
|
|
193
|
-
onError={ reboot }
|
|
194
144
|
postId={ postId }
|
|
195
145
|
postType={ postType }
|
|
196
146
|
initialEdits={ initialEdits }
|
|
197
|
-
|
|
198
|
-
target
|
|
147
|
+
/>
|
|
199
148
|
);
|
|
149
|
+
|
|
150
|
+
return root;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Used to reinitialize the editor after an error. Now it's a deprecated noop function.
|
|
155
|
+
*/
|
|
156
|
+
export function reinitializeEditor() {
|
|
157
|
+
deprecated( 'wp.editPost.reinitializeEditor', {
|
|
158
|
+
since: '6.2',
|
|
159
|
+
version: '6.3',
|
|
160
|
+
} );
|
|
200
161
|
}
|
|
201
162
|
|
|
202
163
|
export { default as PluginBlockSettingsMenuItem } from './components/block-settings-menu/plugin-block-settings-menu-item';
|