@wordpress/edit-widgets 7.2.0 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/blocks/widget-area/edit/index.cjs +10 -8
- package/build/blocks/widget-area/edit/index.cjs.map +1 -1
- package/build/blocks/widget-area/edit/inner-blocks.cjs +10 -8
- package/build/blocks/widget-area/edit/inner-blocks.cjs.map +1 -1
- package/build/blocks/widget-area/edit/use-is-dragging-within.cjs.map +1 -1
- package/build/blocks/widget-area/index.cjs +9 -7
- package/build/blocks/widget-area/index.cjs.map +1 -1
- package/build/components/error-boundary/index.cjs.map +1 -1
- package/build/components/header/document-tools/index.cjs +20 -10
- package/build/components/header/document-tools/index.cjs.map +1 -1
- package/build/components/header/index.cjs +12 -10
- package/build/components/header/index.cjs.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.cjs +5 -0
- package/build/components/keyboard-shortcut-help-modal/config.cjs.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs +9 -7
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.cjs +12 -11
- package/build/components/keyboard-shortcut-help-modal/index.cjs.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.cjs +34 -13
- package/build/components/keyboard-shortcut-help-modal/shortcut.cjs.map +1 -1
- package/build/components/keyboard-shortcuts/index.cjs.map +1 -1
- package/build/components/layout/index.cjs +19 -13
- package/build/components/layout/index.cjs.map +1 -1
- package/build/components/layout/interface.cjs +27 -13
- package/build/components/layout/interface.cjs.map +1 -1
- package/build/components/layout/unsaved-changes-warning.cjs.map +1 -1
- package/build/components/more-menu/index.cjs +14 -9
- package/build/components/more-menu/index.cjs.map +1 -1
- package/build/components/secondary-sidebar/index.cjs +10 -8
- package/build/components/secondary-sidebar/index.cjs.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.cjs +9 -7
- package/build/components/secondary-sidebar/inserter-sidebar.cjs.map +1 -1
- package/build/components/sidebar/index.cjs +23 -15
- package/build/components/sidebar/index.cjs.map +1 -1
- package/build/components/welcome-guide/index.cjs +5 -1
- package/build/components/welcome-guide/index.cjs.map +1 -1
- package/build/components/widget-areas-block-editor-content/index.cjs +10 -8
- package/build/components/widget-areas-block-editor-content/index.cjs.map +1 -1
- package/build/components/widget-areas-block-editor-provider/index.cjs +10 -8
- package/build/components/widget-areas-block-editor-provider/index.cjs.map +1 -1
- package/build/constants.cjs +0 -2
- package/build/constants.cjs.map +1 -1
- package/build/index.cjs +12 -10
- package/build/index.cjs.map +1 -1
- package/build/store/actions.cjs +11 -7
- package/build/store/actions.cjs.map +1 -1
- package/build/store/index.cjs +14 -12
- package/build/store/index.cjs.map +1 -1
- package/build/store/selectors.cjs +3 -1
- package/build/store/selectors.cjs.map +1 -1
- package/build-module/blocks/widget-area/index.mjs.map +1 -1
- package/build-module/components/header/document-tools/index.mjs +10 -2
- package/build-module/components/header/document-tools/index.mjs.map +1 -1
- package/build-module/components/header/undo-redo/redo.mjs.map +1 -1
- package/build-module/components/header/undo-redo/undo.mjs.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.mjs +5 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.mjs.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.mjs +1 -2
- package/build-module/components/keyboard-shortcut-help-modal/index.mjs.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs +34 -13
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs.map +1 -1
- package/build-module/components/layout/index.mjs +5 -1
- package/build-module/components/layout/index.mjs.map +1 -1
- package/build-module/components/layout/interface.mjs +16 -4
- package/build-module/components/layout/interface.mjs.map +1 -1
- package/build-module/components/more-menu/index.mjs +4 -1
- package/build-module/components/more-menu/index.mjs.map +1 -1
- package/build-module/components/sidebar/index.mjs +14 -8
- package/build-module/components/sidebar/index.mjs.map +1 -1
- package/build-module/components/welcome-guide/index.mjs +5 -1
- package/build-module/components/welcome-guide/index.mjs.map +1 -1
- package/build-module/constants.mjs +1 -2
- package/build-module/constants.mjs.map +1 -1
- package/build-module/index.mjs +2 -2
- package/build-module/index.mjs.map +1 -1
- package/build-module/store/actions.mjs +11 -7
- package/build-module/store/actions.mjs.map +1 -1
- package/build-module/store/selectors.mjs +3 -1
- package/build-module/store/selectors.mjs.map +1 -1
- package/build-style/style-rtl.css +42 -37
- package/build-style/style.css +42 -37
- package/build-types/blocks/widget-area/edit/index.d.ts +10 -0
- package/build-types/blocks/widget-area/edit/index.d.ts.map +1 -0
- package/build-types/blocks/widget-area/edit/inner-blocks.d.ts +4 -0
- package/build-types/blocks/widget-area/edit/inner-blocks.d.ts.map +1 -0
- package/build-types/blocks/widget-area/edit/use-is-dragging-within.d.ts +12 -0
- package/build-types/blocks/widget-area/edit/use-is-dragging-within.d.ts.map +1 -0
- package/build-types/blocks/widget-area/index.d.ts +14 -0
- package/build-types/blocks/widget-area/index.d.ts.map +1 -0
- package/build-types/components/error-boundary/index.d.ts +14 -0
- package/build-types/components/error-boundary/index.d.ts.map +1 -0
- package/build-types/components/header/document-tools/index.d.ts +3 -0
- package/build-types/components/header/document-tools/index.d.ts.map +1 -0
- package/build-types/components/header/index.d.ts +3 -0
- package/build-types/components/header/index.d.ts.map +1 -0
- package/build-types/components/header/undo-redo/redo.d.ts +3 -0
- package/build-types/components/header/undo-redo/redo.d.ts.map +1 -0
- package/build-types/components/header/undo-redo/undo.d.ts +3 -0
- package/build-types/components/header/undo-redo/undo.d.ts.map +1 -0
- package/build-types/components/keyboard-shortcut-help-modal/config.d.ts +3 -0
- package/build-types/components/keyboard-shortcut-help-modal/config.d.ts.map +1 -0
- package/build-types/components/keyboard-shortcut-help-modal/dynamic-shortcut.d.ts +5 -0
- package/build-types/components/keyboard-shortcut-help-modal/dynamic-shortcut.d.ts.map +1 -0
- package/build-types/components/keyboard-shortcut-help-modal/index.d.ts +5 -0
- package/build-types/components/keyboard-shortcut-help-modal/index.d.ts.map +1 -0
- package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts +25 -0
- package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts.map +1 -0
- package/build-types/components/keyboard-shortcuts/index.d.ts +7 -0
- package/build-types/components/keyboard-shortcuts/index.d.ts.map +1 -0
- package/build-types/components/layout/index.d.ts +5 -0
- package/build-types/components/layout/index.d.ts.map +1 -0
- package/build-types/components/layout/interface.d.ts +5 -0
- package/build-types/components/layout/interface.d.ts.map +1 -0
- package/build-types/components/layout/unsaved-changes-warning.d.ts +10 -0
- package/build-types/components/layout/unsaved-changes-warning.d.ts.map +1 -0
- package/build-types/components/more-menu/index.d.ts +2 -0
- package/build-types/components/more-menu/index.d.ts.map +1 -0
- package/build-types/components/more-menu/tools-more-menu-group.d.ts +6 -0
- package/build-types/components/more-menu/tools-more-menu-group.d.ts.map +1 -0
- package/build-types/components/notices/index.d.ts +3 -0
- package/build-types/components/notices/index.d.ts.map +1 -0
- package/build-types/components/save-button/index.d.ts +3 -0
- package/build-types/components/save-button/index.d.ts.map +1 -0
- package/build-types/components/secondary-sidebar/index.d.ts +2 -0
- package/build-types/components/secondary-sidebar/index.d.ts.map +1 -0
- package/build-types/components/secondary-sidebar/inserter-sidebar.d.ts +2 -0
- package/build-types/components/secondary-sidebar/inserter-sidebar.d.ts.map +1 -0
- package/build-types/components/secondary-sidebar/list-view-sidebar.d.ts +2 -0
- package/build-types/components/secondary-sidebar/list-view-sidebar.d.ts.map +1 -0
- package/build-types/components/sidebar/index.d.ts +2 -0
- package/build-types/components/sidebar/index.d.ts.map +1 -0
- package/build-types/components/sidebar/widget-areas.d.ts +4 -0
- package/build-types/components/sidebar/widget-areas.d.ts.map +1 -0
- package/build-types/components/welcome-guide/index.d.ts +2 -0
- package/build-types/components/welcome-guide/index.d.ts.map +1 -0
- package/build-types/components/widget-areas-block-editor-content/index.d.ts +4 -0
- package/build-types/components/widget-areas-block-editor-content/index.d.ts.map +1 -0
- package/build-types/components/widget-areas-block-editor-provider/index.d.ts +6 -0
- package/build-types/components/widget-areas-block-editor-provider/index.d.ts.map +1 -0
- package/build-types/constants.d.ts +2 -0
- package/build-types/constants.d.ts.map +1 -0
- package/build-types/filters/index.d.ts +3 -0
- package/build-types/filters/index.d.ts.map +1 -0
- package/build-types/filters/move-to-widget-area.d.ts +2 -0
- package/build-types/filters/move-to-widget-area.d.ts.map +1 -0
- package/build-types/filters/replace-media-upload.d.ts +2 -0
- package/build-types/filters/replace-media-upload.d.ts.map +1 -0
- package/build-types/hooks/use-last-selected-widget-area.d.ts +9 -0
- package/build-types/hooks/use-last-selected-widget-area.d.ts.map +1 -0
- package/build-types/hooks/use-widget-library-insertion-point.d.ts +3 -0
- package/build-types/hooks/use-widget-library-insertion-point.d.ts.map +1 -0
- package/build-types/index.d.ts +16 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/lock-unlock.d.ts +2 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/store/actions.d.ts +144 -0
- package/build-types/store/actions.d.ts.map +1 -0
- package/build-types/store/constants.d.ts +5 -0
- package/build-types/store/constants.d.ts.map +1 -0
- package/build-types/store/index.d.ts +9 -0
- package/build-types/store/index.d.ts.map +1 -0
- package/build-types/store/private-selectors.d.ts +3 -0
- package/build-types/store/private-selectors.d.ts.map +1 -0
- package/build-types/store/reducer.d.ts +73 -0
- package/build-types/store/reducer.d.ts.map +1 -0
- package/build-types/store/resolvers.d.ts +17 -0
- package/build-types/store/resolvers.d.ts.map +1 -0
- package/build-types/store/selectors.d.ts +159 -0
- package/build-types/store/selectors.d.ts.map +1 -0
- package/build-types/store/transformers.d.ts +16 -0
- package/build-types/store/transformers.d.ts.map +1 -0
- package/build-types/store/utils.d.ts +53 -0
- package/build-types/store/utils.d.ts.map +1 -0
- package/package.json +33 -33
- package/src/components/header/style.scss +1 -1
- package/src/components/keyboard-shortcut-help-modal/config.js +3 -0
- package/src/components/keyboard-shortcut-help-modal/index.jsx +0 -2
- package/src/components/keyboard-shortcut-help-modal/shortcut.jsx +43 -29
- package/src/components/sidebar/index.jsx +1 -1
- package/src/components/sidebar/style.scss +6 -0
- package/src/components/welcome-guide/style.scss +1 -1
- package/src/components/widget-areas-block-editor-content/style.scss +1 -1
- package/src/constants.js +0 -1
- package/src/index.jsx +2 -7
- package/src/store/actions.js +8 -12
- package/src/store/selectors.js +4 -1
- package/src/store/test/actions.jsdom.test.js +47 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["unlock","componentsPrivateApis","__","useDispatch","interfaceStore","useContext","ComplementaryArea","isRTL","drawerLeft","drawerRight","WidgetAreas","BlockInspector","useSelect","blockEditorStore","editWidgetsStore","useCallback"],"sources":["../../../src/components/sidebar/index.jsx"],"sourcesContent":["import { useEffect, useContext, useCallback } from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport {\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nconst SIDEBAR_ACTIVE_BY_DEFAULT = true;\nconst BLOCK_INSPECTOR_IDENTIFIER = 'edit-widgets/block-inspector';\n// Widget areas were once called block areas, so use 'edit-widgets/block-areas'\n// for backwards compatibility.\nconst WIDGET_AREAS_IDENTIFIER = 'edit-widgets/block-areas';\nimport WidgetAreas from './widget-areas';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { Tabs: WCTabs } = unlock( componentsPrivateApis );\n\nfunction SidebarHeader( { selectedWidgetAreaBlock } ) {\n\treturn (\n\t\t<WCTabs.TabList>\n\t\t\t<WCTabs.Tab tabId={ WIDGET_AREAS_IDENTIFIER }>\n\t\t\t\t{ selectedWidgetAreaBlock\n\t\t\t\t\t? selectedWidgetAreaBlock.attributes.name\n\t\t\t\t\t: __( 'Widget Areas' ) }\n\t\t\t</WCTabs.Tab>\n\t\t\t<WCTabs.Tab tabId={ BLOCK_INSPECTOR_IDENTIFIER }>\n\t\t\t\t{ __( 'Block' ) }\n\t\t\t</WCTabs.Tab>\n\t\t</WCTabs.TabList>\n\t);\n}\n\nfunction SidebarContent( {\n\thasSelectedNonAreaBlock,\n\tcurrentArea,\n\tisGeneralSidebarOpen,\n\tselectedWidgetAreaBlock,\n} ) {\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\thasSelectedNonAreaBlock &&\n\t\t\tcurrentArea === WIDGET_AREAS_IDENTIFIER &&\n\t\t\tisGeneralSidebarOpen\n\t\t) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\tBLOCK_INSPECTOR_IDENTIFIER\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\t! hasSelectedNonAreaBlock &&\n\t\t\tcurrentArea === BLOCK_INSPECTOR_IDENTIFIER &&\n\t\t\tisGeneralSidebarOpen\n\t\t) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\tWIDGET_AREAS_IDENTIFIER\n\t\t\t);\n\t\t}\n\t\t// We're intentionally leaving `currentArea` and `isGeneralSidebarOpen`\n\t\t// out of the dep array because we want this effect to run based on\n\t\t// block selection changes, not sidebar state changes.\n\t}, [ hasSelectedNonAreaBlock, enableComplementaryArea ] );\n\n\tconst tabsContextValue = useContext( WCTabs.Context );\n\n\treturn (\n\t\t<ComplementaryArea\n\t\t\tclassName=\"edit-widgets-sidebar\"\n\t\t\theader={\n\t\t\t\t<WCTabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<SidebarHeader\n\t\t\t\t\t\tselectedWidgetAreaBlock={ selectedWidgetAreaBlock }\n\t\t\t\t\t/>\n\t\t\t\t</WCTabs.Context.Provider>\n\t\t\t}\n\t\t\theaderClassName=\"edit-widgets-sidebar__panel-tabs\"\n\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\ttitle={ __( 'Settings' ) }\n\t\t\tcloseLabel={ __( 'Close Settings' ) }\n\t\t\tscope=\"core/edit-widgets\"\n\t\t\tidentifier={ currentArea }\n\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t<WCTabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t<WCTabs.TabPanel\n\t\t\t\t\ttabId={ WIDGET_AREAS_IDENTIFIER }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t<WidgetAreas\n\t\t\t\t\t\tselectedWidgetAreaId={\n\t\t\t\t\t\t\tselectedWidgetAreaBlock?.attributes.id\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</WCTabs.TabPanel>\n\t\t\t\t<WCTabs.TabPanel\n\t\t\t\t\ttabId={ BLOCK_INSPECTOR_IDENTIFIER }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t{ hasSelectedNonAreaBlock ? (\n\t\t\t\t\t\t<BlockInspector />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t// Pretend that Widget Areas are part of the UI by not\n\t\t\t\t\t\t// showing the Block Inspector when one is selected.\n\t\t\t\t\t\t<span className=\"block-editor-block-inspector__no-blocks\">\n\t\t\t\t\t\t\t{ __( 'No block selected.' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</WCTabs.TabPanel>\n\t\t\t</WCTabs.Context.Provider>\n\t\t</ComplementaryArea>\n\t);\n}\n\nexport default function Sidebar() {\n\tconst {\n\t\tcurrentArea,\n\t\thasSelectedNonAreaBlock,\n\t\tisGeneralSidebarOpen,\n\t\tselectedWidgetAreaBlock,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSelectedBlock, getBlock, getBlockParentsByBlockName } =\n\t\t\tselect( blockEditorStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\n\t\tconst selectedBlock = getSelectedBlock();\n\n\t\tconst activeArea = getActiveComplementaryArea( editWidgetsStore.name );\n\n\t\tlet currentSelection = activeArea;\n\t\tif ( ! currentSelection ) {\n\t\t\tif ( selectedBlock ) {\n\t\t\t\tcurrentSelection = BLOCK_INSPECTOR_IDENTIFIER;\n\t\t\t} else {\n\t\t\t\tcurrentSelection = WIDGET_AREAS_IDENTIFIER;\n\t\t\t}\n\t\t}\n\n\t\tlet widgetAreaBlock;\n\t\tif ( selectedBlock ) {\n\t\t\tif ( selectedBlock.name === 'core/widget-area' ) {\n\t\t\t\twidgetAreaBlock = selectedBlock;\n\t\t\t} else {\n\t\t\t\twidgetAreaBlock = getBlock(\n\t\t\t\t\tgetBlockParentsByBlockName(\n\t\t\t\t\t\tselectedBlock.clientId,\n\t\t\t\t\t\t'core/widget-area'\n\t\t\t\t\t)[ 0 ]\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tcurrentArea: currentSelection,\n\t\t\thasSelectedNonAreaBlock: !! (\n\t\t\t\tselectedBlock && selectedBlock.name !== 'core/widget-area'\n\t\t\t),\n\t\t\tisGeneralSidebarOpen: !! activeArea,\n\t\t\tselectedWidgetAreaBlock: widgetAreaBlock,\n\t\t};\n\t}, [] );\n\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\t// `newSelectedTabId` could technically be falsy if no tab is selected (i.e.\n\t// the initial render) or when we don't want a tab displayed (i.e. the\n\t// sidebar is closed). These cases should both be covered by the `!!` check\n\t// below, so we shouldn't need any additional falsy handling.\n\tconst onTabSelect = useCallback(\n\t\t( newSelectedTabId ) => {\n\t\t\tif ( !! newSelectedTabId ) {\n\t\t\t\tenableComplementaryArea(\n\t\t\t\t\teditWidgetsStore.name,\n\t\t\t\t\tnewSelectedTabId\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ enableComplementaryArea ]\n\t);\n\n\treturn (\n\t\t<WCTabs\n\t\t\t// Due to how this component is controlled (via a value from the\n\t\t\t// `interfaceStore`), when the sidebar closes the currently selected\n\t\t\t// tab can't be found. This causes the component to continuously reset\n\t\t\t// the selection to `null` in an infinite loop. Proactively setting\n\t\t\t// the selected tab to `null` avoids that.\n\t\t\tselectedTabId={ isGeneralSidebarOpen ? currentArea : null }\n\t\t\tonSelect={ onTabSelect }\n\t\t\tselectOnMove={ false }\n\t\t>\n\t\t\t<SidebarContent\n\t\t\t\thasSelectedNonAreaBlock={ hasSelectedNonAreaBlock }\n\t\t\t\tcurrentArea={ currentArea }\n\t\t\t\tisGeneralSidebarOpen={ isGeneralSidebarOpen }\n\t\t\t\tselectedWidgetAreaBlock={ selectedWidgetAreaBlock }\n\t\t\t/>\n\t\t</WCTabs>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,MAAM,4BAA4B;AAClC,MAAM,6BAA6B;AAGnC,MAAM,0BAA0B;AAKhC,MAAM,EAAE,MAAM,YAAA,GAAWA,qBAAAA,OAAAA,CAAQC,sBAAAA,WAAsB;AAEvD,SAAS,cAAe,EAAE,2BAA4B;CACrD,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAO,SAAR,EAAA,UAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAO,KAAR;EAAY,OAAQ;EACjB,UAAA,0BACC,wBAAwB,WAAW,QAAA,GACnCC,gBAAAA,GAAAA,CAAI,cAAe;CACX,CAAA,GACZ,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAO,KAAR;EAAY,OAAQ;EACjBA,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,OAAQ;CACH,CAAA,CACG,EAAA,CAAA;AAElB;AAEA,SAAS,eAAgB,EACxB,yBACA,aACA,sBACA,2BACG;CACH,MAAM,EAAE,6BAAA,G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index.cjs","names":["unlock","componentsPrivateApis","__","useDispatch","interfaceStore","useEffect","useContext","ComplementaryArea","isRTL","drawerLeft","drawerRight","WidgetAreas","BlockInspector","useSelect","blockEditorStore","editWidgetsStore","useCallback"],"sources":["../../../src/components/sidebar/index.jsx"],"sourcesContent":["import { useEffect, useContext, useCallback } from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport {\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nconst SIDEBAR_ACTIVE_BY_DEFAULT = true;\nconst BLOCK_INSPECTOR_IDENTIFIER = 'edit-widgets/block-inspector';\n// Widget areas were once called block areas, so use 'edit-widgets/block-areas'\n// for backwards compatibility.\nconst WIDGET_AREAS_IDENTIFIER = 'edit-widgets/block-areas';\nimport WidgetAreas from './widget-areas';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { Tabs: WCTabs } = unlock( componentsPrivateApis );\n\nfunction SidebarHeader( { selectedWidgetAreaBlock } ) {\n\treturn (\n\t\t<WCTabs.TabList className=\"edit-widgets-sidebar__panel-tablist\">\n\t\t\t<WCTabs.Tab tabId={ WIDGET_AREAS_IDENTIFIER }>\n\t\t\t\t{ selectedWidgetAreaBlock\n\t\t\t\t\t? selectedWidgetAreaBlock.attributes.name\n\t\t\t\t\t: __( 'Widget Areas' ) }\n\t\t\t</WCTabs.Tab>\n\t\t\t<WCTabs.Tab tabId={ BLOCK_INSPECTOR_IDENTIFIER }>\n\t\t\t\t{ __( 'Block' ) }\n\t\t\t</WCTabs.Tab>\n\t\t</WCTabs.TabList>\n\t);\n}\n\nfunction SidebarContent( {\n\thasSelectedNonAreaBlock,\n\tcurrentArea,\n\tisGeneralSidebarOpen,\n\tselectedWidgetAreaBlock,\n} ) {\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\thasSelectedNonAreaBlock &&\n\t\t\tcurrentArea === WIDGET_AREAS_IDENTIFIER &&\n\t\t\tisGeneralSidebarOpen\n\t\t) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\tBLOCK_INSPECTOR_IDENTIFIER\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\t! hasSelectedNonAreaBlock &&\n\t\t\tcurrentArea === BLOCK_INSPECTOR_IDENTIFIER &&\n\t\t\tisGeneralSidebarOpen\n\t\t) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\tWIDGET_AREAS_IDENTIFIER\n\t\t\t);\n\t\t}\n\t\t// We're intentionally leaving `currentArea` and `isGeneralSidebarOpen`\n\t\t// out of the dep array because we want this effect to run based on\n\t\t// block selection changes, not sidebar state changes.\n\t}, [ hasSelectedNonAreaBlock, enableComplementaryArea ] );\n\n\tconst tabsContextValue = useContext( WCTabs.Context );\n\n\treturn (\n\t\t<ComplementaryArea\n\t\t\tclassName=\"edit-widgets-sidebar\"\n\t\t\theader={\n\t\t\t\t<WCTabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<SidebarHeader\n\t\t\t\t\t\tselectedWidgetAreaBlock={ selectedWidgetAreaBlock }\n\t\t\t\t\t/>\n\t\t\t\t</WCTabs.Context.Provider>\n\t\t\t}\n\t\t\theaderClassName=\"edit-widgets-sidebar__panel-tabs\"\n\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\ttitle={ __( 'Settings' ) }\n\t\t\tcloseLabel={ __( 'Close Settings' ) }\n\t\t\tscope=\"core/edit-widgets\"\n\t\t\tidentifier={ currentArea }\n\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t<WCTabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t<WCTabs.TabPanel\n\t\t\t\t\ttabId={ WIDGET_AREAS_IDENTIFIER }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t<WidgetAreas\n\t\t\t\t\t\tselectedWidgetAreaId={\n\t\t\t\t\t\t\tselectedWidgetAreaBlock?.attributes.id\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</WCTabs.TabPanel>\n\t\t\t\t<WCTabs.TabPanel\n\t\t\t\t\ttabId={ BLOCK_INSPECTOR_IDENTIFIER }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t{ hasSelectedNonAreaBlock ? (\n\t\t\t\t\t\t<BlockInspector />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t// Pretend that Widget Areas are part of the UI by not\n\t\t\t\t\t\t// showing the Block Inspector when one is selected.\n\t\t\t\t\t\t<span className=\"block-editor-block-inspector__no-blocks\">\n\t\t\t\t\t\t\t{ __( 'No block selected.' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</WCTabs.TabPanel>\n\t\t\t</WCTabs.Context.Provider>\n\t\t</ComplementaryArea>\n\t);\n}\n\nexport default function Sidebar() {\n\tconst {\n\t\tcurrentArea,\n\t\thasSelectedNonAreaBlock,\n\t\tisGeneralSidebarOpen,\n\t\tselectedWidgetAreaBlock,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSelectedBlock, getBlock, getBlockParentsByBlockName } =\n\t\t\tselect( blockEditorStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\n\t\tconst selectedBlock = getSelectedBlock();\n\n\t\tconst activeArea = getActiveComplementaryArea( editWidgetsStore.name );\n\n\t\tlet currentSelection = activeArea;\n\t\tif ( ! currentSelection ) {\n\t\t\tif ( selectedBlock ) {\n\t\t\t\tcurrentSelection = BLOCK_INSPECTOR_IDENTIFIER;\n\t\t\t} else {\n\t\t\t\tcurrentSelection = WIDGET_AREAS_IDENTIFIER;\n\t\t\t}\n\t\t}\n\n\t\tlet widgetAreaBlock;\n\t\tif ( selectedBlock ) {\n\t\t\tif ( selectedBlock.name === 'core/widget-area' ) {\n\t\t\t\twidgetAreaBlock = selectedBlock;\n\t\t\t} else {\n\t\t\t\twidgetAreaBlock = getBlock(\n\t\t\t\t\tgetBlockParentsByBlockName(\n\t\t\t\t\t\tselectedBlock.clientId,\n\t\t\t\t\t\t'core/widget-area'\n\t\t\t\t\t)[ 0 ]\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tcurrentArea: currentSelection,\n\t\t\thasSelectedNonAreaBlock: !! (\n\t\t\t\tselectedBlock && selectedBlock.name !== 'core/widget-area'\n\t\t\t),\n\t\t\tisGeneralSidebarOpen: !! activeArea,\n\t\t\tselectedWidgetAreaBlock: widgetAreaBlock,\n\t\t};\n\t}, [] );\n\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\t// `newSelectedTabId` could technically be falsy if no tab is selected (i.e.\n\t// the initial render) or when we don't want a tab displayed (i.e. the\n\t// sidebar is closed). These cases should both be covered by the `!!` check\n\t// below, so we shouldn't need any additional falsy handling.\n\tconst onTabSelect = useCallback(\n\t\t( newSelectedTabId ) => {\n\t\t\tif ( !! newSelectedTabId ) {\n\t\t\t\tenableComplementaryArea(\n\t\t\t\t\teditWidgetsStore.name,\n\t\t\t\t\tnewSelectedTabId\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ enableComplementaryArea ]\n\t);\n\n\treturn (\n\t\t<WCTabs\n\t\t\t// Due to how this component is controlled (via a value from the\n\t\t\t// `interfaceStore`), when the sidebar closes the currently selected\n\t\t\t// tab can't be found. This causes the component to continuously reset\n\t\t\t// the selection to `null` in an infinite loop. Proactively setting\n\t\t\t// the selected tab to `null` avoids that.\n\t\t\tselectedTabId={ isGeneralSidebarOpen ? currentArea : null }\n\t\t\tonSelect={ onTabSelect }\n\t\t\tselectOnMove={ false }\n\t\t>\n\t\t\t<SidebarContent\n\t\t\t\thasSelectedNonAreaBlock={ hasSelectedNonAreaBlock }\n\t\t\t\tcurrentArea={ currentArea }\n\t\t\t\tisGeneralSidebarOpen={ isGeneralSidebarOpen }\n\t\t\t\tselectedWidgetAreaBlock={ selectedWidgetAreaBlock }\n\t\t\t/>\n\t\t</WCTabs>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,MAAM,4BAA4B;AAClC,MAAM,6BAA6B;AAGnC,MAAM,0BAA0B;AAKhC,MAAM,EAAE,MAAM,YAAA,GAAWA,qBAAAA,OAAAA,CAAQC,sBAAAA,WAAsB;AAEvD,SAAS,cAAe,EAAE,2BAA4B;CACrD,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAO,SAAR;EAAgB,WAAU;EAA1B,UAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAO,KAAR;GAAY,OAAQ;GACjB,UAAA,0BACC,wBAAwB,WAAW,QAAA,GACnCC,gBAAAA,GAAAA,CAAI,cAAe;EACX,CAAA,GACZ,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAO,KAAR;GAAY,OAAQ;GACjBA,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,OAAQ;EACH,CAAA,CACG;;AAElB;AAEA,SAAS,eAAgB,EACxB,yBACA,aACA,sBACA,2BACG;CACH,MAAM,EAAE,6BAAA,GAA4BC,gBAAAA,YAAAA,CAAaC,qBAAAA,KAAe;CAEhEC,CAAAA,GAAAA,mBAAAA,UAAAA,OAAiB;EAChB,IACC,2BACA,gBAAgB,2BAChB,sBAEA,wBACC,qBACA,0BACD;EAED,IACC,CAAE,2BACF,gBAAgB,8BAChB,sBAEA,wBACC,qBACA,uBACD;CAKF,GAAG,CAAE,yBAAyB,uBAAwB,CAAE;CAExD,MAAM,oBAAA,GAAmBC,mBAAAA,WAAA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AE,+BAA+B,OAAQV,qBAAAA,KAAe;EAE9D,MAAM,gBAAgB,iBAAiB;EAEvC,MAAM,aAAa,2BAA4BW,qBAAAA,MAAiB,IAAK;EAErE,IAAI,mBAAmB;EACvB,IAAK,CAAE,kBAAmB;GACzB,IAAK,eACJ,mBAAmB;QAEnB,mBAAmB;EAErB;EAEA,IAAI;EACJ,IAAK,eAAgB;GACpB,IAAK,cAAc,SAAS,oBAC3B,kBAAkB;QAElB,kBAAkB,SACjB,2BACC,cAAc,UACd,kBACD,CAAC,CAAE,EACJ;EAEF;EAEA,OAAO;GACN,aAAa;GACb,yBAAyB,CAAC,EACzB,iBAAiB,cAAc,SAAS;GAEzC,sBAAsB,CAAC,CAAE;GACzB,yBAAyB;EAC1B;CACD,GAAG,CAAC,CAAE;CAEN,MAAM,EAAE,6BAAA,GAA4BZ,gBAAAA,YAAAA,CAAaC,qBAAAA,KAAe;CAMhE,MAAM,eAAA,GAAcY,mBAAAA,YAAAA,EACjB,qBAAsB;EACvB,IAAK,CAAC,CAAE,kBACP,wBACCD,qBAAAA,MAAiB,MACjB,gBACD;CAEF,GACA,CAAE,uBAAwB,CAC3B;CAEA,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EAMC,eAAgB,uBAAuB,cAAc;EACrD,UAAW;EACX,cAAe;EAEf,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD;GAC2B;GACZ;GACS;GACG;EAC1B,CAAA;CACM,CAAA;AAEV"}
|
|
@@ -34,7 +34,11 @@ function WelcomeGuide() {
|
|
|
34
34
|
children: (0, _wordpress_i18n.__)("Welcome to block Widgets")
|
|
35
35
|
}), isEntirelyBlockWidgets ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
36
36
|
className: "edit-widgets-welcome-guide__text",
|
|
37
|
-
children: (0, _wordpress_i18n.sprintf)(
|
|
37
|
+
children: (0, _wordpress_i18n.sprintf)(
|
|
38
|
+
/** Translators: %s: Number of block areas in the current theme. */
|
|
39
|
+
(0, _wordpress_i18n._n)("Your theme provides %s “block” area for you to add and edit content.\xA0Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.", "Your theme provides %s different “block” areas for you to add and edit content.\xA0Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.", numWidgetAreas),
|
|
40
|
+
numWidgetAreas
|
|
41
|
+
)
|
|
38
42
|
}) }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
39
43
|
className: "edit-widgets-welcome-guide__text",
|
|
40
44
|
children: (0, _wordpress_i18n.__)("You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly.")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useSelect","preferencesStore","useDispatch","editWidgetsStore","Guide","__","sprintf","_n","ExternalLink","createInterpolateElement"],"sources":["../../../src/components/welcome-guide/index.jsx"],"sourcesContent":["import { useSelect, useDispatch } from '@wordpress/data';\nimport { ExternalLink, Guide } from '@wordpress/components';\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as editWidgetsStore } from '../../store';\n\nexport default function WelcomeGuide() {\n\tconst isActive = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'welcomeGuide'\n\t\t\t),\n\t\t[]\n\t);\n\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\n\tconst widgetAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getWidgetAreas( { per_page: -1 } ),\n\t\t[]\n\t);\n\n\tif ( ! isActive ) {\n\t\treturn null;\n\t}\n\n\tconst isEntirelyBlockWidgets = widgetAreas?.every(\n\t\t( widgetArea ) =>\n\t\t\twidgetArea.id === 'wp_inactive_widgets' ||\n\t\t\twidgetArea.widgets.every( ( widgetId ) =>\n\t\t\t\twidgetId.startsWith( 'block-' )\n\t\t\t)\n\t);\n\n\tconst numWidgetAreas =\n\t\twidgetAreas?.filter(\n\t\t\t( widgetArea ) => widgetArea.id !== 'wp_inactive_widgets'\n\t\t).length ?? 0;\n\n\treturn (\n\t\t<Guide\n\t\t\tclassName=\"edit-widgets-welcome-guide\"\n\t\t\tcontentLabel={ __( 'Welcome to block Widgets' ) }\n\t\t\tfinishButtonText={ __( 'Get started' ) }\n\t\t\tonFinish={ () =>\n\t\t\t\tsetPreference( 'core/edit-widgets', 'welcomeGuide', false )\n\t\t\t}\n\t\t\tpages={ [\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-canvas.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-canvas.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Welcome to block Widgets' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t{ isEntirelyBlockWidgets ? (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t// Translators: %s: Number of block areas in the current theme.\n\t\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t\t'Your theme provides %s “block” area for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.',\n\t\t\t\t\t\t\t\t\t\t\t\t'Your theme provides %s different “block” areas for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.',\n\t\t\t\t\t\t\t\t\t\t\t\tnumWidgetAreas\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tnumWidgetAreas\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t<strong>\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Want to stick with the old widgets?'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</strong>{ ' ' }\n\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/plugins/classic-widgets/'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Get the Classic Widgets plugin.'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-editor.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-editor.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Customize each block' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Each block comes with its own set of controls for changing things like color, width, and alignment. These will show and hide automatically when you have a block selected.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-library.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-library.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Explore all blocks' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'All of the blocks available to you live in the block library. You’ll find it wherever you see the <InserterIconImage /> icon.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tInserterIconImage: (\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"edit-widgets-welcome-guide__inserter-icon\"\n\t\t\t\t\t\t\t\t\t\t\t\talt={ __( 'inserter' ) }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='18' height='18' rx='2' fill='%231E1E1E'/%3E%3Cpath d='M9.22727 4V14M4 8.77273H14' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E%0A\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-documentation.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-documentation.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Learn more' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\"New to the block editor? Want to learn more about using it? <a>Here's a detailed guide.</a>\"\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/wordpress-block-editor/'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t] }\n\t\t/>\n\t);\n}\n\nfunction WelcomeGuideImage( { nonAnimatedSrc, animatedSrc } ) {\n\treturn (\n\t\t<picture className=\"edit-widgets-welcome-guide__image\">\n\t\t\t<source\n\t\t\t\tsrcSet={ nonAnimatedSrc }\n\t\t\t\tmedia=\"(prefers-reduced-motion: reduce)\"\n\t\t\t/>\n\t\t\t<img src={ animatedSrc } width=\"312\" height=\"240\" alt=\"\" />\n\t\t</picture>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,SAAwB,eAAe;CACtC,MAAM,YAAA,GAAWA,gBAAAA,UAAAA,EACd,WACD,CAAC,CAAE,OAAQC,uBAAAA,KAAiB,CAAC,CAAC,IAC7B,qBACA,cACD,GACD,CAAC,CACF;CAEA,MAAM,EAAE,KAAK,mBAAA,GAAkBC,gBAAAA,YAAAA,CAAaD,uBAAAA,KAAiB;CAE7D,MAAM,eAAA,GAAcD,gBAAAA,UAAAA,EACjB,WACD,OAAQG,qBAAAA,KAAiB,CAAC,CAAC,eAAgB,EAAE,UAAU,GAAG,CAAE,GAC7D,CAAC,CACF;CAEA,IAAK,CAAE,UACN,OAAO;CAGR,MAAM,yBAAyB,aAAa,OACzC,eACD,WAAW,OAAO,yBAClB,WAAW,QAAQ,OAAS,aAC3B,SAAS,WAAY,QAAS,CAC/B,CACF;CAEA,MAAM,iBACL,aAAa,QACV,eAAgB,WAAW,OAAO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,kBAAA,UAAA,EAAA,UAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;KAAI,WAAU;KACXA,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,YAAa;IAChB,CAAA,GACJ,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;KAAG,WAAU;KACVI,WAAAA,GAAAA,mBAAAA,yBAAAA,EAAAA,GACDJ,gBAAAA,GAAAA,CACC,6FACD,GACA,EACC,GACC,iBAAA,GAAA,kBAAA,IAAA,CAACG,sBAAAA,cAAD,EACC,OAAA,GAAOH,gBAAAA,GAAAA,CACN,qEACD,EACA,CAAA,EAEH,CACD;IACE,CAAA,CACF,EAAA,CAAA;GAEJ;EACD;CACA,CAAA;AAEH;AAEA,SAAS,kBAAmB,EAAE,gBAAgB,eAAgB;CAC7D,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,WAAD;EAAS,WAAU;EAAnB,UAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;GACC,QAAS;GACT,OAAM;EACN,CAAA,GACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,KAAM;GAAc,OAAM;GAAM,QAAO;GAAM,KAAI;EAAI,CAAA,CAClD;;AAEX"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useSelect","preferencesStore","useDispatch","editWidgetsStore","Guide","__","sprintf","_n","ExternalLink","createInterpolateElement"],"sources":["../../../src/components/welcome-guide/index.jsx"],"sourcesContent":["import { useSelect, useDispatch } from '@wordpress/data';\nimport { ExternalLink, Guide } from '@wordpress/components';\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as editWidgetsStore } from '../../store';\n\nexport default function WelcomeGuide() {\n\tconst isActive = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'welcomeGuide'\n\t\t\t),\n\t\t[]\n\t);\n\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\n\tconst widgetAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getWidgetAreas( { per_page: -1 } ),\n\t\t[]\n\t);\n\n\tif ( ! isActive ) {\n\t\treturn null;\n\t}\n\n\tconst isEntirelyBlockWidgets = widgetAreas?.every(\n\t\t( widgetArea ) =>\n\t\t\twidgetArea.id === 'wp_inactive_widgets' ||\n\t\t\twidgetArea.widgets.every( ( widgetId ) =>\n\t\t\t\twidgetId.startsWith( 'block-' )\n\t\t\t)\n\t);\n\n\tconst numWidgetAreas =\n\t\twidgetAreas?.filter(\n\t\t\t( widgetArea ) => widgetArea.id !== 'wp_inactive_widgets'\n\t\t).length ?? 0;\n\n\treturn (\n\t\t<Guide\n\t\t\tclassName=\"edit-widgets-welcome-guide\"\n\t\t\tcontentLabel={ __( 'Welcome to block Widgets' ) }\n\t\t\tfinishButtonText={ __( 'Get started' ) }\n\t\t\tonFinish={ () =>\n\t\t\t\tsetPreference( 'core/edit-widgets', 'welcomeGuide', false )\n\t\t\t}\n\t\t\tpages={ [\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-canvas.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-canvas.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Welcome to block Widgets' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t{ isEntirelyBlockWidgets ? (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t// Translators: %s: Number of block areas in the current theme.\n\t\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t\t'Your theme provides %s “block” area for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.',\n\t\t\t\t\t\t\t\t\t\t\t\t'Your theme provides %s different “block” areas for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.',\n\t\t\t\t\t\t\t\t\t\t\t\tnumWidgetAreas\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tnumWidgetAreas\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t<strong>\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Want to stick with the old widgets?'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</strong>{ ' ' }\n\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/plugins/classic-widgets/'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Get the Classic Widgets plugin.'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-editor.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-editor.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Customize each block' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Each block comes with its own set of controls for changing things like color, width, and alignment. These will show and hide automatically when you have a block selected.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-library.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-library.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Explore all blocks' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'All of the blocks available to you live in the block library. You’ll find it wherever you see the <InserterIconImage /> icon.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tInserterIconImage: (\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"edit-widgets-welcome-guide__inserter-icon\"\n\t\t\t\t\t\t\t\t\t\t\t\talt={ __( 'inserter' ) }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='18' height='18' rx='2' fill='%231E1E1E'/%3E%3Cpath d='M9.22727 4V14M4 8.77273H14' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E%0A\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-documentation.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-documentation.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Learn more' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\"New to the block editor? Want to learn more about using it? <a>Here's a detailed guide.</a>\"\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/wordpress-block-editor/'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t] }\n\t\t/>\n\t);\n}\n\nfunction WelcomeGuideImage( { nonAnimatedSrc, animatedSrc } ) {\n\treturn (\n\t\t<picture className=\"edit-widgets-welcome-guide__image\">\n\t\t\t<source\n\t\t\t\tsrcSet={ nonAnimatedSrc }\n\t\t\t\tmedia=\"(prefers-reduced-motion: reduce)\"\n\t\t\t/>\n\t\t\t<img src={ animatedSrc } width=\"312\" height=\"240\" alt=\"\" />\n\t\t</picture>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,SAAwB,eAAe;CACtC,MAAM,YAAA,GAAWA,gBAAAA,UAAAA,EACd,WACD,CAAC,CAAE,OAAQC,uBAAAA,KAAiB,CAAC,CAAC,IAC7B,qBACA,cACD,GACD,CAAC,CACF;CAEA,MAAM,EAAE,KAAK,mBAAA,GAAkBC,gBAAAA,YAAAA,CAAaD,uBAAAA,KAAiB;CAE7D,MAAM,eAAA,GAAcD,gBAAAA,UAAAA,EACjB,WACD,OAAQG,qBAAAA,KAAiB,CAAC,CAAC,eAAgB,EAA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gBAAAA,GAAAA,CAAI,UAAW;MACrB,KAAI;KACJ,CAAA,EAEH,CACD;IACE,CAAA,CACF,EAAA,CAAA;GAEJ;GACA;IACC,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAD;KACC,gBAAe;KACf,aAAY;IACZ,CAAA;IAEF,SACC,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;KAAI,WAAU;KACXA,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,YAAa;IAChB,CAAA,GACJ,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;KAAG,WAAU;KACVI,WAAAA,GAAAA,mBAAAA,yBAAAA,EAAAA,GACDJ,gBAAAA,GAAAA,CACC,6FACD,GACA,EACC,GACC,iBAAA,GAAA,kBAAA,IAAA,CAACG,sBAAAA,cAAD,EACC,OAAA,GAAOH,gBAAAA,GAAAA,CACN,qEACD,EACA,CAAA,EAEH,CACD;IACE,CAAA,CACF,EAAA,CAAA;GAEJ;EACD;CACA,CAAA;AAEH;AAEA,SAAS,kBAAmB,EAAE,gBAAgB,eAAgB;CAC7D,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,WAAD;EAAS,WAAU;EAAnB,UAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;GACC,QAAS;GACT,OAAM;EACN,CAAA,GACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,KAAM;GAAc,OAAM;GAAM,QAAO;GAAM,KAAI;EAAI,CAAA,CAClD;;AAEX"}
|
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -30,10 +32,10 @@ let _wordpress_data = require("@wordpress/data");
|
|
|
30
32
|
let _wordpress_element = require("@wordpress/element");
|
|
31
33
|
let _wordpress_preferences = require("@wordpress/preferences");
|
|
32
34
|
let ___notices_index_jsx = require("../notices/index.cjs");
|
|
33
|
-
___notices_index_jsx = __toESM(___notices_index_jsx);
|
|
34
35
|
let ___keyboard_shortcuts_index_js = require("../keyboard-shortcuts/index.cjs");
|
|
35
|
-
___keyboard_shortcuts_index_js = __toESM(___keyboard_shortcuts_index_js);
|
|
36
36
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
+
___notices_index_jsx = __toESM(___notices_index_jsx);
|
|
38
|
+
___keyboard_shortcuts_index_js = __toESM(___keyboard_shortcuts_index_js);
|
|
37
39
|
// packages/edit-widgets/src/components/widget-areas-block-editor-content/index.jsx
|
|
38
40
|
function WidgetAreasBlockEditorContent({ blockEditorSettings }) {
|
|
39
41
|
const hasThemeStyles = (0, _wordpress_data.useSelect)((select) => !!select(_wordpress_preferences.store).get("core/edit-widgets", "themeStyles"), []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useSelect","preferencesStore","useViewportMatch","useRef","useMemo","Notices","BlockToolbar","BlockTools","KeyboardShortcuts","EditorStyles","BlockSelectionClearer","WritingFlow","BlockList"],"sources":["../../../src/components/widget-areas-block-editor-content/index.jsx"],"sourcesContent":["import {\n\tBlockList,\n\tBlockToolbar,\n\tBlockTools,\n\tBlockSelectionClearer,\n\tWritingFlow,\n\t__unstableEditorStyles as EditorStyles,\n} from '@wordpress/block-editor';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo, useRef } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport Notices from '../notices';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\n\nexport default function WidgetAreasBlockEditorContent( {\n\tblockEditorSettings,\n} ) {\n\tconst hasThemeStyles = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'themeStyles'\n\t\t\t),\n\t\t[]\n\t);\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst contentRef = useRef();\n\n\tconst styles = useMemo( () => {\n\t\treturn hasThemeStyles ? blockEditorSettings.styles : [];\n\t}, [ blockEditorSettings, hasThemeStyles ] );\n\n\treturn (\n\t\t<div className=\"edit-widgets-block-editor\">\n\t\t\t<Notices />\n\t\t\t{ ! isLargeViewport && <BlockToolbar hideDragHandle /> }\n\t\t\t<BlockTools __unstableContentRef={ contentRef }>\n\t\t\t\t<KeyboardShortcuts />\n\t\t\t\t<EditorStyles\n\t\t\t\t\tstyles={ styles }\n\t\t\t\t\tscope=\":where(.editor-styles-wrapper)\"\n\t\t\t\t/>\n\t\t\t\t<BlockSelectionClearer>\n\t\t\t\t\t<WritingFlow ref={ contentRef }>\n\t\t\t\t\t\t<BlockList className=\"edit-widgets-main-block-list\" />\n\t\t\t\t\t</WritingFlow>\n\t\t\t\t</BlockSelectionClearer>\n\t\t\t</BlockTools>\n\t\t</div>\n\t);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useSelect","preferencesStore","useViewportMatch","useRef","useMemo","Notices","BlockToolbar","BlockTools","KeyboardShortcuts","EditorStyles","BlockSelectionClearer","WritingFlow","BlockList"],"sources":["../../../src/components/widget-areas-block-editor-content/index.jsx"],"sourcesContent":["import {\n\tBlockList,\n\tBlockToolbar,\n\tBlockTools,\n\tBlockSelectionClearer,\n\tWritingFlow,\n\t__unstableEditorStyles as EditorStyles,\n} from '@wordpress/block-editor';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo, useRef } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport Notices from '../notices';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\n\nexport default function WidgetAreasBlockEditorContent( {\n\tblockEditorSettings,\n} ) {\n\tconst hasThemeStyles = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'themeStyles'\n\t\t\t),\n\t\t[]\n\t);\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst contentRef = useRef();\n\n\tconst styles = useMemo( () => {\n\t\treturn hasThemeStyles ? blockEditorSettings.styles : [];\n\t}, [ blockEditorSettings, hasThemeStyles ] );\n\n\treturn (\n\t\t<div className=\"edit-widgets-block-editor\">\n\t\t\t<Notices />\n\t\t\t{ ! isLargeViewport && <BlockToolbar hideDragHandle /> }\n\t\t\t<BlockTools __unstableContentRef={ contentRef }>\n\t\t\t\t<KeyboardShortcuts />\n\t\t\t\t<EditorStyles\n\t\t\t\t\tstyles={ styles }\n\t\t\t\t\tscope=\":where(.editor-styles-wrapper)\"\n\t\t\t\t/>\n\t\t\t\t<BlockSelectionClearer>\n\t\t\t\t\t<WritingFlow ref={ contentRef }>\n\t\t\t\t\t\t<BlockList className=\"edit-widgets-main-block-list\" />\n\t\t\t\t\t</WritingFlow>\n\t\t\t\t</BlockSelectionClearer>\n\t\t\t</BlockTools>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,SAAwB,8BAA+B,EACtD,uBACG;CACH,MAAM,kBAAA,GAAiBA,gBAAAA,UAAAA,EACpB,WACD,CAAC,CAAE,OAAQC,uBAAAA,KAAiB,CAAC,CAAC,IAC7B,qBACA,aACD,GACD,CAAC,CACF;CACA,MAAM,mBAAA,GAAkBC,mBAAAA,iBAAAA,CAAkB,QAAS;CACnD,MAAM,cAAA,GAAaC,mBAAAA,OAAAA,CAAO;CAE1B,MAAM,UAAA,GAASC,mBAAAA,QAAAA,OAAe;EAC7B,OAAO,iBAAiB,oBAAoB,SAAS,CAAC;CACvD,GAAG,CAAE,qBAAqB,cAAe,CAAE;CAE3C,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,qBAAAA,SAAD,CAAU,CAAA;GACR,CAAE,mBAAmB,iBAAA,GAAA,kBAAA,IAAA,CAACC,wBAAAA,cAAD,EAAc,gBAAA,KAAgB,CAAA;GACrD,iBAAA,GAAA,kBAAA,KAAA,CAACC,wBAAAA,YAAD;IAAY,sBAAuB;IAAnC,UAAA;KACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,+BAAAA,SAAD,CAAoB,CAAA;KACpB,iBAAA,GAAA,kBAAA,IAAA,CAACC,wBAAAA,wBAAD;MACU;MACT,OAAM;KACN,CAAA;KACD,iBAAA,GAAA,kBAAA,IAAA,CAACC,wBAAAA,uBAAD,EAAA,UACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,wBAAAA,aAAD;MAAa,KAAM;MAClB,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,wBAAAA,WAAD,EAAW,WAAU,+BAAgC,CAAA;KACzC,CAAA,EACS,CAAA;IACZ;;EACR;;AAEP"}
|
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -34,14 +36,14 @@ let _wordpress_block_editor = require("@wordpress/block-editor");
|
|
|
34
36
|
let _wordpress_patterns = require("@wordpress/patterns");
|
|
35
37
|
let _wordpress_preferences = require("@wordpress/preferences");
|
|
36
38
|
let ___keyboard_shortcuts_index_js = require("../keyboard-shortcuts/index.cjs");
|
|
37
|
-
___keyboard_shortcuts_index_js = __toESM(___keyboard_shortcuts_index_js);
|
|
38
39
|
let ______store_utils_js = require("../../store/utils.cjs");
|
|
39
40
|
let ______hooks_use_last_selected_widget_area_js = require("../../hooks/use-last-selected-widget-area.cjs");
|
|
40
|
-
______hooks_use_last_selected_widget_area_js = __toESM(______hooks_use_last_selected_widget_area_js);
|
|
41
41
|
let ______store_index_js = require("../../store/index.cjs");
|
|
42
42
|
let ______constants_js = require("../../constants.cjs");
|
|
43
43
|
let ______lock_unlock_js = require("../../lock-unlock.cjs");
|
|
44
44
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
45
|
+
___keyboard_shortcuts_index_js = __toESM(___keyboard_shortcuts_index_js);
|
|
46
|
+
______hooks_use_last_selected_widget_area_js = __toESM(______hooks_use_last_selected_widget_area_js);
|
|
45
47
|
// packages/edit-widgets/src/components/widget-areas-block-editor-provider/index.jsx
|
|
46
48
|
const { ExperimentalBlockEditorProvider } = (0, ______lock_unlock_js.unlock)(_wordpress_block_editor.privateApis);
|
|
47
49
|
const { PatternsMenuItems } = (0, ______lock_unlock_js.unlock)(_wordpress_patterns.privateApis);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["unlock","blockEditorPrivateApis","editPatternsPrivateApis","useViewportMatch","useSelect","coreStore","ALLOW_REUSABLE_BLOCKS","preferencesStore","useDispatch","editWidgetsStore","useMemo","useLastSelectedWidgetArea","useEntityBlockEditor","KIND","POST_TYPE","buildWidgetAreasPostId","SlotFillProvider","KeyboardShortcuts"],"sources":["../../../src/components/widget-areas-block-editor-provider/index.jsx"],"sourcesContent":["import { SlotFillProvider } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { ALLOW_REUSABLE_BLOCKS } from '../../constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\thasUploadPermissions,\n\t\treusableBlocks,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\tselect( coreStore );\n\t\tconst siteSettings = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\thasUploadPermissions:\n\t\t\t\tcanUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'attachment',\n\t\t\t\t} ) ?? true,\n\t\t\treusableBlocks: ALLOW_REUSABLE_BLOCKS\n\t\t\t\t? getEntityRecords( 'postType', 'wp_block' )\n\t\t\t\t: EMPTY_ARRAY,\n\t\t\tisFixedToolbarActive: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\tconst { setIsInserterOpened } = useDispatch( editWidgetsStore );\n\n\tconst settings = useMemo( () => {\n\t\tlet mediaUploadBlockEditor;\n\t\tif ( hasUploadPermissions ) {\n\t\t\tmediaUploadBlockEditor = ( { onError, ...argumentsObject } ) => {\n\t\t\t\tuploadMedia( {\n\t\t\t\t\twpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,\n\t\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t\t...argumentsObject,\n\t\t\t\t} );\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...blockEditorSettings,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\thasFixedToolbar: isFixedToolbarActive || ! isLargeViewport,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\ttemplateLock: 'all',\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t};\n\t}, [\n\t\thasUploadPermissions,\n\t\tblockEditorSettings,\n\t\tisFixedToolbarActive,\n\t\tisLargeViewport,\n\t\tkeepCaretInsideBlock,\n\t\treusableBlocks,\n\t\tsetIsInserterOpened,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t] );\n\n\tconst widgetAreaId = useLastSelectedWidgetArea();\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\tKIND,\n\t\tPOST_TYPE,\n\t\t{ id: buildWidgetAreasPostId() }\n\t);\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<KeyboardShortcuts.Register />\n\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\tvalue={ blocks }\n\t\t\t\tonInput={ onInput }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tsettings={ settings }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t\t<PatternsMenuItems rootClientId={ widgetAreaId } />\n\t\t\t</ExperimentalBlockEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["unlock","blockEditorPrivateApis","editPatternsPrivateApis","useViewportMatch","useSelect","coreStore","ALLOW_REUSABLE_BLOCKS","preferencesStore","useDispatch","editWidgetsStore","useMemo","uploadMedia","useLastSelectedWidgetArea","useEntityBlockEditor","KIND","POST_TYPE","buildWidgetAreasPostId","SlotFillProvider","KeyboardShortcuts"],"sources":["../../../src/components/widget-areas-block-editor-provider/index.jsx"],"sourcesContent":["import { SlotFillProvider } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { ALLOW_REUSABLE_BLOCKS } from '../../constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\thasUploadPermissions,\n\t\treusableBlocks,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\tselect( coreStore );\n\t\tconst siteSettings = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\thasUploadPermissions:\n\t\t\t\tcanUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'attachment',\n\t\t\t\t} ) ?? true,\n\t\t\treusableBlocks: ALLOW_REUSABLE_BLOCKS\n\t\t\t\t? getEntityRecords( 'postType', 'wp_block' )\n\t\t\t\t: EMPTY_ARRAY,\n\t\t\tisFixedToolbarActive: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\tconst { setIsInserterOpened } = useDispatch( editWidgetsStore );\n\n\tconst settings = useMemo( () => {\n\t\tlet mediaUploadBlockEditor;\n\t\tif ( hasUploadPermissions ) {\n\t\t\tmediaUploadBlockEditor = ( { onError, ...argumentsObject } ) => {\n\t\t\t\tuploadMedia( {\n\t\t\t\t\twpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,\n\t\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t\t...argumentsObject,\n\t\t\t\t} );\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...blockEditorSettings,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\thasFixedToolbar: isFixedToolbarActive || ! isLargeViewport,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\ttemplateLock: 'all',\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t};\n\t}, [\n\t\thasUploadPermissions,\n\t\tblockEditorSettings,\n\t\tisFixedToolbarActive,\n\t\tisLargeViewport,\n\t\tkeepCaretInsideBlock,\n\t\treusableBlocks,\n\t\tsetIsInserterOpened,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t] );\n\n\tconst widgetAreaId = useLastSelectedWidgetArea();\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\tKIND,\n\t\tPOST_TYPE,\n\t\t{ id: buildWidgetAreasPostId() }\n\t);\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<KeyboardShortcuts.Register />\n\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\tvalue={ blocks }\n\t\t\t\tonInput={ onInput }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tsettings={ settings }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t\t<PatternsMenuItems rootClientId={ widgetAreaId } />\n\t\t\t</ExperimentalBlockEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAM,EAAE,qCAAA,GAAoCA,qBAAAA,OAAAA,CAAQC,wBAAAA,WAAuB;AAC3E,MAAM,EAAE,uBAAA,GAAsBD,qBAAAA,OAAAA,CAAQE,oBAAAA,WAAwB;AAE9D,MAAM,cAAc,CAAC;AAErB,SAAwB,+BAAgC,EACvD,qBACA,UACA,GAAG,SACA;CACH,MAAM,mBAAA,GAAkBC,mBAAAA,iBAAAA,CAAkB,QAAS;CACnD,MAAM,EACL,sBACA,gBACA,sBACA,sBACA,aACA,kBAAA,GACGC,gBAAAA,UAAAA,EAAa,WAAY;EAC5B,MAAM,EAAE,SAAS,iBAAiB,qBACjC,OAAQC,qBAAAA,KAAU;EACnB,MAAM,eAAe,QAAS,QAAQ;GACrC,MAAM;GACN,MAAM;EACP,CAAE,IACC,gBAAiB,QAAQ,MAAO,IAChC,KAAA;EACH,OAAO;GACN,sBACC,QAAS,UAAU;IAClB,MAAM;IACN,MAAM;GACP,CAAE,KAAK;GACR,gBAAgBC,mBAAAA,wBACb,iBAAkB,YAAY,UAAW,IACzC;GACH,sBAAsB,CAAC,CAAE,OAAQC,uBAAAA,KAAiB,CAAC,CAAC,IACnD,qBACA,cACD;GACA,sBAAsB,CAAC,CAAE,OAAQA,uBAAAA,KAAiB,CAAC,CAAC,IACnD,qBACA,sBACD;GACA,aAAa,cAAc;GAC3B,cAAc,cAAc;EAC7B;CACD,GAAG,CAAC,CAAE;CACN,MAAM,EAAE,yBAAA,GAAwBC,gBAAAA,YAAAA,CAAaC,qBAAAA,KAAiB;CAE9D,MAAM,YAAA,GAAWC,mBAAAA,QAAAA,OAAe;EAC/B,IAAI;EACJ,IAAK,sBACJ,0BAA2B,EAAE,SAAS,GAAG,sBAAuB;GAC/DC,CAAAA,GAAAA,uBAAAA,YAAAA,CAAa;IACZ,oBAAoB,oBAAoB;IACxC,UAAW,EAAE,cAAe,QAAS,OAAQ;IAC7C,GAAG;GACJ,CAAE;EACH;EAED,OAAO;GACN,GAAG;GACH,8BAA8B;GAC9B,iBAAiB,wBAAwB,CAAE;GAC3C;GACA,aAAa;GACb,cAAc;GACd,mCAAmC;GACnC;GACA;EACD;CACD,GAAG;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,CAAE;CAEF,MAAM,gBAAA,GAAeC,6CAAAA,QAAAA,CAA0B;CAE/C,MAAM,CAAE,QAAQ,SAAS,aAAA,GAAaC,qBAAAA,qBAAAA,CACrCC,qBAAAA,MACAC,qBAAAA,WACA,EAAE,KAAA,GAAIC,qBAAAA,uBAAAA,CAAuB,EAAE,CAChC;CAEA,OACC,iBAAA,GAAA,kBAAA,KAAA,CAACC,sBAAAA,kBAAD,EAAA,UAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,+BAAAA,QAAkB,UAAnB,CAA6B,CAAA,GAC7B,iBAAA,GAAA,kBAAA,KAAA,CAAC,iCAAD;EACC,OAAQ;EACE;EACC;EACA;EACX,gBAAiB;EACjB,GAAK;EANN,UAAA,CAQG,UACF,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAD,EAAmB,cAAe,aAAgB,CAAA,CAClB;CAChB,CAAA,CAAA,EAAA,CAAA;AAEpB"}
|
package/build/constants.cjs
CHANGED
|
@@ -5,8 +5,6 @@ Object.defineProperties(exports, {
|
|
|
5
5
|
});
|
|
6
6
|
// packages/edit-widgets/src/constants.js
|
|
7
7
|
const ALLOW_REUSABLE_BLOCKS = false;
|
|
8
|
-
const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;
|
|
9
8
|
exports.ALLOW_REUSABLE_BLOCKS = ALLOW_REUSABLE_BLOCKS;
|
|
10
|
-
exports.ENABLE_EXPERIMENTAL_FSE_BLOCKS = ENABLE_EXPERIMENTAL_FSE_BLOCKS;
|
|
11
9
|
|
|
12
10
|
//# sourceMappingURL=constants.cjs.map
|
package/build/constants.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.js"],"sourcesContent":["export const ALLOW_REUSABLE_BLOCKS = false;\
|
|
1
|
+
{"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.js"],"sourcesContent":["export const ALLOW_REUSABLE_BLOCKS = false;\n"],"mappings":";;;;;;AAAA,MAAa,wBAAwB"}
|
package/build/index.cjs
CHANGED
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -27,7 +29,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
29
|
let _wordpress_blocks = require("@wordpress/blocks");
|
|
28
30
|
let _wordpress_data = require("@wordpress/data");
|
|
29
31
|
let _wordpress_deprecated = require("@wordpress/deprecated");
|
|
30
|
-
_wordpress_deprecated = __toESM(_wordpress_deprecated);
|
|
31
32
|
let _wordpress_element = require("@wordpress/element");
|
|
32
33
|
let _wordpress_block_library = require("@wordpress/block-library");
|
|
33
34
|
let _wordpress_core_data = require("@wordpress/core-data");
|
|
@@ -36,11 +37,12 @@ let _wordpress_preferences = require("@wordpress/preferences");
|
|
|
36
37
|
let __store_index_js = require("./store/index.cjs");
|
|
37
38
|
require("./filters/index.cjs");
|
|
38
39
|
let __blocks_widget_area_index_js = require("./blocks/widget-area/index.cjs");
|
|
39
|
-
__blocks_widget_area_index_js = __toESM(__blocks_widget_area_index_js);
|
|
40
40
|
let __components_layout_index_jsx = require("./components/layout/index.cjs");
|
|
41
|
-
__components_layout_index_jsx = __toESM(__components_layout_index_jsx);
|
|
42
41
|
let __constants_js = require("./constants.cjs");
|
|
43
42
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
43
|
+
_wordpress_deprecated = __toESM(_wordpress_deprecated);
|
|
44
|
+
__blocks_widget_area_index_js = __toESM(__blocks_widget_area_index_js);
|
|
45
|
+
__components_layout_index_jsx = __toESM(__components_layout_index_jsx);
|
|
44
46
|
// packages/edit-widgets/src/index.jsx
|
|
45
47
|
const disabledBlocks = [
|
|
46
48
|
"core/more",
|
|
@@ -69,7 +71,7 @@ function initializeEditor(id, settings) {
|
|
|
69
71
|
(0, _wordpress_data.dispatch)(_wordpress_blocks.store).reapplyBlockTypeFilters();
|
|
70
72
|
(0, _wordpress_block_library.registerCoreBlocks)(coreBlocks);
|
|
71
73
|
(0, _wordpress_widgets.registerLegacyWidgetBlock)();
|
|
72
|
-
if (globalThis.IS_GUTENBERG_PLUGIN) (0, _wordpress_block_library.__experimentalRegisterExperimentalCoreBlocks)(
|
|
74
|
+
if (globalThis.IS_GUTENBERG_PLUGIN) (0, _wordpress_block_library.__experimentalRegisterExperimentalCoreBlocks)();
|
|
73
75
|
(0, _wordpress_widgets.registerLegacyWidgetVariations)(settings);
|
|
74
76
|
registerBlock(__blocks_widget_area_index_js);
|
|
75
77
|
(0, _wordpress_widgets.registerWidgetGroupBlock)();
|
package/build/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["ALLOW_REUSABLE_BLOCKS","createRoot","__experimentalGetCoreBlocks","preferencesStore","blocksStore","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["ALLOW_REUSABLE_BLOCKS","createRoot","__experimentalGetCoreBlocks","dispatch","preferencesStore","blocksStore","registerCoreBlocks","registerLegacyWidgetBlock","__experimentalRegisterExperimentalCoreBlocks","registerLegacyWidgetVariations","widgetArea","registerWidgetGroupBlock","fetchLinkSuggestions","setFreeformContentHandlerName","StrictMode","Layout","deprecated","unstable__bootstrapServerSideBlockDefinitions","registerBlockType"],"sources":["../src/index.jsx"],"sourcesContent":["import {\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 { StrictMode, 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';\nimport './store';\nimport './filters';\nimport * as widgetArea from './blocks/widget-area';\nimport Layout from './components/layout';\nimport { ALLOW_REUSABLE_BLOCKS } 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\tblock.name.startsWith( 'core/term' )\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 ).reapplyBlockTypeFilters();\n\tregisterCoreBlocks( coreBlocks );\n\tregisterLegacyWidgetBlock();\n\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks();\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(\n\t\t<StrictMode>\n\t\t\t<Layout blockEditorSettings={ settings } />\n\t\t</StrictMode>\n\t);\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,iBAAiB;CACtB;CACA;CACA;CACA,GAAKA,eAAAA,wBAAwB,CAAC,IAAI,CAAE,YAAa;AAClD;;;;;;;AAQA,SAAgB,iBAAkB,IAAI,UAAW;CAChD,MAAM,SAAS,SAAS,eAAgB,EAAG;CAC3C,MAAM,QAAA,GAAOC,mBAAAA,WAAAA,CAAY,MAAO;CAEhC,MAAM,cAAA,GAAaC,yBAAAA,4BAAAA,CAA4B,CAAC,CAAC,QAAU,UAAW;EACrE,OAAO,EACN,eAAe,SAAU,MAAM,IAAK,KACpC,MAAM,KAAK,WAAY,WAAY,KACnC,MAAM,KAAK,WAAY,YAAa,KACpC,MAAM,KAAK,WAAY,WAAY,KACnC,MAAM,KAAK,WAAY,iBAAkB,KACzC,MAAM,KAAK,WAAY,WAAY;CAErC,CAAE;CAEFC,CAAAA,GAAAA,gBAAAA,SAAAA,CAAUC,uBAAAA,KAAiB,CAAC,CAAC,YAAa,qBAAqB;EAC9D,cAAc;EACd,cAAc;EACd,sBAAsB;EACtB,aAAa;CACd,CAAE;CAEFD,CAAAA,GAAAA,gBAAAA,SAAAA,CAAUE,kBAAAA,KAAY,CAAC,CAAC,wBAAwB;CAChDC,CAAAA,GAAAA,yBAAAA,mBAAAA,CAAoB,UAAW;CAC/BC,CAAAA,GAAAA,mBAAAA,0BAAAA,CAA0B;CAC1B,IAAK,WAAW,qBACfC,CAAAA,GAAAA,yBAAAA,6CAAAA,CAA6C;CAE9CC,CAAAA,GAAAA,mBAAAA,+BAAAA,CAAgC,QAAS;CACzC,cAAeC,6BAAW;CAC1BC,CAAAA,GAAAA,mBAAAA,yBAAAA,CAAyB;CAEzB,SAAS,sCAAuC,QAAQ,mBAAA,GACvDC,qBAAAA,mCAAAA,CAAsB,QAAQ,eAAe,QAAS;CAMvDC,CAAAA,GAAAA,kBAAAA,8BAAAA,CAA+B,WAAY;CAE3C,KAAK,OACJ,iBAAA,GAAA,kBAAA,IAAA,CAACC,mBAAAA,YAAD,EAAA,UACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,8BAAAA,SAAD,EAAQ,qBAAsB,SAAY,CAAA,EAC/B,CAAA,CACb;CAEA,OAAO;AACR;;;;AAKA,MAAa,aAAa;AAE1B,SAAgB,qBAAqB;CACpCC,CAAAA,GAAAA,sBAAAA,QAAAA,CAAY,qCAAqC;EAChD,OAAO;EACP,SAAS;CACV,CAAE;AACH;;;;;;AAOA,MAAM,iBAAkB,UAAW;CAClC,IAAK,CAAE,OACN;CAED,MAAM,EAAE,UAAU,UAAU,SAAS;CACrC,IAAK,UACJC,CAAAA,GAAAA,kBAAAA,8CAAAA,CAA+C,GAAI,OAAQ,SAAS,CAAE;CAEvEC,CAAAA,GAAAA,kBAAAA,kBAAAA,CAAmB,MAAM,QAAS;AACnC"}
|
package/build/store/actions.cjs
CHANGED
|
@@ -41,7 +41,10 @@ const saveEditedWidgetAreas = () => async ({ select, dispatch, registry }) => {
|
|
|
41
41
|
await dispatch.saveWidgetAreas(editedWidgetAreas);
|
|
42
42
|
registry.dispatch(_wordpress_notices.store).createSuccessNotice((0, _wordpress_i18n.__)("Widgets saved."), { type: "snackbar" });
|
|
43
43
|
} catch (e) {
|
|
44
|
-
registry.dispatch(_wordpress_notices.store).createErrorNotice((0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)(
|
|
44
|
+
registry.dispatch(_wordpress_notices.store).createErrorNotice((0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)(
|
|
45
|
+
/** translators: %s: The error message. */
|
|
46
|
+
"There was an error. %s"
|
|
47
|
+
), e.message), { type: "snackbar" });
|
|
45
48
|
}
|
|
46
49
|
};
|
|
47
50
|
/**
|
|
@@ -65,7 +68,7 @@ const saveWidgetAreas = (widgetAreas) => async ({ dispatch, registry }) => {
|
|
|
65
68
|
* @param {string} widgetAreaId ID of the widget area to process.
|
|
66
69
|
* @return {Function} An action creator.
|
|
67
70
|
*/
|
|
68
|
-
const saveWidgetArea = (widgetAreaId) => async ({
|
|
71
|
+
const saveWidgetArea = (widgetAreaId) => async ({ select, registry }) => {
|
|
69
72
|
const widgets = select.getWidgets();
|
|
70
73
|
const post = registry.select(_wordpress_core_data.store).getEditedEntityRecord(__utils_js.KIND, __utils_js.POST_TYPE, (0, __utils_js.buildWidgetAreaPostId)(widgetAreaId));
|
|
71
74
|
const areaWidgets = Object.values(widgets).filter(({ sidebar }) => sidebar === widgetAreaId);
|
|
@@ -123,14 +126,15 @@ const saveWidgetArea = (widgetAreaId) => async ({ dispatch, select, registry })
|
|
|
123
126
|
if (registry.select(_wordpress_core_data.store).getLastEntitySaveError("root", "widget", widget.id)) failedWidgetNames.push(block.attributes?.name || block?.name);
|
|
124
127
|
if (!sidebarWidgetsIds[position]) sidebarWidgetsIds[position] = widget.id;
|
|
125
128
|
}
|
|
126
|
-
if (failedWidgetNames.length) throw new Error((0, _wordpress_i18n.sprintf)(
|
|
129
|
+
if (failedWidgetNames.length) throw new Error((0, _wordpress_i18n.sprintf)(
|
|
130
|
+
/** translators: %s: List of widget names */
|
|
131
|
+
(0, _wordpress_i18n.__)("Could not save the following widgets: %s."),
|
|
132
|
+
failedWidgetNames.join(", ")
|
|
133
|
+
));
|
|
127
134
|
registry.dispatch(_wordpress_core_data.store).editEntityRecord(__utils_js.KIND, __utils_js.WIDGET_AREA_ENTITY_TYPE, widgetAreaId, { widgets: sidebarWidgetsIds }, { undoIgnore: true });
|
|
128
|
-
dispatch(
|
|
135
|
+
await registry.dispatch(_wordpress_core_data.store).saveEditedEntityRecord(__utils_js.KIND, __utils_js.WIDGET_AREA_ENTITY_TYPE, widgetAreaId, { throwOnError: true });
|
|
129
136
|
registry.dispatch(_wordpress_core_data.store).receiveEntityRecords(__utils_js.KIND, __utils_js.POST_TYPE, post, void 0);
|
|
130
137
|
};
|
|
131
|
-
const trySaveWidgetArea = (widgetAreaId) => ({ registry }) => {
|
|
132
|
-
registry.dispatch(_wordpress_core_data.store).saveEditedEntityRecord(__utils_js.KIND, __utils_js.WIDGET_AREA_ENTITY_TYPE, widgetAreaId, { throwOnError: true });
|
|
133
|
-
};
|
|
134
138
|
/**
|
|
135
139
|
* Sets the clientId stored for a particular widgetId.
|
|
136
140
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.cjs","names":["createStubPost","coreStore","KIND","POST_TYPE","noticesStore","__","sprintf","WIDGET_AREA_ENTITY_TYPE","buildWidgetAreasQuery","buildWidgetAreaPostId","getWidgetIdFromBlock","transformBlockToWidget","interfaceStore","editWidgetsStoreName","blockEditorStore"],"sources":["../../src/store/actions.js"],"sourcesContent":["import { __, 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';\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\tconst claimedWidgetIds = new Set();\n\t\tfor ( let i = 0; i < widgetsBlocks.length; i++ ) {\n\t\t\tconst block = widgetsBlocks[ i ];\n\t\t\tlet widgetId = getWidgetIdFromBlock( block );\n\n\t\t\t// Splitting a block, e.g. pressing Enter in the middle of a\n\t\t\t// paragraph, copies all of its attributes to the new block,\n\t\t\t// including the widget ID, and the new block can then be moved to\n\t\t\t// another widget area. Only the first block with a given ID, in the\n\t\t\t// first widget area that holds it, updates that widget. Any other\n\t\t\t// block with the same ID is saved as a new widget.\n\t\t\tif ( widgetId ) {\n\t\t\t\tif (\n\t\t\t\t\tclaimedWidgetIds.has( widgetId ) ||\n\t\t\t\t\tselect.getWidgetAreaForWidgetId( widgetId )?.id !==\n\t\t\t\t\t\twidgetAreaId\n\t\t\t\t) {\n\t\t\t\t\twidgetId = undefined;\n\t\t\t\t\t// Drop the duplicate ID now, so nothing reads it before the\n\t\t\t\t\t// new widget's ID is written back after the batch.\n\t\t\t\t\tdelete block.attributes.__internalWidgetId;\n\t\t\t\t} else {\n\t\t\t\t\tclaimedWidgetIds.add( widgetId );\n\t\t\t\t}\n\t\t\t}\n\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\tblock.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\n/**\n * Returns an action object used to signal that widget saving is unlocked.\n *\n * @param {string} lockName The lock name.\n *\n * @example\n * ```js\n * import { store as widgetStore } from '@wordpress/edit-widgets';\n * import { useDispatch } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * \tconst { unlockWidgetSaving } = useDispatch( widgetStore );\n * \treturn (\n * \t\t<Button onClick={ () => unlockWidgetSaving( 'lockName' ) }>\n * \t\t\t{ __( 'Unlock Widget Saving' ) }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n * @return {Object} Action object\n */\nexport function unlockWidgetSaving( lockName ) {\n\treturn {\n\t\ttype: 'UNLOCK_WIDGET_SAVING',\n\t\tlockName,\n\t};\n}\n\n/**\n * Returns an action object used to signal that widget saving is locked.\n *\n * @param {string} lockName The lock name.\n *\n * @example\n * ```js\n * import { store as widgetStore } from '@wordpress/edit-widgets';\n * import { useDispatch } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * \tconst { lockWidgetSaving } = useDispatch( widgetStore );\n * \treturn (\n * \t\t<Button onClick={ () => lockWidgetSaving( 'lockName' ) }>\n * \t\t\t{ __( 'Lock Widget Saving' ) }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n * @return {Object} Action object\n */\nexport function lockWidgetSaving( lockName ) {\n\treturn {\n\t\ttype: 'LOCK_WIDGET_SAVING',\n\t\tlockName,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,mBACV,IAAI,YACJ,EAAE,eAAgB;CACnB,MAAM,YAAA,GAAWA,WAAAA,eAAAA,CAAgB,IAAI,MAAO;CAC5C,SACE,SAAUC,qBAAAA,KAAU,CAAC,CACrB,qBACAC,WAAAA,MACAC,WAAAA,WACA,UACA,EAAE,IAAI,SAAS,GAAG,GAClB,KACD;CACD,OAAO;AACR;;;;;;;;;AAUD,MAAa,8BAEZ,OAAQ,EAAE,QAAQ,UAAU,eAAgB;CAC3C,MAAM,oBAAoB,OAAO,qBAAqB;CACtD,IAAK,CAAE,mBAAmB,QACzB;CAED,IAAI;EACH,MAAM,SAAS,gBAAiB,iBAAkB;EAClD,SACE,SAAUC,mBAAAA,KAAa,CAAC,CACxB,qBAAA,GAAqBC,gBAAAA,GAAAA,CAAI,gBAAiB,GAAG,EAC7C,MAAM,WACP,CAAE;CACJ,SAAU,GAAI;EACb,SAAS,SAAUD,mBAAAA,KAAa,CAA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;AACD;;;;;;AAOA,MAAa,6BAEV,EAAE,eAAgB;CACnB,SACE,SAAUK,qBAAAA,KAAe,CAAC,CAC1B,yBAA0BC,eAAAA,UAAqB;AAClD;;;;;;;AAQD,MAAa,yBACV,UAAU,iBACZ,OAAQ,EAAE,UAAU,QAAQ,eAAgB;CAC3C,MAAM,qBAAqB,SACzB,OAAQC,wBAAAA,KAAiB,CAAC,CAC1B,qBAAsB,QAAS;CASjC,MAAM,0BAJc,SAAS,OAAQA,wBAAAA,KAAiB,CAAC,CAAC,UACX,CAAC,CAAC,MAC5C,EAAE,iBAAkB,WAAW,OAAO,YAEgB,CAAC,CAAC;CAM3D,MAAM,mBAHkC,SACtC,OAAQA,wBAAAA,KAAiB,CAAC,CAC1B,cAAe,uBACsC,CAAC,CAAC;CAOzD,IAAK,CAJ+B,OAAO,oBAC1C,uBAGgC,GAChC,SAAS,oBAAqB,yBAAyB,IAAK;CAI7D,SACE,SAAUA,wBAAAA,KAAiB,CAAC,CAC5B,qBACA,CAAE,QAAS,GACX,oBACA,yBACA,gBACD;AACF;;;;;;;;;;;;;;;;;;;;;;;AAwBD,SAAgB,mBAAoB,UAAW;CAC9C,OAAO;EACN,MAAM;EACN;CACD;AACD;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,iBAAkB,UAAW;CAC5C,OAAO;EACN,MAAM;EACN;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"actions.cjs","names":["createStubPost","coreStore","KIND","POST_TYPE","noticesStore","__","sprintf","WIDGET_AREA_ENTITY_TYPE","buildWidgetAreasQuery","buildWidgetAreaPostId","getWidgetIdFromBlock","transformBlockToWidget","interfaceStore","editWidgetsStoreName","blockEditorStore"],"sources":["../../src/store/actions.js"],"sourcesContent":["import { __, 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';\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 ( { 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\tconst claimedWidgetIds = new Set();\n\t\tfor ( let i = 0; i < widgetsBlocks.length; i++ ) {\n\t\t\tconst block = widgetsBlocks[ i ];\n\t\t\tlet widgetId = getWidgetIdFromBlock( block );\n\n\t\t\t// Splitting a block, e.g. pressing Enter in the middle of a\n\t\t\t// paragraph, copies all of its attributes to the new block,\n\t\t\t// including the widget ID, and the new block can then be moved to\n\t\t\t// another widget area. Only the first block with a given ID, in the\n\t\t\t// first widget area that holds it, updates that widget. Any other\n\t\t\t// block with the same ID is saved as a new widget.\n\t\t\tif ( widgetId ) {\n\t\t\t\tif (\n\t\t\t\t\tclaimedWidgetIds.has( widgetId ) ||\n\t\t\t\t\tselect.getWidgetAreaForWidgetId( widgetId )?.id !==\n\t\t\t\t\t\twidgetAreaId\n\t\t\t\t) {\n\t\t\t\t\twidgetId = undefined;\n\t\t\t\t\t// Drop the duplicate ID now, so nothing reads it before the\n\t\t\t\t\t// new widget's ID is written back after the batch.\n\t\t\t\t\tdelete block.attributes.__internalWidgetId;\n\t\t\t\t} else {\n\t\t\t\t\tclaimedWidgetIds.add( widgetId );\n\t\t\t\t}\n\t\t\t}\n\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\tblock.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\t// Sidebar and widget requests can both rewrite the sidebar lists. Finish\n\t\t// this write before saveWidgetAreas starts saving the next area.\n\t\tawait registry\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\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.receiveEntityRecords( KIND, POST_TYPE, post, undefined );\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\n/**\n * Returns an action object used to signal that widget saving is unlocked.\n *\n * @param {string} lockName The lock name.\n *\n * @example\n * ```js\n * import { store as widgetStore } from '@wordpress/edit-widgets';\n * import { useDispatch } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * \tconst { unlockWidgetSaving } = useDispatch( widgetStore );\n * \treturn (\n * \t\t<Button onClick={ () => unlockWidgetSaving( 'lockName' ) }>\n * \t\t\t{ __( 'Unlock Widget Saving' ) }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n * @return {Object} Action object\n */\nexport function unlockWidgetSaving( lockName ) {\n\treturn {\n\t\ttype: 'UNLOCK_WIDGET_SAVING',\n\t\tlockName,\n\t};\n}\n\n/**\n * Returns an action object used to signal that widget saving is locked.\n *\n * @param {string} lockName The lock name.\n *\n * @example\n * ```js\n * import { store as widgetStore } from '@wordpress/edit-widgets';\n * import { useDispatch } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * \tconst { lockWidgetSaving } = useDispatch( widgetStore );\n * \treturn (\n * \t\t<Button onClick={ () => lockWidgetSaving( 'lockName' ) }>\n * \t\t\t{ __( 'Lock Widget Saving' ) }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n * @return {Object} Action object\n */\nexport function lockWidgetSaving( lockName ) {\n\treturn {\n\t\ttype: 'LOCK_WIDGET_SAVING',\n\t\tlockName,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,mBACV,IAAI,YACJ,EAAE,eAAgB;CACnB,MAAM,YAAA,GAAWA,WAAAA,eAAAA,CAAgB,IAAI,MAAO;CAC5C,SACE,SAAUC,qBAAAA,KAAU,CAAA,CACpB,qBACAC,WAAAA,MACAC,WAAAA,WACA,UACA,EAAE,IAAI,SAAS,GAAG,GAClB,KACD;CACD,OAAO;AACR;;;;;;;;;AAUD,MAAa,8BAEZ,OAAQ,EAAE,QAAQ,UAAU,eAAgB;CAC3C,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,UAAU,QAAS;CACvD,OAAO;EACN,MAAM;EACN;EACA;CACD;AACD;;;;;;;;;;;;;AAcA,SAAgB,oBAAqB,OAAQ;CAC5C,OAAO;EACN,MAAM;EACN;CACD;AACD;;;;;;;AAQA,SAAgB,oBAAqB,QAAS;CAC7C,OAAO;EACN,MAAM;EACN;CACD;AACD;;;;;;AAOA,MAAa,6BAEV,EAAE,eAAgB;CACnB,SACE,SAAUS,qBAAAA,KAAe,CAAA,CACzB,yBAA0BC,eAAAA,UAAqB;AAClD;;;;;;;AAQD,MAAa,yBACV,UAAU,iBACZ,OAAQ,EAAE,UAAU,QAAQ,eAAgB;CAC3C,MAAM,qBAAqB,SACzB,OAAQC,wBAAAA,KAAiB,CAAA,CACzB,qBAAsB,QAAS;CASjC,MAAM,0BAJc,SAAS,OAAQA,wBAAAA,KAAiB,CAAC,CAAC,UACrB,CAAW,CAAC,MAC5C,EAAE,iBAAkB,WAAW,OAAO,YAET,CAA0B,CAAC;CAM3D,MAAM,mBAHkC,SACtC,OAAQA,wBAAAA,KAAiB,CAAA,CACzB,cAAe,uBACQ,CAA+B,CAAC;CAOzD,IAAK,CAJ+B,OAAO,oBAC1C,uBAGM,GACN,SAAS,oBAAqB,yBAAyB,IAAK;CAI7D,SACE,SAAUA,wBAAAA,KAAiB,CAAA,CAC3B,qBACA,CAAE,QAAS,GACX,oBACA,yBACA,gBACD;AACF;;;;;;;;;;;;;;;;;;;;;;;AAwBD,SAAgB,mBAAoB,UAAW;CAC9C,OAAO;EACN,MAAM;EACN;CACD;AACD;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,iBAAkB,UAAW;CAC5C,OAAO;EACN,MAAM;EACN;CACD;AACD"}
|
package/build/store/index.cjs
CHANGED
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -25,20 +27,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
27
|
enumerable: true
|
|
26
28
|
}) : target, mod));
|
|
27
29
|
let _wordpress_api_fetch = require("@wordpress/api-fetch");
|
|
28
|
-
_wordpress_api_fetch = __toESM(_wordpress_api_fetch);
|
|
29
30
|
let _wordpress_data = require("@wordpress/data");
|
|
30
31
|
let __reducer_js = require("./reducer.cjs");
|
|
31
|
-
__reducer_js = __toESM(__reducer_js);
|
|
32
32
|
let __resolvers_js = require("./resolvers.cjs");
|
|
33
|
-
__resolvers_js = __toESM(__resolvers_js);
|
|
34
33
|
let __selectors_js = require("./selectors.cjs");
|
|
35
|
-
__selectors_js = __toESM(__selectors_js);
|
|
36
34
|
let __actions_js = require("./actions.cjs");
|
|
37
|
-
__actions_js = __toESM(__actions_js);
|
|
38
35
|
let __private_selectors_js = require("./private-selectors.cjs");
|
|
39
|
-
__private_selectors_js = __toESM(__private_selectors_js);
|
|
40
36
|
let __constants_js = require("./constants.cjs");
|
|
41
37
|
let ___lock_unlock_js = require("../lock-unlock.cjs");
|
|
38
|
+
_wordpress_api_fetch = __toESM(_wordpress_api_fetch);
|
|
39
|
+
__reducer_js = __toESM(__reducer_js);
|
|
40
|
+
__resolvers_js = __toESM(__resolvers_js);
|
|
41
|
+
__selectors_js = __toESM(__selectors_js);
|
|
42
|
+
__actions_js = __toESM(__actions_js);
|
|
43
|
+
__private_selectors_js = __toESM(__private_selectors_js);
|
|
42
44
|
// packages/edit-widgets/src/store/index.js
|
|
43
45
|
/**
|
|
44
46
|
* Block editor data store configuration.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["createReduxStore","STORE_NAME","register","apiFetch","unlock","privateSelectors"],"sources":["../../src/store/index.js"],"sourcesContent":["import apiFetch from '@wordpress/api-fetch';\nimport { createReduxStore, register } from '@wordpress/data';\nimport reducer from './reducer';\nimport * as resolvers from './resolvers';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport * as privateSelectors from './private-selectors';\nimport { STORE_NAME } from './constants';\nimport { unlock } from '../lock-unlock';\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\nunlock( store ).registerPrivateSelectors( privateSelectors );\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["reducer","selectors","resolvers","actions","createReduxStore","STORE_NAME","register","apiFetch","unlock","privateSelectors"],"sources":["../../src/store/index.js"],"sourcesContent":["import apiFetch from '@wordpress/api-fetch';\nimport { createReduxStore, register } from '@wordpress/data';\nimport reducer from './reducer';\nimport * as resolvers from './resolvers';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport * as privateSelectors from './private-selectors';\nimport { STORE_NAME } from './constants';\nimport { unlock } from '../lock-unlock';\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\nunlock( store ).registerPrivateSelectors( privateSelectors );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAM,cAAc;CACnBA,SAAAA,aAAAA;CACAC,WAAAA;CACAC,WAAAA;CACAC,SAAAA;AACD;;;;;;;;AASA,MAAa,SAAA,GAAQC,gBAAAA,iBAAAA,CAAkBC,eAAAA,YAAY,WAAY;CAC/DC,GAAAA,gBAAAA,SAAAA,CAAU,KAAM;AAKhBC,qBAAAA,QAAS,IAAK,SAAW,SAAS,MAAO;CACxC,IAAK,QAAQ,MAAM,QAAS,0BAA2B,MAAM,GAC5D,OAAO,QAAQ,QAAS,CAAC,CAAE;CAG5B,OAAO,KAAM,OAAQ;AACtB,CAAE;CAEFC,GAAAA,kBAAAA,OAAAA,CAAQ,KAAM,CAAC,CAAC,yBAA0BC,sBAAiB"}
|
|
@@ -10,6 +10,7 @@ let _wordpress_block_editor = require("@wordpress/block-editor");
|
|
|
10
10
|
let __utils_js = require("./utils.cjs");
|
|
11
11
|
let __constants_js = require("./constants.cjs");
|
|
12
12
|
// packages/edit-widgets/src/store/selectors.js
|
|
13
|
+
/** @typedef {import('@wordpress/blocks').Block} Block */
|
|
13
14
|
const EMPTY_INSERTION_POINT = {
|
|
14
15
|
rootClientId: void 0,
|
|
15
16
|
insertionIndex: void 0
|
|
@@ -60,7 +61,8 @@ const getWidgetAreaForWidgetId = (0, _wordpress_data.createRegistrySelector)((se
|
|
|
60
61
|
*
|
|
61
62
|
* @param {string} clientId The client id of a block in a widget area.
|
|
62
63
|
*
|
|
63
|
-
* @return {
|
|
64
|
+
* @return {Block | null} The widget area block.
|
|
65
|
+
* @type {(state: Record<string, unknown>, clientId: string) => Block | null}
|
|
64
66
|
*/
|
|
65
67
|
const getParentWidgetAreaBlock = (0, _wordpress_data.createRegistrySelector)((select) => (state, clientId) => {
|
|
66
68
|
const { getBlock, getBlockName, getBlockParents } = select(_wordpress_block_editor.store);
|