@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
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { castArray, reduce } from 'lodash';
|
|
4
|
+
import { castArray, reduce, without } from 'lodash';
|
|
5
5
|
/**
|
|
6
6
|
* WordPress dependencies
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import
|
|
10
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
11
11
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
12
|
-
import {
|
|
12
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
13
13
|
import { speak } from '@wordpress/a11y';
|
|
14
14
|
import { store as noticesStore } from '@wordpress/notices';
|
|
15
15
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -25,22 +25,24 @@ import { store as editPostStore } from '.';
|
|
|
25
25
|
* Returns an action object used in signalling that the user opened an editor sidebar.
|
|
26
26
|
*
|
|
27
27
|
* @param {?string} name Sidebar name to be opened.
|
|
28
|
-
*
|
|
29
|
-
* @yield {Object} Action object.
|
|
30
28
|
*/
|
|
31
29
|
|
|
32
|
-
export
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
export const openGeneralSidebar = name => _ref => {
|
|
31
|
+
let {
|
|
32
|
+
registry
|
|
33
|
+
} = _ref;
|
|
34
|
+
return registry.dispatch(interfaceStore).enableComplementaryArea(editPostStore.name, name);
|
|
35
|
+
};
|
|
35
36
|
/**
|
|
36
37
|
* Returns an action object signalling that the user closed the sidebar.
|
|
37
|
-
*
|
|
38
|
-
* @yield {Object} Action object.
|
|
39
38
|
*/
|
|
40
39
|
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
export const closeGeneralSidebar = () => _ref2 => {
|
|
41
|
+
let {
|
|
42
|
+
registry
|
|
43
|
+
} = _ref2;
|
|
44
|
+
return registry.dispatch(interfaceStore).disableComplementaryArea(editPostStore.name);
|
|
45
|
+
};
|
|
44
46
|
/**
|
|
45
47
|
* Returns an action object used in signalling that the user opened a modal.
|
|
46
48
|
*
|
|
@@ -149,47 +151,48 @@ export function removeEditorPanel(panelName) {
|
|
|
149
151
|
* @param {string} feature Feature name.
|
|
150
152
|
*/
|
|
151
153
|
|
|
152
|
-
export
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
export const toggleFeature = feature => _ref3 => {
|
|
155
|
+
let {
|
|
156
|
+
registry
|
|
157
|
+
} = _ref3;
|
|
158
|
+
return registry.dispatch(preferencesStore).toggle('core/edit-post', feature);
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Triggers an action used to switch editor mode.
|
|
162
|
+
*
|
|
163
|
+
* @param {string} mode The editor mode.
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
export const switchEditorMode = mode => _ref4 => {
|
|
167
|
+
let {
|
|
168
|
+
dispatch,
|
|
169
|
+
registry
|
|
170
|
+
} = _ref4;
|
|
171
|
+
dispatch({
|
|
157
172
|
type: 'SWITCH_MODE',
|
|
158
173
|
mode
|
|
159
|
-
}; // Unselect blocks when we switch to the code editor.
|
|
174
|
+
}); // Unselect blocks when we switch to the code editor.
|
|
160
175
|
|
|
161
176
|
if (mode !== 'visual') {
|
|
162
|
-
|
|
177
|
+
registry.dispatch(blockEditorStore).clearSelectedBlock();
|
|
163
178
|
}
|
|
164
179
|
|
|
165
180
|
const message = mode === 'visual' ? __('Visual editor selected') : __('Code editor selected');
|
|
166
181
|
speak(message, 'assertive');
|
|
167
|
-
}
|
|
182
|
+
};
|
|
168
183
|
/**
|
|
169
184
|
* Triggers an action object used to toggle a plugin name flag.
|
|
170
185
|
*
|
|
171
186
|
* @param {string} pluginName Plugin name.
|
|
172
187
|
*/
|
|
173
188
|
|
|
174
|
-
export
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
*
|
|
182
|
-
* @param {string[]} blockNames Names of block types to hide.
|
|
183
|
-
*
|
|
184
|
-
* @return {Object} Action object.
|
|
185
|
-
*/
|
|
186
|
-
|
|
187
|
-
export function hideBlockTypes(blockNames) {
|
|
188
|
-
return {
|
|
189
|
-
type: 'HIDE_BLOCK_TYPES',
|
|
190
|
-
blockNames: castArray(blockNames)
|
|
191
|
-
};
|
|
192
|
-
}
|
|
189
|
+
export const togglePinnedPluginItem = pluginName => _ref5 => {
|
|
190
|
+
let {
|
|
191
|
+
registry
|
|
192
|
+
} = _ref5;
|
|
193
|
+
const isPinned = registry.select(interfaceStore).isItemPinned('core/edit-post', pluginName);
|
|
194
|
+
registry.dispatch(interfaceStore)[isPinned ? 'unpinItem' : 'pinItem']('core/edit-post', pluginName);
|
|
195
|
+
};
|
|
193
196
|
/**
|
|
194
197
|
* Returns an action object used in signaling that a style should be auto-applied when a block is created.
|
|
195
198
|
*
|
|
@@ -221,45 +224,66 @@ export function __experimentalUpdateLocalAutosaveInterval(interval) {
|
|
|
221
224
|
};
|
|
222
225
|
}
|
|
223
226
|
/**
|
|
224
|
-
*
|
|
225
|
-
* name(s) should be shown.
|
|
227
|
+
* Update the provided block types to be visible.
|
|
226
228
|
*
|
|
227
229
|
* @param {string[]} blockNames Names of block types to show.
|
|
230
|
+
*/
|
|
231
|
+
|
|
232
|
+
export const showBlockTypes = blockNames => _ref6 => {
|
|
233
|
+
var _registry$select$get;
|
|
234
|
+
|
|
235
|
+
let {
|
|
236
|
+
registry
|
|
237
|
+
} = _ref6;
|
|
238
|
+
const existingBlockNames = (_registry$select$get = registry.select(preferencesStore).get('core/edit-post', 'hiddenBlockTypes')) !== null && _registry$select$get !== void 0 ? _registry$select$get : [];
|
|
239
|
+
const newBlockNames = without(existingBlockNames, ...castArray(blockNames));
|
|
240
|
+
registry.dispatch(preferencesStore).set('core/edit-post', 'hiddenBlockTypes', newBlockNames);
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Update the provided block types to be hidden.
|
|
228
244
|
*
|
|
229
|
-
* @
|
|
245
|
+
* @param {string[]} blockNames Names of block types to hide.
|
|
230
246
|
*/
|
|
231
247
|
|
|
232
|
-
export
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
248
|
+
export const hideBlockTypes = blockNames => _ref7 => {
|
|
249
|
+
var _registry$select$get2;
|
|
250
|
+
|
|
251
|
+
let {
|
|
252
|
+
registry
|
|
253
|
+
} = _ref7;
|
|
254
|
+
const existingBlockNames = (_registry$select$get2 = registry.select(preferencesStore).get('core/edit-post', 'hiddenBlockTypes')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : [];
|
|
255
|
+
const mergedBlockNames = new Set([...existingBlockNames, ...castArray(blockNames)]);
|
|
256
|
+
registry.dispatch(preferencesStore).set('core/edit-post', 'hiddenBlockTypes', [...mergedBlockNames]);
|
|
257
|
+
};
|
|
238
258
|
/**
|
|
239
259
|
* Returns an action object used in signaling
|
|
240
260
|
* what Meta boxes are available in which location.
|
|
241
261
|
*
|
|
242
262
|
* @param {Object} metaBoxesPerLocation Meta boxes per location.
|
|
243
|
-
*
|
|
244
|
-
* @yield {Object} Action object.
|
|
245
263
|
*/
|
|
246
264
|
|
|
247
|
-
export
|
|
248
|
-
|
|
265
|
+
export const setAvailableMetaBoxesPerLocation = metaBoxesPerLocation => _ref8 => {
|
|
266
|
+
let {
|
|
267
|
+
dispatch
|
|
268
|
+
} = _ref8;
|
|
269
|
+
return dispatch({
|
|
249
270
|
type: 'SET_META_BOXES_PER_LOCATIONS',
|
|
250
271
|
metaBoxesPerLocation
|
|
251
|
-
};
|
|
252
|
-
}
|
|
272
|
+
});
|
|
273
|
+
};
|
|
253
274
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
* @yield {Object} Action object.
|
|
275
|
+
* Update a metabox.
|
|
257
276
|
*/
|
|
258
277
|
|
|
259
|
-
export
|
|
260
|
-
|
|
278
|
+
export const requestMetaBoxUpdates = () => async _ref9 => {
|
|
279
|
+
let {
|
|
280
|
+
registry,
|
|
281
|
+
select,
|
|
282
|
+
dispatch
|
|
283
|
+
} = _ref9;
|
|
284
|
+
dispatch({
|
|
261
285
|
type: 'REQUEST_META_BOX_UPDATES'
|
|
262
|
-
}; // Saves the wp_editor fields
|
|
286
|
+
}); // Saves the wp_editor fields.
|
|
263
287
|
|
|
264
288
|
if (window.tinyMCE) {
|
|
265
289
|
window.tinyMCE.triggerSave();
|
|
@@ -267,11 +291,11 @@ export function* requestMetaBoxUpdates() {
|
|
|
267
291
|
// If we do not provide this data, the post will be overridden with the default values.
|
|
268
292
|
|
|
269
293
|
|
|
270
|
-
const post =
|
|
271
|
-
const additionalData = [post.comment_status ? ['comment_status', post.comment_status] : false, post.ping_status ? ['ping_status', post.ping_status] : false, post.sticky ? ['sticky', post.sticky] : false, post.author ? ['post_author', post.author] : false].filter(Boolean); // We gather all the metaboxes locations data and the base form data
|
|
294
|
+
const post = registry.select(editorStore).getCurrentPost();
|
|
295
|
+
const additionalData = [post.comment_status ? ['comment_status', post.comment_status] : false, post.ping_status ? ['ping_status', post.ping_status] : false, post.sticky ? ['sticky', post.sticky] : false, post.author ? ['post_author', post.author] : false].filter(Boolean); // We gather all the metaboxes locations data and the base form data.
|
|
272
296
|
|
|
273
297
|
const baseFormData = new window.FormData(document.querySelector('.metabox-base-form'));
|
|
274
|
-
const activeMetaBoxLocations =
|
|
298
|
+
const activeMetaBoxLocations = select.getActiveMetaBoxLocations();
|
|
275
299
|
const formDataToMerge = [baseFormData, ...activeMetaBoxLocations.map(location => new window.FormData(getMetaBoxContainer(location)))]; // Merge all form data objects into a single one.
|
|
276
300
|
|
|
277
301
|
const formData = reduce(formDataToMerge, (memo, currentFormData) => {
|
|
@@ -281,24 +305,24 @@ export function* requestMetaBoxUpdates() {
|
|
|
281
305
|
|
|
282
306
|
return memo;
|
|
283
307
|
}, new window.FormData());
|
|
284
|
-
additionalData.forEach(
|
|
285
|
-
let [key, value] =
|
|
308
|
+
additionalData.forEach(_ref10 => {
|
|
309
|
+
let [key, value] = _ref10;
|
|
286
310
|
return formData.append(key, value);
|
|
287
311
|
});
|
|
288
312
|
|
|
289
313
|
try {
|
|
290
|
-
// Save the metaboxes
|
|
291
|
-
|
|
314
|
+
// Save the metaboxes.
|
|
315
|
+
await apiFetch({
|
|
292
316
|
url: window._wpMetaBoxUrl,
|
|
293
317
|
method: 'POST',
|
|
294
318
|
body: formData,
|
|
295
319
|
parse: false
|
|
296
320
|
});
|
|
297
|
-
|
|
321
|
+
dispatch.metaBoxUpdatesSuccess();
|
|
298
322
|
} catch {
|
|
299
|
-
|
|
323
|
+
dispatch.metaBoxUpdatesFailure();
|
|
300
324
|
}
|
|
301
|
-
}
|
|
325
|
+
};
|
|
302
326
|
/**
|
|
303
327
|
* Returns an action object used to signal a successful meta box update.
|
|
304
328
|
*
|
|
@@ -386,66 +410,83 @@ export function setIsEditingTemplate(value) {
|
|
|
386
410
|
* @param {boolean} newTemplate Is new template.
|
|
387
411
|
*/
|
|
388
412
|
|
|
389
|
-
export function
|
|
413
|
+
export const __unstableSwitchToTemplateMode = function () {
|
|
390
414
|
let newTemplate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
415
|
+
return _ref11 => {
|
|
416
|
+
let {
|
|
417
|
+
registry,
|
|
418
|
+
select,
|
|
419
|
+
dispatch
|
|
420
|
+
} = _ref11;
|
|
421
|
+
dispatch(setIsEditingTemplate(true));
|
|
422
|
+
const isWelcomeGuideActive = select.isFeatureActive('welcomeGuideTemplate');
|
|
423
|
+
|
|
424
|
+
if (!isWelcomeGuideActive) {
|
|
425
|
+
const message = newTemplate ? __("Custom template created. You're in template mode now.") : __('Editing template. Changes made here affect all posts and pages that use the template.');
|
|
426
|
+
registry.dispatch(noticesStore).createSuccessNotice(message, {
|
|
427
|
+
type: 'snackbar'
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
};
|
|
401
432
|
/**
|
|
402
433
|
* Create a block based template.
|
|
403
434
|
*
|
|
404
435
|
* @param {Object?} template Template to create and assign.
|
|
405
436
|
*/
|
|
406
437
|
|
|
407
|
-
export
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
438
|
+
export const __unstableCreateTemplate = template => async _ref12 => {
|
|
439
|
+
let {
|
|
440
|
+
registry
|
|
441
|
+
} = _ref12;
|
|
442
|
+
const savedTemplate = await registry.dispatch(coreStore).saveEntityRecord('postType', 'wp_template', template);
|
|
443
|
+
const post = registry.select(editorStore).getCurrentPost();
|
|
444
|
+
registry.dispatch(coreStore).editEntityRecord('postType', post.type, post.id, {
|
|
411
445
|
template: savedTemplate.slug
|
|
412
446
|
});
|
|
413
|
-
}
|
|
447
|
+
};
|
|
414
448
|
let metaBoxesInitialized = false;
|
|
415
449
|
/**
|
|
416
450
|
* Initializes WordPress `postboxes` script and the logic for saving meta boxes.
|
|
417
451
|
*/
|
|
418
452
|
|
|
419
|
-
export
|
|
420
|
-
|
|
453
|
+
export const initializeMetaBoxes = () => _ref13 => {
|
|
454
|
+
let {
|
|
455
|
+
registry,
|
|
456
|
+
select,
|
|
457
|
+
dispatch
|
|
458
|
+
} = _ref13;
|
|
459
|
+
|
|
460
|
+
const isEditorReady = registry.select(editorStore).__unstableIsEditorReady();
|
|
421
461
|
|
|
422
462
|
if (!isEditorReady) {
|
|
423
463
|
return;
|
|
424
|
-
}
|
|
464
|
+
} // Only initialize once.
|
|
425
465
|
|
|
426
|
-
const postType = yield controls.select(editorStore, 'getCurrentPostType'); // Only initialize once.
|
|
427
466
|
|
|
428
467
|
if (metaBoxesInitialized) {
|
|
429
468
|
return;
|
|
430
469
|
}
|
|
431
470
|
|
|
471
|
+
const postType = registry.select(editorStore).getCurrentPostType();
|
|
472
|
+
|
|
432
473
|
if (window.postboxes.page !== postType) {
|
|
433
474
|
window.postboxes.add_postbox_toggles(postType);
|
|
434
475
|
}
|
|
435
476
|
|
|
436
477
|
metaBoxesInitialized = true;
|
|
437
|
-
let wasSavingPost =
|
|
438
|
-
let wasAutosavingPost =
|
|
439
|
-
const hasMetaBoxes =
|
|
478
|
+
let wasSavingPost = registry.select(editorStore).isSavingPost();
|
|
479
|
+
let wasAutosavingPost = registry.select(editorStore).isAutosavingPost();
|
|
480
|
+
const hasMetaBoxes = select.hasMetaBoxes(); // Save metaboxes when performing a full save on the post.
|
|
440
481
|
|
|
441
|
-
subscribe(() => {
|
|
442
|
-
const isSavingPost = select(editorStore).isSavingPost();
|
|
443
|
-
const isAutosavingPost = select(editorStore).isAutosavingPost(); // Save metaboxes on save completion, except for autosaves that are not a post preview.
|
|
482
|
+
registry.subscribe(async () => {
|
|
483
|
+
const isSavingPost = registry.select(editorStore).isSavingPost();
|
|
484
|
+
const isAutosavingPost = registry.select(editorStore).isAutosavingPost(); // Save metaboxes on save completion, except for autosaves that are not a post preview.
|
|
444
485
|
//
|
|
445
486
|
// Meta boxes are initialized once at page load. It is not necessary to
|
|
446
487
|
// account for updates on each state change.
|
|
447
488
|
//
|
|
448
|
-
// See: https://github.com/WordPress/WordPress/blob/5.1.1/wp-admin/includes/post.php#L2307-L2309
|
|
489
|
+
// See: https://github.com/WordPress/WordPress/blob/5.1.1/wp-admin/includes/post.php#L2307-L2309.
|
|
449
490
|
|
|
450
491
|
const shouldTriggerMetaboxesSave = hasMetaBoxes && wasSavingPost && !isSavingPost && !wasAutosavingPost; // Save current state for next inspection.
|
|
451
492
|
|
|
@@ -453,11 +494,11 @@ export function* initializeMetaBoxes() {
|
|
|
453
494
|
wasAutosavingPost = isAutosavingPost;
|
|
454
495
|
|
|
455
496
|
if (shouldTriggerMetaboxesSave) {
|
|
456
|
-
dispatch
|
|
497
|
+
await dispatch.requestMetaBoxUpdates();
|
|
457
498
|
}
|
|
458
499
|
});
|
|
459
|
-
|
|
500
|
+
dispatch({
|
|
460
501
|
type: 'META_BOXES_INITIALIZED'
|
|
461
|
-
};
|
|
462
|
-
}
|
|
502
|
+
});
|
|
503
|
+
};
|
|
463
504
|
//# sourceMappingURL=actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/store/actions.js"],"names":["castArray","reduce","__","apiFetch","store","interfaceStore","controls","select","subscribe","dispatch","speak","noticesStore","coreStore","blockEditorStore","editorStore","getMetaBoxContainer","editPostStore","openGeneralSidebar","name","closeGeneralSidebar","openModal","type","closeModal","openPublishSidebar","closePublishSidebar","togglePublishSidebar","toggleEditorPanelEnabled","panelName","toggleEditorPanelOpened","removeEditorPanel","toggleFeature","feature","switchEditorMode","mode","message","togglePinnedPluginItem","pluginName","isPinned","hideBlockTypes","blockNames","updatePreferredStyleVariations","blockName","blockStyle","__experimentalUpdateLocalAutosaveInterval","interval","showBlockTypes","setAvailableMetaBoxesPerLocation","metaBoxesPerLocation","requestMetaBoxUpdates","window","tinyMCE","triggerSave","post","additionalData","comment_status","ping_status","sticky","author","filter","Boolean","baseFormData","FormData","document","querySelector","activeMetaBoxLocations","formDataToMerge","map","location","formData","memo","currentFormData","key","value","append","forEach","url","_wpMetaBoxUrl","method","body","parse","metaBoxUpdatesSuccess","metaBoxUpdatesFailure","__experimentalSetPreviewDeviceType","deviceType","setIsInserterOpened","setIsListViewOpened","isOpen","setIsEditingTemplate","__unstableSwitchToTemplateMode","newTemplate","isWelcomeGuideActive","__unstableCreateTemplate","template","savedTemplate","id","slug","metaBoxesInitialized","initializeMetaBoxes","isEditorReady","postType","postboxes","page","add_postbox_toggles","wasSavingPost","wasAutosavingPost","hasMetaBoxes","isSavingPost","isAutosavingPost","shouldTriggerMetaboxesSave"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,QAAlC;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,0BAAzB;AACA,SAASC,KAAK,IAAIC,cAAlB,QAAwC,sBAAxC;AACA,SAASC,QAAT,EAAmBC,MAAnB,EAA2BC,SAA3B,EAAsCC,QAAtC,QAAsD,iBAAtD;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASN,KAAK,IAAIO,YAAlB,QAAsC,oBAAtC;AACA,SAASP,KAAK,IAAIQ,SAAlB,QAAmC,sBAAnC;AACA,SAASR,KAAK,IAAIS,gBAAlB,QAA0C,yBAA1C;AACA,SAAST,KAAK,IAAIU,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SAASC,mBAAT,QAAoC,qBAApC;AACA,SAASX,KAAK,IAAIY,aAAlB,QAAuC,GAAvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,UAAUC,kBAAV,CAA8BC,IAA9B,EAAqC;AAC3C,QAAMZ,QAAQ,CAACG,QAAT,CACLJ,cADK,EAEL,yBAFK,EAGLW,aAAa,CAACE,IAHT,EAILA,IAJK,CAAN;AAMA;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,UAAUC,mBAAV,GAAgC;AACtC,QAAMb,QAAQ,CAACG,QAAT,CACLJ,cADK,EAEL,0BAFK,EAGLW,aAAa,CAACE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B;AAEA,MAAIO,aAAa,GAAG,MAAMjG,QAAQ,CAACC,MAAT,CAAiBO,WAAjB,EAA8B,cAA9B,CAA1B;AACA,MAAI0F,iBAAiB,GAAG,MAAMlG,QAAQ,CAACC,MAAT,CAC7BO,WAD6B,EAE7B,kBAF6B,CAA9B;AAIA,QAAM2F,YAAY,GAAG,MAAMnG,QAAQ,CAACC,MAAT,CAAiBS,aAAjB,EAAgC,cAAhC,CAA3B,CA5BsC,CA8BtC;;AACAR,EAAAA,SAAS,CAAE,MAAM;AAChB,UAAMkG,YAAY,GAAGnG,MAAM,CAAEO,WAAF,CAAN,CAAsB4F,YAAtB,EAArB;AACA,UAAMC,gBAAgB,GAAGpG,MAAM,CAAEO,WAAF,CAAN,CAAsB6F,gBAAtB,EAAzB,CAFgB,CAIhB;AACA;AACA;AACA;AACA;AACA;;AACA,UAAMC,0BAA0B,GAC/BH,YAAY,IACZF,aADA,IAEA,CAAEG,YAFF,IAGA,CAAEF,iBAJH,CAVgB,CAgBhB;;AACAD,IAAAA,aAAa,GAAGG,YAAhB;AACAF,IAAAA,iBAAiB,GAAGG,gBAApB;;AAEA,QAAKC,0BAAL,EAAkC;AACjCnG,MAAAA,QAAQ,CAAEO,aAAF,CAAR,CAA0BgC,qBAA1B;AACA;AACD,GAvBQ,CAAT;AAyBA,SAAO;AACN3B,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA","sourcesContent":["/**\n * External dependencies\n */\nimport { castArray, reduce } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { apiFetch } from '@wordpress/data-controls';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { controls, select, subscribe, dispatch } from '@wordpress/data';\nimport { speak } from '@wordpress/a11y';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { getMetaBoxContainer } from '../utils/meta-boxes';\nimport { store as editPostStore } from '.';\n/**\n * Returns an action object used in signalling that the user opened an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n *\n * @yield {Object} Action object.\n */\nexport function* openGeneralSidebar( name ) {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'enableComplementaryArea',\n\t\teditPostStore.name,\n\t\tname\n\t);\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @yield {Object} Action object.\n */\nexport function* closeGeneralSidebar() {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'disableComplementaryArea',\n\t\teditPostStore.name\n\t);\n}\n\n/**\n * Returns an action object used in signalling that the user opened a modal.\n *\n * @param {string} name A string that uniquely identifies the modal.\n *\n * @return {Object} Action object.\n */\nexport function openModal( name ) {\n\treturn {\n\t\ttype: 'OPEN_MODAL',\n\t\tname,\n\t};\n}\n\n/**\n * Returns an action object signalling that the user closed a modal.\n *\n * @return {Object} Action object.\n */\nexport function closeModal() {\n\treturn {\n\t\ttype: 'CLOSE_MODAL',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user opened the publish\n * sidebar.\n *\n * @return {Object} Action object\n */\nexport function openPublishSidebar() {\n\treturn {\n\t\ttype: 'OPEN_PUBLISH_SIDEBAR',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user closed the\n * publish sidebar.\n *\n * @return {Object} Action object.\n */\nexport function closePublishSidebar() {\n\treturn {\n\t\ttype: 'CLOSE_PUBLISH_SIDEBAR',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user toggles the publish sidebar.\n *\n * @return {Object} Action object\n */\nexport function togglePublishSidebar() {\n\treturn {\n\t\ttype: 'TOGGLE_PUBLISH_SIDEBAR',\n\t};\n}\n\n/**\n * Returns an action object used to enable or disable a panel in the editor.\n *\n * @param {string} panelName A string that identifies the panel to enable or disable.\n *\n * @return {Object} Action object.\n */\nexport function toggleEditorPanelEnabled( panelName ) {\n\treturn {\n\t\ttype: 'TOGGLE_PANEL_ENABLED',\n\t\tpanelName,\n\t};\n}\n\n/**\n * Returns an action object used to open or close a panel in the editor.\n *\n * @param {string} panelName A string that identifies the panel to open or close.\n *\n * @return {Object} Action object.\n */\nexport function toggleEditorPanelOpened( panelName ) {\n\treturn {\n\t\ttype: 'TOGGLE_PANEL_OPENED',\n\t\tpanelName,\n\t};\n}\n\n/**\n * Returns an action object used to remove a panel from the editor.\n *\n * @param {string} panelName A string that identifies the panel to remove.\n *\n * @return {Object} Action object.\n */\nexport function removeEditorPanel( panelName ) {\n\treturn {\n\t\ttype: 'REMOVE_PANEL',\n\t\tpanelName,\n\t};\n}\n\n/**\n * Triggers an action used to toggle a feature flag.\n *\n * @param {string} feature Feature name.\n */\nexport function* toggleFeature( feature ) {\n\tyield controls.dispatch(\n\t\tinterfaceStore.name,\n\t\t'toggleFeature',\n\t\t'core/edit-post',\n\t\tfeature\n\t);\n}\n\nexport function* switchEditorMode( mode ) {\n\tyield {\n\t\ttype: 'SWITCH_MODE',\n\t\tmode,\n\t};\n\n\t// Unselect blocks when we switch to the code editor.\n\tif ( mode !== 'visual' ) {\n\t\tyield controls.dispatch( blockEditorStore, 'clearSelectedBlock' );\n\t}\n\n\tconst message =\n\t\tmode === 'visual'\n\t\t\t? __( 'Visual editor selected' )\n\t\t\t: __( 'Code editor selected' );\n\tspeak( message, 'assertive' );\n}\n\n/**\n * Triggers an action object used to toggle a plugin name flag.\n *\n * @param {string} pluginName Plugin name.\n */\nexport function* togglePinnedPluginItem( pluginName ) {\n\tconst isPinned = yield controls.select(\n\t\tinterfaceStore,\n\t\t'isItemPinned',\n\t\t'core/edit-post',\n\t\tpluginName\n\t);\n\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\tisPinned ? 'unpinItem' : 'pinItem',\n\t\t'core/edit-post',\n\t\tpluginName\n\t);\n}\n\n/**\n * Returns an action object used in signalling that block types by the given\n * name(s) should be hidden.\n *\n * @param {string[]} blockNames Names of block types to hide.\n *\n * @return {Object} Action object.\n */\nexport function hideBlockTypes( blockNames ) {\n\treturn {\n\t\ttype: 'HIDE_BLOCK_TYPES',\n\t\tblockNames: castArray( blockNames ),\n\t};\n}\n\n/**\n * Returns an action object used in signaling that a style should be auto-applied when a block is created.\n *\n * @param {string} blockName Name of the block.\n * @param {?string} blockStyle Name of the style that should be auto applied. If undefined, the \"auto apply\" setting of the block is removed.\n *\n * @return {Object} Action object.\n */\nexport function updatePreferredStyleVariations( blockName, blockStyle ) {\n\treturn {\n\t\ttype: 'UPDATE_PREFERRED_STYLE_VARIATIONS',\n\t\tblockName,\n\t\tblockStyle,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the editor should attempt\n * to locally autosave the current post every `interval` seconds.\n *\n * @param {number} interval The new interval, in seconds.\n * @return {Object} Action object.\n */\nexport function __experimentalUpdateLocalAutosaveInterval( interval ) {\n\treturn {\n\t\ttype: 'UPDATE_LOCAL_AUTOSAVE_INTERVAL',\n\t\tinterval,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that block types by the given\n * name(s) should be shown.\n *\n * @param {string[]} blockNames Names of block types to show.\n *\n * @return {Object} Action object.\n */\nexport function showBlockTypes( blockNames ) {\n\treturn {\n\t\ttype: 'SHOW_BLOCK_TYPES',\n\t\tblockNames: castArray( blockNames ),\n\t};\n}\n\n/**\n * Returns an action object used in signaling\n * what Meta boxes are available in which location.\n *\n * @param {Object} metaBoxesPerLocation Meta boxes per location.\n *\n * @yield {Object} Action object.\n */\nexport function* setAvailableMetaBoxesPerLocation( metaBoxesPerLocation ) {\n\tyield {\n\t\ttype: 'SET_META_BOXES_PER_LOCATIONS',\n\t\tmetaBoxesPerLocation,\n\t};\n}\n\n/**\n * Returns an action object used to request meta box update.\n *\n * @yield {Object} Action object.\n */\nexport function* requestMetaBoxUpdates() {\n\tyield {\n\t\ttype: 'REQUEST_META_BOX_UPDATES',\n\t};\n\n\t// Saves the wp_editor fields\n\tif ( window.tinyMCE ) {\n\t\twindow.tinyMCE.triggerSave();\n\t}\n\n\t// Additional data needed for backward compatibility.\n\t// If we do not provide this data, the post will be overridden with the default values.\n\tconst post = yield controls.select( editorStore, 'getCurrentPost' );\n\tconst additionalData = [\n\t\tpost.comment_status ? [ 'comment_status', post.comment_status ] : false,\n\t\tpost.ping_status ? [ 'ping_status', post.ping_status ] : false,\n\t\tpost.sticky ? [ 'sticky', post.sticky ] : false,\n\t\tpost.author ? [ 'post_author', post.author ] : false,\n\t].filter( Boolean );\n\n\t// We gather all the metaboxes locations data and the base form data\n\tconst baseFormData = new window.FormData(\n\t\tdocument.querySelector( '.metabox-base-form' )\n\t);\n\tconst activeMetaBoxLocations = yield controls.select(\n\t\teditPostStore,\n\t\t'getActiveMetaBoxLocations'\n\t);\n\tconst formDataToMerge = [\n\t\tbaseFormData,\n\t\t...activeMetaBoxLocations.map(\n\t\t\t( location ) =>\n\t\t\t\tnew window.FormData( getMetaBoxContainer( location ) )\n\t\t),\n\t];\n\n\t// Merge all form data objects into a single one.\n\tconst formData = reduce(\n\t\tformDataToMerge,\n\t\t( memo, currentFormData ) => {\n\t\t\tfor ( const [ key, value ] of currentFormData ) {\n\t\t\t\tmemo.append( key, value );\n\t\t\t}\n\t\t\treturn memo;\n\t\t},\n\t\tnew window.FormData()\n\t);\n\tadditionalData.forEach( ( [ key, value ] ) =>\n\t\tformData.append( key, value )\n\t);\n\n\ttry {\n\t\t// Save the metaboxes\n\t\tyield apiFetch( {\n\t\t\turl: window._wpMetaBoxUrl,\n\t\t\tmethod: 'POST',\n\t\t\tbody: formData,\n\t\t\tparse: false,\n\t\t} );\n\t\tyield controls.dispatch( editPostStore, 'metaBoxUpdatesSuccess' );\n\t} catch {\n\t\tyield controls.dispatch( editPostStore, 'metaBoxUpdatesFailure' );\n\t}\n}\n\n/**\n * Returns an action object used to signal a successful meta box update.\n *\n * @return {Object} Action object.\n */\nexport function metaBoxUpdatesSuccess() {\n\treturn {\n\t\ttype: 'META_BOX_UPDATES_SUCCESS',\n\t};\n}\n\n/**\n * Returns an action object used to signal a failed meta box update.\n *\n * @return {Object} Action object.\n */\nexport function metaBoxUpdatesFailure() {\n\treturn {\n\t\ttype: 'META_BOX_UPDATES_FAILURE',\n\t};\n}\n\n/**\n * Returns an action object used to toggle the width of the editing canvas.\n *\n * @param {string} deviceType\n *\n * @return {Object} Action object.\n */\nexport function __experimentalSetPreviewDeviceType( deviceType ) {\n\treturn {\n\t\ttype: 'SET_PREVIEW_DEVICE_TYPE',\n\t\tdeviceType,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the list view.\n *\n * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.\n * @return {Object} Action object.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to switch to template editing.\n *\n * @param {boolean} value Is editing template.\n * @return {Object} Action object.\n */\nexport function setIsEditingTemplate( value ) {\n\treturn {\n\t\ttype: 'SET_IS_EDITING_TEMPLATE',\n\t\tvalue,\n\t};\n}\n\n/**\n * Switches to the template mode.\n *\n * @param {boolean} newTemplate Is new template.\n */\nexport function* __unstableSwitchToTemplateMode( newTemplate = false ) {\n\tyield setIsEditingTemplate( true );\n\n\tconst isWelcomeGuideActive = yield controls.select(\n\t\teditPostStore,\n\t\t'isFeatureActive',\n\t\t'welcomeGuideTemplate'\n\t);\n\n\tif ( ! isWelcomeGuideActive ) {\n\t\tconst message = newTemplate\n\t\t\t? __( \"Custom template created. You're in template mode now.\" )\n\t\t\t: __(\n\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t );\n\t\tyield controls.dispatch( noticesStore, 'createSuccessNotice', message, {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t}\n}\n\n/**\n * Create a block based template.\n *\n * @param {Object?} template Template to create and assign.\n */\nexport function* __unstableCreateTemplate( template ) {\n\tconst savedTemplate = yield controls.dispatch(\n\t\tcoreStore,\n\t\t'saveEntityRecord',\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplate\n\t);\n\tconst post = yield controls.select( editorStore, 'getCurrentPost' );\n\n\tyield controls.dispatch(\n\t\tcoreStore,\n\t\t'editEntityRecord',\n\t\t'postType',\n\t\tpost.type,\n\t\tpost.id,\n\t\t{\n\t\t\ttemplate: savedTemplate.slug,\n\t\t}\n\t);\n}\n\nlet metaBoxesInitialized = false;\n\n/**\n * Initializes WordPress `postboxes` script and the logic for saving meta boxes.\n */\nexport function* initializeMetaBoxes() {\n\tconst isEditorReady = yield controls.select(\n\t\teditorStore,\n\t\t'__unstableIsEditorReady'\n\t);\n\n\tif ( ! isEditorReady ) {\n\t\treturn;\n\t}\n\n\tconst postType = yield controls.select( editorStore, 'getCurrentPostType' );\n\n\t// Only initialize once.\n\tif ( metaBoxesInitialized ) {\n\t\treturn;\n\t}\n\n\tif ( window.postboxes.page !== postType ) {\n\t\twindow.postboxes.add_postbox_toggles( postType );\n\t}\n\n\tmetaBoxesInitialized = true;\n\n\tlet wasSavingPost = yield controls.select( editorStore, 'isSavingPost' );\n\tlet wasAutosavingPost = yield controls.select(\n\t\teditorStore,\n\t\t'isAutosavingPost'\n\t);\n\tconst hasMetaBoxes = yield controls.select( editPostStore, 'hasMetaBoxes' );\n\n\t// Save metaboxes when performing a full save on the post.\n\tsubscribe( () => {\n\t\tconst isSavingPost = select( editorStore ).isSavingPost();\n\t\tconst isAutosavingPost = select( editorStore ).isAutosavingPost();\n\n\t\t// Save metaboxes on save completion, except for autosaves that are not a post preview.\n\t\t//\n\t\t// Meta boxes are initialized once at page load. It is not necessary to\n\t\t// account for updates on each state change.\n\t\t//\n\t\t// See: https://github.com/WordPress/WordPress/blob/5.1.1/wp-admin/includes/post.php#L2307-L2309\n\t\tconst shouldTriggerMetaboxesSave =\n\t\t\thasMetaBoxes &&\n\t\t\twasSavingPost &&\n\t\t\t! isSavingPost &&\n\t\t\t! wasAutosavingPost;\n\n\t\t// Save current state for next inspection.\n\t\twasSavingPost = isSavingPost;\n\t\twasAutosavingPost = isAutosavingPost;\n\n\t\tif ( shouldTriggerMetaboxesSave ) {\n\t\t\tdispatch( editPostStore ).requestMetaBoxUpdates();\n\t\t}\n\t} );\n\n\treturn {\n\t\ttype: 'META_BOXES_INITIALIZED',\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/store/actions.js"],"names":["castArray","reduce","without","__","apiFetch","store","interfaceStore","preferencesStore","speak","noticesStore","coreStore","blockEditorStore","editorStore","getMetaBoxContainer","editPostStore","openGeneralSidebar","name","registry","dispatch","enableComplementaryArea","closeGeneralSidebar","disableComplementaryArea","openModal","type","closeModal","openPublishSidebar","closePublishSidebar","togglePublishSidebar","toggleEditorPanelEnabled","panelName","toggleEditorPanelOpened","removeEditorPanel","toggleFeature","feature","toggle","switchEditorMode","mode","clearSelectedBlock","message","togglePinnedPluginItem","pluginName","isPinned","select","isItemPinned","updatePreferredStyleVariations","blockName","blockStyle","__experimentalUpdateLocalAutosaveInterval","interval","showBlockTypes","blockNames","existingBlockNames","get","newBlockNames","set","hideBlockTypes","mergedBlockNames","Set","setAvailableMetaBoxesPerLocation","metaBoxesPerLocation","requestMetaBoxUpdates","window","tinyMCE","triggerSave","post","getCurrentPost","additionalData","comment_status","ping_status","sticky","author","filter","Boolean","baseFormData","FormData","document","querySelector","activeMetaBoxLocations","getActiveMetaBoxLocations","formDataToMerge","map","location","formData","memo","currentFormData","key","value","append","forEach","url","_wpMetaBoxUrl","method","body","parse","metaBoxUpdatesSuccess","metaBoxUpdatesFailure","__experimentalSetPreviewDeviceType","deviceType","setIsInserterOpened","setIsListViewOpened","isOpen","setIsEditingTemplate","__unstableSwitchToTemplateMode","newTemplate","isWelcomeGuideActive","isFeatureActive","createSuccessNotice","__unstableCreateTemplate","template","savedTemplate","saveEntityRecord","editEntityRecord","id","slug","metaBoxesInitialized","initializeMetaBoxes","isEditorReady","__unstableIsEditorReady","postType","getCurrentPostType","postboxes","page","add_postbox_toggles","wasSavingPost","isSavingPost","wasAutosavingPost","isAutosavingPost","hasMetaBoxes","subscribe","shouldTriggerMetaboxesSave"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,MAApB,EAA4BC,OAA5B,QAA2C,QAA3C;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,OAAOC,QAAP,MAAqB,sBAArB;AACA,SAASC,KAAK,IAAIC,cAAlB,QAAwC,sBAAxC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,wBAA1C;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASH,KAAK,IAAII,YAAlB,QAAsC,oBAAtC;AACA,SAASJ,KAAK,IAAIK,SAAlB,QAAmC,sBAAnC;AACA,SAASL,KAAK,IAAIM,gBAAlB,QAA0C,yBAA1C;AACA,SAASN,KAAK,IAAIO,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SAASC,mBAAT,QAAoC,qBAApC;AACA,SAASR,KAAK,IAAIS,aAAlB,QAAuC,GAAvC;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,kBAAkB,GAAKC,IAAF,IAAY;AAAA,MAAE;AAAEC,IAAAA;AAAF,GAAF;AAAA,SAC7CA,QAAQ,CACNC,QADF,CACYZ,cADZ,EAEEa,uBAFF,CAE2BL,aAAa,CAACE,IAFzC,EAE+CA,IAF/C,CAD6C;AAAA,CAAvC;AAKP;AACA;AACA;;AACA,OAAO,MAAMI,mBAAmB,GAAG,MAAM;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,mBAAjB,CAAsCJ,QAAtC;AACA;;AAEDJ,EAAAA,oBAAoB,GAAG,IAAvB;AAEA,MAAIS,aAAa,GAAG1G,QAAQ,CAACyB,MAAT,CAAiB9B,WAAjB,EAA+BgH,YAA/B,EAApB;AACA,MAAIC,iBAAiB,GAAG5G,QAAQ,CAACyB,MAAT,CAAiB9B,WAAjB,EAA+BkH,gBAA/B,EAAxB;AACA,QAAMC,YAAY,GAAGrF,MAAM,CAACqF,YAAP,EAArB,CArB8E,CAuB9E;;AACA9G,EAAAA,QAAQ,CAAC+G,SAAT,CAAoB,YAAY;AAC/B,UAAMJ,YAAY,GAAG3G,QAAQ,CAACyB,MAAT,CAAiB9B,WAAjB,EAA+BgH,YAA/B,EAArB;AACA,UAAME,gBAAgB,GAAG7G,QAAQ,CAC/ByB,MADuB,CACf9B,WADe,EAEvBkH,gBAFuB,EAAzB,CAF+B,CAM/B;AACA;AACA;AACA;AACA;AACA;;AACA,UAAMG,0BAA0B,GAC/BF,YAAY,IACZJ,aADA,IAEA,CAAEC,YAFF,IAGA,CAAEC,iBAJH,CAZ+B,CAkB/B;;AACAF,IAAAA,aAAa,GAAGC,YAAhB;AACAC,IAAAA,iBAAiB,GAAGC,gBAApB;;AAEA,QAAKG,0BAAL,EAAkC;AACjC,YAAM/G,QAAQ,CAAC0C,qBAAT,EAAN;AACA;AACD,GAzBD;AA2BA1C,EAAAA,QAAQ,CAAE;AACTK,IAAAA,IAAI,EAAE;AADG,GAAF,CAAR;AAGA,CAtDM","sourcesContent":["/**\n * External dependencies\n */\nimport { castArray, reduce, without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { speak } from '@wordpress/a11y';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { getMetaBoxContainer } from '../utils/meta-boxes';\nimport { store as editPostStore } from '.';\n\n/**\n * Returns an action object used in signalling that the user opened an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n */\nexport const openGeneralSidebar = ( name ) => ( { registry } ) =>\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t.enableComplementaryArea( editPostStore.name, name );\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n */\nexport const closeGeneralSidebar = () => ( { registry } ) =>\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t.disableComplementaryArea( editPostStore.name );\n\n/**\n * Returns an action object used in signalling that the user opened a modal.\n *\n * @param {string} name A string that uniquely identifies the modal.\n *\n * @return {Object} Action object.\n */\nexport function openModal( name ) {\n\treturn {\n\t\ttype: 'OPEN_MODAL',\n\t\tname,\n\t};\n}\n\n/**\n * Returns an action object signalling that the user closed a modal.\n *\n * @return {Object} Action object.\n */\nexport function closeModal() {\n\treturn {\n\t\ttype: 'CLOSE_MODAL',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user opened the publish\n * sidebar.\n *\n * @return {Object} Action object\n */\nexport function openPublishSidebar() {\n\treturn {\n\t\ttype: 'OPEN_PUBLISH_SIDEBAR',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user closed the\n * publish sidebar.\n *\n * @return {Object} Action object.\n */\nexport function closePublishSidebar() {\n\treturn {\n\t\ttype: 'CLOSE_PUBLISH_SIDEBAR',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user toggles the publish sidebar.\n *\n * @return {Object} Action object\n */\nexport function togglePublishSidebar() {\n\treturn {\n\t\ttype: 'TOGGLE_PUBLISH_SIDEBAR',\n\t};\n}\n\n/**\n * Returns an action object used to enable or disable a panel in the editor.\n *\n * @param {string} panelName A string that identifies the panel to enable or disable.\n *\n * @return {Object} Action object.\n */\nexport function toggleEditorPanelEnabled( panelName ) {\n\treturn {\n\t\ttype: 'TOGGLE_PANEL_ENABLED',\n\t\tpanelName,\n\t};\n}\n\n/**\n * Returns an action object used to open or close a panel in the editor.\n *\n * @param {string} panelName A string that identifies the panel to open or close.\n *\n * @return {Object} Action object.\n */\nexport function toggleEditorPanelOpened( panelName ) {\n\treturn {\n\t\ttype: 'TOGGLE_PANEL_OPENED',\n\t\tpanelName,\n\t};\n}\n\n/**\n * Returns an action object used to remove a panel from the editor.\n *\n * @param {string} panelName A string that identifies the panel to remove.\n *\n * @return {Object} Action object.\n */\nexport function removeEditorPanel( panelName ) {\n\treturn {\n\t\ttype: 'REMOVE_PANEL',\n\t\tpanelName,\n\t};\n}\n\n/**\n * Triggers an action used to toggle a feature flag.\n *\n * @param {string} feature Feature name.\n */\nexport const toggleFeature = ( feature ) => ( { registry } ) =>\n\tregistry.dispatch( preferencesStore ).toggle( 'core/edit-post', feature );\n\n/**\n * Triggers an action used to switch editor mode.\n *\n * @param {string} mode The editor mode.\n */\nexport const switchEditorMode = ( mode ) => ( { dispatch, registry } ) => {\n\tdispatch( {\n\t\ttype: 'SWITCH_MODE',\n\t\tmode,\n\t} );\n\n\t// Unselect blocks when we switch to the code editor.\n\tif ( mode !== 'visual' ) {\n\t\tregistry.dispatch( blockEditorStore ).clearSelectedBlock();\n\t}\n\n\tconst message =\n\t\tmode === 'visual'\n\t\t\t? __( 'Visual editor selected' )\n\t\t\t: __( 'Code editor selected' );\n\tspeak( message, 'assertive' );\n};\n\n/**\n * Triggers an action object used to toggle a plugin name flag.\n *\n * @param {string} pluginName Plugin name.\n */\nexport const togglePinnedPluginItem = ( pluginName ) => ( { registry } ) => {\n\tconst isPinned = registry\n\t\t.select( interfaceStore )\n\t\t.isItemPinned( 'core/edit-post', pluginName );\n\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t[ isPinned ? 'unpinItem' : 'pinItem' ]( 'core/edit-post', pluginName );\n};\n\n/**\n * Returns an action object used in signaling that a style should be auto-applied when a block is created.\n *\n * @param {string} blockName Name of the block.\n * @param {?string} blockStyle Name of the style that should be auto applied. If undefined, the \"auto apply\" setting of the block is removed.\n *\n * @return {Object} Action object.\n */\nexport function updatePreferredStyleVariations( blockName, blockStyle ) {\n\treturn {\n\t\ttype: 'UPDATE_PREFERRED_STYLE_VARIATIONS',\n\t\tblockName,\n\t\tblockStyle,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the editor should attempt\n * to locally autosave the current post every `interval` seconds.\n *\n * @param {number} interval The new interval, in seconds.\n * @return {Object} Action object.\n */\nexport function __experimentalUpdateLocalAutosaveInterval( interval ) {\n\treturn {\n\t\ttype: 'UPDATE_LOCAL_AUTOSAVE_INTERVAL',\n\t\tinterval,\n\t};\n}\n\n/**\n * Update the provided block types to be visible.\n *\n * @param {string[]} blockNames Names of block types to show.\n */\nexport const showBlockTypes = ( blockNames ) => ( { registry } ) => {\n\tconst existingBlockNames =\n\t\tregistry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( 'core/edit-post', 'hiddenBlockTypes' ) ?? [];\n\n\tconst newBlockNames = without(\n\t\texistingBlockNames,\n\t\t...castArray( blockNames )\n\t);\n\n\tregistry\n\t\t.dispatch( preferencesStore )\n\t\t.set( 'core/edit-post', 'hiddenBlockTypes', newBlockNames );\n};\n\n/**\n * Update the provided block types to be hidden.\n *\n * @param {string[]} blockNames Names of block types to hide.\n */\nexport const hideBlockTypes = ( blockNames ) => ( { registry } ) => {\n\tconst existingBlockNames =\n\t\tregistry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( 'core/edit-post', 'hiddenBlockTypes' ) ?? [];\n\n\tconst mergedBlockNames = new Set( [\n\t\t...existingBlockNames,\n\t\t...castArray( blockNames ),\n\t] );\n\n\tregistry\n\t\t.dispatch( preferencesStore )\n\t\t.set( 'core/edit-post', 'hiddenBlockTypes', [ ...mergedBlockNames ] );\n};\n\n/**\n * Returns an action object used in signaling\n * what Meta boxes are available in which location.\n *\n * @param {Object} metaBoxesPerLocation Meta boxes per location.\n */\nexport const setAvailableMetaBoxesPerLocation = ( metaBoxesPerLocation ) => ( {\n\tdispatch,\n} ) =>\n\tdispatch( {\n\t\ttype: 'SET_META_BOXES_PER_LOCATIONS',\n\t\tmetaBoxesPerLocation,\n\t} );\n\n/**\n * Update a metabox.\n */\nexport const requestMetaBoxUpdates = () => async ( {\n\tregistry,\n\tselect,\n\tdispatch,\n} ) => {\n\tdispatch( {\n\t\ttype: 'REQUEST_META_BOX_UPDATES',\n\t} );\n\n\t// Saves the wp_editor fields.\n\tif ( window.tinyMCE ) {\n\t\twindow.tinyMCE.triggerSave();\n\t}\n\n\t// Additional data needed for backward compatibility.\n\t// If we do not provide this data, the post will be overridden with the default values.\n\tconst post = registry.select( editorStore ).getCurrentPost();\n\tconst additionalData = [\n\t\tpost.comment_status ? [ 'comment_status', post.comment_status ] : false,\n\t\tpost.ping_status ? [ 'ping_status', post.ping_status ] : false,\n\t\tpost.sticky ? [ 'sticky', post.sticky ] : false,\n\t\tpost.author ? [ 'post_author', post.author ] : false,\n\t].filter( Boolean );\n\n\t// We gather all the metaboxes locations data and the base form data.\n\tconst baseFormData = new window.FormData(\n\t\tdocument.querySelector( '.metabox-base-form' )\n\t);\n\tconst activeMetaBoxLocations = select.getActiveMetaBoxLocations();\n\tconst formDataToMerge = [\n\t\tbaseFormData,\n\t\t...activeMetaBoxLocations.map(\n\t\t\t( location ) =>\n\t\t\t\tnew window.FormData( getMetaBoxContainer( location ) )\n\t\t),\n\t];\n\n\t// Merge all form data objects into a single one.\n\tconst formData = reduce(\n\t\tformDataToMerge,\n\t\t( memo, currentFormData ) => {\n\t\t\tfor ( const [ key, value ] of currentFormData ) {\n\t\t\t\tmemo.append( key, value );\n\t\t\t}\n\t\t\treturn memo;\n\t\t},\n\t\tnew window.FormData()\n\t);\n\tadditionalData.forEach( ( [ key, value ] ) =>\n\t\tformData.append( key, value )\n\t);\n\n\ttry {\n\t\t// Save the metaboxes.\n\t\tawait apiFetch( {\n\t\t\turl: window._wpMetaBoxUrl,\n\t\t\tmethod: 'POST',\n\t\t\tbody: formData,\n\t\t\tparse: false,\n\t\t} );\n\t\tdispatch.metaBoxUpdatesSuccess();\n\t} catch {\n\t\tdispatch.metaBoxUpdatesFailure();\n\t}\n};\n\n/**\n * Returns an action object used to signal a successful meta box update.\n *\n * @return {Object} Action object.\n */\nexport function metaBoxUpdatesSuccess() {\n\treturn {\n\t\ttype: 'META_BOX_UPDATES_SUCCESS',\n\t};\n}\n\n/**\n * Returns an action object used to signal a failed meta box update.\n *\n * @return {Object} Action object.\n */\nexport function metaBoxUpdatesFailure() {\n\treturn {\n\t\ttype: 'META_BOX_UPDATES_FAILURE',\n\t};\n}\n\n/**\n * Returns an action object used to toggle the width of the editing canvas.\n *\n * @param {string} deviceType\n *\n * @return {Object} Action object.\n */\nexport function __experimentalSetPreviewDeviceType( deviceType ) {\n\treturn {\n\t\ttype: 'SET_PREVIEW_DEVICE_TYPE',\n\t\tdeviceType,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the list view.\n *\n * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.\n * @return {Object} Action object.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to switch to template editing.\n *\n * @param {boolean} value Is editing template.\n * @return {Object} Action object.\n */\nexport function setIsEditingTemplate( value ) {\n\treturn {\n\t\ttype: 'SET_IS_EDITING_TEMPLATE',\n\t\tvalue,\n\t};\n}\n\n/**\n * Switches to the template mode.\n *\n * @param {boolean} newTemplate Is new template.\n */\nexport const __unstableSwitchToTemplateMode = ( newTemplate = false ) => ( {\n\tregistry,\n\tselect,\n\tdispatch,\n} ) => {\n\tdispatch( setIsEditingTemplate( true ) );\n\tconst isWelcomeGuideActive = select.isFeatureActive(\n\t\t'welcomeGuideTemplate'\n\t);\n\tif ( ! isWelcomeGuideActive ) {\n\t\tconst message = newTemplate\n\t\t\t? __( \"Custom template created. You're in template mode now.\" )\n\t\t\t: __(\n\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t );\n\t\tregistry.dispatch( noticesStore ).createSuccessNotice( message, {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t}\n};\n\n/**\n * Create a block based template.\n *\n * @param {Object?} template Template to create and assign.\n */\nexport const __unstableCreateTemplate = ( template ) => async ( {\n\tregistry,\n} ) => {\n\tconst savedTemplate = await registry\n\t\t.dispatch( coreStore )\n\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\tconst post = registry.select( editorStore ).getCurrentPost();\n\tregistry\n\t\t.dispatch( coreStore )\n\t\t.editEntityRecord( 'postType', post.type, post.id, {\n\t\t\ttemplate: savedTemplate.slug,\n\t\t} );\n};\n\nlet metaBoxesInitialized = false;\n\n/**\n * Initializes WordPress `postboxes` script and the logic for saving meta boxes.\n */\nexport const initializeMetaBoxes = () => ( { registry, select, dispatch } ) => {\n\tconst isEditorReady = registry\n\t\t.select( editorStore )\n\t\t.__unstableIsEditorReady();\n\n\tif ( ! isEditorReady ) {\n\t\treturn;\n\t}\n\t// Only initialize once.\n\tif ( metaBoxesInitialized ) {\n\t\treturn;\n\t}\n\tconst postType = registry.select( editorStore ).getCurrentPostType();\n\tif ( window.postboxes.page !== postType ) {\n\t\twindow.postboxes.add_postbox_toggles( postType );\n\t}\n\n\tmetaBoxesInitialized = true;\n\n\tlet wasSavingPost = registry.select( editorStore ).isSavingPost();\n\tlet wasAutosavingPost = registry.select( editorStore ).isAutosavingPost();\n\tconst hasMetaBoxes = select.hasMetaBoxes();\n\n\t// Save metaboxes when performing a full save on the post.\n\tregistry.subscribe( async () => {\n\t\tconst isSavingPost = registry.select( editorStore ).isSavingPost();\n\t\tconst isAutosavingPost = registry\n\t\t\t.select( editorStore )\n\t\t\t.isAutosavingPost();\n\n\t\t// Save metaboxes on save completion, except for autosaves that are not a post preview.\n\t\t//\n\t\t// Meta boxes are initialized once at page load. It is not necessary to\n\t\t// account for updates on each state change.\n\t\t//\n\t\t// See: https://github.com/WordPress/WordPress/blob/5.1.1/wp-admin/includes/post.php#L2307-L2309.\n\t\tconst shouldTriggerMetaboxesSave =\n\t\t\thasMetaBoxes &&\n\t\t\twasSavingPost &&\n\t\t\t! isSavingPost &&\n\t\t\t! wasAutosavingPost;\n\n\t\t// Save current state for next inspection.\n\t\twasSavingPost = isSavingPost;\n\t\twasAutosavingPost = isAutosavingPost;\n\n\t\tif ( shouldTriggerMetaboxesSave ) {\n\t\t\tawait dispatch.requestMetaBoxUpdates();\n\t\t}\n\t} );\n\n\tdispatch( {\n\t\ttype: 'META_BOXES_INITIALIZED',\n\t} );\n};\n"]}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { createReduxStore, registerStore } from '@wordpress/data';
|
|
5
|
-
import { controls } from '@wordpress/data-controls';
|
|
6
5
|
/**
|
|
7
6
|
* Internal dependencies
|
|
8
7
|
*/
|
|
@@ -15,7 +14,6 @@ const storeConfig = {
|
|
|
15
14
|
reducer,
|
|
16
15
|
actions,
|
|
17
16
|
selectors,
|
|
18
|
-
controls,
|
|
19
17
|
persist: ['preferences']
|
|
20
18
|
};
|
|
21
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/store/index.js"],"names":["createReduxStore","registerStore","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/store/index.js"],"names":["createReduxStore","registerStore","reducer","actions","selectors","STORE_NAME","storeConfig","persist","store"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,aAA3B,QAAgD,iBAAhD;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAO,KAAKC,OAAZ,MAAyB,WAAzB;AACA,OAAO,KAAKC,SAAZ,MAA2B,aAA3B;AACA,SAASC,UAAT,QAA2B,aAA3B;AAEA,MAAMC,WAAW,GAAG;AACnBJ,EAAAA,OADmB;AAEnBC,EAAAA,OAFmB;AAGnBC,EAAAA,SAHmB;AAInBG,EAAAA,OAAO,EAAE,CAAE,aAAF;AAJU,CAApB;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,KAAK,GAAGR,gBAAgB,CAAEK,UAAF,EAAcC,WAAd,CAA9B,C,CAEP;;AACAL,aAAa,CAAEI,UAAF,EAAcC,WAAd,CAAb","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, registerStore } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport { STORE_NAME } from './constants';\n\nconst storeConfig = {\n\treducer,\n\tactions,\n\tselectors,\n\tpersist: [ 'preferences' ],\n};\n\n/**\n * Store definition for the edit post namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig );\n\n// Ideally we use register instead of register store.\nregisterStore( STORE_NAME, storeConfig );\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { flow, get, includes, omit
|
|
4
|
+
import { flow, get, includes, omit } from 'lodash';
|
|
5
5
|
/**
|
|
6
6
|
* WordPress dependencies
|
|
7
7
|
*/
|
|
@@ -89,18 +89,6 @@ export const preferences = flow([combineReducers, createWithInitialState(PREFERE
|
|
|
89
89
|
return state;
|
|
90
90
|
},
|
|
91
91
|
|
|
92
|
-
hiddenBlockTypes(state, action) {
|
|
93
|
-
switch (action.type) {
|
|
94
|
-
case 'SHOW_BLOCK_TYPES':
|
|
95
|
-
return without(state, ...action.blockNames);
|
|
96
|
-
|
|
97
|
-
case 'HIDE_BLOCK_TYPES':
|
|
98
|
-
return union(state, action.blockNames);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return state;
|
|
102
|
-
},
|
|
103
|
-
|
|
104
92
|
preferredStyleVariations(state, action) {
|
|
105
93
|
switch (action.type) {
|
|
106
94
|
case 'UPDATE_PREFERRED_STYLE_VARIATIONS':
|