@wordpress/edit-widgets 6.32.0 → 6.32.1-next.ff1cebbba.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
package/build/store/resolvers.js
CHANGED
|
@@ -1,91 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var resolvers_exports = {};
|
|
19
|
+
__export(resolvers_exports, {
|
|
20
|
+
getWidgetAreas: () => getWidgetAreas,
|
|
21
|
+
getWidgets: () => getWidgets
|
|
5
22
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Internal dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Creates a "stub" widgets post reflecting all available widget areas. The
|
|
22
|
-
* post is meant as a convenient to only exists in runtime and should never be saved. It
|
|
23
|
-
* enables a convenient way of editing the widgets by using a regular post editor.
|
|
24
|
-
*
|
|
25
|
-
* Fetches all widgets from all widgets aras, converts them into blocks, and hydrates a new post with them.
|
|
26
|
-
*
|
|
27
|
-
* @return {Function} An action creator.
|
|
28
|
-
*/
|
|
29
|
-
const getWidgetAreas = () => async ({
|
|
30
|
-
dispatch,
|
|
31
|
-
registry
|
|
32
|
-
}) => {
|
|
33
|
-
const query = (0, _utils.buildWidgetAreasQuery)();
|
|
34
|
-
const widgetAreas = await registry.resolveSelect(_coreData.store).getEntityRecords(_utils.KIND, _utils.WIDGET_AREA_ENTITY_TYPE, query);
|
|
23
|
+
module.exports = __toCommonJS(resolvers_exports);
|
|
24
|
+
var import_blocks = require("@wordpress/blocks");
|
|
25
|
+
var import_core_data = require("@wordpress/core-data");
|
|
26
|
+
var import_actions = require("./actions");
|
|
27
|
+
var import_utils = require("./utils");
|
|
28
|
+
var import_transformers = require("./transformers");
|
|
29
|
+
const getWidgetAreas = () => async ({ dispatch, registry }) => {
|
|
30
|
+
const query = (0, import_utils.buildWidgetAreasQuery)();
|
|
31
|
+
const widgetAreas = await registry.resolveSelect(import_core_data.store).getEntityRecords(import_utils.KIND, import_utils.WIDGET_AREA_ENTITY_TYPE, query);
|
|
35
32
|
const widgetAreaBlocks = [];
|
|
36
33
|
const sortedWidgetAreas = widgetAreas.sort((a, b) => {
|
|
37
|
-
if (a.id ===
|
|
34
|
+
if (a.id === "wp_inactive_widgets") {
|
|
38
35
|
return 1;
|
|
39
36
|
}
|
|
40
|
-
if (b.id ===
|
|
37
|
+
if (b.id === "wp_inactive_widgets") {
|
|
41
38
|
return -1;
|
|
42
39
|
}
|
|
43
40
|
return 0;
|
|
44
41
|
});
|
|
45
42
|
for (const widgetArea of sortedWidgetAreas) {
|
|
46
|
-
widgetAreaBlocks.push(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
widgetAreaBlocks.push(
|
|
44
|
+
(0, import_blocks.createBlock)("core/widget-area", {
|
|
45
|
+
id: widgetArea.id,
|
|
46
|
+
name: widgetArea.name
|
|
47
|
+
})
|
|
48
|
+
);
|
|
50
49
|
if (!widgetArea.widgets.length) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
dispatch(
|
|
51
|
+
(0, import_actions.persistStubPost)(
|
|
52
|
+
(0, import_utils.buildWidgetAreaPostId)(widgetArea.id),
|
|
53
|
+
[]
|
|
54
|
+
)
|
|
55
|
+
);
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
const widgetAreasOpenState = {};
|
|
57
59
|
widgetAreaBlocks.forEach((widgetAreaBlock, index) => {
|
|
58
|
-
// Defaults to open the first widget area.
|
|
59
60
|
widgetAreasOpenState[widgetAreaBlock.clientId] = index === 0;
|
|
60
61
|
});
|
|
61
|
-
dispatch((0,
|
|
62
|
-
dispatch(
|
|
62
|
+
dispatch((0, import_actions.setWidgetAreasOpenState)(widgetAreasOpenState));
|
|
63
|
+
dispatch(
|
|
64
|
+
(0, import_actions.persistStubPost)((0, import_utils.buildWidgetAreasPostId)(), widgetAreaBlocks)
|
|
65
|
+
);
|
|
63
66
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
*
|
|
68
|
-
* @return {Function} An action creator.
|
|
69
|
-
*/
|
|
70
|
-
exports.getWidgetAreas = getWidgetAreas;
|
|
71
|
-
const getWidgets = () => async ({
|
|
72
|
-
dispatch,
|
|
73
|
-
registry
|
|
74
|
-
}) => {
|
|
75
|
-
const query = (0, _utils.buildWidgetsQuery)();
|
|
76
|
-
const widgets = await registry.resolveSelect(_coreData.store).getEntityRecords('root', 'widget', query);
|
|
67
|
+
const getWidgets = () => async ({ dispatch, registry }) => {
|
|
68
|
+
const query = (0, import_utils.buildWidgetsQuery)();
|
|
69
|
+
const widgets = await registry.resolveSelect(import_core_data.store).getEntityRecords("root", "widget", query);
|
|
77
70
|
const groupedBySidebar = {};
|
|
78
71
|
for (const widget of widgets) {
|
|
79
|
-
const block = (0,
|
|
72
|
+
const block = (0, import_transformers.transformWidgetToBlock)(widget);
|
|
80
73
|
groupedBySidebar[widget.sidebar] = groupedBySidebar[widget.sidebar] || [];
|
|
81
74
|
groupedBySidebar[widget.sidebar].push(block);
|
|
82
75
|
}
|
|
83
76
|
for (const sidebarId in groupedBySidebar) {
|
|
84
77
|
if (groupedBySidebar.hasOwnProperty(sidebarId)) {
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
dispatch(
|
|
79
|
+
(0, import_actions.persistStubPost)(
|
|
80
|
+
(0, import_utils.buildWidgetAreaPostId)(sidebarId),
|
|
81
|
+
groupedBySidebar[sidebarId]
|
|
82
|
+
)
|
|
83
|
+
);
|
|
87
84
|
}
|
|
88
85
|
}
|
|
89
86
|
};
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
getWidgetAreas,
|
|
90
|
+
getWidgets
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=resolvers.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/resolvers.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { persistStubPost, setWidgetAreasOpenState } from './actions';\nimport {\n\tKIND,\n\tWIDGET_AREA_ENTITY_TYPE,\n\tbuildWidgetsQuery,\n\tbuildWidgetAreasQuery,\n\tbuildWidgetAreaPostId,\n\tbuildWidgetAreasPostId,\n} from './utils';\nimport { transformWidgetToBlock } from './transformers';\n\n/**\n * Creates a \"stub\" widgets post reflecting all available widget areas. The\n * post is meant as a convenient to only exists in runtime and should never be saved. It\n * enables a convenient way of editing the widgets by using a regular post editor.\n *\n * Fetches all widgets from all widgets aras, converts them into blocks, and hydrates a new post with them.\n *\n * @return {Function} An action creator.\n */\nexport const getWidgetAreas =\n\t() =>\n\tasync ( { dispatch, registry } ) => {\n\t\tconst query = buildWidgetAreasQuery();\n\t\tconst widgetAreas = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecords( KIND, WIDGET_AREA_ENTITY_TYPE, query );\n\n\t\tconst widgetAreaBlocks = [];\n\t\tconst sortedWidgetAreas = widgetAreas.sort( ( a, b ) => {\n\t\t\tif ( a.id === 'wp_inactive_widgets' ) {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tif ( b.id === 'wp_inactive_widgets' ) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\treturn 0;\n\t\t} );\n\t\tfor ( const widgetArea of sortedWidgetAreas ) {\n\t\t\twidgetAreaBlocks.push(\n\t\t\t\tcreateBlock( 'core/widget-area', {\n\t\t\t\t\tid: widgetArea.id,\n\t\t\t\t\tname: widgetArea.name,\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\tif ( ! widgetArea.widgets.length ) {\n\t\t\t\t// If this widget area has no widgets, it won't get a post setup by\n\t\t\t\t// the getWidgets resolver.\n\t\t\t\tdispatch(\n\t\t\t\t\tpersistStubPost(\n\t\t\t\t\t\tbuildWidgetAreaPostId( widgetArea.id ),\n\t\t\t\t\t\t[]\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst widgetAreasOpenState = {};\n\t\twidgetAreaBlocks.forEach( ( widgetAreaBlock, index ) => {\n\t\t\t// Defaults to open the first widget area.\n\t\t\twidgetAreasOpenState[ widgetAreaBlock.clientId ] = index === 0;\n\t\t} );\n\t\tdispatch( setWidgetAreasOpenState( widgetAreasOpenState ) );\n\n\t\tdispatch(\n\t\t\tpersistStubPost( buildWidgetAreasPostId(), widgetAreaBlocks )\n\t\t);\n\t};\n\n/**\n * Fetches all widgets from all widgets ares, and groups them by widget area Id.\n *\n * @return {Function} An action creator.\n */\nexport const getWidgets =\n\t() =>\n\tasync ( { dispatch, registry } ) => {\n\t\tconst query = buildWidgetsQuery();\n\t\tconst widgets = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecords( 'root', 'widget', query );\n\n\t\tconst groupedBySidebar = {};\n\n\t\tfor ( const widget of widgets ) {\n\t\t\tconst block = transformWidgetToBlock( widget );\n\t\t\tgroupedBySidebar[ widget.sidebar ] =\n\t\t\t\tgroupedBySidebar[ widget.sidebar ] || [];\n\t\t\tgroupedBySidebar[ widget.sidebar ].push( block );\n\t\t}\n\n\t\tfor ( const sidebarId in groupedBySidebar ) {\n\t\t\tif ( groupedBySidebar.hasOwnProperty( sidebarId ) ) {\n\t\t\t\t// Persist the actual post containing the widget block\n\t\t\t\tdispatch(\n\t\t\t\t\tpersistStubPost(\n\t\t\t\t\t\tbuildWidgetAreaPostId( sidebarId ),\n\t\t\t\t\t\tgroupedBySidebar[ sidebarId ]\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA4B;AAC5B,uBAAmC;AAKnC,qBAAyD;AACzD,mBAOO;AACP,0BAAuC;AAWhC,MAAM,iBACZ,MACA,OAAQ,EAAE,UAAU,SAAS,MAAO;AACnC,QAAM,YAAQ,oCAAsB;AACpC,QAAM,cAAc,MAAM,SACxB,cAAe,iBAAAA,KAAU,EACzB,iBAAkB,mBAAM,sCAAyB,KAAM;AAEzD,QAAM,mBAAmB,CAAC;AAC1B,QAAM,oBAAoB,YAAY,KAAM,CAAE,GAAG,MAAO;AACvD,QAAK,EAAE,OAAO,uBAAwB;AACrC,aAAO;AAAA,IACR;AACA,QAAK,EAAE,OAAO,uBAAwB;AACrC,aAAO;AAAA,IACR;AACA,WAAO;AAAA,EACR,CAAE;AACF,aAAY,cAAc,mBAAoB;AAC7C,qBAAiB;AAAA,UAChB,2BAAa,oBAAoB;AAAA,QAChC,IAAI,WAAW;AAAA,QACf,MAAM,WAAW;AAAA,MAClB,CAAE;AAAA,IACH;AAEA,QAAK,CAAE,WAAW,QAAQ,QAAS;AAGlC;AAAA,YACC;AAAA,cACC,oCAAuB,WAAW,EAAG;AAAA,UACrC,CAAC;AAAA,QACF;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAEA,QAAM,uBAAuB,CAAC;AAC9B,mBAAiB,QAAS,CAAE,iBAAiB,UAAW;AAEvD,yBAAsB,gBAAgB,QAAS,IAAI,UAAU;AAAA,EAC9D,CAAE;AACF,eAAU,wCAAyB,oBAAqB,CAAE;AAE1D;AAAA,QACC,oCAAiB,qCAAuB,GAAG,gBAAiB;AAAA,EAC7D;AACD;AAOM,MAAM,aACZ,MACA,OAAQ,EAAE,UAAU,SAAS,MAAO;AACnC,QAAM,YAAQ,gCAAkB;AAChC,QAAM,UAAU,MAAM,SACpB,cAAe,iBAAAA,KAAU,EACzB,iBAAkB,QAAQ,UAAU,KAAM;AAE5C,QAAM,mBAAmB,CAAC;AAE1B,aAAY,UAAU,SAAU;AAC/B,UAAM,YAAQ,4CAAwB,MAAO;AAC7C,qBAAkB,OAAO,OAAQ,IAChC,iBAAkB,OAAO,OAAQ,KAAK,CAAC;AACxC,qBAAkB,OAAO,OAAQ,EAAE,KAAM,KAAM;AAAA,EAChD;AAEA,aAAY,aAAa,kBAAmB;AAC3C,QAAK,iBAAiB,eAAgB,SAAU,GAAI;AAEnD;AAAA,YACC;AAAA,cACC,oCAAuB,SAAU;AAAA,UACjC,iBAAkB,SAAU;AAAA,QAC7B;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;",
|
|
6
|
+
"names": ["coreStore"]
|
|
7
|
+
}
|
package/build/store/selectors.js
CHANGED
|
@@ -1,274 +1,237 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var selectors_exports = {};
|
|
19
|
+
__export(selectors_exports, {
|
|
20
|
+
__experimentalGetInsertionPoint: () => __experimentalGetInsertionPoint,
|
|
21
|
+
canInsertBlockInWidgetArea: () => canInsertBlockInWidgetArea,
|
|
22
|
+
getEditedWidgetAreas: () => getEditedWidgetAreas,
|
|
23
|
+
getIsWidgetAreaOpen: () => getIsWidgetAreaOpen,
|
|
24
|
+
getParentWidgetAreaBlock: () => getParentWidgetAreaBlock,
|
|
25
|
+
getReferenceWidgetBlocks: () => getReferenceWidgetBlocks,
|
|
26
|
+
getWidget: () => getWidget,
|
|
27
|
+
getWidgetAreaForWidgetId: () => getWidgetAreaForWidgetId,
|
|
28
|
+
getWidgetAreas: () => getWidgetAreas,
|
|
29
|
+
getWidgets: () => getWidgets,
|
|
30
|
+
isInserterOpened: () => isInserterOpened,
|
|
31
|
+
isListViewOpened: () => isListViewOpened,
|
|
32
|
+
isSavingWidgetAreas: () => isSavingWidgetAreas,
|
|
33
|
+
isWidgetSavingLocked: () => isWidgetSavingLocked
|
|
5
34
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
var _widgets = require("@wordpress/widgets");
|
|
14
|
-
var _coreData = require("@wordpress/core-data");
|
|
15
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
16
|
-
var _utils = require("./utils");
|
|
17
|
-
var _constants = require("./constants");
|
|
18
|
-
/**
|
|
19
|
-
* WordPress dependencies
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Internal dependencies
|
|
24
|
-
*/
|
|
25
|
-
|
|
35
|
+
module.exports = __toCommonJS(selectors_exports);
|
|
36
|
+
var import_data = require("@wordpress/data");
|
|
37
|
+
var import_widgets = require("@wordpress/widgets");
|
|
38
|
+
var import_core_data = require("@wordpress/core-data");
|
|
39
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
40
|
+
var import_utils = require("./utils");
|
|
41
|
+
var import_constants = require("./constants");
|
|
26
42
|
const EMPTY_INSERTION_POINT = {
|
|
27
|
-
rootClientId:
|
|
28
|
-
insertionIndex:
|
|
43
|
+
rootClientId: void 0,
|
|
44
|
+
insertionIndex: void 0
|
|
29
45
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
const getWidgets = (0, import_data.createRegistrySelector)(
|
|
47
|
+
(select) => (0, import_data.createSelector)(
|
|
48
|
+
() => {
|
|
49
|
+
const widgets = select(import_core_data.store).getEntityRecords(
|
|
50
|
+
"root",
|
|
51
|
+
"widget",
|
|
52
|
+
(0, import_utils.buildWidgetsQuery)()
|
|
53
|
+
);
|
|
54
|
+
return (
|
|
55
|
+
// Key widgets by their ID.
|
|
56
|
+
widgets?.reduce(
|
|
57
|
+
(allWidgets, widget) => ({
|
|
58
|
+
...allWidgets,
|
|
59
|
+
[widget.id]: widget
|
|
60
|
+
}),
|
|
61
|
+
{}
|
|
62
|
+
) ?? {}
|
|
63
|
+
);
|
|
64
|
+
},
|
|
65
|
+
() => [
|
|
66
|
+
select(import_core_data.store).getEntityRecords(
|
|
67
|
+
"root",
|
|
68
|
+
"widget",
|
|
69
|
+
(0, import_utils.buildWidgetsQuery)()
|
|
70
|
+
)
|
|
71
|
+
]
|
|
72
|
+
)
|
|
73
|
+
);
|
|
74
|
+
const getWidget = (0, import_data.createRegistrySelector)(
|
|
75
|
+
(select) => (state, id) => {
|
|
76
|
+
const widgets = select(import_constants.STORE_NAME).getWidgets();
|
|
77
|
+
return widgets[id];
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
const getWidgetAreas = (0, import_data.createRegistrySelector)((select) => () => {
|
|
81
|
+
const query = (0, import_utils.buildWidgetAreasQuery)();
|
|
82
|
+
return select(import_core_data.store).getEntityRecords(
|
|
83
|
+
import_utils.KIND,
|
|
84
|
+
import_utils.WIDGET_AREA_ENTITY_TYPE,
|
|
85
|
+
query
|
|
44
86
|
);
|
|
45
|
-
}, () => [select(_coreData.store).getEntityRecords('root', 'widget', (0, _utils.buildWidgetsQuery)())]));
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Returns API widget data for a particular widget ID.
|
|
49
|
-
*
|
|
50
|
-
* @param {number} id Widget ID.
|
|
51
|
-
*
|
|
52
|
-
* @return {Object} API widget data for a particular widget ID.
|
|
53
|
-
*/
|
|
54
|
-
const getWidget = exports.getWidget = (0, _data.createRegistrySelector)(select => (state, id) => {
|
|
55
|
-
const widgets = select(_constants.STORE_NAME).getWidgets();
|
|
56
|
-
return widgets[id];
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Returns all API widget areas.
|
|
61
|
-
*
|
|
62
|
-
* @return {Object[]} API List of widget areas.
|
|
63
|
-
*/
|
|
64
|
-
const getWidgetAreas = exports.getWidgetAreas = (0, _data.createRegistrySelector)(select => () => {
|
|
65
|
-
const query = (0, _utils.buildWidgetAreasQuery)();
|
|
66
|
-
return select(_coreData.store).getEntityRecords(_utils.KIND, _utils.WIDGET_AREA_ENTITY_TYPE, query);
|
|
67
87
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Given a child client id, returns the parent widget area block.
|
|
86
|
-
*
|
|
87
|
-
* @param {string} clientId The client id of a block in a widget area.
|
|
88
|
-
*
|
|
89
|
-
* @return {WPBlock} The widget area block.
|
|
90
|
-
*/
|
|
91
|
-
const getParentWidgetAreaBlock = exports.getParentWidgetAreaBlock = (0, _data.createRegistrySelector)(select => (state, clientId) => {
|
|
92
|
-
const {
|
|
93
|
-
getBlock,
|
|
94
|
-
getBlockName,
|
|
95
|
-
getBlockParents
|
|
96
|
-
} = select(_blockEditor.store);
|
|
97
|
-
const blockParents = getBlockParents(clientId);
|
|
98
|
-
const widgetAreaClientId = blockParents.find(parentClientId => getBlockName(parentClientId) === 'core/widget-area');
|
|
99
|
-
return getBlock(widgetAreaClientId);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Returns all edited widget area entity records.
|
|
104
|
-
*
|
|
105
|
-
* @return {Object[]} List of edited widget area entity records.
|
|
106
|
-
*/
|
|
107
|
-
const getEditedWidgetAreas = exports.getEditedWidgetAreas = (0, _data.createRegistrySelector)(select => (state, ids) => {
|
|
108
|
-
let widgetAreas = select(_constants.STORE_NAME).getWidgetAreas();
|
|
109
|
-
if (!widgetAreas) {
|
|
110
|
-
return [];
|
|
88
|
+
const getWidgetAreaForWidgetId = (0, import_data.createRegistrySelector)(
|
|
89
|
+
(select) => (state, widgetId) => {
|
|
90
|
+
const widgetAreas = select(import_constants.STORE_NAME).getWidgetAreas();
|
|
91
|
+
return widgetAreas.find((widgetArea) => {
|
|
92
|
+
const post = select(import_core_data.store).getEditedEntityRecord(
|
|
93
|
+
import_utils.KIND,
|
|
94
|
+
import_utils.POST_TYPE,
|
|
95
|
+
(0, import_utils.buildWidgetAreaPostId)(widgetArea.id)
|
|
96
|
+
);
|
|
97
|
+
const blockWidgetIds = post.blocks.map(
|
|
98
|
+
(block) => (0, import_widgets.getWidgetIdFromBlock)(block)
|
|
99
|
+
);
|
|
100
|
+
return blockWidgetIds.includes(widgetId);
|
|
101
|
+
});
|
|
111
102
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
103
|
+
);
|
|
104
|
+
const getParentWidgetAreaBlock = (0, import_data.createRegistrySelector)(
|
|
105
|
+
(select) => (state, clientId) => {
|
|
106
|
+
const { getBlock, getBlockName, getBlockParents } = select(import_block_editor.store);
|
|
107
|
+
const blockParents = getBlockParents(clientId);
|
|
108
|
+
const widgetAreaClientId = blockParents.find(
|
|
109
|
+
(parentClientId) => getBlockName(parentClientId) === "core/widget-area"
|
|
110
|
+
);
|
|
111
|
+
return getBlock(widgetAreaClientId);
|
|
116
112
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
113
|
+
);
|
|
114
|
+
const getEditedWidgetAreas = (0, import_data.createRegistrySelector)(
|
|
115
|
+
(select) => (state, ids) => {
|
|
116
|
+
let widgetAreas = select(import_constants.STORE_NAME).getWidgetAreas();
|
|
117
|
+
if (!widgetAreas) {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
if (ids) {
|
|
121
|
+
widgetAreas = widgetAreas.filter(
|
|
122
|
+
({ id }) => ids.includes(id)
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
return widgetAreas.filter(
|
|
126
|
+
({ id }) => select(import_core_data.store).hasEditsForEntityRecord(
|
|
127
|
+
import_utils.KIND,
|
|
128
|
+
import_utils.POST_TYPE,
|
|
129
|
+
(0, import_utils.buildWidgetAreaPostId)(id)
|
|
130
|
+
)
|
|
131
|
+
).map(
|
|
132
|
+
({ id }) => select(import_core_data.store).getEditedEntityRecord(
|
|
133
|
+
import_utils.KIND,
|
|
134
|
+
import_utils.WIDGET_AREA_ENTITY_TYPE,
|
|
135
|
+
id
|
|
136
|
+
)
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
const getReferenceWidgetBlocks = (0, import_data.createRegistrySelector)(
|
|
141
|
+
(select) => (state, referenceWidgetName = null) => {
|
|
142
|
+
const results = [];
|
|
143
|
+
const widgetAreas = select(import_constants.STORE_NAME).getWidgetAreas();
|
|
144
|
+
for (const _widgetArea of widgetAreas) {
|
|
145
|
+
const post = select(import_core_data.store).getEditedEntityRecord(
|
|
146
|
+
import_utils.KIND,
|
|
147
|
+
import_utils.POST_TYPE,
|
|
148
|
+
(0, import_utils.buildWidgetAreaPostId)(_widgetArea.id)
|
|
149
|
+
);
|
|
150
|
+
for (const block of post.blocks) {
|
|
151
|
+
if (block.name === "core/legacy-widget" && (!referenceWidgetName || block.attributes?.referenceWidgetName === referenceWidgetName)) {
|
|
152
|
+
results.push(block);
|
|
153
|
+
}
|
|
138
154
|
}
|
|
139
155
|
}
|
|
156
|
+
return results;
|
|
140
157
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Returns true if any widget area is currently being saved.
|
|
146
|
-
*
|
|
147
|
-
* @return {boolean} True if any widget area is currently being saved. False otherwise.
|
|
148
|
-
*/
|
|
149
|
-
const isSavingWidgetAreas = exports.isSavingWidgetAreas = (0, _data.createRegistrySelector)(select => () => {
|
|
150
|
-
const widgetAreasIds = select(_constants.STORE_NAME).getWidgetAreas()?.map(({
|
|
151
|
-
id
|
|
152
|
-
}) => id);
|
|
158
|
+
);
|
|
159
|
+
const isSavingWidgetAreas = (0, import_data.createRegistrySelector)((select) => () => {
|
|
160
|
+
const widgetAreasIds = select(import_constants.STORE_NAME).getWidgetAreas()?.map(({ id }) => id);
|
|
153
161
|
if (!widgetAreasIds) {
|
|
154
162
|
return false;
|
|
155
163
|
}
|
|
156
164
|
for (const id of widgetAreasIds) {
|
|
157
|
-
const isSaving = select(
|
|
165
|
+
const isSaving = select(import_core_data.store).isSavingEntityRecord(
|
|
166
|
+
import_utils.KIND,
|
|
167
|
+
import_utils.WIDGET_AREA_ENTITY_TYPE,
|
|
168
|
+
id
|
|
169
|
+
);
|
|
158
170
|
if (isSaving) {
|
|
159
171
|
return true;
|
|
160
172
|
}
|
|
161
173
|
}
|
|
162
|
-
const widgetIds = [
|
|
174
|
+
const widgetIds = [
|
|
175
|
+
...Object.keys(select(import_constants.STORE_NAME).getWidgets()),
|
|
176
|
+
void 0
|
|
177
|
+
// account for new widgets without an ID
|
|
163
178
|
];
|
|
164
179
|
for (const id of widgetIds) {
|
|
165
|
-
const isSaving = select(
|
|
180
|
+
const isSaving = select(import_core_data.store).isSavingEntityRecord(
|
|
181
|
+
"root",
|
|
182
|
+
"widget",
|
|
183
|
+
id
|
|
184
|
+
);
|
|
166
185
|
if (isSaving) {
|
|
167
186
|
return true;
|
|
168
187
|
}
|
|
169
188
|
}
|
|
170
189
|
return false;
|
|
171
190
|
});
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Gets whether the widget area is opened.
|
|
175
|
-
*
|
|
176
|
-
* @param {Array} state The open state of the widget areas.
|
|
177
|
-
* @param {string} clientId The clientId of the widget area.
|
|
178
|
-
*
|
|
179
|
-
* @return {boolean} True if the widget area is open.
|
|
180
|
-
*/
|
|
181
191
|
const getIsWidgetAreaOpen = (state, clientId) => {
|
|
182
|
-
const {
|
|
183
|
-
widgetAreasOpenState
|
|
184
|
-
} = state;
|
|
192
|
+
const { widgetAreasOpenState } = state;
|
|
185
193
|
return !!widgetAreasOpenState[clientId];
|
|
186
194
|
};
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Returns true if the inserter is opened.
|
|
190
|
-
*
|
|
191
|
-
* @param {Object} state Global application state.
|
|
192
|
-
*
|
|
193
|
-
* @return {boolean} Whether the inserter is opened.
|
|
194
|
-
*/
|
|
195
|
-
exports.getIsWidgetAreaOpen = getIsWidgetAreaOpen;
|
|
196
195
|
function isInserterOpened(state) {
|
|
197
196
|
return !!state.blockInserterPanel;
|
|
198
197
|
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Get the insertion point for the inserter.
|
|
202
|
-
*
|
|
203
|
-
* @param {Object} state Global application state.
|
|
204
|
-
*
|
|
205
|
-
* @return {Object} The root client ID and index to insert at.
|
|
206
|
-
*/
|
|
207
198
|
function __experimentalGetInsertionPoint(state) {
|
|
208
|
-
if (typeof state.blockInserterPanel ===
|
|
199
|
+
if (typeof state.blockInserterPanel === "boolean") {
|
|
209
200
|
return EMPTY_INSERTION_POINT;
|
|
210
201
|
}
|
|
211
202
|
return state.blockInserterPanel;
|
|
212
203
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
// Widget areas are always top-level blocks, which getBlocks will return.
|
|
224
|
-
const widgetAreas = select(_blockEditor.store).getBlocks();
|
|
225
|
-
|
|
226
|
-
// Makes an assumption that a block that can be inserted into one
|
|
227
|
-
// widget area can be inserted into any widget area. Uses the first
|
|
228
|
-
// widget area for testing whether the block can be inserted.
|
|
229
|
-
const [firstWidgetArea] = widgetAreas;
|
|
230
|
-
return select(_blockEditor.store).canInsertBlockType(blockName, firstWidgetArea.clientId);
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Returns true if the list view is opened.
|
|
235
|
-
*
|
|
236
|
-
* @param {Object} state Global application state.
|
|
237
|
-
*
|
|
238
|
-
* @return {boolean} Whether the list view is opened.
|
|
239
|
-
*/
|
|
204
|
+
const canInsertBlockInWidgetArea = (0, import_data.createRegistrySelector)(
|
|
205
|
+
(select) => (state, blockName) => {
|
|
206
|
+
const widgetAreas = select(import_block_editor.store).getBlocks();
|
|
207
|
+
const [firstWidgetArea] = widgetAreas;
|
|
208
|
+
return select(import_block_editor.store).canInsertBlockType(
|
|
209
|
+
blockName,
|
|
210
|
+
firstWidgetArea.clientId
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
);
|
|
240
214
|
function isListViewOpened(state) {
|
|
241
215
|
return state.listViewPanel;
|
|
242
216
|
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Returns whether widget saving is locked.
|
|
246
|
-
*
|
|
247
|
-
* @param {Object} state Global application state.
|
|
248
|
-
*
|
|
249
|
-
* @example
|
|
250
|
-
* ```jsx
|
|
251
|
-
* import { __ } from '@wordpress/i18n';
|
|
252
|
-
* import { store as widgetStore } from '@wordpress/edit-widgets';
|
|
253
|
-
* import { useSelect } from '@wordpress/data';
|
|
254
|
-
*
|
|
255
|
-
* const ExampleComponent = () => {
|
|
256
|
-
* const isSavingLocked = useSelect(
|
|
257
|
-
* ( select ) => select( widgetStore ).isWidgetSavingLocked(),
|
|
258
|
-
* []
|
|
259
|
-
* );
|
|
260
|
-
*
|
|
261
|
-
* return isSavingLocked ? (
|
|
262
|
-
* <p>{ __( 'Widget saving is locked' ) }</p>
|
|
263
|
-
* ) : (
|
|
264
|
-
* <p>{ __( 'Widget saving is not locked' ) }</p>
|
|
265
|
-
* );
|
|
266
|
-
* };
|
|
267
|
-
* ```
|
|
268
|
-
*
|
|
269
|
-
* @return {boolean} Is locked.
|
|
270
|
-
*/
|
|
271
217
|
function isWidgetSavingLocked(state) {
|
|
272
218
|
return Object.keys(state.widgetSavingLock).length > 0;
|
|
273
219
|
}
|
|
274
|
-
|
|
220
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
221
|
+
0 && (module.exports = {
|
|
222
|
+
__experimentalGetInsertionPoint,
|
|
223
|
+
canInsertBlockInWidgetArea,
|
|
224
|
+
getEditedWidgetAreas,
|
|
225
|
+
getIsWidgetAreaOpen,
|
|
226
|
+
getParentWidgetAreaBlock,
|
|
227
|
+
getReferenceWidgetBlocks,
|
|
228
|
+
getWidget,
|
|
229
|
+
getWidgetAreaForWidgetId,
|
|
230
|
+
getWidgetAreas,
|
|
231
|
+
getWidgets,
|
|
232
|
+
isInserterOpened,
|
|
233
|
+
isListViewOpened,
|
|
234
|
+
isSavingWidgetAreas,
|
|
235
|
+
isWidgetSavingLocked
|
|
236
|
+
});
|
|
237
|
+
//# sourceMappingURL=selectors.js.map
|