@wordpress/edit-post 7.28.5 → 7.30.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/editor-initialization/index.js +3 -6
- package/build/components/editor-initialization/index.js.map +1 -1
- package/build/components/editor-initialization/listener-hooks.js +6 -10
- package/build/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/index.js +13 -7
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +16 -4
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/writing-menu/index.js +2 -6
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -38
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +2 -3
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js +2 -5
- package/build/components/layout/index.native.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/editor.js +3 -31
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +2 -3
- package/build/editor.native.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +2 -135
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/index.js +0 -30
- package/build/index.js.map +1 -1
- package/build/index.native.js +0 -1
- package/build/index.native.js.map +1 -1
- package/build/store/actions.js +24 -77
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +0 -12
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/editor-initialization/index.js +3 -6
- package/build-module/components/editor-initialization/index.js.map +1 -1
- package/build-module/components/editor-initialization/listener-hooks.js +6 -10
- package/build-module/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/index.js +14 -8
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +17 -5
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js +2 -6
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -38
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +3 -4
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js +2 -5
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/text-editor/index.js +1 -1
- package/build-module/components/text-editor/index.js.map +1 -1
- package/build-module/editor.js +4 -32
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +3 -4
- package/build-module/editor.native.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +3 -136
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/index.js +0 -30
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +0 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/store/actions.js +23 -75
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +0 -12
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +10 -38
- package/build-style/style.css +10 -38
- package/package.json +32 -32
- package/src/components/editor-initialization/index.js +3 -4
- package/src/components/editor-initialization/listener-hooks.js +20 -22
- package/src/components/editor-initialization/test/listener-hooks.js +8 -8
- package/src/components/header/header-toolbar/index.native.js +1 -1
- package/src/components/header/index.js +23 -23
- package/src/components/header/more-menu/index.js +17 -10
- package/src/components/header/style.scss +4 -0
- package/src/components/header/test/index.js +4 -14
- package/src/components/header/writing-menu/index.js +2 -6
- package/src/components/keyboard-shortcuts/index.js +3 -50
- package/src/components/layout/index.js +3 -4
- package/src/components/layout/index.native.js +1 -3
- package/src/components/sidebar/plugin-post-publish-panel/test/index.js +1 -1
- package/src/components/text-editor/index.js +1 -1
- package/src/editor.js +32 -65
- package/src/editor.native.js +3 -4
- package/src/hooks/commands/use-common-commands.js +17 -170
- package/src/index.js +0 -44
- package/src/index.native.js +0 -1
- package/src/store/actions.js +24 -126
- package/src/store/selectors.js +0 -18
- package/src/store/test/actions.js +0 -146
- package/src/style.scss +1 -2
- package/build/components/header/mode-switcher/index.js +0 -87
- package/build/components/header/mode-switcher/index.js.map +0 -1
- package/build-module/components/header/mode-switcher/index.js +0 -81
- package/build-module/components/header/mode-switcher/index.js.map +0 -1
- package/src/components/header/mode-switcher/index.js +0 -91
|
@@ -36,7 +36,6 @@ import styles from './style.scss';
|
|
|
36
36
|
import headerToolbarStyles from '../header/header-toolbar/style.scss';
|
|
37
37
|
import Header from '../header';
|
|
38
38
|
import VisualEditor from '../visual-editor';
|
|
39
|
-
import { store as editPostStore } from '../../store';
|
|
40
39
|
|
|
41
40
|
class Layout extends Component {
|
|
42
41
|
constructor() {
|
|
@@ -192,9 +191,8 @@ class Layout extends Component {
|
|
|
192
191
|
|
|
193
192
|
export default compose( [
|
|
194
193
|
withSelect( ( select ) => {
|
|
195
|
-
const { __unstableIsEditorReady: isEditorReady } =
|
|
194
|
+
const { __unstableIsEditorReady: isEditorReady, getEditorMode } =
|
|
196
195
|
select( editorStore );
|
|
197
|
-
const { getEditorMode } = select( editPostStore );
|
|
198
196
|
const { getSettings } = select( blockEditorStore );
|
|
199
197
|
const globalStyles =
|
|
200
198
|
getSettings()?.__experimentalGlobalStylesBaseStyles?.color;
|
|
@@ -21,7 +21,7 @@ export default function TextEditor() {
|
|
|
21
21
|
const isRichEditingEnabled = useSelect( ( select ) => {
|
|
22
22
|
return select( editorStore ).getEditorSettings().richEditingEnabled;
|
|
23
23
|
}, [] );
|
|
24
|
-
const { switchEditorMode } = useDispatch(
|
|
24
|
+
const { switchEditorMode } = useDispatch( editorStore );
|
|
25
25
|
|
|
26
26
|
const { isWelcomeGuideVisible } = useSelect( ( select ) => {
|
|
27
27
|
const { isFeatureActive } = select( editPostStore );
|
package/src/editor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useSelect
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
5
|
import {
|
|
6
6
|
ErrorBoundary,
|
|
7
7
|
PostLockedModal,
|
|
@@ -11,10 +11,7 @@ import {
|
|
|
11
11
|
import { useMemo } from '@wordpress/element';
|
|
12
12
|
import { SlotFillProvider } from '@wordpress/components';
|
|
13
13
|
import { store as coreStore } from '@wordpress/core-data';
|
|
14
|
-
import { store as preferencesStore } from '@wordpress/preferences';
|
|
15
14
|
import { CommandMenu } from '@wordpress/commands';
|
|
16
|
-
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
17
|
-
import { __ } from '@wordpress/i18n';
|
|
18
15
|
|
|
19
16
|
/**
|
|
20
17
|
* Internal dependencies
|
|
@@ -26,14 +23,6 @@ import { unlock } from './lock-unlock';
|
|
|
26
23
|
import useNavigateToEntityRecord from './hooks/use-navigate-to-entity-record';
|
|
27
24
|
|
|
28
25
|
const { ExperimentalEditorProvider } = unlock( editorPrivateApis );
|
|
29
|
-
const { BlockRemovalWarningModal } = unlock( blockEditorPrivateApis );
|
|
30
|
-
// Prevent accidental removal of certain blocks, asking the user for
|
|
31
|
-
// confirmation.
|
|
32
|
-
const blockRemovalRules = {
|
|
33
|
-
'bindings/core/pattern-overrides': __(
|
|
34
|
-
'Blocks from synced patterns that can have overriden content.'
|
|
35
|
-
),
|
|
36
|
-
};
|
|
37
26
|
|
|
38
27
|
function Editor( {
|
|
39
28
|
postId: initialPostId,
|
|
@@ -49,46 +38,37 @@ function Editor( {
|
|
|
49
38
|
onNavigateToPreviousEntityRecord,
|
|
50
39
|
} = useNavigateToEntityRecord( initialPostId, initialPostType );
|
|
51
40
|
|
|
52
|
-
const {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
select( coreStore );
|
|
59
|
-
const { getEditorSettings } = select( editorStore );
|
|
41
|
+
const { post, template } = useSelect(
|
|
42
|
+
( select ) => {
|
|
43
|
+
const { getEditedPostTemplate } = select( editPostStore );
|
|
44
|
+
const { getEntityRecord, getPostType, canUser } =
|
|
45
|
+
select( coreStore );
|
|
46
|
+
const { getEditorSettings } = select( editorStore );
|
|
60
47
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
48
|
+
const postObject = getEntityRecord(
|
|
49
|
+
'postType',
|
|
50
|
+
currentPost.postType,
|
|
51
|
+
currentPost.postId
|
|
52
|
+
);
|
|
66
53
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
post: postObject,
|
|
86
|
-
};
|
|
87
|
-
},
|
|
88
|
-
[ currentPost.postType, currentPost.postId ]
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
const { updatePreferredStyleVariations } = useDispatch( editPostStore );
|
|
54
|
+
const supportsTemplateMode =
|
|
55
|
+
getEditorSettings().supportsTemplateMode;
|
|
56
|
+
const isViewable =
|
|
57
|
+
getPostType( currentPost.postType )?.viewable ?? false;
|
|
58
|
+
const canEditTemplate = canUser( 'create', 'templates' );
|
|
59
|
+
return {
|
|
60
|
+
template:
|
|
61
|
+
supportsTemplateMode &&
|
|
62
|
+
isViewable &&
|
|
63
|
+
canEditTemplate &&
|
|
64
|
+
currentPost.postType !== 'wp_template'
|
|
65
|
+
? getEditedPostTemplate()
|
|
66
|
+
: null,
|
|
67
|
+
post: postObject,
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
[ currentPost.postType, currentPost.postId ]
|
|
71
|
+
);
|
|
92
72
|
|
|
93
73
|
const editorSettings = useMemo(
|
|
94
74
|
() => ( {
|
|
@@ -96,20 +76,8 @@ function Editor( {
|
|
|
96
76
|
onNavigateToEntityRecord,
|
|
97
77
|
onNavigateToPreviousEntityRecord,
|
|
98
78
|
defaultRenderingMode: 'post-only',
|
|
99
|
-
__experimentalPreferredStyleVariations: {
|
|
100
|
-
value: preferredStyleVariations,
|
|
101
|
-
onChange: updatePreferredStyleVariations,
|
|
102
|
-
},
|
|
103
|
-
hasInlineToolbar,
|
|
104
79
|
} ),
|
|
105
|
-
[
|
|
106
|
-
settings,
|
|
107
|
-
hasInlineToolbar,
|
|
108
|
-
preferredStyleVariations,
|
|
109
|
-
updatePreferredStyleVariations,
|
|
110
|
-
onNavigateToEntityRecord,
|
|
111
|
-
onNavigateToPreviousEntityRecord,
|
|
112
|
-
]
|
|
80
|
+
[ settings, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord ]
|
|
113
81
|
);
|
|
114
82
|
|
|
115
83
|
if ( ! post ) {
|
|
@@ -128,9 +96,8 @@ function Editor( {
|
|
|
128
96
|
>
|
|
129
97
|
<ErrorBoundary>
|
|
130
98
|
<CommandMenu />
|
|
131
|
-
<EditorInitialization
|
|
99
|
+
<EditorInitialization />
|
|
132
100
|
<Layout initialPost={ initialPost } />
|
|
133
|
-
<BlockRemovalWarningModal rules={ blockRemovalRules } />
|
|
134
101
|
</ErrorBoundary>
|
|
135
102
|
<PostLockedModal />
|
|
136
103
|
</ExperimentalEditorProvider>
|
package/src/editor.native.js
CHANGED
|
@@ -9,7 +9,7 @@ import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
|
9
9
|
* WordPress dependencies
|
|
10
10
|
*/
|
|
11
11
|
import { Component } from '@wordpress/element';
|
|
12
|
-
import { EditorProvider } from '@wordpress/editor';
|
|
12
|
+
import { EditorProvider, store as editorStore } from '@wordpress/editor';
|
|
13
13
|
import { parse, serialize } from '@wordpress/blocks';
|
|
14
14
|
import { withDispatch, withSelect } from '@wordpress/data';
|
|
15
15
|
import { compose } from '@wordpress/compose';
|
|
@@ -24,7 +24,6 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
24
24
|
* Internal dependencies
|
|
25
25
|
*/
|
|
26
26
|
import Layout from './components/layout';
|
|
27
|
-
import { store as editPostStore } from './store';
|
|
28
27
|
|
|
29
28
|
class Editor extends Component {
|
|
30
29
|
constructor( props ) {
|
|
@@ -154,14 +153,14 @@ class Editor extends Component {
|
|
|
154
153
|
|
|
155
154
|
export default compose( [
|
|
156
155
|
withSelect( ( select ) => {
|
|
157
|
-
const { getEditorMode } = select(
|
|
156
|
+
const { getEditorMode } = select( editorStore );
|
|
158
157
|
|
|
159
158
|
return {
|
|
160
159
|
mode: getEditorMode(),
|
|
161
160
|
};
|
|
162
161
|
} ),
|
|
163
162
|
withDispatch( ( dispatch ) => {
|
|
164
|
-
const { switchEditorMode } = dispatch(
|
|
163
|
+
const { switchEditorMode } = dispatch( editorStore );
|
|
165
164
|
const { editEntityRecord } = dispatch( coreStore );
|
|
166
165
|
return {
|
|
167
166
|
switchEditorMode,
|
|
@@ -4,14 +4,11 @@
|
|
|
4
4
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
5
|
import { __, isRTL } from '@wordpress/i18n';
|
|
6
6
|
import {
|
|
7
|
-
code,
|
|
8
7
|
drawerLeft,
|
|
9
8
|
drawerRight,
|
|
10
9
|
blockDefault,
|
|
11
10
|
keyboard,
|
|
12
11
|
fullscreen,
|
|
13
|
-
listView,
|
|
14
|
-
external,
|
|
15
12
|
formatListBullets,
|
|
16
13
|
} from '@wordpress/icons';
|
|
17
14
|
import { useCommand } from '@wordpress/commands';
|
|
@@ -28,48 +25,26 @@ import { PREFERENCES_MODAL_NAME } from '../../components/preferences-modal';
|
|
|
28
25
|
import { store as editPostStore } from '../../store';
|
|
29
26
|
|
|
30
27
|
export default function useCommonCommands() {
|
|
31
|
-
const {
|
|
32
|
-
|
|
33
|
-
closeGeneralSidebar,
|
|
34
|
-
switchEditorMode,
|
|
35
|
-
toggleDistractionFree,
|
|
36
|
-
} = useDispatch( editPostStore );
|
|
28
|
+
const { openGeneralSidebar, closeGeneralSidebar } =
|
|
29
|
+
useDispatch( editPostStore );
|
|
37
30
|
const { openModal } = useDispatch( interfaceStore );
|
|
38
|
-
const {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
activeSidebar: select( interfaceStore ).getActiveComplementaryArea(
|
|
55
|
-
editPostStore.name
|
|
56
|
-
),
|
|
57
|
-
editorMode: getEditorMode(),
|
|
58
|
-
isListViewOpen: isListViewOpened(),
|
|
59
|
-
isPublishSidebarEnabled:
|
|
60
|
-
select( editorStore ).isPublishSidebarEnabled(),
|
|
61
|
-
showBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),
|
|
62
|
-
isDistractionFree: get( 'core', 'distractionFree' ),
|
|
63
|
-
isFocusMode: get( 'core', 'focusMode' ),
|
|
64
|
-
isTopToolbar: get( 'core', 'fixedToolbar' ),
|
|
65
|
-
isFullscreen: get( 'core/edit-post', 'fullscreenMode' ),
|
|
66
|
-
};
|
|
67
|
-
}, [] );
|
|
31
|
+
const { activeSidebar, isFullscreen, isPublishSidebarEnabled } = useSelect(
|
|
32
|
+
( select ) => {
|
|
33
|
+
const { get } = select( preferencesStore );
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
activeSidebar: select(
|
|
37
|
+
interfaceStore
|
|
38
|
+
).getActiveComplementaryArea( editPostStore.name ),
|
|
39
|
+
isPublishSidebarEnabled:
|
|
40
|
+
select( editorStore ).isPublishSidebarEnabled(),
|
|
41
|
+
isFullscreen: get( 'core/edit-post', 'fullscreenMode' ),
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
[]
|
|
45
|
+
);
|
|
68
46
|
const { toggle } = useDispatch( preferencesStore );
|
|
69
47
|
const { createInfoNotice } = useDispatch( noticesStore );
|
|
70
|
-
const { __unstableSaveForPreview, setIsListViewOpened } =
|
|
71
|
-
useDispatch( editorStore );
|
|
72
|
-
const { getCurrentPostId } = useSelect( editorStore );
|
|
73
48
|
|
|
74
49
|
useCommand( {
|
|
75
50
|
name: 'core/open-settings-sidebar',
|
|
@@ -99,41 +74,6 @@ export default function useCommonCommands() {
|
|
|
99
74
|
},
|
|
100
75
|
} );
|
|
101
76
|
|
|
102
|
-
useCommand( {
|
|
103
|
-
name: 'core/toggle-distraction-free',
|
|
104
|
-
label: isDistractionFree
|
|
105
|
-
? __( 'Exit Distraction Free' )
|
|
106
|
-
: __( 'Enter Distraction Free ' ),
|
|
107
|
-
callback: ( { close } ) => {
|
|
108
|
-
toggleDistractionFree();
|
|
109
|
-
close();
|
|
110
|
-
},
|
|
111
|
-
} );
|
|
112
|
-
|
|
113
|
-
useCommand( {
|
|
114
|
-
name: 'core/toggle-spotlight-mode',
|
|
115
|
-
label: __( 'Toggle spotlight' ),
|
|
116
|
-
callback: ( { close } ) => {
|
|
117
|
-
toggle( 'core', 'focusMode' );
|
|
118
|
-
close();
|
|
119
|
-
createInfoNotice(
|
|
120
|
-
isFocusMode ? __( 'Spotlight off.' ) : __( 'Spotlight on.' ),
|
|
121
|
-
{
|
|
122
|
-
id: 'core/edit-post/toggle-spotlight-mode/notice',
|
|
123
|
-
type: 'snackbar',
|
|
124
|
-
actions: [
|
|
125
|
-
{
|
|
126
|
-
label: __( 'Undo' ),
|
|
127
|
-
onClick: () => {
|
|
128
|
-
toggle( 'core', 'focusMode' );
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
},
|
|
135
|
-
} );
|
|
136
|
-
|
|
137
77
|
useCommand( {
|
|
138
78
|
name: 'core/toggle-fullscreen-mode',
|
|
139
79
|
label: isFullscreen
|
|
@@ -161,67 +101,6 @@ export default function useCommonCommands() {
|
|
|
161
101
|
},
|
|
162
102
|
} );
|
|
163
103
|
|
|
164
|
-
useCommand( {
|
|
165
|
-
name: 'core/toggle-list-view',
|
|
166
|
-
label: isListViewOpen
|
|
167
|
-
? __( 'Close List View' )
|
|
168
|
-
: __( 'Open List View' ),
|
|
169
|
-
icon: listView,
|
|
170
|
-
callback: ( { close } ) => {
|
|
171
|
-
setIsListViewOpened( ! isListViewOpen );
|
|
172
|
-
close();
|
|
173
|
-
createInfoNotice(
|
|
174
|
-
isListViewOpen ? __( 'List View off.' ) : __( 'List View on.' ),
|
|
175
|
-
{
|
|
176
|
-
id: 'core/edit-post/toggle-list-view/notice',
|
|
177
|
-
type: 'snackbar',
|
|
178
|
-
}
|
|
179
|
-
);
|
|
180
|
-
},
|
|
181
|
-
} );
|
|
182
|
-
|
|
183
|
-
useCommand( {
|
|
184
|
-
name: 'core/toggle-top-toolbar',
|
|
185
|
-
label: __( 'Toggle top toolbar' ),
|
|
186
|
-
callback: ( { close } ) => {
|
|
187
|
-
toggle( 'core', 'fixedToolbar' );
|
|
188
|
-
if ( isDistractionFree ) {
|
|
189
|
-
toggleDistractionFree();
|
|
190
|
-
}
|
|
191
|
-
close();
|
|
192
|
-
createInfoNotice(
|
|
193
|
-
isTopToolbar
|
|
194
|
-
? __( 'Top toolbar off.' )
|
|
195
|
-
: __( 'Top toolbar on.' ),
|
|
196
|
-
{
|
|
197
|
-
id: 'core/edit-post/toggle-top-toolbar/notice',
|
|
198
|
-
type: 'snackbar',
|
|
199
|
-
actions: [
|
|
200
|
-
{
|
|
201
|
-
label: __( 'Undo' ),
|
|
202
|
-
onClick: () => {
|
|
203
|
-
toggle( 'core', 'fixedToolbar' );
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
],
|
|
207
|
-
}
|
|
208
|
-
);
|
|
209
|
-
},
|
|
210
|
-
} );
|
|
211
|
-
|
|
212
|
-
useCommand( {
|
|
213
|
-
name: 'core/toggle-code-editor',
|
|
214
|
-
label:
|
|
215
|
-
editorMode === 'visual'
|
|
216
|
-
? __( 'Open code editor' )
|
|
217
|
-
: __( 'Exit code editor' ),
|
|
218
|
-
icon: code,
|
|
219
|
-
callback: ( { close } ) => {
|
|
220
|
-
switchEditorMode( editorMode === 'visual' ? 'text' : 'visual' );
|
|
221
|
-
close();
|
|
222
|
-
},
|
|
223
|
-
} );
|
|
224
|
-
|
|
225
104
|
useCommand( {
|
|
226
105
|
name: 'core/open-preferences',
|
|
227
106
|
label: __( 'Editor preferences' ),
|
|
@@ -239,26 +118,6 @@ export default function useCommonCommands() {
|
|
|
239
118
|
},
|
|
240
119
|
} );
|
|
241
120
|
|
|
242
|
-
useCommand( {
|
|
243
|
-
name: 'core/toggle-breadcrumbs',
|
|
244
|
-
label: showBlockBreadcrumbs
|
|
245
|
-
? __( 'Hide block breadcrumbs' )
|
|
246
|
-
: __( 'Show block breadcrumbs' ),
|
|
247
|
-
callback: ( { close } ) => {
|
|
248
|
-
toggle( 'core', 'showBlockBreadcrumbs' );
|
|
249
|
-
close();
|
|
250
|
-
createInfoNotice(
|
|
251
|
-
showBlockBreadcrumbs
|
|
252
|
-
? __( 'Breadcrumbs hidden.' )
|
|
253
|
-
: __( 'Breadcrumbs visible.' ),
|
|
254
|
-
{
|
|
255
|
-
id: 'core/edit-post/toggle-breadcrumbs/notice',
|
|
256
|
-
type: 'snackbar',
|
|
257
|
-
}
|
|
258
|
-
);
|
|
259
|
-
},
|
|
260
|
-
} );
|
|
261
|
-
|
|
262
121
|
useCommand( {
|
|
263
122
|
name: 'core/toggle-publish-sidebar',
|
|
264
123
|
label: isPublishSidebarEnabled
|
|
@@ -279,16 +138,4 @@ export default function useCommonCommands() {
|
|
|
279
138
|
);
|
|
280
139
|
},
|
|
281
140
|
} );
|
|
282
|
-
|
|
283
|
-
useCommand( {
|
|
284
|
-
name: 'core/preview-link',
|
|
285
|
-
label: __( 'Preview in a new tab' ),
|
|
286
|
-
icon: external,
|
|
287
|
-
callback: async ( { close } ) => {
|
|
288
|
-
close();
|
|
289
|
-
const postId = getCurrentPostId();
|
|
290
|
-
const link = await __unstableSaveForPreview();
|
|
291
|
-
window.open( link, `wp-preview-${ postId }` );
|
|
292
|
-
},
|
|
293
|
-
} );
|
|
294
141
|
}
|
package/src/index.js
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
import deprecated from '@wordpress/deprecated';
|
|
10
10
|
import { createRoot } from '@wordpress/element';
|
|
11
11
|
import { dispatch, select } from '@wordpress/data';
|
|
12
|
-
import { addFilter } from '@wordpress/hooks';
|
|
13
12
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
14
13
|
import {
|
|
15
14
|
registerLegacyWidgetBlock,
|
|
@@ -56,7 +55,6 @@ export function initializeEditor(
|
|
|
56
55
|
dispatch( preferencesStore ).setDefaults( 'core/edit-post', {
|
|
57
56
|
fullscreenMode: true,
|
|
58
57
|
isPublishSidebarEnabled: true,
|
|
59
|
-
preferredStyleVariations: {},
|
|
60
58
|
themeStyles: true,
|
|
61
59
|
welcomeGuide: true,
|
|
62
60
|
welcomeGuideTemplate: true,
|
|
@@ -96,48 +94,6 @@ export function initializeEditor(
|
|
|
96
94
|
} );
|
|
97
95
|
}
|
|
98
96
|
|
|
99
|
-
/*
|
|
100
|
-
* Prevent adding template part in the post editor.
|
|
101
|
-
* Only add the filter when the post editor is initialized, not imported.
|
|
102
|
-
* Also only add the filter(s) after registerCoreBlocks()
|
|
103
|
-
* so that common filters in the block library are not overwritten.
|
|
104
|
-
*/
|
|
105
|
-
addFilter(
|
|
106
|
-
'blockEditor.__unstableCanInsertBlockType',
|
|
107
|
-
'removeTemplatePartsFromInserter',
|
|
108
|
-
( canInsert, blockType ) => {
|
|
109
|
-
if ( blockType.name === 'core/template-part' ) {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
return canInsert;
|
|
113
|
-
}
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
/*
|
|
117
|
-
* Prevent adding post content block (except in query block) in the post editor.
|
|
118
|
-
* Only add the filter when the post editor is initialized, not imported.
|
|
119
|
-
* Also only add the filter(s) after registerCoreBlocks()
|
|
120
|
-
* so that common filters in the block library are not overwritten.
|
|
121
|
-
*/
|
|
122
|
-
addFilter(
|
|
123
|
-
'blockEditor.__unstableCanInsertBlockType',
|
|
124
|
-
'removePostContentFromInserter',
|
|
125
|
-
(
|
|
126
|
-
canInsert,
|
|
127
|
-
blockType,
|
|
128
|
-
rootClientId,
|
|
129
|
-
{ getBlockParentsByBlockName }
|
|
130
|
-
) => {
|
|
131
|
-
if ( blockType.name === 'core/post-content' ) {
|
|
132
|
-
return (
|
|
133
|
-
getBlockParentsByBlockName( rootClientId, 'core/query' )
|
|
134
|
-
.length > 0
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
return canInsert;
|
|
138
|
-
}
|
|
139
|
-
);
|
|
140
|
-
|
|
141
97
|
// Show a console log warning if the browser is not in Standards rendering mode.
|
|
142
98
|
const documentMode =
|
|
143
99
|
document.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';
|
package/src/index.native.js
CHANGED
|
@@ -27,7 +27,6 @@ export function initializeEditor( id, postType, postId ) {
|
|
|
27
27
|
inactivePanels: [],
|
|
28
28
|
isPublishSidebarEnabled: true,
|
|
29
29
|
openPanels: [ 'post-status' ],
|
|
30
|
-
preferredStyleVariations: {},
|
|
31
30
|
welcomeGuide: true,
|
|
32
31
|
} );
|
|
33
32
|
dispatch( preferencesStore ).setDefaults( 'core', {
|