@wordpress/edit-site 5.12.1 → 5.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/add-new-pattern/index.js +9 -9
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/add-new-template/new-template.js +69 -14
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/create-pattern-modal/index.js +1 -1
- package/build/components/create-pattern-modal/index.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +1 -1
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/editor/index.js +1 -0
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/ui.js +7 -2
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/header-edit-mode/index.js +36 -9
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/index.js +36 -2
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/edit-mode.js +32 -1
- package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -1
- package/build/components/keyboard-shortcuts/register.js +9 -0
- package/build/components/keyboard-shortcuts/register.js.map +1 -1
- package/build/components/layout/index.js +86 -12
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page-content-focus-manager/back-to-page-notification.js +9 -3
- package/build/components/page-content-focus-manager/back-to-page-notification.js.map +1 -1
- package/build/components/page-library/grid-item.js +11 -7
- package/build/components/page-library/grid-item.js.map +1 -1
- package/build/components/preferences-modal/enable-feature.js +5 -1
- package/build/components/preferences-modal/enable-feature.js.map +1 -1
- package/build/components/preferences-modal/index.js +30 -0
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +4 -2
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +7 -3
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +15 -3
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-library/category-item.js +1 -1
- package/build/components/sidebar-navigation-screen-library/category-item.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +10 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +5 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +14 -3
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +22 -0
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +170 -42
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/store/selectors.js +2 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +8 -8
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +72 -17
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/create-pattern-modal/index.js +1 -1
- package/build-module/components/create-pattern-modal/index.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +1 -1
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/editor/index.js +1 -0
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/ui.js +8 -3
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +38 -11
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js +35 -3
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js +29 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/register.js +9 -0
- package/build-module/components/keyboard-shortcuts/register.js.map +1 -1
- package/build-module/components/layout/index.js +86 -12
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page-content-focus-manager/back-to-page-notification.js +9 -3
- package/build-module/components/page-content-focus-manager/back-to-page-notification.js.map +1 -1
- package/build-module/components/page-library/grid-item.js +11 -7
- package/build-module/components/page-library/grid-item.js.map +1 -1
- package/build-module/components/preferences-modal/enable-feature.js +5 -1
- package/build-module/components/preferences-modal/enable-feature.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +27 -0
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +4 -2
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +7 -3
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +14 -3
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-library/category-item.js +1 -1
- package/build-module/components/sidebar-navigation-screen-library/category-item.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +11 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +5 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +14 -4
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +23 -1
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +170 -44
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/store/selectors.js +2 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +110 -18
- package/build-style/style.css +110 -18
- package/package.json +15 -15
- package/src/components/add-new-pattern/index.js +8 -10
- package/src/components/add-new-template/new-template.js +120 -24
- package/src/components/add-new-template/style.scss +30 -2
- package/src/components/create-pattern-modal/index.js +1 -1
- package/src/components/create-template-part-modal/index.js +1 -1
- package/src/components/editor/index.js +1 -0
- package/src/components/editor/style.scss +4 -0
- package/src/components/global-styles/ui.js +34 -24
- package/src/components/header-edit-mode/index.js +96 -54
- package/src/components/header-edit-mode/more-menu/index.js +52 -7
- package/src/components/keyboard-shortcuts/edit-mode.js +35 -2
- package/src/components/keyboard-shortcuts/register.js +10 -0
- package/src/components/layout/index.js +115 -46
- package/src/components/layout/style.scss +58 -1
- package/src/components/page-content-focus-manager/back-to-page-notification.js +7 -2
- package/src/components/page-library/grid-item.js +9 -9
- package/src/components/page-library/style.scss +2 -2
- package/src/components/preferences-modal/enable-feature.js +5 -2
- package/src/components/preferences-modal/index.js +25 -0
- package/src/components/sidebar-button/style.scss +1 -1
- package/src/components/sidebar-edit-mode/index.js +4 -2
- package/src/components/sidebar-navigation-item/style.scss +1 -1
- package/src/components/sidebar-navigation-screen/index.js +4 -2
- package/src/components/sidebar-navigation-screen/style.scss +2 -1
- package/src/components/sidebar-navigation-screen-details-panel/style.scss +1 -1
- package/src/components/sidebar-navigation-screen-global-styles/index.js +15 -3
- package/src/components/sidebar-navigation-screen-library/category-item.js +1 -1
- package/src/components/sidebar-navigation-screen-library/style.scss +0 -4
- package/src/components/sidebar-navigation-screen-navigation-menu/index.js +1 -1
- package/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +12 -1
- package/src/components/sidebar-navigation-screen-navigation-menu/style.scss +2 -2
- package/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +5 -1
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +31 -8
- package/src/components/sidebar-navigation-screen-pattern/style.scss +25 -0
- package/src/components/sidebar-navigation-screen-template/style.scss +15 -15
- package/src/components/site-hub/style.scss +4 -3
- package/src/hooks/commands/use-common-commands.js +20 -1
- package/src/hooks/commands/use-edit-mode-commands.js +155 -36
- package/src/index.js +1 -0
- package/src/store/selectors.js +5 -0
- package/src/store/test/selectors.js +2 -0
- package/src/style.scss +1 -0
|
@@ -21,10 +21,10 @@ var _createPatternModal = _interopRequireDefault(require("../create-pattern-moda
|
|
|
21
21
|
|
|
22
22
|
var _createTemplatePartModal = _interopRequireDefault(require("../create-template-part-modal"));
|
|
23
23
|
|
|
24
|
-
var _lockUnlock = require("../../lock-unlock");
|
|
25
|
-
|
|
26
24
|
var _sidebarButton = _interopRequireDefault(require("../sidebar-button"));
|
|
27
25
|
|
|
26
|
+
var _lockUnlock = require("../../lock-unlock");
|
|
27
|
+
|
|
28
28
|
/**
|
|
29
29
|
* WordPress dependencies
|
|
30
30
|
*/
|
|
@@ -74,17 +74,17 @@ function AddNewPattern() {
|
|
|
74
74
|
controls: [{
|
|
75
75
|
icon: _icons.header,
|
|
76
76
|
onClick: () => setShowTemplatePartModal(true),
|
|
77
|
-
title: 'Create
|
|
77
|
+
title: (0, _i18n.__)('Create template part')
|
|
78
78
|
}, {
|
|
79
79
|
icon: _icons.file,
|
|
80
80
|
onClick: () => setShowPatternModal(true),
|
|
81
|
-
title: 'Create
|
|
81
|
+
title: (0, _i18n.__)('Create pattern')
|
|
82
82
|
}],
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
label:
|
|
83
|
+
toggleProps: {
|
|
84
|
+
as: _sidebarButton.default
|
|
85
|
+
},
|
|
86
|
+
icon: _icons.plus,
|
|
87
|
+
label: (0, _i18n.__)('Create pattern')
|
|
88
88
|
}), showPatternModal && (0, _element.createElement)(_createPatternModal.default, {
|
|
89
89
|
closeModal: () => setShowPatternModal(false),
|
|
90
90
|
onCreate: handleCreatePattern,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-pattern/index.js"],"names":["useHistory","routerPrivateApis","AddNewPattern","history","showPatternModal","setShowPatternModal","showTemplatePartModal","setShowTemplatePartModal","handleCreatePattern","pattern","categoryId","push","postId","id","postType","categoryType","canvas","handleCreateTemplatePart","templatePart","handleError","icon","header","onClick","title","file","plus"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAfA;AACA;AACA;;AAOA;AACA;AACA;AAMA,MAAM;AAAEA,EAAAA;AAAF,IAAiB,wBAAQC,mBAAR,CAAvB;;AAEe,SAASC,aAAT,GAAyB;AACvC,QAAMC,OAAO,GAAGH,UAAU,EAA1B;AACA,QAAM,CAAEI,gBAAF,EAAoBC,mBAApB,IAA4C,uBAAU,KAAV,CAAlD;AACA,QAAM,CAAEC,qBAAF,EAAyBC,wBAAzB,IACL,uBAAU,KAAV,CADD;;AAGA,WAASC,mBAAT,CAA8B;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,GAA9B,EAAwD;AACvDL,IAAAA,mBAAmB,CAAE,KAAF,CAAnB;AAEAF,IAAAA,OAAO,CAACQ,IAAR,CAAc;AACbC,MAAAA,MAAM,EAAEH,OAAO,CAACI,EADH;AAEbC,MAAAA,QAAQ,EAAE,UAFG;AAGbC,MAAAA,YAAY,EAAE,UAHD;AAIbL,MAAAA,UAJa;AAKbM,MAAAA,MAAM,EAAE;AALK,KAAd;AAOA;;AAED,WAASC,wBAAT,CAAmCC,YAAnC,EAAkD;AACjDX,IAAAA,wBAAwB,CAAE,KAAF,CAAxB,CADiD,CAGjD;;AACAJ,IAAAA,OAAO,CAACQ,IAAR,CAAc;AACbC,MAAAA,MAAM,EAAEM,YAAY,CAACL,EADR;AAEbC,MAAAA,QAAQ,EAAE,kBAFG;AAGbE,MAAAA,MAAM,EAAE;AAHK,KAAd;AAKA;;AAED,WAASG,WAAT,GAAuB;AACtBd,IAAAA,mBAAmB,CAAE,KAAF,CAAnB;AACAE,IAAAA,wBAAwB,CAAE,KAAF,CAAxB;AACA;;AAED,SACC,qDACC,4BAAC,wBAAD;AACC,IAAA,QAAQ,EAAG,CACV;AACCa,MAAAA,IAAI,EAAEC,aADP;AAECC,MAAAA,OAAO,EAAE,MAAMf,wBAAwB,CAAE,IAAF,CAFxC;AAGCgB,MAAAA,KAAK,EAAE;AAHR,KADU,EAMV;AACCH,MAAAA,IAAI,EAAEI,WADP;AAECF,MAAAA,OAAO,EAAE,MAAMjB,mBAAmB,CAAE,IAAF,CAFnC;AAGCkB,MAAAA,KAAK,EAAE;AAHR,KANU,CADZ;AAaC,IAAA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-pattern/index.js"],"names":["useHistory","routerPrivateApis","AddNewPattern","history","showPatternModal","setShowPatternModal","showTemplatePartModal","setShowTemplatePartModal","handleCreatePattern","pattern","categoryId","push","postId","id","postType","categoryType","canvas","handleCreateTemplatePart","templatePart","handleError","icon","header","onClick","title","file","as","SidebarButton","plus"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAfA;AACA;AACA;;AAOA;AACA;AACA;AAMA,MAAM;AAAEA,EAAAA;AAAF,IAAiB,wBAAQC,mBAAR,CAAvB;;AAEe,SAASC,aAAT,GAAyB;AACvC,QAAMC,OAAO,GAAGH,UAAU,EAA1B;AACA,QAAM,CAAEI,gBAAF,EAAoBC,mBAApB,IAA4C,uBAAU,KAAV,CAAlD;AACA,QAAM,CAAEC,qBAAF,EAAyBC,wBAAzB,IACL,uBAAU,KAAV,CADD;;AAGA,WAASC,mBAAT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,2BAAD;AACC,IAAA,UAAU,EAAG,MAAMC,mBAAmB,CAAE,KAAF,CADvC;AAEC,IAAA,QAAQ,EAAGG,mBAFZ;AAGC,IAAA,OAAO,EAAGW;AAHX,IArBF,EA2BGb,qBAAqB,IACtB,4BAAC,gCAAD;AACC,IAAA,UAAU,EAAG,MAAMC,wBAAwB,CAAE,KAAF,CAD5C;AAEC,IAAA,MAAM,EAAG,EAFV;AAGC,IAAA,QAAQ,EAAGU,wBAHZ;AAIC,IAAA,OAAO,EAAGE;AAJX,IA5BF,CADD;AAsCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { DropdownMenu } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { plus, header, file } from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport CreatePatternModal from '../create-pattern-modal';\nimport CreateTemplatePartModal from '../create-template-part-modal';\nimport SidebarButton from '../sidebar-button';\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nexport default function AddNewPattern() {\n\tconst history = useHistory();\n\tconst [ showPatternModal, setShowPatternModal ] = useState( false );\n\tconst [ showTemplatePartModal, setShowTemplatePartModal ] =\n\t\tuseState( false );\n\n\tfunction handleCreatePattern( { pattern, categoryId } ) {\n\t\tsetShowPatternModal( false );\n\n\t\thistory.push( {\n\t\t\tpostId: pattern.id,\n\t\t\tpostType: 'wp_block',\n\t\t\tcategoryType: 'wp_block',\n\t\t\tcategoryId,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t}\n\n\tfunction handleCreateTemplatePart( templatePart ) {\n\t\tsetShowTemplatePartModal( false );\n\n\t\t// Navigate to the created template part editor.\n\t\thistory.push( {\n\t\t\tpostId: templatePart.id,\n\t\t\tpostType: 'wp_template_part',\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t}\n\n\tfunction handleError() {\n\t\tsetShowPatternModal( false );\n\t\tsetShowTemplatePartModal( false );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tcontrols={ [\n\t\t\t\t\t{\n\t\t\t\t\t\ticon: header,\n\t\t\t\t\t\tonClick: () => setShowTemplatePartModal( true ),\n\t\t\t\t\t\ttitle: __( 'Create template part' ),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ticon: file,\n\t\t\t\t\t\tonClick: () => setShowPatternModal( true ),\n\t\t\t\t\t\ttitle: __( 'Create pattern' ),\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\tas: SidebarButton,\n\t\t\t\t} }\n\t\t\t\ticon={ plus }\n\t\t\t\tlabel={ __( 'Create pattern' ) }\n\t\t\t/>\n\t\t\t{ showPatternModal && (\n\t\t\t\t<CreatePatternModal\n\t\t\t\t\tcloseModal={ () => setShowPatternModal( false ) }\n\t\t\t\t\tonCreate={ handleCreatePattern }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showTemplatePartModal && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => setShowTemplatePartModal( false ) }\n\t\t\t\t\tblocks={ [] }\n\t\t\t\t\tonCreate={ handleCreateTemplatePart }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -54,29 +54,59 @@ const {
|
|
|
54
54
|
useHistory
|
|
55
55
|
} = (0, _lockUnlock.unlock)(_router.privateApis);
|
|
56
56
|
const DEFAULT_TEMPLATE_SLUGS = ['front-page', 'home', 'single', 'page', 'index', 'archive', 'author', 'category', 'date', 'tag', 'search', '404'];
|
|
57
|
+
const TEMPLATE_ICONS = {
|
|
58
|
+
'front-page': _icons.home,
|
|
59
|
+
home: _icons.postList,
|
|
60
|
+
single: _icons.pin,
|
|
61
|
+
page: _icons.page,
|
|
62
|
+
archive: _icons.archive,
|
|
63
|
+
search: _icons.search,
|
|
64
|
+
404: _icons.notFound,
|
|
65
|
+
index: _icons.list,
|
|
66
|
+
category: _icons.category,
|
|
67
|
+
author: _icons.commentAuthorAvatar,
|
|
68
|
+
taxonomy: _icons.blockMeta,
|
|
69
|
+
date: _icons.calendar,
|
|
70
|
+
tag: _icons.tag,
|
|
71
|
+
attachment: _icons.media
|
|
72
|
+
};
|
|
57
73
|
|
|
58
74
|
function TemplateListItem({
|
|
59
75
|
title,
|
|
76
|
+
direction,
|
|
77
|
+
className,
|
|
60
78
|
description,
|
|
61
|
-
|
|
79
|
+
icon,
|
|
80
|
+
onClick,
|
|
81
|
+
children
|
|
62
82
|
}) {
|
|
63
83
|
return (0, _element.createElement)(_components.Button, {
|
|
64
|
-
|
|
65
|
-
|
|
84
|
+
className: className,
|
|
85
|
+
onClick: onClick,
|
|
86
|
+
label: description,
|
|
87
|
+
showTooltip: !!description
|
|
88
|
+
}, (0, _element.createElement)(_components.Flex, {
|
|
66
89
|
as: "span",
|
|
67
90
|
spacing: 2,
|
|
68
|
-
|
|
91
|
+
align: "center",
|
|
92
|
+
justify: "center",
|
|
69
93
|
style: {
|
|
70
94
|
width: '100%'
|
|
71
|
-
}
|
|
95
|
+
},
|
|
96
|
+
direction: direction
|
|
97
|
+
}, (0, _element.createElement)("div", {
|
|
98
|
+
className: "edit-site-add-new-template__template-icon"
|
|
99
|
+
}, (0, _element.createElement)(_components.Icon, {
|
|
100
|
+
icon: icon
|
|
101
|
+
})), (0, _element.createElement)(_components.__experimentalVStack, {
|
|
102
|
+
className: "edit-site-add-new-template__template-name",
|
|
103
|
+
alignment: "center",
|
|
104
|
+
spacing: 0
|
|
72
105
|
}, (0, _element.createElement)(_components.__experimentalText, {
|
|
73
106
|
weight: 500,
|
|
74
107
|
lineHeight: 1.53846153846 // 20px
|
|
75
108
|
|
|
76
|
-
}, title),
|
|
77
|
-
lineHeight: 1.53846153846 // 20px
|
|
78
|
-
|
|
79
|
-
}, description)));
|
|
109
|
+
}, title), children)));
|
|
80
110
|
}
|
|
81
111
|
|
|
82
112
|
const modalContentMap = {
|
|
@@ -105,6 +135,22 @@ function NewTemplate({
|
|
|
105
135
|
const {
|
|
106
136
|
setTemplate
|
|
107
137
|
} = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
|
|
138
|
+
const {
|
|
139
|
+
homeUrl
|
|
140
|
+
} = (0, _data.useSelect)(select => {
|
|
141
|
+
const {
|
|
142
|
+
getUnstableBase // Site index.
|
|
143
|
+
|
|
144
|
+
} = select(_coreData.store);
|
|
145
|
+
return {
|
|
146
|
+
homeUrl: getUnstableBase()?.home
|
|
147
|
+
};
|
|
148
|
+
}, []);
|
|
149
|
+
const TEMPLATE_SHORT_DESCRIPTIONS = {
|
|
150
|
+
'front-page': homeUrl,
|
|
151
|
+
date: (0, _i18n.sprintf)( // translators: %s: The homepage url.
|
|
152
|
+
(0, _i18n.__)('E.g. %s'), homeUrl + '/' + new Date().getFullYear())
|
|
153
|
+
};
|
|
108
154
|
|
|
109
155
|
async function createTemplate(template, isWPSuggestion = true) {
|
|
110
156
|
if (isCreatingTemplate) {
|
|
@@ -194,24 +240,33 @@ function NewTemplate({
|
|
|
194
240
|
align: "flex-start",
|
|
195
241
|
justify: "center",
|
|
196
242
|
className: "edit-site-add-new-template__template-list__contents"
|
|
197
|
-
},
|
|
243
|
+
}, (0, _element.createElement)(_components.Flex, {
|
|
244
|
+
className: "edit-site-add-new-template__template-list__prompt"
|
|
245
|
+
}, (0, _i18n.__)('Select what the new template should apply to:')), missingTemplates.map(template => {
|
|
198
246
|
const {
|
|
199
247
|
title,
|
|
200
|
-
description,
|
|
201
248
|
slug,
|
|
202
249
|
onClick
|
|
203
250
|
} = template;
|
|
204
251
|
return (0, _element.createElement)(TemplateListItem, {
|
|
205
252
|
key: slug,
|
|
206
253
|
title: title,
|
|
207
|
-
|
|
254
|
+
direction: "column",
|
|
255
|
+
className: "edit-site-add-new-template__template-button",
|
|
256
|
+
description: TEMPLATE_SHORT_DESCRIPTIONS[slug],
|
|
257
|
+
icon: TEMPLATE_ICONS[slug] || _icons.layout,
|
|
208
258
|
onClick: () => onClick ? onClick(template) : createTemplate(template)
|
|
209
259
|
});
|
|
210
260
|
}), (0, _element.createElement)(TemplateListItem, {
|
|
211
261
|
title: (0, _i18n.__)('Custom template'),
|
|
212
|
-
|
|
262
|
+
direction: "row",
|
|
263
|
+
className: "edit-site-add-new-template__custom-template-button",
|
|
264
|
+
icon: _icons.edit,
|
|
213
265
|
onClick: () => setModalContent(modalContentMap.customGenericTemplate)
|
|
214
|
-
}
|
|
266
|
+
}, (0, _element.createElement)(_components.__experimentalText, {
|
|
267
|
+
lineHeight: 1.53846153846 // 20px
|
|
268
|
+
|
|
269
|
+
}, (0, _i18n.__)('A custom template can be manually applied to any post or page.')))), modalContent === modalContentMap.customTemplate && (0, _element.createElement)(_addCustomTemplateModalContent.default, {
|
|
215
270
|
onSelect: createTemplate,
|
|
216
271
|
entityForSuggestions: entityForSuggestions
|
|
217
272
|
}), modalContent === modalContentMap.customGenericTemplate && (0, _element.createElement)(_addCustomGenericTemplateModalContent.default, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template.js"],"names":["useHistory","routerPrivateApis","DEFAULT_TEMPLATE_SLUGS","TemplateListItem","title","description","onClick","width","modalContentMap","templatesList","customTemplate","customGenericTemplate","NewTemplate","postType","toggleProps","showIcon","showModal","setShowModal","modalContent","setModalContent","entityForSuggestions","setEntityForSuggestions","isCreatingTemplate","setIsCreatingTemplate","history","saveEntityRecord","coreStore","createErrorNotice","createSuccessNotice","noticesStore","setTemplate","editSiteStore","createTemplate","template","isWPSuggestion","slug","newTemplate","toString","status","is_wp_suggestion","throwOnError","id","push","postId","type","canvas","rendered","error","errorMessage","message","code","onModalClose","missingTemplates","useMissingTemplates","length","as","Toggle","Button","restToggleProps","modalTitle","labels","singular_name","plus","add_new_item","undefined","map","existingTemplates","defaultTemplateTypes","existingTemplateSlugs","missingDefaultTemplates","filter","includes","onClickMenuItem","_entityForSuggestions","enhancedMissingDefaultTemplateTypes","defaultTaxonomiesMenuItems","taxonomiesMenuItems","defaultPostTypesMenuItems","postTypesMenuItems","authorMenuItem","forEach","menuItem","matchIndex","findIndex","sort","template1","template2","indexOf"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AAKA;;AAOA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AAvCA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;AAeA,MAAM;AAAEA,EAAAA;AAAF,IAAiB,wBAAQC,mBAAR,CAAvB;AAEA,MAAMC,sBAAsB,GAAG,CAC9B,YAD8B,EAE9B,MAF8B,EAG9B,QAH8B,EAI9B,MAJ8B,EAK9B,OAL8B,EAM9B,SAN8B,EAO9B,QAP8B,EAQ9B,UAR8B,EAS9B,MAT8B,EAU9B,KAV8B,EAW9B,QAX8B,EAY9B,KAZ8B,CAA/B;;AAeA,SAASC,gBAAT,CAA2B;AAAEC,EAAAA,KAAF;AAASC,EAAAA,WAAT;AAAsBC,EAAAA;AAAtB,CAA3B,EAA6D;AAC5D,SACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAGA;AAAlB,KACC,4BAAC,gCAAD;AACC,IAAA,EAAE,EAAC,MADJ;AAEC,IAAA,OAAO,EAAG,CAFX;AAGC,IAAA,OAAO,EAAC,YAHT;AAIC,IAAA,KAAK,EAAG;AAAEC,MAAAA,KAAK,EAAE;AAAT;AAJT,KAMC,4BAAC,8BAAD;AACC,IAAA,MAAM,EAAG,GADV;AAEC,IAAA,UAAU,EAAG,aAFd,CAE8B;;AAF9B,KAIGH,KAJH,CAND,EAYC,4BAAC,8BAAD;AACC,IAAA,UAAU,EAAG,aADd,CAC8B;;AAD9B,KAGGC,WAHH,CAZD,CADD,CADD;AAsBA;;AAED,MAAMG,eAAe,GA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AEU,IAArC,CAA2C,CAAEC,SAAF,EAAaC,SAAb,KAA4B;AACtE,WACCpF,sBAAsB,CAACqF,OAAvB,CAAgCF,SAAS,CAAClD,IAA1C,IACAjC,sBAAsB,CAACqF,OAAvB,CAAgCD,SAAS,CAACnD,IAA1C,CAFD;AAIA,GALD;AAMA,QAAMiB,gBAAgB,GAAG,CACxB,GAAGsB,mCADqB,EAExB,GAAG,yCAFqB,EAGxB,GAAGI,kBAHqB,EAIxB,GAAGF,mBAJqB,CAAzB;AAMA,SAAOxB,gBAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalGrid as Grid,\n\t__experimentalText as Text,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { plus } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport AddCustomTemplateModalContent from './add-custom-template-modal-content';\nimport {\n\tuseExistingTemplates,\n\tuseDefaultTemplateTypes,\n\tuseTaxonomiesMenuItems,\n\tusePostTypeMenuItems,\n\tuseAuthorMenuItem,\n\tusePostTypeArchiveMenuItems,\n} from './utils';\nimport AddCustomGenericTemplateModalContent from './add-custom-generic-template-modal-content';\nimport TemplateActionsLoadingScreen from './template-actions-loading-screen';\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst DEFAULT_TEMPLATE_SLUGS = [\n\t'front-page',\n\t'home',\n\t'single',\n\t'page',\n\t'index',\n\t'archive',\n\t'author',\n\t'category',\n\t'date',\n\t'tag',\n\t'search',\n\t'404',\n];\n\nfunction TemplateListItem( { title, description, onClick } ) {\n\treturn (\n\t\t<Button onClick={ onClick }>\n\t\t\t<VStack\n\t\t\t\tas=\"span\"\n\t\t\t\tspacing={ 2 }\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tstyle={ { width: '100%' } }\n\t\t\t>\n\t\t\t\t<Text\n\t\t\t\t\tweight={ 500 }\n\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t>\n\t\t\t\t\t{ title }\n\t\t\t\t</Text>\n\t\t\t\t<Text\n\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t>\n\t\t\t\t\t{ description }\n\t\t\t\t</Text>\n\t\t\t</VStack>\n\t\t</Button>\n\t);\n}\n\nconst modalContentMap = {\n\ttemplatesList: 1,\n\tcustomTemplate: 2,\n\tcustomGenericTemplate: 3,\n};\n\nexport default function NewTemplate( {\n\tpostType,\n\ttoggleProps,\n\tshowIcon = true,\n} ) {\n\tconst [ showModal, setShowModal ] = useState( false );\n\tconst [ modalContent, setModalContent ] = useState(\n\t\tmodalContentMap.templatesList\n\t);\n\tconst [ entityForSuggestions, setEntityForSuggestions ] = useState( {} );\n\tconst [ isCreatingTemplate, setIsCreatingTemplate ] = useState( false );\n\n\tconst history = useHistory();\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { setTemplate } = unlock( useDispatch( editSiteStore ) );\n\tasync function createTemplate( template, isWPSuggestion = true ) {\n\t\tif ( isCreatingTemplate ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsCreatingTemplate( true );\n\t\ttry {\n\t\t\tconst { title, description, slug } = template;\n\t\t\tconst newTemplate = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{\n\t\t\t\t\tdescription,\n\t\t\t\t\t// Slugs need to be strings, so this is for template `404`\n\t\t\t\t\tslug: slug.toString(),\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\ttitle,\n\t\t\t\t\t// This adds a post meta field in template that is part of `is_custom` value calculation.\n\t\t\t\t\tis_wp_suggestion: isWPSuggestion,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\t// Set template before navigating away to avoid initial stale value.\n\t\t\tsetTemplate( newTemplate.id, newTemplate.slug );\n\n\t\t\t// Navigate to the created template editor.\n\t\t\thistory.push( {\n\t\t\t\tpostId: newTemplate.id,\n\t\t\t\tpostType: newTemplate.type,\n\t\t\t\tcanvas: 'edit',\n\t\t\t} );\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\tdecodeEntities( newTemplate.title?.rendered || title )\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the template.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsCreatingTemplate( false );\n\t\t}\n\t}\n\tconst onModalClose = () => {\n\t\tsetShowModal( false );\n\t\tsetModalContent( modalContentMap.templatesList );\n\t};\n\n\tconst missingTemplates = useMissingTemplates( setEntityForSuggestions, () =>\n\t\tsetModalContent( modalContentMap.customTemplate )\n\t);\n\tif ( ! missingTemplates.length ) {\n\t\treturn null;\n\t}\n\tconst { as: Toggle = Button, ...restToggleProps } = toggleProps ?? {};\n\n\tlet modalTitle = __( 'Add template' );\n\tif ( modalContent === modalContentMap.customTemplate ) {\n\t\tmodalTitle = sprintf(\n\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t__( 'Add template: %s' ),\n\t\t\tentityForSuggestions.labels.singular_name\n\t\t);\n\t} else if ( modalContent === modalContentMap.customGenericTemplate ) {\n\t\tmodalTitle = __( 'Create custom template' );\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ isCreatingTemplate && <TemplateActionsLoadingScreen /> }\n\t\t\t<Toggle\n\t\t\t\t{ ...restToggleProps }\n\t\t\t\tonClick={ () => setShowModal( true ) }\n\t\t\t\ticon={ showIcon ? plus : null }\n\t\t\t\tlabel={ postType.labels.add_new_item }\n\t\t\t>\n\t\t\t\t{ showIcon ? null : postType.labels.add_new_item }\n\t\t\t</Toggle>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ modalTitle }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'edit-site-add-new-template__modal',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'edit-site-add-new-template__modal_template_list':\n\t\t\t\t\t\t\t\tmodalContent === modalContentMap.templatesList,\n\t\t\t\t\t\t\t'edit-site-custom-template-modal':\n\t\t\t\t\t\t\t\tmodalContent === modalContentMap.customTemplate,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tonRequestClose={ onModalClose }\n\t\t\t\t\toverlayClassName={\n\t\t\t\t\t\tmodalContent === modalContentMap.customGenericTemplate\n\t\t\t\t\t\t\t? 'edit-site-custom-generic-template__modal'\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ modalContent === modalContentMap.templatesList && (\n\t\t\t\t\t\t<Grid\n\t\t\t\t\t\t\tcolumns={ 3 }\n\t\t\t\t\t\t\tgap={ 4 }\n\t\t\t\t\t\t\talign=\"flex-start\"\n\t\t\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\t\t\tclassName=\"edit-site-add-new-template__template-list__contents\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ missingTemplates.map( ( template ) => {\n\t\t\t\t\t\t\t\tconst { title, description, slug, onClick } =\n\t\t\t\t\t\t\t\t\ttemplate;\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<TemplateListItem\n\t\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\t\t\t\t\tdescription={ description }\n\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\tonClick\n\t\t\t\t\t\t\t\t\t\t\t\t? onClick( template )\n\t\t\t\t\t\t\t\t\t\t\t\t: createTemplate( template )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t<TemplateListItem\n\t\t\t\t\t\t\t\ttitle={ __( 'Custom template' ) }\n\t\t\t\t\t\t\t\tdescription={ __(\n\t\t\t\t\t\t\t\t\t'A custom template can be manually applied to any post or page.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\tsetModalContent(\n\t\t\t\t\t\t\t\t\t\tmodalContentMap.customGenericTemplate\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/>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t) }\n\t\t\t\t\t{ modalContent === modalContentMap.customTemplate && (\n\t\t\t\t\t\t<AddCustomTemplateModalContent\n\t\t\t\t\t\t\tonSelect={ createTemplate }\n\t\t\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ modalContent ===\n\t\t\t\t\t\tmodalContentMap.customGenericTemplate && (\n\t\t\t\t\t\t<AddCustomGenericTemplateModalContent\n\t\t\t\t\t\t\tonClose={ onModalClose }\n\t\t\t\t\t\t\tcreateTemplate={ createTemplate }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction useMissingTemplates( setEntityForSuggestions, onClick ) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst missingDefaultTemplates = ( defaultTemplateTypes || [] ).filter(\n\t\t( template ) =>\n\t\t\tDEFAULT_TEMPLATE_SLUGS.includes( template.slug ) &&\n\t\t\t! existingTemplateSlugs.includes( template.slug )\n\t);\n\tconst onClickMenuItem = ( _entityForSuggestions ) => {\n\t\tonClick?.();\n\t\tsetEntityForSuggestions( _entityForSuggestions );\n\t};\n\t// We need to replace existing default template types with\n\t// the create specific template functionality. The original\n\t// info (title, description, etc.) is preserved in the\n\t// used hooks.\n\tconst enhancedMissingDefaultTemplateTypes = [ ...missingDefaultTemplates ];\n\tconst { defaultTaxonomiesMenuItems, taxonomiesMenuItems } =\n\t\tuseTaxonomiesMenuItems( onClickMenuItem );\n\tconst { defaultPostTypesMenuItems, postTypesMenuItems } =\n\t\tusePostTypeMenuItems( onClickMenuItem );\n\n\tconst authorMenuItem = useAuthorMenuItem( onClickMenuItem );\n\t[\n\t\t...defaultTaxonomiesMenuItems,\n\t\t...defaultPostTypesMenuItems,\n\t\tauthorMenuItem,\n\t].forEach( ( menuItem ) => {\n\t\tif ( ! menuItem ) {\n\t\t\treturn;\n\t\t}\n\t\tconst matchIndex = enhancedMissingDefaultTemplateTypes.findIndex(\n\t\t\t( template ) => template.slug === menuItem.slug\n\t\t);\n\t\t// Some default template types might have been filtered above from\n\t\t// `missingDefaultTemplates` because they only check for the general\n\t\t// template. So here we either replace or append the item, augmented\n\t\t// with the check if it has available specific item to create a\n\t\t// template for.\n\t\tif ( matchIndex > -1 ) {\n\t\t\tenhancedMissingDefaultTemplateTypes[ matchIndex ] = menuItem;\n\t\t} else {\n\t\t\tenhancedMissingDefaultTemplateTypes.push( menuItem );\n\t\t}\n\t} );\n\t// Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order.\n\tenhancedMissingDefaultTemplateTypes?.sort( ( template1, template2 ) => {\n\t\treturn (\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template1.slug ) -\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template2.slug )\n\t\t);\n\t} );\n\tconst missingTemplates = [\n\t\t...enhancedMissingDefaultTemplateTypes,\n\t\t...usePostTypeArchiveMenuItems(),\n\t\t...postTypesMenuItems,\n\t\t...taxonomiesMenuItems,\n\t];\n\treturn missingTemplates;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template.js"],"names":["useHistory","routerPrivateApis","DEFAULT_TEMPLATE_SLUGS","TEMPLATE_ICONS","home","postList","single","pin","page","archive","search","notFound","index","list","category","author","commentAuthorAvatar","taxonomy","blockMeta","date","calendar","tag","attachment","media","TemplateListItem","title","direction","className","description","icon","onClick","children","width","modalContentMap","templatesList","customTemplate","customGenericTemplate","NewTemplate","postType","toggleProps","showIcon","showModal","setShowModal","modalContent","setModalContent","entityForSuggestions","setEntityForSuggestions","isCreatingTemplate","setIsCreatingTemplate","history","saveEntityRecord","coreStore","createErrorNotice","createSuccessNotice","noticesStore","setTemplate","editSiteStore","homeUrl","select","getUnstableBase","TEMPLATE_SHORT_DESCRIPTIONS","Date","getFullYear","createTemplate","template","isWPSuggestion","slug","newTemplate","toString","status","is_wp_suggestion","throwOnError","id","push","postId","type","canvas","rendered","error","errorMessage","message","code","onModalClose","missingTemplates","useMissingTemplates","length","as","Toggle","Button","restToggleProps","modalTitle","labels","singular_name","plus","add_new_item","undefined","map","layout","edit","existingTemplates","defaultTemplateTypes","existingTemplateSlugs","missingDefaultTemplates","filter","includes","onClickMenuItem","_entityForSuggestions","enhancedMissingDefaultTemplateTypes","defaultTaxonomiesMenuItems","taxonomiesMenuItems","defaultPostTypesMenuItems","postTypesMenuItems","authorMenuItem","forEach","menuItem","matchIndex","findIndex","sort","template1","template2","indexOf"],"mappings":";;;;;;;;;AAkBA;;AAfA;;AAKA;;AASA;;AAEA;;AACA;;AACA;;AAmBA;;AACA;;AACA;;AAKA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AA3DA;AACA;AACA;;AAGA;AACA;AACA;;AAqCA;AACA;AACA;AAeA,MAAM;AAAEA,EAAAA;AAAF,IAAiB,wBAAQC,mBAAR,CAAvB;AAEA,MAAMC,sBAAsB,GAAG,CAC9B,YAD8B,EAE9B,MAF8B,EAG9B,QAH8B,EAI9B,MAJ8B,EAK9B,OAL8B,EAM9B,SAN8B,EAO9B,QAP8B,EAQ9B,UAR8B,EAS9B,MAT8B,EAU9B,KAV8B,EAW9B,QAX8B,EAY9B,KAZ8B,CAA/B;AAeA,MAAMC,cAAc,GAAG;AACtB,gBAAcC,WADQ;AAEtBA,EAAAA,IAAI,EAAEC,eAFgB;AAGtBC,EAAAA,MAAM,EAAEC,UAHc;AAItBC,EAAAA,IAAI,EAAJA,WAJsB;AAKtBC,EAAAA,OAAO,EAAPA,cALsB;AAMtBC,EAAAA,MAAM,EAANA,aANsB;AAOtB,OAAKC,eAPiB;AAQtBC,EAAAA,KAAK,EAAEC,WARe;AAStBC,EAAAA,QAAQ,EAARA,eATsB;AAUtBC,EAAAA,MAAM,EAAEC,0BAVc;AAWtBC,EAAAA,QAAQ,EAAEC,gBAXY;AAYtBC,EAAAA,IAAI,EAAEC,eAZgB;AAatBC,EAAAA,GAAG,EAAHA,UAbsB;AActBC,EAAAA,UAAU,EAAEC;AAdU,CAAvB;;AAiBA,SAASC,gBAAT,CAA2B;AAC1BC,EAAAA,KAD0B;AAE1BC,EAAAA,SAF0B;AAG1BC,EAAAA,SAH0B;AAI1BC,EAAAA,WAJ0B;AAK1BC,EAAAA,IAL0B;AAM1BC,EAAAA,OAN0B;AAO1BC,EAAAA;AAP0B,CAA3B,EAQI;AACH,SACC,4BAAC,kBA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,QAAQ,CAAChD,IADzB,CAAnB,CAJ0B,CAO1B;AACA;AACA;AACA;AACA;;AACA,QAAKiD,UAAU,GAAG,CAAC,CAAnB,EAAuB;AACtBR,MAAAA,mCAAmC,CAAEQ,UAAF,CAAnC,GAAoDD,QAApD;AACA,KAFD,MAEO;AACNP,MAAAA,mCAAmC,CAAClC,IAApC,CAA0CyC,QAA1C;AACA;AACD,GArBD,EA1BgE,CAgDhE;;AACAP,EAAAA,mCAAmC,EAAEU,IAArC,CAA2C,CAAEC,SAAF,EAAaC,SAAb,KAA4B;AACtE,WACCrH,sBAAsB,CAACsH,OAAvB,CAAgCF,SAAS,CAACpD,IAA1C,IACAhE,sBAAsB,CAACsH,OAAvB,CAAgCD,SAAS,CAACrD,IAA1C,CAFD;AAIA,GALD;AAMA,QAAMiB,gBAAgB,GAAG,CACxB,GAAGwB,mCADqB,EAExB,GAAG,yCAFqB,EAGxB,GAAGI,kBAHqB,EAIxB,GAAGF,mBAJqB,CAAzB;AAMA,SAAO1B,gBAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalGrid as Grid,\n\t__experimentalText as Text,\n\t__experimentalVStack as VStack,\n\tFlex,\n\tIcon,\n} from '@wordpress/components';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useState } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tarchive,\n\tblockMeta,\n\tcalendar,\n\tcategory,\n\tcommentAuthorAvatar,\n\tedit,\n\thome,\n\tlayout,\n\tlist,\n\tmedia,\n\tnotFound,\n\tpage,\n\tplus,\n\tpin,\n\tpostList,\n\tsearch,\n\ttag,\n} from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport AddCustomTemplateModalContent from './add-custom-template-modal-content';\nimport {\n\tuseExistingTemplates,\n\tuseDefaultTemplateTypes,\n\tuseTaxonomiesMenuItems,\n\tusePostTypeMenuItems,\n\tuseAuthorMenuItem,\n\tusePostTypeArchiveMenuItems,\n} from './utils';\nimport AddCustomGenericTemplateModalContent from './add-custom-generic-template-modal-content';\nimport TemplateActionsLoadingScreen from './template-actions-loading-screen';\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst DEFAULT_TEMPLATE_SLUGS = [\n\t'front-page',\n\t'home',\n\t'single',\n\t'page',\n\t'index',\n\t'archive',\n\t'author',\n\t'category',\n\t'date',\n\t'tag',\n\t'search',\n\t'404',\n];\n\nconst TEMPLATE_ICONS = {\n\t'front-page': home,\n\thome: postList,\n\tsingle: pin,\n\tpage,\n\tarchive,\n\tsearch,\n\t404: notFound,\n\tindex: list,\n\tcategory,\n\tauthor: commentAuthorAvatar,\n\ttaxonomy: blockMeta,\n\tdate: calendar,\n\ttag,\n\tattachment: media,\n};\n\nfunction TemplateListItem( {\n\ttitle,\n\tdirection,\n\tclassName,\n\tdescription,\n\ticon,\n\tonClick,\n\tchildren,\n} ) {\n\treturn (\n\t\t<Button\n\t\t\tclassName={ className }\n\t\t\tonClick={ onClick }\n\t\t\tlabel={ description }\n\t\t\tshowTooltip={ !! description }\n\t\t>\n\t\t\t<Flex\n\t\t\t\tas=\"span\"\n\t\t\t\tspacing={ 2 }\n\t\t\t\talign=\"center\"\n\t\t\t\tjustify=\"center\"\n\t\t\t\tstyle={ { width: '100%' } }\n\t\t\t\tdirection={ direction }\n\t\t\t>\n\t\t\t\t<div className=\"edit-site-add-new-template__template-icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t\t<VStack\n\t\t\t\t\tclassName=\"edit-site-add-new-template__template-name\"\n\t\t\t\t\talignment=\"center\"\n\t\t\t\t\tspacing={ 0 }\n\t\t\t\t>\n\t\t\t\t\t<Text\n\t\t\t\t\t\tweight={ 500 }\n\t\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</Text>\n\t\t\t\t\t{ children }\n\t\t\t\t</VStack>\n\t\t\t</Flex>\n\t\t</Button>\n\t);\n}\n\nconst modalContentMap = {\n\ttemplatesList: 1,\n\tcustomTemplate: 2,\n\tcustomGenericTemplate: 3,\n};\n\nexport default function NewTemplate( {\n\tpostType,\n\ttoggleProps,\n\tshowIcon = true,\n} ) {\n\tconst [ showModal, setShowModal ] = useState( false );\n\tconst [ modalContent, setModalContent ] = useState(\n\t\tmodalContentMap.templatesList\n\t);\n\tconst [ entityForSuggestions, setEntityForSuggestions ] = useState( {} );\n\tconst [ isCreatingTemplate, setIsCreatingTemplate ] = useState( false );\n\n\tconst history = useHistory();\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { setTemplate } = unlock( useDispatch( editSiteStore ) );\n\n\tconst { homeUrl } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetUnstableBase, // Site index.\n\t\t} = select( coreStore );\n\n\t\treturn {\n\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t};\n\t}, [] );\n\n\tconst TEMPLATE_SHORT_DESCRIPTIONS = {\n\t\t'front-page': homeUrl,\n\t\tdate: sprintf(\n\t\t\t// translators: %s: The homepage url.\n\t\t\t__( 'E.g. %s' ),\n\t\t\thomeUrl + '/' + new Date().getFullYear()\n\t\t),\n\t};\n\n\tasync function createTemplate( template, isWPSuggestion = true ) {\n\t\tif ( isCreatingTemplate ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsCreatingTemplate( true );\n\t\ttry {\n\t\t\tconst { title, description, slug } = template;\n\t\t\tconst newTemplate = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{\n\t\t\t\t\tdescription,\n\t\t\t\t\t// Slugs need to be strings, so this is for template `404`\n\t\t\t\t\tslug: slug.toString(),\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\ttitle,\n\t\t\t\t\t// This adds a post meta field in template that is part of `is_custom` value calculation.\n\t\t\t\t\tis_wp_suggestion: isWPSuggestion,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\t// Set template before navigating away to avoid initial stale value.\n\t\t\tsetTemplate( newTemplate.id, newTemplate.slug );\n\n\t\t\t// Navigate to the created template editor.\n\t\t\thistory.push( {\n\t\t\t\tpostId: newTemplate.id,\n\t\t\t\tpostType: newTemplate.type,\n\t\t\t\tcanvas: 'edit',\n\t\t\t} );\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\tdecodeEntities( newTemplate.title?.rendered || title )\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the template.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsCreatingTemplate( false );\n\t\t}\n\t}\n\tconst onModalClose = () => {\n\t\tsetShowModal( false );\n\t\tsetModalContent( modalContentMap.templatesList );\n\t};\n\n\tconst missingTemplates = useMissingTemplates( setEntityForSuggestions, () =>\n\t\tsetModalContent( modalContentMap.customTemplate )\n\t);\n\tif ( ! missingTemplates.length ) {\n\t\treturn null;\n\t}\n\tconst { as: Toggle = Button, ...restToggleProps } = toggleProps ?? {};\n\n\tlet modalTitle = __( 'Add template' );\n\tif ( modalContent === modalContentMap.customTemplate ) {\n\t\tmodalTitle = sprintf(\n\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t__( 'Add template: %s' ),\n\t\t\tentityForSuggestions.labels.singular_name\n\t\t);\n\t} else if ( modalContent === modalContentMap.customGenericTemplate ) {\n\t\tmodalTitle = __( 'Create custom template' );\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ isCreatingTemplate && <TemplateActionsLoadingScreen /> }\n\t\t\t<Toggle\n\t\t\t\t{ ...restToggleProps }\n\t\t\t\tonClick={ () => setShowModal( true ) }\n\t\t\t\ticon={ showIcon ? plus : null }\n\t\t\t\tlabel={ postType.labels.add_new_item }\n\t\t\t>\n\t\t\t\t{ showIcon ? null : postType.labels.add_new_item }\n\t\t\t</Toggle>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ modalTitle }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'edit-site-add-new-template__modal',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'edit-site-add-new-template__modal_template_list':\n\t\t\t\t\t\t\t\tmodalContent === modalContentMap.templatesList,\n\t\t\t\t\t\t\t'edit-site-custom-template-modal':\n\t\t\t\t\t\t\t\tmodalContent === modalContentMap.customTemplate,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tonRequestClose={ onModalClose }\n\t\t\t\t\toverlayClassName={\n\t\t\t\t\t\tmodalContent === modalContentMap.customGenericTemplate\n\t\t\t\t\t\t\t? 'edit-site-custom-generic-template__modal'\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ modalContent === modalContentMap.templatesList && (\n\t\t\t\t\t\t<Grid\n\t\t\t\t\t\t\tcolumns={ 3 }\n\t\t\t\t\t\t\tgap={ 4 }\n\t\t\t\t\t\t\talign=\"flex-start\"\n\t\t\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\t\t\tclassName=\"edit-site-add-new-template__template-list__contents\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Flex className=\"edit-site-add-new-template__template-list__prompt\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Select what the new template should apply to:'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t\t{ missingTemplates.map( ( template ) => {\n\t\t\t\t\t\t\t\tconst { title, slug, onClick } = template;\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<TemplateListItem\n\t\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-add-new-template__template-button\"\n\t\t\t\t\t\t\t\t\t\tdescription={\n\t\t\t\t\t\t\t\t\t\t\tTEMPLATE_SHORT_DESCRIPTIONS[ slug ]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\tTEMPLATE_ICONS[ slug ] || layout\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\tonClick\n\t\t\t\t\t\t\t\t\t\t\t\t? onClick( template )\n\t\t\t\t\t\t\t\t\t\t\t\t: createTemplate( template )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t<TemplateListItem\n\t\t\t\t\t\t\t\ttitle={ __( 'Custom template' ) }\n\t\t\t\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\t\t\t\tclassName=\"edit-site-add-new-template__custom-template-button\"\n\t\t\t\t\t\t\t\ticon={ edit }\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\tsetModalContent(\n\t\t\t\t\t\t\t\t\t\tmodalContentMap.customGenericTemplate\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>\n\t\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\t\tlineHeight={ 1.53846153846 } // 20px\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t'A custom template can be manually applied to any post or page.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t</TemplateListItem>\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t) }\n\t\t\t\t\t{ modalContent === modalContentMap.customTemplate && (\n\t\t\t\t\t\t<AddCustomTemplateModalContent\n\t\t\t\t\t\t\tonSelect={ createTemplate }\n\t\t\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ modalContent ===\n\t\t\t\t\t\tmodalContentMap.customGenericTemplate && (\n\t\t\t\t\t\t<AddCustomGenericTemplateModalContent\n\t\t\t\t\t\t\tonClose={ onModalClose }\n\t\t\t\t\t\t\tcreateTemplate={ createTemplate }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction useMissingTemplates( setEntityForSuggestions, onClick ) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst missingDefaultTemplates = ( defaultTemplateTypes || [] ).filter(\n\t\t( template ) =>\n\t\t\tDEFAULT_TEMPLATE_SLUGS.includes( template.slug ) &&\n\t\t\t! existingTemplateSlugs.includes( template.slug )\n\t);\n\tconst onClickMenuItem = ( _entityForSuggestions ) => {\n\t\tonClick?.();\n\t\tsetEntityForSuggestions( _entityForSuggestions );\n\t};\n\t// We need to replace existing default template types with\n\t// the create specific template functionality. The original\n\t// info (title, description, etc.) is preserved in the\n\t// used hooks.\n\tconst enhancedMissingDefaultTemplateTypes = [ ...missingDefaultTemplates ];\n\tconst { defaultTaxonomiesMenuItems, taxonomiesMenuItems } =\n\t\tuseTaxonomiesMenuItems( onClickMenuItem );\n\tconst { defaultPostTypesMenuItems, postTypesMenuItems } =\n\t\tusePostTypeMenuItems( onClickMenuItem );\n\n\tconst authorMenuItem = useAuthorMenuItem( onClickMenuItem );\n\t[\n\t\t...defaultTaxonomiesMenuItems,\n\t\t...defaultPostTypesMenuItems,\n\t\tauthorMenuItem,\n\t].forEach( ( menuItem ) => {\n\t\tif ( ! menuItem ) {\n\t\t\treturn;\n\t\t}\n\t\tconst matchIndex = enhancedMissingDefaultTemplateTypes.findIndex(\n\t\t\t( template ) => template.slug === menuItem.slug\n\t\t);\n\t\t// Some default template types might have been filtered above from\n\t\t// `missingDefaultTemplates` because they only check for the general\n\t\t// template. So here we either replace or append the item, augmented\n\t\t// with the check if it has available specific item to create a\n\t\t// template for.\n\t\tif ( matchIndex > -1 ) {\n\t\t\tenhancedMissingDefaultTemplateTypes[ matchIndex ] = menuItem;\n\t\t} else {\n\t\t\tenhancedMissingDefaultTemplateTypes.push( menuItem );\n\t\t}\n\t} );\n\t// Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order.\n\tenhancedMissingDefaultTemplateTypes?.sort( ( template1, template2 ) => {\n\t\treturn (\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template1.slug ) -\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template2.slug )\n\t\t);\n\t} );\n\tconst missingTemplates = [\n\t\t...enhancedMissingDefaultTemplateTypes,\n\t\t...usePostTypeArchiveMenuItems(),\n\t\t...postTypesMenuItems,\n\t\t...taxonomiesMenuItems,\n\t];\n\treturn missingTemplates;\n}\n"]}
|
|
@@ -79,7 +79,7 @@ function CreatePatternModal({
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
return (0, _element.createElement)(_components.Modal, {
|
|
82
|
-
title: (0, _i18n.__)('Create
|
|
82
|
+
title: (0, _i18n.__)('Create pattern'),
|
|
83
83
|
onRequestClose: closeModal,
|
|
84
84
|
overlayClassName: "edit-site-create-pattern-modal"
|
|
85
85
|
}, (0, _element.createElement)("p", null, (0, _i18n.__)('Turn this block into a pattern to reuse later')), (0, _element.createElement)("form", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/create-pattern-modal/index.js"],"names":["CreatePatternModal","closeModal","onCreate","onError","name","setName","syncType","setSyncType","SYNC_TYPES","full","isSubmitting","setIsSubmitting","onSyncChange","unsynced","createErrorNotice","noticesStore","saveEntityRecord","coreStore","createPattern","type","pattern","title","content","status","meta","sync_status","throwOnError","categoryId","USER_PATTERN_CATEGORY","error","errorMessage","message","code","event","preventDefault"],"mappings":";;;;;;;AAaA;;AAVA;;AAQA;;AACA;;AAEA;;AACA;;AAKA;;AApBA;AACA;AACA;;AAeA;AACA;AACA;AAGe,SAASA,kBAAT,CAA6B;AAC3CC,EAAAA,UAD2C;AAE3CC,EAAAA,QAF2C;AAG3CC,EAAAA;AAH2C,CAA7B,EAIX;AACH,QAAM,CAAEC,IAAF,EAAQC,OAAR,IAAoB,uBAAU,EAAV,CAA1B;AACA,QAAM,CAAEC,QAAF,EAAYC,WAAZ,IAA4B,uBAAUC,kBAAWC,IAArB,CAAlC;AACA,QAAM,CAAEC,YAAF,EAAgBC,eAAhB,IAAoC,uBAAU,KAAV,CAA1C;;AAEA,QAAMC,YAAY,GAAG,MAAM;AAC1BL,IAAAA,WAAW,CACVD,QAAQ,KAAKE,kBAAWC,IAAxB,GAA+BD,kBAAWK,QAA1C,GAAqDL,kBAAWC,IADtD,CAAX;AAGA,GAJD;;AAMA,QAAM;AAAEK,IAAAA;AAAF,MAAwB,uBAAaC,cAAb,CAA9B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAuB,uBAAaC,eAAb,CAA7B;;AAEA,iBAAeC,aAAf,GAA+B;AAC9B,QAAK,CAAEd,IAAP,EAAc;AACbU,MAAAA,iBAAiB,CAAE,cAAI,8BAAJ,CAAF,EAAwC;AACxDK,QAAAA,IAAI,EAAE;AADkD,OAAxC,CAAjB;AAGA;AACA;;AAED,QAAI;AACH,YAAMC,OAAO,GAAG,MAAMJ,gBAAgB,CACrC,UADqC,EAErC,UAFqC,EAGrC;AACCK,QAAAA,KAAK,EAAEjB,IAAI,IAAI,cAAI,kBAAJ,CADhB;AAECkB,QAAAA,OAAO,EAAE,EAFV;AAGCC,QAAAA,MAAM,EAAE,SAHT;AAICC,QAAAA,IAAI,EAAE;AAAEC,UAAAA,WAAW,EAAEnB;AAAf;AAJP,OAHqC,EASrC;AAAEoB,QAAAA,YAAY,EAAE;AAAhB,OATqC,CAAtC;AAYAxB,MAAAA,QAAQ,CAAE;AAAEkB,QAAAA,OAAF;AAAWO,QAAAA,UAAU,EAAEC;AAAvB,OAAF,CAAR;AACA,KAdD,CAcE,OAAQC,KAAR,EAAgB;AACjB,YAAMC,YAAY,GACjBD,KAAK,CAACE,OAAN,IAAiBF,KAAK,CAACG,IAAN,KAAe,eAAhC,GACGH,KAAK,CAACE,OADT,GAEG,cAAI,+CAAJ,CAHJ;AAKAjB,MAAAA,iBAAiB,CAAEgB,YAAF,EAAgB;AAAEX,QAAAA,IAAI,EAAE;AAAR,OAAhB,CAAjB;AACAhB,MAAAA,OAAO;AACP;AACD;;AAED,SACC,4BAAC,iBAAD;AACC,IAAA,KAAK,EAAG,cAAI,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/create-pattern-modal/index.js"],"names":["CreatePatternModal","closeModal","onCreate","onError","name","setName","syncType","setSyncType","SYNC_TYPES","full","isSubmitting","setIsSubmitting","onSyncChange","unsynced","createErrorNotice","noticesStore","saveEntityRecord","coreStore","createPattern","type","pattern","title","content","status","meta","sync_status","throwOnError","categoryId","USER_PATTERN_CATEGORY","error","errorMessage","message","code","event","preventDefault"],"mappings":";;;;;;;AAaA;;AAVA;;AAQA;;AACA;;AAEA;;AACA;;AAKA;;AApBA;AACA;AACA;;AAeA;AACA;AACA;AAGe,SAASA,kBAAT,CAA6B;AAC3CC,EAAAA,UAD2C;AAE3CC,EAAAA,QAF2C;AAG3CC,EAAAA;AAH2C,CAA7B,EAIX;AACH,QAAM,CAAEC,IAAF,EAAQC,OAAR,IAAoB,uBAAU,EAAV,CAA1B;AACA,QAAM,CAAEC,QAAF,EAAYC,WAAZ,IAA4B,uBAAUC,kBAAWC,IAArB,CAAlC;AACA,QAAM,CAAEC,YAAF,EAAgBC,eAAhB,IAAoC,uBAAU,KAAV,CAA1C;;AAEA,QAAMC,YAAY,GAAG,MAAM;AAC1BL,IAAAA,WAAW,CACVD,QAAQ,KAAKE,kBAAWC,IAAxB,GAA+BD,kBAAWK,QAA1C,GAAqDL,kBAAWC,IADtD,CAAX;AAGA,GAJD;;AAMA,QAAM;AAAEK,IAAAA;AAAF,MAAwB,uBAAaC,cAAb,CAA9B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAuB,uBAAaC,eAAb,CAA7B;;AAEA,iBAAeC,aAAf,GAA+B;AAC9B,QAAK,CAAEd,IAAP,EAAc;AACbU,MAAAA,iBAAiB,CAAE,cAAI,8BAAJ,CAAF,EAAwC;AACxDK,QAAAA,IAAI,EAAE;AADkD,OAAxC,CAAjB;AAGA;AACA;;AAED,QAAI;AACH,YAAMC,OAAO,GAAG,MAAMJ,gBAAgB,CACrC,UADqC,EAErC,UAFqC,EAGrC;AACCK,QAAAA,KAAK,EAAEjB,IAAI,IAAI,cAAI,kBAAJ,CADhB;AAECkB,QAAAA,OAAO,EAAE,EAFV;AAGCC,QAAAA,MAAM,EAAE,SAHT;AAICC,QAAAA,IAAI,EAAE;AAAEC,UAAAA,WAAW,EAAEnB;AAAf;AAJP,OAHqC,EAS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,IAAI,EACHN,QAAQ,KAAKE,kBAAWC,IAAxB,GACG,cAAI,mBAAJ,CADH,GAEG,cAAI,uBAAJ,CANL;AAQC,IAAA,OAAO,EAAGH,QAAQ,KAAKE,kBAAWC;AARnC,IAVD,EAoBC,4BAAC,gCAAD;AAAQ,IAAA,OAAO,EAAC;AAAhB,KACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfR,MAAAA,UAAU;AACV;AAJF,KAMG,cAAI,QAAJ,CANH,CADD,EASC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,QAAQ,EAAG,CAAEG,IAHd;AAIC,IAAA,MAAM,EAAGM;AAJV,KAMG,cAAI,QAAJ,CANH,CATD,CApBD,CAVD,CAPD,CADD;AA4DA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tTextControl,\n\tButton,\n\tModal,\n\tToggleControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { SYNC_TYPES, USER_PATTERN_CATEGORY } from '../page-library/utils';\n\nexport default function CreatePatternModal( {\n\tcloseModal,\n\tonCreate,\n\tonError,\n} ) {\n\tconst [ name, setName ] = useState( '' );\n\tconst [ syncType, setSyncType ] = useState( SYNC_TYPES.full );\n\tconst [ isSubmitting, setIsSubmitting ] = useState( false );\n\n\tconst onSyncChange = () => {\n\t\tsetSyncType(\n\t\t\tsyncType === SYNC_TYPES.full ? SYNC_TYPES.unsynced : SYNC_TYPES.full\n\t\t);\n\t};\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\tasync function createPattern() {\n\t\tif ( ! name ) {\n\t\t\tcreateErrorNotice( __( 'Please enter a pattern name.' ), {\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 pattern = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_block',\n\t\t\t\t{\n\t\t\t\t\ttitle: name || __( 'Untitled Pattern' ),\n\t\t\t\t\tcontent: '',\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\tmeta: { sync_status: syncType },\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tonCreate( { pattern, categoryId: USER_PATTERN_CATEGORY } );\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 pattern.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\tonError();\n\t\t}\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create pattern' ) }\n\t\t\tonRequestClose={ closeModal }\n\t\t\toverlayClassName=\"edit-site-create-pattern-modal\"\n\t\t>\n\t\t\t<p>{ __( 'Turn this block into a pattern to reuse later' ) }</p>\n\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 ( ! name ) {\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 createPattern();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"4\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tclassName=\"edit-site-create-pattern-modal__input\"\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tonChange={ setName }\n\t\t\t\t\t\tplaceholder={ __( 'My pattern' ) }\n\t\t\t\t\t\trequired\n\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Synced' ) }\n\t\t\t\t\t\tonChange={ onSyncChange }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\tsyncType === SYNC_TYPES.full\n\t\t\t\t\t\t\t\t? __( 'Content is synced' )\n\t\t\t\t\t\t\t\t: __( 'Content is not synced' )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchecked={ syncType === SYNC_TYPES.full }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"tertiary\"\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\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={ ! name }\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</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
@@ -85,7 +85,7 @@ function CreateTemplatePartModal({
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
return (0, _element.createElement)(_components.Modal, {
|
|
88
|
-
title: (0, _i18n.__)('Create
|
|
88
|
+
title: (0, _i18n.__)('Create template part'),
|
|
89
89
|
onRequestClose: closeModal,
|
|
90
90
|
overlayClassName: "edit-site-create-template-part-modal"
|
|
91
91
|
}, (0, _element.createElement)("form", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/create-template-part-modal/index.js"],"names":["CreateTemplatePartModal","closeModal","blocks","onCreate","onError","createErrorNotice","noticesStore","saveEntityRecord","coreStore","existingTemplateParts","title","setTitle","area","setArea","TEMPLATE_PART_AREA_GENERAL","isSubmitting","setIsSubmitting","instanceId","templatePartAreas","select","editorStore","__experimentalGetDefaultTemplatePartAreas","createTemplatePart","type","uniqueTitle","cleanSlug","templatePart","slug","content","throwOnError","error","errorMessage","message","code","event","preventDefault","map","icon","label","value","description","check"],"mappings":";;;;;;;AAmBA;;AAhBA;;AACA;;AAcA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AA/BA;AACA;AACA;;AAyBA;AACA;AACA;AAQe,SAASA,uBAAT,CAAkC;AAChDC,EAAAA,UADgD;AAEhDC,EAAAA,MAAM,GAAG,EAFuC;AAGhDC,EAAAA,QAHgD;AAIhDC,EAAAA;AAJgD,CAAlC,EAKX;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAwB,uBAAaC,cAAb,CAA9B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAuB,uBAAaC,eAAb,CAA7B;AACA,QAAMC,qBAAqB,GAAG,mDAA9B;AAEA,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAU,EAAV,CAA5B;AACA,QAAM,CAAEC,IAAF,EAAQC,OAAR,IAAoB,uBAAUC,qCAAV,CAA1B;AACA,QAAM,CAAEC,YAAF,EAAgBC,eAAhB,IAAoC,uBAAU,KAAV,CAA1C;AACA,QAAMC,UAAU,GAAG,4BAAejB,uBAAf,CAAnB;AAEA,QAAMkB,iBAAiB,GAAG,qBACvBC,MAAF,IACCA,MAAM,CAAEC,aAAF,CAAN,CAAsBC,yCAAtB,EAFwB,EAGzB,EAHyB,CAA1B;;AAMA,iBAAeC,kBAAf,GAAoC;AACnC,QAAK,CAAEZ,KAAP,EAAe;AACdL,MAAAA,iBAAiB,CAAE,cAAI,uBAAJ,CAAF,EAAiC;AACjDkB,QAAAA,IAAI,EAAE;AAD2C,OAAjC,CAAjB;AAGA;AACA;;AAED,QAAI;AACH,YAAMC,WAAW,GAAG,oDACnBd,KADmB,EAEnBD,qBAFmB,CAApB;AAIA,YAAMgB,SAAS,GAAG,kDAA0BD,WAA1B,CAAlB;AAEA,YAAME,YAAY,GAAG,MAAMnB,gBAAgB,CAC1C,UAD0C,EAE1C,kBAF0C,EAG1C;AACCoB,QAAAA,IAAI,EAAEF,SADP;AAECf,QAAAA,KAAK,EAAEc,WAFR;AAGCI,QAAAA,OAAO,EAAE,uBAAW1B,MAAX,CAHV;AAICU,QAAAA;AAJD,OAH0C,EAS1C;AAAEiB,QAAAA,YAAY,EAAE;AAAhB,OAT0C,CAA3C;AAWA,YAAM1B,QAAQ,CAAEuB,YAAF,CAAd,CAlBG,CAoBH;AACA,KArBD,CAqBE,OAAQI,KAAR,EAAgB;AACjB,YAAMC,YAAY,GACjBD,KAAK,CAACE,OAAN,IAAiBF,KAAK,CAACG,IAAN,KAAe,eAAhC,GACGH,KAAK,CAACE,OADT,GAEG,cACA,qDADA,CAHJ;AAOA3B,MAAAA,iBAAiB,CAAE0B,YAAF,EAAgB;AAAER,QAAAA,IAAI,EAAE;AAAR,OAAhB,CAAjB;AAEAnB,MAAAA,OAAO;AACP;AACD;;AAED,SACC,4BAAC,iBAAD;AACC,IAAA,KAAK,EAAG,cAAI,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/create-template-part-modal/index.js"],"names":["CreateTemplatePartModal","closeModal","blocks","onCreate","onError","createErrorNotice","noticesStore","saveEntityRecord","coreStore","existingTemplateParts","title","setTitle","area","setArea","TEMPLATE_PART_AREA_GENERAL","isSubmitting","setIsSubmitting","instanceId","templatePartAreas","select","editorStore","__experimentalGetDefaultTemplatePartAreas","createTemplatePart","type","uniqueTitle","cleanSlug","templatePart","slug","content","throwOnError","error","errorMessage","message","code","event","preventDefault","map","icon","label","value","description","check"],"mappings":";;;;;;;AA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/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } 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\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\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 { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { serialize } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_PART_AREA_GENERAL } from '../../store/constants';\nimport {\n\tuseExistingTemplateParts,\n\tgetUniqueTemplatePartTitle,\n\tgetCleanTemplatePartSlug,\n} from '../../utils/template-part-create';\n\nexport default function CreateTemplatePartModal( {\n\tcloseModal,\n\tblocks = [],\n\tonCreate,\n\tonError,\n} ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst existingTemplateParts = useExistingTemplateParts();\n\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\tasync function createTemplatePart() {\n\t\tif ( ! title ) {\n\t\t\tcreateErrorNotice( __( 'Please enter a title.' ), {\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 uniqueTitle = getUniqueTemplatePartTitle(\n\t\t\t\ttitle,\n\t\t\t\texistingTemplateParts\n\t\t\t);\n\t\t\tconst cleanSlug = getCleanTemplatePartSlug( uniqueTitle );\n\n\t\t\tconst templatePart = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t{\n\t\t\t\t\tslug: cleanSlug,\n\t\t\t\t\ttitle: uniqueTitle,\n\t\t\t\t\tcontent: serialize( blocks ),\n\t\t\t\t\tarea,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tawait onCreate( templatePart );\n\n\t\t\t// TODO: Add a success notice?\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\n\t\t\tonError?.();\n\t\t}\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create template part' ) }\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 createTemplatePart();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"4\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t\t<BaseControl\n\t\t\t\t\t\tlabel={ __( 'Area' ) }\n\t\t\t\t\t\tid={ `edit-site-create-template-part-modal__area-selection-${ instanceId }` }\n\t\t\t\t\t\tclassName=\"edit-site-create-template-part-modal__area-base-control\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<RadioGroup\n\t\t\t\t\t\t\tlabel={ __( 'Area' ) }\n\t\t\t\t\t\t\tclassName=\"edit-site-create-template-part-modal__area-radio-group\"\n\t\t\t\t\t\t\tid={ `edit-site-create-template-part-modal__area-selection-${ instanceId }` }\n\t\t\t\t\t\t\tonChange={ setArea }\n\t\t\t\t\t\t\tchecked={ area }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ templatePartAreas.map(\n\t\t\t\t\t\t\t\t( {\n\t\t\t\t\t\t\t\t\ticon,\n\t\t\t\t\t\t\t\t\tlabel,\n\t\t\t\t\t\t\t\t\tarea: value,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t} ) => (\n\t\t\t\t\t\t\t\t\t<Radio\n\t\t\t\t\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\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\t>\n\t\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\t<FlexItem>\n\t\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\t</FlexItem>\n\t\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\t{ label }\n\t\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\t</FlexBlock>\n\n\t\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\t{ area === value && (\n\t\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\t) }\n\t\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t\t\t\t</Radio>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</RadioGroup>\n\t\t\t\t\t</BaseControl>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"tertiary\"\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\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</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
@@ -192,6 +192,7 @@ function Editor({
|
|
|
192
192
|
}, (0, _element.createElement)(_blockEditor.BlockContextProvider, {
|
|
193
193
|
value: blockContext
|
|
194
194
|
}, (0, _element.createElement)(_sidebarEditMode.SidebarComplementaryAreaFills, null), isEditMode && (0, _element.createElement)(_startTemplateOptions.default, null), (0, _element.createElement)(_interface.InterfaceSkeleton, {
|
|
195
|
+
isDistractionFree: true,
|
|
195
196
|
enableRegionNavigation: false,
|
|
196
197
|
className: (0, _classnames.default)('edit-site-editor__interface-skeleton', {
|
|
197
198
|
'show-icon-labels': showIconLabels,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/editor/index.js"],"names":["BlockRemovalWarningModal","blockEditorPrivateApis","interfaceLabels","body","sidebar","actions","footer","typeLabels","wp_template","wp_template_part","wp_block","Editor","isLoading","record","editedPost","getTitle","isLoaded","hasLoadedPost","id","editedPostId","type","editedPostType","context","editorMode","canvasMode","blockEditorMode","isRightSidebarOpen","isInserterOpen","isListViewOpen","showIconLabels","showBlockBreadcrumbs","hasPageContentFocus","select","getEditedPostContext","getEditorMode","getCanvasMode","isInserterOpened","isListViewOpened","_hasPageContentFocus","editSiteStore","__unstableGetEditorMode","blockEditorStore","getActiveComplementaryArea","interfaceStore","name","preferencesStore","get","setEditedPostContext","isViewMode","isEditMode","showVisualEditor","shouldShowBlockBreadcrumbs","shouldShowInserter","shouldShowListView","secondarySidebarLabel","blockContext","postType","postId","nonPostFields","queryContext","page","newQueryContext","title","secondarySidebar"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA5CA;AACA;AACA;;AAGA;AACA;AACA;;AAoBA;AACA;AACA;AAiBA,MAAM;AAAEA,EAAAA;AAAF,IAA+B,wBAAQC,wBAAR,CAArC;AAEA,MAAMC,eAAe,GAAG;AACvB;AACAC,EAAAA,IAAI,EAAE,cAAI,gBAAJ,CAFiB;;AAGvB;AACAC,EAAAA,OAAO,EAAE,cAAI,iBAAJ,CAJc;;AAKvB;AACAC,EAAAA,OAAO,EAAE,cAAI,gBAAJ,CANc;;AAOvB;AACAC,EAAAA,MAAM,EAAE,cAAI,eAAJ;AARe,CAAxB;AAWA,MAAMC,UAAU,GAAG;AAClBC,EAAAA,WAAW,EAAE,cAAI,eAAJ,CADK;AAElBC,EAAAA,gBAAgB,EAAE,cAAI,eAAJ,CAFA;AAGlBC,EAAAA,QAAQ,EAAE,cAAI,SAAJ;AAHQ,CAAnB;;AAMe,SAASC,MAAT,CAAi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AU,KAAK,MAAf,IACDT,UADC,IAEDmC,UAFC,IAEa,4BAAC,mBAAD,OAXhB,EAYGhC,aAAa,IAAI,CAAEH,UAAnB,IACD,4BAAC,kBAAD;AACC,MAAA,MAAM,EAAC,SADR;AAEC,MAAA,aAAa,EAAG;AAFjB,OAIG,cACD,2EADC,CAJH,CAbF,EAsBGmC,UAAU,IACX,4BAAC,iBAAD,OAvBF,CAXF;AAsCC,IAAA,gBAAgB,EACfA,UAAU,KACNG,kBAAkB,IACrB,4BAAC,wBAAD,OADC,IAGCC,kBAAkB,IACnB,4BAAC,wBAAD,OALQ,CAvCZ;AA+CC,IAAA,OAAO,EACNJ,UAAU,IACVvB,kBADA,IAEC,qDACC,4BAAC,4BAAD,CAAmB,IAAnB;AAAwB,MAAA,KAAK,EAAC;AAA9B,MADD,EAEC,4BAAC,0CAAD,OAFD,CAlDH;AAwDC,IAAA,MAAM,EACLyB,0BAA0B,IACzB,4BAAC,4BAAD;AACC,MAAA,aAAa,EACZpB,mBAAmB,GAChB,cAAI,MAAJ,CADgB,GAEhB,cAAI,UAAJ;AAJL,MA1DH;AAmEC,IAAA,MAAM,EAAG,EACR,GAAG7B,eADK;AAER6D,MAAAA,gBAAgB,EAAET;AAFV;AAnEV,IAHD,CALD,CADD,CAHD,CADD;AA0FA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Notice } from '@wordpress/components';\nimport { EntityProvider } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tBlockContextProvider,\n\tBlockBreadcrumb,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { EditorNotices, EditorSnackbars } from '@wordpress/editor';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { SidebarComplementaryAreaFills } from '../sidebar-edit-mode';\nimport BlockEditor from '../block-editor';\nimport CodeEditor from '../code-editor';\nimport KeyboardShortcutsEditMode from '../keyboard-shortcuts/edit-mode';\nimport InserterSidebar from '../secondary-sidebar/inserter-sidebar';\nimport ListViewSidebar from '../secondary-sidebar/list-view-sidebar';\nimport WelcomeGuide from '../welcome-guide';\nimport StartTemplateOptions from '../start-template-options';\nimport { store as editSiteStore } from '../../store';\nimport { GlobalStylesRenderer } from '../global-styles-renderer';\nimport useTitle from '../routes/use-title';\nimport CanvasSpinner from '../canvas-spinner';\nimport { unlock } from '../../lock-unlock';\nimport useEditedEntityRecord from '../use-edited-entity-record';\nimport { SidebarFixedBottomSlot } from '../sidebar-edit-mode/sidebar-fixed-bottom';\n\nconst { BlockRemovalWarningModal } = unlock( blockEditorPrivateApis );\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the editor content landmark region. */\n\tbody: __( 'Editor content' ),\n\t/* translators: accessibility text for the editor settings landmark region. */\n\tsidebar: __( 'Editor settings' ),\n\t/* translators: accessibility text for the editor publish landmark region. */\n\tactions: __( 'Editor publish' ),\n\t/* translators: accessibility text for the editor footer landmark region. */\n\tfooter: __( 'Editor footer' ),\n};\n\nconst typeLabels = {\n\twp_template: __( 'Template Part' ),\n\twp_template_part: __( 'Template Part' ),\n\twp_block: __( 'Pattern' ),\n};\n\nexport default function Editor( { isLoading } ) {\n\tconst {\n\t\trecord: editedPost,\n\t\tgetTitle,\n\t\tisLoaded: hasLoadedPost,\n\t} = useEditedEntityRecord();\n\n\tconst { id: editedPostId, type: editedPostType } = editedPost;\n\n\tconst {\n\t\tcontext,\n\t\teditorMode,\n\t\tcanvasMode,\n\t\tblockEditorMode,\n\t\tisRightSidebarOpen,\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tshowIconLabels,\n\t\tshowBlockBreadcrumbs,\n\t\thasPageContentFocus,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEditedPostContext,\n\t\t\tgetEditorMode,\n\t\t\tgetCanvasMode,\n\t\t\tisInserterOpened,\n\t\t\tisListViewOpened,\n\t\t\thasPageContentFocus: _hasPageContentFocus,\n\t\t} = unlock( select( editSiteStore ) );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\n\t\t// The currently selected entity to display.\n\t\t// Typically template or template part in the site editor.\n\t\treturn {\n\t\t\tcontext: getEditedPostContext(),\n\t\t\teditorMode: getEditorMode(),\n\t\t\tcanvasMode: getCanvasMode(),\n\t\t\tblockEditorMode: __unstableGetEditorMode(),\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tisRightSidebarOpen: getActiveComplementaryArea(\n\t\t\t\teditSiteStore.name\n\t\t\t),\n\t\t\tshowIconLabels: select( preferencesStore ).get(\n\t\t\t\t'core/edit-site',\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t\tshowBlockBreadcrumbs: select( preferencesStore ).get(\n\t\t\t\t'core/edit-site',\n\t\t\t\t'showBlockBreadcrumbs'\n\t\t\t),\n\t\t\thasPageContentFocus: _hasPageContentFocus(),\n\t\t};\n\t}, [] );\n\tconst { setEditedPostContext } = useDispatch( editSiteStore );\n\n\tconst isViewMode = canvasMode === 'view';\n\tconst isEditMode = canvasMode === 'edit';\n\tconst showVisualEditor = isViewMode || editorMode === 'visual';\n\tconst shouldShowBlockBreadcrumbs =\n\t\tshowBlockBreadcrumbs &&\n\t\tisEditMode &&\n\t\tshowVisualEditor &&\n\t\tblockEditorMode !== 'zoom-out';\n\tconst shouldShowInserter = isEditMode && showVisualEditor && isInserterOpen;\n\tconst shouldShowListView = isEditMode && showVisualEditor && isListViewOpen;\n\tconst secondarySidebarLabel = isListViewOpen\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\tconst blockContext = useMemo( () => {\n\t\tconst { postType, postId, ...nonPostFields } = context ?? {};\n\t\treturn {\n\t\t\t...( hasPageContentFocus ? context : nonPostFields ),\n\t\t\tqueryContext: [\n\t\t\t\tcontext?.queryContext || { page: 1 },\n\t\t\t\t( newQueryContext ) =>\n\t\t\t\t\tsetEditedPostContext( {\n\t\t\t\t\t\t...context,\n\t\t\t\t\t\tqueryContext: {\n\t\t\t\t\t\t\t...context?.queryContext,\n\t\t\t\t\t\t\t...newQueryContext,\n\t\t\t\t\t\t},\n\t\t\t\t\t} ),\n\t\t\t],\n\t\t};\n\t}, [ hasPageContentFocus, context, setEditedPostContext ] );\n\n\tlet title;\n\tif ( hasLoadedPost ) {\n\t\tconst type = typeLabels[ editedPostType ] ?? __( 'Template' );\n\t\ttitle = sprintf(\n\t\t\t// translators: A breadcrumb trail in browser tab. %1$s: title of template being edited, %2$s: type of template (Template or Template Part).\n\t\t\t__( '%1$s ‹ %2$s ‹ Editor' ),\n\t\t\tgetTitle(),\n\t\t\ttype\n\t\t);\n\t}\n\n\t// Only announce the title once the editor is ready to prevent \"Replace\"\n\t// action in <URLQueryController> from double-announcing.\n\tuseTitle( hasLoadedPost && title );\n\n\treturn (\n\t\t<>\n\t\t\t{ isLoading ? <CanvasSpinner /> : null }\n\t\t\t{ isEditMode && <WelcomeGuide /> }\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ editedPostType }\n\t\t\t\t\tid={ editedPostId }\n\t\t\t\t>\n\t\t\t\t\t<BlockContextProvider value={ blockContext }>\n\t\t\t\t\t\t<SidebarComplementaryAreaFills />\n\t\t\t\t\t\t{ isEditMode && <StartTemplateOptions /> }\n\t\t\t\t\t\t<InterfaceSkeleton\n\t\t\t\t\t\t\tenableRegionNavigation={ false }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'edit-site-editor__interface-skeleton',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'show-icon-labels': showIconLabels,\n\t\t\t\t\t\t\t\t\t'is-loading': isLoading,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tnotices={ <EditorSnackbars /> }\n\t\t\t\t\t\t\tcontent={\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<GlobalStylesRenderer />\n\t\t\t\t\t\t\t\t\t{ isEditMode && <EditorNotices /> }\n\t\t\t\t\t\t\t\t\t{ showVisualEditor && editedPost && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<BlockEditor />\n\t\t\t\t\t\t\t\t\t\t\t<BlockRemovalWarningModal />\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ editorMode === 'text' &&\n\t\t\t\t\t\t\t\t\t\teditedPost &&\n\t\t\t\t\t\t\t\t\t\tisEditMode && <CodeEditor /> }\n\t\t\t\t\t\t\t\t\t{ hasLoadedPost && ! editedPost && (\n\t\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\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\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) }\n\t\t\t\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ isEditMode && (\n\t\t\t\t\t\t\t\t\t\t<KeyboardShortcutsEditMode />\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}\n\t\t\t\t\t\t\tsecondarySidebar={\n\t\t\t\t\t\t\t\tisEditMode &&\n\t\t\t\t\t\t\t\t( ( shouldShowInserter && (\n\t\t\t\t\t\t\t\t\t<InserterSidebar />\n\t\t\t\t\t\t\t\t) ) ||\n\t\t\t\t\t\t\t\t\t( shouldShowListView && (\n\t\t\t\t\t\t\t\t\t\t<ListViewSidebar />\n\t\t\t\t\t\t\t\t\t) ) )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsidebar={\n\t\t\t\t\t\t\t\tisEditMode &&\n\t\t\t\t\t\t\t\tisRightSidebarOpen && (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<ComplementaryArea.Slot scope=\"core/edit-site\" />\n\t\t\t\t\t\t\t\t\t\t<SidebarFixedBottomSlot />\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}\n\t\t\t\t\t\t\tfooter={\n\t\t\t\t\t\t\t\tshouldShowBlockBreadcrumbs && (\n\t\t\t\t\t\t\t\t\t<BlockBreadcrumb\n\t\t\t\t\t\t\t\t\t\trootLabelText={\n\t\t\t\t\t\t\t\t\t\t\thasPageContentFocus\n\t\t\t\t\t\t\t\t\t\t\t\t? __( 'Page' )\n\t\t\t\t\t\t\t\t\t\t\t\t: __( 'Template' )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlabels={ {\n\t\t\t\t\t\t\t\t...interfaceLabels,\n\t\t\t\t\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t</>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/editor/index.js"],"names":["BlockRemovalWarningModal","blockEditorPrivateApis","interfaceLabels","body","sidebar","actions","footer","typeLabels","wp_template","wp_template_part","wp_block","Editor","isLoading","record","editedPost","getTitle","isLoaded","hasLoadedPost","id","editedPostId","type","editedPostType","context","editorMode","canvasMode","blockEditorMode","isRightSidebarOpen","isInserterOpen","isListViewOpen","showIconLabels","showBlockBreadcrumbs","hasPageContentFocus","select","getEditedPostContext","getEditorMode","getCanvasMode","isInserterOpened","isListViewOpened","_hasPageContentFocus","editSiteStore","__unstableGetEditorMode","blockEditorStore","getActiveComplementaryArea","interfaceStore","name","preferencesStore","get","setEditedPostContext","isViewMode","isEditMode","showVisualEditor","shouldShowBlockBreadcrumbs","shouldShowInserter","shouldShowListView","secondarySidebarLabel","blockContext","postType","postId","nonPostFields","queryContext","page","newQueryContext","title","secondarySidebar"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA5CA;AACA;AACA;;AAGA;AACA;AACA;;AAoBA;AACA;AACA;AAiBA,MAAM;AAAEA,EAAAA;AAAF,IAA+B,wBAAQC,wBAAR,CAArC;AAEA,MAAMC,eAAe,GAAG;AACvB;AACAC,EAAAA,IAAI,EAAE,cAAI,gBAAJ,CAFiB;;AAGvB;AACAC,EAAAA,OAAO,EAAE,cAAI,iBAAJ,CAJc;;AAKvB;AACAC,EAAAA,OAAO,EAAE,cAAI,gBAAJ,CANc;;AAOvB;AACAC,EAAAA,MAAM,EAAE,cAAI,eAAJ;AARe,CAAxB;AAWA,MAAMC,UAAU,GAAG;AAClBC,EAAAA,WAAW,EAAE,cAAI,eAAJ,CADK;AAElBC,EAAAA,gBAAgB,EAAE,cAAI,eAAJ,CAFA;AAGlBC,EAAAA,QAAQ,EAAE,cAAI,SAAJ;AAHQ,CAAnB;;AAMe,SAASC,MAAT,CAAiB;AAAEC,EAAAA;AAAF,CAAjB,EAAiC;AAC/C,QAAM;AACLC,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UADC,IAEDmC,UAFC,IAEa,4BAAC,mBAAD,OAXhB,EAYGhC,aAAa,IAAI,CAAEH,UAAnB,IACD,4BAAC,kBAAD;AACC,MAAA,MAAM,EAAC,SADR;AAEC,MAAA,aAAa,EAAG;AAFjB,OAIG,cACD,2EADC,CAJH,CAbF,EAsBGmC,UAAU,IACX,4BAAC,iBAAD,OAvBF,CAZF;AAuCC,IAAA,gBAAgB,EACfA,UAAU,KACNG,kBAAkB,IACrB,4BAAC,wBAAD,OADC,IAGCC,kBAAkB,IACnB,4BAAC,wBAAD,OALQ,CAxCZ;AAgDC,IAAA,OAAO,EACNJ,UAAU,IACVvB,kBADA,IAEC,qDACC,4BAAC,4BAAD,CAAmB,IAAnB;AAAwB,MAAA,KAAK,EAAC;AAA9B,MADD,EAEC,4BAAC,0CAAD,OAFD,CAnDH;AAyDC,IAAA,MAAM,EACLyB,0BAA0B,IACzB,4BAAC,4BAAD;AACC,MAAA,aAAa,EACZpB,mBAAmB,GAChB,cAAI,MAAJ,CADgB,GAEhB,cAAI,UAAJ;AAJL,MA3DH;AAoEC,IAAA,MAAM,EAAG,EACR,GAAG7B,eADK;AAER6D,MAAAA,gBAAgB,EAAET;AAFV;AApEV,IAHD,CALD,CADD,CAHD,CADD;AA2FA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Notice } from '@wordpress/components';\nimport { EntityProvider } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tBlockContextProvider,\n\tBlockBreadcrumb,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { EditorNotices, EditorSnackbars } from '@wordpress/editor';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { SidebarComplementaryAreaFills } from '../sidebar-edit-mode';\nimport BlockEditor from '../block-editor';\nimport CodeEditor from '../code-editor';\nimport KeyboardShortcutsEditMode from '../keyboard-shortcuts/edit-mode';\nimport InserterSidebar from '../secondary-sidebar/inserter-sidebar';\nimport ListViewSidebar from '../secondary-sidebar/list-view-sidebar';\nimport WelcomeGuide from '../welcome-guide';\nimport StartTemplateOptions from '../start-template-options';\nimport { store as editSiteStore } from '../../store';\nimport { GlobalStylesRenderer } from '../global-styles-renderer';\nimport useTitle from '../routes/use-title';\nimport CanvasSpinner from '../canvas-spinner';\nimport { unlock } from '../../lock-unlock';\nimport useEditedEntityRecord from '../use-edited-entity-record';\nimport { SidebarFixedBottomSlot } from '../sidebar-edit-mode/sidebar-fixed-bottom';\n\nconst { BlockRemovalWarningModal } = unlock( blockEditorPrivateApis );\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the editor content landmark region. */\n\tbody: __( 'Editor content' ),\n\t/* translators: accessibility text for the editor settings landmark region. */\n\tsidebar: __( 'Editor settings' ),\n\t/* translators: accessibility text for the editor publish landmark region. */\n\tactions: __( 'Editor publish' ),\n\t/* translators: accessibility text for the editor footer landmark region. */\n\tfooter: __( 'Editor footer' ),\n};\n\nconst typeLabels = {\n\twp_template: __( 'Template Part' ),\n\twp_template_part: __( 'Template Part' ),\n\twp_block: __( 'Pattern' ),\n};\n\nexport default function Editor( { isLoading } ) {\n\tconst {\n\t\trecord: editedPost,\n\t\tgetTitle,\n\t\tisLoaded: hasLoadedPost,\n\t} = useEditedEntityRecord();\n\n\tconst { id: editedPostId, type: editedPostType } = editedPost;\n\n\tconst {\n\t\tcontext,\n\t\teditorMode,\n\t\tcanvasMode,\n\t\tblockEditorMode,\n\t\tisRightSidebarOpen,\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tshowIconLabels,\n\t\tshowBlockBreadcrumbs,\n\t\thasPageContentFocus,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEditedPostContext,\n\t\t\tgetEditorMode,\n\t\t\tgetCanvasMode,\n\t\t\tisInserterOpened,\n\t\t\tisListViewOpened,\n\t\t\thasPageContentFocus: _hasPageContentFocus,\n\t\t} = unlock( select( editSiteStore ) );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\n\t\t// The currently selected entity to display.\n\t\t// Typically template or template part in the site editor.\n\t\treturn {\n\t\t\tcontext: getEditedPostContext(),\n\t\t\teditorMode: getEditorMode(),\n\t\t\tcanvasMode: getCanvasMode(),\n\t\t\tblockEditorMode: __unstableGetEditorMode(),\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tisRightSidebarOpen: getActiveComplementaryArea(\n\t\t\t\teditSiteStore.name\n\t\t\t),\n\t\t\tshowIconLabels: select( preferencesStore ).get(\n\t\t\t\t'core/edit-site',\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t\tshowBlockBreadcrumbs: select( preferencesStore ).get(\n\t\t\t\t'core/edit-site',\n\t\t\t\t'showBlockBreadcrumbs'\n\t\t\t),\n\t\t\thasPageContentFocus: _hasPageContentFocus(),\n\t\t};\n\t}, [] );\n\tconst { setEditedPostContext } = useDispatch( editSiteStore );\n\n\tconst isViewMode = canvasMode === 'view';\n\tconst isEditMode = canvasMode === 'edit';\n\tconst showVisualEditor = isViewMode || editorMode === 'visual';\n\tconst shouldShowBlockBreadcrumbs =\n\t\tshowBlockBreadcrumbs &&\n\t\tisEditMode &&\n\t\tshowVisualEditor &&\n\t\tblockEditorMode !== 'zoom-out';\n\tconst shouldShowInserter = isEditMode && showVisualEditor && isInserterOpen;\n\tconst shouldShowListView = isEditMode && showVisualEditor && isListViewOpen;\n\tconst secondarySidebarLabel = isListViewOpen\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\tconst blockContext = useMemo( () => {\n\t\tconst { postType, postId, ...nonPostFields } = context ?? {};\n\t\treturn {\n\t\t\t...( hasPageContentFocus ? context : nonPostFields ),\n\t\t\tqueryContext: [\n\t\t\t\tcontext?.queryContext || { page: 1 },\n\t\t\t\t( newQueryContext ) =>\n\t\t\t\t\tsetEditedPostContext( {\n\t\t\t\t\t\t...context,\n\t\t\t\t\t\tqueryContext: {\n\t\t\t\t\t\t\t...context?.queryContext,\n\t\t\t\t\t\t\t...newQueryContext,\n\t\t\t\t\t\t},\n\t\t\t\t\t} ),\n\t\t\t],\n\t\t};\n\t}, [ hasPageContentFocus, context, setEditedPostContext ] );\n\n\tlet title;\n\tif ( hasLoadedPost ) {\n\t\tconst type = typeLabels[ editedPostType ] ?? __( 'Template' );\n\t\ttitle = sprintf(\n\t\t\t// translators: A breadcrumb trail in browser tab. %1$s: title of template being edited, %2$s: type of template (Template or Template Part).\n\t\t\t__( '%1$s ‹ %2$s ‹ Editor' ),\n\t\t\tgetTitle(),\n\t\t\ttype\n\t\t);\n\t}\n\n\t// Only announce the title once the editor is ready to prevent \"Replace\"\n\t// action in <URLQueryController> from double-announcing.\n\tuseTitle( hasLoadedPost && title );\n\n\treturn (\n\t\t<>\n\t\t\t{ isLoading ? <CanvasSpinner /> : null }\n\t\t\t{ isEditMode && <WelcomeGuide /> }\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ editedPostType }\n\t\t\t\t\tid={ editedPostId }\n\t\t\t\t>\n\t\t\t\t\t<BlockContextProvider value={ blockContext }>\n\t\t\t\t\t\t<SidebarComplementaryAreaFills />\n\t\t\t\t\t\t{ isEditMode && <StartTemplateOptions /> }\n\t\t\t\t\t\t<InterfaceSkeleton\n\t\t\t\t\t\t\tisDistractionFree={ true }\n\t\t\t\t\t\t\tenableRegionNavigation={ false }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'edit-site-editor__interface-skeleton',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'show-icon-labels': showIconLabels,\n\t\t\t\t\t\t\t\t\t'is-loading': isLoading,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tnotices={ <EditorSnackbars /> }\n\t\t\t\t\t\t\tcontent={\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<GlobalStylesRenderer />\n\t\t\t\t\t\t\t\t\t{ isEditMode && <EditorNotices /> }\n\t\t\t\t\t\t\t\t\t{ showVisualEditor && editedPost && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<BlockEditor />\n\t\t\t\t\t\t\t\t\t\t\t<BlockRemovalWarningModal />\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ editorMode === 'text' &&\n\t\t\t\t\t\t\t\t\t\teditedPost &&\n\t\t\t\t\t\t\t\t\t\tisEditMode && <CodeEditor /> }\n\t\t\t\t\t\t\t\t\t{ hasLoadedPost && ! editedPost && (\n\t\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\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\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) }\n\t\t\t\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ isEditMode && (\n\t\t\t\t\t\t\t\t\t\t<KeyboardShortcutsEditMode />\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}\n\t\t\t\t\t\t\tsecondarySidebar={\n\t\t\t\t\t\t\t\tisEditMode &&\n\t\t\t\t\t\t\t\t( ( shouldShowInserter && (\n\t\t\t\t\t\t\t\t\t<InserterSidebar />\n\t\t\t\t\t\t\t\t) ) ||\n\t\t\t\t\t\t\t\t\t( shouldShowListView && (\n\t\t\t\t\t\t\t\t\t\t<ListViewSidebar />\n\t\t\t\t\t\t\t\t\t) ) )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsidebar={\n\t\t\t\t\t\t\t\tisEditMode &&\n\t\t\t\t\t\t\t\tisRightSidebarOpen && (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<ComplementaryArea.Slot scope=\"core/edit-site\" />\n\t\t\t\t\t\t\t\t\t\t<SidebarFixedBottomSlot />\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}\n\t\t\t\t\t\t\tfooter={\n\t\t\t\t\t\t\t\tshouldShowBlockBreadcrumbs && (\n\t\t\t\t\t\t\t\t\t<BlockBreadcrumb\n\t\t\t\t\t\t\t\t\t\trootLabelText={\n\t\t\t\t\t\t\t\t\t\t\thasPageContentFocus\n\t\t\t\t\t\t\t\t\t\t\t\t? __( 'Page' )\n\t\t\t\t\t\t\t\t\t\t\t\t: __( 'Template' )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlabels={ {\n\t\t\t\t\t\t\t\t...interfaceLabels,\n\t\t\t\t\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -167,7 +167,7 @@ function GlobalStylesRevisionsMenu() {
|
|
|
167
167
|
};
|
|
168
168
|
|
|
169
169
|
const hasRevisions = revisionsCount >= 2;
|
|
170
|
-
return (0, _element.createElement)(GlobalStylesMenuFill, null, (0, _element.createElement)(_components.DropdownMenu, {
|
|
170
|
+
return (0, _element.createElement)(GlobalStylesMenuFill, null, canReset || hasRevisions ? (0, _element.createElement)(_components.DropdownMenu, {
|
|
171
171
|
icon: _icons.backup,
|
|
172
172
|
label: (0, _i18n.__)('Revisions')
|
|
173
173
|
}, ({
|
|
@@ -181,7 +181,12 @@ function GlobalStylesRevisionsMenu() {
|
|
|
181
181
|
onClose();
|
|
182
182
|
},
|
|
183
183
|
disabled: !canReset
|
|
184
|
-
}, (0, _i18n.__)('Reset to defaults')))))
|
|
184
|
+
}, (0, _i18n.__)('Reset to defaults')))) : (0, _element.createElement)(_components.Button, {
|
|
185
|
+
label: (0, _i18n.__)('Revisions'),
|
|
186
|
+
icon: _icons.backup,
|
|
187
|
+
disabled: true,
|
|
188
|
+
__experimentalIsFocusable: true
|
|
189
|
+
}));
|
|
185
190
|
}
|
|
186
191
|
|
|
187
192
|
function GlobalStylesNavigationScreen({
|