@wordpress/edit-post 7.14.0 → 7.15.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/device-preview/index.js +6 -6
- package/build/components/device-preview/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.js +7 -6
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.native.js +91 -49
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/index.js +1 -6
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/post-publish-button-or-toggle.js +0 -2
- package/build/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build/components/layout/actions-panel.js +5 -10
- package/build/components/layout/actions-panel.js.map +1 -1
- package/build/components/layout/index.js +2 -12
- package/build/components/layout/index.js.map +1 -1
- package/build/components/text-editor/index.js +1 -1
- package/build/components/text-editor/index.js.map +1 -1
- package/build/components/visual-editor/header.native.js +1 -13
- package/build/components/visual-editor/header.native.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/plugins/index.js +35 -6
- package/build/plugins/index.js.map +1 -1
- package/build/store/actions.js +12 -14
- package/build/store/actions.js.map +1 -1
- package/build-module/components/device-preview/index.js +6 -6
- package/build-module/components/device-preview/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.js +7 -6
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js +92 -53
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/index.js +1 -6
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/post-publish-button-or-toggle.js +0 -2
- package/build-module/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build-module/components/layout/actions-panel.js +5 -10
- package/build-module/components/layout/actions-panel.js.map +1 -1
- package/build-module/components/layout/index.js +4 -13
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/text-editor/index.js +2 -2
- package/build-module/components/text-editor/index.js.map +1 -1
- package/build-module/components/visual-editor/header.native.js +1 -10
- package/build-module/components/visual-editor/header.native.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/plugins/index.js +33 -6
- package/build-module/plugins/index.js.map +1 -1
- package/build-module/store/actions.js +11 -14
- package/build-module/store/actions.js.map +1 -1
- package/build-style/style-rtl.css +9 -13
- package/build-style/style.css +9 -13
- package/package.json +32 -32
- package/src/components/device-preview/index.js +35 -39
- package/src/components/header/header-toolbar/index.js +3 -2
- package/src/components/header/header-toolbar/index.native.js +124 -68
- package/src/components/header/header-toolbar/style.native.scss +23 -4
- package/src/components/header/index.js +12 -22
- package/src/components/header/post-publish-button-or-toggle.js +0 -2
- package/src/components/layout/actions-panel.js +5 -7
- package/src/components/layout/index.js +5 -14
- package/src/components/layout/style.native.scss +1 -1
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +11 -3
- package/src/components/text-editor/index.js +0 -2
- package/src/components/visual-editor/header.native.js +1 -17
- package/src/components/visual-editor/index.js +1 -6
- package/src/components/visual-editor/test/__snapshots__/index.native.js.snap +15 -0
- package/src/components/visual-editor/test/index.native.js +118 -1
- package/src/plugins/index.js +32 -8
- package/src/store/actions.js +18 -27
- package/src/style.scss +1 -7
- package/src/components/visual-editor/style.native.scss +0 -18
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { initializeEditor, fireEvent } from 'test/helpers';
|
|
4
|
+
import { initializeEditor, getEditorHtml, fireEvent } from 'test/helpers';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
+
import { Platform } from '@wordpress/element';
|
|
9
10
|
import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
|
|
10
11
|
import { registerCoreBlocks } from '@wordpress/block-library';
|
|
11
12
|
|
|
@@ -21,6 +22,12 @@ afterAll( () => {
|
|
|
21
22
|
} );
|
|
22
23
|
} );
|
|
23
24
|
|
|
25
|
+
const MEDIA_OPTIONS = [
|
|
26
|
+
'Choose from device',
|
|
27
|
+
'Take a Photo',
|
|
28
|
+
'WordPress Media Library',
|
|
29
|
+
];
|
|
30
|
+
|
|
24
31
|
const initialHtml = `
|
|
25
32
|
<!-- wp:paragraph -->
|
|
26
33
|
<p>First example paragraph.</p>
|
|
@@ -63,6 +70,38 @@ describe( 'when title is focused', () => {
|
|
|
63
70
|
screen.getAllByLabelText( /Paragraph Block. Row 3/ )[ 0 ]
|
|
64
71
|
).toBeDefined();
|
|
65
72
|
} );
|
|
73
|
+
|
|
74
|
+
it( 'media blocks should be displayed', async () => {
|
|
75
|
+
const screen = await initializeEditor( {
|
|
76
|
+
initialHtml,
|
|
77
|
+
} );
|
|
78
|
+
|
|
79
|
+
// Focus first block
|
|
80
|
+
fireEvent.press(
|
|
81
|
+
screen.getAllByLabelText( /Paragraph Block. Row 1/ )[ 0 ]
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
// Focus title
|
|
85
|
+
fireEvent(
|
|
86
|
+
screen.getAllByLabelText( 'Post title. test' )[ 0 ],
|
|
87
|
+
'select'
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
// Assert that the media buttons are visible
|
|
91
|
+
const imageButton = await screen.findByTestId( 'insert-image-button' );
|
|
92
|
+
expect( imageButton ).toBeVisible();
|
|
93
|
+
|
|
94
|
+
const videoButton = await screen.findByTestId( 'insert-video-button' );
|
|
95
|
+
expect( videoButton ).toBeVisible();
|
|
96
|
+
|
|
97
|
+
const galleryButton = await screen.findByTestId(
|
|
98
|
+
'insert-gallery-button'
|
|
99
|
+
);
|
|
100
|
+
expect( galleryButton ).toBeVisible();
|
|
101
|
+
|
|
102
|
+
const audioButton = await screen.findByTestId( 'insert-audio-button' );
|
|
103
|
+
expect( audioButton ).toBeVisible();
|
|
104
|
+
} );
|
|
66
105
|
} );
|
|
67
106
|
|
|
68
107
|
describe( 'when title is no longer focused', () => {
|
|
@@ -101,4 +140,82 @@ describe( 'when title is no longer focused', () => {
|
|
|
101
140
|
screen.getAllByLabelText( /Heading Block. Row 3/ )[ 0 ]
|
|
102
141
|
).toBeDefined();
|
|
103
142
|
} );
|
|
143
|
+
|
|
144
|
+
it( 'media blocks should not be displayed', async () => {
|
|
145
|
+
const screen = await initializeEditor( {
|
|
146
|
+
initialHtml,
|
|
147
|
+
} );
|
|
148
|
+
|
|
149
|
+
// Focus first block
|
|
150
|
+
fireEvent.press(
|
|
151
|
+
screen.getAllByLabelText( /Paragraph Block. Row 1/ )[ 0 ]
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
// Focus title
|
|
155
|
+
fireEvent(
|
|
156
|
+
screen.getAllByLabelText( 'Post title. test' )[ 0 ],
|
|
157
|
+
'select'
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
// Focus last block
|
|
161
|
+
fireEvent.press(
|
|
162
|
+
screen.getAllByLabelText( /Paragraph Block. Row 2/ )[ 0 ]
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
// Assert that the media buttons are not visible
|
|
166
|
+
const imageButton = screen.queryByTestId( 'insert-image-button' );
|
|
167
|
+
expect( imageButton ).toBeNull();
|
|
168
|
+
|
|
169
|
+
const videoButton = screen.queryByTestId( 'insert-video-button' );
|
|
170
|
+
expect( videoButton ).toBeNull();
|
|
171
|
+
|
|
172
|
+
const galleryButton = screen.queryByTestId( 'insert-gallery-button' );
|
|
173
|
+
expect( galleryButton ).toBeNull();
|
|
174
|
+
|
|
175
|
+
const audioButton = screen.queryByTestId( 'insert-audio-button' );
|
|
176
|
+
expect( audioButton ).toBeNull();
|
|
177
|
+
} );
|
|
178
|
+
} );
|
|
179
|
+
|
|
180
|
+
describe( 'when nothing is selected', () => {
|
|
181
|
+
it( 'media buttons and picker display correctly', async () => {
|
|
182
|
+
const screen = await initializeEditor( {
|
|
183
|
+
initialHtml,
|
|
184
|
+
} );
|
|
185
|
+
|
|
186
|
+
const { getByText, getByTestId } = screen;
|
|
187
|
+
|
|
188
|
+
// Check that the gallery button is visible within the toolbar
|
|
189
|
+
const galleryButton = await screen.queryByTestId(
|
|
190
|
+
'insert-gallery-button'
|
|
191
|
+
);
|
|
192
|
+
expect( galleryButton ).toBeVisible();
|
|
193
|
+
|
|
194
|
+
// Press the toolbar Gallery button
|
|
195
|
+
fireEvent.press( galleryButton );
|
|
196
|
+
|
|
197
|
+
// Expect the block to be created
|
|
198
|
+
expect(
|
|
199
|
+
screen.getAllByLabelText( /Gallery Block. Row 3/ )[ 0 ]
|
|
200
|
+
).toBeDefined();
|
|
201
|
+
|
|
202
|
+
expect( getByText( 'Choose images' ) ).toBeVisible();
|
|
203
|
+
MEDIA_OPTIONS.forEach( ( option ) =>
|
|
204
|
+
expect( getByText( option ) ).toBeVisible()
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
// Dismiss the picker
|
|
208
|
+
if ( Platform.isIOS ) {
|
|
209
|
+
fireEvent.press( getByText( 'Cancel' ) );
|
|
210
|
+
} else {
|
|
211
|
+
fireEvent( getByTestId( 'media-options-picker' ), 'backdropPress' );
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Expect the Gallery block to remain
|
|
215
|
+
expect(
|
|
216
|
+
screen.getAllByLabelText( /Gallery Block. Row 3/ )[ 0 ]
|
|
217
|
+
).toBeDefined();
|
|
218
|
+
|
|
219
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
220
|
+
} );
|
|
104
221
|
} );
|
package/src/plugins/index.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { MenuItem, VisuallyHidden } from '@wordpress/components';
|
|
5
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
7
|
+
import { useSelect } from '@wordpress/data';
|
|
5
8
|
import { external } from '@wordpress/icons';
|
|
6
9
|
import { __ } from '@wordpress/i18n';
|
|
7
10
|
import { registerPlugin } from '@wordpress/plugins';
|
|
@@ -15,6 +18,34 @@ import KeyboardShortcutsHelpMenuItem from './keyboard-shortcuts-help-menu-item';
|
|
|
15
18
|
import ToolsMoreMenuGroup from '../components/header/tools-more-menu-group';
|
|
16
19
|
import WelcomeGuideMenuItem from './welcome-guide-menu-item';
|
|
17
20
|
|
|
21
|
+
function ManagePatternsMenuItem() {
|
|
22
|
+
const url = useSelect( ( select ) => {
|
|
23
|
+
const { canUser } = select( coreStore );
|
|
24
|
+
const { getEditorSettings } = select( editorStore );
|
|
25
|
+
|
|
26
|
+
const isBlockTheme = getEditorSettings().__unstableIsBlockBasedTheme;
|
|
27
|
+
const defaultUrl = addQueryArgs( 'edit.php', {
|
|
28
|
+
post_type: 'wp_block',
|
|
29
|
+
} );
|
|
30
|
+
const patternsUrl = addQueryArgs( 'site-editor.php', {
|
|
31
|
+
path: '/patterns',
|
|
32
|
+
} );
|
|
33
|
+
|
|
34
|
+
// The site editor and templates both check whether the user has
|
|
35
|
+
// edit_theme_options capabilities. We can leverage that here and not
|
|
36
|
+
// display the manage patterns link if the user can't access it.
|
|
37
|
+
return canUser( 'read', 'templates' ) && isBlockTheme
|
|
38
|
+
? patternsUrl
|
|
39
|
+
: defaultUrl;
|
|
40
|
+
}, [] );
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<MenuItem role="menuitem" href={ url }>
|
|
44
|
+
{ __( 'Manage patterns' ) }
|
|
45
|
+
</MenuItem>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
18
49
|
registerPlugin( 'edit-post', {
|
|
19
50
|
render() {
|
|
20
51
|
return (
|
|
@@ -22,14 +53,7 @@ registerPlugin( 'edit-post', {
|
|
|
22
53
|
<ToolsMoreMenuGroup>
|
|
23
54
|
{ ( { onClose } ) => (
|
|
24
55
|
<>
|
|
25
|
-
<
|
|
26
|
-
role="menuitem"
|
|
27
|
-
href={ addQueryArgs( 'edit.php', {
|
|
28
|
-
post_type: 'wp_block',
|
|
29
|
-
} ) }
|
|
30
|
-
>
|
|
31
|
-
{ __( 'Manage Patterns' ) }
|
|
32
|
-
</MenuItem>
|
|
56
|
+
<ManagePatternsMenuItem />
|
|
33
57
|
<KeyboardShortcutsHelpMenuItem
|
|
34
58
|
onSelect={ onClose }
|
|
35
59
|
/>
|
package/src/store/actions.js
CHANGED
|
@@ -11,6 +11,7 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
11
11
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
12
12
|
import { store as editorStore } from '@wordpress/editor';
|
|
13
13
|
import deprecated from '@wordpress/deprecated';
|
|
14
|
+
import { addFilter } from '@wordpress/hooks';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Internal dependencies
|
|
@@ -567,33 +568,23 @@ export const initializeMetaBoxes =
|
|
|
567
568
|
|
|
568
569
|
metaBoxesInitialized = true;
|
|
569
570
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
.
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
select.hasMetaBoxes();
|
|
588
|
-
|
|
589
|
-
// Save current state for next inspection.
|
|
590
|
-
wasSavingPost = isSavingPost;
|
|
591
|
-
wasAutosavingPost = isAutosavingPost;
|
|
592
|
-
|
|
593
|
-
if ( shouldTriggerMetaboxesSave ) {
|
|
594
|
-
await dispatch.requestMetaBoxUpdates();
|
|
595
|
-
}
|
|
596
|
-
} );
|
|
571
|
+
// Save metaboxes on save completion, except for autosaves.
|
|
572
|
+
addFilter(
|
|
573
|
+
'editor.__unstableSavePost',
|
|
574
|
+
'core/edit-post/save-metaboxes',
|
|
575
|
+
( previous, options ) =>
|
|
576
|
+
previous.then( () => {
|
|
577
|
+
if ( options.isAutosave ) {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
if ( ! select.hasMetaBoxes() ) {
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
return dispatch.requestMetaBoxUpdates();
|
|
586
|
+
} )
|
|
587
|
+
);
|
|
597
588
|
|
|
598
589
|
dispatch( {
|
|
599
590
|
type: 'META_BOXES_INITIALIZED',
|
package/src/style.scss
CHANGED
|
@@ -41,13 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
// We scope it to .wp-toolbar to be wp-admin only, to prevent bleed into other implementations
|
|
46
|
-
html.wp-toolbar {
|
|
47
|
-
background: $white;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
body.block-editor-page {
|
|
44
|
+
body.js.block-editor-page {
|
|
51
45
|
@include wp-admin-reset( ".block-editor" );
|
|
52
46
|
}
|
|
53
47
|
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
.blockHolderFullBordered {
|
|
2
|
-
border-top-width: $block-selected-border-width;
|
|
3
|
-
border-bottom-width: $block-selected-border-width;
|
|
4
|
-
border-left-width: $block-selected-border-width;
|
|
5
|
-
border-right-width: $block-selected-border-width;
|
|
6
|
-
border-radius: 4px;
|
|
7
|
-
border-style: solid;
|
|
8
|
-
margin-left: 4px;
|
|
9
|
-
margin-right: 4px;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.blockHolderFocused {
|
|
13
|
-
border-color: $blue-wordpress;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.blockHolderFocusedDark {
|
|
17
|
-
border-color: $blue-30;
|
|
18
|
-
}
|