@wordpress/edit-widgets 5.15.0 → 5.17.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/blocks/widget-area/edit/index.js +4 -16
- package/build/blocks/widget-area/edit/index.js.map +1 -1
- package/build/blocks/widget-area/edit/inner-blocks.js +5 -10
- package/build/blocks/widget-area/edit/inner-blocks.js.map +1 -1
- package/build/blocks/widget-area/edit/use-is-dragging-within.js +5 -10
- package/build/blocks/widget-area/edit/use-is-dragging-within.js.map +1 -1
- package/build/blocks/widget-area/index.js +0 -5
- package/build/blocks/widget-area/index.js.map +1 -1
- package/build/components/error-boundary/index.js +1 -15
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/header/index.js +9 -32
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/undo-redo/redo.js +3 -9
- package/build/components/header/undo-redo/redo.js.map +1 -1
- package/build/components/header/undo-redo/undo.js +3 -9
- package/build/components/header/undo-redo/undo.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +1 -2
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -9
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +4 -20
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +1 -6
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -18
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +2 -19
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/interface.js +5 -21
- package/build/components/layout/interface.js.map +1 -1
- package/build/components/layout/unsaved-changes-warning.js +0 -6
- package/build/components/layout/unsaved-changes-warning.js.map +1 -1
- package/build/components/more-menu/index.js +2 -17
- package/build/components/more-menu/index.js.map +1 -1
- package/build/components/more-menu/tools-more-menu-group.js +1 -5
- package/build/components/more-menu/tools-more-menu-group.js.map +1 -1
- package/build/components/notices/index.js +1 -6
- package/build/components/notices/index.js.map +1 -1
- package/build/components/save-button/index.js +1 -7
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/secondary-sidebar/index.js +1 -10
- package/build/components/secondary-sidebar/index.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +1 -11
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +6 -15
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/index.js +12 -26
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar/widget-areas.js +1 -12
- package/build/components/sidebar/widget-areas.js.map +1 -1
- package/build/components/welcome-guide/index.js +3 -12
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/widget-areas-block-editor-content/index.js +1 -8
- package/build/components/widget-areas-block-editor-content/index.js.map +1 -1
- package/build/components/widget-areas-block-editor-provider/index.js +8 -23
- package/build/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build/constants.js.map +1 -1
- package/build/filters/index.js +0 -1
- package/build/filters/index.js.map +1 -1
- package/build/filters/move-to-widget-area.js +3 -9
- package/build/filters/move-to-widget-area.js.map +1 -1
- package/build/filters/replace-media-upload.js +1 -3
- package/build/filters/replace-media-upload.js.map +1 -1
- package/build/hooks/use-last-selected-widget-area.js +5 -13
- package/build/hooks/use-last-selected-widget-area.js.map +1 -1
- package/build/hooks/use-widget-library-insertion-point.js +6 -14
- package/build/hooks/use-widget-library-insertion-point.js.map +1 -1
- package/build/index.js +6 -34
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +1 -2
- package/build/lock-unlock.js.map +1 -1
- package/build/store/actions.js +41 -79
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +0 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/index.js +4 -15
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +4 -16
- package/build/store/reducer.js.map +1 -1
- package/build/store/resolvers.js +1 -17
- package/build/store/resolvers.js.map +1 -1
- package/build/store/selectors.js +28 -49
- package/build/store/selectors.js.map +1 -1
- package/build/store/transformers.js +7 -16
- package/build/store/transformers.js.map +1 -1
- package/build/store/utils.js +7 -16
- package/build/store/utils.js.map +1 -1
- package/build-module/blocks/widget-area/edit/index.js +5 -8
- package/build-module/blocks/widget-area/edit/index.js.map +1 -1
- package/build-module/blocks/widget-area/edit/inner-blocks.js +6 -6
- package/build-module/blocks/widget-area/edit/inner-blocks.js.map +1 -1
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.js +6 -9
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.js.map +1 -1
- package/build-module/blocks/widget-area/index.js +1 -1
- package/build-module/blocks/widget-area/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +0 -9
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/header/index.js +9 -17
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/undo-redo/redo.js +2 -2
- package/build-module/components/header/undo-redo/redo.js.map +1 -1
- package/build-module/components/header/undo-redo/undo.js +2 -2
- package/build-module/components/header/undo-redo/undo.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -6
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +5 -13
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +0 -5
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -10
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +2 -8
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/interface.js +5 -9
- package/build-module/components/layout/interface.js.map +1 -1
- package/build-module/components/layout/unsaved-changes-warning.js +2 -3
- package/build-module/components/layout/unsaved-changes-warning.js.map +1 -1
- package/build-module/components/more-menu/index.js +2 -6
- package/build-module/components/more-menu/index.js.map +1 -1
- package/build-module/components/more-menu/tools-more-menu-group.js +0 -3
- package/build-module/components/more-menu/tools-more-menu-group.js.map +1 -1
- package/build-module/components/notices/index.js +0 -3
- package/build-module/components/notices/index.js.map +1 -1
- package/build-module/components/save-button/index.js +1 -4
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/index.js +1 -6
- package/build-module/components/secondary-sidebar/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +1 -2
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +6 -7
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/index.js +13 -18
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/widget-areas.js +1 -4
- package/build-module/components/sidebar/widget-areas.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +3 -7
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/widget-areas-block-editor-content/index.js +1 -2
- package/build-module/components/widget-areas-block-editor-content/index.js.map +1 -1
- package/build-module/components/widget-areas-block-editor-provider/index.js +8 -7
- package/build-module/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build-module/constants.js.map +1 -1
- package/build-module/filters/index.js.map +1 -1
- package/build-module/filters/move-to-widget-area.js +4 -4
- package/build-module/filters/move-to-widget-area.js.map +1 -1
- package/build-module/filters/replace-media-upload.js +0 -2
- package/build-module/filters/replace-media-upload.js.map +1 -1
- package/build-module/hooks/use-last-selected-widget-area.js +7 -9
- package/build-module/hooks/use-last-selected-widget-area.js.map +1 -1
- package/build-module/hooks/use-widget-library-insertion-point.js +6 -10
- package/build-module/hooks/use-widget-library-insertion-point.js.map +1 -1
- package/build-module/index.js +8 -20
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/actions.js +43 -56
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/index.js +6 -6
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +5 -11
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/resolvers.js +3 -10
- package/build-module/store/resolvers.js.map +1 -1
- package/build-module/store/selectors.js +29 -38
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/transformers.js +8 -13
- package/build-module/store/transformers.js.map +1 -1
- package/build-module/store/utils.js +7 -7
- package/build-module/store/utils.js.map +1 -1
- package/build-style/style-rtl.css +14 -8
- package/build-style/style.css +14 -8
- package/package.json +28 -27
- package/src/components/widget-areas-block-editor-provider/index.js +3 -3
- package/src/index.js +0 -1
- package/src/store/selectors.js +10 -2
package/build/store/actions.js
CHANGED
|
@@ -9,25 +9,15 @@ exports.setIsListViewOpened = setIsListViewOpened;
|
|
|
9
9
|
exports.setIsWidgetAreaOpen = setIsWidgetAreaOpen;
|
|
10
10
|
exports.setWidgetAreasOpenState = setWidgetAreasOpenState;
|
|
11
11
|
exports.setWidgetIdForClientId = setWidgetIdForClientId;
|
|
12
|
-
|
|
13
12
|
var _i18n = require("@wordpress/i18n");
|
|
14
|
-
|
|
15
13
|
var _notices = require("@wordpress/notices");
|
|
16
|
-
|
|
17
14
|
var _interface = require("@wordpress/interface");
|
|
18
|
-
|
|
19
15
|
var _widgets = require("@wordpress/widgets");
|
|
20
|
-
|
|
21
16
|
var _coreData = require("@wordpress/core-data");
|
|
22
|
-
|
|
23
17
|
var _blockEditor = require("@wordpress/block-editor");
|
|
24
|
-
|
|
25
18
|
var _transformers = require("./transformers");
|
|
26
|
-
|
|
27
19
|
var _utils = require("./utils");
|
|
28
|
-
|
|
29
20
|
var _constants = require("./constants");
|
|
30
|
-
|
|
31
21
|
/**
|
|
32
22
|
* WordPress dependencies
|
|
33
23
|
*/
|
|
@@ -53,6 +43,7 @@ const persistStubPost = (id, blocks) => ({
|
|
|
53
43
|
}, false);
|
|
54
44
|
return stubPost;
|
|
55
45
|
};
|
|
46
|
+
|
|
56
47
|
/**
|
|
57
48
|
* Converts all the blocks from edited widget areas into widgets,
|
|
58
49
|
* and submits a batch request to save everything at once.
|
|
@@ -61,34 +52,29 @@ const persistStubPost = (id, blocks) => ({
|
|
|
61
52
|
*
|
|
62
53
|
* @return {Function} An action creator.
|
|
63
54
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
55
|
exports.persistStubPost = persistStubPost;
|
|
67
|
-
|
|
68
56
|
const saveEditedWidgetAreas = () => async ({
|
|
69
57
|
select,
|
|
70
58
|
dispatch,
|
|
71
59
|
registry
|
|
72
60
|
}) => {
|
|
73
61
|
const editedWidgetAreas = select.getEditedWidgetAreas();
|
|
74
|
-
|
|
75
62
|
if (!editedWidgetAreas?.length) {
|
|
76
63
|
return;
|
|
77
64
|
}
|
|
78
|
-
|
|
79
65
|
try {
|
|
80
66
|
await dispatch.saveWidgetAreas(editedWidgetAreas);
|
|
81
67
|
registry.dispatch(_notices.store).createSuccessNotice((0, _i18n.__)('Widgets saved.'), {
|
|
82
68
|
type: 'snackbar'
|
|
83
69
|
});
|
|
84
70
|
} catch (e) {
|
|
85
|
-
registry.dispatch(_notices.store).createErrorNotice(
|
|
86
|
-
/* translators: %s: The error message. */
|
|
71
|
+
registry.dispatch(_notices.store).createErrorNotice( /* translators: %s: The error message. */
|
|
87
72
|
(0, _i18n.sprintf)((0, _i18n.__)('There was an error. %s'), e.message), {
|
|
88
73
|
type: 'snackbar'
|
|
89
74
|
});
|
|
90
75
|
}
|
|
91
76
|
};
|
|
77
|
+
|
|
92
78
|
/**
|
|
93
79
|
* Converts all the blocks from specified widget areas into widgets,
|
|
94
80
|
* and submits a batch request to save everything at once.
|
|
@@ -96,10 +82,7 @@ const saveEditedWidgetAreas = () => async ({
|
|
|
96
82
|
* @param {Object[]} widgetAreas Widget areas to save.
|
|
97
83
|
* @return {Function} An action creator.
|
|
98
84
|
*/
|
|
99
|
-
|
|
100
|
-
|
|
101
85
|
exports.saveEditedWidgetAreas = saveEditedWidgetAreas;
|
|
102
|
-
|
|
103
86
|
const saveWidgetAreas = widgetAreas => async ({
|
|
104
87
|
dispatch,
|
|
105
88
|
registry
|
|
@@ -113,6 +96,7 @@ const saveWidgetAreas = widgetAreas => async ({
|
|
|
113
96
|
await registry.dispatch(_coreData.store).finishResolution('getEntityRecord', _utils.KIND, _utils.WIDGET_AREA_ENTITY_TYPE, (0, _utils.buildWidgetAreasQuery)());
|
|
114
97
|
}
|
|
115
98
|
};
|
|
99
|
+
|
|
116
100
|
/**
|
|
117
101
|
* Converts all the blocks from a widget area specified by ID into widgets,
|
|
118
102
|
* and submits a batch request to save everything at once.
|
|
@@ -120,81 +104,75 @@ const saveWidgetAreas = widgetAreas => async ({
|
|
|
120
104
|
* @param {string} widgetAreaId ID of the widget area to process.
|
|
121
105
|
* @return {Function} An action creator.
|
|
122
106
|
*/
|
|
123
|
-
|
|
124
|
-
|
|
125
107
|
exports.saveWidgetAreas = saveWidgetAreas;
|
|
126
|
-
|
|
127
108
|
const saveWidgetArea = widgetAreaId => async ({
|
|
128
109
|
dispatch,
|
|
129
110
|
select,
|
|
130
111
|
registry
|
|
131
112
|
}) => {
|
|
132
113
|
const widgets = select.getWidgets();
|
|
133
|
-
const post = registry.select(_coreData.store).getEditedEntityRecord(_utils.KIND, _utils.POST_TYPE, (0, _utils.buildWidgetAreaPostId)(widgetAreaId));
|
|
114
|
+
const post = registry.select(_coreData.store).getEditedEntityRecord(_utils.KIND, _utils.POST_TYPE, (0, _utils.buildWidgetAreaPostId)(widgetAreaId));
|
|
134
115
|
|
|
116
|
+
// Get all widgets from this area
|
|
135
117
|
const areaWidgets = Object.values(widgets).filter(({
|
|
136
118
|
sidebar
|
|
137
|
-
}) => sidebar === widgetAreaId);
|
|
119
|
+
}) => sidebar === widgetAreaId);
|
|
120
|
+
|
|
121
|
+
// Remove all duplicate reference widget instances for legacy widgets.
|
|
138
122
|
// Why? We filter out the widgets with duplicate IDs to prevent adding more than one instance of a widget
|
|
139
123
|
// implemented using a function. WordPress doesn't support having more than one instance of these, if you try to
|
|
140
124
|
// save multiple instances of these in different sidebars you will run into undefined behaviors.
|
|
141
|
-
|
|
142
125
|
const usedReferenceWidgets = [];
|
|
143
126
|
const widgetsBlocks = post.blocks.filter(block => {
|
|
144
127
|
const {
|
|
145
128
|
id
|
|
146
129
|
} = block.attributes;
|
|
147
|
-
|
|
148
130
|
if (block.name === 'core/legacy-widget' && id) {
|
|
149
131
|
if (usedReferenceWidgets.includes(id)) {
|
|
150
132
|
return false;
|
|
151
133
|
}
|
|
152
|
-
|
|
153
134
|
usedReferenceWidgets.push(id);
|
|
154
135
|
}
|
|
155
|
-
|
|
156
136
|
return true;
|
|
157
|
-
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// Determine which widgets have been deleted. We can tell if a widget is
|
|
158
140
|
// deleted and not just moved to a different area by looking to see if
|
|
159
141
|
// getWidgetAreaForWidgetId() finds something.
|
|
160
|
-
|
|
161
142
|
const deletedWidgets = [];
|
|
162
|
-
|
|
163
143
|
for (const widget of areaWidgets) {
|
|
164
144
|
const widgetsNewArea = select.getWidgetAreaForWidgetId(widget.id);
|
|
165
|
-
|
|
166
145
|
if (!widgetsNewArea) {
|
|
167
146
|
deletedWidgets.push(widget);
|
|
168
147
|
}
|
|
169
148
|
}
|
|
170
|
-
|
|
171
149
|
const batchMeta = [];
|
|
172
150
|
const batchTasks = [];
|
|
173
151
|
const sidebarWidgetsIds = [];
|
|
174
|
-
|
|
175
152
|
for (let i = 0; i < widgetsBlocks.length; i++) {
|
|
176
153
|
const block = widgetsBlocks[i];
|
|
177
154
|
const widgetId = (0, _widgets.getWidgetIdFromBlock)(block);
|
|
178
155
|
const oldWidget = widgets[widgetId];
|
|
179
|
-
const widget = (0, _transformers.transformBlockToWidget)(block, oldWidget);
|
|
156
|
+
const widget = (0, _transformers.transformBlockToWidget)(block, oldWidget);
|
|
157
|
+
|
|
158
|
+
// We'll replace the null widgetId after save, but we track it here
|
|
180
159
|
// since order is important.
|
|
160
|
+
sidebarWidgetsIds.push(widgetId);
|
|
181
161
|
|
|
182
|
-
|
|
162
|
+
// Check oldWidget as widgetId might refer to an ID which has been
|
|
183
163
|
// deleted, e.g. if a deleted block is restored via undo after saving.
|
|
184
|
-
|
|
185
164
|
if (oldWidget) {
|
|
186
165
|
// Update an existing widget.
|
|
187
|
-
registry.dispatch(_coreData.store).editEntityRecord('root', 'widget', widgetId, {
|
|
166
|
+
registry.dispatch(_coreData.store).editEntityRecord('root', 'widget', widgetId, {
|
|
167
|
+
...widget,
|
|
188
168
|
sidebar: widgetAreaId
|
|
189
169
|
}, {
|
|
190
170
|
undoIgnore: true
|
|
191
171
|
});
|
|
192
172
|
const hasEdits = registry.select(_coreData.store).hasEditsForEntityRecord('root', 'widget', widgetId);
|
|
193
|
-
|
|
194
173
|
if (!hasEdits) {
|
|
195
174
|
continue;
|
|
196
175
|
}
|
|
197
|
-
|
|
198
176
|
batchTasks.push(({
|
|
199
177
|
saveEditedEntityRecord
|
|
200
178
|
}) => saveEditedEntityRecord('root', 'widget', widgetId));
|
|
@@ -202,18 +180,17 @@ const saveWidgetArea = widgetAreaId => async ({
|
|
|
202
180
|
// Create a new widget.
|
|
203
181
|
batchTasks.push(({
|
|
204
182
|
saveEntityRecord
|
|
205
|
-
}) => saveEntityRecord('root', 'widget', {
|
|
183
|
+
}) => saveEntityRecord('root', 'widget', {
|
|
184
|
+
...widget,
|
|
206
185
|
sidebar: widgetAreaId
|
|
207
186
|
}));
|
|
208
187
|
}
|
|
209
|
-
|
|
210
188
|
batchMeta.push({
|
|
211
189
|
block,
|
|
212
190
|
position: i,
|
|
213
191
|
clientId: block.clientId
|
|
214
192
|
});
|
|
215
193
|
}
|
|
216
|
-
|
|
217
194
|
for (const widget of deletedWidgets) {
|
|
218
195
|
batchTasks.push(({
|
|
219
196
|
deleteEntityRecord
|
|
@@ -221,37 +198,31 @@ const saveWidgetArea = widgetAreaId => async ({
|
|
|
221
198
|
force: true
|
|
222
199
|
}));
|
|
223
200
|
}
|
|
224
|
-
|
|
225
201
|
const records = await registry.dispatch(_coreData.store).__experimentalBatch(batchTasks);
|
|
226
202
|
const preservedRecords = records.filter(record => !record.hasOwnProperty('deleted'));
|
|
227
203
|
const failedWidgetNames = [];
|
|
228
|
-
|
|
229
204
|
for (let i = 0; i < preservedRecords.length; i++) {
|
|
230
205
|
const widget = preservedRecords[i];
|
|
231
206
|
const {
|
|
232
207
|
block,
|
|
233
208
|
position
|
|
234
|
-
} = batchMeta[i];
|
|
235
|
-
// store when we dispatch receiveEntityRecords( post ) below.
|
|
209
|
+
} = batchMeta[i];
|
|
236
210
|
|
|
211
|
+
// Set __internalWidgetId on the block. This will be persisted to the
|
|
212
|
+
// store when we dispatch receiveEntityRecords( post ) below.
|
|
237
213
|
post.blocks[position].attributes.__internalWidgetId = widget.id;
|
|
238
214
|
const error = registry.select(_coreData.store).getLastEntitySaveError('root', 'widget', widget.id);
|
|
239
|
-
|
|
240
215
|
if (error) {
|
|
241
216
|
failedWidgetNames.push(block.attributes?.name || block?.name);
|
|
242
217
|
}
|
|
243
|
-
|
|
244
218
|
if (!sidebarWidgetsIds[position]) {
|
|
245
219
|
sidebarWidgetsIds[position] = widget.id;
|
|
246
220
|
}
|
|
247
221
|
}
|
|
248
|
-
|
|
249
222
|
if (failedWidgetNames.length) {
|
|
250
|
-
throw new Error((0, _i18n.sprintf)(
|
|
251
|
-
/* translators: %s: List of widget names */
|
|
223
|
+
throw new Error((0, _i18n.sprintf)( /* translators: %s: List of widget names */
|
|
252
224
|
(0, _i18n.__)('Could not save the following widgets: %s.'), failedWidgetNames.join(', ')));
|
|
253
225
|
}
|
|
254
|
-
|
|
255
226
|
registry.dispatch(_coreData.store).editEntityRecord(_utils.KIND, _utils.WIDGET_AREA_ENTITY_TYPE, widgetAreaId, {
|
|
256
227
|
widgets: sidebarWidgetsIds
|
|
257
228
|
}, {
|
|
@@ -260,9 +231,7 @@ const saveWidgetArea = widgetAreaId => async ({
|
|
|
260
231
|
dispatch(trySaveWidgetArea(widgetAreaId));
|
|
261
232
|
registry.dispatch(_coreData.store).receiveEntityRecords(_utils.KIND, _utils.POST_TYPE, post, undefined);
|
|
262
233
|
};
|
|
263
|
-
|
|
264
234
|
exports.saveWidgetArea = saveWidgetArea;
|
|
265
|
-
|
|
266
235
|
const trySaveWidgetArea = widgetAreaId => ({
|
|
267
236
|
registry
|
|
268
237
|
}) => {
|
|
@@ -270,6 +239,7 @@ const trySaveWidgetArea = widgetAreaId => ({
|
|
|
270
239
|
throwOnError: true
|
|
271
240
|
});
|
|
272
241
|
};
|
|
242
|
+
|
|
273
243
|
/**
|
|
274
244
|
* Sets the clientId stored for a particular widgetId.
|
|
275
245
|
*
|
|
@@ -278,8 +248,6 @@ const trySaveWidgetArea = widgetAreaId => ({
|
|
|
278
248
|
*
|
|
279
249
|
* @return {Object} Action.
|
|
280
250
|
*/
|
|
281
|
-
|
|
282
|
-
|
|
283
251
|
function setWidgetIdForClientId(clientId, widgetId) {
|
|
284
252
|
return {
|
|
285
253
|
type: 'SET_WIDGET_ID_FOR_CLIENT_ID',
|
|
@@ -287,6 +255,7 @@ function setWidgetIdForClientId(clientId, widgetId) {
|
|
|
287
255
|
widgetId
|
|
288
256
|
};
|
|
289
257
|
}
|
|
258
|
+
|
|
290
259
|
/**
|
|
291
260
|
* Sets the open state of all the widget areas.
|
|
292
261
|
*
|
|
@@ -294,14 +263,13 @@ function setWidgetIdForClientId(clientId, widgetId) {
|
|
|
294
263
|
*
|
|
295
264
|
* @return {Object} Action.
|
|
296
265
|
*/
|
|
297
|
-
|
|
298
|
-
|
|
299
266
|
function setWidgetAreasOpenState(widgetAreasOpenState) {
|
|
300
267
|
return {
|
|
301
268
|
type: 'SET_WIDGET_AREAS_OPEN_STATE',
|
|
302
269
|
widgetAreasOpenState
|
|
303
270
|
};
|
|
304
271
|
}
|
|
272
|
+
|
|
305
273
|
/**
|
|
306
274
|
* Sets the open state of the widget area.
|
|
307
275
|
*
|
|
@@ -310,8 +278,6 @@ function setWidgetAreasOpenState(widgetAreasOpenState) {
|
|
|
310
278
|
*
|
|
311
279
|
* @return {Object} Action.
|
|
312
280
|
*/
|
|
313
|
-
|
|
314
|
-
|
|
315
281
|
function setIsWidgetAreaOpen(clientId, isOpen) {
|
|
316
282
|
return {
|
|
317
283
|
type: 'SET_IS_WIDGET_AREA_OPEN',
|
|
@@ -319,6 +285,7 @@ function setIsWidgetAreaOpen(clientId, isOpen) {
|
|
|
319
285
|
isOpen
|
|
320
286
|
};
|
|
321
287
|
}
|
|
288
|
+
|
|
322
289
|
/**
|
|
323
290
|
* Returns an action object used to open/close the inserter.
|
|
324
291
|
*
|
|
@@ -331,77 +298,72 @@ function setIsWidgetAreaOpen(clientId, isOpen) {
|
|
|
331
298
|
*
|
|
332
299
|
* @return {Object} Action object.
|
|
333
300
|
*/
|
|
334
|
-
|
|
335
|
-
|
|
336
301
|
function setIsInserterOpened(value) {
|
|
337
302
|
return {
|
|
338
303
|
type: 'SET_IS_INSERTER_OPENED',
|
|
339
304
|
value
|
|
340
305
|
};
|
|
341
306
|
}
|
|
307
|
+
|
|
342
308
|
/**
|
|
343
309
|
* Returns an action object used to open/close the list view.
|
|
344
310
|
*
|
|
345
311
|
* @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.
|
|
346
312
|
* @return {Object} Action object.
|
|
347
313
|
*/
|
|
348
|
-
|
|
349
|
-
|
|
350
314
|
function setIsListViewOpened(isOpen) {
|
|
351
315
|
return {
|
|
352
316
|
type: 'SET_IS_LIST_VIEW_OPENED',
|
|
353
317
|
isOpen
|
|
354
318
|
};
|
|
355
319
|
}
|
|
320
|
+
|
|
356
321
|
/**
|
|
357
322
|
* Returns an action object signalling that the user closed the sidebar.
|
|
358
323
|
*
|
|
359
324
|
* @return {Object} Action creator.
|
|
360
325
|
*/
|
|
361
|
-
|
|
362
|
-
|
|
363
326
|
const closeGeneralSidebar = () => ({
|
|
364
327
|
registry
|
|
365
328
|
}) => {
|
|
366
329
|
registry.dispatch(_interface.store).disableComplementaryArea(_constants.STORE_NAME);
|
|
367
330
|
};
|
|
331
|
+
|
|
368
332
|
/**
|
|
369
333
|
* Action that handles moving a block between widget areas
|
|
370
334
|
*
|
|
371
335
|
* @param {string} clientId The clientId of the block to move.
|
|
372
336
|
* @param {string} widgetAreaId The id of the widget area to move the block to.
|
|
373
337
|
*/
|
|
374
|
-
|
|
375
|
-
|
|
376
338
|
exports.closeGeneralSidebar = closeGeneralSidebar;
|
|
377
|
-
|
|
378
339
|
const moveBlockToWidgetArea = (clientId, widgetAreaId) => async ({
|
|
379
340
|
dispatch,
|
|
380
341
|
select,
|
|
381
342
|
registry
|
|
382
343
|
}) => {
|
|
383
|
-
const sourceRootClientId = registry.select(_blockEditor.store).getBlockRootClientId(clientId);
|
|
344
|
+
const sourceRootClientId = registry.select(_blockEditor.store).getBlockRootClientId(clientId);
|
|
345
|
+
|
|
346
|
+
// Search the top level blocks (widget areas) for the one with the matching
|
|
384
347
|
// id attribute. Makes the assumption that all top-level blocks are widget
|
|
385
348
|
// areas.
|
|
386
|
-
|
|
387
349
|
const widgetAreas = registry.select(_blockEditor.store).getBlocks();
|
|
388
350
|
const destinationWidgetAreaBlock = widgetAreas.find(({
|
|
389
351
|
attributes
|
|
390
352
|
}) => attributes.id === widgetAreaId);
|
|
391
|
-
const destinationRootClientId = destinationWidgetAreaBlock.clientId;
|
|
353
|
+
const destinationRootClientId = destinationWidgetAreaBlock.clientId;
|
|
392
354
|
|
|
355
|
+
// Get the index for moving to the end of the destination widget area.
|
|
393
356
|
const destinationInnerBlocksClientIds = registry.select(_blockEditor.store).getBlockOrder(destinationRootClientId);
|
|
394
|
-
const destinationIndex = destinationInnerBlocksClientIds.length;
|
|
357
|
+
const destinationIndex = destinationInnerBlocksClientIds.length;
|
|
395
358
|
|
|
359
|
+
// Reveal the widget area, if it's not open.
|
|
396
360
|
const isDestinationWidgetAreaOpen = select.getIsWidgetAreaOpen(destinationRootClientId);
|
|
397
|
-
|
|
398
361
|
if (!isDestinationWidgetAreaOpen) {
|
|
399
362
|
dispatch.setIsWidgetAreaOpen(destinationRootClientId, true);
|
|
400
|
-
}
|
|
401
|
-
|
|
363
|
+
}
|
|
402
364
|
|
|
365
|
+
// Move the block.
|
|
403
366
|
registry.dispatch(_blockEditor.store).moveBlocksToPosition([clientId], sourceRootClientId, destinationRootClientId, destinationIndex);
|
|
404
367
|
};
|
|
405
|
-
|
|
406
368
|
exports.moveBlockToWidgetArea = moveBlockToWidgetArea;
|
|
407
369
|
//# sourceMappingURL=actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-widgets/src/store/actions.js"],"names":["persistStubPost","id","blocks","registry","stubPost","dispatch","coreStore","receiveEntityRecords","KIND","POST_TYPE","saveEditedWidgetAreas","select","editedWidgetAreas","getEditedWidgetAreas","length","saveWidgetAreas","noticesStore","createSuccessNotice","type","e","createErrorNotice","message","widgetAreas","widgetArea","saveWidgetArea","finishResolution","WIDGET_AREA_ENTITY_TYPE","widgetAreaId","widgets","getWidgets","post","getEditedEntityRecord","areaWidgets","Object","values","filter","sidebar","usedReferenceWidgets","widgetsBlocks","block","attributes","name","includes","push","deletedWidgets","widget","widgetsNewArea","getWidgetAreaForWidgetId","batchMeta","batchTasks","sidebarWidgetsIds","i","widgetId","oldWidget","editEntityRecord","undoIgnore","hasEdits","hasEditsForEntityRecord","saveEditedEntityRecord","saveEntityRecord","position","clientId","deleteEntityRecord","force","records","__experimentalBatch","preservedRecords","record","hasOwnProperty","failedWidgetNames","__internalWidgetId","error","getLastEntitySaveError","Error","join","trySaveWidgetArea","undefined","throwOnError","setWidgetIdForClientId","setWidgetAreasOpenState","widgetAreasOpenState","setIsWidgetAreaOpen","isOpen","setIsInserterOpened","value","setIsListViewOpened","closeGeneralSidebar","interfaceStore","disableComplementaryArea","editWidgetsStoreName","moveBlockToWidgetArea","sourceRootClientId","blockEditorStore","getBlockRootClientId","getBlocks","destinationWidgetAreaBlock","find","destinationRootClientId","destinationInnerBlocksClientIds","getBlockOrder","destinationIndex","isDestinationWidgetAreaOpen","getIsWidgetAreaOpen","moveBlocksToPosition"],"mappings":";;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAQA;;AAtBA;AACA;AACA;;AAQA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,eAAe,GAC3B,CAAEC,EAAF,EAAMC,MAAN,KACA,CAAE;AAAEC,EAAAA;AAAF,CAAF,KAAoB;AACnB,QAAMC,QAAQ,GAAG,2BAAgBH,EAAhB,EAAoBC,MAApB,CAAjB;AACAC,EAAAA,QAAQ,CACNE,QADF,CACYC,eADZ,EAEEC,oBAFF,CAGEC,WAHF,EAIEC,gBAJF,EAKEL,QALF,EAME;AAAEH,IAAAA,EAAE,EAAEG,QAAQ,CAACH;AAAf,GANF,EAOE,KAPF;AASA,SAAOG,QAAP;AACA,CAdK;AAgBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMM,qBAAqB,GACjC,MACA,OAAQ;AAAEC,EAAAA,MAAF;AAAUN,EAAAA,QAAV;AAAoBF,EAAAA;AAApB,CAAR,KAA4C;AAC3C,QAAMS,iBAAiB,GAAGD,MAAM,CAACE,oBAAP,EAA1B;;AACA,MAAK,CAAED,iBAAiB,EAAEE,MAA1B,EAAmC;AAClC;AACA;;AACD,MAAI;AACH,UAAMT,QAAQ,CAACU,eAAT,CAA0BH,iBAA1B,CAAN;AACAT,IAAAA,QAAQ,CACNE,QADF,CACYW,cADZ,EAEEC,mBAFF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xC;AAGA,QAAMG,gBAAgB,GAAGF,+BAA+B,CAACpF,MAAzD,CAlB2C,CAoB3C;;AACA,QAAMuF,2BAA2B,GAAG1F,MAAM,CAAC2F,mBAAP,CACnCL,uBADmC,CAApC;;AAIA,MAAK,CAAEI,2BAAP,EAAqC;AACpChG,IAAAA,QAAQ,CAAC4E,mBAAT,CAA8BgB,uBAA9B,EAAuD,IAAvD;AACA,GA3B0C,CA6B3C;;;AACA9F,EAAAA,QAAQ,CACNE,QADF,CACYuF,kBADZ,EAEEW,oBAFF,CAGE,CAAE1C,QAAF,CAHF,EAIE8B,kBAJF,EAKEM,uBALF,EAMEG,gBANF;AAQA,CAxCK","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { transformBlockToWidget } from './transformers';\nimport {\n\tbuildWidgetAreaPostId,\n\tbuildWidgetAreasQuery,\n\tcreateStubPost,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\n/**\n * Persists a stub post with given ID to core data store. The post is meant to be in-memory only and\n * shouldn't be saved via the API.\n *\n * @param {string} id Post ID.\n * @param {Array} blocks Blocks the post should consist of.\n * @return {Object} The post object.\n */\nexport const persistStubPost =\n\t( id, blocks ) =>\n\t( { registry } ) => {\n\t\tconst stubPost = createStubPost( id, blocks );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.receiveEntityRecords(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tstubPost,\n\t\t\t\t{ id: stubPost.id },\n\t\t\t\tfalse\n\t\t\t);\n\t\treturn stubPost;\n\t};\n\n/**\n * Converts all the blocks from edited widget areas into widgets,\n * and submits a batch request to save everything at once.\n *\n * Creates a snackbar notice on either success or error.\n *\n * @return {Function} An action creator.\n */\nexport const saveEditedWidgetAreas =\n\t() =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst editedWidgetAreas = select.getEditedWidgetAreas();\n\t\tif ( ! editedWidgetAreas?.length ) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tawait dispatch.saveWidgetAreas( editedWidgetAreas );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( __( 'Widgets saved.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t} catch ( e ) {\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice(\n\t\t\t\t/* translators: %s: The error message. */\n\t\t\t\tsprintf( __( 'There was an error. %s' ), e.message ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n/**\n * Converts all the blocks from specified widget areas into widgets,\n * and submits a batch request to save everything at once.\n *\n * @param {Object[]} widgetAreas Widget areas to save.\n * @return {Function} An action creator.\n */\nexport const saveWidgetAreas =\n\t( widgetAreas ) =>\n\tasync ( { dispatch, registry } ) => {\n\t\ttry {\n\t\t\tfor ( const widgetArea of widgetAreas ) {\n\t\t\t\tawait dispatch.saveWidgetArea( widgetArea.id );\n\t\t\t}\n\t\t} finally {\n\t\t\t// saveEditedEntityRecord resets the resolution status, let's fix it manually.\n\t\t\tawait registry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.finishResolution(\n\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\tKIND,\n\t\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\t\tbuildWidgetAreasQuery()\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Converts all the blocks from a widget area specified by ID into widgets,\n * and submits a batch request to save everything at once.\n *\n * @param {string} widgetAreaId ID of the widget area to process.\n * @return {Function} An action creator.\n */\nexport const saveWidgetArea =\n\t( widgetAreaId ) =>\n\tasync ( { dispatch, select, registry } ) => {\n\t\tconst widgets = select.getWidgets();\n\n\t\tconst post = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( widgetAreaId )\n\t\t\t);\n\n\t\t// Get all widgets from this area\n\t\tconst areaWidgets = Object.values( widgets ).filter(\n\t\t\t( { sidebar } ) => sidebar === widgetAreaId\n\t\t);\n\n\t\t// Remove all duplicate reference widget instances for legacy widgets.\n\t\t// Why? We filter out the widgets with duplicate IDs to prevent adding more than one instance of a widget\n\t\t// implemented using a function. WordPress doesn't support having more than one instance of these, if you try to\n\t\t// save multiple instances of these in different sidebars you will run into undefined behaviors.\n\t\tconst usedReferenceWidgets = [];\n\t\tconst widgetsBlocks = post.blocks.filter( ( block ) => {\n\t\t\tconst { id } = block.attributes;\n\n\t\t\tif ( block.name === 'core/legacy-widget' && id ) {\n\t\t\t\tif ( usedReferenceWidgets.includes( id ) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tusedReferenceWidgets.push( id );\n\t\t\t}\n\t\t\treturn true;\n\t\t} );\n\n\t\t// Determine which widgets have been deleted. We can tell if a widget is\n\t\t// deleted and not just moved to a different area by looking to see if\n\t\t// getWidgetAreaForWidgetId() finds something.\n\t\tconst deletedWidgets = [];\n\t\tfor ( const widget of areaWidgets ) {\n\t\t\tconst widgetsNewArea = select.getWidgetAreaForWidgetId( widget.id );\n\t\t\tif ( ! widgetsNewArea ) {\n\t\t\t\tdeletedWidgets.push( widget );\n\t\t\t}\n\t\t}\n\n\t\tconst batchMeta = [];\n\t\tconst batchTasks = [];\n\t\tconst sidebarWidgetsIds = [];\n\t\tfor ( let i = 0; i < widgetsBlocks.length; i++ ) {\n\t\t\tconst block = widgetsBlocks[ i ];\n\t\t\tconst widgetId = getWidgetIdFromBlock( block );\n\t\t\tconst oldWidget = widgets[ widgetId ];\n\t\t\tconst widget = transformBlockToWidget( block, oldWidget );\n\n\t\t\t// We'll replace the null widgetId after save, but we track it here\n\t\t\t// since order is important.\n\t\t\tsidebarWidgetsIds.push( widgetId );\n\n\t\t\t// Check oldWidget as widgetId might refer to an ID which has been\n\t\t\t// deleted, e.g. if a deleted block is restored via undo after saving.\n\t\t\tif ( oldWidget ) {\n\t\t\t\t// Update an existing widget.\n\t\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t\t'root',\n\t\t\t\t\t'widget',\n\t\t\t\t\twidgetId,\n\t\t\t\t\t{\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tsidebar: widgetAreaId,\n\t\t\t\t\t},\n\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t);\n\n\t\t\t\tconst hasEdits = registry\n\t\t\t\t\t.select( coreStore )\n\t\t\t\t\t.hasEditsForEntityRecord( 'root', 'widget', widgetId );\n\n\t\t\t\tif ( ! hasEdits ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tbatchTasks.push( ( { saveEditedEntityRecord } ) =>\n\t\t\t\t\tsaveEditedEntityRecord( 'root', 'widget', widgetId )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Create a new widget.\n\t\t\t\tbatchTasks.push( ( { saveEntityRecord } ) =>\n\t\t\t\t\tsaveEntityRecord( 'root', 'widget', {\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tsidebar: widgetAreaId,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tbatchMeta.push( {\n\t\t\t\tblock,\n\t\t\t\tposition: i,\n\t\t\t\tclientId: block.clientId,\n\t\t\t} );\n\t\t}\n\t\tfor ( const widget of deletedWidgets ) {\n\t\t\tbatchTasks.push( ( { deleteEntityRecord } ) =>\n\t\t\t\tdeleteEntityRecord( 'root', 'widget', widget.id, {\n\t\t\t\t\tforce: true,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\n\t\tconst records = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.__experimentalBatch( batchTasks );\n\t\tconst preservedRecords = records.filter(\n\t\t\t( record ) => ! record.hasOwnProperty( 'deleted' )\n\t\t);\n\n\t\tconst failedWidgetNames = [];\n\n\t\tfor ( let i = 0; i < preservedRecords.length; i++ ) {\n\t\t\tconst widget = preservedRecords[ i ];\n\t\t\tconst { block, position } = batchMeta[ i ];\n\n\t\t\t// Set __internalWidgetId on the block. This will be persisted to the\n\t\t\t// store when we dispatch receiveEntityRecords( post ) below.\n\t\t\tpost.blocks[ position ].attributes.__internalWidgetId = widget.id;\n\n\t\t\tconst error = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getLastEntitySaveError( 'root', 'widget', widget.id );\n\t\t\tif ( error ) {\n\t\t\t\tfailedWidgetNames.push( block.attributes?.name || block?.name );\n\t\t\t}\n\n\t\t\tif ( ! sidebarWidgetsIds[ position ] ) {\n\t\t\t\tsidebarWidgetsIds[ position ] = widget.id;\n\t\t\t}\n\t\t}\n\n\t\tif ( failedWidgetNames.length ) {\n\t\t\tthrow new Error(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: List of widget names */\n\t\t\t\t\t__( 'Could not save the following widgets: %s.' ),\n\t\t\t\t\tfailedWidgetNames.join( ', ' )\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\tKIND,\n\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\twidgetAreaId,\n\t\t\t{\n\t\t\t\twidgets: sidebarWidgetsIds,\n\t\t\t},\n\t\t\t{ undoIgnore: true }\n\t\t);\n\n\t\tdispatch( trySaveWidgetArea( widgetAreaId ) );\n\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.receiveEntityRecords( KIND, POST_TYPE, post, undefined );\n\t};\n\nconst trySaveWidgetArea =\n\t( widgetAreaId ) =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\twidgetAreaId,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t};\n\n/**\n * Sets the clientId stored for a particular widgetId.\n *\n * @param {number} clientId Client id.\n * @param {number} widgetId Widget id.\n *\n * @return {Object} Action.\n */\nexport function setWidgetIdForClientId( clientId, widgetId ) {\n\treturn {\n\t\ttype: 'SET_WIDGET_ID_FOR_CLIENT_ID',\n\t\tclientId,\n\t\twidgetId,\n\t};\n}\n\n/**\n * Sets the open state of all the widget areas.\n *\n * @param {Object} widgetAreasOpenState The open states of all the widget areas.\n *\n * @return {Object} Action.\n */\nexport function setWidgetAreasOpenState( widgetAreasOpenState ) {\n\treturn {\n\t\ttype: 'SET_WIDGET_AREAS_OPEN_STATE',\n\t\twidgetAreasOpenState,\n\t};\n}\n\n/**\n * Sets the open state of the widget area.\n *\n * @param {string} clientId The clientId of the widget area.\n * @param {boolean} isOpen Whether the widget area should be opened.\n *\n * @return {Object} Action.\n */\nexport function setIsWidgetAreaOpen( clientId, isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_WIDGET_AREA_OPEN',\n\t\tclientId,\n\t\tisOpen,\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 signalling that the user closed the sidebar.\n *\n * @return {Object} Action creator.\n */\nexport const closeGeneralSidebar =\n\t() =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( interfaceStore )\n\t\t\t.disableComplementaryArea( editWidgetsStoreName );\n\t};\n\n/**\n * Action that handles moving a block between widget areas\n *\n * @param {string} clientId The clientId of the block to move.\n * @param {string} widgetAreaId The id of the widget area to move the block to.\n */\nexport const moveBlockToWidgetArea =\n\t( clientId, widgetAreaId ) =>\n\tasync ( { dispatch, select, registry } ) => {\n\t\tconst sourceRootClientId = registry\n\t\t\t.select( blockEditorStore )\n\t\t\t.getBlockRootClientId( clientId );\n\n\t\t// Search the top level blocks (widget areas) for the one with the matching\n\t\t// id attribute. Makes the assumption that all top-level blocks are widget\n\t\t// areas.\n\t\tconst widgetAreas = registry.select( blockEditorStore ).getBlocks();\n\t\tconst destinationWidgetAreaBlock = widgetAreas.find(\n\t\t\t( { attributes } ) => attributes.id === widgetAreaId\n\t\t);\n\t\tconst destinationRootClientId = destinationWidgetAreaBlock.clientId;\n\n\t\t// Get the index for moving to the end of the destination widget area.\n\t\tconst destinationInnerBlocksClientIds = registry\n\t\t\t.select( blockEditorStore )\n\t\t\t.getBlockOrder( destinationRootClientId );\n\t\tconst destinationIndex = destinationInnerBlocksClientIds.length;\n\n\t\t// Reveal the widget area, if it's not open.\n\t\tconst isDestinationWidgetAreaOpen = select.getIsWidgetAreaOpen(\n\t\t\tdestinationRootClientId\n\t\t);\n\n\t\tif ( ! isDestinationWidgetAreaOpen ) {\n\t\t\tdispatch.setIsWidgetAreaOpen( destinationRootClientId, true );\n\t\t}\n\n\t\t// Move the block.\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.moveBlocksToPosition(\n\t\t\t\t[ clientId ],\n\t\t\t\tsourceRootClientId,\n\t\t\t\tdestinationRootClientId,\n\t\t\t\tdestinationIndex\n\t\t\t);\n\t};\n"]}
|
|
1
|
+
{"version":3,"names":["_i18n","require","_notices","_interface","_widgets","_coreData","_blockEditor","_transformers","_utils","_constants","persistStubPost","id","blocks","registry","stubPost","createStubPost","dispatch","coreStore","receiveEntityRecords","KIND","POST_TYPE","exports","saveEditedWidgetAreas","select","editedWidgetAreas","getEditedWidgetAreas","length","saveWidgetAreas","noticesStore","createSuccessNotice","__","type","e","createErrorNotice","sprintf","message","widgetAreas","widgetArea","saveWidgetArea","finishResolution","WIDGET_AREA_ENTITY_TYPE","buildWidgetAreasQuery","widgetAreaId","widgets","getWidgets","post","getEditedEntityRecord","buildWidgetAreaPostId","areaWidgets","Object","values","filter","sidebar","usedReferenceWidgets","widgetsBlocks","block","attributes","name","includes","push","deletedWidgets","widget","widgetsNewArea","getWidgetAreaForWidgetId","batchMeta","batchTasks","sidebarWidgetsIds","i","widgetId","getWidgetIdFromBlock","oldWidget","transformBlockToWidget","editEntityRecord","undoIgnore","hasEdits","hasEditsForEntityRecord","saveEditedEntityRecord","saveEntityRecord","position","clientId","deleteEntityRecord","force","records","__experimentalBatch","preservedRecords","record","hasOwnProperty","failedWidgetNames","__internalWidgetId","error","getLastEntitySaveError","Error","join","trySaveWidgetArea","undefined","throwOnError","setWidgetIdForClientId","setWidgetAreasOpenState","widgetAreasOpenState","setIsWidgetAreaOpen","isOpen","setIsInserterOpened","value","setIsListViewOpened","closeGeneralSidebar","interfaceStore","disableComplementaryArea","editWidgetsStoreName","moveBlockToWidgetArea","sourceRootClientId","blockEditorStore","getBlockRootClientId","getBlocks","destinationWidgetAreaBlock","find","destinationRootClientId","destinationInnerBlocksClientIds","getBlockOrder","destinationIndex","isDestinationWidgetAreaOpen","getIsWidgetAreaOpen","moveBlocksToPosition"],"sources":["@wordpress/edit-widgets/src/store/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { transformBlockToWidget } from './transformers';\nimport {\n\tbuildWidgetAreaPostId,\n\tbuildWidgetAreasQuery,\n\tcreateStubPost,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\n/**\n * Persists a stub post with given ID to core data store. The post is meant to be in-memory only and\n * shouldn't be saved via the API.\n *\n * @param {string} id Post ID.\n * @param {Array} blocks Blocks the post should consist of.\n * @return {Object} The post object.\n */\nexport const persistStubPost =\n\t( id, blocks ) =>\n\t( { registry } ) => {\n\t\tconst stubPost = createStubPost( id, blocks );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.receiveEntityRecords(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tstubPost,\n\t\t\t\t{ id: stubPost.id },\n\t\t\t\tfalse\n\t\t\t);\n\t\treturn stubPost;\n\t};\n\n/**\n * Converts all the blocks from edited widget areas into widgets,\n * and submits a batch request to save everything at once.\n *\n * Creates a snackbar notice on either success or error.\n *\n * @return {Function} An action creator.\n */\nexport const saveEditedWidgetAreas =\n\t() =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst editedWidgetAreas = select.getEditedWidgetAreas();\n\t\tif ( ! editedWidgetAreas?.length ) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tawait dispatch.saveWidgetAreas( editedWidgetAreas );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( __( 'Widgets saved.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t} catch ( e ) {\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice(\n\t\t\t\t/* translators: %s: The error message. */\n\t\t\t\tsprintf( __( 'There was an error. %s' ), e.message ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n/**\n * Converts all the blocks from specified widget areas into widgets,\n * and submits a batch request to save everything at once.\n *\n * @param {Object[]} widgetAreas Widget areas to save.\n * @return {Function} An action creator.\n */\nexport const saveWidgetAreas =\n\t( widgetAreas ) =>\n\tasync ( { dispatch, registry } ) => {\n\t\ttry {\n\t\t\tfor ( const widgetArea of widgetAreas ) {\n\t\t\t\tawait dispatch.saveWidgetArea( widgetArea.id );\n\t\t\t}\n\t\t} finally {\n\t\t\t// saveEditedEntityRecord resets the resolution status, let's fix it manually.\n\t\t\tawait registry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.finishResolution(\n\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\tKIND,\n\t\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\t\tbuildWidgetAreasQuery()\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Converts all the blocks from a widget area specified by ID into widgets,\n * and submits a batch request to save everything at once.\n *\n * @param {string} widgetAreaId ID of the widget area to process.\n * @return {Function} An action creator.\n */\nexport const saveWidgetArea =\n\t( widgetAreaId ) =>\n\tasync ( { dispatch, select, registry } ) => {\n\t\tconst widgets = select.getWidgets();\n\n\t\tconst post = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( widgetAreaId )\n\t\t\t);\n\n\t\t// Get all widgets from this area\n\t\tconst areaWidgets = Object.values( widgets ).filter(\n\t\t\t( { sidebar } ) => sidebar === widgetAreaId\n\t\t);\n\n\t\t// Remove all duplicate reference widget instances for legacy widgets.\n\t\t// Why? We filter out the widgets with duplicate IDs to prevent adding more than one instance of a widget\n\t\t// implemented using a function. WordPress doesn't support having more than one instance of these, if you try to\n\t\t// save multiple instances of these in different sidebars you will run into undefined behaviors.\n\t\tconst usedReferenceWidgets = [];\n\t\tconst widgetsBlocks = post.blocks.filter( ( block ) => {\n\t\t\tconst { id } = block.attributes;\n\n\t\t\tif ( block.name === 'core/legacy-widget' && id ) {\n\t\t\t\tif ( usedReferenceWidgets.includes( id ) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tusedReferenceWidgets.push( id );\n\t\t\t}\n\t\t\treturn true;\n\t\t} );\n\n\t\t// Determine which widgets have been deleted. We can tell if a widget is\n\t\t// deleted and not just moved to a different area by looking to see if\n\t\t// getWidgetAreaForWidgetId() finds something.\n\t\tconst deletedWidgets = [];\n\t\tfor ( const widget of areaWidgets ) {\n\t\t\tconst widgetsNewArea = select.getWidgetAreaForWidgetId( widget.id );\n\t\t\tif ( ! widgetsNewArea ) {\n\t\t\t\tdeletedWidgets.push( widget );\n\t\t\t}\n\t\t}\n\n\t\tconst batchMeta = [];\n\t\tconst batchTasks = [];\n\t\tconst sidebarWidgetsIds = [];\n\t\tfor ( let i = 0; i < widgetsBlocks.length; i++ ) {\n\t\t\tconst block = widgetsBlocks[ i ];\n\t\t\tconst widgetId = getWidgetIdFromBlock( block );\n\t\t\tconst oldWidget = widgets[ widgetId ];\n\t\t\tconst widget = transformBlockToWidget( block, oldWidget );\n\n\t\t\t// We'll replace the null widgetId after save, but we track it here\n\t\t\t// since order is important.\n\t\t\tsidebarWidgetsIds.push( widgetId );\n\n\t\t\t// Check oldWidget as widgetId might refer to an ID which has been\n\t\t\t// deleted, e.g. if a deleted block is restored via undo after saving.\n\t\t\tif ( oldWidget ) {\n\t\t\t\t// Update an existing widget.\n\t\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t\t'root',\n\t\t\t\t\t'widget',\n\t\t\t\t\twidgetId,\n\t\t\t\t\t{\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tsidebar: widgetAreaId,\n\t\t\t\t\t},\n\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t);\n\n\t\t\t\tconst hasEdits = registry\n\t\t\t\t\t.select( coreStore )\n\t\t\t\t\t.hasEditsForEntityRecord( 'root', 'widget', widgetId );\n\n\t\t\t\tif ( ! hasEdits ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tbatchTasks.push( ( { saveEditedEntityRecord } ) =>\n\t\t\t\t\tsaveEditedEntityRecord( 'root', 'widget', widgetId )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Create a new widget.\n\t\t\t\tbatchTasks.push( ( { saveEntityRecord } ) =>\n\t\t\t\t\tsaveEntityRecord( 'root', 'widget', {\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tsidebar: widgetAreaId,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tbatchMeta.push( {\n\t\t\t\tblock,\n\t\t\t\tposition: i,\n\t\t\t\tclientId: block.clientId,\n\t\t\t} );\n\t\t}\n\t\tfor ( const widget of deletedWidgets ) {\n\t\t\tbatchTasks.push( ( { deleteEntityRecord } ) =>\n\t\t\t\tdeleteEntityRecord( 'root', 'widget', widget.id, {\n\t\t\t\t\tforce: true,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\n\t\tconst records = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.__experimentalBatch( batchTasks );\n\t\tconst preservedRecords = records.filter(\n\t\t\t( record ) => ! record.hasOwnProperty( 'deleted' )\n\t\t);\n\n\t\tconst failedWidgetNames = [];\n\n\t\tfor ( let i = 0; i < preservedRecords.length; i++ ) {\n\t\t\tconst widget = preservedRecords[ i ];\n\t\t\tconst { block, position } = batchMeta[ i ];\n\n\t\t\t// Set __internalWidgetId on the block. This will be persisted to the\n\t\t\t// store when we dispatch receiveEntityRecords( post ) below.\n\t\t\tpost.blocks[ position ].attributes.__internalWidgetId = widget.id;\n\n\t\t\tconst error = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getLastEntitySaveError( 'root', 'widget', widget.id );\n\t\t\tif ( error ) {\n\t\t\t\tfailedWidgetNames.push( block.attributes?.name || block?.name );\n\t\t\t}\n\n\t\t\tif ( ! sidebarWidgetsIds[ position ] ) {\n\t\t\t\tsidebarWidgetsIds[ position ] = widget.id;\n\t\t\t}\n\t\t}\n\n\t\tif ( failedWidgetNames.length ) {\n\t\t\tthrow new Error(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: List of widget names */\n\t\t\t\t\t__( 'Could not save the following widgets: %s.' ),\n\t\t\t\t\tfailedWidgetNames.join( ', ' )\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\tKIND,\n\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\twidgetAreaId,\n\t\t\t{\n\t\t\t\twidgets: sidebarWidgetsIds,\n\t\t\t},\n\t\t\t{ undoIgnore: true }\n\t\t);\n\n\t\tdispatch( trySaveWidgetArea( widgetAreaId ) );\n\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.receiveEntityRecords( KIND, POST_TYPE, post, undefined );\n\t};\n\nconst trySaveWidgetArea =\n\t( widgetAreaId ) =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\twidgetAreaId,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t};\n\n/**\n * Sets the clientId stored for a particular widgetId.\n *\n * @param {number} clientId Client id.\n * @param {number} widgetId Widget id.\n *\n * @return {Object} Action.\n */\nexport function setWidgetIdForClientId( clientId, widgetId ) {\n\treturn {\n\t\ttype: 'SET_WIDGET_ID_FOR_CLIENT_ID',\n\t\tclientId,\n\t\twidgetId,\n\t};\n}\n\n/**\n * Sets the open state of all the widget areas.\n *\n * @param {Object} widgetAreasOpenState The open states of all the widget areas.\n *\n * @return {Object} Action.\n */\nexport function setWidgetAreasOpenState( widgetAreasOpenState ) {\n\treturn {\n\t\ttype: 'SET_WIDGET_AREAS_OPEN_STATE',\n\t\twidgetAreasOpenState,\n\t};\n}\n\n/**\n * Sets the open state of the widget area.\n *\n * @param {string} clientId The clientId of the widget area.\n * @param {boolean} isOpen Whether the widget area should be opened.\n *\n * @return {Object} Action.\n */\nexport function setIsWidgetAreaOpen( clientId, isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_WIDGET_AREA_OPEN',\n\t\tclientId,\n\t\tisOpen,\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 signalling that the user closed the sidebar.\n *\n * @return {Object} Action creator.\n */\nexport const closeGeneralSidebar =\n\t() =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( interfaceStore )\n\t\t\t.disableComplementaryArea( editWidgetsStoreName );\n\t};\n\n/**\n * Action that handles moving a block between widget areas\n *\n * @param {string} clientId The clientId of the block to move.\n * @param {string} widgetAreaId The id of the widget area to move the block to.\n */\nexport const moveBlockToWidgetArea =\n\t( clientId, widgetAreaId ) =>\n\tasync ( { dispatch, select, registry } ) => {\n\t\tconst sourceRootClientId = registry\n\t\t\t.select( blockEditorStore )\n\t\t\t.getBlockRootClientId( clientId );\n\n\t\t// Search the top level blocks (widget areas) for the one with the matching\n\t\t// id attribute. Makes the assumption that all top-level blocks are widget\n\t\t// areas.\n\t\tconst widgetAreas = registry.select( blockEditorStore ).getBlocks();\n\t\tconst destinationWidgetAreaBlock = widgetAreas.find(\n\t\t\t( { attributes } ) => attributes.id === widgetAreaId\n\t\t);\n\t\tconst destinationRootClientId = destinationWidgetAreaBlock.clientId;\n\n\t\t// Get the index for moving to the end of the destination widget area.\n\t\tconst destinationInnerBlocksClientIds = registry\n\t\t\t.select( blockEditorStore )\n\t\t\t.getBlockOrder( destinationRootClientId );\n\t\tconst destinationIndex = destinationInnerBlocksClientIds.length;\n\n\t\t// Reveal the widget area, if it's not open.\n\t\tconst isDestinationWidgetAreaOpen = select.getIsWidgetAreaOpen(\n\t\t\tdestinationRootClientId\n\t\t);\n\n\t\tif ( ! isDestinationWidgetAreaOpen ) {\n\t\t\tdispatch.setIsWidgetAreaOpen( destinationRootClientId, true );\n\t\t}\n\n\t\t// Move the block.\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.moveBlocksToPosition(\n\t\t\t\t[ clientId ],\n\t\t\t\tsourceRootClientId,\n\t\t\t\tdestinationRootClientId,\n\t\t\t\tdestinationIndex\n\t\t\t);\n\t};\n"],"mappings":";;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AAKA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAQA,IAAAQ,UAAA,GAAAR,OAAA;AAtBA;AACA;AACA;;AAQA;AACA;AACA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@wordpress/edit-widgets/src/store/constants.js"],"
|
|
1
|
+
{"version":3,"names":["STORE_NAME","exports"],"sources":["@wordpress/edit-widgets/src/store/constants.js"],"sourcesContent":["/**\n * Module Constants\n */\nexport const STORE_NAME = 'core/edit-widgets';\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACO,MAAMA,UAAU,GAAG,mBAAmB;AAACC,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
|
package/build/store/index.js
CHANGED
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.store = void 0;
|
|
9
|
-
|
|
10
8
|
var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
|
|
11
|
-
|
|
12
9
|
var _data = require("@wordpress/data");
|
|
13
|
-
|
|
14
10
|
var _reducer = _interopRequireDefault(require("./reducer"));
|
|
15
|
-
|
|
16
11
|
var resolvers = _interopRequireWildcard(require("./resolvers"));
|
|
17
|
-
|
|
18
12
|
var selectors = _interopRequireWildcard(require("./selectors"));
|
|
19
|
-
|
|
20
13
|
var actions = _interopRequireWildcard(require("./actions"));
|
|
21
|
-
|
|
22
14
|
var _constants = require("./constants");
|
|
23
|
-
|
|
24
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
|
-
|
|
26
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
-
|
|
28
17
|
/**
|
|
29
18
|
* WordPress dependencies
|
|
30
19
|
*/
|
|
@@ -46,6 +35,7 @@ const storeConfig = {
|
|
|
46
35
|
resolvers,
|
|
47
36
|
actions
|
|
48
37
|
};
|
|
38
|
+
|
|
49
39
|
/**
|
|
50
40
|
* Store definition for the edit widgets namespace.
|
|
51
41
|
*
|
|
@@ -53,18 +43,17 @@ const storeConfig = {
|
|
|
53
43
|
*
|
|
54
44
|
* @type {Object}
|
|
55
45
|
*/
|
|
56
|
-
|
|
57
46
|
const store = (0, _data.createReduxStore)(_constants.STORE_NAME, storeConfig);
|
|
58
47
|
exports.store = store;
|
|
59
|
-
(0, _data.register)(store);
|
|
48
|
+
(0, _data.register)(store);
|
|
49
|
+
|
|
50
|
+
// This package uses a few in-memory post types as wrappers for convenience.
|
|
60
51
|
// This middleware prevents any network requests related to these types as they are
|
|
61
52
|
// bound to fail anyway.
|
|
62
|
-
|
|
63
53
|
_apiFetch.default.use(function (options, next) {
|
|
64
54
|
if (options.path?.indexOf('/wp/v2/types/widget-area') === 0) {
|
|
65
55
|
return Promise.resolve({});
|
|
66
56
|
}
|
|
67
|
-
|
|
68
57
|
return next(options);
|
|
69
58
|
});
|
|
70
59
|
//# sourceMappingURL=index.js.map
|
package/build/store/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_apiFetch","_interopRequireDefault","require","_data","_reducer","resolvers","_interopRequireWildcard","selectors","actions","_constants","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","storeConfig","reducer","store","createReduxStore","STORE_NAME","exports","register","apiFetch","use","options","next","path","indexOf","Promise","resolve"],"sources":["@wordpress/edit-widgets/src/store/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as resolvers from './resolvers';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport { STORE_NAME } from './constants';\n\n/**\n * Block editor data store configuration.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#register\n *\n * @type {Object}\n */\nconst storeConfig = {\n\treducer,\n\tselectors,\n\tresolvers,\n\tactions,\n};\n\n/**\n * Store definition for the edit widgets 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 );\nregister( store );\n\n// This package uses a few in-memory post types as wrappers for convenience.\n// This middleware prevents any network requests related to these types as they are\n// bound to fail anyway.\napiFetch.use( function ( options, next ) {\n\tif ( options.path?.indexOf( '/wp/v2/types/widget-area' ) === 0 ) {\n\t\treturn Promise.resolve( {} );\n\t}\n\n\treturn next( options );\n} );\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,SAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAD,uBAAA,CAAAJ,OAAA;AACA,IAAAM,OAAA,GAAAF,uBAAA,CAAAJ,OAAA;AACA,IAAAO,UAAA,G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