@wordpress/edit-site 3.0.10 → 3.0.14
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 +34 -18
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +41 -23
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/index.js +3 -1
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/editor/index.js +12 -6
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +29 -6
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +5 -43
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +71 -0
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -0
- package/build/components/global-styles/hooks.js +5 -5
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/palette.js +11 -5
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +3 -1
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-color-palette.js +23 -3
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +3 -1
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +3 -1
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography-element.js +54 -0
- package/build/components/global-styles/screen-typography-element.js.map +1 -0
- package/build/components/global-styles/screen-typography.js +74 -6
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +28 -8
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +12 -0
- package/build/components/global-styles/ui.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/keyboard-shortcuts/index.js +26 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/list/actions/index.js +104 -0
- package/build/components/list/actions/index.js.map +1 -0
- package/build/components/list/actions/rename-menu-item.js +112 -0
- package/build/components/list/actions/rename-menu-item.js.map +1 -0
- package/build/components/list/added-by.js +180 -0
- package/build/components/list/added-by.js.map +1 -0
- package/build/components/list/index.js +54 -7
- package/build/components/list/index.js.map +1 -1
- package/build/components/list/table.js +58 -68
- package/build/components/list/table.js.map +1 -1
- package/build/components/list/use-register-shortcuts.js +52 -0
- package/build/components/list/use-register-shortcuts.js.map +1 -0
- package/build/components/navigation-sidebar/index.js +24 -9
- package/build/components/navigation-sidebar/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +35 -17
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-toggle/index.js +14 -5
- package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build/components/template-details/edit-template-title.js +33 -0
- package/build/components/template-details/edit-template-title.js.map +1 -0
- package/build/components/template-details/index.js +8 -4
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-areas.js +1 -1
- package/build/components/template-details/template-areas.js.map +1 -1
- package/build/index.js +8 -2
- package/build/index.js.map +1 -1
- package/build/store/actions.js +47 -18
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +25 -5
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +30 -17
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +40 -24
- package/build-module/components/add-new-template/new-template.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/editor/index.js +13 -7
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +29 -7
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +6 -39
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +60 -0
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +5 -5
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/palette.js +12 -5
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +3 -1
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-color-palette.js +22 -3
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +3 -1
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +3 -1
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography-element.js +41 -0
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -0
- package/build-module/components/global-styles/screen-typography.js +70 -6
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +28 -8
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +11 -0
- package/build-module/components/global-styles/ui.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/keyboard-shortcuts/index.js +26 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/list/actions/index.js +85 -0
- package/build-module/components/list/actions/index.js.map +1 -0
- package/build-module/components/list/actions/rename-menu-item.js +101 -0
- package/build-module/components/list/actions/rename-menu-item.js.map +1 -0
- package/build-module/components/list/added-by.js +166 -0
- package/build-module/components/list/added-by.js.map +1 -0
- package/build-module/components/list/index.js +49 -8
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/list/table.js +60 -70
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/list/use-register-shortcuts.js +41 -0
- package/build-module/components/list/use-register-shortcuts.js.map +1 -0
- package/build-module/components/navigation-sidebar/index.js +22 -10
- package/build-module/components/navigation-sidebar/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +33 -18
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js +14 -6
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build-module/components/template-details/edit-template-title.js +23 -0
- package/build-module/components/template-details/edit-template-title.js.map +1 -0
- package/build-module/components/template-details/index.js +7 -4
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-areas.js +1 -1
- package/build-module/components/template-details/template-areas.js.map +1 -1
- package/build-module/index.js +8 -3
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +48 -19
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +21 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +146 -21
- package/build-style/style.css +146 -21
- package/package.json +10 -8
- package/src/components/add-new-template/new-template-part.js +32 -18
- package/src/components/add-new-template/new-template.js +39 -20
- package/src/components/block-editor/index.js +2 -0
- package/src/components/editor/index.js +17 -6
- package/src/components/global-styles/color-palette-panel.js +64 -7
- package/src/components/global-styles/global-styles-provider.js +3 -33
- package/src/components/global-styles/gradients-palette-panel.js +99 -0
- package/src/components/global-styles/hooks.js +4 -4
- package/src/components/global-styles/palette.js +30 -10
- package/src/components/global-styles/screen-background-color.js +2 -0
- package/src/components/global-styles/screen-color-palette.js +30 -3
- package/src/components/global-styles/screen-link-color.js +2 -0
- package/src/components/global-styles/screen-text-color.js +2 -0
- package/src/components/global-styles/screen-typography-element.js +39 -0
- package/src/components/global-styles/screen-typography.js +84 -3
- package/src/components/global-styles/style.scss +45 -6
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/test/utils.js +1 -1
- package/src/components/global-styles/typography-panel.js +37 -7
- package/src/components/global-styles/ui.js +9 -0
- package/src/components/global-styles/use-global-styles-output.js +2 -2
- package/src/components/global-styles/utils.js +1 -1
- package/src/components/keyboard-shortcuts/index.js +32 -0
- package/src/components/list/actions/index.js +95 -0
- package/src/components/list/actions/rename-menu-item.js +134 -0
- package/src/components/list/added-by.js +179 -0
- package/src/components/list/index.js +63 -5
- package/src/components/list/style.scss +106 -11
- package/src/components/list/table.js +65 -76
- package/src/components/list/use-register-shortcuts.js +45 -0
- package/src/components/navigation-sidebar/index.js +21 -12
- package/src/components/navigation-sidebar/navigation-panel/index.js +32 -15
- package/src/components/navigation-sidebar/navigation-toggle/index.js +29 -17
- package/src/components/navigation-sidebar/navigation-toggle/test/index.js +2 -0
- package/src/components/sidebar/style.scss +2 -1
- package/src/components/template-details/edit-template-title.js +28 -0
- package/src/components/template-details/index.js +15 -10
- package/src/components/template-details/template-areas.js +1 -1
- package/src/index.js +10 -2
- package/src/store/actions.js +82 -34
- package/src/store/selectors.js +22 -4
- package/src/store/test/actions.js +0 -24
- package/src/store/test/selectors.js +24 -0
|
@@ -11,12 +11,18 @@ var _element = require("@wordpress/element");
|
|
|
11
11
|
|
|
12
12
|
var _lodash = require("lodash");
|
|
13
13
|
|
|
14
|
+
var _data = require("@wordpress/data");
|
|
15
|
+
|
|
14
16
|
var _components = require("@wordpress/components");
|
|
15
17
|
|
|
16
18
|
var _url = require("@wordpress/url");
|
|
17
19
|
|
|
18
20
|
var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
|
|
19
21
|
|
|
22
|
+
var _i18n = require("@wordpress/i18n");
|
|
23
|
+
|
|
24
|
+
var _notices = require("@wordpress/notices");
|
|
25
|
+
|
|
20
26
|
var _createTemplatePartModal = _interopRequireDefault(require("../create-template-part-modal"));
|
|
21
27
|
|
|
22
28
|
/**
|
|
@@ -35,6 +41,9 @@ function NewTemplatePart(_ref) {
|
|
|
35
41
|
postType
|
|
36
42
|
} = _ref;
|
|
37
43
|
const [isModalOpen, setIsModalOpen] = (0, _element.useState)(false);
|
|
44
|
+
const {
|
|
45
|
+
createErrorNotice
|
|
46
|
+
} = (0, _data.useDispatch)(_notices.store);
|
|
38
47
|
|
|
39
48
|
async function createTemplatePart(_ref2) {
|
|
40
49
|
let {
|
|
@@ -43,27 +52,34 @@ function NewTemplatePart(_ref) {
|
|
|
43
52
|
} = _ref2;
|
|
44
53
|
|
|
45
54
|
if (!title) {
|
|
55
|
+
createErrorNotice((0, _i18n.__)('Title is not defined.'), {
|
|
56
|
+
type: 'snackbar'
|
|
57
|
+
});
|
|
46
58
|
return;
|
|
47
59
|
}
|
|
48
60
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
try {
|
|
62
|
+
const templatePart = await (0, _apiFetch.default)({
|
|
63
|
+
path: '/wp/v2/template-parts',
|
|
64
|
+
method: 'POST',
|
|
65
|
+
data: {
|
|
66
|
+
slug: (0, _lodash.kebabCase)(title),
|
|
67
|
+
title,
|
|
68
|
+
content: '',
|
|
69
|
+
area
|
|
70
|
+
}
|
|
71
|
+
}); // Navigate to the created template part editor.
|
|
72
|
+
|
|
73
|
+
window.location.href = (0, _url.addQueryArgs)(window.location.href, {
|
|
74
|
+
postId: templatePart.id,
|
|
75
|
+
postType: 'wp_template_part'
|
|
76
|
+
});
|
|
77
|
+
} catch (error) {
|
|
78
|
+
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while creating the template part.');
|
|
79
|
+
createErrorNotice(errorMessage, {
|
|
80
|
+
type: 'snackbar'
|
|
81
|
+
});
|
|
82
|
+
}
|
|
67
83
|
}
|
|
68
84
|
|
|
69
85
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.Button, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template-part.js"],"names":["NewTemplatePart","postType","isModalOpen","setIsModalOpen","createTemplatePart","title","area","templatePart","path","method","data","slug","content","window","location","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template-part.js"],"names":["NewTemplatePart","postType","isModalOpen","setIsModalOpen","createErrorNotice","noticesStore","createTemplatePart","title","area","type","templatePart","path","method","data","slug","content","window","location","href","postId","id","error","errorMessage","message","code","labels","add_new"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;AAGe,SAASA,eAAT,OAAyC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACvD,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,KAAV,CAAxC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAwB,uBAAaC,cAAb,CAA9B;;AAEA,iBAAeC,kBAAf,QAAqD;AAAA,QAAlB;AAAEC,MAAAA,KAAF;AAASC,MAAAA;AAAT,KAAkB;;AACpD,QAAK,CAAED,KAAP,EAAe;AACdH,MAAAA,iBAAiB,CAAE,cAAI,uBAAJ,CAAF,EAAiC;AACjDK,QAAAA,IAAI,EAAE;AAD2C,OAAjC,CAAjB;AAGA;AACA;;AAED,QAAI;AACH,YAAMC,YAAY,GAAG,MAAM,uBAAU;AACpCC,QAAAA,IAAI,EAAE,uBAD8B;AAEpCC,QAAAA,MAAM,EAAE,MAF4B;AAGpCC,QAAAA,IAAI,EAAE;AACLC,UAAAA,IAAI,EAAE,uBAAWP,KAAX,CADD;AAELA,UAAAA,KAFK;AAGLQ,UAAAA,OAAO,EAAE,EAHJ;AAILP,UAAAA;AAJK;AAH8B,OAAV,CAA3B,CADG,CAYH;;AACAQ,MAAAA,MAAM,CAACC,QAAP,CAAgBC,IAAhB,GAAuB,uBAAcF,MAAM,CAACC,QAAP,CAAgBC,IAA9B,EAAoC;AAC1DC,QAAAA,MAAM,EAAET,YAAY,CAACU,EADqC;AAE1DnB,QAAAA,QAAQ,EAAE;AAFgD,OAApC,CAAvB;AAIA,KAjBD,CAiBE,OAAQoB,KAAR,EAAgB;AACjB,YAAMC,YAAY,GACjBD,KAAK,CAACE,OAAN,IAAiBF,KAAK,CAACG,IAAN,KAAe,eAAhC,GACGH,KAAK,CAACE,OADT,GAEG,cACA,qDADA,CAHJ;AAOAnB,MAAAA,iBAAiB,CAAEkB,YAAF,EAAgB;AAAEb,QAAAA,IAAI,EAAE;AAAR,OAAhB,CAAjB;AACA;AACD;;AAED,SACC,qDACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfN,MAAAA,cAAc,CAAE,IAAF,CAAd;AACA;AAJF,KAMGF,QAAQ,CAACwB,MAAT,CAAgBC,OANnB,CADD,EASGxB,WAAW,IACZ,4BAAC,gCAAD;AACC,IAAA,UAAU,EAAG,MAAMC,cAAc,CAAE,KAAF,CADlC;AAEC,IAAA,QAAQ,EAAGG;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 { useDispatch } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\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\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tasync function createTemplatePart( { title, area } ) {\n\t\tif ( ! title ) {\n\t\t\tcreateErrorNotice( __( 'Title is not defined.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst templatePart = await apiFetch( {\n\t\t\t\tpath: '/wp/v2/template-parts',\n\t\t\t\tmethod: 'POST',\n\t\t\t\tdata: {\n\t\t\t\t\tslug: kebabCase( title ),\n\t\t\t\t\ttitle,\n\t\t\t\t\tcontent: '',\n\t\t\t\t\tarea,\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\t// Navigate to the created template part editor.\n\t\t\twindow.location.href = addQueryArgs( window.location.href, {\n\t\t\t\tpostId: templatePart.id,\n\t\t\t\tpostType: 'wp_template_part',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while creating the template part.'\n\t\t\t\t\t );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\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"]}
|
|
@@ -23,6 +23,10 @@ var _url = require("@wordpress/url");
|
|
|
23
23
|
|
|
24
24
|
var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
|
|
25
25
|
|
|
26
|
+
var _i18n = require("@wordpress/i18n");
|
|
27
|
+
|
|
28
|
+
var _notices = require("@wordpress/notices");
|
|
29
|
+
|
|
26
30
|
/**
|
|
27
31
|
* External dependencies
|
|
28
32
|
*/
|
|
@@ -40,37 +44,51 @@ function NewTemplate(_ref) {
|
|
|
40
44
|
templates,
|
|
41
45
|
defaultTemplateTypes
|
|
42
46
|
} = (0, _data.useSelect)(select => ({
|
|
43
|
-
templates: select(_coreData.store).getEntityRecords('postType', 'wp_template'
|
|
47
|
+
templates: select(_coreData.store).getEntityRecords('postType', 'wp_template', {
|
|
48
|
+
per_page: -1
|
|
49
|
+
}),
|
|
44
50
|
defaultTemplateTypes: select(_editor.store).__experimentalGetDefaultTemplateTypes()
|
|
45
51
|
}), []);
|
|
52
|
+
const {
|
|
53
|
+
createErrorNotice
|
|
54
|
+
} = (0, _data.useDispatch)(_notices.store);
|
|
46
55
|
|
|
47
56
|
async function createTemplate(_ref2) {
|
|
48
57
|
let {
|
|
49
58
|
slug
|
|
50
59
|
} = _ref2;
|
|
51
|
-
const {
|
|
52
|
-
title,
|
|
53
|
-
description
|
|
54
|
-
} = (0, _lodash.find)(defaultTemplateTypes, {
|
|
55
|
-
slug
|
|
56
|
-
});
|
|
57
|
-
const template = await (0, _apiFetch.default)({
|
|
58
|
-
path: '/wp/v2/templates',
|
|
59
|
-
method: 'POST',
|
|
60
|
-
data: {
|
|
61
|
-
excerpt: description,
|
|
62
|
-
// Slugs need to be strings, so this is for template `404`
|
|
63
|
-
slug: slug.toString(),
|
|
64
|
-
status: 'publish',
|
|
65
|
-
title
|
|
66
|
-
}
|
|
67
|
-
}); // Navigate to the created template editor.
|
|
68
60
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
61
|
+
try {
|
|
62
|
+
const {
|
|
63
|
+
title,
|
|
64
|
+
description
|
|
65
|
+
} = (0, _lodash.find)(defaultTemplateTypes, {
|
|
66
|
+
slug
|
|
67
|
+
});
|
|
68
|
+
const template = await (0, _apiFetch.default)({
|
|
69
|
+
path: '/wp/v2/templates',
|
|
70
|
+
method: 'POST',
|
|
71
|
+
data: {
|
|
72
|
+
excerpt: description,
|
|
73
|
+
// Slugs need to be strings, so this is for template `404`
|
|
74
|
+
slug: slug.toString(),
|
|
75
|
+
status: 'publish',
|
|
76
|
+
title
|
|
77
|
+
}
|
|
78
|
+
}); // Navigate to the created template editor.
|
|
79
|
+
|
|
80
|
+
window.location.href = (0, _url.addQueryArgs)(window.location.href, {
|
|
81
|
+
postId: template.id,
|
|
82
|
+
postType: 'wp_template'
|
|
83
|
+
}); // Wait for async navigation to happen before closing the modal.
|
|
84
|
+
|
|
85
|
+
await new Promise(() => {});
|
|
86
|
+
} catch (error) {
|
|
87
|
+
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while creating the template.');
|
|
88
|
+
createErrorNotice(errorMessage, {
|
|
89
|
+
type: 'snackbar'
|
|
90
|
+
});
|
|
91
|
+
}
|
|
74
92
|
}
|
|
75
93
|
|
|
76
94
|
const existingTemplateSlugs = (0, _lodash.map)(templates, 'slug');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template.js"],"names":["DEFAULT_TEMPLATE_SLUGS","NewTemplate","postType","templates","defaultTemplateTypes","select","coreStore","getEntityRecords","editorStore","__experimentalGetDefaultTemplateTypes","createTemplate","slug","title","description","template","path","method","data","excerpt","toString","status","window","location","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template.js"],"names":["DEFAULT_TEMPLATE_SLUGS","NewTemplate","postType","templates","defaultTemplateTypes","select","coreStore","getEntityRecords","per_page","editorStore","__experimentalGetDefaultTemplateTypes","createErrorNotice","noticesStore","createTemplate","slug","title","description","template","path","method","data","excerpt","toString","status","window","location","href","postId","id","Promise","error","errorMessage","message","code","type","existingTemplateSlugs","missingTemplates","length","labels","add_new","add_new_item","noArrow","variant"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;AAeA,MAAMA,sBAAsB,GAAG,CAC9B,YAD8B,EAE9B,aAF8B,EAG9B,MAH8B,EAI9B,SAJ8B,EAK9B,QAL8B,EAM9B,KAN8B,EAO9B,OAP8B,CAA/B;;AAUe,SAASC,WAAT,OAAqC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACnD,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAAsC,qBACzCC,MAAF,KAAgB;AACfF,IAAAA,SAAS,EAAEE,MAAM,CAAEC,eAAF,CAAN,CAAoBC,gBAApB,CACV,UADU,EAEV,aAFU,EAGV;AAAEC,MAAAA,QAAQ,EAAE,CAAC;AAAb,KAHU,CADI;AAMfJ,IAAAA,oBAAoB,EAAEC,MAAM,CAC3BI,aAD2B,CAAN,CAEpBC,qCAFoB;AANP,GAAhB,CAD2C,EAW3C,EAX2C,CAA5C;AAaA,QAAM;AAAEC,IAAAA;AAAF,MAAwB,uBAAaC,cAAb,CAA9B;;AAEA,iBAAeC,cAAf,QAA0C;AAAA,QAAX;AAAEC,MAAAA;AAAF,KAAW;;AACzC,QAAI;AACH,YAAM;AAAEC,QAAAA,KAAF;AAASC,QAAAA;AAAT,UAAyB,kBAAMZ,oBAAN,EAA4B;AAC1DU,QAAAA;AAD0D,OAA5B,CAA/B;AAIA,YAAMG,QAAQ,GAAG,MAAM,uBAAU;AAChCC,QAAAA,IAAI,EAAE,kBAD0B;AAEhCC,QAAAA,MAAM,EAAE,MAFwB;AAGhCC,QAAAA,IAAI,EAAE;AACLC,UAAAA,OAAO,EAAEL,WADJ;AAEL;AACAF,UAAAA,IAAI,EAAEA,IA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,EAAE;AADK,KALhB;AAQC,IAAA,WAAW,EAAG;AACbC,MAAAA,OAAO,EAAE;AADI;AARf,KAYG,MACD,4BAAC,yBAAD;AAAe,IAAA,SAAS,EAAC;AAAzB,KACC,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAGxC,QAAQ,CAACoC,MAAT,CAAgBE;AAAnC,KACG,iBACDJ,gBADC,EAED;AAAA,QAAE;AAAErB,MAAAA,KAAF;AAASC,MAAAA,WAAT;AAAsBF,MAAAA;AAAtB,KAAF;AAAA,WACC,4BAAC,oBAAD;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,GAFC,CADH,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, useDispatch } 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';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\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\t{ per_page: -1 }\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\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tasync function createTemplate( { slug } ) {\n\t\ttry {\n\t\t\tconst { title, description } = find( defaultTemplateTypes, {\n\t\t\t\tslug,\n\t\t\t} );\n\n\t\t\tconst template = await apiFetch( {\n\t\t\t\tpath: '/wp/v2/templates',\n\t\t\t\tmethod: 'POST',\n\t\t\t\tdata: {\n\t\t\t\t\texcerpt: description,\n\t\t\t\t\t// Slugs need to be strings, so this is for template `404`\n\t\t\t\t\tslug: slug.toString(),\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\ttitle,\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\t// Navigate to the created template editor.\n\t\t\twindow.location.href = addQueryArgs( window.location.href, {\n\t\t\t\tpostId: template.id,\n\t\t\t\tpostType: 'wp_template',\n\t\t\t} );\n\n\t\t\t// Wait for async navigation to happen before closing the modal.\n\t\t\tawait new Promise( () => {} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the template.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t}\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"]}
|
|
@@ -21,6 +21,8 @@ var _blockEditor = require("@wordpress/block-editor");
|
|
|
21
21
|
|
|
22
22
|
var _compose = require("@wordpress/compose");
|
|
23
23
|
|
|
24
|
+
var _reusableBlocks = require("@wordpress/reusable-blocks");
|
|
25
|
+
|
|
24
26
|
var _templatePartConverter = _interopRequireDefault(require("../template-part-converter"));
|
|
25
27
|
|
|
26
28
|
var _navigateToLink = _interopRequireDefault(require("../navigate-to-link"));
|
|
@@ -125,6 +127,6 @@ function BlockEditor(_ref) {
|
|
|
125
127
|
return (0, _element.createElement)(_blockInspectorButton.default, {
|
|
126
128
|
onClick: onClose
|
|
127
129
|
});
|
|
128
|
-
})));
|
|
130
|
+
})), (0, _element.createElement)(_reusableBlocks.ReusableBlocksMenuItems, null));
|
|
129
131
|
}
|
|
130
132
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/index.js"],"names":["LAYOUT","type","alignments","BlockEditor","setIsInserterOpen","settings","templateType","templateId","page","select","getSettings","getEditedPostType","getEditedPostId","getPage","editSiteStore","blocks","onInput","onChange","setPage","contentRef","mergedRefs","isMobileViewport","clearSelectedBlock","blockEditorStore","isTemplatePart","fillProps","event","target","currentTarget","onClose"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AACA;;AAUA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/index.js"],"names":["LAYOUT","type","alignments","BlockEditor","setIsInserterOpen","settings","templateType","templateId","page","select","getSettings","getEditedPostType","getEditedPostId","getPage","editSiteStore","blocks","onInput","onChange","setPage","contentRef","mergedRefs","isMobileViewport","clearSelectedBlock","blockEditorStore","isTemplatePart","fillProps","event","target","currentTarget","onClose"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AACA;;AAUA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAlCA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;AAUA,MAAMA,MAAM,GAAG;AACdC,EAAAA,IAAI,EAAE,SADQ;AAEd;AACAC,EAAAA,UAAU,EAAE;AAHE,CAAf;;AAMe,SAASC,WAAT,OAA8C;AAAA,MAAxB;AAAEC,IAAAA;AAAF,GAAwB;AAC5D,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,YAAZ;AAA0BC,IAAAA,UAA1B;AAAsCC,IAAAA;AAAtC,MAA+C,qBAClDC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,WADK;AAELC,MAAAA,iBAFK;AAGLC,MAAAA,eAHK;AAILC,MAAAA;AAJK,QAKF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,yBAAZ,EAAuC;AAClD,uBAAiBgB;AADiC,KAAvC,CADb;AAIC,IAAA,oBAAoB,EAAGL,UAJxB;AAKC,IAAA,OAAO,EAAKO,KAAF,IAAa;AACtB;AACA,UAAKA,KAAK,CAACC,MAAN,KAAiBD,KAAK,CAACE,aAA5B,EAA4C;AAC3CN,QAAAA,kBAAkB;AAClB;AACD;AAVF,KAYC,4BAAC,mBAAD,OAZD,EAcC,4BAAC,wBAAD,CACC;AADD;AAEC,IAAA,GAAG,EAAGf,UAFP;AAGC,IAAA,cAAc,EACbiB,cAAc,IACd;AACA,KAAEH,gBANJ;AAQC,IAAA,QAAQ,EAAGhB,QARZ;AASC,IAAA,UAAU,EAAGe;AATd,KAWC,4BAAC,sBAAD;AACC,IAAA,SAAS,EAAC,mDADX;AAEC,IAAA,oBAAoB,EAAGpB;AAFxB,IAXD,CAdD,EA+BC,4BAAC,iDAAD,QACG;AAAA,QAAE;AAAE6B,MAAAA;AAAF,KAAF;AAAA,WACD,4BAAC,6BAAD;AAAsB,MAAA,OAAO,EAAGA;AAAhC,MADC;AAAA,GADH,CA/BD,CAxBD,EA6DC,4BAAC,uCAAD,OA7DD,CADD;AAiEA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tBlockList,\n\tBlockEditorProvider,\n\t__experimentalLinkControl,\n\tBlockInspector,\n\tBlockTools,\n\t__unstableBlockSettingsMenuFirstItem,\n\t__unstableUseTypingObserver as useTypingObserver,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useMergeRefs, useViewportMatch } from '@wordpress/compose';\nimport { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartConverter from '../template-part-converter';\nimport NavigateToLink from '../navigate-to-link';\nimport { SidebarInspectorFill } from '../sidebar';\nimport { store as editSiteStore } from '../../store';\nimport BlockInspectorButton from './block-inspector-button';\nimport EditTemplatePartMenuButton from '../edit-template-part-menu-button';\nimport BackButton from './back-button';\nimport ResizableEditor from './resizable-editor';\n\nconst LAYOUT = {\n\ttype: 'default',\n\t// At the root level of the site editor, no alignments should be allowed.\n\talignments: [],\n};\n\nexport default function BlockEditor( { setIsInserterOpen } ) {\n\tconst { settings, templateType, templateId, page } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSettings,\n\t\t\t\tgetEditedPostType,\n\t\t\t\tgetEditedPostId,\n\t\t\t\tgetPage,\n\t\t\t} = select( editSiteStore );\n\n\t\t\treturn {\n\t\t\t\tsettings: getSettings( setIsInserterOpen ),\n\t\t\t\ttemplateType: getEditedPostType(),\n\t\t\t\ttemplateId: getEditedPostId(),\n\t\t\t\tpage: getPage(),\n\t\t\t};\n\t\t},\n\t\t[ setIsInserterOpen ]\n\t);\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\ttemplateType\n\t);\n\tconst { setPage } = useDispatch( editSiteStore );\n\tconst contentRef = useRef();\n\tconst mergedRefs = useMergeRefs( [ contentRef, useTypingObserver() ] );\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\n\tconst isTemplatePart = templateType === 'wp_template_part';\n\n\treturn (\n\t\t<BlockEditorProvider\n\t\t\tsettings={ settings }\n\t\t\tvalue={ blocks }\n\t\t\tonInput={ onInput }\n\t\t\tonChange={ onChange }\n\t\t\tuseSubRegistry={ false }\n\t\t>\n\t\t\t<EditTemplatePartMenuButton />\n\t\t\t<TemplatePartConverter />\n\t\t\t<__experimentalLinkControl.ViewerFill>\n\t\t\t\t{ useCallback(\n\t\t\t\t\t( fillProps ) => (\n\t\t\t\t\t\t<NavigateToLink\n\t\t\t\t\t\t\t{ ...fillProps }\n\t\t\t\t\t\t\tactivePage={ page }\n\t\t\t\t\t\t\tonActivePageChange={ setPage }\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\t[ page ]\n\t\t\t\t) }\n\t\t\t</__experimentalLinkControl.ViewerFill>\n\t\t\t<SidebarInspectorFill>\n\t\t\t\t<BlockInspector />\n\t\t\t</SidebarInspectorFill>\n\t\t\t<BlockTools\n\t\t\t\tclassName={ classnames( 'edit-site-visual-editor', {\n\t\t\t\t\t'is-focus-mode': isTemplatePart,\n\t\t\t\t} ) }\n\t\t\t\t__unstableContentRef={ contentRef }\n\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t// Clear selected block when clicking on the gray background.\n\t\t\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<BackButton />\n\n\t\t\t\t<ResizableEditor\n\t\t\t\t\t// Reinitialize the editor and reset the states when the template changes.\n\t\t\t\t\tkey={ templateId }\n\t\t\t\t\tenableResizing={\n\t\t\t\t\t\tisTemplatePart &&\n\t\t\t\t\t\t// Disable resizing in mobile viewport.\n\t\t\t\t\t\t! isMobileViewport\n\t\t\t\t\t}\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tcontentRef={ mergedRefs }\n\t\t\t\t>\n\t\t\t\t\t<BlockList\n\t\t\t\t\t\tclassName=\"edit-site-block-editor__block-list wp-site-blocks\"\n\t\t\t\t\t\t__experimentalLayout={ LAYOUT }\n\t\t\t\t\t/>\n\t\t\t\t</ResizableEditor>\n\n\t\t\t\t<__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<BlockInspectorButton onClick={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t</__unstableBlockSettingsMenuFirstItem>\n\t\t\t</BlockTools>\n\t\t\t<ReusableBlocksMenuItems />\n\t\t</BlockEditorProvider>\n\t);\n}\n"]}
|
|
@@ -80,7 +80,9 @@ function Editor(_ref) {
|
|
|
80
80
|
page,
|
|
81
81
|
template,
|
|
82
82
|
templateResolved,
|
|
83
|
-
isNavigationOpen
|
|
83
|
+
isNavigationOpen,
|
|
84
|
+
previousShortcut,
|
|
85
|
+
nextShortcut
|
|
84
86
|
} = (0, _data.useSelect)(select => {
|
|
85
87
|
const {
|
|
86
88
|
isInserterOpened,
|
|
@@ -108,7 +110,9 @@ function Editor(_ref) {
|
|
|
108
110
|
template: postId ? getEntityRecord('postType', postType, postId) : null,
|
|
109
111
|
templateResolved: postId ? hasFinishedResolution('getEntityRecord', ['postType', postType, postId]) : false,
|
|
110
112
|
entityId: postId,
|
|
111
|
-
isNavigationOpen: isNavigationOpened()
|
|
113
|
+
isNavigationOpen: isNavigationOpened(),
|
|
114
|
+
previousShortcut: select(_keyboardShortcuts.store).getAllShortcutKeyCombinations('core/edit-site/previous-region'),
|
|
115
|
+
nextShortcut: select(_keyboardShortcuts.store).getAllShortcutKeyCombinations('core/edit-site/next-region')
|
|
112
116
|
};
|
|
113
117
|
}, []);
|
|
114
118
|
const {
|
|
@@ -193,9 +197,7 @@ function Editor(_ref) {
|
|
|
193
197
|
sidebar: sidebarIsOpened && (0, _element.createElement)(_interface.ComplementaryArea.Slot, {
|
|
194
198
|
scope: "core/edit-site"
|
|
195
199
|
}),
|
|
196
|
-
drawer: (0, _element.createElement)(_navigationSidebar.default,
|
|
197
|
-
defaultIsOpen: false
|
|
198
|
-
}),
|
|
200
|
+
drawer: (0, _element.createElement)(_navigationSidebar.default, null),
|
|
199
201
|
header: (0, _element.createElement)(_header.default, {
|
|
200
202
|
openEntitiesSavedStates: openEntitiesSavedStates
|
|
201
203
|
}),
|
|
@@ -218,7 +220,11 @@ function Editor(_ref) {
|
|
|
218
220
|
onClick: openEntitiesSavedStates,
|
|
219
221
|
"aria-expanded": false
|
|
220
222
|
}, (0, _i18n.__)('Open save panel')))),
|
|
221
|
-
footer: (0, _element.createElement)(_blockEditor.BlockBreadcrumb, null)
|
|
223
|
+
footer: (0, _element.createElement)(_blockEditor.BlockBreadcrumb, null),
|
|
224
|
+
shortcuts: {
|
|
225
|
+
previous: previousShortcut,
|
|
226
|
+
next: nextShortcut
|
|
227
|
+
}
|
|
222
228
|
}), (0, _element.createElement)(_welcomeGuide.default, null), (0, _element.createElement)(_components.Popover.Slot, null), (0, _element.createElement)(_plugins.PluginArea, null)))))))));
|
|
223
229
|
}
|
|
224
230
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/editor/index.js"],"names":["interfaceLabels","secondarySidebar","drawer","Editor","initialSettings","onError","isInserterOpen","isListViewOpen","sidebarIsOpened","settings","entityId","templateType","page","template","templateResolved","isNavigationOpen","select","isInserterOpened","isListViewOpened","getSettings","getEditedPostType","getEditedPostId","getPage","isNavigationOpened","editSiteStore","hasFinishedResolution","getEntityRecord","coreStore","postType","postId","interfaceStore","getActiveComplementaryArea","name","updateEditorSettings","editorStore","setPage","setIsInserterOpened","updateSettings","defaultTemplateTypes","defaultTemplatePartAreas","isEntitiesSavedStatesOpen","setIsEntitiesSavedStatesOpen","openEntitiesSavedStates","closeEntitiesSavedStates","blockContext","context","queryContext","newQueryContext","document","body","classList","add","remove","isReady","siteUrl","undefined"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAMA;;AAOA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA7CA;AACA;AACA;;AA4BA;AACA;AACA;AAeA,MAAMA,eAAe,GAAG;AACvBC,EAAAA,gBAAgB,EAAE,cAAI,eAAJ,CADK;AAEvBC,EAAAA,MAAM,EAAE,cAAI,oBAAJ;AAFe,CAAxB;;AAKA,SAASC,MAAT,OAAgD;AAAA,MAA/B;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,GAA+B;AAC/C,QAAM;AACLC,IAAAA,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AAGC,MAAA,OAAO,EACND,uBAJF;AAMC,uBACC;AAPF,OAUG,cACD,iBADC,CAVH,CADD,CARF,CAtDF;AAiFC,IAAA,MAAM,EAAG,4BAAC,4BAAD;AAjFV,IALD,EAwFC,4BAAC,qBAAD,OAxFD,EAyFC,4BAAC,mBAAD,CAAS,IAAT,OAzFD,EA0FC,4BAAC,mBAAD,OA1FD,CAJD,CADD,CALD,CADD,CADD,CADD,CAHF,CADD;AAsHA;;eACcvC,M","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useMemo, useCallback } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tSlotFillProvider,\n\tPopover,\n\tButton,\n\tNotice,\n} from '@wordpress/components';\nimport { EntityProvider, store as coreStore } from '@wordpress/core-data';\nimport { BlockContextProvider, BlockBreadcrumb } from '@wordpress/block-editor';\nimport {\n\tFullscreenMode,\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport {\n\tEditorNotices,\n\tEditorSnackbars,\n\tEntitiesSavedStates,\n\tUnsavedChangesWarning,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\nimport { PluginArea } from '@wordpress/plugins';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport Header from '../header';\nimport { SidebarComplementaryAreaFills } from '../sidebar';\nimport NavigationSidebar from '../navigation-sidebar';\nimport BlockEditor from '../block-editor';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport URLQueryController from '../url-query-controller';\nimport InserterSidebar from '../secondary-sidebar/inserter-sidebar';\nimport ListViewSidebar from '../secondary-sidebar/list-view-sidebar';\nimport ErrorBoundary from '../error-boundary';\nimport WelcomeGuide from '../welcome-guide';\nimport { store as editSiteStore } from '../../store';\nimport { GlobalStylesRenderer } from './global-styles-renderer';\nimport { GlobalStylesProvider } from '../global-styles/global-styles-provider';\n\nconst interfaceLabels = {\n\tsecondarySidebar: __( 'Block Library' ),\n\tdrawer: __( 'Navigation Sidebar' ),\n};\n\nfunction Editor( { initialSettings, onError } ) {\n\tconst {\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tsidebarIsOpened,\n\t\tsettings,\n\t\tentityId,\n\t\ttemplateType,\n\t\tpage,\n\t\ttemplate,\n\t\ttemplateResolved,\n\t\tisNavigationOpen,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisInserterOpened,\n\t\t\tisListViewOpened,\n\t\t\tgetSettings,\n\t\t\tgetEditedPostType,\n\t\t\tgetEditedPostId,\n\t\t\tgetPage,\n\t\t\tisNavigationOpened,\n\t\t} = select( editSiteStore );\n\t\tconst { hasFinishedResolution, getEntityRecord } = select( coreStore );\n\t\tconst postType = getEditedPostType();\n\t\tconst postId = getEditedPostId();\n\n\t\t// The currently selected entity to display. Typically template or template part.\n\t\treturn {\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tsidebarIsOpened: !! select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( editSiteStore.name ),\n\t\t\tsettings: getSettings(),\n\t\t\ttemplateType: postType,\n\t\t\tpage: getPage(),\n\t\t\ttemplate: postId\n\t\t\t\t? getEntityRecord( 'postType', postType, postId )\n\t\t\t\t: null,\n\t\t\ttemplateResolved: postId\n\t\t\t\t? hasFinishedResolution( 'getEntityRecord', [\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tpostId,\n\t\t\t\t ] )\n\t\t\t\t: false,\n\t\t\tentityId: postId,\n\t\t\tisNavigationOpen: isNavigationOpened(),\n\t\t};\n\t}, [] );\n\tconst { updateEditorSettings } = useDispatch( editorStore );\n\tconst { setPage, setIsInserterOpened, updateSettings } = useDispatch(\n\t\teditSiteStore\n\t);\n\n\tuseEffect( () => {\n\t\tupdateSettings( initialSettings );\n\t}, [] );\n\n\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t// so that they can be selected with core/editor selectors in any editor.\n\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t// which internally uses updateEditorSettings as well.\n\tconst { defaultTemplateTypes, defaultTemplatePartAreas } = settings;\n\tuseEffect( () => {\n\t\tupdateEditorSettings( {\n\t\t\tdefaultTemplateTypes,\n\t\t\tdefaultTemplatePartAreas,\n\t\t} );\n\t}, [ defaultTemplateTypes, defaultTemplatePartAreas ] );\n\n\tconst [\n\t\tisEntitiesSavedStatesOpen,\n\t\tsetIsEntitiesSavedStatesOpen,\n\t] = useState( false );\n\tconst openEntitiesSavedStates = useCallback(\n\t\t() => setIsEntitiesSavedStatesOpen( true ),\n\t\t[]\n\t);\n\tconst closeEntitiesSavedStates = useCallback( () => {\n\t\tsetIsEntitiesSavedStatesOpen( false );\n\t}, [] );\n\n\tconst blockContext = useMemo(\n\t\t() => ( {\n\t\t\t...page?.context,\n\t\t\tqueryContext: [\n\t\t\t\tpage?.context.queryContext || { page: 1 },\n\t\t\t\t( newQueryContext ) =>\n\t\t\t\t\tsetPage( {\n\t\t\t\t\t\t...page,\n\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\t...page?.context,\n\t\t\t\t\t\t\tqueryContext: {\n\t\t\t\t\t\t\t\t...page?.context.queryContext,\n\t\t\t\t\t\t\t\t...newQueryContext,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t} ),\n\t\t\t],\n\t\t} ),\n\t\t[ page?.context ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( isNavigationOpen ) {\n\t\t\tdocument.body.classList.add( 'is-navigation-sidebar-open' );\n\t\t} else {\n\t\t\tdocument.body.classList.remove( 'is-navigation-sidebar-open' );\n\t\t}\n\t}, [ isNavigationOpen ] );\n\n\t// Don't render the Editor until the settings are set and loaded\n\tconst isReady =\n\t\tsettings?.siteUrl &&\n\t\ttemplateType !== undefined &&\n\t\tentityId !== undefined;\n\n\tconst secondarySidebar = () => {\n\t\tif ( isInserterOpen ) {\n\t\t\treturn <InserterSidebar />;\n\t\t}\n\t\tif ( isListViewOpen ) {\n\t\t\treturn <ListViewSidebar />;\n\t\t}\n\t\treturn null;\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<URLQueryController />\n\t\t\t{ isReady && (\n\t\t\t\t<ShortcutProvider>\n\t\t\t\t\t<SlotFillProvider>\n\t\t\t\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\t\t\t\ttype={ templateType }\n\t\t\t\t\t\t\t\tid={ entityId }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<GlobalStylesProvider>\n\t\t\t\t\t\t\t\t\t<BlockContextProvider\n\t\t\t\t\t\t\t\t\t\tvalue={ blockContext }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<GlobalStylesRenderer />\n\t\t\t\t\t\t\t\t\t\t<ErrorBoundary onError={ onError }>\n\t\t\t\t\t\t\t\t\t\t\t<FullscreenMode isActive />\n\t\t\t\t\t\t\t\t\t\t\t<UnsavedChangesWarning />\n\t\t\t\t\t\t\t\t\t\t\t<KeyboardShortcuts.Register />\n\t\t\t\t\t\t\t\t\t\t\t<SidebarComplementaryAreaFills />\n\t\t\t\t\t\t\t\t\t\t\t<InterfaceSkeleton\n\t\t\t\t\t\t\t\t\t\t\t\tlabels={ interfaceLabels }\n\t\t\t\t\t\t\t\t\t\t\t\tsecondarySidebar={ secondarySidebar() }\n\t\t\t\t\t\t\t\t\t\t\t\tsidebar={\n\t\t\t\t\t\t\t\t\t\t\t\t\tsidebarIsOpened && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<ComplementaryArea.Slot scope=\"core/edit-site\" />\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tdrawer={\n\t\t\t\t\t\t\t\t\t\t\t\t\t<NavigationSidebar\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdefaultIsOpen={ false }\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\theader={\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Header\n\t\t\t\t\t\t\t\t\t\t\t\t\t\topenEntitiesSavedStates={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\topenEntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tnotices={ <EditorSnackbars /> }\n\t\t\t\t\t\t\t\t\t\t\t\tcontent={\n\t\t\t\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<EditorNotices />\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ template && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<BlockEditor\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetIsInserterOpen={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetIsInserterOpened\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ templateResolved &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t! template &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsettings?.siteUrl &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tentityId && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tisDismissible={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"You attempted to edit an item that doesn't exist. Perhaps it was deleted?\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<KeyboardShortcuts\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\topenEntitiesSavedStates={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\topenEntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tactions={\n\t\t\t\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ isEntitiesSavedStatesOpen ? (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<EntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclose={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcloseEntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"edit-site-editor__toggle-save-panel\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-editor__toggle-save-panel-button\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\topenEntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taria-expanded={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Open save panel'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tfooter={ <BlockBreadcrumb /> }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<WelcomeGuide />\n\t\t\t\t\t\t\t\t\t\t\t<Popover.Slot />\n\t\t\t\t\t\t\t\t\t\t\t<PluginArea />\n\t\t\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t\t\t\t\t</GlobalStylesProvider>\n\t\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t</SlotFillProvider>\n\t\t\t\t</ShortcutProvider>\n\t\t\t) }\n\t\t</>\n\t);\n}\nexport default Editor;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/editor/index.js"],"names":["interfaceLabels","secondarySidebar","drawer","Editor","initialSettings","onError","isInserterOpen","isListViewOpen","sidebarIsOpened","settings","entityId","templateType","page","template","templateResolved","isNavigationOpen","previousShortcut","nextShortcut","select","isInserterOpened","isListViewOpened","getSettings","getEditedPostType","getEditedPostId","getPage","isNavigationOpened","editSiteStore","hasFinishedResolution","getEntityRecord","coreStore","postType","postId","interfaceStore","getActiveComplementaryArea","name","keyboardShortcutsStore","getAllShortcutKeyCombinations","updateEditorSettings","editorStore","setPage","setIsInserterOpened","updateSettings","defaultTemplateTypes","defaultTemplatePartAreas","isEntitiesSavedStatesOpen","setIsEntitiesSavedStatesOpen","openEntitiesSavedStates","closeEntitiesSavedStates","blockContext","context","queryContext","newQueryContext","document","body","classList","add","remove","isReady","siteUrl","undefined","previous","next"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAMA;;AAOA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAhDA;AACA;AACA;;AA+BA;AACA;AACA;AAeA,MAAMA,eAAe,GAAG;AACvBC,EAAAA,gBAAgB,EAAE,cAAI,eAAJ,CADK;AAEvBC,EAAAA,MAAM,EAAE,cAAI,oBAAJ;AAFe,CAAxB;;AAKA,SAASC,MAAT,OAAgD;AAAA,MAA/B;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,GAA+B;AAC/C,QAAM;AACLC,IAAAA,cADK;AAELC,IAAAA,cAFK;AAGLC,IAAAA,eAHK;AAILC,IAAAA,QAJK;AAKLC,IAAAA,QALK;AAMLC,IAAAA,YANK;AAOLC,IAAAA,IAPK;AAQLC,IAAAA,QARK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,4BAAC,kBAAD;AACC,MAAA,OAAO,EAAC,WADT;AAEC,MAAA,SAAS,EAAC,4CAFX;AAGC,MAAA,OAAO,EACND,uBAJF;AAMC,uBACC;AAPF,OAUG,cACD,iBADC,CAVH,CADD,CARF,CAlDF;AA6EC,IAAA,MAAM,EAAG,4BAAC,4BAAD,OA7EV;AA8EC,IAAA,SAAS,EAAG;AACXc,MAAAA,QAAQ,EAAE5C,gBADC;AAEX6C,MAAAA,IAAI,EAAE5C;AAFK;AA9Eb,IALD,EAwFC,4BAAC,qBAAD,OAxFD,EAyFC,4BAAC,mBAAD,CAAS,IAAT,OAzFD,EA0FC,4BAAC,mBAAD,OA1FD,CAJD,CADD,CALD,CADD,CADD,CADD,CAHF,CADD;AAsHA;;eACcd,M","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useMemo, useCallback } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tSlotFillProvider,\n\tPopover,\n\tButton,\n\tNotice,\n} from '@wordpress/components';\nimport { EntityProvider, store as coreStore } from '@wordpress/core-data';\nimport { BlockContextProvider, BlockBreadcrumb } from '@wordpress/block-editor';\nimport {\n\tFullscreenMode,\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport {\n\tEditorNotices,\n\tEditorSnackbars,\n\tEntitiesSavedStates,\n\tUnsavedChangesWarning,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\nimport { PluginArea } from '@wordpress/plugins';\nimport {\n\tShortcutProvider,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport Header from '../header';\nimport { SidebarComplementaryAreaFills } from '../sidebar';\nimport NavigationSidebar from '../navigation-sidebar';\nimport BlockEditor from '../block-editor';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport URLQueryController from '../url-query-controller';\nimport InserterSidebar from '../secondary-sidebar/inserter-sidebar';\nimport ListViewSidebar from '../secondary-sidebar/list-view-sidebar';\nimport ErrorBoundary from '../error-boundary';\nimport WelcomeGuide from '../welcome-guide';\nimport { store as editSiteStore } from '../../store';\nimport { GlobalStylesRenderer } from './global-styles-renderer';\nimport { GlobalStylesProvider } from '../global-styles/global-styles-provider';\n\nconst interfaceLabels = {\n\tsecondarySidebar: __( 'Block Library' ),\n\tdrawer: __( 'Navigation Sidebar' ),\n};\n\nfunction Editor( { initialSettings, onError } ) {\n\tconst {\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tsidebarIsOpened,\n\t\tsettings,\n\t\tentityId,\n\t\ttemplateType,\n\t\tpage,\n\t\ttemplate,\n\t\ttemplateResolved,\n\t\tisNavigationOpen,\n\t\tpreviousShortcut,\n\t\tnextShortcut,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisInserterOpened,\n\t\t\tisListViewOpened,\n\t\t\tgetSettings,\n\t\t\tgetEditedPostType,\n\t\t\tgetEditedPostId,\n\t\t\tgetPage,\n\t\t\tisNavigationOpened,\n\t\t} = select( editSiteStore );\n\t\tconst { hasFinishedResolution, getEntityRecord } = select( coreStore );\n\t\tconst postType = getEditedPostType();\n\t\tconst postId = getEditedPostId();\n\n\t\t// The currently selected entity to display. Typically template or template part.\n\t\treturn {\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tsidebarIsOpened: !! select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( editSiteStore.name ),\n\t\t\tsettings: getSettings(),\n\t\t\ttemplateType: postType,\n\t\t\tpage: getPage(),\n\t\t\ttemplate: postId\n\t\t\t\t? getEntityRecord( 'postType', postType, postId )\n\t\t\t\t: null,\n\t\t\ttemplateResolved: postId\n\t\t\t\t? hasFinishedResolution( 'getEntityRecord', [\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tpostId,\n\t\t\t\t ] )\n\t\t\t\t: false,\n\t\t\tentityId: postId,\n\t\t\tisNavigationOpen: isNavigationOpened(),\n\t\t\tpreviousShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations( 'core/edit-site/previous-region' ),\n\t\t\tnextShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),\n\t\t};\n\t}, [] );\n\tconst { updateEditorSettings } = useDispatch( editorStore );\n\tconst { setPage, setIsInserterOpened, updateSettings } = useDispatch(\n\t\teditSiteStore\n\t);\n\n\tuseEffect( () => {\n\t\tupdateSettings( initialSettings );\n\t}, [] );\n\n\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t// so that they can be selected with core/editor selectors in any editor.\n\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t// which internally uses updateEditorSettings as well.\n\tconst { defaultTemplateTypes, defaultTemplatePartAreas } = settings;\n\tuseEffect( () => {\n\t\tupdateEditorSettings( {\n\t\t\tdefaultTemplateTypes,\n\t\t\tdefaultTemplatePartAreas,\n\t\t} );\n\t}, [ defaultTemplateTypes, defaultTemplatePartAreas ] );\n\n\tconst [\n\t\tisEntitiesSavedStatesOpen,\n\t\tsetIsEntitiesSavedStatesOpen,\n\t] = useState( false );\n\tconst openEntitiesSavedStates = useCallback(\n\t\t() => setIsEntitiesSavedStatesOpen( true ),\n\t\t[]\n\t);\n\tconst closeEntitiesSavedStates = useCallback( () => {\n\t\tsetIsEntitiesSavedStatesOpen( false );\n\t}, [] );\n\n\tconst blockContext = useMemo(\n\t\t() => ( {\n\t\t\t...page?.context,\n\t\t\tqueryContext: [\n\t\t\t\tpage?.context.queryContext || { page: 1 },\n\t\t\t\t( newQueryContext ) =>\n\t\t\t\t\tsetPage( {\n\t\t\t\t\t\t...page,\n\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\t...page?.context,\n\t\t\t\t\t\t\tqueryContext: {\n\t\t\t\t\t\t\t\t...page?.context.queryContext,\n\t\t\t\t\t\t\t\t...newQueryContext,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t} ),\n\t\t\t],\n\t\t} ),\n\t\t[ page?.context ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( isNavigationOpen ) {\n\t\t\tdocument.body.classList.add( 'is-navigation-sidebar-open' );\n\t\t} else {\n\t\t\tdocument.body.classList.remove( 'is-navigation-sidebar-open' );\n\t\t}\n\t}, [ isNavigationOpen ] );\n\n\t// Don't render the Editor until the settings are set and loaded\n\tconst isReady =\n\t\tsettings?.siteUrl &&\n\t\ttemplateType !== undefined &&\n\t\tentityId !== undefined;\n\n\tconst secondarySidebar = () => {\n\t\tif ( isInserterOpen ) {\n\t\t\treturn <InserterSidebar />;\n\t\t}\n\t\tif ( isListViewOpen ) {\n\t\t\treturn <ListViewSidebar />;\n\t\t}\n\t\treturn null;\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<URLQueryController />\n\t\t\t{ isReady && (\n\t\t\t\t<ShortcutProvider>\n\t\t\t\t\t<SlotFillProvider>\n\t\t\t\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\t\t\t\ttype={ templateType }\n\t\t\t\t\t\t\t\tid={ entityId }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<GlobalStylesProvider>\n\t\t\t\t\t\t\t\t\t<BlockContextProvider\n\t\t\t\t\t\t\t\t\t\tvalue={ blockContext }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<GlobalStylesRenderer />\n\t\t\t\t\t\t\t\t\t\t<ErrorBoundary onError={ onError }>\n\t\t\t\t\t\t\t\t\t\t\t<FullscreenMode isActive />\n\t\t\t\t\t\t\t\t\t\t\t<UnsavedChangesWarning />\n\t\t\t\t\t\t\t\t\t\t\t<KeyboardShortcuts.Register />\n\t\t\t\t\t\t\t\t\t\t\t<SidebarComplementaryAreaFills />\n\t\t\t\t\t\t\t\t\t\t\t<InterfaceSkeleton\n\t\t\t\t\t\t\t\t\t\t\t\tlabels={ interfaceLabels }\n\t\t\t\t\t\t\t\t\t\t\t\tsecondarySidebar={ secondarySidebar() }\n\t\t\t\t\t\t\t\t\t\t\t\tsidebar={\n\t\t\t\t\t\t\t\t\t\t\t\t\tsidebarIsOpened && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<ComplementaryArea.Slot scope=\"core/edit-site\" />\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tdrawer={ <NavigationSidebar /> }\n\t\t\t\t\t\t\t\t\t\t\t\theader={\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Header\n\t\t\t\t\t\t\t\t\t\t\t\t\t\topenEntitiesSavedStates={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\topenEntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tnotices={ <EditorSnackbars /> }\n\t\t\t\t\t\t\t\t\t\t\t\tcontent={\n\t\t\t\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<EditorNotices />\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ template && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<BlockEditor\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetIsInserterOpen={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetIsInserterOpened\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ templateResolved &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t! template &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsettings?.siteUrl &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tentityId && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tisDismissible={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"You attempted to edit an item that doesn't exist. Perhaps it was deleted?\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<KeyboardShortcuts\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\topenEntitiesSavedStates={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\topenEntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tactions={\n\t\t\t\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ isEntitiesSavedStatesOpen ? (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<EntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclose={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcloseEntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"edit-site-editor__toggle-save-panel\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-editor__toggle-save-panel-button\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\topenEntitiesSavedStates\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taria-expanded={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Open save panel'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tfooter={ <BlockBreadcrumb /> }\n\t\t\t\t\t\t\t\t\t\t\t\tshortcuts={ {\n\t\t\t\t\t\t\t\t\t\t\t\t\tprevious: previousShortcut,\n\t\t\t\t\t\t\t\t\t\t\t\t\tnext: nextShortcut,\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<WelcomeGuide />\n\t\t\t\t\t\t\t\t\t\t\t<Popover.Slot />\n\t\t\t\t\t\t\t\t\t\t\t<PluginArea />\n\t\t\t\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t\t\t\t\t</GlobalStylesProvider>\n\t\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t</SlotFillProvider>\n\t\t\t\t</ShortcutProvider>\n\t\t\t) }\n\t\t</>\n\t);\n}\nexport default Editor;\n"]}
|
|
@@ -9,6 +9,8 @@ var _element = require("@wordpress/element");
|
|
|
9
9
|
|
|
10
10
|
var _components = require("@wordpress/components");
|
|
11
11
|
|
|
12
|
+
var _i18n = require("@wordpress/i18n");
|
|
13
|
+
|
|
12
14
|
var _hooks = require("./hooks");
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -22,12 +24,33 @@ function ColorPalettePanel(_ref) {
|
|
|
22
24
|
let {
|
|
23
25
|
name
|
|
24
26
|
} = _ref;
|
|
25
|
-
const [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const [themeColors, setThemeColors] = (0, _hooks.useSetting)('color.palette.theme', name);
|
|
28
|
+
const [baseThemeColors] = (0, _hooks.useSetting)('color.palette.theme', name, 'base');
|
|
29
|
+
const [defaultColors, setDefaultColors] = (0, _hooks.useSetting)('color.palette.default', name);
|
|
30
|
+
const [baseDefaultColors] = (0, _hooks.useSetting)('color.palette.default', name, 'base');
|
|
31
|
+
const [customColors, setCustomColors] = (0, _hooks.useSetting)('color.palette.custom', name);
|
|
32
|
+
const [defaultPaletteEnabled] = (0, _hooks.useSetting)('color.defaultPalette', name);
|
|
33
|
+
return (0, _element.createElement)(_components.__experimentalVStack, {
|
|
34
|
+
className: "edit-site-global-styles-color-palette-panel",
|
|
35
|
+
spacing: 10
|
|
36
|
+
}, !!themeColors && !!themeColors.length && (0, _element.createElement)(_components.__experimentalPaletteEdit, {
|
|
37
|
+
canReset: themeColors !== baseThemeColors,
|
|
38
|
+
canOnlyChangeValues: true,
|
|
39
|
+
colors: themeColors,
|
|
40
|
+
onChange: setThemeColors,
|
|
41
|
+
paletteLabel: (0, _i18n.__)('Theme')
|
|
42
|
+
}), !!defaultColors && !!defaultColors.length && !!defaultPaletteEnabled && (0, _element.createElement)(_components.__experimentalPaletteEdit, {
|
|
43
|
+
canReset: defaultColors !== baseDefaultColors,
|
|
44
|
+
canOnlyChangeValues: true,
|
|
45
|
+
colors: defaultColors,
|
|
46
|
+
onChange: setDefaultColors,
|
|
47
|
+
paletteLabel: (0, _i18n.__)('Default')
|
|
48
|
+
}), (0, _element.createElement)(_components.__experimentalPaletteEdit, {
|
|
49
|
+
colors: customColors,
|
|
50
|
+
onChange: setCustomColors,
|
|
51
|
+
paletteLabel: (0, _i18n.__)('Custom'),
|
|
52
|
+
emptyMessage: (0, _i18n.__)('Custom colors are empty! Add some colors to create your own color palette.'),
|
|
53
|
+
slugPrefix: "custom-"
|
|
31
54
|
}));
|
|
32
55
|
}
|
|
33
56
|
//# sourceMappingURL=color-palette-panel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/color-palette-panel.js"],"names":["ColorPalettePanel","name","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/color-palette-panel.js"],"names":["ColorPalettePanel","name","themeColors","setThemeColors","baseThemeColors","defaultColors","setDefaultColors","baseDefaultColors","customColors","setCustomColors","defaultPaletteEnabled","length"],"mappings":";;;;;;;;;AAGA;;AAIA;;AAK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I,SAAJ;AALhB,IAhBH,EAwBC,4BAAC,qCAAD;AACC,IAAA,MAAM,EAAGE,YADV;AAEC,IAAA,QAAQ,EAAGC,eAFZ;AAGC,IAAA,YAAY,EAAG,cAAI,QAAJ,CAHhB;AAIC,IAAA,YAAY,EAAG,cACd,4EADc,CAJhB;AAOC,IAAA,UAAU,EAAC;AAPZ,IAxBD,CADD;AAoCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalPaletteEdit as PaletteEdit,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSetting } from './hooks';\n\nexport default function ColorPalettePanel( { name } ) {\n\tconst [ themeColors, setThemeColors ] = useSetting(\n\t\t'color.palette.theme',\n\t\tname\n\t);\n\tconst [ baseThemeColors ] = useSetting(\n\t\t'color.palette.theme',\n\t\tname,\n\t\t'base'\n\t);\n\tconst [ defaultColors, setDefaultColors ] = useSetting(\n\t\t'color.palette.default',\n\t\tname\n\t);\n\tconst [ baseDefaultColors ] = useSetting(\n\t\t'color.palette.default',\n\t\tname,\n\t\t'base'\n\t);\n\tconst [ customColors, setCustomColors ] = useSetting(\n\t\t'color.palette.custom',\n\t\tname\n\t);\n\n\tconst [ defaultPaletteEnabled ] = useSetting(\n\t\t'color.defaultPalette',\n\t\tname\n\t);\n\treturn (\n\t\t<VStack\n\t\t\tclassName=\"edit-site-global-styles-color-palette-panel\"\n\t\t\tspacing={ 10 }\n\t\t>\n\t\t\t{ !! themeColors && !! themeColors.length && (\n\t\t\t\t<PaletteEdit\n\t\t\t\t\tcanReset={ themeColors !== baseThemeColors }\n\t\t\t\t\tcanOnlyChangeValues\n\t\t\t\t\tcolors={ themeColors }\n\t\t\t\t\tonChange={ setThemeColors }\n\t\t\t\t\tpaletteLabel={ __( 'Theme' ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ !! defaultColors &&\n\t\t\t\t!! defaultColors.length &&\n\t\t\t\t!! defaultPaletteEnabled && (\n\t\t\t\t\t<PaletteEdit\n\t\t\t\t\t\tcanReset={ defaultColors !== baseDefaultColors }\n\t\t\t\t\t\tcanOnlyChangeValues\n\t\t\t\t\t\tcolors={ defaultColors }\n\t\t\t\t\t\tonChange={ setDefaultColors }\n\t\t\t\t\t\tpaletteLabel={ __( 'Default' ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t<PaletteEdit\n\t\t\t\tcolors={ customColors }\n\t\t\t\tonChange={ setCustomColors }\n\t\t\t\tpaletteLabel={ __( 'Custom' ) }\n\t\t\t\temptyMessage={ __(\n\t\t\t\t\t'Custom colors are empty! Add some colors to create your own color palette.'\n\t\t\t\t) }\n\t\t\t\tslugPrefix=\"custom-\"\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"]}
|
|
@@ -13,8 +13,6 @@ var _data = require("@wordpress/data");
|
|
|
13
13
|
|
|
14
14
|
var _coreData = require("@wordpress/core-data");
|
|
15
15
|
|
|
16
|
-
var _utils = require("./utils");
|
|
17
|
-
|
|
18
16
|
var _context = require("./context");
|
|
19
17
|
|
|
20
18
|
/**
|
|
@@ -41,42 +39,6 @@ function mergeBaseAndUserConfigs(base, user) {
|
|
|
41
39
|
return (0, _lodash.mergeWith)({}, base, user, mergeTreesCustomizer);
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
function addUserOriginToSettings(settingsToAdd) {
|
|
45
|
-
const newSettings = (0, _lodash.cloneDeep)(settingsToAdd);
|
|
46
|
-
|
|
47
|
-
_utils.PRESET_METADATA.forEach(_ref => {
|
|
48
|
-
let {
|
|
49
|
-
path
|
|
50
|
-
} = _ref;
|
|
51
|
-
const presetData = (0, _lodash.get)(newSettings, path);
|
|
52
|
-
|
|
53
|
-
if (presetData) {
|
|
54
|
-
(0, _lodash.set)(newSettings, path, {
|
|
55
|
-
user: presetData
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
return newSettings;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function removeUserOriginFromSettings(settingsToRemove) {
|
|
64
|
-
const newSettings = (0, _lodash.cloneDeep)(settingsToRemove);
|
|
65
|
-
|
|
66
|
-
_utils.PRESET_METADATA.forEach(_ref2 => {
|
|
67
|
-
let {
|
|
68
|
-
path
|
|
69
|
-
} = _ref2;
|
|
70
|
-
const presetData = (0, _lodash.get)(newSettings, path);
|
|
71
|
-
|
|
72
|
-
if (presetData) {
|
|
73
|
-
(0, _lodash.set)(newSettings, path, (presetData !== null && presetData !== void 0 ? presetData : {}).user);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
return newSettings;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
42
|
const cleanEmptyObject = object => {
|
|
81
43
|
if (!(0, _lodash.isObject)(object) || Array.isArray(object)) {
|
|
82
44
|
return object;
|
|
@@ -109,7 +71,7 @@ function useGlobalStylesUserConfig() {
|
|
|
109
71
|
} = (0, _data.useDispatch)(_coreData.store);
|
|
110
72
|
const config = (0, _element.useMemo)(() => {
|
|
111
73
|
return {
|
|
112
|
-
settings:
|
|
74
|
+
settings: settings !== null && settings !== void 0 ? settings : {},
|
|
113
75
|
styles: styles !== null && styles !== void 0 ? styles : {}
|
|
114
76
|
};
|
|
115
77
|
}, [settings, styles]);
|
|
@@ -119,12 +81,12 @@ function useGlobalStylesUserConfig() {
|
|
|
119
81
|
const record = getEditedEntityRecord('root', 'globalStyles', globalStylesId);
|
|
120
82
|
const currentConfig = {
|
|
121
83
|
styles: (_record$styles = record === null || record === void 0 ? void 0 : record.styles) !== null && _record$styles !== void 0 ? _record$styles : {},
|
|
122
|
-
settings:
|
|
84
|
+
settings: (_record$settings = record === null || record === void 0 ? void 0 : record.settings) !== null && _record$settings !== void 0 ? _record$settings : {}
|
|
123
85
|
};
|
|
124
86
|
const updatedConfig = callback(currentConfig);
|
|
125
87
|
editEntityRecord('root', 'globalStyles', globalStylesId, {
|
|
126
88
|
styles: cleanEmptyObject(updatedConfig.styles) || {},
|
|
127
|
-
settings: cleanEmptyObject(
|
|
89
|
+
settings: cleanEmptyObject(updatedConfig.settings) || {}
|
|
128
90
|
});
|
|
129
91
|
}, [globalStylesId]);
|
|
130
92
|
return [!!settings || !!styles, config, setConfig];
|
|
@@ -159,10 +121,10 @@ function useGlobalStylesContext() {
|
|
|
159
121
|
return context;
|
|
160
122
|
}
|
|
161
123
|
|
|
162
|
-
function GlobalStylesProvider(
|
|
124
|
+
function GlobalStylesProvider(_ref) {
|
|
163
125
|
let {
|
|
164
126
|
children
|
|
165
|
-
} =
|
|
127
|
+
} = _ref;
|
|
166
128
|
const context = useGlobalStylesContext();
|
|
167
129
|
|
|
168
130
|
if (!context.isReady) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/global-styles-provider.js"],"names":["mergeTreesCustomizer","_","srcValue","Array","isArray","mergeBaseAndUserConfigs","base","user","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/global-styles-provider.js"],"names":["mergeTreesCustomizer","_","srcValue","Array","isArray","mergeBaseAndUserConfigs","base","user","cleanEmptyObject","object","cleanedNestedObjects","identity","undefined","useGlobalStylesUserConfig","globalStylesId","settings","styles","select","_globalStylesId","coreStore","__experimentalGetCurrentGlobalStylesId","record","getEditedEntityRecord","editEntityRecord","config","setConfig","callback","currentConfig","updatedConfig","useGlobalStylesBaseConfig","baseConfig","__experimentalGetCurrentThemeBaseGlobalStyles","useGlobalStylesContext","isUserConfigReady","userConfig","setUserConfig","isBaseConfigReady","mergedConfig","context","isReady","merged","GlobalStylesProvider","children"],"mappings":";;;;;;;AAeA;;AAZA;;AAaA;;AACA;;AAKA;;AAtBA;AACA;AACA;;AAUA;AACA;AACA;;AAKA;AACA;AACA;AAGA,SAASA,oBAAT,CAA+BC,CAA/B,EAAkCC,QAAlC,EAA6C;AAC5C;AACA;AACA;AACA,MAAKC,KAA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EAJgB,CAAnB;AAMA,SAAO,CAAE,CAAC,CAAED,UAAL,EAAiBA,UAAjB,CAAP;AACA;;AAED,SAASE,sBAAT,GAAkC;AACjC,QAAM,CACLC,iBADK,EAELC,UAFK,EAGLC,aAHK,IAIFtB,yBAAyB,EAJ7B;AAKA,QAAM,CAAEuB,iBAAF,EAAqBN,UAArB,IAAoCD,yBAAyB,EAAnE;AACA,QAAMQ,YAAY,GAAG,sBAAS,MAAM;AACnC,QAAK,CAAEP,UAAF,IAAgB,CAAEI,UAAvB,EAAoC;AACnC,aAAO,EAAP;AACA;;AACD,WAAO7B,uBAAuB,CAAEyB,UAAF,EAAcI,UAAd,CAA9B;AACA,GALoB,EAKlB,CAAEA,UAAF,EAAcJ,UAAd,CALkB,CAArB;AAMA,QAAMQ,OAAO,GAAG,sBAAS,MAAM;AAC9B,WAAO;AACNC,MAAAA,OAAO,EAAEN,iBAAiB,IAAIG,iBADxB;AAEN7B,MAAAA,IAAI,EAAE2B,UAFA;AAGN5B,MAAAA,IAAI,EAAEwB,UAHA;AAINU,MAAAA,MAAM,EAAEH,YAJF;AAKNF,MAAAA;AALM,KAAP;AAOA,GARe,EAQb,CACFE,YADE,EAEFH,UAFE,EAGFJ,UAHE,EAIFK,aAJE,EAKFF,iBALE,EAMFG,iBANE,CARa,CAAhB;AAiBA,SAAOE,OAAP;AACA;;AAEM,SAASG,oBAAT,OAA8C;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACpD,QAAMJ,OAAO,GAAGN,sBAAsB,EAAtC;;AACA,MAAK,CAAEM,OAAO,CAACC,OAAf,EAAyB;AACxB,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,4BAAD,CAAqB,QAArB;AAA8B,IAAA,KAAK,EAAGD;AAAtC,KACGI,QADH,CADD;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tmergeWith,\n\tpickBy,\n\tisEmpty,\n\tisObject,\n\tidentity,\n\tmapValues,\n} from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { GlobalStylesContext } from './context';\n\nfunction mergeTreesCustomizer( _, srcValue ) {\n\t// We only pass as arrays the presets,\n\t// in which case we want the new array of values\n\t// to override the old array (no merging).\n\tif ( Array.isArray( srcValue ) ) {\n\t\treturn srcValue;\n\t}\n}\n\nfunction mergeBaseAndUserConfigs( base, user ) {\n\treturn mergeWith( {}, base, user, mergeTreesCustomizer );\n}\n\nconst cleanEmptyObject = ( object ) => {\n\tif ( ! isObject( object ) || Array.isArray( object ) ) {\n\t\treturn object;\n\t}\n\tconst cleanedNestedObjects = pickBy(\n\t\tmapValues( object, cleanEmptyObject ),\n\t\tidentity\n\t);\n\treturn isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;\n};\n\nfunction useGlobalStylesUserConfig() {\n\tconst { globalStylesId, settings, styles } = useSelect( ( select ) => {\n\t\tconst _globalStylesId = select(\n\t\t\tcoreStore\n\t\t).__experimentalGetCurrentGlobalStylesId();\n\t\tconst record = _globalStylesId\n\t\t\t? select( coreStore ).getEditedEntityRecord(\n\t\t\t\t\t'root',\n\t\t\t\t\t'globalStyles',\n\t\t\t\t\t_globalStylesId\n\t\t\t )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\tglobalStylesId: _globalStylesId,\n\t\t\tsettings: record?.settings,\n\t\t\tstyles: record?.styles,\n\t\t};\n\t}, [] );\n\n\tconst { getEditedEntityRecord } = useSelect( coreStore );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst config = useMemo( () => {\n\t\treturn {\n\t\t\tsettings: settings ?? {},\n\t\t\tstyles: styles ?? {},\n\t\t};\n\t}, [ settings, styles ] );\n\n\tconst setConfig = useCallback(\n\t\t( callback ) => {\n\t\t\tconst record = getEditedEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'globalStyles',\n\t\t\t\tglobalStylesId\n\t\t\t);\n\t\t\tconst currentConfig = {\n\t\t\t\tstyles: record?.styles ?? {},\n\t\t\t\tsettings: record?.settings ?? {},\n\t\t\t};\n\t\t\tconst updatedConfig = callback( currentConfig );\n\t\t\teditEntityRecord( 'root', 'globalStyles', globalStylesId, {\n\t\t\t\tstyles: cleanEmptyObject( updatedConfig.styles ) || {},\n\t\t\t\tsettings: cleanEmptyObject( updatedConfig.settings ) || {},\n\t\t\t} );\n\t\t},\n\t\t[ globalStylesId ]\n\t);\n\n\treturn [ !! settings || !! styles, config, setConfig ];\n}\n\nfunction useGlobalStylesBaseConfig() {\n\tconst baseConfig = useSelect( ( select ) => {\n\t\treturn select(\n\t\t\tcoreStore\n\t\t).__experimentalGetCurrentThemeBaseGlobalStyles();\n\t}, [] );\n\n\treturn [ !! baseConfig, baseConfig ];\n}\n\nfunction useGlobalStylesContext() {\n\tconst [\n\t\tisUserConfigReady,\n\t\tuserConfig,\n\t\tsetUserConfig,\n\t] = useGlobalStylesUserConfig();\n\tconst [ isBaseConfigReady, baseConfig ] = useGlobalStylesBaseConfig();\n\tconst mergedConfig = useMemo( () => {\n\t\tif ( ! baseConfig || ! userConfig ) {\n\t\t\treturn {};\n\t\t}\n\t\treturn mergeBaseAndUserConfigs( baseConfig, userConfig );\n\t}, [ userConfig, baseConfig ] );\n\tconst context = useMemo( () => {\n\t\treturn {\n\t\t\tisReady: isUserConfigReady && isBaseConfigReady,\n\t\t\tuser: userConfig,\n\t\t\tbase: baseConfig,\n\t\t\tmerged: mergedConfig,\n\t\t\tsetUserConfig,\n\t\t};\n\t}, [\n\t\tmergedConfig,\n\t\tuserConfig,\n\t\tbaseConfig,\n\t\tsetUserConfig,\n\t\tisUserConfigReady,\n\t\tisBaseConfigReady,\n\t] );\n\n\treturn context;\n}\n\nexport function GlobalStylesProvider( { children } ) {\n\tconst context = useGlobalStylesContext();\n\tif ( ! context.isReady ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<GlobalStylesContext.Provider value={ context }>\n\t\t\t{ children }\n\t\t</GlobalStylesContext.Provider>\n\t);\n}\n"]}
|