@wordpress/edit-site 3.0.1-next.253d9b6e21.0 → 3.0.3
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/README.md +1 -1
- package/build/components/block-editor/back-button.js +60 -0
- package/build/components/block-editor/back-button.js.map +1 -0
- package/build/components/block-editor/index.js +20 -5
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/edit-template-part-menu-button/index.js +63 -0
- package/build/components/edit-template-part-menu-button/index.js.map +1 -0
- package/build/components/editor/global-styles-provider.js +15 -2
- package/build/components/editor/global-styles-provider.js.map +1 -1
- package/build/components/editor/global-styles-renderer.js +8 -8
- package/build/components/editor/global-styles-renderer.js.map +1 -1
- package/build/components/editor/index.js +7 -7
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor/utils.js +4 -9
- package/build/components/editor/utils.js.map +1 -1
- package/build/components/{sidebar → global-styles}/border-panel.js +2 -2
- package/build/components/global-styles/border-panel.js.map +1 -0
- package/build/components/{sidebar → global-styles}/color-palette-panel.js +4 -2
- package/build/components/global-styles/color-palette-panel.js.map +1 -0
- package/build/components/{sidebar → global-styles}/color-panel.js +24 -21
- package/build/components/global-styles/color-panel.js.map +1 -0
- package/build/components/global-styles/context-menu.js +58 -0
- package/build/components/global-styles/context-menu.js.map +1 -0
- package/build/components/{sidebar → global-styles}/dimensions-panel.js +58 -8
- package/build/components/global-styles/dimensions-panel.js.map +1 -0
- package/build/components/global-styles/header.js +54 -0
- package/build/components/global-styles/header.js.map +1 -0
- package/build/components/global-styles/index.js +89 -0
- package/build/components/global-styles/index.js.map +1 -0
- package/build/components/global-styles/navigation-button.js +43 -0
- package/build/components/global-styles/navigation-button.js.map +1 -0
- package/build/components/global-styles/palette.js +57 -0
- package/build/components/global-styles/palette.js.map +1 -0
- package/build/components/global-styles/preview.js +59 -0
- package/build/components/global-styles/preview.js.map +1 -0
- package/build/components/global-styles/screen-block-list.js +76 -0
- package/build/components/global-styles/screen-block-list.js.map +1 -0
- package/build/components/global-styles/screen-block.js +45 -0
- package/build/components/global-styles/screen-block.js.map +1 -0
- package/build/components/global-styles/screen-color-palette.js +48 -0
- package/build/components/global-styles/screen-color-palette.js.map +1 -0
- package/build/components/global-styles/screen-colors.js +51 -0
- package/build/components/global-styles/screen-colors.js.map +1 -0
- package/build/components/global-styles/screen-layout.js +60 -0
- package/build/components/global-styles/screen-layout.js.map +1 -0
- package/build/components/global-styles/screen-root.js +44 -0
- package/build/components/global-styles/screen-root.js.map +1 -0
- package/build/components/global-styles/screen-typography.js +50 -0
- package/build/components/global-styles/screen-typography.js.map +1 -0
- package/build/components/global-styles/subtitle.js +25 -0
- package/build/components/global-styles/subtitle.js.map +1 -0
- package/build/components/{sidebar → global-styles}/typography-panel.js +1 -3
- package/build/components/global-styles/typography-panel.js.map +1 -0
- package/build/components/header/document-actions/index.js +1 -1
- package/build/components/header/document-actions/index.js.map +1 -1
- package/build/components/header/plugin-more-menu-item/index.js +82 -0
- package/build/components/header/plugin-more-menu-item/index.js.map +1 -0
- package/build/components/header/plugin-sidebar-more-menu-item/index.js +75 -0
- package/build/components/header/plugin-sidebar-more-menu-item/index.js.map +1 -0
- package/build/components/header/undo-redo/redo.js +1 -1
- package/build/components/header/undo-redo/redo.js.map +1 -1
- package/build/components/header/undo-redo/undo.js +1 -1
- package/build/components/header/undo-redo/undo.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +2 -10
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/navigation-sidebar/index.js +1 -1
- package/build/components/navigation-sidebar/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/constants.js +10 -10
- package/build/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/content-navigation-item.js +1 -3
- package/build/components/navigation-sidebar/navigation-panel/content-navigation-item.js.map +1 -1
- package/build/components/save-button/index.js +1 -1
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +2 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/sidebar/global-styles-sidebar.js +11 -161
- package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar/index.js +1 -6
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js +95 -0
- package/build/components/sidebar/plugin-sidebar/index.js.map +1 -0
- package/build/components/template-details/index.js +12 -6
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-areas.js +73 -0
- package/build/components/template-details/template-areas.js.map +1 -0
- package/build/components/template-part-converter/convert-to-regular.js +3 -3
- package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build/components/template-part-converter/index.js +1 -1
- package/build/components/template-part-converter/index.js.map +1 -1
- package/build/components/url-query-controller/index.js +1 -1
- package/build/components/url-query-controller/index.js.map +1 -1
- package/build/index.js +24 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +60 -7
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +19 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/reducer.js +16 -7
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +91 -9
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-editor/back-button.js +48 -0
- package/build-module/components/block-editor/back-button.js.map +1 -0
- package/build-module/components/block-editor/index.js +17 -5
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/edit-template-part-menu-button/index.js +49 -0
- package/build-module/components/edit-template-part-menu-button/index.js.map +1 -0
- package/build-module/components/editor/global-styles-provider.js +16 -3
- package/build-module/components/editor/global-styles-provider.js.map +1 -1
- package/build-module/components/editor/global-styles-renderer.js +8 -8
- package/build-module/components/editor/global-styles-renderer.js.map +1 -1
- package/build-module/components/editor/index.js +4 -5
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor/utils.js +2 -7
- package/build-module/components/editor/utils.js.map +1 -1
- package/build-module/components/{sidebar → global-styles}/border-panel.js +2 -2
- package/build-module/components/global-styles/border-panel.js.map +1 -0
- package/build-module/components/{sidebar → global-styles}/color-palette-panel.js +4 -2
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -0
- package/build-module/components/{sidebar → global-styles}/color-panel.js +25 -22
- package/build-module/components/global-styles/color-panel.js.map +1 -0
- package/build-module/components/global-styles/context-menu.js +41 -0
- package/build-module/components/global-styles/context-menu.js.map +1 -0
- package/build-module/components/{sidebar → global-styles}/dimensions-panel.js +58 -9
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
- package/build-module/components/global-styles/header.js +41 -0
- package/build-module/components/global-styles/header.js.map +1 -0
- package/build-module/components/global-styles/index.js +70 -0
- package/build-module/components/global-styles/index.js.map +1 -0
- package/build-module/components/global-styles/navigation-button.js +31 -0
- package/build-module/components/global-styles/navigation-button.js.map +1 -0
- package/build-module/components/global-styles/palette.js +43 -0
- package/build-module/components/global-styles/palette.js.map +1 -0
- package/build-module/components/global-styles/preview.js +50 -0
- package/build-module/components/global-styles/preview.js.map +1 -0
- package/build-module/components/global-styles/screen-block-list.js +58 -0
- package/build-module/components/global-styles/screen-block-list.js.map +1 -0
- package/build-module/components/global-styles/screen-block.js +32 -0
- package/build-module/components/global-styles/screen-block.js.map +1 -0
- package/build-module/components/global-styles/screen-color-palette.js +35 -0
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -0
- package/build-module/components/global-styles/screen-colors.js +38 -0
- package/build-module/components/global-styles/screen-colors.js.map +1 -0
- package/build-module/components/global-styles/screen-layout.js +44 -0
- package/build-module/components/global-styles/screen-layout.js.map +1 -0
- package/build-module/components/global-styles/screen-root.js +29 -0
- package/build-module/components/global-styles/screen-root.js.map +1 -0
- package/build-module/components/global-styles/screen-typography.js +37 -0
- package/build-module/components/global-styles/screen-typography.js.map +1 -0
- package/build-module/components/global-styles/subtitle.js +17 -0
- package/build-module/components/global-styles/subtitle.js.map +1 -0
- package/build-module/components/{sidebar → global-styles}/typography-panel.js +1 -2
- package/build-module/components/global-styles/typography-panel.js.map +1 -0
- package/build-module/components/header/document-actions/index.js +1 -1
- package/build-module/components/header/document-actions/index.js.map +1 -1
- package/build-module/components/header/plugin-more-menu-item/index.js +70 -0
- package/build-module/components/header/plugin-more-menu-item/index.js.map +1 -0
- package/build-module/components/header/plugin-sidebar-more-menu-item/index.js +64 -0
- package/build-module/components/header/plugin-sidebar-more-menu-item/index.js.map +1 -0
- package/build-module/components/header/undo-redo/redo.js +1 -1
- package/build-module/components/header/undo-redo/redo.js.map +1 -1
- package/build-module/components/header/undo-redo/undo.js +1 -1
- package/build-module/components/header/undo-redo/undo.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +3 -11
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/index.js +1 -1
- package/build-module/components/navigation-sidebar/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/constants.js +5 -3
- package/build-module/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/content-navigation-item.js +1 -3
- package/build-module/components/navigation-sidebar/navigation-panel/content-navigation-item.js.map +1 -1
- package/build-module/components/save-button/index.js +1 -1
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +2 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/sidebar/global-styles-sidebar.js +13 -159
- package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar/index.js +2 -7
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js +84 -0
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -0
- package/build-module/components/template-details/index.js +13 -8
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-areas.js +60 -0
- package/build-module/components/template-details/template-areas.js.map +1 -0
- package/build-module/components/template-part-converter/convert-to-regular.js +3 -3
- package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build-module/components/template-part-converter/index.js +1 -1
- package/build-module/components/template-part-converter/index.js.map +1 -1
- package/build-module/components/url-query-controller/index.js +1 -1
- package/build-module/components/url-query-controller/index.js.map +1 -1
- package/build-module/index.js +3 -0
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +51 -7
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js +13 -0
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/reducer.js +16 -7
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +85 -9
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +158 -19
- package/build-style/style.css +158 -19
- package/package.json +26 -26
- package/src/components/block-editor/back-button.js +44 -0
- package/src/components/block-editor/index.js +18 -2
- package/src/components/block-editor/style.scss +26 -0
- package/src/components/edit-template-part-menu-button/index.js +57 -0
- package/src/components/editor/global-styles-provider.js +19 -3
- package/src/components/editor/global-styles-renderer.js +8 -5
- package/src/components/editor/index.js +5 -8
- package/src/components/editor/test/global-styles-provider.js +131 -0
- package/src/components/editor/test/global-styles-renderer.js +1 -1
- package/src/components/editor/test/utils.js +146 -0
- package/src/components/editor/utils.js +2 -7
- package/src/components/{sidebar → global-styles}/border-panel.js +2 -2
- package/src/components/{sidebar → global-styles}/color-palette-panel.js +13 -11
- package/src/components/{sidebar → global-styles}/color-panel.js +43 -28
- package/src/components/global-styles/context-menu.js +54 -0
- package/src/components/{sidebar → global-styles}/dimensions-panel.js +60 -9
- package/src/components/global-styles/header.js +50 -0
- package/src/components/global-styles/index.js +81 -0
- package/src/components/global-styles/navigation-button.js +35 -0
- package/src/components/global-styles/palette.js +67 -0
- package/src/components/global-styles/preview.js +41 -0
- package/src/components/global-styles/screen-block-list.js +59 -0
- package/src/components/global-styles/screen-block.js +28 -0
- package/src/components/global-styles/screen-color-palette.js +33 -0
- package/src/components/global-styles/screen-colors.js +36 -0
- package/src/components/global-styles/screen-layout.js +45 -0
- package/src/components/global-styles/screen-root.js +43 -0
- package/src/components/global-styles/screen-typography.js +33 -0
- package/src/components/global-styles/style.scss +35 -0
- package/src/components/global-styles/subtitle.js +10 -0
- package/src/components/{sidebar → global-styles}/typography-panel.js +1 -2
- package/src/components/header/document-actions/index.js +1 -1
- package/src/components/header/plugin-more-menu-item/index.js +71 -0
- package/src/components/header/plugin-sidebar-more-menu-item/index.js +64 -0
- package/src/components/header/undo-redo/redo.js +4 -1
- package/src/components/header/undo-redo/undo.js +4 -1
- package/src/components/keyboard-shortcuts/index.js +25 -40
- package/src/components/navigation-sidebar/index.js +1 -1
- package/src/components/navigation-sidebar/navigation-panel/constants.js +9 -4
- package/src/components/navigation-sidebar/navigation-panel/content-navigation-item.js +1 -1
- package/src/components/navigation-sidebar/navigation-panel/style.scss +1 -0
- package/src/components/navigation-sidebar/navigation-toggle/style.scss +3 -2
- package/src/components/save-button/index.js +1 -1
- package/src/components/secondary-sidebar/inserter-sidebar.js +1 -0
- package/src/components/sidebar/global-styles-sidebar.js +14 -187
- package/src/components/sidebar/index.js +2 -7
- package/src/components/sidebar/plugin-sidebar/index.js +80 -0
- package/src/components/sidebar/style.scss +40 -0
- package/src/components/template-details/index.js +17 -7
- package/src/components/template-details/style.scss +36 -27
- package/src/components/template-details/template-areas.js +66 -0
- package/src/components/template-part-converter/convert-to-regular.js +2 -8
- package/src/components/template-part-converter/index.js +1 -1
- package/src/components/url-query-controller/index.js +1 -1
- package/src/index.js +3 -0
- package/src/store/actions.js +59 -7
- package/src/store/constants.js +15 -0
- package/src/store/reducer.js +26 -12
- package/src/store/selectors.js +96 -9
- package/src/store/test/reducer.js +40 -23
- package/src/store/test/selectors.js +34 -3
- package/src/style.scss +1 -0
- package/build/components/sidebar/border-panel.js.map +0 -1
- package/build/components/sidebar/color-palette-panel.js.map +0 -1
- package/build/components/sidebar/color-panel.js.map +0 -1
- package/build/components/sidebar/dimensions-panel.js.map +0 -1
- package/build/components/sidebar/typography-panel.js.map +0 -1
- package/build-module/components/sidebar/border-panel.js.map +0 -1
- package/build-module/components/sidebar/color-palette-panel.js.map +0 -1
- package/build-module/components/sidebar/color-panel.js.map +0 -1
- package/build-module/components/sidebar/dimensions-panel.js.map +0 -1
- package/build-module/components/sidebar/typography-panel.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/editor/index.js"],"names":["interfaceLabels","secondarySidebar","drawer","Editor","initialSettings","onError","isInserterOpen","isListViewOpen","sidebarIsOpened","settings","entityId","templateType","page","template","templateResolved","isNavigationOpen","select","isInserterOpened","isListViewOpened","getSettings","getEditedPostType","getEditedPostId","getPage","isNavigationOpened","editSiteStore","hasFinishedResolution","getEntityRecord","coreStore","postType","postId","interfaceStore","getActiveComplementaryArea","name","updateEditorSettings","editorStore","setPage","setIsInserterOpened","updateSettings","defaultTemplateTypes","defaultTemplatePartAreas","isEntitiesSavedStatesOpen","setIsEntitiesSavedStatesOpen","openEntitiesSavedStates","closeEntitiesSavedStates","blockContext","context","queryContext","newQueryContext","document","body","classList","add","remove","siteUrl","__experimentalGlobalStylesUserEntityId","__experimentalGlobalStylesBaseStyles"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAMA;;AAOA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA1CA;AACA;AACA;;AA2BA;AACA;AACA;AAaA,MAAMA,eAAe,GAAG;AACvBC,EAAAA,gBAAgB,EAAE,cAAI,eAAJ,CADK;AAEvBC,EAAAA,MAAM,EAAE,cAAI,oBAAJ;AAFe,CAAxB;;AAKA,SAASC,MAAT,CAAiB;AAAEC,EAAAA,eAAF;AAAmBC,EAAAA;AAAnB,CAAjB,EAAgD;AAC/C,QAAM;AACLC,IAAAA,cADK;AAELC,IAAAA,cAFK;AAGLC,IAAAA,eAHK;AAILC,IAAAA,QAJK;AAKLC,IAAAA,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,EACND,uBAJF;AAMC,uBACC;AAPF,OAUG,cACD,iBADC,CAVH,CADD,CARF,CA9CF;AAyEC,IAAA,MAAM,EAAG,4BAAC,4BAAD;AAzEV,IALD,EAgFC,4BAAC,mBAAD,CAAS,IAAT,OAhFD,EAiFC,4BAAC,mBAAD,OAjFD,CALD,CADD,CAPD,CALD,CADD,CADD,CAFD,CADD;AAkHA;;eACcvC,M","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useMemo, useCallback } from '@wordpress/element';\nimport { AsyncModeProvider, useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tSlotFillProvider,\n\tPopover,\n\tButton,\n\tNotice,\n} from '@wordpress/components';\nimport { EntityProvider, store as coreStore } from '@wordpress/core-data';\nimport { BlockContextProvider, BlockBreadcrumb } from '@wordpress/block-editor';\nimport {\n\tFullscreenMode,\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport {\n\tEditorNotices,\n\tEditorSnackbars,\n\tEntitiesSavedStates,\n\tUnsavedChangesWarning,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\nimport { PluginArea } from '@wordpress/plugins';\n\n/**\n * Internal dependencies\n */\nimport Header from '../header';\nimport { SidebarComplementaryAreaFills } from '../sidebar';\nimport BlockEditor from '../block-editor';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport GlobalStylesProvider from './global-styles-provider';\nimport NavigationSidebar from '../navigation-sidebar';\nimport URLQueryController from '../url-query-controller';\nimport InserterSidebar from '../secondary-sidebar/inserter-sidebar';\nimport ListViewSidebar from '../secondary-sidebar/list-view-sidebar';\nimport ErrorBoundary from '../error-boundary';\nimport { store as editSiteStore } from '../../store';\n\nconst interfaceLabels = {\n\tsecondarySidebar: __( 'Block Library' ),\n\tdrawer: __( 'Navigation Sidebar' ),\n};\n\nfunction Editor( { initialSettings, onError } ) {\n\tconst {\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tsidebarIsOpened,\n\t\tsettings,\n\t\tentityId,\n\t\ttemplateType,\n\t\tpage,\n\t\ttemplate,\n\t\ttemplateResolved,\n\t\tisNavigationOpen,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisInserterOpened,\n\t\t\tisListViewOpened,\n\t\t\tgetSettings,\n\t\t\tgetEditedPostType,\n\t\t\tgetEditedPostId,\n\t\t\tgetPage,\n\t\t\tisNavigationOpened,\n\t\t} = select( editSiteStore );\n\t\tconst { hasFinishedResolution, getEntityRecord } = select( coreStore );\n\t\tconst postType = getEditedPostType();\n\t\tconst postId = getEditedPostId();\n\n\t\t// The currently selected entity to display. Typically template or template part.\n\t\treturn {\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tsidebarIsOpened: !! select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( editSiteStore.name ),\n\t\t\tsettings: getSettings(),\n\t\t\ttemplateType: postType,\n\t\t\tpage: getPage(),\n\t\t\ttemplate: postId\n\t\t\t\t? getEntityRecord( 'postType', postType, postId )\n\t\t\t\t: null,\n\t\t\ttemplateResolved: postId\n\t\t\t\t? hasFinishedResolution( 'getEntityRecord', [\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tpostId,\n\t\t\t\t ] )\n\t\t\t\t: false,\n\t\t\tentityId: postId,\n\t\t\tisNavigationOpen: isNavigationOpened(),\n\t\t};\n\t}, [] );\n\tconst { updateEditorSettings } = useDispatch( editorStore );\n\tconst { setPage, setIsInserterOpened, updateSettings } = useDispatch(\n\t\teditSiteStore\n\t);\n\tuseEffect( () => {\n\t\tupdateSettings( initialSettings );\n\t}, [] );\n\n\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t// so that they can be selected with core/editor selectors in any editor.\n\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t// which internally uses updateEditorSettings as well.\n\tconst { defaultTemplateTypes, defaultTemplatePartAreas } = settings;\n\tuseEffect( () => {\n\t\tupdateEditorSettings( {\n\t\t\tdefaultTemplateTypes,\n\t\t\tdefaultTemplatePartAreas,\n\t\t} );\n\t}, [ defaultTemplateTypes, defaultTemplatePartAreas ] );\n\n\tconst [\n\t\tisEntitiesSavedStatesOpen,\n\t\tsetIsEntitiesSavedStatesOpen,\n\t] = useState( false );\n\tconst openEntitiesSavedStates = useCallback(\n\t\t() => setIsEntitiesSavedStatesOpen( true ),\n\t\t[]\n\t);\n\tconst closeEntitiesSavedStates = useCallback( () => {\n\t\tsetIsEntitiesSavedStatesOpen( false );\n\t}, [] );\n\n\tconst blockContext = useMemo(\n\t\t() => ( {\n\t\t\t...page?.context,\n\t\t\tqueryContext: [\n\t\t\t\tpage?.context.queryContext || { page: 1 },\n\t\t\t\t( newQueryContext ) =>\n\t\t\t\t\tsetPage( {\n\t\t\t\t\t\t...page,\n\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\t...page?.context,\n\t\t\t\t\t\t\tqueryContext: {\n\t\t\t\t\t\t\t\t...page?.context.queryContext,\n\t\t\t\t\t\t\t\t...newQueryContext,\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],\n\t\t} ),\n\t\t[ page?.context ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( isNavigationOpen ) {\n\t\t\tdocument.body.classList.add( 'is-navigation-sidebar-open' );\n\t\t} else {\n\t\t\tdocument.body.classList.remove( 'is-navigation-sidebar-open' );\n\t\t}\n\t}, [ isNavigationOpen ] );\n\n\t// Don't render the Editor until the settings are set and loaded\n\tif ( ! settings?.siteUrl ) {\n\t\treturn null;\n\t}\n\n\tconst secondarySidebar = () => {\n\t\tif ( isInserterOpen ) {\n\t\t\treturn <InserterSidebar />;\n\t\t}\n\t\tif ( isListViewOpen ) {\n\t\t\treturn (\n\t\t\t\t<AsyncModeProvider value=\"true\">\n\t\t\t\t\t<ListViewSidebar />\n\t\t\t\t</AsyncModeProvider>\n\t\t\t);\n\t\t}\n\t\treturn null;\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<URLQueryController />\n\t\t\t<SlotFillProvider>\n\t\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\t\ttype={ templateType }\n\t\t\t\t\t\tid={ entityId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\t\t\ttype=\"wp_global_styles\"\n\t\t\t\t\t\t\tid={\n\t\t\t\t\t\t\t\tsettings.__experimentalGlobalStylesUserEntityId\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockContextProvider value={ blockContext }>\n\t\t\t\t\t\t\t\t<GlobalStylesProvider\n\t\t\t\t\t\t\t\t\tbaseStyles={\n\t\t\t\t\t\t\t\t\t\tsettings.__experimentalGlobalStylesBaseStyles\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<ErrorBoundary onError={ onError }>\n\t\t\t\t\t\t\t\t\t\t<FullscreenMode isActive />\n\t\t\t\t\t\t\t\t\t\t<UnsavedChangesWarning />\n\t\t\t\t\t\t\t\t\t\t<KeyboardShortcuts.Register />\n\t\t\t\t\t\t\t\t\t\t<SidebarComplementaryAreaFills />\n\t\t\t\t\t\t\t\t\t\t<InterfaceSkeleton\n\t\t\t\t\t\t\t\t\t\t\tlabels={ interfaceLabels }\n\t\t\t\t\t\t\t\t\t\t\tdrawer={ <NavigationSidebar /> }\n\t\t\t\t\t\t\t\t\t\t\tsecondarySidebar={ secondarySidebar() }\n\t\t\t\t\t\t\t\t\t\t\tsidebar={\n\t\t\t\t\t\t\t\t\t\t\t\tsidebarIsOpened && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<ComplementaryArea.Slot scope=\"core/edit-site\" />\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\theader={\n\t\t\t\t\t\t\t\t\t\t\t\t<Header\n\t\t\t\t\t\t\t\t\t\t\t\t\topenEntitiesSavedStates={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\topenEntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\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\tnotices={ <EditorSnackbars /> }\n\t\t\t\t\t\t\t\t\t\t\tcontent={\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\t\t<EditorNotices />\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ template && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<BlockEditor\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetIsInserterOpen={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetIsInserterOpened\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ templateResolved &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t! template &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsettings?.siteUrl &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tentityId && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tisDismissible={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"You attempted to edit an item that doesn't exist. Perhaps it was deleted?\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t<KeyboardShortcuts />\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\tactions={\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\t\t{ isEntitiesSavedStatesOpen ? (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<EntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclose={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcloseEntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"edit-site-editor__toggle-save-panel\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-editor__toggle-save-panel-button\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\topenEntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taria-expanded={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Open save panel'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t) }\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\tfooter={ <BlockBreadcrumb /> }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<Popover.Slot />\n\t\t\t\t\t\t\t\t\t\t<PluginArea />\n\t\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t\t</GlobalStylesProvider>\n\t\t\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t</EntityProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</SlotFillProvider>\n\t\t</>\n\t);\n}\nexport default Editor;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/editor/index.js"],"names":["interfaceLabels","secondarySidebar","drawer","Editor","initialSettings","onError","isInserterOpen","isListViewOpen","sidebarIsOpened","settings","entityId","templateType","page","template","templateResolved","isNavigationOpen","select","isInserterOpened","isListViewOpened","getSettings","getEditedPostType","getEditedPostId","getPage","isNavigationOpened","editSiteStore","hasFinishedResolution","getEntityRecord","coreStore","postType","postId","interfaceStore","getActiveComplementaryArea","name","updateEditorSettings","editorStore","setPage","setIsInserterOpened","updateSettings","defaultTemplateTypes","defaultTemplatePartAreas","isEntitiesSavedStatesOpen","setIsEntitiesSavedStatesOpen","openEntitiesSavedStates","closeEntitiesSavedStates","blockContext","context","queryContext","newQueryContext","document","body","classList","add","remove","siteUrl","__experimentalGlobalStylesUserEntityId","__experimentalGlobalStylesBaseStyles"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAMA;;AAOA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA3CA;AACA;AACA;;AA4BA;AACA;AACA;AAaA,MAAMA,eAAe,GAAG;AACvBC,EAAAA,gBAAgB,EAAE,cAAI,eAAJ,CADK;AAEvBC,EAAAA,MAAM,EAAE,cAAI,oBAAJ;AAFe,CAAxB;;AAKA,SAASC,MAAT,CAAiB;AAAEC,EAAAA,eAAF;AAAmBC,EAAAA;AAAnB,CAAjB,EAAgD;AAC/C,QAAM;AACLC,IAAAA,cADK;AAELC,IAAAA,cAFK;AAGLC,IAAAA,eAHK;AAILC,IAAAA,QAJK;AAKLC,IAAAA,QALK;AAMLC,IAAAA,YANK;AAOLC,IAAAA,IAPK;AAQLC,IAAAA,QARK;AASLC,IAAAA,gBATK;AAULC,IAAAA;AAVK,MAWF,qBAAaC,MAAF,IAAc;AAC5B,UAAM;AACLC,MAAAA,gBADK;AAELC,MAAAA,gBAFK;AAGLC,MAAAA,WAHK;AAILC,MAAAA,iBAJK;AAKLC,MAAAA,eALK;AAMLC,MAAAA,OANK;AAOLC,MAAAA;AAPK,QAQFP,MAAM,CAAEQ,YAAF,CARV;AASA,UAAM;AAAEC,MAAAA,qBAAF;AAAyBC,MAAAA;AAAzB,QAA6CV,MAAM,CAAEW,eAAF,CAAzD;AACA,UAAMC,QAAQ,GAAGR,iBAAiB,EAAlC;AACA,UAAMS,MAAM,GAAGR,eAAe,EAA9B,CAZ4B,CAc5B;;AACA,WAAO;AACNf,MAAAA,cAAc,EAAEW,gBAAgB,EAD1B;AAENV,MAAAA,cAAc,EAAEW,gBAAgB,EAF1B;AAGNV,MAAAA,eAAe,EAAE,CAAC,CAAEQ,M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EG7B,QAAQ,IACT,4BAAC,qBAAD;AACC,MAAA,iBAAiB,EAChBuB;AAFF,MAHF,EASGtB,gBAAgB,IACjB,CAAED,QADD,KAEDJ,QAFC,aAEDA,QAFC,uBAEDA,QAAQ,CAAE4C,OAFT,KAGD3C,QAHC,IAIA,4BAAC,kBAAD;AACC,MAAA,MAAM,EAAC,SADR;AAEC,MAAA,aAAa,EACZ;AAHF,OAMG,cACD,2EADC,CANH,CAbH,EAwBC,4BAAC,2BAAD,OAxBD,CAlBF;AA6CC,IAAA,OAAO,EACN,qDACG8B,yBAAyB,GAC1B,4BAAC,2BAAD;AACC,MAAA,KAAK,EACJG;AAFF,MAD0B,GAO1B;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,4BAAC,kBAAD;AACC,MAAA,OAAO,EAAC,WADT;AAEC,MAAA,SAAS,EAAC,4CAFX;AAGC,MAAA,OAAO,EACND,uBAJF;AAMC,uBACC;AAPF,OAUG,cACD,iBADC,CAVH,CADD,CARF,CA9CF;AAyEC,IAAA,MAAM,EAAG,4BAAC,4BAAD;AAzEV,IALD,EAgFC,4BAAC,mBAAD,CAAS,IAAT,OAhFD,EAiFC,4BAAC,mBAAD,OAjFD,CALD,CADD,CAPD,CALD,CADD,CADD,CAFD,CADD;AAkHA;;eACcvC,M","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useMemo, useCallback } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tSlotFillProvider,\n\tPopover,\n\tButton,\n\tNotice,\n} from '@wordpress/components';\nimport { EntityProvider, store as coreStore } from '@wordpress/core-data';\nimport { BlockContextProvider, BlockBreadcrumb } from '@wordpress/block-editor';\nimport {\n\tFullscreenMode,\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport {\n\tEditorNotices,\n\tEditorSnackbars,\n\tEntitiesSavedStates,\n\tUnsavedChangesWarning,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\nimport { PluginArea } from '@wordpress/plugins';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport Header from '../header';\nimport { SidebarComplementaryAreaFills } from '../sidebar';\nimport BlockEditor from '../block-editor';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport GlobalStylesProvider from './global-styles-provider';\nimport NavigationSidebar from '../navigation-sidebar';\nimport URLQueryController from '../url-query-controller';\nimport InserterSidebar from '../secondary-sidebar/inserter-sidebar';\nimport ListViewSidebar from '../secondary-sidebar/list-view-sidebar';\nimport ErrorBoundary from '../error-boundary';\nimport { store as editSiteStore } from '../../store';\n\nconst interfaceLabels = {\n\tsecondarySidebar: __( 'Block Library' ),\n\tdrawer: __( 'Navigation Sidebar' ),\n};\n\nfunction Editor( { initialSettings, onError } ) {\n\tconst {\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tsidebarIsOpened,\n\t\tsettings,\n\t\tentityId,\n\t\ttemplateType,\n\t\tpage,\n\t\ttemplate,\n\t\ttemplateResolved,\n\t\tisNavigationOpen,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisInserterOpened,\n\t\t\tisListViewOpened,\n\t\t\tgetSettings,\n\t\t\tgetEditedPostType,\n\t\t\tgetEditedPostId,\n\t\t\tgetPage,\n\t\t\tisNavigationOpened,\n\t\t} = select( editSiteStore );\n\t\tconst { hasFinishedResolution, getEntityRecord } = select( coreStore );\n\t\tconst postType = getEditedPostType();\n\t\tconst postId = getEditedPostId();\n\n\t\t// The currently selected entity to display. Typically template or template part.\n\t\treturn {\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tsidebarIsOpened: !! select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( editSiteStore.name ),\n\t\t\tsettings: getSettings(),\n\t\t\ttemplateType: postType,\n\t\t\tpage: getPage(),\n\t\t\ttemplate: postId\n\t\t\t\t? getEntityRecord( 'postType', postType, postId )\n\t\t\t\t: null,\n\t\t\ttemplateResolved: postId\n\t\t\t\t? hasFinishedResolution( 'getEntityRecord', [\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tpostId,\n\t\t\t\t ] )\n\t\t\t\t: false,\n\t\t\tentityId: postId,\n\t\t\tisNavigationOpen: isNavigationOpened(),\n\t\t};\n\t}, [] );\n\tconst { updateEditorSettings } = useDispatch( editorStore );\n\tconst { setPage, setIsInserterOpened, updateSettings } = useDispatch(\n\t\teditSiteStore\n\t);\n\tuseEffect( () => {\n\t\tupdateSettings( initialSettings );\n\t}, [] );\n\n\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t// so that they can be selected with core/editor selectors in any editor.\n\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t// which internally uses updateEditorSettings as well.\n\tconst { defaultTemplateTypes, defaultTemplatePartAreas } = settings;\n\tuseEffect( () => {\n\t\tupdateEditorSettings( {\n\t\t\tdefaultTemplateTypes,\n\t\t\tdefaultTemplatePartAreas,\n\t\t} );\n\t}, [ defaultTemplateTypes, defaultTemplatePartAreas ] );\n\n\tconst [\n\t\tisEntitiesSavedStatesOpen,\n\t\tsetIsEntitiesSavedStatesOpen,\n\t] = useState( false );\n\tconst openEntitiesSavedStates = useCallback(\n\t\t() => setIsEntitiesSavedStatesOpen( true ),\n\t\t[]\n\t);\n\tconst closeEntitiesSavedStates = useCallback( () => {\n\t\tsetIsEntitiesSavedStatesOpen( false );\n\t}, [] );\n\n\tconst blockContext = useMemo(\n\t\t() => ( {\n\t\t\t...page?.context,\n\t\t\tqueryContext: [\n\t\t\t\tpage?.context.queryContext || { page: 1 },\n\t\t\t\t( newQueryContext ) =>\n\t\t\t\t\tsetPage( {\n\t\t\t\t\t\t...page,\n\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\t...page?.context,\n\t\t\t\t\t\t\tqueryContext: {\n\t\t\t\t\t\t\t\t...page?.context.queryContext,\n\t\t\t\t\t\t\t\t...newQueryContext,\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],\n\t\t} ),\n\t\t[ page?.context ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( isNavigationOpen ) {\n\t\t\tdocument.body.classList.add( 'is-navigation-sidebar-open' );\n\t\t} else {\n\t\t\tdocument.body.classList.remove( 'is-navigation-sidebar-open' );\n\t\t}\n\t}, [ isNavigationOpen ] );\n\n\t// Don't render the Editor until the settings are set and loaded\n\tif ( ! settings?.siteUrl ) {\n\t\treturn null;\n\t}\n\n\tconst secondarySidebar = () => {\n\t\tif ( isInserterOpen ) {\n\t\t\treturn <InserterSidebar />;\n\t\t}\n\t\tif ( isListViewOpen ) {\n\t\t\treturn <ListViewSidebar />;\n\t\t}\n\t\treturn null;\n\t};\n\n\treturn (\n\t\t<ShortcutProvider>\n\t\t\t<URLQueryController />\n\t\t\t<SlotFillProvider>\n\t\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\t\ttype={ templateType }\n\t\t\t\t\t\tid={ entityId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\t\t\ttype=\"wp_global_styles\"\n\t\t\t\t\t\t\tid={\n\t\t\t\t\t\t\t\tsettings.__experimentalGlobalStylesUserEntityId\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockContextProvider value={ blockContext }>\n\t\t\t\t\t\t\t\t<GlobalStylesProvider\n\t\t\t\t\t\t\t\t\tbaseStyles={\n\t\t\t\t\t\t\t\t\t\tsettings.__experimentalGlobalStylesBaseStyles\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<ErrorBoundary onError={ onError }>\n\t\t\t\t\t\t\t\t\t\t<FullscreenMode isActive />\n\t\t\t\t\t\t\t\t\t\t<UnsavedChangesWarning />\n\t\t\t\t\t\t\t\t\t\t<KeyboardShortcuts.Register />\n\t\t\t\t\t\t\t\t\t\t<SidebarComplementaryAreaFills />\n\t\t\t\t\t\t\t\t\t\t<InterfaceSkeleton\n\t\t\t\t\t\t\t\t\t\t\tlabels={ interfaceLabels }\n\t\t\t\t\t\t\t\t\t\t\tdrawer={ <NavigationSidebar /> }\n\t\t\t\t\t\t\t\t\t\t\tsecondarySidebar={ secondarySidebar() }\n\t\t\t\t\t\t\t\t\t\t\tsidebar={\n\t\t\t\t\t\t\t\t\t\t\t\tsidebarIsOpened && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<ComplementaryArea.Slot scope=\"core/edit-site\" />\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\theader={\n\t\t\t\t\t\t\t\t\t\t\t\t<Header\n\t\t\t\t\t\t\t\t\t\t\t\t\topenEntitiesSavedStates={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\topenEntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\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\tnotices={ <EditorSnackbars /> }\n\t\t\t\t\t\t\t\t\t\t\tcontent={\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\t\t<EditorNotices />\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ template && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<BlockEditor\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetIsInserterOpen={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetIsInserterOpened\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ templateResolved &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t! template &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsettings?.siteUrl &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tentityId && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tisDismissible={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"You attempted to edit an item that doesn't exist. Perhaps it was deleted?\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t<KeyboardShortcuts />\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\tactions={\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\t\t{ isEntitiesSavedStatesOpen ? (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<EntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclose={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcloseEntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"edit-site-editor__toggle-save-panel\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-editor__toggle-save-panel-button\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\topenEntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taria-expanded={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Open save panel'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t) }\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\tfooter={ <BlockBreadcrumb /> }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<Popover.Slot />\n\t\t\t\t\t\t\t\t\t\t<PluginArea />\n\t\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t\t</GlobalStylesProvider>\n\t\t\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t</EntityProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</SlotFillProvider>\n\t\t</ShortcutProvider>\n\t);\n}\nexport default Editor;\n"]}
|
|
@@ -12,6 +12,8 @@ var _lodash = require("lodash");
|
|
|
12
12
|
|
|
13
13
|
var _data = require("@wordpress/data");
|
|
14
14
|
|
|
15
|
+
var _blocks = require("@wordpress/blocks");
|
|
16
|
+
|
|
15
17
|
var _store = require("../../store");
|
|
16
18
|
|
|
17
19
|
/**
|
|
@@ -31,7 +33,7 @@ const ROOT_BLOCK_NAME = 'root';
|
|
|
31
33
|
exports.ROOT_BLOCK_NAME = ROOT_BLOCK_NAME;
|
|
32
34
|
const ROOT_BLOCK_SELECTOR = 'body';
|
|
33
35
|
exports.ROOT_BLOCK_SELECTOR = ROOT_BLOCK_SELECTOR;
|
|
34
|
-
const ROOT_BLOCK_SUPPORTS = ['background', 'backgroundColor', 'color', 'linkColor', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'lineHeight', 'textDecoration', 'textTransform'];
|
|
36
|
+
const ROOT_BLOCK_SUPPORTS = ['background', 'backgroundColor', 'color', 'linkColor', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'lineHeight', 'textDecoration', 'textTransform', 'padding'];
|
|
35
37
|
exports.ROOT_BLOCK_SUPPORTS = ROOT_BLOCK_SUPPORTS;
|
|
36
38
|
const PRESET_METADATA = [{
|
|
37
39
|
path: ['color', 'palette'],
|
|
@@ -92,13 +94,6 @@ function getPresetMetadataFromStyleProperty(styleProperty) {
|
|
|
92
94
|
return getPresetMetadataFromStyleProperty.MAP[styleProperty];
|
|
93
95
|
}
|
|
94
96
|
|
|
95
|
-
const PATHS_WITH_MERGE = {
|
|
96
|
-
'color.gradients': true,
|
|
97
|
-
'color.palette': true,
|
|
98
|
-
'typography.fontFamilies': true,
|
|
99
|
-
'typography.fontSizes': true
|
|
100
|
-
};
|
|
101
|
-
|
|
102
97
|
function useSetting(path, blockName = '') {
|
|
103
98
|
var _get;
|
|
104
99
|
|
|
@@ -109,7 +104,7 @@ function useSetting(path, blockName = '') {
|
|
|
109
104
|
const blockPath = `__experimentalFeatures.blocks.${blockName}.${path}`;
|
|
110
105
|
const result = (_get = (0, _lodash.get)(settings, blockPath)) !== null && _get !== void 0 ? _get : (0, _lodash.get)(settings, topLevelPath);
|
|
111
106
|
|
|
112
|
-
if (result &&
|
|
107
|
+
if (result && _blocks.__EXPERIMENTAL_PATHS_WITH_MERGE[path]) {
|
|
113
108
|
var _ref, _result$user;
|
|
114
109
|
|
|
115
110
|
return (_ref = (_result$user = result.user) !== null && _result$user !== void 0 ? _result$user : result.theme) !== null && _ref !== void 0 ? _ref : result.core;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/editor/utils.js"],"names":["ROOT_BLOCK_NAME","ROOT_BLOCK_SELECTOR","ROOT_BLOCK_SUPPORTS","PRESET_METADATA","path","valueKey","cssVarInfix","classes","classSuffix","propertyName","STYLE_PROPERTIES_TO_CSS_VAR_INFIX","linkColor","backgroundColor","background","getPresetMetadataFromStyleProperty","styleProperty","MAP","forEach","index","value","key","PATHS_WITH_MERGE","useSetting","blockName","settings","select","editSiteStore","getSettings","topLevelPath","blockPath","result","user","theme","core","findInPresetsBy","styles","context","presetPath","presetProperty","presetValueValue","orderedPresetsByOrigin","presetByOrigin","origins","origin","presets","presetObject","preset","highestPresetObjectWithSameSlug","slug","undefined","getPresetVariable","metadata","getValueFromPresetVariable","variable","presetType","getValueFromVariable","getValueFromCustomVariable","parsedVar","INTERNAL_REFERENCE_PREFIX","CSS_REFERENCE_PREFIX","CSS_REFERENCE_SUFFIX","startsWith","slice","length","split","endsWith","type"],"mappings":";;;;;;;;;;AAGA;;AAIA;;AAIA;;AAXA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACO,MAAMA,eAAe,GAAG,MAAxB;;AACA,MAAMC,mBAAmB,GAAG,MAA5B;;AACA,MAAMC,mBAAmB,GAAG,CAClC,YADk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EVC,KAFU,CAEH,IAFG,CAAZ;AAGA,GAPM,MAOA;AACN;AACA,WAAOX,QAAP;AACA;;AAED,QAAM,CAAEa,IAAF,EAAQ,GAAG9D,IAAX,IAAoBqD,SAA1B;;AACA,MAAKS,IAAI,KAAK,QAAd,EAAyB;AACxB,WAAOd,0BAA0B,CAAEjB,MAAF,EAAUZ,SAAV,EAAqB8B,QAArB,EAA+BjD,IAA/B,CAAjC;AACA;;AACD,MAAK8D,IAAI,KAAK,QAAd,EAAyB;AACxB,WAAOV,0BAA0B,CAAErB,MAAF,EAAUZ,SAAV,EAAqB8B,QAArB,EAA+BjD,IAA/B,CAAjC;AACA;;AACD,SAAOiD,QAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get, find, forEach, camelCase, isString } from 'lodash';\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\n/* Supporting data */\nexport const ROOT_BLOCK_NAME = 'root';\nexport const ROOT_BLOCK_SELECTOR = 'body';\nexport const ROOT_BLOCK_SUPPORTS = [\n\t'background',\n\t'backgroundColor',\n\t'color',\n\t'linkColor',\n\t'fontFamily',\n\t'fontSize',\n\t'fontStyle',\n\t'fontWeight',\n\t'lineHeight',\n\t'textDecoration',\n\t'textTransform',\n];\n\nexport const PRESET_METADATA = [\n\t{\n\t\tpath: [ 'color', 'palette' ],\n\t\tvalueKey: 'color',\n\t\tcssVarInfix: 'color',\n\t\tclasses: [\n\t\t\t{ classSuffix: 'color', propertyName: 'color' },\n\t\t\t{\n\t\t\t\tclassSuffix: 'background-color',\n\t\t\t\tpropertyName: 'background-color',\n\t\t\t},\n\t\t\t{\n\t\t\t\tclassSuffix: 'border-color',\n\t\t\t\tpropertyName: 'border-color',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tpath: [ 'color', 'gradients' ],\n\t\tvalueKey: 'gradient',\n\t\tcssVarInfix: 'gradient',\n\t\tclasses: [\n\t\t\t{\n\t\t\t\tclassSuffix: 'gradient-background',\n\t\t\t\tpropertyName: 'background',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tpath: [ 'typography', 'fontSizes' ],\n\t\tvalueKey: 'size',\n\t\tcssVarInfix: 'font-size',\n\t\tclasses: [ { classSuffix: 'font-size', propertyName: 'font-size' } ],\n\t},\n\t{\n\t\tpath: [ 'typography', 'fontFamilies' ],\n\t\tvalueKey: 'fontFamily',\n\t\tcssVarInfix: 'font-family',\n\t\tclasses: [],\n\t},\n];\n\nconst STYLE_PROPERTIES_TO_CSS_VAR_INFIX = {\n\tlinkColor: 'color',\n\tbackgroundColor: 'color',\n\tbackground: 'gradient',\n};\n\nfunction getPresetMetadataFromStyleProperty( styleProperty ) {\n\tif ( ! getPresetMetadataFromStyleProperty.MAP ) {\n\t\tgetPresetMetadataFromStyleProperty.MAP = {};\n\t\tPRESET_METADATA.forEach( ( { cssVarInfix }, index ) => {\n\t\t\tgetPresetMetadataFromStyleProperty.MAP[ camelCase( cssVarInfix ) ] =\n\t\t\t\tPRESET_METADATA[ index ];\n\t\t} );\n\t\tforEach( STYLE_PROPERTIES_TO_CSS_VAR_INFIX, ( value, key ) => {\n\t\t\tgetPresetMetadataFromStyleProperty.MAP[ key ] =\n\t\t\t\tgetPresetMetadataFromStyleProperty.MAP[ value ];\n\t\t} );\n\t}\n\treturn getPresetMetadataFromStyleProperty.MAP[ styleProperty ];\n}\n\nconst PATHS_WITH_MERGE = {\n\t'color.gradients': true,\n\t'color.palette': true,\n\t'typography.fontFamilies': true,\n\t'typography.fontSizes': true,\n};\n\nexport function useSetting( path, blockName = '' ) {\n\tconst settings = useSelect( ( select ) => {\n\t\treturn select( editSiteStore ).getSettings();\n\t} );\n\tconst topLevelPath = `__experimentalFeatures.${ path }`;\n\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ path }`;\n\tconst result = get( settings, blockPath ) ?? get( settings, topLevelPath );\n\tif ( result && PATHS_WITH_MERGE[ path ] ) {\n\t\treturn result.user ?? result.theme ?? result.core;\n\t}\n\treturn result;\n}\n\nfunction findInPresetsBy(\n\tstyles,\n\tcontext,\n\tpresetPath,\n\tpresetProperty,\n\tpresetValueValue\n) {\n\t// Block presets take priority above root level presets.\n\tconst orderedPresetsByOrigin = [\n\t\tget( styles, [ 'settings', 'blocks', context, ...presetPath ] ),\n\t\tget( styles, [ 'settings', ...presetPath ] ),\n\t];\n\tfor ( const presetByOrigin of orderedPresetsByOrigin ) {\n\t\tif ( presetByOrigin ) {\n\t\t\t// Preset origins ordered by priority.\n\t\t\tconst origins = [ 'user', 'theme', 'core' ];\n\t\t\tfor ( const origin of origins ) {\n\t\t\t\tconst presets = presetByOrigin[ origin ];\n\t\t\t\tif ( presets ) {\n\t\t\t\t\tconst presetObject = find(\n\t\t\t\t\t\tpresets,\n\t\t\t\t\t\t( preset ) =>\n\t\t\t\t\t\t\tpreset[ presetProperty ] === presetValueValue\n\t\t\t\t\t);\n\t\t\t\t\tif ( presetObject ) {\n\t\t\t\t\t\tif ( presetProperty === 'slug' ) {\n\t\t\t\t\t\t\treturn presetObject;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// if there is a highest priority preset with the same slug but different value the preset we found was overwritten and should be ignored.\n\t\t\t\t\t\tconst highestPresetObjectWithSameSlug = findInPresetsBy(\n\t\t\t\t\t\t\tstyles,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tpresetPath,\n\t\t\t\t\t\t\t'slug',\n\t\t\t\t\t\t\tpresetObject.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\thighestPresetObjectWithSameSlug[\n\t\t\t\t\t\t\t\tpresetProperty\n\t\t\t\t\t\t\t] === presetObject[ presetProperty ]\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn presetObject;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function getPresetVariable( styles, context, propertyName, value ) {\n\tif ( ! value ) {\n\t\treturn value;\n\t}\n\n\tconst metadata = getPresetMetadataFromStyleProperty( propertyName );\n\tif ( ! metadata ) {\n\t\t// The property doesn't have preset data\n\t\t// so the value should be returned as it is.\n\t\treturn value;\n\t}\n\tconst { valueKey, path, cssVarInfix } = metadata;\n\n\tconst presetObject = findInPresetsBy(\n\t\tstyles,\n\t\tcontext,\n\t\tpath,\n\t\tvalueKey,\n\t\tvalue\n\t);\n\n\tif ( ! presetObject ) {\n\t\t// Value wasn't found in the presets,\n\t\t// so it must be a custom value.\n\t\treturn value;\n\t}\n\n\treturn `var:preset|${ cssVarInfix }|${ presetObject.slug }`;\n}\n\nfunction getValueFromPresetVariable(\n\tstyles,\n\tblockName,\n\tvariable,\n\t[ presetType, slug ]\n) {\n\tpresetType = camelCase( presetType );\n\tconst metadata = getPresetMetadataFromStyleProperty( presetType );\n\tif ( ! metadata ) {\n\t\treturn variable;\n\t}\n\n\tconst presetObject = findInPresetsBy(\n\t\tstyles,\n\t\tblockName,\n\t\tmetadata.path,\n\t\t'slug',\n\t\tslug\n\t);\n\n\tif ( presetObject ) {\n\t\tconst { valueKey } = metadata;\n\t\tconst result = presetObject[ valueKey ];\n\t\treturn getValueFromVariable( styles, blockName, result );\n\t}\n\n\treturn variable;\n}\n\nfunction getValueFromCustomVariable( styles, blockName, variable, path ) {\n\tconst result =\n\t\tget( styles, [ 'settings', 'blocks', blockName, 'custom', ...path ] ) ??\n\t\tget( styles, [ 'settings', 'custom', ...path ] );\n\tif ( ! result ) {\n\t\treturn variable;\n\t}\n\t// A variable may reference another variable so we need recursion until we find the value.\n\treturn getValueFromVariable( styles, blockName, result );\n}\n\nexport function getValueFromVariable( styles, blockName, variable ) {\n\tif ( ! variable || ! isString( variable ) ) {\n\t\treturn variable;\n\t}\n\n\tlet parsedVar;\n\tconst INTERNAL_REFERENCE_PREFIX = 'var:';\n\tconst CSS_REFERENCE_PREFIX = 'var(--wp--';\n\tconst CSS_REFERENCE_SUFFIX = ')';\n\tif ( variable.startsWith( INTERNAL_REFERENCE_PREFIX ) ) {\n\t\tparsedVar = variable\n\t\t\t.slice( INTERNAL_REFERENCE_PREFIX.length )\n\t\t\t.split( '|' );\n\t} else if (\n\t\tvariable.startsWith( CSS_REFERENCE_PREFIX ) &&\n\t\tvariable.endsWith( CSS_REFERENCE_SUFFIX )\n\t) {\n\t\tparsedVar = variable\n\t\t\t.slice( CSS_REFERENCE_PREFIX.length, -CSS_REFERENCE_SUFFIX.length )\n\t\t\t.split( '--' );\n\t} else {\n\t\t// Value is raw.\n\t\treturn variable;\n\t}\n\n\tconst [ type, ...path ] = parsedVar;\n\tif ( type === 'preset' ) {\n\t\treturn getValueFromPresetVariable( styles, blockName, variable, path );\n\t}\n\tif ( type === 'custom' ) {\n\t\treturn getValueFromCustomVariable( styles, blockName, variable, path );\n\t}\n\treturn variable;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/editor/utils.js"],"names":["ROOT_BLOCK_NAME","ROOT_BLOCK_SELECTOR","ROOT_BLOCK_SUPPORTS","PRESET_METADATA","path","valueKey","cssVarInfix","classes","classSuffix","propertyName","STYLE_PROPERTIES_TO_CSS_VAR_INFIX","linkColor","backgroundColor","background","getPresetMetadataFromStyleProperty","styleProperty","MAP","forEach","index","value","key","useSetting","blockName","settings","select","editSiteStore","getSettings","topLevelPath","blockPath","result","PATHS_WITH_MERGE","user","theme","core","findInPresetsBy","styles","context","presetPath","presetProperty","presetValueValue","orderedPresetsByOrigin","presetByOrigin","origins","origin","presets","presetObject","preset","highestPresetObjectWithSameSlug","slug","undefined","getPresetVariable","metadata","getValueFromPresetVariable","variable","presetType","getValueFromVariable","getValueFromCustomVariable","parsedVar","INTERNAL_REFERENCE_PREFIX","CSS_REFERENCE_PREFIX","CSS_REFERENCE_SUFFIX","startsWith","slice","length","split","endsWith","type"],"mappings":";;;;;;;;;;AAGA;;AAIA;;AACA;;AAIA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B,CAACI,MADlB,EAC0B,CAACH,oBAAoB,CAACG,MADhD,EAEVC,KAFU,CAEH,IAFG,CAAZ;AAGA,GAPM,MAOA;AACN;AACA,WAAOX,QAAP;AACA;;AAED,QAAM,CAAEa,IAAF,EAAQ,GAAG9D,IAAX,IAAoBqD,SAA1B;;AACA,MAAKS,IAAI,KAAK,QAAd,EAAyB;AACxB,WAAOd,0BAA0B,CAAEjB,MAAF,EAAUb,SAAV,EAAqB+B,QAArB,EAA+BjD,IAA/B,CAAjC;AACA;;AACD,MAAK8D,IAAI,KAAK,QAAd,EAAyB;AACxB,WAAOV,0BAA0B,CAAErB,MAAF,EAAUb,SAAV,EAAqB+B,QAArB,EAA+BjD,IAA/B,CAAjC;AACA;;AACD,SAAOiD,QAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get, find, forEach, camelCase, isString } from 'lodash';\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE } from '@wordpress/blocks';\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\n/* Supporting data */\nexport const ROOT_BLOCK_NAME = 'root';\nexport const ROOT_BLOCK_SELECTOR = 'body';\nexport const ROOT_BLOCK_SUPPORTS = [\n\t'background',\n\t'backgroundColor',\n\t'color',\n\t'linkColor',\n\t'fontFamily',\n\t'fontSize',\n\t'fontStyle',\n\t'fontWeight',\n\t'lineHeight',\n\t'textDecoration',\n\t'textTransform',\n\t'padding',\n];\n\nexport const PRESET_METADATA = [\n\t{\n\t\tpath: [ 'color', 'palette' ],\n\t\tvalueKey: 'color',\n\t\tcssVarInfix: 'color',\n\t\tclasses: [\n\t\t\t{ classSuffix: 'color', propertyName: 'color' },\n\t\t\t{\n\t\t\t\tclassSuffix: 'background-color',\n\t\t\t\tpropertyName: 'background-color',\n\t\t\t},\n\t\t\t{\n\t\t\t\tclassSuffix: 'border-color',\n\t\t\t\tpropertyName: 'border-color',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tpath: [ 'color', 'gradients' ],\n\t\tvalueKey: 'gradient',\n\t\tcssVarInfix: 'gradient',\n\t\tclasses: [\n\t\t\t{\n\t\t\t\tclassSuffix: 'gradient-background',\n\t\t\t\tpropertyName: 'background',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tpath: [ 'typography', 'fontSizes' ],\n\t\tvalueKey: 'size',\n\t\tcssVarInfix: 'font-size',\n\t\tclasses: [ { classSuffix: 'font-size', propertyName: 'font-size' } ],\n\t},\n\t{\n\t\tpath: [ 'typography', 'fontFamilies' ],\n\t\tvalueKey: 'fontFamily',\n\t\tcssVarInfix: 'font-family',\n\t\tclasses: [],\n\t},\n];\n\nconst STYLE_PROPERTIES_TO_CSS_VAR_INFIX = {\n\tlinkColor: 'color',\n\tbackgroundColor: 'color',\n\tbackground: 'gradient',\n};\n\nfunction getPresetMetadataFromStyleProperty( styleProperty ) {\n\tif ( ! getPresetMetadataFromStyleProperty.MAP ) {\n\t\tgetPresetMetadataFromStyleProperty.MAP = {};\n\t\tPRESET_METADATA.forEach( ( { cssVarInfix }, index ) => {\n\t\t\tgetPresetMetadataFromStyleProperty.MAP[ camelCase( cssVarInfix ) ] =\n\t\t\t\tPRESET_METADATA[ index ];\n\t\t} );\n\t\tforEach( STYLE_PROPERTIES_TO_CSS_VAR_INFIX, ( value, key ) => {\n\t\t\tgetPresetMetadataFromStyleProperty.MAP[ key ] =\n\t\t\t\tgetPresetMetadataFromStyleProperty.MAP[ value ];\n\t\t} );\n\t}\n\treturn getPresetMetadataFromStyleProperty.MAP[ styleProperty ];\n}\n\nexport function useSetting( path, blockName = '' ) {\n\tconst settings = useSelect( ( select ) => {\n\t\treturn select( editSiteStore ).getSettings();\n\t} );\n\tconst topLevelPath = `__experimentalFeatures.${ path }`;\n\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ path }`;\n\tconst result = get( settings, blockPath ) ?? get( settings, topLevelPath );\n\tif ( result && PATHS_WITH_MERGE[ path ] ) {\n\t\treturn result.user ?? result.theme ?? result.core;\n\t}\n\treturn result;\n}\n\nfunction findInPresetsBy(\n\tstyles,\n\tcontext,\n\tpresetPath,\n\tpresetProperty,\n\tpresetValueValue\n) {\n\t// Block presets take priority above root level presets.\n\tconst orderedPresetsByOrigin = [\n\t\tget( styles, [ 'settings', 'blocks', context, ...presetPath ] ),\n\t\tget( styles, [ 'settings', ...presetPath ] ),\n\t];\n\tfor ( const presetByOrigin of orderedPresetsByOrigin ) {\n\t\tif ( presetByOrigin ) {\n\t\t\t// Preset origins ordered by priority.\n\t\t\tconst origins = [ 'user', 'theme', 'core' ];\n\t\t\tfor ( const origin of origins ) {\n\t\t\t\tconst presets = presetByOrigin[ origin ];\n\t\t\t\tif ( presets ) {\n\t\t\t\t\tconst presetObject = find(\n\t\t\t\t\t\tpresets,\n\t\t\t\t\t\t( preset ) =>\n\t\t\t\t\t\t\tpreset[ presetProperty ] === presetValueValue\n\t\t\t\t\t);\n\t\t\t\t\tif ( presetObject ) {\n\t\t\t\t\t\tif ( presetProperty === 'slug' ) {\n\t\t\t\t\t\t\treturn presetObject;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// if there is a highest priority preset with the same slug but different value the preset we found was overwritten and should be ignored.\n\t\t\t\t\t\tconst highestPresetObjectWithSameSlug = findInPresetsBy(\n\t\t\t\t\t\t\tstyles,\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tpresetPath,\n\t\t\t\t\t\t\t'slug',\n\t\t\t\t\t\t\tpresetObject.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\thighestPresetObjectWithSameSlug[\n\t\t\t\t\t\t\t\tpresetProperty\n\t\t\t\t\t\t\t] === presetObject[ presetProperty ]\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn presetObject;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function getPresetVariable( styles, context, propertyName, value ) {\n\tif ( ! value ) {\n\t\treturn value;\n\t}\n\n\tconst metadata = getPresetMetadataFromStyleProperty( propertyName );\n\tif ( ! metadata ) {\n\t\t// The property doesn't have preset data\n\t\t// so the value should be returned as it is.\n\t\treturn value;\n\t}\n\tconst { valueKey, path, cssVarInfix } = metadata;\n\n\tconst presetObject = findInPresetsBy(\n\t\tstyles,\n\t\tcontext,\n\t\tpath,\n\t\tvalueKey,\n\t\tvalue\n\t);\n\n\tif ( ! presetObject ) {\n\t\t// Value wasn't found in the presets,\n\t\t// so it must be a custom value.\n\t\treturn value;\n\t}\n\n\treturn `var:preset|${ cssVarInfix }|${ presetObject.slug }`;\n}\n\nfunction getValueFromPresetVariable(\n\tstyles,\n\tblockName,\n\tvariable,\n\t[ presetType, slug ]\n) {\n\tpresetType = camelCase( presetType );\n\tconst metadata = getPresetMetadataFromStyleProperty( presetType );\n\tif ( ! metadata ) {\n\t\treturn variable;\n\t}\n\n\tconst presetObject = findInPresetsBy(\n\t\tstyles,\n\t\tblockName,\n\t\tmetadata.path,\n\t\t'slug',\n\t\tslug\n\t);\n\n\tif ( presetObject ) {\n\t\tconst { valueKey } = metadata;\n\t\tconst result = presetObject[ valueKey ];\n\t\treturn getValueFromVariable( styles, blockName, result );\n\t}\n\n\treturn variable;\n}\n\nfunction getValueFromCustomVariable( styles, blockName, variable, path ) {\n\tconst result =\n\t\tget( styles, [ 'settings', 'blocks', blockName, 'custom', ...path ] ) ??\n\t\tget( styles, [ 'settings', 'custom', ...path ] );\n\tif ( ! result ) {\n\t\treturn variable;\n\t}\n\t// A variable may reference another variable so we need recursion until we find the value.\n\treturn getValueFromVariable( styles, blockName, result );\n}\n\nexport function getValueFromVariable( styles, blockName, variable ) {\n\tif ( ! variable || ! isString( variable ) ) {\n\t\treturn variable;\n\t}\n\n\tlet parsedVar;\n\tconst INTERNAL_REFERENCE_PREFIX = 'var:';\n\tconst CSS_REFERENCE_PREFIX = 'var(--wp--';\n\tconst CSS_REFERENCE_SUFFIX = ')';\n\tif ( variable.startsWith( INTERNAL_REFERENCE_PREFIX ) ) {\n\t\tparsedVar = variable\n\t\t\t.slice( INTERNAL_REFERENCE_PREFIX.length )\n\t\t\t.split( '|' );\n\t} else if (\n\t\tvariable.startsWith( CSS_REFERENCE_PREFIX ) &&\n\t\tvariable.endsWith( CSS_REFERENCE_SUFFIX )\n\t) {\n\t\tparsedVar = variable\n\t\t\t.slice( CSS_REFERENCE_PREFIX.length, -CSS_REFERENCE_SUFFIX.length )\n\t\t\t.split( '--' );\n\t} else {\n\t\t// Value is raw.\n\t\treturn variable;\n\t}\n\n\tconst [ type, ...path ] = parsedVar;\n\tif ( type === 'preset' ) {\n\t\treturn getValueFromPresetVariable( styles, blockName, variable, path );\n\t}\n\tif ( type === 'custom' ) {\n\t\treturn getValueFromCustomVariable( styles, blockName, variable, path );\n\t}\n\treturn variable;\n}\n"]}
|
|
@@ -45,7 +45,7 @@ function useHasBorderPanel({
|
|
|
45
45
|
supports,
|
|
46
46
|
name
|
|
47
47
|
})];
|
|
48
|
-
return controls.
|
|
48
|
+
return controls.some(Boolean);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function useHasBorderColorControl({
|
|
@@ -132,7 +132,7 @@ function BorderPanel({
|
|
|
132
132
|
onChange: value => setStyle(name, 'borderStyle', value)
|
|
133
133
|
})), hasBorderColor && (0, _element.createElement)(_blockEditor.__experimentalColorGradientControl, {
|
|
134
134
|
label: (0, _i18n.__)('Color'),
|
|
135
|
-
|
|
135
|
+
colorValue: borderColor,
|
|
136
136
|
colors: colors,
|
|
137
137
|
gradients: undefined,
|
|
138
138
|
disableCustomColors: disableCustomColors,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/border-panel.js"],"names":["MIN_BORDER_WIDTH","EMPTY_ARRAY","useHasBorderPanel","supports","name","controls","useHasBorderColorControl","useHasBorderRadiusControl","useHasBorderStyleControl","useHasBorderWidthControl","some","Boolean","includes","BorderPanel","context","getStyle","setStyle","units","availableUnits","hasBorderWidth","borderWidthValue","hasBorderStyle","borderStyle","colors","disableCustomColors","disableCustomGradients","hasBorderColor","borderColor","hasBorderRadius","borderRadiusValues","value","undefined"],"mappings":";;;;;;;;;;AAGA;;AAKA;;AAKA;;AAKA;;AAlBA;AACA;AACA;;AAaA;AACA;AACA;AAGA,MAAMA,gBAAgB,GAAG,CAAzB,C,CAEA;AACA;;AACA,MAAMC,WAAW,GAAG,EAApB;;AAEO,SAASC,iBAAT,CAA4B;AAAEC,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,CAA5B,EAAiD;AACvD,QAAMC,QAAQ,GAAG,CAChBC,wBAAwB,CAAE;AAAEH,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAF,CADR,EAEhBG,yBAAyB,CAAE;AAAEJ,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAF,CAFT,EAGhBI,wBAAwB,CAAE;AAAEL,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAF,CAHR,EAIhBK,wBAAwB,CAAE;AAAEN,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAF,CAJR,CAAjB;AAOA,SAAOC,QAAQ,CAACK,IAAT,CAAeC,OAAf,CAAP;AACA;;AAED,SAASL,wBAAT,CAAmC;AAAEH,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,CAAnC,EAAwD;AACvD,SACC,uBAAY,oBAAZ,EAAkCA,IAAlC,KACAD,QAAQ,CAACS,QAAT,CAAmB,aAAnB,CAFD;AAIA;;AAED,SAASL,yBAAT,CAAoC;AAAEJ,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,CAApC,EAAyD;AACxD,SACC,uBAAY,qBAAZ,EAAmCA,IAAnC,KACAD,QAAQ,CAACS,QAAT,CAAmB,cAAnB,CAFD;AAIA;;AAED,SAASJ,wBAAT,CAAmC;AAAEL,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,EAAuB0B,KAAvB;AARV,IA7BF,EAyCGF,eAAe,IAChB,4BAAC,8CAAD;AACC,IAAA,MAAM,EAAGC,kBADV;AAEC,IAAA,QAAQ,EAAKC,KAAF,IACVd,QAAQ,CAAEZ,IAAF,EAAQ,cAAR,EAAwB0B,KAAxB;AAHV,IA1CF,CADD;AAoDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalBorderRadiusControl as BorderRadiusControl,\n\t__experimentalBorderStyleControl as BorderStyleControl,\n\t__experimentalColorGradientControl as ColorGradientControl,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSetting } from '../editor/utils';\n\nconst MIN_BORDER_WIDTH = 0;\n\n// Defining empty array here instead of inline avoids unnecessary re-renders of\n// color control.\nconst EMPTY_ARRAY = [];\n\nexport function useHasBorderPanel( { supports, name } ) {\n\tconst controls = [\n\t\tuseHasBorderColorControl( { supports, name } ),\n\t\tuseHasBorderRadiusControl( { supports, name } ),\n\t\tuseHasBorderStyleControl( { supports, name } ),\n\t\tuseHasBorderWidthControl( { supports, name } ),\n\t];\n\n\treturn controls.some( Boolean );\n}\n\nfunction useHasBorderColorControl( { supports, name } ) {\n\treturn (\n\t\tuseSetting( 'border.customColor', name ) &&\n\t\tsupports.includes( 'borderColor' )\n\t);\n}\n\nfunction useHasBorderRadiusControl( { supports, name } ) {\n\treturn (\n\t\tuseSetting( 'border.customRadius', name ) &&\n\t\tsupports.includes( 'borderRadius' )\n\t);\n}\n\nfunction useHasBorderStyleControl( { supports, name } ) {\n\treturn (\n\t\tuseSetting( 'border.customStyle', name ) &&\n\t\tsupports.includes( 'borderStyle' )\n\t);\n}\n\nfunction useHasBorderWidthControl( { supports, name } ) {\n\treturn (\n\t\tuseSetting( 'border.customWidth', name ) &&\n\t\tsupports.includes( 'borderWidth' )\n\t);\n}\n\nexport default function BorderPanel( {\n\tcontext: { supports, name },\n\tgetStyle,\n\tsetStyle,\n} ) {\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],\n\t} );\n\n\t// Border width.\n\tconst hasBorderWidth = useHasBorderWidthControl( { supports, name } );\n\tconst borderWidthValue = getStyle( name, 'borderWidth' );\n\n\t// Border style.\n\tconst hasBorderStyle = useHasBorderStyleControl( { supports, name } );\n\tconst borderStyle = getStyle( name, 'borderStyle' );\n\n\t// Border color.\n\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomGradients = ! useSetting( 'color.customGradient' );\n\tconst hasBorderColor = useHasBorderColorControl( { supports, name } );\n\tconst borderColor = getStyle( name, 'borderColor' );\n\n\t// Border radius.\n\tconst hasBorderRadius = useHasBorderRadiusControl( { supports, name } );\n\tconst borderRadiusValues = getStyle( name, 'borderRadius' );\n\n\treturn (\n\t\t<PanelBody title={ __( 'Border' ) } initialOpen={ true }>\n\t\t\t{ ( hasBorderWidth || hasBorderStyle ) && (\n\t\t\t\t<div className=\"edit-site-global-styles-sidebar__border-controls-row\">\n\t\t\t\t\t{ hasBorderWidth && (\n\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\tvalue={ borderWidthValue }\n\t\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\t\tmin={ MIN_BORDER_WIDTH }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetStyle(\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t'borderWidth',\n\t\t\t\t\t\t\t\t\tvalue || undefined\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ hasBorderStyle && (\n\t\t\t\t\t\t<BorderStyleControl\n\t\t\t\t\t\t\tvalue={ borderStyle }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetStyle( name, 'borderStyle', value )\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</div>\n\t\t\t) }\n\t\t\t{ hasBorderColor && (\n\t\t\t\t<ColorGradientControl\n\t\t\t\t\tlabel={ __( 'Color' ) }\n\t\t\t\t\tcolorValue={ borderColor }\n\t\t\t\t\tcolors={ colors }\n\t\t\t\t\tgradients={ undefined }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tdisableCustomGradients={ disableCustomGradients }\n\t\t\t\t\tonColorChange={ ( value ) =>\n\t\t\t\t\t\tsetStyle( name, 'borderColor', value )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasBorderRadius && (\n\t\t\t\t<BorderRadiusControl\n\t\t\t\t\tvalues={ borderRadiusValues }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetStyle( name, 'borderRadius', value )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t</PanelBody>\n\t);\n}\n"]}
|
|
@@ -66,7 +66,9 @@ function ColorPalettePanel({
|
|
|
66
66
|
slug
|
|
67
67
|
}) => slug);
|
|
68
68
|
}, [contextName]);
|
|
69
|
-
return (0, _element.createElement)(
|
|
69
|
+
return (0, _element.createElement)("div", {
|
|
70
|
+
className: "edit-site-global-styles-color-palette-panel"
|
|
71
|
+
}, (0, _element.createElement)(_components.__experimentalColorEdit, {
|
|
70
72
|
immutableColorSlugs: immutableColorSlugs,
|
|
71
73
|
colors: colors,
|
|
72
74
|
onChange: newColors => {
|
|
@@ -74,6 +76,6 @@ function ColorPalettePanel({
|
|
|
74
76
|
},
|
|
75
77
|
emptyUI: (0, _i18n.__)('Colors are empty! Add some colors to create your own color palette.'),
|
|
76
78
|
canReset: colors === userColors
|
|
77
|
-
});
|
|
79
|
+
}));
|
|
78
80
|
}
|
|
79
81
|
//# sourceMappingURL=color-palette-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/color-palette-panel.js"],"names":["EMPTY_ARRAY","ColorPalettePanel","contextName","getSetting","setSetting","colors","userColors","immutableColorSlugs","select","baseStyles","editSiteStore","getSettings","__experimentalGlobalStylesBaseStyles","contextualBasePalette","globalPalette","basePalette","theme","core","map","slug","newColors"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,WAAW,GAAG,EAApB;;AAEe,SAASC,iBAAT,CAA4B;AAC1CC,EAAAA,WAD0C;AAE1CC,EAAAA,UAF0C;AAG1CC,EAAAA;AAH0C,CAA5B,EAIX;AACH,QAAMC,MAAM,GAAG,uBAAY,eAAZ,EAA6BH,WAA7B,CAAf;AACA,QAAMI,UAAU,GAAGH,UAAU,CAAED,WAAF,EAAe,eAAf,CAA7B;AACA,QAAMK,mBAAmB,GAAG,qBACzBC,MAAF,IAAc;AAAA;;AACb,UAAMC,UAAU,GAAGD,MAAM,CAAEE,YAAF,CAAN,CAAwBC,WAAxB,GACjBC,oCADF;;AAEA,UAAMC,qBAAqB,GAAG,iBAAKJ,UAAL,EAAiB,CAC9C,UAD8C,EAE9C,QAF8C,EAG9CP,WAH8C,EAI9C,OAJ8C,EAK9C,SAL8C,CAAjB,CAA9B;AAOA,UAAMY,aAAa,GAAG,iBAAKL,UAAL,EAAiB,CACtC,UADsC,EAEtC,OAFsC,EAGtC,SAHsC,CAAjB,CAAtB;AAKA,UAAMM,WAAW,6CAChBF,qBADgB,aAChBA,qBADgB,uBAChBA,qBAAqB,CAAEG,KADP,yEAEhBH,qBAFgB,aAEhBA,qBAFgB,uBAEhBA,qBAAqB,CAAEI,IAFP,yCAGhBH,aAHgB,aAGhBA,aAHgB,uBAGhBA,aAAa,CAAEE,KAHC,uCAIhBF,aAJgB,aAIhBA,aAJgB,uBAIhBA,aAAa,CAAEG,IAJhB;;AAKA,QAAK,CAAEF,WAAP,EAAqB;AACpB,aAAOf,WAAP;AACA;;AACD,WAAOe,WAAW,CAACG,GAAZ,CAAiB,CAAE;AAAEC,MAAAA;AAAF,KAAF,KAAgBA,IAAjC,CAAP;AACA,GAzB0B,EA0B3B,CAAEjB,WAAF,CA1B2B,CAA5B;AA4BA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,mCAAD;AACC,IAAA,mBAAmB,EAAGK,mBADvB;AAEC,IAAA,MAAM,EAAGF,MAFV;AAGC,IAAA,QAAQ,EAAKe,SAAF,IAAiB;AAC3BhB,MAAAA,UAAU,CAAEF,WAAF,EAAe,eAAf,EAAgCkB,SAAhC,CAAV;AACA,KALF;AAMC,IAAA,OAAO,EAAG,cACT,qEADS,CANX;AASC,IAAA,QAAQ,EAAGf,MAAM,KAAKC;AATvB,IADD,CADD;AAeA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalColorEdit as ColorEdit } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useSetting } from '../editor/utils';\nimport { store as editSiteStore } from '../../store';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation, as in a connected or\n * other pure component which performs `shouldComponentUpdate` check on props.\n * This should be used as a last resort, since the normalized data should be\n * maintained by the reducer result in state.\n *\n * @type {Array}\n */\nconst EMPTY_ARRAY = [];\n\nexport default function ColorPalettePanel( {\n\tcontextName,\n\tgetSetting,\n\tsetSetting,\n} ) {\n\tconst colors = useSetting( 'color.palette', contextName );\n\tconst userColors = getSetting( contextName, 'color.palette' );\n\tconst immutableColorSlugs = useSelect(\n\t\t( select ) => {\n\t\t\tconst baseStyles = select( editSiteStore ).getSettings()\n\t\t\t\t.__experimentalGlobalStylesBaseStyles;\n\t\t\tconst contextualBasePalette = get( baseStyles, [\n\t\t\t\t'settings',\n\t\t\t\t'blocks',\n\t\t\t\tcontextName,\n\t\t\t\t'color',\n\t\t\t\t'palette',\n\t\t\t] );\n\t\t\tconst globalPalette = get( baseStyles, [\n\t\t\t\t'settings',\n\t\t\t\t'color',\n\t\t\t\t'palette',\n\t\t\t] );\n\t\t\tconst basePalette =\n\t\t\t\tcontextualBasePalette?.theme ??\n\t\t\t\tcontextualBasePalette?.core ??\n\t\t\t\tglobalPalette?.theme ??\n\t\t\t\tglobalPalette?.core;\n\t\t\tif ( ! basePalette ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\t\t\treturn basePalette.map( ( { slug } ) => slug );\n\t\t},\n\t\t[ contextName ]\n\t);\n\treturn (\n\t\t<div className=\"edit-site-global-styles-color-palette-panel\">\n\t\t\t<ColorEdit\n\t\t\t\timmutableColorSlugs={ immutableColorSlugs }\n\t\t\t\tcolors={ colors }\n\t\t\t\tonChange={ ( newColors ) => {\n\t\t\t\t\tsetSetting( contextName, 'color.palette', newColors );\n\t\t\t\t} }\n\t\t\t\temptyUI={ __(\n\t\t\t\t\t'Colors are empty! Add some colors to create your own color palette.'\n\t\t\t\t) }\n\t\t\t\tcanReset={ colors === userColors }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -16,7 +16,7 @@ var _i18n = require("@wordpress/i18n");
|
|
|
16
16
|
|
|
17
17
|
var _utils = require("../editor/utils");
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _palette = _interopRequireDefault(require("./palette"));
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* WordPress dependencies
|
|
@@ -37,17 +37,22 @@ function ColorPanel({
|
|
|
37
37
|
name
|
|
38
38
|
},
|
|
39
39
|
getStyle,
|
|
40
|
-
setStyle
|
|
41
|
-
getSetting,
|
|
42
|
-
setSetting
|
|
40
|
+
setStyle
|
|
43
41
|
}) {
|
|
44
|
-
const
|
|
45
|
-
const disableCustomColors = !(0, _utils.useSetting)('color.custom', name);
|
|
42
|
+
const solids = (0, _utils.useSetting)('color.palette', name);
|
|
46
43
|
const gradients = (0, _utils.useSetting)('color.gradients', name);
|
|
47
|
-
const
|
|
44
|
+
const areCustomSolidsEnabled = (0, _utils.useSetting)('color.custom', name);
|
|
45
|
+
const areCustomGradientsEnabled = (0, _utils.useSetting)('color.customGradient', name);
|
|
46
|
+
const isLinkEnabled = (0, _utils.useSetting)('color.link', name);
|
|
47
|
+
const isTextEnabled = (0, _utils.useSetting)('color.text', name);
|
|
48
|
+
const isBackgroundEnabled = (0, _utils.useSetting)('color.background', name);
|
|
49
|
+
const hasLinkColor = supports.includes('linkColor') && isLinkEnabled && (solids.length > 0 || areCustomSolidsEnabled);
|
|
50
|
+
const hasTextColor = supports.includes('color') && isTextEnabled && (solids.length > 0 || areCustomSolidsEnabled);
|
|
51
|
+
const hasBackgroundColor = supports.includes('backgroundColor') && isBackgroundEnabled && (solids.length > 0 || areCustomSolidsEnabled);
|
|
52
|
+
const hasGradientColor = supports.includes('background') && (gradients.length > 0 || areCustomGradientsEnabled);
|
|
48
53
|
const settings = [];
|
|
49
54
|
|
|
50
|
-
if (
|
|
55
|
+
if (hasTextColor) {
|
|
51
56
|
const color = getStyle(name, 'color');
|
|
52
57
|
const userColor = getStyle(name, 'color', 'user');
|
|
53
58
|
settings.push({
|
|
@@ -60,7 +65,7 @@ function ColorPanel({
|
|
|
60
65
|
|
|
61
66
|
let backgroundSettings = {};
|
|
62
67
|
|
|
63
|
-
if (
|
|
68
|
+
if (hasBackgroundColor) {
|
|
64
69
|
const backgroundColor = getStyle(name, 'backgroundColor');
|
|
65
70
|
const userBackgroundColor = getStyle(name, 'backgroundColor', 'user');
|
|
66
71
|
backgroundSettings = {
|
|
@@ -75,7 +80,7 @@ function ColorPanel({
|
|
|
75
80
|
|
|
76
81
|
let gradientSettings = {};
|
|
77
82
|
|
|
78
|
-
if (
|
|
83
|
+
if (hasGradientColor) {
|
|
79
84
|
const gradient = getStyle(name, 'background');
|
|
80
85
|
const userGradient = getStyle(name, 'background', 'user');
|
|
81
86
|
gradientSettings = {
|
|
@@ -88,14 +93,14 @@ function ColorPanel({
|
|
|
88
93
|
}
|
|
89
94
|
}
|
|
90
95
|
|
|
91
|
-
if (
|
|
96
|
+
if (hasBackgroundColor || hasGradientColor) {
|
|
92
97
|
settings.push({ ...backgroundSettings,
|
|
93
98
|
...gradientSettings,
|
|
94
99
|
label: (0, _i18n.__)('Background color')
|
|
95
100
|
});
|
|
96
101
|
}
|
|
97
102
|
|
|
98
|
-
if (
|
|
103
|
+
if (hasLinkColor) {
|
|
99
104
|
const color = getStyle(name, 'linkColor');
|
|
100
105
|
const userColor = getStyle(name, 'linkColor', 'user');
|
|
101
106
|
settings.push({
|
|
@@ -106,18 +111,16 @@ function ColorPanel({
|
|
|
106
111
|
});
|
|
107
112
|
}
|
|
108
113
|
|
|
109
|
-
return (0, _element.createElement)(
|
|
114
|
+
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_palette.default, {
|
|
115
|
+
contextName: name
|
|
116
|
+
}), (0, _element.createElement)(_blockEditor.__experimentalPanelColorGradientSettings, {
|
|
110
117
|
title: (0, _i18n.__)('Color'),
|
|
111
118
|
settings: settings,
|
|
112
|
-
colors:
|
|
119
|
+
colors: solids,
|
|
113
120
|
gradients: gradients,
|
|
114
|
-
disableCustomColors:
|
|
115
|
-
disableCustomGradients:
|
|
116
|
-
|
|
117
|
-
key: 'color-palette-panel-' + name,
|
|
118
|
-
contextName: name,
|
|
119
|
-
getSetting: getSetting,
|
|
120
|
-
setSetting: setSetting
|
|
121
|
+
disableCustomColors: !areCustomSolidsEnabled,
|
|
122
|
+
disableCustomGradients: !areCustomGradientsEnabled,
|
|
123
|
+
showTitle: false
|
|
121
124
|
}));
|
|
122
125
|
}
|
|
123
126
|
//# sourceMappingURL=color-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/color-panel.js"],"names":["useHasColorPanel","supports","includes","ColorPanel","context","name","getStyle","setStyle","solids","gradients","areCustomSolidsEnabled","areCustomGradientsEnabled","isLinkEnabled","isTextEnabled","isBackgroundEnabled","hasLinkColor","length","hasTextColor","hasBackgroundColor","hasGradientColor","settings","color","userColor","push","colorValue","onColorChange","value","label","clearable","backgroundSettings","backgroundColor","userBackgroundColor","gradientSettings","gradient","userGradient","gradientValue","onGradientChange"],"mappings":";;;;;;;;;;;;AAGA;;AACA;;AAMA;;AACA;;AAXA;AACA;AACA;;AAIA;AACA;AACA;AAKO,SAASA,gBAAT,CAA2B;AAAEC,EAAAA;AAAF,CAA3B,EAA0C;AAChD,SACCA,QAAQ,CAACC,QAAT,CAAmB,OAAnB,KACAD,QAAQ,CAACC,QAAT,CAAmB,iBAAnB,CADA,IAEAD,QAAQ,CAACC,QAAT,CAAmB,YAAnB,CAFA,IAGAD,QAAQ,CAACC,QAAT,CAAmB,WAAnB,CAJD;AAMA;;AAEc,SAASC,UAAT,CAAqB;AACnCC,EAAAA,OAAO,EAAE;AAAEH,IAAAA,QAAF;AAAYI,IAAAA;AAAZ,GAD0B;AAEnCC,EAAAA,QAFmC;AAGnCC,EAAAA;AAHmC,CAArB,EAIX;AACH,QAAMC,MAAM,GAAG,uBAAY,eAAZ,EAA6BH,IAA7B,CAAf;AACA,QAAMI,SAAS,GAAG,uBAAY,iBAAZ,EAA+BJ,IAA/B,CAAlB;AACA,QAAMK,sBAAsB,GAAG,uBAAY,cAAZ,EAA4BL,IAA5B,CAA/B;AACA,QAAMM,yBAAyB,GAAG,uBACjC,sBADiC,EAEjCN,IAFiC,CAAlC;AAIA,QAAMO,aAAa,GAAG,uBAAY,YAAZ,EA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Q,WAAR,EAAqB,MAArB,CAA1B;AACAe,IAAAA,QAAQ,CAACG,IAAT,CAAe;AACdC,MAAAA,UAAU,EAAEH,KADE;AAEdI,MAAAA,aAAa,EAAIC,KAAF,IAAanB,QAAQ,CAAEF,IAAF,EAAQ,WAAR,EAAqBqB,KAArB,CAFtB;AAGdC,MAAAA,KAAK,EAAE,cAAI,YAAJ,CAHO;AAIdC,MAAAA,SAAS,EAAEP,KAAK,KAAKC;AAJP,KAAf;AAMA;;AAED,SACC,qDACC,4BAAC,gBAAD;AAAS,IAAA,WAAW,EAAGjB;AAAvB,IADD,EAEC,4BAAC,qDAAD;AACC,IAAA,KAAK,EAAG,cAAI,OAAJ,CADT;AAEC,IAAA,QAAQ,EAAGe,QAFZ;AAGC,IAAA,MAAM,EAAGZ,MAHV;AAIC,IAAA,SAAS,EAAGC,SAJb;AAKC,IAAA,mBAAmB,EAAG,CAAEC,sBALzB;AAMC,IAAA,sBAAsB,EAAG,CAAEC,yBAN5B;AAOC,IAAA,SAAS,EAAG;AAPb,IAFD,CADD;AAcA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalPanelColorGradientSettings as PanelColorGradientSettings } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\n\nimport { useSetting } from '../editor/utils';\nimport Palette from './palette';\n\nexport function useHasColorPanel( { supports } ) {\n\treturn (\n\t\tsupports.includes( 'color' ) ||\n\t\tsupports.includes( 'backgroundColor' ) ||\n\t\tsupports.includes( 'background' ) ||\n\t\tsupports.includes( 'linkColor' )\n\t);\n}\n\nexport default function ColorPanel( {\n\tcontext: { supports, name },\n\tgetStyle,\n\tsetStyle,\n} ) {\n\tconst solids = useSetting( 'color.palette', name );\n\tconst gradients = useSetting( 'color.gradients', name );\n\tconst areCustomSolidsEnabled = useSetting( 'color.custom', name );\n\tconst areCustomGradientsEnabled = useSetting(\n\t\t'color.customGradient',\n\t\tname\n\t);\n\tconst isLinkEnabled = useSetting( 'color.link', name );\n\tconst isTextEnabled = useSetting( 'color.text', name );\n\tconst isBackgroundEnabled = useSetting( 'color.background', name );\n\n\tconst hasLinkColor =\n\t\tsupports.includes( 'linkColor' ) &&\n\t\tisLinkEnabled &&\n\t\t( solids.length > 0 || areCustomSolidsEnabled );\n\tconst hasTextColor =\n\t\tsupports.includes( 'color' ) &&\n\t\tisTextEnabled &&\n\t\t( solids.length > 0 || areCustomSolidsEnabled );\n\tconst hasBackgroundColor =\n\t\tsupports.includes( 'backgroundColor' ) &&\n\t\tisBackgroundEnabled &&\n\t\t( solids.length > 0 || areCustomSolidsEnabled );\n\tconst hasGradientColor =\n\t\tsupports.includes( 'background' ) &&\n\t\t( gradients.length > 0 || areCustomGradientsEnabled );\n\n\tconst settings = [];\n\n\tif ( hasTextColor ) {\n\t\tconst color = getStyle( name, 'color' );\n\t\tconst userColor = getStyle( name, 'color', 'user' );\n\t\tsettings.push( {\n\t\t\tcolorValue: color,\n\t\t\tonColorChange: ( value ) => setStyle( name, 'color', value ),\n\t\t\tlabel: __( 'Text color' ),\n\t\t\tclearable: color === userColor,\n\t\t} );\n\t}\n\n\tlet backgroundSettings = {};\n\tif ( hasBackgroundColor ) {\n\t\tconst backgroundColor = getStyle( name, 'backgroundColor' );\n\t\tconst userBackgroundColor = getStyle( name, 'backgroundColor', 'user' );\n\t\tbackgroundSettings = {\n\t\t\tcolorValue: backgroundColor,\n\t\t\tonColorChange: ( value ) =>\n\t\t\t\tsetStyle( name, 'backgroundColor', value ),\n\t\t};\n\t\tif ( backgroundColor ) {\n\t\t\tbackgroundSettings.clearable =\n\t\t\t\tbackgroundColor === userBackgroundColor;\n\t\t}\n\t}\n\n\tlet gradientSettings = {};\n\tif ( hasGradientColor ) {\n\t\tconst gradient = getStyle( name, 'background' );\n\t\tconst userGradient = getStyle( name, 'background', 'user' );\n\t\tgradientSettings = {\n\t\t\tgradientValue: gradient,\n\t\t\tonGradientChange: ( value ) =>\n\t\t\t\tsetStyle( name, 'background', value ),\n\t\t};\n\t\tif ( gradient ) {\n\t\t\tgradientSettings.clearable = gradient === userGradient;\n\t\t}\n\t}\n\n\tif ( hasBackgroundColor || hasGradientColor ) {\n\t\tsettings.push( {\n\t\t\t...backgroundSettings,\n\t\t\t...gradientSettings,\n\t\t\tlabel: __( 'Background color' ),\n\t\t} );\n\t}\n\n\tif ( hasLinkColor ) {\n\t\tconst color = getStyle( name, 'linkColor' );\n\t\tconst userColor = getStyle( name, 'linkColor', 'user' );\n\t\tsettings.push( {\n\t\t\tcolorValue: color,\n\t\t\tonColorChange: ( value ) => setStyle( name, 'linkColor', value ),\n\t\t\tlabel: __( 'Link color' ),\n\t\t\tclearable: color === userColor,\n\t\t} );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Palette contextName={ name } />\n\t\t\t<PanelColorGradientSettings\n\t\t\t\ttitle={ __( 'Color' ) }\n\t\t\t\tsettings={ settings }\n\t\t\t\tcolors={ solids }\n\t\t\t\tgradients={ gradients }\n\t\t\t\tdisableCustomColors={ ! areCustomSolidsEnabled }\n\t\t\t\tdisableCustomGradients={ ! areCustomGradientsEnabled }\n\t\t\t\tshowTitle={ false }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _components = require("@wordpress/components");
|
|
13
|
+
|
|
14
|
+
var _icons = require("@wordpress/icons");
|
|
15
|
+
|
|
16
|
+
var _i18n = require("@wordpress/i18n");
|
|
17
|
+
|
|
18
|
+
var _borderPanel = require("./border-panel");
|
|
19
|
+
|
|
20
|
+
var _colorPanel = require("./color-panel");
|
|
21
|
+
|
|
22
|
+
var _dimensionsPanel = require("./dimensions-panel");
|
|
23
|
+
|
|
24
|
+
var _typographyPanel = require("./typography-panel");
|
|
25
|
+
|
|
26
|
+
var _navigationButton = _interopRequireDefault(require("./navigation-button"));
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* WordPress dependencies
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Internal dependencies
|
|
34
|
+
*/
|
|
35
|
+
function ContextMenu({
|
|
36
|
+
context,
|
|
37
|
+
parentMenu = ''
|
|
38
|
+
}) {
|
|
39
|
+
const hasTypographyPanel = (0, _typographyPanel.useHasTypographyPanel)(context);
|
|
40
|
+
const hasColorPanel = (0, _colorPanel.useHasColorPanel)(context);
|
|
41
|
+
const hasBorderPanel = (0, _borderPanel.useHasBorderPanel)(context);
|
|
42
|
+
const hasDimensionsPanel = (0, _dimensionsPanel.useHasDimensionsPanel)(context);
|
|
43
|
+
const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
|
|
44
|
+
return (0, _element.createElement)(_components.__experimentalItemGroup, null, hasTypographyPanel && (0, _element.createElement)(_navigationButton.default, {
|
|
45
|
+
icon: _icons.typography,
|
|
46
|
+
path: parentMenu + '/typography'
|
|
47
|
+
}, (0, _i18n.__)('Typography')), hasColorPanel && (0, _element.createElement)(_navigationButton.default, {
|
|
48
|
+
icon: _icons.color,
|
|
49
|
+
path: parentMenu + '/colors'
|
|
50
|
+
}, (0, _i18n.__)('Colors')), hasLayoutPanel && (0, _element.createElement)(_navigationButton.default, {
|
|
51
|
+
icon: _icons.layout,
|
|
52
|
+
path: parentMenu + '/layout'
|
|
53
|
+
}, (0, _i18n.__)('Layout')));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var _default = ContextMenu;
|
|
57
|
+
exports.default = _default;
|
|
58
|
+
//# sourceMappingURL=context-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/context-menu.js"],"names":["ContextMenu","context","parentMenu","hasTypographyPanel","hasColorPanel","hasBorderPanel","hasDimensionsPanel","hasLayoutPanel","typography","color","layout"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAdA;AACA;AACA;;AAKA;AACA;AACA;AAOA,SAASA,WAAT,CAAsB;AAAEC,EAAAA,OAAF;AAAWC,EAAAA,UAAU,GAAG;AAAxB,CAAtB,EAAqD;AACpD,QAAMC,kBAAkB,GAAG,4CAAuBF,OAAvB,CAA3B;AACA,QAAMG,aAAa,GAAG,kCAAkBH,OAAlB,CAAtB;AACA,QAAMI,cAAc,GAAG,oCAAmBJ,OAAnB,CAAvB;AACA,QAAMK,kBAAkB,GAAG,4CAAuBL,OAAvB,CAA3B;AACA,QAAMM,cAAc,GAAGF,cAAc,IAAIC,kBAAzC;AAEA,SACC,4BAAC,mCAAD,QACGH,kBAAkB,IACnB,4BAAC,yBAAD;AACC,IAAA,IAAI,EAAGK,iBADR;AAEC,IAAA,IAAI,EAAGN,UAAU,GAAG;AAFrB,KAIG,cAAI,YAAJ,CAJH,CAFF,EASGE,aAAa,IACd,4BAAC,yBAAD;AACC,IAAA,IAAI,EAAGK,YADR;AAEC,IAAA,IAAI,EAAGP,UAAU,GAAG;AAFrB,KAIG,cAAI,QAAJ,CAJH,CAVF,EAiBGK,cAAc,IACf,4BAAC,yBAAD;AACC,IAAA,IAAI,EAAGG,aADR;AAEC,IAAA,IAAI,EAAGR,UAAU,GAAG;AAFrB,KAIG,cAAI,QAAJ,CAJH,CAlBF,CADD;AA4BA;;eAEcF,W","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalItemGroup as ItemGroup } from '@wordpress/components';\nimport { typography, color, layout } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useHasBorderPanel } from './border-panel';\nimport { useHasColorPanel } from './color-panel';\nimport { useHasDimensionsPanel } from './dimensions-panel';\nimport { useHasTypographyPanel } from './typography-panel';\nimport NavigationButton from './navigation-button';\n\nfunction ContextMenu( { context, parentMenu = '' } ) {\n\tconst hasTypographyPanel = useHasTypographyPanel( context );\n\tconst hasColorPanel = useHasColorPanel( context );\n\tconst hasBorderPanel = useHasBorderPanel( context );\n\tconst hasDimensionsPanel = useHasDimensionsPanel( context );\n\tconst hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;\n\n\treturn (\n\t\t<ItemGroup>\n\t\t\t{ hasTypographyPanel && (\n\t\t\t\t<NavigationButton\n\t\t\t\t\ticon={ typography }\n\t\t\t\t\tpath={ parentMenu + '/typography' }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Typography' ) }\n\t\t\t\t</NavigationButton>\n\t\t\t) }\n\t\t\t{ hasColorPanel && (\n\t\t\t\t<NavigationButton\n\t\t\t\t\ticon={ color }\n\t\t\t\t\tpath={ parentMenu + '/colors' }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Colors' ) }\n\t\t\t\t</NavigationButton>\n\t\t\t) }\n\t\t\t{ hasLayoutPanel && (\n\t\t\t\t<NavigationButton\n\t\t\t\t\ticon={ layout }\n\t\t\t\t\tpath={ parentMenu + '/layout' }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Layout' ) }\n\t\t\t\t</NavigationButton>\n\t\t\t) }\n\t\t</ItemGroup>\n\t);\n}\n\nexport default ContextMenu;\n"]}
|
|
@@ -23,10 +23,13 @@ var _utils = require("../editor/utils");
|
|
|
23
23
|
/**
|
|
24
24
|
* Internal dependencies
|
|
25
25
|
*/
|
|
26
|
+
const AXIAL_SIDES = ['horizontal', 'vertical'];
|
|
27
|
+
|
|
26
28
|
function useHasDimensionsPanel(context) {
|
|
27
29
|
const hasPadding = useHasPadding(context);
|
|
28
30
|
const hasMargin = useHasMargin(context);
|
|
29
|
-
|
|
31
|
+
const hasGap = useHasGap(context);
|
|
32
|
+
return hasPadding || hasMargin || hasGap;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
function useHasPadding({
|
|
@@ -45,6 +48,14 @@ function useHasMargin({
|
|
|
45
48
|
return settings && supports.includes('margin');
|
|
46
49
|
}
|
|
47
50
|
|
|
51
|
+
function useHasGap({
|
|
52
|
+
name,
|
|
53
|
+
supports
|
|
54
|
+
}) {
|
|
55
|
+
const settings = (0, _utils.useSetting)('spacing.blockGap', name);
|
|
56
|
+
return settings && supports.includes('--wp--style--block-gap');
|
|
57
|
+
}
|
|
58
|
+
|
|
48
59
|
function filterValuesBySides(values, sides) {
|
|
49
60
|
if (!sides) {
|
|
50
61
|
// If no custom side configuration all sides are opted into by default.
|
|
@@ -53,7 +64,19 @@ function filterValuesBySides(values, sides) {
|
|
|
53
64
|
|
|
54
65
|
|
|
55
66
|
const filteredValues = {};
|
|
56
|
-
sides.forEach(side =>
|
|
67
|
+
sides.forEach(side => {
|
|
68
|
+
if (side === 'vertical') {
|
|
69
|
+
filteredValues.top = values.top;
|
|
70
|
+
filteredValues.bottom = values.bottom;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (side === 'horizontal') {
|
|
74
|
+
filteredValues.left = values.left;
|
|
75
|
+
filteredValues.right = values.right;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
filteredValues[side] = values[side];
|
|
79
|
+
});
|
|
57
80
|
return filteredValues;
|
|
58
81
|
}
|
|
59
82
|
|
|
@@ -82,11 +105,13 @@ function DimensionsPanel({
|
|
|
82
105
|
} = context;
|
|
83
106
|
const showPaddingControl = useHasPadding(context);
|
|
84
107
|
const showMarginControl = useHasMargin(context);
|
|
108
|
+
const showGapControl = useHasGap(context);
|
|
85
109
|
const units = (0, _components.__experimentalUseCustomUnits)({
|
|
86
110
|
availableUnits: (0, _utils.useSetting)('spacing.units', name) || ['%', 'px', 'em', 'rem', 'vw']
|
|
87
111
|
});
|
|
88
112
|
const paddingValues = splitStyleValue(getStyle(name, 'padding'));
|
|
89
113
|
const paddingSides = (0, _blockEditor.__experimentalUseCustomSides)(name, 'padding');
|
|
114
|
+
const isAxialPadding = paddingSides && paddingSides.some(side => AXIAL_SIDES.includes(side));
|
|
90
115
|
|
|
91
116
|
const setPaddingValues = newPaddingValues => {
|
|
92
117
|
const padding = filterValuesBySides(newPaddingValues, paddingSides);
|
|
@@ -95,10 +120,11 @@ function DimensionsPanel({
|
|
|
95
120
|
|
|
96
121
|
const resetPaddingValue = () => setPaddingValues({});
|
|
97
122
|
|
|
98
|
-
const hasPaddingValue = () => paddingValues && Object.keys(paddingValues).length;
|
|
123
|
+
const hasPaddingValue = () => !!paddingValues && Object.keys(paddingValues).length;
|
|
99
124
|
|
|
100
125
|
const marginValues = splitStyleValue(getStyle(name, 'margin'));
|
|
101
126
|
const marginSides = (0, _blockEditor.__experimentalUseCustomSides)(name, 'margin');
|
|
127
|
+
const isAxialMargin = marginSides && marginSides.some(side => AXIAL_SIDES.includes(side));
|
|
102
128
|
|
|
103
129
|
const setMarginValues = newMarginValues => {
|
|
104
130
|
const margin = filterValuesBySides(newMarginValues, marginSides);
|
|
@@ -107,16 +133,26 @@ function DimensionsPanel({
|
|
|
107
133
|
|
|
108
134
|
const resetMarginValue = () => setMarginValues({});
|
|
109
135
|
|
|
110
|
-
const hasMarginValue = () => marginValues && Object.keys(marginValues).length;
|
|
136
|
+
const hasMarginValue = () => !!marginValues && Object.keys(marginValues).length;
|
|
137
|
+
|
|
138
|
+
const gapValue = getStyle(name, '--wp--style--block-gap');
|
|
139
|
+
|
|
140
|
+
const setGapValue = newGapValue => {
|
|
141
|
+
setStyle(name, '--wp--style--block-gap', newGapValue);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const resetGapValue = () => setGapValue(undefined);
|
|
145
|
+
|
|
146
|
+
const hasGapValue = () => !!gapValue;
|
|
111
147
|
|
|
112
148
|
const resetAll = () => {
|
|
113
149
|
resetPaddingValue();
|
|
114
150
|
resetMarginValue();
|
|
151
|
+
resetGapValue();
|
|
115
152
|
};
|
|
116
153
|
|
|
117
154
|
return (0, _element.createElement)(_components.__experimentalToolsPanel, {
|
|
118
|
-
label: (0, _i18n.__)('Dimensions
|
|
119
|
-
header: (0, _i18n.__)('Dimensions'),
|
|
155
|
+
label: (0, _i18n.__)('Dimensions'),
|
|
120
156
|
resetAll: resetAll
|
|
121
157
|
}, showPaddingControl && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
|
|
122
158
|
hasValue: hasPaddingValue,
|
|
@@ -129,7 +165,8 @@ function DimensionsPanel({
|
|
|
129
165
|
label: (0, _i18n.__)('Padding'),
|
|
130
166
|
sides: paddingSides,
|
|
131
167
|
units: units,
|
|
132
|
-
allowReset: false
|
|
168
|
+
allowReset: false,
|
|
169
|
+
splitOnAxis: isAxialPadding
|
|
133
170
|
})), showMarginControl && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
|
|
134
171
|
hasValue: hasMarginValue,
|
|
135
172
|
label: (0, _i18n.__)('Margin'),
|
|
@@ -141,7 +178,20 @@ function DimensionsPanel({
|
|
|
141
178
|
label: (0, _i18n.__)('Margin'),
|
|
142
179
|
sides: marginSides,
|
|
143
180
|
units: units,
|
|
144
|
-
allowReset: false
|
|
181
|
+
allowReset: false,
|
|
182
|
+
splitOnAxis: isAxialMargin
|
|
183
|
+
})), showGapControl && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
|
|
184
|
+
hasValue: hasGapValue,
|
|
185
|
+
label: (0, _i18n.__)('Block spacing'),
|
|
186
|
+
onDeselect: resetGapValue,
|
|
187
|
+
isShownByDefault: true
|
|
188
|
+
}, (0, _element.createElement)(_components.__experimentalUnitControl, {
|
|
189
|
+
label: (0, _i18n.__)('Block spacing'),
|
|
190
|
+
__unstableInputWidth: "80px",
|
|
191
|
+
min: 0,
|
|
192
|
+
onChange: setGapValue,
|
|
193
|
+
units: units,
|
|
194
|
+
value: gapValue
|
|
145
195
|
})));
|
|
146
196
|
}
|
|
147
197
|
//# sourceMappingURL=dimensions-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/dimensions-panel.js"],"names":["AXIAL_SIDES","useHasDimensionsPanel","context","hasPadding","useHasPadding","hasMargin","useHasMargin","hasGap","useHasGap","name","supports","settings","includes","filterValuesBySides","values","sides","filteredValues","forEach","side","top","bottom","left","right","splitStyleValue","value","DimensionsPanel","getStyle","setStyle","showPaddingControl","showMarginControl","showGapControl","units","availableUnits","paddingValues","paddingSides","isAxialPadding","some","setPaddingValues","newPaddingValues","padding","resetPaddingValue","hasPaddingValue","Object","keys","length","marginValues","marginSides","isAxialMargin","setMarginValues","newMarginValues","margin","resetMarginValue","hasMarginValue","gapValue","setGapValue","newGapValue","resetGapValue","undefined","hasGapValue","resetAll"],"mappings":";;;;;;;;;;AAGA;;AACA;;AAOA;;AAKA;;AAhBA;AACA;AACA;;AAWA;AACA;AACA;AAGA,MAAMA,WAAW,GAAG,CAAE,YAAF,EAAgB,UAAhB,CAApB;;AAEO,SAASC,qBAAT,CAAgCC,OAAhC,EAA0C;AAChD,QAAMC,UAAU,GAAGC,aAAa,CAAEF,OAAF,CAAhC;AACA,QAAMG,SAAS,GAAGC,YAAY,CAAEJ,OAAF,CAA9B;AACA,QAAMK,MAAM,GAAGC,SAAS,CAAEN,OAAF,CAAxB;AAEA,SAAOC,UAAU,IAAIE,SAAd,IAA2BE,MAAlC;AACA;;AAED,SAASH,aAAT,CAAwB;AAAEK,EAAAA,IAAF;AAAQC,EAAAA;AAAR,CAAxB,EAA6C;AAC5C,QAAMC,QAAQ,GAAG,uBAAY,uBAAZ,EAAqCF,IAArC,CAAjB;AAEA,SAAOE,QAAQ,IAAID,QAAQ,CAACE,QAAT,CAAmB,SAAnB,CAAnB;AACA;;AAED,SAASN,YAAT,CAAuB;AAAEG,EAAAA,IAAF;AAAQC,EAAAA;AAAR,CAAvB,EAA4C;AAC3C,QAAMC,QAAQ,GAAG,uBAAY,sBAAZ,EAAoCF,IAApC,CAAjB;AA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t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalBoxControl as BoxControl,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { __experimentalUseCustomSides as useCustomSides } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { useSetting } from '../editor/utils';\n\nconst AXIAL_SIDES = [ 'horizontal', 'vertical' ];\n\nexport function useHasDimensionsPanel( context ) {\n\tconst hasPadding = useHasPadding( context );\n\tconst hasMargin = useHasMargin( context );\n\tconst hasGap = useHasGap( context );\n\n\treturn hasPadding || hasMargin || hasGap;\n}\n\nfunction useHasPadding( { name, supports } ) {\n\tconst settings = useSetting( 'spacing.customPadding', name );\n\n\treturn settings && supports.includes( 'padding' );\n}\n\nfunction useHasMargin( { name, supports } ) {\n\tconst settings = useSetting( 'spacing.customMargin', name );\n\n\treturn settings && supports.includes( 'margin' );\n}\n\nfunction useHasGap( { name, supports } ) {\n\tconst settings = useSetting( 'spacing.blockGap', name );\n\n\treturn settings && supports.includes( '--wp--style--block-gap' );\n}\n\nfunction filterValuesBySides( values, sides ) {\n\tif ( ! sides ) {\n\t\t// If no custom side configuration all sides are opted into by default.\n\t\treturn values;\n\t}\n\n\t// Only include sides opted into within filtered values.\n\tconst filteredValues = {};\n\tsides.forEach( ( side ) => {\n\t\tif ( side === 'vertical' ) {\n\t\t\tfilteredValues.top = values.top;\n\t\t\tfilteredValues.bottom = values.bottom;\n\t\t}\n\t\tif ( side === 'horizontal' ) {\n\t\t\tfilteredValues.left = values.left;\n\t\t\tfilteredValues.right = values.right;\n\t\t}\n\t\tfilteredValues[ side ] = values[ side ];\n\t} );\n\n\treturn filteredValues;\n}\n\nfunction splitStyleValue( value ) {\n\t// Check for shorthand value ( a string value ).\n\tif ( value && typeof value === 'string' ) {\n\t\t// Convert to value for individual sides for BoxControl.\n\t\treturn {\n\t\t\ttop: value,\n\t\t\tright: value,\n\t\t\tbottom: value,\n\t\t\tleft: value,\n\t\t};\n\t}\n\n\treturn value;\n}\n\nexport default function DimensionsPanel( { context, getStyle, setStyle } ) {\n\tconst { name } = context;\n\tconst showPaddingControl = useHasPadding( context );\n\tconst showMarginControl = useHasMargin( context );\n\tconst showGapControl = useHasGap( context );\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units', name ) || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t],\n\t} );\n\n\tconst paddingValues = splitStyleValue( getStyle( name, 'padding' ) );\n\tconst paddingSides = useCustomSides( name, 'padding' );\n\tconst isAxialPadding =\n\t\tpaddingSides &&\n\t\tpaddingSides.some( ( side ) => AXIAL_SIDES.includes( side ) );\n\n\tconst setPaddingValues = ( newPaddingValues ) => {\n\t\tconst padding = filterValuesBySides( newPaddingValues, paddingSides );\n\t\tsetStyle( name, 'padding', padding );\n\t};\n\tconst resetPaddingValue = () => setPaddingValues( {} );\n\tconst hasPaddingValue = () =>\n\t\t!! paddingValues && Object.keys( paddingValues ).length;\n\n\tconst marginValues = splitStyleValue( getStyle( name, 'margin' ) );\n\tconst marginSides = useCustomSides( name, 'margin' );\n\tconst isAxialMargin =\n\t\tmarginSides &&\n\t\tmarginSides.some( ( side ) => AXIAL_SIDES.includes( side ) );\n\n\tconst setMarginValues = ( newMarginValues ) => {\n\t\tconst margin = filterValuesBySides( newMarginValues, marginSides );\n\t\tsetStyle( name, 'margin', margin );\n\t};\n\tconst resetMarginValue = () => setMarginValues( {} );\n\tconst hasMarginValue = () =>\n\t\t!! marginValues && Object.keys( marginValues ).length;\n\n\tconst gapValue = getStyle( name, '--wp--style--block-gap' );\n\n\tconst setGapValue = ( newGapValue ) => {\n\t\tsetStyle( name, '--wp--style--block-gap', newGapValue );\n\t};\n\tconst resetGapValue = () => setGapValue( undefined );\n\tconst hasGapValue = () => !! gapValue;\n\n\tconst resetAll = () => {\n\t\tresetPaddingValue();\n\t\tresetMarginValue();\n\t\tresetGapValue();\n\t};\n\n\treturn (\n\t\t<ToolsPanel label={ __( 'Dimensions' ) } resetAll={ resetAll }>\n\t\t\t{ showPaddingControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasPaddingValue }\n\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\tonDeselect={ resetPaddingValue }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BoxControl\n\t\t\t\t\t\tvalues={ paddingValues }\n\t\t\t\t\t\tonChange={ setPaddingValues }\n\t\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\t\tsides={ paddingSides }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ isAxialPadding }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showMarginControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasMarginValue }\n\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\tonDeselect={ resetMarginValue }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BoxControl\n\t\t\t\t\t\tvalues={ marginValues }\n\t\t\t\t\t\tonChange={ setMarginValues }\n\t\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\t\tsides={ marginSides }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ isAxialMargin }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showGapControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasGapValue }\n\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\tonDeselect={ resetGapValue }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tonChange={ setGapValue }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tvalue={ gapValue }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</ToolsPanel>\n\t);\n}\n"]}
|