@wordpress/edit-post 6.0.1 → 6.1.0-next.e230fbab09.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/build/components/block-manager/category.js +2 -2
- package/build/components/block-manager/category.js.map +1 -1
- package/build/components/block-manager/index.js +2 -2
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/header/fullscreen-mode-close/index.js +11 -4
- package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.js +1 -1
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.native.js +1 -1
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/index.js +3 -1
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +0 -6
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/template-title/delete-template.js +29 -20
- package/build/components/header/template-title/delete-template.js.map +1 -1
- package/build/components/header/writing-menu/index.js +7 -7
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +5 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js +1 -1
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/preferences-modal/index.js +14 -136
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preferences-modal/meta-boxes-section.js +2 -4
- package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build/components/preferences-modal/options/enable-custom-fields.js +2 -8
- package/build/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
- package/build/components/preferences-modal/options/enable-feature.js +2 -4
- package/build/components/preferences-modal/options/enable-feature.js.map +1 -1
- package/build/components/preferences-modal/options/enable-panel.js +2 -4
- package/build/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build/components/preferences-modal/options/enable-publish-sidebar.js +2 -8
- package/build/components/preferences-modal/options/enable-publish-sidebar.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +0 -11
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/post-link/index.js +1 -1
- package/build/components/sidebar/post-link/index.js.map +1 -1
- package/build/editor.js +4 -3
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +8 -8
- package/build/editor.native.js.map +1 -1
- package/build/hooks/validate-multiple-use/index.js +1 -1
- package/build/hooks/validate-multiple-use/index.js.map +1 -1
- package/build/index.js +5 -4
- package/build/index.js.map +1 -1
- package/build/plugins/welcome-guide-menu-item/index.js +3 -3
- package/build/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build/store/actions.js +173 -113
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +0 -3
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +0 -12
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +44 -10
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-manager/category.js +2 -2
- package/build-module/components/block-manager/category.js.map +1 -1
- package/build-module/components/block-manager/index.js +2 -2
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/header/fullscreen-mode-close/index.js +8 -4
- package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.js +1 -1
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js +1 -1
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/index.js +3 -1
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +0 -5
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/template-title/delete-template.js +32 -22
- package/build-module/components/header/template-title/delete-template.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js +7 -7
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +5 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/layout/index.js +2 -2
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js +1 -1
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +15 -135
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preferences-modal/meta-boxes-section.js +2 -2
- package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-custom-fields.js +1 -5
- package/build-module/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-feature.js +1 -1
- package/build-module/components/preferences-modal/options/enable-feature.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-panel.js +1 -1
- package/build-module/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-publish-sidebar.js +1 -5
- package/build-module/components/preferences-modal/options/enable-publish-sidebar.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -12
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/post-link/index.js +2 -2
- package/build-module/components/sidebar/post-link/index.js.map +1 -1
- package/build-module/editor.js +5 -4
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +8 -8
- package/build-module/editor.native.js.map +1 -1
- package/build-module/hooks/validate-multiple-use/index.js +1 -1
- package/build-module/hooks/validate-multiple-use/index.js.map +1 -1
- package/build-module/index.js +5 -4
- package/build-module/index.js.map +1 -1
- package/build-module/plugins/welcome-guide-menu-item/index.js +3 -3
- package/build-module/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build-module/store/actions.js +143 -102
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +0 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +1 -13
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +36 -6
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +105 -139
- package/build-style/style.css +105 -139
- package/package.json +30 -25
- package/src/components/block-manager/category.js +2 -2
- package/src/components/block-manager/index.js +2 -2
- package/src/components/header/fullscreen-mode-close/index.js +9 -4
- package/src/components/header/fullscreen-mode-close/style.scss +5 -1
- package/src/components/header/fullscreen-mode-close/test/index.js +1 -1
- package/src/components/header/header-toolbar/index.js +1 -1
- package/src/components/header/header-toolbar/index.native.js +1 -1
- package/src/components/header/index.js +1 -1
- package/src/components/header/more-menu/index.js +0 -6
- package/src/components/header/style.scss +1 -1
- package/src/components/header/template-title/delete-template.js +57 -46
- package/src/components/header/writing-menu/index.js +7 -7
- package/src/components/keyboard-shortcut-help-modal/config.js +4 -0
- package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +6 -0
- package/src/components/layout/index.js +2 -2
- package/src/components/layout/index.native.js +1 -1
- package/src/components/preferences-modal/index.js +24 -178
- package/src/components/preferences-modal/meta-boxes-section.js +3 -3
- package/src/components/preferences-modal/options/enable-custom-fields.js +1 -5
- package/src/components/preferences-modal/options/enable-feature.js +1 -1
- package/src/components/preferences-modal/options/enable-panel.js +1 -1
- package/src/components/preferences-modal/options/enable-publish-sidebar.js +1 -5
- package/src/components/preferences-modal/options/test/__snapshots__/enable-custom-fields.js.snap +4 -4
- package/src/components/preferences-modal/options/test/enable-custom-fields.js +1 -1
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +235 -357
- package/src/components/preferences-modal/test/index.js +6 -6
- package/src/components/secondary-sidebar/list-view-sidebar.js +1 -11
- package/src/components/sidebar/post-link/index.js +2 -2
- package/src/editor.js +4 -3
- package/src/editor.native.js +7 -7
- package/src/hooks/validate-multiple-use/index.js +1 -1
- package/src/index.js +5 -4
- package/src/plugins/welcome-guide-menu-item/index.js +3 -3
- package/src/store/actions.js +129 -149
- package/src/store/index.js +0 -2
- package/src/store/reducer.js +1 -12
- package/src/store/selectors.js +56 -8
- package/src/store/test/actions.js +252 -79
- package/src/store/test/reducer.js +0 -28
- package/src/style.scss +0 -2
- package/src/test/editor.native.js +2 -2
- package/build/components/preferences-modal/options/base.js +0 -35
- package/build/components/preferences-modal/options/base.js.map +0 -1
- package/build/components/preferences-modal/section.js +0 -27
- package/build/components/preferences-modal/section.js.map +0 -1
- package/build-module/components/preferences-modal/options/base.js +0 -27
- package/build-module/components/preferences-modal/options/base.js.map +0 -1
- package/build-module/components/preferences-modal/section.js +0 -19
- package/build-module/components/preferences-modal/section.js.map +0 -1
- package/src/components/header/more-menu/style.scss +0 -35
- package/src/components/preferences-modal/options/base.js +0 -20
- package/src/components/preferences-modal/section.js +0 -15
- package/src/components/preferences-modal/style.scss +0 -112
package/src/store/selectors.js
CHANGED
|
@@ -9,8 +9,12 @@ import { get, includes, some, flatten, values } from 'lodash';
|
|
|
9
9
|
*/
|
|
10
10
|
import { createRegistrySelector } from '@wordpress/data';
|
|
11
11
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
12
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
12
13
|
import { store as coreStore } from '@wordpress/core-data';
|
|
13
14
|
import { store as editorStore } from '@wordpress/editor';
|
|
15
|
+
|
|
16
|
+
const EMPTY_ARRAY = [];
|
|
17
|
+
|
|
14
18
|
/**
|
|
15
19
|
* Returns the current editing mode.
|
|
16
20
|
*
|
|
@@ -85,6 +89,10 @@ export const getActiveGeneralSidebarName = createRegistrySelector(
|
|
|
85
89
|
}
|
|
86
90
|
);
|
|
87
91
|
|
|
92
|
+
// The current list of preference keys that have been migrated to the
|
|
93
|
+
// preferences package.
|
|
94
|
+
const MIGRATED_KEYS = [ 'hiddenBlockTypes' ];
|
|
95
|
+
|
|
88
96
|
/**
|
|
89
97
|
* Returns the preferences (these preferences are persisted locally).
|
|
90
98
|
*
|
|
@@ -92,9 +100,34 @@ export const getActiveGeneralSidebarName = createRegistrySelector(
|
|
|
92
100
|
*
|
|
93
101
|
* @return {Object} Preferences Object.
|
|
94
102
|
*/
|
|
95
|
-
export
|
|
96
|
-
|
|
97
|
-
|
|
103
|
+
export const getPreferences = createRegistrySelector(
|
|
104
|
+
( select ) => ( state ) => {
|
|
105
|
+
const editPostPreferences = state.preferences;
|
|
106
|
+
|
|
107
|
+
// Some preferences now exist in the preferences store.
|
|
108
|
+
// Fetch them so that they can be merged into the post
|
|
109
|
+
// editor preferences.
|
|
110
|
+
const preferenceStorePreferences = MIGRATED_KEYS.reduce(
|
|
111
|
+
( accumulatedPrefs, preferenceKey ) => {
|
|
112
|
+
const value = select( preferencesStore ).get(
|
|
113
|
+
'core/edit-post',
|
|
114
|
+
preferenceKey
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
...accumulatedPrefs,
|
|
119
|
+
[ preferenceKey ]: value,
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
{}
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
...editPostPreferences,
|
|
127
|
+
...preferenceStorePreferences,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
);
|
|
98
131
|
|
|
99
132
|
/**
|
|
100
133
|
*
|
|
@@ -105,11 +138,29 @@ export function getPreferences( state ) {
|
|
|
105
138
|
* @return {*} Preference Value.
|
|
106
139
|
*/
|
|
107
140
|
export function getPreference( state, preferenceKey, defaultValue ) {
|
|
108
|
-
|
|
141
|
+
// Avoid using the `getPreferences` registry selector where possible.
|
|
142
|
+
const isMigratedKey = MIGRATED_KEYS.includes( preferenceKey );
|
|
143
|
+
const preferences = isMigratedKey
|
|
144
|
+
? getPreferences( state )
|
|
145
|
+
: state.preferences;
|
|
109
146
|
const value = preferences[ preferenceKey ];
|
|
110
147
|
return value === undefined ? defaultValue : value;
|
|
111
148
|
}
|
|
112
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Returns an array of blocks that are hidden.
|
|
152
|
+
*
|
|
153
|
+
* @return {Array} A list of the hidden block types
|
|
154
|
+
*/
|
|
155
|
+
export const getHiddenBlockTypes = createRegistrySelector( ( select ) => () => {
|
|
156
|
+
return (
|
|
157
|
+
select( preferencesStore ).get(
|
|
158
|
+
'core/edit-post',
|
|
159
|
+
'hiddenBlockTypes'
|
|
160
|
+
) ?? EMPTY_ARRAY
|
|
161
|
+
);
|
|
162
|
+
} );
|
|
163
|
+
|
|
113
164
|
/**
|
|
114
165
|
* Returns true if the publish sidebar is opened.
|
|
115
166
|
*
|
|
@@ -191,10 +242,7 @@ export function isModalActive( state, modalName ) {
|
|
|
191
242
|
*/
|
|
192
243
|
export const isFeatureActive = createRegistrySelector(
|
|
193
244
|
( select ) => ( state, feature ) => {
|
|
194
|
-
return select(
|
|
195
|
-
'core/edit-post',
|
|
196
|
-
feature
|
|
197
|
-
);
|
|
245
|
+
return !! select( preferencesStore ).get( 'core/edit-post', feature );
|
|
198
246
|
}
|
|
199
247
|
);
|
|
200
248
|
|
|
@@ -1,119 +1,292 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { createRegistry } from '@wordpress/data';
|
|
5
|
+
import { store as interfaceStore } from '@wordpress/interface';
|
|
6
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
7
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
8
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
9
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
10
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
5
11
|
|
|
6
12
|
/**
|
|
7
13
|
* Internal dependencies
|
|
8
14
|
*/
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
import { store as editPostStore } from '..';
|
|
16
|
+
|
|
17
|
+
function createRegistryWithStores() {
|
|
18
|
+
// Create a registry and register used stores.
|
|
19
|
+
const registry = createRegistry();
|
|
20
|
+
[
|
|
21
|
+
editPostStore,
|
|
22
|
+
noticesStore,
|
|
23
|
+
blockEditorStore,
|
|
24
|
+
coreStore,
|
|
25
|
+
interfaceStore,
|
|
26
|
+
preferencesStore,
|
|
27
|
+
editorStore,
|
|
28
|
+
].forEach( registry.register );
|
|
29
|
+
return registry;
|
|
30
|
+
}
|
|
21
31
|
|
|
22
32
|
describe( 'actions', () => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
type: 'OPEN_PUBLISH_SIDEBAR',
|
|
27
|
-
} );
|
|
28
|
-
} );
|
|
33
|
+
let registry;
|
|
34
|
+
beforeEach( () => {
|
|
35
|
+
registry = createRegistryWithStores();
|
|
29
36
|
} );
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
it( 'openGeneralSidebar/closeGeneralSidebar', () => {
|
|
39
|
+
registry.dispatch( editPostStore ).openGeneralSidebar( 'test/sidebar' );
|
|
40
|
+
expect(
|
|
41
|
+
registry
|
|
42
|
+
.select( interfaceStore )
|
|
43
|
+
.getActiveComplementaryArea( 'core/edit-post' )
|
|
44
|
+
).toBe( 'test/sidebar' );
|
|
45
|
+
|
|
46
|
+
registry
|
|
47
|
+
.dispatch( editPostStore )
|
|
48
|
+
.closeGeneralSidebar( 'test/sidebar' );
|
|
49
|
+
expect(
|
|
50
|
+
registry
|
|
51
|
+
.select( interfaceStore )
|
|
52
|
+
.getActiveComplementaryArea( 'core/edit-post' )
|
|
53
|
+
).toBeNull();
|
|
37
54
|
} );
|
|
38
55
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
56
|
+
it( 'toggleFeature', () => {
|
|
57
|
+
registry.dispatch( editPostStore ).toggleFeature( 'welcomeGuide' );
|
|
58
|
+
expect(
|
|
59
|
+
registry
|
|
60
|
+
.select( preferencesStore )
|
|
61
|
+
.get( editPostStore.name, 'welcomeGuide' )
|
|
62
|
+
).toBe( true );
|
|
63
|
+
|
|
64
|
+
registry.dispatch( editPostStore ).toggleFeature( 'welcomeGuide' );
|
|
65
|
+
expect(
|
|
66
|
+
registry
|
|
67
|
+
.select( preferencesStore )
|
|
68
|
+
.get( editPostStore.name, 'welcomeGuide' )
|
|
69
|
+
).toBe( false );
|
|
45
70
|
} );
|
|
46
71
|
|
|
47
|
-
describe( '
|
|
48
|
-
it( '
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
72
|
+
describe( 'switchEditorMode', () => {
|
|
73
|
+
it( 'to visual', () => {
|
|
74
|
+
registry.dispatch( editPostStore ).switchEditorMode( 'visual' );
|
|
75
|
+
expect( registry.select( editPostStore ).getEditorMode() ).toEqual(
|
|
76
|
+
'visual'
|
|
77
|
+
);
|
|
78
|
+
} );
|
|
79
|
+
|
|
80
|
+
it( 'to text', () => {
|
|
81
|
+
// Add a selected client id and make sure it's there.
|
|
82
|
+
const clientId = 'clientId_1';
|
|
83
|
+
registry.dispatch( blockEditorStore ).selectionChange( clientId );
|
|
84
|
+
expect(
|
|
85
|
+
registry.select( blockEditorStore ).getSelectedBlockClientId()
|
|
86
|
+
).toEqual( clientId );
|
|
87
|
+
|
|
88
|
+
registry.dispatch( editPostStore ).switchEditorMode( 'text' );
|
|
89
|
+
expect(
|
|
90
|
+
registry.select( blockEditorStore ).getSelectedBlockClientId()
|
|
91
|
+
).toBeNull();
|
|
53
92
|
} );
|
|
54
93
|
} );
|
|
55
94
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
95
|
+
it( 'togglePinnedPluginItem', () => {
|
|
96
|
+
registry.dispatch( editPostStore ).togglePinnedPluginItem( 'rigatoni' );
|
|
97
|
+
// Sidebars are pinned by default.
|
|
98
|
+
// @See https://github.com/WordPress/gutenberg/pull/21645
|
|
99
|
+
expect(
|
|
100
|
+
registry
|
|
101
|
+
.select( interfaceStore )
|
|
102
|
+
.isItemPinned( editPostStore.name, 'rigatoni' )
|
|
103
|
+
).toBe( false );
|
|
104
|
+
registry.dispatch( editPostStore ).togglePinnedPluginItem( 'rigatoni' );
|
|
105
|
+
expect(
|
|
106
|
+
registry
|
|
107
|
+
.select( interfaceStore )
|
|
108
|
+
.isItemPinned( editPostStore.name, 'rigatoni' )
|
|
109
|
+
).toBe( true );
|
|
110
|
+
} );
|
|
111
|
+
|
|
112
|
+
describe( '__unstableSwitchToTemplateMode', () => {
|
|
113
|
+
it( 'welcome guide is active', () => {
|
|
114
|
+
// Activate `welcomeGuideTemplate` feature.
|
|
115
|
+
registry
|
|
116
|
+
.dispatch( editPostStore )
|
|
117
|
+
.toggleFeature( 'welcomeGuideTemplate' );
|
|
118
|
+
registry.dispatch( editPostStore ).__unstableSwitchToTemplateMode();
|
|
119
|
+
expect(
|
|
120
|
+
registry.select( editPostStore ).isEditingTemplate()
|
|
121
|
+
).toBeTruthy();
|
|
122
|
+
const notices = registry.select( noticesStore ).getNotices();
|
|
123
|
+
expect( notices ).toHaveLength( 0 );
|
|
124
|
+
} );
|
|
125
|
+
|
|
126
|
+
it( 'welcome guide is inactive', () => {
|
|
127
|
+
expect(
|
|
128
|
+
registry.select( editPostStore ).isEditingTemplate()
|
|
129
|
+
).toBeFalsy();
|
|
130
|
+
registry.dispatch( editPostStore ).__unstableSwitchToTemplateMode();
|
|
131
|
+
expect(
|
|
132
|
+
registry.select( editPostStore ).isEditingTemplate()
|
|
133
|
+
).toBeTruthy();
|
|
134
|
+
const notices = registry.select( noticesStore ).getNotices();
|
|
135
|
+
expect( notices ).toHaveLength( 1 );
|
|
136
|
+
expect( notices[ 0 ].content ).toMatch( 'template' );
|
|
62
137
|
} );
|
|
63
138
|
} );
|
|
64
139
|
|
|
65
|
-
describe( '
|
|
66
|
-
it( '
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
140
|
+
describe( 'hideBlockTypes', () => {
|
|
141
|
+
it( 'adds the hidden block type to the preferences', () => {
|
|
142
|
+
registry
|
|
143
|
+
.dispatch( editPostStore )
|
|
144
|
+
.hideBlockTypes( [ 'core/quote', 'core/table' ] );
|
|
145
|
+
|
|
146
|
+
const expected = [ 'core/quote', 'core/table' ];
|
|
147
|
+
|
|
148
|
+
// TODO - remove once `getPreference` is deprecated.
|
|
149
|
+
expect(
|
|
150
|
+
registry
|
|
151
|
+
.select( editPostStore )
|
|
152
|
+
.getPreference( 'hiddenBlockTypes' )
|
|
153
|
+
).toEqual( expected );
|
|
154
|
+
|
|
155
|
+
expect(
|
|
156
|
+
registry.select( editPostStore ).getHiddenBlockTypes()
|
|
157
|
+
).toEqual( expected );
|
|
71
158
|
} );
|
|
72
159
|
} );
|
|
73
160
|
|
|
74
|
-
describe( '
|
|
75
|
-
it( '
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
161
|
+
describe( 'showBlockTypes', () => {
|
|
162
|
+
it( 'removes the hidden block type from the preferences', () => {
|
|
163
|
+
registry
|
|
164
|
+
.dispatch( editPostStore )
|
|
165
|
+
.hideBlockTypes( [ 'core/quote', 'core/table' ] );
|
|
166
|
+
|
|
167
|
+
const expectedA = [ 'core/quote', 'core/table' ];
|
|
168
|
+
|
|
169
|
+
// TODO - remove once `getPreference` is deprecated.
|
|
170
|
+
expect(
|
|
171
|
+
registry
|
|
172
|
+
.select( editPostStore )
|
|
173
|
+
.getPreference( 'hiddenBlockTypes' )
|
|
174
|
+
).toEqual( expectedA );
|
|
175
|
+
|
|
176
|
+
expect(
|
|
177
|
+
registry.select( editPostStore ).getHiddenBlockTypes()
|
|
178
|
+
).toEqual( expectedA );
|
|
179
|
+
|
|
180
|
+
registry
|
|
181
|
+
.dispatch( editPostStore )
|
|
182
|
+
.showBlockTypes( [ 'core/table' ] );
|
|
183
|
+
|
|
184
|
+
const expectedB = [ 'core/quote' ];
|
|
185
|
+
|
|
186
|
+
// TODO - remove once `getPreference` is deprecated.
|
|
187
|
+
expect(
|
|
188
|
+
registry
|
|
189
|
+
.select( editPostStore )
|
|
190
|
+
.getPreference( 'hiddenBlockTypes' )
|
|
191
|
+
).toEqual( expectedB );
|
|
192
|
+
|
|
193
|
+
expect(
|
|
194
|
+
registry.select( editPostStore ).getHiddenBlockTypes()
|
|
195
|
+
).toEqual( expectedB );
|
|
81
196
|
} );
|
|
82
197
|
} );
|
|
83
198
|
|
|
84
|
-
describe( '
|
|
85
|
-
it( '
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
199
|
+
describe( '__experimentalUpdateLocalAutosaveInterval', () => {
|
|
200
|
+
it( 'sets the local autosave interval', () => {
|
|
201
|
+
registry
|
|
202
|
+
.dispatch( editPostStore )
|
|
203
|
+
.__experimentalUpdateLocalAutosaveInterval( 42 );
|
|
204
|
+
|
|
205
|
+
// TODO - remove once `getPreference` is deprecated.
|
|
206
|
+
expect(
|
|
207
|
+
registry
|
|
208
|
+
.select( editPostStore )
|
|
209
|
+
.getPreference( 'localAutosaveInterval' )
|
|
210
|
+
).toBe( 42 );
|
|
89
211
|
} );
|
|
90
212
|
} );
|
|
91
213
|
|
|
92
|
-
describe( '
|
|
93
|
-
it( '
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
214
|
+
describe( 'toggleEditorPanelEnabled', () => {
|
|
215
|
+
it( 'toggles panels to be enabled and not enabled', () => {
|
|
216
|
+
const defaultState = {
|
|
217
|
+
'post-status': {
|
|
218
|
+
opened: true,
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// This will switch it off, since the default is on.
|
|
223
|
+
registry
|
|
224
|
+
.dispatch( editPostStore )
|
|
225
|
+
.toggleEditorPanelEnabled( 'control-panel' );
|
|
226
|
+
|
|
227
|
+
// TODO - remove once `getPreference` is deprecated.
|
|
228
|
+
expect(
|
|
229
|
+
registry.select( editPostStore ).getPreference( 'panels' )
|
|
230
|
+
).toEqual( {
|
|
231
|
+
...defaultState,
|
|
232
|
+
'control-panel': {
|
|
233
|
+
enabled: false,
|
|
99
234
|
},
|
|
100
235
|
} );
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
236
|
+
|
|
237
|
+
// Switch it on again.
|
|
238
|
+
registry
|
|
239
|
+
.dispatch( editPostStore )
|
|
240
|
+
.toggleEditorPanelEnabled( 'control-panel' );
|
|
241
|
+
|
|
242
|
+
// TODO - remove once `getPreference` is deprecated.
|
|
243
|
+
expect(
|
|
244
|
+
registry.select( editPostStore ).getPreference( 'panels' )
|
|
245
|
+
).toEqual( {
|
|
246
|
+
...defaultState,
|
|
247
|
+
'control-panel': {
|
|
248
|
+
enabled: true,
|
|
249
|
+
},
|
|
104
250
|
} );
|
|
105
251
|
} );
|
|
106
252
|
} );
|
|
107
253
|
|
|
108
|
-
describe( '
|
|
109
|
-
it( '
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
254
|
+
describe( 'toggleEditorPanelOpened', () => {
|
|
255
|
+
it( 'toggles panels open and closed', () => {
|
|
256
|
+
const defaultState = {
|
|
257
|
+
'post-status': {
|
|
258
|
+
opened: true,
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// This will open it, since the default is closed.
|
|
263
|
+
registry
|
|
264
|
+
.dispatch( editPostStore )
|
|
265
|
+
.toggleEditorPanelOpened( 'control-panel' );
|
|
266
|
+
|
|
267
|
+
// TODO - remove once `getPreference` is deprecated.
|
|
268
|
+
expect(
|
|
269
|
+
registry.select( editPostStore ).getPreference( 'panels' )
|
|
270
|
+
).toEqual( {
|
|
271
|
+
...defaultState,
|
|
272
|
+
'control-panel': {
|
|
273
|
+
opened: true,
|
|
274
|
+
},
|
|
113
275
|
} );
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
276
|
+
|
|
277
|
+
// Close it.
|
|
278
|
+
registry
|
|
279
|
+
.dispatch( editPostStore )
|
|
280
|
+
.toggleEditorPanelOpened( 'control-panel' );
|
|
281
|
+
|
|
282
|
+
// TODO - remove once `getPreference` is deprecated.
|
|
283
|
+
expect(
|
|
284
|
+
registry.select( editPostStore ).getPreference( 'panels' )
|
|
285
|
+
).toEqual( {
|
|
286
|
+
...defaultState,
|
|
287
|
+
'control-panel': {
|
|
288
|
+
opened: false,
|
|
289
|
+
},
|
|
117
290
|
} );
|
|
118
291
|
} );
|
|
119
292
|
} );
|
|
@@ -151,34 +151,6 @@ describe( 'state', () => {
|
|
|
151
151
|
|
|
152
152
|
expect( state.editorMode ).toBe( 'text' );
|
|
153
153
|
} );
|
|
154
|
-
|
|
155
|
-
describe( 'hiddenBlockTypes', () => {
|
|
156
|
-
it( 'concatenates unique names on disable', () => {
|
|
157
|
-
const original = deepFreeze( {
|
|
158
|
-
hiddenBlockTypes: [ 'a', 'b' ],
|
|
159
|
-
} );
|
|
160
|
-
|
|
161
|
-
const state = preferences( original, {
|
|
162
|
-
type: 'HIDE_BLOCK_TYPES',
|
|
163
|
-
blockNames: [ 'b', 'c' ],
|
|
164
|
-
} );
|
|
165
|
-
|
|
166
|
-
expect( state.hiddenBlockTypes ).toEqual( [ 'a', 'b', 'c' ] );
|
|
167
|
-
} );
|
|
168
|
-
|
|
169
|
-
it( 'omits present names by enable', () => {
|
|
170
|
-
const original = deepFreeze( {
|
|
171
|
-
hiddenBlockTypes: [ 'a', 'b' ],
|
|
172
|
-
} );
|
|
173
|
-
|
|
174
|
-
const state = preferences( original, {
|
|
175
|
-
type: 'SHOW_BLOCK_TYPES',
|
|
176
|
-
blockNames: [ 'b', 'c' ],
|
|
177
|
-
} );
|
|
178
|
-
|
|
179
|
-
expect( state.hiddenBlockTypes ).toEqual( [ 'a' ] );
|
|
180
|
-
} );
|
|
181
|
-
} );
|
|
182
154
|
} );
|
|
183
155
|
|
|
184
156
|
describe( 'activeModal', () => {
|
package/src/style.scss
CHANGED
|
@@ -2,13 +2,11 @@
|
|
|
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/more-menu/style.scss";
|
|
6
5
|
@import "./components/header/template-title/style.scss";
|
|
7
6
|
@import "./components/keyboard-shortcut-help-modal/style.scss";
|
|
8
7
|
@import "./components/layout/style.scss";
|
|
9
8
|
@import "./components/block-manager/style.scss";
|
|
10
9
|
@import "./components/meta-boxes/meta-boxes-area/style.scss";
|
|
11
|
-
@import "./components/preferences-modal/style.scss";
|
|
12
10
|
@import "./components/secondary-sidebar/style.scss";
|
|
13
11
|
@import "./components/sidebar/style.scss";
|
|
14
12
|
@import "./components/sidebar/last-revision/style.scss";
|
|
@@ -34,7 +34,7 @@ describe( 'Editor', () => {
|
|
|
34
34
|
RNReactNativeGutenbergBridge.editorDidMount = jest.fn();
|
|
35
35
|
|
|
36
36
|
const appContainer = renderEditorWith( unsupportedBlock );
|
|
37
|
-
//
|
|
37
|
+
// For some reason resetEditorBlocks() is asynchronous when dispatching editEntityRecord.
|
|
38
38
|
act( () => {
|
|
39
39
|
jest.runAllTicks();
|
|
40
40
|
} );
|
|
@@ -49,7 +49,7 @@ describe( 'Editor', () => {
|
|
|
49
49
|
} );
|
|
50
50
|
} );
|
|
51
51
|
|
|
52
|
-
// Utilities
|
|
52
|
+
// Utilities.
|
|
53
53
|
const renderEditorWith = ( content ) => {
|
|
54
54
|
return render(
|
|
55
55
|
<Editor
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
var _components = require("@wordpress/components");
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* WordPress dependencies
|
|
14
|
-
*/
|
|
15
|
-
function BaseOption(_ref) {
|
|
16
|
-
let {
|
|
17
|
-
help,
|
|
18
|
-
label,
|
|
19
|
-
isChecked,
|
|
20
|
-
onChange,
|
|
21
|
-
children
|
|
22
|
-
} = _ref;
|
|
23
|
-
return (0, _element.createElement)("div", {
|
|
24
|
-
className: "edit-post-preferences-modal__option"
|
|
25
|
-
}, (0, _element.createElement)(_components.ToggleControl, {
|
|
26
|
-
help: help,
|
|
27
|
-
label: label,
|
|
28
|
-
checked: isChecked,
|
|
29
|
-
onChange: onChange
|
|
30
|
-
}), children);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
var _default = BaseOption;
|
|
34
|
-
exports.default = _default;
|
|
35
|
-
//# sourceMappingURL=base.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/preferences-modal/options/base.js"],"names":["BaseOption","help","label","isChecked","onChange","children"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,SAASA,UAAT,OAAsE;AAAA,MAAjD;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAeC,IAAAA,SAAf;AAA0BC,IAAAA,QAA1B;AAAoCC,IAAAA;AAApC,GAAiD;AACrE,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,yBAAD;AACC,IAAA,IAAI,EAAGJ,IADR;AAEC,IAAA,KAAK,EAAGC,KAFT;AAGC,IAAA,OAAO,EAAGC,SAHX;AAIC,IAAA,QAAQ,EAAGC;AAJZ,IADD,EAOGC,QAPH,CADD;AAWA;;eAEcL,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToggleControl } from '@wordpress/components';\n\nfunction BaseOption( { help, label, isChecked, onChange, children } ) {\n\treturn (\n\t\t<div className=\"edit-post-preferences-modal__option\">\n\t\t\t<ToggleControl\n\t\t\t\thelp={ help }\n\t\t\t\tlabel={ label }\n\t\t\t\tchecked={ isChecked }\n\t\t\t\tonChange={ onChange }\n\t\t\t/>\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\nexport default BaseOption;\n"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
const Section = _ref => {
|
|
11
|
-
let {
|
|
12
|
-
description,
|
|
13
|
-
title,
|
|
14
|
-
children
|
|
15
|
-
} = _ref;
|
|
16
|
-
return (0, _element.createElement)("section", {
|
|
17
|
-
className: "edit-post-preferences-modal__section"
|
|
18
|
-
}, (0, _element.createElement)("h2", {
|
|
19
|
-
className: "edit-post-preferences-modal__section-title"
|
|
20
|
-
}, title), description && (0, _element.createElement)("p", {
|
|
21
|
-
className: "edit-post-preferences-modal__section-description"
|
|
22
|
-
}, description), children);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
var _default = Section;
|
|
26
|
-
exports.default = _default;
|
|
27
|
-
//# sourceMappingURL=section.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/preferences-modal/section.js"],"names":["Section","description","title","children"],"mappings":";;;;;;;;;AAAA,MAAMA,OAAO,GAAG;AAAA,MAAE;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,KAAf;AAAsBC,IAAAA;AAAtB,GAAF;AAAA,SACf;AAAS,IAAA,SAAS,EAAC;AAAnB,KACC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGD,KADH,CADD,EAIGD,WAAW,IACZ;AAAG,IAAA,SAAS,EAAC;AAAb,KACGA,WADH,CALF,EASGE,QATH,CADe;AAAA,CAAhB;;eAceH,O","sourcesContent":["const Section = ( { description, title, children } ) => (\n\t<section className=\"edit-post-preferences-modal__section\">\n\t\t<h2 className=\"edit-post-preferences-modal__section-title\">\n\t\t\t{ title }\n\t\t</h2>\n\t\t{ description && (\n\t\t\t<p className=\"edit-post-preferences-modal__section-description\">\n\t\t\t\t{ description }\n\t\t\t</p>\n\t\t) }\n\t\t{ children }\n\t</section>\n);\n\nexport default Section;\n"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { ToggleControl } from '@wordpress/components';
|
|
7
|
-
|
|
8
|
-
function BaseOption(_ref) {
|
|
9
|
-
let {
|
|
10
|
-
help,
|
|
11
|
-
label,
|
|
12
|
-
isChecked,
|
|
13
|
-
onChange,
|
|
14
|
-
children
|
|
15
|
-
} = _ref;
|
|
16
|
-
return createElement("div", {
|
|
17
|
-
className: "edit-post-preferences-modal__option"
|
|
18
|
-
}, createElement(ToggleControl, {
|
|
19
|
-
help: help,
|
|
20
|
-
label: label,
|
|
21
|
-
checked: isChecked,
|
|
22
|
-
onChange: onChange
|
|
23
|
-
}), children);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default BaseOption;
|
|
27
|
-
//# sourceMappingURL=base.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/preferences-modal/options/base.js"],"names":["ToggleControl","BaseOption","help","label","isChecked","onChange","children"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,uBAA9B;;AAEA,SAASC,UAAT,OAAsE;AAAA,MAAjD;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAeC,IAAAA,SAAf;AAA0BC,IAAAA,QAA1B;AAAoCC,IAAAA;AAApC,GAAiD;AACrE,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,aAAD;AACC,IAAA,IAAI,EAAGJ,IADR;AAEC,IAAA,KAAK,EAAGC,KAFT;AAGC,IAAA,OAAO,EAAGC,SAHX;AAIC,IAAA,QAAQ,EAAGC;AAJZ,IADD,EAOGC,QAPH,CADD;AAWA;;AAED,eAAeL,UAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToggleControl } from '@wordpress/components';\n\nfunction BaseOption( { help, label, isChecked, onChange, children } ) {\n\treturn (\n\t\t<div className=\"edit-post-preferences-modal__option\">\n\t\t\t<ToggleControl\n\t\t\t\thelp={ help }\n\t\t\t\tlabel={ label }\n\t\t\t\tchecked={ isChecked }\n\t\t\t\tonChange={ onChange }\n\t\t\t/>\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\nexport default BaseOption;\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
const Section = _ref => {
|
|
4
|
-
let {
|
|
5
|
-
description,
|
|
6
|
-
title,
|
|
7
|
-
children
|
|
8
|
-
} = _ref;
|
|
9
|
-
return createElement("section", {
|
|
10
|
-
className: "edit-post-preferences-modal__section"
|
|
11
|
-
}, createElement("h2", {
|
|
12
|
-
className: "edit-post-preferences-modal__section-title"
|
|
13
|
-
}, title), description && createElement("p", {
|
|
14
|
-
className: "edit-post-preferences-modal__section-description"
|
|
15
|
-
}, description), children);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default Section;
|
|
19
|
-
//# sourceMappingURL=section.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/preferences-modal/section.js"],"names":["Section","description","title","children"],"mappings":";;AAAA,MAAMA,OAAO,GAAG;AAAA,MAAE;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,KAAf;AAAsBC,IAAAA;AAAtB,GAAF;AAAA,SACf;AAAS,IAAA,SAAS,EAAC;AAAnB,KACC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGD,KADH,CADD,EAIGD,WAAW,IACZ;AAAG,IAAA,SAAS,EAAC;AAAb,KACGA,WADH,CALF,EASGE,QATH,CADe;AAAA,CAAhB;;AAcA,eAAeH,OAAf","sourcesContent":["const Section = ( { description, title, children } ) => (\n\t<section className=\"edit-post-preferences-modal__section\">\n\t\t<h2 className=\"edit-post-preferences-modal__section-title\">\n\t\t\t{ title }\n\t\t</h2>\n\t\t{ description && (\n\t\t\t<p className=\"edit-post-preferences-modal__section-description\">\n\t\t\t\t{ description }\n\t\t\t</p>\n\t\t) }\n\t\t{ children }\n\t</section>\n);\n\nexport default Section;\n"]}
|