@wordpress/edit-site 3.0.15 → 3.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/add-new-template/new-template-part.js +29 -18
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +30 -23
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/app/index.js +51 -0
- package/build/components/app/index.js.map +1 -0
- package/build/components/block-editor/back-button.js +8 -20
- package/build/components/block-editor/back-button.js.map +1 -1
- package/build/components/block-editor/index.js +2 -1
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +0 -2
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/edit-template-part-menu-button/index.js +20 -8
- package/build/components/edit-template-part-menu-button/index.js.map +1 -1
- package/build/components/editor/index.js +11 -30
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +10 -10
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +1 -2
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/header/document-actions/index.js +3 -6
- package/build/components/header/document-actions/index.js.map +1 -1
- package/build/components/list/index.js +17 -15
- package/build/components/list/index.js.map +1 -1
- package/build/components/list/table.js +4 -4
- package/build/components/list/table.js.map +1 -1
- package/build/components/navigation-sidebar/index.js +12 -13
- package/build/components/navigation-sidebar/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +26 -24
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build/components/routes/index.js +60 -0
- package/build/components/routes/index.js.map +1 -0
- package/build/components/routes/link.js +65 -0
- package/build/components/routes/link.js.map +1 -0
- package/build/components/routes/use-title.js +57 -0
- package/build/components/routes/use-title.js.map +1 -0
- package/build/components/sidebar/global-styles-sidebar.js +10 -0
- package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar/template-card/template-areas.js +7 -4
- package/build/components/sidebar/template-card/template-areas.js.map +1 -1
- package/build/components/template-details/index.js +12 -10
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-areas.js +27 -10
- package/build/components/template-details/template-areas.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +7 -12
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/components/url-query-controller/index.js +41 -50
- package/build/components/url-query-controller/index.js.map +1 -1
- package/build/components/welcome-guide/editor.js +6 -0
- package/build/components/welcome-guide/editor.js.map +1 -1
- package/build/components/welcome-guide/index.js +1 -28
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/welcome-guide/styles.js +18 -1
- package/build/components/welcome-guide/styles.js.map +1 -1
- package/build/index.js +29 -35
- package/build/index.js.map +1 -1
- package/build/plugins/index.js +3 -23
- package/build/plugins/index.js.map +1 -1
- package/build/plugins/site-export.js +61 -0
- package/build/plugins/site-export.js.map +1 -0
- package/build/plugins/welcome-guide-menu-item.js +1 -7
- package/build/plugins/welcome-guide-menu-item.js.map +1 -1
- package/build/store/actions.js +0 -27
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +1 -14
- package/build/store/constants.js.map +1 -1
- package/build/store/reducer.js +7 -16
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +1 -31
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-is-list-page.js +23 -0
- package/build/utils/get-is-list-page.js.map +1 -0
- package/build/utils/history.js +35 -0
- package/build/utils/history.js.map +1 -0
- package/build-module/components/add-new-template/new-template-part.js +27 -16
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +28 -18
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/app/index.js +35 -0
- package/build-module/components/app/index.js.map +1 -0
- package/build-module/components/block-editor/back-button.js +8 -19
- package/build-module/components/block-editor/back-button.js.map +1 -1
- package/build-module/components/block-editor/index.js +2 -1
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +0 -2
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/edit-template-part-menu-button/index.js +17 -9
- package/build-module/components/edit-template-part-menu-button/index.js.map +1 -1
- package/build-module/components/editor/index.js +13 -33
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +10 -10
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +1 -2
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/header/document-actions/index.js +3 -6
- package/build-module/components/header/document-actions/index.js.map +1 -1
- package/build-module/components/list/index.js +15 -15
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/list/table.js +4 -4
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/navigation-sidebar/index.js +13 -13
- package/build-module/components/navigation-sidebar/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +24 -24
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build-module/components/routes/index.js +47 -0
- package/build-module/components/routes/index.js.map +1 -0
- package/build-module/components/routes/link.js +51 -0
- package/build-module/components/routes/link.js.map +1 -0
- package/build-module/components/routes/use-title.js +44 -0
- package/build-module/components/routes/use-title.js.map +1 -0
- package/build-module/components/sidebar/global-styles-sidebar.js +8 -0
- package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar/template-card/template-areas.js +8 -4
- package/build-module/components/sidebar/template-card/template-areas.js.map +1 -1
- package/build-module/components/template-details/index.js +10 -9
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-areas.js +24 -9
- package/build-module/components/template-details/template-areas.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +7 -12
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/components/url-query-controller/index.js +40 -49
- package/build-module/components/url-query-controller/index.js.map +1 -1
- package/build-module/components/welcome-guide/editor.js +7 -1
- package/build-module/components/welcome-guide/editor.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +2 -26
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/welcome-guide/styles.js +18 -2
- package/build-module/components/welcome-guide/styles.js.map +1 -1
- package/build-module/index.js +28 -33
- package/build-module/index.js.map +1 -1
- package/build-module/plugins/index.js +2 -18
- package/build-module/plugins/index.js.map +1 -1
- package/build-module/plugins/site-export.js +45 -0
- package/build-module/plugins/site-export.js.map +1 -0
- package/build-module/plugins/welcome-guide-menu-item.js +2 -7
- package/build-module/plugins/welcome-guide-menu-item.js.map +1 -1
- package/build-module/store/actions.js +0 -23
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js +0 -11
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/reducer.js +7 -16
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +1 -27
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-is-list-page.js +16 -0
- package/build-module/utils/get-is-list-page.js.map +1 -0
- package/build-module/utils/history.js +25 -0
- package/build-module/utils/history.js.map +1 -0
- package/build-style/style-rtl.css +1 -6
- package/build-style/style.css +1 -6
- package/package.json +9 -8
- package/src/components/add-new-template/new-template-part.js +29 -11
- package/src/components/add-new-template/new-template.js +26 -12
- package/src/components/app/index.js +47 -0
- package/src/components/block-editor/back-button.js +6 -14
- package/src/components/block-editor/index.js +1 -0
- package/src/components/create-template-part-modal/index.js +0 -2
- package/src/components/edit-template-part-menu-button/index.js +16 -5
- package/src/components/editor/index.js +105 -131
- package/src/components/global-styles/gradients-palette-panel.js +12 -12
- package/src/components/global-styles/use-global-styles-output.js +0 -1
- package/src/components/header/document-actions/index.js +3 -9
- package/src/components/list/index.js +11 -12
- package/src/components/list/style.scss +6 -11
- package/src/components/list/table.js +5 -5
- package/src/components/navigation-sidebar/index.js +18 -17
- package/src/components/navigation-sidebar/navigation-panel/index.js +16 -22
- package/src/components/routes/index.js +53 -0
- package/src/components/routes/link.js +44 -0
- package/src/components/routes/use-title.js +56 -0
- package/src/components/sidebar/global-styles-sidebar.js +8 -0
- package/src/components/sidebar/template-card/template-areas.js +16 -4
- package/src/components/template-details/index.js +8 -6
- package/src/components/template-details/template-areas.js +31 -8
- package/src/components/template-part-converter/convert-to-template-part.js +4 -2
- package/src/components/url-query-controller/index.js +34 -45
- package/src/components/welcome-guide/editor.js +10 -1
- package/src/components/welcome-guide/index.js +6 -25
- package/src/components/welcome-guide/styles.js +20 -2
- package/src/index.js +33 -36
- package/src/plugins/index.js +2 -32
- package/src/plugins/site-export.js +48 -0
- package/src/plugins/welcome-guide-menu-item.js +2 -16
- package/src/store/actions.js +0 -23
- package/src/store/constants.js +0 -12
- package/src/store/reducer.js +12 -26
- package/src/store/selectors.js +1 -27
- package/src/store/test/reducer.js +22 -39
- package/src/store/test/selectors.js +3 -34
- package/src/utils/get-is-list-page.js +11 -0
- package/src/utils/history.js +35 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/selectors.js"],"names":["get","map","keyBy","createSelector","store","coreDataStore","createRegistrySelector","uploadMedia","isTemplatePart","Platform","MENU_ROOT","MENU_TEMPLATE_PARTS","MENU_TEMPLATES_UNUSED","TEMPLATE_PARTS_SUB_MENUS","getTemplateLocation","isTemplateSuperseded","isFeatureActive","state","feature","preferences","features","__experimentalGetPreviewDeviceType","deviceType","getCanUserCreateMedia","select","canUser","getReusableBlocks","isWeb","OS","getEntityRecords","per_page","getSettings","setIsInserterOpen","settings","outlineMode","focusMode","hasFixedToolbar","__experimentalSetIsInserterOpened","__experimentalReusableBlocks","canUserCreateMedia","mediaUpload","onError","rest","wpAllowedMimeTypes","allowedMimeTypes","message","getHomeTemplateId","homeTemplateId","getCurrentEditedPost","editedPost","length","getPreviousEditedPost","getEditedPostType","type","getEditedPostId","id","getPreviousEditedPostType","getPreviousEditedPostId","getPage","page","getNavigationPanelActiveMenu","navigationPanel","menu","getCurrentTemplateNavigationPanelSubMenu","templateType","templateId","template","getEntityRecord","find","submenu","area","templates","showOnFront","getEditedEntityRecord","show_on_front","slug","isNavigationOpened","isOpen","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","isListViewOpened","listViewPanel","getCurrentTemplateTemplateParts","templateParts","templatePartsById","templatePart","blocks","filter","block","attributes","theme","templatePartId"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,GAAd,EAAmBC,KAAnB,QAAgC,QAAhC;AACA,OAAOC,cAAP,MAA2B,QAA3B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,sBAAvC;AACA,SAASC,sBAAT,QAAuC,iBAAvC;AACA,SAASC,WAAT,QAA4B,wBAA5B;AACA,SAASC,cAAT,QAA+B,mBAA/B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SACCC,SADD,EAECC,mBAFD,EAGCC,qBAHD,EAICC,wBAJD,QAKO,6DALP;AAMA,SACCC,mBADD,EAECC,oBAFD,QAGO,sEAHP;AAKA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,eAAT,CAA0BC,KAA1B,EAAiCC,OAAjC,EAA2C;AACjD,SAAOlB,GAAG,CAAEiB,KAAK,CAACE,WAAN,CAAkBC,QAApB,EAA8B,CAAEF,OAAF,CAA9B,EAA2C,KAA3C,CAAV;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,kCAAT,CAA6CJ,KAA7C,EAAqD;AAC3D,SAAOA,KAAK,CAACK,UAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,qBAAqB,GAAGjB,sBAAsB,CAAIkB,MAAF,IAAc,MAC1EA,MAAM,CAAEn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AAF,CAAlC;AACA,QAAMiD,QAAQ,GAAG1C,MAAM,CAAEnB,aAAF,CAAN,CAAwBoE,qBAAxB,CAChB,UADgB,EAEhBT,YAFgB,EAGhBC,UAHgB,CAAjB;AAMA,QAAMsB,aAAa,GAAG/D,MAAM,CAC3BnB,aAD2B,CAAN,CAEpBwB,gBAFoB,CAEF,UAFE,EAEU,kBAFV,EAE8B;AAAEC,IAAAA,QAAQ,EAAE,CAAC;AAAb,GAF9B,CAAtB;AAGA,QAAM0D,iBAAiB,GAAGtF,KAAK,CAC9BqF,aAD8B,EAE5BE,YAAF,IAAoBA,YAAY,CAAClC,EAFH,CAA/B;AAKA,SAAO,qBAAEW,QAAQ,CAACwB,MAAX,+DAAqB,EAArB,EACLC,MADK,CACKC,KAAF,IAAapF,cAAc,CAAEoF,KAAF,CAD9B,EAEL3F,GAFK,CAEE2F,KAAF,IAAa;AAClB,UAAM;AACLC,MAAAA,UAAU,EAAE;AAAEC,QAAAA,KAAF;AAASnB,QAAAA;AAAT;AADP,QAEFiB,KAFJ;AAGA,UAAMG,cAAc,GAAI,GAAGD,KAAO,KAAKnB,IAAM,EAA7C;AACA,UAAMc,YAAY,GAAGD,iBAAiB,CAAEO,cAAF,CAAtC;AAEA,WAAO;AACNN,MAAAA,YADM;AAENG,MAAAA;AAFM,KAAP;AAIA,GAbK,EAcLD,MAdK,CAcG;AAAA,QAAE;AAAEF,MAAAA;AAAF,KAAF;AAAA,WAAwB,CAAC,CAAEA,YAA3B;AAAA,GAdH,CAAP;AAeA,CAjCmE,CAA9D","sourcesContent":["/**\n * External dependencies\n */\nimport { get, map, keyBy } from 'lodash';\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { isTemplatePart } from '@wordpress/blocks';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tMENU_ROOT,\n\tMENU_TEMPLATE_PARTS,\n\tMENU_TEMPLATES_UNUSED,\n\tTEMPLATE_PARTS_SUB_MENUS,\n} from '../components/navigation-sidebar/navigation-panel/constants';\nimport {\n\tgetTemplateLocation,\n\tisTemplateSuperseded,\n} from '../components/navigation-sidebar/navigation-panel/template-hierarchy';\n\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @param {Object} state Global application state.\n * @param {string} feature Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function isFeatureActive( state, feature ) {\n\treturn get( state.preferences.features, [ feature ], false );\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns whether the current user can create media or not.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Whether the current user can create media or not.\n */\nexport const getCanUserCreateMedia = createRegistrySelector( ( select ) => () =>\n\tselect( coreDataStore ).canUser( 'create', 'media' )\n);\n\n/**\n * Returns any available Reusable blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} The available reusable blocks.\n */\nexport const getReusableBlocks = createRegistrySelector( ( select ) => () => {\n\tconst isWeb = Platform.OS === 'web';\n\treturn isWeb\n\t\t? select( coreDataStore ).getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\tper_page: -1,\n\t\t } )\n\t\t: [];\n} );\n\n/**\n * Returns the settings, taking into account active features and permissions.\n *\n * @param {Object} state Global application state.\n * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.\n *\n * @return {Object} Settings.\n */\nexport const getSettings = createSelector(\n\t( state, setIsInserterOpen ) => {\n\t\tconst settings = {\n\t\t\t...state.settings,\n\t\t\toutlineMode: true,\n\t\t\tfocusMode: isFeatureActive( state, 'focusMode' ),\n\t\t\thasFixedToolbar: isFeatureActive( state, 'fixedToolbar' ),\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpen,\n\t\t\t__experimentalReusableBlocks: getReusableBlocks( state ),\n\t\t};\n\n\t\tconst canUserCreateMedia = getCanUserCreateMedia( state );\n\t\tif ( ! canUserCreateMedia ) {\n\t\t\treturn settings;\n\t\t}\n\n\t\tsettings.mediaUpload = ( { onError, ...rest } ) => {\n\t\t\tuploadMedia( {\n\t\t\t\twpAllowedMimeTypes: state.settings.allowedMimeTypes,\n\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t};\n\t\treturn settings;\n\t},\n\t( state ) => [\n\t\tgetCanUserCreateMedia( state ),\n\t\tstate.settings,\n\t\tisFeatureActive( state, 'focusMode' ),\n\t\tisFeatureActive( state, 'fixedToolbar' ),\n\t\tgetReusableBlocks( state ),\n\t]\n);\n\n/**\n * Returns the current home template ID.\n *\n * @param {Object} state Global application state.\n *\n * @return {number?} Home template ID.\n */\nexport function getHomeTemplateId( state ) {\n\treturn state.homeTemplateId;\n}\n\nfunction getCurrentEditedPost( state ) {\n\treturn state.editedPost[ state.editedPost.length - 1 ] || {};\n}\n\nfunction getPreviousEditedPost( state ) {\n\treturn state.editedPost[ state.editedPost.length - 2 ] || {};\n}\n\n/**\n * Returns the current edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getEditedPostType( state ) {\n\treturn getCurrentEditedPost( state ).type;\n}\n\n/**\n * Returns the ID of the currently edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getEditedPostId( state ) {\n\treturn getCurrentEditedPost( state ).id;\n}\n\n/**\n * Returns the previous edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getPreviousEditedPostType( state ) {\n\treturn getPreviousEditedPost( state ).type;\n}\n\n/**\n * Returns the ID of the previous edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getPreviousEditedPostId( state ) {\n\treturn getPreviousEditedPost( state ).id;\n}\n\n/**\n * Returns the current page object.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn getCurrentEditedPost( state ).page;\n}\n\n/**\n * Returns the active menu in the navigation panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Active menu.\n */\nexport function getNavigationPanelActiveMenu( state ) {\n\treturn state.navigationPanel.menu;\n}\n\n/**\n * Returns the current template or template part's corresponding\n * navigation panel's sub menu, to be used with `openNavigationPanelToMenu`.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} The current template or template part's sub menu.\n */\nexport const getCurrentTemplateNavigationPanelSubMenu = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = templateId\n\t\t\t? select( coreDataStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplateType,\n\t\t\t\t\ttemplateId\n\t\t\t )\n\t\t\t: null;\n\n\t\tif ( ! template ) {\n\t\t\treturn MENU_ROOT;\n\t\t}\n\n\t\tif ( 'wp_template_part' === templateType ) {\n\t\t\treturn (\n\t\t\t\tTEMPLATE_PARTS_SUB_MENUS.find(\n\t\t\t\t\t( submenu ) => submenu.area === template?.area\n\t\t\t\t)?.menu || MENU_TEMPLATE_PARTS\n\t\t\t);\n\t\t}\n\n\t\tconst templates = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template'\n\t\t);\n\t\tconst showOnFront = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'root',\n\t\t\t'site'\n\t\t).show_on_front;\n\n\t\tif (\n\t\t\tisTemplateSuperseded(\n\t\t\t\ttemplate.slug,\n\t\t\t\tmap( templates, 'slug' ),\n\t\t\t\tshowOnFront\n\t\t\t)\n\t\t) {\n\t\t\treturn MENU_TEMPLATES_UNUSED;\n\t\t}\n\n\t\treturn getTemplateLocation( template.slug );\n\t}\n);\n\n/**\n * Returns the current opened/closed state of the navigation panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the navigation panel should be open; false if closed.\n */\nexport function isNavigationOpened( state ) {\n\treturn state.navigationPanel.isOpen;\n}\n\n/**\n * Returns the current opened/closed state of the inserter panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the inserter panel should be open; false if closed.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst {\n\t\trootClientId,\n\t\tinsertionIndex,\n\t\tfilterValue,\n\t} = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex, filterValue };\n}\n\n/**\n * Returns the current opened/closed state of the list view panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the list view panel should be open; false if closed.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns the template parts and their blocks for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Array} Template parts and their blocks in an array.\n */\nexport const getCurrentTemplateTemplateParts = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplateType,\n\t\t\ttemplateId\n\t\t);\n\n\t\tconst templateParts = select(\n\t\t\tcoreDataStore\n\t\t).getEntityRecords( 'postType', 'wp_template_part', { per_page: -1 } );\n\t\tconst templatePartsById = keyBy(\n\t\t\ttemplateParts,\n\t\t\t( templatePart ) => templatePart.id\n\t\t);\n\n\t\treturn ( template.blocks ?? [] )\n\t\t\t.filter( ( block ) => isTemplatePart( block ) )\n\t\t\t.map( ( block ) => {\n\t\t\t\tconst {\n\t\t\t\t\tattributes: { theme, slug },\n\t\t\t\t} = block;\n\t\t\t\tconst templatePartId = `${ theme }//${ slug }`;\n\t\t\t\tconst templatePart = templatePartsById[ templatePartId ];\n\n\t\t\t\treturn {\n\t\t\t\t\ttemplatePart,\n\t\t\t\t\tblock,\n\t\t\t\t};\n\t\t\t} )\n\t\t\t.filter( ( { templatePart } ) => !! templatePart );\n\t}\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/selectors.js"],"names":["get","map","keyBy","createSelector","store","coreDataStore","createRegistrySelector","uploadMedia","isTemplatePart","Platform","MENU_ROOT","MENU_TEMPLATE_PARTS","MENU_TEMPLATES_UNUSED","TEMPLATE_PARTS_SUB_MENUS","getTemplateLocation","isTemplateSuperseded","isFeatureActive","state","feature","preferences","features","__experimentalGetPreviewDeviceType","deviceType","getCanUserCreateMedia","select","canUser","getReusableBlocks","isWeb","OS","getEntityRecords","per_page","getSettings","setIsInserterOpen","settings","outlineMode","focusMode","hasFixedToolbar","__experimentalSetIsInserterOpened","__experimentalReusableBlocks","canUserCreateMedia","mediaUpload","onError","rest","wpAllowedMimeTypes","allowedMimeTypes","message","getHomeTemplateId","homeTemplateId","getCurrentEditedPost","editedPost","getEditedPostType","type","getEditedPostId","id","getPage","page","getNavigationPanelActiveMenu","navigationPanel","menu","getCurrentTemplateNavigationPanelSubMenu","templateType","templateId","template","getEntityRecord","find","submenu","area","templates","showOnFront","getEditedEntityRecord","show_on_front","slug","isNavigationOpened","isOpen","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","isListViewOpened","listViewPanel","getCurrentTemplateTemplateParts","templateParts","templatePartsById","templatePart","blocks","filter","block","attributes","theme","templatePartId"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,GAAd,EAAmBC,KAAnB,QAAgC,QAAhC;AACA,OAAOC,cAAP,MAA2B,QAA3B;AAEA;AACA;AACA;;AACA,SAASC,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*/\nimport { get, map, keyBy } from 'lodash';\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { isTemplatePart } from '@wordpress/blocks';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tMENU_ROOT,\n\tMENU_TEMPLATE_PARTS,\n\tMENU_TEMPLATES_UNUSED,\n\tTEMPLATE_PARTS_SUB_MENUS,\n} from '../components/navigation-sidebar/navigation-panel/constants';\nimport {\n\tgetTemplateLocation,\n\tisTemplateSuperseded,\n} from '../components/navigation-sidebar/navigation-panel/template-hierarchy';\n\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @param {Object} state Global application state.\n * @param {string} feature Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function isFeatureActive( state, feature ) {\n\treturn get( state.preferences.features, [ feature ], false );\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns whether the current user can create media or not.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Whether the current user can create media or not.\n */\nexport const getCanUserCreateMedia = createRegistrySelector( ( select ) => () =>\n\tselect( coreDataStore ).canUser( 'create', 'media' )\n);\n\n/**\n * Returns any available Reusable blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} The available reusable blocks.\n */\nexport const getReusableBlocks = createRegistrySelector( ( select ) => () => {\n\tconst isWeb = Platform.OS === 'web';\n\treturn isWeb\n\t\t? select( coreDataStore ).getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\tper_page: -1,\n\t\t } )\n\t\t: [];\n} );\n\n/**\n * Returns the settings, taking into account active features and permissions.\n *\n * @param {Object} state Global application state.\n * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.\n *\n * @return {Object} Settings.\n */\nexport const getSettings = createSelector(\n\t( state, setIsInserterOpen ) => {\n\t\tconst settings = {\n\t\t\t...state.settings,\n\t\t\toutlineMode: true,\n\t\t\tfocusMode: isFeatureActive( state, 'focusMode' ),\n\t\t\thasFixedToolbar: isFeatureActive( state, 'fixedToolbar' ),\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpen,\n\t\t\t__experimentalReusableBlocks: getReusableBlocks( state ),\n\t\t};\n\n\t\tconst canUserCreateMedia = getCanUserCreateMedia( state );\n\t\tif ( ! canUserCreateMedia ) {\n\t\t\treturn settings;\n\t\t}\n\n\t\tsettings.mediaUpload = ( { onError, ...rest } ) => {\n\t\t\tuploadMedia( {\n\t\t\t\twpAllowedMimeTypes: state.settings.allowedMimeTypes,\n\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t};\n\t\treturn settings;\n\t},\n\t( state ) => [\n\t\tgetCanUserCreateMedia( state ),\n\t\tstate.settings,\n\t\tisFeatureActive( state, 'focusMode' ),\n\t\tisFeatureActive( state, 'fixedToolbar' ),\n\t\tgetReusableBlocks( state ),\n\t]\n);\n\n/**\n * Returns the current home template ID.\n *\n * @param {Object} state Global application state.\n *\n * @return {number?} Home template ID.\n */\nexport function getHomeTemplateId( state ) {\n\treturn state.homeTemplateId;\n}\n\nfunction getCurrentEditedPost( state ) {\n\treturn state.editedPost;\n}\n\n/**\n * Returns the current edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getEditedPostType( state ) {\n\treturn getCurrentEditedPost( state ).type;\n}\n\n/**\n * Returns the ID of the currently edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getEditedPostId( state ) {\n\treturn getCurrentEditedPost( state ).id;\n}\n\n/**\n * Returns the current page object.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn getCurrentEditedPost( state ).page;\n}\n\n/**\n * Returns the active menu in the navigation panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Active menu.\n */\nexport function getNavigationPanelActiveMenu( state ) {\n\treturn state.navigationPanel.menu;\n}\n\n/**\n * Returns the current template or template part's corresponding\n * navigation panel's sub menu, to be used with `openNavigationPanelToMenu`.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} The current template or template part's sub menu.\n */\nexport const getCurrentTemplateNavigationPanelSubMenu = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = templateId\n\t\t\t? select( coreDataStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplateType,\n\t\t\t\t\ttemplateId\n\t\t\t )\n\t\t\t: null;\n\n\t\tif ( ! template ) {\n\t\t\treturn MENU_ROOT;\n\t\t}\n\n\t\tif ( 'wp_template_part' === templateType ) {\n\t\t\treturn (\n\t\t\t\tTEMPLATE_PARTS_SUB_MENUS.find(\n\t\t\t\t\t( submenu ) => submenu.area === template?.area\n\t\t\t\t)?.menu || MENU_TEMPLATE_PARTS\n\t\t\t);\n\t\t}\n\n\t\tconst templates = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template'\n\t\t);\n\t\tconst showOnFront = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'root',\n\t\t\t'site'\n\t\t).show_on_front;\n\n\t\tif (\n\t\t\tisTemplateSuperseded(\n\t\t\t\ttemplate.slug,\n\t\t\t\tmap( templates, 'slug' ),\n\t\t\t\tshowOnFront\n\t\t\t)\n\t\t) {\n\t\t\treturn MENU_TEMPLATES_UNUSED;\n\t\t}\n\n\t\treturn getTemplateLocation( template.slug );\n\t}\n);\n\n/**\n * Returns the current opened/closed state of the navigation panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the navigation panel should be open; false if closed.\n */\nexport function isNavigationOpened( state ) {\n\treturn state.navigationPanel.isOpen;\n}\n\n/**\n * Returns the current opened/closed state of the inserter panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the inserter panel should be open; false if closed.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst {\n\t\trootClientId,\n\t\tinsertionIndex,\n\t\tfilterValue,\n\t} = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex, filterValue };\n}\n\n/**\n * Returns the current opened/closed state of the list view panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the list view panel should be open; false if closed.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns the template parts and their blocks for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Array} Template parts and their blocks in an array.\n */\nexport const getCurrentTemplateTemplateParts = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplateType,\n\t\t\ttemplateId\n\t\t);\n\n\t\tconst templateParts = select(\n\t\t\tcoreDataStore\n\t\t).getEntityRecords( 'postType', 'wp_template_part', { per_page: -1 } );\n\t\tconst templatePartsById = keyBy(\n\t\t\ttemplateParts,\n\t\t\t( templatePart ) => templatePart.id\n\t\t);\n\n\t\treturn ( template.blocks ?? [] )\n\t\t\t.filter( ( block ) => isTemplatePart( block ) )\n\t\t\t.map( ( block ) => {\n\t\t\t\tconst {\n\t\t\t\t\tattributes: { theme, slug },\n\t\t\t\t} = block;\n\t\t\t\tconst templatePartId = `${ theme }//${ slug }`;\n\t\t\t\tconst templatePart = templatePartsById[ templatePartId ];\n\n\t\t\t\treturn {\n\t\t\t\t\ttemplatePart,\n\t\t\t\t\tblock,\n\t\t\t\t};\n\t\t\t} )\n\t\t\t.filter( ( { templatePart } ) => !! templatePart );\n\t}\n);\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns if the params match the list page route.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} params The search params.
|
|
5
|
+
* @param {string} params.postId The post ID.
|
|
6
|
+
* @param {string} params.postType The post type.
|
|
7
|
+
* @return {boolean} Is list page or not.
|
|
8
|
+
*/
|
|
9
|
+
export default function getIsListPage(_ref) {
|
|
10
|
+
let {
|
|
11
|
+
postId,
|
|
12
|
+
postType
|
|
13
|
+
} = _ref;
|
|
14
|
+
return !!(!postId && postType);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=get-is-list-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/utils/get-is-list-page.js"],"names":["getIsListPage","postId","postType"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,aAAT,OAA+C;AAAA,MAAvB;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAuB;AAC7D,SAAO,CAAC,EAAI,CAAED,MAAF,IAAYC,QAAhB,CAAR;AACA","sourcesContent":["/**\n * Returns if the params match the list page route.\n *\n * @param {Object} params The search params.\n * @param {string} params.postId The post ID.\n * @param {string} params.postType The post type.\n * @return {boolean} Is list page or not.\n */\nexport default function getIsListPage( { postId, postType } ) {\n\treturn !! ( ! postId && postType );\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { createBrowserHistory } from 'history';
|
|
5
|
+
/**
|
|
6
|
+
* WordPress dependencies
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
10
|
+
const history = createBrowserHistory();
|
|
11
|
+
const originalHistoryPush = history.push;
|
|
12
|
+
const originalHistoryReplace = history.replace;
|
|
13
|
+
|
|
14
|
+
function push(params, state) {
|
|
15
|
+
return originalHistoryPush.call(history, addQueryArgs(window.location.href, params), state);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function replace(params, state) {
|
|
19
|
+
return originalHistoryReplace.call(history, addQueryArgs(window.location.href, params), state);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
history.push = push;
|
|
23
|
+
history.replace = replace;
|
|
24
|
+
export default history;
|
|
25
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/utils/history.js"],"names":["createBrowserHistory","addQueryArgs","history","originalHistoryPush","push","originalHistoryReplace","replace","params","state","call","window","location","href"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,oBAAT,QAAqC,SAArC;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA,MAAMC,OAAO,GAAGF,oBAAoB,EAApC;AAEA,MAAMG,mBAAmB,GAAGD,OAAO,CAACE,IAApC;AACA,MAAMC,sBAAsB,GAAGH,OAAO,CAACI,OAAvC;;AAEA,SAASF,IAAT,CAAeG,MAAf,EAAuBC,KAAvB,EAA+B;AAC9B,SAAOL,mBAAmB,CAACM,IAApB,CACNP,OADM,EAEND,YAAY,CAAES,MAAM,CAACC,QAAP,CAAgBC,IAAlB,EAAwBL,MAAxB,CAFN,EAGNC,KAHM,CAAP;AAKA;;AAED,SAASF,OAAT,CAAkBC,MAAlB,EAA0BC,KAA1B,EAAkC;AACjC,SAAOH,sBAAsB,CAACI,IAAvB,CACNP,OADM,EAEND,YAAY,CAAES,MAAM,CAACC,QAAP,CAAgBC,IAAlB,EAAwBL,MAAxB,CAFN,EAGNC,KAHM,CAAP;AAKA;;AAEDN,OAAO,CAACE,IAAR,GAAeA,IAAf;AACAF,OAAO,CAACI,OAAR,GAAkBA,OAAlB;AAEA,eAAeJ,OAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { createBrowserHistory } from 'history';\n\n/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\n\nconst history = createBrowserHistory();\n\nconst originalHistoryPush = history.push;\nconst originalHistoryReplace = history.replace;\n\nfunction push( params, state ) {\n\treturn originalHistoryPush.call(\n\t\thistory,\n\t\taddQueryArgs( window.location.href, params ),\n\t\tstate\n\t);\n}\n\nfunction replace( params, state ) {\n\treturn originalHistoryReplace.call(\n\t\thistory,\n\t\taddQueryArgs( window.location.href, params ),\n\t\tstate\n\t);\n}\n\nhistory.push = push;\nhistory.replace = replace;\n\nexport default history;\n"]}
|
|
@@ -1122,16 +1122,11 @@ body.is-fullscreen-mode .edit-site-list-header {
|
|
|
1122
1122
|
}
|
|
1123
1123
|
.edit-site .edit-site-list .interface-interface-skeleton__content {
|
|
1124
1124
|
background: #fff;
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
.edit-site-list-main {
|
|
1128
|
-
display: flex;
|
|
1129
1125
|
align-items: center;
|
|
1130
|
-
justify-content: center;
|
|
1131
1126
|
padding: 16px;
|
|
1132
1127
|
}
|
|
1133
1128
|
@media (min-width: 782px) {
|
|
1134
|
-
.edit-site-list-
|
|
1129
|
+
.edit-site .edit-site-list .interface-interface-skeleton__content {
|
|
1135
1130
|
padding: 72px;
|
|
1136
1131
|
}
|
|
1137
1132
|
}
|
package/build-style/style.css
CHANGED
|
@@ -1122,16 +1122,11 @@ body.is-fullscreen-mode .edit-site-list-header {
|
|
|
1122
1122
|
}
|
|
1123
1123
|
.edit-site .edit-site-list .interface-interface-skeleton__content {
|
|
1124
1124
|
background: #fff;
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
.edit-site-list-main {
|
|
1128
|
-
display: flex;
|
|
1129
1125
|
align-items: center;
|
|
1130
|
-
justify-content: center;
|
|
1131
1126
|
padding: 16px;
|
|
1132
1127
|
}
|
|
1133
1128
|
@media (min-width: 782px) {
|
|
1134
|
-
.edit-site-list-
|
|
1129
|
+
.edit-site .edit-site-list .interface-interface-skeleton__content {
|
|
1135
1130
|
padding: 72px;
|
|
1136
1131
|
}
|
|
1137
1132
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-site",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.16",
|
|
4
4
|
"description": "Edit Site Page module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -29,33 +29,34 @@
|
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
30
|
"@wordpress/a11y": "^3.2.4",
|
|
31
31
|
"@wordpress/api-fetch": "^5.2.6",
|
|
32
|
-
"@wordpress/block-editor": "^8.0.
|
|
33
|
-
"@wordpress/block-library": "^6.0.
|
|
32
|
+
"@wordpress/block-editor": "^8.0.10",
|
|
33
|
+
"@wordpress/block-library": "^6.0.14",
|
|
34
34
|
"@wordpress/blocks": "^11.1.4",
|
|
35
|
-
"@wordpress/components": "^19.1.
|
|
35
|
+
"@wordpress/components": "^19.1.4",
|
|
36
36
|
"@wordpress/compose": "^5.0.6",
|
|
37
37
|
"@wordpress/core-data": "^4.0.8",
|
|
38
38
|
"@wordpress/data": "^6.1.4",
|
|
39
39
|
"@wordpress/data-controls": "^2.2.7",
|
|
40
|
-
"@wordpress/editor": "^12.0.
|
|
40
|
+
"@wordpress/editor": "^12.0.13",
|
|
41
41
|
"@wordpress/element": "^4.0.4",
|
|
42
42
|
"@wordpress/hooks": "^3.2.2",
|
|
43
43
|
"@wordpress/html-entities": "^3.2.3",
|
|
44
44
|
"@wordpress/i18n": "^4.2.4",
|
|
45
45
|
"@wordpress/icons": "^6.1.1",
|
|
46
|
-
"@wordpress/interface": "^4.1.
|
|
46
|
+
"@wordpress/interface": "^4.1.12",
|
|
47
47
|
"@wordpress/keyboard-shortcuts": "^3.0.6",
|
|
48
48
|
"@wordpress/keycodes": "^3.2.4",
|
|
49
49
|
"@wordpress/media-utils": "^3.0.5",
|
|
50
50
|
"@wordpress/notices": "^3.2.7",
|
|
51
51
|
"@wordpress/plugins": "^4.0.6",
|
|
52
52
|
"@wordpress/primitives": "^3.0.4",
|
|
53
|
-
"@wordpress/reusable-blocks": "^3.0.
|
|
53
|
+
"@wordpress/reusable-blocks": "^3.0.16",
|
|
54
54
|
"@wordpress/url": "^3.3.1",
|
|
55
55
|
"@wordpress/viewport": "^4.0.6",
|
|
56
56
|
"classnames": "^2.3.1",
|
|
57
57
|
"downloadjs": "^1.4.7",
|
|
58
58
|
"file-saver": "^2.0.2",
|
|
59
|
+
"history": "^5.1.0",
|
|
59
60
|
"jszip": "^3.2.2",
|
|
60
61
|
"lodash": "^4.17.21",
|
|
61
62
|
"rememo": "^3.0.0"
|
|
@@ -63,5 +64,5 @@
|
|
|
63
64
|
"publishConfig": {
|
|
64
65
|
"access": "public"
|
|
65
66
|
},
|
|
66
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "3826b68f8c5b5026b318463af647f6fb19b534d2"
|
|
67
68
|
}
|
|
@@ -7,21 +7,24 @@ import { kebabCase } from 'lodash';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useState } from '@wordpress/element';
|
|
10
|
-
import { useDispatch } from '@wordpress/data';
|
|
10
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
11
11
|
import { Button } from '@wordpress/components';
|
|
12
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
13
|
-
import apiFetch from '@wordpress/api-fetch';
|
|
14
12
|
import { __ } from '@wordpress/i18n';
|
|
15
13
|
import { store as noticesStore } from '@wordpress/notices';
|
|
14
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* Internal dependencies
|
|
19
18
|
*/
|
|
19
|
+
import { useHistory } from '../routes';
|
|
20
20
|
import CreateTemplatePartModal from '../create-template-part-modal';
|
|
21
21
|
|
|
22
22
|
export default function NewTemplatePart( { postType } ) {
|
|
23
|
+
const history = useHistory();
|
|
23
24
|
const [ isModalOpen, setIsModalOpen ] = useState( false );
|
|
24
25
|
const { createErrorNotice } = useDispatch( noticesStore );
|
|
26
|
+
const { saveEntityRecord } = useDispatch( coreStore );
|
|
27
|
+
const { getLastEntitySaveError } = useSelect( coreStore );
|
|
25
28
|
|
|
26
29
|
async function createTemplatePart( { title, area } ) {
|
|
27
30
|
if ( ! title ) {
|
|
@@ -32,22 +35,35 @@ export default function NewTemplatePart( { postType } ) {
|
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
try {
|
|
35
|
-
const templatePart = await
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
const templatePart = await saveEntityRecord(
|
|
39
|
+
'postType',
|
|
40
|
+
'wp_template_part',
|
|
41
|
+
{
|
|
39
42
|
slug: kebabCase( title ),
|
|
40
43
|
title,
|
|
41
44
|
content: '',
|
|
42
45
|
area,
|
|
43
|
-
}
|
|
44
|
-
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const lastEntitySaveError = getLastEntitySaveError(
|
|
50
|
+
'postType',
|
|
51
|
+
'wp_template_part',
|
|
52
|
+
templatePart.id
|
|
53
|
+
);
|
|
54
|
+
if ( lastEntitySaveError ) {
|
|
55
|
+
throw lastEntitySaveError;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setIsModalOpen( false );
|
|
45
59
|
|
|
46
60
|
// Navigate to the created template part editor.
|
|
47
|
-
|
|
61
|
+
history.push( {
|
|
48
62
|
postId: templatePart.id,
|
|
49
|
-
postType:
|
|
63
|
+
postType: templatePart.type,
|
|
50
64
|
} );
|
|
65
|
+
|
|
66
|
+
// TODO: Add a success notice?
|
|
51
67
|
} catch ( error ) {
|
|
52
68
|
const errorMessage =
|
|
53
69
|
error.message && error.code !== 'unknown_error'
|
|
@@ -57,6 +73,8 @@ export default function NewTemplatePart( { postType } ) {
|
|
|
57
73
|
);
|
|
58
74
|
|
|
59
75
|
createErrorNotice( errorMessage, { type: 'snackbar' } );
|
|
76
|
+
|
|
77
|
+
setIsModalOpen( false );
|
|
60
78
|
}
|
|
61
79
|
}
|
|
62
80
|
|
|
@@ -15,11 +15,14 @@ import {
|
|
|
15
15
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
16
16
|
import { store as coreStore } from '@wordpress/core-data';
|
|
17
17
|
import { store as editorStore } from '@wordpress/editor';
|
|
18
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
19
|
-
import apiFetch from '@wordpress/api-fetch';
|
|
20
18
|
import { __ } from '@wordpress/i18n';
|
|
21
19
|
import { store as noticesStore } from '@wordpress/notices';
|
|
22
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Internal dependencies
|
|
23
|
+
*/
|
|
24
|
+
import { useHistory } from '../routes';
|
|
25
|
+
|
|
23
26
|
const DEFAULT_TEMPLATE_SLUGS = [
|
|
24
27
|
'front-page',
|
|
25
28
|
'single-post',
|
|
@@ -31,6 +34,7 @@ const DEFAULT_TEMPLATE_SLUGS = [
|
|
|
31
34
|
];
|
|
32
35
|
|
|
33
36
|
export default function NewTemplate( { postType } ) {
|
|
37
|
+
const history = useHistory();
|
|
34
38
|
const { templates, defaultTemplateTypes } = useSelect(
|
|
35
39
|
( select ) => ( {
|
|
36
40
|
templates: select( coreStore ).getEntityRecords(
|
|
@@ -44,7 +48,9 @@ export default function NewTemplate( { postType } ) {
|
|
|
44
48
|
} ),
|
|
45
49
|
[]
|
|
46
50
|
);
|
|
51
|
+
const { saveEntityRecord } = useDispatch( coreStore );
|
|
47
52
|
const { createErrorNotice } = useDispatch( noticesStore );
|
|
53
|
+
const { getLastEntitySaveError } = useSelect( coreStore );
|
|
48
54
|
|
|
49
55
|
async function createTemplate( { slug } ) {
|
|
50
56
|
try {
|
|
@@ -52,26 +58,34 @@ export default function NewTemplate( { postType } ) {
|
|
|
52
58
|
slug,
|
|
53
59
|
} );
|
|
54
60
|
|
|
55
|
-
const template = await
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
const template = await saveEntityRecord(
|
|
62
|
+
'postType',
|
|
63
|
+
'wp_template',
|
|
64
|
+
{
|
|
59
65
|
excerpt: description,
|
|
60
66
|
// Slugs need to be strings, so this is for template `404`
|
|
61
67
|
slug: slug.toString(),
|
|
62
68
|
status: 'publish',
|
|
63
69
|
title,
|
|
64
|
-
}
|
|
65
|
-
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const lastEntitySaveError = getLastEntitySaveError(
|
|
74
|
+
'postType',
|
|
75
|
+
'wp_template',
|
|
76
|
+
template.id
|
|
77
|
+
);
|
|
78
|
+
if ( lastEntitySaveError ) {
|
|
79
|
+
throw lastEntitySaveError;
|
|
80
|
+
}
|
|
66
81
|
|
|
67
82
|
// Navigate to the created template editor.
|
|
68
|
-
|
|
83
|
+
history.push( {
|
|
69
84
|
postId: template.id,
|
|
70
|
-
postType:
|
|
85
|
+
postType: template.type,
|
|
71
86
|
} );
|
|
72
87
|
|
|
73
|
-
//
|
|
74
|
-
await new Promise( () => {} );
|
|
88
|
+
// TODO: Add a success notice?
|
|
75
89
|
} catch ( error ) {
|
|
76
90
|
const errorMessage =
|
|
77
91
|
error.message && error.code !== 'unknown_error'
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { SlotFillProvider } from '@wordpress/components';
|
|
5
|
+
import { UnsavedChangesWarning } from '@wordpress/editor';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { Routes } from '../routes';
|
|
11
|
+
import Editor from '../editor';
|
|
12
|
+
import List from '../list';
|
|
13
|
+
import NavigationSidebar from '../navigation-sidebar';
|
|
14
|
+
import getIsListPage from '../../utils/get-is-list-page';
|
|
15
|
+
|
|
16
|
+
export default function EditSiteApp( { reboot } ) {
|
|
17
|
+
return (
|
|
18
|
+
<SlotFillProvider>
|
|
19
|
+
<UnsavedChangesWarning />
|
|
20
|
+
|
|
21
|
+
<Routes>
|
|
22
|
+
{ ( { params } ) => {
|
|
23
|
+
const isListPage = getIsListPage( params );
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
{ isListPage ? (
|
|
28
|
+
<List />
|
|
29
|
+
) : (
|
|
30
|
+
<Editor onError={ reboot } />
|
|
31
|
+
) }
|
|
32
|
+
{ /* Keep the instance of the sidebar to ensure focus will not be lost
|
|
33
|
+
* when navigating to other pages. */ }
|
|
34
|
+
<NavigationSidebar
|
|
35
|
+
// Open the navigation sidebar by default when in the list page.
|
|
36
|
+
isDefaultOpen={ !! isListPage }
|
|
37
|
+
activeTemplateType={
|
|
38
|
+
isListPage ? params.postType : undefined
|
|
39
|
+
}
|
|
40
|
+
/>
|
|
41
|
+
</>
|
|
42
|
+
);
|
|
43
|
+
} }
|
|
44
|
+
</Routes>
|
|
45
|
+
</SlotFillProvider>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
@@ -3,26 +3,18 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Button } from '@wordpress/components';
|
|
5
5
|
import { arrowLeft } from '@wordpress/icons';
|
|
6
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
6
|
import { __ } from '@wordpress/i18n';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Internal dependencies
|
|
11
10
|
*/
|
|
12
|
-
import {
|
|
11
|
+
import { useLocation, useHistory } from '../routes';
|
|
13
12
|
|
|
14
13
|
function BackButton() {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
isTemplatePart: getEditedPostType() === 'wp_template_part',
|
|
22
|
-
previousTemplateId: getPreviousEditedPostId(),
|
|
23
|
-
};
|
|
24
|
-
}, [] );
|
|
25
|
-
const { goBack } = useDispatch( editSiteStore );
|
|
14
|
+
const location = useLocation();
|
|
15
|
+
const history = useHistory();
|
|
16
|
+
const isTemplatePart = location.params.postType === 'wp_template_part';
|
|
17
|
+
const previousTemplateId = location.state?.fromTemplateId;
|
|
26
18
|
|
|
27
19
|
if ( ! isTemplatePart || ! previousTemplateId ) {
|
|
28
20
|
return null;
|
|
@@ -33,7 +25,7 @@ function BackButton() {
|
|
|
33
25
|
className="edit-site-visual-editor__back-button"
|
|
34
26
|
icon={ arrowLeft }
|
|
35
27
|
onClick={ () => {
|
|
36
|
-
|
|
28
|
+
history.back();
|
|
37
29
|
} }
|
|
38
30
|
>
|
|
39
31
|
{ __( 'Back' ) }
|
|
@@ -124,6 +124,7 @@ export default function BlockEditor( { setIsInserterOpen } ) {
|
|
|
124
124
|
<BlockList
|
|
125
125
|
className="edit-site-block-editor__block-list wp-site-blocks"
|
|
126
126
|
__experimentalLayout={ LAYOUT }
|
|
127
|
+
renderAppender={ isTemplatePart ? false : undefined }
|
|
127
128
|
/>
|
|
128
129
|
</ResizableEditor>
|
|
129
130
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useSelect
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
5
|
import {
|
|
6
6
|
store as blockEditorStore,
|
|
7
7
|
BlockSettingsMenuControls,
|
|
@@ -14,7 +14,8 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
|
-
import {
|
|
17
|
+
import { useLocation } from '../routes';
|
|
18
|
+
import { useLink } from '../routes/link';
|
|
18
19
|
|
|
19
20
|
export default function EditTemplatePartMenuButton() {
|
|
20
21
|
return (
|
|
@@ -30,6 +31,7 @@ export default function EditTemplatePartMenuButton() {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
function EditTemplatePartMenuItem( { selectedClientId, onClose } ) {
|
|
34
|
+
const { params } = useLocation();
|
|
33
35
|
const selectedTemplatePart = useSelect(
|
|
34
36
|
( select ) => {
|
|
35
37
|
const block = select( blockEditorStore ).getBlock(
|
|
@@ -50,7 +52,15 @@ function EditTemplatePartMenuItem( { selectedClientId, onClose } ) {
|
|
|
50
52
|
[ selectedClientId ]
|
|
51
53
|
);
|
|
52
54
|
|
|
53
|
-
const
|
|
55
|
+
const linkProps = useLink(
|
|
56
|
+
{
|
|
57
|
+
postId: selectedTemplatePart?.id,
|
|
58
|
+
postType: selectedTemplatePart?.type,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
fromTemplateId: params.postId,
|
|
62
|
+
}
|
|
63
|
+
);
|
|
54
64
|
|
|
55
65
|
if ( ! selectedTemplatePart ) {
|
|
56
66
|
return null;
|
|
@@ -58,8 +68,9 @@ function EditTemplatePartMenuItem( { selectedClientId, onClose } ) {
|
|
|
58
68
|
|
|
59
69
|
return (
|
|
60
70
|
<MenuItem
|
|
61
|
-
|
|
62
|
-
|
|
71
|
+
{ ...linkProps }
|
|
72
|
+
onClick={ ( event ) => {
|
|
73
|
+
linkProps.onClick( event );
|
|
63
74
|
onClose();
|
|
64
75
|
} }
|
|
65
76
|
>
|