@wordpress/edit-site 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -1
- package/build/components/block-editor/index.js +3 -2
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/editor/index.js +4 -16
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +20 -5
- package/build/components/global-styles/block-preview-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +0 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/custom-css.js +1 -0
- package/build/components/global-styles/custom-css.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +3 -2
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +0 -1
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-block.js +2 -6
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-border.js +4 -0
- package/build/components/global-styles/screen-border.js.map +1 -1
- package/build/components/global-styles/screen-button-color.js +0 -2
- package/build/components/global-styles/screen-button-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +4 -0
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-heading-color.js +1 -3
- package/build/components/global-styles/screen-heading-color.js.map +1 -1
- package/build/components/global-styles/screen-layout.js +4 -0
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +0 -1
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-root.js +7 -2
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +0 -1
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +4 -0
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +17 -5
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/utils.js +11 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +10 -41
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/layout/index.js +52 -83
- package/build/components/layout/index.js.map +1 -1
- package/build/components/sidebar/index.js +5 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +3 -1
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js +10 -0
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +1 -31
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +3 -22
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/site-hub/index.js +149 -0
- package/build/components/site-hub/index.js.map +1 -0
- package/build/components/use-edited-entity-record/index.js +60 -0
- package/build/components/use-edited-entity-record/index.js.map +1 -0
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +144 -0
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -0
- package/build/index.js +5 -0
- package/build/index.js.map +1 -1
- package/build-module/components/block-editor/index.js +3 -2
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +1 -12
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +19 -5
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +0 -1
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/custom-css.js +1 -0
- package/build-module/components/global-styles/custom-css.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +3 -2
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +0 -1
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +2 -5
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +3 -0
- package/build-module/components/global-styles/screen-border.js.map +1 -1
- package/build-module/components/global-styles/screen-button-color.js +0 -2
- package/build-module/components/global-styles/screen-button-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +3 -0
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-heading-color.js +1 -3
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
- package/build-module/components/global-styles/screen-layout.js +3 -0
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +0 -1
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +8 -3
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +0 -1
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +3 -0
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +17 -5
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/utils.js +9 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +10 -38
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/layout/index.js +51 -81
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +4 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +3 -1
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js +11 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +2 -27
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +5 -23
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +126 -0
- package/build-module/components/site-hub/index.js.map +1 -0
- package/build-module/components/use-edited-entity-record/index.js +48 -0
- package/build-module/components/use-edited-entity-record/index.js.map +1 -0
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +132 -0
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -0
- package/build-module/index.js +4 -0
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +106 -113
- package/build-style/style.css +106 -113
- package/package.json +30 -29
- package/src/components/block-editor/index.js +3 -5
- package/src/components/editor/index.js +1 -16
- package/src/components/global-styles/block-preview-panel.js +24 -9
- package/src/components/global-styles/border-panel.js +0 -1
- package/src/components/global-styles/custom-css.js +1 -0
- package/src/components/global-styles/global-styles-provider.js +11 -5
- package/src/components/global-styles/screen-background-color.js +0 -1
- package/src/components/global-styles/screen-block.js +1 -4
- package/src/components/global-styles/screen-border.js +2 -0
- package/src/components/global-styles/screen-button-color.js +0 -2
- package/src/components/global-styles/screen-colors.js +3 -0
- package/src/components/global-styles/screen-heading-color.js +1 -3
- package/src/components/global-styles/screen-layout.js +2 -0
- package/src/components/global-styles/screen-link-color.js +0 -1
- package/src/components/global-styles/screen-root.js +34 -27
- package/src/components/global-styles/screen-text-color.js +0 -1
- package/src/components/global-styles/screen-typography.js +3 -0
- package/src/components/global-styles/test/typography-utils.js +72 -23
- package/src/components/global-styles/typography-utils.js +24 -4
- package/src/components/global-styles/utils.js +10 -1
- package/src/components/header-edit-mode/document-actions/index.js +18 -37
- package/src/components/header-edit-mode/style.scss +1 -0
- package/src/components/layout/index.js +122 -165
- package/src/components/layout/style.scss +70 -63
- package/src/components/list/style.scss +1 -8
- package/src/components/sidebar/index.js +4 -1
- package/src/components/sidebar-edit-mode/index.js +1 -1
- package/src/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js +10 -0
- package/src/components/sidebar-navigation-screen/style.scss +2 -4
- package/src/components/sidebar-navigation-screen-main/index.js +1 -29
- package/src/components/sidebar-navigation-screen-templates/index.js +9 -27
- package/src/components/site-hub/index.js +150 -0
- package/src/components/site-hub/style.scss +31 -0
- package/src/components/use-edited-entity-record/index.js +37 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/push-changes-to-global-styles/index.js +162 -0
- package/src/hooks/push-changes-to-global-styles/style.scss +4 -0
- package/src/index.js +2 -0
- package/src/style.scss +2 -0
- package/build/components/site-title/index.js +0 -55
- package/build/components/site-title/index.js.map +0 -1
- package/build-module/components/site-title/index.js +0 -43
- package/build-module/components/site-title/index.js.map +0 -1
- package/src/components/site-title/index.js +0 -39
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/index.js"],"names":["createSlotFill","PanelBody","isRTL","__","drawerLeft","drawerRight","useEffect","Fragment","useSelect","useDispatch","store","interfaceStore","blockEditorStore","DefaultSidebar","GlobalStylesSidebar","NavigationMenuSidebar","STORE_NAME","SettingsHeader","TemplateCard","SIDEBAR_BLOCK","SIDEBAR_TEMPLATE","editSiteStore","Slot","InspectorSlot","Fill","InspectorFill","SidebarInspectorFill","SidebarComplementaryAreaFills","sidebar","isEditorSidebarOpened","hasBlockSelection","supportsGlobalStyles","select","_sidebar","getActiveComplementaryArea","_isEditorSidebarOpened","includes","settings","getSettings","getBlockSelectionStart","supportsTemplatePartsMode","enableComplementaryArea","sidebarName","MaybeNavigationMenuSidebar","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/index.js"],"names":["createSlotFill","PanelBody","isRTL","__","drawerLeft","drawerRight","useEffect","Fragment","useSelect","useDispatch","store","interfaceStore","blockEditorStore","DefaultSidebar","GlobalStylesSidebar","NavigationMenuSidebar","STORE_NAME","SettingsHeader","TemplateCard","SIDEBAR_BLOCK","SIDEBAR_TEMPLATE","editSiteStore","Slot","InspectorSlot","Fill","InspectorFill","SidebarInspectorFill","SidebarComplementaryAreaFills","sidebar","isEditorSidebarOpened","hasBlockSelection","supportsGlobalStyles","select","_sidebar","getActiveComplementaryArea","_isEditorSidebarOpened","includes","settings","getSettings","getBlockSelectionStart","supportsTemplatePartsMode","enableComplementaryArea","sidebarName","MaybeNavigationMenuSidebar","window","__experimentalEnableOffCanvasNavigationEditor"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,cAAT,EAAyBC,SAAzB,QAA0C,uBAA1C;AACA,SAASC,KAAT,EAAgBC,EAAhB,QAA0B,iBAA1B;AACA,SAASC,UAAT,EAAqBC,WAArB,QAAwC,kBAAxC;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,oBAApC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,cAAlB,QAAwC,sBAAxC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,OAAOC,qBAAP,MAAkC,2BAAlC;AACA,SAASC,UAAT,QAA2B,uBAA3B;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,SAASC,aAAT,EAAwBC,gBAAxB,QAAgD,aAAhD;AACA,SAASV,KAAK,IAAIW,aAAlB,QAAuC,aAAvC;AAEA,MAAM;AAAEC,EAAAA,IAAI,EAAEC,aAAR;AAAuBC,EAAAA,IAAI,EAAEC;AAA7B,IAA+CzB,cAAc,CAClE,0BADkE,CAAnE;AAGA,OAAO,MAAM0B,oBAAoB,GAAGD,aAA7B;AAEP,OAAO,S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,GApC8C,CAsC/C;AACA;AACA;;;AACA,MAAIuB,0BAA0B,GAAGpC,QAAjC;;AAEA,MAAK,YAAAqC,MAAM,UAAN,0CAAQC,6CAAR,MAA0D,IAA/D,EAAsE;AACrEF,IAAAA,0BAA0B,GAAG5B,qBAA7B;AACA;;AAED,SACC,8BACC,cAAC,cAAD;AACC,IAAA,UAAU,EAAG2B,WADd;AAEC,IAAA,KAAK,EAAGvC,EAAE,CAAE,UAAF,CAFX;AAGC,IAAA,IAAI,EAAGD,KAAK,KAAKE,UAAL,GAAkBC,WAH/B;AAIC,IAAA,UAAU,EAAGF,EAAE,CAAE,wBAAF,CAJhB;AAKC,IAAA,MAAM,EAAG,cAAC,cAAD;AAAgB,MAAA,WAAW,EAAGuC;AAA9B,MALV;AAMC,IAAA,eAAe,EAAC;AANjB,KAQGA,WAAW,KAAKtB,gBAAhB,IACD,cAAC,SAAD,QACC,cAAC,YAAD,OADD,CATF,EAaGsB,WAAW,KAAKvB,aAAhB,IACD,cAAC,aAAD;AAAe,IAAA,gBAAgB;AAA/B,IAdF,CADD,EAkBGY,oBAAoB,IAAI,cAAC,mBAAD,OAlB3B,EAmBC,cAAC,0BAAD,OAnBD,CADD;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSlotFill, PanelBody } from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { useEffect, Fragment } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport DefaultSidebar from './default-sidebar';\nimport GlobalStylesSidebar from './global-styles-sidebar';\nimport NavigationMenuSidebar from './navigation-menu-sidebar';\nimport { STORE_NAME } from '../../store/constants';\nimport SettingsHeader from './settings-header';\nimport TemplateCard from './template-card';\nimport { SIDEBAR_BLOCK, SIDEBAR_TEMPLATE } from './constants';\nimport { store as editSiteStore } from '../../store';\n\nconst { Slot: InspectorSlot, Fill: InspectorFill } = createSlotFill(\n\t'EditSiteSidebarInspector'\n);\nexport const SidebarInspectorFill = InspectorFill;\n\nexport function SidebarComplementaryAreaFills() {\n\tconst {\n\t\tsidebar,\n\t\tisEditorSidebarOpened,\n\t\thasBlockSelection,\n\t\tsupportsGlobalStyles,\n\t} = useSelect( ( select ) => {\n\t\tconst _sidebar =\n\t\t\tselect( interfaceStore ).getActiveComplementaryArea( STORE_NAME );\n\t\tconst _isEditorSidebarOpened = [\n\t\t\tSIDEBAR_BLOCK,\n\t\t\tSIDEBAR_TEMPLATE,\n\t\t].includes( _sidebar );\n\t\tconst settings = select( editSiteStore ).getSettings();\n\t\treturn {\n\t\t\tsidebar: _sidebar,\n\t\t\tisEditorSidebarOpened: _isEditorSidebarOpened,\n\t\t\thasBlockSelection:\n\t\t\t\t!! select( blockEditorStore ).getBlockSelectionStart(),\n\t\t\tsupportsGlobalStyles: ! settings?.supportsTemplatePartsMode,\n\t\t};\n\t}, [] );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tuseEffect( () => {\n\t\tif ( ! isEditorSidebarOpened ) return;\n\t\tif ( hasBlockSelection ) {\n\t\t\tenableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK );\n\t\t} else {\n\t\t\tenableComplementaryArea( STORE_NAME, SIDEBAR_TEMPLATE );\n\t\t}\n\t}, [ hasBlockSelection, isEditorSidebarOpened ] );\n\n\tlet sidebarName = sidebar;\n\tif ( ! isEditorSidebarOpened ) {\n\t\tsidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_TEMPLATE;\n\t}\n\n\t// Conditionally include NavMenu sidebar in Plugin only.\n\t// Optimise for dead code elimination.\n\t// See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.\n\tlet MaybeNavigationMenuSidebar = Fragment;\n\n\tif ( window?.__experimentalEnableOffCanvasNavigationEditor === true ) {\n\t\tMaybeNavigationMenuSidebar = NavigationMenuSidebar;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DefaultSidebar\n\t\t\t\tidentifier={ sidebarName }\n\t\t\t\ttitle={ __( 'Settings' ) }\n\t\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\t\tcloseLabel={ __( 'Close settings sidebar' ) }\n\t\t\t\theader={ <SettingsHeader sidebarName={ sidebarName } /> }\n\t\t\t\theaderClassName=\"edit-site-sidebar-edit-mode__panel-tabs\"\n\t\t\t>\n\t\t\t\t{ sidebarName === SIDEBAR_TEMPLATE && (\n\t\t\t\t\t<PanelBody>\n\t\t\t\t\t\t<TemplateCard />\n\t\t\t\t\t</PanelBody>\n\t\t\t\t) }\n\t\t\t\t{ sidebarName === SIDEBAR_BLOCK && (\n\t\t\t\t\t<InspectorSlot bubblesVirtually />\n\t\t\t\t) }\n\t\t\t</DefaultSidebar>\n\t\t\t{ supportsGlobalStyles && <GlobalStylesSidebar /> }\n\t\t\t<MaybeNavigationMenuSidebar />\n\t\t</>\n\t);\n}\n"]}
|
package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { __experimentalListView as ListView, store as blockEditorStore } from '@wordpress/block-editor';
|
|
6
|
+
import { __experimentalListView as ListView, __experimentalOffCanvasEditor as OffCanvasEditor, store as blockEditorStore } from '@wordpress/block-editor';
|
|
7
7
|
import { useEffect } from '@wordpress/element';
|
|
8
8
|
import { useDispatch } from '@wordpress/data';
|
|
9
9
|
const ALLOWED_BLOCKS = {
|
|
@@ -13,6 +13,8 @@ const ALLOWED_BLOCKS = {
|
|
|
13
13
|
'core/navigation-link': ['core/navigation-link', 'core/navigation-submenu']
|
|
14
14
|
};
|
|
15
15
|
export default function NavigationMenu(_ref) {
|
|
16
|
+
var _window;
|
|
17
|
+
|
|
16
18
|
let {
|
|
17
19
|
innerBlocks,
|
|
18
20
|
id
|
|
@@ -34,6 +36,14 @@ export default function NavigationMenu(_ref) {
|
|
|
34
36
|
}
|
|
35
37
|
});
|
|
36
38
|
}, [updateBlockListSettings, innerBlocks]);
|
|
39
|
+
|
|
40
|
+
if ((_window = window) !== null && _window !== void 0 && _window.__experimentalEnableOffCanvasNavigationEditor) {
|
|
41
|
+
return createElement(OffCanvasEditor, {
|
|
42
|
+
blocks: innerBlocks,
|
|
43
|
+
selectBlockInCanvas: false
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
37
47
|
return createElement(ListView, {
|
|
38
48
|
id: id
|
|
39
49
|
});
|
package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js"],"names":["__experimentalListView","ListView","store","blockEditorStore","useEffect","useDispatch","ALLOWED_BLOCKS","NavigationMenu","innerBlocks","id","updateBlockListSettings","allowedBlocks","forEach","block","name","clientId"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,sBAAsB,IAAIC,QAD3B,EAECC,KAAK,IAAIC,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js"],"names":["__experimentalListView","ListView","__experimentalOffCanvasEditor","OffCanvasEditor","store","blockEditorStore","useEffect","useDispatch","ALLOWED_BLOCKS","NavigationMenu","innerBlocks","id","updateBlockListSettings","allowedBlocks","forEach","block","name","clientId","window","__experimentalEnableOffCanvasNavigationEditor"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,sBAAsB,IAAIC,QAD3B,EAECC,6BAA6B,IAAIC,eAFlC,EAGCC,KAAK,IAAIC,gBAHV,QAIO,yBAJP;AAKA,SAASC,SAAT,QAA0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ACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalListView as ListView,\n\t__experimentalOffCanvasEditor as OffCanvasEditor,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\nconst ALLOWED_BLOCKS = {\n\t'core/navigation': [\n\t\t'core/navigation-link',\n\t\t'core/search',\n\t\t'core/social-links',\n\t\t'core/page-list',\n\t\t'core/spacer',\n\t\t'core/home-link',\n\t\t'core/site-title',\n\t\t'core/site-logo',\n\t\t'core/navigation-submenu',\n\t],\n\t'core/social-links': [ 'core/social-link' ],\n\t'core/navigation-submenu': [\n\t\t'core/navigation-link',\n\t\t'core/navigation-submenu',\n\t],\n\t'core/navigation-link': [\n\t\t'core/navigation-link',\n\t\t'core/navigation-submenu',\n\t],\n};\n\nexport default function NavigationMenu( { innerBlocks, id } ) {\n\tconst { updateBlockListSettings } = useDispatch( blockEditorStore );\n\n\t//TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList\n\t//Think through a better way of doing this, possible with adding allowed blocks to block library metadata\n\tuseEffect( () => {\n\t\tupdateBlockListSettings( '', {\n\t\t\tallowedBlocks: ALLOWED_BLOCKS[ 'core/navigation' ],\n\t\t} );\n\t\tinnerBlocks.forEach( ( block ) => {\n\t\t\tif ( ALLOWED_BLOCKS[ block.name ] ) {\n\t\t\t\tupdateBlockListSettings( block.clientId, {\n\t\t\t\t\tallowedBlocks: ALLOWED_BLOCKS[ block.name ],\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}, [ updateBlockListSettings, innerBlocks ] );\n\n\tif ( window?.__experimentalEnableOffCanvasNavigationEditor ) {\n\t\treturn (\n\t\t\t<OffCanvasEditor\n\t\t\t\tblocks={ innerBlocks }\n\t\t\t\tselectBlockInCanvas={ false }\n\t\t\t/>\n\t\t);\n\t}\n\treturn <ListView id={ id } />;\n}\n"]}
|
|
@@ -3,44 +3,19 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { __experimentalItemGroup as ItemGroup,
|
|
6
|
+
import { __experimentalItemGroup as ItemGroup, __experimentalNavigatorButton as NavigatorButton } from '@wordpress/components';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
import { layout, symbolFilled } from '@wordpress/icons';
|
|
9
|
-
import { useDispatch } from '@wordpress/data';
|
|
10
|
-
import { useViewportMatch } from '@wordpress/compose';
|
|
11
9
|
/**
|
|
12
10
|
* Internal dependencies
|
|
13
11
|
*/
|
|
14
12
|
|
|
15
13
|
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
16
14
|
import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
17
|
-
import { useLocation } from '../routes';
|
|
18
|
-
import { store as editSiteStore } from '../../store';
|
|
19
|
-
import getIsListPage from '../../utils/get-is-list-page';
|
|
20
15
|
export default function SidebarNavigationScreenMain() {
|
|
21
|
-
const {
|
|
22
|
-
params
|
|
23
|
-
} = useLocation();
|
|
24
|
-
const isListPage = getIsListPage(params);
|
|
25
|
-
const isEditorPage = !isListPage;
|
|
26
|
-
const {
|
|
27
|
-
__unstableSetCanvasMode
|
|
28
|
-
} = useDispatch(editSiteStore);
|
|
29
|
-
const isMobileViewport = useViewportMatch('medium', '<');
|
|
30
16
|
return createElement(SidebarNavigationScreen, {
|
|
31
17
|
path: "/",
|
|
32
|
-
title:
|
|
33
|
-
justify: "space-between",
|
|
34
|
-
style: {
|
|
35
|
-
minHeight: 36
|
|
36
|
-
}
|
|
37
|
-
}, createElement("div", null, __('Design')), !isMobileViewport && isEditorPage && createElement(Button, {
|
|
38
|
-
className: "edit-site-layout__edit-button",
|
|
39
|
-
label: __('Open the editor'),
|
|
40
|
-
onClick: () => {
|
|
41
|
-
__unstableSetCanvasMode('edit');
|
|
42
|
-
}
|
|
43
|
-
}, __('Edit'))),
|
|
18
|
+
title: __('Design'),
|
|
44
19
|
content: createElement(ItemGroup, null, createElement(NavigatorButton, {
|
|
45
20
|
as: SidebarNavigationItem,
|
|
46
21
|
path: "/templates",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-main/index.js"],"names":["__experimentalItemGroup","ItemGroup","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-main/index.js"],"names":["__experimentalItemGroup","ItemGroup","__experimentalNavigatorButton","NavigatorButton","__","layout","symbolFilled","SidebarNavigationScreen","SidebarNavigationItem","SidebarNavigationScreenMain"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,uBAAuB,IAAIC,SAD5B,EAECC,6BAA6B,IAAIC,eAFlC,QAGO,uBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,YAAjB,QAAqC,kBAArC;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AAEA,eAAe,SAASC,2BAAT,GAAuC;AACrD,SACC,cAAC,uBAAD;AACC,IAAA,IAAI,EAAC,GADN;AAEC,IAAA,KAAK,EAAGL,EAAE,CAAE,QAAF,CAFX;AAGC,IAAA,OAAO,EACN,cAAC,SAAD,QACC,cAAC,eAAD;AACC,MAAA,EAAE,EAAGI,qBADN;AAEC,MAAA,IAAI,EAAC,YAFN;AAGC,MAAA,WAAW,MAHZ;AAIC,MAAA,IAAI,EAAGH;AAJR,OAMGD,EAAE,CAAE,WAAF,CANL,CADD,EASC,cAAC,eAAD;AACC,MAAA,EAAE,EAAGI,qBADN;AAEC,MAAA,IAAI,EAAC,iBAFN;AAGC,MAAA,WAAW,MAHZ;AAIC,MAAA,IAAI,EAAGF;AAJR,OAMGF,EAAE,CAAE,gBAAF,CANL,CATD;AAJF,IADD;AA0BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalNavigatorButton as NavigatorButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { layout, symbolFilled } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\n\nexport default function SidebarNavigationScreenMain() {\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tpath=\"/\"\n\t\t\ttitle={ __( 'Design' ) }\n\t\t\tcontent={\n\t\t\t\t<ItemGroup>\n\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\tpath=\"/templates\"\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ layout }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Templates' ) }\n\t\t\t\t\t</NavigatorButton>\n\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\tpath=\"/template-parts\"\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ symbolFilled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Template Parts' ) }\n\t\t\t\t\t</NavigatorButton>\n\t\t\t\t</ItemGroup>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -4,9 +4,9 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
4
4
|
/**
|
|
5
5
|
* WordPress dependencies
|
|
6
6
|
*/
|
|
7
|
-
import { __experimentalItemGroup as ItemGroup, __experimentalHStack as HStack
|
|
7
|
+
import { __experimentalItemGroup as ItemGroup, __experimentalHStack as HStack } from '@wordpress/components';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
|
-
import {
|
|
9
|
+
import { useSelect } from '@wordpress/data';
|
|
10
10
|
import { useEntityRecords } from '@wordpress/core-data';
|
|
11
11
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
12
12
|
import { useViewportMatch } from '@wordpress/compose';
|
|
@@ -19,7 +19,6 @@ import { useLink } from '../routes/link';
|
|
|
19
19
|
import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
20
20
|
import { useLocation } from '../routes';
|
|
21
21
|
import { store as editSiteStore } from '../../store';
|
|
22
|
-
import getIsListPage from '../../utils/get-is-list-page';
|
|
23
22
|
import AddNewTemplate from '../add-new-template';
|
|
24
23
|
|
|
25
24
|
function omit(object, keys) {
|
|
@@ -67,12 +66,7 @@ export default function SidebarNavigationScreenTemplates(_ref3) {
|
|
|
67
66
|
const {
|
|
68
67
|
params
|
|
69
68
|
} = useLocation();
|
|
70
|
-
const
|
|
71
|
-
__unstableSetCanvasMode
|
|
72
|
-
} = useDispatch(editSiteStore);
|
|
73
|
-
const isMobileViewport = useViewportMatch('medium', '<');
|
|
74
|
-
const isListPage = getIsListPage(params);
|
|
75
|
-
const isEditorPage = !isListPage; // Ideally the URL params would be enough.
|
|
69
|
+
const isMobileViewport = useViewportMatch('medium', '<'); // Ideally the URL params would be enough.
|
|
76
70
|
// Loading the editor should ideally redirect to the home page
|
|
77
71
|
// instead of fetching the edited entity here.
|
|
78
72
|
|
|
@@ -125,29 +119,17 @@ export default function SidebarNavigationScreenTemplates(_ref3) {
|
|
|
125
119
|
path: config[postType].path,
|
|
126
120
|
parentTitle: __('Design'),
|
|
127
121
|
title: createElement(HStack, {
|
|
128
|
-
style: {
|
|
129
|
-
minHeight: 36
|
|
130
|
-
},
|
|
131
122
|
justify: "space-between"
|
|
132
123
|
}, createElement("div", {
|
|
133
124
|
style: {
|
|
134
125
|
flexShrink: 0
|
|
135
126
|
}
|
|
136
|
-
}, config[postType].labels.title), !isMobileViewport && createElement(
|
|
137
|
-
spacing: 2,
|
|
138
|
-
justify: "right"
|
|
139
|
-
}, createElement(AddNewTemplate, {
|
|
127
|
+
}, config[postType].labels.title), !isMobileViewport && createElement(AddNewTemplate, {
|
|
140
128
|
templateType: postType,
|
|
141
129
|
toggleProps: {
|
|
142
130
|
className: 'edit-site-sidebar-navigation-screen-templates__add-button'
|
|
143
131
|
}
|
|
144
|
-
}),
|
|
145
|
-
className: "edit-site-layout__edit-button",
|
|
146
|
-
label: __('Open the editor'),
|
|
147
|
-
onClick: () => {
|
|
148
|
-
__unstableSetCanvasMode('edit');
|
|
149
|
-
}
|
|
150
|
-
}, __('Edit')))),
|
|
132
|
+
})),
|
|
151
133
|
content: createElement(Fragment, null, createElement(ItemGroup, null, items.map((item, index) => createElement(Item, {
|
|
152
134
|
item: item,
|
|
153
135
|
key: index
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates/index.js"],"names":["__experimentalItemGroup","ItemGroup","__experimentalHStack","HStack","Button","__","useDispatch","useSelect","useEntityRecords","decodeEntities","useViewportMatch","SidebarNavigationScreen","useLink","SidebarNavigationItem","useLocation","store","editSiteStore","getIsListPage","AddNewTemplate","omit","object","keys","Object","fromEntries","entries","filter","key","includes","Item","item","linkInfo","params","props","config","wp_template","path","labels","title","loading","notFound","manage","wp_template_part","SidebarNavigationScreenTemplates","postType","__unstableSetCanvasMode","isMobileViewport","isListPage","isEditorPage","editedPostId","editedPostType","select","getEditedPostType","getEditedPostId","records","templates","isResolving","isLoading","per_page","items","children","map","template","postId","id","rendered","slug","undefined","minHeight","flexShrink","className","index"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,uBAAuB,IAAIC,SAD5B,EAECC,oBAAoB,IAAIC,MAFzB,EAGCC,MAHD,QAIO,uBAJP;AAKA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,SAASC,OAAT,QAAwB,gBAAxB;AACA,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ACGnC,MAAM,CAAEU,QAAF,CAAN,CAAmBP,MAAnB,CAA0BC,KAD7B,CADD,EAIG,CAAEQ,gBAAF,IACD,cAAC,MAAD;AAAQ,MAAA,OAAO,EAAG,CAAlB;AAAsB,MAAA,OAAO,EAAC;AAA9B,OACC,cAAC,cAAD;AACC,MAAA,YAAY,EAAGF,QADhB;AAEC,MAAA,WAAW,EAAG;AACb0B,QAAAA,SAAS,EACR;AAFY;AAFf,MADD,EAQGtB,YAAY,IACb,cAAC,MAAD;AACC,MAAA,SAAS,EAAC,+BADX;AAEC,MAAA,KAAK,EAAG1C,EAAE,CAAE,iBAAF,CAFX;AAGC,MAAA,OAAO,EAAG,MAAM;AACfuC,QAAAA,uBAAuB,CAAE,MAAF,CAAvB;AACA;AALF,OAOGvC,EAAE,CAAE,MAAF,CAPL,CATF,CALF,CAJF;AAgCC,IAAA,OAAO,EACN,8BACC,cAAC,SAAD,QACGqD,KAAK,CAACE,GAAN,CAAW,CAAE/B,IAAF,EAAQyC,KAAR,KACZ,cAAC,IAAD;AAAM,MAAA,IAAI,EAAGzC,IAAb;AAAoB,MAAA,GAAG,EAAGyC;AAA1B,MADC,CADH,EAKC,cAAC,qBAAD;AACC,MAAA,SAAS,EAAC;AADX,OAEM1D,OAAO,CAAE;AACb+B,MAAAA,QADa;AAEbmB,MAAAA,MAAM,EAAEI;AAFK,KAAF,CAFb;AAMC,sBACCnC,MAAM,CAACY,QAAP,KAAoBA,QAApB,IAAgC,CAAEZ,MAAM,CAAC+B,MAAzC,GACG,MADH,GAEGI,SATL;AAWC,MAAA,QAAQ,EAAGjC,MAAM,CAAEU,QAAF,CAAN,CAAmBP,MAAnB,CAA0BI;AAXtC,OALD,CADD;AAjCF,IADD;AA0DA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n\tButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport { useLink } from '../routes/link';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport { useLocation } from '../routes';\nimport { store as editSiteStore } from '../../store';\nimport getIsListPage from '../../utils/get-is-list-page';\nimport AddNewTemplate from '../add-new-template';\n\nfunction omit( object, keys ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( object ).filter( ( [ key ] ) => ! keys.includes( key ) )\n\t);\n}\n\nconst Item = ( { item } ) => {\n\tconst linkInfo = useLink( item.params );\n\tconst props = item.params\n\t\t? { ...omit( item, 'params' ), ...linkInfo }\n\t\t: item;\n\treturn <SidebarNavigationItem { ...props } />;\n};\n\nconst config = {\n\twp_template: {\n\t\tpath: '/templates',\n\t\tlabels: {\n\t\t\ttitle: __( 'Templates' ),\n\t\t\tloading: __( 'Loading templates' ),\n\t\t\tnotFound: __( 'No templates found' ),\n\t\t\tmanage: __( 'Manage all templates' ),\n\t\t},\n\t},\n\twp_template_part: {\n\t\tpath: '/template-parts',\n\t\tlabels: {\n\t\t\ttitle: __( 'Template parts' ),\n\t\t\tloading: __( 'Loading template parts' ),\n\t\t\tnotFound: __( 'No template parts found' ),\n\t\t\tmanage: __( 'Manage all template parts' ),\n\t\t},\n\t},\n};\n\nexport default function SidebarNavigationScreenTemplates( {\n\tpostType = 'wp_template',\n} ) {\n\tconst { params } = useLocation();\n\tconst { __unstableSetCanvasMode } = useDispatch( editSiteStore );\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isListPage = getIsListPage( params );\n\tconst isEditorPage = ! isListPage;\n\n\t// Ideally the URL params would be enough.\n\t// Loading the editor should ideally redirect to the home page\n\t// instead of fetching the edited entity here.\n\tconst { editedPostId, editedPostType } = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId } = select( editSiteStore );\n\t\treturn {\n\t\t\teditedPostId: getEditedPostId(),\n\t\t\teditedPostType: getEditedPostType(),\n\t\t};\n\t}, [] );\n\n\tconst { records: templates, isResolving: isLoading } = useEntityRecords(\n\t\t'postType',\n\t\tpostType,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\n\tlet items = [];\n\tif ( isLoading ) {\n\t\titems = [\n\t\t\t{\n\t\t\t\tchildren: config[ postType ].labels.loading,\n\t\t\t},\n\t\t];\n\t} else if ( ! templates && ! isLoading ) {\n\t\titems = [\n\t\t\t{\n\t\t\t\tchildren: config[ postType ].labels.notFound,\n\t\t\t},\n\t\t];\n\t} else {\n\t\titems = templates?.map( ( template ) => ( {\n\t\t\tparams: {\n\t\t\t\tpostType,\n\t\t\t\tpostId: template.id,\n\t\t\t},\n\t\t\tchildren: decodeEntities(\n\t\t\t\ttemplate.title?.rendered || template.slug\n\t\t\t),\n\t\t\t'aria-current':\n\t\t\t\t( params.postType === postType &&\n\t\t\t\t\tparams.postId === template.id ) ||\n\t\t\t\t// This is a special case for the home page.\n\t\t\t\t( editedPostId === template.id &&\n\t\t\t\t\teditedPostType === postType &&\n\t\t\t\t\t!! params.postId )\n\t\t\t\t\t? 'page'\n\t\t\t\t\t: undefined,\n\t\t} ) );\n\t}\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tpath={ config[ postType ].path }\n\t\t\tparentTitle={ __( 'Design' ) }\n\t\t\ttitle={\n\t\t\t\t<HStack style={ { minHeight: 36 } } justify=\"space-between\">\n\t\t\t\t\t<div style={ { flexShrink: 0 } }>\n\t\t\t\t\t\t{ config[ postType ].labels.title }\n\t\t\t\t\t</div>\n\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t<HStack spacing={ 2 } justify=\"right\">\n\t\t\t\t\t\t\t<AddNewTemplate\n\t\t\t\t\t\t\t\ttemplateType={ postType }\n\t\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\t\t'edit-site-sidebar-navigation-screen-templates__add-button',\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{ isEditorPage && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-layout__edit-button\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Open the editor' ) }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t__unstableSetCanvasMode( 'edit' );\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\t\t{ __( 'Edit' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t}\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t{ items.map( ( item, index ) => (\n\t\t\t\t\t\t\t<Item item={ item } key={ index } />\n\t\t\t\t\t\t) ) }\n\n\t\t\t\t\t\t<SidebarNavigationItem\n\t\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen-templates__see-all\"\n\t\t\t\t\t\t\t{ ...useLink( {\n\t\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\t\tpostId: undefined,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\taria-current={\n\t\t\t\t\t\t\t\tparams.postType === postType && ! params.postId\n\t\t\t\t\t\t\t\t\t? 'page'\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tchildren={ config[ postType ].labels.manage }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ItemGroup>\n\t\t\t\t</>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates/index.js"],"names":["__experimentalItemGroup","ItemGroup","__experimentalHStack","HStack","__","useSelect","useEntityRecords","decodeEntities","useViewportMatch","SidebarNavigationScreen","useLink","SidebarNavigationItem","useLocation","store","editSiteStore","AddNewTemplate","omit","object","keys","Object","fromEntries","entries","filter","key","includes","Item","item","linkInfo","params","props","config","wp_template","path","labels","title","loading","notFound","manage","wp_template_part","SidebarNavigationScreenTemplates","postType","isMobileViewport","editedPostId","editedPostType","select","getEditedPostType","getEditedPostId","records","templates","isResolving","isLoading","per_page","items","children","map","template","postId","id","rendered","slug","undefined","flexShrink","className","index"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,uBAAuB,IAAIC,SAD5B,EAECC,oBAAoB,IAAIC,MAFzB,QAGO,uBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,SAASC,OAAT,QAAwB,gBAAxB;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,SAASC,WAAT,QAA4B,WAA5B;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AACA,OAAOC,cAAP,MAA2B,qBAA3B;;AAEA,SAASC,IAAT,CAAeC,MAAf,EAAuBC,IAAvB,EAA8B;AAC7B,SAAOC,MAAM,CAACC,WAAP,CACND,MAAM,CAACE,OAAP,CAAgBJ,MAAhB,EAAyBK,MAAzB,CAAiC;AAAA,QAAE,CAAEC,GAAF,CAAF;AAAA,WAAe,CAAEL,IAAI,CAACM,QAAL,CAAeD,GAAf,CAAjB;AAAA,GAAjC,CADM,CAAP;AAGA;;AAED,MAAME,IAAI,GAAG,SAAgB;AAAA,MAAd;AAAEC,IAAAA;AAAF,GAAc;AAC5B,QAAMC,QAAQ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sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport { useLink } from '../routes/link';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport { useLocation } from '../routes';\nimport { store as editSiteStore } from '../../store';\nimport AddNewTemplate from '../add-new-template';\n\nfunction omit( object, keys ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( object ).filter( ( [ key ] ) => ! keys.includes( key ) )\n\t);\n}\n\nconst Item = ( { item } ) => {\n\tconst linkInfo = useLink( item.params );\n\tconst props = item.params\n\t\t? { ...omit( item, 'params' ), ...linkInfo }\n\t\t: item;\n\treturn <SidebarNavigationItem { ...props } />;\n};\n\nconst config = {\n\twp_template: {\n\t\tpath: '/templates',\n\t\tlabels: {\n\t\t\ttitle: __( 'Templates' ),\n\t\t\tloading: __( 'Loading templates' ),\n\t\t\tnotFound: __( 'No templates found' ),\n\t\t\tmanage: __( 'Manage all templates' ),\n\t\t},\n\t},\n\twp_template_part: {\n\t\tpath: '/template-parts',\n\t\tlabels: {\n\t\t\ttitle: __( 'Template parts' ),\n\t\t\tloading: __( 'Loading template parts' ),\n\t\t\tnotFound: __( 'No template parts found' ),\n\t\t\tmanage: __( 'Manage all template parts' ),\n\t\t},\n\t},\n};\n\nexport default function SidebarNavigationScreenTemplates( {\n\tpostType = 'wp_template',\n} ) {\n\tconst { params } = useLocation();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\n\t// Ideally the URL params would be enough.\n\t// Loading the editor should ideally redirect to the home page\n\t// instead of fetching the edited entity here.\n\tconst { editedPostId, editedPostType } = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId } = select( editSiteStore );\n\t\treturn {\n\t\t\teditedPostId: getEditedPostId(),\n\t\t\teditedPostType: getEditedPostType(),\n\t\t};\n\t}, [] );\n\n\tconst { records: templates, isResolving: isLoading } = useEntityRecords(\n\t\t'postType',\n\t\tpostType,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\n\tlet items = [];\n\tif ( isLoading ) {\n\t\titems = [\n\t\t\t{\n\t\t\t\tchildren: config[ postType ].labels.loading,\n\t\t\t},\n\t\t];\n\t} else if ( ! templates && ! isLoading ) {\n\t\titems = [\n\t\t\t{\n\t\t\t\tchildren: config[ postType ].labels.notFound,\n\t\t\t},\n\t\t];\n\t} else {\n\t\titems = templates?.map( ( template ) => ( {\n\t\t\tparams: {\n\t\t\t\tpostType,\n\t\t\t\tpostId: template.id,\n\t\t\t},\n\t\t\tchildren: decodeEntities(\n\t\t\t\ttemplate.title?.rendered || template.slug\n\t\t\t),\n\t\t\t'aria-current':\n\t\t\t\t( params.postType === postType &&\n\t\t\t\t\tparams.postId === template.id ) ||\n\t\t\t\t// This is a special case for the home page.\n\t\t\t\t( editedPostId === template.id &&\n\t\t\t\t\teditedPostType === postType &&\n\t\t\t\t\t!! params.postId )\n\t\t\t\t\t? 'page'\n\t\t\t\t\t: undefined,\n\t\t} ) );\n\t}\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tpath={ config[ postType ].path }\n\t\t\tparentTitle={ __( 'Design' ) }\n\t\t\ttitle={\n\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t<div style={ { flexShrink: 0 } }>\n\t\t\t\t\t\t{ config[ postType ].labels.title }\n\t\t\t\t\t</div>\n\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t<AddNewTemplate\n\t\t\t\t\t\t\ttemplateType={ postType }\n\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\t'edit-site-sidebar-navigation-screen-templates__add-button',\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</HStack>\n\t\t\t}\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t{ items.map( ( item, index ) => (\n\t\t\t\t\t\t\t<Item item={ item } key={ index } />\n\t\t\t\t\t\t) ) }\n\n\t\t\t\t\t\t<SidebarNavigationItem\n\t\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen-templates__see-all\"\n\t\t\t\t\t\t\t{ ...useLink( {\n\t\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\t\tpostId: undefined,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\taria-current={\n\t\t\t\t\t\t\t\tparams.postType === postType && ! params.postId\n\t\t\t\t\t\t\t\t\t? 'page'\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tchildren={ config[ postType ].labels.manage }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ItemGroup>\n\t\t\t\t</>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { createElement } from "@wordpress/element";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* External dependencies
|
|
6
|
+
*/
|
|
7
|
+
import classnames from 'classnames';
|
|
8
|
+
/**
|
|
9
|
+
* WordPress dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
13
|
+
import { Button, __unstableMotion as motion, __experimentalHStack as HStack, __experimentalVStack as VStack } from '@wordpress/components';
|
|
14
|
+
import { useReducedMotion, useViewportMatch } from '@wordpress/compose';
|
|
15
|
+
import { __ } from '@wordpress/i18n';
|
|
16
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
17
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { store as editSiteStore } from '../../store';
|
|
23
|
+
import { useLocation } from '../routes';
|
|
24
|
+
import getIsListPage from '../../utils/get-is-list-page';
|
|
25
|
+
import SiteIcon from '../site-icon';
|
|
26
|
+
import useEditedEntityRecord from '../use-edited-entity-record';
|
|
27
|
+
const HUB_ANIMATION_DURATION = 0.3;
|
|
28
|
+
|
|
29
|
+
function SiteHub(_ref) {
|
|
30
|
+
let {
|
|
31
|
+
className,
|
|
32
|
+
isMobileCanvasVisible,
|
|
33
|
+
setIsMobileCanvasVisible
|
|
34
|
+
} = _ref;
|
|
35
|
+
const {
|
|
36
|
+
params
|
|
37
|
+
} = useLocation();
|
|
38
|
+
const isListPage = getIsListPage(params);
|
|
39
|
+
const isEditorPage = !isListPage;
|
|
40
|
+
const {
|
|
41
|
+
canvasMode,
|
|
42
|
+
dashboardLink,
|
|
43
|
+
entityConfig
|
|
44
|
+
} = useSelect(select => {
|
|
45
|
+
select(editSiteStore).getEditedPostType();
|
|
46
|
+
const {
|
|
47
|
+
__unstableGetCanvasMode,
|
|
48
|
+
getSettings,
|
|
49
|
+
getEditedPostType
|
|
50
|
+
} = select(editSiteStore);
|
|
51
|
+
return {
|
|
52
|
+
canvasMode: __unstableGetCanvasMode(),
|
|
53
|
+
dashboardLink: getSettings().__experimentalDashboardLink,
|
|
54
|
+
entityConfig: select(coreStore).getEntityConfig('postType', getEditedPostType())
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
57
|
+
const disableMotion = useReducedMotion();
|
|
58
|
+
const isMobileViewport = useViewportMatch('medium', '<');
|
|
59
|
+
const {
|
|
60
|
+
__unstableSetCanvasMode
|
|
61
|
+
} = useDispatch(editSiteStore);
|
|
62
|
+
const {
|
|
63
|
+
clearSelectedBlock
|
|
64
|
+
} = useDispatch(blockEditorStore);
|
|
65
|
+
const showEditButton = isEditorPage && canvasMode === 'view' && !isMobileViewport || isMobileViewport && canvasMode === 'view' && isMobileCanvasVisible;
|
|
66
|
+
const isBackToDashboardButton = !isMobileViewport && canvasMode === 'view' || isMobileViewport && !isMobileCanvasVisible;
|
|
67
|
+
const showLabels = canvasMode !== 'edit';
|
|
68
|
+
const siteIconButtonProps = isBackToDashboardButton ? {
|
|
69
|
+
href: dashboardLink || 'index.php',
|
|
70
|
+
'aria-label': __('Go back to the dashboard')
|
|
71
|
+
} : {
|
|
72
|
+
label: __('Open Navigation Sidebar'),
|
|
73
|
+
onClick: () => {
|
|
74
|
+
clearSelectedBlock();
|
|
75
|
+
setIsMobileCanvasVisible(false);
|
|
76
|
+
|
|
77
|
+
__unstableSetCanvasMode('view');
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const {
|
|
81
|
+
getTitle
|
|
82
|
+
} = useEditedEntityRecord();
|
|
83
|
+
return createElement(motion.div, {
|
|
84
|
+
className: classnames('edit-site-site-hub', className),
|
|
85
|
+
layout: true,
|
|
86
|
+
transition: {
|
|
87
|
+
type: 'tween',
|
|
88
|
+
duration: disableMotion ? 0 : HUB_ANIMATION_DURATION,
|
|
89
|
+
ease: 'easeOut'
|
|
90
|
+
}
|
|
91
|
+
}, createElement(HStack, {
|
|
92
|
+
justify: "flex-start",
|
|
93
|
+
className: "edit-site-site-hub__text-content"
|
|
94
|
+
}, createElement(motion.div, {
|
|
95
|
+
className: "edit-site-site-hub__view-mode-toggle-container",
|
|
96
|
+
layout: true,
|
|
97
|
+
transition: {
|
|
98
|
+
type: 'tween',
|
|
99
|
+
duration: disableMotion ? 0 : HUB_ANIMATION_DURATION,
|
|
100
|
+
ease: 'easeOut'
|
|
101
|
+
}
|
|
102
|
+
}, createElement(Button, _extends({}, siteIconButtonProps, {
|
|
103
|
+
className: "edit-site-layout__view-mode-toggle"
|
|
104
|
+
}), createElement(SiteIcon, {
|
|
105
|
+
className: "edit-site-layout__view-mode-toggle-icon"
|
|
106
|
+
}))), showLabels && createElement(VStack, {
|
|
107
|
+
spacing: 0
|
|
108
|
+
}, createElement("div", {
|
|
109
|
+
className: "edit-site-site-hub__title"
|
|
110
|
+
}, getTitle()), createElement("div", {
|
|
111
|
+
className: "edit-site-site-hub__post-type"
|
|
112
|
+
}, entityConfig === null || entityConfig === void 0 ? void 0 : entityConfig.label))), showEditButton && createElement(Button, {
|
|
113
|
+
className: "edit-site-site-hub__edit-button",
|
|
114
|
+
label: __('Open the editor'),
|
|
115
|
+
onClick: () => {
|
|
116
|
+
__unstableSetCanvasMode('edit');
|
|
117
|
+
},
|
|
118
|
+
variant: "primary"
|
|
119
|
+
}, __('Edit')), isMobileViewport && !isMobileCanvasVisible && createElement(Button, {
|
|
120
|
+
onClick: () => setIsMobileCanvasVisible(true),
|
|
121
|
+
variant: "primary"
|
|
122
|
+
}, __('View Editor')));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export default SiteHub;
|
|
126
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/site-hub/index.js"],"names":["classnames","useSelect","useDispatch","Button","__unstableMotion","motion","__experimentalHStack","HStack","__experimentalVStack","VStack","useReducedMotion","useViewportMatch","__","store","blockEditorStore","coreStore","editSiteStore","useLocation","getIsListPage","SiteIcon","useEditedEntityRecord","HUB_ANIMATION_DURATION","SiteHub","className","isMobileCanvasVisible","setIsMobileCanvasVisible","params","isListPage","isEditorPage","canvasMode","dashboardLink","entityConfig","select","getEditedPostType","__unstableGetCanvasMode","getSettings","__experimentalDashboardLink","getEntityConfig","disableMotion","isMobileViewport","__unstableSetCanvasMode","clearSelectedBlock","showEditButton","isBackToDashboardButton","showLabels","siteIconButtonProps","href","label","onClick","getTitle","type","duration","ease"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoB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;;AAED,eAAeU,OAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__unstableMotion as motion,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useReducedMotion, useViewportMatch } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { useLocation } from '../routes';\nimport getIsListPage from '../../utils/get-is-list-page';\nimport SiteIcon from '../site-icon';\nimport useEditedEntityRecord from '../use-edited-entity-record';\n\nconst HUB_ANIMATION_DURATION = 0.3;\n\nfunction SiteHub( {\n\tclassName,\n\tisMobileCanvasVisible,\n\tsetIsMobileCanvasVisible,\n} ) {\n\tconst { params } = useLocation();\n\tconst isListPage = getIsListPage( params );\n\tconst isEditorPage = ! isListPage;\n\tconst { canvasMode, dashboardLink, entityConfig } = useSelect(\n\t\t( select ) => {\n\t\t\tselect( editSiteStore ).getEditedPostType();\n\t\t\tconst { __unstableGetCanvasMode, getSettings, getEditedPostType } =\n\t\t\t\tselect( editSiteStore );\n\t\t\treturn {\n\t\t\t\tcanvasMode: __unstableGetCanvasMode(),\n\t\t\t\tdashboardLink: getSettings().__experimentalDashboardLink,\n\t\t\t\tentityConfig: select( coreStore ).getEntityConfig(\n\t\t\t\t\t'postType',\n\t\t\t\t\tgetEditedPostType()\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst disableMotion = useReducedMotion();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst { __unstableSetCanvasMode } = useDispatch( editSiteStore );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst showEditButton =\n\t\t( isEditorPage && canvasMode === 'view' && ! isMobileViewport ) ||\n\t\t( isMobileViewport && canvasMode === 'view' && isMobileCanvasVisible );\n\tconst isBackToDashboardButton =\n\t\t( ! isMobileViewport && canvasMode === 'view' ) ||\n\t\t( isMobileViewport && ! isMobileCanvasVisible );\n\tconst showLabels = canvasMode !== 'edit';\n\tconst siteIconButtonProps = isBackToDashboardButton\n\t\t? {\n\t\t\t\thref: dashboardLink || 'index.php',\n\t\t\t\t'aria-label': __( 'Go back to the dashboard' ),\n\t\t }\n\t\t: {\n\t\t\t\tlabel: __( 'Open Navigation Sidebar' ),\n\t\t\t\tonClick: () => {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\tsetIsMobileCanvasVisible( false );\n\t\t\t\t\t__unstableSetCanvasMode( 'view' );\n\t\t\t\t},\n\t\t };\n\tconst { getTitle } = useEditedEntityRecord();\n\n\treturn (\n\t\t<motion.div\n\t\t\tclassName={ classnames( 'edit-site-site-hub', className ) }\n\t\t\tlayout\n\t\t\ttransition={ {\n\t\t\t\ttype: 'tween',\n\t\t\t\tduration: disableMotion ? 0 : HUB_ANIMATION_DURATION,\n\t\t\t\tease: 'easeOut',\n\t\t\t} }\n\t\t>\n\t\t\t<HStack\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tclassName=\"edit-site-site-hub__text-content\"\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"edit-site-site-hub__view-mode-toggle-container\"\n\t\t\t\t\tlayout\n\t\t\t\t\ttransition={ {\n\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\tduration: disableMotion ? 0 : HUB_ANIMATION_DURATION,\n\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t{ ...siteIconButtonProps }\n\t\t\t\t\t\tclassName=\"edit-site-layout__view-mode-toggle\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<SiteIcon className=\"edit-site-layout__view-mode-toggle-icon\" />\n\t\t\t\t\t</Button>\n\t\t\t\t</motion.div>\n\n\t\t\t\t{ showLabels && (\n\t\t\t\t\t<VStack spacing={ 0 }>\n\t\t\t\t\t\t<div className=\"edit-site-site-hub__title\">\n\t\t\t\t\t\t\t{ getTitle() }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"edit-site-site-hub__post-type\">\n\t\t\t\t\t\t\t{ entityConfig?.label }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</VStack>\n\t\t\t\t) }\n\t\t\t</HStack>\n\n\t\t\t{ showEditButton && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"edit-site-site-hub__edit-button\"\n\t\t\t\t\tlabel={ __( 'Open the editor' ) }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t__unstableSetCanvasMode( 'edit' );\n\t\t\t\t\t} }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\n\t\t\t{ isMobileViewport && ! isMobileCanvasVisible && (\n\t\t\t\t<Button\n\t\t\t\t\tonClick={ () => setIsMobileCanvasVisible( true ) }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'View Editor' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</motion.div>\n\t);\n}\n\nexport default SiteHub;\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
7
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { store as editSiteStore } from '../../store';
|
|
13
|
+
export default function useEditedEntityRecord() {
|
|
14
|
+
const {
|
|
15
|
+
record,
|
|
16
|
+
title,
|
|
17
|
+
isLoaded
|
|
18
|
+
} = useSelect(select => {
|
|
19
|
+
const {
|
|
20
|
+
getEditedPostType,
|
|
21
|
+
getEditedPostId
|
|
22
|
+
} = select(editSiteStore);
|
|
23
|
+
const {
|
|
24
|
+
getEditedEntityRecord
|
|
25
|
+
} = select(coreStore);
|
|
26
|
+
const {
|
|
27
|
+
__experimentalGetTemplateInfo: getTemplateInfo
|
|
28
|
+
} = select(editorStore);
|
|
29
|
+
const postType = getEditedPostType();
|
|
30
|
+
const postId = getEditedPostId();
|
|
31
|
+
|
|
32
|
+
const _record = getEditedEntityRecord('postType', postType, postId);
|
|
33
|
+
|
|
34
|
+
const _isLoaded = !!postId;
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
record: _record,
|
|
38
|
+
title: getTemplateInfo(_record).title,
|
|
39
|
+
isLoaded: _isLoaded
|
|
40
|
+
};
|
|
41
|
+
}, []);
|
|
42
|
+
return {
|
|
43
|
+
isLoaded,
|
|
44
|
+
record,
|
|
45
|
+
getTitle: () => title ? decodeEntities(title) : null
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/use-edited-entity-record/index.js"],"names":["useSelect","store","coreStore","editorStore","decodeEntities","editSiteStore","useEditedEntityRecord","record","title","isLoaded","select","getEditedPostType","getEditedPostId","getEditedEntityRecord","__experimentalGetTemplateInfo","getTemplateInfo","postType","postId","_record","_isLoaded","getTitle"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,mBAArC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AAEA;AACA;AACA;;AACA,SAASH,KAAK,IAAII,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,qBAAT,GAAiC;AAC/C,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,KAAV;AAAiBC,IAAAA;AAAjB,MAA8BT,SAAS,CAAIU,MAAF,IAAc;AAC5D,UAAM;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,QAAyCF,MAAM,CAAEL,aAAF,CAArD;AACA,UAAM;AAAEQ,MAAAA;AAAF,QAA4BH,MAAM,CAAER,SAAF,CAAxC;AACA,UAAM;AAAEY,MAAAA,6BAA6B,EAAEC;AAAjC,QACLL,MAAM,CAAEP,WAAF,CADP;AAEA,UAAMa,QAAQ,GAAGL,iBAAiB,EAAlC;AACA,UAAMM,MAAM,GAAGL,eAAe,EAA9B;;AACA,UAAMM,OAAO,GAAGL,qBAAqB,CAAE,UAAF,EAAcG,QAAd,EAAwBC,MAAxB,CAArC;;AACA,UAAME,SAAS,GAAG,CAAC,CAAEF,MAArB;;AAEA,WAAO;AACNV,MAAAA,MAAM,EAAEW,OADF;AAENV,MAAAA,KAAK,EAAEO,eAAe,CAAEG,OAAF,CAAf,CAA2BV,KAF5B;AAGNC,MAAAA,QAAQ,EAAEU;AAHJ,KAAP;AAKA,GAf4C,EAe1C,EAf0C,CAA7C;AAiBA,SAAO;AACNV,IAAAA,QADM;AAENF,IAAAA,MAFM;AAGNa,IAAAA,QAAQ,EAAE,MAAQZ,KAAK,GAAGJ,cAAc,CAAEI,KAAF,CAAjB,GAA6B;AAH9C,GAAP;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function useEditedEntityRecord() {\n\tconst { record, title, isLoaded } = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId } = select( editSiteStore );\n\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } =\n\t\t\tselect( editorStore );\n\t\tconst postType = getEditedPostType();\n\t\tconst postId = getEditedPostId();\n\t\tconst _record = getEditedEntityRecord( 'postType', postType, postId );\n\t\tconst _isLoaded = !! postId;\n\n\t\treturn {\n\t\t\trecord: _record,\n\t\t\ttitle: getTemplateInfo( _record ).title,\n\t\t\tisLoaded: _isLoaded,\n\t\t};\n\t}, [] );\n\n\treturn {\n\t\tisLoaded,\n\t\trecord,\n\t\tgetTitle: () => ( title ? decodeEntities( title ) : null ),\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/hooks/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA,OAAO,cAAP;AACA,OAAO,sBAAP","sourcesContent":["/**\n * Internal dependencies\n */\nimport './components';\nimport './template-part-edit';\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/hooks/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA,OAAO,cAAP;AACA,OAAO,iCAAP;AACA,OAAO,sBAAP","sourcesContent":["/**\n * Internal dependencies\n */\nimport './components';\nimport './push-changes-to-global-styles';\nimport './template-part-edit';\n"]}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { get, set } from 'lodash';
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { addFilter } from '@wordpress/hooks';
|
|
12
|
+
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
13
|
+
import { InspectorAdvancedControls, store as blockEditorStore } from '@wordpress/block-editor';
|
|
14
|
+
import { BaseControl, Button } from '@wordpress/components';
|
|
15
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
16
|
+
import { __EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY, getBlockType } from '@wordpress/blocks';
|
|
17
|
+
import { useContext, useMemo, useCallback } from '@wordpress/element';
|
|
18
|
+
import { useDispatch } from '@wordpress/data';
|
|
19
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
20
|
+
/**
|
|
21
|
+
* Internal dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { getSupportedGlobalStylesPanels } from '../../components/global-styles/hooks';
|
|
25
|
+
import { GlobalStylesContext } from '../../components/global-styles/context';
|
|
26
|
+
import { STYLE_PATH_TO_CSS_VAR_INFIX, STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE } from '../../components/global-styles/utils';
|
|
27
|
+
|
|
28
|
+
function getChangesToPush(name, attributes) {
|
|
29
|
+
return getSupportedGlobalStylesPanels(name).flatMap(key => {
|
|
30
|
+
if (!STYLE_PROPERTY[key]) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const {
|
|
35
|
+
value: path
|
|
36
|
+
} = STYLE_PROPERTY[key];
|
|
37
|
+
const presetAttributeKey = path.join('.');
|
|
38
|
+
const presetAttributeValue = attributes[STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[presetAttributeKey]];
|
|
39
|
+
const value = presetAttributeValue ? `var:preset|${STYLE_PATH_TO_CSS_VAR_INFIX[presetAttributeKey]}|${presetAttributeValue}` : get(attributes.style, path);
|
|
40
|
+
return value ? [{
|
|
41
|
+
path,
|
|
42
|
+
value
|
|
43
|
+
}] : [];
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function cloneDeep(object) {
|
|
48
|
+
return !object ? {} : JSON.parse(JSON.stringify(object));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function PushChangesToGlobalStylesControl(_ref) {
|
|
52
|
+
let {
|
|
53
|
+
name,
|
|
54
|
+
attributes,
|
|
55
|
+
setAttributes
|
|
56
|
+
} = _ref;
|
|
57
|
+
const changes = useMemo(() => getChangesToPush(name, attributes), [name, attributes]);
|
|
58
|
+
const {
|
|
59
|
+
user: userConfig,
|
|
60
|
+
setUserConfig
|
|
61
|
+
} = useContext(GlobalStylesContext);
|
|
62
|
+
const {
|
|
63
|
+
__unstableMarkNextChangeAsNotPersistent
|
|
64
|
+
} = useDispatch(blockEditorStore);
|
|
65
|
+
const {
|
|
66
|
+
createSuccessNotice
|
|
67
|
+
} = useDispatch(noticesStore);
|
|
68
|
+
const pushChanges = useCallback(() => {
|
|
69
|
+
if (changes.length === 0) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const {
|
|
74
|
+
style: blockStyles
|
|
75
|
+
} = attributes;
|
|
76
|
+
const newBlockStyles = cloneDeep(blockStyles);
|
|
77
|
+
const newUserConfig = cloneDeep(userConfig);
|
|
78
|
+
|
|
79
|
+
for (const {
|
|
80
|
+
path,
|
|
81
|
+
value
|
|
82
|
+
} of changes) {
|
|
83
|
+
set(newBlockStyles, path, undefined);
|
|
84
|
+
set(newUserConfig, ['styles', 'blocks', name, ...path], value);
|
|
85
|
+
} // @wordpress/core-data doesn't support editing multiple entity types in
|
|
86
|
+
// a single undo level. So for now, we disable @wordpress/core-data undo
|
|
87
|
+
// tracking and implement our own Undo button in the snackbar
|
|
88
|
+
// notification.
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
92
|
+
|
|
93
|
+
setAttributes({
|
|
94
|
+
style: newBlockStyles
|
|
95
|
+
});
|
|
96
|
+
setUserConfig(() => newUserConfig, {
|
|
97
|
+
undoIgnore: true
|
|
98
|
+
});
|
|
99
|
+
createSuccessNotice(sprintf( // translators: %s: Title of the block e.g. 'Heading'.
|
|
100
|
+
__('Pushed styles to all %s blocks.'), getBlockType(name).title), {
|
|
101
|
+
type: 'snackbar',
|
|
102
|
+
actions: [{
|
|
103
|
+
label: __('Undo'),
|
|
104
|
+
|
|
105
|
+
onClick() {
|
|
106
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
107
|
+
|
|
108
|
+
setAttributes({
|
|
109
|
+
style: blockStyles
|
|
110
|
+
});
|
|
111
|
+
setUserConfig(() => userConfig, {
|
|
112
|
+
undoIgnore: true
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
}]
|
|
117
|
+
});
|
|
118
|
+
}, [changes, attributes, userConfig, name]);
|
|
119
|
+
return createElement(BaseControl, {
|
|
120
|
+
className: "edit-site-push-changes-to-global-styles-control",
|
|
121
|
+
help: sprintf( // translators: %s: Title of the block e.g. 'Heading'.
|
|
122
|
+
__('Move this block’s typography, spacing, dimensions, and color styles to all %s blocks.'), getBlockType(name).title)
|
|
123
|
+
}, createElement(BaseControl.VisualLabel, null, __('Styles')), createElement(Button, {
|
|
124
|
+
variant: "primary",
|
|
125
|
+
disabled: changes.length === 0,
|
|
126
|
+
onClick: pushChanges
|
|
127
|
+
}, __('Push changes to Global Styles')));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const withPushChangesToGlobalStyles = createHigherOrderComponent(BlockEdit => props => createElement(Fragment, null, createElement(BlockEdit, props), createElement(InspectorAdvancedControls, null, createElement(PushChangesToGlobalStylesControl, props))));
|
|
131
|
+
addFilter('editor.BlockEdit', 'core/edit-site/push-changes-to-global-styles', withPushChangesToGlobalStyles);
|
|
132
|
+
//# sourceMappingURL=index.js.map
|