@wordpress/edit-post 7.14.0 → 7.16.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/{document-title → document-actions}/index.js +10 -11
- package/build/components/header/document-actions/index.js.map +1 -0
- 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 +92 -49
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/index.js +4 -9
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js +23 -4
- package/build/components/header/mode-switcher/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 +36 -13
- package/build/components/layout/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +2 -2
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/discussion-panel/index.js +20 -20
- package/build/components/sidebar/discussion-panel/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 +2 -39
- package/build/editor.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +61 -4
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/index.js +2 -1
- package/build/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/{document-title → document-actions}/index.js +10 -11
- package/build-module/components/header/document-actions/index.js.map +1 -0
- 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 +93 -53
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/index.js +4 -9
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/mode-switcher/index.js +23 -4
- package/build-module/components/header/mode-switcher/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 +37 -14
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +3 -3
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/discussion-panel/index.js +21 -19
- package/build-module/components/sidebar/discussion-panel/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 -38
- package/build-module/editor.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +60 -5
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/index.js +2 -1
- package/build-module/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 +30 -31
- package/build-style/style.css +30 -31
- package/package.json +32 -32
- package/src/components/device-preview/index.js +35 -39
- package/src/components/header/{document-title → document-actions}/index.js +22 -23
- package/src/components/header/{document-title → document-actions}/style.scss +25 -22
- package/src/components/header/header-toolbar/index.js +3 -2
- package/src/components/header/header-toolbar/index.native.js +125 -68
- package/src/components/header/header-toolbar/style.native.scss +23 -4
- package/src/components/header/header-toolbar/style.scss +4 -0
- package/src/components/header/index.js +15 -25
- package/src/components/header/mode-switcher/index.js +23 -4
- package/src/components/header/post-publish-button-or-toggle.js +0 -2
- package/src/components/header/style.scss +1 -1
- package/src/components/layout/actions-panel.js +5 -7
- package/src/components/layout/index.js +45 -9
- package/src/components/layout/style.native.scss +1 -1
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +16 -5
- package/src/components/preferences-modal/test/index.js +4 -4
- package/src/components/secondary-sidebar/list-view-sidebar.js +3 -3
- package/src/components/sidebar/discussion-panel/index.js +15 -20
- 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 -47
- package/src/hooks/commands/use-common-commands.js +81 -15
- package/src/index.js +5 -1
- package/src/plugins/index.js +32 -8
- package/src/store/actions.js +18 -27
- package/src/style.scss +2 -8
- package/src/test/editor.native.js +4 -3
- package/build/components/header/document-title/index.js.map +0 -1
- package/build-module/components/header/document-title/index.js.map +0 -1
- package/src/components/visual-editor/style.native.scss +0 -18
|
@@ -55,12 +55,31 @@ function ModeSwitcher() {
|
|
|
55
55
|
return null;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
let selectedMode = mode;
|
|
59
|
+
if ( ! isRichEditingEnabled && mode === 'visual' ) {
|
|
60
|
+
selectedMode = 'text';
|
|
61
|
+
}
|
|
62
|
+
if ( ! isCodeEditingEnabled && mode === 'text' ) {
|
|
63
|
+
selectedMode = 'visual';
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
const choices = MODES.map( ( choice ) => {
|
|
63
|
-
if ( choice.value
|
|
67
|
+
if ( ! isCodeEditingEnabled && choice.value === 'text' ) {
|
|
68
|
+
choice = {
|
|
69
|
+
...choice,
|
|
70
|
+
disabled: true,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if ( ! isRichEditingEnabled && choice.value === 'visual' ) {
|
|
74
|
+
choice = {
|
|
75
|
+
...choice,
|
|
76
|
+
disabled: true,
|
|
77
|
+
info: __(
|
|
78
|
+
'You can enable the visual editor in your profile settings.'
|
|
79
|
+
),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if ( choice.value !== selectedMode && ! choice.disabled ) {
|
|
64
83
|
return { ...choice, shortcut };
|
|
65
84
|
}
|
|
66
85
|
return choice;
|
|
@@ -70,7 +89,7 @@ function ModeSwitcher() {
|
|
|
70
89
|
<MenuGroup label={ __( 'Editor' ) }>
|
|
71
90
|
<MenuItemsChoice
|
|
72
91
|
choices={ choices }
|
|
73
|
-
value={
|
|
92
|
+
value={ selectedMode }
|
|
74
93
|
onSelect={ switchEditorMode }
|
|
75
94
|
/>
|
|
76
95
|
</MenuGroup>
|
|
@@ -12,7 +12,6 @@ import { store as editPostStore } from '../../store';
|
|
|
12
12
|
|
|
13
13
|
export function PostPublishButtonOrToggle( {
|
|
14
14
|
forceIsDirty,
|
|
15
|
-
forceIsSaving,
|
|
16
15
|
hasPublishAction,
|
|
17
16
|
isBeingScheduled,
|
|
18
17
|
isPending,
|
|
@@ -67,7 +66,6 @@ export function PostPublishButtonOrToggle( {
|
|
|
67
66
|
return (
|
|
68
67
|
<PostPublishButton
|
|
69
68
|
forceIsDirty={ forceIsDirty }
|
|
70
|
-
forceIsSaving={ forceIsSaving }
|
|
71
69
|
isOpen={ isPublishSidebarOpened }
|
|
72
70
|
isToggle={ component === IS_TOGGLE }
|
|
73
71
|
onToggle={ togglePublishSidebar }
|
|
@@ -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';
|
|
@@ -54,7 +56,7 @@ import StartPageOptions from '../start-page-options';
|
|
|
54
56
|
import { store as editPostStore } from '../../store';
|
|
55
57
|
import { unlock } from '../../lock-unlock';
|
|
56
58
|
|
|
57
|
-
const {
|
|
59
|
+
const { getLayoutStyles } = unlock( blockEditorPrivateApis );
|
|
58
60
|
|
|
59
61
|
const interfaceLabels = {
|
|
60
62
|
/* translators: accessibility text for the editor top bar landmark region. */
|
|
@@ -69,13 +71,7 @@ const interfaceLabels = {
|
|
|
69
71
|
footer: __( 'Editor footer' ),
|
|
70
72
|
};
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
'core/footnotes': __(
|
|
74
|
-
'The Footnotes block displays all footnotes found in the content. Note that any footnotes in the content will persist after removing this block.'
|
|
75
|
-
),
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
function Layout( { styles } ) {
|
|
74
|
+
function Layout() {
|
|
79
75
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
80
76
|
const isHugeViewport = useViewportMatch( 'huge', '>=' );
|
|
81
77
|
const isLargeViewport = useViewportMatch( 'large' );
|
|
@@ -99,10 +95,45 @@ function Layout( { styles } ) {
|
|
|
99
95
|
showBlockBreadcrumbs,
|
|
100
96
|
isTemplateMode,
|
|
101
97
|
documentLabel,
|
|
98
|
+
styles,
|
|
102
99
|
} = useSelect( ( select ) => {
|
|
103
100
|
const { getEditorSettings, getPostTypeLabel } = select( editorStore );
|
|
101
|
+
const { isFeatureActive } = select( editPostStore );
|
|
104
102
|
const editorSettings = getEditorSettings();
|
|
105
103
|
const postTypeLabel = getPostTypeLabel();
|
|
104
|
+
const hasThemeStyles = isFeatureActive( 'themeStyles' );
|
|
105
|
+
|
|
106
|
+
const themeStyles = [];
|
|
107
|
+
const presetStyles = [];
|
|
108
|
+
editorSettings.styles?.forEach( ( style ) => {
|
|
109
|
+
if ( ! style.__unstableType || style.__unstableType === 'theme' ) {
|
|
110
|
+
themeStyles.push( style );
|
|
111
|
+
} else {
|
|
112
|
+
presetStyles.push( style );
|
|
113
|
+
}
|
|
114
|
+
} );
|
|
115
|
+
|
|
116
|
+
const defaultEditorStyles = [
|
|
117
|
+
...editorSettings.defaultEditorStyles,
|
|
118
|
+
...presetStyles,
|
|
119
|
+
];
|
|
120
|
+
|
|
121
|
+
// If theme styles are not present or displayed, ensure that
|
|
122
|
+
// base layout styles are still present in the editor.
|
|
123
|
+
if (
|
|
124
|
+
! editorSettings.disableLayoutStyles &&
|
|
125
|
+
! ( hasThemeStyles && themeStyles.length )
|
|
126
|
+
) {
|
|
127
|
+
defaultEditorStyles.push( {
|
|
128
|
+
css: getLayoutStyles( {
|
|
129
|
+
style: {},
|
|
130
|
+
selector: 'body',
|
|
131
|
+
hasBlockGapSupport: false,
|
|
132
|
+
hasFallbackGapSupport: true,
|
|
133
|
+
fallbackGapValue: '0.5em',
|
|
134
|
+
} ),
|
|
135
|
+
} );
|
|
136
|
+
}
|
|
106
137
|
|
|
107
138
|
return {
|
|
108
139
|
isTemplateMode: select( editPostStore ).isEditingTemplate(),
|
|
@@ -135,6 +166,10 @@ function Layout( { styles } ) {
|
|
|
135
166
|
),
|
|
136
167
|
// translators: Default label for the Document in the Block Breadcrumb.
|
|
137
168
|
documentLabel: postTypeLabel || _x( 'Document', 'noun' ),
|
|
169
|
+
styles:
|
|
170
|
+
hasThemeStyles && themeStyles.length
|
|
171
|
+
? editorSettings.styles
|
|
172
|
+
: defaultEditorStyles,
|
|
138
173
|
};
|
|
139
174
|
}, [] );
|
|
140
175
|
|
|
@@ -214,7 +249,7 @@ function Layout( { styles } ) {
|
|
|
214
249
|
<LocalAutosaveMonitor />
|
|
215
250
|
<EditPostKeyboardShortcuts />
|
|
216
251
|
<EditorKeyboardShortcutsRegister />
|
|
217
|
-
<
|
|
252
|
+
<EditorKeyboardShortcuts />
|
|
218
253
|
<SettingsSidebar />
|
|
219
254
|
<InterfaceSkeleton
|
|
220
255
|
isDistractionFree={ isDistractionFree && isLargeViewport }
|
|
@@ -304,6 +339,7 @@ function Layout( { styles } ) {
|
|
|
304
339
|
<EditPostPreferencesModal />
|
|
305
340
|
<KeyboardShortcutHelpModal />
|
|
306
341
|
<WelcomeGuide />
|
|
342
|
+
<PostSyncStatusModal />
|
|
307
343
|
<StartPageOptions />
|
|
308
344
|
<Popover.Slot />
|
|
309
345
|
<PluginArea onError={ onPluginAreaError } />
|
|
@@ -115,6 +115,8 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
|
|
|
115
115
|
aria-controls="tab-panel-0-general-view"
|
|
116
116
|
aria-selected="true"
|
|
117
117
|
class="components-button components-tab-panel__tabs-item is-active"
|
|
118
|
+
data-active-item=""
|
|
119
|
+
data-command=""
|
|
118
120
|
id="tab-panel-0-general"
|
|
119
121
|
role="tab"
|
|
120
122
|
type="button"
|
|
@@ -125,9 +127,9 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
|
|
|
125
127
|
aria-controls="tab-panel-0-blocks-view"
|
|
126
128
|
aria-selected="false"
|
|
127
129
|
class="components-button components-tab-panel__tabs-item"
|
|
130
|
+
data-command=""
|
|
128
131
|
id="tab-panel-0-blocks"
|
|
129
132
|
role="tab"
|
|
130
|
-
tabindex="-1"
|
|
131
133
|
type="button"
|
|
132
134
|
>
|
|
133
135
|
Blocks
|
|
@@ -136,9 +138,9 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
|
|
|
136
138
|
aria-controls="tab-panel-0-panels-view"
|
|
137
139
|
aria-selected="false"
|
|
138
140
|
class="components-button components-tab-panel__tabs-item"
|
|
141
|
+
data-command=""
|
|
139
142
|
id="tab-panel-0-panels"
|
|
140
143
|
role="tab"
|
|
141
|
-
tabindex="-1"
|
|
142
144
|
type="button"
|
|
143
145
|
>
|
|
144
146
|
Panels
|
|
@@ -149,6 +151,7 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
|
|
|
149
151
|
class="components-tab-panel__tab-content"
|
|
150
152
|
id="tab-panel-0-general-view"
|
|
151
153
|
role="tabpanel"
|
|
154
|
+
tabindex="0"
|
|
152
155
|
>
|
|
153
156
|
<fieldset
|
|
154
157
|
class="interface-preferences-modal__section"
|
|
@@ -590,6 +593,8 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
|
|
|
590
593
|
}
|
|
591
594
|
|
|
592
595
|
.emotion-13 {
|
|
596
|
+
font-size: 13px;
|
|
597
|
+
font-family: inherit;
|
|
593
598
|
-webkit-appearance: none;
|
|
594
599
|
-moz-appearance: none;
|
|
595
600
|
-ms-appearance: none;
|
|
@@ -616,12 +621,18 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
|
|
|
616
621
|
color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
|
|
617
622
|
}
|
|
618
623
|
|
|
624
|
+
.emotion-13:focus {
|
|
625
|
+
box-shadow: none;
|
|
626
|
+
outline: none;
|
|
627
|
+
}
|
|
628
|
+
|
|
619
629
|
.emotion-13:focus-visible {
|
|
620
630
|
box-shadow: 0 0 0 var( --wp-admin-border-width-focus ) var(
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
631
|
+
--wp-components-color-accent,
|
|
632
|
+
var( --wp-admin-theme-color, var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9)) )
|
|
633
|
+
);
|
|
624
634
|
outline: 2px solid transparent;
|
|
635
|
+
outline-offset: 0;
|
|
625
636
|
}
|
|
626
637
|
|
|
627
638
|
.emotion-15 {
|
|
@@ -20,20 +20,20 @@ jest.mock( '@wordpress/compose/src/hooks/use-viewport-match', () => jest.fn() );
|
|
|
20
20
|
|
|
21
21
|
describe( 'EditPostPreferencesModal', () => {
|
|
22
22
|
describe( 'should match snapshot when the modal is active', () => {
|
|
23
|
-
it( 'large viewports', () => {
|
|
23
|
+
it( 'large viewports', async () => {
|
|
24
24
|
useSelect.mockImplementation( () => [ true, true, false ] );
|
|
25
25
|
useViewportMatch.mockImplementation( () => true );
|
|
26
26
|
render( <EditPostPreferencesModal /> );
|
|
27
27
|
expect(
|
|
28
|
-
screen.
|
|
28
|
+
await screen.findByRole( 'dialog', { name: 'Preferences' } )
|
|
29
29
|
).toMatchSnapshot();
|
|
30
30
|
} );
|
|
31
|
-
it( 'small viewports', () => {
|
|
31
|
+
it( 'small viewports', async () => {
|
|
32
32
|
useSelect.mockImplementation( () => [ true, true, false ] );
|
|
33
33
|
useViewportMatch.mockImplementation( () => false );
|
|
34
34
|
render( <EditPostPreferencesModal /> );
|
|
35
35
|
expect(
|
|
36
|
-
screen.
|
|
36
|
+
await screen.findByRole( 'dialog', { name: 'Preferences' } )
|
|
37
37
|
).toMatchSnapshot();
|
|
38
38
|
} );
|
|
39
39
|
} );
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import { useDispatch } from '@wordpress/data';
|
|
12
12
|
import { focus } from '@wordpress/dom';
|
|
13
13
|
import { useRef, useState } from '@wordpress/element';
|
|
14
|
-
import { __ } from '@wordpress/i18n';
|
|
14
|
+
import { __, _x } from '@wordpress/i18n';
|
|
15
15
|
import { closeSmall } from '@wordpress/icons';
|
|
16
16
|
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
17
17
|
import { ESCAPE } from '@wordpress/keycodes';
|
|
@@ -140,12 +140,12 @@ export default function ListViewSidebar() {
|
|
|
140
140
|
tabs={ [
|
|
141
141
|
{
|
|
142
142
|
name: 'list-view',
|
|
143
|
-
title: 'List View',
|
|
143
|
+
title: _x( 'List View', 'Post overview' ),
|
|
144
144
|
className: 'edit-post-sidebar__panel-tab',
|
|
145
145
|
},
|
|
146
146
|
{
|
|
147
147
|
name: 'outline',
|
|
148
|
-
title: 'Outline',
|
|
148
|
+
title: _x( 'Outline', 'Post overview' ),
|
|
149
149
|
className: 'edit-post-sidebar__panel-tab',
|
|
150
150
|
},
|
|
151
151
|
] }
|
|
@@ -8,8 +8,7 @@ import {
|
|
|
8
8
|
PostPingbacks,
|
|
9
9
|
PostTypeSupportCheck,
|
|
10
10
|
} from '@wordpress/editor';
|
|
11
|
-
import {
|
|
12
|
-
import { withSelect, withDispatch } from '@wordpress/data';
|
|
11
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Internal dependencies
|
|
@@ -21,7 +20,18 @@ import { store as editPostStore } from '../../../store';
|
|
|
21
20
|
*/
|
|
22
21
|
const PANEL_NAME = 'discussion-panel';
|
|
23
22
|
|
|
24
|
-
function DiscussionPanel(
|
|
23
|
+
function DiscussionPanel() {
|
|
24
|
+
const { isEnabled, isOpened } = useSelect( ( select ) => {
|
|
25
|
+
const { isEditorPanelEnabled, isEditorPanelOpened } =
|
|
26
|
+
select( editPostStore );
|
|
27
|
+
return {
|
|
28
|
+
isEnabled: isEditorPanelEnabled( PANEL_NAME ),
|
|
29
|
+
isOpened: isEditorPanelOpened( PANEL_NAME ),
|
|
30
|
+
};
|
|
31
|
+
}, [] );
|
|
32
|
+
|
|
33
|
+
const { toggleEditorPanelOpened } = useDispatch( editPostStore );
|
|
34
|
+
|
|
25
35
|
if ( ! isEnabled ) {
|
|
26
36
|
return null;
|
|
27
37
|
}
|
|
@@ -31,7 +41,7 @@ function DiscussionPanel( { isEnabled, isOpened, onTogglePanel } ) {
|
|
|
31
41
|
<PanelBody
|
|
32
42
|
title={ __( 'Discussion' ) }
|
|
33
43
|
opened={ isOpened }
|
|
34
|
-
onToggle={
|
|
44
|
+
onToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) }
|
|
35
45
|
>
|
|
36
46
|
<PostTypeSupportCheck supportKeys="comments">
|
|
37
47
|
<PanelRow>
|
|
@@ -49,19 +59,4 @@ function DiscussionPanel( { isEnabled, isOpened, onTogglePanel } ) {
|
|
|
49
59
|
);
|
|
50
60
|
}
|
|
51
61
|
|
|
52
|
-
export default
|
|
53
|
-
withSelect( ( select ) => {
|
|
54
|
-
return {
|
|
55
|
-
isEnabled:
|
|
56
|
-
select( editPostStore ).isEditorPanelEnabled( PANEL_NAME ),
|
|
57
|
-
isOpened: select( editPostStore ).isEditorPanelOpened( PANEL_NAME ),
|
|
58
|
-
};
|
|
59
|
-
} ),
|
|
60
|
-
withDispatch( ( dispatch ) => ( {
|
|
61
|
-
onTogglePanel() {
|
|
62
|
-
return dispatch( editPostStore ).toggleEditorPanelOpened(
|
|
63
|
-
PANEL_NAME
|
|
64
|
-
);
|
|
65
|
-
},
|
|
66
|
-
} ) ),
|
|
67
|
-
] )( DiscussionPanel );
|
|
62
|
+
export default DiscussionPanel;
|
|
@@ -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
|
} );
|