@wordpress/edit-widgets 6.32.0 → 6.32.1-next.b8c8708f3.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/blocks/widget-area/block.json +26 -0
- package/build/blocks/widget-area/edit/index.js +94 -87
- package/build/blocks/widget-area/edit/index.js.map +7 -1
- package/build/blocks/widget-area/edit/inner-blocks.js +68 -50
- package/build/blocks/widget-area/edit/inner-blocks.js.map +7 -1
- package/build/blocks/widget-area/edit/use-is-dragging-within.js +34 -40
- package/build/blocks/widget-area/edit/use-is-dragging-within.js.map +7 -1
- package/build/blocks/widget-area/index.js +49 -52
- package/build/blocks/widget-area/index.js.map +7 -1
- package/build/components/error-boundary/index.js +49 -51
- package/build/components/error-boundary/index.js.map +7 -1
- package/build/components/header/document-tools/index.js +104 -74
- package/build/components/header/document-tools/index.js.map +7 -1
- package/build/components/header/index.js +81 -62
- package/build/components/header/index.js.map +7 -1
- package/build/components/header/undo-redo/redo.js +50 -38
- package/build/components/header/undo-redo/redo.js.map +7 -1
- package/build/components/header/undo-redo/undo.js +49 -37
- package/build/components/header/undo-redo/undo.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +74 -71
- package/build/components/keyboard-shortcut-help-modal/config.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +61 -44
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +154 -103
- package/build/components/keyboard-shortcut-help-modal/index.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +74 -56
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +7 -1
- package/build/components/keyboard-shortcuts/index.js +89 -82
- package/build/components/keyboard-shortcuts/index.js.map +7 -1
- package/build/components/layout/index.js +75 -49
- package/build/components/layout/index.js.map +7 -1
- package/build/components/layout/interface.js +89 -75
- package/build/components/layout/interface.js.map +7 -1
- package/build/components/layout/unsaved-changes-warning.js +35 -42
- package/build/components/layout/unsaved-changes-warning.js.map +7 -1
- package/build/components/more-menu/index.js +189 -108
- package/build/components/more-menu/index.js.map +7 -1
- package/build/components/more-menu/tools-more-menu-group.js +29 -23
- package/build/components/more-menu/tools-more-menu-group.js.map +7 -1
- package/build/components/notices/index.js +62 -48
- package/build/components/notices/index.js.map +7 -1
- package/build/components/save-button/index.js +55 -47
- package/build/components/save-button/index.js.map +7 -1
- package/build/components/secondary-sidebar/index.js +41 -34
- package/build/components/secondary-sidebar/index.js.map +7 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +55 -46
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +7 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +76 -67
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +7 -1
- package/build/components/sidebar/index.js +149 -138
- package/build/components/sidebar/index.js.map +7 -1
- package/build/components/sidebar/widget-areas.js +73 -57
- package/build/components/sidebar/widget-areas.js.map +7 -1
- package/build/components/welcome-guide/index.js +182 -137
- package/build/components/welcome-guide/index.js.map +7 -1
- package/build/components/widget-areas-block-editor-content/index.js +64 -43
- package/build/components/widget-areas-block-editor-content/index.js.map +7 -1
- package/build/components/widget-areas-block-editor-provider/index.js +115 -92
- package/build/components/widget-areas-block-editor-provider/index.js.map +7 -1
- package/build/constants.js +30 -8
- package/build/constants.js.map +7 -1
- package/build/filters/index.js +3 -5
- package/build/filters/index.js.map +7 -1
- package/build/filters/move-to-widget-area.js +52 -59
- package/build/filters/move-to-widget-area.js.map +7 -1
- package/build/filters/replace-media-upload.js +9 -11
- package/build/filters/replace-media-upload.js.map +7 -1
- package/build/hooks/use-last-selected-widget-area.js +38 -44
- package/build/hooks/use-last-selected-widget-area.js.map +7 -1
- package/build/hooks/use-widget-library-insertion-point.js +60 -55
- package/build/hooks/use-widget-library-insertion-point.js.map +7 -1
- package/build/index.js +86 -93
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -15
- package/build/lock-unlock.js.map +7 -1
- package/build/store/actions.js +181 -313
- package/build/store/actions.js.map +7 -1
- package/build/store/constants.js +27 -10
- package/build/store/constants.js.map +7 -1
- package/build/store/index.js +51 -51
- package/build/store/index.js.map +7 -1
- package/build/store/private-selectors.js +28 -7
- package/build/store/private-selectors.js.map +7 -1
- package/build/store/reducer.js +65 -118
- package/build/store/reducer.js.map +7 -1
- package/build/store/resolvers.js +64 -63
- package/build/store/resolvers.js.map +7 -1
- package/build/store/selectors.js +194 -231
- package/build/store/selectors.js.map +7 -1
- package/build/store/transformers.js +47 -41
- package/build/store/transformers.js.map +7 -1
- package/build/store/utils.js +47 -70
- package/build/store/utils.js.map +7 -1
- package/build-module/blocks/widget-area/block.json +26 -0
- package/build-module/blocks/widget-area/edit/index.js +63 -75
- package/build-module/blocks/widget-area/edit/index.js.map +7 -1
- package/build-module/blocks/widget-area/edit/inner-blocks.js +38 -41
- package/build-module/blocks/widget-area/edit/inner-blocks.js.map +7 -1
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.js +14 -33
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.js.map +7 -1
- package/build-module/blocks/widget-area/index.js +14 -46
- package/build-module/blocks/widget-area/index.js.map +7 -1
- package/build-module/components/error-boundary/index.js +30 -43
- package/build-module/components/error-boundary/index.js.map +7 -1
- package/build-module/components/header/document-tools/index.js +75 -66
- package/build-module/components/header/document-tools/index.js.map +7 -1
- package/build-module/components/header/index.js +52 -54
- package/build-module/components/header/index.js.map +7 -1
- package/build-module/components/header/undo-redo/redo.js +32 -32
- package/build-module/components/header/undo-redo/redo.js.map +7 -1
- package/build-module/components/header/undo-redo/undo.js +31 -31
- package/build-module/components/header/undo-redo/undo.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +62 -75
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +33 -37
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +130 -97
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +56 -50
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +7 -1
- package/build-module/components/keyboard-shortcuts/index.js +73 -75
- package/build-module/components/keyboard-shortcuts/index.js.map +7 -1
- package/build-module/components/layout/index.js +46 -41
- package/build-module/components/layout/index.js.map +7 -1
- package/build-module/components/layout/interface.js +63 -66
- package/build-module/components/layout/interface.js.map +7 -1
- package/build-module/components/layout/unsaved-changes-warning.js +17 -37
- package/build-module/components/layout/unsaved-changes-warning.js.map +7 -1
- package/build-module/components/more-menu/index.js +167 -102
- package/build-module/components/more-menu/index.js.map +7 -1
- package/build-module/components/more-menu/tools-more-menu-group.js +11 -17
- package/build-module/components/more-menu/tools-more-menu-group.js.map +7 -1
- package/build-module/components/notices/index.js +43 -42
- package/build-module/components/notices/index.js.map +7 -1
- package/build-module/components/save-button/index.js +37 -41
- package/build-module/components/save-button/index.js.map +7 -1
- package/build-module/components/secondary-sidebar/index.js +14 -27
- package/build-module/components/secondary-sidebar/index.js.map +7 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +26 -38
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +7 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +57 -60
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +7 -1
- package/build-module/components/sidebar/index.js +129 -127
- package/build-module/components/sidebar/index.js.map +7 -1
- package/build-module/components/sidebar/widget-areas.js +53 -49
- package/build-module/components/sidebar/widget-areas.js.map +7 -1
- package/build-module/components/welcome-guide/index.js +165 -132
- package/build-module/components/welcome-guide/index.js.map +7 -1
- package/build-module/components/widget-areas-block-editor-content/index.js +43 -36
- package/build-module/components/widget-areas-block-editor-content/index.js.map +7 -1
- package/build-module/components/widget-areas-block-editor-provider/index.js +85 -83
- package/build-module/components/widget-areas-block-editor-provider/index.js.map +7 -1
- package/build-module/constants.js +7 -3
- package/build-module/constants.js.map +7 -1
- package/build-module/filters/index.js +3 -6
- package/build-module/filters/index.js.map +7 -1
- package/build-module/filters/move-to-widget-area.js +52 -57
- package/build-module/filters/move-to-widget-area.js.map +7 -1
- package/build-module/filters/replace-media-upload.js +8 -7
- package/build-module/filters/replace-media-upload.js.map +7 -1
- package/build-module/hooks/use-last-selected-widget-area.js +20 -39
- package/build-module/hooks/use-last-selected-widget-area.js.map +7 -1
- package/build-module/hooks/use-widget-library-insertion-point.js +42 -49
- package/build-module/hooks/use-widget-library-insertion-point.js.map +7 -1
- package/build-module/index.js +60 -72
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/store/actions.js +153 -293
- package/build-module/store/actions.js.map +7 -1
- package/build-module/store/constants.js +5 -5
- package/build-module/store/constants.js.map +7 -1
- package/build-module/store/index.js +16 -40
- package/build-module/store/index.js.map +7 -1
- package/build-module/store/private-selectors.js +7 -3
- package/build-module/store/private-selectors.js.map +7 -1
- package/build-module/store/reducer.js +42 -111
- package/build-module/store/reducer.js.map +7 -1
- package/build-module/store/resolvers.js +43 -51
- package/build-module/store/resolvers.js.map +7 -1
- package/build-module/store/selectors.js +171 -224
- package/build-module/store/selectors.js.map +7 -1
- package/build-module/store/transformers.js +23 -34
- package/build-module/store/transformers.js.map +7 -1
- package/build-module/store/utils.js +22 -63
- package/build-module/store/utils.js.map +7 -1
- package/build-style/style-rtl.css +216 -88
- package/build-style/style.css +216 -88
- package/package.json +36 -29
- package/src/blocks/widget-area/editor.scss +3 -0
- package/src/components/customizer-edit-widgets-initializer/style.scss +3 -0
- package/src/components/error-boundary/style.scss +2 -0
- package/src/components/header/style.scss +5 -0
- package/src/components/keyboard-shortcut-help-modal/style.scss +2 -0
- package/src/components/layout/style.scss +3 -0
- package/src/components/more-menu/style.scss +2 -0
- package/src/components/notices/style.scss +3 -0
- package/src/components/secondary-sidebar/style.scss +4 -0
- package/src/components/sidebar/style.scss +2 -0
- package/src/components/welcome-guide/style.scss +2 -0
- package/src/components/widget-areas-block-editor-content/style.scss +2 -0
- package/src/style.scss +16 -13
|
@@ -1,119 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import { store as
|
|
6
|
-
import { store as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import { STORE_NAME as editWidgetsStoreName } from
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Persists a stub post with given ID to core data store. The post is meant to be in-memory only and
|
|
20
|
-
* shouldn't be saved via the API.
|
|
21
|
-
*
|
|
22
|
-
* @param {string} id Post ID.
|
|
23
|
-
* @param {Array} blocks Blocks the post should consist of.
|
|
24
|
-
* @return {Object} The post object.
|
|
25
|
-
*/
|
|
26
|
-
export const persistStubPost = (id, blocks) => ({
|
|
27
|
-
registry
|
|
28
|
-
}) => {
|
|
1
|
+
import { __, sprintf } from "@wordpress/i18n";
|
|
2
|
+
import { store as noticesStore } from "@wordpress/notices";
|
|
3
|
+
import { store as interfaceStore } from "@wordpress/interface";
|
|
4
|
+
import { getWidgetIdFromBlock } from "@wordpress/widgets";
|
|
5
|
+
import { store as coreStore } from "@wordpress/core-data";
|
|
6
|
+
import { store as blockEditorStore } from "@wordpress/block-editor";
|
|
7
|
+
import { transformBlockToWidget } from "./transformers";
|
|
8
|
+
import {
|
|
9
|
+
buildWidgetAreaPostId,
|
|
10
|
+
buildWidgetAreasQuery,
|
|
11
|
+
createStubPost,
|
|
12
|
+
KIND,
|
|
13
|
+
POST_TYPE,
|
|
14
|
+
WIDGET_AREA_ENTITY_TYPE
|
|
15
|
+
} from "./utils";
|
|
16
|
+
import { STORE_NAME as editWidgetsStoreName } from "./constants";
|
|
17
|
+
const persistStubPost = (id, blocks) => ({ registry }) => {
|
|
29
18
|
const stubPost = createStubPost(id, blocks);
|
|
30
|
-
registry.dispatch(coreStore).receiveEntityRecords(
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
registry.dispatch(coreStore).receiveEntityRecords(
|
|
20
|
+
KIND,
|
|
21
|
+
POST_TYPE,
|
|
22
|
+
stubPost,
|
|
23
|
+
{ id: stubPost.id },
|
|
24
|
+
false
|
|
25
|
+
);
|
|
33
26
|
return stubPost;
|
|
34
27
|
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Converts all the blocks from edited widget areas into widgets,
|
|
38
|
-
* and submits a batch request to save everything at once.
|
|
39
|
-
*
|
|
40
|
-
* Creates a snackbar notice on either success or error.
|
|
41
|
-
*
|
|
42
|
-
* @return {Function} An action creator.
|
|
43
|
-
*/
|
|
44
|
-
export const saveEditedWidgetAreas = () => async ({
|
|
45
|
-
select,
|
|
46
|
-
dispatch,
|
|
47
|
-
registry
|
|
48
|
-
}) => {
|
|
28
|
+
const saveEditedWidgetAreas = () => async ({ select, dispatch, registry }) => {
|
|
49
29
|
const editedWidgetAreas = select.getEditedWidgetAreas();
|
|
50
30
|
if (!editedWidgetAreas?.length) {
|
|
51
31
|
return;
|
|
52
32
|
}
|
|
53
33
|
try {
|
|
54
34
|
await dispatch.saveWidgetAreas(editedWidgetAreas);
|
|
55
|
-
registry.dispatch(noticesStore).createSuccessNotice(__(
|
|
56
|
-
type:
|
|
35
|
+
registry.dispatch(noticesStore).createSuccessNotice(__("Widgets saved."), {
|
|
36
|
+
type: "snackbar"
|
|
57
37
|
});
|
|
58
38
|
} catch (e) {
|
|
59
|
-
registry.dispatch(noticesStore).createErrorNotice(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
39
|
+
registry.dispatch(noticesStore).createErrorNotice(
|
|
40
|
+
/* translators: %s: The error message. */
|
|
41
|
+
sprintf(__("There was an error. %s"), e.message),
|
|
42
|
+
{
|
|
43
|
+
type: "snackbar"
|
|
44
|
+
}
|
|
45
|
+
);
|
|
63
46
|
}
|
|
64
47
|
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Converts all the blocks from specified widget areas into widgets,
|
|
68
|
-
* and submits a batch request to save everything at once.
|
|
69
|
-
*
|
|
70
|
-
* @param {Object[]} widgetAreas Widget areas to save.
|
|
71
|
-
* @return {Function} An action creator.
|
|
72
|
-
*/
|
|
73
|
-
export const saveWidgetAreas = widgetAreas => async ({
|
|
74
|
-
dispatch,
|
|
75
|
-
registry
|
|
76
|
-
}) => {
|
|
48
|
+
const saveWidgetAreas = (widgetAreas) => async ({ dispatch, registry }) => {
|
|
77
49
|
try {
|
|
78
50
|
for (const widgetArea of widgetAreas) {
|
|
79
51
|
await dispatch.saveWidgetArea(widgetArea.id);
|
|
80
52
|
}
|
|
81
53
|
} finally {
|
|
82
|
-
|
|
83
|
-
|
|
54
|
+
await registry.dispatch(coreStore).finishResolution(
|
|
55
|
+
"getEntityRecord",
|
|
56
|
+
KIND,
|
|
57
|
+
WIDGET_AREA_ENTITY_TYPE,
|
|
58
|
+
buildWidgetAreasQuery()
|
|
59
|
+
);
|
|
84
60
|
}
|
|
85
61
|
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Converts all the blocks from a widget area specified by ID into widgets,
|
|
89
|
-
* and submits a batch request to save everything at once.
|
|
90
|
-
*
|
|
91
|
-
* @param {string} widgetAreaId ID of the widget area to process.
|
|
92
|
-
* @return {Function} An action creator.
|
|
93
|
-
*/
|
|
94
|
-
export const saveWidgetArea = widgetAreaId => async ({
|
|
95
|
-
dispatch,
|
|
96
|
-
select,
|
|
97
|
-
registry
|
|
98
|
-
}) => {
|
|
62
|
+
const saveWidgetArea = (widgetAreaId) => async ({ dispatch, select, registry }) => {
|
|
99
63
|
const widgets = select.getWidgets();
|
|
100
|
-
const post = registry.select(coreStore).getEditedEntityRecord(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
// Why? We filter out the widgets with duplicate IDs to prevent adding more than one instance of a widget
|
|
109
|
-
// implemented using a function. WordPress doesn't support having more than one instance of these, if you try to
|
|
110
|
-
// save multiple instances of these in different sidebars you will run into undefined behaviors.
|
|
64
|
+
const post = registry.select(coreStore).getEditedEntityRecord(
|
|
65
|
+
KIND,
|
|
66
|
+
POST_TYPE,
|
|
67
|
+
buildWidgetAreaPostId(widgetAreaId)
|
|
68
|
+
);
|
|
69
|
+
const areaWidgets = Object.values(widgets).filter(
|
|
70
|
+
({ sidebar }) => sidebar === widgetAreaId
|
|
71
|
+
);
|
|
111
72
|
const usedReferenceWidgets = [];
|
|
112
|
-
const widgetsBlocks = post.blocks.filter(block => {
|
|
113
|
-
const {
|
|
114
|
-
|
|
115
|
-
} = block.attributes;
|
|
116
|
-
if (block.name === 'core/legacy-widget' && id) {
|
|
73
|
+
const widgetsBlocks = post.blocks.filter((block) => {
|
|
74
|
+
const { id } = block.attributes;
|
|
75
|
+
if (block.name === "core/legacy-widget" && id) {
|
|
117
76
|
if (usedReferenceWidgets.includes(id)) {
|
|
118
77
|
return false;
|
|
119
78
|
}
|
|
@@ -121,10 +80,6 @@ export const saveWidgetArea = widgetAreaId => async ({
|
|
|
121
80
|
}
|
|
122
81
|
return true;
|
|
123
82
|
});
|
|
124
|
-
|
|
125
|
-
// Determine which widgets have been deleted. We can tell if a widget is
|
|
126
|
-
// deleted and not just moved to a different area by looking to see if
|
|
127
|
-
// getWidgetAreaForWidgetId() finds something.
|
|
128
83
|
const deletedWidgets = [];
|
|
129
84
|
for (const widget of areaWidgets) {
|
|
130
85
|
const widgetsNewArea = select.getWidgetAreaForWidgetId(widget.id);
|
|
@@ -140,36 +95,32 @@ export const saveWidgetArea = widgetAreaId => async ({
|
|
|
140
95
|
const widgetId = getWidgetIdFromBlock(block);
|
|
141
96
|
const oldWidget = widgets[widgetId];
|
|
142
97
|
const widget = transformBlockToWidget(block, oldWidget);
|
|
143
|
-
|
|
144
|
-
// We'll replace the null widgetId after save, but we track it here
|
|
145
|
-
// since order is important.
|
|
146
98
|
sidebarWidgetsIds.push(widgetId);
|
|
147
|
-
|
|
148
|
-
// Check oldWidget as widgetId might refer to an ID which has been
|
|
149
|
-
// deleted, e.g. if a deleted block is restored via undo after saving.
|
|
150
99
|
if (oldWidget) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
100
|
+
registry.dispatch(coreStore).editEntityRecord(
|
|
101
|
+
"root",
|
|
102
|
+
"widget",
|
|
103
|
+
widgetId,
|
|
104
|
+
{
|
|
105
|
+
...widget,
|
|
106
|
+
sidebar: widgetAreaId
|
|
107
|
+
},
|
|
108
|
+
{ undoIgnore: true }
|
|
109
|
+
);
|
|
110
|
+
const hasEdits = registry.select(coreStore).hasEditsForEntityRecord("root", "widget", widgetId);
|
|
159
111
|
if (!hasEdits) {
|
|
160
112
|
continue;
|
|
161
113
|
}
|
|
162
|
-
batchTasks.push(
|
|
163
|
-
saveEditedEntityRecord
|
|
164
|
-
|
|
114
|
+
batchTasks.push(
|
|
115
|
+
({ saveEditedEntityRecord }) => saveEditedEntityRecord("root", "widget", widgetId)
|
|
116
|
+
);
|
|
165
117
|
} else {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}));
|
|
118
|
+
batchTasks.push(
|
|
119
|
+
({ saveEntityRecord }) => saveEntityRecord("root", "widget", {
|
|
120
|
+
...widget,
|
|
121
|
+
sidebar: widgetAreaId
|
|
122
|
+
})
|
|
123
|
+
);
|
|
173
124
|
}
|
|
174
125
|
batchMeta.push({
|
|
175
126
|
block,
|
|
@@ -178,26 +129,22 @@ export const saveWidgetArea = widgetAreaId => async ({
|
|
|
178
129
|
});
|
|
179
130
|
}
|
|
180
131
|
for (const widget of deletedWidgets) {
|
|
181
|
-
batchTasks.push(
|
|
182
|
-
deleteEntityRecord
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
132
|
+
batchTasks.push(
|
|
133
|
+
({ deleteEntityRecord }) => deleteEntityRecord("root", "widget", widget.id, {
|
|
134
|
+
force: true
|
|
135
|
+
})
|
|
136
|
+
);
|
|
186
137
|
}
|
|
187
138
|
const records = await registry.dispatch(coreStore).__experimentalBatch(batchTasks);
|
|
188
|
-
const preservedRecords = records.filter(
|
|
139
|
+
const preservedRecords = records.filter(
|
|
140
|
+
(record) => !record.hasOwnProperty("deleted")
|
|
141
|
+
);
|
|
189
142
|
const failedWidgetNames = [];
|
|
190
143
|
for (let i = 0; i < preservedRecords.length; i++) {
|
|
191
144
|
const widget = preservedRecords[i];
|
|
192
|
-
const {
|
|
193
|
-
block,
|
|
194
|
-
position
|
|
195
|
-
} = batchMeta[i];
|
|
196
|
-
|
|
197
|
-
// Set __internalWidgetId on the block. This will be persisted to the
|
|
198
|
-
// store when we dispatch receiveEntityRecords( post ) below.
|
|
145
|
+
const { block, position } = batchMeta[i];
|
|
199
146
|
post.blocks[position].attributes.__internalWidgetId = widget.id;
|
|
200
|
-
const error = registry.select(coreStore).getLastEntitySaveError(
|
|
147
|
+
const error = registry.select(coreStore).getLastEntitySaveError("root", "widget", widget.id);
|
|
201
148
|
if (error) {
|
|
202
149
|
failedWidgetNames.push(block.attributes?.name || block?.name);
|
|
203
150
|
}
|
|
@@ -206,205 +153,118 @@ export const saveWidgetArea = widgetAreaId => async ({
|
|
|
206
153
|
}
|
|
207
154
|
}
|
|
208
155
|
if (failedWidgetNames.length) {
|
|
209
|
-
throw new Error(
|
|
210
|
-
|
|
156
|
+
throw new Error(
|
|
157
|
+
sprintf(
|
|
158
|
+
/* translators: %s: List of widget names */
|
|
159
|
+
__("Could not save the following widgets: %s."),
|
|
160
|
+
failedWidgetNames.join(", ")
|
|
161
|
+
)
|
|
162
|
+
);
|
|
211
163
|
}
|
|
212
|
-
registry.dispatch(coreStore).editEntityRecord(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
164
|
+
registry.dispatch(coreStore).editEntityRecord(
|
|
165
|
+
KIND,
|
|
166
|
+
WIDGET_AREA_ENTITY_TYPE,
|
|
167
|
+
widgetAreaId,
|
|
168
|
+
{
|
|
169
|
+
widgets: sidebarWidgetsIds
|
|
170
|
+
},
|
|
171
|
+
{ undoIgnore: true }
|
|
172
|
+
);
|
|
217
173
|
dispatch(trySaveWidgetArea(widgetAreaId));
|
|
218
|
-
registry.dispatch(coreStore).receiveEntityRecords(KIND, POST_TYPE, post,
|
|
174
|
+
registry.dispatch(coreStore).receiveEntityRecords(KIND, POST_TYPE, post, void 0);
|
|
219
175
|
};
|
|
220
|
-
const trySaveWidgetArea = widgetAreaId => ({
|
|
221
|
-
registry
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
176
|
+
const trySaveWidgetArea = (widgetAreaId) => ({ registry }) => {
|
|
177
|
+
registry.dispatch(coreStore).saveEditedEntityRecord(
|
|
178
|
+
KIND,
|
|
179
|
+
WIDGET_AREA_ENTITY_TYPE,
|
|
180
|
+
widgetAreaId,
|
|
181
|
+
{
|
|
182
|
+
throwOnError: true
|
|
183
|
+
}
|
|
184
|
+
);
|
|
226
185
|
};
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Sets the clientId stored for a particular widgetId.
|
|
230
|
-
*
|
|
231
|
-
* @param {number} clientId Client id.
|
|
232
|
-
* @param {number} widgetId Widget id.
|
|
233
|
-
*
|
|
234
|
-
* @return {Object} Action.
|
|
235
|
-
*/
|
|
236
|
-
export function setWidgetIdForClientId(clientId, widgetId) {
|
|
186
|
+
function setWidgetIdForClientId(clientId, widgetId) {
|
|
237
187
|
return {
|
|
238
|
-
type:
|
|
188
|
+
type: "SET_WIDGET_ID_FOR_CLIENT_ID",
|
|
239
189
|
clientId,
|
|
240
190
|
widgetId
|
|
241
191
|
};
|
|
242
192
|
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Sets the open state of all the widget areas.
|
|
246
|
-
*
|
|
247
|
-
* @param {Object} widgetAreasOpenState The open states of all the widget areas.
|
|
248
|
-
*
|
|
249
|
-
* @return {Object} Action.
|
|
250
|
-
*/
|
|
251
|
-
export function setWidgetAreasOpenState(widgetAreasOpenState) {
|
|
193
|
+
function setWidgetAreasOpenState(widgetAreasOpenState) {
|
|
252
194
|
return {
|
|
253
|
-
type:
|
|
195
|
+
type: "SET_WIDGET_AREAS_OPEN_STATE",
|
|
254
196
|
widgetAreasOpenState
|
|
255
197
|
};
|
|
256
198
|
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Sets the open state of the widget area.
|
|
260
|
-
*
|
|
261
|
-
* @param {string} clientId The clientId of the widget area.
|
|
262
|
-
* @param {boolean} isOpen Whether the widget area should be opened.
|
|
263
|
-
*
|
|
264
|
-
* @return {Object} Action.
|
|
265
|
-
*/
|
|
266
|
-
export function setIsWidgetAreaOpen(clientId, isOpen) {
|
|
199
|
+
function setIsWidgetAreaOpen(clientId, isOpen) {
|
|
267
200
|
return {
|
|
268
|
-
type:
|
|
201
|
+
type: "SET_IS_WIDGET_AREA_OPEN",
|
|
269
202
|
clientId,
|
|
270
203
|
isOpen
|
|
271
204
|
};
|
|
272
205
|
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Returns an action object used to open/close the inserter.
|
|
276
|
-
*
|
|
277
|
-
* @param {boolean|Object} value Whether the inserter should be
|
|
278
|
-
* opened (true) or closed (false).
|
|
279
|
-
* To specify an insertion point,
|
|
280
|
-
* use an object.
|
|
281
|
-
* @param {string} value.rootClientId The root client ID to insert at.
|
|
282
|
-
* @param {number} value.insertionIndex The index to insert at.
|
|
283
|
-
*
|
|
284
|
-
* @return {Object} Action object.
|
|
285
|
-
*/
|
|
286
|
-
export function setIsInserterOpened(value) {
|
|
206
|
+
function setIsInserterOpened(value) {
|
|
287
207
|
return {
|
|
288
|
-
type:
|
|
208
|
+
type: "SET_IS_INSERTER_OPENED",
|
|
289
209
|
value
|
|
290
210
|
};
|
|
291
211
|
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Returns an action object used to open/close the list view.
|
|
295
|
-
*
|
|
296
|
-
* @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.
|
|
297
|
-
* @return {Object} Action object.
|
|
298
|
-
*/
|
|
299
|
-
export function setIsListViewOpened(isOpen) {
|
|
212
|
+
function setIsListViewOpened(isOpen) {
|
|
300
213
|
return {
|
|
301
|
-
type:
|
|
214
|
+
type: "SET_IS_LIST_VIEW_OPENED",
|
|
302
215
|
isOpen
|
|
303
216
|
};
|
|
304
217
|
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Returns an action object signalling that the user closed the sidebar.
|
|
308
|
-
*
|
|
309
|
-
* @return {Object} Action creator.
|
|
310
|
-
*/
|
|
311
|
-
export const closeGeneralSidebar = () => ({
|
|
312
|
-
registry
|
|
313
|
-
}) => {
|
|
218
|
+
const closeGeneralSidebar = () => ({ registry }) => {
|
|
314
219
|
registry.dispatch(interfaceStore).disableComplementaryArea(editWidgetsStoreName);
|
|
315
220
|
};
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Action that handles moving a block between widget areas
|
|
319
|
-
*
|
|
320
|
-
* @param {string} clientId The clientId of the block to move.
|
|
321
|
-
* @param {string} widgetAreaId The id of the widget area to move the block to.
|
|
322
|
-
*/
|
|
323
|
-
export const moveBlockToWidgetArea = (clientId, widgetAreaId) => async ({
|
|
324
|
-
dispatch,
|
|
325
|
-
select,
|
|
326
|
-
registry
|
|
327
|
-
}) => {
|
|
221
|
+
const moveBlockToWidgetArea = (clientId, widgetAreaId) => async ({ dispatch, select, registry }) => {
|
|
328
222
|
const sourceRootClientId = registry.select(blockEditorStore).getBlockRootClientId(clientId);
|
|
329
|
-
|
|
330
|
-
// Search the top level blocks (widget areas) for the one with the matching
|
|
331
|
-
// id attribute. Makes the assumption that all top-level blocks are widget
|
|
332
|
-
// areas.
|
|
333
223
|
const widgetAreas = registry.select(blockEditorStore).getBlocks();
|
|
334
|
-
const destinationWidgetAreaBlock = widgetAreas.find(
|
|
335
|
-
attributes
|
|
336
|
-
|
|
224
|
+
const destinationWidgetAreaBlock = widgetAreas.find(
|
|
225
|
+
({ attributes }) => attributes.id === widgetAreaId
|
|
226
|
+
);
|
|
337
227
|
const destinationRootClientId = destinationWidgetAreaBlock.clientId;
|
|
338
|
-
|
|
339
|
-
// Get the index for moving to the end of the destination widget area.
|
|
340
228
|
const destinationInnerBlocksClientIds = registry.select(blockEditorStore).getBlockOrder(destinationRootClientId);
|
|
341
229
|
const destinationIndex = destinationInnerBlocksClientIds.length;
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
230
|
+
const isDestinationWidgetAreaOpen = select.getIsWidgetAreaOpen(
|
|
231
|
+
destinationRootClientId
|
|
232
|
+
);
|
|
345
233
|
if (!isDestinationWidgetAreaOpen) {
|
|
346
234
|
dispatch.setIsWidgetAreaOpen(destinationRootClientId, true);
|
|
347
235
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
236
|
+
registry.dispatch(blockEditorStore).moveBlocksToPosition(
|
|
237
|
+
[clientId],
|
|
238
|
+
sourceRootClientId,
|
|
239
|
+
destinationRootClientId,
|
|
240
|
+
destinationIndex
|
|
241
|
+
);
|
|
351
242
|
};
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Returns an action object used to signal that widget saving is unlocked.
|
|
355
|
-
*
|
|
356
|
-
* @param {string} lockName The lock name.
|
|
357
|
-
*
|
|
358
|
-
* @example
|
|
359
|
-
* ```js
|
|
360
|
-
* import { store as widgetStore } from '@wordpress/edit-widgets';
|
|
361
|
-
* import { useDispatch } from '@wordpress/data';
|
|
362
|
-
*
|
|
363
|
-
* const ExampleComponent = () => {
|
|
364
|
-
* const { unlockWidgetSaving } = useDispatch( widgetStore );
|
|
365
|
-
* return (
|
|
366
|
-
* <Button onClick={ () => unlockWidgetSaving( 'lockName' ) }>
|
|
367
|
-
* { __( 'Unlock Widget Saving' ) }
|
|
368
|
-
* </Button>
|
|
369
|
-
* );
|
|
370
|
-
* };
|
|
371
|
-
* ```
|
|
372
|
-
*
|
|
373
|
-
* @return {Object} Action object
|
|
374
|
-
*/
|
|
375
|
-
export function unlockWidgetSaving(lockName) {
|
|
243
|
+
function unlockWidgetSaving(lockName) {
|
|
376
244
|
return {
|
|
377
|
-
type:
|
|
245
|
+
type: "UNLOCK_WIDGET_SAVING",
|
|
378
246
|
lockName
|
|
379
247
|
};
|
|
380
248
|
}
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Returns an action object used to signal that widget saving is locked.
|
|
384
|
-
*
|
|
385
|
-
* @param {string} lockName The lock name.
|
|
386
|
-
*
|
|
387
|
-
* @example
|
|
388
|
-
* ```js
|
|
389
|
-
* import { store as widgetStore } from '@wordpress/edit-widgets';
|
|
390
|
-
* import { useDispatch } from '@wordpress/data';
|
|
391
|
-
*
|
|
392
|
-
* const ExampleComponent = () => {
|
|
393
|
-
* const { lockWidgetSaving } = useDispatch( widgetStore );
|
|
394
|
-
* return (
|
|
395
|
-
* <Button onClick={ () => lockWidgetSaving( 'lockName' ) }>
|
|
396
|
-
* { __( 'Lock Widget Saving' ) }
|
|
397
|
-
* </Button>
|
|
398
|
-
* );
|
|
399
|
-
* };
|
|
400
|
-
* ```
|
|
401
|
-
*
|
|
402
|
-
* @return {Object} Action object
|
|
403
|
-
*/
|
|
404
|
-
export function lockWidgetSaving(lockName) {
|
|
249
|
+
function lockWidgetSaving(lockName) {
|
|
405
250
|
return {
|
|
406
|
-
type:
|
|
251
|
+
type: "LOCK_WIDGET_SAVING",
|
|
407
252
|
lockName
|
|
408
253
|
};
|
|
409
254
|
}
|
|
410
|
-
|
|
255
|
+
export {
|
|
256
|
+
closeGeneralSidebar,
|
|
257
|
+
lockWidgetSaving,
|
|
258
|
+
moveBlockToWidgetArea,
|
|
259
|
+
persistStubPost,
|
|
260
|
+
saveEditedWidgetAreas,
|
|
261
|
+
saveWidgetArea,
|
|
262
|
+
saveWidgetAreas,
|
|
263
|
+
setIsInserterOpened,
|
|
264
|
+
setIsListViewOpened,
|
|
265
|
+
setIsWidgetAreaOpen,
|
|
266
|
+
setWidgetAreasOpenState,
|
|
267
|
+
setWidgetIdForClientId,
|
|
268
|
+
unlockWidgetSaving
|
|
269
|
+
};
|
|
270
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"names":["__","sprintf","store","noticesStore","interfaceStore","getWidgetIdFromBlock","coreStore","blockEditorStore","transformBlockToWidget","buildWidgetAreaPostId","buildWidgetAreasQuery","createStubPost","KIND","POST_TYPE","WIDGET_AREA_ENTITY_TYPE","STORE_NAME","editWidgetsStoreName","persistStubPost","id","blocks","registry","stubPost","dispatch","receiveEntityRecords","saveEditedWidgetAreas","select","editedWidgetAreas","getEditedWidgetAreas","length","saveWidgetAreas","createSuccessNotice","type","e","createErrorNotice","message","widgetAreas","widgetArea","saveWidgetArea","finishResolution","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","disableComplementaryArea","moveBlockToWidgetArea","sourceRootClientId","getBlockRootClientId","getBlocks","destinationWidgetAreaBlock","find","destinationRootClientId","destinationInnerBlocksClientIds","getBlockOrder","destinationIndex","isDestinationWidgetAreaOpen","getIsWidgetAreaOpen","moveBlocksToPosition","unlockWidgetSaving","lockName","lockWidgetSaving"],"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\n/**\n * Returns an action object used to signal that widget saving is unlocked.\n *\n * @param {string} lockName The lock name.\n *\n * @example\n * ```js\n * import { store as widgetStore } from '@wordpress/edit-widgets';\n * import { useDispatch } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * \tconst { unlockWidgetSaving } = useDispatch( widgetStore );\n * \treturn (\n * \t\t<Button onClick={ () => unlockWidgetSaving( 'lockName' ) }>\n * \t\t\t{ __( 'Unlock Widget Saving' ) }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n * @return {Object} Action object\n */\nexport function unlockWidgetSaving( lockName ) {\n\treturn {\n\t\ttype: 'UNLOCK_WIDGET_SAVING',\n\t\tlockName,\n\t};\n}\n\n/**\n * Returns an action object used to signal that widget saving is locked.\n *\n * @param {string} lockName The lock name.\n *\n * @example\n * ```js\n * import { store as widgetStore } from '@wordpress/edit-widgets';\n * import { useDispatch } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * \tconst { lockWidgetSaving } = useDispatch( widgetStore );\n * \treturn (\n * \t\t<Button onClick={ () => lockWidgetSaving( 'lockName' ) }>\n * \t\t\t{ __( 'Lock Widget Saving' ) }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n * @return {Object} Action object\n */\nexport function lockWidgetSaving( lockName ) {\n\treturn {\n\t\ttype: 'LOCK_WIDGET_SAVING',\n\t\tlockName,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASD,KAAK,IAAIE,cAAc,QAAQ,sBAAsB;AAC9D,SAASC,oBAAoB,QAAQ,oBAAoB;AACzD,SAASH,KAAK,IAAII,SAAS,QAAQ,sBAAsB;AACzD,SAASJ,KAAK,IAAIK,gBAAgB,QAAQ,yBAAyB;;AAEnE;AACA;AACA;AACA,SAASC,sBAAsB,QAAQ,gBAAgB;AACvD,SACCC,qBAAqB,EACrBC,qBAAqB,EACrBC,cAAc,EACdC,IAAI,EACJC,SAAS,EACTC,uBAAuB,QACjB,SAAS;AAChB,SAASC,U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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAED,QAAQ,EAAG;EAC5C,OAAO;IACNnF,IAAI,EAAE,oBAAoB;IAC1BmF;EACD,CAAC;AACF","ignoreList":[]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/actions.js"],
|
|
4
|
+
"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\n/**\n * Returns an action object used to signal that widget saving is unlocked.\n *\n * @param {string} lockName The lock name.\n *\n * @example\n * ```js\n * import { store as widgetStore } from '@wordpress/edit-widgets';\n * import { useDispatch } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * \tconst { unlockWidgetSaving } = useDispatch( widgetStore );\n * \treturn (\n * \t\t<Button onClick={ () => unlockWidgetSaving( 'lockName' ) }>\n * \t\t\t{ __( 'Unlock Widget Saving' ) }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n * @return {Object} Action object\n */\nexport function unlockWidgetSaving( lockName ) {\n\treturn {\n\t\ttype: 'UNLOCK_WIDGET_SAVING',\n\t\tlockName,\n\t};\n}\n\n/**\n * Returns an action object used to signal that widget saving is locked.\n *\n * @param {string} lockName The lock name.\n *\n * @example\n * ```js\n * import { store as widgetStore } from '@wordpress/edit-widgets';\n * import { useDispatch } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * \tconst { lockWidgetSaving } = useDispatch( widgetStore );\n * \treturn (\n * \t\t<Button onClick={ () => lockWidgetSaving( 'lockName' ) }>\n * \t\t\t{ __( 'Lock Widget Saving' ) }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n * @return {Object} Action object\n */\nexport function lockWidgetSaving( lockName ) {\n\treturn {\n\t\ttype: 'LOCK_WIDGET_SAVING',\n\t\tlockName,\n\t};\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,IAAI,eAAe;AAC5B,SAAS,SAAS,oBAAoB;AACtC,SAAS,SAAS,sBAAsB;AACxC,SAAS,4BAA4B;AACrC,SAAS,SAAS,iBAAiB;AACnC,SAAS,SAAS,wBAAwB;AAK1C,SAAS,8BAA8B;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,cAAc,4BAA4B;AAU5C,MAAM,kBACZ,CAAE,IAAI,WACN,CAAE,EAAE,SAAS,MAAO;AACnB,QAAM,WAAW,eAAgB,IAAI,MAAO;AAC5C,WACE,SAAU,SAAU,EACpB;AAAA,IACA;AAA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