@wordpress/edit-widgets 6.33.4 → 6.34.1-next.2f1c7c01b.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/blocks/widget-area/edit/index.js +4 -2
- package/build/blocks/widget-area/edit/index.js.map +1 -1
- package/build/blocks/widget-area/edit/inner-blocks.js +3 -1
- package/build/blocks/widget-area/edit/inner-blocks.js.map +1 -1
- package/build/blocks/widget-area/edit/use-is-dragging-within.js +3 -1
- package/build/blocks/widget-area/edit/use-is-dragging-within.js.map +1 -1
- package/build/blocks/widget-area/index.js +4 -2
- package/build/blocks/widget-area/index.js.map +1 -1
- package/build/components/error-boundary/index.js +5 -3
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/header/document-tools/index.js +3 -1
- package/build/components/header/document-tools/index.js.map +1 -1
- package/build/components/header/index.js +3 -1
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/undo-redo/redo.js +3 -1
- package/build/components/header/undo-redo/redo.js.map +1 -1
- package/build/components/header/undo-redo/undo.js +3 -1
- package/build/components/header/undo-redo/undo.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +3 -1
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +3 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +6 -4
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +3 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +2 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +3 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/interface.js +4 -2
- package/build/components/layout/interface.js.map +1 -1
- package/build/components/layout/unsaved-changes-warning.js +2 -0
- package/build/components/layout/unsaved-changes-warning.js.map +1 -1
- package/build/components/more-menu/index.js +3 -1
- package/build/components/more-menu/index.js.map +1 -1
- package/build/components/more-menu/tools-more-menu-group.js +4 -2
- package/build/components/more-menu/tools-more-menu-group.js.map +1 -1
- package/build/components/notices/index.js +4 -2
- package/build/components/notices/index.js.map +1 -1
- package/build/components/save-button/index.js +3 -1
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/secondary-sidebar/index.js +3 -1
- package/build/components/secondary-sidebar/index.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +3 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +3 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/index.js +7 -5
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar/widget-areas.js +3 -1
- package/build/components/sidebar/widget-areas.js.map +1 -1
- package/build/components/welcome-guide/index.js +3 -1
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/widget-areas-block-editor-content/index.js +3 -1
- package/build/components/widget-areas-block-editor-content/index.js.map +1 -1
- package/build/components/widget-areas-block-editor-provider/index.js +7 -5
- package/build/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build/constants.js +4 -2
- package/build/constants.js.map +1 -1
- package/build/filters/index.js +1 -0
- package/build/filters/index.js.map +1 -1
- package/build/filters/move-to-widget-area.js +3 -2
- package/build/filters/move-to-widget-area.js.map +1 -1
- package/build/filters/replace-media-upload.js +15 -1
- package/build/filters/replace-media-upload.js.map +3 -3
- package/build/hooks/use-last-selected-widget-area.js +3 -1
- package/build/hooks/use-last-selected-widget-area.js.map +1 -1
- package/build/hooks/use-widget-library-insertion-point.js +3 -1
- package/build/hooks/use-widget-library-insertion-point.js.map +1 -1
- package/build/index.js +6 -4
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +3 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/store/actions.js +9 -7
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +3 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/index.js +4 -2
- package/build/store/index.js.map +1 -1
- package/build/store/private-selectors.js +2 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +2 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/resolvers.js +4 -2
- package/build/store/resolvers.js.map +1 -1
- package/build/store/selectors.js +13 -11
- package/build/store/selectors.js.map +1 -1
- package/build/store/transformers.js +2 -0
- package/build/store/transformers.js.map +1 -1
- package/build/store/utils.js +8 -6
- package/build/store/utils.js.map +1 -1
- package/build-module/blocks/widget-area/edit/index.js +3 -2
- package/build-module/blocks/widget-area/edit/index.js.map +1 -1
- package/build-module/blocks/widget-area/edit/inner-blocks.js +2 -1
- package/build-module/blocks/widget-area/edit/inner-blocks.js.map +1 -1
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.js +2 -1
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.js.map +1 -1
- package/build-module/blocks/widget-area/index.js +3 -2
- package/build-module/blocks/widget-area/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +4 -3
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/header/document-tools/index.js +2 -1
- package/build-module/components/header/document-tools/index.js.map +1 -1
- package/build-module/components/header/index.js +2 -1
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/undo-redo/redo.js +2 -1
- package/build-module/components/header/undo-redo/redo.js.map +1 -1
- package/build-module/components/header/undo-redo/undo.js +2 -1
- package/build-module/components/header/undo-redo/undo.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +2 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +2 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +5 -4
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +5 -4
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +2 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/interface.js +3 -2
- package/build-module/components/layout/interface.js.map +1 -1
- package/build-module/components/layout/unsaved-changes-warning.js +1 -0
- package/build-module/components/layout/unsaved-changes-warning.js.map +1 -1
- package/build-module/components/more-menu/index.js +2 -1
- package/build-module/components/more-menu/index.js.map +1 -1
- package/build-module/components/more-menu/tools-more-menu-group.js +3 -2
- package/build-module/components/more-menu/tools-more-menu-group.js.map +1 -1
- package/build-module/components/notices/index.js +3 -2
- package/build-module/components/notices/index.js.map +1 -1
- package/build-module/components/save-button/index.js +2 -1
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/index.js +2 -1
- package/build-module/components/secondary-sidebar/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +2 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +2 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/index.js +9 -8
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/widget-areas.js +2 -1
- package/build-module/components/sidebar/widget-areas.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +2 -1
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/widget-areas-block-editor-content/index.js +2 -1
- package/build-module/components/widget-areas-block-editor-content/index.js.map +1 -1
- package/build-module/components/widget-areas-block-editor-provider/index.js +6 -5
- package/build-module/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build-module/constants.js +3 -2
- package/build-module/constants.js.map +1 -1
- package/build-module/filters/index.js +1 -0
- package/build-module/filters/index.js.map +1 -1
- package/build-module/filters/move-to-widget-area.js +3 -2
- package/build-module/filters/move-to-widget-area.js.map +1 -1
- package/build-module/filters/replace-media-upload.js +19 -2
- package/build-module/filters/replace-media-upload.js.map +2 -2
- package/build-module/hooks/use-last-selected-widget-area.js +2 -1
- package/build-module/hooks/use-last-selected-widget-area.js.map +1 -1
- package/build-module/hooks/use-widget-library-insertion-point.js +2 -1
- package/build-module/hooks/use-widget-library-insertion-point.js.map +1 -1
- package/build-module/index.js +6 -5
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js +2 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/actions.js +8 -7
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js +2 -1
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/index.js +3 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-selectors.js +1 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +1 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/resolvers.js +3 -2
- package/build-module/store/resolvers.js.map +1 -1
- package/build-module/store/selectors.js +12 -11
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/transformers.js +1 -0
- package/build-module/store/transformers.js.map +1 -1
- package/build-module/store/utils.js +7 -6
- package/build-module/store/utils.js.map +1 -1
- package/build-style/style-rtl.css +2 -2
- package/build-style/style.css +2 -2
- package/package.json +29 -29
- package/src/filters/replace-media-upload.js +24 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// packages/edit-widgets/src/store/resolvers.js
|
|
1
2
|
import { createBlock } from "@wordpress/blocks";
|
|
2
3
|
import { store as coreStore } from "@wordpress/core-data";
|
|
3
4
|
import { persistStubPost, setWidgetAreasOpenState } from "./actions";
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
buildWidgetAreasPostId
|
|
11
12
|
} from "./utils";
|
|
12
13
|
import { transformWidgetToBlock } from "./transformers";
|
|
13
|
-
|
|
14
|
+
var getWidgetAreas = () => async ({ dispatch, registry }) => {
|
|
14
15
|
const query = buildWidgetAreasQuery();
|
|
15
16
|
const widgetAreas = await registry.resolveSelect(coreStore).getEntityRecords(KIND, WIDGET_AREA_ENTITY_TYPE, query);
|
|
16
17
|
const widgetAreaBlocks = [];
|
|
@@ -48,7 +49,7 @@ const getWidgetAreas = () => async ({ dispatch, registry }) => {
|
|
|
48
49
|
persistStubPost(buildWidgetAreasPostId(), widgetAreaBlocks)
|
|
49
50
|
);
|
|
50
51
|
};
|
|
51
|
-
|
|
52
|
+
var getWidgets = () => async ({ dispatch, registry }) => {
|
|
52
53
|
const query = buildWidgetsQuery();
|
|
53
54
|
const widgets = await registry.resolveSelect(coreStore).getEntityRecords("root", "widget", query);
|
|
54
55
|
const groupedBySidebar = {};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/resolvers.js"],
|
|
4
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": "AAGA,SAAS,mBAAmB;AAC5B,SAAS,SAAS,iBAAiB;AAKnC,SAAS,iBAAiB,+BAA+B;AACzD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,8BAA8B;AAWhC,
|
|
5
|
+
"mappings": ";AAGA,SAAS,mBAAmB;AAC5B,SAAS,SAAS,iBAAiB;AAKnC,SAAS,iBAAiB,+BAA+B;AACzD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,8BAA8B;AAWhC,IAAM,iBACZ,MACA,OAAQ,EAAE,UAAU,SAAS,MAAO;AACnC,QAAM,QAAQ,sBAAsB;AACpC,QAAM,cAAc,MAAM,SACxB,cAAe,SAAU,EACzB,iBAAkB,MAAM,yBAAyB,KAAM;AAEzD,QAAM,mBAAmB,CAAC;AAC1B,QAAM,oBAAoB,YAAY,KAAM,CAAE,GAAG,MAAO;AACvD,QAAK,EAAE,OAAO,uBAAwB;AACrC,aAAO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@
|
|
|
1
|
+
// packages/edit-widgets/src/store/selectors.js
|
|
1
2
|
import { createSelector, createRegistrySelector } from "@wordpress/data";
|
|
2
3
|
import { getWidgetIdFromBlock } from "@wordpress/widgets";
|
|
3
4
|
import { store as coreStore } from "@wordpress/core-data";
|
|
@@ -11,11 +12,11 @@ import {
|
|
|
11
12
|
WIDGET_AREA_ENTITY_TYPE
|
|
12
13
|
} from "./utils";
|
|
13
14
|
import { STORE_NAME as editWidgetsStoreName } from "./constants";
|
|
14
|
-
|
|
15
|
+
var EMPTY_INSERTION_POINT = {
|
|
15
16
|
rootClientId: void 0,
|
|
16
17
|
insertionIndex: void 0
|
|
17
18
|
};
|
|
18
|
-
|
|
19
|
+
var getWidgets = createRegistrySelector(
|
|
19
20
|
(select) => createSelector(
|
|
20
21
|
() => {
|
|
21
22
|
const widgets = select(coreStore).getEntityRecords(
|
|
@@ -43,13 +44,13 @@ const getWidgets = createRegistrySelector(
|
|
|
43
44
|
]
|
|
44
45
|
)
|
|
45
46
|
);
|
|
46
|
-
|
|
47
|
+
var getWidget = createRegistrySelector(
|
|
47
48
|
(select) => (state, id) => {
|
|
48
49
|
const widgets = select(editWidgetsStoreName).getWidgets();
|
|
49
50
|
return widgets[id];
|
|
50
51
|
}
|
|
51
52
|
);
|
|
52
|
-
|
|
53
|
+
var getWidgetAreas = createRegistrySelector((select) => () => {
|
|
53
54
|
const query = buildWidgetAreasQuery();
|
|
54
55
|
return select(coreStore).getEntityRecords(
|
|
55
56
|
KIND,
|
|
@@ -57,7 +58,7 @@ const getWidgetAreas = createRegistrySelector((select) => () => {
|
|
|
57
58
|
query
|
|
58
59
|
);
|
|
59
60
|
});
|
|
60
|
-
|
|
61
|
+
var getWidgetAreaForWidgetId = createRegistrySelector(
|
|
61
62
|
(select) => (state, widgetId) => {
|
|
62
63
|
const widgetAreas = select(editWidgetsStoreName).getWidgetAreas();
|
|
63
64
|
return widgetAreas.find((widgetArea) => {
|
|
@@ -73,7 +74,7 @@ const getWidgetAreaForWidgetId = createRegistrySelector(
|
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
);
|
|
76
|
-
|
|
77
|
+
var getParentWidgetAreaBlock = createRegistrySelector(
|
|
77
78
|
(select) => (state, clientId) => {
|
|
78
79
|
const { getBlock, getBlockName, getBlockParents } = select(blockEditorStore);
|
|
79
80
|
const blockParents = getBlockParents(clientId);
|
|
@@ -83,7 +84,7 @@ const getParentWidgetAreaBlock = createRegistrySelector(
|
|
|
83
84
|
return getBlock(widgetAreaClientId);
|
|
84
85
|
}
|
|
85
86
|
);
|
|
86
|
-
|
|
87
|
+
var getEditedWidgetAreas = createRegistrySelector(
|
|
87
88
|
(select) => (state, ids) => {
|
|
88
89
|
let widgetAreas = select(editWidgetsStoreName).getWidgetAreas();
|
|
89
90
|
if (!widgetAreas) {
|
|
@@ -109,7 +110,7 @@ const getEditedWidgetAreas = createRegistrySelector(
|
|
|
109
110
|
);
|
|
110
111
|
}
|
|
111
112
|
);
|
|
112
|
-
|
|
113
|
+
var getReferenceWidgetBlocks = createRegistrySelector(
|
|
113
114
|
(select) => (state, referenceWidgetName = null) => {
|
|
114
115
|
const results = [];
|
|
115
116
|
const widgetAreas = select(editWidgetsStoreName).getWidgetAreas();
|
|
@@ -128,7 +129,7 @@ const getReferenceWidgetBlocks = createRegistrySelector(
|
|
|
128
129
|
return results;
|
|
129
130
|
}
|
|
130
131
|
);
|
|
131
|
-
|
|
132
|
+
var isSavingWidgetAreas = createRegistrySelector((select) => () => {
|
|
132
133
|
const widgetAreasIds = select(editWidgetsStoreName).getWidgetAreas()?.map(({ id }) => id);
|
|
133
134
|
if (!widgetAreasIds) {
|
|
134
135
|
return false;
|
|
@@ -160,7 +161,7 @@ const isSavingWidgetAreas = createRegistrySelector((select) => () => {
|
|
|
160
161
|
}
|
|
161
162
|
return false;
|
|
162
163
|
});
|
|
163
|
-
|
|
164
|
+
var getIsWidgetAreaOpen = (state, clientId) => {
|
|
164
165
|
const { widgetAreasOpenState } = state;
|
|
165
166
|
return !!widgetAreasOpenState[clientId];
|
|
166
167
|
};
|
|
@@ -173,7 +174,7 @@ function __experimentalGetInsertionPoint(state) {
|
|
|
173
174
|
}
|
|
174
175
|
return state.blockInserterPanel;
|
|
175
176
|
}
|
|
176
|
-
|
|
177
|
+
var canInsertBlockInWidgetArea = createRegistrySelector(
|
|
177
178
|
(select) => (state, blockName) => {
|
|
178
179
|
const widgetAreas = select(blockEditorStore).getBlocks();
|
|
179
180
|
const [firstWidgetArea] = widgetAreas;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/selectors.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\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 {\n\tbuildWidgetsQuery,\n\tbuildWidgetAreasQuery,\n\tbuildWidgetAreaPostId,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\nconst EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n};\n\n/**\n * Returns all API widgets.\n *\n * @return {Object[]} API List of widgets.\n */\nexport const getWidgets = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t() => {\n\t\t\tconst widgets = select( coreStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'widget',\n\t\t\t\tbuildWidgetsQuery()\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t// Key widgets by their ID.\n\t\t\t\twidgets?.reduce(\n\t\t\t\t\t( allWidgets, widget ) => ( {\n\t\t\t\t\t\t...allWidgets,\n\t\t\t\t\t\t[ widget.id ]: widget,\n\t\t\t\t\t} ),\n\t\t\t\t\t{}\n\t\t\t\t) ?? {}\n\t\t\t);\n\t\t},\n\t\t() => [\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'widget',\n\t\t\t\tbuildWidgetsQuery()\n\t\t\t),\n\t\t]\n\t)\n);\n\n/**\n * Returns API widget data for a particular widget ID.\n *\n * @param {number} id Widget ID.\n *\n * @return {Object} API widget data for a particular widget ID.\n */\nexport const getWidget = createRegistrySelector(\n\t( select ) => ( state, id ) => {\n\t\tconst widgets = select( editWidgetsStoreName ).getWidgets();\n\t\treturn widgets[ id ];\n\t}\n);\n\n/**\n * Returns all API widget areas.\n *\n * @return {Object[]} API List of widget areas.\n */\nexport const getWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst query = buildWidgetAreasQuery();\n\treturn select( coreStore ).getEntityRecords(\n\t\tKIND,\n\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\tquery\n\t);\n} );\n\n/**\n * Returns widgetArea containing a block identify by given widgetId\n *\n * @param {string} widgetId The ID of the widget.\n * @return {Object} Containing widget area.\n */\nexport const getWidgetAreaForWidgetId = createRegistrySelector(\n\t( select ) => ( state, widgetId ) => {\n\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\treturn widgetAreas.find( ( widgetArea ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( widgetArea.id )\n\t\t\t);\n\t\t\tconst blockWidgetIds = post.blocks.map( ( block ) =>\n\t\t\t\tgetWidgetIdFromBlock( block )\n\t\t\t);\n\t\t\treturn blockWidgetIds.includes( widgetId );\n\t\t} );\n\t}\n);\n\n/**\n * Given a child client id, returns the parent widget area block.\n *\n * @param {string} clientId The client id of a block in a widget area.\n *\n * @return {WPBlock} The widget area block.\n */\nexport const getParentWidgetAreaBlock = createRegistrySelector(\n\t( select ) => ( state, clientId ) => {\n\t\tconst { getBlock, getBlockName, getBlockParents } =\n\t\t\tselect( blockEditorStore );\n\t\tconst blockParents = getBlockParents( clientId );\n\t\tconst widgetAreaClientId = blockParents.find(\n\t\t\t( parentClientId ) =>\n\t\t\t\tgetBlockName( parentClientId ) === 'core/widget-area'\n\t\t);\n\t\treturn getBlock( widgetAreaClientId );\n\t}\n);\n\n/**\n * Returns all edited widget area entity records.\n *\n * @return {Object[]} List of edited widget area entity records.\n */\nexport const getEditedWidgetAreas = createRegistrySelector(\n\t( select ) => ( state, ids ) => {\n\t\tlet widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\tif ( ! widgetAreas ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( ids ) {\n\t\t\twidgetAreas = widgetAreas.filter( ( { id } ) =>\n\t\t\t\tids.includes( id )\n\t\t\t);\n\t\t}\n\t\treturn widgetAreas\n\t\t\t.filter( ( { id } ) =>\n\t\t\t\tselect( coreStore ).hasEditsForEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( id )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.map( ( { id } ) =>\n\t\t\t\tselect( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\t\tid\n\t\t\t\t)\n\t\t\t);\n\t}\n);\n\n/**\n * Returns all blocks representing reference widgets.\n *\n * @param {string} referenceWidgetName Optional. If given, only reference widgets with this name will be returned.\n * @return {Array} List of all blocks representing reference widgets\n */\nexport const getReferenceWidgetBlocks = createRegistrySelector(\n\t( select ) =>\n\t\t( state, referenceWidgetName = null ) => {\n\t\t\tconst results = [];\n\t\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\t\tfor ( const _widgetArea of widgetAreas ) {\n\t\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( _widgetArea.id )\n\t\t\t\t);\n\t\t\t\tfor ( const block of post.blocks ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tblock.name === 'core/legacy-widget' &&\n\t\t\t\t\t\t( ! referenceWidgetName ||\n\t\t\t\t\t\t\tblock.attributes?.referenceWidgetName ===\n\t\t\t\t\t\t\t\treferenceWidgetName )\n\t\t\t\t\t) {\n\t\t\t\t\t\tresults.push( block );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n);\n\n/**\n * Returns true if any widget area is currently being saved.\n *\n * @return {boolean} True if any widget area is currently being saved. False otherwise.\n */\nexport const isSavingWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst widgetAreasIds = select( editWidgetsStoreName )\n\t\t.getWidgetAreas()\n\t\t?.map( ( { id } ) => id );\n\tif ( ! widgetAreasIds ) {\n\t\treturn false;\n\t}\n\n\tfor ( const id of widgetAreasIds ) {\n\t\tconst isSaving = select( coreStore ).isSavingEntityRecord(\n\t\t\tKIND,\n\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tconst widgetIds = [\n\t\t...Object.keys( select( editWidgetsStoreName ).getWidgets() ),\n\t\tundefined, // account for new widgets without an ID\n\t];\n\tfor ( const id of widgetIds ) {\n\t\tconst isSaving = select( coreStore ).isSavingEntityRecord(\n\t\t\t'root',\n\t\t\t'widget',\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n} );\n\n/**\n * Gets whether the widget area is opened.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} clientId The clientId of the widget area.\n *\n * @return {boolean} True if the widget area is open.\n */\nexport const getIsWidgetAreaOpen = ( state, clientId ) => {\n\tconst { widgetAreasOpenState } = state;\n\treturn !! widgetAreasOpenState[ clientId ];\n};\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID and index to insert at.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tif ( typeof state.blockInserterPanel === 'boolean' ) {\n\t\treturn EMPTY_INSERTION_POINT;\n\t}\n\n\treturn state.blockInserterPanel;\n}\n\n/**\n * Returns true if a block can be inserted into a widget area.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} blockName The name of the block being inserted.\n *\n * @return {boolean} True if the block can be inserted in a widget area.\n */\nexport const canInsertBlockInWidgetArea = createRegistrySelector(\n\t( select ) => ( state, blockName ) => {\n\t\t// Widget areas are always top-level blocks, which getBlocks will return.\n\t\tconst widgetAreas = select( blockEditorStore ).getBlocks();\n\n\t\t// Makes an assumption that a block that can be inserted into one\n\t\t// widget area can be inserted into any widget area. Uses the first\n\t\t// widget area for testing whether the block can be inserted.\n\t\tconst [ firstWidgetArea ] = widgetAreas;\n\t\treturn select( blockEditorStore ).canInsertBlockType(\n\t\t\tblockName,\n\t\t\tfirstWidgetArea.clientId\n\t\t);\n\t}\n);\n\n/**\n * Returns true if the list view is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the list view is opened.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns whether widget saving is locked.\n *\n * @param {Object} state Global application state.\n *\n * @example\n * ```jsx\n * import { __ } from '@wordpress/i18n';\n * import { store as widgetStore } from '@wordpress/edit-widgets';\n * import { useSelect } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * \tconst isSavingLocked = useSelect(\n * \t\t( select ) => select( widgetStore ).isWidgetSavingLocked(),\n * \t\t[]\n * \t);\n *\n * \treturn isSavingLocked ? (\n * \t\t<p>{ __( 'Widget saving is locked' ) }</p>\n * \t) : (\n * \t\t<p>{ __( 'Widget saving is not locked' ) }</p>\n * \t);\n * };\n * ```\n *\n * @return {boolean} Is locked.\n */\nexport function isWidgetSavingLocked( state ) {\n\treturn Object.keys( state.widgetSavingLock ).length > 0;\n}\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,gBAAgB,8BAA8B;AACvD,SAAS,4BAA4B;AACrC,SAAS,SAAS,iBAAiB;AACnC,SAAS,SAAS,wBAAwB;AAK1C;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,cAAc,4BAA4B;AAEnD,
|
|
5
|
+
"mappings": ";AAGA,SAAS,gBAAgB,8BAA8B;AACvD,SAAS,4BAA4B;AACrC,SAAS,SAAS,iBAAiB;AACnC,SAAS,SAAS,wBAAwB;AAK1C;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,cAAc,4BAA4B;AAEnD,IAAM,wBAAwB;AAAA,EAC7B,cAAc;AAAA,EACd,gBAAgB;AACjB;AAOO,IAAM,aAAa;AAAA,EAAwB,CAAE,WACnD;AAAA,IACC,MAAM;AACL,YAAM,UAAU,OAAQ,SAAU,EAAE;AAAA,QACnC;AAAA,QACA;AAAA,QACA,kBAAkB;AAAA,MACnB;AAEA;AAAA;AAAA,QAEC,SAAS;AAAA,UACR,CAAE,YAAY,YAAc;AAAA,YAC3B,GAAG;AAAA,YACH,CAAE,OAAO,EAAG,GAAG;AAAA,UAChB;AAAA,UACA,CAAC;AAAA,QACF,KAAK,CAAC;AAAA;AAAA,IAER;AAAA,IACA,MAAM;AAAA,MACL,OAAQ,SAAU,EAAE;AAAA,QACnB;AAAA,QACA;AAAA,QACA,kBAAkB;AAAA,MACnB;AAAA,IACD;AAAA,EACD;AACD;AASO,IAAM,YAAY;AAAA,EACxB,CAAE,WAAY,CAAE,OAAO,OAAQ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MACA;AAAA,MACA;AAAA,IACD;AACA,QAAK,UAAW;AACf,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR,CAAE;AAUK,IAAM,sBAAsB,CAAE,OAAO,aAAc;AACzD,QAAM,EAAE,qBAAqB,IAAI;AACjC,SAAO,CAAC,CAAE,qBAAsB,QAAS;AAC1C;AASO,SAAS,iBAAkB,OAAQ;AACzC,SAAO,CAAC,CAAE,MAAM;AACjB;AASO,SAAS,gCAAiC,OAAQ;AACxD,MAAK,OAAO,MAAM,uBAAuB,WAAY;AACpD,WAAO;AAAA,EACR;AAEA,SAAO,MAAM;AACd;AAUO,IAAM,6BAA6B;AAAA,EACzC,CAAE,WAAY,CAAE,OAAO,cAAe;AAErC,UAAM,cAAc,OAAQ,gBAAiB,EAAE,UAAU;AAKzD,UAAM,CAAE,eAAgB,IAAI;AAC5B,WAAO,OAAQ,gBAAiB,EAAE;AAAA,MACjC;AAAA,MACA,gBAAgB;AAAA,IACjB;AAAA,EACD;AACD;AASO,SAAS,iBAAkB,OAAQ;AACzC,SAAO,MAAM;AACd;AA6BO,SAAS,qBAAsB,OAAQ;AAC7C,SAAO,OAAO,KAAM,MAAM,gBAAiB,EAAE,SAAS;AACvD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/transformers.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock, parse, serialize } from '@wordpress/blocks';\nimport { addWidgetIdToBlock } from '@wordpress/widgets';\n\n/**\n * Converts a widget entity record into a block.\n *\n * @param {Object} widget The widget entity record.\n * @return {Object} a block (converted from the entity record).\n */\nexport function transformWidgetToBlock( widget ) {\n\tif ( widget.id_base === 'block' ) {\n\t\tconst parsedBlocks = parse( widget.instance.raw.content, {\n\t\t\t__unstableSkipAutop: true,\n\t\t} );\n\t\tif ( ! parsedBlocks.length ) {\n\t\t\treturn addWidgetIdToBlock(\n\t\t\t\tcreateBlock( 'core/paragraph', {}, [] ),\n\t\t\t\twidget.id\n\t\t\t);\n\t\t}\n\t\treturn addWidgetIdToBlock( parsedBlocks[ 0 ], widget.id );\n\t}\n\n\tlet attributes;\n\tif ( widget._embedded.about[ 0 ].is_multi ) {\n\t\tattributes = {\n\t\t\tidBase: widget.id_base,\n\t\t\tinstance: widget.instance,\n\t\t};\n\t} else {\n\t\tattributes = {\n\t\t\tid: widget.id,\n\t\t};\n\t}\n\n\treturn addWidgetIdToBlock(\n\t\tcreateBlock( 'core/legacy-widget', attributes, [] ),\n\t\twidget.id\n\t);\n}\n\n/**\n * Converts a block to a widget entity record.\n *\n * @param {Object} block The block.\n * @param {?Object} relatedWidget A related widget entity record from the API (optional).\n * @return {Object} the widget object (converted from block).\n */\nexport function transformBlockToWidget( block, relatedWidget = {} ) {\n\tlet widget;\n\n\tconst isValidLegacyWidgetBlock =\n\t\tblock.name === 'core/legacy-widget' &&\n\t\t( block.attributes.id || block.attributes.instance );\n\n\tif ( isValidLegacyWidgetBlock ) {\n\t\twidget = {\n\t\t\t...relatedWidget,\n\t\t\tid: block.attributes.id ?? relatedWidget.id,\n\t\t\tid_base: block.attributes.idBase ?? relatedWidget.id_base,\n\t\t\tinstance: block.attributes.instance ?? relatedWidget.instance,\n\t\t};\n\t} else {\n\t\twidget = {\n\t\t\t...relatedWidget,\n\t\t\tid_base: 'block',\n\t\t\tinstance: {\n\t\t\t\traw: {\n\t\t\t\t\tcontent: serialize( block ),\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// Delete read-only properties.\n\tdelete widget.rendered;\n\tdelete widget.rendered_form;\n\n\treturn widget;\n}\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,aAAa,OAAO,iBAAiB;AAC9C,SAAS,0BAA0B;AAQ5B,SAAS,uBAAwB,QAAS;AAChD,MAAK,OAAO,YAAY,SAAU;AACjC,UAAM,eAAe,MAAO,OAAO,SAAS,IAAI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edit-widgets/src/store/utils.js
|
|
2
|
+
var KIND = "root";
|
|
3
|
+
var WIDGET_AREA_ENTITY_TYPE = "sidebar";
|
|
4
|
+
var POST_TYPE = "postType";
|
|
5
|
+
var buildWidgetAreaPostId = (widgetAreaId) => `widget-area-${widgetAreaId}`;
|
|
6
|
+
var buildWidgetAreasPostId = () => `widget-areas`;
|
|
6
7
|
function buildWidgetAreasQuery() {
|
|
7
8
|
return {
|
|
8
9
|
per_page: -1
|
|
@@ -14,7 +15,7 @@ function buildWidgetsQuery() {
|
|
|
14
15
|
_embed: "about"
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
var createStubPost = (id, blocks) => ({
|
|
18
19
|
id,
|
|
19
20
|
slug: id,
|
|
20
21
|
status: "draft",
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/utils.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * \"Kind\" of the navigation post.\n *\n * @type {string}\n */\nexport const KIND = 'root';\n\n/**\n * \"post type\" of the navigation post.\n *\n * @type {string}\n */\nexport const WIDGET_AREA_ENTITY_TYPE = 'sidebar';\n\n/**\n * \"post type\" of the widget area post.\n *\n * @type {string}\n */\nexport const POST_TYPE = 'postType';\n\n/**\n * Builds an ID for a new widget area post.\n *\n * @param {number} widgetAreaId Widget area id.\n * @return {string} An ID.\n */\nexport const buildWidgetAreaPostId = ( widgetAreaId ) =>\n\t`widget-area-${ widgetAreaId }`;\n\n/**\n * Builds an ID for a global widget areas post.\n *\n * @return {string} An ID.\n */\nexport const buildWidgetAreasPostId = () => `widget-areas`;\n\n/**\n * Builds a query to resolve sidebars.\n *\n * @return {Object} Query.\n */\nexport function buildWidgetAreasQuery() {\n\treturn {\n\t\tper_page: -1,\n\t};\n}\n\n/**\n * Builds a query to resolve widgets.\n *\n * @return {Object} Query.\n */\nexport function buildWidgetsQuery() {\n\treturn {\n\t\tper_page: -1,\n\t\t_embed: 'about',\n\t};\n}\n\n/**\n * Creates a stub post with given id and set of blocks. Used as a governing entity records\n * for all widget areas.\n *\n * @param {string} id Post ID.\n * @param {Array} blocks The list of blocks.\n * @return {Object} A stub post object formatted in compliance with the data layer.\n */\nexport const createStubPost = ( id, blocks ) => ( {\n\tid,\n\tslug: id,\n\tstatus: 'draft',\n\ttype: 'page',\n\tblocks,\n\tmeta: {\n\t\twidgetAreaId: id,\n\t},\n} );\n"],
|
|
5
|
-
"mappings": "AAKO,
|
|
5
|
+
"mappings": ";AAKO,IAAM,OAAO;AAOb,IAAM,0BAA0B;AAOhC,IAAM,YAAY;AAQlB,IAAM,wBAAwB,CAAE,iBACtC,eAAgB,YAAa;AAOvB,IAAM,yBAAyB,MAAM;AAOrC,SAAS,wBAAwB;AACvC,SAAO;AAAA,IACN,UAAU;AAAA,EACX;AACD;AAOO,SAAS,oBAAoB;AACnC,SAAO;AAAA,IACN,UAAU;AAAA,IACV,QAAQ;AAAA,EACT;AACD;AAUO,IAAM,iBAAiB,CAAE,IAAI,YAAc;AAAA,EACjD;AAAA,EACA,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN;AAAA,EACA,MAAM;AAAA,IACL,cAAc;AAAA,EACf;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -390,7 +390,7 @@
|
|
|
390
390
|
|
|
391
391
|
.interface-complementary-area h2 {
|
|
392
392
|
font-size: 13px;
|
|
393
|
-
font-weight:
|
|
393
|
+
font-weight: 499;
|
|
394
394
|
color: #1e1e1e;
|
|
395
395
|
margin-bottom: 1.5em;
|
|
396
396
|
}
|
|
@@ -398,7 +398,7 @@
|
|
|
398
398
|
.interface-complementary-area h3 {
|
|
399
399
|
font-size: 11px;
|
|
400
400
|
text-transform: uppercase;
|
|
401
|
-
font-weight:
|
|
401
|
+
font-weight: 499;
|
|
402
402
|
color: #1e1e1e;
|
|
403
403
|
margin-bottom: 1.5em;
|
|
404
404
|
}
|
package/build-style/style.css
CHANGED
|
@@ -390,7 +390,7 @@
|
|
|
390
390
|
|
|
391
391
|
.interface-complementary-area h2 {
|
|
392
392
|
font-size: 13px;
|
|
393
|
-
font-weight:
|
|
393
|
+
font-weight: 499;
|
|
394
394
|
color: #1e1e1e;
|
|
395
395
|
margin-bottom: 1.5em;
|
|
396
396
|
}
|
|
@@ -398,7 +398,7 @@
|
|
|
398
398
|
.interface-complementary-area h3 {
|
|
399
399
|
font-size: 11px;
|
|
400
400
|
text-transform: uppercase;
|
|
401
|
-
font-weight:
|
|
401
|
+
font-weight: 499;
|
|
402
402
|
color: #1e1e1e;
|
|
403
403
|
margin-bottom: 1.5em;
|
|
404
404
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-widgets",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.34.1-next.2f1c7c01b.0",
|
|
4
4
|
"description": "Widgets Page module for WordPress..",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -40,33 +40,33 @@
|
|
|
40
40
|
]
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@wordpress/api-fetch": "^7.
|
|
44
|
-
"@wordpress/base-styles": "^6.
|
|
45
|
-
"@wordpress/block-editor": "^15.
|
|
46
|
-
"@wordpress/block-library": "^9.
|
|
47
|
-
"@wordpress/blocks": "^15.
|
|
48
|
-
"@wordpress/components": "^30.
|
|
49
|
-
"@wordpress/compose": "^7.
|
|
50
|
-
"@wordpress/core-data": "^7.
|
|
51
|
-
"@wordpress/data": "^10.
|
|
52
|
-
"@wordpress/deprecated": "^4.
|
|
53
|
-
"@wordpress/dom": "^4.
|
|
54
|
-
"@wordpress/element": "^6.
|
|
55
|
-
"@wordpress/hooks": "^4.
|
|
56
|
-
"@wordpress/i18n": "^6.
|
|
57
|
-
"@wordpress/icons": "^11.
|
|
58
|
-
"@wordpress/interface": "^9.
|
|
59
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
60
|
-
"@wordpress/keycodes": "^4.
|
|
61
|
-
"@wordpress/media-utils": "^5.
|
|
62
|
-
"@wordpress/notices": "^5.
|
|
63
|
-
"@wordpress/patterns": "^2.
|
|
64
|
-
"@wordpress/plugins": "^7.
|
|
65
|
-
"@wordpress/preferences": "^4.
|
|
66
|
-
"@wordpress/private-apis": "^1.
|
|
67
|
-
"@wordpress/reusable-blocks": "^5.
|
|
68
|
-
"@wordpress/url": "^4.
|
|
69
|
-
"@wordpress/widgets": "^4.
|
|
43
|
+
"@wordpress/api-fetch": "^7.34.1-next.2f1c7c01b.0",
|
|
44
|
+
"@wordpress/base-styles": "^6.10.1-next.2f1c7c01b.0",
|
|
45
|
+
"@wordpress/block-editor": "^15.7.1-next.2f1c7c01b.0",
|
|
46
|
+
"@wordpress/block-library": "^9.34.1-next.2f1c7c01b.0",
|
|
47
|
+
"@wordpress/blocks": "^15.7.1-next.2f1c7c01b.0",
|
|
48
|
+
"@wordpress/components": "^30.7.2-next.2f1c7c01b.0",
|
|
49
|
+
"@wordpress/compose": "^7.34.1-next.2f1c7c01b.0",
|
|
50
|
+
"@wordpress/core-data": "^7.34.1-next.2f1c7c01b.0",
|
|
51
|
+
"@wordpress/data": "^10.34.1-next.2f1c7c01b.0",
|
|
52
|
+
"@wordpress/deprecated": "^4.34.1-next.2f1c7c01b.0",
|
|
53
|
+
"@wordpress/dom": "^4.34.1-next.2f1c7c01b.0",
|
|
54
|
+
"@wordpress/element": "^6.34.1-next.2f1c7c01b.0",
|
|
55
|
+
"@wordpress/hooks": "^4.34.1-next.2f1c7c01b.0",
|
|
56
|
+
"@wordpress/i18n": "^6.7.1-next.2f1c7c01b.0",
|
|
57
|
+
"@wordpress/icons": "^11.1.1-next.2f1c7c01b.0",
|
|
58
|
+
"@wordpress/interface": "^9.19.1-next.2f1c7c01b.0",
|
|
59
|
+
"@wordpress/keyboard-shortcuts": "^5.34.1-next.2f1c7c01b.0",
|
|
60
|
+
"@wordpress/keycodes": "^4.34.1-next.2f1c7c01b.0",
|
|
61
|
+
"@wordpress/media-utils": "^5.34.1-next.2f1c7c01b.0",
|
|
62
|
+
"@wordpress/notices": "^5.34.1-next.2f1c7c01b.0",
|
|
63
|
+
"@wordpress/patterns": "^2.34.1-next.2f1c7c01b.0",
|
|
64
|
+
"@wordpress/plugins": "^7.34.1-next.2f1c7c01b.0",
|
|
65
|
+
"@wordpress/preferences": "^4.34.1-next.2f1c7c01b.0",
|
|
66
|
+
"@wordpress/private-apis": "^1.34.1-next.2f1c7c01b.0",
|
|
67
|
+
"@wordpress/reusable-blocks": "^5.34.1-next.2f1c7c01b.0",
|
|
68
|
+
"@wordpress/url": "^4.34.1-next.2f1c7c01b.0",
|
|
69
|
+
"@wordpress/widgets": "^4.34.1-next.2f1c7c01b.0",
|
|
70
70
|
"clsx": "^2.1.1"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"access": "public"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "c6ddcdf455bc02567a2c9e03de6862a2061b85e8"
|
|
80
80
|
}
|
|
@@ -2,7 +2,30 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { addFilter } from '@wordpress/hooks';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
MediaUpload,
|
|
7
|
+
privateApis as mediaUtilsPrivateApis,
|
|
8
|
+
} from '@wordpress/media-utils';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { unlock } from '../lock-unlock';
|
|
14
|
+
|
|
15
|
+
const { MediaUploadModal: MediaUploadModalComponent } = unlock(
|
|
16
|
+
mediaUtilsPrivateApis
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
if ( window.__experimentalDataViewsMediaModal ) {
|
|
20
|
+
// Create a new filter for the MediaUploadModal component
|
|
21
|
+
addFilter(
|
|
22
|
+
'editor.MediaUploadModal',
|
|
23
|
+
'core/edit-widgets/replace-media-upload-modal',
|
|
24
|
+
() => {
|
|
25
|
+
return MediaUploadModalComponent;
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
}
|
|
6
29
|
|
|
7
30
|
const replaceMediaUpload = () => MediaUpload;
|
|
8
31
|
|