@wordpress/edit-widgets 5.10.0 → 5.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/blocks/widget-area/edit/index.js +24 -29
- package/build/blocks/widget-area/edit/index.js.map +1 -1
- package/build/blocks/widget-area/edit/inner-blocks.js +3 -4
- package/build/blocks/widget-area/edit/inner-blocks.js.map +1 -1
- package/build/blocks/widget-area/index.js +3 -6
- package/build/blocks/widget-area/index.js.map +1 -1
- package/build/components/error-boundary/index.js +8 -10
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/header/index.js +4 -3
- package/build/components/header/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +3 -4
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +41 -50
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +10 -12
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build/components/layout/index.js +3 -4
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/interface.js +3 -4
- package/build/components/layout/interface.js.map +1 -1
- package/build/components/layout/unsaved-changes-warning.js +1 -1
- package/build/components/layout/unsaved-changes-warning.js.map +1 -1
- package/build/components/more-menu/tools-more-menu-group.js +5 -8
- package/build/components/more-menu/tools-more-menu-group.js.map +1 -1
- package/build/components/notices/index.js +11 -20
- package/build/components/notices/index.js.map +1 -1
- package/build/components/save-button/index.js +1 -3
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +8 -3
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/index.js +7 -8
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar/widget-areas.js +5 -6
- package/build/components/sidebar/widget-areas.js.map +1 -1
- package/build/components/welcome-guide/index.js +6 -7
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/widget-areas-block-editor-content/index.js +3 -4
- package/build/components/widget-areas-block-editor-content/index.js.map +1 -1
- package/build/components/widget-areas-block-editor-provider/index.js +12 -17
- package/build/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build/filters/move-to-widget-area.js +2 -4
- package/build/filters/move-to-widget-area.js.map +1 -1
- package/build/hooks/use-last-selected-widget-area.js +2 -4
- package/build/hooks/use-last-selected-widget-area.js.map +1 -1
- package/build/hooks/use-widget-library-insertion-point.js +1 -3
- package/build/hooks/use-widget-library-insertion-point.js.map +1 -1
- package/build/store/actions.js +49 -74
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +1 -3
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +3 -11
- package/build/store/reducer.js.map +1 -1
- package/build/store/resolvers.js +8 -10
- package/build/store/resolvers.js.map +1 -1
- package/build/store/selectors.js +15 -32
- package/build/store/selectors.js.map +1 -1
- package/build/store/transformers.js +1 -2
- package/build/store/transformers.js.map +1 -1
- package/build-module/blocks/widget-area/edit/index.js +24 -29
- package/build-module/blocks/widget-area/edit/index.js.map +1 -1
- package/build-module/blocks/widget-area/edit/inner-blocks.js +3 -4
- package/build-module/blocks/widget-area/edit/inner-blocks.js.map +1 -1
- package/build-module/blocks/widget-area/index.js +3 -6
- package/build-module/blocks/widget-area/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +8 -10
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/header/index.js +3 -3
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +3 -4
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +39 -48
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +10 -12
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build-module/components/layout/index.js +3 -4
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/interface.js +3 -4
- package/build-module/components/layout/interface.js.map +1 -1
- package/build-module/components/layout/unsaved-changes-warning.js +1 -1
- package/build-module/components/layout/unsaved-changes-warning.js.map +1 -1
- package/build-module/components/more-menu/tools-more-menu-group.js +5 -8
- package/build-module/components/more-menu/tools-more-menu-group.js.map +1 -1
- package/build-module/components/notices/index.js +11 -20
- package/build-module/components/notices/index.js.map +1 -1
- package/build-module/components/save-button/index.js +1 -3
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +9 -3
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/index.js +9 -10
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/widget-areas.js +5 -6
- package/build-module/components/sidebar/widget-areas.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +6 -7
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/widget-areas-block-editor-content/index.js +3 -4
- 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 +12 -17
- package/build-module/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build-module/filters/move-to-widget-area.js +2 -4
- package/build-module/filters/move-to-widget-area.js.map +1 -1
- package/build-module/hooks/use-last-selected-widget-area.js +2 -4
- package/build-module/hooks/use-last-selected-widget-area.js.map +1 -1
- package/build-module/hooks/use-widget-library-insertion-point.js +1 -3
- package/build-module/hooks/use-widget-library-insertion-point.js.map +1 -1
- package/build-module/store/actions.js +49 -74
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +1 -3
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +3 -11
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/resolvers.js +8 -10
- package/build-module/store/resolvers.js.map +1 -1
- package/build-module/store/selectors.js +15 -32
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/transformers.js +1 -2
- package/build-module/store/transformers.js.map +1 -1
- package/build-style/style-rtl.css +10 -11
- package/build-style/style.css +10 -11
- package/package.json +27 -27
- package/src/components/header/index.js +2 -1
- package/src/components/secondary-sidebar/list-view-sidebar.js +8 -1
- package/src/components/sidebar/index.js +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-widgets/src/store/reducer.js"],"names":["combineReducers","widgetAreasOpenState","state","action","type","clientId","isOpen","blockInserterPanel","value","listViewPanel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,iBAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,oBAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-widgets/src/store/reducer.js"],"names":["combineReducers","widgetAreasOpenState","state","action","type","clientId","isOpen","blockInserterPanel","value","listViewPanel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,iBAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,oBAAT,CAA+BC,KAAK,GAAG,EAAvC,EAA2CC,MAA3C,EAAoD;AAC1D,QAAM;AAAEC,IAAAA;AAAF,MAAWD,MAAjB;;AACA,UAASC,IAAT;AACC,SAAK,6BAAL;AAAoC;AACnC,eAAOD,MAAM,CAACF,oBAAd;AACA;;AACD,SAAK,yBAAL;AAAgC;AAC/B,cAAM;AAAEI,UAAAA,QAAF;AAAYC,UAAAA;AAAZ,YAAuBH,MAA7B;AACA,eAAO,EACN,GAAGD,KADG;AAEN,WAAEG,QAAF,GAAcC;AAFR,SAAP;AAIA;;AACD;AAAS;AACR,eAAOJ,KAAP;AACA;AAbF;AAeA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,kBAAT,CAA6BL,KAAK,GAAG,KAArC,EAA4CC,MAA5C,EAAqD;AAC3D,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,yBAAL;AACC,aAAOD,MAAM,CAACG,MAAP,GAAgB,KAAhB,GAAwBJ,KAA/B;;AACD,SAAK,wBAAL;AACC,aAAOC,MAAM,CAACK,KAAd;AAJF;;AAMA,SAAON,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASO,aAAT,CAAwBP,KAAK,GAAG,KAAhC,EAAuCC,MAAvC,EAAgD;AACtD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,wBAAL;AACC,aAAOD,MAAM,CAACK,KAAP,GAAe,KAAf,GAAuBN,KAA9B;;AACD,SAAK,yBAAL;AACC,aAAOC,MAAM,CAACG,MAAd;AAJF;;AAMA,SAAOJ,KAAP;AACA;AAED,eAAeF,eAAe,CAAE;AAC/BO,EAAAA,kBAD+B;AAE/BE,EAAAA,aAF+B;AAG/BR,EAAAA;AAH+B,CAAF,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Controls the open state of the widget areas.\n *\n * @param {Object} state Redux state.\n * @param {Object} action Redux action.\n *\n * @return {Array} Updated state.\n */\nexport function widgetAreasOpenState( state = {}, action ) {\n\tconst { type } = action;\n\tswitch ( type ) {\n\t\tcase 'SET_WIDGET_AREAS_OPEN_STATE': {\n\t\t\treturn action.widgetAreasOpenState;\n\t\t}\n\t\tcase 'SET_IS_WIDGET_AREA_OPEN': {\n\t\t\tconst { clientId, isOpen } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ clientId ]: isOpen,\n\t\t\t};\n\t\t}\n\t\tdefault: {\n\t\t\treturn state;\n\t\t}\n\t}\n}\n\n/**\n * Reducer to set the block inserter panel open or closed.\n *\n * Note: this reducer interacts with the list view panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the list view panel open or closed.\n *\n * Note: this reducer interacts with the inserter panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function listViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value ? false : state;\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t}\n\treturn state;\n}\n\nexport default combineReducers( {\n\tblockInserterPanel,\n\tlistViewPanel,\n\twidgetAreasOpenState,\n} );\n"]}
|
|
@@ -20,11 +20,10 @@ import { transformWidgetToBlock } from './transformers';
|
|
|
20
20
|
* @return {Function} An action creator.
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
export const getWidgetAreas = () => async
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} = _ref;
|
|
23
|
+
export const getWidgetAreas = () => async ({
|
|
24
|
+
dispatch,
|
|
25
|
+
registry
|
|
26
|
+
}) => {
|
|
28
27
|
const query = buildWidgetAreasQuery();
|
|
29
28
|
const widgetAreas = await registry.resolveSelect(coreStore).getEntityRecords(KIND, WIDGET_AREA_ENTITY_TYPE, query);
|
|
30
29
|
const widgetAreaBlocks = [];
|
|
@@ -67,11 +66,10 @@ export const getWidgetAreas = () => async _ref => {
|
|
|
67
66
|
* @return {Function} An action creator.
|
|
68
67
|
*/
|
|
69
68
|
|
|
70
|
-
export const getWidgets = () => async
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
} = _ref2;
|
|
69
|
+
export const getWidgets = () => async ({
|
|
70
|
+
dispatch,
|
|
71
|
+
registry
|
|
72
|
+
}) => {
|
|
75
73
|
const query = buildWidgetsQuery();
|
|
76
74
|
const widgets = await registry.resolveSelect(coreStore).getEntityRecords('root', 'widget', query);
|
|
77
75
|
const groupedBySidebar = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-widgets/src/store/resolvers.js"],"names":["createBlock","store","coreStore","persistStubPost","setWidgetAreasOpenState","KIND","WIDGET_AREA_ENTITY_TYPE","buildWidgetsQuery","buildWidgetAreasQuery","buildWidgetAreaPostId","buildWidgetAreasPostId","transformWidgetToBlock","getWidgetAreas","dispatch","registry","query","widgetAreas","resolveSelect","getEntityRecords","widgetAreaBlocks","sortedWidgetAreas","sort","a","b","id","widgetArea","push","name","widgets","length","widgetAreasOpenState","forEach","widgetAreaBlock","index","clientId","getWidgets","groupedBySidebar","widget","block","sidebar","sidebarId","hasOwnProperty"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,mBAA5B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASC,eAAT,EAA0BC,uBAA1B,QAAyD,WAAzD;AACA,SACCC,IADD,EAECC,uBAFD,EAGCC,iBAHD,EAICC,qBAJD,EAKCC,qBALD,EAMCC,sBAND,QAOO,SAPP;AAQA,SAASC,sBAAT,QAAuC,gBAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,cAAc,GAC1B,MACA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-widgets/src/store/resolvers.js"],"names":["createBlock","store","coreStore","persistStubPost","setWidgetAreasOpenState","KIND","WIDGET_AREA_ENTITY_TYPE","buildWidgetsQuery","buildWidgetAreasQuery","buildWidgetAreaPostId","buildWidgetAreasPostId","transformWidgetToBlock","getWidgetAreas","dispatch","registry","query","widgetAreas","resolveSelect","getEntityRecords","widgetAreaBlocks","sortedWidgetAreas","sort","a","b","id","widgetArea","push","name","widgets","length","widgetAreasOpenState","forEach","widgetAreaBlock","index","clientId","getWidgets","groupedBySidebar","widget","block","sidebar","sidebarId","hasOwnProperty"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,mBAA5B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASC,eAAT,EAA0BC,uBAA1B,QAAyD,WAAzD;AACA,SACCC,IADD,EAECC,uBAFD,EAGCC,iBAHD,EAICC,qBAJD,EAKCC,qBALD,EAMCC,sBAND,QAOO,SAPP;AAQA,SAASC,sBAAT,QAAuC,gBAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,cAAc,GAC1B,MACA,OAAQ;AAAEC,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,CAAR,KAAoC;AACnC,QAAMC,KAAK,GAAGP,qBAAqB,EAAnC;AACA,QAAMQ,WAAW,GAAG,MAAMF,QAAQ,CAChCG,aADwB,CACTf,SADS,EAExBgB,gBAFwB,CAENb,IAFM,EAEAC,uBAFA,EAEyBS,KAFzB,CAA1B;AAIA,QAAMI,gBAAgB,GAAG,EAAzB;AACA,QAAMC,iBAAiB,GAAGJ,WAAW,CAACK,IAAZ,CAAkB,CAAEC,CAAF,EAAKC,CAAL,KAAY;AACvD,QAAKD,CAAC,CAACE,EAAF,KAAS,qBAAd,EAAsC;AACrC,aAAO,CAAP;AACA;;AACD,QAAKD,CAAC,CAACC,EAAF,KAAS,qBAAd,EAAsC;AACrC,aAAO,CAAC,CAAR;AACA;;AACD,WAAO,CAAP;AACA,GARyB,CAA1B;;AASA,OAAM,MAAMC,UAAZ,IAA0BL,iBAA1B,EAA8C;AAC7CD,IAAAA,gBAAgB,CAACO,IAAjB,CACC1B,WAAW,CAAE,kBAAF,EAAsB;AAChCwB,MAAAA,EAAE,EAAEC,UAAU,CAACD,EADiB;AAEhCG,MAAAA,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C,CAAyCY,KAAzC;AACA;;AAED,OAAM,MAAME,SAAZ,IAAyBJ,gBAAzB,EAA4C;AAC3C,QAAKA,gBAAgB,CAACK,cAAjB,CAAiCD,SAAjC,CAAL,EAAoD;AACnD;AACA3B,MAAAA,QAAQ,CACPV,eAAe,CACdM,qBAAqB,CAAE+B,SAAF,CADP,EAEdJ,gBAAgB,CAAEI,SAAF,CAFF,CADR,CAAR;AAMA;AACD;AACD,CA5BK","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"]}
|
|
@@ -20,9 +20,9 @@ import { STORE_NAME as editWidgetsStoreName } from './constants';
|
|
|
20
20
|
export const getWidgets = createRegistrySelector(select => () => {
|
|
21
21
|
const widgets = select(coreStore).getEntityRecords('root', 'widget', buildWidgetsQuery());
|
|
22
22
|
return (// Key widgets by their ID.
|
|
23
|
-
|
|
23
|
+
widgets?.reduce((allWidgets, widget) => ({ ...allWidgets,
|
|
24
24
|
[widget.id]: widget
|
|
25
|
-
}), {})
|
|
25
|
+
}), {}) || {}
|
|
26
26
|
);
|
|
27
27
|
});
|
|
28
28
|
/**
|
|
@@ -94,25 +94,16 @@ export const getEditedWidgetAreas = createRegistrySelector(select => (state, ids
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
if (ids) {
|
|
97
|
-
widgetAreas = widgetAreas.filter(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
} = _ref;
|
|
101
|
-
return ids.includes(id);
|
|
102
|
-
});
|
|
97
|
+
widgetAreas = widgetAreas.filter(({
|
|
98
|
+
id
|
|
99
|
+
}) => ids.includes(id));
|
|
103
100
|
}
|
|
104
101
|
|
|
105
|
-
return widgetAreas.filter(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}).map(_ref3 => {
|
|
111
|
-
let {
|
|
112
|
-
id
|
|
113
|
-
} = _ref3;
|
|
114
|
-
return select(coreStore).getEditedEntityRecord(KIND, WIDGET_AREA_ENTITY_TYPE, id);
|
|
115
|
-
});
|
|
102
|
+
return widgetAreas.filter(({
|
|
103
|
+
id
|
|
104
|
+
}) => select(coreStore).hasEditsForEntityRecord(KIND, POST_TYPE, buildWidgetAreaPostId(id))).map(({
|
|
105
|
+
id
|
|
106
|
+
}) => select(coreStore).getEditedEntityRecord(KIND, WIDGET_AREA_ENTITY_TYPE, id));
|
|
116
107
|
});
|
|
117
108
|
/**
|
|
118
109
|
* Returns all blocks representing reference widgets.
|
|
@@ -121,8 +112,7 @@ export const getEditedWidgetAreas = createRegistrySelector(select => (state, ids
|
|
|
121
112
|
* @return {Array} List of all blocks representing reference widgets
|
|
122
113
|
*/
|
|
123
114
|
|
|
124
|
-
export const getReferenceWidgetBlocks = createRegistrySelector(select =>
|
|
125
|
-
let referenceWidgetName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
115
|
+
export const getReferenceWidgetBlocks = createRegistrySelector(select => (state, referenceWidgetName = null) => {
|
|
126
116
|
const results = [];
|
|
127
117
|
const widgetAreas = select(editWidgetsStoreName).getWidgetAreas();
|
|
128
118
|
|
|
@@ -130,9 +120,7 @@ export const getReferenceWidgetBlocks = createRegistrySelector(select => functio
|
|
|
130
120
|
const post = select(coreStore).getEditedEntityRecord(KIND, POST_TYPE, buildWidgetAreaPostId(_widgetArea.id));
|
|
131
121
|
|
|
132
122
|
for (const block of post.blocks) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (block.name === 'core/legacy-widget' && (!referenceWidgetName || ((_block$attributes = block.attributes) === null || _block$attributes === void 0 ? void 0 : _block$attributes.referenceWidgetName) === referenceWidgetName)) {
|
|
123
|
+
if (block.name === 'core/legacy-widget' && (!referenceWidgetName || block.attributes?.referenceWidgetName === referenceWidgetName)) {
|
|
136
124
|
results.push(block);
|
|
137
125
|
}
|
|
138
126
|
}
|
|
@@ -147,14 +135,9 @@ export const getReferenceWidgetBlocks = createRegistrySelector(select => functio
|
|
|
147
135
|
*/
|
|
148
136
|
|
|
149
137
|
export const isSavingWidgetAreas = createRegistrySelector(select => () => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
let {
|
|
154
|
-
id
|
|
155
|
-
} = _ref4;
|
|
156
|
-
return id;
|
|
157
|
-
});
|
|
138
|
+
const widgetAreasIds = select(editWidgetsStoreName).getWidgetAreas()?.map(({
|
|
139
|
+
id
|
|
140
|
+
}) => id);
|
|
158
141
|
|
|
159
142
|
if (!widgetAreasIds) {
|
|
160
143
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-widgets/src/store/selectors.js"],"names":["createRegistrySelector","getWidgetIdFromBlock","store","coreStore","blockEditorStore","buildWidgetsQuery","buildWidgetAreasQuery","buildWidgetAreaPostId","KIND","POST_TYPE","WIDGET_AREA_ENTITY_TYPE","STORE_NAME","editWidgetsStoreName","getWidgets","select","widgets","getEntityRecords","reduce","allWidgets","widget","id","getWidget","state","getWidgetAreas","query","getWidgetAreaForWidgetId","widgetId","widgetAreas","find","widgetArea","post","getEditedEntityRecord","blockWidgetIds","blocks","map","block","includes","getParentWidgetAreaBlock","clientId","getBlock","getBlockName","getBlockParents","blockParents","widgetAreaClientId","parentClientId","getEditedWidgetAreas","ids","filter","hasEditsForEntityRecord","getReferenceWidgetBlocks","referenceWidgetName","results","_widgetArea","name","attributes","push","isSavingWidgetAreas","widgetAreasIds","isSaving","isSavingEntityRecord","widgetIds","Object","keys","undefined","getIsWidgetAreaOpen","widgetAreasOpenState","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","canInsertBlockInWidgetArea","blockName","getBlocks","firstWidgetArea","canInsertBlockType","isListViewOpened","listViewPanel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAT,QAAuC,iBAAvC;AACA,SAASC,oBAAT,QAAqC,oBAArC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,SACCC,iBADD,EAECC,qBAFD,EAGCC,qBAHD,EAICC,IAJD,EAKCC,SALD,EAMCC,uBAND,QAOO,SAPP;AAQA,SAASC,UAAU,IAAIC,oBAAvB,QAAmD,aAAnD;AAEA;AACA;AACA;AACA;A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ACA,OAAO,SAAS4B,gBAAT,CAA2B5C,KAA3B,EAAmC;AACzC,SAAO,CAAC,CAAEA,KAAK,CAAC6C,kBAAhB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,+BAAT,CAA0C9C,KAA1C,EAAkD;AACxD,QAAM;AAAE+C,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAmChD,KAAK,CAAC6C,kBAA/C;AACA,SAAO;AAAEE,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,0BAA0B,GAAGvE,sBAAsB,CAC7Dc,MAAF,IAAc,CAAEQ,KAAF,EAASkD,SAAT,KAAwB;AACrC;AACA,QAAM7C,WAAW,GAAGb,MAAM,CAAEV,gBAAF,CAAN,CAA2BqE,SAA3B,EAApB,CAFqC,CAIrC;AACA;AACA;;AACA,QAAM,CAAEC,eAAF,IAAsB/C,WAA5B;AACA,SAAOb,MAAM,CAAEV,gBAAF,CAAN,CAA2BuE,kBAA3B,CACNH,SADM,EAENE,eAAe,CAACpC,QAFV,CAAP;AAIA,CAb8D,CAAzD;AAgBP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASsC,gBAAT,CAA2BtD,KAA3B,EAAmC;AACzC,SAAOA,KAAK,CAACuD,aAAb;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { 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\n/**\n * Returns all API widgets.\n *\n * @return {Object[]} API List of widgets.\n */\nexport const getWidgets = createRegistrySelector( ( select ) => () => {\n\tconst widgets = select( coreStore ).getEntityRecords(\n\t\t'root',\n\t\t'widget',\n\t\tbuildWidgetsQuery()\n\t);\n\n\treturn (\n\t\t// Key widgets by their ID.\n\t\twidgets?.reduce(\n\t\t\t( allWidgets, widget ) => ( {\n\t\t\t\t...allWidgets,\n\t\t\t\t[ widget.id ]: widget,\n\t\t\t} ),\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\tconst { rootClientId, insertionIndex } = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex };\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"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-widgets/src/store/selectors.js"],"names":["createRegistrySelector","getWidgetIdFromBlock","store","coreStore","blockEditorStore","buildWidgetsQuery","buildWidgetAreasQuery","buildWidgetAreaPostId","KIND","POST_TYPE","WIDGET_AREA_ENTITY_TYPE","STORE_NAME","editWidgetsStoreName","getWidgets","select","widgets","getEntityRecords","reduce","allWidgets","widget","id","getWidget","state","getWidgetAreas","query","getWidgetAreaForWidgetId","widgetId","widgetAreas","find","widgetArea","post","getEditedEntityRecord","blockWidgetIds","blocks","map","block","includes","getParentWidgetAreaBlock","clientId","getBlock","getBlockName","getBlockParents","blockParents","widgetAreaClientId","parentClientId","getEditedWidgetAreas","ids","filter","hasEditsForEntityRecord","getReferenceWidgetBlocks","referenceWidgetName","results","_widgetArea","name","attributes","push","isSavingWidgetAreas","widgetAreasIds","isSaving","isSavingEntityRecord","widgetIds","Object","keys","undefined","getIsWidgetAreaOpen","widgetAreasOpenState","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","canInsertBlockInWidgetArea","blockName","getBlocks","firstWidgetArea","canInsertBlockType","isListViewOpened","listViewPanel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAT,QAAuC,iBAAvC;AACA,SAASC,oBAAT,QAAqC,oBAArC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,SACCC,iBADD,EAECC,qBAFD,EAGCC,qBAHD,EAICC,IAJD,EAKCC,SALD,EAMCC,uBAND,QAOO,SAPP;AAQA,SAASC,UAAU,IAAIC,oBAAvB,QAAmD,aAAnD;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,UAAU,GAAGb,sBAAsB,CAAIc,MAAF,IAAc,MAAM;AACrE,QAAMC,OAAO,GAAGD,MAAM,CAAEX,SAAF,CAAN,CAAoBa,gBAApB,CACf,MADe,EAEf,QAFe,EAGfX,iBAAiB,EAHF,CAAhB;AAMA,SACC;AACAU,IAAAA,OAAO,EAAEE,MAAT,CACC,CAAEC,UAAF,EAAcC,MAAd,MAA4B,EAC3B,GAAGD,UADwB;AAE3B,OAAEC,MAAM,CA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AM7C,WAAW,GAAGb,MAAM,CAAEV,gBAAF,CAAN,CAA2BqE,SAA3B,EAApB,CAFqC,CAIrC;AACA;AACA;;AACA,QAAM,CAAEC,eAAF,IAAsB/C,WAA5B;AACA,SAAOb,MAAM,CAAEV,gBAAF,CAAN,CAA2BuE,kBAA3B,CACNH,SADM,EAENE,eAAe,CAACpC,QAFV,CAAP;AAIA,CAb8D,CAAzD;AAgBP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASsC,gBAAT,CAA2BtD,KAA3B,EAAmC;AACzC,SAAOA,KAAK,CAACuD,aAAb;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { 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\n/**\n * Returns all API widgets.\n *\n * @return {Object[]} API List of widgets.\n */\nexport const getWidgets = createRegistrySelector( ( select ) => () => {\n\tconst widgets = select( coreStore ).getEntityRecords(\n\t\t'root',\n\t\t'widget',\n\t\tbuildWidgetsQuery()\n\t);\n\n\treturn (\n\t\t// Key widgets by their ID.\n\t\twidgets?.reduce(\n\t\t\t( allWidgets, widget ) => ( {\n\t\t\t\t...allWidgets,\n\t\t\t\t[ widget.id ]: widget,\n\t\t\t} ),\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\tconst { rootClientId, insertionIndex } = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex };\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"]}
|
|
@@ -46,8 +46,7 @@ export function transformWidgetToBlock(widget) {
|
|
|
46
46
|
* @return {Object} the widget object (converted from block).
|
|
47
47
|
*/
|
|
48
48
|
|
|
49
|
-
export function transformBlockToWidget(block) {
|
|
50
|
-
let relatedWidget = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
49
|
+
export function transformBlockToWidget(block, relatedWidget = {}) {
|
|
51
50
|
let widget;
|
|
52
51
|
const isValidLegacyWidgetBlock = block.name === 'core/legacy-widget' && (block.attributes.id || block.attributes.instance);
|
|
53
52
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-widgets/src/store/transformers.js"],"names":["createBlock","parse","serialize","addWidgetIdToBlock","transformWidgetToBlock","widget","id_base","parsedBlocks","instance","raw","content","__unstableSkipAutop","length","id","attributes","_embedded","about","is_multi","idBase","transformBlockToWidget","block","relatedWidget","isValidLegacyWidgetBlock","name","rendered","rendered_form"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,KAAtB,EAA6BC,SAA7B,QAA8C,mBAA9C;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,sBAAT,CAAiCC,MAAjC,EAA0C;AAChD,MAAKA,MAAM,CAACC,OAAP,KAAmB,OAAxB,EAAkC;AACjC,UAAMC,YAAY,GAAGN,KAAK,CAAEI,MAAM,CAACG,QAAP,CAAgBC,GAAhB,CAAoBC,OAAtB,EAA+B;AACxDC,MAAAA,mBAAmB,EAAE;AADmC,KAA/B,CAA1B;;AAGA,QAAK,CAAEJ,YAAY,CAACK,MAApB,EAA6B;AAC5B,aAAOT,kBAAkB,CACxBH,WAAW,CAAE,gBAAF,EAAoB,EAApB,EAAwB,EAAxB,CADa,EAExBK,MAAM,CAACQ,EAFiB,CAAzB;AAIA;;AACD,WAAOV,kBAAkB,CAAEI,YAAY,CAAE,CAAF,CAAd,EAAqBF,MAAM,CAACQ,EAA5B,CAAzB;AACA;;AAED,MAAIC,UAAJ;;AACA,MAAKT,MAAM,CAACU,SAAP,CAAiBC,KAAjB,CAAwB,CAAxB,EAA4BC,QAAjC,EAA4C;AAC3CH,IAAAA,UAAU,GAAG;AACZI,MAAAA,MAAM,EAAEb,MAAM,CAACC,OADH;AAEZE,MAAAA,QAAQ,EAAEH,MAAM,CAACG;AAFL,KAAb;AAIA,GALD,MAKO;AACNM,IAAAA,UAAU,GAAG;AACZD,MAAAA,EAAE,EAAER,MAAM,CAACQ;AADC,KAAb;AAGA;;AAED,SAAOV,kBAAkB,CACxBH,WAAW,CAAE,oBAAF,EAAwBc,UAAxB,EAAoC,EAApC,CADa,EAExBT,MAAM,CAACQ,EAFiB,CAAzB;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASM,sBAAT,CAAiCC,KAAjC,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-widgets/src/store/transformers.js"],"names":["createBlock","parse","serialize","addWidgetIdToBlock","transformWidgetToBlock","widget","id_base","parsedBlocks","instance","raw","content","__unstableSkipAutop","length","id","attributes","_embedded","about","is_multi","idBase","transformBlockToWidget","block","relatedWidget","isValidLegacyWidgetBlock","name","rendered","rendered_form"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,KAAtB,EAA6BC,SAA7B,QAA8C,mBAA9C;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,sBAAT,CAAiCC,MAAjC,EAA0C;AAChD,MAAKA,MAAM,CAACC,OAAP,KAAmB,OAAxB,EAAkC;AACjC,UAAMC,YAAY,GAAGN,KAAK,CAAEI,MAAM,CAACG,QAAP,CAAgBC,GAAhB,CAAoBC,OAAtB,EAA+B;AACxDC,MAAAA,mBAAmB,EAAE;AADmC,KAA/B,CAA1B;;AAGA,QAAK,CAAEJ,YAAY,CAACK,MAApB,EAA6B;AAC5B,aAAOT,kBAAkB,CACxBH,WAAW,CAAE,gBAAF,EAAoB,EAApB,EAAwB,EAAxB,CADa,EAExBK,MAAM,CAACQ,EAFiB,CAAzB;AAIA;;AACD,WAAOV,kBAAkB,CAAEI,YAAY,CAAE,CAAF,CAAd,EAAqBF,MAAM,CAACQ,EAA5B,CAAzB;AACA;;AAED,MAAIC,UAAJ;;AACA,MAAKT,MAAM,CAACU,SAAP,CAAiBC,KAAjB,CAAwB,CAAxB,EAA4BC,QAAjC,EAA4C;AAC3CH,IAAAA,UAAU,GAAG;AACZI,MAAAA,MAAM,EAAEb,MAAM,CAACC,OADH;AAEZE,MAAAA,QAAQ,EAAEH,MAAM,CAACG;AAFL,KAAb;AAIA,GALD,MAKO;AACNM,IAAAA,UAAU,GAAG;AACZD,MAAAA,EAAE,EAAER,MAAM,CAACQ;AADC,KAAb;AAGA;;AAED,SAAOV,kBAAkB,CACxBH,WAAW,CAAE,oBAAF,EAAwBc,UAAxB,EAAoC,EAApC,CADa,EAExBT,MAAM,CAACQ,EAFiB,CAAzB;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASM,sBAAT,CAAiCC,KAAjC,EAAwCC,aAAa,GAAG,EAAxD,EAA6D;AACnE,MAAIhB,MAAJ;AAEA,QAAMiB,wBAAwB,GAC7BF,KAAK,CAACG,IAAN,KAAe,oBAAf,KACEH,KAAK,CAACN,UAAN,CAAiBD,EAAjB,IAAuBO,KAAK,CAACN,UAAN,CAAiBN,QAD1C,CADD;;AAIA,MAAKc,wBAAL,EAAgC;AAAA;;AAC/BjB,IAAAA,MAAM,GAAG,EACR,GAAGgB,aADK;AAERR,MAAAA,EAAE,0BAAEO,KAAK,CAACN,UAAN,CAAiBD,EAAnB,uEAAyBQ,aAAa,CAACR,EAFjC;AAGRP,MAAAA,OAAO,2BAAEc,KAAK,CAACN,UAAN,CAAiBI,MAAnB,yEAA6BG,aAAa,CAACf,OAH1C;AAIRE,MAAAA,QAAQ,2BAAEY,KAAK,CAACN,UAAN,CAAiBN,QAAnB,yEAA+Ba,aAAa,CAACb;AAJ7C,KAAT;AAMA,GAPD,MAOO;AACNH,IAAAA,MAAM,GAAG,EACR,GAAGgB,aADK;AAERf,MAAAA,OAAO,EAAE,OAFD;AAGRE,MAAAA,QAAQ,EAAE;AACTC,QAAAA,GAAG,EAAE;AACJC,UAAAA,OAAO,EAAER,SAAS,CAAEkB,KAAF;AADd;AADI;AAHF,KAAT;AASA,GAxBkE,CA0BnE;;;AACA,SAAOf,MAAM,CAACmB,QAAd;AACA,SAAOnB,MAAM,CAACoB,aAAd;AAEA,SAAOpB,MAAP;AACA","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"]}
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
--wp-block-synced-color: #7a00df;
|
|
98
98
|
--wp-block-synced-color--rgb: 122, 0, 223;
|
|
99
99
|
}
|
|
100
|
-
@media (
|
|
100
|
+
@media (min-resolution: 192dpi) {
|
|
101
101
|
:root {
|
|
102
102
|
--wp-admin-border-width-focus: 1.5px;
|
|
103
103
|
}
|
|
@@ -958,8 +958,7 @@ body.is-fullscreen-mode .edit-widgets-notices__snackbar {
|
|
|
958
958
|
.edit-widgets-welcome-guide__image > img {
|
|
959
959
|
display: block;
|
|
960
960
|
max-width: 100%;
|
|
961
|
-
|
|
962
|
-
object-fit: cover;
|
|
961
|
+
object-fit: cover;
|
|
963
962
|
}
|
|
964
963
|
.edit-widgets-welcome-guide__heading {
|
|
965
964
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
@@ -1124,7 +1123,7 @@ body.admin-color-light {
|
|
|
1124
1123
|
--wp-admin-theme-color-darker-20--rgb: 0, 97, 135;
|
|
1125
1124
|
--wp-admin-border-width-focus: 2px;
|
|
1126
1125
|
}
|
|
1127
|
-
@media (
|
|
1126
|
+
@media (min-resolution: 192dpi) {
|
|
1128
1127
|
body.admin-color-light {
|
|
1129
1128
|
--wp-admin-border-width-focus: 1.5px;
|
|
1130
1129
|
}
|
|
@@ -1139,7 +1138,7 @@ body.admin-color-modern {
|
|
|
1139
1138
|
--wp-admin-theme-color-darker-20--rgb: 24, 58, 214;
|
|
1140
1139
|
--wp-admin-border-width-focus: 2px;
|
|
1141
1140
|
}
|
|
1142
|
-
@media (
|
|
1141
|
+
@media (min-resolution: 192dpi) {
|
|
1143
1142
|
body.admin-color-modern {
|
|
1144
1143
|
--wp-admin-border-width-focus: 1.5px;
|
|
1145
1144
|
}
|
|
@@ -1154,7 +1153,7 @@ body.admin-color-blue {
|
|
|
1154
1153
|
--wp-admin-theme-color-darker-20--rgb: 6, 64, 84;
|
|
1155
1154
|
--wp-admin-border-width-focus: 2px;
|
|
1156
1155
|
}
|
|
1157
|
-
@media (
|
|
1156
|
+
@media (min-resolution: 192dpi) {
|
|
1158
1157
|
body.admin-color-blue {
|
|
1159
1158
|
--wp-admin-border-width-focus: 1.5px;
|
|
1160
1159
|
}
|
|
@@ -1169,7 +1168,7 @@ body.admin-color-coffee {
|
|
|
1169
1168
|
--wp-admin-theme-color-darker-20--rgb: 43, 39, 36;
|
|
1170
1169
|
--wp-admin-border-width-focus: 2px;
|
|
1171
1170
|
}
|
|
1172
|
-
@media (
|
|
1171
|
+
@media (min-resolution: 192dpi) {
|
|
1173
1172
|
body.admin-color-coffee {
|
|
1174
1173
|
--wp-admin-border-width-focus: 1.5px;
|
|
1175
1174
|
}
|
|
@@ -1184,7 +1183,7 @@ body.admin-color-ectoplasm {
|
|
|
1184
1183
|
--wp-admin-theme-color-darker-20--rgb: 58, 44, 77;
|
|
1185
1184
|
--wp-admin-border-width-focus: 2px;
|
|
1186
1185
|
}
|
|
1187
|
-
@media (
|
|
1186
|
+
@media (min-resolution: 192dpi) {
|
|
1188
1187
|
body.admin-color-ectoplasm {
|
|
1189
1188
|
--wp-admin-border-width-focus: 1.5px;
|
|
1190
1189
|
}
|
|
@@ -1199,7 +1198,7 @@ body.admin-color-midnight {
|
|
|
1199
1198
|
--wp-admin-theme-color-darker-20--rgb: 208, 44, 33;
|
|
1200
1199
|
--wp-admin-border-width-focus: 2px;
|
|
1201
1200
|
}
|
|
1202
|
-
@media (
|
|
1201
|
+
@media (min-resolution: 192dpi) {
|
|
1203
1202
|
body.admin-color-midnight {
|
|
1204
1203
|
--wp-admin-border-width-focus: 1.5px;
|
|
1205
1204
|
}
|
|
@@ -1214,7 +1213,7 @@ body.admin-color-ocean {
|
|
|
1214
1213
|
--wp-admin-theme-color-darker-20--rgb: 76, 96, 102;
|
|
1215
1214
|
--wp-admin-border-width-focus: 2px;
|
|
1216
1215
|
}
|
|
1217
|
-
@media (
|
|
1216
|
+
@media (min-resolution: 192dpi) {
|
|
1218
1217
|
body.admin-color-ocean {
|
|
1219
1218
|
--wp-admin-border-width-focus: 1.5px;
|
|
1220
1219
|
}
|
|
@@ -1229,7 +1228,7 @@ body.admin-color-sunrise {
|
|
|
1229
1228
|
--wp-admin-theme-color-darker-20--rgb: 195, 105, 34;
|
|
1230
1229
|
--wp-admin-border-width-focus: 2px;
|
|
1231
1230
|
}
|
|
1232
|
-
@media (
|
|
1231
|
+
@media (min-resolution: 192dpi) {
|
|
1233
1232
|
body.admin-color-sunrise {
|
|
1234
1233
|
--wp-admin-border-width-focus: 1.5px;
|
|
1235
1234
|
}
|
package/build-style/style.css
CHANGED
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
--wp-block-synced-color: #7a00df;
|
|
98
98
|
--wp-block-synced-color--rgb: 122, 0, 223;
|
|
99
99
|
}
|
|
100
|
-
@media (
|
|
100
|
+
@media (min-resolution: 192dpi) {
|
|
101
101
|
:root {
|
|
102
102
|
--wp-admin-border-width-focus: 1.5px;
|
|
103
103
|
}
|
|
@@ -958,8 +958,7 @@ body.is-fullscreen-mode .edit-widgets-notices__snackbar {
|
|
|
958
958
|
.edit-widgets-welcome-guide__image > img {
|
|
959
959
|
display: block;
|
|
960
960
|
max-width: 100%;
|
|
961
|
-
|
|
962
|
-
object-fit: cover;
|
|
961
|
+
object-fit: cover;
|
|
963
962
|
}
|
|
964
963
|
.edit-widgets-welcome-guide__heading {
|
|
965
964
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
@@ -1124,7 +1123,7 @@ body.admin-color-light {
|
|
|
1124
1123
|
--wp-admin-theme-color-darker-20--rgb: 0, 97, 135;
|
|
1125
1124
|
--wp-admin-border-width-focus: 2px;
|
|
1126
1125
|
}
|
|
1127
|
-
@media (
|
|
1126
|
+
@media (min-resolution: 192dpi) {
|
|
1128
1127
|
body.admin-color-light {
|
|
1129
1128
|
--wp-admin-border-width-focus: 1.5px;
|
|
1130
1129
|
}
|
|
@@ -1139,7 +1138,7 @@ body.admin-color-modern {
|
|
|
1139
1138
|
--wp-admin-theme-color-darker-20--rgb: 24, 58, 214;
|
|
1140
1139
|
--wp-admin-border-width-focus: 2px;
|
|
1141
1140
|
}
|
|
1142
|
-
@media (
|
|
1141
|
+
@media (min-resolution: 192dpi) {
|
|
1143
1142
|
body.admin-color-modern {
|
|
1144
1143
|
--wp-admin-border-width-focus: 1.5px;
|
|
1145
1144
|
}
|
|
@@ -1154,7 +1153,7 @@ body.admin-color-blue {
|
|
|
1154
1153
|
--wp-admin-theme-color-darker-20--rgb: 6, 64, 84;
|
|
1155
1154
|
--wp-admin-border-width-focus: 2px;
|
|
1156
1155
|
}
|
|
1157
|
-
@media (
|
|
1156
|
+
@media (min-resolution: 192dpi) {
|
|
1158
1157
|
body.admin-color-blue {
|
|
1159
1158
|
--wp-admin-border-width-focus: 1.5px;
|
|
1160
1159
|
}
|
|
@@ -1169,7 +1168,7 @@ body.admin-color-coffee {
|
|
|
1169
1168
|
--wp-admin-theme-color-darker-20--rgb: 43, 39, 36;
|
|
1170
1169
|
--wp-admin-border-width-focus: 2px;
|
|
1171
1170
|
}
|
|
1172
|
-
@media (
|
|
1171
|
+
@media (min-resolution: 192dpi) {
|
|
1173
1172
|
body.admin-color-coffee {
|
|
1174
1173
|
--wp-admin-border-width-focus: 1.5px;
|
|
1175
1174
|
}
|
|
@@ -1184,7 +1183,7 @@ body.admin-color-ectoplasm {
|
|
|
1184
1183
|
--wp-admin-theme-color-darker-20--rgb: 58, 44, 77;
|
|
1185
1184
|
--wp-admin-border-width-focus: 2px;
|
|
1186
1185
|
}
|
|
1187
|
-
@media (
|
|
1186
|
+
@media (min-resolution: 192dpi) {
|
|
1188
1187
|
body.admin-color-ectoplasm {
|
|
1189
1188
|
--wp-admin-border-width-focus: 1.5px;
|
|
1190
1189
|
}
|
|
@@ -1199,7 +1198,7 @@ body.admin-color-midnight {
|
|
|
1199
1198
|
--wp-admin-theme-color-darker-20--rgb: 208, 44, 33;
|
|
1200
1199
|
--wp-admin-border-width-focus: 2px;
|
|
1201
1200
|
}
|
|
1202
|
-
@media (
|
|
1201
|
+
@media (min-resolution: 192dpi) {
|
|
1203
1202
|
body.admin-color-midnight {
|
|
1204
1203
|
--wp-admin-border-width-focus: 1.5px;
|
|
1205
1204
|
}
|
|
@@ -1214,7 +1213,7 @@ body.admin-color-ocean {
|
|
|
1214
1213
|
--wp-admin-theme-color-darker-20--rgb: 76, 96, 102;
|
|
1215
1214
|
--wp-admin-border-width-focus: 2px;
|
|
1216
1215
|
}
|
|
1217
|
-
@media (
|
|
1216
|
+
@media (min-resolution: 192dpi) {
|
|
1218
1217
|
body.admin-color-ocean {
|
|
1219
1218
|
--wp-admin-border-width-focus: 1.5px;
|
|
1220
1219
|
}
|
|
@@ -1229,7 +1228,7 @@ body.admin-color-sunrise {
|
|
|
1229
1228
|
--wp-admin-theme-color-darker-20--rgb: 195, 105, 34;
|
|
1230
1229
|
--wp-admin-border-width-focus: 2px;
|
|
1231
1230
|
}
|
|
1232
|
-
@media (
|
|
1231
|
+
@media (min-resolution: 192dpi) {
|
|
1233
1232
|
body.admin-color-sunrise {
|
|
1234
1233
|
--wp-admin-border-width-focus: 1.5px;
|
|
1235
1234
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-widgets",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.12.0",
|
|
4
4
|
"description": "Widgets Page module for WordPress..",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,31 +27,31 @@
|
|
|
27
27
|
"react-native": "src/index",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
|
-
"@wordpress/api-fetch": "^6.
|
|
31
|
-
"@wordpress/block-editor": "^12.
|
|
32
|
-
"@wordpress/block-library": "^8.
|
|
33
|
-
"@wordpress/blocks": "^12.
|
|
34
|
-
"@wordpress/components": "^
|
|
35
|
-
"@wordpress/compose": "^6.
|
|
36
|
-
"@wordpress/core-data": "^6.
|
|
37
|
-
"@wordpress/data": "^9.
|
|
38
|
-
"@wordpress/deprecated": "^3.
|
|
39
|
-
"@wordpress/dom": "^3.
|
|
40
|
-
"@wordpress/element": "^5.
|
|
41
|
-
"@wordpress/hooks": "^3.
|
|
42
|
-
"@wordpress/i18n": "^4.
|
|
43
|
-
"@wordpress/icons": "^9.
|
|
44
|
-
"@wordpress/interface": "^5.
|
|
45
|
-
"@wordpress/keyboard-shortcuts": "^4.
|
|
46
|
-
"@wordpress/keycodes": "^3.
|
|
47
|
-
"@wordpress/media-utils": "^4.
|
|
48
|
-
"@wordpress/notices": "^4.
|
|
49
|
-
"@wordpress/plugins": "^6.
|
|
50
|
-
"@wordpress/preferences": "^3.
|
|
51
|
-
"@wordpress/private-apis": "^0.
|
|
52
|
-
"@wordpress/reusable-blocks": "^4.
|
|
53
|
-
"@wordpress/url": "^3.
|
|
54
|
-
"@wordpress/widgets": "^3.
|
|
30
|
+
"@wordpress/api-fetch": "^6.32.0",
|
|
31
|
+
"@wordpress/block-editor": "^12.3.0",
|
|
32
|
+
"@wordpress/block-library": "^8.12.0",
|
|
33
|
+
"@wordpress/blocks": "^12.12.0",
|
|
34
|
+
"@wordpress/components": "^25.1.0",
|
|
35
|
+
"@wordpress/compose": "^6.12.0",
|
|
36
|
+
"@wordpress/core-data": "^6.12.0",
|
|
37
|
+
"@wordpress/data": "^9.5.0",
|
|
38
|
+
"@wordpress/deprecated": "^3.35.0",
|
|
39
|
+
"@wordpress/dom": "^3.35.0",
|
|
40
|
+
"@wordpress/element": "^5.12.0",
|
|
41
|
+
"@wordpress/hooks": "^3.35.0",
|
|
42
|
+
"@wordpress/i18n": "^4.35.0",
|
|
43
|
+
"@wordpress/icons": "^9.26.0",
|
|
44
|
+
"@wordpress/interface": "^5.12.0",
|
|
45
|
+
"@wordpress/keyboard-shortcuts": "^4.12.0",
|
|
46
|
+
"@wordpress/keycodes": "^3.35.0",
|
|
47
|
+
"@wordpress/media-utils": "^4.26.0",
|
|
48
|
+
"@wordpress/notices": "^4.3.0",
|
|
49
|
+
"@wordpress/plugins": "^6.3.0",
|
|
50
|
+
"@wordpress/preferences": "^3.12.0",
|
|
51
|
+
"@wordpress/private-apis": "^0.17.0",
|
|
52
|
+
"@wordpress/reusable-blocks": "^4.12.0",
|
|
53
|
+
"@wordpress/url": "^3.36.0",
|
|
54
|
+
"@wordpress/widgets": "^3.12.0",
|
|
55
55
|
"classnames": "^2.3.1"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "a92f606309b1541b834ff9b0a76ed2a466fc45ed"
|
|
65
65
|
}
|
|
@@ -25,6 +25,8 @@ import useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area
|
|
|
25
25
|
import { store as editWidgetsStore } from '../../store';
|
|
26
26
|
import { unlock } from '../../private-apis';
|
|
27
27
|
|
|
28
|
+
const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );
|
|
29
|
+
|
|
28
30
|
function Header() {
|
|
29
31
|
const isMediumViewport = useViewportMatch( 'medium' );
|
|
30
32
|
const inserterButton = useRef();
|
|
@@ -72,7 +74,6 @@ function Header() {
|
|
|
72
74
|
[ setIsListViewOpened, isListViewOpen ]
|
|
73
75
|
);
|
|
74
76
|
|
|
75
|
-
const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );
|
|
76
77
|
const {
|
|
77
78
|
shouldShowContextualToolbar,
|
|
78
79
|
canFocusHiddenToolbar,
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
useMergeRefs,
|
|
10
10
|
} from '@wordpress/compose';
|
|
11
11
|
import { useDispatch } from '@wordpress/data';
|
|
12
|
+
import { useState } from '@wordpress/element';
|
|
12
13
|
import { __ } from '@wordpress/i18n';
|
|
13
14
|
import { closeSmall } from '@wordpress/icons';
|
|
14
15
|
import { ESCAPE } from '@wordpress/keycodes';
|
|
@@ -21,9 +22,14 @@ import { store as editWidgetsStore } from '../../store';
|
|
|
21
22
|
export default function ListViewSidebar() {
|
|
22
23
|
const { setIsListViewOpened } = useDispatch( editWidgetsStore );
|
|
23
24
|
|
|
25
|
+
// Use internal state instead of a ref to make sure that the component
|
|
26
|
+
// re-renders when the dropZoneElement updates.
|
|
27
|
+
const [ dropZoneElement, setDropZoneElement ] = useState( null );
|
|
28
|
+
|
|
24
29
|
const focusOnMountRef = useFocusOnMount( 'firstElement' );
|
|
25
30
|
const headerFocusReturnRef = useFocusReturn();
|
|
26
31
|
const contentFocusReturnRef = useFocusReturn();
|
|
32
|
+
|
|
27
33
|
function closeOnEscape( event ) {
|
|
28
34
|
if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
|
|
29
35
|
event.preventDefault();
|
|
@@ -53,9 +59,10 @@ export default function ListViewSidebar() {
|
|
|
53
59
|
ref={ useMergeRefs( [
|
|
54
60
|
contentFocusReturnRef,
|
|
55
61
|
focusOnMountRef,
|
|
62
|
+
setDropZoneElement,
|
|
56
63
|
] ) }
|
|
57
64
|
>
|
|
58
|
-
<ListView />
|
|
65
|
+
<ListView dropZoneElement={ dropZoneElement } />
|
|
59
66
|
</div>
|
|
60
67
|
</div>
|
|
61
68
|
);
|
|
@@ -7,7 +7,7 @@ import classnames from 'classnames';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useEffect, Platform } from '@wordpress/element';
|
|
10
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
10
|
+
import { isRTL, __, sprintf } from '@wordpress/i18n';
|
|
11
11
|
import {
|
|
12
12
|
ComplementaryArea,
|
|
13
13
|
store as interfaceStore,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
store as blockEditorStore,
|
|
18
18
|
} from '@wordpress/block-editor';
|
|
19
19
|
|
|
20
|
-
import {
|
|
20
|
+
import { drawerLeft, drawerRight } from '@wordpress/icons';
|
|
21
21
|
import { Button } from '@wordpress/components';
|
|
22
22
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
23
23
|
|
|
@@ -168,7 +168,7 @@ export default function Sidebar() {
|
|
|
168
168
|
closeLabel={ __( 'Close Settings' ) }
|
|
169
169
|
scope="core/edit-widgets"
|
|
170
170
|
identifier={ currentArea }
|
|
171
|
-
icon={
|
|
171
|
+
icon={ isRTL() ? drawerLeft : drawerRight }
|
|
172
172
|
isActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }
|
|
173
173
|
>
|
|
174
174
|
{ currentArea === WIDGET_AREAS_IDENTIFIER && (
|