@wordpress/edit-site 5.3.6 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/components/add-new-template/new-template.js +1 -20
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +1 -0
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/editor/index.js +3 -1
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +5 -5
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +5 -2
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/color-utils.js +1 -1
- package/build/components/global-styles/color-utils.js.map +1 -1
- package/build/components/global-styles/context-menu.js +22 -6
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/custom-css.js +1 -1
- package/build/components/global-styles/custom-css.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +41 -486
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/duotone-panel.js +78 -0
- package/build/components/global-styles/duotone-panel.js.map +1 -0
- package/build/components/global-styles/filter-utils.js +17 -0
- package/build/components/global-styles/filter-utils.js.map +1 -0
- package/build/components/global-styles/gradients-palette-panel.js +8 -3
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/header.js +3 -1
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/hooks.js +14 -51
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/palette.js +3 -1
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/preview.js +9 -5
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +3 -2
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +13 -6
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-button-color.js +7 -5
- package/build/components/global-styles/screen-button-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +8 -6
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-filters.js +46 -0
- package/build/components/global-styles/screen-filters.js.map +1 -0
- package/build/components/global-styles/screen-heading-color.js +8 -6
- package/build/components/global-styles/screen-heading-color.js.map +1 -1
- package/build/components/global-styles/screen-layout.js +13 -5
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +3 -2
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +3 -2
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +3 -1
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/shadow-panel.js +2 -3
- package/build/components/global-styles/shadow-panel.js.map +1 -1
- package/build/components/global-styles/subtitle.js +3 -2
- package/build/components/global-styles/subtitle.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +23 -303
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +6 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +12 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +67 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/navigation-inspector/index.js +0 -29
- package/build/components/navigation-inspector/index.js.map +1 -1
- package/build/components/navigation-inspector/navigation-menu.js +22 -5
- package/build/components/navigation-inspector/navigation-menu.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +1 -1
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-card/index.js +9 -2
- package/build/components/sidebar-edit-mode/template-card/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-card/last-revision.js +84 -0
- package/build/components/sidebar-edit-mode/template-card/last-revision.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +9 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/start-template-options/index.js +175 -0
- package/build/components/start-template-options/index.js.map +1 -0
- package/build/hooks/push-changes-to-global-styles/index.js +5 -4
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/store/actions.js +2 -2
- package/build/store/actions.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +1 -18
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +1 -0
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/editor/index.js +2 -1
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +6 -6
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +5 -2
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/color-utils.js +2 -2
- package/build-module/components/global-styles/color-utils.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +20 -6
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/custom-css.js +1 -1
- package/build-module/components/global-styles/custom-css.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +43 -479
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/duotone-panel.js +67 -0
- package/build-module/components/global-styles/duotone-panel.js.map +1 -0
- package/build-module/components/global-styles/filter-utils.js +9 -0
- package/build-module/components/global-styles/filter-utils.js.map +1 -0
- package/build-module/components/global-styles/gradients-palette-panel.js +8 -3
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/header.js +3 -1
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +12 -49
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/palette.js +3 -1
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/preview.js +10 -6
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +4 -3
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +12 -5
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-button-color.js +8 -6
- package/build-module/components/global-styles/screen-button-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +9 -7
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-filters.js +33 -0
- package/build-module/components/global-styles/screen-filters.js.map +1 -0
- package/build-module/components/global-styles/screen-heading-color.js +9 -7
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
- package/build-module/components/global-styles/screen-layout.js +11 -2
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +4 -3
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +4 -3
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +3 -1
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel.js +3 -4
- package/build-module/components/global-styles/shadow-panel.js.map +1 -1
- package/build-module/components/global-styles/subtitle.js +3 -2
- package/build-module/components/global-styles/subtitle.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +24 -300
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +5 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +12 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +65 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/navigation-inspector/index.js +0 -27
- package/build-module/components/navigation-inspector/index.js.map +1 -1
- package/build-module/components/navigation-inspector/navigation-menu.js +25 -8
- package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +1 -1
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-card/index.js +9 -4
- package/build-module/components/sidebar-edit-mode/template-card/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-card/last-revision.js +70 -0
- package/build-module/components/sidebar-edit-mode/template-card/last-revision.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +9 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +156 -0
- package/build-module/components/start-template-options/index.js.map +1 -0
- package/build-module/hooks/push-changes-to-global-styles/index.js +6 -5
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/store/actions.js +2 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-style/style-rtl.css +73 -4
- package/build-style/style.css +73 -4
- package/package.json +31 -31
- package/src/components/add-new-template/new-template.js +1 -16
- package/src/components/app/index.js +0 -1
- package/src/components/block-editor/editor-canvas.js +1 -0
- package/src/components/editor/index.js +2 -0
- package/src/components/global-styles/border-panel.js +6 -6
- package/src/components/global-styles/color-palette-panel.js +3 -0
- package/src/components/global-styles/color-utils.js +2 -3
- package/src/components/global-styles/context-menu.js +25 -4
- package/src/components/global-styles/custom-css.js +1 -1
- package/src/components/global-styles/dimensions-panel.js +43 -573
- package/src/components/global-styles/duotone-panel.js +82 -0
- package/src/components/global-styles/filter-utils.js +9 -0
- package/src/components/global-styles/gradients-palette-panel.js +4 -1
- package/src/components/global-styles/header.js +7 -1
- package/src/components/global-styles/hooks.js +17 -90
- package/src/components/global-styles/palette.js +1 -1
- package/src/components/global-styles/preview.js +155 -140
- package/src/components/global-styles/screen-background-color.js +3 -2
- package/src/components/global-styles/screen-block-list.js +16 -5
- package/src/components/global-styles/screen-button-color.js +8 -6
- package/src/components/global-styles/screen-colors.js +7 -7
- package/src/components/global-styles/screen-filters.js +27 -0
- package/src/components/global-styles/screen-heading-color.js +9 -7
- package/src/components/global-styles/screen-layout.js +9 -2
- package/src/components/global-styles/screen-link-color.js +3 -2
- package/src/components/global-styles/screen-text-color.js +3 -2
- package/src/components/global-styles/screen-typography.js +1 -1
- package/src/components/global-styles/shadow-panel.js +6 -3
- package/src/components/global-styles/style.scss +5 -0
- package/src/components/global-styles/subtitle.js +5 -2
- package/src/components/global-styles/typography-panel.js +29 -395
- package/src/components/global-styles/ui.js +5 -0
- package/src/components/keyboard-shortcut-help-modal/config.js +10 -0
- package/src/components/keyboard-shortcuts/index.js +70 -0
- package/src/components/navigation-inspector/index.js +0 -32
- package/src/components/navigation-inspector/navigation-menu.js +24 -6
- package/src/components/sidebar-edit-mode/index.js +1 -1
- package/src/components/sidebar-edit-mode/template-card/index.js +24 -14
- package/src/components/sidebar-edit-mode/template-card/last-revision.js +75 -0
- package/src/components/sidebar-edit-mode/template-card/style.scss +4 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +7 -1
- package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +0 -4
- package/src/components/start-template-options/index.js +171 -0
- package/src/components/start-template-options/style.scss +76 -0
- package/src/hooks/push-changes-to-global-styles/index.js +26 -21
- package/src/store/actions.js +2 -2
- package/src/style.scss +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/actions.js"],"names":["toggleFeature","featureName","registry","since","alternative","dispatch","preferencesStore","toggle","__experimentalSetPreviewDeviceType","deviceType","type","setTemplate","templateId","templateSlug","template","resolveSelect","coreStore","getEntityRecord","slug","error","postType","id","context","addTemplate","newTemplate","saveEntityRecord","content","editEntityRecord","blocks","undoIgnore","removeTemplate","deleteEntityRecord","force","lastError","select","getLastEntityDeleteError","noticesStore","createSuccessNotice","title","rendered","errorMessage","message","code","createErrorNotice","setTemplatePart","templatePartId","setHomeTemplateId","version","setEditedPostContext","setPage","page","path","postId","entity","link","__experimentalGetTemplateForLink","setNavigationPanelActiveMenu","openNavigationPanelToMenu","setIsNavigationPanelOpened","setIsInserterOpened","value","updateSettings","settings","setIsListViewOpened","isOpen","setIsSaveViewOpened","revertTemplate","allowUndo","templateEntityConfig","getEntityConfig","fileTemplatePath","baseURL","source","fileTemplate","serializeBlocks","blocksForSerialization","edited","getEditedEntityRecord","raw","undoRevert","actions","label","onClick","openGeneralSidebar","name","interfaceStore","enableComplementaryArea","editSiteStoreName","closeGeneralSidebar","disableComplementaryArea","switchEditorMode","mode","set","blockEditorStore","clearSelectedBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAnBA;AACA;AACA;;AAaA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAT,CAAwBC,WAAxB,EAAsC;AAC5C,SAAO,gBAA0B;AAAA,QAAf;AAAEC,MAAAA;AAAF,KAAe;AAChC,6BAAY,yDAAZ,EAAuE;AACtEC,MAAAA,KAAK,EAAE,KAD+D;AAEtEC,MAAAA,WAAW,EACV;AAHqE,KAAvE;AAMAF,IAAAA,QAAQ,CACNG,QADF,CACYC,kBADZ,EAEEC,MAFF,CAEU,gBAFV,EAE4BN,WAF5B;AAGA,GAVD;AAWA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASO,kCAAT,CAA6CC,UAA7C,EAA0D;AAChE,SAAO;AACNC,IAAAA,IAAI,EAAE,yBADA;AAEND,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAME,WAAW,GACvB,CAAEC,UAAF,EAAcC,YAAd,KACA,eAAoC;AAA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kBAAkB,GAC5BC,IAAF,IACA,SAAoB;AAAA,MAAlB;AAAElF,IAAAA;AAAF,GAAkB;AACnBA,EAAAA,QAAQ,CACNG,QADF,CACYgF,gBADZ,EAEEC,uBAFF,CAE2BC,qBAF3B,EAE8CH,IAF9C;AAGA,CANK;AAQP;AACA;AACA;;;;;AACO,MAAMI,mBAAmB,GAC/B,MACA,SAAoB;AAAA,MAAlB;AAAEtF,IAAAA;AAAF,GAAkB;AACnBA,EAAAA,QAAQ,CACNG,QADF,CACYgF,gBADZ,EAEEI,wBAFF,CAE4BF,qBAF5B;AAGA,CANK;;;;AAQA,MAAMG,gBAAgB,GAC1BC,IAAF,IACA,UAAoB;AAAA,MAAlB;AAAEzF,IAAAA;AAAF,GAAkB;AACnBA,EAAAA,QAAQ,CACNG,QADF,CACY,kBADZ,EAEEuF,GAFF,CAEO,gBAFP,EAEyB,YAFzB,EAEuCD,IAFvC,EADmB,CAKnB;;AACA,MAAKA,IAAI,KAAK,QAAd,EAAyB;AACxBzF,IAAAA,QAAQ,CAACG,QAAT,CAAmBwF,kBAAnB,EAAsCC,kBAAtC;AACA;;AAED,MAAKH,IAAI,KAAK,QAAd,EAAyB;AACxB,qBAAO,cAAI,wBAAJ,CAAP,EAAuC,WAAvC;AACA,GAFD,MAEO,IAAKA,IAAI,KAAK,QAAd,EAAyB;AAC/B,qBAAO,cAAI,sBAAJ,CAAP,EAAqC,WAArC;AACA;AACD,CAjBK","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport deprecated from '@wordpress/deprecated';\nimport { addQueryArgs, getPathAndQueryString } from '@wordpress/url';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { speak } from '@wordpress/a11y';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME as editSiteStoreName } from './constants';\nimport isTemplateRevertable from '../utils/is-template-revertable';\n\n/**\n * Dispatches an action that toggles a feature flag.\n *\n * @param {string} featureName Feature name.\n */\nexport function toggleFeature( featureName ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( \"select( 'core/edit-site' ).toggleFeature( featureName )\", {\n\t\t\tsince: '6.0',\n\t\t\talternative:\n\t\t\t\t\"select( 'core/preferences').toggle( 'core/edit-site', featureName )\",\n\t\t} );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.toggle( 'core/edit-site', featureName );\n\t};\n}\n\n/**\n * Action that changes the width of the editing canvas.\n *\n * @param {string} deviceType\n *\n * @return {Object} Action object.\n */\nexport function __experimentalSetPreviewDeviceType( deviceType ) {\n\treturn {\n\t\ttype: 'SET_PREVIEW_DEVICE_TYPE',\n\t\tdeviceType,\n\t};\n}\n\n/**\n * Action that sets a template, optionally fetching it from REST API.\n *\n * @param {number} templateId The template ID.\n * @param {string} templateSlug The template slug.\n * @return {Object} Action object.\n */\nexport const setTemplate =\n\t( templateId, templateSlug ) =>\n\tasync ( { dispatch, registry } ) => {\n\t\tif ( ! templateSlug ) {\n\t\t\ttry {\n\t\t\t\tconst template = await registry\n\t\t\t\t\t.resolveSelect( coreStore )\n\t\t\t\t\t.getEntityRecord( 'postType', 'wp_template', templateId );\n\t\t\t\ttemplateSlug = template?.slug;\n\t\t\t} catch ( error ) {}\n\t\t}\n\n\t\tdispatch( {\n\t\t\ttype: 'SET_EDITED_POST',\n\t\t\tpostType: 'wp_template',\n\t\t\tid: templateId,\n\t\t\tcontext: { templateSlug },\n\t\t} );\n\t};\n\n/**\n * Action that adds a new template and sets it as the current template.\n *\n * @param {Object} template The template.\n *\n * @return {Object} Action object used to set the current template.\n */\nexport const addTemplate =\n\t( template ) =>\n\tasync ( { dispatch, registry } ) => {\n\t\tconst newTemplate = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\n\t\tif ( template.content ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.editEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\tnewTemplate.id,\n\t\t\t\t\t{ blocks: parse( template.content ) },\n\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t);\n\t\t}\n\n\t\tdispatch( {\n\t\t\ttype: 'SET_EDITED_POST',\n\t\t\tpostType: 'wp_template',\n\t\t\tid: newTemplate.id,\n\t\t\tcontext: { templateSlug: newTemplate.slug },\n\t\t} );\n\t};\n\n/**\n * Action that removes a template.\n *\n * @param {Object} template The template object.\n */\nexport const removeTemplate =\n\t( template ) =>\n\tasync ( { registry } ) => {\n\t\ttry {\n\t\t\tawait registry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.deleteEntityRecord( 'postType', template.type, template.id, {\n\t\t\t\t\tforce: true,\n\t\t\t\t} );\n\n\t\t\tconst lastError = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getLastEntityDeleteError(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id\n\t\t\t\t);\n\n\t\t\tif ( lastError ) {\n\t\t\t\tthrow lastError;\n\t\t\t}\n\n\t\t\tregistry.dispatch( noticesStore ).createSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t__( '\"%s\" deleted.' ),\n\t\t\t\t\ttemplate.title.rendered\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while deleting the template.' );\n\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Action that sets a template part.\n *\n * @param {string} templatePartId The template part ID.\n *\n * @return {Object} Action object.\n */\nexport function setTemplatePart( templatePartId ) {\n\treturn {\n\t\ttype: 'SET_EDITED_POST',\n\t\tpostType: 'wp_template_part',\n\t\tid: templatePartId,\n\t};\n}\n\n/**\n * @deprecated\n */\nexport function setHomeTemplateId() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).setHomeTemplateId\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n\n\treturn {\n\t\ttype: 'NOTHING',\n\t};\n}\n\n/**\n * Set's the current block editor context.\n *\n * @param {Object} context The context object.\n *\n * @return {number} The resolved template ID for the page route.\n */\nexport function setEditedPostContext( context ) {\n\treturn {\n\t\ttype: 'SET_EDITED_POST_CONTEXT',\n\t\tcontext,\n\t};\n}\n\n/**\n * Resolves the template for a page and displays both. If no path is given, attempts\n * to use the postId to generate a path like `?p=${ postId }`.\n *\n * @param {Object} page The page object.\n * @param {string} page.type The page type.\n * @param {string} page.slug The page slug.\n * @param {string} page.path The page path.\n * @param {Object} page.context The page context.\n *\n * @return {number} The resolved template ID for the page route.\n */\nexport const setPage =\n\t( page ) =>\n\tasync ( { dispatch, registry } ) => {\n\t\tif ( ! page.path && page.context?.postId ) {\n\t\t\tconst entity = await registry\n\t\t\t\t.resolveSelect( coreStore )\n\t\t\t\t.getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpage.context.postType || 'post',\n\t\t\t\t\tpage.context.postId\n\t\t\t\t);\n\t\t\t// If the entity is undefined for some reason, path will resolve to \"/\"\n\t\t\tpage.path = getPathAndQueryString( entity?.link );\n\t\t}\n\n\t\tconst template = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.__experimentalGetTemplateForLink( page.path );\n\n\t\tif ( ! template ) {\n\t\t\treturn;\n\t\t}\n\n\t\tdispatch( {\n\t\t\ttype: 'SET_EDITED_POST',\n\t\t\tpostType: 'wp_template',\n\t\t\tid: template.id,\n\t\t\tcontext: {\n\t\t\t\t...page.context,\n\t\t\t\ttemplateSlug: template.slug,\n\t\t\t},\n\t\t} );\n\n\t\treturn template.id;\n\t};\n\n/**\n * Action that sets the active navigation panel menu.\n *\n * @deprecated\n *\n * @return {Object} Action object.\n */\nexport function setNavigationPanelActiveMenu() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).setNavigationPanelActiveMenu\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n\n\treturn { type: 'NOTHING' };\n}\n\n/**\n * Opens the navigation panel and sets its active menu at the same time.\n *\n * @deprecated\n */\nexport function openNavigationPanelToMenu() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).openNavigationPanelToMenu\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n\n\treturn { type: 'NOTHING' };\n}\n\n/**\n * Sets whether the navigation panel should be open.\n *\n * @deprecated\n */\nexport function setIsNavigationPanelOpened() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).setIsNavigationPanelOpened\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n\n\treturn { type: 'NOTHING' };\n}\n\n/**\n * Opens or closes the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to update the settings.\n *\n * @param {Object} settings New settings.\n *\n * @return {Object} Action object.\n */\nexport function updateSettings( settings ) {\n\treturn {\n\t\ttype: 'UPDATE_SETTINGS',\n\t\tsettings,\n\t};\n}\n\n/**\n * Sets whether the list view panel should be open.\n *\n * @param {boolean} isOpen If true, opens the list view. If false, closes it.\n * It does not toggle the state, but sets it directly.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Sets whether the save view panel should be open.\n *\n * @param {boolean} isOpen If true, opens the save view. If false, closes it.\n * It does not toggle the state, but sets it directly.\n */\nexport function setIsSaveViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_SAVE_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport const revertTemplate =\n\t( template, { allowUndo = true } = {} ) =>\n\tasync ( { registry } ) => {\n\t\tif ( ! isTemplateRevertable( template ) ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( __( 'This template is not revertable.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst templateEntityConfig = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityConfig( 'postType', template.type );\n\n\t\t\tif ( ! templateEntityConfig ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t\t`${ templateEntityConfig.baseURL }/${ template.id }`,\n\t\t\t\t{ context: 'edit', source: 'theme' }\n\t\t\t);\n\n\t\t\tconst fileTemplate = await apiFetch( { path: fileTemplatePath } );\n\t\t\tif ( ! fileTemplate ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst serializeBlocks = ( {\n\t\t\t\tblocks: blocksForSerialization = [],\n\t\t\t} ) => __unstableSerializeAndClean( blocksForSerialization );\n\n\t\t\tconst edited = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id\n\t\t\t\t);\n\n\t\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t\t// the revert in the header toolbar correctly.\n\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: serializeBlocks, // Required to make the `undo` behave correctly.\n\t\t\t\t\tblocks: edited.blocks, // Required to revert the blocks in the editor.\n\t\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tundoIgnore: true, // Required to merge this edit with the last undo level.\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\t\tregistry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.editEntityRecord( 'postType', template.type, fileTemplate.id, {\n\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\tblocks,\n\t\t\t\t\tsource: 'theme',\n\t\t\t\t} );\n\n\t\t\tif ( allowUndo ) {\n\t\t\t\tconst undoRevert = () => {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\t\tedited.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createSuccessNotice( __( 'Template reverted.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: undoRevert,\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} else {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createSuccessNotice( __( 'Template reverted.' ) );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n/**\n * Action that opens an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n */\nexport const openGeneralSidebar =\n\t( name ) =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( interfaceStore )\n\t\t\t.enableComplementaryArea( editSiteStoreName, name );\n\t};\n\n/**\n * Action that closes the sidebar.\n */\nexport const closeGeneralSidebar =\n\t() =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( interfaceStore )\n\t\t\t.disableComplementaryArea( editSiteStoreName );\n\t};\n\nexport const switchEditorMode =\n\t( mode ) =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( 'core/preferences' )\n\t\t\t.set( 'core/edit-site', 'editorMode', mode );\n\n\t\t// Unselect blocks when we switch to a non visual mode.\n\t\tif ( mode !== 'visual' ) {\n\t\t\tregistry.dispatch( blockEditorStore ).clearSelectedBlock();\n\t\t}\n\n\t\tif ( mode === 'visual' ) {\n\t\t\tspeak( __( 'Visual editor selected' ), 'assertive' );\n\t\t} else if ( mode === 'mosaic' ) {\n\t\t\tspeak( __( 'Mosaic view selected' ), 'assertive' );\n\t\t}\n\t};\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/actions.js"],"names":["toggleFeature","featureName","registry","since","alternative","dispatch","preferencesStore","toggle","__experimentalSetPreviewDeviceType","deviceType","type","setTemplate","templateId","templateSlug","template","resolveSelect","coreStore","getEntityRecord","slug","error","postType","id","context","addTemplate","newTemplate","saveEntityRecord","content","editEntityRecord","blocks","undoIgnore","removeTemplate","deleteEntityRecord","force","lastError","select","getLastEntityDeleteError","noticesStore","createSuccessNotice","title","rendered","errorMessage","message","code","createErrorNotice","setTemplatePart","templatePartId","setHomeTemplateId","version","setEditedPostContext","setPage","page","path","postId","entity","link","__experimentalGetTemplateForLink","setNavigationPanelActiveMenu","openNavigationPanelToMenu","setIsNavigationPanelOpened","setIsInserterOpened","value","updateSettings","settings","setIsListViewOpened","isOpen","setIsSaveViewOpened","revertTemplate","allowUndo","templateEntityConfig","getEntityConfig","fileTemplatePath","baseURL","source","fileTemplate","serializeBlocks","blocksForSerialization","edited","getEditedEntityRecord","raw","undoRevert","actions","label","onClick","openGeneralSidebar","name","interfaceStore","enableComplementaryArea","editSiteStoreName","closeGeneralSidebar","disableComplementaryArea","switchEditorMode","mode","set","blockEditorStore","clearSelectedBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAnBA;AACA;AACA;;AAaA;AACA;AACA;;AAI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QAAT,CAAmBwF,kBAAnB,EAAsCC,kBAAtC;AACA;;AAED,MAAKH,IAAI,KAAK,QAAd,EAAyB;AACxB,qBAAO,cAAI,wBAAJ,CAAP,EAAuC,WAAvC;AACA,GAFD,MAEO,IAAKA,IAAI,KAAK,MAAd,EAAuB;AAC7B,qBAAO,cAAI,sBAAJ,CAAP,EAAqC,WAArC;AACA;AACD,CAjBK","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport deprecated from '@wordpress/deprecated';\nimport { addQueryArgs, getPathAndQueryString } from '@wordpress/url';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { speak } from '@wordpress/a11y';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME as editSiteStoreName } from './constants';\nimport isTemplateRevertable from '../utils/is-template-revertable';\n\n/**\n * Dispatches an action that toggles a feature flag.\n *\n * @param {string} featureName Feature name.\n */\nexport function toggleFeature( featureName ) {\n\treturn function ( { registry } ) {\n\t\tdeprecated( \"select( 'core/edit-site' ).toggleFeature( featureName )\", {\n\t\t\tsince: '6.0',\n\t\t\talternative:\n\t\t\t\t\"select( 'core/preferences').toggle( 'core/edit-site', featureName )\",\n\t\t} );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.toggle( 'core/edit-site', featureName );\n\t};\n}\n\n/**\n * Action that changes the width of the editing canvas.\n *\n * @param {string} deviceType\n *\n * @return {Object} Action object.\n */\nexport function __experimentalSetPreviewDeviceType( deviceType ) {\n\treturn {\n\t\ttype: 'SET_PREVIEW_DEVICE_TYPE',\n\t\tdeviceType,\n\t};\n}\n\n/**\n * Action that sets a template, optionally fetching it from REST API.\n *\n * @param {number} templateId The template ID.\n * @param {string} templateSlug The template slug.\n * @return {Object} Action object.\n */\nexport const setTemplate =\n\t( templateId, templateSlug ) =>\n\tasync ( { dispatch, registry } ) => {\n\t\tif ( ! templateSlug ) {\n\t\t\ttry {\n\t\t\t\tconst template = await registry\n\t\t\t\t\t.resolveSelect( coreStore )\n\t\t\t\t\t.getEntityRecord( 'postType', 'wp_template', templateId );\n\t\t\t\ttemplateSlug = template?.slug;\n\t\t\t} catch ( error ) {}\n\t\t}\n\n\t\tdispatch( {\n\t\t\ttype: 'SET_EDITED_POST',\n\t\t\tpostType: 'wp_template',\n\t\t\tid: templateId,\n\t\t\tcontext: { templateSlug },\n\t\t} );\n\t};\n\n/**\n * Action that adds a new template and sets it as the current template.\n *\n * @param {Object} template The template.\n *\n * @return {Object} Action object used to set the current template.\n */\nexport const addTemplate =\n\t( template ) =>\n\tasync ( { dispatch, registry } ) => {\n\t\tconst newTemplate = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\n\t\tif ( template.content ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.editEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\tnewTemplate.id,\n\t\t\t\t\t{ blocks: parse( template.content ) },\n\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t);\n\t\t}\n\n\t\tdispatch( {\n\t\t\ttype: 'SET_EDITED_POST',\n\t\t\tpostType: 'wp_template',\n\t\t\tid: newTemplate.id,\n\t\t\tcontext: { templateSlug: newTemplate.slug },\n\t\t} );\n\t};\n\n/**\n * Action that removes a template.\n *\n * @param {Object} template The template object.\n */\nexport const removeTemplate =\n\t( template ) =>\n\tasync ( { registry } ) => {\n\t\ttry {\n\t\t\tawait registry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.deleteEntityRecord( 'postType', template.type, template.id, {\n\t\t\t\t\tforce: true,\n\t\t\t\t} );\n\n\t\t\tconst lastError = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getLastEntityDeleteError(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id\n\t\t\t\t);\n\n\t\t\tif ( lastError ) {\n\t\t\t\tthrow lastError;\n\t\t\t}\n\n\t\t\tregistry.dispatch( noticesStore ).createSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t__( '\"%s\" deleted.' ),\n\t\t\t\t\ttemplate.title.rendered\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while deleting the template.' );\n\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Action that sets a template part.\n *\n * @param {string} templatePartId The template part ID.\n *\n * @return {Object} Action object.\n */\nexport function setTemplatePart( templatePartId ) {\n\treturn {\n\t\ttype: 'SET_EDITED_POST',\n\t\tpostType: 'wp_template_part',\n\t\tid: templatePartId,\n\t};\n}\n\n/**\n * @deprecated\n */\nexport function setHomeTemplateId() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).setHomeTemplateId\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n\n\treturn {\n\t\ttype: 'NOTHING',\n\t};\n}\n\n/**\n * Set's the current block editor context.\n *\n * @param {Object} context The context object.\n *\n * @return {number} The resolved template ID for the page route.\n */\nexport function setEditedPostContext( context ) {\n\treturn {\n\t\ttype: 'SET_EDITED_POST_CONTEXT',\n\t\tcontext,\n\t};\n}\n\n/**\n * Resolves the template for a page and displays both. If no path is given, attempts\n * to use the postId to generate a path like `?p=${ postId }`.\n *\n * @param {Object} page The page object.\n * @param {string} page.type The page type.\n * @param {string} page.slug The page slug.\n * @param {string} page.path The page path.\n * @param {Object} page.context The page context.\n *\n * @return {number} The resolved template ID for the page route.\n */\nexport const setPage =\n\t( page ) =>\n\tasync ( { dispatch, registry } ) => {\n\t\tif ( ! page.path && page.context?.postId ) {\n\t\t\tconst entity = await registry\n\t\t\t\t.resolveSelect( coreStore )\n\t\t\t\t.getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpage.context.postType || 'post',\n\t\t\t\t\tpage.context.postId\n\t\t\t\t);\n\t\t\t// If the entity is undefined for some reason, path will resolve to \"/\"\n\t\t\tpage.path = getPathAndQueryString( entity?.link );\n\t\t}\n\n\t\tconst template = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.__experimentalGetTemplateForLink( page.path );\n\n\t\tif ( ! template ) {\n\t\t\treturn;\n\t\t}\n\n\t\tdispatch( {\n\t\t\ttype: 'SET_EDITED_POST',\n\t\t\tpostType: 'wp_template',\n\t\t\tid: template.id,\n\t\t\tcontext: {\n\t\t\t\t...page.context,\n\t\t\t\ttemplateSlug: template.slug,\n\t\t\t},\n\t\t} );\n\n\t\treturn template.id;\n\t};\n\n/**\n * Action that sets the active navigation panel menu.\n *\n * @deprecated\n *\n * @return {Object} Action object.\n */\nexport function setNavigationPanelActiveMenu() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).setNavigationPanelActiveMenu\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n\n\treturn { type: 'NOTHING' };\n}\n\n/**\n * Opens the navigation panel and sets its active menu at the same time.\n *\n * @deprecated\n */\nexport function openNavigationPanelToMenu() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).openNavigationPanelToMenu\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n\n\treturn { type: 'NOTHING' };\n}\n\n/**\n * Sets whether the navigation panel should be open.\n *\n * @deprecated\n */\nexport function setIsNavigationPanelOpened() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).setIsNavigationPanelOpened\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n\n\treturn { type: 'NOTHING' };\n}\n\n/**\n * Opens or closes the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to update the settings.\n *\n * @param {Object} settings New settings.\n *\n * @return {Object} Action object.\n */\nexport function updateSettings( settings ) {\n\treturn {\n\t\ttype: 'UPDATE_SETTINGS',\n\t\tsettings,\n\t};\n}\n\n/**\n * Sets whether the list view panel should be open.\n *\n * @param {boolean} isOpen If true, opens the list view. If false, closes it.\n * It does not toggle the state, but sets it directly.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Sets whether the save view panel should be open.\n *\n * @param {boolean} isOpen If true, opens the save view. If false, closes it.\n * It does not toggle the state, but sets it directly.\n */\nexport function setIsSaveViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_SAVE_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport const revertTemplate =\n\t( template, { allowUndo = true } = {} ) =>\n\tasync ( { registry } ) => {\n\t\tif ( ! isTemplateRevertable( template ) ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( __( 'This template is not revertable.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst templateEntityConfig = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityConfig( 'postType', template.type );\n\n\t\t\tif ( ! templateEntityConfig ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t\t`${ templateEntityConfig.baseURL }/${ template.id }`,\n\t\t\t\t{ context: 'edit', source: 'theme' }\n\t\t\t);\n\n\t\t\tconst fileTemplate = await apiFetch( { path: fileTemplatePath } );\n\t\t\tif ( ! fileTemplate ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst serializeBlocks = ( {\n\t\t\t\tblocks: blocksForSerialization = [],\n\t\t\t} ) => __unstableSerializeAndClean( blocksForSerialization );\n\n\t\t\tconst edited = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id\n\t\t\t\t);\n\n\t\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t\t// the revert in the header toolbar correctly.\n\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: serializeBlocks, // Required to make the `undo` behave correctly.\n\t\t\t\t\tblocks: edited.blocks, // Required to revert the blocks in the editor.\n\t\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tundoIgnore: true, // Required to merge this edit with the last undo level.\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\t\tregistry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.editEntityRecord( 'postType', template.type, fileTemplate.id, {\n\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\tblocks,\n\t\t\t\t\tsource: 'theme',\n\t\t\t\t} );\n\n\t\t\tif ( allowUndo ) {\n\t\t\t\tconst undoRevert = () => {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\t\tedited.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createSuccessNotice( __( 'Template reverted.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: undoRevert,\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} else {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createSuccessNotice( __( 'Template reverted.' ) );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n/**\n * Action that opens an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n */\nexport const openGeneralSidebar =\n\t( name ) =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( interfaceStore )\n\t\t\t.enableComplementaryArea( editSiteStoreName, name );\n\t};\n\n/**\n * Action that closes the sidebar.\n */\nexport const closeGeneralSidebar =\n\t() =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( interfaceStore )\n\t\t\t.disableComplementaryArea( editSiteStoreName );\n\t};\n\nexport const switchEditorMode =\n\t( mode ) =>\n\t( { registry } ) => {\n\t\tregistry\n\t\t\t.dispatch( 'core/preferences' )\n\t\t\t.set( 'core/edit-site', 'editorMode', mode );\n\n\t\t// Unselect blocks when we switch to a non visual mode.\n\t\tif ( mode !== 'visual' ) {\n\t\t\tregistry.dispatch( blockEditorStore ).clearSelectedBlock();\n\t\t}\n\n\t\tif ( mode === 'visual' ) {\n\t\t\tspeak( __( 'Visual editor selected' ), 'assertive' );\n\t\t} else if ( mode === 'text' ) {\n\t\t\tspeak( __( 'Code editor selected' ), 'assertive' );\n\t\t}\n\t};\n"]}
|
|
@@ -3,8 +3,6 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import apiFetch from '@wordpress/api-fetch';
|
|
7
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
8
6
|
import { DropdownMenu, MenuGroup, MenuItem, NavigableMenu } from '@wordpress/components';
|
|
9
7
|
import { useState } from '@wordpress/element';
|
|
10
8
|
import { useDispatch } from '@wordpress/data';
|
|
@@ -75,29 +73,14 @@ export default function NewTemplate(_ref) {
|
|
|
75
73
|
const {
|
|
76
74
|
title,
|
|
77
75
|
description,
|
|
78
|
-
slug
|
|
79
|
-
templatePrefix
|
|
76
|
+
slug
|
|
80
77
|
} = template;
|
|
81
|
-
let templateContent = template.content; // Try to find fallback content from existing templates.
|
|
82
|
-
|
|
83
|
-
if (!templateContent) {
|
|
84
|
-
const fallbackTemplate = await apiFetch({
|
|
85
|
-
path: addQueryArgs('/wp/v2/templates/lookup', {
|
|
86
|
-
slug,
|
|
87
|
-
is_custom: !isWPSuggestion,
|
|
88
|
-
template_prefix: templatePrefix
|
|
89
|
-
})
|
|
90
|
-
});
|
|
91
|
-
templateContent = fallbackTemplate.content.raw;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
78
|
const newTemplate = await saveEntityRecord('postType', 'wp_template', {
|
|
95
79
|
description,
|
|
96
80
|
// Slugs need to be strings, so this is for template `404`
|
|
97
81
|
slug: slug.toString(),
|
|
98
82
|
status: 'publish',
|
|
99
83
|
title,
|
|
100
|
-
content: templateContent,
|
|
101
84
|
// This adds a post meta field in template that is part of `is_custom` value calculation.
|
|
102
85
|
is_wp_suggestion: isWPSuggestion
|
|
103
86
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template.js"],"names":["apiFetch","addQueryArgs","DropdownMenu","MenuGroup","MenuItem","NavigableMenu","useState","useDispatch","store","coreStore","archive","blockMeta","category","home","list","media","notFound","page","plus","post","postAuthor","postDate","search","tag","layout","customGenericTemplateIcon","__","sprintf","noticesStore","AddCustomTemplateModal","useExistingTemplates","useDefaultTemplateTypes","useTaxonomiesMenuItems","usePostTypeMenuItems","useAuthorMenuItem","usePostTypeArchiveMenuItems","AddCustomGenericTemplateModal","TemplateActionsLoadingScreen","useHistory","editSiteStore","unlock","DEFAULT_TEMPLATE_SLUGS","TEMPLATE_ICONS","single","index","author","taxonomy","date","attachment","NewTemplate","postType","toggleProps","showIcon","showCustomTemplateModal","setShowCustomTemplateModal","showCustomGenericTemplateModal","setShowCustomGenericTemplateModal","entityForSuggestions","setEntityForSuggestions","isCreatingTemplate","setIsCreatingTemplate","history","saveEntityRecord","createErrorNotice","createSuccessNotice","setTemplate","setCanvasMode","createTemplate","template","isWPSuggestion","title","description","slug","templatePrefix","templateContent","content","fallbackTemplate","path","is_custom","template_prefix","raw","newTemplate","toString","status","is_wp_suggestion","throwOnError","id","push","postId","type","error","errorMessage","message","code","missingTemplates","useMissingTemplates","length","labels","add_new","add_new_item","noArrow","map","onClick","icon","existingTemplates","defaultTemplateTypes","existingTemplateSlugs","missingDefaultTemplates","filter","includes","onClickMenuItem","_entityForSuggestions","enhancedMissingDefaultTemplateTypes","defaultTaxonomiesMenuItems","taxonomiesMenuItems","defaultPostTypesMenuItems","postTypesMenuItems","authorMenuItem","forEach","menuItem","matchIndex","findIndex","sort","template1","template2","indexOf"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,QAAP,MAAqB,sBAArB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SACCC,YADD,EAECC,SAFD,EAGCC,QAHD,EAICC,aAJD,QAKO,uBALP;AAMA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SACCC,OADD,EAECC,SAFD,EAGCC,QAHD,EAICC,IAJD,EAKCC,IALD,EAMCC,KAND,EAOCC,QAPD,EAQCC,IARD,EASCC,IATD,EAUCC,IAVD,EAWCC,UAXD,EAYCC,QAZD,EAaCC,MAbD,EAcCC,GAdD,EAeCC,MAAM,IAAIC,yBAfX,QAgBO,kBAhBP;AAiBA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASnB,KAAK,IAAIoB,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,OAAOC,sBAAP,MAAmC,6BAAnC;AACA,SACCC,oBADD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F,sBAAsB,CAAE8E,eAAF,CADvB;AAEA,QAAM;AAAEK,IAAAA,yBAAF;AAA6BC,IAAAA;AAA7B,MACLnF,oBAAoB,CAAE6E,eAAF,CADrB;AAGA,QAAMO,cAAc,GAAGnF,iBAAiB,CAAE4E,eAAF,CAAxC;AACA,GACC,GAAGG,0BADJ,EAEC,GAAGE,yBAFJ,EAGCE,cAHD,EAIEC,OAJF,CAIaC,QAAF,IAAgB;AAC1B,QAAK,CAAEA,QAAP,EAAkB;AACjB;AACA;;AACD,UAAMC,UAAU,GAAGR,mCAAmC,CAACS,SAApC,CAChBrD,QAAF,IAAgBA,QAAQ,CAACI,IAAT,KAAkB+C,QAAQ,CAAC/C,IADzB,CAAnB,CAJ0B,CAO1B;AACA;AACA;AACA;AACA;;AACA,QAAKgD,UAAU,GAAG,CAAC,CAAnB,EAAuB;AACtBR,MAAAA,mCAAmC,CAAEQ,UAAF,CAAnC,GAAoDD,QAApD;AACA,KAFD,MAEO;AACNP,MAAAA,mCAAmC,CAACzB,IAApC,CAA0CgC,QAA1C;AACA;AACD,GArBD,EA1BC,CAgDD;;AACAP,EAAAA,mCAAmC,SAAnC,IAAAA,mCAAmC,WAAnC,YAAAA,mCAAmC,CAAEU,IAArC,CAA2C,CAAEC,SAAF,EAAaC,SAAb,KAA4B;AACtE,WACCnF,sBAAsB,CAACoF,OAAvB,CAAgCF,SAAS,CAACnD,IAA1C,IACA/B,sBAAsB,CAACoF,OAAvB,CAAgCD,SAAS,CAACpD,IAA1C,CAFD;AAIA,GALD;AAMA,QAAMsB,gBAAgB,GAAG,CACxB,GAAGkB,mCADqB,EAExB,GAAG7E,2BAA2B,EAFN,EAGxB,GAAGiF,kBAHqB,EAIxB,GAAGF,mBAJqB,CAAzB;AAMA,SAAOpB,gBAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tarchive,\n\tblockMeta,\n\tcategory,\n\thome,\n\tlist,\n\tmedia,\n\tnotFound,\n\tpage,\n\tplus,\n\tpost,\n\tpostAuthor,\n\tpostDate,\n\tsearch,\n\ttag,\n\tlayout as customGenericTemplateIcon,\n} from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AddCustomTemplateModal from './add-custom-template-modal';\nimport {\n\tuseExistingTemplates,\n\tuseDefaultTemplateTypes,\n\tuseTaxonomiesMenuItems,\n\tusePostTypeMenuItems,\n\tuseAuthorMenuItem,\n\tusePostTypeArchiveMenuItems,\n} from './utils';\nimport AddCustomGenericTemplateModal from './add-custom-generic-template-modal';\nimport TemplateActionsLoadingScreen from './template-actions-loading-screen';\nimport { useHistory } from '../routes';\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../private-apis';\n\nconst DEFAULT_TEMPLATE_SLUGS = [\n\t'front-page',\n\t'single',\n\t'page',\n\t'index',\n\t'archive',\n\t'author',\n\t'category',\n\t'date',\n\t'tag',\n\t'taxonomy',\n\t'search',\n\t'404',\n];\n\nconst TEMPLATE_ICONS = {\n\t'front-page': home,\n\tsingle: post,\n\tpage,\n\tarchive,\n\tsearch,\n\t404: notFound,\n\tindex: list,\n\tcategory,\n\tauthor: postAuthor,\n\ttaxonomy: blockMeta,\n\tdate: postDate,\n\ttag,\n\tattachment: media,\n};\n\nexport default function NewTemplate( {\n\tpostType,\n\ttoggleProps,\n\tshowIcon = true,\n} ) {\n\tconst [ showCustomTemplateModal, setShowCustomTemplateModal ] =\n\t\tuseState( false );\n\tconst [\n\t\tshowCustomGenericTemplateModal,\n\t\tsetShowCustomGenericTemplateModal,\n\t] = useState( false );\n\tconst [ entityForSuggestions, setEntityForSuggestions ] = useState( {} );\n\tconst [ isCreatingTemplate, setIsCreatingTemplate ] = useState( false );\n\n\tconst history = useHistory();\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { setTemplate, setCanvasMode } = unlock(\n\t\tuseDispatch( editSiteStore )\n\t);\n\tasync function createTemplate( template, isWPSuggestion = true ) {\n\t\tif ( isCreatingTemplate ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsCreatingTemplate( true );\n\t\ttry {\n\t\t\tconst { title, description, slug, templatePrefix } = template;\n\t\t\tlet templateContent = template.content;\n\t\t\t// Try to find fallback content from existing templates.\n\t\t\tif ( ! templateContent ) {\n\t\t\t\tconst fallbackTemplate = await apiFetch( {\n\t\t\t\t\tpath: addQueryArgs( '/wp/v2/templates/lookup', {\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tis_custom: ! isWPSuggestion,\n\t\t\t\t\t\ttemplate_prefix: templatePrefix,\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t\ttemplateContent = fallbackTemplate.content.raw;\n\t\t\t}\n\t\t\tconst newTemplate = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{\n\t\t\t\t\tdescription,\n\t\t\t\t\t// Slugs need to be strings, so this is for template `404`\n\t\t\t\t\tslug: slug.toString(),\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\ttitle,\n\t\t\t\t\tcontent: templateContent,\n\t\t\t\t\t// This adds a post meta field in template that is part of `is_custom` value calculation.\n\t\t\t\t\tis_wp_suggestion: isWPSuggestion,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\t// Set template before navigating away to avoid initial stale value.\n\t\t\tsetTemplate( newTemplate.id, newTemplate.slug );\n\t\t\t// Switch to edit mode.\n\t\t\tsetCanvasMode( 'edit' );\n\n\t\t\t// Navigate to the created template editor.\n\t\t\thistory.push( {\n\t\t\t\tpostId: newTemplate.id,\n\t\t\t\tpostType: newTemplate.type,\n\t\t\t} );\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\ttitle\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the template.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsCreatingTemplate( false );\n\t\t}\n\t}\n\n\tconst missingTemplates = useMissingTemplates(\n\t\tsetEntityForSuggestions,\n\t\tsetShowCustomTemplateModal\n\t);\n\tif ( ! missingTemplates.length ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tclassName=\"edit-site-new-template-dropdown\"\n\t\t\t\ticon={ showIcon ? plus : null }\n\t\t\t\ttext={ showIcon ? null : postType.labels.add_new }\n\t\t\t\tlabel={ postType.labels.add_new_item }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tnoArrow: false,\n\t\t\t\t} }\n\t\t\t\ttoggleProps={ toggleProps }\n\t\t\t>\n\t\t\t\t{ () => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isCreatingTemplate && (\n\t\t\t\t\t\t\t<TemplateActionsLoadingScreen />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<NavigableMenu className=\"edit-site-new-template-dropdown__popover\">\n\t\t\t\t\t\t\t<MenuGroup label={ postType.labels.add_new_item }>\n\t\t\t\t\t\t\t\t{ missingTemplates.map( ( template ) => {\n\t\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\t\tonClick,\n\t\t\t\t\t\t\t\t\t\ticon,\n\t\t\t\t\t\t\t\t\t} = template;\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\ticon ||\n\t\t\t\t\t\t\t\t\t\t\t\tTEMPLATE_ICONS[ slug ] ||\n\t\t\t\t\t\t\t\t\t\t\t\tpost\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\t\tinfo={ description }\n\t\t\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\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? onClick( template )\n\t\t\t\t\t\t\t\t\t\t\t\t\t: createTemplate( template )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\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</MenuGroup>\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\ticon={ customGenericTemplateIcon }\n\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t'Custom templates can be applied to any post or page.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tkey=\"custom-template\"\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tsetShowCustomGenericTemplateModal(\n\t\t\t\t\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Custom template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t\t{ showCustomTemplateModal && (\n\t\t\t\t<AddCustomTemplateModal\n\t\t\t\t\tonClose={ () => setShowCustomTemplateModal( false ) }\n\t\t\t\t\tonSelect={ createTemplate }\n\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\tisCreatingTemplate={ isCreatingTemplate }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showCustomGenericTemplateModal && (\n\t\t\t\t<AddCustomGenericTemplateModal\n\t\t\t\t\tonClose={ () => setShowCustomGenericTemplateModal( false ) }\n\t\t\t\t\tcreateTemplate={ createTemplate }\n\t\t\t\t\tisCreatingTemplate={ isCreatingTemplate }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction useMissingTemplates(\n\tsetEntityForSuggestions,\n\tsetShowCustomTemplateModal\n) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst missingDefaultTemplates = ( defaultTemplateTypes || [] ).filter(\n\t\t( template ) =>\n\t\t\tDEFAULT_TEMPLATE_SLUGS.includes( template.slug ) &&\n\t\t\t! existingTemplateSlugs.includes( template.slug )\n\t);\n\tconst onClickMenuItem = ( _entityForSuggestions ) => {\n\t\tsetShowCustomTemplateModal( true );\n\t\tsetEntityForSuggestions( _entityForSuggestions );\n\t};\n\t// We need to replace existing default template types with\n\t// the create specific template functionality. The original\n\t// info (title, description, etc.) is preserved in the\n\t// used hooks.\n\tconst enhancedMissingDefaultTemplateTypes = [ ...missingDefaultTemplates ];\n\tconst { defaultTaxonomiesMenuItems, taxonomiesMenuItems } =\n\t\tuseTaxonomiesMenuItems( onClickMenuItem );\n\tconst { defaultPostTypesMenuItems, postTypesMenuItems } =\n\t\tusePostTypeMenuItems( onClickMenuItem );\n\n\tconst authorMenuItem = useAuthorMenuItem( onClickMenuItem );\n\t[\n\t\t...defaultTaxonomiesMenuItems,\n\t\t...defaultPostTypesMenuItems,\n\t\tauthorMenuItem,\n\t].forEach( ( menuItem ) => {\n\t\tif ( ! menuItem ) {\n\t\t\treturn;\n\t\t}\n\t\tconst matchIndex = enhancedMissingDefaultTemplateTypes.findIndex(\n\t\t\t( template ) => template.slug === menuItem.slug\n\t\t);\n\t\t// Some default template types might have been filtered above from\n\t\t// `missingDefaultTemplates` because they only check for the general\n\t\t// template. So here we either replace or append the item, augmented\n\t\t// with the check if it has available specific item to create a\n\t\t// template for.\n\t\tif ( matchIndex > -1 ) {\n\t\t\tenhancedMissingDefaultTemplateTypes[ matchIndex ] = menuItem;\n\t\t} else {\n\t\t\tenhancedMissingDefaultTemplateTypes.push( menuItem );\n\t\t}\n\t} );\n\t// Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order.\n\tenhancedMissingDefaultTemplateTypes?.sort( ( template1, template2 ) => {\n\t\treturn (\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template1.slug ) -\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template2.slug )\n\t\t);\n\t} );\n\tconst missingTemplates = [\n\t\t...enhancedMissingDefaultTemplateTypes,\n\t\t...usePostTypeArchiveMenuItems(),\n\t\t...postTypesMenuItems,\n\t\t...taxonomiesMenuItems,\n\t];\n\treturn missingTemplates;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template.js"],"names":["DropdownMenu","MenuGroup","MenuItem","NavigableMenu","useState","useDispatch","store","coreStore","archive","blockMeta","category","home","list","media","notFound","page","plus","post","postAuthor","postDate","search","tag","layout","customGenericTemplateIcon","__","sprintf","noticesStore","AddCustomTemplateModal","useExistingTemplates","useDefaultTemplateTypes","useTaxonomiesMenuItems","usePostTypeMenuItems","useAuthorMenuItem","usePostTypeArchiveMenuItems","AddCustomGenericTemplateModal","TemplateActionsLoadingScreen","useHistory","editSiteStore","unlock","DEFAULT_TEMPLATE_SLUGS","TEMPLATE_ICONS","single","index","author","taxonomy","date","attachment","NewTemplate","postType","toggleProps","showIcon","showCustomTemplateModal","setShowCustomTemplateModal","showCustomGenericTemplateModal","setShowCustomGenericTemplateModal","entityForSuggestions","setEntityForSuggestions","isCreatingTemplate","setIsCreatingTemplate","history","saveEntityRecord","createErrorNotice","createSuccessNotice","setTemplate","setCanvasMode","createTemplate","template","isWPSuggestion","title","description","slug","newTemplate","toString","status","is_wp_suggestion","throwOnError","id","push","postId","type","error","errorMessage","message","code","missingTemplates","useMissingTemplates","length","labels","add_new","add_new_item","noArrow","map","onClick","icon","existingTemplates","defaultTemplateTypes","existingTemplateSlugs","missingDefaultTemplates","filter","includes","onClickMenuItem","_entityForSuggestions","enhancedMissingDefaultTemplateTypes","defaultTaxonomiesMenuItems","taxonomiesMenuItems","defaultPostTypesMenuItems","postTypesMenuItems","authorMenuItem","forEach","menuItem","matchIndex","findIndex","sort","template1","template2","indexOf"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,YADD,EAECC,SAFD,EAGCC,QAHD,EAICC,aAJD,QAKO,uBALP;AAMA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SACCC,OADD,EAECC,SAFD,EAGCC,QAHD,EAICC,IAJD,EAKCC,IALD,EAMCC,KAND,EAOCC,QAPD,EAQCC,IARD,EASCC,IATD,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AAxC;AACA,GACC,GAAGG,0BADJ,EAEC,GAAGE,yBAFJ,EAGCE,cAHD,EAIEC,OAJF,CAIaC,QAAF,IAAgB;AAC1B,QAAK,CAAEA,QAAP,EAAkB;AACjB;AACA;;AACD,UAAMC,UAAU,GAAGR,mCAAmC,CAACS,SAApC,CAChB7C,QAAF,IAAgBA,QAAQ,CAACI,IAAT,KAAkBuC,QAAQ,CAACvC,IADzB,CAAnB,CAJ0B,CAO1B;AACA;AACA;AACA;AACA;;AACA,QAAKwC,UAAU,GAAG,CAAC,CAAnB,EAAuB;AACtBR,MAAAA,mCAAmC,CAAEQ,UAAF,CAAnC,GAAoDD,QAApD;AACA,KAFD,MAEO;AACNP,MAAAA,mCAAmC,CAACzB,IAApC,CAA0CgC,QAA1C;AACA;AACD,GArBD,EA1BC,CAgDD;;AACAP,EAAAA,mCAAmC,SAAnC,IAAAA,mCAAmC,WAAnC,YAAAA,mCAAmC,CAAEU,IAArC,CAA2C,CAAEC,SAAF,EAAaC,SAAb,KAA4B;AACtE,WACC3E,sBAAsB,CAAC4E,OAAvB,CAAgCF,SAAS,CAAC3C,IAA1C,IACA/B,sBAAsB,CAAC4E,OAAvB,CAAgCD,SAAS,CAAC5C,IAA1C,CAFD;AAIA,GALD;AAMA,QAAMc,gBAAgB,GAAG,CACxB,GAAGkB,mCADqB,EAExB,GAAGrE,2BAA2B,EAFN,EAGxB,GAAGyE,kBAHqB,EAIxB,GAAGF,mBAJqB,CAAzB;AAMA,SAAOpB,gBAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tarchive,\n\tblockMeta,\n\tcategory,\n\thome,\n\tlist,\n\tmedia,\n\tnotFound,\n\tpage,\n\tplus,\n\tpost,\n\tpostAuthor,\n\tpostDate,\n\tsearch,\n\ttag,\n\tlayout as customGenericTemplateIcon,\n} from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AddCustomTemplateModal from './add-custom-template-modal';\nimport {\n\tuseExistingTemplates,\n\tuseDefaultTemplateTypes,\n\tuseTaxonomiesMenuItems,\n\tusePostTypeMenuItems,\n\tuseAuthorMenuItem,\n\tusePostTypeArchiveMenuItems,\n} from './utils';\nimport AddCustomGenericTemplateModal from './add-custom-generic-template-modal';\nimport TemplateActionsLoadingScreen from './template-actions-loading-screen';\nimport { useHistory } from '../routes';\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../private-apis';\n\nconst DEFAULT_TEMPLATE_SLUGS = [\n\t'front-page',\n\t'single',\n\t'page',\n\t'index',\n\t'archive',\n\t'author',\n\t'category',\n\t'date',\n\t'tag',\n\t'taxonomy',\n\t'search',\n\t'404',\n];\n\nconst TEMPLATE_ICONS = {\n\t'front-page': home,\n\tsingle: post,\n\tpage,\n\tarchive,\n\tsearch,\n\t404: notFound,\n\tindex: list,\n\tcategory,\n\tauthor: postAuthor,\n\ttaxonomy: blockMeta,\n\tdate: postDate,\n\ttag,\n\tattachment: media,\n};\n\nexport default function NewTemplate( {\n\tpostType,\n\ttoggleProps,\n\tshowIcon = true,\n} ) {\n\tconst [ showCustomTemplateModal, setShowCustomTemplateModal ] =\n\t\tuseState( false );\n\tconst [\n\t\tshowCustomGenericTemplateModal,\n\t\tsetShowCustomGenericTemplateModal,\n\t] = useState( false );\n\tconst [ entityForSuggestions, setEntityForSuggestions ] = useState( {} );\n\tconst [ isCreatingTemplate, setIsCreatingTemplate ] = useState( false );\n\n\tconst history = useHistory();\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { setTemplate, setCanvasMode } = unlock(\n\t\tuseDispatch( editSiteStore )\n\t);\n\tasync function createTemplate( template, isWPSuggestion = true ) {\n\t\tif ( isCreatingTemplate ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsCreatingTemplate( true );\n\t\ttry {\n\t\t\tconst { title, description, slug } = template;\n\t\t\tconst newTemplate = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{\n\t\t\t\t\tdescription,\n\t\t\t\t\t// Slugs need to be strings, so this is for template `404`\n\t\t\t\t\tslug: slug.toString(),\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\ttitle,\n\t\t\t\t\t// This adds a post meta field in template that is part of `is_custom` value calculation.\n\t\t\t\t\tis_wp_suggestion: isWPSuggestion,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\t// Set template before navigating away to avoid initial stale value.\n\t\t\tsetTemplate( newTemplate.id, newTemplate.slug );\n\t\t\t// Switch to edit mode.\n\t\t\tsetCanvasMode( 'edit' );\n\n\t\t\t// Navigate to the created template editor.\n\t\t\thistory.push( {\n\t\t\t\tpostId: newTemplate.id,\n\t\t\t\tpostType: newTemplate.type,\n\t\t\t} );\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\ttitle\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the template.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsCreatingTemplate( false );\n\t\t}\n\t}\n\n\tconst missingTemplates = useMissingTemplates(\n\t\tsetEntityForSuggestions,\n\t\tsetShowCustomTemplateModal\n\t);\n\tif ( ! missingTemplates.length ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tclassName=\"edit-site-new-template-dropdown\"\n\t\t\t\ticon={ showIcon ? plus : null }\n\t\t\t\ttext={ showIcon ? null : postType.labels.add_new }\n\t\t\t\tlabel={ postType.labels.add_new_item }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tnoArrow: false,\n\t\t\t\t} }\n\t\t\t\ttoggleProps={ toggleProps }\n\t\t\t>\n\t\t\t\t{ () => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isCreatingTemplate && (\n\t\t\t\t\t\t\t<TemplateActionsLoadingScreen />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<NavigableMenu className=\"edit-site-new-template-dropdown__popover\">\n\t\t\t\t\t\t\t<MenuGroup label={ postType.labels.add_new_item }>\n\t\t\t\t\t\t\t\t{ missingTemplates.map( ( template ) => {\n\t\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\t\tonClick,\n\t\t\t\t\t\t\t\t\t\ticon,\n\t\t\t\t\t\t\t\t\t} = template;\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\ticon ||\n\t\t\t\t\t\t\t\t\t\t\t\tTEMPLATE_ICONS[ slug ] ||\n\t\t\t\t\t\t\t\t\t\t\t\tpost\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\t\tinfo={ description }\n\t\t\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\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? onClick( template )\n\t\t\t\t\t\t\t\t\t\t\t\t\t: createTemplate( template )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\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</MenuGroup>\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\ticon={ customGenericTemplateIcon }\n\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t'Custom templates can be applied to any post or page.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tkey=\"custom-template\"\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tsetShowCustomGenericTemplateModal(\n\t\t\t\t\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Custom template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t\t{ showCustomTemplateModal && (\n\t\t\t\t<AddCustomTemplateModal\n\t\t\t\t\tonClose={ () => setShowCustomTemplateModal( false ) }\n\t\t\t\t\tonSelect={ createTemplate }\n\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\tisCreatingTemplate={ isCreatingTemplate }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showCustomGenericTemplateModal && (\n\t\t\t\t<AddCustomGenericTemplateModal\n\t\t\t\t\tonClose={ () => setShowCustomGenericTemplateModal( false ) }\n\t\t\t\t\tcreateTemplate={ createTemplate }\n\t\t\t\t\tisCreatingTemplate={ isCreatingTemplate }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction useMissingTemplates(\n\tsetEntityForSuggestions,\n\tsetShowCustomTemplateModal\n) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst missingDefaultTemplates = ( defaultTemplateTypes || [] ).filter(\n\t\t( template ) =>\n\t\t\tDEFAULT_TEMPLATE_SLUGS.includes( template.slug ) &&\n\t\t\t! existingTemplateSlugs.includes( template.slug )\n\t);\n\tconst onClickMenuItem = ( _entityForSuggestions ) => {\n\t\tsetShowCustomTemplateModal( true );\n\t\tsetEntityForSuggestions( _entityForSuggestions );\n\t};\n\t// We need to replace existing default template types with\n\t// the create specific template functionality. The original\n\t// info (title, description, etc.) is preserved in the\n\t// used hooks.\n\tconst enhancedMissingDefaultTemplateTypes = [ ...missingDefaultTemplates ];\n\tconst { defaultTaxonomiesMenuItems, taxonomiesMenuItems } =\n\t\tuseTaxonomiesMenuItems( onClickMenuItem );\n\tconst { defaultPostTypesMenuItems, postTypesMenuItems } =\n\t\tusePostTypeMenuItems( onClickMenuItem );\n\n\tconst authorMenuItem = useAuthorMenuItem( onClickMenuItem );\n\t[\n\t\t...defaultTaxonomiesMenuItems,\n\t\t...defaultPostTypesMenuItems,\n\t\tauthorMenuItem,\n\t].forEach( ( menuItem ) => {\n\t\tif ( ! menuItem ) {\n\t\t\treturn;\n\t\t}\n\t\tconst matchIndex = enhancedMissingDefaultTemplateTypes.findIndex(\n\t\t\t( template ) => template.slug === menuItem.slug\n\t\t);\n\t\t// Some default template types might have been filtered above from\n\t\t// `missingDefaultTemplates` because they only check for the general\n\t\t// template. So here we either replace or append the item, augmented\n\t\t// with the check if it has available specific item to create a\n\t\t// template for.\n\t\tif ( matchIndex > -1 ) {\n\t\t\tenhancedMissingDefaultTemplateTypes[ matchIndex ] = menuItem;\n\t\t} else {\n\t\t\tenhancedMissingDefaultTemplateTypes.push( menuItem );\n\t\t}\n\t} );\n\t// Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order.\n\tenhancedMissingDefaultTemplateTypes?.sort( ( template1, template2 ) => {\n\t\treturn (\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template1.slug ) -\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template2.slug )\n\t\t);\n\t} );\n\tconst missingTemplates = [\n\t\t...enhancedMissingDefaultTemplateTypes,\n\t\t...usePostTypeArchiveMenuItems(),\n\t\t...postTypesMenuItems,\n\t\t...taxonomiesMenuItems,\n\t];\n\treturn missingTemplates;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/app/index.js"],"names":["SlotFillProvider","Popover","UnsavedChangesWarning","ShortcutProvider","store","noticesStore","useDispatch","__","sprintf","PluginArea","Routes","Layout","App","createErrorNotice","onPluginAreaError","name","height"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,OAA3B,QAA0C,uBAA1C;AACA,SAASC,qBAAT,QAAsC,mBAAtC;AACA,SAASC,gBAAT,QAAiC,+BAAjC;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,WAAvB;AACA,OAAOC,MAAP,MAAmB,WAAnB;AAEA,eAAe,SAASC,GAAT,GAAe;AAC7B,QAAM;AAAEC,IAAAA;AAAF,MAAwBP,WAAW,CAAED,YAAF,CAAzC;;AAEA,WAASS,iBAAT,CAA4BC,IAA5B,EAAmC;AAClCF,IAAAA,iBAAiB,CAChBL,OAAO;AACN;AACAD,IAAAA,EAAE,CACD,kEADC,CAFI,EAKNQ,IALM,CADS,CAAjB;AASA;;AAED,SACC,cAAC,gBAAD;AAAkB,IAAA,KAAK,EAAG;AAAEC,MAAAA,MAAM,EAAE;AAAV;AAA1B,KACC,cAAC,gBAAD,QACC,cAAC,OAAD,CAAS,IAAT,OADD,EAEC,cAAC,qBAAD,OAFD,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/app/index.js"],"names":["SlotFillProvider","Popover","UnsavedChangesWarning","ShortcutProvider","store","noticesStore","useDispatch","__","sprintf","PluginArea","Routes","Layout","App","createErrorNotice","onPluginAreaError","name","height"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,OAA3B,QAA0C,uBAA1C;AACA,SAASC,qBAAT,QAAsC,mBAAtC;AACA,SAASC,gBAAT,QAAiC,+BAAjC;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,WAAvB;AACA,OAAOC,MAAP,MAAmB,WAAnB;AAEA,eAAe,SAASC,GAAT,GAAe;AAC7B,QAAM;AAAEC,IAAAA;AAAF,MAAwBP,WAAW,CAAED,YAAF,CAAzC;;AAEA,WAASS,iBAAT,CAA4BC,IAA5B,EAAmC;AAClCF,IAAAA,iBAAiB,CAChBL,OAAO;AACN;AACAD,IAAAA,EAAE,CACD,kEADC,CAFI,EAKNQ,IALM,CADS,CAAjB;AASA;;AAED,SACC,cAAC,gBAAD;AAAkB,IAAA,KAAK,EAAG;AAAEC,MAAAA,MAAM,EAAE;AAAV;AAA1B,KACC,cAAC,gBAAD,QACC,cAAC,OAAD,CAAS,IAAT,OADD,EAEC,cAAC,qBAAD,OAFD,EAGC,cAAC,MAAD,QACC,cAAC,MAAD,OADD,EAEC,cAAC,UAAD;AAAY,IAAA,OAAO,EAAGF;AAAtB,IAFD,CAHD,CADD,CADD;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SlotFillProvider, Popover } from '@wordpress/components';\nimport { UnsavedChangesWarning } from '@wordpress/editor';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useDispatch } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { PluginArea } from '@wordpress/plugins';\n\n/**\n * Internal dependencies\n */\nimport { Routes } from '../routes';\nimport Layout from '../layout';\n\nexport default function App() {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tfunction onPluginAreaError( name ) {\n\t\tcreateErrorNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: plugin name */\n\t\t\t\t__(\n\t\t\t\t\t'The \"%s\" plugin has encountered an error and cannot be rendered.'\n\t\t\t\t),\n\t\t\t\tname\n\t\t\t)\n\t\t);\n\t}\n\n\treturn (\n\t\t<ShortcutProvider style={ { height: '100%' } }>\n\t\t\t<SlotFillProvider>\n\t\t\t\t<Popover.Slot />\n\t\t\t\t<UnsavedChangesWarning />\n\t\t\t\t<Routes>\n\t\t\t\t\t<Layout />\n\t\t\t\t\t<PluginArea onError={ onPluginAreaError } />\n\t\t\t\t</Routes>\n\t\t\t</SlotFillProvider>\n\t\t</ShortcutProvider>\n\t);\n}\n"]}
|
|
@@ -35,6 +35,7 @@ function EditorCanvas(_ref) {
|
|
|
35
35
|
const deviceStyles = useResizeCanvas(deviceType);
|
|
36
36
|
const mouseMoveTypingRef = useMouseMoveTypingReset();
|
|
37
37
|
return createElement(Iframe, _extends({
|
|
38
|
+
expand: isZoomOutMode,
|
|
38
39
|
scale: isZoomOutMode && 0.45 || undefined,
|
|
39
40
|
frameSize: isZoomOutMode ? 100 : undefined,
|
|
40
41
|
style: enableResizing ? {} : deviceStyles,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/editor-canvas.js"],"names":["__experimentalUseResizeCanvas","useResizeCanvas","__unstableEditorStyles","EditorStyles","__unstableIframe","Iframe","__unstableUseMouseMoveTypingReset","useMouseMoveTypingReset","store","blockEditorStore","useSelect","useDispatch","unlock","editSiteStore","EditorCanvas","enableResizing","settings","children","props","canvasMode","deviceType","isZoomOutMode","select","__experimentalGetPreviewDeviceType","__unstableGetEditorMode","getCanvasMode","setCanvasMode","deviceStyles","mouseMoveTypingRef","undefined","styles","svgFilters"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,6BAA6B,IAAIC,eADlC,EAECC,sBAAsB,IAAIC,YAF3B,EAGCC,gBAAgB,IAAIC,MAHrB,EAICC,iCAAiC,IAAIC,uBAJtC,EAKCC,KAAK,IAAIC,gBALV,QAMO,yBANP;AAOA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASJ,KAAK,IAAIK,aAAlB,QAAuC,aAAvC;;AAEA,SAASC,YAAT,OAA0E;AAAA,MAAnD;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,QAAlB;AAA4BC,IAAAA,QAA5B;AAAsC,OAAGC;AAAzC,GAAmD;AACzE,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,UAAd;AAA0BC,IAAAA;AAA1B,MAA4CX,SAAS,CACxDY,MAAF,KAAgB;AACfF,IAAAA,UAAU,EACTE,MAAM,CAAET,aAAF,CAAN,CAAwBU,kCAAxB,EAFc;AAGfF,IAAAA,aAAa,EACZC,MAAM,CAAEb,gBAAF,CAAN,CAA2Be,uBAA3B,OACA,UALc;AAMfL,IAAAA,UAAU,EAAEP,MAAM,CAAEU,MAAM,CAAET,aAAF,CAAR,CAAN,CAAkCY,aAAlC;AANG,GAAhB,CAD0D,EAS1D,EAT0D,CAA3D;AAWA,QAAM;AAAEC,IAAAA;AAAF,MAAoBd,MAAM,CAAED,WAAW,CAAEE,aAAF,CAAb,CAAhC;AACA,QAAMc,YAAY,GAAG1B,eAAe,CAAEmB,UAAF,CAApC;AACA,QAAMQ,kBAAkB,GAAGrB,uBAAuB,EAAlD;AACA,SACC,cAAC,MAAD;AACC,IAAA,KAAK,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/editor-canvas.js"],"names":["__experimentalUseResizeCanvas","useResizeCanvas","__unstableEditorStyles","EditorStyles","__unstableIframe","Iframe","__unstableUseMouseMoveTypingReset","useMouseMoveTypingReset","store","blockEditorStore","useSelect","useDispatch","unlock","editSiteStore","EditorCanvas","enableResizing","settings","children","props","canvasMode","deviceType","isZoomOutMode","select","__experimentalGetPreviewDeviceType","__unstableGetEditorMode","getCanvasMode","setCanvasMode","deviceStyles","mouseMoveTypingRef","undefined","styles","svgFilters"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,6BAA6B,IAAIC,eADlC,EAECC,sBAAsB,IAAIC,YAF3B,EAGCC,gBAAgB,IAAIC,MAHrB,EAICC,iCAAiC,IAAIC,uBAJtC,EAKCC,KAAK,IAAIC,gBALV,QAMO,yBANP;AAOA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASJ,KAAK,IAAIK,aAAlB,QAAuC,aAAvC;;AAEA,SAASC,YAAT,OAA0E;AAAA,MAAnD;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,QAAlB;AAA4BC,IAAAA,QAA5B;AAAsC,OAAGC;AAAzC,GAAmD;AACzE,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,UAAd;AAA0BC,IAAAA;AAA1B,MAA4CX,SAAS,CACxDY,MAAF,KAAgB;AACfF,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EAuCGd,QAvCH,CADD;AA2CA;;AAED,eAAeH,YAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\n\nfunction EditorCanvas( { enableResizing, settings, children, ...props } ) {\n\tconst { canvasMode, deviceType, isZoomOutMode } = useSelect(\n\t\t( select ) => ( {\n\t\t\tdeviceType:\n\t\t\t\tselect( editSiteStore ).__experimentalGetPreviewDeviceType(),\n\t\t\tisZoomOutMode:\n\t\t\t\tselect( blockEditorStore ).__unstableGetEditorMode() ===\n\t\t\t\t'zoom-out',\n\t\t\tcanvasMode: unlock( select( editSiteStore ) ).getCanvasMode(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst deviceStyles = useResizeCanvas( deviceType );\n\tconst mouseMoveTypingRef = useMouseMoveTypingReset();\n\treturn (\n\t\t<Iframe\n\t\t\texpand={ isZoomOutMode }\n\t\t\tscale={ ( isZoomOutMode && 0.45 ) || undefined }\n\t\t\tframeSize={ isZoomOutMode ? 100 : undefined }\n\t\t\tstyle={ enableResizing ? {} : deviceStyles }\n\t\t\thead={\n\t\t\t\t<>\n\t\t\t\t\t<EditorStyles styles={ settings.styles } />\n\t\t\t\t\t<style>{\n\t\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\t\t\t`.is-root-container { display: flow-root; }\n\t\t\t\t\t\t\tbody { position: relative; }`\n\t\t\t\t\t}</style>\n\t\t\t\t\t{ enableResizing && (\n\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t// Some themes will have `min-height: 100vh` for the root container,\n\t\t\t\t\t\t\t\t// which isn't a requirement in auto resize mode.\n\t\t\t\t\t\t\t\t`.is-root-container { min-height: 0 !important; }`\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</style>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t\tref={ mouseMoveTypingRef }\n\t\t\tname=\"editor-canvas\"\n\t\t\tclassName=\"edit-site-visual-editor__editor-canvas\"\n\t\t\t{ ...props }\n\t\t\trole={ canvasMode === 'view' ? 'button' : undefined }\n\t\t\tonClick={\n\t\t\t\tcanvasMode === 'view'\n\t\t\t\t\t? () => setCanvasMode( 'edit' )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\treadonly={ canvasMode === 'view' }\n\t\t>\n\t\t\t{ /* Filters need to be rendered before children to avoid Safari rendering issues. */ }\n\t\t\t{ settings.svgFilters }\n\t\t\t{ children }\n\t\t</Iframe>\n\t);\n}\n\nexport default EditorCanvas;\n"]}
|
|
@@ -23,6 +23,7 @@ import KeyboardShortcutsEditMode from '../keyboard-shortcuts/edit-mode';
|
|
|
23
23
|
import InserterSidebar from '../secondary-sidebar/inserter-sidebar';
|
|
24
24
|
import ListViewSidebar from '../secondary-sidebar/list-view-sidebar';
|
|
25
25
|
import WelcomeGuide from '../welcome-guide';
|
|
26
|
+
import StartTemplateOptions from '../start-template-options';
|
|
26
27
|
import { store as editSiteStore } from '../../store';
|
|
27
28
|
import { GlobalStylesRenderer } from '../global-styles-renderer';
|
|
28
29
|
import { GlobalStylesProvider } from '../global-styles/global-styles-provider';
|
|
@@ -133,7 +134,7 @@ export default function Editor() {
|
|
|
133
134
|
id: editedPostId
|
|
134
135
|
}, createElement(GlobalStylesProvider, null, createElement(BlockContextProvider, {
|
|
135
136
|
value: blockContext
|
|
136
|
-
}, createElement(SidebarComplementaryAreaFills, null), createElement(InterfaceSkeleton, {
|
|
137
|
+
}, createElement(SidebarComplementaryAreaFills, null), isEditMode && createElement(StartTemplateOptions, null), createElement(InterfaceSkeleton, {
|
|
137
138
|
enableRegionNavigation: false,
|
|
138
139
|
className: showIconLabels && 'show-icon-labels',
|
|
139
140
|
notices: isEditMode && createElement(EditorSnackbars, null),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/editor/index.js"],"names":["useMemo","useSelect","useDispatch","Notice","EntityProvider","store","preferencesStore","BlockContextProvider","BlockBreadcrumb","blockEditorStore","InterfaceSkeleton","ComplementaryArea","interfaceStore","EditorNotices","EditorSnackbars","__","sprintf","SidebarComplementaryAreaFills","BlockEditor","CodeEditor","KeyboardShortcutsEditMode","InserterSidebar","ListViewSidebar","WelcomeGuide","editSiteStore","GlobalStylesRenderer","GlobalStylesProvider","useTitle","CanvasSpinner","unlock","useEditedEntityRecord","interfaceLabels","body","sidebar","actions","footer","Editor","record","editedPost","getTitle","isLoaded","hasLoadedPost","id","editedPostId","type","editedPostType","context","editorMode","canvasMode","blockEditorMode","isRightSidebarOpen","isInserterOpen","isListViewOpen","showIconLabels","select","getEditedPostContext","getEditorMode","getCanvasMode","isInserterOpened","isListViewOpened","__unstableGetEditorMode","getActiveComplementaryArea","name","get","setEditedPostContext","isViewMode","isEditMode","showVisualEditor","showBlockBreakcrumb","shouldShowInserter","shouldShowListView","secondarySidebarLabel","blockContext","queryContext","page","newQueryContext","title","secondarySidebar"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,cAAT,QAA+B,sBAA/B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AACA,SACCC,oBADD,EAECC,eAFD,EAGCH,KAAK,IAAII,gBAHV,QAIO,yBAJP;AAKA,SACCC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AAEN;AAFV;AArDV,IAFD,CADD,CALD,CADD,CAFD,CADD;AA4EA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Notice } from '@wordpress/components';\nimport { EntityProvider } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tBlockContextProvider,\n\tBlockBreadcrumb,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { EditorNotices, EditorSnackbars } from '@wordpress/editor';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { SidebarComplementaryAreaFills } from '../sidebar-edit-mode';\nimport BlockEditor from '../block-editor';\nimport CodeEditor from '../code-editor';\nimport KeyboardShortcutsEditMode from '../keyboard-shortcuts/edit-mode';\nimport InserterSidebar from '../secondary-sidebar/inserter-sidebar';\nimport ListViewSidebar from '../secondary-sidebar/list-view-sidebar';\nimport WelcomeGuide from '../welcome-guide';\nimport { store as editSiteStore } from '../../store';\nimport { GlobalStylesRenderer } from '../global-styles-renderer';\nimport { GlobalStylesProvider } from '../global-styles/global-styles-provider';\nimport useTitle from '../routes/use-title';\nimport CanvasSpinner from '../canvas-spinner';\nimport { unlock } from '../../private-apis';\nimport useEditedEntityRecord from '../use-edited-entity-record';\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the editor content landmark region. */\n\tbody: __( 'Editor content' ),\n\t/* translators: accessibility text for the editor settings landmark region. */\n\tsidebar: __( 'Editor settings' ),\n\t/* translators: accessibility text for the editor publish landmark region. */\n\tactions: __( 'Editor publish' ),\n\t/* translators: accessibility text for the editor footer landmark region. */\n\tfooter: __( 'Editor footer' ),\n};\n\nexport default function Editor() {\n\tconst {\n\t\trecord: editedPost,\n\t\tgetTitle,\n\t\tisLoaded: hasLoadedPost,\n\t} = useEditedEntityRecord();\n\n\tconst { id: editedPostId, type: editedPostType } = editedPost;\n\n\tconst {\n\t\tcontext,\n\t\teditorMode,\n\t\tcanvasMode,\n\t\tblockEditorMode,\n\t\tisRightSidebarOpen,\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tshowIconLabels,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEditedPostContext,\n\t\t\tgetEditorMode,\n\t\t\tgetCanvasMode,\n\t\t\tisInserterOpened,\n\t\t\tisListViewOpened,\n\t\t} = unlock( select( editSiteStore ) );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\n\t\t// The currently selected entity to display.\n\t\t// Typically template or template part in the site editor.\n\t\treturn {\n\t\t\tcontext: getEditedPostContext(),\n\t\t\teditorMode: getEditorMode(),\n\t\t\tcanvasMode: getCanvasMode(),\n\t\t\tblockEditorMode: __unstableGetEditorMode(),\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tisRightSidebarOpen: getActiveComplementaryArea(\n\t\t\t\teditSiteStore.name\n\t\t\t),\n\t\t\tshowIconLabels: select( preferencesStore ).get(\n\t\t\t\t'core/edit-site',\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t};\n\t}, [] );\n\tconst { setEditedPostContext } = useDispatch( editSiteStore );\n\n\tconst isViewMode = canvasMode === 'view';\n\tconst isEditMode = canvasMode === 'edit';\n\tconst showVisualEditor = isViewMode || editorMode === 'visual';\n\tconst showBlockBreakcrumb =\n\t\tisEditMode && showVisualEditor && blockEditorMode !== 'zoom-out';\n\tconst shouldShowInserter = isEditMode && showVisualEditor && isInserterOpen;\n\tconst shouldShowListView = isEditMode && showVisualEditor && isListViewOpen;\n\tconst secondarySidebarLabel = isListViewOpen\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\tconst blockContext = useMemo(\n\t\t() => ( {\n\t\t\t...context,\n\t\t\tqueryContext: [\n\t\t\t\tcontext?.queryContext || { page: 1 },\n\t\t\t\t( newQueryContext ) =>\n\t\t\t\t\tsetEditedPostContext( {\n\t\t\t\t\t\t...context,\n\t\t\t\t\t\tqueryContext: {\n\t\t\t\t\t\t\t...context?.queryContext,\n\t\t\t\t\t\t\t...newQueryContext,\n\t\t\t\t\t\t},\n\t\t\t\t\t} ),\n\t\t\t],\n\t\t} ),\n\t\t[ context, setEditedPostContext ]\n\t);\n\n\tlet title;\n\tif ( hasLoadedPost ) {\n\t\tconst type =\n\t\t\teditedPostType === 'wp_template'\n\t\t\t\t? __( 'Template' )\n\t\t\t\t: __( 'Template Part' );\n\t\ttitle = sprintf(\n\t\t\t// translators: A breadcrumb trail in browser tab. %1$s: title of template being edited, %2$s: type of template (Template or Template Part).\n\t\t\t__( '%1$s ‹ %2$s ‹ Editor' ),\n\t\t\tgetTitle(),\n\t\t\ttype\n\t\t);\n\t}\n\n\t// Only announce the title once the editor is ready to prevent \"Replace\"\n\t// action in <URlQueryController> from double-announcing.\n\tuseTitle( hasLoadedPost && title );\n\n\tif ( ! hasLoadedPost ) {\n\t\treturn <CanvasSpinner />;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ isEditMode && <WelcomeGuide /> }\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ editedPostType }\n\t\t\t\t\tid={ editedPostId }\n\t\t\t\t>\n\t\t\t\t\t<GlobalStylesProvider>\n\t\t\t\t\t\t<BlockContextProvider value={ blockContext }>\n\t\t\t\t\t\t\t<SidebarComplementaryAreaFills />\n\t\t\t\t\t\t\t<InterfaceSkeleton\n\t\t\t\t\t\t\t\tenableRegionNavigation={ false }\n\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\tshowIconLabels && 'show-icon-labels'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tnotices={ isEditMode && <EditorSnackbars /> }\n\t\t\t\t\t\t\t\tcontent={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<GlobalStylesRenderer />\n\t\t\t\t\t\t\t\t\t\t{ isEditMode && <EditorNotices /> }\n\t\t\t\t\t\t\t\t\t\t{ showVisualEditor && editedPost && (\n\t\t\t\t\t\t\t\t\t\t\t<BlockEditor />\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t{ editorMode === 'text' &&\n\t\t\t\t\t\t\t\t\t\t\teditedPost &&\n\t\t\t\t\t\t\t\t\t\t\tisEditMode && <CodeEditor /> }\n\t\t\t\t\t\t\t\t\t\t{ hasLoadedPost && ! editedPost && (\n\t\t\t\t\t\t\t\t\t\t\t<Notice\n\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\tisDismissible={ false }\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\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) }\n\t\t\t\t\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t{ isEditMode && (\n\t\t\t\t\t\t\t\t\t\t\t<KeyboardShortcutsEditMode />\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsecondarySidebar={\n\t\t\t\t\t\t\t\t\tisEditMode &&\n\t\t\t\t\t\t\t\t\t( ( shouldShowInserter && (\n\t\t\t\t\t\t\t\t\t\t<InserterSidebar />\n\t\t\t\t\t\t\t\t\t) ) ||\n\t\t\t\t\t\t\t\t\t\t( shouldShowListView && (\n\t\t\t\t\t\t\t\t\t\t\t<ListViewSidebar />\n\t\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\tsidebar={\n\t\t\t\t\t\t\t\t\tisEditMode &&\n\t\t\t\t\t\t\t\t\tisRightSidebarOpen && (\n\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)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfooter={\n\t\t\t\t\t\t\t\t\tshowBlockBreakcrumb && (\n\t\t\t\t\t\t\t\t\t\t<BlockBreadcrumb\n\t\t\t\t\t\t\t\t\t\t\trootLabelText={ __( 'Template' ) }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlabels={ {\n\t\t\t\t\t\t\t\t\t...interfaceLabels,\n\t\t\t\t\t\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t\t</GlobalStylesProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t</>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/editor/index.js"],"names":["useMemo","useSelect","useDispatch","Notice","EntityProvider","store","preferencesStore","BlockContextProvider","BlockBreadcrumb","blockEditorStore","InterfaceSkeleton","ComplementaryArea","interfaceStore","EditorNotices","EditorSnackbars","__","sprintf","SidebarComplementaryAreaFills","BlockEditor","CodeEditor","KeyboardShortcutsEditMode","InserterSidebar","ListViewSidebar","WelcomeGuide","StartTemplateOptions","editSiteStore","GlobalStylesRenderer","GlobalStylesProvider","useTitle","CanvasSpinner","unlock","useEditedEntityRecord","interfaceLabels","body","sidebar","actions","footer","Editor","record","editedPost","getTitle","isLoaded","hasLoadedPost","id","editedPostId","type","editedPostType","context","editorMode","canvasMode","blockEditorMode","isRightSidebarOpen","isInserterOpen","isListViewOpen","showIconLabels","select","getEditedPostContext","getEditorMode","getCanvasMode","isInserterOpened","isListViewOpened","__unstableGetEditorMode","getActiveComplementaryArea","name","get","setEditedPostContext","isViewMode","isEditMode","showVisualEditor","showBlockBreakcrumb","shouldShowInserter","shouldShowListView","secondarySidebarLabel","blockContext","queryContext","page","newQueryContext","title","secondarySidebar"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,cAAT,QAA+B,sBAA/B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AACA,SACCC,oBADD,EAECC,eAFD,EAGCH,KAAK,IAAII,gBAHV,QAIO,yBAJP;AAKA,SACCC,iBADD,EAECC,iBAFD,EAGCN,KAAK,IAAIO,cAHV,QAIO,sBAJP;AAKA,SAASC,aAAT,EAAwBC,eAAxB,QAA+C,mBAA/C;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,6BAAT,QAA8C,sBAA9C;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,yBAAP,MAAsC,iCAAtC;AACA,OAAOC,eAAP,MAA4B,uCAA5B;AACA,OAAOC,eAAP,MAA4B,wCAA5B;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,oBAAP,MAAiC,2BAAjC;AACA,SAASnB,KAAK,IAAIoB,aAAlB,QAAuC,aAAvC;AACA,SAASC,oBAAT,QAAqC,2BAArC;AACA,SAASC,oBAAT,QAAqC,yCAArC;AACA,OAAOC,QAAP,MAAqB,qBAArB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,OAAOC,qBAAP,MAAkC,6BAAlC;AAEA,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,EASGzB,aAAa,IAAI,CAAEH,UAAnB,IACD,cAAC,MAAD;AACC,MAAA,MAAM,EAAC,SADR;AAEC,MAAA,aAAa,EAAG;AAFjB,OAIGxB,EAAE,CACH,2EADG,CAJL,CAVF,EAmBGoD,UAAU,IACX,cAAC,yBAAD,OApBF,CAPF;AA+BC,IAAA,gBAAgB,EACfA,UAAU,KACNG,kBAAkB,IACrB,cAAC,eAAD,OADC,IAGCC,kBAAkB,IACnB,cAAC,eAAD,OALQ,CAhCZ;AAwCC,IAAA,OAAO,EACNJ,UAAU,IACVhB,kBADA,IAEC,cAAC,iBAAD,CAAmB,IAAnB;AAAwB,MAAA,KAAK,EAAC;AAA9B,MA3CH;AA8CC,IAAA,MAAM,EACLkB,mBAAmB,IAClB,cAAC,eAAD;AACC,MAAA,aAAa,EAAGtD,EAAE,CAAE,UAAF;AADnB,MAhDH;AAqDC,IAAA,MAAM,EAAG,EACR,GAAGiB,eADK;AAER8C,MAAAA,gBAAgB,EAAEN;AAFV;AArDV,IAHD,CADD,CALD,CADD,CAFD,CADD;AA6EA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Notice } from '@wordpress/components';\nimport { EntityProvider } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tBlockContextProvider,\n\tBlockBreadcrumb,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { EditorNotices, EditorSnackbars } from '@wordpress/editor';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { SidebarComplementaryAreaFills } from '../sidebar-edit-mode';\nimport BlockEditor from '../block-editor';\nimport CodeEditor from '../code-editor';\nimport KeyboardShortcutsEditMode from '../keyboard-shortcuts/edit-mode';\nimport InserterSidebar from '../secondary-sidebar/inserter-sidebar';\nimport ListViewSidebar from '../secondary-sidebar/list-view-sidebar';\nimport WelcomeGuide from '../welcome-guide';\nimport StartTemplateOptions from '../start-template-options';\nimport { store as editSiteStore } from '../../store';\nimport { GlobalStylesRenderer } from '../global-styles-renderer';\nimport { GlobalStylesProvider } from '../global-styles/global-styles-provider';\nimport useTitle from '../routes/use-title';\nimport CanvasSpinner from '../canvas-spinner';\nimport { unlock } from '../../private-apis';\nimport useEditedEntityRecord from '../use-edited-entity-record';\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the editor content landmark region. */\n\tbody: __( 'Editor content' ),\n\t/* translators: accessibility text for the editor settings landmark region. */\n\tsidebar: __( 'Editor settings' ),\n\t/* translators: accessibility text for the editor publish landmark region. */\n\tactions: __( 'Editor publish' ),\n\t/* translators: accessibility text for the editor footer landmark region. */\n\tfooter: __( 'Editor footer' ),\n};\n\nexport default function Editor() {\n\tconst {\n\t\trecord: editedPost,\n\t\tgetTitle,\n\t\tisLoaded: hasLoadedPost,\n\t} = useEditedEntityRecord();\n\n\tconst { id: editedPostId, type: editedPostType } = editedPost;\n\n\tconst {\n\t\tcontext,\n\t\teditorMode,\n\t\tcanvasMode,\n\t\tblockEditorMode,\n\t\tisRightSidebarOpen,\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tshowIconLabels,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEditedPostContext,\n\t\t\tgetEditorMode,\n\t\t\tgetCanvasMode,\n\t\t\tisInserterOpened,\n\t\t\tisListViewOpened,\n\t\t} = unlock( select( editSiteStore ) );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\n\t\t// The currently selected entity to display.\n\t\t// Typically template or template part in the site editor.\n\t\treturn {\n\t\t\tcontext: getEditedPostContext(),\n\t\t\teditorMode: getEditorMode(),\n\t\t\tcanvasMode: getCanvasMode(),\n\t\t\tblockEditorMode: __unstableGetEditorMode(),\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tisRightSidebarOpen: getActiveComplementaryArea(\n\t\t\t\teditSiteStore.name\n\t\t\t),\n\t\t\tshowIconLabels: select( preferencesStore ).get(\n\t\t\t\t'core/edit-site',\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t};\n\t}, [] );\n\tconst { setEditedPostContext } = useDispatch( editSiteStore );\n\n\tconst isViewMode = canvasMode === 'view';\n\tconst isEditMode = canvasMode === 'edit';\n\tconst showVisualEditor = isViewMode || editorMode === 'visual';\n\tconst showBlockBreakcrumb =\n\t\tisEditMode && showVisualEditor && blockEditorMode !== 'zoom-out';\n\tconst shouldShowInserter = isEditMode && showVisualEditor && isInserterOpen;\n\tconst shouldShowListView = isEditMode && showVisualEditor && isListViewOpen;\n\tconst secondarySidebarLabel = isListViewOpen\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\tconst blockContext = useMemo(\n\t\t() => ( {\n\t\t\t...context,\n\t\t\tqueryContext: [\n\t\t\t\tcontext?.queryContext || { page: 1 },\n\t\t\t\t( newQueryContext ) =>\n\t\t\t\t\tsetEditedPostContext( {\n\t\t\t\t\t\t...context,\n\t\t\t\t\t\tqueryContext: {\n\t\t\t\t\t\t\t...context?.queryContext,\n\t\t\t\t\t\t\t...newQueryContext,\n\t\t\t\t\t\t},\n\t\t\t\t\t} ),\n\t\t\t],\n\t\t} ),\n\t\t[ context, setEditedPostContext ]\n\t);\n\n\tlet title;\n\tif ( hasLoadedPost ) {\n\t\tconst type =\n\t\t\teditedPostType === 'wp_template'\n\t\t\t\t? __( 'Template' )\n\t\t\t\t: __( 'Template Part' );\n\t\ttitle = sprintf(\n\t\t\t// translators: A breadcrumb trail in browser tab. %1$s: title of template being edited, %2$s: type of template (Template or Template Part).\n\t\t\t__( '%1$s ‹ %2$s ‹ Editor' ),\n\t\t\tgetTitle(),\n\t\t\ttype\n\t\t);\n\t}\n\n\t// Only announce the title once the editor is ready to prevent \"Replace\"\n\t// action in <URlQueryController> from double-announcing.\n\tuseTitle( hasLoadedPost && title );\n\n\tif ( ! hasLoadedPost ) {\n\t\treturn <CanvasSpinner />;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ isEditMode && <WelcomeGuide /> }\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ editedPostType }\n\t\t\t\t\tid={ editedPostId }\n\t\t\t\t>\n\t\t\t\t\t<GlobalStylesProvider>\n\t\t\t\t\t\t<BlockContextProvider value={ blockContext }>\n\t\t\t\t\t\t\t<SidebarComplementaryAreaFills />\n\t\t\t\t\t\t\t{ isEditMode && <StartTemplateOptions /> }\n\t\t\t\t\t\t\t<InterfaceSkeleton\n\t\t\t\t\t\t\t\tenableRegionNavigation={ false }\n\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\tshowIconLabels && 'show-icon-labels'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tnotices={ isEditMode && <EditorSnackbars /> }\n\t\t\t\t\t\t\t\tcontent={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<GlobalStylesRenderer />\n\t\t\t\t\t\t\t\t\t\t{ isEditMode && <EditorNotices /> }\n\t\t\t\t\t\t\t\t\t\t{ showVisualEditor && editedPost && (\n\t\t\t\t\t\t\t\t\t\t\t<BlockEditor />\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t{ editorMode === 'text' &&\n\t\t\t\t\t\t\t\t\t\t\teditedPost &&\n\t\t\t\t\t\t\t\t\t\t\tisEditMode && <CodeEditor /> }\n\t\t\t\t\t\t\t\t\t\t{ hasLoadedPost && ! editedPost && (\n\t\t\t\t\t\t\t\t\t\t\t<Notice\n\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\tisDismissible={ false }\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\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) }\n\t\t\t\t\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t{ isEditMode && (\n\t\t\t\t\t\t\t\t\t\t\t<KeyboardShortcutsEditMode />\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsecondarySidebar={\n\t\t\t\t\t\t\t\t\tisEditMode &&\n\t\t\t\t\t\t\t\t\t( ( shouldShowInserter && (\n\t\t\t\t\t\t\t\t\t\t<InserterSidebar />\n\t\t\t\t\t\t\t\t\t) ) ||\n\t\t\t\t\t\t\t\t\t\t( shouldShowListView && (\n\t\t\t\t\t\t\t\t\t\t\t<ListViewSidebar />\n\t\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\tsidebar={\n\t\t\t\t\t\t\t\t\tisEditMode &&\n\t\t\t\t\t\t\t\t\tisRightSidebarOpen && (\n\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)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfooter={\n\t\t\t\t\t\t\t\t\tshowBlockBreakcrumb && (\n\t\t\t\t\t\t\t\t\t\t<BlockBreadcrumb\n\t\t\t\t\t\t\t\t\t\t\trootLabelText={ __( 'Template' ) }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlabels={ {\n\t\t\t\t\t\t\t\t\t...interfaceLabels,\n\t\t\t\t\t\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t\t</GlobalStylesProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -11,7 +11,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { useSupportedStyles, useColorsPerOrigin } from './hooks';
|
|
15
15
|
import { unlock } from '../../private-apis';
|
|
16
16
|
const {
|
|
17
17
|
useGlobalSetting,
|
|
@@ -23,22 +23,22 @@ export function useHasBorderPanel(name) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function useHasBorderColorControl(name) {
|
|
26
|
-
const supports =
|
|
26
|
+
const supports = useSupportedStyles(name);
|
|
27
27
|
return useGlobalSetting('border.color', name)[0] && supports.includes('borderColor');
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
function useHasBorderRadiusControl(name) {
|
|
31
|
-
const supports =
|
|
31
|
+
const supports = useSupportedStyles(name);
|
|
32
32
|
return useGlobalSetting('border.radius', name)[0] && supports.includes('borderRadius');
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
function useHasBorderStyleControl(name) {
|
|
36
|
-
const supports =
|
|
36
|
+
const supports = useSupportedStyles(name);
|
|
37
37
|
return useGlobalSetting('border.style', name)[0] && supports.includes('borderStyle');
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function useHasBorderWidthControl(name) {
|
|
41
|
-
const supports =
|
|
41
|
+
const supports = useSupportedStyles(name);
|
|
42
42
|
return useGlobalSetting('border.width', name)[0] && supports.includes('borderWidth');
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -145,7 +145,7 @@ export default function BorderPanel(_ref) {
|
|
|
145
145
|
radius: border === null || border === void 0 ? void 0 : border.radius,
|
|
146
146
|
...updatedBorder
|
|
147
147
|
});
|
|
148
|
-
}, [setBorder]);
|
|
148
|
+
}, [setBorder, border === null || border === void 0 ? void 0 : border.radius]);
|
|
149
149
|
return createElement(ToolsPanel, {
|
|
150
150
|
label: __('Border'),
|
|
151
151
|
resetAll: resetAll
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/border-panel.js"],"names":["__experimentalBorderRadiusControl","BorderRadiusControl","privateApis","blockEditorPrivateApis","__experimentalBorderBoxControl","BorderBoxControl","__experimentalHasSplitBorders","hasSplitBorders","__experimentalIsDefinedBorder","isDefinedBorder","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","useCallback","__","getSupportedGlobalStylesPanels","useColorsPerOrigin","unlock","useGlobalSetting","useGlobalStyle","useHasBorderPanel","name","controls","useHasBorderColorControl","useHasBorderRadiusControl","useHasBorderStyleControl","useHasBorderWidthControl","some","Boolean","supports","includes","applyFallbackStyle","border","style","color","width","applyAllFallbackStyles","top","right","bottom","left","BorderPanel","variation","prefix","userBorderStyles","setBorder","colors","showBorderColor","showBorderStyle","showBorderWidth","showBorderRadius","borderRadiusValues","setBorderRadius","hasBorderRadius","borderValues","radius","Object","entries","resetBorder","undefined","resetAll","onBorderChange","newBorder","newBorderWithStyle","updatedBorder","value"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,iCAAiC,IAAIC,mBADtC,EAECC,WAAW,IAAIC,sBAFhB,QAGO,yBAHP;AAIA,SACCC,8BAA8B,IAAIC,gBADnC,EAECC,6BAA6B,IAAIC,eAFlC,EAGCC,6BAA6B,IAAIC,eAHlC,EAICC,wBAAwB,IAAIC,UAJ7B,EAKCC,4BAA4B,IAAIC,cALjC,QAMO,uBANP;AAOA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,8BAAT,EAAyCC,kBAAz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,IAAI,EAAG;AATR,IAND,CAFF,EAqBGkB,gBAAgB,IACjB,cAAC,cAAD;AACC,IAAA,QAAQ,EAAGG,eADZ;AAEC,IAAA,KAAK,EAAGvC,EAAE,CAAE,QAAF,CAFX;AAGC,IAAA,UAAU,EAAG,MAAMsC,eAAe,CAAEO,SAAF,CAHnC;AAIC,IAAA,gBAAgB,EAAG;AAJpB,KAMC,cAAC,mBAAD;AACC,IAAA,MAAM,EAAGR,kBADV;AAEC,IAAA,QAAQ,EAAKc,KAAF,IAAa;AACvBb,MAAAA,eAAe,CAAEa,KAAK,IAAIN,SAAX,CAAf;AACA;AAJF,IAND,CAtBF,CADD;AAuCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalBorderRadiusControl as BorderRadiusControl,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\t__experimentalBorderBoxControl as BorderBoxControl,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n\t__experimentalIsDefinedBorder as isDefinedBorder,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getSupportedGlobalStylesPanels, useColorsPerOrigin } from './hooks';\nimport { unlock } from '../../private-apis';\n\nconst { useGlobalSetting, useGlobalStyle } = unlock( blockEditorPrivateApis );\n\nexport function useHasBorderPanel( name ) {\n\tconst controls = [\n\t\tuseHasBorderColorControl( name ),\n\t\tuseHasBorderRadiusControl( name ),\n\t\tuseHasBorderStyleControl( name ),\n\t\tuseHasBorderWidthControl( name ),\n\t];\n\n\treturn controls.some( Boolean );\n}\n\nfunction useHasBorderColorControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseGlobalSetting( 'border.color', name )[ 0 ] &&\n\t\tsupports.includes( 'borderColor' )\n\t);\n}\n\nfunction useHasBorderRadiusControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseGlobalSetting( 'border.radius', name )[ 0 ] &&\n\t\tsupports.includes( 'borderRadius' )\n\t);\n}\n\nfunction useHasBorderStyleControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseGlobalSetting( 'border.style', name )[ 0 ] &&\n\t\tsupports.includes( 'borderStyle' )\n\t);\n}\n\nfunction useHasBorderWidthControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseGlobalSetting( 'border.width', name )[ 0 ] &&\n\t\tsupports.includes( 'borderWidth' )\n\t);\n}\n\nfunction applyFallbackStyle( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( ! border.style && ( border.color || border.width ) ) {\n\t\treturn { ...border, style: 'solid' };\n\t}\n\n\treturn border;\n}\n\nfunction applyAllFallbackStyles( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( hasSplitBorders( border ) ) {\n\t\treturn {\n\t\t\ttop: applyFallbackStyle( border.top ),\n\t\t\tright: applyFallbackStyle( border.right ),\n\t\t\tbottom: applyFallbackStyle( border.bottom ),\n\t\t\tleft: applyFallbackStyle( border.left ),\n\t\t};\n\t}\n\n\treturn applyFallbackStyle( border );\n}\n\nexport default function BorderPanel( { name, variation = '' } ) {\n\tconst prefix = variation ? `variations.${ variation }.` : '';\n\t// To better reflect if the user has customized a value we need to\n\t// ensure the style value being checked is from the `user` origin.\n\tconst [ userBorderStyles ] = useGlobalStyle(\n\t\t`${ prefix }border`,\n\t\tname,\n\t\t'user'\n\t);\n\tconst [ border, setBorder ] = useGlobalStyle( `${ prefix }border`, name );\n\tconst colors = useColorsPerOrigin( name );\n\n\tconst showBorderColor = useHasBorderColorControl( name );\n\tconst showBorderStyle = useHasBorderStyleControl( name );\n\tconst showBorderWidth = useHasBorderWidthControl( name );\n\n\t// Border radius.\n\tconst showBorderRadius = useHasBorderRadiusControl( name );\n\tconst [ borderRadiusValues, setBorderRadius ] = useGlobalStyle(\n\t\t`${ prefix }border.radius`,\n\t\tname\n\t);\n\tconst hasBorderRadius = () => {\n\t\tconst borderValues = userBorderStyles?.radius;\n\t\tif ( typeof borderValues === 'object' ) {\n\t\t\treturn Object.entries( borderValues ).some( Boolean );\n\t\t}\n\t\treturn !! borderValues;\n\t};\n\n\tconst resetBorder = () => {\n\t\tif ( hasBorderRadius() ) {\n\t\t\treturn setBorder( { radius: userBorderStyles.radius } );\n\t\t}\n\n\t\tsetBorder( undefined );\n\t};\n\n\tconst resetAll = useCallback( () => setBorder( undefined ), [ setBorder ] );\n\tconst onBorderChange = useCallback(\n\t\t( newBorder ) => {\n\t\t\t// Ensure we have a visible border style when a border width or\n\t\t\t// color is being selected.\n\t\t\tconst newBorderWithStyle = applyAllFallbackStyles( newBorder );\n\n\t\t\t// As we can't conditionally generate styles based on if other\n\t\t\t// style properties have been set we need to force split border\n\t\t\t// definitions for user set border styles. Border radius is derived\n\t\t\t// from the same property i.e. `border.radius` if it is a string\n\t\t\t// that is used. The longhand border radii styles are only generated\n\t\t\t// if that property is an object.\n\t\t\t//\n\t\t\t// For borders (color, style, and width) those are all properties on\n\t\t\t// the `border` style property. This means if the theme.json defined\n\t\t\t// split borders and the user condenses them into a flat border or\n\t\t\t// vice-versa we'd get both sets of styles which would conflict.\n\t\t\tconst updatedBorder = ! hasSplitBorders( newBorderWithStyle )\n\t\t\t\t? {\n\t\t\t\t\t\ttop: newBorderWithStyle,\n\t\t\t\t\t\tright: newBorderWithStyle,\n\t\t\t\t\t\tbottom: newBorderWithStyle,\n\t\t\t\t\t\tleft: newBorderWithStyle,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tcolor: null,\n\t\t\t\t\t\tstyle: null,\n\t\t\t\t\t\twidth: null,\n\t\t\t\t\t\t...newBorderWithStyle,\n\t\t\t\t };\n\n\t\t\t// As radius is maintained separately to color, style, and width\n\t\t\t// maintain its value. Undefined values here will be cleaned when\n\t\t\t// global styles are saved.\n\t\t\tsetBorder( { radius: border?.radius, ...updatedBorder } );\n\t\t},\n\t\t[ setBorder ]\n\t);\n\n\treturn (\n\t\t<ToolsPanel label={ __( 'Border' ) } resetAll={ resetAll }>\n\t\t\t{ ( showBorderWidth || showBorderColor ) && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => isDefinedBorder( userBorderStyles ) }\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\tonDeselect={ () => resetBorder() }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BorderBoxControl\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tenableAlpha={ true }\n\t\t\t\t\t\tenableStyle={ showBorderStyle }\n\t\t\t\t\t\tonChange={ onBorderChange }\n\t\t\t\t\t\tpopoverOffset={ 40 }\n\t\t\t\t\t\tpopoverPlacement=\"left-start\"\n\t\t\t\t\t\tvalue={ border }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={ true }\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBorderRadius && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasBorderRadius }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ () => setBorderRadius( undefined ) }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusControl\n\t\t\t\t\t\tvalues={ borderRadiusValues }\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\tsetBorderRadius( value || undefined );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</ToolsPanel>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/border-panel.js"],"names":["__experimentalBorderRadiusControl","BorderRadiusControl","privateApis","blockEditorPrivateApis","__experimentalBorderBoxControl","BorderBoxControl","__experimentalHasSplitBorders","hasSplitBorders","__experimentalIsDefinedBorder","isDefinedBorder","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","useCallback","__","useSupportedStyles","useColorsPerOrigin","unlock","useGlobalSetting","useGlobalStyle","useHasBorderPanel","name","controls","useHasBorderColorControl","useHasBorderRadiusControl","useHasBorderStyleControl","useHasBorderWidthControl","some","Boolean","supports","includes","applyFallbackStyle","border","style","color","width","applyAllFallbackStyles","top","right","bottom","left","BorderPanel","variation","prefix","userBorderStyles","setBorder","colors","showBorderColor","showBorderStyle","showBorderWidth","showBorderRadius","borderRadiusValues","setBorderRadius","hasBorderRadius","borderValues","radius","Object","entries","resetBorder","undefined","resetAll","onBorderChange","newBorder","newBorderWithStyle","updatedBorder","value"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,iCAAiC,IAAIC,mBADtC,EAECC,WAAW,IAAIC,sBAFhB,QAGO,yBAHP;AAIA,SACCC,8BAA8B,IAAIC,gBADnC,EAECC,6BAA6B,IAAIC,eAFlC,EAGCC,6BAA6B,IAAIC,eAHlC,EAICC,wBAAwB,IAAIC,UAJ7B,EAKCC,4BAA4B,IAAIC,cALjC,QAMO,uBANP;AAOA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,kBAAT,EAA6BC,kBAA7B,QAAuD,SAAvD;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA,MAAM;AAAEC,EAAAA,gBAAF;AAAoBC,EAAAA;AAApB,IAAuCF,MAAM,CAAEf,sBAAF,CAAnD;AAEA,OAAO,SAASkB,iBAAT,CAA4BC,IAA5B,EAAmC;AACzC,QAAMC,QAAQ,GAAG,CAChBC,wBAAwB,CAAEF,IAAF,CADR,EAEhBG,yBAAyB,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AAA,gBAAgB,EAAG;AAJpB,KAMC,cAAC,mBAAD;AACC,IAAA,MAAM,EAAGR,kBADV;AAEC,IAAA,QAAQ,EAAKc,KAAF,IAAa;AACvBb,MAAAA,eAAe,CAAEa,KAAK,IAAIN,SAAX,CAAf;AACA;AAJF,IAND,CAtBF,CADD;AAuCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalBorderRadiusControl as BorderRadiusControl,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\t__experimentalBorderBoxControl as BorderBoxControl,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n\t__experimentalIsDefinedBorder as isDefinedBorder,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSupportedStyles, useColorsPerOrigin } from './hooks';\nimport { unlock } from '../../private-apis';\n\nconst { useGlobalSetting, useGlobalStyle } = unlock( blockEditorPrivateApis );\n\nexport function useHasBorderPanel( name ) {\n\tconst controls = [\n\t\tuseHasBorderColorControl( name ),\n\t\tuseHasBorderRadiusControl( name ),\n\t\tuseHasBorderStyleControl( name ),\n\t\tuseHasBorderWidthControl( name ),\n\t];\n\n\treturn controls.some( Boolean );\n}\n\nfunction useHasBorderColorControl( name ) {\n\tconst supports = useSupportedStyles( name );\n\treturn (\n\t\tuseGlobalSetting( 'border.color', name )[ 0 ] &&\n\t\tsupports.includes( 'borderColor' )\n\t);\n}\n\nfunction useHasBorderRadiusControl( name ) {\n\tconst supports = useSupportedStyles( name );\n\treturn (\n\t\tuseGlobalSetting( 'border.radius', name )[ 0 ] &&\n\t\tsupports.includes( 'borderRadius' )\n\t);\n}\n\nfunction useHasBorderStyleControl( name ) {\n\tconst supports = useSupportedStyles( name );\n\treturn (\n\t\tuseGlobalSetting( 'border.style', name )[ 0 ] &&\n\t\tsupports.includes( 'borderStyle' )\n\t);\n}\n\nfunction useHasBorderWidthControl( name ) {\n\tconst supports = useSupportedStyles( name );\n\treturn (\n\t\tuseGlobalSetting( 'border.width', name )[ 0 ] &&\n\t\tsupports.includes( 'borderWidth' )\n\t);\n}\n\nfunction applyFallbackStyle( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( ! border.style && ( border.color || border.width ) ) {\n\t\treturn { ...border, style: 'solid' };\n\t}\n\n\treturn border;\n}\n\nfunction applyAllFallbackStyles( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( hasSplitBorders( border ) ) {\n\t\treturn {\n\t\t\ttop: applyFallbackStyle( border.top ),\n\t\t\tright: applyFallbackStyle( border.right ),\n\t\t\tbottom: applyFallbackStyle( border.bottom ),\n\t\t\tleft: applyFallbackStyle( border.left ),\n\t\t};\n\t}\n\n\treturn applyFallbackStyle( border );\n}\n\nexport default function BorderPanel( { name, variation = '' } ) {\n\tconst prefix = variation ? `variations.${ variation }.` : '';\n\t// To better reflect if the user has customized a value we need to\n\t// ensure the style value being checked is from the `user` origin.\n\tconst [ userBorderStyles ] = useGlobalStyle(\n\t\t`${ prefix }border`,\n\t\tname,\n\t\t'user'\n\t);\n\tconst [ border, setBorder ] = useGlobalStyle( `${ prefix }border`, name );\n\tconst colors = useColorsPerOrigin( name );\n\n\tconst showBorderColor = useHasBorderColorControl( name );\n\tconst showBorderStyle = useHasBorderStyleControl( name );\n\tconst showBorderWidth = useHasBorderWidthControl( name );\n\n\t// Border radius.\n\tconst showBorderRadius = useHasBorderRadiusControl( name );\n\tconst [ borderRadiusValues, setBorderRadius ] = useGlobalStyle(\n\t\t`${ prefix }border.radius`,\n\t\tname\n\t);\n\tconst hasBorderRadius = () => {\n\t\tconst borderValues = userBorderStyles?.radius;\n\t\tif ( typeof borderValues === 'object' ) {\n\t\t\treturn Object.entries( borderValues ).some( Boolean );\n\t\t}\n\t\treturn !! borderValues;\n\t};\n\n\tconst resetBorder = () => {\n\t\tif ( hasBorderRadius() ) {\n\t\t\treturn setBorder( { radius: userBorderStyles.radius } );\n\t\t}\n\n\t\tsetBorder( undefined );\n\t};\n\n\tconst resetAll = useCallback( () => setBorder( undefined ), [ setBorder ] );\n\tconst onBorderChange = useCallback(\n\t\t( newBorder ) => {\n\t\t\t// Ensure we have a visible border style when a border width or\n\t\t\t// color is being selected.\n\t\t\tconst newBorderWithStyle = applyAllFallbackStyles( newBorder );\n\n\t\t\t// As we can't conditionally generate styles based on if other\n\t\t\t// style properties have been set we need to force split border\n\t\t\t// definitions for user set border styles. Border radius is derived\n\t\t\t// from the same property i.e. `border.radius` if it is a string\n\t\t\t// that is used. The longhand border radii styles are only generated\n\t\t\t// if that property is an object.\n\t\t\t//\n\t\t\t// For borders (color, style, and width) those are all properties on\n\t\t\t// the `border` style property. This means if the theme.json defined\n\t\t\t// split borders and the user condenses them into a flat border or\n\t\t\t// vice-versa we'd get both sets of styles which would conflict.\n\t\t\tconst updatedBorder = ! hasSplitBorders( newBorderWithStyle )\n\t\t\t\t? {\n\t\t\t\t\t\ttop: newBorderWithStyle,\n\t\t\t\t\t\tright: newBorderWithStyle,\n\t\t\t\t\t\tbottom: newBorderWithStyle,\n\t\t\t\t\t\tleft: newBorderWithStyle,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tcolor: null,\n\t\t\t\t\t\tstyle: null,\n\t\t\t\t\t\twidth: null,\n\t\t\t\t\t\t...newBorderWithStyle,\n\t\t\t\t };\n\n\t\t\t// As radius is maintained separately to color, style, and width\n\t\t\t// maintain its value. Undefined values here will be cleaned when\n\t\t\t// global styles are saved.\n\t\t\tsetBorder( { radius: border?.radius, ...updatedBorder } );\n\t\t},\n\t\t[ setBorder, border?.radius ]\n\t);\n\n\treturn (\n\t\t<ToolsPanel label={ __( 'Border' ) } resetAll={ resetAll }>\n\t\t\t{ ( showBorderWidth || showBorderColor ) && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => isDefinedBorder( userBorderStyles ) }\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\tonDeselect={ () => resetBorder() }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BorderBoxControl\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tenableAlpha={ true }\n\t\t\t\t\t\tenableStyle={ showBorderStyle }\n\t\t\t\t\t\tonChange={ onBorderChange }\n\t\t\t\t\t\tpopoverOffset={ 40 }\n\t\t\t\t\t\tpopoverPlacement=\"left-start\"\n\t\t\t\t\t\tvalue={ border }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={ true }\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBorderRadius && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasBorderRadius }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ () => setBorderRadius( undefined ) }\n\t\t\t\t\tisShownByDefault={ true }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusControl\n\t\t\t\t\t\tvalues={ borderRadiusValues }\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\tsetBorderRadius( value || undefined );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</ToolsPanel>\n\t);\n}\n"]}
|
|
@@ -32,17 +32,20 @@ export default function ColorPalettePanel(_ref) {
|
|
|
32
32
|
canOnlyChangeValues: true,
|
|
33
33
|
colors: themeColors,
|
|
34
34
|
onChange: setThemeColors,
|
|
35
|
-
paletteLabel: __('Theme')
|
|
35
|
+
paletteLabel: __('Theme'),
|
|
36
|
+
paletteLabelHeadingLevel: 3
|
|
36
37
|
}), !!defaultColors && !!defaultColors.length && !!defaultPaletteEnabled && createElement(PaletteEdit, {
|
|
37
38
|
canReset: defaultColors !== baseDefaultColors,
|
|
38
39
|
canOnlyChangeValues: true,
|
|
39
40
|
colors: defaultColors,
|
|
40
41
|
onChange: setDefaultColors,
|
|
41
|
-
paletteLabel: __('Default')
|
|
42
|
+
paletteLabel: __('Default'),
|
|
43
|
+
paletteLabelHeadingLevel: 3
|
|
42
44
|
}), createElement(PaletteEdit, {
|
|
43
45
|
colors: customColors,
|
|
44
46
|
onChange: setCustomColors,
|
|
45
47
|
paletteLabel: __('Custom'),
|
|
48
|
+
paletteLabelHeadingLevel: 3,
|
|
46
49
|
emptyMessage: __('Custom colors are empty! Add some colors to create your own color palette.'),
|
|
47
50
|
slugPrefix: "custom-"
|
|
48
51
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/color-palette-panel.js"],"names":["__experimentalPaletteEdit","PaletteEdit","__experimentalVStack","VStack","__","privateApis","blockEditorPrivateApis","unlock","useGlobalSetting","ColorPalettePanel","name","themeColors","setThemeColors","baseThemeColors","defaultColors","setDefaultColors","baseDefaultColors","customColors","setCustomColors","defaultPaletteEnabled","length"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,yBAAyB,IAAIC,WAD9B,EAECC,oBAAoB,IAAIC,MAFzB,QAGO,uBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAW,IAAIC,sBAAxB,QAAsD,yBAAtD;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAuBD,MAAM,CAAED,sBAAF,CAAnC;AAEA,eAAe,SAASG,iBAAT,OAAuC;AAAA,MAAX;AAAEC,IAAAA;AAAF,GAAW;AACrD,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkCJ,gBAAgB,CACvD,qBADuD,EAEvDE,IAFuD,CAAxD;AAIA,QAAM,CAAEG,eAAF,IAAsBL,gBAAgB,CAC3C,qBAD2C,EAE3CE,IAF2C,EAG3C,MAH2C,CAA5C;AAKA,QAAM,CAAEI,aAAF,EAAiBC,gBAAjB,IAAsCP,gBAAgB,CAC3D,uBAD2D,EAE3DE,IAF2D,CAA5D;AAIA,QAAM,CAAEM,iBAAF,IAAwBR,gBAAgB,CAC7C,uBAD6C,EAE7CE,IAF6C,EAG7C,MAH6C,CAA9C;AAKA,QAAM,CAAEO,YAAF,EAAgBC,eAAhB,IAAoCV,gBAAgB,CACzD,sBADyD,EAEzDE,IAFyD,CAA1D;AAKA,QAAM,CAAES,qBAAF,IAA4BX,gBAAgB,CACjD,sBADiD,EAEjDE,IAFiD,CAAlD;AAIA,SACC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,OAAO,EAAG;AAFX,KAIG,CAAC,CAAEC,WAAH,IAAkB,CAAC,CAAEA,WAAW,CAACS,MAAjC,IACD,cAAC,WAAD;AACC,IAAA,QAAQ,EAAGT,WAAW,KAAKE,eAD5B;AAEC,IAAA,mBAAmB,MAFpB;AAGC,IAAA,MAAM,EAAGF,WAHV;AAIC,IAAA,QAAQ,EAAGC,cAJZ;AAKC,IAAA,YAAY,EAAGR,EAAE,CAAE,OAAF;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/color-palette-panel.js"],"names":["__experimentalPaletteEdit","PaletteEdit","__experimentalVStack","VStack","__","privateApis","blockEditorPrivateApis","unlock","useGlobalSetting","ColorPalettePanel","name","themeColors","setThemeColors","baseThemeColors","defaultColors","setDefaultColors","baseDefaultColors","customColors","setCustomColors","defaultPaletteEnabled","length"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,yBAAyB,IAAIC,WAD9B,EAECC,oBAAoB,IAAIC,MAFzB,QAGO,uBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAW,IAAIC,sBAAxB,QAAsD,yBAAtD;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA,MA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AA,mBAAmB,MAFpB;AAGC,IAAA,MAAM,EAAGF,aAHV;AAIC,IAAA,QAAQ,EAAGC,gBAJZ;AAKC,IAAA,YAAY,EAAGX,EAAE,CAAE,SAAF,CALlB;AAMC,IAAA,wBAAwB,EAAG;AAN5B,IAjBH,EA0BC,cAAC,WAAD;AACC,IAAA,MAAM,EAAGa,YADV;AAEC,IAAA,QAAQ,EAAGC,eAFZ;AAGC,IAAA,YAAY,EAAGd,EAAE,CAAE,QAAF,CAHlB;AAIC,IAAA,wBAAwB,EAAG,CAJ5B;AAKC,IAAA,YAAY,EAAGA,EAAE,CAChB,4EADgB,CALlB;AAQC,IAAA,UAAU,EAAC;AARZ,IA1BD,CADD;AAuCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalPaletteEdit as PaletteEdit,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\n\nconst { useGlobalSetting } = unlock( blockEditorPrivateApis );\n\nexport default function ColorPalettePanel( { name } ) {\n\tconst [ themeColors, setThemeColors ] = useGlobalSetting(\n\t\t'color.palette.theme',\n\t\tname\n\t);\n\tconst [ baseThemeColors ] = useGlobalSetting(\n\t\t'color.palette.theme',\n\t\tname,\n\t\t'base'\n\t);\n\tconst [ defaultColors, setDefaultColors ] = useGlobalSetting(\n\t\t'color.palette.default',\n\t\tname\n\t);\n\tconst [ baseDefaultColors ] = useGlobalSetting(\n\t\t'color.palette.default',\n\t\tname,\n\t\t'base'\n\t);\n\tconst [ customColors, setCustomColors ] = useGlobalSetting(\n\t\t'color.palette.custom',\n\t\tname\n\t);\n\n\tconst [ defaultPaletteEnabled ] = useGlobalSetting(\n\t\t'color.defaultPalette',\n\t\tname\n\t);\n\treturn (\n\t\t<VStack\n\t\t\tclassName=\"edit-site-global-styles-color-palette-panel\"\n\t\t\tspacing={ 10 }\n\t\t>\n\t\t\t{ !! themeColors && !! themeColors.length && (\n\t\t\t\t<PaletteEdit\n\t\t\t\t\tcanReset={ themeColors !== baseThemeColors }\n\t\t\t\t\tcanOnlyChangeValues\n\t\t\t\t\tcolors={ themeColors }\n\t\t\t\t\tonChange={ setThemeColors }\n\t\t\t\t\tpaletteLabel={ __( 'Theme' ) }\n\t\t\t\t\tpaletteLabelHeadingLevel={ 3 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ !! defaultColors &&\n\t\t\t\t!! defaultColors.length &&\n\t\t\t\t!! defaultPaletteEnabled && (\n\t\t\t\t\t<PaletteEdit\n\t\t\t\t\t\tcanReset={ defaultColors !== baseDefaultColors }\n\t\t\t\t\t\tcanOnlyChangeValues\n\t\t\t\t\t\tcolors={ defaultColors }\n\t\t\t\t\t\tonChange={ setDefaultColors }\n\t\t\t\t\t\tpaletteLabel={ __( 'Default' ) }\n\t\t\t\t\t\tpaletteLabelHeadingLevel={ 3 }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t<PaletteEdit\n\t\t\t\tcolors={ customColors }\n\t\t\t\tonChange={ setCustomColors }\n\t\t\t\tpaletteLabel={ __( 'Custom' ) }\n\t\t\t\tpaletteLabelHeadingLevel={ 3 }\n\t\t\t\temptyMessage={ __(\n\t\t\t\t\t'Custom colors are empty! Add some colors to create your own color palette.'\n\t\t\t\t) }\n\t\t\t\tslugPrefix=\"custom-\"\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { useSupportedStyles } from './hooks';
|
|
5
5
|
export function useHasColorPanel(name) {
|
|
6
|
-
const supports =
|
|
6
|
+
const supports = useSupportedStyles(name);
|
|
7
7
|
return supports.includes('color') || supports.includes('backgroundColor') || supports.includes('background') || supports.includes('linkColor');
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=color-utils.js.map
|