@wordpress/edit-post 7.28.2 → 7.29.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/editor-initialization/listener-hooks.js +14 -6
- package/build/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build/components/header/index.js +1 -1
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +6 -2
- 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 +3 -4
- 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 +2 -16
- 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 +3 -31
- 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/listener-hooks.js +14 -6
- package/build-module/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build-module/components/header/index.js +1 -1
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +5 -1
- 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 +4 -5
- 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 +3 -17
- 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 +3 -31
- 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 +6 -6
- package/build-style/style.css +6 -6
- package/package.json +32 -32
- package/src/components/editor-initialization/listener-hooks.js +16 -9
- package/src/components/editor-initialization/test/listener-hooks.js +40 -0
- package/src/components/header/index.js +1 -1
- package/src/components/header/more-menu/index.js +4 -1
- 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 +4 -5
- package/src/components/layout/index.native.js +1 -3
- package/src/components/text-editor/index.js +1 -1
- package/src/editor.js +31 -53
- package/src/editor.native.js +3 -4
- package/src/hooks/commands/use-common-commands.js +17 -170
- package/src/index.js +3 -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
|
@@ -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,
|
|
@@ -49,13 +48,13 @@ export function initializeEditor(
|
|
|
49
48
|
settings,
|
|
50
49
|
initialEdits
|
|
51
50
|
) {
|
|
51
|
+
const isMediumOrBigger = window.matchMedia( '(min-width: 782px)' ).matches;
|
|
52
52
|
const target = document.getElementById( id );
|
|
53
53
|
const root = createRoot( target );
|
|
54
54
|
|
|
55
55
|
dispatch( preferencesStore ).setDefaults( 'core/edit-post', {
|
|
56
56
|
fullscreenMode: true,
|
|
57
57
|
isPublishSidebarEnabled: true,
|
|
58
|
-
preferredStyleVariations: {},
|
|
59
58
|
themeStyles: true,
|
|
60
59
|
welcomeGuide: true,
|
|
61
60
|
welcomeGuideTemplate: true,
|
|
@@ -77,7 +76,9 @@ export function initializeEditor(
|
|
|
77
76
|
|
|
78
77
|
// Check if the block list view should be open by default.
|
|
79
78
|
// If `distractionFree` mode is enabled, the block list view should not be open.
|
|
79
|
+
// This behavior is disabled for small viewports.
|
|
80
80
|
if (
|
|
81
|
+
isMediumOrBigger &&
|
|
81
82
|
select( preferencesStore ).get( 'core', 'showListViewByDefault' ) &&
|
|
82
83
|
! select( preferencesStore ).get( 'core', 'distractionFree' )
|
|
83
84
|
) {
|
|
@@ -93,48 +94,6 @@ export function initializeEditor(
|
|
|
93
94
|
} );
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
/*
|
|
97
|
-
* Prevent adding template part in the post editor.
|
|
98
|
-
* Only add the filter when the post editor is initialized, not imported.
|
|
99
|
-
* Also only add the filter(s) after registerCoreBlocks()
|
|
100
|
-
* so that common filters in the block library are not overwritten.
|
|
101
|
-
*/
|
|
102
|
-
addFilter(
|
|
103
|
-
'blockEditor.__unstableCanInsertBlockType',
|
|
104
|
-
'removeTemplatePartsFromInserter',
|
|
105
|
-
( canInsert, blockType ) => {
|
|
106
|
-
if ( blockType.name === 'core/template-part' ) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
return canInsert;
|
|
110
|
-
}
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
/*
|
|
114
|
-
* Prevent adding post content block (except in query block) in the post editor.
|
|
115
|
-
* Only add the filter when the post editor is initialized, not imported.
|
|
116
|
-
* Also only add the filter(s) after registerCoreBlocks()
|
|
117
|
-
* so that common filters in the block library are not overwritten.
|
|
118
|
-
*/
|
|
119
|
-
addFilter(
|
|
120
|
-
'blockEditor.__unstableCanInsertBlockType',
|
|
121
|
-
'removePostContentFromInserter',
|
|
122
|
-
(
|
|
123
|
-
canInsert,
|
|
124
|
-
blockType,
|
|
125
|
-
rootClientId,
|
|
126
|
-
{ getBlockParentsByBlockName }
|
|
127
|
-
) => {
|
|
128
|
-
if ( blockType.name === 'core/post-content' ) {
|
|
129
|
-
return (
|
|
130
|
-
getBlockParentsByBlockName( rootClientId, 'core/query' )
|
|
131
|
-
.length > 0
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
return canInsert;
|
|
135
|
-
}
|
|
136
|
-
);
|
|
137
|
-
|
|
138
97
|
// Show a console log warning if the browser is not in Standards rendering mode.
|
|
139
98
|
const documentMode =
|
|
140
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', {
|
package/src/store/actions.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
5
4
|
import apiFetch from '@wordpress/api-fetch';
|
|
6
5
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
7
6
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
8
|
-
import { speak } from '@wordpress/a11y';
|
|
9
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
10
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
11
7
|
import { store as editorStore } from '@wordpress/editor';
|
|
12
8
|
import deprecated from '@wordpress/deprecated';
|
|
13
9
|
import { addFilter } from '@wordpress/hooks';
|
|
@@ -26,13 +22,7 @@ import { unlock } from '../lock-unlock';
|
|
|
26
22
|
*/
|
|
27
23
|
export const openGeneralSidebar =
|
|
28
24
|
( name ) =>
|
|
29
|
-
( {
|
|
30
|
-
const isDistractionFree = registry
|
|
31
|
-
.select( preferencesStore )
|
|
32
|
-
.get( 'core', 'distractionFree' );
|
|
33
|
-
if ( isDistractionFree ) {
|
|
34
|
-
dispatch.toggleDistractionFree();
|
|
35
|
-
}
|
|
25
|
+
( { registry } ) => {
|
|
36
26
|
registry
|
|
37
27
|
.dispatch( interfaceStore )
|
|
38
28
|
.enableComplementaryArea( editPostStore.name, name );
|
|
@@ -190,30 +180,18 @@ export const toggleFeature =
|
|
|
190
180
|
/**
|
|
191
181
|
* Triggers an action used to switch editor mode.
|
|
192
182
|
*
|
|
183
|
+
* @deprecated
|
|
184
|
+
*
|
|
193
185
|
* @param {string} mode The editor mode.
|
|
194
186
|
*/
|
|
195
187
|
export const switchEditorMode =
|
|
196
188
|
( mode ) =>
|
|
197
|
-
( {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (
|
|
206
|
-
mode === 'text' &&
|
|
207
|
-
registry.select( preferencesStore ).get( 'core', 'distractionFree' )
|
|
208
|
-
) {
|
|
209
|
-
dispatch.toggleDistractionFree();
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const message =
|
|
213
|
-
mode === 'visual'
|
|
214
|
-
? __( 'Visual editor selected' )
|
|
215
|
-
: __( 'Code editor selected' );
|
|
216
|
-
speak( message, 'assertive' );
|
|
189
|
+
( { registry } ) => {
|
|
190
|
+
deprecated( "dispatch( 'core/edit-post' ).switchEditorMode", {
|
|
191
|
+
since: '6.6',
|
|
192
|
+
alternative: "dispatch( 'core/editor').switchEditorMode",
|
|
193
|
+
} );
|
|
194
|
+
registry.dispatch( editorStore ).switchEditorMode( mode );
|
|
217
195
|
};
|
|
218
196
|
|
|
219
197
|
/**
|
|
@@ -239,46 +217,15 @@ export const togglePinnedPluginItem =
|
|
|
239
217
|
/**
|
|
240
218
|
* Returns an action object used in signaling that a style should be auto-applied when a block is created.
|
|
241
219
|
*
|
|
242
|
-
* @
|
|
243
|
-
* @param {?string} blockStyle Name of the style that should be auto applied. If undefined, the "auto apply" setting of the block is removed.
|
|
220
|
+
* @deprecated
|
|
244
221
|
*/
|
|
245
|
-
export
|
|
246
|
-
(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
const existingVariations =
|
|
253
|
-
registry
|
|
254
|
-
.select( preferencesStore )
|
|
255
|
-
.get( 'core/edit-post', 'preferredStyleVariations' ) ?? {};
|
|
256
|
-
|
|
257
|
-
// When the blockStyle is omitted, remove the block's preferred variation.
|
|
258
|
-
if ( ! blockStyle ) {
|
|
259
|
-
const updatedVariations = {
|
|
260
|
-
...existingVariations,
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
delete updatedVariations[ blockName ];
|
|
264
|
-
|
|
265
|
-
registry
|
|
266
|
-
.dispatch( preferencesStore )
|
|
267
|
-
.set(
|
|
268
|
-
'core/edit-post',
|
|
269
|
-
'preferredStyleVariations',
|
|
270
|
-
updatedVariations
|
|
271
|
-
);
|
|
272
|
-
} else {
|
|
273
|
-
// Else add the variation.
|
|
274
|
-
registry
|
|
275
|
-
.dispatch( preferencesStore )
|
|
276
|
-
.set( 'core/edit-post', 'preferredStyleVariations', {
|
|
277
|
-
...existingVariations,
|
|
278
|
-
[ blockName ]: blockStyle,
|
|
279
|
-
} );
|
|
280
|
-
}
|
|
281
|
-
};
|
|
222
|
+
export function updatePreferredStyleVariations() {
|
|
223
|
+
deprecated( "dispatch( 'core/edit-post' ).updatePreferredStyleVariations", {
|
|
224
|
+
since: '6.6',
|
|
225
|
+
hint: 'Preferred Style Variations are not supported anymore.',
|
|
226
|
+
} );
|
|
227
|
+
return { type: 'NOTHING' };
|
|
228
|
+
}
|
|
282
229
|
|
|
283
230
|
/**
|
|
284
231
|
* Update the provided block types to be visible.
|
|
@@ -534,64 +481,15 @@ export const initializeMetaBoxes =
|
|
|
534
481
|
* Action that toggles Distraction free mode.
|
|
535
482
|
* Distraction free mode expects there are no sidebars, as due to the
|
|
536
483
|
* z-index values set, you can't close sidebars.
|
|
484
|
+
*
|
|
485
|
+
* @deprecated
|
|
537
486
|
*/
|
|
538
487
|
export const toggleDistractionFree =
|
|
539
488
|
() =>
|
|
540
|
-
( {
|
|
541
|
-
|
|
542
|
-
.
|
|
543
|
-
|
|
544
|
-
if ( isDistractionFree ) {
|
|
545
|
-
registry
|
|
546
|
-
.dispatch( preferencesStore )
|
|
547
|
-
.set( 'core', 'fixedToolbar', false );
|
|
548
|
-
}
|
|
549
|
-
if ( ! isDistractionFree ) {
|
|
550
|
-
registry.batch( () => {
|
|
551
|
-
registry
|
|
552
|
-
.dispatch( preferencesStore )
|
|
553
|
-
.set( 'core', 'fixedToolbar', true );
|
|
554
|
-
registry.dispatch( editorStore ).setIsInserterOpened( false );
|
|
555
|
-
registry.dispatch( editorStore ).setIsListViewOpened( false );
|
|
556
|
-
dispatch.closeGeneralSidebar();
|
|
557
|
-
} );
|
|
558
|
-
}
|
|
559
|
-
registry.batch( () => {
|
|
560
|
-
registry
|
|
561
|
-
.dispatch( preferencesStore )
|
|
562
|
-
.set( 'core', 'distractionFree', ! isDistractionFree );
|
|
563
|
-
registry
|
|
564
|
-
.dispatch( noticesStore )
|
|
565
|
-
.createInfoNotice(
|
|
566
|
-
isDistractionFree
|
|
567
|
-
? __( 'Distraction free off.' )
|
|
568
|
-
: __( 'Distraction free on.' ),
|
|
569
|
-
{
|
|
570
|
-
id: 'core/edit-post/distraction-free-mode/notice',
|
|
571
|
-
type: 'snackbar',
|
|
572
|
-
actions: [
|
|
573
|
-
{
|
|
574
|
-
label: __( 'Undo' ),
|
|
575
|
-
onClick: () => {
|
|
576
|
-
registry.batch( () => {
|
|
577
|
-
registry
|
|
578
|
-
.dispatch( preferencesStore )
|
|
579
|
-
.set(
|
|
580
|
-
'core',
|
|
581
|
-
'fixedToolbar',
|
|
582
|
-
isDistractionFree ? true : false
|
|
583
|
-
);
|
|
584
|
-
registry
|
|
585
|
-
.dispatch( preferencesStore )
|
|
586
|
-
.toggle(
|
|
587
|
-
'core',
|
|
588
|
-
'distractionFree'
|
|
589
|
-
);
|
|
590
|
-
} );
|
|
591
|
-
},
|
|
592
|
-
},
|
|
593
|
-
],
|
|
594
|
-
}
|
|
595
|
-
);
|
|
489
|
+
( { registry } ) => {
|
|
490
|
+
deprecated( "dispatch( 'core/edit-post' ).toggleDistractionFree", {
|
|
491
|
+
since: '6.6',
|
|
492
|
+
alternative: "dispatch( 'core/editor').toggleDistractionFree",
|
|
596
493
|
} );
|
|
494
|
+
registry.dispatch( editorStore ).toggleDistractionFree();
|
|
597
495
|
};
|
package/src/store/selectors.js
CHANGED
|
@@ -161,23 +161,6 @@ export const getPreferences = createRegistrySelector( ( select ) => () => {
|
|
|
161
161
|
alternative: `select( 'core/preferences' ).get`,
|
|
162
162
|
} );
|
|
163
163
|
|
|
164
|
-
// These preferences now exist in the preferences store.
|
|
165
|
-
// Fetch them so that they can be merged into the post
|
|
166
|
-
// editor preferences.
|
|
167
|
-
const preferences = [ 'preferredStyleVariations' ].reduce(
|
|
168
|
-
( accumulatedPrefs, preferenceKey ) => {
|
|
169
|
-
const value = select( preferencesStore ).get(
|
|
170
|
-
'core/edit-post',
|
|
171
|
-
preferenceKey
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
return {
|
|
175
|
-
...accumulatedPrefs,
|
|
176
|
-
[ preferenceKey ]: value,
|
|
177
|
-
};
|
|
178
|
-
},
|
|
179
|
-
{}
|
|
180
|
-
);
|
|
181
164
|
const corePreferences = [ 'editorMode', 'hiddenBlockTypes' ].reduce(
|
|
182
165
|
( accumulatedPrefs, preferenceKey ) => {
|
|
183
166
|
const value = select( preferencesStore ).get(
|
|
@@ -205,7 +188,6 @@ export const getPreferences = createRegistrySelector( ( select ) => () => {
|
|
|
205
188
|
const panels = convertPanelsToOldFormat( inactivePanels, openPanels );
|
|
206
189
|
|
|
207
190
|
return {
|
|
208
|
-
...preferences,
|
|
209
191
|
...corePreferences,
|
|
210
192
|
panels,
|
|
211
193
|
};
|