@wordpress/edit-post 7.13.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 +4 -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 +10 -3
- 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 +26 -30
- 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/header/preferences-menu-item/index.js +5 -3
- package/build/components/header/preferences-menu-item/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +8 -6
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +0 -2
- package/build/components/keyboard-shortcuts/index.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 -2
- package/build/components/layout/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +5 -3
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/sidebar/post-status/index.js +2 -1
- package/build/components/sidebar/post-status/index.js.map +1 -1
- package/build/components/sidebar/post-trash/index.js +1 -5
- package/build/components/sidebar/post-trash/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/editor.js +3 -0
- package/build/editor.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +176 -0
- package/build/hooks/commands/use-common-commands.js.map +1 -0
- package/build/plugins/index.js +35 -6
- package/build/plugins/index.js.map +1 -1
- package/build/plugins/keyboard-shortcuts-help-menu-item/index.js +5 -3
- package/build/plugins/keyboard-shortcuts-help-menu-item/index.js.map +1 -1
- package/build/store/actions.js +43 -29
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +0 -23
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +11 -7
- package/build/store/selectors.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 +9 -3
- 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 +25 -30
- 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/header/preferences-menu-item/index.js +4 -3
- package/build-module/components/header/preferences-menu-item/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +5 -5
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +0 -2
- package/build-module/components/keyboard-shortcuts/index.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 +3 -3
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +4 -4
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/sidebar/post-status/index.js +2 -1
- package/build-module/components/sidebar/post-status/index.js.map +1 -1
- package/build-module/components/sidebar/post-trash/index.js +1 -4
- package/build-module/components/sidebar/post-trash/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/editor.js +2 -0
- package/build-module/editor.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +160 -0
- package/build-module/hooks/commands/use-common-commands.js.map +1 -0
- package/build-module/plugins/index.js +33 -6
- package/build-module/plugins/index.js.map +1 -1
- package/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js +4 -3
- package/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js.map +1 -1
- package/build-module/store/actions.js +35 -25
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +0 -21
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +9 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +10 -15
- package/build-style/style.css +10 -15
- package/package.json +32 -32
- package/src/components/block-manager/style.scss +1 -1
- package/src/components/device-preview/index.js +35 -39
- package/src/components/header/header-toolbar/index.js +5 -1
- 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 +22 -32
- package/src/components/header/post-publish-button-or-toggle.js +0 -2
- package/src/components/header/preferences-menu-item/index.js +4 -3
- package/src/components/keyboard-shortcut-help-modal/index.js +10 -5
- package/src/components/keyboard-shortcuts/index.js +0 -2
- package/src/components/layout/actions-panel.js +5 -7
- package/src/components/layout/index.js +4 -0
- package/src/components/layout/style.native.scss +1 -1
- package/src/components/preferences-modal/index.js +6 -4
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +11 -3
- package/src/components/sidebar/post-status/index.js +1 -0
- package/src/components/sidebar/post-trash/index.js +1 -4
- package/src/components/start-page-options/style.scss +0 -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/editor.js +2 -0
- package/src/hooks/commands/use-common-commands.js +155 -0
- package/src/plugins/index.js +32 -8
- package/src/plugins/keyboard-shortcuts-help-menu-item/index.js +4 -3
- package/src/store/actions.js +40 -36
- package/src/store/reducer.js +0 -20
- package/src/store/selectors.js +11 -3
- package/src/store/test/reducer.js +0 -25
- package/src/store/test/selectors.js +0 -27
- package/src/style.scss +1 -7
- package/src/components/visual-editor/style.native.scss +0 -18
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from '@wordpress/keyboard-shortcuts';
|
|
15
15
|
import { withSelect, withDispatch, useSelect } from '@wordpress/data';
|
|
16
16
|
import { compose } from '@wordpress/compose';
|
|
17
|
+
import { store as interfaceStore } from '@wordpress/interface';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Internal dependencies
|
|
@@ -21,9 +22,9 @@ import { compose } from '@wordpress/compose';
|
|
|
21
22
|
import { textFormattingShortcuts } from './config';
|
|
22
23
|
import Shortcut from './shortcut';
|
|
23
24
|
import DynamicShortcut from './dynamic-shortcut';
|
|
24
|
-
import { store as editPostStore } from '../../store';
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
export const KEYBOARD_SHORTCUT_HELP_MODAL_NAME =
|
|
27
|
+
'edit-post/keyboard-shortcut-help';
|
|
27
28
|
|
|
28
29
|
const ShortcutList = ( { shortcuts } ) => (
|
|
29
30
|
/*
|
|
@@ -141,14 +142,18 @@ export function KeyboardShortcutHelpModal( { isModalActive, toggleModal } ) {
|
|
|
141
142
|
|
|
142
143
|
export default compose( [
|
|
143
144
|
withSelect( ( select ) => ( {
|
|
144
|
-
isModalActive: select(
|
|
145
|
+
isModalActive: select( interfaceStore ).isModalActive(
|
|
146
|
+
KEYBOARD_SHORTCUT_HELP_MODAL_NAME
|
|
147
|
+
),
|
|
145
148
|
} ) ),
|
|
146
149
|
withDispatch( ( dispatch, { isModalActive } ) => {
|
|
147
|
-
const { openModal, closeModal } = dispatch(
|
|
150
|
+
const { openModal, closeModal } = dispatch( interfaceStore );
|
|
148
151
|
|
|
149
152
|
return {
|
|
150
153
|
toggleModal: () =>
|
|
151
|
-
isModalActive
|
|
154
|
+
isModalActive
|
|
155
|
+
? closeModal()
|
|
156
|
+
: openModal( KEYBOARD_SHORTCUT_HELP_MODAL_NAME ),
|
|
152
157
|
};
|
|
153
158
|
} ),
|
|
154
159
|
] )( KeyboardShortcutHelpModal );
|
|
@@ -223,8 +223,6 @@ function KeyboardShortcuts() {
|
|
|
223
223
|
} );
|
|
224
224
|
|
|
225
225
|
useShortcut( 'core/edit-post/toggle-distraction-free', () => {
|
|
226
|
-
closeGeneralSidebar();
|
|
227
|
-
setIsListViewOpened( false );
|
|
228
226
|
toggleDistractionFree();
|
|
229
227
|
toggleFeature( 'distractionFree' );
|
|
230
228
|
createInfoNotice(
|
|
@@ -31,18 +31,17 @@ export default function ActionsPanel( {
|
|
|
31
31
|
const {
|
|
32
32
|
publishSidebarOpened,
|
|
33
33
|
hasActiveMetaboxes,
|
|
34
|
-
isSavingMetaBoxes,
|
|
35
34
|
hasNonPostEntityChanges,
|
|
36
|
-
} = useSelect(
|
|
37
|
-
|
|
35
|
+
} = useSelect(
|
|
36
|
+
( select ) => ( {
|
|
38
37
|
publishSidebarOpened:
|
|
39
38
|
select( editPostStore ).isPublishSidebarOpened(),
|
|
40
39
|
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
|
|
41
|
-
isSavingMetaBoxes: select( editPostStore ).isSavingMetaBoxes(),
|
|
42
40
|
hasNonPostEntityChanges:
|
|
43
41
|
select( editorStore ).hasNonPostEntityChanges(),
|
|
44
|
-
}
|
|
45
|
-
|
|
42
|
+
} ),
|
|
43
|
+
[]
|
|
44
|
+
);
|
|
46
45
|
|
|
47
46
|
const openEntitiesSavedStates = useCallback(
|
|
48
47
|
() => setEntitiesSavedStatesCallback( true ),
|
|
@@ -57,7 +56,6 @@ export default function ActionsPanel( {
|
|
|
57
56
|
<PostPublishPanel
|
|
58
57
|
onClose={ closePublishSidebar }
|
|
59
58
|
forceIsDirty={ hasActiveMetaboxes }
|
|
60
|
-
forceIsSaving={ isSavingMetaBoxes }
|
|
61
59
|
PrePublishExtension={ PluginPrePublishPanel.Slot }
|
|
62
60
|
PostPublishExtension={ PluginPostPublishPanel.Slot }
|
|
63
61
|
/>
|
|
@@ -12,7 +12,9 @@ import {
|
|
|
12
12
|
UnsavedChangesWarning,
|
|
13
13
|
EditorNotices,
|
|
14
14
|
EditorKeyboardShortcutsRegister,
|
|
15
|
+
EditorKeyboardShortcuts,
|
|
15
16
|
EditorSnackbars,
|
|
17
|
+
PostSyncStatusModal,
|
|
16
18
|
store as editorStore,
|
|
17
19
|
} from '@wordpress/editor';
|
|
18
20
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
@@ -202,6 +204,7 @@ function Layout( { styles } ) {
|
|
|
202
204
|
<LocalAutosaveMonitor />
|
|
203
205
|
<EditPostKeyboardShortcuts />
|
|
204
206
|
<EditorKeyboardShortcutsRegister />
|
|
207
|
+
<EditorKeyboardShortcuts />
|
|
205
208
|
<SettingsSidebar />
|
|
206
209
|
<InterfaceSkeleton
|
|
207
210
|
isDistractionFree={ isDistractionFree && isLargeViewport }
|
|
@@ -291,6 +294,7 @@ function Layout( { styles } ) {
|
|
|
291
294
|
<EditPostPreferencesModal />
|
|
292
295
|
<KeyboardShortcutHelpModal />
|
|
293
296
|
<WelcomeGuide />
|
|
297
|
+
<PostSyncStatusModal />
|
|
294
298
|
<StartPageOptions />
|
|
295
299
|
<Popover.Slot />
|
|
296
300
|
<PluginArea onError={ onPluginAreaError } />
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
PreferencesModal,
|
|
19
19
|
PreferencesModalTabs,
|
|
20
20
|
PreferencesModalSection,
|
|
21
|
+
store as interfaceStore,
|
|
21
22
|
} from '@wordpress/interface';
|
|
22
23
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
23
24
|
|
|
@@ -35,17 +36,18 @@ import MetaBoxesSection from './meta-boxes-section';
|
|
|
35
36
|
import { store as editPostStore } from '../../store';
|
|
36
37
|
import BlockManager from '../block-manager';
|
|
37
38
|
|
|
38
|
-
const
|
|
39
|
+
export const PREFERENCES_MODAL_NAME = 'edit-post/preferences';
|
|
39
40
|
|
|
40
41
|
export default function EditPostPreferencesModal() {
|
|
41
42
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
42
|
-
const { closeModal } = useDispatch(
|
|
43
|
+
const { closeModal } = useDispatch( interfaceStore );
|
|
43
44
|
const [ isModalActive, showBlockBreadcrumbsOption ] = useSelect(
|
|
44
45
|
( select ) => {
|
|
45
46
|
const { getEditorSettings } = select( editorStore );
|
|
46
47
|
const { getEditorMode, isFeatureActive } = select( editPostStore );
|
|
47
|
-
const modalActive =
|
|
48
|
-
|
|
48
|
+
const modalActive = select( interfaceStore ).isModalActive(
|
|
49
|
+
PREFERENCES_MODAL_NAME
|
|
50
|
+
);
|
|
49
51
|
const mode = getEditorMode();
|
|
50
52
|
const isRichEditingEnabled = getEditorSettings().richEditingEnabled;
|
|
51
53
|
const isDistractionFreeEnabled =
|
|
@@ -590,6 +590,8 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
|
|
|
590
590
|
}
|
|
591
591
|
|
|
592
592
|
.emotion-13 {
|
|
593
|
+
font-size: 13px;
|
|
594
|
+
font-family: inherit;
|
|
593
595
|
-webkit-appearance: none;
|
|
594
596
|
-moz-appearance: none;
|
|
595
597
|
-ms-appearance: none;
|
|
@@ -617,11 +619,17 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
|
|
|
617
619
|
}
|
|
618
620
|
|
|
619
621
|
.emotion-13:focus {
|
|
622
|
+
box-shadow: none;
|
|
623
|
+
outline: none;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
.emotion-13:focus-visible {
|
|
620
627
|
box-shadow: 0 0 0 var( --wp-admin-border-width-focus ) var(
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
628
|
+
--wp-components-color-accent,
|
|
629
|
+
var( --wp-admin-theme-color, var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9)) )
|
|
630
|
+
);
|
|
624
631
|
outline: 2px solid transparent;
|
|
632
|
+
outline-offset: 0;
|
|
625
633
|
}
|
|
626
634
|
|
|
627
635
|
.emotion-15 {
|
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { PostTrash as PostTrashLink, PostTrashCheck } from '@wordpress/editor';
|
|
5
|
-
import { FlexItem } from '@wordpress/components';
|
|
6
5
|
|
|
7
6
|
export default function PostTrash() {
|
|
8
7
|
return (
|
|
9
8
|
<PostTrashCheck>
|
|
10
|
-
<
|
|
11
|
-
<PostTrashLink />
|
|
12
|
-
</FlexItem>
|
|
9
|
+
<PostTrashLink />
|
|
13
10
|
</PostTrashCheck>
|
|
14
11
|
);
|
|
15
12
|
}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import {
|
|
5
5
|
PostTextEditor,
|
|
6
6
|
PostTitle,
|
|
7
|
-
TextEditorGlobalKeyboardShortcuts,
|
|
8
7
|
store as editorStore,
|
|
9
8
|
} from '@wordpress/editor';
|
|
10
9
|
import { Button } from '@wordpress/components';
|
|
@@ -25,7 +24,6 @@ export default function TextEditor() {
|
|
|
25
24
|
|
|
26
25
|
return (
|
|
27
26
|
<div className="edit-post-text-editor">
|
|
28
|
-
<TextEditorGlobalKeyboardShortcuts />
|
|
29
27
|
{ isRichEditingEnabled && (
|
|
30
28
|
<div className="edit-post-text-editor__toolbar">
|
|
31
29
|
<h2>{ __( 'Editing code' ) }</h2>
|
|
@@ -16,23 +16,9 @@ import {
|
|
|
16
16
|
useEditorWrapperStyles,
|
|
17
17
|
} from '@wordpress/block-editor';
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* Internal dependencies
|
|
21
|
-
*/
|
|
22
|
-
import styles from './style.scss';
|
|
23
|
-
|
|
24
19
|
const Header = memo(
|
|
25
|
-
function EditorHeader( {
|
|
26
|
-
editTitle,
|
|
27
|
-
setTitleRef,
|
|
28
|
-
title,
|
|
29
|
-
getStylesFromColorScheme,
|
|
30
|
-
} ) {
|
|
20
|
+
function EditorHeader( { editTitle, setTitleRef, title } ) {
|
|
31
21
|
const [ wrapperStyles ] = useEditorWrapperStyles();
|
|
32
|
-
const blockHolderFocusedStyle = getStylesFromColorScheme(
|
|
33
|
-
styles.blockHolderFocused,
|
|
34
|
-
styles.blockHolderFocusedDark
|
|
35
|
-
);
|
|
36
22
|
return (
|
|
37
23
|
<View style={ wrapperStyles }>
|
|
38
24
|
<PostTitle
|
|
@@ -40,8 +26,6 @@ const Header = memo(
|
|
|
40
26
|
title={ title }
|
|
41
27
|
onUpdate={ editTitle }
|
|
42
28
|
placeholder={ __( 'Add title' ) }
|
|
43
|
-
borderStyle={ styles.blockHolderFullBordered }
|
|
44
|
-
focusedBorderColor={ blockHolderFocusedStyle.borderColor }
|
|
45
29
|
accessibilityLabel="post-title"
|
|
46
30
|
/>
|
|
47
31
|
</View>
|
|
@@ -6,11 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
VisualEditorGlobalKeyboardShortcuts,
|
|
11
|
-
PostTitle,
|
|
12
|
-
store as editorStore,
|
|
13
|
-
} from '@wordpress/editor';
|
|
9
|
+
import { PostTitle, store as editorStore } from '@wordpress/editor';
|
|
14
10
|
import {
|
|
15
11
|
WritingFlow,
|
|
16
12
|
BlockList,
|
|
@@ -345,7 +341,6 @@ export default function VisualEditor( { styles } ) {
|
|
|
345
341
|
'is-template-mode': isTemplateMode,
|
|
346
342
|
} ) }
|
|
347
343
|
>
|
|
348
|
-
<VisualEditorGlobalKeyboardShortcuts />
|
|
349
344
|
<motion.div
|
|
350
345
|
className="edit-post-visual-editor__content-area"
|
|
351
346
|
animate={ {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`when nothing is selected media buttons and picker display correctly 1`] = `
|
|
4
|
+
"<!-- wp:paragraph -->
|
|
5
|
+
<p>First example paragraph.</p>
|
|
6
|
+
<!-- /wp:paragraph -->
|
|
7
|
+
|
|
8
|
+
<!-- wp:paragraph -->
|
|
9
|
+
<p>Second example paragraph.</p>
|
|
10
|
+
<!-- /wp:paragraph -->
|
|
11
|
+
|
|
12
|
+
<!-- wp:gallery {"linkTo":"none"} -->
|
|
13
|
+
<figure class="wp-block-gallery has-nested-images columns-default is-cropped"></figure>
|
|
14
|
+
<!-- /wp:gallery -->"
|
|
15
|
+
`;
|
|
@@ -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/editor.js
CHANGED
|
@@ -25,6 +25,7 @@ import Layout from './components/layout';
|
|
|
25
25
|
import EditorInitialization from './components/editor-initialization';
|
|
26
26
|
import { store as editPostStore } from './store';
|
|
27
27
|
import { unlock } from './lock-unlock';
|
|
28
|
+
import useCommonCommands from './hooks/commands/use-common-commands';
|
|
28
29
|
|
|
29
30
|
const { ExperimentalEditorProvider } = unlock( editorPrivateApis );
|
|
30
31
|
const { getLayoutStyles } = unlock( blockEditorPrivateApis );
|
|
@@ -32,6 +33,7 @@ const { useCommands } = unlock( coreCommandsPrivateApis );
|
|
|
32
33
|
|
|
33
34
|
function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
34
35
|
useCommands();
|
|
36
|
+
useCommonCommands();
|
|
35
37
|
const {
|
|
36
38
|
hasFixedToolbar,
|
|
37
39
|
focusMode,
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import { __, isRTL } from '@wordpress/i18n';
|
|
6
|
+
import {
|
|
7
|
+
code,
|
|
8
|
+
cog,
|
|
9
|
+
drawerLeft,
|
|
10
|
+
drawerRight,
|
|
11
|
+
blockDefault,
|
|
12
|
+
keyboardClose,
|
|
13
|
+
desktop,
|
|
14
|
+
listView,
|
|
15
|
+
} from '@wordpress/icons';
|
|
16
|
+
import { useCommand } from '@wordpress/commands';
|
|
17
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
18
|
+
import { store as interfaceStore } from '@wordpress/interface';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Internal dependencies
|
|
22
|
+
*/
|
|
23
|
+
import { KEYBOARD_SHORTCUT_HELP_MODAL_NAME } from '../../components/keyboard-shortcut-help-modal';
|
|
24
|
+
import { PREFERENCES_MODAL_NAME } from '../../components/preferences-modal';
|
|
25
|
+
import { store as editPostStore } from '../../store';
|
|
26
|
+
|
|
27
|
+
export default function useCommonCommands() {
|
|
28
|
+
const {
|
|
29
|
+
openGeneralSidebar,
|
|
30
|
+
closeGeneralSidebar,
|
|
31
|
+
switchEditorMode,
|
|
32
|
+
setIsListViewOpened,
|
|
33
|
+
} = useDispatch( editPostStore );
|
|
34
|
+
const { openModal } = useDispatch( interfaceStore );
|
|
35
|
+
const { editorMode, activeSidebar, isListViewOpen } = useSelect(
|
|
36
|
+
( select ) => {
|
|
37
|
+
const { getEditorMode, isListViewOpened } = select( editPostStore );
|
|
38
|
+
return {
|
|
39
|
+
activeSidebar: select(
|
|
40
|
+
interfaceStore
|
|
41
|
+
).getActiveComplementaryArea( editPostStore.name ),
|
|
42
|
+
editorMode: getEditorMode(),
|
|
43
|
+
isListViewOpen: isListViewOpened(),
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
[]
|
|
47
|
+
);
|
|
48
|
+
const { toggle } = useDispatch( preferencesStore );
|
|
49
|
+
|
|
50
|
+
useCommand( {
|
|
51
|
+
name: 'core/open-settings-sidebar',
|
|
52
|
+
label: __( 'Toggle settings sidebar' ),
|
|
53
|
+
icon: isRTL() ? drawerLeft : drawerRight,
|
|
54
|
+
callback: ( { close } ) => {
|
|
55
|
+
close();
|
|
56
|
+
if ( activeSidebar === 'edit-post/document' ) {
|
|
57
|
+
closeGeneralSidebar();
|
|
58
|
+
} else {
|
|
59
|
+
openGeneralSidebar( 'edit-post/document' );
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
} );
|
|
63
|
+
|
|
64
|
+
useCommand( {
|
|
65
|
+
name: 'core/open-block-inspector',
|
|
66
|
+
label: __( 'Toggle block inspector' ),
|
|
67
|
+
icon: blockDefault,
|
|
68
|
+
callback: ( { close } ) => {
|
|
69
|
+
close();
|
|
70
|
+
if ( activeSidebar === 'edit-post/block' ) {
|
|
71
|
+
closeGeneralSidebar();
|
|
72
|
+
} else {
|
|
73
|
+
openGeneralSidebar( 'edit-post/block' );
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
} );
|
|
77
|
+
|
|
78
|
+
useCommand( {
|
|
79
|
+
name: 'core/toggle-distraction-free',
|
|
80
|
+
label: __( 'Toggle distraction free' ),
|
|
81
|
+
icon: cog,
|
|
82
|
+
callback: ( { close } ) => {
|
|
83
|
+
toggle( 'core/edit-post', 'distractionFree' );
|
|
84
|
+
close();
|
|
85
|
+
},
|
|
86
|
+
} );
|
|
87
|
+
|
|
88
|
+
useCommand( {
|
|
89
|
+
name: 'core/toggle-spotlight-mode',
|
|
90
|
+
label: __( 'Toggle spotlight mode' ),
|
|
91
|
+
icon: cog,
|
|
92
|
+
callback: ( { close } ) => {
|
|
93
|
+
toggle( 'core/edit-post', 'focusMode' );
|
|
94
|
+
close();
|
|
95
|
+
},
|
|
96
|
+
} );
|
|
97
|
+
|
|
98
|
+
useCommand( {
|
|
99
|
+
name: 'core/toggle-fullscreen-mode',
|
|
100
|
+
label: __( 'Toggle fullscreen mode' ),
|
|
101
|
+
icon: desktop,
|
|
102
|
+
callback: ( { close } ) => {
|
|
103
|
+
toggle( 'core/edit-post', 'fullscreenMode' );
|
|
104
|
+
close();
|
|
105
|
+
},
|
|
106
|
+
} );
|
|
107
|
+
|
|
108
|
+
useCommand( {
|
|
109
|
+
name: 'core/toggle-list-view',
|
|
110
|
+
label: __( 'Toggle list view' ),
|
|
111
|
+
icon: listView,
|
|
112
|
+
callback: ( { close } ) => {
|
|
113
|
+
setIsListViewOpened( ! isListViewOpen );
|
|
114
|
+
close();
|
|
115
|
+
},
|
|
116
|
+
} );
|
|
117
|
+
|
|
118
|
+
useCommand( {
|
|
119
|
+
name: 'core/toggle-top-toolbar',
|
|
120
|
+
label: __( 'Toggle top toolbar' ),
|
|
121
|
+
icon: cog,
|
|
122
|
+
callback: ( { close } ) => {
|
|
123
|
+
toggle( 'core/edit-post', 'fixedToolbar' );
|
|
124
|
+
close();
|
|
125
|
+
},
|
|
126
|
+
} );
|
|
127
|
+
|
|
128
|
+
useCommand( {
|
|
129
|
+
name: 'core/toggle-code-editor',
|
|
130
|
+
label: __( 'Toggle code editor' ),
|
|
131
|
+
icon: code,
|
|
132
|
+
callback: ( { close } ) => {
|
|
133
|
+
switchEditorMode( editorMode === 'visual' ? 'text' : 'visual' );
|
|
134
|
+
close();
|
|
135
|
+
},
|
|
136
|
+
} );
|
|
137
|
+
|
|
138
|
+
useCommand( {
|
|
139
|
+
name: 'core/open-preferences',
|
|
140
|
+
label: __( 'Open editor preferences' ),
|
|
141
|
+
icon: cog,
|
|
142
|
+
callback: () => {
|
|
143
|
+
openModal( PREFERENCES_MODAL_NAME );
|
|
144
|
+
},
|
|
145
|
+
} );
|
|
146
|
+
|
|
147
|
+
useCommand( {
|
|
148
|
+
name: 'core/open-shortcut-help',
|
|
149
|
+
label: __( 'Open keyboard shortcuts' ),
|
|
150
|
+
icon: keyboardClose,
|
|
151
|
+
callback: () => {
|
|
152
|
+
openModal( KEYBOARD_SHORTCUT_HELP_MODAL_NAME );
|
|
153
|
+
},
|
|
154
|
+
} );
|
|
155
|
+
}
|
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
|
/>
|