@wordpress/edit-site 3.0.18-next.33ec3857e2.0 → 3.0.21
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/block-editor/index.js +1 -1
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/resizable-editor.js +37 -8
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/global-styles/border-panel.js +22 -81
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +7 -3
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +10 -9
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +1 -1
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +10 -6
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +10 -6
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/ui.js +14 -27
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/list/actions/index.js +0 -1
- package/build/components/list/actions/index.js.map +1 -1
- package/build/components/list/added-by.js +9 -3
- package/build/components/list/added-by.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/constants.js +1 -11
- package/build/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-toggle/index.js +10 -1
- package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build/components/sidebar/default-sidebar.js +2 -4
- package/build/components/sidebar/default-sidebar.js.map +1 -1
- package/build/components/sidebar/global-styles-sidebar.js +0 -1
- package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build/plugins/site-export.js +1 -1
- package/build/plugins/site-export.js.map +1 -1
- package/build-module/components/block-editor/index.js +2 -2
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/resizable-editor.js +37 -8
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +23 -82
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +5 -4
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +11 -9
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +1 -1
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +11 -7
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +11 -7
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/ui.js +14 -26
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/list/actions/index.js +0 -1
- package/build-module/components/list/actions/index.js.map +1 -1
- package/build-module/components/list/added-by.js +10 -4
- package/build-module/components/list/added-by.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/constants.js +0 -5
- package/build-module/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js +11 -1
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build-module/components/sidebar/default-sidebar.js +2 -4
- package/build-module/components/sidebar/default-sidebar.js.map +1 -1
- package/build-module/components/sidebar/global-styles-sidebar.js +0 -1
- package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build-module/plugins/site-export.js +2 -2
- package/build-module/plugins/site-export.js.map +1 -1
- package/build-style/style-rtl.css +62 -32
- package/build-style/style.css +62 -32
- package/package.json +28 -28
- package/src/components/block-editor/index.js +2 -2
- package/src/components/block-editor/resizable-editor.js +52 -13
- package/src/components/block-editor/style.scss +18 -10
- package/src/components/global-styles/border-panel.js +42 -106
- package/src/components/global-styles/gradients-palette-panel.js +4 -4
- package/src/components/global-styles/screen-background-color.js +10 -7
- package/src/components/global-styles/screen-colors.js +1 -1
- package/src/components/global-styles/screen-link-color.js +14 -6
- package/src/components/global-styles/screen-text-color.js +14 -6
- package/src/components/global-styles/style.scss +19 -1
- package/src/components/global-styles/ui.js +25 -50
- package/src/components/header/document-actions/style.scss +9 -1
- package/src/components/header/style.scss +1 -2
- package/src/components/list/actions/index.js +0 -1
- package/src/components/list/added-by.js +25 -9
- package/src/components/navigation-sidebar/navigation-panel/constants.js +0 -15
- package/src/components/navigation-sidebar/navigation-toggle/index.js +12 -0
- package/src/components/navigation-sidebar/navigation-toggle/style.scss +8 -4
- package/src/components/sidebar/default-sidebar.js +0 -2
- package/src/components/sidebar/global-styles-sidebar.js +0 -1
- package/src/components/sidebar/style.scss +14 -21
- package/src/plugins/site-export.js +2 -2
- package/build/components/navigation-sidebar/navigation-panel/content-navigation-item.js +0 -101
- package/build/components/navigation-sidebar/navigation-panel/content-navigation-item.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/menus/content-categories.js +0 -82
- package/build/components/navigation-sidebar/navigation-panel/menus/content-categories.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/menus/content-pages.js +0 -82
- package/build/components/navigation-sidebar/navigation-panel/menus/content-pages.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/menus/content-posts.js +0 -107
- package/build/components/navigation-sidebar/navigation-panel/menus/content-posts.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/menus/index.js +0 -57
- package/build/components/navigation-sidebar/navigation-panel/menus/index.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js +0 -48
- package/build/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/menus/template-parts.js +0 -100
- package/build/components/navigation-sidebar/navigation-panel/menus/template-parts.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/menus/templates-sub.js +0 -62
- package/build/components/navigation-sidebar/navigation-panel/menus/templates-sub.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/menus/templates.js +0 -143
- package/build/components/navigation-sidebar/navigation-panel/menus/templates.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/navigation-entity-items.js +0 -76
- package/build/components/navigation-sidebar/navigation-panel/navigation-entity-items.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/new-template-dropdown.js +0 -125
- package/build/components/navigation-sidebar/navigation-panel/new-template-dropdown.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/search-results.js +0 -132
- package/build/components/navigation-sidebar/navigation-panel/search-results.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/template-navigation-item.js +0 -86
- package/build/components/navigation-sidebar/navigation-panel/template-navigation-item.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/template-preview.js +0 -46
- package/build/components/navigation-sidebar/navigation-panel/template-preview.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/use-debounced-search.js +0 -47
- package/build/components/navigation-sidebar/navigation-panel/use-debounced-search.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/utils.js +0 -21
- package/build/components/navigation-sidebar/navigation-panel/utils.js.map +0 -1
- package/build/utils/get-closest-available-template.js +0 -48
- package/build/utils/get-closest-available-template.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/content-navigation-item.js +0 -86
- package/build-module/components/navigation-sidebar/navigation-panel/content-navigation-item.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/menus/content-categories.js +0 -65
- package/build-module/components/navigation-sidebar/navigation-panel/menus/content-categories.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/menus/content-pages.js +0 -65
- package/build-module/components/navigation-sidebar/navigation-panel/menus/content-pages.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/menus/content-posts.js +0 -90
- package/build-module/components/navigation-sidebar/navigation-panel/menus/content-posts.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/menus/index.js +0 -40
- package/build-module/components/navigation-sidebar/navigation-panel/menus/index.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js +0 -35
- package/build-module/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/menus/template-parts.js +0 -84
- package/build-module/components/navigation-sidebar/navigation-panel/menus/template-parts.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/menus/templates-sub.js +0 -50
- package/build-module/components/navigation-sidebar/navigation-panel/menus/templates-sub.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/menus/templates.js +0 -124
- package/build-module/components/navigation-sidebar/navigation-panel/menus/templates.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/navigation-entity-items.js +0 -65
- package/build-module/components/navigation-sidebar/navigation-panel/navigation-entity-items.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/new-template-dropdown.js +0 -106
- package/build-module/components/navigation-sidebar/navigation-panel/new-template-dropdown.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/search-results.js +0 -116
- package/build-module/components/navigation-sidebar/navigation-panel/search-results.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/template-navigation-item.js +0 -71
- package/build-module/components/navigation-sidebar/navigation-panel/template-navigation-item.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/template-preview.js +0 -38
- package/build-module/components/navigation-sidebar/navigation-panel/template-preview.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/use-debounced-search.js +0 -37
- package/build-module/components/navigation-sidebar/navigation-panel/use-debounced-search.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/utils.js +0 -8
- package/build-module/components/navigation-sidebar/navigation-panel/utils.js.map +0 -1
- package/build-module/utils/get-closest-available-template.js +0 -40
- package/build-module/utils/get-closest-available-template.js.map +0 -1
- package/src/components/navigation-sidebar/navigation-panel/content-navigation-item.js +0 -89
- package/src/components/navigation-sidebar/navigation-panel/menus/content-categories.js +0 -85
- package/src/components/navigation-sidebar/navigation-panel/menus/content-pages.js +0 -85
- package/src/components/navigation-sidebar/navigation-panel/menus/content-posts.js +0 -117
- package/src/components/navigation-sidebar/navigation-panel/menus/index.js +0 -61
- package/src/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js +0 -34
- package/src/components/navigation-sidebar/navigation-panel/menus/template-parts.js +0 -94
- package/src/components/navigation-sidebar/navigation-panel/menus/templates-sub.js +0 -42
- package/src/components/navigation-sidebar/navigation-panel/menus/templates.js +0 -147
- package/src/components/navigation-sidebar/navigation-panel/navigation-entity-items.js +0 -53
- package/src/components/navigation-sidebar/navigation-panel/new-template-dropdown.js +0 -110
- package/src/components/navigation-sidebar/navigation-panel/search-results.js +0 -117
- package/src/components/navigation-sidebar/navigation-panel/template-navigation-item.js +0 -83
- package/src/components/navigation-sidebar/navigation-panel/template-preview.js +0 -32
- package/src/components/navigation-sidebar/navigation-panel/use-debounced-search.js +0 -47
- package/src/components/navigation-sidebar/navigation-panel/utils.js +0 -11
- package/src/utils/get-closest-available-template.js +0 -31
package/build-module/components/navigation-sidebar/navigation-panel/navigation-entity-items.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/navigation-entity-items.js"],"names":["useDispatch","useSelect","__experimentalNavigationItem","NavigationItem","getPathAndQueryString","store","coreStore","editSiteStore","getEntityTitle","kind","entity","name","title","rendered","NavigationEntityItems","query","entities","select","getEntityRecords","setPage","onActivateItem","type","slug","link","id","path","context","postType","postId","map","key"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,4BAA4B,IAAIC,cAAzC,QAA+D,uBAA/D;AACA,SAASC,qBAAT,QAAsC,gBAAtC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AAC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,EAA9D;AAEA,WACC,cAAC,cAAD;AACC,MAAA,GAAG,EAAGO,GADP;AAEC,MAAA,IAAI,EAAGA,GAFR;AAGC,MAAA,KAAK,EAAGtB,cAAc,CAAEC,IAAF,EAAQC,MAAR,CAHvB;AAIC,MAAA,OAAO,EAAG,MAAMU,cAAc,CAAEV,MAAF;AAJ/B,MADD;AAQA,GAXM,CAAP;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __experimentalNavigationItem as NavigationItem } from '@wordpress/components';\nimport { getPathAndQueryString } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../../store';\n\nconst getEntityTitle = ( kind, entity ) =>\n\t'taxonomy' === kind ? entity.name : entity?.title?.rendered;\n\nexport default function NavigationEntityItems( { kind, name, query = {} } ) {\n\tconst entities = useSelect(\n\t\t( select ) => select( coreStore ).getEntityRecords( kind, name, query ),\n\t\t[ kind, name, query ]\n\t);\n\n\tconst { setPage } = useDispatch( editSiteStore );\n\n\tif ( ! entities ) {\n\t\treturn null;\n\t}\n\n\tconst onActivateItem = ( { type, slug, link, id } ) => {\n\t\tsetPage( {\n\t\t\ttype,\n\t\t\tslug,\n\t\t\tpath: getPathAndQueryString( link ),\n\t\t\tcontext: {\n\t\t\t\tpostType: type,\n\t\t\t\tpostId: id,\n\t\t\t},\n\t\t} );\n\t};\n\n\treturn entities.map( ( entity ) => {\n\t\tconst key = `content-${ getPathAndQueryString( entity.link ) }`;\n\n\t\treturn (\n\t\t\t<NavigationItem\n\t\t\t\tkey={ key }\n\t\t\t\titem={ key }\n\t\t\t\ttitle={ getEntityTitle( kind, entity ) }\n\t\t\t\tonClick={ () => onActivateItem( entity ) }\n\t\t\t/>\n\t\t);\n\t} );\n}\n"]}
|
package/build-module/components/navigation-sidebar/navigation-panel/new-template-dropdown.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { filter, find, includes, map } from 'lodash';
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { DropdownMenu, MenuGroup, MenuItem, NavigableMenu } from '@wordpress/components';
|
|
12
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
13
|
-
import { __ } from '@wordpress/i18n';
|
|
14
|
-
import { Icon, plus } from '@wordpress/icons';
|
|
15
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
16
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
17
|
-
/**
|
|
18
|
-
* Internal dependencies
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
import getClosestAvailableTemplate from '../../../utils/get-closest-available-template';
|
|
22
|
-
import { TEMPLATES_NEW_OPTIONS } from './constants';
|
|
23
|
-
import { store as editSiteStore } from '../../../store';
|
|
24
|
-
export default function NewTemplateDropdown() {
|
|
25
|
-
const {
|
|
26
|
-
defaultTemplateTypes,
|
|
27
|
-
templates
|
|
28
|
-
} = useSelect(select => {
|
|
29
|
-
const {
|
|
30
|
-
__experimentalGetDefaultTemplateTypes: getDefaultTemplateTypes
|
|
31
|
-
} = select(editorStore);
|
|
32
|
-
const templateEntities = select(coreStore).getEntityRecords('postType', 'wp_template');
|
|
33
|
-
return {
|
|
34
|
-
defaultTemplateTypes: getDefaultTemplateTypes(),
|
|
35
|
-
templates: templateEntities
|
|
36
|
-
};
|
|
37
|
-
}, []);
|
|
38
|
-
const {
|
|
39
|
-
addTemplate
|
|
40
|
-
} = useDispatch(editSiteStore);
|
|
41
|
-
|
|
42
|
-
const createTemplate = slug => {
|
|
43
|
-
const closestAvailableTemplate = getClosestAvailableTemplate(slug, templates);
|
|
44
|
-
const {
|
|
45
|
-
title,
|
|
46
|
-
description
|
|
47
|
-
} = find(defaultTemplateTypes, {
|
|
48
|
-
slug
|
|
49
|
-
});
|
|
50
|
-
addTemplate({
|
|
51
|
-
content: closestAvailableTemplate.content.raw,
|
|
52
|
-
excerpt: description,
|
|
53
|
-
// Slugs need to be strings, so this is for template `404`
|
|
54
|
-
slug: slug.toString(),
|
|
55
|
-
status: 'publish',
|
|
56
|
-
title
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const existingTemplateSlugs = map(templates, 'slug');
|
|
61
|
-
const missingTemplates = filter(defaultTemplateTypes, template => includes(TEMPLATES_NEW_OPTIONS, template.slug) && !includes(existingTemplateSlugs, template.slug));
|
|
62
|
-
|
|
63
|
-
if (!missingTemplates.length) {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return createElement(DropdownMenu, {
|
|
68
|
-
className: "edit-site-navigation-panel__new-template-dropdown",
|
|
69
|
-
icon: null,
|
|
70
|
-
label: __('Add Template'),
|
|
71
|
-
popoverProps: {
|
|
72
|
-
noArrow: false
|
|
73
|
-
},
|
|
74
|
-
toggleProps: {
|
|
75
|
-
children: createElement(Icon, {
|
|
76
|
-
icon: plus
|
|
77
|
-
}),
|
|
78
|
-
isSmall: true,
|
|
79
|
-
variant: 'tertiary'
|
|
80
|
-
}
|
|
81
|
-
}, _ref => {
|
|
82
|
-
let {
|
|
83
|
-
onClose
|
|
84
|
-
} = _ref;
|
|
85
|
-
return createElement(NavigableMenu, {
|
|
86
|
-
className: "edit-site-navigation-panel__new-template-popover"
|
|
87
|
-
}, createElement(MenuGroup, {
|
|
88
|
-
label: __('Add Template')
|
|
89
|
-
}, map(missingTemplates, _ref2 => {
|
|
90
|
-
let {
|
|
91
|
-
title,
|
|
92
|
-
description,
|
|
93
|
-
slug
|
|
94
|
-
} = _ref2;
|
|
95
|
-
return createElement(MenuItem, {
|
|
96
|
-
info: description,
|
|
97
|
-
key: slug,
|
|
98
|
-
onClick: () => {
|
|
99
|
-
createTemplate(slug);
|
|
100
|
-
onClose();
|
|
101
|
-
}
|
|
102
|
-
}, title);
|
|
103
|
-
})));
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=new-template-dropdown.js.map
|
package/build-module/components/navigation-sidebar/navigation-panel/new-template-dropdown.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/new-template-dropdown.js"],"names":["filter","find","includes","map","DropdownMenu","MenuGroup","MenuItem","NavigableMenu","useDispatch","useSelect","__","Icon","plus","store","editorStore","coreStore","getClosestAvailableTemplate","TEMPLATES_NEW_OPTIONS","editSiteStore","NewTemplateDropdown","defaultTemplateTypes","templates","select","__experimentalGetDefaultTemplateTypes","getDefaultTemplateTypes","templateEntities","getEntityRecords","addTemplate","createTemplate","slug","closestAvailableTemplate","title","description","content","raw","excerpt","toString","status","existingTemplateSlugs","missingTemplates","template","length","noArrow","children","isSmall","variant","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,IAAjB,EAAuBC,QAAvB,EAAiCC,GAAjC,QAA4C,QAA5C;AAEA;AACA;AACA;;AACA,SACCC,YADD,EAECC,SAFD,EAGCC,QAHD,EAICC,aAJD,QAKO,uBALP;AAMA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,kBAA3B;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,2BAAP,MAAwC,+CAAxC;AACA,SAASC,qBAAT,QAAsC,aAAtC;AACA,SAASJ,KAAK,IAAIK,aAAlB,QAAuC,gBAAvC;AAEA,eAAe,SAASC,mBAAT,GAA+B;AAC7C,QAAM;AAAEC,IAAAA,oBAAF;AAAwBC,IAAAA;AAAx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AAxB,EAAiC;AAChC,WAAO,IAAP;AACA;;AAED,SACC,cAAC,YAAD;AACC,IAAA,SAAS,EAAC,mDADX;AAEC,IAAA,IAAI,EAAG,IAFR;AAGC,IAAA,KAAK,EAAG/B,EAAE,CAAE,cAAF,CAHX;AAIC,IAAA,YAAY,EAAG;AACdgC,MAAAA,OAAO,EAAE;AADK,KAJhB;AAOC,IAAA,WAAW,EAAG;AACbC,MAAAA,QAAQ,EAAE,cAAC,IAAD;AAAM,QAAA,IAAI,EAAG/B;AAAb,QADG;AAEbgC,MAAAA,OAAO,EAAE,IAFI;AAGbC,MAAAA,OAAO,EAAE;AAHI;AAPf,KAaG;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WACD,cAAC,aAAD;AAAe,MAAA,SAAS,EAAC;AAAzB,OACC,cAAC,SAAD;AAAW,MAAA,KAAK,EAAGpC,EAAE,CAAE,cAAF;AAArB,OACGP,GAAG,CACJoC,gBADI,EAEJ;AAAA,UAAE;AAAER,QAAAA,KAAF;AAASC,QAAAA,WAAT;AAAsBH,QAAAA;AAAtB,OAAF;AAAA,aACC,cAAC,QAAD;AACC,QAAA,IAAI,EAAGG,WADR;AAEC,QAAA,GAAG,EAAGH,IAFP;AAGC,QAAA,OAAO,EAAG,MAAM;AACfD,UAAAA,cAAc,CAAEC,IAAF,CAAd;AACAiB,UAAAA,OAAO;AACP;AANF,SAQGf,KARH,CADD;AAAA,KAFI,CADN,CADD,CADC;AAAA,GAbH,CADD;AAqCA","sourcesContent":["/**\n * External dependencies\n */\nimport { filter, find, includes, map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, plus } from '@wordpress/icons';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport getClosestAvailableTemplate from '../../../utils/get-closest-available-template';\nimport { TEMPLATES_NEW_OPTIONS } from './constants';\nimport { store as editSiteStore } from '../../../store';\n\nexport default function NewTemplateDropdown() {\n\tconst { defaultTemplateTypes, templates } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\t__experimentalGetDefaultTemplateTypes: getDefaultTemplateTypes,\n\t\t} = select( editorStore );\n\t\tconst templateEntities = select( coreStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template'\n\t\t);\n\t\treturn {\n\t\t\tdefaultTemplateTypes: getDefaultTemplateTypes(),\n\t\t\ttemplates: templateEntities,\n\t\t};\n\t}, [] );\n\tconst { addTemplate } = useDispatch( editSiteStore );\n\n\tconst createTemplate = ( slug ) => {\n\t\tconst closestAvailableTemplate = getClosestAvailableTemplate(\n\t\t\tslug,\n\t\t\ttemplates\n\t\t);\n\t\tconst { title, description } = find( defaultTemplateTypes, { slug } );\n\t\taddTemplate( {\n\t\t\tcontent: closestAvailableTemplate.content.raw,\n\t\t\texcerpt: description,\n\t\t\t// Slugs need to be strings, so this is for template `404`\n\t\t\tslug: slug.toString(),\n\t\t\tstatus: 'publish',\n\t\t\ttitle,\n\t\t} );\n\t};\n\n\tconst existingTemplateSlugs = map( templates, 'slug' );\n\n\tconst missingTemplates = filter(\n\t\tdefaultTemplateTypes,\n\t\t( template ) =>\n\t\t\tincludes( TEMPLATES_NEW_OPTIONS, template.slug ) &&\n\t\t\t! includes( existingTemplateSlugs, template.slug )\n\t);\n\n\tif ( ! missingTemplates.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"edit-site-navigation-panel__new-template-dropdown\"\n\t\t\ticon={ null }\n\t\t\tlabel={ __( 'Add Template' ) }\n\t\t\tpopoverProps={ {\n\t\t\t\tnoArrow: false,\n\t\t\t} }\n\t\t\ttoggleProps={ {\n\t\t\t\tchildren: <Icon icon={ plus } />,\n\t\t\t\tisSmall: true,\n\t\t\t\tvariant: 'tertiary',\n\t\t\t} }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<NavigableMenu className=\"edit-site-navigation-panel__new-template-popover\">\n\t\t\t\t\t<MenuGroup label={ __( 'Add Template' ) }>\n\t\t\t\t\t\t{ map(\n\t\t\t\t\t\t\tmissingTemplates,\n\t\t\t\t\t\t\t( { title, description, slug } ) => (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tinfo={ description }\n\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tcreateTemplate( slug );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</NavigableMenu>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"]}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { map, sortBy, keyBy } from 'lodash';
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { useMemo } from '@wordpress/element';
|
|
12
|
-
import { __experimentalNavigationGroup as NavigationGroup } from '@wordpress/components';
|
|
13
|
-
import { __ } from '@wordpress/i18n';
|
|
14
|
-
/**
|
|
15
|
-
* Internal dependencies
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import { normalizedSearch } from './utils';
|
|
19
|
-
import { useSelect } from '@wordpress/data';
|
|
20
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
21
|
-
import TemplateNavigationItem from './template-navigation-item';
|
|
22
|
-
import ContentNavigationItem from './content-navigation-item';
|
|
23
|
-
export default function SearchResults(_ref) {
|
|
24
|
-
let {
|
|
25
|
-
items,
|
|
26
|
-
search,
|
|
27
|
-
disableFilter
|
|
28
|
-
} = _ref;
|
|
29
|
-
let itemType = null;
|
|
30
|
-
|
|
31
|
-
if ((items === null || items === void 0 ? void 0 : items.length) > 0) {
|
|
32
|
-
if (items[0].taxonomy) {
|
|
33
|
-
itemType = 'taxonomy';
|
|
34
|
-
} else {
|
|
35
|
-
itemType = items[0].type;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const itemInfos = useSelect(select => {
|
|
40
|
-
if (itemType === null || items === null) {
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (itemType === 'wp_template') {
|
|
45
|
-
const {
|
|
46
|
-
__experimentalGetTemplateInfo: getTemplateInfo
|
|
47
|
-
} = select(editorStore);
|
|
48
|
-
return items.map(item => ({
|
|
49
|
-
slug: item.slug,
|
|
50
|
-
...getTemplateInfo(item)
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (itemType === 'taxonomy') {
|
|
55
|
-
return items.map(item => ({
|
|
56
|
-
slug: item.slug,
|
|
57
|
-
title: item.name,
|
|
58
|
-
description: item.description
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return items.map(item => {
|
|
63
|
-
var _item$title, _item$excerpt;
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
slug: item.slug,
|
|
67
|
-
title: (_item$title = item.title) === null || _item$title === void 0 ? void 0 : _item$title.rendered,
|
|
68
|
-
description: (_item$excerpt = item.excerpt) === null || _item$excerpt === void 0 ? void 0 : _item$excerpt.rendered
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
}, [items, itemType]);
|
|
72
|
-
const itemInfosMap = useMemo(() => keyBy(itemInfos, 'slug'), [itemInfos]);
|
|
73
|
-
const itemsFiltered = useMemo(() => {
|
|
74
|
-
if (items === null || search.length === 0) {
|
|
75
|
-
return [];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (disableFilter) {
|
|
79
|
-
return items;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return items.filter(_ref2 => {
|
|
83
|
-
let {
|
|
84
|
-
slug
|
|
85
|
-
} = _ref2;
|
|
86
|
-
const {
|
|
87
|
-
title,
|
|
88
|
-
description
|
|
89
|
-
} = itemInfosMap[slug];
|
|
90
|
-
return normalizedSearch(slug, search) || normalizedSearch(title, search) || normalizedSearch(description, search);
|
|
91
|
-
});
|
|
92
|
-
}, [items, itemInfos, search]);
|
|
93
|
-
const itemsSorted = useMemo(() => {
|
|
94
|
-
if (!itemsFiltered) {
|
|
95
|
-
return [];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return sortBy(itemsFiltered, [_ref3 => {
|
|
99
|
-
let {
|
|
100
|
-
slug
|
|
101
|
-
} = _ref3;
|
|
102
|
-
const {
|
|
103
|
-
title
|
|
104
|
-
} = itemInfosMap[slug];
|
|
105
|
-
return !normalizedSearch(title, search);
|
|
106
|
-
}]);
|
|
107
|
-
}, [itemsFiltered, search]);
|
|
108
|
-
const ItemComponent = itemType === 'wp_template' || itemType === 'wp_template_part' ? TemplateNavigationItem : ContentNavigationItem;
|
|
109
|
-
return createElement(NavigationGroup, {
|
|
110
|
-
title: __('Search results')
|
|
111
|
-
}, map(itemsSorted, item => createElement(ItemComponent, {
|
|
112
|
-
item: item,
|
|
113
|
-
key: `${item.taxonomy || item.type}-${item.id}`
|
|
114
|
-
})));
|
|
115
|
-
}
|
|
116
|
-
//# sourceMappingURL=search-results.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/search-results.js"],"names":["map","sortBy","keyBy","useMemo","__experimentalNavigationGroup","NavigationGroup","__","normalizedSearch","useSelect","store","editorStore","TemplateNavigationItem","ContentNavigationItem","SearchResults","items","search","disableFilter","itemType","length","taxonomy","type","itemInfos","select","__experimentalGetTemplateInfo","getTemplateInfo","item","slug","title","name","description","rendered","excerpt","itemInfosMap","itemsFiltered","filter","itemsSorted","ItemComponent","id"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,MAAd,EAAsBC,KAAtB,QAAmC,QAAnC;AAEA;AACA;AACA;;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,6BAA6B,IAAIC,eAA1C,QAAiE,uBAAjE;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,QAAiC,SAAjC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,OAAOC,sBAAP,MAAmC,4BAAnC;AACA,OAAOC,qBAAP,MAAkC,2BAAlC;AAEA,eAAe,SAASC,aAAT,OAA2D;AAAA,MAAnC;AAAEC,IAAAA,KAAF;AAASC,IAAAA,MAAT;AAAiBC,IAAAA;AAAjB,GAAmC;AACzE,MAAIC,QAAQ,GAAG,IAAf;;AACA,MAAK,CAAAH,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEI,MAAP,IAAgB,CAArB,EAAyB;AACxB,QAAKJ,KAAK,CAAE,CAAF,CAAL,CAAWK,QAAhB,EAA2B;AAC1BF,MAAAA,QAAQ,GAAG,UAAX;AACA,KAFD,MAEO;AACNA,MAAAA,QAAQ,GAAGH,KAAK,CAAE,CAAF,CAAL,CAAWM,IAAtB;AACA;AACD;;AAED,QAAMC,SAAS,GAAGb,SAAS,CACxBc,MAAF,IAAc;AACb,QAAKL,QAAQ,KAAK,IAAb,IAAqBH,KAAK,KAAK,IAApC,EAA2C;AAC1C,aAAO,EAAP;AACA;;AAED,QAAKG,QAAQ,KAAK,aAAlB,EAAkC;AACjC,YAAM;AACLM,Q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AM;AAAEC,QAAAA,KAAF;AAASE,QAAAA;AAAT,UAAyBG,YAAY,CAAEN,IAAF,CAA3C;AAEA,aACCnB,gBAAgB,CAAEmB,IAAF,EAAQX,MAAR,CAAhB,IACAR,gBAAgB,CAAEoB,KAAF,EAASZ,MAAT,CADhB,IAEAR,gBAAgB,CAAEsB,WAAF,EAAed,MAAf,CAHjB;AAKA,KARM,CAAP;AASA,GAlB4B,EAkB1B,CAAED,KAAF,EAASO,SAAT,EAAoBN,MAApB,CAlB0B,CAA7B;AAoBA,QAAMoB,WAAW,GAAGhC,OAAO,CAAE,MAAM;AAClC,QAAK,CAAE8B,aAAP,EAAuB;AACtB,aAAO,EAAP;AACA;;AAED,WAAOhC,MAAM,CAAEgC,aAAF,EAAiB,CAC7B,SAAgB;AAAA,UAAd;AAAEP,QAAAA;AAAF,OAAc;AACf,YAAM;AAAEC,QAAAA;AAAF,UAAYK,YAAY,CAAEN,IAAF,CAA9B;AACA,aAAO,CAAEnB,gBAAgB,CAAEoB,KAAF,EAASZ,MAAT,CAAzB;AACA,KAJ4B,CAAjB,CAAb;AAMA,GAX0B,EAWxB,CAAEkB,aAAF,EAAiBlB,MAAjB,CAXwB,CAA3B;AAaA,QAAMqB,aAAa,GAClBnB,QAAQ,KAAK,aAAb,IAA8BA,QAAQ,KAAK,kBAA3C,GACGN,sBADH,GAEGC,qBAHJ;AAKA,SACC,cAAC,eAAD;AAAiB,IAAA,KAAK,EAAGN,EAAE,CAAE,gBAAF;AAA3B,KACGN,GAAG,CAAEmC,WAAF,EAAiBV,IAAF,IACnB,cAAC,aAAD;AACC,IAAA,IAAI,EAAGA,IADR;AAEC,IAAA,GAAG,EAAI,GAAGA,IAAI,CAACN,QAAL,IAAiBM,IAAI,CAACL,IAAM,IAAIK,IAAI,CAACY,EAAI;AAFpD,IADI,CADN,CADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport { map, sortBy, keyBy } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { __experimentalNavigationGroup as NavigationGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { normalizedSearch } from './utils';\nimport { useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport TemplateNavigationItem from './template-navigation-item';\nimport ContentNavigationItem from './content-navigation-item';\n\nexport default function SearchResults( { items, search, disableFilter } ) {\n\tlet itemType = null;\n\tif ( items?.length > 0 ) {\n\t\tif ( items[ 0 ].taxonomy ) {\n\t\t\titemType = 'taxonomy';\n\t\t} else {\n\t\t\titemType = items[ 0 ].type;\n\t\t}\n\t}\n\n\tconst itemInfos = useSelect(\n\t\t( select ) => {\n\t\t\tif ( itemType === null || items === null ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif ( itemType === 'wp_template' ) {\n\t\t\t\tconst {\n\t\t\t\t\t__experimentalGetTemplateInfo: getTemplateInfo,\n\t\t\t\t} = select( editorStore );\n\n\t\t\t\treturn items.map( ( item ) => ( {\n\t\t\t\t\tslug: item.slug,\n\t\t\t\t\t...getTemplateInfo( item ),\n\t\t\t\t} ) );\n\t\t\t}\n\n\t\t\tif ( itemType === 'taxonomy' ) {\n\t\t\t\treturn items.map( ( item ) => ( {\n\t\t\t\t\tslug: item.slug,\n\t\t\t\t\ttitle: item.name,\n\t\t\t\t\tdescription: item.description,\n\t\t\t\t} ) );\n\t\t\t}\n\n\t\t\treturn items.map( ( item ) => ( {\n\t\t\t\tslug: item.slug,\n\t\t\t\ttitle: item.title?.rendered,\n\t\t\t\tdescription: item.excerpt?.rendered,\n\t\t\t} ) );\n\t\t},\n\t\t[ items, itemType ]\n\t);\n\tconst itemInfosMap = useMemo( () => keyBy( itemInfos, 'slug' ), [\n\t\titemInfos,\n\t] );\n\n\tconst itemsFiltered = useMemo( () => {\n\t\tif ( items === null || search.length === 0 ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tif ( disableFilter ) {\n\t\t\treturn items;\n\t\t}\n\n\t\treturn items.filter( ( { slug } ) => {\n\t\t\tconst { title, description } = itemInfosMap[ slug ];\n\n\t\t\treturn (\n\t\t\t\tnormalizedSearch( slug, search ) ||\n\t\t\t\tnormalizedSearch( title, search ) ||\n\t\t\t\tnormalizedSearch( description, search )\n\t\t\t);\n\t\t} );\n\t}, [ items, itemInfos, search ] );\n\n\tconst itemsSorted = useMemo( () => {\n\t\tif ( ! itemsFiltered ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn sortBy( itemsFiltered, [\n\t\t\t( { slug } ) => {\n\t\t\t\tconst { title } = itemInfosMap[ slug ];\n\t\t\t\treturn ! normalizedSearch( title, search );\n\t\t\t},\n\t\t] );\n\t}, [ itemsFiltered, search ] );\n\n\tconst ItemComponent =\n\t\titemType === 'wp_template' || itemType === 'wp_template_part'\n\t\t\t? TemplateNavigationItem\n\t\t\t: ContentNavigationItem;\n\n\treturn (\n\t\t<NavigationGroup title={ __( 'Search results' ) }>\n\t\t\t{ map( itemsSorted, ( item ) => (\n\t\t\t\t<ItemComponent\n\t\t\t\t\titem={ item }\n\t\t\t\t\tkey={ `${ item.taxonomy || item.type }-${ item.id }` }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</NavigationGroup>\n\t);\n}\n"]}
|
package/build-module/components/navigation-sidebar/navigation-panel/template-navigation-item.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { Button, __experimentalNavigationItem as NavigationItem } from '@wordpress/components';
|
|
7
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
|
-
import { useState } from '@wordpress/element';
|
|
9
|
-
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import TemplatePreview from './template-preview';
|
|
16
|
-
import { NavigationPanelPreviewFill } from '../index';
|
|
17
|
-
import { store as editSiteStore } from '../../../store';
|
|
18
|
-
export default function TemplateNavigationItem(_ref) {
|
|
19
|
-
let {
|
|
20
|
-
item
|
|
21
|
-
} = _ref;
|
|
22
|
-
const {
|
|
23
|
-
title,
|
|
24
|
-
description
|
|
25
|
-
} = useSelect(select => {
|
|
26
|
-
var _item$title;
|
|
27
|
-
|
|
28
|
-
return 'wp_template' === item.type ? select(editorStore).__experimentalGetTemplateInfo(item) : {
|
|
29
|
-
title: (item === null || item === void 0 ? void 0 : (_item$title = item.title) === null || _item$title === void 0 ? void 0 : _item$title.rendered) || (item === null || item === void 0 ? void 0 : item.slug),
|
|
30
|
-
description: ''
|
|
31
|
-
};
|
|
32
|
-
}, []);
|
|
33
|
-
const {
|
|
34
|
-
setTemplate,
|
|
35
|
-
setTemplatePart,
|
|
36
|
-
setIsNavigationPanelOpened
|
|
37
|
-
} = useDispatch(editSiteStore);
|
|
38
|
-
const [isPreviewVisible, setIsPreviewVisible] = useState(false);
|
|
39
|
-
|
|
40
|
-
if (!item) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const onActivateItem = () => {
|
|
45
|
-
if ('wp_template' === item.type) {
|
|
46
|
-
setTemplate(item.id, item.slug);
|
|
47
|
-
} else {
|
|
48
|
-
setTemplatePart(item.id);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
setIsNavigationPanelOpened(false);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
return createElement(NavigationItem, {
|
|
55
|
-
className: "edit-site-navigation-panel__template-item",
|
|
56
|
-
item: `${item.type}-${item.id}`
|
|
57
|
-
}, createElement(Button, {
|
|
58
|
-
onClick: onActivateItem,
|
|
59
|
-
onMouseEnter: () => setIsPreviewVisible(true),
|
|
60
|
-
onMouseLeave: () => setIsPreviewVisible(false)
|
|
61
|
-
}, createElement("span", {
|
|
62
|
-
className: "edit-site-navigation-panel__info-wrapper"
|
|
63
|
-
}, createElement("div", {
|
|
64
|
-
className: "edit-site-navigation-panel__template-item-title"
|
|
65
|
-
}, 'draft' === item.status && createElement("em", null, __('[Draft]')), title), description && createElement("div", {
|
|
66
|
-
className: "edit-site-navigation-panel__template-item-description"
|
|
67
|
-
}, description))), isPreviewVisible && createElement(NavigationPanelPreviewFill, null, createElement(TemplatePreview, {
|
|
68
|
-
rawContent: item.content.raw
|
|
69
|
-
})));
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=template-navigation-item.js.map
|
package/build-module/components/navigation-sidebar/navigation-panel/template-navigation-item.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/template-navigation-item.js"],"names":["Button","__experimentalNavigationItem","NavigationItem","useDispatch","useSelect","useState","__","store","editorStore","TemplatePreview","NavigationPanelPreviewFill","editSiteStore","TemplateNavigationItem","item","title","description","select","type","__experimentalGetTemplateInfo","rendered","slug","setTemplate","setTemplatePart","setIsNavigationPanelOpened","isPreviewVisible","setIsPreviewVisible","onActivateItem","id","status","content","raw"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,MADD,EAECC,4BAA4B,IAAIC,cAFjC,QAGO,uBAHP;AAIA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,oBAA5B;AACA,SAASC,0BAAT,QAA2C,UAA3C;AACA,SAASH,KAAK,IAAII,aAAlB,QAAuC,gBAAvC;AAEA,eAAe,SAASC,sBAAT,OAA4C;AAAA,MAAX;AAAEC,IAAAA;AAAF,GAAW;AAC1D,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT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,SAAS,EAAC;AAAhB,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,YAAYZ,IAAI,CAACe,MAAjB,IACD,0BAAMtB,EAAE,CAAE,SAAF,CAAR,CAFF,EAIGQ,KAJH,CADD,EAOGC,WAAW,IACZ;AAAK,IAAA,SAAS,EAAC;AAAf,KACGA,WADH,CARF,CALD,CAJD,EAwBGS,gBAAgB,IACjB,cAAC,0BAAD,QACC,cAAC,eAAD;AAAiB,IAAA,UAAU,EAAGX,IAAI,CAACgB,OAAL,CAAaC;AAA3C,IADD,CAzBF,CADD;AAgCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__experimentalNavigationItem as NavigationItem,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport TemplatePreview from './template-preview';\nimport { NavigationPanelPreviewFill } from '../index';\nimport { store as editSiteStore } from '../../../store';\n\nexport default function TemplateNavigationItem( { item } ) {\n\tconst { title, description } = useSelect(\n\t\t( select ) =>\n\t\t\t'wp_template' === item.type\n\t\t\t\t? select( editorStore ).__experimentalGetTemplateInfo( item )\n\t\t\t\t: {\n\t\t\t\t\t\ttitle: item?.title?.rendered || item?.slug,\n\t\t\t\t\t\tdescription: '',\n\t\t\t\t },\n\t\t[]\n\t);\n\tconst {\n\t\tsetTemplate,\n\t\tsetTemplatePart,\n\t\tsetIsNavigationPanelOpened,\n\t} = useDispatch( editSiteStore );\n\tconst [ isPreviewVisible, setIsPreviewVisible ] = useState( false );\n\n\tif ( ! item ) {\n\t\treturn null;\n\t}\n\n\tconst onActivateItem = () => {\n\t\tif ( 'wp_template' === item.type ) {\n\t\t\tsetTemplate( item.id, item.slug );\n\t\t} else {\n\t\t\tsetTemplatePart( item.id );\n\t\t}\n\t\tsetIsNavigationPanelOpened( false );\n\t};\n\n\treturn (\n\t\t<NavigationItem\n\t\t\tclassName=\"edit-site-navigation-panel__template-item\"\n\t\t\titem={ `${ item.type }-${ item.id }` }\n\t\t>\n\t\t\t<Button\n\t\t\t\tonClick={ onActivateItem }\n\t\t\t\tonMouseEnter={ () => setIsPreviewVisible( true ) }\n\t\t\t\tonMouseLeave={ () => setIsPreviewVisible( false ) }\n\t\t\t>\n\t\t\t\t<span className=\"edit-site-navigation-panel__info-wrapper\">\n\t\t\t\t\t<div className=\"edit-site-navigation-panel__template-item-title\">\n\t\t\t\t\t\t{ 'draft' === item.status && (\n\t\t\t\t\t\t\t<em>{ __( '[Draft]' ) }</em>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</div>\n\t\t\t\t\t{ description && (\n\t\t\t\t\t\t<div className=\"edit-site-navigation-panel__template-item-description\">\n\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t</Button>\n\n\t\t\t{ isPreviewVisible && (\n\t\t\t\t<NavigationPanelPreviewFill>\n\t\t\t\t\t<TemplatePreview rawContent={ item.content.raw } />\n\t\t\t\t</NavigationPanelPreviewFill>\n\t\t\t) }\n\t\t</NavigationItem>\n\t);\n}\n"]}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { parse } from '@wordpress/blocks';
|
|
7
|
-
import { BlockPreview, BlockContextProvider } from '@wordpress/block-editor';
|
|
8
|
-
import { useMemo } from '@wordpress/element';
|
|
9
|
-
export default function TemplatePreview(_ref) {
|
|
10
|
-
let {
|
|
11
|
-
rawContent,
|
|
12
|
-
blockContext
|
|
13
|
-
} = _ref;
|
|
14
|
-
const blocks = useMemo(() => rawContent ? parse(rawContent) : [], [rawContent]);
|
|
15
|
-
|
|
16
|
-
if (!blocks || blocks.length === 0) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (blockContext) {
|
|
21
|
-
return createElement("div", {
|
|
22
|
-
className: "edit-site-navigation-panel__preview"
|
|
23
|
-
}, createElement(BlockContextProvider, {
|
|
24
|
-
value: blockContext
|
|
25
|
-
}, createElement(BlockPreview, {
|
|
26
|
-
blocks: blocks,
|
|
27
|
-
viewportWidth: 1200
|
|
28
|
-
})));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return createElement("div", {
|
|
32
|
-
className: "edit-site-navigation-panel__preview"
|
|
33
|
-
}, createElement(BlockPreview, {
|
|
34
|
-
blocks: blocks,
|
|
35
|
-
viewportWidth: 1200
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=template-preview.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/template-preview.js"],"names":["parse","BlockPreview","BlockContextProvider","useMemo","TemplatePreview","rawContent","blockContext","blocks","length"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,mBAAtB;AACA,SAASC,YAAT,EAAuBC,oBAAvB,QAAmD,yBAAnD;AACA,SAASC,OAAT,QAAwB,oBAAxB;AAEA,eAAe,SAASC,eAAT,OAAyD;AAAA,MAA/B;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAA+B;AACvE,QAAMC,MAAM,GAAGJ,OAAO,CAAE,MAAQE,UAAU,GAAGL,KAAK,CAAEK,UAAF,CAAR,GAAyB,EAA7C,EAAmD,CACxEA,UADwE,CAAnD,CAAtB;;AAIA,MAAK,CAAEE,MAAF,IAAYA,MAAM,CAACC,MAAP,KAAkB,CAAnC,EAAuC;AACtC,WAAO,IAAP;AACA;;AAED,MAAKF,YAAL,EAAoB;AACnB,WACC;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,cAAC,oBAAD;AAAsB,MAAA,KAAK,EAAGA;AAA9B,OACC,cAAC,YAAD;AAAc,MAAA,MAAM,EAAGC,MAAvB;AAAgC,MAAA,aAAa,EAAG;AAAhD,MADD,CADD,CADD;AAOA;;AAED,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,YAAD;AAAc,IAAA,MAAM,EAAGA,MAAvB;AAAgC,IAAA,aAAa,EAAG;AAAhD,IADD,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse } from '@wordpress/blocks';\nimport { BlockPreview, BlockContextProvider } from '@wordpress/block-editor';\nimport { useMemo } from '@wordpress/element';\n\nexport default function TemplatePreview( { rawContent, blockContext } ) {\n\tconst blocks = useMemo( () => ( rawContent ? parse( rawContent ) : [] ), [\n\t\trawContent,\n\t] );\n\n\tif ( ! blocks || blocks.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tif ( blockContext ) {\n\t\treturn (\n\t\t\t<div className=\"edit-site-navigation-panel__preview\">\n\t\t\t\t<BlockContextProvider value={ blockContext }>\n\t\t\t\t\t<BlockPreview blocks={ blocks } viewportWidth={ 1200 } />\n\t\t\t\t</BlockContextProvider>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div className=\"edit-site-navigation-panel__preview\">\n\t\t\t<BlockPreview blocks={ blocks } viewportWidth={ 1200 } />\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { debounce } from 'lodash';
|
|
5
|
-
/**
|
|
6
|
-
* WordPress dependencies
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { useState, useCallback, useEffect } from '@wordpress/element';
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { SEARCH_DEBOUNCE_IN_MS } from './constants';
|
|
15
|
-
export default function useDebouncedSearch() {
|
|
16
|
-
// The value used by the NavigationMenu to control the input field.
|
|
17
|
-
const [search, setSearch] = useState(''); // The value used to actually perform the search query.
|
|
18
|
-
|
|
19
|
-
const [searchQuery, setSearchQuery] = useState('');
|
|
20
|
-
const [isDebouncing, setIsDebouncing] = useState(false);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
setIsDebouncing(false);
|
|
23
|
-
}, [searchQuery]);
|
|
24
|
-
const debouncedSetSearchQuery = useCallback(debounce(setSearchQuery, SEARCH_DEBOUNCE_IN_MS), [setSearchQuery]);
|
|
25
|
-
const onSearch = useCallback(value => {
|
|
26
|
-
setSearch(value);
|
|
27
|
-
debouncedSetSearchQuery(value);
|
|
28
|
-
setIsDebouncing(true);
|
|
29
|
-
}, [setSearch, setIsDebouncing, debouncedSetSearchQuery]);
|
|
30
|
-
return {
|
|
31
|
-
search,
|
|
32
|
-
searchQuery,
|
|
33
|
-
isDebouncing,
|
|
34
|
-
onSearch
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=use-debounced-search.js.map
|
package/build-module/components/navigation-sidebar/navigation-panel/use-debounced-search.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/use-debounced-search.js"],"names":["debounce","useState","useCallback","useEffect","SEARCH_DEBOUNCE_IN_MS","useDebouncedSearch","search","setSearch","searchQuery","setSearchQuery","isDebouncing","setIsDebouncing","debouncedSetSearchQuery","onSearch","value"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,WAAnB,EAAgCC,SAAhC,QAAiD,oBAAjD;AAEA;AACA;AACA;;AACA,SAASC,qBAAT,QAAsC,aAAtC;AAEA,eAAe,SAASC,kBAAT,GAA8B;AAC5C;AACA,QAAM,CAAEC,MAAF,EAAUC,SAAV,IAAwBN,QAAQ,CAAE,EAAF,CAAtC,CAF4C,CAG5C;;AACA,QAAM,CAAEO,WAAF,EAAeC,cAAf,IAAkCR,QAAQ,CAAE,EAAF,CAAhD;AACA,QAAM,CAAES,YAAF,EAAgBC,eAAhB,IAAoCV,QAAQ,CAAE,KAAF,CAAlD;AAEAE,EAAAA,SAAS,CAAE,MAAM;AAChBQ,IAAAA,eAAe,CAAE,KAAF,CAAf;AACA,GAFQ,EAEN,CAAEH,WAAF,CAFM,CAAT;AAIA,QAAMI,uBAAuB,GAAGV,WAAW,CAC1CF,QAAQ,CAAES,cAAF,EAAkBL,qBAAlB,CADkC,EAE1C,CAAEK,cAAF,CAF0C,CAA3C;AAKA,QAAMI,QAAQ,GAAGX,WAAW,CACzBY,KAAF,IAAa;AACZP,IAAAA,SAAS,CAAEO,KAAF,CAAT;AACAF,IAAAA,uBAAuB,CAAEE,KAAF,CAAvB;AACAH,IAAAA,eAAe,CAAE,IAAF,CAAf;AACA,GAL0B,EAM3B,CAAEJ,SAAF,EAAaI,eAAb,EAA8BC,uBAA9B,CAN2B,CAA5B;AASA,SAAO;AACNN,IAAAA,MADM;AAENE,IAAAA,WAFM;AAGNE,IAAAA,YAHM;AAING,IAAAA;AAJM,GAAP;AAMA","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useCallback, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { SEARCH_DEBOUNCE_IN_MS } from './constants';\n\nexport default function useDebouncedSearch() {\n\t// The value used by the NavigationMenu to control the input field.\n\tconst [ search, setSearch ] = useState( '' );\n\t// The value used to actually perform the search query.\n\tconst [ searchQuery, setSearchQuery ] = useState( '' );\n\tconst [ isDebouncing, setIsDebouncing ] = useState( false );\n\n\tuseEffect( () => {\n\t\tsetIsDebouncing( false );\n\t}, [ searchQuery ] );\n\n\tconst debouncedSetSearchQuery = useCallback(\n\t\tdebounce( setSearchQuery, SEARCH_DEBOUNCE_IN_MS ),\n\t\t[ setSearchQuery ]\n\t);\n\n\tconst onSearch = useCallback(\n\t\t( value ) => {\n\t\t\tsetSearch( value );\n\t\t\tdebouncedSetSearchQuery( value );\n\t\t\tsetIsDebouncing( true );\n\t\t},\n\t\t[ setSearch, setIsDebouncing, debouncedSetSearchQuery ]\n\t);\n\n\treturn {\n\t\tsearch,\n\t\tsearchQuery,\n\t\tisDebouncing,\n\t\tonSearch,\n\t};\n}\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { deburr } from 'lodash'; // @see packages/block-editor/src/components/inserter/search-items.js
|
|
5
|
-
|
|
6
|
-
export const normalizeInput = input => deburr(input).replace(/^\//, '').toLowerCase();
|
|
7
|
-
export const normalizedSearch = (title, search) => -1 !== normalizeInput(title).indexOf(normalizeInput(search));
|
|
8
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/utils.js"],"names":["deburr","normalizeInput","input","replace","toLowerCase","normalizedSearch","title","search","indexOf"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,QAAvB,C,CAEA;;AACA,OAAO,MAAMC,cAAc,GAAKC,KAAF,IAC7BF,MAAM,CAAEE,KAAF,CAAN,CAAgBC,OAAhB,CAAyB,KAAzB,EAAgC,EAAhC,EAAqCC,WAArC,EADM;AAGP,OAAO,MAAMC,gBAAgB,GAAG,CAAEC,KAAF,EAASC,MAAT,KAC/B,CAAC,CAAD,KAAON,cAAc,CAAEK,KAAF,CAAd,CAAwBE,OAAxB,CAAiCP,cAAc,CAAEM,MAAF,CAA/C,CADD","sourcesContent":["/**\n * External dependencies\n */\nimport { deburr } from 'lodash';\n\n// @see packages/block-editor/src/components/inserter/search-items.js\nexport const normalizeInput = ( input ) =>\n\tdeburr( input ).replace( /^\\//, '' ).toLowerCase();\n\nexport const normalizedSearch = ( title, search ) =>\n\t-1 !== normalizeInput( title ).indexOf( normalizeInput( search ) );\n"]}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { find } from 'lodash';
|
|
5
|
-
export default function getClosestAvailableTemplate(slug, templates) {
|
|
6
|
-
const template = find(templates, {
|
|
7
|
-
slug
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
if (template) {
|
|
11
|
-
return template;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
switch (slug) {
|
|
15
|
-
case 'single':
|
|
16
|
-
case 'page':
|
|
17
|
-
return getClosestAvailableTemplate('singular', templates);
|
|
18
|
-
|
|
19
|
-
case 'author':
|
|
20
|
-
case 'category':
|
|
21
|
-
case 'taxonomy':
|
|
22
|
-
case 'date':
|
|
23
|
-
case 'tag':
|
|
24
|
-
return getClosestAvailableTemplate('archive', templates);
|
|
25
|
-
|
|
26
|
-
case 'front-page':
|
|
27
|
-
return getClosestAvailableTemplate('home', templates);
|
|
28
|
-
|
|
29
|
-
case 'attachment':
|
|
30
|
-
return getClosestAvailableTemplate('single', templates);
|
|
31
|
-
|
|
32
|
-
case 'privacy-policy':
|
|
33
|
-
return getClosestAvailableTemplate('page', templates);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return find(templates, {
|
|
37
|
-
slug: 'index'
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=get-closest-available-template.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/utils/get-closest-available-template.js"],"names":["find","getClosestAvailableTemplate","slug","templates","template"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA,eAAe,SAASC,2BAAT,CAAsCC,IAAtC,EAA4CC,SAA5C,EAAwD;AACtE,QAAMC,QAAQ,GAAGJ,IAAI,CAAEG,SAAF,EAAa;AAAED,IAAAA;AAAF,GAAb,CAArB;;AACA,MAAKE,QAAL,EAAgB;AACf,WAAOA,QAAP;AACA;;AAED,UAASF,IAAT;AACC,SAAK,QAAL;AACA,SAAK,MAAL;AACC,aAAOD,2BAA2B,CAAE,UAAF,EAAcE,SAAd,CAAlC;;AACD,SAAK,QAAL;AACA,SAAK,UAAL;AACA,SAAK,UAAL;AACA,SAAK,MAAL;AACA,SAAK,KAAL;AACC,aAAOF,2BAA2B,CAAE,SAAF,EAAaE,SAAb,CAAlC;;AACD,SAAK,YAAL;AACC,aAAOF,2BAA2B,CAAE,MAAF,EAAUE,SAAV,CAAlC;;AACD,SAAK,YAAL;AACC,aAAOF,2BAA2B,CAAE,QAAF,EAAYE,SAAZ,CAAlC;;AACD,SAAK,gBAAL;AACC,aAAOF,2BAA2B,CAAE,MAAF,EAAUE,SAAV,CAAlC;AAfF;;AAkBA,SAAOH,IAAI,CAAEG,SAAF,EAAa;AAAED,IAAAA,IAAI,EAAE;AAAR,GAAb,CAAX;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\n\nexport default function getClosestAvailableTemplate( slug, templates ) {\n\tconst template = find( templates, { slug } );\n\tif ( template ) {\n\t\treturn template;\n\t}\n\n\tswitch ( slug ) {\n\t\tcase 'single':\n\t\tcase 'page':\n\t\t\treturn getClosestAvailableTemplate( 'singular', templates );\n\t\tcase 'author':\n\t\tcase 'category':\n\t\tcase 'taxonomy':\n\t\tcase 'date':\n\t\tcase 'tag':\n\t\t\treturn getClosestAvailableTemplate( 'archive', templates );\n\t\tcase 'front-page':\n\t\t\treturn getClosestAvailableTemplate( 'home', templates );\n\t\tcase 'attachment':\n\t\t\treturn getClosestAvailableTemplate( 'single', templates );\n\t\tcase 'privacy-policy':\n\t\t\treturn getClosestAvailableTemplate( 'page', templates );\n\t}\n\n\treturn find( templates, { slug: 'index' } );\n}\n"]}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __experimentalNavigationItem as NavigationItem } from '@wordpress/components';
|
|
5
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
-
import { useCallback, useState } from '@wordpress/element';
|
|
7
|
-
import { __ } from '@wordpress/i18n';
|
|
8
|
-
import { getPathAndQueryString } from '@wordpress/url';
|
|
9
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import { NavigationPanelPreviewFill } from '..';
|
|
15
|
-
import TemplatePreview from './template-preview';
|
|
16
|
-
import { store as editSiteStore } from '../../../store';
|
|
17
|
-
|
|
18
|
-
const getTitle = ( entity ) => {
|
|
19
|
-
const title = entity.taxonomy ? entity.name : entity?.title?.rendered;
|
|
20
|
-
|
|
21
|
-
// Make sure encoded characters are displayed as the characters they represent.
|
|
22
|
-
const titleElement = document.createElement( 'div' );
|
|
23
|
-
titleElement.innerHTML = title;
|
|
24
|
-
|
|
25
|
-
return titleElement.textContent || titleElement.innerText || '';
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default function ContentNavigationItem( { item } ) {
|
|
29
|
-
const [ isPreviewVisible, setIsPreviewVisible ] = useState( false );
|
|
30
|
-
const previewContent = useSelect(
|
|
31
|
-
( select ) => {
|
|
32
|
-
if ( ! isPreviewVisible ) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const template = select(
|
|
37
|
-
coreStore
|
|
38
|
-
).__experimentalGetTemplateForLink( item.link );
|
|
39
|
-
return template?.content;
|
|
40
|
-
},
|
|
41
|
-
[ isPreviewVisible ]
|
|
42
|
-
);
|
|
43
|
-
const { setPage, setIsNavigationPanelOpened } = useDispatch(
|
|
44
|
-
editSiteStore
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const onActivateItem = useCallback( () => {
|
|
48
|
-
const { type, slug, link, id } = item;
|
|
49
|
-
setPage( {
|
|
50
|
-
type,
|
|
51
|
-
slug,
|
|
52
|
-
path: getPathAndQueryString( link ),
|
|
53
|
-
context: {
|
|
54
|
-
postType: type,
|
|
55
|
-
postId: id,
|
|
56
|
-
},
|
|
57
|
-
} );
|
|
58
|
-
setIsNavigationPanelOpened( false );
|
|
59
|
-
}, [ setPage, item ] );
|
|
60
|
-
|
|
61
|
-
if ( ! item ) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<>
|
|
67
|
-
<NavigationItem
|
|
68
|
-
className="edit-site-navigation-panel__content-item"
|
|
69
|
-
item={ `${ item.taxonomy || item.type }-${ item.id }` }
|
|
70
|
-
title={ getTitle( item ) || __( '(no title)' ) }
|
|
71
|
-
onClick={ onActivateItem }
|
|
72
|
-
onMouseEnter={ () => setIsPreviewVisible( true ) }
|
|
73
|
-
onMouseLeave={ () => setIsPreviewVisible( false ) }
|
|
74
|
-
/>
|
|
75
|
-
|
|
76
|
-
{ isPreviewVisible && previewContent && (
|
|
77
|
-
<NavigationPanelPreviewFill>
|
|
78
|
-
<TemplatePreview
|
|
79
|
-
rawContent={ previewContent }
|
|
80
|
-
blockContext={ {
|
|
81
|
-
postType: item.type,
|
|
82
|
-
postId: item.id,
|
|
83
|
-
} }
|
|
84
|
-
/>
|
|
85
|
-
</NavigationPanelPreviewFill>
|
|
86
|
-
) }
|
|
87
|
-
</>
|
|
88
|
-
);
|
|
89
|
-
}
|