@wordpress/edit-post 6.1.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/components/header/plugin-more-menu-item/index.js +5 -0
- package/build/components/header/plugin-more-menu-item/index.js.map +1 -1
- package/build/components/header/template-title/delete-template.js +3 -1
- package/build/components/header/template-title/delete-template.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/components/visual-editor/index.js +3 -3
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/editor.js +4 -6
- package/build/editor.js.map +1 -1
- package/build/index.js +5 -0
- package/build/index.js.map +1 -1
- package/build/index.native.js +15 -0
- package/build/index.native.js.map +1 -1
- package/build/store/actions.js +99 -74
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +7 -10
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +0 -118
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +95 -34
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/header/plugin-more-menu-item/index.js +4 -0
- package/build-module/components/header/plugin-more-menu-item/index.js.map +1 -1
- package/build-module/components/header/template-title/delete-template.js +3 -1
- package/build-module/components/header/template-title/delete-template.js.map +1 -1
- package/build-module/components/sidebar/post-link/index.js +1 -1
- package/build-module/components/sidebar/post-link/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +3 -3
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/editor.js +3 -6
- package/build-module/editor.js.map +1 -1
- package/build-module/index.js +5 -0
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +13 -0
- package/build-module/index.native.js.map +1 -1
- package/build-module/store/actions.js +92 -68
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +7 -10
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +1 -115
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +89 -28
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +1 -4
- package/build-style/style.css +1 -4
- package/package.json +27 -26
- package/src/components/header/plugin-more-menu-item/index.js +2 -0
- package/src/components/header/template-title/delete-template.js +3 -1
- package/src/components/sidebar/post-link/index.js +1 -1
- package/src/components/visual-editor/index.js +5 -3
- package/src/editor.js +3 -8
- package/src/index.js +5 -0
- package/src/index.native.js +14 -0
- package/src/store/actions.js +87 -42
- package/src/store/index.js +7 -11
- package/src/store/reducer.js +1 -106
- package/src/store/selectors.js +124 -50
- package/src/store/test/actions.js +89 -46
- package/src/store/test/reducer.js +0 -135
- package/src/store/test/selectors.js +0 -174
- package/src/style.scss +0 -4
- package/build/store/defaults.js +0 -19
- package/build/store/defaults.js.map +0 -1
- package/build-module/store/defaults.js +0 -12
- package/build-module/store/defaults.js.map +0 -1
- package/src/store/defaults.js +0 -11
|
@@ -7,7 +7,6 @@ import deepFreeze from 'deep-freeze';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import {
|
|
10
|
-
preferences,
|
|
11
10
|
activeModal,
|
|
12
11
|
isSavingMetaBoxes,
|
|
13
12
|
metaBoxLocations,
|
|
@@ -15,144 +14,10 @@ import {
|
|
|
15
14
|
blockInserterPanel,
|
|
16
15
|
listViewPanel,
|
|
17
16
|
} from '../reducer';
|
|
18
|
-
import { PREFERENCES_DEFAULTS } from '../defaults';
|
|
19
17
|
|
|
20
18
|
import { setIsInserterOpened, setIsListViewOpened } from '../actions';
|
|
21
19
|
|
|
22
20
|
describe( 'state', () => {
|
|
23
|
-
describe( 'preferences()', () => {
|
|
24
|
-
it( 'should apply all defaults', () => {
|
|
25
|
-
const state = preferences( undefined, {} );
|
|
26
|
-
|
|
27
|
-
expect( state ).toEqual( PREFERENCES_DEFAULTS );
|
|
28
|
-
} );
|
|
29
|
-
|
|
30
|
-
it( 'should disable panels by default', () => {
|
|
31
|
-
const original = deepFreeze( {
|
|
32
|
-
panels: {},
|
|
33
|
-
} );
|
|
34
|
-
const state = preferences( original, {
|
|
35
|
-
type: 'TOGGLE_PANEL_ENABLED',
|
|
36
|
-
panelName: 'post-status',
|
|
37
|
-
} );
|
|
38
|
-
expect( state.panels ).toEqual( {
|
|
39
|
-
'post-status': { enabled: false },
|
|
40
|
-
} );
|
|
41
|
-
} );
|
|
42
|
-
|
|
43
|
-
it( 'should disable panels that are enabled', () => {
|
|
44
|
-
const original = deepFreeze( {
|
|
45
|
-
panels: {
|
|
46
|
-
'post-status': { enabled: true },
|
|
47
|
-
},
|
|
48
|
-
} );
|
|
49
|
-
const state = preferences( original, {
|
|
50
|
-
type: 'TOGGLE_PANEL_ENABLED',
|
|
51
|
-
panelName: 'post-status',
|
|
52
|
-
} );
|
|
53
|
-
expect( state.panels ).toEqual( {
|
|
54
|
-
'post-status': { enabled: false },
|
|
55
|
-
} );
|
|
56
|
-
} );
|
|
57
|
-
|
|
58
|
-
it( 'should enable panels that are disabled', () => {
|
|
59
|
-
const original = deepFreeze( {
|
|
60
|
-
panels: {
|
|
61
|
-
'post-status': { enabled: false },
|
|
62
|
-
},
|
|
63
|
-
} );
|
|
64
|
-
const state = preferences( original, {
|
|
65
|
-
type: 'TOGGLE_PANEL_ENABLED',
|
|
66
|
-
panelName: 'post-status',
|
|
67
|
-
} );
|
|
68
|
-
expect( state.panels ).toEqual( {
|
|
69
|
-
'post-status': { enabled: true },
|
|
70
|
-
} );
|
|
71
|
-
} );
|
|
72
|
-
|
|
73
|
-
it( 'should open panels by default', () => {
|
|
74
|
-
const original = deepFreeze( {
|
|
75
|
-
panels: {},
|
|
76
|
-
} );
|
|
77
|
-
const state = preferences( original, {
|
|
78
|
-
type: 'TOGGLE_PANEL_OPENED',
|
|
79
|
-
panelName: 'post-status',
|
|
80
|
-
} );
|
|
81
|
-
expect( state.panels ).toEqual( {
|
|
82
|
-
'post-status': { opened: true },
|
|
83
|
-
} );
|
|
84
|
-
} );
|
|
85
|
-
|
|
86
|
-
it( 'should open panels that are closed', () => {
|
|
87
|
-
const original = deepFreeze( {
|
|
88
|
-
panels: {
|
|
89
|
-
'post-status': { opened: false },
|
|
90
|
-
},
|
|
91
|
-
} );
|
|
92
|
-
const state = preferences( original, {
|
|
93
|
-
type: 'TOGGLE_PANEL_OPENED',
|
|
94
|
-
panelName: 'post-status',
|
|
95
|
-
} );
|
|
96
|
-
expect( state.panels ).toEqual( {
|
|
97
|
-
'post-status': { opened: true },
|
|
98
|
-
} );
|
|
99
|
-
} );
|
|
100
|
-
|
|
101
|
-
it( 'should close panels that are opened', () => {
|
|
102
|
-
const original = deepFreeze( {
|
|
103
|
-
panels: {
|
|
104
|
-
'post-status': { opened: true },
|
|
105
|
-
},
|
|
106
|
-
} );
|
|
107
|
-
const state = preferences( original, {
|
|
108
|
-
type: 'TOGGLE_PANEL_OPENED',
|
|
109
|
-
panelName: 'post-status',
|
|
110
|
-
} );
|
|
111
|
-
expect( state.panels ).toEqual( {
|
|
112
|
-
'post-status': { opened: false },
|
|
113
|
-
} );
|
|
114
|
-
} );
|
|
115
|
-
|
|
116
|
-
it( 'should open panels that are legacy closed', () => {
|
|
117
|
-
const original = deepFreeze( {
|
|
118
|
-
panels: {
|
|
119
|
-
'post-status': false,
|
|
120
|
-
},
|
|
121
|
-
} );
|
|
122
|
-
const state = preferences( original, {
|
|
123
|
-
type: 'TOGGLE_PANEL_OPENED',
|
|
124
|
-
panelName: 'post-status',
|
|
125
|
-
} );
|
|
126
|
-
expect( state.panels ).toEqual( {
|
|
127
|
-
'post-status': { opened: true },
|
|
128
|
-
} );
|
|
129
|
-
} );
|
|
130
|
-
|
|
131
|
-
it( 'should close panels that are legacy opened', () => {
|
|
132
|
-
const original = deepFreeze( {
|
|
133
|
-
panels: {
|
|
134
|
-
'post-status': true,
|
|
135
|
-
},
|
|
136
|
-
} );
|
|
137
|
-
const state = preferences( original, {
|
|
138
|
-
type: 'TOGGLE_PANEL_OPENED',
|
|
139
|
-
panelName: 'post-status',
|
|
140
|
-
} );
|
|
141
|
-
expect( state.panels ).toEqual( {
|
|
142
|
-
'post-status': { opened: false },
|
|
143
|
-
} );
|
|
144
|
-
} );
|
|
145
|
-
|
|
146
|
-
it( 'should return switched mode', () => {
|
|
147
|
-
const state = preferences( deepFreeze( { editorMode: 'visual' } ), {
|
|
148
|
-
type: 'SWITCH_MODE',
|
|
149
|
-
mode: 'text',
|
|
150
|
-
} );
|
|
151
|
-
|
|
152
|
-
expect( state.editorMode ).toBe( 'text' );
|
|
153
|
-
} );
|
|
154
|
-
} );
|
|
155
|
-
|
|
156
21
|
describe( 'activeModal', () => {
|
|
157
22
|
it( 'should default to null', () => {
|
|
158
23
|
const state = activeModal( undefined, {} );
|
|
@@ -7,67 +7,17 @@ import deepFreeze from 'deep-freeze';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import {
|
|
10
|
-
getEditorMode,
|
|
11
|
-
getPreference,
|
|
12
|
-
isEditorPanelOpened,
|
|
13
10
|
isModalActive,
|
|
14
11
|
hasMetaBoxes,
|
|
15
12
|
isSavingMetaBoxes,
|
|
16
13
|
getActiveMetaBoxLocations,
|
|
17
14
|
isMetaBoxLocationActive,
|
|
18
|
-
isEditorPanelEnabled,
|
|
19
15
|
isEditorPanelRemoved,
|
|
20
16
|
isInserterOpened,
|
|
21
17
|
isListViewOpened,
|
|
22
18
|
} from '../selectors';
|
|
23
19
|
|
|
24
20
|
describe( 'selectors', () => {
|
|
25
|
-
describe( 'getEditorMode', () => {
|
|
26
|
-
it( 'should return the selected editor mode', () => {
|
|
27
|
-
const state = {
|
|
28
|
-
preferences: { editorMode: 'text' },
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
expect( getEditorMode( state ) ).toEqual( 'text' );
|
|
32
|
-
} );
|
|
33
|
-
|
|
34
|
-
it( 'should fallback to visual if not set', () => {
|
|
35
|
-
const state = {
|
|
36
|
-
preferences: {},
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
expect( getEditorMode( state ) ).toEqual( 'visual' );
|
|
40
|
-
} );
|
|
41
|
-
} );
|
|
42
|
-
|
|
43
|
-
describe( 'getPreference', () => {
|
|
44
|
-
it( 'should return the preference value if set', () => {
|
|
45
|
-
const state = {
|
|
46
|
-
preferences: { chicken: true },
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
expect( getPreference( state, 'chicken' ) ).toBe( true );
|
|
50
|
-
} );
|
|
51
|
-
|
|
52
|
-
it( 'should return undefined if the preference is unset', () => {
|
|
53
|
-
const state = {
|
|
54
|
-
preferences: { chicken: true },
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
expect( getPreference( state, 'ribs' ) ).toBeUndefined();
|
|
58
|
-
} );
|
|
59
|
-
|
|
60
|
-
it( 'should return the default value if provided', () => {
|
|
61
|
-
const state = {
|
|
62
|
-
preferences: {},
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
expect( getPreference( state, 'ribs', 'chicken' ) ).toEqual(
|
|
66
|
-
'chicken'
|
|
67
|
-
);
|
|
68
|
-
} );
|
|
69
|
-
} );
|
|
70
|
-
|
|
71
21
|
describe( 'isModalActive', () => {
|
|
72
22
|
it( 'returns true if the provided name matches the value in the preferences activeModal property', () => {
|
|
73
23
|
const state = {
|
|
@@ -114,130 +64,6 @@ describe( 'selectors', () => {
|
|
|
114
64
|
} );
|
|
115
65
|
} );
|
|
116
66
|
|
|
117
|
-
describe( 'isEditorPanelEnabled', () => {
|
|
118
|
-
it( 'should return true by default', () => {
|
|
119
|
-
const state = {
|
|
120
|
-
preferences: {
|
|
121
|
-
panels: {},
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
expect( isEditorPanelEnabled( state, 'post-status' ) ).toBe( true );
|
|
126
|
-
} );
|
|
127
|
-
|
|
128
|
-
it( 'should return true when a panel has been enabled', () => {
|
|
129
|
-
const state = {
|
|
130
|
-
preferences: {
|
|
131
|
-
panels: {
|
|
132
|
-
'post-status': { enabled: true },
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
expect( isEditorPanelEnabled( state, 'post-status' ) ).toBe( true );
|
|
138
|
-
} );
|
|
139
|
-
|
|
140
|
-
it( 'should return false when a panel has been disabled', () => {
|
|
141
|
-
const state = {
|
|
142
|
-
preferences: {
|
|
143
|
-
panels: {
|
|
144
|
-
'post-status': { enabled: false },
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
expect( isEditorPanelEnabled( state, 'post-status' ) ).toBe(
|
|
150
|
-
false
|
|
151
|
-
);
|
|
152
|
-
} );
|
|
153
|
-
|
|
154
|
-
it( 'should return false when a panel is enabled but removed', () => {
|
|
155
|
-
const state = deepFreeze( {
|
|
156
|
-
preferences: {
|
|
157
|
-
panels: {
|
|
158
|
-
'post-status': {
|
|
159
|
-
enabled: true,
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
removedPanels: [ 'post-status' ],
|
|
164
|
-
} );
|
|
165
|
-
|
|
166
|
-
expect( isEditorPanelEnabled( state, 'post-status' ) ).toBe(
|
|
167
|
-
false
|
|
168
|
-
);
|
|
169
|
-
} );
|
|
170
|
-
} );
|
|
171
|
-
|
|
172
|
-
describe( 'isEditorPanelOpened', () => {
|
|
173
|
-
it( 'is tolerant to an undefined panels preference', () => {
|
|
174
|
-
// See: https://github.com/WordPress/gutenberg/issues/14580
|
|
175
|
-
const state = {
|
|
176
|
-
preferences: {},
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
expect( isEditorPanelOpened( state, 'post-status' ) ).toBe( false );
|
|
180
|
-
} );
|
|
181
|
-
|
|
182
|
-
it( 'should return false by default', () => {
|
|
183
|
-
const state = {
|
|
184
|
-
preferences: {
|
|
185
|
-
panels: {},
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
expect( isEditorPanelOpened( state, 'post-status' ) ).toBe( false );
|
|
190
|
-
} );
|
|
191
|
-
|
|
192
|
-
it( 'should return true when a panel has been opened', () => {
|
|
193
|
-
const state = {
|
|
194
|
-
preferences: {
|
|
195
|
-
panels: {
|
|
196
|
-
'post-status': { opened: true },
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
expect( isEditorPanelOpened( state, 'post-status' ) ).toBe( true );
|
|
202
|
-
} );
|
|
203
|
-
|
|
204
|
-
it( 'should return false when a panel has been closed', () => {
|
|
205
|
-
const state = {
|
|
206
|
-
preferences: {
|
|
207
|
-
panels: {
|
|
208
|
-
'post-status': { opened: false },
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
expect( isEditorPanelOpened( state, 'post-status' ) ).toBe( false );
|
|
214
|
-
} );
|
|
215
|
-
|
|
216
|
-
it( 'should return true when a panel has been legacy opened', () => {
|
|
217
|
-
const state = {
|
|
218
|
-
preferences: {
|
|
219
|
-
panels: {
|
|
220
|
-
'post-status': true,
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
expect( isEditorPanelOpened( state, 'post-status' ) ).toBe( true );
|
|
226
|
-
} );
|
|
227
|
-
|
|
228
|
-
it( 'should return false when a panel has been legacy closed', () => {
|
|
229
|
-
const state = {
|
|
230
|
-
preferences: {
|
|
231
|
-
panels: {
|
|
232
|
-
'post-status': false,
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
expect( isEditorPanelOpened( state, 'post-status' ) ).toBe( false );
|
|
238
|
-
} );
|
|
239
|
-
} );
|
|
240
|
-
|
|
241
67
|
describe( 'hasMetaBoxes', () => {
|
|
242
68
|
it( 'should return true if there are active meta boxes', () => {
|
|
243
69
|
const state = {
|
package/src/style.scss
CHANGED
package/build/store/defaults.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.PREFERENCES_DEFAULTS = void 0;
|
|
7
|
-
const PREFERENCES_DEFAULTS = {
|
|
8
|
-
editorMode: 'visual',
|
|
9
|
-
panels: {
|
|
10
|
-
'post-status': {
|
|
11
|
-
opened: true
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
hiddenBlockTypes: [],
|
|
15
|
-
preferredStyleVariations: {},
|
|
16
|
-
localAutosaveInterval: 15
|
|
17
|
-
};
|
|
18
|
-
exports.PREFERENCES_DEFAULTS = PREFERENCES_DEFAULTS;
|
|
19
|
-
//# sourceMappingURL=defaults.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/store/defaults.js"],"names":["PREFERENCES_DEFAULTS","editorMode","panels","opened","hiddenBlockTypes","preferredStyleVariations","localAutosaveInterval"],"mappings":";;;;;;AAAO,MAAMA,oBAAoB,GAAG;AACnCC,EAAAA,UAAU,EAAE,QADuB;AAEnCC,EAAAA,MAAM,EAAE;AACP,mBAAe;AACdC,MAAAA,MAAM,EAAE;AADM;AADR,GAF2B;AAOnCC,EAAAA,gBAAgB,EAAE,EAPiB;AAQnCC,EAAAA,wBAAwB,EAAE,EARS;AASnCC,EAAAA,qBAAqB,EAAE;AATY,CAA7B","sourcesContent":["export const PREFERENCES_DEFAULTS = {\n\teditorMode: 'visual',\n\tpanels: {\n\t\t'post-status': {\n\t\t\topened: true,\n\t\t},\n\t},\n\thiddenBlockTypes: [],\n\tpreferredStyleVariations: {},\n\tlocalAutosaveInterval: 15,\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/store/defaults.js"],"names":["PREFERENCES_DEFAULTS","editorMode","panels","opened","hiddenBlockTypes","preferredStyleVariations","localAutosaveInterval"],"mappings":"AAAA,OAAO,MAAMA,oBAAoB,GAAG;AACnCC,EAAAA,UAAU,EAAE,QADuB;AAEnCC,EAAAA,MAAM,EAAE;AACP,mBAAe;AACdC,MAAAA,MAAM,EAAE;AADM;AADR,GAF2B;AAOnCC,EAAAA,gBAAgB,EAAE,EAPiB;AAQnCC,EAAAA,wBAAwB,EAAE,EARS;AASnCC,EAAAA,qBAAqB,EAAE;AATY,CAA7B","sourcesContent":["export const PREFERENCES_DEFAULTS = {\n\teditorMode: 'visual',\n\tpanels: {\n\t\t'post-status': {\n\t\t\topened: true,\n\t\t},\n\t},\n\thiddenBlockTypes: [],\n\tpreferredStyleVariations: {},\n\tlocalAutosaveInterval: 15,\n};\n"]}
|