@wordpress/edit-post 5.0.22 → 5.1.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/LICENSE.md +1 -1
- package/build/components/block-manager/category.js +42 -47
- package/build/components/block-manager/category.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/layout/index.js +3 -1
- 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 +20 -10
- 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/index.js +2 -1
- 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.native.js +3 -9
- package/build/index.native.js.map +1 -1
- package/build/store/selectors.js +3 -1
- package/build/store/selectors.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/header/index.native.js +4 -4
- package/build-module/components/header/index.native.js.map +1 -1
- package/build-module/components/layout/index.js +4 -2
- 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 +20 -10
- 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/index.js +2 -1
- 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.native.js +2 -9
- package/build-module/index.native.js.map +1 -1
- package/build-module/store/selectors.js +3 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +17 -16
- package/build-style/style.css +17 -16
- package/package.json +27 -27
- package/src/components/block-manager/category.js +41 -48
- package/src/components/header/index.native.js +10 -4
- 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 +2 -1
- package/src/components/layout/index.native.js +2 -5
- package/src/components/preferences-modal/index.js +9 -16
- 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/post-author/index.js +1 -1
- package/src/components/sidebar/template/index.js +1 -0
- package/src/components/visual-editor/index.js +16 -6
- 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.native.js +1 -10
- package/src/store/selectors.js +1 -1
- 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
|
@@ -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 }
|
|
@@ -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.native.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import '@wordpress/core-data';
|
|
5
5
|
import '@wordpress/format-library';
|
|
6
|
-
import { render } from '@wordpress/element';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Internal dependencies
|
|
@@ -11,8 +10,6 @@ import { render } from '@wordpress/element';
|
|
|
11
10
|
export { store } from './store';
|
|
12
11
|
import Editor from './editor';
|
|
13
12
|
|
|
14
|
-
let editorInitialized = false;
|
|
15
|
-
|
|
16
13
|
/**
|
|
17
14
|
* Initializes the Editor and returns a componentProvider
|
|
18
15
|
* that can be registered with `AppRegistry.registerComponent`
|
|
@@ -22,11 +19,5 @@ let editorInitialized = false;
|
|
|
22
19
|
* @param {Object} postId ID of the post to edit (unused right now)
|
|
23
20
|
*/
|
|
24
21
|
export function initializeEditor( id, postType, postId ) {
|
|
25
|
-
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
editorInitialized = true;
|
|
30
|
-
|
|
31
|
-
render( <Editor postId={ postId } postType={ postType } />, id );
|
|
22
|
+
return <Editor postId={ postId } postType={ postType } />;
|
|
32
23
|
}
|
package/src/store/selectors.js
CHANGED
|
@@ -394,7 +394,7 @@ export const getEditedPostTemplate = createRegistrySelector(
|
|
|
394
394
|
);
|
|
395
395
|
if ( currentTemplate ) {
|
|
396
396
|
const templateWithSameSlug = select( coreStore )
|
|
397
|
-
.getEntityRecords( 'postType', 'wp_template' )
|
|
397
|
+
.getEntityRecords( 'postType', 'wp_template', { per_page: -1 } )
|
|
398
398
|
?.find( ( template ) => template.slug === currentTemplate );
|
|
399
399
|
if ( ! templateWithSameSlug ) {
|
|
400
400
|
return templateWithSameSlug;
|
package/src/style.scss
CHANGED
|
@@ -59,9 +59,8 @@ body.block-editor-page {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
// Target the editor UI excluding the metaboxes and custom fields areas.
|
|
62
|
+
// Target the editor UI excluding the visual editor contents, metaboxes and custom fields areas.
|
|
63
63
|
.edit-post-header,
|
|
64
|
-
.edit-post-visual-editor,
|
|
65
64
|
.edit-post-text-editor,
|
|
66
65
|
.edit-post-sidebar,
|
|
67
66
|
.editor-post-publish-panel,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import { act } from 'react-dom/test-utils';
|
|
4
|
+
import { act, render } from 'test/helpers';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* WordPress dependencies
|
|
@@ -26,11 +25,12 @@ const unsupportedBlock = `
|
|
|
26
25
|
<!-- /wp:notablock -->
|
|
27
26
|
`;
|
|
28
27
|
|
|
28
|
+
jest.useFakeTimers( 'legacy' );
|
|
29
|
+
|
|
29
30
|
describe( 'Editor', () => {
|
|
30
31
|
beforeAll( registerCoreBlocks );
|
|
31
32
|
|
|
32
33
|
it( 'detects unsupported block and sends hasUnsupportedBlocks true to native', () => {
|
|
33
|
-
jest.useFakeTimers();
|
|
34
34
|
RNReactNativeGutenbergBridge.editorDidMount = jest.fn();
|
|
35
35
|
|
|
36
36
|
const appContainer = renderEditorWith( unsupportedBlock );
|
|
@@ -51,7 +51,7 @@ describe( 'Editor', () => {
|
|
|
51
51
|
|
|
52
52
|
// Utilities
|
|
53
53
|
const renderEditorWith = ( content ) => {
|
|
54
|
-
return
|
|
54
|
+
return render(
|
|
55
55
|
<Editor
|
|
56
56
|
initialHtml={ content }
|
|
57
57
|
initialHtmlModeEnabled={ false }
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* WordPress dependencies
|
|
12
|
-
*/
|
|
13
|
-
const EditPostSettings = (0, _element.createContext)({});
|
|
14
|
-
var _default = EditPostSettings;
|
|
15
|
-
exports.default = _default;
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/edit-post-settings/index.js"],"names":["EditPostSettings"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,MAAMA,gBAAgB,GAAG,4BAAe,EAAf,CAAzB;eACeA,gB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nconst EditPostSettings = createContext( {} );\nexport default EditPostSettings;\n"]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _default = {
|
|
8
|
-
't a l e s o f g u t e n b e r g': event => {
|
|
9
|
-
const {
|
|
10
|
-
ownerDocument
|
|
11
|
-
} = event.target;
|
|
12
|
-
|
|
13
|
-
if (!ownerDocument.activeElement.classList.contains('edit-post-visual-editor') && ownerDocument.activeElement !== ownerDocument.body) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
event.preventDefault();
|
|
18
|
-
window.wp.data.dispatch('core/block-editor').insertBlock(window.wp.blocks.createBlock('core/paragraph', {
|
|
19
|
-
content: '🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️'
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
exports.default = _default;
|
|
24
|
-
//# sourceMappingURL=prevent-event-discovery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/prevent-event-discovery.js"],"names":["event","ownerDocument","target","activeElement","classList","contains","body","preventDefault","window","wp","data","dispatch","insertBlock","blocks","createBlock","content"],"mappings":";;;;;;eAAe;AACd,qCAAqCA,KAAF,IAAa;AAC/C,UAAM;AAAEC,MAAAA;AAAF,QAAoBD,KAAK,CAACE,MAAhC;;AACA,QACC,CAAED,aAAa,CAACE,aAAd,CAA4BC,SAA5B,CAAsCC,QAAtC,CACD,yBADC,CAAF,IAGAJ,aAAa,CAACE,aAAd,KAAgCF,aAAa,CAACK,IAJ/C,EAKE;AACD;AACA;;AAEDN,IAAAA,KAAK,CAACO,cAAN;AACAC,IAAAA,MAAM,CAACC,EAAP,CAAUC,IAAV,CAAeC,QAAf,CAAyB,mBAAzB,EAA+CC,WAA/C,CACCJ,MAAM,CAACC,EAAP,CAAUI,MAAV,CAAiBC,WAAjB,CAA8B,gBAA9B,EAAgD;AAC/CC,MAAAA,OAAO,EACN;AAF8C,KAAhD,CADD;AAMA;AAnBa,C","sourcesContent":["export default {\n\t't a l e s o f g u t e n b e r g': ( event ) => {\n\t\tconst { ownerDocument } = event.target;\n\t\tif (\n\t\t\t! ownerDocument.activeElement.classList.contains(\n\t\t\t\t'edit-post-visual-editor'\n\t\t\t) &&\n\t\t\townerDocument.activeElement !== ownerDocument.body\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tevent.preventDefault();\n\t\twindow.wp.data.dispatch( 'core/block-editor' ).insertBlock(\n\t\t\twindow.wp.blocks.createBlock( 'core/paragraph', {\n\t\t\t\tcontent:\n\t\t\t\t\t'🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️',\n\t\t\t} )\n\t\t);\n\t},\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/edit-post-settings/index.js"],"names":["createContext","EditPostSettings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,oBAA9B;AAEA,MAAMC,gBAAgB,GAAGD,aAAa,CAAE,EAAF,CAAtC;AACA,eAAeC,gBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nconst EditPostSettings = createContext( {} );\nexport default EditPostSettings;\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
't a l e s o f g u t e n b e r g': event => {
|
|
3
|
-
const {
|
|
4
|
-
ownerDocument
|
|
5
|
-
} = event.target;
|
|
6
|
-
|
|
7
|
-
if (!ownerDocument.activeElement.classList.contains('edit-post-visual-editor') && ownerDocument.activeElement !== ownerDocument.body) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
event.preventDefault();
|
|
12
|
-
window.wp.data.dispatch('core/block-editor').insertBlock(window.wp.blocks.createBlock('core/paragraph', {
|
|
13
|
-
content: '🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️'
|
|
14
|
-
}));
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=prevent-event-discovery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/prevent-event-discovery.js"],"names":["event","ownerDocument","target","activeElement","classList","contains","body","preventDefault","window","wp","data","dispatch","insertBlock","blocks","createBlock","content"],"mappings":"AAAA,eAAe;AACd,qCAAqCA,KAAF,IAAa;AAC/C,UAAM;AAAEC,MAAAA;AAAF,QAAoBD,KAAK,CAACE,MAAhC;;AACA,QACC,CAAED,aAAa,CAACE,aAAd,CAA4BC,SAA5B,CAAsCC,QAAtC,CACD,yBADC,CAAF,IAGAJ,aAAa,CAACE,aAAd,KAAgCF,aAAa,CAACK,IAJ/C,EAKE;AACD;AACA;;AAEDN,IAAAA,KAAK,CAACO,cAAN;AACAC,IAAAA,MAAM,CAACC,EAAP,CAAUC,IAAV,CAAeC,QAAf,CAAyB,mBAAzB,EAA+CC,WAA/C,CACCJ,MAAM,CAACC,EAAP,CAAUI,MAAV,CAAiBC,WAAjB,CAA8B,gBAA9B,EAAgD;AAC/CC,MAAAA,OAAO,EACN;AAF8C,KAAhD,CADD;AAMA;AAnBa,CAAf","sourcesContent":["export default {\n\t't a l e s o f g u t e n b e r g': ( event ) => {\n\t\tconst { ownerDocument } = event.target;\n\t\tif (\n\t\t\t! ownerDocument.activeElement.classList.contains(\n\t\t\t\t'edit-post-visual-editor'\n\t\t\t) &&\n\t\t\townerDocument.activeElement !== ownerDocument.body\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tevent.preventDefault();\n\t\twindow.wp.data.dispatch( 'core/block-editor' ).insertBlock(\n\t\t\twindow.wp.blocks.createBlock( 'core/paragraph', {\n\t\t\t\tcontent:\n\t\t\t\t\t'🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️',\n\t\t\t} )\n\t\t);\n\t},\n};\n"]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
't a l e s o f g u t e n b e r g': ( event ) => {
|
|
3
|
-
const { ownerDocument } = event.target;
|
|
4
|
-
if (
|
|
5
|
-
! ownerDocument.activeElement.classList.contains(
|
|
6
|
-
'edit-post-visual-editor'
|
|
7
|
-
) &&
|
|
8
|
-
ownerDocument.activeElement !== ownerDocument.body
|
|
9
|
-
) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
event.preventDefault();
|
|
14
|
-
window.wp.data.dispatch( 'core/block-editor' ).insertBlock(
|
|
15
|
-
window.wp.blocks.createBlock( 'core/paragraph', {
|
|
16
|
-
content:
|
|
17
|
-
'🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️',
|
|
18
|
-
} )
|
|
19
|
-
);
|
|
20
|
-
},
|
|
21
|
-
};
|