@wordpress/edit-site 3.0.9 → 3.0.10
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/index.js +49 -0
- package/build/components/add-new-template/index.js.map +1 -0
- package/build/components/add-new-template/new-template-part.js +79 -0
- package/build/components/add-new-template/new-template-part.js.map +1 -0
- package/build/components/add-new-template/new-template.js +115 -0
- package/build/components/add-new-template/new-template.js.map +1 -0
- package/build/components/create-template-part-modal/index.js +115 -0
- package/build/components/create-template-part-modal/index.js.map +1 -0
- package/build/components/editor/index.js +11 -13
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +4 -4
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/hooks.js +27 -25
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +9 -1
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +2 -2
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +1 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header/index.js +1 -5
- package/build/components/header/index.js.map +1 -1
- package/build/components/list/header.js +50 -0
- package/build/components/list/header.js.map +1 -0
- package/build/components/list/index.js +55 -0
- package/build/components/list/index.js.map +1 -0
- package/build/components/list/table.js +128 -0
- package/build/components/list/table.js.map +1 -0
- package/build/components/navigation-sidebar/index.js +11 -10
- package/build/components/navigation-sidebar/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +33 -53
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-toggle/index.js +3 -24
- package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build/components/template-details/index.js +3 -2
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +20 -84
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/components/welcome-guide/editor.js +58 -0
- package/build/components/welcome-guide/editor.js.map +1 -0
- package/build/components/welcome-guide/image.js +27 -0
- package/build/components/welcome-guide/image.js.map +1 -0
- package/build/components/welcome-guide/index.js +49 -0
- package/build/components/welcome-guide/index.js.map +1 -0
- package/build/components/welcome-guide/styles.js +83 -0
- package/build/components/welcome-guide/styles.js.map +1 -0
- package/build/index.js +29 -5
- package/build/index.js.map +1 -1
- package/build/plugins/index.js +4 -2
- package/build/plugins/index.js.map +1 -1
- package/build/plugins/welcome-guide-menu-item.js +39 -0
- package/build/plugins/welcome-guide-menu-item.js.map +1 -0
- package/build/store/actions.js +5 -8
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +4 -1
- package/build/store/defaults.js.map +1 -1
- package/build/utils/is-template-removable.js +21 -0
- package/build/utils/is-template-removable.js.map +1 -0
- package/build-module/components/add-new-template/index.js +36 -0
- package/build-module/components/add-new-template/index.js.map +1 -0
- package/build-module/components/add-new-template/new-template-part.js +66 -0
- package/build-module/components/add-new-template/new-template-part.js.map +1 -0
- package/build-module/components/add-new-template/new-template.js +98 -0
- package/build-module/components/add-new-template/new-template.js.map +1 -0
- package/build-module/components/create-template-part-modal/index.js +102 -0
- package/build-module/components/create-template-part-modal/index.js.map +1 -0
- package/build-module/components/editor/index.js +9 -13
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +4 -4
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +28 -26
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +7 -1
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +2 -2
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +1 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header/index.js +1 -3
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/list/header.js +37 -0
- package/build-module/components/list/header.js.map +1 -0
- package/build-module/components/list/index.js +40 -0
- package/build-module/components/list/index.js.map +1 -0
- package/build-module/components/list/table.js +112 -0
- package/build-module/components/list/table.js.map +1 -0
- package/build-module/components/navigation-sidebar/index.js +12 -8
- package/build-module/components/navigation-sidebar/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +35 -53
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js +4 -24
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build-module/components/template-details/index.js +3 -2
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +20 -84
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/components/welcome-guide/editor.js +45 -0
- package/build-module/components/welcome-guide/editor.js.map +1 -0
- package/build-module/components/welcome-guide/image.js +19 -0
- package/build-module/components/welcome-guide/image.js.map +1 -0
- package/build-module/components/welcome-guide/index.js +35 -0
- package/build-module/components/welcome-guide/index.js.map +1 -0
- package/build-module/components/welcome-guide/styles.js +69 -0
- package/build-module/components/welcome-guide/styles.js.map +1 -0
- package/build-module/index.js +21 -1
- package/build-module/index.js.map +1 -1
- package/build-module/plugins/index.js +3 -2
- package/build-module/plugins/index.js.map +1 -1
- package/build-module/plugins/welcome-guide-menu-item.js +27 -0
- package/build-module/plugins/welcome-guide-menu-item.js.map +1 -0
- package/build-module/store/actions.js +5 -8
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +4 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/utils/is-template-removable.js +14 -0
- package/build-module/utils/is-template-removable.js.map +1 -0
- package/build-style/style-rtl.css +348 -32
- package/build-style/style.css +348 -32
- package/package.json +7 -7
- package/src/components/add-new-template/index.js +30 -0
- package/src/components/add-new-template/new-template-part.js +67 -0
- package/src/components/add-new-template/new-template.js +117 -0
- package/src/components/add-new-template/style.scss +11 -0
- package/src/components/create-template-part-modal/index.js +132 -0
- package/src/components/{template-part-converter → create-template-part-modal}/style.scss +9 -9
- package/src/components/editor/index.js +10 -14
- package/src/components/editor/style.scss +8 -0
- package/src/components/global-styles/global-styles-provider.js +4 -3
- package/src/components/global-styles/hooks.js +58 -26
- package/src/components/global-styles/screen-block-list.js +11 -1
- package/src/components/global-styles/test/use-global-styles-output.js +2 -2
- package/src/components/global-styles/use-global-styles-output.js +2 -2
- package/src/components/global-styles/utils.js +1 -1
- package/src/components/header/index.js +0 -6
- package/src/components/list/header.js +34 -0
- package/src/components/list/index.js +38 -0
- package/src/components/list/style.scss +113 -0
- package/src/components/list/table.js +133 -0
- package/src/components/navigation-sidebar/index.js +15 -8
- package/src/components/navigation-sidebar/navigation-panel/index.js +44 -55
- package/src/components/navigation-sidebar/navigation-panel/style.scss +4 -2
- package/src/components/navigation-sidebar/navigation-toggle/index.js +4 -28
- package/src/components/template-details/index.js +3 -2
- package/src/components/template-part-converter/convert-to-template-part.js +20 -140
- package/src/components/welcome-guide/editor.js +63 -0
- package/src/components/welcome-guide/image.js +11 -0
- package/src/components/welcome-guide/index.js +33 -0
- package/src/components/welcome-guide/style.scss +37 -0
- package/src/components/welcome-guide/styles.js +116 -0
- package/src/index.js +21 -1
- package/src/plugins/index.js +3 -1
- package/src/plugins/welcome-guide-menu-item.js +35 -0
- package/src/store/actions.js +11 -9
- package/src/store/defaults.js +4 -1
- package/src/store/test/actions.js +14 -20
- package/src/style.scss +9 -6
- package/src/utils/is-template-removable.js +13 -0
- package/build/components/header/navigation-link/index.js +0 -87
- package/build/components/header/navigation-link/index.js.map +0 -1
- package/build-module/components/header/navigation-link/index.js +0 -74
- package/build-module/components/header/navigation-link/index.js.map +0 -1
- package/src/components/header/navigation-link/index.js +0 -71
- package/src/components/header/navigation-link/style.scss +0 -69
package/build/store/actions.js
CHANGED
|
@@ -140,19 +140,16 @@ function* addTemplate(template) {
|
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
|
-
* Removes a template
|
|
143
|
+
* Removes a template.
|
|
144
144
|
*
|
|
145
|
-
* @param {
|
|
145
|
+
* @param {Object} template The template object.
|
|
146
146
|
*/
|
|
147
147
|
|
|
148
148
|
|
|
149
|
-
function* removeTemplate(
|
|
150
|
-
yield (
|
|
151
|
-
|
|
152
|
-
method: 'DELETE'
|
|
149
|
+
function* removeTemplate(template) {
|
|
150
|
+
yield _data.controls.dispatch(_coreData.store, 'deleteEntityRecord', 'postType', template.type, template.id, {
|
|
151
|
+
force: true
|
|
153
152
|
});
|
|
154
|
-
const page = yield _data.controls.select(_constants.STORE_NAME, 'getPage');
|
|
155
|
-
yield _data.controls.dispatch(_constants.STORE_NAME, 'setPage', page);
|
|
156
153
|
}
|
|
157
154
|
/**
|
|
158
155
|
* Returns an action object used to set a template part.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/actions.js"],"names":["toggleFeature","feature","type","__experimentalSetPreviewDeviceType","deviceType","setTemplate","templateId","templateSlug","pageContext","template","controls","resolveSelect","coreStore","slug","page","context","addTemplate","newTemplate","dispatch","content","id","blocks","undoIgnore","removeTemplate","path","method","select","editSiteStoreName","setTemplatePart","templatePartId","pushTemplatePart","setHomeTemplateId","homeTemplateId","setPage","postId","entity","postType","link","goBack","showHomepage","show_on_front","showOnFront","page_on_front","frontpageId","siteUrl","homeTemplate","setNavigationPanelActiveMenu","menu","openNavigationPanelToMenu","setIsNavigationPanelOpened","isOpen","setIsInserterOpened","value","updateSettings","settings","setIsListViewOpened","revertTemplate","noticesStore","templateEntity","fileTemplatePath","baseURL","source","fileTemplate","serializeBlocks","blocksForSerialization","edited","raw","undoRevert","editEntityRecord","actions","label","onClick","error","errorMessage","message","code","openGeneralSidebar","name","interfaceStore","closeGeneralSidebar"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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mE,MAAAA,OAAO,EAAE,CACR;AACCC,QAAAA,KAAK,EAAE,cAAI,MAAJ,CADR;AAECC,QAAAA,OAAO,EAAEJ;AAFV,OADQ;AAFV,KAJK,CAAN;AAcA,GAvGD,CAuGE,OAAQK,KAAR,EAAgB;AACjB,UAAMC,YAAY,GACjBD,KAAK,CAACE,OAAN,IAAiBF,KAAK,CAACG,IAAN,KAAe,eAAhC,GACGH,KAAK,CAACE,OADT,GAEG,cAAI,wCAAJ,CAHJ;AAIA,UAAMhE,eAASQ,QAAT,CACLuC,cADK,EAEL,mBAFK,EAGLgB,YAHK,EAIL;AAAEvE,MAAAA,IAAI,EAAE;AAAR,KAJK,CAAN;AAMA;AACD;AACD;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,UAAU0E,kBAAV,CAA8BC,IAA9B,EAAqC;AAC3C,QAAMnE,eAASQ,QAAT,CACL4D,gBADK,EAEL,yBAFK,EAGLnD,qBAHK,EAILkD,IAJK,CAAN;AAMA;AAED;AACA;AACA;AACA;AACA;;;AACO,UAAUE,mBAAV,GAAgC;AACtC,QAAMrE,eAASQ,QAAT,CACL4D,gBADK,EAEL,0BAFK,EAGLnD,qBAHK,CAAN;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { controls, dispatch } from '@wordpress/data';\nimport { apiFetch } from '@wordpress/data-controls';\nimport { addQueryArgs, getPathAndQueryString } from '@wordpress/url';\nimport { __ } 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';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME as editSiteStoreName } from './constants';\nimport isTemplateRevertable from '../utils/is-template-revertable';\n\n/**\n * Returns an action object used to toggle a feature flag.\n *\n * @param {string} feature Feature name.\n *\n * @return {Object} Action object.\n */\nexport function toggleFeature( feature ) {\n\treturn {\n\t\ttype: 'TOGGLE_FEATURE',\n\t\tfeature,\n\t};\n}\n\n/**\n * Returns an action object used to toggle 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 * Returns an action object used to set a template.\n *\n * @param {number} templateId The template ID.\n * @param {string} templateSlug The template slug.\n * @return {Object} Action object.\n */\nexport function* setTemplate( templateId, templateSlug ) {\n\tconst pageContext = { templateSlug };\n\tif ( ! templateSlug ) {\n\t\tconst template = yield controls.resolveSelect(\n\t\t\tcoreStore,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\ttemplateId\n\t\t);\n\t\tpageContext.templateSlug = template?.slug;\n\t}\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId,\n\t\tpage: { context: pageContext },\n\t};\n}\n\n/**\n * 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 function* addTemplate( template ) {\n\tconst newTemplate = yield controls.dispatch(\n\t\tcoreStore,\n\t\t'saveEntityRecord',\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplate\n\t);\n\n\tif ( template.content ) {\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\tnewTemplate.id,\n\t\t\t{ blocks: parse( template.content ) },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t}\n\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId: newTemplate.id,\n\t\tpage: { context: { templateSlug: newTemplate.slug } },\n\t};\n}\n\n/**\n * Removes a template, and updates the current page and template.\n *\n * @param {number} templateId The template ID.\n */\nexport function* removeTemplate( templateId ) {\n\tyield apiFetch( {\n\t\tpath: `/wp/v2/templates/${ templateId }`,\n\t\tmethod: 'DELETE',\n\t} );\n\tconst page = yield controls.select( editSiteStoreName, 'getPage' );\n\tyield controls.dispatch( editSiteStoreName, 'setPage', page );\n}\n\n/**\n * Returns an action object used to set 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_TEMPLATE_PART',\n\t\ttemplatePartId,\n\t};\n}\n\n/**\n * Returns an action object used to push a template part to navigation history.\n *\n * @param {string} templatePartId The template part ID.\n *\n * @return {Object} Action object.\n */\nexport function pushTemplatePart( templatePartId ) {\n\treturn {\n\t\ttype: 'PUSH_TEMPLATE_PART',\n\t\ttemplatePartId,\n\t};\n}\n\n/**\n * Updates the homeTemplateId state with the templateId of the page resolved\n * from the given path.\n *\n * @param {number} homeTemplateId The template ID for the homepage.\n */\nexport function setHomeTemplateId( homeTemplateId ) {\n\treturn {\n\t\ttype: 'SET_HOME_TEMPLATE',\n\t\thomeTemplateId,\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 function* setPage( page ) {\n\tif ( ! page.path && page.context?.postId ) {\n\t\tconst entity = yield controls.resolveSelect(\n\t\t\tcoreStore,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\tpage.context.postType || 'post',\n\t\t\tpage.context.postId\n\t\t);\n\n\t\tpage.path = getPathAndQueryString( entity.link );\n\t}\n\tconst { id: templateId, slug: templateSlug } = yield controls.resolveSelect(\n\t\tcoreStore,\n\t\t'__experimentalGetTemplateForLink',\n\t\tpage.path\n\t);\n\tyield {\n\t\ttype: 'SET_PAGE',\n\t\tpage: ! templateSlug\n\t\t\t? page\n\t\t\t: {\n\t\t\t\t\t...page,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\t...page.context,\n\t\t\t\t\t\ttemplateSlug,\n\t\t\t\t\t},\n\t\t\t },\n\t\ttemplateId,\n\t};\n\treturn templateId;\n}\n\n/**\n * Go back to the current editing page.\n */\nexport function goBack() {\n\treturn {\n\t\ttype: 'GO_BACK',\n\t};\n}\n\n/**\n * Displays the site homepage for editing in the editor.\n */\nexport function* showHomepage() {\n\tconst {\n\t\tshow_on_front: showOnFront,\n\t\tpage_on_front: frontpageId,\n\t} = yield controls.resolveSelect(\n\t\tcoreStore,\n\t\t'getEntityRecord',\n\t\t'root',\n\t\t'site'\n\t);\n\n\tconst { siteUrl } = yield controls.select(\n\t\teditSiteStoreName,\n\t\t'getSettings'\n\t);\n\n\tconst page = {\n\t\tpath: siteUrl,\n\t\tcontext:\n\t\t\tshowOnFront === 'page'\n\t\t\t\t? {\n\t\t\t\t\t\tpostType: 'page',\n\t\t\t\t\t\tpostId: frontpageId,\n\t\t\t\t }\n\t\t\t\t: {},\n\t};\n\n\tconst homeTemplate = yield* setPage( page );\n\tyield setHomeTemplateId( homeTemplate );\n}\n\n/**\n * Returns an action object used to set the active navigation panel menu.\n *\n * @param {string} menu Menu prop of active menu.\n *\n * @return {Object} Action object.\n */\nexport function setNavigationPanelActiveMenu( menu ) {\n\treturn {\n\t\ttype: 'SET_NAVIGATION_PANEL_ACTIVE_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Opens the navigation panel and sets its active menu at the same time.\n *\n * @param {string} menu Identifies the menu to open.\n */\nexport function openNavigationPanelToMenu( menu ) {\n\treturn {\n\t\ttype: 'OPEN_NAVIGATION_PANEL_TO_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Sets whether the navigation panel should be open.\n *\n * @param {boolean} isOpen If true, opens the nav panel. If false, closes it. It\n * does not toggle the state, but sets it directly.\n */\nexport function setIsNavigationPanelOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_NAVIGATION_PANEL_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to 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 * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n */\nexport function* revertTemplate( template ) {\n\tif ( ! isTemplateRevertable( template ) ) {\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\t__( 'This template is not revertable.' ),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst templateEntity = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEntity',\n\t\t\t'postType',\n\t\t\ttemplate.type\n\t\t);\n\t\tif ( ! templateEntity ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t`${ templateEntity.baseURL }/${ template.id }`,\n\t\t\t{ context: 'edit', source: 'theme' }\n\t\t);\n\t\tconst fileTemplate = yield apiFetch( { path: fileTemplatePath } );\n\t\tif ( ! fileTemplate ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializeBlocks = ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t__unstableSerializeAndClean( blocksForSerialization );\n\t\tconst edited = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEditedEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id\n\t\t);\n\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t// the revert in the header toolbar correctly.\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks, // required to make the `undo` behave correctly\n\t\t\t\tblocks: edited.blocks, // required to revert the blocks in the editor\n\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t},\n\t\t\t{\n\t\t\t\tundoIgnore: true, // required to merge this edit with the last undo level\n\t\t\t}\n\t\t);\n\n\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\tfileTemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks,\n\t\t\t\tblocks,\n\t\t\t\tsource: 'theme',\n\t\t\t}\n\t\t);\n\n\t\tconst undoRevert = async () => {\n\t\t\tawait dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\tedited.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\tsource: 'custom',\n\t\t\t\t}\n\t\t\t);\n\t\t};\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createSuccessNotice',\n\t\t\t__( 'Template reverted.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t}\n\t\t);\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\terrorMessage,\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t}\n}\n/**\n * Returns an action object used in signalling that the user opened an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n *\n * @yield {Object} Action object.\n */\nexport function* openGeneralSidebar( name ) {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'enableComplementaryArea',\n\t\teditSiteStoreName,\n\t\tname\n\t);\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @yield {Object} Action object.\n */\nexport function* closeGeneralSidebar() {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'disableComplementaryArea',\n\t\teditSiteStoreName\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/actions.js"],"names":["toggleFeature","feature","type","__experimentalSetPreviewDeviceType","deviceType","setTemplate","templateId","templateSlug","pageContext","template","controls","resolveSelect","coreStore","slug","page","context","addTemplate","newTemplate","dispatch","content","id","blocks","undoIgnore","removeTemplate","force","setTemplatePart","templatePartId","pushTemplatePart","setHomeTemplateId","homeTemplateId","setPage","path","postId","entity","postType","link","goBack","showHomepage","show_on_front","showOnFront","page_on_front","frontpageId","siteUrl","select","editSiteStoreName","homeTemplate","setNavigationPanelActiveMenu","menu","openNavigationPanelToMenu","setIsNavigationPanelOpened","isOpen","setIsInserterOpened","value","updateSettings","settings","setIsListViewOpened","revertTemplate","noticesStore","templateEntity","fileTemplatePath","baseURL","source","fileTemplate","serializeBlocks","blocksForSerialization","edited","raw","undoRevert","editEntityRecord","actions","label","onClick","error","errorMessage","message","code","openGeneralSidebar","name","interfaceStore","closeGeneralSidebar"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAT,CAAwBC,OAAxB,EAAkC;AACxC,SAAO;AACNC,IAAAA,IAAI,EAAE,gBADA;AAEND,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,kCAAT,CAA6CC,UAA7C,EAA0D;AAChE,SAAO;AACNF,IAAAA,IAAI,EAAE,yBADA;AAENE,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,UAAUC,WAAV,CAAuBC,UAAvB,EAAmCC,YAAnC,EAAkD;AACxD,QAAMC,WAAW,GAAG;AAAED,IAAAA;AAAF,GAApB;;AACA,MAAK,CAAEA,YAAP,EAAsB;AACrB,UAAME,QAAQ,GAAG,MAAMC,eAASC,aAAT,CACtBC,eADsB,EAEtB,iBAFsB,EAGtB,UAHsB,EAItB,aAJsB,EAKtBN,UALsB,CAAvB;AAOAE,IAAAA,WAAW,CAACD,YAAZ,GAA2BE,QAA3B,aAA2BA,QAA3B,uBAA2BA,QAAQ,CAAEI,IAArC;A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L3D,QAAQ,CAACP,IAFJ,EAGL+D,MAAM,CAAC7C,EAHF,EAIL;AACCD,QAAAA,OAAO,EAAE4C,eADV;AAEC1C,QAAAA,MAAM,EAAE4C,MAAM,CAAC5C,MAFhB;AAGCwC,QAAAA,MAAM,EAAE;AAHT,OAJK,CAAN;AAUA,KAXD;;AAYA,UAAMnD,eAASQ,QAAT,CACLuC,cADK,EAEL,qBAFK,EAGL,cAAI,oBAAJ,CAHK,EAIL;AACCvD,MAAAA,IAAI,EAAE,UADP;AAECmE,MAAAA,OAAO,EAAE,CACR;AACCC,QAAAA,KAAK,EAAE,cAAI,MAAJ,CADR;AAECC,QAAAA,OAAO,EAAEJ;AAFV,OADQ;AAFV,KAJK,CAAN;AAcA,GAvGD,CAuGE,OAAQK,KAAR,EAAgB;AACjB,UAAMC,YAAY,GACjBD,KAAK,CAACE,OAAN,IAAiBF,KAAK,CAACG,IAAN,KAAe,eAAhC,GACGH,KAAK,CAACE,OADT,GAEG,cAAI,wCAAJ,CAHJ;AAIA,UAAMhE,eAASQ,QAAT,CACLuC,cADK,EAEL,mBAFK,EAGLgB,YAHK,EAIL;AAAEvE,MAAAA,IAAI,EAAE;AAAR,KAJK,CAAN;AAMA;AACD;AACD;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,UAAU0E,kBAAV,CAA8BC,IAA9B,EAAqC;AAC3C,QAAMnE,eAASQ,QAAT,CACL4D,gBADK,EAEL,yBAFK,EAGLlC,qBAHK,EAILiC,IAJK,CAAN;AAMA;AAED;AACA;AACA;AACA;AACA;;;AACO,UAAUE,mBAAV,GAAgC;AACtC,QAAMrE,eAASQ,QAAT,CACL4D,gBADK,EAEL,0BAFK,EAGLlC,qBAHK,CAAN;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { controls, dispatch } from '@wordpress/data';\nimport { apiFetch } from '@wordpress/data-controls';\nimport { addQueryArgs, getPathAndQueryString } from '@wordpress/url';\nimport { __ } 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';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME as editSiteStoreName } from './constants';\nimport isTemplateRevertable from '../utils/is-template-revertable';\n\n/**\n * Returns an action object used to toggle a feature flag.\n *\n * @param {string} feature Feature name.\n *\n * @return {Object} Action object.\n */\nexport function toggleFeature( feature ) {\n\treturn {\n\t\ttype: 'TOGGLE_FEATURE',\n\t\tfeature,\n\t};\n}\n\n/**\n * Returns an action object used to toggle 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 * Returns an action object used to set a template.\n *\n * @param {number} templateId The template ID.\n * @param {string} templateSlug The template slug.\n * @return {Object} Action object.\n */\nexport function* setTemplate( templateId, templateSlug ) {\n\tconst pageContext = { templateSlug };\n\tif ( ! templateSlug ) {\n\t\tconst template = yield controls.resolveSelect(\n\t\t\tcoreStore,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\ttemplateId\n\t\t);\n\t\tpageContext.templateSlug = template?.slug;\n\t}\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId,\n\t\tpage: { context: pageContext },\n\t};\n}\n\n/**\n * 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 function* addTemplate( template ) {\n\tconst newTemplate = yield controls.dispatch(\n\t\tcoreStore,\n\t\t'saveEntityRecord',\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplate\n\t);\n\n\tif ( template.content ) {\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\tnewTemplate.id,\n\t\t\t{ blocks: parse( template.content ) },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t}\n\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId: newTemplate.id,\n\t\tpage: { context: { templateSlug: newTemplate.slug } },\n\t};\n}\n\n/**\n * Removes a template.\n *\n * @param {Object} template The template object.\n */\nexport function* removeTemplate( template ) {\n\tyield controls.dispatch(\n\t\tcoreStore,\n\t\t'deleteEntityRecord',\n\t\t'postType',\n\t\ttemplate.type,\n\t\ttemplate.id,\n\t\t{ force: true }\n\t);\n}\n\n/**\n * Returns an action object used to set 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_TEMPLATE_PART',\n\t\ttemplatePartId,\n\t};\n}\n\n/**\n * Returns an action object used to push a template part to navigation history.\n *\n * @param {string} templatePartId The template part ID.\n *\n * @return {Object} Action object.\n */\nexport function pushTemplatePart( templatePartId ) {\n\treturn {\n\t\ttype: 'PUSH_TEMPLATE_PART',\n\t\ttemplatePartId,\n\t};\n}\n\n/**\n * Updates the homeTemplateId state with the templateId of the page resolved\n * from the given path.\n *\n * @param {number} homeTemplateId The template ID for the homepage.\n */\nexport function setHomeTemplateId( homeTemplateId ) {\n\treturn {\n\t\ttype: 'SET_HOME_TEMPLATE',\n\t\thomeTemplateId,\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 function* setPage( page ) {\n\tif ( ! page.path && page.context?.postId ) {\n\t\tconst entity = yield controls.resolveSelect(\n\t\t\tcoreStore,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\tpage.context.postType || 'post',\n\t\t\tpage.context.postId\n\t\t);\n\n\t\tpage.path = getPathAndQueryString( entity.link );\n\t}\n\tconst { id: templateId, slug: templateSlug } = yield controls.resolveSelect(\n\t\tcoreStore,\n\t\t'__experimentalGetTemplateForLink',\n\t\tpage.path\n\t);\n\tyield {\n\t\ttype: 'SET_PAGE',\n\t\tpage: ! templateSlug\n\t\t\t? page\n\t\t\t: {\n\t\t\t\t\t...page,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\t...page.context,\n\t\t\t\t\t\ttemplateSlug,\n\t\t\t\t\t},\n\t\t\t },\n\t\ttemplateId,\n\t};\n\treturn templateId;\n}\n\n/**\n * Go back to the current editing page.\n */\nexport function goBack() {\n\treturn {\n\t\ttype: 'GO_BACK',\n\t};\n}\n\n/**\n * Displays the site homepage for editing in the editor.\n */\nexport function* showHomepage() {\n\tconst {\n\t\tshow_on_front: showOnFront,\n\t\tpage_on_front: frontpageId,\n\t} = yield controls.resolveSelect(\n\t\tcoreStore,\n\t\t'getEntityRecord',\n\t\t'root',\n\t\t'site'\n\t);\n\n\tconst { siteUrl } = yield controls.select(\n\t\teditSiteStoreName,\n\t\t'getSettings'\n\t);\n\n\tconst page = {\n\t\tpath: siteUrl,\n\t\tcontext:\n\t\t\tshowOnFront === 'page'\n\t\t\t\t? {\n\t\t\t\t\t\tpostType: 'page',\n\t\t\t\t\t\tpostId: frontpageId,\n\t\t\t\t }\n\t\t\t\t: {},\n\t};\n\n\tconst homeTemplate = yield* setPage( page );\n\tyield setHomeTemplateId( homeTemplate );\n}\n\n/**\n * Returns an action object used to set the active navigation panel menu.\n *\n * @param {string} menu Menu prop of active menu.\n *\n * @return {Object} Action object.\n */\nexport function setNavigationPanelActiveMenu( menu ) {\n\treturn {\n\t\ttype: 'SET_NAVIGATION_PANEL_ACTIVE_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Opens the navigation panel and sets its active menu at the same time.\n *\n * @param {string} menu Identifies the menu to open.\n */\nexport function openNavigationPanelToMenu( menu ) {\n\treturn {\n\t\ttype: 'OPEN_NAVIGATION_PANEL_TO_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Sets whether the navigation panel should be open.\n *\n * @param {boolean} isOpen If true, opens the nav panel. If false, closes it. It\n * does not toggle the state, but sets it directly.\n */\nexport function setIsNavigationPanelOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_NAVIGATION_PANEL_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to 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 * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n */\nexport function* revertTemplate( template ) {\n\tif ( ! isTemplateRevertable( template ) ) {\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\t__( 'This template is not revertable.' ),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst templateEntity = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEntity',\n\t\t\t'postType',\n\t\t\ttemplate.type\n\t\t);\n\t\tif ( ! templateEntity ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t`${ templateEntity.baseURL }/${ template.id }`,\n\t\t\t{ context: 'edit', source: 'theme' }\n\t\t);\n\t\tconst fileTemplate = yield apiFetch( { path: fileTemplatePath } );\n\t\tif ( ! fileTemplate ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializeBlocks = ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t__unstableSerializeAndClean( blocksForSerialization );\n\t\tconst edited = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEditedEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id\n\t\t);\n\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t// the revert in the header toolbar correctly.\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks, // required to make the `undo` behave correctly\n\t\t\t\tblocks: edited.blocks, // required to revert the blocks in the editor\n\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t},\n\t\t\t{\n\t\t\t\tundoIgnore: true, // required to merge this edit with the last undo level\n\t\t\t}\n\t\t);\n\n\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\tfileTemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks,\n\t\t\t\tblocks,\n\t\t\t\tsource: 'theme',\n\t\t\t}\n\t\t);\n\n\t\tconst undoRevert = async () => {\n\t\t\tawait dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\tedited.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\tsource: 'custom',\n\t\t\t\t}\n\t\t\t);\n\t\t};\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createSuccessNotice',\n\t\t\t__( 'Template reverted.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t}\n\t\t);\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\terrorMessage,\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t}\n}\n/**\n * Returns an action object used in signalling that the user opened an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n *\n * @yield {Object} Action object.\n */\nexport function* openGeneralSidebar( name ) {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'enableComplementaryArea',\n\t\teditSiteStoreName,\n\t\tname\n\t);\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @yield {Object} Action object.\n */\nexport function* closeGeneralSidebar() {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'disableComplementaryArea',\n\t\teditSiteStoreName\n\t);\n}\n"]}
|
package/build/store/defaults.js
CHANGED
|
@@ -5,7 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.PREFERENCES_DEFAULTS = void 0;
|
|
7
7
|
const PREFERENCES_DEFAULTS = {
|
|
8
|
-
features: {
|
|
8
|
+
features: {
|
|
9
|
+
welcomeGuide: true,
|
|
10
|
+
welcomeGuideStyles: true
|
|
11
|
+
}
|
|
9
12
|
};
|
|
10
13
|
exports.PREFERENCES_DEFAULTS = PREFERENCES_DEFAULTS;
|
|
11
14
|
//# sourceMappingURL=defaults.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/defaults.js"],"names":["PREFERENCES_DEFAULTS","features"],"mappings":";;;;;;AAAO,MAAMA,oBAAoB,GAAG;AACnCC,EAAAA,QAAQ,EAAE;AADyB,CAA7B","sourcesContent":["export const PREFERENCES_DEFAULTS = {\n\tfeatures: {},\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/defaults.js"],"names":["PREFERENCES_DEFAULTS","features","welcomeGuide","welcomeGuideStyles"],"mappings":";;;;;;AAAO,MAAMA,oBAAoB,GAAG;AACnCC,EAAAA,QAAQ,EAAE;AACTC,IAAAA,YAAY,EAAE,IADL;AAETC,IAAAA,kBAAkB,EAAE;AAFX;AADyB,CAA7B","sourcesContent":["export const PREFERENCES_DEFAULTS = {\n\tfeatures: {\n\t\twelcomeGuide: true,\n\t\twelcomeGuideStyles: true,\n\t},\n};\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = isTemplateRemovable;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Check if a template is removable.
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} template The template entity to check.
|
|
12
|
+
* @return {boolean} Whether the template is revertable.
|
|
13
|
+
*/
|
|
14
|
+
function isTemplateRemovable(template) {
|
|
15
|
+
if (!template) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return template.source === 'custom' && !template.has_theme_file;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=is-template-removable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/utils/is-template-removable.js"],"names":["isTemplateRemovable","template","source","has_theme_file"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,mBAAT,CAA8BC,QAA9B,EAAyC;AACvD,MAAK,CAAEA,QAAP,EAAkB;AACjB,WAAO,KAAP;AACA;;AAED,SAAOA,QAAQ,CAACC,MAAT,KAAoB,QAApB,IAAgC,CAAED,QAAQ,CAACE,cAAlD;AACA","sourcesContent":["/**\n * Check if a template is removable.\n *\n * @param {Object} template The template entity to check.\n * @return {boolean} Whether the template is revertable.\n */\nexport default function isTemplateRemovable( template ) {\n\tif ( ! template ) {\n\t\treturn false;\n\t}\n\n\treturn template.source === 'custom' && ! template.has_theme_file;\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useSelect } from '@wordpress/data';
|
|
7
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import NewTemplate from './new-template';
|
|
13
|
+
import NewTemplatePart from './new-template-part';
|
|
14
|
+
export default function AddNewTemplate(_ref) {
|
|
15
|
+
let {
|
|
16
|
+
templateType = 'wp_template'
|
|
17
|
+
} = _ref;
|
|
18
|
+
const postType = useSelect(select => select(coreStore).getPostType(templateType), [templateType]);
|
|
19
|
+
|
|
20
|
+
if (!postType) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (templateType === 'wp_template') {
|
|
25
|
+
return createElement(NewTemplate, {
|
|
26
|
+
postType: postType
|
|
27
|
+
});
|
|
28
|
+
} else if (templateType === 'wp_template_part') {
|
|
29
|
+
return createElement(NewTemplatePart, {
|
|
30
|
+
postType: postType
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/index.js"],"names":["useSelect","store","coreStore","NewTemplate","NewTemplatePart","AddNewTemplate","templateType","postType","select","getPostType"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AAEA,eAAe,SAASC,cAAT,OAA4D;AAAA,MAAnC;AAAEC,IAAAA,YAAY,GAAG;AAAjB,GAAmC;AAC1E,QAAMC,QAAQ,GAAGP,SAAS,CACvBQ,MAAF,IAAcA,MAAM,CAAEN,SAAF,CAAN,CAAoBO,WAApB,CAAiCH,YAAjC,CADW,EAEzB,CAAEA,YAAF,CAFyB,CAA1B;;AAKA,MAAK,CAAEC,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,MAAKD,YAAY,KAAK,aAAtB,EAAsC;AACrC,WAAO,cAAC,WAAD;AAAa,MAAA,QAAQ,EAAGC;AAAxB,MAAP;AACA,GAFD,MAEO,IAAKD,YAAY,KAAK,kBAAtB,EAA2C;AACjD,WAAO,cAAC,eAAD;AAAiB,MAAA,QAAQ,EAAGC;AAA5B,MAAP;AACA;;AAED,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport NewTemplate from './new-template';\nimport NewTemplatePart from './new-template-part';\n\nexport default function AddNewTemplate( { templateType = 'wp_template' } ) {\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\tif ( ! postType ) {\n\t\treturn null;\n\t}\n\n\tif ( templateType === 'wp_template' ) {\n\t\treturn <NewTemplate postType={ postType } />;\n\t} else if ( templateType === 'wp_template_part' ) {\n\t\treturn <NewTemplatePart postType={ postType } />;\n\t}\n\n\treturn null;\n}\n"]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { kebabCase } from 'lodash';
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { useState } from '@wordpress/element';
|
|
12
|
+
import { Button } from '@wordpress/components';
|
|
13
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
14
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import CreateTemplatePartModal from '../create-template-part-modal';
|
|
20
|
+
export default function NewTemplatePart(_ref) {
|
|
21
|
+
let {
|
|
22
|
+
postType
|
|
23
|
+
} = _ref;
|
|
24
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
25
|
+
|
|
26
|
+
async function createTemplatePart(_ref2) {
|
|
27
|
+
let {
|
|
28
|
+
title,
|
|
29
|
+
area
|
|
30
|
+
} = _ref2;
|
|
31
|
+
|
|
32
|
+
if (!title) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const templatePart = await apiFetch({
|
|
37
|
+
path: '/wp/v2/template-parts',
|
|
38
|
+
method: 'POST',
|
|
39
|
+
data: {
|
|
40
|
+
slug: kebabCase(title),
|
|
41
|
+
title,
|
|
42
|
+
content: '',
|
|
43
|
+
area
|
|
44
|
+
}
|
|
45
|
+
}); // Navigate to the created template part editor.
|
|
46
|
+
|
|
47
|
+
window.location.search = addQueryArgs('', {
|
|
48
|
+
page: 'gutenberg-edit-site',
|
|
49
|
+
postId: templatePart.id,
|
|
50
|
+
postType: 'wp_template_part'
|
|
51
|
+
}); // Wait for async navigation to happen before closing the modal.
|
|
52
|
+
|
|
53
|
+
await new Promise(() => {});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return createElement(Fragment, null, createElement(Button, {
|
|
57
|
+
variant: "primary",
|
|
58
|
+
onClick: () => {
|
|
59
|
+
setIsModalOpen(true);
|
|
60
|
+
}
|
|
61
|
+
}, postType.labels.add_new), isModalOpen && createElement(CreateTemplatePartModal, {
|
|
62
|
+
closeModal: () => setIsModalOpen(false),
|
|
63
|
+
onCreate: createTemplatePart
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=new-template-part.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template-part.js"],"names":["kebabCase","useState","Button","addQueryArgs","apiFetch","CreateTemplatePartModal","NewTemplatePart","postType","isModalOpen","setIsModalOpen","createTemplatePart","title","area","templatePart","path","method","data","slug","content","window","location","search","page","postId","id","Promise","labels","add_new"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,OAA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,EAAGC;AAFZ,IAVF,CADD;AAkBA","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { Button } from '@wordpress/components';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport CreateTemplatePartModal from '../create-template-part-modal';\n\nexport default function NewTemplatePart( { postType } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\n\tasync function createTemplatePart( { title, area } ) {\n\t\tif ( ! title ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst templatePart = await apiFetch( {\n\t\t\tpath: '/wp/v2/template-parts',\n\t\t\tmethod: 'POST',\n\t\t\tdata: {\n\t\t\t\tslug: kebabCase( title ),\n\t\t\t\ttitle,\n\t\t\t\tcontent: '',\n\t\t\t\tarea,\n\t\t\t},\n\t\t} );\n\n\t\t// Navigate to the created template part editor.\n\t\twindow.location.search = addQueryArgs( '', {\n\t\t\tpage: 'gutenberg-edit-site',\n\t\t\tpostId: templatePart.id,\n\t\t\tpostType: 'wp_template_part',\n\t\t} );\n\n\t\t// Wait for async navigation to happen before closing the modal.\n\t\tawait new Promise( () => {} );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ postType.labels.add_new }\n\t\t\t</Button>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => setIsModalOpen( false ) }\n\t\t\t\t\tonCreate={ createTemplatePart }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { filter, find, includes, map } from 'lodash';
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { DropdownMenu, MenuGroup, MenuItem, NavigableMenu } from '@wordpress/components';
|
|
12
|
+
import { useSelect } from '@wordpress/data';
|
|
13
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
14
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
15
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
16
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
17
|
+
const DEFAULT_TEMPLATE_SLUGS = ['front-page', 'single-post', 'page', 'archive', 'search', '404', 'index'];
|
|
18
|
+
export default function NewTemplate(_ref) {
|
|
19
|
+
let {
|
|
20
|
+
postType
|
|
21
|
+
} = _ref;
|
|
22
|
+
const {
|
|
23
|
+
templates,
|
|
24
|
+
defaultTemplateTypes
|
|
25
|
+
} = useSelect(select => ({
|
|
26
|
+
templates: select(coreStore).getEntityRecords('postType', 'wp_template'),
|
|
27
|
+
defaultTemplateTypes: select(editorStore).__experimentalGetDefaultTemplateTypes()
|
|
28
|
+
}), []);
|
|
29
|
+
|
|
30
|
+
async function createTemplate(_ref2) {
|
|
31
|
+
let {
|
|
32
|
+
slug
|
|
33
|
+
} = _ref2;
|
|
34
|
+
const {
|
|
35
|
+
title,
|
|
36
|
+
description
|
|
37
|
+
} = find(defaultTemplateTypes, {
|
|
38
|
+
slug
|
|
39
|
+
});
|
|
40
|
+
const template = await apiFetch({
|
|
41
|
+
path: '/wp/v2/templates',
|
|
42
|
+
method: 'POST',
|
|
43
|
+
data: {
|
|
44
|
+
excerpt: description,
|
|
45
|
+
// Slugs need to be strings, so this is for template `404`
|
|
46
|
+
slug: slug.toString(),
|
|
47
|
+
status: 'publish',
|
|
48
|
+
title
|
|
49
|
+
}
|
|
50
|
+
}); // Navigate to the created template editor.
|
|
51
|
+
|
|
52
|
+
window.location.search = addQueryArgs('', {
|
|
53
|
+
page: 'gutenberg-edit-site',
|
|
54
|
+
postId: template.id,
|
|
55
|
+
postType: 'wp_template'
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const existingTemplateSlugs = map(templates, 'slug');
|
|
60
|
+
const missingTemplates = filter(defaultTemplateTypes, template => includes(DEFAULT_TEMPLATE_SLUGS, template.slug) && !includes(existingTemplateSlugs, template.slug));
|
|
61
|
+
|
|
62
|
+
if (!missingTemplates.length) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return createElement(DropdownMenu, {
|
|
67
|
+
className: "edit-site-new-template-dropdown",
|
|
68
|
+
icon: null,
|
|
69
|
+
text: postType.labels.add_new,
|
|
70
|
+
label: postType.labels.add_new_item,
|
|
71
|
+
popoverProps: {
|
|
72
|
+
noArrow: false
|
|
73
|
+
},
|
|
74
|
+
toggleProps: {
|
|
75
|
+
variant: 'primary'
|
|
76
|
+
}
|
|
77
|
+
}, () => createElement(NavigableMenu, {
|
|
78
|
+
className: "edit-site-new-template-dropdown__popover"
|
|
79
|
+
}, createElement(MenuGroup, {
|
|
80
|
+
label: postType.labels.add_new_item
|
|
81
|
+
}, map(missingTemplates, _ref3 => {
|
|
82
|
+
let {
|
|
83
|
+
title,
|
|
84
|
+
description,
|
|
85
|
+
slug
|
|
86
|
+
} = _ref3;
|
|
87
|
+
return createElement(MenuItem, {
|
|
88
|
+
info: description,
|
|
89
|
+
key: slug,
|
|
90
|
+
onClick: () => {
|
|
91
|
+
createTemplate({
|
|
92
|
+
slug
|
|
93
|
+
}); // We will be navigated way so no need to close the dropdown.
|
|
94
|
+
}
|
|
95
|
+
}, title);
|
|
96
|
+
}))));
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=new-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template.js"],"names":["filter","find","includes","map","DropdownMenu","MenuGroup","MenuItem","NavigableMenu","useSelect","store","coreStore","editorStore","addQueryArgs","apiFetch","DEFAULT_TEMPLATE_SLUGS","NewTemplate","postType","templates","defaultTemplateTypes","select","getEntityRecords","__experimentalGetDefaultTemplateTypes","createTemplate","slug","title","description","template","path","method","data","excerpt","toString","status","window","location","search","page","postId","id","existingTemplateSlugs","missingTemplates","length","labels","add_new","add_new_item","noArrow","variant"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,IAAjB,EAAuBC,QAAvB,EAAiCC,GAAjC,QAA4C,QAA5C;AAEA;AACA;AACA;;AACA,SACCC,YADD,EAECC,SAFD,EAGCC,QAHD,EAICC,aAJD,QAKO,uBALP;AAMA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,mBAArC;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAEA,MAAMC,sBAAsB,GAAG,CAC9B,YAD8B,EAE9B,aAF8B,EAG9B,MAH8B,EAI9B,SAJ8B,EAK9B,QAL8B,EAM9B,KAN8B,EAO9B,OAP8B,CAA/B;AAUA,eAAe,SAASC,WAAT,OAAqC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACnD,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAAsCV,SAAS,CAClDW,MAAF,KAAgB;AACfF,IAAAA,SAAS,EAAEE,MAAM,CAAET,SAAF,CAAN,CAAoBU,gBAApB,CACV,UADU,EAEV,aAFU,CADI;AAKfF,IAAAA,oBAAoB,EAAEC,MAAM,CAC3BR,WAD2B,CAAN,CAEpBU,qCAFoB;AALP,GAAhB,CADoD,EAUpD,EAVoD,CAArD;;AAaA,iBAAeC,cAAf,QAA0C;AAAA,QAAX;AAAEC,MAAAA;AAAF,KAAW;AACzC,UAAM;AAAEC,MAAAA,KA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,MAAAA,OAAO,EAAE;AADK,KALhB;AAQC,IAAA,WAAW,EAAG;AACbC,MAAAA,OAAO,EAAE;AADI;AARf,KAYG,MACD,cAAC,aAAD;AAAe,IAAA,SAAS,EAAC;AAAzB,KACC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAG9B,QAAQ,CAAC0B,MAAT,CAAgBE;AAAnC,KACGzC,GAAG,CACJqC,gBADI,EAEJ;AAAA,QAAE;AAAEhB,MAAAA,KAAF;AAASC,MAAAA,WAAT;AAAsBF,MAAAA;AAAtB,KAAF;AAAA,WACC,cAAC,QAAD;AACC,MAAA,IAAI,EAAGE,WADR;AAEC,MAAA,GAAG,EAAGF,IAFP;AAGC,MAAA,OAAO,EAAG,MAAM;AACfD,QAAAA,cAAc,CAAE;AAAEC,UAAAA;AAAF,SAAF,CAAd,CADe,CAEf;AACA;AANF,OAQGC,KARH,CADD;AAAA,GAFI,CADN,CADD,CAbF,CADD;AAoCA","sourcesContent":["/**\n * External dependencies\n */\nimport { filter, find, includes, map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\nconst DEFAULT_TEMPLATE_SLUGS = [\n\t'front-page',\n\t'single-post',\n\t'page',\n\t'archive',\n\t'search',\n\t'404',\n\t'index',\n];\n\nexport default function NewTemplate( { postType } ) {\n\tconst { templates, defaultTemplateTypes } = useSelect(\n\t\t( select ) => ( {\n\t\t\ttemplates: select( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template'\n\t\t\t),\n\t\t\tdefaultTemplateTypes: select(\n\t\t\t\teditorStore\n\t\t\t).__experimentalGetDefaultTemplateTypes(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tasync function createTemplate( { slug } ) {\n\t\tconst { title, description } = find( defaultTemplateTypes, { slug } );\n\n\t\tconst template = await apiFetch( {\n\t\t\tpath: '/wp/v2/templates',\n\t\t\tmethod: 'POST',\n\t\t\tdata: {\n\t\t\t\texcerpt: description,\n\t\t\t\t// Slugs need to be strings, so this is for template `404`\n\t\t\t\tslug: slug.toString(),\n\t\t\t\tstatus: 'publish',\n\t\t\t\ttitle,\n\t\t\t},\n\t\t} );\n\n\t\t// Navigate to the created template editor.\n\t\twindow.location.search = addQueryArgs( '', {\n\t\t\tpage: 'gutenberg-edit-site',\n\t\t\tpostId: template.id,\n\t\t\tpostType: 'wp_template',\n\t\t} );\n\t}\n\n\tconst existingTemplateSlugs = map( templates, 'slug' );\n\n\tconst missingTemplates = filter(\n\t\tdefaultTemplateTypes,\n\t\t( template ) =>\n\t\t\tincludes( DEFAULT_TEMPLATE_SLUGS, template.slug ) &&\n\t\t\t! includes( existingTemplateSlugs, template.slug )\n\t);\n\n\tif ( ! missingTemplates.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"edit-site-new-template-dropdown\"\n\t\t\ticon={ null }\n\t\t\ttext={ postType.labels.add_new }\n\t\t\tlabel={ postType.labels.add_new_item }\n\t\t\tpopoverProps={ {\n\t\t\t\tnoArrow: false,\n\t\t\t} }\n\t\t\ttoggleProps={ {\n\t\t\t\tvariant: 'primary',\n\t\t\t} }\n\t\t>\n\t\t\t{ () => (\n\t\t\t\t<NavigableMenu className=\"edit-site-new-template-dropdown__popover\">\n\t\t\t\t\t<MenuGroup label={ postType.labels.add_new_item }>\n\t\t\t\t\t\t{ map(\n\t\t\t\t\t\t\tmissingTemplates,\n\t\t\t\t\t\t\t( { title, description, slug } ) => (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tinfo={ description }\n\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tcreateTemplate( { slug } );\n\t\t\t\t\t\t\t\t\t\t// We will be navigated way so no need to close the dropdown.\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{ title }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</NavigableMenu>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useSelect } from '@wordpress/data';
|
|
7
|
+
import { Icon, BaseControl, TextControl, Flex, FlexItem, FlexBlock, Button, Modal, __experimentalRadioGroup as RadioGroup, __experimentalRadio as Radio } from '@wordpress/components';
|
|
8
|
+
import { __ } from '@wordpress/i18n';
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
11
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
12
|
+
import { check } from '@wordpress/icons';
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { TEMPLATE_PART_AREA_GENERAL } from '../../store/constants';
|
|
18
|
+
export default function CreateTemplatePartModal(_ref) {
|
|
19
|
+
let {
|
|
20
|
+
closeModal,
|
|
21
|
+
onCreate
|
|
22
|
+
} = _ref;
|
|
23
|
+
const [title, setTitle] = useState('');
|
|
24
|
+
const [area, setArea] = useState(TEMPLATE_PART_AREA_GENERAL);
|
|
25
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
26
|
+
const instanceId = useInstanceId(CreateTemplatePartModal);
|
|
27
|
+
const templatePartAreas = useSelect(select => select(editorStore).__experimentalGetDefaultTemplatePartAreas(), []);
|
|
28
|
+
return createElement(Modal, {
|
|
29
|
+
title: __('Create a template part'),
|
|
30
|
+
closeLabel: __('Close'),
|
|
31
|
+
onRequestClose: closeModal,
|
|
32
|
+
overlayClassName: "edit-site-create-template-part-modal"
|
|
33
|
+
}, createElement("form", {
|
|
34
|
+
onSubmit: async event => {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
|
|
37
|
+
if (!title) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
setIsSubmitting(true);
|
|
42
|
+
await onCreate({
|
|
43
|
+
title,
|
|
44
|
+
area
|
|
45
|
+
});
|
|
46
|
+
setIsSubmitting(false);
|
|
47
|
+
closeModal();
|
|
48
|
+
}
|
|
49
|
+
}, createElement(TextControl, {
|
|
50
|
+
label: __('Name'),
|
|
51
|
+
value: title,
|
|
52
|
+
onChange: setTitle,
|
|
53
|
+
required: true
|
|
54
|
+
}), createElement(BaseControl, {
|
|
55
|
+
label: __('Area'),
|
|
56
|
+
id: `edit-site-create-template-part-modal__area-selection-${instanceId}`,
|
|
57
|
+
className: "edit-site-create-template-part-modal__area-base-control"
|
|
58
|
+
}, createElement(RadioGroup, {
|
|
59
|
+
label: __('Area'),
|
|
60
|
+
className: "edit-site-create-template-part-modal__area-radio-group",
|
|
61
|
+
id: `edit-site-create-template-part-modal__area-selection-${instanceId}`,
|
|
62
|
+
onChange: setArea,
|
|
63
|
+
checked: area
|
|
64
|
+
}, templatePartAreas.map(_ref2 => {
|
|
65
|
+
let {
|
|
66
|
+
icon,
|
|
67
|
+
label,
|
|
68
|
+
area: value,
|
|
69
|
+
description
|
|
70
|
+
} = _ref2;
|
|
71
|
+
return createElement(Radio, {
|
|
72
|
+
key: label,
|
|
73
|
+
value: value,
|
|
74
|
+
className: "edit-site-create-template-part-modal__area-radio"
|
|
75
|
+
}, createElement(Flex, {
|
|
76
|
+
align: "start",
|
|
77
|
+
justify: "start"
|
|
78
|
+
}, createElement(FlexItem, null, createElement(Icon, {
|
|
79
|
+
icon: icon
|
|
80
|
+
})), createElement(FlexBlock, {
|
|
81
|
+
className: "edit-site-create-template-part-modal__option-label"
|
|
82
|
+
}, label, createElement("div", null, description)), createElement(FlexItem, {
|
|
83
|
+
className: "edit-site-create-template-part-modal__checkbox"
|
|
84
|
+
}, area === value && createElement(Icon, {
|
|
85
|
+
icon: check
|
|
86
|
+
}))));
|
|
87
|
+
}))), createElement(Flex, {
|
|
88
|
+
className: "edit-site-create-template-part-modal__modal-actions",
|
|
89
|
+
justify: "flex-end"
|
|
90
|
+
}, createElement(FlexItem, null, createElement(Button, {
|
|
91
|
+
variant: "secondary",
|
|
92
|
+
onClick: () => {
|
|
93
|
+
closeModal();
|
|
94
|
+
}
|
|
95
|
+
}, __('Cancel'))), createElement(FlexItem, null, createElement(Button, {
|
|
96
|
+
variant: "primary",
|
|
97
|
+
type: "submit",
|
|
98
|
+
disabled: !title,
|
|
99
|
+
isBusy: isSubmitting
|
|
100
|
+
}, __('Create'))))));
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/create-template-part-modal/index.js"],"names":["useSelect","Icon","BaseControl","TextControl","Flex","FlexItem","FlexBlock","Button","Modal","__experimentalRadioGroup","RadioGroup","__experimentalRadio","Radio","__","useState","useInstanceId","store","editorStore","check","TEMPLATE_PART_AREA_GENERAL","CreateTemplatePartModal","closeModal","onCreate","title","setTitle","area","setArea","isSubmitting","setIsSubmitting","instanceId","templatePartAreas","select","__experimentalGetDefaultTemplatePartAreas","event","preventDefault","map","icon","label","value","description"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SACCC,IADD,EAECC,WAFD,EAGCC,WAHD,EAICC,IAJD,EAKCC,QALD,EAMCC,SAND,EAOCC,MAPD,EAQCC,KARD,EASCC,wBAAwB,IAAIC,UAT7B,EAUCC,m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AAC,IAAD;AACC,IAAA,SAAS,EAAC,qDADX;AAEC,IAAA,OAAO,EAAC;AAFT,KAIC,cAAC,QAAD,QACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,WADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfG,MAAAA,UAAU;AACV;AAJF,KAMGR,EAAE,CAAE,QAAF,CANL,CADD,CAJD,EAcC,cAAC,QAAD,QACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,QAAQ,EAAG,CAAEU,KAHd;AAIC,IAAA,MAAM,EAAGI;AAJV,KAMGd,EAAE,CAAE,QAAF,CANL,CADD,CAdD,CAzDD,CAND,CADD;AA4FA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tIcon,\n\tBaseControl,\n\tTextControl,\n\tFlex,\n\tFlexItem,\n\tFlexBlock,\n\tButton,\n\tModal,\n\t__experimentalRadioGroup as RadioGroup,\n\t__experimentalRadio as Radio,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as editorStore } from '@wordpress/editor';\nimport { check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_PART_AREA_GENERAL } from '../../store/constants';\n\nexport default function CreateTemplatePartModal( { closeModal, onCreate } ) {\n\tconst [ title, setTitle ] = useState( '' );\n\tconst [ area, setArea ] = useState( TEMPLATE_PART_AREA_GENERAL );\n\tconst [ isSubmitting, setIsSubmitting ] = useState( false );\n\tconst instanceId = useInstanceId( CreateTemplatePartModal );\n\n\tconst templatePartAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetDefaultTemplatePartAreas(),\n\t\t[]\n\t);\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create a template part' ) }\n\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ closeModal }\n\t\t\toverlayClassName=\"edit-site-create-template-part-modal\"\n\t\t>\n\t\t\t<form\n\t\t\t\tonSubmit={ async ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( ! title ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsetIsSubmitting( true );\n\t\t\t\t\tawait onCreate( { title, area } );\n\t\t\t\t\tsetIsSubmitting( false );\n\t\t\t\t\tcloseModal();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<TextControl\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\trequired\n\t\t\t\t/>\n\t\t\t\t<BaseControl\n\t\t\t\t\tlabel={ __( 'Area' ) }\n\t\t\t\t\tid={ `edit-site-create-template-part-modal__area-selection-${ instanceId }` }\n\t\t\t\t\tclassName=\"edit-site-create-template-part-modal__area-base-control\"\n\t\t\t\t>\n\t\t\t\t\t<RadioGroup\n\t\t\t\t\t\tlabel={ __( 'Area' ) }\n\t\t\t\t\t\tclassName=\"edit-site-create-template-part-modal__area-radio-group\"\n\t\t\t\t\t\tid={ `edit-site-create-template-part-modal__area-selection-${ instanceId }` }\n\t\t\t\t\t\tonChange={ setArea }\n\t\t\t\t\t\tchecked={ area }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ templatePartAreas.map(\n\t\t\t\t\t\t\t( { icon, label, area: value, description } ) => (\n\t\t\t\t\t\t\t\t<Radio\n\t\t\t\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-create-template-part-modal__area-radio\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Flex align=\"start\" justify=\"start\">\n\t\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t<FlexBlock className=\"edit-site-create-template-part-modal__option-label\">\n\t\t\t\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t\t\t\t\t<div>{ description }</div>\n\t\t\t\t\t\t\t\t\t\t</FlexBlock>\n\n\t\t\t\t\t\t\t\t\t\t<FlexItem className=\"edit-site-create-template-part-modal__checkbox\">\n\t\t\t\t\t\t\t\t\t\t\t{ area === value && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ check } />\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t\t\t</Radio>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</RadioGroup>\n\t\t\t\t</BaseControl>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"edit-site-create-template-part-modal__modal-actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tdisabled={ ! title }\n\t\t\t\t\t\t\tisBusy={ isSubmitting }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
@@ -19,17 +19,20 @@ import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
|
|
|
19
19
|
|
|
20
20
|
import Header from '../header';
|
|
21
21
|
import { SidebarComplementaryAreaFills } from '../sidebar';
|
|
22
|
+
import NavigationSidebar from '../navigation-sidebar';
|
|
22
23
|
import BlockEditor from '../block-editor';
|
|
23
24
|
import KeyboardShortcuts from '../keyboard-shortcuts';
|
|
24
25
|
import URLQueryController from '../url-query-controller';
|
|
25
26
|
import InserterSidebar from '../secondary-sidebar/inserter-sidebar';
|
|
26
27
|
import ListViewSidebar from '../secondary-sidebar/list-view-sidebar';
|
|
27
28
|
import ErrorBoundary from '../error-boundary';
|
|
29
|
+
import WelcomeGuide from '../welcome-guide';
|
|
28
30
|
import { store as editSiteStore } from '../../store';
|
|
29
31
|
import { GlobalStylesRenderer } from './global-styles-renderer';
|
|
30
32
|
import { GlobalStylesProvider } from '../global-styles/global-styles-provider';
|
|
31
33
|
const interfaceLabels = {
|
|
32
|
-
secondarySidebar: __('Block Library')
|
|
34
|
+
secondarySidebar: __('Block Library'),
|
|
35
|
+
drawer: __('Navigation Sidebar')
|
|
33
36
|
};
|
|
34
37
|
|
|
35
38
|
function Editor(_ref) {
|
|
@@ -86,9 +89,6 @@ function Editor(_ref) {
|
|
|
86
89
|
setIsInserterOpened,
|
|
87
90
|
updateSettings
|
|
88
91
|
} = useDispatch(editSiteStore);
|
|
89
|
-
const {
|
|
90
|
-
enableComplementaryArea
|
|
91
|
-
} = useDispatch(interfaceStore);
|
|
92
92
|
useEffect(() => {
|
|
93
93
|
updateSettings(initialSettings);
|
|
94
94
|
}, []); // Keep the defaultTemplateTypes in the core/editor settings too,
|
|
@@ -128,14 +128,7 @@ function Editor(_ref) {
|
|
|
128
128
|
} else {
|
|
129
129
|
document.body.classList.remove('is-navigation-sidebar-open');
|
|
130
130
|
}
|
|
131
|
-
}, [isNavigationOpen]);
|
|
132
|
-
useEffect(function openGlobalStylesOnLoad() {
|
|
133
|
-
const searchParams = new URLSearchParams(window.location.search);
|
|
134
|
-
|
|
135
|
-
if (searchParams.get('styles') === 'open') {
|
|
136
|
-
enableComplementaryArea('core/edit-site', 'edit-site/global-styles');
|
|
137
|
-
}
|
|
138
|
-
}, [enableComplementaryArea]); // Don't render the Editor until the settings are set and loaded
|
|
131
|
+
}, [isNavigationOpen]); // Don't render the Editor until the settings are set and loaded
|
|
139
132
|
|
|
140
133
|
const isReady = (settings === null || settings === void 0 ? void 0 : settings.siteUrl) && templateType !== undefined && entityId !== undefined;
|
|
141
134
|
|
|
@@ -170,6 +163,9 @@ function Editor(_ref) {
|
|
|
170
163
|
sidebar: sidebarIsOpened && createElement(ComplementaryArea.Slot, {
|
|
171
164
|
scope: "core/edit-site"
|
|
172
165
|
}),
|
|
166
|
+
drawer: createElement(NavigationSidebar, {
|
|
167
|
+
defaultIsOpen: false
|
|
168
|
+
}),
|
|
173
169
|
header: createElement(Header, {
|
|
174
170
|
openEntitiesSavedStates: openEntitiesSavedStates
|
|
175
171
|
}),
|
|
@@ -193,7 +189,7 @@ function Editor(_ref) {
|
|
|
193
189
|
"aria-expanded": false
|
|
194
190
|
}, __('Open save panel')))),
|
|
195
191
|
footer: createElement(BlockBreadcrumb, null)
|
|
196
|
-
}), createElement(Popover.Slot, null), createElement(PluginArea, null)))))))));
|
|
192
|
+
}), createElement(WelcomeGuide, null), createElement(Popover.Slot, null), createElement(PluginArea, null)))))))));
|
|
197
193
|
}
|
|
198
194
|
|
|
199
195
|
export default Editor;
|