@wordpress/edit-post 7.15.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 +2 -0
- 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.native.js +2 -1
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/index.js +3 -3
- 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/layout/index.js +38 -5
- 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/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-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.native.js +2 -1
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/index.js +3 -3
- 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/layout/index.js +38 -6
- 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/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-style/style-rtl.css +21 -18
- package/build-style/style.css +21 -18
- package/package.json +32 -32
- 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.native.js +1 -0
- package/src/components/header/header-toolbar/style.scss +4 -0
- package/src/components/header/index.js +3 -3
- package/src/components/header/mode-switcher/index.js +23 -4
- package/src/components/header/style.scss +1 -1
- package/src/components/layout/index.js +47 -2
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +5 -2
- 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/editor.js +2 -47
- package/src/hooks/commands/use-common-commands.js +81 -15
- package/src/index.js +5 -1
- package/src/style.scss +1 -1
- 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
|
@@ -82,6 +82,10 @@
|
|
|
82
82
|
align-items: center;
|
|
83
83
|
padding-left: $grid-unit-10;
|
|
84
84
|
|
|
85
|
+
// Some plugins add buttons here despite best practices.
|
|
86
|
+
// Push them a bit rightwards to fit the top toolbar.
|
|
87
|
+
margin-right: $grid-unit-10;
|
|
88
|
+
|
|
85
89
|
@include break-small() {
|
|
86
90
|
padding-left: $grid-unit-30;
|
|
87
91
|
}
|
|
@@ -18,7 +18,7 @@ import { default as DevicePreview } from '../device-preview';
|
|
|
18
18
|
import ViewLink from '../view-link';
|
|
19
19
|
import MainDashboardButton from './main-dashboard-button';
|
|
20
20
|
import { store as editPostStore } from '../../store';
|
|
21
|
-
import
|
|
21
|
+
import DocumentActions from './document-actions';
|
|
22
22
|
|
|
23
23
|
const slideY = {
|
|
24
24
|
hidden: { y: '-50px' },
|
|
@@ -60,8 +60,8 @@ function Header( { setEntitiesSavedStatesCallback } ) {
|
|
|
60
60
|
className="edit-post-header__toolbar"
|
|
61
61
|
>
|
|
62
62
|
<HeaderToolbar />
|
|
63
|
-
<div className="edit-post-
|
|
64
|
-
<
|
|
63
|
+
<div className="edit-post-header__center">
|
|
64
|
+
<DocumentActions />
|
|
65
65
|
</div>
|
|
66
66
|
</motion.div>
|
|
67
67
|
<motion.div
|
|
@@ -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>
|
|
@@ -18,7 +18,10 @@ import {
|
|
|
18
18
|
store as editorStore,
|
|
19
19
|
} from '@wordpress/editor';
|
|
20
20
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
BlockBreadcrumb,
|
|
23
|
+
privateApis as blockEditorPrivateApis,
|
|
24
|
+
} from '@wordpress/block-editor';
|
|
22
25
|
import { Button, ScrollLock, Popover } from '@wordpress/components';
|
|
23
26
|
import { useViewportMatch } from '@wordpress/compose';
|
|
24
27
|
import { PluginArea } from '@wordpress/plugins';
|
|
@@ -51,6 +54,9 @@ import WelcomeGuide from '../welcome-guide';
|
|
|
51
54
|
import ActionsPanel from './actions-panel';
|
|
52
55
|
import StartPageOptions from '../start-page-options';
|
|
53
56
|
import { store as editPostStore } from '../../store';
|
|
57
|
+
import { unlock } from '../../lock-unlock';
|
|
58
|
+
|
|
59
|
+
const { getLayoutStyles } = unlock( blockEditorPrivateApis );
|
|
54
60
|
|
|
55
61
|
const interfaceLabels = {
|
|
56
62
|
/* translators: accessibility text for the editor top bar landmark region. */
|
|
@@ -65,7 +71,7 @@ const interfaceLabels = {
|
|
|
65
71
|
footer: __( 'Editor footer' ),
|
|
66
72
|
};
|
|
67
73
|
|
|
68
|
-
function Layout(
|
|
74
|
+
function Layout() {
|
|
69
75
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
70
76
|
const isHugeViewport = useViewportMatch( 'huge', '>=' );
|
|
71
77
|
const isLargeViewport = useViewportMatch( 'large' );
|
|
@@ -89,10 +95,45 @@ function Layout( { styles } ) {
|
|
|
89
95
|
showBlockBreadcrumbs,
|
|
90
96
|
isTemplateMode,
|
|
91
97
|
documentLabel,
|
|
98
|
+
styles,
|
|
92
99
|
} = useSelect( ( select ) => {
|
|
93
100
|
const { getEditorSettings, getPostTypeLabel } = select( editorStore );
|
|
101
|
+
const { isFeatureActive } = select( editPostStore );
|
|
94
102
|
const editorSettings = getEditorSettings();
|
|
95
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
|
+
}
|
|
96
137
|
|
|
97
138
|
return {
|
|
98
139
|
isTemplateMode: select( editPostStore ).isEditingTemplate(),
|
|
@@ -125,6 +166,10 @@ function Layout( { styles } ) {
|
|
|
125
166
|
),
|
|
126
167
|
// translators: Default label for the Document in the Block Breadcrumb.
|
|
127
168
|
documentLabel: postTypeLabel || _x( 'Document', 'noun' ),
|
|
169
|
+
styles:
|
|
170
|
+
hasThemeStyles && themeStyles.length
|
|
171
|
+
? editorSettings.styles
|
|
172
|
+
: defaultEditorStyles,
|
|
128
173
|
};
|
|
129
174
|
}, [] );
|
|
130
175
|
|
|
@@ -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"
|
|
@@ -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;
|
package/src/editor.js
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
store as editorStore,
|
|
10
10
|
privateApis as editorPrivateApis,
|
|
11
11
|
} from '@wordpress/editor';
|
|
12
|
-
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
13
12
|
import { useMemo } from '@wordpress/element';
|
|
14
13
|
import { SlotFillProvider } from '@wordpress/components';
|
|
15
14
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -28,7 +27,6 @@ import { unlock } from './lock-unlock';
|
|
|
28
27
|
import useCommonCommands from './hooks/commands/use-common-commands';
|
|
29
28
|
|
|
30
29
|
const { ExperimentalEditorProvider } = unlock( editorPrivateApis );
|
|
31
|
-
const { getLayoutStyles } = unlock( blockEditorPrivateApis );
|
|
32
30
|
const { useCommands } = unlock( coreCommandsPrivateApis );
|
|
33
31
|
|
|
34
32
|
function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
@@ -39,7 +37,6 @@ function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
|
39
37
|
focusMode,
|
|
40
38
|
isDistractionFree,
|
|
41
39
|
hasInlineToolbar,
|
|
42
|
-
hasThemeStyles,
|
|
43
40
|
post,
|
|
44
41
|
preferredStyleVariations,
|
|
45
42
|
hiddenBlockTypes,
|
|
@@ -51,7 +48,6 @@ function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
|
51
48
|
( select ) => {
|
|
52
49
|
const {
|
|
53
50
|
isFeatureActive,
|
|
54
|
-
__experimentalGetPreviewDeviceType,
|
|
55
51
|
isEditingTemplate,
|
|
56
52
|
getEditedPostTemplate,
|
|
57
53
|
getHiddenBlockTypes,
|
|
@@ -80,13 +76,10 @@ function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
|
80
76
|
const canEditTemplate = canUser( 'create', 'templates' );
|
|
81
77
|
|
|
82
78
|
return {
|
|
83
|
-
hasFixedToolbar:
|
|
84
|
-
isFeatureActive( 'fixedToolbar' ) ||
|
|
85
|
-
__experimentalGetPreviewDeviceType() !== 'Desktop',
|
|
79
|
+
hasFixedToolbar: isFeatureActive( 'fixedToolbar' ),
|
|
86
80
|
focusMode: isFeatureActive( 'focusMode' ),
|
|
87
81
|
isDistractionFree: isFeatureActive( 'distractionFree' ),
|
|
88
82
|
hasInlineToolbar: isFeatureActive( 'inlineToolbar' ),
|
|
89
|
-
hasThemeStyles: isFeatureActive( 'themeStyles' ),
|
|
90
83
|
preferredStyleVariations: select( preferencesStore ).get(
|
|
91
84
|
'core/edit-post',
|
|
92
85
|
'preferredStyleVariations'
|
|
@@ -158,44 +151,6 @@ function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
|
158
151
|
keepCaretInsideBlock,
|
|
159
152
|
] );
|
|
160
153
|
|
|
161
|
-
const styles = useMemo( () => {
|
|
162
|
-
const themeStyles = [];
|
|
163
|
-
const presetStyles = [];
|
|
164
|
-
settings.styles?.forEach( ( style ) => {
|
|
165
|
-
if ( ! style.__unstableType || style.__unstableType === 'theme' ) {
|
|
166
|
-
themeStyles.push( style );
|
|
167
|
-
} else {
|
|
168
|
-
presetStyles.push( style );
|
|
169
|
-
}
|
|
170
|
-
} );
|
|
171
|
-
|
|
172
|
-
const defaultEditorStyles = [
|
|
173
|
-
...settings.defaultEditorStyles,
|
|
174
|
-
...presetStyles,
|
|
175
|
-
];
|
|
176
|
-
|
|
177
|
-
// If theme styles are not present or displayed, ensure that
|
|
178
|
-
// base layout styles are still present in the editor.
|
|
179
|
-
if (
|
|
180
|
-
! settings.disableLayoutStyles &&
|
|
181
|
-
! ( hasThemeStyles && themeStyles.length )
|
|
182
|
-
) {
|
|
183
|
-
defaultEditorStyles.push( {
|
|
184
|
-
css: getLayoutStyles( {
|
|
185
|
-
style: {},
|
|
186
|
-
selector: 'body',
|
|
187
|
-
hasBlockGapSupport: false,
|
|
188
|
-
hasFallbackGapSupport: true,
|
|
189
|
-
fallbackGapValue: '0.5em',
|
|
190
|
-
} ),
|
|
191
|
-
} );
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return hasThemeStyles && themeStyles.length
|
|
195
|
-
? settings.styles
|
|
196
|
-
: defaultEditorStyles;
|
|
197
|
-
}, [ settings, hasThemeStyles ] );
|
|
198
|
-
|
|
199
154
|
if ( ! post ) {
|
|
200
155
|
return null;
|
|
201
156
|
}
|
|
@@ -214,7 +169,7 @@ function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
|
214
169
|
<ErrorBoundary>
|
|
215
170
|
<CommandMenu />
|
|
216
171
|
<EditorInitialization postId={ postId } />
|
|
217
|
-
<Layout
|
|
172
|
+
<Layout />
|
|
218
173
|
</ErrorBoundary>
|
|
219
174
|
<PostLockedModal />
|
|
220
175
|
</ExperimentalEditorProvider>
|
|
@@ -9,13 +9,17 @@ import {
|
|
|
9
9
|
drawerLeft,
|
|
10
10
|
drawerRight,
|
|
11
11
|
blockDefault,
|
|
12
|
-
|
|
12
|
+
keyboard,
|
|
13
13
|
desktop,
|
|
14
14
|
listView,
|
|
15
|
+
external,
|
|
16
|
+
formatListBullets,
|
|
15
17
|
} from '@wordpress/icons';
|
|
16
18
|
import { useCommand } from '@wordpress/commands';
|
|
17
19
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
18
20
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
21
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
22
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
19
23
|
|
|
20
24
|
/**
|
|
21
25
|
* Internal dependencies
|
|
@@ -32,20 +36,29 @@ export default function useCommonCommands() {
|
|
|
32
36
|
setIsListViewOpened,
|
|
33
37
|
} = useDispatch( editPostStore );
|
|
34
38
|
const { openModal } = useDispatch( interfaceStore );
|
|
35
|
-
const {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
const {
|
|
40
|
+
editorMode,
|
|
41
|
+
activeSidebar,
|
|
42
|
+
isListViewOpen,
|
|
43
|
+
isPublishSidebarEnabled,
|
|
44
|
+
showBlockBreadcrumbs,
|
|
45
|
+
} = useSelect( ( select ) => {
|
|
46
|
+
const { getEditorMode, isListViewOpened, isFeatureActive } =
|
|
47
|
+
select( editPostStore );
|
|
48
|
+
return {
|
|
49
|
+
activeSidebar: select( interfaceStore ).getActiveComplementaryArea(
|
|
50
|
+
editPostStore.name
|
|
51
|
+
),
|
|
52
|
+
editorMode: getEditorMode(),
|
|
53
|
+
isListViewOpen: isListViewOpened(),
|
|
54
|
+
isPublishSidebarEnabled:
|
|
55
|
+
select( editorStore ).isPublishSidebarEnabled(),
|
|
56
|
+
showBlockBreadcrumbs: isFeatureActive( 'showBlockBreadcrumbs' ),
|
|
57
|
+
};
|
|
58
|
+
}, [] );
|
|
48
59
|
const { toggle } = useDispatch( preferencesStore );
|
|
60
|
+
const { createInfoNotice } = useDispatch( noticesStore );
|
|
61
|
+
const { __unstableSaveForPreview } = useDispatch( editorStore );
|
|
49
62
|
|
|
50
63
|
useCommand( {
|
|
51
64
|
name: 'core/open-settings-sidebar',
|
|
@@ -147,9 +160,62 @@ export default function useCommonCommands() {
|
|
|
147
160
|
useCommand( {
|
|
148
161
|
name: 'core/open-shortcut-help',
|
|
149
162
|
label: __( 'Open keyboard shortcuts' ),
|
|
150
|
-
icon:
|
|
163
|
+
icon: keyboard,
|
|
151
164
|
callback: () => {
|
|
152
165
|
openModal( KEYBOARD_SHORTCUT_HELP_MODAL_NAME );
|
|
153
166
|
},
|
|
154
167
|
} );
|
|
168
|
+
|
|
169
|
+
useCommand( {
|
|
170
|
+
name: 'core/toggle-breadcrumbs',
|
|
171
|
+
label: showBlockBreadcrumbs
|
|
172
|
+
? __( 'Hide block breadcrumbs' )
|
|
173
|
+
: __( 'Show block breadcrumbs' ),
|
|
174
|
+
icon: cog,
|
|
175
|
+
callback: ( { close } ) => {
|
|
176
|
+
toggle( 'core/edit-post', 'showBlockBreadcrumbs' );
|
|
177
|
+
close();
|
|
178
|
+
createInfoNotice(
|
|
179
|
+
showBlockBreadcrumbs
|
|
180
|
+
? __( 'Breadcrumbs off.' )
|
|
181
|
+
: __( 'Breadcrumbs on.' ),
|
|
182
|
+
{
|
|
183
|
+
id: 'core/edit-post/toggle-breadcrumbs/notice',
|
|
184
|
+
type: 'snackbar',
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
},
|
|
188
|
+
} );
|
|
189
|
+
|
|
190
|
+
useCommand( {
|
|
191
|
+
name: 'core/toggle-publish-sidebar',
|
|
192
|
+
label: isPublishSidebarEnabled
|
|
193
|
+
? __( 'Disable pre-publish checklist' )
|
|
194
|
+
: __( 'Enable pre-publish checklist' ),
|
|
195
|
+
icon: formatListBullets,
|
|
196
|
+
callback: ( { close } ) => {
|
|
197
|
+
close();
|
|
198
|
+
toggle( 'core/edit-post', 'isPublishSidebarEnabled' );
|
|
199
|
+
createInfoNotice(
|
|
200
|
+
isPublishSidebarEnabled
|
|
201
|
+
? __( 'Pre-publish checklist off.' )
|
|
202
|
+
: __( 'Pre-publish checklist on.' ),
|
|
203
|
+
{
|
|
204
|
+
id: 'core/edit-post/publish-sidebar/notice',
|
|
205
|
+
type: 'snackbar',
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
},
|
|
209
|
+
} );
|
|
210
|
+
|
|
211
|
+
useCommand( {
|
|
212
|
+
name: 'core/preview-link',
|
|
213
|
+
label: __( 'Preview in a new tab' ),
|
|
214
|
+
icon: external,
|
|
215
|
+
callback: async ( { close } ) => {
|
|
216
|
+
close();
|
|
217
|
+
const link = await __unstableSaveForPreview( {} );
|
|
218
|
+
window.open( link, '_blank' );
|
|
219
|
+
},
|
|
220
|
+
} );
|
|
155
221
|
}
|
package/src/index.js
CHANGED
|
@@ -65,7 +65,11 @@ export function initializeEditor(
|
|
|
65
65
|
dispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();
|
|
66
66
|
|
|
67
67
|
// Check if the block list view should be open by default.
|
|
68
|
-
|
|
68
|
+
// If `distractionFree` mode is enabled, the block list view should not be open.
|
|
69
|
+
if (
|
|
70
|
+
select( editPostStore ).isFeatureActive( 'showListViewByDefault' ) &&
|
|
71
|
+
! select( editPostStore ).isFeatureActive( 'distractionFree' )
|
|
72
|
+
) {
|
|
69
73
|
dispatch( editPostStore ).setIsListViewOpened( true );
|
|
70
74
|
}
|
|
71
75
|
|
package/src/style.scss
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
@import "./components/header/style.scss";
|
|
3
3
|
@import "./components/header/fullscreen-mode-close/style.scss";
|
|
4
4
|
@import "./components/header/header-toolbar/style.scss";
|
|
5
|
-
@import "./components/header/document-
|
|
5
|
+
@import "./components/header/document-actions/style.scss";
|
|
6
6
|
@import "./components/keyboard-shortcut-help-modal/style.scss";
|
|
7
7
|
@import "./components/layout/style.scss";
|
|
8
8
|
@import "./components/block-manager/style.scss";
|
|
@@ -74,11 +74,12 @@ describe( 'Editor', () => {
|
|
|
74
74
|
// Act
|
|
75
75
|
const paragraphBlock = getBlock( screen, 'Paragraph' );
|
|
76
76
|
fireEvent.press( paragraphBlock );
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
act( () => {
|
|
78
|
+
toggleMode();
|
|
79
|
+
} );
|
|
79
80
|
|
|
80
81
|
// Assert
|
|
81
|
-
const htmlEditor =
|
|
82
|
+
const htmlEditor = screen.getByLabelText( 'html-view-content' );
|
|
82
83
|
expect( htmlEditor ).toBeVisible();
|
|
83
84
|
} );
|
|
84
85
|
} );
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/header/document-title/index.js"],"names":["DocumentTitle","template","isEditing","select","isEditingTemplate","getEditedPostTemplate","editPostStore","_isEditing","clearSelectedBlock","blockEditorStore","setIsEditingTemplate","open","openCommandCenter","commandsStore","templateTitle","title","slug","chevronRightSmall","chevronLeftSmall","layout","displayShortcut","primary"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,SAASA,aAAT,GAAyB;AACxB,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAA0B,qBAAaC,MAAF,IAAc;AACxD,UAAM;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,QACLF,MAAM,CAAEG,YAAF,CADP;;AAEA,UAAMC,UAAU,GAAGH,iBAAiB,EAApC;;AAEA,WAAO;AACNH,MAAAA,QAAQ,EAAEM,UAAU,GAAGF,qBAAqB,EAAxB,GAA6B,IAD3C;AAENH,MAAAA,SAAS,EAAEK;AAFL,KAAP;AAIA,GAT+B,EAS7B,EAT6B,CAAhC;AAUA,QAAM;AAAEC,IAAAA;AAAF,MAAyB,uBAAaC,kBAAb,CAA/B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA2B,uBAAaJ,YAAb,CAAjC;AACA,QAAM;AAAEK,IAAAA,IAAI,EAAEC;AAAR,MAA8B,uBAAaC,eAAb,CAApC;;AAEA,MAAK,CAAEX,SAAF,IAAe,CAAED,QAAtB,EAAiC;AAChC,WAAO,IAAP;AACA;;AAED,MAAIa,aAAa,GAAG,cAAI,SAAJ,CAApB;;AACA,MAAKb,QAAQ,EAAEc,KAAf,EAAuB;AACtBD,IAAAA,aAAa,GAAGb,QAAQ,CAACc,KAAzB;AACA,GAFD,MAEO,IAAK,CAAC,CAAEd,QAAR,EAAmB;AACzBa,IAAAA,aAAa,GAAGb,QAAQ,CAACe,IAAzB;AACA;;AAED,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfR,MAAAA,kBAAkB;AAClBE,MAAAA,oBAAoB,CAAE,KAAF,CAApB;AACA,KAJF;AAKC,IAAA,IAAI,EAAG,qBAAUO,wBAAV,GAA8BC;AALtC,KAOG,cAAI,MAAJ,CAPH,CADD,CADD,EAaC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,OAAO,EAAG,MAAMN,iBAAiB;AAFlC,KAIC,4BAAC,gCAAD;AAAQ,IAAA,OAAO,EAAG,CAAlB;AAAsB,IAAA,OAAO,EAAC;AAA9B,KACC,4BAAC,sBAAD;AAAW,IAAA,IAAI,EAAGO;AAAlB,IADD,EAEC,4BAAC,8BAAD;AAAM,IAAA,IAAI,EAAC,MAAX;AAAkB,IAAA,EAAE,EAAC;AAArB,KACC,4BAAC,0BAAD;AAAgB,IAAA,EAAE,EAAC;AAAnB,KACG,cAAI,oBAAJ,CADH,CADD,EAIGL,aAJH,CAFD,CAJD,CAbD,EA2BC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,oCADX;AAEC,IAAA,OAAO,EAAG,MAAMF,iBAAiB;AAFlC,KAIGQ,0BAAgBC,OAAhB,CAAyB,GAAzB,CAJH,CA3BD,CADD;AAoCA;;eAEcrB,a","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { BlockIcon, store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tVisuallyHidden,\n\t__experimentalHStack as HStack,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { layout, chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nfunction DocumentTitle() {\n\tconst { template, isEditing } = useSelect( ( select ) => {\n\t\tconst { isEditingTemplate, getEditedPostTemplate } =\n\t\t\tselect( editPostStore );\n\t\tconst _isEditing = isEditingTemplate();\n\n\t\treturn {\n\t\t\ttemplate: _isEditing ? getEditedPostTemplate() : null,\n\t\t\tisEditing: _isEditing,\n\t\t};\n\t}, [] );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { setIsEditingTemplate } = useDispatch( editPostStore );\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\n\tif ( ! isEditing || ! template ) {\n\t\treturn null;\n\t}\n\n\tlet templateTitle = __( 'Default' );\n\tif ( template?.title ) {\n\t\ttemplateTitle = template.title;\n\t} else if ( !! template ) {\n\t\ttemplateTitle = template.slug;\n\t}\n\n\treturn (\n\t\t<div className=\"edit-post-document-title\">\n\t\t\t<span className=\"edit-post-document-title__left\">\n\t\t\t\t<Button\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t\tsetIsEditingTemplate( false );\n\t\t\t\t\t} }\n\t\t\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t</Button>\n\t\t\t</span>\n\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-post-document-title__title\"\n\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t>\n\t\t\t\t<HStack spacing={ 1 } justify=\"center\">\n\t\t\t\t\t<BlockIcon icon={ layout } />\n\t\t\t\t\t<Text size=\"body\" as=\"h1\">\n\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t{ __( 'Editing template: ' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t{ templateTitle }\n\t\t\t\t\t</Text>\n\t\t\t\t</HStack>\n\t\t\t</Button>\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-post-document-title__shortcut\"\n\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t>\n\t\t\t\t{ displayShortcut.primary( 'k' ) }\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n\nexport default DocumentTitle;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/header/document-title/index.js"],"names":["__","isRTL","useSelect","useDispatch","BlockIcon","store","blockEditorStore","Button","VisuallyHidden","__experimentalHStack","HStack","__experimentalText","Text","layout","chevronLeftSmall","chevronRightSmall","commandsStore","displayShortcut","editPostStore","DocumentTitle","template","isEditing","select","isEditingTemplate","getEditedPostTemplate","_isEditing","clearSelectedBlock","setIsEditingTemplate","open","openCommandCenter","templateTitle","title","slug","primary"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { BlockIcon, store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tVisuallyHidden,\n\t__experimentalHStack as HStack,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { layout, chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nfunction DocumentTitle() {\n\tconst { template, isEditing } = useSelect( ( select ) => {\n\t\tconst { isEditingTemplate, getEditedPostTemplate } =\n\t\t\tselect( editPostStore );\n\t\tconst _isEditing = isEditingTemplate();\n\n\t\treturn {\n\t\t\ttemplate: _isEditing ? getEditedPostTemplate() : null,\n\t\t\tisEditing: _isEditing,\n\t\t};\n\t}, [] );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { setIsEditingTemplate } = useDispatch( editPostStore );\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\n\tif ( ! isEditing || ! template ) {\n\t\treturn null;\n\t}\n\n\tlet templateTitle = __( 'Default' );\n\tif ( template?.title ) {\n\t\ttemplateTitle = template.title;\n\t} else if ( !! template ) {\n\t\ttemplateTitle = template.slug;\n\t}\n\n\treturn (\n\t\t<div className=\"edit-post-document-title\">\n\t\t\t<span className=\"edit-post-document-title__left\">\n\t\t\t\t<Button\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t\tsetIsEditingTemplate( false );\n\t\t\t\t\t} }\n\t\t\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t</Button>\n\t\t\t</span>\n\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-post-document-title__title\"\n\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t>\n\t\t\t\t<HStack spacing={ 1 } justify=\"center\">\n\t\t\t\t\t<BlockIcon icon={ layout } />\n\t\t\t\t\t<Text size=\"body\" as=\"h1\">\n\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t{ __( 'Editing template: ' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t{ templateTitle }\n\t\t\t\t\t</Text>\n\t\t\t\t</HStack>\n\t\t\t</Button>\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-post-document-title__shortcut\"\n\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t>\n\t\t\t\t{ displayShortcut.primary( 'k' ) }\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n\nexport default DocumentTitle;\n"]}
|