@wordpress/editor 13.25.0 → 13.26.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 +6 -0
- package/LICENSE.md +1 -1
- package/build/components/document-bar/index.js +19 -7
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-outline/index.js +82 -1
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-tools/index.js +160 -0
- package/build/components/document-tools/index.js.map +1 -0
- package/build/components/editor-canvas/index.js +10 -4
- package/build/components/editor-canvas/index.js.map +1 -1
- package/build/components/entities-saved-states/index.js +3 -1
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/index.js +12 -2
- package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +9 -0
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/index.js +56 -8
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +9 -1
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +77 -0
- package/build/components/inserter-sidebar/index.js.map +1 -0
- package/build/components/list-view-sidebar/index.js +150 -0
- package/build/components/list-view-sidebar/index.js.map +1 -0
- package/build/components/list-view-sidebar/list-view-outline.js +28 -0
- package/build/components/list-view-sidebar/list-view-outline.js.map +1 -0
- package/build/components/offline-status/index.native.js +85 -0
- package/build/components/offline-status/index.native.js.map +1 -0
- package/build/components/page-attributes/panel.js +63 -0
- package/build/components/page-attributes/panel.js.map +1 -0
- package/build/components/post-discussion/panel.js +59 -0
- package/build/components/post-discussion/panel.js.map +1 -0
- package/build/components/post-excerpt/check.js +19 -0
- package/build/components/post-excerpt/check.js.map +1 -1
- package/build/components/post-excerpt/panel.js +55 -0
- package/build/components/post-excerpt/panel.js.map +1 -0
- package/build/components/post-excerpt/plugin.js +72 -0
- package/build/components/post-excerpt/plugin.js.map +1 -0
- package/build/components/post-featured-image/index.js +5 -8
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-featured-image/panel.js +60 -0
- package/build/components/post-featured-image/panel.js.map +1 -0
- package/build/components/post-last-revision/panel.js +27 -0
- package/build/components/post-last-revision/panel.js.map +1 -0
- package/build/components/post-saved-state/index.js +12 -8
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-taxonomies/panel.js +68 -0
- package/build/components/post-taxonomies/panel.js.map +1 -0
- package/build/components/post-template/block-theme.js +2 -1
- package/build/components/post-template/block-theme.js.map +1 -1
- package/build/components/post-template/hooks.js +6 -6
- package/build/components/post-template/hooks.js.map +1 -1
- package/build/components/post-template/panel.js +1 -2
- package/build/components/post-template/panel.js.map +1 -1
- package/build/components/post-template/swap-template-button.js +4 -2
- package/build/components/post-template/swap-template-button.js.map +1 -1
- package/build/components/post-title/index.native.js +25 -14
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-view-link/index.js +58 -0
- package/build/components/post-view-link/index.js.map +1 -0
- package/build/components/post-visibility/check.js +5 -17
- package/build/components/post-visibility/check.js.map +1 -1
- package/build/components/preview-dropdown/index.js +8 -3
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build/components/provider/index.native.js +19 -0
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +29 -5
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/private-apis.js +10 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +102 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +2 -0
- package/build/store/index.js.map +1 -1
- package/build/store/private-selectors.js +52 -0
- package/build/store/private-selectors.js.map +1 -0
- package/build/store/reducer.js +78 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +76 -2
- package/build/store/selectors.js.map +1 -1
- package/build/utils/media-upload/index.js +8 -2
- package/build/utils/media-upload/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +19 -7
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/document-outline/index.js +82 -1
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/document-tools/index.js +151 -0
- package/build-module/components/document-tools/index.js.map +1 -0
- package/build-module/components/editor-canvas/index.js +10 -4
- package/build-module/components/editor-canvas/index.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +3 -1
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/index.js +12 -2
- package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +9 -0
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build-module/components/index.js +6 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +70 -0
- package/build-module/components/inserter-sidebar/index.js.map +1 -0
- package/build-module/components/list-view-sidebar/index.js +142 -0
- package/build-module/components/list-view-sidebar/index.js.map +1 -0
- package/build-module/components/list-view-sidebar/list-view-outline.js +20 -0
- package/build-module/components/list-view-sidebar/list-view-outline.js.map +1 -0
- package/build-module/components/offline-status/index.native.js +77 -0
- package/build-module/components/offline-status/index.native.js.map +1 -0
- package/build-module/components/page-attributes/panel.js +53 -0
- package/build-module/components/page-attributes/panel.js.map +1 -0
- package/build-module/components/post-discussion/panel.js +50 -0
- package/build-module/components/post-discussion/panel.js.map +1 -0
- package/build-module/components/post-excerpt/check.js +19 -0
- package/build-module/components/post-excerpt/check.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +48 -0
- package/build-module/components/post-excerpt/panel.js.map +1 -0
- package/build-module/components/post-excerpt/plugin.js +64 -0
- package/build-module/components/post-excerpt/plugin.js.map +1 -0
- package/build-module/components/post-featured-image/index.js +5 -8
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-featured-image/panel.js +51 -0
- package/build-module/components/post-featured-image/panel.js.map +1 -0
- package/build-module/components/post-last-revision/panel.js +18 -0
- package/build-module/components/post-last-revision/panel.js.map +1 -0
- package/build-module/components/post-saved-state/index.js +12 -8
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-taxonomies/panel.js +59 -0
- package/build-module/components/post-taxonomies/panel.js.map +1 -0
- package/build-module/components/post-template/block-theme.js +2 -1
- package/build-module/components/post-template/block-theme.js.map +1 -1
- package/build-module/components/post-template/hooks.js +6 -6
- package/build-module/components/post-template/hooks.js.map +1 -1
- package/build-module/components/post-template/panel.js +1 -2
- package/build-module/components/post-template/panel.js.map +1 -1
- package/build-module/components/post-template/swap-template-button.js +4 -2
- package/build-module/components/post-template/swap-template-button.js.map +1 -1
- package/build-module/components/post-title/index.native.js +26 -15
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/post-view-link/index.js +51 -0
- package/build-module/components/post-view-link/index.js.map +1 -0
- package/build-module/components/post-visibility/check.js +6 -16
- package/build-module/components/post-visibility/check.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +8 -3
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +19 -0
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +29 -5
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/private-apis.js +10 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +94 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +2 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-selectors.js +43 -0
- package/build-module/store/private-selectors.js.map +1 -0
- package/build-module/store/reducer.js +74 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +67 -0
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/media-upload/index.js +8 -2
- package/build-module/utils/media-upload/index.js.map +1 -1
- package/build-style/style-rtl.css +251 -0
- package/build-style/style.css +251 -0
- package/package.json +32 -32
- package/src/components/document-bar/index.js +39 -28
- package/src/components/document-outline/index.js +48 -1
- package/src/components/document-outline/style.scss +12 -0
- package/src/components/document-tools/index.js +177 -0
- package/src/components/document-tools/style.scss +98 -0
- package/src/components/editor-canvas/index.js +12 -7
- package/src/components/editor-canvas/style.scss +5 -0
- package/src/components/entities-saved-states/index.js +3 -1
- package/src/components/entities-saved-states/style.scss +4 -0
- package/src/components/global-keyboard-shortcuts/index.js +12 -2
- package/src/components/global-keyboard-shortcuts/register-shortcuts.js +10 -0
- package/src/components/index.js +6 -0
- package/src/components/index.native.js +1 -0
- package/src/components/inserter-sidebar/index.js +73 -0
- package/src/components/inserter-sidebar/style.scss +22 -0
- package/src/components/list-view-sidebar/index.js +169 -0
- package/src/components/list-view-sidebar/list-view-outline.js +37 -0
- package/src/components/list-view-sidebar/style.scss +84 -0
- package/src/components/offline-status/index.native.js +101 -0
- package/src/components/offline-status/style.native.scss +28 -0
- package/src/components/offline-status/test/index.native.js +108 -0
- package/src/components/page-attributes/panel.js +62 -0
- package/src/components/post-discussion/panel.js +57 -0
- package/src/components/post-excerpt/check.js +18 -0
- package/src/components/post-excerpt/panel.js +57 -0
- package/src/components/post-excerpt/plugin.js +61 -0
- package/src/components/post-excerpt/test/plugin.js +36 -0
- package/src/components/post-featured-image/index.js +3 -7
- package/src/components/post-featured-image/panel.js +55 -0
- package/src/components/post-last-revision/panel.js +22 -0
- package/src/components/post-last-revision/style.scss +10 -0
- package/src/components/post-saved-state/index.js +8 -8
- package/src/components/post-taxonomies/panel.js +66 -0
- package/src/components/post-template/block-theme.js +2 -1
- package/src/components/post-template/hooks.js +6 -6
- package/src/components/post-template/panel.js +1 -2
- package/src/components/post-template/swap-template-button.js +7 -4
- package/src/components/post-title/index.native.js +32 -17
- package/src/components/post-title/style.scss +1 -0
- package/src/components/post-title/test/__snapshots__/index.native.js.snap +25 -0
- package/src/components/post-title/test/index.native.js +78 -0
- package/src/components/post-view-link/index.js +47 -0
- package/src/components/post-visibility/check.js +10 -15
- package/src/components/post-visibility/test/check.js +24 -13
- package/src/components/preview-dropdown/index.js +7 -10
- package/src/components/provider/index.native.js +29 -2
- package/src/components/provider/use-block-editor-settings.js +36 -8
- package/src/private-apis.js +10 -0
- package/src/store/actions.js +109 -0
- package/src/store/index.js +2 -0
- package/src/store/private-selectors.js +51 -0
- package/src/store/reducer.js +72 -0
- package/src/store/selectors.js +80 -0
- package/src/store/test/actions.js +56 -0
- package/src/store/test/reducer.js +98 -0
- package/src/store/test/selectors.js +49 -0
- package/src/style.scss +4 -0
- package/src/utils/media-upload/index.js +9 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
5
|
+
import { createRegistrySelector } from '@wordpress/data';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { getRenderingMode } from './selectors';
|
|
11
|
+
|
|
12
|
+
const EMPTY_INSERTION_POINT = {
|
|
13
|
+
rootClientId: undefined,
|
|
14
|
+
insertionIndex: undefined,
|
|
15
|
+
filterValue: undefined,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get the insertion point for the inserter.
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} state Global application state.
|
|
22
|
+
*
|
|
23
|
+
* @return {Object} The root client ID, index to insert at and starting filter value.
|
|
24
|
+
*/
|
|
25
|
+
export const getInsertionPoint = createRegistrySelector(
|
|
26
|
+
( select ) => ( state ) => {
|
|
27
|
+
if ( typeof state.blockInserterPanel === 'object' ) {
|
|
28
|
+
return state.blockInserterPanel;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if ( getRenderingMode( state ) === 'template-locked' ) {
|
|
32
|
+
const [ postContentClientId ] =
|
|
33
|
+
select( blockEditorStore ).__experimentalGetGlobalBlocksByName(
|
|
34
|
+
'core/post-content'
|
|
35
|
+
);
|
|
36
|
+
if ( postContentClientId ) {
|
|
37
|
+
return {
|
|
38
|
+
rootClientId: postContentClientId,
|
|
39
|
+
insertionIndex: undefined,
|
|
40
|
+
filterValue: undefined,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return EMPTY_INSERTION_POINT;
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export function getListViewToggleRef( state ) {
|
|
50
|
+
return state.listViewToggleRef;
|
|
51
|
+
}
|
package/src/store/reducer.js
CHANGED
|
@@ -292,6 +292,74 @@ export function deviceType( state = 'Desktop', action ) {
|
|
|
292
292
|
return state;
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
+
/**
|
|
296
|
+
* Reducer storing the list of all programmatically removed panels.
|
|
297
|
+
*
|
|
298
|
+
* @param {Array} state Current state.
|
|
299
|
+
* @param {Object} action Action object.
|
|
300
|
+
*
|
|
301
|
+
* @return {Array} Updated state.
|
|
302
|
+
*/
|
|
303
|
+
export function removedPanels( state = [], action ) {
|
|
304
|
+
switch ( action.type ) {
|
|
305
|
+
case 'REMOVE_PANEL':
|
|
306
|
+
if ( ! state.includes( action.panelName ) ) {
|
|
307
|
+
return [ ...state, action.panelName ];
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return state;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Reducer to set the block inserter panel open or closed.
|
|
316
|
+
*
|
|
317
|
+
* Note: this reducer interacts with the list view panel reducer
|
|
318
|
+
* to make sure that only one of the two panels is open at the same time.
|
|
319
|
+
*
|
|
320
|
+
* @param {Object} state Current state.
|
|
321
|
+
* @param {Object} action Dispatched action.
|
|
322
|
+
*/
|
|
323
|
+
export function blockInserterPanel( state = false, action ) {
|
|
324
|
+
switch ( action.type ) {
|
|
325
|
+
case 'SET_IS_LIST_VIEW_OPENED':
|
|
326
|
+
return action.isOpen ? false : state;
|
|
327
|
+
case 'SET_IS_INSERTER_OPENED':
|
|
328
|
+
return action.value;
|
|
329
|
+
}
|
|
330
|
+
return state;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Reducer to set the list view panel open or closed.
|
|
335
|
+
*
|
|
336
|
+
* Note: this reducer interacts with the inserter panel reducer
|
|
337
|
+
* to make sure that only one of the two panels is open at the same time.
|
|
338
|
+
*
|
|
339
|
+
* @param {Object} state Current state.
|
|
340
|
+
* @param {Object} action Dispatched action.
|
|
341
|
+
*/
|
|
342
|
+
export function listViewPanel( state = false, action ) {
|
|
343
|
+
switch ( action.type ) {
|
|
344
|
+
case 'SET_IS_INSERTER_OPENED':
|
|
345
|
+
return action.value ? false : state;
|
|
346
|
+
case 'SET_IS_LIST_VIEW_OPENED':
|
|
347
|
+
return action.isOpen;
|
|
348
|
+
}
|
|
349
|
+
return state;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* This reducer does nothing aside initializing a ref to the list view toggle.
|
|
354
|
+
* We will have a unique ref per "editor" instance.
|
|
355
|
+
*
|
|
356
|
+
* @param {Object} state
|
|
357
|
+
* @return {Object} Reference to the list view toggle button.
|
|
358
|
+
*/
|
|
359
|
+
export function listViewToggleRef( state = { current: null } ) {
|
|
360
|
+
return state;
|
|
361
|
+
}
|
|
362
|
+
|
|
295
363
|
export default combineReducers( {
|
|
296
364
|
postId,
|
|
297
365
|
postType,
|
|
@@ -305,4 +373,8 @@ export default combineReducers( {
|
|
|
305
373
|
postAutosavingLock,
|
|
306
374
|
renderingMode,
|
|
307
375
|
deviceType,
|
|
376
|
+
removedPanels,
|
|
377
|
+
blockInserterPanel,
|
|
378
|
+
listViewPanel,
|
|
379
|
+
listViewToggleRef,
|
|
308
380
|
} );
|
package/src/store/selectors.js
CHANGED
|
@@ -1125,6 +1125,64 @@ export const getEditorBlocks = createSelector(
|
|
|
1125
1125
|
]
|
|
1126
1126
|
);
|
|
1127
1127
|
|
|
1128
|
+
/**
|
|
1129
|
+
* Returns true if the given panel was programmatically removed, or false otherwise.
|
|
1130
|
+
* All panels are not removed by default.
|
|
1131
|
+
*
|
|
1132
|
+
* @param {Object} state Global application state.
|
|
1133
|
+
* @param {string} panelName A string that identifies the panel.
|
|
1134
|
+
*
|
|
1135
|
+
* @return {boolean} Whether or not the panel is removed.
|
|
1136
|
+
*/
|
|
1137
|
+
export function isEditorPanelRemoved( state, panelName ) {
|
|
1138
|
+
return state.removedPanels.includes( panelName );
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
* Returns true if the given panel is enabled, or false otherwise. Panels are
|
|
1143
|
+
* enabled by default.
|
|
1144
|
+
*
|
|
1145
|
+
* @param {Object} state Global application state.
|
|
1146
|
+
* @param {string} panelName A string that identifies the panel.
|
|
1147
|
+
*
|
|
1148
|
+
* @return {boolean} Whether or not the panel is enabled.
|
|
1149
|
+
*/
|
|
1150
|
+
export const isEditorPanelEnabled = createRegistrySelector(
|
|
1151
|
+
( select ) => ( state, panelName ) => {
|
|
1152
|
+
// For backward compatibility, we check edit-post
|
|
1153
|
+
// even though now this is in "editor" package.
|
|
1154
|
+
const inactivePanels = select( preferencesStore ).get(
|
|
1155
|
+
'core',
|
|
1156
|
+
'inactivePanels'
|
|
1157
|
+
);
|
|
1158
|
+
return (
|
|
1159
|
+
! isEditorPanelRemoved( state, panelName ) &&
|
|
1160
|
+
! inactivePanels?.includes( panelName )
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1163
|
+
);
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* Returns true if the given panel is open, or false otherwise. Panels are
|
|
1167
|
+
* closed by default.
|
|
1168
|
+
*
|
|
1169
|
+
* @param {Object} state Global application state.
|
|
1170
|
+
* @param {string} panelName A string that identifies the panel.
|
|
1171
|
+
*
|
|
1172
|
+
* @return {boolean} Whether or not the panel is open.
|
|
1173
|
+
*/
|
|
1174
|
+
export const isEditorPanelOpened = createRegistrySelector(
|
|
1175
|
+
( select ) => ( state, panelName ) => {
|
|
1176
|
+
// For backward compatibility, we check edit-post
|
|
1177
|
+
// even though now this is in "editor" package.
|
|
1178
|
+
const openPanels = select( preferencesStore ).get(
|
|
1179
|
+
'core',
|
|
1180
|
+
'openPanels'
|
|
1181
|
+
);
|
|
1182
|
+
return !! openPanels?.includes( panelName );
|
|
1183
|
+
}
|
|
1184
|
+
);
|
|
1185
|
+
|
|
1128
1186
|
/**
|
|
1129
1187
|
* A block selection object.
|
|
1130
1188
|
*
|
|
@@ -1221,6 +1279,28 @@ export function getDeviceType( state ) {
|
|
|
1221
1279
|
return state.deviceType;
|
|
1222
1280
|
}
|
|
1223
1281
|
|
|
1282
|
+
/**
|
|
1283
|
+
* Returns true if the list view is opened.
|
|
1284
|
+
*
|
|
1285
|
+
* @param {Object} state Global application state.
|
|
1286
|
+
*
|
|
1287
|
+
* @return {boolean} Whether the list view is opened.
|
|
1288
|
+
*/
|
|
1289
|
+
export function isListViewOpened( state ) {
|
|
1290
|
+
return state.listViewPanel;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* Returns true if the inserter is opened.
|
|
1295
|
+
*
|
|
1296
|
+
* @param {Object} state Global application state.
|
|
1297
|
+
*
|
|
1298
|
+
* @return {boolean} Whether the inserter is opened.
|
|
1299
|
+
*/
|
|
1300
|
+
export function isInserterOpened( state ) {
|
|
1301
|
+
return !! state.blockInserterPanel;
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1224
1304
|
/*
|
|
1225
1305
|
* Backward compatibility
|
|
1226
1306
|
*/
|
|
@@ -432,4 +432,60 @@ describe( 'Editor actions', () => {
|
|
|
432
432
|
).toBe( false );
|
|
433
433
|
} );
|
|
434
434
|
} );
|
|
435
|
+
|
|
436
|
+
describe( 'toggleEditorPanelEnabled', () => {
|
|
437
|
+
it( 'toggles panels to be enabled and not enabled', () => {
|
|
438
|
+
const registry = createRegistryWithStores();
|
|
439
|
+
|
|
440
|
+
// This will switch it off, since the default is on.
|
|
441
|
+
registry
|
|
442
|
+
.dispatch( editorStore )
|
|
443
|
+
.toggleEditorPanelEnabled( 'control-panel' );
|
|
444
|
+
|
|
445
|
+
expect(
|
|
446
|
+
registry
|
|
447
|
+
.select( editorStore )
|
|
448
|
+
.isEditorPanelEnabled( 'control-panel' )
|
|
449
|
+
).toBe( false );
|
|
450
|
+
|
|
451
|
+
// Switch it on again.
|
|
452
|
+
registry
|
|
453
|
+
.dispatch( editorStore )
|
|
454
|
+
.toggleEditorPanelEnabled( 'control-panel' );
|
|
455
|
+
|
|
456
|
+
expect(
|
|
457
|
+
registry
|
|
458
|
+
.select( editorStore )
|
|
459
|
+
.isEditorPanelEnabled( 'control-panel' )
|
|
460
|
+
).toBe( true );
|
|
461
|
+
} );
|
|
462
|
+
} );
|
|
463
|
+
|
|
464
|
+
describe( 'toggleEditorPanelOpened', () => {
|
|
465
|
+
it( 'toggles panels open and closed', () => {
|
|
466
|
+
const registry = createRegistryWithStores();
|
|
467
|
+
|
|
468
|
+
// This will open it, since the default is closed.
|
|
469
|
+
registry
|
|
470
|
+
.dispatch( editorStore )
|
|
471
|
+
.toggleEditorPanelOpened( 'control-panel' );
|
|
472
|
+
|
|
473
|
+
expect(
|
|
474
|
+
registry
|
|
475
|
+
.select( editorStore )
|
|
476
|
+
.isEditorPanelOpened( 'control-panel' )
|
|
477
|
+
).toBe( true );
|
|
478
|
+
|
|
479
|
+
// Close it.
|
|
480
|
+
registry
|
|
481
|
+
.dispatch( editorStore )
|
|
482
|
+
.toggleEditorPanelOpened( 'control-panel' );
|
|
483
|
+
|
|
484
|
+
expect(
|
|
485
|
+
registry
|
|
486
|
+
.select( editorStore )
|
|
487
|
+
.isEditorPanelOpened( 'control-panel' )
|
|
488
|
+
).toBe( false );
|
|
489
|
+
} );
|
|
490
|
+
} );
|
|
435
491
|
} );
|
|
@@ -14,7 +14,11 @@ import {
|
|
|
14
14
|
saving,
|
|
15
15
|
postSavingLock,
|
|
16
16
|
postAutosavingLock,
|
|
17
|
+
removedPanels,
|
|
18
|
+
blockInserterPanel,
|
|
19
|
+
listViewPanel,
|
|
17
20
|
} from '../reducer';
|
|
21
|
+
import { setIsInserterOpened } from '../actions';
|
|
18
22
|
|
|
19
23
|
describe( 'state', () => {
|
|
20
24
|
describe( 'hasSameKeys()', () => {
|
|
@@ -264,4 +268,98 @@ describe( 'state', () => {
|
|
|
264
268
|
expect( state ).toEqual( {} );
|
|
265
269
|
} );
|
|
266
270
|
} );
|
|
271
|
+
|
|
272
|
+
describe( 'removedPanels', () => {
|
|
273
|
+
it( 'should remove panel', () => {
|
|
274
|
+
const original = deepFreeze( [] );
|
|
275
|
+
const state = removedPanels( original, {
|
|
276
|
+
type: 'REMOVE_PANEL',
|
|
277
|
+
panelName: 'post-status',
|
|
278
|
+
} );
|
|
279
|
+
expect( state ).toEqual( [ 'post-status' ] );
|
|
280
|
+
} );
|
|
281
|
+
|
|
282
|
+
it( 'should not remove already removed panel', () => {
|
|
283
|
+
const original = deepFreeze( [ 'post-status' ] );
|
|
284
|
+
const state = removedPanels( original, {
|
|
285
|
+
type: 'REMOVE_PANEL',
|
|
286
|
+
panelName: 'post-status',
|
|
287
|
+
} );
|
|
288
|
+
expect( state ).toBe( original );
|
|
289
|
+
} );
|
|
290
|
+
} );
|
|
291
|
+
|
|
292
|
+
describe( 'blockInserterPanel()', () => {
|
|
293
|
+
it( 'should apply default state', () => {
|
|
294
|
+
expect( blockInserterPanel( undefined, {} ) ).toEqual( false );
|
|
295
|
+
} );
|
|
296
|
+
|
|
297
|
+
it( 'should default to returning the same state', () => {
|
|
298
|
+
expect( blockInserterPanel( true, {} ) ).toBe( true );
|
|
299
|
+
} );
|
|
300
|
+
|
|
301
|
+
it( 'should set the open state of the inserter panel', () => {
|
|
302
|
+
expect(
|
|
303
|
+
blockInserterPanel( false, setIsInserterOpened( true ) )
|
|
304
|
+
).toBe( true );
|
|
305
|
+
expect(
|
|
306
|
+
blockInserterPanel( true, setIsInserterOpened( false ) )
|
|
307
|
+
).toBe( false );
|
|
308
|
+
} );
|
|
309
|
+
|
|
310
|
+
it( 'should close the inserter when opening the list view panel', () => {
|
|
311
|
+
expect(
|
|
312
|
+
blockInserterPanel( true, {
|
|
313
|
+
type: 'SET_IS_LIST_VIEW_OPENED',
|
|
314
|
+
isOpen: true,
|
|
315
|
+
} )
|
|
316
|
+
).toBe( false );
|
|
317
|
+
} );
|
|
318
|
+
|
|
319
|
+
it( 'should not change the state when closing the list view panel', () => {
|
|
320
|
+
expect(
|
|
321
|
+
blockInserterPanel( true, {
|
|
322
|
+
type: 'SET_IS_LIST_VIEW_OPENED',
|
|
323
|
+
isOpen: false,
|
|
324
|
+
} )
|
|
325
|
+
).toBe( true );
|
|
326
|
+
} );
|
|
327
|
+
} );
|
|
328
|
+
|
|
329
|
+
describe( 'listViewPanel()', () => {
|
|
330
|
+
it( 'should apply default state', () => {
|
|
331
|
+
expect( listViewPanel( undefined, {} ) ).toEqual( false );
|
|
332
|
+
} );
|
|
333
|
+
|
|
334
|
+
it( 'should default to returning the same state', () => {
|
|
335
|
+
expect( listViewPanel( true, {} ) ).toBe( true );
|
|
336
|
+
} );
|
|
337
|
+
|
|
338
|
+
it( 'should set the open state of the list view panel', () => {
|
|
339
|
+
expect(
|
|
340
|
+
listViewPanel( false, {
|
|
341
|
+
type: 'SET_IS_LIST_VIEW_OPENED',
|
|
342
|
+
isOpen: true,
|
|
343
|
+
} )
|
|
344
|
+
).toBe( true );
|
|
345
|
+
expect(
|
|
346
|
+
listViewPanel( true, {
|
|
347
|
+
type: 'SET_IS_LIST_VIEW_OPENED',
|
|
348
|
+
isOpen: false,
|
|
349
|
+
} )
|
|
350
|
+
).toBe( false );
|
|
351
|
+
} );
|
|
352
|
+
|
|
353
|
+
it( 'should close the list view when opening the inserter panel', () => {
|
|
354
|
+
expect( listViewPanel( true, setIsInserterOpened( true ) ) ).toBe(
|
|
355
|
+
false
|
|
356
|
+
);
|
|
357
|
+
} );
|
|
358
|
+
|
|
359
|
+
it( 'should not change the state when closing the inserter panel', () => {
|
|
360
|
+
expect( listViewPanel( true, setIsInserterOpened( false ) ) ).toBe(
|
|
361
|
+
true
|
|
362
|
+
);
|
|
363
|
+
} );
|
|
364
|
+
} );
|
|
267
365
|
} );
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import deepFreeze from 'deep-freeze';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -187,6 +192,9 @@ const {
|
|
|
187
192
|
__experimentalGetDefaultTemplateTypes,
|
|
188
193
|
__experimentalGetTemplateInfo,
|
|
189
194
|
__experimentalGetDefaultTemplatePartAreas,
|
|
195
|
+
isEditorPanelRemoved,
|
|
196
|
+
isInserterOpened,
|
|
197
|
+
isListViewOpened,
|
|
190
198
|
} = selectors;
|
|
191
199
|
|
|
192
200
|
const defaultTemplateTypes = [
|
|
@@ -3010,4 +3018,45 @@ describe( 'selectors', () => {
|
|
|
3010
3018
|
);
|
|
3011
3019
|
} );
|
|
3012
3020
|
} );
|
|
3021
|
+
describe( 'isEditorPanelRemoved', () => {
|
|
3022
|
+
it( 'should return false by default', () => {
|
|
3023
|
+
const state = deepFreeze( {
|
|
3024
|
+
removedPanels: [],
|
|
3025
|
+
} );
|
|
3026
|
+
|
|
3027
|
+
expect( isEditorPanelRemoved( state, 'post-status' ) ).toBe(
|
|
3028
|
+
false
|
|
3029
|
+
);
|
|
3030
|
+
} );
|
|
3031
|
+
|
|
3032
|
+
it( 'should return true when panel was removed', () => {
|
|
3033
|
+
const state = deepFreeze( {
|
|
3034
|
+
removedPanels: [ 'post-status' ],
|
|
3035
|
+
} );
|
|
3036
|
+
|
|
3037
|
+
expect( isEditorPanelRemoved( state, 'post-status' ) ).toBe( true );
|
|
3038
|
+
} );
|
|
3039
|
+
} );
|
|
3040
|
+
|
|
3041
|
+
describe( 'isInserterOpened', () => {
|
|
3042
|
+
it( 'returns the block inserter panel isOpened state', () => {
|
|
3043
|
+
const state = {
|
|
3044
|
+
blockInserterPanel: true,
|
|
3045
|
+
};
|
|
3046
|
+
expect( isInserterOpened( state ) ).toBe( true );
|
|
3047
|
+
state.blockInserterPanel = false;
|
|
3048
|
+
expect( isInserterOpened( state ) ).toBe( false );
|
|
3049
|
+
} );
|
|
3050
|
+
} );
|
|
3051
|
+
|
|
3052
|
+
describe( 'isListViewOpened', () => {
|
|
3053
|
+
it( 'returns the list view panel isOpened state', () => {
|
|
3054
|
+
const state = {
|
|
3055
|
+
listViewPanel: true,
|
|
3056
|
+
};
|
|
3057
|
+
expect( isListViewOpened( state ) ).toBe( true );
|
|
3058
|
+
state.listViewPanel = false;
|
|
3059
|
+
expect( isListViewOpened( state ) ).toBe( false );
|
|
3060
|
+
} );
|
|
3061
|
+
} );
|
|
3013
3062
|
} );
|
package/src/style.scss
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
@import "./components/autocompleters/style.scss";
|
|
2
2
|
@import "./components/document-bar/style.scss";
|
|
3
3
|
@import "./components/document-outline/style.scss";
|
|
4
|
+
@import "./components/document-tools/style.scss";
|
|
4
5
|
@import "./components/editor-notices/style.scss";
|
|
5
6
|
@import "./components/entities-saved-states/style.scss";
|
|
6
7
|
@import "./components/error-boundary/style.scss";
|
|
8
|
+
@import "./components/inserter-sidebar/style.scss";
|
|
9
|
+
@import "./components/list-view-sidebar/style.scss";
|
|
7
10
|
@import "./components/post-author/style.scss";
|
|
8
11
|
@import "./components/post-excerpt/style.scss";
|
|
9
12
|
@import "./components/post-featured-image/style.scss";
|
|
@@ -26,3 +29,4 @@
|
|
|
26
29
|
@import "./components/preview-dropdown/style.scss";
|
|
27
30
|
@import "./components/table-of-contents/style.scss";
|
|
28
31
|
@import "./components/template-validation-notice/style.scss";
|
|
32
|
+
@import "./components/editor-canvas/style.scss";
|
|
@@ -31,17 +31,24 @@ export default function mediaUpload( {
|
|
|
31
31
|
onError = noop,
|
|
32
32
|
onFileChange,
|
|
33
33
|
} ) {
|
|
34
|
-
const {
|
|
34
|
+
const { getCurrentPost, getEditorSettings } = select( editorStore );
|
|
35
35
|
const wpAllowedMimeTypes = getEditorSettings().allowedMimeTypes;
|
|
36
36
|
maxUploadFileSize =
|
|
37
37
|
maxUploadFileSize || getEditorSettings().maxUploadFileSize;
|
|
38
|
+
const currentPost = getCurrentPost();
|
|
39
|
+
// Templates and template parts' numerical ID is stored in `wp_id`.
|
|
40
|
+
const currentPostId =
|
|
41
|
+
typeof currentPost?.id === 'number'
|
|
42
|
+
? currentPost.id
|
|
43
|
+
: currentPost?.wp_id;
|
|
44
|
+
const postData = currentPostId ? { post: currentPostId } : {};
|
|
38
45
|
|
|
39
46
|
uploadMedia( {
|
|
40
47
|
allowedTypes,
|
|
41
48
|
filesList,
|
|
42
49
|
onFileChange,
|
|
43
50
|
additionalData: {
|
|
44
|
-
|
|
51
|
+
...postData,
|
|
45
52
|
...additionalData,
|
|
46
53
|
},
|
|
47
54
|
maxUploadFileSize,
|