@wordpress/edit-site 3.0.19 → 3.0.24
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 -7
- package/build/components/block-editor/resizable-editor.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/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 -7
- package/build-module/components/block-editor/resizable-editor.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/plugins/site-export.js +2 -2
- package/build-module/plugins/site-export.js.map +1 -1
- package/build-style/style-rtl.css +11 -4
- package/build-style/style.css +11 -4
- package/package.json +8 -8
- package/src/components/block-editor/index.js +2 -2
- package/src/components/block-editor/resizable-editor.js +52 -12
- package/src/components/block-editor/style.scss +8 -0
- package/src/components/editor/style.scss +0 -1
- package/src/components/global-styles/style.scss +2 -1
- package/src/components/navigation-sidebar/navigation-panel/constants.js +0 -15
- package/src/components/navigation-sidebar/navigation-toggle/style.scss +8 -4
- 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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/navigation-entity-items.js"],"names":["getEntityTitle","kind","entity","name","title","rendered","NavigationEntityItems","query","entities","select","coreStore","getEntityRecords","setPage","editSiteStore","onActivateItem","type","slug","link","id","path","context","postType","postId","map","key"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGA,MAAMA,cAAc,GAAG,CAAEC,IAAF,EAAQC,MAAR;AAAA;;AAAA,SACtB,eAAeD,IAAf,GAAsBC,MAAM,CAACC,IAA7B,GAAoCD,MAApC,aAAoCA,MAApC,wCAAoCA,MAAM,CAAEE,KAA5C,kDAAoC,cAAeC,QAD7B;AAAA,CAAvB;;AAGe,SAASC,qBAAT,OAA6D;AAAA,MAA7B;AAAEL,IAAAA,IAAF;AAAQE,IAAAA,IAAR;AAAcI,IAAAA,KAAK,GAAG;AAAtB,GAA6B;AAC3E,QAAMC,QAAQ,GAAG,qBACdC,MAAF,IAAcA,MAAM,CAAEC,eAAF,CAAN,CAAoBC,gBAApB,CAAsCV,IAAtC,EAA4CE,IAA5C,EAAkDI,KAAlD,CADE,EAEhB,CAAEN,IAAF,EAAQE,IAAR,EAAcI,KAAd,CAFgB,CAAjB;AAKA,QAAM;AAAEK,IAAAA;AAAF,MAAc,uBAAaC,YAAb,CAApB;;AAEA,MAAK,CAAEL,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,QAAMM,cAAc,GAAG,SAAgC;AAAA,QAA9B;AAAEC,MAAAA,IAAF;AAAQC,MAAAA,IAAR;AAAcC,MAAAA,IAAd;AAAoBC,MAAAA;AAApB,KAA8B;AACtDN,IAAAA,OAAO,CAAE;AACRG,MAAAA,IADQ;AAERC,MAAAA,IAFQ;AAGRG,MAAAA,IAAI,EAAE,gCAAuBF,IAAvB,CAHE;AAIRG,MAAAA,OAAO,EAAE;AACRC,QAAAA,QAAQ,EAAEN,IADF;AAERO,QAAAA,MAAM,EAAEJ;AAFA;AAJD,KAAF,CAAP;AASA,GAVD;;AAYA,SAAOV,QAAQ,CAACe,GAAT,CAAgBrB,MAAF,IAAc;AAClC,UAAMsB,GAAG,GAAI,WAAW,gCAAuBtB,MAAM,CAACe,IAA9B,CAAsC,EAA9D;AAEA,WACC,4BAAC,wCAAD;AACC,MAAA,GAAG,EAAGO,GADP;AAEC,MAAA,IAAI,EAAGA,GAFR;AAGC,MAAA,KAAK,EAAGxB,cAAc,CAAEC,IAAF,EAAQC,MAAR,CAHvB;AAIC,MAAA,OAAO,EAAG,MAAMY,cAAc,CAAEZ,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"]}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = NewTemplateDropdown;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
|
-
var _components = require("@wordpress/components");
|
|
15
|
-
|
|
16
|
-
var _data = require("@wordpress/data");
|
|
17
|
-
|
|
18
|
-
var _i18n = require("@wordpress/i18n");
|
|
19
|
-
|
|
20
|
-
var _icons = require("@wordpress/icons");
|
|
21
|
-
|
|
22
|
-
var _editor = require("@wordpress/editor");
|
|
23
|
-
|
|
24
|
-
var _coreData = require("@wordpress/core-data");
|
|
25
|
-
|
|
26
|
-
var _getClosestAvailableTemplate = _interopRequireDefault(require("../../../utils/get-closest-available-template"));
|
|
27
|
-
|
|
28
|
-
var _constants = require("./constants");
|
|
29
|
-
|
|
30
|
-
var _store = require("../../../store");
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* External dependencies
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* WordPress dependencies
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Internal dependencies
|
|
42
|
-
*/
|
|
43
|
-
function NewTemplateDropdown() {
|
|
44
|
-
const {
|
|
45
|
-
defaultTemplateTypes,
|
|
46
|
-
templates
|
|
47
|
-
} = (0, _data.useSelect)(select => {
|
|
48
|
-
const {
|
|
49
|
-
__experimentalGetDefaultTemplateTypes: getDefaultTemplateTypes
|
|
50
|
-
} = select(_editor.store);
|
|
51
|
-
const templateEntities = select(_coreData.store).getEntityRecords('postType', 'wp_template');
|
|
52
|
-
return {
|
|
53
|
-
defaultTemplateTypes: getDefaultTemplateTypes(),
|
|
54
|
-
templates: templateEntities
|
|
55
|
-
};
|
|
56
|
-
}, []);
|
|
57
|
-
const {
|
|
58
|
-
addTemplate
|
|
59
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
60
|
-
|
|
61
|
-
const createTemplate = slug => {
|
|
62
|
-
const closestAvailableTemplate = (0, _getClosestAvailableTemplate.default)(slug, templates);
|
|
63
|
-
const {
|
|
64
|
-
title,
|
|
65
|
-
description
|
|
66
|
-
} = (0, _lodash.find)(defaultTemplateTypes, {
|
|
67
|
-
slug
|
|
68
|
-
});
|
|
69
|
-
addTemplate({
|
|
70
|
-
content: closestAvailableTemplate.content.raw,
|
|
71
|
-
excerpt: description,
|
|
72
|
-
// Slugs need to be strings, so this is for template `404`
|
|
73
|
-
slug: slug.toString(),
|
|
74
|
-
status: 'publish',
|
|
75
|
-
title
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const existingTemplateSlugs = (0, _lodash.map)(templates, 'slug');
|
|
80
|
-
const missingTemplates = (0, _lodash.filter)(defaultTemplateTypes, template => (0, _lodash.includes)(_constants.TEMPLATES_NEW_OPTIONS, template.slug) && !(0, _lodash.includes)(existingTemplateSlugs, template.slug));
|
|
81
|
-
|
|
82
|
-
if (!missingTemplates.length) {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return (0, _element.createElement)(_components.DropdownMenu, {
|
|
87
|
-
className: "edit-site-navigation-panel__new-template-dropdown",
|
|
88
|
-
icon: null,
|
|
89
|
-
label: (0, _i18n.__)('Add Template'),
|
|
90
|
-
popoverProps: {
|
|
91
|
-
noArrow: false
|
|
92
|
-
},
|
|
93
|
-
toggleProps: {
|
|
94
|
-
children: (0, _element.createElement)(_icons.Icon, {
|
|
95
|
-
icon: _icons.plus
|
|
96
|
-
}),
|
|
97
|
-
isSmall: true,
|
|
98
|
-
variant: 'tertiary'
|
|
99
|
-
}
|
|
100
|
-
}, _ref => {
|
|
101
|
-
let {
|
|
102
|
-
onClose
|
|
103
|
-
} = _ref;
|
|
104
|
-
return (0, _element.createElement)(_components.NavigableMenu, {
|
|
105
|
-
className: "edit-site-navigation-panel__new-template-popover"
|
|
106
|
-
}, (0, _element.createElement)(_components.MenuGroup, {
|
|
107
|
-
label: (0, _i18n.__)('Add Template')
|
|
108
|
-
}, (0, _lodash.map)(missingTemplates, _ref2 => {
|
|
109
|
-
let {
|
|
110
|
-
title,
|
|
111
|
-
description,
|
|
112
|
-
slug
|
|
113
|
-
} = _ref2;
|
|
114
|
-
return (0, _element.createElement)(_components.MenuItem, {
|
|
115
|
-
info: description,
|
|
116
|
-
key: slug,
|
|
117
|
-
onClick: () => {
|
|
118
|
-
createTemplate(slug);
|
|
119
|
-
onClose();
|
|
120
|
-
}
|
|
121
|
-
}, title);
|
|
122
|
-
})));
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
//# sourceMappingURL=new-template-dropdown.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/new-template-dropdown.js"],"names":["NewTemplateDropdown","defaultTemplateTypes","templates","select","__experimentalGetDefaultTemplateTypes","getDefaultTemplateTypes","editorStore","templateEntities","coreStore","getEntityRecords","addTemplate","editSiteStore","createTemplate","slug","closestAvailableTemplate","title","description","content","raw","excerpt","toString","status","existingTemplateSlugs","missingTemplates","template","TEMPLATES_NEW_OPTIONS","length","noArrow","children","plus","isSmall","variant","onClose"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAKe,SAASA,mBAAT,GAA+B;AAC7C,QAAM;AAAEC,IAAAA,oBAAF;AAAwBC,IAAAA;AAAxB,MAAsC,qBAAaC,MAAF,IAAc;AACpE,UAAM;AACLC,MAAAA,qCAAqC,EAAEC;AADlC,QAEFF,MAAM,CAAEG,aAAF,CAFV;AAGA,UAAMC,gBAAgB,GAAGJ,MAAM,CAAEK,eAAF,CAAN,CAAoBC,gBAApB,CACxB,UADwB,EAExB,aAFwB,CAAzB;AAIA,WAAO;AACNR,MAAAA,oBAAoB,EAAEI,uBAAuB,EADvC;AAENH,MAAAA,SAAS,EAAEK;AAFL,KAAP;AAIA,GAZ2C,EAYzC,EAZyC,CAA5C;AAaA,QAAM;AAAEG,IAAAA;AAAF,MAAkB,uBAAaC,YAAb,CAAxB;;AAEA,QAAMC,cAAc,GAAKC,IAAF,IAAY;AAClC,UAAMC,wBAAwB,GAAG,0CAChCD,IADgC,EAEhCX,SAFgC,CAAjC;AAIA,UAAM;AAAEa,MAAAA,KAAF;AAASC,MAAAA;AAAT,QAAyB,kBAAMf,oBAAN,EAA4B;AAAEY,MAAAA;AAAF,KAA5B,CAA/B;AACAH,IAAAA,WAAW,CAAE;AACZO,MAAAA,OAAO,EAAEH,wBAAwB,CAACG,OAAzB,CAAiCC,GAD9B;AAEZC,MAAAA,OAAO,EAAEH,WAFG;AAGZ;AACAH,MAAAA,IAAI,EAAEA,IAAI,CAACO,QAAL,EAJM;AAKZC,MAAAA,MAAM,EAAE,SALI;AAMZN,MAAAA;AANY,KAAF,CAAX;AAQA,GAdD;;AAgBA,QAAMO,qBAAqB,GAAG,iBAAKpB,SAAL,EAAgB,MAAhB,CAA9B;AAEA,QAAMqB,gBAAgB,GAAG,oBACxBtB,oBADwB,EAEtBuB,QAAF,IACC,sBAAUC,gCAAV,EAAiCD,QAAQ,CAACX,IAA1C,KACA,CAAE,sBAAUS,qBAAV,EAAiCE,QAAQ,CAACX,IAA1C,CAJqB,CAAzB;;AAOA,MAAK,CAAEU,gBAAgB,CAACG,MAAxB,EAAiC;AAChC,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,wBAAD;AACC,IAAA,SAAS,EAAC,mDADX;AAEC,IAAA,IAAI,EAAG,IAFR;AAGC,IAAA,KAAK,EAAG,cAAI,cAAJ,CAHT;AAIC,IAAA,YAAY,EAAG;AACdC,MAAAA,OAAO,EAAE;AADK,KAJhB;AAOC,IAAA,WAAW,EAAG;AACbC,MAAAA,QAAQ,EAAE,4BAAC,WAAD;AAAM,QAAA,IAAI,EAAGC;AAAb,QADG;AAEbC,MAAAA,OAAO,EAAE,IAFI;AAGbC,MAAAA,OAAO,EAAE;AAHI;AAPf,KAaG;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WACD,4BAAC,yBAAD;AAAe,MAAA,SAAS,EAAC;AAAzB,OACC,4BAAC,qBAAD;AAAW,MAAA,KAAK,EAAG,cAAI,cAAJ;AAAnB,OACG,iBACDT,gBADC,EAED;AAAA,UAAE;AAAER,QAAAA,KAAF;AAASC,QAAAA,WAAT;AAAsBH,QAAAA;AAAtB,OAAF;AAAA,aACC,4BAAC,oBAAD;AACC,QAAA,IAAI,EAAGG,WADR;AAEC,QAAA,GAAG,EAAGH,IAFP;AAGC,QAAA,OAAO,EAAG,MAAM;AACfD,UAAAA,cAAc,CAAEC,IAAF,CAAd;AACAmB,UAAAA,OAAO;AACP;AANF,SAQGjB,KARH,CADD;AAAA,KAFC,CADH,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,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = SearchResults;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
|
-
var _components = require("@wordpress/components");
|
|
15
|
-
|
|
16
|
-
var _i18n = require("@wordpress/i18n");
|
|
17
|
-
|
|
18
|
-
var _utils = require("./utils");
|
|
19
|
-
|
|
20
|
-
var _data = require("@wordpress/data");
|
|
21
|
-
|
|
22
|
-
var _editor = require("@wordpress/editor");
|
|
23
|
-
|
|
24
|
-
var _templateNavigationItem = _interopRequireDefault(require("./template-navigation-item"));
|
|
25
|
-
|
|
26
|
-
var _contentNavigationItem = _interopRequireDefault(require("./content-navigation-item"));
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* External dependencies
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* WordPress dependencies
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Internal dependencies
|
|
38
|
-
*/
|
|
39
|
-
function SearchResults(_ref) {
|
|
40
|
-
let {
|
|
41
|
-
items,
|
|
42
|
-
search,
|
|
43
|
-
disableFilter
|
|
44
|
-
} = _ref;
|
|
45
|
-
let itemType = null;
|
|
46
|
-
|
|
47
|
-
if ((items === null || items === void 0 ? void 0 : items.length) > 0) {
|
|
48
|
-
if (items[0].taxonomy) {
|
|
49
|
-
itemType = 'taxonomy';
|
|
50
|
-
} else {
|
|
51
|
-
itemType = items[0].type;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const itemInfos = (0, _data.useSelect)(select => {
|
|
56
|
-
if (itemType === null || items === null) {
|
|
57
|
-
return [];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (itemType === 'wp_template') {
|
|
61
|
-
const {
|
|
62
|
-
__experimentalGetTemplateInfo: getTemplateInfo
|
|
63
|
-
} = select(_editor.store);
|
|
64
|
-
return items.map(item => ({
|
|
65
|
-
slug: item.slug,
|
|
66
|
-
...getTemplateInfo(item)
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (itemType === 'taxonomy') {
|
|
71
|
-
return items.map(item => ({
|
|
72
|
-
slug: item.slug,
|
|
73
|
-
title: item.name,
|
|
74
|
-
description: item.description
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return items.map(item => {
|
|
79
|
-
var _item$title, _item$excerpt;
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
slug: item.slug,
|
|
83
|
-
title: (_item$title = item.title) === null || _item$title === void 0 ? void 0 : _item$title.rendered,
|
|
84
|
-
description: (_item$excerpt = item.excerpt) === null || _item$excerpt === void 0 ? void 0 : _item$excerpt.rendered
|
|
85
|
-
};
|
|
86
|
-
});
|
|
87
|
-
}, [items, itemType]);
|
|
88
|
-
const itemInfosMap = (0, _element.useMemo)(() => (0, _lodash.keyBy)(itemInfos, 'slug'), [itemInfos]);
|
|
89
|
-
const itemsFiltered = (0, _element.useMemo)(() => {
|
|
90
|
-
if (items === null || search.length === 0) {
|
|
91
|
-
return [];
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (disableFilter) {
|
|
95
|
-
return items;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return items.filter(_ref2 => {
|
|
99
|
-
let {
|
|
100
|
-
slug
|
|
101
|
-
} = _ref2;
|
|
102
|
-
const {
|
|
103
|
-
title,
|
|
104
|
-
description
|
|
105
|
-
} = itemInfosMap[slug];
|
|
106
|
-
return (0, _utils.normalizedSearch)(slug, search) || (0, _utils.normalizedSearch)(title, search) || (0, _utils.normalizedSearch)(description, search);
|
|
107
|
-
});
|
|
108
|
-
}, [items, itemInfos, search]);
|
|
109
|
-
const itemsSorted = (0, _element.useMemo)(() => {
|
|
110
|
-
if (!itemsFiltered) {
|
|
111
|
-
return [];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return (0, _lodash.sortBy)(itemsFiltered, [_ref3 => {
|
|
115
|
-
let {
|
|
116
|
-
slug
|
|
117
|
-
} = _ref3;
|
|
118
|
-
const {
|
|
119
|
-
title
|
|
120
|
-
} = itemInfosMap[slug];
|
|
121
|
-
return !(0, _utils.normalizedSearch)(title, search);
|
|
122
|
-
}]);
|
|
123
|
-
}, [itemsFiltered, search]);
|
|
124
|
-
const ItemComponent = itemType === 'wp_template' || itemType === 'wp_template_part' ? _templateNavigationItem.default : _contentNavigationItem.default;
|
|
125
|
-
return (0, _element.createElement)(_components.__experimentalNavigationGroup, {
|
|
126
|
-
title: (0, _i18n.__)('Search results')
|
|
127
|
-
}, (0, _lodash.map)(itemsSorted, item => (0, _element.createElement)(ItemComponent, {
|
|
128
|
-
item: item,
|
|
129
|
-
key: `${item.taxonomy || item.type}-${item.id}`
|
|
130
|
-
})));
|
|
131
|
-
}
|
|
132
|
-
//# 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":["SearchResults","items","search","disableFilter","itemType","length","taxonomy","type","itemInfos","select","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","map","item","slug","title","name","description","rendered","excerpt","itemInfosMap","itemsFiltered","filter","itemsSorted","ItemComponent","TemplateNavigationItem","ContentNavigationItem","id"],"mappings":"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","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"]}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = TemplateNavigationItem;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _components = require("@wordpress/components");
|
|
13
|
-
|
|
14
|
-
var _data = require("@wordpress/data");
|
|
15
|
-
|
|
16
|
-
var _i18n = require("@wordpress/i18n");
|
|
17
|
-
|
|
18
|
-
var _editor = require("@wordpress/editor");
|
|
19
|
-
|
|
20
|
-
var _templatePreview = _interopRequireDefault(require("./template-preview"));
|
|
21
|
-
|
|
22
|
-
var _index = require("../index");
|
|
23
|
-
|
|
24
|
-
var _store = require("../../../store");
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* WordPress dependencies
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Internal dependencies
|
|
32
|
-
*/
|
|
33
|
-
function TemplateNavigationItem(_ref) {
|
|
34
|
-
let {
|
|
35
|
-
item
|
|
36
|
-
} = _ref;
|
|
37
|
-
const {
|
|
38
|
-
title,
|
|
39
|
-
description
|
|
40
|
-
} = (0, _data.useSelect)(select => {
|
|
41
|
-
var _item$title;
|
|
42
|
-
|
|
43
|
-
return 'wp_template' === item.type ? select(_editor.store).__experimentalGetTemplateInfo(item) : {
|
|
44
|
-
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),
|
|
45
|
-
description: ''
|
|
46
|
-
};
|
|
47
|
-
}, []);
|
|
48
|
-
const {
|
|
49
|
-
setTemplate,
|
|
50
|
-
setTemplatePart,
|
|
51
|
-
setIsNavigationPanelOpened
|
|
52
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
53
|
-
const [isPreviewVisible, setIsPreviewVisible] = (0, _element.useState)(false);
|
|
54
|
-
|
|
55
|
-
if (!item) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const onActivateItem = () => {
|
|
60
|
-
if ('wp_template' === item.type) {
|
|
61
|
-
setTemplate(item.id, item.slug);
|
|
62
|
-
} else {
|
|
63
|
-
setTemplatePart(item.id);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
setIsNavigationPanelOpened(false);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
return (0, _element.createElement)(_components.__experimentalNavigationItem, {
|
|
70
|
-
className: "edit-site-navigation-panel__template-item",
|
|
71
|
-
item: `${item.type}-${item.id}`
|
|
72
|
-
}, (0, _element.createElement)(_components.Button, {
|
|
73
|
-
onClick: onActivateItem,
|
|
74
|
-
onMouseEnter: () => setIsPreviewVisible(true),
|
|
75
|
-
onMouseLeave: () => setIsPreviewVisible(false)
|
|
76
|
-
}, (0, _element.createElement)("span", {
|
|
77
|
-
className: "edit-site-navigation-panel__info-wrapper"
|
|
78
|
-
}, (0, _element.createElement)("div", {
|
|
79
|
-
className: "edit-site-navigation-panel__template-item-title"
|
|
80
|
-
}, 'draft' === item.status && (0, _element.createElement)("em", null, (0, _i18n.__)('[Draft]')), title), description && (0, _element.createElement)("div", {
|
|
81
|
-
className: "edit-site-navigation-panel__template-item-description"
|
|
82
|
-
}, description))), isPreviewVisible && (0, _element.createElement)(_index.NavigationPanelPreviewFill, null, (0, _element.createElement)(_templatePreview.default, {
|
|
83
|
-
rawContent: item.content.raw
|
|
84
|
-
})));
|
|
85
|
-
}
|
|
86
|
-
//# sourceMappingURL=template-navigation-item.js.map
|
package/build/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":["TemplateNavigationItem","item","title","description","select","type","editorStore","__experimentalGetTemplateInfo","rendered","slug","setTemplate","setTemplatePart","setIsNavigationPanelOpened","editSiteStore","isPreviewVisible","setIsPreviewVisible","onActivateItem","id","status","content","raw"],"mappings":";;;;;;;;;AAQA;;AALA;;AAIA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAUA;AACA;AACA;AAKe,SAASA,sBAAT,OAA4C;AAAA,MAAX;AAAEC,IAAAA;AAAF,GAAW;AAC1D,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAyB,qBAC5BC,MAAF;AAAA;;AAAA,WACC,kBAAkBH,IAAI,CAACI,IAAvB,GACGD,MAAM,CAAEE,aAAF,CAAN,CAAsBC,6BAAtB,CAAqDN,IAArD,CADH,GAEG;AACAC,MAAAA,KAAK,EAAE,CAAAD,IAAI,SAAJ,IAAAA,IAAI,WAAJ,2BAAAA,IAAI,CAAEC,KAAN,4DAAaM,QAAb,MAAyBP,IAAzB,aAAyBA,IAAzB,uBAAyBA,IAAI,CAAEQ,IAA/B,CADP;AAEAN,MAAAA,WAAW,EAAE;AAFb,KAHJ;AAAA,GAD8B,EAQ9B,EAR8B,CAA/B;AAUA,QAAM;AACLO,IAAAA,WADK;AAELC,IAAAA,eAFK;AAGLC,IAAAA;AAHK,MAIF,uBAAaC,YAAb,CAJJ;AAKA,QAAM,CAAEC,gBAAF,EAAoBC,mBAApB,IAA4C,uBAAU,KAAV,CAAlD;;AAEA,MAAK,CAAEd,IAAP,EAAc;AACb,WAAO,IAAP;AACA;;AAED,QAAMe,cAAc,GAAG,MAAM;AAC5B,QAAK,kBAAkBf,IAAI,CAACI,IAA5B,EAAmC;AAClCK,MAAAA,WAAW,CAAET,IAAI,CAACgB,EAAP,EAAWhB,IAAI,CAACQ,IAAhB,CAAX;AACA,KAFD,MAEO;AACNE,MAAAA,eAAe,CAAEV,IAAI,CAACgB,EAAP,CAAf;AACA;;AACDL,IAAAA,0BAA0B,CAAE,KAAF,CAA1B;AACA,GAPD;;AASA,SACC,4BAAC,wCAAD;AACC,IAAA,SAAS,EAAC,2CADX;AAEC,IAAA,IAAI,EAAI,GAAGX,IAAI,CAACI,IAAM,IAAIJ,IAAI,CAACgB,EAAI;AAFpC,KAIC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAGD,cADX;AAEC,IAAA,YAAY,EAAG,MAAMD,mBAAmB,CAAE,IAAF,CAFzC;AAGC,IAAA,YAAY,EAAG,MAAMA,mBAAmB,CAAE,KAAF;AAHzC,KAKC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,YAAYd,IAAI,CAACiB,MAAjB,IACD,wCAAM,cAAI,SAAJ,CAAN,CAFF,EAIGhB,KAJH,CADD,EAOGC,WAAW,IACZ;AAAK,IAAA,SAAS,EAAC;AAAf,KACGA,WADH,CARF,CALD,CAJD,EAwBGW,gBAAgB,IACjB,4BAAC,iCAAD,QACC,4BAAC,wBAAD;AAAiB,IAAA,UAAU,EAAGb,IAAI,CAACkB,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,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = TemplatePreview;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
var _blocks = require("@wordpress/blocks");
|
|
11
|
-
|
|
12
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* WordPress dependencies
|
|
16
|
-
*/
|
|
17
|
-
function TemplatePreview(_ref) {
|
|
18
|
-
let {
|
|
19
|
-
rawContent,
|
|
20
|
-
blockContext
|
|
21
|
-
} = _ref;
|
|
22
|
-
const blocks = (0, _element.useMemo)(() => rawContent ? (0, _blocks.parse)(rawContent) : [], [rawContent]);
|
|
23
|
-
|
|
24
|
-
if (!blocks || blocks.length === 0) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (blockContext) {
|
|
29
|
-
return (0, _element.createElement)("div", {
|
|
30
|
-
className: "edit-site-navigation-panel__preview"
|
|
31
|
-
}, (0, _element.createElement)(_blockEditor.BlockContextProvider, {
|
|
32
|
-
value: blockContext
|
|
33
|
-
}, (0, _element.createElement)(_blockEditor.BlockPreview, {
|
|
34
|
-
blocks: blocks,
|
|
35
|
-
viewportWidth: 1200
|
|
36
|
-
})));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return (0, _element.createElement)("div", {
|
|
40
|
-
className: "edit-site-navigation-panel__preview"
|
|
41
|
-
}, (0, _element.createElement)(_blockEditor.BlockPreview, {
|
|
42
|
-
blocks: blocks,
|
|
43
|
-
viewportWidth: 1200
|
|
44
|
-
}));
|
|
45
|
-
}
|
|
46
|
-
//# 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":["TemplatePreview","rawContent","blockContext","blocks","length"],"mappings":";;;;;;;AAKA;;AAFA;;AACA;;AAJA;AACA;AACA;AAKe,SAASA,eAAT,OAAyD;AAAA,MAA/B;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAA+B;AACvE,QAAMC,MAAM,GAAG,sBAAS,MAAQF,UAAU,GAAG,mBAAOA,UAAP,CAAH,GAAyB,EAApD,EAA0D,CACxEA,UADwE,CAA1D,CAAf;;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,4BAAC,iCAAD;AAAsB,MAAA,KAAK,EAAGA;AAA9B,OACC,4BAAC,yBAAD;AAAc,MAAA,MAAM,EAAGC,MAAvB;AAAgC,MAAA,aAAa,EAAG;AAAhD,MADD,CADD,CADD;AAOA;;AAED,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,yBAAD;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,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = useDebouncedSearch;
|
|
7
|
-
|
|
8
|
-
var _lodash = require("lodash");
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _constants = require("./constants");
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* External dependencies
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* WordPress dependencies
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Internal dependencies
|
|
24
|
-
*/
|
|
25
|
-
function useDebouncedSearch() {
|
|
26
|
-
// The value used by the NavigationMenu to control the input field.
|
|
27
|
-
const [search, setSearch] = (0, _element.useState)(''); // The value used to actually perform the search query.
|
|
28
|
-
|
|
29
|
-
const [searchQuery, setSearchQuery] = (0, _element.useState)('');
|
|
30
|
-
const [isDebouncing, setIsDebouncing] = (0, _element.useState)(false);
|
|
31
|
-
(0, _element.useEffect)(() => {
|
|
32
|
-
setIsDebouncing(false);
|
|
33
|
-
}, [searchQuery]);
|
|
34
|
-
const debouncedSetSearchQuery = (0, _element.useCallback)((0, _lodash.debounce)(setSearchQuery, _constants.SEARCH_DEBOUNCE_IN_MS), [setSearchQuery]);
|
|
35
|
-
const onSearch = (0, _element.useCallback)(value => {
|
|
36
|
-
setSearch(value);
|
|
37
|
-
debouncedSetSearchQuery(value);
|
|
38
|
-
setIsDebouncing(true);
|
|
39
|
-
}, [setSearch, setIsDebouncing, debouncedSetSearchQuery]);
|
|
40
|
-
return {
|
|
41
|
-
search,
|
|
42
|
-
searchQuery,
|
|
43
|
-
isDebouncing,
|
|
44
|
-
onSearch
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=use-debounced-search.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/use-debounced-search.js"],"names":["useDebouncedSearch","search","setSearch","searchQuery","setSearchQuery","isDebouncing","setIsDebouncing","debouncedSetSearchQuery","SEARCH_DEBOUNCE_IN_MS","onSearch","value"],"mappings":";;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAGe,SAASA,kBAAT,GAA8B;AAC5C;AACA,QAAM,CAAEC,MAAF,EAAUC,SAAV,IAAwB,uBAAU,EAAV,CAA9B,CAF4C,CAG5C;;AACA,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,EAAV,CAAxC;AACA,QAAM,CAAEC,YAAF,EAAgBC,eAAhB,IAAoC,uBAAU,KAAV,CAA1C;AAEA,0BAAW,MAAM;AAChBA,IAAAA,eAAe,CAAE,KAAF,CAAf;AACA,GAFD,EAEG,CAAEH,WAAF,CAFH;AAIA,QAAMI,uBAAuB,GAAG,0BAC/B,sBAAUH,cAAV,EAA0BI,gCAA1B,CAD+B,EAE/B,CAAEJ,cAAF,CAF+B,CAAhC;AAKA,QAAMK,QAAQ,GAAG,0BACdC,KAAF,IAAa;AACZR,IAAAA,SAAS,CAAEQ,KAAF,CAAT;AACAH,IAAAA,uBAAuB,CAAEG,KAAF,CAAvB;AACAJ,IAAAA,eAAe,CAAE,IAAF,CAAf;AACA,GALe,EAMhB,CAAEJ,SAAF,EAAaI,eAAb,EAA8BC,uBAA9B,CANgB,CAAjB;AASA,SAAO;AACNN,IAAAA,MADM;AAENE,IAAAA,WAFM;AAGNE,IAAAA,YAHM;AAINI,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,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.normalizedSearch = exports.normalizeInput = void 0;
|
|
7
|
-
|
|
8
|
-
var _lodash = require("lodash");
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* External dependencies
|
|
12
|
-
*/
|
|
13
|
-
// @see packages/block-editor/src/components/inserter/search-items.js
|
|
14
|
-
const normalizeInput = input => (0, _lodash.deburr)(input).replace(/^\//, '').toLowerCase();
|
|
15
|
-
|
|
16
|
-
exports.normalizeInput = normalizeInput;
|
|
17
|
-
|
|
18
|
-
const normalizedSearch = (title, search) => -1 !== normalizeInput(title).indexOf(normalizeInput(search));
|
|
19
|
-
|
|
20
|
-
exports.normalizedSearch = normalizedSearch;
|
|
21
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/utils.js"],"names":["normalizeInput","input","replace","toLowerCase","normalizedSearch","title","search","indexOf"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA;AACO,MAAMA,cAAc,GAAKC,KAAF,IAC7B,oBAAQA,KAAR,EAAgBC,OAAhB,CAAyB,KAAzB,EAAgC,EAAhC,EAAqCC,WAArC,EADM;;;;AAGA,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,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = getClosestAvailableTemplate;
|
|
7
|
-
|
|
8
|
-
var _lodash = require("lodash");
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* External dependencies
|
|
12
|
-
*/
|
|
13
|
-
function getClosestAvailableTemplate(slug, templates) {
|
|
14
|
-
const template = (0, _lodash.find)(templates, {
|
|
15
|
-
slug
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
if (template) {
|
|
19
|
-
return template;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
switch (slug) {
|
|
23
|
-
case 'single':
|
|
24
|
-
case 'page':
|
|
25
|
-
return getClosestAvailableTemplate('singular', templates);
|
|
26
|
-
|
|
27
|
-
case 'author':
|
|
28
|
-
case 'category':
|
|
29
|
-
case 'taxonomy':
|
|
30
|
-
case 'date':
|
|
31
|
-
case 'tag':
|
|
32
|
-
return getClosestAvailableTemplate('archive', templates);
|
|
33
|
-
|
|
34
|
-
case 'front-page':
|
|
35
|
-
return getClosestAvailableTemplate('home', templates);
|
|
36
|
-
|
|
37
|
-
case 'attachment':
|
|
38
|
-
return getClosestAvailableTemplate('single', templates);
|
|
39
|
-
|
|
40
|
-
case 'privacy-policy':
|
|
41
|
-
return getClosestAvailableTemplate('page', templates);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return (0, _lodash.find)(templates, {
|
|
45
|
-
slug: 'index'
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
//# 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":["getClosestAvailableTemplate","slug","templates","template"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGe,SAASA,2BAAT,CAAsCC,IAAtC,EAA4CC,SAA5C,EAAwD;AACtE,QAAMC,QAAQ,GAAG,kBAAMD,SAAN,EAAiB;AAAED,IAAAA;AAAF,GAAjB,CAAjB;;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,SAAO,kBAAMA,SAAN,EAAiB;AAAED,IAAAA,IAAI,EAAE;AAAR,GAAjB,CAAP;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"]}
|