@wordpress/edit-widgets 6.8.7 → 6.10.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.map +1 -1
- package/build/components/header/document-tools/index.js +1 -1
- package/build/components/header/document-tools/index.js.map +1 -1
- package/build/components/layout/index.js +1 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/sidebar/index.js +3 -3
- package/build/components/sidebar/index.js.map +1 -1
- package/build/index.js +7 -1
- package/build/index.js.map +1 -1
- package/build/store/actions.js +2 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js.map +1 -1
- package/build-module/blocks/widget-area/edit/index.js.map +1 -1
- package/build-module/components/header/document-tools/index.js +2 -4
- package/build-module/components/header/document-tools/index.js.map +1 -1
- package/build-module/components/header/index.js +1 -3
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +1 -2
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +1 -3
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build-module/components/layout/index.js +2 -3
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/interface.js +1 -2
- package/build-module/components/layout/interface.js.map +1 -1
- package/build-module/components/more-menu/index.js +1 -3
- package/build-module/components/more-menu/index.js.map +1 -1
- package/build-module/components/notices/index.js +1 -3
- package/build-module/components/notices/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +2 -3
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -2
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/index.js +4 -5
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/widget-areas.js +1 -2
- package/build-module/components/sidebar/widget-areas.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +1 -3
- 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 +1 -2
- package/build-module/components/widget-areas-block-editor-provider/index.js.map +1 -1
- package/build-module/filters/move-to-widget-area.js +1 -3
- package/build-module/filters/move-to-widget-area.js.map +1 -1
- package/build-module/index.js +7 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +2 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js.map +1 -1
- package/build-style/style-rtl.css +11 -1
- package/build-style/style.css +11 -1
- package/package.json +30 -29
- package/src/components/header/document-tools/index.js +1 -1
- package/src/components/header/style.scss +1 -0
- package/src/components/secondary-sidebar/inserter-sidebar.js +1 -1
- package/src/components/sidebar/index.js +3 -3
- package/src/index.js +5 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSelector","createRegistrySelector","getWidgetIdFromBlock","store","coreStore","blockEditorStore","buildWidgetsQuery","buildWidgetAreasQuery","buildWidgetAreaPostId","KIND","POST_TYPE","WIDGET_AREA_ENTITY_TYPE","STORE_NAME","editWidgetsStoreName","EMPTY_INSERTION_POINT","rootClientId","undefined","insertionIndex","getWidgets","select","_widgets$reduce","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","getIsWidgetAreaOpen","widgetAreasOpenState","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","canInsertBlockInWidgetArea","blockName","getBlocks","firstWidgetArea","canInsertBlockType","isListViewOpened","listViewPanel"],"sources":["@wordpress/edit-widgets/src/store/selectors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport {\n\tbuildWidgetsQuery,\n\tbuildWidgetAreasQuery,\n\tbuildWidgetAreaPostId,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\nconst EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n};\n\n/**\n * Returns all API widgets.\n *\n * @return {Object[]} API List of widgets.\n */\nexport const getWidgets = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t() => {\n\t\t\tconst widgets = select( coreStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'widget',\n\t\t\t\tbuildWidgetsQuery()\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t// Key widgets by their ID.\n\t\t\t\twidgets?.reduce(\n\t\t\t\t\t( allWidgets, widget ) => ( {\n\t\t\t\t\t\t...allWidgets,\n\t\t\t\t\t\t[ widget.id ]: widget,\n\t\t\t\t\t} ),\n\t\t\t\t\t{}\n\t\t\t\t) ?? {}\n\t\t\t);\n\t\t},\n\t\t() => [\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'widget',\n\t\t\t\tbuildWidgetsQuery()\n\t\t\t),\n\t\t]\n\t)\n);\n\n/**\n * Returns API widget data for a particular widget ID.\n *\n * @param {number} id Widget ID.\n *\n * @return {Object} API widget data for a particular widget ID.\n */\nexport const getWidget = createRegistrySelector(\n\t( select ) => ( state, id ) => {\n\t\tconst widgets = select( editWidgetsStoreName ).getWidgets();\n\t\treturn widgets[ id ];\n\t}\n);\n\n/**\n * Returns all API widget areas.\n *\n * @return {Object[]} API List of widget areas.\n */\nexport const getWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst query = buildWidgetAreasQuery();\n\treturn select( coreStore ).getEntityRecords(\n\t\tKIND,\n\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\tquery\n\t);\n} );\n\n/**\n * Returns widgetArea containing a block identify by given widgetId\n *\n * @param {string} widgetId The ID of the widget.\n * @return {Object} Containing widget area.\n */\nexport const getWidgetAreaForWidgetId = createRegistrySelector(\n\t( select ) => ( state, widgetId ) => {\n\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\treturn widgetAreas.find( ( widgetArea ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( widgetArea.id )\n\t\t\t);\n\t\t\tconst blockWidgetIds = post.blocks.map( ( block ) =>\n\t\t\t\tgetWidgetIdFromBlock( block )\n\t\t\t);\n\t\t\treturn blockWidgetIds.includes( widgetId );\n\t\t} );\n\t}\n);\n\n/**\n * Given a child client id, returns the parent widget area block.\n *\n * @param {string} clientId The client id of a block in a widget area.\n *\n * @return {WPBlock} The widget area block.\n */\nexport const getParentWidgetAreaBlock = createRegistrySelector(\n\t( select ) => ( state, clientId ) => {\n\t\tconst { getBlock, getBlockName, getBlockParents } =\n\t\t\tselect( blockEditorStore );\n\t\tconst blockParents = getBlockParents( clientId );\n\t\tconst widgetAreaClientId = blockParents.find(\n\t\t\t( parentClientId ) =>\n\t\t\t\tgetBlockName( parentClientId ) === 'core/widget-area'\n\t\t);\n\t\treturn getBlock( widgetAreaClientId );\n\t}\n);\n\n/**\n * Returns all edited widget area entity records.\n *\n * @return {Object[]} List of edited widget area entity records.\n */\nexport const getEditedWidgetAreas = createRegistrySelector(\n\t( select ) => ( state, ids ) => {\n\t\tlet widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\tif ( ! widgetAreas ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( ids ) {\n\t\t\twidgetAreas = widgetAreas.filter( ( { id } ) =>\n\t\t\t\tids.includes( id )\n\t\t\t);\n\t\t}\n\t\treturn widgetAreas\n\t\t\t.filter( ( { id } ) =>\n\t\t\t\tselect( coreStore ).hasEditsForEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( id )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.map( ( { id } ) =>\n\t\t\t\tselect( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\t\tid\n\t\t\t\t)\n\t\t\t);\n\t}\n);\n\n/**\n * Returns all blocks representing reference widgets.\n *\n * @param {string} referenceWidgetName Optional. If given, only reference widgets with this name will be returned.\n * @return {Array} List of all blocks representing reference widgets\n */\nexport const getReferenceWidgetBlocks = createRegistrySelector(\n\t( select ) =>\n\t\t( state, referenceWidgetName = null ) => {\n\t\t\tconst results = [];\n\t\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\t\tfor ( const _widgetArea of widgetAreas ) {\n\t\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( _widgetArea.id )\n\t\t\t\t);\n\t\t\t\tfor ( const block of post.blocks ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tblock.name === 'core/legacy-widget' &&\n\t\t\t\t\t\t( ! referenceWidgetName ||\n\t\t\t\t\t\t\tblock.attributes?.referenceWidgetName ===\n\t\t\t\t\t\t\t\treferenceWidgetName )\n\t\t\t\t\t) {\n\t\t\t\t\t\tresults.push( block );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n);\n\n/**\n * Returns true if any widget area is currently being saved.\n *\n * @return {boolean} True if any widget area is currently being saved. False otherwise.\n */\nexport const isSavingWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst widgetAreasIds = select( editWidgetsStoreName )\n\t\t.getWidgetAreas()\n\t\t?.map( ( { id } ) => id );\n\tif ( ! widgetAreasIds ) {\n\t\treturn false;\n\t}\n\n\tfor ( const id of widgetAreasIds ) {\n\t\tconst isSaving = select( coreStore ).isSavingEntityRecord(\n\t\t\tKIND,\n\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tconst widgetIds = [\n\t\t...Object.keys( select( editWidgetsStoreName ).getWidgets() ),\n\t\tundefined, // account for new widgets without an ID\n\t];\n\tfor ( const id of widgetIds ) {\n\t\tconst isSaving = select( coreStore ).isSavingEntityRecord(\n\t\t\t'root',\n\t\t\t'widget',\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n} );\n\n/**\n * Gets whether the widget area is opened.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} clientId The clientId of the widget area.\n *\n * @return {boolean} True if the widget area is open.\n */\nexport const getIsWidgetAreaOpen = ( state, clientId ) => {\n\tconst { widgetAreasOpenState } = state;\n\treturn !! widgetAreasOpenState[ clientId ];\n};\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID and index to insert at.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tif ( typeof state.blockInserterPanel === 'boolean' ) {\n\t\treturn EMPTY_INSERTION_POINT;\n\t}\n\n\treturn state.blockInserterPanel;\n}\n\n/**\n * Returns true if a block can be inserted into a widget area.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} blockName The name of the block being inserted.\n *\n * @return {boolean} True if the block can be inserted in a widget area.\n */\nexport const canInsertBlockInWidgetArea = createRegistrySelector(\n\t( select ) => ( state, blockName ) => {\n\t\t// Widget areas are always top-level blocks, which getBlocks will return.\n\t\tconst widgetAreas = select( blockEditorStore ).getBlocks();\n\n\t\t// Makes an assumption that a block that can be inserted into one\n\t\t// widget area can be inserted into any widget area. Uses the first\n\t\t// widget area for testing whether the block can be inserted.\n\t\tconst [ firstWidgetArea ] = widgetAreas;\n\t\treturn select( blockEditorStore ).canInsertBlockType(\n\t\t\tblockName,\n\t\t\tfirstWidgetArea.clientId\n\t\t);\n\t}\n);\n\n/**\n * Returns true if the list view is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the list view is opened.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAc,EAAEC,sBAAsB,QAAQ,iBAAiB;AACxE,SAASC,oBAAoB,QAAQ,oBAAoB;AACzD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE,gBAAgB,QAAQ,yBAAyB;;AAEnE;AACA;AACA;AACA,SACCC,iBAAiB,EACjBC,qBAAqB,EACrBC,qBAAqB,EACrBC,IAAI,EACJC,SAAS,EACTC,uBAAuB,QACjB,SAAS;AAChB,SAASC,UAAU,IAAIC,oBAAoB,QAAQ,aAAa;AAEhE,MAAMC,qBAAqB,GAAG;EAC7BC,YA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A;AACA;AACA;AACA,OAAO,SAAS2B,gBAAgBA,CAAE3C,KAAK,EAAG;EACzC,OAAO,CAAC,CAAEA,KAAK,CAAC4C,kBAAkB;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,+BAA+BA,CAAE7C,KAAK,EAAG;EACxD,IAAK,OAAOA,KAAK,CAAC4C,kBAAkB,KAAK,SAAS,EAAG;IACpD,OAAO1D,qBAAqB;EAC7B;EAEA,OAAOc,KAAK,CAAC4C,kBAAkB;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,0BAA0B,GAAGzE,sBAAsB,CAC7DkB,MAAM,IAAM,CAAES,KAAK,EAAE+C,SAAS,KAAM;EACrC;EACA,MAAM1C,WAAW,GAAGd,MAAM,CAAEd,gBAAiB,CAAC,CAACuE,SAAS,CAAC,CAAC;;EAE1D;EACA;EACA;EACA,MAAM,CAAEC,eAAe,CAAE,GAAG5C,WAAW;EACvC,OAAOd,MAAM,CAAEd,gBAAiB,CAAC,CAACyE,kBAAkB,CACnDH,SAAS,EACTE,eAAe,CAACjC,QACjB,CAAC;AACF,CACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASmC,gBAAgBA,CAAEnD,KAAK,EAAG;EACzC,OAAOA,KAAK,CAACoD,aAAa;AAC3B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["createSelector","createRegistrySelector","getWidgetIdFromBlock","store","coreStore","blockEditorStore","buildWidgetsQuery","buildWidgetAreasQuery","buildWidgetAreaPostId","KIND","POST_TYPE","WIDGET_AREA_ENTITY_TYPE","STORE_NAME","editWidgetsStoreName","EMPTY_INSERTION_POINT","rootClientId","undefined","insertionIndex","getWidgets","select","_widgets$reduce","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","getIsWidgetAreaOpen","widgetAreasOpenState","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","canInsertBlockInWidgetArea","blockName","getBlocks","firstWidgetArea","canInsertBlockType","isListViewOpened","listViewPanel"],"sources":["@wordpress/edit-widgets/src/store/selectors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport {\n\tbuildWidgetsQuery,\n\tbuildWidgetAreasQuery,\n\tbuildWidgetAreaPostId,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\nconst EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n};\n\n/**\n * Returns all API widgets.\n *\n * @return {Object[]} API List of widgets.\n */\nexport const getWidgets = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t() => {\n\t\t\tconst widgets = select( coreStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'widget',\n\t\t\t\tbuildWidgetsQuery()\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t// Key widgets by their ID.\n\t\t\t\twidgets?.reduce(\n\t\t\t\t\t( allWidgets, widget ) => ( {\n\t\t\t\t\t\t...allWidgets,\n\t\t\t\t\t\t[ widget.id ]: widget,\n\t\t\t\t\t} ),\n\t\t\t\t\t{}\n\t\t\t\t) ?? {}\n\t\t\t);\n\t\t},\n\t\t() => [\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'widget',\n\t\t\t\tbuildWidgetsQuery()\n\t\t\t),\n\t\t]\n\t)\n);\n\n/**\n * Returns API widget data for a particular widget ID.\n *\n * @param {number} id Widget ID.\n *\n * @return {Object} API widget data for a particular widget ID.\n */\nexport const getWidget = createRegistrySelector(\n\t( select ) => ( state, id ) => {\n\t\tconst widgets = select( editWidgetsStoreName ).getWidgets();\n\t\treturn widgets[ id ];\n\t}\n);\n\n/**\n * Returns all API widget areas.\n *\n * @return {Object[]} API List of widget areas.\n */\nexport const getWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst query = buildWidgetAreasQuery();\n\treturn select( coreStore ).getEntityRecords(\n\t\tKIND,\n\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\tquery\n\t);\n} );\n\n/**\n * Returns widgetArea containing a block identify by given widgetId\n *\n * @param {string} widgetId The ID of the widget.\n * @return {Object} Containing widget area.\n */\nexport const getWidgetAreaForWidgetId = createRegistrySelector(\n\t( select ) => ( state, widgetId ) => {\n\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\treturn widgetAreas.find( ( widgetArea ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( widgetArea.id )\n\t\t\t);\n\t\t\tconst blockWidgetIds = post.blocks.map( ( block ) =>\n\t\t\t\tgetWidgetIdFromBlock( block )\n\t\t\t);\n\t\t\treturn blockWidgetIds.includes( widgetId );\n\t\t} );\n\t}\n);\n\n/**\n * Given a child client id, returns the parent widget area block.\n *\n * @param {string} clientId The client id of a block in a widget area.\n *\n * @return {WPBlock} The widget area block.\n */\nexport const getParentWidgetAreaBlock = createRegistrySelector(\n\t( select ) => ( state, clientId ) => {\n\t\tconst { getBlock, getBlockName, getBlockParents } =\n\t\t\tselect( blockEditorStore );\n\t\tconst blockParents = getBlockParents( clientId );\n\t\tconst widgetAreaClientId = blockParents.find(\n\t\t\t( parentClientId ) =>\n\t\t\t\tgetBlockName( parentClientId ) === 'core/widget-area'\n\t\t);\n\t\treturn getBlock( widgetAreaClientId );\n\t}\n);\n\n/**\n * Returns all edited widget area entity records.\n *\n * @return {Object[]} List of edited widget area entity records.\n */\nexport const getEditedWidgetAreas = createRegistrySelector(\n\t( select ) => ( state, ids ) => {\n\t\tlet widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\tif ( ! widgetAreas ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( ids ) {\n\t\t\twidgetAreas = widgetAreas.filter( ( { id } ) =>\n\t\t\t\tids.includes( id )\n\t\t\t);\n\t\t}\n\t\treturn widgetAreas\n\t\t\t.filter( ( { id } ) =>\n\t\t\t\tselect( coreStore ).hasEditsForEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( id )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.map( ( { id } ) =>\n\t\t\t\tselect( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\t\tid\n\t\t\t\t)\n\t\t\t);\n\t}\n);\n\n/**\n * Returns all blocks representing reference widgets.\n *\n * @param {string} referenceWidgetName Optional. If given, only reference widgets with this name will be returned.\n * @return {Array} List of all blocks representing reference widgets\n */\nexport const getReferenceWidgetBlocks = createRegistrySelector(\n\t( select ) =>\n\t\t( state, referenceWidgetName = null ) => {\n\t\t\tconst results = [];\n\t\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\t\tfor ( const _widgetArea of widgetAreas ) {\n\t\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( _widgetArea.id )\n\t\t\t\t);\n\t\t\t\tfor ( const block of post.blocks ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tblock.name === 'core/legacy-widget' &&\n\t\t\t\t\t\t( ! referenceWidgetName ||\n\t\t\t\t\t\t\tblock.attributes?.referenceWidgetName ===\n\t\t\t\t\t\t\t\treferenceWidgetName )\n\t\t\t\t\t) {\n\t\t\t\t\t\tresults.push( block );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n);\n\n/**\n * Returns true if any widget area is currently being saved.\n *\n * @return {boolean} True if any widget area is currently being saved. False otherwise.\n */\nexport const isSavingWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst widgetAreasIds = select( editWidgetsStoreName )\n\t\t.getWidgetAreas()\n\t\t?.map( ( { id } ) => id );\n\tif ( ! widgetAreasIds ) {\n\t\treturn false;\n\t}\n\n\tfor ( const id of widgetAreasIds ) {\n\t\tconst isSaving = select( coreStore ).isSavingEntityRecord(\n\t\t\tKIND,\n\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tconst widgetIds = [\n\t\t...Object.keys( select( editWidgetsStoreName ).getWidgets() ),\n\t\tundefined, // account for new widgets without an ID\n\t];\n\tfor ( const id of widgetIds ) {\n\t\tconst isSaving = select( coreStore ).isSavingEntityRecord(\n\t\t\t'root',\n\t\t\t'widget',\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n} );\n\n/**\n * Gets whether the widget area is opened.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} clientId The clientId of the widget area.\n *\n * @return {boolean} True if the widget area is open.\n */\nexport const getIsWidgetAreaOpen = ( state, clientId ) => {\n\tconst { widgetAreasOpenState } = state;\n\treturn !! widgetAreasOpenState[ clientId ];\n};\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID and index to insert at.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tif ( typeof state.blockInserterPanel === 'boolean' ) {\n\t\treturn EMPTY_INSERTION_POINT;\n\t}\n\n\treturn state.blockInserterPanel;\n}\n\n/**\n * Returns true if a block can be inserted into a widget area.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} blockName The name of the block being inserted.\n *\n * @return {boolean} True if the block can be inserted in a widget area.\n */\nexport const canInsertBlockInWidgetArea = createRegistrySelector(\n\t( select ) => ( state, blockName ) => {\n\t\t// Widget areas are always top-level blocks, which getBlocks will return.\n\t\tconst widgetAreas = select( blockEditorStore ).getBlocks();\n\n\t\t// Makes an assumption that a block that can be inserted into one\n\t\t// widget area can be inserted into any widget area. Uses the first\n\t\t// widget area for testing whether the block can be inserted.\n\t\tconst [ firstWidgetArea ] = widgetAreas;\n\t\treturn select( blockEditorStore ).canInsertBlockType(\n\t\t\tblockName,\n\t\t\tfirstWidgetArea.clientId\n\t\t);\n\t}\n);\n\n/**\n * Returns true if the list view is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the list view is opened.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAc,EAAEC,sBAAsB,QAAQ,iBAAiB;AACxE,SAASC,oBAAoB,QAAQ,oBAAoB;AACzD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE,gBAAgB,QAAQ,yBAAyB;;AAEnE;AACA;AACA;AACA,SACCC,iBAAiB,EACjBC,qBAAqB,EACrBC,qBAAqB,EACrBC,IAAI,EACJC,SAAS,EACTC,uBAAuB,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KAAK;EACtC,OAAO,CAAC,CAAE0C,oBAAoB,CAAE1B,QAAQ,CAAE;AAC3C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS2B,gBAAgBA,CAAE3C,KAAK,EAAG;EACzC,OAAO,CAAC,CAAEA,KAAK,CAAC4C,kBAAkB;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,+BAA+BA,CAAE7C,KAAK,EAAG;EACxD,IAAK,OAAOA,KAAK,CAAC4C,kBAAkB,KAAK,SAAS,EAAG;IACpD,OAAO1D,qBAAqB;EAC7B;EAEA,OAAOc,KAAK,CAAC4C,kBAAkB;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,0BAA0B,GAAGzE,sBAAsB,CAC7DkB,MAAM,IAAM,CAAES,KAAK,EAAE+C,SAAS,KAAM;EACrC;EACA,MAAM1C,WAAW,GAAGd,MAAM,CAAEd,gBAAiB,CAAC,CAACuE,SAAS,CAAC,CAAC;;EAE1D;EACA;EACA;EACA,MAAM,CAAEC,eAAe,CAAE,GAAG5C,WAAW;EACvC,OAAOd,MAAM,CAAEd,gBAAiB,CAAC,CAACyE,kBAAkB,CACnDH,SAAS,EACTE,eAAe,CAACjC,QACjB,CAAC;AACF,CACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASmC,gBAAgBA,CAAEnD,KAAK,EAAG;EACzC,OAAOA,KAAK,CAACoD,aAAa;AAC3B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KIND","WIDGET_AREA_ENTITY_TYPE","POST_TYPE","buildWidgetAreaPostId","widgetAreaId","buildWidgetAreasPostId","buildWidgetAreasQuery","per_page","buildWidgetsQuery","_embed","createStubPost","id","blocks","slug","status","type","meta"],"sources":["@wordpress/edit-widgets/src/store/utils.js"],"sourcesContent":["/**\n * \"Kind\" of the navigation post.\n *\n * @type {string}\n */\nexport const KIND = 'root';\n\n/**\n * \"post type\" of the navigation post.\n *\n * @type {string}\n */\nexport const WIDGET_AREA_ENTITY_TYPE = 'sidebar';\n\n/**\n * \"post type\" of the widget area post.\n *\n * @type {string}\n */\nexport const POST_TYPE = 'postType';\n\n/**\n * Builds an ID for a new widget area post.\n *\n * @param {number} widgetAreaId Widget area id.\n * @return {string} An ID.\n */\nexport const buildWidgetAreaPostId = ( widgetAreaId ) =>\n\t`widget-area-${ widgetAreaId }`;\n\n/**\n * Builds an ID for a global widget areas post.\n *\n * @return {string} An ID.\n */\nexport const buildWidgetAreasPostId = () => `widget-areas`;\n\n/**\n * Builds a query to resolve sidebars.\n *\n * @return {Object} Query.\n */\nexport function buildWidgetAreasQuery() {\n\treturn {\n\t\tper_page: -1,\n\t};\n}\n\n/**\n * Builds a query to resolve widgets.\n *\n * @return {Object} Query.\n */\nexport function buildWidgetsQuery() {\n\treturn {\n\t\tper_page: -1,\n\t\t_embed: 'about',\n\t};\n}\n\n/**\n * Creates a stub post with given id and set of blocks. Used as a governing entity records\n * for all widget areas.\n *\n * @param {string} id Post ID.\n * @param {Array} blocks The list of blocks.\n * @return {Object} A stub post object formatted in compliance with the data layer.\n */\nexport const createStubPost = ( id, blocks ) => ( {\n\tid,\n\tslug: id,\n\tstatus: 'draft',\n\ttype: 'page',\n\tblocks,\n\tmeta: {\n\t\twidgetAreaId: id,\n\t},\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,IAAI,GAAG,MAAM;;AAE1B;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,GAAG,SAAS;;AAEhD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAG,UAAU;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,GAAKC,YAAY,
|
|
1
|
+
{"version":3,"names":["KIND","WIDGET_AREA_ENTITY_TYPE","POST_TYPE","buildWidgetAreaPostId","widgetAreaId","buildWidgetAreasPostId","buildWidgetAreasQuery","per_page","buildWidgetsQuery","_embed","createStubPost","id","blocks","slug","status","type","meta"],"sources":["@wordpress/edit-widgets/src/store/utils.js"],"sourcesContent":["/**\n * \"Kind\" of the navigation post.\n *\n * @type {string}\n */\nexport const KIND = 'root';\n\n/**\n * \"post type\" of the navigation post.\n *\n * @type {string}\n */\nexport const WIDGET_AREA_ENTITY_TYPE = 'sidebar';\n\n/**\n * \"post type\" of the widget area post.\n *\n * @type {string}\n */\nexport const POST_TYPE = 'postType';\n\n/**\n * Builds an ID for a new widget area post.\n *\n * @param {number} widgetAreaId Widget area id.\n * @return {string} An ID.\n */\nexport const buildWidgetAreaPostId = ( widgetAreaId ) =>\n\t`widget-area-${ widgetAreaId }`;\n\n/**\n * Builds an ID for a global widget areas post.\n *\n * @return {string} An ID.\n */\nexport const buildWidgetAreasPostId = () => `widget-areas`;\n\n/**\n * Builds a query to resolve sidebars.\n *\n * @return {Object} Query.\n */\nexport function buildWidgetAreasQuery() {\n\treturn {\n\t\tper_page: -1,\n\t};\n}\n\n/**\n * Builds a query to resolve widgets.\n *\n * @return {Object} Query.\n */\nexport function buildWidgetsQuery() {\n\treturn {\n\t\tper_page: -1,\n\t\t_embed: 'about',\n\t};\n}\n\n/**\n * Creates a stub post with given id and set of blocks. Used as a governing entity records\n * for all widget areas.\n *\n * @param {string} id Post ID.\n * @param {Array} blocks The list of blocks.\n * @return {Object} A stub post object formatted in compliance with the data layer.\n */\nexport const createStubPost = ( id, blocks ) => ( {\n\tid,\n\tslug: id,\n\tstatus: 'draft',\n\ttype: 'page',\n\tblocks,\n\tmeta: {\n\t\twidgetAreaId: id,\n\t},\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,IAAI,GAAG,MAAM;;AAE1B;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,GAAG,SAAS;;AAEhD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAG,UAAU;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,GAAKC,YAAY,IAClD,eAAgBA,YAAY,EAAG;;AAEhC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAGA,CAAA,KAAM,cAAc;;AAE1D;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAAA,EAAG;EACvC,OAAO;IACNC,QAAQ,EAAE,CAAC;EACZ,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAA,EAAG;EACnC,OAAO;IACND,QAAQ,EAAE,CAAC,CAAC;IACZE,MAAM,EAAE;EACT,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GAAGA,CAAEC,EAAE,EAAEC,MAAM,MAAQ;EACjDD,EAAE;EACFE,IAAI,EAAEF,EAAE;EACRG,MAAM,EAAE,OAAO;EACfC,IAAI,EAAE,MAAM;EACZH,MAAM;EACNI,IAAI,EAAE;IACLZ,YAAY,EAAEO;EACf;AACD,CAAC,CAAE","ignoreList":[]}
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
/**
|
|
30
30
|
* Fonts & basic variables.
|
|
31
31
|
*/
|
|
32
|
+
/**
|
|
33
|
+
* Typography
|
|
34
|
+
*/
|
|
32
35
|
/**
|
|
33
36
|
* Grid System.
|
|
34
37
|
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
|
|
@@ -43,7 +46,10 @@
|
|
|
43
46
|
* Dimensions.
|
|
44
47
|
*/
|
|
45
48
|
/**
|
|
46
|
-
*
|
|
49
|
+
* Mobile specific styles
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Editor styles.
|
|
47
53
|
*/
|
|
48
54
|
/**
|
|
49
55
|
* Block & Editor UI.
|
|
@@ -67,6 +73,9 @@
|
|
|
67
73
|
* Creates a fading overlay to signify that the content is longer
|
|
68
74
|
* than the space allows.
|
|
69
75
|
*/
|
|
76
|
+
/**
|
|
77
|
+
* Typography
|
|
78
|
+
*/
|
|
70
79
|
/**
|
|
71
80
|
* Breakpoint mixins
|
|
72
81
|
*/
|
|
@@ -590,6 +599,7 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
590
599
|
padding-left: 8px;
|
|
591
600
|
padding-right: 16px;
|
|
592
601
|
overflow: hidden;
|
|
602
|
+
height: 60px;
|
|
593
603
|
}
|
|
594
604
|
|
|
595
605
|
.edit-widgets-header__title {
|
package/build-style/style.css
CHANGED
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
/**
|
|
30
30
|
* Fonts & basic variables.
|
|
31
31
|
*/
|
|
32
|
+
/**
|
|
33
|
+
* Typography
|
|
34
|
+
*/
|
|
32
35
|
/**
|
|
33
36
|
* Grid System.
|
|
34
37
|
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
|
|
@@ -43,7 +46,10 @@
|
|
|
43
46
|
* Dimensions.
|
|
44
47
|
*/
|
|
45
48
|
/**
|
|
46
|
-
*
|
|
49
|
+
* Mobile specific styles
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Editor styles.
|
|
47
53
|
*/
|
|
48
54
|
/**
|
|
49
55
|
* Block & Editor UI.
|
|
@@ -67,6 +73,9 @@
|
|
|
67
73
|
* Creates a fading overlay to signify that the content is longer
|
|
68
74
|
* than the space allows.
|
|
69
75
|
*/
|
|
76
|
+
/**
|
|
77
|
+
* Typography
|
|
78
|
+
*/
|
|
70
79
|
/**
|
|
71
80
|
* Breakpoint mixins
|
|
72
81
|
*/
|
|
@@ -590,6 +599,7 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
590
599
|
padding-right: 8px;
|
|
591
600
|
padding-left: 16px;
|
|
592
601
|
overflow: hidden;
|
|
602
|
+
height: 60px;
|
|
593
603
|
}
|
|
594
604
|
|
|
595
605
|
.edit-widgets-header__title {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-widgets",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0",
|
|
4
4
|
"description": "Widgets Page module for WordPress..",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,33 +27,34 @@
|
|
|
27
27
|
"module": "build-module/index.js",
|
|
28
28
|
"react-native": "src/index",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@babel/runtime": "
|
|
31
|
-
"@wordpress/api-fetch": "^7.
|
|
32
|
-
"@wordpress/block-editor": "^14.
|
|
33
|
-
"@wordpress/block-library": "^9.
|
|
34
|
-
"@wordpress/blocks": "^13.
|
|
35
|
-
"@wordpress/components": "^28.
|
|
36
|
-
"@wordpress/compose": "^7.
|
|
37
|
-
"@wordpress/core-data": "^7.
|
|
38
|
-
"@wordpress/data": "^10.
|
|
39
|
-
"@wordpress/deprecated": "^4.
|
|
40
|
-
"@wordpress/dom": "^4.
|
|
41
|
-
"@wordpress/
|
|
42
|
-
"@wordpress/
|
|
43
|
-
"@wordpress/
|
|
44
|
-
"@wordpress/
|
|
45
|
-
"@wordpress/
|
|
46
|
-
"@wordpress/
|
|
47
|
-
"@wordpress/
|
|
48
|
-
"@wordpress/
|
|
49
|
-
"@wordpress/
|
|
50
|
-
"@wordpress/
|
|
51
|
-
"@wordpress/
|
|
52
|
-
"@wordpress/
|
|
53
|
-
"@wordpress/
|
|
54
|
-
"@wordpress/
|
|
55
|
-
"@wordpress/
|
|
56
|
-
"@wordpress/
|
|
30
|
+
"@babel/runtime": "7.25.7",
|
|
31
|
+
"@wordpress/api-fetch": "^7.10.0",
|
|
32
|
+
"@wordpress/block-editor": "^14.5.0",
|
|
33
|
+
"@wordpress/block-library": "^9.10.0",
|
|
34
|
+
"@wordpress/blocks": "^13.10.0",
|
|
35
|
+
"@wordpress/components": "^28.10.0",
|
|
36
|
+
"@wordpress/compose": "^7.10.0",
|
|
37
|
+
"@wordpress/core-data": "^7.10.0",
|
|
38
|
+
"@wordpress/data": "^10.10.0",
|
|
39
|
+
"@wordpress/deprecated": "^4.10.0",
|
|
40
|
+
"@wordpress/dom": "^4.10.0",
|
|
41
|
+
"@wordpress/editor": "^14.10.0",
|
|
42
|
+
"@wordpress/element": "^6.10.0",
|
|
43
|
+
"@wordpress/hooks": "^4.10.0",
|
|
44
|
+
"@wordpress/i18n": "^5.10.0",
|
|
45
|
+
"@wordpress/icons": "^10.10.0",
|
|
46
|
+
"@wordpress/interface": "^7.0.0",
|
|
47
|
+
"@wordpress/keyboard-shortcuts": "^5.10.0",
|
|
48
|
+
"@wordpress/keycodes": "^4.10.0",
|
|
49
|
+
"@wordpress/media-utils": "^5.10.0",
|
|
50
|
+
"@wordpress/notices": "^5.10.0",
|
|
51
|
+
"@wordpress/patterns": "^2.10.0",
|
|
52
|
+
"@wordpress/plugins": "^7.10.0",
|
|
53
|
+
"@wordpress/preferences": "^4.10.0",
|
|
54
|
+
"@wordpress/private-apis": "^1.10.0",
|
|
55
|
+
"@wordpress/reusable-blocks": "^5.10.0",
|
|
56
|
+
"@wordpress/url": "^4.10.0",
|
|
57
|
+
"@wordpress/widgets": "^4.10.0",
|
|
57
58
|
"clsx": "^2.1.1"
|
|
58
59
|
},
|
|
59
60
|
"peerDependencies": {
|
|
@@ -63,5 +64,5 @@
|
|
|
63
64
|
"publishConfig": {
|
|
64
65
|
"access": "public"
|
|
65
66
|
},
|
|
66
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "ab34a7ac935fd1478eac63b596242d83270897ee"
|
|
67
68
|
}
|
|
@@ -47,7 +47,7 @@ export default function InserterSidebar() {
|
|
|
47
47
|
__next40pxDefaultSize
|
|
48
48
|
icon={ close }
|
|
49
49
|
onClick={ closeInserter }
|
|
50
|
-
label={ __( 'Close
|
|
50
|
+
label={ __( 'Close Block Inserter' ) }
|
|
51
51
|
/>
|
|
52
52
|
</TagName>
|
|
53
53
|
<div className="edit-widgets-layout__inserter-panel-content">
|
|
@@ -28,7 +28,7 @@ const SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {
|
|
|
28
28
|
|
|
29
29
|
const BLOCK_INSPECTOR_IDENTIFIER = 'edit-widgets/block-inspector';
|
|
30
30
|
|
|
31
|
-
// Widget areas were
|
|
31
|
+
// Widget areas were once called block areas, so use 'edit-widgets/block-areas'
|
|
32
32
|
// for backwards compatibility.
|
|
33
33
|
const WIDGET_AREAS_IDENTIFIER = 'edit-widgets/block-areas';
|
|
34
34
|
|
|
@@ -192,10 +192,10 @@ export default function Sidebar() {
|
|
|
192
192
|
|
|
193
193
|
const { enableComplementaryArea } = useDispatch( interfaceStore );
|
|
194
194
|
|
|
195
|
-
// `newSelectedTabId` could technically be
|
|
195
|
+
// `newSelectedTabId` could technically be falsy if no tab is selected (i.e.
|
|
196
196
|
// the initial render) or when we don't want a tab displayed (i.e. the
|
|
197
197
|
// sidebar is closed). These cases should both be covered by the `!!` check
|
|
198
|
-
// below, so we shouldn't need any additional
|
|
198
|
+
// below, so we shouldn't need any additional falsy handling.
|
|
199
199
|
const onTabSelect = useCallback(
|
|
200
200
|
( newSelectedTabId ) => {
|
|
201
201
|
if ( !! newSelectedTabId ) {
|
package/src/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from '@wordpress/blocks';
|
|
10
10
|
import { dispatch } from '@wordpress/data';
|
|
11
11
|
import deprecated from '@wordpress/deprecated';
|
|
12
|
+
import { privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
12
13
|
import { StrictMode, createRoot } from '@wordpress/element';
|
|
13
14
|
import {
|
|
14
15
|
registerCoreBlocks,
|
|
@@ -29,7 +30,7 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
29
30
|
import './store';
|
|
30
31
|
import './filters';
|
|
31
32
|
import * as widgetArea from './blocks/widget-area';
|
|
32
|
-
|
|
33
|
+
import { unlock } from './lock-unlock';
|
|
33
34
|
import Layout from './components/layout';
|
|
34
35
|
import {
|
|
35
36
|
ALLOW_REUSABLE_BLOCKS,
|
|
@@ -43,6 +44,8 @@ const disabledBlocks = [
|
|
|
43
44
|
...( ALLOW_REUSABLE_BLOCKS ? [] : [ 'core/block' ] ),
|
|
44
45
|
];
|
|
45
46
|
|
|
47
|
+
const { registerCoreBlockBindingsSources } = unlock( editorPrivateApis );
|
|
48
|
+
|
|
46
49
|
/**
|
|
47
50
|
* Initializes the block editor in the widgets screen.
|
|
48
51
|
*
|
|
@@ -72,6 +75,7 @@ export function initializeEditor( id, settings ) {
|
|
|
72
75
|
|
|
73
76
|
dispatch( blocksStore ).reapplyBlockTypeFilters();
|
|
74
77
|
registerCoreBlocks( coreBlocks );
|
|
78
|
+
registerCoreBlockBindingsSources();
|
|
75
79
|
registerLegacyWidgetBlock();
|
|
76
80
|
if ( globalThis.IS_GUTENBERG_PLUGIN ) {
|
|
77
81
|
__experimentalRegisterExperimentalCoreBlocks( {
|