@wordpress/edit-widgets 5.16.0 → 5.17.1
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 -16
- package/build/blocks/widget-area/edit/index.js.map +1 -1
- package/build/blocks/widget-area/edit/inner-blocks.js +5 -10
- package/build/blocks/widget-area/edit/inner-blocks.js.map +1 -1
- package/build/blocks/widget-area/edit/use-is-dragging-within.js +5 -10
- package/build/blocks/widget-area/edit/use-is-dragging-within.js.map +1 -1
- package/build/blocks/widget-area/index.js +0 -5
- package/build/blocks/widget-area/index.js.map +1 -1
- package/build/components/error-boundary/index.js +1 -15
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/header/index.js +9 -32
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/undo-redo/redo.js +3 -9
- package/build/components/header/undo-redo/redo.js.map +1 -1
- package/build/components/header/undo-redo/undo.js +3 -9
- package/build/components/header/undo-redo/undo.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +1 -2
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -9
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +4 -20
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +1 -6
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -18
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +2 -19
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/interface.js +5 -21
- package/build/components/layout/interface.js.map +1 -1
- package/build/components/layout/unsaved-changes-warning.js +0 -6
- package/build/components/layout/unsaved-changes-warning.js.map +1 -1
- package/build/components/more-menu/index.js +2 -17
- package/build/components/more-menu/index.js.map +1 -1
- package/build/components/more-menu/tools-more-menu-group.js +1 -5
- package/build/components/more-menu/tools-more-menu-group.js.map +1 -1
- package/build/components/notices/index.js +1 -6
- package/build/components/notices/index.js.map +1 -1
- package/build/components/save-button/index.js +1 -7
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/secondary-sidebar/index.js +1 -10
- package/build/components/secondary-sidebar/index.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +1 -11
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +6 -15
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/index.js +12 -26
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar/widget-areas.js +1 -12
- package/build/components/sidebar/widget-areas.js.map +1 -1
- package/build/components/welcome-guide/index.js +3 -12
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/widget-areas-block-editor-content/index.js +1 -8
- package/build/components/widget-areas-block-editor-content/index.js.map +1 -1
- package/build/components/widget-areas-block-editor-provider/index.js +8 -23
- package/build/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build/constants.js.map +1 -1
- package/build/filters/index.js +0 -1
- package/build/filters/index.js.map +1 -1
- package/build/filters/move-to-widget-area.js +3 -9
- package/build/filters/move-to-widget-area.js.map +1 -1
- package/build/filters/replace-media-upload.js +1 -3
- package/build/filters/replace-media-upload.js.map +1 -1
- package/build/hooks/use-last-selected-widget-area.js +5 -13
- package/build/hooks/use-last-selected-widget-area.js.map +1 -1
- package/build/hooks/use-widget-library-insertion-point.js +6 -14
- package/build/hooks/use-widget-library-insertion-point.js.map +1 -1
- package/build/index.js +6 -34
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +1 -2
- package/build/lock-unlock.js.map +1 -1
- package/build/store/actions.js +41 -79
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +0 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/index.js +4 -15
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +4 -16
- package/build/store/reducer.js.map +1 -1
- package/build/store/resolvers.js +1 -17
- package/build/store/resolvers.js.map +1 -1
- package/build/store/selectors.js +28 -49
- package/build/store/selectors.js.map +1 -1
- package/build/store/transformers.js +7 -16
- package/build/store/transformers.js.map +1 -1
- package/build/store/utils.js +7 -16
- package/build/store/utils.js.map +1 -1
- package/build-module/blocks/widget-area/edit/index.js +5 -8
- package/build-module/blocks/widget-area/edit/index.js.map +1 -1
- package/build-module/blocks/widget-area/edit/inner-blocks.js +6 -6
- package/build-module/blocks/widget-area/edit/inner-blocks.js.map +1 -1
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.js +6 -9
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.js.map +1 -1
- package/build-module/blocks/widget-area/index.js +1 -1
- package/build-module/blocks/widget-area/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +0 -9
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/header/index.js +9 -17
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/undo-redo/redo.js +2 -2
- package/build-module/components/header/undo-redo/redo.js.map +1 -1
- package/build-module/components/header/undo-redo/undo.js +2 -2
- package/build-module/components/header/undo-redo/undo.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -6
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +5 -13
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +0 -5
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -10
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +2 -8
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/interface.js +5 -9
- package/build-module/components/layout/interface.js.map +1 -1
- package/build-module/components/layout/unsaved-changes-warning.js +2 -3
- package/build-module/components/layout/unsaved-changes-warning.js.map +1 -1
- package/build-module/components/more-menu/index.js +2 -6
- package/build-module/components/more-menu/index.js.map +1 -1
- package/build-module/components/more-menu/tools-more-menu-group.js +0 -3
- package/build-module/components/more-menu/tools-more-menu-group.js.map +1 -1
- package/build-module/components/notices/index.js +0 -3
- package/build-module/components/notices/index.js.map +1 -1
- package/build-module/components/save-button/index.js +1 -4
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/index.js +1 -6
- package/build-module/components/secondary-sidebar/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +1 -2
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +6 -7
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/index.js +13 -18
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/widget-areas.js +1 -4
- package/build-module/components/sidebar/widget-areas.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +3 -7
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/widget-areas-block-editor-content/index.js +1 -2
- package/build-module/components/widget-areas-block-editor-content/index.js.map +1 -1
- package/build-module/components/widget-areas-block-editor-provider/index.js +8 -7
- package/build-module/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build-module/constants.js.map +1 -1
- package/build-module/filters/index.js.map +1 -1
- package/build-module/filters/move-to-widget-area.js +4 -4
- package/build-module/filters/move-to-widget-area.js.map +1 -1
- package/build-module/filters/replace-media-upload.js +0 -2
- package/build-module/filters/replace-media-upload.js.map +1 -1
- package/build-module/hooks/use-last-selected-widget-area.js +7 -9
- package/build-module/hooks/use-last-selected-widget-area.js.map +1 -1
- package/build-module/hooks/use-widget-library-insertion-point.js +6 -10
- package/build-module/hooks/use-widget-library-insertion-point.js.map +1 -1
- package/build-module/index.js +8 -20
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/actions.js +43 -56
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/index.js +6 -6
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +5 -11
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/resolvers.js +3 -10
- package/build-module/store/resolvers.js.map +1 -1
- package/build-module/store/selectors.js +29 -38
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/transformers.js +8 -13
- package/build-module/store/transformers.js.map +1 -1
- package/build-module/store/utils.js +7 -7
- package/build-module/store/utils.js.map +1 -1
- package/build-style/style-rtl.css +14 -11
- package/build-style/style.css +14 -11
- package/package.json +28 -27
- package/src/components/keyboard-shortcut-help-modal/style.scss +0 -5
- package/src/components/widget-areas-block-editor-provider/index.js +3 -3
- package/src/index.js +0 -1
- package/src/store/selectors.js +10 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["registerBlockType","unstable__bootstrapServerSideBlockDefinitions","setFreeformContentHandlerName","store","blocksStore","dispatch","deprecated","createRoot","registerCoreBlocks","__experimentalGetCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","registerLegacyWidgetBlock","registerLegacyWidgetVariations","registerWidgetGroupBlock","preferencesStore","widgetArea","Layout","ALLOW_REUSABLE_BLOCKS","ENABLE_EXPERIMENTAL_FSE_BLOCKS","disabledBlocks","initializeEditor","id","settings","target","document","getElementById","root","coreBlocks","filter","block","includes","name","startsWith","setDefaults","fixedToolbar","welcomeGuide","showBlockBreadcrumbs","themeStyles","__experimentalReapplyBlockTypeFilters","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","registerBlock","search","searchOptions","render","createElement","blockEditorSettings","initialize","reinitializeEditor","since","version","metadata"],"sources":["@wordpress/edit-widgets/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tregisterBlockType,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n\tsetFreeformContentHandlerName,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot } from '@wordpress/element';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterLegacyWidgetVariations,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport './store';\nimport './filters';\nimport * as widgetArea from './blocks/widget-area';\n\nimport Layout from './components/layout';\nimport {\n\tALLOW_REUSABLE_BLOCKS,\n\tENABLE_EXPERIMENTAL_FSE_BLOCKS,\n} from './constants';\n\nconst disabledBlocks = [\n\t'core/more',\n\t'core/freeform',\n\t'core/template-part',\n\t...( ALLOW_REUSABLE_BLOCKS ? [] : [ 'core/block' ] ),\n];\n\n/**\n * Initializes the block editor in the widgets screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Block editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter( ( block ) => {\n\t\treturn ! (\n\t\t\tdisabledBlocks.includes( block.name ) ||\n\t\t\tblock.name.startsWith( 'core/post' ) ||\n\t\t\tblock.name.startsWith( 'core/query' ) ||\n\t\t\tblock.name.startsWith( 'core/site' ) ||\n\t\t\tblock.name.startsWith( 'core/navigation' )\n\t\t);\n\t} );\n\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-widgets', {\n\t\tfixedToolbar: false,\n\t\twelcomeGuide: true,\n\t\tshowBlockBreadcrumbs: true,\n\t\tthemeStyles: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tregisterCoreBlocks( coreBlocks );\n\tregisterLegacyWidgetBlock();\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS,\n\t\t} );\n\t}\n\tregisterLegacyWidgetVariations( settings );\n\tregisterBlock( widgetArea );\n\tregisterWidgetGroupBlock();\n\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\n\t// As we are unregistering `core/freeform` to avoid the Classic block, we must\n\t// replace it with something as the default freeform content handler. Failure to\n\t// do this will result in errors in the default block parser.\n\t// see: https://github.com/WordPress/gutenberg/issues/33097\n\tsetFreeformContentHandlerName( 'core/html' );\n\n\troot.render( <Layout blockEditorSettings={ settings } /> );\n\n\treturn root;\n}\n\n/**\n * Compatibility export under the old `initialize` name.\n */\nexport const initialize = initializeEditor;\n\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editWidgets.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\n/**\n * Function to register an individual block.\n *\n * @param {Object} block The block to be registered.\n */\nconst registerBlock = ( block ) => {\n\tif ( ! block ) {\n\t\treturn;\n\t}\n\tconst { metadata, settings, name } = block;\n\tif ( metadata ) {\n\t\tunstable__bootstrapServerSideBlockDefinitions( { [ name ]: metadata } );\n\t}\n\tregisterBlockType( name, settings );\n};\n\nexport { store } from './store';\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,iBAAiB,EACjBC,6CAA6C;AAAE;AAC/CC,6BAA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D;EACA,MAAM;IAAEwB,QAAQ;IAAE/B,QAAQ;IAAES;EAAK,CAAC,GAAGF,KAAK;EAC1C,IAAKwB,QAAQ,EAAG;IACftD,6CAA6C,CAAE;MAAE,CAAEgC,IAAI,GAAIsB;IAAS,CAAE,CAAC;EACxE;EACAvD,iBAAiB,CAAEiC,IAAI,EAAET,QAAS,CAAC;AACpC,CAAC;AAED,SAASrB,KAAK,QAAQ,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"sources":["@wordpress/edit-widgets/src/lock-unlock.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/edit-widgets'\n\t);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAgD,QAAQ,yBAAyB;AAE1F,OAAO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5BF,gDAAgD,CAC/C,8GAA8G,EAC9G,yBACD,CAAC"}
|
|
@@ -7,13 +7,14 @@ import { store as interfaceStore } from '@wordpress/interface';
|
|
|
7
7
|
import { getWidgetIdFromBlock } from '@wordpress/widgets';
|
|
8
8
|
import { store as coreStore } from '@wordpress/core-data';
|
|
9
9
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
10
|
+
|
|
10
11
|
/**
|
|
11
12
|
* Internal dependencies
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
14
|
import { transformBlockToWidget } from './transformers';
|
|
15
15
|
import { buildWidgetAreaPostId, buildWidgetAreasQuery, createStubPost, KIND, POST_TYPE, WIDGET_AREA_ENTITY_TYPE } from './utils';
|
|
16
16
|
import { STORE_NAME as editWidgetsStoreName } from './constants';
|
|
17
|
+
|
|
17
18
|
/**
|
|
18
19
|
* Persists a stub post with given ID to core data store. The post is meant to be in-memory only and
|
|
19
20
|
* shouldn't be saved via the API.
|
|
@@ -22,7 +23,6 @@ import { STORE_NAME as editWidgetsStoreName } from './constants';
|
|
|
22
23
|
* @param {Array} blocks Blocks the post should consist of.
|
|
23
24
|
* @return {Object} The post object.
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
26
|
export const persistStubPost = (id, blocks) => ({
|
|
27
27
|
registry
|
|
28
28
|
}) => {
|
|
@@ -32,6 +32,7 @@ export const persistStubPost = (id, blocks) => ({
|
|
|
32
32
|
}, false);
|
|
33
33
|
return stubPost;
|
|
34
34
|
};
|
|
35
|
+
|
|
35
36
|
/**
|
|
36
37
|
* Converts all the blocks from edited widget areas into widgets,
|
|
37
38
|
* and submits a batch request to save everything at once.
|
|
@@ -40,31 +41,28 @@ export const persistStubPost = (id, blocks) => ({
|
|
|
40
41
|
*
|
|
41
42
|
* @return {Function} An action creator.
|
|
42
43
|
*/
|
|
43
|
-
|
|
44
44
|
export const saveEditedWidgetAreas = () => async ({
|
|
45
45
|
select,
|
|
46
46
|
dispatch,
|
|
47
47
|
registry
|
|
48
48
|
}) => {
|
|
49
49
|
const editedWidgetAreas = select.getEditedWidgetAreas();
|
|
50
|
-
|
|
51
50
|
if (!editedWidgetAreas?.length) {
|
|
52
51
|
return;
|
|
53
52
|
}
|
|
54
|
-
|
|
55
53
|
try {
|
|
56
54
|
await dispatch.saveWidgetAreas(editedWidgetAreas);
|
|
57
55
|
registry.dispatch(noticesStore).createSuccessNotice(__('Widgets saved.'), {
|
|
58
56
|
type: 'snackbar'
|
|
59
57
|
});
|
|
60
58
|
} catch (e) {
|
|
61
|
-
registry.dispatch(noticesStore).createErrorNotice(
|
|
62
|
-
/* translators: %s: The error message. */
|
|
59
|
+
registry.dispatch(noticesStore).createErrorNotice( /* translators: %s: The error message. */
|
|
63
60
|
sprintf(__('There was an error. %s'), e.message), {
|
|
64
61
|
type: 'snackbar'
|
|
65
62
|
});
|
|
66
63
|
}
|
|
67
64
|
};
|
|
65
|
+
|
|
68
66
|
/**
|
|
69
67
|
* Converts all the blocks from specified widget areas into widgets,
|
|
70
68
|
* and submits a batch request to save everything at once.
|
|
@@ -72,7 +70,6 @@ export const saveEditedWidgetAreas = () => async ({
|
|
|
72
70
|
* @param {Object[]} widgetAreas Widget areas to save.
|
|
73
71
|
* @return {Function} An action creator.
|
|
74
72
|
*/
|
|
75
|
-
|
|
76
73
|
export const saveWidgetAreas = widgetAreas => async ({
|
|
77
74
|
dispatch,
|
|
78
75
|
registry
|
|
@@ -86,6 +83,7 @@ export const saveWidgetAreas = widgetAreas => async ({
|
|
|
86
83
|
await registry.dispatch(coreStore).finishResolution('getEntityRecord', KIND, WIDGET_AREA_ENTITY_TYPE, buildWidgetAreasQuery());
|
|
87
84
|
}
|
|
88
85
|
};
|
|
86
|
+
|
|
89
87
|
/**
|
|
90
88
|
* Converts all the blocks from a widget area specified by ID into widgets,
|
|
91
89
|
* and submits a batch request to save everything at once.
|
|
@@ -93,78 +91,74 @@ export const saveWidgetAreas = widgetAreas => async ({
|
|
|
93
91
|
* @param {string} widgetAreaId ID of the widget area to process.
|
|
94
92
|
* @return {Function} An action creator.
|
|
95
93
|
*/
|
|
96
|
-
|
|
97
94
|
export const saveWidgetArea = widgetAreaId => async ({
|
|
98
95
|
dispatch,
|
|
99
96
|
select,
|
|
100
97
|
registry
|
|
101
98
|
}) => {
|
|
102
99
|
const widgets = select.getWidgets();
|
|
103
|
-
const post = registry.select(coreStore).getEditedEntityRecord(KIND, POST_TYPE, buildWidgetAreaPostId(widgetAreaId));
|
|
100
|
+
const post = registry.select(coreStore).getEditedEntityRecord(KIND, POST_TYPE, buildWidgetAreaPostId(widgetAreaId));
|
|
104
101
|
|
|
102
|
+
// Get all widgets from this area
|
|
105
103
|
const areaWidgets = Object.values(widgets).filter(({
|
|
106
104
|
sidebar
|
|
107
|
-
}) => sidebar === widgetAreaId);
|
|
105
|
+
}) => sidebar === widgetAreaId);
|
|
106
|
+
|
|
107
|
+
// Remove all duplicate reference widget instances for legacy widgets.
|
|
108
108
|
// Why? We filter out the widgets with duplicate IDs to prevent adding more than one instance of a widget
|
|
109
109
|
// implemented using a function. WordPress doesn't support having more than one instance of these, if you try to
|
|
110
110
|
// save multiple instances of these in different sidebars you will run into undefined behaviors.
|
|
111
|
-
|
|
112
111
|
const usedReferenceWidgets = [];
|
|
113
112
|
const widgetsBlocks = post.blocks.filter(block => {
|
|
114
113
|
const {
|
|
115
114
|
id
|
|
116
115
|
} = block.attributes;
|
|
117
|
-
|
|
118
116
|
if (block.name === 'core/legacy-widget' && id) {
|
|
119
117
|
if (usedReferenceWidgets.includes(id)) {
|
|
120
118
|
return false;
|
|
121
119
|
}
|
|
122
|
-
|
|
123
120
|
usedReferenceWidgets.push(id);
|
|
124
121
|
}
|
|
125
|
-
|
|
126
122
|
return true;
|
|
127
|
-
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Determine which widgets have been deleted. We can tell if a widget is
|
|
128
126
|
// deleted and not just moved to a different area by looking to see if
|
|
129
127
|
// getWidgetAreaForWidgetId() finds something.
|
|
130
|
-
|
|
131
128
|
const deletedWidgets = [];
|
|
132
|
-
|
|
133
129
|
for (const widget of areaWidgets) {
|
|
134
130
|
const widgetsNewArea = select.getWidgetAreaForWidgetId(widget.id);
|
|
135
|
-
|
|
136
131
|
if (!widgetsNewArea) {
|
|
137
132
|
deletedWidgets.push(widget);
|
|
138
133
|
}
|
|
139
134
|
}
|
|
140
|
-
|
|
141
135
|
const batchMeta = [];
|
|
142
136
|
const batchTasks = [];
|
|
143
137
|
const sidebarWidgetsIds = [];
|
|
144
|
-
|
|
145
138
|
for (let i = 0; i < widgetsBlocks.length; i++) {
|
|
146
139
|
const block = widgetsBlocks[i];
|
|
147
140
|
const widgetId = getWidgetIdFromBlock(block);
|
|
148
141
|
const oldWidget = widgets[widgetId];
|
|
149
|
-
const widget = transformBlockToWidget(block, oldWidget);
|
|
142
|
+
const widget = transformBlockToWidget(block, oldWidget);
|
|
143
|
+
|
|
144
|
+
// We'll replace the null widgetId after save, but we track it here
|
|
150
145
|
// since order is important.
|
|
146
|
+
sidebarWidgetsIds.push(widgetId);
|
|
151
147
|
|
|
152
|
-
|
|
148
|
+
// Check oldWidget as widgetId might refer to an ID which has been
|
|
153
149
|
// deleted, e.g. if a deleted block is restored via undo after saving.
|
|
154
|
-
|
|
155
150
|
if (oldWidget) {
|
|
156
151
|
// Update an existing widget.
|
|
157
|
-
registry.dispatch(coreStore).editEntityRecord('root', 'widget', widgetId, {
|
|
152
|
+
registry.dispatch(coreStore).editEntityRecord('root', 'widget', widgetId, {
|
|
153
|
+
...widget,
|
|
158
154
|
sidebar: widgetAreaId
|
|
159
155
|
}, {
|
|
160
156
|
undoIgnore: true
|
|
161
157
|
});
|
|
162
158
|
const hasEdits = registry.select(coreStore).hasEditsForEntityRecord('root', 'widget', widgetId);
|
|
163
|
-
|
|
164
159
|
if (!hasEdits) {
|
|
165
160
|
continue;
|
|
166
161
|
}
|
|
167
|
-
|
|
168
162
|
batchTasks.push(({
|
|
169
163
|
saveEditedEntityRecord
|
|
170
164
|
}) => saveEditedEntityRecord('root', 'widget', widgetId));
|
|
@@ -172,18 +166,17 @@ export const saveWidgetArea = widgetAreaId => async ({
|
|
|
172
166
|
// Create a new widget.
|
|
173
167
|
batchTasks.push(({
|
|
174
168
|
saveEntityRecord
|
|
175
|
-
}) => saveEntityRecord('root', 'widget', {
|
|
169
|
+
}) => saveEntityRecord('root', 'widget', {
|
|
170
|
+
...widget,
|
|
176
171
|
sidebar: widgetAreaId
|
|
177
172
|
}));
|
|
178
173
|
}
|
|
179
|
-
|
|
180
174
|
batchMeta.push({
|
|
181
175
|
block,
|
|
182
176
|
position: i,
|
|
183
177
|
clientId: block.clientId
|
|
184
178
|
});
|
|
185
179
|
}
|
|
186
|
-
|
|
187
180
|
for (const widget of deletedWidgets) {
|
|
188
181
|
batchTasks.push(({
|
|
189
182
|
deleteEntityRecord
|
|
@@ -191,37 +184,31 @@ export const saveWidgetArea = widgetAreaId => async ({
|
|
|
191
184
|
force: true
|
|
192
185
|
}));
|
|
193
186
|
}
|
|
194
|
-
|
|
195
187
|
const records = await registry.dispatch(coreStore).__experimentalBatch(batchTasks);
|
|
196
188
|
const preservedRecords = records.filter(record => !record.hasOwnProperty('deleted'));
|
|
197
189
|
const failedWidgetNames = [];
|
|
198
|
-
|
|
199
190
|
for (let i = 0; i < preservedRecords.length; i++) {
|
|
200
191
|
const widget = preservedRecords[i];
|
|
201
192
|
const {
|
|
202
193
|
block,
|
|
203
194
|
position
|
|
204
|
-
} = batchMeta[i];
|
|
205
|
-
// store when we dispatch receiveEntityRecords( post ) below.
|
|
195
|
+
} = batchMeta[i];
|
|
206
196
|
|
|
197
|
+
// Set __internalWidgetId on the block. This will be persisted to the
|
|
198
|
+
// store when we dispatch receiveEntityRecords( post ) below.
|
|
207
199
|
post.blocks[position].attributes.__internalWidgetId = widget.id;
|
|
208
200
|
const error = registry.select(coreStore).getLastEntitySaveError('root', 'widget', widget.id);
|
|
209
|
-
|
|
210
201
|
if (error) {
|
|
211
202
|
failedWidgetNames.push(block.attributes?.name || block?.name);
|
|
212
203
|
}
|
|
213
|
-
|
|
214
204
|
if (!sidebarWidgetsIds[position]) {
|
|
215
205
|
sidebarWidgetsIds[position] = widget.id;
|
|
216
206
|
}
|
|
217
207
|
}
|
|
218
|
-
|
|
219
208
|
if (failedWidgetNames.length) {
|
|
220
|
-
throw new Error(sprintf(
|
|
221
|
-
/* translators: %s: List of widget names */
|
|
209
|
+
throw new Error(sprintf( /* translators: %s: List of widget names */
|
|
222
210
|
__('Could not save the following widgets: %s.'), failedWidgetNames.join(', ')));
|
|
223
211
|
}
|
|
224
|
-
|
|
225
212
|
registry.dispatch(coreStore).editEntityRecord(KIND, WIDGET_AREA_ENTITY_TYPE, widgetAreaId, {
|
|
226
213
|
widgets: sidebarWidgetsIds
|
|
227
214
|
}, {
|
|
@@ -230,7 +217,6 @@ export const saveWidgetArea = widgetAreaId => async ({
|
|
|
230
217
|
dispatch(trySaveWidgetArea(widgetAreaId));
|
|
231
218
|
registry.dispatch(coreStore).receiveEntityRecords(KIND, POST_TYPE, post, undefined);
|
|
232
219
|
};
|
|
233
|
-
|
|
234
220
|
const trySaveWidgetArea = widgetAreaId => ({
|
|
235
221
|
registry
|
|
236
222
|
}) => {
|
|
@@ -238,6 +224,7 @@ const trySaveWidgetArea = widgetAreaId => ({
|
|
|
238
224
|
throwOnError: true
|
|
239
225
|
});
|
|
240
226
|
};
|
|
227
|
+
|
|
241
228
|
/**
|
|
242
229
|
* Sets the clientId stored for a particular widgetId.
|
|
243
230
|
*
|
|
@@ -246,8 +233,6 @@ const trySaveWidgetArea = widgetAreaId => ({
|
|
|
246
233
|
*
|
|
247
234
|
* @return {Object} Action.
|
|
248
235
|
*/
|
|
249
|
-
|
|
250
|
-
|
|
251
236
|
export function setWidgetIdForClientId(clientId, widgetId) {
|
|
252
237
|
return {
|
|
253
238
|
type: 'SET_WIDGET_ID_FOR_CLIENT_ID',
|
|
@@ -255,6 +240,7 @@ export function setWidgetIdForClientId(clientId, widgetId) {
|
|
|
255
240
|
widgetId
|
|
256
241
|
};
|
|
257
242
|
}
|
|
243
|
+
|
|
258
244
|
/**
|
|
259
245
|
* Sets the open state of all the widget areas.
|
|
260
246
|
*
|
|
@@ -262,13 +248,13 @@ export function setWidgetIdForClientId(clientId, widgetId) {
|
|
|
262
248
|
*
|
|
263
249
|
* @return {Object} Action.
|
|
264
250
|
*/
|
|
265
|
-
|
|
266
251
|
export function setWidgetAreasOpenState(widgetAreasOpenState) {
|
|
267
252
|
return {
|
|
268
253
|
type: 'SET_WIDGET_AREAS_OPEN_STATE',
|
|
269
254
|
widgetAreasOpenState
|
|
270
255
|
};
|
|
271
256
|
}
|
|
257
|
+
|
|
272
258
|
/**
|
|
273
259
|
* Sets the open state of the widget area.
|
|
274
260
|
*
|
|
@@ -277,7 +263,6 @@ export function setWidgetAreasOpenState(widgetAreasOpenState) {
|
|
|
277
263
|
*
|
|
278
264
|
* @return {Object} Action.
|
|
279
265
|
*/
|
|
280
|
-
|
|
281
266
|
export function setIsWidgetAreaOpen(clientId, isOpen) {
|
|
282
267
|
return {
|
|
283
268
|
type: 'SET_IS_WIDGET_AREA_OPEN',
|
|
@@ -285,6 +270,7 @@ export function setIsWidgetAreaOpen(clientId, isOpen) {
|
|
|
285
270
|
isOpen
|
|
286
271
|
};
|
|
287
272
|
}
|
|
273
|
+
|
|
288
274
|
/**
|
|
289
275
|
* Returns an action object used to open/close the inserter.
|
|
290
276
|
*
|
|
@@ -297,69 +283,70 @@ export function setIsWidgetAreaOpen(clientId, isOpen) {
|
|
|
297
283
|
*
|
|
298
284
|
* @return {Object} Action object.
|
|
299
285
|
*/
|
|
300
|
-
|
|
301
286
|
export function setIsInserterOpened(value) {
|
|
302
287
|
return {
|
|
303
288
|
type: 'SET_IS_INSERTER_OPENED',
|
|
304
289
|
value
|
|
305
290
|
};
|
|
306
291
|
}
|
|
292
|
+
|
|
307
293
|
/**
|
|
308
294
|
* Returns an action object used to open/close the list view.
|
|
309
295
|
*
|
|
310
296
|
* @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.
|
|
311
297
|
* @return {Object} Action object.
|
|
312
298
|
*/
|
|
313
|
-
|
|
314
299
|
export function setIsListViewOpened(isOpen) {
|
|
315
300
|
return {
|
|
316
301
|
type: 'SET_IS_LIST_VIEW_OPENED',
|
|
317
302
|
isOpen
|
|
318
303
|
};
|
|
319
304
|
}
|
|
305
|
+
|
|
320
306
|
/**
|
|
321
307
|
* Returns an action object signalling that the user closed the sidebar.
|
|
322
308
|
*
|
|
323
309
|
* @return {Object} Action creator.
|
|
324
310
|
*/
|
|
325
|
-
|
|
326
311
|
export const closeGeneralSidebar = () => ({
|
|
327
312
|
registry
|
|
328
313
|
}) => {
|
|
329
314
|
registry.dispatch(interfaceStore).disableComplementaryArea(editWidgetsStoreName);
|
|
330
315
|
};
|
|
316
|
+
|
|
331
317
|
/**
|
|
332
318
|
* Action that handles moving a block between widget areas
|
|
333
319
|
*
|
|
334
320
|
* @param {string} clientId The clientId of the block to move.
|
|
335
321
|
* @param {string} widgetAreaId The id of the widget area to move the block to.
|
|
336
322
|
*/
|
|
337
|
-
|
|
338
323
|
export const moveBlockToWidgetArea = (clientId, widgetAreaId) => async ({
|
|
339
324
|
dispatch,
|
|
340
325
|
select,
|
|
341
326
|
registry
|
|
342
327
|
}) => {
|
|
343
|
-
const sourceRootClientId = registry.select(blockEditorStore).getBlockRootClientId(clientId);
|
|
328
|
+
const sourceRootClientId = registry.select(blockEditorStore).getBlockRootClientId(clientId);
|
|
329
|
+
|
|
330
|
+
// Search the top level blocks (widget areas) for the one with the matching
|
|
344
331
|
// id attribute. Makes the assumption that all top-level blocks are widget
|
|
345
332
|
// areas.
|
|
346
|
-
|
|
347
333
|
const widgetAreas = registry.select(blockEditorStore).getBlocks();
|
|
348
334
|
const destinationWidgetAreaBlock = widgetAreas.find(({
|
|
349
335
|
attributes
|
|
350
336
|
}) => attributes.id === widgetAreaId);
|
|
351
|
-
const destinationRootClientId = destinationWidgetAreaBlock.clientId;
|
|
337
|
+
const destinationRootClientId = destinationWidgetAreaBlock.clientId;
|
|
352
338
|
|
|
339
|
+
// Get the index for moving to the end of the destination widget area.
|
|
353
340
|
const destinationInnerBlocksClientIds = registry.select(blockEditorStore).getBlockOrder(destinationRootClientId);
|
|
354
|
-
const destinationIndex = destinationInnerBlocksClientIds.length;
|
|
341
|
+
const destinationIndex = destinationInnerBlocksClientIds.length;
|
|
355
342
|
|
|
343
|
+
// Reveal the widget area, if it's not open.
|
|
356
344
|
const isDestinationWidgetAreaOpen = select.getIsWidgetAreaOpen(destinationRootClientId);
|
|
357
|
-
|
|
358
345
|
if (!isDestinationWidgetAreaOpen) {
|
|
359
346
|
dispatch.setIsWidgetAreaOpen(destinationRootClientId, true);
|
|
360
|
-
}
|
|
361
|
-
|
|
347
|
+
}
|
|
362
348
|
|
|
349
|
+
// Move the block.
|
|
363
350
|
registry.dispatch(blockEditorStore).moveBlocksToPosition([clientId], sourceRootClientId, destinationRootClientId, destinationIndex);
|
|
364
351
|
};
|
|
365
352
|
//# sourceMappingURL=actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-widgets/src/store/actions.js"],"names":["__","sprintf","store","noticesStore","interfaceStore","getWidgetIdFromBlock","coreStore","blockEditorStore","transformBlockToWidget","buildWidgetAreaPostId","buildWidgetAreasQuery","createStubPost","KIND","POST_TYPE","WIDGET_AREA_ENTITY_TYPE","STORE_NAME","editWidgetsStoreName","persistStubPost","id","blocks","registry","stubPost","dispatch","receiveEntityRecords","saveEditedWidgetAreas","select","editedWidgetAreas","getEditedWidgetAreas","length","saveWidgetAreas","createSuccessNotice","type","e","createErrorNotice","message","widgetAreas","widgetArea","saveWidgetArea","finishResolution","widgetAreaId","widgets","getWidgets","post","getEditedEntityRecord","areaWidgets","Object","values","filter","sidebar","usedReferenceWidgets","widgetsBlocks","block","attributes","name","includes","push","deletedWidgets","widget","widgetsNewArea","getWidgetAreaForWidgetId","batchMeta","batchTasks","sidebarWidgetsIds","i","widgetId","oldWidget","editEntityRecord","undoIgnore","hasEdits","hasEditsForEntityRecord","saveEditedEntityRecord","saveEntityRecord","position","clientId","deleteEntityRecord","force","records","__experimentalBatch","preservedRecords","record","hasOwnProperty","failedWidgetNames","__internalWidgetId","error","getLastEntitySaveError","Error","join","trySaveWidgetArea","undefined","throwOnError","setWidgetIdForClientId","setWidgetAreasOpenState","widgetAreasOpenState","setIsWidgetAreaOpen","isOpen","setIsInserterOpened","value","setIsListViewOpened","closeGeneralSidebar","disableComplementaryArea","moveBlockToWidgetArea","sourceRootClientId","getBlockRootClientId","getBlocks","destinationWidgetAreaBlock","find","destinationRootClientId","destinationInnerBlocksClientIds","getBlockOrder","destinationIndex","isDestinationWidgetArea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AClC,EAAX,KAAkBqB,YADN,CAAnC;AAGA,QAAMmE,uBAAuB,GAAGF,0BAA0B,CAAC/B,QAA3D,CAZ2C,CAc3C;;AACA,QAAMkC,+BAA+B,GAAGvF,QAAQ,CAC9CK,MADsC,CAC9BlB,gBAD8B,EAEtCqG,aAFsC,CAEvBF,uBAFuB,CAAxC;AAGA,QAAMG,gBAAgB,GAAGF,+BAA+B,CAAC/E,MAAzD,CAlB2C,CAoB3C;;AACA,QAAMkF,2BAA2B,GAAGrF,MAAM,CAACsF,mBAAP,CACnCL,uBADmC,CAApC;;AAIA,MAAK,CAAEI,2BAAP,EAAqC;AACpCxF,IAAAA,QAAQ,CAACuE,mBAAT,CAA8Ba,uBAA9B,EAAuD,IAAvD;AACA,GA3B0C,CA6B3C;;;AACAtF,EAAAA,QAAQ,CACNE,QADF,CACYf,gBADZ,EAEEyG,oBAFF,CAGE,CAAEvC,QAAF,CAHF,EAIE4B,kBAJF,EAKEK,uBALF,EAMEG,gBANF;AAQA,CAxCK","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { transformBlockToWidget } from './transformers';\nimport {\n\tbuildWidgetAreaPostId,\n\tbuildWidgetAreasQuery,\n\tcreateStubPost,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\n/**\n * Persists a stub post with given ID to core data store. The post is meant to be in-memory only and\n * shouldn't be saved via the API.\n *\n * @param {string} id Post ID.\n * @param {Array} blocks Blocks the post should consist of.\n * @return {Object} The post object.\n */\nexport const persistStubPost =\n\t( id, blocks ) =>\n\t( { registry } ) => {\n\t\tconst stubPost = createStubPost( id, blocks );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.receiveEntityRecords(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tstubPost,\n\t\t\t\t{ id: stubPost.id },\n\t\t\t\tfalse\n\t\t\t);\n\t\treturn stubPost;\n\t};\n\n/**\n * Converts all the blocks from edited widget areas into widgets,\n * and submits a batch request to save everything at once.\n *\n * Creates a snackbar notice on either success or error.\n *\n * @return {Function} An action creator.\n */\nexport const saveEditedWidgetAreas =\n\t() =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst editedWidgetAreas = select.getEditedWidgetAreas();\n\t\tif ( ! editedWidgetAreas?.length ) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tawait dispatch.saveWidgetAreas( editedWidgetAreas );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( __( 'Widgets saved.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t} catch ( e ) {\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice(\n\t\t\t\t/* translators: %s: The error message. */\n\t\t\t\tsprintf( __( 'There was an error. %s' ), e.message ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n/**\n * Converts all the blocks from specified widget areas into widgets,\n * and submits a batch request to save everything at once.\n *\n * @param {Object[]} widgetAreas Widget areas to save.\n * @return {Function} An action creator.\n */\nexport const saveWidgetAreas =\n\t( widgetAreas ) =>\n\tasync ( { dispatch, registry } ) => {\n\t\ttry {\n\t\t\tfor ( const widgetArea of widgetAreas ) {\n\t\t\t\tawait dispatch.saveWidgetArea( widgetArea.id );\n\t\t\t}\n\t\t} finally {\n\t\t\t// saveEditedEntityRecord resets the resolution status, let's fix it manually.\n\t\t\tawait registry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.finishResolution(\n\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\tKIND,\n\t\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\t\tbuildWidgetAreasQuery()\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Converts all the blocks from a widget area specified by ID into widgets,\n * and submits a batch request to save everything at once.\n *\n * @param {string} widgetAreaId ID of the widget area to process.\n * @return {Function} An action creator.\n */\nexport const saveWidgetArea =\n\t( widgetAreaId ) =>\n\tasync ( { dispatch, select, registry } ) => {\n\t\tconst widgets = select.getWidgets();\n\n\t\tconst post = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( widgetAreaId )\n\t\t\t);\n\n\t\t// Get all widgets from this area\n\t\tconst areaWidgets = Object.values( widgets ).filter(\n\t\t\t( { sidebar } ) => sidebar === widgetAreaId\n\t\t);\n\n\t\t// Remove all duplicate reference widget instances for legacy widgets.\n\t\t// Why? We filter out the widgets with duplicate IDs to prevent adding more than one instance of a widget\n\t\t// implemented using a function. WordPress doesn't support having more than one instance of these, if you try to\n\t\t// save multiple instances of these in different sidebars you will run into undefined behaviors.\n\t\tconst usedReferenceWidgets = [];\n\t\tconst widgetsBlocks = post.blocks.filter( ( block ) => {\n\t\t\tconst { id } = block.attributes;\n\n\t\t\tif ( block.name === 'core/legacy-widget' && id ) {\n\t\t\t\tif ( usedReferenceWidgets.includes( id ) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tusedReferenceWidgets.push( id );\n\t\t\t}\n\t\t\treturn true;\n\t\t} );\n\n\t\t// Determine which widgets have been deleted. We can tell if a widget is\n\t\t// deleted and not just moved to a different area by looking to see if\n\t\t// getWidgetAreaForWidgetId() finds something.\n\t\tconst deletedWidgets = [];\n\t\tfor ( const widget of areaWidgets ) {\n\t\t\tconst widgetsNewArea = select.getWidgetAreaForWidgetId( widget.id );\n\t\t\tif ( ! widgetsNewArea ) {\n\t\t\t\tdeletedWidgets.push( widget );\n\t\t\t}\n\t\t}\n\n\t\tconst batchMeta = [];\n\t\tconst batchTasks = [];\n\t\tconst sidebarWidgetsIds = [];\n\t\tfor ( let i = 0; i < widgetsBlocks.length; i++ ) {\n\t\t\tconst block = widgetsBlocks[ i ];\n\t\t\tconst widgetId = getWidgetIdFromBlock( block );\n\t\t\tconst oldWidget = widgets[ widgetId ];\n\t\t\tconst widget = transformBlockToWidget( block, oldWidget );\n\n\t\t\t// We'll replace the null widgetId after save, but we track it here\n\t\t\t// since order is important.\n\t\t\tsidebarWidgetsIds.push( widgetId );\n\n\t\t\t// Check oldWidget as widgetId might refer to an ID which has been\n\t\t\t// deleted, e.g. if a deleted block is restored via undo after saving.\n\t\t\tif ( oldWidget ) {\n\t\t\t\t// Update an existing widget.\n\t\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t\t'root',\n\t\t\t\t\t'widget',\n\t\t\t\t\twidgetId,\n\t\t\t\t\t{\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tsidebar: widgetAreaId,\n\t\t\t\t\t},\n\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t);\n\n\t\t\t\tconst hasEdits = registry\n\t\t\t\t\t.select( coreStore )\n\t\t\t\t\t.hasEditsForEntityRecord( 'root', 'widget', widgetId );\n\n\t\t\t\tif ( ! hasEdits ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tbatchTasks.push( ( { saveEditedEntityRecord } ) =>\n\t\t\t\t\tsaveEditedEntityRecord( 'root', 'widget', widgetId )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Create a new widget.\n\t\t\t\tbatchTasks.push( ( { saveEntityRecord } ) =>\n\t\t\t\t\tsaveEntityRecord( 'root', 'widget', {\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tsidebar: widgetAreaId,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tbatchMeta.push( {\n\t\t\t\tblock,\n\t\t\t\tposition: i,\n\t\t\t\tclientId: block.clientId,\n\t\t\t} );\n\t\t}\n\t\tfor ( const widget of deletedWidgets ) {\n\t\t\tbatchTasks.push( ( { deleteEntityRecord } ) =>\n\t\t\t\tdeleteEntityRecord( 'root', 'widget', widget.id, {\n\t\t\t\t\tforce: true,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\n\t\tconst records = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.__experimentalBatch( batchTasks );\n\t\tconst preservedRecords = records.filter(\n\t\t\t( record ) => ! record.hasOwnProperty( 'deleted' )\n\t\t);\n\n\t\tconst failedWidgetNames = [];\n\n\t\tfor ( let i = 0; i < preservedRecords.length; i++ ) {\n\t\t\tconst widget = preservedRecords[ i ];\n\t\t\tconst { block, position } = batchMeta[ i ];\n\n\t\t\t// Set __internalWidgetId on the block. This will be persisted to the\n\t\t\t// store when we dispatch receiveEntityRecords( post ) below.\n\t\t\tpost.blocks[ position ].attributes.__internalWidgetId = widget.id;\n\n\t\t\tconst error = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getLastEntitySaveError( 'root', 'widget', widget.id );\n\t\t\tif ( error ) {\n\t\t\t\tfailedWidgetNames.push( block.attributes?.name || block?.name );\n\t\t\t}\n\n\t\t\tif ( ! sidebarWidgetsIds[ position ] ) {\n\t\t\t\tsidebarWidgetsIds[ position ] = widget.id;\n\t\t\t}\n\t\t}\n\n\t\tif ( failedWidgetNames.length ) {\n\t\t\tthrow new Error(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: List of widget names */\n\t\t\t\t\t__( 'Could not save the following widgets: %s.' ),\n\t\t\t\t\tfailedWidgetNames.join( ', ' )\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\tKIND,\n\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\twidgetAreaId,\n\t\t\t{\n\t\t\t\twidgets: sidebarWidgetsIds,\n\t\t\t},\n\t\t\t{ undoIgnore: true }\n\t\t);\n\n\t\tdispatch( trySaveWidgetArea( widgetAreaId ) );\n\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.receiveEntityRecords( KIND, POST_TYPE, post, undefined );\n\t};\n\nconst trySaveWidgetArea =\n\t( widgetAreaId ) =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\twidgetAreaId,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t};\n\n/**\n * Sets the clientId stored for a particular widgetId.\n *\n * @param {number} clientId Client id.\n * @param {number} widgetId Widget id.\n *\n * @return {Object} Action.\n */\nexport function setWidgetIdForClientId( clientId, widgetId ) {\n\treturn {\n\t\ttype: 'SET_WIDGET_ID_FOR_CLIENT_ID',\n\t\tclientId,\n\t\twidgetId,\n\t};\n}\n\n/**\n * Sets the open state of all the widget areas.\n *\n * @param {Object} widgetAreasOpenState The open states of all the widget areas.\n *\n * @return {Object} Action.\n */\nexport function setWidgetAreasOpenState( widgetAreasOpenState ) {\n\treturn {\n\t\ttype: 'SET_WIDGET_AREAS_OPEN_STATE',\n\t\twidgetAreasOpenState,\n\t};\n}\n\n/**\n * Sets the open state of the widget area.\n *\n * @param {string} clientId The clientId of the widget area.\n * @param {boolean} isOpen Whether the widget area should be opened.\n *\n * @return {Object} Action.\n */\nexport function setIsWidgetAreaOpen( clientId, isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_WIDGET_AREA_OPEN',\n\t\tclientId,\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the list view.\n *\n * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.\n * @return {Object} Action object.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @return {Object} Action creator.\n */\nexport const closeGeneralSidebar =\n\t() =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( interfaceStore )\n\t\t\t.disableComplementaryArea( editWidgetsStoreName );\n\t};\n\n/**\n * Action that handles moving a block between widget areas\n *\n * @param {string} clientId The clientId of the block to move.\n * @param {string} widgetAreaId The id of the widget area to move the block to.\n */\nexport const moveBlockToWidgetArea =\n\t( clientId, widgetAreaId ) =>\n\tasync ( { dispatch, select, registry } ) => {\n\t\tconst sourceRootClientId = registry\n\t\t\t.select( blockEditorStore )\n\t\t\t.getBlockRootClientId( clientId );\n\n\t\t// Search the top level blocks (widget areas) for the one with the matching\n\t\t// id attribute. Makes the assumption that all top-level blocks are widget\n\t\t// areas.\n\t\tconst widgetAreas = registry.select( blockEditorStore ).getBlocks();\n\t\tconst destinationWidgetAreaBlock = widgetAreas.find(\n\t\t\t( { attributes } ) => attributes.id === widgetAreaId\n\t\t);\n\t\tconst destinationRootClientId = destinationWidgetAreaBlock.clientId;\n\n\t\t// Get the index for moving to the end of the destination widget area.\n\t\tconst destinationInnerBlocksClientIds = registry\n\t\t\t.select( blockEditorStore )\n\t\t\t.getBlockOrder( destinationRootClientId );\n\t\tconst destinationIndex = destinationInnerBlocksClientIds.length;\n\n\t\t// Reveal the widget area, if it's not open.\n\t\tconst isDestinationWidgetAreaOpen = select.getIsWidgetAreaOpen(\n\t\t\tdestinationRootClientId\n\t\t);\n\n\t\tif ( ! isDestinationWidgetAreaOpen ) {\n\t\t\tdispatch.setIsWidgetAreaOpen( destinationRootClientId, true );\n\t\t}\n\n\t\t// Move the block.\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.moveBlocksToPosition(\n\t\t\t\t[ clientId ],\n\t\t\t\tsourceRootClientId,\n\t\t\t\tdestinationRootClientId,\n\t\t\t\tdestinationIndex\n\t\t\t);\n\t};\n"]}
|
|
1
|
+
{"version":3,"names":["__","sprintf","store","noticesStore","interfaceStore","getWidgetIdFromBlock","coreStore","blockEditorStore","transformBlockToWidget","buildWidgetAreaPostId","buildWidgetAreasQuery","createStubPost","KIND","POST_TYPE","WIDGET_AREA_ENTITY_TYPE","STORE_NAME","editWidgetsStoreName","persistStubPost","id","blocks","registry","stubPost","dispatch","receiveEntityRecords","saveEditedWidgetAreas","select","editedWidgetAreas","getEditedWidgetAreas","length","saveWidgetAreas","createSuccessNotice","type","e","createErrorNotice","message","widgetAreas","widgetArea","saveWidgetArea","finishResolution","widgetAreaId","widgets","getWidgets","post","getEditedEntityRecord","areaWidgets","Object","values","filter","sidebar","usedReferenceWidgets","widgetsBlocks","block","attributes","name","includes","push","deletedWidgets","widget","widgetsNewArea","getWidgetAreaForWidgetId","batchMeta","batchTasks","sidebarWidgetsIds","i","widgetId","oldWidget","editEntityRecord","undoIgnore","hasEdits","hasEditsForEntityRecord","saveEditedEntityRecord","saveEntityRecord","position","clientId","deleteEntityRecord","force","records","__experimentalBatch","preservedRecords","record","hasOwnProperty","failedWidgetNames","__internalWidgetId","error","getLastEntitySaveError","Error","join","trySaveWidgetArea","undefined","throwOnError","setWidgetIdForClientId","setWidgetAreasOpenState","widgetAreasOpenState","setIsWidgetAreaOpen","isOpen","setIsInserterOpened","value","setIsListViewOpened","closeGeneralSidebar","disableComplementaryArea","moveBlockToWidgetArea","sourceRootClientId","getBlockRootClientId","getBlocks","destinationWidgetAreaBlock","find","destinationRootClientId","destinationInnerBlocksClientIds","getBlockOrder","destinationIndex","isDestinationWidgetAreaOpen","getIsWidgetAreaOpen","moveBlocksToPosition"],"sources":["@wordpress/edit-widgets/src/store/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { transformBlockToWidget } from './transformers';\nimport {\n\tbuildWidgetAreaPostId,\n\tbuildWidgetAreasQuery,\n\tcreateStubPost,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\n/**\n * Persists a stub post with given ID to core data store. The post is meant to be in-memory only and\n * shouldn't be saved via the API.\n *\n * @param {string} id Post ID.\n * @param {Array} blocks Blocks the post should consist of.\n * @return {Object} The post object.\n */\nexport const persistStubPost =\n\t( id, blocks ) =>\n\t( { registry } ) => {\n\t\tconst stubPost = createStubPost( id, blocks );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.receiveEntityRecords(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tstubPost,\n\t\t\t\t{ id: stubPost.id },\n\t\t\t\tfalse\n\t\t\t);\n\t\treturn stubPost;\n\t};\n\n/**\n * Converts all the blocks from edited widget areas into widgets,\n * and submits a batch request to save everything at once.\n *\n * Creates a snackbar notice on either success or error.\n *\n * @return {Function} An action creator.\n */\nexport const saveEditedWidgetAreas =\n\t() =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst editedWidgetAreas = select.getEditedWidgetAreas();\n\t\tif ( ! editedWidgetAreas?.length ) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tawait dispatch.saveWidgetAreas( editedWidgetAreas );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( __( 'Widgets saved.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t} catch ( e ) {\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice(\n\t\t\t\t/* translators: %s: The error message. */\n\t\t\t\tsprintf( __( 'There was an error. %s' ), e.message ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n/**\n * Converts all the blocks from specified widget areas into widgets,\n * and submits a batch request to save everything at once.\n *\n * @param {Object[]} widgetAreas Widget areas to save.\n * @return {Function} An action creator.\n */\nexport const saveWidgetAreas =\n\t( widgetAreas ) =>\n\tasync ( { dispatch, registry } ) => {\n\t\ttry {\n\t\t\tfor ( const widgetArea of widgetAreas ) {\n\t\t\t\tawait dispatch.saveWidgetArea( widgetArea.id );\n\t\t\t}\n\t\t} finally {\n\t\t\t// saveEditedEntityRecord resets the resolution status, let's fix it manually.\n\t\t\tawait registry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.finishResolution(\n\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\tKIND,\n\t\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\t\tbuildWidgetAreasQuery()\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Converts all the blocks from a widget area specified by ID into widgets,\n * and submits a batch request to save everything at once.\n *\n * @param {string} widgetAreaId ID of the widget area to process.\n * @return {Function} An action creator.\n */\nexport const saveWidgetArea =\n\t( widgetAreaId ) =>\n\tasync ( { dispatch, select, registry } ) => {\n\t\tconst widgets = select.getWidgets();\n\n\t\tconst post = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( widgetAreaId )\n\t\t\t);\n\n\t\t// Get all widgets from this area\n\t\tconst areaWidgets = Object.values( widgets ).filter(\n\t\t\t( { sidebar } ) => sidebar === widgetAreaId\n\t\t);\n\n\t\t// Remove all duplicate reference widget instances for legacy widgets.\n\t\t// Why? We filter out the widgets with duplicate IDs to prevent adding more than one instance of a widget\n\t\t// implemented using a function. WordPress doesn't support having more than one instance of these, if you try to\n\t\t// save multiple instances of these in different sidebars you will run into undefined behaviors.\n\t\tconst usedReferenceWidgets = [];\n\t\tconst widgetsBlocks = post.blocks.filter( ( block ) => {\n\t\t\tconst { id } = block.attributes;\n\n\t\t\tif ( block.name === 'core/legacy-widget' && id ) {\n\t\t\t\tif ( usedReferenceWidgets.includes( id ) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tusedReferenceWidgets.push( id );\n\t\t\t}\n\t\t\treturn true;\n\t\t} );\n\n\t\t// Determine which widgets have been deleted. We can tell if a widget is\n\t\t// deleted and not just moved to a different area by looking to see if\n\t\t// getWidgetAreaForWidgetId() finds something.\n\t\tconst deletedWidgets = [];\n\t\tfor ( const widget of areaWidgets ) {\n\t\t\tconst widgetsNewArea = select.getWidgetAreaForWidgetId( widget.id );\n\t\t\tif ( ! widgetsNewArea ) {\n\t\t\t\tdeletedWidgets.push( widget );\n\t\t\t}\n\t\t}\n\n\t\tconst batchMeta = [];\n\t\tconst batchTasks = [];\n\t\tconst sidebarWidgetsIds = [];\n\t\tfor ( let i = 0; i < widgetsBlocks.length; i++ ) {\n\t\t\tconst block = widgetsBlocks[ i ];\n\t\t\tconst widgetId = getWidgetIdFromBlock( block );\n\t\t\tconst oldWidget = widgets[ widgetId ];\n\t\t\tconst widget = transformBlockToWidget( block, oldWidget );\n\n\t\t\t// We'll replace the null widgetId after save, but we track it here\n\t\t\t// since order is important.\n\t\t\tsidebarWidgetsIds.push( widgetId );\n\n\t\t\t// Check oldWidget as widgetId might refer to an ID which has been\n\t\t\t// deleted, e.g. if a deleted block is restored via undo after saving.\n\t\t\tif ( oldWidget ) {\n\t\t\t\t// Update an existing widget.\n\t\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t\t'root',\n\t\t\t\t\t'widget',\n\t\t\t\t\twidgetId,\n\t\t\t\t\t{\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tsidebar: widgetAreaId,\n\t\t\t\t\t},\n\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t);\n\n\t\t\t\tconst hasEdits = registry\n\t\t\t\t\t.select( coreStore )\n\t\t\t\t\t.hasEditsForEntityRecord( 'root', 'widget', widgetId );\n\n\t\t\t\tif ( ! hasEdits ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tbatchTasks.push( ( { saveEditedEntityRecord } ) =>\n\t\t\t\t\tsaveEditedEntityRecord( 'root', 'widget', widgetId )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Create a new widget.\n\t\t\t\tbatchTasks.push( ( { saveEntityRecord } ) =>\n\t\t\t\t\tsaveEntityRecord( 'root', 'widget', {\n\t\t\t\t\t\t...widget,\n\t\t\t\t\t\tsidebar: widgetAreaId,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tbatchMeta.push( {\n\t\t\t\tblock,\n\t\t\t\tposition: i,\n\t\t\t\tclientId: block.clientId,\n\t\t\t} );\n\t\t}\n\t\tfor ( const widget of deletedWidgets ) {\n\t\t\tbatchTasks.push( ( { deleteEntityRecord } ) =>\n\t\t\t\tdeleteEntityRecord( 'root', 'widget', widget.id, {\n\t\t\t\t\tforce: true,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\n\t\tconst records = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.__experimentalBatch( batchTasks );\n\t\tconst preservedRecords = records.filter(\n\t\t\t( record ) => ! record.hasOwnProperty( 'deleted' )\n\t\t);\n\n\t\tconst failedWidgetNames = [];\n\n\t\tfor ( let i = 0; i < preservedRecords.length; i++ ) {\n\t\t\tconst widget = preservedRecords[ i ];\n\t\t\tconst { block, position } = batchMeta[ i ];\n\n\t\t\t// Set __internalWidgetId on the block. This will be persisted to the\n\t\t\t// store when we dispatch receiveEntityRecords( post ) below.\n\t\t\tpost.blocks[ position ].attributes.__internalWidgetId = widget.id;\n\n\t\t\tconst error = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getLastEntitySaveError( 'root', 'widget', widget.id );\n\t\t\tif ( error ) {\n\t\t\t\tfailedWidgetNames.push( block.attributes?.name || block?.name );\n\t\t\t}\n\n\t\t\tif ( ! sidebarWidgetsIds[ position ] ) {\n\t\t\t\tsidebarWidgetsIds[ position ] = widget.id;\n\t\t\t}\n\t\t}\n\n\t\tif ( failedWidgetNames.length ) {\n\t\t\tthrow new Error(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: List of widget names */\n\t\t\t\t\t__( 'Could not save the following widgets: %s.' ),\n\t\t\t\t\tfailedWidgetNames.join( ', ' )\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\tKIND,\n\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\twidgetAreaId,\n\t\t\t{\n\t\t\t\twidgets: sidebarWidgetsIds,\n\t\t\t},\n\t\t\t{ undoIgnore: true }\n\t\t);\n\n\t\tdispatch( trySaveWidgetArea( widgetAreaId ) );\n\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.receiveEntityRecords( KIND, POST_TYPE, post, undefined );\n\t};\n\nconst trySaveWidgetArea =\n\t( widgetAreaId ) =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\twidgetAreaId,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t};\n\n/**\n * Sets the clientId stored for a particular widgetId.\n *\n * @param {number} clientId Client id.\n * @param {number} widgetId Widget id.\n *\n * @return {Object} Action.\n */\nexport function setWidgetIdForClientId( clientId, widgetId ) {\n\treturn {\n\t\ttype: 'SET_WIDGET_ID_FOR_CLIENT_ID',\n\t\tclientId,\n\t\twidgetId,\n\t};\n}\n\n/**\n * Sets the open state of all the widget areas.\n *\n * @param {Object} widgetAreasOpenState The open states of all the widget areas.\n *\n * @return {Object} Action.\n */\nexport function setWidgetAreasOpenState( widgetAreasOpenState ) {\n\treturn {\n\t\ttype: 'SET_WIDGET_AREAS_OPEN_STATE',\n\t\twidgetAreasOpenState,\n\t};\n}\n\n/**\n * Sets the open state of the widget area.\n *\n * @param {string} clientId The clientId of the widget area.\n * @param {boolean} isOpen Whether the widget area should be opened.\n *\n * @return {Object} Action.\n */\nexport function setIsWidgetAreaOpen( clientId, isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_WIDGET_AREA_OPEN',\n\t\tclientId,\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the list view.\n *\n * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.\n * @return {Object} Action object.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @return {Object} Action creator.\n */\nexport const closeGeneralSidebar =\n\t() =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( interfaceStore )\n\t\t\t.disableComplementaryArea( editWidgetsStoreName );\n\t};\n\n/**\n * Action that handles moving a block between widget areas\n *\n * @param {string} clientId The clientId of the block to move.\n * @param {string} widgetAreaId The id of the widget area to move the block to.\n */\nexport const moveBlockToWidgetArea =\n\t( clientId, widgetAreaId ) =>\n\tasync ( { dispatch, select, registry } ) => {\n\t\tconst sourceRootClientId = registry\n\t\t\t.select( blockEditorStore )\n\t\t\t.getBlockRootClientId( clientId );\n\n\t\t// Search the top level blocks (widget areas) for the one with the matching\n\t\t// id attribute. Makes the assumption that all top-level blocks are widget\n\t\t// areas.\n\t\tconst widgetAreas = registry.select( blockEditorStore ).getBlocks();\n\t\tconst destinationWidgetAreaBlock = widgetAreas.find(\n\t\t\t( { attributes } ) => attributes.id === widgetAreaId\n\t\t);\n\t\tconst destinationRootClientId = destinationWidgetAreaBlock.clientId;\n\n\t\t// Get the index for moving to the end of the destination widget area.\n\t\tconst destinationInnerBlocksClientIds = registry\n\t\t\t.select( blockEditorStore )\n\t\t\t.getBlockOrder( destinationRootClientId );\n\t\tconst destinationIndex = destinationInnerBlocksClientIds.length;\n\n\t\t// Reveal the widget area, if it's not open.\n\t\tconst isDestinationWidgetAreaOpen = select.getIsWidgetAreaOpen(\n\t\t\tdestinationRootClientId\n\t\t);\n\n\t\tif ( ! isDestinationWidgetAreaOpen ) {\n\t\t\tdispatch.setIsWidgetAreaOpen( destinationRootClientId, true );\n\t\t}\n\n\t\t// Move the block.\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.moveBlocksToPosition(\n\t\t\t\t[ clientId ],\n\t\t\t\tsourceRootClientId,\n\t\t\t\tdestinationRootClientId,\n\t\t\t\tdestinationIndex\n\t\t\t);\n\t};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASD,KAAK,IAAIE,cAAc,QAAQ,sBAAsB;AAC9D,SA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AC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-widgets/src/store/constants.js"],"
|
|
1
|
+
{"version":3,"names":["STORE_NAME"],"sources":["@wordpress/edit-widgets/src/store/constants.js"],"sourcesContent":["/**\n * Module Constants\n */\nexport const STORE_NAME = 'core/edit-widgets';\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,MAAMA,UAAU,GAAG,mBAAmB"}
|
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import apiFetch from '@wordpress/api-fetch';
|
|
5
5
|
import { createReduxStore, register } from '@wordpress/data';
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
10
|
import reducer from './reducer';
|
|
11
11
|
import * as resolvers from './resolvers';
|
|
12
12
|
import * as selectors from './selectors';
|
|
13
13
|
import * as actions from './actions';
|
|
14
14
|
import { STORE_NAME } from './constants';
|
|
15
|
+
|
|
15
16
|
/**
|
|
16
17
|
* Block editor data store configuration.
|
|
17
18
|
*
|
|
@@ -19,13 +20,13 @@ import { STORE_NAME } from './constants';
|
|
|
19
20
|
*
|
|
20
21
|
* @type {Object}
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
23
|
const storeConfig = {
|
|
24
24
|
reducer,
|
|
25
25
|
selectors,
|
|
26
26
|
resolvers,
|
|
27
27
|
actions
|
|
28
28
|
};
|
|
29
|
+
|
|
29
30
|
/**
|
|
30
31
|
* Store definition for the edit widgets namespace.
|
|
31
32
|
*
|
|
@@ -33,17 +34,16 @@ const storeConfig = {
|
|
|
33
34
|
*
|
|
34
35
|
* @type {Object}
|
|
35
36
|
*/
|
|
36
|
-
|
|
37
37
|
export const store = createReduxStore(STORE_NAME, storeConfig);
|
|
38
|
-
register(store);
|
|
38
|
+
register(store);
|
|
39
|
+
|
|
40
|
+
// This package uses a few in-memory post types as wrappers for convenience.
|
|
39
41
|
// This middleware prevents any network requests related to these types as they are
|
|
40
42
|
// bound to fail anyway.
|
|
41
|
-
|
|
42
43
|
apiFetch.use(function (options, next) {
|
|
43
44
|
if (options.path?.indexOf('/wp/v2/types/widget-area') === 0) {
|
|
44
45
|
return Promise.resolve({});
|
|
45
46
|
}
|
|
46
|
-
|
|
47
47
|
return next(options);
|
|
48
48
|
});
|
|
49
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["apiFetch","createReduxStore","register","reducer","resolvers","selectors","actions","STORE_NAME","storeConfig","store","use","options","next","path","indexOf","Promise","resolve"],"sources":["@wordpress/edit-widgets/src/store/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as resolvers from './resolvers';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport { STORE_NAME } from './constants';\n\n/**\n * Block editor data store configuration.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#register\n *\n * @type {Object}\n */\nconst storeConfig = {\n\treducer,\n\tselectors,\n\tresolvers,\n\tactions,\n};\n\n/**\n * Store definition for the edit widgets namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig );\nregister( store );\n\n// This package uses a few in-memory post types as wrappers for convenience.\n// This middleware prevents any network requests related to these types as they are\n// bound to fail anyway.\napiFetch.use( function ( options, next ) {\n\tif ( options.path?.indexOf( '/wp/v2/types/widget-area' ) === 0 ) {\n\t\treturn Promise.resolve( {} );\n\t}\n\n\treturn next( options );\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,QAAQ,MAAM,sBAAsB;AAC3C,SAASC,gBAAgB,EAAEC,QAAQ,QAAQ,iBAAiB;;AAE5D;AACA;AACA;AACA,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAO,KAAKC,SAAS,MAAM,aAAa;AACxC,OAAO,KAAKC,SAAS,MAAM,aAAa;AACxC,OAAO,KAAKC,OAAO,MAAM,WAAW;AACpC,SAASC,UAAU,QAAQ,aAAa;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAAG;EACnBL,OAAO;EACPE,SAAS;EACTD,SAAS;EACTE;AACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,KAAK,GAAGR,gBAAgB,CAAEM,UAAU,EAAEC,WAAY,CAAC;AAChEN,QAAQ,CAAEO,KAAM,CAAC;;AAEjB;AACA;AACA;AACAT,QAAQ,CAACU,GAAG,CAAE,UAAWC,OAAO,EAAEC,IAAI,EAAG;EACxC,IAAKD,OAAO,CAACE,IAAI,EAAEC,OAAO,CAAE,0BAA2B,CAAC,KAAK,CAAC,EAAG;IAChE,OAAOC,OAAO,CAACC,OAAO,CAAE,CAAC,CAAE,CAAC;EAC7B;EAEA,OAAOJ,IAAI,CAAED,OAAQ,CAAC;AACvB,CAAE,CAAC"}
|